aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/IRQ-affinity.txt37
-rw-r--r--Documentation/RCU/NMI-RCU.txt3
-rw-r--r--Documentation/RCU/RTFP.txt108
-rw-r--r--Documentation/RCU/checklist.txt89
-rw-r--r--Documentation/RCU/torture.txt48
-rw-r--r--Documentation/RCU/whatisRCU.txt58
-rw-r--r--Documentation/cputopology.txt26
-rw-r--r--Documentation/feature-removal-schedule.txt7
-rw-r--r--Documentation/filesystems/ext4.txt125
-rw-r--r--Documentation/filesystems/gfs2-glocks.txt114
-rw-r--r--Documentation/filesystems/proc.txt29
-rw-r--r--Documentation/ftrace.txt305
-rw-r--r--Documentation/i2c/busses/i2c-i81047
-rw-r--r--Documentation/i2c/busses/i2c-prosavage23
-rw-r--r--Documentation/i2c/busses/i2c-savage426
-rw-r--r--Documentation/i2c/fault-codes127
-rw-r--r--Documentation/i2c/smbus-protocol4
-rw-r--r--Documentation/i2c/writing-clients51
-rw-r--r--Documentation/kernel-parameters.txt9
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/alpha/Kconfig1
-rw-r--r--arch/alpha/kernel/core_marvel.c6
-rw-r--r--arch/alpha/kernel/irq.c5
-rw-r--r--arch/alpha/kernel/process.c2
-rw-r--r--arch/alpha/kernel/smp.c180
-rw-r--r--arch/alpha/oprofile/common.c6
-rw-r--r--arch/arm/Kconfig1
-rw-r--r--arch/arm/kernel/smp.c163
-rw-r--r--arch/arm/kernel/stacktrace.c1
-rw-r--r--arch/arm/oprofile/op_model_mpcore.c2
-rw-r--r--arch/arm/vfp/vfpmodule.c2
-rw-r--r--arch/avr32/kernel/stacktrace.c1
-rw-r--r--arch/cris/arch-v32/kernel/smp.c5
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/ia64/kernel/mca.c6
-rw-r--r--arch/ia64/kernel/palinfo.c2
-rw-r--r--arch/ia64/kernel/perfmon.c6
-rw-r--r--arch/ia64/kernel/process.c2
-rw-r--r--arch/ia64/kernel/smp.c254
-rw-r--r--arch/ia64/kernel/smpboot.c6
-rw-r--r--arch/ia64/kernel/uncached.c5
-rw-r--r--arch/ia64/sn/kernel/irq.c1
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c2
-rw-r--r--arch/m32r/Kconfig1
-rw-r--r--arch/m32r/kernel/m32r_ksyms.c3
-rw-r--r--arch/m32r/kernel/smp.c132
-rw-r--r--arch/m32r/kernel/traps.c3
-rw-r--r--arch/mips/Kconfig131
-rw-r--r--arch/mips/Makefile59
-rw-r--r--arch/mips/au1000/common/platform.c29
-rw-r--r--arch/mips/au1000/mtx-1/platform.c51
-rw-r--r--arch/mips/au1000/pb1200/platform.c5
-rw-r--r--arch/mips/cobalt/Makefile2
-rw-r--r--arch/mips/cobalt/lcd.c55
-rw-r--r--arch/mips/configs/atlas_defconfig1472
-rw-r--r--arch/mips/configs/bcm47xx_defconfig2
-rw-r--r--arch/mips/configs/bigsur_defconfig164
-rw-r--r--arch/mips/configs/capcella_defconfig2
-rw-r--r--arch/mips/configs/cobalt_defconfig2
-rw-r--r--arch/mips/configs/db1000_defconfig2
-rw-r--r--arch/mips/configs/db1100_defconfig2
-rw-r--r--arch/mips/configs/db1200_defconfig2
-rw-r--r--arch/mips/configs/db1500_defconfig2
-rw-r--r--arch/mips/configs/db1550_defconfig2
-rw-r--r--arch/mips/configs/decstation_defconfig2
-rw-r--r--arch/mips/configs/e55_defconfig2
-rw-r--r--arch/mips/configs/emma2rh_defconfig2
-rw-r--r--arch/mips/configs/excite_defconfig2
-rw-r--r--arch/mips/configs/fulong_defconfig2
-rw-r--r--arch/mips/configs/ip22_defconfig2
-rw-r--r--arch/mips/configs/ip27_defconfig2
-rw-r--r--arch/mips/configs/ip28_defconfig2
-rw-r--r--arch/mips/configs/ip32_defconfig2
-rw-r--r--arch/mips/configs/jazz_defconfig2
-rw-r--r--arch/mips/configs/jmr3927_defconfig190
-rw-r--r--arch/mips/configs/lasat_defconfig2
-rw-r--r--arch/mips/configs/malta_defconfig3
-rw-r--r--arch/mips/configs/mipssim_defconfig2
-rw-r--r--arch/mips/configs/mpc30x_defconfig2
-rw-r--r--arch/mips/configs/msp71xx_defconfig2
-rw-r--r--arch/mips/configs/mtx1_defconfig2
-rw-r--r--arch/mips/configs/pb1100_defconfig2
-rw-r--r--arch/mips/configs/pb1500_defconfig2
-rw-r--r--arch/mips/configs/pb1550_defconfig2
-rw-r--r--arch/mips/configs/pnx8550-jbs_defconfig2
-rw-r--r--arch/mips/configs/pnx8550-stb810_defconfig2
-rw-r--r--arch/mips/configs/rbhma4200_defconfig669
-rw-r--r--arch/mips/configs/rbtx49xx_defconfig (renamed from arch/mips/configs/rbhma4500_defconfig)208
-rw-r--r--arch/mips/configs/rm200_defconfig2
-rw-r--r--arch/mips/configs/sb1250-swarm_defconfig2
-rw-r--r--arch/mips/configs/sead_defconfig642
-rw-r--r--arch/mips/configs/tb0219_defconfig2
-rw-r--r--arch/mips/configs/tb0226_defconfig2
-rw-r--r--arch/mips/configs/tb0287_defconfig2
-rw-r--r--arch/mips/configs/workpad_defconfig2
-rw-r--r--arch/mips/configs/wrppmc_defconfig2
-rw-r--r--arch/mips/configs/yosemite_defconfig2
-rw-r--r--arch/mips/emma2rh/common/prom.c15
-rw-r--r--arch/mips/fw/arc/identify.c11
-rw-r--r--arch/mips/gt64120/wrppmc/reset.c14
-rw-r--r--arch/mips/gt64120/wrppmc/setup.c3
-rw-r--r--arch/mips/jazz/setup.c4
-rw-r--r--arch/mips/jmr3927/common/Makefile7
-rw-r--r--arch/mips/jmr3927/common/puts.c60
-rw-r--r--arch/mips/jmr3927/rbhma3100/init.c57
-rw-r--r--arch/mips/kernel/Makefile6
-rw-r--r--arch/mips/kernel/early_printk.c2
-rw-r--r--arch/mips/kernel/gpio_txx9.c10
-rw-r--r--arch/mips/kernel/i8253.c2
-rw-r--r--arch/mips/kernel/irix5sys.S1041
-rw-r--r--arch/mips/kernel/irixelf.c1361
-rw-r--r--arch/mips/kernel/irixinv.c78
-rw-r--r--arch/mips/kernel/irixioctl.c213
-rw-r--r--arch/mips/kernel/irixsig.c888
-rw-r--r--arch/mips/kernel/irq-rm9000.c4
-rw-r--r--arch/mips/kernel/irq.c4
-rw-r--r--arch/mips/kernel/mips-mt.c11
-rw-r--r--arch/mips/kernel/process.c7
-rw-r--r--arch/mips/kernel/scall32-o32.S19
-rw-r--r--arch/mips/kernel/setup.c13
-rw-r--r--arch/mips/kernel/smp.c149
-rw-r--r--arch/mips/kernel/smtc.c1
-rw-r--r--arch/mips/kernel/stacktrace.c1
-rw-r--r--arch/mips/kernel/sysirix.c2140
-rw-r--r--arch/mips/kernel/traps.c14
-rw-r--r--arch/mips/lasat/interrupt.c21
-rw-r--r--arch/mips/lasat/lasat_board.c3
-rw-r--r--arch/mips/lasat/prom.c8
-rw-r--r--arch/mips/lasat/serial.c3
-rw-r--r--arch/mips/lasat/setup.c8
-rw-r--r--arch/mips/mips-boards/atlas/Makefile22
-rw-r--r--arch/mips/mips-boards/atlas/atlas_gdb.c97
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c272
-rw-r--r--arch/mips/mips-boards/atlas/atlas_setup.c82
-rw-r--r--arch/mips/mips-boards/generic/Makefile29
-rw-r--r--arch/mips/mips-boards/malta/Makefile27
-rw-r--r--arch/mips/mips-boards/sead/Makefile28
-rw-r--r--arch/mips/mips-boards/sead/sead_int.c117
-rw-r--r--arch/mips/mips-boards/sead/sead_setup.c77
-rw-r--r--arch/mips/mm/c-r4k.c18
-rw-r--r--arch/mips/mm/uasm.c4
-rw-r--r--arch/mips/mm/uasm.h2
-rw-r--r--arch/mips/mti-malta/Makefile21
-rw-r--r--arch/mips/mti-malta/malta-amon.c (renamed from arch/mips/mips-boards/generic/amon.c)0
-rw-r--r--arch/mips/mti-malta/malta-cmdline.c (renamed from arch/mips/mips-boards/generic/cmdline.c)0
-rw-r--r--arch/mips/mti-malta/malta-console.c (renamed from arch/mips/mips-boards/generic/console.c)21
-rw-r--r--arch/mips/mti-malta/malta-display.c (renamed from arch/mips/mips-boards/generic/display.c)1
-rw-r--r--arch/mips/mti-malta/malta-init.c (renamed from arch/mips/mips-boards/generic/init.c)12
-rw-r--r--arch/mips/mti-malta/malta-int.c (renamed from arch/mips/mips-boards/malta/malta_int.c)11
-rw-r--r--arch/mips/mti-malta/malta-kgdb.c (renamed from arch/mips/mips-boards/generic/gdb_hook.c)0
-rw-r--r--arch/mips/mti-malta/malta-memory.c (renamed from arch/mips/mips-boards/generic/memory.c)6
-rw-r--r--arch/mips/mti-malta/malta-mtd.c (renamed from arch/mips/mips-boards/malta/malta_mtd.c)0
-rw-r--r--arch/mips/mti-malta/malta-pci.c (renamed from arch/mips/mips-boards/generic/pci.c)0
-rw-r--r--arch/mips/mti-malta/malta-platform.c (renamed from arch/mips/mips-boards/malta/malta_platform.c)0
-rw-r--r--arch/mips/mti-malta/malta-reset.c (renamed from arch/mips/mips-boards/generic/reset.c)19
-rw-r--r--arch/mips/mti-malta/malta-setup.c (renamed from arch/mips/mips-boards/malta/malta_setup.c)0
-rw-r--r--arch/mips/mti-malta/malta-smtc.c (renamed from arch/mips/mips-boards/malta/malta_smtc.c)0
-rw-r--r--arch/mips/mti-malta/malta-time.c (renamed from arch/mips/mips-boards/generic/time.c)23
-rw-r--r--arch/mips/nxp/pnx8550/common/platform.c9
-rw-r--r--arch/mips/oprofile/common.c6
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c4
-rw-r--r--arch/mips/pci/Makefile13
-rw-r--r--arch/mips/pci/fixup-atlas.c91
-rw-r--r--arch/mips/pci/fixup-jmr3927.c35
-rw-r--r--arch/mips/pci/fixup-rbtx4927.c119
-rw-r--r--arch/mips/pci/fixup-rbtx4938.c53
-rw-r--r--arch/mips/pci/fixup-tx4938.c92
-rw-r--r--arch/mips/pci/fixup-vr4133.c195
-rw-r--r--arch/mips/pci/ops-mace.c7
-rw-r--r--arch/mips/pci/ops-tx3927.c87
-rw-r--r--arch/mips/pci/ops-tx4927.c517
-rw-r--r--arch/mips/pci/ops-tx4938.c214
-rw-r--r--arch/mips/pci/pci-bcm1480.c3
-rw-r--r--arch/mips/pci/pci-ip27.c1
-rw-r--r--arch/mips/pci/pci-jmr3927.c58
-rw-r--r--arch/mips/pci/pci-lasat.c14
-rw-r--r--arch/mips/pci/pci-sb1250.c4
-rw-r--r--arch/mips/pci/pci-tx4927.c83
-rw-r--r--arch/mips/pci/pci-tx4938.c134
-rw-r--r--arch/mips/pci/pci.c3
-rw-r--r--arch/mips/pmc-sierra/yosemite/prom.c2
-rw-r--r--arch/mips/sgi-ip22/ip22-mc.c26
-rw-r--r--arch/mips/sgi-ip22/ip22-platform.c18
-rw-r--r--arch/mips/sgi-ip22/ip22-reset.c51
-rw-r--r--arch/mips/sgi-ip22/ip28-berr.c4
-rw-r--r--arch/mips/sgi-ip27/ip27-nmi.c10
-rw-r--r--arch/mips/sgi-ip32/ip32-platform.c36
-rw-r--r--arch/mips/sibyte/cfe/setup.c2
-rw-r--r--arch/mips/sibyte/sb1250/prom.c2
-rw-r--r--arch/mips/sibyte/swarm/Makefile1
-rw-r--r--arch/mips/sibyte/swarm/swarm-i2c.c37
-rw-r--r--arch/mips/sni/setup.c1
-rw-r--r--arch/mips/tx4927/Kconfig3
-rw-r--r--arch/mips/tx4927/common/Makefile10
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/Makefile5
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c428
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c94
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c1001
-rw-r--r--arch/mips/tx4938/Kconfig24
-rw-r--r--arch/mips/tx4938/common/Makefile8
-rw-r--r--arch/mips/tx4938/common/irq.c48
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/prom.c74
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/setup.c1124
-rw-r--r--arch/mips/txx9/Kconfig115
-rw-r--r--arch/mips/txx9/generic/Makefile12
-rw-r--r--arch/mips/txx9/generic/dbgio.c (renamed from arch/mips/tx4938/common/dbgio.c)0
-rw-r--r--arch/mips/txx9/generic/irq_tx4927.c (renamed from arch/mips/tx4927/common/tx4927_irq.c)34
-rw-r--r--arch/mips/txx9/generic/irq_tx4938.c25
-rw-r--r--arch/mips/txx9/generic/mem_tx4927.c (renamed from arch/mips/tx4927/common/tx4927_prom.c)9
-rw-r--r--arch/mips/txx9/generic/mem_tx4938.c (renamed from arch/mips/tx4938/common/prom.c)0
-rw-r--r--arch/mips/txx9/generic/pci.c388
-rw-r--r--arch/mips/txx9/generic/setup.c212
-rw-r--r--arch/mips/txx9/generic/smsc_fdc37m81x.c (renamed from arch/mips/tx4927/common/smsc_fdc37m81x.c)2
-rw-r--r--arch/mips/txx9/jmr3927/Makefile (renamed from arch/mips/jmr3927/rbhma3100/Makefile)4
-rw-r--r--arch/mips/txx9/jmr3927/irq.c (renamed from arch/mips/jmr3927/rbhma3100/irq.c)49
-rw-r--r--arch/mips/txx9/jmr3927/kgdb_io.c (renamed from arch/mips/jmr3927/rbhma3100/kgdb_io.c)2
-rw-r--r--arch/mips/txx9/jmr3927/prom.c (renamed from arch/mips/jmr3927/common/prom.c)52
-rw-r--r--arch/mips/txx9/jmr3927/setup.c (renamed from arch/mips/jmr3927/rbhma3100/setup.c)168
-rw-r--r--arch/mips/txx9/rbtx4927/Makefile3
-rw-r--r--arch/mips/txx9/rbtx4927/irq.c199
-rw-r--r--arch/mips/txx9/rbtx4927/prom.c (renamed from arch/mips/tx4927/common/tx4927_dbgio.c)29
-rw-r--r--arch/mips/txx9/rbtx4927/setup.c443
-rw-r--r--arch/mips/txx9/rbtx4938/Makefile (renamed from arch/mips/tx4938/toshiba_rbtx4938/Makefile)4
-rw-r--r--arch/mips/txx9/rbtx4938/irq.c (renamed from arch/mips/tx4938/toshiba_rbtx4938/irq.c)52
-rw-r--r--arch/mips/txx9/rbtx4938/prom.c29
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c625
-rw-r--r--arch/mips/txx9/rbtx4938/spi_eeprom.c (renamed from arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c)4
-rw-r--r--arch/mips/vr41xx/Kconfig17
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/Makefile8
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/init.c65
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/irq.c46
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/m1535plus.c249
-rw-r--r--arch/mips/vr41xx/nec-cmbvr4133/setup.c89
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/kernel/cache.c6
-rw-r--r--arch/parisc/kernel/smp.c136
-rw-r--r--arch/parisc/mm/init.c2
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c2
-rw-r--r--arch/powerpc/kernel/rtas.c2
-rw-r--r--arch/powerpc/kernel/smp.c234
-rw-r--r--arch/powerpc/kernel/stacktrace.c2
-rw-r--r--arch/powerpc/kernel/tau_6xx.c4
-rw-r--r--arch/powerpc/kernel/time.c2
-rw-r--r--arch/powerpc/mm/slice.c2
-rw-r--r--arch/powerpc/mm/tlb_64.c2
-rw-r--r--arch/powerpc/oprofile/common.c6
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c1
-rw-r--r--arch/powerpc/platforms/ps3/smp.c7
-rw-r--r--arch/powerpc/platforms/pseries/xics.c6
-rw-r--r--arch/powerpc/sysdev/mpic.c2
-rw-r--r--arch/ppc/kernel/smp.c2
-rw-r--r--arch/s390/appldata/appldata_base.c4
-rw-r--r--arch/s390/kernel/smp.c22
-rw-r--r--arch/s390/kernel/stacktrace.c2
-rw-r--r--arch/s390/kernel/time.c10
-rw-r--r--arch/sh/Kconfig1
-rw-r--r--arch/sh/kernel/smp.c62
-rw-r--r--arch/sh/kernel/stacktrace.c1
-rw-r--r--arch/sparc64/kernel/smp.c13
-rw-r--r--arch/sparc64/kernel/stacktrace.c2
-rw-r--r--arch/sparc64/mm/hugetlbpage.c2
-rw-r--r--arch/um/kernel/smp.c3
-rw-r--r--arch/x86/Kconfig23
-rw-r--r--arch/x86/kernel/acpi/sleep.c30
-rw-r--r--arch/x86/kernel/apic_32.c4
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_64.c6
-rw-r--r--arch/x86/kernel/cpu/mcheck/non-fatal.c2
-rw-r--r--arch/x86/kernel/cpu/mtrr/main.c4
-rw-r--r--arch/x86/kernel/cpu/perfctr-watchdog.c4
-rw-r--r--arch/x86/kernel/cpuid.c2
-rw-r--r--arch/x86/kernel/entry_64.S3
-rw-r--r--arch/x86/kernel/io_apic_32.c2
-rw-r--r--arch/x86/kernel/io_apic_64.c2
-rw-r--r--arch/x86/kernel/irqinit_64.c4
-rw-r--r--arch/x86/kernel/ldt.c2
-rw-r--r--arch/x86/kernel/nmi.c6
-rw-r--r--arch/x86/kernel/process.c2
-rw-r--r--arch/x86/kernel/quirks.c2
-rw-r--r--arch/x86/kernel/smp.c158
-rw-r--r--arch/x86/kernel/smpboot.c4
-rw-r--r--arch/x86/kernel/smpcommon.c56
-rw-r--r--arch/x86/kernel/stacktrace.c2
-rw-r--r--arch/x86/kernel/tlb_32.c2
-rw-r--r--arch/x86/kernel/tlb_64.c2
-rw-r--r--arch/x86/kernel/tsc.c2
-rw-r--r--arch/x86/kernel/vsyscall_64.c4
-rw-r--r--arch/x86/kvm/vmx.c4
-rw-r--r--arch/x86/kvm/x86.c2
-rw-r--r--arch/x86/lib/msr-on-cpu.c8
-rw-r--r--arch/x86/mach-voyager/voyager_smp.c98
-rw-r--r--arch/x86/mm/pageattr.c4
-rw-r--r--arch/x86/oprofile/nmi_int.c10
-rw-r--r--arch/x86/pci/amd_bus.c2
-rw-r--r--arch/x86/xen/enlighten.c4
-rw-r--r--arch/x86/xen/mmu.c2
-rw-r--r--arch/x86/xen/smp.c135
-rw-r--r--arch/x86/xen/xen-ops.h9
-rw-r--r--block/blk-core.c12
-rw-r--r--block/blk-exec.c6
-rw-r--r--crypto/async_tx/async_tx.c1
-rw-r--r--drivers/acpi/processor_idle.c2
-rw-r--r--drivers/ata/ahci.c331
-rw-r--r--drivers/ata/libata-core.c56
-rw-r--r--drivers/ata/libata-eh.c219
-rw-r--r--drivers/ata/libata-pmp.c13
-rw-r--r--drivers/ata/libata-scsi.c99
-rw-r--r--drivers/ata/libata-sff.c15
-rw-r--r--drivers/ata/libata.h2
-rw-r--r--drivers/ata/pata_bf54x.c6
-rw-r--r--drivers/ata/pata_legacy.c10
-rw-r--r--drivers/ata/pata_qdi.c2
-rw-r--r--drivers/ata/pata_scc.c2
-rw-r--r--drivers/ata/pata_winbond.c2
-rw-r--r--drivers/ata/sata_svw.c38
-rw-r--r--drivers/base/topology.c32
-rw-r--r--drivers/block/paride/pd.c20
-rw-r--r--drivers/char/agp/generic.c2
-rw-r--r--drivers/char/sysrq.c2
-rw-r--r--drivers/clocksource/acpi_pm.c19
-rw-r--r--drivers/cpuidle/cpuidle.c2
-rw-r--r--drivers/firewire/fw-card.c32
-rw-r--r--drivers/firewire/fw-device.c5
-rw-r--r--drivers/firewire/fw-device.h1
-rw-r--r--drivers/firewire/fw-ohci.c1
-rw-r--r--drivers/firewire/fw-sbp2.c25
-rw-r--r--drivers/firewire/fw-transaction.c32
-rw-r--r--drivers/firewire/fw-transaction.h34
-rw-r--r--drivers/gpu/drm/drm_memory.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c4
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c48
-rw-r--r--drivers/i2c/busses/Kconfig715
-rw-r--r--drivers/i2c/busses/Makefile57
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c38
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c38
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c32
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756.c35
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c54
-rw-r--r--drivers/i2c/busses/i2c-au1550.c130
-rw-r--r--drivers/i2c/busses/i2c-cpm.c745
-rw-r--r--drivers/i2c/busses/i2c-davinci.c89
-rw-r--r--drivers/i2c/busses/i2c-elektor.c4
-rw-r--r--drivers/i2c/busses/i2c-gpio.c2
-rw-r--r--drivers/i2c/busses/i2c-hydra.c3
-rw-r--r--drivers/i2c/busses/i2c-i801.c284
-rw-r--r--drivers/i2c/busses/i2c-i810.c260
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c206
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-isch.c339
-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-s4985.c257
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c49
-rw-r--r--drivers/i2c/busses/i2c-ocores.c44
-rw-r--r--drivers/i2c/busses/i2c-pasemi.c2
-rw-r--r--drivers/i2c/busses/i2c-pca-platform.c2
-rw-r--r--drivers/i2c/busses/i2c-piix4.c73
-rw-r--r--drivers/i2c/busses/i2c-pmcmsp.c2
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c325
-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.c185
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c8
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c29
-rw-r--r--drivers/i2c/busses/i2c-sis630.c59
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c37
-rw-r--r--drivers/i2c/busses/i2c-stub.c6
-rw-r--r--drivers/i2c/busses/i2c-taos-evm.c5
-rw-r--r--drivers/i2c/busses/i2c-via.c5
-rw-r--r--drivers/i2c/busses/i2c-viapro.c31
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c2
-rw-r--r--drivers/i2c/chips/Kconfig43
-rw-r--r--drivers/i2c/chips/Makefile1
-rw-r--r--drivers/i2c/chips/at24.c583
-rw-r--r--drivers/i2c/chips/eeprom.c81
-rw-r--r--drivers/i2c/chips/max6875.c4
-rw-r--r--drivers/i2c/chips/pca9539.c25
-rw-r--r--drivers/i2c/chips/pcf8574.c25
-rw-r--r--drivers/i2c/chips/pcf8591.c33
-rw-r--r--drivers/i2c/i2c-core.c575
-rw-r--r--drivers/i2c/i2c-dev.c12
-rw-r--r--drivers/ide/Kconfig6
-rw-r--r--drivers/ide/Makefile1
-rw-r--r--drivers/ide/arm/palm_bk3710.c3
-rw-r--r--drivers/ide/h8300/ide-h8300.c6
-rw-r--r--drivers/ide/ide-acpi.c6
-rw-r--r--drivers/ide/ide-atapi.c296
-rw-r--r--drivers/ide/ide-cd.c122
-rw-r--r--drivers/ide/ide-cd.h4
-rw-r--r--drivers/ide/ide-cd_ioctl.c113
-rw-r--r--drivers/ide/ide-disk.c13
-rw-r--r--drivers/ide/ide-dma.c4
-rw-r--r--drivers/ide/ide-floppy.c357
-rw-r--r--drivers/ide/ide-io.c114
-rw-r--r--drivers/ide/ide-iops.c38
-rw-r--r--drivers/ide/ide-probe.c10
-rw-r--r--drivers/ide/ide-tape.c561
-rw-r--r--drivers/ide/ide-taskfile.c38
-rw-r--r--drivers/ide/ide-timing.h1
-rw-r--r--drivers/ide/ide.c360
-rw-r--r--drivers/ide/legacy/ali14xx.c2
-rw-r--r--drivers/ide/legacy/gayle.c4
-rw-r--r--drivers/ide/legacy/ht6560b.c2
-rw-r--r--drivers/ide/legacy/qd65xx.c4
-rw-r--r--drivers/ide/pci/aec62xx.c2
-rw-r--r--drivers/ide/pci/alim15x3.c2
-rw-r--r--drivers/ide/pci/amd74xx.c16
-rw-r--r--drivers/ide/pci/cmd640.c8
-rw-r--r--drivers/ide/pci/cmd64x.c4
-rw-r--r--drivers/ide/pci/cy82c693.c2
-rw-r--r--drivers/ide/pci/hpt366.c3
-rw-r--r--drivers/ide/pci/ns87415.c4
-rw-r--r--drivers/ide/pci/scc_pata.c12
-rw-r--r--drivers/ide/pci/sgiioc4.c7
-rw-r--r--drivers/ide/pci/siimage.c25
-rw-r--r--drivers/ide/pci/via82cxxx.c16
-rw-r--r--drivers/ide/ppc/pmac.c6
-rw-r--r--drivers/ide/setup-pci.c4
-rw-r--r--drivers/ieee1394/csr1212.c32
-rw-r--r--drivers/ieee1394/dma.c2
-rw-r--r--drivers/ieee1394/highlevel.c4
-rw-r--r--drivers/ieee1394/highlevel.h13
-rw-r--r--drivers/ieee1394/raw1394.c20
-rw-r--r--drivers/ieee1394/sbp2.c22
-rw-r--r--drivers/ieee1394/sbp2.h1
-rw-r--r--drivers/ieee1394/video1394.c2
-rw-r--r--drivers/infiniband/core/addr.c42
-rw-r--r--drivers/infiniband/core/agent.h2
-rw-r--r--drivers/infiniband/core/cache.c2
-rw-r--r--drivers/infiniband/core/cm.c2
-rw-r--r--drivers/infiniband/core/cma.c162
-rw-r--r--drivers/infiniband/core/core_priv.h2
-rw-r--r--drivers/infiniband/core/device.c2
-rw-r--r--drivers/infiniband/core/fmr_pool.c2
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c2
-rw-r--r--drivers/infiniband/core/mad_rmpp.h2
-rw-r--r--drivers/infiniband/core/packer.c2
-rw-r--r--drivers/infiniband/core/sa_query.c24
-rw-r--r--drivers/infiniband/core/sysfs.c122
-rw-r--r--drivers/infiniband/core/ucm.c2
-rw-r--r--drivers/infiniband/core/ud_header.c2
-rw-r--r--drivers/infiniband/core/umem.c2
-rw-r--r--drivers/infiniband/core/user_mad.c2
-rw-r--r--drivers/infiniband/core/uverbs.h2
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c4
-rw-r--r--drivers/infiniband/core/uverbs_main.c2
-rw-r--r--drivers/infiniband/core/verbs.c49
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c27
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.h5
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_wr.h103
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch.c8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch.h2
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cq.c15
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c199
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.h8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_qp.c261
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c9
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_reqs.c14
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c10
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.h1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba7220.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mad.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_uc.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ud.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs_mcast.c3
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c12
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c3
-rw-r--r--drivers/infiniband/hw/mlx4/main.c7
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h3
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c73
-rw-r--r--drivers/infiniband/hw/mthca/mthca_allocator.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c17
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_config_reg.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c6
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_doorbell.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_pd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_profile.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_profile.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c32
-rw-r--r--drivers/infiniband/hw/mthca/mthca_reset.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_uar.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_user.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_wqe.h2
-rw-r--r--drivers/infiniband/hw/nes/nes.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.h9
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c68
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c33
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c207
-rw-r--r--drivers/infiniband/ulp/ipoib/Kconfig1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h48
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c104
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ethtool.c46
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c52
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c115
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c27
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c69
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c2
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c3
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h2
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c2
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c2
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c2
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c15
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
-rw-r--r--drivers/lguest/x86/core.c4
-rw-r--r--drivers/mtd/maps/Kconfig7
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/mtx-1_flash.c95
-rw-r--r--drivers/net/cxgb3/cxgb3_ctl_defs.h1
-rw-r--r--drivers/net/cxgb3/cxgb3_offload.c7
-rw-r--r--drivers/net/cxgb3/version.h2
-rw-r--r--drivers/net/macvlan.c2
-rw-r--r--drivers/net/mlx4/fw.c28
-rw-r--r--drivers/net/mlx4/fw.h6
-rw-r--r--drivers/net/mlx4/main.c7
-rw-r--r--drivers/net/mlx4/mcg.c17
-rw-r--r--drivers/scsi/a100u2w.c49
-rw-r--r--drivers/scsi/ide-scsi.c302
-rw-r--r--drivers/scsi/sd.c5
-rw-r--r--drivers/video/fb_ddc.c1
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c12
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c20
-rw-r--r--drivers/watchdog/booke_wdt.c6
-rw-r--r--firmware/Makefile4
-rw-r--r--fs/buffer.c21
-rw-r--r--fs/ext4/balloc.c209
-rw-r--r--fs/ext4/dir.c17
-rw-r--r--fs/ext4/ext4.h61
-rw-r--r--fs/ext4/ext4_extents.h1
-rw-r--r--fs/ext4/ext4_i.h10
-rw-r--r--fs/ext4/ext4_jbd2.h21
-rw-r--r--fs/ext4/ext4_sb.h5
-rw-r--r--fs/ext4/extents.c111
-rw-r--r--fs/ext4/file.c20
-rw-r--r--fs/ext4/fsync.c4
-rw-r--r--fs/ext4/group.h2
-rw-r--r--fs/ext4/ialloc.c113
-rw-r--r--fs/ext4/inode.c1591
-rw-r--r--fs/ext4/mballoc.c451
-rw-r--r--fs/ext4/namei.c45
-rw-r--r--fs/ext4/resize.c52
-rw-r--r--fs/ext4/super.c142
-rw-r--r--fs/ext4/xattr.c2
-rw-r--r--fs/ext4/xattr_trusted.c4
-rw-r--r--fs/ext4/xattr_user.c4
-rw-r--r--fs/gfs2/Kconfig18
-rw-r--r--fs/gfs2/Makefile1
-rw-r--r--fs/gfs2/gfs2.h5
-rw-r--r--fs/gfs2/glock.c1643
-rw-r--r--fs/gfs2/glock.h11
-rw-r--r--fs/gfs2/glops.c70
-rw-r--r--fs/gfs2/incore.h38
-rw-r--r--fs/gfs2/inode.c11
-rw-r--r--fs/gfs2/inode.h2
-rw-r--r--fs/gfs2/locking.c52
-rw-r--r--fs/gfs2/locking/dlm/lock.c368
-rw-r--r--fs/gfs2/locking/dlm/lock_dlm.h18
-rw-r--r--fs/gfs2/locking/dlm/mount.c14
-rw-r--r--fs/gfs2/locking/dlm/sysfs.c13
-rw-r--r--fs/gfs2/locking/dlm/thread.c331
-rw-r--r--fs/gfs2/locking/nolock/Makefile3
-rw-r--r--fs/gfs2/locking/nolock/main.c238
-rw-r--r--fs/gfs2/log.c2
-rw-r--r--fs/gfs2/log.h2
-rw-r--r--fs/gfs2/main.c2
-rw-r--r--fs/gfs2/meta_io.c14
-rw-r--r--fs/gfs2/meta_io.h1
-rw-r--r--fs/gfs2/ops_address.c40
-rw-r--r--fs/gfs2/ops_file.c38
-rw-r--r--fs/gfs2/ops_fstype.c8
-rw-r--r--fs/gfs2/ops_inode.c25
-rw-r--r--fs/gfs2/ops_super.c4
-rw-r--r--fs/gfs2/quota.c2
-rw-r--r--fs/gfs2/recovery.c5
-rw-r--r--fs/gfs2/rgrp.c108
-rw-r--r--fs/gfs2/super.c4
-rw-r--r--fs/gfs2/sys.c16
-rw-r--r--fs/jbd2/checkpoint.c1
-rw-r--r--fs/jbd2/commit.c294
-rw-r--r--fs/jbd2/journal.c53
-rw-r--r--fs/jbd2/transaction.c365
-rw-r--r--fs/jfs/jfs_debug.c62
-rw-r--r--fs/jfs/jfs_debug.h10
-rw-r--r--fs/jfs/jfs_dtree.h3
-rw-r--r--fs/jfs/jfs_imap.c2
-rw-r--r--fs/jfs/jfs_logmgr.c35
-rw-r--r--fs/jfs/jfs_metapage.c36
-rw-r--r--fs/jfs/jfs_txnmgr.c68
-rw-r--r--fs/jfs/jfs_xtree.c36
-rw-r--r--fs/jfs/namei.c2
-rw-r--r--fs/jfs/super.c7
-rw-r--r--fs/mpage.c14
-rw-r--r--include/asm-alpha/smp.h5
-rw-r--r--include/asm-arm/smp.h3
-rw-r--r--include/asm-generic/pgtable.h2
-rw-r--r--include/asm-ia64/smp.h8
-rw-r--r--include/asm-m32r/smp.h4
-rw-r--r--include/asm-mips/barrier.h14
-rw-r--r--include/asm-mips/bitops.h6
-rw-r--r--include/asm-mips/bootinfo.h43
-rw-r--r--include/asm-mips/cpu.h4
-rw-r--r--include/asm-mips/dec/kn05.h9
-rw-r--r--include/asm-mips/inventory.h24
-rw-r--r--include/asm-mips/io.h17
-rw-r--r--include/asm-mips/lasat/lasat.h2
-rw-r--r--include/asm-mips/mach-atlas/mc146818rtc.h60
-rw-r--r--include/asm-mips/mach-db1x00/db1x00.h45
-rw-r--r--include/asm-mips/mach-malta/cpu-feature-overrides.h (renamed from include/asm-mips/mach-mips/cpu-feature-overrides.h)0
-rw-r--r--include/asm-mips/mach-malta/irq.h (renamed from include/asm-mips/mach-mips/irq.h)0
-rw-r--r--include/asm-mips/mach-malta/kernel-entry-init.h (renamed from include/asm-mips/mach-mips/kernel-entry-init.h)0
-rw-r--r--include/asm-mips/mach-malta/mach-gt64120.h (renamed from include/asm-mips/mach-mips/mach-gt64120.h)0
-rw-r--r--include/asm-mips/mach-malta/mc146818rtc.h (renamed from include/asm-mips/mach-mips/mc146818rtc.h)0
-rw-r--r--include/asm-mips/mach-malta/war.h (renamed from include/asm-mips/mach-mips/war.h)0
-rw-r--r--include/asm-mips/mach-tx39xx/ioremap.h (renamed from include/asm-mips/mach-jmr3927/ioremap.h)8
-rw-r--r--include/asm-mips/mach-tx39xx/mangle-port.h (renamed from include/asm-mips/mach-jmr3927/mangle-port.h)13
-rw-r--r--include/asm-mips/mach-tx39xx/war.h (renamed from include/asm-mips/mach-jmr3927/war.h)6
-rw-r--r--include/asm-mips/mach-vr41xx/irq.h3
-rw-r--r--include/asm-mips/mips-boards/generic.h9
-rw-r--r--include/asm-mips/namei.h25
-rw-r--r--include/asm-mips/pci.h3
-rw-r--r--include/asm-mips/prctl.h41
-rw-r--r--include/asm-mips/setup.h2
-rw-r--r--include/asm-mips/signal.h3
-rw-r--r--include/asm-mips/smp.h13
-rw-r--r--include/asm-mips/traps.h1
-rw-r--r--include/asm-mips/tx4927/tx4927.h46
-rw-r--r--include/asm-mips/tx4927/tx4927_pci.h268
-rw-r--r--include/asm-mips/txx9/generic.h41
-rw-r--r--include/asm-mips/txx9/jmr3927.h (renamed from include/asm-mips/jmr3927/jmr3927.h)13
-rw-r--r--include/asm-mips/txx9/pci.h36
-rw-r--r--include/asm-mips/txx9/rbtx4927.h (renamed from include/asm-mips/tx4927/toshiba_rbtx4927.h)52
-rw-r--r--include/asm-mips/txx9/rbtx4938.h (renamed from include/asm-mips/tx4938/rbtx4938.h)45
-rw-r--r--include/asm-mips/txx9/smsc_fdc37m81x.h (renamed from include/asm-mips/tx4927/smsc_fdc37m81x.h)2
-rw-r--r--include/asm-mips/txx9/spi.h (renamed from include/asm-mips/tx4938/spi.h)7
-rw-r--r--include/asm-mips/txx9/tx3927.h (renamed from include/asm-mips/jmr3927/tx3927.h)12
-rw-r--r--include/asm-mips/txx9/tx4927.h219
-rw-r--r--include/asm-mips/txx9/tx4927pcic.h199
-rw-r--r--include/asm-mips/txx9/tx4938.h (renamed from include/asm-mips/tx4938/tx4938.h)239
-rw-r--r--include/asm-mips/txx9/txx927.h (renamed from include/asm-mips/jmr3927/txx927.h)6
-rw-r--r--include/asm-mips/vr41xx/cmbvr4133.h56
-rw-r--r--include/asm-parisc/smp.h3
-rw-r--r--include/asm-powerpc/smp.h8
-rw-r--r--include/asm-sh/smp.h14
-rw-r--r--include/asm-sparc/smp.h2
-rw-r--r--include/asm-x86/dwarf2.h30
-rw-r--r--include/asm-x86/hw_irq.h1
-rw-r--r--include/asm-x86/irq_vectors.h6
-rw-r--r--include/asm-x86/mach-default/entry_arch.h1
-rw-r--r--include/asm-x86/mach-visws/entry_arch.h22
-rw-r--r--include/asm-x86/mach-voyager/entry_arch.h2
-rw-r--r--include/asm-x86/smp.h21
-rw-r--r--include/asm-x86/xen/events.h1
-rw-r--r--include/drm/drmP.h1
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/linux/dcache.h1
-rw-r--r--include/linux/fs.h2
-rw-r--r--include/linux/i2c-algo-pcf.h8
-rw-r--r--include/linux/i2c-id.h3
-rw-r--r--include/linux/i2c.h46
-rw-r--r--include/linux/i2c/at24.h28
-rw-r--r--include/linux/ide.h55
-rw-r--r--include/linux/interrupt.h5
-rw-r--r--include/linux/irq.h9
-rw-r--r--include/linux/jbd2.h73
-rw-r--r--include/linux/libata.h55
-rw-r--r--include/linux/list.h367
-rw-r--r--include/linux/lm_interface.h6
-rw-r--r--include/linux/mlx4/device.h3
-rw-r--r--include/linux/mpage.h10
-rw-r--r--include/linux/percpu_counter.h12
-rw-r--r--include/linux/rcuclassic.h3
-rw-r--r--include/linux/rculist.h369
-rw-r--r--include/linux/rcupdate.h26
-rw-r--r--include/linux/rcupreempt.h42
-rw-r--r--include/linux/smp.h46
-rw-r--r--include/linux/topology.h13
-rw-r--r--include/linux/writeback.h1
-rw-r--r--include/rdma/ib_addr.h43
-rw-r--r--include/rdma/ib_cache.h2
-rw-r--r--include/rdma/ib_cm.h2
-rw-r--r--include/rdma/ib_fmr_pool.h4
-rw-r--r--include/rdma/ib_mad.h17
-rw-r--r--include/rdma/ib_pack.h2
-rw-r--r--include/rdma/ib_sa.h2
-rw-r--r--include/rdma/ib_smi.h4
-rw-r--r--include/rdma/ib_user_cm.h2
-rw-r--r--include/rdma/ib_user_mad.h2
-rw-r--r--include/rdma/ib_user_verbs.h7
-rw-r--r--include/rdma/ib_verbs.h149
-rw-r--r--include/rdma/iw_cm.h2
-rw-r--r--include/rdma/rdma_cm.h52
-rw-r--r--include/rdma/rdma_cm_ib.h50
-rw-r--r--include/scsi/scsi_device.h1
-rw-r--r--init/main.c3
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/backtracetest.c65
-rw-r--r--kernel/hrtimer.c9
-rw-r--r--kernel/irq/manage.c33
-rw-r--r--kernel/irq/proc.c59
-rw-r--r--kernel/pid.c1
-rw-r--r--kernel/posix-cpu-timers.c3
-rw-r--r--kernel/profile.c6
-rw-r--r--kernel/rcuclassic.c34
-rw-r--r--kernel/rcupdate.c71
-rw-r--r--kernel/rcupreempt.c418
-rw-r--r--kernel/rcupreempt_trace.c1
-rw-r--r--kernel/rcutorture.c174
-rw-r--r--kernel/smp.c383
-rw-r--r--kernel/softirq.c4
-rw-r--r--kernel/stacktrace.c14
-rw-r--r--kernel/sysctl.c13
-rw-r--r--kernel/time/tick-broadcast.c2
-rw-r--r--kernel/time/tick-sched.c8
-rw-r--r--lib/Kconfig.debug24
-rw-r--r--lib/percpu_counter.c7
-rw-r--r--lib/textsearch.c1
-rw-r--r--mm/filemap.c3
-rw-r--r--mm/page-writeback.c3
-rw-r--r--mm/page_alloc.c2
-rw-r--r--mm/slab.c18
-rw-r--r--mm/slub.c5
-rw-r--r--net/802/psnap.c1
-rw-r--r--net/8021q/vlan.c1
-rw-r--r--net/bridge/br_fdb.c1
-rw-r--r--net/bridge/br_stp.c1
-rw-r--r--net/core/flow.c2
-rw-r--r--net/iucv/iucv.c16
-rw-r--r--net/netfilter/nf_conntrack_helper.c1
-rw-r--r--net/netfilter/nf_conntrack_netlink.c1
-rw-r--r--net/netlabel/netlabel_domainhash.c3
-rw-r--r--security/selinux/hooks.c22
-rw-r--r--security/selinux/include/security.h2
-rw-r--r--security/selinux/ss/services.c27
-rw-r--r--virt/kvm/kvm_main.c14
763 files changed, 18586 insertions, 26447 deletions
diff --git a/Documentation/IRQ-affinity.txt b/Documentation/IRQ-affinity.txt
index 938d7dd0549..b4a615b7840 100644
--- a/Documentation/IRQ-affinity.txt
+++ b/Documentation/IRQ-affinity.txt
@@ -1,17 +1,26 @@
1ChangeLog:
2 Started by Ingo Molnar <mingo@redhat.com>
3 Update by Max Krasnyansky <maxk@qualcomm.com>
1 4
2SMP IRQ affinity, started by Ingo Molnar <mingo@redhat.com> 5SMP IRQ affinity
3
4 6
5/proc/irq/IRQ#/smp_affinity specifies which target CPUs are permitted 7/proc/irq/IRQ#/smp_affinity specifies which target CPUs are permitted
6for a given IRQ source. It's a bitmask of allowed CPUs. It's not allowed 8for a given IRQ source. It's a bitmask of allowed CPUs. It's not allowed
7to turn off all CPUs, and if an IRQ controller does not support IRQ 9to turn off all CPUs, and if an IRQ controller does not support IRQ
8affinity then the value will not change from the default 0xffffffff. 10affinity then the value will not change from the default 0xffffffff.
9 11
12/proc/irq/default_smp_affinity specifies default affinity mask that applies
13to all non-active IRQs. Once IRQ is allocated/activated its affinity bitmask
14will be set to the default mask. It can then be changed as described above.
15Default mask is 0xffffffff.
16
10Here is an example of restricting IRQ44 (eth1) to CPU0-3 then restricting 17Here is an example of restricting IRQ44 (eth1) to CPU0-3 then restricting
11the IRQ to CPU4-7 (this is an 8-CPU SMP box): 18it to CPU4-7 (this is an 8-CPU SMP box):
12 19
20[root@moon 44]# cd /proc/irq/44
13[root@moon 44]# cat smp_affinity 21[root@moon 44]# cat smp_affinity
14ffffffff 22ffffffff
23
15[root@moon 44]# echo 0f > smp_affinity 24[root@moon 44]# echo 0f > smp_affinity
16[root@moon 44]# cat smp_affinity 25[root@moon 44]# cat smp_affinity
170000000f 260000000f
@@ -21,17 +30,27 @@ PING hell (195.4.7.3): 56 data bytes
21--- hell ping statistics --- 30--- hell ping statistics ---
226029 packets transmitted, 6027 packets received, 0% packet loss 316029 packets transmitted, 6027 packets received, 0% packet loss
23round-trip min/avg/max = 0.1/0.1/0.4 ms 32round-trip min/avg/max = 0.1/0.1/0.4 ms
24[root@moon 44]# cat /proc/interrupts | grep 44: 33[root@moon 44]# cat /proc/interrupts | grep 'CPU\|44:'
25 44: 0 1785 1785 1783 1783 1 34 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
261 0 IO-APIC-level eth1 35 44: 1068 1785 1785 1783 0 0 0 0 IO-APIC-level eth1
36
37As can be seen from the line above IRQ44 was delivered only to the first four
38processors (0-3).
39Now lets restrict that IRQ to CPU(4-7).
40
27[root@moon 44]# echo f0 > smp_affinity 41[root@moon 44]# echo f0 > smp_affinity
42[root@moon 44]# cat smp_affinity
43000000f0
28[root@moon 44]# ping -f h 44[root@moon 44]# ping -f h
29PING hell (195.4.7.3): 56 data bytes 45PING hell (195.4.7.3): 56 data bytes
30.. 46..
31--- hell ping statistics --- 47--- hell ping statistics ---
322779 packets transmitted, 2777 packets received, 0% packet loss 482779 packets transmitted, 2777 packets received, 0% packet loss
33round-trip min/avg/max = 0.1/0.5/585.4 ms 49round-trip min/avg/max = 0.1/0.5/585.4 ms
34[root@moon 44]# cat /proc/interrupts | grep 44: 50[root@moon 44]# cat /proc/interrupts | 'CPU\|44:'
35 44: 1068 1785 1785 1784 1784 1069 1070 1069 IO-APIC-level eth1 51 CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
36[root@moon 44]# 52 44: 1068 1785 1785 1783 1784 1069 1070 1069 IO-APIC-level eth1
53
54This time around IRQ44 was delivered only to the last four processors.
55i.e counters for the CPU0-3 did not change.
37 56
diff --git a/Documentation/RCU/NMI-RCU.txt b/Documentation/RCU/NMI-RCU.txt
index c64158ecde4..a6d32e65d22 100644
--- a/Documentation/RCU/NMI-RCU.txt
+++ b/Documentation/RCU/NMI-RCU.txt
@@ -93,6 +93,9 @@ Since NMI handlers disable preemption, synchronize_sched() is guaranteed
93not to return until all ongoing NMI handlers exit. It is therefore safe 93not to return until all ongoing NMI handlers exit. It is therefore safe
94to free up the handler's data as soon as synchronize_sched() returns. 94to free up the handler's data as soon as synchronize_sched() returns.
95 95
96Important note: for this to work, the architecture in question must
97invoke irq_enter() and irq_exit() on NMI entry and exit, respectively.
98
96 99
97Answer to Quick Quiz 100Answer to Quick Quiz
98 101
diff --git a/Documentation/RCU/RTFP.txt b/Documentation/RCU/RTFP.txt
index 39ad8f56783..9f711d2df91 100644
--- a/Documentation/RCU/RTFP.txt
+++ b/Documentation/RCU/RTFP.txt
@@ -52,6 +52,10 @@ of each iteration. Unfortunately, chaotic relaxation requires highly
52structured data, such as the matrices used in scientific programs, and 52structured data, such as the matrices used in scientific programs, and
53is thus inapplicable to most data structures in operating-system kernels. 53is thus inapplicable to most data structures in operating-system kernels.
54 54
55In 1992, Henry (now Alexia) Massalin completed a dissertation advising
56parallel programmers to defer processing when feasible to simplify
57synchronization. RCU makes extremely heavy use of this advice.
58
55In 1993, Jacobson [Jacobson93] verbally described what is perhaps the 59In 1993, Jacobson [Jacobson93] verbally described what is perhaps the
56simplest deferred-free technique: simply waiting a fixed amount of time 60simplest deferred-free technique: simply waiting a fixed amount of time
57before freeing blocks awaiting deferred free. Jacobson did not describe 61before freeing blocks awaiting deferred free. Jacobson did not describe
@@ -138,6 +142,13 @@ blocking in read-side critical sections appeared [PaulEMcKenney2006c],
138Robert Olsson described an RCU-protected trie-hash combination 142Robert Olsson described an RCU-protected trie-hash combination
139[RobertOlsson2006a]. 143[RobertOlsson2006a].
140 144
1452007 saw the journal version of the award-winning RCU paper from 2006
146[ThomasEHart2007a], as well as a paper demonstrating use of Promela
147and Spin to mechanically verify an optimization to Oleg Nesterov's
148QRCU [PaulEMcKenney2007QRCUspin], a design document describing
149preemptible RCU [PaulEMcKenney2007PreemptibleRCU], and the three-part
150LWN "What is RCU?" series [PaulEMcKenney2007WhatIsRCUFundamentally,
151PaulEMcKenney2008WhatIsRCUUsage, and PaulEMcKenney2008WhatIsRCUAPI].
141 152
142Bibtex Entries 153Bibtex Entries
143 154
@@ -202,6 +213,20 @@ Bibtex Entries
202,Year="1991" 213,Year="1991"
203} 214}
204 215
216@phdthesis{HMassalinPhD
217,author="H. Massalin"
218,title="Synthesis: An Efficient Implementation of Fundamental Operating
219System Services"
220,school="Columbia University"
221,address="New York, NY"
222,year="1992"
223,annotation="
224 Mondo optimizing compiler.
225 Wait-free stuff.
226 Good advice: defer work to avoid synchronization.
227"
228}
229
205@unpublished{Jacobson93 230@unpublished{Jacobson93
206,author="Van Jacobson" 231,author="Van Jacobson"
207,title="Avoid Read-Side Locking Via Delayed Free" 232,title="Avoid Read-Side Locking Via Delayed Free"
@@ -635,3 +660,86 @@ Revised:
635" 660"
636} 661}
637 662
663@unpublished{PaulEMcKenney2007PreemptibleRCU
664,Author="Paul E. McKenney"
665,Title="The design of preemptible read-copy-update"
666,month="October"
667,day="8"
668,year="2007"
669,note="Available:
670\url{http://lwn.net/Articles/253651/}
671[Viewed October 25, 2007]"
672,annotation="
673 LWN article describing the design of preemptible RCU.
674"
675}
676
677########################################################################
678#
679# "What is RCU?" LWN series.
680#
681
682@unpublished{PaulEMcKenney2007WhatIsRCUFundamentally
683,Author="Paul E. McKenney and Jonathan Walpole"
684,Title="What is {RCU}, Fundamentally?"
685,month="December"
686,day="17"
687,year="2007"
688,note="Available:
689\url{http://lwn.net/Articles/262464/}
690[Viewed December 27, 2007]"
691,annotation="
692 Lays out the three basic components of RCU: (1) publish-subscribe,
693 (2) wait for pre-existing readers to complete, and (2) maintain
694 multiple versions.
695"
696}
697
698@unpublished{PaulEMcKenney2008WhatIsRCUUsage
699,Author="Paul E. McKenney"
700,Title="What is {RCU}? Part 2: Usage"
701,month="January"
702,day="4"
703,year="2008"
704,note="Available:
705\url{http://lwn.net/Articles/263130/}
706[Viewed January 4, 2008]"
707,annotation="
708 Lays out six uses of RCU:
709 1. RCU is a Reader-Writer Lock Replacement
710 2. RCU is a Restricted Reference-Counting Mechanism
711 3. RCU is a Bulk Reference-Counting Mechanism
712 4. RCU is a Poor Man's Garbage Collector
713 5. RCU is a Way of Providing Existence Guarantees
714 6. RCU is a Way of Waiting for Things to Finish
715"
716}
717
718@unpublished{PaulEMcKenney2008WhatIsRCUAPI
719,Author="Paul E. McKenney"
720,Title="{RCU} part 3: the {RCU} {API}"
721,month="January"
722,day="17"
723,year="2008"
724,note="Available:
725\url{http://lwn.net/Articles/264090/}
726[Viewed January 10, 2008]"
727,annotation="
728 Gives an overview of the Linux-kernel RCU API and a brief annotated RCU
729 bibliography.
730"
731}
732
733@article{DinakarGuniguntala2008IBMSysJ
734,author="D. Guniguntala and P. E. McKenney and J. Triplett and J. Walpole"
735,title="The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with {Linux}"
736,Year="2008"
737,Month="April"
738,journal="IBM Systems Journal"
739,volume="47"
740,number="2"
741,pages="@@-@@"
742,annotation="
743 RCU, realtime RCU, sleepable RCU, performance.
744"
745}
diff --git a/Documentation/RCU/checklist.txt b/Documentation/RCU/checklist.txt
index 42b01bc2e1b..cf5562cbe35 100644
--- a/Documentation/RCU/checklist.txt
+++ b/Documentation/RCU/checklist.txt
@@ -13,10 +13,13 @@ over a rather long period of time, but improvements are always welcome!
13 detailed performance measurements show that RCU is nonetheless 13 detailed performance measurements show that RCU is nonetheless
14 the right tool for the job. 14 the right tool for the job.
15 15
16 The other exception would be where performance is not an issue, 16 Another exception is where performance is not an issue, and RCU
17 and RCU provides a simpler implementation. An example of this 17 provides a simpler implementation. An example of this situation
18 situation is the dynamic NMI code in the Linux 2.6 kernel, 18 is the dynamic NMI code in the Linux 2.6 kernel, at least on
19 at least on architectures where NMIs are rare. 19 architectures where NMIs are rare.
20
21 Yet another exception is where the low real-time latency of RCU's
22 read-side primitives is critically important.
20 23
211. Does the update code have proper mutual exclusion? 241. Does the update code have proper mutual exclusion?
22 25
@@ -39,9 +42,10 @@ over a rather long period of time, but improvements are always welcome!
39 42
402. Do the RCU read-side critical sections make proper use of 432. Do the RCU read-side critical sections make proper use of
41 rcu_read_lock() and friends? These primitives are needed 44 rcu_read_lock() and friends? These primitives are needed
42 to suppress preemption (or bottom halves, in the case of 45 to prevent grace periods from ending prematurely, which
43 rcu_read_lock_bh()) in the read-side critical sections, 46 could result in data being unceremoniously freed out from
44 and are also an excellent aid to readability. 47 under your read-side code, which can greatly increase the
48 actuarial risk of your kernel.
45 49
46 As a rough rule of thumb, any dereference of an RCU-protected 50 As a rough rule of thumb, any dereference of an RCU-protected
47 pointer must be covered by rcu_read_lock() or rcu_read_lock_bh() 51 pointer must be covered by rcu_read_lock() or rcu_read_lock_bh()
@@ -54,15 +58,30 @@ over a rather long period of time, but improvements are always welcome!
54 be running while updates are in progress. There are a number 58 be running while updates are in progress. There are a number
55 of ways to handle this concurrency, depending on the situation: 59 of ways to handle this concurrency, depending on the situation:
56 60
57 a. Make updates appear atomic to readers. For example, 61 a. Use the RCU variants of the list and hlist update
62 primitives to add, remove, and replace elements on an
63 RCU-protected list. Alternatively, use the RCU-protected
64 trees that have been added to the Linux kernel.
65
66 This is almost always the best approach.
67
68 b. Proceed as in (a) above, but also maintain per-element
69 locks (that are acquired by both readers and writers)
70 that guard per-element state. Of course, fields that
71 the readers refrain from accessing can be guarded by the
72 update-side lock.
73
74 This works quite well, also.
75
76 c. Make updates appear atomic to readers. For example,
58 pointer updates to properly aligned fields will appear 77 pointer updates to properly aligned fields will appear
59 atomic, as will individual atomic primitives. Operations 78 atomic, as will individual atomic primitives. Operations
60 performed under a lock and sequences of multiple atomic 79 performed under a lock and sequences of multiple atomic
61 primitives will -not- appear to be atomic. 80 primitives will -not- appear to be atomic.
62 81
63 This is almost always the best approach. 82 This can work, but is starting to get a bit tricky.
64 83
65 b. Carefully order the updates and the reads so that 84 d. Carefully order the updates and the reads so that
66 readers see valid data at all phases of the update. 85 readers see valid data at all phases of the update.
67 This is often more difficult than it sounds, especially 86 This is often more difficult than it sounds, especially
68 given modern CPUs' tendency to reorder memory references. 87 given modern CPUs' tendency to reorder memory references.
@@ -123,18 +142,22 @@ over a rather long period of time, but improvements are always welcome!
123 when publicizing a pointer to a structure that can 142 when publicizing a pointer to a structure that can
124 be traversed by an RCU read-side critical section. 143 be traversed by an RCU read-side critical section.
125 144
1265. If call_rcu(), or a related primitive such as call_rcu_bh(), 1455. If call_rcu(), or a related primitive such as call_rcu_bh() or
127 is used, the callback function must be written to be called 146 call_rcu_sched(), is used, the callback function must be
128 from softirq context. In particular, it cannot block. 147 written to be called from softirq context. In particular,
148 it cannot block.
129 149
1306. Since synchronize_rcu() can block, it cannot be called from 1506. Since synchronize_rcu() can block, it cannot be called from
131 any sort of irq context. 151 any sort of irq context. Ditto for synchronize_sched() and
152 synchronize_srcu().
132 153
1337. If the updater uses call_rcu(), then the corresponding readers 1547. If the updater uses call_rcu(), then the corresponding readers
134 must use rcu_read_lock() and rcu_read_unlock(). If the updater 155 must use rcu_read_lock() and rcu_read_unlock(). If the updater
135 uses call_rcu_bh(), then the corresponding readers must use 156 uses call_rcu_bh(), then the corresponding readers must use
136 rcu_read_lock_bh() and rcu_read_unlock_bh(). Mixing things up 157 rcu_read_lock_bh() and rcu_read_unlock_bh(). If the updater
137 will result in confusion and broken kernels. 158 uses call_rcu_sched(), then the corresponding readers must
159 disable preemption. Mixing things up will result in confusion
160 and broken kernels.
138 161
139 One exception to this rule: rcu_read_lock() and rcu_read_unlock() 162 One exception to this rule: rcu_read_lock() and rcu_read_unlock()
140 may be substituted for rcu_read_lock_bh() and rcu_read_unlock_bh() 163 may be substituted for rcu_read_lock_bh() and rcu_read_unlock_bh()
@@ -143,9 +166,9 @@ over a rather long period of time, but improvements are always welcome!
143 such cases is a must, of course! And the jury is still out on 166 such cases is a must, of course! And the jury is still out on
144 whether the increased speed is worth it. 167 whether the increased speed is worth it.
145 168
1468. Although synchronize_rcu() is a bit slower than is call_rcu(), 1698. Although synchronize_rcu() is slower than is call_rcu(), it
147 it usually results in simpler code. So, unless update 170 usually results in simpler code. So, unless update performance
148 performance is critically important or the updaters cannot block, 171 is critically important or the updaters cannot block,
149 synchronize_rcu() should be used in preference to call_rcu(). 172 synchronize_rcu() should be used in preference to call_rcu().
150 173
151 An especially important property of the synchronize_rcu() 174 An especially important property of the synchronize_rcu()
@@ -187,23 +210,23 @@ over a rather long period of time, but improvements are always welcome!
187 number of updates per grace period. 210 number of updates per grace period.
188 211
1899. All RCU list-traversal primitives, which include 2129. All RCU list-traversal primitives, which include
190 list_for_each_rcu(), list_for_each_entry_rcu(), 213 rcu_dereference(), list_for_each_rcu(), list_for_each_entry_rcu(),
191 list_for_each_continue_rcu(), and list_for_each_safe_rcu(), 214 list_for_each_continue_rcu(), and list_for_each_safe_rcu(),
192 must be within an RCU read-side critical section. RCU 215 must be either within an RCU read-side critical section or
216 must be protected by appropriate update-side locks. RCU
193 read-side critical sections are delimited by rcu_read_lock() 217 read-side critical sections are delimited by rcu_read_lock()
194 and rcu_read_unlock(), or by similar primitives such as 218 and rcu_read_unlock(), or by similar primitives such as
195 rcu_read_lock_bh() and rcu_read_unlock_bh(). 219 rcu_read_lock_bh() and rcu_read_unlock_bh().
196 220
197 Use of the _rcu() list-traversal primitives outside of an 221 The reason that it is permissible to use RCU list-traversal
198 RCU read-side critical section causes no harm other than 222 primitives when the update-side lock is held is that doing so
199 a slight performance degradation on Alpha CPUs. It can 223 can be quite helpful in reducing code bloat when common code is
200 also be quite helpful in reducing code bloat when common 224 shared between readers and updaters.
201 code is shared between readers and updaters.
202 225
20310. Conversely, if you are in an RCU read-side critical section, 22610. Conversely, if you are in an RCU read-side critical section,
204 you -must- use the "_rcu()" variants of the list macros. 227 and you don't hold the appropriate update-side lock, you -must-
205 Failing to do so will break Alpha and confuse people reading 228 use the "_rcu()" variants of the list macros. Failing to do so
206 your code. 229 will break Alpha and confuse people reading your code.
207 230
20811. Note that synchronize_rcu() -only- guarantees to wait until 23111. Note that synchronize_rcu() -only- guarantees to wait until
209 all currently executing rcu_read_lock()-protected RCU read-side 232 all currently executing rcu_read_lock()-protected RCU read-side
@@ -230,6 +253,14 @@ over a rather long period of time, but improvements are always welcome!
230 must use whatever locking or other synchronization is required 253 must use whatever locking or other synchronization is required
231 to safely access and/or modify that data structure. 254 to safely access and/or modify that data structure.
232 255
256 RCU callbacks are -usually- executed on the same CPU that executed
257 the corresponding call_rcu(), call_rcu_bh(), or call_rcu_sched(),
258 but are by -no- means guaranteed to be. For example, if a given
259 CPU goes offline while having an RCU callback pending, then that
260 RCU callback will execute on some surviving CPU. (If this was
261 not the case, a self-spawning RCU callback would prevent the
262 victim CPU from ever going offline.)
263
23314. SRCU (srcu_read_lock(), srcu_read_unlock(), and synchronize_srcu()) 26414. SRCU (srcu_read_lock(), srcu_read_unlock(), and synchronize_srcu())
234 may only be invoked from process context. Unlike other forms of 265 may only be invoked from process context. Unlike other forms of
235 RCU, it -is- permissible to block in an SRCU read-side critical 266 RCU, it -is- permissible to block in an SRCU read-side critical
diff --git a/Documentation/RCU/torture.txt b/Documentation/RCU/torture.txt
index 2967a65269d..a342b6e1cc1 100644
--- a/Documentation/RCU/torture.txt
+++ b/Documentation/RCU/torture.txt
@@ -10,23 +10,30 @@ status messages via printk(), which can be examined via the dmesg
10command (perhaps grepping for "torture"). The test is started 10command (perhaps grepping for "torture"). The test is started
11when the module is loaded, and stops when the module is unloaded. 11when the module is loaded, and stops when the module is unloaded.
12 12
13However, actually setting this config option to "y" results in the system 13CONFIG_RCU_TORTURE_TEST_RUNNABLE
14running the test immediately upon boot, and ending only when the system 14
15is taken down. Normally, one will instead want to build the system 15It is also possible to specify CONFIG_RCU_TORTURE_TEST=y, which will
16with CONFIG_RCU_TORTURE_TEST=m and to use modprobe and rmmod to control 16result in the tests being loaded into the base kernel. In this case,
17the test, perhaps using a script similar to the one shown at the end of 17the CONFIG_RCU_TORTURE_TEST_RUNNABLE config option is used to specify
18this document. Note that you will need CONFIG_MODULE_UNLOAD in order 18whether the RCU torture tests are to be started immediately during
19to be able to end the test. 19boot or whether the /proc/sys/kernel/rcutorture_runnable file is used
20to enable them. This /proc file can be used to repeatedly pause and
21restart the tests, regardless of the initial state specified by the
22CONFIG_RCU_TORTURE_TEST_RUNNABLE config option.
23
24You will normally -not- want to start the RCU torture tests during boot
25(and thus the default is CONFIG_RCU_TORTURE_TEST_RUNNABLE=n), but doing
26this can sometimes be useful in finding boot-time bugs.
20 27
21 28
22MODULE PARAMETERS 29MODULE PARAMETERS
23 30
24This module has the following parameters: 31This module has the following parameters:
25 32
26nreaders This is the number of RCU reading threads supported. 33irqreaders Says to invoke RCU readers from irq level. This is currently
27 The default is twice the number of CPUs. Why twice? 34 done via timers. Defaults to "1" for variants of RCU that
28 To properly exercise RCU implementations with preemptible 35 permit this. (Or, more accurately, variants of RCU that do
29 read-side critical sections. 36 -not- permit this know to ignore this variable.)
30 37
31nfakewriters This is the number of RCU fake writer threads to run. Fake 38nfakewriters This is the number of RCU fake writer threads to run. Fake
32 writer threads repeatedly use the synchronous "wait for 39 writer threads repeatedly use the synchronous "wait for
@@ -37,6 +44,16 @@ nfakewriters This is the number of RCU fake writer threads to run. Fake
37 to trigger special cases caused by multiple writers, such as 44 to trigger special cases caused by multiple writers, such as
38 the synchronize_srcu() early return optimization. 45 the synchronize_srcu() early return optimization.
39 46
47nreaders This is the number of RCU reading threads supported.
48 The default is twice the number of CPUs. Why twice?
49 To properly exercise RCU implementations with preemptible
50 read-side critical sections.
51
52shuffle_interval
53 The number of seconds to keep the test threads affinitied
54 to a particular subset of the CPUs, defaults to 3 seconds.
55 Used in conjunction with test_no_idle_hz.
56
40stat_interval The number of seconds between output of torture 57stat_interval The number of seconds between output of torture
41 statistics (via printk()). Regardless of the interval, 58 statistics (via printk()). Regardless of the interval,
42 statistics are printed when the module is unloaded. 59 statistics are printed when the module is unloaded.
@@ -44,10 +61,11 @@ stat_interval The number of seconds between output of torture
44 be printed -only- when the module is unloaded, and this 61 be printed -only- when the module is unloaded, and this
45 is the default. 62 is the default.
46 63
47shuffle_interval 64stutter The length of time to run the test before pausing for this
48 The number of seconds to keep the test threads affinitied 65 same period of time. Defaults to "stutter=5", so as
49 to a particular subset of the CPUs, defaults to 5 seconds. 66 to run and pause for (roughly) five-second intervals.
50 Used in conjunction with test_no_idle_hz. 67 Specifying "stutter=0" causes the test to run continuously
68 without pausing, which is the old default behavior.
51 69
52test_no_idle_hz Whether or not to test the ability of RCU to operate in 70test_no_idle_hz Whether or not to test the ability of RCU to operate in
53 a kernel that disables the scheduling-clock interrupt to 71 a kernel that disables the scheduling-clock interrupt to
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index e0d6d99b8f9..e04d643a9f5 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -1,3 +1,11 @@
1Please note that the "What is RCU?" LWN series is an excellent place
2to start learning about RCU:
3
41. What is RCU, Fundamentally? http://lwn.net/Articles/262464/
52. What is RCU? Part 2: Usage http://lwn.net/Articles/263130/
63. RCU part 3: the RCU API http://lwn.net/Articles/264090/
7
8
1What is RCU? 9What is RCU?
2 10
3RCU is a synchronization mechanism that was added to the Linux kernel 11RCU is a synchronization mechanism that was added to the Linux kernel
@@ -772,26 +780,18 @@ Linux-kernel source code, but it helps to have a full list of the
772APIs, since there does not appear to be a way to categorize them 780APIs, since there does not appear to be a way to categorize them
773in docbook. Here is the list, by category. 781in docbook. Here is the list, by category.
774 782
775Markers for RCU read-side critical sections:
776
777 rcu_read_lock
778 rcu_read_unlock
779 rcu_read_lock_bh
780 rcu_read_unlock_bh
781 srcu_read_lock
782 srcu_read_unlock
783
784RCU pointer/list traversal: 783RCU pointer/list traversal:
785 784
786 rcu_dereference 785 rcu_dereference
786 list_for_each_entry_rcu
787 hlist_for_each_entry_rcu
788
787 list_for_each_rcu (to be deprecated in favor of 789 list_for_each_rcu (to be deprecated in favor of
788 list_for_each_entry_rcu) 790 list_for_each_entry_rcu)
789 list_for_each_entry_rcu
790 list_for_each_continue_rcu (to be deprecated in favor of new 791 list_for_each_continue_rcu (to be deprecated in favor of new
791 list_for_each_entry_continue_rcu) 792 list_for_each_entry_continue_rcu)
792 hlist_for_each_entry_rcu
793 793
794RCU pointer update: 794RCU pointer/list update:
795 795
796 rcu_assign_pointer 796 rcu_assign_pointer
797 list_add_rcu 797 list_add_rcu
@@ -799,16 +799,36 @@ RCU pointer update:
799 list_del_rcu 799 list_del_rcu
800 list_replace_rcu 800 list_replace_rcu
801 hlist_del_rcu 801 hlist_del_rcu
802 hlist_add_after_rcu
803 hlist_add_before_rcu
802 hlist_add_head_rcu 804 hlist_add_head_rcu
805 hlist_replace_rcu
806 list_splice_init_rcu()
803 807
804RCU grace period: 808RCU: Critical sections Grace period Barrier
809
810 rcu_read_lock synchronize_net rcu_barrier
811 rcu_read_unlock synchronize_rcu
812 call_rcu
813
814
815bh: Critical sections Grace period Barrier
816
817 rcu_read_lock_bh call_rcu_bh rcu_barrier_bh
818 rcu_read_unlock_bh
819
820
821sched: Critical sections Grace period Barrier
822
823 [preempt_disable] synchronize_sched rcu_barrier_sched
824 [and friends] call_rcu_sched
825
826
827SRCU: Critical sections Grace period Barrier
828
829 srcu_read_lock synchronize_srcu N/A
830 srcu_read_unlock
805 831
806 synchronize_net
807 synchronize_sched
808 synchronize_rcu
809 synchronize_srcu
810 call_rcu
811 call_rcu_bh
812 832
813See the comment headers in the source code (or the docbook generated 833See the comment headers in the source code (or the docbook generated
814from them) for more information. 834from them) for more information.
diff --git a/Documentation/cputopology.txt b/Documentation/cputopology.txt
index b61cb956402..bd699da2466 100644
--- a/Documentation/cputopology.txt
+++ b/Documentation/cputopology.txt
@@ -14,9 +14,8 @@ represent the thread siblings to cpu X in the same physical package;
14To implement it in an architecture-neutral way, a new source file, 14To implement it in an architecture-neutral way, a new source file,
15drivers/base/topology.c, is to export the 4 attributes. 15drivers/base/topology.c, is to export the 4 attributes.
16 16
17If one architecture wants to support this feature, it just needs to 17For an architecture to support this feature, it must define some of
18implement 4 defines, typically in file include/asm-XXX/topology.h. 18these macros in include/asm-XXX/topology.h:
19The 4 defines are:
20#define topology_physical_package_id(cpu) 19#define topology_physical_package_id(cpu)
21#define topology_core_id(cpu) 20#define topology_core_id(cpu)
22#define topology_thread_siblings(cpu) 21#define topology_thread_siblings(cpu)
@@ -25,17 +24,10 @@ The 4 defines are:
25The type of **_id is int. 24The type of **_id is int.
26The type of siblings is cpumask_t. 25The type of siblings is cpumask_t.
27 26
28To be consistent on all architectures, the 4 attributes should have 27To be consistent on all architectures, include/linux/topology.h
29default values if their values are unavailable. Below is the rule. 28provides default definitions for any of the above macros that are
301) physical_package_id: If cpu has no physical package id, -1 is the 29not defined by include/asm-XXX/topology.h:
31default value. 301) physical_package_id: -1
322) core_id: If cpu doesn't support multi-core, its core id is 0. 312) core_id: 0
333) thread_siblings: Just include itself, if the cpu doesn't support 323) thread_siblings: just the given CPU
34HT/multi-thread. 334) core_siblings: just the given CPU
354) core_siblings: Just include itself, if the cpu doesn't support
36multi-core and HT/Multi-thread.
37
38So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
39
40If an attribute isn't defined on an architecture, it won't be exported.
41
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 46ece3fba6f..65a1482457a 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -222,13 +222,6 @@ Who: Thomas Gleixner <tglx@linutronix.de>
222 222
223--------------------------- 223---------------------------
224 224
225What: i2c-i810, i2c-prosavage and i2c-savage4
226When: May 2008
227Why: These drivers are superseded by i810fb, intelfb and savagefb.
228Who: Jean Delvare <khali@linux-fr.org>
229
230---------------------------
231
232What (Why): 225What (Why):
233 - include/linux/netfilter_ipv4/ipt_TOS.h ipt_tos.h header files 226 - include/linux/netfilter_ipv4/ipt_TOS.h ipt_tos.h header files
234 (superseded by xt_TOS/xt_tos target & match) 227 (superseded by xt_TOS/xt_tos target & match)
diff --git a/Documentation/filesystems/ext4.txt b/Documentation/filesystems/ext4.txt
index 0c5086db835..80e193d82e2 100644
--- a/Documentation/filesystems/ext4.txt
+++ b/Documentation/filesystems/ext4.txt
@@ -13,72 +13,93 @@ Mailing list: linux-ext4@vger.kernel.org
131. Quick usage instructions: 131. Quick usage instructions:
14=========================== 14===========================
15 15
16 - Grab updated e2fsprogs from 16 - Compile and install the latest version of e2fsprogs (as of this
17 ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs-interim/ 17 writing version 1.41) from:
18 This is a patchset on top of e2fsprogs-1.39, which can be found at 18
19 http://sourceforge.net/project/showfiles.php?group_id=2406
20
21 or
22
19 ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/ 23 ftp://ftp.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/
20 24
21 - It's still mke2fs -j /dev/hda1 25 or grab the latest git repository from:
26
27 git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
28
29 - Create a new filesystem using the ext4dev filesystem type:
30
31 # mke2fs -t ext4dev /dev/hda1
32
33 Or configure an existing ext3 filesystem to support extents and set
34 the test_fs flag to indicate that it's ok for an in-development
35 filesystem to touch this filesystem:
22 36
23 - mount /dev/hda1 /wherever -t ext4dev 37 # tune2fs -O extents -E test_fs /dev/hda1
24 38
25 - To enable extents, 39 If the filesystem was created with 128 byte inodes, it can be
40 converted to use 256 byte for greater efficiency via:
26 41
27 mount /dev/hda1 /wherever -t ext4dev -o extents 42 # tune2fs -I 256 /dev/hda1
28 43
29 - The filesystem is compatible with the ext3 driver until you add a file 44 (Note: we currently do not have tools to convert an ext4dev
30 which has extents (ie: `mount -o extents', then create a file). 45 filesystem back to ext3; so please do not do try this on production
46 filesystems.)
31 47
32 NOTE: The "extents" mount flag is temporary. It will soon go away and 48 - Mounting:
33 extents will be enabled by the "-o extents" flag to mke2fs or tune2fs 49
50 # mount -t ext4dev /dev/hda1 /wherever
34 51
35 - When comparing performance with other filesystems, remember that 52 - When comparing performance with other filesystems, remember that
36 ext3/4 by default offers higher data integrity guarantees than most. So 53 ext3/4 by default offers higher data integrity guarantees than most.
37 when comparing with a metadata-only journalling filesystem, use `mount -o 54 So when comparing with a metadata-only journalling filesystem, such
38 data=writeback'. And you might as well use `mount -o nobh' too along 55 as ext3, use `mount -o data=writeback'. And you might as well use
39 with it. Making the journal larger than the mke2fs default often helps 56 `mount -o nobh' too along with it. Making the journal larger than
40 performance with metadata-intensive workloads. 57 the mke2fs default often helps performance with metadata-intensive
58 workloads.
41 59
422. Features 602. Features
43=========== 61===========
44 62
452.1 Currently available 632.1 Currently available
46 64
47* ability to use filesystems > 16TB 65* ability to use filesystems > 16TB (e2fsprogs support not available yet)
48* extent format reduces metadata overhead (RAM, IO for access, transactions) 66* extent format reduces metadata overhead (RAM, IO for access, transactions)
49* extent format more robust in face of on-disk corruption due to magics, 67* extent format more robust in face of on-disk corruption due to magics,
50* internal redunancy in tree 68* internal redunancy in tree
51 69* improved file allocation (multi-block alloc)
522.1 Previously available, soon to be enabled by default by "mkefs.ext4": 70* fix 32000 subdirectory limit
53 71* nsec timestamps for mtime, atime, ctime, create time
54* dir_index and resize inode will be on by default 72* inode version field on disk (NFSv4, Lustre)
55* large inodes will be used by default for fast EAs, nsec timestamps, etc 73* reduced e2fsck time via uninit_bg feature
74* journal checksumming for robustness, performance
75* persistent file preallocation (e.g for streaming media, databases)
76* ability to pack bitmaps and inode tables into larger virtual groups via the
77 flex_bg feature
78* large file support
79* Inode allocation using large virtual block groups via flex_bg
80* delayed allocation
81* large block (up to pagesize) support
82* efficent new ordered mode in JBD2 and ext4(avoid using buffer head to force
83 the ordering)
56 84
572.2 Candidate features for future inclusion 852.2 Candidate features for future inclusion
58 86
59There are several under discussion, whether they all make it in is 87* Online defrag (patches available but not well tested)
60partly a function of how much time everyone has to work on them: 88* reduced mke2fs time via lazy itable initialization in conjuction with
89 the uninit_bg feature (capability to do this is available in e2fsprogs
90 but a kernel thread to do lazy zeroing of unused inode table blocks
91 after filesystem is first mounted is required for safety)
61 92
62* improved file allocation (multi-block alloc, delayed alloc; basically done) 93There are several others under discussion, whether they all make it in is
63* fix 32000 subdirectory limit (patch exists, needs some e2fsck work) 94partly a function of how much time everyone has to work on them. Features like
64* nsec timestamps for mtime, atime, ctime, create time (patch exists, 95metadata checksumming have been discussed and planned for a bit but no patches
65 needs some e2fsck work) 96exist yet so I'm not sure they're in the near-term roadmap.
66* inode version field on disk (NFSv4, Lustre; prototype exists)
67* reduced mke2fs/e2fsck time via uninitialized groups (prototype exists)
68* journal checksumming for robustness, performance (prototype exists)
69* persistent file preallocation (e.g for streaming media, databases)
70 97
71Features like metadata checksumming have been discussed and planned for 98The big performance win will come with mballoc, delalloc and flex_bg
72a bit but no patches exist yet so I'm not sure they're in the near-term 99grouping of bitmaps and inode tables. Some test results available here:
73roadmap.
74 100
75The big performance win will come with mballoc and delalloc. CFS has 101 - http://www.bullopensource.org/ext4/20080530/ffsb-write-2.6.26-rc2.html
76been using mballoc for a few years already with Lustre, and IBM + Bull 102 - http://www.bullopensource.org/ext4/20080530/ffsb-readwrite-2.6.26-rc2.html
77did a lot of benchmarking on it. The reason it isn't in the first set of
78patches is partly a manageability issue, and partly because it doesn't
79directly affect the on-disk format (outside of much better allocation)
80so it isn't critical to get into the first round of changes. I believe
81Alex is working on a new set of patches right now.
82 103
833. Options 1043. Options
84========== 105==========
@@ -222,9 +243,11 @@ stripe=n Number of filesystem blocks that mballoc will try
222 to use for allocation size and alignment. For RAID5/6 243 to use for allocation size and alignment. For RAID5/6
223 systems this should be the number of data 244 systems this should be the number of data
224 disks * RAID chunk size in file system blocks. 245 disks * RAID chunk size in file system blocks.
225 246delalloc (*) Deferring block allocation until write-out time.
247nodelalloc Disable delayed allocation. Blocks are allocation
248 when data is copied from user to page cache.
226Data Mode 249Data Mode
227--------- 250=========
228There are 3 different data modes: 251There are 3 different data modes:
229 252
230* writeback mode 253* writeback mode
@@ -236,10 +259,10 @@ typically provide the best ext4 performance.
236 259
237* ordered mode 260* ordered mode
238In data=ordered mode, ext4 only officially journals metadata, but it logically 261In data=ordered mode, ext4 only officially journals metadata, but it logically
239groups metadata and data blocks into a single unit called a transaction. When 262groups metadata information related to data changes with the data blocks into a
240it's time to write the new metadata out to disk, the associated data blocks 263single unit called a transaction. When it's time to write the new metadata
241are written first. In general, this mode performs slightly slower than 264out to disk, the associated data blocks are written first. In general,
242writeback but significantly faster than journal mode. 265this mode performs slightly slower than writeback but significantly faster than journal mode.
243 266
244* journal mode 267* journal mode
245data=journal mode provides full data and metadata journaling. All new data is 268data=journal mode provides full data and metadata journaling. All new data is
@@ -247,7 +270,8 @@ written to the journal first, and then to its final location.
247In the event of a crash, the journal can be replayed, bringing both data and 270In the event of a crash, the journal can be replayed, bringing both data and
248metadata into a consistent state. This mode is the slowest except when data 271metadata into a consistent state. This mode is the slowest except when data
249needs to be read from and written to disk at the same time where it 272needs to be read from and written to disk at the same time where it
250outperforms all others modes. 273outperforms all others modes. Curently ext4 does not have delayed
274allocation support if this data journalling mode is selected.
251 275
252References 276References
253========== 277==========
@@ -256,7 +280,8 @@ kernel source: <file:fs/ext4/>
256 <file:fs/jbd2/> 280 <file:fs/jbd2/>
257 281
258programs: http://e2fsprogs.sourceforge.net/ 282programs: http://e2fsprogs.sourceforge.net/
259 http://ext2resize.sourceforge.net
260 283
261useful links: http://fedoraproject.org/wiki/ext3-devel 284useful links: http://fedoraproject.org/wiki/ext3-devel
262 http://www.bullopensource.org/ext4/ 285 http://www.bullopensource.org/ext4/
286 http://ext4.wiki.kernel.org/index.php/Main_Page
287 http://fedoraproject.org/wiki/Features/Ext4
diff --git a/Documentation/filesystems/gfs2-glocks.txt b/Documentation/filesystems/gfs2-glocks.txt
new file mode 100644
index 00000000000..4dae9a3840b
--- /dev/null
+++ b/Documentation/filesystems/gfs2-glocks.txt
@@ -0,0 +1,114 @@
1 Glock internal locking rules
2 ------------------------------
3
4This documents the basic principles of the glock state machine
5internals. Each glock (struct gfs2_glock in fs/gfs2/incore.h)
6has two main (internal) locks:
7
8 1. A spinlock (gl_spin) which protects the internal state such
9 as gl_state, gl_target and the list of holders (gl_holders)
10 2. A non-blocking bit lock, GLF_LOCK, which is used to prevent other
11 threads from making calls to the DLM, etc. at the same time. If a
12 thread takes this lock, it must then call run_queue (usually via the
13 workqueue) when it releases it in order to ensure any pending tasks
14 are completed.
15
16The gl_holders list contains all the queued lock requests (not
17just the holders) associated with the glock. If there are any
18held locks, then they will be contiguous entries at the head
19of the list. Locks are granted in strictly the order that they
20are queued, except for those marked LM_FLAG_PRIORITY which are
21used only during recovery, and even then only for journal locks.
22
23There are three lock states that users of the glock layer can request,
24namely shared (SH), deferred (DF) and exclusive (EX). Those translate
25to the following DLM lock modes:
26
27Glock mode | DLM lock mode
28------------------------------
29 UN | IV/NL Unlocked (no DLM lock associated with glock) or NL
30 SH | PR (Protected read)
31 DF | CW (Concurrent write)
32 EX | EX (Exclusive)
33
34Thus DF is basically a shared mode which is incompatible with the "normal"
35shared lock mode, SH. In GFS2 the DF mode is used exclusively for direct I/O
36operations. The glocks are basically a lock plus some routines which deal
37with cache management. The following rules apply for the cache:
38
39Glock mode | Cache data | Cache Metadata | Dirty Data | Dirty Metadata
40--------------------------------------------------------------------------
41 UN | No | No | No | No
42 SH | Yes | Yes | No | No
43 DF | No | Yes | No | No
44 EX | Yes | Yes | Yes | Yes
45
46These rules are implemented using the various glock operations which
47are defined for each type of glock. Not all types of glocks use
48all the modes. Only inode glocks use the DF mode for example.
49
50Table of glock operations and per type constants:
51
52Field | Purpose
53----------------------------------------------------------------------------
54go_xmote_th | Called before remote state change (e.g. to sync dirty data)
55go_xmote_bh | Called after remote state change (e.g. to refill cache)
56go_inval | Called if remote state change requires invalidating the cache
57go_demote_ok | Returns boolean value of whether its ok to demote a glock
58 | (e.g. checks timeout, and that there is no cached data)
59go_lock | Called for the first local holder of a lock
60go_unlock | Called on the final local unlock of a lock
61go_dump | Called to print content of object for debugfs file, or on
62 | error to dump glock to the log.
63go_type; | The type of the glock, LM_TYPE_.....
64go_min_hold_time | The minimum hold time
65
66The minimum hold time for each lock is the time after a remote lock
67grant for which we ignore remote demote requests. This is in order to
68prevent a situation where locks are being bounced around the cluster
69from node to node with none of the nodes making any progress. This
70tends to show up most with shared mmaped files which are being written
71to by multiple nodes. By delaying the demotion in response to a
72remote callback, that gives the userspace program time to make
73some progress before the pages are unmapped.
74
75There is a plan to try and remove the go_lock and go_unlock callbacks
76if possible, in order to try and speed up the fast path though the locking.
77Also, eventually we hope to make the glock "EX" mode locally shared
78such that any local locking will be done with the i_mutex as required
79rather than via the glock.
80
81Locking rules for glock operations:
82
83Operation | GLF_LOCK bit lock held | gl_spin spinlock held
84-----------------------------------------------------------------
85go_xmote_th | Yes | No
86go_xmote_bh | Yes | No
87go_inval | Yes | No
88go_demote_ok | Sometimes | Yes
89go_lock | Yes | No
90go_unlock | Yes | No
91go_dump | Sometimes | Yes
92
93N.B. Operations must not drop either the bit lock or the spinlock
94if its held on entry. go_dump and do_demote_ok must never block.
95Note that go_dump will only be called if the glock's state
96indicates that it is caching uptodate data.
97
98Glock locking order within GFS2:
99
100 1. i_mutex (if required)
101 2. Rename glock (for rename only)
102 3. Inode glock(s)
103 (Parents before children, inodes at "same level" with same parent in
104 lock number order)
105 4. Rgrp glock(s) (for (de)allocation operations)
106 5. Transaction glock (via gfs2_trans_begin) for non-read operations
107 6. Page lock (always last, very important!)
108
109There are two glocks per inode. One deals with access to the inode
110itself (locking order as above), and the other, known as the iopen
111glock is used in conjunction with the i_nlink field in the inode to
112determine the lifetime of the inode in question. Locking of inodes
113is on a per-inode basis. Locking of rgrps is on a per rgrp basis.
114
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index dbc3c6a3650..7f268f327d7 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -380,28 +380,35 @@ i386 and x86_64 platforms support the new IRQ vector displays.
380Of some interest is the introduction of the /proc/irq directory to 2.4. 380Of some interest is the introduction of the /proc/irq directory to 2.4.
381It could be used to set IRQ to CPU affinity, this means that you can "hook" an 381It could be used to set IRQ to CPU affinity, this means that you can "hook" an
382IRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the 382IRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the
383irq subdir is one subdir for each IRQ, and one file; prof_cpu_mask 383irq subdir is one subdir for each IRQ, and two files; default_smp_affinity and
384prof_cpu_mask.
384 385
385For example 386For example
386 > ls /proc/irq/ 387 > ls /proc/irq/
387 0 10 12 14 16 18 2 4 6 8 prof_cpu_mask 388 0 10 12 14 16 18 2 4 6 8 prof_cpu_mask
388 1 11 13 15 17 19 3 5 7 9 389 1 11 13 15 17 19 3 5 7 9 default_smp_affinity
389 > ls /proc/irq/0/ 390 > ls /proc/irq/0/
390 smp_affinity 391 smp_affinity
391 392
392The contents of the prof_cpu_mask file and each smp_affinity file for each IRQ 393smp_affinity is a bitmask, in which you can specify which CPUs can handle the
393is the same by default: 394IRQ, you can set it by doing:
394 395
395 > cat /proc/irq/0/smp_affinity 396 > echo 1 > /proc/irq/10/smp_affinity
396 ffffffff 397
398This means that only the first CPU will handle the IRQ, but you can also echo
3995 which means that only the first and fourth CPU can handle the IRQ.
397 400
398It's a bitmask, in which you can specify which CPUs can handle the IRQ, you can 401The contents of each smp_affinity file is the same by default:
399set it by doing: 402
403 > cat /proc/irq/0/smp_affinity
404 ffffffff
400 405
401 > echo 1 > /proc/irq/prof_cpu_mask 406The default_smp_affinity mask applies to all non-active IRQs, which are the
407IRQs which have not yet been allocated/activated, and hence which lack a
408/proc/irq/[0-9]* directory.
402 409
403This means that only the first CPU will handle the IRQ, but you can also echo 5 410prof_cpu_mask specifies which CPUs are to be profiled by the system wide
404which means that only the first and fourth CPU can handle the IRQ. 411profiler. Default value is ffffffff (all cpus).
405 412
406The way IRQs are routed is handled by the IO-APIC, and it's Round Robin 413The way IRQs are routed is handled by the IO-APIC, and it's Round Robin
407between all the CPUs which are allowed to handle it. As usual the kernel has 414between all the CPUs which are allowed to handle it. As usual the kernel has
diff --git a/Documentation/ftrace.txt b/Documentation/ftrace.txt
index 77d3faa1a61..f218f616ff6 100644
--- a/Documentation/ftrace.txt
+++ b/Documentation/ftrace.txt
@@ -4,9 +4,10 @@
4Copyright 2008 Red Hat Inc. 4Copyright 2008 Red Hat Inc.
5 Author: Steven Rostedt <srostedt@redhat.com> 5 Author: Steven Rostedt <srostedt@redhat.com>
6 License: The GNU Free Documentation License, Version 1.2 6 License: The GNU Free Documentation License, Version 1.2
7Reviewers: Elias Oltmanns and Randy Dunlap 7Reviewers: Elias Oltmanns, Randy Dunlap, Andrew Morton,
8 John Kacur, and David Teigland.
8 9
9Writen for: 2.6.26-rc8 linux-2.6-tip.git tip/tracing/ftrace branch 10Written for: 2.6.27-rc1
10 11
11Introduction 12Introduction
12------------ 13------------
@@ -18,10 +19,11 @@ issues that take place outside of user-space.
18 19
19Although ftrace is the function tracer, it also includes an 20Although ftrace is the function tracer, it also includes an
20infrastructure that allows for other types of tracing. Some of the 21infrastructure that allows for other types of tracing. Some of the
21tracers that are currently in ftrace is a tracer to trace 22tracers that are currently in ftrace include a tracer to trace
22context switches, the time it takes for a high priority task to 23context switches, the time it takes for a high priority task to
23run after it was woken up, the time interrupts are disabled, and 24run after it was woken up, the time interrupts are disabled, and
24more. 25more (ftrace allows for tracer plugins, which means that the list of
26tracers can always grow).
25 27
26 28
27The File System 29The File System
@@ -35,6 +37,8 @@ To mount the debugfs system:
35 # mkdir /debug 37 # mkdir /debug
36 # mount -t debugfs nodev /debug 38 # mount -t debugfs nodev /debug
37 39
40(Note: it is more common to mount at /sys/kernel/debug, but for simplicity
41 this document will use /debug)
38 42
39That's it! (assuming that you have ftrace configured into your kernel) 43That's it! (assuming that you have ftrace configured into your kernel)
40 44
@@ -50,20 +54,19 @@ of ftrace. Here is a list of some of the key files:
50 54
51 available_tracers : This holds the different types of tracers that 55 available_tracers : This holds the different types of tracers that
52 have been compiled into the kernel. The tracers 56 have been compiled into the kernel. The tracers
53 listed here can be configured by echoing in their 57 listed here can be configured by echoing their name
54 name into current_tracer. 58 into current_tracer.
55 59
56 tracing_enabled : This sets or displays whether the current_tracer 60 tracing_enabled : This sets or displays whether the current_tracer
57 is activated and tracing or not. Echo 0 into this 61 is activated and tracing or not. Echo 0 into this
58 file to disable the tracer or 1 (or non-zero) to 62 file to disable the tracer or 1 to enable it.
59 enable it.
60 63
61 trace : This file holds the output of the trace in a human readable 64 trace : This file holds the output of the trace in a human readable
62 format. 65 format (described below).
63 66
64 latency_trace : This file shows the same trace but the information 67 latency_trace : This file shows the same trace but the information
65 is organized more to display possible latencies 68 is organized more to display possible latencies
66 in the system. 69 in the system (described below).
67 70
68 trace_pipe : The output is the same as the "trace" file but this 71 trace_pipe : The output is the same as the "trace" file but this
69 file is meant to be streamed with live tracing. 72 file is meant to be streamed with live tracing.
@@ -75,7 +78,7 @@ of ftrace. Here is a list of some of the key files:
75 file, it is consumed, and will not be read 78 file, it is consumed, and will not be read
76 again with a sequential read. The "trace" and 79 again with a sequential read. The "trace" and
77 "latency_trace" files are static, and if the 80 "latency_trace" files are static, and if the
78 tracer isn't adding more data, they will display 81 tracer is not adding more data, they will display
79 the same information every time they are read. 82 the same information every time they are read.
80 83
81 iter_ctrl : This file lets the user control the amount of data 84 iter_ctrl : This file lets the user control the amount of data
@@ -92,10 +95,10 @@ of ftrace. Here is a list of some of the key files:
92 95
93 trace_entries : This sets or displays the number of trace 96 trace_entries : This sets or displays the number of trace
94 entries each CPU buffer can hold. The tracer buffers 97 entries each CPU buffer can hold. The tracer buffers
95 are the same size for each CPU, so care must be 98 are the same size for each CPU. The displayed number
96 taken when modifying the trace_entries. The trace 99 is the size of the CPU buffer and not total size. The
97 buffers are allocated in pages (blocks of memory that 100 trace buffers are allocated in pages (blocks of memory
98 the kernel uses for allocation, usually 4 KB in size). 101 that the kernel uses for allocation, usually 4 KB in size).
99 Since each entry is smaller than a page, if the last 102 Since each entry is smaller than a page, if the last
100 allocated page has room for more entries than were 103 allocated page has room for more entries than were
101 requested, the rest of the page is used to allocate 104 requested, the rest of the page is used to allocate
@@ -112,20 +115,19 @@ of ftrace. Here is a list of some of the key files:
112 on specified CPUS. The format is a hex string 115 on specified CPUS. The format is a hex string
113 representing the CPUS. 116 representing the CPUS.
114 117
115 set_ftrace_filter : When dynamic ftrace is configured in, the 118 set_ftrace_filter : When dynamic ftrace is configured in (see the
116 code is dynamically modified to disable calling 119 section below "dynamic ftrace"), the code is dynamically
117 of the function profiler (mcount). This lets 120 modified (code text rewrite) to disable calling of the
118 tracing be configured in with practically no overhead 121 function profiler (mcount). This lets tracing be configured
119 in performance. This also has a side effect of 122 in with practically no overhead in performance. This also
120 enabling or disabling specific functions to be 123 has a side effect of enabling or disabling specific functions
121 traced. Echoing in names of functions into this 124 to be traced. Echoing names of functions into this file
122 file will limit the trace to only these functions. 125 will limit the trace to only those functions.
123 126
124 set_ftrace_notrace: This has the opposite effect that 127 set_ftrace_notrace: This has an effect opposite to that of
125 set_ftrace_filter has. Any function that is added 128 set_ftrace_filter. Any function that is added here will not
126 here will not be traced. If a function exists 129 be traced. If a function exists in both set_ftrace_filter
127 in both set_ftrace_filter and set_ftrace_notrace, 130 and set_ftrace_notrace, the function will _not_ be traced.
128 the function will _not_ be traced.
129 131
130 available_filter_functions : When a function is encountered the first 132 available_filter_functions : When a function is encountered the first
131 time by the dynamic tracer, it is recorded and 133 time by the dynamic tracer, it is recorded and
@@ -133,32 +135,31 @@ of ftrace. Here is a list of some of the key files:
133 lists the functions that have been recorded 135 lists the functions that have been recorded
134 by the dynamic tracer and these functions can 136 by the dynamic tracer and these functions can
135 be used to set the ftrace filter by the above 137 be used to set the ftrace filter by the above
136 "set_ftrace_filter" file. 138 "set_ftrace_filter" file. (See the section "dynamic ftrace"
139 below for more details).
137 140
138 141
139The Tracers 142The Tracers
140----------- 143-----------
141 144
142Here are the list of current tracers that can be configured. 145Here is the list of current tracers that may be configured.
143 146
144 ftrace - function tracer that uses mcount to trace all functions. 147 ftrace - function tracer that uses mcount to trace all functions.
145 It is possible to filter out which functions that are
146 to be traced when dynamic ftrace is configured in.
147 148
148 sched_switch - traces the context switches between tasks. 149 sched_switch - traces the context switches between tasks.
149 150
150 irqsoff - traces the areas that disable interrupts and saves off 151 irqsoff - traces the areas that disable interrupts and saves
151 the trace with the longest max latency. 152 the trace with the longest max latency.
152 See tracing_max_latency. When a new max is recorded, 153 See tracing_max_latency. When a new max is recorded,
153 it replaces the old trace. It is best to view this 154 it replaces the old trace. It is best to view this
154 trace with the latency_trace file. 155 trace via the latency_trace file.
155 156
156 preemptoff - Similar to irqsoff but traces and records the time 157 preemptoff - Similar to irqsoff but traces and records the amount of
157 preemption is disabled. 158 time for which preemption is disabled.
158 159
159 preemptirqsoff - Similar to irqsoff and preemptoff, but traces and 160 preemptirqsoff - Similar to irqsoff and preemptoff, but traces and
160 records the largest time irqs and/or preemption is 161 records the largest time for which irqs and/or preemption
161 disabled. 162 is disabled.
162 163
163 wakeup - Traces and records the max latency that it takes for 164 wakeup - Traces and records the max latency that it takes for
164 the highest priority task to get scheduled after 165 the highest priority task to get scheduled after
@@ -171,13 +172,13 @@ Here are the list of current tracers that can be configured.
171Examples of using the tracer 172Examples of using the tracer
172---------------------------- 173----------------------------
173 174
174Here are typical examples of using the tracers with only controlling 175Here are typical examples of using the tracers when controlling them only
175them with the debugfs interface (without using any user-land utilities). 176with the debugfs interface (without using any user-land utilities).
176 177
177Output format: 178Output format:
178-------------- 179--------------
179 180
180Here's an example of the output format of the file "trace" 181Here is an example of the output format of the file "trace"
181 182
182 -------- 183 --------
183# tracer: ftrace 184# tracer: ftrace
@@ -189,14 +190,15 @@ Here's an example of the output format of the file "trace"
189 bash-4251 [01] 10152.583855: _atomic_dec_and_lock <-dput 190 bash-4251 [01] 10152.583855: _atomic_dec_and_lock <-dput
190 -------- 191 --------
191 192
192A header is printed with the trace that is represented. In this case 193A header is printed with the tracer name that is represented by the trace.
193the tracer is "ftrace". Then a header showing the format. Task name 194In this case the tracer is "ftrace". Then a header showing the format. Task
194"bash", the task PID "4251", the CPU that it was running on 195name "bash", the task PID "4251", the CPU that it was running on
195"01", the timestamp in <secs>.<usecs> format, the function name that was 196"01", the timestamp in <secs>.<usecs> format, the function name that was
196traced "path_put" and the parent function that called this function 197traced "path_put" and the parent function that called this function
197"path_walk". 198"path_walk". The timestamp is the time at which the function was
199entered.
198 200
199The sched_switch tracer also includes tracing of task wake ups and 201The sched_switch tracer also includes tracing of task wakeups and
200context switches. 202context switches.
201 203
202 ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 2916:115:S 204 ksoftirqd/1-7 [01] 1453.070013: 7:115:R + 2916:115:S
@@ -206,7 +208,7 @@ context switches.
206 kondemand/1-2916 [01] 1453.070013: 2916:115:S ==> 7:115:R 208 kondemand/1-2916 [01] 1453.070013: 2916:115:S ==> 7:115:R
207 ksoftirqd/1-7 [01] 1453.070013: 7:115:S ==> 0:140:R 209 ksoftirqd/1-7 [01] 1453.070013: 7:115:S ==> 0:140:R
208 210
209Wake ups are represented by a "+" and the context switches show 211Wake ups are represented by a "+" and the context switches are shown as
210"==>". The format is: 212"==>". The format is:
211 213
212 Context switches: 214 Context switches:
@@ -221,7 +223,7 @@ Wake ups are represented by a "+" and the context switches show
221 223
222 <pid>:<prio>:<state> + <pid>:<prio>:<state> 224 <pid>:<prio>:<state> + <pid>:<prio>:<state>
223 225
224The prio is the internal kernel priority, which is inverse to the 226The prio is the internal kernel priority, which is the inverse of the
225priority that is usually displayed by user-space tools. Zero represents 227priority that is usually displayed by user-space tools. Zero represents
226the highest priority (99). Prio 100 starts the "nice" priorities with 228the highest priority (99). Prio 100 starts the "nice" priorities with
227100 being equal to nice -20 and 139 being nice 19. The prio "140" is 229100 being equal to nice -20 and 139 being nice 19. The prio "140" is
@@ -232,7 +234,7 @@ Latency trace format
232-------------------- 234--------------------
233 235
234For traces that display latency times, the latency_trace file gives 236For traces that display latency times, the latency_trace file gives
235a bit more information to see why a latency happened. Here's a typical 237somewhat more information to see why a latency happened. Here is a typical
236trace. 238trace.
237 239
238# tracer: irqsoff 240# tracer: irqsoff
@@ -260,21 +262,20 @@ irqsoff latency trace v1.1.5 on 2.6.26-rc8
260 <idle>-0 0d.s1 98us : trace_hardirqs_on (do_softirq) 262 <idle>-0 0d.s1 98us : trace_hardirqs_on (do_softirq)
261 263
262 264
263vim:ft=help
264
265 265
266This shows that the current tracer is "irqsoff" tracing the time 266This shows that the current tracer is "irqsoff" tracing the time for which
267interrupts are disabled. It gives the trace version and the kernel 267interrupts were disabled. It gives the trace version and the version
268this was executed on (2.6.26-rc8). Then it displays the max latency 268of the kernel upon which this was executed on (2.6.26-rc8). Then it displays
269in microsecs (97 us). The number of trace entries displayed 269the max latency in microsecs (97 us). The number of trace entries displayed
270by the total number recorded (both are three: #3/3). The type of 270and the total number recorded (both are three: #3/3). The type of
271preemption that was used (PREEMPT). VP, KP, SP, and HP are always zero 271preemption that was used (PREEMPT). VP, KP, SP, and HP are always zero
272and reserved for later use. #P is the number of online CPUS (#P:2). 272and are reserved for later use. #P is the number of online CPUS (#P:2).
273 273
274The task is the process that was running when the latency happened. 274The task is the process that was running when the latency occurred.
275(swapper pid: 0). 275(swapper pid: 0).
276 276
277The start and stop that caused the latencies: 277The start and stop (the functions in which the interrupts were disabled and
278enabled respectively) that caused the latencies:
278 279
279 apic_timer_interrupt is where the interrupts were disabled. 280 apic_timer_interrupt is where the interrupts were disabled.
280 do_softirq is where they were enabled again. 281 do_softirq is where they were enabled again.
@@ -286,14 +287,14 @@ explains which is which.
286 287
287 pid: The PID of that process. 288 pid: The PID of that process.
288 289
289 CPU#: The CPU that the process was running on. 290 CPU#: The CPU which the process was running on.
290 291
291 irqs-off: 'd' interrupts are disabled. '.' otherwise. 292 irqs-off: 'd' interrupts are disabled. '.' otherwise.
292 293
293 need-resched: 'N' task need_resched is set, '.' otherwise. 294 need-resched: 'N' task need_resched is set, '.' otherwise.
294 295
295 hardirq/softirq: 296 hardirq/softirq:
296 'H' - hard irq happened inside a softirq. 297 'H' - hard irq occurred inside a softirq.
297 'h' - hard irq is running 298 'h' - hard irq is running
298 's' - soft irq is running 299 's' - soft irq is running
299 '.' - normal context. 300 '.' - normal context.
@@ -303,7 +304,7 @@ explains which is which.
303The above is mostly meaningful for kernel developers. 304The above is mostly meaningful for kernel developers.
304 305
305 time: This differs from the trace file output. The trace file output 306 time: This differs from the trace file output. The trace file output
306 included an absolute timestamp. The timestamp used by the 307 includes an absolute timestamp. The timestamp used by the
307 latency_trace file is relative to the start of the trace. 308 latency_trace file is relative to the start of the trace.
308 309
309 delay: This is just to help catch your eye a bit better. And 310 delay: This is just to help catch your eye a bit better. And
@@ -385,7 +386,7 @@ Here are the available options:
385sched_switch 386sched_switch
386------------ 387------------
387 388
388This tracer simply records schedule switches. Here's an example 389This tracer simply records schedule switches. Here is an example
389of how to use it. 390of how to use it.
390 391
391 # echo sched_switch > /debug/tracing/current_tracer 392 # echo sched_switch > /debug/tracing/current_tracer
@@ -421,8 +422,8 @@ the name of the trace and points to the options. The "FUNCTION"
421is a misnomer since here it represents the wake ups and context 422is a misnomer since here it represents the wake ups and context
422switches. 423switches.
423 424
424The sched_switch only lists the wake ups (represented with '+') 425The sched_switch file only lists the wake ups (represented with '+')
425and context switches ('==>') with the previous task or current 426and context switches ('==>') with the previous task or current task
426first followed by the next task or task waking up. The format for both 427first followed by the next task or task waking up. The format for both
427of these is PID:KERNEL-PRIO:TASK-STATE. Remember that the KERNEL-PRIO 428of these is PID:KERNEL-PRIO:TASK-STATE. Remember that the KERNEL-PRIO
428is the inverse of the actual priority with zero (0) being the highest 429is the inverse of the actual priority with zero (0) being the highest
@@ -437,7 +438,8 @@ The task states are:
437 438
438 R - running : wants to run, may not actually be running 439 R - running : wants to run, may not actually be running
439 S - sleep : process is waiting to be woken up (handles signals) 440 S - sleep : process is waiting to be woken up (handles signals)
440 D - deep sleep : process must be woken up (ignores signals) 441 D - disk sleep (uninterruptible sleep) : process must be woken up
442 (ignores signals)
441 T - stopped : process suspended 443 T - stopped : process suspended
442 t - traced : process is being traced (with something like gdb) 444 t - traced : process is being traced (with something like gdb)
443 Z - zombie : process waiting to be cleaned up 445 Z - zombie : process waiting to be cleaned up
@@ -447,8 +449,8 @@ The task states are:
447ftrace_enabled 449ftrace_enabled
448-------------- 450--------------
449 451
450The following tracers give different output depending on whether 452The following tracers (listed below) give different output depending
451or not the sysctl ftrace_enabled is set. To set ftrace_enabled, 453on whether or not the sysctl ftrace_enabled is set. To set ftrace_enabled,
452one can either use the sysctl function or set it via the proc 454one can either use the sysctl function or set it via the proc
453file system interface. 455file system interface.
454 456
@@ -475,13 +477,12 @@ interrupt from triggering or the mouse interrupt from letting the
475kernel know of a new mouse event. The result is a latency with the 477kernel know of a new mouse event. The result is a latency with the
476reaction time. 478reaction time.
477 479
478The irqsoff tracer tracks the time interrupts are disabled to the time 480The irqsoff tracer tracks the time for which interrupts are disabled.
479they are re-enabled. When a new maximum latency is hit, it saves off 481When a new maximum latency is hit, the tracer saves the trace leading up
480the trace so that it may be retrieved at a later time. Every time a 482to that latency point so that every time a new maximum is reached, the old
481new maximum in reached, the old saved trace is discarded and the new 483saved trace is discarded and the new trace is saved.
482trace is saved.
483 484
484To reset the maximum, echo 0 into tracing_max_latency. Here's an 485To reset the maximum, echo 0 into tracing_max_latency. Here is an
485example: 486example:
486 487
487 # echo irqsoff > /debug/tracing/current_tracer 488 # echo irqsoff > /debug/tracing/current_tracer
@@ -493,14 +494,14 @@ example:
493 # cat /debug/tracing/latency_trace 494 # cat /debug/tracing/latency_trace
494# tracer: irqsoff 495# tracer: irqsoff
495# 496#
496irqsoff latency trace v1.1.5 on 2.6.26-rc8 497irqsoff latency trace v1.1.5 on 2.6.26
497-------------------------------------------------------------------- 498--------------------------------------------------------------------
498 latency: 6 us, #3/3, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:2) 499 latency: 12 us, #3/3, CPU#1 | (M:preempt VP:0, KP:0, SP:0 HP:0 #P:2)
499 ----------------- 500 -----------------
500 | task: bash-4269 (uid:0 nice:0 policy:0 rt_prio:0) 501 | task: bash-3730 (uid:0 nice:0 policy:0 rt_prio:0)
501 ----------------- 502 -----------------
502 => started at: copy_page_range 503 => started at: sys_setpgid
503 => ended at: copy_page_range 504 => ended at: sys_setpgid
504 505
505# _------=> CPU# 506# _------=> CPU#
506# / _-----=> irqs-off 507# / _-----=> irqs-off
@@ -511,21 +512,19 @@ irqsoff latency trace v1.1.5 on 2.6.26-rc8
511# ||||| delay 512# ||||| delay
512# cmd pid ||||| time | caller 513# cmd pid ||||| time | caller
513# \ / ||||| \ | / 514# \ / ||||| \ | /
514 bash-4269 1...1 0us+: _spin_lock (copy_page_range) 515 bash-3730 1d... 0us : _write_lock_irq (sys_setpgid)
515 bash-4269 1...1 7us : _spin_unlock (copy_page_range) 516 bash-3730 1d..1 1us+: _write_unlock_irq (sys_setpgid)
516 bash-4269 1...2 7us : trace_preempt_on (copy_page_range) 517 bash-3730 1d..2 14us : trace_hardirqs_on (sys_setpgid)
517
518 518
519vim:ft=help
520 519
521Here we see that that we had a latency of 6 microsecs (which is 520Here we see that that we had a latency of 12 microsecs (which is
522very good). The spin_lock in copy_page_range disabled interrupts. 521very good). The _write_lock_irq in sys_setpgid disabled interrupts.
523The difference between the 6 and the displayed timestamp 7us is 522The difference between the 12 and the displayed timestamp 14us occurred
524because the clock must have incremented between the time of recording 523because the clock was incremented between the time of recording the max
525the max latency and recording the function that had that latency. 524latency and the time of recording the function that had that latency.
526 525
527Note the above had ftrace_enabled not set. If we set the ftrace_enabled, 526Note the above example had ftrace_enabled not set. If we set the
528we get a much larger output: 527ftrace_enabled, we get a much larger output:
529 528
530# tracer: irqsoff 529# tracer: irqsoff
531# 530#
@@ -571,12 +570,10 @@ irqsoff latency trace v1.1.5 on 2.6.26-rc8
571 ls-4339 0d..2 51us : trace_hardirqs_on (__alloc_pages_internal) 570 ls-4339 0d..2 51us : trace_hardirqs_on (__alloc_pages_internal)
572 571
573 572
574vim:ft=help
575
576 573
577Here we traced a 50 microsecond latency. But we also see all the 574Here we traced a 50 microsecond latency. But we also see all the
578functions that were called during that time. Note that by enabling 575functions that were called during that time. Note that by enabling
579function tracing, we endure an added overhead. This overhead may 576function tracing, we incur an added overhead. This overhead may
580extend the latency times. But nevertheless, this trace has provided 577extend the latency times. But nevertheless, this trace has provided
581some very helpful debugging information. 578some very helpful debugging information.
582 579
@@ -590,8 +587,9 @@ for preemption to be enabled again before it can preempt a lower
590priority task. 587priority task.
591 588
592The preemptoff tracer traces the places that disable preemption. 589The preemptoff tracer traces the places that disable preemption.
593Like the irqsoff, it records the maximum latency that preemption 590Like the irqsoff tracer, it records the maximum latency for which preemption
594was disabled. The control of preemptoff is much like the irqsoff. 591was disabled. The control of preemptoff tracer is much like the irqsoff
592tracer.
595 593
596 # echo preemptoff > /debug/tracing/current_tracer 594 # echo preemptoff > /debug/tracing/current_tracer
597 # echo 0 > /debug/tracing/tracing_max_latency 595 # echo 0 > /debug/tracing/tracing_max_latency
@@ -625,8 +623,6 @@ preemptoff latency trace v1.1.5 on 2.6.26-rc8
625 sshd-4261 0d.s1 30us : trace_preempt_on (__do_softirq) 623 sshd-4261 0d.s1 30us : trace_preempt_on (__do_softirq)
626 624
627 625
628vim:ft=help
629
630This has some more changes. Preemption was disabled when an interrupt 626This has some more changes. Preemption was disabled when an interrupt
631came in (notice the 'h'), and was enabled while doing a softirq. 627came in (notice the 'h'), and was enabled while doing a softirq.
632(notice the 's'). But we also see that interrupts have been disabled 628(notice the 's'). But we also see that interrupts have been disabled
@@ -694,16 +690,16 @@ The above is an example of the preemptoff trace with ftrace_enabled
694set. Here we see that interrupts were disabled the entire time. 690set. Here we see that interrupts were disabled the entire time.
695The irq_enter code lets us know that we entered an interrupt 'h'. 691The irq_enter code lets us know that we entered an interrupt 'h'.
696Before that, the functions being traced still show that it is not 692Before that, the functions being traced still show that it is not
697in an interrupt, but we can see by the functions themselves that 693in an interrupt, but we can see from the functions themselves that
698this is not the case. 694this is not the case.
699 695
700Notice that the __do_softirq when called doesn't have a preempt_count. 696Notice that __do_softirq when called does not have a preempt_count.
701It may seem that we missed a preempt enabled. What really happened 697It may seem that we missed a preempt enabling. What really happened
702is that the preempt count is held on the threads stack and we 698is that the preempt count is held on the thread's stack and we
703switched to the softirq stack (4K stacks in effect). The code 699switched to the softirq stack (4K stacks in effect). The code
704does not copy the preempt count, but because interrupts are disabled, 700does not copy the preempt count, but because interrupts are disabled,
705we don't need to worry about it. Having a tracer like this is good 701we do not need to worry about it. Having a tracer like this is good
706to let people know what really happens inside the kernel. 702for letting people know what really happens inside the kernel.
707 703
708 704
709preemptirqsoff 705preemptirqsoff
@@ -713,7 +709,7 @@ Knowing the locations that have interrupts disabled or preemption
713disabled for the longest times is helpful. But sometimes we would 709disabled for the longest times is helpful. But sometimes we would
714like to know when either preemption and/or interrupts are disabled. 710like to know when either preemption and/or interrupts are disabled.
715 711
716The following code: 712Consider the following code:
717 713
718 local_irq_disable(); 714 local_irq_disable();
719 call_function_with_irqs_off(); 715 call_function_with_irqs_off();
@@ -769,12 +765,10 @@ preemptirqsoff latency trace v1.1.5 on 2.6.26-rc8
769 ls-4860 0d.s1 294us : trace_preempt_on (__do_softirq) 765 ls-4860 0d.s1 294us : trace_preempt_on (__do_softirq)
770 766
771 767
772vim:ft=help
773
774 768
775The trace_hardirqs_off_thunk is called from assembly on x86 when 769The trace_hardirqs_off_thunk is called from assembly on x86 when
776interrupts are disabled in the assembly code. Without the function 770interrupts are disabled in the assembly code. Without the function
777tracing, we don't know if interrupts were enabled within the preemption 771tracing, we do not know if interrupts were enabled within the preemption
778points. We do see that it started with preemption enabled. 772points. We do see that it started with preemption enabled.
779 773
780Here is a trace with ftrace_enabled set: 774Here is a trace with ftrace_enabled set:
@@ -865,19 +859,19 @@ preemptirqsoff latency trace v1.1.5 on 2.6.26-rc8
865 859
866This is a very interesting trace. It started with the preemption of 860This is a very interesting trace. It started with the preemption of
867the ls task. We see that the task had the "need_resched" bit set 861the ls task. We see that the task had the "need_resched" bit set
868with the 'N' in the trace. Interrupts are disabled in the spin_lock 862via the 'N' in the trace. Interrupts were disabled before the spin_lock
869and the trace started. We see that a schedule took place to run 863at the beginning of the trace. We see that a schedule took place to run
870sshd. When the interrupts were enabled, we took an interrupt. 864sshd. When the interrupts were enabled, we took an interrupt.
871On return from the interrupt handler, the softirq ran. We took another 865On return from the interrupt handler, the softirq ran. We took another
872interrupt while running the softirq as we see with the capital 'H'. 866interrupt while running the softirq as we see from the capital 'H'.
873 867
874 868
875wakeup 869wakeup
876------ 870------
877 871
878In Real-Time environment it is very important to know the wakeup 872In a Real-Time environment it is very important to know the wakeup
879time it takes for the highest priority task that wakes up to the 873time it takes for the highest priority task that is woken up to the
880time it executes. This is also known as "schedule latency". 874time that it executes. This is also known as "schedule latency".
881I stress the point that this is about RT tasks. It is also important 875I stress the point that this is about RT tasks. It is also important
882to know the scheduling latency of non-RT tasks, but the average 876to know the scheduling latency of non-RT tasks, but the average
883schedule latency is better for non-RT tasks. Tools like 877schedule latency is better for non-RT tasks. Tools like
@@ -926,8 +920,6 @@ wakeup latency trace v1.1.5 on 2.6.26-rc8
926 <idle>-0 1d..4 4us : schedule (cpu_idle) 920 <idle>-0 1d..4 4us : schedule (cpu_idle)
927 921
928 922
929vim:ft=help
930
931 923
932Running this on an idle system, we see that it only took 4 microseconds 924Running this on an idle system, we see that it only took 4 microseconds
933to perform the task switch. Note, since the trace marker in the 925to perform the task switch. Note, since the trace marker in the
@@ -996,15 +988,15 @@ ksoftirq-7 1d..6 49us : sub_preempt_count (_spin_unlock)
996ksoftirq-7 1d..4 50us : schedule (__cond_resched) 988ksoftirq-7 1d..4 50us : schedule (__cond_resched)
997 989
998The interrupt went off while running ksoftirqd. This task runs at 990The interrupt went off while running ksoftirqd. This task runs at
999SCHED_OTHER. Why didn't we see the 'N' set early? This may be 991SCHED_OTHER. Why did not we see the 'N' set early? This may be
1000a harmless bug with x86_32 and 4K stacks. On x86_32 with 4K stacks 992a harmless bug with x86_32 and 4K stacks. On x86_32 with 4K stacks
1001configured, the interrupt and softirq runs with their own stack. 993configured, the interrupt and softirq run with their own stack.
1002Some information is held on the top of the task's stack (need_resched 994Some information is held on the top of the task's stack (need_resched
1003and preempt_count are both stored there). The setting of the NEED_RESCHED 995and preempt_count are both stored there). The setting of the NEED_RESCHED
1004bit is done directly to the task's stack, but the reading of the 996bit is done directly to the task's stack, but the reading of the
1005NEED_RESCHED is done by looking at the current stack, which in this case 997NEED_RESCHED is done by looking at the current stack, which in this case
1006is the stack for the hard interrupt. This hides the fact that NEED_RESCHED 998is the stack for the hard interrupt. This hides the fact that NEED_RESCHED
1007has been set. We don't see the 'N' until we switch back to the task's 999has been set. We do not see the 'N' until we switch back to the task's
1008assigned stack. 1000assigned stack.
1009 1001
1010ftrace 1002ftrace
@@ -1044,14 +1036,14 @@ this tracer is a nop.
1044[...] 1036[...]
1045 1037
1046 1038
1047Note: It is sometimes better to enable or disable tracing directly from 1039Note: ftrace uses ring buffers to store the above entries. The newest data
1048a program, because the buffer may be overflowed by the echo commands 1040may overwrite the oldest data. Sometimes using echo to stop the trace
1049before you get to the point you want to trace. It is also easier to 1041is not sufficient because the tracing could have overwritten the data
1050stop the tracing at the point that you hit the part that you are 1042that you wanted to record. For this reason, it is sometimes better to
1051interested in. Since the ftrace buffer is a ring buffer with the 1043disable tracing directly from a program. This allows you to stop the
1052oldest data being overwritten, usually it is sufficient to start the 1044tracing at the point that you hit the part that you are interested in.
1053tracer with an echo command but have you code stop it. Something 1045To disable the tracing directly from a C program, something like following
1054like the following is usually appropriate for this. 1046code snippet can be used:
1055 1047
1056int trace_fd; 1048int trace_fd;
1057[...] 1049[...]
@@ -1060,20 +1052,26 @@ int main(int argc, char *argv[]) {
1060 trace_fd = open("/debug/tracing/tracing_enabled", O_WRONLY); 1052 trace_fd = open("/debug/tracing/tracing_enabled", O_WRONLY);
1061 [...] 1053 [...]
1062 if (condition_hit()) { 1054 if (condition_hit()) {
1063 write(trace_fd, "0", 1); 1055 write(trace_fd, "0", 1);
1064 } 1056 }
1065 [...] 1057 [...]
1066} 1058}
1067 1059
1060Note: Here we hard coded the path name. The debugfs mount is not
1061guaranteed to be at /debug (and is more commonly at /sys/kernel/debug).
1062For simple one time traces, the above is sufficent. For anything else,
1063a search through /proc/mounts may be needed to find where the debugfs
1064file-system is mounted.
1068 1065
1069dynamic ftrace 1066dynamic ftrace
1070-------------- 1067--------------
1071 1068
1072If CONFIG_DYNAMIC_FTRACE is set, then the system will run with 1069If CONFIG_DYNAMIC_FTRACE is set, the system will run with
1073virtually no overhead when function tracing is disabled. The way 1070virtually no overhead when function tracing is disabled. The way
1074this works is the mcount function call (placed at the start of 1071this works is the mcount function call (placed at the start of
1075every kernel function, produced by the -pg switch in gcc), starts 1072every kernel function, produced by the -pg switch in gcc), starts
1076of pointing to a simple return. 1073of pointing to a simple return. (Enabling FTRACE will include the
1074-pg switch in the compiling of the kernel.)
1077 1075
1078When dynamic ftrace is initialized, it calls kstop_machine to make 1076When dynamic ftrace is initialized, it calls kstop_machine to make
1079the machine act like a uniprocessor so that it can freely modify code 1077the machine act like a uniprocessor so that it can freely modify code
@@ -1086,15 +1084,15 @@ Later on the ftraced kernel thread is awoken and will again call
1086kstop_machine if new functions have been recorded. The ftraced thread 1084kstop_machine if new functions have been recorded. The ftraced thread
1087will change all calls to mcount to "nop". Just calling mcount 1085will change all calls to mcount to "nop". Just calling mcount
1088and having mcount return has shown a 10% overhead. By converting 1086and having mcount return has shown a 10% overhead. By converting
1089it to a nop, there is no recordable overhead to the system. 1087it to a nop, there is no measurable overhead to the system.
1090 1088
1091One special side-effect to the recording of the functions being 1089One special side-effect to the recording of the functions being
1092traced, is that we can now selectively choose which functions we 1090traced is that we can now selectively choose which functions we
1093want to trace and which ones we want the mcount calls to remain as 1091wish to trace and which ones we want the mcount calls to remain as
1094nops. 1092nops.
1095 1093
1096Two files are used, one for enabling and one for disabling the tracing 1094Two files are used, one for enabling and one for disabling the tracing
1097of recorded functions. They are: 1095of specified functions. They are:
1098 1096
1099 set_ftrace_filter 1097 set_ftrace_filter
1100 1098
@@ -1116,7 +1114,7 @@ pick_next_task_fair
1116mutex_lock 1114mutex_lock
1117[...] 1115[...]
1118 1116
1119If I'm only interested in sys_nanosleep and hrtimer_interrupt: 1117If I am only interested in sys_nanosleep and hrtimer_interrupt:
1120 1118
1121 # echo sys_nanosleep hrtimer_interrupt \ 1119 # echo sys_nanosleep hrtimer_interrupt \
1122 > /debug/tracing/set_ftrace_filter 1120 > /debug/tracing/set_ftrace_filter
@@ -1133,21 +1131,21 @@ If I'm only interested in sys_nanosleep and hrtimer_interrupt:
1133 usleep-4134 [00] 1317.070111: sys_nanosleep <-syscall_call 1131 usleep-4134 [00] 1317.070111: sys_nanosleep <-syscall_call
1134 <idle>-0 [00] 1317.070115: hrtimer_interrupt <-smp_apic_timer_interrupt 1132 <idle>-0 [00] 1317.070115: hrtimer_interrupt <-smp_apic_timer_interrupt
1135 1133
1136To see what functions are being traced, you can cat the file: 1134To see which functions are being traced, you can cat the file:
1137 1135
1138 # cat /debug/tracing/set_ftrace_filter 1136 # cat /debug/tracing/set_ftrace_filter
1139hrtimer_interrupt 1137hrtimer_interrupt
1140sys_nanosleep 1138sys_nanosleep
1141 1139
1142 1140
1143Perhaps this isn't enough. The filters also allow simple wild cards. 1141Perhaps this is not enough. The filters also allow simple wild cards.
1144Only the following are currently available 1142Only the following are currently available
1145 1143
1146 <match>* - will match functions that begin with <match> 1144 <match>* - will match functions that begin with <match>
1147 *<match> - will match functions that end with <match> 1145 *<match> - will match functions that end with <match>
1148 *<match>* - will match functions that have <match> in it 1146 *<match>* - will match functions that have <match> in it
1149 1147
1150Thats all the wild cards that are allowed. 1148These are the only wild cards which are supported.
1151 1149
1152 <match>*<match> will not work. 1150 <match>*<match> will not work.
1153 1151
@@ -1258,15 +1256,15 @@ calls that need to be converted into nops. If there are not any, then
1258it simply goes back to sleep. But if there are some, it will call 1256it simply goes back to sleep. But if there are some, it will call
1259kstop_machine to convert the calls to nops. 1257kstop_machine to convert the calls to nops.
1260 1258
1261There may be a case that you do not want this added latency. 1259There may be a case in which you do not want this added latency.
1262Perhaps you are doing some audio recording and this activity might 1260Perhaps you are doing some audio recording and this activity might
1263cause skips in the playback. There is an interface to disable 1261cause skips in the playback. There is an interface to disable
1264and enable the ftraced kernel thread. 1262and enable the "ftraced" kernel thread.
1265 1263
1266 # echo 0 > /debug/tracing/ftraced_enabled 1264 # echo 0 > /debug/tracing/ftraced_enabled
1267 1265
1268This will disable the calling of the kstop_machine to update the 1266This will disable the calling of kstop_machine to update the
1269mcount calls to nops. Remember that there's a large overhead 1267mcount calls to nops. Remember that there is a large overhead
1270to calling mcount. Without this kernel thread, that overhead will 1268to calling mcount. Without this kernel thread, that overhead will
1271exist. 1269exist.
1272 1270
@@ -1282,8 +1280,8 @@ that uses ftrace function recording.
1282trace_pipe 1280trace_pipe
1283---------- 1281----------
1284 1282
1285The trace_pipe outputs the same as trace, but the effect on the 1283The trace_pipe outputs the same content as the trace file, but the effect
1286tracing is different. Every read from trace_pipe is consumed. 1284on the tracing is different. Every read from trace_pipe is consumed.
1287This means that subsequent reads will be different. The trace 1285This means that subsequent reads will be different. The trace
1288is live. 1286is live.
1289 1287
@@ -1313,7 +1311,7 @@ is live.
1313 bash-4043 [00] 41.267111: select_task_rq_rt <-try_to_wake_up 1311 bash-4043 [00] 41.267111: select_task_rq_rt <-try_to_wake_up
1314 1312
1315 1313
1316Note, reading the trace_pipe will block until more input is added. 1314Note, reading the trace_pipe file will block until more input is added.
1317By changing the tracer, trace_pipe will issue an EOF. We needed 1315By changing the tracer, trace_pipe will issue an EOF. We needed
1318to set the ftrace tracer _before_ cating the trace_pipe file. 1316to set the ftrace tracer _before_ cating the trace_pipe file.
1319 1317
@@ -1322,7 +1320,7 @@ trace entries
1322------------- 1320-------------
1323 1321
1324Having too much or not enough data can be troublesome in diagnosing 1322Having too much or not enough data can be troublesome in diagnosing
1325some issue in the kernel. The file trace_entries is used to modify 1323an issue in the kernel. The file trace_entries is used to modify
1326the size of the internal trace buffers. The number listed 1324the size of the internal trace buffers. The number listed
1327is the number of entries that can be recorded per CPU. To know 1325is the number of entries that can be recorded per CPU. To know
1328the full size, multiply the number of possible CPUS with the 1326the full size, multiply the number of possible CPUS with the
@@ -1332,7 +1330,8 @@ number of entries.
133265620 133065620
1333 1331
1334Note, to modify this, you must have tracing completely disabled. To do that, 1332Note, to modify this, you must have tracing completely disabled. To do that,
1335echo "none" into the current_tracer. 1333echo "none" into the current_tracer. If the current_tracer is not set
1334to "none", an EINVAL error will be returned.
1336 1335
1337 # echo none > /debug/tracing/current_tracer 1336 # echo none > /debug/tracing/current_tracer
1338 # echo 100000 > /debug/tracing/trace_entries 1337 # echo 100000 > /debug/tracing/trace_entries
@@ -1341,18 +1340,18 @@ echo "none" into the current_tracer.
1341 1340
1342 1341
1343Notice that we echoed in 100,000 but the size is 100,045. The entries 1342Notice that we echoed in 100,000 but the size is 100,045. The entries
1344are held by individual pages. It allocates the number of pages it takes 1343are held in individual pages. It allocates the number of pages it takes
1345to fulfill the request. If more entries may fit on the last page 1344to fulfill the request. If more entries may fit on the last page
1346it will add them. 1345then they will be added.
1347 1346
1348 # echo 1 > /debug/tracing/trace_entries 1347 # echo 1 > /debug/tracing/trace_entries
1349 # cat /debug/tracing/trace_entries 1348 # cat /debug/tracing/trace_entries
135085 134985
1351 1350
1352This shows us that 85 entries can fit on a single page. 1351This shows us that 85 entries can fit in a single page.
1353 1352
1354The number of pages that will be allocated is a percentage of available 1353The number of pages which will be allocated is limited to a percentage
1355memory. Allocating too much will produce an error. 1354of available memory. Allocating too much will produce an error.
1356 1355
1357 # echo 1000000000000 > /debug/tracing/trace_entries 1356 # echo 1000000000000 > /debug/tracing/trace_entries
1358-bash: echo: write error: Cannot allocate memory 1357-bash: echo: write error: Cannot allocate memory
diff --git a/Documentation/i2c/busses/i2c-i810 b/Documentation/i2c/busses/i2c-i810
deleted file mode 100644
index 778210ee158..00000000000
--- a/Documentation/i2c/busses/i2c-i810
+++ /dev/null
@@ -1,47 +0,0 @@
1Kernel driver i2c-i810
2
3Supported adapters:
4 * Intel 82810, 82810-DC100, 82810E, and 82815 (GMCH)
5 * Intel 82845G (GMCH)
6
7Authors:
8 Frodo Looijaard <frodol@dds.nl>,
9 Philip Edelbrock <phil@netroedge.com>,
10 Kyösti Mälkki <kmalkki@cc.hut.fi>,
11 Ralph Metzler <rjkm@thp.uni-koeln.de>,
12 Mark D. Studebaker <mdsxyz123@yahoo.com>
13
14Main contact: Mark Studebaker <mdsxyz123@yahoo.com>
15
16Description
17-----------
18
19WARNING: If you have an '810' or '815' motherboard, your standard I2C
20temperature sensors are most likely on the 801's I2C bus. You want the
21i2c-i801 driver for those, not this driver.
22
23Now for the i2c-i810...
24
25The GMCH chip contains two I2C interfaces.
26
27The first interface is used for DDC (Data Display Channel) which is a
28serial channel through the VGA monitor connector to a DDC-compliant
29monitor. This interface is defined by the Video Electronics Standards
30Association (VESA). The standards are available for purchase at
31http://www.vesa.org .
32
33The second interface is a general-purpose I2C bus. It may be connected to a
34TV-out chip such as the BT869 or possibly to a digital flat-panel display.
35
36Features
37--------
38
39Both busses use the i2c-algo-bit driver for 'bit banging'
40and support for specific transactions is provided by i2c-algo-bit.
41
42Issues
43------
44
45If you enable bus testing in i2c-algo-bit (insmod i2c-algo-bit bit_test=1),
46the test may fail; if so, the i2c-i810 driver won't be inserted. However,
47we think this has been fixed.
diff --git a/Documentation/i2c/busses/i2c-prosavage b/Documentation/i2c/busses/i2c-prosavage
deleted file mode 100644
index 70368790251..00000000000
--- a/Documentation/i2c/busses/i2c-prosavage
+++ /dev/null
@@ -1,23 +0,0 @@
1Kernel driver i2c-prosavage
2
3Supported adapters:
4
5 S3/VIA KM266/VT8375 aka ProSavage8
6 S3/VIA KM133/VT8365 aka Savage4
7
8Author: Henk Vergonet <henk@god.dyndns.org>
9
10Description
11-----------
12
13The Savage4 chips contain two I2C interfaces (aka a I2C 'master' or
14'host').
15
16The first interface is used for DDC (Data Display Channel) which is a
17serial channel through the VGA monitor connector to a DDC-compliant
18monitor. This interface is defined by the Video Electronics Standards
19Association (VESA). The standards are available for purchase at
20http://www.vesa.org . The second interface is a general-purpose I2C bus.
21
22Usefull for gaining access to the TV Encoder chips.
23
diff --git a/Documentation/i2c/busses/i2c-savage4 b/Documentation/i2c/busses/i2c-savage4
deleted file mode 100644
index 6ecceab618d..00000000000
--- a/Documentation/i2c/busses/i2c-savage4
+++ /dev/null
@@ -1,26 +0,0 @@
1Kernel driver i2c-savage4
2
3Supported adapters:
4 * Savage4
5 * Savage2000
6
7Authors:
8 Alexander Wold <awold@bigfoot.com>,
9 Mark D. Studebaker <mdsxyz123@yahoo.com>
10
11Description
12-----------
13
14The Savage4 chips contain two I2C interfaces (aka a I2C 'master'
15or 'host').
16
17The first interface is used for DDC (Data Display Channel) which is a
18serial channel through the VGA monitor connector to a DDC-compliant
19monitor. This interface is defined by the Video Electronics Standards
20Association (VESA). The standards are available for purchase at
21http://www.vesa.org . The DDC bus is not yet supported because its register
22is not directly memory-mapped.
23
24The second interface is a general-purpose I2C bus. This is the only
25interface supported by the driver at the moment.
26
diff --git a/Documentation/i2c/fault-codes b/Documentation/i2c/fault-codes
new file mode 100644
index 00000000000..045765c0b9b
--- /dev/null
+++ b/Documentation/i2c/fault-codes
@@ -0,0 +1,127 @@
1This is a summary of the most important conventions for use of fault
2codes in the I2C/SMBus stack.
3
4
5A "Fault" is not always an "Error"
6----------------------------------
7Not all fault reports imply errors; "page faults" should be a familiar
8example. Software often retries idempotent operations after transient
9faults. There may be fancier recovery schemes that are appropriate in
10some cases, such as re-initializing (and maybe resetting). After such
11recovery, triggered by a fault report, there is no error.
12
13In a similar way, sometimes a "fault" code just reports one defined
14result for an operation ... it doesn't indicate that anything is wrong
15at all, just that the outcome wasn't on the "golden path".
16
17In short, your I2C driver code may need to know these codes in order
18to respond correctly. Other code may need to rely on YOUR code reporting
19the right fault code, so that it can (in turn) behave correctly.
20
21
22I2C and SMBus fault codes
23-------------------------
24These are returned as negative numbers from most calls, with zero or
25some positive number indicating a non-fault return. The specific
26numbers associated with these symbols differ between architectures,
27though most Linux systems use <asm-generic/errno*.h> numbering.
28
29Note that the descriptions here are not exhaustive. There are other
30codes that may be returned, and other cases where these codes should
31be returned. However, drivers should not return other codes for these
32cases (unless the hardware doesn't provide unique fault reports).
33
34Also, codes returned by adapter probe methods follow rules which are
35specific to their host bus (such as PCI, or the platform bus).
36
37
38EAGAIN
39 Returned by I2C adapters when they lose arbitration in master
40 transmit mode: some other master was transmitting different
41 data at the same time.
42
43 Also returned when trying to invoke an I2C operation in an
44 atomic context, when some task is already using that I2C bus
45 to execute some other operation.
46
47EBADMSG
48 Returned by SMBus logic when an invalid Packet Error Code byte
49 is received. This code is a CRC covering all bytes in the
50 transaction, and is sent before the terminating STOP. This
51 fault is only reported on read transactions; the SMBus slave
52 may have a way to report PEC mismatches on writes from the
53 host. Note that even if PECs are in use, you should not rely
54 on these as the only way to detect incorrect data transfers.
55
56EBUSY
57 Returned by SMBus adapters when the bus was busy for longer
58 than allowed. This usually indicates some device (maybe the
59 SMBus adapter) needs some fault recovery (such as resetting),
60 or that the reset was attempted but failed.
61
62EINVAL
63 This rather vague error means an invalid parameter has been
64 detected before any I/O operation was started. Use a more
65 specific fault code when you can.
66
67 One example would be a driver trying an SMBus Block Write
68 with block size outside the range of 1-32 bytes.
69
70EIO
71 This rather vague error means something went wrong when
72 performing an I/O operation. Use a more specific fault
73 code when you can.
74
75ENODEV
76 Returned by driver probe() methods. This is a bit more
77 specific than ENXIO, implying the problem isn't with the
78 address, but with the device found there. Driver probes
79 may verify the device returns *correct* responses, and
80 return this as appropriate. (The driver core will warn
81 about probe faults other than ENXIO and ENODEV.)
82
83ENOMEM
84 Returned by any component that can't allocate memory when
85 it needs to do so.
86
87ENXIO
88 Returned by I2C adapters to indicate that the address phase
89 of a transfer didn't get an ACK. While it might just mean
90 an I2C device was temporarily not responding, usually it
91 means there's nothing listening at that address.
92
93 Returned by driver probe() methods to indicate that they
94 found no device to bind to. (ENODEV may also be used.)
95
96EOPNOTSUPP
97 Returned by an adapter when asked to perform an operation
98 that it doesn't, or can't, support.
99
100 For example, this would be returned when an adapter that
101 doesn't support SMBus block transfers is asked to execute
102 one. In that case, the driver making that request should
103 have verified that functionality was supported before it
104 made that block transfer request.
105
106 Similarly, if an I2C adapter can't execute all legal I2C
107 messages, it should return this when asked to perform a
108 transaction it can't. (These limitations can't be seen in
109 the adapter's functionality mask, since the assumption is
110 that if an adapter supports I2C it supports all of I2C.)
111
112EPROTO
113 Returned when slave does not conform to the relevant I2C
114 or SMBus (or chip-specific) protocol specifications. One
115 case is when the length of an SMBus block data response
116 (from the SMBus slave) is outside the range 1-32 bytes.
117
118ETIMEDOUT
119 This is returned by drivers when an operation took too much
120 time, and was aborted before it completed.
121
122 SMBus adapters may return it when an operation took more
123 time than allowed by the SMBus specification; for example,
124 when a slave stretches clocks too far. I2C has no such
125 timeouts, but it's normal for I2C adapters to impose some
126 arbitrary limits (much longer than SMBus!) too.
127
diff --git a/Documentation/i2c/smbus-protocol b/Documentation/i2c/smbus-protocol
index 03f08fb491c..24bfb65da17 100644
--- a/Documentation/i2c/smbus-protocol
+++ b/Documentation/i2c/smbus-protocol
@@ -42,8 +42,8 @@ Count (8 bits): A data byte containing the length of a block operation.
42[..]: Data sent by I2C device, as opposed to data sent by the host adapter. 42[..]: Data sent by I2C device, as opposed to data sent by the host adapter.
43 43
44 44
45SMBus Quick Command: i2c_smbus_write_quick() 45SMBus Quick Command
46============================================= 46===================
47 47
48This sends a single bit to the device, at the place of the Rd/Wr bit. 48This sends a single bit to the device, at the place of the Rd/Wr bit.
49 49
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index d4cd4126d1a..6b61b3a2e90 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -44,6 +44,10 @@ static struct i2c_driver foo_driver = {
44 .id_table = foo_ids, 44 .id_table = foo_ids,
45 .probe = foo_probe, 45 .probe = foo_probe,
46 .remove = foo_remove, 46 .remove = foo_remove,
47 /* if device autodetection is needed: */
48 .class = I2C_CLASS_SOMETHING,
49 .detect = foo_detect,
50 .address_data = &addr_data,
47 51
48 /* else, driver uses "legacy" binding model: */ 52 /* else, driver uses "legacy" binding model: */
49 .attach_adapter = foo_attach_adapter, 53 .attach_adapter = foo_attach_adapter,
@@ -217,6 +221,31 @@ in the I2C bus driver. You may want to save the returned i2c_client
217reference for later use. 221reference for later use.
218 222
219 223
224Device Detection (Standard driver model)
225----------------------------------------
226
227Sometimes you do not know in advance which I2C devices are connected to
228a given I2C bus. This is for example the case of hardware monitoring
229devices on a PC's SMBus. In that case, you may want to let your driver
230detect supported devices automatically. This is how the legacy model
231was working, and is now available as an extension to the standard
232driver model (so that we can finally get rid of the legacy model.)
233
234You simply have to define a detect callback which will attempt to
235identify supported devices (returning 0 for supported ones and -ENODEV
236for unsupported ones), a list of addresses to probe, and a device type
237(or class) so that only I2C buses which may have that type of device
238connected (and not otherwise enumerated) will be probed. The i2c
239core will then call you back as needed and will instantiate a device
240for you for every successful detection.
241
242Note that this mechanism is purely optional and not suitable for all
243devices. You need some reliable way to identify the supported devices
244(typically using device-specific, dedicated identification registers),
245otherwise misdetections are likely to occur and things can get wrong
246quickly.
247
248
220Device Deletion (Standard driver model) 249Device Deletion (Standard driver model)
221--------------------------------------- 250---------------------------------------
222 251
@@ -569,7 +598,6 @@ SMBus communication
569 in terms of it. Never use this function directly! 598 in terms of it. Never use this function directly!
570 599
571 600
572 extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
573 extern s32 i2c_smbus_read_byte(struct i2c_client * client); 601 extern s32 i2c_smbus_read_byte(struct i2c_client * client);
574 extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 602 extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
575 extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 603 extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
@@ -578,30 +606,31 @@ SMBus communication
578 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 606 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command);
579 extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 607 extern s32 i2c_smbus_write_word_data(struct i2c_client * client,
580 u8 command, u16 value); 608 u8 command, u16 value);
609 extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
610 u8 command, u8 *values);
581 extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 611 extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
582 u8 command, u8 length, 612 u8 command, u8 length,
583 u8 *values); 613 u8 *values);
584 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 614 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
585 u8 command, u8 length, u8 *values); 615 u8 command, u8 length, u8 *values);
586
587These ones were removed in Linux 2.6.10 because they had no users, but could
588be added back later if needed:
589
590 extern s32 i2c_smbus_read_block_data(struct i2c_client * client,
591 u8 command, u8 *values);
592 extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 616 extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
593 u8 command, u8 length, 617 u8 command, u8 length,
594 u8 *values); 618 u8 *values);
619
620These ones were removed from i2c-core because they had no users, but could
621be added back later if needed:
622
623 extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
595 extern s32 i2c_smbus_process_call(struct i2c_client * client, 624 extern s32 i2c_smbus_process_call(struct i2c_client * client,
596 u8 command, u16 value); 625 u8 command, u16 value);
597 extern s32 i2c_smbus_block_process_call(struct i2c_client *client, 626 extern s32 i2c_smbus_block_process_call(struct i2c_client *client,
598 u8 command, u8 length, 627 u8 command, u8 length,
599 u8 *values) 628 u8 *values)
600 629
601All these transactions return -1 on failure. The 'write' transactions 630All these transactions return a negative errno value on failure. The 'write'
602return 0 on success; the 'read' transactions return the read value, except 631transactions return 0 on success; the 'read' transactions return the read
603for read_block, which returns the number of values read. The block buffers 632value, except for block transactions, which return the number of values
604need not be longer than 32 bytes. 633read. The block buffers need not be longer than 32 bytes.
605 634
606You can read the file `smbus-protocol' for more information about the 635You can read the file `smbus-protocol' for more information about the
607actual SMBus protocol. 636actual SMBus protocol.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index b3a5aad7e62..312fe77764a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -571,6 +571,8 @@ and is between 256 and 4096 characters. It is defined in the file
571 571
572 debug_objects [KNL] Enable object debugging 572 debug_objects [KNL] Enable object debugging
573 573
574 debugpat [X86] Enable PAT debugging
575
574 decnet.addr= [HW,NET] 576 decnet.addr= [HW,NET]
575 Format: <area>[,<node>] 577 Format: <area>[,<node>]
576 See also Documentation/networking/decnet.txt. 578 See also Documentation/networking/decnet.txt.
@@ -756,9 +758,6 @@ and is between 256 and 4096 characters. It is defined in the file
756 hd= [EIDE] (E)IDE hard drive subsystem geometry 758 hd= [EIDE] (E)IDE hard drive subsystem geometry
757 Format: <cyl>,<head>,<sect> 759 Format: <cyl>,<head>,<sect>
758 760
759 hd?= [HW] (E)IDE subsystem
760 hd?lun= See Documentation/ide/ide.txt.
761
762 highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact 761 highmem=nn[KMG] [KNL,BOOT] forces the highmem zone to have an exact
763 size of <nn>. This works even on boxes that have no 762 size of <nn>. This works even on boxes that have no
764 highmem otherwise. This also works to reduce highmem 763 highmem otherwise. This also works to reduce highmem
@@ -1610,6 +1609,10 @@ and is between 256 and 4096 characters. It is defined in the file
1610 Format: { parport<nr> | timid | 0 } 1609 Format: { parport<nr> | timid | 0 }
1611 See also Documentation/parport.txt. 1610 See also Documentation/parport.txt.
1612 1611
1612 pmtmr= [X86] Manual setup of pmtmr I/O Port.
1613 Override pmtimer IOPort with a hex value.
1614 e.g. pmtmr=0x508
1615
1613 pnpacpi= [ACPI] 1616 pnpacpi= [ACPI]
1614 { off } 1617 { off }
1615 1618
diff --git a/MAINTAINERS b/MAINTAINERS
index 1528e58b540..fc6c005c531 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1686,6 +1686,13 @@ L: linuxppc-embedded@ozlabs.org
1686L: linux-kernel@vger.kernel.org 1686L: linux-kernel@vger.kernel.org
1687S: Maintained 1687S: Maintained
1688 1688
1689FREESCALE I2C CPM DRIVER
1690P: Jochen Friedrich
1691M: jochen@scram.de
1692L: linuxppc-dev@ozlabs.org
1693L: i2c@lm-sensors.org
1694S: Maintained
1695
1689FREESCALE SOC FS_ENET DRIVER 1696FREESCALE SOC FS_ENET DRIVER
1690P: Pantelis Antoniou 1697P: Pantelis Antoniou
1691M: pantelis.antoniou@gmail.com 1698M: pantelis.antoniou@gmail.com
@@ -1770,6 +1777,11 @@ M: hch@infradead.org
1770W: ftp://ftp.openlinux.org/pub/people/hch/vxfs 1777W: ftp://ftp.openlinux.org/pub/people/hch/vxfs
1771S: Maintained 1778S: Maintained
1772 1779
1780FTRACE
1781P: Steven Rostedt
1782M: srostedt@redhat.com
1783S: Maintained
1784
1773FUJITSU FR-V (FRV) PORT 1785FUJITSU FR-V (FRV) PORT
1774P: David Howells 1786P: David Howells
1775M: dhowells@redhat.com 1787M: dhowells@redhat.com
diff --git a/arch/Kconfig b/arch/Kconfig
index 3ea332b009e..ad89a33d8c6 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -39,3 +39,6 @@ config HAVE_KRETPROBES
39 39
40config HAVE_DMA_ATTRS 40config HAVE_DMA_ATTRS
41 def_bool n 41 def_bool n
42
43config USE_GENERIC_SMP_HELPERS
44 def_bool n
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 729cdbdf803..dbe8c280fea 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -528,6 +528,7 @@ config ARCH_MAY_HAVE_PC_FDC
528config SMP 528config SMP
529 bool "Symmetric multi-processing support" 529 bool "Symmetric multi-processing support"
530 depends on ALPHA_SABLE || ALPHA_LYNX || ALPHA_RAWHIDE || ALPHA_DP264 || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_GENERIC || ALPHA_SHARK || ALPHA_MARVEL 530 depends on ALPHA_SABLE || ALPHA_LYNX || ALPHA_RAWHIDE || ALPHA_DP264 || ALPHA_WILDFIRE || ALPHA_TITAN || ALPHA_GENERIC || ALPHA_SHARK || ALPHA_MARVEL
531 select USE_GENERIC_SMP_HELPERS
531 ---help--- 532 ---help---
532 This enables support for systems with more than one CPU. If you have 533 This enables support for systems with more than one CPU. If you have
533 a system with only one CPU, like most personal computers, say N. If 534 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/alpha/kernel/core_marvel.c b/arch/alpha/kernel/core_marvel.c
index b04f1feb1dd..04dcc5e5d4c 100644
--- a/arch/alpha/kernel/core_marvel.c
+++ b/arch/alpha/kernel/core_marvel.c
@@ -660,9 +660,9 @@ __marvel_rtc_io(u8 b, unsigned long addr, int write)
660 660
661#ifdef CONFIG_SMP 661#ifdef CONFIG_SMP
662 if (smp_processor_id() != boot_cpuid) 662 if (smp_processor_id() != boot_cpuid)
663 smp_call_function_on_cpu(__marvel_access_rtc, 663 smp_call_function_single(boot_cpuid,
664 &rtc_access, 1, 1, 664 __marvel_access_rtc,
665 cpumask_of_cpu(boot_cpuid)); 665 &rtc_access, 1);
666 else 666 else
667 __marvel_access_rtc(&rtc_access); 667 __marvel_access_rtc(&rtc_access);
668#else 668#else
diff --git a/arch/alpha/kernel/irq.c b/arch/alpha/kernel/irq.c
index facf82a5499..c626a821cdc 100644
--- a/arch/alpha/kernel/irq.c
+++ b/arch/alpha/kernel/irq.c
@@ -42,8 +42,7 @@ void ack_bad_irq(unsigned int irq)
42#ifdef CONFIG_SMP 42#ifdef CONFIG_SMP
43static char irq_user_affinity[NR_IRQS]; 43static char irq_user_affinity[NR_IRQS];
44 44
45int 45int irq_select_affinity(unsigned int irq)
46select_smp_affinity(unsigned int irq)
47{ 46{
48 static int last_cpu; 47 static int last_cpu;
49 int cpu = last_cpu + 1; 48 int cpu = last_cpu + 1;
@@ -51,7 +50,7 @@ select_smp_affinity(unsigned int irq)
51 if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq]) 50 if (!irq_desc[irq].chip->set_affinity || irq_user_affinity[irq])
52 return 1; 51 return 1;
53 52
54 while (!cpu_possible(cpu)) 53 while (!cpu_possible(cpu) || !cpu_isset(cpu, irq_default_affinity))
55 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0); 54 cpu = (cpu < (NR_CPUS-1) ? cpu + 1 : 0);
56 last_cpu = cpu; 55 last_cpu = cpu;
57 56
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 96ed82fd9ee..351407e07e7 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -160,7 +160,7 @@ common_shutdown(int mode, char *restart_cmd)
160 struct halt_info args; 160 struct halt_info args;
161 args.mode = mode; 161 args.mode = mode;
162 args.restart_cmd = restart_cmd; 162 args.restart_cmd = restart_cmd;
163 on_each_cpu(common_shutdown_1, &args, 1, 0); 163 on_each_cpu(common_shutdown_1, &args, 0);
164} 164}
165 165
166void 166void
diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c
index 2525692db0a..83df541650f 100644
--- a/arch/alpha/kernel/smp.c
+++ b/arch/alpha/kernel/smp.c
@@ -62,6 +62,7 @@ static struct {
62enum ipi_message_type { 62enum ipi_message_type {
63 IPI_RESCHEDULE, 63 IPI_RESCHEDULE,
64 IPI_CALL_FUNC, 64 IPI_CALL_FUNC,
65 IPI_CALL_FUNC_SINGLE,
65 IPI_CPU_STOP, 66 IPI_CPU_STOP,
66}; 67};
67 68
@@ -558,51 +559,6 @@ send_ipi_message(cpumask_t to_whom, enum ipi_message_type operation)
558 wripir(i); 559 wripir(i);
559} 560}
560 561
561/* Structure and data for smp_call_function. This is designed to
562 minimize static memory requirements. Plus it looks cleaner. */
563
564struct smp_call_struct {
565 void (*func) (void *info);
566 void *info;
567 long wait;
568 atomic_t unstarted_count;
569 atomic_t unfinished_count;
570};
571
572static struct smp_call_struct *smp_call_function_data;
573
574/* Atomicly drop data into a shared pointer. The pointer is free if
575 it is initially locked. If retry, spin until free. */
576
577static int
578pointer_lock (void *lock, void *data, int retry)
579{
580 void *old, *tmp;
581
582 mb();
583 again:
584 /* Compare and swap with zero. */
585 asm volatile (
586 "1: ldq_l %0,%1\n"
587 " mov %3,%2\n"
588 " bne %0,2f\n"
589 " stq_c %2,%1\n"
590 " beq %2,1b\n"
591 "2:"
592 : "=&r"(old), "=m"(*(void **)lock), "=&r"(tmp)
593 : "r"(data)
594 : "memory");
595
596 if (old == 0)
597 return 0;
598 if (! retry)
599 return -EBUSY;
600
601 while (*(void **)lock)
602 barrier();
603 goto again;
604}
605
606void 562void
607handle_ipi(struct pt_regs *regs) 563handle_ipi(struct pt_regs *regs)
608{ 564{
@@ -632,31 +588,12 @@ handle_ipi(struct pt_regs *regs)
632 break; 588 break;
633 589
634 case IPI_CALL_FUNC: 590 case IPI_CALL_FUNC:
635 { 591 generic_smp_call_function_interrupt();
636 struct smp_call_struct *data; 592 break;
637 void (*func)(void *info); 593
638 void *info; 594 case IPI_CALL_FUNC_SINGLE:
639 int wait; 595 generic_smp_call_function_single_interrupt();
640
641 data = smp_call_function_data;
642 func = data->func;
643 info = data->info;
644 wait = data->wait;
645
646 /* Notify the sending CPU that the data has been
647 received, and execution is about to begin. */
648 mb();
649 atomic_dec (&data->unstarted_count);
650
651 /* At this point the structure may be gone unless
652 wait is true. */
653 (*func)(info);
654
655 /* Notify the sending CPU that the task is done. */
656 mb();
657 if (wait) atomic_dec (&data->unfinished_count);
658 break; 596 break;
659 }
660 597
661 case IPI_CPU_STOP: 598 case IPI_CPU_STOP:
662 halt(); 599 halt();
@@ -700,102 +637,15 @@ smp_send_stop(void)
700 send_ipi_message(to_whom, IPI_CPU_STOP); 637 send_ipi_message(to_whom, IPI_CPU_STOP);
701} 638}
702 639
703/* 640void arch_send_call_function_ipi(cpumask_t mask)
704 * Run a function on all other CPUs.
705 * <func> The function to run. This must be fast and non-blocking.
706 * <info> An arbitrary pointer to pass to the function.
707 * <retry> If true, keep retrying until ready.
708 * <wait> If true, wait until function has completed on other CPUs.
709 * [RETURNS] 0 on success, else a negative status code.
710 *
711 * Does not return until remote CPUs are nearly ready to execute <func>
712 * or are or have executed.
713 * You must not call this function with disabled interrupts or from a
714 * hardware interrupt handler or from a bottom half handler.
715 */
716
717int
718smp_call_function_on_cpu (void (*func) (void *info), void *info, int retry,
719 int wait, cpumask_t to_whom)
720{ 641{
721 struct smp_call_struct data; 642 send_ipi_message(mask, IPI_CALL_FUNC);
722 unsigned long timeout;
723 int num_cpus_to_call;
724
725 /* Can deadlock when called with interrupts disabled */
726 WARN_ON(irqs_disabled());
727
728 data.func = func;
729 data.info = info;
730 data.wait = wait;
731
732 cpu_clear(smp_processor_id(), to_whom);
733 num_cpus_to_call = cpus_weight(to_whom);
734
735 atomic_set(&data.unstarted_count, num_cpus_to_call);
736 atomic_set(&data.unfinished_count, num_cpus_to_call);
737
738 /* Acquire the smp_call_function_data mutex. */
739 if (pointer_lock(&smp_call_function_data, &data, retry))
740 return -EBUSY;
741
742 /* Send a message to the requested CPUs. */
743 send_ipi_message(to_whom, IPI_CALL_FUNC);
744
745 /* Wait for a minimal response. */
746 timeout = jiffies + HZ;
747 while (atomic_read (&data.unstarted_count) > 0
748 && time_before (jiffies, timeout))
749 barrier();
750
751 /* If there's no response yet, log a message but allow a longer
752 * timeout period -- if we get a response this time, log
753 * a message saying when we got it..
754 */
755 if (atomic_read(&data.unstarted_count) > 0) {
756 long start_time = jiffies;
757 printk(KERN_ERR "%s: initial timeout -- trying long wait\n",
758 __func__);
759 timeout = jiffies + 30 * HZ;
760 while (atomic_read(&data.unstarted_count) > 0
761 && time_before(jiffies, timeout))
762 barrier();
763 if (atomic_read(&data.unstarted_count) <= 0) {
764 long delta = jiffies - start_time;
765 printk(KERN_ERR
766 "%s: response %ld.%ld seconds into long wait\n",
767 __func__, delta / HZ,
768 (100 * (delta - ((delta / HZ) * HZ))) / HZ);
769 }
770 }
771
772 /* We either got one or timed out -- clear the lock. */
773 mb();
774 smp_call_function_data = NULL;
775
776 /*
777 * If after both the initial and long timeout periods we still don't
778 * have a response, something is very wrong...
779 */
780 BUG_ON(atomic_read (&data.unstarted_count) > 0);
781
782 /* Wait for a complete response, if needed. */
783 if (wait) {
784 while (atomic_read (&data.unfinished_count) > 0)
785 barrier();
786 }
787
788 return 0;
789} 643}
790EXPORT_SYMBOL(smp_call_function_on_cpu);
791 644
792int 645void arch_send_call_function_single_ipi(int cpu)
793smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
794{ 646{
795 return smp_call_function_on_cpu (func, info, retry, wait, 647 send_ipi_message(cpumask_of_cpu(cpu), IPI_CALL_FUNC_SINGLE);
796 cpu_online_map);
797} 648}
798EXPORT_SYMBOL(smp_call_function);
799 649
800static void 650static void
801ipi_imb(void *ignored) 651ipi_imb(void *ignored)
@@ -807,7 +657,7 @@ void
807smp_imb(void) 657smp_imb(void)
808{ 658{
809 /* Must wait other processors to flush their icache before continue. */ 659 /* Must wait other processors to flush their icache before continue. */
810 if (on_each_cpu(ipi_imb, NULL, 1, 1)) 660 if (on_each_cpu(ipi_imb, NULL, 1))
811 printk(KERN_CRIT "smp_imb: timed out\n"); 661 printk(KERN_CRIT "smp_imb: timed out\n");
812} 662}
813EXPORT_SYMBOL(smp_imb); 663EXPORT_SYMBOL(smp_imb);
@@ -823,7 +673,7 @@ flush_tlb_all(void)
823{ 673{
824 /* Although we don't have any data to pass, we do want to 674 /* Although we don't have any data to pass, we do want to
825 synchronize with the other processors. */ 675 synchronize with the other processors. */
826 if (on_each_cpu(ipi_flush_tlb_all, NULL, 1, 1)) { 676 if (on_each_cpu(ipi_flush_tlb_all, NULL, 1)) {
827 printk(KERN_CRIT "flush_tlb_all: timed out\n"); 677 printk(KERN_CRIT "flush_tlb_all: timed out\n");
828 } 678 }
829} 679}
@@ -860,7 +710,7 @@ flush_tlb_mm(struct mm_struct *mm)
860 } 710 }
861 } 711 }
862 712
863 if (smp_call_function(ipi_flush_tlb_mm, mm, 1, 1)) { 713 if (smp_call_function(ipi_flush_tlb_mm, mm, 1)) {
864 printk(KERN_CRIT "flush_tlb_mm: timed out\n"); 714 printk(KERN_CRIT "flush_tlb_mm: timed out\n");
865 } 715 }
866 716
@@ -913,7 +763,7 @@ flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
913 data.mm = mm; 763 data.mm = mm;
914 data.addr = addr; 764 data.addr = addr;
915 765
916 if (smp_call_function(ipi_flush_tlb_page, &data, 1, 1)) { 766 if (smp_call_function(ipi_flush_tlb_page, &data, 1)) {
917 printk(KERN_CRIT "flush_tlb_page: timed out\n"); 767 printk(KERN_CRIT "flush_tlb_page: timed out\n");
918 } 768 }
919 769
@@ -965,7 +815,7 @@ flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
965 } 815 }
966 } 816 }
967 817
968 if (smp_call_function(ipi_flush_icache_page, mm, 1, 1)) { 818 if (smp_call_function(ipi_flush_icache_page, mm, 1)) {
969 printk(KERN_CRIT "flush_icache_page: timed out\n"); 819 printk(KERN_CRIT "flush_icache_page: timed out\n");
970 } 820 }
971 821
diff --git a/arch/alpha/oprofile/common.c b/arch/alpha/oprofile/common.c
index 9fc0eeb4f0a..7c3d5ec6ec6 100644
--- a/arch/alpha/oprofile/common.c
+++ b/arch/alpha/oprofile/common.c
@@ -65,7 +65,7 @@ op_axp_setup(void)
65 model->reg_setup(&reg, ctr, &sys); 65 model->reg_setup(&reg, ctr, &sys);
66 66
67 /* Configure the registers on all cpus. */ 67 /* Configure the registers on all cpus. */
68 (void)smp_call_function(model->cpu_setup, &reg, 0, 1); 68 (void)smp_call_function(model->cpu_setup, &reg, 1);
69 model->cpu_setup(&reg); 69 model->cpu_setup(&reg);
70 return 0; 70 return 0;
71} 71}
@@ -86,7 +86,7 @@ op_axp_cpu_start(void *dummy)
86static int 86static int
87op_axp_start(void) 87op_axp_start(void)
88{ 88{
89 (void)smp_call_function(op_axp_cpu_start, NULL, 0, 1); 89 (void)smp_call_function(op_axp_cpu_start, NULL, 1);
90 op_axp_cpu_start(NULL); 90 op_axp_cpu_start(NULL);
91 return 0; 91 return 0;
92} 92}
@@ -101,7 +101,7 @@ op_axp_cpu_stop(void *dummy)
101static void 101static void
102op_axp_stop(void) 102op_axp_stop(void)
103{ 103{
104 (void)smp_call_function(op_axp_cpu_stop, NULL, 0, 1); 104 (void)smp_call_function(op_axp_cpu_stop, NULL, 1);
105 op_axp_cpu_stop(NULL); 105 op_axp_cpu_stop(NULL);
106} 106}
107 107
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 258f1369fb0..c7ad324ddf2 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -701,6 +701,7 @@ source "kernel/time/Kconfig"
701config SMP 701config SMP
702 bool "Symmetric Multi-Processing (EXPERIMENTAL)" 702 bool "Symmetric Multi-Processing (EXPERIMENTAL)"
703 depends on EXPERIMENTAL && (REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP) 703 depends on EXPERIMENTAL && (REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP)
704 select USE_GENERIC_SMP_HELPERS
704 help 705 help
705 This enables support for systems with more than one CPU. If you have 706 This enables support for systems with more than one CPU. If you have
706 a system with only one CPU, like most personal computers, say N. If 707 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index eefae1de334..5a7c09564d1 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -68,20 +68,10 @@ enum ipi_msg_type {
68 IPI_TIMER, 68 IPI_TIMER,
69 IPI_RESCHEDULE, 69 IPI_RESCHEDULE,
70 IPI_CALL_FUNC, 70 IPI_CALL_FUNC,
71 IPI_CALL_FUNC_SINGLE,
71 IPI_CPU_STOP, 72 IPI_CPU_STOP,
72}; 73};
73 74
74struct smp_call_struct {
75 void (*func)(void *info);
76 void *info;
77 int wait;
78 cpumask_t pending;
79 cpumask_t unfinished;
80};
81
82static struct smp_call_struct * volatile smp_call_function_data;
83static DEFINE_SPINLOCK(smp_call_function_lock);
84
85int __cpuinit __cpu_up(unsigned int cpu) 75int __cpuinit __cpu_up(unsigned int cpu)
86{ 76{
87 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu); 77 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
@@ -366,114 +356,15 @@ static void send_ipi_message(cpumask_t callmap, enum ipi_msg_type msg)
366 local_irq_restore(flags); 356 local_irq_restore(flags);
367} 357}
368 358
369/* 359void arch_send_call_function_ipi(cpumask_t mask)
370 * You must not call this function with disabled interrupts, from a
371 * hardware interrupt handler, nor from a bottom half handler.
372 */
373static int smp_call_function_on_cpu(void (*func)(void *info), void *info,
374 int retry, int wait, cpumask_t callmap)
375{
376 struct smp_call_struct data;
377 unsigned long timeout;
378 int ret = 0;
379
380 data.func = func;
381 data.info = info;
382 data.wait = wait;
383
384 cpu_clear(smp_processor_id(), callmap);
385 if (cpus_empty(callmap))
386 goto out;
387
388 data.pending = callmap;
389 if (wait)
390 data.unfinished = callmap;
391
392 /*
393 * try to get the mutex on smp_call_function_data
394 */
395 spin_lock(&smp_call_function_lock);
396 smp_call_function_data = &data;
397
398 send_ipi_message(callmap, IPI_CALL_FUNC);
399
400 timeout = jiffies + HZ;
401 while (!cpus_empty(data.pending) && time_before(jiffies, timeout))
402 barrier();
403
404 /*
405 * did we time out?
406 */
407 if (!cpus_empty(data.pending)) {
408 /*
409 * this may be causing our panic - report it
410 */
411 printk(KERN_CRIT
412 "CPU%u: smp_call_function timeout for %p(%p)\n"
413 " callmap %lx pending %lx, %swait\n",
414 smp_processor_id(), func, info, *cpus_addr(callmap),
415 *cpus_addr(data.pending), wait ? "" : "no ");
416
417 /*
418 * TRACE
419 */
420 timeout = jiffies + (5 * HZ);
421 while (!cpus_empty(data.pending) && time_before(jiffies, timeout))
422 barrier();
423
424 if (cpus_empty(data.pending))
425 printk(KERN_CRIT " RESOLVED\n");
426 else
427 printk(KERN_CRIT " STILL STUCK\n");
428 }
429
430 /*
431 * whatever happened, we're done with the data, so release it
432 */
433 smp_call_function_data = NULL;
434 spin_unlock(&smp_call_function_lock);
435
436 if (!cpus_empty(data.pending)) {
437 ret = -ETIMEDOUT;
438 goto out;
439 }
440
441 if (wait)
442 while (!cpus_empty(data.unfinished))
443 barrier();
444 out:
445
446 return 0;
447}
448
449int smp_call_function(void (*func)(void *info), void *info, int retry,
450 int wait)
451{ 360{
452 return smp_call_function_on_cpu(func, info, retry, wait, 361 send_ipi_message(mask, IPI_CALL_FUNC);
453 cpu_online_map);
454} 362}
455EXPORT_SYMBOL_GPL(smp_call_function);
456 363
457int smp_call_function_single(int cpu, void (*func)(void *info), void *info, 364void arch_send_call_function_single_ipi(int cpu)
458 int retry, int wait)
459{ 365{
460 /* prevent preemption and reschedule on another processor */ 366 send_ipi_message(cpumask_of_cpu(cpu), IPI_CALL_FUNC_SINGLE);
461 int current_cpu = get_cpu();
462 int ret = 0;
463
464 if (cpu == current_cpu) {
465 local_irq_disable();
466 func(info);
467 local_irq_enable();
468 } else
469 ret = smp_call_function_on_cpu(func, info, retry, wait,
470 cpumask_of_cpu(cpu));
471
472 put_cpu();
473
474 return ret;
475} 367}
476EXPORT_SYMBOL_GPL(smp_call_function_single);
477 368
478void show_ipi_list(struct seq_file *p) 369void show_ipi_list(struct seq_file *p)
479{ 370{
@@ -521,27 +412,6 @@ asmlinkage void __exception do_local_timer(struct pt_regs *regs)
521} 412}
522#endif 413#endif
523 414
524/*
525 * ipi_call_function - handle IPI from smp_call_function()
526 *
527 * Note that we copy data out of the cross-call structure and then
528 * let the caller know that we're here and have done with their data
529 */
530static void ipi_call_function(unsigned int cpu)
531{
532 struct smp_call_struct *data = smp_call_function_data;
533 void (*func)(void *info) = data->func;
534 void *info = data->info;
535 int wait = data->wait;
536
537 cpu_clear(cpu, data->pending);
538
539 func(info);
540
541 if (wait)
542 cpu_clear(cpu, data->unfinished);
543}
544
545static DEFINE_SPINLOCK(stop_lock); 415static DEFINE_SPINLOCK(stop_lock);
546 416
547/* 417/*
@@ -611,7 +481,11 @@ asmlinkage void __exception do_IPI(struct pt_regs *regs)
611 break; 481 break;
612 482
613 case IPI_CALL_FUNC: 483 case IPI_CALL_FUNC:
614 ipi_call_function(cpu); 484 generic_smp_call_function_interrupt();
485 break;
486
487 case IPI_CALL_FUNC_SINGLE:
488 generic_smp_call_function_single_interrupt();
615 break; 489 break;
616 490
617 case IPI_CPU_STOP: 491 case IPI_CPU_STOP:
@@ -662,14 +536,13 @@ int setup_profiling_timer(unsigned int multiplier)
662} 536}
663 537
664static int 538static int
665on_each_cpu_mask(void (*func)(void *), void *info, int retry, int wait, 539on_each_cpu_mask(void (*func)(void *), void *info, int wait, cpumask_t mask)
666 cpumask_t mask)
667{ 540{
668 int ret = 0; 541 int ret = 0;
669 542
670 preempt_disable(); 543 preempt_disable();
671 544
672 ret = smp_call_function_on_cpu(func, info, retry, wait, mask); 545 ret = smp_call_function_mask(mask, func, info, wait);
673 if (cpu_isset(smp_processor_id(), mask)) 546 if (cpu_isset(smp_processor_id(), mask))
674 func(info); 547 func(info);
675 548
@@ -731,14 +604,14 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
731 604
732void flush_tlb_all(void) 605void flush_tlb_all(void)
733{ 606{
734 on_each_cpu(ipi_flush_tlb_all, NULL, 1, 1); 607 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
735} 608}
736 609
737void flush_tlb_mm(struct mm_struct *mm) 610void flush_tlb_mm(struct mm_struct *mm)
738{ 611{
739 cpumask_t mask = mm->cpu_vm_mask; 612 cpumask_t mask = mm->cpu_vm_mask;
740 613
741 on_each_cpu_mask(ipi_flush_tlb_mm, mm, 1, 1, mask); 614 on_each_cpu_mask(ipi_flush_tlb_mm, mm, 1, mask);
742} 615}
743 616
744void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr) 617void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
@@ -749,7 +622,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
749 ta.ta_vma = vma; 622 ta.ta_vma = vma;
750 ta.ta_start = uaddr; 623 ta.ta_start = uaddr;
751 624
752 on_each_cpu_mask(ipi_flush_tlb_page, &ta, 1, 1, mask); 625 on_each_cpu_mask(ipi_flush_tlb_page, &ta, 1, mask);
753} 626}
754 627
755void flush_tlb_kernel_page(unsigned long kaddr) 628void flush_tlb_kernel_page(unsigned long kaddr)
@@ -758,7 +631,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
758 631
759 ta.ta_start = kaddr; 632 ta.ta_start = kaddr;
760 633
761 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1, 1); 634 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
762} 635}
763 636
764void flush_tlb_range(struct vm_area_struct *vma, 637void flush_tlb_range(struct vm_area_struct *vma,
@@ -771,7 +644,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
771 ta.ta_start = start; 644 ta.ta_start = start;
772 ta.ta_end = end; 645 ta.ta_end = end;
773 646
774 on_each_cpu_mask(ipi_flush_tlb_range, &ta, 1, 1, mask); 647 on_each_cpu_mask(ipi_flush_tlb_range, &ta, 1, mask);
775} 648}
776 649
777void flush_tlb_kernel_range(unsigned long start, unsigned long end) 650void flush_tlb_kernel_range(unsigned long start, unsigned long end)
@@ -781,5 +654,5 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
781 ta.ta_start = start; 654 ta.ta_start = start;
782 ta.ta_end = end; 655 ta.ta_end = end;
783 656
784 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1, 1); 657 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
785} 658}
diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 90e0c35ae60..fc650f64df4 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -92,4 +92,5 @@ void save_stack_trace(struct stack_trace *trace)
92{ 92{
93 save_stack_trace_tsk(current, trace); 93 save_stack_trace_tsk(current, trace);
94} 94}
95EXPORT_SYMBOL_GPL(save_stack_trace);
95#endif 96#endif
diff --git a/arch/arm/oprofile/op_model_mpcore.c b/arch/arm/oprofile/op_model_mpcore.c
index 74fae604565..4458705021e 100644
--- a/arch/arm/oprofile/op_model_mpcore.c
+++ b/arch/arm/oprofile/op_model_mpcore.c
@@ -201,7 +201,7 @@ static int em_call_function(int (*fn)(void))
201 data.ret = 0; 201 data.ret = 0;
202 202
203 preempt_disable(); 203 preempt_disable();
204 smp_call_function(em_func, &data, 1, 1); 204 smp_call_function(em_func, &data, 1);
205 em_func(&data); 205 em_func(&data);
206 preempt_enable(); 206 preempt_enable();
207 207
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 32455c633f1..c0d2c9bb952 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -352,7 +352,7 @@ static int __init vfp_init(void)
352 else if (vfpsid & FPSID_NODOUBLE) { 352 else if (vfpsid & FPSID_NODOUBLE) {
353 printk("no double precision support\n"); 353 printk("no double precision support\n");
354 } else { 354 } else {
355 smp_call_function(vfp_enable, NULL, 1, 1); 355 smp_call_function(vfp_enable, NULL, 1);
356 356
357 VFP_arch = (vfpsid & FPSID_ARCH_MASK) >> FPSID_ARCH_BIT; /* Extract the architecture version */ 357 VFP_arch = (vfpsid & FPSID_ARCH_MASK) >> FPSID_ARCH_BIT; /* Extract the architecture version */
358 printk("implementor %02x architecture %d part %02x variant %x rev %x\n", 358 printk("implementor %02x architecture %d part %02x variant %x rev %x\n",
diff --git a/arch/avr32/kernel/stacktrace.c b/arch/avr32/kernel/stacktrace.c
index 9a68190bbff..f4bdb448049 100644
--- a/arch/avr32/kernel/stacktrace.c
+++ b/arch/avr32/kernel/stacktrace.c
@@ -51,3 +51,4 @@ void save_stack_trace(struct stack_trace *trace)
51 fp = frame->fp; 51 fp = frame->fp;
52 } 52 }
53} 53}
54EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/cris/arch-v32/kernel/smp.c b/arch/cris/arch-v32/kernel/smp.c
index a9c3334e46c..952a24b2f5a 100644
--- a/arch/cris/arch-v32/kernel/smp.c
+++ b/arch/cris/arch-v32/kernel/smp.c
@@ -194,7 +194,7 @@ void stop_this_cpu(void* dummy)
194/* Other calls */ 194/* Other calls */
195void smp_send_stop(void) 195void smp_send_stop(void)
196{ 196{
197 smp_call_function(stop_this_cpu, NULL, 1, 0); 197 smp_call_function(stop_this_cpu, NULL, 0);
198} 198}
199 199
200int setup_profiling_timer(unsigned int multiplier) 200int setup_profiling_timer(unsigned int multiplier)
@@ -316,8 +316,7 @@ int send_ipi(int vector, int wait, cpumask_t cpu_mask)
316 * You must not call this function with disabled interrupts or from a 316 * You must not call this function with disabled interrupts or from a
317 * hardware interrupt handler or from a bottom half handler. 317 * hardware interrupt handler or from a bottom half handler.
318 */ 318 */
319int smp_call_function(void (*func)(void *info), void *info, 319int smp_call_function(void (*func)(void *info), void *info, int wait)
320 int nonatomic, int wait)
321{ 320{
322 cpumask_t cpu_mask = CPU_MASK_ALL; 321 cpumask_t cpu_mask = CPU_MASK_ALL;
323 struct call_data_struct data; 322 struct call_data_struct data;
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 16be41446b5..18bcc10903b 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -303,6 +303,7 @@ config VIRT_CPU_ACCOUNTING
303 303
304config SMP 304config SMP
305 bool "Symmetric multi-processing support" 305 bool "Symmetric multi-processing support"
306 select USE_GENERIC_SMP_HELPERS
306 help 307 help
307 This enables support for systems with more than one CPU. If you have 308 This enables support for systems with more than one CPU. If you have
308 a system with only one CPU, say N. If you have a system with more 309 a system with only one CPU, say N. If you have a system with more
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 705176b434b..7dd96c12717 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -707,7 +707,7 @@ ia64_mca_cmc_vector_enable (void *dummy)
707static void 707static void
708ia64_mca_cmc_vector_disable_keventd(struct work_struct *unused) 708ia64_mca_cmc_vector_disable_keventd(struct work_struct *unused)
709{ 709{
710 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0); 710 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 0);
711} 711}
712 712
713/* 713/*
@@ -719,7 +719,7 @@ ia64_mca_cmc_vector_disable_keventd(struct work_struct *unused)
719static void 719static void
720ia64_mca_cmc_vector_enable_keventd(struct work_struct *unused) 720ia64_mca_cmc_vector_enable_keventd(struct work_struct *unused)
721{ 721{
722 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0); 722 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 0);
723} 723}
724 724
725/* 725/*
@@ -1881,7 +1881,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
1881 case CPU_ONLINE: 1881 case CPU_ONLINE:
1882 case CPU_ONLINE_FROZEN: 1882 case CPU_ONLINE_FROZEN:
1883 smp_call_function_single(hotcpu, ia64_mca_cmc_vector_adjust, 1883 smp_call_function_single(hotcpu, ia64_mca_cmc_vector_adjust,
1884 NULL, 1, 0); 1884 NULL, 0);
1885 break; 1885 break;
1886 } 1886 }
1887 return NOTIFY_OK; 1887 return NOTIFY_OK;
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index 9dc00f7fe10..e5c57f413ca 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -921,7 +921,7 @@ int palinfo_handle_smp(pal_func_cpu_u_t *f, char *page)
921 921
922 922
923 /* will send IPI to other CPU and wait for completion of remote call */ 923 /* will send IPI to other CPU and wait for completion of remote call */
924 if ((ret=smp_call_function_single(f->req_cpu, palinfo_smp_call, &ptr, 0, 1))) { 924 if ((ret=smp_call_function_single(f->req_cpu, palinfo_smp_call, &ptr, 1))) {
925 printk(KERN_ERR "palinfo: remote CPU call from %d to %d on function %d: " 925 printk(KERN_ERR "palinfo: remote CPU call from %d to %d on function %d: "
926 "error %d\n", smp_processor_id(), f->req_cpu, f->func_id, ret); 926 "error %d\n", smp_processor_id(), f->req_cpu, f->func_id, ret);
927 return 0; 927 return 0;
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 7714a97b010..19d4493c619 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -1820,7 +1820,7 @@ pfm_syswide_cleanup_other_cpu(pfm_context_t *ctx)
1820 int ret; 1820 int ret;
1821 1821
1822 DPRINT(("calling CPU%d for cleanup\n", ctx->ctx_cpu)); 1822 DPRINT(("calling CPU%d for cleanup\n", ctx->ctx_cpu));
1823 ret = smp_call_function_single(ctx->ctx_cpu, pfm_syswide_force_stop, ctx, 0, 1); 1823 ret = smp_call_function_single(ctx->ctx_cpu, pfm_syswide_force_stop, ctx, 1);
1824 DPRINT(("called CPU%d for cleanup ret=%d\n", ctx->ctx_cpu, ret)); 1824 DPRINT(("called CPU%d for cleanup ret=%d\n", ctx->ctx_cpu, ret));
1825} 1825}
1826#endif /* CONFIG_SMP */ 1826#endif /* CONFIG_SMP */
@@ -6508,7 +6508,7 @@ pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl)
6508 } 6508 }
6509 6509
6510 /* save the current system wide pmu states */ 6510 /* save the current system wide pmu states */
6511 ret = on_each_cpu(pfm_alt_save_pmu_state, NULL, 0, 1); 6511 ret = on_each_cpu(pfm_alt_save_pmu_state, NULL, 1);
6512 if (ret) { 6512 if (ret) {
6513 DPRINT(("on_each_cpu() failed: %d\n", ret)); 6513 DPRINT(("on_each_cpu() failed: %d\n", ret));
6514 goto cleanup_reserve; 6514 goto cleanup_reserve;
@@ -6553,7 +6553,7 @@ pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *hdl)
6553 6553
6554 pfm_alt_intr_handler = NULL; 6554 pfm_alt_intr_handler = NULL;
6555 6555
6556 ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 0, 1); 6556 ret = on_each_cpu(pfm_alt_restore_pmu_state, NULL, 1);
6557 if (ret) { 6557 if (ret) {
6558 DPRINT(("on_each_cpu() failed: %d\n", ret)); 6558 DPRINT(("on_each_cpu() failed: %d\n", ret));
6559 } 6559 }
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index a3a34b4eb03..fabaf08d9a6 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -286,7 +286,7 @@ void cpu_idle_wait(void)
286{ 286{
287 smp_mb(); 287 smp_mb();
288 /* kick all the CPUs so that they exit out of pm_idle */ 288 /* kick all the CPUs so that they exit out of pm_idle */
289 smp_call_function(do_nothing, NULL, 0, 1); 289 smp_call_function(do_nothing, NULL, 1);
290} 290}
291EXPORT_SYMBOL_GPL(cpu_idle_wait); 291EXPORT_SYMBOL_GPL(cpu_idle_wait);
292 292
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 983296f1c81..3676468612b 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -60,25 +60,9 @@ static struct local_tlb_flush_counts {
60 60
61static DEFINE_PER_CPU(unsigned int, shadow_flush_counts[NR_CPUS]) ____cacheline_aligned; 61static DEFINE_PER_CPU(unsigned int, shadow_flush_counts[NR_CPUS]) ____cacheline_aligned;
62 62
63
64/*
65 * Structure and data for smp_call_function(). This is designed to minimise static memory
66 * requirements. It also looks cleaner.
67 */
68static __cacheline_aligned DEFINE_SPINLOCK(call_lock);
69
70struct call_data_struct {
71 void (*func) (void *info);
72 void *info;
73 long wait;
74 atomic_t started;
75 atomic_t finished;
76};
77
78static volatile struct call_data_struct *call_data;
79
80#define IPI_CALL_FUNC 0 63#define IPI_CALL_FUNC 0
81#define IPI_CPU_STOP 1 64#define IPI_CPU_STOP 1
65#define IPI_CALL_FUNC_SINGLE 2
82#define IPI_KDUMP_CPU_STOP 3 66#define IPI_KDUMP_CPU_STOP 3
83 67
84/* This needs to be cacheline aligned because it is written to by *other* CPUs. */ 68/* This needs to be cacheline aligned because it is written to by *other* CPUs. */
@@ -86,43 +70,6 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(u64, ipi_operation);
86 70
87extern void cpu_halt (void); 71extern void cpu_halt (void);
88 72
89void
90lock_ipi_calllock(void)
91{
92 spin_lock_irq(&call_lock);
93}
94
95void
96unlock_ipi_calllock(void)
97{
98 spin_unlock_irq(&call_lock);
99}
100
101static inline void
102handle_call_data(void)
103{
104 struct call_data_struct *data;
105 void (*func)(void *info);
106 void *info;
107 int wait;
108
109 /* release the 'pointer lock' */
110 data = (struct call_data_struct *)call_data;
111 func = data->func;
112 info = data->info;
113 wait = data->wait;
114
115 mb();
116 atomic_inc(&data->started);
117 /* At this point the structure may be gone unless wait is true. */
118 (*func)(info);
119
120 /* Notify the sending CPU that the task is done. */
121 mb();
122 if (wait)
123 atomic_inc(&data->finished);
124}
125
126static void 73static void
127stop_this_cpu(void) 74stop_this_cpu(void)
128{ 75{
@@ -163,13 +110,15 @@ handle_IPI (int irq, void *dev_id)
163 ops &= ~(1 << which); 110 ops &= ~(1 << which);
164 111
165 switch (which) { 112 switch (which) {
166 case IPI_CALL_FUNC:
167 handle_call_data();
168 break;
169
170 case IPI_CPU_STOP: 113 case IPI_CPU_STOP:
171 stop_this_cpu(); 114 stop_this_cpu();
172 break; 115 break;
116 case IPI_CALL_FUNC:
117 generic_smp_call_function_interrupt();
118 break;
119 case IPI_CALL_FUNC_SINGLE:
120 generic_smp_call_function_single_interrupt();
121 break;
173#ifdef CONFIG_KEXEC 122#ifdef CONFIG_KEXEC
174 case IPI_KDUMP_CPU_STOP: 123 case IPI_KDUMP_CPU_STOP:
175 unw_init_running(kdump_cpu_freeze, NULL); 124 unw_init_running(kdump_cpu_freeze, NULL);
@@ -187,6 +136,8 @@ handle_IPI (int irq, void *dev_id)
187 return IRQ_HANDLED; 136 return IRQ_HANDLED;
188} 137}
189 138
139
140
190/* 141/*
191 * Called with preemption disabled. 142 * Called with preemption disabled.
192 */ 143 */
@@ -334,7 +285,7 @@ smp_flush_tlb_cpumask(cpumask_t xcpumask)
334void 285void
335smp_flush_tlb_all (void) 286smp_flush_tlb_all (void)
336{ 287{
337 on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1, 1); 288 on_each_cpu((void (*)(void *))local_flush_tlb_all, NULL, 1);
338} 289}
339 290
340void 291void
@@ -357,193 +308,18 @@ smp_flush_tlb_mm (struct mm_struct *mm)
357 * anyhow, and once a CPU is interrupted, the cost of local_flush_tlb_all() is 308 * anyhow, and once a CPU is interrupted, the cost of local_flush_tlb_all() is
358 * rather trivial. 309 * rather trivial.
359 */ 310 */
360 on_each_cpu((void (*)(void *))local_finish_flush_tlb_mm, mm, 1, 1); 311 on_each_cpu((void (*)(void *))local_finish_flush_tlb_mm, mm, 1);
361} 312}
362 313
363/* 314void arch_send_call_function_single_ipi(int cpu)
364 * Run a function on a specific CPU
365 * <func> The function to run. This must be fast and non-blocking.
366 * <info> An arbitrary pointer to pass to the function.
367 * <nonatomic> Currently unused.
368 * <wait> If true, wait until function has completed on other CPUs.
369 * [RETURNS] 0 on success, else a negative status code.
370 *
371 * Does not return until the remote CPU is nearly ready to execute <func>
372 * or is or has executed.
373 */
374
375int
376smp_call_function_single (int cpuid, void (*func) (void *info), void *info, int nonatomic,
377 int wait)
378{
379 struct call_data_struct data;
380 int cpus = 1;
381 int me = get_cpu(); /* prevent preemption and reschedule on another processor */
382
383 if (cpuid == me) {
384 local_irq_disable();
385 func(info);
386 local_irq_enable();
387 put_cpu();
388 return 0;
389 }
390
391 data.func = func;
392 data.info = info;
393 atomic_set(&data.started, 0);
394 data.wait = wait;
395 if (wait)
396 atomic_set(&data.finished, 0);
397
398 spin_lock_bh(&call_lock);
399
400 call_data = &data;
401 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */
402 send_IPI_single(cpuid, IPI_CALL_FUNC);
403
404 /* Wait for response */
405 while (atomic_read(&data.started) != cpus)
406 cpu_relax();
407
408 if (wait)
409 while (atomic_read(&data.finished) != cpus)
410 cpu_relax();
411 call_data = NULL;
412
413 spin_unlock_bh(&call_lock);
414 put_cpu();
415 return 0;
416}
417EXPORT_SYMBOL(smp_call_function_single);
418
419/**
420 * smp_call_function_mask(): Run a function on a set of other CPUs.
421 * <mask> The set of cpus to run on. Must not include the current cpu.
422 * <func> The function to run. This must be fast and non-blocking.
423 * <info> An arbitrary pointer to pass to the function.
424 * <wait> If true, wait (atomically) until function
425 * has completed on other CPUs.
426 *
427 * Returns 0 on success, else a negative status code.
428 *
429 * If @wait is true, then returns once @func has returned; otherwise
430 * it returns just before the target cpu calls @func.
431 *
432 * You must not call this function with disabled interrupts or from a
433 * hardware interrupt handler or from a bottom half handler.
434 */
435int smp_call_function_mask(cpumask_t mask,
436 void (*func)(void *), void *info,
437 int wait)
438{ 315{
439 struct call_data_struct data; 316 send_IPI_single(cpu, IPI_CALL_FUNC_SINGLE);
440 cpumask_t allbutself;
441 int cpus;
442
443 spin_lock(&call_lock);
444 allbutself = cpu_online_map;
445 cpu_clear(smp_processor_id(), allbutself);
446
447 cpus_and(mask, mask, allbutself);
448 cpus = cpus_weight(mask);
449 if (!cpus) {
450 spin_unlock(&call_lock);
451 return 0;
452 }
453
454 /* Can deadlock when called with interrupts disabled */
455 WARN_ON(irqs_disabled());
456
457 data.func = func;
458 data.info = info;
459 atomic_set(&data.started, 0);
460 data.wait = wait;
461 if (wait)
462 atomic_set(&data.finished, 0);
463
464 call_data = &data;
465 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC*/
466
467 /* Send a message to other CPUs */
468 if (cpus_equal(mask, allbutself))
469 send_IPI_allbutself(IPI_CALL_FUNC);
470 else
471 send_IPI_mask(mask, IPI_CALL_FUNC);
472
473 /* Wait for response */
474 while (atomic_read(&data.started) != cpus)
475 cpu_relax();
476
477 if (wait)
478 while (atomic_read(&data.finished) != cpus)
479 cpu_relax();
480 call_data = NULL;
481
482 spin_unlock(&call_lock);
483 return 0;
484
485} 317}
486EXPORT_SYMBOL(smp_call_function_mask);
487 318
488/* 319void arch_send_call_function_ipi(cpumask_t mask)
489 * this function sends a 'generic call function' IPI to all other CPUs
490 * in the system.
491 */
492
493/*
494 * [SUMMARY] Run a function on all other CPUs.
495 * <func> The function to run. This must be fast and non-blocking.
496 * <info> An arbitrary pointer to pass to the function.
497 * <nonatomic> currently unused.
498 * <wait> If true, wait (atomically) until function has completed on other CPUs.
499 * [RETURNS] 0 on success, else a negative status code.
500 *
501 * Does not return until remote CPUs are nearly ready to execute <func> or are or have
502 * executed.
503 *
504 * You must not call this function with disabled interrupts or from a
505 * hardware interrupt handler or from a bottom half handler.
506 */
507int
508smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait)
509{ 320{
510 struct call_data_struct data; 321 send_IPI_mask(mask, IPI_CALL_FUNC);
511 int cpus;
512
513 spin_lock(&call_lock);
514 cpus = num_online_cpus() - 1;
515 if (!cpus) {
516 spin_unlock(&call_lock);
517 return 0;
518 }
519
520 /* Can deadlock when called with interrupts disabled */
521 WARN_ON(irqs_disabled());
522
523 data.func = func;
524 data.info = info;
525 atomic_set(&data.started, 0);
526 data.wait = wait;
527 if (wait)
528 atomic_set(&data.finished, 0);
529
530 call_data = &data;
531 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */
532 send_IPI_allbutself(IPI_CALL_FUNC);
533
534 /* Wait for response */
535 while (atomic_read(&data.started) != cpus)
536 cpu_relax();
537
538 if (wait)
539 while (atomic_read(&data.finished) != cpus)
540 cpu_relax();
541 call_data = NULL;
542
543 spin_unlock(&call_lock);
544 return 0;
545} 322}
546EXPORT_SYMBOL(smp_call_function);
547 323
548/* 324/*
549 * this function calls the 'stop' function on all other CPUs in the system. 325 * this function calls the 'stop' function on all other CPUs in the system.
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index d7ad42b77d4..9d1d429c6c5 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -317,7 +317,7 @@ ia64_sync_itc (unsigned int master)
317 317
318 go[MASTER] = 1; 318 go[MASTER] = 1;
319 319
320 if (smp_call_function_single(master, sync_master, NULL, 1, 0) < 0) { 320 if (smp_call_function_single(master, sync_master, NULL, 0) < 0) {
321 printk(KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master); 321 printk(KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master);
322 return; 322 return;
323 } 323 }
@@ -395,14 +395,14 @@ smp_callin (void)
395 395
396 fix_b0_for_bsp(); 396 fix_b0_for_bsp();
397 397
398 lock_ipi_calllock(); 398 ipi_call_lock_irq();
399 spin_lock(&vector_lock); 399 spin_lock(&vector_lock);
400 /* Setup the per cpu irq handling data structures */ 400 /* Setup the per cpu irq handling data structures */
401 __setup_vector_irq(cpuid); 401 __setup_vector_irq(cpuid);
402 cpu_set(cpuid, cpu_online_map); 402 cpu_set(cpuid, cpu_online_map);
403 per_cpu(cpu_state, cpuid) = CPU_ONLINE; 403 per_cpu(cpu_state, cpuid) = CPU_ONLINE;
404 spin_unlock(&vector_lock); 404 spin_unlock(&vector_lock);
405 unlock_ipi_calllock(); 405 ipi_call_unlock_irq();
406 406
407 smp_setup_percpu_timer(); 407 smp_setup_percpu_timer();
408 408
diff --git a/arch/ia64/kernel/uncached.c b/arch/ia64/kernel/uncached.c
index e77995a6e3e..8eff8c1d40a 100644
--- a/arch/ia64/kernel/uncached.c
+++ b/arch/ia64/kernel/uncached.c
@@ -123,8 +123,7 @@ static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid)
123 status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL); 123 status = ia64_pal_prefetch_visibility(PAL_VISIBILITY_PHYSICAL);
124 if (status == PAL_VISIBILITY_OK_REMOTE_NEEDED) { 124 if (status == PAL_VISIBILITY_OK_REMOTE_NEEDED) {
125 atomic_set(&uc_pool->status, 0); 125 atomic_set(&uc_pool->status, 0);
126 status = smp_call_function(uncached_ipi_visibility, uc_pool, 126 status = smp_call_function(uncached_ipi_visibility, uc_pool, 1);
127 0, 1);
128 if (status || atomic_read(&uc_pool->status)) 127 if (status || atomic_read(&uc_pool->status))
129 goto failed; 128 goto failed;
130 } else if (status != PAL_VISIBILITY_OK) 129 } else if (status != PAL_VISIBILITY_OK)
@@ -146,7 +145,7 @@ static int uncached_add_chunk(struct uncached_pool *uc_pool, int nid)
146 if (status != PAL_STATUS_SUCCESS) 145 if (status != PAL_STATUS_SUCCESS)
147 goto failed; 146 goto failed;
148 atomic_set(&uc_pool->status, 0); 147 atomic_set(&uc_pool->status, 0);
149 status = smp_call_function(uncached_ipi_mc_drain, uc_pool, 0, 1); 148 status = smp_call_function(uncached_ipi_mc_drain, uc_pool, 1);
150 if (status || atomic_read(&uc_pool->status)) 149 if (status || atomic_read(&uc_pool->status))
151 goto failed; 150 goto failed;
152 151
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index 53351c3cd7b..96c31b4180c 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -11,6 +11,7 @@
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/rculist.h>
14#include <asm/sn/addrs.h> 15#include <asm/sn/addrs.h>
15#include <asm/sn/arch.h> 16#include <asm/sn/arch.h>
16#include <asm/sn/intr.h> 17#include <asm/sn/intr.h>
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 8cc0c4753d8..636588e7e06 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -629,7 +629,7 @@ static int sn_hwperf_op_cpu(struct sn_hwperf_op_info *op_info)
629 if (use_ipi) { 629 if (use_ipi) {
630 /* use an interprocessor interrupt to call SAL */ 630 /* use an interprocessor interrupt to call SAL */
631 smp_call_function_single(cpu, sn_hwperf_call_sal, 631 smp_call_function_single(cpu, sn_hwperf_call_sal,
632 op_info, 1, 1); 632 op_info, 1);
633 } 633 }
634 else { 634 else {
635 /* migrate the task before calling SAL */ 635 /* migrate the task before calling SAL */
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index de153de2ea9..a5f864c445b 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -296,6 +296,7 @@ config PREEMPT
296 296
297config SMP 297config SMP
298 bool "Symmetric multi-processing support" 298 bool "Symmetric multi-processing support"
299 select USE_GENERIC_SMP_HELPERS
299 ---help--- 300 ---help---
300 This enables support for systems with more than one CPU. If you have 301 This enables support for systems with more than one CPU. If you have
301 a system with only one CPU, like most personal computers, say N. If 302 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/m32r/kernel/m32r_ksyms.c b/arch/m32r/kernel/m32r_ksyms.c
index e6709fe950b..16bcb189a38 100644
--- a/arch/m32r/kernel/m32r_ksyms.c
+++ b/arch/m32r/kernel/m32r_ksyms.c
@@ -43,9 +43,6 @@ EXPORT_SYMBOL(dcache_dummy);
43#endif 43#endif
44EXPORT_SYMBOL(cpu_data); 44EXPORT_SYMBOL(cpu_data);
45 45
46/* Global SMP stuff */
47EXPORT_SYMBOL(smp_call_function);
48
49/* TLB flushing */ 46/* TLB flushing */
50EXPORT_SYMBOL(smp_flush_tlb_page); 47EXPORT_SYMBOL(smp_flush_tlb_page);
51#endif 48#endif
diff --git a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c
index c837bc13b01..7577f971ea4 100644
--- a/arch/m32r/kernel/smp.c
+++ b/arch/m32r/kernel/smp.c
@@ -35,22 +35,6 @@
35/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 35/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
36 36
37/* 37/*
38 * Structure and data for smp_call_function(). This is designed to minimise
39 * static memory requirements. It also looks cleaner.
40 */
41static DEFINE_SPINLOCK(call_lock);
42
43struct call_data_struct {
44 void (*func) (void *info);
45 void *info;
46 atomic_t started;
47 atomic_t finished;
48 int wait;
49} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
50
51static struct call_data_struct *call_data;
52
53/*
54 * For flush_cache_all() 38 * For flush_cache_all()
55 */ 39 */
56static DEFINE_SPINLOCK(flushcache_lock); 40static DEFINE_SPINLOCK(flushcache_lock);
@@ -96,9 +80,6 @@ void smp_invalidate_interrupt(void);
96void smp_send_stop(void); 80void smp_send_stop(void);
97static void stop_this_cpu(void *); 81static void stop_this_cpu(void *);
98 82
99int smp_call_function(void (*) (void *), void *, int, int);
100void smp_call_function_interrupt(void);
101
102void smp_send_timer(void); 83void smp_send_timer(void);
103void smp_ipi_timer_interrupt(struct pt_regs *); 84void smp_ipi_timer_interrupt(struct pt_regs *);
104void smp_local_timer_interrupt(void); 85void smp_local_timer_interrupt(void);
@@ -231,7 +212,7 @@ void smp_flush_tlb_all(void)
231 local_irq_save(flags); 212 local_irq_save(flags);
232 __flush_tlb_all(); 213 __flush_tlb_all();
233 local_irq_restore(flags); 214 local_irq_restore(flags);
234 smp_call_function(flush_tlb_all_ipi, NULL, 1, 1); 215 smp_call_function(flush_tlb_all_ipi, NULL, 1);
235 preempt_enable(); 216 preempt_enable();
236} 217}
237 218
@@ -524,7 +505,7 @@ void smp_invalidate_interrupt(void)
524 *==========================================================================*/ 505 *==========================================================================*/
525void smp_send_stop(void) 506void smp_send_stop(void)
526{ 507{
527 smp_call_function(stop_this_cpu, NULL, 1, 0); 508 smp_call_function(stop_this_cpu, NULL, 0);
528} 509}
529 510
530/*==========================================================================* 511/*==========================================================================*
@@ -565,86 +546,14 @@ static void stop_this_cpu(void *dummy)
565 for ( ; ; ); 546 for ( ; ; );
566} 547}
567 548
568/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 549void arch_send_call_function_ipi(cpumask_t mask)
569/* Call function Routines */
570/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
571
572/*==========================================================================*
573 * Name: smp_call_function
574 *
575 * Description: This routine sends a 'CALL_FUNCTION_IPI' to all other CPUs
576 * in the system.
577 *
578 * Born on Date: 2002.02.05
579 *
580 * Arguments: *func - The function to run. This must be fast and
581 * non-blocking.
582 * *info - An arbitrary pointer to pass to the function.
583 * nonatomic - currently unused.
584 * wait - If true, wait (atomically) until function has
585 * completed on other CPUs.
586 *
587 * Returns: 0 on success, else a negative status code. Does not return
588 * until remote CPUs are nearly ready to execute <<func>> or
589 * are or have executed.
590 *
591 * Cautions: You must not call this function with disabled interrupts or
592 * from a hardware interrupt handler, you may call it from a
593 * bottom half handler.
594 *
595 * Modification log:
596 * Date Who Description
597 * ---------- --- --------------------------------------------------------
598 *
599 *==========================================================================*/
600int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
601 int wait)
602{ 550{
603 struct call_data_struct data; 551 send_IPI_mask(mask, CALL_FUNCTION_IPI, 0);
604 int cpus; 552}
605
606#ifdef DEBUG_SMP
607 unsigned long flags;
608 __save_flags(flags);
609 if (!(flags & 0x0040)) /* Interrupt Disable NONONO */
610 BUG();
611#endif /* DEBUG_SMP */
612
613 /* Holding any lock stops cpus from going down. */
614 spin_lock(&call_lock);
615 cpus = num_online_cpus() - 1;
616
617 if (!cpus) {
618 spin_unlock(&call_lock);
619 return 0;
620 }
621
622 /* Can deadlock when called with interrupts disabled */
623 WARN_ON(irqs_disabled());
624
625 data.func = func;
626 data.info = info;
627 atomic_set(&data.started, 0);
628 data.wait = wait;
629 if (wait)
630 atomic_set(&data.finished, 0);
631
632 call_data = &data;
633 mb();
634
635 /* Send a message to all other CPUs and wait for them to respond */
636 send_IPI_allbutself(CALL_FUNCTION_IPI, 0);
637
638 /* Wait for response */
639 while (atomic_read(&data.started) != cpus)
640 barrier();
641
642 if (wait)
643 while (atomic_read(&data.finished) != cpus)
644 barrier();
645 spin_unlock(&call_lock);
646 553
647 return 0; 554void arch_send_call_function_single_ipi(int cpu)
555{
556 send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNC_SINGLE_IPI, 0);
648} 557}
649 558
650/*==========================================================================* 559/*==========================================================================*
@@ -666,27 +575,16 @@ int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
666 *==========================================================================*/ 575 *==========================================================================*/
667void smp_call_function_interrupt(void) 576void smp_call_function_interrupt(void)
668{ 577{
669 void (*func) (void *info) = call_data->func;
670 void *info = call_data->info;
671 int wait = call_data->wait;
672
673 /*
674 * Notify initiating CPU that I've grabbed the data and am
675 * about to execute the function
676 */
677 mb();
678 atomic_inc(&call_data->started);
679 /*
680 * At this point the info structure may be out of scope unless wait==1
681 */
682 irq_enter(); 578 irq_enter();
683 (*func)(info); 579 generic_smp_call_function_interrupt();
684 irq_exit(); 580 irq_exit();
581}
685 582
686 if (wait) { 583void smp_call_function_single_interrupt(void)
687 mb(); 584{
688 atomic_inc(&call_data->finished); 585 irq_enter();
689 } 586 generic_smp_call_function_single_interrupt();
587 irq_exit();
690} 588}
691 589
692/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ 590/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
diff --git a/arch/m32r/kernel/traps.c b/arch/m32r/kernel/traps.c
index 89ba4a0b5d5..46159a4e644 100644
--- a/arch/m32r/kernel/traps.c
+++ b/arch/m32r/kernel/traps.c
@@ -40,6 +40,7 @@ extern void smp_invalidate_interrupt(void);
40extern void smp_call_function_interrupt(void); 40extern void smp_call_function_interrupt(void);
41extern void smp_ipi_timer_interrupt(void); 41extern void smp_ipi_timer_interrupt(void);
42extern void smp_flush_cache_all_interrupt(void); 42extern void smp_flush_cache_all_interrupt(void);
43extern void smp_call_function_single_interrupt(void);
43 44
44/* 45/*
45 * for Boot AP function 46 * for Boot AP function
@@ -103,7 +104,7 @@ void set_eit_vector_entries(void)
103 eit_vector[186] = (unsigned long)smp_call_function_interrupt; 104 eit_vector[186] = (unsigned long)smp_call_function_interrupt;
104 eit_vector[187] = (unsigned long)smp_ipi_timer_interrupt; 105 eit_vector[187] = (unsigned long)smp_ipi_timer_interrupt;
105 eit_vector[188] = (unsigned long)smp_flush_cache_all_interrupt; 106 eit_vector[188] = (unsigned long)smp_flush_cache_all_interrupt;
106 eit_vector[189] = 0; 107 eit_vector[189] = (unsigned long)smp_call_function_single_interrupt;
107 eit_vector[190] = 0; 108 eit_vector[190] = 0;
108 eit_vector[191] = 0; 109 eit_vector[191] = 0;
109#endif 110#endif
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 24c5dee9176..d21df5f1b1f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -181,38 +181,6 @@ config LEMOTE_FULONG
181 Lemote Fulong mini-PC board based on the Chinese Loongson-2E CPU and 181 Lemote Fulong mini-PC board based on the Chinese Loongson-2E CPU and
182 an FPGA northbridge 182 an FPGA northbridge
183 183
184config MIPS_ATLAS
185 bool "MIPS Atlas board"
186 select BOOT_ELF32
187 select BOOT_RAW
188 select CEVT_R4K
189 select CSRC_R4K
190 select DMA_NONCOHERENT
191 select SYS_HAS_EARLY_PRINTK
192 select IRQ_CPU
193 select HW_HAS_PCI
194 select MIPS_BOARDS_GEN
195 select MIPS_BONITO64
196 select PCI_GT64XXX_PCI0
197 select MIPS_MSC
198 select RM7000_CPU_SCACHE
199 select SWAP_IO_SPACE
200 select SYS_HAS_CPU_MIPS32_R1
201 select SYS_HAS_CPU_MIPS32_R2
202 select SYS_HAS_CPU_MIPS64_R1
203 select SYS_HAS_CPU_NEVADA
204 select SYS_HAS_CPU_RM7000
205 select SYS_SUPPORTS_32BIT_KERNEL
206 select SYS_SUPPORTS_64BIT_KERNEL
207 select SYS_SUPPORTS_BIG_ENDIAN
208 select SYS_SUPPORTS_LITTLE_ENDIAN
209 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL
210 select SYS_SUPPORTS_SMARTMIPS
211 select GENERIC_HARDIRQS_NO__DO_IRQ
212 help
213 This enables support for the MIPS Technologies Atlas evaluation
214 board.
215
216config MIPS_MALTA 184config MIPS_MALTA
217 bool "MIPS Malta board" 185 bool "MIPS Malta board"
218 select ARCH_MAY_HAVE_PC_FDC 186 select ARCH_MAY_HAVE_PC_FDC
@@ -249,26 +217,6 @@ config MIPS_MALTA
249 This enables support for the MIPS Technologies Malta evaluation 217 This enables support for the MIPS Technologies Malta evaluation
250 board. 218 board.
251 219
252config MIPS_SEAD
253 bool "MIPS SEAD board"
254 select CEVT_R4K
255 select CSRC_R4K
256 select IRQ_CPU
257 select DMA_NONCOHERENT
258 select SYS_HAS_EARLY_PRINTK
259 select MIPS_BOARDS_GEN
260 select SYS_HAS_CPU_MIPS32_R1
261 select SYS_HAS_CPU_MIPS32_R2
262 select SYS_HAS_CPU_MIPS64_R1
263 select SYS_SUPPORTS_32BIT_KERNEL
264 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
265 select SYS_SUPPORTS_BIG_ENDIAN
266 select SYS_SUPPORTS_LITTLE_ENDIAN
267 select SYS_SUPPORTS_SMARTMIPS
268 help
269 This enables support for the MIPS Technologies SEAD evaluation
270 board.
271
272config MIPS_SIM 220config MIPS_SIM
273 bool 'MIPS simulator (MIPSsim)' 221 bool 'MIPS simulator (MIPSsim)'
274 select CEVT_R4K 222 select CEVT_R4K
@@ -437,6 +385,8 @@ config SGI_IP28
437 select SGI_HAS_DS1286 385 select SGI_HAS_DS1286
438 select SGI_HAS_I8042 386 select SGI_HAS_I8042
439 select SGI_HAS_INDYDOG 387 select SGI_HAS_INDYDOG
388 select SGI_HAS_HAL2
389 select SGI_HAS_HAL2
440 select SGI_HAS_SEEQ 390 select SGI_HAS_SEEQ
441 select SGI_HAS_WD93 391 select SGI_HAS_WD93
442 select SGI_HAS_ZILOG 392 select SGI_HAS_ZILOG
@@ -602,65 +552,11 @@ config SNI_RM
602 Technology and now in turn merged with Fujitsu. Say Y here to 552 Technology and now in turn merged with Fujitsu. Say Y here to
603 support this machine type. 553 support this machine type.
604 554
605config TOSHIBA_JMR3927 555config MACH_TX39XX
606 bool "Toshiba JMR-TX3927 board" 556 bool "Toshiba TX39 series based machines"
607 select CEVT_TXX9
608 select DMA_NONCOHERENT
609 select HW_HAS_PCI
610 select MIPS_TX3927
611 select IRQ_TXX9
612 select SWAP_IO_SPACE
613 select SYS_HAS_CPU_TX39XX
614 select SYS_SUPPORTS_32BIT_KERNEL
615 select SYS_SUPPORTS_LITTLE_ENDIAN
616 select SYS_SUPPORTS_BIG_ENDIAN
617 select GENERIC_HARDIRQS_NO__DO_IRQ
618 select GPIO_TXX9
619 557
620config TOSHIBA_RBTX4927 558config MACH_TX49XX
621 bool "Toshiba RBTX49[23]7 board" 559 bool "Toshiba TX49 series based machines"
622 select CEVT_R4K
623 select CSRC_R4K
624 select CEVT_TXX9
625 select DMA_NONCOHERENT
626 select HAS_TXX9_SERIAL
627 select HW_HAS_PCI
628 select IRQ_CPU
629 select IRQ_TXX9
630 select I8259 if TOSHIBA_FPCIB0
631 select SWAP_IO_SPACE
632 select SYS_HAS_CPU_TX49XX
633 select SYS_SUPPORTS_32BIT_KERNEL
634 select SYS_SUPPORTS_64BIT_KERNEL
635 select SYS_SUPPORTS_LITTLE_ENDIAN
636 select SYS_SUPPORTS_BIG_ENDIAN
637 select SYS_SUPPORTS_KGDB
638 select GENERIC_HARDIRQS_NO__DO_IRQ
639 help
640 This Toshiba board is based on the TX4927 processor. Say Y here to
641 support this machine type
642
643config TOSHIBA_RBTX4938
644 bool "Toshiba RBTX4938 board"
645 select CEVT_R4K
646 select CSRC_R4K
647 select CEVT_TXX9
648 select DMA_NONCOHERENT
649 select HAS_TXX9_SERIAL
650 select HW_HAS_PCI
651 select IRQ_CPU
652 select IRQ_TXX9
653 select SWAP_IO_SPACE
654 select SYS_HAS_CPU_TX49XX
655 select SYS_SUPPORTS_32BIT_KERNEL
656 select SYS_SUPPORTS_LITTLE_ENDIAN
657 select SYS_SUPPORTS_BIG_ENDIAN
658 select SYS_SUPPORTS_KGDB
659 select GENERIC_HARDIRQS_NO__DO_IRQ
660 select GPIO_TXX9
661 help
662 This Toshiba board is based on the TX4938 processor. Say Y here to
663 support this machine type
664 560
665config WR_PPMC 561config WR_PPMC
666 bool "Wind River PPMC board" 562 bool "Wind River PPMC board"
@@ -694,8 +590,7 @@ source "arch/mips/lasat/Kconfig"
694source "arch/mips/pmc-sierra/Kconfig" 590source "arch/mips/pmc-sierra/Kconfig"
695source "arch/mips/sgi-ip27/Kconfig" 591source "arch/mips/sgi-ip27/Kconfig"
696source "arch/mips/sibyte/Kconfig" 592source "arch/mips/sibyte/Kconfig"
697source "arch/mips/tx4927/Kconfig" 593source "arch/mips/txx9/Kconfig"
698source "arch/mips/tx4938/Kconfig"
699source "arch/mips/vr41xx/Kconfig" 594source "arch/mips/vr41xx/Kconfig"
700 595
701endmenu 596endmenu
@@ -939,10 +834,6 @@ config PCI_GT64XXX_PCI0
939config NO_EXCEPT_FILL 834config NO_EXCEPT_FILL
940 bool 835 bool
941 836
942config MIPS_TX3927
943 bool
944 select HAS_TXX9_SERIAL
945
946config MIPS_RM9122 837config MIPS_RM9122
947 bool 838 bool
948 select SERIAL_RM9000 839 select SERIAL_RM9000
@@ -979,6 +870,9 @@ config SGI_HAS_DS1286
979config SGI_HAS_INDYDOG 870config SGI_HAS_INDYDOG
980 bool 871 bool
981 872
873config SGI_HAS_HAL2
874 bool
875
982config SGI_HAS_SEEQ 876config SGI_HAS_SEEQ
983 bool 877 bool
984 878
@@ -1763,6 +1657,7 @@ config SMP
1763 bool "Multi-Processing support" 1657 bool "Multi-Processing support"
1764 depends on SYS_SUPPORTS_SMP 1658 depends on SYS_SUPPORTS_SMP
1765 select IRQ_PER_CPU 1659 select IRQ_PER_CPU
1660 select USE_GENERIC_SMP_HELPERS
1766 help 1661 help
1767 This enables support for systems with more than one CPU. If you have 1662 This enables support for systems with more than one CPU. If you have
1768 a system with only one CPU, like most personal computers, say N. If 1663 a system with only one CPU, like most personal computers, say N. If
@@ -2064,10 +1959,6 @@ source "fs/Kconfig.binfmt"
2064config TRAD_SIGNALS 1959config TRAD_SIGNALS
2065 bool 1960 bool
2066 1961
2067config BINFMT_IRIX
2068 bool "Include IRIX binary compatibility"
2069 depends on CPU_BIG_ENDIAN && 32BIT && BROKEN
2070
2071config MIPS32_COMPAT 1962config MIPS32_COMPAT
2072 bool "Kernel support for Linux/MIPS 32-bit binary compatibility" 1963 bool "Kernel support for Linux/MIPS 32-bit binary compatibility"
2073 depends on 64BIT 1964 depends on 64BIT
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index ad36c946ff9..356453322b4 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -14,7 +14,7 @@
14 14
15KBUILD_DEFCONFIG := ip22_defconfig 15KBUILD_DEFCONFIG := ip22_defconfig
16 16
17cflags-y := 17cflags-y := -ffunction-sections
18 18
19# 19#
20# Select the object file format to substitute into the linker script. 20# Select the object file format to substitute into the linker script.
@@ -305,36 +305,14 @@ load-$(CONFIG_LEMOTE_FULONG) +=0xffffffff80100000
305cflags-$(CONFIG_LEMOTE_FULONG) += -Iinclude/asm-mips/mach-lemote 305cflags-$(CONFIG_LEMOTE_FULONG) += -Iinclude/asm-mips/mach-lemote
306 306
307# 307#
308# For all MIPS, Inc. eval boards
309#
310core-$(CONFIG_MIPS_BOARDS_GEN) += arch/mips/mips-boards/generic/
311
312#
313# MIPS Atlas board
314#
315core-$(CONFIG_MIPS_ATLAS) += arch/mips/mips-boards/atlas/
316cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-atlas
317cflags-$(CONFIG_MIPS_ATLAS) += -Iinclude/asm-mips/mach-mips
318load-$(CONFIG_MIPS_ATLAS) += 0xffffffff80100000
319all-$(CONFIG_MIPS_ATLAS) := vmlinux.bin
320
321#
322# MIPS Malta board 308# MIPS Malta board
323# 309#
324core-$(CONFIG_MIPS_MALTA) += arch/mips/mips-boards/malta/ 310core-$(CONFIG_MIPS_MALTA) += arch/mips/mti-malta/
325cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-mips 311cflags-$(CONFIG_MIPS_MALTA) += -Iinclude/asm-mips/mach-malta
326load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000 312load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
327all-$(CONFIG_MIPS_MALTA) := vmlinux.bin 313all-$(CONFIG_MIPS_MALTA) := vmlinux.bin
328 314
329# 315#
330# MIPS SEAD board
331#
332core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/
333cflags-$(CONFIG_MIPS_SEAD) += -Iinclude/asm-mips/mach-mips
334load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000
335all-$(CONFIG_MIPS_SEAD) := vmlinux.srec
336
337#
338# MIPS SIM 316# MIPS SIM
339# 317#
340core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/ 318core-$(CONFIG_MIPS_SIM) += arch/mips/mipssim/
@@ -377,12 +355,6 @@ core-$(CONFIG_MACH_VR41XX) += arch/mips/vr41xx/common/
377cflags-$(CONFIG_MACH_VR41XX) += -Iinclude/asm-mips/mach-vr41xx 355cflags-$(CONFIG_MACH_VR41XX) += -Iinclude/asm-mips/mach-vr41xx
378 356
379# 357#
380# NEC VR4133
381#
382core-$(CONFIG_NEC_CMBVR4133) += arch/mips/vr41xx/nec-cmbvr4133/
383load-$(CONFIG_NEC_CMBVR4133) += 0xffffffff80100000
384
385#
386# ZAO Networks Capcella (VR4131) 358# ZAO Networks Capcella (VR4131)
387# 359#
388load-$(CONFIG_ZAO_CAPCELLA) += 0xffffffff80000000 360load-$(CONFIG_ZAO_CAPCELLA) += 0xffffffff80000000
@@ -573,29 +545,30 @@ endif
573all-$(CONFIG_SNI_RM) := vmlinux.ecoff 545all-$(CONFIG_SNI_RM) := vmlinux.ecoff
574 546
575# 547#
548# Common TXx9
549#
550core-$(CONFIG_MACH_TX39XX) += arch/mips/txx9/generic/
551cflags-$(CONFIG_MACH_TX39XX) += -Iinclude/asm-mips/mach-tx39xx
552load-$(CONFIG_MACH_TX39XX) += 0xffffffff80050000
553core-$(CONFIG_MACH_TX49XX) += arch/mips/txx9/generic/
554cflags-$(CONFIG_MACH_TX49XX) += -Iinclude/asm-mips/mach-tx49xx
555load-$(CONFIG_MACH_TX49XX) += 0xffffffff80100000
556
557#
576# Toshiba JMR-TX3927 board 558# Toshiba JMR-TX3927 board
577# 559#
578core-$(CONFIG_TOSHIBA_JMR3927) += arch/mips/jmr3927/rbhma3100/ \ 560core-$(CONFIG_TOSHIBA_JMR3927) += arch/mips/txx9/jmr3927/
579 arch/mips/jmr3927/common/
580cflags-$(CONFIG_TOSHIBA_JMR3927) += -Iinclude/asm-mips/mach-jmr3927
581load-$(CONFIG_TOSHIBA_JMR3927) += 0xffffffff80050000
582 561
583# 562#
584# Toshiba RBTX4927 board or 563# Toshiba RBTX4927 board or
585# Toshiba RBTX4937 board 564# Toshiba RBTX4937 board
586# 565#
587core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/tx4927/toshiba_rbtx4927/ 566core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/txx9/rbtx4927/
588core-$(CONFIG_TOSHIBA_RBTX4927) += arch/mips/tx4927/common/
589cflags-$(CONFIG_TOSHIBA_RBTX4927) += -Iinclude/asm-mips/mach-tx49xx
590load-$(CONFIG_TOSHIBA_RBTX4927) += 0xffffffff80020000
591 567
592# 568#
593# Toshiba RBTX4938 board 569# Toshiba RBTX4938 board
594# 570#
595core-$(CONFIG_TOSHIBA_RBTX4938) += arch/mips/tx4938/toshiba_rbtx4938/ 571core-$(CONFIG_TOSHIBA_RBTX4938) += arch/mips/txx9/rbtx4938/
596core-$(CONFIG_TOSHIBA_RBTX4938) += arch/mips/tx4938/common/
597cflags-$(CONFIG_TOSHIBA_RBTX4938) += -Iinclude/asm-mips/mach-tx49xx
598load-$(CONFIG_TOSHIBA_RBTX4938) += 0xffffffff80100000
599 572
600cflags-y += -Iinclude/asm-mips/mach-generic 573cflags-y += -Iinclude/asm-mips/mach-generic
601drivers-$(CONFIG_PCI) += arch/mips/pci/ 574drivers-$(CONFIG_PCI) += arch/mips/pci/
diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
index 74d6d4a593b..dc8a67efac2 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/au1000/common/platform.c
@@ -11,6 +11,7 @@
11 * warranty of any kind, whether express or implied. 11 * warranty of any kind, whether express or implied.
12 */ 12 */
13 13
14#include <linux/dma-mapping.h>
14#include <linux/platform_device.h> 15#include <linux/platform_device.h>
15#include <linux/serial_8250.h> 16#include <linux/serial_8250.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -77,14 +78,14 @@ static struct resource au1xxx_usb_ohci_resources[] = {
77}; 78};
78 79
79/* The dmamask must be set for OHCI to work */ 80/* The dmamask must be set for OHCI to work */
80static u64 ohci_dmamask = ~(u32)0; 81static u64 ohci_dmamask = DMA_32BIT_MASK;
81 82
82static struct platform_device au1xxx_usb_ohci_device = { 83static struct platform_device au1xxx_usb_ohci_device = {
83 .name = "au1xxx-ohci", 84 .name = "au1xxx-ohci",
84 .id = 0, 85 .id = 0,
85 .dev = { 86 .dev = {
86 .dma_mask = &ohci_dmamask, 87 .dma_mask = &ohci_dmamask,
87 .coherent_dma_mask = 0xffffffff, 88 .coherent_dma_mask = DMA_32BIT_MASK,
88 }, 89 },
89 .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources), 90 .num_resources = ARRAY_SIZE(au1xxx_usb_ohci_resources),
90 .resource = au1xxx_usb_ohci_resources, 91 .resource = au1xxx_usb_ohci_resources,
@@ -106,14 +107,14 @@ static struct resource au1100_lcd_resources[] = {
106 } 107 }
107}; 108};
108 109
109static u64 au1100_lcd_dmamask = ~(u32)0; 110static u64 au1100_lcd_dmamask = DMA_32BIT_MASK;
110 111
111static struct platform_device au1100_lcd_device = { 112static struct platform_device au1100_lcd_device = {
112 .name = "au1100-lcd", 113 .name = "au1100-lcd",
113 .id = 0, 114 .id = 0,
114 .dev = { 115 .dev = {
115 .dma_mask = &au1100_lcd_dmamask, 116 .dma_mask = &au1100_lcd_dmamask,
116 .coherent_dma_mask = 0xffffffff, 117 .coherent_dma_mask = DMA_32BIT_MASK,
117 }, 118 },
118 .num_resources = ARRAY_SIZE(au1100_lcd_resources), 119 .num_resources = ARRAY_SIZE(au1100_lcd_resources),
119 .resource = au1100_lcd_resources, 120 .resource = au1100_lcd_resources,
@@ -135,14 +136,14 @@ static struct resource au1xxx_usb_ehci_resources[] = {
135 }, 136 },
136}; 137};
137 138
138static u64 ehci_dmamask = ~(u32)0; 139static u64 ehci_dmamask = DMA_32BIT_MASK;
139 140
140static struct platform_device au1xxx_usb_ehci_device = { 141static struct platform_device au1xxx_usb_ehci_device = {
141 .name = "au1xxx-ehci", 142 .name = "au1xxx-ehci",
142 .id = 0, 143 .id = 0,
143 .dev = { 144 .dev = {
144 .dma_mask = &ehci_dmamask, 145 .dma_mask = &ehci_dmamask,
145 .coherent_dma_mask = 0xffffffff, 146 .coherent_dma_mask = DMA_32BIT_MASK,
146 }, 147 },
147 .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources), 148 .num_resources = ARRAY_SIZE(au1xxx_usb_ehci_resources),
148 .resource = au1xxx_usb_ehci_resources, 149 .resource = au1xxx_usb_ehci_resources,
@@ -180,14 +181,14 @@ static struct resource au1xxx_mmc_resources[] = {
180 } 181 }
181}; 182};
182 183
183static u64 udc_dmamask = ~(u32)0; 184static u64 udc_dmamask = DMA_32BIT_MASK;
184 185
185static struct platform_device au1xxx_usb_gdt_device = { 186static struct platform_device au1xxx_usb_gdt_device = {
186 .name = "au1xxx-udc", 187 .name = "au1xxx-udc",
187 .id = 0, 188 .id = 0,
188 .dev = { 189 .dev = {
189 .dma_mask = &udc_dmamask, 190 .dma_mask = &udc_dmamask,
190 .coherent_dma_mask = 0xffffffff, 191 .coherent_dma_mask = DMA_32BIT_MASK,
191 }, 192 },
192 .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources), 193 .num_resources = ARRAY_SIZE(au1xxx_usb_gdt_resources),
193 .resource = au1xxx_usb_gdt_resources, 194 .resource = au1xxx_usb_gdt_resources,
@@ -207,14 +208,14 @@ static struct resource au1xxx_usb_otg_resources[] = {
207 }, 208 },
208}; 209};
209 210
210static u64 uoc_dmamask = ~(u32)0; 211static u64 uoc_dmamask = DMA_32BIT_MASK;
211 212
212static struct platform_device au1xxx_usb_otg_device = { 213static struct platform_device au1xxx_usb_otg_device = {
213 .name = "au1xxx-uoc", 214 .name = "au1xxx-uoc",
214 .id = 0, 215 .id = 0,
215 .dev = { 216 .dev = {
216 .dma_mask = &uoc_dmamask, 217 .dma_mask = &uoc_dmamask,
217 .coherent_dma_mask = 0xffffffff, 218 .coherent_dma_mask = DMA_32BIT_MASK,
218 }, 219 },
219 .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources), 220 .num_resources = ARRAY_SIZE(au1xxx_usb_otg_resources),
220 .resource = au1xxx_usb_otg_resources, 221 .resource = au1xxx_usb_otg_resources,
@@ -233,27 +234,27 @@ static struct resource au1200_lcd_resources[] = {
233 } 234 }
234}; 235};
235 236
236static u64 au1200_lcd_dmamask = ~(u32)0; 237static u64 au1200_lcd_dmamask = DMA_32BIT_MASK;
237 238
238static struct platform_device au1200_lcd_device = { 239static struct platform_device au1200_lcd_device = {
239 .name = "au1200-lcd", 240 .name = "au1200-lcd",
240 .id = 0, 241 .id = 0,
241 .dev = { 242 .dev = {
242 .dma_mask = &au1200_lcd_dmamask, 243 .dma_mask = &au1200_lcd_dmamask,
243 .coherent_dma_mask = 0xffffffff, 244 .coherent_dma_mask = DMA_32BIT_MASK,
244 }, 245 },
245 .num_resources = ARRAY_SIZE(au1200_lcd_resources), 246 .num_resources = ARRAY_SIZE(au1200_lcd_resources),
246 .resource = au1200_lcd_resources, 247 .resource = au1200_lcd_resources,
247}; 248};
248 249
249static u64 au1xxx_mmc_dmamask = ~(u32)0; 250static u64 au1xxx_mmc_dmamask = DMA_32BIT_MASK;
250 251
251static struct platform_device au1xxx_mmc_device = { 252static struct platform_device au1xxx_mmc_device = {
252 .name = "au1xxx-mmc", 253 .name = "au1xxx-mmc",
253 .id = 0, 254 .id = 0,
254 .dev = { 255 .dev = {
255 .dma_mask = &au1xxx_mmc_dmamask, 256 .dma_mask = &au1xxx_mmc_dmamask,
256 .coherent_dma_mask = 0xffffffff, 257 .coherent_dma_mask = DMA_32BIT_MASK,
257 }, 258 },
258 .num_resources = ARRAY_SIZE(au1xxx_mmc_resources), 259 .num_resources = ARRAY_SIZE(au1xxx_mmc_resources),
259 .resource = au1xxx_mmc_resources, 260 .resource = au1xxx_mmc_resources,
diff --git a/arch/mips/au1000/mtx-1/platform.c b/arch/mips/au1000/mtx-1/platform.c
index 9807be37c32..8b5914d1241 100644
--- a/arch/mips/au1000/mtx-1/platform.c
+++ b/arch/mips/au1000/mtx-1/platform.c
@@ -24,6 +24,9 @@
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/mtd/partitions.h>
28#include <linux/mtd/physmap.h>
29#include <mtd/mtd-abi.h>
27 30
28static struct gpio_keys_button mtx1_gpio_button[] = { 31static struct gpio_keys_button mtx1_gpio_button[] = {
29 { 32 {
@@ -85,10 +88,56 @@ static struct platform_device mtx1_gpio_leds = {
85 } 88 }
86}; 89};
87 90
91static struct mtd_partition mtx1_mtd_partitions[] = {
92 {
93 .name = "filesystem",
94 .size = 0x01C00000,
95 .offset = 0,
96 },
97 {
98 .name = "yamon",
99 .size = 0x00100000,
100 .offset = MTDPART_OFS_APPEND,
101 .mask_flags = MTD_WRITEABLE,
102 },
103 {
104 .name = "kernel",
105 .size = 0x002c0000,
106 .offset = MTDPART_OFS_APPEND,
107 },
108 {
109 .name = "yamon env",
110 .size = 0x00040000,
111 .offset = MTDPART_OFS_APPEND,
112 },
113};
114
115static struct physmap_flash_data mtx1_flash_data = {
116 .width = 4,
117 .nr_parts = 4,
118 .parts = mtx1_mtd_partitions,
119};
120
121static struct resource mtx1_mtd_resource = {
122 .start = 0x1e000000,
123 .end = 0x1fffffff,
124 .flags = IORESOURCE_MEM,
125};
126
127static struct platform_device mtx1_mtd = {
128 .name = "physmap-flash",
129 .dev = {
130 .platform_data = &mtx1_flash_data,
131 },
132 .num_resources = 1,
133 .resource = &mtx1_mtd_resource,
134};
135
88static struct __initdata platform_device * mtx1_devs[] = { 136static struct __initdata platform_device * mtx1_devs[] = {
89 &mtx1_gpio_leds, 137 &mtx1_gpio_leds,
90 &mtx1_wdt, 138 &mtx1_wdt,
91 &mtx1_button 139 &mtx1_button,
140 &mtx1_mtd,
92}; 141};
93 142
94static int __init mtx1_register_devices(void) 143static int __init mtx1_register_devices(void)
diff --git a/arch/mips/au1000/pb1200/platform.c b/arch/mips/au1000/pb1200/platform.c
index 5930110b9b6..f8fb0aeac57 100644
--- a/arch/mips/au1000/pb1200/platform.c
+++ b/arch/mips/au1000/pb1200/platform.c
@@ -18,6 +18,7 @@
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20 20
21#include <linux/dma-mapping.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23 24
@@ -36,14 +37,14 @@ static struct resource ide_resources[] = {
36 } 37 }
37}; 38};
38 39
39static u64 ide_dmamask = ~(u32)0; 40static u64 ide_dmamask = DMA_32BIT_MASK;
40 41
41static struct platform_device ide_device = { 42static struct platform_device ide_device = {
42 .name = "au1200-ide", 43 .name = "au1200-ide",
43 .id = 0, 44 .id = 0,
44 .dev = { 45 .dev = {
45 .dma_mask = &ide_dmamask, 46 .dma_mask = &ide_dmamask,
46 .coherent_dma_mask = 0xffffffff, 47 .coherent_dma_mask = DMA_32BIT_MASK,
47 }, 48 },
48 .num_resources = ARRAY_SIZE(ide_resources), 49 .num_resources = ARRAY_SIZE(ide_resources),
49 .resource = ide_resources 50 .resource = ide_resources
diff --git a/arch/mips/cobalt/Makefile b/arch/mips/cobalt/Makefile
index d73833b7c78..237926288d6 100644
--- a/arch/mips/cobalt/Makefile
+++ b/arch/mips/cobalt/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Cobalt micro systems family specific parts of the kernel 2# Makefile for the Cobalt micro systems family specific parts of the kernel
3# 3#
4 4
5obj-y := buttons.o irq.o led.o reset.o rtc.o serial.o setup.o time.o 5obj-y := buttons.o irq.o lcd.o led.o reset.o rtc.o serial.o setup.o time.o
6 6
7obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
8obj-$(CONFIG_EARLY_PRINTK) += console.o 8obj-$(CONFIG_EARLY_PRINTK) += console.o
diff --git a/arch/mips/cobalt/lcd.c b/arch/mips/cobalt/lcd.c
new file mode 100644
index 00000000000..0720e4fae31
--- /dev/null
+++ b/arch/mips/cobalt/lcd.c
@@ -0,0 +1,55 @@
1/*
2 * Registration of Cobalt LCD platform device.
3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#include <linux/errno.h>
21#include <linux/init.h>
22#include <linux/ioport.h>
23#include <linux/platform_device.h>
24
25static struct resource cobalt_lcd_resource __initdata = {
26 .start = 0x1f000000,
27 .end = 0x1f00001f,
28 .flags = IORESOURCE_MEM,
29};
30
31static __init int cobalt_lcd_add(void)
32{
33 struct platform_device *pdev;
34 int retval;
35
36 pdev = platform_device_alloc("cobalt-lcd", -1);
37 if (!pdev)
38 return -ENOMEM;
39
40 retval = platform_device_add_resources(pdev, &cobalt_lcd_resource, 1);
41 if (retval)
42 goto err_free_device;
43
44 retval = platform_device_add(pdev);
45 if (retval)
46 goto err_free_device;
47
48 return 0;
49
50err_free_device:
51 platform_device_put(pdev);
52
53 return retval;
54}
55device_initcall(cobalt_lcd_add);
diff --git a/arch/mips/configs/atlas_defconfig b/arch/mips/configs/atlas_defconfig
deleted file mode 100644
index 3443f6cd57b..00000000000
--- a/arch/mips/configs/atlas_defconfig
+++ /dev/null
@@ -1,1472 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4# Sun Feb 18 21:27:35 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set
15# CONFIG_MIPS_PB1100 is not set
16# CONFIG_MIPS_PB1500 is not set
17# CONFIG_MIPS_PB1550 is not set
18# CONFIG_MIPS_PB1200 is not set
19# CONFIG_MIPS_DB1000 is not set
20# CONFIG_MIPS_DB1100 is not set
21# CONFIG_MIPS_DB1500 is not set
22# CONFIG_MIPS_DB1550 is not set
23# CONFIG_MIPS_DB1200 is not set
24# CONFIG_MIPS_MIRAGE is not set
25# CONFIG_BASLER_EXCITE is not set
26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MACH_JAZZ is not set
29CONFIG_MIPS_ATLAS=y
30# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MIPS_XXS1500 is not set
36# CONFIG_PNX8550_JBS is not set
37# CONFIG_PNX8550_STB810 is not set
38# CONFIG_MACH_VR41XX is not set
39# CONFIG_PMC_YOSEMITE is not set
40# CONFIG_MARKEINS is not set
41# CONFIG_SGI_IP22 is not set
42# CONFIG_SGI_IP27 is not set
43# CONFIG_SGI_IP32 is not set
44# CONFIG_SIBYTE_BIGSUR is not set
45# CONFIG_SIBYTE_SWARM is not set
46# CONFIG_SIBYTE_SENTOSA is not set
47# CONFIG_SIBYTE_RHONE is not set
48# CONFIG_SIBYTE_CARMEL is not set
49# CONFIG_SIBYTE_LITTLESUR is not set
50# CONFIG_SIBYTE_CRHINE is not set
51# CONFIG_SIBYTE_CRHONE is not set
52# CONFIG_SNI_RM is not set
53# CONFIG_TOSHIBA_JMR3927 is not set
54# CONFIG_TOSHIBA_RBTX4927 is not set
55# CONFIG_TOSHIBA_RBTX4938 is not set
56CONFIG_RWSEM_GENERIC_SPINLOCK=y
57# CONFIG_ARCH_HAS_ILOG2_U32 is not set
58# CONFIG_ARCH_HAS_ILOG2_U64 is not set
59CONFIG_GENERIC_FIND_NEXT_BIT=y
60CONFIG_GENERIC_HWEIGHT=y
61CONFIG_GENERIC_CALIBRATE_DELAY=y
62CONFIG_GENERIC_TIME=y
63CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
64CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
65CONFIG_DMA_NONCOHERENT=y
66CONFIG_DMA_NEED_PCI_MAP_STATE=y
67CONFIG_MIPS_BONITO64=y
68CONFIG_MIPS_MSC=y
69# CONFIG_CPU_BIG_ENDIAN is not set
70CONFIG_CPU_LITTLE_ENDIAN=y
71CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
72CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
73CONFIG_IRQ_CPU=y
74CONFIG_MIPS_BOARDS_GEN=y
75CONFIG_MIPS_GT64120=y
76CONFIG_SWAP_IO_SPACE=y
77CONFIG_BOOT_ELF32=y
78CONFIG_MIPS_L1_CACHE_SHIFT=5
79
80#
81# CPU selection
82#
83CONFIG_CPU_MIPS32_R1=y
84# CONFIG_CPU_MIPS32_R2 is not set
85# CONFIG_CPU_MIPS64_R1 is not set
86# CONFIG_CPU_MIPS64_R2 is not set
87# CONFIG_CPU_R3000 is not set
88# CONFIG_CPU_TX39XX is not set
89# CONFIG_CPU_VR41XX is not set
90# CONFIG_CPU_R4300 is not set
91# CONFIG_CPU_R4X00 is not set
92# CONFIG_CPU_TX49XX is not set
93# CONFIG_CPU_R5000 is not set
94# CONFIG_CPU_R5432 is not set
95# CONFIG_CPU_R6000 is not set
96# CONFIG_CPU_NEVADA is not set
97# CONFIG_CPU_R8000 is not set
98# CONFIG_CPU_R10000 is not set
99# CONFIG_CPU_RM7000 is not set
100# CONFIG_CPU_RM9000 is not set
101# CONFIG_CPU_SB1 is not set
102CONFIG_SYS_HAS_CPU_MIPS32_R1=y
103CONFIG_SYS_HAS_CPU_MIPS32_R2=y
104CONFIG_SYS_HAS_CPU_MIPS64_R1=y
105CONFIG_SYS_HAS_CPU_NEVADA=y
106CONFIG_SYS_HAS_CPU_RM7000=y
107CONFIG_CPU_MIPS32=y
108CONFIG_CPU_MIPSR1=y
109CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
110CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
111CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
112
113#
114# Kernel type
115#
116CONFIG_32BIT=y
117# CONFIG_64BIT is not set
118CONFIG_PAGE_SIZE_4KB=y
119# CONFIG_PAGE_SIZE_8KB is not set
120# CONFIG_PAGE_SIZE_16KB is not set
121# CONFIG_PAGE_SIZE_64KB is not set
122CONFIG_BOARD_SCACHE=y
123CONFIG_RM7000_CPU_SCACHE=y
124CONFIG_CPU_HAS_PREFETCH=y
125CONFIG_MIPS_MT_DISABLED=y
126# CONFIG_MIPS_MT_SMP is not set
127# CONFIG_MIPS_MT_SMTC is not set
128# CONFIG_MIPS_VPE_LOADER is not set
129CONFIG_SYS_SUPPORTS_MULTITHREADING=y
130# CONFIG_64BIT_PHYS_ADDR is not set
131CONFIG_CPU_HAS_LLSC=y
132# CONFIG_CPU_HAS_SMARTMIPS is not set
133CONFIG_CPU_HAS_SYNC=y
134CONFIG_GENERIC_HARDIRQS=y
135CONFIG_GENERIC_IRQ_PROBE=y
136CONFIG_CPU_SUPPORTS_HIGHMEM=y
137CONFIG_SYS_SUPPORTS_SMARTMIPS=y
138CONFIG_ARCH_FLATMEM_ENABLE=y
139CONFIG_SELECT_MEMORY_MODEL=y
140CONFIG_FLATMEM_MANUAL=y
141# CONFIG_DISCONTIGMEM_MANUAL is not set
142# CONFIG_SPARSEMEM_MANUAL is not set
143CONFIG_FLATMEM=y
144CONFIG_FLAT_NODE_MEM_MAP=y
145# CONFIG_SPARSEMEM_STATIC is not set
146CONFIG_SPLIT_PTLOCK_CPUS=4
147# CONFIG_RESOURCES_64BIT is not set
148CONFIG_ZONE_DMA_FLAG=1
149# CONFIG_HZ_48 is not set
150CONFIG_HZ_100=y
151# CONFIG_HZ_128 is not set
152# CONFIG_HZ_250 is not set
153# CONFIG_HZ_256 is not set
154# CONFIG_HZ_1000 is not set
155# CONFIG_HZ_1024 is not set
156CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
157CONFIG_HZ=100
158CONFIG_PREEMPT_NONE=y
159# CONFIG_PREEMPT_VOLUNTARY is not set
160# CONFIG_PREEMPT is not set
161# CONFIG_KEXEC is not set
162CONFIG_LOCKDEP_SUPPORT=y
163CONFIG_STACKTRACE_SUPPORT=y
164CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
165
166#
167# Code maturity level options
168#
169CONFIG_EXPERIMENTAL=y
170CONFIG_BROKEN_ON_SMP=y
171CONFIG_INIT_ENV_ARG_LIMIT=32
172
173#
174# General setup
175#
176CONFIG_LOCALVERSION=""
177CONFIG_LOCALVERSION_AUTO=y
178CONFIG_SWAP=y
179CONFIG_SYSVIPC=y
180# CONFIG_IPC_NS is not set
181CONFIG_SYSVIPC_SYSCTL=y
182# CONFIG_POSIX_MQUEUE is not set
183# CONFIG_BSD_PROCESS_ACCT is not set
184# CONFIG_TASKSTATS is not set
185# CONFIG_UTS_NS is not set
186# CONFIG_AUDIT is not set
187# CONFIG_IKCONFIG is not set
188CONFIG_SYSFS_DEPRECATED=y
189CONFIG_RELAY=y
190# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
191CONFIG_SYSCTL=y
192CONFIG_EMBEDDED=y
193CONFIG_SYSCTL_SYSCALL=y
194CONFIG_KALLSYMS=y
195# CONFIG_KALLSYMS_EXTRA_PASS is not set
196CONFIG_HOTPLUG=y
197CONFIG_PRINTK=y
198CONFIG_BUG=y
199CONFIG_ELF_CORE=y
200CONFIG_BASE_FULL=y
201CONFIG_FUTEX=y
202CONFIG_EPOLL=y
203CONFIG_SHMEM=y
204CONFIG_SLAB=y
205CONFIG_VM_EVENT_COUNTERS=y
206CONFIG_RT_MUTEXES=y
207# CONFIG_TINY_SHMEM is not set
208CONFIG_BASE_SMALL=0
209# CONFIG_SLOB is not set
210
211#
212# Loadable module support
213#
214CONFIG_MODULES=y
215CONFIG_MODULE_UNLOAD=y
216# CONFIG_MODULE_FORCE_UNLOAD is not set
217CONFIG_MODVERSIONS=y
218CONFIG_MODULE_SRCVERSION_ALL=y
219CONFIG_KMOD=y
220
221#
222# Block layer
223#
224CONFIG_BLOCK=y
225# CONFIG_LBD is not set
226# CONFIG_BLK_DEV_IO_TRACE is not set
227# CONFIG_LSF is not set
228
229#
230# IO Schedulers
231#
232CONFIG_IOSCHED_NOOP=y
233CONFIG_IOSCHED_AS=y
234CONFIG_IOSCHED_DEADLINE=y
235CONFIG_IOSCHED_CFQ=y
236CONFIG_DEFAULT_AS=y
237# CONFIG_DEFAULT_DEADLINE is not set
238# CONFIG_DEFAULT_CFQ is not set
239# CONFIG_DEFAULT_NOOP is not set
240CONFIG_DEFAULT_IOSCHED="anticipatory"
241
242#
243# Bus options (PCI, PCMCIA, EISA, ISA, TC)
244#
245CONFIG_HW_HAS_PCI=y
246CONFIG_PCI=y
247CONFIG_MMU=y
248
249#
250# PCCARD (PCMCIA/CardBus) support
251#
252# CONFIG_PCCARD is not set
253
254#
255# PCI Hotplug Support
256#
257# CONFIG_HOTPLUG_PCI is not set
258
259#
260# Executable file formats
261#
262CONFIG_BINFMT_ELF=y
263# CONFIG_BINFMT_MISC is not set
264CONFIG_TRAD_SIGNALS=y
265
266#
267# Power management options
268#
269CONFIG_PM=y
270# CONFIG_PM_LEGACY is not set
271# CONFIG_PM_DEBUG is not set
272# CONFIG_PM_SYSFS_DEPRECATED is not set
273
274#
275# Networking
276#
277CONFIG_NET=y
278
279#
280# Networking options
281#
282# CONFIG_NETDEBUG is not set
283CONFIG_PACKET=y
284CONFIG_PACKET_MMAP=y
285CONFIG_UNIX=y
286CONFIG_XFRM=y
287CONFIG_XFRM_USER=m
288# CONFIG_XFRM_SUB_POLICY is not set
289CONFIG_XFRM_MIGRATE=y
290CONFIG_NET_KEY=y
291CONFIG_NET_KEY_MIGRATE=y
292CONFIG_INET=y
293CONFIG_IP_MULTICAST=y
294CONFIG_IP_ADVANCED_ROUTER=y
295CONFIG_ASK_IP_FIB_HASH=y
296# CONFIG_IP_FIB_TRIE is not set
297CONFIG_IP_FIB_HASH=y
298CONFIG_IP_MULTIPLE_TABLES=y
299CONFIG_IP_ROUTE_MULTIPATH=y
300# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
301CONFIG_IP_ROUTE_VERBOSE=y
302CONFIG_IP_PNP=y
303CONFIG_IP_PNP_DHCP=y
304CONFIG_IP_PNP_BOOTP=y
305# CONFIG_IP_PNP_RARP is not set
306CONFIG_NET_IPIP=m
307CONFIG_NET_IPGRE=m
308CONFIG_NET_IPGRE_BROADCAST=y
309CONFIG_IP_MROUTE=y
310CONFIG_IP_PIMSM_V1=y
311CONFIG_IP_PIMSM_V2=y
312# CONFIG_ARPD is not set
313CONFIG_SYN_COOKIES=y
314CONFIG_INET_AH=m
315CONFIG_INET_ESP=m
316CONFIG_INET_IPCOMP=m
317CONFIG_INET_XFRM_TUNNEL=m
318CONFIG_INET_TUNNEL=m
319CONFIG_INET_XFRM_MODE_TRANSPORT=m
320CONFIG_INET_XFRM_MODE_TUNNEL=m
321CONFIG_INET_XFRM_MODE_BEET=m
322CONFIG_INET_DIAG=y
323CONFIG_INET_TCP_DIAG=y
324# CONFIG_TCP_CONG_ADVANCED is not set
325CONFIG_TCP_CONG_CUBIC=y
326CONFIG_DEFAULT_TCP_CONG="cubic"
327CONFIG_TCP_MD5SIG=y
328
329#
330# IP: Virtual Server Configuration
331#
332CONFIG_IP_VS=m
333# CONFIG_IP_VS_DEBUG is not set
334CONFIG_IP_VS_TAB_BITS=12
335
336#
337# IPVS transport protocol load balancing support
338#
339CONFIG_IP_VS_PROTO_TCP=y
340CONFIG_IP_VS_PROTO_UDP=y
341CONFIG_IP_VS_PROTO_ESP=y
342CONFIG_IP_VS_PROTO_AH=y
343
344#
345# IPVS scheduler
346#
347CONFIG_IP_VS_RR=m
348CONFIG_IP_VS_WRR=m
349CONFIG_IP_VS_LC=m
350CONFIG_IP_VS_WLC=m
351CONFIG_IP_VS_LBLC=m
352CONFIG_IP_VS_LBLCR=m
353CONFIG_IP_VS_DH=m
354CONFIG_IP_VS_SH=m
355CONFIG_IP_VS_SED=m
356CONFIG_IP_VS_NQ=m
357
358#
359# IPVS application helper
360#
361CONFIG_IP_VS_FTP=m
362CONFIG_IPV6=m
363CONFIG_IPV6_PRIVACY=y
364CONFIG_IPV6_ROUTER_PREF=y
365CONFIG_IPV6_ROUTE_INFO=y
366CONFIG_INET6_AH=m
367CONFIG_INET6_ESP=m
368CONFIG_INET6_IPCOMP=m
369CONFIG_IPV6_MIP6=y
370CONFIG_INET6_XFRM_TUNNEL=m
371CONFIG_INET6_TUNNEL=m
372CONFIG_INET6_XFRM_MODE_TRANSPORT=m
373CONFIG_INET6_XFRM_MODE_TUNNEL=m
374CONFIG_INET6_XFRM_MODE_BEET=m
375CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
376CONFIG_IPV6_SIT=m
377CONFIG_IPV6_TUNNEL=m
378CONFIG_IPV6_MULTIPLE_TABLES=y
379CONFIG_IPV6_SUBTREES=y
380CONFIG_NETWORK_SECMARK=y
381CONFIG_NETFILTER=y
382# CONFIG_NETFILTER_DEBUG is not set
383CONFIG_BRIDGE_NETFILTER=y
384
385#
386# Core Netfilter Configuration
387#
388CONFIG_NETFILTER_NETLINK=m
389CONFIG_NETFILTER_NETLINK_QUEUE=m
390CONFIG_NETFILTER_NETLINK_LOG=m
391CONFIG_NF_CONNTRACK_ENABLED=m
392CONFIG_NF_CONNTRACK_SUPPORT=y
393# CONFIG_IP_NF_CONNTRACK_SUPPORT is not set
394CONFIG_NF_CONNTRACK=m
395CONFIG_NF_CT_ACCT=y
396CONFIG_NF_CONNTRACK_MARK=y
397CONFIG_NF_CONNTRACK_SECMARK=y
398CONFIG_NF_CONNTRACK_EVENTS=y
399CONFIG_NF_CT_PROTO_GRE=m
400CONFIG_NF_CT_PROTO_SCTP=m
401CONFIG_NF_CONNTRACK_AMANDA=m
402CONFIG_NF_CONNTRACK_FTP=m
403CONFIG_NF_CONNTRACK_H323=m
404CONFIG_NF_CONNTRACK_IRC=m
405# CONFIG_NF_CONNTRACK_NETBIOS_NS is not set
406CONFIG_NF_CONNTRACK_PPTP=m
407CONFIG_NF_CONNTRACK_SANE=m
408CONFIG_NF_CONNTRACK_SIP=m
409CONFIG_NF_CONNTRACK_TFTP=m
410CONFIG_NF_CT_NETLINK=m
411CONFIG_NETFILTER_XTABLES=m
412CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
413CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
414CONFIG_NETFILTER_XT_TARGET_DSCP=m
415CONFIG_NETFILTER_XT_TARGET_MARK=m
416CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m
417CONFIG_NETFILTER_XT_TARGET_NFLOG=m
418CONFIG_NETFILTER_XT_TARGET_NOTRACK=m
419CONFIG_NETFILTER_XT_TARGET_SECMARK=m
420CONFIG_NETFILTER_XT_TARGET_CONNSECMARK=m
421CONFIG_NETFILTER_XT_TARGET_TCPMSS=m
422CONFIG_NETFILTER_XT_MATCH_COMMENT=m
423CONFIG_NETFILTER_XT_MATCH_CONNBYTES=m
424CONFIG_NETFILTER_XT_MATCH_CONNMARK=m
425CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
426CONFIG_NETFILTER_XT_MATCH_DCCP=m
427CONFIG_NETFILTER_XT_MATCH_DSCP=m
428CONFIG_NETFILTER_XT_MATCH_ESP=m
429CONFIG_NETFILTER_XT_MATCH_HELPER=m
430CONFIG_NETFILTER_XT_MATCH_LENGTH=m
431CONFIG_NETFILTER_XT_MATCH_LIMIT=m
432CONFIG_NETFILTER_XT_MATCH_MAC=m
433CONFIG_NETFILTER_XT_MATCH_MARK=m
434CONFIG_NETFILTER_XT_MATCH_POLICY=m
435CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
436CONFIG_NETFILTER_XT_MATCH_PHYSDEV=m
437CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
438CONFIG_NETFILTER_XT_MATCH_QUOTA=m
439CONFIG_NETFILTER_XT_MATCH_REALM=m
440CONFIG_NETFILTER_XT_MATCH_SCTP=m
441CONFIG_NETFILTER_XT_MATCH_STATE=m
442CONFIG_NETFILTER_XT_MATCH_STATISTIC=m
443CONFIG_NETFILTER_XT_MATCH_STRING=m
444CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
445CONFIG_NETFILTER_XT_MATCH_HASHLIMIT=m
446
447#
448# IP: Netfilter Configuration
449#
450CONFIG_NF_CONNTRACK_IPV4=m
451CONFIG_NF_CONNTRACK_PROC_COMPAT=y
452CONFIG_IP_NF_QUEUE=m
453CONFIG_IP_NF_IPTABLES=m
454CONFIG_IP_NF_MATCH_IPRANGE=m
455CONFIG_IP_NF_MATCH_TOS=m
456CONFIG_IP_NF_MATCH_RECENT=m
457CONFIG_IP_NF_MATCH_ECN=m
458CONFIG_IP_NF_MATCH_AH=m
459CONFIG_IP_NF_MATCH_TTL=m
460CONFIG_IP_NF_MATCH_OWNER=m
461CONFIG_IP_NF_MATCH_ADDRTYPE=m
462CONFIG_IP_NF_FILTER=m
463CONFIG_IP_NF_TARGET_REJECT=m
464CONFIG_IP_NF_TARGET_LOG=m
465CONFIG_IP_NF_TARGET_ULOG=m
466CONFIG_NF_NAT=m
467CONFIG_NF_NAT_NEEDED=y
468CONFIG_IP_NF_TARGET_MASQUERADE=m
469CONFIG_IP_NF_TARGET_REDIRECT=m
470CONFIG_IP_NF_TARGET_NETMAP=m
471CONFIG_IP_NF_TARGET_SAME=m
472CONFIG_NF_NAT_SNMP_BASIC=m
473CONFIG_NF_NAT_PROTO_GRE=m
474CONFIG_NF_NAT_FTP=m
475CONFIG_NF_NAT_IRC=m
476CONFIG_NF_NAT_TFTP=m
477CONFIG_NF_NAT_AMANDA=m
478CONFIG_NF_NAT_PPTP=m
479CONFIG_NF_NAT_H323=m
480CONFIG_NF_NAT_SIP=m
481CONFIG_IP_NF_MANGLE=m
482CONFIG_IP_NF_TARGET_TOS=m
483CONFIG_IP_NF_TARGET_ECN=m
484CONFIG_IP_NF_TARGET_TTL=m
485# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
486CONFIG_IP_NF_RAW=m
487CONFIG_IP_NF_ARPTABLES=m
488CONFIG_IP_NF_ARPFILTER=m
489CONFIG_IP_NF_ARP_MANGLE=m
490
491#
492# IPv6: Netfilter Configuration (EXPERIMENTAL)
493#
494CONFIG_NF_CONNTRACK_IPV6=m
495CONFIG_IP6_NF_QUEUE=m
496CONFIG_IP6_NF_IPTABLES=m
497CONFIG_IP6_NF_MATCH_RT=m
498CONFIG_IP6_NF_MATCH_OPTS=m
499CONFIG_IP6_NF_MATCH_FRAG=m
500CONFIG_IP6_NF_MATCH_HL=m
501CONFIG_IP6_NF_MATCH_OWNER=m
502CONFIG_IP6_NF_MATCH_IPV6HEADER=m
503CONFIG_IP6_NF_MATCH_AH=m
504CONFIG_IP6_NF_MATCH_MH=m
505CONFIG_IP6_NF_MATCH_EUI64=m
506CONFIG_IP6_NF_FILTER=m
507CONFIG_IP6_NF_TARGET_LOG=m
508CONFIG_IP6_NF_TARGET_REJECT=m
509CONFIG_IP6_NF_MANGLE=m
510CONFIG_IP6_NF_TARGET_HL=m
511CONFIG_IP6_NF_RAW=m
512
513#
514# Bridge: Netfilter Configuration
515#
516CONFIG_BRIDGE_NF_EBTABLES=m
517CONFIG_BRIDGE_EBT_BROUTE=m
518CONFIG_BRIDGE_EBT_T_FILTER=m
519CONFIG_BRIDGE_EBT_T_NAT=m
520CONFIG_BRIDGE_EBT_802_3=m
521CONFIG_BRIDGE_EBT_AMONG=m
522CONFIG_BRIDGE_EBT_ARP=m
523CONFIG_BRIDGE_EBT_IP=m
524CONFIG_BRIDGE_EBT_LIMIT=m
525CONFIG_BRIDGE_EBT_MARK=m
526CONFIG_BRIDGE_EBT_PKTTYPE=m
527CONFIG_BRIDGE_EBT_STP=m
528CONFIG_BRIDGE_EBT_VLAN=m
529CONFIG_BRIDGE_EBT_ARPREPLY=m
530CONFIG_BRIDGE_EBT_DNAT=m
531CONFIG_BRIDGE_EBT_MARK_T=m
532CONFIG_BRIDGE_EBT_REDIRECT=m
533CONFIG_BRIDGE_EBT_SNAT=m
534CONFIG_BRIDGE_EBT_LOG=m
535CONFIG_BRIDGE_EBT_ULOG=m
536
537#
538# DCCP Configuration (EXPERIMENTAL)
539#
540# CONFIG_IP_DCCP is not set
541
542#
543# SCTP Configuration (EXPERIMENTAL)
544#
545CONFIG_IP_SCTP=m
546# CONFIG_SCTP_DBG_MSG is not set
547# CONFIG_SCTP_DBG_OBJCNT is not set
548# CONFIG_SCTP_HMAC_NONE is not set
549# CONFIG_SCTP_HMAC_SHA1 is not set
550CONFIG_SCTP_HMAC_MD5=y
551
552#
553# TIPC Configuration (EXPERIMENTAL)
554#
555# CONFIG_TIPC is not set
556# CONFIG_ATM is not set
557CONFIG_BRIDGE=m
558CONFIG_VLAN_8021Q=m
559# CONFIG_DECNET is not set
560CONFIG_LLC=m
561# CONFIG_LLC2 is not set
562# CONFIG_IPX is not set
563CONFIG_ATALK=m
564CONFIG_DEV_APPLETALK=m
565CONFIG_IPDDP=m
566CONFIG_IPDDP_ENCAP=y
567CONFIG_IPDDP_DECAP=y
568# CONFIG_X25 is not set
569# CONFIG_LAPB is not set
570# CONFIG_ECONET is not set
571# CONFIG_WAN_ROUTER is not set
572
573#
574# QoS and/or fair queueing
575#
576CONFIG_NET_SCHED=y
577CONFIG_NET_SCH_FIFO=y
578CONFIG_NET_SCH_CLK_JIFFIES=y
579# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
580# CONFIG_NET_SCH_CLK_CPU is not set
581
582#
583# Queueing/Scheduling
584#
585CONFIG_NET_SCH_CBQ=m
586CONFIG_NET_SCH_HTB=m
587CONFIG_NET_SCH_HFSC=m
588CONFIG_NET_SCH_PRIO=m
589CONFIG_NET_SCH_RED=m
590CONFIG_NET_SCH_SFQ=m
591CONFIG_NET_SCH_TEQL=m
592CONFIG_NET_SCH_TBF=m
593CONFIG_NET_SCH_GRED=m
594CONFIG_NET_SCH_DSMARK=m
595CONFIG_NET_SCH_NETEM=m
596CONFIG_NET_SCH_INGRESS=m
597
598#
599# Classification
600#
601CONFIG_NET_CLS=y
602CONFIG_NET_CLS_BASIC=m
603CONFIG_NET_CLS_TCINDEX=m
604CONFIG_NET_CLS_ROUTE4=m
605CONFIG_NET_CLS_ROUTE=y
606CONFIG_NET_CLS_FW=m
607CONFIG_NET_CLS_U32=m
608# CONFIG_CLS_U32_PERF is not set
609# CONFIG_CLS_U32_MARK is not set
610CONFIG_NET_CLS_RSVP=m
611CONFIG_NET_CLS_RSVP6=m
612# CONFIG_NET_EMATCH is not set
613# CONFIG_NET_CLS_ACT is not set
614CONFIG_NET_CLS_POLICE=y
615CONFIG_NET_CLS_IND=y
616CONFIG_NET_ESTIMATOR=y
617
618#
619# Network testing
620#
621# CONFIG_NET_PKTGEN is not set
622# CONFIG_HAMRADIO is not set
623# CONFIG_IRDA is not set
624# CONFIG_BT is not set
625CONFIG_IEEE80211=m
626# CONFIG_IEEE80211_DEBUG is not set
627CONFIG_IEEE80211_CRYPT_WEP=m
628CONFIG_IEEE80211_CRYPT_CCMP=m
629CONFIG_IEEE80211_SOFTMAC=m
630# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
631CONFIG_WIRELESS_EXT=y
632CONFIG_FIB_RULES=y
633
634#
635# Device Drivers
636#
637
638#
639# Generic Driver Options
640#
641CONFIG_STANDALONE=y
642CONFIG_PREVENT_FIRMWARE_BUILD=y
643CONFIG_FW_LOADER=y
644# CONFIG_SYS_HYPERVISOR is not set
645
646#
647# Connector - unified userspace <-> kernelspace linker
648#
649CONFIG_CONNECTOR=m
650
651#
652# Memory Technology Devices (MTD)
653#
654# CONFIG_MTD is not set
655
656#
657# Parallel port support
658#
659# CONFIG_PARPORT is not set
660
661#
662# Plug and Play support
663#
664
665#
666# Block devices
667#
668# CONFIG_BLK_CPQ_DA is not set
669# CONFIG_BLK_CPQ_CISS_DA is not set
670# CONFIG_BLK_DEV_DAC960 is not set
671CONFIG_BLK_DEV_UMEM=m
672# CONFIG_BLK_DEV_COW_COMMON is not set
673CONFIG_BLK_DEV_LOOP=m
674CONFIG_BLK_DEV_CRYPTOLOOP=m
675CONFIG_BLK_DEV_NBD=m
676# CONFIG_BLK_DEV_SX8 is not set
677CONFIG_BLK_DEV_RAM=y
678CONFIG_BLK_DEV_RAM_COUNT=16
679CONFIG_BLK_DEV_RAM_SIZE=4096
680CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
681# CONFIG_BLK_DEV_INITRD is not set
682CONFIG_CDROM_PKTCDVD=m
683CONFIG_CDROM_PKTCDVD_BUFFERS=8
684# CONFIG_CDROM_PKTCDVD_WCACHE is not set
685CONFIG_ATA_OVER_ETH=m
686
687#
688# Misc devices
689#
690CONFIG_SGI_IOC4=m
691# CONFIG_TIFM_CORE is not set
692
693#
694# ATA/ATAPI/MFM/RLL support
695#
696CONFIG_IDE=y
697CONFIG_IDE_MAX_HWIFS=4
698CONFIG_BLK_DEV_IDE=y
699
700#
701# Please see Documentation/ide.txt for help/info on IDE drives
702#
703# CONFIG_BLK_DEV_IDE_SATA is not set
704CONFIG_BLK_DEV_IDEDISK=y
705# CONFIG_IDEDISK_MULTI_MODE is not set
706CONFIG_BLK_DEV_IDECD=y
707# CONFIG_BLK_DEV_IDETAPE is not set
708# CONFIG_BLK_DEV_IDEFLOPPY is not set
709# CONFIG_BLK_DEV_IDESCSI is not set
710# CONFIG_IDE_TASK_IOCTL is not set
711
712#
713# IDE chipset support/bugfixes
714#
715CONFIG_IDE_GENERIC=y
716# CONFIG_BLK_DEV_IDEPCI is not set
717# CONFIG_IDE_ARM is not set
718# CONFIG_BLK_DEV_IDEDMA is not set
719# CONFIG_IDEDMA_AUTO is not set
720# CONFIG_BLK_DEV_HD is not set
721
722#
723# SCSI device support
724#
725CONFIG_RAID_ATTRS=m
726CONFIG_SCSI=y
727CONFIG_SCSI_TGT=m
728CONFIG_SCSI_NETLINK=y
729CONFIG_SCSI_PROC_FS=y
730
731#
732# SCSI support type (disk, tape, CD-ROM)
733#
734CONFIG_BLK_DEV_SD=y
735CONFIG_CHR_DEV_ST=m
736CONFIG_CHR_DEV_OSST=m
737CONFIG_BLK_DEV_SR=m
738CONFIG_BLK_DEV_SR_VENDOR=y
739CONFIG_CHR_DEV_SG=m
740CONFIG_CHR_DEV_SCH=m
741
742#
743# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
744#
745CONFIG_SCSI_MULTI_LUN=y
746CONFIG_SCSI_CONSTANTS=y
747CONFIG_SCSI_LOGGING=y
748CONFIG_SCSI_SCAN_ASYNC=y
749
750#
751# SCSI Transports
752#
753CONFIG_SCSI_SPI_ATTRS=y
754CONFIG_SCSI_FC_ATTRS=y
755CONFIG_SCSI_ISCSI_ATTRS=m
756CONFIG_SCSI_SAS_ATTRS=m
757CONFIG_SCSI_SAS_LIBSAS=m
758CONFIG_SCSI_SAS_LIBSAS_DEBUG=y
759
760#
761# SCSI low-level drivers
762#
763CONFIG_ISCSI_TCP=m
764# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
765# CONFIG_SCSI_3W_9XXX is not set
766# CONFIG_SCSI_ACARD is not set
767# CONFIG_SCSI_AACRAID is not set
768# CONFIG_SCSI_AIC7XXX is not set
769# CONFIG_SCSI_AIC7XXX_OLD is not set
770# CONFIG_SCSI_AIC79XX is not set
771CONFIG_SCSI_AIC94XX=m
772# CONFIG_AIC94XX_DEBUG is not set
773# CONFIG_SCSI_DPT_I2O is not set
774# CONFIG_SCSI_ARCMSR is not set
775# CONFIG_MEGARAID_NEWGEN is not set
776# CONFIG_MEGARAID_LEGACY is not set
777# CONFIG_MEGARAID_SAS is not set
778# CONFIG_SCSI_HPTIOP is not set
779# CONFIG_SCSI_DMX3191D is not set
780# CONFIG_SCSI_FUTURE_DOMAIN is not set
781# CONFIG_SCSI_IPS is not set
782# CONFIG_SCSI_INITIO is not set
783# CONFIG_SCSI_INIA100 is not set
784# CONFIG_SCSI_STEX is not set
785CONFIG_SCSI_SYM53C8XX_2=y
786CONFIG_SCSI_SYM53C8XX_DMA_ADDRESSING_MODE=0
787CONFIG_SCSI_SYM53C8XX_DEFAULT_TAGS=16
788CONFIG_SCSI_SYM53C8XX_MAX_TAGS=64
789CONFIG_SCSI_SYM53C8XX_MMIO=y
790# CONFIG_SCSI_QLOGIC_1280 is not set
791# CONFIG_SCSI_QLA_FC is not set
792# CONFIG_SCSI_QLA_ISCSI is not set
793# CONFIG_SCSI_LPFC is not set
794# CONFIG_SCSI_DC395x is not set
795# CONFIG_SCSI_DC390T is not set
796# CONFIG_SCSI_NSP32 is not set
797# CONFIG_SCSI_DEBUG is not set
798# CONFIG_SCSI_SRP is not set
799
800#
801# Serial ATA (prod) and Parallel ATA (experimental) drivers
802#
803# CONFIG_ATA is not set
804
805#
806# Multi-device support (RAID and LVM)
807#
808CONFIG_MD=y
809CONFIG_BLK_DEV_MD=m
810CONFIG_MD_LINEAR=m
811CONFIG_MD_RAID0=m
812CONFIG_MD_RAID1=m
813CONFIG_MD_RAID10=m
814CONFIG_MD_RAID456=m
815CONFIG_MD_RAID5_RESHAPE=y
816CONFIG_MD_MULTIPATH=m
817CONFIG_MD_FAULTY=m
818CONFIG_BLK_DEV_DM=m
819# CONFIG_DM_DEBUG is not set
820CONFIG_DM_CRYPT=m
821CONFIG_DM_SNAPSHOT=m
822CONFIG_DM_MIRROR=m
823CONFIG_DM_ZERO=m
824CONFIG_DM_MULTIPATH=m
825CONFIG_DM_MULTIPATH_EMC=m
826
827#
828# Fusion MPT device support
829#
830# CONFIG_FUSION is not set
831# CONFIG_FUSION_SPI is not set
832# CONFIG_FUSION_FC is not set
833# CONFIG_FUSION_SAS is not set
834
835#
836# IEEE 1394 (FireWire) support
837#
838# CONFIG_IEEE1394 is not set
839
840#
841# I2O device support
842#
843# CONFIG_I2O is not set
844
845#
846# Network device support
847#
848CONFIG_NETDEVICES=y
849CONFIG_DUMMY=m
850CONFIG_BONDING=m
851CONFIG_EQUALIZER=m
852CONFIG_TUN=m
853
854#
855# ARCnet devices
856#
857# CONFIG_ARCNET is not set
858
859#
860# PHY device support
861#
862CONFIG_PHYLIB=m
863
864#
865# MII PHY device drivers
866#
867CONFIG_MARVELL_PHY=m
868CONFIG_DAVICOM_PHY=m
869CONFIG_QSEMI_PHY=m
870CONFIG_LXT_PHY=m
871CONFIG_CICADA_PHY=m
872CONFIG_VITESSE_PHY=m
873CONFIG_SMSC_PHY=m
874# CONFIG_BROADCOM_PHY is not set
875# CONFIG_FIXED_PHY is not set
876
877#
878# Ethernet (10 or 100Mbit)
879#
880CONFIG_NET_ETHERNET=y
881CONFIG_MII=y
882# CONFIG_HAPPYMEAL is not set
883# CONFIG_SUNGEM is not set
884# CONFIG_CASSINI is not set
885# CONFIG_NET_VENDOR_3COM is not set
886# CONFIG_DM9000 is not set
887
888#
889# Tulip family network device support
890#
891# CONFIG_NET_TULIP is not set
892# CONFIG_HP100 is not set
893CONFIG_NET_PCI=y
894CONFIG_PCNET32=y
895# CONFIG_PCNET32_NAPI is not set
896# CONFIG_AMD8111_ETH is not set
897# CONFIG_ADAPTEC_STARFIRE is not set
898# CONFIG_B44 is not set
899# CONFIG_FORCEDETH is not set
900# CONFIG_DGRS is not set
901# CONFIG_EEPRO100 is not set
902# CONFIG_E100 is not set
903# CONFIG_FEALNX is not set
904# CONFIG_NATSEMI is not set
905# CONFIG_NE2K_PCI is not set
906# CONFIG_8139CP is not set
907# CONFIG_8139TOO is not set
908# CONFIG_SIS900 is not set
909# CONFIG_EPIC100 is not set
910# CONFIG_SUNDANCE is not set
911# CONFIG_TLAN is not set
912# CONFIG_VIA_RHINE is not set
913CONFIG_LAN_SAA9730=y
914# CONFIG_SC92031 is not set
915
916#
917# Ethernet (1000 Mbit)
918#
919# CONFIG_ACENIC is not set
920# CONFIG_DL2K is not set
921# CONFIG_E1000 is not set
922# CONFIG_NS83820 is not set
923# CONFIG_HAMACHI is not set
924# CONFIG_YELLOWFIN is not set
925# CONFIG_R8169 is not set
926# CONFIG_SIS190 is not set
927# CONFIG_SKGE is not set
928# CONFIG_SKY2 is not set
929# CONFIG_SK98LIN is not set
930# CONFIG_VIA_VELOCITY is not set
931# CONFIG_TIGON3 is not set
932# CONFIG_BNX2 is not set
933CONFIG_QLA3XXX=m
934# CONFIG_ATL1 is not set
935
936#
937# Ethernet (10000 Mbit)
938#
939# CONFIG_CHELSIO_T1 is not set
940CONFIG_CHELSIO_T3=m
941# CONFIG_IXGB is not set
942# CONFIG_S2IO is not set
943# CONFIG_MYRI10GE is not set
944CONFIG_NETXEN_NIC=m
945
946#
947# Token Ring devices
948#
949# CONFIG_TR is not set
950
951#
952# Wireless LAN (non-hamradio)
953#
954# CONFIG_NET_RADIO is not set
955
956#
957# Wan interfaces
958#
959# CONFIG_WAN is not set
960# CONFIG_FDDI is not set
961# CONFIG_HIPPI is not set
962# CONFIG_PPP is not set
963# CONFIG_SLIP is not set
964# CONFIG_NET_FC is not set
965# CONFIG_SHAPER is not set
966# CONFIG_NETCONSOLE is not set
967# CONFIG_NETPOLL is not set
968# CONFIG_NET_POLL_CONTROLLER is not set
969
970#
971# ISDN subsystem
972#
973# CONFIG_ISDN is not set
974
975#
976# Telephony Support
977#
978# CONFIG_PHONE is not set
979
980#
981# Input device support
982#
983CONFIG_INPUT=y
984# CONFIG_INPUT_FF_MEMLESS is not set
985
986#
987# Userland interfaces
988#
989CONFIG_INPUT_MOUSEDEV=m
990CONFIG_INPUT_MOUSEDEV_PSAUX=y
991CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
992CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
993# CONFIG_INPUT_JOYDEV is not set
994# CONFIG_INPUT_TSDEV is not set
995# CONFIG_INPUT_EVDEV is not set
996# CONFIG_INPUT_EVBUG is not set
997
998#
999# Input Device Drivers
1000#
1001# CONFIG_INPUT_KEYBOARD is not set
1002CONFIG_INPUT_MOUSE=y
1003# CONFIG_MOUSE_PS2 is not set
1004CONFIG_MOUSE_SERIAL=m
1005# CONFIG_MOUSE_VSXXXAA is not set
1006# CONFIG_INPUT_JOYSTICK is not set
1007# CONFIG_INPUT_TOUCHSCREEN is not set
1008# CONFIG_INPUT_MISC is not set
1009
1010#
1011# Hardware I/O ports
1012#
1013CONFIG_SERIO=y
1014# CONFIG_SERIO_I8042 is not set
1015CONFIG_SERIO_SERPORT=y
1016# CONFIG_SERIO_PCIPS2 is not set
1017CONFIG_SERIO_LIBPS2=y
1018CONFIG_SERIO_RAW=y
1019# CONFIG_GAMEPORT is not set
1020
1021#
1022# Character devices
1023#
1024CONFIG_VT=y
1025CONFIG_VT_CONSOLE=y
1026CONFIG_HW_CONSOLE=y
1027CONFIG_VT_HW_CONSOLE_BINDING=y
1028# CONFIG_SERIAL_NONSTANDARD is not set
1029
1030#
1031# Serial drivers
1032#
1033CONFIG_SERIAL_8250=y
1034CONFIG_SERIAL_8250_CONSOLE=y
1035CONFIG_SERIAL_8250_PCI=m
1036CONFIG_SERIAL_8250_NR_UARTS=4
1037CONFIG_SERIAL_8250_RUNTIME_UARTS=4
1038# CONFIG_SERIAL_8250_EXTENDED is not set
1039
1040#
1041# Non-8250 serial port support
1042#
1043CONFIG_SERIAL_CORE=y
1044CONFIG_SERIAL_CORE_CONSOLE=y
1045# CONFIG_SERIAL_JSM is not set
1046CONFIG_UNIX98_PTYS=y
1047CONFIG_LEGACY_PTYS=y
1048CONFIG_LEGACY_PTY_COUNT=256
1049
1050#
1051# IPMI
1052#
1053# CONFIG_IPMI_HANDLER is not set
1054
1055#
1056# Watchdog Cards
1057#
1058# CONFIG_WATCHDOG is not set
1059# CONFIG_HW_RANDOM is not set
1060# CONFIG_RTC is not set
1061# CONFIG_GEN_RTC is not set
1062# CONFIG_DTLK is not set
1063# CONFIG_R3964 is not set
1064# CONFIG_APPLICOM is not set
1065# CONFIG_DRM is not set
1066# CONFIG_RAW_DRIVER is not set
1067
1068#
1069# TPM devices
1070#
1071# CONFIG_TCG_TPM is not set
1072
1073#
1074# I2C support
1075#
1076# CONFIG_I2C is not set
1077
1078#
1079# SPI support
1080#
1081# CONFIG_SPI is not set
1082# CONFIG_SPI_MASTER is not set
1083
1084#
1085# Dallas's 1-wire bus
1086#
1087# CONFIG_W1 is not set
1088
1089#
1090# Hardware Monitoring support
1091#
1092# CONFIG_HWMON is not set
1093# CONFIG_HWMON_VID is not set
1094
1095#
1096# Multimedia devices
1097#
1098# CONFIG_VIDEO_DEV is not set
1099
1100#
1101# Digital Video Broadcasting Devices
1102#
1103# CONFIG_DVB is not set
1104
1105#
1106# Graphics support
1107#
1108# CONFIG_FIRMWARE_EDID is not set
1109# CONFIG_FB is not set
1110
1111#
1112# Console display driver support
1113#
1114# CONFIG_VGA_CONSOLE is not set
1115CONFIG_DUMMY_CONSOLE=y
1116# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1117
1118#
1119# Sound
1120#
1121# CONFIG_SOUND is not set
1122
1123#
1124# HID Devices
1125#
1126CONFIG_HID=y
1127# CONFIG_HID_DEBUG is not set
1128
1129#
1130# USB support
1131#
1132CONFIG_USB_ARCH_HAS_HCD=y
1133CONFIG_USB_ARCH_HAS_OHCI=y
1134CONFIG_USB_ARCH_HAS_EHCI=y
1135# CONFIG_USB is not set
1136
1137#
1138# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1139#
1140
1141#
1142# USB Gadget Support
1143#
1144# CONFIG_USB_GADGET is not set
1145
1146#
1147# MMC/SD Card support
1148#
1149# CONFIG_MMC is not set
1150
1151#
1152# LED devices
1153#
1154# CONFIG_NEW_LEDS is not set
1155
1156#
1157# LED drivers
1158#
1159
1160#
1161# LED Triggers
1162#
1163
1164#
1165# InfiniBand support
1166#
1167# CONFIG_INFINIBAND is not set
1168
1169#
1170# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1171#
1172
1173#
1174# Real Time Clock
1175#
1176# CONFIG_RTC_CLASS is not set
1177
1178#
1179# DMA Engine support
1180#
1181# CONFIG_DMA_ENGINE is not set
1182
1183#
1184# DMA Clients
1185#
1186
1187#
1188# DMA Devices
1189#
1190
1191#
1192# Auxiliary Display support
1193#
1194
1195#
1196# Virtualization
1197#
1198
1199#
1200# File systems
1201#
1202CONFIG_EXT2_FS=y
1203# CONFIG_EXT2_FS_XATTR is not set
1204# CONFIG_EXT2_FS_XIP is not set
1205CONFIG_EXT3_FS=y
1206CONFIG_EXT3_FS_XATTR=y
1207# CONFIG_EXT3_FS_POSIX_ACL is not set
1208# CONFIG_EXT3_FS_SECURITY is not set
1209# CONFIG_EXT4DEV_FS is not set
1210CONFIG_JBD=y
1211# CONFIG_JBD_DEBUG is not set
1212CONFIG_FS_MBCACHE=y
1213CONFIG_REISERFS_FS=m
1214# CONFIG_REISERFS_CHECK is not set
1215CONFIG_REISERFS_PROC_INFO=y
1216CONFIG_REISERFS_FS_XATTR=y
1217CONFIG_REISERFS_FS_POSIX_ACL=y
1218CONFIG_REISERFS_FS_SECURITY=y
1219CONFIG_JFS_FS=m
1220CONFIG_JFS_POSIX_ACL=y
1221CONFIG_JFS_SECURITY=y
1222# CONFIG_JFS_DEBUG is not set
1223# CONFIG_JFS_STATISTICS is not set
1224CONFIG_FS_POSIX_ACL=y
1225CONFIG_XFS_FS=m
1226CONFIG_XFS_QUOTA=y
1227CONFIG_XFS_SECURITY=y
1228CONFIG_XFS_POSIX_ACL=y
1229# CONFIG_XFS_RT is not set
1230# CONFIG_GFS2_FS is not set
1231# CONFIG_OCFS2_FS is not set
1232CONFIG_MINIX_FS=m
1233CONFIG_ROMFS_FS=m
1234CONFIG_INOTIFY=y
1235CONFIG_INOTIFY_USER=y
1236CONFIG_QUOTA=y
1237# CONFIG_QFMT_V1 is not set
1238CONFIG_QFMT_V2=y
1239CONFIG_QUOTACTL=y
1240CONFIG_DNOTIFY=y
1241CONFIG_AUTOFS_FS=y
1242# CONFIG_AUTOFS4_FS is not set
1243CONFIG_FUSE_FS=m
1244CONFIG_GENERIC_ACL=y
1245
1246#
1247# CD-ROM/DVD Filesystems
1248#
1249CONFIG_ISO9660_FS=m
1250CONFIG_JOLIET=y
1251CONFIG_ZISOFS=y
1252CONFIG_UDF_FS=m
1253CONFIG_UDF_NLS=y
1254
1255#
1256# DOS/FAT/NT Filesystems
1257#
1258CONFIG_FAT_FS=m
1259CONFIG_MSDOS_FS=m
1260CONFIG_VFAT_FS=m
1261CONFIG_FAT_DEFAULT_CODEPAGE=437
1262CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1263# CONFIG_NTFS_FS is not set
1264
1265#
1266# Pseudo filesystems
1267#
1268CONFIG_PROC_FS=y
1269CONFIG_PROC_KCORE=y
1270CONFIG_PROC_SYSCTL=y
1271CONFIG_SYSFS=y
1272CONFIG_TMPFS=y
1273CONFIG_TMPFS_POSIX_ACL=y
1274# CONFIG_HUGETLB_PAGE is not set
1275CONFIG_RAMFS=y
1276CONFIG_CONFIGFS_FS=m
1277
1278#
1279# Miscellaneous filesystems
1280#
1281# CONFIG_ADFS_FS is not set
1282CONFIG_AFFS_FS=m
1283CONFIG_HFS_FS=m
1284CONFIG_HFSPLUS_FS=m
1285CONFIG_BEFS_FS=m
1286# CONFIG_BEFS_DEBUG is not set
1287CONFIG_BFS_FS=m
1288CONFIG_EFS_FS=m
1289CONFIG_CRAMFS=m
1290CONFIG_VXFS_FS=m
1291# CONFIG_HPFS_FS is not set
1292# CONFIG_QNX4FS_FS is not set
1293CONFIG_SYSV_FS=m
1294CONFIG_UFS_FS=m
1295# CONFIG_UFS_FS_WRITE is not set
1296# CONFIG_UFS_DEBUG is not set
1297
1298#
1299# Network File Systems
1300#
1301CONFIG_NFS_FS=y
1302CONFIG_NFS_V3=y
1303# CONFIG_NFS_V3_ACL is not set
1304# CONFIG_NFS_V4 is not set
1305# CONFIG_NFS_DIRECTIO is not set
1306CONFIG_NFSD=y
1307CONFIG_NFSD_V3=y
1308# CONFIG_NFSD_V3_ACL is not set
1309# CONFIG_NFSD_V4 is not set
1310# CONFIG_NFSD_TCP is not set
1311CONFIG_ROOT_NFS=y
1312CONFIG_LOCKD=y
1313CONFIG_LOCKD_V4=y
1314CONFIG_EXPORTFS=y
1315CONFIG_NFS_COMMON=y
1316CONFIG_SUNRPC=y
1317# CONFIG_RPCSEC_GSS_KRB5 is not set
1318# CONFIG_RPCSEC_GSS_SPKM3 is not set
1319# CONFIG_SMB_FS is not set
1320# CONFIG_CIFS is not set
1321# CONFIG_NCP_FS is not set
1322# CONFIG_CODA_FS is not set
1323# CONFIG_AFS_FS is not set
1324# CONFIG_9P_FS is not set
1325
1326#
1327# Partition Types
1328#
1329# CONFIG_PARTITION_ADVANCED is not set
1330CONFIG_MSDOS_PARTITION=y
1331
1332#
1333# Native Language Support
1334#
1335CONFIG_NLS=m
1336CONFIG_NLS_DEFAULT="iso8859-1"
1337CONFIG_NLS_CODEPAGE_437=m
1338CONFIG_NLS_CODEPAGE_737=m
1339CONFIG_NLS_CODEPAGE_775=m
1340CONFIG_NLS_CODEPAGE_850=m
1341CONFIG_NLS_CODEPAGE_852=m
1342CONFIG_NLS_CODEPAGE_855=m
1343CONFIG_NLS_CODEPAGE_857=m
1344CONFIG_NLS_CODEPAGE_860=m
1345CONFIG_NLS_CODEPAGE_861=m
1346CONFIG_NLS_CODEPAGE_862=m
1347CONFIG_NLS_CODEPAGE_863=m
1348CONFIG_NLS_CODEPAGE_864=m
1349CONFIG_NLS_CODEPAGE_865=m
1350CONFIG_NLS_CODEPAGE_866=m
1351CONFIG_NLS_CODEPAGE_869=m
1352CONFIG_NLS_CODEPAGE_936=m
1353CONFIG_NLS_CODEPAGE_950=m
1354CONFIG_NLS_CODEPAGE_932=m
1355CONFIG_NLS_CODEPAGE_949=m
1356CONFIG_NLS_CODEPAGE_874=m
1357CONFIG_NLS_ISO8859_8=m
1358CONFIG_NLS_CODEPAGE_1250=m
1359CONFIG_NLS_CODEPAGE_1251=m
1360CONFIG_NLS_ASCII=m
1361CONFIG_NLS_ISO8859_1=m
1362CONFIG_NLS_ISO8859_2=m
1363CONFIG_NLS_ISO8859_3=m
1364CONFIG_NLS_ISO8859_4=m
1365CONFIG_NLS_ISO8859_5=m
1366CONFIG_NLS_ISO8859_6=m
1367CONFIG_NLS_ISO8859_7=m
1368CONFIG_NLS_ISO8859_9=m
1369CONFIG_NLS_ISO8859_13=m
1370CONFIG_NLS_ISO8859_14=m
1371CONFIG_NLS_ISO8859_15=m
1372CONFIG_NLS_KOI8_R=m
1373CONFIG_NLS_KOI8_U=m
1374CONFIG_NLS_UTF8=m
1375
1376#
1377# Distributed Lock Manager
1378#
1379CONFIG_DLM=m
1380CONFIG_DLM_TCP=y
1381# CONFIG_DLM_SCTP is not set
1382# CONFIG_DLM_DEBUG is not set
1383
1384#
1385# Profiling support
1386#
1387# CONFIG_PROFILING is not set
1388
1389#
1390# Kernel hacking
1391#
1392CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1393# CONFIG_PRINTK_TIME is not set
1394CONFIG_ENABLE_MUST_CHECK=y
1395# CONFIG_MAGIC_SYSRQ is not set
1396# CONFIG_UNUSED_SYMBOLS is not set
1397# CONFIG_DEBUG_FS is not set
1398# CONFIG_HEADERS_CHECK is not set
1399# CONFIG_DEBUG_KERNEL is not set
1400CONFIG_LOG_BUF_SHIFT=14
1401CONFIG_CROSSCOMPILE=y
1402CONFIG_CMDLINE=""
1403
1404#
1405# Security options
1406#
1407# CONFIG_KEYS is not set
1408# CONFIG_SECURITY is not set
1409
1410#
1411# Cryptographic options
1412#
1413CONFIG_CRYPTO=y
1414CONFIG_CRYPTO_ALGAPI=y
1415CONFIG_CRYPTO_BLKCIPHER=m
1416CONFIG_CRYPTO_HASH=y
1417CONFIG_CRYPTO_MANAGER=y
1418CONFIG_CRYPTO_HMAC=y
1419CONFIG_CRYPTO_XCBC=m
1420CONFIG_CRYPTO_NULL=m
1421CONFIG_CRYPTO_MD4=m
1422CONFIG_CRYPTO_MD5=y
1423CONFIG_CRYPTO_SHA1=m
1424CONFIG_CRYPTO_SHA256=m
1425CONFIG_CRYPTO_SHA512=m
1426CONFIG_CRYPTO_WP512=m
1427CONFIG_CRYPTO_TGR192=m
1428CONFIG_CRYPTO_GF128MUL=m
1429CONFIG_CRYPTO_ECB=m
1430CONFIG_CRYPTO_CBC=m
1431CONFIG_CRYPTO_PCBC=m
1432CONFIG_CRYPTO_LRW=m
1433CONFIG_CRYPTO_DES=m
1434CONFIG_CRYPTO_FCRYPT=m
1435CONFIG_CRYPTO_BLOWFISH=m
1436CONFIG_CRYPTO_TWOFISH=m
1437CONFIG_CRYPTO_TWOFISH_COMMON=m
1438CONFIG_CRYPTO_SERPENT=m
1439CONFIG_CRYPTO_AES=m
1440CONFIG_CRYPTO_CAST5=m
1441CONFIG_CRYPTO_CAST6=m
1442CONFIG_CRYPTO_TEA=m
1443CONFIG_CRYPTO_ARC4=m
1444CONFIG_CRYPTO_KHAZAD=m
1445CONFIG_CRYPTO_ANUBIS=m
1446CONFIG_CRYPTO_DEFLATE=m
1447CONFIG_CRYPTO_MICHAEL_MIC=m
1448CONFIG_CRYPTO_CRC32C=m
1449CONFIG_CRYPTO_CAMELLIA=m
1450# CONFIG_CRYPTO_TEST is not set
1451
1452#
1453# Hardware crypto devices
1454#
1455
1456#
1457# Library routines
1458#
1459CONFIG_BITREVERSE=y
1460# CONFIG_CRC_CCITT is not set
1461CONFIG_CRC16=m
1462CONFIG_CRC32=y
1463CONFIG_LIBCRC32C=m
1464CONFIG_ZLIB_INFLATE=m
1465CONFIG_ZLIB_DEFLATE=m
1466CONFIG_TEXTSEARCH=y
1467CONFIG_TEXTSEARCH_KMP=m
1468CONFIG_TEXTSEARCH_BM=m
1469CONFIG_TEXTSEARCH_FSM=m
1470CONFIG_PLIST=y
1471CONFIG_HAS_IOMEM=y
1472CONFIG_HAS_IOPORT=y
diff --git a/arch/mips/configs/bcm47xx_defconfig b/arch/mips/configs/bcm47xx_defconfig
index c0e42e74dfb..d8694332b34 100644
--- a/arch/mips/configs/bcm47xx_defconfig
+++ b/arch/mips/configs/bcm47xx_defconfig
@@ -16,9 +16,7 @@ CONFIG_BCM47XX=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index 3b42cea2e40..a3bbbf067a3 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_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.25-rc7 3# Linux kernel version: 2.6.26-rc8
4# Mon Mar 31 08:11:19 2008 4# Wed Jul 2 17:02:55 2008
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
@@ -148,6 +146,7 @@ CONFIG_FLATMEM=y
148CONFIG_FLAT_NODE_MEM_MAP=y 146CONFIG_FLAT_NODE_MEM_MAP=y
149# CONFIG_SPARSEMEM_STATIC is not set 147# CONFIG_SPARSEMEM_STATIC is not set
150# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set 148# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
149CONFIG_PAGEFLAGS_EXTENDED=y
151CONFIG_SPLIT_PTLOCK_CPUS=4 150CONFIG_SPLIT_PTLOCK_CPUS=4
152CONFIG_RESOURCES_64BIT=y 151CONFIG_RESOURCES_64BIT=y
153CONFIG_ZONE_DMA_FLAG=0 152CONFIG_ZONE_DMA_FLAG=0
@@ -156,6 +155,7 @@ CONFIG_SMP=y
156CONFIG_SYS_SUPPORTS_SMP=y 155CONFIG_SYS_SUPPORTS_SMP=y
157CONFIG_NR_CPUS_DEFAULT_4=y 156CONFIG_NR_CPUS_DEFAULT_4=y
158CONFIG_NR_CPUS=4 157CONFIG_NR_CPUS=4
158# CONFIG_MIPS_CMP is not set
159CONFIG_TICK_ONESHOT=y 159CONFIG_TICK_ONESHOT=y
160CONFIG_NO_HZ=y 160CONFIG_NO_HZ=y
161CONFIG_HIGH_RES_TIMERS=y 161CONFIG_HIGH_RES_TIMERS=y
@@ -223,6 +223,7 @@ CONFIG_HOTPLUG=y
223CONFIG_PRINTK=y 223CONFIG_PRINTK=y
224CONFIG_BUG=y 224CONFIG_BUG=y
225CONFIG_ELF_CORE=y 225CONFIG_ELF_CORE=y
226# CONFIG_PCSPKR_PLATFORM is not set
226CONFIG_COMPAT_BRK=y 227CONFIG_COMPAT_BRK=y
227CONFIG_BASE_FULL=y 228CONFIG_BASE_FULL=y
228CONFIG_FUTEX=y 229CONFIG_FUTEX=y
@@ -241,12 +242,14 @@ CONFIG_SLAB=y
241CONFIG_HAVE_OPROFILE=y 242CONFIG_HAVE_OPROFILE=y
242# CONFIG_HAVE_KPROBES is not set 243# CONFIG_HAVE_KPROBES is not set
243# CONFIG_HAVE_KRETPROBES is not set 244# CONFIG_HAVE_KRETPROBES is not set
245# CONFIG_HAVE_DMA_ATTRS is not set
244CONFIG_PROC_PAGE_MONITOR=y 246CONFIG_PROC_PAGE_MONITOR=y
245CONFIG_SLABINFO=y 247CONFIG_SLABINFO=y
246CONFIG_RT_MUTEXES=y 248CONFIG_RT_MUTEXES=y
247# CONFIG_TINY_SHMEM is not set 249# CONFIG_TINY_SHMEM is not set
248CONFIG_BASE_SMALL=0 250CONFIG_BASE_SMALL=0
249CONFIG_MODULES=y 251CONFIG_MODULES=y
252# CONFIG_MODULE_FORCE_LOAD is not set
250CONFIG_MODULE_UNLOAD=y 253CONFIG_MODULE_UNLOAD=y
251# CONFIG_MODULE_FORCE_UNLOAD is not set 254# CONFIG_MODULE_FORCE_UNLOAD is not set
252CONFIG_MODVERSIONS=y 255CONFIG_MODVERSIONS=y
@@ -302,7 +305,6 @@ CONFIG_BINFMT_ELF32=y
302# Power management options 305# Power management options
303# 306#
304CONFIG_PM=y 307CONFIG_PM=y
305# CONFIG_PM_LEGACY is not set
306# CONFIG_PM_DEBUG is not set 308# CONFIG_PM_DEBUG is not set
307 309
308# 310#
@@ -399,9 +401,11 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=m
399CONFIG_INET6_XFRM_MODE_BEET=m 401CONFIG_INET6_XFRM_MODE_BEET=m
400CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m 402CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
401CONFIG_IPV6_SIT=m 403CONFIG_IPV6_SIT=m
404CONFIG_IPV6_NDISC_NODETYPE=y
402CONFIG_IPV6_TUNNEL=m 405CONFIG_IPV6_TUNNEL=m
403CONFIG_IPV6_MULTIPLE_TABLES=y 406CONFIG_IPV6_MULTIPLE_TABLES=y
404CONFIG_IPV6_SUBTREES=y 407CONFIG_IPV6_SUBTREES=y
408# CONFIG_IPV6_MROUTE is not set
405CONFIG_NETWORK_SECMARK=y 409CONFIG_NETWORK_SECMARK=y
406CONFIG_NETFILTER=y 410CONFIG_NETFILTER=y
407# CONFIG_NETFILTER_DEBUG is not set 411# CONFIG_NETFILTER_DEBUG is not set
@@ -600,7 +604,7 @@ CONFIG_BLK_DEV_IT8213=m
600CONFIG_BLK_DEV_TC86C001=m 604CONFIG_BLK_DEV_TC86C001=m
601# CONFIG_BLK_DEV_IDE_SWARM is not set 605# CONFIG_BLK_DEV_IDE_SWARM is not set
602CONFIG_BLK_DEV_IDEDMA=y 606CONFIG_BLK_DEV_IDEDMA=y
603CONFIG_IDE_ARCH_OBSOLETE_INIT=y 607# CONFIG_BLK_DEV_HD_ONLY is not set
604# CONFIG_BLK_DEV_HD is not set 608# CONFIG_BLK_DEV_HD is not set
605 609
606# 610#
@@ -617,11 +621,12 @@ CONFIG_SCSI_PROC_FS=y
617# SCSI support type (disk, tape, CD-ROM) 621# SCSI support type (disk, tape, CD-ROM)
618# 622#
619CONFIG_BLK_DEV_SD=y 623CONFIG_BLK_DEV_SD=y
620# CONFIG_CHR_DEV_ST is not set 624CONFIG_CHR_DEV_ST=m
621# CONFIG_CHR_DEV_OSST is not set 625# CONFIG_CHR_DEV_OSST is not set
622# CONFIG_BLK_DEV_SR is not set 626CONFIG_BLK_DEV_SR=m
623# CONFIG_CHR_DEV_SG is not set 627CONFIG_BLK_DEV_SR_VENDOR=y
624# CONFIG_CHR_DEV_SCH is not set 628CONFIG_CHR_DEV_SG=m
629CONFIG_CHR_DEV_SCH=m
625 630
626# 631#
627# Some SCSI devices (e.g. CD jukebox) support multiple LUNs 632# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
@@ -650,6 +655,7 @@ CONFIG_SCSI_LOWLEVEL=y
650# CONFIG_SCSI_AIC7XXX_OLD is not set 655# CONFIG_SCSI_AIC7XXX_OLD is not set
651# CONFIG_SCSI_AIC79XX is not set 656# CONFIG_SCSI_AIC79XX is not set
652# CONFIG_SCSI_AIC94XX is not set 657# CONFIG_SCSI_AIC94XX is not set
658# CONFIG_SCSI_DPT_I2O is not set
653# CONFIG_SCSI_ADVANSYS is not set 659# CONFIG_SCSI_ADVANSYS is not set
654# CONFIG_SCSI_ARCMSR is not set 660# CONFIG_SCSI_ARCMSR is not set
655# CONFIG_MEGARAID_NEWGEN is not set 661# CONFIG_MEGARAID_NEWGEN is not set
@@ -675,7 +681,10 @@ CONFIG_SCSI_LOWLEVEL=y
675# CONFIG_SCSI_SRP is not set 681# CONFIG_SCSI_SRP is not set
676CONFIG_ATA=y 682CONFIG_ATA=y
677# CONFIG_ATA_NONSTANDARD is not set 683# CONFIG_ATA_NONSTANDARD is not set
684CONFIG_SATA_PMP=y
678# CONFIG_SATA_AHCI is not set 685# CONFIG_SATA_AHCI is not set
686CONFIG_SATA_SIL24=y
687CONFIG_ATA_SFF=y
679# CONFIG_SATA_SVW is not set 688# CONFIG_SATA_SVW is not set
680# CONFIG_ATA_PIIX is not set 689# CONFIG_ATA_PIIX is not set
681# CONFIG_SATA_MV is not set 690# CONFIG_SATA_MV is not set
@@ -685,7 +694,6 @@ CONFIG_ATA=y
685# CONFIG_SATA_PROMISE is not set 694# CONFIG_SATA_PROMISE is not set
686# CONFIG_SATA_SX4 is not set 695# CONFIG_SATA_SX4 is not set
687# CONFIG_SATA_SIL is not set 696# CONFIG_SATA_SIL is not set
688CONFIG_SATA_SIL24=y
689# CONFIG_SATA_SIS is not set 697# CONFIG_SATA_SIS is not set
690# CONFIG_SATA_ULI is not set 698# CONFIG_SATA_ULI is not set
691# CONFIG_SATA_VIA is not set 699# CONFIG_SATA_VIA is not set
@@ -730,12 +738,17 @@ CONFIG_PATA_SIL680=y
730# CONFIG_PATA_VIA is not set 738# CONFIG_PATA_VIA is not set
731# CONFIG_PATA_WINBOND is not set 739# CONFIG_PATA_WINBOND is not set
732# CONFIG_PATA_PLATFORM is not set 740# CONFIG_PATA_PLATFORM is not set
741# CONFIG_PATA_SCH is not set
733# CONFIG_MD is not set 742# CONFIG_MD is not set
734# CONFIG_FUSION is not set 743# CONFIG_FUSION is not set
735 744
736# 745#
737# IEEE 1394 (FireWire) support 746# IEEE 1394 (FireWire) support
738# 747#
748
749#
750# Enable only one of the two stacks, unless you know what you are doing
751#
739# CONFIG_FIREWIRE is not set 752# CONFIG_FIREWIRE is not set
740# CONFIG_IEEE1394 is not set 753# CONFIG_IEEE1394 is not set
741# CONFIG_I2O is not set 754# CONFIG_I2O is not set
@@ -797,7 +810,6 @@ CONFIG_SB1250_MAC=y
797# CONFIG_SIS190 is not set 810# CONFIG_SIS190 is not set
798# CONFIG_SKGE is not set 811# CONFIG_SKGE is not set
799# CONFIG_SKY2 is not set 812# CONFIG_SKY2 is not set
800# CONFIG_SK98LIN is not set
801# CONFIG_VIA_VELOCITY is not set 813# CONFIG_VIA_VELOCITY is not set
802# CONFIG_TIGON3 is not set 814# CONFIG_TIGON3 is not set
803# CONFIG_BNX2 is not set 815# CONFIG_BNX2 is not set
@@ -815,6 +827,7 @@ CONFIG_NETXEN_NIC=m
815# CONFIG_MLX4_CORE is not set 827# CONFIG_MLX4_CORE is not set
816# CONFIG_TEHUTI is not set 828# CONFIG_TEHUTI is not set
817# CONFIG_BNX2X is not set 829# CONFIG_BNX2X is not set
830# CONFIG_SFC is not set
818# CONFIG_TR is not set 831# CONFIG_TR is not set
819 832
820# 833#
@@ -822,6 +835,7 @@ CONFIG_NETXEN_NIC=m
822# 835#
823# CONFIG_WLAN_PRE80211 is not set 836# CONFIG_WLAN_PRE80211 is not set
824# CONFIG_WLAN_80211 is not set 837# CONFIG_WLAN_80211 is not set
838# CONFIG_IWLWIFI_LEDS is not set
825# CONFIG_WAN is not set 839# CONFIG_WAN is not set
826# CONFIG_FDDI is not set 840# CONFIG_FDDI is not set
827# CONFIG_HIPPI is not set 841# CONFIG_HIPPI is not set
@@ -867,6 +881,7 @@ CONFIG_SERIO_RAW=m
867# Character devices 881# Character devices
868# 882#
869# CONFIG_VT is not set 883# CONFIG_VT is not set
884CONFIG_DEVKMEM=y
870CONFIG_SERIAL_NONSTANDARD=y 885CONFIG_SERIAL_NONSTANDARD=y
871# CONFIG_COMPUTONE is not set 886# CONFIG_COMPUTONE is not set
872# CONFIG_ROCKETPORT is not set 887# CONFIG_ROCKETPORT is not set
@@ -903,7 +918,6 @@ CONFIG_LEGACY_PTYS=y
903CONFIG_LEGACY_PTY_COUNT=256 918CONFIG_LEGACY_PTY_COUNT=256
904# CONFIG_IPMI_HANDLER is not set 919# CONFIG_IPMI_HANDLER is not set
905# CONFIG_HW_RANDOM is not set 920# CONFIG_HW_RANDOM is not set
906# CONFIG_RTC is not set
907# CONFIG_R3964 is not set 921# CONFIG_R3964 is not set
908# CONFIG_APPLICOM is not set 922# CONFIG_APPLICOM is not set
909# CONFIG_RAW_DRIVER is not set 923# CONFIG_RAW_DRIVER is not set
@@ -914,13 +928,6 @@ CONFIG_I2C_BOARDINFO=y
914CONFIG_I2C_CHARDEV=y 928CONFIG_I2C_CHARDEV=y
915 929
916# 930#
917# I2C Algorithms
918#
919# CONFIG_I2C_ALGOBIT is not set
920# CONFIG_I2C_ALGOPCF is not set
921# CONFIG_I2C_ALGOPCA is not set
922
923#
924# I2C Hardware Bus support 931# I2C Hardware Bus support
925# 932#
926# CONFIG_I2C_ALI1535 is not set 933# CONFIG_I2C_ALI1535 is not set
@@ -946,6 +953,7 @@ CONFIG_I2C_SIBYTE=y
946# CONFIG_I2C_VIA is not set 953# CONFIG_I2C_VIA is not set
947# CONFIG_I2C_VIAPRO is not set 954# CONFIG_I2C_VIAPRO is not set
948# CONFIG_I2C_VOODOO3 is not set 955# CONFIG_I2C_VOODOO3 is not set
956# CONFIG_I2C_PCA_PLATFORM is not set
949 957
950# 958#
951# Miscellaneous I2C Chip support 959# Miscellaneous I2C Chip support
@@ -955,23 +963,18 @@ CONFIG_SENSORS_EEPROM=y
955CONFIG_SENSORS_PCF8574=y 963CONFIG_SENSORS_PCF8574=y
956# CONFIG_PCF8575 is not set 964# CONFIG_PCF8575 is not set
957CONFIG_SENSORS_PCF8591=y 965CONFIG_SENSORS_PCF8591=y
958# CONFIG_TPS65010 is not set
959CONFIG_SENSORS_MAX6875=y 966CONFIG_SENSORS_MAX6875=y
960# CONFIG_SENSORS_TSL2550 is not set 967# CONFIG_SENSORS_TSL2550 is not set
961CONFIG_I2C_DEBUG_CORE=y 968CONFIG_I2C_DEBUG_CORE=y
962CONFIG_I2C_DEBUG_ALGO=y 969CONFIG_I2C_DEBUG_ALGO=y
963CONFIG_I2C_DEBUG_BUS=y 970CONFIG_I2C_DEBUG_BUS=y
964CONFIG_I2C_DEBUG_CHIP=y 971CONFIG_I2C_DEBUG_CHIP=y
965
966#
967# SPI support
968#
969# CONFIG_SPI is not set 972# CONFIG_SPI is not set
970# CONFIG_SPI_MASTER is not set
971# CONFIG_W1 is not set 973# CONFIG_W1 is not set
972# CONFIG_POWER_SUPPLY is not set 974# CONFIG_POWER_SUPPLY is not set
973# CONFIG_HWMON is not set 975# CONFIG_HWMON is not set
974# CONFIG_THERMAL is not set 976# CONFIG_THERMAL is not set
977# CONFIG_THERMAL_HWMON is not set
975# CONFIG_WATCHDOG is not set 978# CONFIG_WATCHDOG is not set
976 979
977# 980#
@@ -984,12 +987,22 @@ CONFIG_SSB_POSSIBLE=y
984# Multifunction device drivers 987# Multifunction device drivers
985# 988#
986# CONFIG_MFD_SM501 is not set 989# CONFIG_MFD_SM501 is not set
990# CONFIG_HTC_PASIC3 is not set
987 991
988# 992#
989# Multimedia devices 993# Multimedia devices
990# 994#
995
996#
997# Multimedia core support
998#
991# CONFIG_VIDEO_DEV is not set 999# CONFIG_VIDEO_DEV is not set
992# CONFIG_DVB_CORE is not set 1000# CONFIG_DVB_CORE is not set
1001# CONFIG_VIDEO_MEDIA is not set
1002
1003#
1004# Multimedia drivers
1005#
993# CONFIG_DAB is not set 1006# CONFIG_DAB is not set
994 1007
995# 1008#
@@ -1015,6 +1028,8 @@ CONFIG_USB_ARCH_HAS_HCD=y
1015CONFIG_USB_ARCH_HAS_OHCI=y 1028CONFIG_USB_ARCH_HAS_OHCI=y
1016CONFIG_USB_ARCH_HAS_EHCI=y 1029CONFIG_USB_ARCH_HAS_EHCI=y
1017# CONFIG_USB is not set 1030# CONFIG_USB is not set
1031# CONFIG_USB_OTG_WHITELIST is not set
1032# CONFIG_USB_OTG_BLACKLIST_HUB is not set
1018 1033
1019# 1034#
1020# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1035# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -1023,13 +1038,10 @@ CONFIG_USB_ARCH_HAS_EHCI=y
1023# CONFIG_MMC is not set 1038# CONFIG_MMC is not set
1024# CONFIG_MEMSTICK is not set 1039# CONFIG_MEMSTICK is not set
1025# CONFIG_NEW_LEDS is not set 1040# CONFIG_NEW_LEDS is not set
1041# CONFIG_ACCESSIBILITY is not set
1026# CONFIG_INFINIBAND is not set 1042# CONFIG_INFINIBAND is not set
1027CONFIG_RTC_LIB=y 1043CONFIG_RTC_LIB=y
1028# CONFIG_RTC_CLASS is not set 1044# CONFIG_RTC_CLASS is not set
1029
1030#
1031# Userspace I/O
1032#
1033# CONFIG_UIO is not set 1045# CONFIG_UIO is not set
1034 1046
1035# 1047#
@@ -1123,7 +1135,6 @@ CONFIG_NFS_FS=y
1123CONFIG_NFS_V3=y 1135CONFIG_NFS_V3=y
1124# CONFIG_NFS_V3_ACL is not set 1136# CONFIG_NFS_V3_ACL is not set
1125# CONFIG_NFS_V4 is not set 1137# CONFIG_NFS_V4 is not set
1126# CONFIG_NFS_DIRECTIO is not set
1127# CONFIG_NFSD is not set 1138# CONFIG_NFSD is not set
1128CONFIG_ROOT_NFS=y 1139CONFIG_ROOT_NFS=y
1129CONFIG_LOCKD=y 1140CONFIG_LOCKD=y
@@ -1194,6 +1205,7 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1194# CONFIG_PRINTK_TIME is not set 1205# CONFIG_PRINTK_TIME is not set
1195CONFIG_ENABLE_WARN_DEPRECATED=y 1206CONFIG_ENABLE_WARN_DEPRECATED=y
1196CONFIG_ENABLE_MUST_CHECK=y 1207CONFIG_ENABLE_MUST_CHECK=y
1208CONFIG_FRAME_WARN=2048
1197CONFIG_MAGIC_SYSRQ=y 1209CONFIG_MAGIC_SYSRQ=y
1198# CONFIG_UNUSED_SYMBOLS is not set 1210# CONFIG_UNUSED_SYMBOLS is not set
1199# CONFIG_DEBUG_FS is not set 1211# CONFIG_DEBUG_FS is not set
@@ -1204,6 +1216,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
1204CONFIG_SCHED_DEBUG=y 1216CONFIG_SCHED_DEBUG=y
1205# CONFIG_SCHEDSTATS is not set 1217# CONFIG_SCHEDSTATS is not set
1206# CONFIG_TIMER_STATS is not set 1218# CONFIG_TIMER_STATS is not set
1219# CONFIG_DEBUG_OBJECTS is not set
1207# CONFIG_DEBUG_SLAB is not set 1220# CONFIG_DEBUG_SLAB is not set
1208# CONFIG_DEBUG_RT_MUTEXES is not set 1221# CONFIG_DEBUG_RT_MUTEXES is not set
1209# CONFIG_RT_MUTEX_TESTER is not set 1222# CONFIG_RT_MUTEX_TESTER is not set
@@ -1217,6 +1230,7 @@ CONFIG_DEBUG_MUTEXES=y
1217# CONFIG_DEBUG_KOBJECT is not set 1230# CONFIG_DEBUG_KOBJECT is not set
1218# CONFIG_DEBUG_INFO is not set 1231# CONFIG_DEBUG_INFO is not set
1219# CONFIG_DEBUG_VM is not set 1232# CONFIG_DEBUG_VM is not set
1233# CONFIG_DEBUG_WRITECOUNT is not set
1220# CONFIG_DEBUG_LIST is not set 1234# CONFIG_DEBUG_LIST is not set
1221# CONFIG_DEBUG_SG is not set 1235# CONFIG_DEBUG_SG is not set
1222# CONFIG_BOOT_PRINTK_DELAY is not set 1236# CONFIG_BOOT_PRINTK_DELAY is not set
@@ -1237,53 +1251,82 @@ CONFIG_KEYS_DEBUG_PROC_KEYS=y
1237# CONFIG_SECURITY is not set 1251# CONFIG_SECURITY is not set
1238# CONFIG_SECURITY_FILE_CAPABILITIES is not set 1252# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1239CONFIG_CRYPTO=y 1253CONFIG_CRYPTO=y
1254
1255#
1256# Crypto core or helper
1257#
1240CONFIG_CRYPTO_ALGAPI=y 1258CONFIG_CRYPTO_ALGAPI=y
1241CONFIG_CRYPTO_AEAD=m 1259CONFIG_CRYPTO_AEAD=m
1242CONFIG_CRYPTO_BLKCIPHER=y 1260CONFIG_CRYPTO_BLKCIPHER=y
1243CONFIG_CRYPTO_SEQIV=m
1244CONFIG_CRYPTO_HASH=y 1261CONFIG_CRYPTO_HASH=y
1245CONFIG_CRYPTO_MANAGER=y 1262CONFIG_CRYPTO_MANAGER=y
1263CONFIG_CRYPTO_GF128MUL=m
1264CONFIG_CRYPTO_NULL=y
1265# CONFIG_CRYPTO_CRYPTD is not set
1266CONFIG_CRYPTO_AUTHENC=m
1267# CONFIG_CRYPTO_TEST is not set
1268
1269#
1270# Authenticated Encryption with Associated Data
1271#
1272CONFIG_CRYPTO_CCM=m
1273CONFIG_CRYPTO_GCM=m
1274CONFIG_CRYPTO_SEQIV=m
1275
1276#
1277# Block modes
1278#
1279CONFIG_CRYPTO_CBC=m
1280CONFIG_CRYPTO_CTR=m
1281# CONFIG_CRYPTO_CTS is not set
1282CONFIG_CRYPTO_ECB=m
1283CONFIG_CRYPTO_LRW=m
1284CONFIG_CRYPTO_PCBC=m
1285CONFIG_CRYPTO_XTS=m
1286
1287#
1288# Hash modes
1289#
1246CONFIG_CRYPTO_HMAC=y 1290CONFIG_CRYPTO_HMAC=y
1247CONFIG_CRYPTO_XCBC=m 1291CONFIG_CRYPTO_XCBC=m
1248CONFIG_CRYPTO_NULL=y 1292
1293#
1294# Digest
1295#
1296# CONFIG_CRYPTO_CRC32C is not set
1249CONFIG_CRYPTO_MD4=m 1297CONFIG_CRYPTO_MD4=m
1250CONFIG_CRYPTO_MD5=y 1298CONFIG_CRYPTO_MD5=y
1299CONFIG_CRYPTO_MICHAEL_MIC=m
1251CONFIG_CRYPTO_SHA1=m 1300CONFIG_CRYPTO_SHA1=m
1252CONFIG_CRYPTO_SHA256=m 1301CONFIG_CRYPTO_SHA256=m
1253CONFIG_CRYPTO_SHA512=m 1302CONFIG_CRYPTO_SHA512=m
1254CONFIG_CRYPTO_WP512=m
1255CONFIG_CRYPTO_TGR192=m 1303CONFIG_CRYPTO_TGR192=m
1256CONFIG_CRYPTO_GF128MUL=m 1304CONFIG_CRYPTO_WP512=m
1257CONFIG_CRYPTO_ECB=m 1305
1258CONFIG_CRYPTO_CBC=m 1306#
1259CONFIG_CRYPTO_PCBC=m 1307# Ciphers
1260CONFIG_CRYPTO_LRW=m 1308#
1261CONFIG_CRYPTO_XTS=m
1262CONFIG_CRYPTO_CTR=m
1263CONFIG_CRYPTO_GCM=m
1264CONFIG_CRYPTO_CCM=m
1265# CONFIG_CRYPTO_CRYPTD is not set
1266CONFIG_CRYPTO_DES=m
1267CONFIG_CRYPTO_FCRYPT=m
1268CONFIG_CRYPTO_BLOWFISH=m
1269CONFIG_CRYPTO_TWOFISH=m
1270CONFIG_CRYPTO_TWOFISH_COMMON=m
1271CONFIG_CRYPTO_SERPENT=m
1272CONFIG_CRYPTO_AES=m 1309CONFIG_CRYPTO_AES=m
1310CONFIG_CRYPTO_ANUBIS=m
1311CONFIG_CRYPTO_ARC4=m
1312CONFIG_CRYPTO_BLOWFISH=m
1313CONFIG_CRYPTO_CAMELLIA=m
1273CONFIG_CRYPTO_CAST5=m 1314CONFIG_CRYPTO_CAST5=m
1274CONFIG_CRYPTO_CAST6=m 1315CONFIG_CRYPTO_CAST6=m
1275CONFIG_CRYPTO_TEA=m 1316CONFIG_CRYPTO_DES=m
1276CONFIG_CRYPTO_ARC4=m 1317CONFIG_CRYPTO_FCRYPT=m
1277CONFIG_CRYPTO_KHAZAD=m 1318CONFIG_CRYPTO_KHAZAD=m
1278CONFIG_CRYPTO_ANUBIS=m
1279CONFIG_CRYPTO_SEED=m
1280CONFIG_CRYPTO_SALSA20=m 1319CONFIG_CRYPTO_SALSA20=m
1320CONFIG_CRYPTO_SEED=m
1321CONFIG_CRYPTO_SERPENT=m
1322CONFIG_CRYPTO_TEA=m
1323CONFIG_CRYPTO_TWOFISH=m
1324CONFIG_CRYPTO_TWOFISH_COMMON=m
1325
1326#
1327# Compression
1328#
1281CONFIG_CRYPTO_DEFLATE=m 1329CONFIG_CRYPTO_DEFLATE=m
1282CONFIG_CRYPTO_MICHAEL_MIC=m
1283# CONFIG_CRYPTO_CRC32C is not set
1284CONFIG_CRYPTO_CAMELLIA=m
1285# CONFIG_CRYPTO_TEST is not set
1286CONFIG_CRYPTO_AUTHENC=m
1287# CONFIG_CRYPTO_LZO is not set 1330# CONFIG_CRYPTO_LZO is not set
1288CONFIG_CRYPTO_HW=y 1331CONFIG_CRYPTO_HW=y
1289# CONFIG_CRYPTO_DEV_HIFN_795X is not set 1332# CONFIG_CRYPTO_DEV_HIFN_795X is not set
@@ -1292,9 +1335,10 @@ CONFIG_CRYPTO_HW=y
1292# Library routines 1335# Library routines
1293# 1336#
1294CONFIG_BITREVERSE=y 1337CONFIG_BITREVERSE=y
1338# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1295CONFIG_CRC_CCITT=m 1339CONFIG_CRC_CCITT=m
1296# CONFIG_CRC16 is not set 1340# CONFIG_CRC16 is not set
1297# CONFIG_CRC_ITU_T is not set 1341CONFIG_CRC_ITU_T=m
1298CONFIG_CRC32=y 1342CONFIG_CRC32=y
1299# CONFIG_CRC7 is not set 1343# CONFIG_CRC7 is not set
1300CONFIG_LIBCRC32C=m 1344CONFIG_LIBCRC32C=m
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index a94f14b5c8f..185df23fd46 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22CONFIG_MACH_VR41XX=y 20CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index b7295e98838..2678b7ec335 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS_COBALT=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set 20# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index 36578968d38..ebb8ad62b3a 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_DB1000=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
index 5a90740c363..ad4e5ef6559 100644
--- a/arch/mips/configs/db1100_defconfig
+++ b/arch/mips/configs/db1100_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_DB1100=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/db1200_defconfig b/arch/mips/configs/db1200_defconfig
index 76f37a1159f..d0dc2e83ad3 100644
--- a/arch/mips/configs/db1200_defconfig
+++ b/arch/mips/configs/db1200_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_DB1200=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
index 508c91944f3..9155082313c 100644
--- a/arch/mips/configs/db1500_defconfig
+++ b/arch/mips/configs/db1500_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_DB1500=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
index 0c2c70d21db..e4e324422cd 100644
--- a/arch/mips/configs/db1550_defconfig
+++ b/arch/mips/configs/db1550_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_DB1550=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/decstation_defconfig b/arch/mips/configs/decstation_defconfig
index 58c2cd68c3a..9e65e6a2dcb 100644
--- a/arch/mips/configs/decstation_defconfig
+++ b/arch/mips/configs/decstation_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=y
26# CONFIG_MIPS_COBALT is not set 26# CONFIG_MIPS_COBALT is not set
27CONFIG_MACH_DECSTATION=y 27CONFIG_MACH_DECSTATION=y
28# CONFIG_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index 90d81f5dceb..1bd84d42b14 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22CONFIG_MACH_VR41XX=y 20CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/emma2rh_defconfig b/arch/mips/configs/emma2rh_defconfig
index f9a003c2b3a..634bb4eaf13 100644
--- a/arch/mips/configs/emma2rh_defconfig
+++ b/arch/mips/configs/emma2rh_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/excite_defconfig b/arch/mips/configs/excite_defconfig
index 15efacc75d7..3572e80356d 100644
--- a/arch/mips/configs/excite_defconfig
+++ b/arch/mips/configs/excite_defconfig
@@ -27,9 +27,7 @@ CONFIG_BASLER_EXCITE=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/fulong_defconfig b/arch/mips/configs/fulong_defconfig
index 5887a1735fb..620980081a3 100644
--- a/arch/mips/configs/fulong_defconfig
+++ b/arch/mips/configs/fulong_defconfig
@@ -14,9 +14,7 @@ CONFIG_LEMOTE_FULONG=y
14# CONFIG_MIPS_COBALT is not set 14# CONFIG_MIPS_COBALT is not set
15# CONFIG_MACH_DECSTATION is not set 15# CONFIG_MACH_DECSTATION is not set
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_WR_PPMC is not set 18# CONFIG_WR_PPMC is not set
21# CONFIG_MIPS_SIM is not set 19# CONFIG_MIPS_SIM is not set
22# CONFIG_PNX8550_JBS is not set 20# CONFIG_PNX8550_JBS is not set
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index 4f5e56c9335..cc8e6bf2b24 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -15,9 +15,7 @@ CONFIG_ZONE_DMA=y
15# CONFIG_MACH_DECSTATION is not set 15# CONFIG_MACH_DECSTATION is not set
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LEMOTE_FULONG is not set 17# CONFIG_LEMOTE_FULONG is not set
18# CONFIG_MIPS_ATLAS is not set
19# CONFIG_MIPS_MALTA is not set 18# CONFIG_MIPS_MALTA is not set
20# CONFIG_MIPS_SEAD is not set
21# CONFIG_MIPS_SIM is not set 19# CONFIG_MIPS_SIM is not set
22# CONFIG_MARKEINS is not set 20# CONFIG_MARKEINS is not set
23# CONFIG_MACH_VR41XX is not set 21# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index f40e437bd9e..138c575a015 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set 20# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/ip28_defconfig b/arch/mips/configs/ip28_defconfig
index ec188be9a67..822b01f643e 100644
--- a/arch/mips/configs/ip28_defconfig
+++ b/arch/mips/configs/ip28_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index 2c5c624c5d4..fe4699df962 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/jazz_defconfig b/arch/mips/configs/jazz_defconfig
index 56148745e8f..bbacc35d804 100644
--- a/arch/mips/configs/jazz_defconfig
+++ b/arch/mips/configs/jazz_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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
28CONFIG_MACH_JAZZ=y 28CONFIG_MACH_JAZZ=y
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
index a7cd67753aa..9d5bd2a0af3 100644
--- a/arch/mips/configs/jmr3927_defconfig
+++ b/arch/mips/configs/jmr3927_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.23-rc1 3# Linux kernel version: 2.6.26-rc9
4# Thu Aug 2 23:07:36 2007 4# Fri Jul 11 23:01:36 2008
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -10,13 +10,13 @@ CONFIG_MIPS=y
10# 10#
11# CONFIG_MACH_ALCHEMY is not set 11# CONFIG_MACH_ALCHEMY is not set
12# CONFIG_BASLER_EXCITE is not set 12# CONFIG_BASLER_EXCITE is not set
13# CONFIG_BCM47XX is not set
13# CONFIG_MIPS_COBALT is not set 14# CONFIG_MIPS_COBALT is not set
14# CONFIG_MACH_DECSTATION is not set 15# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set
16# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
@@ -26,6 +26,7 @@ CONFIG_MIPS=y
26# CONFIG_PMC_YOSEMITE is not set 26# CONFIG_PMC_YOSEMITE is not set
27# CONFIG_SGI_IP22 is not set 27# CONFIG_SGI_IP22 is not set
28# CONFIG_SGI_IP27 is not set 28# CONFIG_SGI_IP27 is not set
29# CONFIG_SGI_IP28 is not set
29# CONFIG_SGI_IP32 is not set 30# CONFIG_SGI_IP32 is not set
30# CONFIG_SIBYTE_CRHINE is not set 31# CONFIG_SIBYTE_CRHINE is not set
31# CONFIG_SIBYTE_CARMEL is not set 32# CONFIG_SIBYTE_CARMEL is not set
@@ -36,28 +37,37 @@ CONFIG_MIPS=y
36# CONFIG_SIBYTE_SENTOSA is not set 37# CONFIG_SIBYTE_SENTOSA is not set
37# CONFIG_SIBYTE_BIGSUR is not set 38# CONFIG_SIBYTE_BIGSUR is not set
38# CONFIG_SNI_RM is not set 39# CONFIG_SNI_RM is not set
39CONFIG_TOSHIBA_JMR3927=y 40CONFIG_MACH_TX39XX=y
40# CONFIG_TOSHIBA_RBTX4927 is not set 41# CONFIG_MACH_TX49XX is not set
41# CONFIG_TOSHIBA_RBTX4938 is not set
42# CONFIG_WR_PPMC is not set 42# CONFIG_WR_PPMC is not set
43CONFIG_TOSHIBA_JMR3927=y
44CONFIG_SOC_TX3927=y
45# CONFIG_TOSHIBA_FPCIB0 is not set
46CONFIG_PICMG_PCI_BACKPLANE_DEFAULT=y
43CONFIG_RWSEM_GENERIC_SPINLOCK=y 47CONFIG_RWSEM_GENERIC_SPINLOCK=y
44# CONFIG_ARCH_HAS_ILOG2_U32 is not set 48# CONFIG_ARCH_HAS_ILOG2_U32 is not set
45# CONFIG_ARCH_HAS_ILOG2_U64 is not set 49# CONFIG_ARCH_HAS_ILOG2_U64 is not set
50CONFIG_ARCH_SUPPORTS_OPROFILE=y
46CONFIG_GENERIC_FIND_NEXT_BIT=y 51CONFIG_GENERIC_FIND_NEXT_BIT=y
47CONFIG_GENERIC_HWEIGHT=y 52CONFIG_GENERIC_HWEIGHT=y
48CONFIG_GENERIC_CALIBRATE_DELAY=y 53CONFIG_GENERIC_CALIBRATE_DELAY=y
54CONFIG_GENERIC_CLOCKEVENTS=y
49CONFIG_GENERIC_TIME=y 55CONFIG_GENERIC_TIME=y
56CONFIG_GENERIC_CMOS_UPDATE=y
50CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 57CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
51CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 58CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
59CONFIG_CEVT_TXX9=y
60CONFIG_GPIO_TXX9=y
52CONFIG_DMA_NONCOHERENT=y 61CONFIG_DMA_NONCOHERENT=y
53CONFIG_DMA_NEED_PCI_MAP_STATE=y 62CONFIG_DMA_NEED_PCI_MAP_STATE=y
63# CONFIG_HOTPLUG_CPU is not set
54# CONFIG_NO_IOPORT is not set 64# CONFIG_NO_IOPORT is not set
65CONFIG_GENERIC_GPIO=y
55CONFIG_CPU_BIG_ENDIAN=y 66CONFIG_CPU_BIG_ENDIAN=y
56# CONFIG_CPU_LITTLE_ENDIAN is not set 67# CONFIG_CPU_LITTLE_ENDIAN is not set
57CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 68CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
58CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y 69CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
59CONFIG_IRQ_TXX9=y 70CONFIG_IRQ_TXX9=y
60CONFIG_MIPS_TX3927=y
61CONFIG_SWAP_IO_SPACE=y 71CONFIG_SWAP_IO_SPACE=y
62CONFIG_MIPS_L1_CACHE_SHIFT=5 72CONFIG_MIPS_L1_CACHE_SHIFT=5
63 73
@@ -104,13 +114,20 @@ CONFIG_CPU_HAS_SYNC=y
104CONFIG_GENERIC_HARDIRQS=y 114CONFIG_GENERIC_HARDIRQS=y
105CONFIG_GENERIC_IRQ_PROBE=y 115CONFIG_GENERIC_IRQ_PROBE=y
106CONFIG_ARCH_FLATMEM_ENABLE=y 116CONFIG_ARCH_FLATMEM_ENABLE=y
117CONFIG_ARCH_POPULATES_NODE_MAP=y
107CONFIG_FLATMEM=y 118CONFIG_FLATMEM=y
108CONFIG_FLAT_NODE_MEM_MAP=y 119CONFIG_FLAT_NODE_MEM_MAP=y
109# CONFIG_SPARSEMEM_STATIC is not set 120# CONFIG_SPARSEMEM_STATIC is not set
121# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
122CONFIG_PAGEFLAGS_EXTENDED=y
110CONFIG_SPLIT_PTLOCK_CPUS=4 123CONFIG_SPLIT_PTLOCK_CPUS=4
111# CONFIG_RESOURCES_64BIT is not set 124# CONFIG_RESOURCES_64BIT is not set
112CONFIG_ZONE_DMA_FLAG=0 125CONFIG_ZONE_DMA_FLAG=0
113CONFIG_VIRT_TO_BUS=y 126CONFIG_VIRT_TO_BUS=y
127# CONFIG_TICK_ONESHOT is not set
128# CONFIG_NO_HZ is not set
129# CONFIG_HIGH_RES_TIMERS is not set
130CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
114# CONFIG_HZ_48 is not set 131# CONFIG_HZ_48 is not set
115# CONFIG_HZ_100 is not set 132# CONFIG_HZ_100 is not set
116# CONFIG_HZ_128 is not set 133# CONFIG_HZ_128 is not set
@@ -144,18 +161,25 @@ CONFIG_SYSVIPC_SYSCTL=y
144# CONFIG_AUDIT is not set 161# CONFIG_AUDIT is not set
145# CONFIG_IKCONFIG is not set 162# CONFIG_IKCONFIG is not set
146CONFIG_LOG_BUF_SHIFT=14 163CONFIG_LOG_BUF_SHIFT=14
164# CONFIG_CGROUPS is not set
147CONFIG_SYSFS_DEPRECATED=y 165CONFIG_SYSFS_DEPRECATED=y
166CONFIG_SYSFS_DEPRECATED_V2=y
148# CONFIG_RELAY is not set 167# CONFIG_RELAY is not set
168# CONFIG_NAMESPACES is not set
149# CONFIG_BLK_DEV_INITRD is not set 169# CONFIG_BLK_DEV_INITRD is not set
170CONFIG_CC_OPTIMIZE_FOR_SIZE=y
150CONFIG_SYSCTL=y 171CONFIG_SYSCTL=y
151CONFIG_EMBEDDED=y 172CONFIG_EMBEDDED=y
152CONFIG_SYSCTL_SYSCALL=y 173CONFIG_SYSCTL_SYSCALL=y
174CONFIG_SYSCTL_SYSCALL_CHECK=y
153CONFIG_KALLSYMS=y 175CONFIG_KALLSYMS=y
154# CONFIG_KALLSYMS_EXTRA_PASS is not set 176# CONFIG_KALLSYMS_EXTRA_PASS is not set
155# CONFIG_HOTPLUG is not set 177# CONFIG_HOTPLUG is not set
156CONFIG_PRINTK=y 178CONFIG_PRINTK=y
157CONFIG_BUG=y 179CONFIG_BUG=y
158CONFIG_ELF_CORE=y 180CONFIG_ELF_CORE=y
181# CONFIG_PCSPKR_PLATFORM is not set
182CONFIG_COMPAT_BRK=y
159CONFIG_BASE_FULL=y 183CONFIG_BASE_FULL=y
160CONFIG_FUTEX=y 184CONFIG_FUTEX=y
161CONFIG_ANON_INODES=y 185CONFIG_ANON_INODES=y
@@ -168,6 +192,14 @@ CONFIG_VM_EVENT_COUNTERS=y
168CONFIG_SLAB=y 192CONFIG_SLAB=y
169# CONFIG_SLUB is not set 193# CONFIG_SLUB is not set
170# CONFIG_SLOB is not set 194# CONFIG_SLOB is not set
195# CONFIG_PROFILING is not set
196# CONFIG_MARKERS is not set
197CONFIG_HAVE_OPROFILE=y
198# CONFIG_HAVE_KPROBES is not set
199# CONFIG_HAVE_KRETPROBES is not set
200# CONFIG_HAVE_DMA_ATTRS is not set
201CONFIG_PROC_PAGE_MONITOR=y
202CONFIG_SLABINFO=y
171CONFIG_RT_MUTEXES=y 203CONFIG_RT_MUTEXES=y
172# CONFIG_TINY_SHMEM is not set 204# CONFIG_TINY_SHMEM is not set
173CONFIG_BASE_SMALL=0 205CONFIG_BASE_SMALL=0
@@ -189,20 +221,19 @@ CONFIG_IOSCHED_CFQ=y
189CONFIG_DEFAULT_CFQ=y 221CONFIG_DEFAULT_CFQ=y
190# CONFIG_DEFAULT_NOOP is not set 222# CONFIG_DEFAULT_NOOP is not set
191CONFIG_DEFAULT_IOSCHED="cfq" 223CONFIG_DEFAULT_IOSCHED="cfq"
224CONFIG_CLASSIC_RCU=y
192 225
193# 226#
194# Bus options (PCI, PCMCIA, EISA, ISA, TC) 227# Bus options (PCI, PCMCIA, EISA, ISA, TC)
195# 228#
196CONFIG_HW_HAS_PCI=y 229CONFIG_HW_HAS_PCI=y
197CONFIG_PCI=y 230CONFIG_PCI=y
231CONFIG_PCI_DOMAINS=y
198# CONFIG_ARCH_SUPPORTS_MSI is not set 232# CONFIG_ARCH_SUPPORTS_MSI is not set
233CONFIG_PCI_LEGACY=y
199CONFIG_MMU=y 234CONFIG_MMU=y
200 235
201# 236#
202# PCCARD (PCMCIA/CardBus) support
203#
204
205#
206# Executable file formats 237# Executable file formats
207# 238#
208CONFIG_BINFMT_ELF=y 239CONFIG_BINFMT_ELF=y
@@ -212,6 +243,7 @@ CONFIG_TRAD_SIGNALS=y
212# 243#
213# Power management options 244# Power management options
214# 245#
246CONFIG_ARCH_SUSPEND_POSSIBLE=y
215# CONFIG_PM is not set 247# CONFIG_PM is not set
216 248
217# 249#
@@ -245,25 +277,21 @@ CONFIG_IP_PNP_BOOTP=y
245# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 277# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
246# CONFIG_INET_XFRM_MODE_TUNNEL is not set 278# CONFIG_INET_XFRM_MODE_TUNNEL is not set
247# CONFIG_INET_XFRM_MODE_BEET is not set 279# CONFIG_INET_XFRM_MODE_BEET is not set
280# CONFIG_INET_LRO is not set
248# CONFIG_INET_DIAG is not set 281# CONFIG_INET_DIAG is not set
249# CONFIG_TCP_CONG_ADVANCED is not set 282# CONFIG_TCP_CONG_ADVANCED is not set
250CONFIG_TCP_CONG_CUBIC=y 283CONFIG_TCP_CONG_CUBIC=y
251CONFIG_DEFAULT_TCP_CONG="cubic" 284CONFIG_DEFAULT_TCP_CONG="cubic"
252# CONFIG_IPV6 is not set 285# CONFIG_IPV6 is not set
253# CONFIG_INET6_XFRM_TUNNEL is not set
254# CONFIG_INET6_TUNNEL is not set
255# CONFIG_NETWORK_SECMARK is not set 286# CONFIG_NETWORK_SECMARK is not set
256# CONFIG_NETFILTER is not set 287# CONFIG_NETFILTER is not set
288# CONFIG_ATM is not set
257# CONFIG_BRIDGE is not set 289# CONFIG_BRIDGE is not set
258# CONFIG_VLAN_8021Q is not set 290# CONFIG_VLAN_8021Q is not set
259# CONFIG_DECNET is not set 291# CONFIG_DECNET is not set
260# CONFIG_LLC2 is not set 292# CONFIG_LLC2 is not set
261# CONFIG_IPX is not set 293# CONFIG_IPX is not set
262# CONFIG_ATALK is not set 294# CONFIG_ATALK is not set
263
264#
265# QoS and/or fair queueing
266#
267# CONFIG_NET_SCHED is not set 295# CONFIG_NET_SCHED is not set
268 296
269# 297#
@@ -271,6 +299,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
271# 299#
272# CONFIG_NET_PKTGEN is not set 300# CONFIG_NET_PKTGEN is not set
273# CONFIG_HAMRADIO is not set 301# CONFIG_HAMRADIO is not set
302# CONFIG_CAN is not set
274# CONFIG_IRDA is not set 303# CONFIG_IRDA is not set
275# CONFIG_BT is not set 304# CONFIG_BT is not set
276 305
@@ -279,6 +308,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
279# 308#
280# CONFIG_CFG80211 is not set 309# CONFIG_CFG80211 is not set
281# CONFIG_WIRELESS_EXT is not set 310# CONFIG_WIRELESS_EXT is not set
311# CONFIG_MAC80211 is not set
282# CONFIG_IEEE80211 is not set 312# CONFIG_IEEE80211 is not set
283# CONFIG_RFKILL is not set 313# CONFIG_RFKILL is not set
284 314
@@ -307,6 +337,7 @@ CONFIG_BLK_DEV=y
307# CONFIG_CDROM_PKTCDVD is not set 337# CONFIG_CDROM_PKTCDVD is not set
308# CONFIG_ATA_OVER_ETH is not set 338# CONFIG_ATA_OVER_ETH is not set
309# CONFIG_MISC_DEVICES is not set 339# CONFIG_MISC_DEVICES is not set
340CONFIG_HAVE_IDE=y
310# CONFIG_IDE is not set 341# CONFIG_IDE is not set
311 342
312# 343#
@@ -318,10 +349,6 @@ CONFIG_BLK_DEV=y
318# CONFIG_SCSI_NETLINK is not set 349# CONFIG_SCSI_NETLINK is not set
319# CONFIG_ATA is not set 350# CONFIG_ATA is not set
320# CONFIG_MD is not set 351# CONFIG_MD is not set
321
322#
323# Fusion MPT device support
324#
325# CONFIG_FUSION is not set 352# CONFIG_FUSION is not set
326 353
327# 354#
@@ -329,7 +356,7 @@ CONFIG_BLK_DEV=y
329# 356#
330 357
331# 358#
332# An alternative FireWire stack is available with EXPERIMENTAL=y 359# A new alternative FireWire stack is available with EXPERIMENTAL=y
333# 360#
334# CONFIG_IEEE1394 is not set 361# CONFIG_IEEE1394 is not set
335# CONFIG_I2O is not set 362# CONFIG_I2O is not set
@@ -339,10 +366,27 @@ CONFIG_NETDEVICES=y
339# CONFIG_BONDING is not set 366# CONFIG_BONDING is not set
340# CONFIG_EQUALIZER is not set 367# CONFIG_EQUALIZER is not set
341# CONFIG_TUN is not set 368# CONFIG_TUN is not set
369# CONFIG_VETH is not set
342# CONFIG_ARCNET is not set 370# CONFIG_ARCNET is not set
343# CONFIG_PHYLIB is not set 371CONFIG_PHYLIB=y
372
373#
374# MII PHY device drivers
375#
376# CONFIG_MARVELL_PHY is not set
377# CONFIG_DAVICOM_PHY is not set
378# CONFIG_QSEMI_PHY is not set
379# CONFIG_LXT_PHY is not set
380# CONFIG_CICADA_PHY is not set
381# CONFIG_VITESSE_PHY is not set
382# CONFIG_SMSC_PHY is not set
383# CONFIG_BROADCOM_PHY is not set
384# CONFIG_ICPLUS_PHY is not set
385# CONFIG_REALTEK_PHY is not set
386# CONFIG_FIXED_PHY is not set
387# CONFIG_MDIO_BITBANG is not set
344CONFIG_NET_ETHERNET=y 388CONFIG_NET_ETHERNET=y
345CONFIG_MII=y 389# CONFIG_MII is not set
346# CONFIG_AX88796 is not set 390# CONFIG_AX88796 is not set
347# CONFIG_HAPPYMEAL is not set 391# CONFIG_HAPPYMEAL is not set
348# CONFIG_SUNGEM is not set 392# CONFIG_SUNGEM is not set
@@ -351,6 +395,10 @@ CONFIG_MII=y
351# CONFIG_DM9000 is not set 395# CONFIG_DM9000 is not set
352# CONFIG_NET_TULIP is not set 396# CONFIG_NET_TULIP is not set
353# CONFIG_HP100 is not set 397# CONFIG_HP100 is not set
398# CONFIG_IBM_NEW_EMAC_ZMII is not set
399# CONFIG_IBM_NEW_EMAC_RGMII is not set
400# CONFIG_IBM_NEW_EMAC_TAH is not set
401# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
354CONFIG_NET_PCI=y 402CONFIG_NET_PCI=y
355# CONFIG_PCNET32 is not set 403# CONFIG_PCNET32 is not set
356# CONFIG_AMD8111_ETH is not set 404# CONFIG_AMD8111_ETH is not set
@@ -358,13 +406,13 @@ CONFIG_NET_PCI=y
358# CONFIG_B44 is not set 406# CONFIG_B44 is not set
359# CONFIG_FORCEDETH is not set 407# CONFIG_FORCEDETH is not set
360CONFIG_TC35815=y 408CONFIG_TC35815=y
361# CONFIG_DGRS is not set
362# CONFIG_EEPRO100 is not set 409# CONFIG_EEPRO100 is not set
363# CONFIG_E100 is not set 410# CONFIG_E100 is not set
364# CONFIG_FEALNX is not set 411# CONFIG_FEALNX is not set
365# CONFIG_NATSEMI is not set 412# CONFIG_NATSEMI is not set
366# CONFIG_NE2K_PCI is not set 413# CONFIG_NE2K_PCI is not set
367# CONFIG_8139TOO is not set 414# CONFIG_8139TOO is not set
415# CONFIG_R6040 is not set
368# CONFIG_SIS900 is not set 416# CONFIG_SIS900 is not set
369# CONFIG_EPIC100 is not set 417# CONFIG_EPIC100 is not set
370# CONFIG_SUNDANCE is not set 418# CONFIG_SUNDANCE is not set
@@ -379,6 +427,7 @@ CONFIG_TC35815=y
379# 427#
380# CONFIG_WLAN_PRE80211 is not set 428# CONFIG_WLAN_PRE80211 is not set
381# CONFIG_WLAN_80211 is not set 429# CONFIG_WLAN_80211 is not set
430# CONFIG_IWLWIFI_LEDS is not set
382# CONFIG_WAN is not set 431# CONFIG_WAN is not set
383# CONFIG_FDDI is not set 432# CONFIG_FDDI is not set
384# CONFIG_PPP is not set 433# CONFIG_PPP is not set
@@ -400,7 +449,6 @@ CONFIG_INPUT=y
400# 449#
401# CONFIG_INPUT_MOUSEDEV is not set 450# CONFIG_INPUT_MOUSEDEV is not set
402# CONFIG_INPUT_JOYDEV is not set 451# CONFIG_INPUT_JOYDEV is not set
403# CONFIG_INPUT_TSDEV is not set
404# CONFIG_INPUT_EVDEV is not set 452# CONFIG_INPUT_EVDEV is not set
405# CONFIG_INPUT_EVBUG is not set 453# CONFIG_INPUT_EVBUG is not set
406 454
@@ -424,6 +472,7 @@ CONFIG_INPUT=y
424# Character devices 472# Character devices
425# 473#
426# CONFIG_VT is not set 474# CONFIG_VT is not set
475CONFIG_DEVKMEM=y
427CONFIG_SERIAL_NONSTANDARD=y 476CONFIG_SERIAL_NONSTANDARD=y
428# CONFIG_COMPUTONE is not set 477# CONFIG_COMPUTONE is not set
429# CONFIG_ROCKETPORT is not set 478# CONFIG_ROCKETPORT is not set
@@ -431,7 +480,6 @@ CONFIG_SERIAL_NONSTANDARD=y
431# CONFIG_DIGIEPCA is not set 480# CONFIG_DIGIEPCA is not set
432# CONFIG_MOXA_INTELLIO is not set 481# CONFIG_MOXA_INTELLIO is not set
433# CONFIG_MOXA_SMARTIO is not set 482# CONFIG_MOXA_SMARTIO is not set
434# CONFIG_MOXA_SMARTIO_NEW is not set
435# CONFIG_ISI is not set 483# CONFIG_ISI is not set
436# CONFIG_SYNCLINKMP is not set 484# CONFIG_SYNCLINKMP is not set
437# CONFIG_SYNCLINK_GT is not set 485# CONFIG_SYNCLINK_GT is not set
@@ -463,22 +511,30 @@ CONFIG_LEGACY_PTYS=y
463CONFIG_LEGACY_PTY_COUNT=256 511CONFIG_LEGACY_PTY_COUNT=256
464# CONFIG_IPMI_HANDLER is not set 512# CONFIG_IPMI_HANDLER is not set
465# CONFIG_HW_RANDOM is not set 513# CONFIG_HW_RANDOM is not set
466# CONFIG_RTC is not set
467# CONFIG_R3964 is not set 514# CONFIG_R3964 is not set
468# CONFIG_APPLICOM is not set 515# CONFIG_APPLICOM is not set
469# CONFIG_DRM is not set
470# CONFIG_RAW_DRIVER is not set 516# CONFIG_RAW_DRIVER is not set
471CONFIG_DEVPORT=y 517CONFIG_DEVPORT=y
472# CONFIG_I2C is not set 518# CONFIG_I2C is not set
519# CONFIG_SPI is not set
520CONFIG_HAVE_GPIO_LIB=y
473 521
474# 522#
475# SPI support 523# GPIO Support
524#
525
526#
527# I2C GPIO expanders:
528#
529
530#
531# SPI GPIO expanders:
476# 532#
477# CONFIG_SPI is not set
478# CONFIG_SPI_MASTER is not set
479# CONFIG_W1 is not set 533# CONFIG_W1 is not set
480# CONFIG_POWER_SUPPLY is not set 534# CONFIG_POWER_SUPPLY is not set
481# CONFIG_HWMON is not set 535# CONFIG_HWMON is not set
536# CONFIG_THERMAL is not set
537# CONFIG_THERMAL_HWMON is not set
482CONFIG_WATCHDOG=y 538CONFIG_WATCHDOG=y
483# CONFIG_WATCHDOG_NOWAYOUT is not set 539# CONFIG_WATCHDOG_NOWAYOUT is not set
484 540
@@ -495,29 +551,46 @@ CONFIG_TXX9_WDT=y
495# CONFIG_WDTPCI is not set 551# CONFIG_WDTPCI is not set
496 552
497# 553#
554# Sonics Silicon Backplane
555#
556CONFIG_SSB_POSSIBLE=y
557# CONFIG_SSB is not set
558
559#
498# Multifunction device drivers 560# Multifunction device drivers
499# 561#
500# CONFIG_MFD_SM501 is not set 562# CONFIG_MFD_SM501 is not set
563# CONFIG_HTC_PASIC3 is not set
501 564
502# 565#
503# Multimedia devices 566# Multimedia devices
504# 567#
568
569#
570# Multimedia core support
571#
505# CONFIG_VIDEO_DEV is not set 572# CONFIG_VIDEO_DEV is not set
506# CONFIG_DVB_CORE is not set 573# CONFIG_DVB_CORE is not set
574# CONFIG_VIDEO_MEDIA is not set
575
576#
577# Multimedia drivers
578#
507# CONFIG_DAB is not set 579# CONFIG_DAB is not set
508 580
509# 581#
510# Graphics support 582# Graphics support
511# 583#
584# CONFIG_DRM is not set
585# CONFIG_VGASTATE is not set
586# CONFIG_VIDEO_OUTPUT_CONTROL is not set
587# CONFIG_FB is not set
512# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 588# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
513 589
514# 590#
515# Display device support 591# Display device support
516# 592#
517# CONFIG_DISPLAY_SUPPORT is not set 593# CONFIG_DISPLAY_SUPPORT is not set
518# CONFIG_VGASTATE is not set
519# CONFIG_VIDEO_OUTPUT_CONTROL is not set
520# CONFIG_FB is not set
521 594
522# 595#
523# Sound 596# Sound
@@ -526,7 +599,9 @@ CONFIG_TXX9_WDT=y
526# CONFIG_HID_SUPPORT is not set 599# CONFIG_HID_SUPPORT is not set
527# CONFIG_USB_SUPPORT is not set 600# CONFIG_USB_SUPPORT is not set
528# CONFIG_MMC is not set 601# CONFIG_MMC is not set
602# CONFIG_MEMSTICK is not set
529# CONFIG_NEW_LEDS is not set 603# CONFIG_NEW_LEDS is not set
604# CONFIG_ACCESSIBILITY is not set
530# CONFIG_INFINIBAND is not set 605# CONFIG_INFINIBAND is not set
531CONFIG_RTC_LIB=y 606CONFIG_RTC_LIB=y
532CONFIG_RTC_CLASS=y 607CONFIG_RTC_CLASS=y
@@ -551,9 +626,10 @@ CONFIG_RTC_INTF_DEV=y
551# Platform RTC drivers 626# Platform RTC drivers
552# 627#
553# CONFIG_RTC_DRV_CMOS is not set 628# CONFIG_RTC_DRV_CMOS is not set
629# CONFIG_RTC_DRV_DS1511 is not set
554# CONFIG_RTC_DRV_DS1553 is not set 630# CONFIG_RTC_DRV_DS1553 is not set
555# CONFIG_RTC_DRV_STK17TA8 is not set
556CONFIG_RTC_DRV_DS1742=y 631CONFIG_RTC_DRV_DS1742=y
632# CONFIG_RTC_DRV_STK17TA8 is not set
557# CONFIG_RTC_DRV_M48T86 is not set 633# CONFIG_RTC_DRV_M48T86 is not set
558# CONFIG_RTC_DRV_M48T59 is not set 634# CONFIG_RTC_DRV_M48T59 is not set
559# CONFIG_RTC_DRV_V3020 is not set 635# CONFIG_RTC_DRV_V3020 is not set
@@ -561,23 +637,6 @@ CONFIG_RTC_DRV_DS1742=y
561# 637#
562# on-CPU RTC drivers 638# on-CPU RTC drivers
563# 639#
564
565#
566# DMA Engine support
567#
568# CONFIG_DMA_ENGINE is not set
569
570#
571# DMA Clients
572#
573
574#
575# DMA Devices
576#
577
578#
579# Userspace I/O
580#
581# CONFIG_UIO is not set 640# CONFIG_UIO is not set
582 641
583# 642#
@@ -590,12 +649,10 @@ CONFIG_RTC_DRV_DS1742=y
590# CONFIG_FS_POSIX_ACL is not set 649# CONFIG_FS_POSIX_ACL is not set
591# CONFIG_XFS_FS is not set 650# CONFIG_XFS_FS is not set
592# CONFIG_OCFS2_FS is not set 651# CONFIG_OCFS2_FS is not set
593# CONFIG_MINIX_FS is not set 652CONFIG_DNOTIFY=y
594# CONFIG_ROMFS_FS is not set
595CONFIG_INOTIFY=y 653CONFIG_INOTIFY=y
596CONFIG_INOTIFY_USER=y 654CONFIG_INOTIFY_USER=y
597# CONFIG_QUOTA is not set 655# CONFIG_QUOTA is not set
598CONFIG_DNOTIFY=y
599# CONFIG_AUTOFS_FS is not set 656# CONFIG_AUTOFS_FS is not set
600# CONFIG_AUTOFS4_FS is not set 657# CONFIG_AUTOFS4_FS is not set
601# CONFIG_FUSE_FS is not set 658# CONFIG_FUSE_FS is not set
@@ -622,7 +679,7 @@ CONFIG_PROC_SYSCTL=y
622CONFIG_SYSFS=y 679CONFIG_SYSFS=y
623# CONFIG_TMPFS is not set 680# CONFIG_TMPFS is not set
624# CONFIG_HUGETLB_PAGE is not set 681# CONFIG_HUGETLB_PAGE is not set
625CONFIG_RAMFS=y 682# CONFIG_CONFIGFS_FS is not set
626 683
627# 684#
628# Miscellaneous filesystems 685# Miscellaneous filesystems
@@ -630,17 +687,15 @@ CONFIG_RAMFS=y
630# CONFIG_HFSPLUS_FS is not set 687# CONFIG_HFSPLUS_FS is not set
631# CONFIG_CRAMFS is not set 688# CONFIG_CRAMFS is not set
632# CONFIG_VXFS_FS is not set 689# CONFIG_VXFS_FS is not set
690# CONFIG_MINIX_FS is not set
633# CONFIG_HPFS_FS is not set 691# CONFIG_HPFS_FS is not set
634# CONFIG_QNX4FS_FS is not set 692# CONFIG_QNX4FS_FS is not set
693# CONFIG_ROMFS_FS is not set
635# CONFIG_SYSV_FS is not set 694# CONFIG_SYSV_FS is not set
636# CONFIG_UFS_FS is not set 695# CONFIG_UFS_FS is not set
637 696CONFIG_NETWORK_FILESYSTEMS=y
638#
639# Network File Systems
640#
641CONFIG_NFS_FS=y 697CONFIG_NFS_FS=y
642# CONFIG_NFS_V3 is not set 698# CONFIG_NFS_V3 is not set
643# CONFIG_NFS_DIRECTIO is not set
644# CONFIG_NFSD is not set 699# CONFIG_NFSD is not set
645CONFIG_ROOT_NFS=y 700CONFIG_ROOT_NFS=y
646CONFIG_LOCKD=y 701CONFIG_LOCKD=y
@@ -656,10 +711,6 @@ CONFIG_SUNRPC=y
656# 711#
657# CONFIG_PARTITION_ADVANCED is not set 712# CONFIG_PARTITION_ADVANCED is not set
658CONFIG_MSDOS_PARTITION=y 713CONFIG_MSDOS_PARTITION=y
659
660#
661# Native Language Support
662#
663# CONFIG_NLS is not set 714# CONFIG_NLS is not set
664 715
665# 716#
@@ -667,13 +718,15 @@ CONFIG_MSDOS_PARTITION=y
667# 718#
668CONFIG_TRACE_IRQFLAGS_SUPPORT=y 719CONFIG_TRACE_IRQFLAGS_SUPPORT=y
669# CONFIG_PRINTK_TIME is not set 720# CONFIG_PRINTK_TIME is not set
721CONFIG_ENABLE_WARN_DEPRECATED=y
670CONFIG_ENABLE_MUST_CHECK=y 722CONFIG_ENABLE_MUST_CHECK=y
723CONFIG_FRAME_WARN=1024
671# CONFIG_MAGIC_SYSRQ is not set 724# CONFIG_MAGIC_SYSRQ is not set
672# CONFIG_UNUSED_SYMBOLS is not set 725# CONFIG_UNUSED_SYMBOLS is not set
673# CONFIG_DEBUG_FS is not set 726# CONFIG_DEBUG_FS is not set
674# CONFIG_HEADERS_CHECK is not set 727# CONFIG_HEADERS_CHECK is not set
675# CONFIG_DEBUG_KERNEL is not set 728# CONFIG_DEBUG_KERNEL is not set
676CONFIG_CROSSCOMPILE=y 729# CONFIG_SAMPLES is not set
677CONFIG_CMDLINE="" 730CONFIG_CMDLINE=""
678 731
679# 732#
@@ -687,6 +740,7 @@ CONFIG_CMDLINE=""
687# Library routines 740# Library routines
688# 741#
689CONFIG_BITREVERSE=y 742CONFIG_BITREVERSE=y
743# CONFIG_GENERIC_FIND_FIRST_BIT is not set
690# CONFIG_CRC_CCITT is not set 744# CONFIG_CRC_CCITT is not set
691# CONFIG_CRC16 is not set 745# CONFIG_CRC16 is not set
692# CONFIG_CRC_ITU_T is not set 746# CONFIG_CRC_ITU_T is not set
diff --git a/arch/mips/configs/lasat_defconfig b/arch/mips/configs/lasat_defconfig
index e6aef999854..bc9159fda72 100644
--- a/arch/mips/configs/lasat_defconfig
+++ b/arch/mips/configs/lasat_defconfig
@@ -15,9 +15,7 @@ CONFIG_MIPS=y
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16CONFIG_LASAT=y 16CONFIG_LASAT=y
17# CONFIG_LEMOTE_FULONG is not set 17# CONFIG_LEMOTE_FULONG is not set
18# CONFIG_MIPS_ATLAS is not set
19# CONFIG_MIPS_MALTA is not set 18# CONFIG_MIPS_MALTA is not set
20# CONFIG_MIPS_SEAD is not set
21# CONFIG_MIPS_SIM is not set 19# CONFIG_MIPS_SIM is not set
22# CONFIG_MARKEINS is not set 20# CONFIG_MARKEINS is not set
23# CONFIG_MACH_VR41XX is not set 21# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 3d0da952811..74daa0cf87e 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -15,9 +15,7 @@ CONFIG_ZONE_DMA=y
15# CONFIG_MACH_DECSTATION is not set 15# CONFIG_MACH_DECSTATION is not set
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LEMOTE_FULONG is not set 17# CONFIG_LEMOTE_FULONG is not set
18# CONFIG_MIPS_ATLAS is not set
19CONFIG_MIPS_MALTA=y 18CONFIG_MIPS_MALTA=y
20# CONFIG_MIPS_SEAD is not set
21# CONFIG_MIPS_SIM is not set 19# CONFIG_MIPS_SIM is not set
22# CONFIG_MARKEINS is not set 20# CONFIG_MARKEINS is not set
23# CONFIG_MACH_VR41XX is not set 21# CONFIG_MACH_VR41XX is not set
@@ -68,7 +66,6 @@ CONFIG_CPU_LITTLE_ENDIAN=y
68CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 66CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
69CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y 67CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
70CONFIG_IRQ_CPU=y 68CONFIG_IRQ_CPU=y
71CONFIG_MIPS_BOARDS_GEN=y
72CONFIG_PCI_GT64XXX_PCI0=y 69CONFIG_PCI_GT64XXX_PCI0=y
73CONFIG_SWAP_IO_SPACE=y 70CONFIG_SWAP_IO_SPACE=y
74CONFIG_BOOT_ELF32=y 71CONFIG_BOOT_ELF32=y
diff --git a/arch/mips/configs/mipssim_defconfig b/arch/mips/configs/mipssim_defconfig
index 4f6bce99d5c..2c0a6314e90 100644
--- a/arch/mips/configs/mipssim_defconfig
+++ b/arch/mips/configs/mipssim_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22CONFIG_MIPS_SIM=y 20CONFIG_MIPS_SIM=y
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index 27e23fc9363..8c720e51795 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22CONFIG_MACH_VR41XX=y 20CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/msp71xx_defconfig b/arch/mips/configs/msp71xx_defconfig
index b12b73f6d74..59d19472b16 100644
--- a/arch/mips/configs/msp71xx_defconfig
+++ b/arch/mips/configs/msp71xx_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/mtx1_defconfig b/arch/mips/configs/mtx1_defconfig
index fa3aa391944..bacf0dd0e34 100644
--- a/arch/mips/configs/mtx1_defconfig
+++ b/arch/mips/configs/mtx1_defconfig
@@ -14,9 +14,7 @@ CONFIG_MACH_ALCHEMY=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set 20# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
index 1d0157d3a5b..6dfe6f793ce 100644
--- a/arch/mips/configs/pb1100_defconfig
+++ b/arch/mips/configs/pb1100_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_PB1100=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
index d0491a05ee5..c965a87e6a9 100644
--- a/arch/mips/configs/pb1500_defconfig
+++ b/arch/mips/configs/pb1500_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_PB1500=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
index 16d78d3cd2a..0778996c682 100644
--- a/arch/mips/configs/pb1550_defconfig
+++ b/arch/mips/configs/pb1550_defconfig
@@ -27,9 +27,7 @@ CONFIG_MIPS_PB1550=y
27# CONFIG_MIPS_COBALT is not set 27# CONFIG_MIPS_COBALT is not set
28# CONFIG_MACH_DECSTATION is not set 28# CONFIG_MACH_DECSTATION is not set
29# CONFIG_MACH_JAZZ is not set 29# CONFIG_MACH_JAZZ is not set
30# CONFIG_MIPS_ATLAS is not set
31# CONFIG_MIPS_MALTA is not set 30# CONFIG_MIPS_MALTA is not set
32# CONFIG_MIPS_SEAD is not set
33# CONFIG_WR_PPMC is not set 31# CONFIG_WR_PPMC is not set
34# CONFIG_MIPS_SIM is not set 32# CONFIG_MIPS_SIM is not set
35# CONFIG_MOMENCO_JAGUAR_ATX is not set 33# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/pnx8550-jbs_defconfig b/arch/mips/configs/pnx8550-jbs_defconfig
index 780c7fc24b8..37c7b5ffd47 100644
--- a/arch/mips/configs/pnx8550-jbs_defconfig
+++ b/arch/mips/configs/pnx8550-jbs_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/pnx8550-stb810_defconfig b/arch/mips/configs/pnx8550-stb810_defconfig
index 267f21ed1d0..893e5c4ab66 100644
--- a/arch/mips/configs/pnx8550-stb810_defconfig
+++ b/arch/mips/configs/pnx8550-stb810_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/rbhma4200_defconfig b/arch/mips/configs/rbhma4200_defconfig
deleted file mode 100644
index 470f6f4d3ea..00000000000
--- a/arch/mips/configs/rbhma4200_defconfig
+++ /dev/null
@@ -1,669 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.23-rc1
4# Thu Aug 2 22:55:57 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11# CONFIG_MACH_ALCHEMY is not set
12# CONFIG_BASLER_EXCITE is not set
13# CONFIG_MIPS_COBALT is not set
14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set
23# CONFIG_PNX8550_JBS is not set
24# CONFIG_PNX8550_STB810 is not set
25# CONFIG_PMC_MSP is not set
26# CONFIG_PMC_YOSEMITE is not set
27# CONFIG_SGI_IP22 is not set
28# CONFIG_SGI_IP27 is not set
29# CONFIG_SGI_IP32 is not set
30# CONFIG_SIBYTE_CRHINE is not set
31# CONFIG_SIBYTE_CARMEL is not set
32# CONFIG_SIBYTE_CRHONE is not set
33# CONFIG_SIBYTE_RHONE is not set
34# CONFIG_SIBYTE_SWARM is not set
35# CONFIG_SIBYTE_LITTLESUR is not set
36# CONFIG_SIBYTE_SENTOSA is not set
37# CONFIG_SIBYTE_BIGSUR is not set
38# CONFIG_SNI_RM is not set
39# CONFIG_TOSHIBA_JMR3927 is not set
40CONFIG_TOSHIBA_RBTX4927=y
41# CONFIG_TOSHIBA_RBTX4938 is not set
42# CONFIG_WR_PPMC is not set
43# CONFIG_TOSHIBA_FPCIB0 is not set
44CONFIG_RWSEM_GENERIC_SPINLOCK=y
45# CONFIG_ARCH_HAS_ILOG2_U32 is not set
46# CONFIG_ARCH_HAS_ILOG2_U64 is not set
47CONFIG_GENERIC_FIND_NEXT_BIT=y
48CONFIG_GENERIC_HWEIGHT=y
49CONFIG_GENERIC_CALIBRATE_DELAY=y
50CONFIG_GENERIC_TIME=y
51CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
52CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
53CONFIG_DMA_NONCOHERENT=y
54CONFIG_DMA_NEED_PCI_MAP_STATE=y
55# CONFIG_NO_IOPORT is not set
56CONFIG_CPU_BIG_ENDIAN=y
57# CONFIG_CPU_LITTLE_ENDIAN is not set
58CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
59CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
60CONFIG_IRQ_CPU=y
61CONFIG_IRQ_TXX9=y
62CONFIG_SWAP_IO_SPACE=y
63CONFIG_MIPS_L1_CACHE_SHIFT=5
64
65#
66# CPU selection
67#
68# CONFIG_CPU_LOONGSON2 is not set
69# CONFIG_CPU_MIPS32_R1 is not set
70# CONFIG_CPU_MIPS32_R2 is not set
71# CONFIG_CPU_MIPS64_R1 is not set
72# CONFIG_CPU_MIPS64_R2 is not set
73# CONFIG_CPU_R3000 is not set
74# CONFIG_CPU_TX39XX is not set
75# CONFIG_CPU_VR41XX is not set
76# CONFIG_CPU_R4300 is not set
77# CONFIG_CPU_R4X00 is not set
78CONFIG_CPU_TX49XX=y
79# CONFIG_CPU_R5000 is not set
80# CONFIG_CPU_R5432 is not set
81# CONFIG_CPU_R6000 is not set
82# CONFIG_CPU_NEVADA is not set
83# CONFIG_CPU_R8000 is not set
84# CONFIG_CPU_R10000 is not set
85# CONFIG_CPU_RM7000 is not set
86# CONFIG_CPU_RM9000 is not set
87# CONFIG_CPU_SB1 is not set
88CONFIG_SYS_HAS_CPU_TX49XX=y
89CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
90CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
91CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
92CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
93
94#
95# Kernel type
96#
97CONFIG_32BIT=y
98# CONFIG_64BIT is not set
99CONFIG_PAGE_SIZE_4KB=y
100# CONFIG_PAGE_SIZE_8KB is not set
101# CONFIG_PAGE_SIZE_16KB is not set
102# CONFIG_PAGE_SIZE_64KB is not set
103CONFIG_CPU_HAS_PREFETCH=y
104CONFIG_MIPS_MT_DISABLED=y
105# CONFIG_MIPS_MT_SMP is not set
106# CONFIG_MIPS_MT_SMTC is not set
107CONFIG_CPU_HAS_LLSC=y
108CONFIG_CPU_HAS_SYNC=y
109CONFIG_GENERIC_HARDIRQS=y
110CONFIG_GENERIC_IRQ_PROBE=y
111CONFIG_ARCH_FLATMEM_ENABLE=y
112CONFIG_FLATMEM=y
113CONFIG_FLAT_NODE_MEM_MAP=y
114# CONFIG_SPARSEMEM_STATIC is not set
115CONFIG_SPLIT_PTLOCK_CPUS=4
116# CONFIG_RESOURCES_64BIT is not set
117CONFIG_ZONE_DMA_FLAG=0
118CONFIG_VIRT_TO_BUS=y
119# CONFIG_HZ_48 is not set
120# CONFIG_HZ_100 is not set
121# CONFIG_HZ_128 is not set
122CONFIG_HZ_250=y
123# CONFIG_HZ_256 is not set
124# CONFIG_HZ_1000 is not set
125# CONFIG_HZ_1024 is not set
126CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
127CONFIG_HZ=250
128CONFIG_PREEMPT_NONE=y
129# CONFIG_PREEMPT_VOLUNTARY is not set
130# CONFIG_PREEMPT is not set
131# CONFIG_SECCOMP is not set
132CONFIG_LOCKDEP_SUPPORT=y
133CONFIG_STACKTRACE_SUPPORT=y
134CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
135
136#
137# General setup
138#
139# CONFIG_EXPERIMENTAL is not set
140CONFIG_BROKEN_ON_SMP=y
141CONFIG_INIT_ENV_ARG_LIMIT=32
142CONFIG_LOCALVERSION=""
143CONFIG_LOCALVERSION_AUTO=y
144CONFIG_SWAP=y
145CONFIG_SYSVIPC=y
146CONFIG_SYSVIPC_SYSCTL=y
147# CONFIG_BSD_PROCESS_ACCT is not set
148# CONFIG_TASKSTATS is not set
149# CONFIG_AUDIT is not set
150CONFIG_IKCONFIG=y
151CONFIG_IKCONFIG_PROC=y
152CONFIG_LOG_BUF_SHIFT=14
153CONFIG_SYSFS_DEPRECATED=y
154# CONFIG_RELAY is not set
155CONFIG_BLK_DEV_INITRD=y
156CONFIG_INITRAMFS_SOURCE=""
157CONFIG_SYSCTL=y
158CONFIG_EMBEDDED=y
159CONFIG_SYSCTL_SYSCALL=y
160CONFIG_KALLSYMS=y
161# CONFIG_KALLSYMS_EXTRA_PASS is not set
162# CONFIG_HOTPLUG is not set
163CONFIG_PRINTK=y
164CONFIG_BUG=y
165CONFIG_ELF_CORE=y
166CONFIG_BASE_FULL=y
167# CONFIG_FUTEX is not set
168CONFIG_ANON_INODES=y
169# CONFIG_EPOLL is not set
170CONFIG_SIGNALFD=y
171CONFIG_TIMERFD=y
172CONFIG_EVENTFD=y
173CONFIG_SHMEM=y
174CONFIG_VM_EVENT_COUNTERS=y
175CONFIG_SLAB=y
176# CONFIG_SLUB is not set
177# CONFIG_SLOB is not set
178# CONFIG_TINY_SHMEM is not set
179CONFIG_BASE_SMALL=0
180CONFIG_MODULES=y
181# CONFIG_MODULE_UNLOAD is not set
182# CONFIG_MODVERSIONS is not set
183# CONFIG_MODULE_SRCVERSION_ALL is not set
184CONFIG_KMOD=y
185CONFIG_BLOCK=y
186# CONFIG_LBD is not set
187# CONFIG_BLK_DEV_IO_TRACE is not set
188# CONFIG_LSF is not set
189
190#
191# IO Schedulers
192#
193CONFIG_IOSCHED_NOOP=y
194CONFIG_IOSCHED_AS=y
195CONFIG_IOSCHED_DEADLINE=y
196CONFIG_IOSCHED_CFQ=y
197CONFIG_DEFAULT_AS=y
198# CONFIG_DEFAULT_DEADLINE is not set
199# CONFIG_DEFAULT_CFQ is not set
200# CONFIG_DEFAULT_NOOP is not set
201CONFIG_DEFAULT_IOSCHED="anticipatory"
202
203#
204# Bus options (PCI, PCMCIA, EISA, ISA, TC)
205#
206CONFIG_HW_HAS_PCI=y
207CONFIG_PCI=y
208# CONFIG_ARCH_SUPPORTS_MSI is not set
209CONFIG_MMU=y
210
211#
212# PCCARD (PCMCIA/CardBus) support
213#
214
215#
216# Executable file formats
217#
218CONFIG_BINFMT_ELF=y
219# CONFIG_BINFMT_MISC is not set
220CONFIG_TRAD_SIGNALS=y
221
222#
223# Power management options
224#
225# CONFIG_PM is not set
226
227#
228# Networking
229#
230CONFIG_NET=y
231
232#
233# Networking options
234#
235CONFIG_PACKET=y
236# CONFIG_PACKET_MMAP is not set
237CONFIG_UNIX=y
238# CONFIG_NET_KEY is not set
239CONFIG_INET=y
240CONFIG_IP_MULTICAST=y
241# CONFIG_IP_ADVANCED_ROUTER is not set
242CONFIG_IP_FIB_HASH=y
243CONFIG_IP_PNP=y
244# CONFIG_IP_PNP_DHCP is not set
245# CONFIG_IP_PNP_BOOTP is not set
246# CONFIG_IP_PNP_RARP is not set
247# CONFIG_NET_IPIP is not set
248# CONFIG_NET_IPGRE is not set
249# CONFIG_IP_MROUTE is not set
250# CONFIG_SYN_COOKIES is not set
251# CONFIG_INET_AH is not set
252# CONFIG_INET_ESP is not set
253# CONFIG_INET_IPCOMP is not set
254# CONFIG_INET_XFRM_TUNNEL is not set
255# CONFIG_INET_TUNNEL is not set
256# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
257# CONFIG_INET_XFRM_MODE_TUNNEL is not set
258# CONFIG_INET_XFRM_MODE_BEET is not set
259CONFIG_INET_DIAG=y
260CONFIG_INET_TCP_DIAG=y
261# CONFIG_TCP_CONG_ADVANCED is not set
262CONFIG_TCP_CONG_CUBIC=y
263CONFIG_DEFAULT_TCP_CONG="cubic"
264# CONFIG_IPV6 is not set
265# CONFIG_INET6_XFRM_TUNNEL is not set
266# CONFIG_INET6_TUNNEL is not set
267# CONFIG_NETWORK_SECMARK is not set
268# CONFIG_NETFILTER is not set
269# CONFIG_BRIDGE is not set
270# CONFIG_VLAN_8021Q is not set
271# CONFIG_DECNET is not set
272# CONFIG_LLC2 is not set
273# CONFIG_IPX is not set
274# CONFIG_ATALK is not set
275
276#
277# QoS and/or fair queueing
278#
279# CONFIG_NET_SCHED is not set
280
281#
282# Network testing
283#
284# CONFIG_NET_PKTGEN is not set
285# CONFIG_HAMRADIO is not set
286# CONFIG_IRDA is not set
287# CONFIG_BT is not set
288
289#
290# Wireless
291#
292# CONFIG_CFG80211 is not set
293# CONFIG_WIRELESS_EXT is not set
294# CONFIG_IEEE80211 is not set
295# CONFIG_RFKILL is not set
296
297#
298# Device Drivers
299#
300
301#
302# Generic Driver Options
303#
304CONFIG_STANDALONE=y
305CONFIG_PREVENT_FIRMWARE_BUILD=y
306# CONFIG_SYS_HYPERVISOR is not set
307# CONFIG_CONNECTOR is not set
308# CONFIG_MTD is not set
309# CONFIG_PARPORT is not set
310CONFIG_BLK_DEV=y
311# CONFIG_BLK_CPQ_DA is not set
312# CONFIG_BLK_CPQ_CISS_DA is not set
313# CONFIG_BLK_DEV_DAC960 is not set
314# CONFIG_BLK_DEV_COW_COMMON is not set
315CONFIG_BLK_DEV_LOOP=y
316# CONFIG_BLK_DEV_CRYPTOLOOP is not set
317# CONFIG_BLK_DEV_NBD is not set
318# CONFIG_BLK_DEV_SX8 is not set
319CONFIG_BLK_DEV_RAM=y
320CONFIG_BLK_DEV_RAM_COUNT=16
321CONFIG_BLK_DEV_RAM_SIZE=8192
322CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
323# CONFIG_CDROM_PKTCDVD is not set
324# CONFIG_ATA_OVER_ETH is not set
325# CONFIG_MISC_DEVICES is not set
326# CONFIG_IDE is not set
327
328#
329# SCSI device support
330#
331# CONFIG_RAID_ATTRS is not set
332# CONFIG_SCSI is not set
333# CONFIG_SCSI_DMA is not set
334# CONFIG_SCSI_NETLINK is not set
335# CONFIG_ATA is not set
336# CONFIG_MD is not set
337
338#
339# Fusion MPT device support
340#
341# CONFIG_FUSION is not set
342
343#
344# IEEE 1394 (FireWire) support
345#
346
347#
348# An alternative FireWire stack is available with EXPERIMENTAL=y
349#
350# CONFIG_IEEE1394 is not set
351# CONFIG_I2O is not set
352CONFIG_NETDEVICES=y
353# CONFIG_NETDEVICES_MULTIQUEUE is not set
354# CONFIG_DUMMY is not set
355# CONFIG_BONDING is not set
356# CONFIG_EQUALIZER is not set
357# CONFIG_TUN is not set
358# CONFIG_ARCNET is not set
359# CONFIG_PHYLIB is not set
360CONFIG_NET_ETHERNET=y
361# CONFIG_MII is not set
362# CONFIG_AX88796 is not set
363# CONFIG_HAPPYMEAL is not set
364# CONFIG_SUNGEM is not set
365# CONFIG_CASSINI is not set
366# CONFIG_NET_VENDOR_3COM is not set
367# CONFIG_DM9000 is not set
368# CONFIG_NET_TULIP is not set
369# CONFIG_HP100 is not set
370CONFIG_NE2000=y
371# CONFIG_NET_PCI is not set
372# CONFIG_NETDEV_1000 is not set
373# CONFIG_NETDEV_10000 is not set
374# CONFIG_TR is not set
375
376#
377# Wireless LAN
378#
379# CONFIG_WLAN_PRE80211 is not set
380# CONFIG_WLAN_80211 is not set
381# CONFIG_WAN is not set
382# CONFIG_FDDI is not set
383# CONFIG_PPP is not set
384# CONFIG_SLIP is not set
385# CONFIG_NETPOLL is not set
386# CONFIG_NET_POLL_CONTROLLER is not set
387# CONFIG_ISDN is not set
388# CONFIG_PHONE is not set
389
390#
391# Input device support
392#
393# CONFIG_INPUT is not set
394
395#
396# Hardware I/O ports
397#
398CONFIG_SERIO=y
399# CONFIG_SERIO_I8042 is not set
400CONFIG_SERIO_SERPORT=y
401# CONFIG_SERIO_PCIPS2 is not set
402CONFIG_SERIO_LIBPS2=y
403# CONFIG_SERIO_RAW is not set
404# CONFIG_GAMEPORT is not set
405
406#
407# Character devices
408#
409# CONFIG_VT is not set
410# CONFIG_SERIAL_NONSTANDARD is not set
411
412#
413# Serial drivers
414#
415# CONFIG_SERIAL_8250 is not set
416
417#
418# Non-8250 serial port support
419#
420CONFIG_SERIAL_CORE=y
421CONFIG_SERIAL_CORE_CONSOLE=y
422CONFIG_SERIAL_TXX9=y
423CONFIG_HAS_TXX9_SERIAL=y
424CONFIG_SERIAL_TXX9_NR_UARTS=6
425CONFIG_SERIAL_TXX9_CONSOLE=y
426CONFIG_SERIAL_TXX9_STDSERIAL=y
427# CONFIG_SERIAL_JSM is not set
428CONFIG_UNIX98_PTYS=y
429CONFIG_LEGACY_PTYS=y
430CONFIG_LEGACY_PTY_COUNT=256
431# CONFIG_IPMI_HANDLER is not set
432# CONFIG_HW_RANDOM is not set
433# CONFIG_RTC is not set
434# CONFIG_R3964 is not set
435# CONFIG_APPLICOM is not set
436# CONFIG_DRM is not set
437# CONFIG_RAW_DRIVER is not set
438CONFIG_DEVPORT=y
439# CONFIG_I2C is not set
440
441#
442# SPI support
443#
444# CONFIG_SPI is not set
445# CONFIG_SPI_MASTER is not set
446# CONFIG_W1 is not set
447# CONFIG_POWER_SUPPLY is not set
448# CONFIG_HWMON is not set
449CONFIG_WATCHDOG=y
450# CONFIG_WATCHDOG_NOWAYOUT is not set
451
452#
453# Watchdog Device Drivers
454#
455# CONFIG_SOFT_WATCHDOG is not set
456CONFIG_TXX9_WDT=m
457
458#
459# PCI-based Watchdog Cards
460#
461# CONFIG_PCIPCWATCHDOG is not set
462# CONFIG_WDTPCI is not set
463
464#
465# Multifunction device drivers
466#
467# CONFIG_MFD_SM501 is not set
468
469#
470# Multimedia devices
471#
472# CONFIG_VIDEO_DEV is not set
473# CONFIG_DVB_CORE is not set
474# CONFIG_DAB is not set
475
476#
477# Graphics support
478#
479# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
480
481#
482# Display device support
483#
484# CONFIG_DISPLAY_SUPPORT is not set
485# CONFIG_VGASTATE is not set
486# CONFIG_VIDEO_OUTPUT_CONTROL is not set
487# CONFIG_FB is not set
488
489#
490# Sound
491#
492# CONFIG_SOUND is not set
493# CONFIG_USB_SUPPORT is not set
494# CONFIG_MMC is not set
495# CONFIG_NEW_LEDS is not set
496# CONFIG_INFINIBAND is not set
497CONFIG_RTC_LIB=y
498CONFIG_RTC_CLASS=y
499CONFIG_RTC_HCTOSYS=y
500CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
501# CONFIG_RTC_DEBUG is not set
502
503#
504# RTC interfaces
505#
506CONFIG_RTC_INTF_SYSFS=y
507CONFIG_RTC_INTF_PROC=y
508CONFIG_RTC_INTF_DEV=y
509# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
510# CONFIG_RTC_DRV_TEST is not set
511
512#
513# SPI RTC drivers
514#
515
516#
517# Platform RTC drivers
518#
519# CONFIG_RTC_DRV_CMOS is not set
520# CONFIG_RTC_DRV_DS1553 is not set
521# CONFIG_RTC_DRV_STK17TA8 is not set
522CONFIG_RTC_DRV_DS1742=y
523# CONFIG_RTC_DRV_M48T86 is not set
524# CONFIG_RTC_DRV_M48T59 is not set
525# CONFIG_RTC_DRV_V3020 is not set
526
527#
528# on-CPU RTC drivers
529#
530
531#
532# DMA Engine support
533#
534# CONFIG_DMA_ENGINE is not set
535
536#
537# DMA Clients
538#
539
540#
541# DMA Devices
542#
543
544#
545# Userspace I/O
546#
547# CONFIG_UIO is not set
548
549#
550# File systems
551#
552# CONFIG_EXT2_FS is not set
553# CONFIG_EXT3_FS is not set
554# CONFIG_REISERFS_FS is not set
555# CONFIG_JFS_FS is not set
556CONFIG_FS_POSIX_ACL=y
557# CONFIG_XFS_FS is not set
558# CONFIG_OCFS2_FS is not set
559# CONFIG_MINIX_FS is not set
560# CONFIG_ROMFS_FS is not set
561CONFIG_INOTIFY=y
562CONFIG_INOTIFY_USER=y
563# CONFIG_QUOTA is not set
564# CONFIG_DNOTIFY is not set
565# CONFIG_AUTOFS_FS is not set
566# CONFIG_AUTOFS4_FS is not set
567# CONFIG_FUSE_FS is not set
568CONFIG_GENERIC_ACL=y
569
570#
571# CD-ROM/DVD Filesystems
572#
573# CONFIG_ISO9660_FS is not set
574# CONFIG_UDF_FS is not set
575
576#
577# DOS/FAT/NT Filesystems
578#
579# CONFIG_MSDOS_FS is not set
580# CONFIG_VFAT_FS is not set
581# CONFIG_NTFS_FS is not set
582
583#
584# Pseudo filesystems
585#
586CONFIG_PROC_FS=y
587# CONFIG_PROC_KCORE is not set
588CONFIG_PROC_SYSCTL=y
589CONFIG_SYSFS=y
590CONFIG_TMPFS=y
591CONFIG_TMPFS_POSIX_ACL=y
592# CONFIG_HUGETLB_PAGE is not set
593CONFIG_RAMFS=y
594
595#
596# Miscellaneous filesystems
597#
598# CONFIG_HFSPLUS_FS is not set
599# CONFIG_CRAMFS is not set
600# CONFIG_VXFS_FS is not set
601# CONFIG_HPFS_FS is not set
602# CONFIG_QNX4FS_FS is not set
603# CONFIG_SYSV_FS is not set
604# CONFIG_UFS_FS is not set
605
606#
607# Network File Systems
608#
609CONFIG_NFS_FS=y
610CONFIG_NFS_V3=y
611# CONFIG_NFS_V3_ACL is not set
612# CONFIG_NFS_DIRECTIO is not set
613# CONFIG_NFSD is not set
614CONFIG_ROOT_NFS=y
615CONFIG_LOCKD=y
616CONFIG_LOCKD_V4=y
617CONFIG_NFS_COMMON=y
618CONFIG_SUNRPC=y
619# CONFIG_SMB_FS is not set
620# CONFIG_CIFS is not set
621# CONFIG_NCP_FS is not set
622# CONFIG_CODA_FS is not set
623
624#
625# Partition Types
626#
627# CONFIG_PARTITION_ADVANCED is not set
628CONFIG_MSDOS_PARTITION=y
629
630#
631# Native Language Support
632#
633# CONFIG_NLS is not set
634
635#
636# Kernel hacking
637#
638CONFIG_TRACE_IRQFLAGS_SUPPORT=y
639# CONFIG_PRINTK_TIME is not set
640CONFIG_ENABLE_MUST_CHECK=y
641# CONFIG_MAGIC_SYSRQ is not set
642# CONFIG_UNUSED_SYMBOLS is not set
643# CONFIG_DEBUG_FS is not set
644# CONFIG_HEADERS_CHECK is not set
645# CONFIG_DEBUG_KERNEL is not set
646CONFIG_CROSSCOMPILE=y
647CONFIG_CMDLINE=""
648CONFIG_SYS_SUPPORTS_KGDB=y
649
650#
651# Security options
652#
653# CONFIG_KEYS is not set
654# CONFIG_SECURITY is not set
655# CONFIG_CRYPTO is not set
656
657#
658# Library routines
659#
660CONFIG_BITREVERSE=y
661# CONFIG_CRC_CCITT is not set
662# CONFIG_CRC16 is not set
663# CONFIG_CRC_ITU_T is not set
664CONFIG_CRC32=y
665# CONFIG_CRC7 is not set
666# CONFIG_LIBCRC32C is not set
667CONFIG_HAS_IOMEM=y
668CONFIG_HAS_IOPORT=y
669CONFIG_HAS_DMA=y
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbtx49xx_defconfig
index 5a39f56b175..e42aed5a38b 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbtx49xx_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.23-rc1 3# Linux kernel version: 2.6.26-rc9
4# Thu Aug 2 22:59:53 2007 4# Fri Jul 11 23:03:21 2008
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -10,13 +10,13 @@ CONFIG_MIPS=y
10# 10#
11# CONFIG_MACH_ALCHEMY is not set 11# CONFIG_MACH_ALCHEMY is not set
12# CONFIG_BASLER_EXCITE is not set 12# CONFIG_BASLER_EXCITE is not set
13# CONFIG_BCM47XX is not set
13# CONFIG_MIPS_COBALT is not set 14# CONFIG_MIPS_COBALT is not set
14# CONFIG_MACH_DECSTATION is not set 15# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set
16# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
22# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
@@ -26,6 +26,7 @@ CONFIG_MIPS=y
26# CONFIG_PMC_YOSEMITE is not set 26# CONFIG_PMC_YOSEMITE is not set
27# CONFIG_SGI_IP22 is not set 27# CONFIG_SGI_IP22 is not set
28# CONFIG_SGI_IP27 is not set 28# CONFIG_SGI_IP27 is not set
29# CONFIG_SGI_IP28 is not set
29# CONFIG_SGI_IP32 is not set 30# CONFIG_SGI_IP32 is not set
30# CONFIG_SIBYTE_CRHINE is not set 31# CONFIG_SIBYTE_CRHINE is not set
31# CONFIG_SIBYTE_CARMEL is not set 32# CONFIG_SIBYTE_CARMEL is not set
@@ -36,10 +37,15 @@ CONFIG_MIPS=y
36# CONFIG_SIBYTE_SENTOSA is not set 37# CONFIG_SIBYTE_SENTOSA is not set
37# CONFIG_SIBYTE_BIGSUR is not set 38# CONFIG_SIBYTE_BIGSUR is not set
38# CONFIG_SNI_RM is not set 39# CONFIG_SNI_RM is not set
39# CONFIG_TOSHIBA_JMR3927 is not set 40# CONFIG_MACH_TX39XX is not set
40# CONFIG_TOSHIBA_RBTX4927 is not set 41CONFIG_MACH_TX49XX=y
41CONFIG_TOSHIBA_RBTX4938=y
42# CONFIG_WR_PPMC is not set 42# CONFIG_WR_PPMC is not set
43CONFIG_TOSHIBA_RBTX4927=y
44CONFIG_TOSHIBA_RBTX4938=y
45CONFIG_SOC_TX4927=y
46CONFIG_SOC_TX4938=y
47# CONFIG_TOSHIBA_FPCIB0 is not set
48CONFIG_PICMG_PCI_BACKPLANE_DEFAULT=y
43 49
44# 50#
45# Multiplex Pin Select 51# Multiplex Pin Select
@@ -47,21 +53,30 @@ CONFIG_TOSHIBA_RBTX4938=y
47CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61=y 53CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61=y
48# CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND is not set 54# CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND is not set
49# CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA is not set 55# CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA is not set
56CONFIG_PCI_TX4927=y
50CONFIG_RWSEM_GENERIC_SPINLOCK=y 57CONFIG_RWSEM_GENERIC_SPINLOCK=y
51# CONFIG_ARCH_HAS_ILOG2_U32 is not set 58# CONFIG_ARCH_HAS_ILOG2_U32 is not set
52# CONFIG_ARCH_HAS_ILOG2_U64 is not set 59# CONFIG_ARCH_HAS_ILOG2_U64 is not set
60CONFIG_ARCH_SUPPORTS_OPROFILE=y
53CONFIG_GENERIC_FIND_NEXT_BIT=y 61CONFIG_GENERIC_FIND_NEXT_BIT=y
54CONFIG_GENERIC_HWEIGHT=y 62CONFIG_GENERIC_HWEIGHT=y
55CONFIG_GENERIC_CALIBRATE_DELAY=y 63CONFIG_GENERIC_CALIBRATE_DELAY=y
64CONFIG_GENERIC_CLOCKEVENTS=y
56CONFIG_GENERIC_TIME=y 65CONFIG_GENERIC_TIME=y
66CONFIG_GENERIC_CMOS_UPDATE=y
57CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y 67CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
58CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 68CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
69CONFIG_CEVT_R4K=y
70CONFIG_CEVT_TXX9=y
71CONFIG_CSRC_R4K=y
72CONFIG_GPIO_TXX9=y
59CONFIG_DMA_NONCOHERENT=y 73CONFIG_DMA_NONCOHERENT=y
60CONFIG_DMA_NEED_PCI_MAP_STATE=y 74CONFIG_DMA_NEED_PCI_MAP_STATE=y
75# CONFIG_HOTPLUG_CPU is not set
61# CONFIG_NO_IOPORT is not set 76# CONFIG_NO_IOPORT is not set
62CONFIG_GENERIC_GPIO=y 77CONFIG_GENERIC_GPIO=y
63# CONFIG_CPU_BIG_ENDIAN is not set 78CONFIG_CPU_BIG_ENDIAN=y
64CONFIG_CPU_LITTLE_ENDIAN=y 79# CONFIG_CPU_LITTLE_ENDIAN is not set
65CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y 80CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
66CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y 81CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
67CONFIG_IRQ_CPU=y 82CONFIG_IRQ_CPU=y
@@ -94,6 +109,7 @@ CONFIG_CPU_TX49XX=y
94# CONFIG_CPU_SB1 is not set 109# CONFIG_CPU_SB1 is not set
95CONFIG_SYS_HAS_CPU_TX49XX=y 110CONFIG_SYS_HAS_CPU_TX49XX=y
96CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y 111CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
112CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
97CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y 113CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
98CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y 114CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
99 115
@@ -115,13 +131,20 @@ CONFIG_CPU_HAS_SYNC=y
115CONFIG_GENERIC_HARDIRQS=y 131CONFIG_GENERIC_HARDIRQS=y
116CONFIG_GENERIC_IRQ_PROBE=y 132CONFIG_GENERIC_IRQ_PROBE=y
117CONFIG_ARCH_FLATMEM_ENABLE=y 133CONFIG_ARCH_FLATMEM_ENABLE=y
134CONFIG_ARCH_POPULATES_NODE_MAP=y
118CONFIG_FLATMEM=y 135CONFIG_FLATMEM=y
119CONFIG_FLAT_NODE_MEM_MAP=y 136CONFIG_FLAT_NODE_MEM_MAP=y
120# CONFIG_SPARSEMEM_STATIC is not set 137# CONFIG_SPARSEMEM_STATIC is not set
138# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
139CONFIG_PAGEFLAGS_EXTENDED=y
121CONFIG_SPLIT_PTLOCK_CPUS=4 140CONFIG_SPLIT_PTLOCK_CPUS=4
122# CONFIG_RESOURCES_64BIT is not set 141# CONFIG_RESOURCES_64BIT is not set
123CONFIG_ZONE_DMA_FLAG=0 142CONFIG_ZONE_DMA_FLAG=0
124CONFIG_VIRT_TO_BUS=y 143CONFIG_VIRT_TO_BUS=y
144CONFIG_TICK_ONESHOT=y
145CONFIG_NO_HZ=y
146CONFIG_HIGH_RES_TIMERS=y
147CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
125# CONFIG_HZ_48 is not set 148# CONFIG_HZ_48 is not set
126# CONFIG_HZ_100 is not set 149# CONFIG_HZ_100 is not set
127# CONFIG_HZ_128 is not set 150# CONFIG_HZ_128 is not set
@@ -156,19 +179,26 @@ CONFIG_SYSVIPC_SYSCTL=y
156CONFIG_IKCONFIG=y 179CONFIG_IKCONFIG=y
157CONFIG_IKCONFIG_PROC=y 180CONFIG_IKCONFIG_PROC=y
158CONFIG_LOG_BUF_SHIFT=14 181CONFIG_LOG_BUF_SHIFT=14
182# CONFIG_CGROUPS is not set
159CONFIG_SYSFS_DEPRECATED=y 183CONFIG_SYSFS_DEPRECATED=y
184CONFIG_SYSFS_DEPRECATED_V2=y
160# CONFIG_RELAY is not set 185# CONFIG_RELAY is not set
186# CONFIG_NAMESPACES is not set
161CONFIG_BLK_DEV_INITRD=y 187CONFIG_BLK_DEV_INITRD=y
162CONFIG_INITRAMFS_SOURCE="" 188CONFIG_INITRAMFS_SOURCE=""
189CONFIG_CC_OPTIMIZE_FOR_SIZE=y
163CONFIG_SYSCTL=y 190CONFIG_SYSCTL=y
164CONFIG_EMBEDDED=y 191CONFIG_EMBEDDED=y
165CONFIG_SYSCTL_SYSCALL=y 192CONFIG_SYSCTL_SYSCALL=y
193CONFIG_SYSCTL_SYSCALL_CHECK=y
166CONFIG_KALLSYMS=y 194CONFIG_KALLSYMS=y
167# CONFIG_KALLSYMS_EXTRA_PASS is not set 195# CONFIG_KALLSYMS_EXTRA_PASS is not set
168# CONFIG_HOTPLUG is not set 196# CONFIG_HOTPLUG is not set
169CONFIG_PRINTK=y 197CONFIG_PRINTK=y
170CONFIG_BUG=y 198CONFIG_BUG=y
171CONFIG_ELF_CORE=y 199CONFIG_ELF_CORE=y
200# CONFIG_PCSPKR_PLATFORM is not set
201CONFIG_COMPAT_BRK=y
172CONFIG_BASE_FULL=y 202CONFIG_BASE_FULL=y
173# CONFIG_FUTEX is not set 203# CONFIG_FUTEX is not set
174CONFIG_ANON_INODES=y 204CONFIG_ANON_INODES=y
@@ -181,9 +211,18 @@ CONFIG_VM_EVENT_COUNTERS=y
181CONFIG_SLAB=y 211CONFIG_SLAB=y
182# CONFIG_SLUB is not set 212# CONFIG_SLUB is not set
183# CONFIG_SLOB is not set 213# CONFIG_SLOB is not set
214# CONFIG_PROFILING is not set
215# CONFIG_MARKERS is not set
216CONFIG_HAVE_OPROFILE=y
217# CONFIG_HAVE_KPROBES is not set
218# CONFIG_HAVE_KRETPROBES is not set
219# CONFIG_HAVE_DMA_ATTRS is not set
220CONFIG_PROC_PAGE_MONITOR=y
221CONFIG_SLABINFO=y
184# CONFIG_TINY_SHMEM is not set 222# CONFIG_TINY_SHMEM is not set
185CONFIG_BASE_SMALL=0 223CONFIG_BASE_SMALL=0
186CONFIG_MODULES=y 224CONFIG_MODULES=y
225# CONFIG_MODULE_FORCE_LOAD is not set
187# CONFIG_MODULE_UNLOAD is not set 226# CONFIG_MODULE_UNLOAD is not set
188# CONFIG_MODVERSIONS is not set 227# CONFIG_MODVERSIONS is not set
189# CONFIG_MODULE_SRCVERSION_ALL is not set 228# CONFIG_MODULE_SRCVERSION_ALL is not set
@@ -205,20 +244,19 @@ CONFIG_DEFAULT_AS=y
205# CONFIG_DEFAULT_CFQ is not set 244# CONFIG_DEFAULT_CFQ is not set
206# CONFIG_DEFAULT_NOOP is not set 245# CONFIG_DEFAULT_NOOP is not set
207CONFIG_DEFAULT_IOSCHED="anticipatory" 246CONFIG_DEFAULT_IOSCHED="anticipatory"
247CONFIG_CLASSIC_RCU=y
208 248
209# 249#
210# Bus options (PCI, PCMCIA, EISA, ISA, TC) 250# Bus options (PCI, PCMCIA, EISA, ISA, TC)
211# 251#
212CONFIG_HW_HAS_PCI=y 252CONFIG_HW_HAS_PCI=y
213CONFIG_PCI=y 253CONFIG_PCI=y
254CONFIG_PCI_DOMAINS=y
214# CONFIG_ARCH_SUPPORTS_MSI is not set 255# CONFIG_ARCH_SUPPORTS_MSI is not set
256# CONFIG_PCI_LEGACY is not set
215CONFIG_MMU=y 257CONFIG_MMU=y
216 258
217# 259#
218# PCCARD (PCMCIA/CardBus) support
219#
220
221#
222# Executable file formats 260# Executable file formats
223# 261#
224CONFIG_BINFMT_ELF=y 262CONFIG_BINFMT_ELF=y
@@ -228,6 +266,7 @@ CONFIG_TRAD_SIGNALS=y
228# 266#
229# Power management options 267# Power management options
230# 268#
269CONFIG_ARCH_SUSPEND_POSSIBLE=y
231# CONFIG_PM is not set 270# CONFIG_PM is not set
232 271
233# 272#
@@ -262,26 +301,22 @@ CONFIG_IP_PNP=y
262# CONFIG_INET_XFRM_MODE_TRANSPORT is not set 301# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
263# CONFIG_INET_XFRM_MODE_TUNNEL is not set 302# CONFIG_INET_XFRM_MODE_TUNNEL is not set
264# CONFIG_INET_XFRM_MODE_BEET is not set 303# CONFIG_INET_XFRM_MODE_BEET is not set
304# CONFIG_INET_LRO is not set
265CONFIG_INET_DIAG=y 305CONFIG_INET_DIAG=y
266CONFIG_INET_TCP_DIAG=y 306CONFIG_INET_TCP_DIAG=y
267# CONFIG_TCP_CONG_ADVANCED is not set 307# CONFIG_TCP_CONG_ADVANCED is not set
268CONFIG_TCP_CONG_CUBIC=y 308CONFIG_TCP_CONG_CUBIC=y
269CONFIG_DEFAULT_TCP_CONG="cubic" 309CONFIG_DEFAULT_TCP_CONG="cubic"
270# CONFIG_IPV6 is not set 310# CONFIG_IPV6 is not set
271# CONFIG_INET6_XFRM_TUNNEL is not set
272# CONFIG_INET6_TUNNEL is not set
273# CONFIG_NETWORK_SECMARK is not set 311# CONFIG_NETWORK_SECMARK is not set
274# CONFIG_NETFILTER is not set 312# CONFIG_NETFILTER is not set
313# CONFIG_ATM is not set
275# CONFIG_BRIDGE is not set 314# CONFIG_BRIDGE is not set
276# CONFIG_VLAN_8021Q is not set 315# CONFIG_VLAN_8021Q is not set
277# CONFIG_DECNET is not set 316# CONFIG_DECNET is not set
278# CONFIG_LLC2 is not set 317# CONFIG_LLC2 is not set
279# CONFIG_IPX is not set 318# CONFIG_IPX is not set
280# CONFIG_ATALK is not set 319# CONFIG_ATALK is not set
281
282#
283# QoS and/or fair queueing
284#
285# CONFIG_NET_SCHED is not set 320# CONFIG_NET_SCHED is not set
286 321
287# 322#
@@ -289,6 +324,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
289# 324#
290# CONFIG_NET_PKTGEN is not set 325# CONFIG_NET_PKTGEN is not set
291# CONFIG_HAMRADIO is not set 326# CONFIG_HAMRADIO is not set
327# CONFIG_CAN is not set
292# CONFIG_IRDA is not set 328# CONFIG_IRDA is not set
293# CONFIG_BT is not set 329# CONFIG_BT is not set
294 330
@@ -297,6 +333,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
297# 333#
298# CONFIG_CFG80211 is not set 334# CONFIG_CFG80211 is not set
299# CONFIG_WIRELESS_EXT is not set 335# CONFIG_WIRELESS_EXT is not set
336# CONFIG_MAC80211 is not set
300# CONFIG_IEEE80211 is not set 337# CONFIG_IEEE80211 is not set
301# CONFIG_RFKILL is not set 338# CONFIG_RFKILL is not set
302 339
@@ -325,10 +362,11 @@ CONFIG_BLK_DEV_LOOP=y
325CONFIG_BLK_DEV_RAM=y 362CONFIG_BLK_DEV_RAM=y
326CONFIG_BLK_DEV_RAM_COUNT=16 363CONFIG_BLK_DEV_RAM_COUNT=16
327CONFIG_BLK_DEV_RAM_SIZE=8192 364CONFIG_BLK_DEV_RAM_SIZE=8192
328CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 365# CONFIG_BLK_DEV_XIP is not set
329# CONFIG_CDROM_PKTCDVD is not set 366# CONFIG_CDROM_PKTCDVD is not set
330# CONFIG_ATA_OVER_ETH is not set 367# CONFIG_ATA_OVER_ETH is not set
331# CONFIG_MISC_DEVICES is not set 368# CONFIG_MISC_DEVICES is not set
369CONFIG_HAVE_IDE=y
332# CONFIG_IDE is not set 370# CONFIG_IDE is not set
333 371
334# 372#
@@ -340,10 +378,6 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
340# CONFIG_SCSI_NETLINK is not set 378# CONFIG_SCSI_NETLINK is not set
341# CONFIG_ATA is not set 379# CONFIG_ATA is not set
342# CONFIG_MD is not set 380# CONFIG_MD is not set
343
344#
345# Fusion MPT device support
346#
347# CONFIG_FUSION is not set 381# CONFIG_FUSION is not set
348 382
349# 383#
@@ -351,7 +385,7 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
351# 385#
352 386
353# 387#
354# An alternative FireWire stack is available with EXPERIMENTAL=y 388# A new alternative FireWire stack is available with EXPERIMENTAL=y
355# 389#
356# CONFIG_IEEE1394 is not set 390# CONFIG_IEEE1394 is not set
357# CONFIG_I2O is not set 391# CONFIG_I2O is not set
@@ -361,10 +395,27 @@ CONFIG_NETDEVICES=y
361# CONFIG_BONDING is not set 395# CONFIG_BONDING is not set
362# CONFIG_EQUALIZER is not set 396# CONFIG_EQUALIZER is not set
363# CONFIG_TUN is not set 397# CONFIG_TUN is not set
398# CONFIG_VETH is not set
364# CONFIG_ARCNET is not set 399# CONFIG_ARCNET is not set
365# CONFIG_PHYLIB is not set 400CONFIG_PHYLIB=y
401
402#
403# MII PHY device drivers
404#
405# CONFIG_MARVELL_PHY is not set
406# CONFIG_DAVICOM_PHY is not set
407# CONFIG_QSEMI_PHY is not set
408# CONFIG_LXT_PHY is not set
409# CONFIG_CICADA_PHY is not set
410# CONFIG_VITESSE_PHY is not set
411# CONFIG_SMSC_PHY is not set
412# CONFIG_BROADCOM_PHY is not set
413# CONFIG_ICPLUS_PHY is not set
414# CONFIG_REALTEK_PHY is not set
415# CONFIG_FIXED_PHY is not set
416# CONFIG_MDIO_BITBANG is not set
366CONFIG_NET_ETHERNET=y 417CONFIG_NET_ETHERNET=y
367CONFIG_MII=y 418# CONFIG_MII is not set
368# CONFIG_AX88796 is not set 419# CONFIG_AX88796 is not set
369# CONFIG_HAPPYMEAL is not set 420# CONFIG_HAPPYMEAL is not set
370# CONFIG_SUNGEM is not set 421# CONFIG_SUNGEM is not set
@@ -374,6 +425,10 @@ CONFIG_MII=y
374# CONFIG_NET_TULIP is not set 425# CONFIG_NET_TULIP is not set
375# CONFIG_HP100 is not set 426# CONFIG_HP100 is not set
376CONFIG_NE2000=y 427CONFIG_NE2000=y
428# CONFIG_IBM_NEW_EMAC_ZMII is not set
429# CONFIG_IBM_NEW_EMAC_RGMII is not set
430# CONFIG_IBM_NEW_EMAC_TAH is not set
431# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
377CONFIG_NET_PCI=y 432CONFIG_NET_PCI=y
378# CONFIG_PCNET32 is not set 433# CONFIG_PCNET32 is not set
379# CONFIG_AMD8111_ETH is not set 434# CONFIG_AMD8111_ETH is not set
@@ -381,13 +436,13 @@ CONFIG_NET_PCI=y
381# CONFIG_B44 is not set 436# CONFIG_B44 is not set
382# CONFIG_FORCEDETH is not set 437# CONFIG_FORCEDETH is not set
383CONFIG_TC35815=y 438CONFIG_TC35815=y
384# CONFIG_DGRS is not set
385# CONFIG_EEPRO100 is not set 439# CONFIG_EEPRO100 is not set
386# CONFIG_E100 is not set 440# CONFIG_E100 is not set
387# CONFIG_FEALNX is not set 441# CONFIG_FEALNX is not set
388# CONFIG_NATSEMI is not set 442# CONFIG_NATSEMI is not set
389# CONFIG_NE2K_PCI is not set 443# CONFIG_NE2K_PCI is not set
390# CONFIG_8139TOO is not set 444# CONFIG_8139TOO is not set
445# CONFIG_R6040 is not set
391# CONFIG_SIS900 is not set 446# CONFIG_SIS900 is not set
392# CONFIG_EPIC100 is not set 447# CONFIG_EPIC100 is not set
393# CONFIG_SUNDANCE is not set 448# CONFIG_SUNDANCE is not set
@@ -402,6 +457,7 @@ CONFIG_TC35815=y
402# 457#
403# CONFIG_WLAN_PRE80211 is not set 458# CONFIG_WLAN_PRE80211 is not set
404# CONFIG_WLAN_80211 is not set 459# CONFIG_WLAN_80211 is not set
460# CONFIG_IWLWIFI_LEDS is not set
405# CONFIG_WAN is not set 461# CONFIG_WAN is not set
406# CONFIG_FDDI is not set 462# CONFIG_FDDI is not set
407# CONFIG_PPP is not set 463# CONFIG_PPP is not set
@@ -426,6 +482,7 @@ CONFIG_TC35815=y
426# Character devices 482# Character devices
427# 483#
428# CONFIG_VT is not set 484# CONFIG_VT is not set
485CONFIG_DEVKMEM=y
429# CONFIG_SERIAL_NONSTANDARD is not set 486# CONFIG_SERIAL_NONSTANDARD is not set
430 487
431# 488#
@@ -449,17 +506,11 @@ CONFIG_LEGACY_PTYS=y
449CONFIG_LEGACY_PTY_COUNT=256 506CONFIG_LEGACY_PTY_COUNT=256
450# CONFIG_IPMI_HANDLER is not set 507# CONFIG_IPMI_HANDLER is not set
451# CONFIG_HW_RANDOM is not set 508# CONFIG_HW_RANDOM is not set
452# CONFIG_RTC is not set
453# CONFIG_R3964 is not set 509# CONFIG_R3964 is not set
454# CONFIG_APPLICOM is not set 510# CONFIG_APPLICOM is not set
455# CONFIG_DRM is not set
456# CONFIG_RAW_DRIVER is not set 511# CONFIG_RAW_DRIVER is not set
457CONFIG_DEVPORT=y 512CONFIG_DEVPORT=y
458# CONFIG_I2C is not set 513# CONFIG_I2C is not set
459
460#
461# SPI support
462#
463CONFIG_SPI=y 514CONFIG_SPI=y
464CONFIG_SPI_MASTER=y 515CONFIG_SPI_MASTER=y
465 516
@@ -473,9 +524,25 @@ CONFIG_SPI_TXX9=y
473# 524#
474CONFIG_SPI_AT25=y 525CONFIG_SPI_AT25=y
475# CONFIG_SPI_TLE62X0 is not set 526# CONFIG_SPI_TLE62X0 is not set
527CONFIG_HAVE_GPIO_LIB=y
528
529#
530# GPIO Support
531#
532
533#
534# I2C GPIO expanders:
535#
536
537#
538# SPI GPIO expanders:
539#
540# CONFIG_GPIO_MCP23S08 is not set
476# CONFIG_W1 is not set 541# CONFIG_W1 is not set
477# CONFIG_POWER_SUPPLY is not set 542# CONFIG_POWER_SUPPLY is not set
478# CONFIG_HWMON is not set 543# CONFIG_HWMON is not set
544# CONFIG_THERMAL is not set
545# CONFIG_THERMAL_HWMON is not set
479CONFIG_WATCHDOG=y 546CONFIG_WATCHDOG=y
480# CONFIG_WATCHDOG_NOWAYOUT is not set 547# CONFIG_WATCHDOG_NOWAYOUT is not set
481 548
@@ -492,29 +559,46 @@ CONFIG_TXX9_WDT=m
492# CONFIG_WDTPCI is not set 559# CONFIG_WDTPCI is not set
493 560
494# 561#
562# Sonics Silicon Backplane
563#
564CONFIG_SSB_POSSIBLE=y
565# CONFIG_SSB is not set
566
567#
495# Multifunction device drivers 568# Multifunction device drivers
496# 569#
497# CONFIG_MFD_SM501 is not set 570# CONFIG_MFD_SM501 is not set
571# CONFIG_HTC_PASIC3 is not set
498 572
499# 573#
500# Multimedia devices 574# Multimedia devices
501# 575#
576
577#
578# Multimedia core support
579#
502# CONFIG_VIDEO_DEV is not set 580# CONFIG_VIDEO_DEV is not set
503# CONFIG_DVB_CORE is not set 581# CONFIG_DVB_CORE is not set
582# CONFIG_VIDEO_MEDIA is not set
583
584#
585# Multimedia drivers
586#
504# CONFIG_DAB is not set 587# CONFIG_DAB is not set
505 588
506# 589#
507# Graphics support 590# Graphics support
508# 591#
592# CONFIG_DRM is not set
593# CONFIG_VGASTATE is not set
594# CONFIG_VIDEO_OUTPUT_CONTROL is not set
595# CONFIG_FB is not set
509# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 596# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
510 597
511# 598#
512# Display device support 599# Display device support
513# 600#
514# CONFIG_DISPLAY_SUPPORT is not set 601# CONFIG_DISPLAY_SUPPORT is not set
515# CONFIG_VGASTATE is not set
516# CONFIG_VIDEO_OUTPUT_CONTROL is not set
517# CONFIG_FB is not set
518 602
519# 603#
520# Sound 604# Sound
@@ -522,7 +606,9 @@ CONFIG_TXX9_WDT=m
522# CONFIG_SOUND is not set 606# CONFIG_SOUND is not set
523# CONFIG_USB_SUPPORT is not set 607# CONFIG_USB_SUPPORT is not set
524# CONFIG_MMC is not set 608# CONFIG_MMC is not set
609# CONFIG_MEMSTICK is not set
525# CONFIG_NEW_LEDS is not set 610# CONFIG_NEW_LEDS is not set
611# CONFIG_ACCESSIBILITY is not set
526# CONFIG_INFINIBAND is not set 612# CONFIG_INFINIBAND is not set
527CONFIG_RTC_LIB=y 613CONFIG_RTC_LIB=y
528CONFIG_RTC_CLASS=y 614CONFIG_RTC_CLASS=y
@@ -542,16 +628,18 @@ CONFIG_RTC_INTF_DEV_UIE_EMUL=y
542# 628#
543# SPI RTC drivers 629# SPI RTC drivers
544# 630#
545CONFIG_RTC_DRV_RS5C348=y
546# CONFIG_RTC_DRV_MAX6902 is not set 631# CONFIG_RTC_DRV_MAX6902 is not set
632# CONFIG_RTC_DRV_R9701 is not set
633CONFIG_RTC_DRV_RS5C348=y
547 634
548# 635#
549# Platform RTC drivers 636# Platform RTC drivers
550# 637#
551# CONFIG_RTC_DRV_CMOS is not set 638# CONFIG_RTC_DRV_CMOS is not set
639# CONFIG_RTC_DRV_DS1511 is not set
552# CONFIG_RTC_DRV_DS1553 is not set 640# CONFIG_RTC_DRV_DS1553 is not set
641CONFIG_RTC_DRV_DS1742=y
553# CONFIG_RTC_DRV_STK17TA8 is not set 642# CONFIG_RTC_DRV_STK17TA8 is not set
554# CONFIG_RTC_DRV_DS1742 is not set
555# CONFIG_RTC_DRV_M48T86 is not set 643# CONFIG_RTC_DRV_M48T86 is not set
556# CONFIG_RTC_DRV_M48T59 is not set 644# CONFIG_RTC_DRV_M48T59 is not set
557# CONFIG_RTC_DRV_V3020 is not set 645# CONFIG_RTC_DRV_V3020 is not set
@@ -559,23 +647,6 @@ CONFIG_RTC_DRV_RS5C348=y
559# 647#
560# on-CPU RTC drivers 648# on-CPU RTC drivers
561# 649#
562
563#
564# DMA Engine support
565#
566# CONFIG_DMA_ENGINE is not set
567
568#
569# DMA Clients
570#
571
572#
573# DMA Devices
574#
575
576#
577# Userspace I/O
578#
579# CONFIG_UIO is not set 650# CONFIG_UIO is not set
580 651
581# 652#
@@ -588,12 +659,10 @@ CONFIG_RTC_DRV_RS5C348=y
588CONFIG_FS_POSIX_ACL=y 659CONFIG_FS_POSIX_ACL=y
589# CONFIG_XFS_FS is not set 660# CONFIG_XFS_FS is not set
590# CONFIG_OCFS2_FS is not set 661# CONFIG_OCFS2_FS is not set
591# CONFIG_MINIX_FS is not set 662# CONFIG_DNOTIFY is not set
592# CONFIG_ROMFS_FS is not set
593CONFIG_INOTIFY=y 663CONFIG_INOTIFY=y
594CONFIG_INOTIFY_USER=y 664CONFIG_INOTIFY_USER=y
595# CONFIG_QUOTA is not set 665# CONFIG_QUOTA is not set
596# CONFIG_DNOTIFY is not set
597# CONFIG_AUTOFS_FS is not set 666# CONFIG_AUTOFS_FS is not set
598# CONFIG_AUTOFS4_FS is not set 667# CONFIG_AUTOFS4_FS is not set
599# CONFIG_FUSE_FS is not set 668# CONFIG_FUSE_FS is not set
@@ -622,7 +691,7 @@ CONFIG_SYSFS=y
622CONFIG_TMPFS=y 691CONFIG_TMPFS=y
623CONFIG_TMPFS_POSIX_ACL=y 692CONFIG_TMPFS_POSIX_ACL=y
624# CONFIG_HUGETLB_PAGE is not set 693# CONFIG_HUGETLB_PAGE is not set
625CONFIG_RAMFS=y 694# CONFIG_CONFIGFS_FS is not set
626 695
627# 696#
628# Miscellaneous filesystems 697# Miscellaneous filesystems
@@ -630,18 +699,16 @@ CONFIG_RAMFS=y
630# CONFIG_HFSPLUS_FS is not set 699# CONFIG_HFSPLUS_FS is not set
631# CONFIG_CRAMFS is not set 700# CONFIG_CRAMFS is not set
632# CONFIG_VXFS_FS is not set 701# CONFIG_VXFS_FS is not set
702# CONFIG_MINIX_FS is not set
633# CONFIG_HPFS_FS is not set 703# CONFIG_HPFS_FS is not set
634# CONFIG_QNX4FS_FS is not set 704# CONFIG_QNX4FS_FS is not set
705# CONFIG_ROMFS_FS is not set
635# CONFIG_SYSV_FS is not set 706# CONFIG_SYSV_FS is not set
636# CONFIG_UFS_FS is not set 707# CONFIG_UFS_FS is not set
637 708CONFIG_NETWORK_FILESYSTEMS=y
638#
639# Network File Systems
640#
641CONFIG_NFS_FS=y 709CONFIG_NFS_FS=y
642CONFIG_NFS_V3=y 710CONFIG_NFS_V3=y
643# CONFIG_NFS_V3_ACL is not set 711# CONFIG_NFS_V3_ACL is not set
644# CONFIG_NFS_DIRECTIO is not set
645# CONFIG_NFSD is not set 712# CONFIG_NFSD is not set
646CONFIG_ROOT_NFS=y 713CONFIG_ROOT_NFS=y
647CONFIG_LOCKD=y 714CONFIG_LOCKD=y
@@ -658,10 +725,6 @@ CONFIG_SUNRPC=y
658# 725#
659# CONFIG_PARTITION_ADVANCED is not set 726# CONFIG_PARTITION_ADVANCED is not set
660CONFIG_MSDOS_PARTITION=y 727CONFIG_MSDOS_PARTITION=y
661
662#
663# Native Language Support
664#
665# CONFIG_NLS is not set 728# CONFIG_NLS is not set
666 729
667# 730#
@@ -669,13 +732,15 @@ CONFIG_MSDOS_PARTITION=y
669# 732#
670CONFIG_TRACE_IRQFLAGS_SUPPORT=y 733CONFIG_TRACE_IRQFLAGS_SUPPORT=y
671# CONFIG_PRINTK_TIME is not set 734# CONFIG_PRINTK_TIME is not set
735CONFIG_ENABLE_WARN_DEPRECATED=y
672CONFIG_ENABLE_MUST_CHECK=y 736CONFIG_ENABLE_MUST_CHECK=y
737CONFIG_FRAME_WARN=1024
673# CONFIG_MAGIC_SYSRQ is not set 738# CONFIG_MAGIC_SYSRQ is not set
674# CONFIG_UNUSED_SYMBOLS is not set 739# CONFIG_UNUSED_SYMBOLS is not set
675# CONFIG_DEBUG_FS is not set 740CONFIG_DEBUG_FS=y
676# CONFIG_HEADERS_CHECK is not set 741# CONFIG_HEADERS_CHECK is not set
677# CONFIG_DEBUG_KERNEL is not set 742# CONFIG_DEBUG_KERNEL is not set
678CONFIG_CROSSCOMPILE=y 743# CONFIG_SAMPLES is not set
679CONFIG_CMDLINE="" 744CONFIG_CMDLINE=""
680CONFIG_SYS_SUPPORTS_KGDB=y 745CONFIG_SYS_SUPPORTS_KGDB=y
681 746
@@ -690,6 +755,7 @@ CONFIG_SYS_SUPPORTS_KGDB=y
690# Library routines 755# Library routines
691# 756#
692CONFIG_BITREVERSE=y 757CONFIG_BITREVERSE=y
758# CONFIG_GENERIC_FIND_FIRST_BIT is not set
693# CONFIG_CRC_CCITT is not set 759# CONFIG_CRC_CCITT is not set
694# CONFIG_CRC16 is not set 760# CONFIG_CRC16 is not set
695# CONFIG_CRC_ITU_T is not set 761# CONFIG_CRC_ITU_T is not set
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index 56371b860eb..0f4da0325ea 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
index 4b879980278..1ea97865f2c 100644
--- a/arch/mips/configs/sb1250-swarm_defconfig
+++ b/arch/mips/configs/sb1250-swarm_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24# CONFIG_MACH_VR41XX is not set 22# CONFIG_MACH_VR41XX is not set
diff --git a/arch/mips/configs/sead_defconfig b/arch/mips/configs/sead_defconfig
deleted file mode 100644
index 3ee75b15c0b..00000000000
--- a/arch/mips/configs/sead_defconfig
+++ /dev/null
@@ -1,642 +0,0 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.20
4# Sun Feb 18 21:28:10 2007
5#
6CONFIG_MIPS=y
7
8#
9# Machine selection
10#
11CONFIG_ZONE_DMA=y
12# CONFIG_MIPS_MTX1 is not set
13# CONFIG_MIPS_BOSPORUS is not set
14# CONFIG_MIPS_PB1000 is not set
15# CONFIG_MIPS_PB1100 is not set
16# CONFIG_MIPS_PB1500 is not set
17# CONFIG_MIPS_PB1550 is not set
18# CONFIG_MIPS_PB1200 is not set
19# CONFIG_MIPS_DB1000 is not set
20# CONFIG_MIPS_DB1100 is not set
21# CONFIG_MIPS_DB1500 is not set
22# CONFIG_MIPS_DB1550 is not set
23# CONFIG_MIPS_DB1200 is not set
24# CONFIG_MIPS_MIRAGE is not set
25# CONFIG_BASLER_EXCITE is not set
26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set
31CONFIG_MIPS_SEAD=y
32# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set
35# CONFIG_MIPS_XXS1500 is not set
36# CONFIG_PNX8550_JBS is not set
37# CONFIG_PNX8550_STB810 is not set
38# CONFIG_MACH_VR41XX is not set
39# CONFIG_PMC_YOSEMITE is not set
40# CONFIG_MARKEINS is not set
41# CONFIG_SGI_IP22 is not set
42# CONFIG_SGI_IP27 is not set
43# CONFIG_SGI_IP32 is not set
44# CONFIG_SIBYTE_BIGSUR is not set
45# CONFIG_SIBYTE_SWARM is not set
46# CONFIG_SIBYTE_SENTOSA is not set
47# CONFIG_SIBYTE_RHONE is not set
48# CONFIG_SIBYTE_CARMEL is not set
49# CONFIG_SIBYTE_LITTLESUR is not set
50# CONFIG_SIBYTE_CRHINE is not set
51# CONFIG_SIBYTE_CRHONE is not set
52# CONFIG_SNI_RM is not set
53# CONFIG_TOSHIBA_JMR3927 is not set
54# CONFIG_TOSHIBA_RBTX4927 is not set
55# CONFIG_TOSHIBA_RBTX4938 is not set
56CONFIG_RWSEM_GENERIC_SPINLOCK=y
57# CONFIG_ARCH_HAS_ILOG2_U32 is not set
58# CONFIG_ARCH_HAS_ILOG2_U64 is not set
59CONFIG_GENERIC_FIND_NEXT_BIT=y
60CONFIG_GENERIC_HWEIGHT=y
61CONFIG_GENERIC_CALIBRATE_DELAY=y
62CONFIG_GENERIC_TIME=y
63CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
64# CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ is not set
65CONFIG_DMA_NONCOHERENT=y
66CONFIG_DMA_NEED_PCI_MAP_STATE=y
67# CONFIG_CPU_BIG_ENDIAN is not set
68CONFIG_CPU_LITTLE_ENDIAN=y
69CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
70CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y
71CONFIG_IRQ_CPU=y
72CONFIG_MIPS_BOARDS_GEN=y
73CONFIG_MIPS_L1_CACHE_SHIFT=5
74
75#
76# CPU selection
77#
78CONFIG_CPU_MIPS32_R1=y
79# CONFIG_CPU_MIPS32_R2 is not set
80# CONFIG_CPU_MIPS64_R1 is not set
81# CONFIG_CPU_MIPS64_R2 is not set
82# CONFIG_CPU_R3000 is not set
83# CONFIG_CPU_TX39XX is not set
84# CONFIG_CPU_VR41XX is not set
85# CONFIG_CPU_R4300 is not set
86# CONFIG_CPU_R4X00 is not set
87# CONFIG_CPU_TX49XX is not set
88# CONFIG_CPU_R5000 is not set
89# CONFIG_CPU_R5432 is not set
90# CONFIG_CPU_R6000 is not set
91# CONFIG_CPU_NEVADA is not set
92# CONFIG_CPU_R8000 is not set
93# CONFIG_CPU_R10000 is not set
94# CONFIG_CPU_RM7000 is not set
95# CONFIG_CPU_RM9000 is not set
96# CONFIG_CPU_SB1 is not set
97CONFIG_SYS_HAS_CPU_MIPS32_R1=y
98CONFIG_SYS_HAS_CPU_MIPS32_R2=y
99CONFIG_SYS_HAS_CPU_MIPS64_R1=y
100CONFIG_CPU_MIPS32=y
101CONFIG_CPU_MIPSR1=y
102CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
103CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
104CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
105
106#
107# Kernel type
108#
109CONFIG_32BIT=y
110# CONFIG_64BIT is not set
111CONFIG_PAGE_SIZE_4KB=y
112# CONFIG_PAGE_SIZE_8KB is not set
113# CONFIG_PAGE_SIZE_16KB is not set
114# CONFIG_PAGE_SIZE_64KB is not set
115CONFIG_CPU_HAS_PREFETCH=y
116CONFIG_MIPS_MT_DISABLED=y
117# CONFIG_MIPS_MT_SMP is not set
118# CONFIG_MIPS_MT_SMTC is not set
119# CONFIG_MIPS_VPE_LOADER is not set
120# CONFIG_64BIT_PHYS_ADDR is not set
121CONFIG_CPU_HAS_LLSC=y
122# CONFIG_CPU_HAS_SMARTMIPS is not set
123CONFIG_CPU_HAS_SYNC=y
124CONFIG_GENERIC_HARDIRQS=y
125CONFIG_GENERIC_IRQ_PROBE=y
126CONFIG_CPU_SUPPORTS_HIGHMEM=y
127CONFIG_SYS_SUPPORTS_SMARTMIPS=y
128CONFIG_ARCH_FLATMEM_ENABLE=y
129CONFIG_SELECT_MEMORY_MODEL=y
130CONFIG_FLATMEM_MANUAL=y
131# CONFIG_DISCONTIGMEM_MANUAL is not set
132# CONFIG_SPARSEMEM_MANUAL is not set
133CONFIG_FLATMEM=y
134CONFIG_FLAT_NODE_MEM_MAP=y
135# CONFIG_SPARSEMEM_STATIC is not set
136CONFIG_SPLIT_PTLOCK_CPUS=4
137# CONFIG_RESOURCES_64BIT is not set
138CONFIG_ZONE_DMA_FLAG=1
139# CONFIG_HZ_48 is not set
140# CONFIG_HZ_100 is not set
141# CONFIG_HZ_128 is not set
142# CONFIG_HZ_250 is not set
143# CONFIG_HZ_256 is not set
144CONFIG_HZ_1000=y
145# CONFIG_HZ_1024 is not set
146CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
147CONFIG_HZ=1000
148CONFIG_PREEMPT_NONE=y
149# CONFIG_PREEMPT_VOLUNTARY is not set
150# CONFIG_PREEMPT is not set
151# CONFIG_KEXEC is not set
152CONFIG_LOCKDEP_SUPPORT=y
153CONFIG_STACKTRACE_SUPPORT=y
154CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
155
156#
157# Code maturity level options
158#
159CONFIG_EXPERIMENTAL=y
160CONFIG_BROKEN_ON_SMP=y
161CONFIG_INIT_ENV_ARG_LIMIT=32
162
163#
164# General setup
165#
166CONFIG_LOCALVERSION=""
167CONFIG_LOCALVERSION_AUTO=y
168# CONFIG_SWAP is not set
169CONFIG_SYSVIPC=y
170# CONFIG_IPC_NS is not set
171CONFIG_SYSVIPC_SYSCTL=y
172# CONFIG_BSD_PROCESS_ACCT is not set
173# CONFIG_UTS_NS is not set
174# CONFIG_IKCONFIG is not set
175CONFIG_SYSFS_DEPRECATED=y
176CONFIG_RELAY=y
177CONFIG_INITRAMFS_SOURCE=""
178# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
179CONFIG_SYSCTL=y
180CONFIG_EMBEDDED=y
181CONFIG_SYSCTL_SYSCALL=y
182CONFIG_KALLSYMS=y
183# CONFIG_KALLSYMS_EXTRA_PASS is not set
184# CONFIG_HOTPLUG is not set
185CONFIG_PRINTK=y
186CONFIG_BUG=y
187CONFIG_ELF_CORE=y
188CONFIG_BASE_FULL=y
189CONFIG_FUTEX=y
190CONFIG_EPOLL=y
191CONFIG_SHMEM=y
192CONFIG_SLAB=y
193CONFIG_VM_EVENT_COUNTERS=y
194CONFIG_RT_MUTEXES=y
195# CONFIG_TINY_SHMEM is not set
196CONFIG_BASE_SMALL=0
197# CONFIG_SLOB is not set
198
199#
200# Loadable module support
201#
202# CONFIG_MODULES is not set
203
204#
205# Block layer
206#
207CONFIG_BLOCK=y
208# CONFIG_LBD is not set
209# CONFIG_BLK_DEV_IO_TRACE is not set
210# CONFIG_LSF is not set
211
212#
213# IO Schedulers
214#
215CONFIG_IOSCHED_NOOP=y
216CONFIG_IOSCHED_AS=y
217CONFIG_IOSCHED_DEADLINE=y
218CONFIG_IOSCHED_CFQ=y
219CONFIG_DEFAULT_AS=y
220# CONFIG_DEFAULT_DEADLINE is not set
221# CONFIG_DEFAULT_CFQ is not set
222# CONFIG_DEFAULT_NOOP is not set
223CONFIG_DEFAULT_IOSCHED="anticipatory"
224
225#
226# Bus options (PCI, PCMCIA, EISA, ISA, TC)
227#
228CONFIG_MMU=y
229
230#
231# PCCARD (PCMCIA/CardBus) support
232#
233
234#
235# PCI Hotplug Support
236#
237
238#
239# Executable file formats
240#
241CONFIG_BINFMT_ELF=y
242# CONFIG_BINFMT_MISC is not set
243CONFIG_TRAD_SIGNALS=y
244
245#
246# Power management options
247#
248CONFIG_PM=y
249# CONFIG_PM_LEGACY is not set
250# CONFIG_PM_DEBUG is not set
251# CONFIG_PM_SYSFS_DEPRECATED is not set
252
253#
254# Networking
255#
256# CONFIG_NET is not set
257
258#
259# Device Drivers
260#
261
262#
263# Generic Driver Options
264#
265CONFIG_STANDALONE=y
266CONFIG_PREVENT_FIRMWARE_BUILD=y
267# CONFIG_SYS_HYPERVISOR is not set
268
269#
270# Connector - unified userspace <-> kernelspace linker
271#
272
273#
274# Memory Technology Devices (MTD)
275#
276# CONFIG_MTD is not set
277
278#
279# Parallel port support
280#
281# CONFIG_PARPORT is not set
282
283#
284# Plug and Play support
285#
286
287#
288# Block devices
289#
290# CONFIG_BLK_DEV_COW_COMMON is not set
291CONFIG_BLK_DEV_LOOP=y
292# CONFIG_BLK_DEV_CRYPTOLOOP is not set
293CONFIG_BLK_DEV_RAM=y
294CONFIG_BLK_DEV_RAM_COUNT=16
295CONFIG_BLK_DEV_RAM_SIZE=18432
296CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
297CONFIG_BLK_DEV_INITRD=y
298# CONFIG_CDROM_PKTCDVD is not set
299
300#
301# Misc devices
302#
303
304#
305# ATA/ATAPI/MFM/RLL support
306#
307# CONFIG_IDE is not set
308
309#
310# SCSI device support
311#
312CONFIG_RAID_ATTRS=y
313# CONFIG_SCSI is not set
314# CONFIG_SCSI_NETLINK is not set
315
316#
317# Serial ATA (prod) and Parallel ATA (experimental) drivers
318#
319# CONFIG_ATA is not set
320
321#
322# Multi-device support (RAID and LVM)
323#
324# CONFIG_MD is not set
325
326#
327# Fusion MPT device support
328#
329# CONFIG_FUSION is not set
330
331#
332# IEEE 1394 (FireWire) support
333#
334
335#
336# I2O device support
337#
338
339#
340# ISDN subsystem
341#
342
343#
344# Telephony Support
345#
346# CONFIG_PHONE is not set
347
348#
349# Input device support
350#
351# CONFIG_INPUT is not set
352
353#
354# Hardware I/O ports
355#
356# CONFIG_SERIO is not set
357# CONFIG_GAMEPORT is not set
358
359#
360# Character devices
361#
362# CONFIG_VT is not set
363# CONFIG_SERIAL_NONSTANDARD is not set
364
365#
366# Serial drivers
367#
368CONFIG_SERIAL_8250=y
369CONFIG_SERIAL_8250_CONSOLE=y
370CONFIG_SERIAL_8250_NR_UARTS=4
371CONFIG_SERIAL_8250_RUNTIME_UARTS=4
372# CONFIG_SERIAL_8250_EXTENDED is not set
373
374#
375# Non-8250 serial port support
376#
377CONFIG_SERIAL_CORE=y
378CONFIG_SERIAL_CORE_CONSOLE=y
379CONFIG_UNIX98_PTYS=y
380CONFIG_LEGACY_PTYS=y
381CONFIG_LEGACY_PTY_COUNT=256
382
383#
384# IPMI
385#
386# CONFIG_IPMI_HANDLER is not set
387
388#
389# Watchdog Cards
390#
391# CONFIG_WATCHDOG is not set
392# CONFIG_HW_RANDOM is not set
393# CONFIG_RTC is not set
394# CONFIG_GEN_RTC is not set
395# CONFIG_DTLK is not set
396# CONFIG_R3964 is not set
397# CONFIG_RAW_DRIVER is not set
398
399#
400# TPM devices
401#
402# CONFIG_TCG_TPM is not set
403
404#
405# I2C support
406#
407# CONFIG_I2C is not set
408
409#
410# SPI support
411#
412# CONFIG_SPI is not set
413# CONFIG_SPI_MASTER is not set
414
415#
416# Dallas's 1-wire bus
417#
418# CONFIG_W1 is not set
419
420#
421# Hardware Monitoring support
422#
423# CONFIG_HWMON is not set
424# CONFIG_HWMON_VID is not set
425
426#
427# Multimedia devices
428#
429# CONFIG_VIDEO_DEV is not set
430
431#
432# Digital Video Broadcasting Devices
433#
434
435#
436# Graphics support
437#
438# CONFIG_FIRMWARE_EDID is not set
439# CONFIG_FB is not set
440# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
441
442#
443# Sound
444#
445# CONFIG_SOUND is not set
446
447#
448# USB support
449#
450# CONFIG_USB_ARCH_HAS_HCD is not set
451# CONFIG_USB_ARCH_HAS_OHCI is not set
452# CONFIG_USB_ARCH_HAS_EHCI is not set
453
454#
455# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
456#
457
458#
459# USB Gadget Support
460#
461# CONFIG_USB_GADGET is not set
462
463#
464# MMC/SD Card support
465#
466# CONFIG_MMC is not set
467
468#
469# LED devices
470#
471# CONFIG_NEW_LEDS is not set
472
473#
474# LED drivers
475#
476
477#
478# LED Triggers
479#
480
481#
482# InfiniBand support
483#
484
485#
486# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
487#
488
489#
490# Real Time Clock
491#
492# CONFIG_RTC_CLASS is not set
493
494#
495# DMA Engine support
496#
497# CONFIG_DMA_ENGINE is not set
498
499#
500# DMA Clients
501#
502
503#
504# DMA Devices
505#
506
507#
508# Auxiliary Display support
509#
510
511#
512# Virtualization
513#
514
515#
516# File systems
517#
518CONFIG_EXT2_FS=y
519# CONFIG_EXT2_FS_XATTR is not set
520# CONFIG_EXT2_FS_XIP is not set
521# CONFIG_EXT3_FS is not set
522# CONFIG_EXT4DEV_FS is not set
523# CONFIG_REISERFS_FS is not set
524# CONFIG_JFS_FS is not set
525# CONFIG_FS_POSIX_ACL is not set
526# CONFIG_XFS_FS is not set
527# CONFIG_GFS2_FS is not set
528# CONFIG_MINIX_FS is not set
529# CONFIG_ROMFS_FS is not set
530CONFIG_INOTIFY=y
531CONFIG_INOTIFY_USER=y
532# CONFIG_QUOTA is not set
533CONFIG_DNOTIFY=y
534# CONFIG_AUTOFS_FS is not set
535# CONFIG_AUTOFS4_FS is not set
536CONFIG_FUSE_FS=y
537
538#
539# CD-ROM/DVD Filesystems
540#
541# CONFIG_ISO9660_FS is not set
542# CONFIG_UDF_FS is not set
543
544#
545# DOS/FAT/NT Filesystems
546#
547# CONFIG_MSDOS_FS is not set
548# CONFIG_VFAT_FS is not set
549# CONFIG_NTFS_FS is not set
550
551#
552# Pseudo filesystems
553#
554CONFIG_PROC_FS=y
555CONFIG_PROC_KCORE=y
556CONFIG_PROC_SYSCTL=y
557CONFIG_SYSFS=y
558# CONFIG_TMPFS is not set
559# CONFIG_HUGETLB_PAGE is not set
560CONFIG_RAMFS=y
561# CONFIG_CONFIGFS_FS is not set
562
563#
564# Miscellaneous filesystems
565#
566# CONFIG_ADFS_FS is not set
567# CONFIG_AFFS_FS is not set
568# CONFIG_HFS_FS is not set
569# CONFIG_HFSPLUS_FS is not set
570# CONFIG_BEFS_FS is not set
571# CONFIG_BFS_FS is not set
572# CONFIG_EFS_FS is not set
573# CONFIG_CRAMFS is not set
574# CONFIG_VXFS_FS is not set
575# CONFIG_HPFS_FS is not set
576# CONFIG_QNX4FS_FS is not set
577# CONFIG_SYSV_FS is not set
578# CONFIG_UFS_FS is not set
579
580#
581# Partition Types
582#
583CONFIG_PARTITION_ADVANCED=y
584# CONFIG_ACORN_PARTITION is not set
585# CONFIG_OSF_PARTITION is not set
586# CONFIG_AMIGA_PARTITION is not set
587# CONFIG_ATARI_PARTITION is not set
588# CONFIG_MAC_PARTITION is not set
589# CONFIG_MSDOS_PARTITION is not set
590# CONFIG_LDM_PARTITION is not set
591# CONFIG_SGI_PARTITION is not set
592# CONFIG_ULTRIX_PARTITION is not set
593# CONFIG_SUN_PARTITION is not set
594# CONFIG_KARMA_PARTITION is not set
595# CONFIG_EFI_PARTITION is not set
596
597#
598# Native Language Support
599#
600# CONFIG_NLS is not set
601
602#
603# Profiling support
604#
605# CONFIG_PROFILING is not set
606
607#
608# Kernel hacking
609#
610CONFIG_TRACE_IRQFLAGS_SUPPORT=y
611# CONFIG_PRINTK_TIME is not set
612CONFIG_ENABLE_MUST_CHECK=y
613# CONFIG_MAGIC_SYSRQ is not set
614# CONFIG_UNUSED_SYMBOLS is not set
615# CONFIG_DEBUG_FS is not set
616# CONFIG_HEADERS_CHECK is not set
617# CONFIG_DEBUG_KERNEL is not set
618CONFIG_LOG_BUF_SHIFT=14
619CONFIG_CROSSCOMPILE=y
620CONFIG_CMDLINE=""
621
622#
623# Security options
624#
625# CONFIG_KEYS is not set
626# CONFIG_SECURITY is not set
627
628#
629# Cryptographic options
630#
631# CONFIG_CRYPTO is not set
632
633#
634# Library routines
635#
636# CONFIG_CRC_CCITT is not set
637CONFIG_CRC16=y
638# CONFIG_CRC32 is not set
639# CONFIG_LIBCRC32C is not set
640CONFIG_PLIST=y
641CONFIG_HAS_IOMEM=y
642CONFIG_HAS_IOPORT=y
diff --git a/arch/mips/configs/tb0219_defconfig b/arch/mips/configs/tb0219_defconfig
index 8dd3ae39bca..b5059881bc7 100644
--- a/arch/mips/configs/tb0219_defconfig
+++ b/arch/mips/configs/tb0219_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24CONFIG_MACH_VR41XX=y 22CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
index 2ba240e897c..b06a716bf23 100644
--- a/arch/mips/configs/tb0226_defconfig
+++ b/arch/mips/configs/tb0226_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24CONFIG_MACH_VR41XX=y 22CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index a5d0f3c55ed..46512cf7ce0 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -16,9 +16,7 @@ CONFIG_MIPS=y
16# CONFIG_MACH_JAZZ is not set 16# CONFIG_MACH_JAZZ is not set
17# CONFIG_LASAT is not set 17# CONFIG_LASAT is not set
18# CONFIG_LEMOTE_FULONG is not set 18# CONFIG_LEMOTE_FULONG is not set
19# CONFIG_MIPS_ATLAS is not set
20# CONFIG_MIPS_MALTA is not set 19# CONFIG_MIPS_MALTA is not set
21# CONFIG_MIPS_SEAD is not set
22# CONFIG_MIPS_SIM is not set 20# CONFIG_MIPS_SIM is not set
23# CONFIG_MARKEINS is not set 21# CONFIG_MARKEINS is not set
24CONFIG_MACH_VR41XX=y 22CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
index edf90b321fe..b437eb7f867 100644
--- a/arch/mips/configs/workpad_defconfig
+++ b/arch/mips/configs/workpad_defconfig
@@ -14,9 +14,7 @@ CONFIG_MIPS=y
14# CONFIG_MACH_DECSTATION is not set 14# CONFIG_MACH_DECSTATION is not set
15# CONFIG_MACH_JAZZ is not set 15# CONFIG_MACH_JAZZ is not set
16# CONFIG_LEMOTE_FULONG is not set 16# CONFIG_LEMOTE_FULONG is not set
17# CONFIG_MIPS_ATLAS is not set
18# CONFIG_MIPS_MALTA is not set 17# CONFIG_MIPS_MALTA is not set
19# CONFIG_MIPS_SEAD is not set
20# CONFIG_MIPS_SIM is not set 18# CONFIG_MIPS_SIM is not set
21# CONFIG_MARKEINS is not set 19# CONFIG_MARKEINS is not set
22CONFIG_MACH_VR41XX=y 20CONFIG_MACH_VR41XX=y
diff --git a/arch/mips/configs/wrppmc_defconfig b/arch/mips/configs/wrppmc_defconfig
index 2e3c683b205..fc2c56731b9 100644
--- a/arch/mips/configs/wrppmc_defconfig
+++ b/arch/mips/configs/wrppmc_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32CONFIG_WR_PPMC=y 30CONFIG_WR_PPMC=y
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
index b6178ffbc52..7f86c43d1bd 100644
--- a/arch/mips/configs/yosemite_defconfig
+++ b/arch/mips/configs/yosemite_defconfig
@@ -26,9 +26,7 @@ CONFIG_ZONE_DMA=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_MACH_JAZZ is not set 28# CONFIG_MACH_JAZZ is not set
29# CONFIG_MIPS_ATLAS is not set
30# CONFIG_MIPS_MALTA is not set 29# CONFIG_MIPS_MALTA is not set
31# CONFIG_MIPS_SEAD is not set
32# CONFIG_WR_PPMC is not set 30# CONFIG_WR_PPMC is not set
33# CONFIG_MIPS_SIM is not set 31# CONFIG_MIPS_SIM is not set
34# CONFIG_MOMENCO_JAGUAR_ATX is not set 32# CONFIG_MOMENCO_JAGUAR_ATX is not set
diff --git a/arch/mips/emma2rh/common/prom.c b/arch/mips/emma2rh/common/prom.c
index 0f791eb6bb6..5e92b3a9c5b 100644
--- a/arch/mips/emma2rh/common/prom.c
+++ b/arch/mips/emma2rh/common/prom.c
@@ -34,12 +34,11 @@
34 34
35const char *get_system_type(void) 35const char *get_system_type(void)
36{ 36{
37 switch (mips_machtype) { 37#if defined(CONFIG_MARKEINS)
38 case MACH_NEC_MARKEINS: 38 return "NEC EMMA2RH Mark-eins";
39 return "NEC EMMA2RH Mark-eins"; 39#else
40 default: 40#error Unknown NEC board
41 return "Unknown NEC board"; 41#endif
42 }
43} 42}
44 43
45/* [jsun@junsun.net] PMON passes arguments in C main() style */ 44/* [jsun@junsun.net] PMON passes arguments in C main() style */
@@ -63,10 +62,10 @@ void __init prom_init(void)
63 } 62 }
64 63
65#if defined(CONFIG_MARKEINS) 64#if defined(CONFIG_MARKEINS)
66 mips_machtype = MACH_NEC_MARKEINS;
67 add_memory_region(0, EMMA2RH_RAM_SIZE, BOOT_MEM_RAM); 65 add_memory_region(0, EMMA2RH_RAM_SIZE, BOOT_MEM_RAM);
66#else
67#error Unknown NEC board
68#endif 68#endif
69
70} 69}
71 70
72void __init prom_free_prom_memory(void) 71void __init prom_free_prom_memory(void)
diff --git a/arch/mips/fw/arc/identify.c b/arch/mips/fw/arc/identify.c
index 23066985a73..0ce9acf10c3 100644
--- a/arch/mips/fw/arc/identify.c
+++ b/arch/mips/fw/arc/identify.c
@@ -22,7 +22,6 @@
22struct smatch { 22struct smatch {
23 char *arcname; 23 char *arcname;
24 char *liname; 24 char *liname;
25 int type;
26 int flags; 25 int flags;
27}; 26};
28 27
@@ -30,47 +29,38 @@ static struct smatch mach_table[] = {
30 { 29 {
31 .arcname = "SGI-IP22", 30 .arcname = "SGI-IP22",
32 .liname = "SGI Indy", 31 .liname = "SGI Indy",
33 .type = MACH_SGI_IP22,
34 .flags = PROM_FLAG_ARCS, 32 .flags = PROM_FLAG_ARCS,
35 }, { 33 }, {
36 .arcname = "SGI-IP27", 34 .arcname = "SGI-IP27",
37 .liname = "SGI Origin", 35 .liname = "SGI Origin",
38 .type = MACH_SGI_IP27,
39 .flags = PROM_FLAG_ARCS, 36 .flags = PROM_FLAG_ARCS,
40 }, { 37 }, {
41 .arcname = "SGI-IP28", 38 .arcname = "SGI-IP28",
42 .liname = "SGI IP28", 39 .liname = "SGI IP28",
43 .type = MACH_SGI_IP28,
44 .flags = PROM_FLAG_ARCS, 40 .flags = PROM_FLAG_ARCS,
45 }, { 41 }, {
46 .arcname = "SGI-IP30", 42 .arcname = "SGI-IP30",
47 .liname = "SGI Octane", 43 .liname = "SGI Octane",
48 .type = MACH_SGI_IP30,
49 .flags = PROM_FLAG_ARCS, 44 .flags = PROM_FLAG_ARCS,
50 }, { 45 }, {
51 .arcname = "SGI-IP32", 46 .arcname = "SGI-IP32",
52 .liname = "SGI O2", 47 .liname = "SGI O2",
53 .type = MACH_SGI_IP32,
54 .flags = PROM_FLAG_ARCS, 48 .flags = PROM_FLAG_ARCS,
55 }, { 49 }, {
56 .arcname = "Microsoft-Jazz", 50 .arcname = "Microsoft-Jazz",
57 .liname = "Jazz MIPS_Magnum_4000", 51 .liname = "Jazz MIPS_Magnum_4000",
58 .type = MACH_MIPS_MAGNUM_4000,
59 .flags = 0, 52 .flags = 0,
60 }, { 53 }, {
61 .arcname = "PICA-61", 54 .arcname = "PICA-61",
62 .liname = "Jazz Acer_PICA_61", 55 .liname = "Jazz Acer_PICA_61",
63 .type = MACH_ACER_PICA_61,
64 .flags = 0, 56 .flags = 0,
65 }, { 57 }, {
66 .arcname = "RM200PCI", 58 .arcname = "RM200PCI",
67 .liname = "SNI RM200_PCI", 59 .liname = "SNI RM200_PCI",
68 .type = MACH_SNI_RM200_PCI,
69 .flags = PROM_FLAG_DONT_FREE_TEMP, 60 .flags = PROM_FLAG_DONT_FREE_TEMP,
70 }, { 61 }, {
71 .arcname = "RM200PCI-R5K", 62 .arcname = "RM200PCI-R5K",
72 .liname = "SNI RM200_PCI-R5K", 63 .liname = "SNI RM200_PCI-R5K",
73 .type = MACH_SNI_RM200_PCI,
74 .flags = PROM_FLAG_DONT_FREE_TEMP, 64 .flags = PROM_FLAG_DONT_FREE_TEMP,
75 } 65 }
76}; 66};
@@ -121,6 +111,5 @@ void __init prom_identify_arch(void)
121 mach = string_to_mach(iname); 111 mach = string_to_mach(iname);
122 system_type = mach->liname; 112 system_type = mach->liname;
123 113
124 mips_machtype = mach->type;
125 prom_flags = mach->flags; 114 prom_flags = mach->flags;
126} 115}
diff --git a/arch/mips/gt64120/wrppmc/reset.c b/arch/mips/gt64120/wrppmc/reset.c
index c355cff38f6..cc5474b24f0 100644
--- a/arch/mips/gt64120/wrppmc/reset.c
+++ b/arch/mips/gt64120/wrppmc/reset.c
@@ -5,10 +5,12 @@
5 * 5 *
6 * Copyright (C) 1997 Ralf Baechle 6 * Copyright (C) 1997 Ralf Baechle
7 */ 7 */
8#include <linux/irqflags.h>
8#include <linux/kernel.h> 9#include <linux/kernel.h>
9 10
10#include <asm/cacheflush.h> 11#include <asm/cacheflush.h>
11#include <asm/mipsregs.h> 12#include <asm/mipsregs.h>
13#include <asm/processor.h>
12 14
13void wrppmc_machine_restart(char *command) 15void wrppmc_machine_restart(char *command)
14{ 16{
@@ -32,15 +34,7 @@ void wrppmc_machine_halt(void)
32 34
33 printk(KERN_NOTICE "You can safely turn off the power\n"); 35 printk(KERN_NOTICE "You can safely turn off the power\n");
34 while (1) { 36 while (1) {
35 __asm__( 37 if (cpu_wait)
36 ".set\tmips3\n\t" 38 cpu_wait();
37 "wait\n\t"
38 ".set\tmips0"
39 );
40 } 39 }
41} 40}
42
43void wrppmc_machine_power_off(void)
44{
45 wrppmc_machine_halt();
46}
diff --git a/arch/mips/gt64120/wrppmc/setup.c b/arch/mips/gt64120/wrppmc/setup.c
index 728ef6a80ed..ca65c84031a 100644
--- a/arch/mips/gt64120/wrppmc/setup.c
+++ b/arch/mips/gt64120/wrppmc/setup.c
@@ -98,11 +98,10 @@ void __init plat_mem_setup(void)
98{ 98{
99 extern void wrppmc_machine_restart(char *command); 99 extern void wrppmc_machine_restart(char *command);
100 extern void wrppmc_machine_halt(void); 100 extern void wrppmc_machine_halt(void);
101 extern void wrppmc_machine_power_off(void);
102 101
103 _machine_restart = wrppmc_machine_restart; 102 _machine_restart = wrppmc_machine_restart;
104 _machine_halt = wrppmc_machine_halt; 103 _machine_halt = wrppmc_machine_halt;
105 pm_power_off = wrppmc_machine_power_off; 104 pm_power_off = wrppmc_machine_halt;
106 105
107 /* This makes the operations of 'in/out[bwl]' to the 106 /* This makes the operations of 'in/out[bwl]' to the
108 * physical address ( < KSEG0) can work via KSEG1 107 * physical address ( < KSEG0) can work via KSEG1
diff --git a/arch/mips/jazz/setup.c b/arch/mips/jazz/setup.c
index a7947199c99..f60524e8bc4 100644
--- a/arch/mips/jazz/setup.c
+++ b/arch/mips/jazz/setup.c
@@ -76,10 +76,8 @@ void __init plat_mem_setup(void)
76 76
77 set_io_port_base(JAZZ_PORT_BASE); 77 set_io_port_base(JAZZ_PORT_BASE);
78#ifdef CONFIG_EISA 78#ifdef CONFIG_EISA
79 if (mips_machtype == MACH_MIPS_MAGNUM_4000) 79 EISA_bus = 1;
80 EISA_bus = 1;
81#endif 80#endif
82 isa_slot_offset = 0xe3000000;
83 81
84 /* request I/O space for devices used on all i[345]86 PCs */ 82 /* request I/O space for devices used on all i[345]86 PCs */
85 for (i = 0; i < ARRAY_SIZE(jazz_io_resources); i++) 83 for (i = 0; i < ARRAY_SIZE(jazz_io_resources); i++)
diff --git a/arch/mips/jmr3927/common/Makefile b/arch/mips/jmr3927/common/Makefile
deleted file mode 100644
index 8fd4fcccf10..00000000000
--- a/arch/mips/jmr3927/common/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for the common code of TOSHIBA JMR-TX3927 board
3#
4
5obj-y += prom.o puts.o
6
7EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jmr3927/common/puts.c b/arch/mips/jmr3927/common/puts.c
deleted file mode 100644
index c611ab49788..00000000000
--- a/arch/mips/jmr3927/common/puts.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Low level uart routines to directly access a TX[34]927 SIO.
5 *
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * ahennessy@mvista.com or source@mvista.com
9 *
10 * Copyright (C) 2000-2001 Toshiba Corporation
11 *
12 * Based on arch/mips/au1000/common/puts.c
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
18 *
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
22 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * You should have received a copy of the GNU General Public License along
31 * with this program; if not, write to the Free Software Foundation, Inc.,
32 * 675 Mass Ave, Cambridge, MA 02139, USA.
33 */
34
35#include <asm/jmr3927/tx3927.h>
36
37#define TIMEOUT 0xffffff
38
39void
40prom_putchar(char c)
41{
42 int i = 0;
43
44 do {
45 i++;
46 if (i>TIMEOUT)
47 break;
48 } while (!(tx3927_sioptr(1)->cisr & TXx927_SICISR_TXALS));
49 tx3927_sioptr(1)->tfifo = c;
50 return;
51}
52
53void
54puts(const char *cp)
55{
56 while (*cp)
57 prom_putchar(*cp++);
58 prom_putchar('\r');
59 prom_putchar('\n');
60}
diff --git a/arch/mips/jmr3927/rbhma3100/init.c b/arch/mips/jmr3927/rbhma3100/init.c
deleted file mode 100644
index 700b9cf8eb9..00000000000
--- a/arch/mips/jmr3927/rbhma3100/init.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ahennessy@mvista.com
5 *
6 * arch/mips/jmr3927/common/init.c
7 *
8 * Copyright (C) 2000-2001 Toshiba Corporation
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 <asm/bootinfo.h>
32#include <asm/jmr3927/jmr3927.h>
33
34extern void __init prom_init_cmdline(void);
35
36const char *get_system_type(void)
37{
38 return "Toshiba"
39#ifdef CONFIG_TOSHIBA_JMR3927
40 " JMR_TX3927"
41#endif
42 ;
43}
44
45extern void puts(const char *cp);
46
47void __init prom_init(void)
48{
49#ifdef CONFIG_TOSHIBA_JMR3927
50 /* CCFG */
51 if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0)
52 puts("Warning: TX3927 TLB off\n");
53#endif
54
55 prom_init_cmdline();
56 add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM);
57}
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 65e46a6d417..0fd31974ba2 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -20,9 +20,6 @@ obj-$(CONFIG_CSRC_R4K) += csrc-r4k.o
20obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o 20obj-$(CONFIG_CSRC_SB1250) += csrc-sb1250.o
21obj-$(CONFIG_SYNC_R4K) += sync-r4k.o 21obj-$(CONFIG_SYNC_R4K) += sync-r4k.o
22 22
23binfmt_irix-objs := irixelf.o irixinv.o irixioctl.o irixsig.o \
24 irix5sys.o sysirix.o
25
26obj-$(CONFIG_STACKTRACE) += stacktrace.o 23obj-$(CONFIG_STACKTRACE) += stacktrace.o
27obj-$(CONFIG_MODULES) += mips_ksyms.o module.o 24obj-$(CONFIG_MODULES) += mips_ksyms.o module.o
28 25
@@ -63,14 +60,13 @@ obj-$(CONFIG_I8259) += i8259.o
63obj-$(CONFIG_IRQ_CPU) += irq_cpu.o 60obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
64obj-$(CONFIG_IRQ_CPU_RM7K) += irq-rm7000.o 61obj-$(CONFIG_IRQ_CPU_RM7K) += irq-rm7000.o
65obj-$(CONFIG_IRQ_CPU_RM9K) += irq-rm9000.o 62obj-$(CONFIG_IRQ_CPU_RM9K) += irq-rm9000.o
66obj-$(CONFIG_MIPS_BOARDS_GEN) += irq-msc01.o 63obj-$(CONFIG_MIPS_MSC) += irq-msc01.o
67obj-$(CONFIG_IRQ_TXX9) += irq_txx9.o 64obj-$(CONFIG_IRQ_TXX9) += irq_txx9.o
68obj-$(CONFIG_IRQ_GT641XX) += irq-gt641xx.o 65obj-$(CONFIG_IRQ_GT641XX) += irq-gt641xx.o
69obj-$(CONFIG_IRQ_GIC) += irq-gic.o 66obj-$(CONFIG_IRQ_GIC) += irq-gic.o
70 67
71obj-$(CONFIG_32BIT) += scall32-o32.o 68obj-$(CONFIG_32BIT) += scall32-o32.o
72obj-$(CONFIG_64BIT) += scall64-64.o 69obj-$(CONFIG_64BIT) += scall64-64.o
73obj-$(CONFIG_BINFMT_IRIX) += binfmt_irix.o
74obj-$(CONFIG_MIPS32_COMPAT) += linux32.o ptrace32.o signal32.o 70obj-$(CONFIG_MIPS32_COMPAT) += linux32.o ptrace32.o signal32.o
75obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o 71obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o
76obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o 72obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o
diff --git a/arch/mips/kernel/early_printk.c b/arch/mips/kernel/early_printk.c
index 9dccfa4752b..9ae813eb782 100644
--- a/arch/mips/kernel/early_printk.c
+++ b/arch/mips/kernel/early_printk.c
@@ -10,6 +10,8 @@
10#include <linux/console.h> 10#include <linux/console.h>
11#include <linux/init.h> 11#include <linux/init.h>
12 12
13#include <asm/setup.h>
14
13extern void prom_putchar(char); 15extern void prom_putchar(char);
14 16
15static void __init 17static void __init
diff --git a/arch/mips/kernel/gpio_txx9.c b/arch/mips/kernel/gpio_txx9.c
index b1436a85799..c6854d9df92 100644
--- a/arch/mips/kernel/gpio_txx9.c
+++ b/arch/mips/kernel/gpio_txx9.c
@@ -47,23 +47,25 @@ static void txx9_gpio_set(struct gpio_chip *chip, unsigned int offset,
47 47
48static int txx9_gpio_dir_in(struct gpio_chip *chip, unsigned int offset) 48static int txx9_gpio_dir_in(struct gpio_chip *chip, unsigned int offset)
49{ 49{
50 spin_lock_irq(&txx9_gpio_lock); 50 unsigned long flags;
51 spin_lock_irqsave(&txx9_gpio_lock, flags);
51 __raw_writel(__raw_readl(&txx9_pioptr->dir) & ~(1 << offset), 52 __raw_writel(__raw_readl(&txx9_pioptr->dir) & ~(1 << offset),
52 &txx9_pioptr->dir); 53 &txx9_pioptr->dir);
53 mmiowb(); 54 mmiowb();
54 spin_unlock_irq(&txx9_gpio_lock); 55 spin_unlock_irqrestore(&txx9_gpio_lock, flags);
55 return 0; 56 return 0;
56} 57}
57 58
58static int txx9_gpio_dir_out(struct gpio_chip *chip, unsigned int offset, 59static int txx9_gpio_dir_out(struct gpio_chip *chip, unsigned int offset,
59 int value) 60 int value)
60{ 61{
61 spin_lock_irq(&txx9_gpio_lock); 62 unsigned long flags;
63 spin_lock_irqsave(&txx9_gpio_lock, flags);
62 txx9_gpio_set_raw(offset, value); 64 txx9_gpio_set_raw(offset, value);
63 __raw_writel(__raw_readl(&txx9_pioptr->dir) | (1 << offset), 65 __raw_writel(__raw_readl(&txx9_pioptr->dir) | (1 << offset),
64 &txx9_pioptr->dir); 66 &txx9_pioptr->dir);
65 mmiowb(); 67 mmiowb();
66 spin_unlock_irq(&txx9_gpio_lock); 68 spin_unlock_irqrestore(&txx9_gpio_lock, flags);
67 return 0; 69 return 0;
68} 70}
69 71
diff --git a/arch/mips/kernel/i8253.c b/arch/mips/kernel/i8253.c
index 38fa1a194bf..b6ac55162b9 100644
--- a/arch/mips/kernel/i8253.c
+++ b/arch/mips/kernel/i8253.c
@@ -80,7 +80,7 @@ static int pit_next_event(unsigned long delta, struct clock_event_device *evt)
80 * registered. This mechanism replaces the previous #ifdef LOCAL_APIC - 80 * registered. This mechanism replaces the previous #ifdef LOCAL_APIC -
81 * !using_apic_timer decisions in do_timer_interrupt_hook() 81 * !using_apic_timer decisions in do_timer_interrupt_hook()
82 */ 82 */
83struct clock_event_device pit_clockevent = { 83static struct clock_event_device pit_clockevent = {
84 .name = "pit", 84 .name = "pit",
85 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, 85 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
86 .set_mode = init_pit_timer, 86 .set_mode = init_pit_timer,
diff --git a/arch/mips/kernel/irix5sys.S b/arch/mips/kernel/irix5sys.S
deleted file mode 100644
index eeef891093e..00000000000
--- a/arch/mips/kernel/irix5sys.S
+++ /dev/null
@@ -1,1041 +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 * 32-bit IRIX5 ABI system call table derived from original file 'irix5sys.h'
7 * created by David S. Miller.
8 *
9 * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
10 * Copyright (C) 2004 Steven J. Hill <sjhill@realitydiluted.com>
11 */
12#include <asm/asm.h>
13
14 /*
15 * Key:
16 * V == Valid and should work as expected for most cases.
17 * HV == Half Valid, some things will work, some likely will not
18 * IV == InValid, certainly will not work at all yet
19 * ?V == ?'ably Valid, I have not done enough looking into it
20 * DC == Don't Care, a rats ass we couldn't give
21 */
22
23 .macro irix5syscalltable
24
25 sys sys_syscall 0 /* 1000 sysindir() V*/
26 sys sys_exit 1 /* 1001 exit() V*/
27 sys sys_fork 0 /* 1002 fork() V*/
28 sys sys_read 3 /* 1003 read() V*/
29 sys sys_write 3 /* 1004 write() V*/
30 sys sys_open 3 /* 1005 open() V*/
31 sys sys_close 1 /* 1006 close() V*/
32 sys irix_unimp 0 /* 1007 (XXX IRIX 4 wait) V*/
33 sys sys_creat 2 /* 1008 creat() V*/
34 sys sys_link 2 /* 1009 link() V*/
35 sys sys_unlink 1 /* 1010 unlink() V*/
36 sys irix_exec 0 /* 1011 exec() V*/
37 sys sys_chdir 1 /* 1012 chdir() V*/
38 sys irix_gtime 0 /* 1013 time() V*/
39 sys irix_unimp 0 /* 1014 (XXX IRIX 4 mknod) V*/
40 sys sys_chmod 2 /* 1015 chmod() V*/
41 sys sys_chown 3 /* 1016 chown() V*/
42 sys irix_brk 1 /* 1017 break() V*/
43 sys irix_unimp 0 /* 1018 (XXX IRIX 4 stat) V*/
44 sys sys_lseek 3 /* 1019 lseek() XXX64bit HV*/
45 sys irix_getpid 0 /* 1020 getpid() V*/
46 sys irix_mount 6 /* 1021 mount() IV*/
47 sys sys_umount 1 /* 1022 umount() V*/
48 sys sys_setuid 1 /* 1023 setuid() V*/
49 sys irix_getuid 0 /* 1024 getuid() V*/
50 sys irix_stime 1 /* 1025 stime() V*/
51 sys irix_unimp 4 /* 1026 XXX ptrace() IV*/
52 sys irix_alarm 1 /* 1027 alarm() V*/
53 sys irix_unimp 0 /* 1028 (XXX IRIX 4 fstat) V*/
54 sys irix_pause 0 /* 1029 pause() V*/
55 sys sys_utime 2 /* 1030 utime() V*/
56 sys irix_unimp 0 /* 1031 nuthin' V*/
57 sys irix_unimp 0 /* 1032 nobody home man... V*/
58 sys sys_access 2 /* 1033 access() V*/
59 sys sys_nice 1 /* 1034 nice() V*/
60 sys irix_statfs 2 /* 1035 statfs() V*/
61 sys sys_sync 0 /* 1036 sync() V*/
62 sys sys_kill 2 /* 1037 kill() V*/
63 sys irix_fstatfs 2 /* 1038 fstatfs() V*/
64 sys irix_setpgrp 1 /* 1039 setpgrp() V*/
65 sys irix_syssgi 0 /* 1040 syssgi() HV*/
66 sys sys_dup 1 /* 1041 dup() V*/
67 sys sys_pipe 0 /* 1042 pipe() V*/
68 sys irix_times 1 /* 1043 times() V*/
69 sys irix_unimp 0 /* 1044 XXX profil() IV*/
70 sys irix_unimp 0 /* 1045 XXX lock() IV*/
71 sys sys_setgid 1 /* 1046 setgid() V*/
72 sys irix_getgid 0 /* 1047 getgid() V*/
73 sys irix_unimp 0 /* 1048 (XXX IRIX 4 ssig) V*/
74 sys irix_msgsys 6 /* 1049 sys_msgsys V*/
75 sys sys_sysmips 4 /* 1050 sysmips() HV*/
76 sys irix_unimp 0 /* 1051 XXX sysacct() IV*/
77 sys irix_shmsys 5 /* 1052 sys_shmsys V*/
78 sys irix_semsys 0 /* 1053 sys_semsys V*/
79 sys irix_ioctl 3 /* 1054 ioctl() HV*/
80 sys irix_uadmin 0 /* 1055 XXX sys_uadmin() HC*/
81 sys irix_sysmp 0 /* 1056 sysmp() HV*/
82 sys irix_utssys 4 /* 1057 sys_utssys() HV*/
83 sys irix_unimp 0 /* 1058 nada enchilada V*/
84 sys irix_exece 0 /* 1059 exece() V*/
85 sys sys_umask 1 /* 1060 umask() V*/
86 sys sys_chroot 1 /* 1061 chroot() V*/
87 sys irix_fcntl 3 /* 1062 fcntl() ?V*/
88 sys irix_ulimit 2 /* 1063 ulimit() HV*/
89 sys irix_unimp 0 /* 1064 XXX AFS shit DC*/
90 sys irix_unimp 0 /* 1065 XXX AFS shit DC*/
91 sys irix_unimp 0 /* 1066 XXX AFS shit DC*/
92 sys irix_unimp 0 /* 1067 XXX AFS shit DC*/
93 sys irix_unimp 0 /* 1068 XXX AFS shit DC*/
94 sys irix_unimp 0 /* 1069 XXX AFS shit DC*/
95 sys irix_unimp 0 /* 1070 XXX AFS shit DC*/
96 sys irix_unimp 0 /* 1071 XXX AFS shit DC*/
97 sys irix_unimp 0 /* 1072 XXX AFS shit DC*/
98 sys irix_unimp 0 /* 1073 XXX AFS shit DC*/
99 sys irix_unimp 0 /* 1074 nuttin' V*/
100 sys irix_unimp 0 /* 1075 XXX sys_getrlimit64()IV*/
101 sys irix_unimp 0 /* 1076 XXX sys_setrlimit64()IV*/
102 sys sys_nanosleep 2 /* 1077 nanosleep() V*/
103 sys irix_lseek64 5 /* 1078 lseek64() ?V*/
104 sys sys_rmdir 1 /* 1079 rmdir() V*/
105 sys sys_mkdir 2 /* 1080 mkdir() V*/
106 sys sys_getdents 3 /* 1081 getdents() V*/
107 sys irix_sginap 1 /* 1082 sys_sginap() V*/
108 sys irix_sgikopt 3 /* 1083 sys_sgikopt() DC*/
109 sys sys_sysfs 3 /* 1084 sysfs() ?V*/
110 sys irix_unimp 0 /* 1085 XXX sys_getmsg() DC*/
111 sys irix_unimp 0 /* 1086 XXX sys_putmsg() DC*/
112 sys sys_poll 3 /* 1087 poll() V*/
113 sys irix_sigreturn 0 /* 1088 sigreturn() ?V*/
114 sys sys_accept 3 /* 1089 accept() V*/
115 sys sys_bind 3 /* 1090 bind() V*/
116 sys sys_connect 3 /* 1091 connect() V*/
117 sys irix_gethostid 0 /* 1092 sys_gethostid() ?V*/
118 sys sys_getpeername 3 /* 1093 getpeername() V*/
119 sys sys_getsockname 3 /* 1094 getsockname() V*/
120 sys sys_getsockopt 5 /* 1095 getsockopt() V*/
121 sys sys_listen 2 /* 1096 listen() V*/
122 sys sys_recv 4 /* 1097 recv() V*/
123 sys sys_recvfrom 6 /* 1098 recvfrom() V*/
124 sys sys_recvmsg 3 /* 1099 recvmsg() V*/
125 sys sys_select 5 /* 1100 select() V*/
126 sys sys_send 4 /* 1101 send() V*/
127 sys sys_sendmsg 3 /* 1102 sendmsg() V*/
128 sys sys_sendto 6 /* 1103 sendto() V*/
129 sys irix_sethostid 1 /* 1104 sys_sethostid() ?V*/
130 sys sys_setsockopt 5 /* 1105 setsockopt() V*/
131 sys sys_shutdown 2 /* 1106 shutdown() ?V*/
132 sys irix_socket 3 /* 1107 socket() V*/
133 sys sys_gethostname 2 /* 1108 sys_gethostname() ?V*/
134 sys sys_sethostname 2 /* 1109 sethostname() ?V*/
135 sys irix_getdomainname 2 /* 1110 sys_getdomainname() ?V*/
136 sys sys_setdomainname 2 /* 1111 setdomainname() ?V*/
137 sys sys_truncate 2 /* 1112 truncate() V*/
138 sys sys_ftruncate 2 /* 1113 ftruncate() V*/
139 sys sys_rename 2 /* 1114 rename() V*/
140 sys sys_symlink 2 /* 1115 symlink() V*/
141 sys sys_readlink 3 /* 1116 readlink() V*/
142 sys irix_unimp 0 /* 1117 XXX IRIX 4 lstat() DC*/
143 sys irix_unimp 0 /* 1118 nothin' V*/
144 sys irix_unimp 0 /* 1119 XXX nfs_svc() DC*/
145 sys irix_unimp 0 /* 1120 XXX nfs_getfh() DC*/
146 sys irix_unimp 0 /* 1121 XXX async_daemon() DC*/
147 sys irix_unimp 0 /* 1122 XXX exportfs() DC*/
148 sys sys_setregid 2 /* 1123 setregid() V*/
149 sys sys_setreuid 2 /* 1124 setreuid() V*/
150 sys sys_getitimer 2 /* 1125 getitimer() V*/
151 sys sys_setitimer 3 /* 1126 setitimer() V*/
152 sys irix_unimp 1 /* 1127 XXX adjtime() IV*/
153 sys irix_gettimeofday 1 /* 1128 gettimeofday() V*/
154 sys irix_unimp 0 /* 1129 XXX sproc() IV*/
155 sys irix_prctl 0 /* 1130 prctl() HV*/
156 sys irix_unimp 0 /* 1131 XXX procblk() IV*/
157 sys irix_unimp 0 /* 1132 XXX sprocsp() IV*/
158 sys irix_unimp 0 /* 1133 XXX sgigsc() IV*/
159 sys irix_mmap32 6 /* 1134 mmap() XXXflags? ?V*/
160 sys sys_munmap 2 /* 1135 munmap() V*/
161 sys sys_mprotect 3 /* 1136 mprotect() V*/
162 sys sys_msync 4 /* 1137 msync() V*/
163 sys irix_madvise 3 /* 1138 madvise() DC*/
164 sys irix_pagelock 3 /* 1139 pagelock() IV*/
165 sys irix_getpagesize 0 /* 1140 getpagesize() V*/
166 sys irix_quotactl 0 /* 1141 quotactl() V*/
167 sys irix_unimp 0 /* 1142 nobody home man V*/
168 sys sys_getpgid 1 /* 1143 BSD getpgrp() V*/
169 sys irix_BSDsetpgrp 2 /* 1143 BSD setpgrp() V*/
170 sys sys_vhangup 0 /* 1144 vhangup() V*/
171 sys sys_fsync 1 /* 1145 fsync() V*/
172 sys sys_fchdir 1 /* 1146 fchdir() V*/
173 sys sys_getrlimit 2 /* 1147 getrlimit() ?V*/
174 sys sys_setrlimit 2 /* 1148 setrlimit() ?V*/
175 sys sys_cacheflush 3 /* 1150 cacheflush() HV*/
176 sys sys_cachectl 3 /* 1151 cachectl() HV*/
177 sys sys_fchown 3 /* 1152 fchown() ?V*/
178 sys sys_fchmod 2 /* 1153 fchmod() ?V*/
179 sys irix_unimp 0 /* 1154 XXX IRIX 4 wait3() V*/
180 sys sys_socketpair 4 /* 1155 socketpair() V*/
181 sys irix_systeminfo 3 /* 1156 systeminfo() IV*/
182 sys irix_uname 1 /* 1157 uname() IV*/
183 sys irix_xstat 3 /* 1158 xstat() V*/
184 sys irix_lxstat 3 /* 1159 lxstat() V*/
185 sys irix_fxstat 3 /* 1160 fxstat() V*/
186 sys irix_xmknod 0 /* 1161 xmknod() ?V*/
187 sys irix_sigaction 4 /* 1162 sigaction() ?V*/
188 sys irix_sigpending 1 /* 1163 sigpending() ?V*/
189 sys irix_sigprocmask 3 /* 1164 sigprocmask() ?V*/
190 sys irix_sigsuspend 0 /* 1165 sigsuspend() ?V*/
191 sys irix_sigpoll_sys 3 /* 1166 sigpoll_sys() IV*/
192 sys irix_swapctl 2 /* 1167 swapctl() IV*/
193 sys irix_getcontext 0 /* 1168 getcontext() HV*/
194 sys irix_setcontext 0 /* 1169 setcontext() HV*/
195 sys irix_waitsys 5 /* 1170 waitsys() IV*/
196 sys irix_sigstack 2 /* 1171 sigstack() HV*/
197 sys irix_sigaltstack 2 /* 1172 sigaltstack() HV*/
198 sys irix_sigsendset 2 /* 1173 sigsendset() IV*/
199 sys irix_statvfs 2 /* 1174 statvfs() V*/
200 sys irix_fstatvfs 2 /* 1175 fstatvfs() V*/
201 sys irix_unimp 0 /* 1176 XXX getpmsg() DC*/
202 sys irix_unimp 0 /* 1177 XXX putpmsg() DC*/
203 sys sys_lchown 3 /* 1178 lchown() V*/
204 sys irix_priocntl 0 /* 1179 priocntl() DC*/
205 sys irix_sigqueue 4 /* 1180 sigqueue() IV*/
206 sys sys_readv 3 /* 1181 readv() V*/
207 sys sys_writev 3 /* 1182 writev() V*/
208 sys irix_truncate64 4 /* 1183 truncate64() XX32bit HV*/
209 sys irix_ftruncate64 4 /* 1184 ftruncate64()XX32bit HV*/
210 sys irix_mmap64 0 /* 1185 mmap64() XX32bit HV*/
211 sys irix_dmi 0 /* 1186 dmi() DC*/
212 sys irix_pread 6 /* 1187 pread() IV*/
213 sys irix_pwrite 6 /* 1188 pwrite() IV*/
214 sys sys_fsync 1 /* 1189 fdatasync() XXPOSIX HV*/
215 sys irix_sgifastpath 7 /* 1190 sgifastpath() WHEEE IV*/
216 sys irix_unimp 0 /* 1191 XXX attr_get() DC*/
217 sys irix_unimp 0 /* 1192 XXX attr_getf() DC*/
218 sys irix_unimp 0 /* 1193 XXX attr_set() DC*/
219 sys irix_unimp 0 /* 1194 XXX attr_setf() DC*/
220 sys irix_unimp 0 /* 1195 XXX attr_remove() DC*/
221 sys irix_unimp 0 /* 1196 XXX attr_removef() DC*/
222 sys irix_unimp 0 /* 1197 XXX attr_list() DC*/
223 sys irix_unimp 0 /* 1198 XXX attr_listf() DC*/
224 sys irix_unimp 0 /* 1199 XXX attr_multi() DC*/
225 sys irix_unimp 0 /* 1200 XXX attr_multif() DC*/
226 sys irix_statvfs64 2 /* 1201 statvfs64() V*/
227 sys irix_fstatvfs64 2 /* 1202 fstatvfs64() V*/
228 sys irix_getmountid 2 /* 1203 getmountid()XXXfsids HV*/
229 sys irix_nsproc 5 /* 1204 nsproc() IV*/
230 sys irix_getdents64 3 /* 1205 getdents64() HV*/
231 sys irix_unimp 0 /* 1206 XXX DFS garbage DC*/
232 sys irix_ngetdents 4 /* 1207 ngetdents() XXXeop HV*/
233 sys irix_ngetdents64 4 /* 1208 ngetdents64() XXXeop HV*/
234 sys irix_unimp 0 /* 1209 nothin' V*/
235 sys irix_unimp 0 /* 1210 XXX pidsprocsp() */
236 sys irix_unimp 0 /* 1211 XXX rexec() */
237 sys irix_unimp 0 /* 1212 XXX timer_create() */
238 sys irix_unimp 0 /* 1213 XXX timer_delete() */
239 sys irix_unimp 0 /* 1214 XXX timer_settime() */
240 sys irix_unimp 0 /* 1215 XXX timer_gettime() */
241 sys irix_unimp 0 /* 1216 XXX timer_setoverrun() */
242 sys sys_sched_rr_get_interval 2 /* 1217 sched_rr_get_interval()V*/
243 sys sys_sched_yield 0 /* 1218 sched_yield() V*/
244 sys sys_sched_getscheduler 1 /* 1219 sched_getscheduler() V*/
245 sys sys_sched_setscheduler 3 /* 1220 sched_setscheduler() V*/
246 sys sys_sched_getparam 2 /* 1221 sched_getparam() V*/
247 sys sys_sched_setparam 2 /* 1222 sched_setparam() V*/
248 sys irix_unimp 0 /* 1223 XXX usync_cntl() */
249 sys irix_unimp 0 /* 1224 XXX psema_cntl() */
250 sys irix_unimp 0 /* 1225 XXX restartreturn() */
251
252 /* Just to pad things out nicely. */
253 sys irix_unimp 0
254 sys irix_unimp 0
255 sys irix_unimp 0
256 sys irix_unimp 0
257 sys irix_unimp 0
258 sys irix_unimp 0
259 sys irix_unimp 0
260 sys irix_unimp 0
261 sys irix_unimp 0
262 sys irix_unimp 0
263 sys irix_unimp 0
264 sys irix_unimp 0
265 sys irix_unimp 0
266 sys irix_unimp 0
267 sys irix_unimp 0
268 sys irix_unimp 0
269 sys irix_unimp 0
270 sys irix_unimp 0
271 sys irix_unimp 0
272 sys irix_unimp 0
273 sys irix_unimp 0
274 sys irix_unimp 0
275 sys irix_unimp 0
276 sys irix_unimp 0
277 sys irix_unimp 0
278 sys irix_unimp 0
279 sys irix_unimp 0
280 sys irix_unimp 0
281 sys irix_unimp 0
282 sys irix_unimp 0
283 sys irix_unimp 0
284 sys irix_unimp 0
285 sys irix_unimp 0
286 sys irix_unimp 0
287 sys irix_unimp 0
288 sys irix_unimp 0
289 sys irix_unimp 0
290 sys irix_unimp 0
291 sys irix_unimp 0
292 sys irix_unimp 0
293 sys irix_unimp 0
294 sys irix_unimp 0
295 sys irix_unimp 0
296 sys irix_unimp 0
297 sys irix_unimp 0
298 sys irix_unimp 0
299 sys irix_unimp 0
300 sys irix_unimp 0
301 sys irix_unimp 0
302 sys irix_unimp 0
303 sys irix_unimp 0
304 sys irix_unimp 0
305 sys irix_unimp 0
306 sys irix_unimp 0
307 sys irix_unimp 0
308 sys irix_unimp 0
309 sys irix_unimp 0
310 sys irix_unimp 0
311 sys irix_unimp 0
312 sys irix_unimp 0
313 sys irix_unimp 0
314 sys irix_unimp 0
315 sys irix_unimp 0
316 sys irix_unimp 0
317 sys irix_unimp 0
318 sys irix_unimp 0
319 sys irix_unimp 0
320 sys irix_unimp 0
321 sys irix_unimp 0
322 sys irix_unimp 0
323 sys irix_unimp 0
324 sys irix_unimp 0
325 sys irix_unimp 0
326 sys irix_unimp 0
327 sys irix_unimp 0
328 sys irix_unimp 0
329 sys irix_unimp 0
330 sys irix_unimp 0
331 sys irix_unimp 0
332 sys irix_unimp 0
333 sys irix_unimp 0
334 sys irix_unimp 0
335 sys irix_unimp 0
336 sys irix_unimp 0
337 sys irix_unimp 0
338 sys irix_unimp 0
339 sys irix_unimp 0
340 sys irix_unimp 0
341 sys irix_unimp 0
342 sys irix_unimp 0
343 sys irix_unimp 0
344 sys irix_unimp 0
345 sys irix_unimp 0
346 sys irix_unimp 0
347 sys irix_unimp 0
348 sys irix_unimp 0
349 sys irix_unimp 0
350 sys irix_unimp 0
351 sys irix_unimp 0
352 sys irix_unimp 0
353 sys irix_unimp 0
354 sys irix_unimp 0
355 sys irix_unimp 0
356 sys irix_unimp 0
357 sys irix_unimp 0
358 sys irix_unimp 0
359 sys irix_unimp 0
360 sys irix_unimp 0
361 sys irix_unimp 0
362 sys irix_unimp 0
363 sys irix_unimp 0
364 sys irix_unimp 0
365 sys irix_unimp 0
366 sys irix_unimp 0
367 sys irix_unimp 0
368 sys irix_unimp 0
369 sys irix_unimp 0
370 sys irix_unimp 0
371 sys irix_unimp 0
372 sys irix_unimp 0
373 sys irix_unimp 0
374 sys irix_unimp 0
375 sys irix_unimp 0
376 sys irix_unimp 0
377 sys irix_unimp 0
378 sys irix_unimp 0
379 sys irix_unimp 0
380 sys irix_unimp 0
381 sys irix_unimp 0
382 sys irix_unimp 0
383 sys irix_unimp 0
384 sys irix_unimp 0
385 sys irix_unimp 0
386 sys irix_unimp 0
387 sys irix_unimp 0
388 sys irix_unimp 0
389 sys irix_unimp 0
390 sys irix_unimp 0
391 sys irix_unimp 0
392 sys irix_unimp 0
393 sys irix_unimp 0
394 sys irix_unimp 0
395 sys irix_unimp 0
396 sys irix_unimp 0
397 sys irix_unimp 0
398 sys irix_unimp 0
399 sys irix_unimp 0
400 sys irix_unimp 0
401 sys irix_unimp 0
402 sys irix_unimp 0
403 sys irix_unimp 0
404 sys irix_unimp 0
405 sys irix_unimp 0
406 sys irix_unimp 0
407 sys irix_unimp 0
408 sys irix_unimp 0
409 sys irix_unimp 0
410 sys irix_unimp 0
411 sys irix_unimp 0
412 sys irix_unimp 0
413 sys irix_unimp 0
414 sys irix_unimp 0
415 sys irix_unimp 0
416 sys irix_unimp 0
417 sys irix_unimp 0
418 sys irix_unimp 0
419 sys irix_unimp 0
420 sys irix_unimp 0
421 sys irix_unimp 0
422 sys irix_unimp 0
423 sys irix_unimp 0
424 sys irix_unimp 0
425 sys irix_unimp 0
426 sys irix_unimp 0
427 sys irix_unimp 0
428 sys irix_unimp 0
429 sys irix_unimp 0
430 sys irix_unimp 0
431 sys irix_unimp 0
432 sys irix_unimp 0
433 sys irix_unimp 0
434 sys irix_unimp 0
435 sys irix_unimp 0
436 sys irix_unimp 0
437 sys irix_unimp 0
438 sys irix_unimp 0
439 sys irix_unimp 0
440 sys irix_unimp 0
441 sys irix_unimp 0
442 sys irix_unimp 0
443 sys irix_unimp 0
444 sys irix_unimp 0
445 sys irix_unimp 0
446 sys irix_unimp 0
447 sys irix_unimp 0
448 sys irix_unimp 0
449 sys irix_unimp 0
450 sys irix_unimp 0
451 sys irix_unimp 0
452 sys irix_unimp 0
453 sys irix_unimp 0
454 sys irix_unimp 0
455 sys irix_unimp 0
456 sys irix_unimp 0
457 sys irix_unimp 0
458 sys irix_unimp 0
459 sys irix_unimp 0
460 sys irix_unimp 0
461 sys irix_unimp 0
462 sys irix_unimp 0
463 sys irix_unimp 0
464 sys irix_unimp 0
465 sys irix_unimp 0
466 sys irix_unimp 0
467 sys irix_unimp 0
468 sys irix_unimp 0
469 sys irix_unimp 0
470 sys irix_unimp 0
471 sys irix_unimp 0
472 sys irix_unimp 0
473 sys irix_unimp 0
474 sys irix_unimp 0
475 sys irix_unimp 0
476 sys irix_unimp 0
477 sys irix_unimp 0
478 sys irix_unimp 0
479 sys irix_unimp 0
480 sys irix_unimp 0
481 sys irix_unimp 0
482 sys irix_unimp 0
483 sys irix_unimp 0
484 sys irix_unimp 0
485 sys irix_unimp 0
486 sys irix_unimp 0
487 sys irix_unimp 0
488 sys irix_unimp 0
489 sys irix_unimp 0
490 sys irix_unimp 0
491 sys irix_unimp 0
492 sys irix_unimp 0
493 sys irix_unimp 0
494 sys irix_unimp 0
495 sys irix_unimp 0
496 sys irix_unimp 0
497 sys irix_unimp 0
498 sys irix_unimp 0
499 sys irix_unimp 0
500 sys irix_unimp 0
501 sys irix_unimp 0
502 sys irix_unimp 0
503 sys irix_unimp 0
504 sys irix_unimp 0
505 sys irix_unimp 0
506 sys irix_unimp 0
507 sys irix_unimp 0
508 sys irix_unimp 0
509 sys irix_unimp 0
510 sys irix_unimp 0
511 sys irix_unimp 0
512 sys irix_unimp 0
513 sys irix_unimp 0
514 sys irix_unimp 0
515 sys irix_unimp 0
516 sys irix_unimp 0
517 sys irix_unimp 0
518 sys irix_unimp 0
519 sys irix_unimp 0
520 sys irix_unimp 0
521 sys irix_unimp 0
522 sys irix_unimp 0
523 sys irix_unimp 0
524 sys irix_unimp 0
525 sys irix_unimp 0
526 sys irix_unimp 0
527 sys irix_unimp 0
528 sys irix_unimp 0
529 sys irix_unimp 0
530 sys irix_unimp 0
531 sys irix_unimp 0
532 sys irix_unimp 0
533 sys irix_unimp 0
534 sys irix_unimp 0
535 sys irix_unimp 0
536 sys irix_unimp 0
537 sys irix_unimp 0
538 sys irix_unimp 0
539 sys irix_unimp 0
540 sys irix_unimp 0
541 sys irix_unimp 0
542 sys irix_unimp 0
543 sys irix_unimp 0
544 sys irix_unimp 0
545 sys irix_unimp 0
546 sys irix_unimp 0
547 sys irix_unimp 0
548 sys irix_unimp 0
549 sys irix_unimp 0
550 sys irix_unimp 0
551 sys irix_unimp 0
552 sys irix_unimp 0
553 sys irix_unimp 0
554 sys irix_unimp 0
555 sys irix_unimp 0
556 sys irix_unimp 0
557 sys irix_unimp 0
558 sys irix_unimp 0
559 sys irix_unimp 0
560 sys irix_unimp 0
561 sys irix_unimp 0
562 sys irix_unimp 0
563 sys irix_unimp 0
564 sys irix_unimp 0
565 sys irix_unimp 0
566 sys irix_unimp 0
567 sys irix_unimp 0
568 sys irix_unimp 0
569 sys irix_unimp 0
570 sys irix_unimp 0
571 sys irix_unimp 0
572 sys irix_unimp 0
573 sys irix_unimp 0
574 sys irix_unimp 0
575 sys irix_unimp 0
576 sys irix_unimp 0
577 sys irix_unimp 0
578 sys irix_unimp 0
579 sys irix_unimp 0
580 sys irix_unimp 0
581 sys irix_unimp 0
582 sys irix_unimp 0
583 sys irix_unimp 0
584 sys irix_unimp 0
585 sys irix_unimp 0
586 sys irix_unimp 0
587 sys irix_unimp 0
588 sys irix_unimp 0
589 sys irix_unimp 0
590 sys irix_unimp 0
591 sys irix_unimp 0
592 sys irix_unimp 0
593 sys irix_unimp 0
594 sys irix_unimp 0
595 sys irix_unimp 0
596 sys irix_unimp 0
597 sys irix_unimp 0
598 sys irix_unimp 0
599 sys irix_unimp 0
600 sys irix_unimp 0
601 sys irix_unimp 0
602 sys irix_unimp 0
603 sys irix_unimp 0
604 sys irix_unimp 0
605 sys irix_unimp 0
606 sys irix_unimp 0
607 sys irix_unimp 0
608 sys irix_unimp 0
609 sys irix_unimp 0
610 sys irix_unimp 0
611 sys irix_unimp 0
612 sys irix_unimp 0
613 sys irix_unimp 0
614 sys irix_unimp 0
615 sys irix_unimp 0
616 sys irix_unimp 0
617 sys irix_unimp 0
618 sys irix_unimp 0
619 sys irix_unimp 0
620 sys irix_unimp 0
621 sys irix_unimp 0
622 sys irix_unimp 0
623 sys irix_unimp 0
624 sys irix_unimp 0
625 sys irix_unimp 0
626 sys irix_unimp 0
627 sys irix_unimp 0
628 sys irix_unimp 0
629 sys irix_unimp 0
630 sys irix_unimp 0
631 sys irix_unimp 0
632 sys irix_unimp 0
633 sys irix_unimp 0
634 sys irix_unimp 0
635 sys irix_unimp 0
636 sys irix_unimp 0
637 sys irix_unimp 0
638 sys irix_unimp 0
639 sys irix_unimp 0
640 sys irix_unimp 0
641 sys irix_unimp 0
642 sys irix_unimp 0
643 sys irix_unimp 0
644 sys irix_unimp 0
645 sys irix_unimp 0
646 sys irix_unimp 0
647 sys irix_unimp 0
648 sys irix_unimp 0
649 sys irix_unimp 0
650 sys irix_unimp 0
651 sys irix_unimp 0
652 sys irix_unimp 0
653 sys irix_unimp 0
654 sys irix_unimp 0
655 sys irix_unimp 0
656 sys irix_unimp 0
657 sys irix_unimp 0
658 sys irix_unimp 0
659 sys irix_unimp 0
660 sys irix_unimp 0
661 sys irix_unimp 0
662 sys irix_unimp 0
663 sys irix_unimp 0
664 sys irix_unimp 0
665 sys irix_unimp 0
666 sys irix_unimp 0
667 sys irix_unimp 0
668 sys irix_unimp 0
669 sys irix_unimp 0
670 sys irix_unimp 0
671 sys irix_unimp 0
672 sys irix_unimp 0
673 sys irix_unimp 0
674 sys irix_unimp 0
675 sys irix_unimp 0
676 sys irix_unimp 0
677 sys irix_unimp 0
678 sys irix_unimp 0
679 sys irix_unimp 0
680 sys irix_unimp 0
681 sys irix_unimp 0
682 sys irix_unimp 0
683 sys irix_unimp 0
684 sys irix_unimp 0
685 sys irix_unimp 0
686 sys irix_unimp 0
687 sys irix_unimp 0
688 sys irix_unimp 0
689 sys irix_unimp 0
690 sys irix_unimp 0
691 sys irix_unimp 0
692 sys irix_unimp 0
693 sys irix_unimp 0
694 sys irix_unimp 0
695 sys irix_unimp 0
696 sys irix_unimp 0
697 sys irix_unimp 0
698 sys irix_unimp 0
699 sys irix_unimp 0
700 sys irix_unimp 0
701 sys irix_unimp 0
702 sys irix_unimp 0
703 sys irix_unimp 0
704 sys irix_unimp 0
705 sys irix_unimp 0
706 sys irix_unimp 0
707 sys irix_unimp 0
708 sys irix_unimp 0
709 sys irix_unimp 0
710 sys irix_unimp 0
711 sys irix_unimp 0
712 sys irix_unimp 0
713 sys irix_unimp 0
714 sys irix_unimp 0
715 sys irix_unimp 0
716 sys irix_unimp 0
717 sys irix_unimp 0
718 sys irix_unimp 0
719 sys irix_unimp 0
720 sys irix_unimp 0
721 sys irix_unimp 0
722 sys irix_unimp 0
723 sys irix_unimp 0
724 sys irix_unimp 0
725 sys irix_unimp 0
726 sys irix_unimp 0
727 sys irix_unimp 0
728 sys irix_unimp 0
729 sys irix_unimp 0
730 sys irix_unimp 0
731 sys irix_unimp 0
732 sys irix_unimp 0
733 sys irix_unimp 0
734 sys irix_unimp 0
735 sys irix_unimp 0
736 sys irix_unimp 0
737 sys irix_unimp 0
738 sys irix_unimp 0
739 sys irix_unimp 0
740 sys irix_unimp 0
741 sys irix_unimp 0
742 sys irix_unimp 0
743 sys irix_unimp 0
744 sys irix_unimp 0
745 sys irix_unimp 0
746 sys irix_unimp 0
747 sys irix_unimp 0
748 sys irix_unimp 0
749 sys irix_unimp 0
750 sys irix_unimp 0
751 sys irix_unimp 0
752 sys irix_unimp 0
753 sys irix_unimp 0
754 sys irix_unimp 0
755 sys irix_unimp 0
756 sys irix_unimp 0
757 sys irix_unimp 0
758 sys irix_unimp 0
759 sys irix_unimp 0
760 sys irix_unimp 0
761 sys irix_unimp 0
762 sys irix_unimp 0
763 sys irix_unimp 0
764 sys irix_unimp 0
765 sys irix_unimp 0
766 sys irix_unimp 0
767 sys irix_unimp 0
768 sys irix_unimp 0
769 sys irix_unimp 0
770 sys irix_unimp 0
771 sys irix_unimp 0
772 sys irix_unimp 0
773 sys irix_unimp 0
774 sys irix_unimp 0
775 sys irix_unimp 0
776 sys irix_unimp 0
777 sys irix_unimp 0
778 sys irix_unimp 0
779 sys irix_unimp 0
780 sys irix_unimp 0
781 sys irix_unimp 0
782 sys irix_unimp 0
783 sys irix_unimp 0
784 sys irix_unimp 0
785 sys irix_unimp 0
786 sys irix_unimp 0
787 sys irix_unimp 0
788 sys irix_unimp 0
789 sys irix_unimp 0
790 sys irix_unimp 0
791 sys irix_unimp 0
792 sys irix_unimp 0
793 sys irix_unimp 0
794 sys irix_unimp 0
795 sys irix_unimp 0
796 sys irix_unimp 0
797 sys irix_unimp 0
798 sys irix_unimp 0
799 sys irix_unimp 0
800 sys irix_unimp 0
801 sys irix_unimp 0
802 sys irix_unimp 0
803 sys irix_unimp 0
804 sys irix_unimp 0
805 sys irix_unimp 0
806 sys irix_unimp 0
807 sys irix_unimp 0
808 sys irix_unimp 0
809 sys irix_unimp 0
810 sys irix_unimp 0
811 sys irix_unimp 0
812 sys irix_unimp 0
813 sys irix_unimp 0
814 sys irix_unimp 0
815 sys irix_unimp 0
816 sys irix_unimp 0
817 sys irix_unimp 0
818 sys irix_unimp 0
819 sys irix_unimp 0
820 sys irix_unimp 0
821 sys irix_unimp 0
822 sys irix_unimp 0
823 sys irix_unimp 0
824 sys irix_unimp 0
825 sys irix_unimp 0
826 sys irix_unimp 0
827 sys irix_unimp 0
828 sys irix_unimp 0
829 sys irix_unimp 0
830 sys irix_unimp 0
831 sys irix_unimp 0
832 sys irix_unimp 0
833 sys irix_unimp 0
834 sys irix_unimp 0
835 sys irix_unimp 0
836 sys irix_unimp 0
837 sys irix_unimp 0
838 sys irix_unimp 0
839 sys irix_unimp 0
840 sys irix_unimp 0
841 sys irix_unimp 0
842 sys irix_unimp 0
843 sys irix_unimp 0
844 sys irix_unimp 0
845 sys irix_unimp 0
846 sys irix_unimp 0
847 sys irix_unimp 0
848 sys irix_unimp 0
849 sys irix_unimp 0
850 sys irix_unimp 0
851 sys irix_unimp 0
852 sys irix_unimp 0
853 sys irix_unimp 0
854 sys irix_unimp 0
855 sys irix_unimp 0
856 sys irix_unimp 0
857 sys irix_unimp 0
858 sys irix_unimp 0
859 sys irix_unimp 0
860 sys irix_unimp 0
861 sys irix_unimp 0
862 sys irix_unimp 0
863 sys irix_unimp 0
864 sys irix_unimp 0
865 sys irix_unimp 0
866 sys irix_unimp 0
867 sys irix_unimp 0
868 sys irix_unimp 0
869 sys irix_unimp 0
870 sys irix_unimp 0
871 sys irix_unimp 0
872 sys irix_unimp 0
873 sys irix_unimp 0
874 sys irix_unimp 0
875 sys irix_unimp 0
876 sys irix_unimp 0
877 sys irix_unimp 0
878 sys irix_unimp 0
879 sys irix_unimp 0
880 sys irix_unimp 0
881 sys irix_unimp 0
882 sys irix_unimp 0
883 sys irix_unimp 0
884 sys irix_unimp 0
885 sys irix_unimp 0
886 sys irix_unimp 0
887 sys irix_unimp 0
888 sys irix_unimp 0
889 sys irix_unimp 0
890 sys irix_unimp 0
891 sys irix_unimp 0
892 sys irix_unimp 0
893 sys irix_unimp 0
894 sys irix_unimp 0
895 sys irix_unimp 0
896 sys irix_unimp 0
897 sys irix_unimp 0
898 sys irix_unimp 0
899 sys irix_unimp 0
900 sys irix_unimp 0
901 sys irix_unimp 0
902 sys irix_unimp 0
903 sys irix_unimp 0
904 sys irix_unimp 0
905 sys irix_unimp 0
906 sys irix_unimp 0
907 sys irix_unimp 0
908 sys irix_unimp 0
909 sys irix_unimp 0
910 sys irix_unimp 0
911 sys irix_unimp 0
912 sys irix_unimp 0
913 sys irix_unimp 0
914 sys irix_unimp 0
915 sys irix_unimp 0
916 sys irix_unimp 0
917 sys irix_unimp 0
918 sys irix_unimp 0
919 sys irix_unimp 0
920 sys irix_unimp 0
921 sys irix_unimp 0
922 sys irix_unimp 0
923 sys irix_unimp 0
924 sys irix_unimp 0
925 sys irix_unimp 0
926 sys irix_unimp 0
927 sys irix_unimp 0
928 sys irix_unimp 0
929 sys irix_unimp 0
930 sys irix_unimp 0
931 sys irix_unimp 0
932 sys irix_unimp 0
933 sys irix_unimp 0
934 sys irix_unimp 0
935 sys irix_unimp 0
936 sys irix_unimp 0
937 sys irix_unimp 0
938 sys irix_unimp 0
939 sys irix_unimp 0
940 sys irix_unimp 0
941 sys irix_unimp 0
942 sys irix_unimp 0
943 sys irix_unimp 0
944 sys irix_unimp 0
945 sys irix_unimp 0
946 sys irix_unimp 0
947 sys irix_unimp 0
948 sys irix_unimp 0
949 sys irix_unimp 0
950 sys irix_unimp 0
951 sys irix_unimp 0
952 sys irix_unimp 0
953 sys irix_unimp 0
954 sys irix_unimp 0
955 sys irix_unimp 0
956 sys irix_unimp 0
957 sys irix_unimp 0
958 sys irix_unimp 0
959 sys irix_unimp 0
960 sys irix_unimp 0
961 sys irix_unimp 0
962 sys irix_unimp 0
963 sys irix_unimp 0
964 sys irix_unimp 0
965 sys irix_unimp 0
966 sys irix_unimp 0
967 sys irix_unimp 0
968 sys irix_unimp 0
969 sys irix_unimp 0
970 sys irix_unimp 0
971 sys irix_unimp 0
972 sys irix_unimp 0
973 sys irix_unimp 0
974 sys irix_unimp 0
975 sys irix_unimp 0
976 sys irix_unimp 0
977 sys irix_unimp 0
978 sys irix_unimp 0
979 sys irix_unimp 0
980 sys irix_unimp 0
981 sys irix_unimp 0
982 sys irix_unimp 0
983 sys irix_unimp 0
984 sys irix_unimp 0
985 sys irix_unimp 0
986 sys irix_unimp 0
987 sys irix_unimp 0
988 sys irix_unimp 0
989 sys irix_unimp 0
990 sys irix_unimp 0
991 sys irix_unimp 0
992 sys irix_unimp 0
993 sys irix_unimp 0
994 sys irix_unimp 0
995 sys irix_unimp 0
996 sys irix_unimp 0
997 sys irix_unimp 0
998 sys irix_unimp 0
999 sys irix_unimp 0
1000 sys irix_unimp 0
1001 sys irix_unimp 0
1002 sys irix_unimp 0
1003 sys irix_unimp 0
1004 sys irix_unimp 0
1005 sys irix_unimp 0
1006 sys irix_unimp 0
1007 sys irix_unimp 0
1008 sys irix_unimp 0
1009 sys irix_unimp 0
1010 sys irix_unimp 0
1011 sys irix_unimp 0
1012 sys irix_unimp 0
1013 sys irix_unimp 0
1014 sys irix_unimp 0
1015 sys irix_unimp 0
1016 sys irix_unimp 0
1017 sys irix_unimp 0
1018 sys irix_unimp 0
1019 sys irix_unimp 0
1020 sys irix_unimp 0
1021 sys irix_unimp 0
1022 sys irix_unimp 0
1023 sys irix_unimp 0
1024 sys irix_unimp 0
1025 sys irix_unimp 0
1026 sys irix_unimp 0
1027
1028 .endm
1029
1030 /*
1031 * Pre-compute the number of _instruction_ bytes needed to load
1032 * or store the arguments 6-8. Negative values are ignored.
1033 */
1034 .macro sys function, nargs
1035 PTR \function
1036 LONG (\nargs << 2) - (5 << 2)
1037 .endm
1038
1039 .align 4
1040EXPORT(sys_call_table_irix5)
1041 irix5syscalltable
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
deleted file mode 100644
index 469c7237e5b..00000000000
--- a/arch/mips/kernel/irixelf.c
+++ /dev/null
@@ -1,1361 +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 * irixelf.c: Code to load IRIX ELF executables conforming to the MIPS ABI.
7 * Based off of work by Eric Youngdale.
8 *
9 * Copyright (C) 1993 - 1994 Eric Youngdale <ericy@cais.com>
10 * Copyright (C) 1996 - 2004 David S. Miller <dm@engr.sgi.com>
11 * Copyright (C) 2004 - 2005 Steven J. Hill <sjhill@realitydiluted.com>
12 */
13#undef DEBUG
14
15#include <linux/module.h>
16#include <linux/fs.h>
17#include <linux/stat.h>
18#include <linux/sched.h>
19#include <linux/mm.h>
20#include <linux/mman.h>
21#include <linux/a.out.h>
22#include <linux/errno.h>
23#include <linux/init.h>
24#include <linux/signal.h>
25#include <linux/binfmts.h>
26#include <linux/string.h>
27#include <linux/file.h>
28#include <linux/fcntl.h>
29#include <linux/ptrace.h>
30#include <linux/slab.h>
31#include <linux/shm.h>
32#include <linux/personality.h>
33#include <linux/elfcore.h>
34
35#include <asm/mipsregs.h>
36#include <asm/namei.h>
37#include <asm/prctl.h>
38#include <asm/uaccess.h>
39
40#define DLINFO_ITEMS 12
41
42#include <linux/elf.h>
43
44static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs);
45static int load_irix_library(struct file *);
46static int irix_core_dump(long signr, struct pt_regs * regs,
47 struct file *file, unsigned long limit);
48
49static struct linux_binfmt irix_format = {
50 .module = THIS_MODULE,
51 .load_binary = load_irix_binary,
52 .load_shlib = load_irix_library,
53 .core_dump = irix_core_dump,
54 .min_coredump = PAGE_SIZE,
55};
56
57/* Debugging routines. */
58static char *get_elf_p_type(Elf32_Word p_type)
59{
60#ifdef DEBUG
61 switch (p_type) {
62 case PT_NULL:
63 return "PT_NULL";
64 break;
65
66 case PT_LOAD:
67 return "PT_LOAD";
68 break;
69
70 case PT_DYNAMIC:
71 return "PT_DYNAMIC";
72 break;
73
74 case PT_INTERP:
75 return "PT_INTERP";
76 break;
77
78 case PT_NOTE:
79 return "PT_NOTE";
80 break;
81
82 case PT_SHLIB:
83 return "PT_SHLIB";
84 break;
85
86 case PT_PHDR:
87 return "PT_PHDR";
88 break;
89
90 case PT_LOPROC:
91 return "PT_LOPROC/REGINFO";
92 break;
93
94 case PT_HIPROC:
95 return "PT_HIPROC";
96 break;
97
98 default:
99 return "PT_BOGUS";
100 break;
101 }
102#endif
103}
104
105static void print_elfhdr(struct elfhdr *ehp)
106{
107 int i;
108
109 pr_debug("ELFHDR: e_ident<");
110 for (i = 0; i < (EI_NIDENT - 1); i++)
111 pr_debug("%x ", ehp->e_ident[i]);
112 pr_debug("%x>\n", ehp->e_ident[i]);
113 pr_debug(" e_type[%04x] e_machine[%04x] e_version[%08lx]\n",
114 (unsigned short) ehp->e_type, (unsigned short) ehp->e_machine,
115 (unsigned long) ehp->e_version);
116 pr_debug(" e_entry[%08lx] e_phoff[%08lx] e_shoff[%08lx] "
117 "e_flags[%08lx]\n",
118 (unsigned long) ehp->e_entry, (unsigned long) ehp->e_phoff,
119 (unsigned long) ehp->e_shoff, (unsigned long) ehp->e_flags);
120 pr_debug(" e_ehsize[%04x] e_phentsize[%04x] e_phnum[%04x]\n",
121 (unsigned short) ehp->e_ehsize,
122 (unsigned short) ehp->e_phentsize,
123 (unsigned short) ehp->e_phnum);
124 pr_debug(" e_shentsize[%04x] e_shnum[%04x] e_shstrndx[%04x]\n",
125 (unsigned short) ehp->e_shentsize,
126 (unsigned short) ehp->e_shnum,
127 (unsigned short) ehp->e_shstrndx);
128}
129
130static void print_phdr(int i, struct elf_phdr *ep)
131{
132 pr_debug("PHDR[%d]: p_type[%s] p_offset[%08lx] p_vaddr[%08lx] "
133 "p_paddr[%08lx]\n", i, get_elf_p_type(ep->p_type),
134 (unsigned long) ep->p_offset, (unsigned long) ep->p_vaddr,
135 (unsigned long) ep->p_paddr);
136 pr_debug(" p_filesz[%08lx] p_memsz[%08lx] p_flags[%08lx] "
137 "p_align[%08lx]\n", (unsigned long) ep->p_filesz,
138 (unsigned long) ep->p_memsz, (unsigned long) ep->p_flags,
139 (unsigned long) ep->p_align);
140}
141
142static void dump_phdrs(struct elf_phdr *ep, int pnum)
143{
144 int i;
145
146 for (i = 0; i < pnum; i++, ep++) {
147 if ((ep->p_type == PT_LOAD) ||
148 (ep->p_type == PT_INTERP) ||
149 (ep->p_type == PT_PHDR))
150 print_phdr(i, ep);
151 }
152}
153
154static void set_brk(unsigned long start, unsigned long end)
155{
156 start = PAGE_ALIGN(start);
157 end = PAGE_ALIGN(end);
158 if (end <= start)
159 return;
160 down_write(&current->mm->mmap_sem);
161 do_brk(start, end - start);
162 up_write(&current->mm->mmap_sem);
163}
164
165
166/* We need to explicitly zero any fractional pages
167 * after the data section (i.e. bss). This would
168 * contain the junk from the file that should not
169 * be in memory.
170 */
171static void padzero(unsigned long elf_bss)
172{
173 unsigned long nbyte;
174
175 nbyte = elf_bss & (PAGE_SIZE-1);
176 if (nbyte) {
177 nbyte = PAGE_SIZE - nbyte;
178 clear_user((void __user *) elf_bss, nbyte);
179 }
180}
181
182static unsigned long * create_irix_tables(char * p, int argc, int envc,
183 struct elfhdr * exec, unsigned int load_addr,
184 unsigned int interp_load_addr, struct pt_regs *regs,
185 struct elf_phdr *ephdr)
186{
187 elf_addr_t *argv;
188 elf_addr_t *envp;
189 elf_addr_t *sp, *csp;
190
191 pr_debug("create_irix_tables: p[%p] argc[%d] envc[%d] "
192 "load_addr[%08x] interp_load_addr[%08x]\n",
193 p, argc, envc, load_addr, interp_load_addr);
194
195 sp = (elf_addr_t *) (~15UL & (unsigned long) p);
196 csp = sp;
197 csp -= exec ? DLINFO_ITEMS*2 : 2;
198 csp -= envc+1;
199 csp -= argc+1;
200 csp -= 1; /* argc itself */
201 if ((unsigned long)csp & 15UL) {
202 sp -= (16UL - ((unsigned long)csp & 15UL)) / sizeof(*sp);
203 }
204
205 /*
206 * Put the ELF interpreter info on the stack
207 */
208#define NEW_AUX_ENT(nr, id, val) \
209 __put_user((id), sp+(nr*2)); \
210 __put_user((val), sp+(nr*2+1)); \
211
212 sp -= 2;
213 NEW_AUX_ENT(0, AT_NULL, 0);
214
215 if (exec) {
216 sp -= 11*2;
217
218 NEW_AUX_ENT(0, AT_PHDR, load_addr + exec->e_phoff);
219 NEW_AUX_ENT(1, AT_PHENT, sizeof(struct elf_phdr));
220 NEW_AUX_ENT(2, AT_PHNUM, exec->e_phnum);
221 NEW_AUX_ENT(3, AT_PAGESZ, ELF_EXEC_PAGESIZE);
222 NEW_AUX_ENT(4, AT_BASE, interp_load_addr);
223 NEW_AUX_ENT(5, AT_FLAGS, 0);
224 NEW_AUX_ENT(6, AT_ENTRY, (elf_addr_t) exec->e_entry);
225 NEW_AUX_ENT(7, AT_UID, (elf_addr_t) current->uid);
226 NEW_AUX_ENT(8, AT_EUID, (elf_addr_t) current->euid);
227 NEW_AUX_ENT(9, AT_GID, (elf_addr_t) current->gid);
228 NEW_AUX_ENT(10, AT_EGID, (elf_addr_t) current->egid);
229 }
230#undef NEW_AUX_ENT
231
232 sp -= envc+1;
233 envp = sp;
234 sp -= argc+1;
235 argv = sp;
236
237 __put_user((elf_addr_t)argc, --sp);
238 current->mm->arg_start = (unsigned long) p;
239 while (argc-->0) {
240 __put_user((unsigned long)p, argv++);
241 p += strlen_user(p);
242 }
243 __put_user((unsigned long) NULL, argv);
244 current->mm->arg_end = current->mm->env_start = (unsigned long) p;
245 while (envc-->0) {
246 __put_user((unsigned long)p, envp++);
247 p += strlen_user(p);
248 }
249 __put_user((unsigned long) NULL, envp);
250 current->mm->env_end = (unsigned long) p;
251 return sp;
252}
253
254
255/* This is much more generalized than the library routine read function,
256 * so we keep this separate. Technically the library read function
257 * is only provided so that we can read a.out libraries that have
258 * an ELF header.
259 */
260static unsigned int load_irix_interp(struct elfhdr * interp_elf_ex,
261 struct file * interpreter,
262 unsigned int *interp_load_addr)
263{
264 struct elf_phdr *elf_phdata = NULL;
265 struct elf_phdr *eppnt;
266 unsigned int len;
267 unsigned int load_addr;
268 int elf_bss;
269 int retval;
270 unsigned int last_bss;
271 int error;
272 int i;
273 unsigned int k;
274
275 elf_bss = 0;
276 last_bss = 0;
277 error = load_addr = 0;
278
279 print_elfhdr(interp_elf_ex);
280
281 /* First of all, some simple consistency checks */
282 if ((interp_elf_ex->e_type != ET_EXEC &&
283 interp_elf_ex->e_type != ET_DYN) ||
284 !interpreter->f_op->mmap) {
285 printk("IRIX interp has bad e_type %d\n", interp_elf_ex->e_type);
286 return 0xffffffff;
287 }
288
289 /* Now read in all of the header information */
290 if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > PAGE_SIZE) {
291 printk("IRIX interp header bigger than a page (%d)\n",
292 (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum));
293 return 0xffffffff;
294 }
295
296 elf_phdata = kmalloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum,
297 GFP_KERNEL);
298
299 if (!elf_phdata) {
300 printk("Cannot kmalloc phdata for IRIX interp.\n");
301 return 0xffffffff;
302 }
303
304 /* If the size of this structure has changed, then punt, since
305 * we will be doing the wrong thing.
306 */
307 if (interp_elf_ex->e_phentsize != 32) {
308 printk("IRIX interp e_phentsize == %d != 32 ",
309 interp_elf_ex->e_phentsize);
310 kfree(elf_phdata);
311 return 0xffffffff;
312 }
313
314 retval = kernel_read(interpreter, interp_elf_ex->e_phoff,
315 (char *) elf_phdata,
316 sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
317
318 dump_phdrs(elf_phdata, interp_elf_ex->e_phnum);
319
320 eppnt = elf_phdata;
321 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
322 if (eppnt->p_type == PT_LOAD) {
323 int elf_type = MAP_PRIVATE | MAP_DENYWRITE;
324 int elf_prot = 0;
325 unsigned long vaddr = 0;
326 if (eppnt->p_flags & PF_R)
327 elf_prot = PROT_READ;
328 if (eppnt->p_flags & PF_W)
329 elf_prot |= PROT_WRITE;
330 if (eppnt->p_flags & PF_X)
331 elf_prot |= PROT_EXEC;
332 elf_type |= MAP_FIXED;
333 vaddr = eppnt->p_vaddr;
334
335 pr_debug("INTERP do_mmap"
336 "(%p, %08lx, %08lx, %08lx, %08lx, %08lx) ",
337 interpreter, vaddr,
338 (unsigned long)
339 (eppnt->p_filesz + (eppnt->p_vaddr & 0xfff)),
340 (unsigned long)
341 elf_prot, (unsigned long) elf_type,
342 (unsigned long)
343 (eppnt->p_offset & 0xfffff000));
344
345 down_write(&current->mm->mmap_sem);
346 error = do_mmap(interpreter, vaddr,
347 eppnt->p_filesz + (eppnt->p_vaddr & 0xfff),
348 elf_prot, elf_type,
349 eppnt->p_offset & 0xfffff000);
350 up_write(&current->mm->mmap_sem);
351
352 if (error < 0 && error > -1024) {
353 printk("Aieee IRIX interp mmap error=%d\n",
354 error);
355 break; /* Real error */
356 }
357 pr_debug("error=%08lx ", (unsigned long) error);
358 if (!load_addr && interp_elf_ex->e_type == ET_DYN) {
359 load_addr = error;
360 pr_debug("load_addr = error ");
361 }
362
363 /*
364 * Find the end of the file mapping for this phdr, and
365 * keep track of the largest address we see for this.
366 */
367 k = eppnt->p_vaddr + eppnt->p_filesz;
368 if (k > elf_bss)
369 elf_bss = k;
370
371 /* Do the same thing for the memory mapping - between
372 * elf_bss and last_bss is the bss section.
373 */
374 k = eppnt->p_memsz + eppnt->p_vaddr;
375 if (k > last_bss)
376 last_bss = k;
377 pr_debug("\n");
378 }
379 }
380
381 /* Now use mmap to map the library into memory. */
382 if (error < 0 && error > -1024) {
383 pr_debug("got error %d\n", error);
384 kfree(elf_phdata);
385 return 0xffffffff;
386 }
387
388 /* Now fill out the bss section. First pad the last page up
389 * to the page boundary, and then perform a mmap to make sure
390 * that there are zero-mapped pages up to and including the
391 * last bss page.
392 */
393 pr_debug("padzero(%08lx) ", (unsigned long) (elf_bss));
394 padzero(elf_bss);
395 len = (elf_bss + 0xfff) & 0xfffff000; /* What we have mapped so far */
396
397 pr_debug("last_bss[%08lx] len[%08lx]\n", (unsigned long) last_bss,
398 (unsigned long) len);
399
400 /* Map the last of the bss segment */
401 if (last_bss > len) {
402 down_write(&current->mm->mmap_sem);
403 do_brk(len, (last_bss - len));
404 up_write(&current->mm->mmap_sem);
405 }
406 kfree(elf_phdata);
407
408 *interp_load_addr = load_addr;
409 return ((unsigned int) interp_elf_ex->e_entry);
410}
411
412/* Check sanity of IRIX elf executable header. */
413static int verify_binary(struct elfhdr *ehp, struct linux_binprm *bprm)
414{
415 if (memcmp(ehp->e_ident, ELFMAG, SELFMAG) != 0)
416 return -ENOEXEC;
417
418 /* First of all, some simple consistency checks */
419 if ((ehp->e_type != ET_EXEC && ehp->e_type != ET_DYN) ||
420 !bprm->file->f_op->mmap) {
421 return -ENOEXEC;
422 }
423
424 /* XXX Don't support N32 or 64bit binaries yet because they can
425 * XXX and do execute 64 bit instructions and expect all registers
426 * XXX to be 64 bit as well. We need to make the kernel save
427 * XXX all registers as 64bits on cpu's capable of this at
428 * XXX exception time plus frob the XTLB exception vector.
429 */
430 if ((ehp->e_flags & EF_MIPS_ABI2))
431 return -ENOEXEC;
432
433 return 0;
434}
435
436/*
437 * This is where the detailed check is performed. Irix binaries
438 * use interpreters with 'libc.so' in the name, so this function
439 * can differentiate between Linux and Irix binaries.
440 */
441static inline int look_for_irix_interpreter(char **name,
442 struct file **interpreter,
443 struct elfhdr *interp_elf_ex,
444 struct elf_phdr *epp,
445 struct linux_binprm *bprm, int pnum)
446{
447 int i;
448 int retval = -EINVAL;
449 struct file *file = NULL;
450
451 *name = NULL;
452 for (i = 0; i < pnum; i++, epp++) {
453 if (epp->p_type != PT_INTERP)
454 continue;
455
456 /* It is illegal to have two interpreters for one executable. */
457 if (*name != NULL)
458 goto out;
459
460 *name = kmalloc(epp->p_filesz + strlen(IRIX_EMUL), GFP_KERNEL);
461 if (!*name)
462 return -ENOMEM;
463
464 strcpy(*name, IRIX_EMUL);
465 retval = kernel_read(bprm->file, epp->p_offset, (*name + 16),
466 epp->p_filesz);
467 if (retval < 0)
468 goto out;
469
470 file = open_exec(*name);
471 if (IS_ERR(file)) {
472 retval = PTR_ERR(file);
473 goto out;
474 }
475 retval = kernel_read(file, 0, bprm->buf, 128);
476 if (retval < 0)
477 goto dput_and_out;
478
479 *interp_elf_ex = *(struct elfhdr *) bprm->buf;
480 }
481 *interpreter = file;
482 return 0;
483
484dput_and_out:
485 fput(file);
486out:
487 kfree(*name);
488 return retval;
489}
490
491static inline int verify_irix_interpreter(struct elfhdr *ihp)
492{
493 if (memcmp(ihp->e_ident, ELFMAG, SELFMAG) != 0)
494 return -ELIBBAD;
495 return 0;
496}
497
498#define EXEC_MAP_FLAGS (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE)
499
500static inline void map_executable(struct file *fp, struct elf_phdr *epp, int pnum,
501 unsigned int *estack, unsigned int *laddr,
502 unsigned int *scode, unsigned int *ebss,
503 unsigned int *ecode, unsigned int *edata,
504 unsigned int *ebrk)
505{
506 unsigned int tmp;
507 int i, prot;
508
509 for (i = 0; i < pnum; i++, epp++) {
510 if (epp->p_type != PT_LOAD)
511 continue;
512
513 /* Map it. */
514 prot = (epp->p_flags & PF_R) ? PROT_READ : 0;
515 prot |= (epp->p_flags & PF_W) ? PROT_WRITE : 0;
516 prot |= (epp->p_flags & PF_X) ? PROT_EXEC : 0;
517 down_write(&current->mm->mmap_sem);
518 (void) do_mmap(fp, (epp->p_vaddr & 0xfffff000),
519 (epp->p_filesz + (epp->p_vaddr & 0xfff)),
520 prot, EXEC_MAP_FLAGS,
521 (epp->p_offset & 0xfffff000));
522 up_write(&current->mm->mmap_sem);
523
524 /* Fixup location tracking vars. */
525 if ((epp->p_vaddr & 0xfffff000) < *estack)
526 *estack = (epp->p_vaddr & 0xfffff000);
527 if (!*laddr)
528 *laddr = epp->p_vaddr - epp->p_offset;
529 if (epp->p_vaddr < *scode)
530 *scode = epp->p_vaddr;
531
532 tmp = epp->p_vaddr + epp->p_filesz;
533 if (tmp > *ebss)
534 *ebss = tmp;
535 if ((epp->p_flags & PF_X) && *ecode < tmp)
536 *ecode = tmp;
537 if (*edata < tmp)
538 *edata = tmp;
539
540 tmp = epp->p_vaddr + epp->p_memsz;
541 if (tmp > *ebrk)
542 *ebrk = tmp;
543 }
544
545}
546
547static inline int map_interpreter(struct elf_phdr *epp, struct elfhdr *ihp,
548 struct file *interp, unsigned int *iladdr,
549 int pnum, mm_segment_t old_fs,
550 unsigned int *eentry)
551{
552 int i;
553
554 *eentry = 0xffffffff;
555 for (i = 0; i < pnum; i++, epp++) {
556 if (epp->p_type != PT_INTERP)
557 continue;
558
559 /* We should have fielded this error elsewhere... */
560 if (*eentry != 0xffffffff)
561 return -1;
562
563 set_fs(old_fs);
564 *eentry = load_irix_interp(ihp, interp, iladdr);
565 old_fs = get_fs();
566 set_fs(get_ds());
567
568 fput(interp);
569
570 if (*eentry == 0xffffffff)
571 return -1;
572 }
573 return 0;
574}
575
576/*
577 * IRIX maps a page at 0x200000 that holds information about the
578 * process and the system, here we map the page and fill the
579 * structure
580 */
581static int irix_map_prda_page(void)
582{
583 unsigned long v;
584 struct prda *pp;
585
586 down_write(&current->mm->mmap_sem);
587 v = do_brk(PRDA_ADDRESS, PAGE_SIZE);
588 up_write(&current->mm->mmap_sem);
589
590 if (v != PRDA_ADDRESS)
591 return v; /* v must be an error code */
592
593 pp = (struct prda *) v;
594 pp->prda_sys.t_pid = task_pid_vnr(current);
595 pp->prda_sys.t_prid = read_c0_prid();
596 pp->prda_sys.t_rpid = task_pid_vnr(current);
597
598 /* We leave the rest set to zero */
599
600 return 0;
601}
602
603
604
605/* These are the functions used to load ELF style executables and shared
606 * libraries. There is no binary dependent code anywhere else.
607 */
608static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
609{
610 struct elfhdr elf_ex, interp_elf_ex;
611 struct file *interpreter;
612 struct elf_phdr *elf_phdata, *elf_ihdr, *elf_ephdr;
613 unsigned int load_addr, elf_bss, elf_brk;
614 unsigned int elf_entry, interp_load_addr = 0;
615 unsigned int start_code, end_code, end_data, elf_stack;
616 int retval, has_interp, has_ephdr, size, i;
617 char *elf_interpreter;
618 mm_segment_t old_fs;
619
620 load_addr = 0;
621 has_interp = has_ephdr = 0;
622 elf_ihdr = elf_ephdr = NULL;
623 elf_ex = *((struct elfhdr *) bprm->buf);
624 retval = -ENOEXEC;
625
626 if (verify_binary(&elf_ex, bprm))
627 goto out;
628
629 /*
630 * Telling -o32 static binaries from Linux and Irix apart from each
631 * other is difficult. There are 2 differences to be noted for static
632 * binaries from the 2 operating systems:
633 *
634 * 1) Irix binaries have their .text section before their .init
635 * section. Linux binaries are just the opposite.
636 *
637 * 2) Irix binaries usually have <= 12 sections and Linux
638 * binaries have > 20.
639 *
640 * We will use Method #2 since Method #1 would require us to read in
641 * the section headers which is way too much overhead. This appears
642 * to work for everything we have ran into so far. If anyone has a
643 * better method to tell the binaries apart, I'm listening.
644 */
645 if (elf_ex.e_shnum > 20)
646 goto out;
647
648 print_elfhdr(&elf_ex);
649
650 /* Now read in all of the header information */
651 size = elf_ex.e_phentsize * elf_ex.e_phnum;
652 if (size > 65536)
653 goto out;
654 elf_phdata = kmalloc(size, GFP_KERNEL);
655 if (elf_phdata == NULL) {
656 retval = -ENOMEM;
657 goto out;
658 }
659
660 retval = kernel_read(bprm->file, elf_ex.e_phoff, (char *)elf_phdata, size);
661 if (retval < 0)
662 goto out_free_ph;
663
664 dump_phdrs(elf_phdata, elf_ex.e_phnum);
665
666 /* Set some things for later. */
667 for (i = 0; i < elf_ex.e_phnum; i++) {
668 switch (elf_phdata[i].p_type) {
669 case PT_INTERP:
670 has_interp = 1;
671 elf_ihdr = &elf_phdata[i];
672 break;
673 case PT_PHDR:
674 has_ephdr = 1;
675 elf_ephdr = &elf_phdata[i];
676 break;
677 };
678 }
679
680 pr_debug("\n");
681
682 elf_bss = 0;
683 elf_brk = 0;
684
685 elf_stack = 0xffffffff;
686 elf_interpreter = NULL;
687 start_code = 0xffffffff;
688 end_code = 0;
689 end_data = 0;
690
691 /*
692 * If we get a return value, we change the value to be ENOEXEC
693 * so that we can exit gracefully and the main binary format
694 * search loop in 'fs/exec.c' will move onto the next handler
695 * which should be the normal ELF binary handler.
696 */
697 retval = look_for_irix_interpreter(&elf_interpreter, &interpreter,
698 &interp_elf_ex, elf_phdata, bprm,
699 elf_ex.e_phnum);
700 if (retval) {
701 retval = -ENOEXEC;
702 goto out_free_file;
703 }
704
705 if (elf_interpreter) {
706 retval = verify_irix_interpreter(&interp_elf_ex);
707 if (retval)
708 goto out_free_interp;
709 }
710
711 /* OK, we are done with that, now set up the arg stuff,
712 * and then start this sucker up.
713 */
714 retval = -E2BIG;
715 if (!bprm->sh_bang && !bprm->p)
716 goto out_free_interp;
717
718 /* Flush all traces of the currently running executable */
719 retval = flush_old_exec(bprm);
720 if (retval)
721 goto out_free_dentry;
722
723 /* OK, This is the point of no return */
724 current->mm->end_data = 0;
725 current->mm->end_code = 0;
726 current->mm->mmap = NULL;
727 current->flags &= ~PF_FORKNOEXEC;
728 elf_entry = (unsigned int) elf_ex.e_entry;
729
730 /* Do this so that we can load the interpreter, if need be. We will
731 * change some of these later.
732 */
733 setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
734 current->mm->start_stack = bprm->p;
735
736 /* At this point, we assume that the image should be loaded at
737 * fixed address, not at a variable address.
738 */
739 old_fs = get_fs();
740 set_fs(get_ds());
741
742 map_executable(bprm->file, elf_phdata, elf_ex.e_phnum, &elf_stack,
743 &load_addr, &start_code, &elf_bss, &end_code,
744 &end_data, &elf_brk);
745
746 if (elf_interpreter) {
747 retval = map_interpreter(elf_phdata, &interp_elf_ex,
748 interpreter, &interp_load_addr,
749 elf_ex.e_phnum, old_fs, &elf_entry);
750 kfree(elf_interpreter);
751 if (retval) {
752 set_fs(old_fs);
753 printk("Unable to load IRIX ELF interpreter\n");
754 send_sig(SIGSEGV, current, 0);
755 retval = 0;
756 goto out_free_file;
757 }
758 }
759
760 set_fs(old_fs);
761
762 kfree(elf_phdata);
763 set_personality(PER_IRIX32);
764 set_binfmt(&irix_format);
765 compute_creds(bprm);
766 current->flags &= ~PF_FORKNOEXEC;
767 bprm->p = (unsigned long)
768 create_irix_tables((char *)bprm->p, bprm->argc, bprm->envc,
769 (elf_interpreter ? &elf_ex : NULL),
770 load_addr, interp_load_addr, regs, elf_ephdr);
771 current->mm->start_brk = current->mm->brk = elf_brk;
772 current->mm->end_code = end_code;
773 current->mm->start_code = start_code;
774 current->mm->end_data = end_data;
775 current->mm->start_stack = bprm->p;
776
777 /* Calling set_brk effectively mmaps the pages that we need for the
778 * bss and break sections.
779 */
780 set_brk(elf_bss, elf_brk);
781
782 /*
783 * IRIX maps a page at 0x200000 which holds some system
784 * information. Programs depend on this.
785 */
786 if (irix_map_prda_page())
787 goto out_free_dentry;
788
789 padzero(elf_bss);
790
791 pr_debug("(start_brk) %lx\n" , (long) current->mm->start_brk);
792 pr_debug("(end_code) %lx\n" , (long) current->mm->end_code);
793 pr_debug("(start_code) %lx\n" , (long) current->mm->start_code);
794 pr_debug("(end_data) %lx\n" , (long) current->mm->end_data);
795 pr_debug("(start_stack) %lx\n" , (long) current->mm->start_stack);
796 pr_debug("(brk) %lx\n" , (long) current->mm->brk);
797
798#if 0 /* XXX No fucking way dude... */
799 /* Why this, you ask??? Well SVr4 maps page 0 as read-only,
800 * and some applications "depend" upon this behavior.
801 * Since we do not have the power to recompile these, we
802 * emulate the SVr4 behavior. Sigh.
803 */
804 down_write(&current->mm->mmap_sem);
805 (void) do_mmap(NULL, 0, 4096, PROT_READ | PROT_EXEC,
806 MAP_FIXED | MAP_PRIVATE, 0);
807 up_write(&current->mm->mmap_sem);
808#endif
809
810 start_thread(regs, elf_entry, bprm->p);
811 if (current->ptrace & PT_PTRACED)
812 send_sig(SIGTRAP, current, 0);
813 return 0;
814out:
815 return retval;
816
817out_free_dentry:
818 allow_write_access(interpreter);
819 fput(interpreter);
820out_free_interp:
821 kfree(elf_interpreter);
822out_free_file:
823out_free_ph:
824 kfree(elf_phdata);
825 goto out;
826}
827
828/* This is really simpleminded and specialized - we are loading an
829 * a.out library that is given an ELF header.
830 */
831static int load_irix_library(struct file *file)
832{
833 struct elfhdr elf_ex;
834 struct elf_phdr *elf_phdata = NULL;
835 unsigned int len = 0;
836 int elf_bss = 0;
837 int retval;
838 unsigned int bss;
839 int error;
840 int i, j, k;
841
842 error = kernel_read(file, 0, (char *) &elf_ex, sizeof(elf_ex));
843 if (error != sizeof(elf_ex))
844 return -ENOEXEC;
845
846 if (memcmp(elf_ex.e_ident, ELFMAG, SELFMAG) != 0)
847 return -ENOEXEC;
848
849 /* First of all, some simple consistency checks. */
850 if (elf_ex.e_type != ET_EXEC || elf_ex.e_phnum > 2 ||
851 !file->f_op->mmap)
852 return -ENOEXEC;
853
854 /* Now read in all of the header information. */
855 if (sizeof(struct elf_phdr) * elf_ex.e_phnum > PAGE_SIZE)
856 return -ENOEXEC;
857
858 elf_phdata = kmalloc(sizeof(struct elf_phdr) * elf_ex.e_phnum, GFP_KERNEL);
859 if (elf_phdata == NULL)
860 return -ENOMEM;
861
862 retval = kernel_read(file, elf_ex.e_phoff, (char *) elf_phdata,
863 sizeof(struct elf_phdr) * elf_ex.e_phnum);
864
865 j = 0;
866 for (i=0; i<elf_ex.e_phnum; i++)
867 if ((elf_phdata + i)->p_type == PT_LOAD) j++;
868
869 if (j != 1) {
870 kfree(elf_phdata);
871 return -ENOEXEC;
872 }
873
874 while (elf_phdata->p_type != PT_LOAD) elf_phdata++;
875
876 /* Now use mmap to map the library into memory. */
877 down_write(&current->mm->mmap_sem);
878 error = do_mmap(file,
879 elf_phdata->p_vaddr & 0xfffff000,
880 elf_phdata->p_filesz + (elf_phdata->p_vaddr & 0xfff),
881 PROT_READ | PROT_WRITE | PROT_EXEC,
882 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE,
883 elf_phdata->p_offset & 0xfffff000);
884 up_write(&current->mm->mmap_sem);
885
886 k = elf_phdata->p_vaddr + elf_phdata->p_filesz;
887 if (k > elf_bss) elf_bss = k;
888
889 if (error != (elf_phdata->p_vaddr & 0xfffff000)) {
890 kfree(elf_phdata);
891 return error;
892 }
893
894 padzero(elf_bss);
895
896 len = (elf_phdata->p_filesz + elf_phdata->p_vaddr+ 0xfff) & 0xfffff000;
897 bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
898 if (bss > len) {
899 down_write(&current->mm->mmap_sem);
900 do_brk(len, bss-len);
901 up_write(&current->mm->mmap_sem);
902 }
903 kfree(elf_phdata);
904 return 0;
905}
906
907/* Called through irix_syssgi() to map an elf image given an FD,
908 * a phdr ptr USER_PHDRP in userspace, and a count CNT telling how many
909 * phdrs there are in the USER_PHDRP array. We return the vaddr the
910 * first phdr was successfully mapped to.
911 */
912unsigned long irix_mapelf(int fd, struct elf_phdr __user *user_phdrp, int cnt)
913{
914 unsigned long type, vaddr, filesz, offset, flags;
915 struct elf_phdr __user *hp;
916 struct file *filp;
917 int i, retval;
918
919 pr_debug("irix_mapelf: fd[%d] user_phdrp[%p] cnt[%d]\n",
920 fd, user_phdrp, cnt);
921
922 /* First get the verification out of the way. */
923 hp = user_phdrp;
924 if (!access_ok(VERIFY_READ, hp, (sizeof(struct elf_phdr) * cnt))) {
925 pr_debug("irix_mapelf: bad pointer to ELF PHDR!\n");
926
927 return -EFAULT;
928 }
929
930 dump_phdrs(user_phdrp, cnt);
931
932 for (i = 0; i < cnt; i++, hp++) {
933 if (__get_user(type, &hp->p_type))
934 return -EFAULT;
935 if (type != PT_LOAD) {
936 printk("irix_mapelf: One section is not PT_LOAD!\n");
937 return -ENOEXEC;
938 }
939 }
940
941 filp = fget(fd);
942 if (!filp)
943 return -EACCES;
944 if (!filp->f_op) {
945 printk("irix_mapelf: Bogon filp!\n");
946 fput(filp);
947 return -EACCES;
948 }
949
950 hp = user_phdrp;
951 for (i = 0; i < cnt; i++, hp++) {
952 int prot;
953
954 retval = __get_user(vaddr, &hp->p_vaddr);
955 retval |= __get_user(filesz, &hp->p_filesz);
956 retval |= __get_user(offset, &hp->p_offset);
957 retval |= __get_user(flags, &hp->p_flags);
958 if (retval)
959 return retval;
960
961 prot = (flags & PF_R) ? PROT_READ : 0;
962 prot |= (flags & PF_W) ? PROT_WRITE : 0;
963 prot |= (flags & PF_X) ? PROT_EXEC : 0;
964
965 down_write(&current->mm->mmap_sem);
966 retval = do_mmap(filp, (vaddr & 0xfffff000),
967 (filesz + (vaddr & 0xfff)),
968 prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE),
969 (offset & 0xfffff000));
970 up_write(&current->mm->mmap_sem);
971
972 if (retval != (vaddr & 0xfffff000)) {
973 printk("irix_mapelf: do_mmap fails with %d!\n", retval);
974 fput(filp);
975 return retval;
976 }
977 }
978
979 pr_debug("irix_mapelf: Success, returning %08lx\n",
980 (unsigned long) user_phdrp->p_vaddr);
981
982 fput(filp);
983
984 if (__get_user(vaddr, &user_phdrp->p_vaddr))
985 return -EFAULT;
986
987 return vaddr;
988}
989
990/*
991 * ELF core dumper
992 *
993 * Modelled on fs/exec.c:aout_core_dump()
994 * Jeremy Fitzhardinge <jeremy@sw.oz.au>
995 */
996
997/* These are the only things you should do on a core-file: use only these
998 * functions to write out all the necessary info.
999 */
1000static int dump_write(struct file *file, const void __user *addr, int nr)
1001{
1002 return file->f_op->write(file, (const char __user *) addr, nr, &file->f_pos) == nr;
1003}
1004
1005static int dump_seek(struct file *file, off_t off)
1006{
1007 if (file->f_op->llseek) {
1008 if (file->f_op->llseek(file, off, 0) != off)
1009 return 0;
1010 } else
1011 file->f_pos = off;
1012 return 1;
1013}
1014
1015/* Decide whether a segment is worth dumping; default is yes to be
1016 * sure (missing info is worse than too much; etc).
1017 * Personally I'd include everything, and use the coredump limit...
1018 *
1019 * I think we should skip something. But I am not sure how. H.J.
1020 */
1021static inline int maydump(struct vm_area_struct *vma)
1022{
1023 if (!(vma->vm_flags & (VM_READ|VM_WRITE|VM_EXEC)))
1024 return 0;
1025#if 1
1026 if (vma->vm_flags & (VM_WRITE|VM_GROWSUP|VM_GROWSDOWN))
1027 return 1;
1028 if (vma->vm_flags & (VM_READ|VM_EXEC|VM_EXECUTABLE|VM_SHARED))
1029 return 0;
1030#endif
1031 return 1;
1032}
1033
1034/* An ELF note in memory. */
1035struct memelfnote
1036{
1037 const char *name;
1038 int type;
1039 unsigned int datasz;
1040 void *data;
1041};
1042
1043static int notesize(struct memelfnote *en)
1044{
1045 int sz;
1046
1047 sz = sizeof(struct elf_note);
1048 sz += roundup(strlen(en->name) + 1, 4);
1049 sz += roundup(en->datasz, 4);
1050
1051 return sz;
1052}
1053
1054#define DUMP_WRITE(addr, nr) \
1055 if (!dump_write(file, (addr), (nr))) \
1056 goto end_coredump;
1057#define DUMP_SEEK(off) \
1058 if (!dump_seek(file, (off))) \
1059 goto end_coredump;
1060
1061static int writenote(struct memelfnote *men, struct file *file)
1062{
1063 struct elf_note en;
1064
1065 en.n_namesz = strlen(men->name) + 1;
1066 en.n_descsz = men->datasz;
1067 en.n_type = men->type;
1068
1069 DUMP_WRITE(&en, sizeof(en));
1070 DUMP_WRITE(men->name, en.n_namesz);
1071 /* XXX - cast from long long to long to avoid need for libgcc.a */
1072 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1073 DUMP_WRITE(men->data, men->datasz);
1074 DUMP_SEEK(roundup((unsigned long)file->f_pos, 4)); /* XXX */
1075
1076 return 1;
1077
1078end_coredump:
1079 return 0;
1080}
1081#undef DUMP_WRITE
1082#undef DUMP_SEEK
1083
1084#define DUMP_WRITE(addr, nr) \
1085 if (!dump_write(file, (addr), (nr))) \
1086 goto end_coredump;
1087#define DUMP_SEEK(off) \
1088 if (!dump_seek(file, (off))) \
1089 goto end_coredump;
1090
1091/* Actual dumper.
1092 *
1093 * This is a two-pass process; first we find the offsets of the bits,
1094 * and then they are actually written out. If we run out of core limit
1095 * we just truncate.
1096 */
1097static int irix_core_dump(long signr, struct pt_regs *regs, struct file *file, unsigned long limit)
1098{
1099 int has_dumped = 0;
1100 mm_segment_t fs;
1101 int segs;
1102 int i;
1103 size_t size;
1104 struct vm_area_struct *vma;
1105 struct elfhdr elf;
1106 off_t offset = 0, dataoff;
1107 int numnote = 3;
1108 struct memelfnote notes[3];
1109 struct elf_prstatus prstatus; /* NT_PRSTATUS */
1110 elf_fpregset_t fpu; /* NT_PRFPREG */
1111 struct elf_prpsinfo psinfo; /* NT_PRPSINFO */
1112
1113 /* Count what's needed to dump, up to the limit of coredump size. */
1114 segs = 0;
1115 size = 0;
1116 for (vma = current->mm->mmap; vma != NULL; vma = vma->vm_next) {
1117 if (maydump(vma))
1118 {
1119 int sz = vma->vm_end-vma->vm_start;
1120
1121 if (size+sz >= limit)
1122 break;
1123 else
1124 size += sz;
1125 }
1126
1127 segs++;
1128 }
1129 pr_debug("irix_core_dump: %d segs taking %d bytes\n", segs, size);
1130
1131 /* Set up header. */
1132 memcpy(elf.e_ident, ELFMAG, SELFMAG);
1133 elf.e_ident[EI_CLASS] = ELFCLASS32;
1134 elf.e_ident[EI_DATA] = ELFDATA2LSB;
1135 elf.e_ident[EI_VERSION] = EV_CURRENT;
1136 elf.e_ident[EI_OSABI] = ELF_OSABI;
1137 memset(elf.e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
1138
1139 elf.e_type = ET_CORE;
1140 elf.e_machine = ELF_ARCH;
1141 elf.e_version = EV_CURRENT;
1142 elf.e_entry = 0;
1143 elf.e_phoff = sizeof(elf);
1144 elf.e_shoff = 0;
1145 elf.e_flags = 0;
1146 elf.e_ehsize = sizeof(elf);
1147 elf.e_phentsize = sizeof(struct elf_phdr);
1148 elf.e_phnum = segs+1; /* Include notes. */
1149 elf.e_shentsize = 0;
1150 elf.e_shnum = 0;
1151 elf.e_shstrndx = 0;
1152
1153 fs = get_fs();
1154 set_fs(KERNEL_DS);
1155
1156 has_dumped = 1;
1157 current->flags |= PF_DUMPCORE;
1158
1159 DUMP_WRITE(&elf, sizeof(elf));
1160 offset += sizeof(elf); /* Elf header. */
1161 offset += (segs+1) * sizeof(struct elf_phdr); /* Program headers. */
1162
1163 /* Set up the notes in similar form to SVR4 core dumps made
1164 * with info from their /proc.
1165 */
1166 memset(&psinfo, 0, sizeof(psinfo));
1167 memset(&prstatus, 0, sizeof(prstatus));
1168
1169 notes[0].name = "CORE";
1170 notes[0].type = NT_PRSTATUS;
1171 notes[0].datasz = sizeof(prstatus);
1172 notes[0].data = &prstatus;
1173 prstatus.pr_info.si_signo = prstatus.pr_cursig = signr;
1174 prstatus.pr_sigpend = current->pending.signal.sig[0];
1175 prstatus.pr_sighold = current->blocked.sig[0];
1176 psinfo.pr_pid = prstatus.pr_pid = task_pid_vnr(current);
1177 psinfo.pr_ppid = prstatus.pr_ppid = task_pid_vnr(current->parent);
1178 psinfo.pr_pgrp = prstatus.pr_pgrp = task_pgrp_vnr(current);
1179 psinfo.pr_sid = prstatus.pr_sid = task_session_vnr(current);
1180 if (thread_group_leader(current)) {
1181 /*
1182 * This is the record for the group leader. Add in the
1183 * cumulative times of previous dead threads. This total
1184 * won't include the time of each live thread whose state
1185 * is included in the core dump. The final total reported
1186 * to our parent process when it calls wait4 will include
1187 * those sums as well as the little bit more time it takes
1188 * this and each other thread to finish dying after the
1189 * core dump synchronization phase.
1190 */
1191 jiffies_to_timeval(current->utime + current->signal->utime,
1192 &prstatus.pr_utime);
1193 jiffies_to_timeval(current->stime + current->signal->stime,
1194 &prstatus.pr_stime);
1195 } else {
1196 jiffies_to_timeval(current->utime, &prstatus.pr_utime);
1197 jiffies_to_timeval(current->stime, &prstatus.pr_stime);
1198 }
1199 jiffies_to_timeval(current->signal->cutime, &prstatus.pr_cutime);
1200 jiffies_to_timeval(current->signal->cstime, &prstatus.pr_cstime);
1201
1202 if (sizeof(elf_gregset_t) != sizeof(struct pt_regs)) {
1203 printk("sizeof(elf_gregset_t) (%d) != sizeof(struct pt_regs) "
1204 "(%d)\n", sizeof(elf_gregset_t), sizeof(struct pt_regs));
1205 } else {
1206 *(struct pt_regs *)&prstatus.pr_reg = *regs;
1207 }
1208
1209 notes[1].name = "CORE";
1210 notes[1].type = NT_PRPSINFO;
1211 notes[1].datasz = sizeof(psinfo);
1212 notes[1].data = &psinfo;
1213 i = current->state ? ffz(~current->state) + 1 : 0;
1214 psinfo.pr_state = i;
1215 psinfo.pr_sname = (i < 0 || i > 5) ? '.' : "RSDZTD"[i];
1216 psinfo.pr_zomb = psinfo.pr_sname == 'Z';
1217 psinfo.pr_nice = task_nice(current);
1218 psinfo.pr_flag = current->flags;
1219 psinfo.pr_uid = current->uid;
1220 psinfo.pr_gid = current->gid;
1221 {
1222 int i, len;
1223
1224 set_fs(fs);
1225
1226 len = current->mm->arg_end - current->mm->arg_start;
1227 len = len >= ELF_PRARGSZ ? ELF_PRARGSZ : len;
1228 (void *) copy_from_user(&psinfo.pr_psargs,
1229 (const char __user *)current->mm->arg_start, len);
1230 for (i = 0; i < len; i++)
1231 if (psinfo.pr_psargs[i] == 0)
1232 psinfo.pr_psargs[i] = ' ';
1233 psinfo.pr_psargs[len] = 0;
1234
1235 set_fs(KERNEL_DS);
1236 }
1237 strlcpy(psinfo.pr_fname, current->comm, sizeof(psinfo.pr_fname));
1238
1239 /* Try to dump the FPU. */
1240 prstatus.pr_fpvalid = dump_fpu(regs, &fpu);
1241 if (!prstatus.pr_fpvalid) {
1242 numnote--;
1243 } else {
1244 notes[2].name = "CORE";
1245 notes[2].type = NT_PRFPREG;
1246 notes[2].datasz = sizeof(fpu);
1247 notes[2].data = &fpu;
1248 }
1249
1250 /* Write notes phdr entry. */
1251 {
1252 struct elf_phdr phdr;
1253 int sz = 0;
1254
1255 for (i = 0; i < numnote; i++)
1256 sz += notesize(&notes[i]);
1257
1258 phdr.p_type = PT_NOTE;
1259 phdr.p_offset = offset;
1260 phdr.p_vaddr = 0;
1261 phdr.p_paddr = 0;
1262 phdr.p_filesz = sz;
1263 phdr.p_memsz = 0;
1264 phdr.p_flags = 0;
1265 phdr.p_align = 0;
1266
1267 offset += phdr.p_filesz;
1268 DUMP_WRITE(&phdr, sizeof(phdr));
1269 }
1270
1271 /* Page-align dumped data. */
1272 dataoff = offset = roundup(offset, PAGE_SIZE);
1273
1274 /* Write program headers for segments dump. */
1275 for (vma = current->mm->mmap, i = 0;
1276 i < segs && vma != NULL; vma = vma->vm_next) {
1277 struct elf_phdr phdr;
1278 size_t sz;
1279
1280 i++;
1281
1282 sz = vma->vm_end - vma->vm_start;
1283
1284 phdr.p_type = PT_LOAD;
1285 phdr.p_offset = offset;
1286 phdr.p_vaddr = vma->vm_start;
1287 phdr.p_paddr = 0;
1288 phdr.p_filesz = maydump(vma) ? sz : 0;
1289 phdr.p_memsz = sz;
1290 offset += phdr.p_filesz;
1291 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
1292 if (vma->vm_flags & VM_WRITE)
1293 phdr.p_flags |= PF_W;
1294 if (vma->vm_flags & VM_EXEC)
1295 phdr.p_flags |= PF_X;
1296 phdr.p_align = PAGE_SIZE;
1297
1298 DUMP_WRITE(&phdr, sizeof(phdr));
1299 }
1300
1301 for (i = 0; i < numnote; i++)
1302 if (!writenote(&notes[i], file))
1303 goto end_coredump;
1304
1305 set_fs(fs);
1306
1307 DUMP_SEEK(dataoff);
1308
1309 for (i = 0, vma = current->mm->mmap;
1310 i < segs && vma != NULL;
1311 vma = vma->vm_next) {
1312 unsigned long addr = vma->vm_start;
1313 unsigned long len = vma->vm_end - vma->vm_start;
1314
1315 if (!maydump(vma))
1316 continue;
1317 i++;
1318 pr_debug("elf_core_dump: writing %08lx %lx\n", addr, len);
1319 DUMP_WRITE((void __user *)addr, len);
1320 }
1321
1322 if ((off_t) file->f_pos != offset) {
1323 /* Sanity check. */
1324 printk("elf_core_dump: file->f_pos (%ld) != offset (%ld)\n",
1325 (off_t) file->f_pos, offset);
1326 }
1327
1328end_coredump:
1329 set_fs(fs);
1330 return has_dumped;
1331}
1332
1333static int __init init_irix_binfmt(void)
1334{
1335 extern int init_inventory(void);
1336 extern asmlinkage unsigned long sys_call_table;
1337 extern asmlinkage unsigned long sys_call_table_irix5;
1338
1339 init_inventory();
1340
1341 /*
1342 * Copy the IRIX5 syscall table (8000 bytes) into the main syscall
1343 * table. The IRIX5 calls are located by an offset of 8000 bytes
1344 * from the beginning of the main table.
1345 */
1346 memcpy((void *) ((unsigned long) &sys_call_table + 8000),
1347 &sys_call_table_irix5, 8000);
1348
1349 return register_binfmt(&irix_format);
1350}
1351
1352static void __exit exit_irix_binfmt(void)
1353{
1354 /*
1355 * Remove the Irix ELF loader.
1356 */
1357 unregister_binfmt(&irix_format);
1358}
1359
1360module_init(init_irix_binfmt)
1361module_exit(exit_irix_binfmt)
diff --git a/arch/mips/kernel/irixinv.c b/arch/mips/kernel/irixinv.c
deleted file mode 100644
index cf2dcd3d6a9..00000000000
--- a/arch/mips/kernel/irixinv.c
+++ /dev/null
@@ -1,78 +0,0 @@
1/*
2 * Support the inventory interface for IRIX binaries
3 * This is invoked before the mm layer is working, so we do not
4 * use the linked lists for the inventory yet.
5 *
6 * Miguel de Icaza, 1997.
7 */
8#include <linux/mm.h>
9#include <asm/inventory.h>
10#include <asm/uaccess.h>
11
12#define MAX_INVENTORY 50
13int inventory_items = 0;
14
15static inventory_t inventory [MAX_INVENTORY];
16
17void add_to_inventory(int class, int type, int controller, int unit, int state)
18{
19 inventory_t *ni = &inventory [inventory_items];
20
21 if (inventory_items == MAX_INVENTORY)
22 return;
23
24 ni->inv_class = class;
25 ni->inv_type = type;
26 ni->inv_controller = controller;
27 ni->inv_unit = unit;
28 ni->inv_state = state;
29 ni->inv_next = ni;
30 inventory_items++;
31}
32
33int dump_inventory_to_user(void __user *userbuf, int size)
34{
35 inventory_t *inv = &inventory [0];
36 inventory_t __user *user = userbuf;
37 int v;
38
39 if (!access_ok(VERIFY_WRITE, userbuf, size))
40 return -EFAULT;
41
42 for (v = 0; v < inventory_items; v++){
43 inv = &inventory [v];
44 if (copy_to_user (user, inv, sizeof (inventory_t)))
45 return -EFAULT;
46 user++;
47 }
48 return inventory_items * sizeof(inventory_t);
49}
50
51int __init init_inventory(void)
52{
53 /*
54 * gross hack while we put the right bits all over the kernel
55 * most likely this will not let just anyone run the X server
56 * until we put the right values all over the place
57 */
58 add_to_inventory(10, 3, 0, 0, 16400);
59 add_to_inventory(1, 1, 150, -1, 12);
60 add_to_inventory(1, 3, 0, 0, 8976);
61 add_to_inventory(1, 2, 0, 0, 8976);
62 add_to_inventory(4, 8, 0, 0, 2);
63 add_to_inventory(5, 5, 0, 0, 1);
64 add_to_inventory(3, 3, 0, 0, 32768);
65 add_to_inventory(3, 4, 0, 0, 32768);
66 add_to_inventory(3, 8, 0, 0, 524288);
67 add_to_inventory(3, 9, 0, 0, 64);
68 add_to_inventory(3, 1, 0, 0, 67108864);
69 add_to_inventory(12, 3, 0, 0, 16);
70 add_to_inventory(8, 7, 17, 0, 16777472);
71 add_to_inventory(8, 0, 0, 0, 1);
72 add_to_inventory(2, 1, 0, 13, 2);
73 add_to_inventory(2, 2, 0, 2, 0);
74 add_to_inventory(2, 2, 0, 1, 0);
75 add_to_inventory(7, 14, 0, 0, 6);
76
77 return 0;
78}
diff --git a/arch/mips/kernel/irixioctl.c b/arch/mips/kernel/irixioctl.c
deleted file mode 100644
index b39bdba82e0..00000000000
--- a/arch/mips/kernel/irixioctl.c
+++ /dev/null
@@ -1,213 +0,0 @@
1/*
2 * irixioctl.c: A fucking mess...
3 *
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5 */
6
7#include <linux/kernel.h>
8#include <linux/sched.h>
9#include <linux/fs.h>
10#include <linux/mm.h>
11#include <linux/smp.h>
12#include <linux/sockios.h>
13#include <linux/syscalls.h>
14#include <linux/tty.h>
15#include <linux/file.h>
16#include <linux/rcupdate.h>
17
18#include <asm/uaccess.h>
19#include <asm/ioctl.h>
20#include <asm/ioctls.h>
21
22#undef DEBUG_IOCTLS
23#undef DEBUG_MISSING_IOCTL
24
25struct irix_termios {
26 tcflag_t c_iflag, c_oflag, c_cflag, c_lflag;
27 cc_t c_cc[NCCS];
28};
29
30asmlinkage int irix_ioctl(int fd, unsigned long cmd, unsigned long arg)
31{
32 struct tty_struct *tp, *rtp;
33 mm_segment_t old_fs;
34 int i, error = 0;
35
36#ifdef DEBUG_IOCTLS
37 printk("[%s:%d] irix_ioctl(%d, ", current->comm, current->pid, fd);
38#endif
39 switch(cmd) {
40 case 0x00005401:
41#ifdef DEBUG_IOCTLS
42 printk("TCGETA, %08lx) ", arg);
43#endif
44 error = sys_ioctl(fd, TCGETA, arg);
45 break;
46
47 case 0x0000540d: {
48 struct termios kt;
49 struct irix_termios __user *it =
50 (struct irix_termios __user *) arg;
51
52#ifdef DEBUG_IOCTLS
53 printk("TCGETS, %08lx) ", arg);
54#endif
55 if (!access_ok(VERIFY_WRITE, it, sizeof(*it))) {
56 error = -EFAULT;
57 break;
58 }
59 old_fs = get_fs(); set_fs(get_ds());
60 error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);
61 set_fs(old_fs);
62 if (error)
63 break;
64
65 error = __put_user(kt.c_iflag, &it->c_iflag);
66 error |= __put_user(kt.c_oflag, &it->c_oflag);
67 error |= __put_user(kt.c_cflag, &it->c_cflag);
68 error |= __put_user(kt.c_lflag, &it->c_lflag);
69
70 for (i = 0; i < NCCS; i++)
71 error |= __put_user(kt.c_cc[i], &it->c_cc[i]);
72 break;
73 }
74
75 case 0x0000540e: {
76 struct termios kt;
77 struct irix_termios *it = (struct irix_termios *) arg;
78
79#ifdef DEBUG_IOCTLS
80 printk("TCSETS, %08lx) ", arg);
81#endif
82 if (!access_ok(VERIFY_READ, it, sizeof(*it))) {
83 error = -EFAULT;
84 break;
85 }
86 old_fs = get_fs(); set_fs(get_ds());
87 error = sys_ioctl(fd, TCGETS, (unsigned long) &kt);
88 set_fs(old_fs);
89 if (error)
90 break;
91
92 error = __get_user(kt.c_iflag, &it->c_iflag);
93 error |= __get_user(kt.c_oflag, &it->c_oflag);
94 error |= __get_user(kt.c_cflag, &it->c_cflag);
95 error |= __get_user(kt.c_lflag, &it->c_lflag);
96
97 for (i = 0; i < NCCS; i++)
98 error |= __get_user(kt.c_cc[i], &it->c_cc[i]);
99
100 if (error)
101 break;
102 old_fs = get_fs(); set_fs(get_ds());
103 error = sys_ioctl(fd, TCSETS, (unsigned long) &kt);
104 set_fs(old_fs);
105 break;
106 }
107
108 case 0x0000540f:
109#ifdef DEBUG_IOCTLS
110 printk("TCSETSW, %08lx) ", arg);
111#endif
112 error = sys_ioctl(fd, TCSETSW, arg);
113 break;
114
115 case 0x00005471:
116#ifdef DEBUG_IOCTLS
117 printk("TIOCNOTTY, %08lx) ", arg);
118#endif
119 error = sys_ioctl(fd, TIOCNOTTY, arg);
120 break;
121
122 case 0x00007416: {
123 pid_t pid;
124#ifdef DEBUG_IOCTLS
125 printk("TIOCGSID, %08lx) ", arg);
126#endif
127 old_fs = get_fs(); set_fs(get_ds());
128 error = sys_ioctl(fd, TIOCGSID, (unsigned long)&pid);
129 set_fs(old_fs);
130 if (!error)
131 error = put_user(pid, (unsigned long __user *) arg);
132 break;
133 }
134 case 0x746e:
135 /* TIOCSTART, same effect as hitting ^Q */
136#ifdef DEBUG_IOCTLS
137 printk("TIOCSTART, %08lx) ", arg);
138#endif
139 error = sys_ioctl(fd, TCXONC, TCOON);
140 break;
141
142 case 0x20006968:
143#ifdef DEBUG_IOCTLS
144 printk("SIOCGETLABEL, %08lx) ", arg);
145#endif
146 error = -ENOPKG;
147 break;
148
149 case 0x40047477:
150#ifdef DEBUG_IOCTLS
151 printk("TIOCGPGRP, %08lx) ", arg);
152#endif
153 error = sys_ioctl(fd, TIOCGPGRP, arg);
154#ifdef DEBUG_IOCTLS
155 printk("arg=%d ", *(int *)arg);
156#endif
157 break;
158
159 case 0x40087468:
160#ifdef DEBUG_IOCTLS
161 printk("TIOCGWINSZ, %08lx) ", arg);
162#endif
163 error = sys_ioctl(fd, TIOCGWINSZ, arg);
164 break;
165
166 case 0x8004667e:
167 error = sys_ioctl(fd, FIONBIO, arg);
168 break;
169
170 case 0x80047476:
171 error = sys_ioctl(fd, TIOCSPGRP, arg);
172 break;
173
174 case 0x8020690c:
175 error = sys_ioctl(fd, SIOCSIFADDR, arg);
176 break;
177
178 case 0x80206910:
179 error = sys_ioctl(fd, SIOCSIFFLAGS, arg);
180 break;
181
182 case 0xc0206911:
183 error = sys_ioctl(fd, SIOCGIFFLAGS, arg);
184 break;
185
186 case 0xc020691b:
187 error = sys_ioctl(fd, SIOCGIFMETRIC, arg);
188 break;
189
190 default: {
191#ifdef DEBUG_MISSING_IOCTL
192 char *msg = "Unimplemented IOCTL cmd tell linux-mips@linux-mips.org\n";
193
194#ifdef DEBUG_IOCTLS
195 printk("UNIMP_IOCTL, %08lx)\n", arg);
196#endif
197 old_fs = get_fs(); set_fs(get_ds());
198 sys_write(2, msg, strlen(msg));
199 set_fs(old_fs);
200 printk("[%s:%d] Does unimplemented IRIX ioctl cmd %08lx\n",
201 current->comm, current->pid, cmd);
202 do_exit(255);
203#else
204 error = sys_ioctl(fd, cmd, arg);
205#endif
206 }
207
208 };
209#ifdef DEBUG_IOCTLS
210 printk("error=%d\n", error);
211#endif
212 return error;
213}
diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
deleted file mode 100644
index 0215c805a59..00000000000
--- a/arch/mips/kernel/irixsig.c
+++ /dev/null
@@ -1,888 +0,0 @@
1/*
2 * irixsig.c: WHEEE, IRIX signals! YOW, am I compatible or what?!?!
3 *
4 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5 * Copyright (C) 1997 - 2000 Ralf Baechle (ralf@gnu.org)
6 * Copyright (C) 2000 Silicon Graphics, Inc.
7 */
8#include <linux/kernel.h>
9#include <linux/sched.h>
10#include <linux/mm.h>
11#include <linux/errno.h>
12#include <linux/smp.h>
13#include <linux/time.h>
14#include <linux/ptrace.h>
15#include <linux/resource.h>
16
17#include <asm/ptrace.h>
18#include <asm/uaccess.h>
19#include <asm/unistd.h>
20
21#undef DEBUG_SIG
22
23#define _S(nr) (1<<((nr)-1))
24
25#define _BLOCKABLE (~(_S(SIGKILL) | _S(SIGSTOP)))
26
27#define _IRIX_NSIG 128
28#define _IRIX_NSIG_BPW BITS_PER_LONG
29#define _IRIX_NSIG_WORDS (_IRIX_NSIG / _IRIX_NSIG_BPW)
30
31typedef struct {
32 unsigned long sig[_IRIX_NSIG_WORDS];
33} irix_sigset_t;
34
35struct sigctx_irix5 {
36 u32 rmask, cp0_status;
37 u64 pc;
38 u64 regs[32];
39 u64 fpregs[32];
40 u32 usedfp, fpcsr, fpeir, sstk_flags;
41 u64 hi, lo;
42 u64 cp0_cause, cp0_badvaddr, _unused0;
43 irix_sigset_t sigset;
44 u64 weird_fpu_thing;
45 u64 _unused1[31];
46};
47
48#ifdef DEBUG_SIG
49/* Debugging */
50static inline void dump_irix5_sigctx(struct sigctx_irix5 *c)
51{
52 int i;
53
54 printk("misc: rmask[%08lx] status[%08lx] pc[%08lx]\n",
55 (unsigned long) c->rmask,
56 (unsigned long) c->cp0_status,
57 (unsigned long) c->pc);
58 printk("regs: ");
59 for(i = 0; i < 16; i++)
60 printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
61 printk("\nregs: ");
62 for(i = 16; i < 32; i++)
63 printk("[%d]<%08lx> ", i, (unsigned long) c->regs[i]);
64 printk("\nfpregs: ");
65 for(i = 0; i < 16; i++)
66 printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
67 printk("\nfpregs: ");
68 for(i = 16; i < 32; i++)
69 printk("[%d]<%08lx> ", i, (unsigned long) c->fpregs[i]);
70 printk("misc: usedfp[%d] fpcsr[%08lx] fpeir[%08lx] stk_flgs[%08lx]\n",
71 (int) c->usedfp, (unsigned long) c->fpcsr,
72 (unsigned long) c->fpeir, (unsigned long) c->sstk_flags);
73 printk("misc: hi[%08lx] lo[%08lx] cause[%08lx] badvaddr[%08lx]\n",
74 (unsigned long) c->hi, (unsigned long) c->lo,
75 (unsigned long) c->cp0_cause, (unsigned long) c->cp0_badvaddr);
76 printk("misc: sigset<0>[%08lx] sigset<1>[%08lx] sigset<2>[%08lx] "
77 "sigset<3>[%08lx]\n", (unsigned long) c->sigset.sig[0],
78 (unsigned long) c->sigset.sig[1],
79 (unsigned long) c->sigset.sig[2],
80 (unsigned long) c->sigset.sig[3]);
81}
82#endif
83
84static int setup_irix_frame(struct k_sigaction *ka, struct pt_regs *regs,
85 int signr, sigset_t *oldmask)
86{
87 struct sigctx_irix5 __user *ctx;
88 unsigned long sp;
89 int error, i;
90
91 sp = regs->regs[29];
92 sp -= sizeof(struct sigctx_irix5);
93 sp &= ~(0xf);
94 ctx = (struct sigctx_irix5 __user *) sp;
95 if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
96 goto segv_and_exit;
97
98 error = __put_user(0, &ctx->weird_fpu_thing);
99 error |= __put_user(~(0x00000001), &ctx->rmask);
100 error |= __put_user(0, &ctx->regs[0]);
101 for(i = 1; i < 32; i++)
102 error |= __put_user((u64) regs->regs[i], &ctx->regs[i]);
103
104 error |= __put_user((u64) regs->hi, &ctx->hi);
105 error |= __put_user((u64) regs->lo, &ctx->lo);
106 error |= __put_user((u64) regs->cp0_epc, &ctx->pc);
107 error |= __put_user(!!used_math(), &ctx->usedfp);
108 error |= __put_user((u64) regs->cp0_cause, &ctx->cp0_cause);
109 error |= __put_user((u64) regs->cp0_badvaddr, &ctx->cp0_badvaddr);
110
111 error |= __put_user(0, &ctx->sstk_flags); /* XXX sigstack unimp... todo... */
112
113 error |= __copy_to_user(&ctx->sigset, oldmask, sizeof(irix_sigset_t)) ? -EFAULT : 0;
114
115 if (error)
116 goto segv_and_exit;
117
118#ifdef DEBUG_SIG
119 dump_irix5_sigctx(ctx);
120#endif
121
122 regs->regs[4] = (unsigned long) signr;
123 regs->regs[5] = 0; /* XXX sigcode XXX */
124 regs->regs[6] = regs->regs[29] = sp;
125 regs->regs[7] = (unsigned long) ka->sa.sa_handler;
126 regs->regs[25] = regs->cp0_epc = (unsigned long) ka->sa_restorer;
127
128 return 1;
129
130segv_and_exit:
131 force_sigsegv(signr, current);
132 return 0;
133}
134
135static int inline
136setup_irix_rt_frame(struct k_sigaction * ka, struct pt_regs *regs,
137 int signr, sigset_t *oldmask, siginfo_t *info)
138{
139 printk("Aiee: setup_tr_frame wants to be written");
140 do_exit(SIGSEGV);
141}
142
143static inline int handle_signal(unsigned long sig, siginfo_t *info,
144 struct k_sigaction *ka, sigset_t *oldset, struct pt_regs * regs)
145{
146 int ret;
147
148 switch(regs->regs[0]) {
149 case ERESTARTNOHAND:
150 regs->regs[2] = EINTR;
151 break;
152 case ERESTARTSYS:
153 if(!(ka->sa.sa_flags & SA_RESTART)) {
154 regs->regs[2] = EINTR;
155 break;
156 }
157 /* fallthrough */
158 case ERESTARTNOINTR: /* Userland will reload $v0. */
159 regs->cp0_epc -= 8;
160 }
161
162 regs->regs[0] = 0; /* Don't deal with this again. */
163
164 if (ka->sa.sa_flags & SA_SIGINFO)
165 ret = setup_irix_rt_frame(ka, regs, sig, oldset, info);
166 else
167 ret = setup_irix_frame(ka, regs, sig, oldset);
168
169 spin_lock_irq(&current->sighand->siglock);
170 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
171 if (!(ka->sa.sa_flags & SA_NODEFER))
172 sigaddset(&current->blocked, sig);
173 recalc_sigpending();
174 spin_unlock_irq(&current->sighand->siglock);
175
176 return ret;
177}
178
179void do_irix_signal(struct pt_regs *regs)
180{
181 struct k_sigaction ka;
182 siginfo_t info;
183 int signr;
184 sigset_t *oldset;
185
186 /*
187 * We want the common case to go fast, which is why we may in certain
188 * cases get here from kernel mode. Just return without doing anything
189 * if so.
190 */
191 if (!user_mode(regs))
192 return;
193
194 if (test_thread_flag(TIF_RESTORE_SIGMASK))
195 oldset = &current->saved_sigmask;
196 else
197 oldset = &current->blocked;
198
199 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
200 if (signr > 0) {
201 /* Whee! Actually deliver the signal. */
202 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
203 /* a signal was successfully delivered; the saved
204 * sigmask will have been stored in the signal frame,
205 * and will be restored by sigreturn, so we can simply
206 * clear the TIF_RESTORE_SIGMASK flag */
207 if (test_thread_flag(TIF_RESTORE_SIGMASK))
208 clear_thread_flag(TIF_RESTORE_SIGMASK);
209 }
210
211 return;
212 }
213
214 /*
215 * Who's code doesn't conform to the restartable syscall convention
216 * dies here!!! The li instruction, a single machine instruction,
217 * must directly be followed by the syscall instruction.
218 */
219 if (regs->regs[0]) {
220 if (regs->regs[2] == ERESTARTNOHAND ||
221 regs->regs[2] == ERESTARTSYS ||
222 regs->regs[2] == ERESTARTNOINTR) {
223 regs->cp0_epc -= 8;
224 }
225 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
226 regs->regs[2] = __NR_restart_syscall;
227 regs->regs[7] = regs->regs[26];
228 regs->cp0_epc -= 4;
229 }
230 regs->regs[0] = 0; /* Don't deal with this again. */
231 }
232
233 /*
234 * If there's no signal to deliver, we just put the saved sigmask
235 * back
236 */
237 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
238 clear_thread_flag(TIF_RESTORE_SIGMASK);
239 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
240 }
241}
242
243asmlinkage void
244irix_sigreturn(struct pt_regs *regs)
245{
246 struct sigctx_irix5 __user *context, *magic;
247 unsigned long umask, mask;
248 u64 *fregs;
249 u32 usedfp;
250 int error, sig, i, base = 0;
251 sigset_t blocked;
252
253 /* Always make any pending restarted system calls return -EINTR */
254 current_thread_info()->restart_block.fn = do_no_restart_syscall;
255
256 if (regs->regs[2] == 1000)
257 base = 1;
258
259 context = (struct sigctx_irix5 __user *) regs->regs[base + 4];
260 magic = (struct sigctx_irix5 __user *) regs->regs[base + 5];
261 sig = (int) regs->regs[base + 6];
262#ifdef DEBUG_SIG
263 printk("[%s:%d] IRIX sigreturn(scp[%p],ucp[%p],sig[%d])\n",
264 current->comm, current->pid, context, magic, sig);
265#endif
266 if (!context)
267 context = magic;
268 if (!access_ok(VERIFY_READ, context, sizeof(struct sigctx_irix5)))
269 goto badframe;
270
271#ifdef DEBUG_SIG
272 dump_irix5_sigctx(context);
273#endif
274
275 error = __get_user(regs->cp0_epc, &context->pc);
276 error |= __get_user(umask, &context->rmask);
277
278 mask = 2;
279 for (i = 1; i < 32; i++, mask <<= 1) {
280 if (umask & mask)
281 error |= __get_user(regs->regs[i], &context->regs[i]);
282 }
283 error |= __get_user(regs->hi, &context->hi);
284 error |= __get_user(regs->lo, &context->lo);
285
286 error |= __get_user(usedfp, &context->usedfp);
287 if ((umask & 1) && usedfp) {
288 fregs = (u64 *) &current->thread.fpu;
289
290 for(i = 0; i < 32; i++)
291 error |= __get_user(fregs[i], &context->fpregs[i]);
292 error |= __get_user(current->thread.fpu.fcr31, &context->fpcsr);
293 }
294
295 /* XXX do sigstack crapola here... XXX */
296
297 error |= __copy_from_user(&blocked, &context->sigset, sizeof(blocked)) ? -EFAULT : 0;
298
299 if (error)
300 goto badframe;
301
302 sigdelsetmask(&blocked, ~_BLOCKABLE);
303 spin_lock_irq(&current->sighand->siglock);
304 current->blocked = blocked;
305 recalc_sigpending();
306 spin_unlock_irq(&current->sighand->siglock);
307
308 /*
309 * Don't let your children do this ...
310 */
311 __asm__ __volatile__(
312 "move\t$29,%0\n\t"
313 "j\tsyscall_exit"
314 :/* no outputs */
315 :"r" (&regs));
316 /* Unreached */
317
318badframe:
319 force_sig(SIGSEGV, current);
320}
321
322struct sigact_irix5 {
323 int flags;
324 void (*handler)(int);
325 u32 sigset[4];
326 int _unused0[2];
327};
328
329#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
330 set only the low 32 bit of the sigset. */
331
332#ifdef DEBUG_SIG
333static inline void dump_sigact_irix5(struct sigact_irix5 *p)
334{
335 printk("<f[%d] hndlr[%08lx] msk[%08lx]>", p->flags,
336 (unsigned long) p->handler,
337 (unsigned long) p->sigset[0]);
338}
339#endif
340
341asmlinkage int
342irix_sigaction(int sig, const struct sigaction __user *act,
343 struct sigaction __user *oact, void __user *trampoline)
344{
345 struct k_sigaction new_ka, old_ka;
346 int ret;
347
348#ifdef DEBUG_SIG
349 printk(" (%d,%s,%s,%08lx) ", sig, (!new ? "0" : "NEW"),
350 (!old ? "0" : "OLD"), trampoline);
351 if(new) {
352 dump_sigact_irix5(new); printk(" ");
353 }
354#endif
355 if (act) {
356 sigset_t mask;
357 int err;
358
359 if (!access_ok(VERIFY_READ, act, sizeof(*act)))
360 return -EFAULT;
361 err = __get_user(new_ka.sa.sa_handler, &act->sa_handler);
362 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
363
364 err |= __copy_from_user(&mask, &act->sa_mask, sizeof(sigset_t)) ? -EFAULT : 0;
365 if (err)
366 return err;
367
368 /*
369 * Hmmm... methinks IRIX libc always passes a valid trampoline
370 * value for all invocations of sigaction. Will have to
371 * investigate. POSIX POSIX, die die die...
372 */
373 new_ka.sa_restorer = trampoline;
374 }
375
376/* XXX Implement SIG_SETMASK32 for IRIX compatibility */
377 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
378
379 if (!ret && oact) {
380 int err;
381
382 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
383 return -EFAULT;
384
385 err = __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
386 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
387 err |= __copy_to_user(&oact->sa_mask, &old_ka.sa.sa_mask,
388 sizeof(sigset_t)) ? -EFAULT : 0;
389 if (err)
390 return -EFAULT;
391 }
392
393 return ret;
394}
395
396asmlinkage int irix_sigpending(irix_sigset_t __user *set)
397{
398 return do_sigpending(set, sizeof(*set));
399}
400
401asmlinkage int irix_sigprocmask(int how, irix_sigset_t __user *new,
402 irix_sigset_t __user *old)
403{
404 sigset_t oldbits, newbits;
405
406 if (new) {
407 if (!access_ok(VERIFY_READ, new, sizeof(*new)))
408 return -EFAULT;
409 if (__copy_from_user(&newbits, new, sizeof(unsigned long)*4))
410 return -EFAULT;
411 sigdelsetmask(&newbits, ~_BLOCKABLE);
412
413 spin_lock_irq(&current->sighand->siglock);
414 oldbits = current->blocked;
415
416 switch(how) {
417 case 1:
418 sigorsets(&newbits, &oldbits, &newbits);
419 break;
420
421 case 2:
422 sigandsets(&newbits, &oldbits, &newbits);
423 break;
424
425 case 3:
426 break;
427
428 case 256:
429 siginitset(&newbits, newbits.sig[0]);
430 break;
431
432 default:
433 spin_unlock_irq(&current->sighand->siglock);
434 return -EINVAL;
435 }
436 recalc_sigpending();
437 spin_unlock_irq(&current->sighand->siglock);
438 }
439 if (old)
440 return copy_to_user(old, &current->blocked,
441 sizeof(unsigned long)*4) ? -EFAULT : 0;
442
443 return 0;
444}
445
446asmlinkage int irix_sigsuspend(struct pt_regs *regs)
447{
448 sigset_t newset;
449 sigset_t __user *uset;
450
451 uset = (sigset_t __user *) regs->regs[4];
452 if (copy_from_user(&newset, uset, sizeof(sigset_t)))
453 return -EFAULT;
454 sigdelsetmask(&newset, ~_BLOCKABLE);
455
456 spin_lock_irq(&current->sighand->siglock);
457 current->saved_sigmask = current->blocked;
458 current->blocked = newset;
459 recalc_sigpending();
460 spin_unlock_irq(&current->sighand->siglock);
461
462 current->state = TASK_INTERRUPTIBLE;
463 schedule();
464 set_thread_flag(TIF_RESTORE_SIGMASK);
465 return -ERESTARTNOHAND;
466}
467
468/* hate hate hate... */
469struct irix5_siginfo {
470 int sig, code, error;
471 union {
472 char unused[128 - (3 * 4)]; /* Safety net. */
473 struct {
474 int pid;
475 union {
476 int uid;
477 struct {
478 int utime, status, stime;
479 } child;
480 } procdata;
481 } procinfo;
482
483 unsigned long fault_addr;
484
485 struct {
486 int fd;
487 long band;
488 } fileinfo;
489
490 unsigned long sigval;
491 } stuff;
492};
493
494asmlinkage int irix_sigpoll_sys(unsigned long __user *set,
495 struct irix5_siginfo __user *info, struct timespec __user *tp)
496{
497 long expire = MAX_SCHEDULE_TIMEOUT;
498 sigset_t kset;
499 int i, sig, error, timeo = 0;
500 struct timespec ktp;
501
502#ifdef DEBUG_SIG
503 printk("[%s:%d] irix_sigpoll_sys(%p,%p,%p)\n",
504 current->comm, current->pid, set, info, tp);
505#endif
506
507 /* Must always specify the signal set. */
508 if (!set)
509 return -EINVAL;
510
511 if (copy_from_user(&kset, set, sizeof(set)))
512 return -EFAULT;
513
514 if (info && clear_user(info, sizeof(*info))) {
515 error = -EFAULT;
516 goto out;
517 }
518
519 if (tp) {
520 if (copy_from_user(&ktp, tp, sizeof(*tp)))
521 return -EFAULT;
522
523 if (!ktp.tv_sec && !ktp.tv_nsec)
524 return -EINVAL;
525
526 expire = timespec_to_jiffies(&ktp) +
527 (ktp.tv_sec || ktp.tv_nsec);
528 }
529
530 while(1) {
531 long tmp = 0;
532
533 expire = schedule_timeout_interruptible(expire);
534
535 for (i=0; i < _IRIX_NSIG_WORDS; i++)
536 tmp |= (current->pending.signal.sig[i] & kset.sig[i]);
537
538 if (tmp)
539 break;
540 if (!expire) {
541 timeo = 1;
542 break;
543 }
544 if (signal_pending(current))
545 return -EINTR;
546 }
547 if (timeo)
548 return -EAGAIN;
549
550 for (sig = 1; i <= 65 /* IRIX_NSIG */; sig++) {
551 if (sigismember (&kset, sig))
552 continue;
553 if (sigismember (&current->pending.signal, sig)) {
554 /* XXX need more than this... */
555 if (info)
556 return copy_to_user(&info->sig, &sig, sizeof(sig));
557 return 0;
558 }
559 }
560
561 /* Should not get here, but do something sane if we do. */
562 error = -EINTR;
563
564out:
565 return error;
566}
567
568/* This is here because of irix5_siginfo definition. */
569#define IRIX_P_PID 0
570#define IRIX_P_PGID 2
571#define IRIX_P_ALL 7
572
573#define W_EXITED 1
574#define W_TRAPPED 2
575#define W_STOPPED 4
576#define W_CONT 8
577#define W_NOHANG 64
578
579#define W_MASK (W_EXITED | W_TRAPPED | W_STOPPED | W_CONT | W_NOHANG)
580
581asmlinkage int irix_waitsys(int type, int upid,
582 struct irix5_siginfo __user *info, int options,
583 struct rusage __user *ru)
584{
585 struct pid *pid = NULL;
586 int flag, retval;
587 DECLARE_WAITQUEUE(wait, current);
588 struct task_struct *tsk;
589 struct task_struct *p;
590 struct list_head *_p;
591
592 if (!info)
593 return -EINVAL;
594
595 if (!access_ok(VERIFY_WRITE, info, sizeof(*info)))
596 return -EFAULT;
597
598 if (ru)
599 if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru)))
600 return -EFAULT;
601
602 if (options & ~W_MASK)
603 return -EINVAL;
604
605 if (type != IRIX_P_PID && type != IRIX_P_PGID && type != IRIX_P_ALL)
606 return -EINVAL;
607
608 if (type != IRIX_P_ALL)
609 pid = find_get_pid(upid);
610 add_wait_queue(&current->signal->wait_chldexit, &wait);
611repeat:
612 flag = 0;
613 current->state = TASK_INTERRUPTIBLE;
614 read_lock(&tasklist_lock);
615 tsk = current;
616 list_for_each(_p, &tsk->children) {
617 p = list_entry(_p, struct task_struct, sibling);
618 if ((type == IRIX_P_PID) && task_pid(p) != pid)
619 continue;
620 if ((type == IRIX_P_PGID) && task_pgrp(p) != pid)
621 continue;
622 if ((p->exit_signal != SIGCHLD))
623 continue;
624 flag = 1;
625 switch (p->state) {
626 case TASK_STOPPED:
627 if (!p->exit_code)
628 continue;
629 if (!(options & (W_TRAPPED|W_STOPPED)) &&
630 !(p->ptrace & PT_PTRACED))
631 continue;
632 read_unlock(&tasklist_lock);
633
634 /* move to end of parent's list to avoid starvation */
635 write_lock_irq(&tasklist_lock);
636 remove_parent(p);
637 add_parent(p);
638 write_unlock_irq(&tasklist_lock);
639 retval = ru ? getrusage(p, RUSAGE_BOTH, ru) : 0;
640 if (retval)
641 goto end_waitsys;
642
643 retval = __put_user(SIGCHLD, &info->sig);
644 retval |= __put_user(0, &info->code);
645 retval |= __put_user(task_pid_vnr(p), &info->stuff.procinfo.pid);
646 retval |= __put_user((p->exit_code >> 8) & 0xff,
647 &info->stuff.procinfo.procdata.child.status);
648 retval |= __put_user(p->utime, &info->stuff.procinfo.procdata.child.utime);
649 retval |= __put_user(p->stime, &info->stuff.procinfo.procdata.child.stime);
650 if (retval)
651 goto end_waitsys;
652
653 p->exit_code = 0;
654 goto end_waitsys;
655
656 case EXIT_ZOMBIE:
657 current->signal->cutime += p->utime + p->signal->cutime;
658 current->signal->cstime += p->stime + p->signal->cstime;
659 if (ru != NULL)
660 getrusage(p, RUSAGE_BOTH, ru);
661 retval = __put_user(SIGCHLD, &info->sig);
662 retval |= __put_user(1, &info->code); /* CLD_EXITED */
663 retval |= __put_user(task_pid_vnr(p), &info->stuff.procinfo.pid);
664 retval |= __put_user((p->exit_code >> 8) & 0xff,
665 &info->stuff.procinfo.procdata.child.status);
666 retval |= __put_user(p->utime,
667 &info->stuff.procinfo.procdata.child.utime);
668 retval |= __put_user(p->stime,
669 &info->stuff.procinfo.procdata.child.stime);
670 if (retval)
671 goto end_waitsys;
672
673 if (p->real_parent != p->parent) {
674 write_lock_irq(&tasklist_lock);
675 remove_parent(p);
676 p->parent = p->real_parent;
677 add_parent(p);
678 do_notify_parent(p, SIGCHLD);
679 write_unlock_irq(&tasklist_lock);
680 } else
681 release_task(p);
682 goto end_waitsys;
683 default:
684 continue;
685 }
686 tsk = next_thread(tsk);
687 }
688 read_unlock(&tasklist_lock);
689 if (flag) {
690 retval = 0;
691 if (options & W_NOHANG)
692 goto end_waitsys;
693 retval = -ERESTARTSYS;
694 if (signal_pending(current))
695 goto end_waitsys;
696 current->state = TASK_INTERRUPTIBLE;
697 schedule();
698 goto repeat;
699 }
700 retval = -ECHILD;
701end_waitsys:
702 current->state = TASK_RUNNING;
703 remove_wait_queue(&current->signal->wait_chldexit, &wait);
704 put_pid(pid);
705
706 return retval;
707}
708
709struct irix5_context {
710 u32 flags;
711 u32 link;
712 u32 sigmask[4];
713 struct { u32 sp, size, flags; } stack;
714 int regs[36];
715 u32 fpregs[32];
716 u32 fpcsr;
717 u32 _unused0;
718 u32 _unused1[47];
719 u32 weird_graphics_thing;
720};
721
722asmlinkage int irix_getcontext(struct pt_regs *regs)
723{
724 int error, i, base = 0;
725 struct irix5_context __user *ctx;
726 unsigned long flags;
727
728 if (regs->regs[2] == 1000)
729 base = 1;
730 ctx = (struct irix5_context __user *) regs->regs[base + 4];
731
732#ifdef DEBUG_SIG
733 printk("[%s:%d] irix_getcontext(%p)\n",
734 current->comm, current->pid, ctx);
735#endif
736
737 if (!access_ok(VERIFY_WRITE, ctx, sizeof(*ctx)))
738 return -EFAULT;
739
740 error = __put_user(current->thread.irix_oldctx, &ctx->link);
741
742 error |= __copy_to_user(&ctx->sigmask, &current->blocked, sizeof(irix_sigset_t)) ? -EFAULT : 0;
743
744 /* XXX Do sigstack stuff someday... */
745 error |= __put_user(0, &ctx->stack.sp);
746 error |= __put_user(0, &ctx->stack.size);
747 error |= __put_user(0, &ctx->stack.flags);
748
749 error |= __put_user(0, &ctx->weird_graphics_thing);
750 error |= __put_user(0, &ctx->regs[0]);
751 for (i = 1; i < 32; i++)
752 error |= __put_user(regs->regs[i], &ctx->regs[i]);
753 error |= __put_user(regs->lo, &ctx->regs[32]);
754 error |= __put_user(regs->hi, &ctx->regs[33]);
755 error |= __put_user(regs->cp0_cause, &ctx->regs[34]);
756 error |= __put_user(regs->cp0_epc, &ctx->regs[35]);
757
758 flags = 0x0f;
759 if (!used_math()) {
760 flags &= ~(0x08);
761 } else {
762 /* XXX wheee... */
763 printk("Wheee, no code for saving IRIX FPU context yet.\n");
764 }
765 error |= __put_user(flags, &ctx->flags);
766
767 return error;
768}
769
770asmlinkage void irix_setcontext(struct pt_regs *regs)
771{
772 struct irix5_context __user *ctx;
773 int err, base = 0;
774 u32 flags;
775
776 if (regs->regs[2] == 1000)
777 base = 1;
778 ctx = (struct irix5_context __user *) regs->regs[base + 4];
779
780#ifdef DEBUG_SIG
781 printk("[%s:%d] irix_setcontext(%p)\n",
782 current->comm, current->pid, ctx);
783#endif
784
785 if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)))
786 goto segv_and_exit;
787
788 err = __get_user(flags, &ctx->flags);
789 if (flags & 0x02) {
790 /* XXX sigstack garbage, todo... */
791 printk("Wheee, cannot do sigstack stuff in setcontext\n");
792 }
793
794 if (flags & 0x04) {
795 int i;
796
797 /* XXX extra control block stuff... todo... */
798 for (i = 1; i < 32; i++)
799 err |= __get_user(regs->regs[i], &ctx->regs[i]);
800 err |= __get_user(regs->lo, &ctx->regs[32]);
801 err |= __get_user(regs->hi, &ctx->regs[33]);
802 err |= __get_user(regs->cp0_epc, &ctx->regs[35]);
803 }
804
805 if (flags & 0x08)
806 /* XXX fpu context, blah... */
807 printk(KERN_ERR "Wheee, cannot restore FPU context yet...\n");
808
809 err |= __get_user(current->thread.irix_oldctx, &ctx->link);
810 if (err)
811 goto segv_and_exit;
812
813 /*
814 * Don't let your children do this ...
815 */
816 __asm__ __volatile__(
817 "move\t$29,%0\n\t"
818 "j\tsyscall_exit"
819 :/* no outputs */
820 :"r" (&regs));
821 /* Unreached */
822
823segv_and_exit:
824 force_sigsegv(SIGSEGV, current);
825}
826
827struct irix_sigstack {
828 unsigned long sp;
829 int status;
830};
831
832asmlinkage int irix_sigstack(struct irix_sigstack __user *new,
833 struct irix_sigstack __user *old)
834{
835#ifdef DEBUG_SIG
836 printk("[%s:%d] irix_sigstack(%p,%p)\n",
837 current->comm, current->pid, new, old);
838#endif
839 if (new) {
840 if (!access_ok(VERIFY_READ, new, sizeof(*new)))
841 return -EFAULT;
842 }
843
844 if (old) {
845 if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
846 return -EFAULT;
847 }
848
849 return 0;
850}
851
852struct irix_sigaltstack { unsigned long sp; int size; int status; };
853
854asmlinkage int irix_sigaltstack(struct irix_sigaltstack __user *new,
855 struct irix_sigaltstack __user *old)
856{
857#ifdef DEBUG_SIG
858 printk("[%s:%d] irix_sigaltstack(%p,%p)\n",
859 current->comm, current->pid, new, old);
860#endif
861 if (new)
862 if (!access_ok(VERIFY_READ, new, sizeof(*new)))
863 return -EFAULT;
864
865 if (old) {
866 if (!access_ok(VERIFY_WRITE, old, sizeof(*old)))
867 return -EFAULT;
868 }
869
870 return 0;
871}
872
873struct irix_procset {
874 int cmd, ltype, lid, rtype, rid;
875};
876
877asmlinkage int irix_sigsendset(struct irix_procset __user *pset, int sig)
878{
879 if (!access_ok(VERIFY_READ, pset, sizeof(*pset)))
880 return -EFAULT;
881#ifdef DEBUG_SIG
882 printk("[%s:%d] irix_sigsendset([%d,%d,%d,%d,%d],%d)\n",
883 current->comm, current->pid,
884 pset->cmd, pset->ltype, pset->lid, pset->rtype, pset->rid,
885 sig);
886#endif
887 return -EINVAL;
888}
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index ed9febe63d7..b47e4615ec1 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -49,7 +49,7 @@ static void local_rm9k_perfcounter_irq_startup(void *args)
49 49
50static unsigned int rm9k_perfcounter_irq_startup(unsigned int irq) 50static unsigned int rm9k_perfcounter_irq_startup(unsigned int irq)
51{ 51{
52 on_each_cpu(local_rm9k_perfcounter_irq_startup, (void *) irq, 0, 1); 52 on_each_cpu(local_rm9k_perfcounter_irq_startup, (void *) irq, 1);
53 53
54 return 0; 54 return 0;
55} 55}
@@ -66,7 +66,7 @@ static void local_rm9k_perfcounter_irq_shutdown(void *args)
66 66
67static void rm9k_perfcounter_irq_shutdown(unsigned int irq) 67static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
68{ 68{
69 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1); 69 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 1);
70} 70}
71 71
72static struct irq_chip rm9k_irq_controller = { 72static struct irq_chip rm9k_irq_controller = {
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index e3309ff9ece..6045b9a51a3 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -44,8 +44,6 @@ again:
44 return irq; 44 return irq;
45} 45}
46 46
47EXPORT_SYMBOL_GPL(allocate_irqno);
48
49/* 47/*
50 * Allocate the 16 legacy interrupts for i8259 devices. This happens early 48 * Allocate the 16 legacy interrupts for i8259 devices. This happens early
51 * in the kernel initialization so treating allocation failure as BUG() is 49 * in the kernel initialization so treating allocation failure as BUG() is
@@ -66,8 +64,6 @@ void free_irqno(unsigned int irq)
66 smp_mb__after_clear_bit(); 64 smp_mb__after_clear_bit();
67} 65}
68 66
69EXPORT_SYMBOL_GPL(free_irqno);
70
71/* 67/*
72 * 'what should we do if we get a hw irq event on an illegal vector'. 68 * 'what should we do if we get a hw irq event on an illegal vector'.
73 * each architecture has to answer this themselves. 69 * each architecture has to answer this themselves.
diff --git a/arch/mips/kernel/mips-mt.c b/arch/mips/kernel/mips-mt.c
index 640fb0cc6e3..d01665a453f 100644
--- a/arch/mips/kernel/mips-mt.c
+++ b/arch/mips/kernel/mips-mt.c
@@ -4,7 +4,6 @@
4 */ 4 */
5 5
6#include <linux/device.h> 6#include <linux/device.h>
7#include <linux/kallsyms.h>
8#include <linux/kernel.h> 7#include <linux/kernel.h>
9#include <linux/sched.h> 8#include <linux/sched.h>
10#include <linux/module.h> 9#include <linux/module.h>
@@ -84,9 +83,9 @@ void mips_mt_regdump(unsigned long mvpctl)
84 read_vpe_c0_vpeconf0()); 83 read_vpe_c0_vpeconf0());
85 printk(" VPE%d.Status : %08lx\n", 84 printk(" VPE%d.Status : %08lx\n",
86 i, read_vpe_c0_status()); 85 i, read_vpe_c0_status());
87 printk(" VPE%d.EPC : %08lx ", 86 printk(" VPE%d.EPC : %08lx %pS\n",
88 i, read_vpe_c0_epc()); 87 i, read_vpe_c0_epc(),
89 print_symbol("%s\n", read_vpe_c0_epc()); 88 (void *) read_vpe_c0_epc());
90 printk(" VPE%d.Cause : %08lx\n", 89 printk(" VPE%d.Cause : %08lx\n",
91 i, read_vpe_c0_cause()); 90 i, read_vpe_c0_cause());
92 printk(" VPE%d.Config7 : %08lx\n", 91 printk(" VPE%d.Config7 : %08lx\n",
@@ -111,8 +110,8 @@ void mips_mt_regdump(unsigned long mvpctl)
111 } 110 }
112 printk(" TCStatus : %08lx\n", tcstatval); 111 printk(" TCStatus : %08lx\n", tcstatval);
113 printk(" TCBind : %08lx\n", read_tc_c0_tcbind()); 112 printk(" TCBind : %08lx\n", read_tc_c0_tcbind());
114 printk(" TCRestart : %08lx ", read_tc_c0_tcrestart()); 113 printk(" TCRestart : %08lx %pS\n",
115 print_symbol("%s\n", read_tc_c0_tcrestart()); 114 read_tc_c0_tcrestart(), (void *) read_tc_c0_tcrestart());
116 printk(" TCHalt : %08lx\n", haltval); 115 printk(" TCHalt : %08lx\n", haltval);
117 printk(" TCContext : %08lx\n", read_tc_c0_tccontext()); 116 printk(" TCContext : %08lx\n", read_tc_c0_tccontext());
118 if (!haltval) 117 if (!haltval)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 2c09a442e5e..c06f5b5d764 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -125,13 +125,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
125 *childregs = *regs; 125 *childregs = *regs;
126 childregs->regs[7] = 0; /* Clear error flag */ 126 childregs->regs[7] = 0; /* Clear error flag */
127 127
128#if defined(CONFIG_BINFMT_IRIX)
129 if (current->personality != PER_LINUX) {
130 /* Under IRIX things are a little different. */
131 childregs->regs[3] = 1;
132 regs->regs[3] = 0;
133 }
134#endif
135 childregs->regs[2] = 0; /* Child gets zero as return value */ 128 childregs->regs[2] = 0; /* Child gets zero as return value */
136 regs->regs[2] = p->pid; 129 regs->regs[2] = p->pid;
137 130
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 08a9c5070ea..c058c0b61a2 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -34,12 +34,8 @@ NESTED(handle_sys, PT_SIZE, sp)
34 34
35 lw t1, PT_EPC(sp) # skip syscall on return 35 lw t1, PT_EPC(sp) # skip syscall on return
36 36
37#if defined(CONFIG_BINFMT_IRIX)
38 sltiu t0, v0, MAX_SYSCALL_NO + 1 # check syscall number
39#else
40 subu v0, v0, __NR_O32_Linux # check syscall number 37 subu v0, v0, __NR_O32_Linux # check syscall number
41 sltiu t0, v0, __NR_O32_Linux_syscalls + 1 38 sltiu t0, v0, __NR_O32_Linux_syscalls + 1
42#endif
43 addiu t1, 4 # skip to next instruction 39 addiu t1, 4 # skip to next instruction
44 sw t1, PT_EPC(sp) 40 sw t1, PT_EPC(sp)
45 beqz t0, illegal_syscall 41 beqz t0, illegal_syscall
@@ -264,22 +260,14 @@ bad_alignment:
264 END(sys_sysmips) 260 END(sys_sysmips)
265 261
266 LEAF(sys_syscall) 262 LEAF(sys_syscall)
267#if defined(CONFIG_BINFMT_IRIX)
268 sltiu v0, a0, MAX_SYSCALL_NO + 1 # check syscall number
269#else
270 subu t0, a0, __NR_O32_Linux # check syscall number 263 subu t0, a0, __NR_O32_Linux # check syscall number
271 sltiu v0, t0, __NR_O32_Linux_syscalls + 1 264 sltiu v0, t0, __NR_O32_Linux_syscalls + 1
272#endif
273 sll t1, t0, 3 265 sll t1, t0, 3
274 beqz v0, einval 266 beqz v0, einval
275 267
276 lw t2, sys_call_table(t1) # syscall routine 268 lw t2, sys_call_table(t1) # syscall routine
277 269
278#if defined(CONFIG_BINFMT_IRIX)
279 li v1, 4000 # nr of sys_syscall
280#else
281 li v1, 4000 - __NR_O32_Linux # index of sys_syscall 270 li v1, 4000 - __NR_O32_Linux # index of sys_syscall
282#endif
283 beq t0, v1, einval # do not recurse 271 beq t0, v1, einval # do not recurse
284 272
285 /* Some syscalls like execve get their arguments from struct pt_regs 273 /* Some syscalls like execve get their arguments from struct pt_regs
@@ -324,13 +312,6 @@ einval: li v0, -EINVAL
324 .endm 312 .endm
325 313
326 .macro syscalltable 314 .macro syscalltable
327#if defined(CONFIG_BINFMT_IRIX)
328 mille sys_ni_syscall 0 /* 0 - 999 SVR4 flavour */
329 mille sys_ni_syscall 0 /* 1000 - 1999 32-bit IRIX */
330 mille sys_ni_syscall 0 /* 2000 - 2999 BSD43 flavour */
331 mille sys_ni_syscall 0 /* 3000 - 3999 POSIX flavour */
332#endif
333
334 sys sys_syscall 8 /* 4000 */ 315 sys sys_syscall 8 /* 4000 */
335 sys sys_exit 1 316 sys sys_exit 1
336 sys sys_fork 0 317 sys sys_fork 0
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c6a063b2a0d..8af84867e74 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -68,13 +68,6 @@ static char command_line[CL_SIZE];
68const unsigned long mips_io_port_base __read_mostly = -1; 68const unsigned long mips_io_port_base __read_mostly = -1;
69EXPORT_SYMBOL(mips_io_port_base); 69EXPORT_SYMBOL(mips_io_port_base);
70 70
71/*
72 * isa_slot_offset is the address where E(ISA) busaddress 0 is mapped
73 * for the processor.
74 */
75unsigned long isa_slot_offset;
76EXPORT_SYMBOL(isa_slot_offset);
77
78static struct resource code_resource = { .name = "Kernel code", }; 71static struct resource code_resource = { .name = "Kernel code", };
79static struct resource data_resource = { .name = "Kernel data", }; 72static struct resource data_resource = { .name = "Kernel data", };
80 73
@@ -557,11 +550,7 @@ void __init setup_arch(char **cmdline_p)
557 prom_init(); 550 prom_init();
558 551
559#ifdef CONFIG_EARLY_PRINTK 552#ifdef CONFIG_EARLY_PRINTK
560 { 553 setup_early_printk();
561 extern void setup_early_printk(void);
562
563 setup_early_printk();
564 }
565#endif 554#endif
566 cpu_report(); 555 cpu_report();
567 check_bugs_early(); 556 check_bugs_early();
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index cdf87a9dd4b..4410f172b8a 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -131,148 +131,29 @@ asmlinkage __cpuinit void start_secondary(void)
131 cpu_idle(); 131 cpu_idle();
132} 132}
133 133
134DEFINE_SPINLOCK(smp_call_lock); 134void arch_send_call_function_ipi(cpumask_t mask)
135
136struct call_data_struct *call_data;
137
138/*
139 * Run a function on all other CPUs.
140 *
141 * <mask> cpuset_t of all processors to run the function on.
142 * <func> The function to run. This must be fast and non-blocking.
143 * <info> An arbitrary pointer to pass to the function.
144 * <retry> If true, keep retrying until ready.
145 * <wait> If true, wait until function has completed on other CPUs.
146 * [RETURNS] 0 on success, else a negative status code.
147 *
148 * Does not return until remote CPUs are nearly ready to execute <func>
149 * or are or have executed.
150 *
151 * You must not call this function with disabled interrupts or from a
152 * hardware interrupt handler or from a bottom half handler:
153 *
154 * CPU A CPU B
155 * Disable interrupts
156 * smp_call_function()
157 * Take call_lock
158 * Send IPIs
159 * Wait for all cpus to acknowledge IPI
160 * CPU A has not responded, spin waiting
161 * for cpu A to respond, holding call_lock
162 * smp_call_function()
163 * Spin waiting for call_lock
164 * Deadlock Deadlock
165 */
166int smp_call_function_mask(cpumask_t mask, void (*func) (void *info),
167 void *info, int retry, int wait)
168{ 135{
169 struct call_data_struct data;
170 int cpu = smp_processor_id();
171 int cpus;
172
173 /*
174 * Can die spectacularly if this CPU isn't yet marked online
175 */
176 BUG_ON(!cpu_online(cpu));
177
178 cpu_clear(cpu, mask);
179 cpus = cpus_weight(mask);
180 if (!cpus)
181 return 0;
182
183 /* Can deadlock when called with interrupts disabled */
184 WARN_ON(irqs_disabled());
185
186 data.func = func;
187 data.info = info;
188 atomic_set(&data.started, 0);
189 data.wait = wait;
190 if (wait)
191 atomic_set(&data.finished, 0);
192
193 spin_lock(&smp_call_lock);
194 call_data = &data;
195 smp_mb();
196
197 /* Send a message to all other CPUs and wait for them to respond */
198 mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION); 136 mp_ops->send_ipi_mask(mask, SMP_CALL_FUNCTION);
199
200 /* Wait for response */
201 /* FIXME: lock-up detection, backtrace on lock-up */
202 while (atomic_read(&data.started) != cpus)
203 barrier();
204
205 if (wait)
206 while (atomic_read(&data.finished) != cpus)
207 barrier();
208 call_data = NULL;
209 spin_unlock(&smp_call_lock);
210
211 return 0;
212} 137}
213 138
214int smp_call_function(void (*func) (void *info), void *info, int retry, 139/*
215 int wait) 140 * We reuse the same vector for the single IPI
141 */
142void arch_send_call_function_single_ipi(int cpu)
216{ 143{
217 return smp_call_function_mask(cpu_online_map, func, info, retry, wait); 144 mp_ops->send_ipi_mask(cpumask_of_cpu(cpu), SMP_CALL_FUNCTION);
218} 145}
219EXPORT_SYMBOL(smp_call_function);
220 146
147/*
148 * Call into both interrupt handlers, as we share the IPI for them
149 */
221void smp_call_function_interrupt(void) 150void smp_call_function_interrupt(void)
222{ 151{
223 void (*func) (void *info) = call_data->func;
224 void *info = call_data->info;
225 int wait = call_data->wait;
226
227 /*
228 * Notify initiating CPU that I've grabbed the data and am
229 * about to execute the function.
230 */
231 smp_mb();
232 atomic_inc(&call_data->started);
233
234 /*
235 * At this point the info structure may be out of scope unless wait==1.
236 */
237 irq_enter(); 152 irq_enter();
238 (*func)(info); 153 generic_smp_call_function_single_interrupt();
154 generic_smp_call_function_interrupt();
239 irq_exit(); 155 irq_exit();
240
241 if (wait) {
242 smp_mb();
243 atomic_inc(&call_data->finished);
244 }
245}
246
247int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
248 int retry, int wait)
249{
250 int ret, me;
251
252 /*
253 * Can die spectacularly if this CPU isn't yet marked online
254 */
255 if (!cpu_online(cpu))
256 return 0;
257
258 me = get_cpu();
259 BUG_ON(!cpu_online(me));
260
261 if (cpu == me) {
262 local_irq_disable();
263 func(info);
264 local_irq_enable();
265 put_cpu();
266 return 0;
267 }
268
269 ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, retry,
270 wait);
271
272 put_cpu();
273 return 0;
274} 156}
275EXPORT_SYMBOL(smp_call_function_single);
276 157
277static void stop_this_cpu(void *dummy) 158static void stop_this_cpu(void *dummy)
278{ 159{
@@ -286,7 +167,7 @@ static void stop_this_cpu(void *dummy)
286 167
287void smp_send_stop(void) 168void smp_send_stop(void)
288{ 169{
289 smp_call_function(stop_this_cpu, NULL, 1, 0); 170 smp_call_function(stop_this_cpu, NULL, 0);
290} 171}
291 172
292void __init smp_cpus_done(unsigned int max_cpus) 173void __init smp_cpus_done(unsigned int max_cpus)
@@ -365,7 +246,7 @@ static void flush_tlb_all_ipi(void *info)
365 246
366void flush_tlb_all(void) 247void flush_tlb_all(void)
367{ 248{
368 on_each_cpu(flush_tlb_all_ipi, NULL, 1, 1); 249 on_each_cpu(flush_tlb_all_ipi, NULL, 1);
369} 250}
370 251
371static void flush_tlb_mm_ipi(void *mm) 252static void flush_tlb_mm_ipi(void *mm)
@@ -385,7 +266,7 @@ static void flush_tlb_mm_ipi(void *mm)
385static inline void smp_on_other_tlbs(void (*func) (void *info), void *info) 266static inline void smp_on_other_tlbs(void (*func) (void *info), void *info)
386{ 267{
387#ifndef CONFIG_MIPS_MT_SMTC 268#ifndef CONFIG_MIPS_MT_SMTC
388 smp_call_function(func, info, 1, 1); 269 smp_call_function(func, info, 1);
389#endif 270#endif
390} 271}
391 272
@@ -485,7 +366,7 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
485 .addr2 = end, 366 .addr2 = end,
486 }; 367 };
487 368
488 on_each_cpu(flush_tlb_kernel_range_ipi, &fd, 1, 1); 369 on_each_cpu(flush_tlb_kernel_range_ipi, &fd, 1);
489} 370}
490 371
491static void flush_tlb_page_ipi(void *info) 372static void flush_tlb_page_ipi(void *info)
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 3e863186cd2..a516286532a 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -877,7 +877,6 @@ static void ipi_resched_interrupt(void)
877 /* Return from interrupt should be enough to cause scheduler check */ 877 /* Return from interrupt should be enough to cause scheduler check */
878} 878}
879 879
880
881static void ipi_call_interrupt(void) 880static void ipi_call_interrupt(void)
882{ 881{
883 /* Invoke generic function invocation code in smp.c */ 882 /* Invoke generic function invocation code in smp.c */
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index ebd9db8d1ec..5eb4681a73d 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -73,3 +73,4 @@ void save_stack_trace(struct stack_trace *trace)
73 prepare_frametrace(regs); 73 prepare_frametrace(regs);
74 save_context_stack(trace, regs); 74 save_context_stack(trace, regs);
75} 75}
76EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
deleted file mode 100644
index c357762b801..00000000000
--- a/arch/mips/kernel/sysirix.c
+++ /dev/null
@@ -1,2140 +0,0 @@
1/*
2 * sysirix.c: IRIX system call emulation.
3 *
4 * Copyright (C) 1996 David S. Miller
5 * Copyright (C) 1997 Miguel de Icaza
6 * Copyright (C) 1997, 1998, 1999, 2000 Ralf Baechle
7 */
8#include <linux/kernel.h>
9#include <linux/sched.h>
10#include <linux/binfmts.h>
11#include <linux/capability.h>
12#include <linux/highuid.h>
13#include <linux/pagemap.h>
14#include <linux/mm.h>
15#include <linux/mman.h>
16#include <linux/slab.h>
17#include <linux/swap.h>
18#include <linux/errno.h>
19#include <linux/time.h>
20#include <linux/timex.h>
21#include <linux/times.h>
22#include <linux/elf.h>
23#include <linux/msg.h>
24#include <linux/shm.h>
25#include <linux/smp.h>
26#include <linux/smp_lock.h>
27#include <linux/utsname.h>
28#include <linux/file.h>
29#include <linux/vfs.h>
30#include <linux/namei.h>
31#include <linux/socket.h>
32#include <linux/security.h>
33#include <linux/syscalls.h>
34#include <linux/resource.h>
35
36#include <asm/ptrace.h>
37#include <asm/page.h>
38#include <asm/uaccess.h>
39#include <asm/inventory.h>
40
41/* 2,191 lines of complete and utter shit coming up... */
42
43extern int max_threads;
44
45/* The sysmp commands supported thus far. */
46#define MP_NPROCS 1 /* # processor in complex */
47#define MP_NAPROCS 2 /* # active processors in complex */
48#define MP_PGSIZE 14 /* Return system page size in v1. */
49
50asmlinkage int irix_sysmp(struct pt_regs *regs)
51{
52 unsigned long cmd;
53 int base = 0;
54 int error = 0;
55
56 if(regs->regs[2] == 1000)
57 base = 1;
58 cmd = regs->regs[base + 4];
59 switch(cmd) {
60 case MP_PGSIZE:
61 error = PAGE_SIZE;
62 break;
63 case MP_NPROCS:
64 case MP_NAPROCS:
65 error = num_online_cpus();
66 break;
67 default:
68 printk("SYSMP[%s:%d]: Unsupported opcode %d\n",
69 current->comm, current->pid, (int)cmd);
70 error = -EINVAL;
71 break;
72 }
73
74 return error;
75}
76
77/* The prctl commands. */
78#define PR_MAXPROCS 1 /* Tasks/user. */
79#define PR_ISBLOCKED 2 /* If blocked, return 1. */
80#define PR_SETSTACKSIZE 3 /* Set largest task stack size. */
81#define PR_GETSTACKSIZE 4 /* Get largest task stack size. */
82#define PR_MAXPPROCS 5 /* Num parallel tasks. */
83#define PR_UNBLKONEXEC 6 /* When task exec/exit's, unblock. */
84#define PR_SETEXITSIG 8 /* When task exit's, set signal. */
85#define PR_RESIDENT 9 /* Make task unswappable. */
86#define PR_ATTACHADDR 10 /* (Re-)Connect a vma to a task. */
87#define PR_DETACHADDR 11 /* Disconnect a vma from a task. */
88#define PR_TERMCHILD 12 /* Kill child if the parent dies. */
89#define PR_GETSHMASK 13 /* Get the sproc() share mask. */
90#define PR_GETNSHARE 14 /* Number of share group members. */
91#define PR_COREPID 15 /* Add task pid to name when it core. */
92#define PR_ATTACHADDRPERM 16 /* (Re-)Connect vma, with specified prot. */
93#define PR_PTHREADEXIT 17 /* Kill a pthread, only for IRIX 6.[234] */
94
95asmlinkage int irix_prctl(unsigned option, ...)
96{
97 va_list args;
98 int error = 0;
99
100 va_start(args, option);
101 switch (option) {
102 case PR_MAXPROCS:
103 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
104 current->comm, current->pid);
105 error = max_threads;
106 break;
107
108 case PR_ISBLOCKED: {
109 struct task_struct *task;
110
111 printk("irix_prctl[%s:%d]: Wants PR_ISBLOCKED\n",
112 current->comm, current->pid);
113 read_lock(&tasklist_lock);
114 task = find_task_by_vpid(va_arg(args, pid_t));
115 error = -ESRCH;
116 if (error)
117 error = (task->run_list.next != NULL);
118 read_unlock(&tasklist_lock);
119 /* Can _your_ OS find this out that fast? */
120 break;
121 }
122
123 case PR_SETSTACKSIZE: {
124 long value = va_arg(args, long);
125
126 printk("irix_prctl[%s:%d]: Wants PR_SETSTACKSIZE<%08lx>\n",
127 current->comm, current->pid, (unsigned long) value);
128 if (value > RLIM_INFINITY)
129 value = RLIM_INFINITY;
130 if (capable(CAP_SYS_ADMIN)) {
131 task_lock(current->group_leader);
132 current->signal->rlim[RLIMIT_STACK].rlim_max =
133 current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
134 task_unlock(current->group_leader);
135 error = value;
136 break;
137 }
138 task_lock(current->group_leader);
139 if (value > current->signal->rlim[RLIMIT_STACK].rlim_max) {
140 error = -EINVAL;
141 task_unlock(current->group_leader);
142 break;
143 }
144 current->signal->rlim[RLIMIT_STACK].rlim_cur = value;
145 task_unlock(current->group_leader);
146 error = value;
147 break;
148 }
149
150 case PR_GETSTACKSIZE:
151 printk("irix_prctl[%s:%d]: Wants PR_GETSTACKSIZE\n",
152 current->comm, current->pid);
153 error = current->signal->rlim[RLIMIT_STACK].rlim_cur;
154 break;
155
156 case PR_MAXPPROCS:
157 printk("irix_prctl[%s:%d]: Wants PR_MAXPROCS\n",
158 current->comm, current->pid);
159 error = 1;
160 break;
161
162 case PR_UNBLKONEXEC:
163 printk("irix_prctl[%s:%d]: Wants PR_UNBLKONEXEC\n",
164 current->comm, current->pid);
165 error = -EINVAL;
166 break;
167
168 case PR_SETEXITSIG:
169 printk("irix_prctl[%s:%d]: Wants PR_SETEXITSIG\n",
170 current->comm, current->pid);
171
172 /* We can probably play some game where we set the task
173 * exit_code to some non-zero value when this is requested,
174 * and check whether exit_code is already set in do_exit().
175 */
176 error = -EINVAL;
177 break;
178
179 case PR_RESIDENT:
180 printk("irix_prctl[%s:%d]: Wants PR_RESIDENT\n",
181 current->comm, current->pid);
182 error = 0; /* Compatibility indeed. */
183 break;
184
185 case PR_ATTACHADDR:
186 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDR\n",
187 current->comm, current->pid);
188 error = -EINVAL;
189 break;
190
191 case PR_DETACHADDR:
192 printk("irix_prctl[%s:%d]: Wants PR_DETACHADDR\n",
193 current->comm, current->pid);
194 error = -EINVAL;
195 break;
196
197 case PR_TERMCHILD:
198 printk("irix_prctl[%s:%d]: Wants PR_TERMCHILD\n",
199 current->comm, current->pid);
200 error = -EINVAL;
201 break;
202
203 case PR_GETSHMASK:
204 printk("irix_prctl[%s:%d]: Wants PR_GETSHMASK\n",
205 current->comm, current->pid);
206 error = -EINVAL; /* Until I have the sproc() stuff in. */
207 break;
208
209 case PR_GETNSHARE:
210 error = 0; /* Until I have the sproc() stuff in. */
211 break;
212
213 case PR_COREPID:
214 printk("irix_prctl[%s:%d]: Wants PR_COREPID\n",
215 current->comm, current->pid);
216 error = -EINVAL;
217 break;
218
219 case PR_ATTACHADDRPERM:
220 printk("irix_prctl[%s:%d]: Wants PR_ATTACHADDRPERM\n",
221 current->comm, current->pid);
222 error = -EINVAL;
223 break;
224
225 default:
226 printk("irix_prctl[%s:%d]: Non-existant opcode %d\n",
227 current->comm, current->pid, option);
228 error = -EINVAL;
229 break;
230 }
231 va_end(args);
232
233 return error;
234}
235
236#undef DEBUG_PROCGRPS
237
238extern unsigned long irix_mapelf(int fd, struct elf_phdr __user *user_phdrp, int cnt);
239extern char *prom_getenv(char *name);
240extern long prom_setenv(char *name, char *value);
241
242/* The syssgi commands supported thus far. */
243#define SGI_SYSID 1 /* Return unique per-machine identifier. */
244#define SGI_INVENT 5 /* Fetch inventory */
245# define SGI_INV_SIZEOF 1
246# define SGI_INV_READ 2
247#define SGI_RDNAME 6 /* Return string name of a process. */
248#define SGI_SETNVRAM 8 /* Set PROM variable. */
249#define SGI_GETNVRAM 9 /* Get PROM variable. */
250#define SGI_SETPGID 21 /* Set process group id. */
251#define SGI_SYSCONF 22 /* POSIX sysconf garbage. */
252#define SGI_PATHCONF 24 /* POSIX sysconf garbage. */
253#define SGI_SETGROUPS 40 /* POSIX sysconf garbage. */
254#define SGI_GETGROUPS 41 /* POSIX sysconf garbage. */
255#define SGI_RUSAGE 56 /* BSD style rusage(). */
256#define SGI_SSYNC 62 /* Synchronous fs sync. */
257#define SGI_GETSID 65 /* SysVr4 get session id. */
258#define SGI_ELFMAP 68 /* Map an elf image. */
259#define SGI_TOSSTSAVE 108 /* Toss saved vma's. */
260#define SGI_FP_BCOPY 129 /* Should FPU bcopy be used on this machine? */
261#define SGI_PHYSP 1011 /* Translate virtual into physical page. */
262
263asmlinkage int irix_syssgi(struct pt_regs *regs)
264{
265 unsigned long cmd;
266 int retval, base = 0;
267
268 if (regs->regs[2] == 1000)
269 base = 1;
270
271 cmd = regs->regs[base + 4];
272 switch(cmd) {
273 case SGI_SYSID: {
274 char __user *buf = (char __user *) regs->regs[base + 5];
275
276 /* XXX Use ethernet addr.... */
277 retval = clear_user(buf, 64) ? -EFAULT : 0;
278 break;
279 }
280#if 0
281 case SGI_RDNAME: {
282 int pid = (int) regs->regs[base + 5];
283 char __user *buf = (char __user *) regs->regs[base + 6];
284 struct task_struct *p;
285 char tcomm[sizeof(current->comm)];
286
287 read_lock(&tasklist_lock);
288 p = find_task_by_pid(pid);
289 if (!p) {
290 read_unlock(&tasklist_lock);
291 retval = -ESRCH;
292 break;
293 }
294 get_task_comm(tcomm, p);
295 read_unlock(&tasklist_lock);
296
297 /* XXX Need to check sizes. */
298 retval = copy_to_user(buf, tcomm, sizeof(tcomm)) ? -EFAULT : 0;
299 break;
300 }
301
302 case SGI_GETNVRAM: {
303 char __user *name = (char __user *) regs->regs[base+5];
304 char __user *buf = (char __user *) regs->regs[base+6];
305 char *value;
306 return -EINVAL; /* til I fix it */
307 value = prom_getenv(name); /* PROM lock? */
308 if (!value) {
309 retval = -EINVAL;
310 break;
311 }
312 /* Do I strlen() for the length? */
313 retval = copy_to_user(buf, value, 128) ? -EFAULT : 0;
314 break;
315 }
316
317 case SGI_SETNVRAM: {
318 char __user *name = (char __user *) regs->regs[base+5];
319 char __user *value = (char __user *) regs->regs[base+6];
320 return -EINVAL; /* til I fix it */
321 retval = prom_setenv(name, value);
322 /* XXX make sure retval conforms to syssgi(2) */
323 printk("[%s:%d] setnvram(\"%s\", \"%s\"): retval %d",
324 current->comm, current->pid, name, value, retval);
325/* if (retval == PROM_ENOENT)
326 retval = -ENOENT; */
327 break;
328 }
329#endif
330
331 case SGI_SETPGID: {
332#ifdef DEBUG_PROCGRPS
333 printk("[%s:%d] setpgid(%d, %d) ",
334 current->comm, current->pid,
335 (int) regs->regs[base + 5], (int)regs->regs[base + 6]);
336#endif
337 retval = sys_setpgid(regs->regs[base + 5], regs->regs[base + 6]);
338
339#ifdef DEBUG_PROCGRPS
340 printk("retval=%d\n", retval);
341#endif
342 }
343
344 case SGI_SYSCONF: {
345 switch(regs->regs[base + 5]) {
346 case 1:
347 retval = (MAX_ARG_PAGES >> 4); /* XXX estimate... */
348 goto out;
349 case 2:
350 retval = max_threads;
351 goto out;
352 case 3:
353 retval = HZ;
354 goto out;
355 case 4:
356 retval = NGROUPS_MAX;
357 goto out;
358 case 5:
359 retval = sysctl_nr_open;
360 goto out;
361 case 6:
362 retval = 1;
363 goto out;
364 case 7:
365 retval = 1;
366 goto out;
367 case 8:
368 retval = 199009;
369 goto out;
370 case 11:
371 retval = PAGE_SIZE;
372 goto out;
373 case 12:
374 retval = 4;
375 goto out;
376 case 25:
377 case 26:
378 case 27:
379 case 28:
380 case 29:
381 case 30:
382 retval = 0;
383 goto out;
384 case 31:
385 retval = 32;
386 goto out;
387 default:
388 retval = -EINVAL;
389 goto out;
390 };
391 }
392
393 case SGI_SETGROUPS:
394 retval = sys_setgroups((int) regs->regs[base + 5],
395 (gid_t __user *) regs->regs[base + 6]);
396 break;
397
398 case SGI_GETGROUPS:
399 retval = sys_getgroups((int) regs->regs[base + 5],
400 (gid_t __user *) regs->regs[base + 6]);
401 break;
402
403 case SGI_RUSAGE: {
404 struct rusage __user *ru = (struct rusage __user *) regs->regs[base + 6];
405
406 switch((int) regs->regs[base + 5]) {
407 case 0:
408 /* rusage self */
409 retval = getrusage(current, RUSAGE_SELF, ru);
410 goto out;
411
412 case -1:
413 /* rusage children */
414 retval = getrusage(current, RUSAGE_CHILDREN, ru);
415 goto out;
416
417 default:
418 retval = -EINVAL;
419 goto out;
420 };
421 }
422
423 case SGI_SSYNC:
424 sys_sync();
425 retval = 0;
426 break;
427
428 case SGI_GETSID:
429#ifdef DEBUG_PROCGRPS
430 printk("[%s:%d] getsid(%d) ", current->comm, current->pid,
431 (int) regs->regs[base + 5]);
432#endif
433 retval = sys_getsid(regs->regs[base + 5]);
434#ifdef DEBUG_PROCGRPS
435 printk("retval=%d\n", retval);
436#endif
437 break;
438
439 case SGI_ELFMAP:
440 retval = irix_mapelf((int) regs->regs[base + 5],
441 (struct elf_phdr __user *) regs->regs[base + 6],
442 (int) regs->regs[base + 7]);
443 break;
444
445 case SGI_TOSSTSAVE:
446 /* XXX We don't need to do anything? */
447 retval = 0;
448 break;
449
450 case SGI_FP_BCOPY:
451 retval = 0;
452 break;
453
454 case SGI_PHYSP: {
455 unsigned long addr = regs->regs[base + 5];
456 int __user *pageno = (int __user *) (regs->regs[base + 6]);
457 struct mm_struct *mm = current->mm;
458 pgd_t *pgdp;
459 pud_t *pudp;
460 pmd_t *pmdp;
461 pte_t *ptep;
462
463 down_read(&mm->mmap_sem);
464 pgdp = pgd_offset(mm, addr);
465 pudp = pud_offset(pgdp, addr);
466 pmdp = pmd_offset(pudp, addr);
467 ptep = pte_offset(pmdp, addr);
468 retval = -EINVAL;
469 if (ptep) {
470 pte_t pte = *ptep;
471
472 if (pte_val(pte) & (_PAGE_VALID | _PAGE_PRESENT)) {
473 /* b0rked on 64-bit */
474 retval = put_user((pte_val(pte) & PAGE_MASK) >>
475 PAGE_SHIFT, pageno);
476 }
477 }
478 up_read(&mm->mmap_sem);
479 break;
480 }
481
482 case SGI_INVENT: {
483 int arg1 = (int) regs->regs [base + 5];
484 void __user *buffer = (void __user *) regs->regs [base + 6];
485 int count = (int) regs->regs [base + 7];
486
487 switch (arg1) {
488 case SGI_INV_SIZEOF:
489 retval = sizeof(inventory_t);
490 break;
491 case SGI_INV_READ:
492 retval = dump_inventory_to_user(buffer, count);
493 break;
494 default:
495 retval = -EINVAL;
496 }
497 break;
498 }
499
500 default:
501 printk("irix_syssgi: Unsupported command %d\n", (int)cmd);
502 retval = -EINVAL;
503 break;
504 };
505
506out:
507 return retval;
508}
509
510asmlinkage int irix_gtime(struct pt_regs *regs)
511{
512 return get_seconds();
513}
514
515/*
516 * IRIX is completely broken... it returns 0 on success, otherwise
517 * ENOMEM.
518 */
519asmlinkage int irix_brk(unsigned long brk)
520{
521 unsigned long rlim;
522 unsigned long newbrk, oldbrk;
523 struct mm_struct *mm = current->mm;
524 int ret;
525
526 down_write(&mm->mmap_sem);
527 if (brk < mm->end_code) {
528 ret = -ENOMEM;
529 goto out;
530 }
531
532 newbrk = PAGE_ALIGN(brk);
533 oldbrk = PAGE_ALIGN(mm->brk);
534 if (oldbrk == newbrk) {
535 mm->brk = brk;
536 ret = 0;
537 goto out;
538 }
539
540 /*
541 * Always allow shrinking brk
542 */
543 if (brk <= mm->brk) {
544 mm->brk = brk;
545 do_munmap(mm, newbrk, oldbrk-newbrk);
546 ret = 0;
547 goto out;
548 }
549 /*
550 * Check against rlimit and stack..
551 */
552 rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
553 if (rlim >= RLIM_INFINITY)
554 rlim = ~0;
555 if (brk - mm->end_code > rlim) {
556 ret = -ENOMEM;
557 goto out;
558 }
559
560 /*
561 * Check against existing mmap mappings.
562 */
563 if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE)) {
564 ret = -ENOMEM;
565 goto out;
566 }
567
568 /*
569 * Ok, looks good - let it rip.
570 */
571 if (do_brk(oldbrk, newbrk-oldbrk) != oldbrk) {
572 ret = -ENOMEM;
573 goto out;
574 }
575 mm->brk = brk;
576 ret = 0;
577
578out:
579 up_write(&mm->mmap_sem);
580 return ret;
581}
582
583asmlinkage int irix_getpid(struct pt_regs *regs)
584{
585 regs->regs[3] = task_pid_vnr(current->real_parent);
586 return task_pid_vnr(current);
587}
588
589asmlinkage int irix_getuid(struct pt_regs *regs)
590{
591 regs->regs[3] = current->euid;
592 return current->uid;
593}
594
595asmlinkage int irix_getgid(struct pt_regs *regs)
596{
597 regs->regs[3] = current->egid;
598 return current->gid;
599}
600
601asmlinkage int irix_stime(int value)
602{
603 int err;
604 struct timespec tv;
605
606 tv.tv_sec = value;
607 tv.tv_nsec = 0;
608 err = security_settime(&tv, NULL);
609 if (err)
610 return err;
611
612 write_seqlock_irq(&xtime_lock);
613 xtime.tv_sec = value;
614 xtime.tv_nsec = 0;
615 ntp_clear();
616 write_sequnlock_irq(&xtime_lock);
617
618 return 0;
619}
620
621static inline void jiffiestotv(unsigned long jiffies, struct timeval *value)
622{
623 value->tv_usec = (jiffies % HZ) * (1000000 / HZ);
624 value->tv_sec = jiffies / HZ;
625}
626
627static inline void getitimer_real(struct itimerval *value)
628{
629 register unsigned long val, interval;
630
631 interval = current->it_real_incr;
632 val = 0;
633 if (del_timer(&current->real_timer)) {
634 unsigned long now = jiffies;
635 val = current->real_timer.expires;
636 add_timer(&current->real_timer);
637 /* look out for negative/zero itimer.. */
638 if (val <= now)
639 val = now+1;
640 val -= now;
641 }
642 jiffiestotv(val, &value->it_value);
643 jiffiestotv(interval, &value->it_interval);
644}
645
646asmlinkage unsigned int irix_alarm(unsigned int seconds)
647{
648 return alarm_setitimer(seconds);
649}
650
651asmlinkage int irix_pause(void)
652{
653 current->state = TASK_INTERRUPTIBLE;
654 schedule();
655
656 return -EINTR;
657}
658
659/* XXX need more than this... */
660asmlinkage int irix_mount(char __user *dev_name, char __user *dir_name,
661 unsigned long flags, char __user *type, void __user *data, int datalen)
662{
663 printk("[%s:%d] irix_mount(%p,%p,%08lx,%p,%p,%d)\n",
664 current->comm, current->pid,
665 dev_name, dir_name, flags, type, data, datalen);
666
667 return sys_mount(dev_name, dir_name, type, flags, data);
668}
669
670struct irix_statfs {
671 short f_type;
672 long f_bsize, f_frsize, f_blocks, f_bfree, f_files, f_ffree;
673 char f_fname[6], f_fpack[6];
674};
675
676asmlinkage int irix_statfs(const char __user *path,
677 struct irix_statfs __user *buf, int len, int fs_type)
678{
679 struct nameidata nd;
680 struct kstatfs kbuf;
681 int error, i;
682
683 /* We don't support this feature yet. */
684 if (fs_type) {
685 error = -EINVAL;
686 goto out;
687 }
688 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
689 error = -EFAULT;
690 goto out;
691 }
692
693 error = user_path_walk(path, &nd);
694 if (error)
695 goto out;
696
697 error = vfs_statfs(nd.path.dentry, &kbuf);
698 if (error)
699 goto dput_and_out;
700
701 error = __put_user(kbuf.f_type, &buf->f_type);
702 error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
703 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
704 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
705 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
706 error |= __put_user(kbuf.f_files, &buf->f_files);
707 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
708 for (i = 0; i < 6; i++) {
709 error |= __put_user(0, &buf->f_fname[i]);
710 error |= __put_user(0, &buf->f_fpack[i]);
711 }
712
713dput_and_out:
714 path_put(&nd.path);
715out:
716 return error;
717}
718
719asmlinkage int irix_fstatfs(unsigned int fd, struct irix_statfs __user *buf)
720{
721 struct kstatfs kbuf;
722 struct file *file;
723 int error, i;
724
725 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statfs))) {
726 error = -EFAULT;
727 goto out;
728 }
729
730 if (!(file = fget(fd))) {
731 error = -EBADF;
732 goto out;
733 }
734
735 error = vfs_statfs(file->f_path.dentry, &kbuf);
736 if (error)
737 goto out_f;
738
739 error = __put_user(kbuf.f_type, &buf->f_type);
740 error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
741 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
742 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
743 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
744 error |= __put_user(kbuf.f_files, &buf->f_files);
745 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
746
747 for (i = 0; i < 6; i++) {
748 error |= __put_user(0, &buf->f_fname[i]);
749 error |= __put_user(0, &buf->f_fpack[i]);
750 }
751
752out_f:
753 fput(file);
754out:
755 return error;
756}
757
758asmlinkage int irix_setpgrp(int flags)
759{
760 int error;
761
762#ifdef DEBUG_PROCGRPS
763 printk("[%s:%d] setpgrp(%d) ", current->comm, current->pid, flags);
764#endif
765 if(!flags)
766 error = task_pgrp_vnr(current);
767 else
768 error = sys_setsid();
769#ifdef DEBUG_PROCGRPS
770 printk("returning %d\n", error);
771#endif
772
773 return error;
774}
775
776asmlinkage int irix_times(struct tms __user *tbuf)
777{
778 int err = 0;
779
780 if (tbuf) {
781 if (!access_ok(VERIFY_WRITE, tbuf, sizeof *tbuf))
782 return -EFAULT;
783
784 err = __put_user(current->utime, &tbuf->tms_utime);
785 err |= __put_user(current->stime, &tbuf->tms_stime);
786 err |= __put_user(current->signal->cutime, &tbuf->tms_cutime);
787 err |= __put_user(current->signal->cstime, &tbuf->tms_cstime);
788 }
789
790 return err;
791}
792
793asmlinkage int irix_exec(struct pt_regs *regs)
794{
795 int error, base = 0;
796 char *filename;
797
798 if(regs->regs[2] == 1000)
799 base = 1;
800 filename = getname((char __user *) (long)regs->regs[base + 4]);
801 error = PTR_ERR(filename);
802 if (IS_ERR(filename))
803 return error;
804
805 error = do_execve(filename, (char __user * __user *) (long)regs->regs[base + 5],
806 NULL, regs);
807 putname(filename);
808
809 return error;
810}
811
812asmlinkage int irix_exece(struct pt_regs *regs)
813{
814 int error, base = 0;
815 char *filename;
816
817 if (regs->regs[2] == 1000)
818 base = 1;
819 filename = getname((char __user *) (long)regs->regs[base + 4]);
820 error = PTR_ERR(filename);
821 if (IS_ERR(filename))
822 return error;
823 error = do_execve(filename, (char __user * __user *) (long)regs->regs[base + 5],
824 (char __user * __user *) (long)regs->regs[base + 6], regs);
825 putname(filename);
826
827 return error;
828}
829
830asmlinkage unsigned long irix_gethostid(void)
831{
832 printk("[%s:%d]: irix_gethostid() called...\n",
833 current->comm, current->pid);
834
835 return -EINVAL;
836}
837
838asmlinkage unsigned long irix_sethostid(unsigned long val)
839{
840 printk("[%s:%d]: irix_sethostid(%08lx) called...\n",
841 current->comm, current->pid, val);
842
843 return -EINVAL;
844}
845
846asmlinkage int irix_socket(int family, int type, int protocol)
847{
848 switch(type) {
849 case 1:
850 type = SOCK_DGRAM;
851 break;
852
853 case 2:
854 type = SOCK_STREAM;
855 break;
856
857 case 3:
858 type = 9; /* Invalid... */
859 break;
860
861 case 4:
862 type = SOCK_RAW;
863 break;
864
865 case 5:
866 type = SOCK_RDM;
867 break;
868
869 case 6:
870 type = SOCK_SEQPACKET;
871 break;
872
873 default:
874 break;
875 }
876
877 return sys_socket(family, type, protocol);
878}
879
880asmlinkage int irix_getdomainname(char __user *name, int len)
881{
882 int err;
883
884 down_read(&uts_sem);
885 if (len > __NEW_UTS_LEN)
886 len = __NEW_UTS_LEN;
887 err = copy_to_user(name, utsname()->domainname, len) ? -EFAULT : 0;
888 up_read(&uts_sem);
889
890 return err;
891}
892
893asmlinkage unsigned long irix_getpagesize(void)
894{
895 return PAGE_SIZE;
896}
897
898asmlinkage int irix_msgsys(int opcode, unsigned long arg0, unsigned long arg1,
899 unsigned long arg2, unsigned long arg3,
900 unsigned long arg4)
901{
902 switch (opcode) {
903 case 0:
904 return sys_msgget((key_t) arg0, (int) arg1);
905 case 1:
906 return sys_msgctl((int) arg0, (int) arg1,
907 (struct msqid_ds __user *)arg2);
908 case 2:
909 return sys_msgrcv((int) arg0, (struct msgbuf __user *) arg1,
910 (size_t) arg2, (long) arg3, (int) arg4);
911 case 3:
912 return sys_msgsnd((int) arg0, (struct msgbuf __user *) arg1,
913 (size_t) arg2, (int) arg3);
914 default:
915 return -EINVAL;
916 }
917}
918
919asmlinkage int irix_shmsys(int opcode, unsigned long arg0, unsigned long arg1,
920 unsigned long arg2, unsigned long arg3)
921{
922 switch (opcode) {
923 case 0:
924 return do_shmat((int) arg0, (char __user *) arg1, (int) arg2,
925 (unsigned long *) arg3);
926 case 1:
927 return sys_shmctl((int)arg0, (int)arg1,
928 (struct shmid_ds __user *)arg2);
929 case 2:
930 return sys_shmdt((char __user *)arg0);
931 case 3:
932 return sys_shmget((key_t) arg0, (int) arg1, (int) arg2);
933 default:
934 return -EINVAL;
935 }
936}
937
938asmlinkage int irix_semsys(int opcode, unsigned long arg0, unsigned long arg1,
939 unsigned long arg2, int arg3)
940{
941 switch (opcode) {
942 case 0:
943 return sys_semctl((int) arg0, (int) arg1, (int) arg2,
944 (union semun) arg3);
945 case 1:
946 return sys_semget((key_t) arg0, (int) arg1, (int) arg2);
947 case 2:
948 return sys_semop((int) arg0, (struct sembuf __user *)arg1,
949 (unsigned int) arg2);
950 default:
951 return -EINVAL;
952 }
953}
954
955static inline loff_t llseek(struct file *file, loff_t offset, int origin)
956{
957 loff_t (*fn)(struct file *, loff_t, int);
958 loff_t retval;
959
960 fn = default_llseek;
961 if (file->f_op && file->f_op->llseek)
962 fn = file->f_op->llseek;
963 lock_kernel();
964 retval = fn(file, offset, origin);
965 unlock_kernel();
966
967 return retval;
968}
969
970asmlinkage int irix_lseek64(int fd, int _unused, int offhi, int offlow,
971 int origin)
972{
973 struct file * file;
974 loff_t offset;
975 int retval;
976
977 retval = -EBADF;
978 file = fget(fd);
979 if (!file)
980 goto bad;
981 retval = -EINVAL;
982 if (origin > 2)
983 goto out_putf;
984
985 offset = llseek(file, ((loff_t) offhi << 32) | offlow, origin);
986 retval = (int) offset;
987
988out_putf:
989 fput(file);
990bad:
991 return retval;
992}
993
994asmlinkage int irix_sginap(int ticks)
995{
996 schedule_timeout_interruptible(ticks);
997 return 0;
998}
999
1000asmlinkage int irix_sgikopt(char __user *istring, char __user *ostring, int len)
1001{
1002 return -EINVAL;
1003}
1004
1005asmlinkage int irix_gettimeofday(struct timeval __user *tv)
1006{
1007 time_t sec;
1008 long nsec, seq;
1009 int err;
1010
1011 if (!access_ok(VERIFY_WRITE, tv, sizeof(struct timeval)))
1012 return -EFAULT;
1013
1014 do {
1015 seq = read_seqbegin(&xtime_lock);
1016 sec = xtime.tv_sec;
1017 nsec = xtime.tv_nsec;
1018 } while (read_seqretry(&xtime_lock, seq));
1019
1020 err = __put_user(sec, &tv->tv_sec);
1021 err |= __put_user((nsec / 1000), &tv->tv_usec);
1022
1023 return err;
1024}
1025
1026#define IRIX_MAP_AUTOGROW 0x40
1027
1028asmlinkage unsigned long irix_mmap32(unsigned long addr, size_t len, int prot,
1029 int flags, int fd, off_t offset)
1030{
1031 struct file *file = NULL;
1032 unsigned long retval;
1033
1034 if (!(flags & MAP_ANONYMOUS)) {
1035 if (!(file = fget(fd)))
1036 return -EBADF;
1037
1038 /* Ok, bad taste hack follows, try to think in something else
1039 * when reading this. */
1040 if (flags & IRIX_MAP_AUTOGROW) {
1041 unsigned long old_pos;
1042 long max_size = offset + len;
1043
1044 if (max_size > file->f_path.dentry->d_inode->i_size) {
1045 old_pos = sys_lseek(fd, max_size - 1, 0);
1046 sys_write(fd, (void __user *) "", 1);
1047 sys_lseek(fd, old_pos, 0);
1048 }
1049 }
1050 }
1051
1052 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1053
1054 down_write(&current->mm->mmap_sem);
1055 retval = do_mmap(file, addr, len, prot, flags, offset);
1056 up_write(&current->mm->mmap_sem);
1057 if (file)
1058 fput(file);
1059
1060 return retval;
1061}
1062
1063asmlinkage int irix_madvise(unsigned long addr, int len, int behavior)
1064{
1065 printk("[%s:%d] Wheee.. irix_madvise(%08lx,%d,%d)\n",
1066 current->comm, current->pid, addr, len, behavior);
1067
1068 return -EINVAL;
1069}
1070
1071asmlinkage int irix_pagelock(char __user *addr, int len, int op)
1072{
1073 printk("[%s:%d] Wheee.. irix_pagelock(%p,%d,%d)\n",
1074 current->comm, current->pid, addr, len, op);
1075
1076 return -EINVAL;
1077}
1078
1079asmlinkage int irix_quotactl(struct pt_regs *regs)
1080{
1081 printk("[%s:%d] Wheee.. irix_quotactl()\n",
1082 current->comm, current->pid);
1083
1084 return -EINVAL;
1085}
1086
1087asmlinkage int irix_BSDsetpgrp(int pid, int pgrp)
1088{
1089 int error;
1090
1091#ifdef DEBUG_PROCGRPS
1092 printk("[%s:%d] BSDsetpgrp(%d, %d) ", current->comm, current->pid,
1093 pid, pgrp);
1094#endif
1095 if(!pid)
1096 pid = task_pid_vnr(current);
1097
1098 /* Wheee, weird sysv thing... */
1099 if ((pgrp == 0) && (pid == task_pid_vnr(current)))
1100 error = sys_setsid();
1101 else
1102 error = sys_setpgid(pid, pgrp);
1103
1104#ifdef DEBUG_PROCGRPS
1105 printk("error = %d\n", error);
1106#endif
1107
1108 return error;
1109}
1110
1111asmlinkage int irix_systeminfo(int cmd, char __user *buf, int cnt)
1112{
1113 printk("[%s:%d] Wheee.. irix_systeminfo(%d,%p,%d)\n",
1114 current->comm, current->pid, cmd, buf, cnt);
1115
1116 return -EINVAL;
1117}
1118
1119struct iuname {
1120 char sysname[257], nodename[257], release[257];
1121 char version[257], machine[257];
1122 char m_type[257], base_rel[257];
1123 char _unused0[257], _unused1[257], _unused2[257];
1124 char _unused3[257], _unused4[257], _unused5[257];
1125};
1126
1127asmlinkage int irix_uname(struct iuname __user *buf)
1128{
1129 down_read(&uts_sem);
1130 if (copy_from_user(utsname()->sysname, buf->sysname, 65)
1131 || copy_from_user(utsname()->nodename, buf->nodename, 65)
1132 || copy_from_user(utsname()->release, buf->release, 65)
1133 || copy_from_user(utsname()->version, buf->version, 65)
1134 || copy_from_user(utsname()->machine, buf->machine, 65)) {
1135 return -EFAULT;
1136 }
1137 up_read(&uts_sem);
1138
1139 return 1;
1140}
1141
1142#undef DEBUG_XSTAT
1143
1144static int irix_xstat32_xlate(struct kstat *stat, void __user *ubuf)
1145{
1146 struct xstat32 {
1147 u32 st_dev, st_pad1[3], st_ino, st_mode, st_nlink, st_uid, st_gid;
1148 u32 st_rdev, st_pad2[2], st_size, st_pad3;
1149 u32 st_atime0, st_atime1;
1150 u32 st_mtime0, st_mtime1;
1151 u32 st_ctime0, st_ctime1;
1152 u32 st_blksize, st_blocks;
1153 char st_fstype[16];
1154 u32 st_pad4[8];
1155 } ub;
1156
1157 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1158 return -EOVERFLOW;
1159 ub.st_dev = sysv_encode_dev(stat->dev);
1160 ub.st_ino = stat->ino;
1161 ub.st_mode = stat->mode;
1162 ub.st_nlink = stat->nlink;
1163 SET_UID(ub.st_uid, stat->uid);
1164 SET_GID(ub.st_gid, stat->gid);
1165 ub.st_rdev = sysv_encode_dev(stat->rdev);
1166#if BITS_PER_LONG == 32
1167 if (stat->size > MAX_NON_LFS)
1168 return -EOVERFLOW;
1169#endif
1170 ub.st_size = stat->size;
1171 ub.st_atime0 = stat->atime.tv_sec;
1172 ub.st_atime1 = stat->atime.tv_nsec;
1173 ub.st_mtime0 = stat->mtime.tv_sec;
1174 ub.st_mtime1 = stat->atime.tv_nsec;
1175 ub.st_ctime0 = stat->ctime.tv_sec;
1176 ub.st_ctime1 = stat->atime.tv_nsec;
1177 ub.st_blksize = stat->blksize;
1178 ub.st_blocks = stat->blocks;
1179 strcpy(ub.st_fstype, "efs");
1180
1181 return copy_to_user(ubuf, &ub, sizeof(ub)) ? -EFAULT : 0;
1182}
1183
1184static int irix_xstat64_xlate(struct kstat *stat, void __user *ubuf)
1185{
1186 struct xstat64 {
1187 u32 st_dev; s32 st_pad1[3];
1188 unsigned long long st_ino;
1189 u32 st_mode;
1190 u32 st_nlink; s32 st_uid; s32 st_gid; u32 st_rdev;
1191 s32 st_pad2[2];
1192 long long st_size;
1193 s32 st_pad3;
1194 struct { s32 tv_sec, tv_nsec; } st_atime, st_mtime, st_ctime;
1195 s32 st_blksize;
1196 long long st_blocks;
1197 char st_fstype[16];
1198 s32 st_pad4[8];
1199 } ks;
1200
1201 if (!sysv_valid_dev(stat->dev) || !sysv_valid_dev(stat->rdev))
1202 return -EOVERFLOW;
1203
1204 ks.st_dev = sysv_encode_dev(stat->dev);
1205 ks.st_pad1[0] = ks.st_pad1[1] = ks.st_pad1[2] = 0;
1206 ks.st_ino = (unsigned long long) stat->ino;
1207 ks.st_mode = (u32) stat->mode;
1208 ks.st_nlink = (u32) stat->nlink;
1209 ks.st_uid = (s32) stat->uid;
1210 ks.st_gid = (s32) stat->gid;
1211 ks.st_rdev = sysv_encode_dev(stat->rdev);
1212 ks.st_pad2[0] = ks.st_pad2[1] = 0;
1213 ks.st_size = (long long) stat->size;
1214 ks.st_pad3 = 0;
1215
1216 /* XXX hackety hack... */
1217 ks.st_atime.tv_sec = (s32) stat->atime.tv_sec;
1218 ks.st_atime.tv_nsec = stat->atime.tv_nsec;
1219 ks.st_mtime.tv_sec = (s32) stat->mtime.tv_sec;
1220 ks.st_mtime.tv_nsec = stat->mtime.tv_nsec;
1221 ks.st_ctime.tv_sec = (s32) stat->ctime.tv_sec;
1222 ks.st_ctime.tv_nsec = stat->ctime.tv_nsec;
1223
1224 ks.st_blksize = (s32) stat->blksize;
1225 ks.st_blocks = (long long) stat->blocks;
1226 memset(ks.st_fstype, 0, 16);
1227 ks.st_pad4[0] = ks.st_pad4[1] = ks.st_pad4[2] = ks.st_pad4[3] = 0;
1228 ks.st_pad4[4] = ks.st_pad4[5] = ks.st_pad4[6] = ks.st_pad4[7] = 0;
1229
1230 /* Now write it all back. */
1231 return copy_to_user(ubuf, &ks, sizeof(ks)) ? -EFAULT : 0;
1232}
1233
1234asmlinkage int irix_xstat(int version, char __user *filename, struct stat __user *statbuf)
1235{
1236 int retval;
1237 struct kstat stat;
1238
1239#ifdef DEBUG_XSTAT
1240 printk("[%s:%d] Wheee.. irix_xstat(%d,%s,%p) ",
1241 current->comm, current->pid, version, filename, statbuf);
1242#endif
1243
1244 retval = vfs_stat(filename, &stat);
1245 if (!retval) {
1246 switch(version) {
1247 case 2:
1248 retval = irix_xstat32_xlate(&stat, statbuf);
1249 break;
1250 case 3:
1251 retval = irix_xstat64_xlate(&stat, statbuf);
1252 break;
1253 default:
1254 retval = -EINVAL;
1255 }
1256 }
1257 return retval;
1258}
1259
1260asmlinkage int irix_lxstat(int version, char __user *filename, struct stat __user *statbuf)
1261{
1262 int error;
1263 struct kstat stat;
1264
1265#ifdef DEBUG_XSTAT
1266 printk("[%s:%d] Wheee.. irix_lxstat(%d,%s,%p) ",
1267 current->comm, current->pid, version, filename, statbuf);
1268#endif
1269
1270 error = vfs_lstat(filename, &stat);
1271
1272 if (!error) {
1273 switch (version) {
1274 case 2:
1275 error = irix_xstat32_xlate(&stat, statbuf);
1276 break;
1277 case 3:
1278 error = irix_xstat64_xlate(&stat, statbuf);
1279 break;
1280 default:
1281 error = -EINVAL;
1282 }
1283 }
1284 return error;
1285}
1286
1287asmlinkage int irix_fxstat(int version, int fd, struct stat __user *statbuf)
1288{
1289 int error;
1290 struct kstat stat;
1291
1292#ifdef DEBUG_XSTAT
1293 printk("[%s:%d] Wheee.. irix_fxstat(%d,%d,%p) ",
1294 current->comm, current->pid, version, fd, statbuf);
1295#endif
1296
1297 error = vfs_fstat(fd, &stat);
1298 if (!error) {
1299 switch (version) {
1300 case 2:
1301 error = irix_xstat32_xlate(&stat, statbuf);
1302 break;
1303 case 3:
1304 error = irix_xstat64_xlate(&stat, statbuf);
1305 break;
1306 default:
1307 error = -EINVAL;
1308 }
1309 }
1310 return error;
1311}
1312
1313asmlinkage int irix_xmknod(int ver, char __user *filename, int mode, unsigned dev)
1314{
1315 int retval;
1316 printk("[%s:%d] Wheee.. irix_xmknod(%d,%s,%x,%x)\n",
1317 current->comm, current->pid, ver, filename, mode, dev);
1318
1319 switch(ver) {
1320 case 2:
1321 /* shouldn't we convert here as well as on stat()? */
1322 retval = sys_mknod(filename, mode, dev);
1323 break;
1324
1325 default:
1326 retval = -EINVAL;
1327 break;
1328 };
1329
1330 return retval;
1331}
1332
1333asmlinkage int irix_swapctl(int cmd, char __user *arg)
1334{
1335 printk("[%s:%d] Wheee.. irix_swapctl(%d,%p)\n",
1336 current->comm, current->pid, cmd, arg);
1337
1338 return -EINVAL;
1339}
1340
1341struct irix_statvfs {
1342 u32 f_bsize; u32 f_frsize; u32 f_blocks;
1343 u32 f_bfree; u32 f_bavail; u32 f_files; u32 f_ffree; u32 f_favail;
1344 u32 f_fsid; char f_basetype[16];
1345 u32 f_flag; u32 f_namemax;
1346 char f_fstr[32]; u32 f_filler[16];
1347};
1348
1349asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
1350{
1351 struct nameidata nd;
1352 struct kstatfs kbuf;
1353 int error, i;
1354
1355 printk("[%s:%d] Wheee.. irix_statvfs(%s,%p)\n",
1356 current->comm, current->pid, fname, buf);
1357 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)))
1358 return -EFAULT;
1359
1360 error = user_path_walk(fname, &nd);
1361 if (error)
1362 goto out;
1363 error = vfs_statfs(nd.path.dentry, &kbuf);
1364 if (error)
1365 goto dput_and_out;
1366
1367 error |= __put_user(kbuf.f_bsize, &buf->f_bsize);
1368 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
1369 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
1370 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
1371 error |= __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1372 error |= __put_user(kbuf.f_files, &buf->f_files);
1373 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
1374 error |= __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1375#ifdef __MIPSEB__
1376 error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1377#else
1378 error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1379#endif
1380 for (i = 0; i < 16; i++)
1381 error |= __put_user(0, &buf->f_basetype[i]);
1382 error |= __put_user(0, &buf->f_flag);
1383 error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
1384 for (i = 0; i < 32; i++)
1385 error |= __put_user(0, &buf->f_fstr[i]);
1386
1387dput_and_out:
1388 path_put(&nd.path);
1389out:
1390 return error;
1391}
1392
1393asmlinkage int irix_fstatvfs(int fd, struct irix_statvfs __user *buf)
1394{
1395 struct kstatfs kbuf;
1396 struct file *file;
1397 int error, i;
1398
1399 printk("[%s:%d] Wheee.. irix_fstatvfs(%d,%p)\n",
1400 current->comm, current->pid, fd, buf);
1401
1402 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs)))
1403 return -EFAULT;
1404
1405 if (!(file = fget(fd))) {
1406 error = -EBADF;
1407 goto out;
1408 }
1409 error = vfs_statfs(file->f_path.dentry, &kbuf);
1410 if (error)
1411 goto out_f;
1412
1413 error = __put_user(kbuf.f_bsize, &buf->f_bsize);
1414 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
1415 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
1416 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
1417 error |= __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1418 error |= __put_user(kbuf.f_files, &buf->f_files);
1419 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
1420 error |= __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1421#ifdef __MIPSEB__
1422 error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1423#else
1424 error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1425#endif
1426 for(i = 0; i < 16; i++)
1427 error |= __put_user(0, &buf->f_basetype[i]);
1428 error |= __put_user(0, &buf->f_flag);
1429 error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
1430 error |= __clear_user(&buf->f_fstr, sizeof(buf->f_fstr)) ? -EFAULT : 0;
1431
1432out_f:
1433 fput(file);
1434out:
1435 return error;
1436}
1437
1438asmlinkage int irix_priocntl(struct pt_regs *regs)
1439{
1440 printk("[%s:%d] Wheee.. irix_priocntl()\n",
1441 current->comm, current->pid);
1442
1443 return -EINVAL;
1444}
1445
1446asmlinkage int irix_sigqueue(int pid, int sig, int code, int val)
1447{
1448 printk("[%s:%d] Wheee.. irix_sigqueue(%d,%d,%d,%d)\n",
1449 current->comm, current->pid, pid, sig, code, val);
1450
1451 return -EINVAL;
1452}
1453
1454asmlinkage int irix_truncate64(char __user *name, int pad, int size1, int size2)
1455{
1456 int retval;
1457
1458 if (size1) {
1459 retval = -EINVAL;
1460 goto out;
1461 }
1462 retval = sys_truncate(name, size2);
1463
1464out:
1465 return retval;
1466}
1467
1468asmlinkage int irix_ftruncate64(int fd, int pad, int size1, int size2)
1469{
1470 int retval;
1471
1472 if (size1) {
1473 retval = -EINVAL;
1474 goto out;
1475 }
1476 retval = sys_ftruncate(fd, size2);
1477
1478out:
1479 return retval;
1480}
1481
1482asmlinkage int irix_mmap64(struct pt_regs *regs)
1483{
1484 int len, prot, flags, fd, off1, off2, error, base = 0;
1485 unsigned long addr, pgoff, *sp;
1486 struct file *file = NULL;
1487 int err;
1488
1489 if (regs->regs[2] == 1000)
1490 base = 1;
1491 sp = (unsigned long *) (regs->regs[29] + 16);
1492 addr = regs->regs[base + 4];
1493 len = regs->regs[base + 5];
1494 prot = regs->regs[base + 6];
1495 if (!base) {
1496 flags = regs->regs[base + 7];
1497 if (!access_ok(VERIFY_READ, sp, (4 * sizeof(unsigned long))))
1498 return -EFAULT;
1499 fd = sp[0];
1500 err = __get_user(off1, &sp[1]);
1501 err |= __get_user(off2, &sp[2]);
1502 } else {
1503 if (!access_ok(VERIFY_READ, sp, (5 * sizeof(unsigned long))))
1504 return -EFAULT;
1505 err = __get_user(flags, &sp[0]);
1506 err |= __get_user(fd, &sp[1]);
1507 err |= __get_user(off1, &sp[2]);
1508 err |= __get_user(off2, &sp[3]);
1509 }
1510
1511 if (err)
1512 return err;
1513
1514 if (off1 & PAGE_MASK)
1515 return -EOVERFLOW;
1516
1517 pgoff = (off1 << (32 - PAGE_SHIFT)) | (off2 >> PAGE_SHIFT);
1518
1519 if (!(flags & MAP_ANONYMOUS)) {
1520 if (!(file = fget(fd)))
1521 return -EBADF;
1522
1523 /* Ok, bad taste hack follows, try to think in something else
1524 when reading this */
1525 if (flags & IRIX_MAP_AUTOGROW) {
1526 unsigned long old_pos;
1527 long max_size = off2 + len;
1528
1529 if (max_size > file->f_path.dentry->d_inode->i_size) {
1530 old_pos = sys_lseek(fd, max_size - 1, 0);
1531 sys_write(fd, (void __user *) "", 1);
1532 sys_lseek(fd, old_pos, 0);
1533 }
1534 }
1535 }
1536
1537 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
1538
1539 down_write(&current->mm->mmap_sem);
1540 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
1541 up_write(&current->mm->mmap_sem);
1542
1543 if (file)
1544 fput(file);
1545
1546 return error;
1547}
1548
1549asmlinkage int irix_dmi(struct pt_regs *regs)
1550{
1551 printk("[%s:%d] Wheee.. irix_dmi()\n",
1552 current->comm, current->pid);
1553
1554 return -EINVAL;
1555}
1556
1557asmlinkage int irix_pread(int fd, char __user *buf, int cnt, int off64,
1558 int off1, int off2)
1559{
1560 printk("[%s:%d] Wheee.. irix_pread(%d,%p,%d,%d,%d,%d)\n",
1561 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1562
1563 return -EINVAL;
1564}
1565
1566asmlinkage int irix_pwrite(int fd, char __user *buf, int cnt, int off64,
1567 int off1, int off2)
1568{
1569 printk("[%s:%d] Wheee.. irix_pwrite(%d,%p,%d,%d,%d,%d)\n",
1570 current->comm, current->pid, fd, buf, cnt, off64, off1, off2);
1571
1572 return -EINVAL;
1573}
1574
1575asmlinkage int irix_sgifastpath(int cmd, unsigned long arg0, unsigned long arg1,
1576 unsigned long arg2, unsigned long arg3,
1577 unsigned long arg4, unsigned long arg5)
1578{
1579 printk("[%s:%d] Wheee.. irix_fastpath(%d,%08lx,%08lx,%08lx,%08lx,"
1580 "%08lx,%08lx)\n",
1581 current->comm, current->pid, cmd, arg0, arg1, arg2,
1582 arg3, arg4, arg5);
1583
1584 return -EINVAL;
1585}
1586
1587struct irix_statvfs64 {
1588 u32 f_bsize; u32 f_frsize;
1589 u64 f_blocks; u64 f_bfree; u64 f_bavail;
1590 u64 f_files; u64 f_ffree; u64 f_favail;
1591 u32 f_fsid;
1592 char f_basetype[16];
1593 u32 f_flag; u32 f_namemax;
1594 char f_fstr[32];
1595 u32 f_filler[16];
1596};
1597
1598asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *buf)
1599{
1600 struct nameidata nd;
1601 struct kstatfs kbuf;
1602 int error, i;
1603
1604 printk("[%s:%d] Wheee.. irix_statvfs64(%s,%p)\n",
1605 current->comm, current->pid, fname, buf);
1606 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs64))) {
1607 error = -EFAULT;
1608 goto out;
1609 }
1610
1611 error = user_path_walk(fname, &nd);
1612 if (error)
1613 goto out;
1614 error = vfs_statfs(nd.path.dentry, &kbuf);
1615 if (error)
1616 goto dput_and_out;
1617
1618 error = __put_user(kbuf.f_bsize, &buf->f_bsize);
1619 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
1620 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
1621 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
1622 error |= __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1623 error |= __put_user(kbuf.f_files, &buf->f_files);
1624 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
1625 error |= __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1626#ifdef __MIPSEB__
1627 error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1628#else
1629 error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1630#endif
1631 for(i = 0; i < 16; i++)
1632 error |= __put_user(0, &buf->f_basetype[i]);
1633 error |= __put_user(0, &buf->f_flag);
1634 error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
1635 for(i = 0; i < 32; i++)
1636 error |= __put_user(0, &buf->f_fstr[i]);
1637
1638dput_and_out:
1639 path_put(&nd.path);
1640out:
1641 return error;
1642}
1643
1644asmlinkage int irix_fstatvfs64(int fd, struct irix_statvfs __user *buf)
1645{
1646 struct kstatfs kbuf;
1647 struct file *file;
1648 int error, i;
1649
1650 printk("[%s:%d] Wheee.. irix_fstatvfs64(%d,%p)\n",
1651 current->comm, current->pid, fd, buf);
1652
1653 if (!access_ok(VERIFY_WRITE, buf, sizeof(struct irix_statvfs))) {
1654 error = -EFAULT;
1655 goto out;
1656 }
1657 if (!(file = fget(fd))) {
1658 error = -EBADF;
1659 goto out;
1660 }
1661 error = vfs_statfs(file->f_path.dentry, &kbuf);
1662 if (error)
1663 goto out_f;
1664
1665 error = __put_user(kbuf.f_bsize, &buf->f_bsize);
1666 error |= __put_user(kbuf.f_frsize, &buf->f_frsize);
1667 error |= __put_user(kbuf.f_blocks, &buf->f_blocks);
1668 error |= __put_user(kbuf.f_bfree, &buf->f_bfree);
1669 error |= __put_user(kbuf.f_bfree, &buf->f_bavail); /* XXX hackety hack... */
1670 error |= __put_user(kbuf.f_files, &buf->f_files);
1671 error |= __put_user(kbuf.f_ffree, &buf->f_ffree);
1672 error |= __put_user(kbuf.f_ffree, &buf->f_favail); /* XXX hackety hack... */
1673#ifdef __MIPSEB__
1674 error |= __put_user(kbuf.f_fsid.val[1], &buf->f_fsid);
1675#else
1676 error |= __put_user(kbuf.f_fsid.val[0], &buf->f_fsid);
1677#endif
1678 for(i = 0; i < 16; i++)
1679 error |= __put_user(0, &buf->f_basetype[i]);
1680 error |= __put_user(0, &buf->f_flag);
1681 error |= __put_user(kbuf.f_namelen, &buf->f_namemax);
1682 error |= __clear_user(buf->f_fstr, sizeof(buf->f_fstr[i])) ? -EFAULT : 0;
1683
1684out_f:
1685 fput(file);
1686out:
1687 return error;
1688}
1689
1690asmlinkage int irix_getmountid(char __user *fname, unsigned long __user *midbuf)
1691{
1692 int err;
1693
1694 printk("[%s:%d] irix_getmountid(%s, %p)\n",
1695 current->comm, current->pid, fname, midbuf);
1696 if (!access_ok(VERIFY_WRITE, midbuf, (sizeof(unsigned long) * 4)))
1697 return -EFAULT;
1698
1699 /*
1700 * The idea with this system call is that when trying to determine
1701 * 'pwd' and it's a toss-up for some reason, userland can use the
1702 * fsid of the filesystem to try and make the right decision, but
1703 * we don't have this so for now. XXX
1704 */
1705 err = __put_user(0, &midbuf[0]);
1706 err |= __put_user(0, &midbuf[1]);
1707 err |= __put_user(0, &midbuf[2]);
1708 err |= __put_user(0, &midbuf[3]);
1709
1710 return err;
1711}
1712
1713asmlinkage int irix_nsproc(unsigned long entry, unsigned long mask,
1714 unsigned long arg, unsigned long sp, int slen)
1715{
1716 printk("[%s:%d] Wheee.. irix_nsproc(%08lx,%08lx,%08lx,%08lx,%d)\n",
1717 current->comm, current->pid, entry, mask, arg, sp, slen);
1718
1719 return -EINVAL;
1720}
1721
1722#undef DEBUG_GETDENTS
1723
1724struct irix_dirent32 {
1725 u32 d_ino;
1726 u32 d_off;
1727 unsigned short d_reclen;
1728 char d_name[1];
1729};
1730
1731struct irix_dirent32_callback {
1732 struct irix_dirent32 __user *current_dir;
1733 struct irix_dirent32 __user *previous;
1734 int count;
1735 int error;
1736};
1737
1738#define NAME_OFFSET32(de) ((int) ((de)->d_name - (char *) (de)))
1739#define ROUND_UP32(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
1740
1741static int irix_filldir32(void *__buf, const char *name,
1742 int namlen, loff_t offset, u64 ino, unsigned int d_type)
1743{
1744 struct irix_dirent32 __user *dirent;
1745 struct irix_dirent32_callback *buf = __buf;
1746 unsigned short reclen = ROUND_UP32(NAME_OFFSET32(dirent) + namlen + 1);
1747 int err = 0;
1748 u32 d_ino;
1749
1750#ifdef DEBUG_GETDENTS
1751 printk("\nirix_filldir32[reclen<%d>namlen<%d>count<%d>]",
1752 reclen, namlen, buf->count);
1753#endif
1754 buf->error = -EINVAL; /* only used if we fail.. */
1755 if (reclen > buf->count)
1756 return -EINVAL;
1757 d_ino = ino;
1758 if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
1759 return -EOVERFLOW;
1760 dirent = buf->previous;
1761 if (dirent)
1762 err = __put_user(offset, &dirent->d_off);
1763 dirent = buf->current_dir;
1764 err |= __put_user(dirent, &buf->previous);
1765 err |= __put_user(d_ino, &dirent->d_ino);
1766 err |= __put_user(reclen, &dirent->d_reclen);
1767 err |= copy_to_user((char __user *)dirent->d_name, name, namlen) ? -EFAULT : 0;
1768 err |= __put_user(0, &dirent->d_name[namlen]);
1769 dirent = (struct irix_dirent32 __user *) ((char __user *) dirent + reclen);
1770
1771 buf->current_dir = dirent;
1772 buf->count -= reclen;
1773
1774 return err;
1775}
1776
1777asmlinkage int irix_ngetdents(unsigned int fd, void __user * dirent,
1778 unsigned int count, int __user *eob)
1779{
1780 struct file *file;
1781 struct irix_dirent32 __user *lastdirent;
1782 struct irix_dirent32_callback buf;
1783 int error;
1784
1785#ifdef DEBUG_GETDENTS
1786 printk("[%s:%d] ngetdents(%d, %p, %d, %p) ", current->comm,
1787 current->pid, fd, dirent, count, eob);
1788#endif
1789 error = -EBADF;
1790 file = fget(fd);
1791 if (!file)
1792 goto out;
1793
1794 buf.current_dir = (struct irix_dirent32 __user *) dirent;
1795 buf.previous = NULL;
1796 buf.count = count;
1797 buf.error = 0;
1798
1799 error = vfs_readdir(file, irix_filldir32, &buf);
1800 if (error < 0)
1801 goto out_putf;
1802
1803 error = buf.error;
1804 lastdirent = buf.previous;
1805 if (lastdirent) {
1806 put_user(file->f_pos, &lastdirent->d_off);
1807 error = count - buf.count;
1808 }
1809
1810 if (put_user(0, eob) < 0) {
1811 error = -EFAULT;
1812 goto out_putf;
1813 }
1814
1815#ifdef DEBUG_GETDENTS
1816 printk("eob=%d returning %d\n", *eob, count - buf.count);
1817#endif
1818 error = count - buf.count;
1819
1820out_putf:
1821 fput(file);
1822out:
1823 return error;
1824}
1825
1826struct irix_dirent64 {
1827 u64 d_ino;
1828 u64 d_off;
1829 unsigned short d_reclen;
1830 char d_name[1];
1831};
1832
1833struct irix_dirent64_callback {
1834 struct irix_dirent64 __user *curr;
1835 struct irix_dirent64 __user *previous;
1836 int count;
1837 int error;
1838};
1839
1840#define NAME_OFFSET64(de) ((int) ((de)->d_name - (char *) (de)))
1841#define ROUND_UP64(x) (((x)+sizeof(u64)-1) & ~(sizeof(u64)-1))
1842
1843static int irix_filldir64(void *__buf, const char *name,
1844 int namlen, loff_t offset, u64 ino, unsigned int d_type)
1845{
1846 struct irix_dirent64 __user *dirent;
1847 struct irix_dirent64_callback * buf = __buf;
1848 unsigned short reclen = ROUND_UP64(NAME_OFFSET64(dirent) + namlen + 1);
1849 int err = 0;
1850
1851 if (!access_ok(VERIFY_WRITE, buf, sizeof(*buf)))
1852 return -EFAULT;
1853
1854 if (__put_user(-EINVAL, &buf->error)) /* only used if we fail.. */
1855 return -EFAULT;
1856 if (reclen > buf->count)
1857 return -EINVAL;
1858 dirent = buf->previous;
1859 if (dirent)
1860 err = __put_user(offset, &dirent->d_off);
1861 dirent = buf->curr;
1862 buf->previous = dirent;
1863 err |= __put_user(ino, &dirent->d_ino);
1864 err |= __put_user(reclen, &dirent->d_reclen);
1865 err |= __copy_to_user((char __user *)dirent->d_name, name, namlen)
1866 ? -EFAULT : 0;
1867 err |= __put_user(0, &dirent->d_name[namlen]);
1868
1869 dirent = (struct irix_dirent64 __user *) ((char __user *) dirent + reclen);
1870
1871 buf->curr = dirent;
1872 buf->count -= reclen;
1873
1874 return err;
1875}
1876
1877asmlinkage int irix_getdents64(int fd, void __user *dirent, int cnt)
1878{
1879 struct file *file;
1880 struct irix_dirent64 __user *lastdirent;
1881 struct irix_dirent64_callback buf;
1882 int error;
1883
1884#ifdef DEBUG_GETDENTS
1885 printk("[%s:%d] getdents64(%d, %p, %d) ", current->comm,
1886 current->pid, fd, dirent, cnt);
1887#endif
1888 error = -EBADF;
1889 if (!(file = fget(fd)))
1890 goto out;
1891
1892 error = -EFAULT;
1893 if (!access_ok(VERIFY_WRITE, dirent, cnt))
1894 goto out_f;
1895
1896 error = -EINVAL;
1897 if (cnt < (sizeof(struct irix_dirent64) + 255))
1898 goto out_f;
1899
1900 buf.curr = (struct irix_dirent64 __user *) dirent;
1901 buf.previous = NULL;
1902 buf.count = cnt;
1903 buf.error = 0;
1904 error = vfs_readdir(file, irix_filldir64, &buf);
1905 if (error < 0)
1906 goto out_f;
1907 lastdirent = buf.previous;
1908 if (!lastdirent) {
1909 error = buf.error;
1910 goto out_f;
1911 }
1912 if (put_user(file->f_pos, &lastdirent->d_off))
1913 return -EFAULT;
1914#ifdef DEBUG_GETDENTS
1915 printk("returning %d\n", cnt - buf.count);
1916#endif
1917 error = cnt - buf.count;
1918
1919out_f:
1920 fput(file);
1921out:
1922 return error;
1923}
1924
1925asmlinkage int irix_ngetdents64(int fd, void __user *dirent, int cnt, int *eob)
1926{
1927 struct file *file;
1928 struct irix_dirent64 __user *lastdirent;
1929 struct irix_dirent64_callback buf;
1930 int error;
1931
1932#ifdef DEBUG_GETDENTS
1933 printk("[%s:%d] ngetdents64(%d, %p, %d) ", current->comm,
1934 current->pid, fd, dirent, cnt);
1935#endif
1936 error = -EBADF;
1937 if (!(file = fget(fd)))
1938 goto out;
1939
1940 error = -EFAULT;
1941 if (!access_ok(VERIFY_WRITE, dirent, cnt) ||
1942 !access_ok(VERIFY_WRITE, eob, sizeof(*eob)))
1943 goto out_f;
1944
1945 error = -EINVAL;
1946 if (cnt < (sizeof(struct irix_dirent64) + 255))
1947 goto out_f;
1948
1949 *eob = 0;
1950 buf.curr = (struct irix_dirent64 __user *) dirent;
1951 buf.previous = NULL;
1952 buf.count = cnt;
1953 buf.error = 0;
1954 error = vfs_readdir(file, irix_filldir64, &buf);
1955 if (error < 0)
1956 goto out_f;
1957 lastdirent = buf.previous;
1958 if (!lastdirent) {
1959 error = buf.error;
1960 goto out_f;
1961 }
1962 if (put_user(file->f_pos, &lastdirent->d_off))
1963 return -EFAULT;
1964#ifdef DEBUG_GETDENTS
1965 printk("eob=%d returning %d\n", *eob, cnt - buf.count);
1966#endif
1967 error = cnt - buf.count;
1968
1969out_f:
1970 fput(file);
1971out:
1972 return error;
1973}
1974
1975asmlinkage int irix_uadmin(unsigned long op, unsigned long func, unsigned long arg)
1976{
1977 int retval;
1978
1979 switch (op) {
1980 case 1:
1981 /* Reboot */
1982 printk("[%s:%d] irix_uadmin: Wants to reboot...\n",
1983 current->comm, current->pid);
1984 retval = -EINVAL;
1985 goto out;
1986
1987 case 2:
1988 /* Shutdown */
1989 printk("[%s:%d] irix_uadmin: Wants to shutdown...\n",
1990 current->comm, current->pid);
1991 retval = -EINVAL;
1992 goto out;
1993
1994 case 4:
1995 /* Remount-root */
1996 printk("[%s:%d] irix_uadmin: Wants to remount root...\n",
1997 current->comm, current->pid);
1998 retval = -EINVAL;
1999 goto out;
2000
2001 case 8:
2002 /* Kill all tasks. */
2003 printk("[%s:%d] irix_uadmin: Wants to kill all tasks...\n",
2004 current->comm, current->pid);
2005 retval = -EINVAL;
2006 goto out;
2007
2008 case 256:
2009 /* Set magic mushrooms... */
2010 printk("[%s:%d] irix_uadmin: Wants to set magic mushroom[%d]...\n",
2011 current->comm, current->pid, (int) func);
2012 retval = -EINVAL;
2013 goto out;
2014
2015 default:
2016 printk("[%s:%d] irix_uadmin: Unknown operation [%d]...\n",
2017 current->comm, current->pid, (int) op);
2018 retval = -EINVAL;
2019 goto out;
2020 };
2021
2022out:
2023 return retval;
2024}
2025
2026asmlinkage int irix_utssys(char __user *inbuf, int arg, int type, char __user *outbuf)
2027{
2028 int retval;
2029
2030 switch(type) {
2031 case 0:
2032 /* uname() */
2033 retval = irix_uname((struct iuname __user *)inbuf);
2034 goto out;
2035
2036 case 2:
2037 /* ustat() */
2038 printk("[%s:%d] irix_utssys: Wants to do ustat()\n",
2039 current->comm, current->pid);
2040 retval = -EINVAL;
2041 goto out;
2042
2043 case 3:
2044 /* fusers() */
2045 printk("[%s:%d] irix_utssys: Wants to do fusers()\n",
2046 current->comm, current->pid);
2047 retval = -EINVAL;
2048 goto out;
2049
2050 default:
2051 printk("[%s:%d] irix_utssys: Wants to do unknown type[%d]\n",
2052 current->comm, current->pid, (int) type);
2053 retval = -EINVAL;
2054 goto out;
2055 }
2056
2057out:
2058 return retval;
2059}
2060
2061#undef DEBUG_FCNTL
2062
2063#define IRIX_F_ALLOCSP 10
2064
2065asmlinkage int irix_fcntl(int fd, int cmd, int arg)
2066{
2067 int retval;
2068
2069#ifdef DEBUG_FCNTL
2070 printk("[%s:%d] irix_fcntl(%d, %d, %d) ", current->comm,
2071 current->pid, fd, cmd, arg);
2072#endif
2073 if (cmd == IRIX_F_ALLOCSP){
2074 return 0;
2075 }
2076 retval = sys_fcntl(fd, cmd, arg);
2077#ifdef DEBUG_FCNTL
2078 printk("%d\n", retval);
2079#endif
2080 return retval;
2081}
2082
2083asmlinkage int irix_ulimit(int cmd, int arg)
2084{
2085 int retval;
2086
2087 switch(cmd) {
2088 case 1:
2089 printk("[%s:%d] irix_ulimit: Wants to get file size limit.\n",
2090 current->comm, current->pid);
2091 retval = -EINVAL;
2092 goto out;
2093
2094 case 2:
2095 printk("[%s:%d] irix_ulimit: Wants to set file size limit.\n",
2096 current->comm, current->pid);
2097 retval = -EINVAL;
2098 goto out;
2099
2100 case 3:
2101 printk("[%s:%d] irix_ulimit: Wants to get brk limit.\n",
2102 current->comm, current->pid);
2103 retval = -EINVAL;
2104 goto out;
2105
2106 case 4:
2107#if 0
2108 printk("[%s:%d] irix_ulimit: Wants to get fd limit.\n",
2109 current->comm, current->pid);
2110 retval = -EINVAL;
2111 goto out;
2112#endif
2113 retval = current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
2114 goto out;
2115
2116 case 5:
2117 printk("[%s:%d] irix_ulimit: Wants to get txt offset.\n",
2118 current->comm, current->pid);
2119 retval = -EINVAL;
2120 goto out;
2121
2122 default:
2123 printk("[%s:%d] irix_ulimit: Unknown command [%d].\n",
2124 current->comm, current->pid, cmd);
2125 retval = -EINVAL;
2126 goto out;
2127 }
2128out:
2129 return retval;
2130}
2131
2132asmlinkage int irix_unimp(struct pt_regs *regs)
2133{
2134 printk("irix_unimp [%s:%d] v0=%d v1=%d a0=%08lx a1=%08lx a2=%08lx "
2135 "a3=%08lx\n", current->comm, current->pid,
2136 (int) regs->regs[2], (int) regs->regs[3],
2137 regs->regs[4], regs->regs[5], regs->regs[6], regs->regs[7]);
2138
2139 return -ENOSYS;
2140}
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index f9165d1a17b..b8ea4e9d0d8 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -71,7 +71,6 @@ extern asmlinkage void handle_reserved(void);
71extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, 71extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
72 struct mips_fpu_struct *ctx, int has_fpu); 72 struct mips_fpu_struct *ctx, int has_fpu);
73 73
74void (*board_watchpoint_handler)(struct pt_regs *regs);
75void (*board_be_init)(void); 74void (*board_be_init)(void);
76int (*board_be_handler)(struct pt_regs *regs, int is_fixup); 75int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
77void (*board_nmi_handler_setup)(void); 76void (*board_nmi_handler_setup)(void);
@@ -249,11 +248,11 @@ static void __show_regs(const struct pt_regs *regs)
249 /* 248 /*
250 * Saved cp0 registers 249 * Saved cp0 registers
251 */ 250 */
252 printk("epc : %0*lx ", field, regs->cp0_epc); 251 printk("epc : %0*lx %pS\n", field, regs->cp0_epc,
253 print_symbol("%s ", regs->cp0_epc); 252 (void *) regs->cp0_epc);
254 printk(" %s\n", print_tainted()); 253 printk(" %s\n", print_tainted());
255 printk("ra : %0*lx ", field, regs->regs[31]); 254 printk("ra : %0*lx %pS\n", field, regs->regs[31],
256 print_symbol("%s\n", regs->regs[31]); 255 (void *) regs->regs[31]);
257 256
258 printk("Status: %08x ", (uint32_t) regs->cp0_status); 257 printk("Status: %08x ", (uint32_t) regs->cp0_status);
259 258
@@ -892,11 +891,6 @@ asmlinkage void do_mdmx(struct pt_regs *regs)
892 891
893asmlinkage void do_watch(struct pt_regs *regs) 892asmlinkage void do_watch(struct pt_regs *regs)
894{ 893{
895 if (board_watchpoint_handler) {
896 (*board_watchpoint_handler)(regs);
897 return;
898 }
899
900 /* 894 /*
901 * We use the watch exception where available to detect stack 895 * We use the watch exception where available to detect stack
902 * overflows. 896 * overflows.
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index a56c1502696..d1ac7a25c85 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -22,8 +22,8 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24 24
25#include <asm/bootinfo.h>
26#include <asm/irq_cpu.h> 25#include <asm/irq_cpu.h>
26#include <asm/lasat/lasat.h>
27#include <asm/lasat/lasatint.h> 27#include <asm/lasat/lasatint.h>
28 28
29#include <irq.h> 29#include <irq.h>
@@ -112,23 +112,18 @@ void __init arch_init_irq(void)
112{ 112{
113 int i; 113 int i;
114 114
115 switch (mips_machtype) { 115 if (IS_LASAT_200()) {
116 case MACH_LASAT_100:
117 lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
118 lasat_int_mask = (void *)LASAT_INT_MASK_REG_100;
119 lasat_int_mask_shift = LASATINT_MASK_SHIFT_100;
120 get_int_status = get_int_status_100;
121 *lasat_int_mask = 0;
122 break;
123 case MACH_LASAT_200:
124 lasat_int_status = (void *)LASAT_INT_STATUS_REG_200; 116 lasat_int_status = (void *)LASAT_INT_STATUS_REG_200;
125 lasat_int_mask = (void *)LASAT_INT_MASK_REG_200; 117 lasat_int_mask = (void *)LASAT_INT_MASK_REG_200;
126 lasat_int_mask_shift = LASATINT_MASK_SHIFT_200; 118 lasat_int_mask_shift = LASATINT_MASK_SHIFT_200;
127 get_int_status = get_int_status_200; 119 get_int_status = get_int_status_200;
128 *lasat_int_mask &= 0xffff; 120 *lasat_int_mask &= 0xffff;
129 break; 121 } else {
130 default: 122 lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
131 panic("arch_init_irq: mips_machtype incorrect"); 123 lasat_int_mask = (void *)LASAT_INT_MASK_REG_100;
124 lasat_int_mask_shift = LASATINT_MASK_SHIFT_100;
125 get_int_status = get_int_status_100;
126 *lasat_int_mask = 0;
132 } 127 }
133 128
134 mips_cpu_irq_init(); 129 mips_cpu_irq_init();
diff --git a/arch/mips/lasat/lasat_board.c b/arch/mips/lasat/lasat_board.c
index 31e328b3814..577bb463a87 100644
--- a/arch/mips/lasat/lasat_board.c
+++ b/arch/mips/lasat/lasat_board.c
@@ -24,7 +24,6 @@
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/ctype.h> 25#include <linux/ctype.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <asm/bootinfo.h>
28#include <asm/addrspace.h> 27#include <asm/addrspace.h>
29#include "at93c.h" 28#include "at93c.h"
30/* New model description table */ 29/* New model description table */
@@ -66,7 +65,7 @@ static void init_flash_sizes(void)
66 ls[LASAT_MTD_SERVICE] = 0xC0000; 65 ls[LASAT_MTD_SERVICE] = 0xC0000;
67 ls[LASAT_MTD_NORMAL] = 0x100000; 66 ls[LASAT_MTD_NORMAL] = 0x100000;
68 67
69 if (mips_machtype == MACH_LASAT_100) { 68 if (!IS_LASAT_200()) {
70 lasat_board_info.li_flash_base = 0x1e000000; 69 lasat_board_info.li_flash_base = 0x1e000000;
71 70
72 lb[LASAT_MTD_BOOTLOADER] = 0x1e400000; 71 lb[LASAT_MTD_BOOTLOADER] = 0x1e400000;
diff --git a/arch/mips/lasat/prom.c b/arch/mips/lasat/prom.c
index 209edcc26f0..6acc6cb85f0 100644
--- a/arch/mips/lasat/prom.c
+++ b/arch/mips/lasat/prom.c
@@ -86,18 +86,16 @@ void __init prom_init(void)
86 86
87 setup_prom_vectors(); 87 setup_prom_vectors();
88 88
89 if (current_cpu_data.cputype == CPU_R5000) { 89 if (IS_LASAT_200()) {
90 printk(KERN_INFO "LASAT 200 board\n"); 90 printk(KERN_INFO "LASAT 200 board\n");
91 mips_machtype = MACH_LASAT_200;
92 lasat_ndelay_divider = LASAT_200_DIVIDER; 91 lasat_ndelay_divider = LASAT_200_DIVIDER;
92 at93c = &at93c_defs[1];
93 } else { 93 } else {
94 printk(KERN_INFO "LASAT 100 board\n"); 94 printk(KERN_INFO "LASAT 100 board\n");
95 mips_machtype = MACH_LASAT_100;
96 lasat_ndelay_divider = LASAT_100_DIVIDER; 95 lasat_ndelay_divider = LASAT_100_DIVIDER;
96 at93c = &at93c_defs[0];
97 } 97 }
98 98
99 at93c = &at93c_defs[mips_machtype];
100
101 lasat_init_board_info(); /* Read info from EEPROM */ 99 lasat_init_board_info(); /* Read info from EEPROM */
102 100
103 /* Get the command line */ 101 /* Get the command line */
diff --git a/arch/mips/lasat/serial.c b/arch/mips/lasat/serial.c
index 205bd397d75..5bcb6e89ab7 100644
--- a/arch/mips/lasat/serial.c
+++ b/arch/mips/lasat/serial.c
@@ -23,7 +23,6 @@
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/serial_8250.h> 24#include <linux/serial_8250.h>
25 25
26#include <asm/bootinfo.h>
27#include <asm/lasat/lasat.h> 26#include <asm/lasat/lasat.h>
28#include <asm/lasat/serial.h> 27#include <asm/lasat/serial.h>
29 28
@@ -47,7 +46,7 @@ static __init int lasat_uart_add(void)
47 if (!pdev) 46 if (!pdev)
48 return -ENOMEM; 47 return -ENOMEM;
49 48
50 if (mips_machtype == MACH_LASAT_100) { 49 if (!IS_LASAT_200()) {
51 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100); 50 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100);
52 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1; 51 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1;
53 lasat_serial_res[0].flags = IORESOURCE_MEM; 52 lasat_serial_res[0].flags = IORESOURCE_MEM;
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index e072da4ff3b..dbd3163a85c 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -127,9 +127,11 @@ void __init plat_time_init(void)
127void __init plat_mem_setup(void) 127void __init plat_mem_setup(void)
128{ 128{
129 int i; 129 int i;
130 lasat_misc = &lasat_misc_info[mips_machtype]; 130 int lasat_type = IS_LASAT_200() ? 1 : 0;
131
132 lasat_misc = &lasat_misc_info[lasat_type];
131#ifdef CONFIG_PICVUE 133#ifdef CONFIG_PICVUE
132 picvue = &pvc_defs[mips_machtype]; 134 picvue = &pvc_defs[lasat_type];
133#endif 135#endif
134 136
135 /* Set up panic notifier */ 137 /* Set up panic notifier */
@@ -140,7 +142,7 @@ void __init plat_mem_setup(void)
140 lasat_reboot_setup(); 142 lasat_reboot_setup();
141 143
142#ifdef CONFIG_DS1603 144#ifdef CONFIG_DS1603
143 ds1603 = &ds_defs[mips_machtype]; 145 ds1603 = &ds_defs[lasat_type];
144#endif 146#endif
145 147
146#ifdef DYNAMIC_SERIAL_INIT 148#ifdef DYNAMIC_SERIAL_INIT
diff --git a/arch/mips/mips-boards/atlas/Makefile b/arch/mips/mips-boards/atlas/Makefile
deleted file mode 100644
index f71c2dd1041..00000000000
--- a/arch/mips/mips-boards/atlas/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1#
2# Carsten Langgaard, carstenl@mips.com
3# Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4#
5# This program is free software; you can distribute it and/or modify it
6# under the terms of the GNU General Public License (Version 2) as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12# for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17#
18
19obj-y := atlas_int.o atlas_setup.o
20obj-$(CONFIG_KGDB) += atlas_gdb.o
21
22EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/atlas/atlas_gdb.c b/arch/mips/mips-boards/atlas/atlas_gdb.c
deleted file mode 100644
index 00c98cff62d..00000000000
--- a/arch/mips/mips-boards/atlas/atlas_gdb.c
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * This is the interface to the remote debugger stub.
19 */
20#include <asm/io.h>
21#include <asm/mips-boards/atlas.h>
22#include <asm/mips-boards/saa9730_uart.h>
23
24#define INB(a) inb((unsigned long)a)
25#define OUTB(x, a) outb(x, (unsigned long)a)
26
27/*
28 * This is the interface to the remote debugger stub
29 * if the Philips part is used for the debug port,
30 * called from the platform setup code.
31 */
32void *saa9730_base = (void *)ATLAS_SAA9730_REG;
33
34static int saa9730_kgdb_active = 0;
35
36#define SAA9730_BAUDCLOCK(baud) (((ATLAS_SAA9730_BAUDCLOCK/(baud))/16)-1)
37
38int saa9730_kgdb_hook(int speed)
39{
40 int baudclock;
41 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
42
43 /*
44 * Clear all interrupts
45 */
46 (void) INB(&kgdb_uart->Lsr);
47 (void) INB(&kgdb_uart->Msr);
48 (void) INB(&kgdb_uart->Thr_Rbr);
49 (void) INB(&kgdb_uart->Iir_Fcr);
50
51 /*
52 * Now, initialize the UART
53 */
54 /* 8 data bits, one stop bit, no parity */
55 OUTB(SAA9730_LCR_DATA8, &kgdb_uart->Lcr);
56
57 baudclock = SAA9730_BAUDCLOCK(speed);
58
59 OUTB((baudclock >> 16) & 0xff, &kgdb_uart->BaudDivMsb);
60 OUTB( baudclock & 0xff, &kgdb_uart->BaudDivLsb);
61
62 /* Set RTS/DTR active */
63 OUTB(SAA9730_MCR_DTR | SAA9730_MCR_RTS, &kgdb_uart->Mcr);
64 saa9730_kgdb_active = 1;
65
66 return speed;
67}
68
69int saa9730_putDebugChar(char c)
70{
71 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
72
73 if (!saa9730_kgdb_active) { /* need to init device first */
74 return 0;
75 }
76
77 while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_THRE))
78 ;
79 OUTB(c, &kgdb_uart->Thr_Rbr);
80
81 return 1;
82}
83
84char saa9730_getDebugChar(void)
85{
86 t_uart_saa9730_regmap *kgdb_uart = (t_uart_saa9730_regmap *)(saa9730_base + SAA9730_UART_REGS_ADDR);
87 char c;
88
89 if (!saa9730_kgdb_active) { /* need to init device first */
90 return 0;
91 }
92 while (!(INB(&kgdb_uart->Lsr) & SAA9730_LSR_DR))
93 ;
94
95 c = INB(&kgdb_uart->Thr_Rbr);
96 return(c);
97}
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
deleted file mode 100644
index 6fb29c3ff62..00000000000
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ /dev/null
@@ -1,272 +0,0 @@
1/*
2 * Copyright (C) 1999, 2000, 2006 MIPS Technologies, Inc.
3 * All rights reserved.
4 * Authors: Carsten Langgaard <carstenl@mips.com>
5 * Maciej W. Rozycki <macro@mips.com>
6 *
7 * ########################################################################
8 *
9 * This program is free software; you can distribute it and/or modify it
10 * under the terms of the GNU General Public License (Version 2) as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 *
22 * ########################################################################
23 *
24 * Routines for generic manipulation of the interrupts found on the MIPS
25 * Atlas board.
26 *
27 */
28#include <linux/compiler.h>
29#include <linux/init.h>
30#include <linux/irq.h>
31#include <linux/sched.h>
32#include <linux/slab.h>
33#include <linux/interrupt.h>
34#include <linux/kernel_stat.h>
35#include <linux/kernel.h>
36
37#include <asm/gdb-stub.h>
38#include <asm/io.h>
39#include <asm/irq_cpu.h>
40#include <asm/msc01_ic.h>
41
42#include <asm/mips-boards/atlas.h>
43#include <asm/mips-boards/atlasint.h>
44#include <asm/mips-boards/generic.h>
45
46static struct atlas_ictrl_regs *atlas_hw0_icregs;
47
48#if 0
49#define DEBUG_INT(x...) printk(x)
50#else
51#define DEBUG_INT(x...)
52#endif
53
54void disable_atlas_irq(unsigned int irq_nr)
55{
56 atlas_hw0_icregs->intrsten = 1 << (irq_nr - ATLAS_INT_BASE);
57 iob();
58}
59
60void enable_atlas_irq(unsigned int irq_nr)
61{
62 atlas_hw0_icregs->intseten = 1 << (irq_nr - ATLAS_INT_BASE);
63 iob();
64}
65
66static void end_atlas_irq(unsigned int irq)
67{
68 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
69 enable_atlas_irq(irq);
70}
71
72static struct irq_chip atlas_irq_type = {
73 .name = "Atlas",
74 .ack = disable_atlas_irq,
75 .mask = disable_atlas_irq,
76 .mask_ack = disable_atlas_irq,
77 .unmask = enable_atlas_irq,
78 .eoi = enable_atlas_irq,
79 .end = end_atlas_irq,
80};
81
82static inline int ls1bit32(unsigned int x)
83{
84 int b = 31, s;
85
86 s = 16; if (x << 16 == 0) s = 0; b -= s; x <<= s;
87 s = 8; if (x << 8 == 0) s = 0; b -= s; x <<= s;
88 s = 4; if (x << 4 == 0) s = 0; b -= s; x <<= s;
89 s = 2; if (x << 2 == 0) s = 0; b -= s; x <<= s;
90 s = 1; if (x << 1 == 0) s = 0; b -= s;
91
92 return b;
93}
94
95static inline void atlas_hw0_irqdispatch(void)
96{
97 unsigned long int_status;
98 int irq;
99
100 int_status = atlas_hw0_icregs->intstatus;
101
102 /* if int_status == 0, then the interrupt has already been cleared */
103 if (unlikely(int_status == 0))
104 return;
105
106 irq = ATLAS_INT_BASE + ls1bit32(int_status);
107
108 DEBUG_INT("atlas_hw0_irqdispatch: irq=%d\n", irq);
109
110 do_IRQ(irq);
111}
112
113static inline int clz(unsigned long x)
114{
115 __asm__(
116 " .set push \n"
117 " .set mips32 \n"
118 " clz %0, %1 \n"
119 " .set pop \n"
120 : "=r" (x)
121 : "r" (x));
122
123 return x;
124}
125
126/*
127 * Version of ffs that only looks at bits 12..15.
128 */
129static inline unsigned int irq_ffs(unsigned int pending)
130{
131#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
132 return -clz(pending) + 31 - CAUSEB_IP;
133#else
134 unsigned int a0 = 7;
135 unsigned int t0;
136
137 t0 = s0 & 0xf000;
138 t0 = t0 < 1;
139 t0 = t0 << 2;
140 a0 = a0 - t0;
141 s0 = s0 << t0;
142
143 t0 = s0 & 0xc000;
144 t0 = t0 < 1;
145 t0 = t0 << 1;
146 a0 = a0 - t0;
147 s0 = s0 << t0;
148
149 t0 = s0 & 0x8000;
150 t0 = t0 < 1;
151 //t0 = t0 << 2;
152 a0 = a0 - t0;
153 //s0 = s0 << t0;
154
155 return a0;
156#endif
157}
158
159/*
160 * IRQs on the Atlas board look basically like (all external interrupt
161 * sources are combined together on hardware interrupt 0 (MIPS IRQ 2)):
162 *
163 * MIPS IRQ Source
164 * -------- ------
165 * 0 Software 0 (reschedule IPI on MT)
166 * 1 Software 1 (remote call IPI on MT)
167 * 2 Combined Atlas hardware interrupt (hw0)
168 * 3 Hardware (ignored)
169 * 4 Hardware (ignored)
170 * 5 Hardware (ignored)
171 * 6 Hardware (ignored)
172 * 7 R4k timer (what we use)
173 *
174 * We handle the IRQ according to _our_ priority which is:
175 *
176 * Highest ---- R4k Timer
177 * Lowest ---- Software 0
178 *
179 * then we just return, if multiple IRQs are pending then we will just take
180 * another exception, big deal.
181 */
182asmlinkage void plat_irq_dispatch(void)
183{
184 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
185 int irq;
186
187 irq = irq_ffs(pending);
188
189 if (irq == MIPSCPU_INT_ATLAS)
190 atlas_hw0_irqdispatch();
191 else if (irq >= 0)
192 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
193 else
194 spurious_interrupt();
195}
196
197static inline void init_atlas_irqs(int base)
198{
199 int i;
200
201 atlas_hw0_icregs = (struct atlas_ictrl_regs *)
202 ioremap(ATLAS_ICTRL_REGS_BASE,
203 sizeof(struct atlas_ictrl_regs *));
204
205 /*
206 * Mask out all interrupt by writing "1" to all bit position in
207 * the interrupt reset reg.
208 */
209 atlas_hw0_icregs->intrsten = 0xffffffff;
210
211 for (i = ATLAS_INT_BASE; i <= ATLAS_INT_END; i++)
212 set_irq_chip_and_handler(i, &atlas_irq_type, handle_level_irq);
213}
214
215static struct irqaction atlasirq = {
216 .handler = no_action,
217 .name = "Atlas cascade"
218};
219
220msc_irqmap_t __initdata msc_irqmap[] = {
221 {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0},
222 {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0},
223};
224int __initdata msc_nr_irqs = ARRAY_SIZE(msc_irqmap);
225
226msc_irqmap_t __initdata msc_eicirqmap[] = {
227 {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0},
228 {MSC01E_INT_SW1, MSC01_IRQ_LEVEL, 0},
229 {MSC01E_INT_ATLAS, MSC01_IRQ_LEVEL, 0},
230 {MSC01E_INT_TMR, MSC01_IRQ_EDGE, 0},
231 {MSC01E_INT_PCI, MSC01_IRQ_LEVEL, 0},
232 {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0},
233 {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0}
234};
235int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap);
236
237void __init arch_init_irq(void)
238{
239 init_atlas_irqs(ATLAS_INT_BASE);
240
241 if (!cpu_has_veic)
242 mips_cpu_irq_init();
243
244 switch(mips_revision_corid) {
245 case MIPS_REVISION_CORID_CORE_MSC:
246 case MIPS_REVISION_CORID_CORE_FPGA2:
247 case MIPS_REVISION_CORID_CORE_FPGA3:
248 case MIPS_REVISION_CORID_CORE_FPGA4:
249 case MIPS_REVISION_CORID_CORE_24K:
250 case MIPS_REVISION_CORID_CORE_EMUL_MSC:
251 if (cpu_has_veic)
252 init_msc_irqs(MSC01E_INT_BASE, MSC01E_INT_BASE,
253 msc_eicirqmap, msc_nr_eicirqs);
254 else
255 init_msc_irqs(MSC01E_INT_BASE, MSC01C_INT_BASE,
256 msc_irqmap, msc_nr_irqs);
257 }
258
259 if (cpu_has_veic) {
260 set_vi_handler(MSC01E_INT_ATLAS, atlas_hw0_irqdispatch);
261 setup_irq(MSC01E_INT_BASE + MSC01E_INT_ATLAS, &atlasirq);
262 } else if (cpu_has_vint) {
263 set_vi_handler(MIPSCPU_INT_ATLAS, atlas_hw0_irqdispatch);
264#ifdef CONFIG_MIPS_MT_SMTC
265 setup_irq_smtc(MIPS_CPU_IRQ_BASE + MIPSCPU_INT_ATLAS,
266 &atlasirq, (0x100 << MIPSCPU_INT_ATLAS));
267#else /* Not SMTC */
268 setup_irq(MIPS_CPU_IRQ_BASE + MIPSCPU_INT_ATLAS, &atlasirq);
269#endif /* CONFIG_MIPS_MT_SMTC */
270 } else
271 setup_irq(MIPS_CPU_IRQ_BASE + MIPSCPU_INT_ATLAS, &atlasirq);
272}
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
deleted file mode 100644
index 5c500802271..00000000000
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 */
18#include <linux/init.h>
19#include <linux/interrupt.h>
20#include <linux/sched.h>
21#include <linux/ioport.h>
22#include <linux/tty.h>
23#include <linux/serial.h>
24#include <linux/serial_core.h>
25#include <linux/serial_8250.h>
26
27#include <asm/cpu.h>
28#include <asm/bootinfo.h>
29#include <asm/irq.h>
30#include <asm/mips-boards/generic.h>
31#include <asm/mips-boards/prom.h>
32#include <asm/mips-boards/atlas.h>
33#include <asm/mips-boards/atlasint.h>
34#include <asm/time.h>
35#include <asm/traps.h>
36
37static void __init serial_init(void);
38
39const char *get_system_type(void)
40{
41 return "MIPS Atlas";
42}
43
44const char display_string[] = " LINUX ON ATLAS ";
45
46void __init plat_mem_setup(void)
47{
48 mips_pcibios_init();
49
50 ioport_resource.end = 0x7fffffff;
51
52 serial_init();
53
54#ifdef CONFIG_KGDB
55 kgdb_config();
56#endif
57 mips_reboot_setup();
58}
59
60static void __init serial_init(void)
61{
62#ifdef CONFIG_SERIAL_8250
63 struct uart_port s;
64
65 memset(&s, 0, sizeof(s));
66
67#ifdef CONFIG_CPU_LITTLE_ENDIAN
68 s.iobase = ATLAS_UART_REGS_BASE;
69#else
70 s.iobase = ATLAS_UART_REGS_BASE+3;
71#endif
72 s.irq = ATLAS_INT_UART;
73 s.uartclk = ATLAS_BASE_BAUD * 16;
74 s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ;
75 s.iotype = UPIO_PORT;
76 s.regshift = 3;
77
78 if (early_serial_setup(&s) != 0) {
79 printk(KERN_ERR "Serial setup failed!\n");
80 }
81#endif
82}
diff --git a/arch/mips/mips-boards/generic/Makefile b/arch/mips/mips-boards/generic/Makefile
deleted file mode 100644
index f7f87fc09d1..00000000000
--- a/arch/mips/mips-boards/generic/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
1#
2# Carsten Langgaard, carstenl@mips.com
3# Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4#
5# This program is free software; you can distribute it and/or modify it
6# under the terms of the GNU General Public License (Version 2) as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12# for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17#
18# Makefile for the MIPS boards generic routines under Linux.
19#
20
21obj-y := reset.o display.o init.o memory.o \
22 cmdline.o time.o
23obj-y += amon.o
24
25obj-$(CONFIG_EARLY_PRINTK) += console.o
26obj-$(CONFIG_PCI) += pci.o
27obj-$(CONFIG_KGDB) += gdb_hook.o
28
29EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/malta/Makefile b/arch/mips/mips-boards/malta/Makefile
deleted file mode 100644
index db4ad654a6d..00000000000
--- a/arch/mips/mips-boards/malta/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
1#
2# Carsten Langgaard, carstenl@mips.com
3# Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
4#
5# This program is free software; you can distribute it and/or modify it
6# under the terms of the GNU General Public License (Version 2) as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12# for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17#
18# Makefile for the MIPS Malta specific kernel interface routines
19# under Linux.
20#
21
22obj-y := malta_int.o malta_mtd.o malta_platform.o malta_setup.o
23
24# FIXME FIXME FIXME
25obj-$(CONFIG_MIPS_MT_SMTC) += malta_smtc.o
26
27EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/sead/Makefile b/arch/mips/mips-boards/sead/Makefile
deleted file mode 100644
index 3682fe217bd..00000000000
--- a/arch/mips/mips-boards/sead/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
1#
2# Carsten Langgaard, carstenl@mips.com
3# Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved.
4#
5# ########################################################################
6#
7# This program is free software; you can distribute it and/or modify it
8# under the terms of the GNU General Public License (Version 2) as
9# published by the Free Software Foundation.
10#
11# This program is distributed in the hope it will be useful, but WITHOUT
12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14# 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# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19#
20# #######################################################################
21#
22# Makefile for the MIPS SEAD specific kernel interface routines
23# under Linux.
24#
25
26obj-y := sead_int.o sead_setup.o
27
28EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/sead/sead_int.c b/arch/mips/mips-boards/sead/sead_int.c
deleted file mode 100644
index ec6dd194c14..00000000000
--- a/arch/mips/mips-boards/sead/sead_int.c
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved.
4 * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org)
5 * Copyright (C) 2004 Maciej W. Rozycki
6 *
7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * 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 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 *
20 * Routines for generic manipulation of the interrupts found on the MIPS
21 * Sead board.
22 */
23#include <linux/init.h>
24#include <linux/interrupt.h>
25
26#include <asm/irq_cpu.h>
27#include <asm/mipsregs.h>
28#include <asm/system.h>
29
30#include <asm/mips-boards/seadint.h>
31
32static inline int clz(unsigned long x)
33{
34 __asm__(
35 " .set push \n"
36 " .set mips32 \n"
37 " clz %0, %1 \n"
38 " .set pop \n"
39 : "=r" (x)
40 : "r" (x));
41
42 return x;
43}
44
45/*
46 * Version of ffs that only looks at bits 12..15.
47 */
48static inline unsigned int irq_ffs(unsigned int pending)
49{
50#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
51 return -clz(pending) + 31 - CAUSEB_IP;
52#else
53 unsigned int a0 = 7;
54 unsigned int t0;
55
56 t0 = s0 & 0xf000;
57 t0 = t0 < 1;
58 t0 = t0 << 2;
59 a0 = a0 - t0;
60 s0 = s0 << t0;
61
62 t0 = s0 & 0xc000;
63 t0 = t0 < 1;
64 t0 = t0 << 1;
65 a0 = a0 - t0;
66 s0 = s0 << t0;
67
68 t0 = s0 & 0x8000;
69 t0 = t0 < 1;
70 //t0 = t0 << 2;
71 a0 = a0 - t0;
72 //s0 = s0 << t0;
73
74 return a0;
75#endif
76}
77
78/*
79 * IRQs on the SEAD board look basically are combined together on hardware
80 * interrupt 0 (MIPS IRQ 2)) like:
81 *
82 * MIPS IRQ Source
83 * -------- ------
84 * 0 Software (ignored)
85 * 1 Software (ignored)
86 * 2 UART0 (hw0)
87 * 3 UART1 (hw1)
88 * 4 Hardware (ignored)
89 * 5 Hardware (ignored)
90 * 6 Hardware (ignored)
91 * 7 R4k timer (what we use)
92 *
93 * We handle the IRQ according to _our_ priority which is:
94 *
95 * Highest ---- R4k Timer
96 * Lowest ---- Combined hardware interrupt
97 *
98 * then we just return, if multiple IRQs are pending then we will just take
99 * another exception, big deal.
100 */
101asmlinkage void plat_irq_dispatch(void)
102{
103 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
104 int irq;
105
106 irq = irq_ffs(pending);
107
108 if (irq >= 0)
109 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
110 else
111 spurious_interrupt();
112}
113
114void __init arch_init_irq(void)
115{
116 mips_cpu_irq_init();
117}
diff --git a/arch/mips/mips-boards/sead/sead_setup.c b/arch/mips/mips-boards/sead/sead_setup.c
deleted file mode 100644
index 8aa8e5b7b07..00000000000
--- a/arch/mips/mips-boards/sead/sead_setup.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 2002 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * SEAD specific setup.
19 */
20#include <linux/init.h>
21#include <linux/sched.h>
22#include <linux/ioport.h>
23#include <linux/tty.h>
24#include <linux/serial.h>
25#include <linux/serial_core.h>
26#include <linux/serial_8250.h>
27
28#include <asm/cpu.h>
29#include <asm/bootinfo.h>
30#include <asm/irq.h>
31#include <asm/mips-boards/generic.h>
32#include <asm/mips-boards/prom.h>
33#include <asm/mips-boards/sead.h>
34#include <asm/mips-boards/seadint.h>
35#include <asm/time.h>
36
37static void __init serial_init(void);
38
39const char *get_system_type(void)
40{
41 return "MIPS SEAD";
42}
43
44const char display_string[] = " LINUX ON SEAD ";
45
46void __init plat_mem_setup(void)
47{
48 ioport_resource.end = 0x7fffffff;
49
50 serial_init();
51
52 mips_reboot_setup();
53}
54
55static void __init serial_init(void)
56{
57#ifdef CONFIG_SERIAL_8250
58 struct uart_port s;
59
60 memset(&s, 0, sizeof(s));
61
62#ifdef CONFIG_CPU_LITTLE_ENDIAN
63 s.iobase = SEAD_UART0_REGS_BASE;
64#else
65 s.iobase = SEAD_UART0_REGS_BASE+3;
66#endif
67 s.irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_UART0;
68 s.uartclk = SEAD_BASE_BAUD * 16;
69 s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ;
70 s.iotype = UPIO_PORT;
71 s.regshift = 3;
72
73 if (early_serial_setup(&s) != 0) {
74 printk(KERN_ERR "Serial setup failed!\n");
75 }
76#endif
77}
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 27096751ddc..71df3390c07 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -43,12 +43,12 @@
43 * primary cache. 43 * primary cache.
44 */ 44 */
45static inline void r4k_on_each_cpu(void (*func) (void *info), void *info, 45static inline void r4k_on_each_cpu(void (*func) (void *info), void *info,
46 int retry, int wait) 46 int wait)
47{ 47{
48 preempt_disable(); 48 preempt_disable();
49 49
50#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC) 50#if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
51 smp_call_function(func, info, retry, wait); 51 smp_call_function(func, info, wait);
52#endif 52#endif
53 func(info); 53 func(info);
54 preempt_enable(); 54 preempt_enable();
@@ -350,7 +350,7 @@ static inline void local_r4k___flush_cache_all(void * args)
350 350
351static void r4k___flush_cache_all(void) 351static void r4k___flush_cache_all(void)
352{ 352{
353 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1); 353 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1);
354} 354}
355 355
356static inline int has_valid_asid(const struct mm_struct *mm) 356static inline int has_valid_asid(const struct mm_struct *mm)
@@ -397,7 +397,7 @@ static void r4k_flush_cache_range(struct vm_area_struct *vma,
397 int exec = vma->vm_flags & VM_EXEC; 397 int exec = vma->vm_flags & VM_EXEC;
398 398
399 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) 399 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
400 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1); 400 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1);
401} 401}
402 402
403static inline void local_r4k_flush_cache_mm(void * args) 403static inline void local_r4k_flush_cache_mm(void * args)
@@ -429,7 +429,7 @@ static void r4k_flush_cache_mm(struct mm_struct *mm)
429 if (!cpu_has_dc_aliases) 429 if (!cpu_has_dc_aliases)
430 return; 430 return;
431 431
432 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1); 432 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1);
433} 433}
434 434
435struct flush_cache_page_args { 435struct flush_cache_page_args {
@@ -521,7 +521,7 @@ static void r4k_flush_cache_page(struct vm_area_struct *vma,
521 args.addr = addr; 521 args.addr = addr;
522 args.pfn = pfn; 522 args.pfn = pfn;
523 523
524 r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1); 524 r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1);
525} 525}
526 526
527static inline void local_r4k_flush_data_cache_page(void * addr) 527static inline void local_r4k_flush_data_cache_page(void * addr)
@@ -535,7 +535,7 @@ static void r4k_flush_data_cache_page(unsigned long addr)
535 local_r4k_flush_data_cache_page((void *)addr); 535 local_r4k_flush_data_cache_page((void *)addr);
536 else 536 else
537 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 537 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr,
538 1, 1); 538 1);
539} 539}
540 540
541struct flush_icache_range_args { 541struct flush_icache_range_args {
@@ -571,7 +571,7 @@ static void r4k_flush_icache_range(unsigned long start, unsigned long end)
571 args.start = start; 571 args.start = start;
572 args.end = end; 572 args.end = end;
573 573
574 r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1); 574 r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1);
575 instruction_hazard(); 575 instruction_hazard();
576} 576}
577 577
@@ -672,7 +672,7 @@ static void local_r4k_flush_cache_sigtramp(void * arg)
672 672
673static void r4k_flush_cache_sigtramp(unsigned long addr) 673static void r4k_flush_cache_sigtramp(unsigned long addr)
674{ 674{
675 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1); 675 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1);
676} 676}
677 677
678static void r4k_flush_icache_all(void) 678static void r4k_flush_icache_all(void)
diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
index 1655aa69e13..f467199676a 100644
--- a/arch/mips/mm/uasm.c
+++ b/arch/mips/mm/uasm.c
@@ -396,7 +396,7 @@ int __cpuinit uasm_in_compat_space_p(long addr)
396#endif 396#endif
397} 397}
398 398
399int __cpuinit uasm_rel_highest(long val) 399static int __cpuinit uasm_rel_highest(long val)
400{ 400{
401#ifdef CONFIG_64BIT 401#ifdef CONFIG_64BIT
402 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000; 402 return ((((val + 0x800080008000L) >> 48) & 0xffff) ^ 0x8000) - 0x8000;
@@ -405,7 +405,7 @@ int __cpuinit uasm_rel_highest(long val)
405#endif 405#endif
406} 406}
407 407
408int __cpuinit uasm_rel_higher(long val) 408static int __cpuinit uasm_rel_higher(long val)
409{ 409{
410#ifdef CONFIG_64BIT 410#ifdef CONFIG_64BIT
411 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000; 411 return ((((val + 0x80008000L) >> 32) & 0xffff) ^ 0x8000) - 0x8000;
diff --git a/arch/mips/mm/uasm.h b/arch/mips/mm/uasm.h
index 0d6a66f3203..c6d1e3dd82d 100644
--- a/arch/mips/mm/uasm.h
+++ b/arch/mips/mm/uasm.h
@@ -103,8 +103,6 @@ struct uasm_label {
103void __cpuinit uasm_build_label(struct uasm_label **lab, u32 *addr, int lid); 103void __cpuinit uasm_build_label(struct uasm_label **lab, u32 *addr, int lid);
104#ifdef CONFIG_64BIT 104#ifdef CONFIG_64BIT
105int uasm_in_compat_space_p(long addr); 105int uasm_in_compat_space_p(long addr);
106int uasm_rel_highest(long val);
107int uasm_rel_higher(long val);
108#endif 106#endif
109int uasm_rel_hi(long val); 107int uasm_rel_hi(long val);
110int uasm_rel_lo(long val); 108int uasm_rel_lo(long val);
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
new file mode 100644
index 00000000000..f8064446e81
--- /dev/null
+++ b/arch/mips/mti-malta/Makefile
@@ -0,0 +1,21 @@
1#
2# Carsten Langgaard, carstenl@mips.com
3# Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4#
5# Copyright (C) 2008 Wind River Systems, Inc.
6# written by Ralf Baechle <ralf@linux-mips.org>
7#
8obj-y := malta-amon.o malta-cmdline.o \
9 malta-display.o malta-init.o malta-int.o \
10 malta-memory.o malta-mtd.o \
11 malta-platform.o malta-reset.o \
12 malta-setup.o malta-time.o
13
14obj-$(CONFIG_EARLY_PRINTK) += malta-console.o
15obj-$(CONFIG_PCI) += malta-pci.o
16obj-$(CONFIG_KGDB) += malta-kgdb.o
17
18# FIXME FIXME FIXME
19obj-$(CONFIG_MIPS_MT_SMTC) += malta_smtc.o
20
21EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/mips-boards/generic/amon.c b/arch/mips/mti-malta/malta-amon.c
index 96236bf3383..96236bf3383 100644
--- a/arch/mips/mips-boards/generic/amon.c
+++ b/arch/mips/mti-malta/malta-amon.c
diff --git a/arch/mips/mips-boards/generic/cmdline.c b/arch/mips/mti-malta/malta-cmdline.c
index 1871c30ed2e..1871c30ed2e 100644
--- a/arch/mips/mips-boards/generic/cmdline.c
+++ b/arch/mips/mti-malta/malta-cmdline.c
diff --git a/arch/mips/mips-boards/generic/console.c b/arch/mips/mti-malta/malta-console.c
index 4d8ab99e415..43bcfb4f816 100644
--- a/arch/mips/mips-boards/generic/console.c
+++ b/arch/mips/mti-malta/malta-console.c
@@ -22,30 +22,9 @@
22#include <linux/serial_reg.h> 22#include <linux/serial_reg.h>
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#ifdef CONFIG_MIPS_ATLAS
26#include <asm/mips-boards/atlas.h>
27
28#ifdef CONFIG_CPU_LITTLE_ENDIAN
29#define PORT(offset) (ATLAS_UART_REGS_BASE + ((offset)<<3))
30#else
31#define PORT(offset) (ATLAS_UART_REGS_BASE + 3 + ((offset)<<3))
32#endif
33
34#elif defined(CONFIG_MIPS_SEAD)
35
36#include <asm/mips-boards/sead.h>
37
38#ifdef CONFIG_CPU_LITTLE_ENDIAN
39#define PORT(offset) (SEAD_UART0_REGS_BASE + ((offset)<<3))
40#else
41#define PORT(offset) (SEAD_UART0_REGS_BASE + 3 + ((offset)<<3))
42#endif
43
44#else
45 25
46#define PORT(offset) (0x3f8 + (offset)) 26#define PORT(offset) (0x3f8 + (offset))
47 27
48#endif
49 28
50static inline unsigned int serial_in(int offset) 29static inline unsigned int serial_in(int offset)
51{ 30{
diff --git a/arch/mips/mips-boards/generic/display.c b/arch/mips/mti-malta/malta-display.c
index 2a0057cfc30..7c8828fcb0a 100644
--- a/arch/mips/mips-boards/generic/display.c
+++ b/arch/mips/mti-malta/malta-display.c
@@ -22,6 +22,7 @@
22#include <linux/timer.h> 22#include <linux/timer.h>
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/mips-boards/generic.h> 24#include <asm/mips-boards/generic.h>
25#include <asm/mips-boards/prom.h>
25 26
26extern const char display_string[]; 27extern const char display_string[];
27static unsigned int display_count; 28static unsigned int display_count;
diff --git a/arch/mips/mips-boards/generic/init.c b/arch/mips/mti-malta/malta-init.c
index 83b9dc73920..c0653021a17 100644
--- a/arch/mips/mips-boards/generic/init.c
+++ b/arch/mips/mti-malta/malta-init.c
@@ -197,14 +197,6 @@ void __init kgdb_config(void)
197 while ((c = *++argptr) && ('0' <= c && c <= '9')) 197 while ((c = *++argptr) && ('0' <= c && c <= '9'))
198 speed = speed * 10 + c - '0'; 198 speed = speed * 10 + c - '0';
199 } 199 }
200#ifdef CONFIG_MIPS_ATLAS
201 if (line == 1) {
202 speed = saa9730_kgdb_hook(speed);
203 generic_putDebugChar = saa9730_putDebugChar;
204 generic_getDebugChar = saa9730_getDebugChar;
205 }
206 else
207#endif
208 { 200 {
209 speed = rs_kgdb_hook(line, speed); 201 speed = rs_kgdb_hook(line, speed);
210 generic_putDebugChar = rs_putDebugChar; 202 generic_putDebugChar = rs_putDebugChar;
@@ -260,9 +252,6 @@ void __init prom_init(void)
260 252
261 mips_display_message("LINUX"); 253 mips_display_message("LINUX");
262 254
263#ifdef CONFIG_MIPS_SEAD
264 set_io_port_base(KSEG1);
265#else
266 /* 255 /*
267 * early setup of _pcictrl_bonito so that we can determine 256 * early setup of _pcictrl_bonito so that we can determine
268 * the system controller on a CORE_EMUL board 257 * the system controller on a CORE_EMUL board
@@ -414,7 +403,6 @@ void __init prom_init(void)
414 mips_display_message("SC Error"); 403 mips_display_message("SC Error");
415 while (1); /* We die here... */ 404 while (1); /* We die here... */
416 } 405 }
417#endif
418 board_nmi_handler_setup = mips_nmi_setup; 406 board_nmi_handler_setup = mips_nmi_setup;
419 board_ejtag_handler_setup = mips_ejtag_setup; 407 board_ejtag_handler_setup = mips_ejtag_setup;
420 408
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mti-malta/malta-int.c
index 8c495104b32..ea176113fea 100644
--- a/arch/mips/mips-boards/malta/malta_int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -363,6 +363,7 @@ static msc_irqmap_t __initdata msc_eicirqmap[] = {
363 363
364static int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap); 364static int __initdata msc_nr_eicirqs = ARRAY_SIZE(msc_eicirqmap);
365 365
366#if defined(CONFIG_MIPS_MT_SMP)
366/* 367/*
367 * This GIC specific tabular array defines the association between External 368 * This GIC specific tabular array defines the association between External
368 * Interrupts and CPUs/Core Interrupts. The nature of the External 369 * Interrupts and CPUs/Core Interrupts. The nature of the External
@@ -394,11 +395,12 @@ static struct gic_intr_map gic_intr_map[] = {
394 { GIC_EXT_INTR(22), 3, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 }, 395 { GIC_EXT_INTR(22), 3, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
395 { GIC_EXT_INTR(23), 3, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 }, 396 { GIC_EXT_INTR(23), 3, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_EDGE, 1 },
396}; 397};
398#endif
397 399
398/* 400/*
399 * GCMP needs to be detected before any SMP initialisation 401 * GCMP needs to be detected before any SMP initialisation
400 */ 402 */
401int __init gcmp_probe(unsigned long addr, unsigned long size) 403static int __init gcmp_probe(unsigned long addr, unsigned long size)
402{ 404{
403 if (gcmp_present >= 0) 405 if (gcmp_present >= 0)
404 return gcmp_present; 406 return gcmp_present;
@@ -412,7 +414,8 @@ int __init gcmp_probe(unsigned long addr, unsigned long size)
412 return gcmp_present; 414 return gcmp_present;
413} 415}
414 416
415void __init fill_ipi_map(void) 417#if defined(CONFIG_MIPS_MT_SMP)
418static void __init fill_ipi_map(void)
416{ 419{
417 int i; 420 int i;
418 421
@@ -422,6 +425,7 @@ void __init fill_ipi_map(void)
422 (1 << (gic_intr_map[i].pin + 2)); 425 (1 << (gic_intr_map[i].pin + 2));
423 } 426 }
424} 427}
428#endif
425 429
426void __init arch_init_irq(void) 430void __init arch_init_irq(void)
427{ 431{
@@ -527,7 +531,6 @@ void __init arch_init_irq(void)
527 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE3 531 .call = GIC_IPI_EXT_INTR_CALLFNC_VPE3
528 } 532 }
529 }; 533 };
530#define NIPI (sizeof(ipiirq)/sizeof(ipiirq[0]))
531 fill_ipi_map(); 534 fill_ipi_map();
532 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE); 535 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
533 if (!gcmp_present) { 536 if (!gcmp_present) {
@@ -549,7 +552,7 @@ void __init arch_init_irq(void)
549 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status()); 552 printk("CPU%d: status register now %08x\n", smp_processor_id(), read_c0_status());
550 write_c0_status(0x1100dc00); 553 write_c0_status(0x1100dc00);
551 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status()); 554 printk("CPU%d: status register frc %08x\n", smp_processor_id(), read_c0_status());
552 for (i = 0; i < NIPI; i++) { 555 for (i = 0; i < ARRAY_SIZE(ipiirq); i++) {
553 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].resched, &irq_resched); 556 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].resched, &irq_resched);
554 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].call, &irq_call); 557 setup_irq(MIPS_GIC_IRQ_BASE + ipiirq[i].call, &irq_call);
555 558
diff --git a/arch/mips/mips-boards/generic/gdb_hook.c b/arch/mips/mti-malta/malta-kgdb.c
index 6a1854de457..6a1854de457 100644
--- a/arch/mips/mips-boards/generic/gdb_hook.c
+++ b/arch/mips/mti-malta/malta-kgdb.c
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mti-malta/malta-memory.c
index 5e443bba566..61888ff72c8 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mti-malta/malta-memory.c
@@ -97,7 +97,6 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
97 mdesc[1].base = 0x00001000; 97 mdesc[1].base = 0x00001000;
98 mdesc[1].size = 0x000ef000; 98 mdesc[1].size = 0x000ef000;
99 99
100#ifdef CONFIG_MIPS_MALTA
101 /* 100 /*
102 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the 101 * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the
103 * south bridge and PCI access always forwarded to the ISA Bus and 102 * south bridge and PCI access always forwarded to the ISA Bus and
@@ -108,11 +107,6 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
108 mdesc[2].type = yamon_dontuse; 107 mdesc[2].type = yamon_dontuse;
109 mdesc[2].base = 0x000f0000; 108 mdesc[2].base = 0x000f0000;
110 mdesc[2].size = 0x00010000; 109 mdesc[2].size = 0x00010000;
111#else
112 mdesc[2].type = yamon_prom;
113 mdesc[2].base = 0x000f0000;
114 mdesc[2].size = 0x00010000;
115#endif
116 110
117 mdesc[3].type = yamon_dontuse; 111 mdesc[3].type = yamon_dontuse;
118 mdesc[3].base = 0x00100000; 112 mdesc[3].base = 0x00100000;
diff --git a/arch/mips/mips-boards/malta/malta_mtd.c b/arch/mips/mti-malta/malta-mtd.c
index 8ad9bdf25dc..8ad9bdf25dc 100644
--- a/arch/mips/mips-boards/malta/malta_mtd.c
+++ b/arch/mips/mti-malta/malta-mtd.c
diff --git a/arch/mips/mips-boards/generic/pci.c b/arch/mips/mti-malta/malta-pci.c
index b9743190609..b9743190609 100644
--- a/arch/mips/mips-boards/generic/pci.c
+++ b/arch/mips/mti-malta/malta-pci.c
diff --git a/arch/mips/mips-boards/malta/malta_platform.c b/arch/mips/mti-malta/malta-platform.c
index 83b9bab3cd3..83b9bab3cd3 100644
--- a/arch/mips/mips-boards/malta/malta_platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
diff --git a/arch/mips/mips-boards/generic/reset.c b/arch/mips/mti-malta/malta-reset.c
index 583d468d98a..42dee4da37b 100644
--- a/arch/mips/mips-boards/generic/reset.c
+++ b/arch/mips/mti-malta/malta-reset.c
@@ -27,15 +27,9 @@
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/reboot.h> 28#include <asm/reboot.h>
29#include <asm/mips-boards/generic.h> 29#include <asm/mips-boards/generic.h>
30#if defined(CONFIG_MIPS_ATLAS)
31#include <asm/mips-boards/atlas.h>
32#endif
33 30
34static void mips_machine_restart(char *command); 31static void mips_machine_restart(char *command);
35static void mips_machine_halt(void); 32static void mips_machine_halt(void);
36#if defined(CONFIG_MIPS_ATLAS)
37static void atlas_machine_power_off(void);
38#endif
39 33
40static void mips_machine_restart(char *command) 34static void mips_machine_restart(char *command)
41{ 35{
@@ -53,23 +47,10 @@ static void mips_machine_halt(void)
53 __raw_writel(GORESET, softres_reg); 47 __raw_writel(GORESET, softres_reg);
54} 48}
55 49
56#if defined(CONFIG_MIPS_ATLAS)
57static void atlas_machine_power_off(void)
58{
59 unsigned int __iomem *psustby_reg = ioremap(ATLAS_PSUSTBY_REG, sizeof(unsigned int));
60
61 writew(ATLAS_GOSTBY, psustby_reg);
62}
63#endif
64 50
65void mips_reboot_setup(void) 51void mips_reboot_setup(void)
66{ 52{
67 _machine_restart = mips_machine_restart; 53 _machine_restart = mips_machine_restart;
68 _machine_halt = mips_machine_halt; 54 _machine_halt = mips_machine_halt;
69#if defined(CONFIG_MIPS_ATLAS)
70 pm_power_off = atlas_machine_power_off;
71#endif
72#if defined(CONFIG_MIPS_MALTA) || defined(CONFIG_MIPS_SEAD)
73 pm_power_off = mips_machine_halt; 55 pm_power_off = mips_machine_halt;
74#endif
75} 56}
diff --git a/arch/mips/mips-boards/malta/malta_setup.c b/arch/mips/mti-malta/malta-setup.c
index e7cad54936c..e7cad54936c 100644
--- a/arch/mips/mips-boards/malta/malta_setup.c
+++ b/arch/mips/mti-malta/malta-setup.c
diff --git a/arch/mips/mips-boards/malta/malta_smtc.c b/arch/mips/mti-malta/malta-smtc.c
index 5ea705e4945..5ea705e4945 100644
--- a/arch/mips/mips-boards/malta/malta_smtc.c
+++ b/arch/mips/mti-malta/malta-smtc.c
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mti-malta/malta-time.c
index fe2cac1b451..0b97d47691f 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mti-malta/malta-time.c
@@ -42,15 +42,7 @@
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 44
45#ifdef CONFIG_MIPS_ATLAS
46#include <asm/mips-boards/atlasint.h>
47#endif
48#ifdef CONFIG_MIPS_MALTA
49#include <asm/mips-boards/maltaint.h> 45#include <asm/mips-boards/maltaint.h>
50#endif
51#ifdef CONFIG_MIPS_SEAD
52#include <asm/mips-boards/seadint.h>
53#endif
54 46
55unsigned long cpu_khz; 47unsigned long cpu_khz;
56 48
@@ -76,20 +68,6 @@ static unsigned int __init estimate_cpu_frequency(void)
76 unsigned int prid = read_c0_prid() & 0xffff00; 68 unsigned int prid = read_c0_prid() & 0xffff00;
77 unsigned int count; 69 unsigned int count;
78 70
79#if defined(CONFIG_MIPS_SEAD) || defined(CONFIG_MIPS_SIM)
80 /*
81 * The SEAD board doesn't have a real time clock, so we can't
82 * really calculate the timer frequency
83 * For now we hardwire the SEAD board frequency to 12MHz.
84 */
85
86 if ((prid == (PRID_COMP_MIPS | PRID_IMP_20KC)) ||
87 (prid == (PRID_COMP_MIPS | PRID_IMP_25KF)))
88 count = 12000000;
89 else
90 count = 6000000;
91#endif
92#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA)
93 unsigned long flags; 71 unsigned long flags;
94 unsigned int start; 72 unsigned int start;
95 73
@@ -110,7 +88,6 @@ static unsigned int __init estimate_cpu_frequency(void)
110 88
111 /* restore interrupts */ 89 /* restore interrupts */
112 local_irq_restore(flags); 90 local_irq_restore(flags);
113#endif
114 91
115 mips_hpt_frequency = count; 92 mips_hpt_frequency = count;
116 if ((prid != (PRID_COMP_MIPS | PRID_IMP_20KC)) && 93 if ((prid != (PRID_COMP_MIPS | PRID_IMP_20KC)) &&
diff --git a/arch/mips/nxp/pnx8550/common/platform.c b/arch/mips/nxp/pnx8550/common/platform.c
index c7c763dbe58..21d2955359b 100644
--- a/arch/mips/nxp/pnx8550/common/platform.c
+++ b/arch/mips/nxp/pnx8550/common/platform.c
@@ -13,6 +13,7 @@
13 * warranty of any kind, whether express or implied. 13 * warranty of any kind, whether express or implied.
14 */ 14 */
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/dma-mapping.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/resource.h> 19#include <linux/resource.h>
@@ -91,16 +92,16 @@ struct pnx8xxx_port pnx8xxx_ports[] = {
91}; 92};
92 93
93/* The dmamask must be set for OHCI to work */ 94/* The dmamask must be set for OHCI to work */
94static u64 ohci_dmamask = ~(u32)0; 95static u64 ohci_dmamask = DMA_32BIT_MASK;
95 96
96static u64 uart_dmamask = ~(u32)0; 97static u64 uart_dmamask = DMA_32BIT_MASK;
97 98
98static struct platform_device pnx8550_usb_ohci_device = { 99static struct platform_device pnx8550_usb_ohci_device = {
99 .name = "pnx8550-ohci", 100 .name = "pnx8550-ohci",
100 .id = -1, 101 .id = -1,
101 .dev = { 102 .dev = {
102 .dma_mask = &ohci_dmamask, 103 .dma_mask = &ohci_dmamask,
103 .coherent_dma_mask = 0xffffffff, 104 .coherent_dma_mask = DMA_32BIT_MASK,
104 }, 105 },
105 .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources), 106 .num_resources = ARRAY_SIZE(pnx8550_usb_ohci_resources),
106 .resource = pnx8550_usb_ohci_resources, 107 .resource = pnx8550_usb_ohci_resources,
@@ -111,7 +112,7 @@ static struct platform_device pnx8550_uart_device = {
111 .id = -1, 112 .id = -1,
112 .dev = { 113 .dev = {
113 .dma_mask = &uart_dmamask, 114 .dma_mask = &uart_dmamask,
114 .coherent_dma_mask = 0xffffffff, 115 .coherent_dma_mask = DMA_32BIT_MASK,
115 .platform_data = pnx8xxx_ports, 116 .platform_data = pnx8xxx_ports,
116 }, 117 },
117 .num_resources = ARRAY_SIZE(pnx8550_uart_resources), 118 .num_resources = ARRAY_SIZE(pnx8550_uart_resources),
diff --git a/arch/mips/oprofile/common.c b/arch/mips/oprofile/common.c
index b5f6f71b27b..dd2fbd6645c 100644
--- a/arch/mips/oprofile/common.c
+++ b/arch/mips/oprofile/common.c
@@ -27,7 +27,7 @@ static int op_mips_setup(void)
27 model->reg_setup(ctr); 27 model->reg_setup(ctr);
28 28
29 /* Configure the registers on all cpus. */ 29 /* Configure the registers on all cpus. */
30 on_each_cpu(model->cpu_setup, NULL, 0, 1); 30 on_each_cpu(model->cpu_setup, NULL, 1);
31 31
32 return 0; 32 return 0;
33} 33}
@@ -58,7 +58,7 @@ static int op_mips_create_files(struct super_block * sb, struct dentry * root)
58 58
59static int op_mips_start(void) 59static int op_mips_start(void)
60{ 60{
61 on_each_cpu(model->cpu_start, NULL, 0, 1); 61 on_each_cpu(model->cpu_start, NULL, 1);
62 62
63 return 0; 63 return 0;
64} 64}
@@ -66,7 +66,7 @@ static int op_mips_start(void)
66static void op_mips_stop(void) 66static void op_mips_stop(void)
67{ 67{
68 /* Disable performance monitoring for all counters. */ 68 /* Disable performance monitoring for all counters. */
69 on_each_cpu(model->cpu_stop, NULL, 0, 1); 69 on_each_cpu(model->cpu_stop, NULL, 1);
70} 70}
71 71
72int __init oprofile_arch_init(struct oprofile_operations *ops) 72int __init oprofile_arch_init(struct oprofile_operations *ops)
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index b40df7d2cf4..54759f1669d 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -313,7 +313,7 @@ static int __init mipsxx_init(void)
313 if (!cpu_has_mipsmt_pertccounters) 313 if (!cpu_has_mipsmt_pertccounters)
314 counters = counters_total_to_per_cpu(counters); 314 counters = counters_total_to_per_cpu(counters);
315#endif 315#endif
316 on_each_cpu(reset_counters, (void *)(long)counters, 0, 1); 316 on_each_cpu(reset_counters, (void *)(long)counters, 1);
317 317
318 op_model_mipsxx_ops.num_counters = counters; 318 op_model_mipsxx_ops.num_counters = counters;
319 switch (current_cpu_type()) { 319 switch (current_cpu_type()) {
@@ -382,7 +382,7 @@ static void mipsxx_exit(void)
382 int counters = op_model_mipsxx_ops.num_counters; 382 int counters = op_model_mipsxx_ops.num_counters;
383 383
384 counters = counters_per_cpu_to_total(counters); 384 counters = counters_per_cpu_to_total(counters);
385 on_each_cpu(reset_counters, (void *)(long)counters, 0, 1); 385 on_each_cpu(reset_counters, (void *)(long)counters, 1);
386 386
387 perf_irq = save_perf_irq; 387 perf_irq = save_perf_irq;
388} 388}
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index ed0c07622ba..57e34cafa49 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -11,17 +11,16 @@ obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o
11obj-$(CONFIG_PCI_GT64XXX_PCI0) += ops-gt64xxx_pci0.o 11obj-$(CONFIG_PCI_GT64XXX_PCI0) += ops-gt64xxx_pci0.o
12obj-$(CONFIG_MIPS_MSC) += ops-msc.o 12obj-$(CONFIG_MIPS_MSC) += ops-msc.o
13obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o 13obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
14obj-$(CONFIG_MIPS_TX3927) += ops-tx3927.o 14obj-$(CONFIG_SOC_TX3927) += ops-tx3927.o
15obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o 15obj-$(CONFIG_PCI_VR41XX) += ops-vr41xx.o pci-vr41xx.o
16obj-$(CONFIG_NEC_CMBVR4133) += fixup-vr4133.o
17obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o 16obj-$(CONFIG_MARKEINS) += ops-emma2rh.o pci-emma2rh.o fixup-emma2rh.o
17obj-$(CONFIG_PCI_TX4927) += ops-tx4927.o
18 18
19# 19#
20# These are still pretty much in the old state, watch, go blind. 20# These are still pretty much in the old state, watch, go blind.
21# 21#
22obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o 22obj-$(CONFIG_BASLER_EXCITE) += ops-titan.o pci-excite.o fixup-excite.o
23obj-$(CONFIG_LASAT) += pci-lasat.o 23obj-$(CONFIG_LASAT) += pci-lasat.o
24obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
25obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o 24obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
26obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o 25obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o
27obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o 26obj-$(CONFIG_SOC_AU1550) += fixup-au1000.o ops-au1000.o
@@ -42,9 +41,11 @@ obj-$(CONFIG_SNI_RM) += fixup-sni.o ops-sni.o
42obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o 41obj-$(CONFIG_TANBAC_TB0219) += fixup-tb0219.o
43obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o 42obj-$(CONFIG_TANBAC_TB0226) += fixup-tb0226.o
44obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o 43obj-$(CONFIG_TANBAC_TB0287) += fixup-tb0287.o
45obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o pci-jmr3927.o 44obj-$(CONFIG_TOSHIBA_JMR3927) += fixup-jmr3927.o
46obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o ops-tx4927.o 45obj-$(CONFIG_SOC_TX4927) += pci-tx4927.o
47obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-tx4938.o ops-tx4938.o 46obj-$(CONFIG_SOC_TX4938) += pci-tx4938.o
47obj-$(CONFIG_TOSHIBA_RBTX4927) += fixup-rbtx4927.o
48obj-$(CONFIG_TOSHIBA_RBTX4938) += fixup-rbtx4938.o
48obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o 49obj-$(CONFIG_VICTOR_MPC30X) += fixup-mpc30x.o
49obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o 50obj-$(CONFIG_ZAO_CAPCELLA) += fixup-capcella.o
50obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o 51obj-$(CONFIG_WR_PPMC) += fixup-wrppmc.o
diff --git a/arch/mips/pci/fixup-atlas.c b/arch/mips/pci/fixup-atlas.c
deleted file mode 100644
index 506e883a8c7..00000000000
--- a/arch/mips/pci/fixup-atlas.c
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * Copyright (C) 2003, 2004 Ralf Baechle (ralf@linux-mips.org)
3 * Copyright (C) 2005 MIPS Technologies, Inc. All rights reserved.
4 * Author: Maciej W. Rozycki <macro@mips.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#include <linux/init.h>
20#include <linux/pci.h>
21
22#include <asm/mips-boards/atlasint.h>
23
24#define PCIA ATLAS_INT_PCIA
25#define PCIB ATLAS_INT_PCIB
26#define PCIC ATLAS_INT_PCIC
27#define PCID ATLAS_INT_PCID
28#define INTA ATLAS_INT_INTA
29#define INTB ATLAS_INT_INTB
30#define ETH ATLAS_INT_ETH
31#define INTC ATLAS_INT_INTC
32#define SCSI ATLAS_INT_SCSI
33#define INTD ATLAS_INT_INTD
34
35static char irq_tab[][5] __initdata = {
36 /* INTA INTB INTC INTD */
37 {0, 0, 0, 0, 0 }, /* 0: Unused */
38 {0, 0, 0, 0, 0 }, /* 1: Unused */
39 {0, 0, 0, 0, 0 }, /* 2: Unused */
40 {0, 0, 0, 0, 0 }, /* 3: Unused */
41 {0, 0, 0, 0, 0 }, /* 4: Unused */
42 {0, 0, 0, 0, 0 }, /* 5: Unused */
43 {0, 0, 0, 0, 0 }, /* 6: Unused */
44 {0, 0, 0, 0, 0 }, /* 7: Unused */
45 {0, 0, 0, 0, 0 }, /* 8: Unused */
46 {0, 0, 0, 0, 0 }, /* 9: Unused */
47 {0, 0, 0, 0, 0 }, /* 10: Unused */
48 {0, 0, 0, 0, 0 }, /* 11: Unused */
49 {0, 0, 0, 0, 0 }, /* 12: Unused */
50 {0, 0, 0, 0, 0 }, /* 13: Unused */
51 {0, 0, 0, 0, 0 }, /* 14: Unused */
52 {0, PCIA, PCIB, PCIC, PCID }, /* 15: cPCI (behind 21150) */
53 {0, SCSI, 0, 0, 0 }, /* 16: SYM53C810A SCSI */
54 {0, 0, 0, 0, 0 }, /* 17: Core */
55 {0, INTA, INTB, INTC, INTD }, /* 18: PCI Slot */
56 {0, ETH, 0, 0, 0 }, /* 19: SAA9730 Eth. et al. */
57 {0, 0, 0, 0, 0 }, /* 20: Unused */
58 {0, 0, 0, 0, 0 } /* 21: Unused */
59};
60
61int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
62{
63 return irq_tab[slot][pin];
64}
65
66/* Do platform specific device initialization at pci_enable_device() time */
67int pcibios_plat_dev_init(struct pci_dev *dev)
68{
69 return 0;
70}
71
72#ifdef CONFIG_KGDB
73/*
74 * The PCI scan may have moved the saa9730 I/O address, so reread
75 * the address here.
76 * This does mean that it's not possible to debug the PCI bus configuration
77 * code, but it is better than nothing...
78 */
79
80static void atlas_saa9730_base_fixup(struct pci_dev *pdev)
81{
82 extern void *saa9730_base;
83 if (pdev->bus == 0 && PCI_SLOT(pdev->devfn) == 19)
84 (void) pci_read_config_dword(pdev, 0x14, (u32 *)&saa9730_base);
85 printk("saa9730_base = %x\n", saa9730_base);
86}
87
88DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9730,
89 atlas_saa9730_base_fixup);
90
91#endif
diff --git a/arch/mips/pci/fixup-jmr3927.c b/arch/mips/pci/fixup-jmr3927.c
index e974394be7b..0f1069527cb 100644
--- a/arch/mips/pci/fixup-jmr3927.c
+++ b/arch/mips/pci/fixup-jmr3927.c
@@ -28,36 +28,31 @@
28 * 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/pci.h> 31#include <asm/txx9/pci.h>
32#include <linux/init.h> 32#include <asm/txx9/jmr3927.h>
33 33
34#include <asm/jmr3927/jmr3927.h> 34int __init jmr3927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
35
36int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
37{ 35{
38 unsigned char irq = pin; 36 unsigned char irq = pin;
39 37
40 /* SMSC SLC90E66 IDE uses irq 14, 15 (default) */
41 if (dev->vendor == PCI_VENDOR_ID_EFAR &&
42 dev->device == PCI_DEVICE_ID_EFAR_SLC90E66_1)
43 return irq;
44 /* IRQ rotation (PICMG) */ 38 /* IRQ rotation (PICMG) */
45 irq--; /* 0-3 */ 39 irq--; /* 0-3 */
46 if (dev->bus->parent == NULL && 40 if (slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(23)) {
47 slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(23)) {
48 /* PCI CardSlot (IDSEL=A23, DevNu=12) */ 41 /* PCI CardSlot (IDSEL=A23, DevNu=12) */
49 /* PCIA => PCIC (IDSEL=A23) */ 42 /* PCIA => PCIC (IDSEL=A23) */
50 /* NOTE: JMR3927 JP1 must be set to OPEN */ 43 /* NOTE: JMR3927 JP1 must be set to OPEN */
51 irq = (irq + 2) % 4; 44 irq = (irq + 2) % 4;
52 } else if (dev->bus->parent == NULL && 45 } else if (slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(22)) {
53 slot == TX3927_PCIC_IDSEL_AD_TO_SLOT(22)) {
54 /* PCI CardSlot (IDSEL=A22, DevNu=11) */ 46 /* PCI CardSlot (IDSEL=A22, DevNu=11) */
55 /* PCIA => PCIA (IDSEL=A22) */ 47 /* PCIA => PCIA (IDSEL=A22) */
56 /* NOTE: JMR3927 JP1 must be set to OPEN */ 48 /* NOTE: JMR3927 JP1 must be set to OPEN */
57 irq = (irq + 0) % 4; 49 irq = (irq + 0) % 4;
58 } else { 50 } else {
59 /* PCI Backplane */ 51 /* PCI Backplane */
60 irq = (irq + 3 + slot) % 4; 52 if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
53 irq = (irq + 33 - slot) % 4;
54 else
55 irq = (irq + 3 + slot) % 4;
61 } 56 }
62 irq++; /* 1-4 */ 57 irq++; /* 1-4 */
63 58
@@ -66,15 +61,13 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
66 irq = JMR3927_IRQ_IOC_PCIA; 61 irq = JMR3927_IRQ_IOC_PCIA;
67 break; 62 break;
68 case 2: 63 case 2:
69 // wrong for backplane irq = JMR3927_IRQ_IOC_PCIB; 64 irq = JMR3927_IRQ_IOC_PCIB;
70 irq = JMR3927_IRQ_IOC_PCID;
71 break; 65 break;
72 case 3: 66 case 3:
73 irq = JMR3927_IRQ_IOC_PCIC; 67 irq = JMR3927_IRQ_IOC_PCIC;
74 break; 68 break;
75 case 4: 69 case 4:
76 // wrong for backplane irq = JMR3927_IRQ_IOC_PCID; 70 irq = JMR3927_IRQ_IOC_PCID;
77 irq = JMR3927_IRQ_IOC_PCIB;
78 break; 71 break;
79 } 72 }
80 73
@@ -84,9 +77,3 @@ int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
84 irq = JMR3927_IRQ_ETHER0; 77 irq = JMR3927_IRQ_ETHER0;
85 return irq; 78 return irq;
86} 79}
87
88/* Do platform specific device initialization at pci_enable_device() time */
89int pcibios_plat_dev_init(struct pci_dev *dev)
90{
91 return 0;
92}
diff --git a/arch/mips/pci/fixup-rbtx4927.c b/arch/mips/pci/fixup-rbtx4927.c
index 7450c335b38..321db265829 100644
--- a/arch/mips/pci/fixup-rbtx4927.c
+++ b/arch/mips/pci/fixup-rbtx4927.c
@@ -33,108 +33,41 @@
33 * 675 Mass Ave, Cambridge, MA 02139, USA. 33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */ 34 */
35#include <linux/types.h> 35#include <linux/types.h>
36#include <linux/pci.h> 36#include <asm/txx9/pci.h>
37#include <linux/kernel.h> 37#include <asm/txx9/rbtx4927.h>
38#include <linux/init.h>
39 38
40#include <asm/tx4927/tx4927.h> 39int __init rbtx4927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
41#include <asm/tx4927/tx4927_pci.h>
42
43#undef DEBUG
44#ifdef DEBUG
45#define DBG(x...) printk(x)
46#else
47#define DBG(x...)
48#endif
49
50/* look up table for backplane pci irq for slots 17-20 by pin # */
51static unsigned char backplane_pci_irq[4][4] = {
52 /* PJ6 SLOT: 17, PIN: 1 */ {TX4927_IRQ_IOC_PCIA,
53 /* PJ6 SLOT: 17, PIN: 2 */
54 TX4927_IRQ_IOC_PCIB,
55 /* PJ6 SLOT: 17, PIN: 3 */
56 TX4927_IRQ_IOC_PCIC,
57 /* PJ6 SLOT: 17, PIN: 4 */
58 TX4927_IRQ_IOC_PCID},
59 /* SB SLOT: 18, PIN: 1 */ {TX4927_IRQ_IOC_PCIB,
60 /* SB SLOT: 18, PIN: 2 */
61 TX4927_IRQ_IOC_PCIC,
62 /* SB SLOT: 18, PIN: 3 */
63 TX4927_IRQ_IOC_PCID,
64 /* SB SLOT: 18, PIN: 4 */
65 TX4927_IRQ_IOC_PCIA},
66 /* PJ5 SLOT: 19, PIN: 1 */ {TX4927_IRQ_IOC_PCIC,
67 /* PJ5 SLOT: 19, PIN: 2 */
68 TX4927_IRQ_IOC_PCID,
69 /* PJ5 SLOT: 19, PIN: 3 */
70 TX4927_IRQ_IOC_PCIA,
71 /* PJ5 SLOT: 19, PIN: 4 */
72 TX4927_IRQ_IOC_PCIB},
73 /* PJ4 SLOT: 20, PIN: 1 */ {TX4927_IRQ_IOC_PCID,
74 /* PJ4 SLOT: 20, PIN: 2 */
75 TX4927_IRQ_IOC_PCIA,
76 /* PJ4 SLOT: 20, PIN: 3 */
77 TX4927_IRQ_IOC_PCIB,
78 /* PJ4 SLOT: 20, PIN: 4 */
79 TX4927_IRQ_IOC_PCIC}
80};
81
82static int pci_get_irq(const struct pci_dev *dev, int pin)
83{ 40{
84 unsigned char irq = pin; 41 unsigned char irq = pin;
85 42
86 DBG("pci_get_irq: pin is %d\n", pin);
87 /* IRQ rotation */ 43 /* IRQ rotation */
88 irq--; /* 0-3 */ 44 irq--; /* 0-3 */
89 if (dev->bus->parent == NULL && 45 if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
90 PCI_SLOT(dev->devfn) == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) { 46 /* PCI CardSlot (IDSEL=A23) */
91 printk("Onboard PCI_SLOT(dev->devfn) is %d\n", 47 /* PCIA => PCIA */
92 PCI_SLOT(dev->devfn)); 48 irq = (irq + 0 + slot) % 4;
93 /* IDSEL=A23 is tx4927 onboard pci slot */
94 irq = (irq + PCI_SLOT(dev->devfn)) % 4;
95 irq++; /* 1-4 */
96 DBG("irq is now %d\n", irq);
97
98 switch (irq) {
99 case 1:
100 irq = TX4927_IRQ_IOC_PCIA;
101 break;
102 case 2:
103 irq = TX4927_IRQ_IOC_PCIB;
104 break;
105 case 3:
106 irq = TX4927_IRQ_IOC_PCIC;
107 break;
108 case 4:
109 irq = TX4927_IRQ_IOC_PCID;
110 break;
111 }
112 } else { 49 } else {
113 /* PCI Backplane */ 50 /* PCI Backplane */
114 DBG("PCI Backplane PCI_SLOT(dev->devfn) is %d\n", 51 if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
115 PCI_SLOT(dev->devfn)); 52 irq = (irq + 33 - slot) % 4;
116 irq = backplane_pci_irq[PCI_SLOT(dev->devfn) - 17][irq]; 53 else
54 irq = (irq + 3 + slot) % 4;
117 } 55 }
118 DBG("assigned irq %d\n", irq); 56 irq++; /* 1-4 */
119 return irq;
120}
121
122int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
123{
124 unsigned char irq;
125
126 printk("PCI Setup for pin %d \n", pin);
127
128 if (dev->device == 0x9130) /* IDE */
129 irq = 14;
130 else
131 irq = pci_get_irq(dev, pin);
132 57
58 switch (irq) {
59 case 1:
60 irq = RBTX4927_IRQ_IOC_PCIA;
61 break;
62 case 2:
63 irq = RBTX4927_IRQ_IOC_PCIB;
64 break;
65 case 3:
66 irq = RBTX4927_IRQ_IOC_PCIC;
67 break;
68 case 4:
69 irq = RBTX4927_IRQ_IOC_PCID;
70 break;
71 }
133 return irq; 72 return irq;
134} 73}
135
136/* Do platform specific device initialization at pci_enable_device() time */
137int pcibios_plat_dev_init(struct pci_dev *dev)
138{
139 return 0;
140}
diff --git a/arch/mips/pci/fixup-rbtx4938.c b/arch/mips/pci/fixup-rbtx4938.c
new file mode 100644
index 00000000000..a80579af609
--- /dev/null
+++ b/arch/mips/pci/fixup-rbtx4938.c
@@ -0,0 +1,53 @@
1/*
2 * Toshiba rbtx4938 pci routines
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12#include <linux/types.h>
13#include <asm/txx9/pci.h>
14#include <asm/txx9/rbtx4938.h>
15
16int __init rbtx4938_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
17{
18 int irq = tx4938_pcic1_map_irq(dev, slot);
19
20 if (irq >= 0)
21 return irq;
22 irq = pin;
23 /* IRQ rotation */
24 irq--; /* 0-3 */
25 if (slot == TX4927_PCIC_IDSEL_AD_TO_SLOT(23)) {
26 /* PCI CardSlot (IDSEL=A23) */
27 /* PCIA => PCIA (IDSEL=A23) */
28 irq = (irq + 0 + slot) % 4;
29 } else {
30 /* PCI Backplane */
31 if (txx9_pci_option & TXX9_PCI_OPT_PICMG)
32 irq = (irq + 33 - slot) % 4;
33 else
34 irq = (irq + 3 + slot) % 4;
35 }
36 irq++; /* 1-4 */
37
38 switch (irq) {
39 case 1:
40 irq = RBTX4938_IRQ_IOC_PCIA;
41 break;
42 case 2:
43 irq = RBTX4938_IRQ_IOC_PCIB;
44 break;
45 case 3:
46 irq = RBTX4938_IRQ_IOC_PCIC;
47 break;
48 case 4:
49 irq = RBTX4938_IRQ_IOC_PCID;
50 break;
51 }
52 return irq;
53}
diff --git a/arch/mips/pci/fixup-tx4938.c b/arch/mips/pci/fixup-tx4938.c
deleted file mode 100644
index f2ba06ee0c1..00000000000
--- a/arch/mips/pci/fixup-tx4938.c
+++ /dev/null
@@ -1,92 +0,0 @@
1/*
2 * Toshiba rbtx4938 pci routines
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12#include <linux/types.h>
13#include <linux/pci.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16
17#include <asm/tx4938/rbtx4938.h>
18
19extern struct pci_controller tx4938_pci_controller[];
20
21static int pci_get_irq(const struct pci_dev *dev, int pin)
22{
23 int irq = pin;
24 u8 slot = PCI_SLOT(dev->devfn);
25 struct pci_controller *controller = (struct pci_controller *)dev->sysdata;
26
27 if (controller == &tx4938_pci_controller[1]) {
28 /* TX4938 PCIC1 */
29 switch (slot) {
30 case TX4938_PCIC_IDSEL_AD_TO_SLOT(31):
31 if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH0_SEL)
32 return RBTX4938_IRQ_IRC + TX4938_IR_ETH0;
33 break;
34 case TX4938_PCIC_IDSEL_AD_TO_SLOT(30):
35 if (tx4938_ccfgptr->pcfg & TX4938_PCFG_ETH1_SEL)
36 return RBTX4938_IRQ_IRC + TX4938_IR_ETH1;
37 break;
38 }
39 return 0;
40 }
41
42 /* IRQ rotation */
43 irq--; /* 0-3 */
44 if (dev->bus->parent == NULL &&
45 (slot == TX4938_PCIC_IDSEL_AD_TO_SLOT(23))) {
46 /* PCI CardSlot (IDSEL=A23) */
47 /* PCIA => PCIA (IDSEL=A23) */
48 irq = (irq + 0 + slot) % 4;
49 } else {
50 /* PCI Backplane */
51 irq = (irq + 33 - slot) % 4;
52 }
53 irq++; /* 1-4 */
54
55 switch (irq) {
56 case 1:
57 irq = RBTX4938_IRQ_IOC_PCIA;
58 break;
59 case 2:
60 irq = RBTX4938_IRQ_IOC_PCIB;
61 break;
62 case 3:
63 irq = RBTX4938_IRQ_IOC_PCIC;
64 break;
65 case 4:
66 irq = RBTX4938_IRQ_IOC_PCID;
67 break;
68 }
69 return irq;
70}
71
72int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
73{
74 unsigned char irq = 0;
75
76 irq = pci_get_irq(dev, pin);
77
78 printk(KERN_INFO "PCI: 0x%02x:0x%02x(0x%02x,0x%02x) IRQ=%d\n",
79 dev->bus->number, dev->devfn, PCI_SLOT(dev->devfn),
80 PCI_FUNC(dev->devfn), irq);
81
82 return irq;
83}
84
85/*
86 * Do platform specific device initialization at pci_enable_device() time
87 */
88int pcibios_plat_dev_init(struct pci_dev *dev)
89{
90 return 0;
91}
92
diff --git a/arch/mips/pci/fixup-vr4133.c b/arch/mips/pci/fixup-vr4133.c
deleted file mode 100644
index de5e5f6bbf4..00000000000
--- a/arch/mips/pci/fixup-vr4133.c
+++ /dev/null
@@ -1,195 +0,0 @@
1/*
2 * arch/mips/pci/fixup-vr4133.c
3 *
4 * The NEC CMB-VR4133 Board specific PCI fixups.
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Alex Sapkov <asapkov@ru.mvista.com>
8 *
9 * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 *
14 * Modified for support in 2.6
15 * Author: Manish Lachwani (mlachwani@mvista.com)
16 *
17 */
18#include <linux/init.h>
19#include <linux/pci.h>
20#include <linux/kernel.h>
21
22#include <asm/io.h>
23#include <asm/i8259.h>
24#include <asm/vr41xx/cmbvr4133.h>
25
26extern int vr4133_rockhopper;
27extern void ali_m1535plus_init(struct pci_dev *dev);
28extern void ali_m5229_init(struct pci_dev *dev);
29
30/* Do platform specific device initialization at pci_enable_device() time */
31int pcibios_plat_dev_init(struct pci_dev *dev)
32{
33 /*
34 * We have to reset AMD PCnet adapter on Rockhopper since
35 * PMON leaves it enabled and generating interrupts. This leads
36 * to a lock if some PCI device driver later enables the IRQ line
37 * shared with PCnet and there is no AMD PCnet driver to catch its
38 * interrupts.
39 */
40#ifdef CONFIG_ROCKHOPPER
41 if (dev->vendor == PCI_VENDOR_ID_AMD &&
42 dev->device == PCI_DEVICE_ID_AMD_LANCE) {
43 inl(pci_resource_start(dev, 0) + 0x18);
44 }
45#endif
46
47 /*
48 * we have to open the bridges' windows down to 0 because otherwise
49 * we cannot access ISA south bridge I/O registers that get mapped from
50 * 0. for example, 8259 PIC would be unaccessible without that
51 */
52 if(dev->vendor == PCI_VENDOR_ID_INTEL && dev->device == PCI_DEVICE_ID_INTEL_S21152BB) {
53 pci_write_config_byte(dev, PCI_IO_BASE, 0);
54 if(dev->bus->number == 0) {
55 pci_write_config_word(dev, PCI_IO_BASE_UPPER16, 0);
56 } else {
57 pci_write_config_word(dev, PCI_IO_BASE_UPPER16, 1);
58 }
59 }
60
61 return 0;
62}
63
64/*
65 * M1535 IRQ mapping
66 * Feel free to change this, although it shouldn't be needed
67 */
68#define M1535_IRQ_INTA 7
69#define M1535_IRQ_INTB 9
70#define M1535_IRQ_INTC 10
71#define M1535_IRQ_INTD 11
72
73#define M1535_IRQ_USB 9
74#define M1535_IRQ_IDE 14
75#define M1535_IRQ_IDE2 15
76#define M1535_IRQ_PS2 12
77#define M1535_IRQ_RTC 8
78#define M1535_IRQ_FDC 6
79#define M1535_IRQ_AUDIO 5
80#define M1535_IRQ_COM1 4
81#define M1535_IRQ_COM2 4
82#define M1535_IRQ_IRDA 3
83#define M1535_IRQ_KBD 1
84#define M1535_IRQ_TMR 0
85
86/* Rockhopper "slots" assignment; this is hard-coded ... */
87#define ROCKHOPPER_M5451_SLOT 1
88#define ROCKHOPPER_M1535_SLOT 2
89#define ROCKHOPPER_M5229_SLOT 11
90#define ROCKHOPPER_M5237_SLOT 15
91#define ROCKHOPPER_PMU_SLOT 12
92/* ... and hard-wired. */
93#define ROCKHOPPER_PCI1_SLOT 3
94#define ROCKHOPPER_PCI2_SLOT 4
95#define ROCKHOPPER_PCI3_SLOT 5
96#define ROCKHOPPER_PCI4_SLOT 6
97#define ROCKHOPPER_PCNET_SLOT 1
98
99#define M1535_IRQ_MASK(n) (1 << (n))
100
101#define M1535_IRQ_EDGE (M1535_IRQ_MASK(M1535_IRQ_TMR) | \
102 M1535_IRQ_MASK(M1535_IRQ_KBD) | \
103 M1535_IRQ_MASK(M1535_IRQ_COM1) | \
104 M1535_IRQ_MASK(M1535_IRQ_COM2) | \
105 M1535_IRQ_MASK(M1535_IRQ_IRDA) | \
106 M1535_IRQ_MASK(M1535_IRQ_RTC) | \
107 M1535_IRQ_MASK(M1535_IRQ_FDC) | \
108 M1535_IRQ_MASK(M1535_IRQ_PS2))
109
110#define M1535_IRQ_LEVEL (M1535_IRQ_MASK(M1535_IRQ_IDE) | \
111 M1535_IRQ_MASK(M1535_IRQ_USB) | \
112 M1535_IRQ_MASK(M1535_IRQ_INTA) | \
113 M1535_IRQ_MASK(M1535_IRQ_INTB) | \
114 M1535_IRQ_MASK(M1535_IRQ_INTC) | \
115 M1535_IRQ_MASK(M1535_IRQ_INTD))
116
117struct irq_map_entry {
118 u16 bus;
119 u8 slot;
120 u8 irq;
121};
122static struct irq_map_entry int_map[] = {
123 {1, ROCKHOPPER_M5451_SLOT, M1535_IRQ_AUDIO}, /* Audio controller */
124 {1, ROCKHOPPER_PCI1_SLOT, M1535_IRQ_INTD}, /* PCI slot #1 */
125 {1, ROCKHOPPER_PCI2_SLOT, M1535_IRQ_INTC}, /* PCI slot #2 */
126 {1, ROCKHOPPER_M5237_SLOT, M1535_IRQ_USB}, /* USB host controller */
127 {1, ROCKHOPPER_M5229_SLOT, IDE_PRIMARY_IRQ}, /* IDE controller */
128 {2, ROCKHOPPER_PCNET_SLOT, M1535_IRQ_INTD}, /* AMD Am79c973 on-board
129 ethernet */
130 {2, ROCKHOPPER_PCI3_SLOT, M1535_IRQ_INTB}, /* PCI slot #3 */
131 {2, ROCKHOPPER_PCI4_SLOT, M1535_IRQ_INTC} /* PCI slot #4 */
132};
133
134static int pci_intlines[] =
135 { M1535_IRQ_INTA, M1535_IRQ_INTB, M1535_IRQ_INTC, M1535_IRQ_INTD };
136
137/* Determine the Rockhopper IRQ line number for the PCI device */
138int rockhopper_get_irq(struct pci_dev *dev, u8 pin, u8 slot)
139{
140 struct pci_bus *bus;
141 int i;
142
143 bus = dev->bus;
144 if (bus == NULL)
145 return -1;
146
147 for (i = 0; i < ARRAY_SIZE(int_map); i++) {
148 if (int_map[i].bus == bus->number && int_map[i].slot == slot) {
149 int line;
150 for (line = 0; line < 4; line++)
151 if (pci_intlines[line] == int_map[i].irq)
152 break;
153 if (line < 4)
154 return pci_intlines[(line + (pin - 1)) % 4];
155 else
156 return int_map[i].irq;
157 }
158 }
159 return -1;
160}
161
162#ifdef CONFIG_ROCKHOPPER
163void i8259_init(void)
164{
165 init_i8259_irqs();
166
167 outb(0x00, 0x4d0);
168 outb(0x02, 0x4d1); /* USB IRQ9 is level */
169}
170#endif
171
172int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
173{
174 extern int pci_probe_only;
175 pci_probe_only = 1;
176
177#ifdef CONFIG_ROCKHOPPER
178 if( dev->bus->number == 1 && vr4133_rockhopper ) {
179 if(slot == ROCKHOPPER_PCI1_SLOT || slot == ROCKHOPPER_PCI2_SLOT)
180 dev->irq = CMBVR41XX_INTA_IRQ;
181 else
182 dev->irq = rockhopper_get_irq(dev, pin, slot);
183 } else
184 dev->irq = CMBVR41XX_INTA_IRQ;
185#else
186 dev->irq = CMBVR41XX_INTA_IRQ;
187#endif
188
189 return dev->irq;
190}
191
192DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, ali_m1535plus_init);
193DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, ali_m5229_init);
194
195
diff --git a/arch/mips/pci/ops-mace.c b/arch/mips/pci/ops-mace.c
index e95881897ec..1cfb5588699 100644
--- a/arch/mips/pci/ops-mace.c
+++ b/arch/mips/pci/ops-mace.c
@@ -61,6 +61,13 @@ mace_pci_read_config(struct pci_bus *bus, unsigned int devfn,
61 /* ack possible master abort */ 61 /* ack possible master abort */
62 mace->pci.error &= ~MACEPCI_ERROR_MASTER_ABORT; 62 mace->pci.error &= ~MACEPCI_ERROR_MASTER_ABORT;
63 mace->pci.control = control; 63 mace->pci.control = control;
64 /*
65 * someone forgot to set the ultra bit for the onboard
66 * scsi chips; we fake it here
67 */
68 if (bus->number == 0 && reg == 0x40 && size == 4 &&
69 (devfn == (1 << 3) || devfn == (2 << 3)))
70 *val |= 0x1000;
64 71
65 DPRINTK("read%d: reg=%08x,val=%02x\n", size * 8, reg, *val); 72 DPRINTK("read%d: reg=%08x,val=%02x\n", size * 8, reg, *val);
66 73
diff --git a/arch/mips/pci/ops-tx3927.c b/arch/mips/pci/ops-tx3927.c
index aa698bd0d5e..8a17a39e5bf 100644
--- a/arch/mips/pci/ops-tx3927.c
+++ b/arch/mips/pci/ops-tx3927.c
@@ -8,7 +8,7 @@
8 * 8 *
9 * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c 9 * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c
10 * 10 *
11 * Define the pci_ops for JMR3927. 11 * Define the pci_ops for TX3927.
12 * 12 *
13 * Much of the code is derived from the original DDB5074 port by 13 * Much of the code is derived from the original DDB5074 port by
14 * Geert Uytterhoeven <geert@sonycom.com> 14 * Geert Uytterhoeven <geert@sonycom.com>
@@ -39,7 +39,7 @@
39#include <linux/init.h> 39#include <linux/init.h>
40 40
41#include <asm/addrspace.h> 41#include <asm/addrspace.h>
42#include <asm/jmr3927/jmr3927.h> 42#include <asm/txx9/tx3927.h>
43 43
44static inline int mkaddr(unsigned char bus, unsigned char dev_fn, 44static inline int mkaddr(unsigned char bus, unsigned char dev_fn,
45 unsigned char where) 45 unsigned char where)
@@ -68,7 +68,7 @@ static inline int check_abort(void)
68 return PCIBIOS_SUCCESSFUL; 68 return PCIBIOS_SUCCESSFUL;
69} 69}
70 70
71static int jmr3927_pci_read_config(struct pci_bus *bus, unsigned int devfn, 71static int tx3927_pci_read_config(struct pci_bus *bus, unsigned int devfn,
72 int where, int size, u32 * val) 72 int where, int size, u32 * val)
73{ 73{
74 int ret; 74 int ret;
@@ -94,7 +94,7 @@ static int jmr3927_pci_read_config(struct pci_bus *bus, unsigned int devfn,
94 return check_abort(); 94 return check_abort();
95} 95}
96 96
97static int jmr3927_pci_write_config(struct pci_bus *bus, unsigned int devfn, 97static int tx3927_pci_write_config(struct pci_bus *bus, unsigned int devfn,
98 int where, int size, u32 val) 98 int where, int size, u32 val)
99{ 99{
100 int ret; 100 int ret;
@@ -125,7 +125,80 @@ static int jmr3927_pci_write_config(struct pci_bus *bus, unsigned int devfn,
125 return check_abort(); 125 return check_abort();
126} 126}
127 127
128struct pci_ops jmr3927_pci_ops = { 128static struct pci_ops tx3927_pci_ops = {
129 jmr3927_pci_read_config, 129 .read = tx3927_pci_read_config,
130 jmr3927_pci_write_config, 130 .write = tx3927_pci_write_config,
131}; 131};
132
133void __init tx3927_pcic_setup(struct pci_controller *channel,
134 unsigned long sdram_size, int extarb)
135{
136 unsigned long flags;
137 unsigned long io_base =
138 channel->io_resource->start + mips_io_port_base - IO_BASE;
139 unsigned long io_size =
140 channel->io_resource->end - channel->io_resource->start;
141 unsigned long io_pciaddr =
142 channel->io_resource->start - channel->io_offset;
143 unsigned long mem_base =
144 channel->mem_resource->start;
145 unsigned long mem_size =
146 channel->mem_resource->end - channel->mem_resource->start;
147 unsigned long mem_pciaddr =
148 channel->mem_resource->start - channel->mem_offset;
149
150 printk(KERN_INFO "TX3927 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s",
151 tx3927_pcicptr->did, tx3927_pcicptr->vid,
152 tx3927_pcicptr->rid,
153 extarb ? "External" : "Internal");
154 channel->pci_ops = &tx3927_pci_ops;
155
156 local_irq_save(flags);
157 /* Disable External PCI Config. Access */
158 tx3927_pcicptr->lbc = TX3927_PCIC_LBC_EPCAD;
159#ifdef __BIG_ENDIAN
160 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_IBSE |
161 TX3927_PCIC_LBC_TIBSE |
162 TX3927_PCIC_LBC_TMFBSE | TX3927_PCIC_LBC_MSDSE;
163#endif
164 /* LB->PCI mappings */
165 tx3927_pcicptr->iomas = ~(io_size - 1);
166 tx3927_pcicptr->ilbioma = io_base;
167 tx3927_pcicptr->ipbioma = io_pciaddr;
168 tx3927_pcicptr->mmas = ~(mem_size - 1);
169 tx3927_pcicptr->ilbmma = mem_base;
170 tx3927_pcicptr->ipbmma = mem_pciaddr;
171 /* PCI->LB mappings */
172 tx3927_pcicptr->iobas = 0xffffffff;
173 tx3927_pcicptr->ioba = 0;
174 tx3927_pcicptr->tlbioma = 0;
175 tx3927_pcicptr->mbas = ~(sdram_size - 1);
176 tx3927_pcicptr->mba = 0;
177 tx3927_pcicptr->tlbmma = 0;
178 /* Enable Direct mapping Address Space Decoder */
179 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_ILMDE | TX3927_PCIC_LBC_ILIDE;
180
181 /* Clear All Local Bus Status */
182 tx3927_pcicptr->lbstat = TX3927_PCIC_LBIM_ALL;
183 /* Enable All Local Bus Interrupts */
184 tx3927_pcicptr->lbim = TX3927_PCIC_LBIM_ALL;
185 /* Clear All PCI Status Error */
186 tx3927_pcicptr->pcistat = TX3927_PCIC_PCISTATIM_ALL;
187 /* Enable All PCI Status Error Interrupts */
188 tx3927_pcicptr->pcistatim = TX3927_PCIC_PCISTATIM_ALL;
189
190 /* PCIC Int => IRC IRQ10 */
191 tx3927_pcicptr->il = TX3927_IR_PCI;
192 /* Target Control (per errata) */
193 tx3927_pcicptr->tc = TX3927_PCIC_TC_OF8E | TX3927_PCIC_TC_IF8E;
194
195 /* Enable Bus Arbiter */
196 if (!extarb)
197 tx3927_pcicptr->pbapmc = TX3927_PCIC_PBAPMC_PBAEN;
198
199 tx3927_pcicptr->pcicmd = PCI_COMMAND_MASTER |
200 PCI_COMMAND_MEMORY |
201 PCI_COMMAND_IO |
202 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
203 local_irq_restore(flags);
204}
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index 150419c8b41..c6b49bccd27 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -1,209 +1,408 @@
1/* 1/*
2 * Copyright 2001 MontaVista Software Inc. 2 * Define the pci_ops for the PCIC on Toshiba TX4927, TX4938, etc.
3 * Author: MontaVista Software, Inc.
4 * ahennessy@mvista.com
5 * 3 *
6 * Copyright (C) 2000-2001 Toshiba Corporation 4 * Based on linux/arch/mips/pci/ops-tx4938.c,
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 5 * linux/arch/mips/pci/fixup-rbtx4938.c,
8 * 6 * linux/arch/mips/txx9/rbtx4938/setup.c,
9 * Based on arch/mips/ddb5xxx/ddb5477/pci_ops.c 7 * and RBTX49xx patch from CELF patch archive.
10 *
11 * Define the pci_ops for the Toshiba rbtx4927
12 *
13 * Much of the code is derived from the original DDB5074 port by
14 * Geert Uytterhoeven <geert@sonycom.com>
15 *
16 * Copyright 2004 MontaVista Software Inc.
17 * Author: Manish Lachwani (mlachwani@mvista.com)
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2 of the License, or (at your
22 * option) any later version.
23 * 8 *
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 9 * 2003-2005 (c) MontaVista Software, Inc.
25 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 10 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 11 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
27 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * 12 *
35 * You should have received a copy of the GNU General Public License along 13 * This program is free software; you can redistribute it and/or modify it
36 * with this program; if not, write to the Free Software Foundation, Inc., 14 * under the terms of the GNU General Public License as published by the
37 * 675 Mass Ave, Cambridge, MA 02139, USA. 15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
38 */ 17 */
39#include <linux/types.h>
40#include <linux/pci.h>
41#include <linux/kernel.h> 18#include <linux/kernel.h>
42#include <linux/init.h> 19#include <asm/txx9/tx4927pcic.h>
43
44#include <asm/addrspace.h>
45#include <asm/byteorder.h>
46#include <asm/tx4927/tx4927_pci.h>
47
48/* initialize in setup */
49struct resource pci_io_resource = {
50 .name = "TX4927 PCI IO SPACE",
51 .start = 0x1000,
52 .end = (0x1000 + (TX4927_PCIIO_SIZE)) - 1,
53 .flags = IORESOURCE_IO
54};
55 20
56/* initialize in setup */ 21static struct {
57struct resource pci_mem_resource = { 22 struct pci_controller *channel;
58 .name = "TX4927 PCI MEM SPACE", 23 struct tx4927_pcic_reg __iomem *pcicptr;
59 .start = TX4927_PCIMEM, 24} pcicptrs[2]; /* TX4938 has 2 pcic */
60 .end = TX4927_PCIMEM + TX4927_PCIMEM_SIZE - 1, 25
61 .flags = IORESOURCE_MEM 26static void __init set_tx4927_pcicptr(struct pci_controller *channel,
62}; 27 struct tx4927_pcic_reg __iomem *pcicptr)
28{
29 int i;
30
31 for (i = 0; i < ARRAY_SIZE(pcicptrs); i++) {
32 if (pcicptrs[i].channel == channel) {
33 pcicptrs[i].pcicptr = pcicptr;
34 return;
35 }
36 }
37 for (i = 0; i < ARRAY_SIZE(pcicptrs); i++) {
38 if (!pcicptrs[i].channel) {
39 pcicptrs[i].channel = channel;
40 pcicptrs[i].pcicptr = pcicptr;
41 return;
42 }
43 }
44 BUG();
45}
63 46
64static int mkaddr(int bus, int dev_fn, int where, int *flagsp) 47struct tx4927_pcic_reg __iomem *get_tx4927_pcicptr(
48 struct pci_controller *channel)
65{ 49{
66 if (bus > 0) { 50 int i;
67 /* Type 1 configuration */
68 tx4927_pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) |
69 ((dev_fn & 0xff) << 0x08) | (where & 0xfc) | 1;
70 } else {
71 if (dev_fn >= PCI_DEVFN(TX4927_PCIC_MAX_DEVNU, 0))
72 return -1;
73 51
74 /* Type 0 configuration */ 52 for (i = 0; i < ARRAY_SIZE(pcicptrs); i++) {
75 tx4927_pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) | 53 if (pcicptrs[i].channel == channel)
76 ((dev_fn & 0xff) << 0x08) | (where & 0xfc); 54 return pcicptrs[i].pcicptr;
77 } 55 }
56 return NULL;
57}
58
59static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where,
60 struct tx4927_pcic_reg __iomem *pcicptr)
61{
62 if (bus->parent == NULL &&
63 devfn >= PCI_DEVFN(TX4927_PCIC_MAX_DEVNU, 0))
64 return -1;
65 __raw_writel(((bus->number & 0xff) << 0x10)
66 | ((devfn & 0xff) << 0x08) | (where & 0xfc)
67 | (bus->parent ? 1 : 0),
68 &pcicptr->g2pcfgadrs);
78 /* clear M_ABORT and Disable M_ABORT Int. */ 69 /* clear M_ABORT and Disable M_ABORT Int. */
79 tx4927_pcicptr->pcistatus = 70 __raw_writel((__raw_readl(&pcicptr->pcistatus) & 0x0000ffff)
80 (tx4927_pcicptr->pcistatus & 0x0000ffff) | 71 | (PCI_STATUS_REC_MASTER_ABORT << 16),
81 (PCI_STATUS_REC_MASTER_ABORT << 16); 72 &pcicptr->pcistatus);
82 tx4927_pcicptr->pcimask &= ~PCI_STATUS_REC_MASTER_ABORT;
83 return 0; 73 return 0;
84} 74}
85 75
86static int check_abort(int flags) 76static int check_abort(struct tx4927_pcic_reg __iomem *pcicptr)
87{ 77{
88 int code = PCIBIOS_SUCCESSFUL; 78 int code = PCIBIOS_SUCCESSFUL;
89 if (tx4927_pcicptr-> 79
90 pcistatus & (PCI_STATUS_REC_MASTER_ABORT << 16)) { 80 /* wait write cycle completion before checking error status */
91 tx4927_pcicptr->pcistatus = 81 while (__raw_readl(&pcicptr->pcicstatus) & TX4927_PCIC_PCICSTATUS_IWB)
92 (tx4927_pcicptr-> 82 ;
93 pcistatus & 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT 83 if (__raw_readl(&pcicptr->pcistatus)
94 << 16); 84 & (PCI_STATUS_REC_MASTER_ABORT << 16)) {
95 tx4927_pcicptr->pcimask |= PCI_STATUS_REC_MASTER_ABORT; 85 __raw_writel((__raw_readl(&pcicptr->pcistatus) & 0x0000ffff)
86 | (PCI_STATUS_REC_MASTER_ABORT << 16),
87 &pcicptr->pcistatus);
96 code = PCIBIOS_DEVICE_NOT_FOUND; 88 code = PCIBIOS_DEVICE_NOT_FOUND;
97 } 89 }
98 return code; 90 return code;
99} 91}
100 92
101static int tx4927_pcibios_read_config(struct pci_bus *bus, unsigned int devfn, int where, 93static u8 icd_readb(int offset, struct tx4927_pcic_reg __iomem *pcicptr)
102 int size, u32 * val) 94{
95#ifdef __BIG_ENDIAN
96 offset ^= 3;
97#endif
98 return __raw_readb((void __iomem *)&pcicptr->g2pcfgdata + offset);
99}
100static u16 icd_readw(int offset, struct tx4927_pcic_reg __iomem *pcicptr)
101{
102#ifdef __BIG_ENDIAN
103 offset ^= 2;
104#endif
105 return __raw_readw((void __iomem *)&pcicptr->g2pcfgdata + offset);
106}
107static u32 icd_readl(struct tx4927_pcic_reg __iomem *pcicptr)
108{
109 return __raw_readl(&pcicptr->g2pcfgdata);
110}
111static void icd_writeb(u8 val, int offset,
112 struct tx4927_pcic_reg __iomem *pcicptr)
113{
114#ifdef __BIG_ENDIAN
115 offset ^= 3;
116#endif
117 __raw_writeb(val, (void __iomem *)&pcicptr->g2pcfgdata + offset);
118}
119static void icd_writew(u16 val, int offset,
120 struct tx4927_pcic_reg __iomem *pcicptr)
121{
122#ifdef __BIG_ENDIAN
123 offset ^= 2;
124#endif
125 __raw_writew(val, (void __iomem *)&pcicptr->g2pcfgdata + offset);
126}
127static void icd_writel(u32 val, struct tx4927_pcic_reg __iomem *pcicptr)
103{ 128{
104 int flags, retval, dev, busno, func; 129 __raw_writel(val, &pcicptr->g2pcfgdata);
130}
105 131
106 busno = bus->number; 132static struct tx4927_pcic_reg __iomem *pci_bus_to_pcicptr(struct pci_bus *bus)
107 dev = PCI_SLOT(devfn); 133{
108 func = PCI_FUNC(devfn); 134 struct pci_controller *channel = bus->sysdata;
135 return get_tx4927_pcicptr(channel);
136}
109 137
110 /* check if the bus is top-level */ 138static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn,
111 if (bus->parent != NULL) { 139 int where, int size, u32 *val)
112 busno = bus->number; 140{
113 } else { 141 struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus);
114 busno = 0;
115 }
116 142
117 if (mkaddr(busno, devfn, where, &flags)) 143 if (mkaddr(bus, devfn, where, pcicptr)) {
144 *val = 0xffffffff;
118 return -1; 145 return -1;
119 146 }
120 switch (size) { 147 switch (size) {
121 case 1: 148 case 1:
122 *val = *(volatile u8 *) ((unsigned long) & tx4927_pcicptr-> 149 *val = icd_readb(where & 3, pcicptr);
123 g2pcfgdata |
124#ifdef __LITTLE_ENDIAN
125 (where & 3));
126#else
127 ((where & 0x3) ^ 0x3));
128#endif
129 break; 150 break;
130 case 2: 151 case 2:
131 *val = *(volatile u16 *) ((unsigned long) & tx4927_pcicptr-> 152 *val = icd_readw(where & 3, pcicptr);
132 g2pcfgdata |
133#ifdef __LITTLE_ENDIAN
134 (where & 3));
135#else
136 ((where & 0x3) ^ 0x2));
137#endif
138 break;
139 case 4:
140 *val = tx4927_pcicptr->g2pcfgdata;
141 break; 153 break;
154 default:
155 *val = icd_readl(pcicptr);
142 } 156 }
157 return check_abort(pcicptr);
158}
143 159
144 retval = check_abort(flags); 160static int tx4927_pci_config_write(struct pci_bus *bus, unsigned int devfn,
145 if (retval == PCIBIOS_DEVICE_NOT_FOUND) 161 int where, int size, u32 val)
146 *val = 0xffffffff; 162{
163 struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus);
147 164
148 return retval; 165 if (mkaddr(bus, devfn, where, pcicptr))
166 return -1;
167 switch (size) {
168 case 1:
169 icd_writeb(val, where & 3, pcicptr);
170 break;
171 case 2:
172 icd_writew(val, where & 3, pcicptr);
173 break;
174 default:
175 icd_writel(val, pcicptr);
176 }
177 return check_abort(pcicptr);
149} 178}
150 179
151static int tx4927_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where, 180static struct pci_ops tx4927_pci_ops = {
152 int size, u32 val) 181 .read = tx4927_pci_config_read,
182 .write = tx4927_pci_config_write,
183};
184
185static struct {
186 u8 trdyto;
187 u8 retryto;
188 u16 gbwc;
189} tx4927_pci_opts __devinitdata = {
190 .trdyto = 0,
191 .retryto = 0,
192 .gbwc = 0xfe0, /* 4064 GBUSCLK for CCFG.GTOT=0b11 */
193};
194
195void __init tx4927_pcic_setup(struct tx4927_pcic_reg __iomem *pcicptr,
196 struct pci_controller *channel, int extarb)
153{ 197{
154 int flags, dev, busno, func; 198 int i;
155 busno = bus->number; 199 unsigned long flags;
156 dev = PCI_SLOT(devfn);
157 func = PCI_FUNC(devfn);
158 200
159 /* check if the bus is top-level */ 201 set_tx4927_pcicptr(channel, pcicptr);
160 if (bus->parent != NULL) {
161 busno = bus->number;
162 } else {
163 busno = 0;
164 }
165 202
166 if (mkaddr(busno, devfn, where, &flags)) 203 if (!channel->pci_ops)
167 return -1; 204 printk(KERN_INFO
205 "PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
206 __raw_readl(&pcicptr->pciid) >> 16,
207 __raw_readl(&pcicptr->pciid) & 0xffff,
208 __raw_readl(&pcicptr->pciccrev) & 0xff,
209 extarb ? "External" : "Internal");
210 channel->pci_ops = &tx4927_pci_ops;
168 211
169 switch (size) { 212 local_irq_save(flags);
170 case 1: 213
171 *(volatile u8 *) ((unsigned long) & tx4927_pcicptr-> 214 /* Disable All Initiator Space */
172 g2pcfgdata | 215 __raw_writel(__raw_readl(&pcicptr->pciccfg)
173#ifdef __LITTLE_ENDIAN 216 & ~(TX4927_PCIC_PCICCFG_G2PMEN(0)
174 (where & 3)) = val; 217 | TX4927_PCIC_PCICCFG_G2PMEN(1)
218 | TX4927_PCIC_PCICCFG_G2PMEN(2)
219 | TX4927_PCIC_PCICCFG_G2PIOEN),
220 &pcicptr->pciccfg);
221
222 /* GB->PCI mappings */
223 __raw_writel((channel->io_resource->end - channel->io_resource->start)
224 >> 4,
225 &pcicptr->g2piomask);
226 ____raw_writeq((channel->io_resource->start +
227 channel->io_map_base - IO_BASE) |
228#ifdef __BIG_ENDIAN
229 TX4927_PCIC_G2PIOGBASE_ECHG
175#else 230#else
176 ((where & 0x3) ^ 0x3)) = val; 231 TX4927_PCIC_G2PIOGBASE_BSDIS
177#endif 232#endif
178 break; 233 , &pcicptr->g2piogbase);
179 234 ____raw_writeq(channel->io_resource->start - channel->io_offset,
180 case 2: 235 &pcicptr->g2piopbase);
181 *(volatile u16 *) ((unsigned long) & tx4927_pcicptr-> 236 for (i = 0; i < 3; i++) {
182 g2pcfgdata | 237 __raw_writel(0, &pcicptr->g2pmmask[i]);
183#ifdef __LITTLE_ENDIAN 238 ____raw_writeq(0, &pcicptr->g2pmgbase[i]);
184 (where & 3)) = val; 239 ____raw_writeq(0, &pcicptr->g2pmpbase[i]);
240 }
241 if (channel->mem_resource->end) {
242 __raw_writel((channel->mem_resource->end
243 - channel->mem_resource->start) >> 4,
244 &pcicptr->g2pmmask[0]);
245 ____raw_writeq(channel->mem_resource->start |
246#ifdef __BIG_ENDIAN
247 TX4927_PCIC_G2PMnGBASE_ECHG
185#else 248#else
186 ((where & 0x3) ^ 0x2)) = val; 249 TX4927_PCIC_G2PMnGBASE_BSDIS
187#endif 250#endif
188 break; 251 , &pcicptr->g2pmgbase[0]);
189 case 4: 252 ____raw_writeq(channel->mem_resource->start -
190 tx4927_pcicptr->g2pcfgdata = val; 253 channel->mem_offset,
191 break; 254 &pcicptr->g2pmpbase[0]);
255 }
256 /* PCI->GB mappings (I/O 256B) */
257 __raw_writel(0, &pcicptr->p2giopbase); /* 256B */
258 ____raw_writeq(0, &pcicptr->p2giogbase);
259 /* PCI->GB mappings (MEM 512MB (64MB on R1.x)) */
260 __raw_writel(0, &pcicptr->p2gm0plbase);
261 __raw_writel(0, &pcicptr->p2gm0pubase);
262 ____raw_writeq(TX4927_PCIC_P2GMnGBASE_TMEMEN |
263#ifdef __BIG_ENDIAN
264 TX4927_PCIC_P2GMnGBASE_TECHG
265#else
266 TX4927_PCIC_P2GMnGBASE_TBSDIS
267#endif
268 , &pcicptr->p2gmgbase[0]);
269 /* PCI->GB mappings (MEM 16MB) */
270 __raw_writel(0xffffffff, &pcicptr->p2gm1plbase);
271 __raw_writel(0xffffffff, &pcicptr->p2gm1pubase);
272 ____raw_writeq(0, &pcicptr->p2gmgbase[1]);
273 /* PCI->GB mappings (MEM 1MB) */
274 __raw_writel(0xffffffff, &pcicptr->p2gm2pbase); /* 1MB */
275 ____raw_writeq(0, &pcicptr->p2gmgbase[2]);
276
277 /* Clear all (including IRBER) except for GBWC */
278 __raw_writel((tx4927_pci_opts.gbwc << 16)
279 & TX4927_PCIC_PCICCFG_GBWC_MASK,
280 &pcicptr->pciccfg);
281 /* Enable Initiator Memory Space */
282 if (channel->mem_resource->end)
283 __raw_writel(__raw_readl(&pcicptr->pciccfg)
284 | TX4927_PCIC_PCICCFG_G2PMEN(0),
285 &pcicptr->pciccfg);
286 /* Enable Initiator I/O Space */
287 if (channel->io_resource->end)
288 __raw_writel(__raw_readl(&pcicptr->pciccfg)
289 | TX4927_PCIC_PCICCFG_G2PIOEN,
290 &pcicptr->pciccfg);
291 /* Enable Initiator Config */
292 __raw_writel(__raw_readl(&pcicptr->pciccfg)
293 | TX4927_PCIC_PCICCFG_ICAEN | TX4927_PCIC_PCICCFG_TCAR,
294 &pcicptr->pciccfg);
295
296 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
297 __raw_writel(0, &pcicptr->pcicfg1);
298
299 __raw_writel((__raw_readl(&pcicptr->g2ptocnt) & ~0xffff)
300 | (tx4927_pci_opts.trdyto & 0xff)
301 | ((tx4927_pci_opts.retryto & 0xff) << 8),
302 &pcicptr->g2ptocnt);
303
304 /* Clear All Local Bus Status */
305 __raw_writel(TX4927_PCIC_PCICSTATUS_ALL, &pcicptr->pcicstatus);
306 /* Enable All Local Bus Interrupts */
307 __raw_writel(TX4927_PCIC_PCICSTATUS_ALL, &pcicptr->pcicmask);
308 /* Clear All Initiator Status */
309 __raw_writel(TX4927_PCIC_G2PSTATUS_ALL, &pcicptr->g2pstatus);
310 /* Enable All Initiator Interrupts */
311 __raw_writel(TX4927_PCIC_G2PSTATUS_ALL, &pcicptr->g2pmask);
312 /* Clear All PCI Status Error */
313 __raw_writel((__raw_readl(&pcicptr->pcistatus) & 0x0000ffff)
314 | (TX4927_PCIC_PCISTATUS_ALL << 16),
315 &pcicptr->pcistatus);
316 /* Enable All PCI Status Error Interrupts */
317 __raw_writel(TX4927_PCIC_PCISTATUS_ALL, &pcicptr->pcimask);
318
319 if (!extarb) {
320 /* Reset Bus Arbiter */
321 __raw_writel(TX4927_PCIC_PBACFG_RPBA, &pcicptr->pbacfg);
322 __raw_writel(0, &pcicptr->pbabm);
323 /* Enable Bus Arbiter */
324 __raw_writel(TX4927_PCIC_PBACFG_PBAEN, &pcicptr->pbacfg);
192 } 325 }
193 326
194 return check_abort(flags); 327 __raw_writel(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
328 | PCI_COMMAND_PARITY | PCI_COMMAND_SERR,
329 &pcicptr->pcistatus);
330 local_irq_restore(flags);
331
332 printk(KERN_DEBUG
333 "PCI: COMMAND=%04x,PCIMASK=%04x,"
334 "TRDYTO=%02x,RETRYTO=%02x,GBWC=%03x\n",
335 __raw_readl(&pcicptr->pcistatus) & 0xffff,
336 __raw_readl(&pcicptr->pcimask) & 0xffff,
337 __raw_readl(&pcicptr->g2ptocnt) & 0xff,
338 (__raw_readl(&pcicptr->g2ptocnt) & 0xff00) >> 8,
339 (__raw_readl(&pcicptr->pciccfg) >> 16) & 0xfff);
195} 340}
196 341
197struct pci_ops tx4927_pci_ops = { 342static void tx4927_report_pcic_status1(struct tx4927_pcic_reg __iomem *pcicptr)
198 tx4927_pcibios_read_config, 343{
199 tx4927_pcibios_write_config 344 __u16 pcistatus = (__u16)(__raw_readl(&pcicptr->pcistatus) >> 16);
200}; 345 __u32 g2pstatus = __raw_readl(&pcicptr->g2pstatus);
346 __u32 pcicstatus = __raw_readl(&pcicptr->pcicstatus);
347 static struct {
348 __u32 flag;
349 const char *str;
350 } pcistat_tbl[] = {
351 { PCI_STATUS_DETECTED_PARITY, "DetectedParityError" },
352 { PCI_STATUS_SIG_SYSTEM_ERROR, "SignaledSystemError" },
353 { PCI_STATUS_REC_MASTER_ABORT, "ReceivedMasterAbort" },
354 { PCI_STATUS_REC_TARGET_ABORT, "ReceivedTargetAbort" },
355 { PCI_STATUS_SIG_TARGET_ABORT, "SignaledTargetAbort" },
356 { PCI_STATUS_PARITY, "MasterParityError" },
357 }, g2pstat_tbl[] = {
358 { TX4927_PCIC_G2PSTATUS_TTOE, "TIOE" },
359 { TX4927_PCIC_G2PSTATUS_RTOE, "RTOE" },
360 }, pcicstat_tbl[] = {
361 { TX4927_PCIC_PCICSTATUS_PME, "PME" },
362 { TX4927_PCIC_PCICSTATUS_TLB, "TLB" },
363 { TX4927_PCIC_PCICSTATUS_NIB, "NIB" },
364 { TX4927_PCIC_PCICSTATUS_ZIB, "ZIB" },
365 { TX4927_PCIC_PCICSTATUS_PERR, "PERR" },
366 { TX4927_PCIC_PCICSTATUS_SERR, "SERR" },
367 { TX4927_PCIC_PCICSTATUS_GBE, "GBE" },
368 { TX4927_PCIC_PCICSTATUS_IWB, "IWB" },
369 };
370 int i, cont;
201 371
202/* 372 printk(KERN_ERR "");
203 * h/w only supports devices 0x00 to 0x14 373 if (pcistatus & TX4927_PCIC_PCISTATUS_ALL) {
204 */ 374 printk(KERN_CONT "pcistat:%04x(", pcistatus);
205struct pci_controller tx4927_controller = { 375 for (i = 0, cont = 0; i < ARRAY_SIZE(pcistat_tbl); i++)
206 .pci_ops = &tx4927_pci_ops, 376 if (pcistatus & pcistat_tbl[i].flag)
207 .io_resource = &pci_io_resource, 377 printk(KERN_CONT "%s%s",
208 .mem_resource = &pci_mem_resource, 378 cont++ ? " " : "", pcistat_tbl[i].str);
209}; 379 printk(KERN_CONT ") ");
380 }
381 if (g2pstatus & TX4927_PCIC_G2PSTATUS_ALL) {
382 printk(KERN_CONT "g2pstatus:%08x(", g2pstatus);
383 for (i = 0, cont = 0; i < ARRAY_SIZE(g2pstat_tbl); i++)
384 if (g2pstatus & g2pstat_tbl[i].flag)
385 printk(KERN_CONT "%s%s",
386 cont++ ? " " : "", g2pstat_tbl[i].str);
387 printk(KERN_CONT ") ");
388 }
389 if (pcicstatus & TX4927_PCIC_PCICSTATUS_ALL) {
390 printk(KERN_CONT "pcicstatus:%08x(", pcicstatus);
391 for (i = 0, cont = 0; i < ARRAY_SIZE(pcicstat_tbl); i++)
392 if (pcicstatus & pcicstat_tbl[i].flag)
393 printk(KERN_CONT "%s%s",
394 cont++ ? " " : "", pcicstat_tbl[i].str);
395 printk(KERN_CONT ")");
396 }
397 printk(KERN_CONT "\n");
398}
399
400void tx4927_report_pcic_status(void)
401{
402 int i;
403
404 for (i = 0; i < ARRAY_SIZE(pcicptrs); i++) {
405 if (pcicptrs[i].pcicptr)
406 tx4927_report_pcic_status1(pcicptrs[i].pcicptr);
407 }
408}
diff --git a/arch/mips/pci/ops-tx4938.c b/arch/mips/pci/ops-tx4938.c
deleted file mode 100644
index a450c406203..00000000000
--- a/arch/mips/pci/ops-tx4938.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/*
2 * Define the pci_ops for the Toshiba rbtx4938
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12#include <linux/types.h>
13#include <linux/pci.h>
14#include <linux/kernel.h>
15#include <linux/init.h>
16
17#include <asm/addrspace.h>
18#include <asm/tx4938/rbtx4938.h>
19
20/* initialize in setup */
21struct resource pci_io_resource = {
22 .name = "pci IO space",
23 .start = 0,
24 .end = 0,
25 .flags = IORESOURCE_IO
26};
27
28/* initialize in setup */
29struct resource pci_mem_resource = {
30 .name = "pci memory space",
31 .start = 0,
32 .end = 0,
33 .flags = IORESOURCE_MEM
34};
35
36struct resource tx4938_pcic1_pci_io_resource = {
37 .name = "PCI1 IO",
38 .start = 0,
39 .end = 0,
40 .flags = IORESOURCE_IO
41};
42struct resource tx4938_pcic1_pci_mem_resource = {
43 .name = "PCI1 mem",
44 .start = 0,
45 .end = 0,
46 .flags = IORESOURCE_MEM
47};
48
49static int mkaddr(int bus, int dev_fn, int where,
50 struct tx4938_pcic_reg *pcicptr)
51{
52 if (bus > 0) {
53 /* Type 1 configuration */
54 pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) |
55 ((dev_fn & 0xff) << 0x08) | (where & 0xfc) | 1;
56 } else {
57 if (dev_fn >= PCI_DEVFN(TX4938_PCIC_MAX_DEVNU, 0))
58 return -1;
59
60 /* Type 0 configuration */
61 pcicptr->g2pcfgadrs = ((bus & 0xff) << 0x10) |
62 ((dev_fn & 0xff) << 0x08) | (where & 0xfc);
63 }
64 /* clear M_ABORT and Disable M_ABORT Int. */
65 pcicptr->pcistatus =
66 (pcicptr->pcistatus & 0x0000ffff) |
67 (PCI_STATUS_REC_MASTER_ABORT << 16);
68 pcicptr->pcimask &= ~PCI_STATUS_REC_MASTER_ABORT;
69
70 return 0;
71}
72
73static int check_abort(struct tx4938_pcic_reg *pcicptr)
74{
75 int code = PCIBIOS_SUCCESSFUL;
76 /* wait write cycle completion before checking error status */
77 while (pcicptr->pcicstatus & TX4938_PCIC_PCICSTATUS_IWB)
78 ;
79 if (pcicptr->pcistatus & (PCI_STATUS_REC_MASTER_ABORT << 16)) {
80 pcicptr->pcistatus =
81 (pcicptr->
82 pcistatus & 0x0000ffff) | (PCI_STATUS_REC_MASTER_ABORT
83 << 16);
84 pcicptr->pcimask |= PCI_STATUS_REC_MASTER_ABORT;
85 code = PCIBIOS_DEVICE_NOT_FOUND;
86 }
87 return code;
88}
89
90extern struct pci_controller tx4938_pci_controller[];
91extern struct tx4938_pcic_reg *get_tx4938_pcicptr(int ch);
92
93static struct tx4938_pcic_reg *pci_bus_to_pcicptr(struct pci_bus *bus)
94{
95 struct pci_controller *channel = bus->sysdata;
96 return get_tx4938_pcicptr(channel - &tx4938_pci_controller[0]);
97}
98
99static int tx4938_pcibios_read_config(struct pci_bus *bus, unsigned int devfn,
100 int where, int size, u32 * val)
101{
102 int retval, dev, busno, func;
103 struct tx4938_pcic_reg *pcicptr = pci_bus_to_pcicptr(bus);
104 void __iomem *cfgdata =
105 (void __iomem *)(unsigned long)&pcicptr->g2pcfgdata;
106
107 dev = PCI_SLOT(devfn);
108 func = PCI_FUNC(devfn);
109
110 /* check if the bus is top-level */
111 if (bus->parent != NULL)
112 busno = bus->number;
113 else {
114 busno = 0;
115 }
116
117 if (mkaddr(busno, devfn, where, pcicptr))
118 return -1;
119
120 switch (size) {
121 case 1:
122#ifdef __BIG_ENDIAN
123 cfgdata += (where & 3) ^ 3;
124#else
125 cfgdata += where & 3;
126#endif
127 *val = __raw_readb(cfgdata);
128 break;
129 case 2:
130#ifdef __BIG_ENDIAN
131 cfgdata += (where & 2) ^ 2;
132#else
133 cfgdata += where & 2;
134#endif
135 *val = __raw_readw(cfgdata);
136 break;
137 case 4:
138 *val = __raw_readl(cfgdata);
139 break;
140 }
141
142 retval = check_abort(pcicptr);
143 if (retval == PCIBIOS_DEVICE_NOT_FOUND)
144 *val = 0xffffffff;
145
146 return retval;
147}
148
149static int tx4938_pcibios_write_config(struct pci_bus *bus, unsigned int devfn, int where,
150 int size, u32 val)
151{
152 int dev, busno, func;
153 struct tx4938_pcic_reg *pcicptr = pci_bus_to_pcicptr(bus);
154 void __iomem *cfgdata =
155 (void __iomem *)(unsigned long)&pcicptr->g2pcfgdata;
156
157 busno = bus->number;
158 dev = PCI_SLOT(devfn);
159 func = PCI_FUNC(devfn);
160
161 /* check if the bus is top-level */
162 if (bus->parent != NULL) {
163 busno = bus->number;
164 } else {
165 busno = 0;
166 }
167
168 if (mkaddr(busno, devfn, where, pcicptr))
169 return -1;
170
171 switch (size) {
172 case 1:
173#ifdef __BIG_ENDIAN
174 cfgdata += (where & 3) ^ 3;
175#else
176 cfgdata += where & 3;
177#endif
178 __raw_writeb(val, cfgdata);
179 break;
180 case 2:
181#ifdef __BIG_ENDIAN
182 cfgdata += (where & 2) ^ 2;
183#else
184 cfgdata += where & 2;
185#endif
186 __raw_writew(val, cfgdata);
187 break;
188 case 4:
189 __raw_writel(val, cfgdata);
190 break;
191 }
192
193 return check_abort(pcicptr);
194}
195
196struct pci_ops tx4938_pci_ops = {
197 tx4938_pcibios_read_config,
198 tx4938_pcibios_write_config
199};
200
201struct pci_controller tx4938_pci_controller[] = {
202 /* h/w only supports devices 0x00 to 0x14 */
203 {
204 .pci_ops = &tx4938_pci_ops,
205 .io_resource = &pci_io_resource,
206 .mem_resource = &pci_mem_resource,
207 },
208 /* h/w only supports devices 0x00 to 0x14 */
209 {
210 .pci_ops = &tx4938_pci_ops,
211 .io_resource = &tx4938_pcic1_pci_io_resource,
212 .mem_resource = &tx4938_pcic1_pci_mem_resource,
213 }
214};
diff --git a/arch/mips/pci/pci-bcm1480.c b/arch/mips/pci/pci-bcm1480.c
index 87e2c8f54e2..a9060c77184 100644
--- a/arch/mips/pci/pci-bcm1480.c
+++ b/arch/mips/pci/pci-bcm1480.c
@@ -202,7 +202,6 @@ static int __init bcm1480_pcibios_init(void)
202{ 202{
203 uint32_t cmdreg; 203 uint32_t cmdreg;
204 uint64_t reg; 204 uint64_t reg;
205 extern int pci_probe_only;
206 205
207 /* CFE will assign PCI resources */ 206 /* CFE will assign PCI resources */
208 pci_probe_only = 1; 207 pci_probe_only = 1;
@@ -254,8 +253,6 @@ static int __init bcm1480_pcibios_init(void)
254 ioremap(A_BCM1480_PHYS_PCI_IO_MATCH_BYTES, 65536); 253 ioremap(A_BCM1480_PHYS_PCI_IO_MATCH_BYTES, 65536);
255 bcm1480_controller.io_map_base -= bcm1480_controller.io_offset; 254 bcm1480_controller.io_map_base -= bcm1480_controller.io_offset;
256 set_io_port_base(bcm1480_controller.io_map_base); 255 set_io_port_base(bcm1480_controller.io_map_base);
257 isa_slot_offset = (unsigned long)
258 ioremap(A_BCM1480_PHYS_PCI_MEM_MATCH_BYTES, 1024*1024);
259 256
260 register_pci_controller(&bcm1480_controller); 257 register_pci_controller(&bcm1480_controller);
261 258
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index a18516925cd..ce92f82b16d 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -47,7 +47,6 @@ int __cpuinit bridge_probe(nasid_t nasid, int widget_id, int masterwid)
47 static int num_bridges = 0; 47 static int num_bridges = 0;
48 bridge_t *bridge; 48 bridge_t *bridge;
49 int slot; 49 int slot;
50 extern int pci_probe_only;
51 50
52 pci_probe_only = 1; 51 pci_probe_only = 1;
53 52
diff --git a/arch/mips/pci/pci-jmr3927.c b/arch/mips/pci/pci-jmr3927.c
deleted file mode 100644
index cb84f4e8cca..00000000000
--- a/arch/mips/pci/pci-jmr3927.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * Copyright 2001 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ahennessy@mvista.com
5 *
6 * Copyright (C) 2000-2001 Toshiba Corporation
7 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
20 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29#include <linux/types.h>
30#include <linux/pci.h>
31#include <linux/kernel.h>
32#include <linux/init.h>
33
34#include <asm/jmr3927/jmr3927.h>
35#include <asm/debug.h>
36
37struct resource pci_io_resource = {
38 .name = "IO MEM",
39 .start = 0x1000, /* reserve regacy I/O space */
40 .end = 0x1000 + JMR3927_PCIIO_SIZE - 1,
41 .flags = IORESOURCE_IO
42};
43
44struct resource pci_mem_resource = {
45 .name = "PCI MEM",
46 .start = JMR3927_PCIMEM,
47 .end = JMR3927_PCIMEM + JMR3927_PCIMEM_SIZE - 1,
48 .flags = IORESOURCE_MEM
49};
50
51extern struct pci_ops jmr3927_pci_ops;
52
53struct pci_controller jmr3927_controller = {
54 .pci_ops = &jmr3927_pci_ops,
55 .io_resource = &pci_io_resource,
56 .mem_resource = &pci_mem_resource,
57 .mem_offset = JMR3927_PCIMEM
58};
diff --git a/arch/mips/pci/pci-lasat.c b/arch/mips/pci/pci-lasat.c
index e70ae3236e0..a98e543a514 100644
--- a/arch/mips/pci/pci-lasat.c
+++ b/arch/mips/pci/pci-lasat.c
@@ -10,7 +10,7 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13#include <asm/bootinfo.h> 13#include <asm/lasat/lasat.h>
14 14
15#include <irq.h> 15#include <irq.h>
16 16
@@ -39,16 +39,10 @@ static int __init lasat_pci_setup(void)
39{ 39{
40 printk(KERN_DEBUG "PCI: starting\n"); 40 printk(KERN_DEBUG "PCI: starting\n");
41 41
42 switch (mips_machtype) { 42 if (IS_LASAT_200())
43 case MACH_LASAT_100:
44 lasat_pci_controller.pci_ops = &gt64xxx_pci0_ops;
45 break;
46 case MACH_LASAT_200:
47 lasat_pci_controller.pci_ops = &nile4_pci_ops; 43 lasat_pci_controller.pci_ops = &nile4_pci_ops;
48 break; 44 else
49 default: 45 lasat_pci_controller.pci_ops = &gt64xxx_pci0_ops;
50 panic("pcibios_init: mips_machtype incorrect");
51 }
52 46
53 register_pci_controller(&lasat_pci_controller); 47 register_pci_controller(&lasat_pci_controller);
54 48
diff --git a/arch/mips/pci/pci-sb1250.c b/arch/mips/pci/pci-sb1250.c
index 2a09ad91ec8..bf639590b8b 100644
--- a/arch/mips/pci/pci-sb1250.c
+++ b/arch/mips/pci/pci-sb1250.c
@@ -210,7 +210,6 @@ static int __init sb1250_pcibios_init(void)
210 void __iomem *io_map_base; 210 void __iomem *io_map_base;
211 uint32_t cmdreg; 211 uint32_t cmdreg;
212 uint64_t reg; 212 uint64_t reg;
213 extern int pci_probe_only;
214 213
215 /* CFE will assign PCI resources */ 214 /* CFE will assign PCI resources */
216 pci_probe_only = 1; 215 pci_probe_only = 1;
@@ -254,9 +253,6 @@ static int __init sb1250_pcibios_init(void)
254 * works correctly with most of Linux's drivers. 253 * works correctly with most of Linux's drivers.
255 * XXX ehs: Should this happen in PCI Device mode? 254 * XXX ehs: Should this happen in PCI Device mode?
256 */ 255 */
257 isa_slot_offset = (unsigned long)
258 ioremap(A_PHYS_LDTPCI_IO_MATCH_BYTES_32, 1024 * 1024);
259
260 io_map_base = ioremap(A_PHYS_LDTPCI_IO_MATCH_BYTES, 1024 * 1024); 256 io_map_base = ioremap(A_PHYS_LDTPCI_IO_MATCH_BYTES, 1024 * 1024);
261 sb1250_controller.io_map_base = io_map_base; 257 sb1250_controller.io_map_base = io_map_base;
262 set_io_port_base((unsigned long)io_map_base); 258 set_io_port_base((unsigned long)io_map_base);
diff --git a/arch/mips/pci/pci-tx4927.c b/arch/mips/pci/pci-tx4927.c
new file mode 100644
index 00000000000..27e86a09dd4
--- /dev/null
+++ b/arch/mips/pci/pci-tx4927.c
@@ -0,0 +1,83 @@
1/*
2 * linux/arch/mips/pci/pci-tx4927.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * Copyright 2001, 2003-2005 MontaVista Software Inc.
8 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
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/pci.h>
17#include <linux/kernel.h>
18#include <asm/txx9/generic.h>
19#include <asm/txx9/tx4927.h>
20
21int __init tx4927_report_pciclk(void)
22{
23 int pciclk = 0;
24
25 printk(KERN_INFO "PCIC --%s PCICLK:",
26 (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66) ?
27 " PCI66" : "");
28 if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
29 u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
30 switch ((unsigned long)ccfg &
31 TX4927_CCFG_PCIDIVMODE_MASK) {
32 case TX4927_CCFG_PCIDIVMODE_2_5:
33 pciclk = txx9_cpu_clock * 2 / 5; break;
34 case TX4927_CCFG_PCIDIVMODE_3:
35 pciclk = txx9_cpu_clock / 3; break;
36 case TX4927_CCFG_PCIDIVMODE_5:
37 pciclk = txx9_cpu_clock / 5; break;
38 case TX4927_CCFG_PCIDIVMODE_6:
39 pciclk = txx9_cpu_clock / 6; break;
40 }
41 printk("Internal(%u.%uMHz)",
42 (pciclk + 50000) / 1000000,
43 ((pciclk + 50000) / 100000) % 10);
44 } else {
45 printk("External");
46 pciclk = -1;
47 }
48 printk("\n");
49 return pciclk;
50}
51
52int __init tx4927_pciclk66_setup(void)
53{
54 int pciclk;
55
56 /* Assert M66EN */
57 tx4927_ccfg_set(TX4927_CCFG_PCI66);
58 /* Double PCICLK (if possible) */
59 if (__raw_readq(&tx4927_ccfgptr->pcfg) & TX4927_PCFG_PCICLKEN_ALL) {
60 unsigned int pcidivmode = 0;
61 u64 ccfg = __raw_readq(&tx4927_ccfgptr->ccfg);
62 pcidivmode = (unsigned long)ccfg &
63 TX4927_CCFG_PCIDIVMODE_MASK;
64 switch (pcidivmode) {
65 case TX4927_CCFG_PCIDIVMODE_5:
66 case TX4927_CCFG_PCIDIVMODE_2_5:
67 pcidivmode = TX4927_CCFG_PCIDIVMODE_2_5;
68 pciclk = txx9_cpu_clock * 2 / 5;
69 break;
70 case TX4927_CCFG_PCIDIVMODE_6:
71 case TX4927_CCFG_PCIDIVMODE_3:
72 default:
73 pcidivmode = TX4927_CCFG_PCIDIVMODE_3;
74 pciclk = txx9_cpu_clock / 3;
75 }
76 tx4927_ccfg_change(TX4927_CCFG_PCIDIVMODE_MASK,
77 pcidivmode);
78 printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
79 (unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg));
80 } else
81 pciclk = -1;
82 return pciclk;
83}
diff --git a/arch/mips/pci/pci-tx4938.c b/arch/mips/pci/pci-tx4938.c
new file mode 100644
index 00000000000..e5375511c2b
--- /dev/null
+++ b/arch/mips/pci/pci-tx4938.c
@@ -0,0 +1,134 @@
1/*
2 * linux/arch/mips/pci/pci-tx4938.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * Copyright 2001, 2003-2005 MontaVista Software Inc.
8 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
9 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
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/pci.h>
17#include <linux/kernel.h>
18#include <asm/txx9/generic.h>
19#include <asm/txx9/tx4938.h>
20
21int __init tx4938_report_pciclk(void)
22{
23 int pciclk = 0;
24
25 printk(KERN_INFO "PCIC --%s PCICLK:",
26 (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66) ?
27 " PCI66" : "");
28 if (__raw_readq(&tx4938_ccfgptr->pcfg) & TX4938_PCFG_PCICLKEN_ALL) {
29 u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
30 switch ((unsigned long)ccfg &
31 TX4938_CCFG_PCIDIVMODE_MASK) {
32 case TX4938_CCFG_PCIDIVMODE_4:
33 pciclk = txx9_cpu_clock / 4; break;
34 case TX4938_CCFG_PCIDIVMODE_4_5:
35 pciclk = txx9_cpu_clock * 2 / 9; break;
36 case TX4938_CCFG_PCIDIVMODE_5:
37 pciclk = txx9_cpu_clock / 5; break;
38 case TX4938_CCFG_PCIDIVMODE_5_5:
39 pciclk = txx9_cpu_clock * 2 / 11; break;
40 case TX4938_CCFG_PCIDIVMODE_8:
41 pciclk = txx9_cpu_clock / 8; break;
42 case TX4938_CCFG_PCIDIVMODE_9:
43 pciclk = txx9_cpu_clock / 9; break;
44 case TX4938_CCFG_PCIDIVMODE_10:
45 pciclk = txx9_cpu_clock / 10; break;
46 case TX4938_CCFG_PCIDIVMODE_11:
47 pciclk = txx9_cpu_clock / 11; break;
48 }
49 printk("Internal(%u.%uMHz)",
50 (pciclk + 50000) / 1000000,
51 ((pciclk + 50000) / 100000) % 10);
52 } else {
53 printk("External");
54 pciclk = -1;
55 }
56 printk("\n");
57 return pciclk;
58}
59
60void __init tx4938_report_pci1clk(void)
61{
62 __u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
63 unsigned int pciclk =
64 txx9_gbus_clock / ((ccfg & TX4938_CCFG_PCI1DMD) ? 4 : 2);
65
66 printk(KERN_INFO "PCIC1 -- %sPCICLK:%u.%uMHz\n",
67 (ccfg & TX4938_CCFG_PCI1_66) ? "PCI66 " : "",
68 (pciclk + 50000) / 1000000,
69 ((pciclk + 50000) / 100000) % 10);
70}
71
72int __init tx4938_pciclk66_setup(void)
73{
74 int pciclk;
75
76 /* Assert M66EN */
77 tx4938_ccfg_set(TX4938_CCFG_PCI66);
78 /* Double PCICLK (if possible) */
79 if (__raw_readq(&tx4938_ccfgptr->pcfg) & TX4938_PCFG_PCICLKEN_ALL) {
80 unsigned int pcidivmode = 0;
81 u64 ccfg = __raw_readq(&tx4938_ccfgptr->ccfg);
82 pcidivmode = (unsigned long)ccfg &
83 TX4938_CCFG_PCIDIVMODE_MASK;
84 switch (pcidivmode) {
85 case TX4938_CCFG_PCIDIVMODE_8:
86 case TX4938_CCFG_PCIDIVMODE_4:
87 pcidivmode = TX4938_CCFG_PCIDIVMODE_4;
88 pciclk = txx9_cpu_clock / 4;
89 break;
90 case TX4938_CCFG_PCIDIVMODE_9:
91 case TX4938_CCFG_PCIDIVMODE_4_5:
92 pcidivmode = TX4938_CCFG_PCIDIVMODE_4_5;
93 pciclk = txx9_cpu_clock * 2 / 9;
94 break;
95 case TX4938_CCFG_PCIDIVMODE_10:
96 case TX4938_CCFG_PCIDIVMODE_5:
97 pcidivmode = TX4938_CCFG_PCIDIVMODE_5;
98 pciclk = txx9_cpu_clock / 5;
99 break;
100 case TX4938_CCFG_PCIDIVMODE_11:
101 case TX4938_CCFG_PCIDIVMODE_5_5:
102 default:
103 pcidivmode = TX4938_CCFG_PCIDIVMODE_5_5;
104 pciclk = txx9_cpu_clock * 2 / 11;
105 break;
106 }
107 tx4938_ccfg_change(TX4938_CCFG_PCIDIVMODE_MASK,
108 pcidivmode);
109 printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
110 (unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg));
111 } else
112 pciclk = -1;
113 return pciclk;
114}
115
116int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot)
117{
118 if (get_tx4927_pcicptr(dev->bus->sysdata) == tx4938_pcic1ptr) {
119 switch (slot) {
120 case TX4927_PCIC_IDSEL_AD_TO_SLOT(31):
121 if (__raw_readq(&tx4938_ccfgptr->pcfg) &
122 TX4938_PCFG_ETH0_SEL)
123 return TXX9_IRQ_BASE + TX4938_IR_ETH0;
124 break;
125 case TX4927_PCIC_IDSEL_AD_TO_SLOT(30):
126 if (__raw_readq(&tx4938_ccfgptr->pcfg) &
127 TX4938_PCFG_ETH1_SEL)
128 return TXX9_IRQ_BASE + TX4938_IR_ETH1;
129 break;
130 }
131 return 0;
132 }
133 return -1;
134}
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 358ad621094..d7d6cb063d2 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -29,8 +29,7 @@ unsigned int pci_probe = PCI_ASSIGN_ALL_BUSSES;
29 * The PCI controller list. 29 * The PCI controller list.
30 */ 30 */
31 31
32struct pci_controller *hose_head, **hose_tail = &hose_head; 32static struct pci_controller *hose_head, **hose_tail = &hose_head;
33struct pci_controller *pci_isa_hose;
34 33
35unsigned long PCIBIOS_MIN_IO = 0x0000; 34unsigned long PCIBIOS_MIN_IO = 0x0000;
36unsigned long PCIBIOS_MIN_MEM = 0; 35unsigned long PCIBIOS_MIN_MEM = 0;
diff --git a/arch/mips/pmc-sierra/yosemite/prom.c b/arch/mips/pmc-sierra/yosemite/prom.c
index 35dc435846a..cf4c868715a 100644
--- a/arch/mips/pmc-sierra/yosemite/prom.c
+++ b/arch/mips/pmc-sierra/yosemite/prom.c
@@ -64,7 +64,7 @@ static void prom_exit(void)
64#ifdef CONFIG_SMP 64#ifdef CONFIG_SMP
65 if (smp_processor_id()) 65 if (smp_processor_id())
66 /* CPU 1 */ 66 /* CPU 1 */
67 smp_call_function(prom_cpu0_exit, NULL, 1, 1); 67 smp_call_function(prom_cpu0_exit, NULL, 1);
68#endif 68#endif
69 prom_cpu0_exit(NULL); 69 prom_cpu0_exit(NULL);
70} 70}
diff --git a/arch/mips/sgi-ip22/ip22-mc.c b/arch/mips/sgi-ip22/ip22-mc.c
index 3f35d6367be..5268ac187bb 100644
--- a/arch/mips/sgi-ip22/ip22-mc.c
+++ b/arch/mips/sgi-ip22/ip22-mc.c
@@ -208,4 +208,30 @@ void __init sgimc_init(void)
208void __init prom_meminit(void) {} 208void __init prom_meminit(void) {}
209void __init prom_free_prom_memory(void) 209void __init prom_free_prom_memory(void)
210{ 210{
211#ifdef CONFIG_SGI_IP28
212 u32 mconfig1;
213 unsigned long flags;
214 spinlock_t lock;
215
216 /*
217 * because ARCS accesses memory uncached we wait until ARCS
218 * isn't needed any longer, before we switch from slow to
219 * normal mode
220 */
221 spin_lock_irqsave(&lock, flags);
222 mconfig1 = sgimc->mconfig1;
223 /* map ECC register */
224 sgimc->mconfig1 = (mconfig1 & 0xffff0000) | 0x2060;
225 iob();
226 /* switch to normal mode */
227 *(unsigned long *)PHYS_TO_XKSEG_UNCACHED(0x60000000) = 0;
228 iob();
229 /* reduce WR_COL */
230 sgimc->cmacc = (sgimc->cmacc & ~0xf) | 4;
231 iob();
232 /* restore old config */
233 sgimc->mconfig1 = mconfig1;
234 iob();
235 spin_unlock_irqrestore(&lock, flags);
236#endif
211} 237}
diff --git a/arch/mips/sgi-ip22/ip22-platform.c b/arch/mips/sgi-ip22/ip22-platform.c
index 28ffec8e5d1..fc6df96305e 100644
--- a/arch/mips/sgi-ip22/ip22-platform.c
+++ b/arch/mips/sgi-ip22/ip22-platform.c
@@ -175,3 +175,21 @@ static int __init sgiseeq_devinit(void)
175} 175}
176 176
177device_initcall(sgiseeq_devinit); 177device_initcall(sgiseeq_devinit);
178
179static int __init sgi_hal2_devinit(void)
180{
181 return IS_ERR(platform_device_register_simple("sgihal2", 0, NULL, 0));
182}
183
184device_initcall(sgi_hal2_devinit);
185
186static int __init sgi_button_devinit(void)
187{
188 if (ip22_is_fullhouse())
189 return 0; /* full house has no volume buttons */
190
191 return IS_ERR(platform_device_register_simple("sgiindybtns",
192 -1, NULL, 0));
193}
194
195device_initcall(sgi_button_devinit);
diff --git a/arch/mips/sgi-ip22/ip22-reset.c b/arch/mips/sgi-ip22/ip22-reset.c
index a435b31cf03..4ad5c3393fd 100644
--- a/arch/mips/sgi-ip22/ip22-reset.c
+++ b/arch/mips/sgi-ip22/ip22-reset.c
@@ -39,7 +39,7 @@
39#define POWERDOWN_FREQ (HZ / 4) 39#define POWERDOWN_FREQ (HZ / 4)
40#define PANIC_FREQ (HZ / 8) 40#define PANIC_FREQ (HZ / 8)
41 41
42static struct timer_list power_timer, blink_timer, debounce_timer, volume_timer; 42static struct timer_list power_timer, blink_timer, debounce_timer;
43 43
44#define MACHINE_PANICED 1 44#define MACHINE_PANICED 1
45#define MACHINE_SHUTTING_DOWN 2 45#define MACHINE_SHUTTING_DOWN 2
@@ -139,36 +139,6 @@ static inline void power_button(void)
139 add_timer(&power_timer); 139 add_timer(&power_timer);
140} 140}
141 141
142void (*indy_volume_button)(int) = NULL;
143
144EXPORT_SYMBOL(indy_volume_button);
145
146static inline void volume_up_button(unsigned long data)
147{
148 del_timer(&volume_timer);
149
150 if (indy_volume_button)
151 indy_volume_button(1);
152
153 if (sgint->istat1 & SGINT_ISTAT1_PWR) {
154 volume_timer.expires = jiffies + (HZ / 100);
155 add_timer(&volume_timer);
156 }
157}
158
159static inline void volume_down_button(unsigned long data)
160{
161 del_timer(&volume_timer);
162
163 if (indy_volume_button)
164 indy_volume_button(-1);
165
166 if (sgint->istat1 & SGINT_ISTAT1_PWR) {
167 volume_timer.expires = jiffies + (HZ / 100);
168 add_timer(&volume_timer);
169 }
170}
171
172static irqreturn_t panel_int(int irq, void *dev_id) 142static irqreturn_t panel_int(int irq, void *dev_id)
173{ 143{
174 unsigned int buttons; 144 unsigned int buttons;
@@ -190,25 +160,8 @@ static irqreturn_t panel_int(int irq, void *dev_id)
190 * House. Only lowest 2 bits are used. Guiness uses upper four bits 160 * House. Only lowest 2 bits are used. Guiness uses upper four bits
191 * for volume control". This is not true, all bits are pulled high 161 * for volume control". This is not true, all bits are pulled high
192 * on fullhouse */ 162 * on fullhouse */
193 if (ip22_is_fullhouse() || !(buttons & SGIOC_PANEL_POWERINTR)) { 163 if (!(buttons & SGIOC_PANEL_POWERINTR))
194 power_button(); 164 power_button();
195 return IRQ_HANDLED;
196 }
197 /* TODO: mute/unmute */
198 /* Volume up button was pressed */
199 if (!(buttons & SGIOC_PANEL_VOLUPINTR)) {
200 init_timer(&volume_timer);
201 volume_timer.function = volume_up_button;
202 volume_timer.expires = jiffies + (HZ / 100);
203 add_timer(&volume_timer);
204 }
205 /* Volume down button was pressed */
206 if (!(buttons & SGIOC_PANEL_VOLDNINTR)) {
207 init_timer(&volume_timer);
208 volume_timer.function = volume_down_button;
209 volume_timer.expires = jiffies + (HZ / 100);
210 add_timer(&volume_timer);
211 }
212 165
213 return IRQ_HANDLED; 166 return IRQ_HANDLED;
214} 167}
diff --git a/arch/mips/sgi-ip22/ip28-berr.c b/arch/mips/sgi-ip22/ip28-berr.c
index 30e12e2ec4b..fee7a2e0e53 100644
--- a/arch/mips/sgi-ip22/ip28-berr.c
+++ b/arch/mips/sgi-ip22/ip28-berr.c
@@ -412,7 +412,7 @@ static int ip28_be_interrupt(const struct pt_regs *regs)
412 * Now we have an asynchronous bus error, speculatively or DMA caused. 412 * Now we have an asynchronous bus error, speculatively or DMA caused.
413 * Need to search all DMA descriptors for the error address. 413 * Need to search all DMA descriptors for the error address.
414 */ 414 */
415 for (i = 0; i < sizeof(hpc3)/sizeof(struct hpc3_stat); ++i) { 415 for (i = 0; i < ARRAY_SIZE(hpc3); ++i) {
416 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i; 416 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i;
417 if ((cpu_err_stat & CPU_ERRMASK) && 417 if ((cpu_err_stat & CPU_ERRMASK) &&
418 (cpu_err_addr == hp->ndptr || cpu_err_addr == hp->cbp)) 418 (cpu_err_addr == hp->ndptr || cpu_err_addr == hp->cbp))
@@ -421,7 +421,7 @@ static int ip28_be_interrupt(const struct pt_regs *regs)
421 (gio_err_addr == hp->ndptr || gio_err_addr == hp->cbp)) 421 (gio_err_addr == hp->ndptr || gio_err_addr == hp->cbp))
422 break; 422 break;
423 } 423 }
424 if (i < sizeof(hpc3)/sizeof(struct hpc3_stat)) { 424 if (i < ARRAY_SIZE(hpc3)) {
425 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i; 425 struct hpc3_stat *hp = (struct hpc3_stat *)&hpc3 + i;
426 printk(KERN_ERR "at DMA addresses: HPC3 @ %08lx:" 426 printk(KERN_ERR "at DMA addresses: HPC3 @ %08lx:"
427 " ctl %08x, ndp %08x, cbp %08x\n", 427 " ctl %08x, ndp %08x, cbp %08x\n",
diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
index b0a25e1ee8b..64459e7d891 100644
--- a/arch/mips/sgi-ip27/ip27-nmi.c
+++ b/arch/mips/sgi-ip27/ip27-nmi.c
@@ -1,4 +1,3 @@
1#include <linux/kallsyms.h>
2#include <linux/kernel.h> 1#include <linux/kernel.h>
3#include <linux/mmzone.h> 2#include <linux/mmzone.h>
4#include <linux/nodemask.h> 3#include <linux/nodemask.h>
@@ -84,13 +83,10 @@ void nmi_cpu_eframe_save(nasid_t nasid, int slice)
84 /* 83 /*
85 * Saved cp0 registers 84 * Saved cp0 registers
86 */ 85 */
87 printk("epc : %016lx ", nr->epc); 86 printk("epc : %016lx %pS\n", nr->epc, (void *) nr->epc);
88 print_symbol("%s ", nr->epc);
89 printk("%s\n", print_tainted()); 87 printk("%s\n", print_tainted());
90 printk("ErrEPC: %016lx ", nr->error_epc); 88 printk("ErrEPC: %016lx %pS\n", nr->error_epc, (void *) nr->error_epc);
91 print_symbol("%s\n", nr->error_epc); 89 printk("ra : %016lx %pS\n", nr->gpr[31], (void *) nr->gpr[31]);
92 printk("ra : %016lx ", nr->gpr[31]);
93 print_symbol("%s\n", nr->gpr[31]);
94 printk("Status: %08lx ", nr->sr); 90 printk("Status: %08lx ", nr->sr);
95 91
96 if (nr->sr & ST0_KX) 92 if (nr->sr & ST0_KX)
diff --git a/arch/mips/sgi-ip32/ip32-platform.c b/arch/mips/sgi-ip32/ip32-platform.c
index 89a71f49b69..2ee401ba0b2 100644
--- a/arch/mips/sgi-ip32/ip32-platform.c
+++ b/arch/mips/sgi-ip32/ip32-platform.c
@@ -65,6 +65,42 @@ static __init int meth_devinit(void)
65 65
66device_initcall(meth_devinit); 66device_initcall(meth_devinit);
67 67
68static __init int sgio2audio_devinit(void)
69{
70 struct platform_device *pd;
71 int ret;
72
73 pd = platform_device_alloc("sgio2audio", -1);
74 if (!pd)
75 return -ENOMEM;
76
77 ret = platform_device_add(pd);
78 if (ret)
79 platform_device_put(pd);
80
81 return ret;
82}
83
84device_initcall(sgio2audio_devinit);
85
86static __init int sgio2btns_devinit(void)
87{
88 struct platform_device *pd;
89 int ret;
90
91 pd = platform_device_alloc("sgio2btns", -1);
92 if (!pd)
93 return -ENOMEM;
94
95 ret = platform_device_add(pd);
96 if (ret)
97 platform_device_put(pd);
98
99 return ret;
100}
101
102device_initcall(sgio2btns_devinit);
103
68MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>"); 104MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
69MODULE_LICENSE("GPL"); 105MODULE_LICENSE("GPL");
70MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2"); 106MODULE_DESCRIPTION("8250 UART probe driver for SGI IP32 aka O2");
diff --git a/arch/mips/sibyte/cfe/setup.c b/arch/mips/sibyte/cfe/setup.c
index 33fce826f8b..fd9604d5555 100644
--- a/arch/mips/sibyte/cfe/setup.c
+++ b/arch/mips/sibyte/cfe/setup.c
@@ -74,7 +74,7 @@ static void __noreturn cfe_linux_exit(void *arg)
74 if (!reboot_smp) { 74 if (!reboot_smp) {
75 /* Get CPU 0 to do the cfe_exit */ 75 /* Get CPU 0 to do the cfe_exit */
76 reboot_smp = 1; 76 reboot_smp = 1;
77 smp_call_function(cfe_linux_exit, arg, 1, 0); 77 smp_call_function(cfe_linux_exit, arg, 0);
78 } 78 }
79 } else { 79 } else {
80 printk("Passing control back to CFE...\n"); 80 printk("Passing control back to CFE...\n");
diff --git a/arch/mips/sibyte/sb1250/prom.c b/arch/mips/sibyte/sb1250/prom.c
index cf8f6b3de86..65b1af66b67 100644
--- a/arch/mips/sibyte/sb1250/prom.c
+++ b/arch/mips/sibyte/sb1250/prom.c
@@ -66,7 +66,7 @@ static void prom_linux_exit(void)
66{ 66{
67#ifdef CONFIG_SMP 67#ifdef CONFIG_SMP
68 if (smp_processor_id()) { 68 if (smp_processor_id()) {
69 smp_call_function(prom_cpu0_exit, NULL, 1, 1); 69 smp_call_function(prom_cpu0_exit, NULL, 1);
70 } 70 }
71#endif 71#endif
72 while(1); 72 while(1);
diff --git a/arch/mips/sibyte/swarm/Makefile b/arch/mips/sibyte/swarm/Makefile
index 1775755a261..255d692bfa1 100644
--- a/arch/mips/sibyte/swarm/Makefile
+++ b/arch/mips/sibyte/swarm/Makefile
@@ -1,3 +1,4 @@
1obj-y := setup.o rtc_xicor1241.o rtc_m41t81.o 1obj-y := setup.o rtc_xicor1241.o rtc_m41t81.o
2 2
3obj-$(CONFIG_I2C_BOARDINFO) += swarm-i2c.o
3obj-$(CONFIG_KGDB) += dbg_io.o 4obj-$(CONFIG_KGDB) += dbg_io.o
diff --git a/arch/mips/sibyte/swarm/swarm-i2c.c b/arch/mips/sibyte/swarm/swarm-i2c.c
new file mode 100644
index 00000000000..4282ac9d01d
--- /dev/null
+++ b/arch/mips/sibyte/swarm/swarm-i2c.c
@@ -0,0 +1,37 @@
1/*
2 * arch/mips/sibyte/swarm/swarm-i2c.c
3 *
4 * Broadcom BCM91250A (SWARM), etc. I2C platform setup.
5 *
6 * Copyright (c) 2008 Maciej W. Rozycki
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
14#include <linux/i2c.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17
18
19static struct i2c_board_info swarm_i2c_info1[] __initdata = {
20 {
21 I2C_BOARD_INFO("m41t81", 0x68),
22 },
23};
24
25static int __init swarm_i2c_init(void)
26{
27 int err;
28
29 err = i2c_register_board_info(1, swarm_i2c_info1,
30 ARRAY_SIZE(swarm_i2c_info1));
31 if (err < 0)
32 printk(KERN_ERR
33 "swarm-i2c: cannot register board I2C devices\n");
34 return err;
35}
36
37arch_initcall(swarm_i2c_init);
diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 5484e1c6205..a49272ce7ef 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -116,7 +116,6 @@ void __init plat_mem_setup(void)
116 /* 116 /*
117 * Setup (E)ISA I/O memory access stuff 117 * Setup (E)ISA I/O memory access stuff
118 */ 118 */
119 isa_slot_offset = CKSEG1ADDR(0xb0000000);
120#ifdef CONFIG_EISA 119#ifdef CONFIG_EISA
121 EISA_bus = 1; 120 EISA_bus = 1;
122#endif 121#endif
diff --git a/arch/mips/tx4927/Kconfig b/arch/mips/tx4927/Kconfig
deleted file mode 100644
index 5fbbe12e0fc..00000000000
--- a/arch/mips/tx4927/Kconfig
+++ /dev/null
@@ -1,3 +0,0 @@
1config TOSHIBA_FPCIB0
2 bool "FPCIB0 Backplane Support"
3 depends on TOSHIBA_RBTX4927
diff --git a/arch/mips/tx4927/common/Makefile b/arch/mips/tx4927/common/Makefile
deleted file mode 100644
index a7fe76a6496..00000000000
--- a/arch/mips/tx4927/common/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
1#
2# Makefile for common code for Toshiba TX4927 based systems
3#
4
5obj-y += tx4927_prom.o tx4927_irq.o
6
7obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o
8obj-$(CONFIG_KGDB) += tx4927_dbgio.o
9
10EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/Makefile b/arch/mips/tx4927/toshiba_rbtx4927/Makefile
deleted file mode 100644
index 13f96725d77..00000000000
--- a/arch/mips/tx4927/toshiba_rbtx4927/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1obj-y += toshiba_rbtx4927_prom.o
2obj-y += toshiba_rbtx4927_setup.o
3obj-y += toshiba_rbtx4927_irq.o
4
5EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
deleted file mode 100644
index 6d31f2a98ab..00000000000
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ /dev/null
@@ -1,428 +0,0 @@
1/*
2 * linux/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
3 *
4 * Toshiba RBTX4927 specific interrupt handlers
5 *
6 * Author: MontaVista Software, Inc.
7 * source@mvista.com
8 *
9 * Copyright 2001-2002 MontaVista Software Inc.
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.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */
31
32
33/*
34IRQ Device
3500 RBTX4927-ISA/00
3601 RBTX4927-ISA/01 PS2/Keyboard
3702 RBTX4927-ISA/02 Cascade RBTX4927-ISA (irqs 8-15)
3803 RBTX4927-ISA/03
3904 RBTX4927-ISA/04
4005 RBTX4927-ISA/05
4106 RBTX4927-ISA/06
4207 RBTX4927-ISA/07
4308 RBTX4927-ISA/08
4409 RBTX4927-ISA/09
4510 RBTX4927-ISA/10
4611 RBTX4927-ISA/11
4712 RBTX4927-ISA/12 PS2/Mouse (not supported at this time)
4813 RBTX4927-ISA/13
4914 RBTX4927-ISA/14 IDE
5015 RBTX4927-ISA/15
51
5216 TX4927-CP0/00 Software 0
5317 TX4927-CP0/01 Software 1
5418 TX4927-CP0/02 Cascade TX4927-CP0
5519 TX4927-CP0/03 Multiplexed -- do not use
5620 TX4927-CP0/04 Multiplexed -- do not use
5721 TX4927-CP0/05 Multiplexed -- do not use
5822 TX4927-CP0/06 Multiplexed -- do not use
5923 TX4927-CP0/07 CPU TIMER
60
6124 TX4927-PIC/00
6225 TX4927-PIC/01
6326 TX4927-PIC/02
6427 TX4927-PIC/03 Cascade RBTX4927-IOC
6528 TX4927-PIC/04
6629 TX4927-PIC/05 RBTX4927 RTL-8019AS ethernet
6730 TX4927-PIC/06
6831 TX4927-PIC/07
6932 TX4927-PIC/08 TX4927 SerialIO Channel 0
7033 TX4927-PIC/09 TX4927 SerialIO Channel 1
7134 TX4927-PIC/10
7235 TX4927-PIC/11
7336 TX4927-PIC/12
7437 TX4927-PIC/13
7538 TX4927-PIC/14
7639 TX4927-PIC/15
7740 TX4927-PIC/16 TX4927 PCI PCI-C
7841 TX4927-PIC/17
7942 TX4927-PIC/18
8043 TX4927-PIC/19
8144 TX4927-PIC/20
8245 TX4927-PIC/21
8346 TX4927-PIC/22 TX4927 PCI PCI-ERR
8447 TX4927-PIC/23 TX4927 PCI PCI-PMA (not used)
8548 TX4927-PIC/24
8649 TX4927-PIC/25
8750 TX4927-PIC/26
8851 TX4927-PIC/27
8952 TX4927-PIC/28
9053 TX4927-PIC/29
9154 TX4927-PIC/30
9255 TX4927-PIC/31
93
9456 RBTX4927-IOC/00 FPCIB0 PCI-D PJ4/A PJ5/B SB/C PJ6/D PJ7/A (SouthBridge/NotUsed) [RTL-8139=PJ4]
9557 RBTX4927-IOC/01 FPCIB0 PCI-C PJ4/D PJ5/A SB/B PJ6/C PJ7/D (SouthBridge/NotUsed) [RTL-8139=PJ5]
9658 RBTX4927-IOC/02 FPCIB0 PCI-B PJ4/C PJ5/D SB/A PJ6/B PJ7/C (SouthBridge/IDE/pin=1,INTR) [RTL-8139=NotSupported]
9759 RBTX4927-IOC/03 FPCIB0 PCI-A PJ4/B PJ5/C SB/D PJ6/A PJ7/B (SouthBridge/USB/pin=4) [RTL-8139=PJ6]
9860 RBTX4927-IOC/04
9961 RBTX4927-IOC/05
10062 RBTX4927-IOC/06
10163 RBTX4927-IOC/07
102
103NOTES:
104SouthBridge/INTR is mapped to SouthBridge/A=PCI-B/#58
105SouthBridge/ISA/pin=0 no pci irq used by this device
106SouthBridge/IDE/pin=1 no pci irq used by this device, using INTR via ISA IRQ14
107SouthBridge/USB/pin=4 using pci irq SouthBridge/D=PCI-A=#59
108SouthBridge/PMC/pin=0 no pci irq used by this device
109SuperIO/PS2/Keyboard, using INTR via ISA IRQ1
110SuperIO/PS2/Mouse, using INTR via ISA IRQ12 (mouse not currently supported)
111JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthBridge, JP4, JP5, JP6
112*/
113
114#include <linux/init.h>
115#include <linux/kernel.h>
116#include <linux/types.h>
117#include <linux/mm.h>
118#include <linux/swap.h>
119#include <linux/ioport.h>
120#include <linux/sched.h>
121#include <linux/interrupt.h>
122#include <linux/pci.h>
123#include <linux/timex.h>
124#include <asm/bootinfo.h>
125#include <asm/page.h>
126#include <asm/io.h>
127#include <asm/irq.h>
128#include <asm/pci.h>
129#include <asm/processor.h>
130#include <asm/reboot.h>
131#include <asm/time.h>
132#include <asm/wbflush.h>
133#include <linux/bootmem.h>
134#include <linux/blkdev.h>
135#ifdef CONFIG_TOSHIBA_FPCIB0
136#include <asm/i8259.h>
137#include <asm/tx4927/smsc_fdc37m81x.h>
138#endif
139#include <asm/tx4927/toshiba_rbtx4927.h>
140
141
142#undef TOSHIBA_RBTX4927_IRQ_DEBUG
143
144#ifdef TOSHIBA_RBTX4927_IRQ_DEBUG
145#define TOSHIBA_RBTX4927_IRQ_NONE 0x00000000
146
147#define TOSHIBA_RBTX4927_IRQ_INFO ( 1 << 0 )
148#define TOSHIBA_RBTX4927_IRQ_WARN ( 1 << 1 )
149#define TOSHIBA_RBTX4927_IRQ_EROR ( 1 << 2 )
150
151#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 )
152#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 )
153#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 )
154
155#define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
156#endif
157
158
159#ifdef TOSHIBA_RBTX4927_IRQ_DEBUG
160static const u32 toshiba_rbtx4927_irq_debug_flag =
161 (TOSHIBA_RBTX4927_IRQ_NONE | TOSHIBA_RBTX4927_IRQ_INFO |
162 TOSHIBA_RBTX4927_IRQ_WARN | TOSHIBA_RBTX4927_IRQ_EROR
163// | TOSHIBA_RBTX4927_IRQ_IOC_INIT
164// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
165// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
166 );
167#endif
168
169
170#ifdef TOSHIBA_RBTX4927_IRQ_DEBUG
171#define TOSHIBA_RBTX4927_IRQ_DPRINTK(flag,str...) \
172 if ( (toshiba_rbtx4927_irq_debug_flag) & (flag) ) \
173 { \
174 char tmp[100]; \
175 sprintf( tmp, str ); \
176 printk( "%s(%s:%u)::%s", __func__, __FILE__, __LINE__, tmp ); \
177 }
178#else
179#define TOSHIBA_RBTX4927_IRQ_DPRINTK(flag, str...)
180#endif
181
182
183
184
185#define TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG 0
186#define TOSHIBA_RBTX4927_IRQ_IOC_RAW_END 7
187
188#define TOSHIBA_RBTX4927_IRQ_IOC_BEG ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_BEG) /* 56 */
189#define TOSHIBA_RBTX4927_IRQ_IOC_END ((TX4927_IRQ_PIC_END+1)+TOSHIBA_RBTX4927_IRQ_IOC_RAW_END) /* 63 */
190
191#define TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC TX4927_IRQ_NEST_EXT_ON_PIC
192#define TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC (TOSHIBA_RBTX4927_IRQ_IOC_BEG+2)
193
194extern int tx4927_using_backplane;
195
196static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
197static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
198
199#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
200static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
201 .name = TOSHIBA_RBTX4927_IOC_NAME,
202 .ack = toshiba_rbtx4927_irq_ioc_disable,
203 .mask = toshiba_rbtx4927_irq_ioc_disable,
204 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
205 .unmask = toshiba_rbtx4927_irq_ioc_enable,
206};
207#define TOSHIBA_RBTX4927_IOC_INTR_ENAB (void __iomem *)0xbc002000UL
208#define TOSHIBA_RBTX4927_IOC_INTR_STAT (void __iomem *)0xbc002006UL
209
210
211u32 bit2num(u32 num)
212{
213 u32 i;
214
215 for (i = 0; i < (sizeof(num) * 8); i++) {
216 if (num & (1 << i)) {
217 return (i);
218 }
219 }
220 return (0);
221}
222
223int toshiba_rbtx4927_irq_nested(int sw_irq)
224{
225 u32 level3;
226
227 level3 = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f;
228 if (level3) {
229 sw_irq = TOSHIBA_RBTX4927_IRQ_IOC_BEG + bit2num(level3);
230 if (sw_irq != TOSHIBA_RBTX4927_IRQ_NEST_ISA_ON_IOC) {
231 goto RETURN;
232 }
233 }
234#ifdef CONFIG_TOSHIBA_FPCIB0
235 if (tx4927_using_backplane) {
236 int irq = i8259_irq();
237 if (irq >= 0)
238 sw_irq = irq;
239 }
240#endif
241
242 RETURN:
243 return (sw_irq);
244}
245
246static struct irqaction toshiba_rbtx4927_irq_ioc_action = {
247 .handler = no_action,
248 .flags = IRQF_SHARED,
249 .mask = CPU_MASK_NONE,
250 .name = TOSHIBA_RBTX4927_IOC_NAME
251};
252
253
254/**********************************************************************************/
255/* Functions for ioc */
256/**********************************************************************************/
257
258
259static void __init toshiba_rbtx4927_irq_ioc_init(void)
260{
261 int i;
262
263 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_INIT,
264 "beg=%d end=%d\n",
265 TOSHIBA_RBTX4927_IRQ_IOC_BEG,
266 TOSHIBA_RBTX4927_IRQ_IOC_END);
267
268 for (i = TOSHIBA_RBTX4927_IRQ_IOC_BEG;
269 i <= TOSHIBA_RBTX4927_IRQ_IOC_END; i++)
270 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type,
271 handle_level_irq);
272
273 setup_irq(TOSHIBA_RBTX4927_IRQ_NEST_IOC_ON_PIC,
274 &toshiba_rbtx4927_irq_ioc_action);
275}
276
277static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
278{
279 volatile unsigned char v;
280
281 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENABLE,
282 "irq=%d\n", irq);
283
284 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
285 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
286 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
287 "bad irq=%d\n", irq);
288 panic("\n");
289 }
290
291 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
292 v |= (1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG));
293 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
294}
295
296
297static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
298{
299 volatile unsigned char v;
300
301 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_DISABLE,
302 "irq=%d\n", irq);
303
304 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
305 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
306 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
307 "bad irq=%d\n", irq);
308 panic("\n");
309 }
310
311 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
312 v &= ~(1 << (irq - TOSHIBA_RBTX4927_IRQ_IOC_BEG));
313 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
314 mmiowb();
315}
316
317
318void __init arch_init_irq(void)
319{
320 extern void tx4927_irq_init(void);
321
322 tx4927_irq_init();
323 toshiba_rbtx4927_irq_ioc_init();
324#ifdef CONFIG_TOSHIBA_FPCIB0
325 if (tx4927_using_backplane)
326 init_i8259_irqs();
327#endif
328 /* Onboard 10M Ether: High Active */
329 set_irq_type(RBTX4927_RTL_8019_IRQ, IRQF_TRIGGER_HIGH);
330
331 wbflush();
332}
333
334void toshiba_rbtx4927_irq_dump(char *key)
335{
336#ifdef TOSHIBA_RBTX4927_IRQ_DEBUG
337 {
338 u32 i, j = 0;
339 for (i = 0; i < NR_IRQS; i++) {
340 if (strcmp(irq_desc[i].chip->name, "none")
341 == 0)
342 continue;
343
344 if ((i >= 1)
345 && (irq_desc[i - 1].chip->name ==
346 irq_desc[i].chip->name)) {
347 j++;
348 } else {
349 j = 0;
350 }
351 TOSHIBA_RBTX4927_IRQ_DPRINTK
352 (TOSHIBA_RBTX4927_IRQ_INFO,
353 "%s irq=0x%02x/%3d s=0x%08x h=0x%08x a=0x%08x ah=0x%08x d=%1d n=%s/%02d\n",
354 key, i, i, irq_desc[i].status,
355 (u32) irq_desc[i].chip,
356 (u32) irq_desc[i].action,
357 (u32) (irq_desc[i].action ? irq_desc[i].
358 action->handler : 0),
359 irq_desc[i].depth,
360 irq_desc[i].chip->name, j);
361 }
362 }
363#endif
364}
365
366void toshiba_rbtx4927_irq_dump_pics(char *s)
367{
368 u32 level0_m;
369 u32 level0_s;
370 u32 level1_m;
371 u32 level1_s;
372 u32 level2;
373 u32 level2_p;
374 u32 level2_s;
375 u32 level3_m;
376 u32 level3_s;
377 u32 level4_m;
378 u32 level4_s;
379 u32 level5_m;
380 u32 level5_s;
381
382 if (s == NULL)
383 s = "null";
384
385 level0_m = (read_c0_status() & 0x0000ff00) >> 8;
386 level0_s = (read_c0_cause() & 0x0000ff00) >> 8;
387
388 level1_m = level0_m;
389 level1_s = level0_s & 0x87;
390
391 level2 = __raw_readl((void __iomem *)0xff1ff6a0UL);
392 level2_p = (((level2 & 0x10000)) ? 0 : 1);
393 level2_s = (((level2 & 0x1f) == 0x1f) ? 0 : (level2 & 0x1f));
394
395 level3_m = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB) & 0x1f;
396 level3_s = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f;
397
398 level4_m = inb(0x21);
399 outb(0x0A, 0x20);
400 level4_s = inb(0x20);
401
402 level5_m = inb(0xa1);
403 outb(0x0A, 0xa0);
404 level5_s = inb(0xa0);
405
406 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
407 "dump_raw_pic() ");
408 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
409 "cp0:m=0x%02x/s=0x%02x ", level0_m,
410 level0_s);
411 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
412 "cp0:m=0x%02x/s=0x%02x ", level1_m,
413 level1_s);
414 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
415 "pic:e=0x%02x/s=0x%02x ", level2_p,
416 level2_s);
417 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
418 "ioc:m=0x%02x/s=0x%02x ", level3_m,
419 level3_s);
420 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
421 "sbm:m=0x%02x/s=0x%02x ", level4_m,
422 level4_s);
423 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO,
424 "sbs:m=0x%02x/s=0x%02x ", level5_m,
425 level5_s);
426 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_INFO, "[%s]\n",
427 s);
428}
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c
deleted file mode 100644
index f3f86857bea..00000000000
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_prom.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/*
2 * rbtx4927 specific prom routines
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * Copyright 2001-2002 MontaVista Software Inc.
8 *
9 * Copyright (C) 2004 MontaVista Software Inc.
10 * Author: Manish Lachwani, mlachwani@mvista.com
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.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
23 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
26 * USE OF 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
37#include <asm/addrspace.h>
38#include <asm/bootinfo.h>
39#include <asm/cpu.h>
40#include <asm/tx4927/tx4927.h>
41
42void __init prom_init_cmdline(void)
43{
44 int argc = (int) fw_arg0;
45 char **argv = (char **) fw_arg1;
46 int i; /* Always ignore the "-c" at argv[0] */
47
48 /* ignore all built-in args if any f/w args given */
49 if (argc > 1) {
50 *arcs_cmdline = '\0';
51 }
52
53 for (i = 1; i < argc; i++) {
54 if (i != 1) {
55 strcat(arcs_cmdline, " ");
56 }
57 strcat(arcs_cmdline, argv[i]);
58 }
59}
60
61void __init prom_init(void)
62{
63 extern int tx4927_get_mem_size(void);
64 extern char* toshiba_name;
65 int msize;
66
67 prom_init_cmdline();
68
69 if ((read_c0_prid() & 0xff) == PRID_REV_TX4927) {
70 mips_machtype = MACH_TOSHIBA_RBTX4927;
71 toshiba_name = "TX4927";
72 } else {
73 mips_machtype = MACH_TOSHIBA_RBTX4937;
74 toshiba_name = "TX4937";
75 }
76
77 msize = tx4927_get_mem_size();
78 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
79}
80
81void __init prom_free_prom_memory(void)
82{
83}
84
85const char *get_system_type(void)
86{
87 return "Toshiba RBTX4927/RBTX4937";
88}
89
90char * __init prom_getcmdline(void)
91{
92 return &(arcs_cmdline[0]);
93}
94
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
deleted file mode 100644
index 2203c77b2ce..00000000000
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_setup.c
+++ /dev/null
@@ -1,1001 +0,0 @@
1/*
2 * Toshiba rbtx4927 specific setup
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * Copyright 2001-2002 MontaVista Software Inc.
8 *
9 * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org)
10 * Copyright (C) 2000 RidgeRun, Inc.
11 * Author: RidgeRun, Inc.
12 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
13 *
14 * Copyright 2001 MontaVista Software Inc.
15 * Author: jsun@mvista.com or jsun@junsun.net
16 *
17 * Copyright 2002 MontaVista Software Inc.
18 * Author: Michael Pruznick, michael_pruznick@mvista.com
19 *
20 * Copyright (C) 2000-2001 Toshiba Corporation
21 *
22 * Copyright (C) 2004 MontaVista Software Inc.
23 * Author: Manish Lachwani, mlachwani@mvista.com
24 *
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2 of the License, or (at your
28 * option) any later version.
29 *
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
36 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
39 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * You should have received a copy of the GNU General Public License along
42 * with this program; if not, write to the Free Software Foundation, Inc.,
43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */
45#include <linux/init.h>
46#include <linux/kernel.h>
47#include <linux/types.h>
48#include <linux/ioport.h>
49#include <linux/interrupt.h>
50#include <linux/pci.h>
51#include <linux/pm.h>
52#include <linux/platform_device.h>
53#include <linux/clk.h>
54
55#include <asm/bootinfo.h>
56#include <asm/io.h>
57#include <asm/processor.h>
58#include <asm/reboot.h>
59#include <asm/time.h>
60#include <asm/txx9tmr.h>
61#ifdef CONFIG_TOSHIBA_FPCIB0
62#include <asm/tx4927/smsc_fdc37m81x.h>
63#endif
64#include <asm/tx4927/toshiba_rbtx4927.h>
65#ifdef CONFIG_PCI
66#include <asm/tx4927/tx4927_pci.h>
67#endif
68#ifdef CONFIG_SERIAL_TXX9
69#include <linux/serial_core.h>
70#endif
71
72#undef TOSHIBA_RBTX4927_SETUP_DEBUG
73
74#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
75#define TOSHIBA_RBTX4927_SETUP_SETUP ( 1 << 4 )
76#define TOSHIBA_RBTX4927_SETUP_PCIBIOS ( 1 << 7 )
77#define TOSHIBA_RBTX4927_SETUP_PCI1 ( 1 << 8 )
78#define TOSHIBA_RBTX4927_SETUP_PCI2 ( 1 << 9 )
79
80#define TOSHIBA_RBTX4927_SETUP_ALL 0xffffffff
81#endif
82
83#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
84static const u32 toshiba_rbtx4927_setup_debug_flag =
85 (TOSHIBA_RBTX4927_SETUP_SETUP |
86 | TOSHIBA_RBTX4927_SETUP_PCIBIOS | TOSHIBA_RBTX4927_SETUP_PCI1 |
87 TOSHIBA_RBTX4927_SETUP_PCI2);
88#endif
89
90#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
91#define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag,str...) \
92 if ( (toshiba_rbtx4927_setup_debug_flag) & (flag) ) \
93 { \
94 char tmp[100]; \
95 sprintf( tmp, str ); \
96 printk( "%s(%s:%u)::%s", __func__, __FILE__, __LINE__, tmp ); \
97 }
98#else
99#define TOSHIBA_RBTX4927_SETUP_DPRINTK(flag, str...)
100#endif
101
102/* These functions are used for rebooting or halting the machine*/
103extern void toshiba_rbtx4927_restart(char *command);
104extern void toshiba_rbtx4927_halt(void);
105extern void toshiba_rbtx4927_power_off(void);
106
107int tx4927_using_backplane = 0;
108
109extern void toshiba_rbtx4927_irq_setup(void);
110
111char *prom_getcmdline(void);
112
113#ifdef CONFIG_PCI
114#undef TX4927_SUPPORT_COMMAND_IO
115#undef TX4927_SUPPORT_PCI_66
116int tx4927_cpu_clock = 100000000; /* 100MHz */
117unsigned long mips_pci_io_base;
118unsigned long mips_pci_io_size;
119unsigned long mips_pci_mem_base;
120unsigned long mips_pci_mem_size;
121/* for legacy I/O, PCI I/O PCI Bus address must be 0 */
122unsigned long mips_pci_io_pciaddr = 0;
123unsigned long mips_memory_upper;
124static int tx4927_ccfg_toeon = 1;
125static int tx4927_pcic_trdyto = 0; /* default: disabled */
126unsigned long tx4927_ce_base[8];
127void tx4927_reset_pci_pcic(void);
128int tx4927_pci66 = 0; /* 0:auto */
129#endif
130
131char *toshiba_name = "";
132
133#ifdef CONFIG_PCI
134extern struct pci_controller tx4927_controller;
135
136static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
137 int top_bus, int busnr, int devfn)
138{
139 static struct pci_dev dev;
140 static struct pci_bus bus;
141
142 dev.sysdata = (void *)hose;
143 dev.devfn = devfn;
144 bus.number = busnr;
145 bus.ops = hose->pci_ops;
146 bus.parent = NULL;
147 dev.bus = &bus;
148
149 return &dev;
150}
151
152#define EARLY_PCI_OP(rw, size, type) \
153static int early_##rw##_config_##size(struct pci_controller *hose, \
154 int top_bus, int bus, int devfn, int offset, type value) \
155{ \
156 return pci_##rw##_config_##size( \
157 fake_pci_dev(hose, top_bus, bus, devfn), \
158 offset, value); \
159}
160
161EARLY_PCI_OP(read, byte, u8 *)
162EARLY_PCI_OP(read, dword, u32 *)
163EARLY_PCI_OP(write, byte, u8)
164EARLY_PCI_OP(write, dword, u32)
165
166static int __init tx4927_pcibios_init(void)
167{
168 unsigned int id;
169 u32 pci_devfn;
170 int devfn_start = 0;
171 int devfn_stop = 0xff;
172 int busno = 0; /* One bus on the Toshiba */
173 struct pci_controller *hose = &tx4927_controller;
174
175 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
176 "-\n");
177
178 for (pci_devfn = devfn_start; pci_devfn < devfn_stop; pci_devfn++) {
179 early_read_config_dword(hose, busno, busno, pci_devfn,
180 PCI_VENDOR_ID, &id);
181
182 if (id == 0xffffffff) {
183 continue;
184 }
185
186 if (id == 0x94601055) {
187 u8 v08_64;
188 u32 v32_b0;
189 u8 v08_e1;
190#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
191 char *s = " sb/isa --";
192#endif
193
194 TOSHIBA_RBTX4927_SETUP_DPRINTK
195 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
196 s);
197
198 early_read_config_byte(hose, busno, busno,
199 pci_devfn, 0x64, &v08_64);
200 early_read_config_dword(hose, busno, busno,
201 pci_devfn, 0xb0, &v32_b0);
202 early_read_config_byte(hose, busno, busno,
203 pci_devfn, 0xe1, &v08_e1);
204
205 TOSHIBA_RBTX4927_SETUP_DPRINTK
206 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
207 ":%s beg 0x64 = 0x%02x\n", s, v08_64);
208 TOSHIBA_RBTX4927_SETUP_DPRINTK
209 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
210 ":%s beg 0xb0 = 0x%02x\n", s, v32_b0);
211 TOSHIBA_RBTX4927_SETUP_DPRINTK
212 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
213 ":%s beg 0xe1 = 0x%02x\n", s, v08_e1);
214
215 /* serial irq control */
216 v08_64 = 0xd0;
217
218 /* serial irq pin */
219 v32_b0 |= 0x00010000;
220
221 /* ide irq on isa14 */
222 v08_e1 &= 0xf0;
223 v08_e1 |= 0x0d;
224
225 TOSHIBA_RBTX4927_SETUP_DPRINTK
226 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
227 ":%s mid 0x64 = 0x%02x\n", s, v08_64);
228 TOSHIBA_RBTX4927_SETUP_DPRINTK
229 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
230 ":%s mid 0xb0 = 0x%02x\n", s, v32_b0);
231 TOSHIBA_RBTX4927_SETUP_DPRINTK
232 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
233 ":%s mid 0xe1 = 0x%02x\n", s, v08_e1);
234
235 early_write_config_byte(hose, busno, busno,
236 pci_devfn, 0x64, v08_64);
237 early_write_config_dword(hose, busno, busno,
238 pci_devfn, 0xb0, v32_b0);
239 early_write_config_byte(hose, busno, busno,
240 pci_devfn, 0xe1, v08_e1);
241
242#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
243 {
244 early_read_config_byte(hose, busno, busno,
245 pci_devfn, 0x64,
246 &v08_64);
247 early_read_config_dword(hose, busno, busno,
248 pci_devfn, 0xb0,
249 &v32_b0);
250 early_read_config_byte(hose, busno, busno,
251 pci_devfn, 0xe1,
252 &v08_e1);
253
254 TOSHIBA_RBTX4927_SETUP_DPRINTK
255 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
256 ":%s end 0x64 = 0x%02x\n", s, v08_64);
257 TOSHIBA_RBTX4927_SETUP_DPRINTK
258 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
259 ":%s end 0xb0 = 0x%02x\n", s, v32_b0);
260 TOSHIBA_RBTX4927_SETUP_DPRINTK
261 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
262 ":%s end 0xe1 = 0x%02x\n", s, v08_e1);
263 }
264#endif
265
266 TOSHIBA_RBTX4927_SETUP_DPRINTK
267 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
268 s);
269 }
270
271 if (id == 0x91301055) {
272 u8 v08_04;
273 u8 v08_09;
274 u8 v08_41;
275 u8 v08_43;
276 u8 v08_5c;
277#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
278 char *s = " sb/ide --";
279#endif
280
281 TOSHIBA_RBTX4927_SETUP_DPRINTK
282 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s beg\n",
283 s);
284
285 early_read_config_byte(hose, busno, busno,
286 pci_devfn, 0x04, &v08_04);
287 early_read_config_byte(hose, busno, busno,
288 pci_devfn, 0x09, &v08_09);
289 early_read_config_byte(hose, busno, busno,
290 pci_devfn, 0x41, &v08_41);
291 early_read_config_byte(hose, busno, busno,
292 pci_devfn, 0x43, &v08_43);
293 early_read_config_byte(hose, busno, busno,
294 pci_devfn, 0x5c, &v08_5c);
295
296 TOSHIBA_RBTX4927_SETUP_DPRINTK
297 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
298 ":%s beg 0x04 = 0x%02x\n", s, v08_04);
299 TOSHIBA_RBTX4927_SETUP_DPRINTK
300 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
301 ":%s beg 0x09 = 0x%02x\n", s, v08_09);
302 TOSHIBA_RBTX4927_SETUP_DPRINTK
303 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
304 ":%s beg 0x41 = 0x%02x\n", s, v08_41);
305 TOSHIBA_RBTX4927_SETUP_DPRINTK
306 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
307 ":%s beg 0x43 = 0x%02x\n", s, v08_43);
308 TOSHIBA_RBTX4927_SETUP_DPRINTK
309 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
310 ":%s beg 0x5c = 0x%02x\n", s, v08_5c);
311
312 /* enable ide master/io */
313 v08_04 |= (PCI_COMMAND_MASTER | PCI_COMMAND_IO);
314
315 /* enable ide native mode */
316 v08_09 |= 0x05;
317
318 /* enable primary ide */
319 v08_41 |= 0x80;
320
321 /* enable secondary ide */
322 v08_43 |= 0x80;
323
324 /*
325 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
326 *
327 * This line of code is intended to provide the user with a work
328 * around solution to the anomalies cited in SMSC's anomaly sheet
329 * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
330 *
331 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
332 */
333 v08_5c |= 0x01;
334
335 TOSHIBA_RBTX4927_SETUP_DPRINTK
336 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
337 ":%s mid 0x04 = 0x%02x\n", s, v08_04);
338 TOSHIBA_RBTX4927_SETUP_DPRINTK
339 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
340 ":%s mid 0x09 = 0x%02x\n", s, v08_09);
341 TOSHIBA_RBTX4927_SETUP_DPRINTK
342 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
343 ":%s mid 0x41 = 0x%02x\n", s, v08_41);
344 TOSHIBA_RBTX4927_SETUP_DPRINTK
345 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
346 ":%s mid 0x43 = 0x%02x\n", s, v08_43);
347 TOSHIBA_RBTX4927_SETUP_DPRINTK
348 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
349 ":%s mid 0x5c = 0x%02x\n", s, v08_5c);
350
351 early_write_config_byte(hose, busno, busno,
352 pci_devfn, 0x5c, v08_5c);
353 early_write_config_byte(hose, busno, busno,
354 pci_devfn, 0x04, v08_04);
355 early_write_config_byte(hose, busno, busno,
356 pci_devfn, 0x09, v08_09);
357 early_write_config_byte(hose, busno, busno,
358 pci_devfn, 0x41, v08_41);
359 early_write_config_byte(hose, busno, busno,
360 pci_devfn, 0x43, v08_43);
361
362#ifdef TOSHIBA_RBTX4927_SETUP_DEBUG
363 {
364 early_read_config_byte(hose, busno, busno,
365 pci_devfn, 0x04,
366 &v08_04);
367 early_read_config_byte(hose, busno, busno,
368 pci_devfn, 0x09,
369 &v08_09);
370 early_read_config_byte(hose, busno, busno,
371 pci_devfn, 0x41,
372 &v08_41);
373 early_read_config_byte(hose, busno, busno,
374 pci_devfn, 0x43,
375 &v08_43);
376 early_read_config_byte(hose, busno, busno,
377 pci_devfn, 0x5c,
378 &v08_5c);
379
380 TOSHIBA_RBTX4927_SETUP_DPRINTK
381 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
382 ":%s end 0x04 = 0x%02x\n", s, v08_04);
383 TOSHIBA_RBTX4927_SETUP_DPRINTK
384 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
385 ":%s end 0x09 = 0x%02x\n", s, v08_09);
386 TOSHIBA_RBTX4927_SETUP_DPRINTK
387 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
388 ":%s end 0x41 = 0x%02x\n", s, v08_41);
389 TOSHIBA_RBTX4927_SETUP_DPRINTK
390 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
391 ":%s end 0x43 = 0x%02x\n", s, v08_43);
392 TOSHIBA_RBTX4927_SETUP_DPRINTK
393 (TOSHIBA_RBTX4927_SETUP_PCIBIOS,
394 ":%s end 0x5c = 0x%02x\n", s, v08_5c);
395 }
396#endif
397
398 TOSHIBA_RBTX4927_SETUP_DPRINTK
399 (TOSHIBA_RBTX4927_SETUP_PCIBIOS, ":%s end\n",
400 s);
401 }
402
403 }
404
405 register_pci_controller(&tx4927_controller);
406 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCIBIOS,
407 "+\n");
408
409 return 0;
410}
411
412arch_initcall(tx4927_pcibios_init);
413
414extern struct resource pci_io_resource;
415extern struct resource pci_mem_resource;
416
417void __init tx4927_pci_setup(void)
418{
419 static int called = 0;
420 extern unsigned int tx4927_get_mem_size(void);
421
422 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "-\n");
423
424 mips_memory_upper = tx4927_get_mem_size() << 20;
425 mips_memory_upper += KSEG0;
426 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
427 "0x%08lx=mips_memory_upper\n",
428 mips_memory_upper);
429 mips_pci_io_base = TX4927_PCIIO;
430 mips_pci_io_size = TX4927_PCIIO_SIZE;
431 mips_pci_mem_base = TX4927_PCIMEM;
432 mips_pci_mem_size = TX4927_PCIMEM_SIZE;
433
434 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
435 "0x%08lx=mips_pci_io_base\n",
436 mips_pci_io_base);
437 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
438 "0x%08lx=mips_pci_io_size\n",
439 mips_pci_io_size);
440 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
441 "0x%08lx=mips_pci_mem_base\n",
442 mips_pci_mem_base);
443 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
444 "0x%08lx=mips_pci_mem_size\n",
445 mips_pci_mem_size);
446 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
447 "0x%08lx=pci_io_resource.start\n",
448 pci_io_resource.start);
449 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
450 "0x%08lx=pci_io_resource.end\n",
451 pci_io_resource.end);
452 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
453 "0x%08lx=pci_mem_resource.start\n",
454 pci_mem_resource.start);
455 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
456 "0x%08lx=pci_mem_resource.end\n",
457 pci_mem_resource.end);
458 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
459 "0x%08lx=mips_io_port_base",
460 mips_io_port_base);
461 if (!called) {
462 printk
463 ("%s PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
464 toshiba_name,
465 (unsigned short) (tx4927_pcicptr->pciid >> 16),
466 (unsigned short) (tx4927_pcicptr->pciid & 0xffff),
467 (unsigned short) (tx4927_pcicptr->pciccrev & 0xff),
468 (!(tx4927_ccfgptr->
469 ccfg & TX4927_CCFG_PCIXARB)) ? "External" :
470 "Internal");
471 called = 1;
472 }
473 printk("%s PCIC --%s PCICLK:", toshiba_name,
474 (tx4927_ccfgptr->ccfg & TX4927_CCFG_PCI66) ? " PCI66" : "");
475 if (tx4927_ccfgptr->pcfg & TX4927_PCFG_PCICLKEN_ALL) {
476 int pciclk = 0;
477 if (mips_machtype == MACH_TOSHIBA_RBTX4937)
478 switch ((unsigned long) tx4927_ccfgptr->
479 ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
480 case TX4937_CCFG_PCIDIVMODE_4:
481 pciclk = tx4927_cpu_clock / 4;
482 break;
483 case TX4937_CCFG_PCIDIVMODE_4_5:
484 pciclk = tx4927_cpu_clock * 2 / 9;
485 break;
486 case TX4937_CCFG_PCIDIVMODE_5:
487 pciclk = tx4927_cpu_clock / 5;
488 break;
489 case TX4937_CCFG_PCIDIVMODE_5_5:
490 pciclk = tx4927_cpu_clock * 2 / 11;
491 break;
492 case TX4937_CCFG_PCIDIVMODE_8:
493 pciclk = tx4927_cpu_clock / 8;
494 break;
495 case TX4937_CCFG_PCIDIVMODE_9:
496 pciclk = tx4927_cpu_clock / 9;
497 break;
498 case TX4937_CCFG_PCIDIVMODE_10:
499 pciclk = tx4927_cpu_clock / 10;
500 break;
501 case TX4937_CCFG_PCIDIVMODE_11:
502 pciclk = tx4927_cpu_clock / 11;
503 break;
504 }
505
506 else
507 switch ((unsigned long) tx4927_ccfgptr->
508 ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
509 case TX4927_CCFG_PCIDIVMODE_2_5:
510 pciclk = tx4927_cpu_clock * 2 / 5;
511 break;
512 case TX4927_CCFG_PCIDIVMODE_3:
513 pciclk = tx4927_cpu_clock / 3;
514 break;
515 case TX4927_CCFG_PCIDIVMODE_5:
516 pciclk = tx4927_cpu_clock / 5;
517 break;
518 case TX4927_CCFG_PCIDIVMODE_6:
519 pciclk = tx4927_cpu_clock / 6;
520 break;
521 }
522
523 printk("Internal(%dMHz)", pciclk / 1000000);
524 } else {
525 int pciclk = 0;
526 int pciclk_setting = *tx4927_pci_clk_ptr;
527 switch (pciclk_setting & TX4927_PCI_CLK_MASK) {
528 case TX4927_PCI_CLK_33:
529 pciclk = 33333333;
530 break;
531 case TX4927_PCI_CLK_25:
532 pciclk = 25000000;
533 break;
534 case TX4927_PCI_CLK_66:
535 pciclk = 66666666;
536 break;
537 case TX4927_PCI_CLK_50:
538 pciclk = 50000000;
539 break;
540 }
541 printk("External(%dMHz)", pciclk / 1000000);
542 }
543 printk("\n");
544
545
546
547 /* GB->PCI mappings */
548 tx4927_pcicptr->g2piomask = (mips_pci_io_size - 1) >> 4;
549 tx4927_pcicptr->g2piogbase = mips_pci_io_base |
550#ifdef __BIG_ENDIAN
551 TX4927_PCIC_G2PIOGBASE_ECHG
552#else
553 TX4927_PCIC_G2PIOGBASE_BSDIS
554#endif
555 ;
556
557 tx4927_pcicptr->g2piopbase = 0;
558
559 tx4927_pcicptr->g2pmmask[0] = (mips_pci_mem_size - 1) >> 4;
560 tx4927_pcicptr->g2pmgbase[0] = mips_pci_mem_base |
561#ifdef __BIG_ENDIAN
562 TX4927_PCIC_G2PMnGBASE_ECHG
563#else
564 TX4927_PCIC_G2PMnGBASE_BSDIS
565#endif
566 ;
567 tx4927_pcicptr->g2pmpbase[0] = mips_pci_mem_base;
568
569 tx4927_pcicptr->g2pmmask[1] = 0;
570 tx4927_pcicptr->g2pmgbase[1] = 0;
571 tx4927_pcicptr->g2pmpbase[1] = 0;
572 tx4927_pcicptr->g2pmmask[2] = 0;
573 tx4927_pcicptr->g2pmgbase[2] = 0;
574 tx4927_pcicptr->g2pmpbase[2] = 0;
575
576
577 /* PCI->GB mappings (I/O 256B) */
578 tx4927_pcicptr->p2giopbase = 0; /* 256B */
579
580 /* PCI->GB mappings (MEM 512MB) M0 gets all of memory */
581 tx4927_pcicptr->p2gm0plbase = 0;
582 tx4927_pcicptr->p2gm0pubase = 0;
583 tx4927_pcicptr->p2gmgbase[0] = 0 | TX4927_PCIC_P2GMnGBASE_TMEMEN |
584#ifdef __BIG_ENDIAN
585 TX4927_PCIC_P2GMnGBASE_TECHG
586#else
587 TX4927_PCIC_P2GMnGBASE_TBSDIS
588#endif
589 ;
590
591 /* PCI->GB mappings (MEM 16MB) -not used */
592 tx4927_pcicptr->p2gm1plbase = 0xffffffff;
593 tx4927_pcicptr->p2gm1pubase = 0xffffffff;
594 tx4927_pcicptr->p2gmgbase[1] = 0;
595
596 /* PCI->GB mappings (MEM 1MB) -not used */
597 tx4927_pcicptr->p2gm2pbase = 0xffffffff;
598 tx4927_pcicptr->p2gmgbase[2] = 0;
599
600
601 /* Enable Initiator Memory 0 Space, I/O Space, Config */
602 tx4927_pcicptr->pciccfg &= TX4927_PCIC_PCICCFG_LBWC_MASK;
603 tx4927_pcicptr->pciccfg |=
604 TX4927_PCIC_PCICCFG_IMSE0 | TX4927_PCIC_PCICCFG_IISE |
605 TX4927_PCIC_PCICCFG_ICAE | TX4927_PCIC_PCICCFG_ATR;
606
607
608 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
609 tx4927_pcicptr->pcicfg1 = 0;
610
611 if (tx4927_pcic_trdyto >= 0) {
612 tx4927_pcicptr->g2ptocnt &= ~0xff;
613 tx4927_pcicptr->g2ptocnt |= (tx4927_pcic_trdyto & 0xff);
614 }
615
616 /* Clear All Local Bus Status */
617 tx4927_pcicptr->pcicstatus = TX4927_PCIC_PCICSTATUS_ALL;
618 /* Enable All Local Bus Interrupts */
619 tx4927_pcicptr->pcicmask = TX4927_PCIC_PCICSTATUS_ALL;
620 /* Clear All Initiator Status */
621 tx4927_pcicptr->g2pstatus = TX4927_PCIC_G2PSTATUS_ALL;
622 /* Enable All Initiator Interrupts */
623 tx4927_pcicptr->g2pmask = TX4927_PCIC_G2PSTATUS_ALL;
624 /* Clear All PCI Status Error */
625 tx4927_pcicptr->pcistatus =
626 (tx4927_pcicptr->pcistatus & 0x0000ffff) |
627 (TX4927_PCIC_PCISTATUS_ALL << 16);
628 /* Enable All PCI Status Error Interrupts */
629 tx4927_pcicptr->pcimask = TX4927_PCIC_PCISTATUS_ALL;
630
631 /* PCIC Int => IRC IRQ16 */
632 tx4927_pcicptr->pcicfg2 =
633 (tx4927_pcicptr->pcicfg2 & 0xffffff00) | TX4927_IR_PCIC;
634
635 if (!(tx4927_ccfgptr->ccfg & TX4927_CCFG_PCIXARB)) {
636 /* XXX */
637 } else {
638 /* Reset Bus Arbiter */
639 tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_RPBA;
640 /* Enable Bus Arbiter */
641 tx4927_pcicptr->pbacfg = TX4927_PCIC_PBACFG_PBAEN;
642 }
643
644 tx4927_pcicptr->pcistatus = PCI_COMMAND_MASTER |
645 PCI_COMMAND_MEMORY |
646 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
647
648 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2,
649 ":pci setup complete:\n");
650 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI2, "+\n");
651}
652
653#endif /* CONFIG_PCI */
654
655static void __noreturn wait_forever(void)
656{
657 while (1)
658 if (cpu_wait)
659 (*cpu_wait)();
660}
661
662void toshiba_rbtx4927_restart(char *command)
663{
664 printk(KERN_NOTICE "System Rebooting...\n");
665
666 /* enable the s/w reset register */
667 writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE);
668
669 /* wait for enable to be seen */
670 while ((readb(RBTX4927_SW_RESET_ENABLE) &
671 RBTX4927_SW_RESET_ENABLE_SET) == 0x00);
672
673 /* do a s/w reset */
674 writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO);
675
676 /* do something passive while waiting for reset */
677 local_irq_disable();
678 wait_forever();
679 /* no return */
680}
681
682
683void toshiba_rbtx4927_halt(void)
684{
685 printk(KERN_NOTICE "System Halted\n");
686 local_irq_disable();
687 wait_forever();
688 /* no return */
689}
690
691void toshiba_rbtx4927_power_off(void)
692{
693 toshiba_rbtx4927_halt();
694 /* no return */
695}
696
697void __init plat_mem_setup(void)
698{
699 int i;
700 u32 cp0_config;
701 char *argptr;
702
703 printk("CPU is %s\n", toshiba_name);
704
705 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
706 "-\n");
707
708 /* f/w leaves this on at startup */
709 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
710 ":Clearing STO_ERL.\n");
711 clear_c0_status(ST0_ERL);
712
713 /* enable caches -- HCP5 does this, pmon does not */
714 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
715 ":Enabling TX49_CONF_IC,TX49_CONF_DC.\n");
716 cp0_config = read_c0_config();
717 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
718 write_c0_config(cp0_config);
719
720 set_io_port_base(KSEG1 + TBTX4927_ISA_IO_OFFSET);
721 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
722 ":mips_io_port_base=0x%08lx\n",
723 mips_io_port_base);
724
725 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
726 ":Resource\n");
727 ioport_resource.end = 0xffffffff;
728 iomem_resource.end = 0xffffffff;
729
730 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
731 ":ResetRoutines\n");
732 _machine_restart = toshiba_rbtx4927_restart;
733 _machine_halt = toshiba_rbtx4927_halt;
734 pm_power_off = toshiba_rbtx4927_power_off;
735
736 for (i = 0; i < TX4927_NR_TMR; i++)
737 txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL);
738
739#ifdef CONFIG_PCI
740
741 /* PCIC */
742 /*
743 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
744 *
745 * For TX4927:
746 * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
747 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
748 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
749 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
750 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
751 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
752 *
753 * For TX4937:
754 * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
755 * PCIDIVMODE[10] is 0.
756 * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
757 * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
758 * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
759 * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
760 * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
761 * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
762 *
763 */
764 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
765 "ccfg is %lx, PCIDIVMODE is %x\n",
766 (unsigned long) tx4927_ccfgptr->ccfg,
767 (unsigned long) tx4927_ccfgptr->ccfg &
768 (mips_machtype == MACH_TOSHIBA_RBTX4937 ?
769 TX4937_CCFG_PCIDIVMODE_MASK :
770 TX4927_CCFG_PCIDIVMODE_MASK));
771
772 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_PCI1,
773 "PCI66 mode is %lx, PCI mode is %lx, pci arb is %lx\n",
774 (unsigned long) tx4927_ccfgptr->
775 ccfg & TX4927_CCFG_PCI66,
776 (unsigned long) tx4927_ccfgptr->
777 ccfg & TX4927_CCFG_PCIMIDE,
778 (unsigned long) tx4927_ccfgptr->
779 ccfg & TX4927_CCFG_PCIXARB);
780
781 if (mips_machtype == MACH_TOSHIBA_RBTX4937)
782 switch ((unsigned long)tx4927_ccfgptr->
783 ccfg & TX4937_CCFG_PCIDIVMODE_MASK) {
784 case TX4937_CCFG_PCIDIVMODE_8:
785 case TX4937_CCFG_PCIDIVMODE_4:
786 tx4927_cpu_clock = 266666666; /* 266MHz */
787 break;
788 case TX4937_CCFG_PCIDIVMODE_9:
789 case TX4937_CCFG_PCIDIVMODE_4_5:
790 tx4927_cpu_clock = 300000000; /* 300MHz */
791 break;
792 default:
793 tx4927_cpu_clock = 333333333; /* 333MHz */
794 }
795 else
796 switch ((unsigned long)tx4927_ccfgptr->
797 ccfg & TX4927_CCFG_PCIDIVMODE_MASK) {
798 case TX4927_CCFG_PCIDIVMODE_2_5:
799 case TX4927_CCFG_PCIDIVMODE_5:
800 tx4927_cpu_clock = 166666666; /* 166MHz */
801 break;
802 default:
803 tx4927_cpu_clock = 200000000; /* 200MHz */
804 }
805
806 /* CCFG */
807 /* do reset on watchdog */
808 tx4927_ccfgptr->ccfg |= TX4927_CCFG_WR;
809 /* enable Timeout BusError */
810 if (tx4927_ccfg_toeon)
811 tx4927_ccfgptr->ccfg |= TX4927_CCFG_TOE;
812
813 tx4927_pci_setup();
814 if (tx4927_using_backplane == 1)
815 printk("backplane board IS installed\n");
816 else
817 printk("No Backplane \n");
818
819 /* this is on ISA bus behind PCI bus, so need PCI up first */
820#ifdef CONFIG_TOSHIBA_FPCIB0
821 {
822 if (tx4927_using_backplane) {
823 TOSHIBA_RBTX4927_SETUP_DPRINTK
824 (TOSHIBA_RBTX4927_SETUP_SETUP,
825 ":fpcibo=yes\n");
826
827 TOSHIBA_RBTX4927_SETUP_DPRINTK
828 (TOSHIBA_RBTX4927_SETUP_SETUP,
829 ":smsc_fdc37m81x_init()\n");
830 smsc_fdc37m81x_init(0x3f0);
831
832 TOSHIBA_RBTX4927_SETUP_DPRINTK
833 (TOSHIBA_RBTX4927_SETUP_SETUP,
834 ":smsc_fdc37m81x_config_beg()\n");
835 smsc_fdc37m81x_config_beg();
836
837 TOSHIBA_RBTX4927_SETUP_DPRINTK
838 (TOSHIBA_RBTX4927_SETUP_SETUP,
839 ":smsc_fdc37m81x_config_set(KBD)\n");
840 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM,
841 SMSC_FDC37M81X_KBD);
842 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1);
843 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12);
844 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE,
845 1);
846
847 smsc_fdc37m81x_config_end();
848 TOSHIBA_RBTX4927_SETUP_DPRINTK
849 (TOSHIBA_RBTX4927_SETUP_SETUP,
850 ":smsc_fdc37m81x_config_end()\n");
851 } else {
852 TOSHIBA_RBTX4927_SETUP_DPRINTK
853 (TOSHIBA_RBTX4927_SETUP_SETUP,
854 ":fpcibo=not_found\n");
855 }
856 }
857#else
858 {
859 TOSHIBA_RBTX4927_SETUP_DPRINTK
860 (TOSHIBA_RBTX4927_SETUP_SETUP, ":fpcibo=no\n");
861 }
862#endif
863
864#endif /* CONFIG_PCI */
865
866#ifdef CONFIG_SERIAL_TXX9
867 {
868 extern int early_serial_txx9_setup(struct uart_port *port);
869 struct uart_port req;
870 for(i = 0; i < 2; i++) {
871 memset(&req, 0, sizeof(req));
872 req.line = i;
873 req.iotype = UPIO_MEM;
874 req.membase = (char *)(0xff1ff300 + i * 0x100);
875 req.mapbase = 0xff1ff300 + i * 0x100;
876 req.irq = TX4927_IRQ_PIC_BEG + 8 + i;
877 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
878 req.uartclk = 50000000;
879 early_serial_txx9_setup(&req);
880 }
881 }
882#ifdef CONFIG_SERIAL_TXX9_CONSOLE
883 argptr = prom_getcmdline();
884 if (strstr(argptr, "console=") == NULL) {
885 strcat(argptr, " console=ttyS0,38400");
886 }
887#endif
888#endif
889
890#ifdef CONFIG_ROOT_NFS
891 argptr = prom_getcmdline();
892 if (strstr(argptr, "root=") == NULL) {
893 strcat(argptr, " root=/dev/nfs rw");
894 }
895#endif
896
897
898#ifdef CONFIG_IP_PNP
899 argptr = prom_getcmdline();
900 if (strstr(argptr, "ip=") == NULL) {
901 strcat(argptr, " ip=any");
902 }
903#endif
904
905
906 TOSHIBA_RBTX4927_SETUP_DPRINTK(TOSHIBA_RBTX4927_SETUP_SETUP,
907 "+\n");
908}
909
910void __init plat_time_init(void)
911{
912 mips_hpt_frequency = tx4927_cpu_clock / 2;
913 if (tx4927_ccfgptr->ccfg & TX4927_CCFG_TINTDIS)
914 txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL,
915 TXX9_IRQ_BASE + 17,
916 50000000);
917}
918
919static int __init toshiba_rbtx4927_rtc_init(void)
920{
921 static struct resource __initdata res = {
922 .start = 0x1c010000,
923 .end = 0x1c010000 + 0x800 - 1,
924 .flags = IORESOURCE_MEM,
925 };
926 struct platform_device *dev =
927 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
928 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
929}
930device_initcall(toshiba_rbtx4927_rtc_init);
931
932static int __init rbtx4927_ne_init(void)
933{
934 static struct resource __initdata res[] = {
935 {
936 .start = RBTX4927_RTL_8019_BASE,
937 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
938 .flags = IORESOURCE_IO,
939 }, {
940 .start = RBTX4927_RTL_8019_IRQ,
941 .flags = IORESOURCE_IRQ,
942 }
943 };
944 struct platform_device *dev =
945 platform_device_register_simple("ne", -1,
946 res, ARRAY_SIZE(res));
947 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
948}
949device_initcall(rbtx4927_ne_init);
950
951/* Watchdog support */
952
953static int __init txx9_wdt_init(unsigned long base)
954{
955 struct resource res = {
956 .start = base,
957 .end = base + 0x100 - 1,
958 .flags = IORESOURCE_MEM,
959 };
960 struct platform_device *dev =
961 platform_device_register_simple("txx9wdt", -1, &res, 1);
962 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
963}
964
965static int __init rbtx4927_wdt_init(void)
966{
967 return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
968}
969device_initcall(rbtx4927_wdt_init);
970
971/* Minimum CLK support */
972
973struct clk *clk_get(struct device *dev, const char *id)
974{
975 if (!strcmp(id, "imbus_clk"))
976 return (struct clk *)50000000;
977 return ERR_PTR(-ENOENT);
978}
979EXPORT_SYMBOL(clk_get);
980
981int clk_enable(struct clk *clk)
982{
983 return 0;
984}
985EXPORT_SYMBOL(clk_enable);
986
987void clk_disable(struct clk *clk)
988{
989}
990EXPORT_SYMBOL(clk_disable);
991
992unsigned long clk_get_rate(struct clk *clk)
993{
994 return (unsigned long)clk;
995}
996EXPORT_SYMBOL(clk_get_rate);
997
998void clk_put(struct clk *clk)
999{
1000}
1001EXPORT_SYMBOL(clk_put);
diff --git a/arch/mips/tx4938/Kconfig b/arch/mips/tx4938/Kconfig
deleted file mode 100644
index d90e9cd8513..00000000000
--- a/arch/mips/tx4938/Kconfig
+++ /dev/null
@@ -1,24 +0,0 @@
1if TOSHIBA_RBTX4938
2
3comment "Multiplex Pin Select"
4choice
5 prompt "PIO[58:61]"
6 default TOSHIBA_RBTX4938_MPLEX_PIO58_61
7
8config TOSHIBA_RBTX4938_MPLEX_PIO58_61
9 bool "PIO"
10config TOSHIBA_RBTX4938_MPLEX_NAND
11 bool "NAND"
12config TOSHIBA_RBTX4938_MPLEX_ATA
13 bool "ATA"
14
15endchoice
16
17config TX4938_NAND_BOOT
18 depends on EXPERIMENTAL && TOSHIBA_RBTX4938_MPLEX_NAND
19 bool "NAND Boot Support (EXPERIMENTAL)"
20 help
21 This is only for Toshiba RBTX4938 reference board, which has NAND IPL.
22 Select this option if you need to use NAND boot.
23
24endif
diff --git a/arch/mips/tx4938/common/Makefile b/arch/mips/tx4938/common/Makefile
deleted file mode 100644
index 56aa1ed1ee0..00000000000
--- a/arch/mips/tx4938/common/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for common code for Toshiba TX4927 based systems
3#
4
5obj-y += prom.o irq.o
6obj-$(CONFIG_KGDB) += dbgio.o
7
8EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
deleted file mode 100644
index c059b899d12..00000000000
--- a/arch/mips/tx4938/common/irq.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 * linux/arch/mips/tx4938/common/irq.c
3 *
4 * Common tx4938 irq handler
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <asm/irq_cpu.h>
17#include <asm/mipsregs.h>
18#include <asm/tx4938/rbtx4938.h>
19
20void __init
21tx4938_irq_init(void)
22{
23 mips_cpu_irq_init();
24 txx9_irq_init(TX4938_IRC_REG);
25 set_irq_chained_handler(TX4938_IRQ_NEST_PIC_ON_CP0, handle_simple_irq);
26}
27
28int toshiba_rbtx4938_irq_nested(int irq);
29
30asmlinkage void plat_irq_dispatch(void)
31{
32 unsigned int pending = read_c0_cause() & read_c0_status();
33
34 if (pending & STATUSF_IP7)
35 do_IRQ(TX4938_IRQ_CPU_TIMER);
36 else if (pending & STATUSF_IP2) {
37 int irq = txx9_irq();
38 if (irq == TX4938_IRQ_PIC_BEG + TX4938_IR_INT(0))
39 irq = toshiba_rbtx4938_irq_nested(irq);
40 if (irq >= 0)
41 do_IRQ(irq);
42 else
43 spurious_interrupt();
44 } else if (pending & STATUSF_IP1)
45 do_IRQ(TX4938_IRQ_USER1);
46 else if (pending & STATUSF_IP0)
47 do_IRQ(TX4938_IRQ_USER0);
48}
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/prom.c b/arch/mips/tx4938/toshiba_rbtx4938/prom.c
deleted file mode 100644
index 1644bffa501..00000000000
--- a/arch/mips/tx4938/toshiba_rbtx4938/prom.c
+++ /dev/null
@@ -1,74 +0,0 @@
1/*
2 * linux/arch/mips/tx4938/toshiba_rbtx4938/prom.c
3 *
4 * rbtx4938 specific prom routines
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/bootmem.h>
19
20#include <asm/addrspace.h>
21#include <asm/bootinfo.h>
22#include <asm/tx4938/tx4938.h>
23
24void __init prom_init_cmdline(void)
25{
26 int argc = (int) fw_arg0;
27 char **argv = (char **) fw_arg1;
28 int i;
29
30 /* ignore all built-in args if any f/w args given */
31 if (argc > 1) {
32 *arcs_cmdline = '\0';
33 }
34
35 for (i = 1; i < argc; i++) {
36 if (i != 1) {
37 strcat(arcs_cmdline, " ");
38 }
39 strcat(arcs_cmdline, argv[i]);
40 }
41}
42
43void __init prom_init(void)
44{
45 extern int tx4938_get_mem_size(void);
46 int msize;
47#ifndef CONFIG_TX4938_NAND_BOOT
48 prom_init_cmdline();
49#endif
50
51 msize = tx4938_get_mem_size();
52 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
53
54 return;
55}
56
57void __init prom_free_prom_memory(void)
58{
59}
60
61void __init prom_fixup_mem_map(unsigned long start, unsigned long end)
62{
63 return;
64}
65
66const char *get_system_type(void)
67{
68 return "Toshiba RBTX4938";
69}
70
71char * __init prom_getcmdline(void)
72{
73 return &(arcs_cmdline[0]);
74}
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/setup.c b/arch/mips/tx4938/toshiba_rbtx4938/setup.c
deleted file mode 100644
index 3a3659e8633..00000000000
--- a/arch/mips/tx4938/toshiba_rbtx4938/setup.c
+++ /dev/null
@@ -1,1124 +0,0 @@
1/*
2 * linux/arch/mips/tx4938/toshiba_rbtx4938/setup.c
3 *
4 * Setup pointers to hardware-dependent routines.
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14#include <linux/init.h>
15#include <linux/types.h>
16#include <linux/ioport.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/console.h>
20#include <linux/pci.h>
21#include <linux/pm.h>
22#include <linux/platform_device.h>
23#include <linux/clk.h>
24#include <linux/gpio.h>
25
26#include <asm/reboot.h>
27#include <asm/time.h>
28#include <asm/txx9tmr.h>
29#include <asm/io.h>
30#include <asm/bootinfo.h>
31#include <asm/tx4938/rbtx4938.h>
32#ifdef CONFIG_SERIAL_TXX9
33#include <linux/serial_core.h>
34#endif
35#include <linux/spi/spi.h>
36#include <asm/tx4938/spi.h>
37#include <asm/txx9pio.h>
38
39extern char * __init prom_getcmdline(void);
40static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr);
41
42/* These functions are used for rebooting or halting the machine*/
43extern void rbtx4938_machine_restart(char *command);
44extern void rbtx4938_machine_halt(void);
45extern void rbtx4938_machine_power_off(void);
46
47/* clocks */
48unsigned int txx9_master_clock;
49unsigned int txx9_cpu_clock;
50unsigned int txx9_gbus_clock;
51
52unsigned long rbtx4938_ce_base[8];
53unsigned long rbtx4938_ce_size[8];
54int txboard_pci66_mode;
55static int tx4938_pcic_trdyto; /* default: disabled */
56static int tx4938_pcic_retryto; /* default: disabled */
57static int tx4938_ccfg_toeon = 1;
58
59struct tx4938_pcic_reg *pcicptrs[4] = {
60 tx4938_pcicptr /* default setting for TX4938 */
61};
62
63static struct {
64 unsigned long base;
65 unsigned long size;
66} phys_regions[16] __initdata;
67static int num_phys_regions __initdata;
68
69#define PHYS_REGION_MINSIZE 0x10000
70
71void rbtx4938_machine_halt(void)
72{
73 printk(KERN_NOTICE "System Halted\n");
74 local_irq_disable();
75
76 while (1)
77 __asm__(".set\tmips3\n\t"
78 "wait\n\t"
79 ".set\tmips0");
80}
81
82void rbtx4938_machine_power_off(void)
83{
84 rbtx4938_machine_halt();
85 /* no return */
86}
87
88void rbtx4938_machine_restart(char *command)
89{
90 local_irq_disable();
91
92 printk("Rebooting...");
93 writeb(1, rbtx4938_softresetlock_addr);
94 writeb(1, rbtx4938_sfvol_addr);
95 writeb(1, rbtx4938_softreset_addr);
96 while(1)
97 ;
98}
99
100void __init
101txboard_add_phys_region(unsigned long base, unsigned long size)
102{
103 if (num_phys_regions >= ARRAY_SIZE(phys_regions)) {
104 printk("phys_region overflow\n");
105 return;
106 }
107 phys_regions[num_phys_regions].base = base;
108 phys_regions[num_phys_regions].size = size;
109 num_phys_regions++;
110}
111unsigned long __init
112txboard_find_free_phys_region(unsigned long begin, unsigned long end,
113 unsigned long size)
114{
115 unsigned long base;
116 int i;
117
118 for (base = begin / size * size; base < end; base += size) {
119 for (i = 0; i < num_phys_regions; i++) {
120 if (phys_regions[i].size &&
121 base <= phys_regions[i].base + (phys_regions[i].size - 1) &&
122 base + (size - 1) >= phys_regions[i].base)
123 break;
124 }
125 if (i == num_phys_regions)
126 return base;
127 }
128 return 0;
129}
130unsigned long __init
131txboard_find_free_phys_region_shrink(unsigned long begin, unsigned long end,
132 unsigned long *size)
133{
134 unsigned long sz, base;
135 for (sz = *size; sz >= PHYS_REGION_MINSIZE; sz /= 2) {
136 base = txboard_find_free_phys_region(begin, end, sz);
137 if (base) {
138 *size = sz;
139 return base;
140 }
141 }
142 return 0;
143}
144unsigned long __init
145txboard_request_phys_region_range(unsigned long begin, unsigned long end,
146 unsigned long size)
147{
148 unsigned long base;
149 base = txboard_find_free_phys_region(begin, end, size);
150 if (base)
151 txboard_add_phys_region(base, size);
152 return base;
153}
154unsigned long __init
155txboard_request_phys_region(unsigned long size)
156{
157 unsigned long base;
158 unsigned long begin = 0, end = 0x20000000; /* search low 512MB */
159 base = txboard_find_free_phys_region(begin, end, size);
160 if (base)
161 txboard_add_phys_region(base, size);
162 return base;
163}
164unsigned long __init
165txboard_request_phys_region_shrink(unsigned long *size)
166{
167 unsigned long base;
168 unsigned long begin = 0, end = 0x20000000; /* search low 512MB */
169 base = txboard_find_free_phys_region_shrink(begin, end, size);
170 if (base)
171 txboard_add_phys_region(base, *size);
172 return base;
173}
174
175#ifdef CONFIG_PCI
176void __init
177tx4938_pcic_setup(struct tx4938_pcic_reg *pcicptr,
178 struct pci_controller *channel,
179 unsigned long pci_io_base,
180 int extarb)
181{
182 int i;
183
184 /* Disable All Initiator Space */
185 pcicptr->pciccfg &= ~(TX4938_PCIC_PCICCFG_G2PMEN(0)|
186 TX4938_PCIC_PCICCFG_G2PMEN(1)|
187 TX4938_PCIC_PCICCFG_G2PMEN(2)|
188 TX4938_PCIC_PCICCFG_G2PIOEN);
189
190 /* GB->PCI mappings */
191 pcicptr->g2piomask = (channel->io_resource->end - channel->io_resource->start) >> 4;
192 pcicptr->g2piogbase = pci_io_base |
193#ifdef __BIG_ENDIAN
194 TX4938_PCIC_G2PIOGBASE_ECHG
195#else
196 TX4938_PCIC_G2PIOGBASE_BSDIS
197#endif
198 ;
199 pcicptr->g2piopbase = 0;
200 for (i = 0; i < 3; i++) {
201 pcicptr->g2pmmask[i] = 0;
202 pcicptr->g2pmgbase[i] = 0;
203 pcicptr->g2pmpbase[i] = 0;
204 }
205 if (channel->mem_resource->end) {
206 pcicptr->g2pmmask[0] = (channel->mem_resource->end - channel->mem_resource->start) >> 4;
207 pcicptr->g2pmgbase[0] = channel->mem_resource->start |
208#ifdef __BIG_ENDIAN
209 TX4938_PCIC_G2PMnGBASE_ECHG
210#else
211 TX4938_PCIC_G2PMnGBASE_BSDIS
212#endif
213 ;
214 pcicptr->g2pmpbase[0] = channel->mem_resource->start;
215 }
216 /* PCI->GB mappings (I/O 256B) */
217 pcicptr->p2giopbase = 0; /* 256B */
218 pcicptr->p2giogbase = 0;
219 /* PCI->GB mappings (MEM 512MB (64MB on R1.x)) */
220 pcicptr->p2gm0plbase = 0;
221 pcicptr->p2gm0pubase = 0;
222 pcicptr->p2gmgbase[0] = 0 |
223 TX4938_PCIC_P2GMnGBASE_TMEMEN |
224#ifdef __BIG_ENDIAN
225 TX4938_PCIC_P2GMnGBASE_TECHG
226#else
227 TX4938_PCIC_P2GMnGBASE_TBSDIS
228#endif
229 ;
230 /* PCI->GB mappings (MEM 16MB) */
231 pcicptr->p2gm1plbase = 0xffffffff;
232 pcicptr->p2gm1pubase = 0xffffffff;
233 pcicptr->p2gmgbase[1] = 0;
234 /* PCI->GB mappings (MEM 1MB) */
235 pcicptr->p2gm2pbase = 0xffffffff; /* 1MB */
236 pcicptr->p2gmgbase[2] = 0;
237
238 pcicptr->pciccfg &= TX4938_PCIC_PCICCFG_GBWC_MASK;
239 /* Enable Initiator Memory Space */
240 if (channel->mem_resource->end)
241 pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PMEN(0);
242 /* Enable Initiator I/O Space */
243 if (channel->io_resource->end)
244 pcicptr->pciccfg |= TX4938_PCIC_PCICCFG_G2PIOEN;
245 /* Enable Initiator Config */
246 pcicptr->pciccfg |=
247 TX4938_PCIC_PCICCFG_ICAEN |
248 TX4938_PCIC_PCICCFG_TCAR;
249
250 /* Do not use MEMMUL, MEMINF: YMFPCI card causes M_ABORT. */
251 pcicptr->pcicfg1 = 0;
252
253 pcicptr->g2ptocnt &= ~0xffff;
254
255 if (tx4938_pcic_trdyto >= 0) {
256 pcicptr->g2ptocnt &= ~0xff;
257 pcicptr->g2ptocnt |= (tx4938_pcic_trdyto & 0xff);
258 }
259
260 if (tx4938_pcic_retryto >= 0) {
261 pcicptr->g2ptocnt &= ~0xff00;
262 pcicptr->g2ptocnt |= ((tx4938_pcic_retryto<<8) & 0xff00);
263 }
264
265 /* Clear All Local Bus Status */
266 pcicptr->pcicstatus = TX4938_PCIC_PCICSTATUS_ALL;
267 /* Enable All Local Bus Interrupts */
268 pcicptr->pcicmask = TX4938_PCIC_PCICSTATUS_ALL;
269 /* Clear All Initiator Status */
270 pcicptr->g2pstatus = TX4938_PCIC_G2PSTATUS_ALL;
271 /* Enable All Initiator Interrupts */
272 pcicptr->g2pmask = TX4938_PCIC_G2PSTATUS_ALL;
273 /* Clear All PCI Status Error */
274 pcicptr->pcistatus =
275 (pcicptr->pcistatus & 0x0000ffff) |
276 (TX4938_PCIC_PCISTATUS_ALL << 16);
277 /* Enable All PCI Status Error Interrupts */
278 pcicptr->pcimask = TX4938_PCIC_PCISTATUS_ALL;
279
280 if (!extarb) {
281 /* Reset Bus Arbiter */
282 pcicptr->pbacfg = TX4938_PCIC_PBACFG_RPBA;
283 pcicptr->pbabm = 0;
284 /* Enable Bus Arbiter */
285 pcicptr->pbacfg = TX4938_PCIC_PBACFG_PBAEN;
286 }
287
288 /* PCIC Int => IRC IRQ16 */
289 pcicptr->pcicfg2 =
290 (pcicptr->pcicfg2 & 0xffffff00) | TX4938_IR_PCIC;
291
292 pcicptr->pcistatus = PCI_COMMAND_MASTER |
293 PCI_COMMAND_MEMORY |
294 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
295}
296
297int __init
298tx4938_report_pciclk(void)
299{
300 unsigned long pcode = TX4938_REV_PCODE();
301 int pciclk = 0;
302 printk("TX%lx PCIC --%s PCICLK:",
303 pcode,
304 (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) ? " PCI66" : "");
305 if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {
306
307 switch ((unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK) {
308 case TX4938_CCFG_PCIDIVMODE_4:
309 pciclk = txx9_cpu_clock / 4; break;
310 case TX4938_CCFG_PCIDIVMODE_4_5:
311 pciclk = txx9_cpu_clock * 2 / 9; break;
312 case TX4938_CCFG_PCIDIVMODE_5:
313 pciclk = txx9_cpu_clock / 5; break;
314 case TX4938_CCFG_PCIDIVMODE_5_5:
315 pciclk = txx9_cpu_clock * 2 / 11; break;
316 case TX4938_CCFG_PCIDIVMODE_8:
317 pciclk = txx9_cpu_clock / 8; break;
318 case TX4938_CCFG_PCIDIVMODE_9:
319 pciclk = txx9_cpu_clock / 9; break;
320 case TX4938_CCFG_PCIDIVMODE_10:
321 pciclk = txx9_cpu_clock / 10; break;
322 case TX4938_CCFG_PCIDIVMODE_11:
323 pciclk = txx9_cpu_clock / 11; break;
324 }
325 printk("Internal(%dMHz)", pciclk / 1000000);
326 } else {
327 printk("External");
328 pciclk = -1;
329 }
330 printk("\n");
331 return pciclk;
332}
333
334void __init set_tx4938_pcicptr(int ch, struct tx4938_pcic_reg *pcicptr)
335{
336 pcicptrs[ch] = pcicptr;
337}
338
339struct tx4938_pcic_reg *get_tx4938_pcicptr(int ch)
340{
341 return pcicptrs[ch];
342}
343
344static struct pci_dev *fake_pci_dev(struct pci_controller *hose,
345 int top_bus, int busnr, int devfn)
346{
347 static struct pci_dev dev;
348 static struct pci_bus bus;
349
350 dev.sysdata = bus.sysdata = hose;
351 dev.devfn = devfn;
352 bus.number = busnr;
353 bus.ops = hose->pci_ops;
354 bus.parent = NULL;
355 dev.bus = &bus;
356
357 return &dev;
358}
359
360#define EARLY_PCI_OP(rw, size, type) \
361static int early_##rw##_config_##size(struct pci_controller *hose, \
362 int top_bus, int bus, int devfn, int offset, type value) \
363{ \
364 return pci_##rw##_config_##size( \
365 fake_pci_dev(hose, top_bus, bus, devfn), \
366 offset, value); \
367}
368
369EARLY_PCI_OP(read, word, u16 *)
370
371int txboard_pci66_check(struct pci_controller *hose, int top_bus, int current_bus)
372{
373 u32 pci_devfn;
374 unsigned short vid;
375 int devfn_start = 0;
376 int devfn_stop = 0xff;
377 int cap66 = -1;
378 u16 stat;
379
380 printk("PCI: Checking 66MHz capabilities...\n");
381
382 for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
383 if (early_read_config_word(hose, top_bus, current_bus,
384 pci_devfn, PCI_VENDOR_ID,
385 &vid) != PCIBIOS_SUCCESSFUL)
386 continue;
387
388 if (vid == 0xffff) continue;
389
390 /* check 66MHz capability */
391 if (cap66 < 0)
392 cap66 = 1;
393 if (cap66) {
394 early_read_config_word(hose, top_bus, current_bus, pci_devfn,
395 PCI_STATUS, &stat);
396 if (!(stat & PCI_STATUS_66MHZ)) {
397 printk(KERN_DEBUG "PCI: %02x:%02x not 66MHz capable.\n",
398 current_bus, pci_devfn);
399 cap66 = 0;
400 break;
401 }
402 }
403 }
404 return cap66 > 0;
405}
406
407int __init
408tx4938_pciclk66_setup(void)
409{
410 int pciclk;
411
412 /* Assert M66EN */
413 tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI66;
414 /* Double PCICLK (if possible) */
415 if (tx4938_ccfgptr->pcfg & TX4938_PCFG_PCICLKEN_ALL) {
416 unsigned int pcidivmode =
417 tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIDIVMODE_MASK;
418 switch (pcidivmode) {
419 case TX4938_CCFG_PCIDIVMODE_8:
420 case TX4938_CCFG_PCIDIVMODE_4:
421 pcidivmode = TX4938_CCFG_PCIDIVMODE_4;
422 pciclk = txx9_cpu_clock / 4;
423 break;
424 case TX4938_CCFG_PCIDIVMODE_9:
425 case TX4938_CCFG_PCIDIVMODE_4_5:
426 pcidivmode = TX4938_CCFG_PCIDIVMODE_4_5;
427 pciclk = txx9_cpu_clock * 2 / 9;
428 break;
429 case TX4938_CCFG_PCIDIVMODE_10:
430 case TX4938_CCFG_PCIDIVMODE_5:
431 pcidivmode = TX4938_CCFG_PCIDIVMODE_5;
432 pciclk = txx9_cpu_clock / 5;
433 break;
434 case TX4938_CCFG_PCIDIVMODE_11:
435 case TX4938_CCFG_PCIDIVMODE_5_5:
436 default:
437 pcidivmode = TX4938_CCFG_PCIDIVMODE_5_5;
438 pciclk = txx9_cpu_clock * 2 / 11;
439 break;
440 }
441 tx4938_ccfgptr->ccfg =
442 (tx4938_ccfgptr->ccfg & ~TX4938_CCFG_PCIDIVMODE_MASK)
443 | pcidivmode;
444 printk(KERN_DEBUG "PCICLK: ccfg:%08lx\n",
445 (unsigned long)tx4938_ccfgptr->ccfg);
446 } else {
447 pciclk = -1;
448 }
449 return pciclk;
450}
451
452extern struct pci_controller tx4938_pci_controller[];
453static int __init tx4938_pcibios_init(void)
454{
455 unsigned long mem_base[2];
456 unsigned long mem_size[2] = {TX4938_PCIMEM_SIZE_0, TX4938_PCIMEM_SIZE_1}; /* MAX 128M,64K */
457 unsigned long io_base[2];
458 unsigned long io_size[2] = {TX4938_PCIIO_SIZE_0, TX4938_PCIIO_SIZE_1}; /* MAX 16M,64K */
459 /* TX4938 PCIC1: 64K MEM/IO is enough for ETH0,ETH1 */
460 int extarb = !(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB);
461
462 PCIBIOS_MIN_IO = 0x00001000UL;
463
464 mem_base[0] = txboard_request_phys_region_shrink(&mem_size[0]);
465 io_base[0] = txboard_request_phys_region_shrink(&io_size[0]);
466
467 printk("TX4938 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:%s\n",
468 (unsigned short)(tx4938_pcicptr->pciid >> 16),
469 (unsigned short)(tx4938_pcicptr->pciid & 0xffff),
470 (unsigned short)(tx4938_pcicptr->pciccrev & 0xff),
471 extarb ? "External" : "Internal");
472
473 /* setup PCI area */
474 tx4938_pci_controller[0].io_resource->start = io_base[0];
475 tx4938_pci_controller[0].io_resource->end = (io_base[0] + io_size[0]) - 1;
476 tx4938_pci_controller[0].mem_resource->start = mem_base[0];
477 tx4938_pci_controller[0].mem_resource->end = mem_base[0] + mem_size[0] - 1;
478
479 set_tx4938_pcicptr(0, tx4938_pcicptr);
480
481 register_pci_controller(&tx4938_pci_controller[0]);
482
483 if (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI66) {
484 printk("TX4938_CCFG_PCI66 already configured\n");
485 txboard_pci66_mode = -1; /* already configured */
486 }
487
488 /* Reset PCI Bus */
489 writeb(0, rbtx4938_pcireset_addr);
490 /* Reset PCIC */
491 tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;
492 if (txboard_pci66_mode > 0)
493 tx4938_pciclk66_setup();
494 mdelay(10);
495 /* clear PCIC reset */
496 tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;
497 writeb(1, rbtx4938_pcireset_addr);
498 mmiowb();
499 tx4938_report_pcic_status1(tx4938_pcicptr);
500
501 tx4938_report_pciclk();
502 tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);
503 if (txboard_pci66_mode == 0 &&
504 txboard_pci66_check(&tx4938_pci_controller[0], 0, 0)) {
505 /* Reset PCI Bus */
506 writeb(0, rbtx4938_pcireset_addr);
507 /* Reset PCIC */
508 tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIRST;
509 tx4938_pciclk66_setup();
510 mdelay(10);
511 /* clear PCIC reset */
512 tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIRST;
513 writeb(1, rbtx4938_pcireset_addr);
514 mmiowb();
515 /* Reinitialize PCIC */
516 tx4938_report_pciclk();
517 tx4938_pcic_setup(tx4938_pcicptr, &tx4938_pci_controller[0], io_base[0], extarb);
518 }
519
520 mem_base[1] = txboard_request_phys_region_shrink(&mem_size[1]);
521 io_base[1] = txboard_request_phys_region_shrink(&io_size[1]);
522 /* Reset PCIC1 */
523 tx4938_ccfgptr->clkctr |= TX4938_CLKCTR_PCIC1RST;
524 /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */
525 if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD))
526 tx4938_ccfgptr->ccfg |= TX4938_CCFG_PCI1_66;
527 else
528 tx4938_ccfgptr->ccfg &= ~TX4938_CCFG_PCI1_66;
529 mdelay(10);
530 /* clear PCIC1 reset */
531 tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;
532 tx4938_report_pcic_status1(tx4938_pcic1ptr);
533
534 printk("TX4938 PCIC1 -- DID:%04x VID:%04x RID:%02x",
535 (unsigned short)(tx4938_pcic1ptr->pciid >> 16),
536 (unsigned short)(tx4938_pcic1ptr->pciid & 0xffff),
537 (unsigned short)(tx4938_pcic1ptr->pciccrev & 0xff));
538 printk("%s PCICLK:%dMHz\n",
539 (tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1_66) ? " PCI66" : "",
540 txx9_gbus_clock /
541 ((tx4938_ccfgptr->ccfg & TX4938_CCFG_PCI1DMD) ? 4 : 2) /
542 1000000);
543
544 /* assumption: CPHYSADDR(mips_io_port_base) == io_base[0] */
545 tx4938_pci_controller[1].io_resource->start =
546 io_base[1] - io_base[0];
547 tx4938_pci_controller[1].io_resource->end =
548 io_base[1] - io_base[0] + io_size[1] - 1;
549 tx4938_pci_controller[1].mem_resource->start = mem_base[1];
550 tx4938_pci_controller[1].mem_resource->end =
551 mem_base[1] + mem_size[1] - 1;
552 set_tx4938_pcicptr(1, tx4938_pcic1ptr);
553
554 register_pci_controller(&tx4938_pci_controller[1]);
555
556 tx4938_pcic_setup(tx4938_pcic1ptr, &tx4938_pci_controller[1], io_base[1], extarb);
557
558 /* map ioport 0 to PCI I/O space address 0 */
559 set_io_port_base(KSEG1 + io_base[0]);
560
561 return 0;
562}
563
564arch_initcall(tx4938_pcibios_init);
565
566#endif /* CONFIG_PCI */
567
568/* SPI support */
569
570/* chip select for SPI devices */
571#define SEEPROM1_CS 7 /* PIO7 */
572#define SEEPROM2_CS 0 /* IOC */
573#define SEEPROM3_CS 1 /* IOC */
574#define SRTC_CS 2 /* IOC */
575
576#ifdef CONFIG_PCI
577static int __init rbtx4938_ethaddr_init(void)
578{
579 unsigned char dat[17];
580 unsigned char sum;
581 int i;
582
583 /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */
584 if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) {
585 printk(KERN_ERR "seeprom: read error.\n");
586 return -ENODEV;
587 } else {
588 if (strcmp(dat, "MAC") != 0)
589 printk(KERN_WARNING "seeprom: bad signature.\n");
590 for (i = 0, sum = 0; i < sizeof(dat); i++)
591 sum += dat[i];
592 if (sum)
593 printk(KERN_WARNING "seeprom: bad checksum.\n");
594 }
595 for (i = 0; i < 2; i++) {
596 unsigned int id =
597 TXX9_IRQ_BASE + (i ? TX4938_IR_ETH1 : TX4938_IR_ETH0);
598 struct platform_device *pdev;
599 if (!(tx4938_ccfgptr->pcfg &
600 (i ? TX4938_PCFG_ETH1_SEL : TX4938_PCFG_ETH0_SEL)))
601 continue;
602 pdev = platform_device_alloc("tc35815-mac", id);
603 if (!pdev ||
604 platform_device_add_data(pdev, &dat[4 + 6 * i], 6) ||
605 platform_device_add(pdev))
606 platform_device_put(pdev);
607 }
608 return 0;
609}
610device_initcall(rbtx4938_ethaddr_init);
611#endif /* CONFIG_PCI */
612
613static void __init rbtx4938_spi_setup(void)
614{
615 /* set SPI_SEL */
616 tx4938_ccfgptr->pcfg |= TX4938_PCFG_SPI_SEL;
617}
618
619static struct resource rbtx4938_fpga_resource;
620
621static char pcode_str[8];
622static struct resource tx4938_reg_resource = {
623 .start = TX4938_REG_BASE,
624 .end = TX4938_REG_BASE + TX4938_REG_SIZE,
625 .name = pcode_str,
626 .flags = IORESOURCE_MEM
627};
628
629void __init tx4938_board_setup(void)
630{
631 int i;
632 unsigned long divmode;
633 int cpuclk = 0;
634 unsigned long pcode = TX4938_REV_PCODE();
635
636 ioport_resource.start = 0x1000;
637 ioport_resource.end = 0xffffffff;
638 iomem_resource.start = 0x1000;
639 iomem_resource.end = 0xffffffff; /* expand to 4GB */
640
641 sprintf(pcode_str, "TX%lx", pcode);
642 /* SDRAMC,EBUSC are configured by PROM */
643 for (i = 0; i < 8; i++) {
644 if (!(tx4938_ebuscptr->cr[i] & 0x8))
645 continue; /* disabled */
646 rbtx4938_ce_base[i] = (unsigned long)TX4938_EBUSC_BA(i);
647 txboard_add_phys_region(rbtx4938_ce_base[i], TX4938_EBUSC_SIZE(i));
648 }
649
650 /* clocks */
651 if (txx9_master_clock) {
652 /* calculate gbus_clock and cpu_clock_freq from master_clock */
653 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
654 switch (divmode) {
655 case TX4938_CCFG_DIVMODE_8:
656 case TX4938_CCFG_DIVMODE_10:
657 case TX4938_CCFG_DIVMODE_12:
658 case TX4938_CCFG_DIVMODE_16:
659 case TX4938_CCFG_DIVMODE_18:
660 txx9_gbus_clock = txx9_master_clock * 4; break;
661 default:
662 txx9_gbus_clock = txx9_master_clock;
663 }
664 switch (divmode) {
665 case TX4938_CCFG_DIVMODE_2:
666 case TX4938_CCFG_DIVMODE_8:
667 cpuclk = txx9_gbus_clock * 2; break;
668 case TX4938_CCFG_DIVMODE_2_5:
669 case TX4938_CCFG_DIVMODE_10:
670 cpuclk = txx9_gbus_clock * 5 / 2; break;
671 case TX4938_CCFG_DIVMODE_3:
672 case TX4938_CCFG_DIVMODE_12:
673 cpuclk = txx9_gbus_clock * 3; break;
674 case TX4938_CCFG_DIVMODE_4:
675 case TX4938_CCFG_DIVMODE_16:
676 cpuclk = txx9_gbus_clock * 4; break;
677 case TX4938_CCFG_DIVMODE_4_5:
678 case TX4938_CCFG_DIVMODE_18:
679 cpuclk = txx9_gbus_clock * 9 / 2; break;
680 }
681 txx9_cpu_clock = cpuclk;
682 } else {
683 if (txx9_cpu_clock == 0) {
684 txx9_cpu_clock = 300000000; /* 300MHz */
685 }
686 /* calculate gbus_clock and master_clock from cpu_clock_freq */
687 cpuclk = txx9_cpu_clock;
688 divmode = (unsigned long)tx4938_ccfgptr->ccfg & TX4938_CCFG_DIVMODE_MASK;
689 switch (divmode) {
690 case TX4938_CCFG_DIVMODE_2:
691 case TX4938_CCFG_DIVMODE_8:
692 txx9_gbus_clock = cpuclk / 2; break;
693 case TX4938_CCFG_DIVMODE_2_5:
694 case TX4938_CCFG_DIVMODE_10:
695 txx9_gbus_clock = cpuclk * 2 / 5; break;
696 case TX4938_CCFG_DIVMODE_3:
697 case TX4938_CCFG_DIVMODE_12:
698 txx9_gbus_clock = cpuclk / 3; break;
699 case TX4938_CCFG_DIVMODE_4:
700 case TX4938_CCFG_DIVMODE_16:
701 txx9_gbus_clock = cpuclk / 4; break;
702 case TX4938_CCFG_DIVMODE_4_5:
703 case TX4938_CCFG_DIVMODE_18:
704 txx9_gbus_clock = cpuclk * 2 / 9; break;
705 }
706 switch (divmode) {
707 case TX4938_CCFG_DIVMODE_8:
708 case TX4938_CCFG_DIVMODE_10:
709 case TX4938_CCFG_DIVMODE_12:
710 case TX4938_CCFG_DIVMODE_16:
711 case TX4938_CCFG_DIVMODE_18:
712 txx9_master_clock = txx9_gbus_clock / 4; break;
713 default:
714 txx9_master_clock = txx9_gbus_clock;
715 }
716 }
717 /* change default value to udelay/mdelay take reasonable time */
718 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
719
720 /* CCFG */
721 /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */
722 tx4938_ccfgptr->ccfg |= TX4938_CCFG_WDRST | TX4938_CCFG_BEOW;
723 /* do reset on watchdog */
724 tx4938_ccfgptr->ccfg |= TX4938_CCFG_WR;
725 /* clear PCIC1 reset */
726 if (tx4938_ccfgptr->clkctr & TX4938_CLKCTR_PCIC1RST)
727 tx4938_ccfgptr->clkctr &= ~TX4938_CLKCTR_PCIC1RST;
728
729 /* enable Timeout BusError */
730 if (tx4938_ccfg_toeon)
731 tx4938_ccfgptr->ccfg |= TX4938_CCFG_TOE;
732
733 /* DMA selection */
734 tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_DMASEL_ALL;
735
736 /* Use external clock for external arbiter */
737 if (!(tx4938_ccfgptr->ccfg & TX4938_CCFG_PCIXARB))
738 tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_PCICLKEN_ALL;
739
740 printk("%s -- %dMHz(M%dMHz) CRIR:%08lx CCFG:%Lx PCFG:%Lx\n",
741 pcode_str,
742 cpuclk / 1000000, txx9_master_clock / 1000000,
743 (unsigned long)tx4938_ccfgptr->crir,
744 tx4938_ccfgptr->ccfg,
745 tx4938_ccfgptr->pcfg);
746
747 printk("%s SDRAMC --", pcode_str);
748 for (i = 0; i < 4; i++) {
749 unsigned long long cr = tx4938_sdramcptr->cr[i];
750 unsigned long ram_base, ram_size;
751 if (!((unsigned long)cr & 0x00000400))
752 continue; /* disabled */
753 ram_base = (unsigned long)(cr >> 49) << 21;
754 ram_size = ((unsigned long)(cr >> 33) + 1) << 21;
755 if (ram_base >= 0x20000000)
756 continue; /* high memory (ignore) */
757 printk(" CR%d:%016Lx", i, cr);
758 txboard_add_phys_region(ram_base, ram_size);
759 }
760 printk(" TR:%09Lx\n", tx4938_sdramcptr->tr);
761
762 /* SRAM */
763 if (pcode == 0x4938 && tx4938_sramcptr->cr & 1) {
764 unsigned int size = 0x800;
765 unsigned long base =
766 (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1);
767 txboard_add_phys_region(base, size);
768 }
769
770 /* TMR */
771 for (i = 0; i < TX4938_NR_TMR; i++)
772 txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
773
774 /* enable DMA */
775 for (i = 0; i < 2; i++)
776 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
777 (void __iomem *)(TX4938_DMA_REG(i) + 0x50));
778
779 /* PIO */
780 __raw_writel(0, &tx4938_pioptr->maskcpu);
781 __raw_writel(0, &tx4938_pioptr->maskext);
782
783 /* TX4938 internal registers */
784 if (request_resource(&iomem_resource, &tx4938_reg_resource))
785 printk("request resource for internal registers failed\n");
786}
787
788#ifdef CONFIG_PCI
789static inline void tx4938_report_pcic_status1(struct tx4938_pcic_reg *pcicptr)
790{
791 unsigned short pcistatus = (unsigned short)(pcicptr->pcistatus >> 16);
792 unsigned long g2pstatus = pcicptr->g2pstatus;
793 unsigned long pcicstatus = pcicptr->pcicstatus;
794 static struct {
795 unsigned long flag;
796 const char *str;
797 } pcistat_tbl[] = {
798 { PCI_STATUS_DETECTED_PARITY, "DetectedParityError" },
799 { PCI_STATUS_SIG_SYSTEM_ERROR, "SignaledSystemError" },
800 { PCI_STATUS_REC_MASTER_ABORT, "ReceivedMasterAbort" },
801 { PCI_STATUS_REC_TARGET_ABORT, "ReceivedTargetAbort" },
802 { PCI_STATUS_SIG_TARGET_ABORT, "SignaledTargetAbort" },
803 { PCI_STATUS_PARITY, "MasterParityError" },
804 }, g2pstat_tbl[] = {
805 { TX4938_PCIC_G2PSTATUS_TTOE, "TIOE" },
806 { TX4938_PCIC_G2PSTATUS_RTOE, "RTOE" },
807 }, pcicstat_tbl[] = {
808 { TX4938_PCIC_PCICSTATUS_PME, "PME" },
809 { TX4938_PCIC_PCICSTATUS_TLB, "TLB" },
810 { TX4938_PCIC_PCICSTATUS_NIB, "NIB" },
811 { TX4938_PCIC_PCICSTATUS_ZIB, "ZIB" },
812 { TX4938_PCIC_PCICSTATUS_PERR, "PERR" },
813 { TX4938_PCIC_PCICSTATUS_SERR, "SERR" },
814 { TX4938_PCIC_PCICSTATUS_GBE, "GBE" },
815 { TX4938_PCIC_PCICSTATUS_IWB, "IWB" },
816 };
817 int i;
818
819 printk("pcistat:%04x(", pcistatus);
820 for (i = 0; i < ARRAY_SIZE(pcistat_tbl); i++)
821 if (pcistatus & pcistat_tbl[i].flag)
822 printk("%s ", pcistat_tbl[i].str);
823 printk("), g2pstatus:%08lx(", g2pstatus);
824 for (i = 0; i < ARRAY_SIZE(g2pstat_tbl); i++)
825 if (g2pstatus & g2pstat_tbl[i].flag)
826 printk("%s ", g2pstat_tbl[i].str);
827 printk("), pcicstatus:%08lx(", pcicstatus);
828 for (i = 0; i < ARRAY_SIZE(pcicstat_tbl); i++)
829 if (pcicstatus & pcicstat_tbl[i].flag)
830 printk("%s ", pcicstat_tbl[i].str);
831 printk(")\n");
832}
833
834void tx4938_report_pcic_status(void)
835{
836 int i;
837 struct tx4938_pcic_reg *pcicptr;
838 for (i = 0; (pcicptr = get_tx4938_pcicptr(i)) != NULL; i++)
839 tx4938_report_pcic_status1(pcicptr);
840}
841
842#endif /* CONFIG_PCI */
843
844void __init plat_time_init(void)
845{
846 mips_hpt_frequency = txx9_cpu_clock / 2;
847 if (tx4938_ccfgptr->ccfg & TX4938_CCFG_TINTDIS)
848 txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL,
849 TXX9_IRQ_BASE + TX4938_IR_TMR(0),
850 txx9_gbus_clock / 2);
851}
852
853void __init plat_mem_setup(void)
854{
855 unsigned long long pcfg;
856 char *argptr;
857
858 iomem_resource.end = 0xffffffff; /* 4GB */
859
860 if (txx9_master_clock == 0)
861 txx9_master_clock = 25000000; /* 25MHz */
862 tx4938_board_setup();
863#ifndef CONFIG_PCI
864 set_io_port_base(RBTX4938_ETHER_BASE);
865#endif
866
867#ifdef CONFIG_SERIAL_TXX9
868 {
869 extern int early_serial_txx9_setup(struct uart_port *port);
870 int i;
871 struct uart_port req;
872 for(i = 0; i < 2; i++) {
873 memset(&req, 0, sizeof(req));
874 req.line = i;
875 req.iotype = UPIO_MEM;
876 req.membase = (char *)(0xff1ff300 + i * 0x100);
877 req.mapbase = 0xff1ff300 + i * 0x100;
878 req.irq = RBTX4938_IRQ_IRC_SIO(i);
879 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
880 req.uartclk = 50000000;
881 early_serial_txx9_setup(&req);
882 }
883 }
884#ifdef CONFIG_SERIAL_TXX9_CONSOLE
885 argptr = prom_getcmdline();
886 if (strstr(argptr, "console=") == NULL) {
887 strcat(argptr, " console=ttyS0,38400");
888 }
889#endif
890#endif
891
892#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
893 printk("PIOSEL: disabling both ata and nand selection\n");
894 local_irq_disable();
895 tx4938_ccfgptr->pcfg &= ~(TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);
896#endif
897
898#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND
899 printk("PIOSEL: enabling nand selection\n");
900 tx4938_ccfgptr->pcfg |= TX4938_PCFG_NDF_SEL;
901 tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_ATA_SEL;
902#endif
903
904#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA
905 printk("PIOSEL: enabling ata selection\n");
906 tx4938_ccfgptr->pcfg |= TX4938_PCFG_ATA_SEL;
907 tx4938_ccfgptr->pcfg &= ~TX4938_PCFG_NDF_SEL;
908#endif
909
910#ifdef CONFIG_IP_PNP
911 argptr = prom_getcmdline();
912 if (strstr(argptr, "ip=") == NULL) {
913 strcat(argptr, " ip=any");
914 }
915#endif
916
917
918#ifdef CONFIG_FB
919 {
920 conswitchp = &dummy_con;
921 }
922#endif
923
924 rbtx4938_spi_setup();
925 pcfg = tx4938_ccfgptr->pcfg; /* updated */
926 /* fixup piosel */
927 if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
928 TX4938_PCFG_ATA_SEL)
929 writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04,
930 rbtx4938_piosel_addr);
931 else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
932 TX4938_PCFG_NDF_SEL)
933 writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08,
934 rbtx4938_piosel_addr);
935 else
936 writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04),
937 rbtx4938_piosel_addr);
938
939 rbtx4938_fpga_resource.name = "FPGA Registers";
940 rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);
941 rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;
942 rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
943 if (request_resource(&iomem_resource, &rbtx4938_fpga_resource))
944 printk("request resource for fpga failed\n");
945
946 _machine_restart = rbtx4938_machine_restart;
947 _machine_halt = rbtx4938_machine_halt;
948 pm_power_off = rbtx4938_machine_power_off;
949
950 writeb(0xff, rbtx4938_led_addr);
951 printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",
952 readb(rbtx4938_fpga_rev_addr),
953 readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr));
954}
955
956static int __init rbtx4938_ne_init(void)
957{
958 struct resource res[] = {
959 {
960 .start = RBTX4938_RTL_8019_BASE,
961 .end = RBTX4938_RTL_8019_BASE + 0x20 - 1,
962 .flags = IORESOURCE_IO,
963 }, {
964 .start = RBTX4938_RTL_8019_IRQ,
965 .flags = IORESOURCE_IRQ,
966 }
967 };
968 struct platform_device *dev =
969 platform_device_register_simple("ne", -1,
970 res, ARRAY_SIZE(res));
971 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
972}
973device_initcall(rbtx4938_ne_init);
974
975/* GPIO support */
976
977int gpio_to_irq(unsigned gpio)
978{
979 return -EINVAL;
980}
981
982int irq_to_gpio(unsigned irq)
983{
984 return -EINVAL;
985}
986
987static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock);
988
989static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset,
990 int value)
991{
992 u8 val;
993 unsigned long flags;
994 spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags);
995 val = readb(rbtx4938_spics_addr);
996 if (value)
997 val |= 1 << offset;
998 else
999 val &= ~(1 << offset);
1000 writeb(val, rbtx4938_spics_addr);
1001 mmiowb();
1002 spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags);
1003}
1004
1005static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip,
1006 unsigned int offset, int value)
1007{
1008 rbtx4938_spi_gpio_set(chip, offset, value);
1009 return 0;
1010}
1011
1012static struct gpio_chip rbtx4938_spi_gpio_chip = {
1013 .set = rbtx4938_spi_gpio_set,
1014 .direction_output = rbtx4938_spi_gpio_dir_out,
1015 .label = "RBTX4938-SPICS",
1016 .base = 16,
1017 .ngpio = 3,
1018};
1019
1020/* SPI support */
1021
1022static void __init txx9_spi_init(unsigned long base, int irq)
1023{
1024 struct resource res[] = {
1025 {
1026 .start = base,
1027 .end = base + 0x20 - 1,
1028 .flags = IORESOURCE_MEM,
1029 }, {
1030 .start = irq,
1031 .flags = IORESOURCE_IRQ,
1032 },
1033 };
1034 platform_device_register_simple("spi_txx9", 0,
1035 res, ARRAY_SIZE(res));
1036}
1037
1038static int __init rbtx4938_spi_init(void)
1039{
1040 struct spi_board_info srtc_info = {
1041 .modalias = "rtc-rs5c348",
1042 .max_speed_hz = 1000000, /* 1.0Mbps @ Vdd 2.0V */
1043 .bus_num = 0,
1044 .chip_select = 16 + SRTC_CS,
1045 /* Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS */
1046 .mode = SPI_MODE_1 | SPI_CS_HIGH,
1047 };
1048 spi_register_board_info(&srtc_info, 1);
1049 spi_eeprom_register(SEEPROM1_CS);
1050 spi_eeprom_register(16 + SEEPROM2_CS);
1051 spi_eeprom_register(16 + SEEPROM3_CS);
1052 gpio_request(16 + SRTC_CS, "rtc-rs5c348");
1053 gpio_direction_output(16 + SRTC_CS, 0);
1054 gpio_request(SEEPROM1_CS, "seeprom1");
1055 gpio_direction_output(SEEPROM1_CS, 1);
1056 gpio_request(16 + SEEPROM2_CS, "seeprom2");
1057 gpio_direction_output(16 + SEEPROM2_CS, 1);
1058 gpio_request(16 + SEEPROM3_CS, "seeprom3");
1059 gpio_direction_output(16 + SEEPROM3_CS, 1);
1060 txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI);
1061 return 0;
1062}
1063
1064static int __init rbtx4938_arch_init(void)
1065{
1066 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16);
1067 gpiochip_add(&rbtx4938_spi_gpio_chip);
1068 return rbtx4938_spi_init();
1069}
1070arch_initcall(rbtx4938_arch_init);
1071
1072/* Watchdog support */
1073
1074static int __init txx9_wdt_init(unsigned long base)
1075{
1076 struct resource res = {
1077 .start = base,
1078 .end = base + 0x100 - 1,
1079 .flags = IORESOURCE_MEM,
1080 };
1081 struct platform_device *dev =
1082 platform_device_register_simple("txx9wdt", -1, &res, 1);
1083 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
1084}
1085
1086static int __init rbtx4938_wdt_init(void)
1087{
1088 return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL);
1089}
1090device_initcall(rbtx4938_wdt_init);
1091
1092/* Minimum CLK support */
1093
1094struct clk *clk_get(struct device *dev, const char *id)
1095{
1096 if (!strcmp(id, "spi-baseclk"))
1097 return (struct clk *)(txx9_gbus_clock / 2 / 4);
1098 if (!strcmp(id, "imbus_clk"))
1099 return (struct clk *)(txx9_gbus_clock / 2);
1100 return ERR_PTR(-ENOENT);
1101}
1102EXPORT_SYMBOL(clk_get);
1103
1104int clk_enable(struct clk *clk)
1105{
1106 return 0;
1107}
1108EXPORT_SYMBOL(clk_enable);
1109
1110void clk_disable(struct clk *clk)
1111{
1112}
1113EXPORT_SYMBOL(clk_disable);
1114
1115unsigned long clk_get_rate(struct clk *clk)
1116{
1117 return (unsigned long)clk;
1118}
1119EXPORT_SYMBOL(clk_get_rate);
1120
1121void clk_put(struct clk *clk)
1122{
1123}
1124EXPORT_SYMBOL(clk_put);
diff --git a/arch/mips/txx9/Kconfig b/arch/mips/txx9/Kconfig
new file mode 100644
index 00000000000..b92a134ef12
--- /dev/null
+++ b/arch/mips/txx9/Kconfig
@@ -0,0 +1,115 @@
1config TOSHIBA_JMR3927
2 bool "Toshiba JMR-TX3927 board"
3 depends on MACH_TX39XX
4 select SOC_TX3927
5
6config TOSHIBA_RBTX4927
7 bool "Toshiba RBTX49[23]7 board"
8 depends on MACH_TX49XX
9 select SOC_TX4927
10 help
11 This Toshiba board is based on the TX4927 processor. Say Y here to
12 support this machine type
13
14config TOSHIBA_RBTX4938
15 bool "Toshiba RBTX4938 board"
16 depends on MACH_TX49XX
17 select SOC_TX4938
18 help
19 This Toshiba board is based on the TX4938 processor. Say Y here to
20 support this machine type
21
22config SOC_TX3927
23 bool
24 select CEVT_TXX9
25 select DMA_NONCOHERENT
26 select HAS_TXX9_SERIAL
27 select HW_HAS_PCI
28 select IRQ_TXX9
29 select SWAP_IO_SPACE
30 select SYS_HAS_CPU_TX39XX
31 select SYS_SUPPORTS_32BIT_KERNEL
32 select SYS_SUPPORTS_LITTLE_ENDIAN
33 select SYS_SUPPORTS_BIG_ENDIAN
34 select GENERIC_HARDIRQS_NO__DO_IRQ
35 select GPIO_TXX9
36
37config SOC_TX4927
38 bool
39 select CEVT_R4K
40 select CSRC_R4K
41 select CEVT_TXX9
42 select DMA_NONCOHERENT
43 select HAS_TXX9_SERIAL
44 select HW_HAS_PCI
45 select IRQ_CPU
46 select IRQ_TXX9
47 select PCI_TX4927
48 select SWAP_IO_SPACE
49 select SYS_HAS_CPU_TX49XX
50 select SYS_SUPPORTS_32BIT_KERNEL
51 select SYS_SUPPORTS_64BIT_KERNEL
52 select SYS_SUPPORTS_LITTLE_ENDIAN
53 select SYS_SUPPORTS_BIG_ENDIAN
54 select SYS_SUPPORTS_KGDB
55 select GENERIC_HARDIRQS_NO__DO_IRQ
56 select GPIO_TXX9
57
58config SOC_TX4938
59 bool
60 select CEVT_R4K
61 select CSRC_R4K
62 select CEVT_TXX9
63 select DMA_NONCOHERENT
64 select HAS_TXX9_SERIAL
65 select HW_HAS_PCI
66 select IRQ_CPU
67 select IRQ_TXX9
68 select PCI_TX4927
69 select SWAP_IO_SPACE
70 select SYS_HAS_CPU_TX49XX
71 select SYS_SUPPORTS_32BIT_KERNEL
72 select SYS_SUPPORTS_64BIT_KERNEL
73 select SYS_SUPPORTS_LITTLE_ENDIAN
74 select SYS_SUPPORTS_BIG_ENDIAN
75 select SYS_SUPPORTS_KGDB
76 select GENERIC_HARDIRQS_NO__DO_IRQ
77 select GPIO_TXX9
78
79config TOSHIBA_FPCIB0
80 bool "FPCIB0 Backplane Support"
81 depends on PCI && (MACH_TX39XX || MACH_TX49XX)
82 select I8259
83
84config PICMG_PCI_BACKPLANE_DEFAULT
85 bool "Support for PICMG PCI Backplane"
86 depends on PCI && (MACH_TX39XX || MACH_TX49XX)
87 default y if !TOSHIBA_FPCIB0
88
89if TOSHIBA_RBTX4938
90
91comment "Multiplex Pin Select"
92choice
93 prompt "PIO[58:61]"
94 default TOSHIBA_RBTX4938_MPLEX_PIO58_61
95
96config TOSHIBA_RBTX4938_MPLEX_PIO58_61
97 bool "PIO"
98config TOSHIBA_RBTX4938_MPLEX_NAND
99 bool "NAND"
100config TOSHIBA_RBTX4938_MPLEX_ATA
101 bool "ATA"
102
103endchoice
104
105config TX4938_NAND_BOOT
106 depends on EXPERIMENTAL && TOSHIBA_RBTX4938_MPLEX_NAND
107 bool "NAND Boot Support (EXPERIMENTAL)"
108 help
109 This is only for Toshiba RBTX4938 reference board, which has NAND IPL.
110 Select this option if you need to use NAND boot.
111
112endif
113
114config PCI_TX4927
115 bool
diff --git a/arch/mips/txx9/generic/Makefile b/arch/mips/txx9/generic/Makefile
new file mode 100644
index 00000000000..668fdaad644
--- /dev/null
+++ b/arch/mips/txx9/generic/Makefile
@@ -0,0 +1,12 @@
1#
2# Makefile for common code for TXx9 based systems
3#
4
5obj-y += setup.o
6obj-$(CONFIG_PCI) += pci.o
7obj-$(CONFIG_SOC_TX4927) += mem_tx4927.o irq_tx4927.o
8obj-$(CONFIG_SOC_TX4938) += mem_tx4938.o irq_tx4938.o
9obj-$(CONFIG_TOSHIBA_FPCIB0) += smsc_fdc37m81x.o
10obj-$(CONFIG_KGDB) += dbgio.o
11
12EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/tx4938/common/dbgio.c b/arch/mips/txx9/generic/dbgio.c
index 33b9c672a32..33b9c672a32 100644
--- a/arch/mips/tx4938/common/dbgio.c
+++ b/arch/mips/txx9/generic/dbgio.c
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/txx9/generic/irq_tx4927.c
index 0aabd57fdad..6377bd8a905 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/txx9/generic/irq_tx4927.c
@@ -26,40 +26,12 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <asm/irq_cpu.h> 28#include <asm/irq_cpu.h>
29#include <asm/mipsregs.h> 29#include <asm/txx9/tx4927.h>
30#include <asm/tx4927/tx4927.h>
31#ifdef CONFIG_TOSHIBA_RBTX4927
32#include <asm/tx4927/toshiba_rbtx4927.h>
33#endif
34 30
35void __init tx4927_irq_init(void) 31void __init tx4927_irq_init(void)
36{ 32{
37 mips_cpu_irq_init(); 33 mips_cpu_irq_init();
38 txx9_irq_init(TX4927_IRC_REG); 34 txx9_irq_init(TX4927_IRC_REG);
39 set_irq_chained_handler(TX4927_IRQ_NEST_PIC_ON_CP0, handle_simple_irq); 35 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4927_IRC_INT,
40} 36 handle_simple_irq);
41
42asmlinkage void plat_irq_dispatch(void)
43{
44 unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
45
46 if (pending & STATUSF_IP7) /* cpu timer */
47 do_IRQ(TX4927_IRQ_CPU_TIMER);
48 else if (pending & STATUSF_IP2) { /* tx4927 pic */
49 int irq = txx9_irq();
50#ifdef CONFIG_TOSHIBA_RBTX4927
51 if (irq == TX4927_IRQ_NEST_EXT_ON_PIC)
52 irq = toshiba_rbtx4927_irq_nested(irq);
53#endif
54 if (unlikely(irq < 0)) {
55 spurious_interrupt();
56 return;
57 }
58 do_IRQ(irq);
59 } else if (pending & STATUSF_IP0) /* user line 0 */
60 do_IRQ(TX4927_IRQ_USER0);
61 else if (pending & STATUSF_IP1) /* user line 1 */
62 do_IRQ(TX4927_IRQ_USER1);
63 else
64 spurious_interrupt();
65} 37}
diff --git a/arch/mips/txx9/generic/irq_tx4938.c b/arch/mips/txx9/generic/irq_tx4938.c
new file mode 100644
index 00000000000..5fc86c9c9d2
--- /dev/null
+++ b/arch/mips/txx9/generic/irq_tx4938.c
@@ -0,0 +1,25 @@
1/*
2 * linux/arch/mips/tx4938/common/irq.c
3 *
4 * Common tx4938 irq handler
5 * Copyright (C) 2000-2001 Toshiba Corporation
6 *
7 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is
9 * licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <asm/irq_cpu.h>
17#include <asm/txx9/tx4938.h>
18
19void __init tx4938_irq_init(void)
20{
21 mips_cpu_irq_init();
22 txx9_irq_init(TX4938_IRC_REG);
23 set_irq_chained_handler(MIPS_CPU_IRQ_BASE + TX4938_IRC_INT,
24 handle_simple_irq);
25}
diff --git a/arch/mips/tx4927/common/tx4927_prom.c b/arch/mips/txx9/generic/mem_tx4927.c
index 6eed53d8f38..12dfc377bf2 100644
--- a/arch/mips/tx4927/common/tx4927_prom.c
+++ b/arch/mips/txx9/generic/mem_tx4927.c
@@ -30,13 +30,8 @@
30 */ 30 */
31 31
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/mm.h> 33#include <linux/types.h>
34#include <linux/sched.h> 34#include <linux/io.h>
35#include <linux/bootmem.h>
36
37#include <asm/addrspace.h>
38#include <asm/bootinfo.h>
39#include <asm/tx4927/tx4927.h>
40 35
41static unsigned int __init tx4927_process_sdccr(unsigned long addr) 36static unsigned int __init tx4927_process_sdccr(unsigned long addr)
42{ 37{
diff --git a/arch/mips/tx4938/common/prom.c b/arch/mips/txx9/generic/mem_tx4938.c
index 20baeaeba4c..20baeaeba4c 100644
--- a/arch/mips/tx4938/common/prom.c
+++ b/arch/mips/txx9/generic/mem_tx4938.c
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
new file mode 100644
index 00000000000..0b92d8c1320
--- /dev/null
+++ b/arch/mips/txx9/generic/pci.c
@@ -0,0 +1,388 @@
1/*
2 * linux/arch/mips/txx9/pci.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4927/setup.c,
5 * linux/arch/mips/txx9/rbtx4938/setup.c,
6 * and RBTX49xx patch from CELF patch archive.
7 *
8 * Copyright 2001-2005 MontaVista Software Inc.
9 * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org)
10 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
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/delay.h>
17#include <linux/jiffies.h>
18#include <linux/io.h>
19#include <asm/txx9/generic.h>
20#include <asm/txx9/pci.h>
21#ifdef CONFIG_TOSHIBA_FPCIB0
22#include <linux/interrupt.h>
23#include <asm/i8259.h>
24#include <asm/txx9/smsc_fdc37m81x.h>
25#endif
26
27static int __init
28early_read_config_word(struct pci_controller *hose,
29 int top_bus, int bus, int devfn, int offset, u16 *value)
30{
31 struct pci_dev fake_dev;
32 struct pci_bus fake_bus;
33
34 fake_dev.bus = &fake_bus;
35 fake_dev.sysdata = hose;
36 fake_dev.devfn = devfn;
37 fake_bus.number = bus;
38 fake_bus.sysdata = hose;
39 fake_bus.ops = hose->pci_ops;
40
41 if (bus != top_bus)
42 /* Fake a parent bus structure. */
43 fake_bus.parent = &fake_bus;
44 else
45 fake_bus.parent = NULL;
46
47 return pci_read_config_word(&fake_dev, offset, value);
48}
49
50int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,
51 int current_bus)
52{
53 u32 pci_devfn;
54 unsigned short vid;
55 int cap66 = -1;
56 u16 stat;
57
58 /* It seems SLC90E66 needs some time after PCI reset... */
59 mdelay(80);
60
61 printk(KERN_INFO "PCI: Checking 66MHz capabilities...\n");
62
63 for (pci_devfn = 0; pci_devfn < 0xff; pci_devfn++) {
64 if (PCI_FUNC(pci_devfn))
65 continue;
66 if (early_read_config_word(hose, top_bus, current_bus,
67 pci_devfn, PCI_VENDOR_ID, &vid) !=
68 PCIBIOS_SUCCESSFUL)
69 continue;
70 if (vid == 0xffff)
71 continue;
72
73 /* check 66MHz capability */
74 if (cap66 < 0)
75 cap66 = 1;
76 if (cap66) {
77 early_read_config_word(hose, top_bus, current_bus,
78 pci_devfn, PCI_STATUS, &stat);
79 if (!(stat & PCI_STATUS_66MHZ)) {
80 printk(KERN_DEBUG
81 "PCI: %02x:%02x not 66MHz capable.\n",
82 current_bus, pci_devfn);
83 cap66 = 0;
84 break;
85 }
86 }
87 }
88 return cap66 > 0;
89}
90
91static struct resource primary_pci_mem_res[2] = {
92 { .name = "PCI MEM" },
93 { .name = "PCI MMIO" },
94};
95static struct resource primary_pci_io_res = { .name = "PCI IO" };
96struct pci_controller txx9_primary_pcic = {
97 .mem_resource = &primary_pci_mem_res[0],
98 .io_resource = &primary_pci_io_res,
99};
100
101#ifdef CONFIG_64BIT
102int txx9_pci_mem_high __initdata = 1;
103#else
104int txx9_pci_mem_high __initdata;
105#endif
106
107/*
108 * allocate pci_controller and resources.
109 * mem_base, io_base: physical addresss. 0 for auto assignment.
110 * mem_size and io_size means max size on auto assignment.
111 * pcic must be &txx9_primary_pcic or NULL.
112 */
113struct pci_controller *__init
114txx9_alloc_pci_controller(struct pci_controller *pcic,
115 unsigned long mem_base, unsigned long mem_size,
116 unsigned long io_base, unsigned long io_size)
117{
118 struct pcic {
119 struct pci_controller c;
120 struct resource r_mem[2];
121 struct resource r_io;
122 } *new = NULL;
123 int min_size = 0x10000;
124
125 if (!pcic) {
126 new = kzalloc(sizeof(*new), GFP_KERNEL);
127 if (!new)
128 return NULL;
129 new->r_mem[0].name = "PCI mem";
130 new->r_mem[1].name = "PCI mmio";
131 new->r_io.name = "PCI io";
132 new->c.mem_resource = new->r_mem;
133 new->c.io_resource = &new->r_io;
134 pcic = &new->c;
135 } else
136 BUG_ON(pcic != &txx9_primary_pcic);
137 pcic->io_resource->flags = IORESOURCE_IO;
138
139 /*
140 * for auto assignment, first search a (big) region for PCI
141 * MEM, then search a region for PCI IO.
142 */
143 if (mem_base) {
144 pcic->mem_resource[0].start = mem_base;
145 pcic->mem_resource[0].end = mem_base + mem_size - 1;
146 if (request_resource(&iomem_resource, &pcic->mem_resource[0]))
147 goto free_and_exit;
148 } else {
149 unsigned long min = 0, max = 0x20000000; /* low 512MB */
150 if (!mem_size) {
151 /* default size for auto assignment */
152 if (txx9_pci_mem_high)
153 mem_size = 0x20000000; /* mem:512M(max) */
154 else
155 mem_size = 0x08000000; /* mem:128M(max) */
156 }
157 if (txx9_pci_mem_high) {
158 min = 0x20000000;
159 max = 0xe0000000;
160 }
161 /* search free region for PCI MEM */
162 for (; mem_size >= min_size; mem_size /= 2) {
163 if (allocate_resource(&iomem_resource,
164 &pcic->mem_resource[0],
165 mem_size, min, max,
166 mem_size, NULL, NULL) == 0)
167 break;
168 }
169 if (mem_size < min_size)
170 goto free_and_exit;
171 }
172
173 pcic->mem_resource[1].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
174 if (io_base) {
175 pcic->mem_resource[1].start = io_base;
176 pcic->mem_resource[1].end = io_base + io_size - 1;
177 if (request_resource(&iomem_resource, &pcic->mem_resource[1]))
178 goto release_and_exit;
179 } else {
180 if (!io_size)
181 /* default size for auto assignment */
182 io_size = 0x01000000; /* io:16M(max) */
183 /* search free region for PCI IO in low 512MB */
184 for (; io_size >= min_size; io_size /= 2) {
185 if (allocate_resource(&iomem_resource,
186 &pcic->mem_resource[1],
187 io_size, 0, 0x20000000,
188 io_size, NULL, NULL) == 0)
189 break;
190 }
191 if (io_size < min_size)
192 goto release_and_exit;
193 io_base = pcic->mem_resource[1].start;
194 }
195
196 pcic->mem_resource[0].flags = IORESOURCE_MEM;
197 if (pcic == &txx9_primary_pcic &&
198 mips_io_port_base == (unsigned long)-1) {
199 /* map ioport 0 to PCI I/O space address 0 */
200 set_io_port_base(IO_BASE + pcic->mem_resource[1].start);
201 pcic->io_resource->start = 0;
202 pcic->io_offset = 0; /* busaddr == ioaddr */
203 pcic->io_map_base = IO_BASE + pcic->mem_resource[1].start;
204 } else {
205 /* physaddr to ioaddr */
206 pcic->io_resource->start =
207 io_base - (mips_io_port_base - IO_BASE);
208 pcic->io_offset = io_base - (mips_io_port_base - IO_BASE);
209 pcic->io_map_base = mips_io_port_base;
210 }
211 pcic->io_resource->end = pcic->io_resource->start + io_size - 1;
212
213 pcic->mem_offset = 0; /* busaddr == physaddr */
214
215 printk(KERN_INFO "PCI: IO 0x%08llx-0x%08llx MEM 0x%08llx-0x%08llx\n",
216 (unsigned long long)pcic->mem_resource[1].start,
217 (unsigned long long)pcic->mem_resource[1].end,
218 (unsigned long long)pcic->mem_resource[0].start,
219 (unsigned long long)pcic->mem_resource[0].end);
220
221 /* register_pci_controller() will request MEM resource */
222 release_resource(&pcic->mem_resource[0]);
223 return pcic;
224 release_and_exit:
225 release_resource(&pcic->mem_resource[0]);
226 free_and_exit:
227 kfree(new);
228 printk(KERN_ERR "PCI: Failed to allocate resources.\n");
229 return NULL;
230}
231
232static int __init
233txx9_arch_pci_init(void)
234{
235 PCIBIOS_MIN_IO = 0x8000; /* reseve legacy I/O space */
236 return 0;
237}
238arch_initcall(txx9_arch_pci_init);
239
240/* IRQ/IDSEL mapping */
241int txx9_pci_option =
242#ifdef CONFIG_PICMG_PCI_BACKPLANE_DEFAULT
243 TXX9_PCI_OPT_PICMG |
244#endif
245 TXX9_PCI_OPT_CLK_AUTO;
246
247enum txx9_pci_err_action txx9_pci_err_action = TXX9_PCI_ERR_REPORT;
248
249#ifdef CONFIG_TOSHIBA_FPCIB0
250static irqreturn_t i8259_interrupt(int irq, void *dev_id)
251{
252 int isairq;
253
254 isairq = i8259_irq();
255 if (unlikely(isairq <= I8259A_IRQ_BASE))
256 return IRQ_NONE;
257 generic_handle_irq(isairq);
258 return IRQ_HANDLED;
259}
260
261static int __init
262txx9_i8259_irq_setup(int irq)
263{
264 int err;
265
266 init_i8259_irqs();
267 err = request_irq(irq, &i8259_interrupt, IRQF_DISABLED|IRQF_SHARED,
268 "cascade(i8259)", (void *)(long)irq);
269 if (!err)
270 printk(KERN_INFO "PCI-ISA bridge PIC (irq %d)\n", irq);
271 return err;
272}
273
274static void __init quirk_slc90e66_bridge(struct pci_dev *dev)
275{
276 int irq; /* PCI/ISA Bridge interrupt */
277 u8 reg_64;
278 u32 reg_b0;
279 u8 reg_e1;
280 irq = pcibios_map_irq(dev, PCI_SLOT(dev->devfn), 1); /* INTA */
281 if (!irq)
282 return;
283 txx9_i8259_irq_setup(irq);
284 pci_read_config_byte(dev, 0x64, &reg_64);
285 pci_read_config_dword(dev, 0xb0, &reg_b0);
286 pci_read_config_byte(dev, 0xe1, &reg_e1);
287 /* serial irq control */
288 reg_64 = 0xd0;
289 /* serial irq pin */
290 reg_b0 |= 0x00010000;
291 /* ide irq on isa14 */
292 reg_e1 &= 0xf0;
293 reg_e1 |= 0x0d;
294 pci_write_config_byte(dev, 0x64, reg_64);
295 pci_write_config_dword(dev, 0xb0, reg_b0);
296 pci_write_config_byte(dev, 0xe1, reg_e1);
297
298 smsc_fdc37m81x_init(0x3f0);
299 smsc_fdc37m81x_config_beg();
300 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_DNUM,
301 SMSC_FDC37M81X_KBD);
302 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT, 1);
303 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_INT2, 12);
304 smsc_fdc37m81x_config_set(SMSC_FDC37M81X_ACTIVE,
305 1);
306 smsc_fdc37m81x_config_end();
307}
308
309static void quirk_slc90e66_ide(struct pci_dev *dev)
310{
311 unsigned char dat;
312 int regs[2] = {0x41, 0x43};
313 int i;
314
315 /* SMSC SLC90E66 IDE uses irq 14, 15 (default) */
316 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 14);
317 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &dat);
318 printk(KERN_INFO "PCI: %s: IRQ %02x", pci_name(dev), dat);
319 /* enable SMSC SLC90E66 IDE */
320 for (i = 0; i < ARRAY_SIZE(regs); i++) {
321 pci_read_config_byte(dev, regs[i], &dat);
322 pci_write_config_byte(dev, regs[i], dat | 0x80);
323 pci_read_config_byte(dev, regs[i], &dat);
324 printk(KERN_CONT " IDETIM%d %02x", i, dat);
325 }
326 pci_read_config_byte(dev, 0x5c, &dat);
327 /*
328 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
329 *
330 * This line of code is intended to provide the user with a work
331 * around solution to the anomalies cited in SMSC's anomaly sheet
332 * entitled, "SLC90E66 Functional Rev.J_0.1 Anomalies"".
333 *
334 * !!! DO NOT REMOVE THIS COMMENT IT IS REQUIRED BY SMSC !!!
335 */
336 dat |= 0x01;
337 pci_write_config_byte(dev, regs[i], dat);
338 pci_read_config_byte(dev, 0x5c, &dat);
339 printk(KERN_CONT " REG5C %02x", dat);
340 printk(KERN_CONT "\n");
341}
342#endif /* CONFIG_TOSHIBA_FPCIB0 */
343
344static void final_fixup(struct pci_dev *dev)
345{
346 unsigned char bist;
347
348 /* Do build-in self test */
349 if (pci_read_config_byte(dev, PCI_BIST, &bist) == PCIBIOS_SUCCESSFUL &&
350 (bist & PCI_BIST_CAPABLE)) {
351 unsigned long timeout;
352 pci_set_power_state(dev, PCI_D0);
353 printk(KERN_INFO "PCI: %s BIST...", pci_name(dev));
354 pci_write_config_byte(dev, PCI_BIST, PCI_BIST_START);
355 timeout = jiffies + HZ * 2; /* timeout after 2 sec */
356 do {
357 pci_read_config_byte(dev, PCI_BIST, &bist);
358 if (time_after(jiffies, timeout))
359 break;
360 } while (bist & PCI_BIST_START);
361 if (bist & (PCI_BIST_CODE_MASK | PCI_BIST_START))
362 printk(KERN_CONT "failed. (0x%x)\n", bist);
363 else
364 printk(KERN_CONT "OK.\n");
365 }
366}
367
368#ifdef CONFIG_TOSHIBA_FPCIB0
369#define PCI_DEVICE_ID_EFAR_SLC90E66_0 0x9460
370DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_0,
371 quirk_slc90e66_bridge);
372DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1,
373 quirk_slc90e66_ide);
374DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1,
375 quirk_slc90e66_ide);
376#endif
377DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, final_fixup);
378DECLARE_PCI_FIXUP_RESUME(PCI_ANY_ID, PCI_ANY_ID, final_fixup);
379
380int pcibios_plat_dev_init(struct pci_dev *dev)
381{
382 return 0;
383}
384
385int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
386{
387 return txx9_board_vec->pci_map_irq(dev, slot, pin);
388}
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
new file mode 100644
index 00000000000..5afc5d5cab0
--- /dev/null
+++ b/arch/mips/txx9/generic/setup.c
@@ -0,0 +1,212 @@
1/*
2 * linux/arch/mips/txx9/generic/setup.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive.
6 *
7 * 2003-2005 (c) MontaVista Software, Inc.
8 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007
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.
13 */
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/types.h>
17#include <linux/interrupt.h>
18#include <linux/string.h>
19#include <linux/module.h>
20#include <linux/clk.h>
21#include <linux/err.h>
22#include <asm/bootinfo.h>
23#include <asm/txx9/generic.h>
24#ifdef CONFIG_CPU_TX49XX
25#include <asm/txx9/tx4938.h>
26#endif
27
28/* EBUSC settings of TX4927, etc. */
29struct resource txx9_ce_res[8];
30static char txx9_ce_res_name[8][4]; /* "CEn" */
31
32/* pcode, internal register */
33char txx9_pcode_str[8];
34static struct resource txx9_reg_res = {
35 .name = txx9_pcode_str,
36 .flags = IORESOURCE_MEM,
37};
38void __init
39txx9_reg_res_init(unsigned int pcode, unsigned long base, unsigned long size)
40{
41 int i;
42
43 for (i = 0; i < ARRAY_SIZE(txx9_ce_res); i++) {
44 sprintf(txx9_ce_res_name[i], "CE%d", i);
45 txx9_ce_res[i].flags = IORESOURCE_MEM;
46 txx9_ce_res[i].name = txx9_ce_res_name[i];
47 }
48
49 sprintf(txx9_pcode_str, "TX%x", pcode);
50 if (base) {
51 txx9_reg_res.start = base & 0xfffffffffULL;
52 txx9_reg_res.end = (base & 0xfffffffffULL) + (size - 1);
53 request_resource(&iomem_resource, &txx9_reg_res);
54 }
55}
56
57/* clocks */
58unsigned int txx9_master_clock;
59unsigned int txx9_cpu_clock;
60unsigned int txx9_gbus_clock;
61
62
63/* Minimum CLK support */
64
65struct clk *clk_get(struct device *dev, const char *id)
66{
67 if (!strcmp(id, "spi-baseclk"))
68 return (struct clk *)(txx9_gbus_clock / 2 / 4);
69 if (!strcmp(id, "imbus_clk"))
70 return (struct clk *)(txx9_gbus_clock / 2);
71 return ERR_PTR(-ENOENT);
72}
73EXPORT_SYMBOL(clk_get);
74
75int clk_enable(struct clk *clk)
76{
77 return 0;
78}
79EXPORT_SYMBOL(clk_enable);
80
81void clk_disable(struct clk *clk)
82{
83}
84EXPORT_SYMBOL(clk_disable);
85
86unsigned long clk_get_rate(struct clk *clk)
87{
88 return (unsigned long)clk;
89}
90EXPORT_SYMBOL(clk_get_rate);
91
92void clk_put(struct clk *clk)
93{
94}
95EXPORT_SYMBOL(clk_put);
96
97extern struct txx9_board_vec jmr3927_vec;
98extern struct txx9_board_vec rbtx4927_vec;
99extern struct txx9_board_vec rbtx4937_vec;
100extern struct txx9_board_vec rbtx4938_vec;
101
102struct txx9_board_vec *txx9_board_vec __initdata;
103static char txx9_system_type[32];
104
105void __init prom_init_cmdline(void)
106{
107 int argc = (int)fw_arg0;
108 char **argv = (char **)fw_arg1;
109 int i; /* Always ignore the "-c" at argv[0] */
110
111 /* ignore all built-in args if any f/w args given */
112 if (argc > 1)
113 *arcs_cmdline = '\0';
114
115 for (i = 1; i < argc; i++) {
116 if (i != 1)
117 strcat(arcs_cmdline, " ");
118 strcat(arcs_cmdline, argv[i]);
119 }
120}
121
122void __init prom_init(void)
123{
124#ifdef CONFIG_CPU_TX39XX
125 txx9_board_vec = &jmr3927_vec;
126#endif
127#ifdef CONFIG_CPU_TX49XX
128 switch (TX4938_REV_PCODE()) {
129 case 0x4927:
130 txx9_board_vec = &rbtx4927_vec;
131 break;
132 case 0x4937:
133 txx9_board_vec = &rbtx4937_vec;
134 break;
135 case 0x4938:
136 txx9_board_vec = &rbtx4938_vec;
137 break;
138 }
139#endif
140
141 strcpy(txx9_system_type, txx9_board_vec->system);
142
143 txx9_board_vec->prom_init();
144}
145
146void __init prom_free_prom_memory(void)
147{
148}
149
150const char *get_system_type(void)
151{
152 return txx9_system_type;
153}
154
155char * __init prom_getcmdline(void)
156{
157 return &(arcs_cmdline[0]);
158}
159
160/* wrappers */
161void __init plat_mem_setup(void)
162{
163 txx9_board_vec->mem_setup();
164}
165
166void __init arch_init_irq(void)
167{
168 txx9_board_vec->irq_setup();
169}
170
171void __init plat_time_init(void)
172{
173 txx9_board_vec->time_init();
174}
175
176static int __init _txx9_arch_init(void)
177{
178 if (txx9_board_vec->arch_init)
179 txx9_board_vec->arch_init();
180 return 0;
181}
182arch_initcall(_txx9_arch_init);
183
184static int __init _txx9_device_init(void)
185{
186 if (txx9_board_vec->device_init)
187 txx9_board_vec->device_init();
188 return 0;
189}
190device_initcall(_txx9_device_init);
191
192int (*txx9_irq_dispatch)(int pending);
193asmlinkage void plat_irq_dispatch(void)
194{
195 int pending = read_c0_status() & read_c0_cause() & ST0_IM;
196 int irq = txx9_irq_dispatch(pending);
197
198 if (likely(irq >= 0))
199 do_IRQ(irq);
200 else
201 spurious_interrupt();
202}
203
204/* see include/asm-mips/mach-tx39xx/mangle-port.h, for example. */
205#ifdef NEEDS_TXX9_SWIZZLE_ADDR_B
206static unsigned long __swizzle_addr_none(unsigned long port)
207{
208 return port;
209}
210unsigned long (*__swizzle_addr_b)(unsigned long port) = __swizzle_addr_none;
211EXPORT_SYMBOL(__swizzle_addr_b);
212#endif
diff --git a/arch/mips/tx4927/common/smsc_fdc37m81x.c b/arch/mips/txx9/generic/smsc_fdc37m81x.c
index 33f517bc9a0..69e487467fa 100644
--- a/arch/mips/tx4927/common/smsc_fdc37m81x.c
+++ b/arch/mips/txx9/generic/smsc_fdc37m81x.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/tx4927/smsc_fdc37m81x.h> 16#include <asm/txx9/smsc_fdc37m81x.h>
17 17
18#define DEBUG 18#define DEBUG
19 19
diff --git a/arch/mips/jmr3927/rbhma3100/Makefile b/arch/mips/txx9/jmr3927/Makefile
index d86e30dca8f..ba292c94566 100644
--- a/arch/mips/jmr3927/rbhma3100/Makefile
+++ b/arch/mips/txx9/jmr3927/Makefile
@@ -2,7 +2,7 @@
2# Makefile for TOSHIBA JMR-TX3927 board 2# Makefile for TOSHIBA JMR-TX3927 board
3# 3#
4 4
5obj-y += init.o irq.o setup.o 5obj-y += prom.o irq.o setup.o
6obj-$(CONFIG_KGDB) += kgdb_io.o 6obj-$(CONFIG_KGDB) += kgdb_io.o
7 7
8EXTRA_CFLAGS += -Werror 8EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/txx9/jmr3927/irq.c
index 3a47e8ce119..070c9a115e5 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/txx9/jmr3927/irq.c
@@ -39,7 +39,8 @@
39#include <asm/system.h> 39#include <asm/system.h>
40 40
41#include <asm/processor.h> 41#include <asm/processor.h>
42#include <asm/jmr3927/jmr3927.h> 42#include <asm/txx9/generic.h>
43#include <asm/txx9/jmr3927.h>
43 44
44#if JMR3927_IRQ_END > NR_IRQS 45#if JMR3927_IRQ_END > NR_IRQS
45#error JMR3927_IRQ_END > NR_IRQS 46#error JMR3927_IRQ_END > NR_IRQS
@@ -77,38 +78,32 @@ static void unmask_irq_ioc(unsigned int irq)
77 (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR); 78 (void)jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR);
78} 79}
79 80
80asmlinkage void plat_irq_dispatch(void) 81static int jmr3927_ioc_irqroute(void)
81{
82 unsigned long cp0_cause = read_c0_cause();
83 int irq;
84
85 if ((cp0_cause & CAUSEF_IP7) == 0)
86 return;
87 irq = (cp0_cause >> CAUSEB_IP2) & 0x0f;
88
89 do_IRQ(irq + JMR3927_IRQ_IRC);
90}
91
92static irqreturn_t jmr3927_ioc_interrupt(int irq, void *dev_id)
93{ 82{
94 unsigned char istat = jmr3927_ioc_reg_in(JMR3927_IOC_INTS2_ADDR); 83 unsigned char istat = jmr3927_ioc_reg_in(JMR3927_IOC_INTS2_ADDR);
95 int i; 84 int i;
96 85
97 for (i = 0; i < JMR3927_NR_IRQ_IOC; i++) { 86 for (i = 0; i < JMR3927_NR_IRQ_IOC; i++) {
98 if (istat & (1 << i)) { 87 if (istat & (1 << i))
99 irq = JMR3927_IRQ_IOC + i; 88 return JMR3927_IRQ_IOC + i;
100 do_IRQ(irq);
101 }
102 } 89 }
103 return IRQ_HANDLED; 90 return -1;
104} 91}
105 92
106static struct irqaction ioc_action = { 93static int jmr3927_irq_dispatch(int pending)
107 .handler = jmr3927_ioc_interrupt, 94{
108 .mask = CPU_MASK_NONE, 95 int irq;
109 .name = "IOC",
110};
111 96
97 if ((pending & CAUSEF_IP7) == 0)
98 return -1;
99 irq = (pending >> CAUSEB_IP2) & 0x0f;
100 irq += JMR3927_IRQ_IRC;
101 if (irq == JMR3927_IRQ_IOCINT)
102 irq = jmr3927_ioc_irqroute();
103 return irq;
104}
105
106#ifdef CONFIG_PCI
112static irqreturn_t jmr3927_pcierr_interrupt(int irq, void *dev_id) 107static irqreturn_t jmr3927_pcierr_interrupt(int irq, void *dev_id)
113{ 108{
114 printk(KERN_WARNING "PCI error interrupt (irq 0x%x).\n", irq); 109 printk(KERN_WARNING "PCI error interrupt (irq 0x%x).\n", irq);
@@ -122,11 +117,13 @@ static struct irqaction pcierr_action = {
122 .mask = CPU_MASK_NONE, 117 .mask = CPU_MASK_NONE,
123 .name = "PCI error", 118 .name = "PCI error",
124}; 119};
120#endif
125 121
126static void __init jmr3927_irq_init(void); 122static void __init jmr3927_irq_init(void);
127 123
128void __init arch_init_irq(void) 124void __init jmr3927_irq_setup(void)
129{ 125{
126 txx9_irq_dispatch = jmr3927_irq_dispatch;
130 /* Now, interrupt control disabled, */ 127 /* Now, interrupt control disabled, */
131 /* all IRC interrupts are masked, */ 128 /* all IRC interrupts are masked, */
132 /* all IRC interrupt mode are Low Active. */ 129 /* all IRC interrupt mode are Low Active. */
@@ -144,7 +141,7 @@ void __init arch_init_irq(void)
144 jmr3927_irq_init(); 141 jmr3927_irq_init();
145 142
146 /* setup IOC interrupt 1 (PCI, MODEM) */ 143 /* setup IOC interrupt 1 (PCI, MODEM) */
147 setup_irq(JMR3927_IRQ_IOCINT, &ioc_action); 144 set_irq_chained_handler(JMR3927_IRQ_IOCINT, handle_simple_irq);
148 145
149#ifdef CONFIG_PCI 146#ifdef CONFIG_PCI
150 setup_irq(JMR3927_IRQ_IRC_PCI, &pcierr_action); 147 setup_irq(JMR3927_IRQ_IRC_PCI, &pcierr_action);
diff --git a/arch/mips/jmr3927/rbhma3100/kgdb_io.c b/arch/mips/txx9/jmr3927/kgdb_io.c
index 342579cfdc0..5bd757e56f7 100644
--- a/arch/mips/jmr3927/rbhma3100/kgdb_io.c
+++ b/arch/mips/txx9/jmr3927/kgdb_io.c
@@ -31,7 +31,7 @@
31 * 675 Mass Ave, Cambridge, MA 02139, USA. 31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */ 32 */
33 33
34#include <asm/jmr3927/jmr3927.h> 34#include <asm/txx9/jmr3927.h>
35 35
36#define TIMEOUT 0xffffff 36#define TIMEOUT 0xffffff
37 37
diff --git a/arch/mips/jmr3927/common/prom.c b/arch/mips/txx9/jmr3927/prom.c
index 5398813e50e..2cadb423fac 100644
--- a/arch/mips/jmr3927/common/prom.c
+++ b/arch/mips/txx9/jmr3927/prom.c
@@ -35,38 +35,42 @@
35 * with this program; if not, write to the Free Software Foundation, Inc., 35 * with this program; if not, write to the Free Software Foundation, Inc.,
36 * 675 Mass Ave, Cambridge, MA 02139, USA. 36 * 675 Mass Ave, Cambridge, MA 02139, USA.
37 */ 37 */
38#include <linux/kernel.h>
39#include <linux/init.h> 38#include <linux/init.h>
40#include <linux/string.h>
41
42#include <asm/bootinfo.h> 39#include <asm/bootinfo.h>
40#include <asm/txx9/generic.h>
41#include <asm/txx9/jmr3927.h>
43 42
44char * __init prom_getcmdline(void) 43#define TIMEOUT 0xffffff
45{
46 return &(arcs_cmdline[0]);
47}
48 44
49void __init prom_init_cmdline(void) 45void
46prom_putchar(char c)
50{ 47{
51 char *cp; 48 int i = 0;
52 int actr;
53 int prom_argc = fw_arg0;
54 char **prom_argv = (char **) fw_arg1;
55 49
56 actr = 1; /* Always ignore argv[0] */ 50 do {
51 i++;
52 if (i>TIMEOUT)
53 break;
54 } while (!(tx3927_sioptr(1)->cisr & TXx927_SICISR_TXALS));
55 tx3927_sioptr(1)->tfifo = c;
56 return;
57}
57 58
58 cp = &(arcs_cmdline[0]); 59void
59 while(actr < prom_argc) { 60puts(const char *cp)
60 strcpy(cp, prom_argv[actr]); 61{
61 cp += strlen(prom_argv[actr]); 62 while (*cp)
62 *cp++ = ' '; 63 prom_putchar(*cp++);
63 actr++; 64 prom_putchar('\r');
64 } 65 prom_putchar('\n');
65 if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
66 --cp;
67 *cp = '\0';
68} 66}
69 67
70void __init prom_free_prom_memory(void) 68void __init jmr3927_prom_init(void)
71{ 69{
70 /* CCFG */
71 if ((tx3927_ccfgptr->ccfg & TX3927_CCFG_TLBOFF) == 0)
72 puts("Warning: TX3927 TLB off\n");
73
74 prom_init_cmdline();
75 add_memory_region(0, JMR3927_SDRAM_SIZE, BOOT_MEM_RAM);
72} 76}
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/txx9/jmr3927/setup.c
index f39c444e42d..5e35ef73c5a 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/txx9/jmr3927/setup.c
@@ -30,21 +30,20 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h>
34#include <linux/ioport.h> 33#include <linux/ioport.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/pm.h> 35#include <linux/pm.h>
37#include <linux/platform_device.h> 36#include <linux/platform_device.h>
38#include <linux/clk.h>
39#include <linux/gpio.h> 37#include <linux/gpio.h>
40#ifdef CONFIG_SERIAL_TXX9 38#ifdef CONFIG_SERIAL_TXX9
41#include <linux/serial_core.h> 39#include <linux/serial_core.h>
42#endif 40#endif
43
44#include <asm/txx9tmr.h> 41#include <asm/txx9tmr.h>
45#include <asm/txx9pio.h> 42#include <asm/txx9pio.h>
46#include <asm/reboot.h> 43#include <asm/reboot.h>
47#include <asm/jmr3927/jmr3927.h> 44#include <asm/txx9/generic.h>
45#include <asm/txx9/pci.h>
46#include <asm/txx9/jmr3927.h>
48#include <asm/mipsregs.h> 47#include <asm/mipsregs.h>
49 48
50extern void puts(const char *cp); 49extern void puts(const char *cp);
@@ -83,7 +82,7 @@ static void jmr3927_machine_power_off(void)
83 while (1); 82 while (1);
84} 83}
85 84
86void __init plat_time_init(void) 85static void __init jmr3927_time_init(void)
87{ 86{
88 txx9_clockevent_init(TX3927_TMR_REG(0), 87 txx9_clockevent_init(TX3927_TMR_REG(0),
89 TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0), 88 TXX9_IRQ_BASE + JMR3927_IRQ_IRC_TMR(0),
@@ -94,12 +93,9 @@ void __init plat_time_init(void)
94#define DO_WRITE_THROUGH 93#define DO_WRITE_THROUGH
95#define DO_ENABLE_CACHE 94#define DO_ENABLE_CACHE
96 95
97extern char * __init prom_getcmdline(void);
98static void jmr3927_board_init(void); 96static void jmr3927_board_init(void);
99extern struct resource pci_io_resource;
100extern struct resource pci_mem_resource;
101 97
102void __init plat_mem_setup(void) 98static void __init jmr3927_mem_setup(void)
103{ 99{
104 char *argptr; 100 char *argptr;
105 101
@@ -112,8 +108,8 @@ void __init plat_mem_setup(void)
112 /* 108 /*
113 * IO/MEM resources. 109 * IO/MEM resources.
114 */ 110 */
115 ioport_resource.start = pci_io_resource.start; 111 ioport_resource.start = 0;
116 ioport_resource.end = pci_io_resource.end; 112 ioport_resource.end = 0xffffffff;
117 iomem_resource.start = 0; 113 iomem_resource.start = 0;
118 iomem_resource.end = 0xffffffff; 114 iomem_resource.end = 0xffffffff;
119 115
@@ -191,9 +187,33 @@ void __init plat_mem_setup(void)
191 187
192static void tx3927_setup(void); 188static void tx3927_setup(void);
193 189
190static void __init jmr3927_pci_setup(void)
191{
192#ifdef CONFIG_PCI
193 int extarb = !(tx3927_ccfgptr->ccfg & TX3927_CCFG_PCIXARB);
194 struct pci_controller *c;
195
196 c = txx9_alloc_pci_controller(&txx9_primary_pcic,
197 JMR3927_PCIMEM, JMR3927_PCIMEM_SIZE,
198 JMR3927_PCIIO, JMR3927_PCIIO_SIZE);
199 register_pci_controller(c);
200 if (!extarb) {
201 /* Reset PCI Bus */
202 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
203 udelay(100);
204 jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI,
205 JMR3927_IOC_RESET_ADDR);
206 udelay(100);
207 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
208 }
209 tx3927_pcic_setup(c, JMR3927_SDRAM_SIZE, extarb);
210#endif /* CONFIG_PCI */
211}
212
194static void __init jmr3927_board_init(void) 213static void __init jmr3927_board_init(void)
195{ 214{
196 tx3927_setup(); 215 tx3927_setup();
216 jmr3927_pci_setup();
197 217
198 /* SIO0 DTR on */ 218 /* SIO0 DTR on */
199 jmr3927_ioc_reg_out(0, JMR3927_IOC_DTR_ADDR); 219 jmr3927_ioc_reg_out(0, JMR3927_IOC_DTR_ADDR);
@@ -210,15 +230,9 @@ static void __init jmr3927_board_init(void)
210static void __init tx3927_setup(void) 230static void __init tx3927_setup(void)
211{ 231{
212 int i; 232 int i;
213#ifdef CONFIG_PCI
214 unsigned long mips_pci_io_base = JMR3927_PCIIO;
215 unsigned long mips_pci_io_size = JMR3927_PCIIO_SIZE;
216 unsigned long mips_pci_mem_base = JMR3927_PCIMEM;
217 unsigned long mips_pci_mem_size = JMR3927_PCIMEM_SIZE;
218 /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
219 unsigned long mips_pci_io_pciaddr = 0;
220#endif
221 233
234 txx9_cpu_clock = JMR3927_CORECLK;
235 txx9_gbus_clock = JMR3927_GBUSCLK;
222 /* SDRAMC are configured by PROM */ 236 /* SDRAMC are configured by PROM */
223 237
224 /* ROMC */ 238 /* ROMC */
@@ -272,74 +286,6 @@ static void __init tx3927_setup(void)
272 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE; 286 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE;
273#endif 287#endif
274 288
275#ifdef CONFIG_PCI
276 /* PCIC */
277 printk("TX3927 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:",
278 tx3927_pcicptr->did, tx3927_pcicptr->vid,
279 tx3927_pcicptr->rid);
280 if (!(tx3927_ccfgptr->ccfg & TX3927_CCFG_PCIXARB)) {
281 printk("External\n");
282 /* XXX */
283 } else {
284 printk("Internal\n");
285
286 /* Reset PCI Bus */
287 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
288 udelay(100);
289 jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI,
290 JMR3927_IOC_RESET_ADDR);
291 udelay(100);
292 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
293
294
295 /* Disable External PCI Config. Access */
296 tx3927_pcicptr->lbc = TX3927_PCIC_LBC_EPCAD;
297#ifdef __BIG_ENDIAN
298 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_IBSE |
299 TX3927_PCIC_LBC_TIBSE |
300 TX3927_PCIC_LBC_TMFBSE | TX3927_PCIC_LBC_MSDSE;
301#endif
302 /* LB->PCI mappings */
303 tx3927_pcicptr->iomas = ~(mips_pci_io_size - 1);
304 tx3927_pcicptr->ilbioma = mips_pci_io_base;
305 tx3927_pcicptr->ipbioma = mips_pci_io_pciaddr;
306 tx3927_pcicptr->mmas = ~(mips_pci_mem_size - 1);
307 tx3927_pcicptr->ilbmma = mips_pci_mem_base;
308 tx3927_pcicptr->ipbmma = mips_pci_mem_base;
309 /* PCI->LB mappings */
310 tx3927_pcicptr->iobas = 0xffffffff;
311 tx3927_pcicptr->ioba = 0;
312 tx3927_pcicptr->tlbioma = 0;
313 tx3927_pcicptr->mbas = ~(mips_pci_mem_size - 1);
314 tx3927_pcicptr->mba = 0;
315 tx3927_pcicptr->tlbmma = 0;
316 /* Enable Direct mapping Address Space Decoder */
317 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_ILMDE | TX3927_PCIC_LBC_ILIDE;
318
319 /* Clear All Local Bus Status */
320 tx3927_pcicptr->lbstat = TX3927_PCIC_LBIM_ALL;
321 /* Enable All Local Bus Interrupts */
322 tx3927_pcicptr->lbim = TX3927_PCIC_LBIM_ALL;
323 /* Clear All PCI Status Error */
324 tx3927_pcicptr->pcistat = TX3927_PCIC_PCISTATIM_ALL;
325 /* Enable All PCI Status Error Interrupts */
326 tx3927_pcicptr->pcistatim = TX3927_PCIC_PCISTATIM_ALL;
327
328 /* PCIC Int => IRC IRQ10 */
329 tx3927_pcicptr->il = TX3927_IR_PCI;
330 /* Target Control (per errata) */
331 tx3927_pcicptr->tc = TX3927_PCIC_TC_OF8E | TX3927_PCIC_TC_IF8E;
332
333 /* Enable Bus Arbiter */
334 tx3927_pcicptr->pbapmc = TX3927_PCIC_PBAPMC_PBAEN;
335
336 tx3927_pcicptr->pcicmd = PCI_COMMAND_MASTER |
337 PCI_COMMAND_MEMORY |
338 PCI_COMMAND_IO |
339 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
340 }
341#endif /* CONFIG_PCI */
342
343 /* PIO */ 289 /* PIO */
344 /* PIO[15:12] connected to LEDs */ 290 /* PIO[15:12] connected to LEDs */
345 __raw_writel(0x0000f000, &tx3927_pioptr->dir); 291 __raw_writel(0x0000f000, &tx3927_pioptr->dir);
@@ -366,7 +312,7 @@ static void __init tx3927_setup(void)
366} 312}
367 313
368/* This trick makes rtc-ds1742 driver usable as is. */ 314/* This trick makes rtc-ds1742 driver usable as is. */
369unsigned long __swizzle_addr_b(unsigned long port) 315static unsigned long jmr3927_swizzle_addr_b(unsigned long port)
370{ 316{
371 if ((port & 0xffff0000) != JMR3927_IOC_NVRAMB_ADDR) 317 if ((port & 0xffff0000) != JMR3927_IOC_NVRAMB_ADDR)
372 return port; 318 return port;
@@ -377,7 +323,6 @@ unsigned long __swizzle_addr_b(unsigned long port)
377 return port | 1; 323 return port | 1;
378#endif 324#endif
379} 325}
380EXPORT_SYMBOL(__swizzle_addr_b);
381 326
382static int __init jmr3927_rtc_init(void) 327static int __init jmr3927_rtc_init(void)
383{ 328{
@@ -390,7 +335,6 @@ static int __init jmr3927_rtc_init(void)
390 dev = platform_device_register_simple("rtc-ds1742", -1, &res, 1); 335 dev = platform_device_register_simple("rtc-ds1742", -1, &res, 1);
391 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 336 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
392} 337}
393device_initcall(jmr3927_rtc_init);
394 338
395/* Watchdog support */ 339/* Watchdog support */
396 340
@@ -410,36 +354,22 @@ static int __init jmr3927_wdt_init(void)
410{ 354{
411 return txx9_wdt_init(TX3927_TMR_REG(2)); 355 return txx9_wdt_init(TX3927_TMR_REG(2));
412} 356}
413device_initcall(jmr3927_wdt_init);
414 357
415/* Minimum CLK support */ 358static void __init jmr3927_device_init(void)
416
417struct clk *clk_get(struct device *dev, const char *id)
418{ 359{
419 if (!strcmp(id, "imbus_clk")) 360 __swizzle_addr_b = jmr3927_swizzle_addr_b;
420 return (struct clk *)JMR3927_IMCLK; 361 jmr3927_rtc_init();
421 return ERR_PTR(-ENOENT); 362 jmr3927_wdt_init();
422} 363}
423EXPORT_SYMBOL(clk_get);
424 364
425int clk_enable(struct clk *clk) 365struct txx9_board_vec jmr3927_vec __initdata = {
426{ 366 .system = "Toshiba JMR_TX3927",
427 return 0; 367 .prom_init = jmr3927_prom_init,
428} 368 .mem_setup = jmr3927_mem_setup,
429EXPORT_SYMBOL(clk_enable); 369 .irq_setup = jmr3927_irq_setup,
430 370 .time_init = jmr3927_time_init,
431void clk_disable(struct clk *clk) 371 .device_init = jmr3927_device_init,
432{ 372#ifdef CONFIG_PCI
433} 373 .pci_map_irq = jmr3927_pci_map_irq,
434EXPORT_SYMBOL(clk_disable); 374#endif
435 375};
436unsigned long clk_get_rate(struct clk *clk)
437{
438 return (unsigned long)clk;
439}
440EXPORT_SYMBOL(clk_get_rate);
441
442void clk_put(struct clk *clk)
443{
444}
445EXPORT_SYMBOL(clk_put);
diff --git a/arch/mips/txx9/rbtx4927/Makefile b/arch/mips/txx9/rbtx4927/Makefile
new file mode 100644
index 00000000000..f3e1f597b4f
--- /dev/null
+++ b/arch/mips/txx9/rbtx4927/Makefile
@@ -0,0 +1,3 @@
1obj-y += prom.o setup.o irq.o
2
3EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c
new file mode 100644
index 00000000000..70f13211bc2
--- /dev/null
+++ b/arch/mips/txx9/rbtx4927/irq.c
@@ -0,0 +1,199 @@
1/*
2 * Toshiba RBTX4927 specific interrupt handlers
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * Copyright 2001-2002 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
20 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
22 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * You should have received a copy of the GNU General Public License along
26 * with this program; if not, write to the Free Software Foundation, Inc.,
27 * 675 Mass Ave, Cambridge, MA 02139, USA.
28 */
29/*
30IRQ Device
3100 RBTX4927-ISA/00
3201 RBTX4927-ISA/01 PS2/Keyboard
3302 RBTX4927-ISA/02 Cascade RBTX4927-ISA (irqs 8-15)
3403 RBTX4927-ISA/03
3504 RBTX4927-ISA/04
3605 RBTX4927-ISA/05
3706 RBTX4927-ISA/06
3807 RBTX4927-ISA/07
3908 RBTX4927-ISA/08
4009 RBTX4927-ISA/09
4110 RBTX4927-ISA/10
4211 RBTX4927-ISA/11
4312 RBTX4927-ISA/12 PS2/Mouse (not supported at this time)
4413 RBTX4927-ISA/13
4514 RBTX4927-ISA/14 IDE
4615 RBTX4927-ISA/15
47
4816 TX4927-CP0/00 Software 0
4917 TX4927-CP0/01 Software 1
5018 TX4927-CP0/02 Cascade TX4927-CP0
5119 TX4927-CP0/03 Multiplexed -- do not use
5220 TX4927-CP0/04 Multiplexed -- do not use
5321 TX4927-CP0/05 Multiplexed -- do not use
5422 TX4927-CP0/06 Multiplexed -- do not use
5523 TX4927-CP0/07 CPU TIMER
56
5724 TX4927-PIC/00
5825 TX4927-PIC/01
5926 TX4927-PIC/02
6027 TX4927-PIC/03 Cascade RBTX4927-IOC
6128 TX4927-PIC/04
6229 TX4927-PIC/05 RBTX4927 RTL-8019AS ethernet
6330 TX4927-PIC/06
6431 TX4927-PIC/07
6532 TX4927-PIC/08 TX4927 SerialIO Channel 0
6633 TX4927-PIC/09 TX4927 SerialIO Channel 1
6734 TX4927-PIC/10
6835 TX4927-PIC/11
6936 TX4927-PIC/12
7037 TX4927-PIC/13
7138 TX4927-PIC/14
7239 TX4927-PIC/15
7340 TX4927-PIC/16 TX4927 PCI PCI-C
7441 TX4927-PIC/17
7542 TX4927-PIC/18
7643 TX4927-PIC/19
7744 TX4927-PIC/20
7845 TX4927-PIC/21
7946 TX4927-PIC/22 TX4927 PCI PCI-ERR
8047 TX4927-PIC/23 TX4927 PCI PCI-PMA (not used)
8148 TX4927-PIC/24
8249 TX4927-PIC/25
8350 TX4927-PIC/26
8451 TX4927-PIC/27
8552 TX4927-PIC/28
8653 TX4927-PIC/29
8754 TX4927-PIC/30
8855 TX4927-PIC/31
89
9056 RBTX4927-IOC/00 FPCIB0 PCI-D PJ4/A PJ5/B SB/C PJ6/D PJ7/A (SouthBridge/NotUsed) [RTL-8139=PJ4]
9157 RBTX4927-IOC/01 FPCIB0 PCI-C PJ4/D PJ5/A SB/B PJ6/C PJ7/D (SouthBridge/NotUsed) [RTL-8139=PJ5]
9258 RBTX4927-IOC/02 FPCIB0 PCI-B PJ4/C PJ5/D SB/A PJ6/B PJ7/C (SouthBridge/IDE/pin=1,INTR) [RTL-8139=NotSupported]
9359 RBTX4927-IOC/03 FPCIB0 PCI-A PJ4/B PJ5/C SB/D PJ6/A PJ7/B (SouthBridge/USB/pin=4) [RTL-8139=PJ6]
9460 RBTX4927-IOC/04
9561 RBTX4927-IOC/05
9662 RBTX4927-IOC/06
9763 RBTX4927-IOC/07
98
99NOTES:
100SouthBridge/INTR is mapped to SouthBridge/A=PCI-B/#58
101SouthBridge/ISA/pin=0 no pci irq used by this device
102SouthBridge/IDE/pin=1 no pci irq used by this device, using INTR via ISA IRQ14
103SouthBridge/USB/pin=4 using pci irq SouthBridge/D=PCI-A=#59
104SouthBridge/PMC/pin=0 no pci irq used by this device
105SuperIO/PS2/Keyboard, using INTR via ISA IRQ1
106SuperIO/PS2/Mouse, using INTR via ISA IRQ12 (mouse not currently supported)
107JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthBridge, JP4, JP5, JP6
108*/
109
110#include <linux/init.h>
111#include <linux/types.h>
112#include <linux/interrupt.h>
113#include <asm/io.h>
114#include <asm/mipsregs.h>
115#include <asm/txx9/generic.h>
116#include <asm/txx9/rbtx4927.h>
117
118static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
119static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
120
121#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC"
122static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
123 .name = TOSHIBA_RBTX4927_IOC_NAME,
124 .ack = toshiba_rbtx4927_irq_ioc_disable,
125 .mask = toshiba_rbtx4927_irq_ioc_disable,
126 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
127 .unmask = toshiba_rbtx4927_irq_ioc_enable,
128};
129#define TOSHIBA_RBTX4927_IOC_INTR_ENAB (void __iomem *)0xbc002000UL
130#define TOSHIBA_RBTX4927_IOC_INTR_STAT (void __iomem *)0xbc002006UL
131
132static int toshiba_rbtx4927_irq_nested(int sw_irq)
133{
134 u8 level3;
135
136 level3 = readb(TOSHIBA_RBTX4927_IOC_INTR_STAT) & 0x1f;
137 if (level3)
138 sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1;
139 return (sw_irq);
140}
141
142static void __init toshiba_rbtx4927_irq_ioc_init(void)
143{
144 int i;
145
146 for (i = RBTX4927_IRQ_IOC;
147 i < RBTX4927_IRQ_IOC + RBTX4927_NR_IRQ_IOC; i++)
148 set_irq_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type,
149 handle_level_irq);
150 set_irq_chained_handler(RBTX4927_IRQ_IOCINT, handle_simple_irq);
151}
152
153static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq)
154{
155 unsigned char v;
156
157 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
158 v |= (1 << (irq - RBTX4927_IRQ_IOC));
159 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
160}
161
162static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
163{
164 unsigned char v;
165
166 v = readb(TOSHIBA_RBTX4927_IOC_INTR_ENAB);
167 v &= ~(1 << (irq - RBTX4927_IRQ_IOC));
168 writeb(v, TOSHIBA_RBTX4927_IOC_INTR_ENAB);
169 mmiowb();
170}
171
172
173static int rbtx4927_irq_dispatch(int pending)
174{
175 int irq;
176
177 if (pending & STATUSF_IP7) /* cpu timer */
178 irq = MIPS_CPU_IRQ_BASE + 7;
179 else if (pending & STATUSF_IP2) { /* tx4927 pic */
180 irq = txx9_irq();
181 if (irq == RBTX4927_IRQ_IOCINT)
182 irq = toshiba_rbtx4927_irq_nested(irq);
183 } else if (pending & STATUSF_IP0) /* user line 0 */
184 irq = MIPS_CPU_IRQ_BASE + 0;
185 else if (pending & STATUSF_IP1) /* user line 1 */
186 irq = MIPS_CPU_IRQ_BASE + 1;
187 else
188 irq = -1;
189 return irq;
190}
191
192void __init rbtx4927_irq_setup(void)
193{
194 txx9_irq_dispatch = rbtx4927_irq_dispatch;
195 tx4927_irq_init();
196 toshiba_rbtx4927_irq_ioc_init();
197 /* Onboard 10M Ether: High Active */
198 set_irq_type(RBTX4927_RTL_8019_IRQ, IRQF_TRIGGER_HIGH);
199}
diff --git a/arch/mips/tx4927/common/tx4927_dbgio.c b/arch/mips/txx9/rbtx4927/prom.c
index d8423e001b2..942e627d2dc 100644
--- a/arch/mips/tx4927/common/tx4927_dbgio.c
+++ b/arch/mips/txx9/rbtx4927/prom.c
@@ -1,13 +1,14 @@
1/* 1/*
2 * linux/arch/mips/tx4927/common/tx4927_dbgio.c 2 * rbtx4927 specific prom routines
3 *
4 * kgdb interface for gdb
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
7 * source@mvista.com 5 * source@mvista.com
8 * 6 *
9 * Copyright 2001-2002 MontaVista Software Inc. 7 * Copyright 2001-2002 MontaVista Software Inc.
10 * 8 *
9 * Copyright (C) 2004 MontaVista Software Inc.
10 * Author: Manish Lachwani, mlachwani@mvista.com
11 *
11 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your 14 * Free Software Foundation; either version 2 of the License, or (at your
@@ -28,19 +29,17 @@
28 * with this program; if not, write to the Free Software Foundation, Inc., 29 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA. 30 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 31 */
32#include <linux/init.h>
33#include <asm/bootinfo.h>
34#include <asm/txx9/generic.h>
35#include <asm/txx9/rbtx4927.h>
31 36
32#include <asm/mipsregs.h> 37void __init rbtx4927_prom_init(void)
33#include <asm/system.h>
34
35u8 getDebugChar(void)
36{ 38{
37 extern u8 txx9_sio_kdbg_rd(void); 39 extern int tx4927_get_mem_size(void);
38 return (txx9_sio_kdbg_rd()); 40 int msize;
39}
40
41 41
42int putDebugChar(u8 byte) 42 prom_init_cmdline();
43{ 43 msize = tx4927_get_mem_size();
44 extern int txx9_sio_kdbg_wr( u8 ch ); 44 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
45 return (txx9_sio_kdbg_wr(byte));
46} 45}
diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c
new file mode 100644
index 00000000000..1657fd935da
--- /dev/null
+++ b/arch/mips/txx9/rbtx4927/setup.c
@@ -0,0 +1,443 @@
1/*
2 * Toshiba rbtx4927 specific setup
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * Copyright 2001-2002 MontaVista Software Inc.
8 *
9 * Copyright (C) 1996, 97, 2001, 04 Ralf Baechle (ralf@linux-mips.org)
10 * Copyright (C) 2000 RidgeRun, Inc.
11 * Author: RidgeRun, Inc.
12 * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
13 *
14 * Copyright 2001 MontaVista Software Inc.
15 * Author: jsun@mvista.com or jsun@junsun.net
16 *
17 * Copyright 2002 MontaVista Software Inc.
18 * Author: Michael Pruznick, michael_pruznick@mvista.com
19 *
20 * Copyright (C) 2000-2001 Toshiba Corporation
21 *
22 * Copyright (C) 2004 MontaVista Software Inc.
23 * Author: Manish Lachwani, mlachwani@mvista.com
24 *
25 * This program is free software; you can redistribute it and/or modify it
26 * under the terms of the GNU General Public License as published by the
27 * Free Software Foundation; either version 2 of the License, or (at your
28 * option) any later version.
29 *
30 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
31 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
36 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
38 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
39 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * You should have received a copy of the GNU General Public License along
42 * with this program; if not, write to the Free Software Foundation, Inc.,
43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */
45#include <linux/init.h>
46#include <linux/kernel.h>
47#include <linux/types.h>
48#include <linux/ioport.h>
49#include <linux/interrupt.h>
50#include <linux/pm.h>
51#include <linux/platform_device.h>
52#include <linux/delay.h>
53#include <asm/io.h>
54#include <asm/processor.h>
55#include <asm/reboot.h>
56#include <asm/time.h>
57#include <asm/txx9tmr.h>
58#include <asm/txx9/generic.h>
59#include <asm/txx9/pci.h>
60#include <asm/txx9/rbtx4927.h>
61#include <asm/txx9/tx4938.h> /* for TX4937 */
62#ifdef CONFIG_SERIAL_TXX9
63#include <linux/serial_core.h>
64#endif
65
66static int tx4927_ccfg_toeon = 1;
67
68#ifdef CONFIG_PCI
69static void __init tx4927_pci_setup(void)
70{
71 int extarb = !(__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB);
72 struct pci_controller *c = &txx9_primary_pcic;
73
74 register_pci_controller(c);
75
76 if (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66)
77 txx9_pci_option =
78 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
79 TXX9_PCI_OPT_CLK_66; /* already configured */
80
81 /* Reset PCI Bus */
82 writeb(1, rbtx4927_pcireset_addr);
83 /* Reset PCIC */
84 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
85 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
86 TXX9_PCI_OPT_CLK_66)
87 tx4927_pciclk66_setup();
88 mdelay(10);
89 /* clear PCIC reset */
90 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
91 writeb(0, rbtx4927_pcireset_addr);
92 iob();
93
94 tx4927_report_pciclk();
95 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
96 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
97 TXX9_PCI_OPT_CLK_AUTO &&
98 txx9_pci66_check(c, 0, 0)) {
99 /* Reset PCI Bus */
100 writeb(1, rbtx4927_pcireset_addr);
101 /* Reset PCIC */
102 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
103 tx4927_pciclk66_setup();
104 mdelay(10);
105 /* clear PCIC reset */
106 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
107 writeb(0, rbtx4927_pcireset_addr);
108 iob();
109 /* Reinitialize PCIC */
110 tx4927_report_pciclk();
111 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
112 }
113}
114
115static void __init tx4937_pci_setup(void)
116{
117 int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
118 struct pci_controller *c = &txx9_primary_pcic;
119
120 register_pci_controller(c);
121
122 if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
123 txx9_pci_option =
124 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
125 TXX9_PCI_OPT_CLK_66; /* already configured */
126
127 /* Reset PCI Bus */
128 writeb(1, rbtx4927_pcireset_addr);
129 /* Reset PCIC */
130 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
131 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
132 TXX9_PCI_OPT_CLK_66)
133 tx4938_pciclk66_setup();
134 mdelay(10);
135 /* clear PCIC reset */
136 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
137 writeb(0, rbtx4927_pcireset_addr);
138 iob();
139
140 tx4938_report_pciclk();
141 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
142 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
143 TXX9_PCI_OPT_CLK_AUTO &&
144 txx9_pci66_check(c, 0, 0)) {
145 /* Reset PCI Bus */
146 writeb(1, rbtx4927_pcireset_addr);
147 /* Reset PCIC */
148 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
149 tx4938_pciclk66_setup();
150 mdelay(10);
151 /* clear PCIC reset */
152 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
153 writeb(0, rbtx4927_pcireset_addr);
154 iob();
155 /* Reinitialize PCIC */
156 tx4938_report_pciclk();
157 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
158 }
159}
160
161static void __init rbtx4927_arch_init(void)
162{
163 tx4927_pci_setup();
164}
165
166static void __init rbtx4937_arch_init(void)
167{
168 tx4937_pci_setup();
169}
170#else
171#define rbtx4927_arch_init NULL
172#define rbtx4937_arch_init NULL
173#endif /* CONFIG_PCI */
174
175static void __noreturn wait_forever(void)
176{
177 while (1)
178 if (cpu_wait)
179 (*cpu_wait)();
180}
181
182static void toshiba_rbtx4927_restart(char *command)
183{
184 printk(KERN_NOTICE "System Rebooting...\n");
185
186 /* enable the s/w reset register */
187 writeb(RBTX4927_SW_RESET_ENABLE_SET, RBTX4927_SW_RESET_ENABLE);
188
189 /* wait for enable to be seen */
190 while ((readb(RBTX4927_SW_RESET_ENABLE) &
191 RBTX4927_SW_RESET_ENABLE_SET) == 0x00);
192
193 /* do a s/w reset */
194 writeb(RBTX4927_SW_RESET_DO_SET, RBTX4927_SW_RESET_DO);
195
196 /* do something passive while waiting for reset */
197 local_irq_disable();
198 wait_forever();
199 /* no return */
200}
201
202static void toshiba_rbtx4927_halt(void)
203{
204 printk(KERN_NOTICE "System Halted\n");
205 local_irq_disable();
206 wait_forever();
207 /* no return */
208}
209
210static void toshiba_rbtx4927_power_off(void)
211{
212 toshiba_rbtx4927_halt();
213 /* no return */
214}
215
216static void __init rbtx4927_mem_setup(void)
217{
218 int i;
219 u32 cp0_config;
220 char *argptr;
221
222 /* f/w leaves this on at startup */
223 clear_c0_status(ST0_ERL);
224
225 /* enable caches -- HCP5 does this, pmon does not */
226 cp0_config = read_c0_config();
227 cp0_config = cp0_config & ~(TX49_CONF_IC | TX49_CONF_DC);
228 write_c0_config(cp0_config);
229
230 ioport_resource.end = 0xffffffff;
231 iomem_resource.end = 0xffffffff;
232
233 _machine_restart = toshiba_rbtx4927_restart;
234 _machine_halt = toshiba_rbtx4927_halt;
235 pm_power_off = toshiba_rbtx4927_power_off;
236
237 for (i = 0; i < TX4927_NR_TMR; i++)
238 txx9_tmr_init(TX4927_TMR_REG(0) & 0xfffffffffULL);
239
240#ifdef CONFIG_PCI
241 txx9_alloc_pci_controller(&txx9_primary_pcic,
242 RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE,
243 RBTX4927_PCIIO, RBTX4927_PCIIO_SIZE);
244#else
245 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
246#endif
247
248 /* CCFG */
249 /* do reset on watchdog */
250 tx4927_ccfg_set(TX4927_CCFG_WR);
251 /* enable Timeout BusError */
252 if (tx4927_ccfg_toeon)
253 tx4927_ccfg_set(TX4927_CCFG_TOE);
254
255#ifdef CONFIG_SERIAL_TXX9
256 {
257 extern int early_serial_txx9_setup(struct uart_port *port);
258 struct uart_port req;
259 for(i = 0; i < 2; i++) {
260 memset(&req, 0, sizeof(req));
261 req.line = i;
262 req.iotype = UPIO_MEM;
263 req.membase = (char *)(0xff1ff300 + i * 0x100);
264 req.mapbase = 0xff1ff300 + i * 0x100;
265 req.irq = TXX9_IRQ_BASE + TX4927_IR_SIO(i);
266 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
267 req.uartclk = 50000000;
268 early_serial_txx9_setup(&req);
269 }
270 }
271#ifdef CONFIG_SERIAL_TXX9_CONSOLE
272 argptr = prom_getcmdline();
273 if (strstr(argptr, "console=") == NULL) {
274 strcat(argptr, " console=ttyS0,38400");
275 }
276#endif
277#endif
278
279#ifdef CONFIG_ROOT_NFS
280 argptr = prom_getcmdline();
281 if (strstr(argptr, "root=") == NULL) {
282 strcat(argptr, " root=/dev/nfs rw");
283 }
284#endif
285
286#ifdef CONFIG_IP_PNP
287 argptr = prom_getcmdline();
288 if (strstr(argptr, "ip=") == NULL) {
289 strcat(argptr, " ip=any");
290 }
291#endif
292}
293
294static void __init rbtx49x7_common_time_init(void)
295{
296 /* change default value to udelay/mdelay take reasonable time */
297 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
298
299 mips_hpt_frequency = txx9_cpu_clock / 2;
300 if (____raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_TINTDIS)
301 txx9_clockevent_init(TX4927_TMR_REG(0) & 0xfffffffffULL,
302 TXX9_IRQ_BASE + 17,
303 50000000);
304}
305
306static void __init rbtx4927_time_init(void)
307{
308 /*
309 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
310 *
311 * For TX4927:
312 * PCIDIVMODE[12:11]'s initial value is given by S9[4:3] (ON:0, OFF:1).
313 * CPU 166MHz: PCI 66MHz : PCIDIVMODE: 00 (1/2.5)
314 * CPU 200MHz: PCI 66MHz : PCIDIVMODE: 01 (1/3)
315 * CPU 166MHz: PCI 33MHz : PCIDIVMODE: 10 (1/5)
316 * CPU 200MHz: PCI 33MHz : PCIDIVMODE: 11 (1/6)
317 * i.e. S9[3]: ON (83MHz), OFF (100MHz)
318 */
319 switch ((unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg) &
320 TX4927_CCFG_PCIDIVMODE_MASK) {
321 case TX4927_CCFG_PCIDIVMODE_2_5:
322 case TX4927_CCFG_PCIDIVMODE_5:
323 txx9_cpu_clock = 166666666; /* 166MHz */
324 break;
325 default:
326 txx9_cpu_clock = 200000000; /* 200MHz */
327 }
328
329 rbtx49x7_common_time_init();
330}
331
332static void __init rbtx4937_time_init(void)
333{
334 /*
335 * ASSUMPTION: PCIDIVMODE is configured for PCI 33MHz or 66MHz.
336 *
337 * For TX4937:
338 * PCIDIVMODE[12:11]'s initial value is given by S1[5:4] (ON:0, OFF:1)
339 * PCIDIVMODE[10] is 0.
340 * CPU 266MHz: PCI 33MHz : PCIDIVMODE: 000 (1/8)
341 * CPU 266MHz: PCI 66MHz : PCIDIVMODE: 001 (1/4)
342 * CPU 300MHz: PCI 33MHz : PCIDIVMODE: 010 (1/9)
343 * CPU 300MHz: PCI 66MHz : PCIDIVMODE: 011 (1/4.5)
344 * CPU 333MHz: PCI 33MHz : PCIDIVMODE: 100 (1/10)
345 * CPU 333MHz: PCI 66MHz : PCIDIVMODE: 101 (1/5)
346 */
347 switch ((unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg) &
348 TX4938_CCFG_PCIDIVMODE_MASK) {
349 case TX4938_CCFG_PCIDIVMODE_8:
350 case TX4938_CCFG_PCIDIVMODE_4:
351 txx9_cpu_clock = 266666666; /* 266MHz */
352 break;
353 case TX4938_CCFG_PCIDIVMODE_9:
354 case TX4938_CCFG_PCIDIVMODE_4_5:
355 txx9_cpu_clock = 300000000; /* 300MHz */
356 break;
357 default:
358 txx9_cpu_clock = 333333333; /* 333MHz */
359 }
360
361 rbtx49x7_common_time_init();
362}
363
364static int __init toshiba_rbtx4927_rtc_init(void)
365{
366 static struct resource __initdata res = {
367 .start = 0x1c010000,
368 .end = 0x1c010000 + 0x800 - 1,
369 .flags = IORESOURCE_MEM,
370 };
371 struct platform_device *dev =
372 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
373 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
374}
375
376static int __init rbtx4927_ne_init(void)
377{
378 static struct resource __initdata res[] = {
379 {
380 .start = RBTX4927_RTL_8019_BASE,
381 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
382 .flags = IORESOURCE_IO,
383 }, {
384 .start = RBTX4927_RTL_8019_IRQ,
385 .flags = IORESOURCE_IRQ,
386 }
387 };
388 struct platform_device *dev =
389 platform_device_register_simple("ne", -1,
390 res, ARRAY_SIZE(res));
391 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
392}
393
394/* Watchdog support */
395
396static int __init txx9_wdt_init(unsigned long base)
397{
398 struct resource res = {
399 .start = base,
400 .end = base + 0x100 - 1,
401 .flags = IORESOURCE_MEM,
402 };
403 struct platform_device *dev =
404 platform_device_register_simple("txx9wdt", -1, &res, 1);
405 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
406}
407
408static int __init rbtx4927_wdt_init(void)
409{
410 return txx9_wdt_init(TX4927_TMR_REG(2) & 0xfffffffffULL);
411}
412
413static void __init rbtx4927_device_init(void)
414{
415 toshiba_rbtx4927_rtc_init();
416 rbtx4927_ne_init();
417 rbtx4927_wdt_init();
418}
419
420struct txx9_board_vec rbtx4927_vec __initdata = {
421 .system = "Toshiba RBTX4927",
422 .prom_init = rbtx4927_prom_init,
423 .mem_setup = rbtx4927_mem_setup,
424 .irq_setup = rbtx4927_irq_setup,
425 .time_init = rbtx4927_time_init,
426 .device_init = rbtx4927_device_init,
427 .arch_init = rbtx4927_arch_init,
428#ifdef CONFIG_PCI
429 .pci_map_irq = rbtx4927_pci_map_irq,
430#endif
431};
432struct txx9_board_vec rbtx4937_vec __initdata = {
433 .system = "Toshiba RBTX4937",
434 .prom_init = rbtx4927_prom_init,
435 .mem_setup = rbtx4927_mem_setup,
436 .irq_setup = rbtx4927_irq_setup,
437 .time_init = rbtx4937_time_init,
438 .device_init = rbtx4927_device_init,
439 .arch_init = rbtx4937_arch_init,
440#ifdef CONFIG_PCI
441 .pci_map_irq = rbtx4927_pci_map_irq,
442#endif
443};
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/Makefile b/arch/mips/txx9/rbtx4938/Makefile
index 2316dd7dd1b..9dcc52ae5b9 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/Makefile
+++ b/arch/mips/txx9/rbtx4938/Makefile
@@ -1,7 +1,3 @@
1#
2# Makefile for common code for Toshiba TX4927 based systems
3#
4
5obj-y += prom.o setup.o irq.o spi_eeprom.o 1obj-y += prom.o setup.o irq.o spi_eeprom.o
6 2
7EXTRA_CFLAGS += -Werror 3EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c
index 4d6a8dc46c7..3971a061657 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/txx9/rbtx4938/irq.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/tx4938/toshiba_rbtx4938/irq.c
3 *
4 * Toshiba RBTX4938 specific interrupt handlers 2 * Toshiba RBTX4938 specific interrupt handlers
5 * Copyright (C) 2000-2001 Toshiba Corporation 3 * Copyright (C) 2000-2001 Toshiba Corporation
6 * 4 *
@@ -68,7 +66,9 @@ IRQ Device
68*/ 66*/
69#include <linux/init.h> 67#include <linux/init.h>
70#include <linux/interrupt.h> 68#include <linux/interrupt.h>
71#include <asm/tx4938/rbtx4938.h> 69#include <asm/mipsregs.h>
70#include <asm/txx9/generic.h>
71#include <asm/txx9/rbtx4938.h>
72 72
73static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); 73static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
74static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq); 74static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
@@ -82,26 +82,17 @@ static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
82 .unmask = toshiba_rbtx4938_irq_ioc_enable, 82 .unmask = toshiba_rbtx4938_irq_ioc_enable,
83}; 83};
84 84
85int 85static int toshiba_rbtx4938_irq_nested(int sw_irq)
86toshiba_rbtx4938_irq_nested(int sw_irq)
87{ 86{
88 u8 level3; 87 u8 level3;
89 88
90 level3 = readb(rbtx4938_imstat_addr); 89 level3 = readb(rbtx4938_imstat_addr);
91 if (level3) 90 if (level3)
92 /* must use fls so onboard ATA has priority */ 91 /* must use fls so onboard ATA has priority */
93 sw_irq = TOSHIBA_RBTX4938_IRQ_IOC_BEG + fls(level3) - 1; 92 sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1;
94
95 return sw_irq; 93 return sw_irq;
96} 94}
97 95
98static struct irqaction toshiba_rbtx4938_irq_ioc_action = {
99 .handler = no_action,
100 .flags = 0,
101 .mask = CPU_MASK_NONE,
102 .name = TOSHIBA_RBTX4938_IOC_NAME,
103};
104
105/**********************************************************************************/ 96/**********************************************************************************/
106/* Functions for ioc */ 97/* Functions for ioc */
107/**********************************************************************************/ 98/**********************************************************************************/
@@ -110,13 +101,12 @@ toshiba_rbtx4938_irq_ioc_init(void)
110{ 101{
111 int i; 102 int i;
112 103
113 for (i = TOSHIBA_RBTX4938_IRQ_IOC_BEG; 104 for (i = RBTX4938_IRQ_IOC;
114 i <= TOSHIBA_RBTX4938_IRQ_IOC_END; i++) 105 i < RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC; i++)
115 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type, 106 set_irq_chip_and_handler(i, &toshiba_rbtx4938_irq_ioc_type,
116 handle_level_irq); 107 handle_level_irq);
117 108
118 setup_irq(RBTX4938_IRQ_IOCINT, 109 set_irq_chained_handler(RBTX4938_IRQ_IOCINT, handle_simple_irq);
119 &toshiba_rbtx4938_irq_ioc_action);
120} 110}
121 111
122static void 112static void
@@ -125,7 +115,7 @@ toshiba_rbtx4938_irq_ioc_enable(unsigned int irq)
125 unsigned char v; 115 unsigned char v;
126 116
127 v = readb(rbtx4938_imask_addr); 117 v = readb(rbtx4938_imask_addr);
128 v |= (1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); 118 v |= (1 << (irq - RBTX4938_IRQ_IOC));
129 writeb(v, rbtx4938_imask_addr); 119 writeb(v, rbtx4938_imask_addr);
130 mmiowb(); 120 mmiowb();
131} 121}
@@ -136,15 +126,33 @@ toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
136 unsigned char v; 126 unsigned char v;
137 127
138 v = readb(rbtx4938_imask_addr); 128 v = readb(rbtx4938_imask_addr);
139 v &= ~(1 << (irq - TOSHIBA_RBTX4938_IRQ_IOC_BEG)); 129 v &= ~(1 << (irq - RBTX4938_IRQ_IOC));
140 writeb(v, rbtx4938_imask_addr); 130 writeb(v, rbtx4938_imask_addr);
141 mmiowb(); 131 mmiowb();
142} 132}
143 133
144void __init arch_init_irq(void) 134static int rbtx4938_irq_dispatch(int pending)
145{ 135{
146 extern void tx4938_irq_init(void); 136 int irq;
137
138 if (pending & STATUSF_IP7)
139 irq = MIPS_CPU_IRQ_BASE + 7;
140 else if (pending & STATUSF_IP2) {
141 irq = txx9_irq();
142 if (irq == RBTX4938_IRQ_IOCINT)
143 irq = toshiba_rbtx4938_irq_nested(irq);
144 } else if (pending & STATUSF_IP1)
145 irq = MIPS_CPU_IRQ_BASE + 0;
146 else if (pending & STATUSF_IP0)
147 irq = MIPS_CPU_IRQ_BASE + 1;
148 else
149 irq = -1;
150 return irq;
151}
147 152
153void __init rbtx4938_irq_setup(void)
154{
155 txx9_irq_dispatch = rbtx4938_irq_dispatch;
148 /* Now, interrupt control disabled, */ 156 /* Now, interrupt control disabled, */
149 /* all IRC interrupts are masked, */ 157 /* all IRC interrupts are masked, */
150 /* all IRC interrupt mode are Low Active. */ 158 /* all IRC interrupt mode are Low Active. */
diff --git a/arch/mips/txx9/rbtx4938/prom.c b/arch/mips/txx9/rbtx4938/prom.c
new file mode 100644
index 00000000000..fbb37458ddb
--- /dev/null
+++ b/arch/mips/txx9/rbtx4938/prom.c
@@ -0,0 +1,29 @@
1/*
2 * rbtx4938 specific prom routines
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12
13#include <linux/init.h>
14#include <linux/bootmem.h>
15#include <asm/bootinfo.h>
16#include <asm/txx9/generic.h>
17#include <asm/txx9/rbtx4938.h>
18
19void __init rbtx4938_prom_init(void)
20{
21 extern int tx4938_get_mem_size(void);
22 int msize;
23#ifndef CONFIG_TX4938_NAND_BOOT
24 prom_init_cmdline();
25#endif
26
27 msize = tx4938_get_mem_size();
28 add_memory_region(0, msize << 20, BOOT_MEM_RAM);
29}
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
new file mode 100644
index 00000000000..aaa987ae0f8
--- /dev/null
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -0,0 +1,625 @@
1/*
2 * Setup pointers to hardware-dependent routines.
3 * Copyright (C) 2000-2001 Toshiba Corporation
4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
6 * terms of the GNU General Public License version 2. This program is
7 * licensed "as is" without any warranty of any kind, whether express
8 * or implied.
9 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */
12#include <linux/init.h>
13#include <linux/types.h>
14#include <linux/ioport.h>
15#include <linux/delay.h>
16#include <linux/interrupt.h>
17#include <linux/console.h>
18#include <linux/pm.h>
19#include <linux/platform_device.h>
20#include <linux/gpio.h>
21
22#include <asm/reboot.h>
23#include <asm/time.h>
24#include <asm/txx9tmr.h>
25#include <asm/io.h>
26#include <asm/txx9/generic.h>
27#include <asm/txx9/pci.h>
28#include <asm/txx9/rbtx4938.h>
29#ifdef CONFIG_SERIAL_TXX9
30#include <linux/serial_core.h>
31#endif
32#include <linux/spi/spi.h>
33#include <asm/txx9/spi.h>
34#include <asm/txx9pio.h>
35
36static int tx4938_ccfg_toeon = 1;
37
38static void rbtx4938_machine_halt(void)
39{
40 printk(KERN_NOTICE "System Halted\n");
41 local_irq_disable();
42
43 while (1)
44 __asm__(".set\tmips3\n\t"
45 "wait\n\t"
46 ".set\tmips0");
47}
48
49static void rbtx4938_machine_power_off(void)
50{
51 rbtx4938_machine_halt();
52 /* no return */
53}
54
55static void rbtx4938_machine_restart(char *command)
56{
57 local_irq_disable();
58
59 printk("Rebooting...");
60 writeb(1, rbtx4938_softresetlock_addr);
61 writeb(1, rbtx4938_sfvol_addr);
62 writeb(1, rbtx4938_softreset_addr);
63 while(1)
64 ;
65}
66
67static void __init rbtx4938_pci_setup(void)
68{
69#ifdef CONFIG_PCI
70 int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
71 struct pci_controller *c = &txx9_primary_pcic;
72
73 register_pci_controller(c);
74
75 if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
76 txx9_pci_option =
77 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
78 TXX9_PCI_OPT_CLK_66; /* already configured */
79
80 /* Reset PCI Bus */
81 writeb(0, rbtx4938_pcireset_addr);
82 /* Reset PCIC */
83 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
84 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
85 TXX9_PCI_OPT_CLK_66)
86 tx4938_pciclk66_setup();
87 mdelay(10);
88 /* clear PCIC reset */
89 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
90 writeb(1, rbtx4938_pcireset_addr);
91 iob();
92
93 tx4938_report_pciclk();
94 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
95 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
96 TXX9_PCI_OPT_CLK_AUTO &&
97 txx9_pci66_check(c, 0, 0)) {
98 /* Reset PCI Bus */
99 writeb(0, rbtx4938_pcireset_addr);
100 /* Reset PCIC */
101 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
102 tx4938_pciclk66_setup();
103 mdelay(10);
104 /* clear PCIC reset */
105 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
106 writeb(1, rbtx4938_pcireset_addr);
107 iob();
108 /* Reinitialize PCIC */
109 tx4938_report_pciclk();
110 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
111 }
112
113 if (__raw_readq(&tx4938_ccfgptr->pcfg) &
114 (TX4938_PCFG_ETH0_SEL|TX4938_PCFG_ETH1_SEL)) {
115 /* Reset PCIC1 */
116 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
117 /* PCI1DMD==0 => PCI1CLK==GBUSCLK/2 => PCI66 */
118 if (!(__raw_readq(&tx4938_ccfgptr->ccfg)
119 & TX4938_CCFG_PCI1DMD))
120 tx4938_ccfg_set(TX4938_CCFG_PCI1_66);
121 mdelay(10);
122 /* clear PCIC1 reset */
123 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
124 tx4938_report_pci1clk();
125
126 /* mem:64K(max), io:64K(max) (enough for ETH0,ETH1) */
127 c = txx9_alloc_pci_controller(NULL, 0, 0x10000, 0, 0x10000);
128 register_pci_controller(c);
129 tx4927_pcic_setup(tx4938_pcic1ptr, c, 0);
130 }
131#endif /* CONFIG_PCI */
132}
133
134/* SPI support */
135
136/* chip select for SPI devices */
137#define SEEPROM1_CS 7 /* PIO7 */
138#define SEEPROM2_CS 0 /* IOC */
139#define SEEPROM3_CS 1 /* IOC */
140#define SRTC_CS 2 /* IOC */
141
142static int __init rbtx4938_ethaddr_init(void)
143{
144#ifdef CONFIG_PCI
145 unsigned char dat[17];
146 unsigned char sum;
147 int i;
148
149 /* 0-3: "MAC\0", 4-9:eth0, 10-15:eth1, 16:sum */
150 if (spi_eeprom_read(SEEPROM1_CS, 0, dat, sizeof(dat))) {
151 printk(KERN_ERR "seeprom: read error.\n");
152 return -ENODEV;
153 } else {
154 if (strcmp(dat, "MAC") != 0)
155 printk(KERN_WARNING "seeprom: bad signature.\n");
156 for (i = 0, sum = 0; i < sizeof(dat); i++)
157 sum += dat[i];
158 if (sum)
159 printk(KERN_WARNING "seeprom: bad checksum.\n");
160 }
161 for (i = 0; i < 2; i++) {
162 unsigned int id =
163 TXX9_IRQ_BASE + (i ? TX4938_IR_ETH1 : TX4938_IR_ETH0);
164 struct platform_device *pdev;
165 if (!(__raw_readq(&tx4938_ccfgptr->pcfg) &
166 (i ? TX4938_PCFG_ETH1_SEL : TX4938_PCFG_ETH0_SEL)))
167 continue;
168 pdev = platform_device_alloc("tc35815-mac", id);
169 if (!pdev ||
170 platform_device_add_data(pdev, &dat[4 + 6 * i], 6) ||
171 platform_device_add(pdev))
172 platform_device_put(pdev);
173 }
174#endif /* CONFIG_PCI */
175 return 0;
176}
177
178static void __init rbtx4938_spi_setup(void)
179{
180 /* set SPI_SEL */
181 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_SPI_SEL);
182}
183
184static struct resource rbtx4938_fpga_resource;
185static struct resource tx4938_sdram_resource[4];
186static struct resource tx4938_sram_resource;
187
188void __init tx4938_board_setup(void)
189{
190 int i;
191 unsigned long divmode;
192 int cpuclk = 0;
193 unsigned long pcode = TX4938_REV_PCODE();
194
195 ioport_resource.start = 0;
196 ioport_resource.end = 0xffffffff;
197 iomem_resource.start = 0;
198 iomem_resource.end = 0xffffffff; /* expand to 4GB */
199
200 txx9_reg_res_init(pcode, TX4938_REG_BASE,
201 TX4938_REG_SIZE);
202 /* SDRAMC,EBUSC are configured by PROM */
203 for (i = 0; i < 8; i++) {
204 if (!(TX4938_EBUSC_CR(i) & 0x8))
205 continue; /* disabled */
206 txx9_ce_res[i].start = (unsigned long)TX4938_EBUSC_BA(i);
207 txx9_ce_res[i].end =
208 txx9_ce_res[i].start + TX4938_EBUSC_SIZE(i) - 1;
209 request_resource(&iomem_resource, &txx9_ce_res[i]);
210 }
211
212 /* clocks */
213 if (txx9_master_clock) {
214 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
215 /* calculate gbus_clock and cpu_clock_freq from master_clock */
216 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
217 switch (divmode) {
218 case TX4938_CCFG_DIVMODE_8:
219 case TX4938_CCFG_DIVMODE_10:
220 case TX4938_CCFG_DIVMODE_12:
221 case TX4938_CCFG_DIVMODE_16:
222 case TX4938_CCFG_DIVMODE_18:
223 txx9_gbus_clock = txx9_master_clock * 4; break;
224 default:
225 txx9_gbus_clock = txx9_master_clock;
226 }
227 switch (divmode) {
228 case TX4938_CCFG_DIVMODE_2:
229 case TX4938_CCFG_DIVMODE_8:
230 cpuclk = txx9_gbus_clock * 2; break;
231 case TX4938_CCFG_DIVMODE_2_5:
232 case TX4938_CCFG_DIVMODE_10:
233 cpuclk = txx9_gbus_clock * 5 / 2; break;
234 case TX4938_CCFG_DIVMODE_3:
235 case TX4938_CCFG_DIVMODE_12:
236 cpuclk = txx9_gbus_clock * 3; break;
237 case TX4938_CCFG_DIVMODE_4:
238 case TX4938_CCFG_DIVMODE_16:
239 cpuclk = txx9_gbus_clock * 4; break;
240 case TX4938_CCFG_DIVMODE_4_5:
241 case TX4938_CCFG_DIVMODE_18:
242 cpuclk = txx9_gbus_clock * 9 / 2; break;
243 }
244 txx9_cpu_clock = cpuclk;
245 } else {
246 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
247 if (txx9_cpu_clock == 0) {
248 txx9_cpu_clock = 300000000; /* 300MHz */
249 }
250 /* calculate gbus_clock and master_clock from cpu_clock_freq */
251 cpuclk = txx9_cpu_clock;
252 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
253 switch (divmode) {
254 case TX4938_CCFG_DIVMODE_2:
255 case TX4938_CCFG_DIVMODE_8:
256 txx9_gbus_clock = cpuclk / 2; break;
257 case TX4938_CCFG_DIVMODE_2_5:
258 case TX4938_CCFG_DIVMODE_10:
259 txx9_gbus_clock = cpuclk * 2 / 5; break;
260 case TX4938_CCFG_DIVMODE_3:
261 case TX4938_CCFG_DIVMODE_12:
262 txx9_gbus_clock = cpuclk / 3; break;
263 case TX4938_CCFG_DIVMODE_4:
264 case TX4938_CCFG_DIVMODE_16:
265 txx9_gbus_clock = cpuclk / 4; break;
266 case TX4938_CCFG_DIVMODE_4_5:
267 case TX4938_CCFG_DIVMODE_18:
268 txx9_gbus_clock = cpuclk * 2 / 9; break;
269 }
270 switch (divmode) {
271 case TX4938_CCFG_DIVMODE_8:
272 case TX4938_CCFG_DIVMODE_10:
273 case TX4938_CCFG_DIVMODE_12:
274 case TX4938_CCFG_DIVMODE_16:
275 case TX4938_CCFG_DIVMODE_18:
276 txx9_master_clock = txx9_gbus_clock / 4; break;
277 default:
278 txx9_master_clock = txx9_gbus_clock;
279 }
280 }
281 /* change default value to udelay/mdelay take reasonable time */
282 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
283
284 /* CCFG */
285 /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */
286 tx4938_ccfg_set(TX4938_CCFG_WDRST | TX4938_CCFG_BEOW);
287 /* do reset on watchdog */
288 tx4938_ccfg_set(TX4938_CCFG_WR);
289 /* clear PCIC1 reset */
290 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
291
292 /* enable Timeout BusError */
293 if (tx4938_ccfg_toeon)
294 tx4938_ccfg_set(TX4938_CCFG_TOE);
295
296 /* DMA selection */
297 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_DMASEL_ALL);
298
299 /* Use external clock for external arbiter */
300 if (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB))
301 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_PCICLKEN_ALL);
302
303 printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
304 txx9_pcode_str,
305 (cpuclk + 500000) / 1000000,
306 (txx9_master_clock + 500000) / 1000000,
307 (__u32)____raw_readq(&tx4938_ccfgptr->crir),
308 (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg),
309 (unsigned long long)____raw_readq(&tx4938_ccfgptr->pcfg));
310
311 printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str);
312 for (i = 0; i < 4; i++) {
313 unsigned long long cr = tx4938_sdramcptr->cr[i];
314 unsigned long ram_base, ram_size;
315 if (!((unsigned long)cr & 0x00000400))
316 continue; /* disabled */
317 ram_base = (unsigned long)(cr >> 49) << 21;
318 ram_size = ((unsigned long)(cr >> 33) + 1) << 21;
319 if (ram_base >= 0x20000000)
320 continue; /* high memory (ignore) */
321 printk(" CR%d:%016Lx", i, cr);
322 tx4938_sdram_resource[i].name = "SDRAM";
323 tx4938_sdram_resource[i].start = ram_base;
324 tx4938_sdram_resource[i].end = ram_base + ram_size - 1;
325 tx4938_sdram_resource[i].flags = IORESOURCE_MEM;
326 request_resource(&iomem_resource, &tx4938_sdram_resource[i]);
327 }
328 printk(" TR:%09Lx\n", tx4938_sdramcptr->tr);
329
330 /* SRAM */
331 if (tx4938_sramcptr->cr & 1) {
332 unsigned int size = 0x800;
333 unsigned long base =
334 (tx4938_sramcptr->cr >> (39-11)) & ~(size - 1);
335 tx4938_sram_resource.name = "SRAM";
336 tx4938_sram_resource.start = base;
337 tx4938_sram_resource.end = base + size - 1;
338 tx4938_sram_resource.flags = IORESOURCE_MEM;
339 request_resource(&iomem_resource, &tx4938_sram_resource);
340 }
341
342 /* TMR */
343 for (i = 0; i < TX4938_NR_TMR; i++)
344 txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
345
346 /* enable DMA */
347 for (i = 0; i < 2; i++)
348 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
349 (void __iomem *)(TX4938_DMA_REG(i) + 0x50));
350
351 /* PIO */
352 __raw_writel(0, &tx4938_pioptr->maskcpu);
353 __raw_writel(0, &tx4938_pioptr->maskext);
354
355#ifdef CONFIG_PCI
356 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
357#endif
358}
359
360static void __init rbtx4938_time_init(void)
361{
362 mips_hpt_frequency = txx9_cpu_clock / 2;
363 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS)
364 txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL,
365 TXX9_IRQ_BASE + TX4938_IR_TMR(0),
366 txx9_gbus_clock / 2);
367}
368
369static void __init rbtx4938_mem_setup(void)
370{
371 unsigned long long pcfg;
372 char *argptr;
373
374 iomem_resource.end = 0xffffffff; /* 4GB */
375
376 if (txx9_master_clock == 0)
377 txx9_master_clock = 25000000; /* 25MHz */
378 tx4938_board_setup();
379#ifndef CONFIG_PCI
380 set_io_port_base(RBTX4938_ETHER_BASE);
381#endif
382
383#ifdef CONFIG_SERIAL_TXX9
384 {
385 extern int early_serial_txx9_setup(struct uart_port *port);
386 int i;
387 struct uart_port req;
388 for(i = 0; i < 2; i++) {
389 memset(&req, 0, sizeof(req));
390 req.line = i;
391 req.iotype = UPIO_MEM;
392 req.membase = (char *)(0xff1ff300 + i * 0x100);
393 req.mapbase = 0xff1ff300 + i * 0x100;
394 req.irq = RBTX4938_IRQ_IRC_SIO(i);
395 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
396 req.uartclk = 50000000;
397 early_serial_txx9_setup(&req);
398 }
399 }
400#ifdef CONFIG_SERIAL_TXX9_CONSOLE
401 argptr = prom_getcmdline();
402 if (strstr(argptr, "console=") == NULL) {
403 strcat(argptr, " console=ttyS0,38400");
404 }
405#endif
406#endif
407
408#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
409 printk("PIOSEL: disabling both ata and nand selection\n");
410 local_irq_disable();
411 txx9_clear64(&tx4938_ccfgptr->pcfg,
412 TX4938_PCFG_NDF_SEL | TX4938_PCFG_ATA_SEL);
413#endif
414
415#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_NAND
416 printk("PIOSEL: enabling nand selection\n");
417 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
418 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
419#endif
420
421#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_ATA
422 printk("PIOSEL: enabling ata selection\n");
423 txx9_set64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_ATA_SEL);
424 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_NDF_SEL);
425#endif
426
427#ifdef CONFIG_IP_PNP
428 argptr = prom_getcmdline();
429 if (strstr(argptr, "ip=") == NULL) {
430 strcat(argptr, " ip=any");
431 }
432#endif
433
434
435#ifdef CONFIG_FB
436 {
437 conswitchp = &dummy_con;
438 }
439#endif
440
441 rbtx4938_spi_setup();
442 pcfg = ____raw_readq(&tx4938_ccfgptr->pcfg); /* updated */
443 /* fixup piosel */
444 if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
445 TX4938_PCFG_ATA_SEL)
446 writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x04,
447 rbtx4938_piosel_addr);
448 else if ((pcfg & (TX4938_PCFG_ATA_SEL | TX4938_PCFG_NDF_SEL)) ==
449 TX4938_PCFG_NDF_SEL)
450 writeb((readb(rbtx4938_piosel_addr) & 0x03) | 0x08,
451 rbtx4938_piosel_addr);
452 else
453 writeb(readb(rbtx4938_piosel_addr) & ~(0x08 | 0x04),
454 rbtx4938_piosel_addr);
455
456 rbtx4938_fpga_resource.name = "FPGA Registers";
457 rbtx4938_fpga_resource.start = CPHYSADDR(RBTX4938_FPGA_REG_ADDR);
458 rbtx4938_fpga_resource.end = CPHYSADDR(RBTX4938_FPGA_REG_ADDR) + 0xffff;
459 rbtx4938_fpga_resource.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
460 if (request_resource(&iomem_resource, &rbtx4938_fpga_resource))
461 printk("request resource for fpga failed\n");
462
463 _machine_restart = rbtx4938_machine_restart;
464 _machine_halt = rbtx4938_machine_halt;
465 pm_power_off = rbtx4938_machine_power_off;
466
467 writeb(0xff, rbtx4938_led_addr);
468 printk(KERN_INFO "RBTX4938 --- FPGA(Rev %02x) DIPSW:%02x,%02x\n",
469 readb(rbtx4938_fpga_rev_addr),
470 readb(rbtx4938_dipsw_addr), readb(rbtx4938_bdipsw_addr));
471}
472
473static int __init rbtx4938_ne_init(void)
474{
475 struct resource res[] = {
476 {
477 .start = RBTX4938_RTL_8019_BASE,
478 .end = RBTX4938_RTL_8019_BASE + 0x20 - 1,
479 .flags = IORESOURCE_IO,
480 }, {
481 .start = RBTX4938_RTL_8019_IRQ,
482 .flags = IORESOURCE_IRQ,
483 }
484 };
485 struct platform_device *dev =
486 platform_device_register_simple("ne", -1,
487 res, ARRAY_SIZE(res));
488 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
489}
490
491/* GPIO support */
492
493int gpio_to_irq(unsigned gpio)
494{
495 return -EINVAL;
496}
497
498int irq_to_gpio(unsigned irq)
499{
500 return -EINVAL;
501}
502
503static DEFINE_SPINLOCK(rbtx4938_spi_gpio_lock);
504
505static void rbtx4938_spi_gpio_set(struct gpio_chip *chip, unsigned int offset,
506 int value)
507{
508 u8 val;
509 unsigned long flags;
510 spin_lock_irqsave(&rbtx4938_spi_gpio_lock, flags);
511 val = readb(rbtx4938_spics_addr);
512 if (value)
513 val |= 1 << offset;
514 else
515 val &= ~(1 << offset);
516 writeb(val, rbtx4938_spics_addr);
517 mmiowb();
518 spin_unlock_irqrestore(&rbtx4938_spi_gpio_lock, flags);
519}
520
521static int rbtx4938_spi_gpio_dir_out(struct gpio_chip *chip,
522 unsigned int offset, int value)
523{
524 rbtx4938_spi_gpio_set(chip, offset, value);
525 return 0;
526}
527
528static struct gpio_chip rbtx4938_spi_gpio_chip = {
529 .set = rbtx4938_spi_gpio_set,
530 .direction_output = rbtx4938_spi_gpio_dir_out,
531 .label = "RBTX4938-SPICS",
532 .base = 16,
533 .ngpio = 3,
534};
535
536/* SPI support */
537
538static void __init txx9_spi_init(unsigned long base, int irq)
539{
540 struct resource res[] = {
541 {
542 .start = base,
543 .end = base + 0x20 - 1,
544 .flags = IORESOURCE_MEM,
545 }, {
546 .start = irq,
547 .flags = IORESOURCE_IRQ,
548 },
549 };
550 platform_device_register_simple("spi_txx9", 0,
551 res, ARRAY_SIZE(res));
552}
553
554static int __init rbtx4938_spi_init(void)
555{
556 struct spi_board_info srtc_info = {
557 .modalias = "rtc-rs5c348",
558 .max_speed_hz = 1000000, /* 1.0Mbps @ Vdd 2.0V */
559 .bus_num = 0,
560 .chip_select = 16 + SRTC_CS,
561 /* Mode 1 (High-Active, Shift-Then-Sample), High Avtive CS */
562 .mode = SPI_MODE_1 | SPI_CS_HIGH,
563 };
564 spi_register_board_info(&srtc_info, 1);
565 spi_eeprom_register(SEEPROM1_CS);
566 spi_eeprom_register(16 + SEEPROM2_CS);
567 spi_eeprom_register(16 + SEEPROM3_CS);
568 gpio_request(16 + SRTC_CS, "rtc-rs5c348");
569 gpio_direction_output(16 + SRTC_CS, 0);
570 gpio_request(SEEPROM1_CS, "seeprom1");
571 gpio_direction_output(SEEPROM1_CS, 1);
572 gpio_request(16 + SEEPROM2_CS, "seeprom2");
573 gpio_direction_output(16 + SEEPROM2_CS, 1);
574 gpio_request(16 + SEEPROM3_CS, "seeprom3");
575 gpio_direction_output(16 + SEEPROM3_CS, 1);
576 txx9_spi_init(TX4938_SPI_REG & 0xfffffffffULL, RBTX4938_IRQ_IRC_SPI);
577 return 0;
578}
579
580static void __init rbtx4938_arch_init(void)
581{
582 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16);
583 gpiochip_add(&rbtx4938_spi_gpio_chip);
584 rbtx4938_pci_setup();
585 rbtx4938_spi_init();
586}
587
588/* Watchdog support */
589
590static int __init txx9_wdt_init(unsigned long base)
591{
592 struct resource res = {
593 .start = base,
594 .end = base + 0x100 - 1,
595 .flags = IORESOURCE_MEM,
596 };
597 struct platform_device *dev =
598 platform_device_register_simple("txx9wdt", -1, &res, 1);
599 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
600}
601
602static int __init rbtx4938_wdt_init(void)
603{
604 return txx9_wdt_init(TX4938_TMR_REG(2) & 0xfffffffffULL);
605}
606
607static void __init rbtx4938_device_init(void)
608{
609 rbtx4938_ethaddr_init();
610 rbtx4938_ne_init();
611 rbtx4938_wdt_init();
612}
613
614struct txx9_board_vec rbtx4938_vec __initdata = {
615 .system = "Toshiba RBTX4938",
616 .prom_init = rbtx4938_prom_init,
617 .mem_setup = rbtx4938_mem_setup,
618 .irq_setup = rbtx4938_irq_setup,
619 .time_init = rbtx4938_time_init,
620 .device_init = rbtx4938_device_init,
621 .arch_init = rbtx4938_arch_init,
622#ifdef CONFIG_PCI
623 .pci_map_irq = rbtx4938_pci_map_irq,
624#endif
625};
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c b/arch/mips/txx9/rbtx4938/spi_eeprom.c
index 4d6b4ade5e8..a7ea8b041c1 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c
+++ b/arch/mips/txx9/rbtx4938/spi_eeprom.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/mips/tx4938/toshiba_rbtx4938/spi_eeprom.c 2 * spi_eeprom.c
3 * Copyright (C) 2000-2001 Toshiba Corporation 3 * Copyright (C) 2000-2001 Toshiba Corporation
4 * 4 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the 5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
@@ -13,7 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <linux/spi/eeprom.h> 15#include <linux/spi/eeprom.h>
16#include <asm/tx4938/spi.h> 16#include <asm/txx9/spi.h>
17 17
18#define AT250X0_PAGE_SIZE 8 18#define AT250X0_PAGE_SIZE 8
19 19
diff --git a/arch/mips/vr41xx/Kconfig b/arch/mips/vr41xx/Kconfig
index 559acc09c81..c1be6b37fb2 100644
--- a/arch/mips/vr41xx/Kconfig
+++ b/arch/mips/vr41xx/Kconfig
@@ -23,16 +23,6 @@ config IBM_WORKPAD
23 select SYS_SUPPORTS_32BIT_KERNEL 23 select SYS_SUPPORTS_32BIT_KERNEL
24 select SYS_SUPPORTS_LITTLE_ENDIAN 24 select SYS_SUPPORTS_LITTLE_ENDIAN
25 25
26config NEC_CMBVR4133
27 bool "NEC CMB-VR4133"
28 select CEVT_R4K
29 select CSRC_R4K
30 select DMA_NONCOHERENT
31 select IRQ_CPU
32 select HW_HAS_PCI
33 select SYS_SUPPORTS_32BIT_KERNEL
34 select SYS_SUPPORTS_LITTLE_ENDIAN
35
36config TANBAC_TB022X 26config TANBAC_TB022X
37 bool "TANBAC VR4131 multichip module and TANBAC VR4131DIMM" 27 bool "TANBAC VR4131 multichip module and TANBAC VR4131DIMM"
38 select CEVT_R4K 28 select CEVT_R4K
@@ -73,13 +63,6 @@ config ZAO_CAPCELLA
73 63
74endchoice 64endchoice
75 65
76config ROCKHOPPER
77 bool "Support for Rockhopper base board"
78 depends on NEC_CMBVR4133
79 select PCI_VR41XX
80 select I8259
81 select HAVE_STD_PC_SERIAL_PORT
82
83choice 66choice
84 prompt "Base board type" 67 prompt "Base board type"
85 depends on TANBAC_TB022X 68 depends on TANBAC_TB022X
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/Makefile b/arch/mips/vr41xx/nec-cmbvr4133/Makefile
deleted file mode 100644
index 5835cae54ac..00000000000
--- a/arch/mips/vr41xx/nec-cmbvr4133/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the NEC-CMBVR4133
3#
4
5obj-y := init.o setup.o
6
7obj-$(CONFIG_PCI) += m1535plus.o
8obj-$(CONFIG_ROCKHOPPER) += irq.o
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/init.c b/arch/mips/vr41xx/nec-cmbvr4133/init.c
deleted file mode 100644
index 7c5e18ee223..00000000000
--- a/arch/mips/vr41xx/nec-cmbvr4133/init.c
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * arch/mips/vr41xx/nec-cmbvr4133/init.c
3 *
4 * PROM library initialisation code for NEC CMB-VR4133 board.
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Jun Sun <jsun@mvista.com, or source@mvista.com> and
8 * Alex Sapkov <asapkov@ru.mvista.com>
9 *
10 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2. This program
12 * is licensed "as is" without any warranty of any kind, whether express
13 * or implied.
14 *
15 * Support for NEC-CMBVR4133 in 2.6
16 * Manish Lachwani (mlachwani@mvista.com)
17 */
18
19#ifdef CONFIG_ROCKHOPPER
20#include <asm/io.h>
21#include <linux/pci.h>
22
23#define PCICONFDREG 0xaf000c14
24#define PCICONFAREG 0xaf000c18
25
26void disable_pcnet(void)
27{
28 u32 data;
29
30 /*
31 * Workaround for the bug in PMON on VR4133. PMON leaves
32 * AMD PCNet controller (on Rockhopper) initialized and running in
33 * bus master mode. We have do disable it before doing any
34 * further initialization. Or we get problems with PCI bus 2
35 * and random lockups and crashes.
36 */
37
38 writel((2 << 16) |
39 (PCI_DEVFN(1, 0) << 8) |
40 (0 & 0xfc) |
41 1UL,
42 PCICONFAREG);
43
44 data = readl(PCICONFDREG);
45
46 writel((2 << 16) |
47 (PCI_DEVFN(1, 0) << 8) |
48 (4 & 0xfc) |
49 1UL,
50 PCICONFAREG);
51
52 data = readl(PCICONFDREG);
53
54 writel((2 << 16) |
55 (PCI_DEVFN(1, 0) << 8) |
56 (4 & 0xfc) |
57 1UL,
58 PCICONFAREG);
59
60 data &= ~4;
61
62 writel(data, PCICONFDREG);
63}
64#endif
65
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/irq.c b/arch/mips/vr41xx/nec-cmbvr4133/irq.c
deleted file mode 100644
index 7d2d076b0f5..00000000000
--- a/arch/mips/vr41xx/nec-cmbvr4133/irq.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * arch/mips/vr41xx/nec-cmbvr4133/irq.c
3 *
4 * Interrupt routines for the NEC CMB-VR4133 board.
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Alex Sapkov <asapkov@ru.mvista.com>
8 *
9 * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 *
14 * Support for NEC-CMBVR4133 in 2.6
15 * Manish Lachwani (mlachwani@mvista.com)
16 */
17#include <linux/bitops.h>
18#include <linux/errno.h>
19#include <linux/init.h>
20#include <linux/ioport.h>
21#include <linux/interrupt.h>
22
23#include <asm/io.h>
24#include <asm/i8259.h>
25#include <asm/vr41xx/cmbvr4133.h>
26
27extern int vr4133_rockhopper;
28
29static int i8259_get_irq_number(int irq)
30{
31 return i8259_irq();
32}
33
34void __init rockhopper_init_irq(void)
35{
36 int i;
37
38 if(!vr4133_rockhopper) {
39 printk(KERN_ERR "Not a Rockhopper Board \n");
40 return;
41 }
42
43 vr41xx_set_irq_trigger(CMBVR41XX_INTC_PIN, TRIGGER_LEVEL, SIGNAL_THROUGH);
44 vr41xx_set_irq_level(CMBVR41XX_INTC_PIN, LEVEL_HIGH);
45 vr41xx_cascade_irq(CMBVR41XX_INTC_IRQ, i8259_get_irq_number);
46}
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/m1535plus.c b/arch/mips/vr41xx/nec-cmbvr4133/m1535plus.c
deleted file mode 100644
index 1341f3287d0..00000000000
--- a/arch/mips/vr41xx/nec-cmbvr4133/m1535plus.c
+++ /dev/null
@@ -1,249 +0,0 @@
1/*
2 * arch/mips/vr41xx/nec-cmbvr4133/m1535plus.c
3 *
4 * Initialize for ALi M1535+(included M5229 and M5237).
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Alex Sapkov <asapkov@ru.mvista.com>
8 *
9 * 2003-2004 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 *
14 * Support for NEC-CMBVR4133 in 2.6
15 * Author: Manish Lachwani (mlachwani@mvista.com)
16 */
17#include <linux/init.h>
18#include <linux/types.h>
19#include <linux/serial.h>
20
21#include <asm/vr41xx/cmbvr4133.h>
22#include <linux/pci.h>
23#include <asm/io.h>
24
25#define CONFIG_PORT(port) ((port) ? 0x3f0 : 0x370)
26#define DATA_PORT(port) ((port) ? 0x3f1 : 0x371)
27#define INDEX_PORT(port) CONFIG_PORT(port)
28
29#define ENTER_CONFIG_MODE(port) \
30 do { \
31 outb_p(0x51, CONFIG_PORT(port)); \
32 outb_p(0x23, CONFIG_PORT(port)); \
33 } while(0)
34
35#define SELECT_LOGICAL_DEVICE(port, dev_no) \
36 do { \
37 outb_p(0x07, INDEX_PORT(port)); \
38 outb_p((dev_no), DATA_PORT(port)); \
39 } while(0)
40
41#define WRITE_CONFIG_DATA(port, index, data) \
42 do { \
43 outb_p((index), INDEX_PORT(port)); \
44 outb_p((data), DATA_PORT(port)); \
45 } while(0)
46
47#define EXIT_CONFIG_MODE(port) outb(0xbb, CONFIG_PORT(port))
48
49#define PCI_CONFIG_ADDR KSEG1ADDR(0x0f000c18)
50#define PCI_CONFIG_DATA KSEG1ADDR(0x0f000c14)
51
52#ifdef CONFIG_BLK_DEV_FD
53
54void __devinit ali_m1535plus_fdc_init(int port)
55{
56 ENTER_CONFIG_MODE(port);
57 SELECT_LOGICAL_DEVICE(port, 0); /* FDC */
58 WRITE_CONFIG_DATA(port, 0x30, 0x01); /* FDC: enable */
59 WRITE_CONFIG_DATA(port, 0x60, 0x03); /* I/O port base: 0x3f0 */
60 WRITE_CONFIG_DATA(port, 0x61, 0xf0);
61 WRITE_CONFIG_DATA(port, 0x70, 0x06); /* IRQ: 6 */
62 WRITE_CONFIG_DATA(port, 0x74, 0x02); /* DMA: channel 2 */
63 WRITE_CONFIG_DATA(port, 0xf0, 0x08);
64 WRITE_CONFIG_DATA(port, 0xf1, 0x00);
65 WRITE_CONFIG_DATA(port, 0xf2, 0xff);
66 WRITE_CONFIG_DATA(port, 0xf4, 0x00);
67 EXIT_CONFIG_MODE(port);
68}
69
70#endif
71
72void __devinit ali_m1535plus_parport_init(int port)
73{
74 ENTER_CONFIG_MODE(port);
75 SELECT_LOGICAL_DEVICE(port, 3); /* Parallel Port */
76 WRITE_CONFIG_DATA(port, 0x30, 0x01);
77 WRITE_CONFIG_DATA(port, 0x60, 0x03); /* I/O port base: 0x378 */
78 WRITE_CONFIG_DATA(port, 0x61, 0x78);
79 WRITE_CONFIG_DATA(port, 0x70, 0x07); /* IRQ: 7 */
80 WRITE_CONFIG_DATA(port, 0x74, 0x04); /* DMA: None */
81 WRITE_CONFIG_DATA(port, 0xf0, 0x8c); /* IRQ polarity: Active Low */
82 WRITE_CONFIG_DATA(port, 0xf1, 0xc5);
83 EXIT_CONFIG_MODE(port);
84}
85
86void __devinit ali_m1535plus_keyboard_init(int port)
87{
88 ENTER_CONFIG_MODE(port);
89 SELECT_LOGICAL_DEVICE(port, 7); /* KEYBOARD */
90 WRITE_CONFIG_DATA(port, 0x30, 0x01); /* KEYBOARD: eable */
91 WRITE_CONFIG_DATA(port, 0x70, 0x01); /* IRQ: 1 */
92 WRITE_CONFIG_DATA(port, 0x72, 0x0c); /* PS/2 Mouse IRQ: 12 */
93 WRITE_CONFIG_DATA(port, 0xf0, 0x00);
94 EXIT_CONFIG_MODE(port);
95}
96
97void __devinit ali_m1535plus_hotkey_init(int port)
98{
99 ENTER_CONFIG_MODE(port);
100 SELECT_LOGICAL_DEVICE(port, 0xc); /* HOTKEY */
101 WRITE_CONFIG_DATA(port, 0x30, 0x00);
102 WRITE_CONFIG_DATA(port, 0xf0, 0x35);
103 WRITE_CONFIG_DATA(port, 0xf1, 0x14);
104 WRITE_CONFIG_DATA(port, 0xf2, 0x11);
105 WRITE_CONFIG_DATA(port, 0xf3, 0x71);
106 WRITE_CONFIG_DATA(port, 0xf5, 0x05);
107 EXIT_CONFIG_MODE(port);
108}
109
110void ali_m1535plus_init(struct pci_dev *dev)
111{
112 pci_write_config_byte(dev, 0x40, 0x18); /* PCI Interface Control */
113 pci_write_config_byte(dev, 0x41, 0xc0); /* PS2 keyb & mouse enable */
114 pci_write_config_byte(dev, 0x42, 0x41); /* ISA bus cycle control */
115 pci_write_config_byte(dev, 0x43, 0x00); /* ISA bus cycle control 2 */
116 pci_write_config_byte(dev, 0x44, 0x5d); /* IDE enable & IRQ 14 */
117 pci_write_config_byte(dev, 0x45, 0x0b); /* PCI int polling mode */
118 pci_write_config_byte(dev, 0x47, 0x00); /* BIOS chip select control */
119
120 /* IRQ routing */
121 pci_write_config_byte(dev, 0x48, 0x03); /* INTA IRQ10, INTB disable */
122 pci_write_config_byte(dev, 0x49, 0x00); /* INTC and INTD disable */
123 pci_write_config_byte(dev, 0x4a, 0x00); /* INTE and INTF disable */
124 pci_write_config_byte(dev, 0x4b, 0x90); /* Audio IRQ11, Modem disable */
125
126 pci_write_config_word(dev, 0x50, 0x4000); /* Parity check IDE enable */
127 pci_write_config_word(dev, 0x52, 0x0000); /* USB & RTC disable */
128 pci_write_config_word(dev, 0x54, 0x0002); /* ??? no info */
129 pci_write_config_word(dev, 0x56, 0x0002); /* PCS1J signal disable */
130
131 pci_write_config_byte(dev, 0x59, 0x00); /* PCSDS */
132 pci_write_config_byte(dev, 0x5a, 0x00);
133 pci_write_config_byte(dev, 0x5b, 0x00);
134 pci_write_config_word(dev, 0x5c, 0x0000);
135 pci_write_config_byte(dev, 0x5e, 0x00);
136 pci_write_config_byte(dev, 0x5f, 0x00);
137 pci_write_config_word(dev, 0x60, 0x0000);
138
139 pci_write_config_byte(dev, 0x6c, 0x00);
140 pci_write_config_byte(dev, 0x6d, 0x48); /* ROM address mapping */
141 pci_write_config_byte(dev, 0x6e, 0x00); /* ??? what for? */
142
143 pci_write_config_byte(dev, 0x70, 0x12); /* Serial IRQ control */
144 pci_write_config_byte(dev, 0x71, 0xEF); /* DMA channel select */
145 pci_write_config_byte(dev, 0x72, 0x03); /* USB IDSEL */
146 pci_write_config_byte(dev, 0x73, 0x00); /* ??? no info */
147
148 /*
149 * IRQ setup ALi M5237 USB Host Controller
150 * IRQ: 9
151 */
152 pci_write_config_byte(dev, 0x74, 0x01); /* USB IRQ9 */
153
154 pci_write_config_byte(dev, 0x75, 0x1f); /* IDE2 IRQ 15 */
155 pci_write_config_byte(dev, 0x76, 0x80); /* ACPI disable */
156 pci_write_config_byte(dev, 0x77, 0x40); /* Modem disable */
157 pci_write_config_dword(dev, 0x78, 0x20000000); /* Pin select 2 */
158 pci_write_config_byte(dev, 0x7c, 0x00); /* Pin select 3 */
159 pci_write_config_byte(dev, 0x81, 0x00); /* ID read/write control */
160 pci_write_config_byte(dev, 0x90, 0x00); /* PCI PM block control */
161 pci_write_config_word(dev, 0xa4, 0x0000); /* PMSCR */
162
163#ifdef CONFIG_BLK_DEV_FD
164 ali_m1535plus_fdc_init(1);
165#endif
166
167 ali_m1535plus_keyboard_init(1);
168 ali_m1535plus_hotkey_init(1);
169}
170
171static inline void ali_config_writeb(u8 reg, u8 val, int devfn)
172{
173 u32 data;
174 int shift;
175
176 writel((1 << 16) | (devfn << 8) | (reg & 0xfc) | 1UL, PCI_CONFIG_ADDR);
177 data = readl(PCI_CONFIG_DATA);
178
179 shift = (reg & 3) << 3;
180 data &= ~(0xff << shift);
181 data |= (((u32)val) << shift);
182
183 writel(data, PCI_CONFIG_DATA);
184}
185
186static inline u8 ali_config_readb(u8 reg, int devfn)
187{
188 u32 data;
189
190 writel((1 << 16) | (devfn << 8) | (reg & 0xfc) | 1UL, PCI_CONFIG_ADDR);
191 data = readl(PCI_CONFIG_DATA);
192
193 return (u8)(data >> ((reg & 3) << 3));
194}
195
196static inline u16 ali_config_readw(u8 reg, int devfn)
197{
198 u32 data;
199
200 writel((1 << 16) | (devfn << 8) | (reg & 0xfc) | 1UL, PCI_CONFIG_ADDR);
201 data = readl(PCI_CONFIG_DATA);
202
203 return (u16)(data >> ((reg & 2) << 3));
204}
205
206int vr4133_rockhopper = 0;
207void __init ali_m5229_preinit(void)
208{
209 if (ali_config_readw(PCI_VENDOR_ID, 16) == PCI_VENDOR_ID_AL &&
210 ali_config_readw(PCI_DEVICE_ID, 16) == PCI_DEVICE_ID_AL_M1533) {
211 printk(KERN_INFO "Found an NEC Rockhopper \n");
212 vr4133_rockhopper = 1;
213 /*
214 * Enable ALi M5229 IDE Controller (both channels)
215 * IDSEL: A27
216 */
217 ali_config_writeb(0x58, 0x4c, 16);
218 }
219}
220
221void __init ali_m5229_init(struct pci_dev *dev)
222{
223 /*
224 * Enable Primary/Secondary Channel Cable Detect 40-Pin
225 */
226 pci_write_config_word(dev, 0x4a, 0xc023);
227
228 /*
229 * Set only the 3rd byteis for the master IDE's cycle and
230 * enable Internal IDE Function
231 */
232 pci_write_config_byte(dev, 0x50, 0x23); /* Class code attr register */
233
234 pci_write_config_byte(dev, 0x09, 0xff); /* Set native mode & stuff */
235 pci_write_config_byte(dev, 0x52, 0x00); /* use timing registers */
236 pci_write_config_byte(dev, 0x58, 0x02); /* Primary addr setup timing */
237 pci_write_config_byte(dev, 0x59, 0x22); /* Primary cmd block timing */
238 pci_write_config_byte(dev, 0x5a, 0x22); /* Pr drv 0 R/W timing */
239 pci_write_config_byte(dev, 0x5b, 0x22); /* Pr drv 1 R/W timing */
240 pci_write_config_byte(dev, 0x5c, 0x02); /* Sec addr setup timing */
241 pci_write_config_byte(dev, 0x5d, 0x22); /* Sec cmd block timing */
242 pci_write_config_byte(dev, 0x5e, 0x22); /* Sec drv 0 R/W timing */
243 pci_write_config_byte(dev, 0x5f, 0x22); /* Sec drv 1 R/W timing */
244 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
245 pci_write_config_word(dev, PCI_COMMAND,
246 PCI_COMMAND_PARITY | PCI_COMMAND_MASTER |
247 PCI_COMMAND_IO);
248}
249
diff --git a/arch/mips/vr41xx/nec-cmbvr4133/setup.c b/arch/mips/vr41xx/nec-cmbvr4133/setup.c
deleted file mode 100644
index 7723d2011b0..00000000000
--- a/arch/mips/vr41xx/nec-cmbvr4133/setup.c
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * arch/mips/vr41xx/nec-cmbvr4133/setup.c
3 *
4 * Setup for the NEC CMB-VR4133.
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Alex Sapkov <asapkov@ru.mvista.com>
8 *
9 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
13 *
14 * Support for CMBVR4133 board in 2.6
15 * Author: Manish Lachwani (mlachwani@mvista.com)
16 */
17#include <linux/init.h>
18#include <linux/ide.h>
19#include <linux/ioport.h>
20
21#include <asm/reboot.h>
22#include <asm/time.h>
23#include <asm/vr41xx/cmbvr4133.h>
24#include <asm/bootinfo.h>
25
26#ifdef CONFIG_MTD
27#include <linux/mtd/physmap.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/mtd.h>
30#include <linux/mtd/map.h>
31
32static struct mtd_partition cmbvr4133_mtd_parts[] = {
33 {
34 .name = "User FS",
35 .size = 0x1be0000,
36 .offset = 0,
37 .mask_flags = 0,
38 },
39 {
40 .name = "PMON",
41 .size = 0x140000,
42 .offset = MTDPART_OFS_APPEND,
43 .mask_flags = MTD_WRITEABLE, /* force read-only */
44 },
45 {
46 .name = "User FS2",
47 .size = MTDPART_SIZ_FULL,
48 .offset = MTDPART_OFS_APPEND,
49 .mask_flags = 0,
50 }
51};
52
53#define number_partitions ARRAY_SIZE(cmbvr4133_mtd_parts)
54#endif
55
56extern void i8259_init(void);
57
58static void __init nec_cmbvr4133_setup(void)
59{
60#ifdef CONFIG_ROCKHOPPER
61 extern void disable_pcnet(void);
62
63 disable_pcnet();
64#endif
65 set_io_port_base(KSEG1ADDR(0x16000000));
66
67#ifdef CONFIG_PCI
68#ifdef CONFIG_ROCKHOPPER
69 ali_m5229_preinit();
70#endif
71#endif
72
73#ifdef CONFIG_ROCKHOPPER
74 rockhopper_init_irq();
75#endif
76
77#ifdef CONFIG_MTD
78 /* we use generic physmap mapping driver and we use partitions */
79 physmap_configure(0x1C000000, 0x02000000, 4, NULL);
80 physmap_set_partitions(cmbvr4133_mtd_parts, number_partitions);
81#endif
82
83 /* 128 MB memory support */
84 add_memory_region(0, 0x08000000, BOOT_MEM_RAM);
85
86#ifdef CONFIG_ROCKHOPPER
87 i8259_init();
88#endif
89}
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index bc7a19da624..a7d4fd353c2 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -199,6 +199,7 @@ endchoice
199 199
200config SMP 200config SMP
201 bool "Symmetric multi-processing support" 201 bool "Symmetric multi-processing support"
202 select USE_GENERIC_SMP_HELPERS
202 ---help--- 203 ---help---
203 This enables support for systems with more than one CPU. If you have 204 This enables support for systems with more than one CPU. If you have
204 a system with only one CPU, like most personal computers, say N. If 205 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
index e10d25d2d9c..5259d8c2067 100644
--- a/arch/parisc/kernel/cache.c
+++ b/arch/parisc/kernel/cache.c
@@ -51,12 +51,12 @@ static struct pdc_btlb_info btlb_info __read_mostly;
51void 51void
52flush_data_cache(void) 52flush_data_cache(void)
53{ 53{
54 on_each_cpu(flush_data_cache_local, NULL, 1, 1); 54 on_each_cpu(flush_data_cache_local, NULL, 1);
55} 55}
56void 56void
57flush_instruction_cache(void) 57flush_instruction_cache(void)
58{ 58{
59 on_each_cpu(flush_instruction_cache_local, NULL, 1, 1); 59 on_each_cpu(flush_instruction_cache_local, NULL, 1);
60} 60}
61#endif 61#endif
62 62
@@ -515,7 +515,7 @@ static void cacheflush_h_tmp_function(void *dummy)
515 515
516void flush_cache_all(void) 516void flush_cache_all(void)
517{ 517{
518 on_each_cpu(cacheflush_h_tmp_function, NULL, 1, 1); 518 on_each_cpu(cacheflush_h_tmp_function, NULL, 1);
519} 519}
520 520
521void flush_cache_mm(struct mm_struct *mm) 521void flush_cache_mm(struct mm_struct *mm)
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 85fc7754ec2..d47f3975c9c 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -84,19 +84,11 @@ EXPORT_SYMBOL(cpu_possible_map);
84 84
85DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED; 85DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED;
86 86
87struct smp_call_struct {
88 void (*func) (void *info);
89 void *info;
90 long wait;
91 atomic_t unstarted_count;
92 atomic_t unfinished_count;
93};
94static volatile struct smp_call_struct *smp_call_function_data;
95
96enum ipi_message_type { 87enum ipi_message_type {
97 IPI_NOP=0, 88 IPI_NOP=0,
98 IPI_RESCHEDULE=1, 89 IPI_RESCHEDULE=1,
99 IPI_CALL_FUNC, 90 IPI_CALL_FUNC,
91 IPI_CALL_FUNC_SINGLE,
100 IPI_CPU_START, 92 IPI_CPU_START,
101 IPI_CPU_STOP, 93 IPI_CPU_STOP,
102 IPI_CPU_TEST 94 IPI_CPU_TEST
@@ -187,33 +179,12 @@ ipi_interrupt(int irq, void *dev_id)
187 179
188 case IPI_CALL_FUNC: 180 case IPI_CALL_FUNC:
189 smp_debug(100, KERN_DEBUG "CPU%d IPI_CALL_FUNC\n", this_cpu); 181 smp_debug(100, KERN_DEBUG "CPU%d IPI_CALL_FUNC\n", this_cpu);
190 { 182 generic_smp_call_function_interrupt();
191 volatile struct smp_call_struct *data; 183 break;
192 void (*func)(void *info); 184
193 void *info; 185 case IPI_CALL_FUNC_SINGLE:
194 int wait; 186 smp_debug(100, KERN_DEBUG "CPU%d IPI_CALL_FUNC_SINGLE\n", this_cpu);
195 187 generic_smp_call_function_single_interrupt();
196 data = smp_call_function_data;
197 func = data->func;
198 info = data->info;
199 wait = data->wait;
200
201 mb();
202 atomic_dec ((atomic_t *)&data->unstarted_count);
203
204 /* At this point, *data can't
205 * be relied upon.
206 */
207
208 (*func)(info);
209
210 /* Notify the sending CPU that the
211 * task is done.
212 */
213 mb();
214 if (wait)
215 atomic_dec ((atomic_t *)&data->unfinished_count);
216 }
217 break; 188 break;
218 189
219 case IPI_CPU_START: 190 case IPI_CPU_START:
@@ -256,6 +227,14 @@ ipi_send(int cpu, enum ipi_message_type op)
256 spin_unlock_irqrestore(lock, flags); 227 spin_unlock_irqrestore(lock, flags);
257} 228}
258 229
230static void
231send_IPI_mask(cpumask_t mask, enum ipi_message_type op)
232{
233 int cpu;
234
235 for_each_cpu_mask(cpu, mask)
236 ipi_send(cpu, op);
237}
259 238
260static inline void 239static inline void
261send_IPI_single(int dest_cpu, enum ipi_message_type op) 240send_IPI_single(int dest_cpu, enum ipi_message_type op)
@@ -295,86 +274,15 @@ smp_send_all_nop(void)
295 send_IPI_allbutself(IPI_NOP); 274 send_IPI_allbutself(IPI_NOP);
296} 275}
297 276
298 277void arch_send_call_function_ipi(cpumask_t mask)
299/**
300 * Run a function on all other CPUs.
301 * <func> The function to run. This must be fast and non-blocking.
302 * <info> An arbitrary pointer to pass to the function.
303 * <retry> If true, keep retrying until ready.
304 * <wait> If true, wait until function has completed on other CPUs.
305 * [RETURNS] 0 on success, else a negative status code.
306 *
307 * Does not return until remote CPUs are nearly ready to execute <func>
308 * or have executed.
309 */
310
311int
312smp_call_function (void (*func) (void *info), void *info, int retry, int wait)
313{ 278{
314 struct smp_call_struct data; 279 send_IPI_mask(mask, IPI_CALL_FUNC);
315 unsigned long timeout;
316 static DEFINE_SPINLOCK(lock);
317 int retries = 0;
318
319 if (num_online_cpus() < 2)
320 return 0;
321
322 /* Can deadlock when called with interrupts disabled */
323 WARN_ON(irqs_disabled());
324
325 /* can also deadlock if IPIs are disabled */
326 WARN_ON((get_eiem() & (1UL<<(CPU_IRQ_MAX - IPI_IRQ))) == 0);
327
328
329 data.func = func;
330 data.info = info;
331 data.wait = wait;
332 atomic_set(&data.unstarted_count, num_online_cpus() - 1);
333 atomic_set(&data.unfinished_count, num_online_cpus() - 1);
334
335 if (retry) {
336 spin_lock (&lock);
337 while (smp_call_function_data != 0)
338 barrier();
339 }
340 else {
341 spin_lock (&lock);
342 if (smp_call_function_data) {
343 spin_unlock (&lock);
344 return -EBUSY;
345 }
346 }
347
348 smp_call_function_data = &data;
349 spin_unlock (&lock);
350
351 /* Send a message to all other CPUs and wait for them to respond */
352 send_IPI_allbutself(IPI_CALL_FUNC);
353
354 retry:
355 /* Wait for response */
356 timeout = jiffies + HZ;
357 while ( (atomic_read (&data.unstarted_count) > 0) &&
358 time_before (jiffies, timeout) )
359 barrier ();
360
361 if (atomic_read (&data.unstarted_count) > 0) {
362 printk(KERN_CRIT "SMP CALL FUNCTION TIMED OUT! (cpu=%d), try %d\n",
363 smp_processor_id(), ++retries);
364 goto retry;
365 }
366 /* We either got one or timed out. Release the lock */
367
368 mb();
369 smp_call_function_data = NULL;
370
371 while (wait && atomic_read (&data.unfinished_count) > 0)
372 barrier ();
373
374 return 0;
375} 280}
376 281
377EXPORT_SYMBOL(smp_call_function); 282void arch_send_call_function_single_ipi(int cpu)
283{
284 send_IPI_single(cpu, IPI_CALL_FUNC_SINGLE);
285}
378 286
379/* 287/*
380 * Flush all other CPU's tlb and then mine. Do this with on_each_cpu() 288 * Flush all other CPU's tlb and then mine. Do this with on_each_cpu()
@@ -384,7 +292,7 @@ EXPORT_SYMBOL(smp_call_function);
384void 292void
385smp_flush_tlb_all(void) 293smp_flush_tlb_all(void)
386{ 294{
387 on_each_cpu(flush_tlb_all_local, NULL, 1, 1); 295 on_each_cpu(flush_tlb_all_local, NULL, 1);
388} 296}
389 297
390/* 298/*
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index ce0da689a89..b4d6c8777ed 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -1053,7 +1053,7 @@ void flush_tlb_all(void)
1053 do_recycle++; 1053 do_recycle++;
1054 } 1054 }
1055 spin_unlock(&sid_lock); 1055 spin_unlock(&sid_lock);
1056 on_each_cpu(flush_tlb_all_local, NULL, 1, 1); 1056 on_each_cpu(flush_tlb_all_local, NULL, 1);
1057 if (do_recycle) { 1057 if (do_recycle) {
1058 spin_lock(&sid_lock); 1058 spin_lock(&sid_lock);
1059 recycle_sids(recycle_ndirty,recycle_dirty_array); 1059 recycle_sids(recycle_ndirty,recycle_dirty_array);
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a5e9912e2d3..20eacf2a842 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -111,6 +111,7 @@ config PPC
111 select HAVE_KPROBES 111 select HAVE_KPROBES
112 select HAVE_KRETPROBES 112 select HAVE_KRETPROBES
113 select HAVE_LMB 113 select HAVE_LMB
114 select USE_GENERIC_SMP_HELPERS if SMP
114 select HAVE_OPROFILE 115 select HAVE_OPROFILE
115 116
116config EARLY_PRINTK 117config EARLY_PRINTK
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 704375bda73..b732b5f8e35 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -172,7 +172,7 @@ static void kexec_prepare_cpus(void)
172{ 172{
173 int my_cpu, i, notified=-1; 173 int my_cpu, i, notified=-1;
174 174
175 smp_call_function(kexec_smp_down, NULL, 0, /* wait */0); 175 smp_call_function(kexec_smp_down, NULL, /* wait */0);
176 my_cpu = get_cpu(); 176 my_cpu = get_cpu();
177 177
178 /* check the others cpus are now down (via paca hw cpu id == -1) */ 178 /* check the others cpus are now down (via paca hw cpu id == -1) */
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 34843c31841..647f3e8677d 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -747,7 +747,7 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
747 /* Call function on all CPUs. One of us will make the 747 /* Call function on all CPUs. One of us will make the
748 * rtas call 748 * rtas call
749 */ 749 */
750 if (on_each_cpu(rtas_percpu_suspend_me, &data, 1, 0)) 750 if (on_each_cpu(rtas_percpu_suspend_me, &data, 0))
751 data.error = -EINVAL; 751 data.error = -EINVAL;
752 752
753 wait_for_completion(&done); 753 wait_for_completion(&done);
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 1457aa0a08f..5191b46a611 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -72,12 +72,8 @@ struct smp_ops_t *smp_ops;
72 72
73static volatile unsigned int cpu_callin_map[NR_CPUS]; 73static volatile unsigned int cpu_callin_map[NR_CPUS];
74 74
75void smp_call_function_interrupt(void);
76
77int smt_enabled_at_boot = 1; 75int smt_enabled_at_boot = 1;
78 76
79static int ipi_fail_ok;
80
81static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL; 77static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL;
82 78
83#ifdef CONFIG_PPC64 79#ifdef CONFIG_PPC64
@@ -99,12 +95,15 @@ void smp_message_recv(int msg)
99{ 95{
100 switch(msg) { 96 switch(msg) {
101 case PPC_MSG_CALL_FUNCTION: 97 case PPC_MSG_CALL_FUNCTION:
102 smp_call_function_interrupt(); 98 generic_smp_call_function_interrupt();
103 break; 99 break;
104 case PPC_MSG_RESCHEDULE: 100 case PPC_MSG_RESCHEDULE:
105 /* XXX Do we have to do this? */ 101 /* XXX Do we have to do this? */
106 set_need_resched(); 102 set_need_resched();
107 break; 103 break;
104 case PPC_MSG_CALL_FUNC_SINGLE:
105 generic_smp_call_function_single_interrupt();
106 break;
108 case PPC_MSG_DEBUGGER_BREAK: 107 case PPC_MSG_DEBUGGER_BREAK:
109 if (crash_ipi_function_ptr) { 108 if (crash_ipi_function_ptr) {
110 crash_ipi_function_ptr(get_irq_regs()); 109 crash_ipi_function_ptr(get_irq_regs());
@@ -128,6 +127,19 @@ void smp_send_reschedule(int cpu)
128 smp_ops->message_pass(cpu, PPC_MSG_RESCHEDULE); 127 smp_ops->message_pass(cpu, PPC_MSG_RESCHEDULE);
129} 128}
130 129
130void arch_send_call_function_single_ipi(int cpu)
131{
132 smp_ops->message_pass(cpu, PPC_MSG_CALL_FUNC_SINGLE);
133}
134
135void arch_send_call_function_ipi(cpumask_t mask)
136{
137 unsigned int cpu;
138
139 for_each_cpu_mask(cpu, mask)
140 smp_ops->message_pass(cpu, PPC_MSG_CALL_FUNCTION);
141}
142
131#ifdef CONFIG_DEBUGGER 143#ifdef CONFIG_DEBUGGER
132void smp_send_debugger_break(int cpu) 144void smp_send_debugger_break(int cpu)
133{ 145{
@@ -154,215 +166,9 @@ static void stop_this_cpu(void *dummy)
154 ; 166 ;
155} 167}
156 168
157/*
158 * Structure and data for smp_call_function(). This is designed to minimise
159 * static memory requirements. It also looks cleaner.
160 * Stolen from the i386 version.
161 */
162static __cacheline_aligned_in_smp DEFINE_SPINLOCK(call_lock);
163
164static struct call_data_struct {
165 void (*func) (void *info);
166 void *info;
167 atomic_t started;
168 atomic_t finished;
169 int wait;
170} *call_data;
171
172/* delay of at least 8 seconds */
173#define SMP_CALL_TIMEOUT 8
174
175/*
176 * These functions send a 'generic call function' IPI to other online
177 * CPUS in the system.
178 *
179 * [SUMMARY] Run a function on other CPUs.
180 * <func> The function to run. This must be fast and non-blocking.
181 * <info> An arbitrary pointer to pass to the function.
182 * <nonatomic> currently unused.
183 * <wait> If true, wait (atomically) until function has completed on other CPUs.
184 * [RETURNS] 0 on success, else a negative status code. Does not return until
185 * remote CPUs are nearly ready to execute <<func>> or are or have executed.
186 * <map> is a cpu map of the cpus to send IPI to.
187 *
188 * You must not call this function with disabled interrupts or from a
189 * hardware interrupt handler or from a bottom half handler.
190 */
191static int __smp_call_function_map(void (*func) (void *info), void *info,
192 int nonatomic, int wait, cpumask_t map)
193{
194 struct call_data_struct data;
195 int ret = -1, num_cpus;
196 int cpu;
197 u64 timeout;
198
199 if (unlikely(smp_ops == NULL))
200 return ret;
201
202 data.func = func;
203 data.info = info;
204 atomic_set(&data.started, 0);
205 data.wait = wait;
206 if (wait)
207 atomic_set(&data.finished, 0);
208
209 /* remove 'self' from the map */
210 if (cpu_isset(smp_processor_id(), map))
211 cpu_clear(smp_processor_id(), map);
212
213 /* sanity check the map, remove any non-online processors. */
214 cpus_and(map, map, cpu_online_map);
215
216 num_cpus = cpus_weight(map);
217 if (!num_cpus)
218 goto done;
219
220 call_data = &data;
221 smp_wmb();
222 /* Send a message to all CPUs in the map */
223 for_each_cpu_mask(cpu, map)
224 smp_ops->message_pass(cpu, PPC_MSG_CALL_FUNCTION);
225
226 timeout = get_tb() + (u64) SMP_CALL_TIMEOUT * tb_ticks_per_sec;
227
228 /* Wait for indication that they have received the message */
229 while (atomic_read(&data.started) != num_cpus) {
230 HMT_low();
231 if (get_tb() >= timeout) {
232 printk("smp_call_function on cpu %d: other cpus not "
233 "responding (%d)\n", smp_processor_id(),
234 atomic_read(&data.started));
235 if (!ipi_fail_ok)
236 debugger(NULL);
237 goto out;
238 }
239 }
240
241 /* optionally wait for the CPUs to complete */
242 if (wait) {
243 while (atomic_read(&data.finished) != num_cpus) {
244 HMT_low();
245 if (get_tb() >= timeout) {
246 printk("smp_call_function on cpu %d: other "
247 "cpus not finishing (%d/%d)\n",
248 smp_processor_id(),
249 atomic_read(&data.finished),
250 atomic_read(&data.started));
251 debugger(NULL);
252 goto out;
253 }
254 }
255 }
256
257 done:
258 ret = 0;
259
260 out:
261 call_data = NULL;
262 HMT_medium();
263 return ret;
264}
265
266static int __smp_call_function(void (*func)(void *info), void *info,
267 int nonatomic, int wait)
268{
269 int ret;
270 spin_lock(&call_lock);
271 ret =__smp_call_function_map(func, info, nonatomic, wait,
272 cpu_online_map);
273 spin_unlock(&call_lock);
274 return ret;
275}
276
277int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
278 int wait)
279{
280 /* Can deadlock when called with interrupts disabled */
281 WARN_ON(irqs_disabled());
282
283 return __smp_call_function(func, info, nonatomic, wait);
284}
285EXPORT_SYMBOL(smp_call_function);
286
287int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
288 int nonatomic, int wait)
289{
290 cpumask_t map = CPU_MASK_NONE;
291 int ret = 0;
292
293 /* Can deadlock when called with interrupts disabled */
294 WARN_ON(irqs_disabled());
295
296 if (!cpu_online(cpu))
297 return -EINVAL;
298
299 cpu_set(cpu, map);
300 if (cpu != get_cpu()) {
301 spin_lock(&call_lock);
302 ret = __smp_call_function_map(func, info, nonatomic, wait, map);
303 spin_unlock(&call_lock);
304 } else {
305 local_irq_disable();
306 func(info);
307 local_irq_enable();
308 }
309 put_cpu();
310 return ret;
311}
312EXPORT_SYMBOL(smp_call_function_single);
313
314void smp_send_stop(void) 169void smp_send_stop(void)
315{ 170{
316 int nolock; 171 smp_call_function(stop_this_cpu, NULL, 0);
317
318 /* It's OK to fail sending the IPI, since the alternative is to
319 * be stuck forever waiting on the other CPU to take the interrupt.
320 *
321 * It's better to at least continue and go through reboot, since this
322 * function is usually called at panic or reboot time in the first
323 * place.
324 */
325 ipi_fail_ok = 1;
326
327 /* Don't deadlock in case we got called through panic */
328 nolock = !spin_trylock(&call_lock);
329 __smp_call_function_map(stop_this_cpu, NULL, 1, 0, cpu_online_map);
330 if (!nolock)
331 spin_unlock(&call_lock);
332}
333
334void smp_call_function_interrupt(void)
335{
336 void (*func) (void *info);
337 void *info;
338 int wait;
339
340 /* call_data will be NULL if the sender timed out while
341 * waiting on us to receive the call.
342 */
343 if (!call_data)
344 return;
345
346 func = call_data->func;
347 info = call_data->info;
348 wait = call_data->wait;
349
350 if (!wait)
351 smp_mb__before_atomic_inc();
352
353 /*
354 * Notify initiating CPU that I've grabbed the data and am
355 * about to execute the function
356 */
357 atomic_inc(&call_data->started);
358 /*
359 * At this point the info structure may be out of scope unless wait==1
360 */
361 (*func)(info);
362 if (wait) {
363 smp_mb__before_atomic_inc();
364 atomic_inc(&call_data->finished);
365 }
366} 172}
367 173
368extern struct gettimeofday_struct do_gtod; 174extern struct gettimeofday_struct do_gtod;
@@ -596,9 +402,9 @@ int __devinit start_secondary(void *unused)
596 402
597 secondary_cpu_time_init(); 403 secondary_cpu_time_init();
598 404
599 spin_lock(&call_lock); 405 ipi_call_lock();
600 cpu_set(cpu, cpu_online_map); 406 cpu_set(cpu, cpu_online_map);
601 spin_unlock(&call_lock); 407 ipi_call_unlock();
602 408
603 local_irq_enable(); 409 local_irq_enable();
604 410
diff --git a/arch/powerpc/kernel/stacktrace.c b/arch/powerpc/kernel/stacktrace.c
index 96294403843..3cf0d94ba34 100644
--- a/arch/powerpc/kernel/stacktrace.c
+++ b/arch/powerpc/kernel/stacktrace.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/stacktrace.h> 14#include <linux/stacktrace.h>
15#include <linux/module.h>
15#include <asm/ptrace.h> 16#include <asm/ptrace.h>
16 17
17/* 18/*
@@ -44,3 +45,4 @@ void save_stack_trace(struct stack_trace *trace)
44 sp = newsp; 45 sp = newsp;
45 } 46 }
46} 47}
48EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/powerpc/kernel/tau_6xx.c b/arch/powerpc/kernel/tau_6xx.c
index 368a4934f7e..c3a56d65c5a 100644
--- a/arch/powerpc/kernel/tau_6xx.c
+++ b/arch/powerpc/kernel/tau_6xx.c
@@ -192,7 +192,7 @@ static void tau_timeout_smp(unsigned long unused)
192 192
193 /* schedule ourselves to be run again */ 193 /* schedule ourselves to be run again */
194 mod_timer(&tau_timer, jiffies + shrink_timer) ; 194 mod_timer(&tau_timer, jiffies + shrink_timer) ;
195 on_each_cpu(tau_timeout, NULL, 1, 0); 195 on_each_cpu(tau_timeout, NULL, 0);
196} 196}
197 197
198/* 198/*
@@ -234,7 +234,7 @@ int __init TAU_init(void)
234 tau_timer.expires = jiffies + shrink_timer; 234 tau_timer.expires = jiffies + shrink_timer;
235 add_timer(&tau_timer); 235 add_timer(&tau_timer);
236 236
237 on_each_cpu(TAU_init_smp, NULL, 1, 0); 237 on_each_cpu(TAU_init_smp, NULL, 0);
238 238
239 printk("Thermal assist unit "); 239 printk("Thermal assist unit ");
240#ifdef CONFIG_TAU_INT 240#ifdef CONFIG_TAU_INT
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 73401e83739..f1a38a6c1e2 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -322,7 +322,7 @@ void snapshot_timebases(void)
322{ 322{
323 if (!cpu_has_feature(CPU_FTR_PURR)) 323 if (!cpu_has_feature(CPU_FTR_PURR))
324 return; 324 return;
325 on_each_cpu(snapshot_tb_and_purr, NULL, 0, 1); 325 on_each_cpu(snapshot_tb_and_purr, NULL, 1);
326} 326}
327 327
328/* 328/*
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index ad928edafb0..2bd12d965db 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -218,7 +218,7 @@ static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psiz
218 mb(); 218 mb();
219 219
220 /* XXX this is sub-optimal but will do for now */ 220 /* XXX this is sub-optimal but will do for now */
221 on_each_cpu(slice_flush_segments, mm, 0, 1); 221 on_each_cpu(slice_flush_segments, mm, 1);
222#ifdef CONFIG_SPU_BASE 222#ifdef CONFIG_SPU_BASE
223 spu_flush_all_slbs(mm); 223 spu_flush_all_slbs(mm);
224#endif 224#endif
diff --git a/arch/powerpc/mm/tlb_64.c b/arch/powerpc/mm/tlb_64.c
index e2d867ce1c7..69ad829a7fa 100644
--- a/arch/powerpc/mm/tlb_64.c
+++ b/arch/powerpc/mm/tlb_64.c
@@ -66,7 +66,7 @@ static void pgtable_free_now(pgtable_free_t pgf)
66{ 66{
67 pte_freelist_forced_free++; 67 pte_freelist_forced_free++;
68 68
69 smp_call_function(pte_free_smp_sync, NULL, 0, 1); 69 smp_call_function(pte_free_smp_sync, NULL, 1);
70 70
71 pgtable_free(pgf); 71 pgtable_free(pgf);
72} 72}
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index 4908dc98f9c..17807acb05d 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -65,7 +65,7 @@ static int op_powerpc_setup(void)
65 65
66 /* Configure the registers on all cpus. If an error occurs on one 66 /* Configure the registers on all cpus. If an error occurs on one
67 * of the cpus, op_per_cpu_rc will be set to the error */ 67 * of the cpus, op_per_cpu_rc will be set to the error */
68 on_each_cpu(op_powerpc_cpu_setup, NULL, 0, 1); 68 on_each_cpu(op_powerpc_cpu_setup, NULL, 1);
69 69
70out: if (op_per_cpu_rc) { 70out: if (op_per_cpu_rc) {
71 /* error on setup release the performance counter hardware */ 71 /* error on setup release the performance counter hardware */
@@ -100,7 +100,7 @@ static int op_powerpc_start(void)
100 if (model->global_start) 100 if (model->global_start)
101 return model->global_start(ctr); 101 return model->global_start(ctr);
102 if (model->start) { 102 if (model->start) {
103 on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1); 103 on_each_cpu(op_powerpc_cpu_start, NULL, 1);
104 return op_per_cpu_rc; 104 return op_per_cpu_rc;
105 } 105 }
106 return -EIO; /* No start function is defined for this 106 return -EIO; /* No start function is defined for this
@@ -115,7 +115,7 @@ static inline void op_powerpc_cpu_stop(void *dummy)
115static void op_powerpc_stop(void) 115static void op_powerpc_stop(void)
116{ 116{
117 if (model->stop) 117 if (model->stop)
118 on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1); 118 on_each_cpu(op_powerpc_cpu_stop, NULL, 1);
119 if (model->global_stop) 119 if (model->global_stop)
120 model->global_stop(); 120 model->global_stop();
121} 121}
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index 5bf7df14602..2d5bb22d6c0 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -218,6 +218,7 @@ void iic_request_IPIs(void)
218{ 218{
219 iic_request_ipi(PPC_MSG_CALL_FUNCTION, "IPI-call"); 219 iic_request_ipi(PPC_MSG_CALL_FUNCTION, "IPI-call");
220 iic_request_ipi(PPC_MSG_RESCHEDULE, "IPI-resched"); 220 iic_request_ipi(PPC_MSG_RESCHEDULE, "IPI-resched");
221 iic_request_ipi(PPC_MSG_CALL_FUNC_SINGLE, "IPI-call-single");
221#ifdef CONFIG_DEBUGGER 222#ifdef CONFIG_DEBUGGER
222 iic_request_ipi(PPC_MSG_DEBUGGER_BREAK, "IPI-debug"); 223 iic_request_ipi(PPC_MSG_DEBUGGER_BREAK, "IPI-debug");
223#endif /* CONFIG_DEBUGGER */ 224#endif /* CONFIG_DEBUGGER */
diff --git a/arch/powerpc/platforms/ps3/smp.c b/arch/powerpc/platforms/ps3/smp.c
index f0b12f21236..a0927a3bacb 100644
--- a/arch/powerpc/platforms/ps3/smp.c
+++ b/arch/powerpc/platforms/ps3/smp.c
@@ -105,9 +105,10 @@ static void __init ps3_smp_setup_cpu(int cpu)
105 * to index needs to be setup. 105 * to index needs to be setup.
106 */ 106 */
107 107
108 BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0); 108 BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0);
109 BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1); 109 BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1);
110 BUILD_BUG_ON(PPC_MSG_DEBUGGER_BREAK != 3); 110 BUILD_BUG_ON(PPC_MSG_CALL_FUNC_SINGLE != 2);
111 BUILD_BUG_ON(PPC_MSG_DEBUGGER_BREAK != 3);
111 112
112 for (i = 0; i < MSG_COUNT; i++) { 113 for (i = 0; i < MSG_COUNT; i++) {
113 result = ps3_event_receive_port_setup(cpu, &virqs[i]); 114 result = ps3_event_receive_port_setup(cpu, &virqs[i]);
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index ebebc28fe89..0fc830f576f 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -383,13 +383,11 @@ static irqreturn_t xics_ipi_dispatch(int cpu)
383 mb(); 383 mb();
384 smp_message_recv(PPC_MSG_RESCHEDULE); 384 smp_message_recv(PPC_MSG_RESCHEDULE);
385 } 385 }
386#if 0 386 if (test_and_clear_bit(PPC_MSG_CALL_FUNC_SINGLE,
387 if (test_and_clear_bit(PPC_MSG_MIGRATE_TASK,
388 &xics_ipi_message[cpu].value)) { 387 &xics_ipi_message[cpu].value)) {
389 mb(); 388 mb();
390 smp_message_recv(PPC_MSG_MIGRATE_TASK); 389 smp_message_recv(PPC_MSG_CALL_FUNC_SINGLE);
391 } 390 }
392#endif
393#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC) 391#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
394 if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK, 392 if (test_and_clear_bit(PPC_MSG_DEBUGGER_BREAK,
395 &xics_ipi_message[cpu].value)) { 393 &xics_ipi_message[cpu].value)) {
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 7680001676a..6c90c95b454 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1494,7 +1494,7 @@ void mpic_request_ipis(void)
1494 static char *ipi_names[] = { 1494 static char *ipi_names[] = {
1495 "IPI0 (call function)", 1495 "IPI0 (call function)",
1496 "IPI1 (reschedule)", 1496 "IPI1 (reschedule)",
1497 "IPI2 (unused)", 1497 "IPI2 (call function single)",
1498 "IPI3 (debugger break)", 1498 "IPI3 (debugger break)",
1499 }; 1499 };
1500 BUG_ON(mpic == NULL); 1500 BUG_ON(mpic == NULL);
diff --git a/arch/ppc/kernel/smp.c b/arch/ppc/kernel/smp.c
index 055998575cb..bcab0d210e3 100644
--- a/arch/ppc/kernel/smp.c
+++ b/arch/ppc/kernel/smp.c
@@ -152,7 +152,7 @@ static void stop_this_cpu(void *dummy)
152 152
153void smp_send_stop(void) 153void smp_send_stop(void)
154{ 154{
155 smp_call_function(stop_this_cpu, NULL, 1, 0); 155 smp_call_function(stop_this_cpu, NULL, 0);
156} 156}
157 157
158/* 158/*
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 9cb3d92447a..a7f8979fb92 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -203,7 +203,7 @@ __appldata_vtimer_setup(int cmd)
203 per_cpu(appldata_timer, i).expires = per_cpu_interval; 203 per_cpu(appldata_timer, i).expires = per_cpu_interval;
204 smp_call_function_single(i, add_virt_timer_periodic, 204 smp_call_function_single(i, add_virt_timer_periodic,
205 &per_cpu(appldata_timer, i), 205 &per_cpu(appldata_timer, i),
206 0, 1); 206 1);
207 } 207 }
208 appldata_timer_active = 1; 208 appldata_timer_active = 1;
209 break; 209 break;
@@ -228,7 +228,7 @@ __appldata_vtimer_setup(int cmd)
228 args.timer = &per_cpu(appldata_timer, i); 228 args.timer = &per_cpu(appldata_timer, i);
229 args.expires = per_cpu_interval; 229 args.expires = per_cpu_interval;
230 smp_call_function_single(i, __appldata_mod_vtimer_wrap, 230 smp_call_function_single(i, __appldata_mod_vtimer_wrap,
231 &args, 0, 1); 231 &args, 1);
232 } 232 }
233 } 233 }
234} 234}
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 5d4fa4b1c74..b6781030cfb 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -109,7 +109,7 @@ static void do_call_function(void)
109} 109}
110 110
111static void __smp_call_function_map(void (*func) (void *info), void *info, 111static void __smp_call_function_map(void (*func) (void *info), void *info,
112 int nonatomic, int wait, cpumask_t map) 112 int wait, cpumask_t map)
113{ 113{
114 struct call_data_struct data; 114 struct call_data_struct data;
115 int cpu, local = 0; 115 int cpu, local = 0;
@@ -162,7 +162,6 @@ out:
162 * smp_call_function: 162 * smp_call_function:
163 * @func: the function to run; this must be fast and non-blocking 163 * @func: the function to run; this must be fast and non-blocking
164 * @info: an arbitrary pointer to pass to the function 164 * @info: an arbitrary pointer to pass to the function
165 * @nonatomic: unused
166 * @wait: if true, wait (atomically) until function has completed on other CPUs 165 * @wait: if true, wait (atomically) until function has completed on other CPUs
167 * 166 *
168 * Run a function on all other CPUs. 167 * Run a function on all other CPUs.
@@ -170,15 +169,14 @@ out:
170 * You must not call this function with disabled interrupts, from a 169 * You must not call this function with disabled interrupts, from a
171 * hardware interrupt handler or from a bottom half. 170 * hardware interrupt handler or from a bottom half.
172 */ 171 */
173int smp_call_function(void (*func) (void *info), void *info, int nonatomic, 172int smp_call_function(void (*func) (void *info), void *info, int wait)
174 int wait)
175{ 173{
176 cpumask_t map; 174 cpumask_t map;
177 175
178 spin_lock(&call_lock); 176 spin_lock(&call_lock);
179 map = cpu_online_map; 177 map = cpu_online_map;
180 cpu_clear(smp_processor_id(), map); 178 cpu_clear(smp_processor_id(), map);
181 __smp_call_function_map(func, info, nonatomic, wait, map); 179 __smp_call_function_map(func, info, wait, map);
182 spin_unlock(&call_lock); 180 spin_unlock(&call_lock);
183 return 0; 181 return 0;
184} 182}
@@ -189,7 +187,6 @@ EXPORT_SYMBOL(smp_call_function);
189 * @cpu: the CPU where func should run 187 * @cpu: the CPU where func should run
190 * @func: the function to run; this must be fast and non-blocking 188 * @func: the function to run; this must be fast and non-blocking
191 * @info: an arbitrary pointer to pass to the function 189 * @info: an arbitrary pointer to pass to the function
192 * @nonatomic: unused
193 * @wait: if true, wait (atomically) until function has completed on other CPUs 190 * @wait: if true, wait (atomically) until function has completed on other CPUs
194 * 191 *
195 * Run a function on one processor. 192 * Run a function on one processor.
@@ -198,11 +195,10 @@ EXPORT_SYMBOL(smp_call_function);
198 * hardware interrupt handler or from a bottom half. 195 * hardware interrupt handler or from a bottom half.
199 */ 196 */
200int smp_call_function_single(int cpu, void (*func) (void *info), void *info, 197int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
201 int nonatomic, int wait) 198 int wait)
202{ 199{
203 spin_lock(&call_lock); 200 spin_lock(&call_lock);
204 __smp_call_function_map(func, info, nonatomic, wait, 201 __smp_call_function_map(func, info, wait, cpumask_of_cpu(cpu));
205 cpumask_of_cpu(cpu));
206 spin_unlock(&call_lock); 202 spin_unlock(&call_lock);
207 return 0; 203 return 0;
208} 204}
@@ -228,7 +224,7 @@ int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
228{ 224{
229 spin_lock(&call_lock); 225 spin_lock(&call_lock);
230 cpu_clear(smp_processor_id(), mask); 226 cpu_clear(smp_processor_id(), mask);
231 __smp_call_function_map(func, info, 0, wait, mask); 227 __smp_call_function_map(func, info, wait, mask);
232 spin_unlock(&call_lock); 228 spin_unlock(&call_lock);
233 return 0; 229 return 0;
234} 230}
@@ -303,7 +299,7 @@ static void smp_ptlb_callback(void *info)
303 299
304void smp_ptlb_all(void) 300void smp_ptlb_all(void)
305{ 301{
306 on_each_cpu(smp_ptlb_callback, NULL, 0, 1); 302 on_each_cpu(smp_ptlb_callback, NULL, 1);
307} 303}
308EXPORT_SYMBOL(smp_ptlb_all); 304EXPORT_SYMBOL(smp_ptlb_all);
309#endif /* ! CONFIG_64BIT */ 305#endif /* ! CONFIG_64BIT */
@@ -351,7 +347,7 @@ void smp_ctl_set_bit(int cr, int bit)
351 memset(&parms.orvals, 0, sizeof(parms.orvals)); 347 memset(&parms.orvals, 0, sizeof(parms.orvals));
352 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 348 memset(&parms.andvals, 0xff, sizeof(parms.andvals));
353 parms.orvals[cr] = 1 << bit; 349 parms.orvals[cr] = 1 << bit;
354 on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); 350 on_each_cpu(smp_ctl_bit_callback, &parms, 1);
355} 351}
356EXPORT_SYMBOL(smp_ctl_set_bit); 352EXPORT_SYMBOL(smp_ctl_set_bit);
357 353
@@ -365,7 +361,7 @@ void smp_ctl_clear_bit(int cr, int bit)
365 memset(&parms.orvals, 0, sizeof(parms.orvals)); 361 memset(&parms.orvals, 0, sizeof(parms.orvals));
366 memset(&parms.andvals, 0xff, sizeof(parms.andvals)); 362 memset(&parms.andvals, 0xff, sizeof(parms.andvals));
367 parms.andvals[cr] = ~(1L << bit); 363 parms.andvals[cr] = ~(1L << bit);
368 on_each_cpu(smp_ctl_bit_callback, &parms, 0, 1); 364 on_each_cpu(smp_ctl_bit_callback, &parms, 1);
369} 365}
370EXPORT_SYMBOL(smp_ctl_clear_bit); 366EXPORT_SYMBOL(smp_ctl_clear_bit);
371 367
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index 85e46a5d0e0..57571f10270 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -81,6 +81,7 @@ void save_stack_trace(struct stack_trace *trace)
81 S390_lowcore.thread_info, 81 S390_lowcore.thread_info,
82 S390_lowcore.thread_info + THREAD_SIZE, 1); 82 S390_lowcore.thread_info + THREAD_SIZE, 1);
83} 83}
84EXPORT_SYMBOL_GPL(save_stack_trace);
84 85
85void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 86void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
86{ 87{
@@ -93,3 +94,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
93 if (trace->nr_entries < trace->max_entries) 94 if (trace->nr_entries < trace->max_entries)
94 trace->entries[trace->nr_entries++] = ULONG_MAX; 95 trace->entries[trace->nr_entries++] = ULONG_MAX;
95} 96}
97EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index 7418bebb547..f2cede3947b 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -707,7 +707,7 @@ static int etr_sync_clock(struct etr_aib *aib, int port)
707 */ 707 */
708 memset(&etr_sync, 0, sizeof(etr_sync)); 708 memset(&etr_sync, 0, sizeof(etr_sync));
709 preempt_disable(); 709 preempt_disable();
710 smp_call_function(clock_sync_cpu_start, &etr_sync, 0, 0); 710 smp_call_function(clock_sync_cpu_start, &etr_sync, 0);
711 local_irq_disable(); 711 local_irq_disable();
712 enable_sync_clock(); 712 enable_sync_clock();
713 713
@@ -746,7 +746,7 @@ static int etr_sync_clock(struct etr_aib *aib, int port)
746 rc = -EAGAIN; 746 rc = -EAGAIN;
747 } 747 }
748 local_irq_enable(); 748 local_irq_enable();
749 smp_call_function(clock_sync_cpu_end, NULL, 0, 0); 749 smp_call_function(clock_sync_cpu_end, NULL, 0);
750 preempt_enable(); 750 preempt_enable();
751 return rc; 751 return rc;
752} 752}
@@ -926,7 +926,7 @@ static void etr_work_fn(struct work_struct *work)
926 if (!eacr.ea) { 926 if (!eacr.ea) {
927 /* Both ports offline. Reset everything. */ 927 /* Both ports offline. Reset everything. */
928 eacr.dp = eacr.es = eacr.sl = 0; 928 eacr.dp = eacr.es = eacr.sl = 0;
929 on_each_cpu(disable_sync_clock, NULL, 0, 1); 929 on_each_cpu(disable_sync_clock, NULL, 1);
930 del_timer_sync(&etr_timer); 930 del_timer_sync(&etr_timer);
931 etr_update_eacr(eacr); 931 etr_update_eacr(eacr);
932 clear_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 932 clear_bit(CLOCK_SYNC_ETR, &clock_sync_flags);
@@ -1432,7 +1432,7 @@ static void stp_work_fn(struct work_struct *work)
1432 */ 1432 */
1433 memset(&stp_sync, 0, sizeof(stp_sync)); 1433 memset(&stp_sync, 0, sizeof(stp_sync));
1434 preempt_disable(); 1434 preempt_disable();
1435 smp_call_function(clock_sync_cpu_start, &stp_sync, 0, 0); 1435 smp_call_function(clock_sync_cpu_start, &stp_sync, 0);
1436 local_irq_disable(); 1436 local_irq_disable();
1437 enable_sync_clock(); 1437 enable_sync_clock();
1438 1438
@@ -1465,7 +1465,7 @@ static void stp_work_fn(struct work_struct *work)
1465 stp_sync.in_sync = 1; 1465 stp_sync.in_sync = 1;
1466 1466
1467 local_irq_enable(); 1467 local_irq_enable();
1468 smp_call_function(clock_sync_cpu_end, NULL, 0, 0); 1468 smp_call_function(clock_sync_cpu_end, NULL, 0);
1469 preempt_enable(); 1469 preempt_enable();
1470} 1470}
1471 1471
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 9a854c8e527..3e7384f4619 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -688,6 +688,7 @@ config CRASH_DUMP
688config SMP 688config SMP
689 bool "Symmetric multi-processing support" 689 bool "Symmetric multi-processing support"
690 depends on SYS_SUPPORTS_SMP 690 depends on SYS_SUPPORTS_SMP
691 select USE_GENERIC_SMP_HELPERS
691 ---help--- 692 ---help---
692 This enables support for systems with more than one CPU. If you have 693 This enables support for systems with more than one CPU. If you have
693 a system with only one CPU, like most personal computers, say N. If 694 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 5d039d168f5..60c50841143 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -36,13 +36,6 @@ EXPORT_SYMBOL(cpu_possible_map);
36cpumask_t cpu_online_map; 36cpumask_t cpu_online_map;
37EXPORT_SYMBOL(cpu_online_map); 37EXPORT_SYMBOL(cpu_online_map);
38 38
39static atomic_t cpus_booted = ATOMIC_INIT(0);
40
41/*
42 * Run specified function on a particular processor.
43 */
44void __smp_call_function(unsigned int cpu);
45
46static inline void __init smp_store_cpu_info(unsigned int cpu) 39static inline void __init smp_store_cpu_info(unsigned int cpu)
47{ 40{
48 struct sh_cpuinfo *c = cpu_data + cpu; 41 struct sh_cpuinfo *c = cpu_data + cpu;
@@ -175,45 +168,20 @@ static void stop_this_cpu(void *unused)
175 168
176void smp_send_stop(void) 169void smp_send_stop(void)
177{ 170{
178 smp_call_function(stop_this_cpu, 0, 1, 0); 171 smp_call_function(stop_this_cpu, 0, 0);
179} 172}
180 173
181struct smp_fn_call_struct smp_fn_call = { 174void arch_send_call_function_ipi(cpumask_t mask)
182 .lock = __SPIN_LOCK_UNLOCKED(smp_fn_call.lock),
183 .finished = ATOMIC_INIT(0),
184};
185
186/*
187 * The caller of this wants the passed function to run on every cpu. If wait
188 * is set, wait until all cpus have finished the function before returning.
189 * The lock is here to protect the call structure.
190 * You must not call this function with disabled interrupts or from a
191 * hardware interrupt handler or from a bottom half handler.
192 */
193int smp_call_function(void (*func)(void *info), void *info, int retry, int wait)
194{ 175{
195 unsigned int nr_cpus = atomic_read(&cpus_booted); 176 int cpu;
196 int i;
197
198 /* Can deadlock when called with interrupts disabled */
199 WARN_ON(irqs_disabled());
200
201 spin_lock(&smp_fn_call.lock);
202
203 atomic_set(&smp_fn_call.finished, 0);
204 smp_fn_call.fn = func;
205 smp_fn_call.data = info;
206
207 for (i = 0; i < nr_cpus; i++)
208 if (i != smp_processor_id())
209 plat_send_ipi(i, SMP_MSG_FUNCTION);
210
211 if (wait)
212 while (atomic_read(&smp_fn_call.finished) != (nr_cpus - 1));
213 177
214 spin_unlock(&smp_fn_call.lock); 178 for_each_cpu_mask(cpu, mask)
179 plat_send_ipi(cpu, SMP_MSG_FUNCTION);
180}
215 181
216 return 0; 182void arch_send_call_function_single_ipi(int cpu)
183{
184 plat_send_ipi(cpu, SMP_MSG_FUNCTION_SINGLE);
217} 185}
218 186
219/* Not really SMP stuff ... */ 187/* Not really SMP stuff ... */
@@ -229,7 +197,7 @@ static void flush_tlb_all_ipi(void *info)
229 197
230void flush_tlb_all(void) 198void flush_tlb_all(void)
231{ 199{
232 on_each_cpu(flush_tlb_all_ipi, 0, 1, 1); 200 on_each_cpu(flush_tlb_all_ipi, 0, 1);
233} 201}
234 202
235static void flush_tlb_mm_ipi(void *mm) 203static void flush_tlb_mm_ipi(void *mm)
@@ -255,7 +223,7 @@ void flush_tlb_mm(struct mm_struct *mm)
255 preempt_disable(); 223 preempt_disable();
256 224
257 if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) { 225 if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) {
258 smp_call_function(flush_tlb_mm_ipi, (void *)mm, 1, 1); 226 smp_call_function(flush_tlb_mm_ipi, (void *)mm, 1);
259 } else { 227 } else {
260 int i; 228 int i;
261 for (i = 0; i < num_online_cpus(); i++) 229 for (i = 0; i < num_online_cpus(); i++)
@@ -292,7 +260,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
292 fd.vma = vma; 260 fd.vma = vma;
293 fd.addr1 = start; 261 fd.addr1 = start;
294 fd.addr2 = end; 262 fd.addr2 = end;
295 smp_call_function(flush_tlb_range_ipi, (void *)&fd, 1, 1); 263 smp_call_function(flush_tlb_range_ipi, (void *)&fd, 1);
296 } else { 264 } else {
297 int i; 265 int i;
298 for (i = 0; i < num_online_cpus(); i++) 266 for (i = 0; i < num_online_cpus(); i++)
@@ -316,7 +284,7 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
316 284
317 fd.addr1 = start; 285 fd.addr1 = start;
318 fd.addr2 = end; 286 fd.addr2 = end;
319 on_each_cpu(flush_tlb_kernel_range_ipi, (void *)&fd, 1, 1); 287 on_each_cpu(flush_tlb_kernel_range_ipi, (void *)&fd, 1);
320} 288}
321 289
322static void flush_tlb_page_ipi(void *info) 290static void flush_tlb_page_ipi(void *info)
@@ -335,7 +303,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
335 303
336 fd.vma = vma; 304 fd.vma = vma;
337 fd.addr1 = page; 305 fd.addr1 = page;
338 smp_call_function(flush_tlb_page_ipi, (void *)&fd, 1, 1); 306 smp_call_function(flush_tlb_page_ipi, (void *)&fd, 1);
339 } else { 307 } else {
340 int i; 308 int i;
341 for (i = 0; i < num_online_cpus(); i++) 309 for (i = 0; i < num_online_cpus(); i++)
@@ -359,6 +327,6 @@ void flush_tlb_one(unsigned long asid, unsigned long vaddr)
359 fd.addr1 = asid; 327 fd.addr1 = asid;
360 fd.addr2 = vaddr; 328 fd.addr2 = vaddr;
361 329
362 smp_call_function(flush_tlb_one_ipi, (void *)&fd, 1, 1); 330 smp_call_function(flush_tlb_one_ipi, (void *)&fd, 1);
363 local_flush_tlb_one(asid, vaddr); 331 local_flush_tlb_one(asid, vaddr);
364} 332}
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
index d41e561be20..1b2ae35c4a7 100644
--- a/arch/sh/kernel/stacktrace.c
+++ b/arch/sh/kernel/stacktrace.c
@@ -34,3 +34,4 @@ void save_stack_trace(struct stack_trace *trace)
34 } 34 }
35 } 35 }
36} 36}
37EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index fa63c68a181..c099d96f123 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -807,7 +807,6 @@ extern unsigned long xcall_call_function;
807 * smp_call_function(): Run a function on all other CPUs. 807 * smp_call_function(): Run a function on all other CPUs.
808 * @func: The function to run. This must be fast and non-blocking. 808 * @func: The function to run. This must be fast and non-blocking.
809 * @info: An arbitrary pointer to pass to the function. 809 * @info: An arbitrary pointer to pass to the function.
810 * @nonatomic: currently unused.
811 * @wait: If true, wait (atomically) until function has completed on other CPUs. 810 * @wait: If true, wait (atomically) until function has completed on other CPUs.
812 * 811 *
813 * Returns 0 on success, else a negative status code. Does not return until 812 * Returns 0 on success, else a negative status code. Does not return until
@@ -816,8 +815,8 @@ extern unsigned long xcall_call_function;
816 * You must not call this function with disabled interrupts or from a 815 * You must not call this function with disabled interrupts or from a
817 * hardware interrupt handler or from a bottom half handler. 816 * hardware interrupt handler or from a bottom half handler.
818 */ 817 */
819static int smp_call_function_mask(void (*func)(void *info), void *info, 818static int sparc64_smp_call_function_mask(void (*func)(void *info), void *info,
820 int nonatomic, int wait, cpumask_t mask) 819 int wait, cpumask_t mask)
821{ 820{
822 struct call_data_struct data; 821 struct call_data_struct data;
823 int cpus; 822 int cpus;
@@ -852,11 +851,9 @@ out_unlock:
852 return 0; 851 return 0;
853} 852}
854 853
855int smp_call_function(void (*func)(void *info), void *info, 854int smp_call_function(void (*func)(void *info), void *info, int wait)
856 int nonatomic, int wait)
857{ 855{
858 return smp_call_function_mask(func, info, nonatomic, wait, 856 return sparc64_smp_call_function_mask(func, info, wait, cpu_online_map);
859 cpu_online_map);
860} 857}
861 858
862void smp_call_function_client(int irq, struct pt_regs *regs) 859void smp_call_function_client(int irq, struct pt_regs *regs)
@@ -893,7 +890,7 @@ static void tsb_sync(void *info)
893 890
894void smp_tsb_sync(struct mm_struct *mm) 891void smp_tsb_sync(struct mm_struct *mm)
895{ 892{
896 smp_call_function_mask(tsb_sync, mm, 0, 1, mm->cpu_vm_mask); 893 sparc64_smp_call_function_mask(tsb_sync, mm, 1, mm->cpu_vm_mask);
897} 894}
898 895
899extern unsigned long xcall_flush_tlb_mm; 896extern unsigned long xcall_flush_tlb_mm;
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index c73ce3f4197..b3e3737750d 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -1,6 +1,7 @@
1#include <linux/sched.h> 1#include <linux/sched.h>
2#include <linux/stacktrace.h> 2#include <linux/stacktrace.h>
3#include <linux/thread_info.h> 3#include <linux/thread_info.h>
4#include <linux/module.h>
4#include <asm/ptrace.h> 5#include <asm/ptrace.h>
5#include <asm/stacktrace.h> 6#include <asm/stacktrace.h>
6 7
@@ -47,3 +48,4 @@ void save_stack_trace(struct stack_trace *trace)
47 trace->entries[trace->nr_entries++] = pc; 48 trace->entries[trace->nr_entries++] = pc;
48 } while (trace->nr_entries < trace->max_entries); 49 } while (trace->nr_entries < trace->max_entries);
49} 50}
51EXPORT_SYMBOL_GPL(save_stack_trace);
diff --git a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
index 6cfab2e4d34..ebefd2a1437 100644
--- a/arch/sparc64/mm/hugetlbpage.c
+++ b/arch/sparc64/mm/hugetlbpage.c
@@ -344,7 +344,7 @@ void hugetlb_prefault_arch_hook(struct mm_struct *mm)
344 * also executing in this address space. 344 * also executing in this address space.
345 */ 345 */
346 mm->context.sparc64_ctx_val = ctx; 346 mm->context.sparc64_ctx_val = ctx;
347 on_each_cpu(context_reload, mm, 0, 0); 347 on_each_cpu(context_reload, mm, 0);
348 } 348 }
349 spin_unlock(&ctx_alloc_lock); 349 spin_unlock(&ctx_alloc_lock);
350 } 350 }
diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c
index e1062ec36d4..be2d50c3aa9 100644
--- a/arch/um/kernel/smp.c
+++ b/arch/um/kernel/smp.c
@@ -214,8 +214,7 @@ void smp_call_function_slave(int cpu)
214 atomic_inc(&scf_finished); 214 atomic_inc(&scf_finished);
215} 215}
216 216
217int smp_call_function(void (*_func)(void *info), void *_info, int nonatomic, 217int smp_call_function(void (*_func)(void *info), void *_info, int wait)
218 int wait)
219{ 218{
220 int cpus = num_online_cpus() - 1; 219 int cpus = num_online_cpus() - 1;
221 int i; 220 int i;
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6958d6bcaf7..96e0c2ebc38 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -170,6 +170,7 @@ config GENERIC_PENDING_IRQ
170config X86_SMP 170config X86_SMP
171 bool 171 bool
172 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64) 172 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64)
173 select USE_GENERIC_SMP_HELPERS
173 default y 174 default y
174 175
175config X86_32_SMP 176config X86_32_SMP
@@ -447,7 +448,6 @@ config PARAVIRT_DEBUG
447config MEMTEST 448config MEMTEST
448 bool "Memtest" 449 bool "Memtest"
449 depends on X86_64 450 depends on X86_64
450 default y
451 help 451 help
452 This option adds a kernel parameter 'memtest', which allows memtest 452 This option adds a kernel parameter 'memtest', which allows memtest
453 to be set. 453 to be set.
@@ -455,7 +455,7 @@ config MEMTEST
455 memtest=1, mean do 1 test pattern; 455 memtest=1, mean do 1 test pattern;
456 ... 456 ...
457 memtest=4, mean do 4 test patterns. 457 memtest=4, mean do 4 test patterns.
458 If you are unsure how to answer this question, answer Y. 458 If you are unsure how to answer this question, answer N.
459 459
460config X86_SUMMIT_NUMA 460config X86_SUMMIT_NUMA
461 def_bool y 461 def_bool y
@@ -1135,21 +1135,18 @@ config MTRR
1135 See <file:Documentation/mtrr.txt> for more information. 1135 See <file:Documentation/mtrr.txt> for more information.
1136 1136
1137config MTRR_SANITIZER 1137config MTRR_SANITIZER
1138 def_bool y 1138 bool
1139 prompt "MTRR cleanup support" 1139 prompt "MTRR cleanup support"
1140 depends on MTRR 1140 depends on MTRR
1141 help 1141 help
1142 Convert MTRR layout from continuous to discrete, so some X driver 1142 Convert MTRR layout from continuous to discrete, so X drivers can
1143 could add WB entries. 1143 add writeback entries.
1144 1144
1145 Say N here if you see bootup problems (boot crash, boot hang, 1145 Can be disabled with disable_mtrr_cleanup on the kernel command line.
1146 spontaneous reboots). 1146 The largest mtrr entry size for a continous block can be set with
1147 mtrr_chunk_size.
1147 1148
1148 Could be disabled with disable_mtrr_cleanup. Also mtrr_chunk_size 1149 If unsure, say N.
1149 could be used to send largest mtrr entry size for continuous block
1150 to hold holes (aka. UC entries)
1151
1152 If unsure, say Y.
1153 1150
1154config MTRR_SANITIZER_ENABLE_DEFAULT 1151config MTRR_SANITIZER_ENABLE_DEFAULT
1155 int "MTRR cleanup enable value (0-1)" 1152 int "MTRR cleanup enable value (0-1)"
@@ -1166,7 +1163,7 @@ config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT
1166 depends on MTRR_SANITIZER 1163 depends on MTRR_SANITIZER
1167 help 1164 help
1168 mtrr cleanup spare entries default, it can be changed via 1165 mtrr cleanup spare entries default, it can be changed via
1169 mtrr_spare_reg_nr= 1166 mtrr_spare_reg_nr=N on the kernel command line.
1170 1167
1171config X86_PAT 1168config X86_PAT
1172 bool 1169 bool
diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
index e6a4b564cca..793ad2045f5 100644
--- a/arch/x86/kernel/acpi/sleep.c
+++ b/arch/x86/kernel/acpi/sleep.c
@@ -23,6 +23,15 @@ static unsigned long acpi_realmode;
23static char temp_stack[10240]; 23static char temp_stack[10240];
24#endif 24#endif
25 25
26/* XXX: this macro should move to asm-x86/segment.h and be shared with the
27 boot code... */
28#define GDT_ENTRY(flags, base, limit) \
29 (((u64)(base & 0xff000000) << 32) | \
30 ((u64)flags << 40) | \
31 ((u64)(limit & 0x00ff0000) << 32) | \
32 ((u64)(base & 0x00ffffff) << 16) | \
33 ((u64)(limit & 0x0000ffff)))
34
26/** 35/**
27 * acpi_save_state_mem - save kernel state 36 * acpi_save_state_mem - save kernel state
28 * 37 *
@@ -51,18 +60,27 @@ int acpi_save_state_mem(void)
51 header->video_mode = saved_video_mode; 60 header->video_mode = saved_video_mode;
52 61
53 header->wakeup_jmp_seg = acpi_wakeup_address >> 4; 62 header->wakeup_jmp_seg = acpi_wakeup_address >> 4;
63
64 /*
65 * Set up the wakeup GDT. We set these up as Big Real Mode,
66 * that is, with limits set to 4 GB. At least the Lenovo
67 * Thinkpad X61 is known to need this for the video BIOS
68 * initialization quirk to work; this is likely to also
69 * be the case for other laptops or integrated video devices.
70 */
71
54 /* GDT[0]: GDT self-pointer */ 72 /* GDT[0]: GDT self-pointer */
55 header->wakeup_gdt[0] = 73 header->wakeup_gdt[0] =
56 (u64)(sizeof(header->wakeup_gdt) - 1) + 74 (u64)(sizeof(header->wakeup_gdt) - 1) +
57 ((u64)(acpi_wakeup_address + 75 ((u64)(acpi_wakeup_address +
58 ((char *)&header->wakeup_gdt - (char *)acpi_realmode)) 76 ((char *)&header->wakeup_gdt - (char *)acpi_realmode))
59 << 16); 77 << 16);
60 /* GDT[1]: real-mode-like code segment */ 78 /* GDT[1]: big real mode-like code segment */
61 header->wakeup_gdt[1] = (0x009bULL << 40) + 79 header->wakeup_gdt[1] =
62 ((u64)acpi_wakeup_address << 16) + 0xffff; 80 GDT_ENTRY(0x809b, acpi_wakeup_address, 0xfffff);
63 /* GDT[2]: real-mode-like data segment */ 81 /* GDT[2]: big real mode-like data segment */
64 header->wakeup_gdt[2] = (0x0093ULL << 40) + 82 header->wakeup_gdt[2] =
65 ((u64)acpi_wakeup_address << 16) + 0xffff; 83 GDT_ENTRY(0x8093, acpi_wakeup_address, 0xfffff);
66 84
67#ifndef CONFIG_64BIT 85#ifndef CONFIG_64BIT
68 store_gdt((struct desc_ptr *)&header->pmode_gdt); 86 store_gdt((struct desc_ptr *)&header->pmode_gdt);
diff --git a/arch/x86/kernel/apic_32.c b/arch/x86/kernel/apic_32.c
index 3e58b676d23..a437d027f20 100644
--- a/arch/x86/kernel/apic_32.c
+++ b/arch/x86/kernel/apic_32.c
@@ -1340,6 +1340,10 @@ void __init smp_intr_init(void)
1340 1340
1341 /* IPI for generic function call */ 1341 /* IPI for generic function call */
1342 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 1342 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
1343
1344 /* IPI for single call function */
1345 set_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
1346 call_function_single_interrupt);
1343} 1347}
1344#endif 1348#endif
1345 1349
diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c b/arch/x86/kernel/cpu/mcheck/mce_64.c
index 98741074518..c4a7ec31394 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_64.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_64.c
@@ -364,7 +364,7 @@ static void mcheck_check_cpu(void *info)
364 364
365static void mcheck_timer(struct work_struct *work) 365static void mcheck_timer(struct work_struct *work)
366{ 366{
367 on_each_cpu(mcheck_check_cpu, NULL, 1, 1); 367 on_each_cpu(mcheck_check_cpu, NULL, 1);
368 368
369 /* 369 /*
370 * Alert userspace if needed. If we logged an MCE, reduce the 370 * Alert userspace if needed. If we logged an MCE, reduce the
@@ -621,7 +621,7 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
621 * Collect entries that were still getting written before the 621 * Collect entries that were still getting written before the
622 * synchronize. 622 * synchronize.
623 */ 623 */
624 on_each_cpu(collect_tscs, cpu_tsc, 1, 1); 624 on_each_cpu(collect_tscs, cpu_tsc, 1);
625 for (i = next; i < MCE_LOG_LEN; i++) { 625 for (i = next; i < MCE_LOG_LEN; i++) {
626 if (mcelog.entry[i].finished && 626 if (mcelog.entry[i].finished &&
627 mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) { 627 mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
@@ -746,7 +746,7 @@ static void mce_restart(void)
746 if (next_interval) 746 if (next_interval)
747 cancel_delayed_work(&mcheck_work); 747 cancel_delayed_work(&mcheck_work);
748 /* Timer race is harmless here */ 748 /* Timer race is harmless here */
749 on_each_cpu(mce_init, NULL, 1, 1); 749 on_each_cpu(mce_init, NULL, 1);
750 next_interval = check_interval * HZ; 750 next_interval = check_interval * HZ;
751 if (next_interval) 751 if (next_interval)
752 schedule_delayed_work(&mcheck_work, 752 schedule_delayed_work(&mcheck_work,
diff --git a/arch/x86/kernel/cpu/mcheck/non-fatal.c b/arch/x86/kernel/cpu/mcheck/non-fatal.c
index 00ccb6c14ec..cc1fccdd31e 100644
--- a/arch/x86/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/x86/kernel/cpu/mcheck/non-fatal.c
@@ -59,7 +59,7 @@ static DECLARE_DELAYED_WORK(mce_work, mce_work_fn);
59 59
60static void mce_work_fn(struct work_struct *work) 60static void mce_work_fn(struct work_struct *work)
61{ 61{
62 on_each_cpu(mce_checkregs, NULL, 1, 1); 62 on_each_cpu(mce_checkregs, NULL, 1);
63 schedule_delayed_work(&mce_work, round_jiffies_relative(MCE_RATE)); 63 schedule_delayed_work(&mce_work, round_jiffies_relative(MCE_RATE));
64} 64}
65 65
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
index 105afe12beb..6f23969c8fa 100644
--- a/arch/x86/kernel/cpu/mtrr/main.c
+++ b/arch/x86/kernel/cpu/mtrr/main.c
@@ -223,7 +223,7 @@ static void set_mtrr(unsigned int reg, unsigned long base,
223 atomic_set(&data.gate,0); 223 atomic_set(&data.gate,0);
224 224
225 /* Start the ball rolling on other CPUs */ 225 /* Start the ball rolling on other CPUs */
226 if (smp_call_function(ipi_handler, &data, 1, 0) != 0) 226 if (smp_call_function(ipi_handler, &data, 0) != 0)
227 panic("mtrr: timed out waiting for other CPUs\n"); 227 panic("mtrr: timed out waiting for other CPUs\n");
228 228
229 local_irq_save(flags); 229 local_irq_save(flags);
@@ -1682,7 +1682,7 @@ void mtrr_ap_init(void)
1682 */ 1682 */
1683void mtrr_save_state(void) 1683void mtrr_save_state(void)
1684{ 1684{
1685 smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1, 1); 1685 smp_call_function_single(0, mtrr_save_fixed_ranges, NULL, 1);
1686} 1686}
1687 1687
1688static int __init mtrr_init_finialize(void) 1688static int __init mtrr_init_finialize(void)
diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c
index 2e9bef6e3aa..6d4bdc02388 100644
--- a/arch/x86/kernel/cpu/perfctr-watchdog.c
+++ b/arch/x86/kernel/cpu/perfctr-watchdog.c
@@ -189,7 +189,7 @@ void disable_lapic_nmi_watchdog(void)
189 if (atomic_read(&nmi_active) <= 0) 189 if (atomic_read(&nmi_active) <= 0)
190 return; 190 return;
191 191
192 on_each_cpu(stop_apic_nmi_watchdog, NULL, 0, 1); 192 on_each_cpu(stop_apic_nmi_watchdog, NULL, 1);
193 193
194 if (wd_ops) 194 if (wd_ops)
195 wd_ops->unreserve(); 195 wd_ops->unreserve();
@@ -213,7 +213,7 @@ void enable_lapic_nmi_watchdog(void)
213 return; 213 return;
214 } 214 }
215 215
216 on_each_cpu(setup_apic_nmi_watchdog, NULL, 0, 1); 216 on_each_cpu(setup_apic_nmi_watchdog, NULL, 1);
217 touch_nmi_watchdog(); 217 touch_nmi_watchdog();
218} 218}
219 219
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 71f1c2654be..2de5fa2bbf7 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -96,7 +96,7 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
96 for (; count; count -= 16) { 96 for (; count; count -= 16) {
97 cmd.eax = pos; 97 cmd.eax = pos;
98 cmd.ecx = pos >> 32; 98 cmd.ecx = pos >> 32;
99 smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1, 1); 99 smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
100 if (copy_to_user(tmp, &cmd, 16)) 100 if (copy_to_user(tmp, &cmd, 16))
101 return -EFAULT; 101 return -EFAULT;
102 tmp += 16; 102 tmp += 16;
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index ba41bf42748..ae63e584c34 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -816,6 +816,9 @@ END(invalidate_interrupt\num)
816ENTRY(call_function_interrupt) 816ENTRY(call_function_interrupt)
817 apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt 817 apicinterrupt CALL_FUNCTION_VECTOR,smp_call_function_interrupt
818END(call_function_interrupt) 818END(call_function_interrupt)
819ENTRY(call_function_single_interrupt)
820 apicinterrupt CALL_FUNCTION_SINGLE_VECTOR,smp_call_function_single_interrupt
821END(call_function_single_interrupt)
819ENTRY(irq_move_cleanup_interrupt) 822ENTRY(irq_move_cleanup_interrupt)
820 apicinterrupt IRQ_MOVE_CLEANUP_VECTOR,smp_irq_move_cleanup_interrupt 823 apicinterrupt IRQ_MOVE_CLEANUP_VECTOR,smp_irq_move_cleanup_interrupt
821END(irq_move_cleanup_interrupt) 824END(irq_move_cleanup_interrupt)
diff --git a/arch/x86/kernel/io_apic_32.c b/arch/x86/kernel/io_apic_32.c
index 603261a5885..558abf4c796 100644
--- a/arch/x86/kernel/io_apic_32.c
+++ b/arch/x86/kernel/io_apic_32.c
@@ -1569,7 +1569,7 @@ void /*__init*/ print_local_APIC(void *dummy)
1569 1569
1570void print_all_local_APICs(void) 1570void print_all_local_APICs(void)
1571{ 1571{
1572 on_each_cpu(print_local_APIC, NULL, 1, 1); 1572 on_each_cpu(print_local_APIC, NULL, 1);
1573} 1573}
1574 1574
1575void /*__init*/ print_PIC(void) 1575void /*__init*/ print_PIC(void)
diff --git a/arch/x86/kernel/io_apic_64.c b/arch/x86/kernel/io_apic_64.c
index b16ef029cf8..6510cde36b3 100644
--- a/arch/x86/kernel/io_apic_64.c
+++ b/arch/x86/kernel/io_apic_64.c
@@ -1160,7 +1160,7 @@ void __apicdebuginit print_local_APIC(void * dummy)
1160 1160
1161void print_all_local_APICs (void) 1161void print_all_local_APICs (void)
1162{ 1162{
1163 on_each_cpu(print_local_APIC, NULL, 1, 1); 1163 on_each_cpu(print_local_APIC, NULL, 1);
1164} 1164}
1165 1165
1166void __apicdebuginit print_PIC(void) 1166void __apicdebuginit print_PIC(void)
diff --git a/arch/x86/kernel/irqinit_64.c b/arch/x86/kernel/irqinit_64.c
index 31f49e8f46a..0373e88de95 100644
--- a/arch/x86/kernel/irqinit_64.c
+++ b/arch/x86/kernel/irqinit_64.c
@@ -199,6 +199,10 @@ void __init native_init_IRQ(void)
199 /* IPI for generic function call */ 199 /* IPI for generic function call */
200 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 200 alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
201 201
202 /* IPI for generic single function call */
203 alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
204 call_function_single_interrupt);
205
202 /* Low priority IPI to cleanup after moving an irq */ 206 /* Low priority IPI to cleanup after moving an irq */
203 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt); 207 set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
204#endif 208#endif
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 21f2bae98c1..a8449571858 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -68,7 +68,7 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
68 load_LDT(pc); 68 load_LDT(pc);
69 mask = cpumask_of_cpu(smp_processor_id()); 69 mask = cpumask_of_cpu(smp_processor_id());
70 if (!cpus_equal(current->mm->cpu_vm_mask, mask)) 70 if (!cpus_equal(current->mm->cpu_vm_mask, mask))
71 smp_call_function(flush_ldt, current->mm, 1, 1); 71 smp_call_function(flush_ldt, current->mm, 1);
72 preempt_enable(); 72 preempt_enable();
73#else 73#else
74 load_LDT(pc); 74 load_LDT(pc);
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 716b89284be..ec024b3baad 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -130,7 +130,7 @@ int __init check_nmi_watchdog(void)
130 130
131#ifdef CONFIG_SMP 131#ifdef CONFIG_SMP
132 if (nmi_watchdog == NMI_LOCAL_APIC) 132 if (nmi_watchdog == NMI_LOCAL_APIC)
133 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0, 0); 133 smp_call_function(nmi_cpu_busy, (void *)&endflag, 0);
134#endif 134#endif
135 135
136 for_each_possible_cpu(cpu) 136 for_each_possible_cpu(cpu)
@@ -272,7 +272,7 @@ static void __acpi_nmi_enable(void *__unused)
272void acpi_nmi_enable(void) 272void acpi_nmi_enable(void)
273{ 273{
274 if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC) 274 if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
275 on_each_cpu(__acpi_nmi_enable, NULL, 0, 1); 275 on_each_cpu(__acpi_nmi_enable, NULL, 1);
276} 276}
277 277
278static void __acpi_nmi_disable(void *__unused) 278static void __acpi_nmi_disable(void *__unused)
@@ -286,7 +286,7 @@ static void __acpi_nmi_disable(void *__unused)
286void acpi_nmi_disable(void) 286void acpi_nmi_disable(void)
287{ 287{
288 if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC) 288 if (atomic_read(&nmi_active) && nmi_watchdog == NMI_IO_APIC)
289 on_each_cpu(__acpi_nmi_disable, NULL, 0, 1); 289 on_each_cpu(__acpi_nmi_disable, NULL, 1);
290} 290}
291 291
292void setup_apic_nmi_watchdog(void *unused) 292void setup_apic_nmi_watchdog(void *unused)
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 4061d63aabe..7dceea94723 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -132,7 +132,7 @@ void cpu_idle_wait(void)
132{ 132{
133 smp_mb(); 133 smp_mb();
134 /* kick all the CPUs so that they exit out of pm_idle */ 134 /* kick all the CPUs so that they exit out of pm_idle */
135 smp_call_function(do_nothing, NULL, 0, 1); 135 smp_call_function(do_nothing, NULL, 1);
136} 136}
137EXPORT_SYMBOL_GPL(cpu_idle_wait); 137EXPORT_SYMBOL_GPL(cpu_idle_wait);
138 138
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 79bdcd11c66..d1385881810 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -266,6 +266,8 @@ static void old_ich_force_enable_hpet_user(struct pci_dev *dev)
266 hpet_print_force_info(); 266 hpet_print_force_info();
267} 267}
268 268
269DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,
270 old_ich_force_enable_hpet_user);
269DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, 271DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
270 old_ich_force_enable_hpet_user); 272 old_ich_force_enable_hpet_user);
271DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, 273DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index 0cb7aadc87c..361b7a4c640 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -121,132 +121,23 @@ static void native_smp_send_reschedule(int cpu)
121 send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR); 121 send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
122} 122}
123 123
124/* 124void native_send_call_func_single_ipi(int cpu)
125 * Structure and data for smp_call_function(). This is designed to minimise
126 * static memory requirements. It also looks cleaner.
127 */
128static DEFINE_SPINLOCK(call_lock);
129
130struct call_data_struct {
131 void (*func) (void *info);
132 void *info;
133 atomic_t started;
134 atomic_t finished;
135 int wait;
136};
137
138void lock_ipi_call_lock(void)
139{ 125{
140 spin_lock_irq(&call_lock); 126 send_IPI_mask(cpumask_of_cpu(cpu), CALL_FUNCTION_SINGLE_VECTOR);
141}
142
143void unlock_ipi_call_lock(void)
144{
145 spin_unlock_irq(&call_lock);
146}
147
148static struct call_data_struct *call_data;
149
150static void __smp_call_function(void (*func) (void *info), void *info,
151 int nonatomic, int wait)
152{
153 struct call_data_struct data;
154 int cpus = num_online_cpus() - 1;
155
156 if (!cpus)
157 return;
158
159 data.func = func;
160 data.info = info;
161 atomic_set(&data.started, 0);
162 data.wait = wait;
163 if (wait)
164 atomic_set(&data.finished, 0);
165
166 call_data = &data;
167 mb();
168
169 /* Send a message to all other CPUs and wait for them to respond */
170 send_IPI_allbutself(CALL_FUNCTION_VECTOR);
171
172 /* Wait for response */
173 while (atomic_read(&data.started) != cpus)
174 cpu_relax();
175
176 if (wait)
177 while (atomic_read(&data.finished) != cpus)
178 cpu_relax();
179} 127}
180 128
181 129void native_send_call_func_ipi(cpumask_t mask)
182/**
183 * smp_call_function_mask(): Run a function on a set of other CPUs.
184 * @mask: The set of cpus to run on. Must not include the current cpu.
185 * @func: The function to run. This must be fast and non-blocking.
186 * @info: An arbitrary pointer to pass to the function.
187 * @wait: If true, wait (atomically) until function has completed on other CPUs.
188 *
189 * Returns 0 on success, else a negative status code.
190 *
191 * If @wait is true, then returns once @func has returned; otherwise
192 * it returns just before the target cpu calls @func.
193 *
194 * You must not call this function with disabled interrupts or from a
195 * hardware interrupt handler or from a bottom half handler.
196 */
197static int
198native_smp_call_function_mask(cpumask_t mask,
199 void (*func)(void *), void *info,
200 int wait)
201{ 130{
202 struct call_data_struct data;
203 cpumask_t allbutself; 131 cpumask_t allbutself;
204 int cpus;
205
206 /* Can deadlock when called with interrupts disabled */
207 WARN_ON(irqs_disabled());
208
209 /* Holding any lock stops cpus from going down. */
210 spin_lock(&call_lock);
211 132
212 allbutself = cpu_online_map; 133 allbutself = cpu_online_map;
213 cpu_clear(smp_processor_id(), allbutself); 134 cpu_clear(smp_processor_id(), allbutself);
214 135
215 cpus_and(mask, mask, allbutself);
216 cpus = cpus_weight(mask);
217
218 if (!cpus) {
219 spin_unlock(&call_lock);
220 return 0;
221 }
222
223 data.func = func;
224 data.info = info;
225 atomic_set(&data.started, 0);
226 data.wait = wait;
227 if (wait)
228 atomic_set(&data.finished, 0);
229
230 call_data = &data;
231 wmb();
232
233 /* Send a message to other CPUs */
234 if (cpus_equal(mask, allbutself) && 136 if (cpus_equal(mask, allbutself) &&
235 cpus_equal(cpu_online_map, cpu_callout_map)) 137 cpus_equal(cpu_online_map, cpu_callout_map))
236 send_IPI_allbutself(CALL_FUNCTION_VECTOR); 138 send_IPI_allbutself(CALL_FUNCTION_VECTOR);
237 else 139 else
238 send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 140 send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
239
240 /* Wait for response */
241 while (atomic_read(&data.started) != cpus)
242 cpu_relax();
243
244 if (wait)
245 while (atomic_read(&data.finished) != cpus)
246 cpu_relax();
247 spin_unlock(&call_lock);
248
249 return 0;
250} 141}
251 142
252static void stop_this_cpu(void *dummy) 143static void stop_this_cpu(void *dummy)
@@ -268,18 +159,13 @@ static void stop_this_cpu(void *dummy)
268 159
269static void native_smp_send_stop(void) 160static void native_smp_send_stop(void)
270{ 161{
271 int nolock;
272 unsigned long flags; 162 unsigned long flags;
273 163
274 if (reboot_force) 164 if (reboot_force)
275 return; 165 return;
276 166
277 /* Don't deadlock on the call lock in panic */ 167 smp_call_function(stop_this_cpu, NULL, 0);
278 nolock = !spin_trylock(&call_lock);
279 local_irq_save(flags); 168 local_irq_save(flags);
280 __smp_call_function(stop_this_cpu, NULL, 0, 0);
281 if (!nolock)
282 spin_unlock(&call_lock);
283 disable_local_APIC(); 169 disable_local_APIC();
284 local_irq_restore(flags); 170 local_irq_restore(flags);
285} 171}
@@ -301,33 +187,28 @@ void smp_reschedule_interrupt(struct pt_regs *regs)
301 187
302void smp_call_function_interrupt(struct pt_regs *regs) 188void smp_call_function_interrupt(struct pt_regs *regs)
303{ 189{
304 void (*func) (void *info) = call_data->func;
305 void *info = call_data->info;
306 int wait = call_data->wait;
307
308 ack_APIC_irq(); 190 ack_APIC_irq();
309 /*
310 * Notify initiating CPU that I've grabbed the data and am
311 * about to execute the function
312 */
313 mb();
314 atomic_inc(&call_data->started);
315 /*
316 * At this point the info structure may be out of scope unless wait==1
317 */
318 irq_enter(); 191 irq_enter();
319 (*func)(info); 192 generic_smp_call_function_interrupt();
320#ifdef CONFIG_X86_32 193#ifdef CONFIG_X86_32
321 __get_cpu_var(irq_stat).irq_call_count++; 194 __get_cpu_var(irq_stat).irq_call_count++;
322#else 195#else
323 add_pda(irq_call_count, 1); 196 add_pda(irq_call_count, 1);
324#endif 197#endif
325 irq_exit(); 198 irq_exit();
199}
326 200
327 if (wait) { 201void smp_call_function_single_interrupt(struct pt_regs *regs)
328 mb(); 202{
329 atomic_inc(&call_data->finished); 203 ack_APIC_irq();
330 } 204 irq_enter();
205 generic_smp_call_function_single_interrupt();
206#ifdef CONFIG_X86_32
207 __get_cpu_var(irq_stat).irq_call_count++;
208#else
209 add_pda(irq_call_count, 1);
210#endif
211 irq_exit();
331} 212}
332 213
333struct smp_ops smp_ops = { 214struct smp_ops smp_ops = {
@@ -338,7 +219,8 @@ struct smp_ops smp_ops = {
338 219
339 .smp_send_stop = native_smp_send_stop, 220 .smp_send_stop = native_smp_send_stop,
340 .smp_send_reschedule = native_smp_send_reschedule, 221 .smp_send_reschedule = native_smp_send_reschedule,
341 .smp_call_function_mask = native_smp_call_function_mask, 222
223 .send_call_func_ipi = native_send_call_func_ipi,
224 .send_call_func_single_ipi = native_send_call_func_single_ipi,
342}; 225};
343EXPORT_SYMBOL_GPL(smp_ops); 226EXPORT_SYMBOL_GPL(smp_ops);
344
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index f35c2d8016a..687376ab07e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -327,12 +327,12 @@ static void __cpuinit start_secondary(void *unused)
327 * lock helps us to not include this cpu in a currently in progress 327 * lock helps us to not include this cpu in a currently in progress
328 * smp_call_function(). 328 * smp_call_function().
329 */ 329 */
330 lock_ipi_call_lock(); 330 ipi_call_lock_irq();
331#ifdef CONFIG_X86_IO_APIC 331#ifdef CONFIG_X86_IO_APIC
332 setup_vector_irq(smp_processor_id()); 332 setup_vector_irq(smp_processor_id());
333#endif 333#endif
334 cpu_set(smp_processor_id(), cpu_online_map); 334 cpu_set(smp_processor_id(), cpu_online_map);
335 unlock_ipi_call_lock(); 335 ipi_call_unlock_irq();
336 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; 336 per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
337 337
338 setup_secondary_clock(); 338 setup_secondary_clock();
diff --git a/arch/x86/kernel/smpcommon.c b/arch/x86/kernel/smpcommon.c
index 3449064d141..99941b37eca 100644
--- a/arch/x86/kernel/smpcommon.c
+++ b/arch/x86/kernel/smpcommon.c
@@ -25,59 +25,3 @@ __cpuinit void init_gdt(int cpu)
25 per_cpu(cpu_number, cpu) = cpu; 25 per_cpu(cpu_number, cpu) = cpu;
26} 26}
27#endif 27#endif
28
29/**
30 * smp_call_function(): Run a function on all other CPUs.
31 * @func: The function to run. This must be fast and non-blocking.
32 * @info: An arbitrary pointer to pass to the function.
33 * @nonatomic: Unused.
34 * @wait: If true, wait (atomically) until function has completed on other CPUs.
35 *
36 * Returns 0 on success, else a negative status code.
37 *
38 * If @wait is true, then returns once @func has returned; otherwise
39 * it returns just before the target cpu calls @func.
40 *
41 * You must not call this function with disabled interrupts or from a
42 * hardware interrupt handler or from a bottom half handler.
43 */
44int smp_call_function(void (*func) (void *info), void *info, int nonatomic,
45 int wait)
46{
47 return smp_call_function_mask(cpu_online_map, func, info, wait);
48}
49EXPORT_SYMBOL(smp_call_function);
50
51/**
52 * smp_call_function_single - Run a function on a specific CPU
53 * @cpu: The target CPU. Cannot be the calling CPU.
54 * @func: The function to run. This must be fast and non-blocking.
55 * @info: An arbitrary pointer to pass to the function.
56 * @nonatomic: Unused.
57 * @wait: If true, wait until function has completed on other CPUs.
58 *
59 * Returns 0 on success, else a negative status code.
60 *
61 * If @wait is true, then returns once @func has returned; otherwise
62 * it returns just before the target cpu calls @func.
63 */
64int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
65 int nonatomic, int wait)
66{
67 /* prevent preemption and reschedule on another processor */
68 int ret;
69 int me = get_cpu();
70 if (cpu == me) {
71 local_irq_disable();
72 func(info);
73 local_irq_enable();
74 put_cpu();
75 return 0;
76 }
77
78 ret = smp_call_function_mask(cpumask_of_cpu(cpu), func, info, wait);
79
80 put_cpu();
81 return ret;
82}
83EXPORT_SYMBOL(smp_call_function_single);
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index c28c342c162..a03e7f6d90c 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -74,6 +74,7 @@ void save_stack_trace(struct stack_trace *trace)
74 if (trace->nr_entries < trace->max_entries) 74 if (trace->nr_entries < trace->max_entries)
75 trace->entries[trace->nr_entries++] = ULONG_MAX; 75 trace->entries[trace->nr_entries++] = ULONG_MAX;
76} 76}
77EXPORT_SYMBOL_GPL(save_stack_trace);
77 78
78void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 79void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
79{ 80{
@@ -81,3 +82,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
81 if (trace->nr_entries < trace->max_entries) 82 if (trace->nr_entries < trace->max_entries)
82 trace->entries[trace->nr_entries++] = ULONG_MAX; 83 trace->entries[trace->nr_entries++] = ULONG_MAX;
83} 84}
85EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
diff --git a/arch/x86/kernel/tlb_32.c b/arch/x86/kernel/tlb_32.c
index 9bb2363851a..fec1ecedc9b 100644
--- a/arch/x86/kernel/tlb_32.c
+++ b/arch/x86/kernel/tlb_32.c
@@ -238,6 +238,6 @@ static void do_flush_tlb_all(void *info)
238 238
239void flush_tlb_all(void) 239void flush_tlb_all(void)
240{ 240{
241 on_each_cpu(do_flush_tlb_all, NULL, 1, 1); 241 on_each_cpu(do_flush_tlb_all, NULL, 1);
242} 242}
243 243
diff --git a/arch/x86/kernel/tlb_64.c b/arch/x86/kernel/tlb_64.c
index 5039d0f097a..dcbf7a1159e 100644
--- a/arch/x86/kernel/tlb_64.c
+++ b/arch/x86/kernel/tlb_64.c
@@ -275,5 +275,5 @@ static void do_flush_tlb_all(void *info)
275 275
276void flush_tlb_all(void) 276void flush_tlb_all(void)
277{ 277{
278 on_each_cpu(do_flush_tlb_all, NULL, 1, 1); 278 on_each_cpu(do_flush_tlb_all, NULL, 1);
279} 279}
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 3c36f92160c..7603c055390 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -358,6 +358,7 @@ static cycle_t read_tsc(void)
358 ret : clocksource_tsc.cycle_last; 358 ret : clocksource_tsc.cycle_last;
359} 359}
360 360
361#ifdef CONFIG_X86_64
361static cycle_t __vsyscall_fn vread_tsc(void) 362static cycle_t __vsyscall_fn vread_tsc(void)
362{ 363{
363 cycle_t ret = (cycle_t)vget_cycles(); 364 cycle_t ret = (cycle_t)vget_cycles();
@@ -365,6 +366,7 @@ static cycle_t __vsyscall_fn vread_tsc(void)
365 return ret >= __vsyscall_gtod_data.clock.cycle_last ? 366 return ret >= __vsyscall_gtod_data.clock.cycle_last ?
366 ret : __vsyscall_gtod_data.clock.cycle_last; 367 ret : __vsyscall_gtod_data.clock.cycle_last;
367} 368}
369#endif
368 370
369static struct clocksource clocksource_tsc = { 371static struct clocksource clocksource_tsc = {
370 .name = "tsc", 372 .name = "tsc",
diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
index e50740d3231..0b8b6690a86 100644
--- a/arch/x86/kernel/vsyscall_64.c
+++ b/arch/x86/kernel/vsyscall_64.c
@@ -279,7 +279,7 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
279{ 279{
280 long cpu = (long)arg; 280 long cpu = (long)arg;
281 if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN) 281 if (action == CPU_ONLINE || action == CPU_ONLINE_FROZEN)
282 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1); 282 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 1);
283 return NOTIFY_DONE; 283 return NOTIFY_DONE;
284} 284}
285 285
@@ -302,7 +302,7 @@ static int __init vsyscall_init(void)
302#ifdef CONFIG_SYSCTL 302#ifdef CONFIG_SYSCTL
303 register_sysctl_table(kernel_root_table2); 303 register_sysctl_table(kernel_root_table2);
304#endif 304#endif
305 on_each_cpu(cpu_vsyscall_init, NULL, 0, 1); 305 on_each_cpu(cpu_vsyscall_init, NULL, 1);
306 hotcpu_notifier(cpu_vsyscall_notifier, 0); 306 hotcpu_notifier(cpu_vsyscall_notifier, 0);
307 return 0; 307 return 0;
308} 308}
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 540e9517907..10ce6ee4c49 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -335,7 +335,7 @@ static void vcpu_clear(struct vcpu_vmx *vmx)
335{ 335{
336 if (vmx->vcpu.cpu == -1) 336 if (vmx->vcpu.cpu == -1)
337 return; 337 return;
338 smp_call_function_single(vmx->vcpu.cpu, __vcpu_clear, vmx, 0, 1); 338 smp_call_function_single(vmx->vcpu.cpu, __vcpu_clear, vmx, 1);
339 vmx->launched = 0; 339 vmx->launched = 0;
340} 340}
341 341
@@ -2968,7 +2968,7 @@ static void vmx_free_vmcs(struct kvm_vcpu *vcpu)
2968 struct vcpu_vmx *vmx = to_vmx(vcpu); 2968 struct vcpu_vmx *vmx = to_vmx(vcpu);
2969 2969
2970 if (vmx->vmcs) { 2970 if (vmx->vmcs) {
2971 on_each_cpu(__vcpu_clear, vmx, 0, 1); 2971 on_each_cpu(__vcpu_clear, vmx, 1);
2972 free_vmcs(vmx->vmcs); 2972 free_vmcs(vmx->vmcs);
2973 vmx->vmcs = NULL; 2973 vmx->vmcs = NULL;
2974 } 2974 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 63a77caa59f..0faa2546b1c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4044,6 +4044,6 @@ void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
4044 * So need not to call smp_call_function_single() in that case. 4044 * So need not to call smp_call_function_single() in that case.
4045 */ 4045 */
4046 if (vcpu->guest_mode && vcpu->cpu != cpu) 4046 if (vcpu->guest_mode && vcpu->cpu != cpu)
4047 smp_call_function_single(ipi_pcpu, vcpu_kick_intr, vcpu, 0, 0); 4047 smp_call_function_single(ipi_pcpu, vcpu_kick_intr, vcpu, 0);
4048 put_cpu(); 4048 put_cpu();
4049} 4049}
diff --git a/arch/x86/lib/msr-on-cpu.c b/arch/x86/lib/msr-on-cpu.c
index 57d043fa893..d5a2b39f882 100644
--- a/arch/x86/lib/msr-on-cpu.c
+++ b/arch/x86/lib/msr-on-cpu.c
@@ -30,10 +30,10 @@ static int _rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h, int safe)
30 30
31 rv.msr_no = msr_no; 31 rv.msr_no = msr_no;
32 if (safe) { 32 if (safe) {
33 smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 0, 1); 33 smp_call_function_single(cpu, __rdmsr_safe_on_cpu, &rv, 1);
34 err = rv.err; 34 err = rv.err;
35 } else { 35 } else {
36 smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 0, 1); 36 smp_call_function_single(cpu, __rdmsr_on_cpu, &rv, 1);
37 } 37 }
38 *l = rv.l; 38 *l = rv.l;
39 *h = rv.h; 39 *h = rv.h;
@@ -64,10 +64,10 @@ static int _wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h, int safe)
64 rv.l = l; 64 rv.l = l;
65 rv.h = h; 65 rv.h = h;
66 if (safe) { 66 if (safe) {
67 smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 0, 1); 67 smp_call_function_single(cpu, __wrmsr_safe_on_cpu, &rv, 1);
68 err = rv.err; 68 err = rv.err;
69 } else { 69 } else {
70 smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 0, 1); 70 smp_call_function_single(cpu, __wrmsr_on_cpu, &rv, 1);
71 } 71 }
72 72
73 return err; 73 return err;
diff --git a/arch/x86/mach-voyager/voyager_smp.c b/arch/x86/mach-voyager/voyager_smp.c
index 8dedd01e909..ee0fba09215 100644
--- a/arch/x86/mach-voyager/voyager_smp.c
+++ b/arch/x86/mach-voyager/voyager_smp.c
@@ -950,94 +950,24 @@ static void smp_stop_cpu_function(void *dummy)
950 halt(); 950 halt();
951} 951}
952 952
953static DEFINE_SPINLOCK(call_lock);
954
955struct call_data_struct {
956 void (*func) (void *info);
957 void *info;
958 volatile unsigned long started;
959 volatile unsigned long finished;
960 int wait;
961};
962
963static struct call_data_struct *call_data;
964
965/* execute a thread on a new CPU. The function to be called must be 953/* execute a thread on a new CPU. The function to be called must be
966 * previously set up. This is used to schedule a function for 954 * previously set up. This is used to schedule a function for
967 * execution on all CPUs - set up the function then broadcast a 955 * execution on all CPUs - set up the function then broadcast a
968 * function_interrupt CPI to come here on each CPU */ 956 * function_interrupt CPI to come here on each CPU */
969static void smp_call_function_interrupt(void) 957static void smp_call_function_interrupt(void)
970{ 958{
971 void (*func) (void *info) = call_data->func;
972 void *info = call_data->info;
973 /* must take copy of wait because call_data may be replaced
974 * unless the function is waiting for us to finish */
975 int wait = call_data->wait;
976 __u8 cpu = smp_processor_id();
977
978 /*
979 * Notify initiating CPU that I've grabbed the data and am
980 * about to execute the function
981 */
982 mb();
983 if (!test_and_clear_bit(cpu, &call_data->started)) {
984 /* If the bit wasn't set, this could be a replay */
985 printk(KERN_WARNING "VOYAGER SMP: CPU %d received call funtion"
986 " with no call pending\n", cpu);
987 return;
988 }
989 /*
990 * At this point the info structure may be out of scope unless wait==1
991 */
992 irq_enter(); 959 irq_enter();
993 (*func) (info); 960 generic_smp_call_function_interrupt();
994 __get_cpu_var(irq_stat).irq_call_count++; 961 __get_cpu_var(irq_stat).irq_call_count++;
995 irq_exit(); 962 irq_exit();
996 if (wait) {
997 mb();
998 clear_bit(cpu, &call_data->finished);
999 }
1000} 963}
1001 964
1002static int 965static void smp_call_function_single_interrupt(void)
1003voyager_smp_call_function_mask(cpumask_t cpumask,
1004 void (*func) (void *info), void *info, int wait)
1005{ 966{
1006 struct call_data_struct data; 967 irq_enter();
1007 u32 mask = cpus_addr(cpumask)[0]; 968 generic_smp_call_function_single_interrupt();
1008 969 __get_cpu_var(irq_stat).irq_call_count++;
1009 mask &= ~(1 << smp_processor_id()); 970 irq_exit();
1010
1011 if (!mask)
1012 return 0;
1013
1014 /* Can deadlock when called with interrupts disabled */
1015 WARN_ON(irqs_disabled());
1016
1017 data.func = func;
1018 data.info = info;
1019 data.started = mask;
1020 data.wait = wait;
1021 if (wait)
1022 data.finished = mask;
1023
1024 spin_lock(&call_lock);
1025 call_data = &data;
1026 wmb();
1027 /* Send a message to all other CPUs and wait for them to respond */
1028 send_CPI(mask, VIC_CALL_FUNCTION_CPI);
1029
1030 /* Wait for response */
1031 while (data.started)
1032 barrier();
1033
1034 if (wait)
1035 while (data.finished)
1036 barrier();
1037
1038 spin_unlock(&call_lock);
1039
1040 return 0;
1041} 971}
1042 972
1043/* Sorry about the name. In an APIC based system, the APICs 973/* Sorry about the name. In an APIC based system, the APICs
@@ -1094,6 +1024,12 @@ void smp_qic_call_function_interrupt(struct pt_regs *regs)
1094 smp_call_function_interrupt(); 1024 smp_call_function_interrupt();
1095} 1025}
1096 1026
1027void smp_qic_call_function_single_interrupt(struct pt_regs *regs)
1028{
1029 ack_QIC_CPI(QIC_CALL_FUNCTION_SINGLE_CPI);
1030 smp_call_function_single_interrupt();
1031}
1032
1097void smp_vic_cpi_interrupt(struct pt_regs *regs) 1033void smp_vic_cpi_interrupt(struct pt_regs *regs)
1098{ 1034{
1099 struct pt_regs *old_regs = set_irq_regs(regs); 1035 struct pt_regs *old_regs = set_irq_regs(regs);
@@ -1114,6 +1050,8 @@ void smp_vic_cpi_interrupt(struct pt_regs *regs)
1114 smp_enable_irq_interrupt(); 1050 smp_enable_irq_interrupt();
1115 if (test_and_clear_bit(VIC_CALL_FUNCTION_CPI, &vic_cpi_mailbox[cpu])) 1051 if (test_and_clear_bit(VIC_CALL_FUNCTION_CPI, &vic_cpi_mailbox[cpu]))
1116 smp_call_function_interrupt(); 1052 smp_call_function_interrupt();
1053 if (test_and_clear_bit(VIC_CALL_FUNCTION_SINGLE_CPI, &vic_cpi_mailbox[cpu]))
1054 smp_call_function_single_interrupt();
1117 set_irq_regs(old_regs); 1055 set_irq_regs(old_regs);
1118} 1056}
1119 1057
@@ -1129,7 +1067,7 @@ static void do_flush_tlb_all(void *info)
1129/* flush the TLB of every active CPU in the system */ 1067/* flush the TLB of every active CPU in the system */
1130void flush_tlb_all(void) 1068void flush_tlb_all(void)
1131{ 1069{
1132 on_each_cpu(do_flush_tlb_all, 0, 1, 1); 1070 on_each_cpu(do_flush_tlb_all, 0, 1);
1133} 1071}
1134 1072
1135/* send a reschedule CPI to one CPU by physical CPU number*/ 1073/* send a reschedule CPI to one CPU by physical CPU number*/
@@ -1161,7 +1099,7 @@ int safe_smp_processor_id(void)
1161/* broadcast a halt to all other CPUs */ 1099/* broadcast a halt to all other CPUs */
1162static void voyager_smp_send_stop(void) 1100static void voyager_smp_send_stop(void)
1163{ 1101{
1164 smp_call_function(smp_stop_cpu_function, NULL, 1, 1); 1102 smp_call_function(smp_stop_cpu_function, NULL, 1);
1165} 1103}
1166 1104
1167/* this function is triggered in time.c when a clock tick fires 1105/* this function is triggered in time.c when a clock tick fires
@@ -1848,5 +1786,7 @@ struct smp_ops smp_ops = {
1848 1786
1849 .smp_send_stop = voyager_smp_send_stop, 1787 .smp_send_stop = voyager_smp_send_stop,
1850 .smp_send_reschedule = voyager_smp_send_reschedule, 1788 .smp_send_reschedule = voyager_smp_send_reschedule,
1851 .smp_call_function_mask = voyager_smp_call_function_mask, 1789
1790 .send_call_func_ipi = native_send_call_func_ipi,
1791 .send_call_func_single_ipi = native_send_call_func_single_ipi,
1852}; 1792};
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 47f4e2e4a09..65c6e46bf05 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -141,7 +141,7 @@ static void cpa_flush_all(unsigned long cache)
141{ 141{
142 BUG_ON(irqs_disabled()); 142 BUG_ON(irqs_disabled());
143 143
144 on_each_cpu(__cpa_flush_all, (void *) cache, 1, 1); 144 on_each_cpu(__cpa_flush_all, (void *) cache, 1);
145} 145}
146 146
147static void __cpa_flush_range(void *arg) 147static void __cpa_flush_range(void *arg)
@@ -162,7 +162,7 @@ static void cpa_flush_range(unsigned long start, int numpages, int cache)
162 BUG_ON(irqs_disabled()); 162 BUG_ON(irqs_disabled());
163 WARN_ON(PAGE_ALIGN(start) != start); 163 WARN_ON(PAGE_ALIGN(start) != start);
164 164
165 on_each_cpu(__cpa_flush_range, NULL, 1, 1); 165 on_each_cpu(__cpa_flush_range, NULL, 1);
166 166
167 if (!cache) 167 if (!cache)
168 return; 168 return;
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 2b6ad5b9f9d..7f3329b55d2 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -218,8 +218,8 @@ static int nmi_setup(void)
218 } 218 }
219 219
220 } 220 }
221 on_each_cpu(nmi_save_registers, NULL, 0, 1); 221 on_each_cpu(nmi_save_registers, NULL, 1);
222 on_each_cpu(nmi_cpu_setup, NULL, 0, 1); 222 on_each_cpu(nmi_cpu_setup, NULL, 1);
223 nmi_enabled = 1; 223 nmi_enabled = 1;
224 return 0; 224 return 0;
225} 225}
@@ -271,7 +271,7 @@ static void nmi_shutdown(void)
271{ 271{
272 struct op_msrs *msrs = &get_cpu_var(cpu_msrs); 272 struct op_msrs *msrs = &get_cpu_var(cpu_msrs);
273 nmi_enabled = 0; 273 nmi_enabled = 0;
274 on_each_cpu(nmi_cpu_shutdown, NULL, 0, 1); 274 on_each_cpu(nmi_cpu_shutdown, NULL, 1);
275 unregister_die_notifier(&profile_exceptions_nb); 275 unregister_die_notifier(&profile_exceptions_nb);
276 model->shutdown(msrs); 276 model->shutdown(msrs);
277 free_msrs(); 277 free_msrs();
@@ -286,7 +286,7 @@ static void nmi_cpu_start(void *dummy)
286 286
287static int nmi_start(void) 287static int nmi_start(void)
288{ 288{
289 on_each_cpu(nmi_cpu_start, NULL, 0, 1); 289 on_each_cpu(nmi_cpu_start, NULL, 1);
290 return 0; 290 return 0;
291} 291}
292 292
@@ -298,7 +298,7 @@ static void nmi_cpu_stop(void *dummy)
298 298
299static void nmi_stop(void) 299static void nmi_stop(void)
300{ 300{
301 on_each_cpu(nmi_cpu_stop, NULL, 0, 1); 301 on_each_cpu(nmi_cpu_stop, NULL, 1);
302} 302}
303 303
304struct op_counter_config counter_config[OP_MAX_COUNTER]; 304struct op_counter_config counter_config[OP_MAX_COUNTER];
diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
index a18141ae3f0..dbf53236971 100644
--- a/arch/x86/pci/amd_bus.c
+++ b/arch/x86/pci/amd_bus.c
@@ -578,7 +578,7 @@ static int __init enable_pci_io_ecs(void)
578 /* assume all cpus from fam10h have IO ECS */ 578 /* assume all cpus from fam10h have IO ECS */
579 if (boot_cpu_data.x86 < 0x10) 579 if (boot_cpu_data.x86 < 0x10)
580 return 0; 580 return 0;
581 on_each_cpu(enable_pci_io_ecs_per_cpu, NULL, 1, 1); 581 on_each_cpu(enable_pci_io_ecs_per_cpu, NULL, 1);
582 pci_probe |= PCI_HAS_IO_ECS; 582 pci_probe |= PCI_HAS_IO_ECS;
583 return 0; 583 return 0;
584} 584}
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index dcd4e51f2f1..bb508456ef5 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1214,7 +1214,9 @@ static const struct smp_ops xen_smp_ops __initdata = {
1214 1214
1215 .smp_send_stop = xen_smp_send_stop, 1215 .smp_send_stop = xen_smp_send_stop,
1216 .smp_send_reschedule = xen_smp_send_reschedule, 1216 .smp_send_reschedule = xen_smp_send_reschedule,
1217 .smp_call_function_mask = xen_smp_call_function_mask, 1217
1218 .send_call_func_ipi = xen_smp_send_call_function_ipi,
1219 .send_call_func_single_ipi = xen_smp_send_call_function_single_ipi,
1218}; 1220};
1219#endif /* CONFIG_SMP */ 1221#endif /* CONFIG_SMP */
1220 1222
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 42b3b9ed641..ff0aa74afaa 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -796,7 +796,7 @@ static void drop_mm_ref(struct mm_struct *mm)
796 } 796 }
797 797
798 if (!cpus_empty(mask)) 798 if (!cpus_empty(mask))
799 xen_smp_call_function_mask(mask, drop_other_mm_ref, mm, 1); 799 smp_call_function_mask(mask, drop_other_mm_ref, mm, 1);
800} 800}
801#else 801#else
802static void drop_mm_ref(struct mm_struct *mm) 802static void drop_mm_ref(struct mm_struct *mm)
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index d2e3c20127d..233156f39b7 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -36,27 +36,14 @@
36#include "mmu.h" 36#include "mmu.h"
37 37
38cpumask_t xen_cpu_initialized_map; 38cpumask_t xen_cpu_initialized_map;
39static DEFINE_PER_CPU(int, resched_irq) = -1;
40static DEFINE_PER_CPU(int, callfunc_irq) = -1;
41static DEFINE_PER_CPU(int, debug_irq) = -1;
42
43/*
44 * Structure and data for smp_call_function(). This is designed to minimise
45 * static memory requirements. It also looks cleaner.
46 */
47static DEFINE_SPINLOCK(call_lock);
48 39
49struct call_data_struct { 40static DEFINE_PER_CPU(int, resched_irq);
50 void (*func) (void *info); 41static DEFINE_PER_CPU(int, callfunc_irq);
51 void *info; 42static DEFINE_PER_CPU(int, callfuncsingle_irq);
52 atomic_t started; 43static DEFINE_PER_CPU(int, debug_irq) = -1;
53 atomic_t finished;
54 int wait;
55};
56 44
57static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id); 45static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id);
58 46static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id);
59static struct call_data_struct *call_data;
60 47
61/* 48/*
62 * Reschedule call back. Nothing to do, 49 * Reschedule call back. Nothing to do,
@@ -128,6 +115,17 @@ static int xen_smp_intr_init(unsigned int cpu)
128 goto fail; 115 goto fail;
129 per_cpu(debug_irq, cpu) = rc; 116 per_cpu(debug_irq, cpu) = rc;
130 117
118 callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
119 rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
120 cpu,
121 xen_call_function_single_interrupt,
122 IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
123 callfunc_name,
124 NULL);
125 if (rc < 0)
126 goto fail;
127 per_cpu(callfuncsingle_irq, cpu) = rc;
128
131 return 0; 129 return 0;
132 130
133 fail: 131 fail:
@@ -137,6 +135,9 @@ static int xen_smp_intr_init(unsigned int cpu)
137 unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL); 135 unbind_from_irqhandler(per_cpu(callfunc_irq, cpu), NULL);
138 if (per_cpu(debug_irq, cpu) >= 0) 136 if (per_cpu(debug_irq, cpu) >= 0)
139 unbind_from_irqhandler(per_cpu(debug_irq, cpu), NULL); 137 unbind_from_irqhandler(per_cpu(debug_irq, cpu), NULL);
138 if (per_cpu(callfuncsingle_irq, cpu) >= 0)
139 unbind_from_irqhandler(per_cpu(callfuncsingle_irq, cpu), NULL);
140
140 return rc; 141 return rc;
141} 142}
142 143
@@ -336,7 +337,7 @@ static void stop_self(void *v)
336 337
337void xen_smp_send_stop(void) 338void xen_smp_send_stop(void)
338{ 339{
339 smp_call_function(stop_self, NULL, 0, 0); 340 smp_call_function(stop_self, NULL, 0);
340} 341}
341 342
342void xen_smp_send_reschedule(int cpu) 343void xen_smp_send_reschedule(int cpu)
@@ -344,7 +345,6 @@ void xen_smp_send_reschedule(int cpu)
344 xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR); 345 xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR);
345} 346}
346 347
347
348static void xen_send_IPI_mask(cpumask_t mask, enum ipi_vector vector) 348static void xen_send_IPI_mask(cpumask_t mask, enum ipi_vector vector)
349{ 349{
350 unsigned cpu; 350 unsigned cpu;
@@ -355,83 +355,42 @@ static void xen_send_IPI_mask(cpumask_t mask, enum ipi_vector vector)
355 xen_send_IPI_one(cpu, vector); 355 xen_send_IPI_one(cpu, vector);
356} 356}
357 357
358void xen_smp_send_call_function_ipi(cpumask_t mask)
359{
360 int cpu;
361
362 xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
363
364 /* Make sure other vcpus get a chance to run if they need to. */
365 for_each_cpu_mask(cpu, mask) {
366 if (xen_vcpu_stolen(cpu)) {
367 HYPERVISOR_sched_op(SCHEDOP_yield, 0);
368 break;
369 }
370 }
371}
372
373void xen_smp_send_call_function_single_ipi(int cpu)
374{
375 xen_send_IPI_mask(cpumask_of_cpu(cpu), XEN_CALL_FUNCTION_SINGLE_VECTOR);
376}
377
358static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id) 378static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)
359{ 379{
360 void (*func) (void *info) = call_data->func;
361 void *info = call_data->info;
362 int wait = call_data->wait;
363
364 /*
365 * Notify initiating CPU that I've grabbed the data and am
366 * about to execute the function
367 */
368 mb();
369 atomic_inc(&call_data->started);
370 /*
371 * At this point the info structure may be out of scope unless wait==1
372 */
373 irq_enter(); 380 irq_enter();
374 (*func)(info); 381 generic_smp_call_function_interrupt();
375 __get_cpu_var(irq_stat).irq_call_count++; 382 __get_cpu_var(irq_stat).irq_call_count++;
376 irq_exit(); 383 irq_exit();
377 384
378 if (wait) {
379 mb(); /* commit everything before setting finished */
380 atomic_inc(&call_data->finished);
381 }
382
383 return IRQ_HANDLED; 385 return IRQ_HANDLED;
384} 386}
385 387
386int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *), 388static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id)
387 void *info, int wait)
388{ 389{
389 struct call_data_struct data; 390 irq_enter();
390 int cpus, cpu; 391 generic_smp_call_function_single_interrupt();
391 bool yield; 392 __get_cpu_var(irq_stat).irq_call_count++;
392 393 irq_exit();
393 /* Holding any lock stops cpus from going down. */
394 spin_lock(&call_lock);
395
396 cpu_clear(smp_processor_id(), mask);
397
398 cpus = cpus_weight(mask);
399 if (!cpus) {
400 spin_unlock(&call_lock);
401 return 0;
402 }
403
404 /* Can deadlock when called with interrupts disabled */
405 WARN_ON(irqs_disabled());
406
407 data.func = func;
408 data.info = info;
409 atomic_set(&data.started, 0);
410 data.wait = wait;
411 if (wait)
412 atomic_set(&data.finished, 0);
413
414 call_data = &data;
415 mb(); /* write everything before IPI */
416
417 /* Send a message to other CPUs and wait for them to respond */
418 xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
419
420 /* Make sure other vcpus get a chance to run if they need to. */
421 yield = false;
422 for_each_cpu_mask(cpu, mask)
423 if (xen_vcpu_stolen(cpu))
424 yield = true;
425
426 if (yield)
427 HYPERVISOR_sched_op(SCHEDOP_yield, 0);
428
429 /* Wait for response */
430 while (atomic_read(&data.started) != cpus ||
431 (wait && atomic_read(&data.finished) != cpus))
432 cpu_relax();
433
434 spin_unlock(&call_lock);
435 394
436 return 0; 395 return IRQ_HANDLED;
437} 396}
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index d852ddbb344..6f4b1045c1c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -55,13 +55,8 @@ void xen_smp_cpus_done(unsigned int max_cpus);
55 55
56void xen_smp_send_stop(void); 56void xen_smp_send_stop(void);
57void xen_smp_send_reschedule(int cpu); 57void xen_smp_send_reschedule(int cpu);
58int xen_smp_call_function (void (*func) (void *info), void *info, int nonatomic, 58void xen_smp_send_call_function_ipi(cpumask_t mask);
59 int wait); 59void xen_smp_send_call_function_single_ipi(int cpu);
60int xen_smp_call_function_single(int cpu, void (*func) (void *info), void *info,
61 int nonatomic, int wait);
62
63int xen_smp_call_function_mask(cpumask_t mask, void (*func)(void *),
64 void *info, int wait);
65 60
66extern cpumask_t xen_cpu_initialized_map; 61extern cpumask_t xen_cpu_initialized_map;
67 62
diff --git a/block/blk-core.c b/block/blk-core.c
index c6e536597c8..fef79ccb2a1 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1042,15 +1042,9 @@ void blk_put_request(struct request *req)
1042 unsigned long flags; 1042 unsigned long flags;
1043 struct request_queue *q = req->q; 1043 struct request_queue *q = req->q;
1044 1044
1045 /* 1045 spin_lock_irqsave(q->queue_lock, flags);
1046 * Gee, IDE calls in w/ NULL q. Fix IDE and remove the 1046 __blk_put_request(q, req);
1047 * following if (q) test. 1047 spin_unlock_irqrestore(q->queue_lock, flags);
1048 */
1049 if (q) {
1050 spin_lock_irqsave(q->queue_lock, flags);
1051 __blk_put_request(q, req);
1052 spin_unlock_irqrestore(q->queue_lock, flags);
1053 }
1054} 1048}
1055EXPORT_SYMBOL(blk_put_request); 1049EXPORT_SYMBOL(blk_put_request);
1056 1050
diff --git a/block/blk-exec.c b/block/blk-exec.c
index 391dd622489..9bceff7674f 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -18,7 +18,7 @@
18 * @rq: request to complete 18 * @rq: request to complete
19 * @error: end io status of the request 19 * @error: end io status of the request
20 */ 20 */
21void blk_end_sync_rq(struct request *rq, int error) 21static void blk_end_sync_rq(struct request *rq, int error)
22{ 22{
23 struct completion *waiting = rq->end_io_data; 23 struct completion *waiting = rq->end_io_data;
24 24
@@ -31,7 +31,6 @@ void blk_end_sync_rq(struct request *rq, int error)
31 */ 31 */
32 complete(waiting); 32 complete(waiting);
33} 33}
34EXPORT_SYMBOL(blk_end_sync_rq);
35 34
36/** 35/**
37 * blk_execute_rq_nowait - insert a request into queue for execution 36 * blk_execute_rq_nowait - insert a request into queue for execution
@@ -58,6 +57,9 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
58 spin_lock_irq(q->queue_lock); 57 spin_lock_irq(q->queue_lock);
59 __elv_add_request(q, rq, where, 1); 58 __elv_add_request(q, rq, where, 1);
60 __generic_unplug_device(q); 59 __generic_unplug_device(q);
60 /* the queue is stopped so it won't be plugged+unplugged */
61 if (blk_pm_resume_request(rq))
62 q->request_fn(q);
61 spin_unlock_irq(q->queue_lock); 63 spin_unlock_irq(q->queue_lock);
62} 64}
63EXPORT_SYMBOL_GPL(blk_execute_rq_nowait); 65EXPORT_SYMBOL_GPL(blk_execute_rq_nowait);
diff --git a/crypto/async_tx/async_tx.c b/crypto/async_tx/async_tx.c
index c6e772fc5cc..095c798d317 100644
--- a/crypto/async_tx/async_tx.c
+++ b/crypto/async_tx/async_tx.c
@@ -23,6 +23,7 @@
23 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
24 * 24 *
25 */ 25 */
26#include <linux/rculist.h>
26#include <linux/kernel.h> 27#include <linux/kernel.h>
27#include <linux/async_tx.h> 28#include <linux/async_tx.h>
28 29
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 556ee158519..4976e5db2b3 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -1339,7 +1339,7 @@ static void smp_callback(void *v)
1339static int acpi_processor_latency_notify(struct notifier_block *b, 1339static int acpi_processor_latency_notify(struct notifier_block *b,
1340 unsigned long l, void *v) 1340 unsigned long l, void *v)
1341{ 1341{
1342 smp_call_function(smp_callback, NULL, 0, 1); 1342 smp_call_function(smp_callback, NULL, 1);
1343 return NOTIFY_OK; 1343 return NOTIFY_OK;
1344} 1344}
1345 1345
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 5e6468a7ca4..dc7596f028b 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -56,6 +56,12 @@ MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)
56static int ahci_enable_alpm(struct ata_port *ap, 56static int ahci_enable_alpm(struct ata_port *ap,
57 enum link_pm policy); 57 enum link_pm policy);
58static void ahci_disable_alpm(struct ata_port *ap); 58static void ahci_disable_alpm(struct ata_port *ap);
59static ssize_t ahci_led_show(struct ata_port *ap, char *buf);
60static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
61 size_t size);
62static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
63 ssize_t size);
64#define MAX_SLOTS 8
59 65
60enum { 66enum {
61 AHCI_PCI_BAR = 5, 67 AHCI_PCI_BAR = 5,
@@ -98,6 +104,8 @@ enum {
98 HOST_IRQ_STAT = 0x08, /* interrupt status */ 104 HOST_IRQ_STAT = 0x08, /* interrupt status */
99 HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */ 105 HOST_PORTS_IMPL = 0x0c, /* bitmap of implemented ports */
100 HOST_VERSION = 0x10, /* AHCI spec. version compliancy */ 106 HOST_VERSION = 0x10, /* AHCI spec. version compliancy */
107 HOST_EM_LOC = 0x1c, /* Enclosure Management location */
108 HOST_EM_CTL = 0x20, /* Enclosure Management Control */
101 109
102 /* HOST_CTL bits */ 110 /* HOST_CTL bits */
103 HOST_RESET = (1 << 0), /* reset controller; self-clear */ 111 HOST_RESET = (1 << 0), /* reset controller; self-clear */
@@ -105,6 +113,7 @@ enum {
105 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */ 113 HOST_AHCI_EN = (1 << 31), /* AHCI enabled */
106 114
107 /* HOST_CAP bits */ 115 /* HOST_CAP bits */
116 HOST_CAP_EMS = (1 << 6), /* Enclosure Management support */
108 HOST_CAP_SSC = (1 << 14), /* Slumber capable */ 117 HOST_CAP_SSC = (1 << 14), /* Slumber capable */
109 HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */ 118 HOST_CAP_PMP = (1 << 17), /* Port Multiplier support */
110 HOST_CAP_CLO = (1 << 24), /* Command List Override support */ 119 HOST_CAP_CLO = (1 << 24), /* Command List Override support */
@@ -202,6 +211,11 @@ enum {
202 ATA_FLAG_IPM, 211 ATA_FLAG_IPM,
203 212
204 ICH_MAP = 0x90, /* ICH MAP register */ 213 ICH_MAP = 0x90, /* ICH MAP register */
214
215 /* em_ctl bits */
216 EM_CTL_RST = (1 << 9), /* Reset */
217 EM_CTL_TM = (1 << 8), /* Transmit Message */
218 EM_CTL_ALHD = (1 << 26), /* Activity LED */
205}; 219};
206 220
207struct ahci_cmd_hdr { 221struct ahci_cmd_hdr {
@@ -219,12 +233,21 @@ struct ahci_sg {
219 __le32 flags_size; 233 __le32 flags_size;
220}; 234};
221 235
236struct ahci_em_priv {
237 enum sw_activity blink_policy;
238 struct timer_list timer;
239 unsigned long saved_activity;
240 unsigned long activity;
241 unsigned long led_state;
242};
243
222struct ahci_host_priv { 244struct ahci_host_priv {
223 unsigned int flags; /* AHCI_HFLAG_* */ 245 unsigned int flags; /* AHCI_HFLAG_* */
224 u32 cap; /* cap to use */ 246 u32 cap; /* cap to use */
225 u32 port_map; /* port map to use */ 247 u32 port_map; /* port map to use */
226 u32 saved_cap; /* saved initial cap */ 248 u32 saved_cap; /* saved initial cap */
227 u32 saved_port_map; /* saved initial port_map */ 249 u32 saved_port_map; /* saved initial port_map */
250 u32 em_loc; /* enclosure management location */
228}; 251};
229 252
230struct ahci_port_priv { 253struct ahci_port_priv {
@@ -240,6 +263,8 @@ struct ahci_port_priv {
240 unsigned int ncq_saw_dmas:1; 263 unsigned int ncq_saw_dmas:1;
241 unsigned int ncq_saw_sdb:1; 264 unsigned int ncq_saw_sdb:1;
242 u32 intr_mask; /* interrupts to enable */ 265 u32 intr_mask; /* interrupts to enable */
266 struct ahci_em_priv em_priv[MAX_SLOTS];/* enclosure management info
267 * per PM slot */
243}; 268};
244 269
245static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val); 270static int ahci_scr_read(struct ata_port *ap, unsigned int sc_reg, u32 *val);
@@ -277,9 +302,20 @@ static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg);
277static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg); 302static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
278static int ahci_pci_device_resume(struct pci_dev *pdev); 303static int ahci_pci_device_resume(struct pci_dev *pdev);
279#endif 304#endif
305static ssize_t ahci_activity_show(struct ata_device *dev, char *buf);
306static ssize_t ahci_activity_store(struct ata_device *dev,
307 enum sw_activity val);
308static void ahci_init_sw_activity(struct ata_link *link);
280 309
281static struct device_attribute *ahci_shost_attrs[] = { 310static struct device_attribute *ahci_shost_attrs[] = {
282 &dev_attr_link_power_management_policy, 311 &dev_attr_link_power_management_policy,
312 &dev_attr_em_message_type,
313 &dev_attr_em_message,
314 NULL
315};
316
317static struct device_attribute *ahci_sdev_attrs[] = {
318 &dev_attr_sw_activity,
283 NULL 319 NULL
284}; 320};
285 321
@@ -289,6 +325,7 @@ static struct scsi_host_template ahci_sht = {
289 .sg_tablesize = AHCI_MAX_SG, 325 .sg_tablesize = AHCI_MAX_SG,
290 .dma_boundary = AHCI_DMA_BOUNDARY, 326 .dma_boundary = AHCI_DMA_BOUNDARY,
291 .shost_attrs = ahci_shost_attrs, 327 .shost_attrs = ahci_shost_attrs,
328 .sdev_attrs = ahci_sdev_attrs,
292}; 329};
293 330
294static struct ata_port_operations ahci_ops = { 331static struct ata_port_operations ahci_ops = {
@@ -316,6 +353,10 @@ static struct ata_port_operations ahci_ops = {
316 353
317 .enable_pm = ahci_enable_alpm, 354 .enable_pm = ahci_enable_alpm,
318 .disable_pm = ahci_disable_alpm, 355 .disable_pm = ahci_disable_alpm,
356 .em_show = ahci_led_show,
357 .em_store = ahci_led_store,
358 .sw_activity_show = ahci_activity_show,
359 .sw_activity_store = ahci_activity_store,
319#ifdef CONFIG_PM 360#ifdef CONFIG_PM
320 .port_suspend = ahci_port_suspend, 361 .port_suspend = ahci_port_suspend,
321 .port_resume = ahci_port_resume, 362 .port_resume = ahci_port_resume,
@@ -561,6 +602,11 @@ static struct pci_driver ahci_pci_driver = {
561#endif 602#endif
562}; 603};
563 604
605static int ahci_em_messages = 1;
606module_param(ahci_em_messages, int, 0444);
607/* add other LED protocol types when they become supported */
608MODULE_PARM_DESC(ahci_em_messages,
609 "Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED");
564 610
565static inline int ahci_nr_ports(u32 cap) 611static inline int ahci_nr_ports(u32 cap)
566{ 612{
@@ -1031,11 +1077,28 @@ static void ahci_power_down(struct ata_port *ap)
1031 1077
1032static void ahci_start_port(struct ata_port *ap) 1078static void ahci_start_port(struct ata_port *ap)
1033{ 1079{
1080 struct ahci_port_priv *pp = ap->private_data;
1081 struct ata_link *link;
1082 struct ahci_em_priv *emp;
1083
1034 /* enable FIS reception */ 1084 /* enable FIS reception */
1035 ahci_start_fis_rx(ap); 1085 ahci_start_fis_rx(ap);
1036 1086
1037 /* enable DMA */ 1087 /* enable DMA */
1038 ahci_start_engine(ap); 1088 ahci_start_engine(ap);
1089
1090 /* turn on LEDs */
1091 if (ap->flags & ATA_FLAG_EM) {
1092 ata_port_for_each_link(link, ap) {
1093 emp = &pp->em_priv[link->pmp];
1094 ahci_transmit_led_message(ap, emp->led_state, 4);
1095 }
1096 }
1097
1098 if (ap->flags & ATA_FLAG_SW_ACTIVITY)
1099 ata_port_for_each_link(link, ap)
1100 ahci_init_sw_activity(link);
1101
1039} 1102}
1040 1103
1041static int ahci_deinit_port(struct ata_port *ap, const char **emsg) 1104static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
@@ -1079,12 +1142,15 @@ static int ahci_reset_controller(struct ata_host *host)
1079 readl(mmio + HOST_CTL); /* flush */ 1142 readl(mmio + HOST_CTL); /* flush */
1080 } 1143 }
1081 1144
1082 /* reset must complete within 1 second, or 1145 /*
1146 * to perform host reset, OS should set HOST_RESET
1147 * and poll until this bit is read to be "0".
1148 * reset must complete within 1 second, or
1083 * the hardware should be considered fried. 1149 * the hardware should be considered fried.
1084 */ 1150 */
1085 ssleep(1); 1151 tmp = ata_wait_register(mmio + HOST_CTL, HOST_RESET,
1152 HOST_RESET, 10, 1000);
1086 1153
1087 tmp = readl(mmio + HOST_CTL);
1088 if (tmp & HOST_RESET) { 1154 if (tmp & HOST_RESET) {
1089 dev_printk(KERN_ERR, host->dev, 1155 dev_printk(KERN_ERR, host->dev,
1090 "controller reset failed (0x%x)\n", tmp); 1156 "controller reset failed (0x%x)\n", tmp);
@@ -1116,6 +1182,230 @@ static int ahci_reset_controller(struct ata_host *host)
1116 return 0; 1182 return 0;
1117} 1183}
1118 1184
1185static void ahci_sw_activity(struct ata_link *link)
1186{
1187 struct ata_port *ap = link->ap;
1188 struct ahci_port_priv *pp = ap->private_data;
1189 struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
1190
1191 if (!(link->flags & ATA_LFLAG_SW_ACTIVITY))
1192 return;
1193
1194 emp->activity++;
1195 if (!timer_pending(&emp->timer))
1196 mod_timer(&emp->timer, jiffies + msecs_to_jiffies(10));
1197}
1198
1199static void ahci_sw_activity_blink(unsigned long arg)
1200{
1201 struct ata_link *link = (struct ata_link *)arg;
1202 struct ata_port *ap = link->ap;
1203 struct ahci_port_priv *pp = ap->private_data;
1204 struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
1205 unsigned long led_message = emp->led_state;
1206 u32 activity_led_state;
1207
1208 led_message &= 0xffff0000;
1209 led_message |= ap->port_no | (link->pmp << 8);
1210
1211 /* check to see if we've had activity. If so,
1212 * toggle state of LED and reset timer. If not,
1213 * turn LED to desired idle state.
1214 */
1215 if (emp->saved_activity != emp->activity) {
1216 emp->saved_activity = emp->activity;
1217 /* get the current LED state */
1218 activity_led_state = led_message & 0x00010000;
1219
1220 if (activity_led_state)
1221 activity_led_state = 0;
1222 else
1223 activity_led_state = 1;
1224
1225 /* clear old state */
1226 led_message &= 0xfff8ffff;
1227
1228 /* toggle state */
1229 led_message |= (activity_led_state << 16);
1230 mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100));
1231 } else {
1232 /* switch to idle */
1233 led_message &= 0xfff8ffff;
1234 if (emp->blink_policy == BLINK_OFF)
1235 led_message |= (1 << 16);
1236 }
1237 ahci_transmit_led_message(ap, led_message, 4);
1238}
1239
1240static void ahci_init_sw_activity(struct ata_link *link)
1241{
1242 struct ata_port *ap = link->ap;
1243 struct ahci_port_priv *pp = ap->private_data;
1244 struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
1245
1246 /* init activity stats, setup timer */
1247 emp->saved_activity = emp->activity = 0;
1248 setup_timer(&emp->timer, ahci_sw_activity_blink, (unsigned long)link);
1249
1250 /* check our blink policy and set flag for link if it's enabled */
1251 if (emp->blink_policy)
1252 link->flags |= ATA_LFLAG_SW_ACTIVITY;
1253}
1254
1255static int ahci_reset_em(struct ata_host *host)
1256{
1257 void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
1258 u32 em_ctl;
1259
1260 em_ctl = readl(mmio + HOST_EM_CTL);
1261 if ((em_ctl & EM_CTL_TM) || (em_ctl & EM_CTL_RST))
1262 return -EINVAL;
1263
1264 writel(em_ctl | EM_CTL_RST, mmio + HOST_EM_CTL);
1265 return 0;
1266}
1267
1268static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
1269 ssize_t size)
1270{
1271 struct ahci_host_priv *hpriv = ap->host->private_data;
1272 struct ahci_port_priv *pp = ap->private_data;
1273 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
1274 u32 em_ctl;
1275 u32 message[] = {0, 0};
1276 unsigned int flags;
1277 int pmp;
1278 struct ahci_em_priv *emp;
1279
1280 /* get the slot number from the message */
1281 pmp = (state & 0x0000ff00) >> 8;
1282 if (pmp < MAX_SLOTS)
1283 emp = &pp->em_priv[pmp];
1284 else
1285 return -EINVAL;
1286
1287 spin_lock_irqsave(ap->lock, flags);
1288
1289 /*
1290 * if we are still busy transmitting a previous message,
1291 * do not allow
1292 */
1293 em_ctl = readl(mmio + HOST_EM_CTL);
1294 if (em_ctl & EM_CTL_TM) {
1295 spin_unlock_irqrestore(ap->lock, flags);
1296 return -EINVAL;
1297 }
1298
1299 /*
1300 * create message header - this is all zero except for
1301 * the message size, which is 4 bytes.
1302 */
1303 message[0] |= (4 << 8);
1304
1305 /* ignore 0:4 of byte zero, fill in port info yourself */
1306 message[1] = ((state & 0xfffffff0) | ap->port_no);
1307
1308 /* write message to EM_LOC */
1309 writel(message[0], mmio + hpriv->em_loc);
1310 writel(message[1], mmio + hpriv->em_loc+4);
1311
1312 /* save off new led state for port/slot */
1313 emp->led_state = message[1];
1314
1315 /*
1316 * tell hardware to transmit the message
1317 */
1318 writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
1319
1320 spin_unlock_irqrestore(ap->lock, flags);
1321 return size;
1322}
1323
1324static ssize_t ahci_led_show(struct ata_port *ap, char *buf)
1325{
1326 struct ahci_port_priv *pp = ap->private_data;
1327 struct ata_link *link;
1328 struct ahci_em_priv *emp;
1329 int rc = 0;
1330
1331 ata_port_for_each_link(link, ap) {
1332 emp = &pp->em_priv[link->pmp];
1333 rc += sprintf(buf, "%lx\n", emp->led_state);
1334 }
1335 return rc;
1336}
1337
1338static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
1339 size_t size)
1340{
1341 int state;
1342 int pmp;
1343 struct ahci_port_priv *pp = ap->private_data;
1344 struct ahci_em_priv *emp;
1345
1346 state = simple_strtoul(buf, NULL, 0);
1347
1348 /* get the slot number from the message */
1349 pmp = (state & 0x0000ff00) >> 8;
1350 if (pmp < MAX_SLOTS)
1351 emp = &pp->em_priv[pmp];
1352 else
1353 return -EINVAL;
1354
1355 /* mask off the activity bits if we are in sw_activity
1356 * mode, user should turn off sw_activity before setting
1357 * activity led through em_message
1358 */
1359 if (emp->blink_policy)
1360 state &= 0xfff8ffff;
1361
1362 return ahci_transmit_led_message(ap, state, size);
1363}
1364
1365static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
1366{
1367 struct ata_link *link = dev->link;
1368 struct ata_port *ap = link->ap;
1369 struct ahci_port_priv *pp = ap->private_data;
1370 struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
1371 u32 port_led_state = emp->led_state;
1372
1373 /* save the desired Activity LED behavior */
1374 if (val == OFF) {
1375 /* clear LFLAG */
1376 link->flags &= ~(ATA_LFLAG_SW_ACTIVITY);
1377
1378 /* set the LED to OFF */
1379 port_led_state &= 0xfff80000;
1380 port_led_state |= (ap->port_no | (link->pmp << 8));
1381 ahci_transmit_led_message(ap, port_led_state, 4);
1382 } else {
1383 link->flags |= ATA_LFLAG_SW_ACTIVITY;
1384 if (val == BLINK_OFF) {
1385 /* set LED to ON for idle */
1386 port_led_state &= 0xfff80000;
1387 port_led_state |= (ap->port_no | (link->pmp << 8));
1388 port_led_state |= 0x00010000; /* check this */
1389 ahci_transmit_led_message(ap, port_led_state, 4);
1390 }
1391 }
1392 emp->blink_policy = val;
1393 return 0;
1394}
1395
1396static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
1397{
1398 struct ata_link *link = dev->link;
1399 struct ata_port *ap = link->ap;
1400 struct ahci_port_priv *pp = ap->private_data;
1401 struct ahci_em_priv *emp = &pp->em_priv[link->pmp];
1402
1403 /* display the saved value of activity behavior for this
1404 * disk.
1405 */
1406 return sprintf(buf, "%d\n", emp->blink_policy);
1407}
1408
1119static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap, 1409static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap,
1120 int port_no, void __iomem *mmio, 1410 int port_no, void __iomem *mmio,
1121 void __iomem *port_mmio) 1411 void __iomem *port_mmio)
@@ -1846,7 +2136,8 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
1846 if (qc->tf.protocol == ATA_PROT_NCQ) 2136 if (qc->tf.protocol == ATA_PROT_NCQ)
1847 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT); 2137 writel(1 << qc->tag, port_mmio + PORT_SCR_ACT);
1848 writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE); 2138 writel(1 << qc->tag, port_mmio + PORT_CMD_ISSUE);
1849 readl(port_mmio + PORT_CMD_ISSUE); /* flush */ 2139
2140 ahci_sw_activity(qc->dev->link);
1850 2141
1851 return 0; 2142 return 0;
1852} 2143}
@@ -2154,7 +2445,8 @@ static void ahci_print_info(struct ata_host *host)
2154 dev_printk(KERN_INFO, &pdev->dev, 2445 dev_printk(KERN_INFO, &pdev->dev,
2155 "flags: " 2446 "flags: "
2156 "%s%s%s%s%s%s%s" 2447 "%s%s%s%s%s%s%s"
2157 "%s%s%s%s%s%s%s\n" 2448 "%s%s%s%s%s%s%s"
2449 "%s\n"
2158 , 2450 ,
2159 2451
2160 cap & (1 << 31) ? "64bit " : "", 2452 cap & (1 << 31) ? "64bit " : "",
@@ -2171,7 +2463,8 @@ static void ahci_print_info(struct ata_host *host)
2171 cap & (1 << 17) ? "pmp " : "", 2463 cap & (1 << 17) ? "pmp " : "",
2172 cap & (1 << 15) ? "pio " : "", 2464 cap & (1 << 15) ? "pio " : "",
2173 cap & (1 << 14) ? "slum " : "", 2465 cap & (1 << 14) ? "slum " : "",
2174 cap & (1 << 13) ? "part " : "" 2466 cap & (1 << 13) ? "part " : "",
2467 cap & (1 << 6) ? "ems ": ""
2175 ); 2468 );
2176} 2469}
2177 2470
@@ -2291,6 +2584,24 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2291 if (hpriv->cap & HOST_CAP_PMP) 2584 if (hpriv->cap & HOST_CAP_PMP)
2292 pi.flags |= ATA_FLAG_PMP; 2585 pi.flags |= ATA_FLAG_PMP;
2293 2586
2587 if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
2588 u8 messages;
2589 void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
2590 u32 em_loc = readl(mmio + HOST_EM_LOC);
2591 u32 em_ctl = readl(mmio + HOST_EM_CTL);
2592
2593 messages = (em_ctl & 0x000f0000) >> 16;
2594
2595 /* we only support LED message type right now */
2596 if ((messages & 0x01) && (ahci_em_messages == 1)) {
2597 /* store em_loc */
2598 hpriv->em_loc = ((em_loc >> 16) * 4);
2599 pi.flags |= ATA_FLAG_EM;
2600 if (!(em_ctl & EM_CTL_ALHD))
2601 pi.flags |= ATA_FLAG_SW_ACTIVITY;
2602 }
2603 }
2604
2294 /* CAP.NP sometimes indicate the index of the last enabled 2605 /* CAP.NP sometimes indicate the index of the last enabled
2295 * port, at other times, that of the last possible port, so 2606 * port, at other times, that of the last possible port, so
2296 * determining the maximum port number requires looking at 2607 * determining the maximum port number requires looking at
@@ -2304,6 +2615,9 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2304 host->iomap = pcim_iomap_table(pdev); 2615 host->iomap = pcim_iomap_table(pdev);
2305 host->private_data = hpriv; 2616 host->private_data = hpriv;
2306 2617
2618 if (pi.flags & ATA_FLAG_EM)
2619 ahci_reset_em(host);
2620
2307 for (i = 0; i < host->n_ports; i++) { 2621 for (i = 0; i < host->n_ports; i++) {
2308 struct ata_port *ap = host->ports[i]; 2622 struct ata_port *ap = host->ports[i];
2309 2623
@@ -2314,6 +2628,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2314 /* set initial link pm policy */ 2628 /* set initial link pm policy */
2315 ap->pm_policy = NOT_AVAILABLE; 2629 ap->pm_policy = NOT_AVAILABLE;
2316 2630
2631 /* set enclosure management message type */
2632 if (ap->flags & ATA_FLAG_EM)
2633 ap->em_message_type = ahci_em_messages;
2634
2635
2317 /* disabled/not-implemented port */ 2636 /* disabled/not-implemented port */
2318 if (!(hpriv->port_map & (1 << i))) 2637 if (!(hpriv->port_map & (1 << i)))
2319 ap->ops = &ata_dummy_port_ops; 2638 ap->ops = &ata_dummy_port_ops;
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 303fc0d2b97..9bef1a84fe3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -54,7 +54,6 @@
54#include <linux/completion.h> 54#include <linux/completion.h>
55#include <linux/suspend.h> 55#include <linux/suspend.h>
56#include <linux/workqueue.h> 56#include <linux/workqueue.h>
57#include <linux/jiffies.h>
58#include <linux/scatterlist.h> 57#include <linux/scatterlist.h>
59#include <linux/io.h> 58#include <linux/io.h>
60#include <scsi/scsi.h> 59#include <scsi/scsi.h>
@@ -145,7 +144,7 @@ static int libata_dma_mask = ATA_DMA_MASK_ATA|ATA_DMA_MASK_ATAPI|ATA_DMA_MASK_CF
145module_param_named(dma, libata_dma_mask, int, 0444); 144module_param_named(dma, libata_dma_mask, int, 0444);
146MODULE_PARM_DESC(dma, "DMA enable/disable (0x1==ATA, 0x2==ATAPI, 0x4==CF)"); 145MODULE_PARM_DESC(dma, "DMA enable/disable (0x1==ATA, 0x2==ATAPI, 0x4==CF)");
147 146
148static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ; 147static int ata_probe_timeout;
149module_param(ata_probe_timeout, int, 0444); 148module_param(ata_probe_timeout, int, 0444);
150MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)"); 149MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
151 150
@@ -1533,7 +1532,7 @@ unsigned long ata_id_xfermask(const u16 *id)
1533 * @ap: The ata_port to queue port_task for 1532 * @ap: The ata_port to queue port_task for
1534 * @fn: workqueue function to be scheduled 1533 * @fn: workqueue function to be scheduled
1535 * @data: data for @fn to use 1534 * @data: data for @fn to use
1536 * @delay: delay time for workqueue function 1535 * @delay: delay time in msecs for workqueue function
1537 * 1536 *
1538 * Schedule @fn(@data) for execution after @delay jiffies using 1537 * Schedule @fn(@data) for execution after @delay jiffies using
1539 * port_task. There is one port_task per port and it's the 1538 * port_task. There is one port_task per port and it's the
@@ -1552,7 +1551,7 @@ void ata_pio_queue_task(struct ata_port *ap, void *data, unsigned long delay)
1552 ap->port_task_data = data; 1551 ap->port_task_data = data;
1553 1552
1554 /* may fail if ata_port_flush_task() in progress */ 1553 /* may fail if ata_port_flush_task() in progress */
1555 queue_delayed_work(ata_wq, &ap->port_task, delay); 1554 queue_delayed_work(ata_wq, &ap->port_task, msecs_to_jiffies(delay));
1556} 1555}
1557 1556
1558/** 1557/**
@@ -1612,6 +1611,7 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1612 struct ata_link *link = dev->link; 1611 struct ata_link *link = dev->link;
1613 struct ata_port *ap = link->ap; 1612 struct ata_port *ap = link->ap;
1614 u8 command = tf->command; 1613 u8 command = tf->command;
1614 int auto_timeout = 0;
1615 struct ata_queued_cmd *qc; 1615 struct ata_queued_cmd *qc;
1616 unsigned int tag, preempted_tag; 1616 unsigned int tag, preempted_tag;
1617 u32 preempted_sactive, preempted_qc_active; 1617 u32 preempted_sactive, preempted_qc_active;
@@ -1684,8 +1684,14 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1684 1684
1685 spin_unlock_irqrestore(ap->lock, flags); 1685 spin_unlock_irqrestore(ap->lock, flags);
1686 1686
1687 if (!timeout) 1687 if (!timeout) {
1688 timeout = ata_probe_timeout * 1000 / HZ; 1688 if (ata_probe_timeout)
1689 timeout = ata_probe_timeout * 1000;
1690 else {
1691 timeout = ata_internal_cmd_timeout(dev, command);
1692 auto_timeout = 1;
1693 }
1694 }
1689 1695
1690 rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout)); 1696 rc = wait_for_completion_timeout(&wait, msecs_to_jiffies(timeout));
1691 1697
@@ -1761,6 +1767,9 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1761 1767
1762 spin_unlock_irqrestore(ap->lock, flags); 1768 spin_unlock_irqrestore(ap->lock, flags);
1763 1769
1770 if ((err_mask & AC_ERR_TIMEOUT) && auto_timeout)
1771 ata_internal_cmd_timed_out(dev, command);
1772
1764 return err_mask; 1773 return err_mask;
1765} 1774}
1766 1775
@@ -3319,7 +3328,7 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline,
3319 int (*check_ready)(struct ata_link *link)) 3328 int (*check_ready)(struct ata_link *link))
3320{ 3329{
3321 unsigned long start = jiffies; 3330 unsigned long start = jiffies;
3322 unsigned long nodev_deadline = start + ATA_TMOUT_FF_WAIT; 3331 unsigned long nodev_deadline = ata_deadline(start, ATA_TMOUT_FF_WAIT);
3323 int warned = 0; 3332 int warned = 0;
3324 3333
3325 if (time_after(nodev_deadline, deadline)) 3334 if (time_after(nodev_deadline, deadline))
@@ -3387,7 +3396,7 @@ int ata_wait_ready(struct ata_link *link, unsigned long deadline,
3387int ata_wait_after_reset(struct ata_link *link, unsigned long deadline, 3396int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
3388 int (*check_ready)(struct ata_link *link)) 3397 int (*check_ready)(struct ata_link *link))
3389{ 3398{
3390 msleep(ATA_WAIT_AFTER_RESET_MSECS); 3399 msleep(ATA_WAIT_AFTER_RESET);
3391 3400
3392 return ata_wait_ready(link, deadline, check_ready); 3401 return ata_wait_ready(link, deadline, check_ready);
3393} 3402}
@@ -3417,13 +3426,13 @@ int ata_wait_after_reset(struct ata_link *link, unsigned long deadline,
3417int sata_link_debounce(struct ata_link *link, const unsigned long *params, 3426int sata_link_debounce(struct ata_link *link, const unsigned long *params,
3418 unsigned long deadline) 3427 unsigned long deadline)
3419{ 3428{
3420 unsigned long interval_msec = params[0]; 3429 unsigned long interval = params[0];
3421 unsigned long duration = msecs_to_jiffies(params[1]); 3430 unsigned long duration = params[1];
3422 unsigned long last_jiffies, t; 3431 unsigned long last_jiffies, t;
3423 u32 last, cur; 3432 u32 last, cur;
3424 int rc; 3433 int rc;
3425 3434
3426 t = jiffies + msecs_to_jiffies(params[2]); 3435 t = ata_deadline(jiffies, params[2]);
3427 if (time_before(t, deadline)) 3436 if (time_before(t, deadline))
3428 deadline = t; 3437 deadline = t;
3429 3438
@@ -3435,7 +3444,7 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
3435 last_jiffies = jiffies; 3444 last_jiffies = jiffies;
3436 3445
3437 while (1) { 3446 while (1) {
3438 msleep(interval_msec); 3447 msleep(interval);
3439 if ((rc = sata_scr_read(link, SCR_STATUS, &cur))) 3448 if ((rc = sata_scr_read(link, SCR_STATUS, &cur)))
3440 return rc; 3449 return rc;
3441 cur &= 0xf; 3450 cur &= 0xf;
@@ -3444,7 +3453,8 @@ int sata_link_debounce(struct ata_link *link, const unsigned long *params,
3444 if (cur == last) { 3453 if (cur == last) {
3445 if (cur == 1 && time_before(jiffies, deadline)) 3454 if (cur == 1 && time_before(jiffies, deadline))
3446 continue; 3455 continue;
3447 if (time_after(jiffies, last_jiffies + duration)) 3456 if (time_after(jiffies,
3457 ata_deadline(last_jiffies, duration)))
3448 return 0; 3458 return 0;
3449 continue; 3459 continue;
3450 } 3460 }
@@ -3636,7 +3646,8 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
3636 if (check_ready) { 3646 if (check_ready) {
3637 unsigned long pmp_deadline; 3647 unsigned long pmp_deadline;
3638 3648
3639 pmp_deadline = jiffies + ATA_TMOUT_PMP_SRST_WAIT; 3649 pmp_deadline = ata_deadline(jiffies,
3650 ATA_TMOUT_PMP_SRST_WAIT);
3640 if (time_after(pmp_deadline, deadline)) 3651 if (time_after(pmp_deadline, deadline))
3641 pmp_deadline = deadline; 3652 pmp_deadline = deadline;
3642 ata_wait_ready(link, pmp_deadline, check_ready); 3653 ata_wait_ready(link, pmp_deadline, check_ready);
@@ -6073,8 +6084,6 @@ static void __init ata_parse_force_param(void)
6073 6084
6074static int __init ata_init(void) 6085static int __init ata_init(void)
6075{ 6086{
6076 ata_probe_timeout *= HZ;
6077
6078 ata_parse_force_param(); 6087 ata_parse_force_param();
6079 6088
6080 ata_wq = create_workqueue("ata"); 6089 ata_wq = create_workqueue("ata");
@@ -6127,8 +6136,8 @@ int ata_ratelimit(void)
6127 * @reg: IO-mapped register 6136 * @reg: IO-mapped register
6128 * @mask: Mask to apply to read register value 6137 * @mask: Mask to apply to read register value
6129 * @val: Wait condition 6138 * @val: Wait condition
6130 * @interval_msec: polling interval in milliseconds 6139 * @interval: polling interval in milliseconds
6131 * @timeout_msec: timeout in milliseconds 6140 * @timeout: timeout in milliseconds
6132 * 6141 *
6133 * Waiting for some bits of register to change is a common 6142 * Waiting for some bits of register to change is a common
6134 * operation for ATA controllers. This function reads 32bit LE 6143 * operation for ATA controllers. This function reads 32bit LE
@@ -6146,10 +6155,9 @@ int ata_ratelimit(void)
6146 * The final register value. 6155 * The final register value.
6147 */ 6156 */
6148u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 6157u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
6149 unsigned long interval_msec, 6158 unsigned long interval, unsigned long timeout)
6150 unsigned long timeout_msec)
6151{ 6159{
6152 unsigned long timeout; 6160 unsigned long deadline;
6153 u32 tmp; 6161 u32 tmp;
6154 6162
6155 tmp = ioread32(reg); 6163 tmp = ioread32(reg);
@@ -6158,10 +6166,10 @@ u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
6158 * preceding writes reach the controller before starting to 6166 * preceding writes reach the controller before starting to
6159 * eat away the timeout. 6167 * eat away the timeout.
6160 */ 6168 */
6161 timeout = jiffies + (timeout_msec * HZ) / 1000; 6169 deadline = ata_deadline(jiffies, timeout);
6162 6170
6163 while ((tmp & mask) == val && time_before(jiffies, timeout)) { 6171 while ((tmp & mask) == val && time_before(jiffies, deadline)) {
6164 msleep(interval_msec); 6172 msleep(interval);
6165 tmp = ioread32(reg); 6173 tmp = ioread32(reg);
6166 } 6174 }
6167 6175
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 7894d83ea1e..58bdc538d22 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -66,15 +66,19 @@ enum {
66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6, 66 ATA_ECAT_DUBIOUS_TOUT_HSM = 6,
67 ATA_ECAT_DUBIOUS_UNK_DEV = 7, 67 ATA_ECAT_DUBIOUS_UNK_DEV = 7,
68 ATA_ECAT_NR = 8, 68 ATA_ECAT_NR = 8,
69};
70 69
71/* Waiting in ->prereset can never be reliable. It's sometimes nice 70 ATA_EH_CMD_DFL_TIMEOUT = 5000,
72 * to wait there but it can't be depended upon; otherwise, we wouldn't 71
73 * be resetting. Just give it enough time for most drives to spin up. 72 /* always put at least this amount of time between resets */
74 */ 73 ATA_EH_RESET_COOL_DOWN = 5000,
75enum { 74
76 ATA_EH_PRERESET_TIMEOUT = 10 * HZ, 75 /* Waiting in ->prereset can never be reliable. It's
77 ATA_EH_FASTDRAIN_INTERVAL = 3 * HZ, 76 * sometimes nice to wait there but it can't be depended upon;
77 * otherwise, we wouldn't be resetting. Just give it enough
78 * time for most drives to spin up.
79 */
80 ATA_EH_PRERESET_TIMEOUT = 10000,
81 ATA_EH_FASTDRAIN_INTERVAL = 3000,
78}; 82};
79 83
80/* The following table determines how we sequence resets. Each entry 84/* The following table determines how we sequence resets. Each entry
@@ -84,12 +88,59 @@ enum {
84 * are mostly for error handling, hotplug and retarded devices. 88 * are mostly for error handling, hotplug and retarded devices.
85 */ 89 */
86static const unsigned long ata_eh_reset_timeouts[] = { 90static const unsigned long ata_eh_reset_timeouts[] = {
87 10 * HZ, /* most drives spin up by 10sec */ 91 10000, /* most drives spin up by 10sec */
88 10 * HZ, /* > 99% working drives spin up before 20sec */ 92 10000, /* > 99% working drives spin up before 20sec */
89 35 * HZ, /* give > 30 secs of idleness for retarded devices */ 93 35000, /* give > 30 secs of idleness for retarded devices */
90 5 * HZ, /* and sweet one last chance */ 94 5000, /* and sweet one last chance */
91 /* > 1 min has elapsed, give up */ 95 ULONG_MAX, /* > 1 min has elapsed, give up */
96};
97
98static const unsigned long ata_eh_identify_timeouts[] = {
99 5000, /* covers > 99% of successes and not too boring on failures */
100 10000, /* combined time till here is enough even for media access */
101 30000, /* for true idiots */
102 ULONG_MAX,
103};
104
105static const unsigned long ata_eh_other_timeouts[] = {
106 5000, /* same rationale as identify timeout */
107 10000, /* ditto */
108 /* but no merciful 30sec for other commands, it just isn't worth it */
109 ULONG_MAX,
110};
111
112struct ata_eh_cmd_timeout_ent {
113 const u8 *commands;
114 const unsigned long *timeouts;
115};
116
117/* The following table determines timeouts to use for EH internal
118 * commands. Each table entry is a command class and matches the
119 * commands the entry applies to and the timeout table to use.
120 *
121 * On the retry after a command timed out, the next timeout value from
122 * the table is used. If the table doesn't contain further entries,
123 * the last value is used.
124 *
125 * ehc->cmd_timeout_idx keeps track of which timeout to use per
126 * command class, so if SET_FEATURES times out on the first try, the
127 * next try will use the second timeout value only for that class.
128 */
129#define CMDS(cmds...) (const u8 []){ cmds, 0 }
130static const struct ata_eh_cmd_timeout_ent
131ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = {
132 { .commands = CMDS(ATA_CMD_ID_ATA, ATA_CMD_ID_ATAPI),
133 .timeouts = ata_eh_identify_timeouts, },
134 { .commands = CMDS(ATA_CMD_READ_NATIVE_MAX, ATA_CMD_READ_NATIVE_MAX_EXT),
135 .timeouts = ata_eh_other_timeouts, },
136 { .commands = CMDS(ATA_CMD_SET_MAX, ATA_CMD_SET_MAX_EXT),
137 .timeouts = ata_eh_other_timeouts, },
138 { .commands = CMDS(ATA_CMD_SET_FEATURES),
139 .timeouts = ata_eh_other_timeouts, },
140 { .commands = CMDS(ATA_CMD_INIT_DEV_PARAMS),
141 .timeouts = ata_eh_other_timeouts, },
92}; 142};
143#undef CMDS
93 144
94static void __ata_port_freeze(struct ata_port *ap); 145static void __ata_port_freeze(struct ata_port *ap);
95#ifdef CONFIG_PM 146#ifdef CONFIG_PM
@@ -236,6 +287,73 @@ void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
236 287
237#endif /* CONFIG_PCI */ 288#endif /* CONFIG_PCI */
238 289
290static int ata_lookup_timeout_table(u8 cmd)
291{
292 int i;
293
294 for (i = 0; i < ATA_EH_CMD_TIMEOUT_TABLE_SIZE; i++) {
295 const u8 *cur;
296
297 for (cur = ata_eh_cmd_timeout_table[i].commands; *cur; cur++)
298 if (*cur == cmd)
299 return i;
300 }
301
302 return -1;
303}
304
305/**
306 * ata_internal_cmd_timeout - determine timeout for an internal command
307 * @dev: target device
308 * @cmd: internal command to be issued
309 *
310 * Determine timeout for internal command @cmd for @dev.
311 *
312 * LOCKING:
313 * EH context.
314 *
315 * RETURNS:
316 * Determined timeout.
317 */
318unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd)
319{
320 struct ata_eh_context *ehc = &dev->link->eh_context;
321 int ent = ata_lookup_timeout_table(cmd);
322 int idx;
323
324 if (ent < 0)
325 return ATA_EH_CMD_DFL_TIMEOUT;
326
327 idx = ehc->cmd_timeout_idx[dev->devno][ent];
328 return ata_eh_cmd_timeout_table[ent].timeouts[idx];
329}
330
331/**
332 * ata_internal_cmd_timed_out - notification for internal command timeout
333 * @dev: target device
334 * @cmd: internal command which timed out
335 *
336 * Notify EH that internal command @cmd for @dev timed out. This
337 * function should be called only for commands whose timeouts are
338 * determined using ata_internal_cmd_timeout().
339 *
340 * LOCKING:
341 * EH context.
342 */
343void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd)
344{
345 struct ata_eh_context *ehc = &dev->link->eh_context;
346 int ent = ata_lookup_timeout_table(cmd);
347 int idx;
348
349 if (ent < 0)
350 return;
351
352 idx = ehc->cmd_timeout_idx[dev->devno][ent];
353 if (ata_eh_cmd_timeout_table[ent].timeouts[idx + 1] != ULONG_MAX)
354 ehc->cmd_timeout_idx[dev->devno][ent]++;
355}
356
239static void ata_ering_record(struct ata_ering *ering, unsigned int eflags, 357static void ata_ering_record(struct ata_ering *ering, unsigned int eflags,
240 unsigned int err_mask) 358 unsigned int err_mask)
241{ 359{
@@ -486,6 +604,9 @@ void ata_scsi_error(struct Scsi_Host *host)
486 if (ata_ncq_enabled(dev)) 604 if (ata_ncq_enabled(dev))
487 ehc->saved_ncq_enabled |= 1 << devno; 605 ehc->saved_ncq_enabled |= 1 << devno;
488 } 606 }
607
608 /* set last reset timestamp to some time in the past */
609 ehc->last_reset = jiffies - 60 * HZ;
489 } 610 }
490 611
491 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS; 612 ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS;
@@ -641,7 +762,7 @@ void ata_eh_fastdrain_timerfn(unsigned long arg)
641 /* some qcs have finished, give it another chance */ 762 /* some qcs have finished, give it another chance */
642 ap->fastdrain_cnt = cnt; 763 ap->fastdrain_cnt = cnt;
643 ap->fastdrain_timer.expires = 764 ap->fastdrain_timer.expires =
644 jiffies + ATA_EH_FASTDRAIN_INTERVAL; 765 ata_deadline(jiffies, ATA_EH_FASTDRAIN_INTERVAL);
645 add_timer(&ap->fastdrain_timer); 766 add_timer(&ap->fastdrain_timer);
646 } 767 }
647 768
@@ -681,7 +802,8 @@ static void ata_eh_set_pending(struct ata_port *ap, int fastdrain)
681 802
682 /* activate fast drain */ 803 /* activate fast drain */
683 ap->fastdrain_cnt = cnt; 804 ap->fastdrain_cnt = cnt;
684 ap->fastdrain_timer.expires = jiffies + ATA_EH_FASTDRAIN_INTERVAL; 805 ap->fastdrain_timer.expires =
806 ata_deadline(jiffies, ATA_EH_FASTDRAIN_INTERVAL);
685 add_timer(&ap->fastdrain_timer); 807 add_timer(&ap->fastdrain_timer);
686} 808}
687 809
@@ -1238,6 +1360,7 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
1238 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE 1360 * atapi_eh_request_sense - perform ATAPI REQUEST_SENSE
1239 * @dev: device to perform REQUEST_SENSE to 1361 * @dev: device to perform REQUEST_SENSE to
1240 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long) 1362 * @sense_buf: result sense data buffer (SCSI_SENSE_BUFFERSIZE bytes long)
1363 * @dfl_sense_key: default sense key to use
1241 * 1364 *
1242 * Perform ATAPI REQUEST_SENSE after the device reported CHECK 1365 * Perform ATAPI REQUEST_SENSE after the device reported CHECK
1243 * SENSE. This function is EH helper. 1366 * SENSE. This function is EH helper.
@@ -1248,13 +1371,13 @@ static int ata_eh_read_log_10h(struct ata_device *dev,
1248 * RETURNS: 1371 * RETURNS:
1249 * 0 on success, AC_ERR_* mask on failure 1372 * 0 on success, AC_ERR_* mask on failure
1250 */ 1373 */
1251static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc) 1374static unsigned int atapi_eh_request_sense(struct ata_device *dev,
1375 u8 *sense_buf, u8 dfl_sense_key)
1252{ 1376{
1253 struct ata_device *dev = qc->dev; 1377 u8 cdb[ATAPI_CDB_LEN] =
1254 unsigned char *sense_buf = qc->scsicmd->sense_buffer; 1378 { REQUEST_SENSE, 0, 0, 0, SCSI_SENSE_BUFFERSIZE, 0 };
1255 struct ata_port *ap = dev->link->ap; 1379 struct ata_port *ap = dev->link->ap;
1256 struct ata_taskfile tf; 1380 struct ata_taskfile tf;
1257 u8 cdb[ATAPI_CDB_LEN];
1258 1381
1259 DPRINTK("ATAPI request sense\n"); 1382 DPRINTK("ATAPI request sense\n");
1260 1383
@@ -1265,15 +1388,11 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
1265 * for the case where they are -not- overwritten 1388 * for the case where they are -not- overwritten
1266 */ 1389 */
1267 sense_buf[0] = 0x70; 1390 sense_buf[0] = 0x70;
1268 sense_buf[2] = qc->result_tf.feature >> 4; 1391 sense_buf[2] = dfl_sense_key;
1269 1392
1270 /* some devices time out if garbage left in tf */ 1393 /* some devices time out if garbage left in tf */
1271 ata_tf_init(dev, &tf); 1394 ata_tf_init(dev, &tf);
1272 1395
1273 memset(cdb, 0, ATAPI_CDB_LEN);
1274 cdb[0] = REQUEST_SENSE;
1275 cdb[4] = SCSI_SENSE_BUFFERSIZE;
1276
1277 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 1396 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1278 tf.command = ATA_CMD_PACKET; 1397 tf.command = ATA_CMD_PACKET;
1279 1398
@@ -1445,7 +1564,9 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
1445 1564
1446 case ATA_DEV_ATAPI: 1565 case ATA_DEV_ATAPI:
1447 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) { 1566 if (!(qc->ap->pflags & ATA_PFLAG_FROZEN)) {
1448 tmp = atapi_eh_request_sense(qc); 1567 tmp = atapi_eh_request_sense(qc->dev,
1568 qc->scsicmd->sense_buffer,
1569 qc->result_tf.feature >> 4);
1449 if (!tmp) { 1570 if (!tmp) {
1450 /* ATA_QCFLAG_SENSE_VALID is used to 1571 /* ATA_QCFLAG_SENSE_VALID is used to
1451 * tell atapi_qc_complete() that sense 1572 * tell atapi_qc_complete() that sense
@@ -2071,13 +2192,12 @@ int ata_eh_reset(struct ata_link *link, int classify,
2071 ata_prereset_fn_t prereset, ata_reset_fn_t softreset, 2192 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
2072 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset) 2193 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
2073{ 2194{
2074 const int max_tries = ARRAY_SIZE(ata_eh_reset_timeouts);
2075 struct ata_port *ap = link->ap; 2195 struct ata_port *ap = link->ap;
2076 struct ata_eh_context *ehc = &link->eh_context; 2196 struct ata_eh_context *ehc = &link->eh_context;
2077 unsigned int *classes = ehc->classes; 2197 unsigned int *classes = ehc->classes;
2078 unsigned int lflags = link->flags; 2198 unsigned int lflags = link->flags;
2079 int verbose = !(ehc->i.flags & ATA_EHI_QUIET); 2199 int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
2080 int try = 0; 2200 int max_tries = 0, try = 0;
2081 struct ata_device *dev; 2201 struct ata_device *dev;
2082 unsigned long deadline, now; 2202 unsigned long deadline, now;
2083 ata_reset_fn_t reset; 2203 ata_reset_fn_t reset;
@@ -2088,11 +2208,20 @@ int ata_eh_reset(struct ata_link *link, int classify,
2088 /* 2208 /*
2089 * Prepare to reset 2209 * Prepare to reset
2090 */ 2210 */
2211 while (ata_eh_reset_timeouts[max_tries] != ULONG_MAX)
2212 max_tries++;
2213
2214 now = jiffies;
2215 deadline = ata_deadline(ehc->last_reset, ATA_EH_RESET_COOL_DOWN);
2216 if (time_before(now, deadline))
2217 schedule_timeout_uninterruptible(deadline - now);
2218
2091 spin_lock_irqsave(ap->lock, flags); 2219 spin_lock_irqsave(ap->lock, flags);
2092 ap->pflags |= ATA_PFLAG_RESETTING; 2220 ap->pflags |= ATA_PFLAG_RESETTING;
2093 spin_unlock_irqrestore(ap->lock, flags); 2221 spin_unlock_irqrestore(ap->lock, flags);
2094 2222
2095 ata_eh_about_to_do(link, NULL, ATA_EH_RESET); 2223 ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
2224 ehc->last_reset = jiffies;
2096 2225
2097 ata_link_for_each_dev(dev, link) { 2226 ata_link_for_each_dev(dev, link) {
2098 /* If we issue an SRST then an ATA drive (not ATAPI) 2227 /* If we issue an SRST then an ATA drive (not ATAPI)
@@ -2125,7 +2254,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
2125 } 2254 }
2126 2255
2127 if (prereset) { 2256 if (prereset) {
2128 rc = prereset(link, jiffies + ATA_EH_PRERESET_TIMEOUT); 2257 rc = prereset(link,
2258 ata_deadline(jiffies, ATA_EH_PRERESET_TIMEOUT));
2129 if (rc) { 2259 if (rc) {
2130 if (rc == -ENOENT) { 2260 if (rc == -ENOENT) {
2131 ata_link_printk(link, KERN_DEBUG, 2261 ata_link_printk(link, KERN_DEBUG,
@@ -2157,10 +2287,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
2157 /* 2287 /*
2158 * Perform reset 2288 * Perform reset
2159 */ 2289 */
2290 ehc->last_reset = jiffies;
2160 if (ata_is_host_link(link)) 2291 if (ata_is_host_link(link))
2161 ata_eh_freeze_port(ap); 2292 ata_eh_freeze_port(ap);
2162 2293
2163 deadline = jiffies + ata_eh_reset_timeouts[try++]; 2294 deadline = ata_deadline(jiffies, ata_eh_reset_timeouts[try++]);
2164 2295
2165 if (reset) { 2296 if (reset) {
2166 if (verbose) 2297 if (verbose)
@@ -2277,6 +2408,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
2277 2408
2278 /* reset successful, schedule revalidation */ 2409 /* reset successful, schedule revalidation */
2279 ata_eh_done(link, NULL, ATA_EH_RESET); 2410 ata_eh_done(link, NULL, ATA_EH_RESET);
2411 ehc->last_reset = jiffies;
2280 ehc->i.action |= ATA_EH_REVALIDATE; 2412 ehc->i.action |= ATA_EH_REVALIDATE;
2281 2413
2282 rc = 0; 2414 rc = 0;
@@ -2303,9 +2435,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
2303 if (time_before(now, deadline)) { 2435 if (time_before(now, deadline)) {
2304 unsigned long delta = deadline - now; 2436 unsigned long delta = deadline - now;
2305 2437
2306 ata_link_printk(link, KERN_WARNING, "reset failed " 2438 ata_link_printk(link, KERN_WARNING,
2307 "(errno=%d), retrying in %u secs\n", 2439 "reset failed (errno=%d), retrying in %u secs\n",
2308 rc, (jiffies_to_msecs(delta) + 999) / 1000); 2440 rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000));
2309 2441
2310 while (delta) 2442 while (delta)
2311 delta = schedule_timeout_uninterruptible(delta); 2443 delta = schedule_timeout_uninterruptible(delta);
@@ -2583,8 +2715,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
2583 ata_eh_detach_dev(dev); 2715 ata_eh_detach_dev(dev);
2584 2716
2585 /* schedule probe if necessary */ 2717 /* schedule probe if necessary */
2586 if (ata_eh_schedule_probe(dev)) 2718 if (ata_eh_schedule_probe(dev)) {
2587 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES; 2719 ehc->tries[dev->devno] = ATA_EH_DEV_TRIES;
2720 memset(ehc->cmd_timeout_idx[dev->devno], 0,
2721 sizeof(ehc->cmd_timeout_idx[dev->devno]));
2722 }
2588 2723
2589 return 1; 2724 return 1;
2590 } else { 2725 } else {
@@ -2622,7 +2757,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2622{ 2757{
2623 struct ata_link *link; 2758 struct ata_link *link;
2624 struct ata_device *dev; 2759 struct ata_device *dev;
2625 int nr_failed_devs, nr_disabled_devs; 2760 int nr_failed_devs;
2626 int rc; 2761 int rc;
2627 unsigned long flags; 2762 unsigned long flags;
2628 2763
@@ -2665,7 +2800,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2665 retry: 2800 retry:
2666 rc = 0; 2801 rc = 0;
2667 nr_failed_devs = 0; 2802 nr_failed_devs = 0;
2668 nr_disabled_devs = 0;
2669 2803
2670 /* if UNLOADING, finish immediately */ 2804 /* if UNLOADING, finish immediately */
2671 if (ap->pflags & ATA_PFLAG_UNLOADING) 2805 if (ap->pflags & ATA_PFLAG_UNLOADING)
@@ -2732,8 +2866,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
2732 2866
2733dev_fail: 2867dev_fail:
2734 nr_failed_devs++; 2868 nr_failed_devs++;
2735 if (ata_eh_handle_dev_fail(dev, rc)) 2869 ata_eh_handle_dev_fail(dev, rc);
2736 nr_disabled_devs++;
2737 2870
2738 if (ap->pflags & ATA_PFLAG_FROZEN) { 2871 if (ap->pflags & ATA_PFLAG_FROZEN) {
2739 /* PMP reset requires working host port. 2872 /* PMP reset requires working host port.
@@ -2745,18 +2878,8 @@ dev_fail:
2745 } 2878 }
2746 } 2879 }
2747 2880
2748 if (nr_failed_devs) { 2881 if (nr_failed_devs)
2749 if (nr_failed_devs != nr_disabled_devs) {
2750 ata_port_printk(ap, KERN_WARNING, "failed to recover "
2751 "some devices, retrying in 5 secs\n");
2752 ssleep(5);
2753 } else {
2754 /* no device left to recover, repeat fast */
2755 msleep(500);
2756 }
2757
2758 goto retry; 2882 goto retry;
2759 }
2760 2883
2761 out: 2884 out:
2762 if (rc && r_failed_link) 2885 if (rc && r_failed_link)
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c
index 7daf4c0f621..b65db309c18 100644
--- a/drivers/ata/libata-pmp.c
+++ b/drivers/ata/libata-pmp.c
@@ -727,19 +727,12 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
727 } 727 }
728 728
729 if (tries) { 729 if (tries) {
730 int sleep = ehc->i.flags & ATA_EHI_DID_RESET;
731
732 /* consecutive revalidation failures? speed down */ 730 /* consecutive revalidation failures? speed down */
733 if (reval_failed) 731 if (reval_failed)
734 sata_down_spd_limit(link); 732 sata_down_spd_limit(link);
735 else 733 else
736 reval_failed = 1; 734 reval_failed = 1;
737 735
738 ata_dev_printk(dev, KERN_WARNING,
739 "retrying reset%s\n",
740 sleep ? " in 5 secs" : "");
741 if (sleep)
742 ssleep(5);
743 ehc->i.action |= ATA_EH_RESET; 736 ehc->i.action |= ATA_EH_RESET;
744 goto retry; 737 goto retry;
745 } else { 738 } else {
@@ -785,7 +778,8 @@ static int sata_pmp_eh_handle_disabled_links(struct ata_port *ap)
785 * SError.N working. 778 * SError.N working.
786 */ 779 */
787 sata_link_hardreset(link, sata_deb_timing_normal, 780 sata_link_hardreset(link, sata_deb_timing_normal,
788 jiffies + ATA_TMOUT_INTERNAL_QUICK, NULL, NULL); 781 ata_deadline(jiffies, ATA_TMOUT_INTERNAL_QUICK),
782 NULL, NULL);
789 783
790 /* unconditionally clear SError.N */ 784 /* unconditionally clear SError.N */
791 rc = sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG); 785 rc = sata_scr_write(link, SCR_ERROR, SERR_PHYRDY_CHG);
@@ -990,10 +984,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
990 goto retry; 984 goto retry;
991 985
992 if (--pmp_tries) { 986 if (--pmp_tries) {
993 ata_port_printk(ap, KERN_WARNING,
994 "failed to recover PMP, retrying in 5 secs\n");
995 pmp_ehc->i.action |= ATA_EH_RESET; 987 pmp_ehc->i.action |= ATA_EH_RESET;
996 ssleep(5);
997 goto retry; 988 goto retry;
998 } 989 }
999 990
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 499ccc628d8..f3b4b15a8dc 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -190,6 +190,85 @@ static void ata_scsi_set_sense(struct scsi_cmnd *cmd, u8 sk, u8 asc, u8 ascq)
190 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq); 190 scsi_build_sense_buffer(0, cmd->sense_buffer, sk, asc, ascq);
191} 191}
192 192
193static ssize_t
194ata_scsi_em_message_store(struct device *dev, struct device_attribute *attr,
195 const char *buf, size_t count)
196{
197 struct Scsi_Host *shost = class_to_shost(dev);
198 struct ata_port *ap = ata_shost_to_port(shost);
199 if (ap->ops->em_store && (ap->flags & ATA_FLAG_EM))
200 return ap->ops->em_store(ap, buf, count);
201 return -EINVAL;
202}
203
204static ssize_t
205ata_scsi_em_message_show(struct device *dev, struct device_attribute *attr,
206 char *buf)
207{
208 struct Scsi_Host *shost = class_to_shost(dev);
209 struct ata_port *ap = ata_shost_to_port(shost);
210
211 if (ap->ops->em_show && (ap->flags & ATA_FLAG_EM))
212 return ap->ops->em_show(ap, buf);
213 return -EINVAL;
214}
215DEVICE_ATTR(em_message, S_IRUGO | S_IWUGO,
216 ata_scsi_em_message_show, ata_scsi_em_message_store);
217EXPORT_SYMBOL_GPL(dev_attr_em_message);
218
219static ssize_t
220ata_scsi_em_message_type_show(struct device *dev, struct device_attribute *attr,
221 char *buf)
222{
223 struct Scsi_Host *shost = class_to_shost(dev);
224 struct ata_port *ap = ata_shost_to_port(shost);
225
226 return snprintf(buf, 23, "%d\n", ap->em_message_type);
227}
228DEVICE_ATTR(em_message_type, S_IRUGO,
229 ata_scsi_em_message_type_show, NULL);
230EXPORT_SYMBOL_GPL(dev_attr_em_message_type);
231
232static ssize_t
233ata_scsi_activity_show(struct device *dev, struct device_attribute *attr,
234 char *buf)
235{
236 struct scsi_device *sdev = to_scsi_device(dev);
237 struct ata_port *ap = ata_shost_to_port(sdev->host);
238 struct ata_device *atadev = ata_scsi_find_dev(ap, sdev);
239
240 if (ap->ops->sw_activity_show && (ap->flags & ATA_FLAG_SW_ACTIVITY))
241 return ap->ops->sw_activity_show(atadev, buf);
242 return -EINVAL;
243}
244
245static ssize_t
246ata_scsi_activity_store(struct device *dev, struct device_attribute *attr,
247 const char *buf, size_t count)
248{
249 struct scsi_device *sdev = to_scsi_device(dev);
250 struct ata_port *ap = ata_shost_to_port(sdev->host);
251 struct ata_device *atadev = ata_scsi_find_dev(ap, sdev);
252 enum sw_activity val;
253 int rc;
254
255 if (ap->ops->sw_activity_store && (ap->flags & ATA_FLAG_SW_ACTIVITY)) {
256 val = simple_strtoul(buf, NULL, 0);
257 switch (val) {
258 case OFF: case BLINK_ON: case BLINK_OFF:
259 rc = ap->ops->sw_activity_store(atadev, val);
260 if (!rc)
261 return count;
262 else
263 return rc;
264 }
265 }
266 return -EINVAL;
267}
268DEVICE_ATTR(sw_activity, S_IWUGO | S_IRUGO, ata_scsi_activity_show,
269 ata_scsi_activity_store);
270EXPORT_SYMBOL_GPL(dev_attr_sw_activity);
271
193static void ata_scsi_invalid_field(struct scsi_cmnd *cmd, 272static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
194 void (*done)(struct scsi_cmnd *)) 273 void (*done)(struct scsi_cmnd *))
195{ 274{
@@ -1779,7 +1858,9 @@ static unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf)
1779 const u8 pages[] = { 1858 const u8 pages[] = {
1780 0x00, /* page 0x00, this page */ 1859 0x00, /* page 0x00, this page */
1781 0x80, /* page 0x80, unit serial no page */ 1860 0x80, /* page 0x80, unit serial no page */
1782 0x83 /* page 0x83, device ident page */ 1861 0x83, /* page 0x83, device ident page */
1862 0x89, /* page 0x89, ata info page */
1863 0xb1, /* page 0xb1, block device characteristics page */
1783 }; 1864 };
1784 1865
1785 rbuf[3] = sizeof(pages); /* number of supported VPD pages */ 1866 rbuf[3] = sizeof(pages); /* number of supported VPD pages */
@@ -1900,6 +1981,19 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf)
1900 return 0; 1981 return 0;
1901} 1982}
1902 1983
1984static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf)
1985{
1986 rbuf[1] = 0xb1;
1987 rbuf[3] = 0x3c;
1988 if (ata_id_major_version(args->id) > 7) {
1989 rbuf[4] = args->id[217] >> 8;
1990 rbuf[5] = args->id[217];
1991 rbuf[7] = args->id[168] & 0xf;
1992 }
1993
1994 return 0;
1995}
1996
1903/** 1997/**
1904 * ata_scsiop_noop - Command handler that simply returns success. 1998 * ata_scsiop_noop - Command handler that simply returns success.
1905 * @args: device IDENTIFY data / SCSI command of interest. 1999 * @args: device IDENTIFY data / SCSI command of interest.
@@ -2921,6 +3015,9 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
2921 case 0x89: 3015 case 0x89:
2922 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89); 3016 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_89);
2923 break; 3017 break;
3018 case 0xb1:
3019 ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b1);
3020 break;
2924 default: 3021 default:
2925 ata_scsi_invalid_field(cmd, done); 3022 ata_scsi_invalid_field(cmd, done);
2926 break; 3023 break;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index c0908c22548..304fdc6f1dc 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -345,8 +345,8 @@ void ata_sff_dma_pause(struct ata_port *ap)
345/** 345/**
346 * ata_sff_busy_sleep - sleep until BSY clears, or timeout 346 * ata_sff_busy_sleep - sleep until BSY clears, or timeout
347 * @ap: port containing status register to be polled 347 * @ap: port containing status register to be polled
348 * @tmout_pat: impatience timeout 348 * @tmout_pat: impatience timeout in msecs
349 * @tmout: overall timeout 349 * @tmout: overall timeout in msecs
350 * 350 *
351 * Sleep until ATA Status register bit BSY clears, 351 * Sleep until ATA Status register bit BSY clears,
352 * or a timeout occurs. 352 * or a timeout occurs.
@@ -365,7 +365,7 @@ int ata_sff_busy_sleep(struct ata_port *ap,
365 365
366 status = ata_sff_busy_wait(ap, ATA_BUSY, 300); 366 status = ata_sff_busy_wait(ap, ATA_BUSY, 300);
367 timer_start = jiffies; 367 timer_start = jiffies;
368 timeout = timer_start + tmout_pat; 368 timeout = ata_deadline(timer_start, tmout_pat);
369 while (status != 0xff && (status & ATA_BUSY) && 369 while (status != 0xff && (status & ATA_BUSY) &&
370 time_before(jiffies, timeout)) { 370 time_before(jiffies, timeout)) {
371 msleep(50); 371 msleep(50);
@@ -377,7 +377,7 @@ int ata_sff_busy_sleep(struct ata_port *ap,
377 "port is slow to respond, please be patient " 377 "port is slow to respond, please be patient "
378 "(Status 0x%x)\n", status); 378 "(Status 0x%x)\n", status);
379 379
380 timeout = timer_start + tmout; 380 timeout = ata_deadline(timer_start, tmout);
381 while (status != 0xff && (status & ATA_BUSY) && 381 while (status != 0xff && (status & ATA_BUSY) &&
382 time_before(jiffies, timeout)) { 382 time_before(jiffies, timeout)) {
383 msleep(50); 383 msleep(50);
@@ -390,7 +390,7 @@ int ata_sff_busy_sleep(struct ata_port *ap,
390 if (status & ATA_BUSY) { 390 if (status & ATA_BUSY) {
391 ata_port_printk(ap, KERN_ERR, "port failed to respond " 391 ata_port_printk(ap, KERN_ERR, "port failed to respond "
392 "(%lu secs, Status 0x%x)\n", 392 "(%lu secs, Status 0x%x)\n",
393 tmout / HZ, status); 393 DIV_ROUND_UP(tmout, 1000), status);
394 return -EBUSY; 394 return -EBUSY;
395 } 395 }
396 396
@@ -1888,7 +1888,7 @@ int ata_sff_wait_after_reset(struct ata_link *link, unsigned int devmask,
1888 unsigned int dev1 = devmask & (1 << 1); 1888 unsigned int dev1 = devmask & (1 << 1);
1889 int rc, ret = 0; 1889 int rc, ret = 0;
1890 1890
1891 msleep(ATA_WAIT_AFTER_RESET_MSECS); 1891 msleep(ATA_WAIT_AFTER_RESET);
1892 1892
1893 /* always check readiness of the master device */ 1893 /* always check readiness of the master device */
1894 rc = ata_sff_wait_ready(link, deadline); 1894 rc = ata_sff_wait_ready(link, deadline);
@@ -2371,7 +2371,8 @@ void ata_bus_reset(struct ata_port *ap)
2371 2371
2372 /* issue bus reset */ 2372 /* issue bus reset */
2373 if (ap->flags & ATA_FLAG_SRST) { 2373 if (ap->flags & ATA_FLAG_SRST) {
2374 rc = ata_bus_softreset(ap, devmask, jiffies + 40 * HZ); 2374 rc = ata_bus_softreset(ap, devmask,
2375 ata_deadline(jiffies, 40000));
2375 if (rc && rc != -ENODEV) 2376 if (rc && rc != -ENODEV)
2376 goto err_out; 2377 goto err_out;
2377 } 2378 }
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 1cf803adbc9..f6f9c28ec7f 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -151,6 +151,8 @@ extern void ata_scsi_dev_rescan(struct work_struct *work);
151extern int ata_bus_probe(struct ata_port *ap); 151extern int ata_bus_probe(struct ata_port *ap);
152 152
153/* libata-eh.c */ 153/* libata-eh.c */
154extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd);
155extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd);
154extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); 156extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd);
155extern void ata_scsi_error(struct Scsi_Host *host); 157extern void ata_scsi_error(struct Scsi_Host *host);
156extern void ata_port_wait_eh(struct ata_port *ap); 158extern void ata_port_wait_eh(struct ata_port *ap);
diff --git a/drivers/ata/pata_bf54x.c b/drivers/ata/pata_bf54x.c
index 55516103626..d3932901a3b 100644
--- a/drivers/ata/pata_bf54x.c
+++ b/drivers/ata/pata_bf54x.c
@@ -1011,7 +1011,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1011 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr; 1011 void __iomem *base = (void __iomem *)ap->ioaddr.ctl_addr;
1012 unsigned int dev0 = devmask & (1 << 0); 1012 unsigned int dev0 = devmask & (1 << 0);
1013 unsigned int dev1 = devmask & (1 << 1); 1013 unsigned int dev1 = devmask & (1 << 1);
1014 unsigned long timeout; 1014 unsigned long deadline;
1015 1015
1016 /* if device 0 was found in ata_devchk, wait for its 1016 /* if device 0 was found in ata_devchk, wait for its
1017 * BSY bit to clear 1017 * BSY bit to clear
@@ -1022,7 +1022,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1022 /* if device 1 was found in ata_devchk, wait for 1022 /* if device 1 was found in ata_devchk, wait for
1023 * register access, then wait for BSY to clear 1023 * register access, then wait for BSY to clear
1024 */ 1024 */
1025 timeout = jiffies + ATA_TMOUT_BOOT; 1025 deadline = ata_deadline(jiffies, ATA_TMOUT_BOOT);
1026 while (dev1) { 1026 while (dev1) {
1027 u8 nsect, lbal; 1027 u8 nsect, lbal;
1028 1028
@@ -1031,7 +1031,7 @@ static void bfin_bus_post_reset(struct ata_port *ap, unsigned int devmask)
1031 lbal = read_atapi_register(base, ATA_REG_LBAL); 1031 lbal = read_atapi_register(base, ATA_REG_LBAL);
1032 if ((nsect == 1) && (lbal == 1)) 1032 if ((nsect == 1) && (lbal == 1))
1033 break; 1033 break;
1034 if (time_after(jiffies, timeout)) { 1034 if (time_after(jiffies, deadline)) {
1035 dev1 = 0; 1035 dev1 = 0;
1036 break; 1036 break;
1037 } 1037 }
diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c
index fe7cc8ed4ea..bc037ffce20 100644
--- a/drivers/ata/pata_legacy.c
+++ b/drivers/ata/pata_legacy.c
@@ -305,7 +305,7 @@ static unsigned int pdc_data_xfer_vlb(struct ata_device *dev,
305 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); 305 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
306 306
307 if (unlikely(slop)) { 307 if (unlikely(slop)) {
308 u32 pad; 308 __le32 pad;
309 if (rw == READ) { 309 if (rw == READ) {
310 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); 310 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
311 memcpy(buf + buflen - slop, &pad, slop); 311 memcpy(buf + buflen - slop, &pad, slop);
@@ -746,14 +746,12 @@ static unsigned int vlb32_data_xfer(struct ata_device *adev, unsigned char *buf,
746 ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); 746 ioread32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
747 747
748 if (unlikely(slop)) { 748 if (unlikely(slop)) {
749 u32 pad; 749 __le32 pad;
750 if (rw == WRITE) { 750 if (rw == WRITE) {
751 memcpy(&pad, buf + buflen - slop, slop); 751 memcpy(&pad, buf + buflen - slop, slop);
752 pad = le32_to_cpu(pad); 752 iowrite32(le32_to_cpu(pad), ap->ioaddr.data_addr);
753 iowrite32(pad, ap->ioaddr.data_addr);
754 } else { 753 } else {
755 pad = ioread32(ap->ioaddr.data_addr); 754 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
756 pad = cpu_to_le32(pad);
757 memcpy(buf + buflen - slop, &pad, slop); 755 memcpy(buf + buflen - slop, &pad, slop);
758 } 756 }
759 } 757 }
diff --git a/drivers/ata/pata_qdi.c b/drivers/ata/pata_qdi.c
index 97e5b090d7c..63b7a1c165a 100644
--- a/drivers/ata/pata_qdi.c
+++ b/drivers/ata/pata_qdi.c
@@ -137,7 +137,7 @@ static unsigned int qdi_data_xfer(struct ata_device *dev, unsigned char *buf,
137 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); 137 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
138 138
139 if (unlikely(slop)) { 139 if (unlikely(slop)) {
140 u32 pad; 140 __le32 pad;
141 if (rw == READ) { 141 if (rw == READ) {
142 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); 142 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
143 memcpy(buf + buflen - slop, &pad, slop); 143 memcpy(buf + buflen - slop, &pad, slop);
diff --git a/drivers/ata/pata_scc.c b/drivers/ata/pata_scc.c
index bbf5aa345e6..16673d16857 100644
--- a/drivers/ata/pata_scc.c
+++ b/drivers/ata/pata_scc.c
@@ -696,7 +696,7 @@ static void scc_bmdma_stop (struct ata_queued_cmd *qc)
696 696
697 if (reg & INTSTS_BMSINT) { 697 if (reg & INTSTS_BMSINT) {
698 unsigned int classes; 698 unsigned int classes;
699 unsigned long deadline = jiffies + ATA_TMOUT_BOOT; 699 unsigned long deadline = ata_deadline(jiffies, ATA_TMOUT_BOOT);
700 printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME); 700 printk(KERN_WARNING "%s: Internal Bus Error\n", DRV_NAME);
701 out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT); 701 out_be32(bmid_base + SCC_DMA_INTST, INTSTS_BMSINT);
702 /* TBD: SW reset */ 702 /* TBD: SW reset */
diff --git a/drivers/ata/pata_winbond.c b/drivers/ata/pata_winbond.c
index 474528f8fe3..a7606b044a6 100644
--- a/drivers/ata/pata_winbond.c
+++ b/drivers/ata/pata_winbond.c
@@ -105,7 +105,7 @@ static unsigned int winbond_data_xfer(struct ata_device *dev,
105 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2); 105 iowrite32_rep(ap->ioaddr.data_addr, buf, buflen >> 2);
106 106
107 if (unlikely(slop)) { 107 if (unlikely(slop)) {
108 u32 pad; 108 __le32 pad;
109 if (rw == READ) { 109 if (rw == READ) {
110 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr)); 110 pad = cpu_to_le32(ioread32(ap->ioaddr.data_addr));
111 memcpy(buf + buflen - slop, &pad, slop); 111 memcpy(buf + buflen - slop, &pad, slop);
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 16aa6839aa5..fb13b82aacb 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -253,21 +253,29 @@ static void k2_bmdma_start_mmio(struct ata_queued_cmd *qc)
253 /* start host DMA transaction */ 253 /* start host DMA transaction */
254 dmactl = readb(mmio + ATA_DMA_CMD); 254 dmactl = readb(mmio + ATA_DMA_CMD);
255 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD); 255 writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
256 /* There is a race condition in certain SATA controllers that can 256 /* This works around possible data corruption.
257 be seen when the r/w command is given to the controller before the 257
258 host DMA is started. On a Read command, the controller would initiate 258 On certain SATA controllers that can be seen when the r/w
259 the command to the drive even before it sees the DMA start. When there 259 command is given to the controller before the host DMA is
260 are very fast drives connected to the controller, or when the data request 260 started.
261 hits in the drive cache, there is the possibility that the drive returns a part 261
262 or all of the requested data to the controller before the DMA start is issued. 262 On a Read command, the controller would initiate the
263 In this case, the controller would become confused as to what to do with the data. 263 command to the drive even before it sees the DMA
264 In the worst case when all the data is returned back to the controller, the 264 start. When there are very fast drives connected to the
265 controller could hang. In other cases it could return partial data returning 265 controller, or when the data request hits in the drive
266 in data corruption. This problem has been seen in PPC systems and can also appear 266 cache, there is the possibility that the drive returns a
267 on an system with very fast disks, where the SATA controller is sitting behind a 267 part or all of the requested data to the controller before
268 number of bridges, and hence there is significant latency between the r/w command 268 the DMA start is issued. In this case, the controller
269 and the start command. */ 269 would become confused as to what to do with the data. In
270 /* issue r/w command if the access is to ATA*/ 270 the worst case when all the data is returned back to the
271 controller, the controller could hang. In other cases it
272 could return partial data returning in data
273 corruption. This problem has been seen in PPC systems and
274 can also appear on an system with very fast disks, where
275 the SATA controller is sitting behind a number of bridges,
276 and hence there is significant latency between the r/w
277 command and the start command. */
278 /* issue r/w command if the access is to ATA */
271 if (qc->tf.protocol == ATA_PROT_DMA) 279 if (qc->tf.protocol == ATA_PROT_DMA)
272 ap->ops->sff_exec_command(ap, &qc->tf); 280 ap->ops->sff_exec_command(ap, &qc->tf);
273} 281}
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 1efe162e16d..3f6d9b0a6ab 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -93,47 +93,27 @@ static ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
93#define define_siblings_show_func(name) \ 93#define define_siblings_show_func(name) \
94 define_siblings_show_map(name); define_siblings_show_list(name) 94 define_siblings_show_map(name); define_siblings_show_list(name)
95 95
96#ifdef topology_physical_package_id
97define_id_show_func(physical_package_id); 96define_id_show_func(physical_package_id);
98define_one_ro(physical_package_id); 97define_one_ro(physical_package_id);
99#define ref_physical_package_id_attr &attr_physical_package_id.attr,
100#else
101#define ref_physical_package_id_attr
102#endif
103 98
104#ifdef topology_core_id
105define_id_show_func(core_id); 99define_id_show_func(core_id);
106define_one_ro(core_id); 100define_one_ro(core_id);
107#define ref_core_id_attr &attr_core_id.attr,
108#else
109#define ref_core_id_attr
110#endif
111 101
112#ifdef topology_thread_siblings
113define_siblings_show_func(thread_siblings); 102define_siblings_show_func(thread_siblings);
114define_one_ro(thread_siblings); 103define_one_ro(thread_siblings);
115define_one_ro(thread_siblings_list); 104define_one_ro(thread_siblings_list);
116#define ref_thread_siblings_attr \
117 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
118#else
119#define ref_thread_siblings_attr
120#endif
121 105
122#ifdef topology_core_siblings
123define_siblings_show_func(core_siblings); 106define_siblings_show_func(core_siblings);
124define_one_ro(core_siblings); 107define_one_ro(core_siblings);
125define_one_ro(core_siblings_list); 108define_one_ro(core_siblings_list);
126#define ref_core_siblings_attr \
127 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
128#else
129#define ref_core_siblings_attr
130#endif
131 109
132static struct attribute *default_attrs[] = { 110static struct attribute *default_attrs[] = {
133 ref_physical_package_id_attr 111 &attr_physical_package_id.attr,
134 ref_core_id_attr 112 &attr_core_id.attr,
135 ref_thread_siblings_attr 113 &attr_thread_siblings.attr,
136 ref_core_siblings_attr 114 &attr_thread_siblings_list.attr,
115 &attr_core_siblings.attr,
116 &attr_core_siblings_list.attr,
137 NULL 117 NULL
138}; 118};
139 119
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 570f3b70dce..5fdfa7c888c 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -712,19 +712,17 @@ static void do_pd_request(struct request_queue * q)
712static int pd_special_command(struct pd_unit *disk, 712static int pd_special_command(struct pd_unit *disk,
713 enum action (*func)(struct pd_unit *disk)) 713 enum action (*func)(struct pd_unit *disk))
714{ 714{
715 DECLARE_COMPLETION_ONSTACK(wait); 715 struct request *rq;
716 struct request rq;
717 int err = 0; 716 int err = 0;
718 717
719 blk_rq_init(NULL, &rq); 718 rq = blk_get_request(disk->gd->queue, READ, __GFP_WAIT);
720 rq.rq_disk = disk->gd; 719
721 rq.end_io_data = &wait; 720 rq->cmd_type = REQ_TYPE_SPECIAL;
722 rq.end_io = blk_end_sync_rq; 721 rq->special = func;
723 blk_insert_request(disk->gd->queue, &rq, 0, func); 722
724 wait_for_completion(&wait); 723 err = blk_execute_rq(disk->gd->queue, disk->gd, rq, 0);
725 if (rq.errors) 724
726 err = -EIO; 725 blk_put_request(rq);
727 blk_put_request(&rq);
728 return err; 726 return err;
729} 727}
730 728
diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 564daaa6c7d..eaa1a355bb3 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1249,7 +1249,7 @@ static void ipi_handler(void *null)
1249 1249
1250void global_cache_flush(void) 1250void global_cache_flush(void)
1251{ 1251{
1252 if (on_each_cpu(ipi_handler, NULL, 1, 1) != 0) 1252 if (on_each_cpu(ipi_handler, NULL, 1) != 0)
1253 panic(PFX "timed out waiting for the other CPUs!\n"); 1253 panic(PFX "timed out waiting for the other CPUs!\n");
1254} 1254}
1255EXPORT_SYMBOL(global_cache_flush); 1255EXPORT_SYMBOL(global_cache_flush);
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index dbce1263bdf..8fdfe9c871e 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -215,7 +215,7 @@ static void showacpu(void *dummy)
215 215
216static void sysrq_showregs_othercpus(struct work_struct *dummy) 216static void sysrq_showregs_othercpus(struct work_struct *dummy)
217{ 217{
218 smp_call_function(showacpu, NULL, 0, 0); 218 smp_call_function(showacpu, NULL, 0);
219} 219}
220 220
221static DECLARE_WORK(sysrq_showallcpus, sysrq_showregs_othercpus); 221static DECLARE_WORK(sysrq_showallcpus, sysrq_showregs_othercpus);
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 7b46faf2231..5ca1d80de18 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -215,3 +215,22 @@ pm_good:
215 * but we still need to load before device_initcall 215 * but we still need to load before device_initcall
216 */ 216 */
217fs_initcall(init_acpi_pm_clocksource); 217fs_initcall(init_acpi_pm_clocksource);
218
219/*
220 * Allow an override of the IOPort. Stupid BIOSes do not tell us about
221 * the PMTimer, but we might know where it is.
222 */
223static int __init parse_pmtmr(char *arg)
224{
225 unsigned long base;
226
227 if (strict_strtoul(arg, 16, &base))
228 return -EINVAL;
229
230 printk(KERN_INFO "PMTMR IOPort override: 0x%04x -> 0x%04lx\n",
231 (unsigned int)pmtmr_ioport, base);
232 pmtmr_ioport = base;
233
234 return 1;
235}
236__setup("pmtmr=", parse_pmtmr);
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 23554b676d6..5405769020a 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -340,7 +340,7 @@ static void smp_callback(void *v)
340static int cpuidle_latency_notify(struct notifier_block *b, 340static int cpuidle_latency_notify(struct notifier_block *b,
341 unsigned long l, void *v) 341 unsigned long l, void *v)
342{ 342{
343 smp_call_function(smp_callback, NULL, 0, 1); 343 smp_call_function(smp_callback, NULL, 1);
344 return NOTIFY_OK; 344 return NOTIFY_OK;
345} 345}
346 346
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 5b4c0d9f517..da873d795aa 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -16,12 +16,15 @@
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19#include <linux/module.h> 19#include <linux/completion.h>
20#include <linux/errno.h> 20#include <linux/crc-itu-t.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/device.h> 22#include <linux/device.h>
23#include <linux/errno.h>
24#include <linux/kref.h>
25#include <linux/module.h>
23#include <linux/mutex.h> 26#include <linux/mutex.h>
24#include <linux/crc-itu-t.h> 27
25#include "fw-transaction.h" 28#include "fw-transaction.h"
26#include "fw-topology.h" 29#include "fw-topology.h"
27#include "fw-device.h" 30#include "fw-device.h"
@@ -396,14 +399,16 @@ fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver,
396{ 399{
397 static atomic_t index = ATOMIC_INIT(-1); 400 static atomic_t index = ATOMIC_INIT(-1);
398 401
399 atomic_set(&card->device_count, 0);
400 card->index = atomic_inc_return(&index); 402 card->index = atomic_inc_return(&index);
401 card->driver = driver; 403 card->driver = driver;
402 card->device = device; 404 card->device = device;
403 card->current_tlabel = 0; 405 card->current_tlabel = 0;
404 card->tlabel_mask = 0; 406 card->tlabel_mask = 0;
405 card->color = 0; 407 card->color = 0;
408 card->broadcast_channel = BROADCAST_CHANNEL_INITIAL;
406 409
410 kref_init(&card->kref);
411 init_completion(&card->done);
407 INIT_LIST_HEAD(&card->transaction_list); 412 INIT_LIST_HEAD(&card->transaction_list);
408 spin_lock_init(&card->lock); 413 spin_lock_init(&card->lock);
409 setup_timer(&card->flush_timer, 414 setup_timer(&card->flush_timer,
@@ -496,7 +501,6 @@ dummy_enable_phys_dma(struct fw_card *card,
496} 501}
497 502
498static struct fw_card_driver dummy_driver = { 503static struct fw_card_driver dummy_driver = {
499 .name = "dummy",
500 .enable = dummy_enable, 504 .enable = dummy_enable,
501 .update_phy_reg = dummy_update_phy_reg, 505 .update_phy_reg = dummy_update_phy_reg,
502 .set_config_rom = dummy_set_config_rom, 506 .set_config_rom = dummy_set_config_rom,
@@ -507,6 +511,14 @@ static struct fw_card_driver dummy_driver = {
507}; 511};
508 512
509void 513void
514fw_card_release(struct kref *kref)
515{
516 struct fw_card *card = container_of(kref, struct fw_card, kref);
517
518 complete(&card->done);
519}
520
521void
510fw_core_remove_card(struct fw_card *card) 522fw_core_remove_card(struct fw_card *card)
511{ 523{
512 card->driver->update_phy_reg(card, 4, 524 card->driver->update_phy_reg(card, 4,
@@ -521,12 +533,10 @@ fw_core_remove_card(struct fw_card *card)
521 card->driver = &dummy_driver; 533 card->driver = &dummy_driver;
522 534
523 fw_destroy_nodes(card); 535 fw_destroy_nodes(card);
524 /* 536
525 * Wait for all device workqueue jobs to finish. Otherwise the 537 /* Wait for all users, especially device workqueue jobs, to finish. */
526 * firewire-core module could be unloaded before the jobs ran. 538 fw_card_put(card);
527 */ 539 wait_for_completion(&card->done);
528 while (atomic_read(&card->device_count) > 0)
529 msleep(100);
530 540
531 cancel_delayed_work_sync(&card->work); 541 cancel_delayed_work_sync(&card->work);
532 fw_flush_transactions(card); 542 fw_flush_transactions(card);
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index d9c8daf7ae7..0855fb5568e 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -168,7 +168,7 @@ static void fw_device_release(struct device *dev)
168 fw_node_put(device->node); 168 fw_node_put(device->node);
169 kfree(device->config_rom); 169 kfree(device->config_rom);
170 kfree(device); 170 kfree(device);
171 atomic_dec(&card->device_count); 171 fw_card_put(card);
172} 172}
173 173
174int fw_device_enable_phys_dma(struct fw_device *device) 174int fw_device_enable_phys_dma(struct fw_device *device)
@@ -946,8 +946,7 @@ void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
946 */ 946 */
947 device_initialize(&device->device); 947 device_initialize(&device->device);
948 atomic_set(&device->state, FW_DEVICE_INITIALIZING); 948 atomic_set(&device->state, FW_DEVICE_INITIALIZING);
949 atomic_inc(&card->device_count); 949 device->card = fw_card_get(card);
950 device->card = card;
951 device->node = fw_node_get(node); 950 device->node = fw_node_get(node);
952 device->node_id = node->node_id; 951 device->node_id = node->node_id;
953 device->generation = card->generation; 952 device->generation = card->generation;
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
index 5f131f5129d..42305bbac72 100644
--- a/drivers/firewire/fw-device.h
+++ b/drivers/firewire/fw-device.h
@@ -62,7 +62,6 @@ struct fw_device {
62 bool cmc; 62 bool cmc;
63 struct fw_card *card; 63 struct fw_card *card;
64 struct device device; 64 struct device device;
65 struct list_head link;
66 struct list_head client_list; 65 struct list_head client_list;
67 u32 *config_rom; 66 u32 *config_rom;
68 size_t config_rom_length; 67 size_t config_rom_length;
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index 0b66306af47..333b12544dd 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -2292,7 +2292,6 @@ ohci_queue_iso(struct fw_iso_context *base,
2292} 2292}
2293 2293
2294static const struct fw_card_driver ohci_driver = { 2294static const struct fw_card_driver ohci_driver = {
2295 .name = ohci_driver_name,
2296 .enable = ohci_enable, 2295 .enable = ohci_enable,
2297 .update_phy_reg = ohci_update_phy_reg, 2296 .update_phy_reg = ohci_update_phy_reg,
2298 .set_config_rom = ohci_set_config_rom, 2297 .set_config_rom = ohci_set_config_rom,
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index 227d2e036cd..53fc5a641e6 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -86,6 +86,11 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
86 * - delay inquiry 86 * - delay inquiry
87 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry. 87 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
88 * 88 *
89 * - power condition
90 * Set the power condition field in the START STOP UNIT commands sent by
91 * sd_mod on suspend, resume, and shutdown (if manage_start_stop is on).
92 * Some disks need this to spin down or to resume properly.
93 *
89 * - override internal blacklist 94 * - override internal blacklist
90 * Instead of adding to the built-in blacklist, use only the workarounds 95 * Instead of adding to the built-in blacklist, use only the workarounds
91 * specified in the module load parameter. 96 * specified in the module load parameter.
@@ -97,6 +102,7 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
97#define SBP2_WORKAROUND_FIX_CAPACITY 0x8 102#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
98#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10 103#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10
99#define SBP2_INQUIRY_DELAY 12 104#define SBP2_INQUIRY_DELAY 12
105#define SBP2_WORKAROUND_POWER_CONDITION 0x20
100#define SBP2_WORKAROUND_OVERRIDE 0x100 106#define SBP2_WORKAROUND_OVERRIDE 0x100
101 107
102static int sbp2_param_workarounds; 108static int sbp2_param_workarounds;
@@ -107,6 +113,8 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
107 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8) 113 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
108 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY) 114 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
109 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY) 115 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
116 ", set power condition in start stop unit = "
117 __stringify(SBP2_WORKAROUND_POWER_CONDITION)
110 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 118 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
111 ", or a combination)"); 119 ", or a combination)");
112 120
@@ -310,18 +318,25 @@ static const struct {
310 .firmware_revision = 0x002800, 318 .firmware_revision = 0x002800,
311 .model = 0x001010, 319 .model = 0x001010,
312 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 320 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
313 SBP2_WORKAROUND_MODE_SENSE_8, 321 SBP2_WORKAROUND_MODE_SENSE_8 |
322 SBP2_WORKAROUND_POWER_CONDITION,
314 }, 323 },
315 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ { 324 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
316 .firmware_revision = 0x002800, 325 .firmware_revision = 0x002800,
317 .model = 0x000000, 326 .model = 0x000000,
318 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY, 327 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY |
328 SBP2_WORKAROUND_POWER_CONDITION,
319 }, 329 },
320 /* Initio bridges, actually only needed for some older ones */ { 330 /* Initio bridges, actually only needed for some older ones */ {
321 .firmware_revision = 0x000200, 331 .firmware_revision = 0x000200,
322 .model = ~0, 332 .model = ~0,
323 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 333 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
324 }, 334 },
335 /* PL-3507 bridge with Prolific firmware */ {
336 .firmware_revision = 0x012800,
337 .model = ~0,
338 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
339 },
325 /* Symbios bridge */ { 340 /* Symbios bridge */ {
326 .firmware_revision = 0xa0b800, 341 .firmware_revision = 0xa0b800,
327 .model = ~0, 342 .model = ~0,
@@ -1530,6 +1545,9 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1530 1545
1531 sdev->use_10_for_rw = 1; 1546 sdev->use_10_for_rw = 1;
1532 1547
1548 if (sbp2_param_exclusive_login)
1549 sdev->manage_start_stop = 1;
1550
1533 if (sdev->type == TYPE_ROM) 1551 if (sdev->type == TYPE_ROM)
1534 sdev->use_10_for_ms = 1; 1552 sdev->use_10_for_ms = 1;
1535 1553
@@ -1540,6 +1558,9 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1540 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) 1558 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
1541 sdev->fix_capacity = 1; 1559 sdev->fix_capacity = 1;
1542 1560
1561 if (lu->tgt->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
1562 sdev->start_stop_pwr_cond = 1;
1563
1543 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 1564 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1544 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 1565 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
1545 1566
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index 03ae8a77c47..40db8075227 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -55,6 +55,9 @@
55#define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff) 55#define HEADER_GET_DATA_LENGTH(q) (((q) >> 16) & 0xffff)
56#define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff) 56#define HEADER_GET_EXTENDED_TCODE(q) (((q) >> 0) & 0xffff)
57 57
58#define HEADER_DESTINATION_IS_BROADCAST(q) \
59 (((q) & HEADER_DESTINATION(0x3f)) == HEADER_DESTINATION(0x3f))
60
58#define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22)) 61#define PHY_CONFIG_GAP_COUNT(gap_count) (((gap_count) << 16) | (1 << 22))
59#define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23)) 62#define PHY_CONFIG_ROOT_ID(node_id) ((((node_id) & 0x3f) << 24) | (1 << 23))
60#define PHY_IDENTIFIER(id) ((id) << 30) 63#define PHY_IDENTIFIER(id) ((id) << 30)
@@ -624,12 +627,9 @@ allocate_request(struct fw_packet *p)
624void 627void
625fw_send_response(struct fw_card *card, struct fw_request *request, int rcode) 628fw_send_response(struct fw_card *card, struct fw_request *request, int rcode)
626{ 629{
627 /* 630 /* unified transaction or broadcast transaction: don't respond */
628 * Broadcast packets are reported as ACK_COMPLETE, so this 631 if (request->ack != ACK_PENDING ||
629 * check is sufficient to ensure we don't send response to 632 HEADER_DESTINATION_IS_BROADCAST(request->request_header[0])) {
630 * broadcast packets or posted writes.
631 */
632 if (request->ack != ACK_PENDING) {
633 kfree(request); 633 kfree(request);
634 return; 634 return;
635 } 635 }
@@ -817,12 +817,13 @@ handle_registers(struct fw_card *card, struct fw_request *request,
817 int reg = offset & ~CSR_REGISTER_BASE; 817 int reg = offset & ~CSR_REGISTER_BASE;
818 unsigned long long bus_time; 818 unsigned long long bus_time;
819 __be32 *data = payload; 819 __be32 *data = payload;
820 int rcode = RCODE_COMPLETE;
820 821
821 switch (reg) { 822 switch (reg) {
822 case CSR_CYCLE_TIME: 823 case CSR_CYCLE_TIME:
823 case CSR_BUS_TIME: 824 case CSR_BUS_TIME:
824 if (!TCODE_IS_READ_REQUEST(tcode) || length != 4) { 825 if (!TCODE_IS_READ_REQUEST(tcode) || length != 4) {
825 fw_send_response(card, request, RCODE_TYPE_ERROR); 826 rcode = RCODE_TYPE_ERROR;
826 break; 827 break;
827 } 828 }
828 829
@@ -831,7 +832,17 @@ handle_registers(struct fw_card *card, struct fw_request *request,
831 *data = cpu_to_be32(bus_time); 832 *data = cpu_to_be32(bus_time);
832 else 833 else
833 *data = cpu_to_be32(bus_time >> 25); 834 *data = cpu_to_be32(bus_time >> 25);
834 fw_send_response(card, request, RCODE_COMPLETE); 835 break;
836
837 case CSR_BROADCAST_CHANNEL:
838 if (tcode == TCODE_READ_QUADLET_REQUEST)
839 *data = cpu_to_be32(card->broadcast_channel);
840 else if (tcode == TCODE_WRITE_QUADLET_REQUEST)
841 card->broadcast_channel =
842 (be32_to_cpu(*data) & BROADCAST_CHANNEL_VALID) |
843 BROADCAST_CHANNEL_INITIAL;
844 else
845 rcode = RCODE_TYPE_ERROR;
835 break; 846 break;
836 847
837 case CSR_BUS_MANAGER_ID: 848 case CSR_BUS_MANAGER_ID:
@@ -850,10 +861,13 @@ handle_registers(struct fw_card *card, struct fw_request *request,
850 861
851 case CSR_BUSY_TIMEOUT: 862 case CSR_BUSY_TIMEOUT:
852 /* FIXME: Implement this. */ 863 /* FIXME: Implement this. */
864
853 default: 865 default:
854 fw_send_response(card, request, RCODE_ADDRESS_ERROR); 866 rcode = RCODE_ADDRESS_ERROR;
855 break; 867 break;
856 } 868 }
869
870 fw_send_response(card, request, rcode);
857} 871}
858 872
859static struct fw_address_handler registers = { 873static struct fw_address_handler registers = {
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 04d3854f656..2ae1b0d6cb7 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -19,14 +19,15 @@
19#ifndef __fw_transaction_h 19#ifndef __fw_transaction_h
20#define __fw_transaction_h 20#define __fw_transaction_h
21 21
22#include <linux/completion.h>
22#include <linux/device.h> 23#include <linux/device.h>
23#include <linux/timer.h>
24#include <linux/interrupt.h>
25#include <linux/list.h>
26#include <linux/fs.h>
27#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
28#include <linux/firewire-constants.h> 25#include <linux/firewire-constants.h>
29#include <asm/atomic.h> 26#include <linux/kref.h>
27#include <linux/list.h>
28#include <linux/spinlock_types.h>
29#include <linux/timer.h>
30#include <linux/workqueue.h>
30 31
31#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4) 32#define TCODE_IS_READ_REQUEST(tcode) (((tcode) & ~1) == 4)
32#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0) 33#define TCODE_IS_BLOCK_PACKET(tcode) (((tcode) & 1) != 0)
@@ -80,6 +81,9 @@
80#define CSR_SPEED_MAP 0x2000 81#define CSR_SPEED_MAP 0x2000
81#define CSR_SPEED_MAP_END 0x3000 82#define CSR_SPEED_MAP_END 0x3000
82 83
84#define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31)
85#define BROADCAST_CHANNEL_VALID (1 << 30)
86
83#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) 87#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args)
84#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) 88#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
85 89
@@ -216,7 +220,8 @@ extern struct bus_type fw_bus_type;
216struct fw_card { 220struct fw_card {
217 const struct fw_card_driver *driver; 221 const struct fw_card_driver *driver;
218 struct device *device; 222 struct device *device;
219 atomic_t device_count; 223 struct kref kref;
224 struct completion done;
220 225
221 int node_id; 226 int node_id;
222 int generation; 227 int generation;
@@ -236,6 +241,7 @@ struct fw_card {
236 */ 241 */
237 int self_id_count; 242 int self_id_count;
238 u32 topology_map[252 + 3]; 243 u32 topology_map[252 + 3];
244 u32 broadcast_channel;
239 245
240 spinlock_t lock; /* Take this lock when handling the lists in 246 spinlock_t lock; /* Take this lock when handling the lists in
241 * this struct. */ 247 * this struct. */
@@ -256,6 +262,20 @@ struct fw_card {
256 int bm_generation; 262 int bm_generation;
257}; 263};
258 264
265static inline struct fw_card *fw_card_get(struct fw_card *card)
266{
267 kref_get(&card->kref);
268
269 return card;
270}
271
272void fw_card_release(struct kref *kref);
273
274static inline void fw_card_put(struct fw_card *card)
275{
276 kref_put(&card->kref, fw_card_release);
277}
278
259/* 279/*
260 * The iso packet format allows for an immediate header/payload part 280 * The iso packet format allows for an immediate header/payload part
261 * stored in 'header' immediately after the packet info plus an 281 * stored in 'header' immediately after the packet info plus an
@@ -348,8 +368,6 @@ int
348fw_iso_context_stop(struct fw_iso_context *ctx); 368fw_iso_context_stop(struct fw_iso_context *ctx);
349 369
350struct fw_card_driver { 370struct fw_card_driver {
351 const char *name;
352
353 /* 371 /*
354 * Enable the given card with the given initial config rom. 372 * Enable the given card with the given initial config rom.
355 * This function is expected to activate the card, and either 373 * This function is expected to activate the card, and either
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 845081b44f6..0177012845c 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -167,6 +167,11 @@ void drm_core_ioremap(struct drm_map *map, struct drm_device *dev)
167} 167}
168EXPORT_SYMBOL(drm_core_ioremap); 168EXPORT_SYMBOL(drm_core_ioremap);
169 169
170void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev)
171{
172 map->handle = ioremap_wc(map->offset, map->size);
173}
174EXPORT_SYMBOL(drm_core_ioremap_wc);
170void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) 175void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
171{ 176{
172 if (!map->handle || !map->size) 177 if (!map->handle || !map->size)
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index e53158f0ecb..f0de81a5689 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -1154,7 +1154,7 @@ static int radeon_do_init_cp(struct drm_device * dev, drm_radeon_init_t * init)
1154 dev_priv->gart_info.mapping.size = 1154 dev_priv->gart_info.mapping.size =
1155 dev_priv->gart_info.table_size; 1155 dev_priv->gart_info.table_size;
1156 1156
1157 drm_core_ioremap(&dev_priv->gart_info.mapping, dev); 1157 drm_core_ioremap_wc(&dev_priv->gart_info.mapping, dev);
1158 dev_priv->gart_info.addr = 1158 dev_priv->gart_info.addr =
1159 dev_priv->gart_info.mapping.handle; 1159 dev_priv->gart_info.mapping.handle;
1160 1160
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 35812823787..eb8f72ca02f 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -320,7 +320,7 @@ static int try_address(struct i2c_adapter *i2c_adap,
320 unsigned char addr, int retries) 320 unsigned char addr, int retries)
321{ 321{
322 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 322 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
323 int i, ret = -1; 323 int i, ret = 0;
324 324
325 for (i = 0; i <= retries; i++) { 325 for (i = 0; i <= retries; i++) {
326 ret = i2c_outb(i2c_adap, addr); 326 ret = i2c_outb(i2c_adap, addr);
@@ -508,7 +508,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
508 addr ^= 1; 508 addr ^= 1;
509 ret = try_address(i2c_adap, addr, retries); 509 ret = try_address(i2c_adap, addr, retries);
510 if ((ret != 1) && !nak_ok) 510 if ((ret != 1) && !nak_ok)
511 return -EREMOTEIO; 511 return -ENXIO;
512 } 512 }
513 513
514 return 0; 514 return 0;
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index e954a20b97a..d50b329a3c9 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -182,7 +182,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
182 } 182 }
183 if (state != 0xf8) { 183 if (state != 0xf8) {
184 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state); 184 dev_dbg(&i2c_adap->dev, "bus is not idle. status is %#04x\n", state);
185 return -EIO; 185 return -EAGAIN;
186 } 186 }
187 187
188 DEB1("{{{ XFER %d messages\n", num); 188 DEB1("{{{ XFER %d messages\n", num);
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 8907b019167..1e328d19cd6 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -78,6 +78,36 @@ static void i2c_stop(struct i2c_algo_pcf_data *adap)
78 set_pcf(adap, 1, I2C_PCF_STOP); 78 set_pcf(adap, 1, I2C_PCF_STOP);
79} 79}
80 80
81static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
82{
83 DEB2(printk(KERN_INFO
84 "i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
85 *status));
86
87 /* Cleanup from LAB -- reset and enable ESO.
88 * This resets the PCF8584; since we've lost the bus, no
89 * further attempts should be made by callers to clean up
90 * (no i2c_stop() etc.)
91 */
92 set_pcf(adap, 1, I2C_PCF_PIN);
93 set_pcf(adap, 1, I2C_PCF_ESO);
94
95 /* We pause for a time period sufficient for any running
96 * I2C transaction to complete -- the arbitration logic won't
97 * work properly until the next START is seen.
98 * It is assumed the bus driver or client has set a proper value.
99 *
100 * REVISIT: should probably use msleep instead of mdelay if we
101 * know we can sleep.
102 */
103 if (adap->lab_mdelay)
104 mdelay(adap->lab_mdelay);
105
106 DEB2(printk(KERN_INFO
107 "i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
108 get_pcf(adap, 1)));
109}
110
81static int wait_for_bb(struct i2c_algo_pcf_data *adap) { 111static int wait_for_bb(struct i2c_algo_pcf_data *adap) {
82 112
83 int timeout = DEF_TIMEOUT; 113 int timeout = DEF_TIMEOUT;
@@ -109,23 +139,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) {
109 *status = get_pcf(adap, 1); 139 *status = get_pcf(adap, 1);
110 } 140 }
111 if (*status & I2C_PCF_LAB) { 141 if (*status & I2C_PCF_LAB) {
112 DEB2(printk(KERN_INFO 142 handle_lab(adap, status);
113 "i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
114 *status));
115 /* Cleanup from LAB-- reset and enable ESO.
116 * This resets the PCF8584; since we've lost the bus, no
117 * further attempts should be made by callers to clean up
118 * (no i2c_stop() etc.)
119 */
120 set_pcf(adap, 1, I2C_PCF_PIN);
121 set_pcf(adap, 1, I2C_PCF_ESO);
122 /* TODO: we should pause for a time period sufficient for any
123 * running I2C transaction to complete-- the arbitration
124 * logic won't work properly until the next START is seen.
125 */
126 DEB2(printk(KERN_INFO
127 "i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
128 get_pcf(adap,1)));
129 return(-EINTR); 143 return(-EINTR);
130 } 144 }
131#endif 145#endif
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 48438cc5d0c..6ee997b2817 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -4,6 +4,9 @@
4 4
5menu "I2C Hardware Bus support" 5menu "I2C Hardware Bus support"
6 6
7comment "PC SMBus host controller drivers"
8 depends on PCI
9
7config I2C_ALI1535 10config I2C_ALI1535
8 tristate "ALI 1535" 11 tristate "ALI 1535"
9 depends on PCI 12 depends on PCI
@@ -73,6 +76,186 @@ config I2C_AMD8111
73 This driver can also be built as a module. If so, the module 76 This driver can also be built as a module. If so, the module
74 will be called i2c-amd8111. 77 will be called i2c-amd8111.
75 78
79config I2C_I801
80 tristate "Intel 82801 (ICH)"
81 depends on PCI
82 help
83 If you say yes to this option, support will be included for the Intel
84 801 family of mainboard I2C interfaces. Specifically, the following
85 versions of the chipset are supported:
86 82801AA
87 82801AB
88 82801BA
89 82801CA/CAM
90 82801DB
91 82801EB/ER (ICH5/ICH5R)
92 6300ESB
93 ICH6
94 ICH7
95 ESB2
96 ICH8
97 ICH9
98 Tolapai
99 ICH10
100
101 This driver can also be built as a module. If so, the module
102 will be called i2c-i801.
103
104config I2C_ISCH
105 tristate "Intel SCH SMBus 1.0"
106 depends on PCI
107 help
108 Say Y here if you want to use SMBus controller on the Intel SCH
109 based systems.
110
111 This driver can also be built as a module. If so, the module
112 will be called i2c-isch.
113
114config I2C_PIIX4
115 tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)"
116 depends on PCI
117 help
118 If you say yes to this option, support will be included for the Intel
119 PIIX4 family of mainboard I2C interfaces. Specifically, the following
120 versions of the chipset are supported (note that Serverworks is part
121 of Broadcom):
122 Intel PIIX4
123 Intel 440MX
124 ATI IXP200
125 ATI IXP300
126 ATI IXP400
127 ATI SB600
128 ATI SB700
129 ATI SB800
130 Serverworks OSB4
131 Serverworks CSB5
132 Serverworks CSB6
133 Serverworks HT-1000
134 SMSC Victory66
135
136 This driver can also be built as a module. If so, the module
137 will be called i2c-piix4.
138
139config I2C_NFORCE2
140 tristate "Nvidia nForce2, nForce3 and nForce4"
141 depends on PCI
142 help
143 If you say yes to this option, support will be included for the Nvidia
144 nForce2, nForce3 and nForce4 families of mainboard I2C interfaces.
145
146 This driver can also be built as a module. If so, the module
147 will be called i2c-nforce2.
148
149config I2C_NFORCE2_S4985
150 tristate "SMBus multiplexing on the Tyan S4985"
151 depends on I2C_NFORCE2 && EXPERIMENTAL
152 help
153 Enabling this option will add specific SMBus support for the Tyan
154 S4985 motherboard. On this 4-CPU board, the SMBus is multiplexed
155 over 4 different channels, where the various memory module EEPROMs
156 live. Saying yes here will give you access to these in addition
157 to the trunk.
158
159 This driver can also be built as a module. If so, the module
160 will be called i2c-nforce2-s4985.
161
162config I2C_SIS5595
163 tristate "SiS 5595"
164 depends on PCI
165 help
166 If you say yes to this option, support will be included for the
167 SiS5595 SMBus (a subset of I2C) interface.
168
169 This driver can also be built as a module. If so, the module
170 will be called i2c-sis5595.
171
172config I2C_SIS630
173 tristate "SiS 630/730"
174 depends on PCI
175 help
176 If you say yes to this option, support will be included for the
177 SiS630 and SiS730 SMBus (a subset of I2C) interface.
178
179 This driver can also be built as a module. If so, the module
180 will be called i2c-sis630.
181
182config I2C_SIS96X
183 tristate "SiS 96x"
184 depends on PCI
185 help
186 If you say yes to this option, support will be included for the SiS
187 96x SMBus (a subset of I2C) interfaces. Specifically, the following
188 chipsets are supported:
189 645/961
190 645DX/961
191 645DX/962
192 648/961
193 650/961
194 735
195 745
196
197 This driver can also be built as a module. If so, the module
198 will be called i2c-sis96x.
199
200config I2C_VIA
201 tristate "VIA VT82C586B"
202 depends on PCI && EXPERIMENTAL
203 select I2C_ALGOBIT
204 help
205 If you say yes to this option, support will be included for the VIA
206 82C586B I2C interface
207
208 This driver can also be built as a module. If so, the module
209 will be called i2c-via.
210
211config I2C_VIAPRO
212 tristate "VIA VT82C596/82C686/82xx and CX700"
213 depends on PCI
214 help
215 If you say yes to this option, support will be included for the VIA
216 VT82C596 and later SMBus interface. Specifically, the following
217 chipsets are supported:
218 VT82C596A/B
219 VT82C686A/B
220 VT8231
221 VT8233/A
222 VT8235
223 VT8237R/A/S
224 VT8251
225 CX700
226
227 This driver can also be built as a module. If so, the module
228 will be called i2c-viapro.
229
230comment "Mac SMBus host controller drivers"
231 depends on PPC_CHRP || PPC_PMAC
232
233config I2C_HYDRA
234 tristate "CHRP Apple Hydra Mac I/O I2C interface"
235 depends on PCI && PPC_CHRP && EXPERIMENTAL
236 select I2C_ALGOBIT
237 help
238 This supports the use of the I2C interface in the Apple Hydra Mac
239 I/O chip on some CHRP machines (e.g. the LongTrail). Say Y if you
240 have such a machine.
241
242 This support is also available as a module. If so, the module
243 will be called i2c-hydra.
244
245config I2C_POWERMAC
246 tristate "Powermac I2C interface"
247 depends on PPC_PMAC
248 default y
249 help
250 This exposes the various PowerMac i2c interfaces to the linux i2c
251 layer and to userland. It is used by various drivers on the PowerMac
252 platform, and should generally be enabled.
253
254 This support is also available as a module. If so, the module
255 will be called i2c-powermac.
256
257comment "I2C system bus drivers (mostly embedded / system-on-chip)"
258
76config I2C_AT91 259config I2C_AT91
77 tristate "Atmel AT91 I2C Two-Wire interface (TWI)" 260 tristate "Atmel AT91 I2C Two-Wire interface (TWI)"
78 depends on ARCH_AT91 && EXPERIMENTAL && BROKEN 261 depends on ARCH_AT91 && EXPERIMENTAL && BROKEN
@@ -101,10 +284,9 @@ config I2C_AU1550
101config I2C_BLACKFIN_TWI 284config I2C_BLACKFIN_TWI
102 tristate "Blackfin TWI I2C support" 285 tristate "Blackfin TWI I2C support"
103 depends on BLACKFIN 286 depends on BLACKFIN
287 depends on !BF561 && !BF531 && !BF532 && !BF533
104 help 288 help
105 This is the TWI I2C device driver for Blackfin BF522, BF525, 289 This is the I2C bus driver for Blackfin on-chip TWI interface.
106 BF527, BF534, BF536, BF537 and BF54x. For other Blackfin processors,
107 please don't use this driver.
108 290
109 This driver can also be built as a module. If so, the module 291 This driver can also be built as a module. If so, the module
110 will be called i2c-bfin-twi. 292 will be called i2c-bfin-twi.
@@ -117,6 +299,16 @@ config I2C_BLACKFIN_TWI_CLK_KHZ
117 help 299 help
118 The unit of the TWI clock is kHz. 300 The unit of the TWI clock is kHz.
119 301
302config I2C_CPM
303 tristate "Freescale CPM1 or CPM2 (MPC8xx/826x)"
304 depends on (CPM1 || CPM2) && OF_I2C
305 help
306 This supports the use of the I2C interface on Freescale
307 processors with CPM1 or CPM2.
308
309 This driver can also be built as a module. If so, the module
310 will be called i2c-cpm.
311
120config I2C_DAVINCI 312config I2C_DAVINCI
121 tristate "DaVinci I2C driver" 313 tristate "DaVinci I2C driver"
122 depends on ARCH_DAVINCI 314 depends on ARCH_DAVINCI
@@ -130,17 +322,6 @@ config I2C_DAVINCI
130 devices such as DaVinci NIC. 322 devices such as DaVinci NIC.
131 For details please see http://www.ti.com/davinci 323 For details please see http://www.ti.com/davinci
132 324
133config I2C_ELEKTOR
134 tristate "Elektor ISA card"
135 depends on ISA && BROKEN_ON_SMP
136 select I2C_ALGOPCF
137 help
138 This supports the PCF8584 ISA bus I2C adapter. Say Y if you own
139 such an adapter.
140
141 This support is also available as a module. If so, the module
142 will be called i2c-elektor.
143
144config I2C_GPIO 325config I2C_GPIO
145 tristate "GPIO-based bitbanging I2C" 326 tristate "GPIO-based bitbanging I2C"
146 depends on GENERIC_GPIO 327 depends on GENERIC_GPIO
@@ -149,104 +330,6 @@ config I2C_GPIO
149 This is a very simple bitbanging I2C driver utilizing the 330 This is a very simple bitbanging I2C driver utilizing the
150 arch-neutral GPIO API to control the SCL and SDA lines. 331 arch-neutral GPIO API to control the SCL and SDA lines.
151 332
152config I2C_HYDRA
153 tristate "CHRP Apple Hydra Mac I/O I2C interface"
154 depends on PCI && PPC_CHRP && EXPERIMENTAL
155 select I2C_ALGOBIT
156 help
157 This supports the use of the I2C interface in the Apple Hydra Mac
158 I/O chip on some CHRP machines (e.g. the LongTrail). Say Y if you
159 have such a machine.
160
161 This support is also available as a module. If so, the module
162 will be called i2c-hydra.
163
164config I2C_I801
165 tristate "Intel 82801 (ICH)"
166 depends on PCI
167 help
168 If you say yes to this option, support will be included for the Intel
169 801 family of mainboard I2C interfaces. Specifically, the following
170 versions of the chipset are supported:
171 82801AA
172 82801AB
173 82801BA
174 82801CA/CAM
175 82801DB
176 82801EB/ER (ICH5/ICH5R)
177 6300ESB
178 ICH6
179 ICH7
180 ESB2
181 ICH8
182 ICH9
183 Tolapai
184 ICH10
185
186 This driver can also be built as a module. If so, the module
187 will be called i2c-i801.
188
189config I2C_I810
190 tristate "Intel 810/815 (DEPRECATED)"
191 default n
192 depends on PCI
193 select I2C_ALGOBIT
194 help
195 If you say yes to this option, support will be included for the Intel
196 810/815 family of mainboard I2C interfaces. Specifically, the
197 following versions of the chipset are supported:
198 i810AA
199 i810AB
200 i810E
201 i815
202 i845G
203
204 This driver is deprecated in favor of the i810fb and intelfb drivers.
205
206 This driver can also be built as a module. If so, the module
207 will be called i2c-i810.
208
209config I2C_PXA
210 tristate "Intel PXA2XX I2C adapter (EXPERIMENTAL)"
211 depends on EXPERIMENTAL && ARCH_PXA
212 help
213 If you have devices in the PXA I2C bus, say yes to this option.
214 This driver can also be built as a module. If so, the module
215 will be called i2c-pxa.
216
217config I2C_PXA_SLAVE
218 bool "Intel PXA2XX I2C Slave comms support"
219 depends on I2C_PXA
220 help
221 Support I2C slave mode communications on the PXA I2C bus. This
222 is necessary for systems where the PXA may be a target on the
223 I2C bus.
224
225config I2C_PIIX4
226 tristate "Intel PIIX4 and compatible (ATI/Serverworks/Broadcom/SMSC)"
227 depends on PCI
228 help
229 If you say yes to this option, support will be included for the Intel
230 PIIX4 family of mainboard I2C interfaces. Specifically, the following
231 versions of the chipset are supported (note that Serverworks is part
232 of Broadcom):
233 Intel PIIX4
234 Intel 440MX
235 ATI IXP200
236 ATI IXP300
237 ATI IXP400
238 ATI SB600
239 ATI SB700
240 ATI SB800
241 Serverworks OSB4
242 Serverworks CSB5
243 Serverworks CSB6
244 Serverworks HT-1000
245 SMSC Victory66
246
247 This driver can also be built as a module. If so, the module
248 will be called i2c-piix4.
249
250config I2C_IBM_IIC 333config I2C_IBM_IIC
251 tristate "IBM PPC 4xx on-chip I2C interface" 334 tristate "IBM PPC 4xx on-chip I2C interface"
252 depends on 4xx 335 depends on 4xx
@@ -281,18 +364,6 @@ config I2C_IXP2000
281 This driver is deprecated and will be dropped soon. Use i2c-gpio 364 This driver is deprecated and will be dropped soon. Use i2c-gpio
282 instead. 365 instead.
283 366
284config I2C_POWERMAC
285 tristate "Powermac I2C interface"
286 depends on PPC_PMAC
287 default y
288 help
289 This exposes the various PowerMac i2c interfaces to the linux i2c
290 layer and to userland. It is used by various drivers on the PowerMac
291 platform, and should generally be enabled.
292
293 This support is also available as a module. If so, the module
294 will be called i2c-powermac.
295
296config I2C_MPC 367config I2C_MPC
297 tristate "MPC107/824x/85xx/52xx/86xx" 368 tristate "MPC107/824x/85xx/52xx/86xx"
298 depends on PPC32 369 depends on PPC32
@@ -305,15 +376,15 @@ config I2C_MPC
305 This driver can also be built as a module. If so, the module 376 This driver can also be built as a module. If so, the module
306 will be called i2c-mpc. 377 will be called i2c-mpc.
307 378
308config I2C_NFORCE2 379config I2C_MV64XXX
309 tristate "Nvidia nForce2, nForce3 and nForce4" 380 tristate "Marvell mv64xxx I2C Controller"
310 depends on PCI 381 depends on (MV64X60 || PLAT_ORION) && EXPERIMENTAL
311 help 382 help
312 If you say yes to this option, support will be included for the Nvidia 383 If you say yes to this option, support will be included for the
313 nForce2, nForce3 and nForce4 families of mainboard I2C interfaces. 384 built-in I2C interface on the Marvell 64xxx line of host bridges.
314 385
315 This driver can also be built as a module. If so, the module 386 This driver can also be built as a module. If so, the module
316 will be called i2c-nforce2. 387 will be called i2c-mv64xxx.
317 388
318config I2C_OCORES 389config I2C_OCORES
319 tristate "OpenCores I2C Controller" 390 tristate "OpenCores I2C Controller"
@@ -336,76 +407,37 @@ config I2C_OMAP
336 Like OMAP1510/1610/1710/5912 and OMAP242x. 407 Like OMAP1510/1610/1710/5912 and OMAP242x.
337 For details see http://www.ti.com/omap. 408 For details see http://www.ti.com/omap.
338 409
339config I2C_PARPORT
340 tristate "Parallel port adapter"
341 depends on PARPORT
342 select I2C_ALGOBIT
343 help
344 This supports parallel port I2C adapters such as the ones made by
345 Philips or Velleman, Analog Devices evaluation boards, and more.
346 Basically any adapter using the parallel port as an I2C bus with
347 no extra chipset is supported by this driver, or could be.
348
349 This driver is a replacement for (and was inspired by) an older
350 driver named i2c-philips-par. The new driver supports more devices,
351 and makes it easier to add support for new devices.
352
353 An adapter type parameter is now mandatory. Please read the file
354 Documentation/i2c/busses/i2c-parport for details.
355
356 Another driver exists, named i2c-parport-light, which doesn't depend
357 on the parport driver. This is meant for embedded systems. Don't say
358 Y here if you intend to say Y or M there.
359
360 This support is also available as a module. If so, the module
361 will be called i2c-parport.
362
363config I2C_PARPORT_LIGHT
364 tristate "Parallel port adapter (light)"
365 select I2C_ALGOBIT
366 help
367 This supports parallel port I2C adapters such as the ones made by
368 Philips or Velleman, Analog Devices evaluation boards, and more.
369 Basically any adapter using the parallel port as an I2C bus with
370 no extra chipset is supported by this driver, or could be.
371
372 This driver is a light version of i2c-parport. It doesn't depend
373 on the parport driver, and uses direct I/O access instead. This
374 might be preferred on embedded systems where wasting memory for
375 the clean but heavy parport handling is not an option. The
376 drawback is a reduced portability and the impossibility to
377 daisy-chain other parallel port devices.
378
379 Don't say Y here if you said Y or M to i2c-parport. Saying M to
380 both is possible but both modules should not be loaded at the same
381 time.
382
383 This support is also available as a module. If so, the module
384 will be called i2c-parport-light.
385
386config I2C_PASEMI 410config I2C_PASEMI
387 tristate "PA Semi SMBus interface" 411 tristate "PA Semi SMBus interface"
388 depends on PPC_PASEMI && PCI 412 depends on PPC_PASEMI && PCI
389 help 413 help
390 Supports the PA Semi PWRficient on-chip SMBus interfaces. 414 Supports the PA Semi PWRficient on-chip SMBus interfaces.
391 415
392config I2C_PROSAVAGE 416config I2C_PNX
393 tristate "S3/VIA (Pro)Savage (DEPRECATED)" 417 tristate "I2C bus support for Philips PNX targets"
394 default n 418 depends on ARCH_PNX4008
395 depends on PCI
396 select I2C_ALGOBIT
397 help 419 help
398 If you say yes to this option, support will be included for the 420 This driver supports the Philips IP3204 I2C IP block master and/or
399 I2C bus and DDC bus of the S3VIA embedded Savage4 and ProSavage8 421 slave controller
400 graphics processors.
401 chipsets supported:
402 S3/VIA KM266/VT8375 aka ProSavage8
403 S3/VIA KM133/VT8365 aka Savage4
404 422
405 This driver is deprecated in favor of the savagefb driver. 423 This driver can also be built as a module. If so, the module
424 will be called i2c-pnx.
406 425
407 This support is also available as a module. If so, the module 426config I2C_PXA
408 will be called i2c-prosavage. 427 tristate "Intel PXA2XX I2C adapter (EXPERIMENTAL)"
428 depends on EXPERIMENTAL && ARCH_PXA
429 help
430 If you have devices in the PXA I2C bus, say yes to this option.
431 This driver can also be built as a module. If so, the module
432 will be called i2c-pxa.
433
434config I2C_PXA_SLAVE
435 bool "Intel PXA2XX I2C Slave comms support"
436 depends on I2C_PXA
437 help
438 Support I2C slave mode communications on the PXA I2C bus. This
439 is necessary for systems where the PXA may be a target on the
440 I2C bus.
409 441
410config I2C_S3C2410 442config I2C_S3C2410
411 tristate "S3C2410 I2C Driver" 443 tristate "S3C2410 I2C Driver"
@@ -414,25 +446,24 @@ config I2C_S3C2410
414 Say Y here to include support for I2C controller in the 446 Say Y here to include support for I2C controller in the
415 Samsung S3C2410 based System-on-Chip devices. 447 Samsung S3C2410 based System-on-Chip devices.
416 448
417config I2C_SAVAGE4 449config I2C_SH7760
418 tristate "S3 Savage 4 (DEPRECATED)" 450 tristate "Renesas SH7760 I2C Controller"
419 default n 451 depends on CPU_SUBTYPE_SH7760
420 depends on PCI
421 select I2C_ALGOBIT
422 help 452 help
423 If you say yes to this option, support will be included for the 453 This driver supports the 2 I2C interfaces on the Renesas SH7760.
424 S3 Savage 4 I2C interface.
425
426 This driver is deprecated in favor of the savagefb driver.
427 454
428 This driver can also be built as a module. If so, the module 455 This driver can also be built as a module. If so, the module
429 will be called i2c-savage4. 456 will be called i2c-sh7760.
430 457
431config I2C_SIBYTE 458config I2C_SH_MOBILE
432 tristate "SiByte SMBus interface" 459 tristate "SuperH Mobile I2C Controller"
433 depends on SIBYTE_SB1xxx_SOC 460 depends on SUPERH
434 help 461 help
435 Supports the SiByte SOC on-chip I2C interfaces (2 channels). 462 If you say yes to this option, support will be included for the
463 built-in I2C interface on the Renesas SH-Mobile processor.
464
465 This driver can also be built as a module. If so, the module
466 will be called i2c-sh_mobile.
436 467
437config I2C_SIMTEC 468config I2C_SIMTEC
438 tristate "Simtec Generic I2C interface" 469 tristate "Simtec Generic I2C interface"
@@ -446,86 +477,65 @@ config I2C_SIMTEC
446 This driver can also be built as a module. If so, the module 477 This driver can also be built as a module. If so, the module
447 will be called i2c-simtec. 478 will be called i2c-simtec.
448 479
449config SCx200_I2C 480config I2C_VERSATILE
450 tristate "NatSemi SCx200 I2C using GPIO pins (DEPRECATED)" 481 tristate "ARM Versatile/Realview I2C bus support"
451 depends on SCx200_GPIO 482 depends on ARCH_VERSATILE || ARCH_REALVIEW
452 select I2C_ALGOBIT 483 select I2C_ALGOBIT
453 help 484 help
454 Enable the use of two GPIO pins of a SCx200 processor as an I2C bus. 485 Say yes if you want to support the I2C serial bus on ARMs Versatile
455 486 range of platforms.
456 If you don't know what to do here, say N.
457 487
458 This support is also available as a module. If so, the module 488 This driver can also be built as a module. If so, the module
459 will be called scx200_i2c. 489 will be called i2c-versatile.
460 490
461 This driver is deprecated and will be dropped soon. Use i2c-gpio 491comment "External I2C/SMBus adapter drivers"
462 (or scx200_acb) instead.
463 492
464config SCx200_I2C_SCL 493config I2C_PARPORT
465 int "GPIO pin used for SCL" 494 tristate "Parallel port adapter"
466 depends on SCx200_I2C 495 depends on PARPORT
467 default "12" 496 select I2C_ALGOBIT
468 help 497 help
469 Enter the GPIO pin number used for the SCL signal. This value can 498 This supports parallel port I2C adapters such as the ones made by
470 also be specified with a module parameter. 499 Philips or Velleman, Analog Devices evaluation boards, and more.
500 Basically any adapter using the parallel port as an I2C bus with
501 no extra chipset is supported by this driver, or could be.
471 502
472config SCx200_I2C_SDA 503 This driver is a replacement for (and was inspired by) an older
473 int "GPIO pin used for SDA" 504 driver named i2c-philips-par. The new driver supports more devices,
474 depends on SCx200_I2C 505 and makes it easier to add support for new devices.
475 default "13"
476 help
477 Enter the GPIO pin number used for the SSA signal. This value can
478 also be specified with a module parameter.
479 506
480config SCx200_ACB 507 An adapter type parameter is now mandatory. Please read the file
481 tristate "Geode ACCESS.bus support" 508 Documentation/i2c/busses/i2c-parport for details.
482 depends on X86_32 && PCI
483 help
484 Enable the use of the ACCESS.bus controllers on the Geode SCx200 and
485 SC1100 processors and the CS5535 and CS5536 Geode companion devices.
486 509
487 If you don't know what to do here, say N. 510 Another driver exists, named i2c-parport-light, which doesn't depend
511 on the parport driver. This is meant for embedded systems. Don't say
512 Y here if you intend to say Y or M there.
488 513
489 This support is also available as a module. If so, the module 514 This support is also available as a module. If so, the module
490 will be called scx200_acb. 515 will be called i2c-parport.
491
492config I2C_SIS5595
493 tristate "SiS 5595"
494 depends on PCI
495 help
496 If you say yes to this option, support will be included for the
497 SiS5595 SMBus (a subset of I2C) interface.
498
499 This driver can also be built as a module. If so, the module
500 will be called i2c-sis5595.
501 516
502config I2C_SIS630 517config I2C_PARPORT_LIGHT
503 tristate "SiS 630/730" 518 tristate "Parallel port adapter (light)"
504 depends on PCI 519 select I2C_ALGOBIT
505 help 520 help
506 If you say yes to this option, support will be included for the 521 This supports parallel port I2C adapters such as the ones made by
507 SiS630 and SiS730 SMBus (a subset of I2C) interface. 522 Philips or Velleman, Analog Devices evaluation boards, and more.
523 Basically any adapter using the parallel port as an I2C bus with
524 no extra chipset is supported by this driver, or could be.
508 525
509 This driver can also be built as a module. If so, the module 526 This driver is a light version of i2c-parport. It doesn't depend
510 will be called i2c-sis630. 527 on the parport driver, and uses direct I/O access instead. This
528 might be preferred on embedded systems where wasting memory for
529 the clean but heavy parport handling is not an option. The
530 drawback is a reduced portability and the impossibility to
531 daisy-chain other parallel port devices.
511 532
512config I2C_SIS96X 533 Don't say Y here if you said Y or M to i2c-parport. Saying M to
513 tristate "SiS 96x" 534 both is possible but both modules should not be loaded at the same
514 depends on PCI 535 time.
515 help
516 If you say yes to this option, support will be included for the SiS
517 96x SMBus (a subset of I2C) interfaces. Specifically, the following
518 chipsets are supported:
519 645/961
520 645DX/961
521 645DX/962
522 648/961
523 650/961
524 735
525 745
526 536
527 This driver can also be built as a module. If so, the module 537 This support is also available as a module. If so, the module
528 will be called i2c-sis96x. 538 will be called i2c-parport-light.
529 539
530config I2C_TAOS_EVM 540config I2C_TAOS_EVM
531 tristate "TAOS evaluation module" 541 tristate "TAOS evaluation module"
@@ -543,21 +553,8 @@ config I2C_TAOS_EVM
543 This support is also available as a module. If so, the module 553 This support is also available as a module. If so, the module
544 will be called i2c-taos-evm. 554 will be called i2c-taos-evm.
545 555
546config I2C_STUB
547 tristate "I2C/SMBus Test Stub"
548 depends on EXPERIMENTAL && m
549 default 'n'
550 help
551 This module may be useful to developers of SMBus client drivers,
552 especially for certain kinds of sensor chips.
553
554 If you do build this module, be sure to read the notes and warnings
555 in <file:Documentation/i2c/i2c-stub>.
556
557 If you don't know what to do here, definitely say N.
558
559config I2C_TINY_USB 556config I2C_TINY_USB
560 tristate "I2C-Tiny-USB" 557 tristate "Tiny-USB adapter"
561 depends on USB 558 depends on USB
562 help 559 help
563 If you say yes to this option, support will be included for the 560 If you say yes to this option, support will be included for the
@@ -567,16 +564,21 @@ config I2C_TINY_USB
567 This driver can also be built as a module. If so, the module 564 This driver can also be built as a module. If so, the module
568 will be called i2c-tiny-usb. 565 will be called i2c-tiny-usb.
569 566
570config I2C_VERSATILE 567comment "Graphics adapter I2C/DDC channel drivers"
571 tristate "ARM Versatile/Realview I2C bus support" 568 depends on PCI
572 depends on ARCH_VERSATILE || ARCH_REALVIEW 569
570config I2C_VOODOO3
571 tristate "Voodoo 3"
572 depends on PCI
573 select I2C_ALGOBIT 573 select I2C_ALGOBIT
574 help 574 help
575 Say yes if you want to support the I2C serial bus on ARMs Versatile 575 If you say yes to this option, support will be included for the
576 range of platforms. 576 Voodoo 3 I2C interface.
577 577
578 This driver can also be built as a module. If so, the module 578 This driver can also be built as a module. If so, the module
579 will be called i2c-versatile. 579 will be called i2c-voodoo3.
580
581comment "Other I2C/SMBus bus drivers"
580 582
581config I2C_ACORN 583config I2C_ACORN
582 tristate "Acorn IOC/IOMD I2C bus support" 584 tristate "Acorn IOC/IOMD I2C bus support"
@@ -588,46 +590,16 @@ config I2C_ACORN
588 590
589 If you don't know, say Y. 591 If you don't know, say Y.
590 592
591config I2C_VIA 593config I2C_ELEKTOR
592 tristate "VIA 82C586B" 594 tristate "Elektor ISA card"
593 depends on PCI && EXPERIMENTAL 595 depends on ISA && BROKEN_ON_SMP
594 select I2C_ALGOBIT 596 select I2C_ALGOPCF
595 help
596 If you say yes to this option, support will be included for the VIA
597 82C586B I2C interface
598
599 This driver can also be built as a module. If so, the module
600 will be called i2c-via.
601
602config I2C_VIAPRO
603 tristate "VIA VT82C596/82C686/82xx and CX700"
604 depends on PCI
605 help
606 If you say yes to this option, support will be included for the VIA
607 VT82C596 and later SMBus interface. Specifically, the following
608 chipsets are supported:
609 VT82C596A/B
610 VT82C686A/B
611 VT8231
612 VT8233/A
613 VT8235
614 VT8237R/A/S
615 VT8251
616 CX700
617
618 This driver can also be built as a module. If so, the module
619 will be called i2c-viapro.
620
621config I2C_VOODOO3
622 tristate "Voodoo 3"
623 depends on PCI
624 select I2C_ALGOBIT
625 help 597 help
626 If you say yes to this option, support will be included for the 598 This supports the PCF8584 ISA bus I2C adapter. Say Y if you own
627 Voodoo 3 I2C interface. 599 such an adapter.
628 600
629 This driver can also be built as a module. If so, the module 601 This support is also available as a module. If so, the module
630 will be called i2c-voodoo3. 602 will be called i2c-elektor.
631 603
632config I2C_PCA_ISA 604config I2C_PCA_ISA
633 tristate "PCA9564 on an ISA bus" 605 tristate "PCA9564 on an ISA bus"
@@ -657,26 +629,6 @@ config I2C_PCA_PLATFORM
657 This driver can also be built as a module. If so, the module 629 This driver can also be built as a module. If so, the module
658 will be called i2c-pca-platform. 630 will be called i2c-pca-platform.
659 631
660config I2C_MV64XXX
661 tristate "Marvell mv64xxx I2C Controller"
662 depends on (MV64X60 || PLAT_ORION) && EXPERIMENTAL
663 help
664 If you say yes to this option, support will be included for the
665 built-in I2C interface on the Marvell 64xxx line of host bridges.
666
667 This driver can also be built as a module. If so, the module
668 will be called i2c-mv64xxx.
669
670config I2C_PNX
671 tristate "I2C bus support for Philips PNX targets"
672 depends on ARCH_PNX4008
673 help
674 This driver supports the Philips IP3204 I2C IP block master and/or
675 slave controller
676
677 This driver can also be built as a module. If so, the module
678 will be called i2c-pnx.
679
680config I2C_PMCMSP 632config I2C_PMCMSP
681 tristate "PMC MSP I2C TWI Controller" 633 tristate "PMC MSP I2C TWI Controller"
682 depends on PMC_MSP 634 depends on PMC_MSP
@@ -686,23 +638,66 @@ config I2C_PMCMSP
686 This driver can also be built as module. If so, the module 638 This driver can also be built as module. If so, the module
687 will be called i2c-pmcmsp. 639 will be called i2c-pmcmsp.
688 640
689config I2C_SH7760 641config I2C_SIBYTE
690 tristate "Renesas SH7760 I2C Controller" 642 tristate "SiByte SMBus interface"
691 depends on CPU_SUBTYPE_SH7760 643 depends on SIBYTE_SB1xxx_SOC
692 help 644 help
693 This driver supports the 2 I2C interfaces on the Renesas SH7760. 645 Supports the SiByte SOC on-chip I2C interfaces (2 channels).
694 646
695 This driver can also be built as a module. If so, the module 647config I2C_STUB
696 will be called i2c-sh7760. 648 tristate "I2C/SMBus Test Stub"
649 depends on EXPERIMENTAL && m
650 default 'n'
651 help
652 This module may be useful to developers of SMBus client drivers,
653 especially for certain kinds of sensor chips.
697 654
698config I2C_SH_MOBILE 655 If you do build this module, be sure to read the notes and warnings
699 tristate "SuperH Mobile I2C Controller" 656 in <file:Documentation/i2c/i2c-stub>.
700 depends on SUPERH 657
658 If you don't know what to do here, definitely say N.
659
660config SCx200_I2C
661 tristate "NatSemi SCx200 I2C using GPIO pins (DEPRECATED)"
662 depends on SCx200_GPIO
663 select I2C_ALGOBIT
701 help 664 help
702 If you say yes to this option, support will be included for the 665 Enable the use of two GPIO pins of a SCx200 processor as an I2C bus.
703 built-in I2C interface on the Renesas SH-Mobile processor.
704 666
705 This driver can also be built as a module. If so, the module 667 If you don't know what to do here, say N.
706 will be called i2c-sh_mobile. 668
669 This support is also available as a module. If so, the module
670 will be called scx200_i2c.
671
672 This driver is deprecated and will be dropped soon. Use i2c-gpio
673 (or scx200_acb) instead.
674
675config SCx200_I2C_SCL
676 int "GPIO pin used for SCL"
677 depends on SCx200_I2C
678 default "12"
679 help
680 Enter the GPIO pin number used for the SCL signal. This value can
681 also be specified with a module parameter.
682
683config SCx200_I2C_SDA
684 int "GPIO pin used for SDA"
685 depends on SCx200_I2C
686 default "13"
687 help
688 Enter the GPIO pin number used for the SSA signal. This value can
689 also be specified with a module parameter.
690
691config SCx200_ACB
692 tristate "Geode ACCESS.bus support"
693 depends on X86_32 && PCI
694 help
695 Enable the use of the ACCESS.bus controllers on the Geode SCx200 and
696 SC1100 processors and the CS5535 and CS5536 Geode companion devices.
697
698 If you don't know what to do here, say N.
699
700 This support is also available as a module. If so, the module
701 will be called scx200_acb.
707 702
708endmenu 703endmenu
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index e8c882a5ea6..97dbfa2107f 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -2,57 +2,68 @@
2# Makefile for the i2c bus drivers. 2# Makefile for the i2c bus drivers.
3# 3#
4 4
5# PC SMBus host controller drivers
5obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o 6obj-$(CONFIG_I2C_ALI1535) += i2c-ali1535.o
6obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o 7obj-$(CONFIG_I2C_ALI1563) += i2c-ali1563.o
7obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o 8obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o
8obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o 9obj-$(CONFIG_I2C_AMD756) += i2c-amd756.o
9obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o 10obj-$(CONFIG_I2C_AMD756_S4882) += i2c-amd756-s4882.o
10obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o 11obj-$(CONFIG_I2C_AMD8111) += i2c-amd8111.o
12obj-$(CONFIG_I2C_I801) += i2c-i801.o
13obj-$(CONFIG_I2C_ISCH) += i2c-isch.o
14obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
15obj-$(CONFIG_I2C_NFORCE2_S4985) += i2c-nforce2-s4985.o
16obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
17obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o
18obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o
19obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o
20obj-$(CONFIG_I2C_VIA) += i2c-via.o
21obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o
22
23# Mac SMBus host controller drivers
24obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
25obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
26
27# Embebbed system I2C/SMBus host controller drivers
11obj-$(CONFIG_I2C_AT91) += i2c-at91.o 28obj-$(CONFIG_I2C_AT91) += i2c-at91.o
12obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o 29obj-$(CONFIG_I2C_AU1550) += i2c-au1550.o
13obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o 30obj-$(CONFIG_I2C_BLACKFIN_TWI) += i2c-bfin-twi.o
31obj-$(CONFIG_I2C_CPM) += i2c-cpm.o
14obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o 32obj-$(CONFIG_I2C_DAVINCI) += i2c-davinci.o
15obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
16obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o 33obj-$(CONFIG_I2C_GPIO) += i2c-gpio.o
17obj-$(CONFIG_I2C_HYDRA) += i2c-hydra.o
18obj-$(CONFIG_I2C_I801) += i2c-i801.o
19obj-$(CONFIG_I2C_I810) += i2c-i810.o
20obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o 34obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
21obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 35obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
22obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o 36obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o
23obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
24obj-$(CONFIG_I2C_MPC) += i2c-mpc.o 37obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
25obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o 38obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o
26obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
27obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o 39obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o
28obj-$(CONFIG_I2C_OMAP) += i2c-omap.o 40obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
29obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
30obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
31obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o 41obj-$(CONFIG_I2C_PASEMI) += i2c-pasemi.o
32obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
33obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o
34obj-$(CONFIG_I2C_PIIX4) += i2c-piix4.o
35obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
36obj-$(CONFIG_I2C_PNX) += i2c-pnx.o 42obj-$(CONFIG_I2C_PNX) += i2c-pnx.o
37obj-$(CONFIG_I2C_PROSAVAGE) += i2c-prosavage.o
38obj-$(CONFIG_I2C_PXA) += i2c-pxa.o 43obj-$(CONFIG_I2C_PXA) += i2c-pxa.o
39obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o 44obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o
40obj-$(CONFIG_I2C_SAVAGE4) += i2c-savage4.o
41obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o 45obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o
42obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o 46obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o
43obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
44obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o 47obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o
45obj-$(CONFIG_I2C_SIS5595) += i2c-sis5595.o 48obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o
46obj-$(CONFIG_I2C_SIS630) += i2c-sis630.o 49
47obj-$(CONFIG_I2C_SIS96X) += i2c-sis96x.o 50# External I2C/SMBus adapter drivers
48obj-$(CONFIG_I2C_STUB) += i2c-stub.o 51obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
52obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
49obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o 53obj-$(CONFIG_I2C_TAOS_EVM) += i2c-taos-evm.o
50obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o 54obj-$(CONFIG_I2C_TINY_USB) += i2c-tiny-usb.o
51obj-$(CONFIG_I2C_VERSATILE) += i2c-versatile.o 55
52obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o 56# Graphics adapter I2C/DDC channel drivers
53obj-$(CONFIG_I2C_VIA) += i2c-via.o
54obj-$(CONFIG_I2C_VIAPRO) += i2c-viapro.o
55obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o 57obj-$(CONFIG_I2C_VOODOO3) += i2c-voodoo3.o
58
59# Other I2C/SMBus bus drivers
60obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
61obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
62obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
63obj-$(CONFIG_I2C_PCA_PLATFORM) += i2c-pca-platform.o
64obj-$(CONFIG_I2C_PMCMSP) += i2c-pmcmsp.o
65obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
66obj-$(CONFIG_I2C_STUB) += i2c-stub.o
56obj-$(CONFIG_SCx200_ACB) += scx200_acb.o 67obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
57obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o 68obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
58 69
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index f14372ac2fc..9cead9b9458 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -1,6 +1,4 @@
1/* 1/*
2 i2c-ali1535.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, 3 Philip Edelbrock <phil@netroedge.com>,
6 Mark D. Studebaker <mdsxyz123@yahoo.com>, 4 Mark D. Studebaker <mdsxyz123@yahoo.com>,
@@ -61,6 +59,7 @@
61#include <linux/ioport.h> 59#include <linux/ioport.h>
62#include <linux/i2c.h> 60#include <linux/i2c.h>
63#include <linux/init.h> 61#include <linux/init.h>
62#include <linux/acpi.h>
64#include <asm/io.h> 63#include <asm/io.h>
65 64
66 65
@@ -159,6 +158,11 @@ static int ali1535_setup(struct pci_dev *dev)
159 goto exit; 158 goto exit;
160 } 159 }
161 160
161 retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE,
162 ali1535_driver.name);
163 if (retval)
164 goto exit;
165
162 if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE, 166 if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
163 ali1535_driver.name)) { 167 ali1535_driver.name)) {
164 dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n", 168 dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
@@ -259,7 +263,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
259 dev_err(&adap->dev, 263 dev_err(&adap->dev,
260 "SMBus reset failed! (0x%02x) - controller or " 264 "SMBus reset failed! (0x%02x) - controller or "
261 "device on bus is probably hung\n", temp); 265 "device on bus is probably hung\n", temp);
262 return -1; 266 return -EBUSY;
263 } 267 }
264 } else { 268 } else {
265 /* check and clear done bit */ 269 /* check and clear done bit */
@@ -281,12 +285,12 @@ static int ali1535_transaction(struct i2c_adapter *adap)
281 285
282 /* If the SMBus is still busy, we give up */ 286 /* If the SMBus is still busy, we give up */
283 if (timeout >= MAX_TIMEOUT) { 287 if (timeout >= MAX_TIMEOUT) {
284 result = -1; 288 result = -ETIMEDOUT;
285 dev_err(&adap->dev, "SMBus Timeout!\n"); 289 dev_err(&adap->dev, "SMBus Timeout!\n");
286 } 290 }
287 291
288 if (temp & ALI1535_STS_FAIL) { 292 if (temp & ALI1535_STS_FAIL) {
289 result = -1; 293 result = -EIO;
290 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 294 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
291 } 295 }
292 296
@@ -295,7 +299,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
295 * do a printk. This means that bus collisions go unreported. 299 * do a printk. This means that bus collisions go unreported.
296 */ 300 */
297 if (temp & ALI1535_STS_BUSERR) { 301 if (temp & ALI1535_STS_BUSERR) {
298 result = -1; 302 result = -ENXIO;
299 dev_dbg(&adap->dev, 303 dev_dbg(&adap->dev,
300 "Error: no response or bus collision ADD=%02x\n", 304 "Error: no response or bus collision ADD=%02x\n",
301 inb_p(SMBHSTADD)); 305 inb_p(SMBHSTADD));
@@ -303,13 +307,13 @@ static int ali1535_transaction(struct i2c_adapter *adap)
303 307
304 /* haven't ever seen this */ 308 /* haven't ever seen this */
305 if (temp & ALI1535_STS_DEV) { 309 if (temp & ALI1535_STS_DEV) {
306 result = -1; 310 result = -EIO;
307 dev_err(&adap->dev, "Error: device error\n"); 311 dev_err(&adap->dev, "Error: device error\n");
308 } 312 }
309 313
310 /* check to see if the "command complete" indication is set */ 314 /* check to see if the "command complete" indication is set */
311 if (!(temp & ALI1535_STS_DONE)) { 315 if (!(temp & ALI1535_STS_DONE)) {
312 result = -1; 316 result = -ETIMEDOUT;
313 dev_err(&adap->dev, "Error: command never completed\n"); 317 dev_err(&adap->dev, "Error: command never completed\n");
314 } 318 }
315 319
@@ -332,7 +336,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
332 return result; 336 return result;
333} 337}
334 338
335/* Return -1 on error. */ 339/* Return negative errno on error. */
336static s32 ali1535_access(struct i2c_adapter *adap, u16 addr, 340static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
337 unsigned short flags, char read_write, u8 command, 341 unsigned short flags, char read_write, u8 command,
338 int size, union i2c_smbus_data *data) 342 int size, union i2c_smbus_data *data)
@@ -357,10 +361,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
357 outb_p(0xFF, SMBHSTSTS); 361 outb_p(0xFF, SMBHSTSTS);
358 362
359 switch (size) { 363 switch (size) {
360 case I2C_SMBUS_PROC_CALL:
361 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
362 result = -1;
363 goto EXIT;
364 case I2C_SMBUS_QUICK: 364 case I2C_SMBUS_QUICK:
365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 365 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
366 SMBHSTADD); 366 SMBHSTADD);
@@ -418,13 +418,15 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
418 outb_p(data->block[i], SMBBLKDAT); 418 outb_p(data->block[i], SMBBLKDAT);
419 } 419 }
420 break; 420 break;
421 default:
422 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
423 result = -EOPNOTSUPP;
424 goto EXIT;
421 } 425 }
422 426
423 if (ali1535_transaction(adap)) { 427 result = ali1535_transaction(adap);
424 /* Error in transaction */ 428 if (result)
425 result = -1;
426 goto EXIT; 429 goto EXIT;
427 }
428 430
429 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) { 431 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI1535_QUICK)) {
430 result = 0; 432 result = 0;
@@ -475,7 +477,7 @@ static const struct i2c_algorithm smbus_algorithm = {
475static struct i2c_adapter ali1535_adapter = { 477static struct i2c_adapter ali1535_adapter = {
476 .owner = THIS_MODULE, 478 .owner = THIS_MODULE,
477 .id = I2C_HW_SMBUS_ALI1535, 479 .id = I2C_HW_SMBUS_ALI1535,
478 .class = I2C_CLASS_HWMON, 480 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
479 .algo = &smbus_algorithm, 481 .algo = &smbus_algorithm,
480}; 482};
481 483
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index 6b68074e518..fc3e5b02642 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -21,6 +21,7 @@
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/acpi.h>
24 25
25#define ALI1563_MAX_TIMEOUT 500 26#define ALI1563_MAX_TIMEOUT 500
26#define ALI1563_SMBBA 0x80 27#define ALI1563_SMBBA 0x80
@@ -67,6 +68,7 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
67{ 68{
68 u32 data; 69 u32 data;
69 int timeout; 70 int timeout;
71 int status = -EIO;
70 72
71 dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, " 73 dev_dbg(&a->dev, "Transaction (pre): STS=%02x, CNTL1=%02x, "
72 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", 74 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
@@ -103,13 +105,15 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
103 /* Issue 'kill' to host controller */ 105 /* Issue 'kill' to host controller */
104 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2); 106 outb_p(HST_CNTL2_KILL,SMB_HST_CNTL2);
105 data = inb_p(SMB_HST_STS); 107 data = inb_p(SMB_HST_STS);
108 status = -ETIMEDOUT;
106 } 109 }
107 110
108 /* device error - no response, ignore the autodetection case */ 111 /* device error - no response, ignore the autodetection case */
109 if ((data & HST_STS_DEVERR) && (size != HST_CNTL2_QUICK)) { 112 if (data & HST_STS_DEVERR) {
110 dev_err(&a->dev, "Device error!\n"); 113 if (size != HST_CNTL2_QUICK)
114 dev_err(&a->dev, "Device error!\n");
115 status = -ENXIO;
111 } 116 }
112
113 /* bus collision */ 117 /* bus collision */
114 if (data & HST_STS_BUSERR) { 118 if (data & HST_STS_BUSERR) {
115 dev_err(&a->dev, "Bus collision!\n"); 119 dev_err(&a->dev, "Bus collision!\n");
@@ -122,13 +126,14 @@ static int ali1563_transaction(struct i2c_adapter * a, int size)
122 outb_p(0x0,SMB_HST_CNTL2); 126 outb_p(0x0,SMB_HST_CNTL2);
123 } 127 }
124 128
125 return -1; 129 return status;
126} 130}
127 131
128static int ali1563_block_start(struct i2c_adapter * a) 132static int ali1563_block_start(struct i2c_adapter * a)
129{ 133{
130 u32 data; 134 u32 data;
131 int timeout; 135 int timeout;
136 int status = -EIO;
132 137
133 dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, " 138 dev_dbg(&a->dev, "Block (pre): STS=%02x, CNTL1=%02x, "
134 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n", 139 "CNTL2=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
@@ -164,13 +169,20 @@ static int ali1563_block_start(struct i2c_adapter * a)
164 169
165 if (timeout && !(data & HST_STS_BAD)) 170 if (timeout && !(data & HST_STS_BAD))
166 return 0; 171 return 0;
172
173 if (timeout == 0)
174 status = -ETIMEDOUT;
175
176 if (data & HST_STS_DEVERR)
177 status = -ENXIO;
178
167 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n", 179 dev_err(&a->dev, "SMBus Error: %s%s%s%s%s\n",
168 timeout ? "Timeout " : "", 180 timeout ? "" : "Timeout ",
169 data & HST_STS_FAIL ? "Transaction Failed " : "", 181 data & HST_STS_FAIL ? "Transaction Failed " : "",
170 data & HST_STS_BUSERR ? "No response or Bus Collision " : "", 182 data & HST_STS_BUSERR ? "No response or Bus Collision " : "",
171 data & HST_STS_DEVERR ? "Device Error " : "", 183 data & HST_STS_DEVERR ? "Device Error " : "",
172 !(data & HST_STS_DONE) ? "Transaction Never Finished " : ""); 184 !(data & HST_STS_DONE) ? "Transaction Never Finished " : "");
173 return -1; 185 return status;
174} 186}
175 187
176static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw) 188static int ali1563_block(struct i2c_adapter * a, union i2c_smbus_data * data, u8 rw)
@@ -235,10 +247,6 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
235 247
236 /* Map the size to what the chip understands */ 248 /* Map the size to what the chip understands */
237 switch (size) { 249 switch (size) {
238 case I2C_SMBUS_PROC_CALL:
239 dev_err(&a->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
240 error = -EINVAL;
241 break;
242 case I2C_SMBUS_QUICK: 250 case I2C_SMBUS_QUICK:
243 size = HST_CNTL2_QUICK; 251 size = HST_CNTL2_QUICK;
244 break; 252 break;
@@ -254,6 +262,10 @@ static s32 ali1563_access(struct i2c_adapter * a, u16 addr,
254 case I2C_SMBUS_BLOCK_DATA: 262 case I2C_SMBUS_BLOCK_DATA:
255 size = HST_CNTL2_BLOCK; 263 size = HST_CNTL2_BLOCK;
256 break; 264 break;
265 default:
266 dev_warn(&a->dev, "Unsupported transaction %d\n", size);
267 error = -EOPNOTSUPP;
268 goto Done;
257 } 269 }
258 270
259 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD); 271 outb_p(((addr & 0x7f) << 1) | (rw & 0x01), SMB_HST_ADD);
@@ -345,6 +357,10 @@ static int __devinit ali1563_setup(struct pci_dev * dev)
345 } 357 }
346 } 358 }
347 359
360 if (acpi_check_region(ali1563_smba, ALI1563_SMB_IOSIZE,
361 ali1563_pci_driver.name))
362 goto Err;
363
348 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, 364 if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
349 ali1563_pci_driver.name)) { 365 ali1563_pci_driver.name)) {
350 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n", 366 dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n",
@@ -371,7 +387,7 @@ static const struct i2c_algorithm ali1563_algorithm = {
371static struct i2c_adapter ali1563_adapter = { 387static struct i2c_adapter ali1563_adapter = {
372 .owner = THIS_MODULE, 388 .owner = THIS_MODULE,
373 .id = I2C_HW_SMBUS_ALI1563, 389 .id = I2C_HW_SMBUS_ALI1563,
374 .class = I2C_CLASS_HWMON, 390 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
375 .algo = &ali1563_algorithm, 391 .algo = &ali1563_algorithm,
376}; 392};
377 393
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 93bf87d7096..234fdde7d40 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 ali15x3.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> and 3 Philip Edelbrock <phil@netroedge.com> and
6 Mark D. Studebaker <mdsxyz123@yahoo.com> 4 Mark D. Studebaker <mdsxyz123@yahoo.com>
@@ -68,6 +66,7 @@
68#include <linux/delay.h> 66#include <linux/delay.h>
69#include <linux/i2c.h> 67#include <linux/i2c.h>
70#include <linux/init.h> 68#include <linux/init.h>
69#include <linux/acpi.h>
71#include <asm/io.h> 70#include <asm/io.h>
72 71
73/* ALI15X3 SMBus address offsets */ 72/* ALI15X3 SMBus address offsets */
@@ -166,6 +165,10 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
166 if(force_addr) 165 if(force_addr)
167 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); 166 ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
168 167
168 if (acpi_check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
169 ali15x3_driver.name))
170 return -EBUSY;
171
169 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, 172 if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
170 ali15x3_driver.name)) { 173 ali15x3_driver.name)) {
171 dev_err(&ALI15X3_dev->dev, 174 dev_err(&ALI15X3_dev->dev,
@@ -282,7 +285,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
282 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - " 285 dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - "
283 "controller or device on bus is probably hung\n", 286 "controller or device on bus is probably hung\n",
284 temp); 287 temp);
285 return -1; 288 return -EBUSY;
286 } 289 }
287 } else { 290 } else {
288 /* check and clear done bit */ 291 /* check and clear done bit */
@@ -304,12 +307,12 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
304 307
305 /* If the SMBus is still busy, we give up */ 308 /* If the SMBus is still busy, we give up */
306 if (timeout >= MAX_TIMEOUT) { 309 if (timeout >= MAX_TIMEOUT) {
307 result = -1; 310 result = -ETIMEDOUT;
308 dev_err(&adap->dev, "SMBus Timeout!\n"); 311 dev_err(&adap->dev, "SMBus Timeout!\n");
309 } 312 }
310 313
311 if (temp & ALI15X3_STS_TERM) { 314 if (temp & ALI15X3_STS_TERM) {
312 result = -1; 315 result = -EIO;
313 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 316 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
314 } 317 }
315 318
@@ -320,7 +323,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
320 This means that bus collisions go unreported. 323 This means that bus collisions go unreported.
321 */ 324 */
322 if (temp & ALI15X3_STS_COLL) { 325 if (temp & ALI15X3_STS_COLL) {
323 result = -1; 326 result = -ENXIO;
324 dev_dbg(&adap->dev, 327 dev_dbg(&adap->dev,
325 "Error: no response or bus collision ADD=%02x\n", 328 "Error: no response or bus collision ADD=%02x\n",
326 inb_p(SMBHSTADD)); 329 inb_p(SMBHSTADD));
@@ -328,7 +331,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
328 331
329 /* haven't ever seen this */ 332 /* haven't ever seen this */
330 if (temp & ALI15X3_STS_DEV) { 333 if (temp & ALI15X3_STS_DEV) {
331 result = -1; 334 result = -EIO;
332 dev_err(&adap->dev, "Error: device error\n"); 335 dev_err(&adap->dev, "Error: device error\n");
333 } 336 }
334 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " 337 dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
@@ -338,7 +341,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
338 return result; 341 return result;
339} 342}
340 343
341/* Return -1 on error. */ 344/* Return negative errno on error. */
342static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, 345static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
343 unsigned short flags, char read_write, u8 command, 346 unsigned short flags, char read_write, u8 command,
344 int size, union i2c_smbus_data * data) 347 int size, union i2c_smbus_data * data)
@@ -362,9 +365,6 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
362 } 365 }
363 366
364 switch (size) { 367 switch (size) {
365 case I2C_SMBUS_PROC_CALL:
366 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
367 return -1;
368 case I2C_SMBUS_QUICK: 368 case I2C_SMBUS_QUICK:
369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 369 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
370 SMBHSTADD); 370 SMBHSTADD);
@@ -417,12 +417,16 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
417 } 417 }
418 size = ALI15X3_BLOCK_DATA; 418 size = ALI15X3_BLOCK_DATA;
419 break; 419 break;
420 default:
421 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
422 return -EOPNOTSUPP;
420 } 423 }
421 424
422 outb_p(size, SMBHSTCNT); /* output command */ 425 outb_p(size, SMBHSTCNT); /* output command */
423 426
424 if (ali15x3_transaction(adap)) /* Error in transaction */ 427 temp = ali15x3_transaction(adap);
425 return -1; 428 if (temp)
429 return temp;
426 430
427 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK)) 431 if ((read_write == I2C_SMBUS_WRITE) || (size == ALI15X3_QUICK))
428 return 0; 432 return 0;
@@ -470,7 +474,7 @@ static const struct i2c_algorithm smbus_algorithm = {
470static struct i2c_adapter ali15x3_adapter = { 474static struct i2c_adapter ali15x3_adapter = {
471 .owner = THIS_MODULE, 475 .owner = THIS_MODULE,
472 .id = I2C_HW_SMBUS_ALI15X3, 476 .id = I2C_HW_SMBUS_ALI15X3,
473 .class = I2C_CLASS_HWMON, 477 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
474 .algo = &smbus_algorithm, 478 .algo = &smbus_algorithm,
475}; 479};
476 480
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index c38a0a11220..2f150e33c74 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -58,7 +58,7 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
58 /* We exclude the multiplexed addresses */ 58 /* We exclude the multiplexed addresses */
59 if (addr == 0x4c || (addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30 59 if (addr == 0x4c || (addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30
60 || addr == 0x18) 60 || addr == 0x18)
61 return -1; 61 return -ENXIO;
62 62
63 mutex_lock(&amd756_lock); 63 mutex_lock(&amd756_lock);
64 64
@@ -86,7 +86,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
86 86
87 /* We exclude the non-multiplexed addresses */ 87 /* We exclude the non-multiplexed addresses */
88 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30) 88 if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
89 return -1; 89 return -ENXIO;
90 90
91 mutex_lock(&amd756_lock); 91 mutex_lock(&amd756_lock);
92 92
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 43508d61eb7..1ea39254dac 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -1,7 +1,4 @@
1/* 1/*
2 amd756.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4
5 Copyright (c) 1999-2002 Merlin Hughes <merlin@merlin.org> 2 Copyright (c) 1999-2002 Merlin Hughes <merlin@merlin.org>
6 3
7 Shamelessly ripped from i2c-piix4.c: 4 Shamelessly ripped from i2c-piix4.c:
@@ -45,6 +42,7 @@
45#include <linux/ioport.h> 42#include <linux/ioport.h>
46#include <linux/i2c.h> 43#include <linux/i2c.h>
47#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/acpi.h>
48#include <asm/io.h> 46#include <asm/io.h>
49 47
50/* AMD756 SMBus address offsets */ 48/* AMD756 SMBus address offsets */
@@ -151,17 +149,17 @@ static int amd756_transaction(struct i2c_adapter *adap)
151 } 149 }
152 150
153 if (temp & GS_PRERR_STS) { 151 if (temp & GS_PRERR_STS) {
154 result = -1; 152 result = -ENXIO;
155 dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n"); 153 dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n");
156 } 154 }
157 155
158 if (temp & GS_COL_STS) { 156 if (temp & GS_COL_STS) {
159 result = -1; 157 result = -EIO;
160 dev_warn(&adap->dev, "SMBus collision!\n"); 158 dev_warn(&adap->dev, "SMBus collision!\n");
161 } 159 }
162 160
163 if (temp & GS_TO_STS) { 161 if (temp & GS_TO_STS) {
164 result = -1; 162 result = -ETIMEDOUT;
165 dev_dbg(&adap->dev, "SMBus protocol timeout!\n"); 163 dev_dbg(&adap->dev, "SMBus protocol timeout!\n");
166 } 164 }
167 165
@@ -189,22 +187,18 @@ static int amd756_transaction(struct i2c_adapter *adap)
189 outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE); 187 outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
190 msleep(100); 188 msleep(100);
191 outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS); 189 outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
192 return -1; 190 return -EIO;
193} 191}
194 192
195/* Return -1 on error. */ 193/* Return negative errno on error. */
196static s32 amd756_access(struct i2c_adapter * adap, u16 addr, 194static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
197 unsigned short flags, char read_write, 195 unsigned short flags, char read_write,
198 u8 command, int size, union i2c_smbus_data * data) 196 u8 command, int size, union i2c_smbus_data * data)
199{ 197{
200 int i, len; 198 int i, len;
199 int status;
201 200
202 /** TODO: Should I supporte the 10-bit transfers? */
203 switch (size) { 201 switch (size) {
204 case I2C_SMBUS_PROC_CALL:
205 dev_dbg(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
206 /* TODO: Well... It is supported, I'm just not sure what to do here... */
207 return -1;
208 case I2C_SMBUS_QUICK: 202 case I2C_SMBUS_QUICK:
209 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01), 203 outw_p(((addr & 0x7f) << 1) | (read_write & 0x01),
210 SMB_HOST_ADDRESS); 204 SMB_HOST_ADDRESS);
@@ -251,13 +245,17 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
251 } 245 }
252 size = AMD756_BLOCK_DATA; 246 size = AMD756_BLOCK_DATA;
253 break; 247 break;
248 default:
249 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
250 return -EOPNOTSUPP;
254 } 251 }
255 252
256 /* How about enabling interrupts... */ 253 /* How about enabling interrupts... */
257 outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE); 254 outw_p(size & GE_CYC_TYPE_MASK, SMB_GLOBAL_ENABLE);
258 255
259 if (amd756_transaction(adap)) /* Error in transaction */ 256 status = amd756_transaction(adap);
260 return -1; 257 if (status)
258 return status;
261 259
262 if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK)) 260 if ((read_write == I2C_SMBUS_WRITE) || (size == AMD756_QUICK))
263 return 0; 261 return 0;
@@ -301,7 +299,7 @@ static const struct i2c_algorithm smbus_algorithm = {
301struct i2c_adapter amd756_smbus = { 299struct i2c_adapter amd756_smbus = {
302 .owner = THIS_MODULE, 300 .owner = THIS_MODULE,
303 .id = I2C_HW_SMBUS_AMD756, 301 .id = I2C_HW_SMBUS_AMD756,
304 .class = I2C_CLASS_HWMON, 302 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
305 .algo = &smbus_algorithm, 303 .algo = &smbus_algorithm,
306}; 304};
307 305
@@ -368,6 +366,11 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
368 amd756_ioport += SMB_ADDR_OFFSET; 366 amd756_ioport += SMB_ADDR_OFFSET;
369 } 367 }
370 368
369 error = acpi_check_region(amd756_ioport, SMB_IOSIZE,
370 amd756_driver.name);
371 if (error)
372 return error;
373
371 if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) { 374 if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) {
372 dev_err(&pdev->dev, "SMB region 0x%x already in use!\n", 375 dev_err(&pdev->dev, "SMB region 0x%x already in use!\n",
373 amd756_ioport); 376 amd756_ioport);
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index 5d1a27ef250..3972208876b 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/i2c.h> 17#include <linux/i2c.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/acpi.h>
19#include <asm/io.h> 20#include <asm/io.h>
20 21
21MODULE_LICENSE("GPL"); 22MODULE_LICENSE("GPL");
@@ -77,7 +78,7 @@ static unsigned int amd_ec_wait_write(struct amd_smbus *smbus)
77 if (!timeout) { 78 if (!timeout) {
78 dev_warn(&smbus->dev->dev, 79 dev_warn(&smbus->dev->dev,
79 "Timeout while waiting for IBF to clear\n"); 80 "Timeout while waiting for IBF to clear\n");
80 return -1; 81 return -ETIMEDOUT;
81 } 82 }
82 83
83 return 0; 84 return 0;
@@ -93,7 +94,7 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
93 if (!timeout) { 94 if (!timeout) {
94 dev_warn(&smbus->dev->dev, 95 dev_warn(&smbus->dev->dev,
95 "Timeout while waiting for OBF to set\n"); 96 "Timeout while waiting for OBF to set\n");
96 return -1; 97 return -ETIMEDOUT;
97 } 98 }
98 99
99 return 0; 100 return 0;
@@ -102,16 +103,21 @@ static unsigned int amd_ec_wait_read(struct amd_smbus *smbus)
102static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address, 103static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
103 unsigned char *data) 104 unsigned char *data)
104{ 105{
105 if (amd_ec_wait_write(smbus)) 106 int status;
106 return -1; 107
108 status = amd_ec_wait_write(smbus);
109 if (status)
110 return status;
107 outb(AMD_EC_CMD_RD, smbus->base + AMD_EC_CMD); 111 outb(AMD_EC_CMD_RD, smbus->base + AMD_EC_CMD);
108 112
109 if (amd_ec_wait_write(smbus)) 113 status = amd_ec_wait_write(smbus);
110 return -1; 114 if (status)
115 return status;
111 outb(address, smbus->base + AMD_EC_DATA); 116 outb(address, smbus->base + AMD_EC_DATA);
112 117
113 if (amd_ec_wait_read(smbus)) 118 status = amd_ec_wait_read(smbus);
114 return -1; 119 if (status)
120 return status;
115 *data = inb(smbus->base + AMD_EC_DATA); 121 *data = inb(smbus->base + AMD_EC_DATA);
116 122
117 return 0; 123 return 0;
@@ -120,16 +126,21 @@ static unsigned int amd_ec_read(struct amd_smbus *smbus, unsigned char address,
120static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address, 126static unsigned int amd_ec_write(struct amd_smbus *smbus, unsigned char address,
121 unsigned char data) 127 unsigned char data)
122{ 128{
123 if (amd_ec_wait_write(smbus)) 129 int status;
124 return -1; 130
131 status = amd_ec_wait_write(smbus);
132 if (status)
133 return status;
125 outb(AMD_EC_CMD_WR, smbus->base + AMD_EC_CMD); 134 outb(AMD_EC_CMD_WR, smbus->base + AMD_EC_CMD);
126 135
127 if (amd_ec_wait_write(smbus)) 136 status = amd_ec_wait_write(smbus);
128 return -1; 137 if (status)
138 return status;
129 outb(address, smbus->base + AMD_EC_DATA); 139 outb(address, smbus->base + AMD_EC_DATA);
130 140
131 if (amd_ec_wait_write(smbus)) 141 status = amd_ec_wait_write(smbus);
132 return -1; 142 if (status)
143 return status;
133 outb(data, smbus->base + AMD_EC_DATA); 144 outb(data, smbus->base + AMD_EC_DATA);
134 145
135 return 0; 146 return 0;
@@ -267,12 +278,17 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr,
267 278
268 default: 279 default:
269 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 280 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
270 return -1; 281 return -EOPNOTSUPP;
271 } 282 }
272 283
273 amd_ec_write(smbus, AMD_SMB_ADDR, addr << 1); 284 amd_ec_write(smbus, AMD_SMB_ADDR, addr << 1);
274 amd_ec_write(smbus, AMD_SMB_PRTCL, protocol); 285 amd_ec_write(smbus, AMD_SMB_PRTCL, protocol);
275 286
287 /* FIXME this discards status from ec_read(); so temp[0] will
288 * hold stack garbage ... the rest of this routine will act
289 * nonsensically. Ignored ec_write() status might explain
290 * some such failures...
291 */
276 amd_ec_read(smbus, AMD_SMB_STS, temp + 0); 292 amd_ec_read(smbus, AMD_SMB_STS, temp + 0);
277 293
278 if (~temp[0] & AMD_SMB_STS_DONE) { 294 if (~temp[0] & AMD_SMB_STS_DONE) {
@@ -286,7 +302,7 @@ static s32 amd8111_access(struct i2c_adapter * adap, u16 addr,
286 } 302 }
287 303
288 if ((~temp[0] & AMD_SMB_STS_DONE) || (temp[0] & AMD_SMB_STS_STATUS)) 304 if ((~temp[0] & AMD_SMB_STS_DONE) || (temp[0] & AMD_SMB_STS_STATUS))
289 return -1; 305 return -EIO;
290 306
291 if (read_write == I2C_SMBUS_WRITE) 307 if (read_write == I2C_SMBUS_WRITE)
292 return 0; 308 return 0;
@@ -359,6 +375,10 @@ static int __devinit amd8111_probe(struct pci_dev *dev,
359 smbus->base = pci_resource_start(dev, 0); 375 smbus->base = pci_resource_start(dev, 0);
360 smbus->size = pci_resource_len(dev, 0); 376 smbus->size = pci_resource_len(dev, 0);
361 377
378 error = acpi_check_resource_conflict(&dev->resource[0]);
379 if (error)
380 goto out_kfree;
381
362 if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) { 382 if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) {
363 error = -EBUSY; 383 error = -EBUSY;
364 goto out_kfree; 384 goto out_kfree;
@@ -368,7 +388,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev,
368 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), 388 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
369 "SMBus2 AMD8111 adapter at %04x", smbus->base); 389 "SMBus2 AMD8111 adapter at %04x", smbus->base);
370 smbus->adapter.id = I2C_HW_SMBUS_AMD8111; 390 smbus->adapter.id = I2C_HW_SMBUS_AMD8111;
371 smbus->adapter.class = I2C_CLASS_HWMON; 391 smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
372 smbus->adapter.algo = &smbus_algorithm; 392 smbus->adapter.algo = &smbus_algorithm;
373 smbus->adapter.algo_data = smbus; 393 smbus->adapter.algo_data = smbus;
374 394
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index cae9dc89d88..66a04c2c660 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -269,9 +269,13 @@ static int
269au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) 269au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
270{ 270{
271 struct i2c_au1550_data *adap = i2c_adap->algo_data; 271 struct i2c_au1550_data *adap = i2c_adap->algo_data;
272 volatile psc_smb_t *sp = (volatile psc_smb_t *)adap->psc_base;
272 struct i2c_msg *p; 273 struct i2c_msg *p;
273 int i, err = 0; 274 int i, err = 0;
274 275
276 sp->psc_ctrl = PSC_CTRL_ENABLE;
277 au_sync();
278
275 for (i = 0; !err && i < num; i++) { 279 for (i = 0; !err && i < num; i++) {
276 p = &msgs[i]; 280 p = &msgs[i];
277 err = do_address(adap, p->addr, p->flags & I2C_M_RD, 281 err = do_address(adap, p->addr, p->flags & I2C_M_RD,
@@ -288,6 +292,10 @@ au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
288 */ 292 */
289 if (err == 0) 293 if (err == 0)
290 err = num; 294 err = num;
295
296 sp->psc_ctrl = PSC_CTRL_SUSPEND;
297 au_sync();
298
291 return err; 299 return err;
292} 300}
293 301
@@ -302,6 +310,61 @@ static const struct i2c_algorithm au1550_algo = {
302 .functionality = au1550_func, 310 .functionality = au1550_func,
303}; 311};
304 312
313static void i2c_au1550_setup(struct i2c_au1550_data *priv)
314{
315 volatile psc_smb_t *sp = (volatile psc_smb_t *)priv->psc_base;
316 u32 stat;
317
318 sp->psc_ctrl = PSC_CTRL_DISABLE;
319 au_sync();
320 sp->psc_sel = PSC_SEL_PS_SMBUSMODE;
321 sp->psc_smbcfg = 0;
322 au_sync();
323 sp->psc_ctrl = PSC_CTRL_ENABLE;
324 au_sync();
325 do {
326 stat = sp->psc_smbstat;
327 au_sync();
328 } while ((stat & PSC_SMBSTAT_SR) == 0);
329
330 sp->psc_smbcfg = (PSC_SMBCFG_RT_FIFO8 | PSC_SMBCFG_TT_FIFO8 |
331 PSC_SMBCFG_DD_DISABLE);
332
333 /* Divide by 8 to get a 6.25 MHz clock. The later protocol
334 * timings are based on this clock.
335 */
336 sp->psc_smbcfg |= PSC_SMBCFG_SET_DIV(PSC_SMBCFG_DIV8);
337 sp->psc_smbmsk = PSC_SMBMSK_ALLMASK;
338 au_sync();
339
340 /* Set the protocol timer values. See Table 71 in the
341 * Au1550 Data Book for standard timing values.
342 */
343 sp->psc_smbtmr = PSC_SMBTMR_SET_TH(0) | PSC_SMBTMR_SET_PS(15) | \
344 PSC_SMBTMR_SET_PU(15) | PSC_SMBTMR_SET_SH(15) | \
345 PSC_SMBTMR_SET_SU(15) | PSC_SMBTMR_SET_CL(15) | \
346 PSC_SMBTMR_SET_CH(15);
347 au_sync();
348
349 sp->psc_smbcfg |= PSC_SMBCFG_DE_ENABLE;
350 do {
351 stat = sp->psc_smbstat;
352 au_sync();
353 } while ((stat & PSC_SMBSTAT_SR) == 0);
354
355 sp->psc_ctrl = PSC_CTRL_SUSPEND;
356 au_sync();
357}
358
359static void i2c_au1550_disable(struct i2c_au1550_data *priv)
360{
361 volatile psc_smb_t *sp = (volatile psc_smb_t *)priv->psc_base;
362
363 sp->psc_smbcfg = 0;
364 sp->psc_ctrl = PSC_CTRL_DISABLE;
365 au_sync();
366}
367
305/* 368/*
306 * registering functions to load algorithms at runtime 369 * registering functions to load algorithms at runtime
307 * Prior to calling us, the 50MHz clock frequency and routing 370 * Prior to calling us, the 50MHz clock frequency and routing
@@ -311,9 +374,7 @@ static int __devinit
311i2c_au1550_probe(struct platform_device *pdev) 374i2c_au1550_probe(struct platform_device *pdev)
312{ 375{
313 struct i2c_au1550_data *priv; 376 struct i2c_au1550_data *priv;
314 volatile psc_smb_t *sp;
315 struct resource *r; 377 struct resource *r;
316 u32 stat;
317 int ret; 378 int ret;
318 379
319 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 380 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -348,43 +409,7 @@ i2c_au1550_probe(struct platform_device *pdev)
348 409
349 /* Now, set up the PSC for SMBus PIO mode. 410 /* Now, set up the PSC for SMBus PIO mode.
350 */ 411 */
351 sp = (volatile psc_smb_t *)priv->psc_base; 412 i2c_au1550_setup(priv);
352 sp->psc_ctrl = PSC_CTRL_DISABLE;
353 au_sync();
354 sp->psc_sel = PSC_SEL_PS_SMBUSMODE;
355 sp->psc_smbcfg = 0;
356 au_sync();
357 sp->psc_ctrl = PSC_CTRL_ENABLE;
358 au_sync();
359 do {
360 stat = sp->psc_smbstat;
361 au_sync();
362 } while ((stat & PSC_SMBSTAT_SR) == 0);
363
364 sp->psc_smbcfg = (PSC_SMBCFG_RT_FIFO8 | PSC_SMBCFG_TT_FIFO8 |
365 PSC_SMBCFG_DD_DISABLE);
366
367 /* Divide by 8 to get a 6.25 MHz clock. The later protocol
368 * timings are based on this clock.
369 */
370 sp->psc_smbcfg |= PSC_SMBCFG_SET_DIV(PSC_SMBCFG_DIV8);
371 sp->psc_smbmsk = PSC_SMBMSK_ALLMASK;
372 au_sync();
373
374 /* Set the protocol timer values. See Table 71 in the
375 * Au1550 Data Book for standard timing values.
376 */
377 sp->psc_smbtmr = PSC_SMBTMR_SET_TH(0) | PSC_SMBTMR_SET_PS(15) | \
378 PSC_SMBTMR_SET_PU(15) | PSC_SMBTMR_SET_SH(15) | \
379 PSC_SMBTMR_SET_SU(15) | PSC_SMBTMR_SET_CL(15) | \
380 PSC_SMBTMR_SET_CH(15);
381 au_sync();
382
383 sp->psc_smbcfg |= PSC_SMBCFG_DE_ENABLE;
384 do {
385 stat = sp->psc_smbstat;
386 au_sync();
387 } while ((stat & PSC_SMBSTAT_DR) == 0);
388 413
389 ret = i2c_add_numbered_adapter(&priv->adap); 414 ret = i2c_add_numbered_adapter(&priv->adap);
390 if (ret == 0) { 415 if (ret == 0) {
@@ -392,10 +417,7 @@ i2c_au1550_probe(struct platform_device *pdev)
392 return 0; 417 return 0;
393 } 418 }
394 419
395 /* disable the PSC */ 420 i2c_au1550_disable(priv);
396 sp->psc_smbcfg = 0;
397 sp->psc_ctrl = PSC_CTRL_DISABLE;
398 au_sync();
399 421
400 release_resource(priv->ioarea); 422 release_resource(priv->ioarea);
401 kfree(priv->ioarea); 423 kfree(priv->ioarea);
@@ -409,27 +431,24 @@ static int __devexit
409i2c_au1550_remove(struct platform_device *pdev) 431i2c_au1550_remove(struct platform_device *pdev)
410{ 432{
411 struct i2c_au1550_data *priv = platform_get_drvdata(pdev); 433 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
412 volatile psc_smb_t *sp = (volatile psc_smb_t *)priv->psc_base;
413 434
414 platform_set_drvdata(pdev, NULL); 435 platform_set_drvdata(pdev, NULL);
415 i2c_del_adapter(&priv->adap); 436 i2c_del_adapter(&priv->adap);
416 sp->psc_smbcfg = 0; 437 i2c_au1550_disable(priv);
417 sp->psc_ctrl = PSC_CTRL_DISABLE;
418 au_sync();
419 release_resource(priv->ioarea); 438 release_resource(priv->ioarea);
420 kfree(priv->ioarea); 439 kfree(priv->ioarea);
421 kfree(priv); 440 kfree(priv);
422 return 0; 441 return 0;
423} 442}
424 443
444#ifdef CONFIG_PM
425static int 445static int
426i2c_au1550_suspend(struct platform_device *pdev, pm_message_t state) 446i2c_au1550_suspend(struct platform_device *pdev, pm_message_t state)
427{ 447{
428 struct i2c_au1550_data *priv = platform_get_drvdata(pdev); 448 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
429 volatile psc_smb_t *sp = (volatile psc_smb_t *)priv->psc_base;
430 449
431 sp->psc_ctrl = PSC_CTRL_SUSPEND; 450 i2c_au1550_disable(priv);
432 au_sync(); 451
433 return 0; 452 return 0;
434} 453}
435 454
@@ -437,14 +456,15 @@ static int
437i2c_au1550_resume(struct platform_device *pdev) 456i2c_au1550_resume(struct platform_device *pdev)
438{ 457{
439 struct i2c_au1550_data *priv = platform_get_drvdata(pdev); 458 struct i2c_au1550_data *priv = platform_get_drvdata(pdev);
440 volatile psc_smb_t *sp = (volatile psc_smb_t *)priv->psc_base;
441 459
442 sp->psc_ctrl = PSC_CTRL_ENABLE; 460 i2c_au1550_setup(priv);
443 au_sync(); 461
444 while (!(sp->psc_smbstat & PSC_SMBSTAT_SR))
445 au_sync();
446 return 0; 462 return 0;
447} 463}
464#else
465#define i2c_au1550_suspend NULL
466#define i2c_au1550_resume NULL
467#endif
448 468
449static struct platform_driver au1xpsc_smbus_driver = { 469static struct platform_driver au1xpsc_smbus_driver = {
450 .driver = { 470 .driver = {
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
new file mode 100644
index 00000000000..8164de1f4d7
--- /dev/null
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -0,0 +1,745 @@
1/*
2 * Freescale CPM1/CPM2 I2C interface.
3 * Copyright (c) 1999 Dan Malek (dmalek@jlc.net).
4 *
5 * moved into proper i2c interface;
6 * Brad Parker (brad@heeltoe.com)
7 *
8 * Parts from dbox2_i2c.c (cvs.tuxbox.org)
9 * (C) 2000-2001 Felix Domke (tmbinc@gmx.net), Gillem (htoa@gmx.net)
10 *
11 * (C) 2007 Montavista Software, Inc.
12 * Vitaly Bordug <vitb@kernel.crashing.org>
13 *
14 * Converted to of_platform_device. Renamed to i2c-cpm.c.
15 * (C) 2007,2008 Jochen Friedrich <jochen@scram.de>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 */
31
32#include <linux/kernel.h>
33#include <linux/module.h>
34#include <linux/delay.h>
35#include <linux/slab.h>
36#include <linux/init.h>
37#include <linux/interrupt.h>
38#include <linux/errno.h>
39#include <linux/stddef.h>
40#include <linux/i2c.h>
41#include <linux/io.h>
42#include <linux/dma-mapping.h>
43#include <linux/of_device.h>
44#include <linux/of_platform.h>
45#include <linux/of_i2c.h>
46#include <sysdev/fsl_soc.h>
47#include <asm/cpm.h>
48
49/* Try to define this if you have an older CPU (earlier than rev D4) */
50/* However, better use a GPIO based bitbang driver in this case :/ */
51#undef I2C_CHIP_ERRATA
52
53#define CPM_MAX_READ 513
54#define CPM_MAXBD 4
55
56#define I2C_EB (0x10) /* Big endian mode */
57#define I2C_EB_CPM2 (0x30) /* Big endian mode, memory snoop */
58
59#define DPRAM_BASE ((u8 __iomem __force *)cpm_muram_addr(0))
60
61/* I2C parameter RAM. */
62struct i2c_ram {
63 ushort rbase; /* Rx Buffer descriptor base address */
64 ushort tbase; /* Tx Buffer descriptor base address */
65 u_char rfcr; /* Rx function code */
66 u_char tfcr; /* Tx function code */
67 ushort mrblr; /* Max receive buffer length */
68 uint rstate; /* Internal */
69 uint rdp; /* Internal */
70 ushort rbptr; /* Rx Buffer descriptor pointer */
71 ushort rbc; /* Internal */
72 uint rxtmp; /* Internal */
73 uint tstate; /* Internal */
74 uint tdp; /* Internal */
75 ushort tbptr; /* Tx Buffer descriptor pointer */
76 ushort tbc; /* Internal */
77 uint txtmp; /* Internal */
78 char res1[4]; /* Reserved */
79 ushort rpbase; /* Relocation pointer */
80 char res2[2]; /* Reserved */
81};
82
83#define I2COM_START 0x80
84#define I2COM_MASTER 0x01
85#define I2CER_TXE 0x10
86#define I2CER_BUSY 0x04
87#define I2CER_TXB 0x02
88#define I2CER_RXB 0x01
89#define I2MOD_EN 0x01
90
91/* I2C Registers */
92struct i2c_reg {
93 u8 i2mod;
94 u8 res1[3];
95 u8 i2add;
96 u8 res2[3];
97 u8 i2brg;
98 u8 res3[3];
99 u8 i2com;
100 u8 res4[3];
101 u8 i2cer;
102 u8 res5[3];
103 u8 i2cmr;
104};
105
106struct cpm_i2c {
107 char *base;
108 struct of_device *ofdev;
109 struct i2c_adapter adap;
110 uint dp_addr;
111 int version; /* CPM1=1, CPM2=2 */
112 int irq;
113 int cp_command;
114 int freq;
115 struct i2c_reg __iomem *i2c_reg;
116 struct i2c_ram __iomem *i2c_ram;
117 u16 i2c_addr;
118 wait_queue_head_t i2c_wait;
119 cbd_t __iomem *tbase;
120 cbd_t __iomem *rbase;
121 u_char *txbuf[CPM_MAXBD];
122 u_char *rxbuf[CPM_MAXBD];
123 u32 txdma[CPM_MAXBD];
124 u32 rxdma[CPM_MAXBD];
125};
126
127static irqreturn_t cpm_i2c_interrupt(int irq, void *dev_id)
128{
129 struct cpm_i2c *cpm;
130 struct i2c_reg __iomem *i2c_reg;
131 struct i2c_adapter *adap = dev_id;
132 int i;
133
134 cpm = i2c_get_adapdata(dev_id);
135 i2c_reg = cpm->i2c_reg;
136
137 /* Clear interrupt. */
138 i = in_8(&i2c_reg->i2cer);
139 out_8(&i2c_reg->i2cer, i);
140
141 dev_dbg(&adap->dev, "Interrupt: %x\n", i);
142
143 wake_up_interruptible(&cpm->i2c_wait);
144
145 return i ? IRQ_HANDLED : IRQ_NONE;
146}
147
148static void cpm_reset_i2c_params(struct cpm_i2c *cpm)
149{
150 struct i2c_ram __iomem *i2c_ram = cpm->i2c_ram;
151
152 /* Set up the I2C parameters in the parameter ram. */
153 out_be16(&i2c_ram->tbase, (u8 __iomem *)cpm->tbase - DPRAM_BASE);
154 out_be16(&i2c_ram->rbase, (u8 __iomem *)cpm->rbase - DPRAM_BASE);
155
156 if (cpm->version == 1) {
157 out_8(&i2c_ram->tfcr, I2C_EB);
158 out_8(&i2c_ram->rfcr, I2C_EB);
159 } else {
160 out_8(&i2c_ram->tfcr, I2C_EB_CPM2);
161 out_8(&i2c_ram->rfcr, I2C_EB_CPM2);
162 }
163
164 out_be16(&i2c_ram->mrblr, CPM_MAX_READ);
165
166 out_be32(&i2c_ram->rstate, 0);
167 out_be32(&i2c_ram->rdp, 0);
168 out_be16(&i2c_ram->rbptr, 0);
169 out_be16(&i2c_ram->rbc, 0);
170 out_be32(&i2c_ram->rxtmp, 0);
171 out_be32(&i2c_ram->tstate, 0);
172 out_be32(&i2c_ram->tdp, 0);
173 out_be16(&i2c_ram->tbptr, 0);
174 out_be16(&i2c_ram->tbc, 0);
175 out_be32(&i2c_ram->txtmp, 0);
176}
177
178static void cpm_i2c_force_close(struct i2c_adapter *adap)
179{
180 struct cpm_i2c *cpm = i2c_get_adapdata(adap);
181 struct i2c_reg __iomem *i2c_reg = cpm->i2c_reg;
182
183 dev_dbg(&adap->dev, "cpm_i2c_force_close()\n");
184
185 cpm_command(cpm->cp_command, CPM_CR_CLOSE_RX_BD);
186
187 out_8(&i2c_reg->i2cmr, 0x00); /* Disable all interrupts */
188 out_8(&i2c_reg->i2cer, 0xff);
189}
190
191static void cpm_i2c_parse_message(struct i2c_adapter *adap,
192 struct i2c_msg *pmsg, int num, int tx, int rx)
193{
194 cbd_t __iomem *tbdf;
195 cbd_t __iomem *rbdf;
196 u_char addr;
197 u_char *tb;
198 u_char *rb;
199 struct cpm_i2c *cpm = i2c_get_adapdata(adap);
200
201 tbdf = cpm->tbase + tx;
202 rbdf = cpm->rbase + rx;
203
204 addr = pmsg->addr << 1;
205 if (pmsg->flags & I2C_M_RD)
206 addr |= 1;
207
208 tb = cpm->txbuf[tx];
209 rb = cpm->rxbuf[rx];
210
211 /* Align read buffer */
212 rb = (u_char *) (((ulong) rb + 1) & ~1);
213
214 tb[0] = addr; /* Device address byte w/rw flag */
215
216 out_be16(&tbdf->cbd_datlen, pmsg->len + 1);
217 out_be16(&tbdf->cbd_sc, 0);
218
219 if (!(pmsg->flags & I2C_M_NOSTART))
220 setbits16(&tbdf->cbd_sc, BD_I2C_START);
221
222 if (tx + 1 == num)
223 setbits16(&tbdf->cbd_sc, BD_SC_LAST | BD_SC_WRAP);
224
225 if (pmsg->flags & I2C_M_RD) {
226 /*
227 * To read, we need an empty buffer of the proper length.
228 * All that is used is the first byte for address, the remainder
229 * is just used for timing (and doesn't really have to exist).
230 */
231
232 dev_dbg(&adap->dev, "cpm_i2c_read(abyte=0x%x)\n", addr);
233
234 out_be16(&rbdf->cbd_datlen, 0);
235 out_be16(&rbdf->cbd_sc, BD_SC_EMPTY | BD_SC_INTRPT);
236
237 if (rx + 1 == CPM_MAXBD)
238 setbits16(&rbdf->cbd_sc, BD_SC_WRAP);
239
240 eieio();
241 setbits16(&tbdf->cbd_sc, BD_SC_READY);
242 } else {
243 dev_dbg(&adap->dev, "cpm_i2c_write(abyte=0x%x)\n", addr);
244
245 memcpy(tb+1, pmsg->buf, pmsg->len);
246
247 eieio();
248 setbits16(&tbdf->cbd_sc, BD_SC_READY | BD_SC_INTRPT);
249 }
250}
251
252static int cpm_i2c_check_message(struct i2c_adapter *adap,
253 struct i2c_msg *pmsg, int tx, int rx)
254{
255 cbd_t __iomem *tbdf;
256 cbd_t __iomem *rbdf;
257 u_char *tb;
258 u_char *rb;
259 struct cpm_i2c *cpm = i2c_get_adapdata(adap);
260
261 tbdf = cpm->tbase + tx;
262 rbdf = cpm->rbase + rx;
263
264 tb = cpm->txbuf[tx];
265 rb = cpm->rxbuf[rx];
266
267 /* Align read buffer */
268 rb = (u_char *) (((uint) rb + 1) & ~1);
269
270 eieio();
271 if (pmsg->flags & I2C_M_RD) {
272 dev_dbg(&adap->dev, "tx sc 0x%04x, rx sc 0x%04x\n",
273 in_be16(&tbdf->cbd_sc), in_be16(&rbdf->cbd_sc));
274
275 if (in_be16(&tbdf->cbd_sc) & BD_SC_NAK) {
276 dev_dbg(&adap->dev, "I2C read; No ack\n");
277 return -ENXIO;
278 }
279 if (in_be16(&rbdf->cbd_sc) & BD_SC_EMPTY) {
280 dev_err(&adap->dev,
281 "I2C read; complete but rbuf empty\n");
282 return -EREMOTEIO;
283 }
284 if (in_be16(&rbdf->cbd_sc) & BD_SC_OV) {
285 dev_err(&adap->dev, "I2C read; Overrun\n");
286 return -EREMOTEIO;
287 }
288 memcpy(pmsg->buf, rb, pmsg->len);
289 } else {
290 dev_dbg(&adap->dev, "tx sc %d 0x%04x\n", tx,
291 in_be16(&tbdf->cbd_sc));
292
293 if (in_be16(&tbdf->cbd_sc) & BD_SC_NAK) {
294 dev_dbg(&adap->dev, "I2C write; No ack\n");
295 return -ENXIO;
296 }
297 if (in_be16(&tbdf->cbd_sc) & BD_SC_UN) {
298 dev_err(&adap->dev, "I2C write; Underrun\n");
299 return -EIO;
300 }
301 if (in_be16(&tbdf->cbd_sc) & BD_SC_CL) {
302 dev_err(&adap->dev, "I2C write; Collision\n");
303 return -EIO;
304 }
305 }
306 return 0;
307}
308
309static int cpm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
310{
311 struct cpm_i2c *cpm = i2c_get_adapdata(adap);
312 struct i2c_reg __iomem *i2c_reg = cpm->i2c_reg;
313 struct i2c_ram __iomem *i2c_ram = cpm->i2c_ram;
314 struct i2c_msg *pmsg;
315 int ret, i;
316 int tptr;
317 int rptr;
318 cbd_t __iomem *tbdf;
319 cbd_t __iomem *rbdf;
320
321 if (num > CPM_MAXBD)
322 return -EINVAL;
323
324 /* Check if we have any oversized READ requests */
325 for (i = 0; i < num; i++) {
326 pmsg = &msgs[i];
327 if (pmsg->len >= CPM_MAX_READ)
328 return -EINVAL;
329 }
330
331 /* Reset to use first buffer */
332 out_be16(&i2c_ram->rbptr, in_be16(&i2c_ram->rbase));
333 out_be16(&i2c_ram->tbptr, in_be16(&i2c_ram->tbase));
334
335 tbdf = cpm->tbase;
336 rbdf = cpm->rbase;
337
338 tptr = 0;
339 rptr = 0;
340
341 while (tptr < num) {
342 pmsg = &msgs[tptr];
343 dev_dbg(&adap->dev, "R: %d T: %d\n", rptr, tptr);
344
345 cpm_i2c_parse_message(adap, pmsg, num, tptr, rptr);
346 if (pmsg->flags & I2C_M_RD)
347 rptr++;
348 tptr++;
349 }
350 /* Start transfer now */
351 /* Enable RX/TX/Error interupts */
352 out_8(&i2c_reg->i2cmr, I2CER_TXE | I2CER_TXB | I2CER_RXB);
353 out_8(&i2c_reg->i2cer, 0xff); /* Clear interrupt status */
354 /* Chip bug, set enable here */
355 setbits8(&i2c_reg->i2mod, I2MOD_EN); /* Enable */
356 /* Begin transmission */
357 setbits8(&i2c_reg->i2com, I2COM_START);
358
359 tptr = 0;
360 rptr = 0;
361
362 while (tptr < num) {
363 /* Check for outstanding messages */
364 dev_dbg(&adap->dev, "test ready.\n");
365 pmsg = &msgs[tptr];
366 if (pmsg->flags & I2C_M_RD)
367 ret = wait_event_interruptible_timeout(cpm->i2c_wait,
368 !(in_be16(&rbdf[rptr].cbd_sc) & BD_SC_EMPTY),
369 1 * HZ);
370 else
371 ret = wait_event_interruptible_timeout(cpm->i2c_wait,
372 !(in_be16(&tbdf[tptr].cbd_sc) & BD_SC_READY),
373 1 * HZ);
374 if (ret == 0) {
375 ret = -EREMOTEIO;
376 dev_err(&adap->dev, "I2C transfer: timeout\n");
377 goto out_err;
378 }
379 if (ret > 0) {
380 dev_dbg(&adap->dev, "ready.\n");
381 ret = cpm_i2c_check_message(adap, pmsg, tptr, rptr);
382 tptr++;
383 if (pmsg->flags & I2C_M_RD)
384 rptr++;
385 if (ret)
386 goto out_err;
387 }
388 }
389#ifdef I2C_CHIP_ERRATA
390 /*
391 * Chip errata, clear enable. This is not needed on rev D4 CPUs.
392 * Disabling I2C too early may cause too short stop condition
393 */
394 udelay(4);
395 clrbits8(&i2c_reg->i2mod, I2MOD_EN);
396#endif
397 return (num);
398
399out_err:
400 cpm_i2c_force_close(adap);
401#ifdef I2C_CHIP_ERRATA
402 /*
403 * Chip errata, clear enable. This is not needed on rev D4 CPUs.
404 */
405 clrbits8(&i2c_reg->i2mod, I2MOD_EN);
406#endif
407 return ret;
408}
409
410static u32 cpm_i2c_func(struct i2c_adapter *adap)
411{
412 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
413}
414
415/* -----exported algorithm data: ------------------------------------- */
416
417static const struct i2c_algorithm cpm_i2c_algo = {
418 .master_xfer = cpm_i2c_xfer,
419 .functionality = cpm_i2c_func,
420};
421
422static const struct i2c_adapter cpm_ops = {
423 .owner = THIS_MODULE,
424 .name = "i2c-cpm",
425 .algo = &cpm_i2c_algo,
426 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
427};
428
429static int __devinit cpm_i2c_setup(struct cpm_i2c *cpm)
430{
431 struct of_device *ofdev = cpm->ofdev;
432 const u32 *data;
433 int len, ret, i;
434 void __iomem *i2c_base;
435 cbd_t __iomem *tbdf;
436 cbd_t __iomem *rbdf;
437 unsigned char brg;
438
439 dev_dbg(&cpm->ofdev->dev, "cpm_i2c_setup()\n");
440
441 init_waitqueue_head(&cpm->i2c_wait);
442
443 cpm->irq = of_irq_to_resource(ofdev->node, 0, NULL);
444 if (cpm->irq == NO_IRQ)
445 return -EINVAL;
446
447 /* Install interrupt handler. */
448 ret = request_irq(cpm->irq, cpm_i2c_interrupt, 0, "cpm_i2c",
449 &cpm->adap);
450 if (ret)
451 return ret;
452
453 /* I2C parameter RAM */
454 i2c_base = of_iomap(ofdev->node, 1);
455 if (i2c_base == NULL) {
456 ret = -EINVAL;
457 goto out_irq;
458 }
459
460 if (of_device_is_compatible(ofdev->node, "fsl,cpm1-i2c")) {
461
462 /* Check for and use a microcode relocation patch. */
463 cpm->i2c_ram = i2c_base;
464 cpm->i2c_addr = in_be16(&cpm->i2c_ram->rpbase);
465
466 /*
467 * Maybe should use cpm_muram_alloc instead of hardcoding
468 * this in micropatch.c
469 */
470 if (cpm->i2c_addr) {
471 cpm->i2c_ram = cpm_muram_addr(cpm->i2c_addr);
472 iounmap(i2c_base);
473 }
474
475 cpm->version = 1;
476
477 } else if (of_device_is_compatible(ofdev->node, "fsl,cpm2-i2c")) {
478 cpm->i2c_addr = cpm_muram_alloc(sizeof(struct i2c_ram), 64);
479 cpm->i2c_ram = cpm_muram_addr(cpm->i2c_addr);
480 out_be16(i2c_base, cpm->i2c_addr);
481 iounmap(i2c_base);
482
483 cpm->version = 2;
484
485 } else {
486 iounmap(i2c_base);
487 ret = -EINVAL;
488 goto out_irq;
489 }
490
491 /* I2C control/status registers */
492 cpm->i2c_reg = of_iomap(ofdev->node, 0);
493 if (cpm->i2c_reg == NULL) {
494 ret = -EINVAL;
495 goto out_ram;
496 }
497
498 data = of_get_property(ofdev->node, "fsl,cpm-command", &len);
499 if (!data || len != 4) {
500 ret = -EINVAL;
501 goto out_reg;
502 }
503 cpm->cp_command = *data;
504
505 data = of_get_property(ofdev->node, "linux,i2c-class", &len);
506 if (data && len == 4)
507 cpm->adap.class = *data;
508
509 data = of_get_property(ofdev->node, "clock-frequency", &len);
510 if (data && len == 4)
511 cpm->freq = *data;
512 else
513 cpm->freq = 60000; /* use 60kHz i2c clock by default */
514
515 /*
516 * Allocate space for CPM_MAXBD transmit and receive buffer
517 * descriptors in the DP ram.
518 */
519 cpm->dp_addr = cpm_muram_alloc(sizeof(cbd_t) * 2 * CPM_MAXBD, 8);
520 if (!cpm->dp_addr) {
521 ret = -ENOMEM;
522 goto out_reg;
523 }
524
525 cpm->tbase = cpm_muram_addr(cpm->dp_addr);
526 cpm->rbase = cpm_muram_addr(cpm->dp_addr + sizeof(cbd_t) * CPM_MAXBD);
527
528 /* Allocate TX and RX buffers */
529
530 tbdf = cpm->tbase;
531 rbdf = cpm->rbase;
532
533 for (i = 0; i < CPM_MAXBD; i++) {
534 cpm->rxbuf[i] = dma_alloc_coherent(
535 NULL, CPM_MAX_READ + 1, &cpm->rxdma[i], GFP_KERNEL);
536 if (!cpm->rxbuf[i]) {
537 ret = -ENOMEM;
538 goto out_muram;
539 }
540 out_be32(&rbdf[i].cbd_bufaddr, ((cpm->rxdma[i] + 1) & ~1));
541
542 cpm->txbuf[i] = (unsigned char *)dma_alloc_coherent(
543 NULL, CPM_MAX_READ + 1, &cpm->txdma[i], GFP_KERNEL);
544 if (!cpm->txbuf[i]) {
545 ret = -ENOMEM;
546 goto out_muram;
547 }
548 out_be32(&tbdf[i].cbd_bufaddr, cpm->txdma[i]);
549 }
550
551 /* Initialize Tx/Rx parameters. */
552
553 cpm_reset_i2c_params(cpm);
554
555 dev_dbg(&cpm->ofdev->dev, "i2c_ram 0x%p, i2c_addr 0x%04x, freq %d\n",
556 cpm->i2c_ram, cpm->i2c_addr, cpm->freq);
557 dev_dbg(&cpm->ofdev->dev, "tbase 0x%04x, rbase 0x%04x\n",
558 (u8 __iomem *)cpm->tbase - DPRAM_BASE,
559 (u8 __iomem *)cpm->rbase - DPRAM_BASE);
560
561 cpm_command(cpm->cp_command, CPM_CR_INIT_TRX);
562
563 /*
564 * Select an invalid address. Just make sure we don't use loopback mode
565 */
566 out_8(&cpm->i2c_reg->i2add, 0x7f << 1);
567
568 /*
569 * PDIV is set to 00 in i2mod, so brgclk/32 is used as input to the
570 * i2c baud rate generator. This is divided by 2 x (DIV + 3) to get
571 * the actual i2c bus frequency.
572 */
573 brg = get_brgfreq() / (32 * 2 * cpm->freq) - 3;
574 out_8(&cpm->i2c_reg->i2brg, brg);
575
576 out_8(&cpm->i2c_reg->i2mod, 0x00);
577 out_8(&cpm->i2c_reg->i2com, I2COM_MASTER); /* Master mode */
578
579 /* Disable interrupts. */
580 out_8(&cpm->i2c_reg->i2cmr, 0);
581 out_8(&cpm->i2c_reg->i2cer, 0xff);
582
583 return 0;
584
585out_muram:
586 for (i = 0; i < CPM_MAXBD; i++) {
587 if (cpm->rxbuf[i])
588 dma_free_coherent(NULL, CPM_MAX_READ + 1,
589 cpm->rxbuf[i], cpm->rxdma[i]);
590 if (cpm->txbuf[i])
591 dma_free_coherent(NULL, CPM_MAX_READ + 1,
592 cpm->txbuf[i], cpm->txdma[i]);
593 }
594 cpm_muram_free(cpm->dp_addr);
595out_reg:
596 iounmap(cpm->i2c_reg);
597out_ram:
598 if ((cpm->version == 1) && (!cpm->i2c_addr))
599 iounmap(cpm->i2c_ram);
600 if (cpm->version == 2)
601 cpm_muram_free(cpm->i2c_addr);
602out_irq:
603 free_irq(cpm->irq, &cpm->adap);
604 return ret;
605}
606
607static void cpm_i2c_shutdown(struct cpm_i2c *cpm)
608{
609 int i;
610
611 /* Shut down I2C. */
612 clrbits8(&cpm->i2c_reg->i2mod, I2MOD_EN);
613
614 /* Disable interrupts */
615 out_8(&cpm->i2c_reg->i2cmr, 0);
616 out_8(&cpm->i2c_reg->i2cer, 0xff);
617
618 free_irq(cpm->irq, &cpm->adap);
619
620 /* Free all memory */
621 for (i = 0; i < CPM_MAXBD; i++) {
622 dma_free_coherent(NULL, CPM_MAX_READ + 1,
623 cpm->rxbuf[i], cpm->rxdma[i]);
624 dma_free_coherent(NULL, CPM_MAX_READ + 1,
625 cpm->txbuf[i], cpm->txdma[i]);
626 }
627
628 cpm_muram_free(cpm->dp_addr);
629 iounmap(cpm->i2c_reg);
630
631 if ((cpm->version == 1) && (!cpm->i2c_addr))
632 iounmap(cpm->i2c_ram);
633 if (cpm->version == 2)
634 cpm_muram_free(cpm->i2c_addr);
635}
636
637static int __devinit cpm_i2c_probe(struct of_device *ofdev,
638 const struct of_device_id *match)
639{
640 int result, len;
641 struct cpm_i2c *cpm;
642 const u32 *data;
643
644 cpm = kzalloc(sizeof(struct cpm_i2c), GFP_KERNEL);
645 if (!cpm)
646 return -ENOMEM;
647
648 cpm->ofdev = ofdev;
649
650 dev_set_drvdata(&ofdev->dev, cpm);
651
652 cpm->adap = cpm_ops;
653 i2c_set_adapdata(&cpm->adap, cpm);
654 cpm->adap.dev.parent = &ofdev->dev;
655
656 result = cpm_i2c_setup(cpm);
657 if (result) {
658 dev_err(&ofdev->dev, "Unable to init hardware\n");
659 goto out_free;
660 }
661
662 /* register new adapter to i2c module... */
663
664 data = of_get_property(ofdev->node, "linux,i2c-index", &len);
665 if (data && len == 4) {
666 cpm->adap.nr = *data;
667 result = i2c_add_numbered_adapter(&cpm->adap);
668 } else
669 result = i2c_add_adapter(&cpm->adap);
670
671 if (result < 0) {
672 dev_err(&ofdev->dev, "Unable to register with I2C\n");
673 goto out_shut;
674 }
675
676 dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
677 cpm->adap.name);
678
679 /*
680 * register OF I2C devices
681 */
682 of_register_i2c_devices(&cpm->adap, ofdev->node);
683
684 return 0;
685out_shut:
686 cpm_i2c_shutdown(cpm);
687out_free:
688 dev_set_drvdata(&ofdev->dev, NULL);
689 kfree(cpm);
690
691 return result;
692}
693
694static int __devexit cpm_i2c_remove(struct of_device *ofdev)
695{
696 struct cpm_i2c *cpm = dev_get_drvdata(&ofdev->dev);
697
698 i2c_del_adapter(&cpm->adap);
699
700 cpm_i2c_shutdown(cpm);
701
702 dev_set_drvdata(&ofdev->dev, NULL);
703 kfree(cpm);
704
705 return 0;
706}
707
708static const struct of_device_id cpm_i2c_match[] = {
709 {
710 .compatible = "fsl,cpm1-i2c",
711 },
712 {
713 .compatible = "fsl,cpm2-i2c",
714 },
715 {},
716};
717
718MODULE_DEVICE_TABLE(of, cpm_i2c_match);
719
720static struct of_platform_driver cpm_i2c_driver = {
721 .match_table = cpm_i2c_match,
722 .probe = cpm_i2c_probe,
723 .remove = __devexit_p(cpm_i2c_remove),
724 .driver = {
725 .name = "fsl-i2c-cpm",
726 .owner = THIS_MODULE,
727 }
728};
729
730static int __init cpm_i2c_init(void)
731{
732 return of_register_platform_driver(&cpm_i2c_driver);
733}
734
735static void __exit cpm_i2c_exit(void)
736{
737 of_unregister_platform_driver(&cpm_i2c_driver);
738}
739
740module_init(cpm_i2c_init);
741module_exit(cpm_i2c_exit);
742
743MODULE_AUTHOR("Jochen Friedrich <jochen@scram.de>");
744MODULE_DESCRIPTION("I2C-Bus adapter routines for CPM boards");
745MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 7ecbfc429b1..af3846eda98 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -85,6 +85,7 @@
85#define DAVINCI_I2C_MDR_MST (1 << 10) 85#define DAVINCI_I2C_MDR_MST (1 << 10)
86#define DAVINCI_I2C_MDR_TRX (1 << 9) 86#define DAVINCI_I2C_MDR_TRX (1 << 9)
87#define DAVINCI_I2C_MDR_XA (1 << 8) 87#define DAVINCI_I2C_MDR_XA (1 << 8)
88#define DAVINCI_I2C_MDR_RM (1 << 7)
88#define DAVINCI_I2C_MDR_IRS (1 << 5) 89#define DAVINCI_I2C_MDR_IRS (1 << 5)
89 90
90#define DAVINCI_I2C_IMR_AAS (1 << 6) 91#define DAVINCI_I2C_IMR_AAS (1 << 6)
@@ -112,6 +113,7 @@ struct davinci_i2c_dev {
112 u8 *buf; 113 u8 *buf;
113 size_t buf_len; 114 size_t buf_len;
114 int irq; 115 int irq;
116 u8 terminate;
115 struct i2c_adapter adapter; 117 struct i2c_adapter adapter;
116}; 118};
117 119
@@ -142,6 +144,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
142 struct davinci_i2c_platform_data *pdata = dev->dev->platform_data; 144 struct davinci_i2c_platform_data *pdata = dev->dev->platform_data;
143 u16 psc; 145 u16 psc;
144 u32 clk; 146 u32 clk;
147 u32 d;
145 u32 clkh; 148 u32 clkh;
146 u32 clkl; 149 u32 clkl;
147 u32 input_clock = clk_get_rate(dev->clk); 150 u32 input_clock = clk_get_rate(dev->clk);
@@ -171,23 +174,29 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
171 * if PSC > 1 , d = 5 174 * if PSC > 1 , d = 5
172 */ 175 */
173 176
174 psc = 26; /* To get 1MHz clock */ 177 /* get minimum of 7 MHz clock, but max of 12 MHz */
178 psc = (input_clock / 7000000) - 1;
179 if ((input_clock / (psc + 1)) > 12000000)
180 psc++; /* better to run under spec than over */
181 d = (psc >= 2) ? 5 : 7 - psc;
175 182
176 clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000)) - 10; 183 clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000)) - (d << 1);
177 clkh = (50 * clk) / 100; 184 clkh = clk >> 1;
178 clkl = clk - clkh; 185 clkl = clk - clkh;
179 186
180 davinci_i2c_write_reg(dev, DAVINCI_I2C_PSC_REG, psc); 187 davinci_i2c_write_reg(dev, DAVINCI_I2C_PSC_REG, psc);
181 davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh); 188 davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKH_REG, clkh);
182 davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl); 189 davinci_i2c_write_reg(dev, DAVINCI_I2C_CLKL_REG, clkl);
183 190
184 dev_dbg(dev->dev, "CLK = %d\n", clk); 191 dev_dbg(dev->dev, "input_clock = %d, CLK = %d\n", input_clock, clk);
185 dev_dbg(dev->dev, "PSC = %d\n", 192 dev_dbg(dev->dev, "PSC = %d\n",
186 davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG)); 193 davinci_i2c_read_reg(dev, DAVINCI_I2C_PSC_REG));
187 dev_dbg(dev->dev, "CLKL = %d\n", 194 dev_dbg(dev->dev, "CLKL = %d\n",
188 davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKL_REG)); 195 davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKL_REG));
189 dev_dbg(dev->dev, "CLKH = %d\n", 196 dev_dbg(dev->dev, "CLKH = %d\n",
190 davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKH_REG)); 197 davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKH_REG));
198 dev_dbg(dev->dev, "bus_freq = %dkHz, bus_delay = %d\n",
199 pdata->bus_freq, pdata->bus_delay);
191 200
192 /* Take the I2C module out of reset: */ 201 /* Take the I2C module out of reset: */
193 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); 202 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
@@ -233,7 +242,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
233 struct davinci_i2c_dev *dev = i2c_get_adapdata(adap); 242 struct davinci_i2c_dev *dev = i2c_get_adapdata(adap);
234 struct davinci_i2c_platform_data *pdata = dev->dev->platform_data; 243 struct davinci_i2c_platform_data *pdata = dev->dev->platform_data;
235 u32 flag; 244 u32 flag;
236 u32 stat;
237 u16 w; 245 u16 w;
238 int r; 246 int r;
239 247
@@ -254,12 +262,9 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
254 262
255 davinci_i2c_write_reg(dev, DAVINCI_I2C_CNT_REG, dev->buf_len); 263 davinci_i2c_write_reg(dev, DAVINCI_I2C_CNT_REG, dev->buf_len);
256 264
257 init_completion(&dev->cmd_complete); 265 INIT_COMPLETION(dev->cmd_complete);
258 dev->cmd_err = 0; 266 dev->cmd_err = 0;
259 267
260 /* Clear any pending interrupts by reading the IVR */
261 stat = davinci_i2c_read_reg(dev, DAVINCI_I2C_IVR_REG);
262
263 /* Take I2C out of reset, configure it as master and set the 268 /* Take I2C out of reset, configure it as master and set the
264 * start bit */ 269 * start bit */
265 flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST | DAVINCI_I2C_MDR_STT; 270 flag = DAVINCI_I2C_MDR_IRS | DAVINCI_I2C_MDR_MST | DAVINCI_I2C_MDR_STT;
@@ -280,20 +285,34 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
280 MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1); 285 MOD_REG_BIT(w, DAVINCI_I2C_IMR_XRDY, 1);
281 davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w); 286 davinci_i2c_write_reg(dev, DAVINCI_I2C_IMR_REG, w);
282 287
288 dev->terminate = 0;
283 /* write the data into mode register */ 289 /* write the data into mode register */
284 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); 290 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag);
285 291
286 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 292 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
287 DAVINCI_I2C_TIMEOUT); 293 DAVINCI_I2C_TIMEOUT);
288 dev->buf_len = 0;
289 if (r < 0)
290 return r;
291
292 if (r == 0) { 294 if (r == 0) {
293 dev_err(dev->dev, "controller timed out\n"); 295 dev_err(dev->dev, "controller timed out\n");
294 i2c_davinci_init(dev); 296 i2c_davinci_init(dev);
297 dev->buf_len = 0;
295 return -ETIMEDOUT; 298 return -ETIMEDOUT;
296 } 299 }
300 if (dev->buf_len) {
301 /* This should be 0 if all bytes were transferred
302 * or dev->cmd_err denotes an error.
303 * A signal may have aborted the transfer.
304 */
305 if (r >= 0) {
306 dev_err(dev->dev, "abnormal termination buf_len=%i\n",
307 dev->buf_len);
308 r = -EREMOTEIO;
309 }
310 dev->terminate = 1;
311 wmb();
312 dev->buf_len = 0;
313 }
314 if (r < 0)
315 return r;
297 316
298 /* no error */ 317 /* no error */
299 if (likely(!dev->cmd_err)) 318 if (likely(!dev->cmd_err))
@@ -338,12 +357,11 @@ i2c_davinci_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
338 357
339 for (i = 0; i < num; i++) { 358 for (i = 0; i < num; i++) {
340 ret = i2c_davinci_xfer_msg(adap, &msgs[i], (i == (num - 1))); 359 ret = i2c_davinci_xfer_msg(adap, &msgs[i], (i == (num - 1)));
360 dev_dbg(dev->dev, "%s [%d/%d] ret: %d\n", __func__, i + 1, num,
361 ret);
341 if (ret < 0) 362 if (ret < 0)
342 return ret; 363 return ret;
343 } 364 }
344
345 dev_dbg(dev->dev, "%s:%d ret: %d\n", __func__, __LINE__, ret);
346
347 return num; 365 return num;
348} 366}
349 367
@@ -352,6 +370,27 @@ static u32 i2c_davinci_func(struct i2c_adapter *adap)
352 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); 370 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
353} 371}
354 372
373static void terminate_read(struct davinci_i2c_dev *dev)
374{
375 u16 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
376 w |= DAVINCI_I2C_MDR_NACK;
377 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
378
379 /* Throw away data */
380 davinci_i2c_read_reg(dev, DAVINCI_I2C_DRR_REG);
381 if (!dev->terminate)
382 dev_err(dev->dev, "RDR IRQ while no data requested\n");
383}
384static void terminate_write(struct davinci_i2c_dev *dev)
385{
386 u16 w = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG);
387 w |= DAVINCI_I2C_MDR_RM | DAVINCI_I2C_MDR_STP;
388 davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, w);
389
390 if (!dev->terminate)
391 dev_err(dev->dev, "TDR IRQ while no data to send\n");
392}
393
355/* 394/*
356 * Interrupt service routine. This gets called whenever an I2C interrupt 395 * Interrupt service routine. This gets called whenever an I2C interrupt
357 * occurs. 396 * occurs.
@@ -372,12 +411,15 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
372 411
373 switch (stat) { 412 switch (stat) {
374 case DAVINCI_I2C_IVR_AL: 413 case DAVINCI_I2C_IVR_AL:
414 /* Arbitration lost, must retry */
375 dev->cmd_err |= DAVINCI_I2C_STR_AL; 415 dev->cmd_err |= DAVINCI_I2C_STR_AL;
416 dev->buf_len = 0;
376 complete(&dev->cmd_complete); 417 complete(&dev->cmd_complete);
377 break; 418 break;
378 419
379 case DAVINCI_I2C_IVR_NACK: 420 case DAVINCI_I2C_IVR_NACK:
380 dev->cmd_err |= DAVINCI_I2C_STR_NACK; 421 dev->cmd_err |= DAVINCI_I2C_STR_NACK;
422 dev->buf_len = 0;
381 complete(&dev->cmd_complete); 423 complete(&dev->cmd_complete);
382 break; 424 break;
383 425
@@ -399,9 +441,10 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
399 davinci_i2c_write_reg(dev, 441 davinci_i2c_write_reg(dev,
400 DAVINCI_I2C_STR_REG, 442 DAVINCI_I2C_STR_REG,
401 DAVINCI_I2C_IMR_RRDY); 443 DAVINCI_I2C_IMR_RRDY);
402 } else 444 } else {
403 dev_err(dev->dev, "RDR IRQ while no " 445 /* signal can terminate transfer */
404 "data requested\n"); 446 terminate_read(dev);
447 }
405 break; 448 break;
406 449
407 case DAVINCI_I2C_IVR_XRDY: 450 case DAVINCI_I2C_IVR_XRDY:
@@ -418,9 +461,10 @@ static irqreturn_t i2c_davinci_isr(int this_irq, void *dev_id)
418 davinci_i2c_write_reg(dev, 461 davinci_i2c_write_reg(dev,
419 DAVINCI_I2C_IMR_REG, 462 DAVINCI_I2C_IMR_REG,
420 w); 463 w);
421 } else 464 } else {
422 dev_err(dev->dev, "TDR IRQ while no data to " 465 /* signal can terminate transfer */
423 "send\n"); 466 terminate_write(dev);
467 }
424 break; 468 break;
425 469
426 case DAVINCI_I2C_IVR_SCD: 470 case DAVINCI_I2C_IVR_SCD:
@@ -475,6 +519,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
475 goto err_release_region; 519 goto err_release_region;
476 } 520 }
477 521
522 init_completion(&dev->cmd_complete);
478 dev->dev = get_device(&pdev->dev); 523 dev->dev = get_device(&pdev->dev);
479 dev->irq = irq->start; 524 dev->irq = irq->start;
480 platform_set_drvdata(pdev, dev); 525 platform_set_drvdata(pdev, dev);
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index b7a9977b025..7f38c01fb3a 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -196,13 +196,11 @@ static struct i2c_algo_pcf_data pcf_isa_data = {
196 .getown = pcf_isa_getown, 196 .getown = pcf_isa_getown,
197 .getclock = pcf_isa_getclock, 197 .getclock = pcf_isa_getclock,
198 .waitforpin = pcf_isa_waitforpin, 198 .waitforpin = pcf_isa_waitforpin,
199 .udelay = 10,
200 .timeout = 100,
201}; 199};
202 200
203static struct i2c_adapter pcf_isa_ops = { 201static struct i2c_adapter pcf_isa_ops = {
204 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
205 .class = I2C_CLASS_HWMON, 203 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
206 .id = I2C_HW_P_ELEK, 204 .id = I2C_HW_P_ELEK,
207 .algo_data = &pcf_isa_data, 205 .algo_data = &pcf_isa_data,
208 .name = "i2c-elektor", 206 .name = "i2c-elektor",
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 7c1b762aa68..79b455a1f09 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -140,7 +140,7 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
140 adap->owner = THIS_MODULE; 140 adap->owner = THIS_MODULE;
141 snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); 141 snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
142 adap->algo_data = bit_data; 142 adap->algo_data = bit_data;
143 adap->class = I2C_CLASS_HWMON; 143 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
144 adap->dev.parent = &pdev->dev; 144 adap->dev.parent = &pdev->dev;
145 145
146 /* 146 /*
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index f9972f9651e..1098f21ace1 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -1,7 +1,4 @@
1/* 1/*
2 i2c-hydra.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
4
5 i2c Support for the Apple `Hydra' Mac I/O 2 i2c Support for the Apple `Hydra' Mac I/O
6 3
7 Copyright (c) 1999-2004 Geert Uytterhoeven <geert@linux-m68k.org> 4 Copyright (c) 1999-2004 Geert Uytterhoeven <geert@linux-m68k.org>
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index b0f771fe432..dc7ea32b69a 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1,10 +1,8 @@
1/* 1/*
2 i2c-i801.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker 3 Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker
6 <mdsxyz123@yahoo.com> 4 <mdsxyz123@yahoo.com>
7 Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> 5 Copyright (C) 2007, 2008 Jean Delvare <khali@linux-fr.org>
8 6
9 This program is free software; you can redistribute it and/or modify 7 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 8 it under the terms of the GNU General Public License as published by
@@ -64,6 +62,7 @@
64#include <linux/ioport.h> 62#include <linux/ioport.h>
65#include <linux/init.h> 63#include <linux/init.h>
66#include <linux/i2c.h> 64#include <linux/i2c.h>
65#include <linux/acpi.h>
67#include <asm/io.h> 66#include <asm/io.h>
68 67
69/* I801 SMBus address offsets */ 68/* I801 SMBus address offsets */
@@ -121,6 +120,10 @@
121#define SMBHSTSTS_INTR 0x02 120#define SMBHSTSTS_INTR 0x02
122#define SMBHSTSTS_HOST_BUSY 0x01 121#define SMBHSTSTS_HOST_BUSY 0x01
123 122
123#define STATUS_FLAGS (SMBHSTSTS_BYTE_DONE | SMBHSTSTS_FAILED | \
124 SMBHSTSTS_BUS_ERR | SMBHSTSTS_DEV_ERR | \
125 SMBHSTSTS_INTR)
126
124static unsigned long i801_smba; 127static unsigned long i801_smba;
125static unsigned char i801_original_hstcfg; 128static unsigned char i801_original_hstcfg;
126static struct pci_driver i801_driver; 129static struct pci_driver i801_driver;
@@ -132,105 +135,137 @@ static struct pci_dev *I801_dev;
132#define FEATURE_I2C_BLOCK_READ (1 << 3) 135#define FEATURE_I2C_BLOCK_READ (1 << 3)
133static unsigned int i801_features; 136static unsigned int i801_features;
134 137
135static int i801_transaction(int xact) 138/* Make sure the SMBus host is ready to start transmitting.
139 Return 0 if it is, -EBUSY if it is not. */
140static int i801_check_pre(void)
136{ 141{
137 int temp; 142 int status;
138 int result = 0;
139 int timeout = 0;
140 143
141 dev_dbg(&I801_dev->dev, "Transaction (pre): CNT=%02x, CMD=%02x, " 144 status = inb_p(SMBHSTSTS);
142 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT), 145 if (status & SMBHSTSTS_HOST_BUSY) {
143 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 146 dev_err(&I801_dev->dev, "SMBus is busy, can't use it!\n");
144 inb_p(SMBHSTDAT1)); 147 return -EBUSY;
145 148 }
146 /* Make sure the SMBus host is ready to start transmitting */ 149
147 /* 0x1f = Failed, Bus_Err, Dev_Err, Intr, Host_Busy */ 150 status &= STATUS_FLAGS;
148 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 151 if (status) {
149 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). Resetting...\n", 152 dev_dbg(&I801_dev->dev, "Clearing status flags (%02x)\n",
150 temp); 153 status);
151 outb_p(temp, SMBHSTSTS); 154 outb_p(status, SMBHSTSTS);
152 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 155 status = inb_p(SMBHSTSTS) & STATUS_FLAGS;
153 dev_dbg(&I801_dev->dev, "Failed! (%02x)\n", temp); 156 if (status) {
154 return -1; 157 dev_err(&I801_dev->dev,
155 } else { 158 "Failed clearing status flags (%02x)\n",
156 dev_dbg(&I801_dev->dev, "Successful!\n"); 159 status);
160 return -EBUSY;
157 } 161 }
158 } 162 }
159 163
160 /* the current contents of SMBHSTCNT can be overwritten, since PEC, 164 return 0;
161 * INTREN, SMBSCMD are passed in xact */ 165}
162 outb_p(xact | I801_START, SMBHSTCNT);
163 166
164 /* We will always wait for a fraction of a second! */ 167/* Convert the status register to an error code, and clear it. */
165 do { 168static int i801_check_post(int status, int timeout)
166 msleep(1); 169{
167 temp = inb_p(SMBHSTSTS); 170 int result = 0;
168 } while ((temp & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));
169 171
170 /* If the SMBus is still busy, we give up */ 172 /* If the SMBus is still busy, we give up */
171 if (timeout >= MAX_TIMEOUT) { 173 if (timeout) {
172 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n"); 174 dev_err(&I801_dev->dev, "Transaction timeout\n");
173 result = -1;
174 /* try to stop the current command */ 175 /* try to stop the current command */
175 dev_dbg(&I801_dev->dev, "Terminating the current operation\n"); 176 dev_dbg(&I801_dev->dev, "Terminating the current operation\n");
176 outb_p(inb_p(SMBHSTCNT) | SMBHSTCNT_KILL, SMBHSTCNT); 177 outb_p(inb_p(SMBHSTCNT) | SMBHSTCNT_KILL, SMBHSTCNT);
177 msleep(1); 178 msleep(1);
178 outb_p(inb_p(SMBHSTCNT) & (~SMBHSTCNT_KILL), SMBHSTCNT); 179 outb_p(inb_p(SMBHSTCNT) & (~SMBHSTCNT_KILL), SMBHSTCNT);
179 }
180 180
181 if (temp & SMBHSTSTS_FAILED) { 181 /* Check if it worked */
182 result = -1; 182 status = inb_p(SMBHSTSTS);
183 dev_dbg(&I801_dev->dev, "Error: Failed bus transaction\n"); 183 if ((status & SMBHSTSTS_HOST_BUSY) ||
184 !(status & SMBHSTSTS_FAILED))
185 dev_err(&I801_dev->dev,
186 "Failed terminating the transaction\n");
187 outb_p(STATUS_FLAGS, SMBHSTSTS);
188 return -ETIMEDOUT;
184 } 189 }
185 190
186 if (temp & SMBHSTSTS_BUS_ERR) { 191 if (status & SMBHSTSTS_FAILED) {
187 result = -1; 192 result = -EIO;
188 dev_err(&I801_dev->dev, "Bus collision! SMBus may be locked " 193 dev_err(&I801_dev->dev, "Transaction failed\n");
189 "until next hard reset. (sorry!)\n");
190 /* Clock stops and slave is stuck in mid-transmission */
191 } 194 }
192 195 if (status & SMBHSTSTS_DEV_ERR) {
193 if (temp & SMBHSTSTS_DEV_ERR) { 196 result = -ENXIO;
194 result = -1; 197 dev_dbg(&I801_dev->dev, "No response\n");
195 dev_dbg(&I801_dev->dev, "Error: no response!\n"); 198 }
199 if (status & SMBHSTSTS_BUS_ERR) {
200 result = -EAGAIN;
201 dev_dbg(&I801_dev->dev, "Lost arbitration\n");
196 } 202 }
197 203
198 if ((inb_p(SMBHSTSTS) & 0x1f) != 0x00) 204 if (result) {
199 outb_p(inb(SMBHSTSTS), SMBHSTSTS); 205 /* Clear error flags */
200 206 outb_p(status & STATUS_FLAGS, SMBHSTSTS);
201 if ((temp = (0x1f & inb_p(SMBHSTSTS))) != 0x00) { 207 status = inb_p(SMBHSTSTS) & STATUS_FLAGS;
202 dev_dbg(&I801_dev->dev, "Failed reset at end of transaction " 208 if (status) {
203 "(%02x)\n", temp); 209 dev_warn(&I801_dev->dev, "Failed clearing status "
210 "flags at end of transaction (%02x)\n",
211 status);
212 }
204 } 213 }
205 dev_dbg(&I801_dev->dev, "Transaction (post): CNT=%02x, CMD=%02x, " 214
206 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
207 inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
208 inb_p(SMBHSTDAT1));
209 return result; 215 return result;
210} 216}
211 217
218static int i801_transaction(int xact)
219{
220 int status;
221 int result;
222 int timeout = 0;
223
224 result = i801_check_pre();
225 if (result < 0)
226 return result;
227
228 /* the current contents of SMBHSTCNT can be overwritten, since PEC,
229 * INTREN, SMBSCMD are passed in xact */
230 outb_p(xact | I801_START, SMBHSTCNT);
231
232 /* We will always wait for a fraction of a second! */
233 do {
234 msleep(1);
235 status = inb_p(SMBHSTSTS);
236 } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_TIMEOUT));
237
238 result = i801_check_post(status, timeout >= MAX_TIMEOUT);
239 if (result < 0)
240 return result;
241
242 outb_p(SMBHSTSTS_INTR, SMBHSTSTS);
243 return 0;
244}
245
212/* wait for INTR bit as advised by Intel */ 246/* wait for INTR bit as advised by Intel */
213static void i801_wait_hwpec(void) 247static void i801_wait_hwpec(void)
214{ 248{
215 int timeout = 0; 249 int timeout = 0;
216 int temp; 250 int status;
217 251
218 do { 252 do {
219 msleep(1); 253 msleep(1);
220 temp = inb_p(SMBHSTSTS); 254 status = inb_p(SMBHSTSTS);
221 } while ((!(temp & SMBHSTSTS_INTR)) 255 } while ((!(status & SMBHSTSTS_INTR))
222 && (timeout++ < MAX_TIMEOUT)); 256 && (timeout++ < MAX_TIMEOUT));
223 257
224 if (timeout >= MAX_TIMEOUT) { 258 if (timeout >= MAX_TIMEOUT) {
225 dev_dbg(&I801_dev->dev, "PEC Timeout!\n"); 259 dev_dbg(&I801_dev->dev, "PEC Timeout!\n");
226 } 260 }
227 outb_p(temp, SMBHSTSTS); 261 outb_p(status, SMBHSTSTS);
228} 262}
229 263
230static int i801_block_transaction_by_block(union i2c_smbus_data *data, 264static int i801_block_transaction_by_block(union i2c_smbus_data *data,
231 char read_write, int hwpec) 265 char read_write, int hwpec)
232{ 266{
233 int i, len; 267 int i, len;
268 int status;
234 269
235 inb_p(SMBHSTCNT); /* reset the data buffer index */ 270 inb_p(SMBHSTCNT); /* reset the data buffer index */
236 271
@@ -242,14 +277,15 @@ static int i801_block_transaction_by_block(union i2c_smbus_data *data,
242 outb_p(data->block[i+1], SMBBLKDAT); 277 outb_p(data->block[i+1], SMBBLKDAT);
243 } 278 }
244 279
245 if (i801_transaction(I801_BLOCK_DATA | ENABLE_INT9 | 280 status = i801_transaction(I801_BLOCK_DATA | ENABLE_INT9 |
246 I801_PEC_EN * hwpec)) 281 I801_PEC_EN * hwpec);
247 return -1; 282 if (status)
283 return status;
248 284
249 if (read_write == I2C_SMBUS_READ) { 285 if (read_write == I2C_SMBUS_READ) {
250 len = inb_p(SMBHSTDAT0); 286 len = inb_p(SMBHSTDAT0);
251 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) 287 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX)
252 return -1; 288 return -EPROTO;
253 289
254 data->block[0] = len; 290 data->block[0] = len;
255 for (i = 0; i < len; i++) 291 for (i = 0; i < len; i++)
@@ -264,10 +300,13 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
264{ 300{
265 int i, len; 301 int i, len;
266 int smbcmd; 302 int smbcmd;
267 int temp; 303 int status;
268 int result = 0; 304 int result;
269 int timeout; 305 int timeout;
270 unsigned char errmask; 306
307 result = i801_check_pre();
308 if (result < 0)
309 return result;
271 310
272 len = data->block[0]; 311 len = data->block[0];
273 312
@@ -291,36 +330,6 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
291 } 330 }
292 outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT); 331 outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT);
293 332
294 dev_dbg(&I801_dev->dev, "Block (pre %d): CNT=%02x, CMD=%02x, "
295 "ADD=%02x, DAT0=%02x, DAT1=%02x, BLKDAT=%02x\n", i,
296 inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
297 inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1), inb_p(SMBBLKDAT));
298
299 /* Make sure the SMBus host is ready to start transmitting */
300 temp = inb_p(SMBHSTSTS);
301 if (i == 1) {
302 /* Erroneous conditions before transaction:
303 * Byte_Done, Failed, Bus_Err, Dev_Err, Intr, Host_Busy */
304 errmask = 0x9f;
305 } else {
306 /* Erroneous conditions during transaction:
307 * Failed, Bus_Err, Dev_Err, Intr */
308 errmask = 0x1e;
309 }
310 if (temp & errmask) {
311 dev_dbg(&I801_dev->dev, "SMBus busy (%02x). "
312 "Resetting...\n", temp);
313 outb_p(temp, SMBHSTSTS);
314 if (((temp = inb_p(SMBHSTSTS)) & errmask) != 0x00) {
315 dev_err(&I801_dev->dev,
316 "Reset failed! (%02x)\n", temp);
317 return -1;
318 }
319 if (i != 1)
320 /* if die in middle of block transaction, fail */
321 return -1;
322 }
323
324 if (i == 1) 333 if (i == 1)
325 outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT); 334 outb_p(inb(SMBHSTCNT) | I801_START, SMBHSTCNT);
326 335
@@ -328,41 +337,28 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
328 timeout = 0; 337 timeout = 0;
329 do { 338 do {
330 msleep(1); 339 msleep(1);
331 temp = inb_p(SMBHSTSTS); 340 status = inb_p(SMBHSTSTS);
332 } 341 }
333 while ((!(temp & SMBHSTSTS_BYTE_DONE)) 342 while ((!(status & SMBHSTSTS_BYTE_DONE))
334 && (timeout++ < MAX_TIMEOUT)); 343 && (timeout++ < MAX_TIMEOUT));
335 344
336 /* If the SMBus is still busy, we give up */ 345 result = i801_check_post(status, timeout >= MAX_TIMEOUT);
337 if (timeout >= MAX_TIMEOUT) { 346 if (result < 0)
338 /* try to stop the current command */ 347 return result;
339 dev_dbg(&I801_dev->dev, "Terminating the current "
340 "operation\n");
341 outb_p(inb_p(SMBHSTCNT) | SMBHSTCNT_KILL, SMBHSTCNT);
342 msleep(1);
343 outb_p(inb_p(SMBHSTCNT) & (~SMBHSTCNT_KILL),
344 SMBHSTCNT);
345 result = -1;
346 dev_dbg(&I801_dev->dev, "SMBus Timeout!\n");
347 }
348
349 if (temp & SMBHSTSTS_FAILED) {
350 result = -1;
351 dev_dbg(&I801_dev->dev,
352 "Error: Failed bus transaction\n");
353 } else if (temp & SMBHSTSTS_BUS_ERR) {
354 result = -1;
355 dev_err(&I801_dev->dev, "Bus collision!\n");
356 } else if (temp & SMBHSTSTS_DEV_ERR) {
357 result = -1;
358 dev_dbg(&I801_dev->dev, "Error: no response!\n");
359 }
360 348
361 if (i == 1 && read_write == I2C_SMBUS_READ 349 if (i == 1 && read_write == I2C_SMBUS_READ
362 && command != I2C_SMBUS_I2C_BLOCK_DATA) { 350 && command != I2C_SMBUS_I2C_BLOCK_DATA) {
363 len = inb_p(SMBHSTDAT0); 351 len = inb_p(SMBHSTDAT0);
364 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) 352 if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) {
365 return -1; 353 dev_err(&I801_dev->dev,
354 "Illegal SMBus block read size %d\n",
355 len);
356 /* Recover */
357 while (inb_p(SMBHSTSTS) & SMBHSTSTS_HOST_BUSY)
358 outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS);
359 outb_p(SMBHSTSTS_INTR, SMBHSTSTS);
360 return -EPROTO;
361 }
366 data->block[0] = len; 362 data->block[0] = len;
367 } 363 }
368 364
@@ -371,30 +367,19 @@ static int i801_block_transaction_byte_by_byte(union i2c_smbus_data *data,
371 data->block[i] = inb_p(SMBBLKDAT); 367 data->block[i] = inb_p(SMBBLKDAT);
372 if (read_write == I2C_SMBUS_WRITE && i+1 <= len) 368 if (read_write == I2C_SMBUS_WRITE && i+1 <= len)
373 outb_p(data->block[i+1], SMBBLKDAT); 369 outb_p(data->block[i+1], SMBBLKDAT);
374 if ((temp & 0x9e) != 0x00)
375 outb_p(temp, SMBHSTSTS); /* signals SMBBLKDAT ready */
376
377 if ((temp = (0x1e & inb_p(SMBHSTSTS))) != 0x00) {
378 dev_dbg(&I801_dev->dev,
379 "Bad status (%02x) at end of transaction\n",
380 temp);
381 }
382 dev_dbg(&I801_dev->dev, "Block (post %d): CNT=%02x, CMD=%02x, "
383 "ADD=%02x, DAT0=%02x, DAT1=%02x, BLKDAT=%02x\n", i,
384 inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
385 inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1), inb_p(SMBBLKDAT));
386 370
387 if (result < 0) 371 /* signals SMBBLKDAT ready */
388 return result; 372 outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS);
389 } 373 }
390 return result; 374
375 return 0;
391} 376}
392 377
393static int i801_set_block_buffer_mode(void) 378static int i801_set_block_buffer_mode(void)
394{ 379{
395 outb_p(inb_p(SMBAUXCTL) | SMBAUXCTL_E32B, SMBAUXCTL); 380 outb_p(inb_p(SMBAUXCTL) | SMBAUXCTL_E32B, SMBAUXCTL);
396 if ((inb_p(SMBAUXCTL) & SMBAUXCTL_E32B) == 0) 381 if ((inb_p(SMBAUXCTL) & SMBAUXCTL_E32B) == 0)
397 return -1; 382 return -EIO;
398 return 0; 383 return 0;
399} 384}
400 385
@@ -414,7 +399,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
414 } else if (!(i801_features & FEATURE_I2C_BLOCK_READ)) { 399 } else if (!(i801_features & FEATURE_I2C_BLOCK_READ)) {
415 dev_err(&I801_dev->dev, 400 dev_err(&I801_dev->dev,
416 "I2C block read is unsupported!\n"); 401 "I2C block read is unsupported!\n");
417 return -1; 402 return -EOPNOTSUPP;
418 } 403 }
419 } 404 }
420 405
@@ -449,7 +434,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
449 return result; 434 return result;
450} 435}
451 436
452/* Return -1 on error. */ 437/* Return negative errno on error. */
453static s32 i801_access(struct i2c_adapter * adap, u16 addr, 438static s32 i801_access(struct i2c_adapter * adap, u16 addr,
454 unsigned short flags, char read_write, u8 command, 439 unsigned short flags, char read_write, u8 command,
455 int size, union i2c_smbus_data * data) 440 int size, union i2c_smbus_data * data)
@@ -511,10 +496,9 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
511 outb_p(command, SMBHSTCMD); 496 outb_p(command, SMBHSTCMD);
512 block = 1; 497 block = 1;
513 break; 498 break;
514 case I2C_SMBUS_PROC_CALL:
515 default: 499 default:
516 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size); 500 dev_err(&I801_dev->dev, "Unsupported transaction %d\n", size);
517 return -1; 501 return -EOPNOTSUPP;
518 } 502 }
519 503
520 if (hwpec) /* enable/disable hardware PEC */ 504 if (hwpec) /* enable/disable hardware PEC */
@@ -537,7 +521,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
537 if(block) 521 if(block)
538 return ret; 522 return ret;
539 if(ret) 523 if(ret)
540 return -1; 524 return ret;
541 if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) 525 if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK))
542 return 0; 526 return 0;
543 527
@@ -572,7 +556,7 @@ static const struct i2c_algorithm smbus_algorithm = {
572static struct i2c_adapter i801_adapter = { 556static struct i2c_adapter i801_adapter = {
573 .owner = THIS_MODULE, 557 .owner = THIS_MODULE,
574 .id = I2C_HW_SMBUS_I801, 558 .id = I2C_HW_SMBUS_I801,
575 .class = I2C_CLASS_HWMON, 559 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
576 .algo = &smbus_algorithm, 560 .algo = &smbus_algorithm,
577}; 561};
578 562
@@ -639,6 +623,10 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
639 goto exit; 623 goto exit;
640 } 624 }
641 625
626 err = acpi_check_resource_conflict(&dev->resource[SMBBAR]);
627 if (err)
628 goto exit;
629
642 err = pci_request_region(dev, SMBBAR, i801_driver.name); 630 err = pci_request_region(dev, SMBBAR, i801_driver.name);
643 if (err) { 631 if (err) {
644 dev_err(&dev->dev, "Failed to request SMBus region " 632 dev_err(&dev->dev, "Failed to request SMBus region "
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
deleted file mode 100644
index 42e8d94c276..00000000000
--- a/drivers/i2c/busses/i2c-i810.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/*
2 i2c-i810.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998, 1999, 2000 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>,
6 Ralph Metzler <rjkm@thp.uni-koeln.de>, and
7 Mark D. Studebaker <mdsxyz123@yahoo.com>
8
9 Based on code written by Ralph Metzler <rjkm@thp.uni-koeln.de> and
10 Simon Vogl
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25*/
26/*
27 This interfaces to the I810/I815 to provide access to
28 the DDC Bus and the I2C Bus.
29
30 SUPPORTED DEVICES PCI ID
31 i810AA 7121
32 i810AB 7123
33 i810E 7125
34 i815 1132
35 i845G 2562
36*/
37
38#include <linux/kernel.h>
39#include <linux/module.h>
40#include <linux/init.h>
41#include <linux/pci.h>
42#include <linux/i2c.h>
43#include <linux/i2c-algo-bit.h>
44#include <asm/io.h>
45
46/* GPIO register locations */
47#define I810_IOCONTROL_OFFSET 0x5000
48#define I810_HVSYNC 0x00 /* not used */
49#define I810_GPIOA 0x10
50#define I810_GPIOB 0x14
51
52/* bit locations in the registers */
53#define SCL_DIR_MASK 0x0001
54#define SCL_DIR 0x0002
55#define SCL_VAL_MASK 0x0004
56#define SCL_VAL_OUT 0x0008
57#define SCL_VAL_IN 0x0010
58#define SDA_DIR_MASK 0x0100
59#define SDA_DIR 0x0200
60#define SDA_VAL_MASK 0x0400
61#define SDA_VAL_OUT 0x0800
62#define SDA_VAL_IN 0x1000
63
64/* initialization states */
65#define INIT1 0x1
66#define INIT2 0x2
67#define INIT3 0x4
68
69/* delays */
70#define CYCLE_DELAY 10
71#define TIMEOUT (HZ / 2)
72
73static void __iomem *ioaddr;
74
75/* The i810 GPIO registers have individual masks for each bit
76 so we never have to read before writing. Nice. */
77
78static void bit_i810i2c_setscl(void *data, int val)
79{
80 writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
81 ioaddr + I810_GPIOB);
82 readl(ioaddr + I810_GPIOB); /* flush posted write */
83}
84
85static void bit_i810i2c_setsda(void *data, int val)
86{
87 writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
88 ioaddr + I810_GPIOB);
89 readl(ioaddr + I810_GPIOB); /* flush posted write */
90}
91
92/* The GPIO pins are open drain, so the pins could always remain outputs.
93 However, some chip versions don't latch the inputs unless they
94 are set as inputs.
95 We rely on the i2c-algo-bit routines to set the pins high before
96 reading the input from other chips. Following guidance in the 815
97 prog. ref. guide, we do a "dummy write" of 0 to the register before
98 reading which forces the input value to be latched. We presume this
99 applies to the 810 as well; shouldn't hurt anyway. This is necessary to get
100 i2c_algo_bit bit_test=1 to pass. */
101
102static int bit_i810i2c_getscl(void *data)
103{
104 writel(SCL_DIR_MASK, ioaddr + I810_GPIOB);
105 writel(0, ioaddr + I810_GPIOB);
106 return (0 != (readl(ioaddr + I810_GPIOB) & SCL_VAL_IN));
107}
108
109static int bit_i810i2c_getsda(void *data)
110{
111 writel(SDA_DIR_MASK, ioaddr + I810_GPIOB);
112 writel(0, ioaddr + I810_GPIOB);
113 return (0 != (readl(ioaddr + I810_GPIOB) & SDA_VAL_IN));
114}
115
116static void bit_i810ddc_setscl(void *data, int val)
117{
118 writel((val ? SCL_VAL_OUT : 0) | SCL_DIR | SCL_DIR_MASK | SCL_VAL_MASK,
119 ioaddr + I810_GPIOA);
120 readl(ioaddr + I810_GPIOA); /* flush posted write */
121}
122
123static void bit_i810ddc_setsda(void *data, int val)
124{
125 writel((val ? SDA_VAL_OUT : 0) | SDA_DIR | SDA_DIR_MASK | SDA_VAL_MASK,
126 ioaddr + I810_GPIOA);
127 readl(ioaddr + I810_GPIOA); /* flush posted write */
128}
129
130static int bit_i810ddc_getscl(void *data)
131{
132 writel(SCL_DIR_MASK, ioaddr + I810_GPIOA);
133 writel(0, ioaddr + I810_GPIOA);
134 return (0 != (readl(ioaddr + I810_GPIOA) & SCL_VAL_IN));
135}
136
137static int bit_i810ddc_getsda(void *data)
138{
139 writel(SDA_DIR_MASK, ioaddr + I810_GPIOA);
140 writel(0, ioaddr + I810_GPIOA);
141 return (0 != (readl(ioaddr + I810_GPIOA) & SDA_VAL_IN));
142}
143
144static int config_i810(struct pci_dev *dev)
145{
146 unsigned long cadr;
147
148 /* map I810 memory */
149 cadr = dev->resource[1].start;
150 cadr += I810_IOCONTROL_OFFSET;
151 cadr &= PCI_BASE_ADDRESS_MEM_MASK;
152 ioaddr = ioremap_nocache(cadr, 0x1000);
153 if (ioaddr) {
154 bit_i810i2c_setscl(NULL, 1);
155 bit_i810i2c_setsda(NULL, 1);
156 bit_i810ddc_setscl(NULL, 1);
157 bit_i810ddc_setsda(NULL, 1);
158 return 0;
159 }
160 return -ENODEV;
161}
162
163static struct i2c_algo_bit_data i810_i2c_bit_data = {
164 .setsda = bit_i810i2c_setsda,
165 .setscl = bit_i810i2c_setscl,
166 .getsda = bit_i810i2c_getsda,
167 .getscl = bit_i810i2c_getscl,
168 .udelay = CYCLE_DELAY,
169 .timeout = TIMEOUT,
170};
171
172static struct i2c_adapter i810_i2c_adapter = {
173 .owner = THIS_MODULE,
174 .id = I2C_HW_B_I810,
175 .name = "I810/I815 I2C Adapter",
176 .algo_data = &i810_i2c_bit_data,
177};
178
179static struct i2c_algo_bit_data i810_ddc_bit_data = {
180 .setsda = bit_i810ddc_setsda,
181 .setscl = bit_i810ddc_setscl,
182 .getsda = bit_i810ddc_getsda,
183 .getscl = bit_i810ddc_getscl,
184 .udelay = CYCLE_DELAY,
185 .timeout = TIMEOUT,
186};
187
188static struct i2c_adapter i810_ddc_adapter = {
189 .owner = THIS_MODULE,
190 .id = I2C_HW_B_I810,
191 .name = "I810/I815 DDC Adapter",
192 .algo_data = &i810_ddc_bit_data,
193};
194
195static struct pci_device_id i810_ids[] __devinitdata = {
196 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG1) },
197 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG3) },
198 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810E_IG) },
199 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82815_CGC) },
200 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845G_IG) },
201 { 0, },
202};
203
204MODULE_DEVICE_TABLE (pci, i810_ids);
205
206static int __devinit i810_probe(struct pci_dev *dev, const struct pci_device_id *id)
207{
208 int retval;
209
210 retval = config_i810(dev);
211 if (retval)
212 return retval;
213 dev_info(&dev->dev, "i810/i815 i2c device found.\n");
214
215 /* set up the sysfs linkage to our parent device */
216 i810_i2c_adapter.dev.parent = &dev->dev;
217 i810_ddc_adapter.dev.parent = &dev->dev;
218
219 retval = i2c_bit_add_bus(&i810_i2c_adapter);
220 if (retval)
221 return retval;
222 retval = i2c_bit_add_bus(&i810_ddc_adapter);
223 if (retval)
224 i2c_del_adapter(&i810_i2c_adapter);
225 return retval;
226}
227
228static void __devexit i810_remove(struct pci_dev *dev)
229{
230 i2c_del_adapter(&i810_ddc_adapter);
231 i2c_del_adapter(&i810_i2c_adapter);
232 iounmap(ioaddr);
233}
234
235static struct pci_driver i810_driver = {
236 .name = "i810_smbus",
237 .id_table = i810_ids,
238 .probe = i810_probe,
239 .remove = __devexit_p(i810_remove),
240};
241
242static int __init i2c_i810_init(void)
243{
244 return pci_register_driver(&i810_driver);
245}
246
247static void __exit i2c_i810_exit(void)
248{
249 pci_unregister_driver(&i810_driver);
250}
251
252MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>, "
253 "Philip Edelbrock <phil@netroedge.com>, "
254 "Ralph Metzler <rjkm@thp.uni-koeln.de>, "
255 "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
256MODULE_DESCRIPTION("I810/I815 I2C/DDC driver");
257MODULE_LICENSE("GPL");
258
259module_init(i2c_i810_init);
260module_exit(i2c_i810_exit);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 85dbf34382e..651f2f1ae5b 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -42,13 +42,8 @@
42#include <asm/io.h> 42#include <asm/io.h>
43#include <linux/i2c.h> 43#include <linux/i2c.h>
44#include <linux/i2c-id.h> 44#include <linux/i2c-id.h>
45
46#ifdef CONFIG_IBM_OCP
47#include <asm/ocp.h>
48#include <asm/ibm4xx.h>
49#else
50#include <linux/of_platform.h> 45#include <linux/of_platform.h>
51#endif 46#include <linux/of_i2c.h>
52 47
53#include "i2c-ibm_iic.h" 48#include "i2c-ibm_iic.h"
54 49
@@ -665,180 +660,6 @@ static inline u8 iic_clckdiv(unsigned int opb)
665 return (u8)((opb + 9) / 10 - 1); 660 return (u8)((opb + 9) / 10 - 1);
666} 661}
667 662
668#ifdef CONFIG_IBM_OCP
669/*
670 * Register single IIC interface
671 */
672static int __devinit iic_probe(struct ocp_device *ocp){
673
674 struct ibm_iic_private* dev;
675 struct i2c_adapter* adap;
676 struct ocp_func_iic_data* iic_data = ocp->def->additions;
677 int ret;
678
679 if (!iic_data)
680 printk(KERN_WARNING"ibm-iic%d: missing additional data!\n",
681 ocp->def->index);
682
683 if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) {
684 printk(KERN_ERR "ibm-iic%d: failed to allocate device data\n",
685 ocp->def->index);
686 return -ENOMEM;
687 }
688
689 dev->idx = ocp->def->index;
690 ocp_set_drvdata(ocp, dev);
691
692 if (!request_mem_region(ocp->def->paddr, sizeof(struct iic_regs),
693 "ibm_iic")) {
694 ret = -EBUSY;
695 goto fail1;
696 }
697
698 if (!(dev->vaddr = ioremap(ocp->def->paddr, sizeof(struct iic_regs)))){
699 printk(KERN_ERR "ibm-iic%d: failed to ioremap device registers\n",
700 dev->idx);
701 ret = -ENXIO;
702 goto fail2;
703 }
704
705 init_waitqueue_head(&dev->wq);
706
707 dev->irq = iic_force_poll ? -1 : ocp->def->irq;
708 if (dev->irq >= 0){
709 /* Disable interrupts until we finish initialization,
710 assumes level-sensitive IRQ setup...
711 */
712 iic_interrupt_mode(dev, 0);
713 if (request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)){
714 printk(KERN_ERR "ibm-iic%d: request_irq %d failed\n",
715 dev->idx, dev->irq);
716 /* Fallback to the polling mode */
717 dev->irq = -1;
718 }
719 }
720
721 if (dev->irq < 0)
722 printk(KERN_WARNING "ibm-iic%d: using polling mode\n",
723 dev->idx);
724
725 /* Board specific settings */
726 dev->fast_mode = iic_force_fast ? 1 : (iic_data ? iic_data->fast_mode : 0);
727
728 /* clckdiv is the same for *all* IIC interfaces,
729 * but I'd rather make a copy than introduce another global. --ebs
730 */
731 dev->clckdiv = iic_clckdiv(ocp_sys_info.opb_bus_freq);
732 DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
733
734 /* Initialize IIC interface */
735 iic_dev_init(dev);
736
737 /* Register it with i2c layer */
738 adap = &dev->adap;
739 adap->dev.parent = &ocp->dev;
740 strcpy(adap->name, "IBM IIC");
741 i2c_set_adapdata(adap, dev);
742 adap->id = I2C_HW_OCP;
743 adap->class = I2C_CLASS_HWMON;
744 adap->algo = &iic_algo;
745 adap->client_register = NULL;
746 adap->client_unregister = NULL;
747 adap->timeout = 1;
748
749 /*
750 * If "dev->idx" is negative we consider it as zero.
751 * The reason to do so is to avoid sysfs names that only make
752 * sense when there are multiple adapters.
753 */
754 adap->nr = dev->idx >= 0 ? dev->idx : 0;
755
756 if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
757 printk(KERN_ERR "ibm-iic%d: failed to register i2c adapter\n",
758 dev->idx);
759 goto fail;
760 }
761
762 printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
763 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
764
765 return 0;
766
767fail:
768 if (dev->irq >= 0){
769 iic_interrupt_mode(dev, 0);
770 free_irq(dev->irq, dev);
771 }
772
773 iounmap(dev->vaddr);
774fail2:
775 release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
776fail1:
777 ocp_set_drvdata(ocp, NULL);
778 kfree(dev);
779 return ret;
780}
781
782/*
783 * Cleanup initialized IIC interface
784 */
785static void __devexit iic_remove(struct ocp_device *ocp)
786{
787 struct ibm_iic_private* dev = (struct ibm_iic_private*)ocp_get_drvdata(ocp);
788 BUG_ON(dev == NULL);
789 if (i2c_del_adapter(&dev->adap)){
790 printk(KERN_ERR "ibm-iic%d: failed to delete i2c adapter :(\n",
791 dev->idx);
792 /* That's *very* bad, just shutdown IRQ ... */
793 if (dev->irq >= 0){
794 iic_interrupt_mode(dev, 0);
795 free_irq(dev->irq, dev);
796 dev->irq = -1;
797 }
798 } else {
799 if (dev->irq >= 0){
800 iic_interrupt_mode(dev, 0);
801 free_irq(dev->irq, dev);
802 }
803 iounmap(dev->vaddr);
804 release_mem_region(ocp->def->paddr, sizeof(struct iic_regs));
805 kfree(dev);
806 }
807}
808
809static struct ocp_device_id ibm_iic_ids[] __devinitdata =
810{
811 { .vendor = OCP_VENDOR_IBM, .function = OCP_FUNC_IIC },
812 { .vendor = OCP_VENDOR_INVALID }
813};
814
815MODULE_DEVICE_TABLE(ocp, ibm_iic_ids);
816
817static struct ocp_driver ibm_iic_driver =
818{
819 .name = "iic",
820 .id_table = ibm_iic_ids,
821 .probe = iic_probe,
822 .remove = __devexit_p(iic_remove),
823#if defined(CONFIG_PM)
824 .suspend = NULL,
825 .resume = NULL,
826#endif
827};
828
829static int __init iic_init(void)
830{
831 printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n");
832 return ocp_register_driver(&ibm_iic_driver);
833}
834
835static void __exit iic_exit(void)
836{
837 ocp_unregister_driver(&ibm_iic_driver);
838}
839
840#else /* !CONFIG_IBM_OCP */
841
842static int __devinit iic_request_irq(struct of_device *ofdev, 663static int __devinit iic_request_irq(struct of_device *ofdev,
843 struct ibm_iic_private *dev) 664 struct ibm_iic_private *dev)
844{ 665{
@@ -876,7 +697,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
876 struct device_node *np = ofdev->node; 697 struct device_node *np = ofdev->node;
877 struct ibm_iic_private *dev; 698 struct ibm_iic_private *dev;
878 struct i2c_adapter *adap; 699 struct i2c_adapter *adap;
879 const u32 *indexp, *freq; 700 const u32 *freq;
880 int ret; 701 int ret;
881 702
882 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 703 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
@@ -887,14 +708,6 @@ static int __devinit iic_probe(struct of_device *ofdev,
887 708
888 dev_set_drvdata(&ofdev->dev, dev); 709 dev_set_drvdata(&ofdev->dev, dev);
889 710
890 indexp = of_get_property(np, "index", NULL);
891 if (!indexp) {
892 dev_err(&ofdev->dev, "no index specified\n");
893 ret = -EINVAL;
894 goto error_cleanup;
895 }
896 dev->idx = *indexp;
897
898 dev->vaddr = of_iomap(np, 0); 711 dev->vaddr = of_iomap(np, 0);
899 if (dev->vaddr == NULL) { 712 if (dev->vaddr == NULL) {
900 dev_err(&ofdev->dev, "failed to iomap device\n"); 713 dev_err(&ofdev->dev, "failed to iomap device\n");
@@ -934,17 +747,19 @@ static int __devinit iic_probe(struct of_device *ofdev,
934 strlcpy(adap->name, "IBM IIC", sizeof(adap->name)); 747 strlcpy(adap->name, "IBM IIC", sizeof(adap->name));
935 i2c_set_adapdata(adap, dev); 748 i2c_set_adapdata(adap, dev);
936 adap->id = I2C_HW_OCP; 749 adap->id = I2C_HW_OCP;
937 adap->class = I2C_CLASS_HWMON; 750 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
938 adap->algo = &iic_algo; 751 adap->algo = &iic_algo;
939 adap->timeout = 1; 752 adap->timeout = 1;
940 adap->nr = dev->idx;
941 753
942 ret = i2c_add_numbered_adapter(adap); 754 ret = i2c_add_adapter(adap);
943 if (ret < 0) { 755 if (ret < 0) {
944 dev_err(&ofdev->dev, "failed to register i2c adapter\n"); 756 dev_err(&ofdev->dev, "failed to register i2c adapter\n");
945 goto error_cleanup; 757 goto error_cleanup;
946 } 758 }
947 759
760 /* Now register all the child nodes */
761 of_register_i2c_devices(adap, np);
762
948 dev_info(&ofdev->dev, "using %s mode\n", 763 dev_info(&ofdev->dev, "using %s mode\n",
949 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); 764 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
950 765
@@ -987,11 +802,7 @@ static int __devexit iic_remove(struct of_device *ofdev)
987} 802}
988 803
989static const struct of_device_id ibm_iic_match[] = { 804static const struct of_device_id ibm_iic_match[] = {
990 { .compatible = "ibm,iic-405ex", }, 805 { .compatible = "ibm,iic", },
991 { .compatible = "ibm,iic-405gp", },
992 { .compatible = "ibm,iic-440gp", },
993 { .compatible = "ibm,iic-440gpx", },
994 { .compatible = "ibm,iic-440grx", },
995 {} 806 {}
996}; 807};
997 808
@@ -1011,7 +822,6 @@ static void __exit iic_exit(void)
1011{ 822{
1012 of_unregister_platform_driver(&ibm_iic_driver); 823 of_unregister_platform_driver(&ibm_iic_driver);
1013} 824}
1014#endif /* CONFIG_IBM_OCP */
1015 825
1016module_init(iic_init); 826module_init(iic_init);
1017module_exit(iic_exit); 827module_exit(iic_exit);
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 39884e79759..fc2714ac0c0 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -482,7 +482,7 @@ iop3xx_i2c_probe(struct platform_device *pdev)
482 memcpy(new_adapter->name, pdev->name, strlen(pdev->name)); 482 memcpy(new_adapter->name, pdev->name, strlen(pdev->name));
483 new_adapter->id = I2C_HW_IOP3XX; 483 new_adapter->id = I2C_HW_IOP3XX;
484 new_adapter->owner = THIS_MODULE; 484 new_adapter->owner = THIS_MODULE;
485 new_adapter->class = I2C_CLASS_HWMON; 485 new_adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
486 new_adapter->dev.parent = &pdev->dev; 486 new_adapter->dev.parent = &pdev->dev;
487 new_adapter->nr = pdev->id; 487 new_adapter->nr = pdev->id;
488 488
diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
new file mode 100644
index 00000000000..b9c01aa9003
--- /dev/null
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -0,0 +1,339 @@
1/*
2 i2c-isch.c - Linux kernel driver for Intel SCH chipset SMBus
3 - Based on i2c-piix4.c
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com>
6 - Intel SCH support
7 Copyright (c) 2007 - 2008 Jacob Jun Pan <jacob.jun.pan@intel.com>
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 version 2 as
11 published by the Free Software Foundation.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/
22
23/*
24 Supports:
25 Intel SCH chipsets (AF82US15W, AF82US15L, AF82UL11L)
26 Note: we assume there can only be one device, with one SMBus interface.
27*/
28
29#include <linux/module.h>
30#include <linux/pci.h>
31#include <linux/kernel.h>
32#include <linux/delay.h>
33#include <linux/stddef.h>
34#include <linux/ioport.h>
35#include <linux/i2c.h>
36#include <linux/init.h>
37#include <linux/io.h>
38#include <linux/acpi.h>
39
40/* SCH SMBus address offsets */
41#define SMBHSTCNT (0 + sch_smba)
42#define SMBHSTSTS (1 + sch_smba)
43#define SMBHSTADD (4 + sch_smba) /* TSA */
44#define SMBHSTCMD (5 + sch_smba)
45#define SMBHSTDAT0 (6 + sch_smba)
46#define SMBHSTDAT1 (7 + sch_smba)
47#define SMBBLKDAT (0x20 + sch_smba)
48
49/* count for request_region */
50#define SMBIOSIZE 64
51
52/* PCI Address Constants */
53#define SMBBA_SCH 0x40
54
55/* Other settings */
56#define MAX_TIMEOUT 500
57
58/* I2C constants */
59#define SCH_QUICK 0x00
60#define SCH_BYTE 0x01
61#define SCH_BYTE_DATA 0x02
62#define SCH_WORD_DATA 0x03
63#define SCH_BLOCK_DATA 0x05
64
65static unsigned short sch_smba;
66static struct pci_driver sch_driver;
67static struct i2c_adapter sch_adapter;
68
69/*
70 * Start the i2c transaction -- the i2c_access will prepare the transaction
71 * and this function will execute it.
72 * return 0 for success and others for failure.
73 */
74static int sch_transaction(void)
75{
76 int temp;
77 int result = 0;
78 int timeout = 0;
79
80 dev_dbg(&sch_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
81 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT),
82 inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0),
83 inb(SMBHSTDAT1));
84
85 /* Make sure the SMBus host is ready to start transmitting */
86 temp = inb(SMBHSTSTS) & 0x0f;
87 if (temp) {
88 /* Can not be busy since we checked it in sch_access */
89 if (temp & 0x01) {
90 dev_dbg(&sch_adapter.dev, "Completion (%02x). "
91 "Clear...\n", temp);
92 }
93 if (temp & 0x06) {
94 dev_dbg(&sch_adapter.dev, "SMBus error (%02x). "
95 "Resetting...\n", temp);
96 }
97 outb(temp, SMBHSTSTS);
98 temp = inb(SMBHSTSTS) & 0x0f;
99 if (temp) {
100 dev_err(&sch_adapter.dev,
101 "SMBus is not ready: (%02x)\n", temp);
102 return -EAGAIN;
103 }
104 }
105
106 /* start the transaction by setting bit 4 */
107 outb(inb(SMBHSTCNT) | 0x10, SMBHSTCNT);
108
109 do {
110 msleep(1);
111 temp = inb(SMBHSTSTS) & 0x0f;
112 } while ((temp & 0x08) && (timeout++ < MAX_TIMEOUT));
113
114 /* If the SMBus is still busy, we give up */
115 if (timeout >= MAX_TIMEOUT) {
116 dev_err(&sch_adapter.dev, "SMBus Timeout!\n");
117 result = -ETIMEDOUT;
118 }
119 if (temp & 0x04) {
120 result = -EIO;
121 dev_dbg(&sch_adapter.dev, "Bus collision! SMBus may be "
122 "locked until next hard reset. (sorry!)\n");
123 /* Clock stops and slave is stuck in mid-transmission */
124 } else if (temp & 0x02) {
125 result = -EIO;
126 dev_err(&sch_adapter.dev, "Error: no response!\n");
127 } else if (temp & 0x01) {
128 dev_dbg(&sch_adapter.dev, "Post complete!\n");
129 outb(temp, SMBHSTSTS);
130 temp = inb(SMBHSTSTS) & 0x07;
131 if (temp & 0x06) {
132 /* Completion clear failed */
133 dev_dbg(&sch_adapter.dev, "Failed reset at end of "
134 "transaction (%02x), Bus error!\n", temp);
135 }
136 } else {
137 result = -ENXIO;
138 dev_dbg(&sch_adapter.dev, "No such address.\n");
139 }
140 dev_dbg(&sch_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
141 "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb(SMBHSTCNT),
142 inb(SMBHSTCMD), inb(SMBHSTADD), inb(SMBHSTDAT0),
143 inb(SMBHSTDAT1));
144 return result;
145}
146
147/*
148 * This is the main access entry for i2c-sch access
149 * adap is i2c_adapter pointer, addr is the i2c device bus address, read_write
150 * (0 for read and 1 for write), size is i2c transaction type and data is the
151 * union of transaction for data to be transfered or data read from bus.
152 * return 0 for success and others for failure.
153 */
154static s32 sch_access(struct i2c_adapter *adap, u16 addr,
155 unsigned short flags, char read_write,
156 u8 command, int size, union i2c_smbus_data *data)
157{
158 int i, len, temp, rc;
159
160 /* Make sure the SMBus host is not busy */
161 temp = inb(SMBHSTSTS) & 0x0f;
162 if (temp & 0x08) {
163 dev_dbg(&sch_adapter.dev, "SMBus busy (%02x)\n", temp);
164 return -EAGAIN;
165 }
166 dev_dbg(&sch_adapter.dev, "access size: %d %s\n", size,
167 (read_write)?"READ":"WRITE");
168 switch (size) {
169 case I2C_SMBUS_QUICK:
170 outb((addr << 1) | read_write, SMBHSTADD);
171 size = SCH_QUICK;
172 break;
173 case I2C_SMBUS_BYTE:
174 outb((addr << 1) | read_write, SMBHSTADD);
175 if (read_write == I2C_SMBUS_WRITE)
176 outb(command, SMBHSTCMD);
177 size = SCH_BYTE;
178 break;
179 case I2C_SMBUS_BYTE_DATA:
180 outb((addr << 1) | read_write, SMBHSTADD);
181 outb(command, SMBHSTCMD);
182 if (read_write == I2C_SMBUS_WRITE)
183 outb(data->byte, SMBHSTDAT0);
184 size = SCH_BYTE_DATA;
185 break;
186 case I2C_SMBUS_WORD_DATA:
187 outb((addr << 1) | read_write, SMBHSTADD);
188 outb(command, SMBHSTCMD);
189 if (read_write == I2C_SMBUS_WRITE) {
190 outb(data->word & 0xff, SMBHSTDAT0);
191 outb((data->word & 0xff00) >> 8, SMBHSTDAT1);
192 }
193 size = SCH_WORD_DATA;
194 break;
195 case I2C_SMBUS_BLOCK_DATA:
196 outb((addr << 1) | read_write, SMBHSTADD);
197 outb(command, SMBHSTCMD);
198 if (read_write == I2C_SMBUS_WRITE) {
199 len = data->block[0];
200 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
201 return -EINVAL;
202 outb(len, SMBHSTDAT0);
203 for (i = 1; i <= len; i++)
204 outb(data->block[i], SMBBLKDAT+i-1);
205 }
206 size = SCH_BLOCK_DATA;
207 break;
208 default:
209 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
210 return -EOPNOTSUPP;
211 }
212 dev_dbg(&sch_adapter.dev, "write size %d to 0x%04x\n", size, SMBHSTCNT);
213 outb((inb(SMBHSTCNT) & 0xb0) | (size & 0x7), SMBHSTCNT);
214
215 rc = sch_transaction();
216 if (rc) /* Error in transaction */
217 return rc;
218
219 if ((read_write == I2C_SMBUS_WRITE) || (size == SCH_QUICK))
220 return 0;
221
222 switch (size) {
223 case SCH_BYTE:
224 case SCH_BYTE_DATA:
225 data->byte = inb(SMBHSTDAT0);
226 break;
227 case SCH_WORD_DATA:
228 data->word = inb(SMBHSTDAT0) + (inb(SMBHSTDAT1) << 8);
229 break;
230 case SCH_BLOCK_DATA:
231 data->block[0] = inb(SMBHSTDAT0);
232 if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX)
233 return -EPROTO;
234 for (i = 1; i <= data->block[0]; i++)
235 data->block[i] = inb(SMBBLKDAT+i-1);
236 break;
237 }
238 return 0;
239}
240
241static u32 sch_func(struct i2c_adapter *adapter)
242{
243 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
244 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
245 I2C_FUNC_SMBUS_BLOCK_DATA;
246}
247
248static const struct i2c_algorithm smbus_algorithm = {
249 .smbus_xfer = sch_access,
250 .functionality = sch_func,
251};
252
253static struct i2c_adapter sch_adapter = {
254 .owner = THIS_MODULE,
255 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
256 .algo = &smbus_algorithm,
257};
258
259static struct pci_device_id sch_ids[] = {
260 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) },
261 { 0, }
262};
263
264MODULE_DEVICE_TABLE(pci, sch_ids);
265
266static int __devinit sch_probe(struct pci_dev *dev,
267 const struct pci_device_id *id)
268{
269 int retval;
270 unsigned int smba;
271
272 pci_read_config_dword(dev, SMBBA_SCH, &smba);
273 if (!(smba & (1 << 31))) {
274 dev_err(&dev->dev, "SMBus I/O space disabled!\n");
275 return -ENODEV;
276 }
277
278 sch_smba = (unsigned short)smba;
279 if (sch_smba == 0) {
280 dev_err(&dev->dev, "SMBus base address uninitialized!\n");
281 return -ENODEV;
282 }
283 if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name))
284 return -EBUSY;
285 if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) {
286 dev_err(&dev->dev, "SMBus region 0x%x already in use!\n",
287 sch_smba);
288 return -EBUSY;
289 }
290 dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba);
291
292 /* set up the sysfs linkage to our parent device */
293 sch_adapter.dev.parent = &dev->dev;
294
295 snprintf(sch_adapter.name, sizeof(sch_adapter.name),
296 "SMBus SCH adapter at %04x", sch_smba);
297
298 retval = i2c_add_adapter(&sch_adapter);
299 if (retval) {
300 dev_err(&dev->dev, "Couldn't register adapter!\n");
301 release_region(sch_smba, SMBIOSIZE);
302 sch_smba = 0;
303 }
304
305 return retval;
306}
307
308static void __devexit sch_remove(struct pci_dev *dev)
309{
310 if (sch_smba) {
311 i2c_del_adapter(&sch_adapter);
312 release_region(sch_smba, SMBIOSIZE);
313 sch_smba = 0;
314 }
315}
316
317static struct pci_driver sch_driver = {
318 .name = "isch_smbus",
319 .id_table = sch_ids,
320 .probe = sch_probe,
321 .remove = __devexit_p(sch_remove),
322};
323
324static int __init i2c_sch_init(void)
325{
326 return pci_register_driver(&sch_driver);
327}
328
329static void __exit i2c_sch_exit(void)
330{
331 pci_unregister_driver(&sch_driver);
332}
333
334MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>");
335MODULE_DESCRIPTION("Intel SCH SMBus driver");
336MODULE_LICENSE("GPL");
337
338module_init(i2c_sch_init);
339module_exit(i2c_sch_exit);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index a076129de7e..10b9342a36c 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -311,7 +311,7 @@ static struct i2c_adapter mpc_ops = {
311 .name = "MPC adapter", 311 .name = "MPC adapter",
312 .id = I2C_HW_MPC107, 312 .id = I2C_HW_MPC107,
313 .algo = &mpc_algo, 313 .algo = &mpc_algo,
314 .class = I2C_CLASS_HWMON, 314 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
315 .timeout = 1, 315 .timeout = 1,
316}; 316};
317 317
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 036e6a883e6..9e8118d2fe6 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -530,7 +530,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
530 drv_data->adapter.id = I2C_HW_MV64XXX; 530 drv_data->adapter.id = I2C_HW_MV64XXX;
531 drv_data->adapter.algo = &mv64xxx_i2c_algo; 531 drv_data->adapter.algo = &mv64xxx_i2c_algo;
532 drv_data->adapter.owner = THIS_MODULE; 532 drv_data->adapter.owner = THIS_MODULE;
533 drv_data->adapter.class = I2C_CLASS_HWMON; 533 drv_data->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
534 drv_data->adapter.timeout = pdata->timeout; 534 drv_data->adapter.timeout = pdata->timeout;
535 drv_data->adapter.nr = pd->id; 535 drv_data->adapter.nr = pd->id;
536 platform_set_drvdata(pd, drv_data); 536 platform_set_drvdata(pd, drv_data);
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
new file mode 100644
index 00000000000..6a8995dfd0b
--- /dev/null
+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
@@ -0,0 +1,257 @@
1/*
2 * i2c-nforce2-s4985.c - i2c-nforce2 extras for the Tyan S4985 motherboard
3 *
4 * Copyright (C) 2008 Jean Delvare <khali@linux-fr.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/*
22 * We select the channels by sending commands to the Philips
23 * PCA9556 chip at I2C address 0x18. The main adapter is used for
24 * the non-multiplexed part of the bus, and 4 virtual adapters
25 * are defined for the multiplexed addresses: 0x50-0x53 (memory
26 * module EEPROM) located on channels 1-4. We define one virtual
27 * adapter per CPU, which corresponds to one multiplexed channel:
28 * CPU0: virtual adapter 1, channel 1
29 * CPU1: virtual adapter 2, channel 2
30 * CPU2: virtual adapter 3, channel 3
31 * CPU3: virtual adapter 4, channel 4
32 */
33
34#include <linux/module.h>
35#include <linux/kernel.h>
36#include <linux/slab.h>
37#include <linux/init.h>
38#include <linux/i2c.h>
39#include <linux/mutex.h>
40
41extern struct i2c_adapter *nforce2_smbus;
42
43static struct i2c_adapter *s4985_adapter;
44static struct i2c_algorithm *s4985_algo;
45
46/* Wrapper access functions for multiplexed SMBus */
47static DEFINE_MUTEX(nforce2_lock);
48
49static s32 nforce2_access_virt0(struct i2c_adapter *adap, u16 addr,
50 unsigned short flags, char read_write,
51 u8 command, int size,
52 union i2c_smbus_data *data)
53{
54 int error;
55
56 /* We exclude the multiplexed addresses */
57 if ((addr & 0xfc) == 0x50 || (addr & 0xfc) == 0x30
58 || addr == 0x18)
59 return -ENXIO;
60
61 mutex_lock(&nforce2_lock);
62 error = nforce2_smbus->algo->smbus_xfer(adap, addr, flags, read_write,
63 command, size, data);
64 mutex_unlock(&nforce2_lock);
65
66 return error;
67}
68
69/* We remember the last used channels combination so as to only switch
70 channels when it is really needed. This greatly reduces the SMBus
71 overhead, but also assumes that nobody will be writing to the PCA9556
72 in our back. */
73static u8 last_channels;
74
75static inline s32 nforce2_access_channel(struct i2c_adapter *adap, u16 addr,
76 unsigned short flags, char read_write,
77 u8 command, int size,
78 union i2c_smbus_data *data,
79 u8 channels)
80{
81 int error;
82
83 /* We exclude the non-multiplexed addresses */
84 if ((addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
85 return -ENXIO;
86
87 mutex_lock(&nforce2_lock);
88 if (last_channels != channels) {
89 union i2c_smbus_data mplxdata;
90 mplxdata.byte = channels;
91
92 error = nforce2_smbus->algo->smbus_xfer(adap, 0x18, 0,
93 I2C_SMBUS_WRITE, 0x01,
94 I2C_SMBUS_BYTE_DATA,
95 &mplxdata);
96 if (error)
97 goto UNLOCK;
98 last_channels = channels;
99 }
100 error = nforce2_smbus->algo->smbus_xfer(adap, addr, flags, read_write,
101 command, size, data);
102
103UNLOCK:
104 mutex_unlock(&nforce2_lock);
105 return error;
106}
107
108static s32 nforce2_access_virt1(struct i2c_adapter *adap, u16 addr,
109 unsigned short flags, char read_write,
110 u8 command, int size,
111 union i2c_smbus_data *data)
112{
113 /* CPU0: channel 1 enabled */
114 return nforce2_access_channel(adap, addr, flags, read_write, command,
115 size, data, 0x02);
116}
117
118static s32 nforce2_access_virt2(struct i2c_adapter *adap, u16 addr,
119 unsigned short flags, char read_write,
120 u8 command, int size,
121 union i2c_smbus_data *data)
122{
123 /* CPU1: channel 2 enabled */
124 return nforce2_access_channel(adap, addr, flags, read_write, command,
125 size, data, 0x04);
126}
127
128static s32 nforce2_access_virt3(struct i2c_adapter *adap, u16 addr,
129 unsigned short flags, char read_write,
130 u8 command, int size,
131 union i2c_smbus_data *data)
132{
133 /* CPU2: channel 3 enabled */
134 return nforce2_access_channel(adap, addr, flags, read_write, command,
135 size, data, 0x08);
136}
137
138static s32 nforce2_access_virt4(struct i2c_adapter *adap, u16 addr,
139 unsigned short flags, char read_write,
140 u8 command, int size,
141 union i2c_smbus_data *data)
142{
143 /* CPU3: channel 4 enabled */
144 return nforce2_access_channel(adap, addr, flags, read_write, command,
145 size, data, 0x10);
146}
147
148static int __init nforce2_s4985_init(void)
149{
150 int i, error;
151 union i2c_smbus_data ioconfig;
152
153 /* Unregister physical bus */
154 if (!nforce2_smbus)
155 return -ENODEV;
156 error = i2c_del_adapter(nforce2_smbus);
157 if (error) {
158 dev_err(&nforce2_smbus->dev, "Physical bus removal failed\n");
159 goto ERROR0;
160 }
161
162 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n");
163 /* Define the 5 virtual adapters and algorithms structures */
164 s4985_adapter = kzalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL);
165 if (!s4985_adapter) {
166 error = -ENOMEM;
167 goto ERROR1;
168 }
169 s4985_algo = kzalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL);
170 if (!s4985_algo) {
171 error = -ENOMEM;
172 goto ERROR2;
173 }
174
175 /* Fill in the new structures */
176 s4985_algo[0] = *(nforce2_smbus->algo);
177 s4985_algo[0].smbus_xfer = nforce2_access_virt0;
178 s4985_adapter[0] = *nforce2_smbus;
179 s4985_adapter[0].algo = s4985_algo;
180 s4985_adapter[0].dev.parent = nforce2_smbus->dev.parent;
181 for (i = 1; i < 5; i++) {
182 s4985_algo[i] = *(nforce2_smbus->algo);
183 s4985_adapter[i] = *nforce2_smbus;
184 snprintf(s4985_adapter[i].name, sizeof(s4985_adapter[i].name),
185 "SMBus nForce2 adapter (CPU%d)", i - 1);
186 s4985_adapter[i].algo = s4985_algo + i;
187 s4985_adapter[i].dev.parent = nforce2_smbus->dev.parent;
188 }
189 s4985_algo[1].smbus_xfer = nforce2_access_virt1;
190 s4985_algo[2].smbus_xfer = nforce2_access_virt2;
191 s4985_algo[3].smbus_xfer = nforce2_access_virt3;
192 s4985_algo[4].smbus_xfer = nforce2_access_virt4;
193
194 /* Configure the PCA9556 multiplexer */
195 ioconfig.byte = 0x00; /* All I/O to output mode */
196 error = nforce2_smbus->algo->smbus_xfer(nforce2_smbus, 0x18, 0,
197 I2C_SMBUS_WRITE, 0x03,
198 I2C_SMBUS_BYTE_DATA, &ioconfig);
199 if (error) {
200 dev_err(&nforce2_smbus->dev, "PCA9556 configuration failed\n");
201 error = -EIO;
202 goto ERROR3;
203 }
204
205 /* Register virtual adapters */
206 for (i = 0; i < 5; i++) {
207 error = i2c_add_adapter(s4985_adapter + i);
208 if (error) {
209 dev_err(&nforce2_smbus->dev,
210 "Virtual adapter %d registration "
211 "failed, module not inserted\n", i);
212 for (i--; i >= 0; i--)
213 i2c_del_adapter(s4985_adapter + i);
214 goto ERROR3;
215 }
216 }
217
218 return 0;
219
220ERROR3:
221 kfree(s4985_algo);
222 s4985_algo = NULL;
223ERROR2:
224 kfree(s4985_adapter);
225 s4985_adapter = NULL;
226ERROR1:
227 /* Restore physical bus */
228 i2c_add_adapter(nforce2_smbus);
229ERROR0:
230 return error;
231}
232
233static void __exit nforce2_s4985_exit(void)
234{
235 if (s4985_adapter) {
236 int i;
237
238 for (i = 0; i < 5; i++)
239 i2c_del_adapter(s4985_adapter+i);
240 kfree(s4985_adapter);
241 s4985_adapter = NULL;
242 }
243 kfree(s4985_algo);
244 s4985_algo = NULL;
245
246 /* Restore physical bus */
247 if (i2c_add_adapter(nforce2_smbus))
248 dev_err(&nforce2_smbus->dev, "Physical bus restoration "
249 "failed\n");
250}
251
252MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
253MODULE_DESCRIPTION("S4985 SMBus multiplexing");
254MODULE_LICENSE("GPL");
255
256module_init(nforce2_s4985_init);
257module_exit(nforce2_s4985_exit);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 43c9f8df950..3b19bc41a60 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -51,6 +51,7 @@
51#include <linux/i2c.h> 51#include <linux/i2c.h>
52#include <linux/delay.h> 52#include <linux/delay.h>
53#include <linux/dmi.h> 53#include <linux/dmi.h>
54#include <linux/acpi.h>
54#include <asm/io.h> 55#include <asm/io.h>
55 56
56MODULE_LICENSE("GPL"); 57MODULE_LICENSE("GPL");
@@ -124,6 +125,20 @@ static struct dmi_system_id __devinitdata nforce2_dmi_blacklist2[] = {
124 125
125static struct pci_driver nforce2_driver; 126static struct pci_driver nforce2_driver;
126 127
128/* For multiplexing support, we need a global reference to the 1st
129 SMBus channel */
130#if defined CONFIG_I2C_NFORCE2_S4985 || defined CONFIG_I2C_NFORCE2_S4985_MODULE
131struct i2c_adapter *nforce2_smbus;
132EXPORT_SYMBOL_GPL(nforce2_smbus);
133
134static void nforce2_set_reference(struct i2c_adapter *adap)
135{
136 nforce2_smbus = adap;
137}
138#else
139static inline void nforce2_set_reference(struct i2c_adapter *adap) { }
140#endif
141
127static void nforce2_abort(struct i2c_adapter *adap) 142static void nforce2_abort(struct i2c_adapter *adap)
128{ 143{
129 struct nforce2_smbus *smbus = adap->algo_data; 144 struct nforce2_smbus *smbus = adap->algo_data;
@@ -158,16 +173,16 @@ static int nforce2_check_status(struct i2c_adapter *adap)
158 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 173 dev_dbg(&adap->dev, "SMBus Timeout!\n");
159 if (smbus->can_abort) 174 if (smbus->can_abort)
160 nforce2_abort(adap); 175 nforce2_abort(adap);
161 return -1; 176 return -ETIMEDOUT;
162 } 177 }
163 if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) { 178 if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
164 dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp); 179 dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp);
165 return -1; 180 return -EIO;
166 } 181 }
167 return 0; 182 return 0;
168} 183}
169 184
170/* Return -1 on error */ 185/* Return negative errno on error */
171static s32 nforce2_access(struct i2c_adapter * adap, u16 addr, 186static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
172 unsigned short flags, char read_write, 187 unsigned short flags, char read_write,
173 u8 command, int size, union i2c_smbus_data * data) 188 u8 command, int size, union i2c_smbus_data * data)
@@ -175,7 +190,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
175 struct nforce2_smbus *smbus = adap->algo_data; 190 struct nforce2_smbus *smbus = adap->algo_data;
176 unsigned char protocol, pec; 191 unsigned char protocol, pec;
177 u8 len; 192 u8 len;
178 int i; 193 int i, status;
179 194
180 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ : 195 protocol = (read_write == I2C_SMBUS_READ) ? NVIDIA_SMB_PRTCL_READ :
181 NVIDIA_SMB_PRTCL_WRITE; 196 NVIDIA_SMB_PRTCL_WRITE;
@@ -219,7 +234,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
219 "Transaction failed " 234 "Transaction failed "
220 "(requested block size: %d)\n", 235 "(requested block size: %d)\n",
221 len); 236 len);
222 return -1; 237 return -EINVAL;
223 } 238 }
224 outb_p(len, NVIDIA_SMB_BCNT); 239 outb_p(len, NVIDIA_SMB_BCNT);
225 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) 240 for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++)
@@ -231,14 +246,15 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
231 246
232 default: 247 default:
233 dev_err(&adap->dev, "Unsupported transaction %d\n", size); 248 dev_err(&adap->dev, "Unsupported transaction %d\n", size);
234 return -1; 249 return -EOPNOTSUPP;
235 } 250 }
236 251
237 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR); 252 outb_p((addr & 0x7f) << 1, NVIDIA_SMB_ADDR);
238 outb_p(protocol, NVIDIA_SMB_PRTCL); 253 outb_p(protocol, NVIDIA_SMB_PRTCL);
239 254
240 if (nforce2_check_status(adap)) 255 status = nforce2_check_status(adap);
241 return -1; 256 if (status)
257 return status;
242 258
243 if (read_write == I2C_SMBUS_WRITE) 259 if (read_write == I2C_SMBUS_WRITE)
244 return 0; 260 return 0;
@@ -260,7 +276,7 @@ static s32 nforce2_access(struct i2c_adapter * adap, u16 addr,
260 dev_err(&adap->dev, "Transaction failed " 276 dev_err(&adap->dev, "Transaction failed "
261 "(received block size: 0x%02x)\n", 277 "(received block size: 0x%02x)\n",
262 len); 278 len);
263 return -1; 279 return -EPROTO;
264 } 280 }
265 for (i = 0; i < len; i++) 281 for (i = 0; i < len; i++)
266 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i); 282 data->block[i+1] = inb_p(NVIDIA_SMB_DATA + i);
@@ -321,21 +337,26 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
321 != PCIBIOS_SUCCESSFUL) { 337 != PCIBIOS_SUCCESSFUL) {
322 dev_err(&dev->dev, "Error reading PCI config for %s\n", 338 dev_err(&dev->dev, "Error reading PCI config for %s\n",
323 name); 339 name);
324 return -1; 340 return -EIO;
325 } 341 }
326 342
327 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK; 343 smbus->base = iobase & PCI_BASE_ADDRESS_IO_MASK;
328 smbus->size = 64; 344 smbus->size = 64;
329 } 345 }
330 346
347 error = acpi_check_region(smbus->base, smbus->size,
348 nforce2_driver.name);
349 if (error)
350 return -1;
351
331 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) { 352 if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
332 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n", 353 dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
333 smbus->base, smbus->base+smbus->size-1, name); 354 smbus->base, smbus->base+smbus->size-1, name);
334 return -1; 355 return -EBUSY;
335 } 356 }
336 smbus->adapter.owner = THIS_MODULE; 357 smbus->adapter.owner = THIS_MODULE;
337 smbus->adapter.id = I2C_HW_SMBUS_NFORCE2; 358 smbus->adapter.id = I2C_HW_SMBUS_NFORCE2;
338 smbus->adapter.class = I2C_CLASS_HWMON; 359 smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
339 smbus->adapter.algo = &smbus_algorithm; 360 smbus->adapter.algo = &smbus_algorithm;
340 smbus->adapter.algo_data = smbus; 361 smbus->adapter.algo_data = smbus;
341 smbus->adapter.dev.parent = &dev->dev; 362 smbus->adapter.dev.parent = &dev->dev;
@@ -346,7 +367,7 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
346 if (error) { 367 if (error) {
347 dev_err(&smbus->adapter.dev, "Failed to register adapter.\n"); 368 dev_err(&smbus->adapter.dev, "Failed to register adapter.\n");
348 release_region(smbus->base, smbus->size); 369 release_region(smbus->base, smbus->size);
349 return -1; 370 return error;
350 } 371 }
351 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base); 372 dev_info(&smbus->adapter.dev, "nForce2 SMBus adapter at %#x\n", smbus->base);
352 return 0; 373 return 0;
@@ -398,6 +419,7 @@ static int __devinit nforce2_probe(struct pci_dev *dev, const struct pci_device_
398 return -ENODEV; 419 return -ENODEV;
399 } 420 }
400 421
422 nforce2_set_reference(&smbuses[0].adapter);
401 return 0; 423 return 0;
402} 424}
403 425
@@ -406,6 +428,7 @@ static void __devexit nforce2_remove(struct pci_dev *dev)
406{ 428{
407 struct nforce2_smbus *smbuses = (void*) pci_get_drvdata(dev); 429 struct nforce2_smbus *smbuses = (void*) pci_get_drvdata(dev);
408 430
431 nforce2_set_reference(NULL);
409 if (smbuses[0].base) { 432 if (smbuses[0].base) {
410 i2c_del_adapter(&smbuses[0].adapter); 433 i2c_del_adapter(&smbuses[0].adapter);
411 release_region(smbuses[0].base, smbuses[0].size); 434 release_region(smbuses[0].base, smbuses[0].size);
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index f145692cbb7..e5193bf7548 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -29,6 +29,7 @@ struct ocores_i2c {
29 int pos; 29 int pos;
30 int nmsgs; 30 int nmsgs;
31 int state; /* see STATE_ */ 31 int state; /* see STATE_ */
32 int clock_khz;
32}; 33};
33 34
34/* registers */ 35/* registers */
@@ -173,8 +174,7 @@ static int ocores_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
173 return -ETIMEDOUT; 174 return -ETIMEDOUT;
174} 175}
175 176
176static void ocores_init(struct ocores_i2c *i2c, 177static void ocores_init(struct ocores_i2c *i2c)
177 struct ocores_i2c_platform_data *pdata)
178{ 178{
179 int prescale; 179 int prescale;
180 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); 180 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);
@@ -182,7 +182,7 @@ static void ocores_init(struct ocores_i2c *i2c,
182 /* make sure the device is disabled */ 182 /* make sure the device is disabled */
183 oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN)); 183 oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN));
184 184
185 prescale = (pdata->clock_khz / (5*100)) - 1; 185 prescale = (i2c->clock_khz / (5*100)) - 1;
186 oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff); 186 oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff);
187 oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8); 187 oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);
188 188
@@ -205,7 +205,7 @@ static const struct i2c_algorithm ocores_algorithm = {
205static struct i2c_adapter ocores_adapter = { 205static struct i2c_adapter ocores_adapter = {
206 .owner = THIS_MODULE, 206 .owner = THIS_MODULE,
207 .name = "i2c-ocores", 207 .name = "i2c-ocores",
208 .class = I2C_CLASS_HWMON, 208 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
209 .algo = &ocores_algorithm, 209 .algo = &ocores_algorithm,
210}; 210};
211 211
@@ -248,7 +248,8 @@ static int __devinit ocores_i2c_probe(struct platform_device *pdev)
248 } 248 }
249 249
250 i2c->regstep = pdata->regstep; 250 i2c->regstep = pdata->regstep;
251 ocores_init(i2c, pdata); 251 i2c->clock_khz = pdata->clock_khz;
252 ocores_init(i2c);
252 253
253 init_waitqueue_head(&i2c->wait); 254 init_waitqueue_head(&i2c->wait);
254 ret = request_irq(res2->start, ocores_isr, 0, pdev->name, i2c); 255 ret = request_irq(res2->start, ocores_isr, 0, pdev->name, i2c);
@@ -312,13 +313,40 @@ static int __devexit ocores_i2c_remove(struct platform_device* pdev)
312 return 0; 313 return 0;
313} 314}
314 315
316#ifdef CONFIG_PM
317static int ocores_i2c_suspend(struct platform_device *pdev, pm_message_t state)
318{
319 struct ocores_i2c *i2c = platform_get_drvdata(pdev);
320 u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL);
321
322 /* make sure the device is disabled */
323 oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~(OCI2C_CTRL_EN|OCI2C_CTRL_IEN));
324
325 return 0;
326}
327
328static int ocores_i2c_resume(struct platform_device *pdev)
329{
330 struct ocores_i2c *i2c = platform_get_drvdata(pdev);
331
332 ocores_init(i2c);
333
334 return 0;
335}
336#else
337#define ocores_i2c_suspend NULL
338#define ocores_i2c_resume NULL
339#endif
340
315/* work with hotplug and coldplug */ 341/* work with hotplug and coldplug */
316MODULE_ALIAS("platform:ocores-i2c"); 342MODULE_ALIAS("platform:ocores-i2c");
317 343
318static struct platform_driver ocores_i2c_driver = { 344static struct platform_driver ocores_i2c_driver = {
319 .probe = ocores_i2c_probe, 345 .probe = ocores_i2c_probe,
320 .remove = __devexit_p(ocores_i2c_remove), 346 .remove = __devexit_p(ocores_i2c_remove),
321 .driver = { 347 .suspend = ocores_i2c_suspend,
348 .resume = ocores_i2c_resume,
349 .driver = {
322 .owner = THIS_MODULE, 350 .owner = THIS_MODULE,
323 .name = "ocores-i2c", 351 .name = "ocores-i2c",
324 }, 352 },
diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
index 1603c81e39d..adf0fbb902f 100644
--- a/drivers/i2c/busses/i2c-pasemi.c
+++ b/drivers/i2c/busses/i2c-pasemi.c
@@ -365,7 +365,7 @@ static int __devinit pasemi_smb_probe(struct pci_dev *dev,
365 smbus->adapter.owner = THIS_MODULE; 365 smbus->adapter.owner = THIS_MODULE;
366 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name), 366 snprintf(smbus->adapter.name, sizeof(smbus->adapter.name),
367 "PA Semi SMBus adapter at 0x%lx", smbus->base); 367 "PA Semi SMBus adapter at 0x%lx", smbus->base);
368 smbus->adapter.class = I2C_CLASS_HWMON; 368 smbus->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
369 smbus->adapter.algo = &smbus_algorithm; 369 smbus->adapter.algo = &smbus_algorithm;
370 smbus->adapter.algo_data = smbus; 370 smbus->adapter.algo_data = smbus;
371 smbus->adapter.nr = PCI_FUNC(dev->devfn); 371 smbus->adapter.nr = PCI_FUNC(dev->devfn);
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 9d75f51e8f0..6bb15ad0a6b 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -163,7 +163,7 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
163 163
164 i2c->reg_base = ioremap(res->start, res_len(res)); 164 i2c->reg_base = ioremap(res->start, res_len(res));
165 if (!i2c->reg_base) { 165 if (!i2c->reg_base) {
166 ret = -EIO; 166 ret = -ENOMEM;
167 goto e_remap; 167 goto e_remap;
168 } 168 }
169 i2c->io_base = res->start; 169 i2c->io_base = res->start;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index ac916596858..eaa9b387543 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -1,6 +1,4 @@
1/* 1/*
2 piix4.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> 3 Philip Edelbrock <phil@netroedge.com>
6 4
@@ -39,16 +37,10 @@
39#include <linux/i2c.h> 37#include <linux/i2c.h>
40#include <linux/init.h> 38#include <linux/init.h>
41#include <linux/dmi.h> 39#include <linux/dmi.h>
40#include <linux/acpi.h>
42#include <asm/io.h> 41#include <asm/io.h>
43 42
44 43
45struct sd {
46 const unsigned short mfr;
47 const unsigned short dev;
48 const unsigned char fn;
49 const char *name;
50};
51
52/* PIIX4 SMBus address offsets */ 44/* PIIX4 SMBus address offsets */
53#define SMBHSTSTS (0 + piix4_smba) 45#define SMBHSTSTS (0 + piix4_smba)
54#define SMBHSLVSTS (1 + piix4_smba) 46#define SMBHSLVSTS (1 + piix4_smba)
@@ -101,8 +93,6 @@ MODULE_PARM_DESC(force_addr,
101 "Forcibly enable the PIIX4 at the given address. " 93 "Forcibly enable the PIIX4 at the given address. "
102 "EXTREMELY DANGEROUS!"); 94 "EXTREMELY DANGEROUS!");
103 95
104static int piix4_transaction(void);
105
106static unsigned short piix4_smba; 96static unsigned short piix4_smba;
107static int srvrworks_csb5_delay; 97static int srvrworks_csb5_delay;
108static struct pci_driver piix4_driver; 98static struct pci_driver piix4_driver;
@@ -141,8 +131,6 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
141{ 131{
142 unsigned char temp; 132 unsigned char temp;
143 133
144 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));
145
146 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) && 134 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
147 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5)) 135 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
148 srvrworks_csb5_delay = 1; 136 srvrworks_csb5_delay = 1;
@@ -172,17 +160,20 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
172 pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba); 160 pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba);
173 piix4_smba &= 0xfff0; 161 piix4_smba &= 0xfff0;
174 if(piix4_smba == 0) { 162 if(piix4_smba == 0) {
175 dev_err(&PIIX4_dev->dev, "SMB base address " 163 dev_err(&PIIX4_dev->dev, "SMBus base address "
176 "uninitialized - upgrade BIOS or use " 164 "uninitialized - upgrade BIOS or use "
177 "force_addr=0xaddr\n"); 165 "force_addr=0xaddr\n");
178 return -ENODEV; 166 return -ENODEV;
179 } 167 }
180 } 168 }
181 169
170 if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
171 return -EBUSY;
172
182 if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) { 173 if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
183 dev_err(&PIIX4_dev->dev, "SMB region 0x%x already in use!\n", 174 dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
184 piix4_smba); 175 piix4_smba);
185 return -ENODEV; 176 return -EBUSY;
186 } 177 }
187 178
188 pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp); 179 pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);
@@ -228,13 +219,13 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
228 "(or code out of date)!\n"); 219 "(or code out of date)!\n");
229 220
230 pci_read_config_byte(PIIX4_dev, SMBREV, &temp); 221 pci_read_config_byte(PIIX4_dev, SMBREV, &temp);
231 dev_dbg(&PIIX4_dev->dev, "SMBREV = 0x%X\n", temp); 222 dev_info(&PIIX4_dev->dev,
232 dev_dbg(&PIIX4_dev->dev, "SMBA = 0x%X\n", piix4_smba); 223 "SMBus Host Controller at 0x%x, revision %d\n",
224 piix4_smba, temp);
233 225
234 return 0; 226 return 0;
235} 227}
236 228
237/* Another internally used function */
238static int piix4_transaction(void) 229static int piix4_transaction(void)
239{ 230{
240 int temp; 231 int temp;
@@ -253,7 +244,7 @@ static int piix4_transaction(void)
253 outb_p(temp, SMBHSTSTS); 244 outb_p(temp, SMBHSTSTS);
254 if ((temp = inb_p(SMBHSTSTS)) != 0x00) { 245 if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
255 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp); 246 dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
256 return -1; 247 return -EBUSY;
257 } else { 248 } else {
258 dev_dbg(&piix4_adapter.dev, "Successful!\n"); 249 dev_dbg(&piix4_adapter.dev, "Successful!\n");
259 } 250 }
@@ -275,23 +266,23 @@ static int piix4_transaction(void)
275 /* If the SMBus is still busy, we give up */ 266 /* If the SMBus is still busy, we give up */
276 if (timeout >= MAX_TIMEOUT) { 267 if (timeout >= MAX_TIMEOUT) {
277 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n"); 268 dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
278 result = -1; 269 result = -ETIMEDOUT;
279 } 270 }
280 271
281 if (temp & 0x10) { 272 if (temp & 0x10) {
282 result = -1; 273 result = -EIO;
283 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n"); 274 dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
284 } 275 }
285 276
286 if (temp & 0x08) { 277 if (temp & 0x08) {
287 result = -1; 278 result = -EIO;
288 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be " 279 dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
289 "locked until next hard reset. (sorry!)\n"); 280 "locked until next hard reset. (sorry!)\n");
290 /* Clock stops and slave is stuck in mid-transmission */ 281 /* Clock stops and slave is stuck in mid-transmission */
291 } 282 }
292 283
293 if (temp & 0x04) { 284 if (temp & 0x04) {
294 result = -1; 285 result = -ENXIO;
295 dev_dbg(&piix4_adapter.dev, "Error: no response!\n"); 286 dev_dbg(&piix4_adapter.dev, "Error: no response!\n");
296 } 287 }
297 288
@@ -309,31 +300,29 @@ static int piix4_transaction(void)
309 return result; 300 return result;
310} 301}
311 302
312/* Return -1 on error. */ 303/* Return negative errno on error. */
313static s32 piix4_access(struct i2c_adapter * adap, u16 addr, 304static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
314 unsigned short flags, char read_write, 305 unsigned short flags, char read_write,
315 u8 command, int size, union i2c_smbus_data * data) 306 u8 command, int size, union i2c_smbus_data * data)
316{ 307{
317 int i, len; 308 int i, len;
309 int status;
318 310
319 switch (size) { 311 switch (size) {
320 case I2C_SMBUS_PROC_CALL:
321 dev_err(&adap->dev, "I2C_SMBUS_PROC_CALL not supported!\n");
322 return -1;
323 case I2C_SMBUS_QUICK: 312 case I2C_SMBUS_QUICK:
324 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 313 outb_p((addr << 1) | read_write,
325 SMBHSTADD); 314 SMBHSTADD);
326 size = PIIX4_QUICK; 315 size = PIIX4_QUICK;
327 break; 316 break;
328 case I2C_SMBUS_BYTE: 317 case I2C_SMBUS_BYTE:
329 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 318 outb_p((addr << 1) | read_write,
330 SMBHSTADD); 319 SMBHSTADD);
331 if (read_write == I2C_SMBUS_WRITE) 320 if (read_write == I2C_SMBUS_WRITE)
332 outb_p(command, SMBHSTCMD); 321 outb_p(command, SMBHSTCMD);
333 size = PIIX4_BYTE; 322 size = PIIX4_BYTE;
334 break; 323 break;
335 case I2C_SMBUS_BYTE_DATA: 324 case I2C_SMBUS_BYTE_DATA:
336 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 325 outb_p((addr << 1) | read_write,
337 SMBHSTADD); 326 SMBHSTADD);
338 outb_p(command, SMBHSTCMD); 327 outb_p(command, SMBHSTCMD);
339 if (read_write == I2C_SMBUS_WRITE) 328 if (read_write == I2C_SMBUS_WRITE)
@@ -341,7 +330,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
341 size = PIIX4_BYTE_DATA; 330 size = PIIX4_BYTE_DATA;
342 break; 331 break;
343 case I2C_SMBUS_WORD_DATA: 332 case I2C_SMBUS_WORD_DATA:
344 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 333 outb_p((addr << 1) | read_write,
345 SMBHSTADD); 334 SMBHSTADD);
346 outb_p(command, SMBHSTCMD); 335 outb_p(command, SMBHSTCMD);
347 if (read_write == I2C_SMBUS_WRITE) { 336 if (read_write == I2C_SMBUS_WRITE) {
@@ -351,15 +340,13 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
351 size = PIIX4_WORD_DATA; 340 size = PIIX4_WORD_DATA;
352 break; 341 break;
353 case I2C_SMBUS_BLOCK_DATA: 342 case I2C_SMBUS_BLOCK_DATA:
354 outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), 343 outb_p((addr << 1) | read_write,
355 SMBHSTADD); 344 SMBHSTADD);
356 outb_p(command, SMBHSTCMD); 345 outb_p(command, SMBHSTCMD);
357 if (read_write == I2C_SMBUS_WRITE) { 346 if (read_write == I2C_SMBUS_WRITE) {
358 len = data->block[0]; 347 len = data->block[0];
359 if (len < 0) 348 if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
360 len = 0; 349 return -EINVAL;
361 if (len > 32)
362 len = 32;
363 outb_p(len, SMBHSTDAT0); 350 outb_p(len, SMBHSTDAT0);
364 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ 351 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
365 for (i = 1; i <= len; i++) 352 for (i = 1; i <= len; i++)
@@ -367,12 +354,16 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
367 } 354 }
368 size = PIIX4_BLOCK_DATA; 355 size = PIIX4_BLOCK_DATA;
369 break; 356 break;
357 default:
358 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
359 return -EOPNOTSUPP;
370 } 360 }
371 361
372 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT); 362 outb_p((size & 0x1C) + (ENABLE_INT9 & 1), SMBHSTCNT);
373 363
374 if (piix4_transaction()) /* Error in transaction */ 364 status = piix4_transaction();
375 return -1; 365 if (status)
366 return status;
376 367
377 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK)) 368 if ((read_write == I2C_SMBUS_WRITE) || (size == PIIX4_QUICK))
378 return 0; 369 return 0;
@@ -388,6 +379,8 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
388 break; 379 break;
389 case PIIX4_BLOCK_DATA: 380 case PIIX4_BLOCK_DATA:
390 data->block[0] = inb_p(SMBHSTDAT0); 381 data->block[0] = inb_p(SMBHSTDAT0);
382 if (data->block[0] == 0 || data->block[0] > I2C_SMBUS_BLOCK_MAX)
383 return -EPROTO;
391 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */ 384 i = inb_p(SMBHSTCNT); /* Reset SMBBLKDAT */
392 for (i = 1; i <= data->block[0]; i++) 385 for (i = 1; i <= data->block[0]; i++)
393 data->block[i] = inb_p(SMBBLKDAT); 386 data->block[i] = inb_p(SMBBLKDAT);
@@ -411,7 +404,7 @@ static const struct i2c_algorithm smbus_algorithm = {
411static struct i2c_adapter piix4_adapter = { 404static struct i2c_adapter piix4_adapter = {
412 .owner = THIS_MODULE, 405 .owner = THIS_MODULE,
413 .id = I2C_HW_SMBUS_PIIX4, 406 .id = I2C_HW_SMBUS_PIIX4,
414 .class = I2C_CLASS_HWMON, 407 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
415 .algo = &smbus_algorithm, 408 .algo = &smbus_algorithm,
416}; 409};
417 410
diff --git a/drivers/i2c/busses/i2c-pmcmsp.c b/drivers/i2c/busses/i2c-pmcmsp.c
index 63b3e2c11cf..dcf2045b522 100644
--- a/drivers/i2c/busses/i2c-pmcmsp.c
+++ b/drivers/i2c/busses/i2c-pmcmsp.c
@@ -622,7 +622,7 @@ static struct i2c_algorithm pmcmsptwi_algo = {
622 622
623static struct i2c_adapter pmcmsptwi_adapter = { 623static struct i2c_adapter pmcmsptwi_adapter = {
624 .owner = THIS_MODULE, 624 .owner = THIS_MODULE,
625 .class = I2C_CLASS_HWMON, 625 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
626 .algo = &pmcmsptwi_algo, 626 .algo = &pmcmsptwi_algo,
627 .name = DRV_NAME, 627 .name = DRV_NAME,
628}; 628};
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
deleted file mode 100644
index 07c1f1e27df..00000000000
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ /dev/null
@@ -1,325 +0,0 @@
1/*
2 * kernel/busses/i2c-prosavage.c
3 *
4 * i2c bus driver for S3/VIA 8365/8375 graphics processor.
5 * Copyright (c) 2003 Henk Vergonet <henk@god.dyndns.org>
6 * Based on code written by:
7 * Frodo Looijaard <frodol@dds.nl>,
8 * Philip Edelbrock <phil@netroedge.com>,
9 * Ralph Metzler <rjkm@thp.uni-koeln.de>, and
10 * Mark D. Studebaker <mdsxyz123@yahoo.com>
11 * Simon Vogl
12 * and others
13 *
14 * Please read the lm_sensors documentation for details on use.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 *
30 */
31/* 18-05-2003 HVE - created
32 * 14-06-2003 HVE - adapted for lm_sensors2
33 * 17-06-2003 HVE - linux 2.5.xx compatible
34 * 18-06-2003 HVE - codingstyle
35 * 21-06-2003 HVE - compatibility lm_sensors2 and linux 2.5.xx
36 * codingstyle, mmio enabled
37 *
38 * This driver interfaces to the I2C bus of the VIA north bridge embedded
39 * ProSavage4/8 devices. Usefull for gaining access to the TV Encoder chips.
40 *
41 * Graphics cores:
42 * S3/VIA KM266/VT8375 aka ProSavage8
43 * S3/VIA KM133/VT8365 aka Savage4
44 *
45 * Two serial busses are implemented:
46 * SERIAL1 - I2C serial communications interface
47 * SERIAL2 - DDC2 monitor communications interface
48 *
49 * Tested on a FX41 mainboard, see http://www.shuttle.com
50 *
51 *
52 * TODO:
53 * - integration with prosavage framebuffer device
54 * (Additional documentation needed :(
55 */
56
57#include <linux/module.h>
58#include <linux/init.h>
59#include <linux/pci.h>
60#include <linux/i2c.h>
61#include <linux/i2c-algo-bit.h>
62#include <asm/io.h>
63
64/*
65 * driver configuration
66 */
67#define MAX_BUSSES 2
68
69struct s_i2c_bus {
70 void __iomem *mmvga;
71 int i2c_reg;
72 int adap_ok;
73 struct i2c_adapter adap;
74 struct i2c_algo_bit_data algo;
75};
76
77struct s_i2c_chip {
78 void __iomem *mmio;
79 struct s_i2c_bus i2c_bus[MAX_BUSSES];
80};
81
82
83/*
84 * i2c configuration
85 */
86#define CYCLE_DELAY 10
87#define TIMEOUT (HZ / 2)
88
89
90/*
91 * S3/VIA 8365/8375 registers
92 */
93#define VGA_CR_IX 0x3d4
94#define VGA_CR_DATA 0x3d5
95
96#define CR_SERIAL1 0xa0 /* I2C serial communications interface */
97#define MM_SERIAL1 0xff20
98#define CR_SERIAL2 0xb1 /* DDC2 monitor communications interface */
99
100/* based on vt8365 documentation */
101#define I2C_ENAB 0x10
102#define I2C_SCL_OUT 0x01
103#define I2C_SDA_OUT 0x02
104#define I2C_SCL_IN 0x04
105#define I2C_SDA_IN 0x08
106
107#define SET_CR_IX(p, val) writeb((val), (p)->mmvga + VGA_CR_IX)
108#define SET_CR_DATA(p, val) writeb((val), (p)->mmvga + VGA_CR_DATA)
109#define GET_CR_DATA(p) readb((p)->mmvga + VGA_CR_DATA)
110
111
112/*
113 * Serial bus line handling
114 *
115 * serial communications register as parameter in private data
116 *
117 * TODO: locks with other code sections accessing video registers?
118 */
119static void bit_s3via_setscl(void *bus, int val)
120{
121 struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
122 unsigned int r;
123
124 SET_CR_IX(p, p->i2c_reg);
125 r = GET_CR_DATA(p);
126 r |= I2C_ENAB;
127 if (val) {
128 r |= I2C_SCL_OUT;
129 } else {
130 r &= ~I2C_SCL_OUT;
131 }
132 SET_CR_DATA(p, r);
133}
134
135static void bit_s3via_setsda(void *bus, int val)
136{
137 struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
138 unsigned int r;
139
140 SET_CR_IX(p, p->i2c_reg);
141 r = GET_CR_DATA(p);
142 r |= I2C_ENAB;
143 if (val) {
144 r |= I2C_SDA_OUT;
145 } else {
146 r &= ~I2C_SDA_OUT;
147 }
148 SET_CR_DATA(p, r);
149}
150
151static int bit_s3via_getscl(void *bus)
152{
153 struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
154
155 SET_CR_IX(p, p->i2c_reg);
156 return (0 != (GET_CR_DATA(p) & I2C_SCL_IN));
157}
158
159static int bit_s3via_getsda(void *bus)
160{
161 struct s_i2c_bus *p = (struct s_i2c_bus *)bus;
162
163 SET_CR_IX(p, p->i2c_reg);
164 return (0 != (GET_CR_DATA(p) & I2C_SDA_IN));
165}
166
167
168/*
169 * adapter initialisation
170 */
171static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, void __iomem *mmvga, u32 i2c_reg)
172{
173 int ret;
174 p->adap.owner = THIS_MODULE;
175 p->adap.id = I2C_HW_B_S3VIA;
176 p->adap.algo_data = &p->algo;
177 p->adap.dev.parent = &dev->dev;
178 p->algo.setsda = bit_s3via_setsda;
179 p->algo.setscl = bit_s3via_setscl;
180 p->algo.getsda = bit_s3via_getsda;
181 p->algo.getscl = bit_s3via_getscl;
182 p->algo.udelay = CYCLE_DELAY;
183 p->algo.timeout = TIMEOUT;
184 p->algo.data = p;
185 p->mmvga = mmvga;
186 p->i2c_reg = i2c_reg;
187
188 ret = i2c_bit_add_bus(&p->adap);
189 if (ret) {
190 return ret;
191 }
192
193 p->adap_ok = 1;
194 return 0;
195}
196
197
198/*
199 * Cleanup stuff
200 */
201static void prosavage_remove(struct pci_dev *dev)
202{
203 struct s_i2c_chip *chip;
204 int i, ret;
205
206 chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
207
208 if (!chip) {
209 return;
210 }
211 for (i = MAX_BUSSES - 1; i >= 0; i--) {
212 if (chip->i2c_bus[i].adap_ok == 0)
213 continue;
214
215 ret = i2c_del_adapter(&chip->i2c_bus[i].adap);
216 if (ret) {
217 dev_err(&dev->dev, "%s not removed\n",
218 chip->i2c_bus[i].adap.name);
219 }
220 }
221 if (chip->mmio) {
222 iounmap(chip->mmio);
223 }
224 kfree(chip);
225}
226
227
228/*
229 * Detect chip and initialize it
230 */
231static int __devinit prosavage_probe(struct pci_dev *dev, const struct pci_device_id *id)
232{
233 int ret;
234 unsigned long base, len;
235 struct s_i2c_chip *chip;
236 struct s_i2c_bus *bus;
237
238 pci_set_drvdata(dev, kzalloc(sizeof(struct s_i2c_chip), GFP_KERNEL));
239 chip = (struct s_i2c_chip *)pci_get_drvdata(dev);
240 if (chip == NULL) {
241 return -ENOMEM;
242 }
243
244 base = dev->resource[0].start & PCI_BASE_ADDRESS_MEM_MASK;
245 len = dev->resource[0].end - base + 1;
246 chip->mmio = ioremap_nocache(base, len);
247
248 if (chip->mmio == NULL) {
249 dev_err(&dev->dev, "ioremap failed\n");
250 prosavage_remove(dev);
251 return -ENODEV;
252 }
253
254
255 /*
256 * Chip initialisation
257 */
258 /* Unlock Extended IO Space ??? */
259
260
261 /*
262 * i2c bus registration
263 */
264 bus = &chip->i2c_bus[0];
265 snprintf(bus->adap.name, sizeof(bus->adap.name),
266 "ProSavage I2C bus at %02x:%02x.%x",
267 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
268 ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL1);
269 if (ret) {
270 goto err_adap;
271 }
272 /*
273 * ddc bus registration
274 */
275 bus = &chip->i2c_bus[1];
276 snprintf(bus->adap.name, sizeof(bus->adap.name),
277 "ProSavage DDC bus at %02x:%02x.%x",
278 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
279 ret = i2c_register_bus(dev, bus, chip->mmio + 0x8000, CR_SERIAL2);
280 if (ret) {
281 goto err_adap;
282 }
283 return 0;
284err_adap:
285 dev_err(&dev->dev, "%s failed\n", bus->adap.name);
286 prosavage_remove(dev);
287 return ret;
288}
289
290
291/*
292 * Data for PCI driver interface
293 */
294static struct pci_device_id prosavage_pci_tbl[] = {
295 { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_SAVAGE4) },
296 { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_PROSAVAGE8) },
297 { 0, },
298};
299
300MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl);
301
302static struct pci_driver prosavage_driver = {
303 .name = "prosavage_smbus",
304 .id_table = prosavage_pci_tbl,
305 .probe = prosavage_probe,
306 .remove = prosavage_remove,
307};
308
309static int __init i2c_prosavage_init(void)
310{
311 return pci_register_driver(&prosavage_driver);
312}
313
314static void __exit i2c_prosavage_exit(void)
315{
316 pci_unregister_driver(&prosavage_driver);
317}
318
319MODULE_DEVICE_TABLE(pci, prosavage_pci_tbl);
320MODULE_AUTHOR("Henk Vergonet");
321MODULE_DESCRIPTION("ProSavage VIA 8365/8375 smbus driver");
322MODULE_LICENSE("GPL");
323
324module_init (i2c_prosavage_init);
325module_exit (i2c_prosavage_exit);
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index dde6ce963a1..af9e6034d7f 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1104,5 +1104,5 @@ static void __exit i2c_adap_pxa_exit(void)
1104MODULE_LICENSE("GPL"); 1104MODULE_LICENSE("GPL");
1105MODULE_ALIAS("platform:pxa2xx-i2c"); 1105MODULE_ALIAS("platform:pxa2xx-i2c");
1106 1106
1107module_init(i2c_adap_pxa_init); 1107subsys_initcall(i2c_adap_pxa_init);
1108module_exit(i2c_adap_pxa_exit); 1108module_exit(i2c_adap_pxa_exit);
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 9e8c875437b..007390ad981 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -590,7 +590,7 @@ static struct s3c24xx_i2c s3c24xx_i2c = {
590 .owner = THIS_MODULE, 590 .owner = THIS_MODULE,
591 .algo = &s3c24xx_i2c_algorithm, 591 .algo = &s3c24xx_i2c_algorithm,
592 .retries = 2, 592 .retries = 2,
593 .class = I2C_CLASS_HWMON, 593 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
594 }, 594 },
595}; 595};
596 596
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
deleted file mode 100644
index 8adf4abaa03..00000000000
--- a/drivers/i2c/busses/i2c-savage4.c
+++ /dev/null
@@ -1,185 +0,0 @@
1/*
2 i2c-savage4.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (C) 1998-2003 The LM Sensors Team
5 Alexander Wold <awold@bigfoot.com>
6 Mark D. Studebaker <mdsxyz123@yahoo.com>
7
8 Based on i2c-voodoo3.c.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program 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
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23*/
24
25/* This interfaces to the I2C bus of the Savage4 to gain access to
26 the BT869 and possibly other I2C devices. The DDC bus is not
27 yet supported because its register is not memory-mapped.
28*/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/pci.h>
34#include <linux/i2c.h>
35#include <linux/i2c-algo-bit.h>
36#include <asm/io.h>
37
38/* device IDs */
39#define PCI_CHIP_SAVAGE4 0x8A22
40#define PCI_CHIP_SAVAGE2000 0x9102
41
42#define REG 0xff20 /* Serial Port 1 Register */
43
44/* bit locations in the register */
45#define I2C_ENAB 0x00000020
46#define I2C_SCL_OUT 0x00000001
47#define I2C_SDA_OUT 0x00000002
48#define I2C_SCL_IN 0x00000008
49#define I2C_SDA_IN 0x00000010
50
51/* delays */
52#define CYCLE_DELAY 10
53#define TIMEOUT (HZ / 2)
54
55
56static void __iomem *ioaddr;
57
58/* The sav GPIO registers don't have individual masks for each bit
59 so we always have to read before writing. */
60
61static void bit_savi2c_setscl(void *data, int val)
62{
63 unsigned int r;
64 r = readl(ioaddr + REG);
65 if(val)
66 r |= I2C_SCL_OUT;
67 else
68 r &= ~I2C_SCL_OUT;
69 writel(r, ioaddr + REG);
70 readl(ioaddr + REG); /* flush posted write */
71}
72
73static void bit_savi2c_setsda(void *data, int val)
74{
75 unsigned int r;
76 r = readl(ioaddr + REG);
77 if(val)
78 r |= I2C_SDA_OUT;
79 else
80 r &= ~I2C_SDA_OUT;
81 writel(r, ioaddr + REG);
82 readl(ioaddr + REG); /* flush posted write */
83}
84
85/* The GPIO pins are open drain, so the pins always remain outputs.
86 We rely on the i2c-algo-bit routines to set the pins high before
87 reading the input from other chips. */
88
89static int bit_savi2c_getscl(void *data)
90{
91 return (0 != (readl(ioaddr + REG) & I2C_SCL_IN));
92}
93
94static int bit_savi2c_getsda(void *data)
95{
96 return (0 != (readl(ioaddr + REG) & I2C_SDA_IN));
97}
98
99/* Configures the chip */
100
101static int config_s4(struct pci_dev *dev)
102{
103 unsigned long cadr;
104
105 /* map memory */
106 cadr = dev->resource[0].start;
107 cadr &= PCI_BASE_ADDRESS_MEM_MASK;
108 ioaddr = ioremap_nocache(cadr, 0x0080000);
109 if (ioaddr) {
110 /* writel(0x8160, ioaddr + REG2); */
111 writel(0x00000020, ioaddr + REG);
112 dev_info(&dev->dev, "Using Savage4 at %p\n", ioaddr);
113 return 0;
114 }
115 return -ENODEV;
116}
117
118static struct i2c_algo_bit_data sav_i2c_bit_data = {
119 .setsda = bit_savi2c_setsda,
120 .setscl = bit_savi2c_setscl,
121 .getsda = bit_savi2c_getsda,
122 .getscl = bit_savi2c_getscl,
123 .udelay = CYCLE_DELAY,
124 .timeout = TIMEOUT
125};
126
127static struct i2c_adapter savage4_i2c_adapter = {
128 .owner = THIS_MODULE,
129 .id = I2C_HW_B_SAVAGE,
130 .name = "I2C Savage4 adapter",
131 .algo_data = &sav_i2c_bit_data,
132};
133
134static struct pci_device_id savage4_ids[] __devinitdata = {
135 { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE4) },
136 { PCI_DEVICE(PCI_VENDOR_ID_S3, PCI_CHIP_SAVAGE2000) },
137 { 0, }
138};
139
140MODULE_DEVICE_TABLE (pci, savage4_ids);
141
142static int __devinit savage4_probe(struct pci_dev *dev, const struct pci_device_id *id)
143{
144 int retval;
145
146 retval = config_s4(dev);
147 if (retval)
148 return retval;
149
150 /* set up the sysfs linkage to our parent device */
151 savage4_i2c_adapter.dev.parent = &dev->dev;
152
153 return i2c_bit_add_bus(&savage4_i2c_adapter);
154}
155
156static void __devexit savage4_remove(struct pci_dev *dev)
157{
158 i2c_del_adapter(&savage4_i2c_adapter);
159 iounmap(ioaddr);
160}
161
162static struct pci_driver savage4_driver = {
163 .name = "savage4_smbus",
164 .id_table = savage4_ids,
165 .probe = savage4_probe,
166 .remove = __devexit_p(savage4_remove),
167};
168
169static int __init i2c_savage4_init(void)
170{
171 return pci_register_driver(&savage4_driver);
172}
173
174static void __exit i2c_savage4_exit(void)
175{
176 pci_unregister_driver(&savage4_driver);
177}
178
179MODULE_AUTHOR("Alexander Wold <awold@bigfoot.com> "
180 "and Mark D. Studebaker <mdsxyz123@yahoo.com>");
181MODULE_DESCRIPTION("Savage4 I2C/SMBus driver");
182MODULE_LICENSE("GPL");
183
184module_init(i2c_savage4_init);
185module_exit(i2c_savage4_exit);
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 114634da6c6..4ddefbf238e 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -143,7 +143,7 @@ static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); 143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); 144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
145 145
146 return i2c_add_adapter(i2c_adap); 146 return i2c_add_numbered_adapter(i2c_adap);
147} 147}
148 148
149 149
@@ -156,17 +156,19 @@ static struct i2c_adapter sibyte_board_adapter[2] = {
156 { 156 {
157 .owner = THIS_MODULE, 157 .owner = THIS_MODULE,
158 .id = I2C_HW_SIBYTE, 158 .id = I2C_HW_SIBYTE,
159 .class = I2C_CLASS_HWMON, 159 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
160 .algo = NULL, 160 .algo = NULL,
161 .algo_data = &sibyte_board_data[0], 161 .algo_data = &sibyte_board_data[0],
162 .nr = 0,
162 .name = "SiByte SMBus 0", 163 .name = "SiByte SMBus 0",
163 }, 164 },
164 { 165 {
165 .owner = THIS_MODULE, 166 .owner = THIS_MODULE,
166 .id = I2C_HW_SIBYTE, 167 .id = I2C_HW_SIBYTE,
167 .class = I2C_CLASS_HWMON, 168 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
168 .algo = NULL, 169 .algo = NULL,
169 .algo_data = &sibyte_board_data[1], 170 .algo_data = &sibyte_board_data[1],
171 .nr = 1,
170 .name = "SiByte SMBus 1", 172 .name = "SiByte SMBus 1",
171 }, 173 },
172}; 174};
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 9ca8f9155f9..dfc2d5eb6a6 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -1,6 +1,4 @@
1/* 1/*
2 sis5595.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> 3 Philip Edelbrock <phil@netroedge.com>
6 4
@@ -62,6 +60,7 @@
62#include <linux/ioport.h> 60#include <linux/ioport.h>
63#include <linux/init.h> 61#include <linux/init.h>
64#include <linux/i2c.h> 62#include <linux/i2c.h>
63#include <linux/acpi.h>
65#include <asm/io.h> 64#include <asm/io.h>
66 65
67static int blacklist[] = { 66static int blacklist[] = {
@@ -174,6 +173,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
174 173
175 /* NB: We grab just the two SMBus registers here, but this may still 174 /* NB: We grab just the two SMBus registers here, but this may still
176 * interfere with ACPI :-( */ 175 * interfere with ACPI :-( */
176 retval = acpi_check_region(sis5595_base + SMB_INDEX, 2,
177 sis5595_driver.name);
178 if (retval)
179 return retval;
180
177 if (!request_region(sis5595_base + SMB_INDEX, 2, 181 if (!request_region(sis5595_base + SMB_INDEX, 2,
178 sis5595_driver.name)) { 182 sis5595_driver.name)) {
179 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n", 183 dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n",
@@ -236,7 +240,7 @@ static int sis5595_transaction(struct i2c_adapter *adap)
236 sis5595_write(SMB_STS_HI, temp >> 8); 240 sis5595_write(SMB_STS_HI, temp >> 8);
237 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) { 241 if ((temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8)) != 0x00) {
238 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); 242 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
239 return -1; 243 return -EBUSY;
240 } else { 244 } else {
241 dev_dbg(&adap->dev, "Successful!\n"); 245 dev_dbg(&adap->dev, "Successful!\n");
242 } 246 }
@@ -254,19 +258,19 @@ static int sis5595_transaction(struct i2c_adapter *adap)
254 /* If the SMBus is still busy, we give up */ 258 /* If the SMBus is still busy, we give up */
255 if (timeout >= MAX_TIMEOUT) { 259 if (timeout >= MAX_TIMEOUT) {
256 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 260 dev_dbg(&adap->dev, "SMBus Timeout!\n");
257 result = -1; 261 result = -ETIMEDOUT;
258 } 262 }
259 263
260 if (temp & 0x10) { 264 if (temp & 0x10) {
261 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 265 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
262 result = -1; 266 result = -ENXIO;
263 } 267 }
264 268
265 if (temp & 0x20) { 269 if (temp & 0x20) {
266 dev_err(&adap->dev, "Bus collision! SMBus may be locked until " 270 dev_err(&adap->dev, "Bus collision! SMBus may be locked until "
267 "next hard reset (or not...)\n"); 271 "next hard reset (or not...)\n");
268 /* Clock stops and slave is stuck in mid-transmission */ 272 /* Clock stops and slave is stuck in mid-transmission */
269 result = -1; 273 result = -EIO;
270 } 274 }
271 275
272 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8); 276 temp = sis5595_read(SMB_STS_LO) + (sis5595_read(SMB_STS_HI) << 8);
@@ -282,11 +286,13 @@ static int sis5595_transaction(struct i2c_adapter *adap)
282 return result; 286 return result;
283} 287}
284 288
285/* Return -1 on error. */ 289/* Return negative errno on error. */
286static s32 sis5595_access(struct i2c_adapter *adap, u16 addr, 290static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
287 unsigned short flags, char read_write, 291 unsigned short flags, char read_write,
288 u8 command, int size, union i2c_smbus_data *data) 292 u8 command, int size, union i2c_smbus_data *data)
289{ 293{
294 int status;
295
290 switch (size) { 296 switch (size) {
291 case I2C_SMBUS_QUICK: 297 case I2C_SMBUS_QUICK:
292 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01)); 298 sis5595_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
@@ -318,13 +324,14 @@ static s32 sis5595_access(struct i2c_adapter *adap, u16 addr,
318 break; 324 break;
319 default: 325 default:
320 dev_warn(&adap->dev, "Unsupported transaction %d\n", size); 326 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
321 return -1; 327 return -EOPNOTSUPP;
322 } 328 }
323 329
324 sis5595_write(SMB_CTL_LO, ((size & 0x0E))); 330 sis5595_write(SMB_CTL_LO, ((size & 0x0E)));
325 331
326 if (sis5595_transaction(adap)) 332 status = sis5595_transaction(adap);
327 return -1; 333 if (status)
334 return status;
328 335
329 if ((size != SIS5595_PROC_CALL) && 336 if ((size != SIS5595_PROC_CALL) &&
330 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK))) 337 ((read_write == I2C_SMBUS_WRITE) || (size == SIS5595_QUICK)))
@@ -359,7 +366,7 @@ static const struct i2c_algorithm smbus_algorithm = {
359static struct i2c_adapter sis5595_adapter = { 366static struct i2c_adapter sis5595_adapter = {
360 .owner = THIS_MODULE, 367 .owner = THIS_MODULE,
361 .id = I2C_HW_SMBUS_SIS5595, 368 .id = I2C_HW_SMBUS_SIS5595,
362 .class = I2C_CLASS_HWMON, 369 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
363 .algo = &smbus_algorithm, 370 .algo = &smbus_algorithm,
364}; 371};
365 372
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 3765dd7f450..e7c4b790da5 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -1,7 +1,4 @@
1/* 1/*
2 i2c-sis630.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4
5 Copyright (c) 2002,2003 Alexander Malysh <amalysh@web.de> 2 Copyright (c) 2002,2003 Alexander Malysh <amalysh@web.de>
6 3
7 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
@@ -55,6 +52,7 @@
55#include <linux/ioport.h> 52#include <linux/ioport.h>
56#include <linux/init.h> 53#include <linux/init.h>
57#include <linux/i2c.h> 54#include <linux/i2c.h>
55#include <linux/acpi.h>
58#include <asm/io.h> 56#include <asm/io.h>
59 57
60/* SIS630 SMBus registers */ 58/* SIS630 SMBus registers */
@@ -134,7 +132,7 @@ static int sis630_transaction_start(struct i2c_adapter *adap, int size, u8 *oldc
134 132
135 if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) { 133 if ((temp = sis630_read(SMB_CNT) & 0x03) != 0x00) {
136 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp); 134 dev_dbg(&adap->dev, "Failed! (%02x)\n", temp);
137 return -1; 135 return -EBUSY;
138 } else { 136 } else {
139 dev_dbg(&adap->dev, "Successful!\n"); 137 dev_dbg(&adap->dev, "Successful!\n");
140 } 138 }
@@ -177,17 +175,17 @@ static int sis630_transaction_wait(struct i2c_adapter *adap, int size)
177 /* If the SMBus is still busy, we give up */ 175 /* If the SMBus is still busy, we give up */
178 if (timeout >= MAX_TIMEOUT) { 176 if (timeout >= MAX_TIMEOUT) {
179 dev_dbg(&adap->dev, "SMBus Timeout!\n"); 177 dev_dbg(&adap->dev, "SMBus Timeout!\n");
180 result = -1; 178 result = -ETIMEDOUT;
181 } 179 }
182 180
183 if (temp & 0x02) { 181 if (temp & 0x02) {
184 dev_dbg(&adap->dev, "Error: Failed bus transaction\n"); 182 dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
185 result = -1; 183 result = -ENXIO;
186 } 184 }
187 185
188 if (temp & 0x04) { 186 if (temp & 0x04) {
189 dev_err(&adap->dev, "Bus collision!\n"); 187 dev_err(&adap->dev, "Bus collision!\n");
190 result = -1; 188 result = -EIO;
191 /* 189 /*
192 TBD: Datasheet say: 190 TBD: Datasheet say:
193 the software should clear this bit and restart SMBUS operation. 191 the software should clear this bit and restart SMBUS operation.
@@ -250,8 +248,10 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
250 if (i==8 || (len<8 && i==len)) { 248 if (i==8 || (len<8 && i==len)) {
251 dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i); 249 dev_dbg(&adap->dev, "start trans len=%d i=%d\n",len ,i);
252 /* first transaction */ 250 /* first transaction */
253 if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) 251 rc = sis630_transaction_start(adap,
254 return -1; 252 SIS630_BLOCK_DATA, &oldclock);
253 if (rc)
254 return rc;
255 } 255 }
256 else if ((i-1)%8 == 7 || i==len) { 256 else if ((i-1)%8 == 7 || i==len) {
257 dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i); 257 dev_dbg(&adap->dev, "trans_wait len=%d i=%d\n",len,i);
@@ -264,9 +264,10 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
264 */ 264 */
265 sis630_write(SMB_STS,0x10); 265 sis630_write(SMB_STS,0x10);
266 } 266 }
267 if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) { 267 rc = sis630_transaction_wait(adap,
268 SIS630_BLOCK_DATA);
269 if (rc) {
268 dev_dbg(&adap->dev, "trans_wait failed\n"); 270 dev_dbg(&adap->dev, "trans_wait failed\n");
269 rc = -1;
270 break; 271 break;
271 } 272 }
272 } 273 }
@@ -275,13 +276,14 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
275 else { 276 else {
276 /* read request */ 277 /* read request */
277 data->block[0] = len = 0; 278 data->block[0] = len = 0;
278 if (sis630_transaction_start(adap, SIS630_BLOCK_DATA, &oldclock)) { 279 rc = sis630_transaction_start(adap,
279 return -1; 280 SIS630_BLOCK_DATA, &oldclock);
280 } 281 if (rc)
282 return rc;
281 do { 283 do {
282 if (sis630_transaction_wait(adap, SIS630_BLOCK_DATA)) { 284 rc = sis630_transaction_wait(adap, SIS630_BLOCK_DATA);
285 if (rc) {
283 dev_dbg(&adap->dev, "trans_wait failed\n"); 286 dev_dbg(&adap->dev, "trans_wait failed\n");
284 rc = -1;
285 break; 287 break;
286 } 288 }
287 /* if this first transaction then read byte count */ 289 /* if this first transaction then read byte count */
@@ -311,11 +313,13 @@ static int sis630_block_data(struct i2c_adapter *adap, union i2c_smbus_data *dat
311 return rc; 313 return rc;
312} 314}
313 315
314/* Return -1 on error. */ 316/* Return negative errno on error. */
315static s32 sis630_access(struct i2c_adapter *adap, u16 addr, 317static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
316 unsigned short flags, char read_write, 318 unsigned short flags, char read_write,
317 u8 command, int size, union i2c_smbus_data *data) 319 u8 command, int size, union i2c_smbus_data *data)
318{ 320{
321 int status;
322
319 switch (size) { 323 switch (size) {
320 case I2C_SMBUS_QUICK: 324 case I2C_SMBUS_QUICK:
321 sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01)); 325 sis630_write(SMB_ADDR, ((addr & 0x7f) << 1) | (read_write & 0x01));
@@ -350,13 +354,14 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
350 size = SIS630_BLOCK_DATA; 354 size = SIS630_BLOCK_DATA;
351 return sis630_block_data(adap, data, read_write); 355 return sis630_block_data(adap, data, read_write);
352 default: 356 default:
353 printk("Unsupported I2C size\n"); 357 dev_warn(&adap->dev, "Unsupported transaction %d\n",
354 return -1; 358 size);
355 break; 359 return -EOPNOTSUPP;
356 } 360 }
357 361
358 if (sis630_transaction(adap, size)) 362 status = sis630_transaction(adap, size);
359 return -1; 363 if (status)
364 return status;
360 365
361 if ((size != SIS630_PCALL) && 366 if ((size != SIS630_PCALL) &&
362 ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) { 367 ((read_write == I2C_SMBUS_WRITE) || (size == SIS630_QUICK))) {
@@ -372,9 +377,6 @@ static s32 sis630_access(struct i2c_adapter *adap, u16 addr,
372 case SIS630_WORD_DATA: 377 case SIS630_WORD_DATA:
373 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8); 378 data->word = sis630_read(SMB_BYTE) + (sis630_read(SMB_BYTE + 1) << 8);
374 break; 379 break;
375 default:
376 return -1;
377 break;
378 } 380 }
379 381
380 return 0; 382 return 0;
@@ -433,6 +435,11 @@ static int sis630_setup(struct pci_dev *sis630_dev)
433 435
434 dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base); 436 dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
435 437
438 retval = acpi_check_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION,
439 sis630_driver.name);
440 if (retval)
441 goto exit;
442
436 /* Everything is happy, let's grab the memory and set things up. */ 443 /* Everything is happy, let's grab the memory and set things up. */
437 if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION, 444 if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION,
438 sis630_driver.name)) { 445 sis630_driver.name)) {
@@ -458,7 +465,7 @@ static const struct i2c_algorithm smbus_algorithm = {
458static struct i2c_adapter sis630_adapter = { 465static struct i2c_adapter sis630_adapter = {
459 .owner = THIS_MODULE, 466 .owner = THIS_MODULE,
460 .id = I2C_HW_SMBUS_SIS630, 467 .id = I2C_HW_SMBUS_SIS630,
461 .class = I2C_CLASS_HWMON, 468 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
462 .algo = &smbus_algorithm, 469 .algo = &smbus_algorithm,
463}; 470};
464 471
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index dc235bb8e24..f1bba639664 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -1,7 +1,4 @@
1/* 1/*
2 sis96x.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4
5 Copyright (c) 2003 Mark M. Hoffman <mhoffman@lightlink.com> 2 Copyright (c) 2003 Mark M. Hoffman <mhoffman@lightlink.com>
6 3
7 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
@@ -40,6 +37,7 @@
40#include <linux/ioport.h> 37#include <linux/ioport.h>
41#include <linux/i2c.h> 38#include <linux/i2c.h>
42#include <linux/init.h> 39#include <linux/init.h>
40#include <linux/acpi.h>
43#include <asm/io.h> 41#include <asm/io.h>
44 42
45/* base address register in PCI config space */ 43/* base address register in PCI config space */
@@ -111,7 +109,7 @@ static int sis96x_transaction(int size)
111 /* check it again */ 109 /* check it again */
112 if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) { 110 if (((temp = sis96x_read(SMB_CNT)) & 0x03) != 0x00) {
113 dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp); 111 dev_dbg(&sis96x_adapter.dev, "Failed (0x%02x)\n", temp);
114 return -1; 112 return -EBUSY;
115 } else { 113 } else {
116 dev_dbg(&sis96x_adapter.dev, "Successful\n"); 114 dev_dbg(&sis96x_adapter.dev, "Successful\n");
117 } 115 }
@@ -136,19 +134,19 @@ static int sis96x_transaction(int size)
136 /* If the SMBus is still busy, we give up */ 134 /* If the SMBus is still busy, we give up */
137 if (timeout >= MAX_TIMEOUT) { 135 if (timeout >= MAX_TIMEOUT) {
138 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp); 136 dev_dbg(&sis96x_adapter.dev, "SMBus Timeout! (0x%02x)\n", temp);
139 result = -1; 137 result = -ETIMEDOUT;
140 } 138 }
141 139
142 /* device error - probably missing ACK */ 140 /* device error - probably missing ACK */
143 if (temp & 0x02) { 141 if (temp & 0x02) {
144 dev_dbg(&sis96x_adapter.dev, "Failed bus transaction!\n"); 142 dev_dbg(&sis96x_adapter.dev, "Failed bus transaction!\n");
145 result = -1; 143 result = -ENXIO;
146 } 144 }
147 145
148 /* bus collision */ 146 /* bus collision */
149 if (temp & 0x04) { 147 if (temp & 0x04) {
150 dev_dbg(&sis96x_adapter.dev, "Bus collision!\n"); 148 dev_dbg(&sis96x_adapter.dev, "Bus collision!\n");
151 result = -1; 149 result = -EIO;
152 } 150 }
153 151
154 /* Finish up by resetting the bus */ 152 /* Finish up by resetting the bus */
@@ -161,11 +159,12 @@ static int sis96x_transaction(int size)
161 return result; 159 return result;
162} 160}
163 161
164/* Return -1 on error. */ 162/* Return negative errno on error. */
165static s32 sis96x_access(struct i2c_adapter * adap, u16 addr, 163static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
166 unsigned short flags, char read_write, 164 unsigned short flags, char read_write,
167 u8 command, int size, union i2c_smbus_data * data) 165 u8 command, int size, union i2c_smbus_data * data)
168{ 166{
167 int status;
169 168
170 switch (size) { 169 switch (size) {
171 case I2C_SMBUS_QUICK: 170 case I2C_SMBUS_QUICK:
@@ -200,20 +199,14 @@ static s32 sis96x_access(struct i2c_adapter * adap, u16 addr,
200 SIS96x_PROC_CALL : SIS96x_WORD_DATA); 199 SIS96x_PROC_CALL : SIS96x_WORD_DATA);
201 break; 200 break;
202 201
203 case I2C_SMBUS_BLOCK_DATA:
204 /* TO DO: */
205 dev_info(&adap->dev, "SMBus block not implemented!\n");
206 return -1;
207 break;
208
209 default: 202 default:
210 dev_info(&adap->dev, "Unsupported I2C size\n"); 203 dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
211 return -1; 204 return -EOPNOTSUPP;
212 break;
213 } 205 }
214 206
215 if (sis96x_transaction(size)) 207 status = sis96x_transaction(size);
216 return -1; 208 if (status)
209 return status;
217 210
218 if ((size != SIS96x_PROC_CALL) && 211 if ((size != SIS96x_PROC_CALL) &&
219 ((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK))) 212 ((read_write == I2C_SMBUS_WRITE) || (size == SIS96x_QUICK)))
@@ -249,7 +242,7 @@ static const struct i2c_algorithm smbus_algorithm = {
249static struct i2c_adapter sis96x_adapter = { 242static struct i2c_adapter sis96x_adapter = {
250 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
251 .id = I2C_HW_SMBUS_SIS96X, 244 .id = I2C_HW_SMBUS_SIS96X,
252 .class = I2C_CLASS_HWMON, 245 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
253 .algo = &smbus_algorithm, 246 .algo = &smbus_algorithm,
254}; 247};
255 248
@@ -286,6 +279,10 @@ static int __devinit sis96x_probe(struct pci_dev *dev,
286 dev_info(&dev->dev, "SiS96x SMBus base address: 0x%04x\n", 279 dev_info(&dev->dev, "SiS96x SMBus base address: 0x%04x\n",
287 sis96x_smbus_base); 280 sis96x_smbus_base);
288 281
282 retval = acpi_check_resource_conflict(&dev->resource[SIS96x_BAR]);
283 if (retval)
284 return retval;
285
289 /* Everything is happy, let's grab the memory and set things up. */ 286 /* Everything is happy, let's grab the memory and set things up. */
290 if (!request_region(sis96x_smbus_base, SMB_IOSIZE, 287 if (!request_region(sis96x_smbus_base, SMB_IOSIZE,
291 sis96x_driver.name)) { 288 sis96x_driver.name)) {
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
index d08eeec5391..1b7b2af9403 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/busses/i2c-stub.c
@@ -43,7 +43,7 @@ struct stub_chip {
43 43
44static struct stub_chip *stub_chips; 44static struct stub_chip *stub_chips;
45 45
46/* Return -1 on error. */ 46/* Return negative errno on error. */
47static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, 47static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
48 char read_write, u8 command, int size, union i2c_smbus_data * data) 48 char read_write, u8 command, int size, union i2c_smbus_data * data)
49{ 49{
@@ -120,7 +120,7 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
120 120
121 default: 121 default:
122 dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n"); 122 dev_dbg(&adap->dev, "Unsupported I2C/SMBus command\n");
123 ret = -1; 123 ret = -EOPNOTSUPP;
124 break; 124 break;
125 } /* switch (size) */ 125 } /* switch (size) */
126 126
@@ -140,7 +140,7 @@ static const struct i2c_algorithm smbus_algorithm = {
140 140
141static struct i2c_adapter stub_adapter = { 141static struct i2c_adapter stub_adapter = {
142 .owner = THIS_MODULE, 142 .owner = THIS_MODULE,
143 .class = I2C_CLASS_HWMON, 143 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
144 .algo = &smbus_algorithm, 144 .algo = &smbus_algorithm,
145 .name = "SMBus stub driver", 145 .name = "SMBus stub driver",
146}; 146};
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index de9db49e54d..224aa12ee7c 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -96,9 +96,8 @@ static int taos_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
96 sprintf(p, "$%02X", command); 96 sprintf(p, "$%02X", command);
97 break; 97 break;
98 default: 98 default:
99 dev_dbg(&adapter->dev, "Unsupported transaction size %d\n", 99 dev_warn(&adapter->dev, "Unsupported transaction %d\n", size);
100 size); 100 return -EOPNOTSUPP;
101 return -EINVAL;
102 } 101 }
103 102
104 /* Send the transaction to the TAOS EVM */ 103 /* Send the transaction to the TAOS EVM */
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 61716f6b14d..29cef0433f3 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -1,7 +1,4 @@
1/* 1/*
2 i2c-via.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
4
5 i2c Support for Via Technologies 82C586B South Bridge 2 i2c Support for Via Technologies 82C586B South Bridge
6 3
7 Copyright (c) 1998, 1999 Kyösti Mälkki <kmalkki@cc.hut.fi> 4 Copyright (c) 1998, 1999 Kyösti Mälkki <kmalkki@cc.hut.fi>
@@ -87,7 +84,7 @@ static struct i2c_algo_bit_data bit_data = {
87static struct i2c_adapter vt586b_adapter = { 84static struct i2c_adapter vt586b_adapter = {
88 .owner = THIS_MODULE, 85 .owner = THIS_MODULE,
89 .id = I2C_HW_B_VIA, 86 .id = I2C_HW_B_VIA,
90 .class = I2C_CLASS_HWMON, 87 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
91 .name = "VIA i2c", 88 .name = "VIA i2c",
92 .algo_data = &bit_data, 89 .algo_data = &bit_data,
93}; 90};
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 77b13d027f8..862eb352a2d 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -1,6 +1,4 @@
1/* 1/*
2 i2c-viapro.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>, 3 Philip Edelbrock <phil@netroedge.com>, Kyösti Mälkki <kmalkki@cc.hut.fi>,
6 Mark D. Studebaker <mdsxyz123@yahoo.com> 4 Mark D. Studebaker <mdsxyz123@yahoo.com>
@@ -50,6 +48,7 @@
50#include <linux/ioport.h> 48#include <linux/ioport.h>
51#include <linux/i2c.h> 49#include <linux/i2c.h>
52#include <linux/init.h> 50#include <linux/init.h>
51#include <linux/acpi.h>
53#include <asm/io.h> 52#include <asm/io.h>
54 53
55static struct pci_dev *vt596_pdev; 54static struct pci_dev *vt596_pdev;
@@ -152,7 +151,7 @@ static int vt596_transaction(u8 size)
152 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) { 151 if ((temp = inb_p(SMBHSTSTS)) & 0x1F) {
153 dev_err(&vt596_adapter.dev, "SMBus reset failed! " 152 dev_err(&vt596_adapter.dev, "SMBus reset failed! "
154 "(0x%02x)\n", temp); 153 "(0x%02x)\n", temp);
155 return -1; 154 return -EBUSY;
156 } 155 }
157 } 156 }
158 157
@@ -167,24 +166,24 @@ static int vt596_transaction(u8 size)
167 166
168 /* If the SMBus is still busy, we give up */ 167 /* If the SMBus is still busy, we give up */
169 if (timeout >= MAX_TIMEOUT) { 168 if (timeout >= MAX_TIMEOUT) {
170 result = -1; 169 result = -ETIMEDOUT;
171 dev_err(&vt596_adapter.dev, "SMBus timeout!\n"); 170 dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
172 } 171 }
173 172
174 if (temp & 0x10) { 173 if (temp & 0x10) {
175 result = -1; 174 result = -EIO;
176 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n", 175 dev_err(&vt596_adapter.dev, "Transaction failed (0x%02x)\n",
177 size); 176 size);
178 } 177 }
179 178
180 if (temp & 0x08) { 179 if (temp & 0x08) {
181 result = -1; 180 result = -EIO;
182 dev_err(&vt596_adapter.dev, "SMBus collision!\n"); 181 dev_err(&vt596_adapter.dev, "SMBus collision!\n");
183 } 182 }
184 183
185 if (temp & 0x04) { 184 if (temp & 0x04) {
186 int read = inb_p(SMBHSTADD) & 0x01; 185 int read = inb_p(SMBHSTADD) & 0x01;
187 result = -1; 186 result = -ENXIO;
188 /* The quick and receive byte commands are used to probe 187 /* The quick and receive byte commands are used to probe
189 for chips, so errors are expected, and we don't want 188 for chips, so errors are expected, and we don't want
190 to frighten the user. */ 189 to frighten the user. */
@@ -202,12 +201,13 @@ static int vt596_transaction(u8 size)
202 return result; 201 return result;
203} 202}
204 203
205/* Return -1 on error, 0 on success */ 204/* Return negative errno on error, 0 on success */
206static s32 vt596_access(struct i2c_adapter *adap, u16 addr, 205static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
207 unsigned short flags, char read_write, u8 command, 206 unsigned short flags, char read_write, u8 command,
208 int size, union i2c_smbus_data *data) 207 int size, union i2c_smbus_data *data)
209{ 208{
210 int i; 209 int i;
210 int status;
211 211
212 switch (size) { 212 switch (size) {
213 case I2C_SMBUS_QUICK: 213 case I2C_SMBUS_QUICK:
@@ -258,8 +258,9 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
258 258
259 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD); 259 outb_p(((addr & 0x7f) << 1) | read_write, SMBHSTADD);
260 260
261 if (vt596_transaction(size)) /* Error in transaction */ 261 status = vt596_transaction(size);
262 return -1; 262 if (status)
263 return status;
263 264
264 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK)) 265 if ((read_write == I2C_SMBUS_WRITE) || (size == VT596_QUICK))
265 return 0; 266 return 0;
@@ -285,9 +286,9 @@ static s32 vt596_access(struct i2c_adapter *adap, u16 addr,
285 return 0; 286 return 0;
286 287
287exit_unsupported: 288exit_unsupported:
288 dev_warn(&vt596_adapter.dev, "Unsupported command invoked! (0x%02x)\n", 289 dev_warn(&vt596_adapter.dev, "Unsupported transaction %d\n",
289 size); 290 size);
290 return -1; 291 return -EOPNOTSUPP;
291} 292}
292 293
293static u32 vt596_func(struct i2c_adapter *adapter) 294static u32 vt596_func(struct i2c_adapter *adapter)
@@ -309,7 +310,7 @@ static const struct i2c_algorithm smbus_algorithm = {
309static struct i2c_adapter vt596_adapter = { 310static struct i2c_adapter vt596_adapter = {
310 .owner = THIS_MODULE, 311 .owner = THIS_MODULE,
311 .id = I2C_HW_SMBUS_VIA2, 312 .id = I2C_HW_SMBUS_VIA2,
312 .class = I2C_CLASS_HWMON, 313 .class = I2C_CLASS_HWMON | I2C_CLASS_SPD,
313 .algo = &smbus_algorithm, 314 .algo = &smbus_algorithm,
314}; 315};
315 316
@@ -354,6 +355,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
354 } 355 }
355 356
356found: 357found:
358 error = acpi_check_region(vt596_smba, 8, vt596_driver.name);
359 if (error)
360 return error;
361
357 if (!request_region(vt596_smba, 8, vt596_driver.name)) { 362 if (!request_region(vt596_smba, 8, vt596_driver.name)) {
358 dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n", 363 dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
359 vt596_smba); 364 vt596_smba);
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index 88a3447e11e..1d4ae26ba73 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -1,6 +1,4 @@
1/* 1/*
2 voodoo3.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, 3 Philip Edelbrock <phil@netroedge.com>,
6 Ralph Metzler <rjkm@thp.uni-koeln.de>, and 4 Ralph Metzler <rjkm@thp.uni-koeln.de>, and
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index 61abe0f3325..ed794b145a1 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -442,7 +442,7 @@ static __init struct scx200_acb_iface *scx200_create_iface(const char *text,
442 adapter->owner = THIS_MODULE; 442 adapter->owner = THIS_MODULE;
443 adapter->id = I2C_HW_SMBUS_SCX200; 443 adapter->id = I2C_HW_SMBUS_SCX200;
444 adapter->algo = &scx200_acb_algorithm; 444 adapter->algo = &scx200_acb_algorithm;
445 adapter->class = I2C_CLASS_HWMON; 445 adapter->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
446 adapter->dev.parent = dev; 446 adapter->dev.parent = dev;
447 447
448 mutex_init(&iface->mutex); 448 mutex_init(&iface->mutex);
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 2da2edfa68e..50e0a465374 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -14,6 +14,32 @@ config DS1682
14 This driver can also be built as a module. If so, the module 14 This driver can also be built as a module. If so, the module
15 will be called ds1682. 15 will be called ds1682.
16 16
17config AT24
18 tristate "EEPROMs from most vendors"
19 depends on SYSFS && EXPERIMENTAL
20 help
21 Enable this driver to get read/write support to most I2C EEPROMs,
22 after you configure the driver to know about each EEPROM on
23 your target board. Use these generic chip names, instead of
24 vendor-specific ones like at24c64 or 24lc02:
25
26 24c00, 24c01, 24c02, spd (readonly 24c02), 24c04, 24c08,
27 24c16, 24c32, 24c64, 24c128, 24c256, 24c512, 24c1024
28
29 Unless you like data loss puzzles, always be sure that any chip
30 you configure as a 24c32 (32 kbit) or larger is NOT really a
31 24c16 (16 kbit) or smaller, and vice versa. Marking the chip
32 as read-only won't help recover from this. Also, if your chip
33 has any software write-protect mechanism you may want to review the
34 code to make sure this driver won't turn it on by accident.
35
36 If you use this with an SMBus adapter instead of an I2C adapter,
37 full functionality is not available. Only smaller devices are
38 supported (24c16 and below, max 4 kByte).
39
40 This driver can also be built as a module. If so, the module
41 will be called at24.
42
17config SENSORS_EEPROM 43config SENSORS_EEPROM
18 tristate "EEPROM reader" 44 tristate "EEPROM reader"
19 depends on EXPERIMENTAL 45 depends on EXPERIMENTAL
@@ -26,8 +52,8 @@ config SENSORS_EEPROM
26 will be called eeprom. 52 will be called eeprom.
27 53
28config SENSORS_PCF8574 54config SENSORS_PCF8574
29 tristate "Philips PCF8574 and PCF8574A" 55 tristate "Philips PCF8574 and PCF8574A (DEPRECATED)"
30 depends on EXPERIMENTAL 56 depends on EXPERIMENTAL && GPIO_PCF857X = "n"
31 default n 57 default n
32 help 58 help
33 If you say yes here you get support for Philips PCF8574 and 59 If you say yes here you get support for Philips PCF8574 and
@@ -36,12 +62,16 @@ config SENSORS_PCF8574
36 This driver can also be built as a module. If so, the module 62 This driver can also be built as a module. If so, the module
37 will be called pcf8574. 63 will be called pcf8574.
38 64
65 This driver is deprecated and will be dropped soon. Use
66 drivers/gpio/pcf857x.c instead.
67
39 These devices are hard to detect and rarely found on mainstream 68 These devices are hard to detect and rarely found on mainstream
40 hardware. If unsure, say N. 69 hardware. If unsure, say N.
41 70
42config PCF8575 71config PCF8575
43 tristate "Philips PCF8575" 72 tristate "Philips PCF8575 (DEPRECATED)"
44 default n 73 default n
74 depends on GPIO_PCF857X = "n"
45 help 75 help
46 If you say yes here you get support for Philips PCF8575 chip. 76 If you say yes here you get support for Philips PCF8575 chip.
47 This chip is a 16-bit I/O expander for the I2C bus. Several other 77 This chip is a 16-bit I/O expander for the I2C bus. Several other
@@ -50,12 +80,15 @@ config PCF8575
50 This driver can also be built as a module. If so, the module 80 This driver can also be built as a module. If so, the module
51 will be called pcf8575. 81 will be called pcf8575.
52 82
83 This driver is deprecated and will be dropped soon. Use
84 drivers/gpio/pcf857x.c instead.
85
53 This device is hard to detect and is rarely found on mainstream 86 This device is hard to detect and is rarely found on mainstream
54 hardware. If unsure, say N. 87 hardware. If unsure, say N.
55 88
56config SENSORS_PCA9539 89config SENSORS_PCA9539
57 tristate "Philips PCA9539 16-bit I/O port (DEPRECATED)" 90 tristate "Philips PCA9539 16-bit I/O port (DEPRECATED)"
58 depends on EXPERIMENTAL && GPIO_PCA9539 = "n" 91 depends on EXPERIMENTAL && GPIO_PCA953X = "n"
59 help 92 help
60 If you say yes here you get support for the Philips PCA9539 93 If you say yes here you get support for the Philips PCA9539
61 16-bit I/O port. 94 16-bit I/O port.
@@ -64,7 +97,7 @@ config SENSORS_PCA9539
64 will be called pca9539. 97 will be called pca9539.
65 98
66 This driver is deprecated and will be dropped soon. Use 99 This driver is deprecated and will be dropped soon. Use
67 drivers/gpio/pca9539.c instead. 100 drivers/gpio/pca953x.c instead.
68 101
69config SENSORS_PCF8591 102config SENSORS_PCF8591
70 tristate "Philips PCF8591" 103 tristate "Philips PCF8591"
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index e47aca0ca5a..39e3e69ed12 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -10,6 +10,7 @@
10# 10#
11 11
12obj-$(CONFIG_DS1682) += ds1682.o 12obj-$(CONFIG_DS1682) += ds1682.o
13obj-$(CONFIG_AT24) += at24.o
13obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o 14obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o
14obj-$(CONFIG_SENSORS_MAX6875) += max6875.o 15obj-$(CONFIG_SENSORS_MAX6875) += max6875.o
15obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o 16obj-$(CONFIG_SENSORS_PCA9539) += pca9539.o
diff --git a/drivers/i2c/chips/at24.c b/drivers/i2c/chips/at24.c
new file mode 100644
index 00000000000..e764c94f3e3
--- /dev/null
+++ b/drivers/i2c/chips/at24.c
@@ -0,0 +1,583 @@
1/*
2 * at24.c - handle most I2C EEPROMs
3 *
4 * Copyright (C) 2005-2007 David Brownell
5 * Copyright (C) 2008 Wolfram Sang, Pengutronix
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#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/slab.h>
16#include <linux/delay.h>
17#include <linux/mutex.h>
18#include <linux/sysfs.h>
19#include <linux/mod_devicetable.h>
20#include <linux/log2.h>
21#include <linux/bitops.h>
22#include <linux/jiffies.h>
23#include <linux/i2c.h>
24#include <linux/i2c/at24.h>
25
26/*
27 * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
28 * Differences between different vendor product lines (like Atmel AT24C or
29 * MicroChip 24LC, etc) won't much matter for typical read/write access.
30 * There are also I2C RAM chips, likewise interchangeable. One example
31 * would be the PCF8570, which acts like a 24c02 EEPROM (256 bytes).
32 *
33 * However, misconfiguration can lose data. "Set 16-bit memory address"
34 * to a part with 8-bit addressing will overwrite data. Writing with too
35 * big a page size also loses data. And it's not safe to assume that the
36 * conventional addresses 0x50..0x57 only hold eeproms; a PCF8563 RTC
37 * uses 0x51, for just one example.
38 *
39 * Accordingly, explicit board-specific configuration data should be used
40 * in almost all cases. (One partial exception is an SMBus used to access
41 * "SPD" data for DRAM sticks. Those only use 24c02 EEPROMs.)
42 *
43 * So this driver uses "new style" I2C driver binding, expecting to be
44 * told what devices exist. That may be in arch/X/mach-Y/board-Z.c or
45 * similar kernel-resident tables; or, configuration data coming from
46 * a bootloader.
47 *
48 * Other than binding model, current differences from "eeprom" driver are
49 * that this one handles write access and isn't restricted to 24c02 devices.
50 * It also handles larger devices (32 kbit and up) with two-byte addresses,
51 * which won't work on pure SMBus systems.
52 */
53
54struct at24_data {
55 struct at24_platform_data chip;
56 bool use_smbus;
57
58 /*
59 * Lock protects against activities from other Linux tasks,
60 * but not from changes by other I2C masters.
61 */
62 struct mutex lock;
63 struct bin_attribute bin;
64
65 u8 *writebuf;
66 unsigned write_max;
67 unsigned num_addresses;
68
69 /*
70 * Some chips tie up multiple I2C addresses; dummy devices reserve
71 * them for us, and we'll use them with SMBus calls.
72 */
73 struct i2c_client *client[];
74};
75
76/*
77 * This parameter is to help this driver avoid blocking other drivers out
78 * of I2C for potentially troublesome amounts of time. With a 100 kHz I2C
79 * clock, one 256 byte read takes about 1/43 second which is excessive;
80 * but the 1/170 second it takes at 400 kHz may be quite reasonable; and
81 * at 1 MHz (Fm+) a 1/430 second delay could easily be invisible.
82 *
83 * This value is forced to be a power of two so that writes align on pages.
84 */
85static unsigned io_limit = 128;
86module_param(io_limit, uint, 0);
87MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)");
88
89/*
90 * Specs often allow 5 msec for a page write, sometimes 20 msec;
91 * it's important to recover from write timeouts.
92 */
93static unsigned write_timeout = 25;
94module_param(write_timeout, uint, 0);
95MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)");
96
97#define AT24_SIZE_BYTELEN 5
98#define AT24_SIZE_FLAGS 8
99
100#define AT24_BITMASK(x) (BIT(x) - 1)
101
102/* create non-zero magic value for given eeprom parameters */
103#define AT24_DEVICE_MAGIC(_len, _flags) \
104 ((1 << AT24_SIZE_FLAGS | (_flags)) \
105 << AT24_SIZE_BYTELEN | ilog2(_len))
106
107static const struct i2c_device_id at24_ids[] = {
108 /* needs 8 addresses as A0-A2 are ignored */
109 { "24c00", AT24_DEVICE_MAGIC(128 / 8, AT24_FLAG_TAKE8ADDR) },
110 /* old variants can't be handled with this generic entry! */
111 { "24c01", AT24_DEVICE_MAGIC(1024 / 8, 0) },
112 { "24c02", AT24_DEVICE_MAGIC(2048 / 8, 0) },
113 /* spd is a 24c02 in memory DIMMs */
114 { "spd", AT24_DEVICE_MAGIC(2048 / 8,
115 AT24_FLAG_READONLY | AT24_FLAG_IRUGO) },
116 { "24c04", AT24_DEVICE_MAGIC(4096 / 8, 0) },
117 /* 24rf08 quirk is handled at i2c-core */
118 { "24c08", AT24_DEVICE_MAGIC(8192 / 8, 0) },
119 { "24c16", AT24_DEVICE_MAGIC(16384 / 8, 0) },
120 { "24c32", AT24_DEVICE_MAGIC(32768 / 8, AT24_FLAG_ADDR16) },
121 { "24c64", AT24_DEVICE_MAGIC(65536 / 8, AT24_FLAG_ADDR16) },
122 { "24c128", AT24_DEVICE_MAGIC(131072 / 8, AT24_FLAG_ADDR16) },
123 { "24c256", AT24_DEVICE_MAGIC(262144 / 8, AT24_FLAG_ADDR16) },
124 { "24c512", AT24_DEVICE_MAGIC(524288 / 8, AT24_FLAG_ADDR16) },
125 { "24c1024", AT24_DEVICE_MAGIC(1048576 / 8, AT24_FLAG_ADDR16) },
126 { "at24", 0 },
127 { /* END OF LIST */ }
128};
129MODULE_DEVICE_TABLE(i2c, at24_ids);
130
131/*-------------------------------------------------------------------------*/
132
133/*
134 * This routine supports chips which consume multiple I2C addresses. It
135 * computes the addressing information to be used for a given r/w request.
136 * Assumes that sanity checks for offset happened at sysfs-layer.
137 */
138static struct i2c_client *at24_translate_offset(struct at24_data *at24,
139 unsigned *offset)
140{
141 unsigned i;
142
143 if (at24->chip.flags & AT24_FLAG_ADDR16) {
144 i = *offset >> 16;
145 *offset &= 0xffff;
146 } else {
147 i = *offset >> 8;
148 *offset &= 0xff;
149 }
150
151 return at24->client[i];
152}
153
154static ssize_t at24_eeprom_read(struct at24_data *at24, char *buf,
155 unsigned offset, size_t count)
156{
157 struct i2c_msg msg[2];
158 u8 msgbuf[2];
159 struct i2c_client *client;
160 int status, i;
161
162 memset(msg, 0, sizeof(msg));
163
164 /*
165 * REVISIT some multi-address chips don't rollover page reads to
166 * the next slave address, so we may need to truncate the count.
167 * Those chips might need another quirk flag.
168 *
169 * If the real hardware used four adjacent 24c02 chips and that
170 * were misconfigured as one 24c08, that would be a similar effect:
171 * one "eeprom" file not four, but larger reads would fail when
172 * they crossed certain pages.
173 */
174
175 /*
176 * Slave address and byte offset derive from the offset. Always
177 * set the byte address; on a multi-master board, another master
178 * may have changed the chip's "current" address pointer.
179 */
180 client = at24_translate_offset(at24, &offset);
181
182 if (count > io_limit)
183 count = io_limit;
184
185 /* Smaller eeproms can work given some SMBus extension calls */
186 if (at24->use_smbus) {
187 if (count > I2C_SMBUS_BLOCK_MAX)
188 count = I2C_SMBUS_BLOCK_MAX;
189 status = i2c_smbus_read_i2c_block_data(client, offset,
190 count, buf);
191 dev_dbg(&client->dev, "smbus read %zd@%d --> %d\n",
192 count, offset, status);
193 return (status < 0) ? -EIO : status;
194 }
195
196 /*
197 * When we have a better choice than SMBus calls, use a combined
198 * I2C message. Write address; then read up to io_limit data bytes.
199 * Note that read page rollover helps us here (unlike writes).
200 * msgbuf is u8 and will cast to our needs.
201 */
202 i = 0;
203 if (at24->chip.flags & AT24_FLAG_ADDR16)
204 msgbuf[i++] = offset >> 8;
205 msgbuf[i++] = offset;
206
207 msg[0].addr = client->addr;
208 msg[0].buf = msgbuf;
209 msg[0].len = i;
210
211 msg[1].addr = client->addr;
212 msg[1].flags = I2C_M_RD;
213 msg[1].buf = buf;
214 msg[1].len = count;
215
216 status = i2c_transfer(client->adapter, msg, 2);
217 dev_dbg(&client->dev, "i2c read %zd@%d --> %d\n",
218 count, offset, status);
219
220 if (status == 2)
221 return count;
222 else if (status >= 0)
223 return -EIO;
224 else
225 return status;
226}
227
228static ssize_t at24_bin_read(struct kobject *kobj, struct bin_attribute *attr,
229 char *buf, loff_t off, size_t count)
230{
231 struct at24_data *at24;
232 ssize_t retval = 0;
233
234 at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
235
236 if (unlikely(!count))
237 return count;
238
239 /*
240 * Read data from chip, protecting against concurrent updates
241 * from this host, but not from other I2C masters.
242 */
243 mutex_lock(&at24->lock);
244
245 while (count) {
246 ssize_t status;
247
248 status = at24_eeprom_read(at24, buf, off, count);
249 if (status <= 0) {
250 if (retval == 0)
251 retval = status;
252 break;
253 }
254 buf += status;
255 off += status;
256 count -= status;
257 retval += status;
258 }
259
260 mutex_unlock(&at24->lock);
261
262 return retval;
263}
264
265
266/*
267 * REVISIT: export at24_bin{read,write}() to let other kernel code use
268 * eeprom data. For example, it might hold a board's Ethernet address, or
269 * board-specific calibration data generated on the manufacturing floor.
270 */
271
272
273/*
274 * Note that if the hardware write-protect pin is pulled high, the whole
275 * chip is normally write protected. But there are plenty of product
276 * variants here, including OTP fuses and partial chip protect.
277 *
278 * We only use page mode writes; the alternative is sloooow. This routine
279 * writes at most one page.
280 */
281static ssize_t at24_eeprom_write(struct at24_data *at24, char *buf,
282 unsigned offset, size_t count)
283{
284 struct i2c_client *client;
285 struct i2c_msg msg;
286 ssize_t status;
287 unsigned long timeout, write_time;
288 unsigned next_page;
289
290 /* Get corresponding I2C address and adjust offset */
291 client = at24_translate_offset(at24, &offset);
292
293 /* write_max is at most a page */
294 if (count > at24->write_max)
295 count = at24->write_max;
296
297 /* Never roll over backwards, to the start of this page */
298 next_page = roundup(offset + 1, at24->chip.page_size);
299 if (offset + count > next_page)
300 count = next_page - offset;
301
302 /* If we'll use I2C calls for I/O, set up the message */
303 if (!at24->use_smbus) {
304 int i = 0;
305
306 msg.addr = client->addr;
307 msg.flags = 0;
308
309 /* msg.buf is u8 and casts will mask the values */
310 msg.buf = at24->writebuf;
311 if (at24->chip.flags & AT24_FLAG_ADDR16)
312 msg.buf[i++] = offset >> 8;
313
314 msg.buf[i++] = offset;
315 memcpy(&msg.buf[i], buf, count);
316 msg.len = i + count;
317 }
318
319 /*
320 * Writes fail if the previous one didn't complete yet. We may
321 * loop a few times until this one succeeds, waiting at least
322 * long enough for one entire page write to work.
323 */
324 timeout = jiffies + msecs_to_jiffies(write_timeout);
325 do {
326 write_time = jiffies;
327 if (at24->use_smbus) {
328 status = i2c_smbus_write_i2c_block_data(client,
329 offset, count, buf);
330 if (status == 0)
331 status = count;
332 } else {
333 status = i2c_transfer(client->adapter, &msg, 1);
334 if (status == 1)
335 status = count;
336 }
337 dev_dbg(&client->dev, "write %zd@%d --> %zd (%ld)\n",
338 count, offset, status, jiffies);
339
340 if (status == count)
341 return count;
342
343 /* REVISIT: at HZ=100, this is sloooow */
344 msleep(1);
345 } while (time_before(write_time, timeout));
346
347 return -ETIMEDOUT;
348}
349
350static ssize_t at24_bin_write(struct kobject *kobj, struct bin_attribute *attr,
351 char *buf, loff_t off, size_t count)
352{
353 struct at24_data *at24;
354 ssize_t retval = 0;
355
356 at24 = dev_get_drvdata(container_of(kobj, struct device, kobj));
357
358 if (unlikely(!count))
359 return count;
360
361 /*
362 * Write data to chip, protecting against concurrent updates
363 * from this host, but not from other I2C masters.
364 */
365 mutex_lock(&at24->lock);
366
367 while (count) {
368 ssize_t status;
369
370 status = at24_eeprom_write(at24, buf, off, count);
371 if (status <= 0) {
372 if (retval == 0)
373 retval = status;
374 break;
375 }
376 buf += status;
377 off += status;
378 count -= status;
379 retval += status;
380 }
381
382 mutex_unlock(&at24->lock);
383
384 return retval;
385}
386
387/*-------------------------------------------------------------------------*/
388
389static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id)
390{
391 struct at24_platform_data chip;
392 bool writable;
393 bool use_smbus = false;
394 struct at24_data *at24;
395 int err;
396 unsigned i, num_addresses;
397 kernel_ulong_t magic;
398
399 if (client->dev.platform_data) {
400 chip = *(struct at24_platform_data *)client->dev.platform_data;
401 } else {
402 if (!id->driver_data) {
403 err = -ENODEV;
404 goto err_out;
405 }
406 magic = id->driver_data;
407 chip.byte_len = BIT(magic & AT24_BITMASK(AT24_SIZE_BYTELEN));
408 magic >>= AT24_SIZE_BYTELEN;
409 chip.flags = magic & AT24_BITMASK(AT24_SIZE_FLAGS);
410 /*
411 * This is slow, but we can't know all eeproms, so we better
412 * play safe. Specifying custom eeprom-types via platform_data
413 * is recommended anyhow.
414 */
415 chip.page_size = 1;
416 }
417
418 if (!is_power_of_2(chip.byte_len))
419 dev_warn(&client->dev,
420 "byte_len looks suspicious (no power of 2)!\n");
421 if (!is_power_of_2(chip.page_size))
422 dev_warn(&client->dev,
423 "page_size looks suspicious (no power of 2)!\n");
424
425 /* Use I2C operations unless we're stuck with SMBus extensions. */
426 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
427 if (chip.flags & AT24_FLAG_ADDR16) {
428 err = -EPFNOSUPPORT;
429 goto err_out;
430 }
431 if (!i2c_check_functionality(client->adapter,
432 I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
433 err = -EPFNOSUPPORT;
434 goto err_out;
435 }
436 use_smbus = true;
437 }
438
439 if (chip.flags & AT24_FLAG_TAKE8ADDR)
440 num_addresses = 8;
441 else
442 num_addresses = DIV_ROUND_UP(chip.byte_len,
443 (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
444
445 at24 = kzalloc(sizeof(struct at24_data) +
446 num_addresses * sizeof(struct i2c_client *), GFP_KERNEL);
447 if (!at24) {
448 err = -ENOMEM;
449 goto err_out;
450 }
451
452 mutex_init(&at24->lock);
453 at24->use_smbus = use_smbus;
454 at24->chip = chip;
455 at24->num_addresses = num_addresses;
456
457 /*
458 * Export the EEPROM bytes through sysfs, since that's convenient.
459 * By default, only root should see the data (maybe passwords etc)
460 */
461 at24->bin.attr.name = "eeprom";
462 at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
463 at24->bin.attr.owner = THIS_MODULE;
464 at24->bin.read = at24_bin_read;
465 at24->bin.size = chip.byte_len;
466
467 writable = !(chip.flags & AT24_FLAG_READONLY);
468 if (writable) {
469 if (!use_smbus || i2c_check_functionality(client->adapter,
470 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) {
471
472 unsigned write_max = chip.page_size;
473
474 at24->bin.write = at24_bin_write;
475 at24->bin.attr.mode |= S_IWUSR;
476
477 if (write_max > io_limit)
478 write_max = io_limit;
479 if (use_smbus && write_max > I2C_SMBUS_BLOCK_MAX)
480 write_max = I2C_SMBUS_BLOCK_MAX;
481 at24->write_max = write_max;
482
483 /* buffer (data + address at the beginning) */
484 at24->writebuf = kmalloc(write_max + 2, GFP_KERNEL);
485 if (!at24->writebuf) {
486 err = -ENOMEM;
487 goto err_struct;
488 }
489 } else {
490 dev_warn(&client->dev,
491 "cannot write due to controller restrictions.");
492 }
493 }
494
495 at24->client[0] = client;
496
497 /* use dummy devices for multiple-address chips */
498 for (i = 1; i < num_addresses; i++) {
499 at24->client[i] = i2c_new_dummy(client->adapter,
500 client->addr + i);
501 if (!at24->client[i]) {
502 dev_err(&client->dev, "address 0x%02x unavailable\n",
503 client->addr + i);
504 err = -EADDRINUSE;
505 goto err_clients;
506 }
507 }
508
509 err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);
510 if (err)
511 goto err_clients;
512
513 i2c_set_clientdata(client, at24);
514
515 dev_info(&client->dev, "%Zd byte %s EEPROM %s\n",
516 at24->bin.size, client->name,
517 writable ? "(writable)" : "(read-only)");
518 dev_dbg(&client->dev,
519 "page_size %d, num_addresses %d, write_max %d%s\n",
520 chip.page_size, num_addresses,
521 at24->write_max,
522 use_smbus ? ", use_smbus" : "");
523
524 return 0;
525
526err_clients:
527 for (i = 1; i < num_addresses; i++)
528 if (at24->client[i])
529 i2c_unregister_device(at24->client[i]);
530
531 kfree(at24->writebuf);
532err_struct:
533 kfree(at24);
534err_out:
535 dev_dbg(&client->dev, "probe error %d\n", err);
536 return err;
537}
538
539static int __devexit at24_remove(struct i2c_client *client)
540{
541 struct at24_data *at24;
542 int i;
543
544 at24 = i2c_get_clientdata(client);
545 sysfs_remove_bin_file(&client->dev.kobj, &at24->bin);
546
547 for (i = 1; i < at24->num_addresses; i++)
548 i2c_unregister_device(at24->client[i]);
549
550 kfree(at24->writebuf);
551 kfree(at24);
552 i2c_set_clientdata(client, NULL);
553 return 0;
554}
555
556/*-------------------------------------------------------------------------*/
557
558static struct i2c_driver at24_driver = {
559 .driver = {
560 .name = "at24",
561 .owner = THIS_MODULE,
562 },
563 .probe = at24_probe,
564 .remove = __devexit_p(at24_remove),
565 .id_table = at24_ids,
566};
567
568static int __init at24_init(void)
569{
570 io_limit = rounddown_pow_of_two(io_limit);
571 return i2c_add_driver(&at24_driver);
572}
573module_init(at24_init);
574
575static void __exit at24_exit(void)
576{
577 i2c_del_driver(&at24_driver);
578}
579module_exit(at24_exit);
580
581MODULE_DESCRIPTION("Driver for most I2C EEPROMs");
582MODULE_AUTHOR("David Brownell and Wolfram Sang");
583MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 7dee001e513..373ea8d8fe8 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -1,15 +1,9 @@
1/* 1/*
2 eeprom.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (C) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and 2 Copyright (C) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
5 Philip Edelbrock <phil@netroedge.com> 3 Philip Edelbrock <phil@netroedge.com>
6 Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com> 4 Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
7 Copyright (C) 2003 IBM Corp. 5 Copyright (C) 2003 IBM Corp.
8 6 Copyright (C) 2004 Jean Delvare <khali@linux-fr.org>
9 2004-01-16 Jean Delvare <khali@linux-fr.org>
10 Divide the eeprom in 32-byte (arbitrary) slices. This significantly
11 speeds sensors up, as well as various scripts using the eeprom
12 module.
13 7
14 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
15 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
@@ -78,7 +72,7 @@ static struct i2c_driver eeprom_driver = {
78static void eeprom_update_client(struct i2c_client *client, u8 slice) 72static void eeprom_update_client(struct i2c_client *client, u8 slice)
79{ 73{
80 struct eeprom_data *data = i2c_get_clientdata(client); 74 struct eeprom_data *data = i2c_get_clientdata(client);
81 int i, j; 75 int i;
82 76
83 mutex_lock(&data->update_lock); 77 mutex_lock(&data->update_lock);
84 78
@@ -93,15 +87,12 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
93 != 32) 87 != 32)
94 goto exit; 88 goto exit;
95 } else { 89 } else {
96 if (i2c_smbus_write_byte(client, slice << 5)) { 90 for (i = slice << 5; i < (slice + 1) << 5; i += 2) {
97 dev_dbg(&client->dev, "eeprom read start has failed!\n"); 91 int word = i2c_smbus_read_word_data(client, i);
98 goto exit; 92 if (word < 0)
99 }
100 for (i = slice << 5; i < (slice + 1) << 5; i++) {
101 j = i2c_smbus_read_byte(client);
102 if (j < 0)
103 goto exit; 93 goto exit;
104 data->data[i] = (u8) j; 94 data->data[i] = word & 0xff;
95 data->data[i + 1] = word >> 8;
105 } 96 }
106 } 97 }
107 data->last_updated[slice] = jiffies; 98 data->last_updated[slice] = jiffies;
@@ -159,24 +150,33 @@ static struct bin_attribute eeprom_attr = {
159 150
160static int eeprom_attach_adapter(struct i2c_adapter *adapter) 151static int eeprom_attach_adapter(struct i2c_adapter *adapter)
161{ 152{
153 if (!(adapter->class & (I2C_CLASS_DDC | I2C_CLASS_SPD)))
154 return 0;
162 return i2c_probe(adapter, &addr_data, eeprom_detect); 155 return i2c_probe(adapter, &addr_data, eeprom_detect);
163} 156}
164 157
165/* This function is called by i2c_probe */ 158/* This function is called by i2c_probe */
166static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind) 159static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
167{ 160{
168 struct i2c_client *new_client; 161 struct i2c_client *client;
169 struct eeprom_data *data; 162 struct eeprom_data *data;
170 int err = 0; 163 int err = 0;
171 164
172 /* There are three ways we can read the EEPROM data: 165 /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all
166 addresses 0x50-0x57, but we only care about 0x50. So decline
167 attaching to addresses >= 0x51 on DDC buses */
168 if (!(adapter->class & I2C_CLASS_SPD) && address >= 0x51)
169 goto exit;
170
171 /* There are four ways we can read the EEPROM data:
173 (1) I2C block reads (faster, but unsupported by most adapters) 172 (1) I2C block reads (faster, but unsupported by most adapters)
174 (2) Consecutive byte reads (100% overhead) 173 (2) Word reads (128% overhead)
175 (3) Regular byte data reads (200% overhead) 174 (3) Consecutive byte reads (88% overhead, unsafe)
176 The third method is not implemented by this driver because all 175 (4) Regular byte data reads (265% overhead)
177 known adapters support at least the second. */ 176 The third and fourth methods are not implemented by this driver
178 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA 177 because all known adapters support one of the first two. */
179 | I2C_FUNC_SMBUS_BYTE)) 178 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA)
179 && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK))
180 goto exit; 180 goto exit;
181 181
182 if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { 182 if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
@@ -184,50 +184,49 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
184 goto exit; 184 goto exit;
185 } 185 }
186 186
187 new_client = &data->client; 187 client = &data->client;
188 memset(data->data, 0xff, EEPROM_SIZE); 188 memset(data->data, 0xff, EEPROM_SIZE);
189 i2c_set_clientdata(new_client, data); 189 i2c_set_clientdata(client, data);
190 new_client->addr = address; 190 client->addr = address;
191 new_client->adapter = adapter; 191 client->adapter = adapter;
192 new_client->driver = &eeprom_driver; 192 client->driver = &eeprom_driver;
193 new_client->flags = 0;
194 193
195 /* Fill in the remaining client fields */ 194 /* Fill in the remaining client fields */
196 strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE); 195 strlcpy(client->name, "eeprom", I2C_NAME_SIZE);
197 data->valid = 0;
198 mutex_init(&data->update_lock); 196 mutex_init(&data->update_lock);
199 data->nature = UNKNOWN; 197 data->nature = UNKNOWN;
200 198
201 /* Tell the I2C layer a new client has arrived */ 199 /* Tell the I2C layer a new client has arrived */
202 if ((err = i2c_attach_client(new_client))) 200 if ((err = i2c_attach_client(client)))
203 goto exit_kfree; 201 goto exit_kfree;
204 202
205 /* Detect the Vaio nature of EEPROMs. 203 /* Detect the Vaio nature of EEPROMs.
206 We use the "PCG-" or "VGN-" prefix as the signature. */ 204 We use the "PCG-" or "VGN-" prefix as the signature. */
207 if (address == 0x57) { 205 if (address == 0x57
206 && i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE_DATA)) {
208 char name[4]; 207 char name[4];
209 208
210 name[0] = i2c_smbus_read_byte_data(new_client, 0x80); 209 name[0] = i2c_smbus_read_byte_data(client, 0x80);
211 name[1] = i2c_smbus_read_byte(new_client); 210 name[1] = i2c_smbus_read_byte_data(client, 0x81);
212 name[2] = i2c_smbus_read_byte(new_client); 211 name[2] = i2c_smbus_read_byte_data(client, 0x82);
213 name[3] = i2c_smbus_read_byte(new_client); 212 name[3] = i2c_smbus_read_byte_data(client, 0x83);
214 213
215 if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) { 214 if (!memcmp(name, "PCG-", 4) || !memcmp(name, "VGN-", 4)) {
216 dev_info(&new_client->dev, "Vaio EEPROM detected, " 215 dev_info(&client->dev, "Vaio EEPROM detected, "
217 "enabling privacy protection\n"); 216 "enabling privacy protection\n");
218 data->nature = VAIO; 217 data->nature = VAIO;
219 } 218 }
220 } 219 }
221 220
222 /* create the sysfs eeprom file */ 221 /* create the sysfs eeprom file */
223 err = sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr); 222 err = sysfs_create_bin_file(&client->dev.kobj, &eeprom_attr);
224 if (err) 223 if (err)
225 goto exit_detach; 224 goto exit_detach;
226 225
227 return 0; 226 return 0;
228 227
229exit_detach: 228exit_detach:
230 i2c_detach_client(new_client); 229 i2c_detach_client(client);
231exit_kfree: 230exit_kfree:
232 kfree(data); 231 kfree(data);
233exit: 232exit:
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index cf507b3f60f..5a0285d8b6f 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -170,7 +170,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
170 struct i2c_client *real_client; 170 struct i2c_client *real_client;
171 struct i2c_client *fake_client; 171 struct i2c_client *fake_client;
172 struct max6875_data *data; 172 struct max6875_data *data;
173 int err = 0; 173 int err;
174 174
175 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA 175 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA
176 | I2C_FUNC_SMBUS_READ_BYTE)) 176 | I2C_FUNC_SMBUS_READ_BYTE))
@@ -195,7 +195,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
195 real_client->addr = address; 195 real_client->addr = address;
196 real_client->adapter = adapter; 196 real_client->adapter = adapter;
197 real_client->driver = &max6875_driver; 197 real_client->driver = &max6875_driver;
198 real_client->flags = 0;
199 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE); 198 strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
200 mutex_init(&data->update_lock); 199 mutex_init(&data->update_lock);
201 200
@@ -204,7 +203,6 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
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;
207 fake_client->flags = 0;
208 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE); 206 strlcpy(fake_client->name, "max6875 subclient", I2C_NAME_SIZE);
209 207
210 if ((err = i2c_attach_client(real_client)) != 0) 208 if ((err = i2c_attach_client(real_client)) != 0)
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index f43c4e79b55..58ab7f26be2 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -113,7 +113,7 @@ static int pca9539_attach_adapter(struct i2c_adapter *adapter)
113/* This function is called by i2c_probe */ 113/* This function is called by i2c_probe */
114static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind) 114static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
115{ 115{
116 struct i2c_client *new_client; 116 struct i2c_client *client;
117 struct pca9539_data *data; 117 struct pca9539_data *data;
118 int err = 0; 118 int err = 0;
119 119
@@ -127,29 +127,28 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
127 goto exit; 127 goto exit;
128 } 128 }
129 129
130 new_client = &data->client; 130 client = &data->client;
131 i2c_set_clientdata(new_client, data); 131 i2c_set_clientdata(client, data);
132 new_client->addr = address; 132 client->addr = address;
133 new_client->adapter = adapter; 133 client->adapter = adapter;
134 new_client->driver = &pca9539_driver; 134 client->driver = &pca9539_driver;
135 new_client->flags = 0;
136 135
137 if (kind < 0) { 136 if (kind < 0) {
138 /* Detection: the pca9539 only has 8 registers (0-7). 137 /* Detection: the pca9539 only has 8 registers (0-7).
139 A read of 7 should succeed, but a read of 8 should fail. */ 138 A read of 7 should succeed, but a read of 8 should fail. */
140 if ((i2c_smbus_read_byte_data(new_client, 7) < 0) || 139 if ((i2c_smbus_read_byte_data(client, 7) < 0) ||
141 (i2c_smbus_read_byte_data(new_client, 8) >= 0)) 140 (i2c_smbus_read_byte_data(client, 8) >= 0))
142 goto exit_kfree; 141 goto exit_kfree;
143 } 142 }
144 143
145 strlcpy(new_client->name, "pca9539", I2C_NAME_SIZE); 144 strlcpy(client->name, "pca9539", I2C_NAME_SIZE);
146 145
147 /* Tell the I2C layer a new client has arrived */ 146 /* Tell the I2C layer a new client has arrived */
148 if ((err = i2c_attach_client(new_client))) 147 if ((err = i2c_attach_client(client)))
149 goto exit_kfree; 148 goto exit_kfree;
150 149
151 /* Register sysfs hooks */ 150 /* Register sysfs hooks */
152 err = sysfs_create_group(&new_client->dev.kobj, 151 err = sysfs_create_group(&client->dev.kobj,
153 &pca9539_defattr_group); 152 &pca9539_defattr_group);
154 if (err) 153 if (err)
155 goto exit_detach; 154 goto exit_detach;
@@ -157,7 +156,7 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
157 return 0; 156 return 0;
158 157
159exit_detach: 158exit_detach:
160 i2c_detach_client(new_client); 159 i2c_detach_client(client);
161exit_kfree: 160exit_kfree:
162 kfree(data); 161 kfree(data);
163exit: 162exit:
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index e5b31329b56..1b3db2b3ada 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -1,6 +1,4 @@
1/* 1/*
2 pcf8574.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>, 2 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>,
5 Philip Edelbrock <phil@netroedge.com>, 3 Philip Edelbrock <phil@netroedge.com>,
6 Dan Eaton <dan.eaton@rocketlogix.com> 4 Dan Eaton <dan.eaton@rocketlogix.com>
@@ -129,7 +127,7 @@ static int pcf8574_attach_adapter(struct i2c_adapter *adapter)
129/* This function is called by i2c_probe */ 127/* This function is called by i2c_probe */
130static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind) 128static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
131{ 129{
132 struct i2c_client *new_client; 130 struct i2c_client *client;
133 struct pcf8574_data *data; 131 struct pcf8574_data *data;
134 int err = 0; 132 int err = 0;
135 const char *client_name = ""; 133 const char *client_name = "";
@@ -144,12 +142,11 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
144 goto exit; 142 goto exit;
145 } 143 }
146 144
147 new_client = &data->client; 145 client = &data->client;
148 i2c_set_clientdata(new_client, data); 146 i2c_set_clientdata(client, data);
149 new_client->addr = address; 147 client->addr = address;
150 new_client->adapter = adapter; 148 client->adapter = adapter;
151 new_client->driver = &pcf8574_driver; 149 client->driver = &pcf8574_driver;
152 new_client->flags = 0;
153 150
154 /* Now, we would do the remaining detection. But the PCF8574 is plainly 151 /* Now, we would do the remaining detection. But the PCF8574 is plainly
155 impossible to detect! Stupid chip. */ 152 impossible to detect! Stupid chip. */
@@ -168,23 +165,23 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
168 client_name = "pcf8574"; 165 client_name = "pcf8574";
169 166
170 /* Fill in the remaining client fields and put it into the global list */ 167 /* Fill in the remaining client fields and put it into the global list */
171 strlcpy(new_client->name, client_name, I2C_NAME_SIZE); 168 strlcpy(client->name, client_name, I2C_NAME_SIZE);
172 169
173 /* Tell the I2C layer a new client has arrived */ 170 /* Tell the I2C layer a new client has arrived */
174 if ((err = i2c_attach_client(new_client))) 171 if ((err = i2c_attach_client(client)))
175 goto exit_free; 172 goto exit_free;
176 173
177 /* Initialize the PCF8574 chip */ 174 /* Initialize the PCF8574 chip */
178 pcf8574_init_client(new_client); 175 pcf8574_init_client(client);
179 176
180 /* Register sysfs hooks */ 177 /* Register sysfs hooks */
181 err = sysfs_create_group(&new_client->dev.kobj, &pcf8574_attr_group); 178 err = sysfs_create_group(&client->dev.kobj, &pcf8574_attr_group);
182 if (err) 179 if (err)
183 goto exit_detach; 180 goto exit_detach;
184 return 0; 181 return 0;
185 182
186 exit_detach: 183 exit_detach:
187 i2c_detach_client(new_client); 184 i2c_detach_client(client);
188 exit_free: 185 exit_free:
189 kfree(data); 186 kfree(data);
190 exit: 187 exit:
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 66c7c3bb942..db735379f22 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -1,6 +1,4 @@
1/* 1/*
2 pcf8591.c - Part of lm_sensors, Linux kernel modules for hardware
3 monitoring
4 Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net> 2 Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net>
5 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with 3 Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
6 the help of Jean Delvare <khali@linux-fr.org> 4 the help of Jean Delvare <khali@linux-fr.org>
@@ -190,7 +188,7 @@ static int pcf8591_attach_adapter(struct i2c_adapter *adapter)
190/* This function is called by i2c_probe */ 188/* This function is called by i2c_probe */
191static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind) 189static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
192{ 190{
193 struct i2c_client *new_client; 191 struct i2c_client *client;
194 struct pcf8591_data *data; 192 struct pcf8591_data *data;
195 int err = 0; 193 int err = 0;
196 194
@@ -205,12 +203,11 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
205 goto exit; 203 goto exit;
206 } 204 }
207 205
208 new_client = &data->client; 206 client = &data->client;
209 i2c_set_clientdata(new_client, data); 207 i2c_set_clientdata(client, data);
210 new_client->addr = address; 208 client->addr = address;
211 new_client->adapter = adapter; 209 client->adapter = adapter;
212 new_client->driver = &pcf8591_driver; 210 client->driver = &pcf8591_driver;
213 new_client->flags = 0;
214 211
215 /* Now, we would do the remaining detection. But the PCF8591 is plainly 212 /* Now, we would do the remaining detection. But the PCF8591 is plainly
216 impossible to detect! Stupid chip. */ 213 impossible to detect! Stupid chip. */
@@ -221,31 +218,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
221 218
222 /* Fill in the remaining client fields and put it into the global 219 /* Fill in the remaining client fields and put it into the global
223 list */ 220 list */
224 strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE); 221 strlcpy(client->name, "pcf8591", I2C_NAME_SIZE);
225 mutex_init(&data->update_lock); 222 mutex_init(&data->update_lock);
226 223
227 /* Tell the I2C layer a new client has arrived */ 224 /* Tell the I2C layer a new client has arrived */
228 if ((err = i2c_attach_client(new_client))) 225 if ((err = i2c_attach_client(client)))
229 goto exit_kfree; 226 goto exit_kfree;
230 227
231 /* Initialize the PCF8591 chip */ 228 /* Initialize the PCF8591 chip */
232 pcf8591_init_client(new_client); 229 pcf8591_init_client(client);
233 230
234 /* Register sysfs hooks */ 231 /* Register sysfs hooks */
235 err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group); 232 err = sysfs_create_group(&client->dev.kobj, &pcf8591_attr_group);
236 if (err) 233 if (err)
237 goto exit_detach; 234 goto exit_detach;
238 235
239 /* Register input2 if not in "two differential inputs" mode */ 236 /* Register input2 if not in "two differential inputs" mode */
240 if (input_mode != 3) { 237 if (input_mode != 3) {
241 if ((err = device_create_file(&new_client->dev, 238 if ((err = device_create_file(&client->dev,
242 &dev_attr_in2_input))) 239 &dev_attr_in2_input)))
243 goto exit_sysfs_remove; 240 goto exit_sysfs_remove;
244 } 241 }
245 242
246 /* Register input3 only in "four single ended inputs" mode */ 243 /* Register input3 only in "four single ended inputs" mode */
247 if (input_mode == 0) { 244 if (input_mode == 0) {
248 if ((err = device_create_file(&new_client->dev, 245 if ((err = device_create_file(&client->dev,
249 &dev_attr_in3_input))) 246 &dev_attr_in3_input)))
250 goto exit_sysfs_remove; 247 goto exit_sysfs_remove;
251 } 248 }
@@ -253,10 +250,10 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
253 return 0; 250 return 0;
254 251
255exit_sysfs_remove: 252exit_sysfs_remove:
256 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt); 253 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt);
257 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group); 254 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group);
258exit_detach: 255exit_detach:
259 i2c_detach_client(new_client); 256 i2c_detach_client(client);
260exit_kfree: 257exit_kfree:
261 kfree(data); 258 kfree(data);
262exit: 259exit:
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index d0175f4f8fc..0a79f766101 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -29,13 +29,11 @@
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/idr.h> 31#include <linux/idr.h>
32#include <linux/seq_file.h>
33#include <linux/platform_device.h> 32#include <linux/platform_device.h>
34#include <linux/mutex.h> 33#include <linux/mutex.h>
35#include <linux/completion.h> 34#include <linux/completion.h>
36#include <linux/hardirq.h> 35#include <linux/hardirq.h>
37#include <linux/irqflags.h> 36#include <linux/irqflags.h>
38#include <linux/semaphore.h>
39#include <asm/uaccess.h> 37#include <asm/uaccess.h>
40 38
41#include "i2c-core.h" 39#include "i2c-core.h"
@@ -44,7 +42,9 @@
44static DEFINE_MUTEX(core_lock); 42static DEFINE_MUTEX(core_lock);
45static DEFINE_IDR(i2c_adapter_idr); 43static DEFINE_IDR(i2c_adapter_idr);
46 44
47#define is_newstyle_driver(d) ((d)->probe || (d)->remove) 45#define is_newstyle_driver(d) ((d)->probe || (d)->remove || (d)->detect)
46
47static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
48 48
49/* ------------------------------------------------------------------------- */ 49/* ------------------------------------------------------------------------- */
50 50
@@ -103,19 +103,14 @@ static int i2c_device_probe(struct device *dev)
103{ 103{
104 struct i2c_client *client = to_i2c_client(dev); 104 struct i2c_client *client = to_i2c_client(dev);
105 struct i2c_driver *driver = to_i2c_driver(dev->driver); 105 struct i2c_driver *driver = to_i2c_driver(dev->driver);
106 const struct i2c_device_id *id;
107 int status; 106 int status;
108 107
109 if (!driver->probe) 108 if (!driver->probe || !driver->id_table)
110 return -ENODEV; 109 return -ENODEV;
111 client->driver = driver; 110 client->driver = driver;
112 dev_dbg(dev, "probe\n"); 111 dev_dbg(dev, "probe\n");
113 112
114 if (driver->id_table) 113 status = driver->probe(client, i2c_match_id(driver->id_table, client));
115 id = i2c_match_id(driver->id_table, client);
116 else
117 id = NULL;
118 status = driver->probe(client, id);
119 if (status) 114 if (status)
120 client->driver = NULL; 115 client->driver = NULL;
121 return status; 116 return status;
@@ -208,7 +203,7 @@ static struct device_attribute i2c_dev_attrs[] = {
208 { }, 203 { },
209}; 204};
210 205
211static struct bus_type i2c_bus_type = { 206struct bus_type i2c_bus_type = {
212 .name = "i2c", 207 .name = "i2c",
213 .dev_attrs = i2c_dev_attrs, 208 .dev_attrs = i2c_dev_attrs,
214 .match = i2c_device_match, 209 .match = i2c_device_match,
@@ -219,6 +214,7 @@ static struct bus_type i2c_bus_type = {
219 .suspend = i2c_device_suspend, 214 .suspend = i2c_device_suspend,
220 .resume = i2c_device_resume, 215 .resume = i2c_device_resume,
221}; 216};
217EXPORT_SYMBOL_GPL(i2c_bus_type);
222 218
223 219
224/** 220/**
@@ -306,6 +302,14 @@ void i2c_unregister_device(struct i2c_client *client)
306 return; 302 return;
307 } 303 }
308 304
305 if (adapter->client_unregister) {
306 if (adapter->client_unregister(client)) {
307 dev_warn(&client->dev,
308 "client_unregister [%s] failed\n",
309 client->name);
310 }
311 }
312
309 mutex_lock(&adapter->clist_lock); 313 mutex_lock(&adapter->clist_lock);
310 list_del(&client->list); 314 list_del(&client->list);
311 mutex_unlock(&adapter->clist_lock); 315 mutex_unlock(&adapter->clist_lock);
@@ -416,6 +420,10 @@ static int i2c_do_add_adapter(struct device_driver *d, void *data)
416 struct i2c_driver *driver = to_i2c_driver(d); 420 struct i2c_driver *driver = to_i2c_driver(d);
417 struct i2c_adapter *adap = data; 421 struct i2c_adapter *adap = data;
418 422
423 /* Detect supported devices on that bus, and instantiate them */
424 i2c_detect(adap, driver);
425
426 /* Let legacy drivers scan this bus for matching devices */
419 if (driver->attach_adapter) { 427 if (driver->attach_adapter) {
420 /* We ignore the return code; if it fails, too bad */ 428 /* We ignore the return code; if it fails, too bad */
421 driver->attach_adapter(adap); 429 driver->attach_adapter(adap);
@@ -455,7 +463,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
455 if (adap->nr < __i2c_first_dynamic_bus_num) 463 if (adap->nr < __i2c_first_dynamic_bus_num)
456 i2c_scan_static_board_info(adap); 464 i2c_scan_static_board_info(adap);
457 465
458 /* let legacy drivers scan this bus for matching devices */ 466 /* Notify drivers */
459 dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap, 467 dummy = bus_for_each_drv(&i2c_bus_type, NULL, adap,
460 i2c_do_add_adapter); 468 i2c_do_add_adapter);
461 469
@@ -561,8 +569,19 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data)
561{ 569{
562 struct i2c_driver *driver = to_i2c_driver(d); 570 struct i2c_driver *driver = to_i2c_driver(d);
563 struct i2c_adapter *adapter = data; 571 struct i2c_adapter *adapter = data;
572 struct i2c_client *client, *_n;
564 int res; 573 int res;
565 574
575 /* Remove the devices we created ourselves */
576 list_for_each_entry_safe(client, _n, &driver->clients, detected) {
577 if (client->adapter == adapter) {
578 dev_dbg(&adapter->dev, "Removing %s at 0x%x\n",
579 client->name, client->addr);
580 list_del(&client->detected);
581 i2c_unregister_device(client);
582 }
583 }
584
566 if (!driver->detach_adapter) 585 if (!driver->detach_adapter)
567 return 0; 586 return 0;
568 res = driver->detach_adapter(adapter); 587 res = driver->detach_adapter(adapter);
@@ -582,8 +601,7 @@ static int i2c_do_del_adapter(struct device_driver *d, void *data)
582 */ 601 */
583int i2c_del_adapter(struct i2c_adapter *adap) 602int i2c_del_adapter(struct i2c_adapter *adap)
584{ 603{
585 struct list_head *item, *_n; 604 struct i2c_client *client, *_n;
586 struct i2c_client *client;
587 int res = 0; 605 int res = 0;
588 606
589 mutex_lock(&core_lock); 607 mutex_lock(&core_lock);
@@ -604,10 +622,9 @@ int i2c_del_adapter(struct i2c_adapter *adap)
604 622
605 /* detach any active clients. This must be done first, because 623 /* detach any active clients. This must be done first, because
606 * it can fail; in which case we give up. */ 624 * it can fail; in which case we give up. */
607 list_for_each_safe(item, _n, &adap->clients) { 625 list_for_each_entry_safe(client, _n, &adap->clients, list) {
608 struct i2c_driver *driver; 626 struct i2c_driver *driver;
609 627
610 client = list_entry(item, struct i2c_client, list);
611 driver = client->driver; 628 driver = client->driver;
612 629
613 /* new style, follow standard driver model */ 630 /* new style, follow standard driver model */
@@ -646,6 +663,20 @@ EXPORT_SYMBOL(i2c_del_adapter);
646 663
647/* ------------------------------------------------------------------------- */ 664/* ------------------------------------------------------------------------- */
648 665
666static int __attach_adapter(struct device *dev, void *data)
667{
668 struct i2c_adapter *adapter = to_i2c_adapter(dev);
669 struct i2c_driver *driver = data;
670
671 i2c_detect(adapter, driver);
672
673 /* Legacy drivers scan i2c busses directly */
674 if (driver->attach_adapter)
675 driver->attach_adapter(adapter);
676
677 return 0;
678}
679
649/* 680/*
650 * An i2c_driver is used with one or more i2c_client (device) nodes to access 681 * An i2c_driver is used with one or more i2c_client (device) nodes to access
651 * i2c slave chips, on a bus instance associated with some i2c_adapter. There 682 * i2c slave chips, on a bus instance associated with some i2c_adapter. There
@@ -685,72 +716,70 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
685 716
686 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name); 717 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
687 718
688 /* legacy drivers scan i2c busses directly */ 719 INIT_LIST_HEAD(&driver->clients);
689 if (driver->attach_adapter) { 720 /* Walk the adapters that are already present */
690 struct i2c_adapter *adapter; 721 class_for_each_device(&i2c_adapter_class, driver, __attach_adapter);
691
692 down(&i2c_adapter_class.sem);
693 list_for_each_entry(adapter, &i2c_adapter_class.devices,
694 dev.node) {
695 driver->attach_adapter(adapter);
696 }
697 up(&i2c_adapter_class.sem);
698 }
699 722
700 mutex_unlock(&core_lock); 723 mutex_unlock(&core_lock);
701 return 0; 724 return 0;
702} 725}
703EXPORT_SYMBOL(i2c_register_driver); 726EXPORT_SYMBOL(i2c_register_driver);
704 727
705/** 728static int __detach_adapter(struct device *dev, void *data)
706 * i2c_del_driver - unregister I2C driver
707 * @driver: the driver being unregistered
708 * Context: can sleep
709 */
710void i2c_del_driver(struct i2c_driver *driver)
711{ 729{
712 struct list_head *item2, *_n; 730 struct i2c_adapter *adapter = to_i2c_adapter(dev);
713 struct i2c_client *client; 731 struct i2c_driver *driver = data;
714 struct i2c_adapter *adap; 732 struct i2c_client *client, *_n;
715 733
716 mutex_lock(&core_lock); 734 list_for_each_entry_safe(client, _n, &driver->clients, detected) {
735 dev_dbg(&adapter->dev, "Removing %s at 0x%x\n",
736 client->name, client->addr);
737 list_del(&client->detected);
738 i2c_unregister_device(client);
739 }
717 740
718 /* new-style driver? */
719 if (is_newstyle_driver(driver)) 741 if (is_newstyle_driver(driver))
720 goto unregister; 742 return 0;
721 743
722 /* Have a look at each adapter, if clients of this driver are still 744 /* Have a look at each adapter, if clients of this driver are still
723 * attached. If so, detach them to be able to kill the driver 745 * attached. If so, detach them to be able to kill the driver
724 * afterwards. 746 * afterwards.
725 */ 747 */
726 down(&i2c_adapter_class.sem); 748 if (driver->detach_adapter) {
727 list_for_each_entry(adap, &i2c_adapter_class.devices, dev.node) { 749 if (driver->detach_adapter(adapter))
728 if (driver->detach_adapter) { 750 dev_err(&adapter->dev,
729 if (driver->detach_adapter(adap)) { 751 "detach_adapter failed for driver [%s]\n",
730 dev_err(&adap->dev, "detach_adapter failed " 752 driver->driver.name);
731 "for driver [%s]\n", 753 } else {
732 driver->driver.name); 754 struct i2c_client *client, *_n;
733 } 755
734 } else { 756 list_for_each_entry_safe(client, _n, &adapter->clients, list) {
735 list_for_each_safe(item2, _n, &adap->clients) { 757 if (client->driver != driver)
736 client = list_entry(item2, struct i2c_client, list); 758 continue;
737 if (client->driver != driver) 759 dev_dbg(&adapter->dev,
738 continue; 760 "detaching client [%s] at 0x%02x\n",
739 dev_dbg(&adap->dev, "detaching client [%s] " 761 client->name, client->addr);
740 "at 0x%02x\n", client->name, 762 if (driver->detach_client(client))
741 client->addr); 763 dev_err(&adapter->dev, "detach_client "
742 if (driver->detach_client(client)) { 764 "failed for client [%s] at 0x%02x\n",
743 dev_err(&adap->dev, "detach_client " 765 client->name, client->addr);
744 "failed for client [%s] at "
745 "0x%02x\n", client->name,
746 client->addr);
747 }
748 }
749 } 766 }
750 } 767 }
751 up(&i2c_adapter_class.sem);
752 768
753 unregister: 769 return 0;
770}
771
772/**
773 * i2c_del_driver - unregister I2C driver
774 * @driver: the driver being unregistered
775 * Context: can sleep
776 */
777void i2c_del_driver(struct i2c_driver *driver)
778{
779 mutex_lock(&core_lock);
780
781 class_for_each_device(&i2c_adapter_class, driver, __detach_adapter);
782
754 driver_unregister(&driver->driver); 783 driver_unregister(&driver->driver);
755 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name); 784 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
756 785
@@ -863,8 +892,9 @@ EXPORT_SYMBOL(i2c_detach_client);
863 */ 892 */
864struct i2c_client *i2c_use_client(struct i2c_client *client) 893struct i2c_client *i2c_use_client(struct i2c_client *client)
865{ 894{
866 get_device(&client->dev); 895 if (client && get_device(&client->dev))
867 return client; 896 return client;
897 return NULL;
868} 898}
869EXPORT_SYMBOL(i2c_use_client); 899EXPORT_SYMBOL(i2c_use_client);
870 900
@@ -876,7 +906,8 @@ EXPORT_SYMBOL(i2c_use_client);
876 */ 906 */
877void i2c_release_client(struct i2c_client *client) 907void i2c_release_client(struct i2c_client *client)
878{ 908{
879 put_device(&client->dev); 909 if (client)
910 put_device(&client->dev);
880} 911}
881EXPORT_SYMBOL(i2c_release_client); 912EXPORT_SYMBOL(i2c_release_client);
882 913
@@ -942,10 +973,39 @@ module_exit(i2c_exit);
942 * ---------------------------------------------------- 973 * ----------------------------------------------------
943 */ 974 */
944 975
976/**
977 * i2c_transfer - execute a single or combined I2C message
978 * @adap: Handle to I2C bus
979 * @msgs: One or more messages to execute before STOP is issued to
980 * terminate the operation; each message begins with a START.
981 * @num: Number of messages to be executed.
982 *
983 * Returns negative errno, else the number of messages executed.
984 *
985 * Note that there is no requirement that each message be sent to
986 * the same slave address, although that is the most common model.
987 */
945int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) 988int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
946{ 989{
947 int ret; 990 int ret;
948 991
992 /* REVISIT the fault reporting model here is weak:
993 *
994 * - When we get an error after receiving N bytes from a slave,
995 * there is no way to report "N".
996 *
997 * - When we get a NAK after transmitting N bytes to a slave,
998 * there is no way to report "N" ... or to let the master
999 * continue executing the rest of this combined message, if
1000 * that's the appropriate response.
1001 *
1002 * - When for example "num" is two and we successfully complete
1003 * the first message but get an error part way through the
1004 * second, it's unclear whether that should be reported as
1005 * one (discarding status on the second message) or errno
1006 * (discarding status on the first one).
1007 */
1008
949 if (adap->algo->master_xfer) { 1009 if (adap->algo->master_xfer) {
950#ifdef DEBUG 1010#ifdef DEBUG
951 for (ret = 0; ret < num; ret++) { 1011 for (ret = 0; ret < num; ret++) {
@@ -971,11 +1031,19 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
971 return ret; 1031 return ret;
972 } else { 1032 } else {
973 dev_dbg(&adap->dev, "I2C level transfers not supported\n"); 1033 dev_dbg(&adap->dev, "I2C level transfers not supported\n");
974 return -ENOSYS; 1034 return -EOPNOTSUPP;
975 } 1035 }
976} 1036}
977EXPORT_SYMBOL(i2c_transfer); 1037EXPORT_SYMBOL(i2c_transfer);
978 1038
1039/**
1040 * i2c_master_send - issue a single I2C message in master transmit mode
1041 * @client: Handle to slave device
1042 * @buf: Data that will be written to the slave
1043 * @count: How many bytes to write
1044 *
1045 * Returns negative errno, or else the number of bytes written.
1046 */
979int i2c_master_send(struct i2c_client *client,const char *buf ,int count) 1047int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
980{ 1048{
981 int ret; 1049 int ret;
@@ -995,6 +1063,14 @@ int i2c_master_send(struct i2c_client *client,const char *buf ,int count)
995} 1063}
996EXPORT_SYMBOL(i2c_master_send); 1064EXPORT_SYMBOL(i2c_master_send);
997 1065
1066/**
1067 * i2c_master_recv - issue a single I2C message in master receive mode
1068 * @client: Handle to slave device
1069 * @buf: Where to store data read from slave
1070 * @count: How many bytes to read
1071 *
1072 * Returns negative errno, or else the number of bytes read.
1073 */
998int i2c_master_recv(struct i2c_client *client, char *buf ,int count) 1074int i2c_master_recv(struct i2c_client *client, char *buf ,int count)
999{ 1075{
1000 struct i2c_adapter *adap=client->adapter; 1076 struct i2c_adapter *adap=client->adapter;
@@ -1103,7 +1179,7 @@ int i2c_probe(struct i2c_adapter *adapter,
1103 1179
1104 dev_warn(&adapter->dev, "SMBus Quick command not supported, " 1180 dev_warn(&adapter->dev, "SMBus Quick command not supported, "
1105 "can't probe for chips\n"); 1181 "can't probe for chips\n");
1106 return -1; 1182 return -EOPNOTSUPP;
1107 } 1183 }
1108 1184
1109 /* Probe entries are done second, and are not affected by ignore 1185 /* Probe entries are done second, and are not affected by ignore
@@ -1157,6 +1233,179 @@ int i2c_probe(struct i2c_adapter *adapter,
1157} 1233}
1158EXPORT_SYMBOL(i2c_probe); 1234EXPORT_SYMBOL(i2c_probe);
1159 1235
1236/* Separate detection function for new-style drivers */
1237static int i2c_detect_address(struct i2c_client *temp_client, int kind,
1238 struct i2c_driver *driver)
1239{
1240 struct i2c_board_info info;
1241 struct i2c_adapter *adapter = temp_client->adapter;
1242 int addr = temp_client->addr;
1243 int err;
1244
1245 /* Make sure the address is valid */
1246 if (addr < 0x03 || addr > 0x77) {
1247 dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
1248 addr);
1249 return -EINVAL;
1250 }
1251
1252 /* Skip if already in use */
1253 if (i2c_check_addr(adapter, addr))
1254 return 0;
1255
1256 /* Make sure there is something at this address, unless forced */
1257 if (kind < 0) {
1258 if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
1259 I2C_SMBUS_QUICK, NULL) < 0)
1260 return 0;
1261
1262 /* prevent 24RF08 corruption */
1263 if ((addr & ~0x0f) == 0x50)
1264 i2c_smbus_xfer(adapter, addr, 0, 0, 0,
1265 I2C_SMBUS_QUICK, NULL);
1266 }
1267
1268 /* Finally call the custom detection function */
1269 memset(&info, 0, sizeof(struct i2c_board_info));
1270 info.addr = addr;
1271 err = driver->detect(temp_client, kind, &info);
1272 if (err) {
1273 /* -ENODEV is returned if the detection fails. We catch it
1274 here as this isn't an error. */
1275 return err == -ENODEV ? 0 : err;
1276 }
1277
1278 /* Consistency check */
1279 if (info.type[0] == '\0') {
1280 dev_err(&adapter->dev, "%s detection function provided "
1281 "no name for 0x%x\n", driver->driver.name,
1282 addr);
1283 } else {
1284 struct i2c_client *client;
1285
1286 /* Detection succeeded, instantiate the device */
1287 dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n",
1288 info.type, info.addr);
1289 client = i2c_new_device(adapter, &info);
1290 if (client)
1291 list_add_tail(&client->detected, &driver->clients);
1292 else
1293 dev_err(&adapter->dev, "Failed creating %s at 0x%02x\n",
1294 info.type, info.addr);
1295 }
1296 return 0;
1297}
1298
1299static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
1300{
1301 const struct i2c_client_address_data *address_data;
1302 struct i2c_client *temp_client;
1303 int i, err = 0;
1304 int adap_id = i2c_adapter_id(adapter);
1305
1306 address_data = driver->address_data;
1307 if (!driver->detect || !address_data)
1308 return 0;
1309
1310 /* Set up a temporary client to help detect callback */
1311 temp_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1312 if (!temp_client)
1313 return -ENOMEM;
1314 temp_client->adapter = adapter;
1315
1316 /* Force entries are done first, and are not affected by ignore
1317 entries */
1318 if (address_data->forces) {
1319 const unsigned short * const *forces = address_data->forces;
1320 int kind;
1321
1322 for (kind = 0; forces[kind]; kind++) {
1323 for (i = 0; forces[kind][i] != I2C_CLIENT_END;
1324 i += 2) {
1325 if (forces[kind][i] == adap_id
1326 || forces[kind][i] == ANY_I2C_BUS) {
1327 dev_dbg(&adapter->dev, "found force "
1328 "parameter for adapter %d, "
1329 "addr 0x%02x, kind %d\n",
1330 adap_id, forces[kind][i + 1],
1331 kind);
1332 temp_client->addr = forces[kind][i + 1];
1333 err = i2c_detect_address(temp_client,
1334 kind, driver);
1335 if (err)
1336 goto exit_free;
1337 }
1338 }
1339 }
1340 }
1341
1342 /* Stop here if we can't use SMBUS_QUICK */
1343 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
1344 if (address_data->probe[0] == I2C_CLIENT_END
1345 && address_data->normal_i2c[0] == I2C_CLIENT_END)
1346 goto exit_free;
1347
1348 dev_warn(&adapter->dev, "SMBus Quick command not supported, "
1349 "can't probe for chips\n");
1350 err = -EOPNOTSUPP;
1351 goto exit_free;
1352 }
1353
1354 /* Stop here if the classes do not match */
1355 if (!(adapter->class & driver->class))
1356 goto exit_free;
1357
1358 /* Probe entries are done second, and are not affected by ignore
1359 entries either */
1360 for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) {
1361 if (address_data->probe[i] == adap_id
1362 || address_data->probe[i] == ANY_I2C_BUS) {
1363 dev_dbg(&adapter->dev, "found probe parameter for "
1364 "adapter %d, addr 0x%02x\n", adap_id,
1365 address_data->probe[i + 1]);
1366 temp_client->addr = address_data->probe[i + 1];
1367 err = i2c_detect_address(temp_client, -1, driver);
1368 if (err)
1369 goto exit_free;
1370 }
1371 }
1372
1373 /* Normal entries are done last, unless shadowed by an ignore entry */
1374 for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) {
1375 int j, ignore;
1376
1377 ignore = 0;
1378 for (j = 0; address_data->ignore[j] != I2C_CLIENT_END;
1379 j += 2) {
1380 if ((address_data->ignore[j] == adap_id ||
1381 address_data->ignore[j] == ANY_I2C_BUS)
1382 && address_data->ignore[j + 1]
1383 == address_data->normal_i2c[i]) {
1384 dev_dbg(&adapter->dev, "found ignore "
1385 "parameter for adapter %d, "
1386 "addr 0x%02x\n", adap_id,
1387 address_data->ignore[j + 1]);
1388 ignore = 1;
1389 break;
1390 }
1391 }
1392 if (ignore)
1393 continue;
1394
1395 dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
1396 "addr 0x%02x\n", adap_id,
1397 address_data->normal_i2c[i]);
1398 temp_client->addr = address_data->normal_i2c[i];
1399 err = i2c_detect_address(temp_client, -1, driver);
1400 if (err)
1401 goto exit_free;
1402 }
1403
1404 exit_free:
1405 kfree(temp_client);
1406 return err;
1407}
1408
1160struct i2c_client * 1409struct i2c_client *
1161i2c_new_probed_device(struct i2c_adapter *adap, 1410i2c_new_probed_device(struct i2c_adapter *adap,
1162 struct i2c_board_info *info, 1411 struct i2c_board_info *info,
@@ -1295,29 +1544,38 @@ static int i2c_smbus_check_pec(u8 cpec, struct i2c_msg *msg)
1295 if (rpec != cpec) { 1544 if (rpec != cpec) {
1296 pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n", 1545 pr_debug("i2c-core: Bad PEC 0x%02x vs. 0x%02x\n",
1297 rpec, cpec); 1546 rpec, cpec);
1298 return -1; 1547 return -EBADMSG;
1299 } 1548 }
1300 return 0; 1549 return 0;
1301} 1550}
1302 1551
1303s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value) 1552/**
1304{ 1553 * i2c_smbus_read_byte - SMBus "receive byte" protocol
1305 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1554 * @client: Handle to slave device
1306 value,0,I2C_SMBUS_QUICK,NULL); 1555 *
1307} 1556 * This executes the SMBus "receive byte" protocol, returning negative errno
1308EXPORT_SYMBOL(i2c_smbus_write_quick); 1557 * else the byte received from the device.
1309 1558 */
1310s32 i2c_smbus_read_byte(struct i2c_client *client) 1559s32 i2c_smbus_read_byte(struct i2c_client *client)
1311{ 1560{
1312 union i2c_smbus_data data; 1561 union i2c_smbus_data data;
1313 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1562 int status;
1314 I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data)) 1563
1315 return -1; 1564 status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1316 else 1565 I2C_SMBUS_READ, 0,
1317 return data.byte; 1566 I2C_SMBUS_BYTE, &data);
1567 return (status < 0) ? status : data.byte;
1318} 1568}
1319EXPORT_SYMBOL(i2c_smbus_read_byte); 1569EXPORT_SYMBOL(i2c_smbus_read_byte);
1320 1570
1571/**
1572 * i2c_smbus_write_byte - SMBus "send byte" protocol
1573 * @client: Handle to slave device
1574 * @value: Byte to be sent
1575 *
1576 * This executes the SMBus "send byte" protocol, returning negative errno
1577 * else zero on success.
1578 */
1321s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 1579s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
1322{ 1580{
1323 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1581 return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
@@ -1325,17 +1583,35 @@ s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
1325} 1583}
1326EXPORT_SYMBOL(i2c_smbus_write_byte); 1584EXPORT_SYMBOL(i2c_smbus_write_byte);
1327 1585
1586/**
1587 * i2c_smbus_read_byte_data - SMBus "read byte" protocol
1588 * @client: Handle to slave device
1589 * @command: Byte interpreted by slave
1590 *
1591 * This executes the SMBus "read byte" protocol, returning negative errno
1592 * else a data byte received from the device.
1593 */
1328s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command) 1594s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command)
1329{ 1595{
1330 union i2c_smbus_data data; 1596 union i2c_smbus_data data;
1331 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1597 int status;
1332 I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data)) 1598
1333 return -1; 1599 status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1334 else 1600 I2C_SMBUS_READ, command,
1335 return data.byte; 1601 I2C_SMBUS_BYTE_DATA, &data);
1602 return (status < 0) ? status : data.byte;
1336} 1603}
1337EXPORT_SYMBOL(i2c_smbus_read_byte_data); 1604EXPORT_SYMBOL(i2c_smbus_read_byte_data);
1338 1605
1606/**
1607 * i2c_smbus_write_byte_data - SMBus "write byte" protocol
1608 * @client: Handle to slave device
1609 * @command: Byte interpreted by slave
1610 * @value: Byte being written
1611 *
1612 * This executes the SMBus "write byte" protocol, returning negative errno
1613 * else zero on success.
1614 */
1339s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) 1615s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
1340{ 1616{
1341 union i2c_smbus_data data; 1617 union i2c_smbus_data data;
@@ -1346,17 +1622,35 @@ s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
1346} 1622}
1347EXPORT_SYMBOL(i2c_smbus_write_byte_data); 1623EXPORT_SYMBOL(i2c_smbus_write_byte_data);
1348 1624
1625/**
1626 * i2c_smbus_read_word_data - SMBus "read word" protocol
1627 * @client: Handle to slave device
1628 * @command: Byte interpreted by slave
1629 *
1630 * This executes the SMBus "read word" protocol, returning negative errno
1631 * else a 16-bit unsigned "word" received from the device.
1632 */
1349s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command) 1633s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command)
1350{ 1634{
1351 union i2c_smbus_data data; 1635 union i2c_smbus_data data;
1352 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1636 int status;
1353 I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data)) 1637
1354 return -1; 1638 status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1355 else 1639 I2C_SMBUS_READ, command,
1356 return data.word; 1640 I2C_SMBUS_WORD_DATA, &data);
1641 return (status < 0) ? status : data.word;
1357} 1642}
1358EXPORT_SYMBOL(i2c_smbus_read_word_data); 1643EXPORT_SYMBOL(i2c_smbus_read_word_data);
1359 1644
1645/**
1646 * i2c_smbus_write_word_data - SMBus "write word" protocol
1647 * @client: Handle to slave device
1648 * @command: Byte interpreted by slave
1649 * @value: 16-bit "word" being written
1650 *
1651 * This executes the SMBus "write word" protocol, returning negative errno
1652 * else zero on success.
1653 */
1360s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) 1654s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
1361{ 1655{
1362 union i2c_smbus_data data; 1656 union i2c_smbus_data data;
@@ -1368,15 +1662,14 @@ s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
1368EXPORT_SYMBOL(i2c_smbus_write_word_data); 1662EXPORT_SYMBOL(i2c_smbus_write_word_data);
1369 1663
1370/** 1664/**
1371 * i2c_smbus_read_block_data - SMBus block read request 1665 * i2c_smbus_read_block_data - SMBus "block read" protocol
1372 * @client: Handle to slave device 1666 * @client: Handle to slave device
1373 * @command: Command byte issued to let the slave know what data should 1667 * @command: Byte interpreted by slave
1374 * be returned
1375 * @values: Byte array into which data will be read; big enough to hold 1668 * @values: Byte array into which data will be read; big enough to hold
1376 * the data returned by the slave. SMBus allows at most 32 bytes. 1669 * the data returned by the slave. SMBus allows at most 32 bytes.
1377 * 1670 *
1378 * Returns the number of bytes read in the slave's response, else a 1671 * This executes the SMBus "block read" protocol, returning negative errno
1379 * negative number to indicate some kind of error. 1672 * else the number of data bytes in the slave's response.
1380 * 1673 *
1381 * Note that using this function requires that the client's adapter support 1674 * Note that using this function requires that the client's adapter support
1382 * the I2C_FUNC_SMBUS_READ_BLOCK_DATA functionality. Not all adapter drivers 1675 * the I2C_FUNC_SMBUS_READ_BLOCK_DATA functionality. Not all adapter drivers
@@ -1387,17 +1680,29 @@ s32 i2c_smbus_read_block_data(struct i2c_client *client, u8 command,
1387 u8 *values) 1680 u8 *values)
1388{ 1681{
1389 union i2c_smbus_data data; 1682 union i2c_smbus_data data;
1683 int status;
1390 1684
1391 if (i2c_smbus_xfer(client->adapter, client->addr, client->flags, 1685 status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1392 I2C_SMBUS_READ, command, 1686 I2C_SMBUS_READ, command,
1393 I2C_SMBUS_BLOCK_DATA, &data)) 1687 I2C_SMBUS_BLOCK_DATA, &data);
1394 return -1; 1688 if (status)
1689 return status;
1395 1690
1396 memcpy(values, &data.block[1], data.block[0]); 1691 memcpy(values, &data.block[1], data.block[0]);
1397 return data.block[0]; 1692 return data.block[0];
1398} 1693}
1399EXPORT_SYMBOL(i2c_smbus_read_block_data); 1694EXPORT_SYMBOL(i2c_smbus_read_block_data);
1400 1695
1696/**
1697 * i2c_smbus_write_block_data - SMBus "block write" protocol
1698 * @client: Handle to slave device
1699 * @command: Byte interpreted by slave
1700 * @length: Size of data block; SMBus allows at most 32 bytes
1701 * @values: Byte array which will be written.
1702 *
1703 * This executes the SMBus "block write" protocol, returning negative errno
1704 * else zero on success.
1705 */
1401s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, 1706s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
1402 u8 length, const u8 *values) 1707 u8 length, const u8 *values)
1403{ 1708{
@@ -1418,14 +1723,16 @@ s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command,
1418 u8 length, u8 *values) 1723 u8 length, u8 *values)
1419{ 1724{
1420 union i2c_smbus_data data; 1725 union i2c_smbus_data data;
1726 int status;
1421 1727
1422 if (length > I2C_SMBUS_BLOCK_MAX) 1728 if (length > I2C_SMBUS_BLOCK_MAX)
1423 length = I2C_SMBUS_BLOCK_MAX; 1729 length = I2C_SMBUS_BLOCK_MAX;
1424 data.block[0] = length; 1730 data.block[0] = length;
1425 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 1731 status = i2c_smbus_xfer(client->adapter, client->addr, client->flags,
1426 I2C_SMBUS_READ,command, 1732 I2C_SMBUS_READ, command,
1427 I2C_SMBUS_I2C_BLOCK_DATA,&data)) 1733 I2C_SMBUS_I2C_BLOCK_DATA, &data);
1428 return -1; 1734 if (status < 0)
1735 return status;
1429 1736
1430 memcpy(values, &data.block[1], data.block[0]); 1737 memcpy(values, &data.block[1], data.block[0]);
1431 return data.block[0]; 1738 return data.block[0];
@@ -1466,6 +1773,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1466 }; 1773 };
1467 int i; 1774 int i;
1468 u8 partial_pec = 0; 1775 u8 partial_pec = 0;
1776 int status;
1469 1777
1470 msgbuf0[0] = command; 1778 msgbuf0[0] = command;
1471 switch(size) { 1779 switch(size) {
@@ -1515,10 +1823,10 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1515 } else { 1823 } else {
1516 msg[0].len = data->block[0] + 2; 1824 msg[0].len = data->block[0] + 2;
1517 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) { 1825 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 2) {
1518 dev_err(&adapter->dev, "smbus_access called with " 1826 dev_err(&adapter->dev,
1519 "invalid block write size (%d)\n", 1827 "Invalid block write size %d\n",
1520 data->block[0]); 1828 data->block[0]);
1521 return -1; 1829 return -EINVAL;
1522 } 1830 }
1523 for (i = 1; i < msg[0].len; i++) 1831 for (i = 1; i < msg[0].len; i++)
1524 msgbuf0[i] = data->block[i-1]; 1832 msgbuf0[i] = data->block[i-1];
@@ -1528,10 +1836,10 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1528 num = 2; /* Another special case */ 1836 num = 2; /* Another special case */
1529 read_write = I2C_SMBUS_READ; 1837 read_write = I2C_SMBUS_READ;
1530 if (data->block[0] > I2C_SMBUS_BLOCK_MAX) { 1838 if (data->block[0] > I2C_SMBUS_BLOCK_MAX) {
1531 dev_err(&adapter->dev, "%s called with invalid " 1839 dev_err(&adapter->dev,
1532 "block proc call size (%d)\n", __func__, 1840 "Invalid block write size %d\n",
1533 data->block[0]); 1841 data->block[0]);
1534 return -1; 1842 return -EINVAL;
1535 } 1843 }
1536 msg[0].len = data->block[0] + 2; 1844 msg[0].len = data->block[0] + 2;
1537 for (i = 1; i < msg[0].len; i++) 1845 for (i = 1; i < msg[0].len; i++)
@@ -1546,19 +1854,18 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1546 } else { 1854 } else {
1547 msg[0].len = data->block[0] + 1; 1855 msg[0].len = data->block[0] + 1;
1548 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { 1856 if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) {
1549 dev_err(&adapter->dev, "i2c_smbus_xfer_emulated called with " 1857 dev_err(&adapter->dev,
1550 "invalid block write size (%d)\n", 1858 "Invalid block write size %d\n",
1551 data->block[0]); 1859 data->block[0]);
1552 return -1; 1860 return -EINVAL;
1553 } 1861 }
1554 for (i = 1; i <= data->block[0]; i++) 1862 for (i = 1; i <= data->block[0]; i++)
1555 msgbuf0[i] = data->block[i]; 1863 msgbuf0[i] = data->block[i];
1556 } 1864 }
1557 break; 1865 break;
1558 default: 1866 default:
1559 dev_err(&adapter->dev, "smbus_access called with invalid size (%d)\n", 1867 dev_err(&adapter->dev, "Unsupported transaction %d\n", size);
1560 size); 1868 return -EOPNOTSUPP;
1561 return -1;
1562 } 1869 }
1563 1870
1564 i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK 1871 i = ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK
@@ -1576,13 +1883,15 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1576 msg[num-1].len++; 1883 msg[num-1].len++;
1577 } 1884 }
1578 1885
1579 if (i2c_transfer(adapter, msg, num) < 0) 1886 status = i2c_transfer(adapter, msg, num);
1580 return -1; 1887 if (status < 0)
1888 return status;
1581 1889
1582 /* Check PEC if last message is a read */ 1890 /* Check PEC if last message is a read */
1583 if (i && (msg[num-1].flags & I2C_M_RD)) { 1891 if (i && (msg[num-1].flags & I2C_M_RD)) {
1584 if (i2c_smbus_check_pec(partial_pec, &msg[num-1]) < 0) 1892 status = i2c_smbus_check_pec(partial_pec, &msg[num-1]);
1585 return -1; 1893 if (status < 0)
1894 return status;
1586 } 1895 }
1587 1896
1588 if (read_write == I2C_SMBUS_READ) 1897 if (read_write == I2C_SMBUS_READ)
@@ -1610,9 +1919,21 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1610 return 0; 1919 return 0;
1611} 1920}
1612 1921
1613 1922/**
1923 * i2c_smbus_xfer - execute SMBus protocol operations
1924 * @adapter: Handle to I2C bus
1925 * @addr: Address of SMBus slave on that bus
1926 * @flags: I2C_CLIENT_* flags (usually zero or I2C_CLIENT_PEC)
1927 * @read_write: I2C_SMBUS_READ or I2C_SMBUS_WRITE
1928 * @command: Byte interpreted by slave, for protocols which use such bytes
1929 * @protocol: SMBus protocol operation to execute, such as I2C_SMBUS_PROC_CALL
1930 * @data: Data to be read or written
1931 *
1932 * This executes an SMBus protocol operation, and returns a negative
1933 * errno code else zero on success.
1934 */
1614s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags, 1935s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1615 char read_write, u8 command, int size, 1936 char read_write, u8 command, int protocol,
1616 union i2c_smbus_data * data) 1937 union i2c_smbus_data * data)
1617{ 1938{
1618 s32 res; 1939 s32 res;
@@ -1622,11 +1943,11 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
1622 if (adapter->algo->smbus_xfer) { 1943 if (adapter->algo->smbus_xfer) {
1623 mutex_lock(&adapter->bus_lock); 1944 mutex_lock(&adapter->bus_lock);
1624 res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write, 1945 res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write,
1625 command,size,data); 1946 command, protocol, data);
1626 mutex_unlock(&adapter->bus_lock); 1947 mutex_unlock(&adapter->bus_lock);
1627 } else 1948 } else
1628 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write, 1949 res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
1629 command,size,data); 1950 command, protocol, data);
1630 1951
1631 return res; 1952 return res;
1632} 1953}
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 006a5857256..86727fa8858 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -367,8 +367,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
367 return res; 367 return res;
368} 368}
369 369
370static int i2cdev_ioctl(struct inode *inode, struct file *file, 370static long i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
371 unsigned int cmd, unsigned long arg)
372{ 371{
373 struct i2c_client *client = (struct i2c_client *)file->private_data; 372 struct i2c_client *client = (struct i2c_client *)file->private_data;
374 unsigned long funcs; 373 unsigned long funcs;
@@ -497,7 +496,7 @@ static const struct file_operations i2cdev_fops = {
497 .llseek = no_llseek, 496 .llseek = no_llseek,
498 .read = i2cdev_read, 497 .read = i2cdev_read,
499 .write = i2cdev_write, 498 .write = i2cdev_write,
500 .ioctl = i2cdev_ioctl, 499 .unlocked_ioctl = i2cdev_ioctl,
501 .open = i2cdev_open, 500 .open = i2cdev_open,
502 .release = i2cdev_release, 501 .release = i2cdev_release,
503}; 502};
@@ -559,19 +558,12 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
559 return 0; 558 return 0;
560} 559}
561 560
562static int i2cdev_detach_client(struct i2c_client *client)
563{
564 return 0;
565}
566
567static struct i2c_driver i2cdev_driver = { 561static struct i2c_driver i2cdev_driver = {
568 .driver = { 562 .driver = {
569 .name = "dev_driver", 563 .name = "dev_driver",
570 }, 564 },
571 .id = I2C_DRIVERID_I2CDEV,
572 .attach_adapter = i2cdev_attach_adapter, 565 .attach_adapter = i2cdev_attach_adapter,
573 .detach_adapter = i2cdev_detach_adapter, 566 .detach_adapter = i2cdev_detach_adapter,
574 .detach_client = i2cdev_detach_client,
575}; 567};
576 568
577/* ------------------------------------------------------------------------- */ 569/* ------------------------------------------------------------------------- */
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 1607536ff5f..cf707c8f08d 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -98,6 +98,9 @@ if BLK_DEV_IDE
98 98
99comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" 99comment "Please see Documentation/ide/ide.txt for help/info on IDE drives"
100 100
101config IDE_ATAPI
102 bool
103
101config BLK_DEV_IDE_SATA 104config BLK_DEV_IDE_SATA
102 bool "Support for SATA (deprecated; conflicts with libata SATA driver)" 105 bool "Support for SATA (deprecated; conflicts with libata SATA driver)"
103 default n 106 default n
@@ -201,6 +204,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS
201 204
202config BLK_DEV_IDETAPE 205config BLK_DEV_IDETAPE
203 tristate "Include IDE/ATAPI TAPE support" 206 tristate "Include IDE/ATAPI TAPE support"
207 select IDE_ATAPI
204 help 208 help
205 If you have an IDE tape drive using the ATAPI protocol, say Y. 209 If you have an IDE tape drive using the ATAPI protocol, say Y.
206 ATAPI is a newer protocol used by IDE tape and CD-ROM drives, 210 ATAPI is a newer protocol used by IDE tape and CD-ROM drives,
@@ -223,6 +227,7 @@ config BLK_DEV_IDETAPE
223 227
224config BLK_DEV_IDEFLOPPY 228config BLK_DEV_IDEFLOPPY
225 tristate "Include IDE/ATAPI FLOPPY support" 229 tristate "Include IDE/ATAPI FLOPPY support"
230 select IDE_ATAPI
226 ---help--- 231 ---help---
227 If you have an IDE floppy drive which uses the ATAPI protocol, 232 If you have an IDE floppy drive which uses the ATAPI protocol,
228 answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy 233 answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy
@@ -246,6 +251,7 @@ config BLK_DEV_IDEFLOPPY
246config BLK_DEV_IDESCSI 251config BLK_DEV_IDESCSI
247 tristate "SCSI emulation support" 252 tristate "SCSI emulation support"
248 depends on SCSI 253 depends on SCSI
254 select IDE_ATAPI
249 ---help--- 255 ---help---
250 WARNING: ide-scsi is no longer needed for cd writing applications! 256 WARNING: ide-scsi is no longer needed for cd writing applications!
251 The 2.6 kernel supports direct writing to ide-cd, which eliminates 257 The 2.6 kernel supports direct writing to ide-cd, which eliminates
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index f94b679b611..a2b3f84d710 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -14,6 +14,7 @@ EXTRA_CFLAGS += -Idrivers/ide
14ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o 14ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o
15 15
16# core IDE code 16# core IDE code
17ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o
17ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 18ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
18ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o 19ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
19ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o 20ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index 2f2b4f4cf22..3839f572298 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -83,7 +83,7 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
83 {125, 160}, /* UDMA Mode 1 */ 83 {125, 160}, /* UDMA Mode 1 */
84 {100, 120}, /* UDMA Mode 2 */ 84 {100, 120}, /* UDMA Mode 2 */
85 {100, 90}, /* UDMA Mode 3 */ 85 {100, 90}, /* UDMA Mode 3 */
86 {85, 60}, /* UDMA Mode 4 */ 86 {100, 60}, /* UDMA Mode 4 */
87}; 87};
88 88
89static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, 89static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
@@ -405,7 +405,6 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
405 ide_init_port_data(hwif, i); 405 ide_init_port_data(hwif, i);
406 ide_init_port_hw(hwif, &hw); 406 ide_init_port_hw(hwif, &hw);
407 407
408 hwif->mmio = 1;
409 default_hwif_mmiops(hwif); 408 default_hwif_mmiops(hwif);
410 409
411 idx[0] = i; 410 idx[0] = i;
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index ecf53bb0d2a..ae37ee58bae 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -52,8 +52,6 @@ static void h8300_tf_load(ide_drive_t *drive, ide_task_t *task)
52 if (task->tf_flags & IDE_TFLAG_FLAGGED) 52 if (task->tf_flags & IDE_TFLAG_FLAGGED)
53 HIHI = 0xFF; 53 HIHI = 0xFF;
54 54
55 ide_set_irq(drive, 1);
56
57 if (task->tf_flags & IDE_TFLAG_OUT_DATA) 55 if (task->tf_flags & IDE_TFLAG_OUT_DATA)
58 mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr); 56 mm_outw((tf->hob_data << 8) | tf->data, io_ports->data_addr);
59 57
@@ -98,7 +96,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task)
98 } 96 }
99 97
100 /* be sure we're looking at the low order bits */ 98 /* be sure we're looking at the low order bits */
101 outb(drive->ctl & ~0x80, io_ports->ctl_addr); 99 outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
102 100
103 if (task->tf_flags & IDE_TFLAG_IN_NSECT) 101 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
104 tf->nsect = inb(io_ports->nsect_addr); 102 tf->nsect = inb(io_ports->nsect_addr);
@@ -112,7 +110,7 @@ static void h8300_tf_read(ide_drive_t *drive, ide_task_t *task)
112 tf->device = inb(io_ports->device_addr); 110 tf->device = inb(io_ports->device_addr);
113 111
114 if (task->tf_flags & IDE_TFLAG_LBA48) { 112 if (task->tf_flags & IDE_TFLAG_LBA48) {
115 outb(drive->ctl | 0x80, io_ports->ctl_addr); 113 outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
116 114
117 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) 115 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
118 tf->hob_feature = inb(io_ports->feature_addr); 116 tf->hob_feature = inb(io_ports->feature_addr);
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 9d3601fa568..6f704628c27 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -60,15 +60,15 @@ struct ide_acpi_hwif_link {
60#define DEBPRINT(fmt, args...) do {} while (0) 60#define DEBPRINT(fmt, args...) do {} while (0)
61#endif /* DEBUGGING */ 61#endif /* DEBUGGING */
62 62
63int ide_noacpi; 63static int ide_noacpi;
64module_param_named(noacpi, ide_noacpi, bool, 0); 64module_param_named(noacpi, ide_noacpi, bool, 0);
65MODULE_PARM_DESC(noacpi, "disable IDE ACPI support"); 65MODULE_PARM_DESC(noacpi, "disable IDE ACPI support");
66 66
67int ide_acpigtf; 67static int ide_acpigtf;
68module_param_named(acpigtf, ide_acpigtf, bool, 0); 68module_param_named(acpigtf, ide_acpigtf, bool, 0);
69MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support"); 69MODULE_PARM_DESC(acpigtf, "enable IDE ACPI _GTF support");
70 70
71int ide_acpionboot; 71static int ide_acpionboot;
72module_param_named(acpionboot, ide_acpionboot, bool, 0); 72module_param_named(acpionboot, ide_acpionboot, bool, 0);
73MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot"); 73MODULE_PARM_DESC(acpionboot, "call IDE ACPI methods on boot");
74 74
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
new file mode 100644
index 00000000000..2802031de67
--- /dev/null
+++ b/drivers/ide/ide-atapi.c
@@ -0,0 +1,296 @@
1/*
2 * ATAPI support.
3 */
4
5#include <linux/kernel.h>
6#include <linux/delay.h>
7#include <linux/ide.h>
8#include <scsi/scsi.h>
9
10#ifdef DEBUG
11#define debug_log(fmt, args...) \
12 printk(KERN_INFO "ide: " fmt, ## args)
13#else
14#define debug_log(fmt, args...) do {} while (0)
15#endif
16
17/* TODO: unify the code thus making some arguments go away */
18ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
19 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
20 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
21 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
22 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int))
23{
24 ide_hwif_t *hwif = drive->hwif;
25 xfer_func_t *xferfunc;
26 unsigned int temp;
27 u16 bcount;
28 u8 stat, ireason, scsi = drive->scsi;
29
30 debug_log("Enter %s - interrupt handler\n", __func__);
31
32 if (pc->flags & PC_FLAG_TIMEDOUT) {
33 pc->callback(drive);
34 return ide_stopped;
35 }
36
37 /* Clear the interrupt */
38 stat = ide_read_status(drive);
39
40 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
41 if (hwif->dma_ops->dma_end(drive) ||
42 (drive->media == ide_tape && !scsi && (stat & ERR_STAT))) {
43 if (drive->media == ide_floppy && !scsi)
44 printk(KERN_ERR "%s: DMA %s error\n",
45 drive->name, rq_data_dir(pc->rq)
46 ? "write" : "read");
47 pc->flags |= PC_FLAG_DMA_ERROR;
48 } else {
49 pc->xferred = pc->req_xfer;
50 if (update_buffers)
51 update_buffers(drive, pc);
52 }
53 debug_log("%s: DMA finished\n", drive->name);
54 }
55
56 /* No more interrupts */
57 if ((stat & DRQ_STAT) == 0) {
58 debug_log("Packet command completed, %d bytes transferred\n",
59 pc->xferred);
60
61 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
62
63 local_irq_enable_in_hardirq();
64
65 if (drive->media == ide_tape && !scsi &&
66 (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
67 stat &= ~ERR_STAT;
68 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
69 /* Error detected */
70 debug_log("%s: I/O error\n", drive->name);
71
72 if (drive->media != ide_tape || scsi) {
73 pc->rq->errors++;
74 if (scsi)
75 goto cmd_finished;
76 }
77
78 if (pc->c[0] == REQUEST_SENSE) {
79 printk(KERN_ERR "%s: I/O error in request sense"
80 " command\n", drive->name);
81 return ide_do_reset(drive);
82 }
83
84 debug_log("[cmd %x]: check condition\n", pc->c[0]);
85
86 /* Retry operation */
87 retry_pc(drive);
88 /* queued, but not started */
89 return ide_stopped;
90 }
91cmd_finished:
92 pc->error = 0;
93 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
94 (stat & SEEK_STAT) == 0) {
95 dsc_handle(drive);
96 return ide_stopped;
97 }
98 /* Command finished - Call the callback function */
99 pc->callback(drive);
100 return ide_stopped;
101 }
102
103 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
104 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
105 printk(KERN_ERR "%s: The device wants to issue more interrupts "
106 "in DMA mode\n", drive->name);
107 ide_dma_off(drive);
108 return ide_do_reset(drive);
109 }
110 /* Get the number of bytes to transfer on this interrupt. */
111 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
112 hwif->INB(hwif->io_ports.lbam_addr);
113
114 ireason = hwif->INB(hwif->io_ports.nsect_addr);
115
116 if (ireason & CD) {
117 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
118 return ide_do_reset(drive);
119 }
120 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
121 /* Hopefully, we will never get here */
122 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
123 "to %s!\n", drive->name,
124 (ireason & IO) ? "Write" : "Read",
125 (ireason & IO) ? "Read" : "Write");
126 return ide_do_reset(drive);
127 }
128 if (!(pc->flags & PC_FLAG_WRITING)) {
129 /* Reading - Check that we have enough space */
130 temp = pc->xferred + bcount;
131 if (temp > pc->req_xfer) {
132 if (temp > pc->buf_size) {
133 printk(KERN_ERR "%s: The device wants to send "
134 "us more data than expected - "
135 "discarding data\n",
136 drive->name);
137 if (scsi)
138 temp = pc->buf_size - pc->xferred;
139 else
140 temp = 0;
141 if (temp) {
142 if (pc->sg)
143 io_buffers(drive, pc, temp, 0);
144 else
145 hwif->input_data(drive, NULL,
146 pc->cur_pos, temp);
147 printk(KERN_ERR "%s: transferred %d of "
148 "%d bytes\n",
149 drive->name,
150 temp, bcount);
151 }
152 pc->xferred += temp;
153 pc->cur_pos += temp;
154 ide_pad_transfer(drive, 0, bcount - temp);
155 ide_set_handler(drive, handler, timeout,
156 expiry);
157 return ide_started;
158 }
159 debug_log("The device wants to send us more data than "
160 "expected - allowing transfer\n");
161 }
162 xferfunc = hwif->input_data;
163 } else
164 xferfunc = hwif->output_data;
165
166 if ((drive->media == ide_floppy && !scsi && !pc->buf) ||
167 (drive->media == ide_tape && !scsi && pc->bh) ||
168 (scsi && pc->sg))
169 io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING));
170 else
171 xferfunc(drive, NULL, pc->cur_pos, bcount);
172
173 /* Update the current position */
174 pc->xferred += bcount;
175 pc->cur_pos += bcount;
176
177 debug_log("[cmd %x] transferred %d bytes on that intr.\n",
178 pc->c[0], bcount);
179
180 /* And set the interrupt handler again */
181 ide_set_handler(drive, handler, timeout, expiry);
182 return ide_started;
183}
184EXPORT_SYMBOL_GPL(ide_pc_intr);
185
186static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
187{
188 ide_hwif_t *hwif = drive->hwif;
189 int retries = 100;
190
191 while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
192 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
193 "a packet command, retrying\n", drive->name);
194 udelay(100);
195 ireason = hwif->INB(hwif->io_ports.nsect_addr);
196 if (retries == 0) {
197 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
198 "a packet command, ignoring\n",
199 drive->name);
200 ireason |= CD;
201 ireason &= ~IO;
202 }
203 }
204
205 return ireason;
206}
207
208ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
209 ide_handler_t *handler, unsigned int timeout,
210 ide_expiry_t *expiry)
211{
212 ide_hwif_t *hwif = drive->hwif;
213 ide_startstop_t startstop;
214 u8 ireason;
215
216 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
217 printk(KERN_ERR "%s: Strange, packet command initiated yet "
218 "DRQ isn't asserted\n", drive->name);
219 return startstop;
220 }
221
222 ireason = hwif->INB(hwif->io_ports.nsect_addr);
223 if (drive->media == ide_tape && !drive->scsi)
224 ireason = ide_wait_ireason(drive, ireason);
225
226 if ((ireason & CD) == 0 || (ireason & IO)) {
227 printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
228 "a packet command\n", drive->name);
229 return ide_do_reset(drive);
230 }
231
232 /* Set the interrupt routine */
233 ide_set_handler(drive, handler, timeout, expiry);
234
235 /* Begin DMA, if necessary */
236 if (pc->flags & PC_FLAG_DMA_OK) {
237 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
238 hwif->dma_ops->dma_start(drive);
239 }
240
241 /* Send the actual packet */
242 if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0)
243 hwif->output_data(drive, NULL, pc->c, 12);
244
245 return ide_started;
246}
247EXPORT_SYMBOL_GPL(ide_transfer_pc);
248
249ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc,
250 ide_handler_t *handler, unsigned int timeout,
251 ide_expiry_t *expiry)
252{
253 ide_hwif_t *hwif = drive->hwif;
254 u16 bcount;
255 u8 dma = 0;
256
257 /* We haven't transferred any data yet */
258 pc->xferred = 0;
259 pc->cur_pos = pc->buf;
260
261 /* Request to transfer the entire buffer at once */
262 if (drive->media == ide_tape && !drive->scsi)
263 bcount = pc->req_xfer;
264 else
265 bcount = min(pc->req_xfer, 63 * 1024);
266
267 if (pc->flags & PC_FLAG_DMA_ERROR) {
268 pc->flags &= ~PC_FLAG_DMA_ERROR;
269 ide_dma_off(drive);
270 }
271
272 if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) {
273 if (drive->scsi)
274 hwif->sg_mapped = 1;
275 dma = !hwif->dma_ops->dma_setup(drive);
276 if (drive->scsi)
277 hwif->sg_mapped = 0;
278 }
279
280 if (!dma)
281 pc->flags &= ~PC_FLAG_DMA_OK;
282
283 ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE,
284 bcount, dma);
285
286 /* Issue the packet command */
287 if (pc->flags & PC_FLAG_DRQ_INTERRUPT) {
288 ide_execute_command(drive, WIN_PACKETCMD, handler,
289 timeout, NULL);
290 return ide_started;
291 } else {
292 ide_execute_pkt_cmd(drive);
293 return (*handler)(drive);
294 }
295}
296EXPORT_SYMBOL_GPL(ide_issue_pc);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 68e7f19dc03..d9984715718 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -188,16 +188,6 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
188 ide_cd_log_error(drive->name, failed_command, sense); 188 ide_cd_log_error(drive->name, failed_command, sense);
189} 189}
190 190
191/* Initialize a ide-cd packet command request */
192void ide_cd_init_rq(ide_drive_t *drive, struct request *rq)
193{
194 struct cdrom_info *cd = drive->driver_data;
195
196 ide_init_drive_cmd(rq);
197 rq->cmd_type = REQ_TYPE_ATA_PC;
198 rq->rq_disk = cd->disk;
199}
200
201static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, 191static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
202 struct request *failed_command) 192 struct request *failed_command)
203{ 193{
@@ -208,7 +198,9 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
208 sense = &info->sense_data; 198 sense = &info->sense_data;
209 199
210 /* stuff the sense request in front of our current request */ 200 /* stuff the sense request in front of our current request */
211 ide_cd_init_rq(drive, rq); 201 blk_rq_init(NULL, rq);
202 rq->cmd_type = REQ_TYPE_ATA_PC;
203 rq->rq_disk = info->disk;
212 204
213 rq->data = sense; 205 rq->data = sense;
214 rq->cmd[0] = GPCMD_REQUEST_SENSE; 206 rq->cmd[0] = GPCMD_REQUEST_SENSE;
@@ -216,11 +208,12 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
216 rq->data_len = 18; 208 rq->data_len = 18;
217 209
218 rq->cmd_type = REQ_TYPE_SENSE; 210 rq->cmd_type = REQ_TYPE_SENSE;
211 rq->cmd_flags |= REQ_PREEMPT;
219 212
220 /* NOTE! Save the failed command in "rq->buffer" */ 213 /* NOTE! Save the failed command in "rq->buffer" */
221 rq->buffer = (void *) failed_command; 214 rq->buffer = (void *) failed_command;
222 215
223 (void) ide_do_drive_cmd(drive, rq, ide_preempt); 216 ide_do_drive_cmd(drive, rq);
224} 217}
225 218
226static void cdrom_end_request(ide_drive_t *drive, int uptodate) 219static void cdrom_end_request(ide_drive_t *drive, int uptodate)
@@ -537,8 +530,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
537 info->dma = !hwif->dma_ops->dma_setup(drive); 530 info->dma = !hwif->dma_ops->dma_setup(drive);
538 531
539 /* set up the controller registers */ 532 /* set up the controller registers */
540 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | 533 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL,
541 IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); 534 xferlen, info->dma);
542 535
543 if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { 536 if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) {
544 /* waiting for CDB interrupt, not DMA yet. */ 537 /* waiting for CDB interrupt, not DMA yet. */
@@ -838,34 +831,54 @@ static void ide_cd_request_sense_fixup(struct request *rq)
838 } 831 }
839} 832}
840 833
841int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq) 834int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
835 int write, void *buffer, unsigned *bufflen,
836 struct request_sense *sense, int timeout,
837 unsigned int cmd_flags)
842{ 838{
843 struct request_sense sense; 839 struct cdrom_info *info = drive->driver_data;
840 struct request_sense local_sense;
844 int retries = 10; 841 int retries = 10;
845 unsigned int flags = rq->cmd_flags; 842 unsigned int flags = 0;
846 843
847 if (rq->sense == NULL) 844 if (!sense)
848 rq->sense = &sense; 845 sense = &local_sense;
849 846
850 /* start of retry loop */ 847 /* start of retry loop */
851 do { 848 do {
849 struct request *rq;
852 int error; 850 int error;
853 unsigned long time = jiffies;
854 rq->cmd_flags = flags;
855 851
856 error = ide_do_drive_cmd(drive, rq, ide_wait); 852 rq = blk_get_request(drive->queue, write, __GFP_WAIT);
857 time = jiffies - time; 853
854 memcpy(rq->cmd, cmd, BLK_MAX_CDB);
855 rq->cmd_type = REQ_TYPE_ATA_PC;
856 rq->sense = sense;
857 rq->cmd_flags |= cmd_flags;
858 rq->timeout = timeout;
859 if (buffer) {
860 rq->data = buffer;
861 rq->data_len = *bufflen;
862 }
863
864 error = blk_execute_rq(drive->queue, info->disk, rq, 0);
865
866 if (buffer)
867 *bufflen = rq->data_len;
868
869 flags = rq->cmd_flags;
870 blk_put_request(rq);
858 871
859 /* 872 /*
860 * FIXME: we should probably abort/retry or something in case of 873 * FIXME: we should probably abort/retry or something in case of
861 * failure. 874 * failure.
862 */ 875 */
863 if (rq->cmd_flags & REQ_FAILED) { 876 if (flags & REQ_FAILED) {
864 /* 877 /*
865 * The request failed. Retry if it was due to a unit 878 * The request failed. Retry if it was due to a unit
866 * attention status (usually means media was changed). 879 * attention status (usually means media was changed).
867 */ 880 */
868 struct request_sense *reqbuf = rq->sense; 881 struct request_sense *reqbuf = sense;
869 882
870 if (reqbuf->sense_key == UNIT_ATTENTION) 883 if (reqbuf->sense_key == UNIT_ATTENTION)
871 cdrom_saw_media_change(drive); 884 cdrom_saw_media_change(drive);
@@ -885,10 +898,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
885 } 898 }
886 899
887 /* end of retry loop */ 900 /* end of retry loop */
888 } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); 901 } while ((flags & REQ_FAILED) && retries >= 0);
889 902
890 /* return an error if the command failed */ 903 /* return an error if the command failed */
891 return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; 904 return (flags & REQ_FAILED) ? -EIO : 0;
892} 905}
893 906
894/* 907/*
@@ -1268,23 +1281,20 @@ static void msf_from_bcd(struct atapi_msf *msf)
1268 1281
1269int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) 1282int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
1270{ 1283{
1271 struct request req;
1272 struct cdrom_info *info = drive->driver_data; 1284 struct cdrom_info *info = drive->driver_data;
1273 struct cdrom_device_info *cdi = &info->devinfo; 1285 struct cdrom_device_info *cdi = &info->devinfo;
1286 unsigned char cmd[BLK_MAX_CDB];
1274 1287
1275 ide_cd_init_rq(drive, &req); 1288 memset(cmd, 0, BLK_MAX_CDB);
1276 1289 cmd[0] = GPCMD_TEST_UNIT_READY;
1277 req.sense = sense;
1278 req.cmd[0] = GPCMD_TEST_UNIT_READY;
1279 req.cmd_flags |= REQ_QUIET;
1280 1290
1281 /* 1291 /*
1282 * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs 1292 * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs
1283 * instead of supporting the LOAD_UNLOAD opcode. 1293 * instead of supporting the LOAD_UNLOAD opcode.
1284 */ 1294 */
1285 req.cmd[7] = cdi->sanyo_slot % 3; 1295 cmd[7] = cdi->sanyo_slot % 3;
1286 1296
1287 return ide_cd_queue_pc(drive, &req); 1297 return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, REQ_QUIET);
1288} 1298}
1289 1299
1290static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, 1300static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
@@ -1297,17 +1307,14 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1297 } capbuf; 1307 } capbuf;
1298 1308
1299 int stat; 1309 int stat;
1300 struct request req; 1310 unsigned char cmd[BLK_MAX_CDB];
1301 1311 unsigned len = sizeof(capbuf);
1302 ide_cd_init_rq(drive, &req);
1303 1312
1304 req.sense = sense; 1313 memset(cmd, 0, BLK_MAX_CDB);
1305 req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; 1314 cmd[0] = GPCMD_READ_CDVD_CAPACITY;
1306 req.data = (char *)&capbuf;
1307 req.data_len = sizeof(capbuf);
1308 req.cmd_flags |= REQ_QUIET;
1309 1315
1310 stat = ide_cd_queue_pc(drive, &req); 1316 stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0,
1317 REQ_QUIET);
1311 if (stat == 0) { 1318 if (stat == 0) {
1312 *capacity = 1 + be32_to_cpu(capbuf.lba); 1319 *capacity = 1 + be32_to_cpu(capbuf.lba);
1313 *sectors_per_frame = 1320 *sectors_per_frame =
@@ -1321,24 +1328,20 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
1321 int format, char *buf, int buflen, 1328 int format, char *buf, int buflen,
1322 struct request_sense *sense) 1329 struct request_sense *sense)
1323{ 1330{
1324 struct request req; 1331 unsigned char cmd[BLK_MAX_CDB];
1325 1332
1326 ide_cd_init_rq(drive, &req); 1333 memset(cmd, 0, BLK_MAX_CDB);
1327 1334
1328 req.sense = sense; 1335 cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
1329 req.data = buf; 1336 cmd[6] = trackno;
1330 req.data_len = buflen; 1337 cmd[7] = (buflen >> 8);
1331 req.cmd_flags |= REQ_QUIET; 1338 cmd[8] = (buflen & 0xff);
1332 req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 1339 cmd[9] = (format << 6);
1333 req.cmd[6] = trackno;
1334 req.cmd[7] = (buflen >> 8);
1335 req.cmd[8] = (buflen & 0xff);
1336 req.cmd[9] = (format << 6);
1337 1340
1338 if (msf_flag) 1341 if (msf_flag)
1339 req.cmd[1] = 2; 1342 cmd[1] = 2;
1340 1343
1341 return ide_cd_queue_pc(drive, &req); 1344 return ide_cd_queue_pc(drive, cmd, 0, buf, &buflen, sense, 0, REQ_QUIET);
1342} 1345}
1343 1346
1344/* Try to read the entire TOC for the disk into our internal buffer. */ 1347/* Try to read the entire TOC for the disk into our internal buffer. */
@@ -2103,11 +2106,6 @@ static int ide_cd_probe(ide_drive_t *drive)
2103 goto failed; 2106 goto failed;
2104 } 2107 }
2105 } 2108 }
2106 if (drive->scsi) {
2107 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi "
2108 "emulation.\n", drive->name);
2109 goto failed;
2110 }
2111 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); 2109 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
2112 if (info == NULL) { 2110 if (info == NULL) {
2113 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", 2111 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n",
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index a58801c4484..fe0ea36e412 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -143,8 +143,8 @@ struct cdrom_info {
143void ide_cd_log_error(const char *, struct request *, struct request_sense *); 143void ide_cd_log_error(const char *, struct request *, struct request_sense *);
144 144
145/* ide-cd.c functions used by ide-cd_ioctl.c */ 145/* ide-cd.c functions used by ide-cd_ioctl.c */
146void ide_cd_init_rq(ide_drive_t *, struct request *); 146int ide_cd_queue_pc(ide_drive_t *, const unsigned char *, int, void *,
147int ide_cd_queue_pc(ide_drive_t *, struct request *); 147 unsigned *, struct request_sense *, int, unsigned int);
148int ide_cd_read_toc(ide_drive_t *, struct request_sense *); 148int ide_cd_read_toc(ide_drive_t *, struct request_sense *);
149int ide_cdrom_get_capabilities(ide_drive_t *, u8 *); 149int ide_cdrom_get_capabilities(ide_drive_t *, u8 *);
150void ide_cdrom_update_speed(ide_drive_t *, u8 *); 150void ide_cdrom_update_speed(ide_drive_t *, u8 *);
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 6d147ce6782..24d002addf7 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -104,8 +104,8 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag,
104{ 104{
105 struct cdrom_info *cd = drive->driver_data; 105 struct cdrom_info *cd = drive->driver_data;
106 struct cdrom_device_info *cdi = &cd->devinfo; 106 struct cdrom_device_info *cdi = &cd->devinfo;
107 struct request req;
108 char loej = 0x02; 107 char loej = 0x02;
108 unsigned char cmd[BLK_MAX_CDB];
109 109
110 if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag) 110 if ((cd->cd_flags & IDE_CD_FLAG_NO_EJECT) && !ejectflag)
111 return -EDRIVE_CANT_DO_THIS; 111 return -EDRIVE_CANT_DO_THIS;
@@ -114,17 +114,16 @@ int cdrom_eject(ide_drive_t *drive, int ejectflag,
114 if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag) 114 if ((cd->cd_flags & IDE_CD_FLAG_DOOR_LOCKED) && ejectflag)
115 return 0; 115 return 0;
116 116
117 ide_cd_init_rq(drive, &req);
118
119 /* only tell drive to close tray if open, if it can do that */ 117 /* only tell drive to close tray if open, if it can do that */
120 if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY)) 118 if (ejectflag && (cdi->mask & CDC_CLOSE_TRAY))
121 loej = 0; 119 loej = 0;
122 120
123 req.sense = sense; 121 memset(cmd, 0, BLK_MAX_CDB);
124 req.cmd[0] = GPCMD_START_STOP_UNIT; 122
125 req.cmd[4] = loej | (ejectflag != 0); 123 cmd[0] = GPCMD_START_STOP_UNIT;
124 cmd[4] = loej | (ejectflag != 0);
126 125
127 return ide_cd_queue_pc(drive, &req); 126 return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, sense, 0, 0);
128} 127}
129 128
130/* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */ 129/* Lock the door if LOCKFLAG is nonzero; unlock it otherwise. */
@@ -134,7 +133,6 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
134{ 133{
135 struct cdrom_info *cd = drive->driver_data; 134 struct cdrom_info *cd = drive->driver_data;
136 struct request_sense my_sense; 135 struct request_sense my_sense;
137 struct request req;
138 int stat; 136 int stat;
139 137
140 if (sense == NULL) 138 if (sense == NULL)
@@ -144,11 +142,15 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
144 if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) { 142 if (cd->cd_flags & IDE_CD_FLAG_NO_DOORLOCK) {
145 stat = 0; 143 stat = 0;
146 } else { 144 } else {
147 ide_cd_init_rq(drive, &req); 145 unsigned char cmd[BLK_MAX_CDB];
148 req.sense = sense; 146
149 req.cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; 147 memset(cmd, 0, BLK_MAX_CDB);
150 req.cmd[4] = lockflag ? 1 : 0; 148
151 stat = ide_cd_queue_pc(drive, &req); 149 cmd[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
150 cmd[4] = lockflag ? 1 : 0;
151
152 stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0,
153 sense, 0, 0);
152 } 154 }
153 155
154 /* If we got an illegal field error, the drive 156 /* If we got an illegal field error, the drive
@@ -206,32 +208,30 @@ int ide_cdrom_select_speed(struct cdrom_device_info *cdi, int speed)
206{ 208{
207 ide_drive_t *drive = cdi->handle; 209 ide_drive_t *drive = cdi->handle;
208 struct cdrom_info *cd = drive->driver_data; 210 struct cdrom_info *cd = drive->driver_data;
209 struct request rq;
210 struct request_sense sense; 211 struct request_sense sense;
211 u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; 212 u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE];
212 int stat; 213 int stat;
213 214 unsigned char cmd[BLK_MAX_CDB];
214 ide_cd_init_rq(drive, &rq);
215
216 rq.sense = &sense;
217 215
218 if (speed == 0) 216 if (speed == 0)
219 speed = 0xffff; /* set to max */ 217 speed = 0xffff; /* set to max */
220 else 218 else
221 speed *= 177; /* Nx to kbytes/s */ 219 speed *= 177; /* Nx to kbytes/s */
222 220
223 rq.cmd[0] = GPCMD_SET_SPEED; 221 memset(cmd, 0, BLK_MAX_CDB);
222
223 cmd[0] = GPCMD_SET_SPEED;
224 /* Read Drive speed in kbytes/second MSB/LSB */ 224 /* Read Drive speed in kbytes/second MSB/LSB */
225 rq.cmd[2] = (speed >> 8) & 0xff; 225 cmd[2] = (speed >> 8) & 0xff;
226 rq.cmd[3] = speed & 0xff; 226 cmd[3] = speed & 0xff;
227 if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) != 227 if ((cdi->mask & (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) !=
228 (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) { 228 (CDC_CD_R | CDC_CD_RW | CDC_DVD_R)) {
229 /* Write Drive speed in kbytes/second MSB/LSB */ 229 /* Write Drive speed in kbytes/second MSB/LSB */
230 rq.cmd[4] = (speed >> 8) & 0xff; 230 cmd[4] = (speed >> 8) & 0xff;
231 rq.cmd[5] = speed & 0xff; 231 cmd[5] = speed & 0xff;
232 } 232 }
233 233
234 stat = ide_cd_queue_pc(drive, &rq); 234 stat = ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0);
235 235
236 if (!ide_cdrom_get_capabilities(drive, buf)) { 236 if (!ide_cdrom_get_capabilities(drive, buf)) {
237 ide_cdrom_update_speed(drive, buf); 237 ide_cdrom_update_speed(drive, buf);
@@ -268,21 +268,19 @@ int ide_cdrom_get_mcn(struct cdrom_device_info *cdi,
268{ 268{
269 ide_drive_t *drive = cdi->handle; 269 ide_drive_t *drive = cdi->handle;
270 int stat, mcnlen; 270 int stat, mcnlen;
271 struct request rq;
272 char buf[24]; 271 char buf[24];
272 unsigned char cmd[BLK_MAX_CDB];
273 unsigned len = sizeof(buf);
273 274
274 ide_cd_init_rq(drive, &rq); 275 memset(cmd, 0, BLK_MAX_CDB);
275 276
276 rq.data = buf; 277 cmd[0] = GPCMD_READ_SUBCHANNEL;
277 rq.data_len = sizeof(buf); 278 cmd[1] = 2; /* MSF addressing */
279 cmd[2] = 0x40; /* request subQ data */
280 cmd[3] = 2; /* format */
281 cmd[8] = len;
278 282
279 rq.cmd[0] = GPCMD_READ_SUBCHANNEL; 283 stat = ide_cd_queue_pc(drive, cmd, 0, buf, &len, NULL, 0, 0);
280 rq.cmd[1] = 2; /* MSF addressing */
281 rq.cmd[2] = 0x40; /* request subQ data */
282 rq.cmd[3] = 2; /* format */
283 rq.cmd[8] = sizeof(buf);
284
285 stat = ide_cd_queue_pc(drive, &rq);
286 if (stat) 284 if (stat)
287 return stat; 285 return stat;
288 286
@@ -298,14 +296,14 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
298 ide_drive_t *drive = cdi->handle; 296 ide_drive_t *drive = cdi->handle;
299 struct cdrom_info *cd = drive->driver_data; 297 struct cdrom_info *cd = drive->driver_data;
300 struct request_sense sense; 298 struct request_sense sense;
301 struct request req; 299 struct request *rq;
302 int ret; 300 int ret;
303 301
304 ide_cd_init_rq(drive, &req); 302 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
305 req.cmd_type = REQ_TYPE_SPECIAL; 303 rq->cmd_type = REQ_TYPE_SPECIAL;
306 req.cmd_flags = REQ_QUIET; 304 rq->cmd_flags = REQ_QUIET;
307 ret = ide_do_drive_cmd(drive, &req, ide_wait); 305 ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
308 306 blk_put_request(rq);
309 /* 307 /*
310 * A reset will unlock the door. If it was previously locked, 308 * A reset will unlock the door. If it was previously locked,
311 * lock it again. 309 * lock it again.
@@ -351,8 +349,8 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg)
351 struct atapi_toc_entry *first_toc, *last_toc; 349 struct atapi_toc_entry *first_toc, *last_toc;
352 unsigned long lba_start, lba_end; 350 unsigned long lba_start, lba_end;
353 int stat; 351 int stat;
354 struct request rq;
355 struct request_sense sense; 352 struct request_sense sense;
353 unsigned char cmd[BLK_MAX_CDB];
356 354
357 stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc); 355 stat = ide_cd_get_toc_entry(drive, ti->cdti_trk0, &first_toc);
358 if (stat) 356 if (stat)
@@ -370,14 +368,13 @@ static int ide_cd_fake_play_trkind(ide_drive_t *drive, void *arg)
370 if (lba_end <= lba_start) 368 if (lba_end <= lba_start)
371 return -EINVAL; 369 return -EINVAL;
372 370
373 ide_cd_init_rq(drive, &rq); 371 memset(cmd, 0, BLK_MAX_CDB);
374 372
375 rq.sense = &sense; 373 cmd[0] = GPCMD_PLAY_AUDIO_MSF;
376 rq.cmd[0] = GPCMD_PLAY_AUDIO_MSF; 374 lba_to_msf(lba_start, &cmd[3], &cmd[4], &cmd[5]);
377 lba_to_msf(lba_start, &rq.cmd[3], &rq.cmd[4], &rq.cmd[5]); 375 lba_to_msf(lba_end - 1, &cmd[6], &cmd[7], &cmd[8]);
378 lba_to_msf(lba_end - 1, &rq.cmd[6], &rq.cmd[7], &rq.cmd[8]);
379 376
380 return ide_cd_queue_pc(drive, &rq); 377 return ide_cd_queue_pc(drive, cmd, 0, NULL, 0, &sense, 0, 0);
381} 378}
382 379
383static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg) 380static int ide_cd_read_tochdr(ide_drive_t *drive, void *arg)
@@ -447,8 +444,9 @@ int ide_cdrom_audio_ioctl(struct cdrom_device_info *cdi,
447int ide_cdrom_packet(struct cdrom_device_info *cdi, 444int ide_cdrom_packet(struct cdrom_device_info *cdi,
448 struct packet_command *cgc) 445 struct packet_command *cgc)
449{ 446{
450 struct request req;
451 ide_drive_t *drive = cdi->handle; 447 ide_drive_t *drive = cdi->handle;
448 unsigned int flags = 0;
449 unsigned len = cgc->buflen;
452 450
453 if (cgc->timeout <= 0) 451 if (cgc->timeout <= 0)
454 cgc->timeout = ATAPI_WAIT_PC; 452 cgc->timeout = ATAPI_WAIT_PC;
@@ -456,24 +454,21 @@ int ide_cdrom_packet(struct cdrom_device_info *cdi,
456 /* here we queue the commands from the uniform CD-ROM 454 /* here we queue the commands from the uniform CD-ROM
457 layer. the packet must be complete, as we do not 455 layer. the packet must be complete, as we do not
458 touch it at all. */ 456 touch it at all. */
459 ide_cd_init_rq(drive, &req);
460 457
461 if (cgc->data_direction == CGC_DATA_WRITE) 458 if (cgc->data_direction == CGC_DATA_WRITE)
462 req.cmd_flags |= REQ_RW; 459 flags |= REQ_RW;
463 460
464 memcpy(req.cmd, cgc->cmd, CDROM_PACKET_SIZE);
465 if (cgc->sense) 461 if (cgc->sense)
466 memset(cgc->sense, 0, sizeof(struct request_sense)); 462 memset(cgc->sense, 0, sizeof(struct request_sense));
467 req.data = cgc->buffer;
468 req.data_len = cgc->buflen;
469 req.timeout = cgc->timeout;
470 463
471 if (cgc->quiet) 464 if (cgc->quiet)
472 req.cmd_flags |= REQ_QUIET; 465 flags |= REQ_QUIET;
473 466
474 req.sense = cgc->sense; 467 cgc->stat = ide_cd_queue_pc(drive, cgc->cmd,
475 cgc->stat = ide_cd_queue_pc(drive, &req); 468 cgc->data_direction == CGC_DATA_WRITE,
469 cgc->buffer, &len,
470 cgc->sense, cgc->timeout, flags);
476 if (!cgc->stat) 471 if (!cgc->stat)
477 cgc->buflen -= req.data_len; 472 cgc->buflen -= len;
478 return cgc->stat; 473 return cgc->stat;
479} 474}
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 8e08d083fce..5f49a4ae9dd 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -198,8 +198,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
198 } 198 }
199 199
200 memset(&task, 0, sizeof(task)); 200 memset(&task, 0, sizeof(task));
201 task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ 201 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
202 task.tf_flags |= (IDE_TFLAG_TF | IDE_TFLAG_DEVICE);
203 202
204 if (drive->select.b.lba) { 203 if (drive->select.b.lba) {
205 if (lba48) { 204 if (lba48) {
@@ -617,7 +616,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
617 */ 616 */
618static int set_multcount(ide_drive_t *drive, int arg) 617static int set_multcount(ide_drive_t *drive, int arg)
619{ 618{
620 struct request rq; 619 struct request *rq;
620 int error;
621 621
622 if (arg < 0 || arg > drive->id->max_multsect) 622 if (arg < 0 || arg > drive->id->max_multsect)
623 return -EINVAL; 623 return -EINVAL;
@@ -625,12 +625,13 @@ static int set_multcount(ide_drive_t *drive, int arg)
625 if (drive->special.b.set_multmode) 625 if (drive->special.b.set_multmode)
626 return -EBUSY; 626 return -EBUSY;
627 627
628 ide_init_drive_cmd(&rq); 628 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
629 rq.cmd_type = REQ_TYPE_ATA_TASKFILE; 629 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
630 630
631 drive->mult_req = arg; 631 drive->mult_req = arg;
632 drive->special.b.set_multmode = 1; 632 drive->special.b.set_multmode = 1;
633 (void)ide_do_drive_cmd(drive, &rq, ide_wait); 633 error = blk_execute_rq(drive->queue, NULL, rq, 0);
634 blk_put_request(rq);
634 635
635 return (drive->mult_count == arg) ? 0 : -EIO; 636 return (drive->mult_count == arg) ? 0 : -EIO;
636} 637}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 653b1ade13d..7ee44f86bc5 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -463,7 +463,7 @@ int ide_dma_setup(ide_drive_t *drive)
463 } 463 }
464 464
465 /* PRD table */ 465 /* PRD table */
466 if (hwif->mmio) 466 if (hwif->host_flags & IDE_HFLAG_MMIO)
467 writel(hwif->dmatable_dma, 467 writel(hwif->dmatable_dma,
468 (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); 468 (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS));
469 else 469 else
@@ -692,7 +692,7 @@ static int ide_tune_dma(ide_drive_t *drive)
692 ide_hwif_t *hwif = drive->hwif; 692 ide_hwif_t *hwif = drive->hwif;
693 u8 speed; 693 u8 speed;
694 694
695 if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) 695 if (drive->nodma || (drive->id->capability & 1) == 0)
696 return 0; 696 return 0;
697 697
698 /* consult the list of known "bad" drives */ 698 /* consult the list of known "bad" drives */
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f05fbc2bd7a..b3689437269 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -286,11 +286,12 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
286{ 286{
287 struct ide_floppy_obj *floppy = drive->driver_data; 287 struct ide_floppy_obj *floppy = drive->driver_data;
288 288
289 ide_init_drive_cmd(rq); 289 blk_rq_init(NULL, rq);
290 rq->buffer = (char *) pc; 290 rq->buffer = (char *) pc;
291 rq->cmd_type = REQ_TYPE_SPECIAL; 291 rq->cmd_type = REQ_TYPE_SPECIAL;
292 rq->cmd_flags |= REQ_PREEMPT;
292 rq->rq_disk = floppy->disk; 293 rq->rq_disk = floppy->disk;
293 (void) ide_do_drive_cmd(drive, rq, ide_preempt); 294 ide_do_drive_cmd(drive, rq);
294} 295}
295 296
296static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) 297static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
@@ -311,50 +312,41 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
311 return (&floppy->rq_stack[floppy->rq_stack_index++]); 312 return (&floppy->rq_stack[floppy->rq_stack_index++]);
312} 313}
313 314
314static void idefloppy_request_sense_callback(ide_drive_t *drive) 315static void ide_floppy_callback(ide_drive_t *drive)
315{ 316{
316 idefloppy_floppy_t *floppy = drive->driver_data; 317 idefloppy_floppy_t *floppy = drive->driver_data;
317 u8 *buf = floppy->pc->buf; 318 struct ide_atapi_pc *pc = floppy->pc;
319 int uptodate = pc->error ? 0 : 1;
318 320
319 debug_log("Reached %s\n", __func__); 321 debug_log("Reached %s\n", __func__);
320 322
321 if (!floppy->pc->error) { 323 if (floppy->failed_pc == pc)
322 floppy->sense_key = buf[2] & 0x0F; 324 floppy->failed_pc = NULL;
323 floppy->asc = buf[12];
324 floppy->ascq = buf[13];
325 floppy->progress_indication = buf[15] & 0x80 ?
326 (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
327 325
328 if (floppy->failed_pc) 326 if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
329 debug_log("pc = %x, sense key = %x, asc = %x," 327 (pc->rq && blk_pc_request(pc->rq)))
330 " ascq = %x\n", 328 uptodate = 1; /* FIXME */
331 floppy->failed_pc->c[0], 329 else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
332 floppy->sense_key, 330 u8 *buf = floppy->pc->buf;
333 floppy->asc,
334 floppy->ascq);
335 else
336 debug_log("sense key = %x, asc = %x, ascq = %x\n",
337 floppy->sense_key,
338 floppy->asc,
339 floppy->ascq);
340 331
332 if (!pc->error) {
333 floppy->sense_key = buf[2] & 0x0F;
334 floppy->asc = buf[12];
335 floppy->ascq = buf[13];
336 floppy->progress_indication = buf[15] & 0x80 ?
337 (u16)get_unaligned((u16 *)&buf[16]) : 0x10000;
341 338
342 idefloppy_end_request(drive, 1, 0); 339 if (floppy->failed_pc)
343 } else { 340 debug_log("pc = %x, ", floppy->failed_pc->c[0]);
344 printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
345 " request!\n");
346 idefloppy_end_request(drive, 0, 0);
347 }
348}
349 341
350/* General packet command callback function. */ 342 debug_log("sense key = %x, asc = %x, ascq = %x\n",
351static void idefloppy_pc_callback(ide_drive_t *drive) 343 floppy->sense_key, floppy->asc, floppy->ascq);
352{ 344 } else
353 idefloppy_floppy_t *floppy = drive->driver_data; 345 printk(KERN_ERR "Error in REQUEST SENSE itself - "
354 346 "Aborting request!\n");
355 debug_log("Reached %s\n", __func__); 347 }
356 348
357 idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0); 349 idefloppy_end_request(drive, uptodate, 0);
358} 350}
359 351
360static void idefloppy_init_pc(struct ide_atapi_pc *pc) 352static void idefloppy_init_pc(struct ide_atapi_pc *pc)
@@ -365,7 +357,7 @@ static void idefloppy_init_pc(struct ide_atapi_pc *pc)
365 pc->req_xfer = 0; 357 pc->req_xfer = 0;
366 pc->buf = pc->pc_buf; 358 pc->buf = pc->pc_buf;
367 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; 359 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
368 pc->idefloppy_callback = &idefloppy_pc_callback; 360 pc->callback = ide_floppy_callback;
369} 361}
370 362
371static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) 363static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
@@ -374,7 +366,6 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
374 pc->c[0] = GPCMD_REQUEST_SENSE; 366 pc->c[0] = GPCMD_REQUEST_SENSE;
375 pc->c[4] = 255; 367 pc->c[4] = 255;
376 pc->req_xfer = 18; 368 pc->req_xfer = 18;
377 pc->idefloppy_callback = &idefloppy_request_sense_callback;
378} 369}
379 370
380/* 371/*
@@ -397,174 +388,19 @@ static void idefloppy_retry_pc(ide_drive_t *drive)
397static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) 388static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)
398{ 389{
399 idefloppy_floppy_t *floppy = drive->driver_data; 390 idefloppy_floppy_t *floppy = drive->driver_data;
400 ide_hwif_t *hwif = drive->hwif;
401 struct ide_atapi_pc *pc = floppy->pc;
402 struct request *rq = pc->rq;
403 xfer_func_t *xferfunc;
404 unsigned int temp;
405 int dma_error = 0;
406 u16 bcount;
407 u8 stat, ireason;
408
409 debug_log("Reached %s interrupt handler\n", __func__);
410
411 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
412 dma_error = hwif->dma_ops->dma_end(drive);
413 if (dma_error) {
414 printk(KERN_ERR "%s: DMA %s error\n", drive->name,
415 rq_data_dir(rq) ? "write" : "read");
416 pc->flags |= PC_FLAG_DMA_ERROR;
417 } else {
418 pc->xferred = pc->req_xfer;
419 idefloppy_update_buffers(drive, pc);
420 }
421 debug_log("DMA finished\n");
422 }
423
424 /* Clear the interrupt */
425 stat = ide_read_status(drive);
426
427 /* No more interrupts */
428 if ((stat & DRQ_STAT) == 0) {
429 debug_log("Packet command completed, %d bytes transferred\n",
430 pc->xferred);
431 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
432
433 local_irq_enable_in_hardirq();
434
435 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
436 /* Error detected */
437 debug_log("%s: I/O error\n", drive->name);
438 rq->errors++;
439 if (pc->c[0] == GPCMD_REQUEST_SENSE) {
440 printk(KERN_ERR "ide-floppy: I/O error in "
441 "request sense command\n");
442 return ide_do_reset(drive);
443 }
444 /* Retry operation */
445 idefloppy_retry_pc(drive);
446 /* queued, but not started */
447 return ide_stopped;
448 }
449 pc->error = 0;
450 if (floppy->failed_pc == pc)
451 floppy->failed_pc = NULL;
452 /* Command finished - Call the callback function */
453 pc->idefloppy_callback(drive);
454 return ide_stopped;
455 }
456
457 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
458 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
459 printk(KERN_ERR "ide-floppy: The floppy wants to issue "
460 "more interrupts in DMA mode\n");
461 ide_dma_off(drive);
462 return ide_do_reset(drive);
463 }
464
465 /* Get the number of bytes to transfer */
466 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
467 hwif->INB(hwif->io_ports.lbam_addr);
468 /* on this interrupt */
469 ireason = hwif->INB(hwif->io_ports.nsect_addr);
470
471 if (ireason & CD) {
472 printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
473 return ide_do_reset(drive);
474 }
475 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
476 /* Hopefully, we will never get here */
477 printk(KERN_ERR "ide-floppy: We wanted to %s, ",
478 (ireason & IO) ? "Write" : "Read");
479 printk(KERN_ERR "but the floppy wants us to %s !\n",
480 (ireason & IO) ? "Read" : "Write");
481 return ide_do_reset(drive);
482 }
483 if (!(pc->flags & PC_FLAG_WRITING)) {
484 /* Reading - Check that we have enough space */
485 temp = pc->xferred + bcount;
486 if (temp > pc->req_xfer) {
487 if (temp > pc->buf_size) {
488 printk(KERN_ERR "ide-floppy: The floppy wants "
489 "to send us more data than expected "
490 "- discarding data\n");
491 ide_pad_transfer(drive, 0, bcount);
492
493 ide_set_handler(drive,
494 &idefloppy_pc_intr,
495 IDEFLOPPY_WAIT_CMD,
496 NULL);
497 return ide_started;
498 }
499 debug_log("The floppy wants to send us more data than"
500 " expected - allowing transfer\n");
501 }
502 }
503 if (pc->flags & PC_FLAG_WRITING)
504 xferfunc = hwif->output_data;
505 else
506 xferfunc = hwif->input_data;
507
508 if (pc->buf)
509 xferfunc(drive, NULL, pc->cur_pos, bcount);
510 else
511 ide_floppy_io_buffers(drive, pc, bcount,
512 !!(pc->flags & PC_FLAG_WRITING));
513
514 /* Update the current position */
515 pc->xferred += bcount;
516 pc->cur_pos += bcount;
517
518 /* And set the interrupt handler again */
519 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
520 return ide_started;
521}
522
523/*
524 * This is the original routine that did the packet transfer.
525 * It fails at high speeds on the Iomega ZIP drive, so there's a slower version
526 * for that drive below. The algorithm is chosen based on drive type
527 */
528static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
529{
530 ide_hwif_t *hwif = drive->hwif;
531 ide_startstop_t startstop;
532 idefloppy_floppy_t *floppy = drive->driver_data;
533 u8 ireason;
534
535 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
536 printk(KERN_ERR "ide-floppy: Strange, packet command "
537 "initiated yet DRQ isn't asserted\n");
538 return startstop;
539 }
540 ireason = hwif->INB(hwif->io_ports.nsect_addr);
541 if ((ireason & CD) == 0 || (ireason & IO)) {
542 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
543 "issuing a packet command\n");
544 return ide_do_reset(drive);
545 }
546 391
547 /* Set the interrupt routine */ 392 return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr,
548 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); 393 IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers,
549 394 idefloppy_retry_pc, NULL, ide_floppy_io_buffers);
550 /* Send the actual packet */
551 hwif->output_data(drive, NULL, floppy->pc->c, 12);
552
553 return ide_started;
554} 395}
555 396
556
557/* 397/*
558 * What we have here is a classic case of a top half / bottom half interrupt 398 * What we have here is a classic case of a top half / bottom half interrupt
559 * service routine. In interrupt mode, the device sends an interrupt to signal 399 * service routine. In interrupt mode, the device sends an interrupt to signal
560 * that it is ready to receive a packet. However, we need to delay about 2-3 400 * that it is ready to receive a packet. However, we need to delay about 2-3
561 * ticks before issuing the packet or we gets in trouble. 401 * ticks before issuing the packet or we gets in trouble.
562 *
563 * So, follow carefully. transfer_pc1 is called as an interrupt (or directly).
564 * In either case, when the device says it's ready for a packet, we schedule
565 * the packet transfer to occur about 2-3 ticks later in transfer_pc2.
566 */ 402 */
567static int idefloppy_transfer_pc2(ide_drive_t *drive) 403static int idefloppy_transfer_pc(ide_drive_t *drive)
568{ 404{
569 idefloppy_floppy_t *floppy = drive->driver_data; 405 idefloppy_floppy_t *floppy = drive->driver_data;
570 406
@@ -575,24 +411,19 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)
575 return IDEFLOPPY_WAIT_CMD; 411 return IDEFLOPPY_WAIT_CMD;
576} 412}
577 413
578static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) 414
415/*
416 * Called as an interrupt (or directly). When the device says it's ready for a
417 * packet, we schedule the packet transfer to occur about 2-3 ticks later in
418 * transfer_pc.
419 */
420static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive)
579{ 421{
580 ide_hwif_t *hwif = drive->hwif;
581 idefloppy_floppy_t *floppy = drive->driver_data; 422 idefloppy_floppy_t *floppy = drive->driver_data;
582 ide_startstop_t startstop; 423 struct ide_atapi_pc *pc = floppy->pc;
583 u8 ireason; 424 ide_expiry_t *expiry;
425 unsigned int timeout;
584 426
585 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
586 printk(KERN_ERR "ide-floppy: Strange, packet command "
587 "initiated yet DRQ isn't asserted\n");
588 return startstop;
589 }
590 ireason = hwif->INB(hwif->io_ports.nsect_addr);
591 if ((ireason & CD) == 0 || (ireason & IO)) {
592 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
593 "while issuing a packet command\n");
594 return ide_do_reset(drive);
595 }
596 /* 427 /*
597 * The following delay solves a problem with ATAPI Zip 100 drives 428 * The following delay solves a problem with ATAPI Zip 100 drives
598 * where the Busy flag was apparently being deasserted before the 429 * where the Busy flag was apparently being deasserted before the
@@ -601,10 +432,15 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
601 * 40 and 50msec work well. idefloppy_pc_intr will not be actually 432 * 40 and 50msec work well. idefloppy_pc_intr will not be actually
602 * used until after the packet is moved in about 50 msec. 433 * used until after the packet is moved in about 50 msec.
603 */ 434 */
435 if (pc->flags & PC_FLAG_ZIP_DRIVE) {
436 timeout = floppy->ticks;
437 expiry = &idefloppy_transfer_pc;
438 } else {
439 timeout = IDEFLOPPY_WAIT_CMD;
440 expiry = NULL;
441 }
604 442
605 ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, 443 return ide_transfer_pc(drive, pc, idefloppy_pc_intr, timeout, expiry);
606 &idefloppy_transfer_pc2);
607 return ide_started;
608} 444}
609 445
610static void ide_floppy_report_error(idefloppy_floppy_t *floppy, 446static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
@@ -627,10 +463,6 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
627 struct ide_atapi_pc *pc) 463 struct ide_atapi_pc *pc)
628{ 464{
629 idefloppy_floppy_t *floppy = drive->driver_data; 465 idefloppy_floppy_t *floppy = drive->driver_data;
630 ide_hwif_t *hwif = drive->hwif;
631 ide_handler_t *pkt_xfer_routine;
632 u16 bcount;
633 u8 dma;
634 466
635 if (floppy->failed_pc == NULL && 467 if (floppy->failed_pc == NULL &&
636 pc->c[0] != GPCMD_REQUEST_SENSE) 468 pc->c[0] != GPCMD_REQUEST_SENSE)
@@ -645,65 +477,16 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
645 pc->error = IDEFLOPPY_ERROR_GENERAL; 477 pc->error = IDEFLOPPY_ERROR_GENERAL;
646 478
647 floppy->failed_pc = NULL; 479 floppy->failed_pc = NULL;
648 pc->idefloppy_callback(drive); 480 pc->callback(drive);
649 return ide_stopped; 481 return ide_stopped;
650 } 482 }
651 483
652 debug_log("Retry number - %d\n", pc->retries); 484 debug_log("Retry number - %d\n", pc->retries);
653 485
654 pc->retries++; 486 pc->retries++;
655 /* We haven't transferred any data yet */
656 pc->xferred = 0;
657 pc->cur_pos = pc->buf;
658 bcount = min(pc->req_xfer, 63 * 1024);
659
660 if (pc->flags & PC_FLAG_DMA_ERROR) {
661 pc->flags &= ~PC_FLAG_DMA_ERROR;
662 ide_dma_off(drive);
663 }
664 dma = 0;
665
666 if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma)
667 dma = !hwif->dma_ops->dma_setup(drive);
668 487
669 ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | 488 return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer,
670 IDE_TFLAG_OUT_DEVICE, bcount, dma); 489 IDEFLOPPY_WAIT_CMD, NULL);
671
672 if (dma) {
673 /* Begin DMA, if necessary */
674 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
675 hwif->dma_ops->dma_start(drive);
676 }
677
678 /* Can we transfer the packet when we get the interrupt or wait? */
679 if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE) {
680 /* wait */
681 pkt_xfer_routine = &idefloppy_transfer_pc1;
682 } else {
683 /* immediate */
684 pkt_xfer_routine = &idefloppy_transfer_pc;
685 }
686
687 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) {
688 /* Issue the packet command */
689 ide_execute_command(drive, WIN_PACKETCMD,
690 pkt_xfer_routine,
691 IDEFLOPPY_WAIT_CMD,
692 NULL);
693 return ide_started;
694 } else {
695 /* Issue the packet command */
696 ide_execute_pkt_cmd(drive);
697 return (*pkt_xfer_routine) (drive);
698 }
699}
700
701static void idefloppy_rw_callback(ide_drive_t *drive)
702{
703 debug_log("Reached %s\n", __func__);
704
705 idefloppy_end_request(drive, 1, 0);
706 return;
707} 490}
708 491
709static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) 492static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent)
@@ -800,21 +583,19 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
800 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); 583 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
801 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); 584 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
802 585
803 pc->idefloppy_callback = &idefloppy_rw_callback;
804 pc->rq = rq; 586 pc->rq = rq;
805 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; 587 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
806 if (rq->cmd_flags & REQ_RW) 588 if (rq->cmd_flags & REQ_RW)
807 pc->flags |= PC_FLAG_WRITING; 589 pc->flags |= PC_FLAG_WRITING;
808 pc->buf = NULL; 590 pc->buf = NULL;
809 pc->req_xfer = pc->buf_size = blocks * floppy->block_size; 591 pc->req_xfer = pc->buf_size = blocks * floppy->block_size;
810 pc->flags |= PC_FLAG_DMA_RECOMMENDED; 592 pc->flags |= PC_FLAG_DMA_OK;
811} 593}
812 594
813static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, 595static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
814 struct ide_atapi_pc *pc, struct request *rq) 596 struct ide_atapi_pc *pc, struct request *rq)
815{ 597{
816 idefloppy_init_pc(pc); 598 idefloppy_init_pc(pc);
817 pc->idefloppy_callback = &idefloppy_rw_callback;
818 memcpy(pc->c, rq->cmd, sizeof(pc->c)); 599 memcpy(pc->c, rq->cmd, sizeof(pc->c));
819 pc->rq = rq; 600 pc->rq = rq;
820 pc->b_count = rq->data_len; 601 pc->b_count = rq->data_len;
@@ -822,7 +603,7 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
822 pc->flags |= PC_FLAG_WRITING; 603 pc->flags |= PC_FLAG_WRITING;
823 pc->buf = rq->data; 604 pc->buf = rq->data;
824 if (rq->bio) 605 if (rq->bio)
825 pc->flags |= PC_FLAG_DMA_RECOMMENDED; 606 pc->flags |= PC_FLAG_DMA_OK;
826 /* 607 /*
827 * possibly problematic, doesn't look like ide-floppy correctly 608 * possibly problematic, doesn't look like ide-floppy correctly
828 * handled scattered requests if dma fails... 609 * handled scattered requests if dma fails...
@@ -875,7 +656,14 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
875 return ide_stopped; 656 return ide_stopped;
876 } 657 }
877 658
659 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT)
660 pc->flags |= PC_FLAG_DRQ_INTERRUPT;
661
662 if (floppy->flags & IDEFLOPPY_FLAG_ZIP_DRIVE)
663 pc->flags |= PC_FLAG_ZIP_DRIVE;
664
878 pc->rq = rq; 665 pc->rq = rq;
666
879 return idefloppy_issue_pc(drive, pc); 667 return idefloppy_issue_pc(drive, pc);
880} 668}
881 669
@@ -886,14 +674,16 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
886static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) 674static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc)
887{ 675{
888 struct ide_floppy_obj *floppy = drive->driver_data; 676 struct ide_floppy_obj *floppy = drive->driver_data;
889 struct request rq; 677 struct request *rq;
678 int error;
890 679
891 ide_init_drive_cmd(&rq); 680 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
892 rq.buffer = (char *) pc; 681 rq->buffer = (char *) pc;
893 rq.cmd_type = REQ_TYPE_SPECIAL; 682 rq->cmd_type = REQ_TYPE_SPECIAL;
894 rq.rq_disk = floppy->disk; 683 error = blk_execute_rq(drive->queue, floppy->disk, rq, 0);
684 blk_put_request(rq);
895 685
896 return ide_do_drive_cmd(drive, &rq, ide_wait); 686 return error;
897} 687}
898 688
899/* 689/*
@@ -1622,11 +1412,6 @@ static int ide_floppy_probe(ide_drive_t *drive)
1622 " of ide-floppy\n", drive->name); 1412 " of ide-floppy\n", drive->name);
1623 goto failed; 1413 goto failed;
1624 } 1414 }
1625 if (drive->scsi) {
1626 printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi"
1627 " emulation.\n", drive->name);
1628 goto failed;
1629 }
1630 floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); 1415 floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL);
1631 if (!floppy) { 1416 if (!floppy) {
1632 printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" 1417 printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy"
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 696525342e9..28057747c1f 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -358,31 +358,6 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
358 358
359EXPORT_SYMBOL(ide_end_drive_cmd); 359EXPORT_SYMBOL(ide_end_drive_cmd);
360 360
361/**
362 * try_to_flush_leftover_data - flush junk
363 * @drive: drive to flush
364 *
365 * try_to_flush_leftover_data() is invoked in response to a drive
366 * unexpectedly having its DRQ_STAT bit set. As an alternative to
367 * resetting the drive, this routine tries to clear the condition
368 * by read a sector's worth of data from the drive. Of course,
369 * this may not help if the drive is *waiting* for data from *us*.
370 */
371static void try_to_flush_leftover_data (ide_drive_t *drive)
372{
373 int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS;
374
375 if (drive->media != ide_disk)
376 return;
377 while (i > 0) {
378 u32 buffer[16];
379 u32 wcount = (i > 16) ? 16 : i;
380
381 i -= wcount;
382 drive->hwif->input_data(drive, NULL, buffer, wcount * 4);
383 }
384}
385
386static void ide_kill_rq(ide_drive_t *drive, struct request *rq) 361static void ide_kill_rq(ide_drive_t *drive, struct request *rq)
387{ 362{
388 if (rq->rq_disk) { 363 if (rq->rq_disk) {
@@ -422,8 +397,11 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
422 } 397 }
423 398
424 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && 399 if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ &&
425 (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) 400 (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) {
426 try_to_flush_leftover_data(drive); 401 int nsect = drive->mult_count ? drive->mult_count : 1;
402
403 ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE);
404 }
427 405
428 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) { 406 if (rq->errors >= ERROR_MAX || blk_noretry_request(rq)) {
429 ide_kill_rq(drive, rq); 407 ide_kill_rq(drive, rq);
@@ -459,7 +437,7 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
459 437
460 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 438 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
461 /* force an abort */ 439 /* force an abort */
462 hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE, 440 hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE,
463 hwif->io_ports.command_addr); 441 hwif->io_ports.command_addr);
464 442
465 if (rq->errors >= ERROR_MAX) { 443 if (rq->errors >= ERROR_MAX) {
@@ -1539,88 +1517,30 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1539} 1517}
1540 1518
1541/** 1519/**
1542 * ide_init_drive_cmd - initialize a drive command request
1543 * @rq: request object
1544 *
1545 * Initialize a request before we fill it in and send it down to
1546 * ide_do_drive_cmd. Commands must be set up by this function. Right
1547 * now it doesn't do a lot, but if that changes abusers will have a
1548 * nasty surprise.
1549 */
1550
1551void ide_init_drive_cmd (struct request *rq)
1552{
1553 blk_rq_init(NULL, rq);
1554}
1555
1556EXPORT_SYMBOL(ide_init_drive_cmd);
1557
1558/**
1559 * ide_do_drive_cmd - issue IDE special command 1520 * ide_do_drive_cmd - issue IDE special command
1560 * @drive: device to issue command 1521 * @drive: device to issue command
1561 * @rq: request to issue 1522 * @rq: request to issue
1562 * @action: action for processing
1563 * 1523 *
1564 * This function issues a special IDE device request 1524 * This function issues a special IDE device request
1565 * onto the request queue. 1525 * onto the request queue.
1566 * 1526 *
1567 * If action is ide_wait, then the rq is queued at the end of the 1527 * the rq is queued at the head of the request queue, displacing
1568 * request queue, and the function sleeps until it has been processed. 1528 * the currently-being-processed request and this function
1569 * This is for use when invoked from an ioctl handler. 1529 * returns immediately without waiting for the new rq to be
1570 * 1530 * completed. This is VERY DANGEROUS, and is intended for
1571 * If action is ide_preempt, then the rq is queued at the head of 1531 * careful use by the ATAPI tape/cdrom driver code.
1572 * the request queue, displacing the currently-being-processed
1573 * request and this function returns immediately without waiting
1574 * for the new rq to be completed. This is VERY DANGEROUS, and is
1575 * intended for careful use by the ATAPI tape/cdrom driver code.
1576 *
1577 * If action is ide_end, then the rq is queued at the end of the
1578 * request queue, and the function returns immediately without waiting
1579 * for the new rq to be completed. This is again intended for careful
1580 * use by the ATAPI tape/cdrom driver code.
1581 */ 1532 */
1582 1533
1583int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action) 1534void ide_do_drive_cmd(ide_drive_t *drive, struct request *rq)
1584{ 1535{
1585 unsigned long flags; 1536 unsigned long flags;
1586 ide_hwgroup_t *hwgroup = HWGROUP(drive); 1537 ide_hwgroup_t *hwgroup = HWGROUP(drive);
1587 DECLARE_COMPLETION_ONSTACK(wait);
1588 int where = ELEVATOR_INSERT_BACK, err;
1589 int must_wait = (action == ide_wait || action == ide_head_wait);
1590
1591 rq->errors = 0;
1592
1593 /*
1594 * we need to hold an extra reference to request for safe inspection
1595 * after completion
1596 */
1597 if (must_wait) {
1598 rq->ref_count++;
1599 rq->end_io_data = &wait;
1600 rq->end_io = blk_end_sync_rq;
1601 }
1602 1538
1603 spin_lock_irqsave(&ide_lock, flags); 1539 spin_lock_irqsave(&ide_lock, flags);
1604 if (action == ide_preempt) 1540 hwgroup->rq = NULL;
1605 hwgroup->rq = NULL; 1541 __elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 1);
1606 if (action == ide_preempt || action == ide_head_wait) { 1542 __generic_unplug_device(drive->queue);
1607 where = ELEVATOR_INSERT_FRONT;
1608 rq->cmd_flags |= REQ_PREEMPT;
1609 }
1610 __elv_add_request(drive->queue, rq, where, 0);
1611 ide_do_request(hwgroup, IDE_NO_IRQ);
1612 spin_unlock_irqrestore(&ide_lock, flags); 1543 spin_unlock_irqrestore(&ide_lock, flags);
1613
1614 err = 0;
1615 if (must_wait) {
1616 wait_for_completion(&wait);
1617 if (rq->errors)
1618 err = -EIO;
1619
1620 blk_put_request(rq);
1621 }
1622
1623 return err;
1624} 1544}
1625 1545
1626EXPORT_SYMBOL(ide_do_drive_cmd); 1546EXPORT_SYMBOL(ide_do_drive_cmd);
@@ -1637,6 +1557,8 @@ void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount, u8 dma)
1637 task.tf.lbah = (bcount >> 8) & 0xff; 1557 task.tf.lbah = (bcount >> 8) & 0xff;
1638 1558
1639 ide_tf_dump(drive->name, &task.tf); 1559 ide_tf_dump(drive->name, &task.tf);
1560 ide_set_irq(drive, 1);
1561 SELECT_MASK(drive, 0);
1640 drive->hwif->tf_load(drive, &task); 1562 drive->hwif->tf_load(drive, &task);
1641} 1563}
1642 1564
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 0daf923541f..80ad4f234f3 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -42,7 +42,7 @@ static void ide_outb (u8 val, unsigned long port)
42 outb(val, port); 42 outb(val, port);
43} 43}
44 44
45static void ide_outbsync (ide_drive_t *drive, u8 addr, unsigned long port) 45static void ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port)
46{ 46{
47 outb(addr, port); 47 outb(addr, port);
48} 48}
@@ -68,7 +68,7 @@ static void ide_mm_outb (u8 value, unsigned long port)
68 writeb(value, (void __iomem *) port); 68 writeb(value, (void __iomem *) port);
69} 69}
70 70
71static void ide_mm_outbsync (ide_drive_t *drive, u8 value, unsigned long port) 71static void ide_mm_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
72{ 72{
73 writeb(value, (void __iomem *) port); 73 writeb(value, (void __iomem *) port);
74} 74}
@@ -95,7 +95,7 @@ void SELECT_DRIVE (ide_drive_t *drive)
95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); 95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
96} 96}
97 97
98static void SELECT_MASK(ide_drive_t *drive, int mask) 98void SELECT_MASK(ide_drive_t *drive, int mask)
99{ 99{
100 const struct ide_port_ops *port_ops = drive->hwif->port_ops; 100 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
101 101
@@ -120,11 +120,6 @@ static void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
120 if (task->tf_flags & IDE_TFLAG_FLAGGED) 120 if (task->tf_flags & IDE_TFLAG_FLAGGED)
121 HIHI = 0xFF; 121 HIHI = 0xFF;
122 122
123 ide_set_irq(drive, 1);
124
125 if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0)
126 SELECT_MASK(drive, 0);
127
128 if (task->tf_flags & IDE_TFLAG_OUT_DATA) { 123 if (task->tf_flags & IDE_TFLAG_OUT_DATA) {
129 u16 data = (tf->hob_data << 8) | tf->data; 124 u16 data = (tf->hob_data << 8) | tf->data;
130 125
@@ -191,7 +186,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
191 } 186 }
192 187
193 /* be sure we're looking at the low order bits */ 188 /* be sure we're looking at the low order bits */
194 tf_outb(drive->ctl & ~0x80, io_ports->ctl_addr); 189 tf_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
195 190
196 if (task->tf_flags & IDE_TFLAG_IN_NSECT) 191 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
197 tf->nsect = tf_inb(io_ports->nsect_addr); 192 tf->nsect = tf_inb(io_ports->nsect_addr);
@@ -205,7 +200,7 @@ static void ide_tf_read(ide_drive_t *drive, ide_task_t *task)
205 tf->device = tf_inb(io_ports->device_addr); 200 tf->device = tf_inb(io_ports->device_addr);
206 201
207 if (task->tf_flags & IDE_TFLAG_LBA48) { 202 if (task->tf_flags & IDE_TFLAG_LBA48) {
208 tf_outb(drive->ctl | 0x80, io_ports->ctl_addr); 203 tf_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
209 204
210 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) 205 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
211 tf->hob_feature = tf_inb(io_ports->feature_addr); 206 tf->hob_feature = tf_inb(io_ports->feature_addr);
@@ -689,9 +684,9 @@ int ide_driveid_update(ide_drive_t *drive)
689 */ 684 */
690 685
691 SELECT_MASK(drive, 1); 686 SELECT_MASK(drive, 1);
692 ide_set_irq(drive, 1); 687 ide_set_irq(drive, 0);
693 msleep(50); 688 msleep(50);
694 hwif->OUTBSYNC(drive, WIN_IDENTIFY, hwif->io_ports.command_addr); 689 hwif->OUTBSYNC(hwif, WIN_IDENTIFY, hwif->io_ports.command_addr);
695 timeout = jiffies + WAIT_WORSTCASE; 690 timeout = jiffies + WAIT_WORSTCASE;
696 do { 691 do {
697 if (time_after(jiffies, timeout)) { 692 if (time_after(jiffies, timeout)) {
@@ -744,9 +739,6 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
744 int error = 0; 739 int error = 0;
745 u8 stat; 740 u8 stat;
746 741
747// while (HWGROUP(drive)->busy)
748// msleep(50);
749
750#ifdef CONFIG_BLK_DEV_IDEDMA 742#ifdef CONFIG_BLK_DEV_IDEDMA
751 if (hwif->dma_ops) /* check if host supports DMA */ 743 if (hwif->dma_ops) /* check if host supports DMA */
752 hwif->dma_ops->dma_host_set(drive, 0); 744 hwif->dma_ops->dma_host_set(drive, 0);
@@ -781,7 +773,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
781 ide_set_irq(drive, 0); 773 ide_set_irq(drive, 0);
782 hwif->OUTB(speed, io_ports->nsect_addr); 774 hwif->OUTB(speed, io_ports->nsect_addr);
783 hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr); 775 hwif->OUTB(SETFEATURES_XFER, io_ports->feature_addr);
784 hwif->OUTBSYNC(drive, WIN_SETFEATURES, io_ports->command_addr); 776 hwif->OUTBSYNC(hwif, WIN_SETFEATURES, io_ports->command_addr);
785 if (drive->quirk_list == 2) 777 if (drive->quirk_list == 2)
786 ide_set_irq(drive, 1); 778 ide_set_irq(drive, 1);
787 779
@@ -889,7 +881,7 @@ void ide_execute_command(ide_drive_t *drive, u8 cmd, ide_handler_t *handler,
889 881
890 spin_lock_irqsave(&ide_lock, flags); 882 spin_lock_irqsave(&ide_lock, flags);
891 __ide_set_handler(drive, handler, timeout, expiry); 883 __ide_set_handler(drive, handler, timeout, expiry);
892 hwif->OUTBSYNC(drive, cmd, hwif->io_ports.command_addr); 884 hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr);
893 /* 885 /*
894 * Drive takes 400nS to respond, we must avoid the IRQ being 886 * Drive takes 400nS to respond, we must avoid the IRQ being
895 * serviced before that. 887 * serviced before that.
@@ -907,7 +899,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive)
907 unsigned long flags; 899 unsigned long flags;
908 900
909 spin_lock_irqsave(&ide_lock, flags); 901 spin_lock_irqsave(&ide_lock, flags);
910 hwif->OUTBSYNC(drive, WIN_PACKETCMD, hwif->io_ports.command_addr); 902 hwif->OUTBSYNC(hwif, WIN_PACKETCMD, hwif->io_ports.command_addr);
911 ndelay(400); 903 ndelay(400);
912 spin_unlock_irqrestore(&ide_lock, flags); 904 spin_unlock_irqrestore(&ide_lock, flags);
913} 905}
@@ -1102,7 +1094,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1102 pre_reset(drive); 1094 pre_reset(drive);
1103 SELECT_DRIVE(drive); 1095 SELECT_DRIVE(drive);
1104 udelay (20); 1096 udelay (20);
1105 hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); 1097 hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr);
1106 ndelay(400); 1098 ndelay(400);
1107 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1099 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
1108 hwgroup->polling = 1; 1100 hwgroup->polling = 1;
@@ -1133,14 +1125,14 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
1133 * recover from reset very quickly, saving us the first 50ms wait time. 1125 * recover from reset very quickly, saving us the first 50ms wait time.
1134 */ 1126 */
1135 /* set SRST and nIEN */ 1127 /* set SRST and nIEN */
1136 hwif->OUTBSYNC(drive, drive->ctl|6, io_ports->ctl_addr); 1128 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | 6, io_ports->ctl_addr);
1137 /* more than enough time */ 1129 /* more than enough time */
1138 udelay(10); 1130 udelay(10);
1139 if (drive->quirk_list == 2) 1131 if (drive->quirk_list == 2)
1140 ctl = drive->ctl; /* clear SRST and nIEN */ 1132 ctl = ATA_DEVCTL_OBS; /* clear SRST and nIEN */
1141 else 1133 else
1142 ctl = drive->ctl | 2; /* clear SRST, leave nIEN */ 1134 ctl = ATA_DEVCTL_OBS | 2; /* clear SRST, leave nIEN */
1143 hwif->OUTBSYNC(drive, ctl, io_ports->ctl_addr); 1135 hwif->OUTBSYNC(hwif, ctl, io_ports->ctl_addr);
1144 /* more than enough time */ 1136 /* more than enough time */
1145 udelay(10); 1137 udelay(10);
1146 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; 1138 hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE;
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 26e68b65b7c..d21e51a02c3 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -293,7 +293,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
293 hwif->OUTB(0, io_ports->feature_addr); 293 hwif->OUTB(0, io_ports->feature_addr);
294 294
295 /* ask drive for ID */ 295 /* ask drive for ID */
296 hwif->OUTBSYNC(drive, cmd, io_ports->command_addr); 296 hwif->OUTBSYNC(hwif, cmd, hwif->io_ports.command_addr);
297 297
298 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 298 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
299 timeout += jiffies; 299 timeout += jiffies;
@@ -478,9 +478,9 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
478 printk(KERN_ERR "%s: no response (status = 0x%02x), " 478 printk(KERN_ERR "%s: no response (status = 0x%02x), "
479 "resetting drive\n", drive->name, stat); 479 "resetting drive\n", drive->name, stat);
480 msleep(50); 480 msleep(50);
481 hwif->OUTB(drive->select.all, io_ports->device_addr); 481 SELECT_DRIVE(drive);
482 msleep(50); 482 msleep(50);
483 hwif->OUTBSYNC(drive, WIN_SRST, io_ports->command_addr); 483 hwif->OUTBSYNC(hwif, WIN_SRST, io_ports->command_addr);
484 (void)ide_busy_sleep(hwif); 484 (void)ide_busy_sleep(hwif);
485 rc = try_to_identify(drive, cmd); 485 rc = try_to_identify(drive, cmd);
486 } 486 }
@@ -516,7 +516,7 @@ static void enable_nest (ide_drive_t *drive)
516 printk("%s: enabling %s -- ", hwif->name, drive->id->model); 516 printk("%s: enabling %s -- ", hwif->name, drive->id->model);
517 SELECT_DRIVE(drive); 517 SELECT_DRIVE(drive);
518 msleep(50); 518 msleep(50);
519 hwif->OUTBSYNC(drive, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); 519 hwif->OUTBSYNC(hwif, EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr);
520 520
521 if (ide_busy_sleep(hwif)) { 521 if (ide_busy_sleep(hwif)) {
522 printk(KERN_CONT "failed (timeout)\n"); 522 printk(KERN_CONT "failed (timeout)\n");
@@ -1065,7 +1065,7 @@ static int init_irq (ide_hwif_t *hwif)
1065 1065
1066 if (io_ports->ctl_addr) 1066 if (io_ports->ctl_addr)
1067 /* clear nIEN */ 1067 /* clear nIEN */
1068 hwif->OUTB(0x08, io_ports->ctl_addr); 1068 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS, io_ports->ctl_addr);
1069 1069
1070 if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) 1070 if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup))
1071 goto out_unlink; 1071 goto out_unlink;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index a3d228302d2..f9cf1670e4e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -144,9 +144,6 @@ enum {
144 144
145/*************************** End of tunable parameters ***********************/ 145/*************************** End of tunable parameters ***********************/
146 146
147/* Read/Write error simulation */
148#define SIMULATE_ERRORS 0
149
150/* tape directions */ 147/* tape directions */
151enum { 148enum {
152 IDETAPE_DIR_NONE = (1 << 0), 149 IDETAPE_DIR_NONE = (1 << 0),
@@ -442,7 +439,7 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
442 } 439 }
443} 440}
444 441
445static void idetape_update_buffers(struct ide_atapi_pc *pc) 442static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc)
446{ 443{
447 struct idetape_bh *bh = pc->bh; 444 struct idetape_bh *bh = pc->bh;
448 int count; 445 int count;
@@ -506,18 +503,6 @@ static struct request *idetape_next_rq_storage(ide_drive_t *drive)
506 return (&tape->rq_stack[tape->rq_stack_index++]); 503 return (&tape->rq_stack[tape->rq_stack_index++]);
507} 504}
508 505
509static void idetape_init_pc(struct ide_atapi_pc *pc)
510{
511 memset(pc->c, 0, 12);
512 pc->retries = 0;
513 pc->flags = 0;
514 pc->req_xfer = 0;
515 pc->buf = pc->pc_buf;
516 pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
517 pc->bh = NULL;
518 pc->b_data = NULL;
519}
520
521/* 506/*
522 * called on each failed packet command retry to analyze the request sense. We 507 * called on each failed packet command retry to analyze the request sense. We
523 * currently do not utilize this information. 508 * currently do not utilize this information.
@@ -538,8 +523,8 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
538 if (pc->flags & PC_FLAG_DMA_ERROR) { 523 if (pc->flags & PC_FLAG_DMA_ERROR) {
539 pc->xferred = pc->req_xfer - 524 pc->xferred = pc->req_xfer -
540 tape->blk_size * 525 tape->blk_size *
541 be32_to_cpu(get_unaligned((u32 *)&sense[3])); 526 get_unaligned_be32(&sense[3]);
542 idetape_update_buffers(pc); 527 idetape_update_buffers(drive, pc);
543 } 528 }
544 529
545 /* 530 /*
@@ -634,21 +619,78 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects)
634 return 0; 619 return 0;
635} 620}
636 621
637static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) 622static void ide_tape_callback(ide_drive_t *drive)
638{ 623{
639 idetape_tape_t *tape = drive->driver_data; 624 idetape_tape_t *tape = drive->driver_data;
625 struct ide_atapi_pc *pc = tape->pc;
626 int uptodate = pc->error ? 0 : 1;
640 627
641 debug_log(DBG_PROCS, "Enter %s\n", __func__); 628 debug_log(DBG_PROCS, "Enter %s\n", __func__);
642 629
643 if (!tape->pc->error) { 630 if (tape->failed_pc == pc)
644 idetape_analyze_error(drive, tape->pc->buf); 631 tape->failed_pc = NULL;
645 idetape_end_request(drive, 1, 0); 632
646 } else { 633 if (pc->c[0] == REQUEST_SENSE) {
647 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " 634 if (uptodate)
648 "Aborting request!\n"); 635 idetape_analyze_error(drive, pc->buf);
649 idetape_end_request(drive, 0, 0); 636 else
637 printk(KERN_ERR "ide-tape: Error in REQUEST SENSE "
638 "itself - Aborting request!\n");
639 } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
640 struct request *rq = drive->hwif->hwgroup->rq;
641 int blocks = pc->xferred / tape->blk_size;
642
643 tape->avg_size += blocks * tape->blk_size;
644
645 if (time_after_eq(jiffies, tape->avg_time + HZ)) {
646 tape->avg_speed = tape->avg_size * HZ /
647 (jiffies - tape->avg_time) / 1024;
648 tape->avg_size = 0;
649 tape->avg_time = jiffies;
650 }
651
652 tape->first_frame += blocks;
653 rq->current_nr_sectors -= blocks;
654
655 if (pc->error)
656 uptodate = pc->error;
657 } else if (pc->c[0] == READ_POSITION && uptodate) {
658 u8 *readpos = tape->pc->buf;
659
660 debug_log(DBG_SENSE, "BOP - %s\n",
661 (readpos[0] & 0x80) ? "Yes" : "No");
662 debug_log(DBG_SENSE, "EOP - %s\n",
663 (readpos[0] & 0x40) ? "Yes" : "No");
664
665 if (readpos[0] & 0x4) {
666 printk(KERN_INFO "ide-tape: Block location is unknown"
667 "to the tape\n");
668 clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags);
669 uptodate = 0;
670 } else {
671 debug_log(DBG_SENSE, "Block Location - %u\n",
672 be32_to_cpu(*(u32 *)&readpos[4]));
673
674 tape->partition = readpos[1];
675 tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]);
676 set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags);
677 }
650 } 678 }
651 return ide_stopped; 679
680 idetape_end_request(drive, uptodate, 0);
681}
682
683static void idetape_init_pc(struct ide_atapi_pc *pc)
684{
685 memset(pc->c, 0, 12);
686 pc->retries = 0;
687 pc->flags = 0;
688 pc->req_xfer = 0;
689 pc->buf = pc->pc_buf;
690 pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
691 pc->bh = NULL;
692 pc->b_data = NULL;
693 pc->callback = ide_tape_callback;
652} 694}
653 695
654static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) 696static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
@@ -657,7 +699,6 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
657 pc->c[0] = REQUEST_SENSE; 699 pc->c[0] = REQUEST_SENSE;
658 pc->c[4] = 20; 700 pc->c[4] = 20;
659 pc->req_xfer = 20; 701 pc->req_xfer = 20;
660 pc->idetape_callback = &idetape_request_sense_callback;
661} 702}
662 703
663static void idetape_init_rq(struct request *rq, u8 cmd) 704static void idetape_init_rq(struct request *rq, u8 cmd)
@@ -688,9 +729,10 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
688 struct ide_tape_obj *tape = drive->driver_data; 729 struct ide_tape_obj *tape = drive->driver_data;
689 730
690 idetape_init_rq(rq, REQ_IDETAPE_PC1); 731 idetape_init_rq(rq, REQ_IDETAPE_PC1);
732 rq->cmd_flags |= REQ_PREEMPT;
691 rq->buffer = (char *) pc; 733 rq->buffer = (char *) pc;
692 rq->rq_disk = tape->disk; 734 rq->rq_disk = tape->disk;
693 (void) ide_do_drive_cmd(drive, rq, ide_preempt); 735 ide_do_drive_cmd(drive, rq);
694} 736}
695 737
696/* 738/*
@@ -698,7 +740,7 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
698 * last packet command. We queue a request sense packet command in 740 * last packet command. We queue a request sense packet command in
699 * the head of the request list. 741 * the head of the request list.
700 */ 742 */
701static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) 743static void idetape_retry_pc(ide_drive_t *drive)
702{ 744{
703 idetape_tape_t *tape = drive->driver_data; 745 idetape_tape_t *tape = drive->driver_data;
704 struct ide_atapi_pc *pc; 746 struct ide_atapi_pc *pc;
@@ -710,7 +752,6 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive)
710 idetape_create_request_sense_cmd(pc); 752 idetape_create_request_sense_cmd(pc);
711 set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); 753 set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags);
712 idetape_queue_pc_head(drive, pc, rq); 754 idetape_queue_pc_head(drive, pc, rq);
713 return ide_stopped;
714} 755}
715 756
716/* 757/*
@@ -727,7 +768,26 @@ static void idetape_postpone_request(ide_drive_t *drive)
727 ide_stall_queue(drive, tape->dsc_poll_freq); 768 ide_stall_queue(drive, tape->dsc_poll_freq);
728} 769}
729 770
730typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); 771static void ide_tape_handle_dsc(ide_drive_t *drive)
772{
773 idetape_tape_t *tape = drive->driver_data;
774
775 /* Media access command */
776 tape->dsc_polling_start = jiffies;
777 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST;
778 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
779 /* Allow ide.c to handle other requests */
780 idetape_postpone_request(drive);
781}
782
783static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
784 unsigned int bcount, int write)
785{
786 if (write)
787 idetape_output_buffers(drive, pc, bcount);
788 else
789 idetape_input_buffers(drive, pc, bcount);
790}
731 791
732/* 792/*
733 * This is the usual interrupt handler which will be called during a packet 793 * This is the usual interrupt handler which will be called during a packet
@@ -738,169 +798,11 @@ typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int);
738 */ 798 */
739static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) 799static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
740{ 800{
741 ide_hwif_t *hwif = drive->hwif;
742 idetape_tape_t *tape = drive->driver_data; 801 idetape_tape_t *tape = drive->driver_data;
743 struct ide_atapi_pc *pc = tape->pc;
744 xfer_func_t *xferfunc;
745 idetape_io_buf *iobuf;
746 unsigned int temp;
747#if SIMULATE_ERRORS
748 static int error_sim_count;
749#endif
750 u16 bcount;
751 u8 stat, ireason;
752
753 debug_log(DBG_PROCS, "Enter %s - interrupt handler\n", __func__);
754
755 /* Clear the interrupt */
756 stat = ide_read_status(drive);
757
758 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
759 if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) {
760 /*
761 * A DMA error is sometimes expected. For example,
762 * if the tape is crossing a filemark during a
763 * READ command, it will issue an irq and position
764 * itself before the filemark, so that only a partial
765 * data transfer will occur (which causes the DMA
766 * error). In that case, we will later ask the tape
767 * how much bytes of the original request were
768 * actually transferred (we can't receive that
769 * information from the DMA engine on most chipsets).
770 */
771
772 /*
773 * On the contrary, a DMA error is never expected;
774 * it usually indicates a hardware error or abort.
775 * If the tape crosses a filemark during a READ
776 * command, it will issue an irq and position itself
777 * after the filemark (not before). Only a partial
778 * data transfer will occur, but no DMA error.
779 * (AS, 19 Apr 2001)
780 */
781 pc->flags |= PC_FLAG_DMA_ERROR;
782 } else {
783 pc->xferred = pc->req_xfer;
784 idetape_update_buffers(pc);
785 }
786 debug_log(DBG_PROCS, "DMA finished\n");
787
788 }
789
790 /* No more interrupts */
791 if ((stat & DRQ_STAT) == 0) {
792 debug_log(DBG_SENSE, "Packet command completed, %d bytes"
793 " transferred\n", pc->xferred);
794
795 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
796 local_irq_enable();
797
798#if SIMULATE_ERRORS
799 if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) &&
800 (++error_sim_count % 100) == 0) {
801 printk(KERN_INFO "ide-tape: %s: simulating error\n",
802 tape->name);
803 stat |= ERR_STAT;
804 }
805#endif
806 if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
807 stat &= ~ERR_STAT;
808 if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) {
809 /* Error detected */
810 debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
811
812 if (pc->c[0] == REQUEST_SENSE) {
813 printk(KERN_ERR "ide-tape: I/O error in request"
814 " sense command\n");
815 return ide_do_reset(drive);
816 }
817 debug_log(DBG_ERR, "[cmd %x]: check condition\n",
818 pc->c[0]);
819
820 /* Retry operation */
821 return idetape_retry_pc(drive);
822 }
823 pc->error = 0;
824 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
825 (stat & SEEK_STAT) == 0) {
826 /* Media access command */
827 tape->dsc_polling_start = jiffies;
828 tape->dsc_poll_freq = IDETAPE_DSC_MA_FAST;
829 tape->dsc_timeout = jiffies + IDETAPE_DSC_MA_TIMEOUT;
830 /* Allow ide.c to handle other requests */
831 idetape_postpone_request(drive);
832 return ide_stopped;
833 }
834 if (tape->failed_pc == pc)
835 tape->failed_pc = NULL;
836 /* Command finished - Call the callback function */
837 return pc->idetape_callback(drive);
838 }
839
840 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
841 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
842 printk(KERN_ERR "ide-tape: The tape wants to issue more "
843 "interrupts in DMA mode\n");
844 printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n");
845 ide_dma_off(drive);
846 return ide_do_reset(drive);
847 }
848 /* Get the number of bytes to transfer on this interrupt. */
849 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
850 hwif->INB(hwif->io_ports.lbam_addr);
851
852 ireason = hwif->INB(hwif->io_ports.nsect_addr);
853
854 if (ireason & CD) {
855 printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__);
856 return ide_do_reset(drive);
857 }
858 if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) {
859 /* Hopefully, we will never get here */
860 printk(KERN_ERR "ide-tape: We wanted to %s, ",
861 (ireason & IO) ? "Write" : "Read");
862 printk(KERN_ERR "ide-tape: but the tape wants us to %s !\n",
863 (ireason & IO) ? "Read" : "Write");
864 return ide_do_reset(drive);
865 }
866 if (!(pc->flags & PC_FLAG_WRITING)) {
867 /* Reading - Check that we have enough space */
868 temp = pc->xferred + bcount;
869 if (temp > pc->req_xfer) {
870 if (temp > pc->buf_size) {
871 printk(KERN_ERR "ide-tape: The tape wants to "
872 "send us more data than expected "
873 "- discarding data\n");
874 ide_pad_transfer(drive, 0, bcount);
875 ide_set_handler(drive, &idetape_pc_intr,
876 IDETAPE_WAIT_CMD, NULL);
877 return ide_started;
878 }
879 debug_log(DBG_SENSE, "The tape wants to send us more "
880 "data than expected - allowing transfer\n");
881 }
882 iobuf = &idetape_input_buffers;
883 xferfunc = hwif->input_data;
884 } else {
885 iobuf = &idetape_output_buffers;
886 xferfunc = hwif->output_data;
887 }
888
889 if (pc->bh)
890 iobuf(drive, pc, bcount);
891 else
892 xferfunc(drive, NULL, pc->cur_pos, bcount);
893
894 /* Update the current position */
895 pc->xferred += bcount;
896 pc->cur_pos += bcount;
897
898 debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n",
899 pc->c[0], bcount);
900 802
901 /* And set the interrupt handler again */ 803 return ide_pc_intr(drive, tape->pc, idetape_pc_intr, IDETAPE_WAIT_CMD,
902 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); 804 NULL, idetape_update_buffers, idetape_retry_pc,
903 return ide_started; 805 ide_tape_handle_dsc, ide_tape_io_buffers);
904} 806}
905 807
906/* 808/*
@@ -941,56 +843,16 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
941 */ 843 */
942static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) 844static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
943{ 845{
944 ide_hwif_t *hwif = drive->hwif;
945 idetape_tape_t *tape = drive->driver_data; 846 idetape_tape_t *tape = drive->driver_data;
946 struct ide_atapi_pc *pc = tape->pc;
947 int retries = 100;
948 ide_startstop_t startstop;
949 u8 ireason;
950
951 if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) {
952 printk(KERN_ERR "ide-tape: Strange, packet command initiated "
953 "yet DRQ isn't asserted\n");
954 return startstop;
955 }
956 ireason = hwif->INB(hwif->io_ports.nsect_addr);
957 while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) {
958 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing "
959 "a packet command, retrying\n");
960 udelay(100);
961 ireason = hwif->INB(hwif->io_ports.nsect_addr);
962 if (retries == 0) {
963 printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while "
964 "issuing a packet command, ignoring\n");
965 ireason |= CD;
966 ireason &= ~IO;
967 }
968 }
969 if ((ireason & CD) == 0 || (ireason & IO)) {
970 printk(KERN_ERR "ide-tape: (IO,CoD) != (0,1) while issuing "
971 "a packet command\n");
972 return ide_do_reset(drive);
973 }
974 /* Set the interrupt routine */
975 ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);
976#ifdef CONFIG_BLK_DEV_IDEDMA
977 /* Begin DMA, if necessary */
978 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS)
979 hwif->dma_ops->dma_start(drive);
980#endif
981 /* Send the actual packet */
982 hwif->output_data(drive, NULL, pc->c, 12);
983 847
984 return ide_started; 848 return ide_transfer_pc(drive, tape->pc, idetape_pc_intr,
849 IDETAPE_WAIT_CMD, NULL);
985} 850}
986 851
987static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, 852static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
988 struct ide_atapi_pc *pc) 853 struct ide_atapi_pc *pc)
989{ 854{
990 ide_hwif_t *hwif = drive->hwif;
991 idetape_tape_t *tape = drive->driver_data; 855 idetape_tape_t *tape = drive->driver_data;
992 int dma_ok = 0;
993 u16 bcount;
994 856
995 if (tape->pc->c[0] == REQUEST_SENSE && 857 if (tape->pc->c[0] == REQUEST_SENSE &&
996 pc->c[0] == REQUEST_SENSE) { 858 pc->c[0] == REQUEST_SENSE) {
@@ -1025,50 +887,15 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive,
1025 pc->error = IDETAPE_ERROR_GENERAL; 887 pc->error = IDETAPE_ERROR_GENERAL;
1026 } 888 }
1027 tape->failed_pc = NULL; 889 tape->failed_pc = NULL;
1028 return pc->idetape_callback(drive); 890 pc->callback(drive);
891 return ide_stopped;
1029 } 892 }
1030 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 893 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]);
1031 894
1032 pc->retries++; 895 pc->retries++;
1033 /* We haven't transferred any data yet */
1034 pc->xferred = 0;
1035 pc->cur_pos = pc->buf;
1036 /* Request to transfer the entire buffer at once */
1037 bcount = pc->req_xfer;
1038 896
1039 if (pc->flags & PC_FLAG_DMA_ERROR) { 897 return ide_issue_pc(drive, pc, idetape_transfer_pc,
1040 pc->flags &= ~PC_FLAG_DMA_ERROR; 898 IDETAPE_WAIT_CMD, NULL);
1041 printk(KERN_WARNING "ide-tape: DMA disabled, "
1042 "reverting to PIO\n");
1043 ide_dma_off(drive);
1044 }
1045 if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma)
1046 dma_ok = !hwif->dma_ops->dma_setup(drive);
1047
1048 ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK |
1049 IDE_TFLAG_OUT_DEVICE, bcount, dma_ok);
1050
1051 if (dma_ok)
1052 /* Will begin DMA later */
1053 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
1054 if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) {
1055 ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc,
1056 IDETAPE_WAIT_CMD, NULL);
1057 return ide_started;
1058 } else {
1059 ide_execute_pkt_cmd(drive);
1060 return idetape_transfer_pc(drive);
1061 }
1062}
1063
1064static ide_startstop_t idetape_pc_callback(ide_drive_t *drive)
1065{
1066 idetape_tape_t *tape = drive->driver_data;
1067
1068 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1069
1070 idetape_end_request(drive, tape->pc->error ? 0 : 1, 0);
1071 return ide_stopped;
1072} 899}
1073 900
1074/* A mode sense command is used to "sense" tape parameters. */ 901/* A mode sense command is used to "sense" tape parameters. */
@@ -1096,7 +923,6 @@ static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code)
1096 pc->req_xfer = 24; 923 pc->req_xfer = 24;
1097 else 924 else
1098 pc->req_xfer = 50; 925 pc->req_xfer = 50;
1099 pc->idetape_callback = &idetape_pc_callback;
1100} 926}
1101 927
1102static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) 928static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
@@ -1114,80 +940,41 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)
1114 printk(KERN_ERR "ide-tape: %s: I/O error, ", 940 printk(KERN_ERR "ide-tape: %s: I/O error, ",
1115 tape->name); 941 tape->name);
1116 /* Retry operation */ 942 /* Retry operation */
1117 return idetape_retry_pc(drive); 943 idetape_retry_pc(drive);
944 return ide_stopped;
1118 } 945 }
1119 pc->error = 0; 946 pc->error = 0;
1120 if (tape->failed_pc == pc)
1121 tape->failed_pc = NULL;
1122 } else { 947 } else {
1123 pc->error = IDETAPE_ERROR_GENERAL; 948 pc->error = IDETAPE_ERROR_GENERAL;
1124 tape->failed_pc = NULL; 949 tape->failed_pc = NULL;
1125 } 950 }
1126 return pc->idetape_callback(drive); 951 pc->callback(drive);
1127}
1128
1129static ide_startstop_t idetape_rw_callback(ide_drive_t *drive)
1130{
1131 idetape_tape_t *tape = drive->driver_data;
1132 struct request *rq = HWGROUP(drive)->rq;
1133 int blocks = tape->pc->xferred / tape->blk_size;
1134
1135 tape->avg_size += blocks * tape->blk_size;
1136
1137 if (time_after_eq(jiffies, tape->avg_time + HZ)) {
1138 tape->avg_speed = tape->avg_size * HZ /
1139 (jiffies - tape->avg_time) / 1024;
1140 tape->avg_size = 0;
1141 tape->avg_time = jiffies;
1142 }
1143 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1144
1145 tape->first_frame += blocks;
1146 rq->current_nr_sectors -= blocks;
1147
1148 if (!tape->pc->error)
1149 idetape_end_request(drive, 1, 0);
1150 else
1151 idetape_end_request(drive, tape->pc->error, 0);
1152 return ide_stopped; 952 return ide_stopped;
1153} 953}
1154 954
1155static void idetape_create_read_cmd(idetape_tape_t *tape, 955static void ide_tape_create_rw_cmd(idetape_tape_t *tape,
1156 struct ide_atapi_pc *pc, 956 struct ide_atapi_pc *pc, unsigned int length,
1157 unsigned int length, struct idetape_bh *bh) 957 struct idetape_bh *bh, u8 opcode)
1158{ 958{
1159 idetape_init_pc(pc); 959 idetape_init_pc(pc);
1160 pc->c[0] = READ_6;
1161 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 960 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
1162 pc->c[1] = 1; 961 pc->c[1] = 1;
1163 pc->idetape_callback = &idetape_rw_callback;
1164 pc->bh = bh; 962 pc->bh = bh;
1165 atomic_set(&bh->b_count, 0);
1166 pc->buf = NULL; 963 pc->buf = NULL;
1167 pc->buf_size = length * tape->blk_size; 964 pc->buf_size = length * tape->blk_size;
1168 pc->req_xfer = pc->buf_size; 965 pc->req_xfer = pc->buf_size;
1169 if (pc->req_xfer == tape->buffer_size) 966 if (pc->req_xfer == tape->buffer_size)
1170 pc->flags |= PC_FLAG_DMA_RECOMMENDED; 967 pc->flags |= PC_FLAG_DMA_OK;
1171}
1172 968
1173static void idetape_create_write_cmd(idetape_tape_t *tape, 969 if (opcode == READ_6) {
1174 struct ide_atapi_pc *pc, 970 pc->c[0] = READ_6;
1175 unsigned int length, struct idetape_bh *bh) 971 atomic_set(&bh->b_count, 0);
1176{ 972 } else if (opcode == WRITE_6) {
1177 idetape_init_pc(pc); 973 pc->c[0] = WRITE_6;
1178 pc->c[0] = WRITE_6; 974 pc->flags |= PC_FLAG_WRITING;
1179 put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); 975 pc->b_data = bh->b_data;
1180 pc->c[1] = 1; 976 pc->b_count = atomic_read(&bh->b_count);
1181 pc->idetape_callback = &idetape_rw_callback; 977 }
1182 pc->flags |= PC_FLAG_WRITING;
1183 pc->bh = bh;
1184 pc->b_data = bh->b_data;
1185 pc->b_count = atomic_read(&bh->b_count);
1186 pc->buf = NULL;
1187 pc->buf_size = length * tape->blk_size;
1188 pc->req_xfer = pc->buf_size;
1189 if (pc->req_xfer == tape->buffer_size)
1190 pc->flags |= PC_FLAG_DMA_RECOMMENDED;
1191} 978}
1192 979
1193static ide_startstop_t idetape_do_request(ide_drive_t *drive, 980static ide_startstop_t idetape_do_request(ide_drive_t *drive,
@@ -1211,8 +998,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1211 } 998 }
1212 999
1213 /* Retry a failed packet command */ 1000 /* Retry a failed packet command */
1214 if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) 1001 if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) {
1215 return idetape_issue_pc(drive, tape->failed_pc); 1002 pc = tape->failed_pc;
1003 goto out;
1004 }
1216 1005
1217 if (postponed_rq != NULL) 1006 if (postponed_rq != NULL)
1218 if (rq != postponed_rq) { 1007 if (rq != postponed_rq) {
@@ -1262,14 +1051,16 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1262 } 1051 }
1263 if (rq->cmd[0] & REQ_IDETAPE_READ) { 1052 if (rq->cmd[0] & REQ_IDETAPE_READ) {
1264 pc = idetape_next_pc_storage(drive); 1053 pc = idetape_next_pc_storage(drive);
1265 idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, 1054 ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors,
1266 (struct idetape_bh *)rq->special); 1055 (struct idetape_bh *)rq->special,
1056 READ_6);
1267 goto out; 1057 goto out;
1268 } 1058 }
1269 if (rq->cmd[0] & REQ_IDETAPE_WRITE) { 1059 if (rq->cmd[0] & REQ_IDETAPE_WRITE) {
1270 pc = idetape_next_pc_storage(drive); 1060 pc = idetape_next_pc_storage(drive);
1271 idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, 1061 ide_tape_create_rw_cmd(tape, pc, rq->current_nr_sectors,
1272 (struct idetape_bh *)rq->special); 1062 (struct idetape_bh *)rq->special,
1063 WRITE_6);
1273 goto out; 1064 goto out;
1274 } 1065 }
1275 if (rq->cmd[0] & REQ_IDETAPE_PC1) { 1066 if (rq->cmd[0] & REQ_IDETAPE_PC1) {
@@ -1284,6 +1075,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1284 } 1075 }
1285 BUG(); 1076 BUG();
1286out: 1077out:
1078 if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags))
1079 pc->flags |= PC_FLAG_DRQ_INTERRUPT;
1080
1287 return idetape_issue_pc(drive, pc); 1081 return idetape_issue_pc(drive, pc);
1288} 1082}
1289 1083
@@ -1447,40 +1241,6 @@ static void idetape_init_merge_buffer(idetape_tape_t *tape)
1447 } 1241 }
1448} 1242}
1449 1243
1450static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive)
1451{
1452 idetape_tape_t *tape = drive->driver_data;
1453 u8 *readpos = tape->pc->buf;
1454
1455 debug_log(DBG_PROCS, "Enter %s\n", __func__);
1456
1457 if (!tape->pc->error) {
1458 debug_log(DBG_SENSE, "BOP - %s\n",
1459 (readpos[0] & 0x80) ? "Yes" : "No");
1460 debug_log(DBG_SENSE, "EOP - %s\n",
1461 (readpos[0] & 0x40) ? "Yes" : "No");
1462
1463 if (readpos[0] & 0x4) {
1464 printk(KERN_INFO "ide-tape: Block location is unknown"
1465 "to the tape\n");
1466 clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags);
1467 idetape_end_request(drive, 0, 0);
1468 } else {
1469 debug_log(DBG_SENSE, "Block Location - %u\n",
1470 be32_to_cpu(*(u32 *)&readpos[4]));
1471
1472 tape->partition = readpos[1];
1473 tape->first_frame =
1474 be32_to_cpu(*(u32 *)&readpos[4]);
1475 set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags);
1476 idetape_end_request(drive, 1, 0);
1477 }
1478 } else {
1479 idetape_end_request(drive, 0, 0);
1480 }
1481 return ide_stopped;
1482}
1483
1484/* 1244/*
1485 * Write a filemark if write_filemark=1. Flush the device buffers without 1245 * Write a filemark if write_filemark=1. Flush the device buffers without
1486 * writing a filemark otherwise. 1246 * writing a filemark otherwise.
@@ -1492,14 +1252,12 @@ static void idetape_create_write_filemark_cmd(ide_drive_t *drive,
1492 pc->c[0] = WRITE_FILEMARKS; 1252 pc->c[0] = WRITE_FILEMARKS;
1493 pc->c[4] = write_filemark; 1253 pc->c[4] = write_filemark;
1494 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1254 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1495 pc->idetape_callback = &idetape_pc_callback;
1496} 1255}
1497 1256
1498static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) 1257static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
1499{ 1258{
1500 idetape_init_pc(pc); 1259 idetape_init_pc(pc);
1501 pc->c[0] = TEST_UNIT_READY; 1260 pc->c[0] = TEST_UNIT_READY;
1502 pc->idetape_callback = &idetape_pc_callback;
1503} 1261}
1504 1262
1505/* 1263/*
@@ -1518,12 +1276,16 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
1518static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) 1276static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc)
1519{ 1277{
1520 struct ide_tape_obj *tape = drive->driver_data; 1278 struct ide_tape_obj *tape = drive->driver_data;
1521 struct request rq; 1279 struct request *rq;
1280 int error;
1522 1281
1523 idetape_init_rq(&rq, REQ_IDETAPE_PC1); 1282 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
1524 rq.buffer = (char *) pc; 1283 rq->cmd_type = REQ_TYPE_SPECIAL;
1525 rq.rq_disk = tape->disk; 1284 rq->cmd[0] = REQ_IDETAPE_PC1;
1526 return ide_do_drive_cmd(drive, &rq, ide_wait); 1285 rq->buffer = (char *)pc;
1286 error = blk_execute_rq(drive->queue, tape->disk, rq, 0);
1287 blk_put_request(rq);
1288 return error;
1527} 1289}
1528 1290
1529static void idetape_create_load_unload_cmd(ide_drive_t *drive, 1291static void idetape_create_load_unload_cmd(ide_drive_t *drive,
@@ -1533,7 +1295,6 @@ static void idetape_create_load_unload_cmd(ide_drive_t *drive,
1533 pc->c[0] = START_STOP; 1295 pc->c[0] = START_STOP;
1534 pc->c[4] = cmd; 1296 pc->c[4] = cmd;
1535 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1297 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1536 pc->idetape_callback = &idetape_pc_callback;
1537} 1298}
1538 1299
1539static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) 1300static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout)
@@ -1585,7 +1346,6 @@ static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc)
1585 idetape_init_pc(pc); 1346 idetape_init_pc(pc);
1586 pc->c[0] = READ_POSITION; 1347 pc->c[0] = READ_POSITION;
1587 pc->req_xfer = 20; 1348 pc->req_xfer = 20;
1588 pc->idetape_callback = &idetape_read_position_callback;
1589} 1349}
1590 1350
1591static int idetape_read_position(ide_drive_t *drive) 1351static int idetape_read_position(ide_drive_t *drive)
@@ -1613,7 +1373,6 @@ static void idetape_create_locate_cmd(ide_drive_t *drive,
1613 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); 1373 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]);
1614 pc->c[8] = partition; 1374 pc->c[8] = partition;
1615 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1375 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1616 pc->idetape_callback = &idetape_pc_callback;
1617} 1376}
1618 1377
1619static int idetape_create_prevent_cmd(ide_drive_t *drive, 1378static int idetape_create_prevent_cmd(ide_drive_t *drive,
@@ -1628,7 +1387,6 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive,
1628 idetape_init_pc(pc); 1387 idetape_init_pc(pc);
1629 pc->c[0] = ALLOW_MEDIUM_REMOVAL; 1388 pc->c[0] = ALLOW_MEDIUM_REMOVAL;
1630 pc->c[4] = prevent; 1389 pc->c[4] = prevent;
1631 pc->idetape_callback = &idetape_pc_callback;
1632 return 1; 1390 return 1;
1633} 1391}
1634 1392
@@ -1700,26 +1458,33 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks,
1700 struct idetape_bh *bh) 1458 struct idetape_bh *bh)
1701{ 1459{
1702 idetape_tape_t *tape = drive->driver_data; 1460 idetape_tape_t *tape = drive->driver_data;
1703 struct request rq; 1461 struct request *rq;
1462 int ret, errors;
1704 1463
1705 debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); 1464 debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd);
1706 1465
1707 idetape_init_rq(&rq, cmd); 1466 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
1708 rq.rq_disk = tape->disk; 1467 rq->cmd_type = REQ_TYPE_SPECIAL;
1709 rq.special = (void *)bh; 1468 rq->cmd[0] = cmd;
1710 rq.sector = tape->first_frame; 1469 rq->rq_disk = tape->disk;
1711 rq.nr_sectors = blocks; 1470 rq->special = (void *)bh;
1712 rq.current_nr_sectors = blocks; 1471 rq->sector = tape->first_frame;
1713 (void) ide_do_drive_cmd(drive, &rq, ide_wait); 1472 rq->nr_sectors = blocks;
1473 rq->current_nr_sectors = blocks;
1474 blk_execute_rq(drive->queue, tape->disk, rq, 0);
1475
1476 errors = rq->errors;
1477 ret = tape->blk_size * (blocks - rq->current_nr_sectors);
1478 blk_put_request(rq);
1714 1479
1715 if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) 1480 if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0)
1716 return 0; 1481 return 0;
1717 1482
1718 if (tape->merge_bh) 1483 if (tape->merge_bh)
1719 idetape_init_merge_buffer(tape); 1484 idetape_init_merge_buffer(tape);
1720 if (rq.errors == IDETAPE_ERROR_GENERAL) 1485 if (errors == IDETAPE_ERROR_GENERAL)
1721 return -EIO; 1486 return -EIO;
1722 return (tape->blk_size * (blocks-rq.current_nr_sectors)); 1487 return ret;
1723} 1488}
1724 1489
1725static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) 1490static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
@@ -1728,7 +1493,6 @@ static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
1728 pc->c[0] = INQUIRY; 1493 pc->c[0] = INQUIRY;
1729 pc->c[4] = 254; 1494 pc->c[4] = 254;
1730 pc->req_xfer = 254; 1495 pc->req_xfer = 254;
1731 pc->idetape_callback = &idetape_pc_callback;
1732} 1496}
1733 1497
1734static void idetape_create_rewind_cmd(ide_drive_t *drive, 1498static void idetape_create_rewind_cmd(ide_drive_t *drive,
@@ -1737,7 +1501,6 @@ static void idetape_create_rewind_cmd(ide_drive_t *drive,
1737 idetape_init_pc(pc); 1501 idetape_init_pc(pc);
1738 pc->c[0] = REZERO_UNIT; 1502 pc->c[0] = REZERO_UNIT;
1739 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1503 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1740 pc->idetape_callback = &idetape_pc_callback;
1741} 1504}
1742 1505
1743static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) 1506static void idetape_create_erase_cmd(struct ide_atapi_pc *pc)
@@ -1746,7 +1509,6 @@ static void idetape_create_erase_cmd(struct ide_atapi_pc *pc)
1746 pc->c[0] = ERASE; 1509 pc->c[0] = ERASE;
1747 pc->c[1] = 1; 1510 pc->c[1] = 1;
1748 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1511 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1749 pc->idetape_callback = &idetape_pc_callback;
1750} 1512}
1751 1513
1752static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) 1514static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
@@ -1756,7 +1518,6 @@ static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
1756 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); 1518 put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]);
1757 pc->c[1] = cmd; 1519 pc->c[1] = cmd;
1758 pc->flags |= PC_FLAG_WAIT_FOR_DSC; 1520 pc->flags |= PC_FLAG_WAIT_FOR_DSC;
1759 pc->idetape_callback = &idetape_pc_callback;
1760} 1521}
1761 1522
1762/* Queue up a character device originated write request. */ 1523/* Queue up a character device originated write request. */
@@ -2751,9 +2512,8 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
2751 * Ensure that the number we got makes sense; limit it within 2512 * Ensure that the number we got makes sense; limit it within
2752 * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX. 2513 * IDETAPE_DSC_RW_MIN and IDETAPE_DSC_RW_MAX.
2753 */ 2514 */
2754 tape->best_dsc_rw_freq = max_t(unsigned long, 2515 tape->best_dsc_rw_freq = clamp_t(unsigned long, t, IDETAPE_DSC_RW_MIN,
2755 min_t(unsigned long, t, IDETAPE_DSC_RW_MAX), 2516 IDETAPE_DSC_RW_MAX);
2756 IDETAPE_DSC_RW_MIN);
2757 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, " 2517 printk(KERN_INFO "ide-tape: %s <-> %s: %dKBps, %d*%dkB buffer, "
2758 "%lums tDSC%s\n", 2518 "%lums tDSC%s\n",
2759 drive->name, tape->name, *(u16 *)&tape->caps[14], 2519 drive->name, tape->name, *(u16 *)&tape->caps[14],
@@ -2905,11 +2665,6 @@ static int ide_tape_probe(ide_drive_t *drive)
2905 " the driver\n", drive->name); 2665 " the driver\n", drive->name);
2906 goto failed; 2666 goto failed;
2907 } 2667 }
2908 if (drive->scsi) {
2909 printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi"
2910 " emulation.\n", drive->name);
2911 goto failed;
2912 }
2913 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); 2668 tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL);
2914 if (tape == NULL) { 2669 if (tape == NULL) {
2915 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", 2670 printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n",
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index ab545ffa154..cf55a48a7dd 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -109,13 +109,15 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
109 109
110 if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { 110 if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
111 ide_tf_dump(drive->name, tf); 111 ide_tf_dump(drive->name, tf);
112 ide_set_irq(drive, 1);
113 SELECT_MASK(drive, 0);
112 hwif->tf_load(drive, task); 114 hwif->tf_load(drive, task);
113 } 115 }
114 116
115 switch (task->data_phase) { 117 switch (task->data_phase) {
116 case TASKFILE_MULTI_OUT: 118 case TASKFILE_MULTI_OUT:
117 case TASKFILE_OUT: 119 case TASKFILE_OUT:
118 hwif->OUTBSYNC(drive, tf->command, hwif->io_ports.command_addr); 120 hwif->OUTBSYNC(hwif, tf->command, hwif->io_ports.command_addr);
119 ndelay(400); /* FIXME */ 121 ndelay(400); /* FIXME */
120 return pre_task_out_intr(drive, task->rq); 122 return pre_task_out_intr(drive, task->rq);
121 case TASKFILE_MULTI_IN: 123 case TASKFILE_MULTI_IN:
@@ -492,11 +494,12 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
492 494
493int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect) 495int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect)
494{ 496{
495 struct request rq; 497 struct request *rq;
498 int error;
496 499
497 blk_rq_init(NULL, &rq); 500 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
498 rq.cmd_type = REQ_TYPE_ATA_TASKFILE; 501 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
499 rq.buffer = buf; 502 rq->buffer = buf;
500 503
501 /* 504 /*
502 * (ks) We transfer currently only whole sectors. 505 * (ks) We transfer currently only whole sectors.
@@ -504,16 +507,19 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *task, u8 *buf, u16 nsect)
504 * if we would find a solution to transfer any size. 507 * if we would find a solution to transfer any size.
505 * To support special commands like READ LONG. 508 * To support special commands like READ LONG.
506 */ 509 */
507 rq.hard_nr_sectors = rq.nr_sectors = nsect; 510 rq->hard_nr_sectors = rq->nr_sectors = nsect;
508 rq.hard_cur_sectors = rq.current_nr_sectors = nsect; 511 rq->hard_cur_sectors = rq->current_nr_sectors = nsect;
509 512
510 if (task->tf_flags & IDE_TFLAG_WRITE) 513 if (task->tf_flags & IDE_TFLAG_WRITE)
511 rq.cmd_flags |= REQ_RW; 514 rq->cmd_flags |= REQ_RW;
512 515
513 rq.special = task; 516 rq->special = task;
514 task->rq = &rq; 517 task->rq = rq;
515 518
516 return ide_do_drive_cmd(drive, &rq, ide_wait); 519 error = blk_execute_rq(drive->queue, NULL, rq, 0);
520 blk_put_request(rq);
521
522 return error;
517} 523}
518 524
519EXPORT_SYMBOL(ide_raw_taskfile); 525EXPORT_SYMBOL(ide_raw_taskfile);
@@ -739,12 +745,14 @@ int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
739 struct hd_driveid *id = drive->id; 745 struct hd_driveid *id = drive->id;
740 746
741 if (NULL == (void *) arg) { 747 if (NULL == (void *) arg) {
742 struct request rq; 748 struct request *rq;
743 749
744 ide_init_drive_cmd(&rq); 750 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
745 rq.cmd_type = REQ_TYPE_ATA_TASKFILE; 751 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
752 err = blk_execute_rq(drive->queue, NULL, rq, 0);
753 blk_put_request(rq);
746 754
747 return ide_do_drive_cmd(drive, &rq, ide_wait); 755 return err;
748 } 756 }
749 757
750 if (copy_from_user(args, (void __user *)arg, 4)) 758 if (copy_from_user(args, (void __user *)arg, 4))
diff --git a/drivers/ide/ide-timing.h b/drivers/ide/ide-timing.h
index 3b12ffe7707..2e91c5870b4 100644
--- a/drivers/ide/ide-timing.h
+++ b/drivers/ide/ide-timing.h
@@ -95,7 +95,6 @@ static struct ide_timing ide_timing[] = {
95#define IDE_TIMING_UDMA 0x80 95#define IDE_TIMING_UDMA 0x80
96#define IDE_TIMING_ALL 0xff 96#define IDE_TIMING_ALL 0xff
97 97
98#define FIT(v,vmin,vmax) max_t(short,min_t(short,v,vmax),vmin)
99#define ENOUGH(v,unit) (((v)-1)/(unit)+1) 98#define ENOUGH(v,unit) (((v)-1)/(unit)+1)
100#define EZ(v,unit) ((v)?ENOUGH(v,unit):0) 99#define EZ(v,unit) ((v)?ENOUGH(v,unit):0)
101 100
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 300431d080a..2b8453510e0 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -86,13 +86,10 @@ static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR,
86 IDE6_MAJOR, IDE7_MAJOR, 86 IDE6_MAJOR, IDE7_MAJOR,
87 IDE8_MAJOR, IDE9_MAJOR }; 87 IDE8_MAJOR, IDE9_MAJOR };
88 88
89static int idebus_parameter; /* holds the "idebus=" parameter */
90static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */
91
92DEFINE_MUTEX(ide_cfg_mtx); 89DEFINE_MUTEX(ide_cfg_mtx);
93 __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
94 90
95int noautodma = 0; 91__cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
92EXPORT_SYMBOL(ide_lock);
96 93
97ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */ 94ide_hwif_t ide_hwifs[MAX_HWIFS]; /* master data repository */
98 95
@@ -139,7 +136,6 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
139 drive->media = ide_disk; 136 drive->media = ide_disk;
140 drive->select.all = (unit<<4)|0xa0; 137 drive->select.all = (unit<<4)|0xa0;
141 drive->hwif = hwif; 138 drive->hwif = hwif;
142 drive->ctl = 0x08;
143 drive->ready_stat = READY_STAT; 139 drive->ready_stat = READY_STAT;
144 drive->bad_wstat = BAD_W_STAT; 140 drive->bad_wstat = BAD_W_STAT;
145 drive->special.b.recalibrate = 1; 141 drive->special.b.recalibrate = 1;
@@ -154,32 +150,9 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif)
154 } 150 }
155} 151}
156 152
157/*
158 * init_ide_data() sets reasonable default values into all fields
159 * of all instances of the hwifs and drives, but only on the first call.
160 * Subsequent calls have no effect (they don't wipe out anything).
161 *
162 * This routine is normally called at driver initialization time,
163 * but may also be called MUCH earlier during kernel "command-line"
164 * parameter processing. As such, we cannot depend on any other parts
165 * of the kernel (such as memory allocation) to be functioning yet.
166 *
167 * This is too bad, as otherwise we could dynamically allocate the
168 * ide_drive_t structs as needed, rather than always consuming memory
169 * for the max possible number (MAX_HWIFS * MAX_DRIVES) of them.
170 *
171 * FIXME: We should stuff the setup data into __init and copy the
172 * relevant hwifs/allocate them properly during boot.
173 */
174#define MAGIC_COOKIE 0x12345678
175static void __init init_ide_data (void) 153static void __init init_ide_data (void)
176{ 154{
177 unsigned int index; 155 unsigned int index;
178 static unsigned long magic_cookie = MAGIC_COOKIE;
179
180 if (magic_cookie != MAGIC_COOKIE)
181 return; /* already initialized */
182 magic_cookie = 0;
183 156
184 /* Initialise all interface structures */ 157 /* Initialise all interface structures */
185 for (index = 0; index < MAX_HWIFS; ++index) { 158 for (index = 0; index < MAX_HWIFS; ++index) {
@@ -189,38 +162,6 @@ static void __init init_ide_data (void)
189 } 162 }
190} 163}
191 164
192/**
193 * ide_system_bus_speed - guess bus speed
194 *
195 * ide_system_bus_speed() returns what we think is the system VESA/PCI
196 * bus speed (in MHz). This is used for calculating interface PIO timings.
197 * The default is 40 for known PCI systems, 50 otherwise.
198 * The "idebus=xx" parameter can be used to override this value.
199 * The actual value to be used is computed/displayed the first time
200 * through. Drivers should only use this as a last resort.
201 *
202 * Returns a guessed speed in MHz.
203 */
204
205static int ide_system_bus_speed(void)
206{
207#ifdef CONFIG_PCI
208 static struct pci_device_id pci_default[] = {
209 { PCI_DEVICE(PCI_ANY_ID, PCI_ANY_ID) },
210 { }
211 };
212#else
213#define pci_default 0
214#endif /* CONFIG_PCI */
215
216 /* user supplied value */
217 if (idebus_parameter)
218 return idebus_parameter;
219
220 /* safe default value for PCI or VESA and PCI*/
221 return pci_dev_present(pci_default) ? 33 : 50;
222}
223
224void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) 165void ide_remove_port_from_hwgroup(ide_hwif_t *hwif)
225{ 166{
226 ide_hwgroup_t *hwgroup = hwif->hwgroup; 167 ide_hwgroup_t *hwgroup = hwif->hwgroup;
@@ -498,7 +439,7 @@ out:
498 439
499int set_pio_mode(ide_drive_t *drive, int arg) 440int set_pio_mode(ide_drive_t *drive, int arg)
500{ 441{
501 struct request rq; 442 struct request *rq;
502 ide_hwif_t *hwif = drive->hwif; 443 ide_hwif_t *hwif = drive->hwif;
503 const struct ide_port_ops *port_ops = hwif->port_ops; 444 const struct ide_port_ops *port_ops = hwif->port_ops;
504 445
@@ -512,12 +453,15 @@ int set_pio_mode(ide_drive_t *drive, int arg)
512 if (drive->special.b.set_tune) 453 if (drive->special.b.set_tune)
513 return -EBUSY; 454 return -EBUSY;
514 455
515 ide_init_drive_cmd(&rq); 456 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
516 rq.cmd_type = REQ_TYPE_ATA_TASKFILE; 457 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
517 458
518 drive->tune_req = (u8) arg; 459 drive->tune_req = (u8) arg;
519 drive->special.b.set_tune = 1; 460 drive->special.b.set_tune = 1;
520 (void) ide_do_drive_cmd(drive, &rq, ide_wait); 461
462 blk_execute_rq(drive->queue, NULL, rq, 0);
463 blk_put_request(rq);
464
521 return 0; 465 return 0;
522} 466}
523 467
@@ -537,25 +481,11 @@ static int set_unmaskirq(ide_drive_t *drive, int arg)
537 return 0; 481 return 0;
538} 482}
539 483
540/**
541 * system_bus_clock - clock guess
542 *
543 * External version of the bus clock guess used by very old IDE drivers
544 * for things like VLB timings. Should not be used.
545 */
546
547int system_bus_clock (void)
548{
549 return system_bus_speed;
550}
551
552EXPORT_SYMBOL(system_bus_clock);
553
554static int generic_ide_suspend(struct device *dev, pm_message_t mesg) 484static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
555{ 485{
556 ide_drive_t *drive = dev->driver_data; 486 ide_drive_t *drive = dev->driver_data;
557 ide_hwif_t *hwif = HWIF(drive); 487 ide_hwif_t *hwif = HWIF(drive);
558 struct request rq; 488 struct request *rq;
559 struct request_pm_state rqpm; 489 struct request_pm_state rqpm;
560 ide_task_t args; 490 ide_task_t args;
561 int ret; 491 int ret;
@@ -564,18 +494,19 @@ static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
564 if (!(drive->dn % 2)) 494 if (!(drive->dn % 2))
565 ide_acpi_get_timing(hwif); 495 ide_acpi_get_timing(hwif);
566 496
567 blk_rq_init(NULL, &rq);
568 memset(&rqpm, 0, sizeof(rqpm)); 497 memset(&rqpm, 0, sizeof(rqpm));
569 memset(&args, 0, sizeof(args)); 498 memset(&args, 0, sizeof(args));
570 rq.cmd_type = REQ_TYPE_PM_SUSPEND; 499 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
571 rq.special = &args; 500 rq->cmd_type = REQ_TYPE_PM_SUSPEND;
572 rq.data = &rqpm; 501 rq->special = &args;
502 rq->data = &rqpm;
573 rqpm.pm_step = ide_pm_state_start_suspend; 503 rqpm.pm_step = ide_pm_state_start_suspend;
574 if (mesg.event == PM_EVENT_PRETHAW) 504 if (mesg.event == PM_EVENT_PRETHAW)
575 mesg.event = PM_EVENT_FREEZE; 505 mesg.event = PM_EVENT_FREEZE;
576 rqpm.pm_state = mesg.event; 506 rqpm.pm_state = mesg.event;
577 507
578 ret = ide_do_drive_cmd(drive, &rq, ide_wait); 508 ret = blk_execute_rq(drive->queue, NULL, rq, 0);
509 blk_put_request(rq);
579 /* only call ACPI _PS3 after both drivers are suspended */ 510 /* only call ACPI _PS3 after both drivers are suspended */
580 if (!ret && (((drive->dn % 2) && hwif->drives[0].present 511 if (!ret && (((drive->dn % 2) && hwif->drives[0].present
581 && hwif->drives[1].present) 512 && hwif->drives[1].present)
@@ -589,7 +520,7 @@ static int generic_ide_resume(struct device *dev)
589{ 520{
590 ide_drive_t *drive = dev->driver_data; 521 ide_drive_t *drive = dev->driver_data;
591 ide_hwif_t *hwif = HWIF(drive); 522 ide_hwif_t *hwif = HWIF(drive);
592 struct request rq; 523 struct request *rq;
593 struct request_pm_state rqpm; 524 struct request_pm_state rqpm;
594 ide_task_t args; 525 ide_task_t args;
595 int err; 526 int err;
@@ -602,16 +533,18 @@ static int generic_ide_resume(struct device *dev)
602 533
603 ide_acpi_exec_tfs(drive); 534 ide_acpi_exec_tfs(drive);
604 535
605 blk_rq_init(NULL, &rq);
606 memset(&rqpm, 0, sizeof(rqpm)); 536 memset(&rqpm, 0, sizeof(rqpm));
607 memset(&args, 0, sizeof(args)); 537 memset(&args, 0, sizeof(args));
608 rq.cmd_type = REQ_TYPE_PM_RESUME; 538 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
609 rq.special = &args; 539 rq->cmd_type = REQ_TYPE_PM_RESUME;
610 rq.data = &rqpm; 540 rq->cmd_flags |= REQ_PREEMPT;
541 rq->special = &args;
542 rq->data = &rqpm;
611 rqpm.pm_step = ide_pm_state_start_resume; 543 rqpm.pm_step = ide_pm_state_start_resume;
612 rqpm.pm_state = PM_EVENT_ON; 544 rqpm.pm_state = PM_EVENT_ON;
613 545
614 err = ide_do_drive_cmd(drive, &rq, ide_head_wait); 546 err = blk_execute_rq(drive->queue, NULL, rq, 1);
547 blk_put_request(rq);
615 548
616 if (err == 0 && dev->driver) { 549 if (err == 0 && dev->driver) {
617 ide_driver_t *drv = to_ide_driver(dev->driver); 550 ide_driver_t *drv = to_ide_driver(dev->driver);
@@ -764,212 +697,6 @@ set_val:
764 697
765EXPORT_SYMBOL(generic_ide_ioctl); 698EXPORT_SYMBOL(generic_ide_ioctl);
766 699
767/*
768 * stridx() returns the offset of c within s,
769 * or -1 if c is '\0' or not found within s.
770 */
771static int __init stridx (const char *s, char c)
772{
773 char *i = strchr(s, c);
774 return (i && c) ? i - s : -1;
775}
776
777/*
778 * match_parm() does parsing for ide_setup():
779 *
780 * 1. the first char of s must be '='.
781 * 2. if the remainder matches one of the supplied keywords,
782 * the index (1 based) of the keyword is negated and returned.
783 * 3. if the remainder is a series of no more than max_vals numbers
784 * separated by commas, the numbers are saved in vals[] and a
785 * count of how many were saved is returned. Base10 is assumed,
786 * and base16 is allowed when prefixed with "0x".
787 * 4. otherwise, zero is returned.
788 */
789static int __init match_parm (char *s, const char *keywords[], int vals[], int max_vals)
790{
791 static const char *decimal = "0123456789";
792 static const char *hex = "0123456789abcdef";
793 int i, n;
794
795 if (*s++ == '=') {
796 /*
797 * Try matching against the supplied keywords,
798 * and return -(index+1) if we match one
799 */
800 if (keywords != NULL) {
801 for (i = 0; *keywords != NULL; ++i) {
802 if (!strcmp(s, *keywords++))
803 return -(i+1);
804 }
805 }
806 /*
807 * Look for a series of no more than "max_vals"
808 * numeric values separated by commas, in base10,
809 * or base16 when prefixed with "0x".
810 * Return a count of how many were found.
811 */
812 for (n = 0; (i = stridx(decimal, *s)) >= 0;) {
813 vals[n] = i;
814 while ((i = stridx(decimal, *++s)) >= 0)
815 vals[n] = (vals[n] * 10) + i;
816 if (*s == 'x' && !vals[n]) {
817 while ((i = stridx(hex, *++s)) >= 0)
818 vals[n] = (vals[n] * 0x10) + i;
819 }
820 if (++n == max_vals)
821 break;
822 if (*s == ',' || *s == ';')
823 ++s;
824 }
825 if (!*s)
826 return n;
827 }
828 return 0; /* zero = nothing matched */
829}
830
831/*
832 * ide_setup() gets called VERY EARLY during initialization,
833 * to handle kernel "command line" strings beginning with "hdx=" or "ide".
834 *
835 * Remember to update Documentation/ide/ide.txt if you change something here.
836 */
837static int __init ide_setup(char *s)
838{
839 ide_hwif_t *hwif;
840 ide_drive_t *drive;
841 unsigned int hw, unit;
842 int vals[3];
843 const char max_drive = 'a' + ((MAX_HWIFS * MAX_DRIVES) - 1);
844
845 if (strncmp(s,"hd",2) == 0 && s[2] == '=') /* hd= is for hd.c */
846 return 0; /* driver and not us */
847
848 if (strncmp(s,"ide",3) && strncmp(s,"idebus",6) && strncmp(s,"hd",2))
849 return 0;
850
851 printk(KERN_INFO "ide_setup: %s", s);
852 init_ide_data ();
853
854#ifdef CONFIG_BLK_DEV_IDEDOUBLER
855 if (!strcmp(s, "ide=doubler")) {
856 extern int ide_doubler;
857
858 printk(" : Enabled support for IDE doublers\n");
859 ide_doubler = 1;
860 goto obsolete_option;
861 }
862#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
863
864 if (!strcmp(s, "ide=nodma")) {
865 printk(" : Prevented DMA\n");
866 noautodma = 1;
867 goto obsolete_option;
868 }
869
870#ifdef CONFIG_BLK_DEV_IDEACPI
871 if (!strcmp(s, "ide=noacpi")) {
872 //printk(" : Disable IDE ACPI support.\n");
873 ide_noacpi = 1;
874 goto obsolete_option;
875 }
876 if (!strcmp(s, "ide=acpigtf")) {
877 //printk(" : Enable IDE ACPI _GTF support.\n");
878 ide_acpigtf = 1;
879 goto obsolete_option;
880 }
881 if (!strcmp(s, "ide=acpionboot")) {
882 //printk(" : Call IDE ACPI methods on boot.\n");
883 ide_acpionboot = 1;
884 goto obsolete_option;
885 }
886#endif /* CONFIG_BLK_DEV_IDEACPI */
887
888 /*
889 * Look for drive options: "hdx="
890 */
891 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
892 const char *hd_words[] = {
893 "none", "noprobe", "nowerr", "cdrom", "nodma",
894 "-6", "-7", "-8", "-9", "-10",
895 "noflush", "remap", "remap63", "scsi", NULL };
896 unit = s[2] - 'a';
897 hw = unit / MAX_DRIVES;
898 unit = unit % MAX_DRIVES;
899 hwif = &ide_hwifs[hw];
900 drive = &hwif->drives[unit];
901 if (strncmp(s + 4, "ide-", 4) == 0) {
902 strlcpy(drive->driver_req, s + 4, sizeof(drive->driver_req));
903 goto obsolete_option;
904 }
905 switch (match_parm(&s[3], hd_words, vals, 3)) {
906 case -1: /* "none" */
907 case -2: /* "noprobe" */
908 drive->noprobe = 1;
909 goto obsolete_option;
910 case -3: /* "nowerr" */
911 drive->bad_wstat = BAD_R_STAT;
912 goto obsolete_option;
913 case -4: /* "cdrom" */
914 drive->present = 1;
915 drive->media = ide_cdrom;
916 /* an ATAPI device ignores DRDY */
917 drive->ready_stat = 0;
918 goto obsolete_option;
919 case -5: /* nodma */
920 drive->nodma = 1;
921 goto obsolete_option;
922 case -11: /* noflush */
923 drive->noflush = 1;
924 goto obsolete_option;
925 case -12: /* "remap" */
926 drive->remap_0_to_1 = 1;
927 goto obsolete_option;
928 case -13: /* "remap63" */
929 drive->sect0 = 63;
930 goto obsolete_option;
931 case -14: /* "scsi" */
932 drive->scsi = 1;
933 goto obsolete_option;
934 case 3: /* cyl,head,sect */
935 drive->media = ide_disk;
936 drive->ready_stat = READY_STAT;
937 drive->cyl = drive->bios_cyl = vals[0];
938 drive->head = drive->bios_head = vals[1];
939 drive->sect = drive->bios_sect = vals[2];
940 drive->present = 1;
941 drive->forced_geom = 1;
942 goto obsolete_option;
943 default:
944 goto bad_option;
945 }
946 }
947
948 if (s[0] != 'i' || s[1] != 'd' || s[2] != 'e')
949 goto bad_option;
950 /*
951 * Look for bus speed option: "idebus="
952 */
953 if (s[3] == 'b' && s[4] == 'u' && s[5] == 's') {
954 if (match_parm(&s[6], NULL, vals, 1) != 1)
955 goto bad_option;
956 if (vals[0] >= 20 && vals[0] <= 66) {
957 idebus_parameter = vals[0];
958 } else
959 printk(" -- BAD BUS SPEED! Expected value from 20 to 66");
960 goto obsolete_option;
961 }
962
963bad_option:
964 printk(" -- BAD OPTION\n");
965 return 1;
966obsolete_option:
967 printk(" -- OBSOLETE OPTION, WILL BE REMOVED SOON!\n");
968 return 1;
969}
970
971EXPORT_SYMBOL(ide_lock);
972
973static int ide_bus_match(struct device *dev, struct device_driver *drv) 700static int ide_bus_match(struct device *dev, struct device_driver *drv)
974{ 701{
975 return 1; 702 return 1;
@@ -1281,11 +1008,6 @@ static int __init ide_init(void)
1281 int ret; 1008 int ret;
1282 1009
1283 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n"); 1010 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver\n");
1284 system_bus_speed = ide_system_bus_speed();
1285
1286 printk(KERN_INFO "ide: Assuming %dMHz system bus speed "
1287 "for PIO modes%s\n", system_bus_speed,
1288 idebus_parameter ? "" : "; override with idebus=xx");
1289 1011
1290 ret = bus_register(&ide_bus_type); 1012 ret = bus_register(&ide_bus_type);
1291 if (ret < 0) { 1013 if (ret < 0) {
@@ -1311,32 +1033,7 @@ out_port_class:
1311 return ret; 1033 return ret;
1312} 1034}
1313 1035
1314#ifdef MODULE 1036static void __exit ide_exit(void)
1315static char *options = NULL;
1316module_param(options, charp, 0);
1317MODULE_LICENSE("GPL");
1318
1319static void __init parse_options (char *line)
1320{
1321 char *next = line;
1322
1323 if (line == NULL || !*line)
1324 return;
1325 while ((line = next) != NULL) {
1326 if ((next = strchr(line,' ')) != NULL)
1327 *next++ = 0;
1328 if (!ide_setup(line))
1329 printk (KERN_INFO "Unknown option '%s'\n", line);
1330 }
1331}
1332
1333int __init init_module (void)
1334{
1335 parse_options(options);
1336 return ide_init();
1337}
1338
1339void __exit cleanup_module (void)
1340{ 1037{
1341 proc_ide_destroy(); 1038 proc_ide_destroy();
1342 1039
@@ -1345,10 +1042,7 @@ void __exit cleanup_module (void)
1345 bus_unregister(&ide_bus_type); 1042 bus_unregister(&ide_bus_type);
1346} 1043}
1347 1044
1348#else /* !MODULE */
1349
1350__setup("", ide_setup);
1351
1352module_init(ide_init); 1045module_init(ide_init);
1046module_exit(ide_exit);
1353 1047
1354#endif /* MODULE */ 1048MODULE_LICENSE("GPL");
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 90c65cf9744..052125fafcf 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -116,7 +116,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
116 int time1, time2; 116 int time1, time2;
117 u8 param1, param2, param3, param4; 117 u8 param1, param2, param3, param4;
118 unsigned long flags; 118 unsigned long flags;
119 int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); 119 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
120 120
121 /* calculate timing, according to PIO mode */ 121 /* calculate timing, according to PIO mode */
122 time1 = ide_pio_cycle_time(drive, pio); 122 time1 = ide_pio_cycle_time(drive, pio);
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index fed7d812761..b78941680c3 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -64,9 +64,7 @@
64#define GAYLE_HAS_CONTROL_REG (!ide_doubler) 64#define GAYLE_HAS_CONTROL_REG (!ide_doubler)
65#define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000) 65#define GAYLE_IDEREG_SIZE (ide_doubler ? 0x1000 : 0x2000)
66 66
67int ide_doubler = 0; /* support IDE doublers? */ 67static int ide_doubler;
68EXPORT_SYMBOL_GPL(ide_doubler);
69
70module_param_named(doubler, ide_doubler, bool, 0); 68module_param_named(doubler, ide_doubler, bool, 0);
71MODULE_PARM_DESC(doubler, "enable support for IDE doublers"); 69MODULE_PARM_DESC(doubler, "enable support for IDE doublers");
72#endif /* CONFIG_BLK_DEV_IDEDOUBLER */ 70#endif /* CONFIG_BLK_DEV_IDEDOUBLER */
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index 4fe516df9f7..dd6dfb32e85 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -212,7 +212,7 @@ static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio)
212{ 212{
213 int active_time, recovery_time; 213 int active_time, recovery_time;
214 int active_cycles, recovery_cycles; 214 int active_cycles, recovery_cycles;
215 int bus_speed = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); 215 int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
216 216
217 if (pio) { 217 if (pio) {
218 unsigned int cycle_time; 218 unsigned int cycle_time;
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 6424af15432..51dba82f881 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -110,7 +110,7 @@ static void qd65xx_select(ide_drive_t *drive)
110 110
111static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time) 111static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery_time)
112{ 112{
113 int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); 113 int clk = ide_vlb_clk ? ide_vlb_clk : 50;
114 u8 act_cyc, rec_cyc; 114 u8 act_cyc, rec_cyc;
115 115
116 if (clk <= 33) { 116 if (clk <= 33) {
@@ -132,7 +132,7 @@ static u8 qd6500_compute_timing (ide_hwif_t *hwif, int active_time, int recovery
132 132
133static u8 qd6580_compute_timing (int active_time, int recovery_time) 133static u8 qd6580_compute_timing (int active_time, int recovery_time)
134{ 134{
135 int clk = ide_vlb_clk ? ide_vlb_clk : system_bus_clock(); 135 int clk = ide_vlb_clk ? ide_vlb_clk : 50;
136 u8 act_cyc, rec_cyc; 136 u8 act_cyc, rec_cyc;
137 137
138 act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17); 138 act_cyc = 17 - IDE_IN(active_time * clk / 1000 + 1, 2, 17);
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 7f46c224b7c..ae7a4329a58 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -140,7 +140,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
140 140
141static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) 141static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name)
142{ 142{
143 int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); 143 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
144 144
145 if (bus_speed <= 33) 145 if (bus_speed <= 33)
146 pci_set_drvdata(dev, (void *) aec6xxx_33_base); 146 pci_set_drvdata(dev, (void *) aec6xxx_33_base);
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index f2129d5e07f..f2de00adf14 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -72,7 +72,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
72 int s_time, a_time, c_time; 72 int s_time, a_time, c_time;
73 u8 s_clc, a_clc, r_clc; 73 u8 s_clc, a_clc, r_clc;
74 unsigned long flags; 74 unsigned long flags;
75 int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); 75 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
76 int port = hwif->channel ? 0x5c : 0x58; 76 int port = hwif->channel ? 0x5c : 0x58;
77 int portFIFO = hwif->channel ? 0x55 : 0x54; 77 int portFIFO = hwif->channel ? 0x55 : 0x54;
78 u8 cd_dma_fifo = 0; 78 u8 cd_dma_fifo = 0;
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index efcf54338be..ad222206a42 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -53,20 +53,20 @@ static void amd_set_speed(struct pci_dev *dev, u8 dn, u8 udma_mask,
53 u8 t = 0, offset = amd_offset(dev); 53 u8 t = 0, offset = amd_offset(dev);
54 54
55 pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t); 55 pci_read_config_byte(dev, AMD_ADDRESS_SETUP + offset, &t);
56 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 56 t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1));
57 pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t); 57 pci_write_config_byte(dev, AMD_ADDRESS_SETUP + offset, t);
58 58
59 pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)), 59 pci_write_config_byte(dev, AMD_8BIT_TIMING + offset + (1 - (dn >> 1)),
60 ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); 60 ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1));
61 61
62 pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn), 62 pci_write_config_byte(dev, AMD_DRIVE_TIMING + offset + (3 - dn),
63 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 63 ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1));
64 64
65 switch (udma_mask) { 65 switch (udma_mask) {
66 case ATA_UDMA2: t = timing->udma ? (0xc0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 66 case ATA_UDMA2: t = timing->udma ? (0xc0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break;
67 case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 2, 10)]) : 0x03; break; 67 case ATA_UDMA4: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 2, 10)]) : 0x03; break;
68 case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 10)]) : 0x03; break; 68 case ATA_UDMA5: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 10)]) : 0x03; break;
69 case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[FIT(timing->udma, 1, 15)]) : 0x03; break; 69 case ATA_UDMA6: t = timing->udma ? (0xc0 | amd_cyc2udma[clamp_val(timing->udma, 1, 15)]) : 0x03; break;
70 default: return; 70 default: return;
71 } 71 }
72 72
@@ -179,7 +179,7 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,
179 * Determine the system bus clock. 179 * Determine the system bus clock.
180 */ 180 */
181 181
182 amd_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; 182 amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
183 183
184 switch (amd_clock) { 184 switch (amd_clock) {
185 case 33000: amd_clock = 33333; break; 185 case 33000: amd_clock = 33333; break;
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index b38a1980dcd..cd1ba14984a 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -525,12 +525,10 @@ static void cmd640_set_mode(ide_drive_t *drive, unsigned int index,
525 u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count; 525 u8 setup_count, active_count, recovery_count, recovery_count2, cycle_count;
526 int bus_speed; 526 int bus_speed;
527 527
528 if (cmd640_vlb && ide_vlb_clk) 528 if (cmd640_vlb)
529 bus_speed = ide_vlb_clk; 529 bus_speed = ide_vlb_clk ? ide_vlb_clk : 50;
530 else if (!cmd640_vlb && ide_pci_clk)
531 bus_speed = ide_pci_clk;
532 else 530 else
533 bus_speed = system_bus_clock(); 531 bus_speed = ide_pci_clk ? ide_pci_clk : 33;
534 532
535 if (pio_mode > 5) 533 if (pio_mode > 5)
536 pio_mode = 5; 534 pio_mode = 5;
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 08674711d08..ca4774aa27e 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -69,7 +69,7 @@ static u8 quantize_timing(int timing, int quant)
69static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time) 69static void program_cycle_times (ide_drive_t *drive, int cycle_time, int active_time)
70{ 70{
71 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 71 struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
72 int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock()); 72 int clock_time = 1000 / (ide_pci_clk ? ide_pci_clk : 33);
73 u8 cycle_count, active_count, recovery_count, drwtim; 73 u8 cycle_count, active_count, recovery_count, drwtim;
74 static const u8 recovery_values[] = 74 static const u8 recovery_values[] =
75 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0}; 75 {15, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0};
@@ -128,7 +128,7 @@ static void cmd64x_tune_pio(ide_drive_t *drive, const u8 pio)
128 ide_pio_timings[pio].active_time); 128 ide_pio_timings[pio].active_time);
129 129
130 setup_count = quantize_timing(ide_pio_timings[pio].setup_time, 130 setup_count = quantize_timing(ide_pio_timings[pio].setup_time,
131 1000 / (ide_pci_clk ? ide_pci_clk : system_bus_clock())); 131 1000 / (ide_pci_clk ? ide_pci_clk : 33));
132 132
133 /* 133 /*
134 * The primary channel has individual address setup timing registers 134 * The primary channel has individual address setup timing registers
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 77cc22c2ad4..8c534afcb6c 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -134,7 +134,7 @@ static int calc_clk(int time, int bus_speed)
134static void compute_clocks(u8 pio, pio_clocks_t *p_pclk) 134static void compute_clocks(u8 pio, pio_clocks_t *p_pclk)
135{ 135{
136 int clk1, clk2; 136 int clk1, clk2;
137 int bus_speed = ide_pci_clk ? ide_pci_clk : system_bus_clock(); 137 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
138 138
139 /* we don't check against CY82C693's min and max speed, 139 /* we don't check against CY82C693's min and max speed,
140 * so you can play with the idebus=xx parameter 140 * so you can play with the idebus=xx parameter
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index c929dadaaaf..397c6cbe953 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -759,8 +759,7 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
759 enable_irq (hwif->irq); 759 enable_irq (hwif->irq);
760 } 760 }
761 } else 761 } else
762 outb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), 762 outb(ATA_DEVCTL_OBS | (mask ? 2 : 0), hwif->io_ports.ctl_addr);
763 hwif->io_ports.ctl_addr);
764} 763}
765 764
766/* 765/*
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index a7a41bb8277..45ba71a7182 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -76,7 +76,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task)
76 } 76 }
77 77
78 /* be sure we're looking at the low order bits */ 78 /* be sure we're looking at the low order bits */
79 outb(drive->ctl & ~0x80, io_ports->ctl_addr); 79 outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
80 80
81 if (task->tf_flags & IDE_TFLAG_IN_NSECT) 81 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
82 tf->nsect = inb(io_ports->nsect_addr); 82 tf->nsect = inb(io_ports->nsect_addr);
@@ -90,7 +90,7 @@ static void superio_tf_read(ide_drive_t *drive, ide_task_t *task)
90 tf->device = superio_ide_inb(io_ports->device_addr); 90 tf->device = superio_ide_inb(io_ports->device_addr);
91 91
92 if (task->tf_flags & IDE_TFLAG_LBA48) { 92 if (task->tf_flags & IDE_TFLAG_LBA48) {
93 outb(drive->ctl | 0x80, io_ports->ctl_addr); 93 outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
94 94
95 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) 95 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
96 tf->hob_feature = inb(io_ports->feature_addr); 96 tf->hob_feature = inb(io_ports->feature_addr);
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 910fb00deb7..1584ebb6a18 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -148,11 +148,8 @@ static void scc_ide_outb(u8 addr, unsigned long port)
148 out_be32((void*)port, addr); 148 out_be32((void*)port, addr);
149} 149}
150 150
151static void 151static void scc_ide_outbsync(ide_hwif_t *hwif, u8 addr, unsigned long port)
152scc_ide_outbsync(ide_drive_t * drive, u8 addr, unsigned long port)
153{ 152{
154 ide_hwif_t *hwif = HWIF(drive);
155
156 out_be32((void*)port, addr); 153 out_be32((void*)port, addr);
157 eieio(); 154 eieio();
158 in_be32((void*)(hwif->dma_base + 0x01c)); 155 in_be32((void*)(hwif->dma_base + 0x01c));
@@ -662,8 +659,6 @@ static void scc_tf_load(ide_drive_t *drive, ide_task_t *task)
662 if (task->tf_flags & IDE_TFLAG_FLAGGED) 659 if (task->tf_flags & IDE_TFLAG_FLAGGED)
663 HIHI = 0xFF; 660 HIHI = 0xFF;
664 661
665 ide_set_irq(drive, 1);
666
667 if (task->tf_flags & IDE_TFLAG_OUT_DATA) 662 if (task->tf_flags & IDE_TFLAG_OUT_DATA)
668 out_be32((void *)io_ports->data_addr, 663 out_be32((void *)io_ports->data_addr,
669 (tf->hob_data << 8) | tf->data); 664 (tf->hob_data << 8) | tf->data);
@@ -708,7 +703,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task)
708 } 703 }
709 704
710 /* be sure we're looking at the low order bits */ 705 /* be sure we're looking at the low order bits */
711 scc_ide_outb(drive->ctl & ~0x80, io_ports->ctl_addr); 706 scc_ide_outb(ATA_DEVCTL_OBS & ~0x80, io_ports->ctl_addr);
712 707
713 if (task->tf_flags & IDE_TFLAG_IN_NSECT) 708 if (task->tf_flags & IDE_TFLAG_IN_NSECT)
714 tf->nsect = scc_ide_inb(io_ports->nsect_addr); 709 tf->nsect = scc_ide_inb(io_ports->nsect_addr);
@@ -722,7 +717,7 @@ static void scc_tf_read(ide_drive_t *drive, ide_task_t *task)
722 tf->device = scc_ide_inb(io_ports->device_addr); 717 tf->device = scc_ide_inb(io_ports->device_addr);
723 718
724 if (task->tf_flags & IDE_TFLAG_LBA48) { 719 if (task->tf_flags & IDE_TFLAG_LBA48) {
725 scc_ide_outb(drive->ctl | 0x80, io_ports->ctl_addr); 720 scc_ide_outb(ATA_DEVCTL_OBS | 0x80, io_ports->ctl_addr);
726 721
727 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE) 722 if (task->tf_flags & IDE_TFLAG_IN_HOB_FEATURE)
728 tf->hob_feature = scc_ide_inb(io_ports->feature_addr); 723 tf->hob_feature = scc_ide_inb(io_ports->feature_addr);
@@ -795,7 +790,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif)
795 790
796 hwif->dma_base = dma_base; 791 hwif->dma_base = dma_base;
797 hwif->config_data = ports->ctl; 792 hwif->config_data = ports->ctl;
798 hwif->mmio = 1;
799} 793}
800 794
801/** 795/**
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index 16a0bce17d6..24513e3dcd6 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -111,7 +111,7 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
111static void 111static void
112sgiioc4_maskproc(ide_drive_t * drive, int mask) 112sgiioc4_maskproc(ide_drive_t * drive, int mask)
113{ 113{
114 writeb(mask ? (drive->ctl | 2) : (drive->ctl & ~2), 114 writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0),
115 (void __iomem *)drive->hwif->io_ports.ctl_addr); 115 (void __iomem *)drive->hwif->io_ports.ctl_addr);
116} 116}
117 117
@@ -369,8 +369,7 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
369 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 369 hwif->sg_max_nents = IOC4_PRD_ENTRIES;
370 370
371 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, 371 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE,
372 (dma_addr_t *) &(hwif->dma_status)); 372 (dma_addr_t *)&hwif->extra_base);
373
374 if (pad) { 373 if (pad) {
375 ide_set_hwifdata(hwif, pad); 374 ide_set_hwifdata(hwif, pad);
376 return 0; 375 return 0;
@@ -439,7 +438,7 @@ sgiioc4_configure_for_dma(int dma_direction, ide_drive_t * drive)
439 438
440 /* Address of the Ending DMA */ 439 /* Address of the Ending DMA */
441 memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE); 440 memset(ide_get_hwifdata(hwif), 0, IOC4_IDE_CACHELINE_SIZE);
442 ending_dma_addr = cpu_to_le32(hwif->dma_status); 441 ending_dma_addr = cpu_to_le32(hwif->extra_base);
443 writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4)); 442 writel(ending_dma_addr, (void __iomem *)(dma_base + IOC4_DMA_END_ADDR * 4));
444 443
445 writel(dma_direction, (void __iomem *)ioc4_dma_addr); 444 writel(dma_direction, (void __iomem *)ioc4_dma_addr);
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 0006b9e5856..b75e9bb390a 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -94,7 +94,7 @@ static unsigned long siimage_selreg(ide_hwif_t *hwif, int r)
94 unsigned long base = (unsigned long)hwif->hwif_data; 94 unsigned long base = (unsigned long)hwif->hwif_data;
95 95
96 base += 0xA0 + r; 96 base += 0xA0 + r;
97 if (hwif->mmio) 97 if (hwif->host_flags & IDE_HFLAG_MMIO)
98 base += hwif->channel << 6; 98 base += hwif->channel << 6;
99 else 99 else
100 base += hwif->channel << 4; 100 base += hwif->channel << 4;
@@ -117,7 +117,7 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
117 unsigned long base = (unsigned long)hwif->hwif_data; 117 unsigned long base = (unsigned long)hwif->hwif_data;
118 118
119 base += 0xA0 + r; 119 base += 0xA0 + r;
120 if (hwif->mmio) 120 if (hwif->host_flags & IDE_HFLAG_MMIO)
121 base += hwif->channel << 6; 121 base += hwif->channel << 6;
122 else 122 else
123 base += hwif->channel << 4; 123 base += hwif->channel << 4;
@@ -190,7 +190,9 @@ static u8 sil_pata_udma_filter(ide_drive_t *drive)
190 unsigned long base = (unsigned long)hwif->hwif_data; 190 unsigned long base = (unsigned long)hwif->hwif_data;
191 u8 scsc, mask = 0; 191 u8 scsc, mask = 0;
192 192
193 scsc = sil_ioread8(dev, base + (hwif->mmio ? 0x4A : 0x8A)); 193 base += (hwif->host_flags & IDE_HFLAG_MMIO) ? 0x4A : 0x8A;
194
195 scsc = sil_ioread8(dev, base);
194 196
195 switch (scsc & 0x30) { 197 switch (scsc & 0x30) {
196 case 0x10: /* 133 */ 198 case 0x10: /* 133 */
@@ -238,8 +240,9 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio)
238 unsigned long tfaddr = siimage_selreg(hwif, 0x02); 240 unsigned long tfaddr = siimage_selreg(hwif, 0x02);
239 unsigned long base = (unsigned long)hwif->hwif_data; 241 unsigned long base = (unsigned long)hwif->hwif_data;
240 u8 tf_pio = pio; 242 u8 tf_pio = pio;
241 u8 addr_mask = hwif->channel ? (hwif->mmio ? 0xF4 : 0x84) 243 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
242 : (hwif->mmio ? 0xB4 : 0x80); 244 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
245 : (mmio ? 0xB4 : 0x80);
243 u8 mode = 0; 246 u8 mode = 0;
244 u8 unit = drive->select.b.unit; 247 u8 unit = drive->select.b.unit;
245 248
@@ -290,13 +293,13 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed)
290 u16 ultra = 0, multi = 0; 293 u16 ultra = 0, multi = 0;
291 u8 mode = 0, unit = drive->select.b.unit; 294 u8 mode = 0, unit = drive->select.b.unit;
292 unsigned long base = (unsigned long)hwif->hwif_data; 295 unsigned long base = (unsigned long)hwif->hwif_data;
293 u8 scsc = 0, addr_mask = hwif->channel ? 296 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0;
294 (hwif->mmio ? 0xF4 : 0x84) : 297 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84)
295 (hwif->mmio ? 0xB4 : 0x80); 298 : (mmio ? 0xB4 : 0x80);
296 unsigned long ma = siimage_seldev(drive, 0x08); 299 unsigned long ma = siimage_seldev(drive, 0x08);
297 unsigned long ua = siimage_seldev(drive, 0x0C); 300 unsigned long ua = siimage_seldev(drive, 0x0C);
298 301
299 scsc = sil_ioread8 (dev, base + (hwif->mmio ? 0x4A : 0x8A)); 302 scsc = sil_ioread8 (dev, base + (mmio ? 0x4A : 0x8A));
300 mode = sil_ioread8 (dev, base + addr_mask); 303 mode = sil_ioread8 (dev, base + addr_mask);
301 multi = sil_ioread16(dev, ma); 304 multi = sil_ioread16(dev, ma);
302 ultra = sil_ioread16(dev, ua); 305 ultra = sil_ioread16(dev, ua);
@@ -391,7 +394,7 @@ static int siimage_mmio_dma_test_irq(ide_drive_t *drive)
391 394
392static int siimage_dma_test_irq(ide_drive_t *drive) 395static int siimage_dma_test_irq(ide_drive_t *drive)
393{ 396{
394 if (drive->hwif->mmio) 397 if (drive->hwif->host_flags & IDE_HFLAG_MMIO)
395 return siimage_mmio_dma_test_irq(drive); 398 return siimage_mmio_dma_test_irq(drive);
396 else 399 else
397 return siimage_io_dma_test_irq(drive); 400 return siimage_io_dma_test_irq(drive);
@@ -640,8 +643,6 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
640 hwif->irq = dev->irq; 643 hwif->irq = dev->irq;
641 644
642 hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00); 645 hwif->dma_base = (unsigned long)addr + (ch ? 0x08 : 0x00);
643
644 hwif->mmio = 1;
645} 646}
646 647
647static int is_dev_seagate_sata(ide_drive_t *drive) 648static int is_dev_seagate_sata(ide_drive_t *drive)
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 566e0ecb8db..3ed9728abd2 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -120,21 +120,21 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing)
120 120
121 if (~vdev->via_config->flags & VIA_BAD_AST) { 121 if (~vdev->via_config->flags & VIA_BAD_AST) {
122 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); 122 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t);
123 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 123 t = (t & ~(3 << ((3 - dn) << 1))) | ((clamp_val(timing->setup, 1, 4) - 1) << ((3 - dn) << 1));
124 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); 124 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t);
125 } 125 }
126 126
127 pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)), 127 pci_write_config_byte(dev, VIA_8BIT_TIMING + (1 - (dn >> 1)),
128 ((FIT(timing->act8b, 1, 16) - 1) << 4) | (FIT(timing->rec8b, 1, 16) - 1)); 128 ((clamp_val(timing->act8b, 1, 16) - 1) << 4) | (clamp_val(timing->rec8b, 1, 16) - 1));
129 129
130 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), 130 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn),
131 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 131 ((clamp_val(timing->active, 1, 16) - 1) << 4) | (clamp_val(timing->recover, 1, 16) - 1));
132 132
133 switch (vdev->via_config->udma_mask) { 133 switch (vdev->via_config->udma_mask) {
134 case ATA_UDMA2: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 134 case ATA_UDMA2: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 5) - 2)) : 0x03; break;
135 case ATA_UDMA4: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; 135 case ATA_UDMA4: t = timing->udma ? (0xe8 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x0f; break;
136 case ATA_UDMA5: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; 136 case ATA_UDMA5: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break;
137 case ATA_UDMA6: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; 137 case ATA_UDMA6: t = timing->udma ? (0xe0 | (clamp_val(timing->udma, 2, 9) - 2)) : 0x07; break;
138 default: return; 138 default: return;
139 } 139 }
140 140
@@ -340,7 +340,7 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
340 * Determine system bus clock. 340 * Determine system bus clock.
341 */ 341 */
342 342
343 via_clock = (ide_pci_clk ? ide_pci_clk : system_bus_clock()) * 1000; 343 via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
344 344
345 switch (via_clock) { 345 switch (via_clock) {
346 case 33000: via_clock = 33333; break; 346 case 33000: via_clock = 33333; break;
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index ba2d5872796..dcb2c466bb9 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -480,13 +480,13 @@ pmac_ide_do_update_timings(ide_drive_t *drive)
480 pmac_ide_selectproc(drive); 480 pmac_ide_selectproc(drive);
481} 481}
482 482
483static void 483static void pmac_outbsync(ide_hwif_t *hwif, u8 value, unsigned long port)
484pmac_outbsync(ide_drive_t *drive, u8 value, unsigned long port)
485{ 484{
486 u32 tmp; 485 u32 tmp;
487 486
488 writeb(value, (void __iomem *) port); 487 writeb(value, (void __iomem *) port);
489 tmp = readl(PMAC_IDE_REG(IDE_TIMING_CONFIG)); 488 tmp = readl((void __iomem *)(hwif->io_ports.data_addr
489 + IDE_TIMING_CONFIG));
490} 490}
491 491
492/* 492/*
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 5171601fb25..abcfb1739d4 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -87,7 +87,7 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
87 unsigned long dma_base = 0; 87 unsigned long dma_base = 0;
88 u8 dma_stat = 0; 88 u8 dma_stat = 0;
89 89
90 if (hwif->mmio) 90 if (hwif->host_flags & IDE_HFLAG_MMIO)
91 return hwif->dma_base; 91 return hwif->dma_base;
92 92
93 if (hwif->mate && hwif->mate->dma_base) { 93 if (hwif->mate && hwif->mate->dma_base) {
@@ -374,7 +374,7 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
374 if (base == 0 || ide_pci_set_master(dev, d->name) < 0) 374 if (base == 0 || ide_pci_set_master(dev, d->name) < 0)
375 return -1; 375 return -1;
376 376
377 if (hwif->mmio) 377 if (hwif->host_flags & IDE_HFLAG_MMIO)
378 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 378 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
379 else 379 else
380 printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", 380 printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n",
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index e8122def164..9f95337139e 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -1049,6 +1049,24 @@ int csr1212_read(struct csr1212_csr *csr, u32 offset, void *buffer, u32 len)
1049 return -ENOENT; 1049 return -ENOENT;
1050} 1050}
1051 1051
1052/*
1053 * Apparently there are many different wrong implementations of the CRC
1054 * algorithm. We don't fail, we just warn... approximately once per GUID.
1055 */
1056static void
1057csr1212_check_crc(const u32 *buffer, size_t length, u16 crc, __be32 *guid)
1058{
1059 static u64 last_bad_eui64;
1060 u64 eui64 = ((u64)be32_to_cpu(guid[0]) << 32) | be32_to_cpu(guid[1]);
1061
1062 if (csr1212_crc16(buffer, length) == crc ||
1063 csr1212_msft_crc16(buffer, length) == crc ||
1064 eui64 == last_bad_eui64)
1065 return;
1066
1067 printk(KERN_DEBUG "ieee1394: config ROM CRC error\n");
1068 last_bad_eui64 = eui64;
1069}
1052 1070
1053/* Parse a chunk of data as a Config ROM */ 1071/* Parse a chunk of data as a Config ROM */
1054 1072
@@ -1092,11 +1110,8 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
1092 return ret; 1110 return ret;
1093 } 1111 }
1094 1112
1095 /* Apparently there are many different wrong implementations of the CRC 1113 csr1212_check_crc(bi->data, bi->crc_length, bi->crc,
1096 * algorithm. We don't fail, we just warn. */ 1114 &csr->bus_info_data[3]);
1097 if ((csr1212_crc16(bi->data, bi->crc_length) != bi->crc) &&
1098 (csr1212_msft_crc16(bi->data, bi->crc_length) != bi->crc))
1099 printk(KERN_DEBUG "IEEE 1394 device has ROM CRC error\n");
1100 1115
1101 cr = CSR1212_MALLOC(sizeof(*cr)); 1116 cr = CSR1212_MALLOC(sizeof(*cr));
1102 if (!cr) 1117 if (!cr)
@@ -1205,11 +1220,8 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv,
1205 &cache->data[bytes_to_quads(kv->offset - cache->offset)]; 1220 &cache->data[bytes_to_quads(kv->offset - cache->offset)];
1206 kvi_len = be16_to_cpu(kvi->length); 1221 kvi_len = be16_to_cpu(kvi->length);
1207 1222
1208 /* Apparently there are many different wrong implementations of the CRC 1223 /* GUID is wrong in here in case of extended ROM. We don't care. */
1209 * algorithm. We don't fail, we just warn. */ 1224 csr1212_check_crc(kvi->data, kvi_len, kvi->crc, &cache->data[3]);
1210 if ((csr1212_crc16(kvi->data, kvi_len) != kvi->crc) &&
1211 (csr1212_msft_crc16(kvi->data, kvi_len) != kvi->crc))
1212 printk(KERN_DEBUG "IEEE 1394 device has ROM CRC error\n");
1213 1225
1214 switch (kv->key.type) { 1226 switch (kv->key.type) {
1215 case CSR1212_KV_TYPE_DIRECTORY: 1227 case CSR1212_KV_TYPE_DIRECTORY:
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 73685e7dc7e..1aba8c13fe8 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -274,7 +274,7 @@ int dma_region_mmap(struct dma_region *dma, struct file *file,
274 vma->vm_ops = &dma_region_vm_ops; 274 vma->vm_ops = &dma_region_vm_ops;
275 vma->vm_private_data = dma; 275 vma->vm_private_data = dma;
276 vma->vm_file = file; 276 vma->vm_file = file;
277 vma->vm_flags |= VM_RESERVED; 277 vma->vm_flags |= VM_RESERVED | VM_ALWAYSDUMP;
278 278
279 return 0; 279 return 0;
280} 280}
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
index fa2bfec0fca..918ffc4fc8a 100644
--- a/drivers/ieee1394/highlevel.c
+++ b/drivers/ieee1394/highlevel.c
@@ -228,10 +228,8 @@ void hpsb_register_highlevel(struct hpsb_highlevel *hl)
228{ 228{
229 unsigned long flags; 229 unsigned long flags;
230 230
231 hpsb_init_highlevel(hl);
231 INIT_LIST_HEAD(&hl->addr_list); 232 INIT_LIST_HEAD(&hl->addr_list);
232 INIT_LIST_HEAD(&hl->host_info_list);
233
234 rwlock_init(&hl->host_info_lock);
235 233
236 down_write(&hl_drivers_sem); 234 down_write(&hl_drivers_sem);
237 list_add_tail(&hl->hl_list, &hl_drivers); 235 list_add_tail(&hl->hl_list, &hl_drivers);
diff --git a/drivers/ieee1394/highlevel.h b/drivers/ieee1394/highlevel.h
index eb9fe321e09..bc5d0854c17 100644
--- a/drivers/ieee1394/highlevel.h
+++ b/drivers/ieee1394/highlevel.h
@@ -2,7 +2,7 @@
2#define IEEE1394_HIGHLEVEL_H 2#define IEEE1394_HIGHLEVEL_H
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/spinlock_types.h> 5#include <linux/spinlock.h>
6#include <linux/types.h> 6#include <linux/types.h>
7 7
8struct module; 8struct module;
@@ -103,6 +103,17 @@ int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
103void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction, 103void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
104 void *data, size_t length); 104 void *data, size_t length);
105 105
106/**
107 * hpsb_init_highlevel - initialize a struct hpsb_highlevel
108 *
109 * This is only necessary if hpsb_get_hostinfo_bykey can be called
110 * before hpsb_register_highlevel.
111 */
112static inline void hpsb_init_highlevel(struct hpsb_highlevel *hl)
113{
114 rwlock_init(&hl->host_info_lock);
115 INIT_LIST_HEAD(&hl->host_info_list);
116}
106void hpsb_register_highlevel(struct hpsb_highlevel *hl); 117void hpsb_register_highlevel(struct hpsb_highlevel *hl);
107void hpsb_unregister_highlevel(struct hpsb_highlevel *hl); 118void hpsb_unregister_highlevel(struct hpsb_highlevel *hl);
108 119
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index ec2a0adbedb..96f2847b040 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -2549,8 +2549,8 @@ static int raw1394_mmap(struct file *file, struct vm_area_struct *vma)
2549} 2549}
2550 2550
2551/* ioctl is only used for rawiso operations */ 2551/* ioctl is only used for rawiso operations */
2552static int raw1394_ioctl(struct inode *inode, struct file *file, 2552static long do_raw1394_ioctl(struct file *file, unsigned int cmd,
2553 unsigned int cmd, unsigned long arg) 2553 unsigned long arg)
2554{ 2554{
2555 struct file_info *fi = file->private_data; 2555 struct file_info *fi = file->private_data;
2556 void __user *argp = (void __user *)arg; 2556 void __user *argp = (void __user *)arg;
@@ -2656,6 +2656,16 @@ static int raw1394_ioctl(struct inode *inode, struct file *file,
2656 return -EINVAL; 2656 return -EINVAL;
2657} 2657}
2658 2658
2659static long raw1394_ioctl(struct file *file, unsigned int cmd,
2660 unsigned long arg)
2661{
2662 long ret;
2663 lock_kernel();
2664 ret = do_raw1394_ioctl(file, cmd, arg);
2665 unlock_kernel();
2666 return ret;
2667}
2668
2659#ifdef CONFIG_COMPAT 2669#ifdef CONFIG_COMPAT
2660struct raw1394_iso_packets32 { 2670struct raw1394_iso_packets32 {
2661 __u32 n_packets; 2671 __u32 n_packets;
@@ -2690,7 +2700,7 @@ static long raw1394_iso_xmit_recv_packets32(struct file *file, unsigned int cmd,
2690 !copy_from_user(&infos32, &arg->infos, sizeof infos32)) { 2700 !copy_from_user(&infos32, &arg->infos, sizeof infos32)) {
2691 infos = compat_ptr(infos32); 2701 infos = compat_ptr(infos32);
2692 if (!copy_to_user(&dst->infos, &infos, sizeof infos)) 2702 if (!copy_to_user(&dst->infos, &infos, sizeof infos))
2693 err = raw1394_ioctl(NULL, file, cmd, (unsigned long)dst); 2703 err = do_raw1394_ioctl(file, cmd, (unsigned long)dst);
2694 } 2704 }
2695 return err; 2705 return err;
2696} 2706}
@@ -2731,7 +2741,7 @@ static long raw1394_compat_ioctl(struct file *file,
2731 case RAW1394_IOC_ISO_GET_STATUS: 2741 case RAW1394_IOC_ISO_GET_STATUS:
2732 case RAW1394_IOC_ISO_SHUTDOWN: 2742 case RAW1394_IOC_ISO_SHUTDOWN:
2733 case RAW1394_IOC_ISO_QUEUE_ACTIVITY: 2743 case RAW1394_IOC_ISO_QUEUE_ACTIVITY:
2734 err = raw1394_ioctl(NULL, file, cmd, arg); 2744 err = do_raw1394_ioctl(file, cmd, arg);
2735 break; 2745 break;
2736 /* These request have different format. */ 2746 /* These request have different format. */
2737 case RAW1394_IOC_ISO_RECV_PACKETS32: 2747 case RAW1394_IOC_ISO_RECV_PACKETS32:
@@ -2984,7 +2994,7 @@ static const struct file_operations raw1394_fops = {
2984 .read = raw1394_read, 2994 .read = raw1394_read,
2985 .write = raw1394_write, 2995 .write = raw1394_write,
2986 .mmap = raw1394_mmap, 2996 .mmap = raw1394_mmap,
2987 .ioctl = raw1394_ioctl, 2997 .unlocked_ioctl = raw1394_ioctl,
2988#ifdef CONFIG_COMPAT 2998#ifdef CONFIG_COMPAT
2989 .compat_ioctl = raw1394_compat_ioctl, 2999 .compat_ioctl = raw1394_compat_ioctl,
2990#endif 3000#endif
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index a5ceff287a2..9cbf3154d24 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -186,6 +186,11 @@ MODULE_PARM_DESC(exclusive_login, "Exclusive login to sbp2 device "
186 * - delay inquiry 186 * - delay inquiry
187 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry. 187 * Wait extra SBP2_INQUIRY_DELAY seconds after login before SCSI inquiry.
188 * 188 *
189 * - power condition
190 * Set the power condition field in the START STOP UNIT commands sent by
191 * sd_mod on suspend, resume, and shutdown (if manage_start_stop is on).
192 * Some disks need this to spin down or to resume properly.
193 *
189 * - override internal blacklist 194 * - override internal blacklist
190 * Instead of adding to the built-in blacklist, use only the workarounds 195 * Instead of adding to the built-in blacklist, use only the workarounds
191 * specified in the module load parameter. 196 * specified in the module load parameter.
@@ -199,6 +204,8 @@ MODULE_PARM_DESC(workarounds, "Work around device bugs (default = 0"
199 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8) 204 ", skip mode page 8 = " __stringify(SBP2_WORKAROUND_MODE_SENSE_8)
200 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY) 205 ", fix capacity = " __stringify(SBP2_WORKAROUND_FIX_CAPACITY)
201 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY) 206 ", delay inquiry = " __stringify(SBP2_WORKAROUND_DELAY_INQUIRY)
207 ", set power condition in start stop unit = "
208 __stringify(SBP2_WORKAROUND_POWER_CONDITION)
202 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE) 209 ", override internal blacklist = " __stringify(SBP2_WORKAROUND_OVERRIDE)
203 ", or a combination)"); 210 ", or a combination)");
204 211
@@ -359,18 +366,25 @@ static const struct {
359 .firmware_revision = 0x002800, 366 .firmware_revision = 0x002800,
360 .model_id = 0x001010, 367 .model_id = 0x001010,
361 .workarounds = SBP2_WORKAROUND_INQUIRY_36 | 368 .workarounds = SBP2_WORKAROUND_INQUIRY_36 |
362 SBP2_WORKAROUND_MODE_SENSE_8, 369 SBP2_WORKAROUND_MODE_SENSE_8 |
370 SBP2_WORKAROUND_POWER_CONDITION,
363 }, 371 },
364 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ { 372 /* DViCO Momobay FX-3A with TSB42AA9A bridge */ {
365 .firmware_revision = 0x002800, 373 .firmware_revision = 0x002800,
366 .model_id = 0x000000, 374 .model_id = 0x000000,
367 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY, 375 .workarounds = SBP2_WORKAROUND_DELAY_INQUIRY |
376 SBP2_WORKAROUND_POWER_CONDITION,
368 }, 377 },
369 /* Initio bridges, actually only needed for some older ones */ { 378 /* Initio bridges, actually only needed for some older ones */ {
370 .firmware_revision = 0x000200, 379 .firmware_revision = 0x000200,
371 .model_id = SBP2_ROM_VALUE_WILDCARD, 380 .model_id = SBP2_ROM_VALUE_WILDCARD,
372 .workarounds = SBP2_WORKAROUND_INQUIRY_36, 381 .workarounds = SBP2_WORKAROUND_INQUIRY_36,
373 }, 382 },
383 /* PL-3507 bridge with Prolific firmware */ {
384 .firmware_revision = 0x012800,
385 .model_id = SBP2_ROM_VALUE_WILDCARD,
386 .workarounds = SBP2_WORKAROUND_POWER_CONDITION,
387 },
374 /* Symbios bridge */ { 388 /* Symbios bridge */ {
375 .firmware_revision = 0xa0b800, 389 .firmware_revision = 0xa0b800,
376 .model_id = SBP2_ROM_VALUE_WILDCARD, 390 .model_id = SBP2_ROM_VALUE_WILDCARD,
@@ -1995,6 +2009,8 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
1995 2009
1996 sdev->use_10_for_rw = 1; 2010 sdev->use_10_for_rw = 1;
1997 2011
2012 if (sbp2_exclusive_login)
2013 sdev->manage_start_stop = 1;
1998 if (sdev->type == TYPE_ROM) 2014 if (sdev->type == TYPE_ROM)
1999 sdev->use_10_for_ms = 1; 2015 sdev->use_10_for_ms = 1;
2000 if (sdev->type == TYPE_DISK && 2016 if (sdev->type == TYPE_DISK &&
@@ -2002,6 +2018,8 @@ static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2002 sdev->skip_ms_page_8 = 1; 2018 sdev->skip_ms_page_8 = 1;
2003 if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY) 2019 if (lu->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
2004 sdev->fix_capacity = 1; 2020 sdev->fix_capacity = 1;
2021 if (lu->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
2022 sdev->start_stop_pwr_cond = 1;
2005 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS) 2023 if (lu->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
2006 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512); 2024 blk_queue_max_sectors(sdev->request_queue, 128 * 1024 / 512);
2007 return 0; 2025 return 0;
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index 80d8e097b06..875428bc8d2 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -345,6 +345,7 @@ enum sbp2lu_state_types {
345#define SBP2_WORKAROUND_FIX_CAPACITY 0x8 345#define SBP2_WORKAROUND_FIX_CAPACITY 0x8
346#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10 346#define SBP2_WORKAROUND_DELAY_INQUIRY 0x10
347#define SBP2_INQUIRY_DELAY 12 347#define SBP2_INQUIRY_DELAY 12
348#define SBP2_WORKAROUND_POWER_CONDITION 0x20
348#define SBP2_WORKAROUND_OVERRIDE 0x100 349#define SBP2_WORKAROUND_OVERRIDE 0x100
349 350
350#endif /* SBP2_H */ 351#endif /* SBP2_H */
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index e24772d336e..069b9f6bf16 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -1503,6 +1503,8 @@ static int __init video1394_init_module (void)
1503{ 1503{
1504 int ret; 1504 int ret;
1505 1505
1506 hpsb_init_highlevel(&video1394_highlevel);
1507
1506 cdev_init(&video1394_cdev, &video1394_fops); 1508 cdev_init(&video1394_cdev, &video1394_fops);
1507 video1394_cdev.owner = THIS_MODULE; 1509 video1394_cdev.owner = THIS_MODULE;
1508 ret = cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16); 1510 ret = cdev_add(&video1394_cdev, IEEE1394_VIDEO1394_DEV, 16);
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 781ea595037..09a2bec7fd3 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -4,28 +4,33 @@
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved. 4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005 Intel Corporation. All rights reserved. 5 * Copyright (c) 2005 Intel Corporation. All rights reserved.
6 * 6 *
7 * This Software is licensed under one of the following licenses: 7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
8 * 12 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is 13 * Redistribution and use in source and binary forms, with or
10 * available from the Open Source Initiative, see 14 * without modification, are permitted provided that the following
11 * http://www.opensource.org/licenses/cpl.php. 15 * conditions are met:
12 * 16 *
13 * 2) under the terms of the "The BSD License" a copy of which is 17 * - Redistributions of source code must retain the above
14 * available from the Open Source Initiative, see 18 * copyright notice, this list of conditions and the following
15 * http://www.opensource.org/licenses/bsd-license.php. 19 * disclaimer.
16 * 20 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 21 * - Redistributions in binary form must reproduce the above
18 * copy of which is available from the Open Source Initiative, see 22 * copyright notice, this list of conditions and the following
19 * http://www.opensource.org/licenses/gpl-license.php. 23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
20 * 25 *
21 * Licensee has the right to choose one of the above licenses. 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * Redistributions of source code must retain the above copyright 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * notice and one of the license notices. 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 * 30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 * Redistributions in binary form must reproduce both the above copyright 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * notice, one of the license notices in the documentation 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 * and/or other materials provided with the distribution. 33 * SOFTWARE.
29 */ 34 */
30 35
31#include <linux/mutex.h> 36#include <linux/mutex.h>
@@ -100,6 +105,7 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
100 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN); 105 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
101 if (dst_dev_addr) 106 if (dst_dev_addr)
102 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN); 107 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
108 dev_addr->src_dev = dev;
103 return 0; 109 return 0;
104} 110}
105EXPORT_SYMBOL(rdma_copy_addr); 111EXPORT_SYMBOL(rdma_copy_addr);
diff --git a/drivers/infiniband/core/agent.h b/drivers/infiniband/core/agent.h
index fb9ed1489f9..6669287009c 100644
--- a/drivers/infiniband/core/agent.h
+++ b/drivers/infiniband/core/agent.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: agent.h 1389 2004-12-27 22:56:47Z roland $
37 */ 35 */
38 36
39#ifndef __AGENT_H_ 37#ifndef __AGENT_H_
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index e85f7013de5..68883565b72 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: cache.c 1349 2004-12-16 21:09:43Z roland $
36 */ 34 */
37 35
38#include <linux/module.h> 36#include <linux/module.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index a47fe64e5c3..55738eead3b 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: cm.c 4311 2005-12-05 18:42:01Z sean.hefty $
36 */ 34 */
37 35
38#include <linux/completion.h> 36#include <linux/completion.h>
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 671f1373805..ae11d5cc74d 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4,29 +4,33 @@
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved. 4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. 5 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
6 * 6 *
7 * This Software is licensed under one of the following licenses: 7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
8 * 12 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is 13 * Redistribution and use in source and binary forms, with or
10 * available from the Open Source Initiative, see 14 * without modification, are permitted provided that the following
11 * http://www.opensource.org/licenses/cpl.php. 15 * conditions are met:
12 * 16 *
13 * 2) under the terms of the "The BSD License" a copy of which is 17 * - Redistributions of source code must retain the above
14 * available from the Open Source Initiative, see 18 * copyright notice, this list of conditions and the following
15 * http://www.opensource.org/licenses/bsd-license.php. 19 * disclaimer.
16 * 20 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 21 * - Redistributions in binary form must reproduce the above
18 * copy of which is available from the Open Source Initiative, see 22 * copyright notice, this list of conditions and the following
19 * http://www.opensource.org/licenses/gpl-license.php. 23 * disclaimer in the documentation and/or other materials
20 * 24 * provided with the distribution.
21 * Licensee has the right to choose one of the above licenses.
22 *
23 * Redistributions of source code must retain the above copyright
24 * notice and one of the license notices.
25 *
26 * Redistributions in binary form must reproduce both the above copyright
27 * notice, one of the license notices in the documentation
28 * and/or other materials provided with the distribution.
29 * 25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
30 */ 34 */
31 35
32#include <linux/completion.h> 36#include <linux/completion.h>
@@ -126,8 +130,7 @@ struct rdma_id_private {
126 130
127 struct completion comp; 131 struct completion comp;
128 atomic_t refcount; 132 atomic_t refcount;
129 wait_queue_head_t wait_remove; 133 struct mutex handler_mutex;
130 atomic_t dev_remove;
131 134
132 int backlog; 135 int backlog;
133 int timeout_ms; 136 int timeout_ms;
@@ -351,26 +354,15 @@ static void cma_deref_id(struct rdma_id_private *id_priv)
351 complete(&id_priv->comp); 354 complete(&id_priv->comp);
352} 355}
353 356
354static int cma_disable_remove(struct rdma_id_private *id_priv, 357static int cma_disable_callback(struct rdma_id_private *id_priv,
355 enum cma_state state) 358 enum cma_state state)
356{ 359{
357 unsigned long flags; 360 mutex_lock(&id_priv->handler_mutex);
358 int ret; 361 if (id_priv->state != state) {
359 362 mutex_unlock(&id_priv->handler_mutex);
360 spin_lock_irqsave(&id_priv->lock, flags); 363 return -EINVAL;
361 if (id_priv->state == state) { 364 }
362 atomic_inc(&id_priv->dev_remove); 365 return 0;
363 ret = 0;
364 } else
365 ret = -EINVAL;
366 spin_unlock_irqrestore(&id_priv->lock, flags);
367 return ret;
368}
369
370static void cma_enable_remove(struct rdma_id_private *id_priv)
371{
372 if (atomic_dec_and_test(&id_priv->dev_remove))
373 wake_up(&id_priv->wait_remove);
374} 366}
375 367
376static int cma_has_cm_dev(struct rdma_id_private *id_priv) 368static int cma_has_cm_dev(struct rdma_id_private *id_priv)
@@ -395,8 +387,7 @@ struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
395 mutex_init(&id_priv->qp_mutex); 387 mutex_init(&id_priv->qp_mutex);
396 init_completion(&id_priv->comp); 388 init_completion(&id_priv->comp);
397 atomic_set(&id_priv->refcount, 1); 389 atomic_set(&id_priv->refcount, 1);
398 init_waitqueue_head(&id_priv->wait_remove); 390 mutex_init(&id_priv->handler_mutex);
399 atomic_set(&id_priv->dev_remove, 0);
400 INIT_LIST_HEAD(&id_priv->listen_list); 391 INIT_LIST_HEAD(&id_priv->listen_list);
401 INIT_LIST_HEAD(&id_priv->mc_list); 392 INIT_LIST_HEAD(&id_priv->mc_list);
402 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num); 393 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
@@ -923,7 +914,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
923 struct rdma_cm_event event; 914 struct rdma_cm_event event;
924 int ret = 0; 915 int ret = 0;
925 916
926 if (cma_disable_remove(id_priv, CMA_CONNECT)) 917 if (cma_disable_callback(id_priv, CMA_CONNECT))
927 return 0; 918 return 0;
928 919
929 memset(&event, 0, sizeof event); 920 memset(&event, 0, sizeof event);
@@ -970,7 +961,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
970 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; 961 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
971 break; 962 break;
972 default: 963 default:
973 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d", 964 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
974 ib_event->event); 965 ib_event->event);
975 goto out; 966 goto out;
976 } 967 }
@@ -980,12 +971,12 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
980 /* Destroy the CM ID by returning a non-zero value. */ 971 /* Destroy the CM ID by returning a non-zero value. */
981 id_priv->cm_id.ib = NULL; 972 id_priv->cm_id.ib = NULL;
982 cma_exch(id_priv, CMA_DESTROYING); 973 cma_exch(id_priv, CMA_DESTROYING);
983 cma_enable_remove(id_priv); 974 mutex_unlock(&id_priv->handler_mutex);
984 rdma_destroy_id(&id_priv->id); 975 rdma_destroy_id(&id_priv->id);
985 return ret; 976 return ret;
986 } 977 }
987out: 978out:
988 cma_enable_remove(id_priv); 979 mutex_unlock(&id_priv->handler_mutex);
989 return ret; 980 return ret;
990} 981}
991 982
@@ -998,6 +989,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
998 union cma_ip_addr *src, *dst; 989 union cma_ip_addr *src, *dst;
999 __be16 port; 990 __be16 port;
1000 u8 ip_ver; 991 u8 ip_ver;
992 int ret;
1001 993
1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps, 994 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
1003 &ip_ver, &port, &src, &dst)) 995 &ip_ver, &port, &src, &dst))
@@ -1022,10 +1014,11 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
1022 if (rt->num_paths == 2) 1014 if (rt->num_paths == 2)
1023 rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; 1015 rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
1024 1016
1025 ib_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
1026 ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); 1017 ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
1027 ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey)); 1018 ret = rdma_translate_ip(&id->route.addr.src_addr,
1028 rt->addr.dev_addr.dev_type = RDMA_NODE_IB_CA; 1019 &id->route.addr.dev_addr);
1020 if (ret)
1021 goto destroy_id;
1029 1022
1030 id_priv = container_of(id, struct rdma_id_private, id); 1023 id_priv = container_of(id, struct rdma_id_private, id);
1031 id_priv->state = CMA_CONNECT; 1024 id_priv->state = CMA_CONNECT;
@@ -1095,7 +1088,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1095 int offset, ret; 1088 int offset, ret;
1096 1089
1097 listen_id = cm_id->context; 1090 listen_id = cm_id->context;
1098 if (cma_disable_remove(listen_id, CMA_LISTEN)) 1091 if (cma_disable_callback(listen_id, CMA_LISTEN))
1099 return -ECONNABORTED; 1092 return -ECONNABORTED;
1100 1093
1101 memset(&event, 0, sizeof event); 1094 memset(&event, 0, sizeof event);
@@ -1116,7 +1109,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1116 goto out; 1109 goto out;
1117 } 1110 }
1118 1111
1119 atomic_inc(&conn_id->dev_remove); 1112 mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
1120 mutex_lock(&lock); 1113 mutex_lock(&lock);
1121 ret = cma_acquire_dev(conn_id); 1114 ret = cma_acquire_dev(conn_id);
1122 mutex_unlock(&lock); 1115 mutex_unlock(&lock);
@@ -1138,7 +1131,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1138 !cma_is_ud_ps(conn_id->id.ps)) 1131 !cma_is_ud_ps(conn_id->id.ps))
1139 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0); 1132 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1140 mutex_unlock(&lock); 1133 mutex_unlock(&lock);
1141 cma_enable_remove(conn_id); 1134 mutex_unlock(&conn_id->handler_mutex);
1142 goto out; 1135 goto out;
1143 } 1136 }
1144 1137
@@ -1147,11 +1140,11 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1147 1140
1148release_conn_id: 1141release_conn_id:
1149 cma_exch(conn_id, CMA_DESTROYING); 1142 cma_exch(conn_id, CMA_DESTROYING);
1150 cma_enable_remove(conn_id); 1143 mutex_unlock(&conn_id->handler_mutex);
1151 rdma_destroy_id(&conn_id->id); 1144 rdma_destroy_id(&conn_id->id);
1152 1145
1153out: 1146out:
1154 cma_enable_remove(listen_id); 1147 mutex_unlock(&listen_id->handler_mutex);
1155 return ret; 1148 return ret;
1156} 1149}
1157 1150
@@ -1217,7 +1210,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1217 struct sockaddr_in *sin; 1210 struct sockaddr_in *sin;
1218 int ret = 0; 1211 int ret = 0;
1219 1212
1220 if (cma_disable_remove(id_priv, CMA_CONNECT)) 1213 if (cma_disable_callback(id_priv, CMA_CONNECT))
1221 return 0; 1214 return 0;
1222 1215
1223 memset(&event, 0, sizeof event); 1216 memset(&event, 0, sizeof event);
@@ -1261,12 +1254,12 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1261 /* Destroy the CM ID by returning a non-zero value. */ 1254 /* Destroy the CM ID by returning a non-zero value. */
1262 id_priv->cm_id.iw = NULL; 1255 id_priv->cm_id.iw = NULL;
1263 cma_exch(id_priv, CMA_DESTROYING); 1256 cma_exch(id_priv, CMA_DESTROYING);
1264 cma_enable_remove(id_priv); 1257 mutex_unlock(&id_priv->handler_mutex);
1265 rdma_destroy_id(&id_priv->id); 1258 rdma_destroy_id(&id_priv->id);
1266 return ret; 1259 return ret;
1267 } 1260 }
1268 1261
1269 cma_enable_remove(id_priv); 1262 mutex_unlock(&id_priv->handler_mutex);
1270 return ret; 1263 return ret;
1271} 1264}
1272 1265
@@ -1282,7 +1275,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1282 struct ib_device_attr attr; 1275 struct ib_device_attr attr;
1283 1276
1284 listen_id = cm_id->context; 1277 listen_id = cm_id->context;
1285 if (cma_disable_remove(listen_id, CMA_LISTEN)) 1278 if (cma_disable_callback(listen_id, CMA_LISTEN))
1286 return -ECONNABORTED; 1279 return -ECONNABORTED;
1287 1280
1288 /* Create a new RDMA id for the new IW CM ID */ 1281 /* Create a new RDMA id for the new IW CM ID */
@@ -1294,19 +1287,19 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1294 goto out; 1287 goto out;
1295 } 1288 }
1296 conn_id = container_of(new_cm_id, struct rdma_id_private, id); 1289 conn_id = container_of(new_cm_id, struct rdma_id_private, id);
1297 atomic_inc(&conn_id->dev_remove); 1290 mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
1298 conn_id->state = CMA_CONNECT; 1291 conn_id->state = CMA_CONNECT;
1299 1292
1300 dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr); 1293 dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr);
1301 if (!dev) { 1294 if (!dev) {
1302 ret = -EADDRNOTAVAIL; 1295 ret = -EADDRNOTAVAIL;
1303 cma_enable_remove(conn_id); 1296 mutex_unlock(&conn_id->handler_mutex);
1304 rdma_destroy_id(new_cm_id); 1297 rdma_destroy_id(new_cm_id);
1305 goto out; 1298 goto out;
1306 } 1299 }
1307 ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL); 1300 ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL);
1308 if (ret) { 1301 if (ret) {
1309 cma_enable_remove(conn_id); 1302 mutex_unlock(&conn_id->handler_mutex);
1310 rdma_destroy_id(new_cm_id); 1303 rdma_destroy_id(new_cm_id);
1311 goto out; 1304 goto out;
1312 } 1305 }
@@ -1315,7 +1308,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1315 ret = cma_acquire_dev(conn_id); 1308 ret = cma_acquire_dev(conn_id);
1316 mutex_unlock(&lock); 1309 mutex_unlock(&lock);
1317 if (ret) { 1310 if (ret) {
1318 cma_enable_remove(conn_id); 1311 mutex_unlock(&conn_id->handler_mutex);
1319 rdma_destroy_id(new_cm_id); 1312 rdma_destroy_id(new_cm_id);
1320 goto out; 1313 goto out;
1321 } 1314 }
@@ -1331,7 +1324,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1331 1324
1332 ret = ib_query_device(conn_id->id.device, &attr); 1325 ret = ib_query_device(conn_id->id.device, &attr);
1333 if (ret) { 1326 if (ret) {
1334 cma_enable_remove(conn_id); 1327 mutex_unlock(&conn_id->handler_mutex);
1335 rdma_destroy_id(new_cm_id); 1328 rdma_destroy_id(new_cm_id);
1336 goto out; 1329 goto out;
1337 } 1330 }
@@ -1347,14 +1340,17 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1347 /* User wants to destroy the CM ID */ 1340 /* User wants to destroy the CM ID */
1348 conn_id->cm_id.iw = NULL; 1341 conn_id->cm_id.iw = NULL;
1349 cma_exch(conn_id, CMA_DESTROYING); 1342 cma_exch(conn_id, CMA_DESTROYING);
1350 cma_enable_remove(conn_id); 1343 mutex_unlock(&conn_id->handler_mutex);
1351 rdma_destroy_id(&conn_id->id); 1344 rdma_destroy_id(&conn_id->id);
1345 goto out;
1352 } 1346 }
1353 1347
1348 mutex_unlock(&conn_id->handler_mutex);
1349
1354out: 1350out:
1355 if (dev) 1351 if (dev)
1356 dev_put(dev); 1352 dev_put(dev);
1357 cma_enable_remove(listen_id); 1353 mutex_unlock(&listen_id->handler_mutex);
1358 return ret; 1354 return ret;
1359} 1355}
1360 1356
@@ -1446,7 +1442,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
1446 ret = rdma_listen(id, id_priv->backlog); 1442 ret = rdma_listen(id, id_priv->backlog);
1447 if (ret) 1443 if (ret)
1448 printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, " 1444 printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, "
1449 "listening on device %s", ret, cma_dev->device->name); 1445 "listening on device %s\n", ret, cma_dev->device->name);
1450} 1446}
1451 1447
1452static void cma_listen_on_all(struct rdma_id_private *id_priv) 1448static void cma_listen_on_all(struct rdma_id_private *id_priv)
@@ -1586,7 +1582,7 @@ static void cma_work_handler(struct work_struct *_work)
1586 struct rdma_id_private *id_priv = work->id; 1582 struct rdma_id_private *id_priv = work->id;
1587 int destroy = 0; 1583 int destroy = 0;
1588 1584
1589 atomic_inc(&id_priv->dev_remove); 1585 mutex_lock(&id_priv->handler_mutex);
1590 if (!cma_comp_exch(id_priv, work->old_state, work->new_state)) 1586 if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
1591 goto out; 1587 goto out;
1592 1588
@@ -1595,7 +1591,7 @@ static void cma_work_handler(struct work_struct *_work)
1595 destroy = 1; 1591 destroy = 1;
1596 } 1592 }
1597out: 1593out:
1598 cma_enable_remove(id_priv); 1594 mutex_unlock(&id_priv->handler_mutex);
1599 cma_deref_id(id_priv); 1595 cma_deref_id(id_priv);
1600 if (destroy) 1596 if (destroy)
1601 rdma_destroy_id(&id_priv->id); 1597 rdma_destroy_id(&id_priv->id);
@@ -1758,7 +1754,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1758 struct rdma_cm_event event; 1754 struct rdma_cm_event event;
1759 1755
1760 memset(&event, 0, sizeof event); 1756 memset(&event, 0, sizeof event);
1761 atomic_inc(&id_priv->dev_remove); 1757 mutex_lock(&id_priv->handler_mutex);
1762 1758
1763 /* 1759 /*
1764 * Grab mutex to block rdma_destroy_id() from removing the device while 1760 * Grab mutex to block rdma_destroy_id() from removing the device while
@@ -1787,13 +1783,13 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1787 1783
1788 if (id_priv->id.event_handler(&id_priv->id, &event)) { 1784 if (id_priv->id.event_handler(&id_priv->id, &event)) {
1789 cma_exch(id_priv, CMA_DESTROYING); 1785 cma_exch(id_priv, CMA_DESTROYING);
1790 cma_enable_remove(id_priv); 1786 mutex_unlock(&id_priv->handler_mutex);
1791 cma_deref_id(id_priv); 1787 cma_deref_id(id_priv);
1792 rdma_destroy_id(&id_priv->id); 1788 rdma_destroy_id(&id_priv->id);
1793 return; 1789 return;
1794 } 1790 }
1795out: 1791out:
1796 cma_enable_remove(id_priv); 1792 mutex_unlock(&id_priv->handler_mutex);
1797 cma_deref_id(id_priv); 1793 cma_deref_id(id_priv);
1798} 1794}
1799 1795
@@ -2120,7 +2116,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2120 struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd; 2116 struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd;
2121 int ret = 0; 2117 int ret = 0;
2122 2118
2123 if (cma_disable_remove(id_priv, CMA_CONNECT)) 2119 if (cma_disable_callback(id_priv, CMA_CONNECT))
2124 return 0; 2120 return 0;
2125 2121
2126 memset(&event, 0, sizeof event); 2122 memset(&event, 0, sizeof event);
@@ -2151,7 +2147,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2151 event.status = 0; 2147 event.status = 0;
2152 break; 2148 break;
2153 default: 2149 default:
2154 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d", 2150 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
2155 ib_event->event); 2151 ib_event->event);
2156 goto out; 2152 goto out;
2157 } 2153 }
@@ -2161,12 +2157,12 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2161 /* Destroy the CM ID by returning a non-zero value. */ 2157 /* Destroy the CM ID by returning a non-zero value. */
2162 id_priv->cm_id.ib = NULL; 2158 id_priv->cm_id.ib = NULL;
2163 cma_exch(id_priv, CMA_DESTROYING); 2159 cma_exch(id_priv, CMA_DESTROYING);
2164 cma_enable_remove(id_priv); 2160 mutex_unlock(&id_priv->handler_mutex);
2165 rdma_destroy_id(&id_priv->id); 2161 rdma_destroy_id(&id_priv->id);
2166 return ret; 2162 return ret;
2167 } 2163 }
2168out: 2164out:
2169 cma_enable_remove(id_priv); 2165 mutex_unlock(&id_priv->handler_mutex);
2170 return ret; 2166 return ret;
2171} 2167}
2172 2168
@@ -2564,8 +2560,8 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
2564 int ret; 2560 int ret;
2565 2561
2566 id_priv = mc->id_priv; 2562 id_priv = mc->id_priv;
2567 if (cma_disable_remove(id_priv, CMA_ADDR_BOUND) && 2563 if (cma_disable_callback(id_priv, CMA_ADDR_BOUND) &&
2568 cma_disable_remove(id_priv, CMA_ADDR_RESOLVED)) 2564 cma_disable_callback(id_priv, CMA_ADDR_RESOLVED))
2569 return 0; 2565 return 0;
2570 2566
2571 mutex_lock(&id_priv->qp_mutex); 2567 mutex_lock(&id_priv->qp_mutex);
@@ -2590,12 +2586,12 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
2590 ret = id_priv->id.event_handler(&id_priv->id, &event); 2586 ret = id_priv->id.event_handler(&id_priv->id, &event);
2591 if (ret) { 2587 if (ret) {
2592 cma_exch(id_priv, CMA_DESTROYING); 2588 cma_exch(id_priv, CMA_DESTROYING);
2593 cma_enable_remove(id_priv); 2589 mutex_unlock(&id_priv->handler_mutex);
2594 rdma_destroy_id(&id_priv->id); 2590 rdma_destroy_id(&id_priv->id);
2595 return 0; 2591 return 0;
2596 } 2592 }
2597 2593
2598 cma_enable_remove(id_priv); 2594 mutex_unlock(&id_priv->handler_mutex);
2599 return 0; 2595 return 0;
2600} 2596}
2601 2597
@@ -2754,6 +2750,7 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2754{ 2750{
2755 struct rdma_cm_event event; 2751 struct rdma_cm_event event;
2756 enum cma_state state; 2752 enum cma_state state;
2753 int ret = 0;
2757 2754
2758 /* Record that we want to remove the device */ 2755 /* Record that we want to remove the device */
2759 state = cma_exch(id_priv, CMA_DEVICE_REMOVAL); 2756 state = cma_exch(id_priv, CMA_DEVICE_REMOVAL);
@@ -2761,15 +2758,18 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2761 return 0; 2758 return 0;
2762 2759
2763 cma_cancel_operation(id_priv, state); 2760 cma_cancel_operation(id_priv, state);
2764 wait_event(id_priv->wait_remove, !atomic_read(&id_priv->dev_remove)); 2761 mutex_lock(&id_priv->handler_mutex);
2765 2762
2766 /* Check for destruction from another callback. */ 2763 /* Check for destruction from another callback. */
2767 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL)) 2764 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL))
2768 return 0; 2765 goto out;
2769 2766
2770 memset(&event, 0, sizeof event); 2767 memset(&event, 0, sizeof event);
2771 event.event = RDMA_CM_EVENT_DEVICE_REMOVAL; 2768 event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
2772 return id_priv->id.event_handler(&id_priv->id, &event); 2769 ret = id_priv->id.event_handler(&id_priv->id, &event);
2770out:
2771 mutex_unlock(&id_priv->handler_mutex);
2772 return ret;
2773} 2773}
2774 2774
2775static void cma_process_remove(struct cma_device *cma_dev) 2775static void cma_process_remove(struct cma_device *cma_dev)
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index 7ad47a4b166..05ac36e6acd 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: core_priv.h 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#ifndef _CORE_PRIV_H 33#ifndef _CORE_PRIV_H
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 5ac5ffee05c..7913b804311 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: device.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 1286dc1b98b..4507043d24c 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: fmr_pool.c 2730 2005-06-28 16:43:03Z sean.hefty $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index 8b75010016e..05ce331733b 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mad_priv.h 5596 2006-03-03 01:00:07Z sean.hefty $
35 */ 33 */
36 34
37#ifndef __IB_MAD_PRIV_H__ 35#ifndef __IB_MAD_PRIV_H__
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index a5e2a310f31..d0ef7d61c03 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mad_rmpp.c 1921 2005-03-02 22:58:44Z sean.hefty $
34 */ 32 */
35 33
36#include "mad_priv.h" 34#include "mad_priv.h"
diff --git a/drivers/infiniband/core/mad_rmpp.h b/drivers/infiniband/core/mad_rmpp.h
index f0616fd2249..3d336bff114 100644
--- a/drivers/infiniband/core/mad_rmpp.h
+++ b/drivers/infiniband/core/mad_rmpp.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mad_rmpp.h 1921 2005-02-25 22:58:44Z sean.hefty $
33 */ 31 */
34 32
35#ifndef __MAD_RMPP_H__ 33#ifndef __MAD_RMPP_H__
diff --git a/drivers/infiniband/core/packer.c b/drivers/infiniband/core/packer.c
index c972d723576..019bd4b0863 100644
--- a/drivers/infiniband/core/packer.c
+++ b/drivers/infiniband/core/packer.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: packer.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/string.h> 34#include <linux/string.h>
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index cf474ec2707..1341de793e5 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: sa_query.c 2811 2005-07-06 18:11:43Z halr $
35 */ 33 */
36 34
37#include <linux/module.h> 35#include <linux/module.h>
@@ -361,7 +359,7 @@ static void update_sm_ah(struct work_struct *work)
361{ 359{
362 struct ib_sa_port *port = 360 struct ib_sa_port *port =
363 container_of(work, struct ib_sa_port, update_task); 361 container_of(work, struct ib_sa_port, update_task);
364 struct ib_sa_sm_ah *new_ah, *old_ah; 362 struct ib_sa_sm_ah *new_ah;
365 struct ib_port_attr port_attr; 363 struct ib_port_attr port_attr;
366 struct ib_ah_attr ah_attr; 364 struct ib_ah_attr ah_attr;
367 365
@@ -397,12 +395,9 @@ static void update_sm_ah(struct work_struct *work)
397 } 395 }
398 396
399 spin_lock_irq(&port->ah_lock); 397 spin_lock_irq(&port->ah_lock);
400 old_ah = port->sm_ah;
401 port->sm_ah = new_ah; 398 port->sm_ah = new_ah;
402 spin_unlock_irq(&port->ah_lock); 399 spin_unlock_irq(&port->ah_lock);
403 400
404 if (old_ah)
405 kref_put(&old_ah->ref, free_sm_ah);
406} 401}
407 402
408static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event) 403static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event)
@@ -413,8 +408,17 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
413 event->event == IB_EVENT_PKEY_CHANGE || 408 event->event == IB_EVENT_PKEY_CHANGE ||
414 event->event == IB_EVENT_SM_CHANGE || 409 event->event == IB_EVENT_SM_CHANGE ||
415 event->event == IB_EVENT_CLIENT_REREGISTER) { 410 event->event == IB_EVENT_CLIENT_REREGISTER) {
416 struct ib_sa_device *sa_dev; 411 unsigned long flags;
417 sa_dev = container_of(handler, typeof(*sa_dev), event_handler); 412 struct ib_sa_device *sa_dev =
413 container_of(handler, typeof(*sa_dev), event_handler);
414 struct ib_sa_port *port =
415 &sa_dev->port[event->element.port_num - sa_dev->start_port];
416
417 spin_lock_irqsave(&port->ah_lock, flags);
418 if (port->sm_ah)
419 kref_put(&port->sm_ah->ref, free_sm_ah);
420 port->sm_ah = NULL;
421 spin_unlock_irqrestore(&port->ah_lock, flags);
418 422
419 schedule_work(&sa_dev->port[event->element.port_num - 423 schedule_work(&sa_dev->port[event->element.port_num -
420 sa_dev->start_port].update_task); 424 sa_dev->start_port].update_task);
@@ -519,6 +523,10 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
519 unsigned long flags; 523 unsigned long flags;
520 524
521 spin_lock_irqsave(&query->port->ah_lock, flags); 525 spin_lock_irqsave(&query->port->ah_lock, flags);
526 if (!query->port->sm_ah) {
527 spin_unlock_irqrestore(&query->port->ah_lock, flags);
528 return -EAGAIN;
529 }
522 kref_get(&query->port->sm_ah->ref); 530 kref_get(&query->port->sm_ah->ref);
523 query->sm_ah = query->port->sm_ah; 531 query->sm_ah = query->port->sm_ah;
524 spin_unlock_irqrestore(&query->port->ah_lock, flags); 532 spin_unlock_irqrestore(&query->port->ah_lock, flags);
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 95756551cf7..4d104211559 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: sysfs.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include "core_priv.h" 35#include "core_priv.h"
@@ -665,6 +663,120 @@ static struct class ib_class = {
665 .dev_uevent = ib_device_uevent, 663 .dev_uevent = ib_device_uevent,
666}; 664};
667 665
666/* Show a given an attribute in the statistics group */
667static ssize_t show_protocol_stat(const struct device *device,
668 struct device_attribute *attr, char *buf,
669 unsigned offset)
670{
671 struct ib_device *dev = container_of(device, struct ib_device, dev);
672 union rdma_protocol_stats stats;
673 ssize_t ret;
674
675 ret = dev->get_protocol_stats(dev, &stats);
676 if (ret)
677 return ret;
678
679 return sprintf(buf, "%llu\n",
680 (unsigned long long) ((u64 *) &stats)[offset]);
681}
682
683/* generate a read-only iwarp statistics attribute */
684#define IW_STATS_ENTRY(name) \
685static ssize_t show_##name(struct device *device, \
686 struct device_attribute *attr, char *buf) \
687{ \
688 return show_protocol_stat(device, attr, buf, \
689 offsetof(struct iw_protocol_stats, name) / \
690 sizeof (u64)); \
691} \
692static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
693
694IW_STATS_ENTRY(ipInReceives);
695IW_STATS_ENTRY(ipInHdrErrors);
696IW_STATS_ENTRY(ipInTooBigErrors);
697IW_STATS_ENTRY(ipInNoRoutes);
698IW_STATS_ENTRY(ipInAddrErrors);
699IW_STATS_ENTRY(ipInUnknownProtos);
700IW_STATS_ENTRY(ipInTruncatedPkts);
701IW_STATS_ENTRY(ipInDiscards);
702IW_STATS_ENTRY(ipInDelivers);
703IW_STATS_ENTRY(ipOutForwDatagrams);
704IW_STATS_ENTRY(ipOutRequests);
705IW_STATS_ENTRY(ipOutDiscards);
706IW_STATS_ENTRY(ipOutNoRoutes);
707IW_STATS_ENTRY(ipReasmTimeout);
708IW_STATS_ENTRY(ipReasmReqds);
709IW_STATS_ENTRY(ipReasmOKs);
710IW_STATS_ENTRY(ipReasmFails);
711IW_STATS_ENTRY(ipFragOKs);
712IW_STATS_ENTRY(ipFragFails);
713IW_STATS_ENTRY(ipFragCreates);
714IW_STATS_ENTRY(ipInMcastPkts);
715IW_STATS_ENTRY(ipOutMcastPkts);
716IW_STATS_ENTRY(ipInBcastPkts);
717IW_STATS_ENTRY(ipOutBcastPkts);
718IW_STATS_ENTRY(tcpRtoAlgorithm);
719IW_STATS_ENTRY(tcpRtoMin);
720IW_STATS_ENTRY(tcpRtoMax);
721IW_STATS_ENTRY(tcpMaxConn);
722IW_STATS_ENTRY(tcpActiveOpens);
723IW_STATS_ENTRY(tcpPassiveOpens);
724IW_STATS_ENTRY(tcpAttemptFails);
725IW_STATS_ENTRY(tcpEstabResets);
726IW_STATS_ENTRY(tcpCurrEstab);
727IW_STATS_ENTRY(tcpInSegs);
728IW_STATS_ENTRY(tcpOutSegs);
729IW_STATS_ENTRY(tcpRetransSegs);
730IW_STATS_ENTRY(tcpInErrs);
731IW_STATS_ENTRY(tcpOutRsts);
732
733static struct attribute *iw_proto_stats_attrs[] = {
734 &dev_attr_ipInReceives.attr,
735 &dev_attr_ipInHdrErrors.attr,
736 &dev_attr_ipInTooBigErrors.attr,
737 &dev_attr_ipInNoRoutes.attr,
738 &dev_attr_ipInAddrErrors.attr,
739 &dev_attr_ipInUnknownProtos.attr,
740 &dev_attr_ipInTruncatedPkts.attr,
741 &dev_attr_ipInDiscards.attr,
742 &dev_attr_ipInDelivers.attr,
743 &dev_attr_ipOutForwDatagrams.attr,
744 &dev_attr_ipOutRequests.attr,
745 &dev_attr_ipOutDiscards.attr,
746 &dev_attr_ipOutNoRoutes.attr,
747 &dev_attr_ipReasmTimeout.attr,
748 &dev_attr_ipReasmReqds.attr,
749 &dev_attr_ipReasmOKs.attr,
750 &dev_attr_ipReasmFails.attr,
751 &dev_attr_ipFragOKs.attr,
752 &dev_attr_ipFragFails.attr,
753 &dev_attr_ipFragCreates.attr,
754 &dev_attr_ipInMcastPkts.attr,
755 &dev_attr_ipOutMcastPkts.attr,
756 &dev_attr_ipInBcastPkts.attr,
757 &dev_attr_ipOutBcastPkts.attr,
758 &dev_attr_tcpRtoAlgorithm.attr,
759 &dev_attr_tcpRtoMin.attr,
760 &dev_attr_tcpRtoMax.attr,
761 &dev_attr_tcpMaxConn.attr,
762 &dev_attr_tcpActiveOpens.attr,
763 &dev_attr_tcpPassiveOpens.attr,
764 &dev_attr_tcpAttemptFails.attr,
765 &dev_attr_tcpEstabResets.attr,
766 &dev_attr_tcpCurrEstab.attr,
767 &dev_attr_tcpInSegs.attr,
768 &dev_attr_tcpOutSegs.attr,
769 &dev_attr_tcpRetransSegs.attr,
770 &dev_attr_tcpInErrs.attr,
771 &dev_attr_tcpOutRsts.attr,
772 NULL
773};
774
775static struct attribute_group iw_stats_group = {
776 .name = "proto_stats",
777 .attrs = iw_proto_stats_attrs,
778};
779
668int ib_device_register_sysfs(struct ib_device *device) 780int ib_device_register_sysfs(struct ib_device *device)
669{ 781{
670 struct device *class_dev = &device->dev; 782 struct device *class_dev = &device->dev;
@@ -707,6 +819,12 @@ int ib_device_register_sysfs(struct ib_device *device)
707 } 819 }
708 } 820 }
709 821
822 if (device->node_type == RDMA_NODE_RNIC && device->get_protocol_stats) {
823 ret = sysfs_create_group(&class_dev->kobj, &iw_stats_group);
824 if (ret)
825 goto err_put;
826 }
827
710 return 0; 828 return 0;
711 829
712err_put: 830err_put:
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index b25675faaaf..9494005d1c9 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ucm.c 4311 2005-12-05 18:42:01Z sean.hefty $
34 */ 32 */
35 33
36#include <linux/completion.h> 34#include <linux/completion.h>
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c
index 997c07db6d8..8ec7876bedc 100644
--- a/drivers/infiniband/core/ud_header.c
+++ b/drivers/infiniband/core/ud_header.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ud_header.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index a1768dbb072..6f7c096abf1 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: uverbs_mem.c 2743 2005-06-28 22:27:59Z roland $
35 */ 33 */
36 34
37#include <linux/mm.h> 35#include <linux/mm.h>
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 208c7f34323..268a2d23b7c 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: user_mad.c 5596 2006-03-03 01:00:07Z sean.hefty $
36 */ 34 */
37 35
38#include <linux/module.h> 36#include <linux/module.h>
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 376a57ce1b4..b3ea9587dc8 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: uverbs.h 2559 2005-06-06 19:43:16Z roland $
37 */ 35 */
38 36
39#ifndef UVERBS_H 37#ifndef UVERBS_H
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 2c3bff5fe86..56feab6c251 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: uverbs_cmd.c 2708 2005-06-24 17:27:21Z roland $
36 */ 34 */
37 35
38#include <linux/file.h> 36#include <linux/file.h>
@@ -919,7 +917,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
919 resp->wc[i].opcode = wc[i].opcode; 917 resp->wc[i].opcode = wc[i].opcode;
920 resp->wc[i].vendor_err = wc[i].vendor_err; 918 resp->wc[i].vendor_err = wc[i].vendor_err;
921 resp->wc[i].byte_len = wc[i].byte_len; 919 resp->wc[i].byte_len = wc[i].byte_len;
922 resp->wc[i].imm_data = (__u32 __force) wc[i].imm_data; 920 resp->wc[i].ex.imm_data = (__u32 __force) wc[i].ex.imm_data;
923 resp->wc[i].qp_num = wc[i].qp->qp_num; 921 resp->wc[i].qp_num = wc[i].qp->qp_num;
924 resp->wc[i].src_qp = wc[i].src_qp; 922 resp->wc[i].src_qp = wc[i].src_qp;
925 resp->wc[i].wc_flags = wc[i].wc_flags; 923 resp->wc[i].wc_flags = wc[i].wc_flags;
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 0f34858e31e..aeee856c406 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: uverbs_main.c 2733 2005-06-28 19:14:34Z roland $
37 */ 35 */
38 36
39#include <linux/module.h> 37#include <linux/module.h>
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 05042089de6..a7da9be43e6 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -34,8 +34,6 @@
34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 * SOFTWARE. 36 * SOFTWARE.
37 *
38 * $Id: verbs.c 1349 2004-12-16 21:09:43Z roland $
39 */ 37 */
40 38
41#include <linux/errno.h> 39#include <linux/errno.h>
@@ -317,7 +315,6 @@ static const struct {
317} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { 315} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
318 [IB_QPS_RESET] = { 316 [IB_QPS_RESET] = {
319 [IB_QPS_RESET] = { .valid = 1 }, 317 [IB_QPS_RESET] = { .valid = 1 },
320 [IB_QPS_ERR] = { .valid = 1 },
321 [IB_QPS_INIT] = { 318 [IB_QPS_INIT] = {
322 .valid = 1, 319 .valid = 1,
323 .req_param = { 320 .req_param = {
@@ -755,6 +752,52 @@ int ib_dereg_mr(struct ib_mr *mr)
755} 752}
756EXPORT_SYMBOL(ib_dereg_mr); 753EXPORT_SYMBOL(ib_dereg_mr);
757 754
755struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
756{
757 struct ib_mr *mr;
758
759 if (!pd->device->alloc_fast_reg_mr)
760 return ERR_PTR(-ENOSYS);
761
762 mr = pd->device->alloc_fast_reg_mr(pd, max_page_list_len);
763
764 if (!IS_ERR(mr)) {
765 mr->device = pd->device;
766 mr->pd = pd;
767 mr->uobject = NULL;
768 atomic_inc(&pd->usecnt);
769 atomic_set(&mr->usecnt, 0);
770 }
771
772 return mr;
773}
774EXPORT_SYMBOL(ib_alloc_fast_reg_mr);
775
776struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(struct ib_device *device,
777 int max_page_list_len)
778{
779 struct ib_fast_reg_page_list *page_list;
780
781 if (!device->alloc_fast_reg_page_list)
782 return ERR_PTR(-ENOSYS);
783
784 page_list = device->alloc_fast_reg_page_list(device, max_page_list_len);
785
786 if (!IS_ERR(page_list)) {
787 page_list->device = device;
788 page_list->max_page_list_len = max_page_list_len;
789 }
790
791 return page_list;
792}
793EXPORT_SYMBOL(ib_alloc_fast_reg_page_list);
794
795void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
796{
797 page_list->device->free_fast_reg_page_list(page_list);
798}
799EXPORT_SYMBOL(ib_free_fast_reg_page_list);
800
758/* Memory windows */ 801/* Memory windows */
759 802
760struct ib_mw *ib_alloc_mw(struct ib_pd *pd) 803struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index b1441aeb60c..dd05c483564 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -454,7 +454,7 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev)
454 (IB_DEVICE_RESIZE_MAX_WR | 454 (IB_DEVICE_RESIZE_MAX_WR |
455 IB_DEVICE_CURR_QP_STATE_MOD | 455 IB_DEVICE_CURR_QP_STATE_MOD |
456 IB_DEVICE_SYS_IMAGE_GUID | 456 IB_DEVICE_SYS_IMAGE_GUID |
457 IB_DEVICE_ZERO_STAG | 457 IB_DEVICE_LOCAL_DMA_LKEY |
458 IB_DEVICE_MEM_WINDOW); 458 IB_DEVICE_MEM_WINDOW);
459 459
460 /* Allocate the qptr_array */ 460 /* Allocate the qptr_array */
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index 3f441fc57c1..f6d5747153a 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -145,7 +145,9 @@ static int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev_p, u32 qpid)
145 } 145 }
146 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 146 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
147 memset(wqe, 0, sizeof(*wqe)); 147 memset(wqe, 0, sizeof(*wqe));
148 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 0, qpid, 7); 148 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD,
149 T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 0, qpid, 7,
150 T3_SOPEOP);
149 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 151 wqe->flags = cpu_to_be32(MODQP_WRITE_EC);
150 sge_cmd = qpid << 8 | 3; 152 sge_cmd = qpid << 8 | 3;
151 wqe->sge_cmd = cpu_to_be64(sge_cmd); 153 wqe->sge_cmd = cpu_to_be64(sge_cmd);
@@ -276,7 +278,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
276 if (!wq->qpid) 278 if (!wq->qpid)
277 return -ENOMEM; 279 return -ENOMEM;
278 280
279 wq->rq = kzalloc(depth * sizeof(u64), GFP_KERNEL); 281 wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL);
280 if (!wq->rq) 282 if (!wq->rq)
281 goto err1; 283 goto err1;
282 284
@@ -300,6 +302,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
300 if (!kernel_domain) 302 if (!kernel_domain)
301 wq->udb = (u64)rdev_p->rnic_info.udbell_physbase + 303 wq->udb = (u64)rdev_p->rnic_info.udbell_physbase +
302 (wq->qpid << rdev_p->qpshift); 304 (wq->qpid << rdev_p->qpshift);
305 wq->rdev = rdev_p;
303 PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__, 306 PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__,
304 wq->qpid, wq->doorbell, (unsigned long long) wq->udb); 307 wq->qpid, wq->doorbell, (unsigned long long) wq->udb);
305 return 0; 308 return 0;
@@ -558,7 +561,7 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
558 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 561 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
559 memset(wqe, 0, sizeof(*wqe)); 562 memset(wqe, 0, sizeof(*wqe));
560 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, 563 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0,
561 T3_CTL_QP_TID, 7); 564 T3_CTL_QP_TID, 7, T3_SOPEOP);
562 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 565 wqe->flags = cpu_to_be32(MODQP_WRITE_EC);
563 sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; 566 sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3;
564 wqe->sge_cmd = cpu_to_be64(sge_cmd); 567 wqe->sge_cmd = cpu_to_be64(sge_cmd);
@@ -674,7 +677,7 @@ static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr,
674 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, 677 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag,
675 Q_GENBIT(rdev_p->ctrl_qp.wptr, 678 Q_GENBIT(rdev_p->ctrl_qp.wptr,
676 T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, 679 T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID,
677 wr_len); 680 wr_len, T3_SOPEOP);
678 if (flag == T3_COMPLETION_FLAG) 681 if (flag == T3_COMPLETION_FLAG)
679 ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); 682 ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID);
680 len -= 96; 683 len -= 96;
@@ -816,6 +819,13 @@ int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag)
816 0, 0); 819 0, 0);
817} 820}
818 821
822int cxio_allocate_stag(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr)
823{
824 *stag = T3_STAG_UNSET;
825 return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_NON_SHARED_MR,
826 0, 0, 0ULL, 0, 0, pbl_size, pbl_addr);
827}
828
819int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) 829int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr)
820{ 830{
821 struct t3_rdma_init_wr *wqe; 831 struct t3_rdma_init_wr *wqe;
@@ -1257,13 +1267,16 @@ proc_cqe:
1257 wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); 1267 wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe);
1258 PDBG("%s completing sq idx %ld\n", __func__, 1268 PDBG("%s completing sq idx %ld\n", __func__,
1259 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)); 1269 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2));
1260 *cookie = (wq->sq + 1270 *cookie = wq->sq[Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)].wr_id;
1261 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2))->wr_id;
1262 wq->sq_rptr++; 1271 wq->sq_rptr++;
1263 } else { 1272 } else {
1264 PDBG("%s completing rq idx %ld\n", __func__, 1273 PDBG("%s completing rq idx %ld\n", __func__,
1265 Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); 1274 Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2));
1266 *cookie = *(wq->rq + Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); 1275 *cookie = wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].wr_id;
1276 if (wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].pbl_addr)
1277 cxio_hal_pblpool_free(wq->rdev,
1278 wq->rq[Q_PTR2IDX(wq->rq_rptr,
1279 wq->rq_size_log2)].pbl_addr, T3_STAG0_PBL_SIZE);
1267 wq->rq_rptr++; 1280 wq->rq_rptr++;
1268 } 1281 }
1269 1282
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h
index 6e128f6bab0..656fe47bc84 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h
@@ -45,15 +45,17 @@
45#define T3_CTRL_QP_SIZE_LOG2 8 45#define T3_CTRL_QP_SIZE_LOG2 8
46#define T3_CTRL_CQ_ID 0 46#define T3_CTRL_CQ_ID 0
47 47
48/* TBD */
49#define T3_MAX_NUM_RI (1<<15) 48#define T3_MAX_NUM_RI (1<<15)
50#define T3_MAX_NUM_QP (1<<15) 49#define T3_MAX_NUM_QP (1<<15)
51#define T3_MAX_NUM_CQ (1<<15) 50#define T3_MAX_NUM_CQ (1<<15)
52#define T3_MAX_NUM_PD (1<<15) 51#define T3_MAX_NUM_PD (1<<15)
53#define T3_MAX_PBL_SIZE 256 52#define T3_MAX_PBL_SIZE 256
54#define T3_MAX_RQ_SIZE 1024 53#define T3_MAX_RQ_SIZE 1024
54#define T3_MAX_QP_DEPTH (T3_MAX_RQ_SIZE-1)
55#define T3_MAX_CQ_DEPTH 8192
55#define T3_MAX_NUM_STAG (1<<15) 56#define T3_MAX_NUM_STAG (1<<15)
56#define T3_MAX_MR_SIZE 0x100000000ULL 57#define T3_MAX_MR_SIZE 0x100000000ULL
58#define T3_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */
57 59
58#define T3_STAG_UNSET 0xffffffff 60#define T3_STAG_UNSET 0xffffffff
59 61
@@ -165,6 +167,7 @@ int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,
165int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, 167int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size,
166 u32 pbl_addr); 168 u32 pbl_addr);
167int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); 169int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid);
170int cxio_allocate_stag(struct cxio_rdev *rdev, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr);
168int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag); 171int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag);
169int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr); 172int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr);
170void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb); 173void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb);
diff --git a/drivers/infiniband/hw/cxgb3/cxio_wr.h b/drivers/infiniband/hw/cxgb3/cxio_wr.h
index f1a25a821a4..04618f7bfbb 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_wr.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_wr.h
@@ -39,6 +39,9 @@
39 39
40#define T3_MAX_SGE 4 40#define T3_MAX_SGE 4
41#define T3_MAX_INLINE 64 41#define T3_MAX_INLINE 64
42#define T3_STAG0_PBL_SIZE (2 * T3_MAX_SGE << 3)
43#define T3_STAG0_MAX_PBE_LEN (128 * 1024 * 1024)
44#define T3_STAG0_PAGE_SHIFT 15
42 45
43#define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) 46#define Q_EMPTY(rptr,wptr) ((rptr)==(wptr))
44#define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ 47#define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \
@@ -72,7 +75,8 @@ enum t3_wr_opcode {
72 T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, 75 T3_WR_BIND = FW_WROPCODE_RI_BIND_MW,
73 T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, 76 T3_WR_RCV = FW_WROPCODE_RI_RECEIVE,
74 T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, 77 T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT,
75 T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP 78 T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP,
79 T3_WR_FASTREG = FW_WROPCODE_RI_FASTREGISTER_MR
76} __attribute__ ((packed)); 80} __attribute__ ((packed));
77 81
78enum t3_rdma_opcode { 82enum t3_rdma_opcode {
@@ -89,7 +93,8 @@ enum t3_rdma_opcode {
89 T3_FAST_REGISTER, 93 T3_FAST_REGISTER,
90 T3_LOCAL_INV, 94 T3_LOCAL_INV,
91 T3_QP_MOD, 95 T3_QP_MOD,
92 T3_BYPASS 96 T3_BYPASS,
97 T3_RDMA_READ_REQ_WITH_INV,
93} __attribute__ ((packed)); 98} __attribute__ ((packed));
94 99
95static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) 100static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop)
@@ -103,6 +108,7 @@ static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop)
103 case T3_WR_BIND: return T3_BIND_MW; 108 case T3_WR_BIND: return T3_BIND_MW;
104 case T3_WR_INIT: return T3_RDMA_INIT; 109 case T3_WR_INIT: return T3_RDMA_INIT;
105 case T3_WR_QP_MOD: return T3_QP_MOD; 110 case T3_WR_QP_MOD: return T3_QP_MOD;
111 case T3_WR_FASTREG: return T3_FAST_REGISTER;
106 default: break; 112 default: break;
107 } 113 }
108 return -1; 114 return -1;
@@ -170,11 +176,54 @@ struct t3_send_wr {
170 struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ 176 struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */
171}; 177};
172 178
179#define T3_MAX_FASTREG_DEPTH 24
180#define T3_MAX_FASTREG_FRAG 10
181
182struct t3_fastreg_wr {
183 struct fw_riwrh wrh; /* 0 */
184 union t3_wrid wrid; /* 1 */
185 __be32 stag; /* 2 */
186 __be32 len;
187 __be32 va_base_hi; /* 3 */
188 __be32 va_base_lo_fbo;
189 __be32 page_type_perms; /* 4 */
190 __be32 reserved1;
191 __be64 pbl_addrs[0]; /* 5+ */
192};
193
194/*
195 * If a fastreg wr spans multiple wqes, then the 2nd fragment look like this.
196 */
197struct t3_pbl_frag {
198 struct fw_riwrh wrh; /* 0 */
199 __be64 pbl_addrs[14]; /* 1..14 */
200};
201
202#define S_FR_PAGE_COUNT 24
203#define M_FR_PAGE_COUNT 0xff
204#define V_FR_PAGE_COUNT(x) ((x) << S_FR_PAGE_COUNT)
205#define G_FR_PAGE_COUNT(x) ((((x) >> S_FR_PAGE_COUNT)) & M_FR_PAGE_COUNT)
206
207#define S_FR_PAGE_SIZE 16
208#define M_FR_PAGE_SIZE 0x1f
209#define V_FR_PAGE_SIZE(x) ((x) << S_FR_PAGE_SIZE)
210#define G_FR_PAGE_SIZE(x) ((((x) >> S_FR_PAGE_SIZE)) & M_FR_PAGE_SIZE)
211
212#define S_FR_TYPE 8
213#define M_FR_TYPE 0x1
214#define V_FR_TYPE(x) ((x) << S_FR_TYPE)
215#define G_FR_TYPE(x) ((((x) >> S_FR_TYPE)) & M_FR_TYPE)
216
217#define S_FR_PERMS 0
218#define M_FR_PERMS 0xff
219#define V_FR_PERMS(x) ((x) << S_FR_PERMS)
220#define G_FR_PERMS(x) ((((x) >> S_FR_PERMS)) & M_FR_PERMS)
221
173struct t3_local_inv_wr { 222struct t3_local_inv_wr {
174 struct fw_riwrh wrh; /* 0 */ 223 struct fw_riwrh wrh; /* 0 */
175 union t3_wrid wrid; /* 1 */ 224 union t3_wrid wrid; /* 1 */
176 __be32 stag; /* 2 */ 225 __be32 stag; /* 2 */
177 __be32 reserved3; 226 __be32 reserved;
178}; 227};
179 228
180struct t3_rdma_write_wr { 229struct t3_rdma_write_wr {
@@ -193,7 +242,8 @@ struct t3_rdma_read_wr {
193 struct fw_riwrh wrh; /* 0 */ 242 struct fw_riwrh wrh; /* 0 */
194 union t3_wrid wrid; /* 1 */ 243 union t3_wrid wrid; /* 1 */
195 u8 rdmaop; /* 2 */ 244 u8 rdmaop; /* 2 */
196 u8 reserved[3]; 245 u8 local_inv;
246 u8 reserved[2];
197 __be32 rem_stag; 247 __be32 rem_stag;
198 __be64 rem_to; /* 3 */ 248 __be64 rem_to; /* 3 */
199 __be32 local_stag; /* 4 */ 249 __be32 local_stag; /* 4 */
@@ -201,18 +251,6 @@ struct t3_rdma_read_wr {
201 __be64 local_to; /* 5 */ 251 __be64 local_to; /* 5 */
202}; 252};
203 253
204enum t3_addr_type {
205 T3_VA_BASED_TO = 0x0,
206 T3_ZERO_BASED_TO = 0x1
207} __attribute__ ((packed));
208
209enum t3_mem_perms {
210 T3_MEM_ACCESS_LOCAL_READ = 0x1,
211 T3_MEM_ACCESS_LOCAL_WRITE = 0x2,
212 T3_MEM_ACCESS_REM_READ = 0x4,
213 T3_MEM_ACCESS_REM_WRITE = 0x8
214} __attribute__ ((packed));
215
216struct t3_bind_mw_wr { 254struct t3_bind_mw_wr {
217 struct fw_riwrh wrh; /* 0 */ 255 struct fw_riwrh wrh; /* 0 */
218 union t3_wrid wrid; /* 1 */ 256 union t3_wrid wrid; /* 1 */
@@ -336,6 +374,11 @@ struct t3_genbit {
336 __be64 genbit; 374 __be64 genbit;
337}; 375};
338 376
377struct t3_wq_in_err {
378 u64 flit[13];
379 u64 err;
380};
381
339enum rdma_init_wr_flags { 382enum rdma_init_wr_flags {
340 MPA_INITIATOR = (1<<0), 383 MPA_INITIATOR = (1<<0),
341 PRIV_QP = (1<<1), 384 PRIV_QP = (1<<1),
@@ -346,13 +389,16 @@ union t3_wr {
346 struct t3_rdma_write_wr write; 389 struct t3_rdma_write_wr write;
347 struct t3_rdma_read_wr read; 390 struct t3_rdma_read_wr read;
348 struct t3_receive_wr recv; 391 struct t3_receive_wr recv;
392 struct t3_fastreg_wr fastreg;
393 struct t3_pbl_frag pbl_frag;
349 struct t3_local_inv_wr local_inv; 394 struct t3_local_inv_wr local_inv;
350 struct t3_bind_mw_wr bind; 395 struct t3_bind_mw_wr bind;
351 struct t3_bypass_wr bypass; 396 struct t3_bypass_wr bypass;
352 struct t3_rdma_init_wr init; 397 struct t3_rdma_init_wr init;
353 struct t3_modify_qp_wr qp_mod; 398 struct t3_modify_qp_wr qp_mod;
354 struct t3_genbit genbit; 399 struct t3_genbit genbit;
355 u64 flit[16]; 400 struct t3_wq_in_err wq_in_err;
401 __be64 flit[16];
356}; 402};
357 403
358#define T3_SQ_CQE_FLIT 13 404#define T3_SQ_CQE_FLIT 13
@@ -366,12 +412,18 @@ static inline enum t3_wr_opcode fw_riwrh_opcode(struct fw_riwrh *wqe)
366 return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); 412 return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags));
367} 413}
368 414
415enum t3_wr_hdr_bits {
416 T3_EOP = 1,
417 T3_SOP = 2,
418 T3_SOPEOP = T3_EOP|T3_SOP,
419};
420
369static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, 421static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op,
370 enum t3_wr_flags flags, u8 genbit, u32 tid, 422 enum t3_wr_flags flags, u8 genbit, u32 tid,
371 u8 len) 423 u8 len, u8 sopeop)
372{ 424{
373 wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | 425 wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) |
374 V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | 426 V_FW_RIWR_SOPEOP(sopeop) |
375 V_FW_RIWR_FLAGS(flags)); 427 V_FW_RIWR_FLAGS(flags));
376 wmb(); 428 wmb();
377 wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | 429 wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) |
@@ -404,6 +456,7 @@ enum tpt_addr_type {
404}; 456};
405 457
406enum tpt_mem_perm { 458enum tpt_mem_perm {
459 TPT_MW_BIND = 0x10,
407 TPT_LOCAL_READ = 0x8, 460 TPT_LOCAL_READ = 0x8,
408 TPT_LOCAL_WRITE = 0x4, 461 TPT_LOCAL_WRITE = 0x4,
409 TPT_REMOTE_READ = 0x2, 462 TPT_REMOTE_READ = 0x2,
@@ -615,6 +668,11 @@ struct t3_swsq {
615 int signaled; 668 int signaled;
616}; 669};
617 670
671struct t3_swrq {
672 __u64 wr_id;
673 __u32 pbl_addr;
674};
675
618/* 676/*
619 * A T3 WQ implements both the SQ and RQ. 677 * A T3 WQ implements both the SQ and RQ.
620 */ 678 */
@@ -631,14 +689,15 @@ struct t3_wq {
631 u32 sq_wptr; /* sq_wptr - sq_rptr == count of */ 689 u32 sq_wptr; /* sq_wptr - sq_rptr == count of */
632 u32 sq_rptr; /* pending wrs */ 690 u32 sq_rptr; /* pending wrs */
633 u32 sq_size_log2; /* sq size */ 691 u32 sq_size_log2; /* sq size */
634 u64 *rq; /* SW RQ (holds consumer wr_ids */ 692 struct t3_swrq *rq; /* SW RQ (holds consumer wr_ids */
635 u32 rq_wptr; /* rq_wptr - rq_rptr == count of */ 693 u32 rq_wptr; /* rq_wptr - rq_rptr == count of */
636 u32 rq_rptr; /* pending wrs */ 694 u32 rq_rptr; /* pending wrs */
637 u64 *rq_oldest_wr; /* oldest wr on the SW RQ */ 695 struct t3_swrq *rq_oldest_wr; /* oldest wr on the SW RQ */
638 u32 rq_size_log2; /* rq size */ 696 u32 rq_size_log2; /* rq size */
639 u32 rq_addr; /* rq adapter address */ 697 u32 rq_addr; /* rq adapter address */
640 void __iomem *doorbell; /* kernel db */ 698 void __iomem *doorbell; /* kernel db */
641 u64 udb; /* user db if any */ 699 u64 udb; /* user db if any */
700 struct cxio_rdev *rdev;
642}; 701};
643 702
644struct t3_cq { 703struct t3_cq {
@@ -659,7 +718,7 @@ struct t3_cq {
659 718
660static inline void cxio_set_wq_in_error(struct t3_wq *wq) 719static inline void cxio_set_wq_in_error(struct t3_wq *wq)
661{ 720{
662 wq->queue->flit[13] = 1; 721 wq->queue->wq_in_err.err = 1;
663} 722}
664 723
665static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) 724static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq)
diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c
index 71554eacb13..4489c89d671 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.c
+++ b/drivers/infiniband/hw/cxgb3/iwch.c
@@ -71,18 +71,16 @@ static void rnic_init(struct iwch_dev *rnicp)
71 idr_init(&rnicp->mmidr); 71 idr_init(&rnicp->mmidr);
72 spin_lock_init(&rnicp->lock); 72 spin_lock_init(&rnicp->lock);
73 73
74 rnicp->attr.vendor_id = 0x168;
75 rnicp->attr.vendor_part_id = 7;
76 rnicp->attr.max_qps = T3_MAX_NUM_QP - 32; 74 rnicp->attr.max_qps = T3_MAX_NUM_QP - 32;
77 rnicp->attr.max_wrs = (1UL << 24) - 1; 75 rnicp->attr.max_wrs = T3_MAX_QP_DEPTH;
78 rnicp->attr.max_sge_per_wr = T3_MAX_SGE; 76 rnicp->attr.max_sge_per_wr = T3_MAX_SGE;
79 rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE; 77 rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE;
80 rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1; 78 rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1;
81 rnicp->attr.max_cqes_per_cq = (1UL << 24) - 1; 79 rnicp->attr.max_cqes_per_cq = T3_MAX_CQ_DEPTH;
82 rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev); 80 rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev);
83 rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; 81 rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE;
84 rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; 82 rnicp->attr.max_pds = T3_MAX_NUM_PD - 1;
85 rnicp->attr.mem_pgsizes_bitmask = 0x7FFF; /* 4KB-128MB */ 83 rnicp->attr.mem_pgsizes_bitmask = T3_PAGESIZE_MASK;
86 rnicp->attr.max_mr_size = T3_MAX_MR_SIZE; 84 rnicp->attr.max_mr_size = T3_MAX_MR_SIZE;
87 rnicp->attr.can_resize_wq = 0; 85 rnicp->attr.can_resize_wq = 0;
88 rnicp->attr.max_rdma_reads_per_qp = 8; 86 rnicp->attr.max_rdma_reads_per_qp = 8;
diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h
index d2409a505e8..3773453b2cf 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.h
+++ b/drivers/infiniband/hw/cxgb3/iwch.h
@@ -48,8 +48,6 @@ struct iwch_qp;
48struct iwch_mr; 48struct iwch_mr;
49 49
50struct iwch_rnic_attributes { 50struct iwch_rnic_attributes {
51 u32 vendor_id;
52 u32 vendor_part_id;
53 u32 max_qps; 51 u32 max_qps;
54 u32 max_wrs; /* Max for any SQ/RQ */ 52 u32 max_wrs; /* Max for any SQ/RQ */
55 u32 max_sge_per_wr; 53 u32 max_sge_per_wr;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cq.c b/drivers/infiniband/hw/cxgb3/iwch_cq.c
index 4ee8ccd0a9e..cf5474ae68f 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cq.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cq.c
@@ -81,6 +81,7 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
81 wc->wr_id = cookie; 81 wc->wr_id = cookie;
82 wc->qp = &qhp->ibqp; 82 wc->qp = &qhp->ibqp;
83 wc->vendor_err = CQE_STATUS(cqe); 83 wc->vendor_err = CQE_STATUS(cqe);
84 wc->wc_flags = 0;
84 85
85 PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " 86 PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x "
86 "lo 0x%x cookie 0x%llx\n", __func__, 87 "lo 0x%x cookie 0x%llx\n", __func__,
@@ -94,6 +95,11 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
94 else 95 else
95 wc->byte_len = 0; 96 wc->byte_len = 0;
96 wc->opcode = IB_WC_RECV; 97 wc->opcode = IB_WC_RECV;
98 if (CQE_OPCODE(cqe) == T3_SEND_WITH_INV ||
99 CQE_OPCODE(cqe) == T3_SEND_WITH_SE_INV) {
100 wc->ex.invalidate_rkey = CQE_WRID_STAG(cqe);
101 wc->wc_flags |= IB_WC_WITH_INVALIDATE;
102 }
97 } else { 103 } else {
98 switch (CQE_OPCODE(cqe)) { 104 switch (CQE_OPCODE(cqe)) {
99 case T3_RDMA_WRITE: 105 case T3_RDMA_WRITE:
@@ -105,17 +111,20 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
105 break; 111 break;
106 case T3_SEND: 112 case T3_SEND:
107 case T3_SEND_WITH_SE: 113 case T3_SEND_WITH_SE:
114 case T3_SEND_WITH_INV:
115 case T3_SEND_WITH_SE_INV:
108 wc->opcode = IB_WC_SEND; 116 wc->opcode = IB_WC_SEND;
109 break; 117 break;
110 case T3_BIND_MW: 118 case T3_BIND_MW:
111 wc->opcode = IB_WC_BIND_MW; 119 wc->opcode = IB_WC_BIND_MW;
112 break; 120 break;
113 121
114 /* these aren't supported yet */
115 case T3_SEND_WITH_INV:
116 case T3_SEND_WITH_SE_INV:
117 case T3_LOCAL_INV: 122 case T3_LOCAL_INV:
123 wc->opcode = IB_WC_LOCAL_INV;
124 break;
118 case T3_FAST_REGISTER: 125 case T3_FAST_REGISTER:
126 wc->opcode = IB_WC_FAST_REG_MR;
127 break;
119 default: 128 default:
120 printk(KERN_ERR MOD "Unexpected opcode %d " 129 printk(KERN_ERR MOD "Unexpected opcode %d "
121 "in the CQE received for QPID=0x%0x\n", 130 "in the CQE received for QPID=0x%0x\n",
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index 95f82cfb6c5..b89640aa6e1 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -56,6 +56,7 @@
56#include "iwch_provider.h" 56#include "iwch_provider.h"
57#include "iwch_cm.h" 57#include "iwch_cm.h"
58#include "iwch_user.h" 58#include "iwch_user.h"
59#include "common.h"
59 60
60static int iwch_modify_port(struct ib_device *ibdev, 61static int iwch_modify_port(struct ib_device *ibdev,
61 u8 port, int port_modify_mask, 62 u8 port, int port_modify_mask,
@@ -747,6 +748,7 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd)
747 mhp->attr.type = TPT_MW; 748 mhp->attr.type = TPT_MW;
748 mhp->attr.stag = stag; 749 mhp->attr.stag = stag;
749 mmid = (stag) >> 8; 750 mmid = (stag) >> 8;
751 mhp->ibmw.rkey = stag;
750 insert_handle(rhp, &rhp->mmidr, mhp, mmid); 752 insert_handle(rhp, &rhp->mmidr, mhp, mmid);
751 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); 753 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
752 return &(mhp->ibmw); 754 return &(mhp->ibmw);
@@ -768,6 +770,68 @@ static int iwch_dealloc_mw(struct ib_mw *mw)
768 return 0; 770 return 0;
769} 771}
770 772
773static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
774{
775 struct iwch_dev *rhp;
776 struct iwch_pd *php;
777 struct iwch_mr *mhp;
778 u32 mmid;
779 u32 stag = 0;
780 int ret;
781
782 php = to_iwch_pd(pd);
783 rhp = php->rhp;
784 mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
785 if (!mhp)
786 return ERR_PTR(-ENOMEM);
787
788 mhp->rhp = rhp;
789 ret = iwch_alloc_pbl(mhp, pbl_depth);
790 if (ret) {
791 kfree(mhp);
792 return ERR_PTR(ret);
793 }
794 mhp->attr.pbl_size = pbl_depth;
795 ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid,
796 mhp->attr.pbl_size, mhp->attr.pbl_addr);
797 if (ret) {
798 iwch_free_pbl(mhp);
799 kfree(mhp);
800 return ERR_PTR(ret);
801 }
802 mhp->attr.pdid = php->pdid;
803 mhp->attr.type = TPT_NON_SHARED_MR;
804 mhp->attr.stag = stag;
805 mhp->attr.state = 1;
806 mmid = (stag) >> 8;
807 mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
808 insert_handle(rhp, &rhp->mmidr, mhp, mmid);
809 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
810 return &(mhp->ibmr);
811}
812
813static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl(
814 struct ib_device *device,
815 int page_list_len)
816{
817 struct ib_fast_reg_page_list *page_list;
818
819 page_list = kmalloc(sizeof *page_list + page_list_len * sizeof(u64),
820 GFP_KERNEL);
821 if (!page_list)
822 return ERR_PTR(-ENOMEM);
823
824 page_list->page_list = (u64 *)(page_list + 1);
825 page_list->max_page_list_len = page_list_len;
826
827 return page_list;
828}
829
830static void iwch_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list)
831{
832 kfree(page_list);
833}
834
771static int iwch_destroy_qp(struct ib_qp *ib_qp) 835static int iwch_destroy_qp(struct ib_qp *ib_qp)
772{ 836{
773 struct iwch_dev *rhp; 837 struct iwch_dev *rhp;
@@ -843,6 +907,15 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
843 */ 907 */
844 sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); 908 sqsize = roundup_pow_of_two(attrs->cap.max_send_wr);
845 wqsize = roundup_pow_of_two(rqsize + sqsize); 909 wqsize = roundup_pow_of_two(rqsize + sqsize);
910
911 /*
912 * Kernel users need more wq space for fastreg WRs which can take
913 * 2 WR fragments.
914 */
915 ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL;
916 if (!ucontext && wqsize < (rqsize + (2 * sqsize)))
917 wqsize = roundup_pow_of_two(rqsize +
918 roundup_pow_of_two(attrs->cap.max_send_wr * 2));
846 PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, 919 PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__,
847 wqsize, sqsize, rqsize); 920 wqsize, sqsize, rqsize);
848 qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); 921 qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
@@ -851,7 +924,6 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
851 qhp->wq.size_log2 = ilog2(wqsize); 924 qhp->wq.size_log2 = ilog2(wqsize);
852 qhp->wq.rq_size_log2 = ilog2(rqsize); 925 qhp->wq.rq_size_log2 = ilog2(rqsize);
853 qhp->wq.sq_size_log2 = ilog2(sqsize); 926 qhp->wq.sq_size_log2 = ilog2(sqsize);
854 ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL;
855 if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, 927 if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq,
856 ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { 928 ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) {
857 kfree(qhp); 929 kfree(qhp);
@@ -935,10 +1007,10 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
935 qhp->ibqp.qp_num = qhp->wq.qpid; 1007 qhp->ibqp.qp_num = qhp->wq.qpid;
936 init_timer(&(qhp->timer)); 1008 init_timer(&(qhp->timer));
937 PDBG("%s sq_num_entries %d, rq_num_entries %d " 1009 PDBG("%s sq_num_entries %d, rq_num_entries %d "
938 "qpid 0x%0x qhp %p dma_addr 0x%llx size %d\n", 1010 "qpid 0x%0x qhp %p dma_addr 0x%llx size %d rq_addr 0x%x\n",
939 __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, 1011 __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
940 qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr, 1012 qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr,
941 1 << qhp->wq.size_log2); 1013 1 << qhp->wq.size_log2, qhp->wq.rq_addr);
942 return &qhp->ibqp; 1014 return &qhp->ibqp;
943} 1015}
944 1016
@@ -1023,6 +1095,29 @@ static int iwch_query_gid(struct ib_device *ibdev, u8 port,
1023 return 0; 1095 return 0;
1024} 1096}
1025 1097
1098static u64 fw_vers_string_to_u64(struct iwch_dev *iwch_dev)
1099{
1100 struct ethtool_drvinfo info;
1101 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1102 char *cp, *next;
1103 unsigned fw_maj, fw_min, fw_mic;
1104
1105 rtnl_lock();
1106 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1107 rtnl_unlock();
1108
1109 next = info.fw_version + 1;
1110 cp = strsep(&next, ".");
1111 sscanf(cp, "%i", &fw_maj);
1112 cp = strsep(&next, ".");
1113 sscanf(cp, "%i", &fw_min);
1114 cp = strsep(&next, ".");
1115 sscanf(cp, "%i", &fw_mic);
1116
1117 return (((u64)fw_maj & 0xffff) << 32) | ((fw_min & 0xffff) << 16) |
1118 (fw_mic & 0xffff);
1119}
1120
1026static int iwch_query_device(struct ib_device *ibdev, 1121static int iwch_query_device(struct ib_device *ibdev,
1027 struct ib_device_attr *props) 1122 struct ib_device_attr *props)
1028{ 1123{
@@ -1033,7 +1128,10 @@ static int iwch_query_device(struct ib_device *ibdev,
1033 dev = to_iwch_dev(ibdev); 1128 dev = to_iwch_dev(ibdev);
1034 memset(props, 0, sizeof *props); 1129 memset(props, 0, sizeof *props);
1035 memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1130 memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
1131 props->hw_ver = dev->rdev.t3cdev_p->type;
1132 props->fw_ver = fw_vers_string_to_u64(dev);
1036 props->device_cap_flags = dev->device_cap_flags; 1133 props->device_cap_flags = dev->device_cap_flags;
1134 props->page_size_cap = dev->attr.mem_pgsizes_bitmask;
1037 props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; 1135 props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor;
1038 props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; 1136 props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device;
1039 props->max_mr_size = dev->attr.max_mr_size; 1137 props->max_mr_size = dev->attr.max_mr_size;
@@ -1048,6 +1146,7 @@ static int iwch_query_device(struct ib_device *ibdev,
1048 props->max_mr = dev->attr.max_mem_regs; 1146 props->max_mr = dev->attr.max_mem_regs;
1049 props->max_pd = dev->attr.max_pds; 1147 props->max_pd = dev->attr.max_pds;
1050 props->local_ca_ack_delay = 0; 1148 props->local_ca_ack_delay = 0;
1149 props->max_fast_reg_page_list_len = T3_MAX_FASTREG_DEPTH;
1051 1150
1052 return 0; 1151 return 0;
1053} 1152}
@@ -1088,6 +1187,28 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
1088 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); 1187 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
1089} 1188}
1090 1189
1190static int fw_supports_fastreg(struct iwch_dev *iwch_dev)
1191{
1192 struct ethtool_drvinfo info;
1193 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1194 char *cp, *next;
1195 unsigned fw_maj, fw_min;
1196
1197 rtnl_lock();
1198 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1199 rtnl_unlock();
1200
1201 next = info.fw_version+1;
1202 cp = strsep(&next, ".");
1203 sscanf(cp, "%i", &fw_maj);
1204 cp = strsep(&next, ".");
1205 sscanf(cp, "%i", &fw_min);
1206
1207 PDBG("%s maj %u min %u\n", __func__, fw_maj, fw_min);
1208
1209 return fw_maj > 6 || (fw_maj == 6 && fw_min > 0);
1210}
1211
1091static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) 1212static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
1092{ 1213{
1093 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1214 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
@@ -1127,6 +1248,61 @@ static ssize_t show_board(struct device *dev, struct device_attribute *attr,
1127 iwch_dev->rdev.rnic_info.pdev->device); 1248 iwch_dev->rdev.rnic_info.pdev->device);
1128} 1249}
1129 1250
1251static int iwch_get_mib(struct ib_device *ibdev,
1252 union rdma_protocol_stats *stats)
1253{
1254 struct iwch_dev *dev;
1255 struct tp_mib_stats m;
1256 int ret;
1257
1258 PDBG("%s ibdev %p\n", __func__, ibdev);
1259 dev = to_iwch_dev(ibdev);
1260 ret = dev->rdev.t3cdev_p->ctl(dev->rdev.t3cdev_p, RDMA_GET_MIB, &m);
1261 if (ret)
1262 return -ENOSYS;
1263
1264 memset(stats, 0, sizeof *stats);
1265 stats->iw.ipInReceives = ((u64) m.ipInReceive_hi << 32) +
1266 m.ipInReceive_lo;
1267 stats->iw.ipInHdrErrors = ((u64) m.ipInHdrErrors_hi << 32) +
1268 m.ipInHdrErrors_lo;
1269 stats->iw.ipInAddrErrors = ((u64) m.ipInAddrErrors_hi << 32) +
1270 m.ipInAddrErrors_lo;
1271 stats->iw.ipInUnknownProtos = ((u64) m.ipInUnknownProtos_hi << 32) +
1272 m.ipInUnknownProtos_lo;
1273 stats->iw.ipInDiscards = ((u64) m.ipInDiscards_hi << 32) +
1274 m.ipInDiscards_lo;
1275 stats->iw.ipInDelivers = ((u64) m.ipInDelivers_hi << 32) +
1276 m.ipInDelivers_lo;
1277 stats->iw.ipOutRequests = ((u64) m.ipOutRequests_hi << 32) +
1278 m.ipOutRequests_lo;
1279 stats->iw.ipOutDiscards = ((u64) m.ipOutDiscards_hi << 32) +
1280 m.ipOutDiscards_lo;
1281 stats->iw.ipOutNoRoutes = ((u64) m.ipOutNoRoutes_hi << 32) +
1282 m.ipOutNoRoutes_lo;
1283 stats->iw.ipReasmTimeout = (u64) m.ipReasmTimeout;
1284 stats->iw.ipReasmReqds = (u64) m.ipReasmReqds;
1285 stats->iw.ipReasmOKs = (u64) m.ipReasmOKs;
1286 stats->iw.ipReasmFails = (u64) m.ipReasmFails;
1287 stats->iw.tcpActiveOpens = (u64) m.tcpActiveOpens;
1288 stats->iw.tcpPassiveOpens = (u64) m.tcpPassiveOpens;
1289 stats->iw.tcpAttemptFails = (u64) m.tcpAttemptFails;
1290 stats->iw.tcpEstabResets = (u64) m.tcpEstabResets;
1291 stats->iw.tcpOutRsts = (u64) m.tcpOutRsts;
1292 stats->iw.tcpCurrEstab = (u64) m.tcpCurrEstab;
1293 stats->iw.tcpInSegs = ((u64) m.tcpInSegs_hi << 32) +
1294 m.tcpInSegs_lo;
1295 stats->iw.tcpOutSegs = ((u64) m.tcpOutSegs_hi << 32) +
1296 m.tcpOutSegs_lo;
1297 stats->iw.tcpRetransSegs = ((u64) m.tcpRetransSeg_hi << 32) +
1298 m.tcpRetransSeg_lo;
1299 stats->iw.tcpInErrs = ((u64) m.tcpInErrs_hi << 32) +
1300 m.tcpInErrs_lo;
1301 stats->iw.tcpRtoMin = (u64) m.tcpRtoMin;
1302 stats->iw.tcpRtoMax = (u64) m.tcpRtoMax;
1303 return 0;
1304}
1305
1130static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1306static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1131static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1307static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1132static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1308static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
@@ -1136,7 +1312,7 @@ static struct device_attribute *iwch_class_attributes[] = {
1136 &dev_attr_hw_rev, 1312 &dev_attr_hw_rev,
1137 &dev_attr_fw_ver, 1313 &dev_attr_fw_ver,
1138 &dev_attr_hca_type, 1314 &dev_attr_hca_type,
1139 &dev_attr_board_id 1315 &dev_attr_board_id,
1140}; 1316};
1141 1317
1142int iwch_register_device(struct iwch_dev *dev) 1318int iwch_register_device(struct iwch_dev *dev)
@@ -1149,8 +1325,12 @@ int iwch_register_device(struct iwch_dev *dev)
1149 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); 1325 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
1150 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1326 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
1151 dev->ibdev.owner = THIS_MODULE; 1327 dev->ibdev.owner = THIS_MODULE;
1152 dev->device_cap_flags = 1328 dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
1153 (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW); 1329
1330 /* cxgb3 supports STag 0. */
1331 dev->ibdev.local_dma_lkey = 0;
1332 if (fw_supports_fastreg(dev))
1333 dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
1154 1334
1155 dev->ibdev.uverbs_cmd_mask = 1335 dev->ibdev.uverbs_cmd_mask =
1156 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | 1336 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
@@ -1202,15 +1382,16 @@ int iwch_register_device(struct iwch_dev *dev)
1202 dev->ibdev.alloc_mw = iwch_alloc_mw; 1382 dev->ibdev.alloc_mw = iwch_alloc_mw;
1203 dev->ibdev.bind_mw = iwch_bind_mw; 1383 dev->ibdev.bind_mw = iwch_bind_mw;
1204 dev->ibdev.dealloc_mw = iwch_dealloc_mw; 1384 dev->ibdev.dealloc_mw = iwch_dealloc_mw;
1205 1385 dev->ibdev.alloc_fast_reg_mr = iwch_alloc_fast_reg_mr;
1386 dev->ibdev.alloc_fast_reg_page_list = iwch_alloc_fastreg_pbl;
1387 dev->ibdev.free_fast_reg_page_list = iwch_free_fastreg_pbl;
1206 dev->ibdev.attach_mcast = iwch_multicast_attach; 1388 dev->ibdev.attach_mcast = iwch_multicast_attach;
1207 dev->ibdev.detach_mcast = iwch_multicast_detach; 1389 dev->ibdev.detach_mcast = iwch_multicast_detach;
1208 dev->ibdev.process_mad = iwch_process_mad; 1390 dev->ibdev.process_mad = iwch_process_mad;
1209
1210 dev->ibdev.req_notify_cq = iwch_arm_cq; 1391 dev->ibdev.req_notify_cq = iwch_arm_cq;
1211 dev->ibdev.post_send = iwch_post_send; 1392 dev->ibdev.post_send = iwch_post_send;
1212 dev->ibdev.post_recv = iwch_post_receive; 1393 dev->ibdev.post_recv = iwch_post_receive;
1213 1394 dev->ibdev.get_protocol_stats = iwch_get_mib;
1214 1395
1215 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); 1396 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
1216 if (!dev->ibdev.iwcm) 1397 if (!dev->ibdev.iwcm)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index 836163fc542..f5ceca05c43 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -296,14 +296,6 @@ static inline u32 iwch_ib_to_tpt_access(int acc)
296 TPT_LOCAL_READ; 296 TPT_LOCAL_READ;
297} 297}
298 298
299static inline u32 iwch_ib_to_mwbind_access(int acc)
300{
301 return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) |
302 (acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) |
303 (acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) |
304 T3_MEM_ACCESS_LOCAL_READ;
305}
306
307enum iwch_mmid_state { 299enum iwch_mmid_state {
308 IWCH_STAG_STATE_VALID, 300 IWCH_STAG_STATE_VALID,
309 IWCH_STAG_STATE_INVALID 301 IWCH_STAG_STATE_INVALID
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index 99261379922..9a3be3a9d5d 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -33,10 +33,11 @@
33#include "iwch.h" 33#include "iwch.h"
34#include "iwch_cm.h" 34#include "iwch_cm.h"
35#include "cxio_hal.h" 35#include "cxio_hal.h"
36#include "cxio_resource.h"
36 37
37#define NO_SUPPORT -1 38#define NO_SUPPORT -1
38 39
39static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, 40static int build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
40 u8 * flit_cnt) 41 u8 * flit_cnt)
41{ 42{
42 int i; 43 int i;
@@ -44,59 +45,44 @@ static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
44 45
45 switch (wr->opcode) { 46 switch (wr->opcode) {
46 case IB_WR_SEND: 47 case IB_WR_SEND:
47 case IB_WR_SEND_WITH_IMM:
48 if (wr->send_flags & IB_SEND_SOLICITED) 48 if (wr->send_flags & IB_SEND_SOLICITED)
49 wqe->send.rdmaop = T3_SEND_WITH_SE; 49 wqe->send.rdmaop = T3_SEND_WITH_SE;
50 else 50 else
51 wqe->send.rdmaop = T3_SEND; 51 wqe->send.rdmaop = T3_SEND;
52 wqe->send.rem_stag = 0; 52 wqe->send.rem_stag = 0;
53 break; 53 break;
54#if 0 /* Not currently supported */ 54 case IB_WR_SEND_WITH_INV:
55 case TYPE_SEND_INVALIDATE: 55 if (wr->send_flags & IB_SEND_SOLICITED)
56 case TYPE_SEND_INVALIDATE_IMMEDIATE: 56 wqe->send.rdmaop = T3_SEND_WITH_SE_INV;
57 wqe->send.rdmaop = T3_SEND_WITH_INV; 57 else
58 wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); 58 wqe->send.rdmaop = T3_SEND_WITH_INV;
59 break; 59 wqe->send.rem_stag = cpu_to_be32(wr->ex.invalidate_rkey);
60 case TYPE_SEND_SE_INVALIDATE:
61 wqe->send.rdmaop = T3_SEND_WITH_SE_INV;
62 wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
63 break; 60 break;
64#endif
65 default: 61 default:
66 break; 62 return -EINVAL;
67 } 63 }
68 if (wr->num_sge > T3_MAX_SGE) 64 if (wr->num_sge > T3_MAX_SGE)
69 return -EINVAL; 65 return -EINVAL;
70 wqe->send.reserved[0] = 0; 66 wqe->send.reserved[0] = 0;
71 wqe->send.reserved[1] = 0; 67 wqe->send.reserved[1] = 0;
72 wqe->send.reserved[2] = 0; 68 wqe->send.reserved[2] = 0;
73 if (wr->opcode == IB_WR_SEND_WITH_IMM) { 69 plen = 0;
74 plen = 4; 70 for (i = 0; i < wr->num_sge; i++) {
75 wqe->send.sgl[0].stag = wr->ex.imm_data; 71 if ((plen + wr->sg_list[i].length) < plen)
76 wqe->send.sgl[0].len = __constant_cpu_to_be32(0); 72 return -EMSGSIZE;
77 wqe->send.num_sgle = __constant_cpu_to_be32(0); 73
78 *flit_cnt = 5; 74 plen += wr->sg_list[i].length;
79 } else { 75 wqe->send.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey);
80 plen = 0; 76 wqe->send.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
81 for (i = 0; i < wr->num_sge; i++) { 77 wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
82 if ((plen + wr->sg_list[i].length) < plen) {
83 return -EMSGSIZE;
84 }
85 plen += wr->sg_list[i].length;
86 wqe->send.sgl[i].stag =
87 cpu_to_be32(wr->sg_list[i].lkey);
88 wqe->send.sgl[i].len =
89 cpu_to_be32(wr->sg_list[i].length);
90 wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
91 }
92 wqe->send.num_sgle = cpu_to_be32(wr->num_sge);
93 *flit_cnt = 4 + ((wr->num_sge) << 1);
94 } 78 }
79 wqe->send.num_sgle = cpu_to_be32(wr->num_sge);
80 *flit_cnt = 4 + ((wr->num_sge) << 1);
95 wqe->send.plen = cpu_to_be32(plen); 81 wqe->send.plen = cpu_to_be32(plen);
96 return 0; 82 return 0;
97} 83}
98 84
99static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, 85static int build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
100 u8 *flit_cnt) 86 u8 *flit_cnt)
101{ 87{
102 int i; 88 int i;
@@ -137,15 +123,18 @@ static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
137 return 0; 123 return 0;
138} 124}
139 125
140static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, 126static int build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
141 u8 *flit_cnt) 127 u8 *flit_cnt)
142{ 128{
143 if (wr->num_sge > 1) 129 if (wr->num_sge > 1)
144 return -EINVAL; 130 return -EINVAL;
145 wqe->read.rdmaop = T3_READ_REQ; 131 wqe->read.rdmaop = T3_READ_REQ;
132 if (wr->opcode == IB_WR_RDMA_READ_WITH_INV)
133 wqe->read.local_inv = 1;
134 else
135 wqe->read.local_inv = 0;
146 wqe->read.reserved[0] = 0; 136 wqe->read.reserved[0] = 0;
147 wqe->read.reserved[1] = 0; 137 wqe->read.reserved[1] = 0;
148 wqe->read.reserved[2] = 0;
149 wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); 138 wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
150 wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); 139 wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr);
151 wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); 140 wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey);
@@ -155,6 +144,57 @@ static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
155 return 0; 144 return 0;
156} 145}
157 146
147static int build_fastreg(union t3_wr *wqe, struct ib_send_wr *wr,
148 u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq)
149{
150 int i;
151 __be64 *p;
152
153 if (wr->wr.fast_reg.page_list_len > T3_MAX_FASTREG_DEPTH)
154 return -EINVAL;
155 *wr_cnt = 1;
156 wqe->fastreg.stag = cpu_to_be32(wr->wr.fast_reg.rkey);
157 wqe->fastreg.len = cpu_to_be32(wr->wr.fast_reg.length);
158 wqe->fastreg.va_base_hi = cpu_to_be32(wr->wr.fast_reg.iova_start >> 32);
159 wqe->fastreg.va_base_lo_fbo =
160 cpu_to_be32(wr->wr.fast_reg.iova_start & 0xffffffff);
161 wqe->fastreg.page_type_perms = cpu_to_be32(
162 V_FR_PAGE_COUNT(wr->wr.fast_reg.page_list_len) |
163 V_FR_PAGE_SIZE(wr->wr.fast_reg.page_shift-12) |
164 V_FR_TYPE(TPT_VATO) |
165 V_FR_PERMS(iwch_ib_to_tpt_access(wr->wr.fast_reg.access_flags)));
166 p = &wqe->fastreg.pbl_addrs[0];
167 for (i = 0; i < wr->wr.fast_reg.page_list_len; i++, p++) {
168
169 /* If we need a 2nd WR, then set it up */
170 if (i == T3_MAX_FASTREG_FRAG) {
171 *wr_cnt = 2;
172 wqe = (union t3_wr *)(wq->queue +
173 Q_PTR2IDX((wq->wptr+1), wq->size_log2));
174 build_fw_riwrh((void *)wqe, T3_WR_FASTREG, 0,
175 Q_GENBIT(wq->wptr + 1, wq->size_log2),
176 0, 1 + wr->wr.fast_reg.page_list_len - T3_MAX_FASTREG_FRAG,
177 T3_EOP);
178
179 p = &wqe->pbl_frag.pbl_addrs[0];
180 }
181 *p = cpu_to_be64((u64)wr->wr.fast_reg.page_list->page_list[i]);
182 }
183 *flit_cnt = 5 + wr->wr.fast_reg.page_list_len;
184 if (*flit_cnt > 15)
185 *flit_cnt = 15;
186 return 0;
187}
188
189static int build_inv_stag(union t3_wr *wqe, struct ib_send_wr *wr,
190 u8 *flit_cnt)
191{
192 wqe->local_inv.stag = cpu_to_be32(wr->ex.invalidate_rkey);
193 wqe->local_inv.reserved = 0;
194 *flit_cnt = sizeof(struct t3_local_inv_wr) >> 3;
195 return 0;
196}
197
158/* 198/*
159 * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. 199 * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now.
160 */ 200 */
@@ -205,23 +245,106 @@ static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list,
205 return 0; 245 return 0;
206} 246}
207 247
208static int iwch_build_rdma_recv(struct iwch_dev *rhp, union t3_wr *wqe, 248static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
209 struct ib_recv_wr *wr) 249 struct ib_recv_wr *wr)
210{ 250{
211 int i; 251 int i, err = 0;
212 if (wr->num_sge > T3_MAX_SGE) 252 u32 pbl_addr[T3_MAX_SGE];
213 return -EINVAL; 253 u8 page_size[T3_MAX_SGE];
254
255 err = iwch_sgl2pbl_map(qhp->rhp, wr->sg_list, wr->num_sge, pbl_addr,
256 page_size);
257 if (err)
258 return err;
259 wqe->recv.pagesz[0] = page_size[0];
260 wqe->recv.pagesz[1] = page_size[1];
261 wqe->recv.pagesz[2] = page_size[2];
262 wqe->recv.pagesz[3] = page_size[3];
214 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); 263 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
215 for (i = 0; i < wr->num_sge; i++) { 264 for (i = 0; i < wr->num_sge; i++) {
216 wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); 265 wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey);
217 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); 266 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
267
268 /* to in the WQE == the offset into the page */
269 wqe->recv.sgl[i].to = cpu_to_be64(((u32) wr->sg_list[i].addr) %
270 (1UL << (12 + page_size[i])));
271
272 /* pbl_addr is the adapters address in the PBL */
273 wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_addr[i]);
274 }
275 for (; i < T3_MAX_SGE; i++) {
276 wqe->recv.sgl[i].stag = 0;
277 wqe->recv.sgl[i].len = 0;
278 wqe->recv.sgl[i].to = 0;
279 wqe->recv.pbl_addr[i] = 0;
280 }
281 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
282 qhp->wq.rq_size_log2)].wr_id = wr->wr_id;
283 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
284 qhp->wq.rq_size_log2)].pbl_addr = 0;
285 return 0;
286}
287
288static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
289 struct ib_recv_wr *wr)
290{
291 int i;
292 u32 pbl_addr;
293 u32 pbl_offset;
294
295
296 /*
297 * The T3 HW requires the PBL in the HW recv descriptor to reference
298 * a PBL entry. So we allocate the max needed PBL memory here and pass
299 * it to the uP in the recv WR. The uP will build the PBL and setup
300 * the HW recv descriptor.
301 */
302 pbl_addr = cxio_hal_pblpool_alloc(&qhp->rhp->rdev, T3_STAG0_PBL_SIZE);
303 if (!pbl_addr)
304 return -ENOMEM;
305
306 /*
307 * Compute the 8B aligned offset.
308 */
309 pbl_offset = (pbl_addr - qhp->rhp->rdev.rnic_info.pbl_base) >> 3;
310
311 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
312
313 for (i = 0; i < wr->num_sge; i++) {
314
315 /*
316 * Use a 128MB page size. This and an imposed 128MB
317 * sge length limit allows us to require only a 2-entry HW
318 * PBL for each SGE. This restriction is acceptable since
319 * since it is not possible to allocate 128MB of contiguous
320 * DMA coherent memory!
321 */
322 if (wr->sg_list[i].length > T3_STAG0_MAX_PBE_LEN)
323 return -EINVAL;
324 wqe->recv.pagesz[i] = T3_STAG0_PAGE_SHIFT;
325
326 /*
327 * T3 restricts a recv to all zero-stag or all non-zero-stag.
328 */
329 if (wr->sg_list[i].lkey != 0)
330 return -EINVAL;
331 wqe->recv.sgl[i].stag = 0;
332 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
218 wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); 333 wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
334 wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_offset);
335 pbl_offset += 2;
219 } 336 }
220 for (; i < T3_MAX_SGE; i++) { 337 for (; i < T3_MAX_SGE; i++) {
338 wqe->recv.pagesz[i] = 0;
221 wqe->recv.sgl[i].stag = 0; 339 wqe->recv.sgl[i].stag = 0;
222 wqe->recv.sgl[i].len = 0; 340 wqe->recv.sgl[i].len = 0;
223 wqe->recv.sgl[i].to = 0; 341 wqe->recv.sgl[i].to = 0;
342 wqe->recv.pbl_addr[i] = 0;
224 } 343 }
344 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
345 qhp->wq.rq_size_log2)].wr_id = wr->wr_id;
346 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
347 qhp->wq.rq_size_log2)].pbl_addr = pbl_addr;
225 return 0; 348 return 0;
226} 349}
227 350
@@ -238,6 +361,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
238 u32 num_wrs; 361 u32 num_wrs;
239 unsigned long flag; 362 unsigned long flag;
240 struct t3_swsq *sqp; 363 struct t3_swsq *sqp;
364 int wr_cnt = 1;
241 365
242 qhp = to_iwch_qp(ibqp); 366 qhp = to_iwch_qp(ibqp);
243 spin_lock_irqsave(&qhp->lock, flag); 367 spin_lock_irqsave(&qhp->lock, flag);
@@ -262,33 +386,45 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
262 t3_wr_flags = 0; 386 t3_wr_flags = 0;
263 if (wr->send_flags & IB_SEND_SOLICITED) 387 if (wr->send_flags & IB_SEND_SOLICITED)
264 t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; 388 t3_wr_flags |= T3_SOLICITED_EVENT_FLAG;
265 if (wr->send_flags & IB_SEND_FENCE)
266 t3_wr_flags |= T3_READ_FENCE_FLAG;
267 if (wr->send_flags & IB_SEND_SIGNALED) 389 if (wr->send_flags & IB_SEND_SIGNALED)
268 t3_wr_flags |= T3_COMPLETION_FLAG; 390 t3_wr_flags |= T3_COMPLETION_FLAG;
269 sqp = qhp->wq.sq + 391 sqp = qhp->wq.sq +
270 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); 392 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
271 switch (wr->opcode) { 393 switch (wr->opcode) {
272 case IB_WR_SEND: 394 case IB_WR_SEND:
273 case IB_WR_SEND_WITH_IMM: 395 case IB_WR_SEND_WITH_INV:
396 if (wr->send_flags & IB_SEND_FENCE)
397 t3_wr_flags |= T3_READ_FENCE_FLAG;
274 t3_wr_opcode = T3_WR_SEND; 398 t3_wr_opcode = T3_WR_SEND;
275 err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); 399 err = build_rdma_send(wqe, wr, &t3_wr_flit_cnt);
276 break; 400 break;
277 case IB_WR_RDMA_WRITE: 401 case IB_WR_RDMA_WRITE:
278 case IB_WR_RDMA_WRITE_WITH_IMM: 402 case IB_WR_RDMA_WRITE_WITH_IMM:
279 t3_wr_opcode = T3_WR_WRITE; 403 t3_wr_opcode = T3_WR_WRITE;
280 err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); 404 err = build_rdma_write(wqe, wr, &t3_wr_flit_cnt);
281 break; 405 break;
282 case IB_WR_RDMA_READ: 406 case IB_WR_RDMA_READ:
407 case IB_WR_RDMA_READ_WITH_INV:
283 t3_wr_opcode = T3_WR_READ; 408 t3_wr_opcode = T3_WR_READ;
284 t3_wr_flags = 0; /* T3 reads are always signaled */ 409 t3_wr_flags = 0; /* T3 reads are always signaled */
285 err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); 410 err = build_rdma_read(wqe, wr, &t3_wr_flit_cnt);
286 if (err) 411 if (err)
287 break; 412 break;
288 sqp->read_len = wqe->read.local_len; 413 sqp->read_len = wqe->read.local_len;
289 if (!qhp->wq.oldest_read) 414 if (!qhp->wq.oldest_read)
290 qhp->wq.oldest_read = sqp; 415 qhp->wq.oldest_read = sqp;
291 break; 416 break;
417 case IB_WR_FAST_REG_MR:
418 t3_wr_opcode = T3_WR_FASTREG;
419 err = build_fastreg(wqe, wr, &t3_wr_flit_cnt,
420 &wr_cnt, &qhp->wq);
421 break;
422 case IB_WR_LOCAL_INV:
423 if (wr->send_flags & IB_SEND_FENCE)
424 t3_wr_flags |= T3_LOCAL_FENCE_FLAG;
425 t3_wr_opcode = T3_WR_INV_STAG;
426 err = build_inv_stag(wqe, wr, &t3_wr_flit_cnt);
427 break;
292 default: 428 default:
293 PDBG("%s post of type=%d TBD!\n", __func__, 429 PDBG("%s post of type=%d TBD!\n", __func__,
294 wr->opcode); 430 wr->opcode);
@@ -307,14 +443,15 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
307 443
308 build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, 444 build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags,
309 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 445 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
310 0, t3_wr_flit_cnt); 446 0, t3_wr_flit_cnt,
447 (wr_cnt == 1) ? T3_SOPEOP : T3_SOP);
311 PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", 448 PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n",
312 __func__, (unsigned long long) wr->wr_id, idx, 449 __func__, (unsigned long long) wr->wr_id, idx,
313 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), 450 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2),
314 sqp->opcode); 451 sqp->opcode);
315 wr = wr->next; 452 wr = wr->next;
316 num_wrs--; 453 num_wrs--;
317 ++(qhp->wq.wptr); 454 qhp->wq.wptr += wr_cnt;
318 ++(qhp->wq.sq_wptr); 455 ++(qhp->wq.sq_wptr);
319 } 456 }
320 spin_unlock_irqrestore(&qhp->lock, flag); 457 spin_unlock_irqrestore(&qhp->lock, flag);
@@ -345,21 +482,27 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
345 return -EINVAL; 482 return -EINVAL;
346 } 483 }
347 while (wr) { 484 while (wr) {
485 if (wr->num_sge > T3_MAX_SGE) {
486 err = -EINVAL;
487 *bad_wr = wr;
488 break;
489 }
348 idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); 490 idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
349 wqe = (union t3_wr *) (qhp->wq.queue + idx); 491 wqe = (union t3_wr *) (qhp->wq.queue + idx);
350 if (num_wrs) 492 if (num_wrs)
351 err = iwch_build_rdma_recv(qhp->rhp, wqe, wr); 493 if (wr->sg_list[0].lkey)
494 err = build_rdma_recv(qhp, wqe, wr);
495 else
496 err = build_zero_stag_recv(qhp, wqe, wr);
352 else 497 else
353 err = -ENOMEM; 498 err = -ENOMEM;
354 if (err) { 499 if (err) {
355 *bad_wr = wr; 500 *bad_wr = wr;
356 break; 501 break;
357 } 502 }
358 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] =
359 wr->wr_id;
360 build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, 503 build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG,
361 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 504 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
362 0, sizeof(struct t3_receive_wr) >> 3); 505 0, sizeof(struct t3_receive_wr) >> 3, T3_SOPEOP);
363 PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " 506 PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x "
364 "wqe %p \n", __func__, (unsigned long long) wr->wr_id, 507 "wqe %p \n", __func__, (unsigned long long) wr->wr_id,
365 idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); 508 idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe);
@@ -419,10 +562,10 @@ int iwch_bind_mw(struct ib_qp *qp,
419 sgl.lkey = mw_bind->mr->lkey; 562 sgl.lkey = mw_bind->mr->lkey;
420 sgl.length = mw_bind->length; 563 sgl.length = mw_bind->length;
421 wqe->bind.reserved = 0; 564 wqe->bind.reserved = 0;
422 wqe->bind.type = T3_VA_BASED_TO; 565 wqe->bind.type = TPT_VATO;
423 566
424 /* TBD: check perms */ 567 /* TBD: check perms */
425 wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags); 568 wqe->bind.perms = iwch_ib_to_tpt_access(mw_bind->mw_access_flags);
426 wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); 569 wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey);
427 wqe->bind.mw_stag = cpu_to_be32(mw->rkey); 570 wqe->bind.mw_stag = cpu_to_be32(mw->rkey);
428 wqe->bind.mw_len = cpu_to_be32(mw_bind->length); 571 wqe->bind.mw_len = cpu_to_be32(mw_bind->length);
@@ -430,7 +573,7 @@ int iwch_bind_mw(struct ib_qp *qp,
430 err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); 573 err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size);
431 if (err) { 574 if (err) {
432 spin_unlock_irqrestore(&qhp->lock, flag); 575 spin_unlock_irqrestore(&qhp->lock, flag);
433 return err; 576 return err;
434 } 577 }
435 wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; 578 wqe->send.wrid.id0.hi = qhp->wq.sq_wptr;
436 sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); 579 sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
@@ -441,10 +584,9 @@ int iwch_bind_mw(struct ib_qp *qp,
441 sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); 584 sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED);
442 wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); 585 wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr);
443 wqe->bind.mr_pagesz = page_size; 586 wqe->bind.mr_pagesz = page_size;
444 wqe->flit[T3_SQ_COOKIE_FLIT] = mw_bind->wr_id;
445 build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, 587 build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags,
446 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, 588 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0,
447 sizeof(struct t3_bind_mw_wr) >> 3); 589 sizeof(struct t3_bind_mw_wr) >> 3, T3_SOPEOP);
448 ++(qhp->wq.wptr); 590 ++(qhp->wq.wptr);
449 ++(qhp->wq.sq_wptr); 591 ++(qhp->wq.sq_wptr);
450 spin_unlock_irqrestore(&qhp->lock, flag); 592 spin_unlock_irqrestore(&qhp->lock, flag);
@@ -758,7 +900,8 @@ static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp,
758 init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); 900 init_attr.qp_dma_size = (1UL << qhp->wq.size_log2);
759 init_attr.rqe_count = iwch_rqes_posted(qhp); 901 init_attr.rqe_count = iwch_rqes_posted(qhp);
760 init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0; 902 init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0;
761 init_attr.flags |= capable(CAP_NET_BIND_SERVICE) ? PRIV_QP : 0; 903 if (!qhp->ibqp.uobject)
904 init_attr.flags |= PRIV_QP;
762 if (peer2peer) { 905 if (peer2peer) {
763 init_attr.rtr_type = RTR_READ; 906 init_attr.rtr_type = RTR_READ;
764 if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator) 907 if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator)
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index ce1ab0571be..0792d930c48 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -531,7 +531,7 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
531{ 531{
532 struct ehca_eq *eq = &shca->eq; 532 struct ehca_eq *eq = &shca->eq;
533 struct ehca_eqe_cache_entry *eqe_cache = eq->eqe_cache; 533 struct ehca_eqe_cache_entry *eqe_cache = eq->eqe_cache;
534 u64 eqe_value; 534 u64 eqe_value, ret;
535 unsigned long flags; 535 unsigned long flags;
536 int eqe_cnt, i; 536 int eqe_cnt, i;
537 int eq_empty = 0; 537 int eq_empty = 0;
@@ -583,8 +583,13 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
583 ehca_dbg(&shca->ib_device, 583 ehca_dbg(&shca->ib_device,
584 "No eqe found for irq event"); 584 "No eqe found for irq event");
585 goto unlock_irq_spinlock; 585 goto unlock_irq_spinlock;
586 } else if (!is_irq) 586 } else if (!is_irq) {
587 ret = hipz_h_eoi(eq->ist);
588 if (ret != H_SUCCESS)
589 ehca_err(&shca->ib_device,
590 "bad return code EOI -rc = %ld\n", ret);
587 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt); 591 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt);
592 }
588 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE)) 593 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE))
589 ehca_dbg(&shca->ib_device, "too many eqes for one irq event"); 594 ehca_dbg(&shca->ib_device, "too many eqes for one irq event");
590 /* enable irq for new packets */ 595 /* enable irq for new packets */
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 482103eb6ea..598844d2edc 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -923,6 +923,7 @@ static struct of_device_id ehca_device_table[] =
923 }, 923 },
924 {}, 924 {},
925}; 925};
926MODULE_DEVICE_TABLE(of, ehca_device_table);
926 927
927static struct of_platform_driver ehca_driver = { 928static struct of_platform_driver ehca_driver = {
928 .name = "ehca", 929 .name = "ehca",
diff --git a/drivers/infiniband/hw/ehca/ehca_reqs.c b/drivers/infiniband/hw/ehca/ehca_reqs.c
index f093b0033da..dd9bc68f1c7 100644
--- a/drivers/infiniband/hw/ehca/ehca_reqs.c
+++ b/drivers/infiniband/hw/ehca/ehca_reqs.c
@@ -544,8 +544,16 @@ int ehca_post_recv(struct ib_qp *qp,
544 struct ib_recv_wr *recv_wr, 544 struct ib_recv_wr *recv_wr,
545 struct ib_recv_wr **bad_recv_wr) 545 struct ib_recv_wr **bad_recv_wr)
546{ 546{
547 return internal_post_recv(container_of(qp, struct ehca_qp, ib_qp), 547 struct ehca_qp *my_qp = container_of(qp, struct ehca_qp, ib_qp);
548 qp->device, recv_wr, bad_recv_wr); 548
549 /* Reject WR if QP is in RESET state */
550 if (unlikely(my_qp->state == IB_QPS_RESET)) {
551 ehca_err(qp->device, "Invalid QP state qp_state=%d qpn=%x",
552 my_qp->state, qp->qp_num);
553 return -EINVAL;
554 }
555
556 return internal_post_recv(my_qp, qp->device, recv_wr, bad_recv_wr);
549} 557}
550 558
551int ehca_post_srq_recv(struct ib_srq *srq, 559int ehca_post_srq_recv(struct ib_srq *srq,
@@ -681,7 +689,7 @@ poll_cq_one_read_cqe:
681 wc->dlid_path_bits = cqe->dlid; 689 wc->dlid_path_bits = cqe->dlid;
682 wc->src_qp = cqe->remote_qp_number; 690 wc->src_qp = cqe->remote_qp_number;
683 wc->wc_flags = cqe->w_completion_flags; 691 wc->wc_flags = cqe->w_completion_flags;
684 wc->imm_data = cpu_to_be32(cqe->immediate_data); 692 wc->ex.imm_data = cpu_to_be32(cqe->immediate_data);
685 wc->sl = cqe->service_level; 693 wc->sl = cqe->service_level;
686 694
687poll_cq_one_exit0: 695poll_cq_one_exit0:
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index 5245e13c3a3..415d3a465de 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -933,3 +933,13 @@ u64 hipz_h_error_data(const struct ipz_adapter_handle adapter_handle,
933 r_cb, 933 r_cb,
934 0, 0, 0, 0); 934 0, 0, 0, 0);
935} 935}
936
937u64 hipz_h_eoi(int irq)
938{
939 unsigned long xirr;
940
941 iosync();
942 xirr = (0xffULL << 24) | irq;
943
944 return plpar_hcall_norets(H_EOI, xirr);
945}
diff --git a/drivers/infiniband/hw/ehca/hcp_if.h b/drivers/infiniband/hw/ehca/hcp_if.h
index 60ce02b7066..2c3c6e0ea5c 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.h
+++ b/drivers/infiniband/hw/ehca/hcp_if.h
@@ -260,5 +260,6 @@ u64 hipz_h_error_data(const struct ipz_adapter_handle adapter_handle,
260 const u64 ressource_handle, 260 const u64 ressource_handle,
261 void *rblock, 261 void *rblock,
262 unsigned long *byte_count); 262 unsigned long *byte_count);
263u64 hipz_h_eoi(int irq);
263 264
264#endif /* __HCP_IF_H__ */ 265#endif /* __HCP_IF_H__ */
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index a03bd28d9b4..d385e4168c9 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -82,7 +82,7 @@ void ipath_cq_enter(struct ipath_cq *cq, struct ib_wc *entry, int solicited)
82 wc->uqueue[head].opcode = entry->opcode; 82 wc->uqueue[head].opcode = entry->opcode;
83 wc->uqueue[head].vendor_err = entry->vendor_err; 83 wc->uqueue[head].vendor_err = entry->vendor_err;
84 wc->uqueue[head].byte_len = entry->byte_len; 84 wc->uqueue[head].byte_len = entry->byte_len;
85 wc->uqueue[head].imm_data = (__u32 __force)entry->imm_data; 85 wc->uqueue[head].ex.imm_data = (__u32 __force) entry->ex.imm_data;
86 wc->uqueue[head].qp_num = entry->qp->qp_num; 86 wc->uqueue[head].qp_num = entry->qp->qp_num;
87 wc->uqueue[head].src_qp = entry->src_qp; 87 wc->uqueue[head].src_qp = entry->src_qp;
88 wc->uqueue[head].wc_flags = entry->wc_flags; 88 wc->uqueue[head].wc_flags = entry->wc_flags;
diff --git a/drivers/infiniband/hw/ipath/ipath_iba7220.c b/drivers/infiniband/hw/ipath/ipath_iba7220.c
index 8eee7830f04..fb70712ac85 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba7220.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba7220.c
@@ -2228,8 +2228,8 @@ static void ipath_autoneg_send(struct ipath_devdata *dd, int which)
2228 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 2228 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
2229 0x40000001, 0x1388, 0x15e, /* rest 0's */ 2229 0x40000001, 0x1388, 0x15e, /* rest 0's */
2230 }; 2230 };
2231 dcnt = sizeof(madpayload_start)/sizeof(madpayload_start[0]); 2231 dcnt = ARRAY_SIZE(madpayload_start);
2232 hcnt = sizeof(hdr)/sizeof(hdr[0]); 2232 hcnt = ARRAY_SIZE(hdr);
2233 if (!swapped) { 2233 if (!swapped) {
2234 /* for maintainability, do it at runtime */ 2234 /* for maintainability, do it at runtime */
2235 for (i = 0; i < hcnt; i++) { 2235 for (i = 0; i < hcnt; i++) {
diff --git a/drivers/infiniband/hw/ipath/ipath_mad.c b/drivers/infiniband/hw/ipath/ipath_mad.c
index 5f9315d77a4..be4fc9ada8e 100644
--- a/drivers/infiniband/hw/ipath/ipath_mad.c
+++ b/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -111,9 +111,9 @@ static int recv_subn_get_nodeinfo(struct ib_smp *smp,
111 nip->revision = cpu_to_be32((majrev << 16) | minrev); 111 nip->revision = cpu_to_be32((majrev << 16) | minrev);
112 nip->local_port_num = port; 112 nip->local_port_num = port;
113 vendor = dd->ipath_vendorid; 113 vendor = dd->ipath_vendorid;
114 nip->vendor_id[0] = 0; 114 nip->vendor_id[0] = IPATH_SRC_OUI_1;
115 nip->vendor_id[1] = vendor >> 8; 115 nip->vendor_id[1] = IPATH_SRC_OUI_2;
116 nip->vendor_id[2] = vendor; 116 nip->vendor_id[2] = IPATH_SRC_OUI_3;
117 117
118 return reply(smp); 118 return reply(smp);
119} 119}
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index 108df667d2e..97710522624 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -1703,11 +1703,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1703 case OP(SEND_LAST_WITH_IMMEDIATE): 1703 case OP(SEND_LAST_WITH_IMMEDIATE):
1704 send_last_imm: 1704 send_last_imm:
1705 if (header_in_data) { 1705 if (header_in_data) {
1706 wc.imm_data = *(__be32 *) data; 1706 wc.ex.imm_data = *(__be32 *) data;
1707 data += sizeof(__be32); 1707 data += sizeof(__be32);
1708 } else { 1708 } else {
1709 /* Immediate data comes after BTH */ 1709 /* Immediate data comes after BTH */
1710 wc.imm_data = ohdr->u.imm_data; 1710 wc.ex.imm_data = ohdr->u.imm_data;
1711 } 1711 }
1712 hdrsize += 4; 1712 hdrsize += 4;
1713 wc.wc_flags = IB_WC_WITH_IMM; 1713 wc.wc_flags = IB_WC_WITH_IMM;
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index a4b5521567f..af051f75766 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -331,7 +331,7 @@ again:
331 switch (wqe->wr.opcode) { 331 switch (wqe->wr.opcode) {
332 case IB_WR_SEND_WITH_IMM: 332 case IB_WR_SEND_WITH_IMM:
333 wc.wc_flags = IB_WC_WITH_IMM; 333 wc.wc_flags = IB_WC_WITH_IMM;
334 wc.imm_data = wqe->wr.ex.imm_data; 334 wc.ex.imm_data = wqe->wr.ex.imm_data;
335 /* FALLTHROUGH */ 335 /* FALLTHROUGH */
336 case IB_WR_SEND: 336 case IB_WR_SEND:
337 if (!ipath_get_rwqe(qp, 0)) 337 if (!ipath_get_rwqe(qp, 0))
@@ -342,7 +342,7 @@ again:
342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) 342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
343 goto inv_err; 343 goto inv_err;
344 wc.wc_flags = IB_WC_WITH_IMM; 344 wc.wc_flags = IB_WC_WITH_IMM;
345 wc.imm_data = wqe->wr.ex.imm_data; 345 wc.ex.imm_data = wqe->wr.ex.imm_data;
346 if (!ipath_get_rwqe(qp, 1)) 346 if (!ipath_get_rwqe(qp, 1))
347 goto rnr_nak; 347 goto rnr_nak;
348 /* FALLTHROUGH */ 348 /* FALLTHROUGH */
diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c
index 0596ec16fcb..82cc588b8bf 100644
--- a/drivers/infiniband/hw/ipath/ipath_uc.c
+++ b/drivers/infiniband/hw/ipath/ipath_uc.c
@@ -379,11 +379,11 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
379 case OP(SEND_LAST_WITH_IMMEDIATE): 379 case OP(SEND_LAST_WITH_IMMEDIATE):
380 send_last_imm: 380 send_last_imm:
381 if (header_in_data) { 381 if (header_in_data) {
382 wc.imm_data = *(__be32 *) data; 382 wc.ex.imm_data = *(__be32 *) data;
383 data += sizeof(__be32); 383 data += sizeof(__be32);
384 } else { 384 } else {
385 /* Immediate data comes after BTH */ 385 /* Immediate data comes after BTH */
386 wc.imm_data = ohdr->u.imm_data; 386 wc.ex.imm_data = ohdr->u.imm_data;
387 } 387 }
388 hdrsize += 4; 388 hdrsize += 4;
389 wc.wc_flags = IB_WC_WITH_IMM; 389 wc.wc_flags = IB_WC_WITH_IMM;
@@ -483,11 +483,11 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
483 case OP(RDMA_WRITE_LAST_WITH_IMMEDIATE): 483 case OP(RDMA_WRITE_LAST_WITH_IMMEDIATE):
484 rdma_last_imm: 484 rdma_last_imm:
485 if (header_in_data) { 485 if (header_in_data) {
486 wc.imm_data = *(__be32 *) data; 486 wc.ex.imm_data = *(__be32 *) data;
487 data += sizeof(__be32); 487 data += sizeof(__be32);
488 } else { 488 } else {
489 /* Immediate data comes after BTH */ 489 /* Immediate data comes after BTH */
490 wc.imm_data = ohdr->u.imm_data; 490 wc.ex.imm_data = ohdr->u.imm_data;
491 } 491 }
492 hdrsize += 4; 492 hdrsize += 4;
493 wc.wc_flags = IB_WC_WITH_IMM; 493 wc.wc_flags = IB_WC_WITH_IMM;
diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c
index 77ca8ca74e7..36aa242c487 100644
--- a/drivers/infiniband/hw/ipath/ipath_ud.c
+++ b/drivers/infiniband/hw/ipath/ipath_ud.c
@@ -96,7 +96,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
96 96
97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) { 97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
98 wc.wc_flags = IB_WC_WITH_IMM; 98 wc.wc_flags = IB_WC_WITH_IMM;
99 wc.imm_data = swqe->wr.ex.imm_data; 99 wc.ex.imm_data = swqe->wr.ex.imm_data;
100 } 100 }
101 101
102 /* 102 /*
@@ -492,14 +492,14 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
492 if (qp->ibqp.qp_num > 1 && 492 if (qp->ibqp.qp_num > 1 &&
493 opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) { 493 opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) {
494 if (header_in_data) { 494 if (header_in_data) {
495 wc.imm_data = *(__be32 *) data; 495 wc.ex.imm_data = *(__be32 *) data;
496 data += sizeof(__be32); 496 data += sizeof(__be32);
497 } else 497 } else
498 wc.imm_data = ohdr->u.ud.imm_data; 498 wc.ex.imm_data = ohdr->u.ud.imm_data;
499 wc.wc_flags = IB_WC_WITH_IMM; 499 wc.wc_flags = IB_WC_WITH_IMM;
500 hdrsize += sizeof(u32); 500 hdrsize += sizeof(u32);
501 } else if (opcode == IB_OPCODE_UD_SEND_ONLY) { 501 } else if (opcode == IB_OPCODE_UD_SEND_ONLY) {
502 wc.imm_data = 0; 502 wc.ex.imm_data = 0;
503 wc.wc_flags = 0; 503 wc.wc_flags = 0;
504 } else { 504 } else {
505 dev->n_pkt_drops++; 505 dev->n_pkt_drops++;
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 7779165b2c2..55c71882882 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -35,6 +35,7 @@
35#include <rdma/ib_user_verbs.h> 35#include <rdma/ib_user_verbs.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/utsname.h> 37#include <linux/utsname.h>
38#include <linux/rculist.h>
38 39
39#include "ipath_kernel.h" 40#include "ipath_kernel.h"
40#include "ipath_verbs.h" 41#include "ipath_verbs.h"
@@ -1497,7 +1498,8 @@ static int ipath_query_device(struct ib_device *ibdev,
1497 IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN | 1498 IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN |
1498 IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE; 1499 IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE;
1499 props->page_size_cap = PAGE_SIZE; 1500 props->page_size_cap = PAGE_SIZE;
1500 props->vendor_id = dev->dd->ipath_vendorid; 1501 props->vendor_id =
1502 IPATH_SRC_OUI_1 << 16 | IPATH_SRC_OUI_2 << 8 | IPATH_SRC_OUI_3;
1501 props->vendor_part_id = dev->dd->ipath_deviceid; 1503 props->vendor_part_id = dev->dd->ipath_deviceid;
1502 props->hw_ver = dev->dd->ipath_pcirev; 1504 props->hw_ver = dev->dd->ipath_pcirev;
1503 1505
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
index 9e5abf9c309..d73e3223287 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
@@ -31,8 +31,7 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/list.h> 34#include <linux/rculist.h>
35#include <linux/rcupdate.h>
36 35
37#include "ipath_verbs.h" 36#include "ipath_verbs.h"
38 37
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 4521319b140..299f20832ab 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -663,18 +663,18 @@ repoll:
663 663
664 switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) { 664 switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
665 case MLX4_RECV_OPCODE_RDMA_WRITE_IMM: 665 case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
666 wc->opcode = IB_WC_RECV_RDMA_WITH_IMM; 666 wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
667 wc->wc_flags = IB_WC_WITH_IMM; 667 wc->wc_flags = IB_WC_WITH_IMM;
668 wc->imm_data = cqe->immed_rss_invalid; 668 wc->ex.imm_data = cqe->immed_rss_invalid;
669 break; 669 break;
670 case MLX4_RECV_OPCODE_SEND: 670 case MLX4_RECV_OPCODE_SEND:
671 wc->opcode = IB_WC_RECV; 671 wc->opcode = IB_WC_RECV;
672 wc->wc_flags = 0; 672 wc->wc_flags = 0;
673 break; 673 break;
674 case MLX4_RECV_OPCODE_SEND_IMM: 674 case MLX4_RECV_OPCODE_SEND_IMM:
675 wc->opcode = IB_WC_RECV; 675 wc->opcode = IB_WC_RECV;
676 wc->wc_flags = IB_WC_WITH_IMM; 676 wc->wc_flags = IB_WC_WITH_IMM;
677 wc->imm_data = cqe->immed_rss_invalid; 677 wc->ex.imm_data = cqe->immed_rss_invalid;
678 break; 678 break;
679 } 679 }
680 680
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 4c1e72fc8f5..cdca3a511e1 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -255,7 +255,8 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
255 return IB_MAD_RESULT_SUCCESS; 255 return IB_MAD_RESULT_SUCCESS;
256 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT || 256 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
257 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 || 257 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 ||
258 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS2) { 258 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS2 ||
259 in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_CONG_MGMT) {
259 if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET && 260 if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
260 in_mad->mad_hdr.method != IB_MGMT_METHOD_SET) 261 in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
261 return IB_MAD_RESULT_SUCCESS; 262 return IB_MAD_RESULT_SUCCESS;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4d61e32866c..bcf50648fa1 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -90,7 +90,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
90 props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT | 90 props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
91 IB_DEVICE_PORT_ACTIVE_EVENT | 91 IB_DEVICE_PORT_ACTIVE_EVENT |
92 IB_DEVICE_SYS_IMAGE_GUID | 92 IB_DEVICE_SYS_IMAGE_GUID |
93 IB_DEVICE_RC_RNR_NAK_GEN; 93 IB_DEVICE_RC_RNR_NAK_GEN |
94 IB_DEVICE_BLOCK_MULTICAST_LOOPBACK;
94 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR) 95 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR)
95 props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR; 96 props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR;
96 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR) 97 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR)
@@ -437,7 +438,9 @@ static int mlx4_ib_dealloc_pd(struct ib_pd *pd)
437static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) 438static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
438{ 439{
439 return mlx4_multicast_attach(to_mdev(ibqp->device)->dev, 440 return mlx4_multicast_attach(to_mdev(ibqp->device)->dev,
440 &to_mqp(ibqp)->mqp, gid->raw); 441 &to_mqp(ibqp)->mqp, gid->raw,
442 !!(to_mqp(ibqp)->flags &
443 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK));
441} 444}
442 445
443static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) 446static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 5cf994794d2..c4cf5b69eef 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -101,7 +101,8 @@ struct mlx4_ib_wq {
101}; 101};
102 102
103enum mlx4_ib_qp_flags { 103enum mlx4_ib_qp_flags {
104 MLX4_IB_QP_LSO = 1 << 0 104 MLX4_IB_QP_LSO = 1 << 0,
105 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
105}; 106};
106 107
107struct mlx4_ib_qp { 108struct mlx4_ib_qp {
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index a80df22deae..89eb6cbe592 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -129,9 +129,10 @@ static void stamp_send_wqe(struct mlx4_ib_qp *qp, int n, int size)
129 int ind; 129 int ind;
130 void *buf; 130 void *buf;
131 __be32 stamp; 131 __be32 stamp;
132 struct mlx4_wqe_ctrl_seg *ctrl;
132 133
133 s = roundup(size, 1U << qp->sq.wqe_shift);
134 if (qp->sq_max_wqes_per_wr > 1) { 134 if (qp->sq_max_wqes_per_wr > 1) {
135 s = roundup(size, 1U << qp->sq.wqe_shift);
135 for (i = 0; i < s; i += 64) { 136 for (i = 0; i < s; i += 64) {
136 ind = (i >> qp->sq.wqe_shift) + n; 137 ind = (i >> qp->sq.wqe_shift) + n;
137 stamp = ind & qp->sq.wqe_cnt ? cpu_to_be32(0x7fffffff) : 138 stamp = ind & qp->sq.wqe_cnt ? cpu_to_be32(0x7fffffff) :
@@ -141,7 +142,8 @@ static void stamp_send_wqe(struct mlx4_ib_qp *qp, int n, int size)
141 *wqe = stamp; 142 *wqe = stamp;
142 } 143 }
143 } else { 144 } else {
144 buf = get_send_wqe(qp, n & (qp->sq.wqe_cnt - 1)); 145 ctrl = buf = get_send_wqe(qp, n & (qp->sq.wqe_cnt - 1));
146 s = (ctrl->fence_size & 0x3f) << 4;
145 for (i = 64; i < s; i += 64) { 147 for (i = 64; i < s; i += 64) {
146 wqe = buf + i; 148 wqe = buf + i;
147 *wqe = cpu_to_be32(0xffffffff); 149 *wqe = cpu_to_be32(0xffffffff);
@@ -452,19 +454,8 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
452 spin_lock_init(&qp->rq.lock); 454 spin_lock_init(&qp->rq.lock);
453 455
454 qp->state = IB_QPS_RESET; 456 qp->state = IB_QPS_RESET;
455 qp->atomic_rd_en = 0;
456 qp->resp_depth = 0;
457
458 qp->rq.head = 0;
459 qp->rq.tail = 0;
460 qp->sq.head = 0;
461 qp->sq.tail = 0;
462 qp->sq_next_wqe = 0;
463
464 if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) 457 if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
465 qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); 458 qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE);
466 else
467 qp->sq_signal_bits = 0;
468 459
469 err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, !!init_attr->srq, qp); 460 err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, !!init_attr->srq, qp);
470 if (err) 461 if (err)
@@ -509,6 +500,9 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
509 } else { 500 } else {
510 qp->sq_no_prefetch = 0; 501 qp->sq_no_prefetch = 0;
511 502
503 if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
504 qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
505
512 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO) 506 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
513 qp->flags |= MLX4_IB_QP_LSO; 507 qp->flags |= MLX4_IB_QP_LSO;
514 508
@@ -682,10 +676,15 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
682 struct mlx4_ib_qp *qp; 676 struct mlx4_ib_qp *qp;
683 int err; 677 int err;
684 678
685 /* We only support LSO, and only for kernel UD QPs. */ 679 /*
686 if (init_attr->create_flags & ~IB_QP_CREATE_IPOIB_UD_LSO) 680 * We only support LSO and multicast loopback blocking, and
681 * only for kernel UD QPs.
682 */
683 if (init_attr->create_flags & ~(IB_QP_CREATE_IPOIB_UD_LSO |
684 IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK))
687 return ERR_PTR(-EINVAL); 685 return ERR_PTR(-EINVAL);
688 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO && 686
687 if (init_attr->create_flags &&
689 (pd->uobject || init_attr->qp_type != IB_QPT_UD)) 688 (pd->uobject || init_attr->qp_type != IB_QPT_UD))
690 return ERR_PTR(-EINVAL); 689 return ERR_PTR(-EINVAL);
691 690
@@ -694,7 +693,7 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
694 case IB_QPT_UC: 693 case IB_QPT_UC:
695 case IB_QPT_UD: 694 case IB_QPT_UD:
696 { 695 {
697 qp = kmalloc(sizeof *qp, GFP_KERNEL); 696 qp = kzalloc(sizeof *qp, GFP_KERNEL);
698 if (!qp) 697 if (!qp)
699 return ERR_PTR(-ENOMEM); 698 return ERR_PTR(-ENOMEM);
700 699
@@ -715,7 +714,7 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
715 if (pd->uobject) 714 if (pd->uobject)
716 return ERR_PTR(-EINVAL); 715 return ERR_PTR(-EINVAL);
717 716
718 sqp = kmalloc(sizeof *sqp, GFP_KERNEL); 717 sqp = kzalloc(sizeof *sqp, GFP_KERNEL);
719 if (!sqp) 718 if (!sqp)
720 return ERR_PTR(-ENOMEM); 719 return ERR_PTR(-ENOMEM);
721 720
@@ -906,7 +905,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
906 attr->path_mtu); 905 attr->path_mtu);
907 goto out; 906 goto out;
908 } 907 }
909 context->mtu_msgmax = (attr->path_mtu << 5) | 31; 908 context->mtu_msgmax = (attr->path_mtu << 5) |
909 ilog2(dev->dev->caps.max_msg_sz);
910 } 910 }
911 911
912 if (qp->rq.wqe_cnt) 912 if (qp->rq.wqe_cnt)
@@ -1063,6 +1063,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1063 for (i = 0; i < qp->sq.wqe_cnt; ++i) { 1063 for (i = 0; i < qp->sq.wqe_cnt; ++i) {
1064 ctrl = get_send_wqe(qp, i); 1064 ctrl = get_send_wqe(qp, i);
1065 ctrl->owner_opcode = cpu_to_be32(1 << 31); 1065 ctrl->owner_opcode = cpu_to_be32(1 << 31);
1066 if (qp->sq_max_wqes_per_wr == 1)
1067 ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
1066 1068
1067 stamp_send_wqe(qp, i, 1 << qp->sq.wqe_shift); 1069 stamp_send_wqe(qp, i, 1 << qp->sq.wqe_shift);
1068 } 1070 }
@@ -1127,23 +1129,6 @@ out:
1127 return err; 1129 return err;
1128} 1130}
1129 1131
1130static const struct ib_qp_attr mlx4_ib_qp_attr = { .port_num = 1 };
1131static const int mlx4_ib_qp_attr_mask_table[IB_QPT_UD + 1] = {
1132 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
1133 IB_QP_PORT |
1134 IB_QP_QKEY),
1135 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
1136 IB_QP_PORT |
1137 IB_QP_ACCESS_FLAGS),
1138 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
1139 IB_QP_PORT |
1140 IB_QP_ACCESS_FLAGS),
1141 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
1142 IB_QP_QKEY),
1143 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
1144 IB_QP_QKEY),
1145};
1146
1147int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 1132int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1148 int attr_mask, struct ib_udata *udata) 1133 int attr_mask, struct ib_udata *udata)
1149{ 1134{
@@ -1186,15 +1171,6 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1186 goto out; 1171 goto out;
1187 } 1172 }
1188 1173
1189 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
1190 err = __mlx4_ib_modify_qp(ibqp, &mlx4_ib_qp_attr,
1191 mlx4_ib_qp_attr_mask_table[ibqp->qp_type],
1192 IB_QPS_RESET, IB_QPS_INIT);
1193 if (err)
1194 goto out;
1195 cur_state = IB_QPS_INIT;
1196 }
1197
1198 err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state); 1174 err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
1199 1175
1200out: 1176out:
@@ -1865,6 +1841,13 @@ done:
1865 1841
1866 qp_init_attr->cap = qp_attr->cap; 1842 qp_init_attr->cap = qp_attr->cap;
1867 1843
1844 qp_init_attr->create_flags = 0;
1845 if (qp->flags & MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK)
1846 qp_init_attr->create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
1847
1848 if (qp->flags & MLX4_IB_QP_LSO)
1849 qp_init_attr->create_flags |= IB_QP_CREATE_IPOIB_UD_LSO;
1850
1868out: 1851out:
1869 mutex_unlock(&qp->mutex); 1852 mutex_unlock(&qp->mutex);
1870 return err; 1853 return err;
diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
index a7630670961..c5ccc2daab6 100644
--- a/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_allocator.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/errno.h> 33#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 4b111a852ff..32f6c631545 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/string.h> 34#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index e948158a28d..cc440f90000 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <linux/jiffies.h> 33#include <linux/jiffies.h>
@@ -128,7 +126,6 @@ static void handle_catas(struct mthca_dev *dev)
128static void poll_catas(unsigned long dev_ptr) 126static void poll_catas(unsigned long dev_ptr)
129{ 127{
130 struct mthca_dev *dev = (struct mthca_dev *) dev_ptr; 128 struct mthca_dev *dev = (struct mthca_dev *) dev_ptr;
131 unsigned long flags;
132 int i; 129 int i;
133 130
134 for (i = 0; i < dev->catas_err.size; ++i) 131 for (i = 0; i < dev->catas_err.size; ++i)
@@ -137,13 +134,8 @@ static void poll_catas(unsigned long dev_ptr)
137 return; 134 return;
138 } 135 }
139 136
140 spin_lock_irqsave(&catas_lock, flags); 137 mod_timer(&dev->catas_err.timer,
141 if (!dev->catas_err.stop) 138 round_jiffies(jiffies + MTHCA_CATAS_POLL_INTERVAL));
142 mod_timer(&dev->catas_err.timer,
143 jiffies + MTHCA_CATAS_POLL_INTERVAL);
144 spin_unlock_irqrestore(&catas_lock, flags);
145
146 return;
147} 139}
148 140
149void mthca_start_catas_poll(struct mthca_dev *dev) 141void mthca_start_catas_poll(struct mthca_dev *dev)
@@ -151,7 +143,6 @@ void mthca_start_catas_poll(struct mthca_dev *dev)
151 unsigned long addr; 143 unsigned long addr;
152 144
153 init_timer(&dev->catas_err.timer); 145 init_timer(&dev->catas_err.timer);
154 dev->catas_err.stop = 0;
155 dev->catas_err.map = NULL; 146 dev->catas_err.map = NULL;
156 147
157 addr = pci_resource_start(dev->pdev, 0) + 148 addr = pci_resource_start(dev->pdev, 0) +
@@ -182,10 +173,6 @@ void mthca_start_catas_poll(struct mthca_dev *dev)
182 173
183void mthca_stop_catas_poll(struct mthca_dev *dev) 174void mthca_stop_catas_poll(struct mthca_dev *dev)
184{ 175{
185 spin_lock_irq(&catas_lock);
186 dev->catas_err.stop = 1;
187 spin_unlock_irq(&catas_lock);
188
189 del_timer_sync(&dev->catas_err.timer); 176 del_timer_sync(&dev->catas_err.timer);
190 177
191 if (dev->catas_err.map) { 178 if (dev->catas_err.map) {
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 54d230ee7d6..c33e1c53c79 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_cmd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/completion.h> 35#include <linux/completion.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h
index 8928ca4a932..6efd3265f24 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.h
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_cmd.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#ifndef MTHCA_CMD_H 35#ifndef MTHCA_CMD_H
diff --git a/drivers/infiniband/hw/mthca/mthca_config_reg.h b/drivers/infiniband/hw/mthca/mthca_config_reg.h
index afa56bfaab2..75671f75cac 100644
--- a/drivers/infiniband/hw/mthca/mthca_config_reg.h
+++ b/drivers/infiniband/hw/mthca/mthca_config_reg.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_config_reg.h 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#ifndef MTHCA_CONFIG_REG_H 34#ifndef MTHCA_CONFIG_REG_H
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 20401d2ba6b..d9f4735c2b3 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $
37 */ 35 */
38 36
39#include <linux/hardirq.h> 37#include <linux/hardirq.h>
@@ -622,13 +620,13 @@ static inline int mthca_poll_one(struct mthca_dev *dev,
622 case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE: 620 case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE:
623 case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE: 621 case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE:
624 entry->wc_flags = IB_WC_WITH_IMM; 622 entry->wc_flags = IB_WC_WITH_IMM;
625 entry->imm_data = cqe->imm_etype_pkey_eec; 623 entry->ex.imm_data = cqe->imm_etype_pkey_eec;
626 entry->opcode = IB_WC_RECV; 624 entry->opcode = IB_WC_RECV;
627 break; 625 break;
628 case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE: 626 case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
629 case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE: 627 case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
630 entry->wc_flags = IB_WC_WITH_IMM; 628 entry->wc_flags = IB_WC_WITH_IMM;
631 entry->imm_data = cqe->imm_etype_pkey_eec; 629 entry->ex.imm_data = cqe->imm_etype_pkey_eec;
632 entry->opcode = IB_WC_RECV_RDMA_WITH_IMM; 630 entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;
633 break; 631 break;
634 default: 632 default:
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 7bc32f8e377..ee4d073c889 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_dev.h 1349 2004-12-16 21:09:43Z roland $
37 */ 35 */
38 36
39#ifndef MTHCA_DEV_H 37#ifndef MTHCA_DEV_H
@@ -279,7 +277,6 @@ struct mthca_mcg_table {
279struct mthca_catas_err { 277struct mthca_catas_err {
280 u64 addr; 278 u64 addr;
281 u32 __iomem *map; 279 u32 __iomem *map;
282 unsigned long stop;
283 u32 size; 280 u32 size;
284 struct timer_list timer; 281 struct timer_list timer;
285 struct list_head list; 282 struct list_head list;
diff --git a/drivers/infiniband/hw/mthca/mthca_doorbell.h b/drivers/infiniband/hw/mthca/mthca_doorbell.h
index b374dc395be..14f51ef97d7 100644
--- a/drivers/infiniband/hw/mthca/mthca_doorbell.h
+++ b/drivers/infiniband/hw/mthca/mthca_doorbell.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_doorbell.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/types.h> 35#include <linux/types.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 8bde7f98e58..4e36aa7cb3d 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 8b7e83e6e88..640449582ab 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_mad.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/string.h> 35#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 200cf13fc9b..fb9f91b60f3 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_main.c 1396 2004-12-28 04:10:27Z roland $
35 */ 33 */
36 34
37#include <linux/module.h> 35#include <linux/module.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index a8ad072be07..3f5f9487920 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/string.h> 33#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index d5862e5d99a..1f7d1a29d2a 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id$
35 */ 33 */
36 34
37#include <linux/mm.h> 35#include <linux/mm.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index a1ab06847b7..da9b8f9b884 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id$
35 */ 33 */
36 34
37#ifndef MTHCA_MEMFREE_H 35#ifndef MTHCA_MEMFREE_H
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index 820205dec56..8489b1e81c0 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_mr.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/slab.h> 34#include <linux/slab.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c
index c1e950764bd..266f14e4740 100644
--- a/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/drivers/infiniband/hw/mthca/mthca_pd.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/errno.h> 35#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c
index 605a8d57fac..d168c254061 100644
--- a/drivers/infiniband/hw/mthca/mthca_profile.c
+++ b/drivers/infiniband/hw/mthca/mthca_profile.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_profile.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.h b/drivers/infiniband/hw/mthca/mthca_profile.h
index e76cb62d8e3..62b009cc873 100644
--- a/drivers/infiniband/hw/mthca/mthca_profile.h
+++ b/drivers/infiniband/hw/mthca/mthca_profile.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_profile.h 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#ifndef MTHCA_PROFILE_H 34#ifndef MTHCA_PROFILE_H
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index be34f99ca62..87ad889e367 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $
37 */ 35 */
38 36
39#include <rdma/ib_smi.h> 37#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 934bf954403..c621f8794b8 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_provider.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#ifndef MTHCA_PROVIDER_H 35#ifndef MTHCA_PROVIDER_H
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 09dc3614cf2..f5081bfde6d 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $
36 */ 34 */
37 35
38#include <linux/string.h> 36#include <linux/string.h>
@@ -850,23 +848,6 @@ out:
850 return err; 848 return err;
851} 849}
852 850
853static const struct ib_qp_attr dummy_init_attr = { .port_num = 1 };
854static const int dummy_init_attr_mask[] = {
855 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
856 IB_QP_PORT |
857 IB_QP_QKEY),
858 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
859 IB_QP_PORT |
860 IB_QP_ACCESS_FLAGS),
861 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
862 IB_QP_PORT |
863 IB_QP_ACCESS_FLAGS),
864 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
865 IB_QP_QKEY),
866 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
867 IB_QP_QKEY),
868};
869
870int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, 851int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
871 struct ib_udata *udata) 852 struct ib_udata *udata)
872{ 853{
@@ -928,15 +909,6 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
928 goto out; 909 goto out;
929 } 910 }
930 911
931 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
932 err = __mthca_modify_qp(ibqp, &dummy_init_attr,
933 dummy_init_attr_mask[ibqp->qp_type],
934 IB_QPS_RESET, IB_QPS_INIT);
935 if (err)
936 goto out;
937 cur_state = IB_QPS_INIT;
938 }
939
940 err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state); 912 err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
941 913
942out: 914out:
@@ -1277,10 +1249,10 @@ static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
1277 return -EINVAL; 1249 return -EINVAL;
1278 1250
1279 /* 1251 /*
1280 * For MLX transport we need 2 extra S/G entries: 1252 * For MLX transport we need 2 extra send gather entries:
1281 * one for the header and one for the checksum at the end 1253 * one for the header and one for the checksum at the end
1282 */ 1254 */
1283 if (qp->transport == MLX && cap->max_recv_sge + 2 > dev->limits.max_sg) 1255 if (qp->transport == MLX && cap->max_send_sge + 2 > dev->limits.max_sg)
1284 return -EINVAL; 1256 return -EINVAL;
1285 1257
1286 if (mthca_is_memfree(dev)) { 1258 if (mthca_is_memfree(dev)) {
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index 91934f2d9db..acb6817f606 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_reset.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/init.h> 33#include <linux/init.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index a5ffff6e102..4fabe62aab8 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_srq.c 3047 2005-08-10 03:59:35Z roland $
33 */ 31 */
34 32
35#include <linux/slab.h> 33#include <linux/slab.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_uar.c b/drivers/infiniband/hw/mthca/mthca_uar.c
index 8b728486410..ca5900c96fc 100644
--- a/drivers/infiniband/hw/mthca/mthca_uar.c
+++ b/drivers/infiniband/hw/mthca/mthca_uar.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <asm/page.h> /* PAGE_SHIFT */ 33#include <asm/page.h> /* PAGE_SHIFT */
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
index e1262c942db..5fe56e81073 100644
--- a/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -29,7 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 */ 32 */
34 33
35#ifndef MTHCA_USER_H 34#ifndef MTHCA_USER_H
diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h
index b3551a8dea1..341a5ae881c 100644
--- a/drivers/infiniband/hw/mthca/mthca_wqe.h
+++ b/drivers/infiniband/hw/mthca/mthca_wqe.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_wqe.h 3047 2005-08-10 03:59:35Z roland $
33 */ 31 */
34 32
35#ifndef MTHCA_WQE_H 33#ifndef MTHCA_WQE_H
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index a4e9269a29b..d2884e77809 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -328,7 +328,7 @@ void nes_rem_ref(struct ib_qp *ibqp)
328 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, nesqp->hwqp.qp_id); 328 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, nesqp->hwqp.qp_id);
329 u64temp = (u64)nesqp->nesqp_context_pbase; 329 u64temp = (u64)nesqp->nesqp_context_pbase;
330 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp); 330 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp);
331 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 331 nes_post_cqp_request(nesdev, cqp_request);
332 } 332 }
333} 333}
334 334
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 61b46e9c7d2..39bd897b40c 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -94,9 +94,6 @@
94 94
95#define MAX_DPC_ITERATIONS 128 95#define MAX_DPC_ITERATIONS 128
96 96
97#define NES_CQP_REQUEST_NO_DOORBELL_RING 0
98#define NES_CQP_REQUEST_RING_DOORBELL 1
99
100#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001 97#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001
101#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002 98#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002
102#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004 99#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004
@@ -538,7 +535,11 @@ void nes_read_1G_phy_reg(struct nes_device *, u8, u8, u16 *);
538void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16, u16); 535void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16, u16);
539void nes_read_10G_phy_reg(struct nes_device *, u8, u8, u16); 536void nes_read_10G_phy_reg(struct nes_device *, u8, u8, u16);
540struct nes_cqp_request *nes_get_cqp_request(struct nes_device *); 537struct nes_cqp_request *nes_get_cqp_request(struct nes_device *);
541void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *, int); 538void nes_free_cqp_request(struct nes_device *nesdev,
539 struct nes_cqp_request *cqp_request);
540void nes_put_cqp_request(struct nes_device *nesdev,
541 struct nes_cqp_request *cqp_request);
542void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *);
542int nes_arp_table(struct nes_device *, u32, u8 *, u32); 543int nes_arp_table(struct nes_device *, u32, u8 *, u32);
543void nes_mh_fix(unsigned long); 544void nes_mh_fix(unsigned long);
544void nes_clc(unsigned long); 545void nes_clc(unsigned long);
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 9a4b40fae40..6aa531d5276 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1603,7 +1603,6 @@ static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
1603 return NULL; 1603 return NULL;
1604 } 1604 }
1605 1605
1606 memset(listener, 0, sizeof(struct nes_cm_listener));
1607 listener->loc_addr = htonl(cm_info->loc_addr); 1606 listener->loc_addr = htonl(cm_info->loc_addr);
1608 listener->loc_port = htons(cm_info->loc_port); 1607 listener->loc_port = htons(cm_info->loc_port);
1609 listener->reused_node = 0; 1608 listener->reused_node = 0;
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index d3278f111ca..85f26d19a32 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -398,7 +398,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
398 nesadapter->base_pd = 1; 398 nesadapter->base_pd = 1;
399 399
400 nesadapter->device_cap_flags = 400 nesadapter->device_cap_flags =
401 IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW; 401 IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
402 402
403 nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter) 403 nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter)
404 [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]); 404 [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]);
@@ -2710,39 +2710,11 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
2710 barrier(); 2710 barrier();
2711 cqp_request->request_done = 1; 2711 cqp_request->request_done = 1;
2712 wake_up(&cqp_request->waitq); 2712 wake_up(&cqp_request->waitq);
2713 if (atomic_dec_and_test(&cqp_request->refcount)) { 2713 nes_put_cqp_request(nesdev, cqp_request);
2714 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n",
2715 cqp_request,
2716 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f);
2717 if (cqp_request->dynamic) {
2718 kfree(cqp_request);
2719 } else {
2720 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2721 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2722 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2723 }
2724 }
2725 } else if (cqp_request->callback) {
2726 /* Envoke the callback routine */
2727 cqp_request->cqp_callback(nesdev, cqp_request);
2728 if (cqp_request->dynamic) {
2729 kfree(cqp_request);
2730 } else {
2731 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2732 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2733 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2734 }
2735 } else { 2714 } else {
2736 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n", 2715 if (cqp_request->callback)
2737 cqp_request, 2716 cqp_request->cqp_callback(nesdev, cqp_request);
2738 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f); 2717 nes_free_cqp_request(nesdev, cqp_request);
2739 if (cqp_request->dynamic) {
2740 kfree(cqp_request);
2741 } else {
2742 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2743 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2744 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2745 }
2746 } 2718 }
2747 } else { 2719 } else {
2748 wake_up(&nesdev->cqp.waitq); 2720 wake_up(&nesdev->cqp.waitq);
@@ -3149,7 +3121,6 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3149{ 3121{
3150 struct nes_device *nesdev = nesvnic->nesdev; 3122 struct nes_device *nesdev = nesvnic->nesdev;
3151 struct nes_hw_cqp_wqe *cqp_wqe; 3123 struct nes_hw_cqp_wqe *cqp_wqe;
3152 unsigned long flags;
3153 struct nes_cqp_request *cqp_request; 3124 struct nes_cqp_request *cqp_request;
3154 int ret = 0; 3125 int ret = 0;
3155 u16 major_code; 3126 u16 major_code;
@@ -3176,7 +3147,7 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3176 nes_debug(NES_DBG_QP, "Waiting for CQP completion for APBVT.\n"); 3147 nes_debug(NES_DBG_QP, "Waiting for CQP completion for APBVT.\n");
3177 3148
3178 atomic_set(&cqp_request->refcount, 2); 3149 atomic_set(&cqp_request->refcount, 2);
3179 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3150 nes_post_cqp_request(nesdev, cqp_request);
3180 3151
3181 if (add_port == NES_MANAGE_APBVT_ADD) 3152 if (add_port == NES_MANAGE_APBVT_ADD)
3182 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 3153 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -3184,15 +3155,9 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3184 nes_debug(NES_DBG_QP, "Completed, ret=%u, CQP Major:Minor codes = 0x%04X:0x%04X\n", 3155 nes_debug(NES_DBG_QP, "Completed, ret=%u, CQP Major:Minor codes = 0x%04X:0x%04X\n",
3185 ret, cqp_request->major_code, cqp_request->minor_code); 3156 ret, cqp_request->major_code, cqp_request->minor_code);
3186 major_code = cqp_request->major_code; 3157 major_code = cqp_request->major_code;
3187 if (atomic_dec_and_test(&cqp_request->refcount)) { 3158
3188 if (cqp_request->dynamic) { 3159 nes_put_cqp_request(nesdev, cqp_request);
3189 kfree(cqp_request); 3160
3190 } else {
3191 spin_lock_irqsave(&nesdev->cqp.lock, flags);
3192 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
3193 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
3194 }
3195 }
3196 if (!ret) 3161 if (!ret)
3197 return -ETIME; 3162 return -ETIME;
3198 else if (major_code) 3163 else if (major_code)
@@ -3252,7 +3217,7 @@ void nes_manage_arp_cache(struct net_device *netdev, unsigned char *mac_addr,
3252 nesdev->cqp.sq_head, nesdev->cqp.sq_tail); 3217 nesdev->cqp.sq_head, nesdev->cqp.sq_tail);
3253 3218
3254 atomic_set(&cqp_request->refcount, 1); 3219 atomic_set(&cqp_request->refcount, 1);
3255 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3220 nes_post_cqp_request(nesdev, cqp_request);
3256} 3221}
3257 3222
3258 3223
@@ -3262,7 +3227,6 @@ void nes_manage_arp_cache(struct net_device *netdev, unsigned char *mac_addr,
3262void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp, 3227void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3263 u32 which_wq, u32 wait_completion) 3228 u32 which_wq, u32 wait_completion)
3264{ 3229{
3265 unsigned long flags;
3266 struct nes_cqp_request *cqp_request; 3230 struct nes_cqp_request *cqp_request;
3267 struct nes_hw_cqp_wqe *cqp_wqe; 3231 struct nes_hw_cqp_wqe *cqp_wqe;
3268 int ret; 3232 int ret;
@@ -3285,7 +3249,7 @@ void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3285 cpu_to_le32(NES_CQP_FLUSH_WQES | which_wq); 3249 cpu_to_le32(NES_CQP_FLUSH_WQES | which_wq);
3286 cqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX] = cpu_to_le32(nesqp->hwqp.qp_id); 3250 cqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX] = cpu_to_le32(nesqp->hwqp.qp_id);
3287 3251
3288 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3252 nes_post_cqp_request(nesdev, cqp_request);
3289 3253
3290 if (wait_completion) { 3254 if (wait_completion) {
3291 /* Wait for CQP */ 3255 /* Wait for CQP */
@@ -3294,14 +3258,6 @@ void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3294 nes_debug(NES_DBG_QP, "Flush SQ QP WQEs completed, ret=%u," 3258 nes_debug(NES_DBG_QP, "Flush SQ QP WQEs completed, ret=%u,"
3295 " CQP Major:Minor codes = 0x%04X:0x%04X\n", 3259 " CQP Major:Minor codes = 0x%04X:0x%04X\n",
3296 ret, cqp_request->major_code, cqp_request->minor_code); 3260 ret, cqp_request->major_code, cqp_request->minor_code);
3297 if (atomic_dec_and_test(&cqp_request->refcount)) { 3261 nes_put_cqp_request(nesdev, cqp_request);
3298 if (cqp_request->dynamic) {
3299 kfree(cqp_request);
3300 } else {
3301 spin_lock_irqsave(&nesdev->cqp.lock, flags);
3302 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
3303 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
3304 }
3305 }
3306 } 3262 }
3307} 3263}
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 745bf94f3f0..7b81e0ae007 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -1172,7 +1172,7 @@ struct nes_vnic {
1172 u32 mcrq_qp_id; 1172 u32 mcrq_qp_id;
1173 struct nes_ucontext *mcrq_ucontext; 1173 struct nes_ucontext *mcrq_ucontext;
1174 struct nes_cqp_request* (*get_cqp_request)(struct nes_device *nesdev); 1174 struct nes_cqp_request* (*get_cqp_request)(struct nes_device *nesdev);
1175 void (*post_cqp_request)(struct nes_device*, struct nes_cqp_request *, int); 1175 void (*post_cqp_request)(struct nes_device*, struct nes_cqp_request *);
1176 int (*mcrq_mcast_filter)( struct nes_vnic* nesvnic, __u8* dmi_addr ); 1176 int (*mcrq_mcast_filter)( struct nes_vnic* nesvnic, __u8* dmi_addr );
1177 struct net_device_stats netstats; 1177 struct net_device_stats netstats;
1178 /* used to put the netdev on the adapters logical port list */ 1178 /* used to put the netdev on the adapters logical port list */
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index fe83d1b2b17..fb8cbd71a2e 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -567,12 +567,36 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev)
567 return cqp_request; 567 return cqp_request;
568} 568}
569 569
570void nes_free_cqp_request(struct nes_device *nesdev,
571 struct nes_cqp_request *cqp_request)
572{
573 unsigned long flags;
574
575 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n",
576 cqp_request,
577 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f);
578
579 if (cqp_request->dynamic) {
580 kfree(cqp_request);
581 } else {
582 spin_lock_irqsave(&nesdev->cqp.lock, flags);
583 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
584 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
585 }
586}
587
588void nes_put_cqp_request(struct nes_device *nesdev,
589 struct nes_cqp_request *cqp_request)
590{
591 if (atomic_dec_and_test(&cqp_request->refcount))
592 nes_free_cqp_request(nesdev, cqp_request);
593}
570 594
571/** 595/**
572 * nes_post_cqp_request 596 * nes_post_cqp_request
573 */ 597 */
574void nes_post_cqp_request(struct nes_device *nesdev, 598void nes_post_cqp_request(struct nes_device *nesdev,
575 struct nes_cqp_request *cqp_request, int ring_doorbell) 599 struct nes_cqp_request *cqp_request)
576{ 600{
577 struct nes_hw_cqp_wqe *cqp_wqe; 601 struct nes_hw_cqp_wqe *cqp_wqe;
578 unsigned long flags; 602 unsigned long flags;
@@ -600,10 +624,9 @@ void nes_post_cqp_request(struct nes_device *nesdev,
600 nesdev->cqp.sq_head, nesdev->cqp.sq_tail, nesdev->cqp.sq_size, 624 nesdev->cqp.sq_head, nesdev->cqp.sq_tail, nesdev->cqp.sq_size,
601 cqp_request->waiting, atomic_read(&cqp_request->refcount)); 625 cqp_request->waiting, atomic_read(&cqp_request->refcount));
602 barrier(); 626 barrier();
603 if (ring_doorbell) { 627
604 /* Ring doorbell (1 WQEs) */ 628 /* Ring doorbell (1 WQEs) */
605 nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x01800000 | nesdev->cqp.qp_id); 629 nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x01800000 | nesdev->cqp.qp_id);
606 }
607 630
608 barrier(); 631 barrier();
609 } else { 632 } else {
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index d617da9bd35..e3939d13484 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -55,7 +55,6 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
55 * nes_alloc_mw 55 * nes_alloc_mw
56 */ 56 */
57static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) { 57static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
58 unsigned long flags;
59 struct nes_pd *nespd = to_nespd(ibpd); 58 struct nes_pd *nespd = to_nespd(ibpd);
60 struct nes_vnic *nesvnic = to_nesvnic(ibpd->device); 59 struct nes_vnic *nesvnic = to_nesvnic(ibpd->device);
61 struct nes_device *nesdev = nesvnic->nesdev; 60 struct nes_device *nesdev = nesvnic->nesdev;
@@ -119,7 +118,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
119 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag); 118 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag);
120 119
121 atomic_set(&cqp_request->refcount, 2); 120 atomic_set(&cqp_request->refcount, 2);
122 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 121 nes_post_cqp_request(nesdev, cqp_request);
123 122
124 /* Wait for CQP */ 123 /* Wait for CQP */
125 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 124 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -128,15 +127,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
128 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 127 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
129 stag, ret, cqp_request->major_code, cqp_request->minor_code); 128 stag, ret, cqp_request->major_code, cqp_request->minor_code);
130 if ((!ret) || (cqp_request->major_code)) { 129 if ((!ret) || (cqp_request->major_code)) {
131 if (atomic_dec_and_test(&cqp_request->refcount)) { 130 nes_put_cqp_request(nesdev, cqp_request);
132 if (cqp_request->dynamic) {
133 kfree(cqp_request);
134 } else {
135 spin_lock_irqsave(&nesdev->cqp.lock, flags);
136 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
137 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
138 }
139 }
140 kfree(nesmr); 131 kfree(nesmr);
141 nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index); 132 nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index);
142 if (!ret) { 133 if (!ret) {
@@ -144,17 +135,8 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
144 } else { 135 } else {
145 return ERR_PTR(-ENOMEM); 136 return ERR_PTR(-ENOMEM);
146 } 137 }
147 } else {
148 if (atomic_dec_and_test(&cqp_request->refcount)) {
149 if (cqp_request->dynamic) {
150 kfree(cqp_request);
151 } else {
152 spin_lock_irqsave(&nesdev->cqp.lock, flags);
153 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
154 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
155 }
156 }
157 } 138 }
139 nes_put_cqp_request(nesdev, cqp_request);
158 140
159 nesmr->ibmw.rkey = stag; 141 nesmr->ibmw.rkey = stag;
160 nesmr->mode = IWNES_MEMREG_TYPE_MW; 142 nesmr->mode = IWNES_MEMREG_TYPE_MW;
@@ -178,7 +160,6 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
178 struct nes_hw_cqp_wqe *cqp_wqe; 160 struct nes_hw_cqp_wqe *cqp_wqe;
179 struct nes_cqp_request *cqp_request; 161 struct nes_cqp_request *cqp_request;
180 int err = 0; 162 int err = 0;
181 unsigned long flags;
182 int ret; 163 int ret;
183 164
184 /* Deallocate the window with the adapter */ 165 /* Deallocate the window with the adapter */
@@ -194,7 +175,7 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
194 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ibmw->rkey); 175 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ibmw->rkey);
195 176
196 atomic_set(&cqp_request->refcount, 2); 177 atomic_set(&cqp_request->refcount, 2);
197 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 178 nes_post_cqp_request(nesdev, cqp_request);
198 179
199 /* Wait for CQP */ 180 /* Wait for CQP */
200 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X to complete.\n", 181 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X to complete.\n",
@@ -204,32 +185,12 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
204 nes_debug(NES_DBG_MR, "Deallocate STag completed, wait_event_timeout ret = %u," 185 nes_debug(NES_DBG_MR, "Deallocate STag completed, wait_event_timeout ret = %u,"
205 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 186 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
206 ret, cqp_request->major_code, cqp_request->minor_code); 187 ret, cqp_request->major_code, cqp_request->minor_code);
207 if ((!ret) || (cqp_request->major_code)) { 188 if (!ret)
208 if (atomic_dec_and_test(&cqp_request->refcount)) { 189 err = -ETIME;
209 if (cqp_request->dynamic) { 190 else if (cqp_request->major_code)
210 kfree(cqp_request); 191 err = -EIO;
211 } else { 192
212 spin_lock_irqsave(&nesdev->cqp.lock, flags); 193 nes_put_cqp_request(nesdev, cqp_request);
213 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
214 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
215 }
216 }
217 if (!ret) {
218 err = -ETIME;
219 } else {
220 err = -EIO;
221 }
222 } else {
223 if (atomic_dec_and_test(&cqp_request->refcount)) {
224 if (cqp_request->dynamic) {
225 kfree(cqp_request);
226 } else {
227 spin_lock_irqsave(&nesdev->cqp.lock, flags);
228 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
229 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
230 }
231 }
232 }
233 194
234 nes_free_resource(nesadapter, nesadapter->allocated_mrs, 195 nes_free_resource(nesadapter, nesadapter->allocated_mrs,
235 (ibmw->rkey & 0x0fffff00) >> 8); 196 (ibmw->rkey & 0x0fffff00) >> 8);
@@ -516,7 +477,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd,
516 (nesfmr->nesmr.pbls_used-1) : nesfmr->nesmr.pbls_used); 477 (nesfmr->nesmr.pbls_used-1) : nesfmr->nesmr.pbls_used);
517 478
518 atomic_set(&cqp_request->refcount, 2); 479 atomic_set(&cqp_request->refcount, 2);
519 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 480 nes_post_cqp_request(nesdev, cqp_request);
520 481
521 /* Wait for CQP */ 482 /* Wait for CQP */
522 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 483 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -526,29 +487,11 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd,
526 stag, ret, cqp_request->major_code, cqp_request->minor_code); 487 stag, ret, cqp_request->major_code, cqp_request->minor_code);
527 488
528 if ((!ret) || (cqp_request->major_code)) { 489 if ((!ret) || (cqp_request->major_code)) {
529 if (atomic_dec_and_test(&cqp_request->refcount)) { 490 nes_put_cqp_request(nesdev, cqp_request);
530 if (cqp_request->dynamic) {
531 kfree(cqp_request);
532 } else {
533 spin_lock_irqsave(&nesdev->cqp.lock, flags);
534 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
535 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
536 }
537 }
538 ret = (!ret) ? -ETIME : -EIO; 491 ret = (!ret) ? -ETIME : -EIO;
539 goto failed_leaf_vpbl_pages_alloc; 492 goto failed_leaf_vpbl_pages_alloc;
540 } else {
541 if (atomic_dec_and_test(&cqp_request->refcount)) {
542 if (cqp_request->dynamic) {
543 kfree(cqp_request);
544 } else {
545 spin_lock_irqsave(&nesdev->cqp.lock, flags);
546 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
547 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
548 }
549 }
550 } 493 }
551 494 nes_put_cqp_request(nesdev, cqp_request);
552 nesfmr->nesmr.ibfmr.lkey = stag; 495 nesfmr->nesmr.ibfmr.lkey = stag;
553 nesfmr->nesmr.ibfmr.rkey = stag; 496 nesfmr->nesmr.ibfmr.rkey = stag;
554 nesfmr->attr = *ibfmr_attr; 497 nesfmr->attr = *ibfmr_attr;
@@ -1474,7 +1417,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1474 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp); 1417 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp);
1475 1418
1476 atomic_set(&cqp_request->refcount, 2); 1419 atomic_set(&cqp_request->refcount, 2);
1477 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1420 nes_post_cqp_request(nesdev, cqp_request);
1478 1421
1479 /* Wait for CQP */ 1422 /* Wait for CQP */
1480 nes_debug(NES_DBG_QP, "Waiting for create iWARP QP%u to complete.\n", 1423 nes_debug(NES_DBG_QP, "Waiting for create iWARP QP%u to complete.\n",
@@ -1487,15 +1430,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1487 nesqp->hwqp.qp_id, ret, nesdev->cqp.sq_head, nesdev->cqp.sq_tail, 1430 nesqp->hwqp.qp_id, ret, nesdev->cqp.sq_head, nesdev->cqp.sq_tail,
1488 cqp_request->major_code, cqp_request->minor_code); 1431 cqp_request->major_code, cqp_request->minor_code);
1489 if ((!ret) || (cqp_request->major_code)) { 1432 if ((!ret) || (cqp_request->major_code)) {
1490 if (atomic_dec_and_test(&cqp_request->refcount)) { 1433 nes_put_cqp_request(nesdev, cqp_request);
1491 if (cqp_request->dynamic) {
1492 kfree(cqp_request);
1493 } else {
1494 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1495 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1496 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1497 }
1498 }
1499 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); 1434 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1500 nes_free_qp_mem(nesdev, nesqp,virt_wqs); 1435 nes_free_qp_mem(nesdev, nesqp,virt_wqs);
1501 kfree(nesqp->allocated_buffer); 1436 kfree(nesqp->allocated_buffer);
@@ -1504,18 +1439,10 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1504 } else { 1439 } else {
1505 return ERR_PTR(-EIO); 1440 return ERR_PTR(-EIO);
1506 } 1441 }
1507 } else {
1508 if (atomic_dec_and_test(&cqp_request->refcount)) {
1509 if (cqp_request->dynamic) {
1510 kfree(cqp_request);
1511 } else {
1512 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1513 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1514 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1515 }
1516 }
1517 } 1442 }
1518 1443
1444 nes_put_cqp_request(nesdev, cqp_request);
1445
1519 if (ibpd->uobject) { 1446 if (ibpd->uobject) {
1520 uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; 1447 uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index;
1521 uresp.actual_sq_size = sq_size; 1448 uresp.actual_sq_size = sq_size;
@@ -1817,7 +1744,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1817 cpu_to_le32(((u32)((u64temp) >> 33)) & 0x7FFFFFFF); 1744 cpu_to_le32(((u32)((u64temp) >> 33)) & 0x7FFFFFFF);
1818 1745
1819 atomic_set(&cqp_request->refcount, 2); 1746 atomic_set(&cqp_request->refcount, 2);
1820 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1747 nes_post_cqp_request(nesdev, cqp_request);
1821 1748
1822 /* Wait for CQP */ 1749 /* Wait for CQP */
1823 nes_debug(NES_DBG_CQ, "Waiting for create iWARP CQ%u to complete.\n", 1750 nes_debug(NES_DBG_CQ, "Waiting for create iWARP CQ%u to complete.\n",
@@ -1827,32 +1754,15 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1827 nes_debug(NES_DBG_CQ, "Create iWARP CQ%u completed, wait_event_timeout ret = %d.\n", 1754 nes_debug(NES_DBG_CQ, "Create iWARP CQ%u completed, wait_event_timeout ret = %d.\n",
1828 nescq->hw_cq.cq_number, ret); 1755 nescq->hw_cq.cq_number, ret);
1829 if ((!ret) || (cqp_request->major_code)) { 1756 if ((!ret) || (cqp_request->major_code)) {
1830 if (atomic_dec_and_test(&cqp_request->refcount)) { 1757 nes_put_cqp_request(nesdev, cqp_request);
1831 if (cqp_request->dynamic) {
1832 kfree(cqp_request);
1833 } else {
1834 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1835 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1836 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1837 }
1838 }
1839 if (!context) 1758 if (!context)
1840 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, 1759 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem,
1841 nescq->hw_cq.cq_pbase); 1760 nescq->hw_cq.cq_pbase);
1842 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); 1761 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
1843 kfree(nescq); 1762 kfree(nescq);
1844 return ERR_PTR(-EIO); 1763 return ERR_PTR(-EIO);
1845 } else {
1846 if (atomic_dec_and_test(&cqp_request->refcount)) {
1847 if (cqp_request->dynamic) {
1848 kfree(cqp_request);
1849 } else {
1850 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1851 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1852 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1853 }
1854 }
1855 } 1764 }
1765 nes_put_cqp_request(nesdev, cqp_request);
1856 1766
1857 if (context) { 1767 if (context) {
1858 /* free the nespbl */ 1768 /* free the nespbl */
@@ -1931,7 +1841,7 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
1931 (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16))); 1841 (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16)));
1932 nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number); 1842 nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number);
1933 atomic_set(&cqp_request->refcount, 2); 1843 atomic_set(&cqp_request->refcount, 2);
1934 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1844 nes_post_cqp_request(nesdev, cqp_request);
1935 1845
1936 /* Wait for CQP */ 1846 /* Wait for CQP */
1937 nes_debug(NES_DBG_CQ, "Waiting for destroy iWARP CQ%u to complete.\n", 1847 nes_debug(NES_DBG_CQ, "Waiting for destroy iWARP CQ%u to complete.\n",
@@ -1942,37 +1852,18 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
1942 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 1852 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
1943 nescq->hw_cq.cq_number, ret, cqp_request->major_code, 1853 nescq->hw_cq.cq_number, ret, cqp_request->major_code,
1944 cqp_request->minor_code); 1854 cqp_request->minor_code);
1945 if ((!ret) || (cqp_request->major_code)) { 1855 if (!ret) {
1946 if (atomic_dec_and_test(&cqp_request->refcount)) { 1856 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy timeout expired\n",
1947 if (cqp_request->dynamic) {
1948 kfree(cqp_request);
1949 } else {
1950 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1951 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1952 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1953 }
1954 }
1955 if (!ret) {
1956 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy timeout expired\n",
1957 nescq->hw_cq.cq_number); 1857 nescq->hw_cq.cq_number);
1958 ret = -ETIME; 1858 ret = -ETIME;
1959 } else { 1859 } else if (cqp_request->major_code) {
1960 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy failed\n", 1860 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy failed\n",
1961 nescq->hw_cq.cq_number); 1861 nescq->hw_cq.cq_number);
1962 ret = -EIO; 1862 ret = -EIO;
1963 }
1964 } else { 1863 } else {
1965 ret = 0; 1864 ret = 0;
1966 if (atomic_dec_and_test(&cqp_request->refcount)) {
1967 if (cqp_request->dynamic) {
1968 kfree(cqp_request);
1969 } else {
1970 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1971 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1972 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1973 }
1974 }
1975 } 1865 }
1866 nes_put_cqp_request(nesdev, cqp_request);
1976 1867
1977 if (nescq->cq_mem_size) 1868 if (nescq->cq_mem_size)
1978 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, 1869 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size,
@@ -2096,7 +1987,7 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
2096 barrier(); 1987 barrier();
2097 1988
2098 atomic_set(&cqp_request->refcount, 2); 1989 atomic_set(&cqp_request->refcount, 2);
2099 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1990 nes_post_cqp_request(nesdev, cqp_request);
2100 1991
2101 /* Wait for CQP */ 1992 /* Wait for CQP */
2102 ret = wait_event_timeout(cqp_request->waitq, (0 != cqp_request->request_done), 1993 ret = wait_event_timeout(cqp_request->waitq, (0 != cqp_request->request_done),
@@ -2105,15 +1996,8 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
2105 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 1996 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
2106 stag, ret, cqp_request->major_code, cqp_request->minor_code); 1997 stag, ret, cqp_request->major_code, cqp_request->minor_code);
2107 major_code = cqp_request->major_code; 1998 major_code = cqp_request->major_code;
2108 if (atomic_dec_and_test(&cqp_request->refcount)) { 1999 nes_put_cqp_request(nesdev, cqp_request);
2109 if (cqp_request->dynamic) { 2000
2110 kfree(cqp_request);
2111 } else {
2112 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2113 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2114 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2115 }
2116 }
2117 if (!ret) 2001 if (!ret)
2118 return -ETIME; 2002 return -ETIME;
2119 else if (major_code) 2003 else if (major_code)
@@ -2754,7 +2638,7 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2754 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ib_mr->rkey); 2638 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ib_mr->rkey);
2755 2639
2756 atomic_set(&cqp_request->refcount, 2); 2640 atomic_set(&cqp_request->refcount, 2);
2757 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 2641 nes_post_cqp_request(nesdev, cqp_request);
2758 2642
2759 /* Wait for CQP */ 2643 /* Wait for CQP */
2760 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X completed\n", ib_mr->rkey); 2644 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X completed\n", ib_mr->rkey);
@@ -2771,15 +2655,9 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2771 2655
2772 major_code = cqp_request->major_code; 2656 major_code = cqp_request->major_code;
2773 minor_code = cqp_request->minor_code; 2657 minor_code = cqp_request->minor_code;
2774 if (atomic_dec_and_test(&cqp_request->refcount)) { 2658
2775 if (cqp_request->dynamic) { 2659 nes_put_cqp_request(nesdev, cqp_request);
2776 kfree(cqp_request); 2660
2777 } else {
2778 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2779 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2780 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2781 }
2782 }
2783 if (!ret) { 2661 if (!ret) {
2784 nes_debug(NES_DBG_MR, "Timeout waiting to destroy STag," 2662 nes_debug(NES_DBG_MR, "Timeout waiting to destroy STag,"
2785 " ib_mr=%p, rkey = 0x%08X\n", 2663 " ib_mr=%p, rkey = 0x%08X\n",
@@ -2904,7 +2782,6 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2904 /* struct iw_cm_id *cm_id = nesqp->cm_id; */ 2782 /* struct iw_cm_id *cm_id = nesqp->cm_id; */
2905 /* struct iw_cm_event cm_event; */ 2783 /* struct iw_cm_event cm_event; */
2906 struct nes_cqp_request *cqp_request; 2784 struct nes_cqp_request *cqp_request;
2907 unsigned long flags;
2908 int ret; 2785 int ret;
2909 u16 major_code; 2786 u16 major_code;
2910 2787
@@ -2932,7 +2809,7 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2932 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, (u64)nesqp->nesqp_context_pbase); 2809 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, (u64)nesqp->nesqp_context_pbase);
2933 2810
2934 atomic_set(&cqp_request->refcount, 2); 2811 atomic_set(&cqp_request->refcount, 2);
2935 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 2812 nes_post_cqp_request(nesdev, cqp_request);
2936 2813
2937 /* Wait for CQP */ 2814 /* Wait for CQP */
2938 if (wait_completion) { 2815 if (wait_completion) {
@@ -2950,15 +2827,9 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2950 nesqp->hwqp.qp_id, cqp_request->major_code, 2827 nesqp->hwqp.qp_id, cqp_request->major_code,
2951 cqp_request->minor_code, next_iwarp_state); 2828 cqp_request->minor_code, next_iwarp_state);
2952 } 2829 }
2953 if (atomic_dec_and_test(&cqp_request->refcount)) { 2830
2954 if (cqp_request->dynamic) { 2831 nes_put_cqp_request(nesdev, cqp_request);
2955 kfree(cqp_request); 2832
2956 } else {
2957 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2958 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2959 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2960 }
2961 }
2962 if (!ret) 2833 if (!ret)
2963 return -ETIME; 2834 return -ETIME;
2964 else if (major_code) 2835 else if (major_code)
diff --git a/drivers/infiniband/ulp/ipoib/Kconfig b/drivers/infiniband/ulp/ipoib/Kconfig
index 1f76bad020f..691525cf394 100644
--- a/drivers/infiniband/ulp/ipoib/Kconfig
+++ b/drivers/infiniband/ulp/ipoib/Kconfig
@@ -1,6 +1,7 @@
1config INFINIBAND_IPOIB 1config INFINIBAND_IPOIB
2 tristate "IP-over-InfiniBand" 2 tristate "IP-over-InfiniBand"
3 depends on NETDEVICES && INET && (IPV6 || IPV6=n) 3 depends on NETDEVICES && INET && (IPV6 || IPV6=n)
4 select INET_LRO
4 ---help--- 5 ---help---
5 Support for the IP-over-InfiniBand protocol (IPoIB). This 6 Support for the IP-over-InfiniBand protocol (IPoIB). This
6 transports IP packets over InfiniBand so you can use your IB 7 transports IP packets over InfiniBand so you can use your IB
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index ca126fc2b85..b0ffc9abe8c 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib.h 1358 2004-12-17 22:00:11Z roland $
35 */ 33 */
36 34
37#ifndef _IPOIB_H 35#ifndef _IPOIB_H
@@ -52,9 +50,16 @@
52#include <rdma/ib_verbs.h> 50#include <rdma/ib_verbs.h>
53#include <rdma/ib_pack.h> 51#include <rdma/ib_pack.h>
54#include <rdma/ib_sa.h> 52#include <rdma/ib_sa.h>
53#include <linux/inet_lro.h>
55 54
56/* constants */ 55/* constants */
57 56
57enum ipoib_flush_level {
58 IPOIB_FLUSH_LIGHT,
59 IPOIB_FLUSH_NORMAL,
60 IPOIB_FLUSH_HEAVY
61};
62
58enum { 63enum {
59 IPOIB_ENCAP_LEN = 4, 64 IPOIB_ENCAP_LEN = 4,
60 65
@@ -65,8 +70,8 @@ enum {
65 IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN, 70 IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN,
66 IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE, 71 IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE,
67 IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE, 72 IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE,
68 IPOIB_RX_RING_SIZE = 128, 73 IPOIB_RX_RING_SIZE = 256,
69 IPOIB_TX_RING_SIZE = 64, 74 IPOIB_TX_RING_SIZE = 128,
70 IPOIB_MAX_QUEUE_SIZE = 8192, 75 IPOIB_MAX_QUEUE_SIZE = 8192,
71 IPOIB_MIN_QUEUE_SIZE = 2, 76 IPOIB_MIN_QUEUE_SIZE = 2,
72 IPOIB_CM_MAX_CONN_QP = 4096, 77 IPOIB_CM_MAX_CONN_QP = 4096,
@@ -84,7 +89,6 @@ enum {
84 IPOIB_FLAG_SUBINTERFACE = 5, 89 IPOIB_FLAG_SUBINTERFACE = 5,
85 IPOIB_MCAST_RUN = 6, 90 IPOIB_MCAST_RUN = 6,
86 IPOIB_STOP_REAPER = 7, 91 IPOIB_STOP_REAPER = 7,
87 IPOIB_MCAST_STARTED = 8,
88 IPOIB_FLAG_ADMIN_CM = 9, 92 IPOIB_FLAG_ADMIN_CM = 9,
89 IPOIB_FLAG_UMCAST = 10, 93 IPOIB_FLAG_UMCAST = 10,
90 IPOIB_FLAG_CSUM = 11, 94 IPOIB_FLAG_CSUM = 11,
@@ -96,7 +100,11 @@ enum {
96 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */ 100 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
97 IPOIB_MCAST_FLAG_ATTACHED = 3, 101 IPOIB_MCAST_FLAG_ATTACHED = 3,
98 102
103 IPOIB_MAX_LRO_DESCRIPTORS = 8,
104 IPOIB_LRO_MAX_AGGR = 64,
105
99 MAX_SEND_CQE = 16, 106 MAX_SEND_CQE = 16,
107 IPOIB_CM_COPYBREAK = 256,
100}; 108};
101 109
102#define IPOIB_OP_RECV (1ul << 31) 110#define IPOIB_OP_RECV (1ul << 31)
@@ -149,6 +157,11 @@ struct ipoib_tx_buf {
149 u64 mapping[MAX_SKB_FRAGS + 1]; 157 u64 mapping[MAX_SKB_FRAGS + 1];
150}; 158};
151 159
160struct ipoib_cm_tx_buf {
161 struct sk_buff *skb;
162 u64 mapping;
163};
164
152struct ib_cm_id; 165struct ib_cm_id;
153 166
154struct ipoib_cm_data { 167struct ipoib_cm_data {
@@ -207,7 +220,7 @@ struct ipoib_cm_tx {
207 struct net_device *dev; 220 struct net_device *dev;
208 struct ipoib_neigh *neigh; 221 struct ipoib_neigh *neigh;
209 struct ipoib_path *path; 222 struct ipoib_path *path;
210 struct ipoib_tx_buf *tx_ring; 223 struct ipoib_cm_tx_buf *tx_ring;
211 unsigned tx_head; 224 unsigned tx_head;
212 unsigned tx_tail; 225 unsigned tx_tail;
213 unsigned long flags; 226 unsigned long flags;
@@ -249,6 +262,11 @@ struct ipoib_ethtool_st {
249 u16 max_coalesced_frames; 262 u16 max_coalesced_frames;
250}; 263};
251 264
265struct ipoib_lro {
266 struct net_lro_mgr lro_mgr;
267 struct net_lro_desc lro_desc[IPOIB_MAX_LRO_DESCRIPTORS];
268};
269
252/* 270/*
253 * Device private locking: tx_lock protects members used in TX fast 271 * Device private locking: tx_lock protects members used in TX fast
254 * path (and we use LLTX so upper layers don't do extra locking). 272 * path (and we use LLTX so upper layers don't do extra locking).
@@ -264,7 +282,6 @@ struct ipoib_dev_priv {
264 282
265 unsigned long flags; 283 unsigned long flags;
266 284
267 struct mutex mcast_mutex;
268 struct mutex vlan_mutex; 285 struct mutex vlan_mutex;
269 286
270 struct rb_root path_tree; 287 struct rb_root path_tree;
@@ -276,10 +293,11 @@ struct ipoib_dev_priv {
276 293
277 struct delayed_work pkey_poll_task; 294 struct delayed_work pkey_poll_task;
278 struct delayed_work mcast_task; 295 struct delayed_work mcast_task;
279 struct work_struct flush_task; 296 struct work_struct flush_light;
297 struct work_struct flush_normal;
298 struct work_struct flush_heavy;
280 struct work_struct restart_task; 299 struct work_struct restart_task;
281 struct delayed_work ah_reap_task; 300 struct delayed_work ah_reap_task;
282 struct work_struct pkey_event_task;
283 301
284 struct ib_device *ca; 302 struct ib_device *ca;
285 u8 port; 303 u8 port;
@@ -335,6 +353,8 @@ struct ipoib_dev_priv {
335 int hca_caps; 353 int hca_caps;
336 struct ipoib_ethtool_st ethtool; 354 struct ipoib_ethtool_st ethtool;
337 struct timer_list poll_timer; 355 struct timer_list poll_timer;
356
357 struct ipoib_lro lro;
338}; 358};
339 359
340struct ipoib_ah { 360struct ipoib_ah {
@@ -359,6 +379,7 @@ struct ipoib_path {
359 379
360 struct rb_node rb_node; 380 struct rb_node rb_node;
361 struct list_head list; 381 struct list_head list;
382 int valid;
362}; 383};
363 384
364struct ipoib_neigh { 385struct ipoib_neigh {
@@ -423,11 +444,14 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
423 struct ipoib_ah *address, u32 qpn); 444 struct ipoib_ah *address, u32 qpn);
424void ipoib_reap_ah(struct work_struct *work); 445void ipoib_reap_ah(struct work_struct *work);
425 446
447void ipoib_mark_paths_invalid(struct net_device *dev);
426void ipoib_flush_paths(struct net_device *dev); 448void ipoib_flush_paths(struct net_device *dev);
427struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 449struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
428 450
429int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 451int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
430void ipoib_ib_dev_flush(struct work_struct *work); 452void ipoib_ib_dev_flush_light(struct work_struct *work);
453void ipoib_ib_dev_flush_normal(struct work_struct *work);
454void ipoib_ib_dev_flush_heavy(struct work_struct *work);
431void ipoib_pkey_event(struct work_struct *work); 455void ipoib_pkey_event(struct work_struct *work);
432void ipoib_ib_dev_cleanup(struct net_device *dev); 456void ipoib_ib_dev_cleanup(struct net_device *dev);
433 457
@@ -466,9 +490,7 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
466#endif 490#endif
467 491
468int ipoib_mcast_attach(struct net_device *dev, u16 mlid, 492int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
469 union ib_gid *mgid); 493 union ib_gid *mgid, int set_qkey);
470int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
471 union ib_gid *mgid);
472 494
473int ipoib_init_qp(struct net_device *dev); 495int ipoib_init_qp(struct net_device *dev);
474int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca); 496int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 97e67d36378..0f2d3045061 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <rdma/ib_cm.h> 33#include <rdma/ib_cm.h>
@@ -113,18 +111,20 @@ static int ipoib_cm_post_receive_srq(struct net_device *dev, int id)
113} 111}
114 112
115static int ipoib_cm_post_receive_nonsrq(struct net_device *dev, 113static int ipoib_cm_post_receive_nonsrq(struct net_device *dev,
116 struct ipoib_cm_rx *rx, int id) 114 struct ipoib_cm_rx *rx,
115 struct ib_recv_wr *wr,
116 struct ib_sge *sge, int id)
117{ 117{
118 struct ipoib_dev_priv *priv = netdev_priv(dev); 118 struct ipoib_dev_priv *priv = netdev_priv(dev);
119 struct ib_recv_wr *bad_wr; 119 struct ib_recv_wr *bad_wr;
120 int i, ret; 120 int i, ret;
121 121
122 priv->cm.rx_wr.wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV; 122 wr->wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
123 123
124 for (i = 0; i < IPOIB_CM_RX_SG; ++i) 124 for (i = 0; i < IPOIB_CM_RX_SG; ++i)
125 priv->cm.rx_sge[i].addr = rx->rx_ring[id].mapping[i]; 125 sge[i].addr = rx->rx_ring[id].mapping[i];
126 126
127 ret = ib_post_recv(rx->qp, &priv->cm.rx_wr, &bad_wr); 127 ret = ib_post_recv(rx->qp, wr, &bad_wr);
128 if (unlikely(ret)) { 128 if (unlikely(ret)) {
129 ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret); 129 ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret);
130 ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1, 130 ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
@@ -322,10 +322,33 @@ static int ipoib_cm_modify_rx_qp(struct net_device *dev,
322 return 0; 322 return 0;
323} 323}
324 324
325static void ipoib_cm_init_rx_wr(struct net_device *dev,
326 struct ib_recv_wr *wr,
327 struct ib_sge *sge)
328{
329 struct ipoib_dev_priv *priv = netdev_priv(dev);
330 int i;
331
332 for (i = 0; i < priv->cm.num_frags; ++i)
333 sge[i].lkey = priv->mr->lkey;
334
335 sge[0].length = IPOIB_CM_HEAD_SIZE;
336 for (i = 1; i < priv->cm.num_frags; ++i)
337 sge[i].length = PAGE_SIZE;
338
339 wr->next = NULL;
340 wr->sg_list = priv->cm.rx_sge;
341 wr->num_sge = priv->cm.num_frags;
342}
343
325static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_id, 344static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_id,
326 struct ipoib_cm_rx *rx) 345 struct ipoib_cm_rx *rx)
327{ 346{
328 struct ipoib_dev_priv *priv = netdev_priv(dev); 347 struct ipoib_dev_priv *priv = netdev_priv(dev);
348 struct {
349 struct ib_recv_wr wr;
350 struct ib_sge sge[IPOIB_CM_RX_SG];
351 } *t;
329 int ret; 352 int ret;
330 int i; 353 int i;
331 354
@@ -333,6 +356,14 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
333 if (!rx->rx_ring) 356 if (!rx->rx_ring)
334 return -ENOMEM; 357 return -ENOMEM;
335 358
359 t = kmalloc(sizeof *t, GFP_KERNEL);
360 if (!t) {
361 ret = -ENOMEM;
362 goto err_free;
363 }
364
365 ipoib_cm_init_rx_wr(dev, &t->wr, t->sge);
366
336 spin_lock_irq(&priv->lock); 367 spin_lock_irq(&priv->lock);
337 368
338 if (priv->cm.nonsrq_conn_qp >= ipoib_max_conn_qp) { 369 if (priv->cm.nonsrq_conn_qp >= ipoib_max_conn_qp) {
@@ -351,8 +382,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
351 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i); 382 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
352 ret = -ENOMEM; 383 ret = -ENOMEM;
353 goto err_count; 384 goto err_count;
354 } 385 }
355 ret = ipoib_cm_post_receive_nonsrq(dev, rx, i); 386 ret = ipoib_cm_post_receive_nonsrq(dev, rx, &t->wr, t->sge, i);
356 if (ret) { 387 if (ret) {
357 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq " 388 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq "
358 "failed for buf %d\n", i); 389 "failed for buf %d\n", i);
@@ -363,6 +394,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
363 394
364 rx->recv_count = ipoib_recvq_size; 395 rx->recv_count = ipoib_recvq_size;
365 396
397 kfree(t);
398
366 return 0; 399 return 0;
367 400
368err_count: 401err_count:
@@ -371,6 +404,7 @@ err_count:
371 spin_unlock_irq(&priv->lock); 404 spin_unlock_irq(&priv->lock);
372 405
373err_free: 406err_free:
407 kfree(t);
374 ipoib_cm_free_rx_ring(dev, rx->rx_ring); 408 ipoib_cm_free_rx_ring(dev, rx->rx_ring);
375 409
376 return ret; 410 return ret;
@@ -525,6 +559,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
525 u64 mapping[IPOIB_CM_RX_SG]; 559 u64 mapping[IPOIB_CM_RX_SG];
526 int frags; 560 int frags;
527 int has_srq; 561 int has_srq;
562 struct sk_buff *small_skb;
528 563
529 ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n", 564 ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n",
530 wr_id, wc->status); 565 wr_id, wc->status);
@@ -579,6 +614,23 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
579 } 614 }
580 } 615 }
581 616
617 if (wc->byte_len < IPOIB_CM_COPYBREAK) {
618 int dlen = wc->byte_len;
619
620 small_skb = dev_alloc_skb(dlen + 12);
621 if (small_skb) {
622 skb_reserve(small_skb, 12);
623 ib_dma_sync_single_for_cpu(priv->ca, rx_ring[wr_id].mapping[0],
624 dlen, DMA_FROM_DEVICE);
625 skb_copy_from_linear_data(skb, small_skb->data, dlen);
626 ib_dma_sync_single_for_device(priv->ca, rx_ring[wr_id].mapping[0],
627 dlen, DMA_FROM_DEVICE);
628 skb_put(small_skb, dlen);
629 skb = small_skb;
630 goto copied;
631 }
632 }
633
582 frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len, 634 frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len,
583 (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE; 635 (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
584 636
@@ -601,6 +653,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
601 653
602 skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len, newskb); 654 skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len, newskb);
603 655
656copied:
604 skb->protocol = ((struct ipoib_header *) skb->data)->proto; 657 skb->protocol = ((struct ipoib_header *) skb->data)->proto;
605 skb_reset_mac_header(skb); 658 skb_reset_mac_header(skb);
606 skb_pull(skb, IPOIB_ENCAP_LEN); 659 skb_pull(skb, IPOIB_ENCAP_LEN);
@@ -620,7 +673,10 @@ repost:
620 ipoib_warn(priv, "ipoib_cm_post_receive_srq failed " 673 ipoib_warn(priv, "ipoib_cm_post_receive_srq failed "
621 "for buf %d\n", wr_id); 674 "for buf %d\n", wr_id);
622 } else { 675 } else {
623 if (unlikely(ipoib_cm_post_receive_nonsrq(dev, p, wr_id))) { 676 if (unlikely(ipoib_cm_post_receive_nonsrq(dev, p,
677 &priv->cm.rx_wr,
678 priv->cm.rx_sge,
679 wr_id))) {
624 --p->recv_count; 680 --p->recv_count;
625 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq failed " 681 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq failed "
626 "for buf %d\n", wr_id); 682 "for buf %d\n", wr_id);
@@ -647,7 +703,7 @@ static inline int post_send(struct ipoib_dev_priv *priv,
647void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) 703void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx)
648{ 704{
649 struct ipoib_dev_priv *priv = netdev_priv(dev); 705 struct ipoib_dev_priv *priv = netdev_priv(dev);
650 struct ipoib_tx_buf *tx_req; 706 struct ipoib_cm_tx_buf *tx_req;
651 u64 addr; 707 u64 addr;
652 708
653 if (unlikely(skb->len > tx->mtu)) { 709 if (unlikely(skb->len > tx->mtu)) {
@@ -678,7 +734,7 @@ void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_
678 return; 734 return;
679 } 735 }
680 736
681 tx_req->mapping[0] = addr; 737 tx_req->mapping = addr;
682 738
683 if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1), 739 if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1),
684 addr, skb->len))) { 740 addr, skb->len))) {
@@ -703,7 +759,7 @@ void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
703 struct ipoib_dev_priv *priv = netdev_priv(dev); 759 struct ipoib_dev_priv *priv = netdev_priv(dev);
704 struct ipoib_cm_tx *tx = wc->qp->qp_context; 760 struct ipoib_cm_tx *tx = wc->qp->qp_context;
705 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_CM; 761 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_CM;
706 struct ipoib_tx_buf *tx_req; 762 struct ipoib_cm_tx_buf *tx_req;
707 unsigned long flags; 763 unsigned long flags;
708 764
709 ipoib_dbg_data(priv, "cm send completion: id %d, status: %d\n", 765 ipoib_dbg_data(priv, "cm send completion: id %d, status: %d\n",
@@ -717,7 +773,7 @@ void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
717 773
718 tx_req = &tx->tx_ring[wr_id]; 774 tx_req = &tx->tx_ring[wr_id];
719 775
720 ib_dma_unmap_single(priv->ca, tx_req->mapping[0], tx_req->skb->len, DMA_TO_DEVICE); 776 ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len, DMA_TO_DEVICE);
721 777
722 /* FIXME: is this right? Shouldn't we only increment on success? */ 778 /* FIXME: is this right? Shouldn't we only increment on success? */
723 ++dev->stats.tx_packets; 779 ++dev->stats.tx_packets;
@@ -1087,7 +1143,7 @@ err_tx:
1087static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) 1143static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p)
1088{ 1144{
1089 struct ipoib_dev_priv *priv = netdev_priv(p->dev); 1145 struct ipoib_dev_priv *priv = netdev_priv(p->dev);
1090 struct ipoib_tx_buf *tx_req; 1146 struct ipoib_cm_tx_buf *tx_req;
1091 unsigned long flags; 1147 unsigned long flags;
1092 unsigned long begin; 1148 unsigned long begin;
1093 1149
@@ -1115,7 +1171,7 @@ timeout:
1115 1171
1116 while ((int) p->tx_tail - (int) p->tx_head < 0) { 1172 while ((int) p->tx_tail - (int) p->tx_head < 0) {
1117 tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)]; 1173 tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)];
1118 ib_dma_unmap_single(priv->ca, tx_req->mapping[0], tx_req->skb->len, 1174 ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len,
1119 DMA_TO_DEVICE); 1175 DMA_TO_DEVICE);
1120 dev_kfree_skb_any(tx_req->skb); 1176 dev_kfree_skb_any(tx_req->skb);
1121 ++p->tx_tail; 1177 ++p->tx_tail;
@@ -1384,7 +1440,9 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
1384 ipoib_warn(priv, "enabling connected mode " 1440 ipoib_warn(priv, "enabling connected mode "
1385 "will cause multicast packet drops\n"); 1441 "will cause multicast packet drops\n");
1386 1442
1443 rtnl_lock();
1387 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); 1444 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO);
1445 rtnl_unlock();
1388 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM; 1446 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
1389 1447
1390 ipoib_flush_paths(dev); 1448 ipoib_flush_paths(dev);
@@ -1393,14 +1451,16 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
1393 1451
1394 if (!strcmp(buf, "datagram\n")) { 1452 if (!strcmp(buf, "datagram\n")) {
1395 clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 1453 clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
1396 dev->mtu = min(priv->mcast_mtu, dev->mtu);
1397 ipoib_flush_paths(dev);
1398 1454
1455 rtnl_lock();
1399 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) { 1456 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) {
1400 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 1457 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
1401 if (priv->hca_caps & IB_DEVICE_UD_TSO) 1458 if (priv->hca_caps & IB_DEVICE_UD_TSO)
1402 dev->features |= NETIF_F_TSO; 1459 dev->features |= NETIF_F_TSO;
1403 } 1460 }
1461 dev_set_mtu(dev, min(priv->mcast_mtu, dev->mtu));
1462 rtnl_unlock();
1463 ipoib_flush_paths(dev);
1404 1464
1405 return count; 1465 return count;
1406 } 1466 }
@@ -1485,15 +1545,7 @@ int ipoib_cm_dev_init(struct net_device *dev)
1485 priv->cm.num_frags = IPOIB_CM_RX_SG; 1545 priv->cm.num_frags = IPOIB_CM_RX_SG;
1486 } 1546 }
1487 1547
1488 for (i = 0; i < priv->cm.num_frags; ++i) 1548 ipoib_cm_init_rx_wr(dev, &priv->cm.rx_wr, priv->cm.rx_sge);
1489 priv->cm.rx_sge[i].lkey = priv->mr->lkey;
1490
1491 priv->cm.rx_sge[0].length = IPOIB_CM_HEAD_SIZE;
1492 for (i = 1; i < priv->cm.num_frags; ++i)
1493 priv->cm.rx_sge[i].length = PAGE_SIZE;
1494 priv->cm.rx_wr.next = NULL;
1495 priv->cm.rx_wr.sg_list = priv->cm.rx_sge;
1496 priv->cm.rx_wr.num_sge = priv->cm.num_frags;
1497 1549
1498 if (ipoib_cm_has_srq(dev)) { 1550 if (ipoib_cm_has_srq(dev)) {
1499 for (i = 0; i < ipoib_recvq_size; ++i) { 1551 for (i = 0; i < ipoib_recvq_size; ++i) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index 10279b79c44..66af5c1a76e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
@@ -86,11 +86,57 @@ static int ipoib_set_coalesce(struct net_device *dev,
86 return 0; 86 return 0;
87} 87}
88 88
89static const char ipoib_stats_keys[][ETH_GSTRING_LEN] = {
90 "LRO aggregated", "LRO flushed",
91 "LRO avg aggr", "LRO no desc"
92};
93
94static void ipoib_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
95{
96 switch (stringset) {
97 case ETH_SS_STATS:
98 memcpy(data, *ipoib_stats_keys, sizeof(ipoib_stats_keys));
99 break;
100 }
101}
102
103static int ipoib_get_sset_count(struct net_device *dev, int sset)
104{
105 switch (sset) {
106 case ETH_SS_STATS:
107 return ARRAY_SIZE(ipoib_stats_keys);
108 default:
109 return -EOPNOTSUPP;
110 }
111}
112
113static void ipoib_get_ethtool_stats(struct net_device *dev,
114 struct ethtool_stats *stats, uint64_t *data)
115{
116 struct ipoib_dev_priv *priv = netdev_priv(dev);
117 int index = 0;
118
119 /* Get LRO statistics */
120 data[index++] = priv->lro.lro_mgr.stats.aggregated;
121 data[index++] = priv->lro.lro_mgr.stats.flushed;
122 if (priv->lro.lro_mgr.stats.flushed)
123 data[index++] = priv->lro.lro_mgr.stats.aggregated /
124 priv->lro.lro_mgr.stats.flushed;
125 else
126 data[index++] = 0;
127 data[index++] = priv->lro.lro_mgr.stats.no_desc;
128}
129
89static const struct ethtool_ops ipoib_ethtool_ops = { 130static const struct ethtool_ops ipoib_ethtool_ops = {
90 .get_drvinfo = ipoib_get_drvinfo, 131 .get_drvinfo = ipoib_get_drvinfo,
91 .get_tso = ethtool_op_get_tso, 132 .get_tso = ethtool_op_get_tso,
92 .get_coalesce = ipoib_get_coalesce, 133 .get_coalesce = ipoib_get_coalesce,
93 .set_coalesce = ipoib_set_coalesce, 134 .set_coalesce = ipoib_set_coalesce,
135 .get_flags = ethtool_op_get_flags,
136 .set_flags = ethtool_op_set_flags,
137 .get_strings = ipoib_get_strings,
138 .get_sset_count = ipoib_get_sset_count,
139 .get_ethtool_stats = ipoib_get_ethtool_stats,
94}; 140};
95 141
96void ipoib_set_ethtool_ops(struct net_device *dev) 142void ipoib_set_ethtool_ops(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 8b882bbd1d0..961c585da21 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ipoib_fs.c 1389 2004-12-27 22:56:47Z roland $
33 */ 31 */
34 32
35#include <linux/err.h> 33#include <linux/err.h>
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index f429bce24c2..66cafa20c24 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: ipoib_ib.c 1386 2004-12-27 16:23:17Z roland $
36 */ 34 */
37 35
38#include <linux/delay.h> 36#include <linux/delay.h>
@@ -290,7 +288,10 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
290 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->csum_ok)) 288 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->csum_ok))
291 skb->ip_summed = CHECKSUM_UNNECESSARY; 289 skb->ip_summed = CHECKSUM_UNNECESSARY;
292 290
293 netif_receive_skb(skb); 291 if (dev->features & NETIF_F_LRO)
292 lro_receive_skb(&priv->lro.lro_mgr, skb, NULL);
293 else
294 netif_receive_skb(skb);
294 295
295repost: 296repost:
296 if (unlikely(ipoib_ib_post_receive(dev, wr_id))) 297 if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
@@ -442,6 +443,9 @@ poll_more:
442 } 443 }
443 444
444 if (done < budget) { 445 if (done < budget) {
446 if (dev->features & NETIF_F_LRO)
447 lro_flush_all(&priv->lro.lro_mgr);
448
445 netif_rx_complete(dev, napi); 449 netif_rx_complete(dev, napi);
446 if (unlikely(ib_req_notify_cq(priv->recv_cq, 450 if (unlikely(ib_req_notify_cq(priv->recv_cq,
447 IB_CQ_NEXT_COMP | 451 IB_CQ_NEXT_COMP |
@@ -898,7 +902,8 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
898 return 0; 902 return 0;
899} 903}
900 904
901static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event) 905static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
906 enum ipoib_flush_level level)
902{ 907{
903 struct ipoib_dev_priv *cpriv; 908 struct ipoib_dev_priv *cpriv;
904 struct net_device *dev = priv->dev; 909 struct net_device *dev = priv->dev;
@@ -911,7 +916,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
911 * the parent is down. 916 * the parent is down.
912 */ 917 */
913 list_for_each_entry(cpriv, &priv->child_intfs, list) 918 list_for_each_entry(cpriv, &priv->child_intfs, list)
914 __ipoib_ib_dev_flush(cpriv, pkey_event); 919 __ipoib_ib_dev_flush(cpriv, level);
915 920
916 mutex_unlock(&priv->vlan_mutex); 921 mutex_unlock(&priv->vlan_mutex);
917 922
@@ -925,7 +930,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
925 return; 930 return;
926 } 931 }
927 932
928 if (pkey_event) { 933 if (level == IPOIB_FLUSH_HEAVY) {
929 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { 934 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
930 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 935 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
931 ipoib_ib_dev_down(dev, 0); 936 ipoib_ib_dev_down(dev, 0);
@@ -943,11 +948,15 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
943 priv->pkey_index = new_index; 948 priv->pkey_index = new_index;
944 } 949 }
945 950
946 ipoib_dbg(priv, "flushing\n"); 951 if (level == IPOIB_FLUSH_LIGHT) {
952 ipoib_mark_paths_invalid(dev);
953 ipoib_mcast_dev_flush(dev);
954 }
947 955
948 ipoib_ib_dev_down(dev, 0); 956 if (level >= IPOIB_FLUSH_NORMAL)
957 ipoib_ib_dev_down(dev, 0);
949 958
950 if (pkey_event) { 959 if (level == IPOIB_FLUSH_HEAVY) {
951 ipoib_ib_dev_stop(dev, 0); 960 ipoib_ib_dev_stop(dev, 0);
952 ipoib_ib_dev_open(dev); 961 ipoib_ib_dev_open(dev);
953 } 962 }
@@ -957,27 +966,34 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
957 * we get here, don't bring it back up if it's not configured up 966 * we get here, don't bring it back up if it's not configured up
958 */ 967 */
959 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 968 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
960 ipoib_ib_dev_up(dev); 969 if (level >= IPOIB_FLUSH_NORMAL)
970 ipoib_ib_dev_up(dev);
961 ipoib_mcast_restart_task(&priv->restart_task); 971 ipoib_mcast_restart_task(&priv->restart_task);
962 } 972 }
963} 973}
964 974
965void ipoib_ib_dev_flush(struct work_struct *work) 975void ipoib_ib_dev_flush_light(struct work_struct *work)
976{
977 struct ipoib_dev_priv *priv =
978 container_of(work, struct ipoib_dev_priv, flush_light);
979
980 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_LIGHT);
981}
982
983void ipoib_ib_dev_flush_normal(struct work_struct *work)
966{ 984{
967 struct ipoib_dev_priv *priv = 985 struct ipoib_dev_priv *priv =
968 container_of(work, struct ipoib_dev_priv, flush_task); 986 container_of(work, struct ipoib_dev_priv, flush_normal);
969 987
970 ipoib_dbg(priv, "Flushing %s\n", priv->dev->name); 988 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_NORMAL);
971 __ipoib_ib_dev_flush(priv, 0);
972} 989}
973 990
974void ipoib_pkey_event(struct work_struct *work) 991void ipoib_ib_dev_flush_heavy(struct work_struct *work)
975{ 992{
976 struct ipoib_dev_priv *priv = 993 struct ipoib_dev_priv *priv =
977 container_of(work, struct ipoib_dev_priv, pkey_event_task); 994 container_of(work, struct ipoib_dev_priv, flush_heavy);
978 995
979 ipoib_dbg(priv, "Flushing %s and restarting its QP\n", priv->dev->name); 996 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_HEAVY);
980 __ipoib_ib_dev_flush(priv, 1);
981} 997}
982 998
983void ipoib_ib_dev_cleanup(struct net_device *dev) 999void ipoib_ib_dev_cleanup(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 2442090ac8d..8be9ea0436e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib_main.c 1377 2004-12-23 19:57:12Z roland $
35 */ 33 */
36 34
37#include "ipoib.h" 35#include "ipoib.h"
@@ -62,6 +60,15 @@ MODULE_PARM_DESC(send_queue_size, "Number of descriptors in send queue");
62module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444); 60module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444);
63MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue"); 61MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue");
64 62
63static int lro;
64module_param(lro, bool, 0444);
65MODULE_PARM_DESC(lro, "Enable LRO (Large Receive Offload)");
66
67static int lro_max_aggr = IPOIB_LRO_MAX_AGGR;
68module_param(lro_max_aggr, int, 0644);
69MODULE_PARM_DESC(lro_max_aggr, "LRO: Max packets to be aggregated "
70 "(default = 64)");
71
65#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 72#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
66int ipoib_debug_level; 73int ipoib_debug_level;
67 74
@@ -350,6 +357,23 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
350 357
351#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 358#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
352 359
360void ipoib_mark_paths_invalid(struct net_device *dev)
361{
362 struct ipoib_dev_priv *priv = netdev_priv(dev);
363 struct ipoib_path *path, *tp;
364
365 spin_lock_irq(&priv->lock);
366
367 list_for_each_entry_safe(path, tp, &priv->path_list, list) {
368 ipoib_dbg(priv, "mark path LID 0x%04x GID " IPOIB_GID_FMT " invalid\n",
369 be16_to_cpu(path->pathrec.dlid),
370 IPOIB_GID_ARG(path->pathrec.dgid));
371 path->valid = 0;
372 }
373
374 spin_unlock_irq(&priv->lock);
375}
376
353void ipoib_flush_paths(struct net_device *dev) 377void ipoib_flush_paths(struct net_device *dev)
354{ 378{
355 struct ipoib_dev_priv *priv = netdev_priv(dev); 379 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -386,6 +410,7 @@ static void path_rec_completion(int status,
386 struct net_device *dev = path->dev; 410 struct net_device *dev = path->dev;
387 struct ipoib_dev_priv *priv = netdev_priv(dev); 411 struct ipoib_dev_priv *priv = netdev_priv(dev);
388 struct ipoib_ah *ah = NULL; 412 struct ipoib_ah *ah = NULL;
413 struct ipoib_ah *old_ah;
389 struct ipoib_neigh *neigh, *tn; 414 struct ipoib_neigh *neigh, *tn;
390 struct sk_buff_head skqueue; 415 struct sk_buff_head skqueue;
391 struct sk_buff *skb; 416 struct sk_buff *skb;
@@ -409,6 +434,7 @@ static void path_rec_completion(int status,
409 434
410 spin_lock_irqsave(&priv->lock, flags); 435 spin_lock_irqsave(&priv->lock, flags);
411 436
437 old_ah = path->ah;
412 path->ah = ah; 438 path->ah = ah;
413 439
414 if (ah) { 440 if (ah) {
@@ -421,6 +447,17 @@ static void path_rec_completion(int status,
421 __skb_queue_tail(&skqueue, skb); 447 __skb_queue_tail(&skqueue, skb);
422 448
423 list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) { 449 list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) {
450 if (neigh->ah) {
451 WARN_ON(neigh->ah != old_ah);
452 /*
453 * Dropping the ah reference inside
454 * priv->lock is safe here, because we
455 * will hold one more reference from
456 * the original value of path->ah (ie
457 * old_ah).
458 */
459 ipoib_put_ah(neigh->ah);
460 }
424 kref_get(&path->ah->ref); 461 kref_get(&path->ah->ref);
425 neigh->ah = path->ah; 462 neigh->ah = path->ah;
426 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, 463 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
@@ -443,6 +480,7 @@ static void path_rec_completion(int status,
443 while ((skb = __skb_dequeue(&neigh->queue))) 480 while ((skb = __skb_dequeue(&neigh->queue)))
444 __skb_queue_tail(&skqueue, skb); 481 __skb_queue_tail(&skqueue, skb);
445 } 482 }
483 path->valid = 1;
446 } 484 }
447 485
448 path->query = NULL; 486 path->query = NULL;
@@ -450,6 +488,9 @@ static void path_rec_completion(int status,
450 488
451 spin_unlock_irqrestore(&priv->lock, flags); 489 spin_unlock_irqrestore(&priv->lock, flags);
452 490
491 if (old_ah)
492 ipoib_put_ah(old_ah);
493
453 while ((skb = __skb_dequeue(&skqueue))) { 494 while ((skb = __skb_dequeue(&skqueue))) {
454 skb->dev = dev; 495 skb->dev = dev;
455 if (dev_queue_xmit(skb)) 496 if (dev_queue_xmit(skb))
@@ -623,8 +664,9 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
623 spin_lock(&priv->lock); 664 spin_lock(&priv->lock);
624 665
625 path = __path_find(dev, phdr->hwaddr + 4); 666 path = __path_find(dev, phdr->hwaddr + 4);
626 if (!path) { 667 if (!path || !path->valid) {
627 path = path_rec_create(dev, phdr->hwaddr + 4); 668 if (!path)
669 path = path_rec_create(dev, phdr->hwaddr + 4);
628 if (path) { 670 if (path) {
629 /* put pseudoheader back on for next time */ 671 /* put pseudoheader back on for next time */
630 skb_push(skb, sizeof *phdr); 672 skb_push(skb, sizeof *phdr);
@@ -938,6 +980,54 @@ static const struct header_ops ipoib_header_ops = {
938 .create = ipoib_hard_header, 980 .create = ipoib_hard_header,
939}; 981};
940 982
983static int get_skb_hdr(struct sk_buff *skb, void **iphdr,
984 void **tcph, u64 *hdr_flags, void *priv)
985{
986 unsigned int ip_len;
987 struct iphdr *iph;
988
989 if (unlikely(skb->protocol != htons(ETH_P_IP)))
990 return -1;
991
992 /*
993 * In the future we may add an else clause that verifies the
994 * checksum and allows devices which do not calculate checksum
995 * to use LRO.
996 */
997 if (unlikely(skb->ip_summed != CHECKSUM_UNNECESSARY))
998 return -1;
999
1000 /* Check for non-TCP packet */
1001 skb_reset_network_header(skb);
1002 iph = ip_hdr(skb);
1003 if (iph->protocol != IPPROTO_TCP)
1004 return -1;
1005
1006 ip_len = ip_hdrlen(skb);
1007 skb_set_transport_header(skb, ip_len);
1008 *tcph = tcp_hdr(skb);
1009
1010 /* check if IP header and TCP header are complete */
1011 if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb))
1012 return -1;
1013
1014 *hdr_flags = LRO_IPV4 | LRO_TCP;
1015 *iphdr = iph;
1016
1017 return 0;
1018}
1019
1020static void ipoib_lro_setup(struct ipoib_dev_priv *priv)
1021{
1022 priv->lro.lro_mgr.max_aggr = lro_max_aggr;
1023 priv->lro.lro_mgr.max_desc = IPOIB_MAX_LRO_DESCRIPTORS;
1024 priv->lro.lro_mgr.lro_arr = priv->lro.lro_desc;
1025 priv->lro.lro_mgr.get_skb_header = get_skb_hdr;
1026 priv->lro.lro_mgr.features = LRO_F_NAPI;
1027 priv->lro.lro_mgr.dev = priv->dev;
1028 priv->lro.lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
1029}
1030
941static void ipoib_setup(struct net_device *dev) 1031static void ipoib_setup(struct net_device *dev)
942{ 1032{
943 struct ipoib_dev_priv *priv = netdev_priv(dev); 1033 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -977,10 +1067,11 @@ static void ipoib_setup(struct net_device *dev)
977 1067
978 priv->dev = dev; 1068 priv->dev = dev;
979 1069
1070 ipoib_lro_setup(priv);
1071
980 spin_lock_init(&priv->lock); 1072 spin_lock_init(&priv->lock);
981 spin_lock_init(&priv->tx_lock); 1073 spin_lock_init(&priv->tx_lock);
982 1074
983 mutex_init(&priv->mcast_mutex);
984 mutex_init(&priv->vlan_mutex); 1075 mutex_init(&priv->vlan_mutex);
985 1076
986 INIT_LIST_HEAD(&priv->path_list); 1077 INIT_LIST_HEAD(&priv->path_list);
@@ -989,9 +1080,10 @@ static void ipoib_setup(struct net_device *dev)
989 INIT_LIST_HEAD(&priv->multicast_list); 1080 INIT_LIST_HEAD(&priv->multicast_list);
990 1081
991 INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll); 1082 INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll);
992 INIT_WORK(&priv->pkey_event_task, ipoib_pkey_event);
993 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task); 1083 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
994 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush); 1084 INIT_WORK(&priv->flush_light, ipoib_ib_dev_flush_light);
1085 INIT_WORK(&priv->flush_normal, ipoib_ib_dev_flush_normal);
1086 INIT_WORK(&priv->flush_heavy, ipoib_ib_dev_flush_heavy);
995 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task); 1087 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
996 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah); 1088 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
997} 1089}
@@ -1154,6 +1246,9 @@ static struct net_device *ipoib_add_port(const char *format,
1154 priv->dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 1246 priv->dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
1155 } 1247 }
1156 1248
1249 if (lro)
1250 priv->dev->features |= NETIF_F_LRO;
1251
1157 /* 1252 /*
1158 * Set the full membership bit, so that we join the right 1253 * Set the full membership bit, so that we join the right
1159 * broadcast group, etc. 1254 * broadcast group, etc.
@@ -1304,6 +1399,12 @@ static int __init ipoib_init_module(void)
1304 ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP); 1399 ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP);
1305#endif 1400#endif
1306 1401
1402 /*
1403 * When copying small received packets, we only copy from the
1404 * linear data part of the SKB, so we rely on this condition.
1405 */
1406 BUILD_BUG_ON(IPOIB_CM_COPYBREAK > IPOIB_CM_HEAD_SIZE);
1407
1307 ret = ipoib_register_debugfs(); 1408 ret = ipoib_register_debugfs();
1308 if (ret) 1409 if (ret)
1309 return ret; 1410 return ret;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 3f663fb852c..1fcc9a898d8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib_multicast.c 1362 2004-12-18 15:56:29Z roland $
35 */ 33 */
36 34
37#include <linux/skbuff.h> 35#include <linux/skbuff.h>
@@ -188,6 +186,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
188 struct ipoib_dev_priv *priv = netdev_priv(dev); 186 struct ipoib_dev_priv *priv = netdev_priv(dev);
189 struct ipoib_ah *ah; 187 struct ipoib_ah *ah;
190 int ret; 188 int ret;
189 int set_qkey = 0;
191 190
192 mcast->mcmember = *mcmember; 191 mcast->mcmember = *mcmember;
193 192
@@ -202,6 +201,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
202 priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey); 201 priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
203 spin_unlock_irq(&priv->lock); 202 spin_unlock_irq(&priv->lock);
204 priv->tx_wr.wr.ud.remote_qkey = priv->qkey; 203 priv->tx_wr.wr.ud.remote_qkey = priv->qkey;
204 set_qkey = 1;
205 } 205 }
206 206
207 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { 207 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
@@ -214,7 +214,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
214 } 214 }
215 215
216 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid), 216 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid),
217 &mcast->mcmember.mgid); 217 &mcast->mcmember.mgid, set_qkey);
218 if (ret < 0) { 218 if (ret < 0) {
219 ipoib_warn(priv, "couldn't attach QP to multicast group " 219 ipoib_warn(priv, "couldn't attach QP to multicast group "
220 IPOIB_GID_FMT "\n", 220 IPOIB_GID_FMT "\n",
@@ -575,8 +575,11 @@ void ipoib_mcast_join_task(struct work_struct *work)
575 575
576 priv->mcast_mtu = IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu)); 576 priv->mcast_mtu = IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
577 577
578 if (!ipoib_cm_admin_enabled(dev)) 578 if (!ipoib_cm_admin_enabled(dev)) {
579 dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); 579 rtnl_lock();
580 dev_set_mtu(dev, min(priv->mcast_mtu, priv->admin_mtu));
581 rtnl_unlock();
582 }
580 583
581 ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n"); 584 ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n");
582 585
@@ -594,10 +597,6 @@ int ipoib_mcast_start_thread(struct net_device *dev)
594 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0); 597 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0);
595 mutex_unlock(&mcast_mutex); 598 mutex_unlock(&mcast_mutex);
596 599
597 spin_lock_irq(&priv->lock);
598 set_bit(IPOIB_MCAST_STARTED, &priv->flags);
599 spin_unlock_irq(&priv->lock);
600
601 return 0; 600 return 0;
602} 601}
603 602
@@ -607,10 +606,6 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
607 606
608 ipoib_dbg_mcast(priv, "stopping multicast thread\n"); 607 ipoib_dbg_mcast(priv, "stopping multicast thread\n");
609 608
610 spin_lock_irq(&priv->lock);
611 clear_bit(IPOIB_MCAST_STARTED, &priv->flags);
612 spin_unlock_irq(&priv->lock);
613
614 mutex_lock(&mcast_mutex); 609 mutex_lock(&mcast_mutex);
615 clear_bit(IPOIB_MCAST_RUN, &priv->flags); 610 clear_bit(IPOIB_MCAST_RUN, &priv->flags);
616 cancel_delayed_work(&priv->mcast_task); 611 cancel_delayed_work(&priv->mcast_task);
@@ -635,10 +630,10 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
635 IPOIB_GID_ARG(mcast->mcmember.mgid)); 630 IPOIB_GID_ARG(mcast->mcmember.mgid));
636 631
637 /* Remove ourselves from the multicast group */ 632 /* Remove ourselves from the multicast group */
638 ret = ipoib_mcast_detach(dev, be16_to_cpu(mcast->mcmember.mlid), 633 ret = ib_detach_mcast(priv->qp, &mcast->mcmember.mgid,
639 &mcast->mcmember.mgid); 634 be16_to_cpu(mcast->mcmember.mlid));
640 if (ret) 635 if (ret)
641 ipoib_warn(priv, "ipoib_mcast_detach failed (result = %d)\n", ret); 636 ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret);
642 } 637 }
643 638
644 return 0; 639 return 0;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 8766d29ce3b..68325119f74 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -29,24 +29,17 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include "ipoib.h" 34#include "ipoib.h"
37 35
38int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) 36int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
39{ 37{
40 struct ipoib_dev_priv *priv = netdev_priv(dev); 38 struct ipoib_dev_priv *priv = netdev_priv(dev);
41 struct ib_qp_attr *qp_attr; 39 struct ib_qp_attr *qp_attr = NULL;
42 int ret; 40 int ret;
43 u16 pkey_index; 41 u16 pkey_index;
44 42
45 ret = -ENOMEM;
46 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
47 if (!qp_attr)
48 goto out;
49
50 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) { 43 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
51 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 44 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
52 ret = -ENXIO; 45 ret = -ENXIO;
@@ -54,18 +47,23 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
54 } 47 }
55 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 48 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
56 49
57 /* set correct QKey for QP */ 50 if (set_qkey) {
58 qp_attr->qkey = priv->qkey; 51 ret = -ENOMEM;
59 ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY); 52 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
60 if (ret) { 53 if (!qp_attr)
61 ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret); 54 goto out;
62 goto out; 55
56 /* set correct QKey for QP */
57 qp_attr->qkey = priv->qkey;
58 ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY);
59 if (ret) {
60 ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret);
61 goto out;
62 }
63 } 63 }
64 64
65 /* attach QP to multicast group */ 65 /* attach QP to multicast group */
66 mutex_lock(&priv->mcast_mutex);
67 ret = ib_attach_mcast(priv->qp, mgid, mlid); 66 ret = ib_attach_mcast(priv->qp, mgid, mlid);
68 mutex_unlock(&priv->mcast_mutex);
69 if (ret) 67 if (ret)
70 ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret); 68 ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret);
71 69
@@ -74,20 +72,6 @@ out:
74 return ret; 72 return ret;
75} 73}
76 74
77int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
78{
79 struct ipoib_dev_priv *priv = netdev_priv(dev);
80 int ret;
81
82 mutex_lock(&priv->mcast_mutex);
83 ret = ib_detach_mcast(priv->qp, mgid, mlid);
84 mutex_unlock(&priv->mcast_mutex);
85 if (ret)
86 ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret);
87
88 return ret;
89}
90
91int ipoib_init_qp(struct net_device *dev) 75int ipoib_init_qp(struct net_device *dev)
92{ 76{
93 struct ipoib_dev_priv *priv = netdev_priv(dev); 77 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -201,7 +185,10 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
201 init_attr.recv_cq = priv->recv_cq; 185 init_attr.recv_cq = priv->recv_cq;
202 186
203 if (priv->hca_caps & IB_DEVICE_UD_TSO) 187 if (priv->hca_caps & IB_DEVICE_UD_TSO)
204 init_attr.create_flags = IB_QP_CREATE_IPOIB_UD_LSO; 188 init_attr.create_flags |= IB_QP_CREATE_IPOIB_UD_LSO;
189
190 if (priv->hca_caps & IB_DEVICE_BLOCK_MULTICAST_LOOPBACK)
191 init_attr.create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
205 192
206 if (dev->features & NETIF_F_SG) 193 if (dev->features & NETIF_F_SG)
207 init_attr.cap.max_send_sge = MAX_SKB_FRAGS + 1; 194 init_attr.cap.max_send_sge = MAX_SKB_FRAGS + 1;
@@ -289,15 +276,17 @@ void ipoib_event(struct ib_event_handler *handler,
289 if (record->element.port_num != priv->port) 276 if (record->element.port_num != priv->port)
290 return; 277 return;
291 278
292 if (record->event == IB_EVENT_PORT_ERR || 279 ipoib_dbg(priv, "Event %d on device %s port %d\n", record->event,
293 record->event == IB_EVENT_PORT_ACTIVE || 280 record->device->name, record->element.port_num);
294 record->event == IB_EVENT_LID_CHANGE || 281
295 record->event == IB_EVENT_SM_CHANGE || 282 if (record->event == IB_EVENT_SM_CHANGE ||
296 record->event == IB_EVENT_CLIENT_REREGISTER) { 283 record->event == IB_EVENT_CLIENT_REREGISTER) {
297 ipoib_dbg(priv, "Port state change event\n"); 284 queue_work(ipoib_workqueue, &priv->flush_light);
298 queue_work(ipoib_workqueue, &priv->flush_task); 285 } else if (record->event == IB_EVENT_PORT_ERR ||
286 record->event == IB_EVENT_PORT_ACTIVE ||
287 record->event == IB_EVENT_LID_CHANGE) {
288 queue_work(ipoib_workqueue, &priv->flush_normal);
299 } else if (record->event == IB_EVENT_PKEY_CHANGE) { 289 } else if (record->event == IB_EVENT_PKEY_CHANGE) {
300 ipoib_dbg(priv, "P_Key change event on port:%d\n", priv->port); 290 queue_work(ipoib_workqueue, &priv->flush_heavy);
301 queue_work(ipoib_workqueue, &priv->pkey_event_task);
302 } 291 }
303} 292}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 1cdb5cfb0ff..b08eb56196d 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ipoib_vlan.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/module.h> 33#include <linux/module.h>
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index aeb58cae9a3..356fac6d105 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -42,9 +42,6 @@
42 * Zhenyu Wang 42 * Zhenyu Wang
43 * Modified by: 43 * Modified by:
44 * Erez Zilber 44 * Erez Zilber
45 *
46 *
47 * $Id: iscsi_iser.c 6965 2006-05-07 11:36:20Z ogerlitz $
48 */ 45 */
49 46
50#include <linux/types.h> 47#include <linux/types.h>
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index a8c1b300e34..0e10703cf59 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -36,8 +36,6 @@
36 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
37 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * SOFTWARE. 38 * SOFTWARE.
39 *
40 * $Id: iscsi_iser.h 7051 2006-05-10 12:29:11Z ogerlitz $
41 */ 39 */
42#ifndef __ISCSI_ISER_H__ 40#ifndef __ISCSI_ISER_H__
43#define __ISCSI_ISER_H__ 41#define __ISCSI_ISER_H__
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 08dc81c46f4..31ad498bdc5 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: iser_initiator.c 6964 2006-05-07 11:11:43Z ogerlitz $
33 */ 31 */
34#include <linux/kernel.h> 32#include <linux/kernel.h>
35#include <linux/slab.h> 33#include <linux/slab.h>
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index cac50c4dc15..81e49cb10ed 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: iser_memory.c 6964 2006-05-07 11:11:43Z ogerlitz $
33 */ 31 */
34#include <linux/module.h> 32#include <linux/module.h>
35#include <linux/kernel.h> 33#include <linux/kernel.h>
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index d19cfe605eb..77cabee7cc0 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: iser_verbs.c 7051 2006-05-10 12:29:11Z ogerlitz $
34 */ 32 */
35#include <linux/kernel.h> 33#include <linux/kernel.h>
36#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 435145709dd..ed7c5f72cb8 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ib_srp.c 3932 2005-11-01 17:19:29Z roland $
33 */ 31 */
34 32
35#include <linux/module.h> 33#include <linux/module.h>
@@ -49,8 +47,6 @@
49#include <scsi/srp.h> 47#include <scsi/srp.h>
50#include <scsi/scsi_transport_srp.h> 48#include <scsi/scsi_transport_srp.h>
51 49
52#include <rdma/ib_cache.h>
53
54#include "ib_srp.h" 50#include "ib_srp.h"
55 51
56#define DRV_NAME "ib_srp" 52#define DRV_NAME "ib_srp"
@@ -183,10 +179,10 @@ static int srp_init_qp(struct srp_target_port *target,
183 if (!attr) 179 if (!attr)
184 return -ENOMEM; 180 return -ENOMEM;
185 181
186 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, 182 ret = ib_find_pkey(target->srp_host->srp_dev->dev,
187 target->srp_host->port, 183 target->srp_host->port,
188 be16_to_cpu(target->path.pkey), 184 be16_to_cpu(target->path.pkey),
189 &attr->pkey_index); 185 &attr->pkey_index);
190 if (ret) 186 if (ret)
191 goto out; 187 goto out;
192 188
@@ -1883,8 +1879,7 @@ static ssize_t srp_create_target(struct device *dev,
1883 if (ret) 1879 if (ret)
1884 goto err; 1880 goto err;
1885 1881
1886 ib_get_cached_gid(host->srp_dev->dev, host->port, 0, 1882 ib_query_gid(host->srp_dev->dev, host->port, 0, &target->path.sgid);
1887 &target->path.sgid);
1888 1883
1889 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1884 shost_printk(KERN_DEBUG, target->scsi_host, PFX
1890 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1885 "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 63d2ae72406..e185b907fc1 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ib_srp.h 3932 2005-11-01 17:19:29Z roland $
33 */ 31 */
34 32
35#ifndef IB_SRP_H 33#ifndef IB_SRP_H
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
index 2e554a4ab33..95dfda52b4f 100644
--- a/drivers/lguest/x86/core.c
+++ b/drivers/lguest/x86/core.c
@@ -478,7 +478,7 @@ void __init lguest_arch_host_init(void)
478 cpu_had_pge = 1; 478 cpu_had_pge = 1;
479 /* adjust_pge is a helper function which sets or unsets the PGE 479 /* adjust_pge is a helper function which sets or unsets the PGE
480 * bit on its CPU, depending on the argument (0 == unset). */ 480 * bit on its CPU, depending on the argument (0 == unset). */
481 on_each_cpu(adjust_pge, (void *)0, 0, 1); 481 on_each_cpu(adjust_pge, (void *)0, 1);
482 /* Turn off the feature in the global feature set. */ 482 /* Turn off the feature in the global feature set. */
483 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 483 clear_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
484 } 484 }
@@ -493,7 +493,7 @@ void __exit lguest_arch_host_fini(void)
493 if (cpu_had_pge) { 493 if (cpu_had_pge) {
494 set_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability); 494 set_bit(X86_FEATURE_PGE, boot_cpu_data.x86_capability);
495 /* adjust_pge's argument "1" means set PGE. */ 495 /* adjust_pge's argument "1" means set PGE. */
496 on_each_cpu(adjust_pge, (void *)1, 0, 1); 496 on_each_cpu(adjust_pge, (void *)1, 1);
497 } 497 }
498 put_online_cpus(); 498 put_online_cpus();
499} 499}
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 17bc87a43ff..d2fbc296452 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -258,13 +258,6 @@ config MTD_ALCHEMY
258 help 258 help
259 Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards 259 Flash memory access on AMD Alchemy Pb/Db/RDK Reference Boards
260 260
261config MTD_MTX1
262 tristate "4G Systems MTX-1 Flash device"
263 depends on MIPS_MTX1 && MTD_CFI
264 help
265 Flash memory access on 4G Systems MTX-1 Board. If you have one of
266 these boards and would like to use the flash chips on it, say 'Y'.
267
268config MTD_DILNETPC 261config MTD_DILNETPC
269 tristate "CFI Flash device mapped on DIL/Net PC" 262 tristate "CFI Flash device mapped on DIL/Net PC"
270 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT 263 depends on X86 && MTD_CONCAT && MTD_PARTITIONS && MTD_CFI_INTELEXT
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 957fb5f70f5..c6ce8673dab 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -65,5 +65,4 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o
65obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o 65obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
66obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 66obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
67obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 67obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
68obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
69obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o 68obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_vr_nor.o
diff --git a/drivers/mtd/maps/mtx-1_flash.c b/drivers/mtd/maps/mtx-1_flash.c
deleted file mode 100644
index 2a8fde9b92f..00000000000
--- a/drivers/mtd/maps/mtx-1_flash.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/*
2 * Flash memory access on 4G Systems MTX-1 boards
3 *
4 * $Id: mtx-1_flash.c,v 1.2 2005/11/07 11:14:27 gleixner Exp $
5 *
6 * (C) 2005 Bruno Randolf <bruno.randolf@4g-systems.biz>
7 * (C) 2005 Joern Engel <joern@wohnheim.fh-wedel.de>
8 *
9 */
10
11#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15
16#include <linux/mtd/mtd.h>
17#include <linux/mtd/map.h>
18#include <linux/mtd/partitions.h>
19
20#include <asm/io.h>
21
22static struct map_info mtx1_map = {
23 .name = "MTX-1 flash",
24 .bankwidth = 4,
25 .size = 0x2000000,
26 .phys = 0x1E000000,
27};
28
29static struct mtd_partition mtx1_partitions[] = {
30 {
31 .name = "filesystem",
32 .size = 0x01C00000,
33 .offset = 0,
34 },{
35 .name = "yamon",
36 .size = 0x00100000,
37 .offset = MTDPART_OFS_APPEND,
38 .mask_flags = MTD_WRITEABLE,
39 },{
40 .name = "kernel",
41 .size = 0x002c0000,
42 .offset = MTDPART_OFS_APPEND,
43 },{
44 .name = "yamon env",
45 .size = 0x00040000,
46 .offset = MTDPART_OFS_APPEND,
47 }
48};
49
50static struct mtd_info *mtx1_mtd;
51
52int __init mtx1_mtd_init(void)
53{
54 int ret = -ENXIO;
55
56 simple_map_init(&mtx1_map);
57
58 mtx1_map.virt = ioremap(mtx1_map.phys, mtx1_map.size);
59 if (!mtx1_map.virt)
60 return -EIO;
61
62 mtx1_mtd = do_map_probe("cfi_probe", &mtx1_map);
63 if (!mtx1_mtd)
64 goto err;
65
66 mtx1_mtd->owner = THIS_MODULE;
67
68 ret = add_mtd_partitions(mtx1_mtd, mtx1_partitions,
69 ARRAY_SIZE(mtx1_partitions));
70 if (ret)
71 goto err;
72
73 return 0;
74
75err:
76 iounmap(mtx1_map.virt);
77 return ret;
78}
79
80static void __exit mtx1_mtd_cleanup(void)
81{
82 if (mtx1_mtd) {
83 del_mtd_partitions(mtx1_mtd);
84 map_destroy(mtx1_mtd);
85 }
86 if (mtx1_map.virt)
87 iounmap(mtx1_map.virt);
88}
89
90module_init(mtx1_mtd_init);
91module_exit(mtx1_mtd_cleanup);
92
93MODULE_AUTHOR("Bruno Randolf <bruno.randolf@4g-systems.biz>");
94MODULE_DESCRIPTION("MTX-1 flash map");
95MODULE_LICENSE("GPL");
diff --git a/drivers/net/cxgb3/cxgb3_ctl_defs.h b/drivers/net/cxgb3/cxgb3_ctl_defs.h
index 6c4f3206691..ed0ecd9679c 100644
--- a/drivers/net/cxgb3/cxgb3_ctl_defs.h
+++ b/drivers/net/cxgb3/cxgb3_ctl_defs.h
@@ -54,6 +54,7 @@ enum {
54 RDMA_CQ_DISABLE = 16, 54 RDMA_CQ_DISABLE = 16,
55 RDMA_CTRL_QP_SETUP = 17, 55 RDMA_CTRL_QP_SETUP = 17,
56 RDMA_GET_MEM = 18, 56 RDMA_GET_MEM = 18,
57 RDMA_GET_MIB = 19,
57 58
58 GET_RX_PAGE_INFO = 50, 59 GET_RX_PAGE_INFO = 50,
59}; 60};
diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index ff9c013ce53..cf269687379 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -303,6 +303,12 @@ static int cxgb_rdma_ctl(struct adapter *adapter, unsigned int req, void *data)
303 spin_unlock_irq(&adapter->sge.reg_lock); 303 spin_unlock_irq(&adapter->sge.reg_lock);
304 break; 304 break;
305 } 305 }
306 case RDMA_GET_MIB: {
307 spin_lock(&adapter->stats_lock);
308 t3_tp_get_mib_stats(adapter, (struct tp_mib_stats *)data);
309 spin_unlock(&adapter->stats_lock);
310 break;
311 }
306 default: 312 default:
307 ret = -EOPNOTSUPP; 313 ret = -EOPNOTSUPP;
308 } 314 }
@@ -381,6 +387,7 @@ static int cxgb_offload_ctl(struct t3cdev *tdev, unsigned int req, void *data)
381 case RDMA_CQ_DISABLE: 387 case RDMA_CQ_DISABLE:
382 case RDMA_CTRL_QP_SETUP: 388 case RDMA_CTRL_QP_SETUP:
383 case RDMA_GET_MEM: 389 case RDMA_GET_MEM:
390 case RDMA_GET_MIB:
384 if (!offload_running(adapter)) 391 if (!offload_running(adapter))
385 return -EAGAIN; 392 return -EAGAIN;
386 return cxgb_rdma_ctl(adapter, req, data); 393 return cxgb_rdma_ctl(adapter, req, data);
diff --git a/drivers/net/cxgb3/version.h b/drivers/net/cxgb3/version.h
index a0177fc55e2..29db711303b 100644
--- a/drivers/net/cxgb3/version.h
+++ b/drivers/net/cxgb3/version.h
@@ -38,7 +38,7 @@
38#define DRV_VERSION "1.0-ko" 38#define DRV_VERSION "1.0-ko"
39 39
40/* Firmware version */ 40/* Firmware version */
41#define FW_VERSION_MAJOR 6 41#define FW_VERSION_MAJOR 7
42#define FW_VERSION_MINOR 0 42#define FW_VERSION_MINOR 0
43#define FW_VERSION_MICRO 0 43#define FW_VERSION_MICRO 0
44#endif /* __CHELSIO_VERSION_H */ 44#endif /* __CHELSIO_VERSION_H */
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index c36a03ae9bf..860d75d81f8 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -20,7 +20,7 @@
20#include <linux/errno.h> 20#include <linux/errno.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/list.h> 23#include <linux/rculist.h>
24#include <linux/notifier.h> 24#include <linux/notifier.h>
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/etherdevice.h> 26#include <linux/etherdevice.h>
diff --git a/drivers/net/mlx4/fw.c b/drivers/net/mlx4/fw.c
index d82f2751d2c..2b5006b9be6 100644
--- a/drivers/net/mlx4/fw.c
+++ b/drivers/net/mlx4/fw.c
@@ -101,6 +101,34 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u32 flags)
101 mlx4_dbg(dev, " %s\n", fname[i]); 101 mlx4_dbg(dev, " %s\n", fname[i]);
102} 102}
103 103
104int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg)
105{
106 struct mlx4_cmd_mailbox *mailbox;
107 u32 *inbox;
108 int err = 0;
109
110#define MOD_STAT_CFG_IN_SIZE 0x100
111
112#define MOD_STAT_CFG_PG_SZ_M_OFFSET 0x002
113#define MOD_STAT_CFG_PG_SZ_OFFSET 0x003
114
115 mailbox = mlx4_alloc_cmd_mailbox(dev);
116 if (IS_ERR(mailbox))
117 return PTR_ERR(mailbox);
118 inbox = mailbox->buf;
119
120 memset(inbox, 0, MOD_STAT_CFG_IN_SIZE);
121
122 MLX4_PUT(inbox, cfg->log_pg_sz, MOD_STAT_CFG_PG_SZ_OFFSET);
123 MLX4_PUT(inbox, cfg->log_pg_sz_m, MOD_STAT_CFG_PG_SZ_M_OFFSET);
124
125 err = mlx4_cmd(dev, mailbox->dma, 0, 0, MLX4_CMD_MOD_STAT_CFG,
126 MLX4_CMD_TIME_CLASS_A);
127
128 mlx4_free_cmd_mailbox(dev, mailbox);
129 return err;
130}
131
104int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) 132int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
105{ 133{
106 struct mlx4_cmd_mailbox *mailbox; 134 struct mlx4_cmd_mailbox *mailbox;
diff --git a/drivers/net/mlx4/fw.h b/drivers/net/mlx4/fw.h
index 306cb9b0242..a0e046c149b 100644
--- a/drivers/net/mlx4/fw.h
+++ b/drivers/net/mlx4/fw.h
@@ -38,6 +38,11 @@
38#include "mlx4.h" 38#include "mlx4.h"
39#include "icm.h" 39#include "icm.h"
40 40
41struct mlx4_mod_stat_cfg {
42 u8 log_pg_sz;
43 u8 log_pg_sz_m;
44};
45
41struct mlx4_dev_cap { 46struct mlx4_dev_cap {
42 int max_srq_sz; 47 int max_srq_sz;
43 int max_qp_sz; 48 int max_qp_sz;
@@ -162,5 +167,6 @@ int mlx4_SET_ICM_SIZE(struct mlx4_dev *dev, u64 icm_size, u64 *aux_pages);
162int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm); 167int mlx4_MAP_ICM_AUX(struct mlx4_dev *dev, struct mlx4_icm *icm);
163int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev); 168int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev);
164int mlx4_NOP(struct mlx4_dev *dev); 169int mlx4_NOP(struct mlx4_dev *dev);
170int mlx4_MOD_STAT_CFG(struct mlx4_dev *dev, struct mlx4_mod_stat_cfg *cfg);
165 171
166#endif /* MLX4_FW_H */ 172#endif /* MLX4_FW_H */
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index a6aa49fc1d6..d3736013fe9 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -485,6 +485,7 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
485 struct mlx4_priv *priv = mlx4_priv(dev); 485 struct mlx4_priv *priv = mlx4_priv(dev);
486 struct mlx4_adapter adapter; 486 struct mlx4_adapter adapter;
487 struct mlx4_dev_cap dev_cap; 487 struct mlx4_dev_cap dev_cap;
488 struct mlx4_mod_stat_cfg mlx4_cfg;
488 struct mlx4_profile profile; 489 struct mlx4_profile profile;
489 struct mlx4_init_hca_param init_hca; 490 struct mlx4_init_hca_param init_hca;
490 u64 icm_size; 491 u64 icm_size;
@@ -502,6 +503,12 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
502 return err; 503 return err;
503 } 504 }
504 505
506 mlx4_cfg.log_pg_sz_m = 1;
507 mlx4_cfg.log_pg_sz = 0;
508 err = mlx4_MOD_STAT_CFG(dev, &mlx4_cfg);
509 if (err)
510 mlx4_warn(dev, "Failed to override log_pg_sz parameter\n");
511
505 err = mlx4_dev_cap(dev, &dev_cap); 512 err = mlx4_dev_cap(dev, &dev_cap);
506 if (err) { 513 if (err) {
507 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n"); 514 mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
diff --git a/drivers/net/mlx4/mcg.c b/drivers/net/mlx4/mcg.c
index 57f7f1f0d4e..b4b57870ddf 100644
--- a/drivers/net/mlx4/mcg.c
+++ b/drivers/net/mlx4/mcg.c
@@ -38,6 +38,9 @@
38 38
39#include "mlx4.h" 39#include "mlx4.h"
40 40
41#define MGM_QPN_MASK 0x00FFFFFF
42#define MGM_BLCK_LB_BIT 30
43
41struct mlx4_mgm { 44struct mlx4_mgm {
42 __be32 next_gid_index; 45 __be32 next_gid_index;
43 __be32 members_count; 46 __be32 members_count;
@@ -153,7 +156,8 @@ static int find_mgm(struct mlx4_dev *dev,
153 return err; 156 return err;
154} 157}
155 158
156int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]) 159int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
160 int block_mcast_loopback)
157{ 161{
158 struct mlx4_priv *priv = mlx4_priv(dev); 162 struct mlx4_priv *priv = mlx4_priv(dev);
159 struct mlx4_cmd_mailbox *mailbox; 163 struct mlx4_cmd_mailbox *mailbox;
@@ -202,13 +206,18 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
202 } 206 }
203 207
204 for (i = 0; i < members_count; ++i) 208 for (i = 0; i < members_count; ++i)
205 if (mgm->qp[i] == cpu_to_be32(qp->qpn)) { 209 if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn) {
206 mlx4_dbg(dev, "QP %06x already a member of MGM\n", qp->qpn); 210 mlx4_dbg(dev, "QP %06x already a member of MGM\n", qp->qpn);
207 err = 0; 211 err = 0;
208 goto out; 212 goto out;
209 } 213 }
210 214
211 mgm->qp[members_count++] = cpu_to_be32(qp->qpn); 215 if (block_mcast_loopback)
216 mgm->qp[members_count++] = cpu_to_be32((qp->qpn & MGM_QPN_MASK) |
217 (1 << MGM_BLCK_LB_BIT));
218 else
219 mgm->qp[members_count++] = cpu_to_be32(qp->qpn & MGM_QPN_MASK);
220
212 mgm->members_count = cpu_to_be32(members_count); 221 mgm->members_count = cpu_to_be32(members_count);
213 222
214 err = mlx4_WRITE_MCG(dev, index, mailbox); 223 err = mlx4_WRITE_MCG(dev, index, mailbox);
@@ -283,7 +292,7 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16])
283 292
284 members_count = be32_to_cpu(mgm->members_count); 293 members_count = be32_to_cpu(mgm->members_count);
285 for (loc = -1, i = 0; i < members_count; ++i) 294 for (loc = -1, i = 0; i < members_count; ++i)
286 if (mgm->qp[i] == cpu_to_be32(qp->qpn)) 295 if ((be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK) == qp->qpn)
287 loc = i; 296 loc = i;
288 297
289 if (loc == -1) { 298 if (loc == -1) {
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index ced3eebe252..84bb6162837 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -389,7 +389,7 @@ static u8 orc_load_firmware(struct orc_host * host)
389 389
390 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Enable SRAM programming */ 390 outb(PRGMRST | DOWNLOAD, host->base + ORC_RISCCTL); /* Enable SRAM programming */
391 data32_ptr = (u8 *) & data32; 391 data32_ptr = (u8 *) & data32;
392 data32 = 0; /* Initial FW address to 0 */ 392 data32 = cpu_to_le32(0); /* Initial FW address to 0 */
393 outw(0x0010, host->base + ORC_EBIOSADR0); 393 outw(0x0010, host->base + ORC_EBIOSADR0);
394 *data32_ptr = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ 394 *data32_ptr = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
395 outw(0x0011, host->base + ORC_EBIOSADR0); 395 outw(0x0011, host->base + ORC_EBIOSADR0);
@@ -397,18 +397,19 @@ static u8 orc_load_firmware(struct orc_host * host)
397 outw(0x0012, host->base + ORC_EBIOSADR0); 397 outw(0x0012, host->base + ORC_EBIOSADR0);
398 *(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ 398 *(data32_ptr + 2) = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
399 outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2); 399 outw(*(data32_ptr + 2), host->base + ORC_EBIOSADR2);
400 outl(data32, host->base + ORC_FWBASEADR); /* Write FW address */ 400 outl(le32_to_cpu(data32), host->base + ORC_FWBASEADR); /* Write FW address */
401 401
402 /* Copy the code from the BIOS to the SRAM */ 402 /* Copy the code from the BIOS to the SRAM */
403 403
404 bios_addr = (u16) data32; /* FW code locate at BIOS address + ? */ 404 udelay(500); /* Required on Sun Ultra 5 ... 350 -> failures */
405 bios_addr = (u16) le32_to_cpu(data32); /* FW code locate at BIOS address + ? */
405 for (i = 0, data32_ptr = (u8 *) & data32; /* Download the code */ 406 for (i = 0, data32_ptr = (u8 *) & data32; /* Download the code */
406 i < 0x1000; /* Firmware code size = 4K */ 407 i < 0x1000; /* Firmware code size = 4K */
407 i++, bios_addr++) { 408 i++, bios_addr++) {
408 outw(bios_addr, host->base + ORC_EBIOSADR0); 409 outw(bios_addr, host->base + ORC_EBIOSADR0);
409 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ 410 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
410 if ((i % 4) == 3) { 411 if ((i % 4) == 3) {
411 outl(data32, host->base + ORC_RISCRAM); /* Write every 4 bytes */ 412 outl(le32_to_cpu(data32), host->base + ORC_RISCRAM); /* Write every 4 bytes */
412 data32_ptr = (u8 *) & data32; 413 data32_ptr = (u8 *) & data32;
413 } 414 }
414 } 415 }
@@ -423,7 +424,7 @@ static u8 orc_load_firmware(struct orc_host * host)
423 outw(bios_addr, host->base + ORC_EBIOSADR0); 424 outw(bios_addr, host->base + ORC_EBIOSADR0);
424 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */ 425 *data32_ptr++ = inb(host->base + ORC_EBIOSDATA); /* Read from BIOS */
425 if ((i % 4) == 3) { 426 if ((i % 4) == 3) {
426 if (inl(host->base + ORC_RISCRAM) != data32) { 427 if (inl(host->base + ORC_RISCRAM) != le32_to_cpu(data32)) {
427 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */ 428 outb(PRGMRST, host->base + ORC_RISCCTL); /* Reset program to 0 */
428 outb(data, host->base + ORC_GCFG); /*Disable EEPROM programming */ 429 outb(data, host->base + ORC_GCFG); /*Disable EEPROM programming */
429 return 0; 430 return 0;
@@ -459,8 +460,8 @@ static void setup_SCBs(struct orc_host * host)
459 460
460 for (i = 0; i < ORC_MAXQUEUE; i++) { 461 for (i = 0; i < ORC_MAXQUEUE; i++) {
461 escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i)); 462 escb_phys = (host->escb_phys + (sizeof(struct orc_extended_scb) * i));
462 scb->sg_addr = (u32) escb_phys; 463 scb->sg_addr = cpu_to_le32((u32) escb_phys);
463 scb->sense_addr = (u32) escb_phys; 464 scb->sense_addr = cpu_to_le32((u32) escb_phys);
464 scb->escb = escb; 465 scb->escb = escb;
465 scb->scbidx = i; 466 scb->scbidx = i;
466 scb++; 467 scb++;
@@ -642,8 +643,8 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig
642 scb->link = 0xFF; 643 scb->link = 0xFF;
643 scb->reserved0 = 0; 644 scb->reserved0 = 0;
644 scb->reserved1 = 0; 645 scb->reserved1 = 0;
645 scb->xferlen = 0; 646 scb->xferlen = cpu_to_le32(0);
646 scb->sg_len = 0; 647 scb->sg_len = cpu_to_le32(0);
647 648
648 escb->srb = NULL; 649 escb->srb = NULL;
649 escb->srb = cmd; 650 escb->srb = cmd;
@@ -839,7 +840,7 @@ static irqreturn_t orc_interrupt(struct orc_host * host)
839 * Build a host adapter control block from the SCSI mid layer command 840 * Build a host adapter control block from the SCSI mid layer command
840 */ 841 */
841 842
842static void inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd) 843static int inia100_build_scb(struct orc_host * host, struct orc_scb * scb, struct scsi_cmnd * cmd)
843{ /* Create corresponding SCB */ 844{ /* Create corresponding SCB */
844 struct scatterlist *sg; 845 struct scatterlist *sg;
845 struct orc_sgent *sgent; /* Pointer to SG list */ 846 struct orc_sgent *sgent; /* Pointer to SG list */
@@ -858,28 +859,30 @@ static void inia100_build_scb(struct orc_host * host, struct orc_scb * scb, stru
858 scb->lun = cmd->device->lun; 859 scb->lun = cmd->device->lun;
859 scb->reserved0 = 0; 860 scb->reserved0 = 0;
860 scb->reserved1 = 0; 861 scb->reserved1 = 0;
861 scb->sg_len = 0; 862 scb->sg_len = cpu_to_le32(0);
862 863
863 scb->xferlen = (u32) scsi_bufflen(cmd); 864 scb->xferlen = cpu_to_le32((u32) scsi_bufflen(cmd));
864 sgent = (struct orc_sgent *) & escb->sglist[0]; 865 sgent = (struct orc_sgent *) & escb->sglist[0];
865 866
866 count_sg = scsi_dma_map(cmd); 867 count_sg = scsi_dma_map(cmd);
867 BUG_ON(count_sg < 0); 868 if (count_sg < 0)
869 return count_sg;
870 BUG_ON(count_sg > TOTAL_SG_ENTRY);
868 871
869 /* Build the scatter gather lists */ 872 /* Build the scatter gather lists */
870 if (count_sg) { 873 if (count_sg) {
871 scb->sg_len = (u32) (count_sg * 8); 874 scb->sg_len = cpu_to_le32((u32) (count_sg * 8));
872 scsi_for_each_sg(cmd, sg, count_sg, i) { 875 scsi_for_each_sg(cmd, sg, count_sg, i) {
873 sgent->base = (u32) sg_dma_address(sg); 876 sgent->base = cpu_to_le32((u32) sg_dma_address(sg));
874 sgent->length = (u32) sg_dma_len(sg); 877 sgent->length = cpu_to_le32((u32) sg_dma_len(sg));
875 sgent++; 878 sgent++;
876 } 879 }
877 } else { 880 } else {
878 scb->sg_len = 0; 881 scb->sg_len = cpu_to_le32(0);
879 sgent->base = 0; 882 sgent->base = cpu_to_le32(0);
880 sgent->length = 0; 883 sgent->length = cpu_to_le32(0);
881 } 884 }
882 scb->sg_addr = (u32) scb->sense_addr; 885 scb->sg_addr = (u32) scb->sense_addr; /* sense_addr is already little endian */
883 scb->hastat = 0; 886 scb->hastat = 0;
884 scb->tastat = 0; 887 scb->tastat = 0;
885 scb->link = 0xFF; 888 scb->link = 0xFF;
@@ -896,6 +899,7 @@ static void inia100_build_scb(struct orc_host * host, struct orc_scb * scb, stru
896 scb->tag_msg = 0; /* No tag support */ 899 scb->tag_msg = 0; /* No tag support */
897 } 900 }
898 memcpy(scb->cdb, cmd->cmnd, scb->cdb_len); 901 memcpy(scb->cdb, cmd->cmnd, scb->cdb_len);
902 return 0;
899} 903}
900 904
901/** 905/**
@@ -919,7 +923,10 @@ static int inia100_queue(struct scsi_cmnd * cmd, void (*done) (struct scsi_cmnd
919 if ((scb = orc_alloc_scb(host)) == NULL) 923 if ((scb = orc_alloc_scb(host)) == NULL)
920 return SCSI_MLQUEUE_HOST_BUSY; 924 return SCSI_MLQUEUE_HOST_BUSY;
921 925
922 inia100_build_scb(host, scb, cmd); 926 if (inia100_build_scb(host, scb, cmd)) {
927 orc_release_scb(host, scb);
928 return SCSI_MLQUEUE_HOST_BUSY;
929 }
923 orc_exec_scb(host, scb); /* Start execute SCB */ 930 orc_exec_scb(host, scb); /* Start execute SCB */
924 return 0; 931 return 0;
925} 932}
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 44d8d5163a1..683bce375c7 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -60,6 +60,13 @@
60 60
61#define IDESCSI_DEBUG_LOG 0 61#define IDESCSI_DEBUG_LOG 0
62 62
63#if IDESCSI_DEBUG_LOG
64#define debug_log(fmt, args...) \
65 printk(KERN_INFO "ide-scsi: " fmt, ## args)
66#else
67#define debug_log(fmt, args...) do {} while (0)
68#endif
69
63/* 70/*
64 * SCSI command transformation layer 71 * SCSI command transformation layer
65 */ 72 */
@@ -129,14 +136,15 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive)
129#define IDESCSI_PC_RQ 90 136#define IDESCSI_PC_RQ 90
130 137
131/* 138/*
132 * PIO data transfer routines using the scatter gather table. 139 * PIO data transfer routine using the scatter gather table.
133 */ 140 */
134static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, 141static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
135 unsigned int bcount) 142 unsigned int bcount, int write)
136{ 143{
137 ide_hwif_t *hwif = drive->hwif; 144 ide_hwif_t *hwif = drive->hwif;
138 int count; 145 xfer_func_t *xf = write ? hwif->output_data : hwif->input_data;
139 char *buf; 146 char *buf;
147 int count;
140 148
141 while (bcount) { 149 while (bcount) {
142 count = min(pc->sg->length - pc->b_count, bcount); 150 count = min(pc->sg->length - pc->b_count, bcount);
@@ -145,13 +153,13 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
145 153
146 local_irq_save(flags); 154 local_irq_save(flags);
147 buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + 155 buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) +
148 pc->sg->offset; 156 pc->sg->offset;
149 hwif->input_data(drive, NULL, buf + pc->b_count, count); 157 xf(drive, NULL, buf + pc->b_count, count);
150 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); 158 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
151 local_irq_restore(flags); 159 local_irq_restore(flags);
152 } else { 160 } else {
153 buf = sg_virt(pc->sg); 161 buf = sg_virt(pc->sg);
154 hwif->input_data(drive, NULL, buf + pc->b_count, count); 162 xf(drive, NULL, buf + pc->b_count, count);
155 } 163 }
156 bcount -= count; pc->b_count += count; 164 bcount -= count; pc->b_count += count;
157 if (pc->b_count == pc->sg->length) { 165 if (pc->b_count == pc->sg->length) {
@@ -163,51 +171,34 @@ static void idescsi_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
163 } 171 }
164 172
165 if (bcount) { 173 if (bcount) {
166 printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n"); 174 printk(KERN_ERR "%s: scatter gather table too small, %s\n",
167 ide_pad_transfer(drive, 0, bcount); 175 drive->name, write ? "padding with zeros"
176 : "discarding data");
177 ide_pad_transfer(drive, write, bcount);
168 } 178 }
169} 179}
170 180
171static void idescsi_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, 181static void ide_scsi_hex_dump(u8 *data, int len)
172 unsigned int bcount)
173{ 182{
174 ide_hwif_t *hwif = drive->hwif; 183 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0);
175 int count; 184}
176 char *buf;
177 185
178 while (bcount) { 186static int idescsi_end_request(ide_drive_t *, int, int);
179 count = min(pc->sg->length - pc->b_count, bcount);
180 if (PageHighMem(sg_page(pc->sg))) {
181 unsigned long flags;
182 187
183 local_irq_save(flags); 188static void ide_scsi_callback(ide_drive_t *drive)
184 buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + 189{
185 pc->sg->offset; 190 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
186 hwif->output_data(drive, NULL, buf + pc->b_count, count); 191 struct ide_atapi_pc *pc = scsi->pc;
187 kunmap_atomic(buf - pc->sg->offset, KM_IRQ0);
188 local_irq_restore(flags);
189 } else {
190 buf = sg_virt(pc->sg);
191 hwif->output_data(drive, NULL, buf + pc->b_count, count);
192 }
193 bcount -= count; pc->b_count += count;
194 if (pc->b_count == pc->sg->length) {
195 if (!--pc->sg_cnt)
196 break;
197 pc->sg = sg_next(pc->sg);
198 pc->b_count = 0;
199 }
200 }
201 192
202 if (bcount) { 193 if (pc->flags & PC_FLAG_TIMEDOUT)
203 printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n"); 194 debug_log("%s: got timed out packet %lu at %lu\n", __func__,
204 ide_pad_transfer(drive, 1, bcount); 195 pc->scsi_cmd->serial_number, jiffies);
205 } 196 /* end this request now - scsi should retry it*/
206} 197 else if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
198 printk(KERN_INFO "Packet command completed, %d bytes"
199 " transferred\n", pc->xferred);
207 200
208static void ide_scsi_hex_dump(u8 *data, int len) 201 idescsi_end_request(drive, 1, 0);
209{
210 print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0);
211} 202}
212 203
213static int idescsi_check_condition(ide_drive_t *drive, 204static int idescsi_check_condition(ide_drive_t *drive,
@@ -228,14 +219,16 @@ static int idescsi_check_condition(ide_drive_t *drive,
228 kfree(pc); 219 kfree(pc);
229 return -ENOMEM; 220 return -ENOMEM;
230 } 221 }
231 ide_init_drive_cmd(rq); 222 blk_rq_init(NULL, rq);
232 rq->special = (char *) pc; 223 rq->special = (char *) pc;
233 pc->rq = rq; 224 pc->rq = rq;
234 pc->buf = buf; 225 pc->buf = buf;
235 pc->c[0] = REQUEST_SENSE; 226 pc->c[0] = REQUEST_SENSE;
236 pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE; 227 pc->c[4] = pc->req_xfer = pc->buf_size = SCSI_SENSE_BUFFERSIZE;
237 rq->cmd_type = REQ_TYPE_SENSE; 228 rq->cmd_type = REQ_TYPE_SENSE;
229 rq->cmd_flags |= REQ_PREEMPT;
238 pc->timeout = jiffies + WAIT_READY; 230 pc->timeout = jiffies + WAIT_READY;
231 pc->callback = ide_scsi_callback;
239 /* NOTE! Save the failed packet command in "rq->buffer" */ 232 /* NOTE! Save the failed packet command in "rq->buffer" */
240 rq->buffer = (void *) failed_cmd->special; 233 rq->buffer = (void *) failed_cmd->special;
241 pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd; 234 pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd;
@@ -244,11 +237,10 @@ static int idescsi_check_condition(ide_drive_t *drive,
244 ide_scsi_hex_dump(pc->c, 6); 237 ide_scsi_hex_dump(pc->c, 6);
245 } 238 }
246 rq->rq_disk = scsi->disk; 239 rq->rq_disk = scsi->disk;
247 return ide_do_drive_cmd(drive, rq, ide_preempt); 240 ide_do_drive_cmd(drive, rq);
241 return 0;
248} 242}
249 243
250static int idescsi_end_request(ide_drive_t *, int, int);
251
252static ide_startstop_t 244static ide_startstop_t
253idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) 245idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
254{ 246{
@@ -256,7 +248,7 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
256 248
257 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT)) 249 if (ide_read_status(drive) & (BUSY_STAT | DRQ_STAT))
258 /* force an abort */ 250 /* force an abort */
259 hwif->OUTBSYNC(drive, WIN_IDLEIMMEDIATE, 251 hwif->OUTBSYNC(hwif, WIN_IDLEIMMEDIATE,
260 hwif->io_ports.command_addr); 252 hwif->io_ports.command_addr);
261 253
262 rq->errors++; 254 rq->errors++;
@@ -269,10 +261,9 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
269static ide_startstop_t 261static ide_startstop_t
270idescsi_atapi_abort(ide_drive_t *drive, struct request *rq) 262idescsi_atapi_abort(ide_drive_t *drive, struct request *rq)
271{ 263{
272#if IDESCSI_DEBUG_LOG 264 debug_log("%s called for %lu\n", __func__,
273 printk(KERN_WARNING "idescsi_atapi_abort called for %lu\n",
274 ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number); 265 ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number);
275#endif 266
276 rq->errors |= ERROR_MAX; 267 rq->errors |= ERROR_MAX;
277 268
278 idescsi_end_request(drive, 0, 0); 269 idescsi_end_request(drive, 0, 0);
@@ -351,9 +342,9 @@ static int idescsi_expiry(ide_drive_t *drive)
351 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 342 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
352 struct ide_atapi_pc *pc = scsi->pc; 343 struct ide_atapi_pc *pc = scsi->pc;
353 344
354#if IDESCSI_DEBUG_LOG 345 debug_log("%s called for %lu at %lu\n", __func__,
355 printk(KERN_WARNING "idescsi_expiry called for %lu at %lu\n", pc->scsi_cmd->serial_number, jiffies); 346 pc->scsi_cmd->serial_number, jiffies);
356#endif 347
357 pc->flags |= PC_FLAG_TIMEDOUT; 348 pc->flags |= PC_FLAG_TIMEDOUT;
358 349
359 return 0; /* we do not want the ide subsystem to retry */ 350 return 0; /* we do not want the ide subsystem to retry */
@@ -365,141 +356,19 @@ static int idescsi_expiry(ide_drive_t *drive)
365static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) 356static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
366{ 357{
367 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 358 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
368 ide_hwif_t *hwif = drive->hwif;
369 struct ide_atapi_pc *pc = scsi->pc; 359 struct ide_atapi_pc *pc = scsi->pc;
370 struct request *rq = pc->rq;
371 unsigned int temp;
372 u16 bcount;
373 u8 stat, ireason;
374
375#if IDESCSI_DEBUG_LOG
376 printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n");
377#endif /* IDESCSI_DEBUG_LOG */
378
379 if (pc->flags & PC_FLAG_TIMEDOUT) {
380#if IDESCSI_DEBUG_LOG
381 printk(KERN_WARNING "idescsi_pc_intr: got timed out packet %lu at %lu\n",
382 pc->scsi_cmd->serial_number, jiffies);
383#endif
384 /* end this request now - scsi should retry it*/
385 idescsi_end_request (drive, 1, 0);
386 return ide_stopped;
387 }
388 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
389 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
390#if IDESCSI_DEBUG_LOG
391 printk ("ide-scsi: %s: DMA complete\n", drive->name);
392#endif /* IDESCSI_DEBUG_LOG */
393 pc->xferred = pc->req_xfer;
394 (void)hwif->dma_ops->dma_end(drive);
395 }
396
397 /* Clear the interrupt */
398 stat = ide_read_status(drive);
399
400 if ((stat & DRQ_STAT) == 0) {
401 /* No more interrupts */
402 if (test_bit(IDESCSI_LOG_CMD, &scsi->log))
403 printk(KERN_INFO "Packet command completed, %d bytes"
404 " transferred\n", pc->xferred);
405 local_irq_enable_in_hardirq();
406 if (stat & ERR_STAT)
407 rq->errors++;
408 idescsi_end_request (drive, 1, 0);
409 return ide_stopped;
410 }
411 bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) |
412 hwif->INB(hwif->io_ports.lbam_addr);
413 ireason = hwif->INB(hwif->io_ports.nsect_addr);
414
415 if (ireason & CD) {
416 printk(KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n");
417 return ide_do_reset (drive);
418 }
419 if (ireason & IO) {
420 temp = pc->xferred + bcount;
421 if (temp > pc->req_xfer) {
422 if (temp > pc->buf_size) {
423 printk(KERN_ERR "ide-scsi: The scsi wants to "
424 "send us more data than expected "
425 "- discarding data\n");
426 temp = pc->buf_size - pc->xferred;
427 if (temp) {
428 pc->flags &= ~PC_FLAG_WRITING;
429 if (pc->sg)
430 idescsi_input_buffers(drive, pc,
431 temp);
432 else
433 hwif->input_data(drive, NULL,
434 pc->cur_pos, temp);
435 printk(KERN_ERR "ide-scsi: transferred"
436 " %d of %d bytes\n",
437 temp, bcount);
438 }
439 pc->xferred += temp;
440 pc->cur_pos += temp;
441 ide_pad_transfer(drive, 0, bcount - temp);
442 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
443 return ide_started;
444 }
445#if IDESCSI_DEBUG_LOG
446 printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n");
447#endif /* IDESCSI_DEBUG_LOG */
448 }
449 }
450 if (ireason & IO) {
451 pc->flags &= ~PC_FLAG_WRITING;
452 if (pc->sg)
453 idescsi_input_buffers(drive, pc, bcount);
454 else
455 hwif->input_data(drive, NULL, pc->cur_pos, bcount);
456 } else {
457 pc->flags |= PC_FLAG_WRITING;
458 if (pc->sg)
459 idescsi_output_buffers(drive, pc, bcount);
460 else
461 hwif->output_data(drive, NULL, pc->cur_pos, bcount);
462 }
463 /* Update the current position */
464 pc->xferred += bcount;
465 pc->cur_pos += bcount;
466 360
467 /* And set the interrupt handler again */ 361 return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc),
468 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); 362 idescsi_expiry, NULL, NULL, NULL,
469 return ide_started; 363 ide_scsi_io_buffers);
470} 364}
471 365
472static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) 366static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive)
473{ 367{
474 ide_hwif_t *hwif = drive->hwif;
475 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 368 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
476 struct ide_atapi_pc *pc = scsi->pc;
477 ide_startstop_t startstop;
478 u8 ireason;
479 369
480 if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { 370 return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr,
481 printk(KERN_ERR "ide-scsi: Strange, packet command " 371 get_timeout(scsi->pc), idescsi_expiry);
482 "initiated yet DRQ isn't asserted\n");
483 return startstop;
484 }
485 ireason = hwif->INB(hwif->io_ports.nsect_addr);
486 if ((ireason & CD) == 0 || (ireason & IO)) {
487 printk(KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while "
488 "issuing a packet command\n");
489 return ide_do_reset (drive);
490 }
491 BUG_ON(HWGROUP(drive)->handler != NULL);
492 /* Set the interrupt routine */
493 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
494
495 /* Send the actual packet */
496 hwif->output_data(drive, NULL, scsi->pc->c, 12);
497
498 if (pc->flags & PC_FLAG_DMA_OK) {
499 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
500 hwif->dma_ops->dma_start(drive);
501 }
502 return ide_started;
503} 372}
504 373
505static inline int idescsi_set_direction(struct ide_atapi_pc *pc) 374static inline int idescsi_set_direction(struct ide_atapi_pc *pc)
@@ -545,38 +414,12 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
545 struct ide_atapi_pc *pc) 414 struct ide_atapi_pc *pc)
546{ 415{
547 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 416 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
548 ide_hwif_t *hwif = drive->hwif;
549 u16 bcount;
550 u8 dma = 0;
551 417
552 /* Set the current packet command */ 418 /* Set the current packet command */
553 scsi->pc = pc; 419 scsi->pc = pc;
554 /* We haven't transferred any data yet */
555 pc->xferred = 0;
556 pc->cur_pos = pc->buf;
557 /* Request to transfer the entire buffer at once */
558 bcount = min(pc->req_xfer, 63 * 1024);
559
560 if (drive->using_dma && !idescsi_map_sg(drive, pc)) {
561 hwif->sg_mapped = 1;
562 dma = !hwif->dma_ops->dma_setup(drive);
563 hwif->sg_mapped = 0;
564 }
565
566 ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK, bcount, dma);
567 420
568 if (dma) 421 return ide_issue_pc(drive, pc, idescsi_transfer_pc,
569 pc->flags |= PC_FLAG_DMA_OK; 422 get_timeout(pc), idescsi_expiry);
570
571 if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags)) {
572 ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc,
573 get_timeout(pc), idescsi_expiry);
574 return ide_started;
575 } else {
576 /* Issue the packet command */
577 ide_execute_pkt_cmd(drive);
578 return idescsi_transfer_pc(drive);
579 }
580} 423}
581 424
582/* 425/*
@@ -584,14 +427,22 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,
584 */ 427 */
585static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *rq, sector_t block) 428static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *rq, sector_t block)
586{ 429{
587#if IDESCSI_DEBUG_LOG 430 debug_log("dev: %s, cmd: %x, errors: %d\n", rq->rq_disk->disk_name,
588 printk (KERN_INFO "dev: %s, cmd: %x, errors: %d\n", rq->rq_disk->disk_name,rq->cmd[0],rq->errors); 431 rq->cmd[0], rq->errors);
589 printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors); 432 debug_log("sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",
590#endif /* IDESCSI_DEBUG_LOG */ 433 rq->sector, rq->nr_sectors, rq->current_nr_sectors);
591 434
592 if (blk_sense_request(rq) || blk_special_request(rq)) { 435 if (blk_sense_request(rq) || blk_special_request(rq)) {
593 return idescsi_issue_pc(drive, 436 struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special;
594 (struct ide_atapi_pc *) rq->special); 437 idescsi_scsi_t *scsi = drive_to_idescsi(drive);
438
439 if (test_bit(IDESCSI_DRQ_INTERRUPT, &scsi->flags))
440 pc->flags |= PC_FLAG_DRQ_INTERRUPT;
441
442 if (drive->using_dma && !idescsi_map_sg(drive, pc))
443 pc->flags |= PC_FLAG_DMA_OK;
444
445 return idescsi_issue_pc(drive, pc);
595 } 446 }
596 blk_dump_rq_flags(rq, "ide-scsi: unsup command"); 447 blk_dump_rq_flags(rq, "ide-scsi: unsup command");
597 idescsi_end_request (drive, 0, 0); 448 idescsi_end_request (drive, 0, 0);
@@ -646,6 +497,8 @@ static void ide_scsi_remove(ide_drive_t *drive)
646 put_disk(g); 497 put_disk(g);
647 498
648 ide_scsi_put(scsi); 499 ide_scsi_put(scsi);
500
501 drive->scsi = 0;
649} 502}
650 503
651static int ide_scsi_probe(ide_drive_t *); 504static int ide_scsi_probe(ide_drive_t *);
@@ -765,6 +618,8 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
765 618
766 memset (pc->c, 0, 12); 619 memset (pc->c, 0, 12);
767 pc->flags = 0; 620 pc->flags = 0;
621 if (cmd->sc_data_direction == DMA_TO_DEVICE)
622 pc->flags |= PC_FLAG_WRITING;
768 pc->rq = rq; 623 pc->rq = rq;
769 memcpy (pc->c, cmd->cmnd, cmd->cmd_len); 624 memcpy (pc->c, cmd->cmnd, cmd->cmd_len);
770 pc->buf = NULL; 625 pc->buf = NULL;
@@ -775,6 +630,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
775 pc->scsi_cmd = cmd; 630 pc->scsi_cmd = cmd;
776 pc->done = done; 631 pc->done = done;
777 pc->timeout = jiffies + cmd->timeout_per_command; 632 pc->timeout = jiffies + cmd->timeout_per_command;
633 pc->callback = ide_scsi_callback;
778 634
779 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { 635 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) {
780 printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); 636 printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number);
@@ -785,12 +641,11 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
785 } 641 }
786 } 642 }
787 643
788 ide_init_drive_cmd (rq); 644 blk_rq_init(NULL, rq);
789 rq->special = (char *) pc; 645 rq->special = (char *) pc;
790 rq->cmd_type = REQ_TYPE_SPECIAL; 646 rq->cmd_type = REQ_TYPE_SPECIAL;
791 spin_unlock_irq(host->host_lock); 647 spin_unlock_irq(host->host_lock);
792 rq->rq_disk = scsi->disk; 648 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL);
793 (void) ide_do_drive_cmd (drive, rq, ide_end);
794 spin_lock_irq(host->host_lock); 649 spin_lock_irq(host->host_lock);
795 return 0; 650 return 0;
796abort: 651abort:
@@ -985,6 +840,8 @@ static int ide_scsi_probe(ide_drive_t *drive)
985 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) 840 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))
986 return -ENODEV; 841 return -ENODEV;
987 842
843 drive->scsi = 1;
844
988 g = alloc_disk(1 << PARTN_BITS); 845 g = alloc_disk(1 << PARTN_BITS);
989 if (!g) 846 if (!g)
990 goto out_host_put; 847 goto out_host_put;
@@ -993,10 +850,10 @@ static int ide_scsi_probe(ide_drive_t *drive)
993 850
994 host->max_id = 1; 851 host->max_id = 1;
995 852
996#if IDESCSI_DEBUG_LOG
997 if (drive->id->last_lun) 853 if (drive->id->last_lun)
998 printk(KERN_NOTICE "%s: id->last_lun=%u\n", drive->name, drive->id->last_lun); 854 debug_log("%s: id->last_lun=%u\n", drive->name,
999#endif 855 drive->id->last_lun);
856
1000 if ((drive->id->last_lun & 0x7) != 7) 857 if ((drive->id->last_lun & 0x7) != 7)
1001 host->max_lun = (drive->id->last_lun & 0x7) + 1; 858 host->max_lun = (drive->id->last_lun & 0x7) + 1;
1002 else 859 else
@@ -1025,6 +882,7 @@ static int ide_scsi_probe(ide_drive_t *drive)
1025 882
1026 put_disk(g); 883 put_disk(g);
1027out_host_put: 884out_host_put:
885 drive->scsi = 0;
1028 scsi_host_put(host); 886 scsi_host_put(host);
1029 return err; 887 return err;
1030} 888}
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 01cefbb2d53..d53312c4254 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1124,6 +1124,8 @@ sd_spinup_disk(struct scsi_disk *sdkp)
1124 cmd[1] = 1; /* Return immediately */ 1124 cmd[1] = 1; /* Return immediately */
1125 memset((void *) &cmd[2], 0, 8); 1125 memset((void *) &cmd[2], 0, 8);
1126 cmd[4] = 1; /* Start spin cycle */ 1126 cmd[4] = 1; /* Start spin cycle */
1127 if (sdkp->device->start_stop_pwr_cond)
1128 cmd[4] |= 1 << 4;
1127 scsi_execute_req(sdkp->device, cmd, DMA_NONE, 1129 scsi_execute_req(sdkp->device, cmd, DMA_NONE,
1128 NULL, 0, &sshdr, 1130 NULL, 0, &sshdr,
1129 SD_TIMEOUT, SD_MAX_RETRIES); 1131 SD_TIMEOUT, SD_MAX_RETRIES);
@@ -1790,6 +1792,9 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
1790 if (start) 1792 if (start)
1791 cmd[4] |= 1; /* START */ 1793 cmd[4] |= 1; /* START */
1792 1794
1795 if (sdp->start_stop_pwr_cond)
1796 cmd[4] |= start ? 1 << 4 : 3 << 4; /* Active or Standby */
1797
1793 if (!scsi_device_online(sdp)) 1798 if (!scsi_device_online(sdp))
1794 return -ENODEV; 1799 return -ENODEV;
1795 1800
diff --git a/drivers/video/fb_ddc.c b/drivers/video/fb_ddc.c
index a0df63289b5..0cf96eb8a60 100644
--- a/drivers/video/fb_ddc.c
+++ b/drivers/video/fb_ddc.c
@@ -106,6 +106,7 @@ unsigned char *fb_ddc_read(struct i2c_adapter *adapter)
106 algo_data->setsda(algo_data->data, 1); 106 algo_data->setsda(algo_data->data, 1);
107 algo_data->setscl(algo_data->data, 1); 107 algo_data->setscl(algo_data->data, 1);
108 108
109 adapter->class |= I2C_CLASS_DDC;
109 return edid; 110 return edid;
110} 111}
111 112
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index ca95f09d8b4..fcf9fadbf57 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -100,7 +100,8 @@ static int intelfb_gpio_getsda(void *data)
100 100
101static int intelfb_setup_i2c_bus(struct intelfb_info *dinfo, 101static int intelfb_setup_i2c_bus(struct intelfb_info *dinfo,
102 struct intelfb_i2c_chan *chan, 102 struct intelfb_i2c_chan *chan,
103 const u32 reg, const char *name) 103 const u32 reg, const char *name,
104 int class)
104{ 105{
105 int rc; 106 int rc;
106 107
@@ -108,6 +109,7 @@ static int intelfb_setup_i2c_bus(struct intelfb_info *dinfo,
108 chan->reg = reg; 109 chan->reg = reg;
109 snprintf(chan->adapter.name, sizeof(chan->adapter.name), 110 snprintf(chan->adapter.name, sizeof(chan->adapter.name),
110 "intelfb %s", name); 111 "intelfb %s", name);
112 chan->adapter.class = class;
111 chan->adapter.owner = THIS_MODULE; 113 chan->adapter.owner = THIS_MODULE;
112 chan->adapter.id = I2C_HW_B_INTELFB; 114 chan->adapter.id = I2C_HW_B_INTELFB;
113 chan->adapter.algo_data = &chan->algo; 115 chan->adapter.algo_data = &chan->algo;
@@ -145,7 +147,7 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
145 147
146 /* setup the DDC bus for analog output */ 148 /* setup the DDC bus for analog output */
147 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].ddc_bus, GPIOA, 149 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].ddc_bus, GPIOA,
148 "CRTDDC_A"); 150 "CRTDDC_A", I2C_CLASS_DDC);
149 i++; 151 i++;
150 152
151 /* need to add the output busses for each device 153 /* need to add the output busses for each device
@@ -159,9 +161,9 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
159 case INTEL_865G: 161 case INTEL_865G:
160 dinfo->output[i].type = INTELFB_OUTPUT_DVO; 162 dinfo->output[i].type = INTELFB_OUTPUT_DVO;
161 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].ddc_bus, 163 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].ddc_bus,
162 GPIOD, "DVODDC_D"); 164 GPIOD, "DVODDC_D", I2C_CLASS_DDC);
163 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus, 165 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus,
164 GPIOE, "DVOI2C_E"); 166 GPIOE, "DVOI2C_E", 0);
165 i++; 167 i++;
166 break; 168 break;
167 case INTEL_915G: 169 case INTEL_915G:
@@ -174,7 +176,7 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
174 /* SDVO ports have a single control bus - 2 devices */ 176 /* SDVO ports have a single control bus - 2 devices */
175 dinfo->output[i].type = INTELFB_OUTPUT_SDVO; 177 dinfo->output[i].type = INTELFB_OUTPUT_SDVO;
176 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus, 178 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus,
177 GPIOE, "SDVOCTRL_E"); 179 GPIOE, "SDVOCTRL_E", 0);
178 /* TODO: initialize the SDVO */ 180 /* TODO: initialize the SDVO */
179 /* I830SDVOInit(pScrn, i, DVOB); */ 181 /* I830SDVOInit(pScrn, i, DVOB); */
180 i++; 182 i++;
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index 4baab7be58d..75ee5a12e54 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -104,7 +104,9 @@ static struct i2c_algo_bit_data matrox_i2c_algo_template =
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,
107 unsigned int data, unsigned int clock, const char* name) { 107 unsigned int data, unsigned int clock, const char *name,
108 int class)
109{
108 int err; 110 int err;
109 111
110 b->minfo = minfo; 112 b->minfo = minfo;
@@ -114,6 +116,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo,
114 snprintf(b->adapter.name, sizeof(b->adapter.name), name, 116 snprintf(b->adapter.name, sizeof(b->adapter.name), name,
115 minfo->fbcon.node); 117 minfo->fbcon.node);
116 i2c_set_adapdata(&b->adapter, b); 118 i2c_set_adapdata(&b->adapter, b);
119 b->adapter.class = class;
117 b->adapter.algo_data = &b->bac; 120 b->adapter.algo_data = &b->bac;
118 b->adapter.dev.parent = &ACCESS_FBINFO(pcidev)->dev; 121 b->adapter.dev.parent = &ACCESS_FBINFO(pcidev)->dev;
119 b->bac = matrox_i2c_algo_template; 122 b->bac = matrox_i2c_algo_template;
@@ -159,22 +162,29 @@ static void* i2c_matroxfb_probe(struct matrox_fb_info* minfo) {
159 switch (ACCESS_FBINFO(chip)) { 162 switch (ACCESS_FBINFO(chip)) {
160 case MGA_2064: 163 case MGA_2064:
161 case MGA_2164: 164 case MGA_2164:
162 err = i2c_bus_reg(&m2info->ddc1, minfo, DDC1B_DATA, DDC1B_CLK, "DDC:fb%u #0"); 165 err = i2c_bus_reg(&m2info->ddc1, minfo,
166 DDC1B_DATA, DDC1B_CLK,
167 "DDC:fb%u #0", I2C_CLASS_DDC);
163 break; 168 break;
164 default: 169 default:
165 err = i2c_bus_reg(&m2info->ddc1, minfo, DDC1_DATA, DDC1_CLK, "DDC:fb%u #0"); 170 err = i2c_bus_reg(&m2info->ddc1, minfo,
171 DDC1_DATA, DDC1_CLK,
172 "DDC:fb%u #0", I2C_CLASS_DDC);
166 break; 173 break;
167 } 174 }
168 if (err) 175 if (err)
169 goto fail_ddc1; 176 goto fail_ddc1;
170 if (ACCESS_FBINFO(devflags.dualhead)) { 177 if (ACCESS_FBINFO(devflags.dualhead)) {
171 err = i2c_bus_reg(&m2info->ddc2, minfo, DDC2_DATA, DDC2_CLK, "DDC:fb%u #1"); 178 err = i2c_bus_reg(&m2info->ddc2, minfo,
179 DDC2_DATA, DDC2_CLK,
180 "DDC:fb%u #1", I2C_CLASS_DDC);
172 if (err == -ENODEV) { 181 if (err == -ENODEV) {
173 printk(KERN_INFO "i2c-matroxfb: VGA->TV plug detected, DDC unavailable.\n"); 182 printk(KERN_INFO "i2c-matroxfb: VGA->TV plug detected, DDC unavailable.\n");
174 } else if (err) 183 } else if (err)
175 printk(KERN_INFO "i2c-matroxfb: Could not register secondary output i2c bus. Continuing anyway.\n"); 184 printk(KERN_INFO "i2c-matroxfb: Could not register secondary output i2c bus. Continuing anyway.\n");
176 /* Register maven bus even on G450/G550 */ 185 /* Register maven bus even on G450/G550 */
177 err = i2c_bus_reg(&m2info->maven, minfo, MAT_DATA, MAT_CLK, "MAVEN:fb%u"); 186 err = i2c_bus_reg(&m2info->maven, minfo,
187 MAT_DATA, MAT_CLK, "MAVEN:fb%u", 0);
178 if (err) 188 if (err)
179 printk(KERN_INFO "i2c-matroxfb: Could not register Maven i2c bus. Continuing anyway.\n"); 189 printk(KERN_INFO "i2c-matroxfb: Could not register Maven i2c bus. Continuing anyway.\n");
180 } 190 }
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
index c1ba0db4850..770824458d4 100644
--- a/drivers/watchdog/booke_wdt.c
+++ b/drivers/watchdog/booke_wdt.c
@@ -55,7 +55,7 @@ static void __booke_wdt_ping(void *data)
55 55
56static void booke_wdt_ping(void) 56static void booke_wdt_ping(void)
57{ 57{
58 on_each_cpu(__booke_wdt_ping, NULL, 0, 0); 58 on_each_cpu(__booke_wdt_ping, NULL, 0);
59} 59}
60 60
61static void __booke_wdt_enable(void *data) 61static void __booke_wdt_enable(void *data)
@@ -131,7 +131,7 @@ static int booke_wdt_open(struct inode *inode, struct file *file)
131 spin_lock(&booke_wdt_lock); 131 spin_lock(&booke_wdt_lock);
132 if (booke_wdt_enabled == 0) { 132 if (booke_wdt_enabled == 0) {
133 booke_wdt_enabled = 1; 133 booke_wdt_enabled = 1;
134 on_each_cpu(__booke_wdt_enable, NULL, 0, 0); 134 on_each_cpu(__booke_wdt_enable, NULL, 0);
135 printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " 135 printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled "
136 "(wdt_period=%d)\n", booke_wdt_period); 136 "(wdt_period=%d)\n", booke_wdt_period);
137 } 137 }
@@ -177,7 +177,7 @@ static int __init booke_wdt_init(void)
177 if (booke_wdt_enabled == 1) { 177 if (booke_wdt_enabled == 1) {
178 printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled " 178 printk(KERN_INFO "PowerPC Book-E Watchdog Timer Enabled "
179 "(wdt_period=%d)\n", booke_wdt_period); 179 "(wdt_period=%d)\n", booke_wdt_period);
180 on_each_cpu(__booke_wdt_enable, NULL, 0, 0); 180 on_each_cpu(__booke_wdt_enable, NULL, 0);
181 } 181 }
182 spin_unlock(&booke_wdt_lock); 182 spin_unlock(&booke_wdt_lock);
183 183
diff --git a/firmware/Makefile b/firmware/Makefile
index 10028ace2de..e4f2fb3d191 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -34,8 +34,6 @@ fw-shipped-$(CONFIG_SND_SB16_CSP) += sb16/mulaw_main.csp sb16/alaw_main.csp \
34 sb16/ima_adpcm_capture.csp 34 sb16/ima_adpcm_capture.csp
35fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \ 35fw-shipped-$(CONFIG_SND_YMFPCI) += yamaha/ds1_ctrl.fw yamaha/ds1_dsp.fw \
36 yamaha/ds1e_ctrl.fw 36 yamaha/ds1e_ctrl.fw
37fw-shipped-$(CONFIG_TIGON3) += tigon/tg3.bin tigon/tg3_tso.bin \
38 tigon/tg3_tso5.bin
39fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin 37fw-shipped-$(CONFIG_USB_DABUSB) += dabusb/firmware.fw dabusb/bitstream.bin
40fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \ 38fw-shipped-$(CONFIG_USB_EMI26) += emi26/loader.fw emi26/firmware.fw \
41 emi26/bitstream.fw 39 emi26/bitstream.fw
@@ -136,7 +134,7 @@ $(patsubst %,$(obj)/%.gen.S, $(fw-shipped-y)): %: $(wordsize_deps) \
136 | $(objtree)/$$(dir %) 134 | $(objtree)/$$(dir %)
137 $(call cmd,fwbin,$(patsubst %.gen.S,%,$@)) 135 $(call cmd,fwbin,$(patsubst %.gen.S,%,$@))
138$(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \ 136$(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \
139 include/config/builtin/firmware/dir.h | $(objtree)/$$(dir %) 137 include/config/extra/firmware/dir.h | $(objtree)/$$(dir %)
140 $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@)) 138 $(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@))
141 139
142# The .o files depend on the binaries directly; the .S files don't. 140# The .o files depend on the binaries directly; the .S files don't.
diff --git a/fs/buffer.c b/fs/buffer.c
index 0f51c0f7c26..d48caee12e2 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1464,7 +1464,7 @@ static void invalidate_bh_lru(void *arg)
1464 1464
1465void invalidate_bh_lrus(void) 1465void invalidate_bh_lrus(void)
1466{ 1466{
1467 on_each_cpu(invalidate_bh_lru, NULL, 1, 1); 1467 on_each_cpu(invalidate_bh_lru, NULL, 1);
1468} 1468}
1469EXPORT_SYMBOL_GPL(invalidate_bh_lrus); 1469EXPORT_SYMBOL_GPL(invalidate_bh_lrus);
1470 1470
@@ -1691,11 +1691,13 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1691 */ 1691 */
1692 clear_buffer_dirty(bh); 1692 clear_buffer_dirty(bh);
1693 set_buffer_uptodate(bh); 1693 set_buffer_uptodate(bh);
1694 } else if (!buffer_mapped(bh) && buffer_dirty(bh)) { 1694 } else if ((!buffer_mapped(bh) || buffer_delay(bh)) &&
1695 buffer_dirty(bh)) {
1695 WARN_ON(bh->b_size != blocksize); 1696 WARN_ON(bh->b_size != blocksize);
1696 err = get_block(inode, block, bh, 1); 1697 err = get_block(inode, block, bh, 1);
1697 if (err) 1698 if (err)
1698 goto recover; 1699 goto recover;
1700 clear_buffer_delay(bh);
1699 if (buffer_new(bh)) { 1701 if (buffer_new(bh)) {
1700 /* blockdev mappings never come here */ 1702 /* blockdev mappings never come here */
1701 clear_buffer_new(bh); 1703 clear_buffer_new(bh);
@@ -1774,7 +1776,8 @@ recover:
1774 bh = head; 1776 bh = head;
1775 /* Recovery: lock and submit the mapped buffers */ 1777 /* Recovery: lock and submit the mapped buffers */
1776 do { 1778 do {
1777 if (buffer_mapped(bh) && buffer_dirty(bh)) { 1779 if (buffer_mapped(bh) && buffer_dirty(bh) &&
1780 !buffer_delay(bh)) {
1778 lock_buffer(bh); 1781 lock_buffer(bh);
1779 mark_buffer_async_write(bh); 1782 mark_buffer_async_write(bh);
1780 } else { 1783 } else {
@@ -2061,6 +2064,7 @@ int generic_write_end(struct file *file, struct address_space *mapping,
2061 struct page *page, void *fsdata) 2064 struct page *page, void *fsdata)
2062{ 2065{
2063 struct inode *inode = mapping->host; 2066 struct inode *inode = mapping->host;
2067 int i_size_changed = 0;
2064 2068
2065 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata); 2069 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
2066 2070
@@ -2073,12 +2077,21 @@ int generic_write_end(struct file *file, struct address_space *mapping,
2073 */ 2077 */
2074 if (pos+copied > inode->i_size) { 2078 if (pos+copied > inode->i_size) {
2075 i_size_write(inode, pos+copied); 2079 i_size_write(inode, pos+copied);
2076 mark_inode_dirty(inode); 2080 i_size_changed = 1;
2077 } 2081 }
2078 2082
2079 unlock_page(page); 2083 unlock_page(page);
2080 page_cache_release(page); 2084 page_cache_release(page);
2081 2085
2086 /*
2087 * Don't mark the inode dirty under page lock. First, it unnecessarily
2088 * makes the holding time of page lock longer. Second, it forces lock
2089 * ordering of page lock and transaction start for journaling
2090 * filesystems.
2091 */
2092 if (i_size_changed)
2093 mark_inode_dirty(inode);
2094
2082 return copied; 2095 return copied;
2083} 2096}
2084EXPORT_SYMBOL(generic_write_end); 2097EXPORT_SYMBOL(generic_write_end);
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 9cc80b9cc8d..495ab21b983 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -47,7 +47,7 @@ static int ext4_block_in_group(struct super_block *sb, ext4_fsblk_t block,
47 ext4_group_t block_group) 47 ext4_group_t block_group)
48{ 48{
49 ext4_group_t actual_group; 49 ext4_group_t actual_group;
50 ext4_get_group_no_and_offset(sb, block, &actual_group, 0); 50 ext4_get_group_no_and_offset(sb, block, &actual_group, NULL);
51 if (actual_group == block_group) 51 if (actual_group == block_group)
52 return 1; 52 return 1;
53 return 0; 53 return 0;
@@ -121,12 +121,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
121 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks); 121 le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks);
122 } 122 }
123 } else { /* For META_BG_BLOCK_GROUPS */ 123 } else { /* For META_BG_BLOCK_GROUPS */
124 int group_rel = (block_group - 124 bit_max += ext4_bg_num_gdb(sb, block_group);
125 le32_to_cpu(sbi->s_es->s_first_meta_bg)) %
126 EXT4_DESC_PER_BLOCK(sb);
127 if (group_rel == 0 || group_rel == 1 ||
128 (group_rel == EXT4_DESC_PER_BLOCK(sb) - 1))
129 bit_max += 1;
130 } 125 }
131 126
132 if (block_group == sbi->s_groups_count - 1) { 127 if (block_group == sbi->s_groups_count - 1) {
@@ -295,7 +290,7 @@ err_out:
295 return 0; 290 return 0;
296} 291}
297/** 292/**
298 * read_block_bitmap() 293 * ext4_read_block_bitmap()
299 * @sb: super block 294 * @sb: super block
300 * @block_group: given block group 295 * @block_group: given block group
301 * 296 *
@@ -305,7 +300,7 @@ err_out:
305 * Return buffer_head on success or NULL in case of failure. 300 * Return buffer_head on success or NULL in case of failure.
306 */ 301 */
307struct buffer_head * 302struct buffer_head *
308read_block_bitmap(struct super_block *sb, ext4_group_t block_group) 303ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
309{ 304{
310 struct ext4_group_desc * desc; 305 struct ext4_group_desc * desc;
311 struct buffer_head * bh = NULL; 306 struct buffer_head * bh = NULL;
@@ -409,8 +404,7 @@ restart:
409 prev = rsv; 404 prev = rsv;
410 } 405 }
411 printk("Window map complete.\n"); 406 printk("Window map complete.\n");
412 if (bad) 407 BUG_ON(bad);
413 BUG();
414} 408}
415#define rsv_window_dump(root, verbose) \ 409#define rsv_window_dump(root, verbose) \
416 __rsv_window_dump((root), (verbose), __func__) 410 __rsv_window_dump((root), (verbose), __func__)
@@ -694,7 +688,7 @@ do_more:
694 count -= overflow; 688 count -= overflow;
695 } 689 }
696 brelse(bitmap_bh); 690 brelse(bitmap_bh);
697 bitmap_bh = read_block_bitmap(sb, block_group); 691 bitmap_bh = ext4_read_block_bitmap(sb, block_group);
698 if (!bitmap_bh) 692 if (!bitmap_bh)
699 goto error_return; 693 goto error_return;
700 desc = ext4_get_group_desc (sb, block_group, &gd_bh); 694 desc = ext4_get_group_desc (sb, block_group, &gd_bh);
@@ -810,6 +804,13 @@ do_more:
810 spin_unlock(sb_bgl_lock(sbi, block_group)); 804 spin_unlock(sb_bgl_lock(sbi, block_group));
811 percpu_counter_add(&sbi->s_freeblocks_counter, count); 805 percpu_counter_add(&sbi->s_freeblocks_counter, count);
812 806
807 if (sbi->s_log_groups_per_flex) {
808 ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
809 spin_lock(sb_bgl_lock(sbi, flex_group));
810 sbi->s_flex_groups[flex_group].free_blocks += count;
811 spin_unlock(sb_bgl_lock(sbi, flex_group));
812 }
813
813 /* We dirtied the bitmap block */ 814 /* We dirtied the bitmap block */
814 BUFFER_TRACE(bitmap_bh, "dirtied bitmap block"); 815 BUFFER_TRACE(bitmap_bh, "dirtied bitmap block");
815 err = ext4_journal_dirty_metadata(handle, bitmap_bh); 816 err = ext4_journal_dirty_metadata(handle, bitmap_bh);
@@ -1598,23 +1599,35 @@ out:
1598 1599
1599/** 1600/**
1600 * ext4_has_free_blocks() 1601 * ext4_has_free_blocks()
1601 * @sbi: in-core super block structure. 1602 * @sbi: in-core super block structure.
1603 * @nblocks: number of neeed blocks
1602 * 1604 *
1603 * Check if filesystem has at least 1 free block available for allocation. 1605 * Check if filesystem has free blocks available for allocation.
1606 * Return the number of blocks avaible for allocation for this request
1607 * On success, return nblocks
1604 */ 1608 */
1605static int ext4_has_free_blocks(struct ext4_sb_info *sbi) 1609ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
1610 ext4_fsblk_t nblocks)
1606{ 1611{
1607 ext4_fsblk_t free_blocks, root_blocks; 1612 ext4_fsblk_t free_blocks;
1613 ext4_fsblk_t root_blocks = 0;
1608 1614
1609 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); 1615 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
1610 root_blocks = ext4_r_blocks_count(sbi->s_es); 1616
1611 if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) && 1617 if (!capable(CAP_SYS_RESOURCE) &&
1612 sbi->s_resuid != current->fsuid && 1618 sbi->s_resuid != current->fsuid &&
1613 (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) { 1619 (sbi->s_resgid == 0 || !in_group_p(sbi->s_resgid)))
1614 return 0; 1620 root_blocks = ext4_r_blocks_count(sbi->s_es);
1615 } 1621#ifdef CONFIG_SMP
1616 return 1; 1622 if (free_blocks - root_blocks < FBC_BATCH)
1617} 1623 free_blocks =
1624 percpu_counter_sum_and_set(&sbi->s_freeblocks_counter);
1625#endif
1626 if (free_blocks - root_blocks < nblocks)
1627 return free_blocks - root_blocks;
1628 return nblocks;
1629 }
1630
1618 1631
1619/** 1632/**
1620 * ext4_should_retry_alloc() 1633 * ext4_should_retry_alloc()
@@ -1630,7 +1643,7 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi)
1630 */ 1643 */
1631int ext4_should_retry_alloc(struct super_block *sb, int *retries) 1644int ext4_should_retry_alloc(struct super_block *sb, int *retries)
1632{ 1645{
1633 if (!ext4_has_free_blocks(EXT4_SB(sb)) || (*retries)++ > 3) 1646 if (!ext4_has_free_blocks(EXT4_SB(sb), 1) || (*retries)++ > 3)
1634 return 0; 1647 return 0;
1635 1648
1636 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); 1649 jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);
@@ -1639,20 +1652,24 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)
1639} 1652}
1640 1653
1641/** 1654/**
1642 * ext4_new_blocks_old() -- core block(s) allocation function 1655 * ext4_old_new_blocks() -- core block bitmap based block allocation function
1656 *
1643 * @handle: handle to this transaction 1657 * @handle: handle to this transaction
1644 * @inode: file inode 1658 * @inode: file inode
1645 * @goal: given target block(filesystem wide) 1659 * @goal: given target block(filesystem wide)
1646 * @count: target number of blocks to allocate 1660 * @count: target number of blocks to allocate
1647 * @errp: error code 1661 * @errp: error code
1648 * 1662 *
1649 * ext4_new_blocks uses a goal block to assist allocation. It tries to 1663 * ext4_old_new_blocks uses a goal block to assist allocation and look up
1650 * allocate block(s) from the block group contains the goal block first. If that 1664 * the block bitmap directly to do block allocation. It tries to
1651 * fails, it will try to allocate block(s) from other block groups without 1665 * allocate block(s) from the block group contains the goal block first. If
1652 * any specific goal block. 1666 * that fails, it will try to allocate block(s) from other block groups
1667 * without any specific goal block.
1668 *
1669 * This function is called when -o nomballoc mount option is enabled
1653 * 1670 *
1654 */ 1671 */
1655ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode, 1672ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode,
1656 ext4_fsblk_t goal, unsigned long *count, int *errp) 1673 ext4_fsblk_t goal, unsigned long *count, int *errp)
1657{ 1674{
1658 struct buffer_head *bitmap_bh = NULL; 1675 struct buffer_head *bitmap_bh = NULL;
@@ -1676,13 +1693,26 @@ ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode,
1676 ext4_group_t ngroups; 1693 ext4_group_t ngroups;
1677 unsigned long num = *count; 1694 unsigned long num = *count;
1678 1695
1679 *errp = -ENOSPC;
1680 sb = inode->i_sb; 1696 sb = inode->i_sb;
1681 if (!sb) { 1697 if (!sb) {
1698 *errp = -ENODEV;
1682 printk("ext4_new_block: nonexistent device"); 1699 printk("ext4_new_block: nonexistent device");
1683 return 0; 1700 return 0;
1684 } 1701 }
1685 1702
1703 sbi = EXT4_SB(sb);
1704 if (!EXT4_I(inode)->i_delalloc_reserved_flag) {
1705 /*
1706 * With delalloc we already reserved the blocks
1707 */
1708 *count = ext4_has_free_blocks(sbi, *count);
1709 }
1710 if (*count == 0) {
1711 *errp = -ENOSPC;
1712 return 0; /*return with ENOSPC error */
1713 }
1714 num = *count;
1715
1686 /* 1716 /*
1687 * Check quota for allocation of this block. 1717 * Check quota for allocation of this block.
1688 */ 1718 */
@@ -1706,11 +1736,6 @@ ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode,
1706 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0)) 1736 if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0))
1707 my_rsv = &block_i->rsv_window_node; 1737 my_rsv = &block_i->rsv_window_node;
1708 1738
1709 if (!ext4_has_free_blocks(sbi)) {
1710 *errp = -ENOSPC;
1711 goto out;
1712 }
1713
1714 /* 1739 /*
1715 * First, test whether the goal block is free. 1740 * First, test whether the goal block is free.
1716 */ 1741 */
@@ -1734,7 +1759,7 @@ retry_alloc:
1734 my_rsv = NULL; 1759 my_rsv = NULL;
1735 1760
1736 if (free_blocks > 0) { 1761 if (free_blocks > 0) {
1737 bitmap_bh = read_block_bitmap(sb, group_no); 1762 bitmap_bh = ext4_read_block_bitmap(sb, group_no);
1738 if (!bitmap_bh) 1763 if (!bitmap_bh)
1739 goto io_error; 1764 goto io_error;
1740 grp_alloc_blk = ext4_try_to_allocate_with_rsv(sb, handle, 1765 grp_alloc_blk = ext4_try_to_allocate_with_rsv(sb, handle,
@@ -1770,7 +1795,7 @@ retry_alloc:
1770 continue; 1795 continue;
1771 1796
1772 brelse(bitmap_bh); 1797 brelse(bitmap_bh);
1773 bitmap_bh = read_block_bitmap(sb, group_no); 1798 bitmap_bh = ext4_read_block_bitmap(sb, group_no);
1774 if (!bitmap_bh) 1799 if (!bitmap_bh)
1775 goto io_error; 1800 goto io_error;
1776 /* 1801 /*
@@ -1882,7 +1907,15 @@ allocated:
1882 le16_add_cpu(&gdp->bg_free_blocks_count, -num); 1907 le16_add_cpu(&gdp->bg_free_blocks_count, -num);
1883 gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp); 1908 gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp);
1884 spin_unlock(sb_bgl_lock(sbi, group_no)); 1909 spin_unlock(sb_bgl_lock(sbi, group_no));
1885 percpu_counter_sub(&sbi->s_freeblocks_counter, num); 1910 if (!EXT4_I(inode)->i_delalloc_reserved_flag)
1911 percpu_counter_sub(&sbi->s_freeblocks_counter, num);
1912
1913 if (sbi->s_log_groups_per_flex) {
1914 ext4_group_t flex_group = ext4_flex_group(sbi, group_no);
1915 spin_lock(sb_bgl_lock(sbi, flex_group));
1916 sbi->s_flex_groups[flex_group].free_blocks -= num;
1917 spin_unlock(sb_bgl_lock(sbi, flex_group));
1918 }
1886 1919
1887 BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor"); 1920 BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
1888 err = ext4_journal_dirty_metadata(handle, gdp_bh); 1921 err = ext4_journal_dirty_metadata(handle, gdp_bh);
@@ -1915,46 +1948,104 @@ out:
1915 return 0; 1948 return 0;
1916} 1949}
1917 1950
1918ext4_fsblk_t ext4_new_block(handle_t *handle, struct inode *inode, 1951#define EXT4_META_BLOCK 0x1
1919 ext4_fsblk_t goal, int *errp) 1952
1953static ext4_fsblk_t do_blk_alloc(handle_t *handle, struct inode *inode,
1954 ext4_lblk_t iblock, ext4_fsblk_t goal,
1955 unsigned long *count, int *errp, int flags)
1920{ 1956{
1921 struct ext4_allocation_request ar; 1957 struct ext4_allocation_request ar;
1922 ext4_fsblk_t ret; 1958 ext4_fsblk_t ret;
1923 1959
1924 if (!test_opt(inode->i_sb, MBALLOC)) { 1960 if (!test_opt(inode->i_sb, MBALLOC)) {
1925 unsigned long count = 1; 1961 return ext4_old_new_blocks(handle, inode, goal, count, errp);
1926 ret = ext4_new_blocks_old(handle, inode, goal, &count, errp);
1927 return ret;
1928 } 1962 }
1929 1963
1930 memset(&ar, 0, sizeof(ar)); 1964 memset(&ar, 0, sizeof(ar));
1965 /* Fill with neighbour allocated blocks */
1966
1931 ar.inode = inode; 1967 ar.inode = inode;
1932 ar.goal = goal; 1968 ar.goal = goal;
1933 ar.len = 1; 1969 ar.len = *count;
1970 ar.logical = iblock;
1971
1972 if (S_ISREG(inode->i_mode) && !(flags & EXT4_META_BLOCK))
1973 /* enable in-core preallocation for data block allocation */
1974 ar.flags = EXT4_MB_HINT_DATA;
1975 else
1976 /* disable in-core preallocation for non-regular files */
1977 ar.flags = 0;
1978
1934 ret = ext4_mb_new_blocks(handle, &ar, errp); 1979 ret = ext4_mb_new_blocks(handle, &ar, errp);
1980 *count = ar.len;
1935 return ret; 1981 return ret;
1936} 1982}
1937 1983
1938ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode, 1984/*
1985 * ext4_new_meta_blocks() -- allocate block for meta data (indexing) blocks
1986 *
1987 * @handle: handle to this transaction
1988 * @inode: file inode
1989 * @goal: given target block(filesystem wide)
1990 * @count: total number of blocks need
1991 * @errp: error code
1992 *
1993 * Return 1st allocated block numberon success, *count stores total account
1994 * error stores in errp pointer
1995 */
1996ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
1939 ext4_fsblk_t goal, unsigned long *count, int *errp) 1997 ext4_fsblk_t goal, unsigned long *count, int *errp)
1940{ 1998{
1941 struct ext4_allocation_request ar;
1942 ext4_fsblk_t ret; 1999 ext4_fsblk_t ret;
1943 2000 ret = do_blk_alloc(handle, inode, 0, goal,
1944 if (!test_opt(inode->i_sb, MBALLOC)) { 2001 count, errp, EXT4_META_BLOCK);
1945 ret = ext4_new_blocks_old(handle, inode, goal, count, errp); 2002 /*
1946 return ret; 2003 * Account for the allocated meta blocks
2004 */
2005 if (!(*errp)) {
2006 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
2007 EXT4_I(inode)->i_allocated_meta_blocks += *count;
2008 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1947 } 2009 }
1948
1949 memset(&ar, 0, sizeof(ar));
1950 ar.inode = inode;
1951 ar.goal = goal;
1952 ar.len = *count;
1953 ret = ext4_mb_new_blocks(handle, &ar, errp);
1954 *count = ar.len;
1955 return ret; 2010 return ret;
1956} 2011}
1957 2012
2013/*
2014 * ext4_new_meta_block() -- allocate block for meta data (indexing) blocks
2015 *
2016 * @handle: handle to this transaction
2017 * @inode: file inode
2018 * @goal: given target block(filesystem wide)
2019 * @errp: error code
2020 *
2021 * Return allocated block number on success
2022 */
2023ext4_fsblk_t ext4_new_meta_block(handle_t *handle, struct inode *inode,
2024 ext4_fsblk_t goal, int *errp)
2025{
2026 unsigned long count = 1;
2027 return ext4_new_meta_blocks(handle, inode, goal, &count, errp);
2028}
2029
2030/*
2031 * ext4_new_blocks() -- allocate data blocks
2032 *
2033 * @handle: handle to this transaction
2034 * @inode: file inode
2035 * @goal: given target block(filesystem wide)
2036 * @count: total number of blocks need
2037 * @errp: error code
2038 *
2039 * Return 1st allocated block numberon success, *count stores total account
2040 * error stores in errp pointer
2041 */
2042
2043ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
2044 ext4_lblk_t iblock, ext4_fsblk_t goal,
2045 unsigned long *count, int *errp)
2046{
2047 return do_blk_alloc(handle, inode, iblock, goal, count, errp, 0);
2048}
1958 2049
1959/** 2050/**
1960 * ext4_count_free_blocks() -- count filesystem free blocks 2051 * ext4_count_free_blocks() -- count filesystem free blocks
@@ -1986,7 +2077,7 @@ ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb)
1986 continue; 2077 continue;
1987 desc_count += le16_to_cpu(gdp->bg_free_blocks_count); 2078 desc_count += le16_to_cpu(gdp->bg_free_blocks_count);
1988 brelse(bitmap_bh); 2079 brelse(bitmap_bh);
1989 bitmap_bh = read_block_bitmap(sb, i); 2080 bitmap_bh = ext4_read_block_bitmap(sb, i);
1990 if (bitmap_bh == NULL) 2081 if (bitmap_bh == NULL)
1991 continue; 2082 continue;
1992 2083
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index 2bf0331ea19..d3d23d73c08 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -129,7 +129,8 @@ static int ext4_readdir(struct file * filp,
129 struct buffer_head *bh = NULL; 129 struct buffer_head *bh = NULL;
130 130
131 map_bh.b_state = 0; 131 map_bh.b_state = 0;
132 err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh, 0, 0); 132 err = ext4_get_blocks_wrap(NULL, inode, blk, 1, &map_bh,
133 0, 0, 0);
133 if (err > 0) { 134 if (err > 0) {
134 pgoff_t index = map_bh.b_blocknr >> 135 pgoff_t index = map_bh.b_blocknr >>
135 (PAGE_CACHE_SHIFT - inode->i_blkbits); 136 (PAGE_CACHE_SHIFT - inode->i_blkbits);
@@ -272,7 +273,7 @@ static void free_rb_tree_fname(struct rb_root *root)
272 273
273 while (n) { 274 while (n) {
274 /* Do the node's children first */ 275 /* Do the node's children first */
275 if ((n)->rb_left) { 276 if (n->rb_left) {
276 n = n->rb_left; 277 n = n->rb_left;
277 continue; 278 continue;
278 } 279 }
@@ -301,24 +302,18 @@ static void free_rb_tree_fname(struct rb_root *root)
301 parent->rb_right = NULL; 302 parent->rb_right = NULL;
302 n = parent; 303 n = parent;
303 } 304 }
304 root->rb_node = NULL;
305} 305}
306 306
307 307
308static struct dir_private_info *create_dir_info(loff_t pos) 308static struct dir_private_info *ext4_htree_create_dir_info(loff_t pos)
309{ 309{
310 struct dir_private_info *p; 310 struct dir_private_info *p;
311 311
312 p = kmalloc(sizeof(struct dir_private_info), GFP_KERNEL); 312 p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
313 if (!p) 313 if (!p)
314 return NULL; 314 return NULL;
315 p->root.rb_node = NULL;
316 p->curr_node = NULL;
317 p->extra_fname = NULL;
318 p->last_pos = 0;
319 p->curr_hash = pos2maj_hash(pos); 315 p->curr_hash = pos2maj_hash(pos);
320 p->curr_minor_hash = pos2min_hash(pos); 316 p->curr_minor_hash = pos2min_hash(pos);
321 p->next_hash = 0;
322 return p; 317 return p;
323} 318}
324 319
@@ -433,7 +428,7 @@ static int ext4_dx_readdir(struct file * filp,
433 int ret; 428 int ret;
434 429
435 if (!info) { 430 if (!info) {
436 info = create_dir_info(filp->f_pos); 431 info = ext4_htree_create_dir_info(filp->f_pos);
437 if (!info) 432 if (!info)
438 return -ENOMEM; 433 return -ENOMEM;
439 filp->private_data = info; 434 filp->private_data = info;
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 8158083f7ac..303e41cf7b1 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -22,7 +22,7 @@
22#include "ext4_i.h" 22#include "ext4_i.h"
23 23
24/* 24/*
25 * The second extended filesystem constants/structures 25 * The fourth extended filesystem constants/structures
26 */ 26 */
27 27
28/* 28/*
@@ -45,7 +45,7 @@
45#define ext4_debug(f, a...) \ 45#define ext4_debug(f, a...) \
46 do { \ 46 do { \
47 printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \ 47 printk (KERN_DEBUG "EXT4-fs DEBUG (%s, %d): %s:", \
48 __FILE__, __LINE__, __FUNCTION__); \ 48 __FILE__, __LINE__, __func__); \
49 printk (KERN_DEBUG f, ## a); \ 49 printk (KERN_DEBUG f, ## a); \
50 } while (0) 50 } while (0)
51#else 51#else
@@ -74,6 +74,9 @@
74#define EXT4_MB_HINT_GOAL_ONLY 256 74#define EXT4_MB_HINT_GOAL_ONLY 256
75/* goal is meaningful */ 75/* goal is meaningful */
76#define EXT4_MB_HINT_TRY_GOAL 512 76#define EXT4_MB_HINT_TRY_GOAL 512
77/* blocks already pre-reserved by delayed allocation */
78#define EXT4_MB_DELALLOC_RESERVED 1024
79
77 80
78struct ext4_allocation_request { 81struct ext4_allocation_request {
79 /* target inode for block we're allocating */ 82 /* target inode for block we're allocating */
@@ -170,6 +173,15 @@ struct ext4_group_desc
170 __u32 bg_reserved2[3]; 173 __u32 bg_reserved2[3];
171}; 174};
172 175
176/*
177 * Structure of a flex block group info
178 */
179
180struct flex_groups {
181 __u32 free_inodes;
182 __u32 free_blocks;
183};
184
173#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */ 185#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
174#define EXT4_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */ 186#define EXT4_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not in use */
175#define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */ 187#define EXT4_BG_INODE_ZEROED 0x0004 /* On-disk itable initialized to zero */
@@ -527,6 +539,7 @@ do { \
527#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ 539#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
528#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */ 540#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
529#define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */ 541#define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
542#define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */
530/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */ 543/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
531#ifndef _LINUX_EXT2_FS_H 544#ifndef _LINUX_EXT2_FS_H
532#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt 545#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
@@ -647,7 +660,10 @@ struct ext4_super_block {
647 __le16 s_mmp_interval; /* # seconds to wait in MMP checking */ 660 __le16 s_mmp_interval; /* # seconds to wait in MMP checking */
648 __le64 s_mmp_block; /* Block for multi-mount protection */ 661 __le64 s_mmp_block; /* Block for multi-mount protection */
649 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/ 662 __le32 s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
650 __u32 s_reserved[163]; /* Padding to the end of the block */ 663 __u8 s_log_groups_per_flex; /* FLEX_BG group size */
664 __u8 s_reserved_char_pad2;
665 __le16 s_reserved_pad;
666 __u32 s_reserved[162]; /* Padding to the end of the block */
651}; 667};
652 668
653#ifdef __KERNEL__ 669#ifdef __KERNEL__
@@ -958,12 +974,17 @@ extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
958extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group); 974extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
959extern unsigned long ext4_bg_num_gdb(struct super_block *sb, 975extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
960 ext4_group_t group); 976 ext4_group_t group);
961extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode, 977extern ext4_fsblk_t ext4_new_meta_block(handle_t *handle, struct inode *inode,
962 ext4_fsblk_t goal, int *errp); 978 ext4_fsblk_t goal, int *errp);
963extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode, 979extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
964 ext4_fsblk_t goal, unsigned long *count, int *errp); 980 ext4_fsblk_t goal, unsigned long *count, int *errp);
965extern ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode, 981extern ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
982 ext4_lblk_t iblock, ext4_fsblk_t goal,
983 unsigned long *count, int *errp);
984extern ext4_fsblk_t ext4_old_new_blocks(handle_t *handle, struct inode *inode,
966 ext4_fsblk_t goal, unsigned long *count, int *errp); 985 ext4_fsblk_t goal, unsigned long *count, int *errp);
986extern ext4_fsblk_t ext4_has_free_blocks(struct ext4_sb_info *sbi,
987 ext4_fsblk_t nblocks);
967extern void ext4_free_blocks (handle_t *handle, struct inode *inode, 988extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
968 ext4_fsblk_t block, unsigned long count, int metadata); 989 ext4_fsblk_t block, unsigned long count, int metadata);
969extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb, 990extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
@@ -1016,9 +1037,14 @@ extern int __init init_ext4_mballoc(void);
1016extern void exit_ext4_mballoc(void); 1037extern void exit_ext4_mballoc(void);
1017extern void ext4_mb_free_blocks(handle_t *, struct inode *, 1038extern void ext4_mb_free_blocks(handle_t *, struct inode *,
1018 unsigned long, unsigned long, int, unsigned long *); 1039 unsigned long, unsigned long, int, unsigned long *);
1040extern int ext4_mb_add_more_groupinfo(struct super_block *sb,
1041 ext4_group_t i, struct ext4_group_desc *desc);
1042extern void ext4_mb_update_group_info(struct ext4_group_info *grp,
1043 ext4_grpblk_t add);
1019 1044
1020 1045
1021/* inode.c */ 1046/* inode.c */
1047void ext4_da_release_space(struct inode *inode, int used, int to_free);
1022int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, 1048int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
1023 struct buffer_head *bh, ext4_fsblk_t blocknr); 1049 struct buffer_head *bh, ext4_fsblk_t blocknr);
1024struct buffer_head *ext4_getblk(handle_t *, struct inode *, 1050struct buffer_head *ext4_getblk(handle_t *, struct inode *,
@@ -1033,19 +1059,23 @@ int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
1033extern struct inode *ext4_iget(struct super_block *, unsigned long); 1059extern struct inode *ext4_iget(struct super_block *, unsigned long);
1034extern int ext4_write_inode (struct inode *, int); 1060extern int ext4_write_inode (struct inode *, int);
1035extern int ext4_setattr (struct dentry *, struct iattr *); 1061extern int ext4_setattr (struct dentry *, struct iattr *);
1062extern int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
1063 struct kstat *stat);
1036extern void ext4_delete_inode (struct inode *); 1064extern void ext4_delete_inode (struct inode *);
1037extern int ext4_sync_inode (handle_t *, struct inode *); 1065extern int ext4_sync_inode (handle_t *, struct inode *);
1038extern void ext4_discard_reservation (struct inode *); 1066extern void ext4_discard_reservation (struct inode *);
1039extern void ext4_dirty_inode(struct inode *); 1067extern void ext4_dirty_inode(struct inode *);
1040extern int ext4_change_inode_journal_flag(struct inode *, int); 1068extern int ext4_change_inode_journal_flag(struct inode *, int);
1041extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); 1069extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
1070extern int ext4_can_truncate(struct inode *inode);
1042extern void ext4_truncate (struct inode *); 1071extern void ext4_truncate (struct inode *);
1043extern void ext4_set_inode_flags(struct inode *); 1072extern void ext4_set_inode_flags(struct inode *);
1044extern void ext4_get_inode_flags(struct ext4_inode_info *); 1073extern void ext4_get_inode_flags(struct ext4_inode_info *);
1045extern void ext4_set_aops(struct inode *inode); 1074extern void ext4_set_aops(struct inode *inode);
1046extern int ext4_writepage_trans_blocks(struct inode *); 1075extern int ext4_writepage_trans_blocks(struct inode *);
1047extern int ext4_block_truncate_page(handle_t *handle, struct page *page, 1076extern int ext4_block_truncate_page(handle_t *handle,
1048 struct address_space *mapping, loff_t from); 1077 struct address_space *mapping, loff_t from);
1078extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page);
1049 1079
1050/* ioctl.c */ 1080/* ioctl.c */
1051extern long ext4_ioctl(struct file *, unsigned int, unsigned long); 1081extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
@@ -1159,10 +1189,21 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
1159} 1189}
1160 1190
1161 1191
1192static inline ext4_group_t ext4_flex_group(struct ext4_sb_info *sbi,
1193 ext4_group_t block_group)
1194{
1195 return block_group >> sbi->s_log_groups_per_flex;
1196}
1197
1198static inline unsigned int ext4_flex_bg_size(struct ext4_sb_info *sbi)
1199{
1200 return 1 << sbi->s_log_groups_per_flex;
1201}
1202
1162#define ext4_std_error(sb, errno) \ 1203#define ext4_std_error(sb, errno) \
1163do { \ 1204do { \
1164 if ((errno)) \ 1205 if ((errno)) \
1165 __ext4_std_error((sb), __FUNCTION__, (errno)); \ 1206 __ext4_std_error((sb), __func__, (errno)); \
1166} while (0) 1207} while (0)
1167 1208
1168/* 1209/*
@@ -1191,7 +1232,7 @@ extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1191 ext4_lblk_t iblock, 1232 ext4_lblk_t iblock,
1192 unsigned long max_blocks, struct buffer_head *bh_result, 1233 unsigned long max_blocks, struct buffer_head *bh_result,
1193 int create, int extend_disksize); 1234 int create, int extend_disksize);
1194extern void ext4_ext_truncate(struct inode *, struct page *); 1235extern void ext4_ext_truncate(struct inode *);
1195extern void ext4_ext_init(struct super_block *); 1236extern void ext4_ext_init(struct super_block *);
1196extern void ext4_ext_release(struct super_block *); 1237extern void ext4_ext_release(struct super_block *);
1197extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, 1238extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
@@ -1199,7 +1240,7 @@ extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
1199extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, 1240extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
1200 sector_t block, unsigned long max_blocks, 1241 sector_t block, unsigned long max_blocks,
1201 struct buffer_head *bh, int create, 1242 struct buffer_head *bh, int create,
1202 int extend_disksize); 1243 int extend_disksize, int flag);
1203#endif /* __KERNEL__ */ 1244#endif /* __KERNEL__ */
1204 1245
1205#endif /* _EXT4_H */ 1246#endif /* _EXT4_H */
diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h
index 75333b595fa..6c166c0a54b 100644
--- a/fs/ext4/ext4_extents.h
+++ b/fs/ext4/ext4_extents.h
@@ -212,6 +212,7 @@ static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
212 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN)); 212 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
213} 213}
214 214
215extern int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks);
215extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *); 216extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
216extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t); 217extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
217extern int ext4_extent_tree_init(handle_t *, struct inode *); 218extern int ext4_extent_tree_init(handle_t *, struct inode *);
diff --git a/fs/ext4/ext4_i.h b/fs/ext4/ext4_i.h
index 26a4ae255d7..ef7409f0e7e 100644
--- a/fs/ext4/ext4_i.h
+++ b/fs/ext4/ext4_i.h
@@ -79,7 +79,7 @@ struct ext4_ext_cache {
79}; 79};
80 80
81/* 81/*
82 * third extended file system inode data in memory 82 * fourth extended file system inode data in memory
83 */ 83 */
84struct ext4_inode_info { 84struct ext4_inode_info {
85 __le32 i_data[15]; /* unconverted */ 85 __le32 i_data[15]; /* unconverted */
@@ -150,6 +150,7 @@ struct ext4_inode_info {
150 */ 150 */
151 struct rw_semaphore i_data_sem; 151 struct rw_semaphore i_data_sem;
152 struct inode vfs_inode; 152 struct inode vfs_inode;
153 struct jbd2_inode jinode;
153 154
154 unsigned long i_ext_generation; 155 unsigned long i_ext_generation;
155 struct ext4_ext_cache i_cached_extent; 156 struct ext4_ext_cache i_cached_extent;
@@ -162,6 +163,13 @@ struct ext4_inode_info {
162 /* mballoc */ 163 /* mballoc */
163 struct list_head i_prealloc_list; 164 struct list_head i_prealloc_list;
164 spinlock_t i_prealloc_lock; 165 spinlock_t i_prealloc_lock;
166
167 /* allocation reservation info for delalloc */
168 unsigned long i_reserved_data_blocks;
169 unsigned long i_reserved_meta_blocks;
170 unsigned long i_allocated_meta_blocks;
171 unsigned short i_delalloc_reserved_flag;
172 spinlock_t i_block_reservation_lock;
165}; 173};
166 174
167#endif /* _EXT4_I */ 175#endif /* _EXT4_I */
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
index 9255a7d28b2..eb8bc3afe6e 100644
--- a/fs/ext4/ext4_jbd2.h
+++ b/fs/ext4/ext4_jbd2.h
@@ -142,19 +142,17 @@ int __ext4_journal_dirty_metadata(const char *where,
142 handle_t *handle, struct buffer_head *bh); 142 handle_t *handle, struct buffer_head *bh);
143 143
144#define ext4_journal_get_undo_access(handle, bh) \ 144#define ext4_journal_get_undo_access(handle, bh) \
145 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 145 __ext4_journal_get_undo_access(__func__, (handle), (bh))
146#define ext4_journal_get_write_access(handle, bh) \ 146#define ext4_journal_get_write_access(handle, bh) \
147 __ext4_journal_get_write_access(__FUNCTION__, (handle), (bh)) 147 __ext4_journal_get_write_access(__func__, (handle), (bh))
148#define ext4_journal_revoke(handle, blocknr, bh) \ 148#define ext4_journal_revoke(handle, blocknr, bh) \
149 __ext4_journal_revoke(__FUNCTION__, (handle), (blocknr), (bh)) 149 __ext4_journal_revoke(__func__, (handle), (blocknr), (bh))
150#define ext4_journal_get_create_access(handle, bh) \ 150#define ext4_journal_get_create_access(handle, bh) \
151 __ext4_journal_get_create_access(__FUNCTION__, (handle), (bh)) 151 __ext4_journal_get_create_access(__func__, (handle), (bh))
152#define ext4_journal_dirty_metadata(handle, bh) \ 152#define ext4_journal_dirty_metadata(handle, bh) \
153 __ext4_journal_dirty_metadata(__FUNCTION__, (handle), (bh)) 153 __ext4_journal_dirty_metadata(__func__, (handle), (bh))
154#define ext4_journal_forget(handle, bh) \ 154#define ext4_journal_forget(handle, bh) \
155 __ext4_journal_forget(__FUNCTION__, (handle), (bh)) 155 __ext4_journal_forget(__func__, (handle), (bh))
156
157int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh);
158 156
159handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks); 157handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks);
160int __ext4_journal_stop(const char *where, handle_t *handle); 158int __ext4_journal_stop(const char *where, handle_t *handle);
@@ -165,7 +163,7 @@ static inline handle_t *ext4_journal_start(struct inode *inode, int nblocks)
165} 163}
166 164
167#define ext4_journal_stop(handle) \ 165#define ext4_journal_stop(handle) \
168 __ext4_journal_stop(__FUNCTION__, (handle)) 166 __ext4_journal_stop(__func__, (handle))
169 167
170static inline handle_t *ext4_journal_current_handle(void) 168static inline handle_t *ext4_journal_current_handle(void)
171{ 169{
@@ -192,6 +190,11 @@ static inline int ext4_journal_force_commit(journal_t *journal)
192 return jbd2_journal_force_commit(journal); 190 return jbd2_journal_force_commit(journal);
193} 191}
194 192
193static inline int ext4_jbd2_file_inode(handle_t *handle, struct inode *inode)
194{
195 return jbd2_journal_file_inode(handle, &EXT4_I(inode)->jinode);
196}
197
195/* super.c */ 198/* super.c */
196int ext4_force_commit(struct super_block *sb); 199int ext4_force_commit(struct super_block *sb);
197 200
diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h
index 5802e69f219..6300226d553 100644
--- a/fs/ext4/ext4_sb.h
+++ b/fs/ext4/ext4_sb.h
@@ -25,7 +25,7 @@
25#include <linux/rbtree.h> 25#include <linux/rbtree.h>
26 26
27/* 27/*
28 * third extended-fs super-block data in memory 28 * fourth extended-fs super-block data in memory
29 */ 29 */
30struct ext4_sb_info { 30struct ext4_sb_info {
31 unsigned long s_desc_size; /* Size of a group descriptor in bytes */ 31 unsigned long s_desc_size; /* Size of a group descriptor in bytes */
@@ -143,6 +143,9 @@ struct ext4_sb_info {
143 143
144 /* locality groups */ 144 /* locality groups */
145 struct ext4_locality_group *s_locality_groups; 145 struct ext4_locality_group *s_locality_groups;
146
147 unsigned int s_log_groups_per_flex;
148 struct flex_groups *s_flex_groups;
146}; 149};
147 150
148#endif /* _EXT4_SB */ 151#endif /* _EXT4_SB */
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 47929c4e3da..42c4c0c892e 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -92,17 +92,16 @@ static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); 92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
93} 93}
94 94
95static handle_t *ext4_ext_journal_restart(handle_t *handle, int needed) 95static int ext4_ext_journal_restart(handle_t *handle, int needed)
96{ 96{
97 int err; 97 int err;
98 98
99 if (handle->h_buffer_credits > needed) 99 if (handle->h_buffer_credits > needed)
100 return handle; 100 return 0;
101 if (!ext4_journal_extend(handle, needed)) 101 err = ext4_journal_extend(handle, needed);
102 return handle; 102 if (err)
103 err = ext4_journal_restart(handle, needed); 103 return err;
104 104 return ext4_journal_restart(handle, needed);
105 return handle;
106} 105}
107 106
108/* 107/*
@@ -180,15 +179,18 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
180 return bg_start + colour + block; 179 return bg_start + colour + block;
181} 180}
182 181
182/*
183 * Allocation for a meta data block
184 */
183static ext4_fsblk_t 185static ext4_fsblk_t
184ext4_ext_new_block(handle_t *handle, struct inode *inode, 186ext4_ext_new_meta_block(handle_t *handle, struct inode *inode,
185 struct ext4_ext_path *path, 187 struct ext4_ext_path *path,
186 struct ext4_extent *ex, int *err) 188 struct ext4_extent *ex, int *err)
187{ 189{
188 ext4_fsblk_t goal, newblock; 190 ext4_fsblk_t goal, newblock;
189 191
190 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); 192 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block));
191 newblock = ext4_new_block(handle, inode, goal, err); 193 newblock = ext4_new_meta_block(handle, inode, goal, err);
192 return newblock; 194 return newblock;
193} 195}
194 196
@@ -246,6 +248,36 @@ static int ext4_ext_space_root_idx(struct inode *inode)
246 return size; 248 return size;
247} 249}
248 250
251/*
252 * Calculate the number of metadata blocks needed
253 * to allocate @blocks
254 * Worse case is one block per extent
255 */
256int ext4_ext_calc_metadata_amount(struct inode *inode, int blocks)
257{
258 int lcap, icap, rcap, leafs, idxs, num;
259 int newextents = blocks;
260
261 rcap = ext4_ext_space_root_idx(inode);
262 lcap = ext4_ext_space_block(inode);
263 icap = ext4_ext_space_block_idx(inode);
264
265 /* number of new leaf blocks needed */
266 num = leafs = (newextents + lcap - 1) / lcap;
267
268 /*
269 * Worse case, we need separate index block(s)
270 * to link all new leaf blocks
271 */
272 idxs = (leafs + icap - 1) / icap;
273 do {
274 num += idxs;
275 idxs = (idxs + icap - 1) / icap;
276 } while (idxs > rcap);
277
278 return num;
279}
280
249static int 281static int
250ext4_ext_max_entries(struct inode *inode, int depth) 282ext4_ext_max_entries(struct inode *inode, int depth)
251{ 283{
@@ -524,6 +556,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
524 alloc = 1; 556 alloc = 1;
525 } 557 }
526 path[0].p_hdr = eh; 558 path[0].p_hdr = eh;
559 path[0].p_bh = NULL;
527 560
528 i = depth; 561 i = depth;
529 /* walk through the tree */ 562 /* walk through the tree */
@@ -552,12 +585,14 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
552 } 585 }
553 586
554 path[ppos].p_depth = i; 587 path[ppos].p_depth = i;
555 path[ppos].p_hdr = eh;
556 path[ppos].p_ext = NULL; 588 path[ppos].p_ext = NULL;
557 path[ppos].p_idx = NULL; 589 path[ppos].p_idx = NULL;
558 590
559 /* find extent */ 591 /* find extent */
560 ext4_ext_binsearch(inode, path + ppos, block); 592 ext4_ext_binsearch(inode, path + ppos, block);
593 /* if not an empty leaf */
594 if (path[ppos].p_ext)
595 path[ppos].p_block = ext_pblock(path[ppos].p_ext);
561 596
562 ext4_ext_show_path(inode, path); 597 ext4_ext_show_path(inode, path);
563 598
@@ -688,7 +723,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
688 /* allocate all needed blocks */ 723 /* allocate all needed blocks */
689 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at); 724 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
690 for (a = 0; a < depth - at; a++) { 725 for (a = 0; a < depth - at; a++) {
691 newblock = ext4_ext_new_block(handle, inode, path, newext, &err); 726 newblock = ext4_ext_new_meta_block(handle, inode, path,
727 newext, &err);
692 if (newblock == 0) 728 if (newblock == 0)
693 goto cleanup; 729 goto cleanup;
694 ablocks[a] = newblock; 730 ablocks[a] = newblock;
@@ -884,7 +920,7 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
884 ext4_fsblk_t newblock; 920 ext4_fsblk_t newblock;
885 int err = 0; 921 int err = 0;
886 922
887 newblock = ext4_ext_new_block(handle, inode, path, newext, &err); 923 newblock = ext4_ext_new_meta_block(handle, inode, path, newext, &err);
888 if (newblock == 0) 924 if (newblock == 0)
889 return err; 925 return err;
890 926
@@ -981,6 +1017,8 @@ repeat:
981 /* if we found index with free entry, then use that 1017 /* if we found index with free entry, then use that
982 * entry: create all needed subtree and add new leaf */ 1018 * entry: create all needed subtree and add new leaf */
983 err = ext4_ext_split(handle, inode, path, newext, i); 1019 err = ext4_ext_split(handle, inode, path, newext, i);
1020 if (err)
1021 goto out;
984 1022
985 /* refill path */ 1023 /* refill path */
986 ext4_ext_drop_refs(path); 1024 ext4_ext_drop_refs(path);
@@ -1883,11 +1921,9 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
1883 credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb); 1921 credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
1884#endif 1922#endif
1885 1923
1886 handle = ext4_ext_journal_restart(handle, credits); 1924 err = ext4_ext_journal_restart(handle, credits);
1887 if (IS_ERR(handle)) { 1925 if (err)
1888 err = PTR_ERR(handle);
1889 goto out; 1926 goto out;
1890 }
1891 1927
1892 err = ext4_ext_get_access(handle, inode, path + depth); 1928 err = ext4_ext_get_access(handle, inode, path + depth);
1893 if (err) 1929 if (err)
@@ -2529,6 +2565,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2529 int err = 0, depth, ret; 2565 int err = 0, depth, ret;
2530 unsigned long allocated = 0; 2566 unsigned long allocated = 0;
2531 struct ext4_allocation_request ar; 2567 struct ext4_allocation_request ar;
2568 loff_t disksize;
2532 2569
2533 __clear_bit(BH_New, &bh_result->b_state); 2570 __clear_bit(BH_New, &bh_result->b_state);
2534 ext_debug("blocks %u/%lu requested for inode %u\n", 2571 ext_debug("blocks %u/%lu requested for inode %u\n",
@@ -2616,8 +2653,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2616 */ 2653 */
2617 if (allocated > max_blocks) 2654 if (allocated > max_blocks)
2618 allocated = max_blocks; 2655 allocated = max_blocks;
2619 /* mark the buffer unwritten */ 2656 set_buffer_unwritten(bh_result);
2620 __set_bit(BH_Unwritten, &bh_result->b_state);
2621 goto out2; 2657 goto out2;
2622 } 2658 }
2623 2659
@@ -2716,14 +2752,19 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
2716 goto out2; 2752 goto out2;
2717 } 2753 }
2718 2754
2719 if (extend_disksize && inode->i_size > EXT4_I(inode)->i_disksize)
2720 EXT4_I(inode)->i_disksize = inode->i_size;
2721
2722 /* previous routine could use block we allocated */ 2755 /* previous routine could use block we allocated */
2723 newblock = ext_pblock(&newex); 2756 newblock = ext_pblock(&newex);
2724 allocated = ext4_ext_get_actual_len(&newex); 2757 allocated = ext4_ext_get_actual_len(&newex);
2725outnew: 2758outnew:
2726 __set_bit(BH_New, &bh_result->b_state); 2759 if (extend_disksize) {
2760 disksize = ((loff_t) iblock + ar.len) << inode->i_blkbits;
2761 if (disksize > i_size_read(inode))
2762 disksize = i_size_read(inode);
2763 if (disksize > EXT4_I(inode)->i_disksize)
2764 EXT4_I(inode)->i_disksize = disksize;
2765 }
2766
2767 set_buffer_new(bh_result);
2727 2768
2728 /* Cache only when it is _not_ an uninitialized extent */ 2769 /* Cache only when it is _not_ an uninitialized extent */
2729 if (create != EXT4_CREATE_UNINITIALIZED_EXT) 2770 if (create != EXT4_CREATE_UNINITIALIZED_EXT)
@@ -2733,7 +2774,7 @@ out:
2733 if (allocated > max_blocks) 2774 if (allocated > max_blocks)
2734 allocated = max_blocks; 2775 allocated = max_blocks;
2735 ext4_ext_show_leaf(inode, path); 2776 ext4_ext_show_leaf(inode, path);
2736 __set_bit(BH_Mapped, &bh_result->b_state); 2777 set_buffer_mapped(bh_result);
2737 bh_result->b_bdev = inode->i_sb->s_bdev; 2778 bh_result->b_bdev = inode->i_sb->s_bdev;
2738 bh_result->b_blocknr = newblock; 2779 bh_result->b_blocknr = newblock;
2739out2: 2780out2:
@@ -2744,7 +2785,7 @@ out2:
2744 return err ? err : allocated; 2785 return err ? err : allocated;
2745} 2786}
2746 2787
2747void ext4_ext_truncate(struct inode * inode, struct page *page) 2788void ext4_ext_truncate(struct inode *inode)
2748{ 2789{
2749 struct address_space *mapping = inode->i_mapping; 2790 struct address_space *mapping = inode->i_mapping;
2750 struct super_block *sb = inode->i_sb; 2791 struct super_block *sb = inode->i_sb;
@@ -2757,18 +2798,14 @@ void ext4_ext_truncate(struct inode * inode, struct page *page)
2757 */ 2798 */
2758 err = ext4_writepage_trans_blocks(inode) + 3; 2799 err = ext4_writepage_trans_blocks(inode) + 3;
2759 handle = ext4_journal_start(inode, err); 2800 handle = ext4_journal_start(inode, err);
2760 if (IS_ERR(handle)) { 2801 if (IS_ERR(handle))
2761 if (page) {
2762 clear_highpage(page);
2763 flush_dcache_page(page);
2764 unlock_page(page);
2765 page_cache_release(page);
2766 }
2767 return; 2802 return;
2768 }
2769 2803
2770 if (page) 2804 if (inode->i_size & (sb->s_blocksize - 1))
2771 ext4_block_truncate_page(handle, page, mapping, inode->i_size); 2805 ext4_block_truncate_page(handle, mapping, inode->i_size);
2806
2807 if (ext4_orphan_add(handle, inode))
2808 goto out_stop;
2772 2809
2773 down_write(&EXT4_I(inode)->i_data_sem); 2810 down_write(&EXT4_I(inode)->i_data_sem);
2774 ext4_ext_invalidate_cache(inode); 2811 ext4_ext_invalidate_cache(inode);
@@ -2780,8 +2817,6 @@ void ext4_ext_truncate(struct inode * inode, struct page *page)
2780 * Probably we need not scan at all, 2817 * Probably we need not scan at all,
2781 * because page truncation is enough. 2818 * because page truncation is enough.
2782 */ 2819 */
2783 if (ext4_orphan_add(handle, inode))
2784 goto out_stop;
2785 2820
2786 /* we have to know where to truncate from in crash case */ 2821 /* we have to know where to truncate from in crash case */
2787 EXT4_I(inode)->i_disksize = inode->i_size; 2822 EXT4_I(inode)->i_disksize = inode->i_size;
@@ -2798,6 +2833,7 @@ void ext4_ext_truncate(struct inode * inode, struct page *page)
2798 handle->h_sync = 1; 2833 handle->h_sync = 1;
2799 2834
2800out_stop: 2835out_stop:
2836 up_write(&EXT4_I(inode)->i_data_sem);
2801 /* 2837 /*
2802 * If this was a simple ftruncate() and the file will remain alive, 2838 * If this was a simple ftruncate() and the file will remain alive,
2803 * then we need to clear up the orphan record which we created above. 2839 * then we need to clear up the orphan record which we created above.
@@ -2808,7 +2844,6 @@ out_stop:
2808 if (inode->i_nlink) 2844 if (inode->i_nlink)
2809 ext4_orphan_del(handle, inode); 2845 ext4_orphan_del(handle, inode);
2810 2846
2811 up_write(&EXT4_I(inode)->i_data_sem);
2812 inode->i_mtime = inode->i_ctime = ext4_current_time(inode); 2847 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
2813 ext4_mark_inode_dirty(handle, inode); 2848 ext4_mark_inode_dirty(handle, inode);
2814 ext4_journal_stop(handle); 2849 ext4_journal_stop(handle);
@@ -2911,7 +2946,7 @@ retry:
2911 } 2946 }
2912 ret = ext4_get_blocks_wrap(handle, inode, block, 2947 ret = ext4_get_blocks_wrap(handle, inode, block,
2913 max_blocks, &map_bh, 2948 max_blocks, &map_bh,
2914 EXT4_CREATE_UNINITIALIZED_EXT, 0); 2949 EXT4_CREATE_UNINITIALIZED_EXT, 0, 0);
2915 if (ret <= 0) { 2950 if (ret <= 0) {
2916#ifdef EXT4FS_DEBUG 2951#ifdef EXT4FS_DEBUG
2917 WARN_ON(ret <= 0); 2952 WARN_ON(ret <= 0);
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 4159be6366a..430eb7978db 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -123,6 +123,23 @@ force_commit:
123 return ret; 123 return ret;
124} 124}
125 125
126static struct vm_operations_struct ext4_file_vm_ops = {
127 .fault = filemap_fault,
128 .page_mkwrite = ext4_page_mkwrite,
129};
130
131static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
132{
133 struct address_space *mapping = file->f_mapping;
134
135 if (!mapping->a_ops->readpage)
136 return -ENOEXEC;
137 file_accessed(file);
138 vma->vm_ops = &ext4_file_vm_ops;
139 vma->vm_flags |= VM_CAN_NONLINEAR;
140 return 0;
141}
142
126const struct file_operations ext4_file_operations = { 143const struct file_operations ext4_file_operations = {
127 .llseek = generic_file_llseek, 144 .llseek = generic_file_llseek,
128 .read = do_sync_read, 145 .read = do_sync_read,
@@ -133,7 +150,7 @@ const struct file_operations ext4_file_operations = {
133#ifdef CONFIG_COMPAT 150#ifdef CONFIG_COMPAT
134 .compat_ioctl = ext4_compat_ioctl, 151 .compat_ioctl = ext4_compat_ioctl,
135#endif 152#endif
136 .mmap = generic_file_mmap, 153 .mmap = ext4_file_mmap,
137 .open = generic_file_open, 154 .open = generic_file_open,
138 .release = ext4_release_file, 155 .release = ext4_release_file,
139 .fsync = ext4_sync_file, 156 .fsync = ext4_sync_file,
@@ -144,6 +161,7 @@ const struct file_operations ext4_file_operations = {
144const struct inode_operations ext4_file_inode_operations = { 161const struct inode_operations ext4_file_inode_operations = {
145 .truncate = ext4_truncate, 162 .truncate = ext4_truncate,
146 .setattr = ext4_setattr, 163 .setattr = ext4_setattr,
164 .getattr = ext4_getattr,
147#ifdef CONFIG_EXT4DEV_FS_XATTR 165#ifdef CONFIG_EXT4DEV_FS_XATTR
148 .setxattr = generic_setxattr, 166 .setxattr = generic_setxattr,
149 .getxattr = generic_getxattr, 167 .getxattr = generic_getxattr,
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index 1c8ba48d4f8..a45c3737ad3 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -27,6 +27,7 @@
27#include <linux/sched.h> 27#include <linux/sched.h>
28#include <linux/writeback.h> 28#include <linux/writeback.h>
29#include <linux/jbd2.h> 29#include <linux/jbd2.h>
30#include <linux/blkdev.h>
30#include "ext4.h" 31#include "ext4.h"
31#include "ext4_jbd2.h" 32#include "ext4_jbd2.h"
32 33
@@ -45,6 +46,7 @@
45int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync) 46int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)
46{ 47{
47 struct inode *inode = dentry->d_inode; 48 struct inode *inode = dentry->d_inode;
49 journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
48 int ret = 0; 50 int ret = 0;
49 51
50 J_ASSERT(ext4_journal_current_handle() == NULL); 52 J_ASSERT(ext4_journal_current_handle() == NULL);
@@ -85,6 +87,8 @@ int ext4_sync_file(struct file * file, struct dentry *dentry, int datasync)
85 .nr_to_write = 0, /* sys_fsync did this */ 87 .nr_to_write = 0, /* sys_fsync did this */
86 }; 88 };
87 ret = sync_inode(inode, &wbc); 89 ret = sync_inode(inode, &wbc);
90 if (journal && (journal->j_flags & JBD2_BARRIER))
91 blkdev_issue_flush(inode->i_sb->s_bdev, NULL);
88 } 92 }
89out: 93out:
90 return ret; 94 return ret;
diff --git a/fs/ext4/group.h b/fs/ext4/group.h
index 7eb0604e7ee..c2c0a8d06d0 100644
--- a/fs/ext4/group.h
+++ b/fs/ext4/group.h
@@ -13,7 +13,7 @@ extern __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 group,
13 struct ext4_group_desc *gdp); 13 struct ext4_group_desc *gdp);
14extern int ext4_group_desc_csum_verify(struct ext4_sb_info *sbi, __u32 group, 14extern int ext4_group_desc_csum_verify(struct ext4_sb_info *sbi, __u32 group,
15 struct ext4_group_desc *gdp); 15 struct ext4_group_desc *gdp);
16struct buffer_head *read_block_bitmap(struct super_block *sb, 16struct buffer_head *ext4_read_block_bitmap(struct super_block *sb,
17 ext4_group_t block_group); 17 ext4_group_t block_group);
18extern unsigned ext4_init_block_bitmap(struct super_block *sb, 18extern unsigned ext4_init_block_bitmap(struct super_block *sb,
19 struct buffer_head *bh, 19 struct buffer_head *bh,
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index c6efbab0c80..a92eb305344 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -157,6 +157,7 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
157 struct ext4_super_block * es; 157 struct ext4_super_block * es;
158 struct ext4_sb_info *sbi; 158 struct ext4_sb_info *sbi;
159 int fatal = 0, err; 159 int fatal = 0, err;
160 ext4_group_t flex_group;
160 161
161 if (atomic_read(&inode->i_count) > 1) { 162 if (atomic_read(&inode->i_count) > 1) {
162 printk ("ext4_free_inode: inode has count=%d\n", 163 printk ("ext4_free_inode: inode has count=%d\n",
@@ -232,6 +233,12 @@ void ext4_free_inode (handle_t *handle, struct inode * inode)
232 if (is_directory) 233 if (is_directory)
233 percpu_counter_dec(&sbi->s_dirs_counter); 234 percpu_counter_dec(&sbi->s_dirs_counter);
234 235
236 if (sbi->s_log_groups_per_flex) {
237 flex_group = ext4_flex_group(sbi, block_group);
238 spin_lock(sb_bgl_lock(sbi, flex_group));
239 sbi->s_flex_groups[flex_group].free_inodes++;
240 spin_unlock(sb_bgl_lock(sbi, flex_group));
241 }
235 } 242 }
236 BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata"); 243 BUFFER_TRACE(bh2, "call ext4_journal_dirty_metadata");
237 err = ext4_journal_dirty_metadata(handle, bh2); 244 err = ext4_journal_dirty_metadata(handle, bh2);
@@ -286,6 +293,80 @@ static int find_group_dir(struct super_block *sb, struct inode *parent,
286 return ret; 293 return ret;
287} 294}
288 295
296#define free_block_ratio 10
297
298static int find_group_flex(struct super_block *sb, struct inode *parent,
299 ext4_group_t *best_group)
300{
301 struct ext4_sb_info *sbi = EXT4_SB(sb);
302 struct ext4_group_desc *desc;
303 struct buffer_head *bh;
304 struct flex_groups *flex_group = sbi->s_flex_groups;
305 ext4_group_t parent_group = EXT4_I(parent)->i_block_group;
306 ext4_group_t parent_fbg_group = ext4_flex_group(sbi, parent_group);
307 ext4_group_t ngroups = sbi->s_groups_count;
308 int flex_size = ext4_flex_bg_size(sbi);
309 ext4_group_t best_flex = parent_fbg_group;
310 int blocks_per_flex = sbi->s_blocks_per_group * flex_size;
311 int flexbg_free_blocks;
312 int flex_freeb_ratio;
313 ext4_group_t n_fbg_groups;
314 ext4_group_t i;
315
316 n_fbg_groups = (sbi->s_groups_count + flex_size - 1) >>
317 sbi->s_log_groups_per_flex;
318
319find_close_to_parent:
320 flexbg_free_blocks = flex_group[best_flex].free_blocks;
321 flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
322 if (flex_group[best_flex].free_inodes &&
323 flex_freeb_ratio > free_block_ratio)
324 goto found_flexbg;
325
326 if (best_flex && best_flex == parent_fbg_group) {
327 best_flex--;
328 goto find_close_to_parent;
329 }
330
331 for (i = 0; i < n_fbg_groups; i++) {
332 if (i == parent_fbg_group || i == parent_fbg_group - 1)
333 continue;
334
335 flexbg_free_blocks = flex_group[i].free_blocks;
336 flex_freeb_ratio = flexbg_free_blocks * 100 / blocks_per_flex;
337
338 if (flex_freeb_ratio > free_block_ratio &&
339 flex_group[i].free_inodes) {
340 best_flex = i;
341 goto found_flexbg;
342 }
343
344 if (best_flex < 0 ||
345 (flex_group[i].free_blocks >
346 flex_group[best_flex].free_blocks &&
347 flex_group[i].free_inodes))
348 best_flex = i;
349 }
350
351 if (!flex_group[best_flex].free_inodes ||
352 !flex_group[best_flex].free_blocks)
353 return -1;
354
355found_flexbg:
356 for (i = best_flex * flex_size; i < ngroups &&
357 i < (best_flex + 1) * flex_size; i++) {
358 desc = ext4_get_group_desc(sb, i, &bh);
359 if (le16_to_cpu(desc->bg_free_inodes_count)) {
360 *best_group = i;
361 goto out;
362 }
363 }
364
365 return -1;
366out:
367 return 0;
368}
369
289/* 370/*
290 * Orlov's allocator for directories. 371 * Orlov's allocator for directories.
291 * 372 *
@@ -501,6 +582,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
501 struct inode *ret; 582 struct inode *ret;
502 ext4_group_t i; 583 ext4_group_t i;
503 int free = 0; 584 int free = 0;
585 ext4_group_t flex_group;
504 586
505 /* Cannot create files in a deleted directory */ 587 /* Cannot create files in a deleted directory */
506 if (!dir || !dir->i_nlink) 588 if (!dir || !dir->i_nlink)
@@ -514,6 +596,12 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
514 596
515 sbi = EXT4_SB(sb); 597 sbi = EXT4_SB(sb);
516 es = sbi->s_es; 598 es = sbi->s_es;
599
600 if (sbi->s_log_groups_per_flex) {
601 ret2 = find_group_flex(sb, dir, &group);
602 goto got_group;
603 }
604
517 if (S_ISDIR(mode)) { 605 if (S_ISDIR(mode)) {
518 if (test_opt (sb, OLDALLOC)) 606 if (test_opt (sb, OLDALLOC))
519 ret2 = find_group_dir(sb, dir, &group); 607 ret2 = find_group_dir(sb, dir, &group);
@@ -522,6 +610,7 @@ struct inode *ext4_new_inode(handle_t *handle, struct inode * dir, int mode)
522 } else 610 } else
523 ret2 = find_group_other(sb, dir, &group); 611 ret2 = find_group_other(sb, dir, &group);
524 612
613got_group:
525 err = -ENOSPC; 614 err = -ENOSPC;
526 if (ret2 == -1) 615 if (ret2 == -1)
527 goto out; 616 goto out;
@@ -600,7 +689,7 @@ got:
600 /* We may have to initialize the block bitmap if it isn't already */ 689 /* We may have to initialize the block bitmap if it isn't already */
601 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && 690 if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) &&
602 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { 691 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
603 struct buffer_head *block_bh = read_block_bitmap(sb, group); 692 struct buffer_head *block_bh = ext4_read_block_bitmap(sb, group);
604 693
605 BUFFER_TRACE(block_bh, "get block bitmap access"); 694 BUFFER_TRACE(block_bh, "get block bitmap access");
606 err = ext4_journal_get_write_access(handle, block_bh); 695 err = ext4_journal_get_write_access(handle, block_bh);
@@ -676,6 +765,13 @@ got:
676 percpu_counter_inc(&sbi->s_dirs_counter); 765 percpu_counter_inc(&sbi->s_dirs_counter);
677 sb->s_dirt = 1; 766 sb->s_dirt = 1;
678 767
768 if (sbi->s_log_groups_per_flex) {
769 flex_group = ext4_flex_group(sbi, group);
770 spin_lock(sb_bgl_lock(sbi, flex_group));
771 sbi->s_flex_groups[flex_group].free_inodes--;
772 spin_unlock(sb_bgl_lock(sbi, flex_group));
773 }
774
679 inode->i_uid = current->fsuid; 775 inode->i_uid = current->fsuid;
680 if (test_opt (sb, GRPID)) 776 if (test_opt (sb, GRPID))
681 inode->i_gid = dir->i_gid; 777 inode->i_gid = dir->i_gid;
@@ -740,14 +836,10 @@ got:
740 goto fail_free_drop; 836 goto fail_free_drop;
741 837
742 if (test_opt(sb, EXTENTS)) { 838 if (test_opt(sb, EXTENTS)) {
743 /* set extent flag only for diretory, file and normal symlink*/ 839 /* set extent flag only for directory, file and normal symlink*/
744 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) { 840 if (S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode)) {
745 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL; 841 EXT4_I(inode)->i_flags |= EXT4_EXTENTS_FL;
746 ext4_ext_tree_init(handle, inode); 842 ext4_ext_tree_init(handle, inode);
747 err = ext4_update_incompat_feature(handle, sb,
748 EXT4_FEATURE_INCOMPAT_EXTENTS);
749 if (err)
750 goto fail_free_drop;
751 } 843 }
752 } 844 }
753 845
@@ -817,6 +909,14 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
817 if (IS_ERR(inode)) 909 if (IS_ERR(inode))
818 goto iget_failed; 910 goto iget_failed;
819 911
912 /*
913 * If the orphans has i_nlinks > 0 then it should be able to be
914 * truncated, otherwise it won't be removed from the orphan list
915 * during processing and an infinite loop will result.
916 */
917 if (inode->i_nlink && !ext4_can_truncate(inode))
918 goto bad_orphan;
919
820 if (NEXT_ORPHAN(inode) > max_ino) 920 if (NEXT_ORPHAN(inode) > max_ino)
821 goto bad_orphan; 921 goto bad_orphan;
822 brelse(bitmap_bh); 922 brelse(bitmap_bh);
@@ -838,6 +938,7 @@ bad_orphan:
838 printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n", 938 printk(KERN_NOTICE "NEXT_ORPHAN(inode)=%u\n",
839 NEXT_ORPHAN(inode)); 939 NEXT_ORPHAN(inode));
840 printk(KERN_NOTICE "max_ino=%lu\n", max_ino); 940 printk(KERN_NOTICE "max_ino=%lu\n", max_ino);
941 printk(KERN_NOTICE "i_nlink=%u\n", inode->i_nlink);
841 /* Avoid freeing blocks if we got a bad deleted inode */ 942 /* Avoid freeing blocks if we got a bad deleted inode */
842 if (inode->i_nlink == 0) 943 if (inode->i_nlink == 0)
843 inode->i_blocks = 0; 944 inode->i_blocks = 0;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8d970774641..8ca2763df09 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -32,12 +32,23 @@
32#include <linux/string.h> 32#include <linux/string.h>
33#include <linux/buffer_head.h> 33#include <linux/buffer_head.h>
34#include <linux/writeback.h> 34#include <linux/writeback.h>
35#include <linux/pagevec.h>
35#include <linux/mpage.h> 36#include <linux/mpage.h>
36#include <linux/uio.h> 37#include <linux/uio.h>
37#include <linux/bio.h> 38#include <linux/bio.h>
38#include "ext4_jbd2.h" 39#include "ext4_jbd2.h"
39#include "xattr.h" 40#include "xattr.h"
40#include "acl.h" 41#include "acl.h"
42#include "ext4_extents.h"
43
44static inline int ext4_begin_ordered_truncate(struct inode *inode,
45 loff_t new_size)
46{
47 return jbd2_journal_begin_ordered_truncate(&EXT4_I(inode)->jinode,
48 new_size);
49}
50
51static void ext4_invalidatepage(struct page *page, unsigned long offset);
41 52
42/* 53/*
43 * Test whether an inode is a fast symlink. 54 * Test whether an inode is a fast symlink.
@@ -181,6 +192,8 @@ void ext4_delete_inode (struct inode * inode)
181{ 192{
182 handle_t *handle; 193 handle_t *handle;
183 194
195 if (ext4_should_order_data(inode))
196 ext4_begin_ordered_truncate(inode, 0);
184 truncate_inode_pages(&inode->i_data, 0); 197 truncate_inode_pages(&inode->i_data, 0);
185 198
186 if (is_bad_inode(inode)) 199 if (is_bad_inode(inode))
@@ -508,11 +521,12 @@ static int ext4_blks_to_allocate(Indirect *branch, int k, unsigned long blks,
508 * direct blocks 521 * direct blocks
509 */ 522 */
510static int ext4_alloc_blocks(handle_t *handle, struct inode *inode, 523static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
511 ext4_fsblk_t goal, int indirect_blks, int blks, 524 ext4_lblk_t iblock, ext4_fsblk_t goal,
512 ext4_fsblk_t new_blocks[4], int *err) 525 int indirect_blks, int blks,
526 ext4_fsblk_t new_blocks[4], int *err)
513{ 527{
514 int target, i; 528 int target, i;
515 unsigned long count = 0; 529 unsigned long count = 0, blk_allocated = 0;
516 int index = 0; 530 int index = 0;
517 ext4_fsblk_t current_block = 0; 531 ext4_fsblk_t current_block = 0;
518 int ret = 0; 532 int ret = 0;
@@ -525,12 +539,13 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
525 * the first direct block of this branch. That's the 539 * the first direct block of this branch. That's the
526 * minimum number of blocks need to allocate(required) 540 * minimum number of blocks need to allocate(required)
527 */ 541 */
528 target = blks + indirect_blks; 542 /* first we try to allocate the indirect blocks */
529 543 target = indirect_blks;
530 while (1) { 544 while (target > 0) {
531 count = target; 545 count = target;
532 /* allocating blocks for indirect blocks and direct blocks */ 546 /* allocating blocks for indirect blocks and direct blocks */
533 current_block = ext4_new_blocks(handle,inode,goal,&count,err); 547 current_block = ext4_new_meta_blocks(handle, inode,
548 goal, &count, err);
534 if (*err) 549 if (*err)
535 goto failed_out; 550 goto failed_out;
536 551
@@ -540,16 +555,48 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode *inode,
540 new_blocks[index++] = current_block++; 555 new_blocks[index++] = current_block++;
541 count--; 556 count--;
542 } 557 }
543 558 if (count > 0) {
544 if (count > 0) 559 /*
560 * save the new block number
561 * for the first direct block
562 */
563 new_blocks[index] = current_block;
564 printk(KERN_INFO "%s returned more blocks than "
565 "requested\n", __func__);
566 WARN_ON(1);
545 break; 567 break;
568 }
546 } 569 }
547 570
548 /* save the new block number for the first direct block */ 571 target = blks - count ;
549 new_blocks[index] = current_block; 572 blk_allocated = count;
550 573 if (!target)
574 goto allocated;
575 /* Now allocate data blocks */
576 count = target;
577 /* allocating blocks for data blocks */
578 current_block = ext4_new_blocks(handle, inode, iblock,
579 goal, &count, err);
580 if (*err && (target == blks)) {
581 /*
582 * if the allocation failed and we didn't allocate
583 * any blocks before
584 */
585 goto failed_out;
586 }
587 if (!*err) {
588 if (target == blks) {
589 /*
590 * save the new block number
591 * for the first direct block
592 */
593 new_blocks[index] = current_block;
594 }
595 blk_allocated += count;
596 }
597allocated:
551 /* total number of blocks allocated for direct blocks */ 598 /* total number of blocks allocated for direct blocks */
552 ret = count; 599 ret = blk_allocated;
553 *err = 0; 600 *err = 0;
554 return ret; 601 return ret;
555failed_out: 602failed_out:
@@ -584,8 +631,9 @@ failed_out:
584 * as described above and return 0. 631 * as described above and return 0.
585 */ 632 */
586static int ext4_alloc_branch(handle_t *handle, struct inode *inode, 633static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
587 int indirect_blks, int *blks, ext4_fsblk_t goal, 634 ext4_lblk_t iblock, int indirect_blks,
588 ext4_lblk_t *offsets, Indirect *branch) 635 int *blks, ext4_fsblk_t goal,
636 ext4_lblk_t *offsets, Indirect *branch)
589{ 637{
590 int blocksize = inode->i_sb->s_blocksize; 638 int blocksize = inode->i_sb->s_blocksize;
591 int i, n = 0; 639 int i, n = 0;
@@ -595,7 +643,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
595 ext4_fsblk_t new_blocks[4]; 643 ext4_fsblk_t new_blocks[4];
596 ext4_fsblk_t current_block; 644 ext4_fsblk_t current_block;
597 645
598 num = ext4_alloc_blocks(handle, inode, goal, indirect_blks, 646 num = ext4_alloc_blocks(handle, inode, iblock, goal, indirect_blks,
599 *blks, new_blocks, &err); 647 *blks, new_blocks, &err);
600 if (err) 648 if (err)
601 return err; 649 return err;
@@ -799,6 +847,7 @@ int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
799 struct ext4_inode_info *ei = EXT4_I(inode); 847 struct ext4_inode_info *ei = EXT4_I(inode);
800 int count = 0; 848 int count = 0;
801 ext4_fsblk_t first_block = 0; 849 ext4_fsblk_t first_block = 0;
850 loff_t disksize;
802 851
803 852
804 J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); 853 J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL));
@@ -855,8 +904,9 @@ int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
855 /* 904 /*
856 * Block out ext4_truncate while we alter the tree 905 * Block out ext4_truncate while we alter the tree
857 */ 906 */
858 err = ext4_alloc_branch(handle, inode, indirect_blks, &count, goal, 907 err = ext4_alloc_branch(handle, inode, iblock, indirect_blks,
859 offsets + (partial - chain), partial); 908 &count, goal,
909 offsets + (partial - chain), partial);
860 910
861 /* 911 /*
862 * The ext4_splice_branch call will free and forget any buffers 912 * The ext4_splice_branch call will free and forget any buffers
@@ -873,8 +923,13 @@ int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
873 * protect it if you're about to implement concurrent 923 * protect it if you're about to implement concurrent
874 * ext4_get_block() -bzzz 924 * ext4_get_block() -bzzz
875 */ 925 */
876 if (!err && extend_disksize && inode->i_size > ei->i_disksize) 926 if (!err && extend_disksize) {
877 ei->i_disksize = inode->i_size; 927 disksize = ((loff_t) iblock + count) << inode->i_blkbits;
928 if (disksize > i_size_read(inode))
929 disksize = i_size_read(inode);
930 if (disksize > ei->i_disksize)
931 ei->i_disksize = disksize;
932 }
878 if (err) 933 if (err)
879 goto cleanup; 934 goto cleanup;
880 935
@@ -934,7 +989,7 @@ out:
934 */ 989 */
935int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, 990int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
936 unsigned long max_blocks, struct buffer_head *bh, 991 unsigned long max_blocks, struct buffer_head *bh,
937 int create, int extend_disksize) 992 int create, int extend_disksize, int flag)
938{ 993{
939 int retval; 994 int retval;
940 995
@@ -975,6 +1030,15 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
975 * with create == 1 flag. 1030 * with create == 1 flag.
976 */ 1031 */
977 down_write((&EXT4_I(inode)->i_data_sem)); 1032 down_write((&EXT4_I(inode)->i_data_sem));
1033
1034 /*
1035 * if the caller is from delayed allocation writeout path
1036 * we have already reserved fs blocks for allocation
1037 * let the underlying get_block() function know to
1038 * avoid double accounting
1039 */
1040 if (flag)
1041 EXT4_I(inode)->i_delalloc_reserved_flag = 1;
978 /* 1042 /*
979 * We need to check for EXT4 here because migrate 1043 * We need to check for EXT4 here because migrate
980 * could have changed the inode type in between 1044 * could have changed the inode type in between
@@ -996,6 +1060,18 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
996 ~EXT4_EXT_MIGRATE; 1060 ~EXT4_EXT_MIGRATE;
997 } 1061 }
998 } 1062 }
1063
1064 if (flag) {
1065 EXT4_I(inode)->i_delalloc_reserved_flag = 0;
1066 /*
1067 * Update reserved blocks/metadata blocks
1068 * after successful block allocation
1069 * which were deferred till now
1070 */
1071 if ((retval > 0) && buffer_delay(bh))
1072 ext4_da_release_space(inode, retval, 0);
1073 }
1074
999 up_write((&EXT4_I(inode)->i_data_sem)); 1075 up_write((&EXT4_I(inode)->i_data_sem));
1000 return retval; 1076 return retval;
1001} 1077}
@@ -1021,7 +1097,7 @@ static int ext4_get_block(struct inode *inode, sector_t iblock,
1021 } 1097 }
1022 1098
1023 ret = ext4_get_blocks_wrap(handle, inode, iblock, 1099 ret = ext4_get_blocks_wrap(handle, inode, iblock,
1024 max_blocks, bh_result, create, 0); 1100 max_blocks, bh_result, create, 0, 0);
1025 if (ret > 0) { 1101 if (ret > 0) {
1026 bh_result->b_size = (ret << inode->i_blkbits); 1102 bh_result->b_size = (ret << inode->i_blkbits);
1027 ret = 0; 1103 ret = 0;
@@ -1047,7 +1123,7 @@ struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode,
1047 dummy.b_blocknr = -1000; 1123 dummy.b_blocknr = -1000;
1048 buffer_trace_init(&dummy.b_history); 1124 buffer_trace_init(&dummy.b_history);
1049 err = ext4_get_blocks_wrap(handle, inode, block, 1, 1125 err = ext4_get_blocks_wrap(handle, inode, block, 1,
1050 &dummy, create, 1); 1126 &dummy, create, 1, 0);
1051 /* 1127 /*
1052 * ext4_get_blocks_handle() returns number of blocks 1128 * ext4_get_blocks_handle() returns number of blocks
1053 * mapped. 0 in case of a HOLE. 1129 * mapped. 0 in case of a HOLE.
@@ -1203,19 +1279,20 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
1203 to = from + len; 1279 to = from + len;
1204 1280
1205retry: 1281retry:
1206 page = __grab_cache_page(mapping, index);
1207 if (!page)
1208 return -ENOMEM;
1209 *pagep = page;
1210
1211 handle = ext4_journal_start(inode, needed_blocks); 1282 handle = ext4_journal_start(inode, needed_blocks);
1212 if (IS_ERR(handle)) { 1283 if (IS_ERR(handle)) {
1213 unlock_page(page);
1214 page_cache_release(page);
1215 ret = PTR_ERR(handle); 1284 ret = PTR_ERR(handle);
1216 goto out; 1285 goto out;
1217 } 1286 }
1218 1287
1288 page = __grab_cache_page(mapping, index);
1289 if (!page) {
1290 ext4_journal_stop(handle);
1291 ret = -ENOMEM;
1292 goto out;
1293 }
1294 *pagep = page;
1295
1219 ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata, 1296 ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
1220 ext4_get_block); 1297 ext4_get_block);
1221 1298
@@ -1225,8 +1302,8 @@ retry:
1225 } 1302 }
1226 1303
1227 if (ret) { 1304 if (ret) {
1228 ext4_journal_stop(handle);
1229 unlock_page(page); 1305 unlock_page(page);
1306 ext4_journal_stop(handle);
1230 page_cache_release(page); 1307 page_cache_release(page);
1231 } 1308 }
1232 1309
@@ -1236,15 +1313,6 @@ out:
1236 return ret; 1313 return ret;
1237} 1314}
1238 1315
1239int ext4_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
1240{
1241 int err = jbd2_journal_dirty_data(handle, bh);
1242 if (err)
1243 ext4_journal_abort_handle(__func__, __func__,
1244 bh, handle, err);
1245 return err;
1246}
1247
1248/* For write_end() in data=journal mode */ 1316/* For write_end() in data=journal mode */
1249static int write_end_fn(handle_t *handle, struct buffer_head *bh) 1317static int write_end_fn(handle_t *handle, struct buffer_head *bh)
1250{ 1318{
@@ -1255,29 +1323,6 @@ static int write_end_fn(handle_t *handle, struct buffer_head *bh)
1255} 1323}
1256 1324
1257/* 1325/*
1258 * Generic write_end handler for ordered and writeback ext4 journal modes.
1259 * We can't use generic_write_end, because that unlocks the page and we need to
1260 * unlock the page after ext4_journal_stop, but ext4_journal_stop must run
1261 * after block_write_end.
1262 */
1263static int ext4_generic_write_end(struct file *file,
1264 struct address_space *mapping,
1265 loff_t pos, unsigned len, unsigned copied,
1266 struct page *page, void *fsdata)
1267{
1268 struct inode *inode = file->f_mapping->host;
1269
1270 copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
1271
1272 if (pos+copied > inode->i_size) {
1273 i_size_write(inode, pos+copied);
1274 mark_inode_dirty(inode);
1275 }
1276
1277 return copied;
1278}
1279
1280/*
1281 * We need to pick up the new inode size which generic_commit_write gave us 1326 * We need to pick up the new inode size which generic_commit_write gave us
1282 * `file' can be NULL - eg, when called from page_symlink(). 1327 * `file' can be NULL - eg, when called from page_symlink().
1283 * 1328 *
@@ -1290,15 +1335,14 @@ static int ext4_ordered_write_end(struct file *file,
1290 struct page *page, void *fsdata) 1335 struct page *page, void *fsdata)
1291{ 1336{
1292 handle_t *handle = ext4_journal_current_handle(); 1337 handle_t *handle = ext4_journal_current_handle();
1293 struct inode *inode = file->f_mapping->host; 1338 struct inode *inode = mapping->host;
1294 unsigned from, to; 1339 unsigned from, to;
1295 int ret = 0, ret2; 1340 int ret = 0, ret2;
1296 1341
1297 from = pos & (PAGE_CACHE_SIZE - 1); 1342 from = pos & (PAGE_CACHE_SIZE - 1);
1298 to = from + len; 1343 to = from + len;
1299 1344
1300 ret = walk_page_buffers(handle, page_buffers(page), 1345 ret = ext4_jbd2_file_inode(handle, inode);
1301 from, to, NULL, ext4_journal_dirty_data);
1302 1346
1303 if (ret == 0) { 1347 if (ret == 0) {
1304 /* 1348 /*
@@ -1311,7 +1355,7 @@ static int ext4_ordered_write_end(struct file *file,
1311 new_i_size = pos + copied; 1355 new_i_size = pos + copied;
1312 if (new_i_size > EXT4_I(inode)->i_disksize) 1356 if (new_i_size > EXT4_I(inode)->i_disksize)
1313 EXT4_I(inode)->i_disksize = new_i_size; 1357 EXT4_I(inode)->i_disksize = new_i_size;
1314 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1358 ret2 = generic_write_end(file, mapping, pos, len, copied,
1315 page, fsdata); 1359 page, fsdata);
1316 copied = ret2; 1360 copied = ret2;
1317 if (ret2 < 0) 1361 if (ret2 < 0)
@@ -1320,8 +1364,6 @@ static int ext4_ordered_write_end(struct file *file,
1320 ret2 = ext4_journal_stop(handle); 1364 ret2 = ext4_journal_stop(handle);
1321 if (!ret) 1365 if (!ret)
1322 ret = ret2; 1366 ret = ret2;
1323 unlock_page(page);
1324 page_cache_release(page);
1325 1367
1326 return ret ? ret : copied; 1368 return ret ? ret : copied;
1327} 1369}
@@ -1332,7 +1374,7 @@ static int ext4_writeback_write_end(struct file *file,
1332 struct page *page, void *fsdata) 1374 struct page *page, void *fsdata)
1333{ 1375{
1334 handle_t *handle = ext4_journal_current_handle(); 1376 handle_t *handle = ext4_journal_current_handle();
1335 struct inode *inode = file->f_mapping->host; 1377 struct inode *inode = mapping->host;
1336 int ret = 0, ret2; 1378 int ret = 0, ret2;
1337 loff_t new_i_size; 1379 loff_t new_i_size;
1338 1380
@@ -1340,7 +1382,7 @@ static int ext4_writeback_write_end(struct file *file,
1340 if (new_i_size > EXT4_I(inode)->i_disksize) 1382 if (new_i_size > EXT4_I(inode)->i_disksize)
1341 EXT4_I(inode)->i_disksize = new_i_size; 1383 EXT4_I(inode)->i_disksize = new_i_size;
1342 1384
1343 ret2 = ext4_generic_write_end(file, mapping, pos, len, copied, 1385 ret2 = generic_write_end(file, mapping, pos, len, copied,
1344 page, fsdata); 1386 page, fsdata);
1345 copied = ret2; 1387 copied = ret2;
1346 if (ret2 < 0) 1388 if (ret2 < 0)
@@ -1349,8 +1391,6 @@ static int ext4_writeback_write_end(struct file *file,
1349 ret2 = ext4_journal_stop(handle); 1391 ret2 = ext4_journal_stop(handle);
1350 if (!ret) 1392 if (!ret)
1351 ret = ret2; 1393 ret = ret2;
1352 unlock_page(page);
1353 page_cache_release(page);
1354 1394
1355 return ret ? ret : copied; 1395 return ret ? ret : copied;
1356} 1396}
@@ -1389,14 +1429,965 @@ static int ext4_journalled_write_end(struct file *file,
1389 ret = ret2; 1429 ret = ret2;
1390 } 1430 }
1391 1431
1432 unlock_page(page);
1392 ret2 = ext4_journal_stop(handle); 1433 ret2 = ext4_journal_stop(handle);
1393 if (!ret) 1434 if (!ret)
1394 ret = ret2; 1435 ret = ret2;
1395 unlock_page(page);
1396 page_cache_release(page); 1436 page_cache_release(page);
1397 1437
1398 return ret ? ret : copied; 1438 return ret ? ret : copied;
1399} 1439}
1440/*
1441 * Calculate the number of metadata blocks need to reserve
1442 * to allocate @blocks for non extent file based file
1443 */
1444static int ext4_indirect_calc_metadata_amount(struct inode *inode, int blocks)
1445{
1446 int icap = EXT4_ADDR_PER_BLOCK(inode->i_sb);
1447 int ind_blks, dind_blks, tind_blks;
1448
1449 /* number of new indirect blocks needed */
1450 ind_blks = (blocks + icap - 1) / icap;
1451
1452 dind_blks = (ind_blks + icap - 1) / icap;
1453
1454 tind_blks = 1;
1455
1456 return ind_blks + dind_blks + tind_blks;
1457}
1458
1459/*
1460 * Calculate the number of metadata blocks need to reserve
1461 * to allocate given number of blocks
1462 */
1463static int ext4_calc_metadata_amount(struct inode *inode, int blocks)
1464{
1465 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
1466 return ext4_ext_calc_metadata_amount(inode, blocks);
1467
1468 return ext4_indirect_calc_metadata_amount(inode, blocks);
1469}
1470
1471static int ext4_da_reserve_space(struct inode *inode, int nrblocks)
1472{
1473 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
1474 unsigned long md_needed, mdblocks, total = 0;
1475
1476 /*
1477 * recalculate the amount of metadata blocks to reserve
1478 * in order to allocate nrblocks
1479 * worse case is one extent per block
1480 */
1481 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
1482 total = EXT4_I(inode)->i_reserved_data_blocks + nrblocks;
1483 mdblocks = ext4_calc_metadata_amount(inode, total);
1484 BUG_ON(mdblocks < EXT4_I(inode)->i_reserved_meta_blocks);
1485
1486 md_needed = mdblocks - EXT4_I(inode)->i_reserved_meta_blocks;
1487 total = md_needed + nrblocks;
1488
1489 if (ext4_has_free_blocks(sbi, total) < total) {
1490 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1491 return -ENOSPC;
1492 }
1493
1494 /* reduce fs free blocks counter */
1495 percpu_counter_sub(&sbi->s_freeblocks_counter, total);
1496
1497 EXT4_I(inode)->i_reserved_data_blocks += nrblocks;
1498 EXT4_I(inode)->i_reserved_meta_blocks = mdblocks;
1499
1500 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1501 return 0; /* success */
1502}
1503
1504void ext4_da_release_space(struct inode *inode, int used, int to_free)
1505{
1506 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
1507 int total, mdb, mdb_free, release;
1508
1509 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
1510 /* recalculate the number of metablocks still need to be reserved */
1511 total = EXT4_I(inode)->i_reserved_data_blocks - used - to_free;
1512 mdb = ext4_calc_metadata_amount(inode, total);
1513
1514 /* figure out how many metablocks to release */
1515 BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
1516 mdb_free = EXT4_I(inode)->i_reserved_meta_blocks - mdb;
1517
1518 /* Account for allocated meta_blocks */
1519 mdb_free -= EXT4_I(inode)->i_allocated_meta_blocks;
1520
1521 release = to_free + mdb_free;
1522
1523 /* update fs free blocks counter for truncate case */
1524 percpu_counter_add(&sbi->s_freeblocks_counter, release);
1525
1526 /* update per-inode reservations */
1527 BUG_ON(used + to_free > EXT4_I(inode)->i_reserved_data_blocks);
1528 EXT4_I(inode)->i_reserved_data_blocks -= (used + to_free);
1529
1530 BUG_ON(mdb > EXT4_I(inode)->i_reserved_meta_blocks);
1531 EXT4_I(inode)->i_reserved_meta_blocks = mdb;
1532 EXT4_I(inode)->i_allocated_meta_blocks = 0;
1533 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
1534}
1535
1536static void ext4_da_page_release_reservation(struct page *page,
1537 unsigned long offset)
1538{
1539 int to_release = 0;
1540 struct buffer_head *head, *bh;
1541 unsigned int curr_off = 0;
1542
1543 head = page_buffers(page);
1544 bh = head;
1545 do {
1546 unsigned int next_off = curr_off + bh->b_size;
1547
1548 if ((offset <= curr_off) && (buffer_delay(bh))) {
1549 to_release++;
1550 clear_buffer_delay(bh);
1551 }
1552 curr_off = next_off;
1553 } while ((bh = bh->b_this_page) != head);
1554 ext4_da_release_space(page->mapping->host, 0, to_release);
1555}
1556
1557/*
1558 * Delayed allocation stuff
1559 */
1560
1561struct mpage_da_data {
1562 struct inode *inode;
1563 struct buffer_head lbh; /* extent of blocks */
1564 unsigned long first_page, next_page; /* extent of pages */
1565 get_block_t *get_block;
1566 struct writeback_control *wbc;
1567};
1568
1569/*
1570 * mpage_da_submit_io - walks through extent of pages and try to write
1571 * them with __mpage_writepage()
1572 *
1573 * @mpd->inode: inode
1574 * @mpd->first_page: first page of the extent
1575 * @mpd->next_page: page after the last page of the extent
1576 * @mpd->get_block: the filesystem's block mapper function
1577 *
1578 * By the time mpage_da_submit_io() is called we expect all blocks
1579 * to be allocated. this may be wrong if allocation failed.
1580 *
1581 * As pages are already locked by write_cache_pages(), we can't use it
1582 */
1583static int mpage_da_submit_io(struct mpage_da_data *mpd)
1584{
1585 struct address_space *mapping = mpd->inode->i_mapping;
1586 struct mpage_data mpd_pp = {
1587 .bio = NULL,
1588 .last_block_in_bio = 0,
1589 .get_block = mpd->get_block,
1590 .use_writepage = 1,
1591 };
1592 int ret = 0, err, nr_pages, i;
1593 unsigned long index, end;
1594 struct pagevec pvec;
1595
1596 BUG_ON(mpd->next_page <= mpd->first_page);
1597
1598 pagevec_init(&pvec, 0);
1599 index = mpd->first_page;
1600 end = mpd->next_page - 1;
1601
1602 while (index <= end) {
1603 /* XXX: optimize tail */
1604 nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
1605 if (nr_pages == 0)
1606 break;
1607 for (i = 0; i < nr_pages; i++) {
1608 struct page *page = pvec.pages[i];
1609
1610 index = page->index;
1611 if (index > end)
1612 break;
1613 index++;
1614
1615 err = __mpage_writepage(page, mpd->wbc, &mpd_pp);
1616
1617 /*
1618 * In error case, we have to continue because
1619 * remaining pages are still locked
1620 * XXX: unlock and re-dirty them?
1621 */
1622 if (ret == 0)
1623 ret = err;
1624 }
1625 pagevec_release(&pvec);
1626 }
1627 if (mpd_pp.bio)
1628 mpage_bio_submit(WRITE, mpd_pp.bio);
1629
1630 return ret;
1631}
1632
1633/*
1634 * mpage_put_bnr_to_bhs - walk blocks and assign them actual numbers
1635 *
1636 * @mpd->inode - inode to walk through
1637 * @exbh->b_blocknr - first block on a disk
1638 * @exbh->b_size - amount of space in bytes
1639 * @logical - first logical block to start assignment with
1640 *
1641 * the function goes through all passed space and put actual disk
1642 * block numbers into buffer heads, dropping BH_Delay
1643 */
1644static void mpage_put_bnr_to_bhs(struct mpage_da_data *mpd, sector_t logical,
1645 struct buffer_head *exbh)
1646{
1647 struct inode *inode = mpd->inode;
1648 struct address_space *mapping = inode->i_mapping;
1649 int blocks = exbh->b_size >> inode->i_blkbits;
1650 sector_t pblock = exbh->b_blocknr, cur_logical;
1651 struct buffer_head *head, *bh;
1652 unsigned long index, end;
1653 struct pagevec pvec;
1654 int nr_pages, i;
1655
1656 index = logical >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
1657 end = (logical + blocks - 1) >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
1658 cur_logical = index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
1659
1660 pagevec_init(&pvec, 0);
1661
1662 while (index <= end) {
1663 /* XXX: optimize tail */
1664 nr_pages = pagevec_lookup(&pvec, mapping, index, PAGEVEC_SIZE);
1665 if (nr_pages == 0)
1666 break;
1667 for (i = 0; i < nr_pages; i++) {
1668 struct page *page = pvec.pages[i];
1669
1670 index = page->index;
1671 if (index > end)
1672 break;
1673 index++;
1674
1675 BUG_ON(!PageLocked(page));
1676 BUG_ON(PageWriteback(page));
1677 BUG_ON(!page_has_buffers(page));
1678
1679 bh = page_buffers(page);
1680 head = bh;
1681
1682 /* skip blocks out of the range */
1683 do {
1684 if (cur_logical >= logical)
1685 break;
1686 cur_logical++;
1687 } while ((bh = bh->b_this_page) != head);
1688
1689 do {
1690 if (cur_logical >= logical + blocks)
1691 break;
1692 if (buffer_delay(bh)) {
1693 bh->b_blocknr = pblock;
1694 clear_buffer_delay(bh);
1695 } else if (buffer_mapped(bh))
1696 BUG_ON(bh->b_blocknr != pblock);
1697
1698 cur_logical++;
1699 pblock++;
1700 } while ((bh = bh->b_this_page) != head);
1701 }
1702 pagevec_release(&pvec);
1703 }
1704}
1705
1706
1707/*
1708 * __unmap_underlying_blocks - just a helper function to unmap
1709 * set of blocks described by @bh
1710 */
1711static inline void __unmap_underlying_blocks(struct inode *inode,
1712 struct buffer_head *bh)
1713{
1714 struct block_device *bdev = inode->i_sb->s_bdev;
1715 int blocks, i;
1716
1717 blocks = bh->b_size >> inode->i_blkbits;
1718 for (i = 0; i < blocks; i++)
1719 unmap_underlying_metadata(bdev, bh->b_blocknr + i);
1720}
1721
1722/*
1723 * mpage_da_map_blocks - go through given space
1724 *
1725 * @mpd->lbh - bh describing space
1726 * @mpd->get_block - the filesystem's block mapper function
1727 *
1728 * The function skips space we know is already mapped to disk blocks.
1729 *
1730 * The function ignores errors ->get_block() returns, thus real
1731 * error handling is postponed to __mpage_writepage()
1732 */
1733static void mpage_da_map_blocks(struct mpage_da_data *mpd)
1734{
1735 struct buffer_head *lbh = &mpd->lbh;
1736 int err = 0, remain = lbh->b_size;
1737 sector_t next = lbh->b_blocknr;
1738 struct buffer_head new;
1739
1740 /*
1741 * We consider only non-mapped and non-allocated blocks
1742 */
1743 if (buffer_mapped(lbh) && !buffer_delay(lbh))
1744 return;
1745
1746 while (remain) {
1747 new.b_state = lbh->b_state;
1748 new.b_blocknr = 0;
1749 new.b_size = remain;
1750 err = mpd->get_block(mpd->inode, next, &new, 1);
1751 if (err) {
1752 /*
1753 * Rather than implement own error handling
1754 * here, we just leave remaining blocks
1755 * unallocated and try again with ->writepage()
1756 */
1757 break;
1758 }
1759 BUG_ON(new.b_size == 0);
1760
1761 if (buffer_new(&new))
1762 __unmap_underlying_blocks(mpd->inode, &new);
1763
1764 /*
1765 * If blocks are delayed marked, we need to
1766 * put actual blocknr and drop delayed bit
1767 */
1768 if (buffer_delay(lbh))
1769 mpage_put_bnr_to_bhs(mpd, next, &new);
1770
1771 /* go for the remaining blocks */
1772 next += new.b_size >> mpd->inode->i_blkbits;
1773 remain -= new.b_size;
1774 }
1775}
1776
1777#define BH_FLAGS ((1 << BH_Uptodate) | (1 << BH_Mapped) | (1 << BH_Delay))
1778
1779/*
1780 * mpage_add_bh_to_extent - try to add one more block to extent of blocks
1781 *
1782 * @mpd->lbh - extent of blocks
1783 * @logical - logical number of the block in the file
1784 * @bh - bh of the block (used to access block's state)
1785 *
1786 * the function is used to collect contig. blocks in same state
1787 */
1788static void mpage_add_bh_to_extent(struct mpage_da_data *mpd,
1789 sector_t logical, struct buffer_head *bh)
1790{
1791 struct buffer_head *lbh = &mpd->lbh;
1792 sector_t next;
1793
1794 next = lbh->b_blocknr + (lbh->b_size >> mpd->inode->i_blkbits);
1795
1796 /*
1797 * First block in the extent
1798 */
1799 if (lbh->b_size == 0) {
1800 lbh->b_blocknr = logical;
1801 lbh->b_size = bh->b_size;
1802 lbh->b_state = bh->b_state & BH_FLAGS;
1803 return;
1804 }
1805
1806 /*
1807 * Can we merge the block to our big extent?
1808 */
1809 if (logical == next && (bh->b_state & BH_FLAGS) == lbh->b_state) {
1810 lbh->b_size += bh->b_size;
1811 return;
1812 }
1813
1814 /*
1815 * We couldn't merge the block to our extent, so we
1816 * need to flush current extent and start new one
1817 */
1818 mpage_da_map_blocks(mpd);
1819
1820 /*
1821 * Now start a new extent
1822 */
1823 lbh->b_size = bh->b_size;
1824 lbh->b_state = bh->b_state & BH_FLAGS;
1825 lbh->b_blocknr = logical;
1826}
1827
1828/*
1829 * __mpage_da_writepage - finds extent of pages and blocks
1830 *
1831 * @page: page to consider
1832 * @wbc: not used, we just follow rules
1833 * @data: context
1834 *
1835 * The function finds extents of pages and scan them for all blocks.
1836 */
1837static int __mpage_da_writepage(struct page *page,
1838 struct writeback_control *wbc, void *data)
1839{
1840 struct mpage_da_data *mpd = data;
1841 struct inode *inode = mpd->inode;
1842 struct buffer_head *bh, *head, fake;
1843 sector_t logical;
1844
1845 /*
1846 * Can we merge this page to current extent?
1847 */
1848 if (mpd->next_page != page->index) {
1849 /*
1850 * Nope, we can't. So, we map non-allocated blocks
1851 * and start IO on them using __mpage_writepage()
1852 */
1853 if (mpd->next_page != mpd->first_page) {
1854 mpage_da_map_blocks(mpd);
1855 mpage_da_submit_io(mpd);
1856 }
1857
1858 /*
1859 * Start next extent of pages ...
1860 */
1861 mpd->first_page = page->index;
1862
1863 /*
1864 * ... and blocks
1865 */
1866 mpd->lbh.b_size = 0;
1867 mpd->lbh.b_state = 0;
1868 mpd->lbh.b_blocknr = 0;
1869 }
1870
1871 mpd->next_page = page->index + 1;
1872 logical = (sector_t) page->index <<
1873 (PAGE_CACHE_SHIFT - inode->i_blkbits);
1874
1875 if (!page_has_buffers(page)) {
1876 /*
1877 * There is no attached buffer heads yet (mmap?)
1878 * we treat the page asfull of dirty blocks
1879 */
1880 bh = &fake;
1881 bh->b_size = PAGE_CACHE_SIZE;
1882 bh->b_state = 0;
1883 set_buffer_dirty(bh);
1884 set_buffer_uptodate(bh);
1885 mpage_add_bh_to_extent(mpd, logical, bh);
1886 } else {
1887 /*
1888 * Page with regular buffer heads, just add all dirty ones
1889 */
1890 head = page_buffers(page);
1891 bh = head;
1892 do {
1893 BUG_ON(buffer_locked(bh));
1894 if (buffer_dirty(bh))
1895 mpage_add_bh_to_extent(mpd, logical, bh);
1896 logical++;
1897 } while ((bh = bh->b_this_page) != head);
1898 }
1899
1900 return 0;
1901}
1902
1903/*
1904 * mpage_da_writepages - walk the list of dirty pages of the given
1905 * address space, allocates non-allocated blocks, maps newly-allocated
1906 * blocks to existing bhs and issue IO them
1907 *
1908 * @mapping: address space structure to write
1909 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
1910 * @get_block: the filesystem's block mapper function.
1911 *
1912 * This is a library function, which implements the writepages()
1913 * address_space_operation.
1914 *
1915 * In order to avoid duplication of logic that deals with partial pages,
1916 * multiple bio per page, etc, we find non-allocated blocks, allocate
1917 * them with minimal calls to ->get_block() and re-use __mpage_writepage()
1918 *
1919 * It's important that we call __mpage_writepage() only once for each
1920 * involved page, otherwise we'd have to implement more complicated logic
1921 * to deal with pages w/o PG_lock or w/ PG_writeback and so on.
1922 *
1923 * See comments to mpage_writepages()
1924 */
1925static int mpage_da_writepages(struct address_space *mapping,
1926 struct writeback_control *wbc,
1927 get_block_t get_block)
1928{
1929 struct mpage_da_data mpd;
1930 int ret;
1931
1932 if (!get_block)
1933 return generic_writepages(mapping, wbc);
1934
1935 mpd.wbc = wbc;
1936 mpd.inode = mapping->host;
1937 mpd.lbh.b_size = 0;
1938 mpd.lbh.b_state = 0;
1939 mpd.lbh.b_blocknr = 0;
1940 mpd.first_page = 0;
1941 mpd.next_page = 0;
1942 mpd.get_block = get_block;
1943
1944 ret = write_cache_pages(mapping, wbc, __mpage_da_writepage, &mpd);
1945
1946 /*
1947 * Handle last extent of pages
1948 */
1949 if (mpd.next_page != mpd.first_page) {
1950 mpage_da_map_blocks(&mpd);
1951 mpage_da_submit_io(&mpd);
1952 }
1953
1954 return ret;
1955}
1956
1957/*
1958 * this is a special callback for ->write_begin() only
1959 * it's intention is to return mapped block or reserve space
1960 */
1961static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
1962 struct buffer_head *bh_result, int create)
1963{
1964 int ret = 0;
1965
1966 BUG_ON(create == 0);
1967 BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);
1968
1969 /*
1970 * first, we need to know whether the block is allocated already
1971 * preallocated blocks are unmapped but should treated
1972 * the same as allocated blocks.
1973 */
1974 ret = ext4_get_blocks_wrap(NULL, inode, iblock, 1, bh_result, 0, 0, 0);
1975 if ((ret == 0) && !buffer_delay(bh_result)) {
1976 /* the block isn't (pre)allocated yet, let's reserve space */
1977 /*
1978 * XXX: __block_prepare_write() unmaps passed block,
1979 * is it OK?
1980 */
1981 ret = ext4_da_reserve_space(inode, 1);
1982 if (ret)
1983 /* not enough space to reserve */
1984 return ret;
1985
1986 map_bh(bh_result, inode->i_sb, 0);
1987 set_buffer_new(bh_result);
1988 set_buffer_delay(bh_result);
1989 } else if (ret > 0) {
1990 bh_result->b_size = (ret << inode->i_blkbits);
1991 ret = 0;
1992 }
1993
1994 return ret;
1995}
1996#define EXT4_DELALLOC_RSVED 1
1997static int ext4_da_get_block_write(struct inode *inode, sector_t iblock,
1998 struct buffer_head *bh_result, int create)
1999{
2000 int ret;
2001 unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
2002 loff_t disksize = EXT4_I(inode)->i_disksize;
2003 handle_t *handle = NULL;
2004
2005 handle = ext4_journal_current_handle();
2006 if (!handle) {
2007 ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
2008 bh_result, 0, 0, 0);
2009 BUG_ON(!ret);
2010 } else {
2011 ret = ext4_get_blocks_wrap(handle, inode, iblock, max_blocks,
2012 bh_result, create, 0, EXT4_DELALLOC_RSVED);
2013 }
2014
2015 if (ret > 0) {
2016 bh_result->b_size = (ret << inode->i_blkbits);
2017
2018 /*
2019 * Update on-disk size along with block allocation
2020 * we don't use 'extend_disksize' as size may change
2021 * within already allocated block -bzzz
2022 */
2023 disksize = ((loff_t) iblock + ret) << inode->i_blkbits;
2024 if (disksize > i_size_read(inode))
2025 disksize = i_size_read(inode);
2026 if (disksize > EXT4_I(inode)->i_disksize) {
2027 /*
2028 * XXX: replace with spinlock if seen contended -bzzz
2029 */
2030 down_write(&EXT4_I(inode)->i_data_sem);
2031 if (disksize > EXT4_I(inode)->i_disksize)
2032 EXT4_I(inode)->i_disksize = disksize;
2033 up_write(&EXT4_I(inode)->i_data_sem);
2034
2035 if (EXT4_I(inode)->i_disksize == disksize) {
2036 ret = ext4_mark_inode_dirty(handle, inode);
2037 return ret;
2038 }
2039 }
2040 ret = 0;
2041 }
2042 return ret;
2043}
2044
2045static int ext4_bh_unmapped_or_delay(handle_t *handle, struct buffer_head *bh)
2046{
2047 /*
2048 * unmapped buffer is possible for holes.
2049 * delay buffer is possible with delayed allocation
2050 */
2051 return ((!buffer_mapped(bh) || buffer_delay(bh)) && buffer_dirty(bh));
2052}
2053
2054static int ext4_normal_get_block_write(struct inode *inode, sector_t iblock,
2055 struct buffer_head *bh_result, int create)
2056{
2057 int ret = 0;
2058 unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
2059
2060 /*
2061 * we don't want to do block allocation in writepage
2062 * so call get_block_wrap with create = 0
2063 */
2064 ret = ext4_get_blocks_wrap(NULL, inode, iblock, max_blocks,
2065 bh_result, 0, 0, 0);
2066 if (ret > 0) {
2067 bh_result->b_size = (ret << inode->i_blkbits);
2068 ret = 0;
2069 }
2070 return ret;
2071}
2072
2073/*
2074 * get called vi ext4_da_writepages after taking page lock (have journal handle)
2075 * get called via journal_submit_inode_data_buffers (no journal handle)
2076 * get called via shrink_page_list via pdflush (no journal handle)
2077 * or grab_page_cache when doing write_begin (have journal handle)
2078 */
2079static int ext4_da_writepage(struct page *page,
2080 struct writeback_control *wbc)
2081{
2082 int ret = 0;
2083 loff_t size;
2084 unsigned long len;
2085 struct buffer_head *page_bufs;
2086 struct inode *inode = page->mapping->host;
2087
2088 size = i_size_read(inode);
2089 if (page->index == size >> PAGE_CACHE_SHIFT)
2090 len = size & ~PAGE_CACHE_MASK;
2091 else
2092 len = PAGE_CACHE_SIZE;
2093
2094 if (page_has_buffers(page)) {
2095 page_bufs = page_buffers(page);
2096 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL,
2097 ext4_bh_unmapped_or_delay)) {
2098 /*
2099 * We don't want to do block allocation
2100 * So redirty the page and return
2101 * We may reach here when we do a journal commit
2102 * via journal_submit_inode_data_buffers.
2103 * If we don't have mapping block we just ignore
2104 * them. We can also reach here via shrink_page_list
2105 */
2106 redirty_page_for_writepage(wbc, page);
2107 unlock_page(page);
2108 return 0;
2109 }
2110 } else {
2111 /*
2112 * The test for page_has_buffers() is subtle:
2113 * We know the page is dirty but it lost buffers. That means
2114 * that at some moment in time after write_begin()/write_end()
2115 * has been called all buffers have been clean and thus they
2116 * must have been written at least once. So they are all
2117 * mapped and we can happily proceed with mapping them
2118 * and writing the page.
2119 *
2120 * Try to initialize the buffer_heads and check whether
2121 * all are mapped and non delay. We don't want to
2122 * do block allocation here.
2123 */
2124 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
2125 ext4_normal_get_block_write);
2126 if (!ret) {
2127 page_bufs = page_buffers(page);
2128 /* check whether all are mapped and non delay */
2129 if (walk_page_buffers(NULL, page_bufs, 0, len, NULL,
2130 ext4_bh_unmapped_or_delay)) {
2131 redirty_page_for_writepage(wbc, page);
2132 unlock_page(page);
2133 return 0;
2134 }
2135 } else {
2136 /*
2137 * We can't do block allocation here
2138 * so just redity the page and unlock
2139 * and return
2140 */
2141 redirty_page_for_writepage(wbc, page);
2142 unlock_page(page);
2143 return 0;
2144 }
2145 }
2146
2147 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
2148 ret = nobh_writepage(page, ext4_normal_get_block_write, wbc);
2149 else
2150 ret = block_write_full_page(page,
2151 ext4_normal_get_block_write,
2152 wbc);
2153
2154 return ret;
2155}
2156
2157/*
2158 * For now just follow the DIO way to estimate the max credits
2159 * needed to write out EXT4_MAX_WRITEBACK_PAGES.
2160 * todo: need to calculate the max credits need for
2161 * extent based files, currently the DIO credits is based on
2162 * indirect-blocks mapping way.
2163 *
2164 * Probably should have a generic way to calculate credits
2165 * for DIO, writepages, and truncate
2166 */
2167#define EXT4_MAX_WRITEBACK_PAGES DIO_MAX_BLOCKS
2168#define EXT4_MAX_WRITEBACK_CREDITS DIO_CREDITS
2169
2170static int ext4_da_writepages(struct address_space *mapping,
2171 struct writeback_control *wbc)
2172{
2173 struct inode *inode = mapping->host;
2174 handle_t *handle = NULL;
2175 int needed_blocks;
2176 int ret = 0;
2177 long to_write;
2178 loff_t range_start = 0;
2179
2180 /*
2181 * No pages to write? This is mainly a kludge to avoid starting
2182 * a transaction for special inodes like journal inode on last iput()
2183 * because that could violate lock ordering on umount
2184 */
2185 if (!mapping->nrpages)
2186 return 0;
2187
2188 /*
2189 * Estimate the worse case needed credits to write out
2190 * EXT4_MAX_BUF_BLOCKS pages
2191 */
2192 needed_blocks = EXT4_MAX_WRITEBACK_CREDITS;
2193
2194 to_write = wbc->nr_to_write;
2195 if (!wbc->range_cyclic) {
2196 /*
2197 * If range_cyclic is not set force range_cont
2198 * and save the old writeback_index
2199 */
2200 wbc->range_cont = 1;
2201 range_start = wbc->range_start;
2202 }
2203
2204 while (!ret && to_write) {
2205 /* start a new transaction*/
2206 handle = ext4_journal_start(inode, needed_blocks);
2207 if (IS_ERR(handle)) {
2208 ret = PTR_ERR(handle);
2209 goto out_writepages;
2210 }
2211 if (ext4_should_order_data(inode)) {
2212 /*
2213 * With ordered mode we need to add
2214 * the inode to the journal handle
2215 * when we do block allocation.
2216 */
2217 ret = ext4_jbd2_file_inode(handle, inode);
2218 if (ret) {
2219 ext4_journal_stop(handle);
2220 goto out_writepages;
2221 }
2222
2223 }
2224 /*
2225 * set the max dirty pages could be write at a time
2226 * to fit into the reserved transaction credits
2227 */
2228 if (wbc->nr_to_write > EXT4_MAX_WRITEBACK_PAGES)
2229 wbc->nr_to_write = EXT4_MAX_WRITEBACK_PAGES;
2230
2231 to_write -= wbc->nr_to_write;
2232 ret = mpage_da_writepages(mapping, wbc,
2233 ext4_da_get_block_write);
2234 ext4_journal_stop(handle);
2235 if (wbc->nr_to_write) {
2236 /*
2237 * There is no more writeout needed
2238 * or we requested for a noblocking writeout
2239 * and we found the device congested
2240 */
2241 to_write += wbc->nr_to_write;
2242 break;
2243 }
2244 wbc->nr_to_write = to_write;
2245 }
2246
2247out_writepages:
2248 wbc->nr_to_write = to_write;
2249 if (range_start)
2250 wbc->range_start = range_start;
2251 return ret;
2252}
2253
2254static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
2255 loff_t pos, unsigned len, unsigned flags,
2256 struct page **pagep, void **fsdata)
2257{
2258 int ret, retries = 0;
2259 struct page *page;
2260 pgoff_t index;
2261 unsigned from, to;
2262 struct inode *inode = mapping->host;
2263 handle_t *handle;
2264
2265 index = pos >> PAGE_CACHE_SHIFT;
2266 from = pos & (PAGE_CACHE_SIZE - 1);
2267 to = from + len;
2268
2269retry:
2270 /*
2271 * With delayed allocation, we don't log the i_disksize update
2272 * if there is delayed block allocation. But we still need
2273 * to journalling the i_disksize update if writes to the end
2274 * of file which has an already mapped buffer.
2275 */
2276 handle = ext4_journal_start(inode, 1);
2277 if (IS_ERR(handle)) {
2278 ret = PTR_ERR(handle);
2279 goto out;
2280 }
2281
2282 page = __grab_cache_page(mapping, index);
2283 if (!page)
2284 return -ENOMEM;
2285 *pagep = page;
2286
2287 ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
2288 ext4_da_get_block_prep);
2289 if (ret < 0) {
2290 unlock_page(page);
2291 ext4_journal_stop(handle);
2292 page_cache_release(page);
2293 }
2294
2295 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
2296 goto retry;
2297out:
2298 return ret;
2299}
2300
2301/*
2302 * Check if we should update i_disksize
2303 * when write to the end of file but not require block allocation
2304 */
2305static int ext4_da_should_update_i_disksize(struct page *page,
2306 unsigned long offset)
2307{
2308 struct buffer_head *bh;
2309 struct inode *inode = page->mapping->host;
2310 unsigned int idx;
2311 int i;
2312
2313 bh = page_buffers(page);
2314 idx = offset >> inode->i_blkbits;
2315
2316 for (i=0; i < idx; i++)
2317 bh = bh->b_this_page;
2318
2319 if (!buffer_mapped(bh) || (buffer_delay(bh)))
2320 return 0;
2321 return 1;
2322}
2323
2324static int ext4_da_write_end(struct file *file,
2325 struct address_space *mapping,
2326 loff_t pos, unsigned len, unsigned copied,
2327 struct page *page, void *fsdata)
2328{
2329 struct inode *inode = mapping->host;
2330 int ret = 0, ret2;
2331 handle_t *handle = ext4_journal_current_handle();
2332 loff_t new_i_size;
2333 unsigned long start, end;
2334
2335 start = pos & (PAGE_CACHE_SIZE - 1);
2336 end = start + copied -1;
2337
2338 /*
2339 * generic_write_end() will run mark_inode_dirty() if i_size
2340 * changes. So let's piggyback the i_disksize mark_inode_dirty
2341 * into that.
2342 */
2343
2344 new_i_size = pos + copied;
2345 if (new_i_size > EXT4_I(inode)->i_disksize) {
2346 if (ext4_da_should_update_i_disksize(page, end)) {
2347 down_write(&EXT4_I(inode)->i_data_sem);
2348 if (new_i_size > EXT4_I(inode)->i_disksize) {
2349 /*
2350 * Updating i_disksize when extending file
2351 * without needing block allocation
2352 */
2353 if (ext4_should_order_data(inode))
2354 ret = ext4_jbd2_file_inode(handle,
2355 inode);
2356
2357 EXT4_I(inode)->i_disksize = new_i_size;
2358 }
2359 up_write(&EXT4_I(inode)->i_data_sem);
2360 }
2361 }
2362 ret2 = generic_write_end(file, mapping, pos, len, copied,
2363 page, fsdata);
2364 copied = ret2;
2365 if (ret2 < 0)
2366 ret = ret2;
2367 ret2 = ext4_journal_stop(handle);
2368 if (!ret)
2369 ret = ret2;
2370
2371 return ret ? ret : copied;
2372}
2373
2374static void ext4_da_invalidatepage(struct page *page, unsigned long offset)
2375{
2376 /*
2377 * Drop reserved blocks
2378 */
2379 BUG_ON(!PageLocked(page));
2380 if (!page_has_buffers(page))
2381 goto out;
2382
2383 ext4_da_page_release_reservation(page, offset);
2384
2385out:
2386 ext4_invalidatepage(page, offset);
2387
2388 return;
2389}
2390
1400 2391
1401/* 2392/*
1402 * bmap() is special. It gets used by applications such as lilo and by 2393 * bmap() is special. It gets used by applications such as lilo and by
@@ -1418,6 +2409,16 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)
1418 journal_t *journal; 2409 journal_t *journal;
1419 int err; 2410 int err;
1420 2411
2412 if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) &&
2413 test_opt(inode->i_sb, DELALLOC)) {
2414 /*
2415 * With delalloc we want to sync the file
2416 * so that we can make sure we allocate
2417 * blocks for file
2418 */
2419 filemap_write_and_wait(mapping);
2420 }
2421
1421 if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) { 2422 if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) {
1422 /* 2423 /*
1423 * This is a REALLY heavyweight approach, but the use of 2424 * This is a REALLY heavyweight approach, but the use of
@@ -1462,21 +2463,17 @@ static int bput_one(handle_t *handle, struct buffer_head *bh)
1462 return 0; 2463 return 0;
1463} 2464}
1464 2465
1465static int jbd2_journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
1466{
1467 if (buffer_mapped(bh))
1468 return ext4_journal_dirty_data(handle, bh);
1469 return 0;
1470}
1471
1472/* 2466/*
1473 * Note that we always start a transaction even if we're not journalling 2467 * Note that we don't need to start a transaction unless we're journaling data
1474 * data. This is to preserve ordering: any hole instantiation within 2468 * because we should have holes filled from ext4_page_mkwrite(). We even don't
1475 * __block_write_full_page -> ext4_get_block() should be journalled 2469 * need to file the inode to the transaction's list in ordered mode because if
1476 * along with the data so we don't crash and then get metadata which 2470 * we are writing back data added by write(), the inode is already there and if
1477 * refers to old data. 2471 * we are writing back data modified via mmap(), noone guarantees in which
2472 * transaction the data will hit the disk. In case we are journaling data, we
2473 * cannot start transaction directly because transaction start ranks above page
2474 * lock so we have to do some magic.
1478 * 2475 *
1479 * In all journalling modes block_write_full_page() will start the I/O. 2476 * In all journaling modes block_write_full_page() will start the I/O.
1480 * 2477 *
1481 * Problem: 2478 * Problem:
1482 * 2479 *
@@ -1518,105 +2515,103 @@ static int jbd2_journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
1518 * disastrous. Any write() or metadata operation will sync the fs for 2515 * disastrous. Any write() or metadata operation will sync the fs for
1519 * us. 2516 * us.
1520 * 2517 *
1521 * AKPM2: if all the page's buffers are mapped to disk and !data=journal,
1522 * we don't need to open a transaction here.
1523 */ 2518 */
1524static int ext4_ordered_writepage(struct page *page, 2519static int __ext4_normal_writepage(struct page *page,
1525 struct writeback_control *wbc) 2520 struct writeback_control *wbc)
1526{ 2521{
1527 struct inode *inode = page->mapping->host; 2522 struct inode *inode = page->mapping->host;
1528 struct buffer_head *page_bufs;
1529 handle_t *handle = NULL;
1530 int ret = 0;
1531 int err;
1532
1533 J_ASSERT(PageLocked(page));
1534
1535 /*
1536 * We give up here if we're reentered, because it might be for a
1537 * different filesystem.
1538 */
1539 if (ext4_journal_current_handle())
1540 goto out_fail;
1541 2523
1542 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); 2524 if (test_opt(inode->i_sb, NOBH))
2525 return nobh_writepage(page,
2526 ext4_normal_get_block_write, wbc);
2527 else
2528 return block_write_full_page(page,
2529 ext4_normal_get_block_write,
2530 wbc);
2531}
1543 2532
1544 if (IS_ERR(handle)) { 2533static int ext4_normal_writepage(struct page *page,
1545 ret = PTR_ERR(handle); 2534 struct writeback_control *wbc)
1546 goto out_fail; 2535{
1547 } 2536 struct inode *inode = page->mapping->host;
2537 loff_t size = i_size_read(inode);
2538 loff_t len;
1548 2539
1549 if (!page_has_buffers(page)) { 2540 J_ASSERT(PageLocked(page));
1550 create_empty_buffers(page, inode->i_sb->s_blocksize, 2541 if (page->index == size >> PAGE_CACHE_SHIFT)
1551 (1 << BH_Dirty)|(1 << BH_Uptodate)); 2542 len = size & ~PAGE_CACHE_MASK;
2543 else
2544 len = PAGE_CACHE_SIZE;
2545
2546 if (page_has_buffers(page)) {
2547 /* if page has buffers it should all be mapped
2548 * and allocated. If there are not buffers attached
2549 * to the page we know the page is dirty but it lost
2550 * buffers. That means that at some moment in time
2551 * after write_begin() / write_end() has been called
2552 * all buffers have been clean and thus they must have been
2553 * written at least once. So they are all mapped and we can
2554 * happily proceed with mapping them and writing the page.
2555 */
2556 BUG_ON(walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
2557 ext4_bh_unmapped_or_delay));
1552 } 2558 }
1553 page_bufs = page_buffers(page);
1554 walk_page_buffers(handle, page_bufs, 0,
1555 PAGE_CACHE_SIZE, NULL, bget_one);
1556
1557 ret = block_write_full_page(page, ext4_get_block, wbc);
1558 2559
1559 /* 2560 if (!ext4_journal_current_handle())
1560 * The page can become unlocked at any point now, and 2561 return __ext4_normal_writepage(page, wbc);
1561 * truncate can then come in and change things. So we
1562 * can't touch *page from now on. But *page_bufs is
1563 * safe due to elevated refcount.
1564 */
1565 2562
1566 /*
1567 * And attach them to the current transaction. But only if
1568 * block_write_full_page() succeeded. Otherwise they are unmapped,
1569 * and generally junk.
1570 */
1571 if (ret == 0) {
1572 err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
1573 NULL, jbd2_journal_dirty_data_fn);
1574 if (!ret)
1575 ret = err;
1576 }
1577 walk_page_buffers(handle, page_bufs, 0,
1578 PAGE_CACHE_SIZE, NULL, bput_one);
1579 err = ext4_journal_stop(handle);
1580 if (!ret)
1581 ret = err;
1582 return ret;
1583
1584out_fail:
1585 redirty_page_for_writepage(wbc, page); 2563 redirty_page_for_writepage(wbc, page);
1586 unlock_page(page); 2564 unlock_page(page);
1587 return ret; 2565 return 0;
1588} 2566}
1589 2567
1590static int ext4_writeback_writepage(struct page *page, 2568static int __ext4_journalled_writepage(struct page *page,
1591 struct writeback_control *wbc) 2569 struct writeback_control *wbc)
1592{ 2570{
1593 struct inode *inode = page->mapping->host; 2571 struct address_space *mapping = page->mapping;
2572 struct inode *inode = mapping->host;
2573 struct buffer_head *page_bufs;
1594 handle_t *handle = NULL; 2574 handle_t *handle = NULL;
1595 int ret = 0; 2575 int ret = 0;
1596 int err; 2576 int err;
1597 2577
1598 if (ext4_journal_current_handle()) 2578 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE,
1599 goto out_fail; 2579 ext4_normal_get_block_write);
2580 if (ret != 0)
2581 goto out_unlock;
2582
2583 page_bufs = page_buffers(page);
2584 walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, NULL,
2585 bget_one);
2586 /* As soon as we unlock the page, it can go away, but we have
2587 * references to buffers so we are safe */
2588 unlock_page(page);
1600 2589
1601 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); 2590 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
1602 if (IS_ERR(handle)) { 2591 if (IS_ERR(handle)) {
1603 ret = PTR_ERR(handle); 2592 ret = PTR_ERR(handle);
1604 goto out_fail; 2593 goto out;
1605 } 2594 }
1606 2595
1607 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 2596 ret = walk_page_buffers(handle, page_bufs, 0,
1608 ret = nobh_writepage(page, ext4_get_block, wbc); 2597 PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
1609 else
1610 ret = block_write_full_page(page, ext4_get_block, wbc);
1611 2598
2599 err = walk_page_buffers(handle, page_bufs, 0,
2600 PAGE_CACHE_SIZE, NULL, write_end_fn);
2601 if (ret == 0)
2602 ret = err;
1612 err = ext4_journal_stop(handle); 2603 err = ext4_journal_stop(handle);
1613 if (!ret) 2604 if (!ret)
1614 ret = err; 2605 ret = err;
1615 return ret;
1616 2606
1617out_fail: 2607 walk_page_buffers(handle, page_bufs, 0,
1618 redirty_page_for_writepage(wbc, page); 2608 PAGE_CACHE_SIZE, NULL, bput_one);
2609 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
2610 goto out;
2611
2612out_unlock:
1619 unlock_page(page); 2613 unlock_page(page);
2614out:
1620 return ret; 2615 return ret;
1621} 2616}
1622 2617
@@ -1624,59 +2619,53 @@ static int ext4_journalled_writepage(struct page *page,
1624 struct writeback_control *wbc) 2619 struct writeback_control *wbc)
1625{ 2620{
1626 struct inode *inode = page->mapping->host; 2621 struct inode *inode = page->mapping->host;
1627 handle_t *handle = NULL; 2622 loff_t size = i_size_read(inode);
1628 int ret = 0; 2623 loff_t len;
1629 int err;
1630 2624
1631 if (ext4_journal_current_handle()) 2625 J_ASSERT(PageLocked(page));
1632 goto no_write; 2626 if (page->index == size >> PAGE_CACHE_SHIFT)
2627 len = size & ~PAGE_CACHE_MASK;
2628 else
2629 len = PAGE_CACHE_SIZE;
2630
2631 if (page_has_buffers(page)) {
2632 /* if page has buffers it should all be mapped
2633 * and allocated. If there are not buffers attached
2634 * to the page we know the page is dirty but it lost
2635 * buffers. That means that at some moment in time
2636 * after write_begin() / write_end() has been called
2637 * all buffers have been clean and thus they must have been
2638 * written at least once. So they are all mapped and we can
2639 * happily proceed with mapping them and writing the page.
2640 */
2641 BUG_ON(walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
2642 ext4_bh_unmapped_or_delay));
2643 }
1633 2644
1634 handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode)); 2645 if (ext4_journal_current_handle())
1635 if (IS_ERR(handle)) {
1636 ret = PTR_ERR(handle);
1637 goto no_write; 2646 goto no_write;
1638 }
1639 2647
1640 if (!page_has_buffers(page) || PageChecked(page)) { 2648 if (PageChecked(page)) {
1641 /* 2649 /*
1642 * It's mmapped pagecache. Add buffers and journal it. There 2650 * It's mmapped pagecache. Add buffers and journal it. There
1643 * doesn't seem much point in redirtying the page here. 2651 * doesn't seem much point in redirtying the page here.
1644 */ 2652 */
1645 ClearPageChecked(page); 2653 ClearPageChecked(page);
1646 ret = block_prepare_write(page, 0, PAGE_CACHE_SIZE, 2654 return __ext4_journalled_writepage(page, wbc);
1647 ext4_get_block);
1648 if (ret != 0) {
1649 ext4_journal_stop(handle);
1650 goto out_unlock;
1651 }
1652 ret = walk_page_buffers(handle, page_buffers(page), 0,
1653 PAGE_CACHE_SIZE, NULL, do_journal_get_write_access);
1654
1655 err = walk_page_buffers(handle, page_buffers(page), 0,
1656 PAGE_CACHE_SIZE, NULL, write_end_fn);
1657 if (ret == 0)
1658 ret = err;
1659 EXT4_I(inode)->i_state |= EXT4_STATE_JDATA;
1660 unlock_page(page);
1661 } else { 2655 } else {
1662 /* 2656 /*
1663 * It may be a page full of checkpoint-mode buffers. We don't 2657 * It may be a page full of checkpoint-mode buffers. We don't
1664 * really know unless we go poke around in the buffer_heads. 2658 * really know unless we go poke around in the buffer_heads.
1665 * But block_write_full_page will do the right thing. 2659 * But block_write_full_page will do the right thing.
1666 */ 2660 */
1667 ret = block_write_full_page(page, ext4_get_block, wbc); 2661 return block_write_full_page(page,
2662 ext4_normal_get_block_write,
2663 wbc);
1668 } 2664 }
1669 err = ext4_journal_stop(handle);
1670 if (!ret)
1671 ret = err;
1672out:
1673 return ret;
1674
1675no_write: 2665no_write:
1676 redirty_page_for_writepage(wbc, page); 2666 redirty_page_for_writepage(wbc, page);
1677out_unlock:
1678 unlock_page(page); 2667 unlock_page(page);
1679 goto out; 2668 return 0;
1680} 2669}
1681 2670
1682static int ext4_readpage(struct file *file, struct page *page) 2671static int ext4_readpage(struct file *file, struct page *page)
@@ -1819,7 +2808,7 @@ static int ext4_journalled_set_page_dirty(struct page *page)
1819static const struct address_space_operations ext4_ordered_aops = { 2808static const struct address_space_operations ext4_ordered_aops = {
1820 .readpage = ext4_readpage, 2809 .readpage = ext4_readpage,
1821 .readpages = ext4_readpages, 2810 .readpages = ext4_readpages,
1822 .writepage = ext4_ordered_writepage, 2811 .writepage = ext4_normal_writepage,
1823 .sync_page = block_sync_page, 2812 .sync_page = block_sync_page,
1824 .write_begin = ext4_write_begin, 2813 .write_begin = ext4_write_begin,
1825 .write_end = ext4_ordered_write_end, 2814 .write_end = ext4_ordered_write_end,
@@ -1833,7 +2822,7 @@ static const struct address_space_operations ext4_ordered_aops = {
1833static const struct address_space_operations ext4_writeback_aops = { 2822static const struct address_space_operations ext4_writeback_aops = {
1834 .readpage = ext4_readpage, 2823 .readpage = ext4_readpage,
1835 .readpages = ext4_readpages, 2824 .readpages = ext4_readpages,
1836 .writepage = ext4_writeback_writepage, 2825 .writepage = ext4_normal_writepage,
1837 .sync_page = block_sync_page, 2826 .sync_page = block_sync_page,
1838 .write_begin = ext4_write_begin, 2827 .write_begin = ext4_write_begin,
1839 .write_end = ext4_writeback_write_end, 2828 .write_end = ext4_writeback_write_end,
@@ -1857,10 +2846,31 @@ static const struct address_space_operations ext4_journalled_aops = {
1857 .releasepage = ext4_releasepage, 2846 .releasepage = ext4_releasepage,
1858}; 2847};
1859 2848
2849static const struct address_space_operations ext4_da_aops = {
2850 .readpage = ext4_readpage,
2851 .readpages = ext4_readpages,
2852 .writepage = ext4_da_writepage,
2853 .writepages = ext4_da_writepages,
2854 .sync_page = block_sync_page,
2855 .write_begin = ext4_da_write_begin,
2856 .write_end = ext4_da_write_end,
2857 .bmap = ext4_bmap,
2858 .invalidatepage = ext4_da_invalidatepage,
2859 .releasepage = ext4_releasepage,
2860 .direct_IO = ext4_direct_IO,
2861 .migratepage = buffer_migrate_page,
2862};
2863
1860void ext4_set_aops(struct inode *inode) 2864void ext4_set_aops(struct inode *inode)
1861{ 2865{
1862 if (ext4_should_order_data(inode)) 2866 if (ext4_should_order_data(inode) &&
2867 test_opt(inode->i_sb, DELALLOC))
2868 inode->i_mapping->a_ops = &ext4_da_aops;
2869 else if (ext4_should_order_data(inode))
1863 inode->i_mapping->a_ops = &ext4_ordered_aops; 2870 inode->i_mapping->a_ops = &ext4_ordered_aops;
2871 else if (ext4_should_writeback_data(inode) &&
2872 test_opt(inode->i_sb, DELALLOC))
2873 inode->i_mapping->a_ops = &ext4_da_aops;
1864 else if (ext4_should_writeback_data(inode)) 2874 else if (ext4_should_writeback_data(inode))
1865 inode->i_mapping->a_ops = &ext4_writeback_aops; 2875 inode->i_mapping->a_ops = &ext4_writeback_aops;
1866 else 2876 else
@@ -1873,7 +2883,7 @@ void ext4_set_aops(struct inode *inode)
1873 * This required during truncate. We need to physically zero the tail end 2883 * This required during truncate. We need to physically zero the tail end
1874 * of that block so it doesn't yield old data if the file is later grown. 2884 * of that block so it doesn't yield old data if the file is later grown.
1875 */ 2885 */
1876int ext4_block_truncate_page(handle_t *handle, struct page *page, 2886int ext4_block_truncate_page(handle_t *handle,
1877 struct address_space *mapping, loff_t from) 2887 struct address_space *mapping, loff_t from)
1878{ 2888{
1879 ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT; 2889 ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
@@ -1882,8 +2892,13 @@ int ext4_block_truncate_page(handle_t *handle, struct page *page,
1882 ext4_lblk_t iblock; 2892 ext4_lblk_t iblock;
1883 struct inode *inode = mapping->host; 2893 struct inode *inode = mapping->host;
1884 struct buffer_head *bh; 2894 struct buffer_head *bh;
2895 struct page *page;
1885 int err = 0; 2896 int err = 0;
1886 2897
2898 page = grab_cache_page(mapping, from >> PAGE_CACHE_SHIFT);
2899 if (!page)
2900 return -EINVAL;
2901
1887 blocksize = inode->i_sb->s_blocksize; 2902 blocksize = inode->i_sb->s_blocksize;
1888 length = blocksize - (offset & (blocksize - 1)); 2903 length = blocksize - (offset & (blocksize - 1));
1889 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); 2904 iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
@@ -1956,7 +2971,7 @@ int ext4_block_truncate_page(handle_t *handle, struct page *page,
1956 err = ext4_journal_dirty_metadata(handle, bh); 2971 err = ext4_journal_dirty_metadata(handle, bh);
1957 } else { 2972 } else {
1958 if (ext4_should_order_data(inode)) 2973 if (ext4_should_order_data(inode))
1959 err = ext4_journal_dirty_data(handle, bh); 2974 err = ext4_jbd2_file_inode(handle, inode);
1960 mark_buffer_dirty(bh); 2975 mark_buffer_dirty(bh);
1961 } 2976 }
1962 2977
@@ -2179,7 +3194,21 @@ static void ext4_free_data(handle_t *handle, struct inode *inode,
2179 3194
2180 if (this_bh) { 3195 if (this_bh) {
2181 BUFFER_TRACE(this_bh, "call ext4_journal_dirty_metadata"); 3196 BUFFER_TRACE(this_bh, "call ext4_journal_dirty_metadata");
2182 ext4_journal_dirty_metadata(handle, this_bh); 3197
3198 /*
3199 * The buffer head should have an attached journal head at this
3200 * point. However, if the data is corrupted and an indirect
3201 * block pointed to itself, it would have been detached when
3202 * the block was cleared. Check for this instead of OOPSing.
3203 */
3204 if (bh2jh(this_bh))
3205 ext4_journal_dirty_metadata(handle, this_bh);
3206 else
3207 ext4_error(inode->i_sb, __func__,
3208 "circular indirect block detected, "
3209 "inode=%lu, block=%llu",
3210 inode->i_ino,
3211 (unsigned long long) this_bh->b_blocknr);
2183 } 3212 }
2184} 3213}
2185 3214
@@ -2305,6 +3334,19 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
2305 } 3334 }
2306} 3335}
2307 3336
3337int ext4_can_truncate(struct inode *inode)
3338{
3339 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
3340 return 0;
3341 if (S_ISREG(inode->i_mode))
3342 return 1;
3343 if (S_ISDIR(inode->i_mode))
3344 return 1;
3345 if (S_ISLNK(inode->i_mode))
3346 return !ext4_inode_is_fast_symlink(inode);
3347 return 0;
3348}
3349
2308/* 3350/*
2309 * ext4_truncate() 3351 * ext4_truncate()
2310 * 3352 *
@@ -2347,51 +3389,25 @@ void ext4_truncate(struct inode *inode)
2347 int n; 3389 int n;
2348 ext4_lblk_t last_block; 3390 ext4_lblk_t last_block;
2349 unsigned blocksize = inode->i_sb->s_blocksize; 3391 unsigned blocksize = inode->i_sb->s_blocksize;
2350 struct page *page;
2351 3392
2352 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || 3393 if (!ext4_can_truncate(inode))
2353 S_ISLNK(inode->i_mode)))
2354 return;
2355 if (ext4_inode_is_fast_symlink(inode))
2356 return;
2357 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2358 return; 3394 return;
2359 3395
2360 /*
2361 * We have to lock the EOF page here, because lock_page() nests
2362 * outside jbd2_journal_start().
2363 */
2364 if ((inode->i_size & (blocksize - 1)) == 0) {
2365 /* Block boundary? Nothing to do */
2366 page = NULL;
2367 } else {
2368 page = grab_cache_page(mapping,
2369 inode->i_size >> PAGE_CACHE_SHIFT);
2370 if (!page)
2371 return;
2372 }
2373
2374 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) { 3396 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {
2375 ext4_ext_truncate(inode, page); 3397 ext4_ext_truncate(inode);
2376 return; 3398 return;
2377 } 3399 }
2378 3400
2379 handle = start_transaction(inode); 3401 handle = start_transaction(inode);
2380 if (IS_ERR(handle)) { 3402 if (IS_ERR(handle))
2381 if (page) {
2382 clear_highpage(page);
2383 flush_dcache_page(page);
2384 unlock_page(page);
2385 page_cache_release(page);
2386 }
2387 return; /* AKPM: return what? */ 3403 return; /* AKPM: return what? */
2388 }
2389 3404
2390 last_block = (inode->i_size + blocksize-1) 3405 last_block = (inode->i_size + blocksize-1)
2391 >> EXT4_BLOCK_SIZE_BITS(inode->i_sb); 3406 >> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
2392 3407
2393 if (page) 3408 if (inode->i_size & (blocksize - 1))
2394 ext4_block_truncate_page(handle, page, mapping, inode->i_size); 3409 if (ext4_block_truncate_page(handle, mapping, inode->i_size))
3410 goto out_stop;
2395 3411
2396 n = ext4_block_to_path(inode, last_block, offsets, NULL); 3412 n = ext4_block_to_path(inode, last_block, offsets, NULL);
2397 if (n == 0) 3413 if (n == 0)
@@ -2410,6 +3426,11 @@ void ext4_truncate(struct inode *inode)
2410 goto out_stop; 3426 goto out_stop;
2411 3427
2412 /* 3428 /*
3429 * From here we block out all ext4_get_block() callers who want to
3430 * modify the block allocation tree.
3431 */
3432 down_write(&ei->i_data_sem);
3433 /*
2413 * The orphan list entry will now protect us from any crash which 3434 * The orphan list entry will now protect us from any crash which
2414 * occurs before the truncate completes, so it is now safe to propagate 3435 * occurs before the truncate completes, so it is now safe to propagate
2415 * the new, shorter inode size (held for now in i_size) into the 3436 * the new, shorter inode size (held for now in i_size) into the
@@ -2418,12 +3439,6 @@ void ext4_truncate(struct inode *inode)
2418 */ 3439 */
2419 ei->i_disksize = inode->i_size; 3440 ei->i_disksize = inode->i_size;
2420 3441
2421 /*
2422 * From here we block out all ext4_get_block() callers who want to
2423 * modify the block allocation tree.
2424 */
2425 down_write(&ei->i_data_sem);
2426
2427 if (n == 1) { /* direct blocks */ 3442 if (n == 1) { /* direct blocks */
2428 ext4_free_data(handle, inode, NULL, i_data+offsets[0], 3443 ext4_free_data(handle, inode, NULL, i_data+offsets[0],
2429 i_data + EXT4_NDIR_BLOCKS); 3444 i_data + EXT4_NDIR_BLOCKS);
@@ -3107,7 +4122,14 @@ int ext4_write_inode(struct inode *inode, int wait)
3107 * be freed, so we have a strong guarantee that no future commit will 4122 * be freed, so we have a strong guarantee that no future commit will
3108 * leave these blocks visible to the user.) 4123 * leave these blocks visible to the user.)
3109 * 4124 *
3110 * Called with inode->sem down. 4125 * Another thing we have to assure is that if we are in ordered mode
4126 * and inode is still attached to the committing transaction, we must
4127 * we start writeout of all the dirty pages which are being truncated.
4128 * This way we are sure that all the data written in the previous
4129 * transaction are already on disk (truncate waits for pages under
4130 * writeback).
4131 *
4132 * Called with inode->i_mutex down.
3111 */ 4133 */
3112int ext4_setattr(struct dentry *dentry, struct iattr *attr) 4134int ext4_setattr(struct dentry *dentry, struct iattr *attr)
3113{ 4135{
@@ -3173,6 +4195,22 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
3173 if (!error) 4195 if (!error)
3174 error = rc; 4196 error = rc;
3175 ext4_journal_stop(handle); 4197 ext4_journal_stop(handle);
4198
4199 if (ext4_should_order_data(inode)) {
4200 error = ext4_begin_ordered_truncate(inode,
4201 attr->ia_size);
4202 if (error) {
4203 /* Do as much error cleanup as possible */
4204 handle = ext4_journal_start(inode, 3);
4205 if (IS_ERR(handle)) {
4206 ext4_orphan_del(NULL, inode);
4207 goto err_out;
4208 }
4209 ext4_orphan_del(handle, inode);
4210 ext4_journal_stop(handle);
4211 goto err_out;
4212 }
4213 }
3176 } 4214 }
3177 4215
3178 rc = inode_setattr(inode, attr); 4216 rc = inode_setattr(inode, attr);
@@ -3193,6 +4231,32 @@ err_out:
3193 return error; 4231 return error;
3194} 4232}
3195 4233
4234int ext4_getattr(struct vfsmount *mnt, struct dentry *dentry,
4235 struct kstat *stat)
4236{
4237 struct inode *inode;
4238 unsigned long delalloc_blocks;
4239
4240 inode = dentry->d_inode;
4241 generic_fillattr(inode, stat);
4242
4243 /*
4244 * We can't update i_blocks if the block allocation is delayed
4245 * otherwise in the case of system crash before the real block
4246 * allocation is done, we will have i_blocks inconsistent with
4247 * on-disk file blocks.
4248 * We always keep i_blocks updated together with real
4249 * allocation. But to not confuse with user, stat
4250 * will return the blocks that include the delayed allocation
4251 * blocks for this file.
4252 */
4253 spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
4254 delalloc_blocks = EXT4_I(inode)->i_reserved_data_blocks;
4255 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
4256
4257 stat->blocks += (delalloc_blocks << inode->i_sb->s_blocksize_bits)>>9;
4258 return 0;
4259}
3196 4260
3197/* 4261/*
3198 * How many blocks doth make a writepage()? 4262 * How many blocks doth make a writepage()?
@@ -3506,3 +4570,64 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
3506 4570
3507 return err; 4571 return err;
3508} 4572}
4573
4574static int ext4_bh_unmapped(handle_t *handle, struct buffer_head *bh)
4575{
4576 return !buffer_mapped(bh);
4577}
4578
4579int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page)
4580{
4581 loff_t size;
4582 unsigned long len;
4583 int ret = -EINVAL;
4584 struct file *file = vma->vm_file;
4585 struct inode *inode = file->f_path.dentry->d_inode;
4586 struct address_space *mapping = inode->i_mapping;
4587
4588 /*
4589 * Get i_alloc_sem to stop truncates messing with the inode. We cannot
4590 * get i_mutex because we are already holding mmap_sem.
4591 */
4592 down_read(&inode->i_alloc_sem);
4593 size = i_size_read(inode);
4594 if (page->mapping != mapping || size <= page_offset(page)
4595 || !PageUptodate(page)) {
4596 /* page got truncated from under us? */
4597 goto out_unlock;
4598 }
4599 ret = 0;
4600 if (PageMappedToDisk(page))
4601 goto out_unlock;
4602
4603 if (page->index == size >> PAGE_CACHE_SHIFT)
4604 len = size & ~PAGE_CACHE_MASK;
4605 else
4606 len = PAGE_CACHE_SIZE;
4607
4608 if (page_has_buffers(page)) {
4609 /* return if we have all the buffers mapped */
4610 if (!walk_page_buffers(NULL, page_buffers(page), 0, len, NULL,
4611 ext4_bh_unmapped))
4612 goto out_unlock;
4613 }
4614 /*
4615 * OK, we need to fill the hole... Do write_begin write_end
4616 * to do block allocation/reservation.We are not holding
4617 * inode.i__mutex here. That allow * parallel write_begin,
4618 * write_end call. lock_page prevent this from happening
4619 * on the same page though
4620 */
4621 ret = mapping->a_ops->write_begin(file, mapping, page_offset(page),
4622 len, AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
4623 if (ret < 0)
4624 goto out_unlock;
4625 ret = mapping->a_ops->write_end(file, mapping, page_offset(page),
4626 len, len, page, NULL);
4627 if (ret < 0)
4628 goto out_unlock;
4629 ret = 0;
4630out_unlock:
4631 up_read(&inode->i_alloc_sem);
4632 return ret;
4633}
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index c9900aade15..8d141a25bbe 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -381,22 +381,28 @@ static inline void mb_clear_bit_atomic(spinlock_t *lock, int bit, void *addr)
381 381
382static inline int mb_find_next_zero_bit(void *addr, int max, int start) 382static inline int mb_find_next_zero_bit(void *addr, int max, int start)
383{ 383{
384 int fix = 0; 384 int fix = 0, ret, tmpmax;
385 addr = mb_correct_addr_and_bit(&fix, addr); 385 addr = mb_correct_addr_and_bit(&fix, addr);
386 max += fix; 386 tmpmax = max + fix;
387 start += fix; 387 start += fix;
388 388
389 return ext4_find_next_zero_bit(addr, max, start) - fix; 389 ret = ext4_find_next_zero_bit(addr, tmpmax, start) - fix;
390 if (ret > max)
391 return max;
392 return ret;
390} 393}
391 394
392static inline int mb_find_next_bit(void *addr, int max, int start) 395static inline int mb_find_next_bit(void *addr, int max, int start)
393{ 396{
394 int fix = 0; 397 int fix = 0, ret, tmpmax;
395 addr = mb_correct_addr_and_bit(&fix, addr); 398 addr = mb_correct_addr_and_bit(&fix, addr);
396 max += fix; 399 tmpmax = max + fix;
397 start += fix; 400 start += fix;
398 401
399 return ext4_find_next_bit(addr, max, start) - fix; 402 ret = ext4_find_next_bit(addr, tmpmax, start) - fix;
403 if (ret > max)
404 return max;
405 return ret;
400} 406}
401 407
402static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max) 408static void *mb_find_buddy(struct ext4_buddy *e4b, int order, int *max)
@@ -803,6 +809,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
803 if (!buffer_uptodate(bh[i])) 809 if (!buffer_uptodate(bh[i]))
804 goto out; 810 goto out;
805 811
812 err = 0;
806 first_block = page->index * blocks_per_page; 813 first_block = page->index * blocks_per_page;
807 for (i = 0; i < blocks_per_page; i++) { 814 for (i = 0; i < blocks_per_page; i++) {
808 int group; 815 int group;
@@ -883,6 +890,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
883 int pnum; 890 int pnum;
884 int poff; 891 int poff;
885 struct page *page; 892 struct page *page;
893 int ret;
886 894
887 mb_debug("load group %lu\n", group); 895 mb_debug("load group %lu\n", group);
888 896
@@ -914,15 +922,21 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
914 if (page) { 922 if (page) {
915 BUG_ON(page->mapping != inode->i_mapping); 923 BUG_ON(page->mapping != inode->i_mapping);
916 if (!PageUptodate(page)) { 924 if (!PageUptodate(page)) {
917 ext4_mb_init_cache(page, NULL); 925 ret = ext4_mb_init_cache(page, NULL);
926 if (ret) {
927 unlock_page(page);
928 goto err;
929 }
918 mb_cmp_bitmaps(e4b, page_address(page) + 930 mb_cmp_bitmaps(e4b, page_address(page) +
919 (poff * sb->s_blocksize)); 931 (poff * sb->s_blocksize));
920 } 932 }
921 unlock_page(page); 933 unlock_page(page);
922 } 934 }
923 } 935 }
924 if (page == NULL || !PageUptodate(page)) 936 if (page == NULL || !PageUptodate(page)) {
937 ret = -EIO;
925 goto err; 938 goto err;
939 }
926 e4b->bd_bitmap_page = page; 940 e4b->bd_bitmap_page = page;
927 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize); 941 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
928 mark_page_accessed(page); 942 mark_page_accessed(page);
@@ -938,14 +952,20 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
938 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS); 952 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
939 if (page) { 953 if (page) {
940 BUG_ON(page->mapping != inode->i_mapping); 954 BUG_ON(page->mapping != inode->i_mapping);
941 if (!PageUptodate(page)) 955 if (!PageUptodate(page)) {
942 ext4_mb_init_cache(page, e4b->bd_bitmap); 956 ret = ext4_mb_init_cache(page, e4b->bd_bitmap);
943 957 if (ret) {
958 unlock_page(page);
959 goto err;
960 }
961 }
944 unlock_page(page); 962 unlock_page(page);
945 } 963 }
946 } 964 }
947 if (page == NULL || !PageUptodate(page)) 965 if (page == NULL || !PageUptodate(page)) {
966 ret = -EIO;
948 goto err; 967 goto err;
968 }
949 e4b->bd_buddy_page = page; 969 e4b->bd_buddy_page = page;
950 e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize); 970 e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize);
951 mark_page_accessed(page); 971 mark_page_accessed(page);
@@ -962,7 +982,7 @@ err:
962 page_cache_release(e4b->bd_buddy_page); 982 page_cache_release(e4b->bd_buddy_page);
963 e4b->bd_buddy = NULL; 983 e4b->bd_buddy = NULL;
964 e4b->bd_bitmap = NULL; 984 e4b->bd_bitmap = NULL;
965 return -EIO; 985 return ret;
966} 986}
967 987
968static void ext4_mb_release_desc(struct ext4_buddy *e4b) 988static void ext4_mb_release_desc(struct ext4_buddy *e4b)
@@ -1031,7 +1051,7 @@ static void mb_set_bits(spinlock_t *lock, void *bm, int cur, int len)
1031 } 1051 }
1032} 1052}
1033 1053
1034static int mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b, 1054static void mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1035 int first, int count) 1055 int first, int count)
1036{ 1056{
1037 int block = 0; 1057 int block = 0;
@@ -1071,11 +1091,12 @@ static int mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1071 blocknr += block; 1091 blocknr += block;
1072 blocknr += 1092 blocknr +=
1073 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 1093 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
1074 1094 ext4_unlock_group(sb, e4b->bd_group);
1075 ext4_error(sb, __func__, "double-free of inode" 1095 ext4_error(sb, __func__, "double-free of inode"
1076 " %lu's block %llu(bit %u in group %lu)\n", 1096 " %lu's block %llu(bit %u in group %lu)\n",
1077 inode ? inode->i_ino : 0, blocknr, block, 1097 inode ? inode->i_ino : 0, blocknr, block,
1078 e4b->bd_group); 1098 e4b->bd_group);
1099 ext4_lock_group(sb, e4b->bd_group);
1079 } 1100 }
1080 mb_clear_bit(block, EXT4_MB_BITMAP(e4b)); 1101 mb_clear_bit(block, EXT4_MB_BITMAP(e4b));
1081 e4b->bd_info->bb_counters[order]++; 1102 e4b->bd_info->bb_counters[order]++;
@@ -1113,8 +1134,6 @@ static int mb_free_blocks(struct inode *inode, struct ext4_buddy *e4b,
1113 } while (1); 1134 } while (1);
1114 } 1135 }
1115 mb_check_buddy(e4b); 1136 mb_check_buddy(e4b);
1116
1117 return 0;
1118} 1137}
1119 1138
1120static int mb_find_extent(struct ext4_buddy *e4b, int order, int block, 1139static int mb_find_extent(struct ext4_buddy *e4b, int order, int block,
@@ -1730,10 +1749,6 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
1730 ac->ac_g_ex.fe_start = sbi->s_mb_last_start; 1749 ac->ac_g_ex.fe_start = sbi->s_mb_last_start;
1731 spin_unlock(&sbi->s_md_lock); 1750 spin_unlock(&sbi->s_md_lock);
1732 } 1751 }
1733
1734 /* searching for the right group start from the goal value specified */
1735 group = ac->ac_g_ex.fe_group;
1736
1737 /* Let's just scan groups to find more-less suitable blocks */ 1752 /* Let's just scan groups to find more-less suitable blocks */
1738 cr = ac->ac_2order ? 0 : 1; 1753 cr = ac->ac_2order ? 0 : 1;
1739 /* 1754 /*
@@ -1743,6 +1758,12 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
1743repeat: 1758repeat:
1744 for (; cr < 4 && ac->ac_status == AC_STATUS_CONTINUE; cr++) { 1759 for (; cr < 4 && ac->ac_status == AC_STATUS_CONTINUE; cr++) {
1745 ac->ac_criteria = cr; 1760 ac->ac_criteria = cr;
1761 /*
1762 * searching for the right group start
1763 * from the goal value specified
1764 */
1765 group = ac->ac_g_ex.fe_group;
1766
1746 for (i = 0; i < EXT4_SB(sb)->s_groups_count; group++, i++) { 1767 for (i = 0; i < EXT4_SB(sb)->s_groups_count; group++, i++) {
1747 struct ext4_group_info *grp; 1768 struct ext4_group_info *grp;
1748 struct ext4_group_desc *desc; 1769 struct ext4_group_desc *desc;
@@ -1963,6 +1984,8 @@ static int ext4_mb_seq_history_open(struct inode *inode, struct file *file)
1963 int rc; 1984 int rc;
1964 int size; 1985 int size;
1965 1986
1987 if (unlikely(sbi->s_mb_history == NULL))
1988 return -ENOMEM;
1966 s = kmalloc(sizeof(*s), GFP_KERNEL); 1989 s = kmalloc(sizeof(*s), GFP_KERNEL);
1967 if (s == NULL) 1990 if (s == NULL)
1968 return -ENOMEM; 1991 return -ENOMEM;
@@ -2165,9 +2188,7 @@ static void ext4_mb_history_init(struct super_block *sb)
2165 sbi->s_mb_history_cur = 0; 2188 sbi->s_mb_history_cur = 0;
2166 spin_lock_init(&sbi->s_mb_history_lock); 2189 spin_lock_init(&sbi->s_mb_history_lock);
2167 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history); 2190 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history);
2168 sbi->s_mb_history = kmalloc(i, GFP_KERNEL); 2191 sbi->s_mb_history = kzalloc(i, GFP_KERNEL);
2169 if (likely(sbi->s_mb_history != NULL))
2170 memset(sbi->s_mb_history, 0, i);
2171 /* if we can't allocate history, then we simple won't use it */ 2192 /* if we can't allocate history, then we simple won't use it */
2172} 2193}
2173 2194
@@ -2215,21 +2236,192 @@ ext4_mb_store_history(struct ext4_allocation_context *ac)
2215#define ext4_mb_history_init(sb) 2236#define ext4_mb_history_init(sb)
2216#endif 2237#endif
2217 2238
2239
2240/* Create and initialize ext4_group_info data for the given group. */
2241int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group,
2242 struct ext4_group_desc *desc)
2243{
2244 int i, len;
2245 int metalen = 0;
2246 struct ext4_sb_info *sbi = EXT4_SB(sb);
2247 struct ext4_group_info **meta_group_info;
2248
2249 /*
2250 * First check if this group is the first of a reserved block.
2251 * If it's true, we have to allocate a new table of pointers
2252 * to ext4_group_info structures
2253 */
2254 if (group % EXT4_DESC_PER_BLOCK(sb) == 0) {
2255 metalen = sizeof(*meta_group_info) <<
2256 EXT4_DESC_PER_BLOCK_BITS(sb);
2257 meta_group_info = kmalloc(metalen, GFP_KERNEL);
2258 if (meta_group_info == NULL) {
2259 printk(KERN_ERR "EXT4-fs: can't allocate mem for a "
2260 "buddy group\n");
2261 goto exit_meta_group_info;
2262 }
2263 sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)] =
2264 meta_group_info;
2265 }
2266
2267 /*
2268 * calculate needed size. if change bb_counters size,
2269 * don't forget about ext4_mb_generate_buddy()
2270 */
2271 len = offsetof(typeof(**meta_group_info),
2272 bb_counters[sb->s_blocksize_bits + 2]);
2273
2274 meta_group_info =
2275 sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)];
2276 i = group & (EXT4_DESC_PER_BLOCK(sb) - 1);
2277
2278 meta_group_info[i] = kzalloc(len, GFP_KERNEL);
2279 if (meta_group_info[i] == NULL) {
2280 printk(KERN_ERR "EXT4-fs: can't allocate buddy mem\n");
2281 goto exit_group_info;
2282 }
2283 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT,
2284 &(meta_group_info[i]->bb_state));
2285
2286 /*
2287 * initialize bb_free to be able to skip
2288 * empty groups without initialization
2289 */
2290 if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
2291 meta_group_info[i]->bb_free =
2292 ext4_free_blocks_after_init(sb, group, desc);
2293 } else {
2294 meta_group_info[i]->bb_free =
2295 le16_to_cpu(desc->bg_free_blocks_count);
2296 }
2297
2298 INIT_LIST_HEAD(&meta_group_info[i]->bb_prealloc_list);
2299
2300#ifdef DOUBLE_CHECK
2301 {
2302 struct buffer_head *bh;
2303 meta_group_info[i]->bb_bitmap =
2304 kmalloc(sb->s_blocksize, GFP_KERNEL);
2305 BUG_ON(meta_group_info[i]->bb_bitmap == NULL);
2306 bh = ext4_read_block_bitmap(sb, group);
2307 BUG_ON(bh == NULL);
2308 memcpy(meta_group_info[i]->bb_bitmap, bh->b_data,
2309 sb->s_blocksize);
2310 put_bh(bh);
2311 }
2312#endif
2313
2314 return 0;
2315
2316exit_group_info:
2317 /* If a meta_group_info table has been allocated, release it now */
2318 if (group % EXT4_DESC_PER_BLOCK(sb) == 0)
2319 kfree(sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)]);
2320exit_meta_group_info:
2321 return -ENOMEM;
2322} /* ext4_mb_add_groupinfo */
2323
2324/*
2325 * Add a group to the existing groups.
2326 * This function is used for online resize
2327 */
2328int ext4_mb_add_more_groupinfo(struct super_block *sb, ext4_group_t group,
2329 struct ext4_group_desc *desc)
2330{
2331 struct ext4_sb_info *sbi = EXT4_SB(sb);
2332 struct inode *inode = sbi->s_buddy_cache;
2333 int blocks_per_page;
2334 int block;
2335 int pnum;
2336 struct page *page;
2337 int err;
2338
2339 /* Add group based on group descriptor*/
2340 err = ext4_mb_add_groupinfo(sb, group, desc);
2341 if (err)
2342 return err;
2343
2344 /*
2345 * Cache pages containing dynamic mb_alloc datas (buddy and bitmap
2346 * datas) are set not up to date so that they will be re-initilaized
2347 * during the next call to ext4_mb_load_buddy
2348 */
2349
2350 /* Set buddy page as not up to date */
2351 blocks_per_page = PAGE_CACHE_SIZE / sb->s_blocksize;
2352 block = group * 2;
2353 pnum = block / blocks_per_page;
2354 page = find_get_page(inode->i_mapping, pnum);
2355 if (page != NULL) {
2356 ClearPageUptodate(page);
2357 page_cache_release(page);
2358 }
2359
2360 /* Set bitmap page as not up to date */
2361 block++;
2362 pnum = block / blocks_per_page;
2363 page = find_get_page(inode->i_mapping, pnum);
2364 if (page != NULL) {
2365 ClearPageUptodate(page);
2366 page_cache_release(page);
2367 }
2368
2369 return 0;
2370}
2371
2372/*
2373 * Update an existing group.
2374 * This function is used for online resize
2375 */
2376void ext4_mb_update_group_info(struct ext4_group_info *grp, ext4_grpblk_t add)
2377{
2378 grp->bb_free += add;
2379}
2380
2218static int ext4_mb_init_backend(struct super_block *sb) 2381static int ext4_mb_init_backend(struct super_block *sb)
2219{ 2382{
2220 ext4_group_t i; 2383 ext4_group_t i;
2221 int j, len, metalen; 2384 int metalen;
2222 struct ext4_sb_info *sbi = EXT4_SB(sb); 2385 struct ext4_sb_info *sbi = EXT4_SB(sb);
2223 int num_meta_group_infos = 2386 struct ext4_super_block *es = sbi->s_es;
2224 (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) >> 2387 int num_meta_group_infos;
2225 EXT4_DESC_PER_BLOCK_BITS(sb); 2388 int num_meta_group_infos_max;
2389 int array_size;
2226 struct ext4_group_info **meta_group_info; 2390 struct ext4_group_info **meta_group_info;
2391 struct ext4_group_desc *desc;
2392
2393 /* This is the number of blocks used by GDT */
2394 num_meta_group_infos = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) -
2395 1) >> EXT4_DESC_PER_BLOCK_BITS(sb);
2396
2397 /*
2398 * This is the total number of blocks used by GDT including
2399 * the number of reserved blocks for GDT.
2400 * The s_group_info array is allocated with this value
2401 * to allow a clean online resize without a complex
2402 * manipulation of pointer.
2403 * The drawback is the unused memory when no resize
2404 * occurs but it's very low in terms of pages
2405 * (see comments below)
2406 * Need to handle this properly when META_BG resizing is allowed
2407 */
2408 num_meta_group_infos_max = num_meta_group_infos +
2409 le16_to_cpu(es->s_reserved_gdt_blocks);
2227 2410
2411 /*
2412 * array_size is the size of s_group_info array. We round it
2413 * to the next power of two because this approximation is done
2414 * internally by kmalloc so we can have some more memory
2415 * for free here (e.g. may be used for META_BG resize).
2416 */
2417 array_size = 1;
2418 while (array_size < sizeof(*sbi->s_group_info) *
2419 num_meta_group_infos_max)
2420 array_size = array_size << 1;
2228 /* An 8TB filesystem with 64-bit pointers requires a 4096 byte 2421 /* An 8TB filesystem with 64-bit pointers requires a 4096 byte
2229 * kmalloc. A 128kb malloc should suffice for a 256TB filesystem. 2422 * kmalloc. A 128kb malloc should suffice for a 256TB filesystem.
2230 * So a two level scheme suffices for now. */ 2423 * So a two level scheme suffices for now. */
2231 sbi->s_group_info = kmalloc(sizeof(*sbi->s_group_info) * 2424 sbi->s_group_info = kmalloc(array_size, GFP_KERNEL);
2232 num_meta_group_infos, GFP_KERNEL);
2233 if (sbi->s_group_info == NULL) { 2425 if (sbi->s_group_info == NULL) {
2234 printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n"); 2426 printk(KERN_ERR "EXT4-fs: can't allocate buddy meta group\n");
2235 return -ENOMEM; 2427 return -ENOMEM;
@@ -2256,63 +2448,15 @@ static int ext4_mb_init_backend(struct super_block *sb)
2256 sbi->s_group_info[i] = meta_group_info; 2448 sbi->s_group_info[i] = meta_group_info;
2257 } 2449 }
2258 2450
2259 /*
2260 * calculate needed size. if change bb_counters size,
2261 * don't forget about ext4_mb_generate_buddy()
2262 */
2263 len = sizeof(struct ext4_group_info);
2264 len += sizeof(unsigned short) * (sb->s_blocksize_bits + 2);
2265 for (i = 0; i < sbi->s_groups_count; i++) { 2451 for (i = 0; i < sbi->s_groups_count; i++) {
2266 struct ext4_group_desc *desc;
2267
2268 meta_group_info =
2269 sbi->s_group_info[i >> EXT4_DESC_PER_BLOCK_BITS(sb)];
2270 j = i & (EXT4_DESC_PER_BLOCK(sb) - 1);
2271
2272 meta_group_info[j] = kzalloc(len, GFP_KERNEL);
2273 if (meta_group_info[j] == NULL) {
2274 printk(KERN_ERR "EXT4-fs: can't allocate buddy mem\n");
2275 goto err_freebuddy;
2276 }
2277 desc = ext4_get_group_desc(sb, i, NULL); 2452 desc = ext4_get_group_desc(sb, i, NULL);
2278 if (desc == NULL) { 2453 if (desc == NULL) {
2279 printk(KERN_ERR 2454 printk(KERN_ERR
2280 "EXT4-fs: can't read descriptor %lu\n", i); 2455 "EXT4-fs: can't read descriptor %lu\n", i);
2281 i++;
2282 goto err_freebuddy; 2456 goto err_freebuddy;
2283 } 2457 }
2284 memset(meta_group_info[j], 0, len); 2458 if (ext4_mb_add_groupinfo(sb, i, desc) != 0)
2285 set_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, 2459 goto err_freebuddy;
2286 &(meta_group_info[j]->bb_state));
2287
2288 /*
2289 * initialize bb_free to be able to skip
2290 * empty groups without initialization
2291 */
2292 if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
2293 meta_group_info[j]->bb_free =
2294 ext4_free_blocks_after_init(sb, i, desc);
2295 } else {
2296 meta_group_info[j]->bb_free =
2297 le16_to_cpu(desc->bg_free_blocks_count);
2298 }
2299
2300 INIT_LIST_HEAD(&meta_group_info[j]->bb_prealloc_list);
2301
2302#ifdef DOUBLE_CHECK
2303 {
2304 struct buffer_head *bh;
2305 meta_group_info[j]->bb_bitmap =
2306 kmalloc(sb->s_blocksize, GFP_KERNEL);
2307 BUG_ON(meta_group_info[j]->bb_bitmap == NULL);
2308 bh = read_block_bitmap(sb, i);
2309 BUG_ON(bh == NULL);
2310 memcpy(meta_group_info[j]->bb_bitmap, bh->b_data,
2311 sb->s_blocksize);
2312 put_bh(bh);
2313 }
2314#endif
2315
2316 } 2460 }
2317 2461
2318 return 0; 2462 return 0;
@@ -2336,6 +2480,7 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
2336 unsigned i; 2480 unsigned i;
2337 unsigned offset; 2481 unsigned offset;
2338 unsigned max; 2482 unsigned max;
2483 int ret;
2339 2484
2340 if (!test_opt(sb, MBALLOC)) 2485 if (!test_opt(sb, MBALLOC))
2341 return 0; 2486 return 0;
@@ -2370,12 +2515,12 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
2370 } while (i <= sb->s_blocksize_bits + 1); 2515 } while (i <= sb->s_blocksize_bits + 1);
2371 2516
2372 /* init file for buddy data */ 2517 /* init file for buddy data */
2373 i = ext4_mb_init_backend(sb); 2518 ret = ext4_mb_init_backend(sb);
2374 if (i) { 2519 if (ret != 0) {
2375 clear_opt(sbi->s_mount_opt, MBALLOC); 2520 clear_opt(sbi->s_mount_opt, MBALLOC);
2376 kfree(sbi->s_mb_offsets); 2521 kfree(sbi->s_mb_offsets);
2377 kfree(sbi->s_mb_maxs); 2522 kfree(sbi->s_mb_maxs);
2378 return i; 2523 return ret;
2379 } 2524 }
2380 2525
2381 spin_lock_init(&sbi->s_md_lock); 2526 spin_lock_init(&sbi->s_md_lock);
@@ -2548,8 +2693,7 @@ ext4_mb_free_committed_blocks(struct super_block *sb)
2548 ext4_lock_group(sb, md->group); 2693 ext4_lock_group(sb, md->group);
2549 for (i = 0; i < md->num; i++) { 2694 for (i = 0; i < md->num; i++) {
2550 mb_debug(" %u", md->blocks[i]); 2695 mb_debug(" %u", md->blocks[i]);
2551 err = mb_free_blocks(NULL, &e4b, md->blocks[i], 1); 2696 mb_free_blocks(NULL, &e4b, md->blocks[i], 1);
2552 BUG_ON(err != 0);
2553 } 2697 }
2554 mb_debug("\n"); 2698 mb_debug("\n");
2555 ext4_unlock_group(sb, md->group); 2699 ext4_unlock_group(sb, md->group);
@@ -2575,25 +2719,24 @@ ext4_mb_free_committed_blocks(struct super_block *sb)
2575 2719
2576 2720
2577 2721
2578#define MB_PROC_VALUE_READ(name) \ 2722#define MB_PROC_FOPS(name) \
2579static int ext4_mb_read_##name(char *page, char **start, \ 2723static int ext4_mb_##name##_proc_show(struct seq_file *m, void *v) \
2580 off_t off, int count, int *eof, void *data) \
2581{ \ 2724{ \
2582 struct ext4_sb_info *sbi = data; \ 2725 struct ext4_sb_info *sbi = m->private; \
2583 int len; \ 2726 \
2584 *eof = 1; \ 2727 seq_printf(m, "%ld\n", sbi->s_mb_##name); \
2585 if (off != 0) \ 2728 return 0; \
2586 return 0; \ 2729} \
2587 len = sprintf(page, "%ld\n", sbi->s_mb_##name); \ 2730 \
2588 *start = page; \ 2731static int ext4_mb_##name##_proc_open(struct inode *inode, struct file *file)\
2589 return len; \ 2732{ \
2590} 2733 return single_open(file, ext4_mb_##name##_proc_show, PDE(inode)->data);\
2591 2734} \
2592#define MB_PROC_VALUE_WRITE(name) \ 2735 \
2593static int ext4_mb_write_##name(struct file *file, \ 2736static ssize_t ext4_mb_##name##_proc_write(struct file *file, \
2594 const char __user *buf, unsigned long cnt, void *data) \ 2737 const char __user *buf, size_t cnt, loff_t *ppos) \
2595{ \ 2738{ \
2596 struct ext4_sb_info *sbi = data; \ 2739 struct ext4_sb_info *sbi = PDE(file->f_path.dentry->d_inode)->data;\
2597 char str[32]; \ 2740 char str[32]; \
2598 long value; \ 2741 long value; \
2599 if (cnt >= sizeof(str)) \ 2742 if (cnt >= sizeof(str)) \
@@ -2605,31 +2748,32 @@ static int ext4_mb_write_##name(struct file *file, \
2605 return -ERANGE; \ 2748 return -ERANGE; \
2606 sbi->s_mb_##name = value; \ 2749 sbi->s_mb_##name = value; \
2607 return cnt; \ 2750 return cnt; \
2608} 2751} \
2752 \
2753static const struct file_operations ext4_mb_##name##_proc_fops = { \
2754 .owner = THIS_MODULE, \
2755 .open = ext4_mb_##name##_proc_open, \
2756 .read = seq_read, \
2757 .llseek = seq_lseek, \
2758 .release = single_release, \
2759 .write = ext4_mb_##name##_proc_write, \
2760};
2609 2761
2610MB_PROC_VALUE_READ(stats); 2762MB_PROC_FOPS(stats);
2611MB_PROC_VALUE_WRITE(stats); 2763MB_PROC_FOPS(max_to_scan);
2612MB_PROC_VALUE_READ(max_to_scan); 2764MB_PROC_FOPS(min_to_scan);
2613MB_PROC_VALUE_WRITE(max_to_scan); 2765MB_PROC_FOPS(order2_reqs);
2614MB_PROC_VALUE_READ(min_to_scan); 2766MB_PROC_FOPS(stream_request);
2615MB_PROC_VALUE_WRITE(min_to_scan); 2767MB_PROC_FOPS(group_prealloc);
2616MB_PROC_VALUE_READ(order2_reqs);
2617MB_PROC_VALUE_WRITE(order2_reqs);
2618MB_PROC_VALUE_READ(stream_request);
2619MB_PROC_VALUE_WRITE(stream_request);
2620MB_PROC_VALUE_READ(group_prealloc);
2621MB_PROC_VALUE_WRITE(group_prealloc);
2622 2768
2623#define MB_PROC_HANDLER(name, var) \ 2769#define MB_PROC_HANDLER(name, var) \
2624do { \ 2770do { \
2625 proc = create_proc_entry(name, mode, sbi->s_mb_proc); \ 2771 proc = proc_create_data(name, mode, sbi->s_mb_proc, \
2772 &ext4_mb_##var##_proc_fops, sbi); \
2626 if (proc == NULL) { \ 2773 if (proc == NULL) { \
2627 printk(KERN_ERR "EXT4-fs: can't to create %s\n", name); \ 2774 printk(KERN_ERR "EXT4-fs: can't to create %s\n", name); \
2628 goto err_out; \ 2775 goto err_out; \
2629 } \ 2776 } \
2630 proc->data = sbi; \
2631 proc->read_proc = ext4_mb_read_##var ; \
2632 proc->write_proc = ext4_mb_write_##var; \
2633} while (0) 2777} while (0)
2634 2778
2635static int ext4_mb_init_per_dev_proc(struct super_block *sb) 2779static int ext4_mb_init_per_dev_proc(struct super_block *sb)
@@ -2639,6 +2783,10 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
2639 struct proc_dir_entry *proc; 2783 struct proc_dir_entry *proc;
2640 char devname[64]; 2784 char devname[64];
2641 2785
2786 if (proc_root_ext4 == NULL) {
2787 sbi->s_mb_proc = NULL;
2788 return -EINVAL;
2789 }
2642 bdevname(sb->s_bdev, devname); 2790 bdevname(sb->s_bdev, devname);
2643 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); 2791 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
2644 2792
@@ -2747,7 +2895,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2747 2895
2748 2896
2749 err = -EIO; 2897 err = -EIO;
2750 bitmap_bh = read_block_bitmap(sb, ac->ac_b_ex.fe_group); 2898 bitmap_bh = ext4_read_block_bitmap(sb, ac->ac_b_ex.fe_group);
2751 if (!bitmap_bh) 2899 if (!bitmap_bh)
2752 goto out_err; 2900 goto out_err;
2753 2901
@@ -2816,7 +2964,23 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2816 le16_add_cpu(&gdp->bg_free_blocks_count, -ac->ac_b_ex.fe_len); 2964 le16_add_cpu(&gdp->bg_free_blocks_count, -ac->ac_b_ex.fe_len);
2817 gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp); 2965 gdp->bg_checksum = ext4_group_desc_csum(sbi, ac->ac_b_ex.fe_group, gdp);
2818 spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group)); 2966 spin_unlock(sb_bgl_lock(sbi, ac->ac_b_ex.fe_group));
2819 percpu_counter_sub(&sbi->s_freeblocks_counter, ac->ac_b_ex.fe_len); 2967
2968 /*
2969 * free blocks account has already be reduced/reserved
2970 * at write_begin() time for delayed allocation
2971 * do not double accounting
2972 */
2973 if (!(ac->ac_flags & EXT4_MB_DELALLOC_RESERVED))
2974 percpu_counter_sub(&sbi->s_freeblocks_counter,
2975 ac->ac_b_ex.fe_len);
2976
2977 if (sbi->s_log_groups_per_flex) {
2978 ext4_group_t flex_group = ext4_flex_group(sbi,
2979 ac->ac_b_ex.fe_group);
2980 spin_lock(sb_bgl_lock(sbi, flex_group));
2981 sbi->s_flex_groups[flex_group].free_blocks -= ac->ac_b_ex.fe_len;
2982 spin_unlock(sb_bgl_lock(sbi, flex_group));
2983 }
2820 2984
2821 err = ext4_journal_dirty_metadata(handle, bitmap_bh); 2985 err = ext4_journal_dirty_metadata(handle, bitmap_bh);
2822 if (err) 2986 if (err)
@@ -3473,8 +3637,6 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
3473 if (bit >= end) 3637 if (bit >= end)
3474 break; 3638 break;
3475 next = mb_find_next_bit(bitmap_bh->b_data, end, bit); 3639 next = mb_find_next_bit(bitmap_bh->b_data, end, bit);
3476 if (next > end)
3477 next = end;
3478 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit + 3640 start = group * EXT4_BLOCKS_PER_GROUP(sb) + bit +
3479 le32_to_cpu(sbi->s_es->s_first_data_block); 3641 le32_to_cpu(sbi->s_es->s_first_data_block);
3480 mb_debug(" free preallocated %u/%u in group %u\n", 3642 mb_debug(" free preallocated %u/%u in group %u\n",
@@ -3569,7 +3731,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
3569 if (list_empty(&grp->bb_prealloc_list)) 3731 if (list_empty(&grp->bb_prealloc_list))
3570 return 0; 3732 return 0;
3571 3733
3572 bitmap_bh = read_block_bitmap(sb, group); 3734 bitmap_bh = ext4_read_block_bitmap(sb, group);
3573 if (bitmap_bh == NULL) { 3735 if (bitmap_bh == NULL) {
3574 /* error handling here */ 3736 /* error handling here */
3575 ext4_mb_release_desc(&e4b); 3737 ext4_mb_release_desc(&e4b);
@@ -3743,7 +3905,7 @@ repeat:
3743 err = ext4_mb_load_buddy(sb, group, &e4b); 3905 err = ext4_mb_load_buddy(sb, group, &e4b);
3744 BUG_ON(err != 0); /* error handling here */ 3906 BUG_ON(err != 0); /* error handling here */
3745 3907
3746 bitmap_bh = read_block_bitmap(sb, group); 3908 bitmap_bh = ext4_read_block_bitmap(sb, group);
3747 if (bitmap_bh == NULL) { 3909 if (bitmap_bh == NULL) {
3748 /* error handling here */ 3910 /* error handling here */
3749 ext4_mb_release_desc(&e4b); 3911 ext4_mb_release_desc(&e4b);
@@ -4011,10 +4173,21 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4011 sbi = EXT4_SB(sb); 4173 sbi = EXT4_SB(sb);
4012 4174
4013 if (!test_opt(sb, MBALLOC)) { 4175 if (!test_opt(sb, MBALLOC)) {
4014 block = ext4_new_blocks_old(handle, ar->inode, ar->goal, 4176 block = ext4_old_new_blocks(handle, ar->inode, ar->goal,
4015 &(ar->len), errp); 4177 &(ar->len), errp);
4016 return block; 4178 return block;
4017 } 4179 }
4180 if (!EXT4_I(ar->inode)->i_delalloc_reserved_flag) {
4181 /*
4182 * With delalloc we already reserved the blocks
4183 */
4184 ar->len = ext4_has_free_blocks(sbi, ar->len);
4185 }
4186
4187 if (ar->len == 0) {
4188 *errp = -ENOSPC;
4189 return 0;
4190 }
4018 4191
4019 while (ar->len && DQUOT_ALLOC_BLOCK(ar->inode, ar->len)) { 4192 while (ar->len && DQUOT_ALLOC_BLOCK(ar->inode, ar->len)) {
4020 ar->flags |= EXT4_MB_HINT_NOPREALLOC; 4193 ar->flags |= EXT4_MB_HINT_NOPREALLOC;
@@ -4026,10 +4199,14 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4026 } 4199 }
4027 inquota = ar->len; 4200 inquota = ar->len;
4028 4201
4202 if (EXT4_I(ar->inode)->i_delalloc_reserved_flag)
4203 ar->flags |= EXT4_MB_DELALLOC_RESERVED;
4204
4029 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS); 4205 ac = kmem_cache_alloc(ext4_ac_cachep, GFP_NOFS);
4030 if (!ac) { 4206 if (!ac) {
4207 ar->len = 0;
4031 *errp = -ENOMEM; 4208 *errp = -ENOMEM;
4032 return 0; 4209 goto out1;
4033 } 4210 }
4034 4211
4035 ext4_mb_poll_new_transaction(sb, handle); 4212 ext4_mb_poll_new_transaction(sb, handle);
@@ -4037,12 +4214,11 @@ ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
4037 *errp = ext4_mb_initialize_context(ac, ar); 4214 *errp = ext4_mb_initialize_context(ac, ar);
4038 if (*errp) { 4215 if (*errp) {
4039 ar->len = 0; 4216 ar->len = 0;
4040 goto out; 4217 goto out2;
4041 } 4218 }
4042 4219
4043 ac->ac_op = EXT4_MB_HISTORY_PREALLOC; 4220 ac->ac_op = EXT4_MB_HISTORY_PREALLOC;
4044 if (!ext4_mb_use_preallocated(ac)) { 4221 if (!ext4_mb_use_preallocated(ac)) {
4045
4046 ac->ac_op = EXT4_MB_HISTORY_ALLOC; 4222 ac->ac_op = EXT4_MB_HISTORY_ALLOC;
4047 ext4_mb_normalize_request(ac, ar); 4223 ext4_mb_normalize_request(ac, ar);
4048repeat: 4224repeat:
@@ -4085,11 +4261,12 @@ repeat:
4085 4261
4086 ext4_mb_release_context(ac); 4262 ext4_mb_release_context(ac);
4087 4263
4088out: 4264out2:
4265 kmem_cache_free(ext4_ac_cachep, ac);
4266out1:
4089 if (ar->len < inquota) 4267 if (ar->len < inquota)
4090 DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len); 4268 DQUOT_FREE_BLOCK(ar->inode, inquota - ar->len);
4091 4269
4092 kmem_cache_free(ext4_ac_cachep, ac);
4093 return block; 4270 return block;
4094} 4271}
4095static void ext4_mb_poll_new_transaction(struct super_block *sb, 4272static void ext4_mb_poll_new_transaction(struct super_block *sb,
@@ -4242,7 +4419,7 @@ do_more:
4242 overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb); 4419 overflow = bit + count - EXT4_BLOCKS_PER_GROUP(sb);
4243 count -= overflow; 4420 count -= overflow;
4244 } 4421 }
4245 bitmap_bh = read_block_bitmap(sb, block_group); 4422 bitmap_bh = ext4_read_block_bitmap(sb, block_group);
4246 if (!bitmap_bh) 4423 if (!bitmap_bh)
4247 goto error_return; 4424 goto error_return;
4248 gdp = ext4_get_group_desc(sb, block_group, &gd_bh); 4425 gdp = ext4_get_group_desc(sb, block_group, &gd_bh);
@@ -4309,10 +4486,9 @@ do_more:
4309 ext4_mb_free_metadata(handle, &e4b, block_group, bit, count); 4486 ext4_mb_free_metadata(handle, &e4b, block_group, bit, count);
4310 } else { 4487 } else {
4311 ext4_lock_group(sb, block_group); 4488 ext4_lock_group(sb, block_group);
4312 err = mb_free_blocks(inode, &e4b, bit, count); 4489 mb_free_blocks(inode, &e4b, bit, count);
4313 ext4_mb_return_to_preallocation(inode, &e4b, block, count); 4490 ext4_mb_return_to_preallocation(inode, &e4b, block, count);
4314 ext4_unlock_group(sb, block_group); 4491 ext4_unlock_group(sb, block_group);
4315 BUG_ON(err != 0);
4316 } 4492 }
4317 4493
4318 spin_lock(sb_bgl_lock(sbi, block_group)); 4494 spin_lock(sb_bgl_lock(sbi, block_group));
@@ -4321,6 +4497,13 @@ do_more:
4321 spin_unlock(sb_bgl_lock(sbi, block_group)); 4497 spin_unlock(sb_bgl_lock(sbi, block_group));
4322 percpu_counter_add(&sbi->s_freeblocks_counter, count); 4498 percpu_counter_add(&sbi->s_freeblocks_counter, count);
4323 4499
4500 if (sbi->s_log_groups_per_flex) {
4501 ext4_group_t flex_group = ext4_flex_group(sbi, block_group);
4502 spin_lock(sb_bgl_lock(sbi, flex_group));
4503 sbi->s_flex_groups[flex_group].free_blocks += count;
4504 spin_unlock(sb_bgl_lock(sbi, flex_group));
4505 }
4506
4324 ext4_mb_release_desc(&e4b); 4507 ext4_mb_release_desc(&e4b);
4325 4508
4326 *freed += count; 4509 *freed += count;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index ab16beaa830..387ad98350c 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -183,6 +183,16 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
183 struct inode *inode); 183 struct inode *inode);
184 184
185/* 185/*
186 * p is at least 6 bytes before the end of page
187 */
188static inline struct ext4_dir_entry_2 *
189ext4_next_entry(struct ext4_dir_entry_2 *p)
190{
191 return (struct ext4_dir_entry_2 *)((char *)p +
192 ext4_rec_len_from_disk(p->rec_len));
193}
194
195/*
186 * Future: use high four bits of block for coalesce-on-delete flags 196 * Future: use high four bits of block for coalesce-on-delete flags
187 * Mask them off for now. 197 * Mask them off for now.
188 */ 198 */
@@ -231,13 +241,13 @@ static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize)
231{ 241{
232 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) - 242 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(1) -
233 EXT4_DIR_REC_LEN(2) - infosize; 243 EXT4_DIR_REC_LEN(2) - infosize;
234 return 0? 20: entry_space / sizeof(struct dx_entry); 244 return entry_space / sizeof(struct dx_entry);
235} 245}
236 246
237static inline unsigned dx_node_limit (struct inode *dir) 247static inline unsigned dx_node_limit (struct inode *dir)
238{ 248{
239 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0); 249 unsigned entry_space = dir->i_sb->s_blocksize - EXT4_DIR_REC_LEN(0);
240 return 0? 22: entry_space / sizeof(struct dx_entry); 250 return entry_space / sizeof(struct dx_entry);
241} 251}
242 252
243/* 253/*
@@ -554,15 +564,6 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
554 564
555 565
556/* 566/*
557 * p is at least 6 bytes before the end of page
558 */
559static inline struct ext4_dir_entry_2 *ext4_next_entry(struct ext4_dir_entry_2 *p)
560{
561 return (struct ext4_dir_entry_2 *)((char *)p +
562 ext4_rec_len_from_disk(p->rec_len));
563}
564
565/*
566 * This function fills a red-black tree with information from a 567 * This function fills a red-black tree with information from a
567 * directory block. It returns the number directory entries loaded 568 * directory block. It returns the number directory entries loaded
568 * into the tree. If there is an error it is returned in err. 569 * into the tree. If there is an error it is returned in err.
@@ -993,19 +994,21 @@ static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
993 de = (struct ext4_dir_entry_2 *) bh->b_data; 994 de = (struct ext4_dir_entry_2 *) bh->b_data;
994 top = (struct ext4_dir_entry_2 *) ((char *) de + sb->s_blocksize - 995 top = (struct ext4_dir_entry_2 *) ((char *) de + sb->s_blocksize -
995 EXT4_DIR_REC_LEN(0)); 996 EXT4_DIR_REC_LEN(0));
996 for (; de < top; de = ext4_next_entry(de)) 997 for (; de < top; de = ext4_next_entry(de)) {
997 if (ext4_match (namelen, name, de)) { 998 int off = (block << EXT4_BLOCK_SIZE_BITS(sb))
998 if (!ext4_check_dir_entry("ext4_find_entry", 999 + ((char *) de - bh->b_data);
999 dir, de, bh, 1000
1000 (block<<EXT4_BLOCK_SIZE_BITS(sb)) 1001 if (!ext4_check_dir_entry(__func__, dir, de, bh, off)) {
1001 +((char *)de - bh->b_data))) { 1002 brelse(bh);
1002 brelse (bh);
1003 *err = ERR_BAD_DX_DIR; 1003 *err = ERR_BAD_DX_DIR;
1004 goto errout; 1004 goto errout;
1005 } 1005 }
1006 *res_dir = de; 1006
1007 dx_release (frames); 1007 if (ext4_match(namelen, name, de)) {
1008 return bh; 1008 *res_dir = de;
1009 dx_release(frames);
1010 return bh;
1011 }
1009 } 1012 }
1010 brelse (bh); 1013 brelse (bh);
1011 /* Check to see if we should continue to search */ 1014 /* Check to see if we should continue to search */
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 9ff7b1c0423..f000fbe2cd9 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -866,6 +866,15 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
866 gdp->bg_checksum = ext4_group_desc_csum(sbi, input->group, gdp); 866 gdp->bg_checksum = ext4_group_desc_csum(sbi, input->group, gdp);
867 867
868 /* 868 /*
869 * We can allocate memory for mb_alloc based on the new group
870 * descriptor
871 */
872 if (test_opt(sb, MBALLOC)) {
873 err = ext4_mb_add_more_groupinfo(sb, input->group, gdp);
874 if (err)
875 goto exit_journal;
876 }
877 /*
869 * Make the new blocks and inodes valid next. We do this before 878 * Make the new blocks and inodes valid next. We do this before
870 * increasing the group count so that once the group is enabled, 879 * increasing the group count so that once the group is enabled,
871 * all of its blocks and inodes are already valid. 880 * all of its blocks and inodes are already valid.
@@ -957,6 +966,8 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
957 handle_t *handle; 966 handle_t *handle;
958 int err; 967 int err;
959 unsigned long freed_blocks; 968 unsigned long freed_blocks;
969 ext4_group_t group;
970 struct ext4_group_info *grp;
960 971
961 /* We don't need to worry about locking wrt other resizers just 972 /* We don't need to worry about locking wrt other resizers just
962 * yet: we're going to revalidate es->s_blocks_count after 973 * yet: we're going to revalidate es->s_blocks_count after
@@ -988,7 +999,7 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
988 } 999 }
989 1000
990 /* Handle the remaining blocks in the last group only. */ 1001 /* Handle the remaining blocks in the last group only. */
991 ext4_get_group_no_and_offset(sb, o_blocks_count, NULL, &last); 1002 ext4_get_group_no_and_offset(sb, o_blocks_count, &group, &last);
992 1003
993 if (last == 0) { 1004 if (last == 0) {
994 ext4_warning(sb, __func__, 1005 ext4_warning(sb, __func__,
@@ -1060,6 +1071,45 @@ int ext4_group_extend(struct super_block *sb, struct ext4_super_block *es,
1060 o_blocks_count + add); 1071 o_blocks_count + add);
1061 if ((err = ext4_journal_stop(handle))) 1072 if ((err = ext4_journal_stop(handle)))
1062 goto exit_put; 1073 goto exit_put;
1074
1075 /*
1076 * Mark mballoc pages as not up to date so that they will be updated
1077 * next time they are loaded by ext4_mb_load_buddy.
1078 */
1079 if (test_opt(sb, MBALLOC)) {
1080 struct ext4_sb_info *sbi = EXT4_SB(sb);
1081 struct inode *inode = sbi->s_buddy_cache;
1082 int blocks_per_page;
1083 int block;
1084 int pnum;
1085 struct page *page;
1086
1087 /* Set buddy page as not up to date */
1088 blocks_per_page = PAGE_CACHE_SIZE / sb->s_blocksize;
1089 block = group * 2;
1090 pnum = block / blocks_per_page;
1091 page = find_get_page(inode->i_mapping, pnum);
1092 if (page != NULL) {
1093 ClearPageUptodate(page);
1094 page_cache_release(page);
1095 }
1096
1097 /* Set bitmap page as not up to date */
1098 block++;
1099 pnum = block / blocks_per_page;
1100 page = find_get_page(inode->i_mapping, pnum);
1101 if (page != NULL) {
1102 ClearPageUptodate(page);
1103 page_cache_release(page);
1104 }
1105
1106 /* Get the info on the last group */
1107 grp = ext4_get_group_info(sb, group);
1108
1109 /* Update free blocks in group info */
1110 ext4_mb_update_group_info(grp, add);
1111 }
1112
1063 if (test_opt(sb, DEBUG)) 1113 if (test_opt(sb, DEBUG))
1064 printk(KERN_DEBUG "EXT4-fs: extended group to %llu blocks\n", 1114 printk(KERN_DEBUG "EXT4-fs: extended group to %llu blocks\n",
1065 ext4_blocks_count(es)); 1115 ext4_blocks_count(es));
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 02bf2434397..1cb371dcd60 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -506,6 +506,7 @@ static void ext4_put_super (struct super_block * sb)
506 ext4_ext_release(sb); 506 ext4_ext_release(sb);
507 ext4_xattr_put_super(sb); 507 ext4_xattr_put_super(sb);
508 jbd2_journal_destroy(sbi->s_journal); 508 jbd2_journal_destroy(sbi->s_journal);
509 sbi->s_journal = NULL;
509 if (!(sb->s_flags & MS_RDONLY)) { 510 if (!(sb->s_flags & MS_RDONLY)) {
510 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 511 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
511 es->s_state = cpu_to_le16(sbi->s_mount_state); 512 es->s_state = cpu_to_le16(sbi->s_mount_state);
@@ -517,6 +518,7 @@ static void ext4_put_super (struct super_block * sb)
517 for (i = 0; i < sbi->s_gdb_count; i++) 518 for (i = 0; i < sbi->s_gdb_count; i++)
518 brelse(sbi->s_group_desc[i]); 519 brelse(sbi->s_group_desc[i]);
519 kfree(sbi->s_group_desc); 520 kfree(sbi->s_group_desc);
521 kfree(sbi->s_flex_groups);
520 percpu_counter_destroy(&sbi->s_freeblocks_counter); 522 percpu_counter_destroy(&sbi->s_freeblocks_counter);
521 percpu_counter_destroy(&sbi->s_freeinodes_counter); 523 percpu_counter_destroy(&sbi->s_freeinodes_counter);
522 percpu_counter_destroy(&sbi->s_dirs_counter); 524 percpu_counter_destroy(&sbi->s_dirs_counter);
@@ -571,6 +573,12 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
571 memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache)); 573 memset(&ei->i_cached_extent, 0, sizeof(struct ext4_ext_cache));
572 INIT_LIST_HEAD(&ei->i_prealloc_list); 574 INIT_LIST_HEAD(&ei->i_prealloc_list);
573 spin_lock_init(&ei->i_prealloc_lock); 575 spin_lock_init(&ei->i_prealloc_lock);
576 jbd2_journal_init_jbd_inode(&ei->jinode, &ei->vfs_inode);
577 ei->i_reserved_data_blocks = 0;
578 ei->i_reserved_meta_blocks = 0;
579 ei->i_allocated_meta_blocks = 0;
580 ei->i_delalloc_reserved_flag = 0;
581 spin_lock_init(&(ei->i_block_reservation_lock));
574 return &ei->vfs_inode; 582 return &ei->vfs_inode;
575} 583}
576 584
@@ -635,6 +643,8 @@ static void ext4_clear_inode(struct inode *inode)
635 EXT4_I(inode)->i_block_alloc_info = NULL; 643 EXT4_I(inode)->i_block_alloc_info = NULL;
636 if (unlikely(rsv)) 644 if (unlikely(rsv))
637 kfree(rsv); 645 kfree(rsv);
646 jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal,
647 &EXT4_I(inode)->jinode);
638} 648}
639 649
640static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb) 650static inline void ext4_show_quota_options(struct seq_file *seq, struct super_block *sb)
@@ -671,7 +681,6 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
671 unsigned long def_mount_opts; 681 unsigned long def_mount_opts;
672 struct super_block *sb = vfs->mnt_sb; 682 struct super_block *sb = vfs->mnt_sb;
673 struct ext4_sb_info *sbi = EXT4_SB(sb); 683 struct ext4_sb_info *sbi = EXT4_SB(sb);
674 journal_t *journal = sbi->s_journal;
675 struct ext4_super_block *es = sbi->s_es; 684 struct ext4_super_block *es = sbi->s_es;
676 685
677 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); 686 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
@@ -747,6 +756,9 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
747 seq_puts(seq, ",nomballoc"); 756 seq_puts(seq, ",nomballoc");
748 if (test_opt(sb, I_VERSION)) 757 if (test_opt(sb, I_VERSION))
749 seq_puts(seq, ",i_version"); 758 seq_puts(seq, ",i_version");
759 if (!test_opt(sb, DELALLOC))
760 seq_puts(seq, ",nodelalloc");
761
750 762
751 if (sbi->s_stripe) 763 if (sbi->s_stripe)
752 seq_printf(seq, ",stripe=%lu", sbi->s_stripe); 764 seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
@@ -894,7 +906,7 @@ enum {
894 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, 906 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota,
895 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, 907 Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota,
896 Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version, 908 Opt_grpquota, Opt_extents, Opt_noextents, Opt_i_version,
897 Opt_mballoc, Opt_nomballoc, Opt_stripe, 909 Opt_mballoc, Opt_nomballoc, Opt_stripe, Opt_delalloc, Opt_nodelalloc,
898}; 910};
899 911
900static match_table_t tokens = { 912static match_table_t tokens = {
@@ -953,6 +965,8 @@ static match_table_t tokens = {
953 {Opt_nomballoc, "nomballoc"}, 965 {Opt_nomballoc, "nomballoc"},
954 {Opt_stripe, "stripe=%u"}, 966 {Opt_stripe, "stripe=%u"},
955 {Opt_resize, "resize"}, 967 {Opt_resize, "resize"},
968 {Opt_delalloc, "delalloc"},
969 {Opt_nodelalloc, "nodelalloc"},
956 {Opt_err, NULL}, 970 {Opt_err, NULL},
957}; 971};
958 972
@@ -990,6 +1004,7 @@ static int parse_options (char *options, struct super_block *sb,
990 int qtype, qfmt; 1004 int qtype, qfmt;
991 char *qname; 1005 char *qname;
992#endif 1006#endif
1007 ext4_fsblk_t last_block;
993 1008
994 if (!options) 1009 if (!options)
995 return 1; 1010 return 1;
@@ -1309,15 +1324,39 @@ set_qf_format:
1309 clear_opt(sbi->s_mount_opt, NOBH); 1324 clear_opt(sbi->s_mount_opt, NOBH);
1310 break; 1325 break;
1311 case Opt_extents: 1326 case Opt_extents:
1327 if (!EXT4_HAS_INCOMPAT_FEATURE(sb,
1328 EXT4_FEATURE_INCOMPAT_EXTENTS)) {
1329 ext4_warning(sb, __func__,
1330 "extents feature not enabled "
1331 "on this filesystem, use tune2fs\n");
1332 return 0;
1333 }
1312 set_opt (sbi->s_mount_opt, EXTENTS); 1334 set_opt (sbi->s_mount_opt, EXTENTS);
1313 break; 1335 break;
1314 case Opt_noextents: 1336 case Opt_noextents:
1337 /*
1338 * When e2fsprogs support resizing an already existing
1339 * ext3 file system to greater than 2**32 we need to
1340 * add support to block allocator to handle growing
1341 * already existing block mapped inode so that blocks
1342 * allocated for them fall within 2**32
1343 */
1344 last_block = ext4_blocks_count(sbi->s_es) - 1;
1345 if (last_block > 0xffffffffULL) {
1346 printk(KERN_ERR "EXT4-fs: Filesystem too "
1347 "large to mount with "
1348 "-o noextents options\n");
1349 return 0;
1350 }
1315 clear_opt (sbi->s_mount_opt, EXTENTS); 1351 clear_opt (sbi->s_mount_opt, EXTENTS);
1316 break; 1352 break;
1317 case Opt_i_version: 1353 case Opt_i_version:
1318 set_opt(sbi->s_mount_opt, I_VERSION); 1354 set_opt(sbi->s_mount_opt, I_VERSION);
1319 sb->s_flags |= MS_I_VERSION; 1355 sb->s_flags |= MS_I_VERSION;
1320 break; 1356 break;
1357 case Opt_nodelalloc:
1358 clear_opt(sbi->s_mount_opt, DELALLOC);
1359 break;
1321 case Opt_mballoc: 1360 case Opt_mballoc:
1322 set_opt(sbi->s_mount_opt, MBALLOC); 1361 set_opt(sbi->s_mount_opt, MBALLOC);
1323 break; 1362 break;
@@ -1331,6 +1370,9 @@ set_qf_format:
1331 return 0; 1370 return 0;
1332 sbi->s_stripe = option; 1371 sbi->s_stripe = option;
1333 break; 1372 break;
1373 case Opt_delalloc:
1374 set_opt(sbi->s_mount_opt, DELALLOC);
1375 break;
1334 default: 1376 default:
1335 printk (KERN_ERR 1377 printk (KERN_ERR
1336 "EXT4-fs: Unrecognized mount option \"%s\" " 1378 "EXT4-fs: Unrecognized mount option \"%s\" "
@@ -1443,6 +1485,54 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
1443 return res; 1485 return res;
1444} 1486}
1445 1487
1488static int ext4_fill_flex_info(struct super_block *sb)
1489{
1490 struct ext4_sb_info *sbi = EXT4_SB(sb);
1491 struct ext4_group_desc *gdp = NULL;
1492 struct buffer_head *bh;
1493 ext4_group_t flex_group_count;
1494 ext4_group_t flex_group;
1495 int groups_per_flex = 0;
1496 __u64 block_bitmap = 0;
1497 int i;
1498
1499 if (!sbi->s_es->s_log_groups_per_flex) {
1500 sbi->s_log_groups_per_flex = 0;
1501 return 1;
1502 }
1503
1504 sbi->s_log_groups_per_flex = sbi->s_es->s_log_groups_per_flex;
1505 groups_per_flex = 1 << sbi->s_log_groups_per_flex;
1506
1507 flex_group_count = (sbi->s_groups_count + groups_per_flex - 1) /
1508 groups_per_flex;
1509 sbi->s_flex_groups = kmalloc(flex_group_count *
1510 sizeof(struct flex_groups), GFP_KERNEL);
1511 if (sbi->s_flex_groups == NULL) {
1512 printk(KERN_ERR "EXT4-fs: not enough memory\n");
1513 goto failed;
1514 }
1515 memset(sbi->s_flex_groups, 0, flex_group_count *
1516 sizeof(struct flex_groups));
1517
1518 gdp = ext4_get_group_desc(sb, 1, &bh);
1519 block_bitmap = ext4_block_bitmap(sb, gdp) - 1;
1520
1521 for (i = 0; i < sbi->s_groups_count; i++) {
1522 gdp = ext4_get_group_desc(sb, i, &bh);
1523
1524 flex_group = ext4_flex_group(sbi, i);
1525 sbi->s_flex_groups[flex_group].free_inodes +=
1526 le16_to_cpu(gdp->bg_free_inodes_count);
1527 sbi->s_flex_groups[flex_group].free_blocks +=
1528 le16_to_cpu(gdp->bg_free_blocks_count);
1529 }
1530
1531 return 1;
1532failed:
1533 return 0;
1534}
1535
1446__le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group, 1536__le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
1447 struct ext4_group_desc *gdp) 1537 struct ext4_group_desc *gdp)
1448{ 1538{
@@ -1810,8 +1900,8 @@ static unsigned long ext4_get_stripe_size(struct ext4_sb_info *sbi)
1810} 1900}
1811 1901
1812static int ext4_fill_super (struct super_block *sb, void *data, int silent) 1902static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1813 __releases(kernel_sem) 1903 __releases(kernel_lock)
1814 __acquires(kernel_sem) 1904 __acquires(kernel_lock)
1815 1905
1816{ 1906{
1817 struct buffer_head * bh; 1907 struct buffer_head * bh;
@@ -1851,11 +1941,6 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1851 goto out_fail; 1941 goto out_fail;
1852 } 1942 }
1853 1943
1854 if (!sb_set_blocksize(sb, blocksize)) {
1855 printk(KERN_ERR "EXT4-fs: bad blocksize %d.\n", blocksize);
1856 goto out_fail;
1857 }
1858
1859 /* 1944 /*
1860 * The ext4 superblock will not be buffer aligned for other than 1kB 1945 * The ext4 superblock will not be buffer aligned for other than 1kB
1861 * block sizes. We need to calculate the offset from buffer start. 1946 * block sizes. We need to calculate the offset from buffer start.
@@ -1919,15 +2004,28 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1919 2004
1920 /* 2005 /*
1921 * turn on extents feature by default in ext4 filesystem 2006 * turn on extents feature by default in ext4 filesystem
1922 * User -o noextents to turn it off 2007 * only if feature flag already set by mkfs or tune2fs.
2008 * Use -o noextents to turn it off
1923 */ 2009 */
1924 set_opt(sbi->s_mount_opt, EXTENTS); 2010 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS))
2011 set_opt(sbi->s_mount_opt, EXTENTS);
2012 else
2013 ext4_warning(sb, __func__,
2014 "extents feature not enabled on this filesystem, "
2015 "use tune2fs.\n");
1925 /* 2016 /*
1926 * turn on mballoc feature by default in ext4 filesystem 2017 * turn on mballoc code by default in ext4 filesystem
1927 * User -o nomballoc to turn it off 2018 * Use -o nomballoc to turn it off
1928 */ 2019 */
1929 set_opt(sbi->s_mount_opt, MBALLOC); 2020 set_opt(sbi->s_mount_opt, MBALLOC);
1930 2021
2022 /*
2023 * enable delayed allocation by default
2024 * Use -o nodelalloc to turn it off
2025 */
2026 set_opt(sbi->s_mount_opt, DELALLOC);
2027
2028
1931 if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum, 2029 if (!parse_options ((char *) data, sb, &journal_inum, &journal_devnum,
1932 NULL, 0)) 2030 NULL, 0))
1933 goto failed_mount; 2031 goto failed_mount;
@@ -2138,6 +2236,14 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2138 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n"); 2236 printk(KERN_ERR "EXT4-fs: group descriptors corrupted!\n");
2139 goto failed_mount2; 2237 goto failed_mount2;
2140 } 2238 }
2239 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG))
2240 if (!ext4_fill_flex_info(sb)) {
2241 printk(KERN_ERR
2242 "EXT4-fs: unable to initialize "
2243 "flex_bg meta info!\n");
2244 goto failed_mount2;
2245 }
2246
2141 sbi->s_gdb_count = db_count; 2247 sbi->s_gdb_count = db_count;
2142 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 2248 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
2143 spin_lock_init(&sbi->s_next_gen_lock); 2249 spin_lock_init(&sbi->s_next_gen_lock);
@@ -2358,6 +2464,13 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
2358 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered": 2464 test_opt(sb,DATA_FLAGS) == EXT4_MOUNT_ORDERED_DATA ? "ordered":
2359 "writeback"); 2465 "writeback");
2360 2466
2467 if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) {
2468 printk(KERN_WARNING "EXT4-fs: Ignoring delalloc option - "
2469 "requested data journaling mode\n");
2470 clear_opt(sbi->s_mount_opt, DELALLOC);
2471 } else if (test_opt(sb, DELALLOC))
2472 printk(KERN_INFO "EXT4-fs: delayed allocation enabled\n");
2473
2361 ext4_ext_init(sb); 2474 ext4_ext_init(sb);
2362 ext4_mb_init(sb, needs_recovery); 2475 ext4_mb_init(sb, needs_recovery);
2363 2476
@@ -2372,6 +2485,7 @@ cantfind_ext4:
2372 2485
2373failed_mount4: 2486failed_mount4:
2374 jbd2_journal_destroy(sbi->s_journal); 2487 jbd2_journal_destroy(sbi->s_journal);
2488 sbi->s_journal = NULL;
2375failed_mount3: 2489failed_mount3:
2376 percpu_counter_destroy(&sbi->s_freeblocks_counter); 2490 percpu_counter_destroy(&sbi->s_freeblocks_counter);
2377 percpu_counter_destroy(&sbi->s_freeinodes_counter); 2491 percpu_counter_destroy(&sbi->s_freeinodes_counter);
@@ -3325,7 +3439,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
3325 err = ext4_journal_dirty_metadata(handle, bh); 3439 err = ext4_journal_dirty_metadata(handle, bh);
3326 else { 3440 else {
3327 /* Always do at least ordered writes for quotas */ 3441 /* Always do at least ordered writes for quotas */
3328 err = ext4_journal_dirty_data(handle, bh); 3442 err = ext4_jbd2_file_inode(handle, inode);
3329 mark_buffer_dirty(bh); 3443 mark_buffer_dirty(bh);
3330 } 3444 }
3331 brelse(bh); 3445 brelse(bh);
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index ff08633f398..93c5fdcdad2 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -810,7 +810,7 @@ inserted:
810 /* We need to allocate a new block */ 810 /* We need to allocate a new block */
811 ext4_fsblk_t goal = ext4_group_first_block_no(sb, 811 ext4_fsblk_t goal = ext4_group_first_block_no(sb,
812 EXT4_I(inode)->i_block_group); 812 EXT4_I(inode)->i_block_group);
813 ext4_fsblk_t block = ext4_new_block(handle, inode, 813 ext4_fsblk_t block = ext4_new_meta_block(handle, inode,
814 goal, &error); 814 goal, &error);
815 if (error) 815 if (error)
816 goto cleanup; 816 goto cleanup;
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
index fff33382cad..ac1a52cf2a3 100644
--- a/fs/ext4/xattr_trusted.c
+++ b/fs/ext4/xattr_trusted.c
@@ -13,13 +13,11 @@
13#include "ext4.h" 13#include "ext4.h"
14#include "xattr.h" 14#include "xattr.h"
15 15
16#define XATTR_TRUSTED_PREFIX "trusted."
17
18static size_t 16static size_t
19ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size, 17ext4_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
20 const char *name, size_t name_len) 18 const char *name, size_t name_len)
21{ 19{
22 const size_t prefix_len = sizeof(XATTR_TRUSTED_PREFIX)-1; 20 const size_t prefix_len = XATTR_TRUSTED_PREFIX_LEN;
23 const size_t total_len = prefix_len + name_len + 1; 21 const size_t total_len = prefix_len + name_len + 1;
24 22
25 if (!capable(CAP_SYS_ADMIN)) 23 if (!capable(CAP_SYS_ADMIN))
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
index 67be723fcc4..d91aa61b42a 100644
--- a/fs/ext4/xattr_user.c
+++ b/fs/ext4/xattr_user.c
@@ -12,13 +12,11 @@
12#include "ext4.h" 12#include "ext4.h"
13#include "xattr.h" 13#include "xattr.h"
14 14
15#define XATTR_USER_PREFIX "user."
16
17static size_t 15static size_t
18ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size, 16ext4_xattr_user_list(struct inode *inode, char *list, size_t list_size,
19 const char *name, size_t name_len) 17 const char *name, size_t name_len)
20{ 18{
21 const size_t prefix_len = sizeof(XATTR_USER_PREFIX)-1; 19 const size_t prefix_len = XATTR_USER_PREFIX_LEN;
22 const size_t total_len = prefix_len + name_len + 1; 20 const size_t total_len = prefix_len + name_len + 1;
23 21
24 if (!test_opt(inode->i_sb, XATTR_USER)) 22 if (!test_opt(inode->i_sb, XATTR_USER))
diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig
index 7f7947e3dfb..ab2f57e3fb8 100644
--- a/fs/gfs2/Kconfig
+++ b/fs/gfs2/Kconfig
@@ -14,23 +14,11 @@ config GFS2_FS
14 GFS is perfect consistency -- changes made to the filesystem on one 14 GFS is perfect consistency -- changes made to the filesystem on one
15 machine show up immediately on all other machines in the cluster. 15 machine show up immediately on all other machines in the cluster.
16 16
17 To use the GFS2 filesystem, you will need to enable one or more of 17 To use the GFS2 filesystem in a cluster, you will need to enable
18 the below locking modules. Documentation and utilities for GFS2 can 18 the locking module below. Documentation and utilities for GFS2 can
19 be found here: http://sources.redhat.com/cluster 19 be found here: http://sources.redhat.com/cluster
20 20
21config GFS2_FS_LOCKING_NOLOCK 21 The "nolock" lock module is now built in to GFS2 by default.
22 tristate "GFS2 \"nolock\" locking module"
23 depends on GFS2_FS
24 help
25 Single node locking module for GFS2.
26
27 Use this module if you want to use GFS2 on a single node without
28 its clustering features. You can still take advantage of the
29 large file support, and upgrade to running a full cluster later on
30 if required.
31
32 If you will only be using GFS2 in cluster mode, you do not need this
33 module.
34 22
35config GFS2_FS_LOCKING_DLM 23config GFS2_FS_LOCKING_DLM
36 tristate "GFS2 DLM locking module" 24 tristate "GFS2 DLM locking module"
diff --git a/fs/gfs2/Makefile b/fs/gfs2/Makefile
index e2350df02a0..ec65851ec80 100644
--- a/fs/gfs2/Makefile
+++ b/fs/gfs2/Makefile
@@ -5,6 +5,5 @@ gfs2-y := acl.o bmap.o daemon.o dir.o eaops.o eattr.o glock.o \
5 ops_fstype.o ops_inode.o ops_super.o quota.o \ 5 ops_fstype.o ops_inode.o ops_super.o quota.o \
6 recovery.o rgrp.o super.o sys.o trans.o util.o 6 recovery.o rgrp.o super.o sys.o trans.o util.o
7 7
8obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += locking/nolock/
9obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/ 8obj-$(CONFIG_GFS2_FS_LOCKING_DLM) += locking/dlm/
10 9
diff --git a/fs/gfs2/gfs2.h b/fs/gfs2/gfs2.h
index 3bb11c0f8b5..ef606e3a5cf 100644
--- a/fs/gfs2/gfs2.h
+++ b/fs/gfs2/gfs2.h
@@ -16,11 +16,6 @@ enum {
16}; 16};
17 17
18enum { 18enum {
19 NO_WAIT = 0,
20 WAIT = 1,
21};
22
23enum {
24 NO_FORCE = 0, 19 NO_FORCE = 0,
25 FORCE = 1, 20 FORCE = 1,
26}; 21};
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index d636b3e80f5..13391e54661 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -45,21 +45,19 @@ struct gfs2_gl_hash_bucket {
45 struct hlist_head hb_list; 45 struct hlist_head hb_list;
46}; 46};
47 47
48struct glock_iter { 48struct gfs2_glock_iter {
49 int hash; /* hash bucket index */ 49 int hash; /* hash bucket index */
50 struct gfs2_sbd *sdp; /* incore superblock */ 50 struct gfs2_sbd *sdp; /* incore superblock */
51 struct gfs2_glock *gl; /* current glock struct */ 51 struct gfs2_glock *gl; /* current glock struct */
52 struct seq_file *seq; /* sequence file for debugfs */ 52 char string[512]; /* scratch space */
53 char string[512]; /* scratch space */
54}; 53};
55 54
56typedef void (*glock_examiner) (struct gfs2_glock * gl); 55typedef void (*glock_examiner) (struct gfs2_glock * gl);
57 56
58static int gfs2_dump_lockstate(struct gfs2_sbd *sdp); 57static int gfs2_dump_lockstate(struct gfs2_sbd *sdp);
59static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl); 58static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl);
60static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh); 59#define GLOCK_BUG_ON(gl,x) do { if (unlikely(x)) { __dump_glock(NULL, gl); BUG(); } } while(0)
61static void gfs2_glock_drop_th(struct gfs2_glock *gl); 60static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
62static void run_queue(struct gfs2_glock *gl);
63 61
64static DECLARE_RWSEM(gfs2_umount_flush_sem); 62static DECLARE_RWSEM(gfs2_umount_flush_sem);
65static struct dentry *gfs2_root; 63static struct dentry *gfs2_root;
@@ -123,33 +121,6 @@ static inline rwlock_t *gl_lock_addr(unsigned int x)
123#endif 121#endif
124 122
125/** 123/**
126 * relaxed_state_ok - is a requested lock compatible with the current lock mode?
127 * @actual: the current state of the lock
128 * @requested: the lock state that was requested by the caller
129 * @flags: the modifier flags passed in by the caller
130 *
131 * Returns: 1 if the locks are compatible, 0 otherwise
132 */
133
134static inline int relaxed_state_ok(unsigned int actual, unsigned requested,
135 int flags)
136{
137 if (actual == requested)
138 return 1;
139
140 if (flags & GL_EXACT)
141 return 0;
142
143 if (actual == LM_ST_EXCLUSIVE && requested == LM_ST_SHARED)
144 return 1;
145
146 if (actual != LM_ST_UNLOCKED && (flags & LM_FLAG_ANY))
147 return 1;
148
149 return 0;
150}
151
152/**
153 * gl_hash() - Turn glock number into hash bucket number 124 * gl_hash() - Turn glock number into hash bucket number
154 * @lock: The glock number 125 * @lock: The glock number
155 * 126 *
@@ -182,7 +153,7 @@ static void glock_free(struct gfs2_glock *gl)
182 struct gfs2_sbd *sdp = gl->gl_sbd; 153 struct gfs2_sbd *sdp = gl->gl_sbd;
183 struct inode *aspace = gl->gl_aspace; 154 struct inode *aspace = gl->gl_aspace;
184 155
185 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 156 if (sdp->sd_lockstruct.ls_ops->lm_put_lock)
186 sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock); 157 sdp->sd_lockstruct.ls_ops->lm_put_lock(gl->gl_lock);
187 158
188 if (aspace) 159 if (aspace)
@@ -211,17 +182,14 @@ static void gfs2_glock_hold(struct gfs2_glock *gl)
211int gfs2_glock_put(struct gfs2_glock *gl) 182int gfs2_glock_put(struct gfs2_glock *gl)
212{ 183{
213 int rv = 0; 184 int rv = 0;
214 struct gfs2_sbd *sdp = gl->gl_sbd;
215 185
216 write_lock(gl_lock_addr(gl->gl_hash)); 186 write_lock(gl_lock_addr(gl->gl_hash));
217 if (atomic_dec_and_test(&gl->gl_ref)) { 187 if (atomic_dec_and_test(&gl->gl_ref)) {
218 hlist_del(&gl->gl_list); 188 hlist_del(&gl->gl_list);
219 write_unlock(gl_lock_addr(gl->gl_hash)); 189 write_unlock(gl_lock_addr(gl->gl_hash));
220 gfs2_assert(sdp, gl->gl_state == LM_ST_UNLOCKED); 190 GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_UNLOCKED);
221 gfs2_assert(sdp, list_empty(&gl->gl_reclaim)); 191 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_reclaim));
222 gfs2_assert(sdp, list_empty(&gl->gl_holders)); 192 GLOCK_BUG_ON(gl, !list_empty(&gl->gl_holders));
223 gfs2_assert(sdp, list_empty(&gl->gl_waiters1));
224 gfs2_assert(sdp, list_empty(&gl->gl_waiters3));
225 glock_free(gl); 193 glock_free(gl);
226 rv = 1; 194 rv = 1;
227 goto out; 195 goto out;
@@ -281,22 +249,401 @@ static struct gfs2_glock *gfs2_glock_find(const struct gfs2_sbd *sdp,
281 return gl; 249 return gl;
282} 250}
283 251
252/**
253 * may_grant - check if its ok to grant a new lock
254 * @gl: The glock
255 * @gh: The lock request which we wish to grant
256 *
257 * Returns: true if its ok to grant the lock
258 */
259
260static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh)
261{
262 const struct gfs2_holder *gh_head = list_entry(gl->gl_holders.next, const struct gfs2_holder, gh_list);
263 if ((gh->gh_state == LM_ST_EXCLUSIVE ||
264 gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head)
265 return 0;
266 if (gl->gl_state == gh->gh_state)
267 return 1;
268 if (gh->gh_flags & GL_EXACT)
269 return 0;
270 if (gl->gl_state == LM_ST_EXCLUSIVE) {
271 if (gh->gh_state == LM_ST_SHARED && gh_head->gh_state == LM_ST_SHARED)
272 return 1;
273 if (gh->gh_state == LM_ST_DEFERRED && gh_head->gh_state == LM_ST_DEFERRED)
274 return 1;
275 }
276 if (gl->gl_state != LM_ST_UNLOCKED && (gh->gh_flags & LM_FLAG_ANY))
277 return 1;
278 return 0;
279}
280
281static void gfs2_holder_wake(struct gfs2_holder *gh)
282{
283 clear_bit(HIF_WAIT, &gh->gh_iflags);
284 smp_mb__after_clear_bit();
285 wake_up_bit(&gh->gh_iflags, HIF_WAIT);
286}
287
288/**
289 * do_promote - promote as many requests as possible on the current queue
290 * @gl: The glock
291 *
292 * Returns: true if there is a blocked holder at the head of the list
293 */
294
295static int do_promote(struct gfs2_glock *gl)
296{
297 const struct gfs2_glock_operations *glops = gl->gl_ops;
298 struct gfs2_holder *gh, *tmp;
299 int ret;
300
301restart:
302 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
303 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
304 continue;
305 if (may_grant(gl, gh)) {
306 if (gh->gh_list.prev == &gl->gl_holders &&
307 glops->go_lock) {
308 spin_unlock(&gl->gl_spin);
309 /* FIXME: eliminate this eventually */
310 ret = glops->go_lock(gh);
311 spin_lock(&gl->gl_spin);
312 if (ret) {
313 gh->gh_error = ret;
314 list_del_init(&gh->gh_list);
315 gfs2_holder_wake(gh);
316 goto restart;
317 }
318 set_bit(HIF_HOLDER, &gh->gh_iflags);
319 gfs2_holder_wake(gh);
320 goto restart;
321 }
322 set_bit(HIF_HOLDER, &gh->gh_iflags);
323 gfs2_holder_wake(gh);
324 continue;
325 }
326 if (gh->gh_list.prev == &gl->gl_holders)
327 return 1;
328 break;
329 }
330 return 0;
331}
332
333/**
334 * do_error - Something unexpected has happened during a lock request
335 *
336 */
337
338static inline void do_error(struct gfs2_glock *gl, const int ret)
339{
340 struct gfs2_holder *gh, *tmp;
341
342 list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
343 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
344 continue;
345 if (ret & LM_OUT_ERROR)
346 gh->gh_error = -EIO;
347 else if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
348 gh->gh_error = GLR_TRYFAILED;
349 else
350 continue;
351 list_del_init(&gh->gh_list);
352 gfs2_holder_wake(gh);
353 }
354}
355
356/**
357 * find_first_waiter - find the first gh that's waiting for the glock
358 * @gl: the glock
359 */
360
361static inline struct gfs2_holder *find_first_waiter(const struct gfs2_glock *gl)
362{
363 struct gfs2_holder *gh;
364
365 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
366 if (!test_bit(HIF_HOLDER, &gh->gh_iflags))
367 return gh;
368 }
369 return NULL;
370}
371
372/**
373 * state_change - record that the glock is now in a different state
374 * @gl: the glock
375 * @new_state the new state
376 *
377 */
378
379static void state_change(struct gfs2_glock *gl, unsigned int new_state)
380{
381 int held1, held2;
382
383 held1 = (gl->gl_state != LM_ST_UNLOCKED);
384 held2 = (new_state != LM_ST_UNLOCKED);
385
386 if (held1 != held2) {
387 if (held2)
388 gfs2_glock_hold(gl);
389 else
390 gfs2_glock_put(gl);
391 }
392
393 gl->gl_state = new_state;
394 gl->gl_tchange = jiffies;
395}
396
397static void gfs2_demote_wake(struct gfs2_glock *gl)
398{
399 gl->gl_demote_state = LM_ST_EXCLUSIVE;
400 clear_bit(GLF_DEMOTE, &gl->gl_flags);
401 smp_mb__after_clear_bit();
402 wake_up_bit(&gl->gl_flags, GLF_DEMOTE);
403}
404
405/**
406 * finish_xmote - The DLM has replied to one of our lock requests
407 * @gl: The glock
408 * @ret: The status from the DLM
409 *
410 */
411
412static void finish_xmote(struct gfs2_glock *gl, unsigned int ret)
413{
414 const struct gfs2_glock_operations *glops = gl->gl_ops;
415 struct gfs2_holder *gh;
416 unsigned state = ret & LM_OUT_ST_MASK;
417
418 spin_lock(&gl->gl_spin);
419 state_change(gl, state);
420 gh = find_first_waiter(gl);
421
422 /* Demote to UN request arrived during demote to SH or DF */
423 if (test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags) &&
424 state != LM_ST_UNLOCKED && gl->gl_demote_state == LM_ST_UNLOCKED)
425 gl->gl_target = LM_ST_UNLOCKED;
426
427 /* Check for state != intended state */
428 if (unlikely(state != gl->gl_target)) {
429 if (gh && !test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) {
430 /* move to back of queue and try next entry */
431 if (ret & LM_OUT_CANCELED) {
432 if ((gh->gh_flags & LM_FLAG_PRIORITY) == 0)
433 list_move_tail(&gh->gh_list, &gl->gl_holders);
434 gh = find_first_waiter(gl);
435 gl->gl_target = gh->gh_state;
436 goto retry;
437 }
438 /* Some error or failed "try lock" - report it */
439 if ((ret & LM_OUT_ERROR) ||
440 (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) {
441 gl->gl_target = gl->gl_state;
442 do_error(gl, ret);
443 goto out;
444 }
445 }
446 switch(state) {
447 /* Unlocked due to conversion deadlock, try again */
448 case LM_ST_UNLOCKED:
449retry:
450 do_xmote(gl, gh, gl->gl_target);
451 break;
452 /* Conversion fails, unlock and try again */
453 case LM_ST_SHARED:
454 case LM_ST_DEFERRED:
455 do_xmote(gl, gh, LM_ST_UNLOCKED);
456 break;
457 default: /* Everything else */
458 printk(KERN_ERR "GFS2: wanted %u got %u\n", gl->gl_target, state);
459 GLOCK_BUG_ON(gl, 1);
460 }
461 spin_unlock(&gl->gl_spin);
462 gfs2_glock_put(gl);
463 return;
464 }
465
466 /* Fast path - we got what we asked for */
467 if (test_and_clear_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags))
468 gfs2_demote_wake(gl);
469 if (state != LM_ST_UNLOCKED) {
470 if (glops->go_xmote_bh) {
471 int rv;
472 spin_unlock(&gl->gl_spin);
473 rv = glops->go_xmote_bh(gl, gh);
474 if (rv == -EAGAIN)
475 return;
476 spin_lock(&gl->gl_spin);
477 if (rv) {
478 do_error(gl, rv);
479 goto out;
480 }
481 }
482 do_promote(gl);
483 }
484out:
485 clear_bit(GLF_LOCK, &gl->gl_flags);
486 spin_unlock(&gl->gl_spin);
487 gfs2_glock_put(gl);
488}
489
490static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock,
491 unsigned int cur_state, unsigned int req_state,
492 unsigned int flags)
493{
494 int ret = LM_OUT_ERROR;
495
496 if (!sdp->sd_lockstruct.ls_ops->lm_lock)
497 return req_state == LM_ST_UNLOCKED ? 0 : req_state;
498
499 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
500 ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state,
501 req_state, flags);
502 return ret;
503}
504
505/**
506 * do_xmote - Calls the DLM to change the state of a lock
507 * @gl: The lock state
508 * @gh: The holder (only for promotes)
509 * @target: The target lock state
510 *
511 */
512
513static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target)
514{
515 const struct gfs2_glock_operations *glops = gl->gl_ops;
516 struct gfs2_sbd *sdp = gl->gl_sbd;
517 unsigned int lck_flags = gh ? gh->gh_flags : 0;
518 int ret;
519
520 lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
521 LM_FLAG_PRIORITY);
522 BUG_ON(gl->gl_state == target);
523 BUG_ON(gl->gl_state == gl->gl_target);
524 if ((target == LM_ST_UNLOCKED || target == LM_ST_DEFERRED) &&
525 glops->go_inval) {
526 set_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags);
527 do_error(gl, 0); /* Fail queued try locks */
528 }
529 spin_unlock(&gl->gl_spin);
530 if (glops->go_xmote_th)
531 glops->go_xmote_th(gl);
532 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags))
533 glops->go_inval(gl, target == LM_ST_DEFERRED ? 0 : DIO_METADATA);
534 clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags);
535
536 gfs2_glock_hold(gl);
537 if (target != LM_ST_UNLOCKED && (gl->gl_state == LM_ST_SHARED ||
538 gl->gl_state == LM_ST_DEFERRED) &&
539 !(lck_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
540 lck_flags |= LM_FLAG_TRY_1CB;
541 ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, target, lck_flags);
542
543 if (!(ret & LM_OUT_ASYNC)) {
544 finish_xmote(gl, ret);
545 gfs2_glock_hold(gl);
546 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
547 gfs2_glock_put(gl);
548 } else {
549 GLOCK_BUG_ON(gl, ret != LM_OUT_ASYNC);
550 }
551 spin_lock(&gl->gl_spin);
552}
553
554/**
555 * find_first_holder - find the first "holder" gh
556 * @gl: the glock
557 */
558
559static inline struct gfs2_holder *find_first_holder(const struct gfs2_glock *gl)
560{
561 struct gfs2_holder *gh;
562
563 if (!list_empty(&gl->gl_holders)) {
564 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
565 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
566 return gh;
567 }
568 return NULL;
569}
570
571/**
572 * run_queue - do all outstanding tasks related to a glock
573 * @gl: The glock in question
574 * @nonblock: True if we must not block in run_queue
575 *
576 */
577
578static void run_queue(struct gfs2_glock *gl, const int nonblock)
579{
580 struct gfs2_holder *gh = NULL;
581
582 if (test_and_set_bit(GLF_LOCK, &gl->gl_flags))
583 return;
584
585 GLOCK_BUG_ON(gl, test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags));
586
587 if (test_bit(GLF_DEMOTE, &gl->gl_flags) &&
588 gl->gl_demote_state != gl->gl_state) {
589 if (find_first_holder(gl))
590 goto out;
591 if (nonblock)
592 goto out_sched;
593 set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
594 GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
595 gl->gl_target = gl->gl_demote_state;
596 } else {
597 if (test_bit(GLF_DEMOTE, &gl->gl_flags))
598 gfs2_demote_wake(gl);
599 if (do_promote(gl) == 0)
600 goto out;
601 gh = find_first_waiter(gl);
602 gl->gl_target = gh->gh_state;
603 if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
604 do_error(gl, 0); /* Fail queued try locks */
605 }
606 do_xmote(gl, gh, gl->gl_target);
607 return;
608
609out_sched:
610 gfs2_glock_hold(gl);
611 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
612 gfs2_glock_put(gl);
613out:
614 clear_bit(GLF_LOCK, &gl->gl_flags);
615}
616
284static void glock_work_func(struct work_struct *work) 617static void glock_work_func(struct work_struct *work)
285{ 618{
619 unsigned long delay = 0;
286 struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work); 620 struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work);
287 621
622 if (test_and_clear_bit(GLF_REPLY_PENDING, &gl->gl_flags))
623 finish_xmote(gl, gl->gl_reply);
288 spin_lock(&gl->gl_spin); 624 spin_lock(&gl->gl_spin);
289 if (test_and_clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags)) 625 if (test_and_clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
290 set_bit(GLF_DEMOTE, &gl->gl_flags); 626 gl->gl_state != LM_ST_UNLOCKED &&
291 run_queue(gl); 627 gl->gl_demote_state != LM_ST_EXCLUSIVE) {
628 unsigned long holdtime, now = jiffies;
629 holdtime = gl->gl_tchange + gl->gl_ops->go_min_hold_time;
630 if (time_before(now, holdtime))
631 delay = holdtime - now;
632 set_bit(delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE, &gl->gl_flags);
633 }
634 run_queue(gl, 0);
292 spin_unlock(&gl->gl_spin); 635 spin_unlock(&gl->gl_spin);
293 gfs2_glock_put(gl); 636 if (!delay ||
637 queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
638 gfs2_glock_put(gl);
294} 639}
295 640
296static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name, 641static int gfs2_lm_get_lock(struct gfs2_sbd *sdp, struct lm_lockname *name,
297 void **lockp) 642 void **lockp)
298{ 643{
299 int error = -EIO; 644 int error = -EIO;
645 if (!sdp->sd_lockstruct.ls_ops->lm_get_lock)
646 return 0;
300 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 647 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
301 error = sdp->sd_lockstruct.ls_ops->lm_get_lock( 648 error = sdp->sd_lockstruct.ls_ops->lm_get_lock(
302 sdp->sd_lockstruct.ls_lockspace, name, lockp); 649 sdp->sd_lockstruct.ls_lockspace, name, lockp);
@@ -342,12 +689,10 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
342 gl->gl_name = name; 689 gl->gl_name = name;
343 atomic_set(&gl->gl_ref, 1); 690 atomic_set(&gl->gl_ref, 1);
344 gl->gl_state = LM_ST_UNLOCKED; 691 gl->gl_state = LM_ST_UNLOCKED;
692 gl->gl_target = LM_ST_UNLOCKED;
345 gl->gl_demote_state = LM_ST_EXCLUSIVE; 693 gl->gl_demote_state = LM_ST_EXCLUSIVE;
346 gl->gl_hash = hash; 694 gl->gl_hash = hash;
347 gl->gl_owner_pid = NULL;
348 gl->gl_ip = 0;
349 gl->gl_ops = glops; 695 gl->gl_ops = glops;
350 gl->gl_req_gh = NULL;
351 gl->gl_stamp = jiffies; 696 gl->gl_stamp = jiffies;
352 gl->gl_tchange = jiffies; 697 gl->gl_tchange = jiffies;
353 gl->gl_object = NULL; 698 gl->gl_object = NULL;
@@ -447,13 +792,6 @@ void gfs2_holder_uninit(struct gfs2_holder *gh)
447 gh->gh_ip = 0; 792 gh->gh_ip = 0;
448} 793}
449 794
450static void gfs2_holder_wake(struct gfs2_holder *gh)
451{
452 clear_bit(HIF_WAIT, &gh->gh_iflags);
453 smp_mb__after_clear_bit();
454 wake_up_bit(&gh->gh_iflags, HIF_WAIT);
455}
456
457static int just_schedule(void *word) 795static int just_schedule(void *word)
458{ 796{
459 schedule(); 797 schedule();
@@ -466,14 +804,6 @@ static void wait_on_holder(struct gfs2_holder *gh)
466 wait_on_bit(&gh->gh_iflags, HIF_WAIT, just_schedule, TASK_UNINTERRUPTIBLE); 804 wait_on_bit(&gh->gh_iflags, HIF_WAIT, just_schedule, TASK_UNINTERRUPTIBLE);
467} 805}
468 806
469static void gfs2_demote_wake(struct gfs2_glock *gl)
470{
471 gl->gl_demote_state = LM_ST_EXCLUSIVE;
472 clear_bit(GLF_DEMOTE, &gl->gl_flags);
473 smp_mb__after_clear_bit();
474 wake_up_bit(&gl->gl_flags, GLF_DEMOTE);
475}
476
477static void wait_on_demote(struct gfs2_glock *gl) 807static void wait_on_demote(struct gfs2_glock *gl)
478{ 808{
479 might_sleep(); 809 might_sleep();
@@ -481,217 +811,6 @@ static void wait_on_demote(struct gfs2_glock *gl)
481} 811}
482 812
483/** 813/**
484 * rq_mutex - process a mutex request in the queue
485 * @gh: the glock holder
486 *
487 * Returns: 1 if the queue is blocked
488 */
489
490static int rq_mutex(struct gfs2_holder *gh)
491{
492 struct gfs2_glock *gl = gh->gh_gl;
493
494 list_del_init(&gh->gh_list);
495 /* gh->gh_error never examined. */
496 set_bit(GLF_LOCK, &gl->gl_flags);
497 clear_bit(HIF_WAIT, &gh->gh_iflags);
498 smp_mb();
499 wake_up_bit(&gh->gh_iflags, HIF_WAIT);
500
501 return 1;
502}
503
504/**
505 * rq_promote - process a promote request in the queue
506 * @gh: the glock holder
507 *
508 * Acquire a new inter-node lock, or change a lock state to more restrictive.
509 *
510 * Returns: 1 if the queue is blocked
511 */
512
513static int rq_promote(struct gfs2_holder *gh)
514{
515 struct gfs2_glock *gl = gh->gh_gl;
516
517 if (!relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) {
518 if (list_empty(&gl->gl_holders)) {
519 gl->gl_req_gh = gh;
520 set_bit(GLF_LOCK, &gl->gl_flags);
521 spin_unlock(&gl->gl_spin);
522 gfs2_glock_xmote_th(gh->gh_gl, gh);
523 spin_lock(&gl->gl_spin);
524 }
525 return 1;
526 }
527
528 if (list_empty(&gl->gl_holders)) {
529 set_bit(HIF_FIRST, &gh->gh_iflags);
530 set_bit(GLF_LOCK, &gl->gl_flags);
531 } else {
532 struct gfs2_holder *next_gh;
533 if (gh->gh_state == LM_ST_EXCLUSIVE)
534 return 1;
535 next_gh = list_entry(gl->gl_holders.next, struct gfs2_holder,
536 gh_list);
537 if (next_gh->gh_state == LM_ST_EXCLUSIVE)
538 return 1;
539 }
540
541 list_move_tail(&gh->gh_list, &gl->gl_holders);
542 gh->gh_error = 0;
543 set_bit(HIF_HOLDER, &gh->gh_iflags);
544
545 gfs2_holder_wake(gh);
546
547 return 0;
548}
549
550/**
551 * rq_demote - process a demote request in the queue
552 * @gh: the glock holder
553 *
554 * Returns: 1 if the queue is blocked
555 */
556
557static int rq_demote(struct gfs2_glock *gl)
558{
559 if (!list_empty(&gl->gl_holders))
560 return 1;
561
562 if (gl->gl_state == gl->gl_demote_state ||
563 gl->gl_state == LM_ST_UNLOCKED) {
564 gfs2_demote_wake(gl);
565 return 0;
566 }
567
568 set_bit(GLF_LOCK, &gl->gl_flags);
569 set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
570
571 if (gl->gl_demote_state == LM_ST_UNLOCKED ||
572 gl->gl_state != LM_ST_EXCLUSIVE) {
573 spin_unlock(&gl->gl_spin);
574 gfs2_glock_drop_th(gl);
575 } else {
576 spin_unlock(&gl->gl_spin);
577 gfs2_glock_xmote_th(gl, NULL);
578 }
579
580 spin_lock(&gl->gl_spin);
581 clear_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
582
583 return 0;
584}
585
586/**
587 * run_queue - process holder structures on a glock
588 * @gl: the glock
589 *
590 */
591static void run_queue(struct gfs2_glock *gl)
592{
593 struct gfs2_holder *gh;
594 int blocked = 1;
595
596 for (;;) {
597 if (test_bit(GLF_LOCK, &gl->gl_flags))
598 break;
599
600 if (!list_empty(&gl->gl_waiters1)) {
601 gh = list_entry(gl->gl_waiters1.next,
602 struct gfs2_holder, gh_list);
603 blocked = rq_mutex(gh);
604 } else if (test_bit(GLF_DEMOTE, &gl->gl_flags)) {
605 blocked = rq_demote(gl);
606 if (test_bit(GLF_WAITERS2, &gl->gl_flags) &&
607 !blocked) {
608 set_bit(GLF_DEMOTE, &gl->gl_flags);
609 gl->gl_demote_state = LM_ST_UNLOCKED;
610 }
611 clear_bit(GLF_WAITERS2, &gl->gl_flags);
612 } else if (!list_empty(&gl->gl_waiters3)) {
613 gh = list_entry(gl->gl_waiters3.next,
614 struct gfs2_holder, gh_list);
615 blocked = rq_promote(gh);
616 } else
617 break;
618
619 if (blocked)
620 break;
621 }
622}
623
624/**
625 * gfs2_glmutex_lock - acquire a local lock on a glock
626 * @gl: the glock
627 *
628 * Gives caller exclusive access to manipulate a glock structure.
629 */
630
631static void gfs2_glmutex_lock(struct gfs2_glock *gl)
632{
633 spin_lock(&gl->gl_spin);
634 if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) {
635 struct gfs2_holder gh;
636
637 gfs2_holder_init(gl, 0, 0, &gh);
638 set_bit(HIF_WAIT, &gh.gh_iflags);
639 list_add_tail(&gh.gh_list, &gl->gl_waiters1);
640 spin_unlock(&gl->gl_spin);
641 wait_on_holder(&gh);
642 gfs2_holder_uninit(&gh);
643 } else {
644 gl->gl_owner_pid = get_pid(task_pid(current));
645 gl->gl_ip = (unsigned long)__builtin_return_address(0);
646 spin_unlock(&gl->gl_spin);
647 }
648}
649
650/**
651 * gfs2_glmutex_trylock - try to acquire a local lock on a glock
652 * @gl: the glock
653 *
654 * Returns: 1 if the glock is acquired
655 */
656
657static int gfs2_glmutex_trylock(struct gfs2_glock *gl)
658{
659 int acquired = 1;
660
661 spin_lock(&gl->gl_spin);
662 if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) {
663 acquired = 0;
664 } else {
665 gl->gl_owner_pid = get_pid(task_pid(current));
666 gl->gl_ip = (unsigned long)__builtin_return_address(0);
667 }
668 spin_unlock(&gl->gl_spin);
669
670 return acquired;
671}
672
673/**
674 * gfs2_glmutex_unlock - release a local lock on a glock
675 * @gl: the glock
676 *
677 */
678
679static void gfs2_glmutex_unlock(struct gfs2_glock *gl)
680{
681 struct pid *pid;
682
683 spin_lock(&gl->gl_spin);
684 clear_bit(GLF_LOCK, &gl->gl_flags);
685 pid = gl->gl_owner_pid;
686 gl->gl_owner_pid = NULL;
687 gl->gl_ip = 0;
688 run_queue(gl);
689 spin_unlock(&gl->gl_spin);
690
691 put_pid(pid);
692}
693
694/**
695 * handle_callback - process a demote request 814 * handle_callback - process a demote request
696 * @gl: the glock 815 * @gl: the glock
697 * @state: the state the caller wants us to change to 816 * @state: the state the caller wants us to change to
@@ -705,398 +824,45 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state,
705{ 824{
706 int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE; 825 int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE;
707 826
708 spin_lock(&gl->gl_spin);
709 set_bit(bit, &gl->gl_flags); 827 set_bit(bit, &gl->gl_flags);
710 if (gl->gl_demote_state == LM_ST_EXCLUSIVE) { 828 if (gl->gl_demote_state == LM_ST_EXCLUSIVE) {
711 gl->gl_demote_state = state; 829 gl->gl_demote_state = state;
712 gl->gl_demote_time = jiffies; 830 gl->gl_demote_time = jiffies;
713 if (remote && gl->gl_ops->go_type == LM_TYPE_IOPEN && 831 if (remote && gl->gl_ops->go_type == LM_TYPE_IOPEN &&
714 gl->gl_object) { 832 gl->gl_object)
715 gfs2_glock_schedule_for_reclaim(gl); 833 gfs2_glock_schedule_for_reclaim(gl);
716 spin_unlock(&gl->gl_spin);
717 return;
718 }
719 } else if (gl->gl_demote_state != LM_ST_UNLOCKED && 834 } else if (gl->gl_demote_state != LM_ST_UNLOCKED &&
720 gl->gl_demote_state != state) { 835 gl->gl_demote_state != state) {
721 if (test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)) 836 gl->gl_demote_state = LM_ST_UNLOCKED;
722 set_bit(GLF_WAITERS2, &gl->gl_flags);
723 else
724 gl->gl_demote_state = LM_ST_UNLOCKED;
725 }
726 spin_unlock(&gl->gl_spin);
727}
728
729/**
730 * state_change - record that the glock is now in a different state
731 * @gl: the glock
732 * @new_state the new state
733 *
734 */
735
736static void state_change(struct gfs2_glock *gl, unsigned int new_state)
737{
738 int held1, held2;
739
740 held1 = (gl->gl_state != LM_ST_UNLOCKED);
741 held2 = (new_state != LM_ST_UNLOCKED);
742
743 if (held1 != held2) {
744 if (held2)
745 gfs2_glock_hold(gl);
746 else
747 gfs2_glock_put(gl);
748 } 837 }
749
750 gl->gl_state = new_state;
751 gl->gl_tchange = jiffies;
752} 838}
753 839
754/** 840/**
755 * drop_bh - Called after a lock module unlock completes 841 * gfs2_glock_wait - wait on a glock acquisition
756 * @gl: the glock
757 * @ret: the return status
758 *
759 * Doesn't wake up the process waiting on the struct gfs2_holder (if any)
760 * Doesn't drop the reference on the glock the top half took out
761 *
762 */
763
764static void drop_bh(struct gfs2_glock *gl, unsigned int ret)
765{
766 struct gfs2_sbd *sdp = gl->gl_sbd;
767 struct gfs2_holder *gh = gl->gl_req_gh;
768
769 gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
770 gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
771 gfs2_assert_warn(sdp, !ret);
772
773 state_change(gl, LM_ST_UNLOCKED);
774
775 if (test_and_clear_bit(GLF_CONV_DEADLK, &gl->gl_flags)) {
776 spin_lock(&gl->gl_spin);
777 gh->gh_error = 0;
778 spin_unlock(&gl->gl_spin);
779 gfs2_glock_xmote_th(gl, gl->gl_req_gh);
780 gfs2_glock_put(gl);
781 return;
782 }
783
784 spin_lock(&gl->gl_spin);
785 gfs2_demote_wake(gl);
786 clear_bit(GLF_LOCK, &gl->gl_flags);
787 spin_unlock(&gl->gl_spin);
788 gfs2_glock_put(gl);
789}
790
791/**
792 * xmote_bh - Called after the lock module is done acquiring a lock
793 * @gl: The glock in question
794 * @ret: the int returned from the lock module
795 *
796 */
797
798static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
799{
800 struct gfs2_sbd *sdp = gl->gl_sbd;
801 const struct gfs2_glock_operations *glops = gl->gl_ops;
802 struct gfs2_holder *gh = gl->gl_req_gh;
803 int op_done = 1;
804
805 if (!gh && (ret & LM_OUT_ST_MASK) == LM_ST_UNLOCKED) {
806 drop_bh(gl, ret);
807 return;
808 }
809
810 gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
811 gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
812 gfs2_assert_warn(sdp, !(ret & LM_OUT_ASYNC));
813
814 state_change(gl, ret & LM_OUT_ST_MASK);
815
816 /* Deal with each possible exit condition */
817
818 if (!gh) {
819 gl->gl_stamp = jiffies;
820 if (ret & LM_OUT_CANCELED) {
821 op_done = 0;
822 } else {
823 spin_lock(&gl->gl_spin);
824 if (gl->gl_state != gl->gl_demote_state) {
825 spin_unlock(&gl->gl_spin);
826 gfs2_glock_drop_th(gl);
827 gfs2_glock_put(gl);
828 return;
829 }
830 gfs2_demote_wake(gl);
831 spin_unlock(&gl->gl_spin);
832 }
833 } else {
834 spin_lock(&gl->gl_spin);
835 if (ret & LM_OUT_CONV_DEADLK) {
836 gh->gh_error = 0;
837 set_bit(GLF_CONV_DEADLK, &gl->gl_flags);
838 spin_unlock(&gl->gl_spin);
839 gfs2_glock_drop_th(gl);
840 gfs2_glock_put(gl);
841 return;
842 }
843 list_del_init(&gh->gh_list);
844 gh->gh_error = -EIO;
845 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
846 goto out;
847 gh->gh_error = GLR_CANCELED;
848 if (ret & LM_OUT_CANCELED)
849 goto out;
850 if (relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) {
851 list_add_tail(&gh->gh_list, &gl->gl_holders);
852 gh->gh_error = 0;
853 set_bit(HIF_HOLDER, &gh->gh_iflags);
854 set_bit(HIF_FIRST, &gh->gh_iflags);
855 op_done = 0;
856 goto out;
857 }
858 gh->gh_error = GLR_TRYFAILED;
859 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))
860 goto out;
861 gh->gh_error = -EINVAL;
862 if (gfs2_assert_withdraw(sdp, 0) == -1)
863 fs_err(sdp, "ret = 0x%.8X\n", ret);
864out:
865 spin_unlock(&gl->gl_spin);
866 }
867
868 if (glops->go_xmote_bh)
869 glops->go_xmote_bh(gl);
870
871 if (op_done) {
872 spin_lock(&gl->gl_spin);
873 gl->gl_req_gh = NULL;
874 clear_bit(GLF_LOCK, &gl->gl_flags);
875 spin_unlock(&gl->gl_spin);
876 }
877
878 gfs2_glock_put(gl);
879
880 if (gh)
881 gfs2_holder_wake(gh);
882}
883
884static unsigned int gfs2_lm_lock(struct gfs2_sbd *sdp, void *lock,
885 unsigned int cur_state, unsigned int req_state,
886 unsigned int flags)
887{
888 int ret = 0;
889 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
890 ret = sdp->sd_lockstruct.ls_ops->lm_lock(lock, cur_state,
891 req_state, flags);
892 return ret;
893}
894
895/**
896 * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock
897 * @gl: The glock in question
898 * @state: the requested state
899 * @flags: modifier flags to the lock call
900 *
901 */
902
903static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh)
904{
905 struct gfs2_sbd *sdp = gl->gl_sbd;
906 int flags = gh ? gh->gh_flags : 0;
907 unsigned state = gh ? gh->gh_state : gl->gl_demote_state;
908 const struct gfs2_glock_operations *glops = gl->gl_ops;
909 int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB |
910 LM_FLAG_NOEXP | LM_FLAG_ANY |
911 LM_FLAG_PRIORITY);
912 unsigned int lck_ret;
913
914 if (glops->go_xmote_th)
915 glops->go_xmote_th(gl);
916 if (state == LM_ST_DEFERRED && glops->go_inval)
917 glops->go_inval(gl, DIO_METADATA);
918
919 gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
920 gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
921 gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED);
922 gfs2_assert_warn(sdp, state != gl->gl_state);
923
924 gfs2_glock_hold(gl);
925
926 lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags);
927
928 if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR)))
929 return;
930
931 if (lck_ret & LM_OUT_ASYNC)
932 gfs2_assert_warn(sdp, lck_ret == LM_OUT_ASYNC);
933 else
934 xmote_bh(gl, lck_ret);
935}
936
937static unsigned int gfs2_lm_unlock(struct gfs2_sbd *sdp, void *lock,
938 unsigned int cur_state)
939{
940 int ret = 0;
941 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
942 ret = sdp->sd_lockstruct.ls_ops->lm_unlock(lock, cur_state);
943 return ret;
944}
945
946/**
947 * gfs2_glock_drop_th - call into the lock module to unlock a lock
948 * @gl: the glock
949 *
950 */
951
952static void gfs2_glock_drop_th(struct gfs2_glock *gl)
953{
954 struct gfs2_sbd *sdp = gl->gl_sbd;
955 const struct gfs2_glock_operations *glops = gl->gl_ops;
956 unsigned int ret;
957
958 if (glops->go_xmote_th)
959 glops->go_xmote_th(gl);
960 if (glops->go_inval)
961 glops->go_inval(gl, DIO_METADATA);
962
963 gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
964 gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
965 gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED);
966
967 gfs2_glock_hold(gl);
968
969 ret = gfs2_lm_unlock(sdp, gl->gl_lock, gl->gl_state);
970
971 if (gfs2_assert_withdraw(sdp, !(ret & LM_OUT_ERROR)))
972 return;
973
974 if (!ret)
975 drop_bh(gl, ret);
976 else
977 gfs2_assert_warn(sdp, ret == LM_OUT_ASYNC);
978}
979
980/**
981 * do_cancels - cancel requests for locks stuck waiting on an expire flag
982 * @gh: the LM_FLAG_PRIORITY holder waiting to acquire the lock
983 *
984 * Don't cancel GL_NOCANCEL requests.
985 */
986
987static void do_cancels(struct gfs2_holder *gh)
988{
989 struct gfs2_glock *gl = gh->gh_gl;
990 struct gfs2_sbd *sdp = gl->gl_sbd;
991
992 spin_lock(&gl->gl_spin);
993
994 while (gl->gl_req_gh != gh &&
995 !test_bit(HIF_HOLDER, &gh->gh_iflags) &&
996 !list_empty(&gh->gh_list)) {
997 if (!(gl->gl_req_gh && (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) {
998 spin_unlock(&gl->gl_spin);
999 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
1000 sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
1001 msleep(100);
1002 spin_lock(&gl->gl_spin);
1003 } else {
1004 spin_unlock(&gl->gl_spin);
1005 msleep(100);
1006 spin_lock(&gl->gl_spin);
1007 }
1008 }
1009
1010 spin_unlock(&gl->gl_spin);
1011}
1012
1013/**
1014 * glock_wait_internal - wait on a glock acquisition
1015 * @gh: the glock holder 842 * @gh: the glock holder
1016 * 843 *
1017 * Returns: 0 on success 844 * Returns: 0 on success
1018 */ 845 */
1019 846
1020static int glock_wait_internal(struct gfs2_holder *gh) 847int gfs2_glock_wait(struct gfs2_holder *gh)
1021{ 848{
1022 struct gfs2_glock *gl = gh->gh_gl;
1023 struct gfs2_sbd *sdp = gl->gl_sbd;
1024 const struct gfs2_glock_operations *glops = gl->gl_ops;
1025
1026 if (test_bit(HIF_ABORTED, &gh->gh_iflags))
1027 return -EIO;
1028
1029 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) {
1030 spin_lock(&gl->gl_spin);
1031 if (gl->gl_req_gh != gh &&
1032 !test_bit(HIF_HOLDER, &gh->gh_iflags) &&
1033 !list_empty(&gh->gh_list)) {
1034 list_del_init(&gh->gh_list);
1035 gh->gh_error = GLR_TRYFAILED;
1036 run_queue(gl);
1037 spin_unlock(&gl->gl_spin);
1038 return gh->gh_error;
1039 }
1040 spin_unlock(&gl->gl_spin);
1041 }
1042
1043 if (gh->gh_flags & LM_FLAG_PRIORITY)
1044 do_cancels(gh);
1045
1046 wait_on_holder(gh); 849 wait_on_holder(gh);
1047 if (gh->gh_error)
1048 return gh->gh_error;
1049
1050 gfs2_assert_withdraw(sdp, test_bit(HIF_HOLDER, &gh->gh_iflags));
1051 gfs2_assert_withdraw(sdp, relaxed_state_ok(gl->gl_state, gh->gh_state,
1052 gh->gh_flags));
1053
1054 if (test_bit(HIF_FIRST, &gh->gh_iflags)) {
1055 gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
1056
1057 if (glops->go_lock) {
1058 gh->gh_error = glops->go_lock(gh);
1059 if (gh->gh_error) {
1060 spin_lock(&gl->gl_spin);
1061 list_del_init(&gh->gh_list);
1062 spin_unlock(&gl->gl_spin);
1063 }
1064 }
1065
1066 spin_lock(&gl->gl_spin);
1067 gl->gl_req_gh = NULL;
1068 clear_bit(GLF_LOCK, &gl->gl_flags);
1069 run_queue(gl);
1070 spin_unlock(&gl->gl_spin);
1071 }
1072
1073 return gh->gh_error; 850 return gh->gh_error;
1074} 851}
1075 852
1076static inline struct gfs2_holder * 853void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...)
1077find_holder_by_owner(struct list_head *head, struct pid *pid)
1078{
1079 struct gfs2_holder *gh;
1080
1081 list_for_each_entry(gh, head, gh_list) {
1082 if (gh->gh_owner_pid == pid)
1083 return gh;
1084 }
1085
1086 return NULL;
1087}
1088
1089static void print_dbg(struct glock_iter *gi, const char *fmt, ...)
1090{ 854{
1091 va_list args; 855 va_list args;
1092 856
1093 va_start(args, fmt); 857 va_start(args, fmt);
1094 if (gi) { 858 if (seq) {
859 struct gfs2_glock_iter *gi = seq->private;
1095 vsprintf(gi->string, fmt, args); 860 vsprintf(gi->string, fmt, args);
1096 seq_printf(gi->seq, gi->string); 861 seq_printf(seq, gi->string);
1097 } 862 } else {
1098 else 863 printk(KERN_ERR " ");
1099 vprintk(fmt, args); 864 vprintk(fmt, args);
865 }
1100 va_end(args); 866 va_end(args);
1101} 867}
1102 868
@@ -1104,50 +870,76 @@ static void print_dbg(struct glock_iter *gi, const char *fmt, ...)
1104 * add_to_queue - Add a holder to the wait queue (but look for recursion) 870 * add_to_queue - Add a holder to the wait queue (but look for recursion)
1105 * @gh: the holder structure to add 871 * @gh: the holder structure to add
1106 * 872 *
873 * Eventually we should move the recursive locking trap to a
874 * debugging option or something like that. This is the fast
875 * path and needs to have the minimum number of distractions.
876 *
1107 */ 877 */
1108 878
1109static void add_to_queue(struct gfs2_holder *gh) 879static inline void add_to_queue(struct gfs2_holder *gh)
1110{ 880{
1111 struct gfs2_glock *gl = gh->gh_gl; 881 struct gfs2_glock *gl = gh->gh_gl;
1112 struct gfs2_holder *existing; 882 struct gfs2_sbd *sdp = gl->gl_sbd;
883 struct list_head *insert_pt = NULL;
884 struct gfs2_holder *gh2;
885 int try_lock = 0;
1113 886
1114 BUG_ON(gh->gh_owner_pid == NULL); 887 BUG_ON(gh->gh_owner_pid == NULL);
1115 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) 888 if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags))
1116 BUG(); 889 BUG();
1117 890
1118 if (!(gh->gh_flags & GL_FLOCK)) { 891 if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) {
1119 existing = find_holder_by_owner(&gl->gl_holders, 892 if (test_bit(GLF_LOCK, &gl->gl_flags))
1120 gh->gh_owner_pid); 893 try_lock = 1;
1121 if (existing) { 894 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags))
1122 print_symbol(KERN_WARNING "original: %s\n", 895 goto fail;
1123 existing->gh_ip); 896 }
1124 printk(KERN_INFO "pid : %d\n", 897
1125 pid_nr(existing->gh_owner_pid)); 898 list_for_each_entry(gh2, &gl->gl_holders, gh_list) {
1126 printk(KERN_INFO "lock type : %d lock state : %d\n", 899 if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid &&
1127 existing->gh_gl->gl_name.ln_type, 900 (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK)))
1128 existing->gh_gl->gl_state); 901 goto trap_recursive;
1129 print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip); 902 if (try_lock &&
1130 printk(KERN_INFO "pid : %d\n", 903 !(gh2->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) &&
1131 pid_nr(gh->gh_owner_pid)); 904 !may_grant(gl, gh)) {
1132 printk(KERN_INFO "lock type : %d lock state : %d\n", 905fail:
1133 gl->gl_name.ln_type, gl->gl_state); 906 gh->gh_error = GLR_TRYFAILED;
1134 BUG(); 907 gfs2_holder_wake(gh);
1135 } 908 return;
1136
1137 existing = find_holder_by_owner(&gl->gl_waiters3,
1138 gh->gh_owner_pid);
1139 if (existing) {
1140 print_symbol(KERN_WARNING "original: %s\n",
1141 existing->gh_ip);
1142 print_symbol(KERN_WARNING "new: %s\n", gh->gh_ip);
1143 BUG();
1144 } 909 }
910 if (test_bit(HIF_HOLDER, &gh2->gh_iflags))
911 continue;
912 if (unlikely((gh->gh_flags & LM_FLAG_PRIORITY) && !insert_pt))
913 insert_pt = &gh2->gh_list;
914 }
915 if (likely(insert_pt == NULL)) {
916 list_add_tail(&gh->gh_list, &gl->gl_holders);
917 if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY))
918 goto do_cancel;
919 return;
920 }
921 list_add_tail(&gh->gh_list, insert_pt);
922do_cancel:
923 gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
924 if (!(gh->gh_flags & LM_FLAG_PRIORITY)) {
925 spin_unlock(&gl->gl_spin);
926 if (sdp->sd_lockstruct.ls_ops->lm_cancel)
927 sdp->sd_lockstruct.ls_ops->lm_cancel(gl->gl_lock);
928 spin_lock(&gl->gl_spin);
1145 } 929 }
930 return;
1146 931
1147 if (gh->gh_flags & LM_FLAG_PRIORITY) 932trap_recursive:
1148 list_add(&gh->gh_list, &gl->gl_waiters3); 933 print_symbol(KERN_ERR "original: %s\n", gh2->gh_ip);
1149 else 934 printk(KERN_ERR "pid: %d\n", pid_nr(gh2->gh_owner_pid));
1150 list_add_tail(&gh->gh_list, &gl->gl_waiters3); 935 printk(KERN_ERR "lock type: %d req lock state : %d\n",
936 gh2->gh_gl->gl_name.ln_type, gh2->gh_state);
937 print_symbol(KERN_ERR "new: %s\n", gh->gh_ip);
938 printk(KERN_ERR "pid: %d\n", pid_nr(gh->gh_owner_pid));
939 printk(KERN_ERR "lock type: %d req lock state : %d\n",
940 gh->gh_gl->gl_name.ln_type, gh->gh_state);
941 __dump_glock(NULL, gl);
942 BUG();
1151} 943}
1152 944
1153/** 945/**
@@ -1165,24 +957,16 @@ int gfs2_glock_nq(struct gfs2_holder *gh)
1165 struct gfs2_sbd *sdp = gl->gl_sbd; 957 struct gfs2_sbd *sdp = gl->gl_sbd;
1166 int error = 0; 958 int error = 0;
1167 959
1168restart: 960 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
1169 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) {
1170 set_bit(HIF_ABORTED, &gh->gh_iflags);
1171 return -EIO; 961 return -EIO;
1172 }
1173 962
1174 spin_lock(&gl->gl_spin); 963 spin_lock(&gl->gl_spin);
1175 add_to_queue(gh); 964 add_to_queue(gh);
1176 run_queue(gl); 965 run_queue(gl, 1);
1177 spin_unlock(&gl->gl_spin); 966 spin_unlock(&gl->gl_spin);
1178 967
1179 if (!(gh->gh_flags & GL_ASYNC)) { 968 if (!(gh->gh_flags & GL_ASYNC))
1180 error = glock_wait_internal(gh); 969 error = gfs2_glock_wait(gh);
1181 if (error == GLR_CANCELED) {
1182 msleep(100);
1183 goto restart;
1184 }
1185 }
1186 970
1187 return error; 971 return error;
1188} 972}
@@ -1196,48 +980,7 @@ restart:
1196 980
1197int gfs2_glock_poll(struct gfs2_holder *gh) 981int gfs2_glock_poll(struct gfs2_holder *gh)
1198{ 982{
1199 struct gfs2_glock *gl = gh->gh_gl; 983 return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1;
1200 int ready = 0;
1201
1202 spin_lock(&gl->gl_spin);
1203
1204 if (test_bit(HIF_HOLDER, &gh->gh_iflags))
1205 ready = 1;
1206 else if (list_empty(&gh->gh_list)) {
1207 if (gh->gh_error == GLR_CANCELED) {
1208 spin_unlock(&gl->gl_spin);
1209 msleep(100);
1210 if (gfs2_glock_nq(gh))
1211 return 1;
1212 return 0;
1213 } else
1214 ready = 1;
1215 }
1216
1217 spin_unlock(&gl->gl_spin);
1218
1219 return ready;
1220}
1221
1222/**
1223 * gfs2_glock_wait - wait for a lock acquisition that ended in a GLR_ASYNC
1224 * @gh: the holder structure
1225 *
1226 * Returns: 0, GLR_TRYFAILED, or errno on failure
1227 */
1228
1229int gfs2_glock_wait(struct gfs2_holder *gh)
1230{
1231 int error;
1232
1233 error = glock_wait_internal(gh);
1234 if (error == GLR_CANCELED) {
1235 msleep(100);
1236 gh->gh_flags &= ~GL_ASYNC;
1237 error = gfs2_glock_nq(gh);
1238 }
1239
1240 return error;
1241} 984}
1242 985
1243/** 986/**
@@ -1251,26 +994,30 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
1251 struct gfs2_glock *gl = gh->gh_gl; 994 struct gfs2_glock *gl = gh->gh_gl;
1252 const struct gfs2_glock_operations *glops = gl->gl_ops; 995 const struct gfs2_glock_operations *glops = gl->gl_ops;
1253 unsigned delay = 0; 996 unsigned delay = 0;
997 int fast_path = 0;
1254 998
999 spin_lock(&gl->gl_spin);
1255 if (gh->gh_flags & GL_NOCACHE) 1000 if (gh->gh_flags & GL_NOCACHE)
1256 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1001 handle_callback(gl, LM_ST_UNLOCKED, 0, 0);
1257 1002
1258 gfs2_glmutex_lock(gl);
1259
1260 spin_lock(&gl->gl_spin);
1261 list_del_init(&gh->gh_list); 1003 list_del_init(&gh->gh_list);
1262 1004 if (find_first_holder(gl) == NULL) {
1263 if (list_empty(&gl->gl_holders)) {
1264 if (glops->go_unlock) { 1005 if (glops->go_unlock) {
1006 GLOCK_BUG_ON(gl, test_and_set_bit(GLF_LOCK, &gl->gl_flags));
1265 spin_unlock(&gl->gl_spin); 1007 spin_unlock(&gl->gl_spin);
1266 glops->go_unlock(gh); 1008 glops->go_unlock(gh);
1267 spin_lock(&gl->gl_spin); 1009 spin_lock(&gl->gl_spin);
1010 clear_bit(GLF_LOCK, &gl->gl_flags);
1268 } 1011 }
1269 gl->gl_stamp = jiffies; 1012 gl->gl_stamp = jiffies;
1013 if (list_empty(&gl->gl_holders) &&
1014 !test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
1015 !test_bit(GLF_DEMOTE, &gl->gl_flags))
1016 fast_path = 1;
1270 } 1017 }
1271
1272 clear_bit(GLF_LOCK, &gl->gl_flags);
1273 spin_unlock(&gl->gl_spin); 1018 spin_unlock(&gl->gl_spin);
1019 if (likely(fast_path))
1020 return;
1274 1021
1275 gfs2_glock_hold(gl); 1022 gfs2_glock_hold(gl);
1276 if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) && 1023 if (test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags) &&
@@ -1454,6 +1201,8 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs)
1454static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp) 1201static int gfs2_lm_hold_lvb(struct gfs2_sbd *sdp, void *lock, char **lvbp)
1455{ 1202{
1456 int error = -EIO; 1203 int error = -EIO;
1204 if (!sdp->sd_lockstruct.ls_ops->lm_hold_lvb)
1205 return 0;
1457 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 1206 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
1458 error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp); 1207 error = sdp->sd_lockstruct.ls_ops->lm_hold_lvb(lock, lvbp);
1459 return error; 1208 return error;
@@ -1469,20 +1218,14 @@ int gfs2_lvb_hold(struct gfs2_glock *gl)
1469{ 1218{
1470 int error; 1219 int error;
1471 1220
1472 gfs2_glmutex_lock(gl);
1473
1474 if (!atomic_read(&gl->gl_lvb_count)) { 1221 if (!atomic_read(&gl->gl_lvb_count)) {
1475 error = gfs2_lm_hold_lvb(gl->gl_sbd, gl->gl_lock, &gl->gl_lvb); 1222 error = gfs2_lm_hold_lvb(gl->gl_sbd, gl->gl_lock, &gl->gl_lvb);
1476 if (error) { 1223 if (error)
1477 gfs2_glmutex_unlock(gl);
1478 return error; 1224 return error;
1479 }
1480 gfs2_glock_hold(gl); 1225 gfs2_glock_hold(gl);
1481 } 1226 }
1482 atomic_inc(&gl->gl_lvb_count); 1227 atomic_inc(&gl->gl_lvb_count);
1483 1228
1484 gfs2_glmutex_unlock(gl);
1485
1486 return 0; 1229 return 0;
1487} 1230}
1488 1231
@@ -1497,17 +1240,13 @@ void gfs2_lvb_unhold(struct gfs2_glock *gl)
1497 struct gfs2_sbd *sdp = gl->gl_sbd; 1240 struct gfs2_sbd *sdp = gl->gl_sbd;
1498 1241
1499 gfs2_glock_hold(gl); 1242 gfs2_glock_hold(gl);
1500 gfs2_glmutex_lock(gl);
1501
1502 gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0); 1243 gfs2_assert(gl->gl_sbd, atomic_read(&gl->gl_lvb_count) > 0);
1503 if (atomic_dec_and_test(&gl->gl_lvb_count)) { 1244 if (atomic_dec_and_test(&gl->gl_lvb_count)) {
1504 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 1245 if (sdp->sd_lockstruct.ls_ops->lm_unhold_lvb)
1505 sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb); 1246 sdp->sd_lockstruct.ls_ops->lm_unhold_lvb(gl->gl_lock, gl->gl_lvb);
1506 gl->gl_lvb = NULL; 1247 gl->gl_lvb = NULL;
1507 gfs2_glock_put(gl); 1248 gfs2_glock_put(gl);
1508 } 1249 }
1509
1510 gfs2_glmutex_unlock(gl);
1511 gfs2_glock_put(gl); 1250 gfs2_glock_put(gl);
1512} 1251}
1513 1252
@@ -1527,7 +1266,9 @@ static void blocking_cb(struct gfs2_sbd *sdp, struct lm_lockname *name,
1527 if (time_before(now, holdtime)) 1266 if (time_before(now, holdtime))
1528 delay = holdtime - now; 1267 delay = holdtime - now;
1529 1268
1269 spin_lock(&gl->gl_spin);
1530 handle_callback(gl, state, 1, delay); 1270 handle_callback(gl, state, 1, delay);
1271 spin_unlock(&gl->gl_spin);
1531 if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0) 1272 if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
1532 gfs2_glock_put(gl); 1273 gfs2_glock_put(gl);
1533} 1274}
@@ -1568,7 +1309,8 @@ void gfs2_glock_cb(void *cb_data, unsigned int type, void *data)
1568 gl = gfs2_glock_find(sdp, &async->lc_name); 1309 gl = gfs2_glock_find(sdp, &async->lc_name);
1569 if (gfs2_assert_warn(sdp, gl)) 1310 if (gfs2_assert_warn(sdp, gl))
1570 return; 1311 return;
1571 xmote_bh(gl, async->lc_ret); 1312 gl->gl_reply = async->lc_ret;
1313 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
1572 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) 1314 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1573 gfs2_glock_put(gl); 1315 gfs2_glock_put(gl);
1574 up_read(&gfs2_umount_flush_sem); 1316 up_read(&gfs2_umount_flush_sem);
@@ -1581,11 +1323,6 @@ void gfs2_glock_cb(void *cb_data, unsigned int type, void *data)
1581 wake_up_process(sdp->sd_recoverd_process); 1323 wake_up_process(sdp->sd_recoverd_process);
1582 return; 1324 return;
1583 1325
1584 case LM_CB_DROPLOCKS:
1585 gfs2_gl_hash_clear(sdp, NO_WAIT);
1586 gfs2_quota_scan(sdp);
1587 return;
1588
1589 default: 1326 default:
1590 gfs2_assert_warn(sdp, 0); 1327 gfs2_assert_warn(sdp, 0);
1591 return; 1328 return;
@@ -1646,6 +1383,7 @@ void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl)
1646void gfs2_reclaim_glock(struct gfs2_sbd *sdp) 1383void gfs2_reclaim_glock(struct gfs2_sbd *sdp)
1647{ 1384{
1648 struct gfs2_glock *gl; 1385 struct gfs2_glock *gl;
1386 int done_callback = 0;
1649 1387
1650 spin_lock(&sdp->sd_reclaim_lock); 1388 spin_lock(&sdp->sd_reclaim_lock);
1651 if (list_empty(&sdp->sd_reclaim_list)) { 1389 if (list_empty(&sdp->sd_reclaim_list)) {
@@ -1660,14 +1398,16 @@ void gfs2_reclaim_glock(struct gfs2_sbd *sdp)
1660 atomic_dec(&sdp->sd_reclaim_count); 1398 atomic_dec(&sdp->sd_reclaim_count);
1661 atomic_inc(&sdp->sd_reclaimed); 1399 atomic_inc(&sdp->sd_reclaimed);
1662 1400
1663 if (gfs2_glmutex_trylock(gl)) { 1401 spin_lock(&gl->gl_spin);
1664 if (list_empty(&gl->gl_holders) && 1402 if (find_first_holder(gl) == NULL &&
1665 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) 1403 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) {
1666 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1404 handle_callback(gl, LM_ST_UNLOCKED, 0, 0);
1667 gfs2_glmutex_unlock(gl); 1405 done_callback = 1;
1668 } 1406 }
1669 1407 spin_unlock(&gl->gl_spin);
1670 gfs2_glock_put(gl); 1408 if (!done_callback ||
1409 queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1410 gfs2_glock_put(gl);
1671} 1411}
1672 1412
1673/** 1413/**
@@ -1724,18 +1464,14 @@ static void scan_glock(struct gfs2_glock *gl)
1724{ 1464{
1725 if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) 1465 if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object)
1726 return; 1466 return;
1467 if (test_bit(GLF_LOCK, &gl->gl_flags))
1468 return;
1727 1469
1728 if (gfs2_glmutex_trylock(gl)) { 1470 spin_lock(&gl->gl_spin);
1729 if (list_empty(&gl->gl_holders) && 1471 if (find_first_holder(gl) == NULL &&
1730 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl)) 1472 gl->gl_state != LM_ST_UNLOCKED && demote_ok(gl))
1731 goto out_schedule; 1473 gfs2_glock_schedule_for_reclaim(gl);
1732 gfs2_glmutex_unlock(gl); 1474 spin_unlock(&gl->gl_spin);
1733 }
1734 return;
1735
1736out_schedule:
1737 gfs2_glmutex_unlock(gl);
1738 gfs2_glock_schedule_for_reclaim(gl);
1739} 1475}
1740 1476
1741/** 1477/**
@@ -1760,12 +1496,13 @@ static void clear_glock(struct gfs2_glock *gl)
1760 spin_unlock(&sdp->sd_reclaim_lock); 1496 spin_unlock(&sdp->sd_reclaim_lock);
1761 } 1497 }
1762 1498
1763 if (gfs2_glmutex_trylock(gl)) { 1499 spin_lock(&gl->gl_spin);
1764 if (list_empty(&gl->gl_holders) && 1500 if (find_first_holder(gl) == NULL && gl->gl_state != LM_ST_UNLOCKED)
1765 gl->gl_state != LM_ST_UNLOCKED) 1501 handle_callback(gl, LM_ST_UNLOCKED, 0, 0);
1766 handle_callback(gl, LM_ST_UNLOCKED, 0, 0); 1502 spin_unlock(&gl->gl_spin);
1767 gfs2_glmutex_unlock(gl); 1503 gfs2_glock_hold(gl);
1768 } 1504 if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
1505 gfs2_glock_put(gl);
1769} 1506}
1770 1507
1771/** 1508/**
@@ -1773,11 +1510,10 @@ static void clear_glock(struct gfs2_glock *gl)
1773 * @sdp: the filesystem 1510 * @sdp: the filesystem
1774 * @wait: wait until it's all gone 1511 * @wait: wait until it's all gone
1775 * 1512 *
1776 * Called when unmounting the filesystem, or when inter-node lock manager 1513 * Called when unmounting the filesystem.
1777 * requests DROPLOCKS because it is running out of capacity.
1778 */ 1514 */
1779 1515
1780void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait) 1516void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
1781{ 1517{
1782 unsigned long t; 1518 unsigned long t;
1783 unsigned int x; 1519 unsigned int x;
@@ -1792,7 +1528,7 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait)
1792 cont = 1; 1528 cont = 1;
1793 } 1529 }
1794 1530
1795 if (!wait || !cont) 1531 if (!cont)
1796 break; 1532 break;
1797 1533
1798 if (time_after_eq(jiffies, 1534 if (time_after_eq(jiffies,
@@ -1810,180 +1546,164 @@ void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait)
1810 } 1546 }
1811} 1547}
1812 1548
1813/* 1549static const char *state2str(unsigned state)
1814 * Diagnostic routines to help debug distributed deadlock
1815 */
1816
1817static void gfs2_print_symbol(struct glock_iter *gi, const char *fmt,
1818 unsigned long address)
1819{ 1550{
1820 char buffer[KSYM_SYMBOL_LEN]; 1551 switch(state) {
1821 1552 case LM_ST_UNLOCKED:
1822 sprint_symbol(buffer, address); 1553 return "UN";
1823 print_dbg(gi, fmt, buffer); 1554 case LM_ST_SHARED:
1555 return "SH";
1556 case LM_ST_DEFERRED:
1557 return "DF";
1558 case LM_ST_EXCLUSIVE:
1559 return "EX";
1560 }
1561 return "??";
1562}
1563
1564static const char *hflags2str(char *buf, unsigned flags, unsigned long iflags)
1565{
1566 char *p = buf;
1567 if (flags & LM_FLAG_TRY)
1568 *p++ = 't';
1569 if (flags & LM_FLAG_TRY_1CB)
1570 *p++ = 'T';
1571 if (flags & LM_FLAG_NOEXP)
1572 *p++ = 'e';
1573 if (flags & LM_FLAG_ANY)
1574 *p++ = 'a';
1575 if (flags & LM_FLAG_PRIORITY)
1576 *p++ = 'p';
1577 if (flags & GL_ASYNC)
1578 *p++ = 'a';
1579 if (flags & GL_EXACT)
1580 *p++ = 'E';
1581 if (flags & GL_ATIME)
1582 *p++ = 'a';
1583 if (flags & GL_NOCACHE)
1584 *p++ = 'c';
1585 if (test_bit(HIF_HOLDER, &iflags))
1586 *p++ = 'H';
1587 if (test_bit(HIF_WAIT, &iflags))
1588 *p++ = 'W';
1589 if (test_bit(HIF_FIRST, &iflags))
1590 *p++ = 'F';
1591 *p = 0;
1592 return buf;
1824} 1593}
1825 1594
1826/** 1595/**
1827 * dump_holder - print information about a glock holder 1596 * dump_holder - print information about a glock holder
1828 * @str: a string naming the type of holder 1597 * @seq: the seq_file struct
1829 * @gh: the glock holder 1598 * @gh: the glock holder
1830 * 1599 *
1831 * Returns: 0 on success, -ENOBUFS when we run out of space 1600 * Returns: 0 on success, -ENOBUFS when we run out of space
1832 */ 1601 */
1833 1602
1834static int dump_holder(struct glock_iter *gi, char *str, 1603static int dump_holder(struct seq_file *seq, const struct gfs2_holder *gh)
1835 struct gfs2_holder *gh)
1836{ 1604{
1837 unsigned int x; 1605 struct task_struct *gh_owner = NULL;
1838 struct task_struct *gh_owner; 1606 char buffer[KSYM_SYMBOL_LEN];
1607 char flags_buf[32];
1839 1608
1840 print_dbg(gi, " %s\n", str); 1609 sprint_symbol(buffer, gh->gh_ip);
1841 if (gh->gh_owner_pid) { 1610 if (gh->gh_owner_pid)
1842 print_dbg(gi, " owner = %ld ",
1843 (long)pid_nr(gh->gh_owner_pid));
1844 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID); 1611 gh_owner = pid_task(gh->gh_owner_pid, PIDTYPE_PID);
1845 if (gh_owner) 1612 gfs2_print_dbg(seq, " H: s:%s f:%s e:%d p:%ld [%s] %s\n",
1846 print_dbg(gi, "(%s)\n", gh_owner->comm); 1613 state2str(gh->gh_state),
1847 else 1614 hflags2str(flags_buf, gh->gh_flags, gh->gh_iflags),
1848 print_dbg(gi, "(ended)\n"); 1615 gh->gh_error,
1849 } else 1616 gh->gh_owner_pid ? (long)pid_nr(gh->gh_owner_pid) : -1,
1850 print_dbg(gi, " owner = -1\n"); 1617 gh_owner ? gh_owner->comm : "(ended)", buffer);
1851 print_dbg(gi, " gh_state = %u\n", gh->gh_state);
1852 print_dbg(gi, " gh_flags =");
1853 for (x = 0; x < 32; x++)
1854 if (gh->gh_flags & (1 << x))
1855 print_dbg(gi, " %u", x);
1856 print_dbg(gi, " \n");
1857 print_dbg(gi, " error = %d\n", gh->gh_error);
1858 print_dbg(gi, " gh_iflags =");
1859 for (x = 0; x < 32; x++)
1860 if (test_bit(x, &gh->gh_iflags))
1861 print_dbg(gi, " %u", x);
1862 print_dbg(gi, " \n");
1863 gfs2_print_symbol(gi, " initialized at: %s\n", gh->gh_ip);
1864
1865 return 0; 1618 return 0;
1866} 1619}
1867 1620
1868/** 1621static const char *gflags2str(char *buf, const unsigned long *gflags)
1869 * dump_inode - print information about an inode 1622{
1870 * @ip: the inode 1623 char *p = buf;
1871 * 1624 if (test_bit(GLF_LOCK, gflags))
1872 * Returns: 0 on success, -ENOBUFS when we run out of space 1625 *p++ = 'l';
1873 */ 1626 if (test_bit(GLF_STICKY, gflags))
1874 1627 *p++ = 's';
1875static int dump_inode(struct glock_iter *gi, struct gfs2_inode *ip) 1628 if (test_bit(GLF_DEMOTE, gflags))
1876{ 1629 *p++ = 'D';
1877 unsigned int x; 1630 if (test_bit(GLF_PENDING_DEMOTE, gflags))
1878 1631 *p++ = 'd';
1879 print_dbg(gi, " Inode:\n"); 1632 if (test_bit(GLF_DEMOTE_IN_PROGRESS, gflags))
1880 print_dbg(gi, " num = %llu/%llu\n", 1633 *p++ = 'p';
1881 (unsigned long long)ip->i_no_formal_ino, 1634 if (test_bit(GLF_DIRTY, gflags))
1882 (unsigned long long)ip->i_no_addr); 1635 *p++ = 'y';
1883 print_dbg(gi, " type = %u\n", IF2DT(ip->i_inode.i_mode)); 1636 if (test_bit(GLF_LFLUSH, gflags))
1884 print_dbg(gi, " i_flags ="); 1637 *p++ = 'f';
1885 for (x = 0; x < 32; x++) 1638 if (test_bit(GLF_INVALIDATE_IN_PROGRESS, gflags))
1886 if (test_bit(x, &ip->i_flags)) 1639 *p++ = 'i';
1887 print_dbg(gi, " %u", x); 1640 if (test_bit(GLF_REPLY_PENDING, gflags))
1888 print_dbg(gi, " \n"); 1641 *p++ = 'r';
1889 return 0; 1642 *p = 0;
1643 return buf;
1890} 1644}
1891 1645
1892/** 1646/**
1893 * dump_glock - print information about a glock 1647 * __dump_glock - print information about a glock
1648 * @seq: The seq_file struct
1894 * @gl: the glock 1649 * @gl: the glock
1895 * @count: where we are in the buffer 1650 *
1651 * The file format is as follows:
1652 * One line per object, capital letters are used to indicate objects
1653 * G = glock, I = Inode, R = rgrp, H = holder. Glocks are not indented,
1654 * other objects are indented by a single space and follow the glock to
1655 * which they are related. Fields are indicated by lower case letters
1656 * followed by a colon and the field value, except for strings which are in
1657 * [] so that its possible to see if they are composed of spaces for
1658 * example. The field's are n = number (id of the object), f = flags,
1659 * t = type, s = state, r = refcount, e = error, p = pid.
1896 * 1660 *
1897 * Returns: 0 on success, -ENOBUFS when we run out of space 1661 * Returns: 0 on success, -ENOBUFS when we run out of space
1898 */ 1662 */
1899 1663
1900static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl) 1664static int __dump_glock(struct seq_file *seq, const struct gfs2_glock *gl)
1901{ 1665{
1902 struct gfs2_holder *gh; 1666 const struct gfs2_glock_operations *glops = gl->gl_ops;
1903 unsigned int x; 1667 unsigned long long dtime;
1904 int error = -ENOBUFS; 1668 const struct gfs2_holder *gh;
1905 struct task_struct *gl_owner; 1669 char gflags_buf[32];
1670 int error = 0;
1906 1671
1907 spin_lock(&gl->gl_spin); 1672 dtime = jiffies - gl->gl_demote_time;
1673 dtime *= 1000000/HZ; /* demote time in uSec */
1674 if (!test_bit(GLF_DEMOTE, &gl->gl_flags))
1675 dtime = 0;
1676 gfs2_print_dbg(seq, "G: s:%s n:%u/%llu f:%s t:%s d:%s/%llu l:%d a:%d r:%d\n",
1677 state2str(gl->gl_state),
1678 gl->gl_name.ln_type,
1679 (unsigned long long)gl->gl_name.ln_number,
1680 gflags2str(gflags_buf, &gl->gl_flags),
1681 state2str(gl->gl_target),
1682 state2str(gl->gl_demote_state), dtime,
1683 atomic_read(&gl->gl_lvb_count),
1684 atomic_read(&gl->gl_ail_count),
1685 atomic_read(&gl->gl_ref));
1908 1686
1909 print_dbg(gi, "Glock 0x%p (%u, 0x%llx)\n", gl, gl->gl_name.ln_type,
1910 (unsigned long long)gl->gl_name.ln_number);
1911 print_dbg(gi, " gl_flags =");
1912 for (x = 0; x < 32; x++) {
1913 if (test_bit(x, &gl->gl_flags))
1914 print_dbg(gi, " %u", x);
1915 }
1916 if (!test_bit(GLF_LOCK, &gl->gl_flags))
1917 print_dbg(gi, " (unlocked)");
1918 print_dbg(gi, " \n");
1919 print_dbg(gi, " gl_ref = %d\n", atomic_read(&gl->gl_ref));
1920 print_dbg(gi, " gl_state = %u\n", gl->gl_state);
1921 if (gl->gl_owner_pid) {
1922 gl_owner = pid_task(gl->gl_owner_pid, PIDTYPE_PID);
1923 if (gl_owner)
1924 print_dbg(gi, " gl_owner = pid %d (%s)\n",
1925 pid_nr(gl->gl_owner_pid), gl_owner->comm);
1926 else
1927 print_dbg(gi, " gl_owner = %d (ended)\n",
1928 pid_nr(gl->gl_owner_pid));
1929 } else
1930 print_dbg(gi, " gl_owner = -1\n");
1931 print_dbg(gi, " gl_ip = %lu\n", gl->gl_ip);
1932 print_dbg(gi, " req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no");
1933 print_dbg(gi, " lvb_count = %d\n", atomic_read(&gl->gl_lvb_count));
1934 print_dbg(gi, " object = %s\n", (gl->gl_object) ? "yes" : "no");
1935 print_dbg(gi, " reclaim = %s\n",
1936 (list_empty(&gl->gl_reclaim)) ? "no" : "yes");
1937 if (gl->gl_aspace)
1938 print_dbg(gi, " aspace = 0x%p nrpages = %lu\n", gl->gl_aspace,
1939 gl->gl_aspace->i_mapping->nrpages);
1940 else
1941 print_dbg(gi, " aspace = no\n");
1942 print_dbg(gi, " ail = %d\n", atomic_read(&gl->gl_ail_count));
1943 if (gl->gl_req_gh) {
1944 error = dump_holder(gi, "Request", gl->gl_req_gh);
1945 if (error)
1946 goto out;
1947 }
1948 list_for_each_entry(gh, &gl->gl_holders, gh_list) { 1687 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
1949 error = dump_holder(gi, "Holder", gh); 1688 error = dump_holder(seq, gh);
1950 if (error) 1689 if (error)
1951 goto out; 1690 goto out;
1952 } 1691 }
1953 list_for_each_entry(gh, &gl->gl_waiters1, gh_list) { 1692 if (gl->gl_state != LM_ST_UNLOCKED && glops->go_dump)
1954 error = dump_holder(gi, "Waiter1", gh); 1693 error = glops->go_dump(seq, gl);
1955 if (error)
1956 goto out;
1957 }
1958 list_for_each_entry(gh, &gl->gl_waiters3, gh_list) {
1959 error = dump_holder(gi, "Waiter3", gh);
1960 if (error)
1961 goto out;
1962 }
1963 if (test_bit(GLF_DEMOTE, &gl->gl_flags)) {
1964 print_dbg(gi, " Demotion req to state %u (%llu uS ago)\n",
1965 gl->gl_demote_state, (unsigned long long)
1966 (jiffies - gl->gl_demote_time)*(1000000/HZ));
1967 }
1968 if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object) {
1969 if (!test_bit(GLF_LOCK, &gl->gl_flags) &&
1970 list_empty(&gl->gl_holders)) {
1971 error = dump_inode(gi, gl->gl_object);
1972 if (error)
1973 goto out;
1974 } else {
1975 error = -ENOBUFS;
1976 print_dbg(gi, " Inode: busy\n");
1977 }
1978 }
1979
1980 error = 0;
1981
1982out: 1694out:
1983 spin_unlock(&gl->gl_spin);
1984 return error; 1695 return error;
1985} 1696}
1986 1697
1698static int dump_glock(struct seq_file *seq, struct gfs2_glock *gl)
1699{
1700 int ret;
1701 spin_lock(&gl->gl_spin);
1702 ret = __dump_glock(seq, gl);
1703 spin_unlock(&gl->gl_spin);
1704 return ret;
1705}
1706
1987/** 1707/**
1988 * gfs2_dump_lockstate - print out the current lockstate 1708 * gfs2_dump_lockstate - print out the current lockstate
1989 * @sdp: the filesystem 1709 * @sdp: the filesystem
@@ -2086,7 +1806,7 @@ void gfs2_glock_exit(void)
2086module_param(scand_secs, uint, S_IRUGO|S_IWUSR); 1806module_param(scand_secs, uint, S_IRUGO|S_IWUSR);
2087MODULE_PARM_DESC(scand_secs, "The number of seconds between scand runs"); 1807MODULE_PARM_DESC(scand_secs, "The number of seconds between scand runs");
2088 1808
2089static int gfs2_glock_iter_next(struct glock_iter *gi) 1809static int gfs2_glock_iter_next(struct gfs2_glock_iter *gi)
2090{ 1810{
2091 struct gfs2_glock *gl; 1811 struct gfs2_glock *gl;
2092 1812
@@ -2104,7 +1824,7 @@ restart:
2104 gfs2_glock_put(gl); 1824 gfs2_glock_put(gl);
2105 if (gl && gi->gl == NULL) 1825 if (gl && gi->gl == NULL)
2106 gi->hash++; 1826 gi->hash++;
2107 while(gi->gl == NULL) { 1827 while (gi->gl == NULL) {
2108 if (gi->hash >= GFS2_GL_HASH_SIZE) 1828 if (gi->hash >= GFS2_GL_HASH_SIZE)
2109 return 1; 1829 return 1;
2110 read_lock(gl_lock_addr(gi->hash)); 1830 read_lock(gl_lock_addr(gi->hash));
@@ -2122,58 +1842,34 @@ restart:
2122 return 0; 1842 return 0;
2123} 1843}
2124 1844
2125static void gfs2_glock_iter_free(struct glock_iter *gi) 1845static void gfs2_glock_iter_free(struct gfs2_glock_iter *gi)
2126{ 1846{
2127 if (gi->gl) 1847 if (gi->gl)
2128 gfs2_glock_put(gi->gl); 1848 gfs2_glock_put(gi->gl);
2129 kfree(gi);
2130}
2131
2132static struct glock_iter *gfs2_glock_iter_init(struct gfs2_sbd *sdp)
2133{
2134 struct glock_iter *gi;
2135
2136 gi = kmalloc(sizeof (*gi), GFP_KERNEL);
2137 if (!gi)
2138 return NULL;
2139
2140 gi->sdp = sdp;
2141 gi->hash = 0;
2142 gi->seq = NULL;
2143 gi->gl = NULL; 1849 gi->gl = NULL;
2144 memset(gi->string, 0, sizeof(gi->string));
2145
2146 if (gfs2_glock_iter_next(gi)) {
2147 gfs2_glock_iter_free(gi);
2148 return NULL;
2149 }
2150
2151 return gi;
2152} 1850}
2153 1851
2154static void *gfs2_glock_seq_start(struct seq_file *file, loff_t *pos) 1852static void *gfs2_glock_seq_start(struct seq_file *seq, loff_t *pos)
2155{ 1853{
2156 struct glock_iter *gi; 1854 struct gfs2_glock_iter *gi = seq->private;
2157 loff_t n = *pos; 1855 loff_t n = *pos;
2158 1856
2159 gi = gfs2_glock_iter_init(file->private); 1857 gi->hash = 0;
2160 if (!gi)
2161 return NULL;
2162 1858
2163 while(n--) { 1859 do {
2164 if (gfs2_glock_iter_next(gi)) { 1860 if (gfs2_glock_iter_next(gi)) {
2165 gfs2_glock_iter_free(gi); 1861 gfs2_glock_iter_free(gi);
2166 return NULL; 1862 return NULL;
2167 } 1863 }
2168 } 1864 } while (n--);
2169 1865
2170 return gi; 1866 return gi->gl;
2171} 1867}
2172 1868
2173static void *gfs2_glock_seq_next(struct seq_file *file, void *iter_ptr, 1869static void *gfs2_glock_seq_next(struct seq_file *seq, void *iter_ptr,
2174 loff_t *pos) 1870 loff_t *pos)
2175{ 1871{
2176 struct glock_iter *gi = iter_ptr; 1872 struct gfs2_glock_iter *gi = seq->private;
2177 1873
2178 (*pos)++; 1874 (*pos)++;
2179 1875
@@ -2182,24 +1878,18 @@ static void *gfs2_glock_seq_next(struct seq_file *file, void *iter_ptr,
2182 return NULL; 1878 return NULL;
2183 } 1879 }
2184 1880
2185 return gi; 1881 return gi->gl;
2186} 1882}
2187 1883
2188static void gfs2_glock_seq_stop(struct seq_file *file, void *iter_ptr) 1884static void gfs2_glock_seq_stop(struct seq_file *seq, void *iter_ptr)
2189{ 1885{
2190 struct glock_iter *gi = iter_ptr; 1886 struct gfs2_glock_iter *gi = seq->private;
2191 if (gi) 1887 gfs2_glock_iter_free(gi);
2192 gfs2_glock_iter_free(gi);
2193} 1888}
2194 1889
2195static int gfs2_glock_seq_show(struct seq_file *file, void *iter_ptr) 1890static int gfs2_glock_seq_show(struct seq_file *seq, void *iter_ptr)
2196{ 1891{
2197 struct glock_iter *gi = iter_ptr; 1892 return dump_glock(seq, iter_ptr);
2198
2199 gi->seq = file;
2200 dump_glock(gi, gi->gl);
2201
2202 return 0;
2203} 1893}
2204 1894
2205static const struct seq_operations gfs2_glock_seq_ops = { 1895static const struct seq_operations gfs2_glock_seq_ops = {
@@ -2211,17 +1901,14 @@ static const struct seq_operations gfs2_glock_seq_ops = {
2211 1901
2212static int gfs2_debugfs_open(struct inode *inode, struct file *file) 1902static int gfs2_debugfs_open(struct inode *inode, struct file *file)
2213{ 1903{
2214 struct seq_file *seq; 1904 int ret = seq_open_private(file, &gfs2_glock_seq_ops,
2215 int ret; 1905 sizeof(struct gfs2_glock_iter));
2216 1906 if (ret == 0) {
2217 ret = seq_open(file, &gfs2_glock_seq_ops); 1907 struct seq_file *seq = file->private_data;
2218 if (ret) 1908 struct gfs2_glock_iter *gi = seq->private;
2219 return ret; 1909 gi->sdp = inode->i_private;
2220 1910 }
2221 seq = file->private_data; 1911 return ret;
2222 seq->private = inode->i_private;
2223
2224 return 0;
2225} 1912}
2226 1913
2227static const struct file_operations gfs2_debug_fops = { 1914static const struct file_operations gfs2_debug_fops = {
@@ -2229,7 +1916,7 @@ static const struct file_operations gfs2_debug_fops = {
2229 .open = gfs2_debugfs_open, 1916 .open = gfs2_debugfs_open,
2230 .read = seq_read, 1917 .read = seq_read,
2231 .llseek = seq_lseek, 1918 .llseek = seq_lseek,
2232 .release = seq_release 1919 .release = seq_release_private,
2233}; 1920};
2234 1921
2235int gfs2_create_debugfs_file(struct gfs2_sbd *sdp) 1922int gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index cdad3e6f815..971d92af70f 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -26,11 +26,8 @@
26#define GL_SKIP 0x00000100 26#define GL_SKIP 0x00000100
27#define GL_ATIME 0x00000200 27#define GL_ATIME 0x00000200
28#define GL_NOCACHE 0x00000400 28#define GL_NOCACHE 0x00000400
29#define GL_FLOCK 0x00000800
30#define GL_NOCANCEL 0x00001000
31 29
32#define GLR_TRYFAILED 13 30#define GLR_TRYFAILED 13
33#define GLR_CANCELED 14
34 31
35static inline struct gfs2_holder *gfs2_glock_is_locked_by_me(struct gfs2_glock *gl) 32static inline struct gfs2_holder *gfs2_glock_is_locked_by_me(struct gfs2_glock *gl)
36{ 33{
@@ -41,6 +38,8 @@ static inline struct gfs2_holder *gfs2_glock_is_locked_by_me(struct gfs2_glock *
41 spin_lock(&gl->gl_spin); 38 spin_lock(&gl->gl_spin);
42 pid = task_pid(current); 39 pid = task_pid(current);
43 list_for_each_entry(gh, &gl->gl_holders, gh_list) { 40 list_for_each_entry(gh, &gl->gl_holders, gh_list) {
41 if (!test_bit(HIF_HOLDER, &gh->gh_iflags))
42 break;
44 if (gh->gh_owner_pid == pid) 43 if (gh->gh_owner_pid == pid)
45 goto out; 44 goto out;
46 } 45 }
@@ -70,7 +69,7 @@ static inline int gfs2_glock_is_blocking(struct gfs2_glock *gl)
70{ 69{
71 int ret; 70 int ret;
72 spin_lock(&gl->gl_spin); 71 spin_lock(&gl->gl_spin);
73 ret = test_bit(GLF_DEMOTE, &gl->gl_flags) || !list_empty(&gl->gl_waiters3); 72 ret = test_bit(GLF_DEMOTE, &gl->gl_flags);
74 spin_unlock(&gl->gl_spin); 73 spin_unlock(&gl->gl_spin);
75 return ret; 74 return ret;
76} 75}
@@ -98,6 +97,7 @@ int gfs2_glock_nq_num(struct gfs2_sbd *sdp,
98int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); 97int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs);
99void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); 98void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs);
100void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); 99void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);
100void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...);
101 101
102/** 102/**
103 * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock 103 * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock
@@ -130,10 +130,9 @@ int gfs2_lvb_hold(struct gfs2_glock *gl);
130void gfs2_lvb_unhold(struct gfs2_glock *gl); 130void gfs2_lvb_unhold(struct gfs2_glock *gl);
131 131
132void gfs2_glock_cb(void *cb_data, unsigned int type, void *data); 132void gfs2_glock_cb(void *cb_data, unsigned int type, void *data);
133
134void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl); 133void gfs2_glock_schedule_for_reclaim(struct gfs2_glock *gl);
135void gfs2_reclaim_glock(struct gfs2_sbd *sdp); 134void gfs2_reclaim_glock(struct gfs2_sbd *sdp);
136void gfs2_gl_hash_clear(struct gfs2_sbd *sdp, int wait); 135void gfs2_gl_hash_clear(struct gfs2_sbd *sdp);
137 136
138int __init gfs2_glock_init(void); 137int __init gfs2_glock_init(void);
139void gfs2_glock_exit(void); 138void gfs2_glock_exit(void);
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 07d84d16cda..c6c318c2a0f 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -13,6 +13,7 @@
13#include <linux/buffer_head.h> 13#include <linux/buffer_head.h>
14#include <linux/gfs2_ondisk.h> 14#include <linux/gfs2_ondisk.h>
15#include <linux/lm_interface.h> 15#include <linux/lm_interface.h>
16#include <linux/bio.h>
16 17
17#include "gfs2.h" 18#include "gfs2.h"
18#include "incore.h" 19#include "incore.h"
@@ -172,26 +173,6 @@ static void inode_go_sync(struct gfs2_glock *gl)
172} 173}
173 174
174/** 175/**
175 * inode_go_xmote_bh - After promoting/demoting a glock
176 * @gl: the glock
177 *
178 */
179
180static void inode_go_xmote_bh(struct gfs2_glock *gl)
181{
182 struct gfs2_holder *gh = gl->gl_req_gh;
183 struct buffer_head *bh;
184 int error;
185
186 if (gl->gl_state != LM_ST_UNLOCKED &&
187 (!gh || !(gh->gh_flags & GL_SKIP))) {
188 error = gfs2_meta_read(gl, gl->gl_name.ln_number, 0, &bh);
189 if (!error)
190 brelse(bh);
191 }
192}
193
194/**
195 * inode_go_inval - prepare a inode glock to be released 176 * inode_go_inval - prepare a inode glock to be released
196 * @gl: the glock 177 * @gl: the glock
197 * @flags: 178 * @flags:
@@ -267,6 +248,26 @@ static int inode_go_lock(struct gfs2_holder *gh)
267} 248}
268 249
269/** 250/**
251 * inode_go_dump - print information about an inode
252 * @seq: The iterator
253 * @ip: the inode
254 *
255 * Returns: 0 on success, -ENOBUFS when we run out of space
256 */
257
258static int inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
259{
260 const struct gfs2_inode *ip = gl->gl_object;
261 if (ip == NULL)
262 return 0;
263 gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%08lx\n",
264 (unsigned long long)ip->i_no_formal_ino,
265 (unsigned long long)ip->i_no_addr,
266 IF2DT(ip->i_inode.i_mode), ip->i_flags);
267 return 0;
268}
269
270/**
270 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock 271 * rgrp_go_demote_ok - Check to see if it's ok to unlock a RG's glock
271 * @gl: the glock 272 * @gl: the glock
272 * 273 *
@@ -306,6 +307,22 @@ static void rgrp_go_unlock(struct gfs2_holder *gh)
306} 307}
307 308
308/** 309/**
310 * rgrp_go_dump - print out an rgrp
311 * @seq: The iterator
312 * @gl: The glock in question
313 *
314 */
315
316static int rgrp_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
317{
318 const struct gfs2_rgrpd *rgd = gl->gl_object;
319 if (rgd == NULL)
320 return 0;
321 gfs2_print_dbg(seq, " R: n:%llu\n", (unsigned long long)rgd->rd_addr);
322 return 0;
323}
324
325/**
309 * trans_go_sync - promote/demote the transaction glock 326 * trans_go_sync - promote/demote the transaction glock
310 * @gl: the glock 327 * @gl: the glock
311 * @state: the requested state 328 * @state: the requested state
@@ -330,7 +347,7 @@ static void trans_go_sync(struct gfs2_glock *gl)
330 * 347 *
331 */ 348 */
332 349
333static void trans_go_xmote_bh(struct gfs2_glock *gl) 350static int trans_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
334{ 351{
335 struct gfs2_sbd *sdp = gl->gl_sbd; 352 struct gfs2_sbd *sdp = gl->gl_sbd;
336 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); 353 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
@@ -338,8 +355,7 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
338 struct gfs2_log_header_host head; 355 struct gfs2_log_header_host head;
339 int error; 356 int error;
340 357
341 if (gl->gl_state != LM_ST_UNLOCKED && 358 if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
342 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
343 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA); 359 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
344 360
345 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 361 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
@@ -354,6 +370,7 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
354 gfs2_log_pointers_init(sdp, head.lh_blkno); 370 gfs2_log_pointers_init(sdp, head.lh_blkno);
355 } 371 }
356 } 372 }
373 return 0;
357} 374}
358 375
359/** 376/**
@@ -375,12 +392,12 @@ const struct gfs2_glock_operations gfs2_meta_glops = {
375 392
376const struct gfs2_glock_operations gfs2_inode_glops = { 393const struct gfs2_glock_operations gfs2_inode_glops = {
377 .go_xmote_th = inode_go_sync, 394 .go_xmote_th = inode_go_sync,
378 .go_xmote_bh = inode_go_xmote_bh,
379 .go_inval = inode_go_inval, 395 .go_inval = inode_go_inval,
380 .go_demote_ok = inode_go_demote_ok, 396 .go_demote_ok = inode_go_demote_ok,
381 .go_lock = inode_go_lock, 397 .go_lock = inode_go_lock,
398 .go_dump = inode_go_dump,
382 .go_type = LM_TYPE_INODE, 399 .go_type = LM_TYPE_INODE,
383 .go_min_hold_time = HZ / 10, 400 .go_min_hold_time = HZ / 5,
384}; 401};
385 402
386const struct gfs2_glock_operations gfs2_rgrp_glops = { 403const struct gfs2_glock_operations gfs2_rgrp_glops = {
@@ -389,8 +406,9 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
389 .go_demote_ok = rgrp_go_demote_ok, 406 .go_demote_ok = rgrp_go_demote_ok,
390 .go_lock = rgrp_go_lock, 407 .go_lock = rgrp_go_lock,
391 .go_unlock = rgrp_go_unlock, 408 .go_unlock = rgrp_go_unlock,
409 .go_dump = rgrp_go_dump,
392 .go_type = LM_TYPE_RGRP, 410 .go_type = LM_TYPE_RGRP,
393 .go_min_hold_time = HZ / 10, 411 .go_min_hold_time = HZ / 5,
394}; 412};
395 413
396const struct gfs2_glock_operations gfs2_trans_glops = { 414const struct gfs2_glock_operations gfs2_trans_glops = {
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index eabe5eac41d..448697a5c46 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -77,7 +77,6 @@ struct gfs2_rgrp_host {
77struct gfs2_rgrpd { 77struct gfs2_rgrpd {
78 struct list_head rd_list; /* Link with superblock */ 78 struct list_head rd_list; /* Link with superblock */
79 struct list_head rd_list_mru; 79 struct list_head rd_list_mru;
80 struct list_head rd_recent; /* Recently used rgrps */
81 struct gfs2_glock *rd_gl; /* Glock for this rgrp */ 80 struct gfs2_glock *rd_gl; /* Glock for this rgrp */
82 u64 rd_addr; /* grp block disk address */ 81 u64 rd_addr; /* grp block disk address */
83 u64 rd_data0; /* first data location */ 82 u64 rd_data0; /* first data location */
@@ -128,20 +127,20 @@ struct gfs2_bufdata {
128 127
129struct gfs2_glock_operations { 128struct gfs2_glock_operations {
130 void (*go_xmote_th) (struct gfs2_glock *gl); 129 void (*go_xmote_th) (struct gfs2_glock *gl);
131 void (*go_xmote_bh) (struct gfs2_glock *gl); 130 int (*go_xmote_bh) (struct gfs2_glock *gl, struct gfs2_holder *gh);
132 void (*go_inval) (struct gfs2_glock *gl, int flags); 131 void (*go_inval) (struct gfs2_glock *gl, int flags);
133 int (*go_demote_ok) (struct gfs2_glock *gl); 132 int (*go_demote_ok) (struct gfs2_glock *gl);
134 int (*go_lock) (struct gfs2_holder *gh); 133 int (*go_lock) (struct gfs2_holder *gh);
135 void (*go_unlock) (struct gfs2_holder *gh); 134 void (*go_unlock) (struct gfs2_holder *gh);
135 int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
136 const int go_type; 136 const int go_type;
137 const unsigned long go_min_hold_time; 137 const unsigned long go_min_hold_time;
138}; 138};
139 139
140enum { 140enum {
141 /* States */ 141 /* States */
142 HIF_HOLDER = 6, 142 HIF_HOLDER = 6, /* Set for gh that "holds" the glock */
143 HIF_FIRST = 7, 143 HIF_FIRST = 7,
144 HIF_ABORTED = 9,
145 HIF_WAIT = 10, 144 HIF_WAIT = 10,
146}; 145};
147 146
@@ -154,20 +153,20 @@ struct gfs2_holder {
154 unsigned gh_flags; 153 unsigned gh_flags;
155 154
156 int gh_error; 155 int gh_error;
157 unsigned long gh_iflags; 156 unsigned long gh_iflags; /* HIF_... */
158 unsigned long gh_ip; 157 unsigned long gh_ip;
159}; 158};
160 159
161enum { 160enum {
162 GLF_LOCK = 1, 161 GLF_LOCK = 1,
163 GLF_STICKY = 2, 162 GLF_STICKY = 2,
164 GLF_DEMOTE = 3, 163 GLF_DEMOTE = 3,
165 GLF_PENDING_DEMOTE = 4, 164 GLF_PENDING_DEMOTE = 4,
166 GLF_DIRTY = 5, 165 GLF_DEMOTE_IN_PROGRESS = 5,
167 GLF_DEMOTE_IN_PROGRESS = 6, 166 GLF_DIRTY = 6,
168 GLF_LFLUSH = 7, 167 GLF_LFLUSH = 7,
169 GLF_WAITERS2 = 8, 168 GLF_INVALIDATE_IN_PROGRESS = 8,
170 GLF_CONV_DEADLK = 9, 169 GLF_REPLY_PENDING = 9,
171}; 170};
172 171
173struct gfs2_glock { 172struct gfs2_glock {
@@ -179,19 +178,14 @@ struct gfs2_glock {
179 spinlock_t gl_spin; 178 spinlock_t gl_spin;
180 179
181 unsigned int gl_state; 180 unsigned int gl_state;
181 unsigned int gl_target;
182 unsigned int gl_reply;
182 unsigned int gl_hash; 183 unsigned int gl_hash;
183 unsigned int gl_demote_state; /* state requested by remote node */ 184 unsigned int gl_demote_state; /* state requested by remote node */
184 unsigned long gl_demote_time; /* time of first demote request */ 185 unsigned long gl_demote_time; /* time of first demote request */
185 struct pid *gl_owner_pid;
186 unsigned long gl_ip;
187 struct list_head gl_holders; 186 struct list_head gl_holders;
188 struct list_head gl_waiters1; /* HIF_MUTEX */
189 struct list_head gl_waiters3; /* HIF_PROMOTE */
190 187
191 const struct gfs2_glock_operations *gl_ops; 188 const struct gfs2_glock_operations *gl_ops;
192
193 struct gfs2_holder *gl_req_gh;
194
195 void *gl_lock; 189 void *gl_lock;
196 char *gl_lvb; 190 char *gl_lvb;
197 atomic_t gl_lvb_count; 191 atomic_t gl_lvb_count;
@@ -427,7 +421,6 @@ struct gfs2_tune {
427 unsigned int gt_quota_quantum; /* Secs between syncs to quota file */ 421 unsigned int gt_quota_quantum; /* Secs between syncs to quota file */
428 unsigned int gt_atime_quantum; /* Min secs between atime updates */ 422 unsigned int gt_atime_quantum; /* Min secs between atime updates */
429 unsigned int gt_new_files_jdata; 423 unsigned int gt_new_files_jdata;
430 unsigned int gt_new_files_directio;
431 unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */ 424 unsigned int gt_max_readahead; /* Max bytes to read-ahead from disk */
432 unsigned int gt_stall_secs; /* Detects trouble! */ 425 unsigned int gt_stall_secs; /* Detects trouble! */
433 unsigned int gt_complain_secs; 426 unsigned int gt_complain_secs;
@@ -534,7 +527,6 @@ struct gfs2_sbd {
534 struct mutex sd_rindex_mutex; 527 struct mutex sd_rindex_mutex;
535 struct list_head sd_rindex_list; 528 struct list_head sd_rindex_list;
536 struct list_head sd_rindex_mru_list; 529 struct list_head sd_rindex_mru_list;
537 struct list_head sd_rindex_recent_list;
538 struct gfs2_rgrpd *sd_rindex_forward; 530 struct gfs2_rgrpd *sd_rindex_forward;
539 unsigned int sd_rgrps; 531 unsigned int sd_rgrps;
540 532
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 09453d057e4..6da0ab355b8 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -504,7 +504,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
504 } 504 }
505 505
506 if (!is_root) { 506 if (!is_root) {
507 error = permission(dir, MAY_EXEC, NULL); 507 error = gfs2_permission(dir, MAY_EXEC);
508 if (error) 508 if (error)
509 goto out; 509 goto out;
510 } 510 }
@@ -667,7 +667,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
667{ 667{
668 int error; 668 int error;
669 669
670 error = permission(&dip->i_inode, MAY_WRITE | MAY_EXEC, NULL); 670 error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
671 if (error) 671 if (error)
672 return error; 672 return error;
673 673
@@ -789,13 +789,8 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
789 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) || 789 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) ||
790 gfs2_tune_get(sdp, gt_new_files_jdata)) 790 gfs2_tune_get(sdp, gt_new_files_jdata))
791 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA); 791 di->di_flags |= cpu_to_be32(GFS2_DIF_JDATA);
792 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_DIRECTIO) ||
793 gfs2_tune_get(sdp, gt_new_files_directio))
794 di->di_flags |= cpu_to_be32(GFS2_DIF_DIRECTIO);
795 } else if (S_ISDIR(mode)) { 792 } else if (S_ISDIR(mode)) {
796 di->di_flags |= cpu_to_be32(dip->i_di.di_flags & 793 di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
797 GFS2_DIF_INHERIT_DIRECTIO);
798 di->di_flags |= cpu_to_be32(dip->i_di.di_flags &
799 GFS2_DIF_INHERIT_JDATA); 794 GFS2_DIF_INHERIT_JDATA);
800 } 795 }
801 796
@@ -1134,7 +1129,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
1134 if (IS_APPEND(&dip->i_inode)) 1129 if (IS_APPEND(&dip->i_inode))
1135 return -EPERM; 1130 return -EPERM;
1136 1131
1137 error = permission(&dip->i_inode, MAY_WRITE | MAY_EXEC, NULL); 1132 error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
1138 if (error) 1133 if (error)
1139 return error; 1134 return error;
1140 1135
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 580da454b38..6074c2506f7 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -72,7 +72,6 @@ static inline void gfs2_inum_out(const struct gfs2_inode *ip,
72} 72}
73 73
74 74
75void gfs2_inode_attr_in(struct gfs2_inode *ip);
76void gfs2_set_iop(struct inode *inode); 75void gfs2_set_iop(struct inode *inode);
77struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 76struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
78 u64 no_addr, u64 no_formal_ino, 77 u64 no_addr, u64 no_formal_ino,
@@ -91,6 +90,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
91 struct gfs2_inode *ip); 90 struct gfs2_inode *ip);
92int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, 91int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
93 const struct gfs2_inode *ip); 92 const struct gfs2_inode *ip);
93int gfs2_permission(struct inode *inode, int mask);
94int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to); 94int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to);
95int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); 95int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
96int gfs2_glock_nq_atime(struct gfs2_holder *gh); 96int gfs2_glock_nq_atime(struct gfs2_holder *gh);
diff --git a/fs/gfs2/locking.c b/fs/gfs2/locking.c
index 663fee72878..523243a13a2 100644
--- a/fs/gfs2/locking.c
+++ b/fs/gfs2/locking.c
@@ -23,12 +23,54 @@ struct lmh_wrapper {
23 const struct lm_lockops *lw_ops; 23 const struct lm_lockops *lw_ops;
24}; 24};
25 25
26static int nolock_mount(char *table_name, char *host_data,
27 lm_callback_t cb, void *cb_data,
28 unsigned int min_lvb_size, int flags,
29 struct lm_lockstruct *lockstruct,
30 struct kobject *fskobj);
31
26/* List of registered low-level locking protocols. A file system selects one 32/* List of registered low-level locking protocols. A file system selects one
27 of them by name at mount time, e.g. lock_nolock, lock_dlm. */ 33 of them by name at mount time, e.g. lock_nolock, lock_dlm. */
28 34
35static const struct lm_lockops nolock_ops = {
36 .lm_proto_name = "lock_nolock",
37 .lm_mount = nolock_mount,
38};
39
40static struct lmh_wrapper nolock_proto = {
41 .lw_list = LIST_HEAD_INIT(nolock_proto.lw_list),
42 .lw_ops = &nolock_ops,
43};
44
29static LIST_HEAD(lmh_list); 45static LIST_HEAD(lmh_list);
30static DEFINE_MUTEX(lmh_lock); 46static DEFINE_MUTEX(lmh_lock);
31 47
48static int nolock_mount(char *table_name, char *host_data,
49 lm_callback_t cb, void *cb_data,
50 unsigned int min_lvb_size, int flags,
51 struct lm_lockstruct *lockstruct,
52 struct kobject *fskobj)
53{
54 char *c;
55 unsigned int jid;
56
57 c = strstr(host_data, "jid=");
58 if (!c)
59 jid = 0;
60 else {
61 c += 4;
62 sscanf(c, "%u", &jid);
63 }
64
65 lockstruct->ls_jid = jid;
66 lockstruct->ls_first = 1;
67 lockstruct->ls_lvb_size = min_lvb_size;
68 lockstruct->ls_ops = &nolock_ops;
69 lockstruct->ls_flags = LM_LSFLAG_LOCAL;
70
71 return 0;
72}
73
32/** 74/**
33 * gfs2_register_lockproto - Register a low-level locking protocol 75 * gfs2_register_lockproto - Register a low-level locking protocol
34 * @proto: the protocol definition 76 * @proto: the protocol definition
@@ -116,9 +158,13 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
116 int try = 0; 158 int try = 0;
117 int error, found; 159 int error, found;
118 160
161
119retry: 162retry:
120 mutex_lock(&lmh_lock); 163 mutex_lock(&lmh_lock);
121 164
165 if (list_empty(&nolock_proto.lw_list))
166 list_add(&nolock_proto.lw_list, &lmh_list);
167
122 found = 0; 168 found = 0;
123 list_for_each_entry(lw, &lmh_list, lw_list) { 169 list_for_each_entry(lw, &lmh_list, lw_list) {
124 if (!strcmp(lw->lw_ops->lm_proto_name, proto_name)) { 170 if (!strcmp(lw->lw_ops->lm_proto_name, proto_name)) {
@@ -139,7 +185,8 @@ retry:
139 goto out; 185 goto out;
140 } 186 }
141 187
142 if (!try_module_get(lw->lw_ops->lm_owner)) { 188 if (lw->lw_ops->lm_owner &&
189 !try_module_get(lw->lw_ops->lm_owner)) {
143 try = 0; 190 try = 0;
144 mutex_unlock(&lmh_lock); 191 mutex_unlock(&lmh_lock);
145 msleep(1000); 192 msleep(1000);
@@ -158,7 +205,8 @@ out:
158void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct) 205void gfs2_unmount_lockproto(struct lm_lockstruct *lockstruct)
159{ 206{
160 mutex_lock(&lmh_lock); 207 mutex_lock(&lmh_lock);
161 lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace); 208 if (lockstruct->ls_ops->lm_unmount)
209 lockstruct->ls_ops->lm_unmount(lockstruct->ls_lockspace);
162 if (lockstruct->ls_ops->lm_owner) 210 if (lockstruct->ls_ops->lm_owner)
163 module_put(lockstruct->ls_ops->lm_owner); 211 module_put(lockstruct->ls_ops->lm_owner);
164 mutex_unlock(&lmh_lock); 212 mutex_unlock(&lmh_lock);
diff --git a/fs/gfs2/locking/dlm/lock.c b/fs/gfs2/locking/dlm/lock.c
index cf7ea8abec8..2482c904750 100644
--- a/fs/gfs2/locking/dlm/lock.c
+++ b/fs/gfs2/locking/dlm/lock.c
@@ -11,46 +11,60 @@
11 11
12static char junk_lvb[GDLM_LVB_SIZE]; 12static char junk_lvb[GDLM_LVB_SIZE];
13 13
14static void queue_complete(struct gdlm_lock *lp) 14
15/* convert dlm lock-mode to gfs lock-state */
16
17static s16 gdlm_make_lmstate(s16 dlmmode)
15{ 18{
16 struct gdlm_ls *ls = lp->ls; 19 switch (dlmmode) {
20 case DLM_LOCK_IV:
21 case DLM_LOCK_NL:
22 return LM_ST_UNLOCKED;
23 case DLM_LOCK_EX:
24 return LM_ST_EXCLUSIVE;
25 case DLM_LOCK_CW:
26 return LM_ST_DEFERRED;
27 case DLM_LOCK_PR:
28 return LM_ST_SHARED;
29 }
30 gdlm_assert(0, "unknown DLM mode %d", dlmmode);
31 return -1;
32}
17 33
18 clear_bit(LFL_ACTIVE, &lp->flags); 34/* A lock placed on this queue is re-submitted to DLM as soon as the lock_dlm
35 thread gets to it. */
36
37static void queue_submit(struct gdlm_lock *lp)
38{
39 struct gdlm_ls *ls = lp->ls;
19 40
20 spin_lock(&ls->async_lock); 41 spin_lock(&ls->async_lock);
21 list_add_tail(&lp->clist, &ls->complete); 42 list_add_tail(&lp->delay_list, &ls->submit);
22 spin_unlock(&ls->async_lock); 43 spin_unlock(&ls->async_lock);
23 wake_up(&ls->thread_wait); 44 wake_up(&ls->thread_wait);
24} 45}
25 46
26static inline void gdlm_ast(void *astarg) 47static void wake_up_ast(struct gdlm_lock *lp)
27{ 48{
28 queue_complete(astarg); 49 clear_bit(LFL_AST_WAIT, &lp->flags);
50 smp_mb__after_clear_bit();
51 wake_up_bit(&lp->flags, LFL_AST_WAIT);
29} 52}
30 53
31static inline void gdlm_bast(void *astarg, int mode) 54static void gdlm_delete_lp(struct gdlm_lock *lp)
32{ 55{
33 struct gdlm_lock *lp = astarg;
34 struct gdlm_ls *ls = lp->ls; 56 struct gdlm_ls *ls = lp->ls;
35 57
36 if (!mode) {
37 printk(KERN_INFO "lock_dlm: bast mode zero %x,%llx\n",
38 lp->lockname.ln_type,
39 (unsigned long long)lp->lockname.ln_number);
40 return;
41 }
42
43 spin_lock(&ls->async_lock); 58 spin_lock(&ls->async_lock);
44 if (!lp->bast_mode) { 59 if (!list_empty(&lp->delay_list))
45 list_add_tail(&lp->blist, &ls->blocking); 60 list_del_init(&lp->delay_list);
46 lp->bast_mode = mode; 61 ls->all_locks_count--;
47 } else if (lp->bast_mode < mode)
48 lp->bast_mode = mode;
49 spin_unlock(&ls->async_lock); 62 spin_unlock(&ls->async_lock);
50 wake_up(&ls->thread_wait); 63
64 kfree(lp);
51} 65}
52 66
53void gdlm_queue_delayed(struct gdlm_lock *lp) 67static void gdlm_queue_delayed(struct gdlm_lock *lp)
54{ 68{
55 struct gdlm_ls *ls = lp->ls; 69 struct gdlm_ls *ls = lp->ls;
56 70
@@ -59,6 +73,236 @@ void gdlm_queue_delayed(struct gdlm_lock *lp)
59 spin_unlock(&ls->async_lock); 73 spin_unlock(&ls->async_lock);
60} 74}
61 75
76static void process_complete(struct gdlm_lock *lp)
77{
78 struct gdlm_ls *ls = lp->ls;
79 struct lm_async_cb acb;
80
81 memset(&acb, 0, sizeof(acb));
82
83 if (lp->lksb.sb_status == -DLM_ECANCEL) {
84 log_info("complete dlm cancel %x,%llx flags %lx",
85 lp->lockname.ln_type,
86 (unsigned long long)lp->lockname.ln_number,
87 lp->flags);
88
89 lp->req = lp->cur;
90 acb.lc_ret |= LM_OUT_CANCELED;
91 if (lp->cur == DLM_LOCK_IV)
92 lp->lksb.sb_lkid = 0;
93 goto out;
94 }
95
96 if (test_and_clear_bit(LFL_DLM_UNLOCK, &lp->flags)) {
97 if (lp->lksb.sb_status != -DLM_EUNLOCK) {
98 log_info("unlock sb_status %d %x,%llx flags %lx",
99 lp->lksb.sb_status, lp->lockname.ln_type,
100 (unsigned long long)lp->lockname.ln_number,
101 lp->flags);
102 return;
103 }
104
105 lp->cur = DLM_LOCK_IV;
106 lp->req = DLM_LOCK_IV;
107 lp->lksb.sb_lkid = 0;
108
109 if (test_and_clear_bit(LFL_UNLOCK_DELETE, &lp->flags)) {
110 gdlm_delete_lp(lp);
111 return;
112 }
113 goto out;
114 }
115
116 if (lp->lksb.sb_flags & DLM_SBF_VALNOTVALID)
117 memset(lp->lksb.sb_lvbptr, 0, GDLM_LVB_SIZE);
118
119 if (lp->lksb.sb_flags & DLM_SBF_ALTMODE) {
120 if (lp->req == DLM_LOCK_PR)
121 lp->req = DLM_LOCK_CW;
122 else if (lp->req == DLM_LOCK_CW)
123 lp->req = DLM_LOCK_PR;
124 }
125
126 /*
127 * A canceled lock request. The lock was just taken off the delayed
128 * list and was never even submitted to dlm.
129 */
130
131 if (test_and_clear_bit(LFL_CANCEL, &lp->flags)) {
132 log_info("complete internal cancel %x,%llx",
133 lp->lockname.ln_type,
134 (unsigned long long)lp->lockname.ln_number);
135 lp->req = lp->cur;
136 acb.lc_ret |= LM_OUT_CANCELED;
137 goto out;
138 }
139
140 /*
141 * An error occured.
142 */
143
144 if (lp->lksb.sb_status) {
145 /* a "normal" error */
146 if ((lp->lksb.sb_status == -EAGAIN) &&
147 (lp->lkf & DLM_LKF_NOQUEUE)) {
148 lp->req = lp->cur;
149 if (lp->cur == DLM_LOCK_IV)
150 lp->lksb.sb_lkid = 0;
151 goto out;
152 }
153
154 /* this could only happen with cancels I think */
155 log_info("ast sb_status %d %x,%llx flags %lx",
156 lp->lksb.sb_status, lp->lockname.ln_type,
157 (unsigned long long)lp->lockname.ln_number,
158 lp->flags);
159 return;
160 }
161
162 /*
163 * This is an AST for an EX->EX conversion for sync_lvb from GFS.
164 */
165
166 if (test_and_clear_bit(LFL_SYNC_LVB, &lp->flags)) {
167 wake_up_ast(lp);
168 return;
169 }
170
171 /*
172 * A lock has been demoted to NL because it initially completed during
173 * BLOCK_LOCKS. Now it must be requested in the originally requested
174 * mode.
175 */
176
177 if (test_and_clear_bit(LFL_REREQUEST, &lp->flags)) {
178 gdlm_assert(lp->req == DLM_LOCK_NL, "%x,%llx",
179 lp->lockname.ln_type,
180 (unsigned long long)lp->lockname.ln_number);
181 gdlm_assert(lp->prev_req > DLM_LOCK_NL, "%x,%llx",
182 lp->lockname.ln_type,
183 (unsigned long long)lp->lockname.ln_number);
184
185 lp->cur = DLM_LOCK_NL;
186 lp->req = lp->prev_req;
187 lp->prev_req = DLM_LOCK_IV;
188 lp->lkf &= ~DLM_LKF_CONVDEADLK;
189
190 set_bit(LFL_NOCACHE, &lp->flags);
191
192 if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) &&
193 !test_bit(LFL_NOBLOCK, &lp->flags))
194 gdlm_queue_delayed(lp);
195 else
196 queue_submit(lp);
197 return;
198 }
199
200 /*
201 * A request is granted during dlm recovery. It may be granted
202 * because the locks of a failed node were cleared. In that case,
203 * there may be inconsistent data beneath this lock and we must wait
204 * for recovery to complete to use it. When gfs recovery is done this
205 * granted lock will be converted to NL and then reacquired in this
206 * granted state.
207 */
208
209 if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) &&
210 !test_bit(LFL_NOBLOCK, &lp->flags) &&
211 lp->req != DLM_LOCK_NL) {
212
213 lp->cur = lp->req;
214 lp->prev_req = lp->req;
215 lp->req = DLM_LOCK_NL;
216 lp->lkf |= DLM_LKF_CONVERT;
217 lp->lkf &= ~DLM_LKF_CONVDEADLK;
218
219 log_debug("rereq %x,%llx id %x %d,%d",
220 lp->lockname.ln_type,
221 (unsigned long long)lp->lockname.ln_number,
222 lp->lksb.sb_lkid, lp->cur, lp->req);
223
224 set_bit(LFL_REREQUEST, &lp->flags);
225 queue_submit(lp);
226 return;
227 }
228
229 /*
230 * DLM demoted the lock to NL before it was granted so GFS must be
231 * told it cannot cache data for this lock.
232 */
233
234 if (lp->lksb.sb_flags & DLM_SBF_DEMOTED)
235 set_bit(LFL_NOCACHE, &lp->flags);
236
237out:
238 /*
239 * This is an internal lock_dlm lock
240 */
241
242 if (test_bit(LFL_INLOCK, &lp->flags)) {
243 clear_bit(LFL_NOBLOCK, &lp->flags);
244 lp->cur = lp->req;
245 wake_up_ast(lp);
246 return;
247 }
248
249 /*
250 * Normal completion of a lock request. Tell GFS it now has the lock.
251 */
252
253 clear_bit(LFL_NOBLOCK, &lp->flags);
254 lp->cur = lp->req;
255
256 acb.lc_name = lp->lockname;
257 acb.lc_ret |= gdlm_make_lmstate(lp->cur);
258
259 ls->fscb(ls->sdp, LM_CB_ASYNC, &acb);
260}
261
262static void gdlm_ast(void *astarg)
263{
264 struct gdlm_lock *lp = astarg;
265 clear_bit(LFL_ACTIVE, &lp->flags);
266 process_complete(lp);
267}
268
269static void process_blocking(struct gdlm_lock *lp, int bast_mode)
270{
271 struct gdlm_ls *ls = lp->ls;
272 unsigned int cb = 0;
273
274 switch (gdlm_make_lmstate(bast_mode)) {
275 case LM_ST_EXCLUSIVE:
276 cb = LM_CB_NEED_E;
277 break;
278 case LM_ST_DEFERRED:
279 cb = LM_CB_NEED_D;
280 break;
281 case LM_ST_SHARED:
282 cb = LM_CB_NEED_S;
283 break;
284 default:
285 gdlm_assert(0, "unknown bast mode %u", bast_mode);
286 }
287
288 ls->fscb(ls->sdp, cb, &lp->lockname);
289}
290
291
292static void gdlm_bast(void *astarg, int mode)
293{
294 struct gdlm_lock *lp = astarg;
295
296 if (!mode) {
297 printk(KERN_INFO "lock_dlm: bast mode zero %x,%llx\n",
298 lp->lockname.ln_type,
299 (unsigned long long)lp->lockname.ln_number);
300 return;
301 }
302
303 process_blocking(lp, mode);
304}
305
62/* convert gfs lock-state to dlm lock-mode */ 306/* convert gfs lock-state to dlm lock-mode */
63 307
64static s16 make_mode(s16 lmstate) 308static s16 make_mode(s16 lmstate)
@@ -77,24 +321,6 @@ static s16 make_mode(s16 lmstate)
77 return -1; 321 return -1;
78} 322}
79 323
80/* convert dlm lock-mode to gfs lock-state */
81
82s16 gdlm_make_lmstate(s16 dlmmode)
83{
84 switch (dlmmode) {
85 case DLM_LOCK_IV:
86 case DLM_LOCK_NL:
87 return LM_ST_UNLOCKED;
88 case DLM_LOCK_EX:
89 return LM_ST_EXCLUSIVE;
90 case DLM_LOCK_CW:
91 return LM_ST_DEFERRED;
92 case DLM_LOCK_PR:
93 return LM_ST_SHARED;
94 }
95 gdlm_assert(0, "unknown DLM mode %d", dlmmode);
96 return -1;
97}
98 324
99/* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and 325/* verify agreement with GFS on the current lock state, NB: DLM_LOCK_NL and
100 DLM_LOCK_IV are both considered LM_ST_UNLOCKED by GFS. */ 326 DLM_LOCK_IV are both considered LM_ST_UNLOCKED by GFS. */
@@ -134,14 +360,6 @@ static inline unsigned int make_flags(struct gdlm_lock *lp,
134 360
135 if (lp->lksb.sb_lkid != 0) { 361 if (lp->lksb.sb_lkid != 0) {
136 lkf |= DLM_LKF_CONVERT; 362 lkf |= DLM_LKF_CONVERT;
137
138 /* Conversion deadlock avoidance by DLM */
139
140 if (!(lp->ls->fsflags & LM_MFLAG_CONV_NODROP) &&
141 !test_bit(LFL_FORCE_PROMOTE, &lp->flags) &&
142 !(lkf & DLM_LKF_NOQUEUE) &&
143 cur > DLM_LOCK_NL && req > DLM_LOCK_NL && cur != req)
144 lkf |= DLM_LKF_CONVDEADLK;
145 } 363 }
146 364
147 if (lp->lvb) 365 if (lp->lvb)
@@ -173,14 +391,9 @@ static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name,
173 make_strname(name, &lp->strname); 391 make_strname(name, &lp->strname);
174 lp->ls = ls; 392 lp->ls = ls;
175 lp->cur = DLM_LOCK_IV; 393 lp->cur = DLM_LOCK_IV;
176 lp->lvb = NULL;
177 lp->hold_null = NULL;
178 INIT_LIST_HEAD(&lp->clist);
179 INIT_LIST_HEAD(&lp->blist);
180 INIT_LIST_HEAD(&lp->delay_list); 394 INIT_LIST_HEAD(&lp->delay_list);
181 395
182 spin_lock(&ls->async_lock); 396 spin_lock(&ls->async_lock);
183 list_add(&lp->all_list, &ls->all_locks);
184 ls->all_locks_count++; 397 ls->all_locks_count++;
185 spin_unlock(&ls->async_lock); 398 spin_unlock(&ls->async_lock);
186 399
@@ -188,26 +401,6 @@ static int gdlm_create_lp(struct gdlm_ls *ls, struct lm_lockname *name,
188 return 0; 401 return 0;
189} 402}
190 403
191void gdlm_delete_lp(struct gdlm_lock *lp)
192{
193 struct gdlm_ls *ls = lp->ls;
194
195 spin_lock(&ls->async_lock);
196 if (!list_empty(&lp->clist))
197 list_del_init(&lp->clist);
198 if (!list_empty(&lp->blist))
199 list_del_init(&lp->blist);
200 if (!list_empty(&lp->delay_list))
201 list_del_init(&lp->delay_list);
202 gdlm_assert(!list_empty(&lp->all_list), "%x,%llx", lp->lockname.ln_type,
203 (unsigned long long)lp->lockname.ln_number);
204 list_del_init(&lp->all_list);
205 ls->all_locks_count--;
206 spin_unlock(&ls->async_lock);
207
208 kfree(lp);
209}
210
211int gdlm_get_lock(void *lockspace, struct lm_lockname *name, 404int gdlm_get_lock(void *lockspace, struct lm_lockname *name,
212 void **lockp) 405 void **lockp)
213{ 406{
@@ -261,7 +454,7 @@ unsigned int gdlm_do_lock(struct gdlm_lock *lp)
261 454
262 if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) { 455 if ((error == -EAGAIN) && (lp->lkf & DLM_LKF_NOQUEUE)) {
263 lp->lksb.sb_status = -EAGAIN; 456 lp->lksb.sb_status = -EAGAIN;
264 queue_complete(lp); 457 gdlm_ast(lp);
265 error = 0; 458 error = 0;
266 } 459 }
267 460
@@ -308,6 +501,12 @@ unsigned int gdlm_lock(void *lock, unsigned int cur_state,
308{ 501{
309 struct gdlm_lock *lp = lock; 502 struct gdlm_lock *lp = lock;
310 503
504 if (req_state == LM_ST_UNLOCKED)
505 return gdlm_unlock(lock, cur_state);
506
507 if (req_state == LM_ST_UNLOCKED)
508 return gdlm_unlock(lock, cur_state);
509
311 clear_bit(LFL_DLM_CANCEL, &lp->flags); 510 clear_bit(LFL_DLM_CANCEL, &lp->flags);
312 if (flags & LM_FLAG_NOEXP) 511 if (flags & LM_FLAG_NOEXP)
313 set_bit(LFL_NOBLOCK, &lp->flags); 512 set_bit(LFL_NOBLOCK, &lp->flags);
@@ -351,7 +550,7 @@ void gdlm_cancel(void *lock)
351 if (delay_list) { 550 if (delay_list) {
352 set_bit(LFL_CANCEL, &lp->flags); 551 set_bit(LFL_CANCEL, &lp->flags);
353 set_bit(LFL_ACTIVE, &lp->flags); 552 set_bit(LFL_ACTIVE, &lp->flags);
354 queue_complete(lp); 553 gdlm_ast(lp);
355 return; 554 return;
356 } 555 }
357 556
@@ -507,22 +706,3 @@ void gdlm_submit_delayed(struct gdlm_ls *ls)
507 wake_up(&ls->thread_wait); 706 wake_up(&ls->thread_wait);
508} 707}
509 708
510int gdlm_release_all_locks(struct gdlm_ls *ls)
511{
512 struct gdlm_lock *lp, *safe;
513 int count = 0;
514
515 spin_lock(&ls->async_lock);
516 list_for_each_entry_safe(lp, safe, &ls->all_locks, all_list) {
517 list_del_init(&lp->all_list);
518
519 if (lp->lvb && lp->lvb != junk_lvb)
520 kfree(lp->lvb);
521 kfree(lp);
522 count++;
523 }
524 spin_unlock(&ls->async_lock);
525
526 return count;
527}
528
diff --git a/fs/gfs2/locking/dlm/lock_dlm.h b/fs/gfs2/locking/dlm/lock_dlm.h
index a243cf69c54..3c98e7c6f93 100644
--- a/fs/gfs2/locking/dlm/lock_dlm.h
+++ b/fs/gfs2/locking/dlm/lock_dlm.h
@@ -72,19 +72,12 @@ struct gdlm_ls {
72 int recover_jid_done; 72 int recover_jid_done;
73 int recover_jid_status; 73 int recover_jid_status;
74 spinlock_t async_lock; 74 spinlock_t async_lock;
75 struct list_head complete;
76 struct list_head blocking;
77 struct list_head delayed; 75 struct list_head delayed;
78 struct list_head submit; 76 struct list_head submit;
79 struct list_head all_locks;
80 u32 all_locks_count; 77 u32 all_locks_count;
81 wait_queue_head_t wait_control; 78 wait_queue_head_t wait_control;
82 struct task_struct *thread1; 79 struct task_struct *thread;
83 struct task_struct *thread2;
84 wait_queue_head_t thread_wait; 80 wait_queue_head_t thread_wait;
85 unsigned long drop_time;
86 int drop_locks_count;
87 int drop_locks_period;
88}; 81};
89 82
90enum { 83enum {
@@ -117,12 +110,7 @@ struct gdlm_lock {
117 u32 lkf; /* dlm flags DLM_LKF_ */ 110 u32 lkf; /* dlm flags DLM_LKF_ */
118 unsigned long flags; /* lock_dlm flags LFL_ */ 111 unsigned long flags; /* lock_dlm flags LFL_ */
119 112
120 int bast_mode; /* protected by async_lock */
121
122 struct list_head clist; /* complete */
123 struct list_head blist; /* blocking */
124 struct list_head delay_list; /* delayed */ 113 struct list_head delay_list; /* delayed */
125 struct list_head all_list; /* all locks for the fs */
126 struct gdlm_lock *hold_null; /* NL lock for hold_lvb */ 114 struct gdlm_lock *hold_null; /* NL lock for hold_lvb */
127}; 115};
128 116
@@ -159,11 +147,7 @@ void gdlm_release_threads(struct gdlm_ls *);
159 147
160/* lock.c */ 148/* lock.c */
161 149
162s16 gdlm_make_lmstate(s16);
163void gdlm_queue_delayed(struct gdlm_lock *);
164void gdlm_submit_delayed(struct gdlm_ls *); 150void gdlm_submit_delayed(struct gdlm_ls *);
165int gdlm_release_all_locks(struct gdlm_ls *);
166void gdlm_delete_lp(struct gdlm_lock *);
167unsigned int gdlm_do_lock(struct gdlm_lock *); 151unsigned int gdlm_do_lock(struct gdlm_lock *);
168 152
169int gdlm_get_lock(void *, struct lm_lockname *, void **); 153int gdlm_get_lock(void *, struct lm_lockname *, void **);
diff --git a/fs/gfs2/locking/dlm/mount.c b/fs/gfs2/locking/dlm/mount.c
index 470bdf650b5..09d78c216f4 100644
--- a/fs/gfs2/locking/dlm/mount.c
+++ b/fs/gfs2/locking/dlm/mount.c
@@ -22,22 +22,14 @@ static struct gdlm_ls *init_gdlm(lm_callback_t cb, struct gfs2_sbd *sdp,
22 if (!ls) 22 if (!ls)
23 return NULL; 23 return NULL;
24 24
25 ls->drop_locks_count = GDLM_DROP_COUNT;
26 ls->drop_locks_period = GDLM_DROP_PERIOD;
27 ls->fscb = cb; 25 ls->fscb = cb;
28 ls->sdp = sdp; 26 ls->sdp = sdp;
29 ls->fsflags = flags; 27 ls->fsflags = flags;
30 spin_lock_init(&ls->async_lock); 28 spin_lock_init(&ls->async_lock);
31 INIT_LIST_HEAD(&ls->complete);
32 INIT_LIST_HEAD(&ls->blocking);
33 INIT_LIST_HEAD(&ls->delayed); 29 INIT_LIST_HEAD(&ls->delayed);
34 INIT_LIST_HEAD(&ls->submit); 30 INIT_LIST_HEAD(&ls->submit);
35 INIT_LIST_HEAD(&ls->all_locks);
36 init_waitqueue_head(&ls->thread_wait); 31 init_waitqueue_head(&ls->thread_wait);
37 init_waitqueue_head(&ls->wait_control); 32 init_waitqueue_head(&ls->wait_control);
38 ls->thread1 = NULL;
39 ls->thread2 = NULL;
40 ls->drop_time = jiffies;
41 ls->jid = -1; 33 ls->jid = -1;
42 34
43 strncpy(buf, table_name, 256); 35 strncpy(buf, table_name, 256);
@@ -180,7 +172,6 @@ out:
180static void gdlm_unmount(void *lockspace) 172static void gdlm_unmount(void *lockspace)
181{ 173{
182 struct gdlm_ls *ls = lockspace; 174 struct gdlm_ls *ls = lockspace;
183 int rv;
184 175
185 log_debug("unmount flags %lx", ls->flags); 176 log_debug("unmount flags %lx", ls->flags);
186 177
@@ -194,9 +185,7 @@ static void gdlm_unmount(void *lockspace)
194 gdlm_kobject_release(ls); 185 gdlm_kobject_release(ls);
195 dlm_release_lockspace(ls->dlm_lockspace, 2); 186 dlm_release_lockspace(ls->dlm_lockspace, 2);
196 gdlm_release_threads(ls); 187 gdlm_release_threads(ls);
197 rv = gdlm_release_all_locks(ls); 188 BUG_ON(ls->all_locks_count);
198 if (rv)
199 log_info("gdlm_unmount: %d stray locks freed", rv);
200out: 189out:
201 kfree(ls); 190 kfree(ls);
202} 191}
@@ -232,7 +221,6 @@ static void gdlm_withdraw(void *lockspace)
232 221
233 dlm_release_lockspace(ls->dlm_lockspace, 2); 222 dlm_release_lockspace(ls->dlm_lockspace, 2);
234 gdlm_release_threads(ls); 223 gdlm_release_threads(ls);
235 gdlm_release_all_locks(ls);
236 gdlm_kobject_release(ls); 224 gdlm_kobject_release(ls);
237} 225}
238 226
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index a4ff271df9e..4ec571c3d8a 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -114,17 +114,6 @@ static ssize_t recover_status_show(struct gdlm_ls *ls, char *buf)
114 return sprintf(buf, "%d\n", ls->recover_jid_status); 114 return sprintf(buf, "%d\n", ls->recover_jid_status);
115} 115}
116 116
117static ssize_t drop_count_show(struct gdlm_ls *ls, char *buf)
118{
119 return sprintf(buf, "%d\n", ls->drop_locks_count);
120}
121
122static ssize_t drop_count_store(struct gdlm_ls *ls, const char *buf, size_t len)
123{
124 ls->drop_locks_count = simple_strtol(buf, NULL, 0);
125 return len;
126}
127
128struct gdlm_attr { 117struct gdlm_attr {
129 struct attribute attr; 118 struct attribute attr;
130 ssize_t (*show)(struct gdlm_ls *, char *); 119 ssize_t (*show)(struct gdlm_ls *, char *);
@@ -144,7 +133,6 @@ GDLM_ATTR(first_done, 0444, first_done_show, NULL);
144GDLM_ATTR(recover, 0644, recover_show, recover_store); 133GDLM_ATTR(recover, 0644, recover_show, recover_store);
145GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); 134GDLM_ATTR(recover_done, 0444, recover_done_show, NULL);
146GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); 135GDLM_ATTR(recover_status, 0444, recover_status_show, NULL);
147GDLM_ATTR(drop_count, 0644, drop_count_show, drop_count_store);
148 136
149static struct attribute *gdlm_attrs[] = { 137static struct attribute *gdlm_attrs[] = {
150 &gdlm_attr_proto_name.attr, 138 &gdlm_attr_proto_name.attr,
@@ -157,7 +145,6 @@ static struct attribute *gdlm_attrs[] = {
157 &gdlm_attr_recover.attr, 145 &gdlm_attr_recover.attr,
158 &gdlm_attr_recover_done.attr, 146 &gdlm_attr_recover_done.attr,
159 &gdlm_attr_recover_status.attr, 147 &gdlm_attr_recover_status.attr,
160 &gdlm_attr_drop_count.attr,
161 NULL, 148 NULL,
162}; 149};
163 150
diff --git a/fs/gfs2/locking/dlm/thread.c b/fs/gfs2/locking/dlm/thread.c
index e53db6fd28a..38823efd698 100644
--- a/fs/gfs2/locking/dlm/thread.c
+++ b/fs/gfs2/locking/dlm/thread.c
@@ -9,367 +9,60 @@
9 9
10#include "lock_dlm.h" 10#include "lock_dlm.h"
11 11
12/* A lock placed on this queue is re-submitted to DLM as soon as the lock_dlm 12static inline int no_work(struct gdlm_ls *ls)
13 thread gets to it. */
14
15static void queue_submit(struct gdlm_lock *lp)
16{
17 struct gdlm_ls *ls = lp->ls;
18
19 spin_lock(&ls->async_lock);
20 list_add_tail(&lp->delay_list, &ls->submit);
21 spin_unlock(&ls->async_lock);
22 wake_up(&ls->thread_wait);
23}
24
25static void process_blocking(struct gdlm_lock *lp, int bast_mode)
26{
27 struct gdlm_ls *ls = lp->ls;
28 unsigned int cb = 0;
29
30 switch (gdlm_make_lmstate(bast_mode)) {
31 case LM_ST_EXCLUSIVE:
32 cb = LM_CB_NEED_E;
33 break;
34 case LM_ST_DEFERRED:
35 cb = LM_CB_NEED_D;
36 break;
37 case LM_ST_SHARED:
38 cb = LM_CB_NEED_S;
39 break;
40 default:
41 gdlm_assert(0, "unknown bast mode %u", lp->bast_mode);
42 }
43
44 ls->fscb(ls->sdp, cb, &lp->lockname);
45}
46
47static void wake_up_ast(struct gdlm_lock *lp)
48{
49 clear_bit(LFL_AST_WAIT, &lp->flags);
50 smp_mb__after_clear_bit();
51 wake_up_bit(&lp->flags, LFL_AST_WAIT);
52}
53
54static void process_complete(struct gdlm_lock *lp)
55{
56 struct gdlm_ls *ls = lp->ls;
57 struct lm_async_cb acb;
58 s16 prev_mode = lp->cur;
59
60 memset(&acb, 0, sizeof(acb));
61
62 if (lp->lksb.sb_status == -DLM_ECANCEL) {
63 log_info("complete dlm cancel %x,%llx flags %lx",
64 lp->lockname.ln_type,
65 (unsigned long long)lp->lockname.ln_number,
66 lp->flags);
67
68 lp->req = lp->cur;
69 acb.lc_ret |= LM_OUT_CANCELED;
70 if (lp->cur == DLM_LOCK_IV)
71 lp->lksb.sb_lkid = 0;
72 goto out;
73 }
74
75 if (test_and_clear_bit(LFL_DLM_UNLOCK, &lp->flags)) {
76 if (lp->lksb.sb_status != -DLM_EUNLOCK) {
77 log_info("unlock sb_status %d %x,%llx flags %lx",
78 lp->lksb.sb_status, lp->lockname.ln_type,
79 (unsigned long long)lp->lockname.ln_number,
80 lp->flags);
81 return;
82 }
83
84 lp->cur = DLM_LOCK_IV;
85 lp->req = DLM_LOCK_IV;
86 lp->lksb.sb_lkid = 0;
87
88 if (test_and_clear_bit(LFL_UNLOCK_DELETE, &lp->flags)) {
89 gdlm_delete_lp(lp);
90 return;
91 }
92 goto out;
93 }
94
95 if (lp->lksb.sb_flags & DLM_SBF_VALNOTVALID)
96 memset(lp->lksb.sb_lvbptr, 0, GDLM_LVB_SIZE);
97
98 if (lp->lksb.sb_flags & DLM_SBF_ALTMODE) {
99 if (lp->req == DLM_LOCK_PR)
100 lp->req = DLM_LOCK_CW;
101 else if (lp->req == DLM_LOCK_CW)
102 lp->req = DLM_LOCK_PR;
103 }
104
105 /*
106 * A canceled lock request. The lock was just taken off the delayed
107 * list and was never even submitted to dlm.
108 */
109
110 if (test_and_clear_bit(LFL_CANCEL, &lp->flags)) {
111 log_info("complete internal cancel %x,%llx",
112 lp->lockname.ln_type,
113 (unsigned long long)lp->lockname.ln_number);
114 lp->req = lp->cur;
115 acb.lc_ret |= LM_OUT_CANCELED;
116 goto out;
117 }
118
119 /*
120 * An error occured.
121 */
122
123 if (lp->lksb.sb_status) {
124 /* a "normal" error */
125 if ((lp->lksb.sb_status == -EAGAIN) &&
126 (lp->lkf & DLM_LKF_NOQUEUE)) {
127 lp->req = lp->cur;
128 if (lp->cur == DLM_LOCK_IV)
129 lp->lksb.sb_lkid = 0;
130 goto out;
131 }
132
133 /* this could only happen with cancels I think */
134 log_info("ast sb_status %d %x,%llx flags %lx",
135 lp->lksb.sb_status, lp->lockname.ln_type,
136 (unsigned long long)lp->lockname.ln_number,
137 lp->flags);
138 if (lp->lksb.sb_status == -EDEADLOCK &&
139 lp->ls->fsflags & LM_MFLAG_CONV_NODROP) {
140 lp->req = lp->cur;
141 acb.lc_ret |= LM_OUT_CONV_DEADLK;
142 if (lp->cur == DLM_LOCK_IV)
143 lp->lksb.sb_lkid = 0;
144 goto out;
145 } else
146 return;
147 }
148
149 /*
150 * This is an AST for an EX->EX conversion for sync_lvb from GFS.
151 */
152
153 if (test_and_clear_bit(LFL_SYNC_LVB, &lp->flags)) {
154 wake_up_ast(lp);
155 return;
156 }
157
158 /*
159 * A lock has been demoted to NL because it initially completed during
160 * BLOCK_LOCKS. Now it must be requested in the originally requested
161 * mode.
162 */
163
164 if (test_and_clear_bit(LFL_REREQUEST, &lp->flags)) {
165 gdlm_assert(lp->req == DLM_LOCK_NL, "%x,%llx",
166 lp->lockname.ln_type,
167 (unsigned long long)lp->lockname.ln_number);
168 gdlm_assert(lp->prev_req > DLM_LOCK_NL, "%x,%llx",
169 lp->lockname.ln_type,
170 (unsigned long long)lp->lockname.ln_number);
171
172 lp->cur = DLM_LOCK_NL;
173 lp->req = lp->prev_req;
174 lp->prev_req = DLM_LOCK_IV;
175 lp->lkf &= ~DLM_LKF_CONVDEADLK;
176
177 set_bit(LFL_NOCACHE, &lp->flags);
178
179 if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) &&
180 !test_bit(LFL_NOBLOCK, &lp->flags))
181 gdlm_queue_delayed(lp);
182 else
183 queue_submit(lp);
184 return;
185 }
186
187 /*
188 * A request is granted during dlm recovery. It may be granted
189 * because the locks of a failed node were cleared. In that case,
190 * there may be inconsistent data beneath this lock and we must wait
191 * for recovery to complete to use it. When gfs recovery is done this
192 * granted lock will be converted to NL and then reacquired in this
193 * granted state.
194 */
195
196 if (test_bit(DFL_BLOCK_LOCKS, &ls->flags) &&
197 !test_bit(LFL_NOBLOCK, &lp->flags) &&
198 lp->req != DLM_LOCK_NL) {
199
200 lp->cur = lp->req;
201 lp->prev_req = lp->req;
202 lp->req = DLM_LOCK_NL;
203 lp->lkf |= DLM_LKF_CONVERT;
204 lp->lkf &= ~DLM_LKF_CONVDEADLK;
205
206 log_debug("rereq %x,%llx id %x %d,%d",
207 lp->lockname.ln_type,
208 (unsigned long long)lp->lockname.ln_number,
209 lp->lksb.sb_lkid, lp->cur, lp->req);
210
211 set_bit(LFL_REREQUEST, &lp->flags);
212 queue_submit(lp);
213 return;
214 }
215
216 /*
217 * DLM demoted the lock to NL before it was granted so GFS must be
218 * told it cannot cache data for this lock.
219 */
220
221 if (lp->lksb.sb_flags & DLM_SBF_DEMOTED)
222 set_bit(LFL_NOCACHE, &lp->flags);
223
224out:
225 /*
226 * This is an internal lock_dlm lock
227 */
228
229 if (test_bit(LFL_INLOCK, &lp->flags)) {
230 clear_bit(LFL_NOBLOCK, &lp->flags);
231 lp->cur = lp->req;
232 wake_up_ast(lp);
233 return;
234 }
235
236 /*
237 * Normal completion of a lock request. Tell GFS it now has the lock.
238 */
239
240 clear_bit(LFL_NOBLOCK, &lp->flags);
241 lp->cur = lp->req;
242
243 acb.lc_name = lp->lockname;
244 acb.lc_ret |= gdlm_make_lmstate(lp->cur);
245
246 if (!test_and_clear_bit(LFL_NOCACHE, &lp->flags) &&
247 (lp->cur > DLM_LOCK_NL) && (prev_mode > DLM_LOCK_NL))
248 acb.lc_ret |= LM_OUT_CACHEABLE;
249
250 ls->fscb(ls->sdp, LM_CB_ASYNC, &acb);
251}
252
253static inline int no_work(struct gdlm_ls *ls, int blocking)
254{ 13{
255 int ret; 14 int ret;
256 15
257 spin_lock(&ls->async_lock); 16 spin_lock(&ls->async_lock);
258 ret = list_empty(&ls->complete) && list_empty(&ls->submit); 17 ret = list_empty(&ls->submit);
259 if (ret && blocking)
260 ret = list_empty(&ls->blocking);
261 spin_unlock(&ls->async_lock); 18 spin_unlock(&ls->async_lock);
262 19
263 return ret; 20 return ret;
264} 21}
265 22
266static inline int check_drop(struct gdlm_ls *ls) 23static int gdlm_thread(void *data)
267{
268 if (!ls->drop_locks_count)
269 return 0;
270
271 if (time_after(jiffies, ls->drop_time + ls->drop_locks_period * HZ)) {
272 ls->drop_time = jiffies;
273 if (ls->all_locks_count >= ls->drop_locks_count)
274 return 1;
275 }
276 return 0;
277}
278
279static int gdlm_thread(void *data, int blist)
280{ 24{
281 struct gdlm_ls *ls = (struct gdlm_ls *) data; 25 struct gdlm_ls *ls = (struct gdlm_ls *) data;
282 struct gdlm_lock *lp = NULL; 26 struct gdlm_lock *lp = NULL;
283 uint8_t complete, blocking, submit, drop;
284
285 /* Only thread1 is allowed to do blocking callbacks since gfs
286 may wait for a completion callback within a blocking cb. */
287 27
288 while (!kthread_should_stop()) { 28 while (!kthread_should_stop()) {
289 wait_event_interruptible(ls->thread_wait, 29 wait_event_interruptible(ls->thread_wait,
290 !no_work(ls, blist) || kthread_should_stop()); 30 !no_work(ls) || kthread_should_stop());
291
292 complete = blocking = submit = drop = 0;
293 31
294 spin_lock(&ls->async_lock); 32 spin_lock(&ls->async_lock);
295 33
296 if (blist && !list_empty(&ls->blocking)) { 34 if (!list_empty(&ls->submit)) {
297 lp = list_entry(ls->blocking.next, struct gdlm_lock,
298 blist);
299 list_del_init(&lp->blist);
300 blocking = lp->bast_mode;
301 lp->bast_mode = 0;
302 } else if (!list_empty(&ls->complete)) {
303 lp = list_entry(ls->complete.next, struct gdlm_lock,
304 clist);
305 list_del_init(&lp->clist);
306 complete = 1;
307 } else if (!list_empty(&ls->submit)) {
308 lp = list_entry(ls->submit.next, struct gdlm_lock, 35 lp = list_entry(ls->submit.next, struct gdlm_lock,
309 delay_list); 36 delay_list);
310 list_del_init(&lp->delay_list); 37 list_del_init(&lp->delay_list);
311 submit = 1; 38 spin_unlock(&ls->async_lock);
39 gdlm_do_lock(lp);
40 spin_lock(&ls->async_lock);
312 } 41 }
313
314 drop = check_drop(ls);
315 spin_unlock(&ls->async_lock); 42 spin_unlock(&ls->async_lock);
316
317 if (complete)
318 process_complete(lp);
319
320 else if (blocking)
321 process_blocking(lp, blocking);
322
323 else if (submit)
324 gdlm_do_lock(lp);
325
326 if (drop)
327 ls->fscb(ls->sdp, LM_CB_DROPLOCKS, NULL);
328
329 schedule();
330 } 43 }
331 44
332 return 0; 45 return 0;
333} 46}
334 47
335static int gdlm_thread1(void *data)
336{
337 return gdlm_thread(data, 1);
338}
339
340static int gdlm_thread2(void *data)
341{
342 return gdlm_thread(data, 0);
343}
344
345int gdlm_init_threads(struct gdlm_ls *ls) 48int gdlm_init_threads(struct gdlm_ls *ls)
346{ 49{
347 struct task_struct *p; 50 struct task_struct *p;
348 int error; 51 int error;
349 52
350 p = kthread_run(gdlm_thread1, ls, "lock_dlm1"); 53 p = kthread_run(gdlm_thread, ls, "lock_dlm");
351 error = IS_ERR(p);
352 if (error) {
353 log_error("can't start lock_dlm1 thread %d", error);
354 return error;
355 }
356 ls->thread1 = p;
357
358 p = kthread_run(gdlm_thread2, ls, "lock_dlm2");
359 error = IS_ERR(p); 54 error = IS_ERR(p);
360 if (error) { 55 if (error) {
361 log_error("can't start lock_dlm2 thread %d", error); 56 log_error("can't start lock_dlm thread %d", error);
362 kthread_stop(ls->thread1);
363 return error; 57 return error;
364 } 58 }
365 ls->thread2 = p; 59 ls->thread = p;
366 60
367 return 0; 61 return 0;
368} 62}
369 63
370void gdlm_release_threads(struct gdlm_ls *ls) 64void gdlm_release_threads(struct gdlm_ls *ls)
371{ 65{
372 kthread_stop(ls->thread1); 66 kthread_stop(ls->thread);
373 kthread_stop(ls->thread2);
374} 67}
375 68
diff --git a/fs/gfs2/locking/nolock/Makefile b/fs/gfs2/locking/nolock/Makefile
deleted file mode 100644
index 35e9730bc3a..00000000000
--- a/fs/gfs2/locking/nolock/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1obj-$(CONFIG_GFS2_FS_LOCKING_NOLOCK) += lock_nolock.o
2lock_nolock-y := main.o
3
diff --git a/fs/gfs2/locking/nolock/main.c b/fs/gfs2/locking/nolock/main.c
deleted file mode 100644
index 284a5ece8d9..00000000000
--- a/fs/gfs2/locking/nolock/main.c
+++ /dev/null
@@ -1,238 +0,0 @@
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
4 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
7 * of the GNU General Public License version 2.
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/init.h>
13#include <linux/types.h>
14#include <linux/fs.h>
15#include <linux/lm_interface.h>
16
17struct nolock_lockspace {
18 unsigned int nl_lvb_size;
19};
20
21static const struct lm_lockops nolock_ops;
22
23static int nolock_mount(char *table_name, char *host_data,
24 lm_callback_t cb, void *cb_data,
25 unsigned int min_lvb_size, int flags,
26 struct lm_lockstruct *lockstruct,
27 struct kobject *fskobj)
28{
29 char *c;
30 unsigned int jid;
31 struct nolock_lockspace *nl;
32
33 c = strstr(host_data, "jid=");
34 if (!c)
35 jid = 0;
36 else {
37 c += 4;
38 sscanf(c, "%u", &jid);
39 }
40
41 nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
42 if (!nl)
43 return -ENOMEM;
44
45 nl->nl_lvb_size = min_lvb_size;
46
47 lockstruct->ls_jid = jid;
48 lockstruct->ls_first = 1;
49 lockstruct->ls_lvb_size = min_lvb_size;
50 lockstruct->ls_lockspace = nl;
51 lockstruct->ls_ops = &nolock_ops;
52 lockstruct->ls_flags = LM_LSFLAG_LOCAL;
53
54 return 0;
55}
56
57static void nolock_others_may_mount(void *lockspace)
58{
59}
60
61static void nolock_unmount(void *lockspace)
62{
63 struct nolock_lockspace *nl = lockspace;
64 kfree(nl);
65}
66
67static void nolock_withdraw(void *lockspace)
68{
69}
70
71/**
72 * nolock_get_lock - get a lm_lock_t given a descripton of the lock
73 * @lockspace: the lockspace the lock lives in
74 * @name: the name of the lock
75 * @lockp: return the lm_lock_t here
76 *
77 * Returns: 0 on success, -EXXX on failure
78 */
79
80static int nolock_get_lock(void *lockspace, struct lm_lockname *name,
81 void **lockp)
82{
83 *lockp = lockspace;
84 return 0;
85}
86
87/**
88 * nolock_put_lock - get rid of a lock structure
89 * @lock: the lock to throw away
90 *
91 */
92
93static void nolock_put_lock(void *lock)
94{
95}
96
97/**
98 * nolock_lock - acquire a lock
99 * @lock: the lock to manipulate
100 * @cur_state: the current state
101 * @req_state: the requested state
102 * @flags: modifier flags
103 *
104 * Returns: A bitmap of LM_OUT_*
105 */
106
107static unsigned int nolock_lock(void *lock, unsigned int cur_state,
108 unsigned int req_state, unsigned int flags)
109{
110 return req_state | LM_OUT_CACHEABLE;
111}
112
113/**
114 * nolock_unlock - unlock a lock
115 * @lock: the lock to manipulate
116 * @cur_state: the current state
117 *
118 * Returns: 0
119 */
120
121static unsigned int nolock_unlock(void *lock, unsigned int cur_state)
122{
123 return 0;
124}
125
126static void nolock_cancel(void *lock)
127{
128}
129
130/**
131 * nolock_hold_lvb - hold on to a lock value block
132 * @lock: the lock the LVB is associated with
133 * @lvbp: return the lm_lvb_t here
134 *
135 * Returns: 0 on success, -EXXX on failure
136 */
137
138static int nolock_hold_lvb(void *lock, char **lvbp)
139{
140 struct nolock_lockspace *nl = lock;
141 int error = 0;
142
143 *lvbp = kzalloc(nl->nl_lvb_size, GFP_NOFS);
144 if (!*lvbp)
145 error = -ENOMEM;
146
147 return error;
148}
149
150/**
151 * nolock_unhold_lvb - release a LVB
152 * @lock: the lock the LVB is associated with
153 * @lvb: the lock value block
154 *
155 */
156
157static void nolock_unhold_lvb(void *lock, char *lvb)
158{
159 kfree(lvb);
160}
161
162static int nolock_plock_get(void *lockspace, struct lm_lockname *name,
163 struct file *file, struct file_lock *fl)
164{
165 posix_test_lock(file, fl);
166
167 return 0;
168}
169
170static int nolock_plock(void *lockspace, struct lm_lockname *name,
171 struct file *file, int cmd, struct file_lock *fl)
172{
173 int error;
174 error = posix_lock_file_wait(file, fl);
175 return error;
176}
177
178static int nolock_punlock(void *lockspace, struct lm_lockname *name,
179 struct file *file, struct file_lock *fl)
180{
181 int error;
182 error = posix_lock_file_wait(file, fl);
183 return error;
184}
185
186static void nolock_recovery_done(void *lockspace, unsigned int jid,
187 unsigned int message)
188{
189}
190
191static const struct lm_lockops nolock_ops = {
192 .lm_proto_name = "lock_nolock",
193 .lm_mount = nolock_mount,
194 .lm_others_may_mount = nolock_others_may_mount,
195 .lm_unmount = nolock_unmount,
196 .lm_withdraw = nolock_withdraw,
197 .lm_get_lock = nolock_get_lock,
198 .lm_put_lock = nolock_put_lock,
199 .lm_lock = nolock_lock,
200 .lm_unlock = nolock_unlock,
201 .lm_cancel = nolock_cancel,
202 .lm_hold_lvb = nolock_hold_lvb,
203 .lm_unhold_lvb = nolock_unhold_lvb,
204 .lm_plock_get = nolock_plock_get,
205 .lm_plock = nolock_plock,
206 .lm_punlock = nolock_punlock,
207 .lm_recovery_done = nolock_recovery_done,
208 .lm_owner = THIS_MODULE,
209};
210
211static int __init init_nolock(void)
212{
213 int error;
214
215 error = gfs2_register_lockproto(&nolock_ops);
216 if (error) {
217 printk(KERN_WARNING
218 "lock_nolock: can't register protocol: %d\n", error);
219 return error;
220 }
221
222 printk(KERN_INFO
223 "Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__);
224 return 0;
225}
226
227static void __exit exit_nolock(void)
228{
229 gfs2_unregister_lockproto(&nolock_ops);
230}
231
232module_init(init_nolock);
233module_exit(exit_nolock);
234
235MODULE_DESCRIPTION("GFS Nolock Locking Module");
236MODULE_AUTHOR("Red Hat, Inc.");
237MODULE_LICENSE("GPL");
238
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 548264b1836..6c6af9f5e3a 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -87,6 +87,8 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd)
87 */ 87 */
88 88
89static void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai) 89static void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
90__releases(&sdp->sd_log_lock)
91__acquires(&sdp->sd_log_lock)
90{ 92{
91 struct gfs2_bufdata *bd, *s; 93 struct gfs2_bufdata *bd, *s;
92 struct buffer_head *bh; 94 struct buffer_head *bh;
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index 77115281650..7c64510ccfd 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23static inline void gfs2_log_lock(struct gfs2_sbd *sdp) 23static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
24__acquires(&sdp->sd_log_lock)
24{ 25{
25 spin_lock(&sdp->sd_log_lock); 26 spin_lock(&sdp->sd_log_lock);
26} 27}
@@ -32,6 +33,7 @@ static inline void gfs2_log_lock(struct gfs2_sbd *sdp)
32 */ 33 */
33 34
34static inline void gfs2_log_unlock(struct gfs2_sbd *sdp) 35static inline void gfs2_log_unlock(struct gfs2_sbd *sdp)
36__releases(&sdp->sd_log_lock)
35{ 37{
36 spin_unlock(&sdp->sd_log_lock); 38 spin_unlock(&sdp->sd_log_lock);
37} 39}
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index 053e2ebbbd5..bcc668d0fad 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -40,8 +40,6 @@ static void gfs2_init_glock_once(struct kmem_cache *cachep, void *foo)
40 INIT_HLIST_NODE(&gl->gl_list); 40 INIT_HLIST_NODE(&gl->gl_list);
41 spin_lock_init(&gl->gl_spin); 41 spin_lock_init(&gl->gl_spin);
42 INIT_LIST_HEAD(&gl->gl_holders); 42 INIT_LIST_HEAD(&gl->gl_holders);
43 INIT_LIST_HEAD(&gl->gl_waiters1);
44 INIT_LIST_HEAD(&gl->gl_waiters3);
45 gl->gl_lvb = NULL; 43 gl->gl_lvb = NULL;
46 atomic_set(&gl->gl_lvb_count, 0); 44 atomic_set(&gl->gl_lvb_count, 0);
47 INIT_LIST_HEAD(&gl->gl_reclaim); 45 INIT_LIST_HEAD(&gl->gl_reclaim);
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 78d75f892f8..09853620c95 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -129,7 +129,7 @@ void gfs2_meta_sync(struct gfs2_glock *gl)
129} 129}
130 130
131/** 131/**
132 * getbuf - Get a buffer with a given address space 132 * gfs2_getbuf - Get a buffer with a given address space
133 * @gl: the glock 133 * @gl: the glock
134 * @blkno: the block number (filesystem scope) 134 * @blkno: the block number (filesystem scope)
135 * @create: 1 if the buffer should be created 135 * @create: 1 if the buffer should be created
@@ -137,7 +137,7 @@ void gfs2_meta_sync(struct gfs2_glock *gl)
137 * Returns: the buffer 137 * Returns: the buffer
138 */ 138 */
139 139
140static struct buffer_head *getbuf(struct gfs2_glock *gl, u64 blkno, int create) 140struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create)
141{ 141{
142 struct address_space *mapping = gl->gl_aspace->i_mapping; 142 struct address_space *mapping = gl->gl_aspace->i_mapping;
143 struct gfs2_sbd *sdp = gl->gl_sbd; 143 struct gfs2_sbd *sdp = gl->gl_sbd;
@@ -205,7 +205,7 @@ static void meta_prep_new(struct buffer_head *bh)
205struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno) 205struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
206{ 206{
207 struct buffer_head *bh; 207 struct buffer_head *bh;
208 bh = getbuf(gl, blkno, CREATE); 208 bh = gfs2_getbuf(gl, blkno, CREATE);
209 meta_prep_new(bh); 209 meta_prep_new(bh);
210 return bh; 210 return bh;
211} 211}
@@ -223,7 +223,7 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
223int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, 223int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
224 struct buffer_head **bhp) 224 struct buffer_head **bhp)
225{ 225{
226 *bhp = getbuf(gl, blkno, CREATE); 226 *bhp = gfs2_getbuf(gl, blkno, CREATE);
227 if (!buffer_uptodate(*bhp)) { 227 if (!buffer_uptodate(*bhp)) {
228 ll_rw_block(READ_META, 1, bhp); 228 ll_rw_block(READ_META, 1, bhp);
229 if (flags & DIO_WAIT) { 229 if (flags & DIO_WAIT) {
@@ -346,7 +346,7 @@ void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)
346 struct buffer_head *bh; 346 struct buffer_head *bh;
347 347
348 while (blen) { 348 while (blen) {
349 bh = getbuf(ip->i_gl, bstart, NO_CREATE); 349 bh = gfs2_getbuf(ip->i_gl, bstart, NO_CREATE);
350 if (bh) { 350 if (bh) {
351 lock_buffer(bh); 351 lock_buffer(bh);
352 gfs2_log_lock(sdp); 352 gfs2_log_lock(sdp);
@@ -421,7 +421,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
421 if (extlen > max_ra) 421 if (extlen > max_ra)
422 extlen = max_ra; 422 extlen = max_ra;
423 423
424 first_bh = getbuf(gl, dblock, CREATE); 424 first_bh = gfs2_getbuf(gl, dblock, CREATE);
425 425
426 if (buffer_uptodate(first_bh)) 426 if (buffer_uptodate(first_bh))
427 goto out; 427 goto out;
@@ -432,7 +432,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
432 extlen--; 432 extlen--;
433 433
434 while (extlen) { 434 while (extlen) {
435 bh = getbuf(gl, dblock, CREATE); 435 bh = gfs2_getbuf(gl, dblock, CREATE);
436 436
437 if (!buffer_uptodate(bh) && !buffer_locked(bh)) 437 if (!buffer_uptodate(bh) && !buffer_locked(bh))
438 ll_rw_block(READA, 1, &bh); 438 ll_rw_block(READA, 1, &bh);
diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h
index 73e3b1c76fe..b1a5f3674d4 100644
--- a/fs/gfs2/meta_io.h
+++ b/fs/gfs2/meta_io.h
@@ -47,6 +47,7 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
47int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, 47int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno,
48 int flags, struct buffer_head **bhp); 48 int flags, struct buffer_head **bhp);
49int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh); 49int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);
50struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create);
50 51
51void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh, 52void gfs2_attach_bufdata(struct gfs2_glock *gl, struct buffer_head *bh,
52 int meta); 53 int meta);
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index f55394e57cb..e64a1b04117 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -499,34 +499,34 @@ static int __gfs2_readpage(void *file, struct page *page)
499 * @file: The file to read 499 * @file: The file to read
500 * @page: The page of the file 500 * @page: The page of the file
501 * 501 *
502 * This deals with the locking required. We use a trylock in order to 502 * This deals with the locking required. We have to unlock and
503 * avoid the page lock / glock ordering problems returning AOP_TRUNCATED_PAGE 503 * relock the page in order to get the locking in the right
504 * in the event that we are unable to get the lock. 504 * order.
505 */ 505 */
506 506
507static int gfs2_readpage(struct file *file, struct page *page) 507static int gfs2_readpage(struct file *file, struct page *page)
508{ 508{
509 struct gfs2_inode *ip = GFS2_I(page->mapping->host); 509 struct address_space *mapping = page->mapping;
510 struct gfs2_holder *gh; 510 struct gfs2_inode *ip = GFS2_I(mapping->host);
511 struct gfs2_holder gh;
511 int error; 512 int error;
512 513
513 gh = gfs2_glock_is_locked_by_me(ip->i_gl); 514 unlock_page(page);
514 if (!gh) { 515 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
515 gh = kmalloc(sizeof(struct gfs2_holder), GFP_NOFS); 516 error = gfs2_glock_nq_atime(&gh);
516 if (!gh) 517 if (unlikely(error))
517 return -ENOBUFS; 518 goto out;
518 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, gh); 519 error = AOP_TRUNCATED_PAGE;
520 lock_page(page);
521 if (page->mapping == mapping && !PageUptodate(page))
522 error = __gfs2_readpage(file, page);
523 else
519 unlock_page(page); 524 unlock_page(page);
520 error = gfs2_glock_nq_atime(gh); 525 gfs2_glock_dq(&gh);
521 if (likely(error != 0))
522 goto out;
523 return AOP_TRUNCATED_PAGE;
524 }
525 error = __gfs2_readpage(file, page);
526 gfs2_glock_dq(gh);
527out: 526out:
528 gfs2_holder_uninit(gh); 527 gfs2_holder_uninit(&gh);
529 kfree(gh); 528 if (error && error != AOP_TRUNCATED_PAGE)
529 lock_page(page);
530 return error; 530 return error;
531} 531}
532 532
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 24dd5945008..e9a366d4411 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -15,6 +15,7 @@
15#include <linux/uio.h> 15#include <linux/uio.h>
16#include <linux/blkdev.h> 16#include <linux/blkdev.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/mount.h>
18#include <linux/fs.h> 19#include <linux/fs.h>
19#include <linux/gfs2_ondisk.h> 20#include <linux/gfs2_ondisk.h>
20#include <linux/ext2_fs.h> 21#include <linux/ext2_fs.h>
@@ -133,7 +134,6 @@ static const u32 fsflags_to_gfs2[32] = {
133 [7] = GFS2_DIF_NOATIME, 134 [7] = GFS2_DIF_NOATIME,
134 [12] = GFS2_DIF_EXHASH, 135 [12] = GFS2_DIF_EXHASH,
135 [14] = GFS2_DIF_INHERIT_JDATA, 136 [14] = GFS2_DIF_INHERIT_JDATA,
136 [20] = GFS2_DIF_INHERIT_DIRECTIO,
137}; 137};
138 138
139static const u32 gfs2_to_fsflags[32] = { 139static const u32 gfs2_to_fsflags[32] = {
@@ -142,7 +142,6 @@ static const u32 gfs2_to_fsflags[32] = {
142 [gfs2fl_AppendOnly] = FS_APPEND_FL, 142 [gfs2fl_AppendOnly] = FS_APPEND_FL,
143 [gfs2fl_NoAtime] = FS_NOATIME_FL, 143 [gfs2fl_NoAtime] = FS_NOATIME_FL,
144 [gfs2fl_ExHash] = FS_INDEX_FL, 144 [gfs2fl_ExHash] = FS_INDEX_FL,
145 [gfs2fl_InheritDirectio] = FS_DIRECTIO_FL,
146 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL, 145 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
147}; 146};
148 147
@@ -160,12 +159,8 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
160 return error; 159 return error;
161 160
162 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags); 161 fsflags = fsflags_cvt(gfs2_to_fsflags, ip->i_di.di_flags);
163 if (!S_ISDIR(inode->i_mode)) { 162 if (!S_ISDIR(inode->i_mode) && ip->i_di.di_flags & GFS2_DIF_JDATA)
164 if (ip->i_di.di_flags & GFS2_DIF_JDATA) 163 fsflags |= FS_JOURNAL_DATA_FL;
165 fsflags |= FS_JOURNAL_DATA_FL;
166 if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
167 fsflags |= FS_DIRECTIO_FL;
168 }
169 if (put_user(fsflags, ptr)) 164 if (put_user(fsflags, ptr))
170 error = -EFAULT; 165 error = -EFAULT;
171 166
@@ -194,13 +189,11 @@ void gfs2_set_inode_flags(struct inode *inode)
194 189
195/* Flags that can be set by user space */ 190/* Flags that can be set by user space */
196#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \ 191#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \
197 GFS2_DIF_DIRECTIO| \
198 GFS2_DIF_IMMUTABLE| \ 192 GFS2_DIF_IMMUTABLE| \
199 GFS2_DIF_APPENDONLY| \ 193 GFS2_DIF_APPENDONLY| \
200 GFS2_DIF_NOATIME| \ 194 GFS2_DIF_NOATIME| \
201 GFS2_DIF_SYNC| \ 195 GFS2_DIF_SYNC| \
202 GFS2_DIF_SYSTEM| \ 196 GFS2_DIF_SYSTEM| \
203 GFS2_DIF_INHERIT_DIRECTIO| \
204 GFS2_DIF_INHERIT_JDATA) 197 GFS2_DIF_INHERIT_JDATA)
205 198
206/** 199/**
@@ -220,10 +213,14 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
220 int error; 213 int error;
221 u32 new_flags, flags; 214 u32 new_flags, flags;
222 215
223 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); 216 error = mnt_want_write(filp->f_path.mnt);
224 if (error) 217 if (error)
225 return error; 218 return error;
226 219
220 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
221 if (error)
222 goto out_drop_write;
223
227 flags = ip->i_di.di_flags; 224 flags = ip->i_di.di_flags;
228 new_flags = (flags & ~mask) | (reqflags & mask); 225 new_flags = (flags & ~mask) | (reqflags & mask);
229 if ((new_flags ^ flags) == 0) 226 if ((new_flags ^ flags) == 0)
@@ -242,7 +239,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
242 !capable(CAP_LINUX_IMMUTABLE)) 239 !capable(CAP_LINUX_IMMUTABLE))
243 goto out; 240 goto out;
244 if (!IS_IMMUTABLE(inode)) { 241 if (!IS_IMMUTABLE(inode)) {
245 error = permission(inode, MAY_WRITE, NULL); 242 error = gfs2_permission(inode, MAY_WRITE);
246 if (error) 243 if (error)
247 goto out; 244 goto out;
248 } 245 }
@@ -272,6 +269,8 @@ out_trans_end:
272 gfs2_trans_end(sdp); 269 gfs2_trans_end(sdp);
273out: 270out:
274 gfs2_glock_dq_uninit(&gh); 271 gfs2_glock_dq_uninit(&gh);
272out_drop_write:
273 mnt_drop_write(filp->f_path.mnt);
275 return error; 274 return error;
276} 275}
277 276
@@ -285,8 +284,6 @@ static int gfs2_set_flags(struct file *filp, u32 __user *ptr)
285 if (!S_ISDIR(inode->i_mode)) { 284 if (!S_ISDIR(inode->i_mode)) {
286 if (gfsflags & GFS2_DIF_INHERIT_JDATA) 285 if (gfsflags & GFS2_DIF_INHERIT_JDATA)
287 gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA); 286 gfsflags ^= (GFS2_DIF_JDATA | GFS2_DIF_INHERIT_JDATA);
288 if (gfsflags & GFS2_DIF_INHERIT_DIRECTIO)
289 gfsflags ^= (GFS2_DIF_DIRECTIO | GFS2_DIF_INHERIT_DIRECTIO);
290 return do_gfs2_set_flags(filp, gfsflags, ~0); 287 return do_gfs2_set_flags(filp, gfsflags, ~0);
291 } 288 }
292 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA); 289 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
@@ -487,11 +484,6 @@ static int gfs2_open(struct inode *inode, struct file *file)
487 goto fail_gunlock; 484 goto fail_gunlock;
488 } 485 }
489 486
490 /* Listen to the Direct I/O flag */
491
492 if (ip->i_di.di_flags & GFS2_DIF_DIRECTIO)
493 file->f_flags |= O_DIRECT;
494
495 gfs2_glock_dq_uninit(&i_gh); 487 gfs2_glock_dq_uninit(&i_gh);
496 } 488 }
497 489
@@ -669,8 +661,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
669 int error = 0; 661 int error = 0;
670 662
671 state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; 663 state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
672 flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE 664 flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE;
673 | GL_FLOCK;
674 665
675 mutex_lock(&fp->f_fl_mutex); 666 mutex_lock(&fp->f_fl_mutex);
676 667
@@ -683,9 +674,8 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
683 gfs2_glock_dq_wait(fl_gh); 674 gfs2_glock_dq_wait(fl_gh);
684 gfs2_holder_reinit(state, flags, fl_gh); 675 gfs2_holder_reinit(state, flags, fl_gh);
685 } else { 676 } else {
686 error = gfs2_glock_get(GFS2_SB(&ip->i_inode), 677 error = gfs2_glock_get(GFS2_SB(&ip->i_inode), ip->i_no_addr,
687 ip->i_no_addr, &gfs2_flock_glops, 678 &gfs2_flock_glops, CREATE, &gl);
688 CREATE, &gl);
689 if (error) 679 if (error)
690 goto out; 680 goto out;
691 gfs2_holder_init(gl, state, flags, fl_gh); 681 gfs2_holder_init(gl, state, flags, fl_gh);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index b2028c82e8d..b4d1d649063 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -64,7 +64,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
64 mutex_init(&sdp->sd_rindex_mutex); 64 mutex_init(&sdp->sd_rindex_mutex);
65 INIT_LIST_HEAD(&sdp->sd_rindex_list); 65 INIT_LIST_HEAD(&sdp->sd_rindex_list);
66 INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); 66 INIT_LIST_HEAD(&sdp->sd_rindex_mru_list);
67 INIT_LIST_HEAD(&sdp->sd_rindex_recent_list);
68 67
69 INIT_LIST_HEAD(&sdp->sd_jindex_list); 68 INIT_LIST_HEAD(&sdp->sd_jindex_list);
70 spin_lock_init(&sdp->sd_jindex_spin); 69 spin_lock_init(&sdp->sd_jindex_spin);
@@ -364,6 +363,8 @@ static int map_journal_extents(struct gfs2_sbd *sdp)
364 363
365static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) 364static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp)
366{ 365{
366 if (!sdp->sd_lockstruct.ls_ops->lm_others_may_mount)
367 return;
367 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 368 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
368 sdp->sd_lockstruct.ls_ops->lm_others_may_mount( 369 sdp->sd_lockstruct.ls_ops->lm_others_may_mount(
369 sdp->sd_lockstruct.ls_lockspace); 370 sdp->sd_lockstruct.ls_lockspace);
@@ -741,8 +742,7 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)
741 goto out; 742 goto out;
742 } 743 }
743 744
744 if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) || 745 if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) ||
745 gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) ||
746 gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= 746 gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >=
747 GFS2_MIN_LVB_SIZE)) { 747 GFS2_MIN_LVB_SIZE)) {
748 gfs2_unmount_lockproto(&sdp->sd_lockstruct); 748 gfs2_unmount_lockproto(&sdp->sd_lockstruct);
@@ -873,7 +873,7 @@ fail_sb:
873fail_locking: 873fail_locking:
874 init_locking(sdp, &mount_gh, UNDO); 874 init_locking(sdp, &mount_gh, UNDO);
875fail_lm: 875fail_lm:
876 gfs2_gl_hash_clear(sdp, WAIT); 876 gfs2_gl_hash_clear(sdp);
877 gfs2_lm_unmount(sdp); 877 gfs2_lm_unmount(sdp);
878 while (invalidate_inodes(sb)) 878 while (invalidate_inodes(sb))
879 yield(); 879 yield();
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 2686ad4c002..1e252dfc529 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -163,7 +163,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
163 if (error) 163 if (error)
164 goto out; 164 goto out;
165 165
166 error = permission(dir, MAY_WRITE | MAY_EXEC, NULL); 166 error = gfs2_permission(dir, MAY_WRITE | MAY_EXEC);
167 if (error) 167 if (error)
168 goto out_gunlock; 168 goto out_gunlock;
169 169
@@ -669,7 +669,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
669 } 669 }
670 } 670 }
671 } else { 671 } else {
672 error = permission(ndir, MAY_WRITE | MAY_EXEC, NULL); 672 error = gfs2_permission(ndir, MAY_WRITE | MAY_EXEC);
673 if (error) 673 if (error)
674 goto out_gunlock; 674 goto out_gunlock;
675 675
@@ -704,7 +704,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
704 /* Check out the dir to be renamed */ 704 /* Check out the dir to be renamed */
705 705
706 if (dir_rename) { 706 if (dir_rename) {
707 error = permission(odentry->d_inode, MAY_WRITE, NULL); 707 error = gfs2_permission(odentry->d_inode, MAY_WRITE);
708 if (error) 708 if (error)
709 goto out_gunlock; 709 goto out_gunlock;
710 } 710 }
@@ -891,7 +891,7 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
891 * Returns: errno 891 * Returns: errno
892 */ 892 */
893 893
894static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd) 894int gfs2_permission(struct inode *inode, int mask)
895{ 895{
896 struct gfs2_inode *ip = GFS2_I(inode); 896 struct gfs2_inode *ip = GFS2_I(inode);
897 struct gfs2_holder i_gh; 897 struct gfs2_holder i_gh;
@@ -905,13 +905,22 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
905 unlock = 1; 905 unlock = 1;
906 } 906 }
907 907
908 error = generic_permission(inode, mask, gfs2_check_acl); 908 if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
909 error = -EACCES;
910 else
911 error = generic_permission(inode, mask, gfs2_check_acl);
909 if (unlock) 912 if (unlock)
910 gfs2_glock_dq_uninit(&i_gh); 913 gfs2_glock_dq_uninit(&i_gh);
911 914
912 return error; 915 return error;
913} 916}
914 917
918static int gfs2_iop_permission(struct inode *inode, int mask,
919 struct nameidata *nd)
920{
921 return gfs2_permission(inode, mask);
922}
923
915static int setattr_size(struct inode *inode, struct iattr *attr) 924static int setattr_size(struct inode *inode, struct iattr *attr)
916{ 925{
917 struct gfs2_inode *ip = GFS2_I(inode); 926 struct gfs2_inode *ip = GFS2_I(inode);
@@ -1141,7 +1150,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
1141} 1150}
1142 1151
1143const struct inode_operations gfs2_file_iops = { 1152const struct inode_operations gfs2_file_iops = {
1144 .permission = gfs2_permission, 1153 .permission = gfs2_iop_permission,
1145 .setattr = gfs2_setattr, 1154 .setattr = gfs2_setattr,
1146 .getattr = gfs2_getattr, 1155 .getattr = gfs2_getattr,
1147 .setxattr = gfs2_setxattr, 1156 .setxattr = gfs2_setxattr,
@@ -1160,7 +1169,7 @@ const struct inode_operations gfs2_dir_iops = {
1160 .rmdir = gfs2_rmdir, 1169 .rmdir = gfs2_rmdir,
1161 .mknod = gfs2_mknod, 1170 .mknod = gfs2_mknod,
1162 .rename = gfs2_rename, 1171 .rename = gfs2_rename,
1163 .permission = gfs2_permission, 1172 .permission = gfs2_iop_permission,
1164 .setattr = gfs2_setattr, 1173 .setattr = gfs2_setattr,
1165 .getattr = gfs2_getattr, 1174 .getattr = gfs2_getattr,
1166 .setxattr = gfs2_setxattr, 1175 .setxattr = gfs2_setxattr,
@@ -1172,7 +1181,7 @@ const struct inode_operations gfs2_dir_iops = {
1172const struct inode_operations gfs2_symlink_iops = { 1181const struct inode_operations gfs2_symlink_iops = {
1173 .readlink = gfs2_readlink, 1182 .readlink = gfs2_readlink,
1174 .follow_link = gfs2_follow_link, 1183 .follow_link = gfs2_follow_link,
1175 .permission = gfs2_permission, 1184 .permission = gfs2_iop_permission,
1176 .setattr = gfs2_setattr, 1185 .setattr = gfs2_setattr,
1177 .getattr = gfs2_getattr, 1186 .getattr = gfs2_getattr,
1178 .setxattr = gfs2_setxattr, 1187 .setxattr = gfs2_setxattr,
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index 0b7cc920eb8..f66ea0f7a35 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -126,7 +126,7 @@ static void gfs2_put_super(struct super_block *sb)
126 gfs2_clear_rgrpd(sdp); 126 gfs2_clear_rgrpd(sdp);
127 gfs2_jindex_free(sdp); 127 gfs2_jindex_free(sdp);
128 /* Take apart glock structures and buffer lists */ 128 /* Take apart glock structures and buffer lists */
129 gfs2_gl_hash_clear(sdp, WAIT); 129 gfs2_gl_hash_clear(sdp);
130 /* Unmount the locking protocol */ 130 /* Unmount the locking protocol */
131 gfs2_lm_unmount(sdp); 131 gfs2_lm_unmount(sdp);
132 132
@@ -155,7 +155,7 @@ static void gfs2_write_super(struct super_block *sb)
155static int gfs2_sync_fs(struct super_block *sb, int wait) 155static int gfs2_sync_fs(struct super_block *sb, int wait)
156{ 156{
157 sb->s_dirt = 0; 157 sb->s_dirt = 0;
158 if (wait) 158 if (wait && sb->s_fs_info)
159 gfs2_log_flush(sb->s_fs_info, NULL); 159 gfs2_log_flush(sb->s_fs_info, NULL);
160 return 0; 160 return 0;
161} 161}
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 56aaf915c59..3e073f5144f 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -904,7 +904,7 @@ static int need_sync(struct gfs2_quota_data *qd)
904 do_sync = 0; 904 do_sync = 0;
905 else { 905 else {
906 value *= gfs2_jindex_size(sdp) * num; 906 value *= gfs2_jindex_size(sdp) * num;
907 do_div(value, den); 907 value = div_s64(value, den);
908 value += (s64)be64_to_cpu(qd->qd_qb.qb_value); 908 value += (s64)be64_to_cpu(qd->qd_qb.qb_value);
909 if (value < (s64)be64_to_cpu(qd->qd_qb.qb_limit)) 909 if (value < (s64)be64_to_cpu(qd->qd_qb.qb_limit))
910 do_sync = 0; 910 do_sync = 0;
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 2888e4b4b1c..d5e91f4f6a0 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -428,6 +428,9 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *hea
428static void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid, 428static void gfs2_lm_recovery_done(struct gfs2_sbd *sdp, unsigned int jid,
429 unsigned int message) 429 unsigned int message)
430{ 430{
431 if (!sdp->sd_lockstruct.ls_ops->lm_recovery_done)
432 return;
433
431 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 434 if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
432 sdp->sd_lockstruct.ls_ops->lm_recovery_done( 435 sdp->sd_lockstruct.ls_ops->lm_recovery_done(
433 sdp->sd_lockstruct.ls_lockspace, jid, message); 436 sdp->sd_lockstruct.ls_lockspace, jid, message);
@@ -505,7 +508,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
505 508
506 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, 509 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
507 LM_FLAG_NOEXP | LM_FLAG_PRIORITY | 510 LM_FLAG_NOEXP | LM_FLAG_PRIORITY |
508 GL_NOCANCEL | GL_NOCACHE, &t_gh); 511 GL_NOCACHE, &t_gh);
509 if (error) 512 if (error)
510 goto fail_gunlock_ji; 513 goto fail_gunlock_ji;
511 514
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 3401628d742..2d90fb25350 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -371,11 +371,6 @@ static void clear_rgrpdi(struct gfs2_sbd *sdp)
371 371
372 spin_lock(&sdp->sd_rindex_spin); 372 spin_lock(&sdp->sd_rindex_spin);
373 sdp->sd_rindex_forward = NULL; 373 sdp->sd_rindex_forward = NULL;
374 head = &sdp->sd_rindex_recent_list;
375 while (!list_empty(head)) {
376 rgd = list_entry(head->next, struct gfs2_rgrpd, rd_recent);
377 list_del(&rgd->rd_recent);
378 }
379 spin_unlock(&sdp->sd_rindex_spin); 374 spin_unlock(&sdp->sd_rindex_spin);
380 375
381 head = &sdp->sd_rindex_list; 376 head = &sdp->sd_rindex_list;
@@ -945,107 +940,30 @@ static struct inode *try_rgrp_unlink(struct gfs2_rgrpd *rgd, u64 *last_unlinked)
945} 940}
946 941
947/** 942/**
948 * recent_rgrp_first - get first RG from "recent" list
949 * @sdp: The GFS2 superblock
950 * @rglast: address of the rgrp used last
951 *
952 * Returns: The first rgrp in the recent list
953 */
954
955static struct gfs2_rgrpd *recent_rgrp_first(struct gfs2_sbd *sdp,
956 u64 rglast)
957{
958 struct gfs2_rgrpd *rgd;
959
960 spin_lock(&sdp->sd_rindex_spin);
961
962 if (rglast) {
963 list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) {
964 if (rgrp_contains_block(rgd, rglast))
965 goto out;
966 }
967 }
968 rgd = NULL;
969 if (!list_empty(&sdp->sd_rindex_recent_list))
970 rgd = list_entry(sdp->sd_rindex_recent_list.next,
971 struct gfs2_rgrpd, rd_recent);
972out:
973 spin_unlock(&sdp->sd_rindex_spin);
974 return rgd;
975}
976
977/**
978 * recent_rgrp_next - get next RG from "recent" list 943 * recent_rgrp_next - get next RG from "recent" list
979 * @cur_rgd: current rgrp 944 * @cur_rgd: current rgrp
980 * @remove:
981 * 945 *
982 * Returns: The next rgrp in the recent list 946 * Returns: The next rgrp in the recent list
983 */ 947 */
984 948
985static struct gfs2_rgrpd *recent_rgrp_next(struct gfs2_rgrpd *cur_rgd, 949static struct gfs2_rgrpd *recent_rgrp_next(struct gfs2_rgrpd *cur_rgd)
986 int remove)
987{ 950{
988 struct gfs2_sbd *sdp = cur_rgd->rd_sbd; 951 struct gfs2_sbd *sdp = cur_rgd->rd_sbd;
989 struct list_head *head; 952 struct list_head *head;
990 struct gfs2_rgrpd *rgd; 953 struct gfs2_rgrpd *rgd;
991 954
992 spin_lock(&sdp->sd_rindex_spin); 955 spin_lock(&sdp->sd_rindex_spin);
993 956 head = &sdp->sd_rindex_mru_list;
994 head = &sdp->sd_rindex_recent_list; 957 if (unlikely(cur_rgd->rd_list_mru.next == head)) {
995 958 spin_unlock(&sdp->sd_rindex_spin);
996 list_for_each_entry(rgd, head, rd_recent) { 959 return NULL;
997 if (rgd == cur_rgd) {
998 if (cur_rgd->rd_recent.next != head)
999 rgd = list_entry(cur_rgd->rd_recent.next,
1000 struct gfs2_rgrpd, rd_recent);
1001 else
1002 rgd = NULL;
1003
1004 if (remove)
1005 list_del(&cur_rgd->rd_recent);
1006
1007 goto out;
1008 }
1009 } 960 }
1010 961 rgd = list_entry(cur_rgd->rd_list_mru.next, struct gfs2_rgrpd, rd_list_mru);
1011 rgd = NULL;
1012 if (!list_empty(head))
1013 rgd = list_entry(head->next, struct gfs2_rgrpd, rd_recent);
1014
1015out:
1016 spin_unlock(&sdp->sd_rindex_spin); 962 spin_unlock(&sdp->sd_rindex_spin);
1017 return rgd; 963 return rgd;
1018} 964}
1019 965
1020/** 966/**
1021 * recent_rgrp_add - add an RG to tail of "recent" list
1022 * @new_rgd: The rgrp to add
1023 *
1024 */
1025
1026static void recent_rgrp_add(struct gfs2_rgrpd *new_rgd)
1027{
1028 struct gfs2_sbd *sdp = new_rgd->rd_sbd;
1029 struct gfs2_rgrpd *rgd;
1030 unsigned int count = 0;
1031 unsigned int max = sdp->sd_rgrps / gfs2_jindex_size(sdp);
1032
1033 spin_lock(&sdp->sd_rindex_spin);
1034
1035 list_for_each_entry(rgd, &sdp->sd_rindex_recent_list, rd_recent) {
1036 if (rgd == new_rgd)
1037 goto out;
1038
1039 if (++count >= max)
1040 goto out;
1041 }
1042 list_add_tail(&new_rgd->rd_recent, &sdp->sd_rindex_recent_list);
1043
1044out:
1045 spin_unlock(&sdp->sd_rindex_spin);
1046}
1047
1048/**
1049 * forward_rgrp_get - get an rgrp to try next from full list 967 * forward_rgrp_get - get an rgrp to try next from full list
1050 * @sdp: The GFS2 superblock 968 * @sdp: The GFS2 superblock
1051 * 969 *
@@ -1112,9 +1030,7 @@ static struct inode *get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked)
1112 int loops = 0; 1030 int loops = 0;
1113 int error, rg_locked; 1031 int error, rg_locked;
1114 1032
1115 /* Try recently successful rgrps */ 1033 rgd = gfs2_blk2rgrpd(sdp, ip->i_goal);
1116
1117 rgd = recent_rgrp_first(sdp, ip->i_goal);
1118 1034
1119 while (rgd) { 1035 while (rgd) {
1120 rg_locked = 0; 1036 rg_locked = 0;
@@ -1136,11 +1052,9 @@ static struct inode *get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked)
1136 gfs2_glock_dq_uninit(&al->al_rgd_gh); 1052 gfs2_glock_dq_uninit(&al->al_rgd_gh);
1137 if (inode) 1053 if (inode)
1138 return inode; 1054 return inode;
1139 rgd = recent_rgrp_next(rgd, 1); 1055 /* fall through */
1140 break;
1141
1142 case GLR_TRYFAILED: 1056 case GLR_TRYFAILED:
1143 rgd = recent_rgrp_next(rgd, 0); 1057 rgd = recent_rgrp_next(rgd);
1144 break; 1058 break;
1145 1059
1146 default: 1060 default:
@@ -1199,7 +1113,9 @@ static struct inode *get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked)
1199 1113
1200out: 1114out:
1201 if (begin) { 1115 if (begin) {
1202 recent_rgrp_add(rgd); 1116 spin_lock(&sdp->sd_rindex_spin);
1117 list_move(&rgd->rd_list_mru, &sdp->sd_rindex_mru_list);
1118 spin_unlock(&sdp->sd_rindex_spin);
1203 rgd = gfs2_rgrpd_get_next(rgd); 1119 rgd = gfs2_rgrpd_get_next(rgd);
1204 if (!rgd) 1120 if (!rgd)
1205 rgd = gfs2_rgrpd_get_first(sdp); 1121 rgd = gfs2_rgrpd_get_first(sdp);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 7aeacbc65f3..63a8a902d9d 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -65,7 +65,6 @@ void gfs2_tune_init(struct gfs2_tune *gt)
65 gt->gt_quota_quantum = 60; 65 gt->gt_quota_quantum = 60;
66 gt->gt_atime_quantum = 3600; 66 gt->gt_atime_quantum = 3600;
67 gt->gt_new_files_jdata = 0; 67 gt->gt_new_files_jdata = 0;
68 gt->gt_new_files_directio = 0;
69 gt->gt_max_readahead = 1 << 18; 68 gt->gt_max_readahead = 1 << 18;
70 gt->gt_stall_secs = 600; 69 gt->gt_stall_secs = 600;
71 gt->gt_complain_secs = 10; 70 gt->gt_complain_secs = 10;
@@ -941,8 +940,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
941 } 940 }
942 941
943 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED, 942 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED,
944 LM_FLAG_PRIORITY | GL_NOCACHE, 943 GL_NOCACHE, t_gh);
945 t_gh);
946 944
947 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { 945 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
948 error = gfs2_jdesc_check(jd); 946 error = gfs2_jdesc_check(jd);
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 9ab9fc85ecd..74846559fc3 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -110,18 +110,6 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf,
110 return len; 110 return len;
111} 111}
112 112
113static ssize_t shrink_store(struct gfs2_sbd *sdp, const char *buf, size_t len)
114{
115 if (!capable(CAP_SYS_ADMIN))
116 return -EACCES;
117
118 if (simple_strtol(buf, NULL, 0) != 1)
119 return -EINVAL;
120
121 gfs2_gl_hash_clear(sdp, NO_WAIT);
122 return len;
123}
124
125static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, 113static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf,
126 size_t len) 114 size_t len)
127{ 115{
@@ -175,7 +163,6 @@ static struct gfs2_attr gfs2_attr_##name = __ATTR(name, mode, show, store)
175GFS2_ATTR(id, 0444, id_show, NULL); 163GFS2_ATTR(id, 0444, id_show, NULL);
176GFS2_ATTR(fsname, 0444, fsname_show, NULL); 164GFS2_ATTR(fsname, 0444, fsname_show, NULL);
177GFS2_ATTR(freeze, 0644, freeze_show, freeze_store); 165GFS2_ATTR(freeze, 0644, freeze_show, freeze_store);
178GFS2_ATTR(shrink, 0200, NULL, shrink_store);
179GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store); 166GFS2_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
180GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store); 167GFS2_ATTR(statfs_sync, 0200, NULL, statfs_sync_store);
181GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store); 168GFS2_ATTR(quota_sync, 0200, NULL, quota_sync_store);
@@ -186,7 +173,6 @@ static struct attribute *gfs2_attrs[] = {
186 &gfs2_attr_id.attr, 173 &gfs2_attr_id.attr,
187 &gfs2_attr_fsname.attr, 174 &gfs2_attr_fsname.attr,
188 &gfs2_attr_freeze.attr, 175 &gfs2_attr_freeze.attr,
189 &gfs2_attr_shrink.attr,
190 &gfs2_attr_withdraw.attr, 176 &gfs2_attr_withdraw.attr,
191 &gfs2_attr_statfs_sync.attr, 177 &gfs2_attr_statfs_sync.attr,
192 &gfs2_attr_quota_sync.attr, 178 &gfs2_attr_quota_sync.attr,
@@ -426,7 +412,6 @@ TUNE_ATTR(max_readahead, 0);
426TUNE_ATTR(complain_secs, 0); 412TUNE_ATTR(complain_secs, 0);
427TUNE_ATTR(statfs_slow, 0); 413TUNE_ATTR(statfs_slow, 0);
428TUNE_ATTR(new_files_jdata, 0); 414TUNE_ATTR(new_files_jdata, 0);
429TUNE_ATTR(new_files_directio, 0);
430TUNE_ATTR(quota_simul_sync, 1); 415TUNE_ATTR(quota_simul_sync, 1);
431TUNE_ATTR(quota_cache_secs, 1); 416TUNE_ATTR(quota_cache_secs, 1);
432TUNE_ATTR(stall_secs, 1); 417TUNE_ATTR(stall_secs, 1);
@@ -455,7 +440,6 @@ static struct attribute *tune_attrs[] = {
455 &tune_attr_quotad_secs.attr, 440 &tune_attr_quotad_secs.attr,
456 &tune_attr_quota_scale.attr, 441 &tune_attr_quota_scale.attr,
457 &tune_attr_new_files_jdata.attr, 442 &tune_attr_new_files_jdata.attr,
458 &tune_attr_new_files_directio.attr,
459 NULL, 443 NULL,
460}; 444};
461 445
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 6914598022c..91389c8aee8 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -688,7 +688,6 @@ void __jbd2_journal_drop_transaction(journal_t *journal, transaction_t *transact
688 688
689 J_ASSERT(transaction->t_state == T_FINISHED); 689 J_ASSERT(transaction->t_state == T_FINISHED);
690 J_ASSERT(transaction->t_buffers == NULL); 690 J_ASSERT(transaction->t_buffers == NULL);
691 J_ASSERT(transaction->t_sync_datalist == NULL);
692 J_ASSERT(transaction->t_forget == NULL); 691 J_ASSERT(transaction->t_forget == NULL);
693 J_ASSERT(transaction->t_iobuf_list == NULL); 692 J_ASSERT(transaction->t_iobuf_list == NULL);
694 J_ASSERT(transaction->t_shadow_list == NULL); 693 J_ASSERT(transaction->t_shadow_list == NULL);
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index a2ed72f7cee..f8b3be87322 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -22,6 +22,8 @@
22#include <linux/pagemap.h> 22#include <linux/pagemap.h>
23#include <linux/jiffies.h> 23#include <linux/jiffies.h>
24#include <linux/crc32.h> 24#include <linux/crc32.h>
25#include <linux/writeback.h>
26#include <linux/backing-dev.h>
25 27
26/* 28/*
27 * Default IO end handler for temporary BJ_IO buffer_heads. 29 * Default IO end handler for temporary BJ_IO buffer_heads.
@@ -37,8 +39,8 @@ static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate)
37} 39}
38 40
39/* 41/*
40 * When an ext3-ordered file is truncated, it is possible that many pages are 42 * When an ext4 file is truncated, it is possible that some pages are not
41 * not sucessfully freed, because they are attached to a committing transaction. 43 * successfully freed, because they are attached to a committing transaction.
42 * After the transaction commits, these pages are left on the LRU, with no 44 * After the transaction commits, these pages are left on the LRU, with no
43 * ->mapping, and with attached buffers. These pages are trivially reclaimable 45 * ->mapping, and with attached buffers. These pages are trivially reclaimable
44 * by the VM, but their apparent absence upsets the VM accounting, and it makes 46 * by the VM, but their apparent absence upsets the VM accounting, and it makes
@@ -80,21 +82,6 @@ nope:
80} 82}
81 83
82/* 84/*
83 * Try to acquire jbd_lock_bh_state() against the buffer, when j_list_lock is
84 * held. For ranking reasons we must trylock. If we lose, schedule away and
85 * return 0. j_list_lock is dropped in this case.
86 */
87static int inverted_lock(journal_t *journal, struct buffer_head *bh)
88{
89 if (!jbd_trylock_bh_state(bh)) {
90 spin_unlock(&journal->j_list_lock);
91 schedule();
92 return 0;
93 }
94 return 1;
95}
96
97/*
98 * Done it all: now submit the commit record. We should have 85 * Done it all: now submit the commit record. We should have
99 * cleaned up our previous buffers by now, so if we are in abort 86 * cleaned up our previous buffers by now, so if we are in abort
100 * mode we can now just skip the rest of the journal write 87 * mode we can now just skip the rest of the journal write
@@ -112,6 +99,7 @@ static int journal_submit_commit_record(journal_t *journal,
112 struct buffer_head *bh; 99 struct buffer_head *bh;
113 int ret; 100 int ret;
114 int barrier_done = 0; 101 int barrier_done = 0;
102 struct timespec now = current_kernel_time();
115 103
116 if (is_journal_aborted(journal)) 104 if (is_journal_aborted(journal))
117 return 0; 105 return 0;
@@ -126,6 +114,8 @@ static int journal_submit_commit_record(journal_t *journal,
126 tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER); 114 tmp->h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
127 tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK); 115 tmp->h_blocktype = cpu_to_be32(JBD2_COMMIT_BLOCK);
128 tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid); 116 tmp->h_sequence = cpu_to_be32(commit_transaction->t_tid);
117 tmp->h_commit_sec = cpu_to_be64(now.tv_sec);
118 tmp->h_commit_nsec = cpu_to_be32(now.tv_nsec);
129 119
130 if (JBD2_HAS_COMPAT_FEATURE(journal, 120 if (JBD2_HAS_COMPAT_FEATURE(journal,
131 JBD2_FEATURE_COMPAT_CHECKSUM)) { 121 JBD2_FEATURE_COMPAT_CHECKSUM)) {
@@ -197,159 +187,104 @@ static int journal_wait_on_commit_record(struct buffer_head *bh)
197} 187}
198 188
199/* 189/*
200 * Wait for all submitted IO to complete. 190 * write the filemap data using writepage() address_space_operations.
191 * We don't do block allocation here even for delalloc. We don't
192 * use writepages() because with dealyed allocation we may be doing
193 * block allocation in writepages().
201 */ 194 */
202static int journal_wait_on_locked_list(journal_t *journal, 195static int journal_submit_inode_data_buffers(struct address_space *mapping)
203 transaction_t *commit_transaction)
204{ 196{
205 int ret = 0; 197 int ret;
206 struct journal_head *jh; 198 struct writeback_control wbc = {
207 199 .sync_mode = WB_SYNC_ALL,
208 while (commit_transaction->t_locked_list) { 200 .nr_to_write = mapping->nrpages * 2,
209 struct buffer_head *bh; 201 .range_start = 0,
210 202 .range_end = i_size_read(mapping->host),
211 jh = commit_transaction->t_locked_list->b_tprev; 203 .for_writepages = 1,
212 bh = jh2bh(jh); 204 };
213 get_bh(bh); 205
214 if (buffer_locked(bh)) { 206 ret = generic_writepages(mapping, &wbc);
215 spin_unlock(&journal->j_list_lock);
216 wait_on_buffer(bh);
217 if (unlikely(!buffer_uptodate(bh)))
218 ret = -EIO;
219 spin_lock(&journal->j_list_lock);
220 }
221 if (!inverted_lock(journal, bh)) {
222 put_bh(bh);
223 spin_lock(&journal->j_list_lock);
224 continue;
225 }
226 if (buffer_jbd(bh) && jh->b_jlist == BJ_Locked) {
227 __jbd2_journal_unfile_buffer(jh);
228 jbd_unlock_bh_state(bh);
229 jbd2_journal_remove_journal_head(bh);
230 put_bh(bh);
231 } else {
232 jbd_unlock_bh_state(bh);
233 }
234 put_bh(bh);
235 cond_resched_lock(&journal->j_list_lock);
236 }
237 return ret; 207 return ret;
238 } 208}
239 209
240static void journal_do_submit_data(struct buffer_head **wbuf, int bufs) 210/*
211 * Submit all the data buffers of inode associated with the transaction to
212 * disk.
213 *
214 * We are in a committing transaction. Therefore no new inode can be added to
215 * our inode list. We use JI_COMMIT_RUNNING flag to protect inode we currently
216 * operate on from being released while we write out pages.
217 */
218static int journal_submit_data_buffers(journal_t *journal,
219 transaction_t *commit_transaction)
241{ 220{
242 int i; 221 struct jbd2_inode *jinode;
222 int err, ret = 0;
223 struct address_space *mapping;
243 224
244 for (i = 0; i < bufs; i++) { 225 spin_lock(&journal->j_list_lock);
245 wbuf[i]->b_end_io = end_buffer_write_sync; 226 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
246 /* We use-up our safety reference in submit_bh() */ 227 mapping = jinode->i_vfs_inode->i_mapping;
247 submit_bh(WRITE, wbuf[i]); 228 jinode->i_flags |= JI_COMMIT_RUNNING;
229 spin_unlock(&journal->j_list_lock);
230 /*
231 * submit the inode data buffers. We use writepage
232 * instead of writepages. Because writepages can do
233 * block allocation with delalloc. We need to write
234 * only allocated blocks here.
235 */
236 err = journal_submit_inode_data_buffers(mapping);
237 if (!ret)
238 ret = err;
239 spin_lock(&journal->j_list_lock);
240 J_ASSERT(jinode->i_transaction == commit_transaction);
241 jinode->i_flags &= ~JI_COMMIT_RUNNING;
242 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
248 } 243 }
244 spin_unlock(&journal->j_list_lock);
245 return ret;
249} 246}
250 247
251/* 248/*
252 * Submit all the data buffers to disk 249 * Wait for data submitted for writeout, refile inodes to proper
250 * transaction if needed.
251 *
253 */ 252 */
254static void journal_submit_data_buffers(journal_t *journal, 253static int journal_finish_inode_data_buffers(journal_t *journal,
255 transaction_t *commit_transaction) 254 transaction_t *commit_transaction)
256{ 255{
257 struct journal_head *jh; 256 struct jbd2_inode *jinode, *next_i;
258 struct buffer_head *bh; 257 int err, ret = 0;
259 int locked;
260 int bufs = 0;
261 struct buffer_head **wbuf = journal->j_wbuf;
262 258
263 /* 259 /* For locking, see the comment in journal_submit_data_buffers() */
264 * Whenever we unlock the journal and sleep, things can get added
265 * onto ->t_sync_datalist, so we have to keep looping back to
266 * write_out_data until we *know* that the list is empty.
267 *
268 * Cleanup any flushed data buffers from the data list. Even in
269 * abort mode, we want to flush this out as soon as possible.
270 */
271write_out_data:
272 cond_resched();
273 spin_lock(&journal->j_list_lock); 260 spin_lock(&journal->j_list_lock);
261 list_for_each_entry(jinode, &commit_transaction->t_inode_list, i_list) {
262 jinode->i_flags |= JI_COMMIT_RUNNING;
263 spin_unlock(&journal->j_list_lock);
264 err = filemap_fdatawait(jinode->i_vfs_inode->i_mapping);
265 if (!ret)
266 ret = err;
267 spin_lock(&journal->j_list_lock);
268 jinode->i_flags &= ~JI_COMMIT_RUNNING;
269 wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING);
270 }
274 271
275 while (commit_transaction->t_sync_datalist) { 272 /* Now refile inode to proper lists */
276 jh = commit_transaction->t_sync_datalist; 273 list_for_each_entry_safe(jinode, next_i,
277 bh = jh2bh(jh); 274 &commit_transaction->t_inode_list, i_list) {
278 locked = 0; 275 list_del(&jinode->i_list);
279 276 if (jinode->i_next_transaction) {
280 /* Get reference just to make sure buffer does not disappear 277 jinode->i_transaction = jinode->i_next_transaction;
281 * when we are forced to drop various locks */ 278 jinode->i_next_transaction = NULL;
282 get_bh(bh); 279 list_add(&jinode->i_list,
283 /* If the buffer is dirty, we need to submit IO and hence 280 &jinode->i_transaction->t_inode_list);
284 * we need the buffer lock. We try to lock the buffer without
285 * blocking. If we fail, we need to drop j_list_lock and do
286 * blocking lock_buffer().
287 */
288 if (buffer_dirty(bh)) {
289 if (test_set_buffer_locked(bh)) {
290 BUFFER_TRACE(bh, "needs blocking lock");
291 spin_unlock(&journal->j_list_lock);
292 /* Write out all data to prevent deadlocks */
293 journal_do_submit_data(wbuf, bufs);
294 bufs = 0;
295 lock_buffer(bh);
296 spin_lock(&journal->j_list_lock);
297 }
298 locked = 1;
299 }
300 /* We have to get bh_state lock. Again out of order, sigh. */
301 if (!inverted_lock(journal, bh)) {
302 jbd_lock_bh_state(bh);
303 spin_lock(&journal->j_list_lock);
304 }
305 /* Someone already cleaned up the buffer? */
306 if (!buffer_jbd(bh)
307 || jh->b_transaction != commit_transaction
308 || jh->b_jlist != BJ_SyncData) {
309 jbd_unlock_bh_state(bh);
310 if (locked)
311 unlock_buffer(bh);
312 BUFFER_TRACE(bh, "already cleaned up");
313 put_bh(bh);
314 continue;
315 }
316 if (locked && test_clear_buffer_dirty(bh)) {
317 BUFFER_TRACE(bh, "needs writeout, adding to array");
318 wbuf[bufs++] = bh;
319 __jbd2_journal_file_buffer(jh, commit_transaction,
320 BJ_Locked);
321 jbd_unlock_bh_state(bh);
322 if (bufs == journal->j_wbufsize) {
323 spin_unlock(&journal->j_list_lock);
324 journal_do_submit_data(wbuf, bufs);
325 bufs = 0;
326 goto write_out_data;
327 }
328 } else if (!locked && buffer_locked(bh)) {
329 __jbd2_journal_file_buffer(jh, commit_transaction,
330 BJ_Locked);
331 jbd_unlock_bh_state(bh);
332 put_bh(bh);
333 } else { 281 } else {
334 BUFFER_TRACE(bh, "writeout complete: unfile"); 282 jinode->i_transaction = NULL;
335 __jbd2_journal_unfile_buffer(jh);
336 jbd_unlock_bh_state(bh);
337 if (locked)
338 unlock_buffer(bh);
339 jbd2_journal_remove_journal_head(bh);
340 /* Once for our safety reference, once for
341 * jbd2_journal_remove_journal_head() */
342 put_bh(bh);
343 put_bh(bh);
344 }
345
346 if (need_resched() || spin_needbreak(&journal->j_list_lock)) {
347 spin_unlock(&journal->j_list_lock);
348 goto write_out_data;
349 } 283 }
350 } 284 }
351 spin_unlock(&journal->j_list_lock); 285 spin_unlock(&journal->j_list_lock);
352 journal_do_submit_data(wbuf, bufs); 286
287 return ret;
353} 288}
354 289
355static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh) 290static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh)
@@ -524,21 +459,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
524 * Now start flushing things to disk, in the order they appear 459 * Now start flushing things to disk, in the order they appear
525 * on the transaction lists. Data blocks go first. 460 * on the transaction lists. Data blocks go first.
526 */ 461 */
527 err = 0; 462 err = journal_submit_data_buffers(journal, commit_transaction);
528 journal_submit_data_buffers(journal, commit_transaction);
529
530 /*
531 * Wait for all previously submitted IO to complete if commit
532 * record is to be written synchronously.
533 */
534 spin_lock(&journal->j_list_lock);
535 if (!JBD2_HAS_INCOMPAT_FEATURE(journal,
536 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT))
537 err = journal_wait_on_locked_list(journal,
538 commit_transaction);
539
540 spin_unlock(&journal->j_list_lock);
541
542 if (err) 463 if (err)
543 jbd2_journal_abort(journal, err); 464 jbd2_journal_abort(journal, err);
544 465
@@ -547,16 +468,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
547 jbd_debug(3, "JBD: commit phase 2\n"); 468 jbd_debug(3, "JBD: commit phase 2\n");
548 469
549 /* 470 /*
550 * If we found any dirty or locked buffers, then we should have
551 * looped back up to the write_out_data label. If there weren't
552 * any then journal_clean_data_list should have wiped the list
553 * clean by now, so check that it is in fact empty.
554 */
555 J_ASSERT (commit_transaction->t_sync_datalist == NULL);
556
557 jbd_debug (3, "JBD: commit phase 3\n");
558
559 /*
560 * Way to go: we have now written out all of the data for a 471 * Way to go: we have now written out all of the data for a
561 * transaction! Now comes the tricky part: we need to write out 472 * transaction! Now comes the tricky part: we need to write out
562 * metadata. Loop over the transaction's entire buffer list: 473 * metadata. Loop over the transaction's entire buffer list:
@@ -574,6 +485,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
574 J_ASSERT(commit_transaction->t_nr_buffers <= 485 J_ASSERT(commit_transaction->t_nr_buffers <=
575 commit_transaction->t_outstanding_credits); 486 commit_transaction->t_outstanding_credits);
576 487
488 err = 0;
577 descriptor = NULL; 489 descriptor = NULL;
578 bufs = 0; 490 bufs = 0;
579 while (commit_transaction->t_buffers) { 491 while (commit_transaction->t_buffers) {
@@ -748,15 +660,19 @@ start_journal_io:
748 &cbh, crc32_sum); 660 &cbh, crc32_sum);
749 if (err) 661 if (err)
750 __jbd2_journal_abort_hard(journal); 662 __jbd2_journal_abort_hard(journal);
751
752 spin_lock(&journal->j_list_lock);
753 err = journal_wait_on_locked_list(journal,
754 commit_transaction);
755 spin_unlock(&journal->j_list_lock);
756 if (err)
757 __jbd2_journal_abort_hard(journal);
758 } 663 }
759 664
665 /*
666 * This is the right place to wait for data buffers both for ASYNC
667 * and !ASYNC commit. If commit is ASYNC, we need to wait only after
668 * the commit block went to disk (which happens above). If commit is
669 * SYNC, we need to wait for data buffers before we start writing
670 * commit block, which happens below in such setting.
671 */
672 err = journal_finish_inode_data_buffers(journal, commit_transaction);
673 if (err)
674 jbd2_journal_abort(journal, err);
675
760 /* Lo and behold: we have just managed to send a transaction to 676 /* Lo and behold: we have just managed to send a transaction to
761 the log. Before we can commit it, wait for the IO so far to 677 the log. Before we can commit it, wait for the IO so far to
762 complete. Control buffers being written are on the 678 complete. Control buffers being written are on the
@@ -768,7 +684,7 @@ start_journal_io:
768 so we incur less scheduling load. 684 so we incur less scheduling load.
769 */ 685 */
770 686
771 jbd_debug(3, "JBD: commit phase 4\n"); 687 jbd_debug(3, "JBD: commit phase 3\n");
772 688
773 /* 689 /*
774 * akpm: these are BJ_IO, and j_list_lock is not needed. 690 * akpm: these are BJ_IO, and j_list_lock is not needed.
@@ -827,7 +743,7 @@ wait_for_iobuf:
827 743
828 J_ASSERT (commit_transaction->t_shadow_list == NULL); 744 J_ASSERT (commit_transaction->t_shadow_list == NULL);
829 745
830 jbd_debug(3, "JBD: commit phase 5\n"); 746 jbd_debug(3, "JBD: commit phase 4\n");
831 747
832 /* Here we wait for the revoke record and descriptor record buffers */ 748 /* Here we wait for the revoke record and descriptor record buffers */
833 wait_for_ctlbuf: 749 wait_for_ctlbuf:
@@ -854,7 +770,7 @@ wait_for_iobuf:
854 /* AKPM: bforget here */ 770 /* AKPM: bforget here */
855 } 771 }
856 772
857 jbd_debug(3, "JBD: commit phase 6\n"); 773 jbd_debug(3, "JBD: commit phase 5\n");
858 774
859 if (!JBD2_HAS_INCOMPAT_FEATURE(journal, 775 if (!JBD2_HAS_INCOMPAT_FEATURE(journal,
860 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) { 776 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)) {
@@ -874,9 +790,9 @@ wait_for_iobuf:
874 transaction can be removed from any checkpoint list it was on 790 transaction can be removed from any checkpoint list it was on
875 before. */ 791 before. */
876 792
877 jbd_debug(3, "JBD: commit phase 7\n"); 793 jbd_debug(3, "JBD: commit phase 6\n");
878 794
879 J_ASSERT(commit_transaction->t_sync_datalist == NULL); 795 J_ASSERT(list_empty(&commit_transaction->t_inode_list));
880 J_ASSERT(commit_transaction->t_buffers == NULL); 796 J_ASSERT(commit_transaction->t_buffers == NULL);
881 J_ASSERT(commit_transaction->t_checkpoint_list == NULL); 797 J_ASSERT(commit_transaction->t_checkpoint_list == NULL);
882 J_ASSERT(commit_transaction->t_iobuf_list == NULL); 798 J_ASSERT(commit_transaction->t_iobuf_list == NULL);
@@ -997,7 +913,7 @@ restart_loop:
997 913
998 /* Done with this transaction! */ 914 /* Done with this transaction! */
999 915
1000 jbd_debug(3, "JBD: commit phase 8\n"); 916 jbd_debug(3, "JBD: commit phase 7\n");
1001 917
1002 J_ASSERT(commit_transaction->t_state == T_COMMIT); 918 J_ASSERT(commit_transaction->t_state == T_COMMIT);
1003 919
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 2e24567c4a7..b26c6d9fe6a 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -50,7 +50,6 @@ EXPORT_SYMBOL(jbd2_journal_unlock_updates);
50EXPORT_SYMBOL(jbd2_journal_get_write_access); 50EXPORT_SYMBOL(jbd2_journal_get_write_access);
51EXPORT_SYMBOL(jbd2_journal_get_create_access); 51EXPORT_SYMBOL(jbd2_journal_get_create_access);
52EXPORT_SYMBOL(jbd2_journal_get_undo_access); 52EXPORT_SYMBOL(jbd2_journal_get_undo_access);
53EXPORT_SYMBOL(jbd2_journal_dirty_data);
54EXPORT_SYMBOL(jbd2_journal_dirty_metadata); 53EXPORT_SYMBOL(jbd2_journal_dirty_metadata);
55EXPORT_SYMBOL(jbd2_journal_release_buffer); 54EXPORT_SYMBOL(jbd2_journal_release_buffer);
56EXPORT_SYMBOL(jbd2_journal_forget); 55EXPORT_SYMBOL(jbd2_journal_forget);
@@ -82,6 +81,10 @@ EXPORT_SYMBOL(jbd2_journal_blocks_per_page);
82EXPORT_SYMBOL(jbd2_journal_invalidatepage); 81EXPORT_SYMBOL(jbd2_journal_invalidatepage);
83EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers); 82EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
84EXPORT_SYMBOL(jbd2_journal_force_commit); 83EXPORT_SYMBOL(jbd2_journal_force_commit);
84EXPORT_SYMBOL(jbd2_journal_file_inode);
85EXPORT_SYMBOL(jbd2_journal_init_jbd_inode);
86EXPORT_SYMBOL(jbd2_journal_release_jbd_inode);
87EXPORT_SYMBOL(jbd2_journal_begin_ordered_truncate);
85 88
86static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *); 89static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
87static void __journal_abort_soft (journal_t *journal, int errno); 90static void __journal_abort_soft (journal_t *journal, int errno);
@@ -2195,6 +2198,54 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
2195} 2198}
2196 2199
2197/* 2200/*
2201 * Initialize jbd inode head
2202 */
2203void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode)
2204{
2205 jinode->i_transaction = NULL;
2206 jinode->i_next_transaction = NULL;
2207 jinode->i_vfs_inode = inode;
2208 jinode->i_flags = 0;
2209 INIT_LIST_HEAD(&jinode->i_list);
2210}
2211
2212/*
2213 * Function to be called before we start removing inode from memory (i.e.,
2214 * clear_inode() is a fine place to be called from). It removes inode from
2215 * transaction's lists.
2216 */
2217void jbd2_journal_release_jbd_inode(journal_t *journal,
2218 struct jbd2_inode *jinode)
2219{
2220 int writeout = 0;
2221
2222 if (!journal)
2223 return;
2224restart:
2225 spin_lock(&journal->j_list_lock);
2226 /* Is commit writing out inode - we have to wait */
2227 if (jinode->i_flags & JI_COMMIT_RUNNING) {
2228 wait_queue_head_t *wq;
2229 DEFINE_WAIT_BIT(wait, &jinode->i_flags, __JI_COMMIT_RUNNING);
2230 wq = bit_waitqueue(&jinode->i_flags, __JI_COMMIT_RUNNING);
2231 prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
2232 spin_unlock(&journal->j_list_lock);
2233 schedule();
2234 finish_wait(wq, &wait.wait);
2235 goto restart;
2236 }
2237
2238 /* Do we need to wait for data writeback? */
2239 if (journal->j_committing_transaction == jinode->i_transaction)
2240 writeout = 1;
2241 if (jinode->i_transaction) {
2242 list_del(&jinode->i_list);
2243 jinode->i_transaction = NULL;
2244 }
2245 spin_unlock(&journal->j_list_lock);
2246}
2247
2248/*
2198 * debugfs tunables 2249 * debugfs tunables
2199 */ 2250 */
2200#ifdef CONFIG_JBD2_DEBUG 2251#ifdef CONFIG_JBD2_DEBUG
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index d6e006e6780..4f7cadbb19f 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -41,7 +41,6 @@ static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
41 * new transaction and we can't block without protecting against other 41 * new transaction and we can't block without protecting against other
42 * processes trying to touch the journal while it is in transition. 42 * processes trying to touch the journal while it is in transition.
43 * 43 *
44 * Called under j_state_lock
45 */ 44 */
46 45
47static transaction_t * 46static transaction_t *
@@ -52,6 +51,7 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction)
52 transaction->t_tid = journal->j_transaction_sequence++; 51 transaction->t_tid = journal->j_transaction_sequence++;
53 transaction->t_expires = jiffies + journal->j_commit_interval; 52 transaction->t_expires = jiffies + journal->j_commit_interval;
54 spin_lock_init(&transaction->t_handle_lock); 53 spin_lock_init(&transaction->t_handle_lock);
54 INIT_LIST_HEAD(&transaction->t_inode_list);
55 55
56 /* Set up the commit timer for the new transaction. */ 56 /* Set up the commit timer for the new transaction. */
57 journal->j_commit_timer.expires = round_jiffies(transaction->t_expires); 57 journal->j_commit_timer.expires = round_jiffies(transaction->t_expires);
@@ -943,183 +943,6 @@ out:
943} 943}
944 944
945/** 945/**
946 * int jbd2_journal_dirty_data() - mark a buffer as containing dirty data which
947 * needs to be flushed before we can commit the
948 * current transaction.
949 * @handle: transaction
950 * @bh: bufferhead to mark
951 *
952 * The buffer is placed on the transaction's data list and is marked as
953 * belonging to the transaction.
954 *
955 * Returns error number or 0 on success.
956 *
957 * jbd2_journal_dirty_data() can be called via page_launder->ext3_writepage
958 * by kswapd.
959 */
960int jbd2_journal_dirty_data(handle_t *handle, struct buffer_head *bh)
961{
962 journal_t *journal = handle->h_transaction->t_journal;
963 int need_brelse = 0;
964 struct journal_head *jh;
965
966 if (is_handle_aborted(handle))
967 return 0;
968
969 jh = jbd2_journal_add_journal_head(bh);
970 JBUFFER_TRACE(jh, "entry");
971
972 /*
973 * The buffer could *already* be dirty. Writeout can start
974 * at any time.
975 */
976 jbd_debug(4, "jh: %p, tid:%d\n", jh, handle->h_transaction->t_tid);
977
978 /*
979 * What if the buffer is already part of a running transaction?
980 *
981 * There are two cases:
982 * 1) It is part of the current running transaction. Refile it,
983 * just in case we have allocated it as metadata, deallocated
984 * it, then reallocated it as data.
985 * 2) It is part of the previous, still-committing transaction.
986 * If all we want to do is to guarantee that the buffer will be
987 * written to disk before this new transaction commits, then
988 * being sure that the *previous* transaction has this same
989 * property is sufficient for us! Just leave it on its old
990 * transaction.
991 *
992 * In case (2), the buffer must not already exist as metadata
993 * --- that would violate write ordering (a transaction is free
994 * to write its data at any point, even before the previous
995 * committing transaction has committed). The caller must
996 * never, ever allow this to happen: there's nothing we can do
997 * about it in this layer.
998 */
999 jbd_lock_bh_state(bh);
1000 spin_lock(&journal->j_list_lock);
1001
1002 /* Now that we have bh_state locked, are we really still mapped? */
1003 if (!buffer_mapped(bh)) {
1004 JBUFFER_TRACE(jh, "unmapped buffer, bailing out");
1005 goto no_journal;
1006 }
1007
1008 if (jh->b_transaction) {
1009 JBUFFER_TRACE(jh, "has transaction");
1010 if (jh->b_transaction != handle->h_transaction) {
1011 JBUFFER_TRACE(jh, "belongs to older transaction");
1012 J_ASSERT_JH(jh, jh->b_transaction ==
1013 journal->j_committing_transaction);
1014
1015 /* @@@ IS THIS TRUE ? */
1016 /*
1017 * Not any more. Scenario: someone does a write()
1018 * in data=journal mode. The buffer's transaction has
1019 * moved into commit. Then someone does another
1020 * write() to the file. We do the frozen data copyout
1021 * and set b_next_transaction to point to j_running_t.
1022 * And while we're in that state, someone does a
1023 * writepage() in an attempt to pageout the same area
1024 * of the file via a shared mapping. At present that
1025 * calls jbd2_journal_dirty_data(), and we get right here.
1026 * It may be too late to journal the data. Simply
1027 * falling through to the next test will suffice: the
1028 * data will be dirty and wil be checkpointed. The
1029 * ordering comments in the next comment block still
1030 * apply.
1031 */
1032 //J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
1033
1034 /*
1035 * If we're journalling data, and this buffer was
1036 * subject to a write(), it could be metadata, forget
1037 * or shadow against the committing transaction. Now,
1038 * someone has dirtied the same darn page via a mapping
1039 * and it is being writepage()'d.
1040 * We *could* just steal the page from commit, with some
1041 * fancy locking there. Instead, we just skip it -
1042 * don't tie the page's buffers to the new transaction
1043 * at all.
1044 * Implication: if we crash before the writepage() data
1045 * is written into the filesystem, recovery will replay
1046 * the write() data.
1047 */
1048 if (jh->b_jlist != BJ_None &&
1049 jh->b_jlist != BJ_SyncData &&
1050 jh->b_jlist != BJ_Locked) {
1051 JBUFFER_TRACE(jh, "Not stealing");
1052 goto no_journal;
1053 }
1054
1055 /*
1056 * This buffer may be undergoing writeout in commit. We
1057 * can't return from here and let the caller dirty it
1058 * again because that can cause the write-out loop in
1059 * commit to never terminate.
1060 */
1061 if (buffer_dirty(bh)) {
1062 get_bh(bh);
1063 spin_unlock(&journal->j_list_lock);
1064 jbd_unlock_bh_state(bh);
1065 need_brelse = 1;
1066 sync_dirty_buffer(bh);
1067 jbd_lock_bh_state(bh);
1068 spin_lock(&journal->j_list_lock);
1069 /* Since we dropped the lock... */
1070 if (!buffer_mapped(bh)) {
1071 JBUFFER_TRACE(jh, "buffer got unmapped");
1072 goto no_journal;
1073 }
1074 /* The buffer may become locked again at any
1075 time if it is redirtied */
1076 }
1077
1078 /* journal_clean_data_list() may have got there first */
1079 if (jh->b_transaction != NULL) {
1080 JBUFFER_TRACE(jh, "unfile from commit");
1081 __jbd2_journal_temp_unlink_buffer(jh);
1082 /* It still points to the committing
1083 * transaction; move it to this one so
1084 * that the refile assert checks are
1085 * happy. */
1086 jh->b_transaction = handle->h_transaction;
1087 }
1088 /* The buffer will be refiled below */
1089
1090 }
1091 /*
1092 * Special case --- the buffer might actually have been
1093 * allocated and then immediately deallocated in the previous,
1094 * committing transaction, so might still be left on that
1095 * transaction's metadata lists.
1096 */
1097 if (jh->b_jlist != BJ_SyncData && jh->b_jlist != BJ_Locked) {
1098 JBUFFER_TRACE(jh, "not on correct data list: unfile");
1099 J_ASSERT_JH(jh, jh->b_jlist != BJ_Shadow);
1100 __jbd2_journal_temp_unlink_buffer(jh);
1101 jh->b_transaction = handle->h_transaction;
1102 JBUFFER_TRACE(jh, "file as data");
1103 __jbd2_journal_file_buffer(jh, handle->h_transaction,
1104 BJ_SyncData);
1105 }
1106 } else {
1107 JBUFFER_TRACE(jh, "not on a transaction");
1108 __jbd2_journal_file_buffer(jh, handle->h_transaction, BJ_SyncData);
1109 }
1110no_journal:
1111 spin_unlock(&journal->j_list_lock);
1112 jbd_unlock_bh_state(bh);
1113 if (need_brelse) {
1114 BUFFER_TRACE(bh, "brelse");
1115 __brelse(bh);
1116 }
1117 JBUFFER_TRACE(jh, "exit");
1118 jbd2_journal_put_journal_head(jh);
1119 return 0;
1120}
1121
1122/**
1123 * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata 946 * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata
1124 * @handle: transaction to add buffer to. 947 * @handle: transaction to add buffer to.
1125 * @bh: buffer to mark 948 * @bh: buffer to mark
@@ -1541,10 +1364,10 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
1541 * Remove a buffer from the appropriate transaction list. 1364 * Remove a buffer from the appropriate transaction list.
1542 * 1365 *
1543 * Note that this function can *change* the value of 1366 * Note that this function can *change* the value of
1544 * bh->b_transaction->t_sync_datalist, t_buffers, t_forget, 1367 * bh->b_transaction->t_buffers, t_forget, t_iobuf_list, t_shadow_list,
1545 * t_iobuf_list, t_shadow_list, t_log_list or t_reserved_list. If the caller 1368 * t_log_list or t_reserved_list. If the caller is holding onto a copy of one
1546 * is holding onto a copy of one of thee pointers, it could go bad. 1369 * of these pointers, it could go bad. Generally the caller needs to re-read
1547 * Generally the caller needs to re-read the pointer from the transaction_t. 1370 * the pointer from the transaction_t.
1548 * 1371 *
1549 * Called under j_list_lock. The journal may not be locked. 1372 * Called under j_list_lock. The journal may not be locked.
1550 */ 1373 */
@@ -1566,9 +1389,6 @@ void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
1566 switch (jh->b_jlist) { 1389 switch (jh->b_jlist) {
1567 case BJ_None: 1390 case BJ_None:
1568 return; 1391 return;
1569 case BJ_SyncData:
1570 list = &transaction->t_sync_datalist;
1571 break;
1572 case BJ_Metadata: 1392 case BJ_Metadata:
1573 transaction->t_nr_buffers--; 1393 transaction->t_nr_buffers--;
1574 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0); 1394 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0);
@@ -1589,9 +1409,6 @@ void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
1589 case BJ_Reserved: 1409 case BJ_Reserved:
1590 list = &transaction->t_reserved_list; 1410 list = &transaction->t_reserved_list;
1591 break; 1411 break;
1592 case BJ_Locked:
1593 list = &transaction->t_locked_list;
1594 break;
1595 } 1412 }
1596 1413
1597 __blist_del_buffer(list, jh); 1414 __blist_del_buffer(list, jh);
@@ -1634,15 +1451,7 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
1634 goto out; 1451 goto out;
1635 1452
1636 spin_lock(&journal->j_list_lock); 1453 spin_lock(&journal->j_list_lock);
1637 if (jh->b_transaction != NULL && jh->b_cp_transaction == NULL) { 1454 if (jh->b_cp_transaction != NULL && jh->b_transaction == NULL) {
1638 if (jh->b_jlist == BJ_SyncData || jh->b_jlist == BJ_Locked) {
1639 /* A written-back ordered data buffer */
1640 JBUFFER_TRACE(jh, "release data");
1641 __jbd2_journal_unfile_buffer(jh);
1642 jbd2_journal_remove_journal_head(bh);
1643 __brelse(bh);
1644 }
1645 } else if (jh->b_cp_transaction != NULL && jh->b_transaction == NULL) {
1646 /* written-back checkpointed metadata buffer */ 1455 /* written-back checkpointed metadata buffer */
1647 if (jh->b_jlist == BJ_None) { 1456 if (jh->b_jlist == BJ_None) {
1648 JBUFFER_TRACE(jh, "remove from checkpoint list"); 1457 JBUFFER_TRACE(jh, "remove from checkpoint list");
@@ -1656,12 +1465,43 @@ out:
1656 return; 1465 return;
1657} 1466}
1658 1467
1468/*
1469 * jbd2_journal_try_to_free_buffers() could race with
1470 * jbd2_journal_commit_transaction(). The later might still hold the
1471 * reference count to the buffers when inspecting them on
1472 * t_syncdata_list or t_locked_list.
1473 *
1474 * jbd2_journal_try_to_free_buffers() will call this function to
1475 * wait for the current transaction to finish syncing data buffers, before
1476 * try to free that buffer.
1477 *
1478 * Called with journal->j_state_lock hold.
1479 */
1480static void jbd2_journal_wait_for_transaction_sync_data(journal_t *journal)
1481{
1482 transaction_t *transaction;
1483 tid_t tid;
1484
1485 spin_lock(&journal->j_state_lock);
1486 transaction = journal->j_committing_transaction;
1487
1488 if (!transaction) {
1489 spin_unlock(&journal->j_state_lock);
1490 return;
1491 }
1492
1493 tid = transaction->t_tid;
1494 spin_unlock(&journal->j_state_lock);
1495 jbd2_log_wait_commit(journal, tid);
1496}
1659 1497
1660/** 1498/**
1661 * int jbd2_journal_try_to_free_buffers() - try to free page buffers. 1499 * int jbd2_journal_try_to_free_buffers() - try to free page buffers.
1662 * @journal: journal for operation 1500 * @journal: journal for operation
1663 * @page: to try and free 1501 * @page: to try and free
1664 * @unused_gfp_mask: unused 1502 * @gfp_mask: we use the mask to detect how hard should we try to release
1503 * buffers. If __GFP_WAIT and __GFP_FS is set, we wait for commit code to
1504 * release the buffers.
1665 * 1505 *
1666 * 1506 *
1667 * For all the buffers on this page, 1507 * For all the buffers on this page,
@@ -1690,9 +1530,11 @@ out:
1690 * journal_try_to_free_buffer() is changing its state. But that 1530 * journal_try_to_free_buffer() is changing its state. But that
1691 * cannot happen because we never reallocate freed data as metadata 1531 * cannot happen because we never reallocate freed data as metadata
1692 * while the data is part of a transaction. Yes? 1532 * while the data is part of a transaction. Yes?
1533 *
1534 * Return 0 on failure, 1 on success
1693 */ 1535 */
1694int jbd2_journal_try_to_free_buffers(journal_t *journal, 1536int jbd2_journal_try_to_free_buffers(journal_t *journal,
1695 struct page *page, gfp_t unused_gfp_mask) 1537 struct page *page, gfp_t gfp_mask)
1696{ 1538{
1697 struct buffer_head *head; 1539 struct buffer_head *head;
1698 struct buffer_head *bh; 1540 struct buffer_head *bh;
@@ -1708,7 +1550,8 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
1708 /* 1550 /*
1709 * We take our own ref against the journal_head here to avoid 1551 * We take our own ref against the journal_head here to avoid
1710 * having to add tons of locking around each instance of 1552 * having to add tons of locking around each instance of
1711 * jbd2_journal_remove_journal_head() and jbd2_journal_put_journal_head(). 1553 * jbd2_journal_remove_journal_head() and
1554 * jbd2_journal_put_journal_head().
1712 */ 1555 */
1713 jh = jbd2_journal_grab_journal_head(bh); 1556 jh = jbd2_journal_grab_journal_head(bh);
1714 if (!jh) 1557 if (!jh)
@@ -1721,7 +1564,28 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
1721 if (buffer_jbd(bh)) 1564 if (buffer_jbd(bh))
1722 goto busy; 1565 goto busy;
1723 } while ((bh = bh->b_this_page) != head); 1566 } while ((bh = bh->b_this_page) != head);
1567
1724 ret = try_to_free_buffers(page); 1568 ret = try_to_free_buffers(page);
1569
1570 /*
1571 * There are a number of places where jbd2_journal_try_to_free_buffers()
1572 * could race with jbd2_journal_commit_transaction(), the later still
1573 * holds the reference to the buffers to free while processing them.
1574 * try_to_free_buffers() failed to free those buffers. Some of the
1575 * caller of releasepage() request page buffers to be dropped, otherwise
1576 * treat the fail-to-free as errors (such as generic_file_direct_IO())
1577 *
1578 * So, if the caller of try_to_release_page() wants the synchronous
1579 * behaviour(i.e make sure buffers are dropped upon return),
1580 * let's wait for the current transaction to finish flush of
1581 * dirty data buffers, then try to free those buffers again,
1582 * with the journal locked.
1583 */
1584 if (ret == 0 && (gfp_mask & __GFP_WAIT) && (gfp_mask & __GFP_FS)) {
1585 jbd2_journal_wait_for_transaction_sync_data(journal);
1586 ret = try_to_free_buffers(page);
1587 }
1588
1725busy: 1589busy:
1726 return ret; 1590 return ret;
1727} 1591}
@@ -1823,6 +1687,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1823 if (!buffer_jbd(bh)) 1687 if (!buffer_jbd(bh))
1824 goto zap_buffer_unlocked; 1688 goto zap_buffer_unlocked;
1825 1689
1690 /* OK, we have data buffer in journaled mode */
1826 spin_lock(&journal->j_state_lock); 1691 spin_lock(&journal->j_state_lock);
1827 jbd_lock_bh_state(bh); 1692 jbd_lock_bh_state(bh);
1828 spin_lock(&journal->j_list_lock); 1693 spin_lock(&journal->j_list_lock);
@@ -1886,15 +1751,6 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
1886 } 1751 }
1887 } else if (transaction == journal->j_committing_transaction) { 1752 } else if (transaction == journal->j_committing_transaction) {
1888 JBUFFER_TRACE(jh, "on committing transaction"); 1753 JBUFFER_TRACE(jh, "on committing transaction");
1889 if (jh->b_jlist == BJ_Locked) {
1890 /*
1891 * The buffer is on the committing transaction's locked
1892 * list. We have the buffer locked, so I/O has
1893 * completed. So we can nail the buffer now.
1894 */
1895 may_free = __dispose_buffer(jh, transaction);
1896 goto zap_buffer;
1897 }
1898 /* 1754 /*
1899 * If it is committing, we simply cannot touch it. We 1755 * If it is committing, we simply cannot touch it. We
1900 * can remove it's next_transaction pointer from the 1756 * can remove it's next_transaction pointer from the
@@ -2027,9 +1883,6 @@ void __jbd2_journal_file_buffer(struct journal_head *jh,
2027 J_ASSERT_JH(jh, !jh->b_committed_data); 1883 J_ASSERT_JH(jh, !jh->b_committed_data);
2028 J_ASSERT_JH(jh, !jh->b_frozen_data); 1884 J_ASSERT_JH(jh, !jh->b_frozen_data);
2029 return; 1885 return;
2030 case BJ_SyncData:
2031 list = &transaction->t_sync_datalist;
2032 break;
2033 case BJ_Metadata: 1886 case BJ_Metadata:
2034 transaction->t_nr_buffers++; 1887 transaction->t_nr_buffers++;
2035 list = &transaction->t_buffers; 1888 list = &transaction->t_buffers;
@@ -2049,9 +1902,6 @@ void __jbd2_journal_file_buffer(struct journal_head *jh,
2049 case BJ_Reserved: 1902 case BJ_Reserved:
2050 list = &transaction->t_reserved_list; 1903 list = &transaction->t_reserved_list;
2051 break; 1904 break;
2052 case BJ_Locked:
2053 list = &transaction->t_locked_list;
2054 break;
2055 } 1905 }
2056 1906
2057 __blist_add_buffer(list, jh); 1907 __blist_add_buffer(list, jh);
@@ -2141,3 +1991,88 @@ void jbd2_journal_refile_buffer(journal_t *journal, struct journal_head *jh)
2141 spin_unlock(&journal->j_list_lock); 1991 spin_unlock(&journal->j_list_lock);
2142 __brelse(bh); 1992 __brelse(bh);
2143} 1993}
1994
1995/*
1996 * File inode in the inode list of the handle's transaction
1997 */
1998int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode)
1999{
2000 transaction_t *transaction = handle->h_transaction;
2001 journal_t *journal = transaction->t_journal;
2002
2003 if (is_handle_aborted(handle))
2004 return -EIO;
2005
2006 jbd_debug(4, "Adding inode %lu, tid:%d\n", jinode->i_vfs_inode->i_ino,
2007 transaction->t_tid);
2008
2009 /*
2010 * First check whether inode isn't already on the transaction's
2011 * lists without taking the lock. Note that this check is safe
2012 * without the lock as we cannot race with somebody removing inode
2013 * from the transaction. The reason is that we remove inode from the
2014 * transaction only in journal_release_jbd_inode() and when we commit
2015 * the transaction. We are guarded from the first case by holding
2016 * a reference to the inode. We are safe against the second case
2017 * because if jinode->i_transaction == transaction, commit code
2018 * cannot touch the transaction because we hold reference to it,
2019 * and if jinode->i_next_transaction == transaction, commit code
2020 * will only file the inode where we want it.
2021 */
2022 if (jinode->i_transaction == transaction ||
2023 jinode->i_next_transaction == transaction)
2024 return 0;
2025
2026 spin_lock(&journal->j_list_lock);
2027
2028 if (jinode->i_transaction == transaction ||
2029 jinode->i_next_transaction == transaction)
2030 goto done;
2031
2032 /* On some different transaction's list - should be
2033 * the committing one */
2034 if (jinode->i_transaction) {
2035 J_ASSERT(jinode->i_next_transaction == NULL);
2036 J_ASSERT(jinode->i_transaction ==
2037 journal->j_committing_transaction);
2038 jinode->i_next_transaction = transaction;
2039 goto done;
2040 }
2041 /* Not on any transaction list... */
2042 J_ASSERT(!jinode->i_next_transaction);
2043 jinode->i_transaction = transaction;
2044 list_add(&jinode->i_list, &transaction->t_inode_list);
2045done:
2046 spin_unlock(&journal->j_list_lock);
2047
2048 return 0;
2049}
2050
2051/*
2052 * This function must be called when inode is journaled in ordered mode
2053 * before truncation happens. It starts writeout of truncated part in
2054 * case it is in the committing transaction so that we stand to ordered
2055 * mode consistency guarantees.
2056 */
2057int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode,
2058 loff_t new_size)
2059{
2060 journal_t *journal;
2061 transaction_t *commit_trans;
2062 int ret = 0;
2063
2064 if (!inode->i_transaction && !inode->i_next_transaction)
2065 goto out;
2066 journal = inode->i_transaction->t_journal;
2067 spin_lock(&journal->j_state_lock);
2068 commit_trans = journal->j_committing_transaction;
2069 spin_unlock(&journal->j_state_lock);
2070 if (inode->i_transaction == commit_trans) {
2071 ret = filemap_fdatawrite_range(inode->i_vfs_inode->i_mapping,
2072 new_size, LLONG_MAX);
2073 if (ret)
2074 jbd2_journal_abort(journal, ret);
2075 }
2076out:
2077 return ret;
2078}
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index bf6ab19b86e..6a73de84bce 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -21,6 +21,7 @@
21#include <linux/ctype.h> 21#include <linux/ctype.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/proc_fs.h> 23#include <linux/proc_fs.h>
24#include <linux/seq_file.h>
24#include <asm/uaccess.h> 25#include <asm/uaccess.h>
25#include "jfs_incore.h" 26#include "jfs_incore.h"
26#include "jfs_filsys.h" 27#include "jfs_filsys.h"
@@ -30,29 +31,19 @@
30 31
31static struct proc_dir_entry *base; 32static struct proc_dir_entry *base;
32#ifdef CONFIG_JFS_DEBUG 33#ifdef CONFIG_JFS_DEBUG
33static int loglevel_read(char *page, char **start, off_t off, 34static int jfs_loglevel_proc_show(struct seq_file *m, void *v)
34 int count, int *eof, void *data)
35{ 35{
36 int len; 36 seq_printf(m, "%d\n", jfsloglevel);
37 37 return 0;
38 len = sprintf(page, "%d\n", jfsloglevel); 38}
39
40 len -= off;
41 *start = page + off;
42
43 if (len > count)
44 len = count;
45 else
46 *eof = 1;
47
48 if (len < 0)
49 len = 0;
50 39
51 return len; 40static int jfs_loglevel_proc_open(struct inode *inode, struct file *file)
41{
42 return single_open(file, jfs_loglevel_proc_show, NULL);
52} 43}
53 44
54static int loglevel_write(struct file *file, const char __user *buffer, 45static ssize_t jfs_loglevel_proc_write(struct file *file,
55 unsigned long count, void *data) 46 const char __user *buffer, size_t count, loff_t *ppos)
56{ 47{
57 char c; 48 char c;
58 49
@@ -65,22 +56,30 @@ static int loglevel_write(struct file *file, const char __user *buffer,
65 jfsloglevel = c - '0'; 56 jfsloglevel = c - '0';
66 return count; 57 return count;
67} 58}
59
60static const struct file_operations jfs_loglevel_proc_fops = {
61 .owner = THIS_MODULE,
62 .open = jfs_loglevel_proc_open,
63 .read = seq_read,
64 .llseek = seq_lseek,
65 .release = single_release,
66 .write = jfs_loglevel_proc_write,
67};
68#endif 68#endif
69 69
70static struct { 70static struct {
71 const char *name; 71 const char *name;
72 read_proc_t *read_fn; 72 const struct file_operations *proc_fops;
73 write_proc_t *write_fn;
74} Entries[] = { 73} Entries[] = {
75#ifdef CONFIG_JFS_STATISTICS 74#ifdef CONFIG_JFS_STATISTICS
76 { "lmstats", jfs_lmstats_read, }, 75 { "lmstats", &jfs_lmstats_proc_fops, },
77 { "txstats", jfs_txstats_read, }, 76 { "txstats", &jfs_txstats_proc_fops, },
78 { "xtstat", jfs_xtstat_read, }, 77 { "xtstat", &jfs_xtstat_proc_fops, },
79 { "mpstat", jfs_mpstat_read, }, 78 { "mpstat", &jfs_mpstat_proc_fops, },
80#endif 79#endif
81#ifdef CONFIG_JFS_DEBUG 80#ifdef CONFIG_JFS_DEBUG
82 { "TxAnchor", jfs_txanchor_read, }, 81 { "TxAnchor", &jfs_txanchor_proc_fops, },
83 { "loglevel", loglevel_read, loglevel_write } 82 { "loglevel", &jfs_loglevel_proc_fops }
84#endif 83#endif
85}; 84};
86#define NPROCENT ARRAY_SIZE(Entries) 85#define NPROCENT ARRAY_SIZE(Entries)
@@ -93,13 +92,8 @@ void jfs_proc_init(void)
93 return; 92 return;
94 base->owner = THIS_MODULE; 93 base->owner = THIS_MODULE;
95 94
96 for (i = 0; i < NPROCENT; i++) { 95 for (i = 0; i < NPROCENT; i++)
97 struct proc_dir_entry *p; 96 proc_create(Entries[i].name, 0, base, Entries[i].proc_fops);
98 if ((p = create_proc_entry(Entries[i].name, 0, base))) {
99 p->read_proc = Entries[i].read_fn;
100 p->write_proc = Entries[i].write_fn;
101 }
102 }
103} 97}
104 98
105void jfs_proc_clean(void) 99void jfs_proc_clean(void)
diff --git a/fs/jfs/jfs_debug.h b/fs/jfs/jfs_debug.h
index 044c1e654cc..eafd1300a00 100644
--- a/fs/jfs/jfs_debug.h
+++ b/fs/jfs/jfs_debug.h
@@ -62,7 +62,7 @@ extern void jfs_proc_clean(void);
62 62
63extern int jfsloglevel; 63extern int jfsloglevel;
64 64
65extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *); 65extern const struct file_operations jfs_txanchor_proc_fops;
66 66
67/* information message: e.g., configuration, major event */ 67/* information message: e.g., configuration, major event */
68#define jfs_info(fmt, arg...) do { \ 68#define jfs_info(fmt, arg...) do { \
@@ -105,10 +105,10 @@ extern int jfs_txanchor_read(char *, char **, off_t, int, int *, void *);
105 * ---------- 105 * ----------
106 */ 106 */
107#ifdef CONFIG_JFS_STATISTICS 107#ifdef CONFIG_JFS_STATISTICS
108extern int jfs_lmstats_read(char *, char **, off_t, int, int *, void *); 108extern const struct file_operations jfs_lmstats_proc_fops;
109extern int jfs_txstats_read(char *, char **, off_t, int, int *, void *); 109extern const struct file_operations jfs_txstats_proc_fops;
110extern int jfs_mpstat_read(char *, char **, off_t, int, int *, void *); 110extern const struct file_operations jfs_mpstat_proc_fops;
111extern int jfs_xtstat_read(char *, char **, off_t, int, int *, void *); 111extern const struct file_operations jfs_xtstat_proc_fops;
112 112
113#define INCREMENT(x) ((x)++) 113#define INCREMENT(x) ((x)++)
114#define DECREMENT(x) ((x)--) 114#define DECREMENT(x) ((x)--)
diff --git a/fs/jfs/jfs_dtree.h b/fs/jfs/jfs_dtree.h
index cdac2d5bafe..2545bb31723 100644
--- a/fs/jfs/jfs_dtree.h
+++ b/fs/jfs/jfs_dtree.h
@@ -243,9 +243,6 @@ typedef union {
243#define JFS_REMOVE 3 243#define JFS_REMOVE 3
244#define JFS_RENAME 4 244#define JFS_RENAME 4
245 245
246#define DIRENTSIZ(namlen) \
247 ( (sizeof(struct dirent) - 2*(JFS_NAME_MAX+1) + 2*((namlen)+1) + 3) &~ 3 )
248
249/* 246/*
250 * Maximum file offset for directories. 247 * Maximum file offset for directories.
251 */ 248 */
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 734ec916bea..d6363d8309d 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -1520,7 +1520,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
1520 jfs_error(ip->i_sb, 1520 jfs_error(ip->i_sb,
1521 "diAlloc: can't find free bit " 1521 "diAlloc: can't find free bit "
1522 "in wmap"); 1522 "in wmap");
1523 return EIO; 1523 return -EIO;
1524 } 1524 }
1525 1525
1526 /* determine the inode number within the 1526 /* determine the inode number within the
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 325a9679b95..cd2ec2988b5 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -69,6 +69,7 @@
69#include <linux/freezer.h> 69#include <linux/freezer.h>
70#include <linux/delay.h> 70#include <linux/delay.h>
71#include <linux/mutex.h> 71#include <linux/mutex.h>
72#include <linux/seq_file.h>
72#include "jfs_incore.h" 73#include "jfs_incore.h"
73#include "jfs_filsys.h" 74#include "jfs_filsys.h"
74#include "jfs_metapage.h" 75#include "jfs_metapage.h"
@@ -2503,13 +2504,9 @@ exit:
2503} 2504}
2504 2505
2505#ifdef CONFIG_JFS_STATISTICS 2506#ifdef CONFIG_JFS_STATISTICS
2506int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length, 2507static int jfs_lmstats_proc_show(struct seq_file *m, void *v)
2507 int *eof, void *data)
2508{ 2508{
2509 int len = 0; 2509 seq_printf(m,
2510 off_t begin;
2511
2512 len += sprintf(buffer,
2513 "JFS Logmgr stats\n" 2510 "JFS Logmgr stats\n"
2514 "================\n" 2511 "================\n"
2515 "commits = %d\n" 2512 "commits = %d\n"
@@ -2522,19 +2519,19 @@ int jfs_lmstats_read(char *buffer, char **start, off_t offset, int length,
2522 lmStat.pagedone, 2519 lmStat.pagedone,
2523 lmStat.full_page, 2520 lmStat.full_page,
2524 lmStat.partial_page); 2521 lmStat.partial_page);
2522 return 0;
2523}
2525 2524
2526 begin = offset; 2525static int jfs_lmstats_proc_open(struct inode *inode, struct file *file)
2527 *start = buffer + begin; 2526{
2528 len -= begin; 2527 return single_open(file, jfs_lmstats_proc_show, NULL);
2529
2530 if (len > length)
2531 len = length;
2532 else
2533 *eof = 1;
2534
2535 if (len < 0)
2536 len = 0;
2537
2538 return len;
2539} 2528}
2529
2530const struct file_operations jfs_lmstats_proc_fops = {
2531 .owner = THIS_MODULE,
2532 .open = jfs_lmstats_proc_open,
2533 .read = seq_read,
2534 .llseek = seq_lseek,
2535 .release = single_release,
2536};
2540#endif /* CONFIG_JFS_STATISTICS */ 2537#endif /* CONFIG_JFS_STATISTICS */
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index d1e64f2f2fc..854ff0ec574 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -19,10 +19,12 @@
19 19
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/module.h>
22#include <linux/bio.h> 23#include <linux/bio.h>
23#include <linux/init.h> 24#include <linux/init.h>
24#include <linux/buffer_head.h> 25#include <linux/buffer_head.h>
25#include <linux/mempool.h> 26#include <linux/mempool.h>
27#include <linux/seq_file.h>
26#include "jfs_incore.h" 28#include "jfs_incore.h"
27#include "jfs_superblock.h" 29#include "jfs_superblock.h"
28#include "jfs_filsys.h" 30#include "jfs_filsys.h"
@@ -804,13 +806,9 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
804} 806}
805 807
806#ifdef CONFIG_JFS_STATISTICS 808#ifdef CONFIG_JFS_STATISTICS
807int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length, 809static int jfs_mpstat_proc_show(struct seq_file *m, void *v)
808 int *eof, void *data)
809{ 810{
810 int len = 0; 811 seq_printf(m,
811 off_t begin;
812
813 len += sprintf(buffer,
814 "JFS Metapage statistics\n" 812 "JFS Metapage statistics\n"
815 "=======================\n" 813 "=======================\n"
816 "page allocations = %d\n" 814 "page allocations = %d\n"
@@ -819,19 +817,19 @@ int jfs_mpstat_read(char *buffer, char **start, off_t offset, int length,
819 mpStat.pagealloc, 817 mpStat.pagealloc,
820 mpStat.pagefree, 818 mpStat.pagefree,
821 mpStat.lockwait); 819 mpStat.lockwait);
820 return 0;
821}
822 822
823 begin = offset; 823static int jfs_mpstat_proc_open(struct inode *inode, struct file *file)
824 *start = buffer + begin; 824{
825 len -= begin; 825 return single_open(file, jfs_mpstat_proc_show, NULL);
826
827 if (len > length)
828 len = length;
829 else
830 *eof = 1;
831
832 if (len < 0)
833 len = 0;
834
835 return len;
836} 826}
827
828const struct file_operations jfs_mpstat_proc_fops = {
829 .owner = THIS_MODULE,
830 .open = jfs_mpstat_proc_open,
831 .read = seq_read,
832 .llseek = seq_lseek,
833 .release = single_release,
834};
837#endif 835#endif
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index e7c60ae6b5b..f26e4d03ada 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -49,6 +49,7 @@
49#include <linux/module.h> 49#include <linux/module.h>
50#include <linux/moduleparam.h> 50#include <linux/moduleparam.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/seq_file.h>
52#include "jfs_incore.h" 53#include "jfs_incore.h"
53#include "jfs_inode.h" 54#include "jfs_inode.h"
54#include "jfs_filsys.h" 55#include "jfs_filsys.h"
@@ -3009,11 +3010,8 @@ int jfs_sync(void *arg)
3009} 3010}
3010 3011
3011#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG) 3012#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_DEBUG)
3012int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length, 3013static int jfs_txanchor_proc_show(struct seq_file *m, void *v)
3013 int *eof, void *data)
3014{ 3014{
3015 int len = 0;
3016 off_t begin;
3017 char *freewait; 3015 char *freewait;
3018 char *freelockwait; 3016 char *freelockwait;
3019 char *lowlockwait; 3017 char *lowlockwait;
@@ -3025,7 +3023,7 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
3025 lowlockwait = 3023 lowlockwait =
3026 waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty"; 3024 waitqueue_active(&TxAnchor.lowlockwait) ? "active" : "empty";
3027 3025
3028 len += sprintf(buffer, 3026 seq_printf(m,
3029 "JFS TxAnchor\n" 3027 "JFS TxAnchor\n"
3030 "============\n" 3028 "============\n"
3031 "freetid = %d\n" 3029 "freetid = %d\n"
@@ -3044,31 +3042,27 @@ int jfs_txanchor_read(char *buffer, char **start, off_t offset, int length,
3044 TxAnchor.tlocksInUse, 3042 TxAnchor.tlocksInUse,
3045 jfs_tlocks_low, 3043 jfs_tlocks_low,
3046 list_empty(&TxAnchor.unlock_queue) ? "" : "not "); 3044 list_empty(&TxAnchor.unlock_queue) ? "" : "not ");
3045 return 0;
3046}
3047 3047
3048 begin = offset; 3048static int jfs_txanchor_proc_open(struct inode *inode, struct file *file)
3049 *start = buffer + begin; 3049{
3050 len -= begin; 3050 return single_open(file, jfs_txanchor_proc_show, NULL);
3051
3052 if (len > length)
3053 len = length;
3054 else
3055 *eof = 1;
3056
3057 if (len < 0)
3058 len = 0;
3059
3060 return len;
3061} 3051}
3052
3053const struct file_operations jfs_txanchor_proc_fops = {
3054 .owner = THIS_MODULE,
3055 .open = jfs_txanchor_proc_open,
3056 .read = seq_read,
3057 .llseek = seq_lseek,
3058 .release = single_release,
3059};
3062#endif 3060#endif
3063 3061
3064#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS) 3062#if defined(CONFIG_PROC_FS) && defined(CONFIG_JFS_STATISTICS)
3065int jfs_txstats_read(char *buffer, char **start, off_t offset, int length, 3063static int jfs_txstats_proc_show(struct seq_file *m, void *v)
3066 int *eof, void *data)
3067{ 3064{
3068 int len = 0; 3065 seq_printf(m,
3069 off_t begin;
3070
3071 len += sprintf(buffer,
3072 "JFS TxStats\n" 3066 "JFS TxStats\n"
3073 "===========\n" 3067 "===========\n"
3074 "calls to txBegin = %d\n" 3068 "calls to txBegin = %d\n"
@@ -3089,19 +3083,19 @@ int jfs_txstats_read(char *buffer, char **start, off_t offset, int length,
3089 TxStat.txBeginAnon_lockslow, 3083 TxStat.txBeginAnon_lockslow,
3090 TxStat.txLockAlloc, 3084 TxStat.txLockAlloc,
3091 TxStat.txLockAlloc_freelock); 3085 TxStat.txLockAlloc_freelock);
3086 return 0;
3087}
3092 3088
3093 begin = offset; 3089static int jfs_txstats_proc_open(struct inode *inode, struct file *file)
3094 *start = buffer + begin; 3090{
3095 len -= begin; 3091 return single_open(file, jfs_txstats_proc_show, NULL);
3096
3097 if (len > length)
3098 len = length;
3099 else
3100 *eof = 1;
3101
3102 if (len < 0)
3103 len = 0;
3104
3105 return len;
3106} 3092}
3093
3094const struct file_operations jfs_txstats_proc_fops = {
3095 .owner = THIS_MODULE,
3096 .open = jfs_txstats_proc_open,
3097 .read = seq_read,
3098 .llseek = seq_lseek,
3099 .release = single_release,
3100};
3107#endif 3101#endif
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 5a61ebf2cbc..ae3acafb447 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -20,7 +20,9 @@
20 */ 20 */
21 21
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/module.h>
23#include <linux/quotaops.h> 24#include <linux/quotaops.h>
25#include <linux/seq_file.h>
24#include "jfs_incore.h" 26#include "jfs_incore.h"
25#include "jfs_filsys.h" 27#include "jfs_filsys.h"
26#include "jfs_metapage.h" 28#include "jfs_metapage.h"
@@ -4134,13 +4136,9 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
4134} 4136}
4135 4137
4136#ifdef CONFIG_JFS_STATISTICS 4138#ifdef CONFIG_JFS_STATISTICS
4137int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, 4139static int jfs_xtstat_proc_show(struct seq_file *m, void *v)
4138 int *eof, void *data)
4139{ 4140{
4140 int len = 0; 4141 seq_printf(m,
4141 off_t begin;
4142
4143 len += sprintf(buffer,
4144 "JFS Xtree statistics\n" 4142 "JFS Xtree statistics\n"
4145 "====================\n" 4143 "====================\n"
4146 "searches = %d\n" 4144 "searches = %d\n"
@@ -4149,19 +4147,19 @@ int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length,
4149 xtStat.search, 4147 xtStat.search,
4150 xtStat.fastSearch, 4148 xtStat.fastSearch,
4151 xtStat.split); 4149 xtStat.split);
4150 return 0;
4151}
4152 4152
4153 begin = offset; 4153static int jfs_xtstat_proc_open(struct inode *inode, struct file *file)
4154 *start = buffer + begin; 4154{
4155 len -= begin; 4155 return single_open(file, jfs_xtstat_proc_show, NULL);
4156
4157 if (len > length)
4158 len = length;
4159 else
4160 *eof = 1;
4161
4162 if (len < 0)
4163 len = 0;
4164
4165 return len;
4166} 4156}
4157
4158const struct file_operations jfs_xtstat_proc_fops = {
4159 .owner = THIS_MODULE,
4160 .open = jfs_xtstat_proc_open,
4161 .read = seq_read,
4162 .llseek = seq_lseek,
4163 .release = single_release,
4164};
4167#endif 4165#endif
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 0ba6778edaa..2aba8238681 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1455,7 +1455,7 @@ static struct dentry *jfs_lookup(struct inode *dip, struct dentry *dentry, struc
1455 free_UCSname(&key); 1455 free_UCSname(&key);
1456 if (rc == -ENOENT) { 1456 if (rc == -ENOENT) {
1457 d_add(dentry, NULL); 1457 d_add(dentry, NULL);
1458 return ERR_PTR(0); 1458 return NULL;
1459 } else if (rc) { 1459 } else if (rc) {
1460 jfs_err("jfs_lookup: dtSearch returned %d", rc); 1460 jfs_err("jfs_lookup: dtSearch returned %d", rc);
1461 return ERR_PTR(rc); 1461 return ERR_PTR(rc);
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 50ea6545173..0288e6d7936 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -499,7 +499,7 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
499 inode = jfs_iget(sb, ROOT_I); 499 inode = jfs_iget(sb, ROOT_I);
500 if (IS_ERR(inode)) { 500 if (IS_ERR(inode)) {
501 ret = PTR_ERR(inode); 501 ret = PTR_ERR(inode);
502 goto out_no_root; 502 goto out_no_rw;
503 } 503 }
504 sb->s_root = d_alloc_root(inode); 504 sb->s_root = d_alloc_root(inode);
505 if (!sb->s_root) 505 if (!sb->s_root)
@@ -521,9 +521,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
521 return 0; 521 return 0;
522 522
523out_no_root: 523out_no_root:
524 jfs_err("jfs_read_super: get root inode failed"); 524 jfs_err("jfs_read_super: get root dentry failed");
525 if (inode) 525 iput(inode);
526 iput(inode);
527 526
528out_no_rw: 527out_no_rw:
529 rc = jfs_umount(sb); 528 rc = jfs_umount(sb);
diff --git a/fs/mpage.c b/fs/mpage.c
index 235e4d3873a..dbcc7af76a1 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -82,7 +82,7 @@ static void mpage_end_io_write(struct bio *bio, int err)
82 bio_put(bio); 82 bio_put(bio);
83} 83}
84 84
85static struct bio *mpage_bio_submit(int rw, struct bio *bio) 85struct bio *mpage_bio_submit(int rw, struct bio *bio)
86{ 86{
87 bio->bi_end_io = mpage_end_io_read; 87 bio->bi_end_io = mpage_end_io_read;
88 if (rw == WRITE) 88 if (rw == WRITE)
@@ -90,6 +90,7 @@ static struct bio *mpage_bio_submit(int rw, struct bio *bio)
90 submit_bio(rw, bio); 90 submit_bio(rw, bio);
91 return NULL; 91 return NULL;
92} 92}
93EXPORT_SYMBOL(mpage_bio_submit);
93 94
94static struct bio * 95static struct bio *
95mpage_alloc(struct block_device *bdev, 96mpage_alloc(struct block_device *bdev,
@@ -435,15 +436,9 @@ EXPORT_SYMBOL(mpage_readpage);
435 * written, so it can intelligently allocate a suitably-sized BIO. For now, 436 * written, so it can intelligently allocate a suitably-sized BIO. For now,
436 * just allocate full-size (16-page) BIOs. 437 * just allocate full-size (16-page) BIOs.
437 */ 438 */
438struct mpage_data {
439 struct bio *bio;
440 sector_t last_block_in_bio;
441 get_block_t *get_block;
442 unsigned use_writepage;
443};
444 439
445static int __mpage_writepage(struct page *page, struct writeback_control *wbc, 440int __mpage_writepage(struct page *page, struct writeback_control *wbc,
446 void *data) 441 void *data)
447{ 442{
448 struct mpage_data *mpd = data; 443 struct mpage_data *mpd = data;
449 struct bio *bio = mpd->bio; 444 struct bio *bio = mpd->bio;
@@ -651,6 +646,7 @@ out:
651 mpd->bio = bio; 646 mpd->bio = bio;
652 return ret; 647 return ret;
653} 648}
649EXPORT_SYMBOL(__mpage_writepage);
654 650
655/** 651/**
656 * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them 652 * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them
diff --git a/include/asm-alpha/smp.h b/include/asm-alpha/smp.h
index 286e1d844f6..544c69af816 100644
--- a/include/asm-alpha/smp.h
+++ b/include/asm-alpha/smp.h
@@ -47,12 +47,13 @@ extern struct cpuinfo_alpha cpu_data[NR_CPUS];
47extern int smp_num_cpus; 47extern int smp_num_cpus;
48#define cpu_possible_map cpu_present_map 48#define cpu_possible_map cpu_present_map
49 49
50int smp_call_function_on_cpu(void (*func) (void *info), void *info,int retry, int wait, cpumask_t cpu); 50extern void arch_send_call_function_single_ipi(int cpu);
51extern void arch_send_call_function_ipi(cpumask_t mask);
51 52
52#else /* CONFIG_SMP */ 53#else /* CONFIG_SMP */
53 54
54#define hard_smp_processor_id() 0 55#define hard_smp_processor_id() 0
55#define smp_call_function_on_cpu(func,info,retry,wait,cpu) ({ 0; }) 56#define smp_call_function_on_cpu(func,info,wait,cpu) ({ 0; })
56 57
57#endif /* CONFIG_SMP */ 58#endif /* CONFIG_SMP */
58 59
diff --git a/include/asm-arm/smp.h b/include/asm-arm/smp.h
index af99636db40..7fffa2404b8 100644
--- a/include/asm-arm/smp.h
+++ b/include/asm-arm/smp.h
@@ -101,6 +101,9 @@ extern void platform_cpu_die(unsigned int cpu);
101extern int platform_cpu_kill(unsigned int cpu); 101extern int platform_cpu_kill(unsigned int cpu);
102extern void platform_cpu_enable(unsigned int cpu); 102extern void platform_cpu_enable(unsigned int cpu);
103 103
104extern void arch_send_call_function_single_ipi(int cpu);
105extern void arch_send_call_function_ipi(cpumask_t mask);
106
104/* 107/*
105 * Local timer interrupt handling function (can be IPI'ed). 108 * Local timer interrupt handling function (can be IPI'ed).
106 */ 109 */
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 4fce3db2cec..ef87f889ef6 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -195,7 +195,6 @@ static inline int pmd_none_or_clear_bad(pmd_t *pmd)
195 } 195 }
196 return 0; 196 return 0;
197} 197}
198#endif /* CONFIG_MMU */
199 198
200static inline pte_t __ptep_modify_prot_start(struct mm_struct *mm, 199static inline pte_t __ptep_modify_prot_start(struct mm_struct *mm,
201 unsigned long addr, 200 unsigned long addr,
@@ -253,6 +252,7 @@ static inline void ptep_modify_prot_commit(struct mm_struct *mm,
253 __ptep_modify_prot_commit(mm, addr, ptep, pte); 252 __ptep_modify_prot_commit(mm, addr, ptep, pte);
254} 253}
255#endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */ 254#endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */
255#endif /* CONFIG_MMU */
256 256
257/* 257/*
258 * A facility to provide lazy MMU batching. This allows PTE updates and 258 * A facility to provide lazy MMU batching. This allows PTE updates and
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index ec5f355fb7e..27731e032ee 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -38,9 +38,6 @@ ia64_get_lid (void)
38 return lid.f.id << 8 | lid.f.eid; 38 return lid.f.id << 8 | lid.f.eid;
39} 39}
40 40
41extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
42 void *info, int wait);
43
44#define hard_smp_processor_id() ia64_get_lid() 41#define hard_smp_processor_id() ia64_get_lid()
45 42
46#ifdef CONFIG_SMP 43#ifdef CONFIG_SMP
@@ -124,11 +121,12 @@ extern void __init init_smp_config (void);
124extern void smp_do_timer (struct pt_regs *regs); 121extern void smp_do_timer (struct pt_regs *regs);
125 122
126extern void smp_send_reschedule (int cpu); 123extern void smp_send_reschedule (int cpu);
127extern void lock_ipi_calllock(void);
128extern void unlock_ipi_calllock(void);
129extern void identify_siblings (struct cpuinfo_ia64 *); 124extern void identify_siblings (struct cpuinfo_ia64 *);
130extern int is_multithreading_enabled(void); 125extern int is_multithreading_enabled(void);
131 126
127extern void arch_send_call_function_single_ipi(int cpu);
128extern void arch_send_call_function_ipi(cpumask_t mask);
129
132#else /* CONFIG_SMP */ 130#else /* CONFIG_SMP */
133 131
134#define cpu_logical_id(i) 0 132#define cpu_logical_id(i) 0
diff --git a/include/asm-m32r/smp.h b/include/asm-m32r/smp.h
index 078e1a51a04..c5dd6691669 100644
--- a/include/asm-m32r/smp.h
+++ b/include/asm-m32r/smp.h
@@ -89,6 +89,9 @@ static __inline__ unsigned int num_booting_cpus(void)
89extern void smp_send_timer(void); 89extern void smp_send_timer(void);
90extern unsigned long send_IPI_mask_phys(cpumask_t, int, int); 90extern unsigned long send_IPI_mask_phys(cpumask_t, int, int);
91 91
92extern void arch_send_call_function_single_ipi(int cpu);
93extern void arch_send_call_function_ipi(cpumask_t mask);
94
92#endif /* not __ASSEMBLY__ */ 95#endif /* not __ASSEMBLY__ */
93 96
94#define NO_PROC_ID (0xff) /* No processor magic marker */ 97#define NO_PROC_ID (0xff) /* No processor magic marker */
@@ -104,6 +107,7 @@ extern unsigned long send_IPI_mask_phys(cpumask_t, int, int);
104#define LOCAL_TIMER_IPI (M32R_IRQ_IPI3-M32R_IRQ_IPI0) 107#define LOCAL_TIMER_IPI (M32R_IRQ_IPI3-M32R_IRQ_IPI0)
105#define INVALIDATE_CACHE_IPI (M32R_IRQ_IPI4-M32R_IRQ_IPI0) 108#define INVALIDATE_CACHE_IPI (M32R_IRQ_IPI4-M32R_IRQ_IPI0)
106#define CPU_BOOT_IPI (M32R_IRQ_IPI5-M32R_IRQ_IPI0) 109#define CPU_BOOT_IPI (M32R_IRQ_IPI5-M32R_IRQ_IPI0)
110#define CALL_FUNC_SINGLE_IPI (M32R_IRQ_IPI6-M32R_IRQ_IPI0)
107 111
108#define IPI_SHIFT (0) 112#define IPI_SHIFT (0)
109#define NR_IPIS (8) 113#define NR_IPIS (8)
diff --git a/include/asm-mips/barrier.h b/include/asm-mips/barrier.h
index 9d8cfbb5e79..8e9ac313ca3 100644
--- a/include/asm-mips/barrier.h
+++ b/include/asm-mips/barrier.h
@@ -92,11 +92,25 @@
92#define fast_wmb() __sync() 92#define fast_wmb() __sync()
93#define fast_rmb() __sync() 93#define fast_rmb() __sync()
94#define fast_mb() __sync() 94#define fast_mb() __sync()
95#ifdef CONFIG_SGI_IP28
96#define fast_iob() \
97 __asm__ __volatile__( \
98 ".set push\n\t" \
99 ".set noreorder\n\t" \
100 "lw $0,%0\n\t" \
101 "sync\n\t" \
102 "lw $0,%0\n\t" \
103 ".set pop" \
104 : /* no output */ \
105 : "m" (*(int *)CKSEG1ADDR(0x1fa00004)) \
106 : "memory")
107#else
95#define fast_iob() \ 108#define fast_iob() \
96 do { \ 109 do { \
97 __sync(); \ 110 __sync(); \
98 __fast_iob(); \ 111 __fast_iob(); \
99 } while (0) 112 } while (0)
113#endif
100 114
101#ifdef CONFIG_CPU_HAS_WB 115#ifdef CONFIG_CPU_HAS_WB
102 116
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index 642724734eb..9a7274ba6a0 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -82,7 +82,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
82 "2: b 1b \n" 82 "2: b 1b \n"
83 " .previous \n" 83 " .previous \n"
84 : "=&r" (temp), "=m" (*m) 84 : "=&r" (temp), "=m" (*m)
85 : "ir" (bit), "m" (*m), "r" (~0)); 85 : "i" (bit), "m" (*m), "r" (~0));
86#endif /* CONFIG_CPU_MIPSR2 */ 86#endif /* CONFIG_CPU_MIPSR2 */
87 } else if (cpu_has_llsc) { 87 } else if (cpu_has_llsc) {
88 __asm__ __volatile__( 88 __asm__ __volatile__(
@@ -147,7 +147,7 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
147 "2: b 1b \n" 147 "2: b 1b \n"
148 " .previous \n" 148 " .previous \n"
149 : "=&r" (temp), "=m" (*m) 149 : "=&r" (temp), "=m" (*m)
150 : "ir" (bit), "m" (*m)); 150 : "i" (bit), "m" (*m));
151#endif /* CONFIG_CPU_MIPSR2 */ 151#endif /* CONFIG_CPU_MIPSR2 */
152 } else if (cpu_has_llsc) { 152 } else if (cpu_has_llsc) {
153 __asm__ __volatile__( 153 __asm__ __volatile__(
@@ -428,7 +428,7 @@ static inline int test_and_clear_bit(unsigned long nr,
428 "2: b 1b \n" 428 "2: b 1b \n"
429 " .previous \n" 429 " .previous \n"
430 : "=&r" (temp), "=m" (*m), "=&r" (res) 430 : "=&r" (temp), "=m" (*m), "=&r" (res)
431 : "ri" (bit), "m" (*m) 431 : "i" (bit), "m" (*m)
432 : "memory"); 432 : "memory");
433#endif 433#endif
434 } else if (cpu_has_llsc) { 434 } else if (cpu_has_llsc) {
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index e031bdff992..d39e143b4a3 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -26,13 +26,6 @@
26#define MACH_UNKNOWN 0 /* whatever... */ 26#define MACH_UNKNOWN 0 /* whatever... */
27 27
28/* 28/*
29 * Valid machtype values for group JAZZ
30 */
31#define MACH_ACER_PICA_61 0 /* Acer PICA-61 (PICA1) */
32#define MACH_MIPS_MAGNUM_4000 1 /* Mips Magnum 4000 "RC4030" */
33#define MACH_OLIVETTI_M700 2 /* Olivetti M700-10 (-15 ??) */
34
35/*
36 * Valid machtype for group DEC 29 * Valid machtype for group DEC
37 */ 30 */
38#define MACH_DSUNKNOWN 0 31#define MACH_DSUNKNOWN 0
@@ -48,42 +41,6 @@
48#define MACH_DS5900 10 /* DECsystem 5900 */ 41#define MACH_DS5900 10 /* DECsystem 5900 */
49 42
50/* 43/*
51 * Valid machtype for group SNI_RM
52 */
53#define MACH_SNI_RM200_PCI 0 /* RM200/RM300/RM400 PCI series */
54
55/*
56 * Valid machtype for group SGI
57 */
58#define MACH_SGI_IP22 0 /* Indy, Indigo2, Challenge S */
59#define MACH_SGI_IP27 1 /* Origin 200, Origin 2000, Onyx 2 */
60#define MACH_SGI_IP28 2 /* Indigo2 Impact */
61#define MACH_SGI_IP32 3 /* O2 */
62#define MACH_SGI_IP30 4 /* Octane, Octane2 */
63
64/*
65 * Valid machtypes for group Toshiba
66 */
67#define MACH_PALLAS 0
68#define MACH_TOPAS 1
69#define MACH_JMR 2
70#define MACH_TOSHIBA_JMR3927 3 /* JMR-TX3927 CPU/IO board */
71#define MACH_TOSHIBA_RBTX4927 4
72#define MACH_TOSHIBA_RBTX4937 5
73#define MACH_TOSHIBA_RBTX4938 6
74
75/*
76 * Valid machtype for group LASAT
77 */
78#define MACH_LASAT_100 0 /* Masquerade II/SP100/SP50/SP25 */
79#define MACH_LASAT_200 1 /* Masquerade PRO/SP200 */
80
81/*
82 * Valid machtype for group NEC EMMA2RH
83 */
84#define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */
85
86/*
87 * Valid machtype for group PMC-MSP 44 * Valid machtype for group PMC-MSP
88 */ 45 */
89#define MACH_MSP4200_EVAL 0 /* PMC-Sierra MSP4200 Evaluation */ 46#define MACH_MSP4200_EVAL 0 /* PMC-Sierra MSP4200 Evaluation */
diff --git a/include/asm-mips/cpu.h b/include/asm-mips/cpu.h
index 1c35cac6f35..229a786101d 100644
--- a/include/asm-mips/cpu.h
+++ b/include/asm-mips/cpu.h
@@ -66,8 +66,10 @@
66#define PRID_IMP_RM7000 0x2700 66#define PRID_IMP_RM7000 0x2700
67#define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */ 67#define PRID_IMP_NEVADA 0x2800 /* RM5260 ??? */
68#define PRID_IMP_RM9000 0x3400 68#define PRID_IMP_RM9000 0x3400
69#define PRID_IMP_LOONGSON1 0x4200
69#define PRID_IMP_R5432 0x5400 70#define PRID_IMP_R5432 0x5400
70#define PRID_IMP_R5500 0x5500 71#define PRID_IMP_R5500 0x5500
72#define PRID_IMP_LOONGSON2 0x6300
71 73
72#define PRID_IMP_UNKNOWN 0xff00 74#define PRID_IMP_UNKNOWN 0xff00
73 75
@@ -90,8 +92,6 @@
90#define PRID_IMP_24KE 0x9600 92#define PRID_IMP_24KE 0x9600
91#define PRID_IMP_74K 0x9700 93#define PRID_IMP_74K 0x9700
92#define PRID_IMP_1004K 0x9900 94#define PRID_IMP_1004K 0x9900
93#define PRID_IMP_LOONGSON1 0x4200
94#define PRID_IMP_LOONGSON2 0x6300
95 95
96/* 96/*
97 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE 97 * These are the PRID's for when 23:16 == PRID_COMP_SIBYTE
diff --git a/include/asm-mips/dec/kn05.h b/include/asm-mips/dec/kn05.h
index 15fe8f881e6..56d22dc8803 100644
--- a/include/asm-mips/dec/kn05.h
+++ b/include/asm-mips/dec/kn05.h
@@ -6,7 +6,7 @@
6 * KN04-CA) and DECsystem 5900/260 (KN05) R4k CPU card MB ASIC 6 * KN04-CA) and DECsystem 5900/260 (KN05) R4k CPU card MB ASIC
7 * definitions. 7 * definitions.
8 * 8 *
9 * Copyright (C) 2002, 2003, 2005 Maciej W. Rozycki 9 * Copyright (C) 2002, 2003, 2005, 2008 Maciej W. Rozycki
10 * 10 *
11 * This program is free software; you can redistribute it and/or 11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License 12 * modify it under the terms of the GNU General Public License
@@ -54,11 +54,11 @@
54 */ 54 */
55#define KN4K_MB_INT_TC (1<<0) /* TURBOchannel? */ 55#define KN4K_MB_INT_TC (1<<0) /* TURBOchannel? */
56#define KN4K_MB_INT_RTC (1<<1) /* RTC? */ 56#define KN4K_MB_INT_RTC (1<<1) /* RTC? */
57#define KN4K_MB_INT_MT (1<<3) /* ??? */ 57#define KN4K_MB_INT_MT (1<<3) /* I/O ASIC cascade */
58 58
59/* 59/*
60 * Bits for the MB control & status register. 60 * Bits for the MB control & status register.
61 * Set to 0x00bf8001 on my system by the ROM. 61 * Set to 0x00bf8001 for KN05 and to 0x003f8000 for KN04 by the firmware.
62 */ 62 */
63#define KN4K_MB_CSR_PF (1<<0) /* PreFetching enable? */ 63#define KN4K_MB_CSR_PF (1<<0) /* PreFetching enable? */
64#define KN4K_MB_CSR_F (1<<1) /* ??? */ 64#define KN4K_MB_CSR_F (1<<1) /* ??? */
@@ -69,7 +69,8 @@
69#define KN4K_MB_CSR_IM (1<<13) /* ??? */ 69#define KN4K_MB_CSR_IM (1<<13) /* ??? */
70#define KN4K_MB_CSR_NC (1<<14) /* ??? */ 70#define KN4K_MB_CSR_NC (1<<14) /* ??? */
71#define KN4K_MB_CSR_EE (1<<15) /* (bus) Exception Enable? */ 71#define KN4K_MB_CSR_EE (1<<15) /* (bus) Exception Enable? */
72#define KN4K_MB_CSR_MSK (0x1f<<16) /* ??? */ 72#define KN4K_MB_CSR_MSK (0x1f<<16) /* CPU Int[4:0] mask */
73#define KN4K_MB_CSR_FW (1<<21) /* ??? */ 73#define KN4K_MB_CSR_FW (1<<21) /* ??? */
74#define KN4K_MB_CSR_W (1<<31) /* ??? */
74 75
75#endif /* __ASM_MIPS_DEC_KN05_H */ 76#endif /* __ASM_MIPS_DEC_KN05_H */
diff --git a/include/asm-mips/inventory.h b/include/asm-mips/inventory.h
deleted file mode 100644
index cc88aed23f0..00000000000
--- a/include/asm-mips/inventory.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * Miguel de Icaza
3 */
4#ifndef __ASM_INVENTORY_H
5#define __ASM_INVENTORY_H
6
7#include <linux/compiler.h>
8
9typedef struct inventory_s {
10 struct inventory_s *inv_next;
11 int inv_class;
12 int inv_type;
13 int inv_controller;
14 int inv_unit;
15 int inv_state;
16} inventory_t;
17
18extern int inventory_items;
19
20extern void add_to_inventory(int class, int type, int controller, int unit, int state);
21extern int dump_inventory_to_user(void __user *userbuf, int size);
22extern int __init init_inventory(void);
23
24#endif /* __ASM_INVENTORY_H */
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index f18d2816cbe..501a40b9f18 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -161,13 +161,6 @@ static inline void * isa_bus_to_virt(unsigned long address)
161#define bus_to_virt phys_to_virt 161#define bus_to_virt phys_to_virt
162 162
163/* 163/*
164 * isa_slot_offset is the address where E(ISA) busaddress 0 is mapped
165 * for the processor. This implies the assumption that there is only
166 * one of these busses.
167 */
168extern unsigned long isa_slot_offset;
169
170/*
171 * Change "struct page" to physical address. 164 * Change "struct page" to physical address.
172 */ 165 */
173#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 166#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
@@ -528,16 +521,6 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
528} 521}
529 522
530/* 523/*
531 * ISA space is 'always mapped' on currently supported MIPS systems, no need
532 * to explicitly ioremap() it. The fact that the ISA IO space is mapped
533 * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
534 * are physical addresses. The following constant pointer can be
535 * used as the IO-area pointer (it can be iounmapped as well, so the
536 * analogy with PCI is quite large):
537 */
538#define __ISA_IO_base ((char *)(isa_slot_offset))
539
540/*
541 * The caches on some architectures aren't dma-coherent and have need to 524 * The caches on some architectures aren't dma-coherent and have need to
542 * handle this in software. There are three types of operations that 525 * handle this in software. There are three types of operations that
543 * can be applied to dma buffers. 526 * can be applied to dma buffers.
diff --git a/include/asm-mips/lasat/lasat.h b/include/asm-mips/lasat/lasat.h
index ea04d9262ed..caeba1e302a 100644
--- a/include/asm-mips/lasat/lasat.h
+++ b/include/asm-mips/lasat/lasat.h
@@ -240,6 +240,8 @@ static inline void lasat_ndelay(unsigned int ns)
240 __delay(ns / lasat_ndelay_divider); 240 __delay(ns / lasat_ndelay_divider);
241} 241}
242 242
243#define IS_LASAT_200() (current_cpu_data.cputype == CPU_R5000)
244
243#endif /* !defined (_LANGUAGE_ASSEMBLY) */ 245#endif /* !defined (_LANGUAGE_ASSEMBLY) */
244 246
245#define LASAT_SERVICEMODE_MAGIC_1 0xdeadbeef 247#define LASAT_SERVICEMODE_MAGIC_1 0xdeadbeef
diff --git a/include/asm-mips/mach-atlas/mc146818rtc.h b/include/asm-mips/mach-atlas/mc146818rtc.h
deleted file mode 100644
index 51d337e1bbd..00000000000
--- a/include/asm-mips/mach-atlas/mc146818rtc.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * Copyright (C) 1999, 2000, 2005 MIPS Technologies, Inc.
3 * All rights reserved.
4 * Authors: Carsten Langgaard <carstenl@mips.com>
5 * Maciej W. Rozycki <macro@mips.com>
6 * Copyright (C) 2003, 05 Ralf Baechle (ralf@linux-mips.org)
7 *
8 * This program is free software; you can distribute it and/or modify it
9 * under the terms of the GNU General Public License (Version 2) as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */
21#ifndef __ASM_MACH_ATLAS_MC146818RTC_H
22#define __ASM_MACH_ATLAS_MC146818RTC_H
23
24#include <linux/types.h>
25
26#include <asm/addrspace.h>
27
28#include <asm/mips-boards/atlas.h>
29#include <asm/mips-boards/atlasint.h>
30
31#define ARCH_RTC_LOCATION
32
33#define RTC_PORT(x) (ATLAS_RTC_ADR_REG + (x) * 8)
34#define RTC_IO_EXTENT 0x100
35#define RTC_IOMAPPED 0
36#define RTC_IRQ ATLAS_INT_RTC
37
38static inline unsigned char CMOS_READ(unsigned long addr)
39{
40 volatile u32 *ireg = (void *)CKSEG1ADDR(RTC_PORT(0));
41 volatile u32 *dreg = (void *)CKSEG1ADDR(RTC_PORT(1));
42
43 *ireg = addr;
44 return *dreg;
45}
46
47static inline void CMOS_WRITE(unsigned char data, unsigned long addr)
48{
49 volatile u32 *ireg = (void *)CKSEG1ADDR(RTC_PORT(0));
50 volatile u32 *dreg = (void *)CKSEG1ADDR(RTC_PORT(1));
51
52 *ireg = addr;
53 *dreg = data;
54}
55
56#define RTC_ALWAYS_BCD 0
57
58#define mc146818_decode_year(year) ((year) < 70 ? (year) + 2000 : (year) + 1900)
59
60#endif /* __ASM_MACH_ATLAS_MC146818RTC_H */
diff --git a/include/asm-mips/mach-db1x00/db1x00.h b/include/asm-mips/mach-db1x00/db1x00.h
index 612ae90dbcb..1a515b8c870 100644
--- a/include/asm-mips/mach-db1x00/db1x00.h
+++ b/include/asm-mips/mach-db1x00/db1x00.h
@@ -146,51 +146,6 @@ typedef volatile struct
146 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8)) 146 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
147 147
148/* 148/*
149 * SD controller macros
150 */
151
152/* Detect card. */
153#define mmc_card_inserted(_n_, _res_) \
154 do { \
155 BCSR * const bcsr = (BCSR *)0xAE000000; \
156 unsigned long mmc_wp, board_specific; \
157 if ((_n_)) { \
158 mmc_wp = BCSR_BOARD_SD1_WP; \
159 } else { \
160 mmc_wp = BCSR_BOARD_SD0_WP; \
161 } \
162 board_specific = au_readl((unsigned long)(&bcsr->specific)); \
163 if (!(board_specific & mmc_wp)) {/* low means card present */ \
164 *(int *)(_res_) = 1; \
165 } else { \
166 *(int *)(_res_) = 0; \
167 } \
168 } while (0)
169
170/*
171 * Apply power to card slot(s).
172 */
173#define mmc_power_on(_n_) \
174 do { \
175 BCSR * const bcsr = (BCSR *)0xAE000000; \
176 unsigned long mmc_pwr, mmc_wp, board_specific; \
177 if ((_n_)) { \
178 mmc_pwr = BCSR_BOARD_SD1_PWR; \
179 mmc_wp = BCSR_BOARD_SD1_WP; \
180 } else { \
181 mmc_pwr = BCSR_BOARD_SD0_PWR; \
182 mmc_wp = BCSR_BOARD_SD0_WP; \
183 } \
184 board_specific = au_readl((unsigned long)(&bcsr->specific)); \
185 if (!(board_specific & mmc_wp)) {/* low means card present */ \
186 board_specific |= mmc_pwr; \
187 au_writel(board_specific, (int)(&bcsr->specific)); \
188 au_sync(); \
189 } \
190 } while (0)
191
192
193/*
194 * NAND defines 149 * NAND defines
195 * 150 *
196 * Timing values as described in databook, * ns value stripped of the 151 * Timing values as described in databook, * ns value stripped of the
diff --git a/include/asm-mips/mach-mips/cpu-feature-overrides.h b/include/asm-mips/mach-malta/cpu-feature-overrides.h
index 7f3e3f9bd23..7f3e3f9bd23 100644
--- a/include/asm-mips/mach-mips/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-malta/cpu-feature-overrides.h
diff --git a/include/asm-mips/mach-mips/irq.h b/include/asm-mips/mach-malta/irq.h
index 9b9da26683c..9b9da26683c 100644
--- a/include/asm-mips/mach-mips/irq.h
+++ b/include/asm-mips/mach-malta/irq.h
diff --git a/include/asm-mips/mach-mips/kernel-entry-init.h b/include/asm-mips/mach-malta/kernel-entry-init.h
index 0b793e7bf67..0b793e7bf67 100644
--- a/include/asm-mips/mach-mips/kernel-entry-init.h
+++ b/include/asm-mips/mach-malta/kernel-entry-init.h
diff --git a/include/asm-mips/mach-mips/mach-gt64120.h b/include/asm-mips/mach-malta/mach-gt64120.h
index 0f863148f3b..0f863148f3b 100644
--- a/include/asm-mips/mach-mips/mach-gt64120.h
+++ b/include/asm-mips/mach-malta/mach-gt64120.h
diff --git a/include/asm-mips/mach-mips/mc146818rtc.h b/include/asm-mips/mach-malta/mc146818rtc.h
index ea612f37f61..ea612f37f61 100644
--- a/include/asm-mips/mach-mips/mc146818rtc.h
+++ b/include/asm-mips/mach-malta/mc146818rtc.h
diff --git a/include/asm-mips/mach-mips/war.h b/include/asm-mips/mach-malta/war.h
index 7c6931d5f45..7c6931d5f45 100644
--- a/include/asm-mips/mach-mips/war.h
+++ b/include/asm-mips/mach-malta/war.h
diff --git a/include/asm-mips/mach-jmr3927/ioremap.h b/include/asm-mips/mach-tx39xx/ioremap.h
index 29989ff10d6..93c6c04ffda 100644
--- a/include/asm-mips/mach-jmr3927/ioremap.h
+++ b/include/asm-mips/mach-tx39xx/ioremap.h
@@ -1,13 +1,13 @@
1/* 1/*
2 * include/asm-mips/mach-jmr3927/ioremap.h 2 * include/asm-mips/mach-tx39xx/ioremap.h
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 */ 8 */
9#ifndef __ASM_MACH_JMR3927_IOREMAP_H 9#ifndef __ASM_MACH_TX39XX_IOREMAP_H
10#define __ASM_MACH_JMR3927_IOREMAP_H 10#define __ASM_MACH_TX39XX_IOREMAP_H
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
@@ -35,4 +35,4 @@ static inline int plat_iounmap(const volatile void __iomem *addr)
35 return (unsigned long)addr >= TXX9_DIRECTMAP_BASE; 35 return (unsigned long)addr >= TXX9_DIRECTMAP_BASE;
36} 36}
37 37
38#endif /* __ASM_MACH_JMR3927_IOREMAP_H */ 38#endif /* __ASM_MACH_TX39XX_IOREMAP_H */
diff --git a/include/asm-mips/mach-jmr3927/mangle-port.h b/include/asm-mips/mach-tx39xx/mangle-port.h
index 11bffcd1043..ef0b502fd8b 100644
--- a/include/asm-mips/mach-jmr3927/mangle-port.h
+++ b/include/asm-mips/mach-tx39xx/mangle-port.h
@@ -1,7 +1,12 @@
1#ifndef __ASM_MACH_JMR3927_MANGLE_PORT_H 1#ifndef __ASM_MACH_TX39XX_MANGLE_PORT_H
2#define __ASM_MACH_JMR3927_MANGLE_PORT_H 2#define __ASM_MACH_TX39XX_MANGLE_PORT_H
3 3
4extern unsigned long __swizzle_addr_b(unsigned long port); 4#if defined(CONFIG_TOSHIBA_JMR3927)
5extern unsigned long (*__swizzle_addr_b)(unsigned long port);
6#define NEEDS_TXX9_SWIZZLE_ADDR_B
7#else
8#define __swizzle_addr_b(port) (port)
9#endif
5#define __swizzle_addr_w(port) (port) 10#define __swizzle_addr_w(port) (port)
6#define __swizzle_addr_l(port) (port) 11#define __swizzle_addr_l(port) (port)
7#define __swizzle_addr_q(port) (port) 12#define __swizzle_addr_q(port) (port)
@@ -15,4 +20,4 @@ extern unsigned long __swizzle_addr_b(unsigned long port);
15#define ioswabq(a, x) le64_to_cpu(x) 20#define ioswabq(a, x) le64_to_cpu(x)
16#define __mem_ioswabq(a, x) (x) 21#define __mem_ioswabq(a, x) (x)
17 22
18#endif /* __ASM_MACH_JMR3927_MANGLE_PORT_H */ 23#endif /* __ASM_MACH_TX39XX_MANGLE_PORT_H */
diff --git a/include/asm-mips/mach-jmr3927/war.h b/include/asm-mips/mach-tx39xx/war.h
index 1ff55fb3fbc..43381461635 100644
--- a/include/asm-mips/mach-jmr3927/war.h
+++ b/include/asm-mips/mach-tx39xx/war.h
@@ -5,8 +5,8 @@
5 * 5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org> 6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */ 7 */
8#ifndef __ASM_MIPS_MACH_JMR3927_WAR_H 8#ifndef __ASM_MIPS_MACH_TX39XX_WAR_H
9#define __ASM_MIPS_MACH_JMR3927_WAR_H 9#define __ASM_MIPS_MACH_TX39XX_WAR_H
10 10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0 11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0 12#define R4600_V1_HIT_CACHEOP_WAR 0
@@ -22,4 +22,4 @@
22#define R10000_LLSC_WAR 0 22#define R10000_LLSC_WAR 0
23#define MIPS34K_MISSED_ITLB_WAR 0 23#define MIPS34K_MISSED_ITLB_WAR 0
24 24
25#endif /* __ASM_MIPS_MACH_JMR3927_WAR_H */ 25#endif /* __ASM_MIPS_MACH_TX39XX_WAR_H */
diff --git a/include/asm-mips/mach-vr41xx/irq.h b/include/asm-mips/mach-vr41xx/irq.h
index 84881229605..862058d3f81 100644
--- a/include/asm-mips/mach-vr41xx/irq.h
+++ b/include/asm-mips/mach-vr41xx/irq.h
@@ -2,9 +2,6 @@
2#define __ASM_MACH_VR41XX_IRQ_H 2#define __ASM_MACH_VR41XX_IRQ_H
3 3
4#include <asm/vr41xx/irq.h> /* for MIPS_CPU_IRQ_BASE */ 4#include <asm/vr41xx/irq.h> /* for MIPS_CPU_IRQ_BASE */
5#ifdef CONFIG_NEC_CMBVR4133
6#include <asm/vr41xx/cmbvr4133.h> /* for I8259A_IRQ_BASE */
7#endif
8 5
9#include_next <irq.h> 6#include_next <irq.h>
10 7
diff --git a/include/asm-mips/mips-boards/generic.h b/include/asm-mips/mips-boards/generic.h
index 33407bee4e7..7f0b034dd9a 100644
--- a/include/asm-mips/mips-boards/generic.h
+++ b/include/asm-mips/mips-boards/generic.h
@@ -27,12 +27,8 @@
27/* 27/*
28 * Display register base. 28 * Display register base.
29 */ 29 */
30#ifdef CONFIG_MIPS_SEAD
31#define ASCII_DISPLAY_POS_BASE 0x1f0005c0
32#else
33#define ASCII_DISPLAY_WORD_BASE 0x1f000410 30#define ASCII_DISPLAY_WORD_BASE 0x1f000410
34#define ASCII_DISPLAY_POS_BASE 0x1f000418 31#define ASCII_DISPLAY_POS_BASE 0x1f000418
35#endif
36 32
37 33
38/* 34/*
@@ -44,13 +40,8 @@
44/* 40/*
45 * Reset register. 41 * Reset register.
46 */ 42 */
47#ifdef CONFIG_MIPS_SEAD
48#define SOFTRES_REG 0x1e800050
49#define GORESET 0x4d
50#else
51#define SOFTRES_REG 0x1f000500 43#define SOFTRES_REG 0x1f000500
52#define GORESET 0x42 44#define GORESET 0x42
53#endif
54 45
55/* 46/*
56 * Revision register. 47 * Revision register.
diff --git a/include/asm-mips/namei.h b/include/asm-mips/namei.h
index c94d12d1f86..a6605a75246 100644
--- a/include/asm-mips/namei.h
+++ b/include/asm-mips/namei.h
@@ -1,26 +1,11 @@
1#ifndef _ASM_NAMEI_H 1#ifndef _ASM_NAMEI_H
2#define _ASM_NAMEI_H 2#define _ASM_NAMEI_H
3 3
4#include <linux/personality.h> 4/*
5#include <linux/stddef.h> 5 * This dummy routine maybe changed to something useful
6 * for /usr/gnemul/ emulation stuff.
7 */
6 8
7#define IRIX_EMUL "/usr/gnemul/irix/" 9#define __emul_prefix() NULL
8#define RISCOS_EMUL "/usr/gnemul/riscos/"
9
10static inline char *__emul_prefix(void)
11{
12 switch (current->personality) {
13 case PER_IRIX32:
14 case PER_IRIXN32:
15 case PER_IRIX64:
16 return IRIX_EMUL;
17
18 case PER_RISCOS:
19 return RISCOS_EMUL;
20
21 default:
22 return NULL;
23 }
24}
25 10
26#endif /* _ASM_NAMEI_H */ 11#endif /* _ASM_NAMEI_H */
diff --git a/include/asm-mips/pci.h b/include/asm-mips/pci.h
index 301ff2f2801..d3be8343607 100644
--- a/include/asm-mips/pci.h
+++ b/include/asm-mips/pci.h
@@ -172,4 +172,7 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
172 return channel ? 15 : 14; 172 return channel ? 15 : 14;
173} 173}
174 174
175extern int pci_probe_only;
176extern unsigned int pcibios_max_latency;
177
175#endif /* _ASM_PCI_H */ 178#endif /* _ASM_PCI_H */
diff --git a/include/asm-mips/prctl.h b/include/asm-mips/prctl.h
deleted file mode 100644
index 8121a9a75bf..00000000000
--- a/include/asm-mips/prctl.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * IRIX prctl interface
3 *
4 * The IRIX kernel maps a page at PRDA_ADDRESS with the
5 * contents of prda and fills it the bits on prda_sys.
6 */
7
8#ifndef __PRCTL_H__
9#define __PRCTL_H__
10
11#define PRDA_ADDRESS 0x200000L
12#define PRDA ((struct prda *) PRDA_ADDRESS)
13
14struct prda_sys {
15 pid_t t_pid;
16 u32 t_hint;
17 u32 t_dlactseq;
18 u32 t_fpflags;
19 u32 t_prid; /* processor type, $prid CP0 register */
20 u32 t_dlendseq;
21 u64 t_unused1[5];
22 pid_t t_rpid;
23 s32 t_resched;
24 u32 t_unused[8];
25 u32 t_cpu; /* current/last cpu */
26
27 /* FIXME: The signal information, not supported by Linux now */
28 u32 t_flags; /* if true, then the sigprocmask is in userspace */
29 u32 t_sigprocmask [1]; /* the sigprocmask */
30};
31
32struct prda {
33 char fill [0xe00];
34 struct prda_sys prda_sys;
35};
36
37#define t_sys prda_sys
38
39ptrdiff_t prctl(int op, int v1, int v2);
40
41#endif
diff --git a/include/asm-mips/setup.h b/include/asm-mips/setup.h
index 70009a90263..883f59bfa09 100644
--- a/include/asm-mips/setup.h
+++ b/include/asm-mips/setup.h
@@ -3,4 +3,6 @@
3 3
4#define COMMAND_LINE_SIZE 256 4#define COMMAND_LINE_SIZE 256
5 5
6extern void setup_early_printk(void);
7
6#endif /* __SETUP_H */ 8#endif /* __SETUP_H */
diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h
index 7a28989f7ee..bee5153aca4 100644
--- a/include/asm-mips/signal.h
+++ b/include/asm-mips/signal.h
@@ -119,9 +119,6 @@ struct sigaction {
119 119
120struct k_sigaction { 120struct k_sigaction {
121 struct sigaction sa; 121 struct sigaction sa;
122#ifdef CONFIG_BINFMT_IRIX
123 void (*sa_restorer)(void);
124#endif
125}; 122};
126 123
127/* IRIX compatible stack_t */ 124/* IRIX compatible stack_t */
diff --git a/include/asm-mips/smp.h b/include/asm-mips/smp.h
index 84fef1aeec0..0ff5b523ea7 100644
--- a/include/asm-mips/smp.h
+++ b/include/asm-mips/smp.h
@@ -35,16 +35,6 @@ extern int __cpu_logical_map[NR_CPUS];
35 35
36#define NO_PROC_ID (-1) 36#define NO_PROC_ID (-1)
37 37
38struct call_data_struct {
39 void (*func)(void *);
40 void *info;
41 atomic_t started;
42 atomic_t finished;
43 int wait;
44};
45
46extern struct call_data_struct *call_data;
47
48#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */ 38#define SMP_RESCHEDULE_YOURSELF 0x1 /* XXX braindead */
49#define SMP_CALL_FUNCTION 0x2 39#define SMP_CALL_FUNCTION 0x2
50 40
@@ -67,4 +57,7 @@ static inline void smp_send_reschedule(int cpu)
67 57
68extern asmlinkage void smp_call_function_interrupt(void); 58extern asmlinkage void smp_call_function_interrupt(void);
69 59
60extern void arch_send_call_function_single_ipi(int cpu);
61extern void arch_send_call_function_ipi(cpumask_t mask);
62
70#endif /* __ASM_SMP_H */ 63#endif /* __ASM_SMP_H */
diff --git a/include/asm-mips/traps.h b/include/asm-mips/traps.h
index e5dbde625ec..90ff2f497c5 100644
--- a/include/asm-mips/traps.h
+++ b/include/asm-mips/traps.h
@@ -24,6 +24,5 @@ extern int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
24extern void (*board_nmi_handler_setup)(void); 24extern void (*board_nmi_handler_setup)(void);
25extern void (*board_ejtag_handler_setup)(void); 25extern void (*board_ejtag_handler_setup)(void);
26extern void (*board_bind_eic_interrupt)(int irq, int regset); 26extern void (*board_bind_eic_interrupt)(int irq, int regset);
27extern void (*board_watchpoint_handler)(struct pt_regs *regs);
28 27
29#endif /* _ASM_TRAPS_H */ 28#endif /* _ASM_TRAPS_H */
diff --git a/include/asm-mips/tx4927/tx4927.h b/include/asm-mips/tx4927/tx4927.h
deleted file mode 100644
index 193e80a17c1..00000000000
--- a/include/asm-mips/tx4927/tx4927.h
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * Author: MontaVista Software, Inc.
3 * source@mvista.com
4 *
5 * Copyright 2001-2006 MontaVista Software Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
18 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
20 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27#ifndef __ASM_TX4927_TX4927_H
28#define __ASM_TX4927_TX4927_H
29
30#include <asm/txx9irq.h>
31
32#define TX4927_IRQ_CP0_BEG MIPS_CPU_IRQ_BASE
33#define TX4927_IRQ_CP0_END (MIPS_CPU_IRQ_BASE + 8 - 1)
34
35#define TX4927_IRQ_PIC_BEG TXX9_IRQ_BASE
36#define TX4927_IRQ_PIC_END (TXX9_IRQ_BASE + TXx9_MAX_IR - 1)
37
38
39#define TX4927_IRQ_USER0 (TX4927_IRQ_CP0_BEG+0)
40#define TX4927_IRQ_USER1 (TX4927_IRQ_CP0_BEG+1)
41#define TX4927_IRQ_NEST_PIC_ON_CP0 (TX4927_IRQ_CP0_BEG+2)
42#define TX4927_IRQ_CPU_TIMER (TX4927_IRQ_CP0_BEG+7)
43
44#define TX4927_IRQ_NEST_EXT_ON_PIC (TX4927_IRQ_PIC_BEG+3)
45
46#endif /* __ASM_TX4927_TX4927_H */
diff --git a/include/asm-mips/tx4927/tx4927_pci.h b/include/asm-mips/tx4927/tx4927_pci.h
deleted file mode 100644
index 0be77df70f2..00000000000
--- a/include/asm-mips/tx4927/tx4927_pci.h
+++ /dev/null
@@ -1,268 +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) 2000-2001 Toshiba Corporation
7 */
8#ifndef __ASM_TX4927_TX4927_PCI_H
9#define __ASM_TX4927_TX4927_PCI_H
10
11#define TX4927_CCFG_TOE 0x00004000
12#define TX4927_CCFG_WR 0x00008000
13#define TX4927_CCFG_TINTDIS 0x01000000
14
15#define TX4927_PCIMEM 0x08000000
16#define TX4927_PCIMEM_SIZE 0x08000000
17#define TX4927_PCIIO 0x16000000
18#define TX4927_PCIIO_SIZE 0x01000000
19
20#define TX4927_SDRAMC_REG 0xff1f8000
21#define TX4927_EBUSC_REG 0xff1f9000
22#define TX4927_PCIC_REG 0xff1fd000
23#define TX4927_CCFG_REG 0xff1fe000
24#define TX4927_IRC_REG 0xff1ff600
25#define TX4927_NR_TMR 3
26#define TX4927_TMR_REG(ch) (0xff1ff000 + (ch) * 0x100)
27#define TX4927_CE3 0x17f00000 /* 1M */
28#define TX4927_PCIRESET_ADDR 0xbc00f006
29#define TX4927_PCI_CLK_ADDR (KSEG1 + TX4927_CE3 + 0x00040020)
30
31#define TX4927_IMSTAT_ADDR(n) (KSEG1 + TX4927_CE3 + 0x0004001a + (n))
32#define tx4927_imstat_ptr(n) \
33 ((volatile unsigned char *)TX4927_IMSTAT_ADDR(n))
34
35/* bits for ISTAT3/IMASK3/IMSTAT3 */
36#define TX4927_INT3B_PCID 0
37#define TX4927_INT3B_PCIC 1
38#define TX4927_INT3B_PCIB 2
39#define TX4927_INT3B_PCIA 3
40#define TX4927_INT3F_PCID (1 << TX4927_INT3B_PCID)
41#define TX4927_INT3F_PCIC (1 << TX4927_INT3B_PCIC)
42#define TX4927_INT3F_PCIB (1 << TX4927_INT3B_PCIB)
43#define TX4927_INT3F_PCIA (1 << TX4927_INT3B_PCIA)
44
45/* bits for PCI_CLK (S6) */
46#define TX4927_PCI_CLK_HOST 0x80
47#define TX4927_PCI_CLK_MASK (0x0f << 3)
48#define TX4927_PCI_CLK_33 (0x01 << 3)
49#define TX4927_PCI_CLK_25 (0x04 << 3)
50#define TX4927_PCI_CLK_66 (0x09 << 3)
51#define TX4927_PCI_CLK_50 (0x0c << 3)
52#define TX4927_PCI_CLK_ACK 0x04
53#define TX4927_PCI_CLK_ACE 0x02
54#define TX4927_PCI_CLK_ENDIAN 0x01
55#define TX4927_NR_IRQ_LOCAL TX4927_IRQ_PIC_BEG
56#define TX4927_NR_IRQ_IRC 32 /* On-Chip IRC */
57
58#define TX4927_IR_PCIC 16
59#define TX4927_IR_PCIERR 22
60#define TX4927_IR_PCIPMA 23
61#define TX4927_IRQ_IRC_PCIC (TX4927_NR_IRQ_LOCAL + TX4927_IR_PCIC)
62#define TX4927_IRQ_IRC_PCIERR (TX4927_NR_IRQ_LOCAL + TX4927_IR_PCIERR)
63#define TX4927_IRQ_IOC1 (TX4927_NR_IRQ_LOCAL + TX4927_NR_IRQ_IRC)
64#define TX4927_IRQ_IOC_PCID (TX4927_IRQ_IOC1 + TX4927_INT3B_PCID)
65#define TX4927_IRQ_IOC_PCIC (TX4927_IRQ_IOC1 + TX4927_INT3B_PCIC)
66#define TX4927_IRQ_IOC_PCIB (TX4927_IRQ_IOC1 + TX4927_INT3B_PCIB)
67#define TX4927_IRQ_IOC_PCIA (TX4927_IRQ_IOC1 + TX4927_INT3B_PCIA)
68
69#ifdef _LANGUAGE_ASSEMBLY
70#define _CONST64(c) c
71#else
72#define _CONST64(c) c##ull
73
74#include <asm/byteorder.h>
75
76#define tx4927_pcireset_ptr \
77 ((volatile unsigned char *)TX4927_PCIRESET_ADDR)
78#define tx4927_pci_clk_ptr \
79 ((volatile unsigned char *)TX4927_PCI_CLK_ADDR)
80
81struct tx4927_sdramc_reg {
82 volatile unsigned long long cr[4];
83 volatile unsigned long long unused0[4];
84 volatile unsigned long long tr;
85 volatile unsigned long long unused1[2];
86 volatile unsigned long long cmd;
87};
88
89struct tx4927_ebusc_reg {
90 volatile unsigned long long cr[8];
91};
92
93struct tx4927_ccfg_reg {
94 volatile unsigned long long ccfg;
95 volatile unsigned long long crir;
96 volatile unsigned long long pcfg;
97 volatile unsigned long long tear;
98 volatile unsigned long long clkctr;
99 volatile unsigned long long unused0;
100 volatile unsigned long long garbc;
101 volatile unsigned long long unused1;
102 volatile unsigned long long unused2;
103 volatile unsigned long long ramp;
104};
105
106struct tx4927_pcic_reg {
107 volatile unsigned long pciid;
108 volatile unsigned long pcistatus;
109 volatile unsigned long pciccrev;
110 volatile unsigned long pcicfg1;
111 volatile unsigned long p2gm0plbase; /* +10 */
112 volatile unsigned long p2gm0pubase;
113 volatile unsigned long p2gm1plbase;
114 volatile unsigned long p2gm1pubase;
115 volatile unsigned long p2gm2pbase; /* +20 */
116 volatile unsigned long p2giopbase;
117 volatile unsigned long unused0;
118 volatile unsigned long pcisid;
119 volatile unsigned long unused1; /* +30 */
120 volatile unsigned long pcicapptr;
121 volatile unsigned long unused2;
122 volatile unsigned long pcicfg2;
123 volatile unsigned long g2ptocnt; /* +40 */
124 volatile unsigned long unused3[15];
125 volatile unsigned long g2pstatus; /* +80 */
126 volatile unsigned long g2pmask;
127 volatile unsigned long pcisstatus;
128 volatile unsigned long pcimask;
129 volatile unsigned long p2gcfg; /* +90 */
130 volatile unsigned long p2gstatus;
131 volatile unsigned long p2gmask;
132 volatile unsigned long p2gccmd;
133 volatile unsigned long unused4[24]; /* +a0 */
134 volatile unsigned long pbareqport; /* +100 */
135 volatile unsigned long pbacfg;
136 volatile unsigned long pbastatus;
137 volatile unsigned long pbamask;
138 volatile unsigned long pbabm; /* +110 */
139 volatile unsigned long pbacreq;
140 volatile unsigned long pbacgnt;
141 volatile unsigned long pbacstate;
142 volatile unsigned long long g2pmgbase[3]; /* +120 */
143 volatile unsigned long long g2piogbase;
144 volatile unsigned long g2pmmask[3]; /* +140 */
145 volatile unsigned long g2piomask;
146 volatile unsigned long long g2pmpbase[3]; /* +150 */
147 volatile unsigned long long g2piopbase;
148 volatile unsigned long pciccfg; /* +170 */
149 volatile unsigned long pcicstatus;
150 volatile unsigned long pcicmask;
151 volatile unsigned long unused5;
152 volatile unsigned long long p2gmgbase[3]; /* +180 */
153 volatile unsigned long long p2giogbase;
154 volatile unsigned long g2pcfgadrs; /* +1a0 */
155 volatile unsigned long g2pcfgdata;
156 volatile unsigned long unused6[8];
157 volatile unsigned long g2pintack;
158 volatile unsigned long g2pspc;
159 volatile unsigned long unused7[12]; /* +1d0 */
160 volatile unsigned long long pdmca; /* +200 */
161 volatile unsigned long long pdmga;
162 volatile unsigned long long pdmpa;
163 volatile unsigned long long pdmcut;
164 volatile unsigned long long pdmcnt; /* +220 */
165 volatile unsigned long long pdmsts;
166 volatile unsigned long long unused8[2];
167 volatile unsigned long long pdmdb[4]; /* +240 */
168 volatile unsigned long long pdmtdh; /* +260 */
169 volatile unsigned long long pdmdms;
170};
171
172#endif /* _LANGUAGE_ASSEMBLY */
173
174/*
175 * PCIC
176 */
177
178/* bits for G2PSTATUS/G2PMASK */
179#define TX4927_PCIC_G2PSTATUS_ALL 0x00000003
180#define TX4927_PCIC_G2PSTATUS_TTOE 0x00000002
181#define TX4927_PCIC_G2PSTATUS_RTOE 0x00000001
182
183/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci.h */
184#define TX4927_PCIC_PCISTATUS_ALL 0x0000f900
185
186/* bits for PBACFG */
187#define TX4927_PCIC_PBACFG_RPBA 0x00000004
188#define TX4927_PCIC_PBACFG_PBAEN 0x00000002
189#define TX4927_PCIC_PBACFG_BMCEN 0x00000001
190
191/* bits for G2PMnGBASE */
192#define TX4927_PCIC_G2PMnGBASE_BSDIS _CONST64(0x0000002000000000)
193#define TX4927_PCIC_G2PMnGBASE_ECHG _CONST64(0x0000001000000000)
194
195/* bits for G2PIOGBASE */
196#define TX4927_PCIC_G2PIOGBASE_BSDIS _CONST64(0x0000002000000000)
197#define TX4927_PCIC_G2PIOGBASE_ECHG _CONST64(0x0000001000000000)
198
199/* bits for PCICSTATUS/PCICMASK */
200#define TX4927_PCIC_PCICSTATUS_ALL 0x000007dc
201
202/* bits for PCICCFG */
203#define TX4927_PCIC_PCICCFG_LBWC_MASK 0x0fff0000
204#define TX4927_PCIC_PCICCFG_HRST 0x00000800
205#define TX4927_PCIC_PCICCFG_SRST 0x00000400
206#define TX4927_PCIC_PCICCFG_IRBER 0x00000200
207#define TX4927_PCIC_PCICCFG_IMSE0 0x00000100
208#define TX4927_PCIC_PCICCFG_IMSE1 0x00000080
209#define TX4927_PCIC_PCICCFG_IMSE2 0x00000040
210#define TX4927_PCIC_PCICCFG_IISE 0x00000020
211#define TX4927_PCIC_PCICCFG_ATR 0x00000010
212#define TX4927_PCIC_PCICCFG_ICAE 0x00000008
213
214/* bits for P2GMnGBASE */
215#define TX4927_PCIC_P2GMnGBASE_TMEMEN _CONST64(0x0000004000000000)
216#define TX4927_PCIC_P2GMnGBASE_TBSDIS _CONST64(0x0000002000000000)
217#define TX4927_PCIC_P2GMnGBASE_TECHG _CONST64(0x0000001000000000)
218
219/* bits for P2GIOGBASE */
220#define TX4927_PCIC_P2GIOGBASE_TIOEN _CONST64(0x0000004000000000)
221#define TX4927_PCIC_P2GIOGBASE_TBSDIS _CONST64(0x0000002000000000)
222#define TX4927_PCIC_P2GIOGBASE_TECHG _CONST64(0x0000001000000000)
223
224#define TX4927_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)
225#define TX4927_PCIC_MAX_DEVNU TX4927_PCIC_IDSEL_AD_TO_SLOT(32)
226
227/*
228 * CCFG
229 */
230/* CCFG : Chip Configuration */
231#define TX4927_CCFG_PCI66 0x00800000
232#define TX4927_CCFG_PCIMIDE 0x00400000
233#define TX4927_CCFG_PCIXARB 0x00002000
234#define TX4927_CCFG_PCIDIVMODE_MASK 0x00001800
235#define TX4927_CCFG_PCIDIVMODE_2_5 0x00000000
236#define TX4927_CCFG_PCIDIVMODE_3 0x00000800
237#define TX4927_CCFG_PCIDIVMODE_5 0x00001000
238#define TX4927_CCFG_PCIDIVMODE_6 0x00001800
239
240#define TX4937_CCFG_PCIDIVMODE_MASK 0x00001c00
241#define TX4937_CCFG_PCIDIVMODE_8 0x00000000
242#define TX4937_CCFG_PCIDIVMODE_4 0x00000400
243#define TX4937_CCFG_PCIDIVMODE_9 0x00000800
244#define TX4937_CCFG_PCIDIVMODE_4_5 0x00000c00
245#define TX4937_CCFG_PCIDIVMODE_10 0x00001000
246#define TX4937_CCFG_PCIDIVMODE_5 0x00001400
247#define TX4937_CCFG_PCIDIVMODE_11 0x00001800
248#define TX4937_CCFG_PCIDIVMODE_5_5 0x00001c00
249
250/* PCFG : Pin Configuration */
251#define TX4927_PCFG_PCICLKEN_ALL 0x003f0000
252#define TX4927_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
253
254/* CLKCTR : Clock Control */
255#define TX4927_CLKCTR_PCICKD 0x00400000
256#define TX4927_CLKCTR_PCIRST 0x00000040
257
258
259#ifndef _LANGUAGE_ASSEMBLY
260
261#define tx4927_sdramcptr ((struct tx4927_sdramc_reg *)TX4927_SDRAMC_REG)
262#define tx4927_pcicptr ((struct tx4927_pcic_reg *)TX4927_PCIC_REG)
263#define tx4927_ccfgptr ((struct tx4927_ccfg_reg *)TX4927_CCFG_REG)
264#define tx4927_ebuscptr ((struct tx4927_ebusc_reg *)TX4927_EBUSC_REG)
265
266#endif /* _LANGUAGE_ASSEMBLY */
267
268#endif /* __ASM_TX4927_TX4927_PCI_H */
diff --git a/include/asm-mips/txx9/generic.h b/include/asm-mips/txx9/generic.h
new file mode 100644
index 00000000000..d8756660523
--- /dev/null
+++ b/include/asm-mips/txx9/generic.h
@@ -0,0 +1,41 @@
1/*
2 * linux/include/asm-mips/txx9/generic.h
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#ifndef __ASM_TXX9_GENERIC_H
9#define __ASM_TXX9_GENERIC_H
10
11#include <linux/init.h>
12#include <linux/ioport.h> /* for struct resource */
13
14extern struct resource txx9_ce_res[];
15extern char txx9_pcode_str[8];
16void txx9_reg_res_init(unsigned int pcode, unsigned long base,
17 unsigned long size);
18
19extern unsigned int txx9_master_clock;
20extern unsigned int txx9_cpu_clock;
21extern unsigned int txx9_gbus_clock;
22
23struct pci_dev;
24struct txx9_board_vec {
25 const char *system;
26 void (*prom_init)(void);
27 void (*mem_setup)(void);
28 void (*irq_setup)(void);
29 void (*time_init)(void);
30 void (*arch_init)(void);
31 void (*device_init)(void);
32#ifdef CONFIG_PCI
33 int (*pci_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin);
34#endif
35};
36extern struct txx9_board_vec *txx9_board_vec;
37extern int (*txx9_irq_dispatch)(int pending);
38void prom_init_cmdline(void);
39char *prom_getcmdline(void);
40
41#endif /* __ASM_TXX9_GENERIC_H */
diff --git a/include/asm-mips/jmr3927/jmr3927.h b/include/asm-mips/txx9/jmr3927.h
index a162268f17d..d6eb1b6a54e 100644
--- a/include/asm-mips/jmr3927/jmr3927.h
+++ b/include/asm-mips/txx9/jmr3927.h
@@ -7,10 +7,10 @@
7 * 7 *
8 * Copyright (C) 2000-2001 Toshiba Corporation 8 * Copyright (C) 2000-2001 Toshiba Corporation
9 */ 9 */
10#ifndef __ASM_TX3927_JMR3927_H 10#ifndef __ASM_TXX9_JMR3927_H
11#define __ASM_TX3927_JMR3927_H 11#define __ASM_TXX9_JMR3927_H
12 12
13#include <asm/jmr3927/tx3927.h> 13#include <asm/txx9/tx3927.h>
14#include <asm/addrspace.h> 14#include <asm/addrspace.h>
15#include <asm/system.h> 15#include <asm/system.h>
16#include <asm/txx9irq.h> 16#include <asm/txx9irq.h>
@@ -174,4 +174,9 @@
174 * INT[3:0] 174 * INT[3:0]
175 */ 175 */
176 176
177#endif /* __ASM_TX3927_JMR3927_H */ 177void jmr3927_prom_init(void);
178void jmr3927_irq_setup(void);
179struct pci_dev;
180int jmr3927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
181
182#endif /* __ASM_TXX9_JMR3927_H */
diff --git a/include/asm-mips/txx9/pci.h b/include/asm-mips/txx9/pci.h
new file mode 100644
index 00000000000..d89a45091e2
--- /dev/null
+++ b/include/asm-mips/txx9/pci.h
@@ -0,0 +1,36 @@
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#ifndef __ASM_TXX9_PCI_H
7#define __ASM_TXX9_PCI_H
8
9#include <linux/pci.h>
10
11extern struct pci_controller txx9_primary_pcic;
12struct pci_controller *
13txx9_alloc_pci_controller(struct pci_controller *pcic,
14 unsigned long mem_base, unsigned long mem_size,
15 unsigned long io_base, unsigned long io_size);
16
17int txx9_pci66_check(struct pci_controller *hose, int top_bus,
18 int current_bus);
19extern int txx9_pci_mem_high __initdata;
20
21extern int txx9_pci_option;
22#define TXX9_PCI_OPT_PICMG 0x0002
23#define TXX9_PCI_OPT_CLK_33 0x0008
24#define TXX9_PCI_OPT_CLK_66 0x0010
25#define TXX9_PCI_OPT_CLK_MASK \
26 (TXX9_PCI_OPT_CLK_33 | TXX9_PCI_OPT_CLK_66)
27#define TXX9_PCI_OPT_CLK_AUTO TXX9_PCI_OPT_CLK_MASK
28
29enum txx9_pci_err_action {
30 TXX9_PCI_ERR_REPORT,
31 TXX9_PCI_ERR_IGNORE,
32 TXX9_PCI_ERR_PANIC,
33};
34extern enum txx9_pci_err_action txx9_pci_err_action;
35
36#endif /* __ASM_TXX9_PCI_H */
diff --git a/include/asm-mips/tx4927/toshiba_rbtx4927.h b/include/asm-mips/txx9/rbtx4927.h
index b188a659ce0..bf194589216 100644
--- a/include/asm-mips/tx4927/toshiba_rbtx4927.h
+++ b/include/asm-mips/txx9/rbtx4927.h
@@ -24,18 +24,42 @@
24 * with this program; if not, write to the Free Software Foundation, Inc., 24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA. 25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27#ifndef __ASM_TX4927_TOSHIBA_RBTX4927_H 27#ifndef __ASM_TXX9_RBTX4927_H
28#define __ASM_TX4927_TOSHIBA_RBTX4927_H 28#define __ASM_TXX9_RBTX4927_H
29 29
30#include <asm/tx4927/tx4927.h> 30#include <asm/txx9/tx4927.h>
31#ifdef CONFIG_PCI 31
32#include <asm/tx4927/tx4927_pci.h> 32#define RBTX4927_PCIMEM 0x08000000
33#endif 33#define RBTX4927_PCIMEM_SIZE 0x08000000
34#define RBTX4927_PCIIO 0x16000000
35#define RBTX4927_PCIIO_SIZE 0x01000000
36
37#define rbtx4927_pcireset_addr ((__u8 __iomem *)0xbc00f006UL)
38
39/* bits for ISTAT/IMASK/IMSTAT */
40#define RBTX4927_INTB_PCID 0
41#define RBTX4927_INTB_PCIC 1
42#define RBTX4927_INTB_PCIB 2
43#define RBTX4927_INTB_PCIA 3
44#define RBTX4927_INTF_PCID (1 << RBTX4927_INTB_PCID)
45#define RBTX4927_INTF_PCIC (1 << RBTX4927_INTB_PCIC)
46#define RBTX4927_INTF_PCIB (1 << RBTX4927_INTB_PCIB)
47#define RBTX4927_INTF_PCIA (1 << RBTX4927_INTB_PCIA)
48
49#define RBTX4927_NR_IRQ_IOC 8 /* IOC */
50
51#define RBTX4927_IRQ_IOC (TXX9_IRQ_BASE + TX4927_NUM_IR)
52#define RBTX4927_IRQ_IOC_PCID (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCID)
53#define RBTX4927_IRQ_IOC_PCIC (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIC)
54#define RBTX4927_IRQ_IOC_PCIB (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIB)
55#define RBTX4927_IRQ_IOC_PCIA (RBTX4927_IRQ_IOC + RBTX4927_INTB_PCIA)
56
57#define RBTX4927_IRQ_IOCINT (TXX9_IRQ_BASE + TX4927_IR_INT(1))
34 58
35#ifdef CONFIG_PCI 59#ifdef CONFIG_PCI
36#define TBTX4927_ISA_IO_OFFSET TX4927_PCIIO 60#define RBTX4927_ISA_IO_OFFSET RBTX4927_PCIIO
37#else 61#else
38#define TBTX4927_ISA_IO_OFFSET 0 62#define RBTX4927_ISA_IO_OFFSET 0
39#endif 63#endif
40 64
41#define RBTX4927_SW_RESET_DO (void __iomem *)0xbc00f000UL 65#define RBTX4927_SW_RESET_DO (void __iomem *)0xbc00f000UL
@@ -44,10 +68,12 @@
44#define RBTX4927_SW_RESET_ENABLE (void __iomem *)0xbc00f002UL 68#define RBTX4927_SW_RESET_ENABLE (void __iomem *)0xbc00f002UL
45#define RBTX4927_SW_RESET_ENABLE_SET 0x01 69#define RBTX4927_SW_RESET_ENABLE_SET 0x01
46 70
71#define RBTX4927_RTL_8019_BASE (0x1c020280 - RBTX4927_ISA_IO_OFFSET)
72#define RBTX4927_RTL_8019_IRQ (TXX9_IRQ_BASE + TX4927_IR_INT(3))
47 73
48#define RBTX4927_RTL_8019_BASE (0x1c020280-TBTX4927_ISA_IO_OFFSET) 74void rbtx4927_prom_init(void);
49#define RBTX4927_RTL_8019_IRQ (TX4927_IRQ_PIC_BEG + 5) 75void rbtx4927_irq_setup(void);
50 76struct pci_dev;
51int toshiba_rbtx4927_irq_nested(int sw_irq); 77int rbtx4927_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
52 78
53#endif /* __ASM_TX4927_TOSHIBA_RBTX4927_H */ 79#endif /* __ASM_TXX9_RBTX4927_H */
diff --git a/include/asm-mips/tx4938/rbtx4938.h b/include/asm-mips/txx9/rbtx4938.h
index dfed7beb533..2f5d5e705a4 100644
--- a/include/asm-mips/tx4938/rbtx4938.h
+++ b/include/asm-mips/txx9/rbtx4938.h
@@ -1,5 +1,4 @@
1/* 1/*
2 * linux/include/asm-mips/tx4938/rbtx4938.h
3 * Definitions for TX4937/TX4938 2 * Definitions for TX4937/TX4938
4 * 3 *
5 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the 4 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
@@ -9,12 +8,12 @@
9 * 8 *
10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) 9 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
11 */ 10 */
12#ifndef __ASM_TX_BOARDS_RBTX4938_H 11#ifndef __ASM_TXX9_RBTX4938_H
13#define __ASM_TX_BOARDS_RBTX4938_H 12#define __ASM_TXX9_RBTX4938_H
14 13
15#include <asm/addrspace.h> 14#include <asm/addrspace.h>
16#include <asm/tx4938/tx4938.h>
17#include <asm/txx9irq.h> 15#include <asm/txx9irq.h>
16#include <asm/txx9/tx4938.h>
18 17
19/* CS */ 18/* CS */
20#define RBTX4938_CE0 0x1c000000 /* 64M */ 19#define RBTX4938_CE0 0x1c000000 /* 64M */
@@ -102,35 +101,12 @@
102 * that particular IRQ on an RBTX4938 machine. Add new 'spaces' as new 101 * that particular IRQ on an RBTX4938 machine. Add new 'spaces' as new
103 * IRQ hardware is supported. 102 * IRQ hardware is supported.
104 */ 103 */
105#define RBTX4938_NR_IRQ_LOCAL 8
106#define RBTX4938_NR_IRQ_IRC 32 /* On-Chip IRC */
107#define RBTX4938_NR_IRQ_IOC 8 104#define RBTX4938_NR_IRQ_IOC 8
108 105
109#define TX4938_IRQ_CP0_BEG MIPS_CPU_IRQ_BASE 106#define RBTX4938_IRQ_IRC TXX9_IRQ_BASE
110#define TX4938_IRQ_CP0_END (MIPS_CPU_IRQ_BASE + 8 - 1) 107#define RBTX4938_IRQ_IOC (TXX9_IRQ_BASE + TX4938_NUM_IR)
111
112#define TX4938_IRQ_PIC_BEG TXX9_IRQ_BASE
113#define TX4938_IRQ_PIC_END (TXX9_IRQ_BASE + TXx9_MAX_IR - 1)
114#define TX4938_IRQ_NEST_EXT_ON_PIC (TX4938_IRQ_PIC_BEG+2)
115#define TX4938_IRQ_NEST_PIC_ON_CP0 (TX4938_IRQ_CP0_BEG+2)
116#define TX4938_IRQ_USER0 (TX4938_IRQ_CP0_BEG+0)
117#define TX4938_IRQ_USER1 (TX4938_IRQ_CP0_BEG+1)
118#define TX4938_IRQ_CPU_TIMER (TX4938_IRQ_CP0_BEG+7)
119
120#define TOSHIBA_RBTX4938_IRQ_IOC_RAW_BEG 0
121#define TOSHIBA_RBTX4938_IRQ_IOC_RAW_END 7
122
123#define TOSHIBA_RBTX4938_IRQ_IOC_BEG ((TX4938_IRQ_PIC_END+1)+TOSHIBA_RBTX4938_IRQ_IOC_RAW_BEG) /* 56 */
124#define TOSHIBA_RBTX4938_IRQ_IOC_END ((TX4938_IRQ_PIC_END+1)+TOSHIBA_RBTX4938_IRQ_IOC_RAW_END) /* 63 */
125#define RBTX4938_IRQ_LOCAL TX4938_IRQ_CP0_BEG
126#define RBTX4938_IRQ_IRC (RBTX4938_IRQ_LOCAL + RBTX4938_NR_IRQ_LOCAL)
127#define RBTX4938_IRQ_IOC (RBTX4938_IRQ_IRC + RBTX4938_NR_IRQ_IRC)
128#define RBTX4938_IRQ_END (RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC) 108#define RBTX4938_IRQ_END (RBTX4938_IRQ_IOC + RBTX4938_NR_IRQ_IOC)
129 109
130#define RBTX4938_IRQ_LOCAL_SOFT0 (RBTX4938_IRQ_LOCAL + RBTX4938_SOFT_INT0)
131#define RBTX4938_IRQ_LOCAL_SOFT1 (RBTX4938_IRQ_LOCAL + RBTX4938_SOFT_INT1)
132#define RBTX4938_IRQ_LOCAL_IRC (RBTX4938_IRQ_LOCAL + RBTX4938_IRC_INT)
133#define RBTX4938_IRQ_LOCAL_TIMER (RBTX4938_IRQ_LOCAL + RBTX4938_TIMER_INT)
134#define RBTX4938_IRQ_IRC_ECCERR (RBTX4938_IRQ_IRC + TX4938_IR_ECCERR) 110#define RBTX4938_IRQ_IRC_ECCERR (RBTX4938_IRQ_IRC + TX4938_IR_ECCERR)
135#define RBTX4938_IRQ_IRC_WTOERR (RBTX4938_IRQ_IRC + TX4938_IR_WTOERR) 111#define RBTX4938_IRQ_IRC_WTOERR (RBTX4938_IRQ_IRC + TX4938_IR_WTOERR)
136#define RBTX4938_IRQ_IRC_INT(n) (RBTX4938_IRQ_IRC + TX4938_IR_INT(n)) 112#define RBTX4938_IRQ_IRC_INT(n) (RBTX4938_IRQ_IRC + TX4938_IR_INT(n))
@@ -158,11 +134,16 @@
158 134
159 135
160/* IOC (PCI, etc) */ 136/* IOC (PCI, etc) */
161#define RBTX4938_IRQ_IOCINT (TX4938_IRQ_NEST_EXT_ON_PIC) 137#define RBTX4938_IRQ_IOCINT (TXX9_IRQ_BASE + TX4938_IR_INT(0))
162/* Onboard 10M Ether */ 138/* Onboard 10M Ether */
163#define RBTX4938_IRQ_ETHER (TX4938_IRQ_NEST_EXT_ON_PIC + 1) 139#define RBTX4938_IRQ_ETHER (TXX9_IRQ_BASE + TX4938_IR_INT(1))
164 140
165#define RBTX4938_RTL_8019_BASE (RBTX4938_ETHER_ADDR - mips_io_port_base) 141#define RBTX4938_RTL_8019_BASE (RBTX4938_ETHER_ADDR - mips_io_port_base)
166#define RBTX4938_RTL_8019_IRQ (RBTX4938_IRQ_ETHER) 142#define RBTX4938_RTL_8019_IRQ (RBTX4938_IRQ_ETHER)
167 143
168#endif /* __ASM_TX_BOARDS_RBTX4938_H */ 144void rbtx4938_prom_init(void);
145void rbtx4938_irq_setup(void);
146struct pci_dev;
147int rbtx4938_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
148
149#endif /* __ASM_TXX9_RBTX4938_H */
diff --git a/include/asm-mips/tx4927/smsc_fdc37m81x.h b/include/asm-mips/txx9/smsc_fdc37m81x.h
index 5d93bab5125..9375e4fc228 100644
--- a/include/asm-mips/tx4927/smsc_fdc37m81x.h
+++ b/include/asm-mips/txx9/smsc_fdc37m81x.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/include/asm-mips/tx4927/smsc_fdc37m81x.h
3 *
4 * Interface for smsc fdc48m81x Super IO chip 2 * Interface for smsc fdc48m81x Super IO chip
5 * 3 *
6 * Author: MontaVista Software, Inc. source@mvista.com 4 * Author: MontaVista Software, Inc. source@mvista.com
diff --git a/include/asm-mips/tx4938/spi.h b/include/asm-mips/txx9/spi.h
index 6a60c83e152..ddfb2a0dc43 100644
--- a/include/asm-mips/tx4938/spi.h
+++ b/include/asm-mips/txx9/spi.h
@@ -1,5 +1,4 @@
1/* 1/*
2 * linux/include/asm-mips/tx4938/spi.h
3 * Definitions for TX4937/TX4938 SPI 2 * Definitions for TX4937/TX4938 SPI
4 * 3 *
5 * Copyright (C) 2000-2001 Toshiba Corporation 4 * Copyright (C) 2000-2001 Toshiba Corporation
@@ -11,10 +10,10 @@
11 * 10 *
12 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) 11 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
13 */ 12 */
14#ifndef __ASM_TX_BOARDS_TX4938_SPI_H 13#ifndef __ASM_TXX9_SPI_H
15#define __ASM_TX_BOARDS_TX4938_SPI_H 14#define __ASM_TXX9_SPI_H
16 15
17extern int spi_eeprom_register(int chipid); 16extern int spi_eeprom_register(int chipid);
18extern int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len); 17extern int spi_eeprom_read(int chipid, int address, unsigned char *buf, int len);
19 18
20#endif /* __ASM_TX_BOARDS_TX4938_SPI_H */ 19#endif /* __ASM_TXX9_SPI_H */
diff --git a/include/asm-mips/jmr3927/tx3927.h b/include/asm-mips/txx9/tx3927.h
index fb580333c10..ca414c7624e 100644
--- a/include/asm-mips/jmr3927/tx3927.h
+++ b/include/asm-mips/txx9/tx3927.h
@@ -5,10 +5,10 @@
5 * 5 *
6 * Copyright (C) 2000 Toshiba Corporation 6 * Copyright (C) 2000 Toshiba Corporation
7 */ 7 */
8#ifndef __ASM_TX3927_H 8#ifndef __ASM_TXX9_TX3927_H
9#define __ASM_TX3927_H 9#define __ASM_TXX9_TX3927_H
10 10
11#include <asm/jmr3927/txx927.h> 11#include <asm/txx9/txx927.h>
12 12
13#define TX3927_SDRAMC_REG 0xfffe8000 13#define TX3927_SDRAMC_REG 0xfffe8000
14#define TX3927_ROMC_REG 0xfffe9000 14#define TX3927_ROMC_REG 0xfffe9000
@@ -316,4 +316,8 @@ struct tx3927_ccfg_reg {
316#define tx3927_sioptr(ch) ((struct txx927_sio_reg *)TX3927_SIO_REG(ch)) 316#define tx3927_sioptr(ch) ((struct txx927_sio_reg *)TX3927_SIO_REG(ch))
317#define tx3927_pioptr ((struct txx9_pio_reg __iomem *)TX3927_PIO_REG) 317#define tx3927_pioptr ((struct txx9_pio_reg __iomem *)TX3927_PIO_REG)
318 318
319#endif /* __ASM_TX3927_H */ 319struct pci_controller;
320void __init tx3927_pcic_setup(struct pci_controller *channel,
321 unsigned long sdram_size, int extarb);
322
323#endif /* __ASM_TXX9_TX3927_H */
diff --git a/include/asm-mips/txx9/tx4927.h b/include/asm-mips/txx9/tx4927.h
new file mode 100644
index 00000000000..46d60afc038
--- /dev/null
+++ b/include/asm-mips/txx9/tx4927.h
@@ -0,0 +1,219 @@
1/*
2 * Author: MontaVista Software, Inc.
3 * source@mvista.com
4 *
5 * Copyright 2001-2006 MontaVista Software Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
17 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
18 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
20 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27#ifndef __ASM_TXX9_TX4927_H
28#define __ASM_TXX9_TX4927_H
29
30#include <linux/types.h>
31#include <linux/io.h>
32#include <asm/txx9irq.h>
33#include <asm/txx9/tx4927pcic.h>
34
35#define TX4927_SDRAMC_REG 0xff1f8000
36#define TX4927_EBUSC_REG 0xff1f9000
37#define TX4927_PCIC_REG 0xff1fd000
38#define TX4927_CCFG_REG 0xff1fe000
39#define TX4927_IRC_REG 0xff1ff600
40#define TX4927_NR_TMR 3
41#define TX4927_TMR_REG(ch) (0xff1ff000 + (ch) * 0x100)
42
43#define TX4927_IR_INT(n) (2 + (n))
44#define TX4927_IR_SIO(n) (8 + (n))
45#define TX4927_IR_PCIC 16
46#define TX4927_IR_PCIERR 22
47#define TX4927_NUM_IR 32
48
49#define TX4927_IRC_INT 2 /* IP[2] in Status register */
50
51struct tx4927_sdramc_reg {
52 volatile unsigned long long cr[4];
53 volatile unsigned long long unused0[4];
54 volatile unsigned long long tr;
55 volatile unsigned long long unused1[2];
56 volatile unsigned long long cmd;
57};
58
59struct tx4927_ebusc_reg {
60 volatile unsigned long long cr[8];
61};
62
63struct tx4927_ccfg_reg {
64 u64 ccfg;
65 u64 crir;
66 u64 pcfg;
67 u64 toea;
68 u64 clkctr;
69 u64 unused0;
70 u64 garbc;
71 u64 unused1;
72 u64 unused2;
73 u64 ramp;
74};
75
76/*
77 * CCFG
78 */
79/* CCFG : Chip Configuration */
80#define TX4927_CCFG_WDRST 0x0000020000000000ULL
81#define TX4927_CCFG_WDREXEN 0x0000010000000000ULL
82#define TX4927_CCFG_BCFG_MASK 0x000000ff00000000ULL
83#define TX4927_CCFG_TINTDIS 0x01000000
84#define TX4927_CCFG_PCI66 0x00800000
85#define TX4927_CCFG_PCIMODE 0x00400000
86#define TX4927_CCFG_DIVMODE_MASK 0x000e0000
87#define TX4927_CCFG_DIVMODE_8 (0x0 << 17)
88#define TX4927_CCFG_DIVMODE_12 (0x1 << 17)
89#define TX4927_CCFG_DIVMODE_16 (0x2 << 17)
90#define TX4927_CCFG_DIVMODE_10 (0x3 << 17)
91#define TX4927_CCFG_DIVMODE_2 (0x4 << 17)
92#define TX4927_CCFG_DIVMODE_3 (0x5 << 17)
93#define TX4927_CCFG_DIVMODE_4 (0x6 << 17)
94#define TX4927_CCFG_DIVMODE_2_5 (0x7 << 17)
95#define TX4927_CCFG_BEOW 0x00010000
96#define TX4927_CCFG_WR 0x00008000
97#define TX4927_CCFG_TOE 0x00004000
98#define TX4927_CCFG_PCIARB 0x00002000
99#define TX4927_CCFG_PCIDIVMODE_MASK 0x00001800
100#define TX4927_CCFG_PCIDIVMODE_2_5 0x00000000
101#define TX4927_CCFG_PCIDIVMODE_3 0x00000800
102#define TX4927_CCFG_PCIDIVMODE_5 0x00001000
103#define TX4927_CCFG_PCIDIVMODE_6 0x00001800
104#define TX4927_CCFG_SYSSP_MASK 0x000000c0
105#define TX4927_CCFG_ENDIAN 0x00000004
106#define TX4927_CCFG_HALT 0x00000002
107#define TX4927_CCFG_ACEHOLD 0x00000001
108#define TX4927_CCFG_W1CBITS (TX4927_CCFG_WDRST | TX4927_CCFG_BEOW)
109
110/* PCFG : Pin Configuration */
111#define TX4927_PCFG_SDCLKDLY_MASK 0x30000000
112#define TX4927_PCFG_SDCLKDLY(d) ((d)<<28)
113#define TX4927_PCFG_SYSCLKEN 0x08000000
114#define TX4927_PCFG_SDCLKEN_ALL 0x07800000
115#define TX4927_PCFG_SDCLKEN(ch) (0x00800000<<(ch))
116#define TX4927_PCFG_PCICLKEN_ALL 0x003f0000
117#define TX4927_PCFG_PCICLKEN(ch) (0x00010000<<(ch))
118#define TX4927_PCFG_SEL2 0x00000200
119#define TX4927_PCFG_SEL1 0x00000100
120#define TX4927_PCFG_DMASEL_ALL 0x000000ff
121#define TX4927_PCFG_DMASEL0_MASK 0x00000003
122#define TX4927_PCFG_DMASEL1_MASK 0x0000000c
123#define TX4927_PCFG_DMASEL2_MASK 0x00000030
124#define TX4927_PCFG_DMASEL3_MASK 0x000000c0
125#define TX4927_PCFG_DMASEL0_DRQ0 0x00000000
126#define TX4927_PCFG_DMASEL0_SIO1 0x00000001
127#define TX4927_PCFG_DMASEL0_ACL0 0x00000002
128#define TX4927_PCFG_DMASEL0_ACL2 0x00000003
129#define TX4927_PCFG_DMASEL1_DRQ1 0x00000000
130#define TX4927_PCFG_DMASEL1_SIO1 0x00000004
131#define TX4927_PCFG_DMASEL1_ACL1 0x00000008
132#define TX4927_PCFG_DMASEL1_ACL3 0x0000000c
133#define TX4927_PCFG_DMASEL2_DRQ2 0x00000000 /* SEL2=0 */
134#define TX4927_PCFG_DMASEL2_SIO0 0x00000010 /* SEL2=0 */
135#define TX4927_PCFG_DMASEL2_ACL1 0x00000000 /* SEL2=1 */
136#define TX4927_PCFG_DMASEL2_ACL2 0x00000020 /* SEL2=1 */
137#define TX4927_PCFG_DMASEL2_ACL0 0x00000030 /* SEL2=1 */
138#define TX4927_PCFG_DMASEL3_DRQ3 0x00000000
139#define TX4927_PCFG_DMASEL3_SIO0 0x00000040
140#define TX4927_PCFG_DMASEL3_ACL3 0x00000080
141#define TX4927_PCFG_DMASEL3_ACL1 0x000000c0
142
143/* CLKCTR : Clock Control */
144#define TX4927_CLKCTR_ACLCKD 0x02000000
145#define TX4927_CLKCTR_PIOCKD 0x01000000
146#define TX4927_CLKCTR_DMACKD 0x00800000
147#define TX4927_CLKCTR_PCICKD 0x00400000
148#define TX4927_CLKCTR_TM0CKD 0x00100000
149#define TX4927_CLKCTR_TM1CKD 0x00080000
150#define TX4927_CLKCTR_TM2CKD 0x00040000
151#define TX4927_CLKCTR_SIO0CKD 0x00020000
152#define TX4927_CLKCTR_SIO1CKD 0x00010000
153#define TX4927_CLKCTR_ACLRST 0x00000200
154#define TX4927_CLKCTR_PIORST 0x00000100
155#define TX4927_CLKCTR_DMARST 0x00000080
156#define TX4927_CLKCTR_PCIRST 0x00000040
157#define TX4927_CLKCTR_TM0RST 0x00000010
158#define TX4927_CLKCTR_TM1RST 0x00000008
159#define TX4927_CLKCTR_TM2RST 0x00000004
160#define TX4927_CLKCTR_SIO0RST 0x00000002
161#define TX4927_CLKCTR_SIO1RST 0x00000001
162
163#define tx4927_sdramcptr ((struct tx4927_sdramc_reg *)TX4927_SDRAMC_REG)
164#define tx4927_pcicptr \
165 ((struct tx4927_pcic_reg __iomem *)TX4927_PCIC_REG)
166#define tx4927_ccfgptr \
167 ((struct tx4927_ccfg_reg __iomem *)TX4927_CCFG_REG)
168#define tx4927_ebuscptr ((struct tx4927_ebusc_reg *)TX4927_EBUSC_REG)
169
170/* utilities */
171static inline void txx9_clear64(__u64 __iomem *adr, __u64 bits)
172{
173#ifdef CONFIG_32BIT
174 unsigned long flags;
175 local_irq_save(flags);
176#endif
177 ____raw_writeq(____raw_readq(adr) & ~bits, adr);
178#ifdef CONFIG_32BIT
179 local_irq_restore(flags);
180#endif
181}
182static inline void txx9_set64(__u64 __iomem *adr, __u64 bits)
183{
184#ifdef CONFIG_32BIT
185 unsigned long flags;
186 local_irq_save(flags);
187#endif
188 ____raw_writeq(____raw_readq(adr) | bits, adr);
189#ifdef CONFIG_32BIT
190 local_irq_restore(flags);
191#endif
192}
193
194/* These functions are not interrupt safe. */
195static inline void tx4927_ccfg_clear(__u64 bits)
196{
197 ____raw_writeq(____raw_readq(&tx4927_ccfgptr->ccfg)
198 & ~(TX4927_CCFG_W1CBITS | bits),
199 &tx4927_ccfgptr->ccfg);
200}
201static inline void tx4927_ccfg_set(__u64 bits)
202{
203 ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
204 & ~TX4927_CCFG_W1CBITS) | bits,
205 &tx4927_ccfgptr->ccfg);
206}
207static inline void tx4927_ccfg_change(__u64 change, __u64 new)
208{
209 ____raw_writeq((____raw_readq(&tx4927_ccfgptr->ccfg)
210 & ~(TX4927_CCFG_W1CBITS | change)) |
211 new,
212 &tx4927_ccfgptr->ccfg);
213}
214
215int tx4927_report_pciclk(void);
216int tx4927_pciclk66_setup(void);
217void tx4927_irq_init(void);
218
219#endif /* __ASM_TXX9_TX4927_H */
diff --git a/include/asm-mips/txx9/tx4927pcic.h b/include/asm-mips/txx9/tx4927pcic.h
new file mode 100644
index 00000000000..d61c3d09c4a
--- /dev/null
+++ b/include/asm-mips/txx9/tx4927pcic.h
@@ -0,0 +1,199 @@
1/*
2 * include/asm-mips/txx9/tx4927pcic.h
3 * TX4927 PCI controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9_TX4927PCIC_H
10#define __ASM_TXX9_TX4927PCIC_H
11
12#include <linux/pci.h>
13
14struct tx4927_pcic_reg {
15 u32 pciid;
16 u32 pcistatus;
17 u32 pciccrev;
18 u32 pcicfg1;
19 u32 p2gm0plbase; /* +10 */
20 u32 p2gm0pubase;
21 u32 p2gm1plbase;
22 u32 p2gm1pubase;
23 u32 p2gm2pbase; /* +20 */
24 u32 p2giopbase;
25 u32 unused0;
26 u32 pcisid;
27 u32 unused1; /* +30 */
28 u32 pcicapptr;
29 u32 unused2;
30 u32 pcicfg2;
31 u32 g2ptocnt; /* +40 */
32 u32 unused3[15];
33 u32 g2pstatus; /* +80 */
34 u32 g2pmask;
35 u32 pcisstatus;
36 u32 pcimask;
37 u32 p2gcfg; /* +90 */
38 u32 p2gstatus;
39 u32 p2gmask;
40 u32 p2gccmd;
41 u32 unused4[24]; /* +a0 */
42 u32 pbareqport; /* +100 */
43 u32 pbacfg;
44 u32 pbastatus;
45 u32 pbamask;
46 u32 pbabm; /* +110 */
47 u32 pbacreq;
48 u32 pbacgnt;
49 u32 pbacstate;
50 u64 g2pmgbase[3]; /* +120 */
51 u64 g2piogbase;
52 u32 g2pmmask[3]; /* +140 */
53 u32 g2piomask;
54 u64 g2pmpbase[3]; /* +150 */
55 u64 g2piopbase;
56 u32 pciccfg; /* +170 */
57 u32 pcicstatus;
58 u32 pcicmask;
59 u32 unused5;
60 u64 p2gmgbase[3]; /* +180 */
61 u64 p2giogbase;
62 u32 g2pcfgadrs; /* +1a0 */
63 u32 g2pcfgdata;
64 u32 unused6[8];
65 u32 g2pintack;
66 u32 g2pspc;
67 u32 unused7[12]; /* +1d0 */
68 u64 pdmca; /* +200 */
69 u64 pdmga;
70 u64 pdmpa;
71 u64 pdmctr;
72 u64 pdmcfg; /* +220 */
73 u64 pdmsts;
74};
75
76/* bits for PCICMD */
77/* see PCI_COMMAND_XXX in linux/pci_regs.h */
78
79/* bits for PCISTAT */
80/* see PCI_STATUS_XXX in linux/pci_regs.h */
81
82/* bits for IOBA/MBA */
83/* see PCI_BASE_ADDRESS_XXX in linux/pci_regs.h */
84
85/* bits for G2PSTATUS/G2PMASK */
86#define TX4927_PCIC_G2PSTATUS_ALL 0x00000003
87#define TX4927_PCIC_G2PSTATUS_TTOE 0x00000002
88#define TX4927_PCIC_G2PSTATUS_RTOE 0x00000001
89
90/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci_regs.h */
91#define TX4927_PCIC_PCISTATUS_ALL 0x0000f900
92
93/* bits for PBACFG */
94#define TX4927_PCIC_PBACFG_FIXPA 0x00000008
95#define TX4927_PCIC_PBACFG_RPBA 0x00000004
96#define TX4927_PCIC_PBACFG_PBAEN 0x00000002
97#define TX4927_PCIC_PBACFG_BMCEN 0x00000001
98
99/* bits for PBASTATUS/PBAMASK */
100#define TX4927_PCIC_PBASTATUS_ALL 0x00000001
101#define TX4927_PCIC_PBASTATUS_BM 0x00000001
102
103/* bits for G2PMnGBASE */
104#define TX4927_PCIC_G2PMnGBASE_BSDIS 0x0000002000000000ULL
105#define TX4927_PCIC_G2PMnGBASE_ECHG 0x0000001000000000ULL
106
107/* bits for G2PIOGBASE */
108#define TX4927_PCIC_G2PIOGBASE_BSDIS 0x0000002000000000ULL
109#define TX4927_PCIC_G2PIOGBASE_ECHG 0x0000001000000000ULL
110
111/* bits for PCICSTATUS/PCICMASK */
112#define TX4927_PCIC_PCICSTATUS_ALL 0x000007b8
113#define TX4927_PCIC_PCICSTATUS_PME 0x00000400
114#define TX4927_PCIC_PCICSTATUS_TLB 0x00000200
115#define TX4927_PCIC_PCICSTATUS_NIB 0x00000100
116#define TX4927_PCIC_PCICSTATUS_ZIB 0x00000080
117#define TX4927_PCIC_PCICSTATUS_PERR 0x00000020
118#define TX4927_PCIC_PCICSTATUS_SERR 0x00000010
119#define TX4927_PCIC_PCICSTATUS_GBE 0x00000008
120#define TX4927_PCIC_PCICSTATUS_IWB 0x00000002
121#define TX4927_PCIC_PCICSTATUS_E2PDONE 0x00000001
122
123/* bits for PCICCFG */
124#define TX4927_PCIC_PCICCFG_GBWC_MASK 0x0fff0000
125#define TX4927_PCIC_PCICCFG_HRST 0x00000800
126#define TX4927_PCIC_PCICCFG_SRST 0x00000400
127#define TX4927_PCIC_PCICCFG_IRBER 0x00000200
128#define TX4927_PCIC_PCICCFG_G2PMEN(ch) (0x00000100>>(ch))
129#define TX4927_PCIC_PCICCFG_G2PM0EN 0x00000100
130#define TX4927_PCIC_PCICCFG_G2PM1EN 0x00000080
131#define TX4927_PCIC_PCICCFG_G2PM2EN 0x00000040
132#define TX4927_PCIC_PCICCFG_G2PIOEN 0x00000020
133#define TX4927_PCIC_PCICCFG_TCAR 0x00000010
134#define TX4927_PCIC_PCICCFG_ICAEN 0x00000008
135
136/* bits for P2GMnGBASE */
137#define TX4927_PCIC_P2GMnGBASE_TMEMEN 0x0000004000000000ULL
138#define TX4927_PCIC_P2GMnGBASE_TBSDIS 0x0000002000000000ULL
139#define TX4927_PCIC_P2GMnGBASE_TECHG 0x0000001000000000ULL
140
141/* bits for P2GIOGBASE */
142#define TX4927_PCIC_P2GIOGBASE_TIOEN 0x0000004000000000ULL
143#define TX4927_PCIC_P2GIOGBASE_TBSDIS 0x0000002000000000ULL
144#define TX4927_PCIC_P2GIOGBASE_TECHG 0x0000001000000000ULL
145
146#define TX4927_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)
147#define TX4927_PCIC_MAX_DEVNU TX4927_PCIC_IDSEL_AD_TO_SLOT(32)
148
149/* bits for PDMCFG */
150#define TX4927_PCIC_PDMCFG_RSTFIFO 0x00200000
151#define TX4927_PCIC_PDMCFG_EXFER 0x00100000
152#define TX4927_PCIC_PDMCFG_REQDLY_MASK 0x00003800
153#define TX4927_PCIC_PDMCFG_REQDLY_NONE (0 << 11)
154#define TX4927_PCIC_PDMCFG_REQDLY_16 (1 << 11)
155#define TX4927_PCIC_PDMCFG_REQDLY_32 (2 << 11)
156#define TX4927_PCIC_PDMCFG_REQDLY_64 (3 << 11)
157#define TX4927_PCIC_PDMCFG_REQDLY_128 (4 << 11)
158#define TX4927_PCIC_PDMCFG_REQDLY_256 (5 << 11)
159#define TX4927_PCIC_PDMCFG_REQDLY_512 (6 << 11)
160#define TX4927_PCIC_PDMCFG_REQDLY_1024 (7 << 11)
161#define TX4927_PCIC_PDMCFG_ERRIE 0x00000400
162#define TX4927_PCIC_PDMCFG_NCCMPIE 0x00000200
163#define TX4927_PCIC_PDMCFG_NTCMPIE 0x00000100
164#define TX4927_PCIC_PDMCFG_CHNEN 0x00000080
165#define TX4927_PCIC_PDMCFG_XFRACT 0x00000040
166#define TX4927_PCIC_PDMCFG_BSWAP 0x00000020
167#define TX4927_PCIC_PDMCFG_XFRSIZE_MASK 0x0000000c
168#define TX4927_PCIC_PDMCFG_XFRSIZE_1DW 0x00000000
169#define TX4927_PCIC_PDMCFG_XFRSIZE_1QW 0x00000004
170#define TX4927_PCIC_PDMCFG_XFRSIZE_4QW 0x00000008
171#define TX4927_PCIC_PDMCFG_XFRDIRC 0x00000002
172#define TX4927_PCIC_PDMCFG_CHRST 0x00000001
173
174/* bits for PDMSTS */
175#define TX4927_PCIC_PDMSTS_REQCNT_MASK 0x3f000000
176#define TX4927_PCIC_PDMSTS_FIFOCNT_MASK 0x00f00000
177#define TX4927_PCIC_PDMSTS_FIFOWP_MASK 0x000c0000
178#define TX4927_PCIC_PDMSTS_FIFORP_MASK 0x00030000
179#define TX4927_PCIC_PDMSTS_ERRINT 0x00000800
180#define TX4927_PCIC_PDMSTS_DONEINT 0x00000400
181#define TX4927_PCIC_PDMSTS_CHNEN 0x00000200
182#define TX4927_PCIC_PDMSTS_XFRACT 0x00000100
183#define TX4927_PCIC_PDMSTS_ACCMP 0x00000080
184#define TX4927_PCIC_PDMSTS_NCCMP 0x00000040
185#define TX4927_PCIC_PDMSTS_NTCMP 0x00000020
186#define TX4927_PCIC_PDMSTS_CFGERR 0x00000008
187#define TX4927_PCIC_PDMSTS_PCIERR 0x00000004
188#define TX4927_PCIC_PDMSTS_CHNERR 0x00000002
189#define TX4927_PCIC_PDMSTS_DATAERR 0x00000001
190#define TX4927_PCIC_PDMSTS_ALL_CMP 0x000000e0
191#define TX4927_PCIC_PDMSTS_ALL_ERR 0x0000000f
192
193struct tx4927_pcic_reg __iomem *get_tx4927_pcicptr(
194 struct pci_controller *channel);
195void __init tx4927_pcic_setup(struct tx4927_pcic_reg __iomem *pcicptr,
196 struct pci_controller *channel, int extarb);
197void tx4927_report_pcic_status(void);
198
199#endif /* __ASM_TXX9_TX4927PCIC_H */
diff --git a/include/asm-mips/tx4938/tx4938.h b/include/asm-mips/txx9/tx4938.h
index e8807f5c61e..12de68a4c10 100644
--- a/include/asm-mips/tx4938/tx4938.h
+++ b/include/asm-mips/txx9/tx4938.h
@@ -1,5 +1,4 @@
1/* 1/*
2 * linux/include/asm-mips/tx4938/tx4938.h
3 * Definitions for TX4937/TX4938 2 * Definitions for TX4937/TX4938
4 * Copyright (C) 2000-2001 Toshiba Corporation 3 * Copyright (C) 2000-2001 Toshiba Corporation
5 * 4 *
@@ -10,17 +9,15 @@
10 * 9 *
11 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com) 10 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
12 */ 11 */
13#ifndef __ASM_TX_BOARDS_TX4938_H 12#ifndef __ASM_TXX9_TX4938_H
14#define __ASM_TX_BOARDS_TX4938_H 13#define __ASM_TXX9_TX4938_H
14
15/* some controllers are compatible with 4927 */
16#include <asm/txx9/tx4927.h>
15 17
16#define tx4938_read_nfmc(addr) (*(volatile unsigned int *)(addr)) 18#define tx4938_read_nfmc(addr) (*(volatile unsigned int *)(addr))
17#define tx4938_write_nfmc(b, addr) (*(volatile unsigned int *)(addr)) = (b) 19#define tx4938_write_nfmc(b, addr) (*(volatile unsigned int *)(addr)) = (b)
18 20
19#define TX4938_NR_IRQ_LOCAL TX4938_IRQ_PIC_BEG
20
21#define TX4938_IRQ_IRC_PCIC (TX4938_NR_IRQ_LOCAL + TX4938_IR_PCIC)
22#define TX4938_IRQ_IRC_PCIERR (TX4938_NR_IRQ_LOCAL + TX4938_IR_PCIERR)
23
24#define TX4938_PCIIO_0 0x10000000 21#define TX4938_PCIIO_0 0x10000000
25#define TX4938_PCIIO_1 0x01010000 22#define TX4938_PCIIO_1 0x01010000
26#define TX4938_PCIMEM_0 0x08000000 23#define TX4938_PCIMEM_0 0x08000000
@@ -52,9 +49,6 @@
52#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700) 49#define TX4938_ACLC_REG (TX4938_REG_BASE + 0xf700)
53#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800) 50#define TX4938_SPI_REG (TX4938_REG_BASE + 0xf800)
54 51
55#ifdef __ASSEMBLY__
56#define _CONST64(c) c
57#else
58#define _CONST64(c) c##ull 52#define _CONST64(c) c##ull
59 53
60#include <asm/byteorder.h> 54#include <asm/byteorder.h>
@@ -114,68 +108,6 @@ struct tx4938_dma_reg {
114 endian_def_l2(unused0, mcr); 108 endian_def_l2(unused0, mcr);
115}; 109};
116 110
117struct tx4938_pcic_reg {
118 volatile unsigned long pciid;
119 volatile unsigned long pcistatus;
120 volatile unsigned long pciccrev;
121 volatile unsigned long pcicfg1;
122 volatile unsigned long p2gm0plbase; /* +10 */
123 volatile unsigned long p2gm0pubase;
124 volatile unsigned long p2gm1plbase;
125 volatile unsigned long p2gm1pubase;
126 volatile unsigned long p2gm2pbase; /* +20 */
127 volatile unsigned long p2giopbase;
128 volatile unsigned long unused0;
129 volatile unsigned long pcisid;
130 volatile unsigned long unused1; /* +30 */
131 volatile unsigned long pcicapptr;
132 volatile unsigned long unused2;
133 volatile unsigned long pcicfg2;
134 volatile unsigned long g2ptocnt; /* +40 */
135 volatile unsigned long unused3[15];
136 volatile unsigned long g2pstatus; /* +80 */
137 volatile unsigned long g2pmask;
138 volatile unsigned long pcisstatus;
139 volatile unsigned long pcimask;
140 volatile unsigned long p2gcfg; /* +90 */
141 volatile unsigned long p2gstatus;
142 volatile unsigned long p2gmask;
143 volatile unsigned long p2gccmd;
144 volatile unsigned long unused4[24]; /* +a0 */
145 volatile unsigned long pbareqport; /* +100 */
146 volatile unsigned long pbacfg;
147 volatile unsigned long pbastatus;
148 volatile unsigned long pbamask;
149 volatile unsigned long pbabm; /* +110 */
150 volatile unsigned long pbacreq;
151 volatile unsigned long pbacgnt;
152 volatile unsigned long pbacstate;
153 volatile unsigned long long g2pmgbase[3]; /* +120 */
154 volatile unsigned long long g2piogbase;
155 volatile unsigned long g2pmmask[3]; /* +140 */
156 volatile unsigned long g2piomask;
157 volatile unsigned long long g2pmpbase[3]; /* +150 */
158 volatile unsigned long long g2piopbase;
159 volatile unsigned long pciccfg; /* +170 */
160 volatile unsigned long pcicstatus;
161 volatile unsigned long pcicmask;
162 volatile unsigned long unused5;
163 volatile unsigned long long p2gmgbase[3]; /* +180 */
164 volatile unsigned long long p2giogbase;
165 volatile unsigned long g2pcfgadrs; /* +1a0 */
166 volatile unsigned long g2pcfgdata;
167 volatile unsigned long unused6[8];
168 volatile unsigned long g2pintack;
169 volatile unsigned long g2pspc;
170 volatile unsigned long unused7[12]; /* +1d0 */
171 volatile unsigned long long pdmca; /* +200 */
172 volatile unsigned long long pdmga;
173 volatile unsigned long long pdmpa;
174 volatile unsigned long long pdmctr;
175 volatile unsigned long long pdmcfg; /* +220 */
176 volatile unsigned long long pdmsts;
177};
178
179struct tx4938_aclc_reg { 111struct tx4938_aclc_reg {
180 volatile unsigned long acctlen; 112 volatile unsigned long acctlen;
181 volatile unsigned long acctldis; 113 volatile unsigned long acctldis;
@@ -263,18 +195,18 @@ struct tx4938_sramc_reg {
263}; 195};
264 196
265struct tx4938_ccfg_reg { 197struct tx4938_ccfg_reg {
266 volatile unsigned long long ccfg; 198 u64 ccfg;
267 volatile unsigned long long crir; 199 u64 crir;
268 volatile unsigned long long pcfg; 200 u64 pcfg;
269 volatile unsigned long long tear; 201 u64 toea;
270 volatile unsigned long long clkctr; 202 u64 clkctr;
271 volatile unsigned long long unused0; 203 u64 unused0;
272 volatile unsigned long long garbc; 204 u64 garbc;
273 volatile unsigned long long unused1; 205 u64 unused1;
274 volatile unsigned long long unused2; 206 u64 unused2;
275 volatile unsigned long long ramp; 207 u64 ramp;
276 volatile unsigned long long unused3; 208 u64 unused3;
277 volatile unsigned long long jmpadr; 209 u64 jmpadr;
278}; 210};
279 211
280#undef endian_def_l2 212#undef endian_def_l2
@@ -283,8 +215,6 @@ struct tx4938_ccfg_reg {
283#undef endian_def_b2s 215#undef endian_def_b2s
284#undef endian_def_b4 216#undef endian_def_b4
285 217
286#endif /* __ASSEMBLY__ */
287
288/* 218/*
289 * NDFMC 219 * NDFMC
290 */ 220 */
@@ -336,6 +266,8 @@ struct tx4938_ccfg_reg {
336#define TX4938_IR_ETH0 TX4938_IR_INT(4) 266#define TX4938_IR_ETH0 TX4938_IR_INT(4)
337#define TX4938_IR_ETH1 TX4938_IR_INT(3) 267#define TX4938_IR_ETH1 TX4938_IR_INT(3)
338 268
269#define TX4938_IRC_INT 2 /* IP[2] in Status register */
270
339/* 271/*
340 * CCFG 272 * CCFG
341 */ 273 */
@@ -361,7 +293,7 @@ struct tx4938_ccfg_reg {
361#define TX4938_CCFG_BEOW 0x00010000 293#define TX4938_CCFG_BEOW 0x00010000
362#define TX4938_CCFG_WR 0x00008000 294#define TX4938_CCFG_WR 0x00008000
363#define TX4938_CCFG_TOE 0x00004000 295#define TX4938_CCFG_TOE 0x00004000
364#define TX4938_CCFG_PCIXARB 0x00002000 296#define TX4938_CCFG_PCIARB 0x00002000
365#define TX4938_CCFG_PCIDIVMODE_MASK 0x00001c00 297#define TX4938_CCFG_PCIDIVMODE_MASK 0x00001c00
366#define TX4938_CCFG_PCIDIVMODE_4 (0x1 << 10) 298#define TX4938_CCFG_PCIDIVMODE_4 (0x1 << 10)
367#define TX4938_CCFG_PCIDIVMODE_4_5 (0x3 << 10) 299#define TX4938_CCFG_PCIDIVMODE_4_5 (0x3 << 10)
@@ -437,110 +369,6 @@ struct tx4938_ccfg_reg {
437#define TX4938_CLKCTR_SIO0RST 0x00000002 369#define TX4938_CLKCTR_SIO0RST 0x00000002
438#define TX4938_CLKCTR_SIO1RST 0x00000001 370#define TX4938_CLKCTR_SIO1RST 0x00000001
439 371
440/* bits for G2PSTATUS/G2PMASK */
441#define TX4938_PCIC_G2PSTATUS_ALL 0x00000003
442#define TX4938_PCIC_G2PSTATUS_TTOE 0x00000002
443#define TX4938_PCIC_G2PSTATUS_RTOE 0x00000001
444
445/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci.h */
446#define TX4938_PCIC_PCISTATUS_ALL 0x0000f900
447
448/* bits for PBACFG */
449#define TX4938_PCIC_PBACFG_FIXPA 0x00000008
450#define TX4938_PCIC_PBACFG_RPBA 0x00000004
451#define TX4938_PCIC_PBACFG_PBAEN 0x00000002
452#define TX4938_PCIC_PBACFG_BMCEN 0x00000001
453
454/* bits for G2PMnGBASE */
455#define TX4938_PCIC_G2PMnGBASE_BSDIS _CONST64(0x0000002000000000)
456#define TX4938_PCIC_G2PMnGBASE_ECHG _CONST64(0x0000001000000000)
457
458/* bits for G2PIOGBASE */
459#define TX4938_PCIC_G2PIOGBASE_BSDIS _CONST64(0x0000002000000000)
460#define TX4938_PCIC_G2PIOGBASE_ECHG _CONST64(0x0000001000000000)
461
462/* bits for PCICSTATUS/PCICMASK */
463#define TX4938_PCIC_PCICSTATUS_ALL 0x000007b8
464#define TX4938_PCIC_PCICSTATUS_PME 0x00000400
465#define TX4938_PCIC_PCICSTATUS_TLB 0x00000200
466#define TX4938_PCIC_PCICSTATUS_NIB 0x00000100
467#define TX4938_PCIC_PCICSTATUS_ZIB 0x00000080
468#define TX4938_PCIC_PCICSTATUS_PERR 0x00000020
469#define TX4938_PCIC_PCICSTATUS_SERR 0x00000010
470#define TX4938_PCIC_PCICSTATUS_GBE 0x00000008
471#define TX4938_PCIC_PCICSTATUS_IWB 0x00000002
472#define TX4938_PCIC_PCICSTATUS_E2PDONE 0x00000001
473
474/* bits for PCICCFG */
475#define TX4938_PCIC_PCICCFG_GBWC_MASK 0x0fff0000
476#define TX4938_PCIC_PCICCFG_HRST 0x00000800
477#define TX4938_PCIC_PCICCFG_SRST 0x00000400
478#define TX4938_PCIC_PCICCFG_IRBER 0x00000200
479#define TX4938_PCIC_PCICCFG_G2PMEN(ch) (0x00000100>>(ch))
480#define TX4938_PCIC_PCICCFG_G2PM0EN 0x00000100
481#define TX4938_PCIC_PCICCFG_G2PM1EN 0x00000080
482#define TX4938_PCIC_PCICCFG_G2PM2EN 0x00000040
483#define TX4938_PCIC_PCICCFG_G2PIOEN 0x00000020
484#define TX4938_PCIC_PCICCFG_TCAR 0x00000010
485#define TX4938_PCIC_PCICCFG_ICAEN 0x00000008
486
487/* bits for P2GMnGBASE */
488#define TX4938_PCIC_P2GMnGBASE_TMEMEN _CONST64(0x0000004000000000)
489#define TX4938_PCIC_P2GMnGBASE_TBSDIS _CONST64(0x0000002000000000)
490#define TX4938_PCIC_P2GMnGBASE_TECHG _CONST64(0x0000001000000000)
491
492/* bits for P2GIOGBASE */
493#define TX4938_PCIC_P2GIOGBASE_TIOEN _CONST64(0x0000004000000000)
494#define TX4938_PCIC_P2GIOGBASE_TBSDIS _CONST64(0x0000002000000000)
495#define TX4938_PCIC_P2GIOGBASE_TECHG _CONST64(0x0000001000000000)
496
497#define TX4938_PCIC_IDSEL_AD_TO_SLOT(ad) ((ad) - 11)
498#define TX4938_PCIC_MAX_DEVNU TX4938_PCIC_IDSEL_AD_TO_SLOT(32)
499
500/* bits for PDMCFG */
501#define TX4938_PCIC_PDMCFG_RSTFIFO 0x00200000
502#define TX4938_PCIC_PDMCFG_EXFER 0x00100000
503#define TX4938_PCIC_PDMCFG_REQDLY_MASK 0x00003800
504#define TX4938_PCIC_PDMCFG_REQDLY_NONE (0 << 11)
505#define TX4938_PCIC_PDMCFG_REQDLY_16 (1 << 11)
506#define TX4938_PCIC_PDMCFG_REQDLY_32 (2 << 11)
507#define TX4938_PCIC_PDMCFG_REQDLY_64 (3 << 11)
508#define TX4938_PCIC_PDMCFG_REQDLY_128 (4 << 11)
509#define TX4938_PCIC_PDMCFG_REQDLY_256 (5 << 11)
510#define TX4938_PCIC_PDMCFG_REQDLY_512 (6 << 11)
511#define TX4938_PCIC_PDMCFG_REQDLY_1024 (7 << 11)
512#define TX4938_PCIC_PDMCFG_ERRIE 0x00000400
513#define TX4938_PCIC_PDMCFG_NCCMPIE 0x00000200
514#define TX4938_PCIC_PDMCFG_NTCMPIE 0x00000100
515#define TX4938_PCIC_PDMCFG_CHNEN 0x00000080
516#define TX4938_PCIC_PDMCFG_XFRACT 0x00000040
517#define TX4938_PCIC_PDMCFG_BSWAP 0x00000020
518#define TX4938_PCIC_PDMCFG_XFRSIZE_MASK 0x0000000c
519#define TX4938_PCIC_PDMCFG_XFRSIZE_1DW 0x00000000
520#define TX4938_PCIC_PDMCFG_XFRSIZE_1QW 0x00000004
521#define TX4938_PCIC_PDMCFG_XFRSIZE_4QW 0x00000008
522#define TX4938_PCIC_PDMCFG_XFRDIRC 0x00000002
523#define TX4938_PCIC_PDMCFG_CHRST 0x00000001
524
525/* bits for PDMSTS */
526#define TX4938_PCIC_PDMSTS_REQCNT_MASK 0x3f000000
527#define TX4938_PCIC_PDMSTS_FIFOCNT_MASK 0x00f00000
528#define TX4938_PCIC_PDMSTS_FIFOWP_MASK 0x000c0000
529#define TX4938_PCIC_PDMSTS_FIFORP_MASK 0x00030000
530#define TX4938_PCIC_PDMSTS_ERRINT 0x00000800
531#define TX4938_PCIC_PDMSTS_DONEINT 0x00000400
532#define TX4938_PCIC_PDMSTS_CHNEN 0x00000200
533#define TX4938_PCIC_PDMSTS_XFRACT 0x00000100
534#define TX4938_PCIC_PDMSTS_ACCMP 0x00000080
535#define TX4938_PCIC_PDMSTS_NCCMP 0x00000040
536#define TX4938_PCIC_PDMSTS_NTCMP 0x00000020
537#define TX4938_PCIC_PDMSTS_CFGERR 0x00000008
538#define TX4938_PCIC_PDMSTS_PCIERR 0x00000004
539#define TX4938_PCIC_PDMSTS_CHNERR 0x00000002
540#define TX4938_PCIC_PDMSTS_DATAERR 0x00000001
541#define TX4938_PCIC_PDMSTS_ALL_CMP 0x000000e0
542#define TX4938_PCIC_PDMSTS_ALL_ERR 0x0000000f
543
544/* 372/*
545 * DMA 373 * DMA
546 */ 374 */
@@ -596,15 +424,15 @@ struct tx4938_ccfg_reg {
596#define TX4938_DMA_CSR_DESERR 0x00000002 424#define TX4938_DMA_CSR_DESERR 0x00000002
597#define TX4938_DMA_CSR_SORERR 0x00000001 425#define TX4938_DMA_CSR_SORERR 0x00000001
598 426
599#ifndef __ASSEMBLY__
600
601#define tx4938_sdramcptr ((struct tx4938_sdramc_reg *)TX4938_SDRAMC_REG) 427#define tx4938_sdramcptr ((struct tx4938_sdramc_reg *)TX4938_SDRAMC_REG)
602#define tx4938_ebuscptr ((struct tx4938_ebusc_reg *)TX4938_EBUSC_REG) 428#define tx4938_ebuscptr ((struct tx4938_ebusc_reg *)TX4938_EBUSC_REG)
603#define tx4938_dmaptr(ch) ((struct tx4938_dma_reg *)TX4938_DMA_REG(ch)) 429#define tx4938_dmaptr(ch) ((struct tx4938_dma_reg *)TX4938_DMA_REG(ch))
604#define tx4938_ndfmcptr ((struct tx4938_ndfmc_reg *)TX4938_NDFMC_REG) 430#define tx4938_ndfmcptr ((struct tx4938_ndfmc_reg *)TX4938_NDFMC_REG)
605#define tx4938_pcicptr ((struct tx4938_pcic_reg *)TX4938_PCIC_REG) 431#define tx4938_pcicptr tx4927_pcicptr
606#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG) 432#define tx4938_pcic1ptr \
607#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG) 433 ((struct tx4927_pcic_reg __iomem *)TX4938_PCIC1_REG)
434#define tx4938_ccfgptr \
435 ((struct tx4938_ccfg_reg __iomem *)TX4938_CCFG_REG)
608#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch)) 436#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch))
609#define tx4938_pioptr ((struct txx9_pio_reg __iomem *)TX4938_PIO_REG) 437#define tx4938_pioptr ((struct txx9_pio_reg __iomem *)TX4938_PIO_REG)
610#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG) 438#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG)
@@ -612,17 +440,26 @@ struct tx4938_ccfg_reg {
612#define tx4938_sramcptr ((struct tx4938_sramc_reg *)TX4938_SRAMC_REG) 440#define tx4938_sramcptr ((struct tx4938_sramc_reg *)TX4938_SRAMC_REG)
613 441
614 442
615#define TX4938_REV_MAJ_MIN() ((unsigned long)tx4938_ccfgptr->crir & 0x00ff) 443#define TX4938_REV_PCODE() \
616#define TX4938_REV_PCODE() ((unsigned long)tx4938_ccfgptr->crir >> 16) 444 ((__u32)__raw_readq(&tx4938_ccfgptr->crir) >> 16)
445
446#define tx4938_ccfg_clear(bits) tx4927_ccfg_clear(bits)
447#define tx4938_ccfg_set(bits) tx4927_ccfg_set(bits)
448#define tx4938_ccfg_change(change, new) tx4927_ccfg_change(change, new)
617 449
618#define TX4938_SDRAMC_BA(ch) ((tx4938_sdramcptr->cr[ch] >> 49) << 21) 450#define TX4938_SDRAMC_BA(ch) ((tx4938_sdramcptr->cr[ch] >> 49) << 21)
619#define TX4938_SDRAMC_SIZE(ch) (((tx4938_sdramcptr->cr[ch] >> 33) + 1) << 21) 451#define TX4938_SDRAMC_SIZE(ch) (((tx4938_sdramcptr->cr[ch] >> 33) + 1) << 21)
620 452
453#define TX4938_EBUSC_CR(ch) __raw_readq(&tx4938_ebuscptr->cr[(ch)])
621#define TX4938_EBUSC_BA(ch) ((tx4938_ebuscptr->cr[ch] >> 48) << 20) 454#define TX4938_EBUSC_BA(ch) ((tx4938_ebuscptr->cr[ch] >> 48) << 20)
622#define TX4938_EBUSC_SIZE(ch) \ 455#define TX4938_EBUSC_SIZE(ch) \
623 (0x00100000 << ((unsigned long)(tx4938_ebuscptr->cr[ch] >> 8) & 0xf)) 456 (0x00100000 << ((unsigned long)(tx4938_ebuscptr->cr[ch] >> 8) & 0xf))
624 457
625 458int tx4938_report_pciclk(void);
626#endif /* !__ASSEMBLY__ */ 459void tx4938_report_pci1clk(void);
460int tx4938_pciclk66_setup(void);
461struct pci_dev;
462int tx4938_pcic1_map_irq(const struct pci_dev *dev, u8 slot);
463void tx4938_irq_init(void);
627 464
628#endif 465#endif
diff --git a/include/asm-mips/jmr3927/txx927.h b/include/asm-mips/txx9/txx927.h
index 25dcf2feb09..97dd7ad1a89 100644
--- a/include/asm-mips/jmr3927/txx927.h
+++ b/include/asm-mips/txx9/txx927.h
@@ -7,8 +7,8 @@
7 * 7 *
8 * Copyright (C) 2000 Toshiba Corporation 8 * Copyright (C) 2000 Toshiba Corporation
9 */ 9 */
10#ifndef __ASM_TXX927_H 10#ifndef __ASM_TXX9_TXX927_H
11#define __ASM_TXX927_H 11#define __ASM_TXX9_TXX927_H
12 12
13struct txx927_sio_reg { 13struct txx927_sio_reg {
14 volatile unsigned long lcr; 14 volatile unsigned long lcr;
@@ -118,4 +118,4 @@ struct txx927_sio_reg {
118 * PIO 118 * PIO
119 */ 119 */
120 120
121#endif /* __ASM_TXX927_H */ 121#endif /* __ASM_TXX9_TXX927_H */
diff --git a/include/asm-mips/vr41xx/cmbvr4133.h b/include/asm-mips/vr41xx/cmbvr4133.h
deleted file mode 100644
index 42300037d59..00000000000
--- a/include/asm-mips/vr41xx/cmbvr4133.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * include/asm-mips/vr41xx/cmbvr4133.h
3 *
4 * Include file for NEC CMB-VR4133.
5 *
6 * Author: Yoichi Yuasa <yyuasa@mvista.com, or source@mvista.com> and
7 * Jun Sun <jsun@mvista.com, or source@mvista.com> and
8 * Alex Sapkov <asapkov@ru.mvista.com>
9 *
10 * 2002-2004 (c) MontaVista, Software, Inc. This file is licensed under
11 * the terms of the GNU General Public License version 2. This program
12 * is licensed "as is" without any warranty of any kind, whether express
13 * or implied.
14 */
15#ifndef __NEC_CMBVR4133_H
16#define __NEC_CMBVR4133_H
17
18#include <asm/vr41xx/irq.h>
19
20/*
21 * General-Purpose I/O Pin Number
22 */
23#define CMBVR41XX_INTA_PIN 1
24#define CMBVR41XX_INTB_PIN 1
25#define CMBVR41XX_INTC_PIN 3
26#define CMBVR41XX_INTD_PIN 1
27#define CMBVR41XX_INTE_PIN 1
28
29/*
30 * Interrupt Number
31 */
32#define CMBVR41XX_INTA_IRQ GIU_IRQ(CMBVR41XX_INTA_PIN)
33#define CMBVR41XX_INTB_IRQ GIU_IRQ(CMBVR41XX_INTB_PIN)
34#define CMBVR41XX_INTC_IRQ GIU_IRQ(CMBVR41XX_INTC_PIN)
35#define CMBVR41XX_INTD_IRQ GIU_IRQ(CMBVR41XX_INTD_PIN)
36#define CMBVR41XX_INTE_IRQ GIU_IRQ(CMBVR41XX_INTE_PIN)
37
38#define I8259A_IRQ_BASE 72
39#define I8259_IRQ(x) (I8259A_IRQ_BASE + (x))
40#define TIMER_IRQ I8259_IRQ(0)
41#define KEYBOARD_IRQ I8259_IRQ(1)
42#define I8259_SLAVE_IRQ I8259_IRQ(2)
43#define UART3_IRQ I8259_IRQ(3)
44#define UART1_IRQ I8259_IRQ(4)
45#define UART2_IRQ I8259_IRQ(5)
46#define FDC_IRQ I8259_IRQ(6)
47#define PARPORT_IRQ I8259_IRQ(7)
48#define RTC_IRQ I8259_IRQ(8)
49#define USB_IRQ I8259_IRQ(9)
50#define I8259_INTA_IRQ I8259_IRQ(10)
51#define AUDIO_IRQ I8259_IRQ(11)
52#define AUX_IRQ I8259_IRQ(12)
53#define IDE_PRIMARY_IRQ I8259_IRQ(14)
54#define IDE_SECONDARY_IRQ I8259_IRQ(15)
55
56#endif /* __NEC_CMBVR4133_H */
diff --git a/include/asm-parisc/smp.h b/include/asm-parisc/smp.h
index 306f4950e32..398cdbaf4e5 100644
--- a/include/asm-parisc/smp.h
+++ b/include/asm-parisc/smp.h
@@ -30,6 +30,9 @@ extern cpumask_t cpu_online_map;
30extern void smp_send_reschedule(int cpu); 30extern void smp_send_reschedule(int cpu);
31extern void smp_send_all_nop(void); 31extern void smp_send_all_nop(void);
32 32
33extern void arch_send_call_function_single_ipi(int cpu);
34extern void arch_send_call_function_ipi(cpumask_t mask);
35
33#endif /* !ASSEMBLY */ 36#endif /* !ASSEMBLY */
34 37
35/* 38/*
diff --git a/include/asm-powerpc/smp.h b/include/asm-powerpc/smp.h
index 505f35bacaa..c663a1fa77c 100644
--- a/include/asm-powerpc/smp.h
+++ b/include/asm-powerpc/smp.h
@@ -67,10 +67,7 @@ DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
67 * in /proc/interrupts will be wrong!!! --Troy */ 67 * in /proc/interrupts will be wrong!!! --Troy */
68#define PPC_MSG_CALL_FUNCTION 0 68#define PPC_MSG_CALL_FUNCTION 0
69#define PPC_MSG_RESCHEDULE 1 69#define PPC_MSG_RESCHEDULE 1
70/* This is unused now */ 70#define PPC_MSG_CALL_FUNC_SINGLE 2
71#if 0
72#define PPC_MSG_MIGRATE_TASK 2
73#endif
74#define PPC_MSG_DEBUGGER_BREAK 3 71#define PPC_MSG_DEBUGGER_BREAK 3
75 72
76void smp_init_iSeries(void); 73void smp_init_iSeries(void);
@@ -117,6 +114,9 @@ extern void smp_generic_take_timebase(void);
117 114
118extern struct smp_ops_t *smp_ops; 115extern struct smp_ops_t *smp_ops;
119 116
117extern void arch_send_call_function_single_ipi(int cpu);
118extern void arch_send_call_function_ipi(cpumask_t mask);
119
120#endif /* __ASSEMBLY__ */ 120#endif /* __ASSEMBLY__ */
121 121
122#endif /* __KERNEL__ */ 122#endif /* __KERNEL__ */
diff --git a/include/asm-sh/smp.h b/include/asm-sh/smp.h
index 9c8d34b07eb..593343cd26e 100644
--- a/include/asm-sh/smp.h
+++ b/include/asm-sh/smp.h
@@ -26,18 +26,10 @@ extern int __cpu_logical_map[NR_CPUS];
26 26
27#define NO_PROC_ID (-1) 27#define NO_PROC_ID (-1)
28 28
29struct smp_fn_call_struct {
30 spinlock_t lock;
31 atomic_t finished;
32 void (*fn)(void *);
33 void *data;
34};
35
36extern struct smp_fn_call_struct smp_fn_call;
37
38#define SMP_MSG_FUNCTION 0 29#define SMP_MSG_FUNCTION 0
39#define SMP_MSG_RESCHEDULE 1 30#define SMP_MSG_RESCHEDULE 1
40#define SMP_MSG_NR 2 31#define SMP_MSG_FUNCTION_SINGLE 2
32#define SMP_MSG_NR 3
41 33
42void plat_smp_setup(void); 34void plat_smp_setup(void);
43void plat_prepare_cpus(unsigned int max_cpus); 35void plat_prepare_cpus(unsigned int max_cpus);
@@ -46,6 +38,8 @@ void plat_start_cpu(unsigned int cpu, unsigned long entry_point);
46void plat_send_ipi(unsigned int cpu, unsigned int message); 38void plat_send_ipi(unsigned int cpu, unsigned int message);
47int plat_register_ipi_handler(unsigned int message, 39int plat_register_ipi_handler(unsigned int message,
48 void (*handler)(void *), void *arg); 40 void (*handler)(void *), void *arg);
41extern void arch_send_call_function_single_ipi(int cpu);
42extern void arch_send_call_function_ipi(cpumask_t mask);
49 43
50#else 44#else
51 45
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index e6d56159972..b61e74bea06 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -72,7 +72,7 @@ static inline void xc5(smpfunc_t func, unsigned long arg1, unsigned long arg2,
72 unsigned long arg3, unsigned long arg4, unsigned long arg5) 72 unsigned long arg3, unsigned long arg4, unsigned long arg5)
73{ smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); } 73{ smp_cross_call(func, arg1, arg2, arg3, arg4, arg5); }
74 74
75static inline int smp_call_function(void (*func)(void *info), void *info, int nonatomic, int wait) 75static inline int smp_call_function(void (*func)(void *info), void *info, int wait)
76{ 76{
77 xc1((smpfunc_t)func, (unsigned long)info); 77 xc1((smpfunc_t)func, (unsigned long)info);
78 return 0; 78 return 0;
diff --git a/include/asm-x86/dwarf2.h b/include/asm-x86/dwarf2.h
index 0bfe250894f..738bb9fb3e5 100644
--- a/include/asm-x86/dwarf2.h
+++ b/include/asm-x86/dwarf2.h
@@ -38,23 +38,23 @@
38 38
39/* Due to the structure of pre-exisiting code, don't use assembler line 39/* Due to the structure of pre-exisiting code, don't use assembler line
40 comment character # to ignore the arguments. Instead, use a dummy macro. */ 40 comment character # to ignore the arguments. Instead, use a dummy macro. */
41.macro ignore a=0, b=0, c=0, d=0 41.macro cfi_ignore a=0, b=0, c=0, d=0
42.endm 42.endm
43 43
44#define CFI_STARTPROC ignore 44#define CFI_STARTPROC cfi_ignore
45#define CFI_ENDPROC ignore 45#define CFI_ENDPROC cfi_ignore
46#define CFI_DEF_CFA ignore 46#define CFI_DEF_CFA cfi_ignore
47#define CFI_DEF_CFA_REGISTER ignore 47#define CFI_DEF_CFA_REGISTER cfi_ignore
48#define CFI_DEF_CFA_OFFSET ignore 48#define CFI_DEF_CFA_OFFSET cfi_ignore
49#define CFI_ADJUST_CFA_OFFSET ignore 49#define CFI_ADJUST_CFA_OFFSET cfi_ignore
50#define CFI_OFFSET ignore 50#define CFI_OFFSET cfi_ignore
51#define CFI_REL_OFFSET ignore 51#define CFI_REL_OFFSET cfi_ignore
52#define CFI_REGISTER ignore 52#define CFI_REGISTER cfi_ignore
53#define CFI_RESTORE ignore 53#define CFI_RESTORE cfi_ignore
54#define CFI_REMEMBER_STATE ignore 54#define CFI_REMEMBER_STATE cfi_ignore
55#define CFI_RESTORE_STATE ignore 55#define CFI_RESTORE_STATE cfi_ignore
56#define CFI_UNDEFINED ignore 56#define CFI_UNDEFINED cfi_ignore
57#define CFI_SIGNAL_FRAME ignore 57#define CFI_SIGNAL_FRAME cfi_ignore
58 58
59#endif 59#endif
60 60
diff --git a/include/asm-x86/hw_irq.h b/include/asm-x86/hw_irq.h
index 18f067c310f..77ba51df566 100644
--- a/include/asm-x86/hw_irq.h
+++ b/include/asm-x86/hw_irq.h
@@ -48,6 +48,7 @@ extern void irq_move_cleanup_interrupt(void);
48extern void threshold_interrupt(void); 48extern void threshold_interrupt(void);
49 49
50extern void call_function_interrupt(void); 50extern void call_function_interrupt(void);
51extern void call_function_single_interrupt(void);
51 52
52/* PIC specific functions */ 53/* PIC specific functions */
53extern void disable_8259A_irq(unsigned int irq); 54extern void disable_8259A_irq(unsigned int irq);
diff --git a/include/asm-x86/irq_vectors.h b/include/asm-x86/irq_vectors.h
index 0ac864ef3cd..90b1d1f12f0 100644
--- a/include/asm-x86/irq_vectors.h
+++ b/include/asm-x86/irq_vectors.h
@@ -64,6 +64,7 @@
64# define INVALIDATE_TLB_VECTOR 0xfd 64# define INVALIDATE_TLB_VECTOR 0xfd
65# define RESCHEDULE_VECTOR 0xfc 65# define RESCHEDULE_VECTOR 0xfc
66# define CALL_FUNCTION_VECTOR 0xfb 66# define CALL_FUNCTION_VECTOR 0xfb
67# define CALL_FUNCTION_SINGLE_VECTOR 0xfa
67# define THERMAL_APIC_VECTOR 0xf0 68# define THERMAL_APIC_VECTOR 0xf0
68 69
69#else 70#else
@@ -72,6 +73,7 @@
72#define ERROR_APIC_VECTOR 0xfe 73#define ERROR_APIC_VECTOR 0xfe
73#define RESCHEDULE_VECTOR 0xfd 74#define RESCHEDULE_VECTOR 0xfd
74#define CALL_FUNCTION_VECTOR 0xfc 75#define CALL_FUNCTION_VECTOR 0xfc
76#define CALL_FUNCTION_SINGLE_VECTOR 0xfb
75#define THERMAL_APIC_VECTOR 0xfa 77#define THERMAL_APIC_VECTOR 0xfa
76#define THRESHOLD_APIC_VECTOR 0xf9 78#define THRESHOLD_APIC_VECTOR 0xf9
77#define INVALIDATE_TLB_VECTOR_END 0xf7 79#define INVALIDATE_TLB_VECTOR_END 0xf7
@@ -143,6 +145,7 @@
143#define VIC_RESCHEDULE_CPI 4 145#define VIC_RESCHEDULE_CPI 4
144#define VIC_ENABLE_IRQ_CPI 5 146#define VIC_ENABLE_IRQ_CPI 5
145#define VIC_CALL_FUNCTION_CPI 6 147#define VIC_CALL_FUNCTION_CPI 6
148#define VIC_CALL_FUNCTION_SINGLE_CPI 7
146 149
147/* Now the QIC CPIs: Since we don't need the two initial levels, 150/* Now the QIC CPIs: Since we don't need the two initial levels,
148 * these are 2 less than the VIC CPIs */ 151 * these are 2 less than the VIC CPIs */
@@ -152,9 +155,10 @@
152#define QIC_RESCHEDULE_CPI (VIC_RESCHEDULE_CPI - QIC_CPI_OFFSET) 155#define QIC_RESCHEDULE_CPI (VIC_RESCHEDULE_CPI - QIC_CPI_OFFSET)
153#define QIC_ENABLE_IRQ_CPI (VIC_ENABLE_IRQ_CPI - QIC_CPI_OFFSET) 156#define QIC_ENABLE_IRQ_CPI (VIC_ENABLE_IRQ_CPI - QIC_CPI_OFFSET)
154#define QIC_CALL_FUNCTION_CPI (VIC_CALL_FUNCTION_CPI - QIC_CPI_OFFSET) 157#define QIC_CALL_FUNCTION_CPI (VIC_CALL_FUNCTION_CPI - QIC_CPI_OFFSET)
158#define QIC_CALL_FUNCTION_SINGLE_CPI (VIC_CALL_FUNCTION_SINGLE_CPI - QIC_CPI_OFFSET)
155 159
156#define VIC_START_FAKE_CPI VIC_TIMER_CPI 160#define VIC_START_FAKE_CPI VIC_TIMER_CPI
157#define VIC_END_FAKE_CPI VIC_CALL_FUNCTION_CPI 161#define VIC_END_FAKE_CPI VIC_CALL_FUNCTION_SINGLE_CPI
158 162
159/* this is the SYS_INT CPI. */ 163/* this is the SYS_INT CPI. */
160#define VIC_SYS_INT 8 164#define VIC_SYS_INT 8
diff --git a/include/asm-x86/mach-default/entry_arch.h b/include/asm-x86/mach-default/entry_arch.h
index bc861469bdb..9283b60a1dd 100644
--- a/include/asm-x86/mach-default/entry_arch.h
+++ b/include/asm-x86/mach-default/entry_arch.h
@@ -13,6 +13,7 @@
13BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) 13BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR)
14BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR) 14BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR)
15BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) 15BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR)
16BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR)
16#endif 17#endif
17 18
18/* 19/*
diff --git a/include/asm-x86/mach-visws/entry_arch.h b/include/asm-x86/mach-visws/entry_arch.h
index b183fa6d83d..86be554342d 100644
--- a/include/asm-x86/mach-visws/entry_arch.h
+++ b/include/asm-x86/mach-visws/entry_arch.h
@@ -1,23 +1,5 @@
1/* 1/*
2 * The following vectors are part of the Linux architecture, there 2 * VISWS uses the standard Linux entry points:
3 * is no hardware IRQ pin equivalent for them, they are triggered
4 * through the ICC by us (IPIs)
5 */ 3 */
6#ifdef CONFIG_X86_SMP
7BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR)
8BUILD_INTERRUPT(invalidate_interrupt,INVALIDATE_TLB_VECTOR)
9BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR)
10#endif
11 4
12/* 5#include "../mach-default/entry_arch.h"
13 * every pentium local APIC has two 'local interrupts', with a
14 * soft-definable vector attached to both interrupts, one of
15 * which is a timer interrupt, the other one is error counter
16 * overflow. Linux uses the local APIC timer interrupt to get
17 * a much simpler SMP time architecture:
18 */
19#ifdef CONFIG_X86_LOCAL_APIC
20BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR)
21BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR)
22BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR)
23#endif
diff --git a/include/asm-x86/mach-voyager/entry_arch.h b/include/asm-x86/mach-voyager/entry_arch.h
index 4a1e1e8c10b..ae52624b593 100644
--- a/include/asm-x86/mach-voyager/entry_arch.h
+++ b/include/asm-x86/mach-voyager/entry_arch.h
@@ -23,4 +23,4 @@ BUILD_INTERRUPT(qic_invalidate_interrupt, QIC_INVALIDATE_CPI);
23BUILD_INTERRUPT(qic_reschedule_interrupt, QIC_RESCHEDULE_CPI); 23BUILD_INTERRUPT(qic_reschedule_interrupt, QIC_RESCHEDULE_CPI);
24BUILD_INTERRUPT(qic_enable_irq_interrupt, QIC_ENABLE_IRQ_CPI); 24BUILD_INTERRUPT(qic_enable_irq_interrupt, QIC_ENABLE_IRQ_CPI);
25BUILD_INTERRUPT(qic_call_function_interrupt, QIC_CALL_FUNCTION_CPI); 25BUILD_INTERRUPT(qic_call_function_interrupt, QIC_CALL_FUNCTION_CPI);
26 26BUILD_INTERRUPT(qic_call_function_single_interrupt, QIC_CALL_FUNCTION_SINGLE_CPI);
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h
index 2e221f1ce0b..c2784b3e0b7 100644
--- a/include/asm-x86/smp.h
+++ b/include/asm-x86/smp.h
@@ -50,9 +50,9 @@ struct smp_ops {
50 50
51 void (*smp_send_stop)(void); 51 void (*smp_send_stop)(void);
52 void (*smp_send_reschedule)(int cpu); 52 void (*smp_send_reschedule)(int cpu);
53 int (*smp_call_function_mask)(cpumask_t mask, 53
54 void (*func)(void *info), void *info, 54 void (*send_call_func_ipi)(cpumask_t mask);
55 int wait); 55 void (*send_call_func_single_ipi)(int cpu);
56}; 56};
57 57
58/* Globals due to paravirt */ 58/* Globals due to paravirt */
@@ -94,17 +94,22 @@ static inline void smp_send_reschedule(int cpu)
94 smp_ops.smp_send_reschedule(cpu); 94 smp_ops.smp_send_reschedule(cpu);
95} 95}
96 96
97static inline int smp_call_function_mask(cpumask_t mask, 97static inline void arch_send_call_function_single_ipi(int cpu)
98 void (*func) (void *info), void *info, 98{
99 int wait) 99 smp_ops.send_call_func_single_ipi(cpu);
100}
101
102static inline void arch_send_call_function_ipi(cpumask_t mask)
100{ 103{
101 return smp_ops.smp_call_function_mask(mask, func, info, wait); 104 smp_ops.send_call_func_ipi(mask);
102} 105}
103 106
104void native_smp_prepare_boot_cpu(void); 107void native_smp_prepare_boot_cpu(void);
105void native_smp_prepare_cpus(unsigned int max_cpus); 108void native_smp_prepare_cpus(unsigned int max_cpus);
106void native_smp_cpus_done(unsigned int max_cpus); 109void native_smp_cpus_done(unsigned int max_cpus);
107int native_cpu_up(unsigned int cpunum); 110int native_cpu_up(unsigned int cpunum);
111void native_send_call_func_ipi(cpumask_t mask);
112void native_send_call_func_single_ipi(int cpu);
108 113
109extern int __cpu_disable(void); 114extern int __cpu_disable(void);
110extern void __cpu_die(unsigned int cpu); 115extern void __cpu_die(unsigned int cpu);
@@ -197,7 +202,5 @@ static inline int hard_smp_processor_id(void)
197extern void cpu_uninit(void); 202extern void cpu_uninit(void);
198#endif 203#endif
199 204
200extern void lock_ipi_call_lock(void);
201extern void unlock_ipi_call_lock(void);
202#endif /* __ASSEMBLY__ */ 205#endif /* __ASSEMBLY__ */
203#endif 206#endif
diff --git a/include/asm-x86/xen/events.h b/include/asm-x86/xen/events.h
index 596312a7bfc..f8d57ea1f05 100644
--- a/include/asm-x86/xen/events.h
+++ b/include/asm-x86/xen/events.h
@@ -4,6 +4,7 @@
4enum ipi_vector { 4enum ipi_vector {
5 XEN_RESCHEDULE_VECTOR, 5 XEN_RESCHEDULE_VECTOR,
6 XEN_CALL_FUNCTION_VECTOR, 6 XEN_CALL_FUNCTION_VECTOR,
7 XEN_CALL_FUNCTION_SINGLE_VECTOR,
7 8
8 XEN_NR_IPIS, 9 XEN_NR_IPIS,
9}; 10};
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0764b662b33..1c1b13e2922 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1089,6 +1089,7 @@ extern int drm_mm_remove_space_from_tail(struct drm_mm *mm, unsigned long size);
1089extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size); 1089extern int drm_mm_add_space_to_tail(struct drm_mm *mm, unsigned long size);
1090 1090
1091extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev); 1091extern void drm_core_ioremap(struct drm_map *map, struct drm_device *dev);
1092extern void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev);
1092extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev); 1093extern void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev);
1093 1094
1094static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev, 1095static __inline__ struct drm_map *drm_core_findmap(struct drm_device *dev,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 1ffd8bfdc4c..32a441b05fd 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -651,7 +651,6 @@ extern void generic_make_request(struct bio *bio);
651extern void blk_rq_init(struct request_queue *q, struct request *rq); 651extern void blk_rq_init(struct request_queue *q, struct request *rq);
652extern void blk_put_request(struct request *); 652extern void blk_put_request(struct request *);
653extern void __blk_put_request(struct request_queue *, struct request *); 653extern void __blk_put_request(struct request_queue *, struct request *);
654extern void blk_end_sync_rq(struct request *rq, int error);
655extern struct request *blk_get_request(struct request_queue *, int, gfp_t); 654extern struct request *blk_get_request(struct request_queue *, int, gfp_t);
656extern void blk_insert_request(struct request_queue *, struct request *, int, void *); 655extern void blk_insert_request(struct request_queue *, struct request *, int, void *);
657extern void blk_requeue_request(struct request_queue *, struct request *); 656extern void blk_requeue_request(struct request_queue *, struct request *);
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index d982eb89c77..98202c672fd 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -3,6 +3,7 @@
3 3
4#include <asm/atomic.h> 4#include <asm/atomic.h>
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/rculist.h>
6#include <linux/spinlock.h> 7#include <linux/spinlock.h>
7#include <linux/cache.h> 8#include <linux/cache.h>
8#include <linux/rcupdate.h> 9#include <linux/rcupdate.h>
diff --git a/include/linux/fs.h b/include/linux/fs.h
index faac13e2cc5..52e510a0aec 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1740,6 +1740,8 @@ extern int wait_on_page_writeback_range(struct address_space *mapping,
1740 pgoff_t start, pgoff_t end); 1740 pgoff_t start, pgoff_t end);
1741extern int __filemap_fdatawrite_range(struct address_space *mapping, 1741extern int __filemap_fdatawrite_range(struct address_space *mapping,
1742 loff_t start, loff_t end, int sync_mode); 1742 loff_t start, loff_t end, int sync_mode);
1743extern int filemap_fdatawrite_range(struct address_space *mapping,
1744 loff_t start, loff_t end);
1743 1745
1744extern long do_fsync(struct file *file, int datasync); 1746extern long do_fsync(struct file *file, int datasync);
1745extern void sync_supers(void); 1747extern void sync_supers(void);
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 77afbb60fd1..0177d280f73 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -33,9 +33,11 @@ struct i2c_algo_pcf_data {
33 int (*getclock) (void *data); 33 int (*getclock) (void *data);
34 void (*waitforpin) (void); 34 void (*waitforpin) (void);
35 35
36 /* local settings */ 36 /* Multi-master lost arbitration back-off delay (msecs)
37 int udelay; 37 * This should be set by the bus adapter or knowledgable client
38 int timeout; 38 * if bus is multi-mastered, else zero
39 */
40 unsigned long lab_mdelay;
39}; 41};
40 42
41int i2c_pcf_add_bus(struct i2c_adapter *); 43int i2c_pcf_add_bus(struct i2c_adapter *);
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 580acc93903..ef13b7c66df 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -91,8 +91,6 @@
91#define I2C_DRIVERID_M52790 95 /* Mitsubishi M52790SP/FP AV switch */ 91#define I2C_DRIVERID_M52790 95 /* Mitsubishi M52790SP/FP AV switch */
92#define I2C_DRIVERID_CS5345 96 /* cs5345 audio processor */ 92#define I2C_DRIVERID_CS5345 96 /* cs5345 audio processor */
93 93
94#define I2C_DRIVERID_I2CDEV 900
95
96#define I2C_DRIVERID_OV7670 1048 /* Omnivision 7670 camera */ 94#define I2C_DRIVERID_OV7670 1048 /* Omnivision 7670 camera */
97 95
98/* 96/*
@@ -111,7 +109,6 @@
111#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ 109#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */
112#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ 110#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */
113#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ 111#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */
114#define I2C_HW_B_S3VIA 0x010018 /* S3Via ProSavage adapter */
115#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */ 112#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */
116#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */ 113#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */
117#define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */ 114#define I2C_HW_B_CX2388x 0x01001b /* connexant 2388x based tv cards */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8dc73013219..08be0d21864 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -35,6 +35,8 @@
35#include <linux/sched.h> /* for completion */ 35#include <linux/sched.h> /* for completion */
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37 37
38extern struct bus_type i2c_bus_type;
39
38/* --- General options ------------------------------------------------ */ 40/* --- General options ------------------------------------------------ */
39 41
40struct i2c_msg; 42struct i2c_msg;
@@ -43,6 +45,7 @@ struct i2c_adapter;
43struct i2c_client; 45struct i2c_client;
44struct i2c_driver; 46struct i2c_driver;
45union i2c_smbus_data; 47union i2c_smbus_data;
48struct i2c_board_info;
46 49
47/* 50/*
48 * The master routines are the ones normally used to transmit data to devices 51 * The master routines are the ones normally used to transmit data to devices
@@ -69,9 +72,8 @@ extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr,
69 union i2c_smbus_data * data); 72 union i2c_smbus_data * data);
70 73
71/* Now follow the 'nice' access routines. These also document the calling 74/* Now follow the 'nice' access routines. These also document the calling
72 conventions of smbus_access. */ 75 conventions of i2c_smbus_xfer. */
73 76
74extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value);
75extern s32 i2c_smbus_read_byte(struct i2c_client * client); 77extern s32 i2c_smbus_read_byte(struct i2c_client * client);
76extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 78extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value);
77extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 79extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command);
@@ -93,15 +95,33 @@ extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
93 u8 command, u8 length, 95 u8 command, u8 length,
94 const u8 *values); 96 const u8 *values);
95 97
96/* 98/**
97 * A driver is capable of handling one or more physical devices present on 99 * struct i2c_driver - represent an I2C device driver
98 * I2C adapters. This information is used to inform the driver of adapter 100 * @class: What kind of i2c device we instantiate (for detect)
99 * events. 101 * @detect: Callback for device detection
102 * @address_data: The I2C addresses to probe, ignore or force (for detect)
103 * @clients: List of detected clients we created (for i2c-core use only)
100 * 104 *
101 * The driver.owner field should be set to the module owner of this driver. 105 * The driver.owner field should be set to the module owner of this driver.
102 * The driver.name field should be set to the name of this driver. 106 * The driver.name field should be set to the name of this driver.
107 *
108 * For automatic device detection, both @detect and @address_data must
109 * be defined. @class should also be set, otherwise only devices forced
110 * with module parameters will be created. The detect function must
111 * fill at least the name field of the i2c_board_info structure it is
112 * handed upon successful detection, and possibly also the flags field.
113 *
114 * If @detect is missing, the driver will still work fine for enumerated
115 * devices. Detected devices simply won't be supported. This is expected
116 * for the many I2C/SMBus devices which can't be detected reliably, and
117 * the ones which can always be enumerated in practice.
118 *
119 * The i2c_client structure which is handed to the @detect callback is
120 * not a real i2c_client. It is initialized just enough so that you can
121 * call i2c_smbus_read_byte_data and friends on it. Don't do anything
122 * else with it. In particular, calling dev_dbg and friends on it is
123 * not allowed.
103 */ 124 */
104
105struct i2c_driver { 125struct i2c_driver {
106 int id; 126 int id;
107 unsigned int class; 127 unsigned int class;
@@ -141,6 +161,11 @@ struct i2c_driver {
141 161
142 struct device_driver driver; 162 struct device_driver driver;
143 const struct i2c_device_id *id_table; 163 const struct i2c_device_id *id_table;
164
165 /* Device detection callback for automatic device creation */
166 int (*detect)(struct i2c_client *, int kind, struct i2c_board_info *);
167 const struct i2c_client_address_data *address_data;
168 struct list_head clients;
144}; 169};
145#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 170#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
146 171
@@ -156,6 +181,7 @@ struct i2c_driver {
156 * @dev: Driver model device node for the slave. 181 * @dev: Driver model device node for the slave.
157 * @irq: indicates the IRQ generated by this device (if any) 182 * @irq: indicates the IRQ generated by this device (if any)
158 * @list: list of active/busy clients (DEPRECATED) 183 * @list: list of active/busy clients (DEPRECATED)
184 * @detected: member of an i2c_driver.clients list
159 * @released: used to synchronize client releases & detaches and references 185 * @released: used to synchronize client releases & detaches and references
160 * 186 *
161 * An i2c_client identifies a single device (i.e. chip) connected to an 187 * An i2c_client identifies a single device (i.e. chip) connected to an
@@ -173,6 +199,7 @@ struct i2c_client {
173 struct device dev; /* the device structure */ 199 struct device dev; /* the device structure */
174 int irq; /* irq issued by device */ 200 int irq; /* irq issued by device */
175 struct list_head list; /* DEPRECATED */ 201 struct list_head list; /* DEPRECATED */
202 struct list_head detected;
176 struct completion released; 203 struct completion released;
177}; 204};
178#define to_i2c_client(d) container_of(d, struct i2c_client, dev) 205#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
@@ -350,10 +377,11 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
350#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */ 377#define I2C_CLASS_HWMON (1<<0) /* lm_sensors, ... */
351#define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ 378#define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
352#define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */ 379#define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
353#define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ 380#define I2C_CLASS_DDC (1<<3) /* DDC bus on graphics adapters */
354#define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */ 381#define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
355#define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */ 382#define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
356#define I2C_CLASS_SOUND (1<<6) /* sound devices */ 383#define I2C_CLASS_SOUND (1<<6) /* sound devices */
384#define I2C_CLASS_SPD (1<<7) /* SPD EEPROMs and similar */
357#define I2C_CLASS_ALL (UINT_MAX) /* all of the above */ 385#define I2C_CLASS_ALL (UINT_MAX) /* all of the above */
358 386
359/* i2c_client_address_data is the struct for holding default client 387/* i2c_client_address_data is the struct for holding default client
@@ -537,7 +565,7 @@ union i2c_smbus_data {
537 /* and one more for user-space compatibility */ 565 /* and one more for user-space compatibility */
538}; 566};
539 567
540/* smbus_access read or write markers */ 568/* i2c_smbus_xfer read or write markers */
541#define I2C_SMBUS_READ 1 569#define I2C_SMBUS_READ 1
542#define I2C_SMBUS_WRITE 0 570#define I2C_SMBUS_WRITE 0
543 571
diff --git a/include/linux/i2c/at24.h b/include/linux/i2c/at24.h
new file mode 100644
index 00000000000..f6edd522a92
--- /dev/null
+++ b/include/linux/i2c/at24.h
@@ -0,0 +1,28 @@
1#ifndef _LINUX_AT24_H
2#define _LINUX_AT24_H
3
4#include <linux/types.h>
5
6/*
7 * As seen through Linux I2C, differences between the most common types of I2C
8 * memory include:
9 * - How much memory is available (usually specified in bit)?
10 * - What write page size does it support?
11 * - Special flags (16 bit addresses, read_only, world readable...)?
12 *
13 * If you set up a custom eeprom type, please double-check the parameters.
14 * Especially page_size needs extra care, as you risk data loss if your value
15 * is bigger than what the chip actually supports!
16 */
17
18struct at24_platform_data {
19 u32 byte_len; /* size (sum of all addr) */
20 u16 page_size; /* for writes */
21 u8 flags;
22#define AT24_FLAG_ADDR16 0x80 /* address pointer is 16 bit */
23#define AT24_FLAG_READONLY 0x40 /* sysfs-entry will be read-only */
24#define AT24_FLAG_IRUGO 0x20 /* sysfs-entry will be world-readable */
25#define AT24_FLAG_TAKE8ADDR 0x10 /* take always 8 addresses (24c00) */
26};
27
28#endif /* _LINUX_AT24_H */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index eddb6daadf4..ac4eeb2932e 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -364,7 +364,6 @@ typedef struct ide_drive_s {
364 u8 wcache; /* status of write cache */ 364 u8 wcache; /* status of write cache */
365 u8 acoustic; /* acoustic management */ 365 u8 acoustic; /* acoustic management */
366 u8 media; /* disk, cdrom, tape, floppy, ... */ 366 u8 media; /* disk, cdrom, tape, floppy, ... */
367 u8 ctl; /* "normal" value for Control register */
368 u8 ready_stat; /* min status value for drive ready */ 367 u8 ready_stat; /* min status value for drive ready */
369 u8 mult_count; /* current multiple sector setting */ 368 u8 mult_count; /* current multiple sector setting */
370 u8 mult_req; /* requested multiple sector setting */ 369 u8 mult_req; /* requested multiple sector setting */
@@ -493,7 +492,7 @@ typedef struct hwif_s {
493 void (*ide_dma_clear_irq)(ide_drive_t *drive); 492 void (*ide_dma_clear_irq)(ide_drive_t *drive);
494 493
495 void (*OUTB)(u8 addr, unsigned long port); 494 void (*OUTB)(u8 addr, unsigned long port);
496 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); 495 void (*OUTBSYNC)(struct hwif_s *hwif, u8 addr, unsigned long port);
497 496
498 u8 (*INB)(unsigned long port); 497 u8 (*INB)(unsigned long port);
499 498
@@ -532,7 +531,6 @@ typedef struct hwif_s {
532 unsigned serialized : 1; /* serialized all channel operation */ 531 unsigned serialized : 1; /* serialized all channel operation */
533 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 532 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
534 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 533 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
535 unsigned mmio : 1; /* host uses MMIO */
536 534
537 struct device gendev; 535 struct device gendev;
538 struct device *portdev; 536 struct device *portdev;
@@ -604,12 +602,13 @@ enum {
604 PC_FLAG_SUPPRESS_ERROR = (1 << 1), 602 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
605 PC_FLAG_WAIT_FOR_DSC = (1 << 2), 603 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
606 PC_FLAG_DMA_OK = (1 << 3), 604 PC_FLAG_DMA_OK = (1 << 3),
607 PC_FLAG_DMA_RECOMMENDED = (1 << 4), 605 PC_FLAG_DMA_IN_PROGRESS = (1 << 4),
608 PC_FLAG_DMA_IN_PROGRESS = (1 << 5), 606 PC_FLAG_DMA_ERROR = (1 << 5),
609 PC_FLAG_DMA_ERROR = (1 << 6), 607 PC_FLAG_WRITING = (1 << 6),
610 PC_FLAG_WRITING = (1 << 7),
611 /* command timed out */ 608 /* command timed out */
612 PC_FLAG_TIMEDOUT = (1 << 8), 609 PC_FLAG_TIMEDOUT = (1 << 7),
610 PC_FLAG_ZIP_DRIVE = (1 << 8),
611 PC_FLAG_DRQ_INTERRUPT = (1 << 9),
613}; 612};
614 613
615struct ide_atapi_pc { 614struct ide_atapi_pc {
@@ -642,8 +641,8 @@ struct ide_atapi_pc {
642 * to change/removal later. 641 * to change/removal later.
643 */ 642 */
644 u8 pc_buf[256]; 643 u8 pc_buf[256];
645 void (*idefloppy_callback) (ide_drive_t *); 644
646 ide_startstop_t (*idetape_callback) (ide_drive_t *); 645 void (*callback)(ide_drive_t *);
647 646
648 /* idetape only */ 647 /* idetape only */
649 struct idetape_bh *bh; 648 struct idetape_bh *bh;
@@ -813,10 +812,6 @@ int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsig
813#ifndef _IDE_C 812#ifndef _IDE_C
814extern ide_hwif_t ide_hwifs[]; /* master data repository */ 813extern ide_hwif_t ide_hwifs[]; /* master data repository */
815#endif 814#endif
816extern int ide_noacpi;
817extern int ide_acpigtf;
818extern int ide_acpionboot;
819extern int noautodma;
820 815
821extern int ide_vlb_clk; 816extern int ide_vlb_clk;
822extern int ide_pci_clk; 817extern int ide_pci_clk;
@@ -857,25 +852,12 @@ int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
857 852
858extern ide_startstop_t ide_do_reset (ide_drive_t *); 853extern ide_startstop_t ide_do_reset (ide_drive_t *);
859 854
860extern void ide_init_drive_cmd (struct request *rq); 855extern void ide_do_drive_cmd(ide_drive_t *, struct request *);
861
862/*
863 * "action" parameter type for ide_do_drive_cmd() below.
864 */
865typedef enum {
866 ide_wait, /* insert rq at end of list, and wait for it */
867 ide_preempt, /* insert rq in front of current request */
868 ide_head_wait, /* insert rq in front of current request and wait for it */
869 ide_end /* insert rq at end of list, but don't wait for it */
870} ide_action_t;
871
872extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
873 856
874extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 857extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
875 858
876enum { 859enum {
877 IDE_TFLAG_LBA48 = (1 << 0), 860 IDE_TFLAG_LBA48 = (1 << 0),
878 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
879 IDE_TFLAG_FLAGGED = (1 << 2), 861 IDE_TFLAG_FLAGGED = (1 << 2),
880 IDE_TFLAG_OUT_DATA = (1 << 3), 862 IDE_TFLAG_OUT_DATA = (1 << 3),
881 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4), 863 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
@@ -980,11 +962,23 @@ typedef struct ide_task_s {
980void ide_tf_dump(const char *, struct ide_taskfile *); 962void ide_tf_dump(const char *, struct ide_taskfile *);
981 963
982extern void SELECT_DRIVE(ide_drive_t *); 964extern void SELECT_DRIVE(ide_drive_t *);
965void SELECT_MASK(ide_drive_t *, int);
983 966
984extern int drive_is_ready(ide_drive_t *); 967extern int drive_is_ready(ide_drive_t *);
985 968
986void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); 969void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
987 970
971ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
972 ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
973 void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),
974 void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *),
975 void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int,
976 int));
977ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *,
978 ide_handler_t *, unsigned int, ide_expiry_t *);
979ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
980 ide_handler_t *, unsigned int, ide_expiry_t *);
981
988ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 982ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
989 983
990void task_end_request(ide_drive_t *, struct request *, u8); 984void task_end_request(ide_drive_t *, struct request *, u8);
@@ -996,8 +990,6 @@ int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
996int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 990int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
997int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); 991int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
998 992
999extern int system_bus_clock(void);
1000
1001extern int ide_driveid_update(ide_drive_t *); 993extern int ide_driveid_update(ide_drive_t *);
1002extern int ide_config_drive_speed(ide_drive_t *, u8); 994extern int ide_config_drive_speed(ide_drive_t *, u8);
1003extern u8 eighty_ninty_three (ide_drive_t *); 995extern u8 eighty_ninty_three (ide_drive_t *);
@@ -1349,7 +1341,8 @@ static inline void ide_set_irq(ide_drive_t *drive, int on)
1349{ 1341{
1350 ide_hwif_t *hwif = drive->hwif; 1342 ide_hwif_t *hwif = drive->hwif;
1351 1343
1352 hwif->OUTB(drive->ctl | (on ? 0 : 2), hwif->io_ports.ctl_addr); 1344 hwif->OUTBSYNC(hwif, ATA_DEVCTL_OBS | (on ? 0 : 2),
1345 hwif->io_ports.ctl_addr);
1353} 1346}
1354 1347
1355static inline u8 ide_read_status(ide_drive_t *drive) 1348static inline u8 ide_read_status(ide_drive_t *drive)
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index a86186dd047..62aa4f895ab 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -104,8 +104,11 @@ extern void enable_irq(unsigned int irq);
104 104
105#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS) 105#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
106 106
107extern cpumask_t irq_default_affinity;
108
107extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask); 109extern int irq_set_affinity(unsigned int irq, cpumask_t cpumask);
108extern int irq_can_set_affinity(unsigned int irq); 110extern int irq_can_set_affinity(unsigned int irq);
111extern int irq_select_affinity(unsigned int irq);
109 112
110#else /* CONFIG_SMP */ 113#else /* CONFIG_SMP */
111 114
@@ -119,6 +122,8 @@ static inline int irq_can_set_affinity(unsigned int irq)
119 return 0; 122 return 0;
120} 123}
121 124
125static inline int irq_select_affinity(unsigned int irq) { return 0; }
126
122#endif /* CONFIG_SMP && CONFIG_GENERIC_HARDIRQS */ 127#endif /* CONFIG_SMP && CONFIG_GENERIC_HARDIRQS */
123 128
124#ifdef CONFIG_GENERIC_HARDIRQS 129#ifdef CONFIG_GENERIC_HARDIRQS
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 552e0ec269c..8ccb462ea42 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -244,15 +244,6 @@ static inline void set_balance_irq_affinity(unsigned int irq, cpumask_t mask)
244} 244}
245#endif 245#endif
246 246
247#ifdef CONFIG_AUTO_IRQ_AFFINITY
248extern int select_smp_affinity(unsigned int irq);
249#else
250static inline int select_smp_affinity(unsigned int irq)
251{
252 return 1;
253}
254#endif
255
256extern int no_irq_affinity; 247extern int no_irq_affinity;
257 248
258static inline int irq_balancing_disabled(unsigned int irq) 249static inline int irq_balancing_disabled(unsigned int irq)
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index d147f0f9036..3dd20900709 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -168,6 +168,8 @@ struct commit_header {
168 unsigned char h_chksum_size; 168 unsigned char h_chksum_size;
169 unsigned char h_padding[2]; 169 unsigned char h_padding[2];
170 __be32 h_chksum[JBD2_CHECKSUM_BYTES]; 170 __be32 h_chksum[JBD2_CHECKSUM_BYTES];
171 __be64 h_commit_sec;
172 __be32 h_commit_nsec;
171}; 173};
172 174
173/* 175/*
@@ -379,6 +381,38 @@ static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh)
379 bit_spin_unlock(BH_JournalHead, &bh->b_state); 381 bit_spin_unlock(BH_JournalHead, &bh->b_state);
380} 382}
381 383
384/* Flags in jbd_inode->i_flags */
385#define __JI_COMMIT_RUNNING 0
386/* Commit of the inode data in progress. We use this flag to protect us from
387 * concurrent deletion of inode. We cannot use reference to inode for this
388 * since we cannot afford doing last iput() on behalf of kjournald
389 */
390#define JI_COMMIT_RUNNING (1 << __JI_COMMIT_RUNNING)
391
392/**
393 * struct jbd_inode is the structure linking inodes in ordered mode
394 * present in a transaction so that we can sync them during commit.
395 */
396struct jbd2_inode {
397 /* Which transaction does this inode belong to? Either the running
398 * transaction or the committing one. [j_list_lock] */
399 transaction_t *i_transaction;
400
401 /* Pointer to the running transaction modifying inode's data in case
402 * there is already a committing transaction touching it. [j_list_lock] */
403 transaction_t *i_next_transaction;
404
405 /* List of inodes in the i_transaction [j_list_lock] */
406 struct list_head i_list;
407
408 /* VFS inode this inode belongs to [constant during the lifetime
409 * of the structure] */
410 struct inode *i_vfs_inode;
411
412 /* Flags of inode [j_list_lock] */
413 unsigned int i_flags;
414};
415
382struct jbd2_revoke_table_s; 416struct jbd2_revoke_table_s;
383 417
384/** 418/**
@@ -509,24 +543,12 @@ struct transaction_s
509 struct journal_head *t_reserved_list; 543 struct journal_head *t_reserved_list;
510 544
511 /* 545 /*
512 * Doubly-linked circular list of all buffers under writeout during
513 * commit [j_list_lock]
514 */
515 struct journal_head *t_locked_list;
516
517 /*
518 * Doubly-linked circular list of all metadata buffers owned by this 546 * Doubly-linked circular list of all metadata buffers owned by this
519 * transaction [j_list_lock] 547 * transaction [j_list_lock]
520 */ 548 */
521 struct journal_head *t_buffers; 549 struct journal_head *t_buffers;
522 550
523 /* 551 /*
524 * Doubly-linked circular list of all data buffers still to be
525 * flushed before this transaction can be committed [j_list_lock]
526 */
527 struct journal_head *t_sync_datalist;
528
529 /*
530 * Doubly-linked circular list of all forget buffers (superseded 552 * Doubly-linked circular list of all forget buffers (superseded
531 * buffers which we can un-checkpoint once this transaction commits) 553 * buffers which we can un-checkpoint once this transaction commits)
532 * [j_list_lock] 554 * [j_list_lock]
@@ -565,6 +587,12 @@ struct transaction_s
565 struct journal_head *t_log_list; 587 struct journal_head *t_log_list;
566 588
567 /* 589 /*
590 * List of inodes whose data we've modified in data=ordered mode.
591 * [j_list_lock]
592 */
593 struct list_head t_inode_list;
594
595 /*
568 * Protects info related to handles 596 * Protects info related to handles
569 */ 597 */
570 spinlock_t t_handle_lock; 598 spinlock_t t_handle_lock;
@@ -1004,7 +1032,6 @@ extern int jbd2_journal_extend (handle_t *, int nblocks);
1004extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *); 1032extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
1005extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *); 1033extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
1006extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *); 1034extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
1007extern int jbd2_journal_dirty_data (handle_t *, struct buffer_head *);
1008extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *); 1035extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
1009extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *); 1036extern void jbd2_journal_release_buffer (handle_t *, struct buffer_head *);
1010extern int jbd2_journal_forget (handle_t *, struct buffer_head *); 1037extern int jbd2_journal_forget (handle_t *, struct buffer_head *);
@@ -1044,6 +1071,10 @@ extern void jbd2_journal_ack_err (journal_t *);
1044extern int jbd2_journal_clear_err (journal_t *); 1071extern int jbd2_journal_clear_err (journal_t *);
1045extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *); 1072extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *);
1046extern int jbd2_journal_force_commit(journal_t *); 1073extern int jbd2_journal_force_commit(journal_t *);
1074extern int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *inode);
1075extern int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode, loff_t new_size);
1076extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode);
1077extern void jbd2_journal_release_jbd_inode(journal_t *journal, struct jbd2_inode *jinode);
1047 1078
1048/* 1079/*
1049 * journal_head management 1080 * journal_head management
@@ -1179,15 +1210,13 @@ static inline int jbd_space_needed(journal_t *journal)
1179 1210
1180/* journaling buffer types */ 1211/* journaling buffer types */
1181#define BJ_None 0 /* Not journaled */ 1212#define BJ_None 0 /* Not journaled */
1182#define BJ_SyncData 1 /* Normal data: flush before commit */ 1213#define BJ_Metadata 1 /* Normal journaled metadata */
1183#define BJ_Metadata 2 /* Normal journaled metadata */ 1214#define BJ_Forget 2 /* Buffer superseded by this transaction */
1184#define BJ_Forget 3 /* Buffer superseded by this transaction */ 1215#define BJ_IO 3 /* Buffer is for temporary IO use */
1185#define BJ_IO 4 /* Buffer is for temporary IO use */ 1216#define BJ_Shadow 4 /* Buffer contents being shadowed to the log */
1186#define BJ_Shadow 5 /* Buffer contents being shadowed to the log */ 1217#define BJ_LogCtl 5 /* Buffer contains log descriptors */
1187#define BJ_LogCtl 6 /* Buffer contains log descriptors */ 1218#define BJ_Reserved 6 /* Buffer is reserved for access by journal */
1188#define BJ_Reserved 7 /* Buffer is reserved for access by journal */ 1219#define BJ_Types 7
1189#define BJ_Locked 8 /* Locked for I/O during commit */
1190#define BJ_Types 9
1191 1220
1192extern int jbd_blocks_per_page(struct inode *inode); 1221extern int jbd_blocks_per_page(struct inode *inode);
1193 1222
diff --git a/include/linux/libata.h b/include/linux/libata.h
index e57e5d08312..5b247b8a6b3 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -27,6 +27,7 @@
27#define __LINUX_LIBATA_H__ 27#define __LINUX_LIBATA_H__
28 28
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/jiffies.h>
30#include <linux/interrupt.h> 31#include <linux/interrupt.h>
31#include <linux/dma-mapping.h> 32#include <linux/dma-mapping.h>
32#include <linux/scatterlist.h> 33#include <linux/scatterlist.h>
@@ -115,7 +116,7 @@ enum {
115 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */ 116 /* tag ATA_MAX_QUEUE - 1 is reserved for internal commands */
116 ATA_MAX_QUEUE = 32, 117 ATA_MAX_QUEUE = 32,
117 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1, 118 ATA_TAG_INTERNAL = ATA_MAX_QUEUE - 1,
118 ATA_SHORT_PAUSE = (HZ >> 6) + 1, 119 ATA_SHORT_PAUSE = 16,
119 120
120 ATAPI_MAX_DRAIN = 16 << 10, 121 ATAPI_MAX_DRAIN = 16 << 10,
121 122
@@ -168,6 +169,7 @@ enum {
168 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB, 169 ATA_LFLAG_ASSUME_CLASS = ATA_LFLAG_ASSUME_ATA | ATA_LFLAG_ASSUME_SEMB,
169 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */ 170 ATA_LFLAG_NO_RETRY = (1 << 5), /* don't retry this link */
170 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */ 171 ATA_LFLAG_DISABLED = (1 << 6), /* link is disabled */
172 ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */
171 173
172 /* struct ata_port flags */ 174 /* struct ata_port flags */
173 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ 175 ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */
@@ -190,6 +192,10 @@ enum {
190 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 192 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
191 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 193 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
192 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */ 194 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
195 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
196 * management */
197 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
198 * led */
193 199
194 /* The following flag belongs to ap->pflags but is kept in 200 /* The following flag belongs to ap->pflags but is kept in
195 * ap->flags because it's referenced in many LLDs and will be 201 * ap->flags because it's referenced in many LLDs and will be
@@ -234,17 +240,16 @@ enum {
234 /* bits 24:31 of host->flags are reserved for LLD specific flags */ 240 /* bits 24:31 of host->flags are reserved for LLD specific flags */
235 241
236 /* various lengths of time */ 242 /* various lengths of time */
237 ATA_TMOUT_BOOT = 30 * HZ, /* heuristic */ 243 ATA_TMOUT_BOOT = 30000, /* heuristic */
238 ATA_TMOUT_BOOT_QUICK = 7 * HZ, /* heuristic */ 244 ATA_TMOUT_BOOT_QUICK = 7000, /* heuristic */
239 ATA_TMOUT_INTERNAL = 30 * HZ, 245 ATA_TMOUT_INTERNAL_QUICK = 5000,
240 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,
241 246
242 /* FIXME: GoVault needs 2s but we can't afford that without 247 /* FIXME: GoVault needs 2s but we can't afford that without
243 * parallel probing. 800ms is enough for iVDR disk 248 * parallel probing. 800ms is enough for iVDR disk
244 * HHD424020F7SV00. Increase to 2secs when parallel probing 249 * HHD424020F7SV00. Increase to 2secs when parallel probing
245 * is in place. 250 * is in place.
246 */ 251 */
247 ATA_TMOUT_FF_WAIT = 4 * HZ / 5, 252 ATA_TMOUT_FF_WAIT = 800,
248 253
249 /* Spec mandates to wait for ">= 2ms" before checking status 254 /* Spec mandates to wait for ">= 2ms" before checking status
250 * after reset. We wait 150ms, because that was the magic 255 * after reset. We wait 150ms, because that was the magic
@@ -256,14 +261,14 @@ enum {
256 * 261 *
257 * Old drivers/ide uses the 2mS rule and then waits for ready. 262 * Old drivers/ide uses the 2mS rule and then waits for ready.
258 */ 263 */
259 ATA_WAIT_AFTER_RESET_MSECS = 150, 264 ATA_WAIT_AFTER_RESET = 150,
260 265
261 /* If PMP is supported, we have to do follow-up SRST. As some 266 /* If PMP is supported, we have to do follow-up SRST. As some
262 * PMPs don't send D2H Reg FIS after hardreset, LLDs are 267 * PMPs don't send D2H Reg FIS after hardreset, LLDs are
263 * advised to wait only for the following duration before 268 * advised to wait only for the following duration before
264 * doing SRST. 269 * doing SRST.
265 */ 270 */
266 ATA_TMOUT_PMP_SRST_WAIT = 1 * HZ, 271 ATA_TMOUT_PMP_SRST_WAIT = 1000,
267 272
268 /* ATA bus states */ 273 /* ATA bus states */
269 BUS_UNKNOWN = 0, 274 BUS_UNKNOWN = 0,
@@ -340,6 +345,11 @@ enum {
340 345
341 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */ 346 SATA_PMP_RW_TIMEOUT = 3000, /* PMP read/write timeout */
342 347
348 /* This should match the actual table size of
349 * ata_eh_cmd_timeout_table in libata-eh.c.
350 */
351 ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 5,
352
343 /* Horkage types. May be set by libata or controller on drives 353 /* Horkage types. May be set by libata or controller on drives
344 (some horkage may be drive/controller pair dependant */ 354 (some horkage may be drive/controller pair dependant */
345 355
@@ -441,6 +451,15 @@ enum link_pm {
441 MEDIUM_POWER, 451 MEDIUM_POWER,
442}; 452};
443extern struct device_attribute dev_attr_link_power_management_policy; 453extern struct device_attribute dev_attr_link_power_management_policy;
454extern struct device_attribute dev_attr_em_message_type;
455extern struct device_attribute dev_attr_em_message;
456extern struct device_attribute dev_attr_sw_activity;
457
458enum sw_activity {
459 OFF,
460 BLINK_ON,
461 BLINK_OFF,
462};
444 463
445#ifdef CONFIG_ATA_SFF 464#ifdef CONFIG_ATA_SFF
446struct ata_ioports { 465struct ata_ioports {
@@ -597,10 +616,14 @@ struct ata_eh_info {
597struct ata_eh_context { 616struct ata_eh_context {
598 struct ata_eh_info i; 617 struct ata_eh_info i;
599 int tries[ATA_MAX_DEVICES]; 618 int tries[ATA_MAX_DEVICES];
619 int cmd_timeout_idx[ATA_MAX_DEVICES]
620 [ATA_EH_CMD_TIMEOUT_TABLE_SIZE];
600 unsigned int classes[ATA_MAX_DEVICES]; 621 unsigned int classes[ATA_MAX_DEVICES];
601 unsigned int did_probe_mask; 622 unsigned int did_probe_mask;
602 unsigned int saved_ncq_enabled; 623 unsigned int saved_ncq_enabled;
603 u8 saved_xfer_mode[ATA_MAX_DEVICES]; 624 u8 saved_xfer_mode[ATA_MAX_DEVICES];
625 /* timestamp for the last reset attempt or success */
626 unsigned long last_reset;
604}; 627};
605 628
606struct ata_acpi_drive 629struct ata_acpi_drive
@@ -692,6 +715,7 @@ struct ata_port {
692 struct timer_list fastdrain_timer; 715 struct timer_list fastdrain_timer;
693 unsigned long fastdrain_cnt; 716 unsigned long fastdrain_cnt;
694 717
718 int em_message_type;
695 void *private_data; 719 void *private_data;
696 720
697#ifdef CONFIG_ATA_ACPI 721#ifdef CONFIG_ATA_ACPI
@@ -783,6 +807,12 @@ struct ata_port_operations {
783 u8 (*bmdma_status)(struct ata_port *ap); 807 u8 (*bmdma_status)(struct ata_port *ap);
784#endif /* CONFIG_ATA_SFF */ 808#endif /* CONFIG_ATA_SFF */
785 809
810 ssize_t (*em_show)(struct ata_port *ap, char *buf);
811 ssize_t (*em_store)(struct ata_port *ap, const char *message,
812 size_t size);
813 ssize_t (*sw_activity_show)(struct ata_device *dev, char *buf);
814 ssize_t (*sw_activity_store)(struct ata_device *dev,
815 enum sw_activity val);
786 /* 816 /*
787 * Obsolete 817 * Obsolete
788 */ 818 */
@@ -895,8 +925,7 @@ extern void ata_host_resume(struct ata_host *host);
895#endif 925#endif
896extern int ata_ratelimit(void); 926extern int ata_ratelimit(void);
897extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 927extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
898 unsigned long interval_msec, 928 unsigned long interval, unsigned long timeout);
899 unsigned long timeout_msec);
900extern int atapi_cmd_type(u8 opcode); 929extern int atapi_cmd_type(u8 opcode);
901extern void ata_tf_to_fis(const struct ata_taskfile *tf, 930extern void ata_tf_to_fis(const struct ata_taskfile *tf,
902 u8 pmp, int is_cmd, u8 *fis); 931 u8 pmp, int is_cmd, u8 *fis);
@@ -1389,6 +1418,12 @@ static inline int ata_check_ready(u8 status)
1389 return 0; 1418 return 0;
1390} 1419}
1391 1420
1421static inline unsigned long ata_deadline(unsigned long from_jiffies,
1422 unsigned long timeout_msecs)
1423{
1424 return from_jiffies + msecs_to_jiffies(timeout_msecs);
1425}
1426
1392 1427
1393/************************************************************************** 1428/**************************************************************************
1394 * PMP - drivers/ata/libata-pmp.c 1429 * PMP - drivers/ata/libata-pmp.c
diff --git a/include/linux/list.h b/include/linux/list.h
index 08cf4f65188..139ec41d9c2 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -85,65 +85,6 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
85} 85}
86 86
87/* 87/*
88 * Insert a new entry between two known consecutive entries.
89 *
90 * This is only for internal list manipulation where we know
91 * the prev/next entries already!
92 */
93static inline void __list_add_rcu(struct list_head * new,
94 struct list_head * prev, struct list_head * next)
95{
96 new->next = next;
97 new->prev = prev;
98 smp_wmb();
99 next->prev = new;
100 prev->next = new;
101}
102
103/**
104 * list_add_rcu - add a new entry to rcu-protected list
105 * @new: new entry to be added
106 * @head: list head to add it after
107 *
108 * Insert a new entry after the specified head.
109 * This is good for implementing stacks.
110 *
111 * The caller must take whatever precautions are necessary
112 * (such as holding appropriate locks) to avoid racing
113 * with another list-mutation primitive, such as list_add_rcu()
114 * or list_del_rcu(), running on this same list.
115 * However, it is perfectly legal to run concurrently with
116 * the _rcu list-traversal primitives, such as
117 * list_for_each_entry_rcu().
118 */
119static inline void list_add_rcu(struct list_head *new, struct list_head *head)
120{
121 __list_add_rcu(new, head, head->next);
122}
123
124/**
125 * list_add_tail_rcu - add a new entry to rcu-protected list
126 * @new: new entry to be added
127 * @head: list head to add it before
128 *
129 * Insert a new entry before the specified head.
130 * This is useful for implementing queues.
131 *
132 * The caller must take whatever precautions are necessary
133 * (such as holding appropriate locks) to avoid racing
134 * with another list-mutation primitive, such as list_add_tail_rcu()
135 * or list_del_rcu(), running on this same list.
136 * However, it is perfectly legal to run concurrently with
137 * the _rcu list-traversal primitives, such as
138 * list_for_each_entry_rcu().
139 */
140static inline void list_add_tail_rcu(struct list_head *new,
141 struct list_head *head)
142{
143 __list_add_rcu(new, head->prev, head);
144}
145
146/*
147 * Delete a list entry by making the prev/next entries 88 * Delete a list entry by making the prev/next entries
148 * point to each other. 89 * point to each other.
149 * 90 *
@@ -174,36 +115,6 @@ extern void list_del(struct list_head *entry);
174#endif 115#endif
175 116
176/** 117/**
177 * list_del_rcu - deletes entry from list without re-initialization
178 * @entry: the element to delete from the list.
179 *
180 * Note: list_empty() on entry does not return true after this,
181 * the entry is in an undefined state. It is useful for RCU based
182 * lockfree traversal.
183 *
184 * In particular, it means that we can not poison the forward
185 * pointers that may still be used for walking the list.
186 *
187 * The caller must take whatever precautions are necessary
188 * (such as holding appropriate locks) to avoid racing
189 * with another list-mutation primitive, such as list_del_rcu()
190 * or list_add_rcu(), running on this same list.
191 * However, it is perfectly legal to run concurrently with
192 * the _rcu list-traversal primitives, such as
193 * list_for_each_entry_rcu().
194 *
195 * Note that the caller is not permitted to immediately free
196 * the newly deleted entry. Instead, either synchronize_rcu()
197 * or call_rcu() must be used to defer freeing until an RCU
198 * grace period has elapsed.
199 */
200static inline void list_del_rcu(struct list_head *entry)
201{
202 __list_del(entry->prev, entry->next);
203 entry->prev = LIST_POISON2;
204}
205
206/**
207 * list_replace - replace old entry by new one 118 * list_replace - replace old entry by new one
208 * @old : the element to be replaced 119 * @old : the element to be replaced
209 * @new : the new element to insert 120 * @new : the new element to insert
@@ -227,25 +138,6 @@ static inline void list_replace_init(struct list_head *old,
227} 138}
228 139
229/** 140/**
230 * list_replace_rcu - replace old entry by new one
231 * @old : the element to be replaced
232 * @new : the new element to insert
233 *
234 * The @old entry will be replaced with the @new entry atomically.
235 * Note: @old should not be empty.
236 */
237static inline void list_replace_rcu(struct list_head *old,
238 struct list_head *new)
239{
240 new->next = old->next;
241 new->prev = old->prev;
242 smp_wmb();
243 new->next->prev = new;
244 new->prev->next = new;
245 old->prev = LIST_POISON2;
246}
247
248/**
249 * list_del_init - deletes entry from list and reinitialize it. 141 * list_del_init - deletes entry from list and reinitialize it.
250 * @entry: the element to delete from the list. 142 * @entry: the element to delete from the list.
251 */ 143 */
@@ -369,62 +261,6 @@ static inline void list_splice_init(struct list_head *list,
369} 261}
370 262
371/** 263/**
372 * list_splice_init_rcu - splice an RCU-protected list into an existing list.
373 * @list: the RCU-protected list to splice
374 * @head: the place in the list to splice the first list into
375 * @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
376 *
377 * @head can be RCU-read traversed concurrently with this function.
378 *
379 * Note that this function blocks.
380 *
381 * Important note: the caller must take whatever action is necessary to
382 * prevent any other updates to @head. In principle, it is possible
383 * to modify the list as soon as sync() begins execution.
384 * If this sort of thing becomes necessary, an alternative version
385 * based on call_rcu() could be created. But only if -really-
386 * needed -- there is no shortage of RCU API members.
387 */
388static inline void list_splice_init_rcu(struct list_head *list,
389 struct list_head *head,
390 void (*sync)(void))
391{
392 struct list_head *first = list->next;
393 struct list_head *last = list->prev;
394 struct list_head *at = head->next;
395
396 if (list_empty(head))
397 return;
398
399 /* "first" and "last" tracking list, so initialize it. */
400
401 INIT_LIST_HEAD(list);
402
403 /*
404 * At this point, the list body still points to the source list.
405 * Wait for any readers to finish using the list before splicing
406 * the list body into the new list. Any new readers will see
407 * an empty list.
408 */
409
410 sync();
411
412 /*
413 * Readers are finished with the source list, so perform splice.
414 * The order is important if the new list is global and accessible
415 * to concurrent RCU readers. Note that RCU readers are not
416 * permitted to traverse the prev pointers without excluding
417 * this function.
418 */
419
420 last->next = at;
421 smp_wmb();
422 head->next = first;
423 first->prev = head;
424 at->prev = last;
425}
426
427/**
428 * list_entry - get the struct for this entry 264 * list_entry - get the struct for this entry
429 * @ptr: the &struct list_head pointer. 265 * @ptr: the &struct list_head pointer.
430 * @type: the type of the struct this is embedded in. 266 * @type: the type of the struct this is embedded in.
@@ -629,57 +465,6 @@ static inline void list_splice_init_rcu(struct list_head *list,
629 &pos->member != (head); \ 465 &pos->member != (head); \
630 pos = n, n = list_entry(n->member.prev, typeof(*n), member)) 466 pos = n, n = list_entry(n->member.prev, typeof(*n), member))
631 467
632/**
633 * list_for_each_rcu - iterate over an rcu-protected list
634 * @pos: the &struct list_head to use as a loop cursor.
635 * @head: the head for your list.
636 *
637 * This list-traversal primitive may safely run concurrently with
638 * the _rcu list-mutation primitives such as list_add_rcu()
639 * as long as the traversal is guarded by rcu_read_lock().
640 */
641#define list_for_each_rcu(pos, head) \
642 for (pos = rcu_dereference((head)->next); \
643 prefetch(pos->next), pos != (head); \
644 pos = rcu_dereference(pos->next))
645
646#define __list_for_each_rcu(pos, head) \
647 for (pos = rcu_dereference((head)->next); \
648 pos != (head); \
649 pos = rcu_dereference(pos->next))
650
651/**
652 * list_for_each_entry_rcu - iterate over rcu list of given type
653 * @pos: the type * to use as a loop cursor.
654 * @head: the head for your list.
655 * @member: the name of the list_struct within the struct.
656 *
657 * This list-traversal primitive may safely run concurrently with
658 * the _rcu list-mutation primitives such as list_add_rcu()
659 * as long as the traversal is guarded by rcu_read_lock().
660 */
661#define list_for_each_entry_rcu(pos, head, member) \
662 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), member); \
663 prefetch(pos->member.next), &pos->member != (head); \
664 pos = list_entry(rcu_dereference(pos->member.next), typeof(*pos), member))
665
666
667/**
668 * list_for_each_continue_rcu
669 * @pos: the &struct list_head to use as a loop cursor.
670 * @head: the head for your list.
671 *
672 * Iterate over an rcu-protected list, continuing after current point.
673 *
674 * This list-traversal primitive may safely run concurrently with
675 * the _rcu list-mutation primitives such as list_add_rcu()
676 * as long as the traversal is guarded by rcu_read_lock().
677 */
678#define list_for_each_continue_rcu(pos, head) \
679 for ((pos) = rcu_dereference((pos)->next); \
680 prefetch((pos)->next), (pos) != (head); \
681 (pos) = rcu_dereference((pos)->next))
682
683/* 468/*
684 * Double linked lists with a single pointer list head. 469 * Double linked lists with a single pointer list head.
685 * Mostly useful for hash tables where the two pointer list head is 470 * Mostly useful for hash tables where the two pointer list head is
@@ -730,31 +515,6 @@ static inline void hlist_del(struct hlist_node *n)
730 n->pprev = LIST_POISON2; 515 n->pprev = LIST_POISON2;
731} 516}
732 517
733/**
734 * hlist_del_rcu - deletes entry from hash list without re-initialization
735 * @n: the element to delete from the hash list.
736 *
737 * Note: list_unhashed() on entry does not return true after this,
738 * the entry is in an undefined state. It is useful for RCU based
739 * lockfree traversal.
740 *
741 * In particular, it means that we can not poison the forward
742 * pointers that may still be used for walking the hash list.
743 *
744 * The caller must take whatever precautions are necessary
745 * (such as holding appropriate locks) to avoid racing
746 * with another list-mutation primitive, such as hlist_add_head_rcu()
747 * or hlist_del_rcu(), running on this same list.
748 * However, it is perfectly legal to run concurrently with
749 * the _rcu list-traversal primitives, such as
750 * hlist_for_each_entry().
751 */
752static inline void hlist_del_rcu(struct hlist_node *n)
753{
754 __hlist_del(n);
755 n->pprev = LIST_POISON2;
756}
757
758static inline void hlist_del_init(struct hlist_node *n) 518static inline void hlist_del_init(struct hlist_node *n)
759{ 519{
760 if (!hlist_unhashed(n)) { 520 if (!hlist_unhashed(n)) {
@@ -763,27 +523,6 @@ static inline void hlist_del_init(struct hlist_node *n)
763 } 523 }
764} 524}
765 525
766/**
767 * hlist_replace_rcu - replace old entry by new one
768 * @old : the element to be replaced
769 * @new : the new element to insert
770 *
771 * The @old entry will be replaced with the @new entry atomically.
772 */
773static inline void hlist_replace_rcu(struct hlist_node *old,
774 struct hlist_node *new)
775{
776 struct hlist_node *next = old->next;
777
778 new->next = next;
779 new->pprev = old->pprev;
780 smp_wmb();
781 if (next)
782 new->next->pprev = &new->next;
783 *new->pprev = new;
784 old->pprev = LIST_POISON2;
785}
786
787static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) 526static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
788{ 527{
789 struct hlist_node *first = h->first; 528 struct hlist_node *first = h->first;
@@ -794,38 +533,6 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
794 n->pprev = &h->first; 533 n->pprev = &h->first;
795} 534}
796 535
797
798/**
799 * hlist_add_head_rcu
800 * @n: the element to add to the hash list.
801 * @h: the list to add to.
802 *
803 * Description:
804 * Adds the specified element to the specified hlist,
805 * while permitting racing traversals.
806 *
807 * The caller must take whatever precautions are necessary
808 * (such as holding appropriate locks) to avoid racing
809 * with another list-mutation primitive, such as hlist_add_head_rcu()
810 * or hlist_del_rcu(), running on this same list.
811 * However, it is perfectly legal to run concurrently with
812 * the _rcu list-traversal primitives, such as
813 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
814 * problems on Alpha CPUs. Regardless of the type of CPU, the
815 * list-traversal primitive must be guarded by rcu_read_lock().
816 */
817static inline void hlist_add_head_rcu(struct hlist_node *n,
818 struct hlist_head *h)
819{
820 struct hlist_node *first = h->first;
821 n->next = first;
822 n->pprev = &h->first;
823 smp_wmb();
824 if (first)
825 first->pprev = &n->next;
826 h->first = n;
827}
828
829/* next must be != NULL */ 536/* next must be != NULL */
830static inline void hlist_add_before(struct hlist_node *n, 537static inline void hlist_add_before(struct hlist_node *n,
831 struct hlist_node *next) 538 struct hlist_node *next)
@@ -847,63 +554,6 @@ static inline void hlist_add_after(struct hlist_node *n,
847 next->next->pprev = &next->next; 554 next->next->pprev = &next->next;
848} 555}
849 556
850/**
851 * hlist_add_before_rcu
852 * @n: the new element to add to the hash list.
853 * @next: the existing element to add the new element before.
854 *
855 * Description:
856 * Adds the specified element to the specified hlist
857 * before the specified node while permitting racing traversals.
858 *
859 * The caller must take whatever precautions are necessary
860 * (such as holding appropriate locks) to avoid racing
861 * with another list-mutation primitive, such as hlist_add_head_rcu()
862 * or hlist_del_rcu(), running on this same list.
863 * However, it is perfectly legal to run concurrently with
864 * the _rcu list-traversal primitives, such as
865 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
866 * problems on Alpha CPUs.
867 */
868static inline void hlist_add_before_rcu(struct hlist_node *n,
869 struct hlist_node *next)
870{
871 n->pprev = next->pprev;
872 n->next = next;
873 smp_wmb();
874 next->pprev = &n->next;
875 *(n->pprev) = n;
876}
877
878/**
879 * hlist_add_after_rcu
880 * @prev: the existing element to add the new element after.
881 * @n: the new element to add to the hash list.
882 *
883 * Description:
884 * Adds the specified element to the specified hlist
885 * after the specified node while permitting racing traversals.
886 *
887 * The caller must take whatever precautions are necessary
888 * (such as holding appropriate locks) to avoid racing
889 * with another list-mutation primitive, such as hlist_add_head_rcu()
890 * or hlist_del_rcu(), running on this same list.
891 * However, it is perfectly legal to run concurrently with
892 * the _rcu list-traversal primitives, such as
893 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
894 * problems on Alpha CPUs.
895 */
896static inline void hlist_add_after_rcu(struct hlist_node *prev,
897 struct hlist_node *n)
898{
899 n->next = prev->next;
900 n->pprev = &prev->next;
901 smp_wmb();
902 prev->next = n;
903 if (n->next)
904 n->next->pprev = &n->next;
905}
906
907#define hlist_entry(ptr, type, member) container_of(ptr,type,member) 557#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
908 558
909#define hlist_for_each(pos, head) \ 559#define hlist_for_each(pos, head) \
@@ -964,21 +614,4 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
964 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 614 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
965 pos = n) 615 pos = n)
966 616
967/**
968 * hlist_for_each_entry_rcu - iterate over rcu list of given type
969 * @tpos: the type * to use as a loop cursor.
970 * @pos: the &struct hlist_node to use as a loop cursor.
971 * @head: the head for your list.
972 * @member: the name of the hlist_node within the struct.
973 *
974 * This list-traversal primitive may safely run concurrently with
975 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
976 * as long as the traversal is guarded by rcu_read_lock().
977 */
978#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
979 for (pos = rcu_dereference((head)->first); \
980 pos && ({ prefetch(pos->next); 1;}) && \
981 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
982 pos = rcu_dereference(pos->next))
983
984#endif 617#endif
diff --git a/include/linux/lm_interface.h b/include/linux/lm_interface.h
index f274997bc28..2ed8fa1b762 100644
--- a/include/linux/lm_interface.h
+++ b/include/linux/lm_interface.h
@@ -122,11 +122,9 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
122 */ 122 */
123 123
124#define LM_OUT_ST_MASK 0x00000003 124#define LM_OUT_ST_MASK 0x00000003
125#define LM_OUT_CACHEABLE 0x00000004
126#define LM_OUT_CANCELED 0x00000008 125#define LM_OUT_CANCELED 0x00000008
127#define LM_OUT_ASYNC 0x00000080 126#define LM_OUT_ASYNC 0x00000080
128#define LM_OUT_ERROR 0x00000100 127#define LM_OUT_ERROR 0x00000100
129#define LM_OUT_CONV_DEADLK 0x00000200
130 128
131/* 129/*
132 * lm_callback_t types 130 * lm_callback_t types
@@ -138,9 +136,6 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
138 * LM_CB_NEED_RECOVERY 136 * LM_CB_NEED_RECOVERY
139 * The given journal needs to be recovered. 137 * The given journal needs to be recovered.
140 * 138 *
141 * LM_CB_DROPLOCKS
142 * Reduce the number of cached locks.
143 *
144 * LM_CB_ASYNC 139 * LM_CB_ASYNC
145 * The given lock has been granted. 140 * The given lock has been granted.
146 */ 141 */
@@ -149,7 +144,6 @@ typedef void (*lm_callback_t) (void *ptr, unsigned int type, void *data);
149#define LM_CB_NEED_D 258 144#define LM_CB_NEED_D 258
150#define LM_CB_NEED_S 259 145#define LM_CB_NEED_S 259
151#define LM_CB_NEED_RECOVERY 260 146#define LM_CB_NEED_RECOVERY 260
152#define LM_CB_DROPLOCKS 261
153#define LM_CB_ASYNC 262 147#define LM_CB_ASYNC 262
154 148
155/* 149/*
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index a744383d16e..81b3dd5206e 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -398,7 +398,8 @@ int mlx4_srq_query(struct mlx4_dev *dev, struct mlx4_srq *srq, int *limit_waterm
398int mlx4_INIT_PORT(struct mlx4_dev *dev, int port); 398int mlx4_INIT_PORT(struct mlx4_dev *dev, int port);
399int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port); 399int mlx4_CLOSE_PORT(struct mlx4_dev *dev, int port);
400 400
401int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]); 401int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
402 int block_mcast_loopback);
402int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]); 403int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16]);
403 404
404int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list, 405int mlx4_map_phys_fmr(struct mlx4_dev *dev, struct mlx4_fmr *fmr, u64 *page_list,
diff --git a/include/linux/mpage.h b/include/linux/mpage.h
index 068a0c9946a..5c42821da2d 100644
--- a/include/linux/mpage.h
+++ b/include/linux/mpage.h
@@ -11,11 +11,21 @@
11 */ 11 */
12#ifdef CONFIG_BLOCK 12#ifdef CONFIG_BLOCK
13 13
14struct mpage_data {
15 struct bio *bio;
16 sector_t last_block_in_bio;
17 get_block_t *get_block;
18 unsigned use_writepage;
19};
20
14struct writeback_control; 21struct writeback_control;
15 22
23struct bio *mpage_bio_submit(int rw, struct bio *bio);
16int mpage_readpages(struct address_space *mapping, struct list_head *pages, 24int mpage_readpages(struct address_space *mapping, struct list_head *pages,
17 unsigned nr_pages, get_block_t get_block); 25 unsigned nr_pages, get_block_t get_block);
18int mpage_readpage(struct page *page, get_block_t get_block); 26int mpage_readpage(struct page *page, get_block_t get_block);
27int __mpage_writepage(struct page *page, struct writeback_control *wbc,
28 void *data);
19int mpage_writepages(struct address_space *mapping, 29int mpage_writepages(struct address_space *mapping,
20 struct writeback_control *wbc, get_block_t get_block); 30 struct writeback_control *wbc, get_block_t get_block);
21int mpage_writepage(struct page *page, get_block_t *get_block, 31int mpage_writepage(struct page *page, get_block_t *get_block,
diff --git a/include/linux/percpu_counter.h b/include/linux/percpu_counter.h
index 9007ccdfc11..20838883535 100644
--- a/include/linux/percpu_counter.h
+++ b/include/linux/percpu_counter.h
@@ -35,7 +35,7 @@ int percpu_counter_init_irq(struct percpu_counter *fbc, s64 amount);
35void percpu_counter_destroy(struct percpu_counter *fbc); 35void percpu_counter_destroy(struct percpu_counter *fbc);
36void percpu_counter_set(struct percpu_counter *fbc, s64 amount); 36void percpu_counter_set(struct percpu_counter *fbc, s64 amount);
37void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch); 37void __percpu_counter_add(struct percpu_counter *fbc, s64 amount, s32 batch);
38s64 __percpu_counter_sum(struct percpu_counter *fbc); 38s64 __percpu_counter_sum(struct percpu_counter *fbc, int set);
39 39
40static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount) 40static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
41{ 41{
@@ -44,13 +44,19 @@ static inline void percpu_counter_add(struct percpu_counter *fbc, s64 amount)
44 44
45static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc) 45static inline s64 percpu_counter_sum_positive(struct percpu_counter *fbc)
46{ 46{
47 s64 ret = __percpu_counter_sum(fbc); 47 s64 ret = __percpu_counter_sum(fbc, 0);
48 return ret < 0 ? 0 : ret; 48 return ret < 0 ? 0 : ret;
49} 49}
50 50
51static inline s64 percpu_counter_sum_and_set(struct percpu_counter *fbc)
52{
53 return __percpu_counter_sum(fbc, 1);
54}
55
56
51static inline s64 percpu_counter_sum(struct percpu_counter *fbc) 57static inline s64 percpu_counter_sum(struct percpu_counter *fbc)
52{ 58{
53 return __percpu_counter_sum(fbc); 59 return __percpu_counter_sum(fbc, 0);
54} 60}
55 61
56static inline s64 percpu_counter_read(struct percpu_counter *fbc) 62static inline s64 percpu_counter_read(struct percpu_counter *fbc)
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index b3aa05baab8..8c774905dcf 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -151,7 +151,10 @@ extern struct lockdep_map rcu_lock_map;
151 151
152#define __synchronize_sched() synchronize_rcu() 152#define __synchronize_sched() synchronize_rcu()
153 153
154#define call_rcu_sched(head, func) call_rcu(head, func)
155
154extern void __rcu_init(void); 156extern void __rcu_init(void);
157#define rcu_init_sched() do { } while (0)
155extern void rcu_check_callbacks(int cpu, int user); 158extern void rcu_check_callbacks(int cpu, int user);
156extern void rcu_restart_cpu(int cpu); 159extern void rcu_restart_cpu(int cpu);
157 160
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index bde4586f438..b0f39be08b6 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -1,6 +1,373 @@
1#ifndef _LINUX_RCULIST_H 1#ifndef _LINUX_RCULIST_H
2#define _LINUX_RCULIST_H 2#define _LINUX_RCULIST_H
3 3
4#ifdef __KERNEL__
5
6/*
7 * RCU-protected list version
8 */
4#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/rcupdate.h>
11
12/*
13 * Insert a new entry between two known consecutive entries.
14 *
15 * This is only for internal list manipulation where we know
16 * the prev/next entries already!
17 */
18static inline void __list_add_rcu(struct list_head *new,
19 struct list_head *prev, struct list_head *next)
20{
21 new->next = next;
22 new->prev = prev;
23 rcu_assign_pointer(prev->next, new);
24 next->prev = new;
25}
26
27/**
28 * list_add_rcu - add a new entry to rcu-protected list
29 * @new: new entry to be added
30 * @head: list head to add it after
31 *
32 * Insert a new entry after the specified head.
33 * This is good for implementing stacks.
34 *
35 * The caller must take whatever precautions are necessary
36 * (such as holding appropriate locks) to avoid racing
37 * with another list-mutation primitive, such as list_add_rcu()
38 * or list_del_rcu(), running on this same list.
39 * However, it is perfectly legal to run concurrently with
40 * the _rcu list-traversal primitives, such as
41 * list_for_each_entry_rcu().
42 */
43static inline void list_add_rcu(struct list_head *new, struct list_head *head)
44{
45 __list_add_rcu(new, head, head->next);
46}
47
48/**
49 * list_add_tail_rcu - add a new entry to rcu-protected list
50 * @new: new entry to be added
51 * @head: list head to add it before
52 *
53 * Insert a new entry before the specified head.
54 * This is useful for implementing queues.
55 *
56 * The caller must take whatever precautions are necessary
57 * (such as holding appropriate locks) to avoid racing
58 * with another list-mutation primitive, such as list_add_tail_rcu()
59 * or list_del_rcu(), running on this same list.
60 * However, it is perfectly legal to run concurrently with
61 * the _rcu list-traversal primitives, such as
62 * list_for_each_entry_rcu().
63 */
64static inline void list_add_tail_rcu(struct list_head *new,
65 struct list_head *head)
66{
67 __list_add_rcu(new, head->prev, head);
68}
69
70/**
71 * list_del_rcu - deletes entry from list without re-initialization
72 * @entry: the element to delete from the list.
73 *
74 * Note: list_empty() on entry does not return true after this,
75 * the entry is in an undefined state. It is useful for RCU based
76 * lockfree traversal.
77 *
78 * In particular, it means that we can not poison the forward
79 * pointers that may still be used for walking the list.
80 *
81 * The caller must take whatever precautions are necessary
82 * (such as holding appropriate locks) to avoid racing
83 * with another list-mutation primitive, such as list_del_rcu()
84 * or list_add_rcu(), running on this same list.
85 * However, it is perfectly legal to run concurrently with
86 * the _rcu list-traversal primitives, such as
87 * list_for_each_entry_rcu().
88 *
89 * Note that the caller is not permitted to immediately free
90 * the newly deleted entry. Instead, either synchronize_rcu()
91 * or call_rcu() must be used to defer freeing until an RCU
92 * grace period has elapsed.
93 */
94static inline void list_del_rcu(struct list_head *entry)
95{
96 __list_del(entry->prev, entry->next);
97 entry->prev = LIST_POISON2;
98}
99
100/**
101 * list_replace_rcu - replace old entry by new one
102 * @old : the element to be replaced
103 * @new : the new element to insert
104 *
105 * The @old entry will be replaced with the @new entry atomically.
106 * Note: @old should not be empty.
107 */
108static inline void list_replace_rcu(struct list_head *old,
109 struct list_head *new)
110{
111 new->next = old->next;
112 new->prev = old->prev;
113 rcu_assign_pointer(new->prev->next, new);
114 new->next->prev = new;
115 old->prev = LIST_POISON2;
116}
117
118/**
119 * list_splice_init_rcu - splice an RCU-protected list into an existing list.
120 * @list: the RCU-protected list to splice
121 * @head: the place in the list to splice the first list into
122 * @sync: function to sync: synchronize_rcu(), synchronize_sched(), ...
123 *
124 * @head can be RCU-read traversed concurrently with this function.
125 *
126 * Note that this function blocks.
127 *
128 * Important note: the caller must take whatever action is necessary to
129 * prevent any other updates to @head. In principle, it is possible
130 * to modify the list as soon as sync() begins execution.
131 * If this sort of thing becomes necessary, an alternative version
132 * based on call_rcu() could be created. But only if -really-
133 * needed -- there is no shortage of RCU API members.
134 */
135static inline void list_splice_init_rcu(struct list_head *list,
136 struct list_head *head,
137 void (*sync)(void))
138{
139 struct list_head *first = list->next;
140 struct list_head *last = list->prev;
141 struct list_head *at = head->next;
142
143 if (list_empty(head))
144 return;
145
146 /* "first" and "last" tracking list, so initialize it. */
147
148 INIT_LIST_HEAD(list);
149
150 /*
151 * At this point, the list body still points to the source list.
152 * Wait for any readers to finish using the list before splicing
153 * the list body into the new list. Any new readers will see
154 * an empty list.
155 */
156
157 sync();
158
159 /*
160 * Readers are finished with the source list, so perform splice.
161 * The order is important if the new list is global and accessible
162 * to concurrent RCU readers. Note that RCU readers are not
163 * permitted to traverse the prev pointers without excluding
164 * this function.
165 */
166
167 last->next = at;
168 rcu_assign_pointer(head->next, first);
169 first->prev = head;
170 at->prev = last;
171}
172
173/**
174 * list_for_each_rcu - iterate over an rcu-protected list
175 * @pos: the &struct list_head to use as a loop cursor.
176 * @head: the head for your list.
177 *
178 * This list-traversal primitive may safely run concurrently with
179 * the _rcu list-mutation primitives such as list_add_rcu()
180 * as long as the traversal is guarded by rcu_read_lock().
181 */
182#define list_for_each_rcu(pos, head) \
183 for (pos = rcu_dereference((head)->next); \
184 prefetch(pos->next), pos != (head); \
185 pos = rcu_dereference(pos->next))
186
187#define __list_for_each_rcu(pos, head) \
188 for (pos = rcu_dereference((head)->next); \
189 pos != (head); \
190 pos = rcu_dereference(pos->next))
191
192/**
193 * list_for_each_entry_rcu - iterate over rcu list of given type
194 * @pos: the type * to use as a loop cursor.
195 * @head: the head for your list.
196 * @member: the name of the list_struct within the struct.
197 *
198 * This list-traversal primitive may safely run concurrently with
199 * the _rcu list-mutation primitives such as list_add_rcu()
200 * as long as the traversal is guarded by rcu_read_lock().
201 */
202#define list_for_each_entry_rcu(pos, head, member) \
203 for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), member); \
204 prefetch(pos->member.next), &pos->member != (head); \
205 pos = list_entry(rcu_dereference(pos->member.next), typeof(*pos), member))
206
207
208/**
209 * list_for_each_continue_rcu
210 * @pos: the &struct list_head to use as a loop cursor.
211 * @head: the head for your list.
212 *
213 * Iterate over an rcu-protected list, continuing after current point.
214 *
215 * This list-traversal primitive may safely run concurrently with
216 * the _rcu list-mutation primitives such as list_add_rcu()
217 * as long as the traversal is guarded by rcu_read_lock().
218 */
219#define list_for_each_continue_rcu(pos, head) \
220 for ((pos) = rcu_dereference((pos)->next); \
221 prefetch((pos)->next), (pos) != (head); \
222 (pos) = rcu_dereference((pos)->next))
223
224/**
225 * hlist_del_rcu - deletes entry from hash list without re-initialization
226 * @n: the element to delete from the hash list.
227 *
228 * Note: list_unhashed() on entry does not return true after this,
229 * the entry is in an undefined state. It is useful for RCU based
230 * lockfree traversal.
231 *
232 * In particular, it means that we can not poison the forward
233 * pointers that may still be used for walking the hash list.
234 *
235 * The caller must take whatever precautions are necessary
236 * (such as holding appropriate locks) to avoid racing
237 * with another list-mutation primitive, such as hlist_add_head_rcu()
238 * or hlist_del_rcu(), running on this same list.
239 * However, it is perfectly legal to run concurrently with
240 * the _rcu list-traversal primitives, such as
241 * hlist_for_each_entry().
242 */
243static inline void hlist_del_rcu(struct hlist_node *n)
244{
245 __hlist_del(n);
246 n->pprev = LIST_POISON2;
247}
248
249/**
250 * hlist_replace_rcu - replace old entry by new one
251 * @old : the element to be replaced
252 * @new : the new element to insert
253 *
254 * The @old entry will be replaced with the @new entry atomically.
255 */
256static inline void hlist_replace_rcu(struct hlist_node *old,
257 struct hlist_node *new)
258{
259 struct hlist_node *next = old->next;
260
261 new->next = next;
262 new->pprev = old->pprev;
263 rcu_assign_pointer(*new->pprev, new);
264 if (next)
265 new->next->pprev = &new->next;
266 old->pprev = LIST_POISON2;
267}
268
269/**
270 * hlist_add_head_rcu
271 * @n: the element to add to the hash list.
272 * @h: the list to add to.
273 *
274 * Description:
275 * Adds the specified element to the specified hlist,
276 * while permitting racing traversals.
277 *
278 * The caller must take whatever precautions are necessary
279 * (such as holding appropriate locks) to avoid racing
280 * with another list-mutation primitive, such as hlist_add_head_rcu()
281 * or hlist_del_rcu(), running on this same list.
282 * However, it is perfectly legal to run concurrently with
283 * the _rcu list-traversal primitives, such as
284 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
285 * problems on Alpha CPUs. Regardless of the type of CPU, the
286 * list-traversal primitive must be guarded by rcu_read_lock().
287 */
288static inline void hlist_add_head_rcu(struct hlist_node *n,
289 struct hlist_head *h)
290{
291 struct hlist_node *first = h->first;
292
293 n->next = first;
294 n->pprev = &h->first;
295 rcu_assign_pointer(h->first, n);
296 if (first)
297 first->pprev = &n->next;
298}
299
300/**
301 * hlist_add_before_rcu
302 * @n: the new element to add to the hash list.
303 * @next: the existing element to add the new element before.
304 *
305 * Description:
306 * Adds the specified element to the specified hlist
307 * before the specified node while permitting racing traversals.
308 *
309 * The caller must take whatever precautions are necessary
310 * (such as holding appropriate locks) to avoid racing
311 * with another list-mutation primitive, such as hlist_add_head_rcu()
312 * or hlist_del_rcu(), running on this same list.
313 * However, it is perfectly legal to run concurrently with
314 * the _rcu list-traversal primitives, such as
315 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
316 * problems on Alpha CPUs.
317 */
318static inline void hlist_add_before_rcu(struct hlist_node *n,
319 struct hlist_node *next)
320{
321 n->pprev = next->pprev;
322 n->next = next;
323 rcu_assign_pointer(*(n->pprev), n);
324 next->pprev = &n->next;
325}
326
327/**
328 * hlist_add_after_rcu
329 * @prev: the existing element to add the new element after.
330 * @n: the new element to add to the hash list.
331 *
332 * Description:
333 * Adds the specified element to the specified hlist
334 * after the specified node while permitting racing traversals.
335 *
336 * The caller must take whatever precautions are necessary
337 * (such as holding appropriate locks) to avoid racing
338 * with another list-mutation primitive, such as hlist_add_head_rcu()
339 * or hlist_del_rcu(), running on this same list.
340 * However, it is perfectly legal to run concurrently with
341 * the _rcu list-traversal primitives, such as
342 * hlist_for_each_entry_rcu(), used to prevent memory-consistency
343 * problems on Alpha CPUs.
344 */
345static inline void hlist_add_after_rcu(struct hlist_node *prev,
346 struct hlist_node *n)
347{
348 n->next = prev->next;
349 n->pprev = &prev->next;
350 rcu_assign_pointer(prev->next, n);
351 if (n->next)
352 n->next->pprev = &n->next;
353}
354
355/**
356 * hlist_for_each_entry_rcu - iterate over rcu list of given type
357 * @tpos: the type * to use as a loop cursor.
358 * @pos: the &struct hlist_node to use as a loop cursor.
359 * @head: the head for your list.
360 * @member: the name of the hlist_node within the struct.
361 *
362 * This list-traversal primitive may safely run concurrently with
363 * the _rcu list-mutation primitives such as hlist_add_head_rcu()
364 * as long as the traversal is guarded by rcu_read_lock().
365 */
366#define hlist_for_each_entry_rcu(tpos, pos, head, member) \
367 for (pos = rcu_dereference((head)->first); \
368 pos && ({ prefetch(pos->next); 1; }) && \
369 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; }); \
370 pos = rcu_dereference(pos->next))
5 371
6#endif /* _LINUX_RCULIST_H */ 372#endif /* __KERNEL__ */
373#endif
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index d42dbec0608..e8b4039cfb2 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -40,6 +40,7 @@
40#include <linux/cpumask.h> 40#include <linux/cpumask.h>
41#include <linux/seqlock.h> 41#include <linux/seqlock.h>
42#include <linux/lockdep.h> 42#include <linux/lockdep.h>
43#include <linux/completion.h>
43 44
44/** 45/**
45 * struct rcu_head - callback structure for use with RCU 46 * struct rcu_head - callback structure for use with RCU
@@ -168,6 +169,27 @@ struct rcu_head {
168 (p) = (v); \ 169 (p) = (v); \
169 }) 170 })
170 171
172/* Infrastructure to implement the synchronize_() primitives. */
173
174struct rcu_synchronize {
175 struct rcu_head head;
176 struct completion completion;
177};
178
179extern void wakeme_after_rcu(struct rcu_head *head);
180
181#define synchronize_rcu_xxx(name, func) \
182void name(void) \
183{ \
184 struct rcu_synchronize rcu; \
185 \
186 init_completion(&rcu.completion); \
187 /* Will wake me after RCU finished. */ \
188 func(&rcu.head, wakeme_after_rcu); \
189 /* Wait for it. */ \
190 wait_for_completion(&rcu.completion); \
191}
192
171/** 193/**
172 * synchronize_sched - block until all CPUs have exited any non-preemptive 194 * synchronize_sched - block until all CPUs have exited any non-preemptive
173 * kernel code sequences. 195 * kernel code sequences.
@@ -224,8 +246,8 @@ extern void call_rcu_bh(struct rcu_head *head,
224/* Exported common interfaces */ 246/* Exported common interfaces */
225extern void synchronize_rcu(void); 247extern void synchronize_rcu(void);
226extern void rcu_barrier(void); 248extern void rcu_barrier(void);
227extern long rcu_batches_completed(void); 249extern void rcu_barrier_bh(void);
228extern long rcu_batches_completed_bh(void); 250extern void rcu_barrier_sched(void);
229 251
230/* Internal to kernel */ 252/* Internal to kernel */
231extern void rcu_init(void); 253extern void rcu_init(void);
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
index 8a05c7e20bc..f04b64eca63 100644
--- a/include/linux/rcupreempt.h
+++ b/include/linux/rcupreempt.h
@@ -40,10 +40,39 @@
40#include <linux/cpumask.h> 40#include <linux/cpumask.h>
41#include <linux/seqlock.h> 41#include <linux/seqlock.h>
42 42
43#define rcu_qsctr_inc(cpu) 43struct rcu_dyntick_sched {
44 int dynticks;
45 int dynticks_snap;
46 int sched_qs;
47 int sched_qs_snap;
48 int sched_dynticks_snap;
49};
50
51DECLARE_PER_CPU(struct rcu_dyntick_sched, rcu_dyntick_sched);
52
53static inline void rcu_qsctr_inc(int cpu)
54{
55 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
56
57 rdssp->sched_qs++;
58}
44#define rcu_bh_qsctr_inc(cpu) 59#define rcu_bh_qsctr_inc(cpu)
45#define call_rcu_bh(head, rcu) call_rcu(head, rcu) 60#define call_rcu_bh(head, rcu) call_rcu(head, rcu)
46 61
62/**
63 * call_rcu_sched - Queue RCU callback for invocation after sched grace period.
64 * @head: structure to be used for queueing the RCU updates.
65 * @func: actual update function to be invoked after the grace period
66 *
67 * The update function will be invoked some time after a full
68 * synchronize_sched()-style grace period elapses, in other words after
69 * all currently executing preempt-disabled sections of code (including
70 * hardirq handlers, NMI handlers, and local_irq_save() blocks) have
71 * completed.
72 */
73extern void call_rcu_sched(struct rcu_head *head,
74 void (*func)(struct rcu_head *head));
75
47extern void __rcu_read_lock(void) __acquires(RCU); 76extern void __rcu_read_lock(void) __acquires(RCU);
48extern void __rcu_read_unlock(void) __releases(RCU); 77extern void __rcu_read_unlock(void) __releases(RCU);
49extern int rcu_pending(int cpu); 78extern int rcu_pending(int cpu);
@@ -55,6 +84,7 @@ extern int rcu_needs_cpu(int cpu);
55extern void __synchronize_sched(void); 84extern void __synchronize_sched(void);
56 85
57extern void __rcu_init(void); 86extern void __rcu_init(void);
87extern void rcu_init_sched(void);
58extern void rcu_check_callbacks(int cpu, int user); 88extern void rcu_check_callbacks(int cpu, int user);
59extern void rcu_restart_cpu(int cpu); 89extern void rcu_restart_cpu(int cpu);
60extern long rcu_batches_completed(void); 90extern long rcu_batches_completed(void);
@@ -81,20 +111,20 @@ extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu);
81struct softirq_action; 111struct softirq_action;
82 112
83#ifdef CONFIG_NO_HZ 113#ifdef CONFIG_NO_HZ
84DECLARE_PER_CPU(long, dynticks_progress_counter); 114DECLARE_PER_CPU(struct rcu_dyntick_sched, rcu_dyntick_sched);
85 115
86static inline void rcu_enter_nohz(void) 116static inline void rcu_enter_nohz(void)
87{ 117{
88 smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */ 118 smp_mb(); /* CPUs seeing ++ must see prior RCU read-side crit sects */
89 __get_cpu_var(dynticks_progress_counter)++; 119 __get_cpu_var(rcu_dyntick_sched).dynticks++;
90 WARN_ON(__get_cpu_var(dynticks_progress_counter) & 0x1); 120 WARN_ON(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1);
91} 121}
92 122
93static inline void rcu_exit_nohz(void) 123static inline void rcu_exit_nohz(void)
94{ 124{
95 __get_cpu_var(dynticks_progress_counter)++;
96 smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */ 125 smp_mb(); /* CPUs seeing ++ must see later RCU read-side crit sects */
97 WARN_ON(!(__get_cpu_var(dynticks_progress_counter) & 0x1)); 126 __get_cpu_var(rcu_dyntick_sched).dynticks++;
127 WARN_ON(!(__get_cpu_var(rcu_dyntick_sched).dynticks & 0x1));
98} 128}
99 129
100#else /* CONFIG_NO_HZ */ 130#else /* CONFIG_NO_HZ */
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 55232ccf9cf..48262f86c96 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -7,9 +7,18 @@
7 */ 7 */
8 8
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/list.h>
11#include <linux/cpumask.h>
10 12
11extern void cpu_idle(void); 13extern void cpu_idle(void);
12 14
15struct call_single_data {
16 struct list_head list;
17 void (*func) (void *info);
18 void *info;
19 unsigned int flags;
20};
21
13#ifdef CONFIG_SMP 22#ifdef CONFIG_SMP
14 23
15#include <linux/preempt.h> 24#include <linux/preempt.h>
@@ -52,15 +61,34 @@ extern void smp_cpus_done(unsigned int max_cpus);
52/* 61/*
53 * Call a function on all other processors 62 * Call a function on all other processors
54 */ 63 */
55int smp_call_function(void(*func)(void *info), void *info, int retry, int wait); 64int smp_call_function(void(*func)(void *info), void *info, int wait);
56 65int smp_call_function_mask(cpumask_t mask, void(*func)(void *info), void *info,
66 int wait);
57int smp_call_function_single(int cpuid, void (*func) (void *info), void *info, 67int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
58 int retry, int wait); 68 int wait);
69void __smp_call_function_single(int cpuid, struct call_single_data *data);
70
71/*
72 * Generic and arch helpers
73 */
74#ifdef CONFIG_USE_GENERIC_SMP_HELPERS
75void generic_smp_call_function_single_interrupt(void);
76void generic_smp_call_function_interrupt(void);
77void init_call_single_data(void);
78void ipi_call_lock(void);
79void ipi_call_unlock(void);
80void ipi_call_lock_irq(void);
81void ipi_call_unlock_irq(void);
82#else
83static inline void init_call_single_data(void)
84{
85}
86#endif
59 87
60/* 88/*
61 * Call a function on all processors 89 * Call a function on all processors
62 */ 90 */
63int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait); 91int on_each_cpu(void (*func) (void *info), void *info, int wait);
64 92
65#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */ 93#define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */
66#define MSG_ALL 0x8001 94#define MSG_ALL 0x8001
@@ -90,9 +118,9 @@ static inline int up_smp_call_function(void (*func)(void *), void *info)
90{ 118{
91 return 0; 119 return 0;
92} 120}
93#define smp_call_function(func, info, retry, wait) \ 121#define smp_call_function(func, info, wait) \
94 (up_smp_call_function(func, info)) 122 (up_smp_call_function(func, info))
95#define on_each_cpu(func,info,retry,wait) \ 123#define on_each_cpu(func,info,wait) \
96 ({ \ 124 ({ \
97 local_irq_disable(); \ 125 local_irq_disable(); \
98 func(info); \ 126 func(info); \
@@ -102,7 +130,7 @@ static inline int up_smp_call_function(void (*func)(void *), void *info)
102static inline void smp_send_reschedule(int cpu) { } 130static inline void smp_send_reschedule(int cpu) { }
103#define num_booting_cpus() 1 131#define num_booting_cpus() 1
104#define smp_prepare_boot_cpu() do {} while (0) 132#define smp_prepare_boot_cpu() do {} while (0)
105#define smp_call_function_single(cpuid, func, info, retry, wait) \ 133#define smp_call_function_single(cpuid, func, info, wait) \
106({ \ 134({ \
107 WARN_ON(cpuid != 0); \ 135 WARN_ON(cpuid != 0); \
108 local_irq_disable(); \ 136 local_irq_disable(); \
@@ -112,7 +140,9 @@ static inline void smp_send_reschedule(int cpu) { }
112}) 140})
113#define smp_call_function_mask(mask, func, info, wait) \ 141#define smp_call_function_mask(mask, func, info, wait) \
114 (up_smp_call_function(func, info)) 142 (up_smp_call_function(func, info))
115 143static inline void init_call_single_data(void)
144{
145}
116#endif /* !SMP */ 146#endif /* !SMP */
117 147
118/* 148/*
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 24f3d2282e1..2158fc0d5a5 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -179,4 +179,17 @@ void arch_update_cpu_topology(void);
179#endif 179#endif
180#endif /* CONFIG_NUMA */ 180#endif /* CONFIG_NUMA */
181 181
182#ifndef topology_physical_package_id
183#define topology_physical_package_id(cpu) ((void)(cpu), -1)
184#endif
185#ifndef topology_core_id
186#define topology_core_id(cpu) ((void)(cpu), 0)
187#endif
188#ifndef topology_thread_siblings
189#define topology_thread_siblings(cpu) cpumask_of_cpu(cpu)
190#endif
191#ifndef topology_core_siblings
192#define topology_core_siblings(cpu) cpumask_of_cpu(cpu)
193#endif
194
182#endif /* _LINUX_TOPOLOGY_H */ 195#endif /* _LINUX_TOPOLOGY_H */
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index bd91987c065..12b15c561a1 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -63,6 +63,7 @@ struct writeback_control {
63 unsigned for_writepages:1; /* This is a writepages() call */ 63 unsigned for_writepages:1; /* This is a writepages() call */
64 unsigned range_cyclic:1; /* range_start is cyclic */ 64 unsigned range_cyclic:1; /* range_start is cyclic */
65 unsigned more_io:1; /* more io to be dispatched */ 65 unsigned more_io:1; /* more io to be dispatched */
66 unsigned range_cont:1;
66}; 67};
67 68
68/* 69/*
diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h
index c36750ff6ae..483057b2f4b 100644
--- a/include/rdma/ib_addr.h
+++ b/include/rdma/ib_addr.h
@@ -2,29 +2,33 @@
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved. 2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved. 3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * 4 *
5 * This Software is licensed under one of the following licenses: 5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
6 * 10 *
7 * 1) under the terms of the "Common Public License 1.0" a copy of which is 11 * Redistribution and use in source and binary forms, with or
8 * available from the Open Source Initiative, see 12 * without modification, are permitted provided that the following
9 * http://www.opensource.org/licenses/cpl.php. 13 * conditions are met:
10 * 14 *
11 * 2) under the terms of the "The BSD License" a copy of which is 15 * - Redistributions of source code must retain the above
12 * available from the Open Source Initiative, see 16 * copyright notice, this list of conditions and the following
13 * http://www.opensource.org/licenses/bsd-license.php. 17 * disclaimer.
14 * 18 *
15 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 19 * - Redistributions in binary form must reproduce the above
16 * copy of which is available from the Open Source Initiative, see 20 * copyright notice, this list of conditions and the following
17 * http://www.opensource.org/licenses/gpl-license.php. 21 * disclaimer in the documentation and/or other materials
18 * 22 * provided with the distribution.
19 * Licensee has the right to choose one of the above licenses.
20 *
21 * Redistributions of source code must retain the above copyright
22 * notice and one of the license notices.
23 *
24 * Redistributions in binary form must reproduce both the above copyright
25 * notice, one of the license notices in the documentation
26 * and/or other materials provided with the distribution.
27 * 23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
28 */ 32 */
29 33
30#if !defined(IB_ADDR_H) 34#if !defined(IB_ADDR_H)
@@ -57,6 +61,7 @@ struct rdma_dev_addr {
57 unsigned char dst_dev_addr[MAX_ADDR_LEN]; 61 unsigned char dst_dev_addr[MAX_ADDR_LEN];
58 unsigned char broadcast[MAX_ADDR_LEN]; 62 unsigned char broadcast[MAX_ADDR_LEN];
59 enum rdma_node_type dev_type; 63 enum rdma_node_type dev_type;
64 struct net_device *src_dev;
60}; 65};
61 66
62/** 67/**
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index f179d233ffc..00a2b8ec327 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ib_cache.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#ifndef _IB_CACHE_H 35#ifndef _IB_CACHE_H
diff --git a/include/rdma/ib_cm.h b/include/rdma/ib_cm.h
index a627c8682d2..ec7c6d99ed3 100644
--- a/include/rdma/ib_cm.h
+++ b/include/rdma/ib_cm.h
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: ib_cm.h 4311 2005-12-05 18:42:01Z sean.hefty $
36 */ 34 */
37#if !defined(IB_CM_H) 35#if !defined(IB_CM_H)
38#define IB_CM_H 36#define IB_CM_H
diff --git a/include/rdma/ib_fmr_pool.h b/include/rdma/ib_fmr_pool.h
index 00dadbf94e1..f62b842e659 100644
--- a/include/rdma/ib_fmr_pool.h
+++ b/include/rdma/ib_fmr_pool.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ib_fmr_pool.h 2730 2005-06-28 16:43:03Z sean.hefty $
34 */ 32 */
35 33
36#if !defined(IB_FMR_POOL_H) 34#if !defined(IB_FMR_POOL_H)
@@ -61,7 +59,7 @@ struct ib_fmr_pool_param {
61 int pool_size; 59 int pool_size;
62 int dirty_watermark; 60 int dirty_watermark;
63 void (*flush_function)(struct ib_fmr_pool *pool, 61 void (*flush_function)(struct ib_fmr_pool *pool,
64 void * arg); 62 void *arg);
65 void *flush_arg; 63 void *flush_arg;
66 unsigned cache:1; 64 unsigned cache:1;
67}; 65};
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 7228c056b9e..5f6c40fffcf 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -32,11 +32,9 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: ib_mad.h 5596 2006-03-03 01:00:07Z sean.hefty $
37 */ 35 */
38 36
39#if !defined( IB_MAD_H ) 37#if !defined(IB_MAD_H)
40#define IB_MAD_H 38#define IB_MAD_H
41 39
42#include <linux/list.h> 40#include <linux/list.h>
@@ -194,8 +192,7 @@ struct ib_vendor_mad {
194 u8 data[IB_MGMT_VENDOR_DATA]; 192 u8 data[IB_MGMT_VENDOR_DATA];
195}; 193};
196 194
197struct ib_class_port_info 195struct ib_class_port_info {
198{
199 u8 base_version; 196 u8 base_version;
200 u8 class_version; 197 u8 class_version;
201 __be16 capability_mask; 198 __be16 capability_mask;
@@ -614,11 +611,11 @@ int ib_process_mad_wc(struct ib_mad_agent *mad_agent,
614 * any class specific header, and MAD data area. 611 * any class specific header, and MAD data area.
615 * If @rmpp_active is set, the RMPP header will be initialized for sending. 612 * If @rmpp_active is set, the RMPP header will be initialized for sending.
616 */ 613 */
617struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, 614struct ib_mad_send_buf *ib_create_send_mad(struct ib_mad_agent *mad_agent,
618 u32 remote_qpn, u16 pkey_index, 615 u32 remote_qpn, u16 pkey_index,
619 int rmpp_active, 616 int rmpp_active,
620 int hdr_len, int data_len, 617 int hdr_len, int data_len,
621 gfp_t gfp_mask); 618 gfp_t gfp_mask);
622 619
623/** 620/**
624 * ib_is_mad_class_rmpp - returns whether given management class 621 * ib_is_mad_class_rmpp - returns whether given management class
diff --git a/include/rdma/ib_pack.h b/include/rdma/ib_pack.h
index f926020d633..d7fc45c4eba 100644
--- a/include/rdma/ib_pack.h
+++ b/include/rdma/ib_pack.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ib_pack.h 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#ifndef IB_PACK_H 33#ifndef IB_PACK_H
diff --git a/include/rdma/ib_sa.h b/include/rdma/ib_sa.h
index 942692b0b92..3841c1aff69 100644
--- a/include/rdma/ib_sa.h
+++ b/include/rdma/ib_sa.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ib_sa.h 2811 2005-07-06 18:11:43Z halr $
35 */ 33 */
36 34
37#ifndef IB_SA_H 35#ifndef IB_SA_H
diff --git a/include/rdma/ib_smi.h b/include/rdma/ib_smi.h
index f29af135ba8..aaca0878668 100644
--- a/include/rdma/ib_smi.h
+++ b/include/rdma/ib_smi.h
@@ -32,11 +32,9 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: ib_smi.h 1389 2004-12-27 22:56:47Z roland $
37 */ 35 */
38 36
39#if !defined( IB_SMI_H ) 37#if !defined(IB_SMI_H)
40#define IB_SMI_H 38#define IB_SMI_H
41 39
42#include <rdma/ib_mad.h> 40#include <rdma/ib_mad.h>
diff --git a/include/rdma/ib_user_cm.h b/include/rdma/ib_user_cm.h
index 37650afb982..bd3d380781e 100644
--- a/include/rdma/ib_user_cm.h
+++ b/include/rdma/ib_user_cm.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ib_user_cm.h 4019 2005-11-11 00:33:09Z sean.hefty $
34 */ 32 */
35 33
36#ifndef IB_USER_CM_H 34#ifndef IB_USER_CM_H
diff --git a/include/rdma/ib_user_mad.h b/include/rdma/ib_user_mad.h
index 29d2c7205a9..d6fce1cbdb9 100644
--- a/include/rdma/ib_user_mad.h
+++ b/include/rdma/ib_user_mad.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ib_user_mad.h 2814 2005-07-06 19:14:09Z halr $
34 */ 32 */
35 33
36#ifndef IB_USER_MAD_H 34#ifndef IB_USER_MAD_H
diff --git a/include/rdma/ib_user_verbs.h b/include/rdma/ib_user_verbs.h
index 8d65bf0a625..a17f7710614 100644
--- a/include/rdma/ib_user_verbs.h
+++ b/include/rdma/ib_user_verbs.h
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: ib_user_verbs.h 4019 2005-11-11 00:33:09Z sean.hefty $
36 */ 34 */
37 35
38#ifndef IB_USER_VERBS_H 36#ifndef IB_USER_VERBS_H
@@ -291,7 +289,10 @@ struct ib_uverbs_wc {
291 __u32 opcode; 289 __u32 opcode;
292 __u32 vendor_err; 290 __u32 vendor_err;
293 __u32 byte_len; 291 __u32 byte_len;
294 __u32 imm_data; 292 union {
293 __u32 imm_data;
294 __u32 invalidate_rkey;
295 } ex;
295 __u32 qp_num; 296 __u32 qp_num;
296 __u32 src_qp; 297 __u32 src_qp;
297 __u32 wc_flags; 298 __u32 wc_flags;
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 31d30b1852e..90b529f7a15 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -34,8 +34,6 @@
34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 * SOFTWARE. 36 * SOFTWARE.
37 *
38 * $Id: ib_verbs.h 1349 2004-12-16 21:09:43Z roland $
39 */ 37 */
40 38
41#if !defined(IB_VERBS_H) 39#if !defined(IB_VERBS_H)
@@ -93,7 +91,7 @@ enum ib_device_cap_flags {
93 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12), 91 IB_DEVICE_RC_RNR_NAK_GEN = (1<<12),
94 IB_DEVICE_SRQ_RESIZE = (1<<13), 92 IB_DEVICE_SRQ_RESIZE = (1<<13),
95 IB_DEVICE_N_NOTIFY_CQ = (1<<14), 93 IB_DEVICE_N_NOTIFY_CQ = (1<<14),
96 IB_DEVICE_ZERO_STAG = (1<<15), 94 IB_DEVICE_LOCAL_DMA_LKEY = (1<<15),
97 IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */ 95 IB_DEVICE_RESERVED = (1<<16), /* old SEND_W_INV */
98 IB_DEVICE_MEM_WINDOW = (1<<17), 96 IB_DEVICE_MEM_WINDOW = (1<<17),
99 /* 97 /*
@@ -105,6 +103,8 @@ enum ib_device_cap_flags {
105 */ 103 */
106 IB_DEVICE_UD_IP_CSUM = (1<<18), 104 IB_DEVICE_UD_IP_CSUM = (1<<18),
107 IB_DEVICE_UD_TSO = (1<<19), 105 IB_DEVICE_UD_TSO = (1<<19),
106 IB_DEVICE_MEM_MGT_EXTENSIONS = (1<<21),
107 IB_DEVICE_BLOCK_MULTICAST_LOOPBACK = (1<<22),
108}; 108};
109 109
110enum ib_atomic_cap { 110enum ib_atomic_cap {
@@ -150,6 +150,7 @@ struct ib_device_attr {
150 int max_srq; 150 int max_srq;
151 int max_srq_wr; 151 int max_srq_wr;
152 int max_srq_sge; 152 int max_srq_sge;
153 unsigned int max_fast_reg_page_list_len;
153 u16 max_pkeys; 154 u16 max_pkeys;
154 u8 local_ca_ack_delay; 155 u8 local_ca_ack_delay;
155}; 156};
@@ -226,6 +227,57 @@ static inline int ib_width_enum_to_int(enum ib_port_width width)
226 } 227 }
227} 228}
228 229
230struct ib_protocol_stats {
231 /* TBD... */
232};
233
234struct iw_protocol_stats {
235 u64 ipInReceives;
236 u64 ipInHdrErrors;
237 u64 ipInTooBigErrors;
238 u64 ipInNoRoutes;
239 u64 ipInAddrErrors;
240 u64 ipInUnknownProtos;
241 u64 ipInTruncatedPkts;
242 u64 ipInDiscards;
243 u64 ipInDelivers;
244 u64 ipOutForwDatagrams;
245 u64 ipOutRequests;
246 u64 ipOutDiscards;
247 u64 ipOutNoRoutes;
248 u64 ipReasmTimeout;
249 u64 ipReasmReqds;
250 u64 ipReasmOKs;
251 u64 ipReasmFails;
252 u64 ipFragOKs;
253 u64 ipFragFails;
254 u64 ipFragCreates;
255 u64 ipInMcastPkts;
256 u64 ipOutMcastPkts;
257 u64 ipInBcastPkts;
258 u64 ipOutBcastPkts;
259
260 u64 tcpRtoAlgorithm;
261 u64 tcpRtoMin;
262 u64 tcpRtoMax;
263 u64 tcpMaxConn;
264 u64 tcpActiveOpens;
265 u64 tcpPassiveOpens;
266 u64 tcpAttemptFails;
267 u64 tcpEstabResets;
268 u64 tcpCurrEstab;
269 u64 tcpInSegs;
270 u64 tcpOutSegs;
271 u64 tcpRetransSegs;
272 u64 tcpInErrs;
273 u64 tcpOutRsts;
274};
275
276union rdma_protocol_stats {
277 struct ib_protocol_stats ib;
278 struct iw_protocol_stats iw;
279};
280
229struct ib_port_attr { 281struct ib_port_attr {
230 enum ib_port_state state; 282 enum ib_port_state state;
231 enum ib_mtu max_mtu; 283 enum ib_mtu max_mtu;
@@ -413,6 +465,8 @@ enum ib_wc_opcode {
413 IB_WC_FETCH_ADD, 465 IB_WC_FETCH_ADD,
414 IB_WC_BIND_MW, 466 IB_WC_BIND_MW,
415 IB_WC_LSO, 467 IB_WC_LSO,
468 IB_WC_LOCAL_INV,
469 IB_WC_FAST_REG_MR,
416/* 470/*
417 * Set value of IB_WC_RECV so consumers can test if a completion is a 471 * Set value of IB_WC_RECV so consumers can test if a completion is a
418 * receive by testing (opcode & IB_WC_RECV). 472 * receive by testing (opcode & IB_WC_RECV).
@@ -423,7 +477,8 @@ enum ib_wc_opcode {
423 477
424enum ib_wc_flags { 478enum ib_wc_flags {
425 IB_WC_GRH = 1, 479 IB_WC_GRH = 1,
426 IB_WC_WITH_IMM = (1<<1) 480 IB_WC_WITH_IMM = (1<<1),
481 IB_WC_WITH_INVALIDATE = (1<<2),
427}; 482};
428 483
429struct ib_wc { 484struct ib_wc {
@@ -433,7 +488,10 @@ struct ib_wc {
433 u32 vendor_err; 488 u32 vendor_err;
434 u32 byte_len; 489 u32 byte_len;
435 struct ib_qp *qp; 490 struct ib_qp *qp;
436 __be32 imm_data; 491 union {
492 __be32 imm_data;
493 u32 invalidate_rkey;
494 } ex;
437 u32 src_qp; 495 u32 src_qp;
438 int wc_flags; 496 int wc_flags;
439 u16 pkey_index; 497 u16 pkey_index;
@@ -498,7 +556,8 @@ enum ib_qp_type {
498}; 556};
499 557
500enum ib_qp_create_flags { 558enum ib_qp_create_flags {
501 IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0, 559 IB_QP_CREATE_IPOIB_UD_LSO = 1 << 0,
560 IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
502}; 561};
503 562
504struct ib_qp_init_attr { 563struct ib_qp_init_attr {
@@ -627,6 +686,9 @@ enum ib_wr_opcode {
627 IB_WR_ATOMIC_FETCH_AND_ADD, 686 IB_WR_ATOMIC_FETCH_AND_ADD,
628 IB_WR_LSO, 687 IB_WR_LSO,
629 IB_WR_SEND_WITH_INV, 688 IB_WR_SEND_WITH_INV,
689 IB_WR_RDMA_READ_WITH_INV,
690 IB_WR_LOCAL_INV,
691 IB_WR_FAST_REG_MR,
630}; 692};
631 693
632enum ib_send_flags { 694enum ib_send_flags {
@@ -643,6 +705,12 @@ struct ib_sge {
643 u32 lkey; 705 u32 lkey;
644}; 706};
645 707
708struct ib_fast_reg_page_list {
709 struct ib_device *device;
710 u64 *page_list;
711 unsigned int max_page_list_len;
712};
713
646struct ib_send_wr { 714struct ib_send_wr {
647 struct ib_send_wr *next; 715 struct ib_send_wr *next;
648 u64 wr_id; 716 u64 wr_id;
@@ -675,6 +743,15 @@ struct ib_send_wr {
675 u16 pkey_index; /* valid for GSI only */ 743 u16 pkey_index; /* valid for GSI only */
676 u8 port_num; /* valid for DR SMPs on switch only */ 744 u8 port_num; /* valid for DR SMPs on switch only */
677 } ud; 745 } ud;
746 struct {
747 u64 iova_start;
748 struct ib_fast_reg_page_list *page_list;
749 unsigned int page_shift;
750 unsigned int page_list_len;
751 u32 length;
752 int access_flags;
753 u32 rkey;
754 } fast_reg;
678 } wr; 755 } wr;
679}; 756};
680 757
@@ -777,7 +854,7 @@ struct ib_cq {
777 struct ib_uobject *uobject; 854 struct ib_uobject *uobject;
778 ib_comp_handler comp_handler; 855 ib_comp_handler comp_handler;
779 void (*event_handler)(struct ib_event *, void *); 856 void (*event_handler)(struct ib_event *, void *);
780 void * cq_context; 857 void *cq_context;
781 int cqe; 858 int cqe;
782 atomic_t usecnt; /* count number of work queues */ 859 atomic_t usecnt; /* count number of work queues */
783}; 860};
@@ -883,7 +960,7 @@ struct ib_dma_mapping_ops {
883 void (*sync_single_for_cpu)(struct ib_device *dev, 960 void (*sync_single_for_cpu)(struct ib_device *dev,
884 u64 dma_handle, 961 u64 dma_handle,
885 size_t size, 962 size_t size,
886 enum dma_data_direction dir); 963 enum dma_data_direction dir);
887 void (*sync_single_for_device)(struct ib_device *dev, 964 void (*sync_single_for_device)(struct ib_device *dev,
888 u64 dma_handle, 965 u64 dma_handle,
889 size_t size, 966 size_t size,
@@ -919,6 +996,8 @@ struct ib_device {
919 996
920 struct iw_cm_verbs *iwcm; 997 struct iw_cm_verbs *iwcm;
921 998
999 int (*get_protocol_stats)(struct ib_device *device,
1000 union rdma_protocol_stats *stats);
922 int (*query_device)(struct ib_device *device, 1001 int (*query_device)(struct ib_device *device,
923 struct ib_device_attr *device_attr); 1002 struct ib_device_attr *device_attr);
924 int (*query_port)(struct ib_device *device, 1003 int (*query_port)(struct ib_device *device,
@@ -1013,6 +1092,11 @@ struct ib_device {
1013 int (*query_mr)(struct ib_mr *mr, 1092 int (*query_mr)(struct ib_mr *mr,
1014 struct ib_mr_attr *mr_attr); 1093 struct ib_mr_attr *mr_attr);
1015 int (*dereg_mr)(struct ib_mr *mr); 1094 int (*dereg_mr)(struct ib_mr *mr);
1095 struct ib_mr * (*alloc_fast_reg_mr)(struct ib_pd *pd,
1096 int max_page_list_len);
1097 struct ib_fast_reg_page_list * (*alloc_fast_reg_page_list)(struct ib_device *device,
1098 int page_list_len);
1099 void (*free_fast_reg_page_list)(struct ib_fast_reg_page_list *page_list);
1016 int (*rereg_phys_mr)(struct ib_mr *mr, 1100 int (*rereg_phys_mr)(struct ib_mr *mr,
1017 int mr_rereg_mask, 1101 int mr_rereg_mask,
1018 struct ib_pd *pd, 1102 struct ib_pd *pd,
@@ -1065,6 +1149,7 @@ struct ib_device {
1065 1149
1066 char node_desc[64]; 1150 char node_desc[64];
1067 __be64 node_guid; 1151 __be64 node_guid;
1152 u32 local_dma_lkey;
1068 u8 node_type; 1153 u8 node_type;
1069 u8 phys_port_cnt; 1154 u8 phys_port_cnt;
1070}; 1155};
@@ -1807,6 +1892,54 @@ int ib_query_mr(struct ib_mr *mr, struct ib_mr_attr *mr_attr);
1807int ib_dereg_mr(struct ib_mr *mr); 1892int ib_dereg_mr(struct ib_mr *mr);
1808 1893
1809/** 1894/**
1895 * ib_alloc_fast_reg_mr - Allocates memory region usable with the
1896 * IB_WR_FAST_REG_MR send work request.
1897 * @pd: The protection domain associated with the region.
1898 * @max_page_list_len: requested max physical buffer list length to be
1899 * used with fast register work requests for this MR.
1900 */
1901struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len);
1902
1903/**
1904 * ib_alloc_fast_reg_page_list - Allocates a page list array
1905 * @device - ib device pointer.
1906 * @page_list_len - size of the page list array to be allocated.
1907 *
1908 * This allocates and returns a struct ib_fast_reg_page_list * and a
1909 * page_list array that is at least page_list_len in size. The actual
1910 * size is returned in max_page_list_len. The caller is responsible
1911 * for initializing the contents of the page_list array before posting
1912 * a send work request with the IB_WC_FAST_REG_MR opcode.
1913 *
1914 * The page_list array entries must be translated using one of the
1915 * ib_dma_*() functions just like the addresses passed to
1916 * ib_map_phys_fmr(). Once the ib_post_send() is issued, the struct
1917 * ib_fast_reg_page_list must not be modified by the caller until the
1918 * IB_WC_FAST_REG_MR work request completes.
1919 */
1920struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(
1921 struct ib_device *device, int page_list_len);
1922
1923/**
1924 * ib_free_fast_reg_page_list - Deallocates a previously allocated
1925 * page list array.
1926 * @page_list - struct ib_fast_reg_page_list pointer to be deallocated.
1927 */
1928void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list);
1929
1930/**
1931 * ib_update_fast_reg_key - updates the key portion of the fast_reg MR
1932 * R_Key and L_Key.
1933 * @mr - struct ib_mr pointer to be updated.
1934 * @newkey - new key to be used.
1935 */
1936static inline void ib_update_fast_reg_key(struct ib_mr *mr, u8 newkey)
1937{
1938 mr->lkey = (mr->lkey & 0xffffff00) | newkey;
1939 mr->rkey = (mr->rkey & 0xffffff00) | newkey;
1940}
1941
1942/**
1810 * ib_alloc_mw - Allocates a memory window. 1943 * ib_alloc_mw - Allocates a memory window.
1811 * @pd: The protection domain associated with the memory window. 1944 * @pd: The protection domain associated with the memory window.
1812 */ 1945 */
diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
index aeefa9b740d..cbb822e8d79 100644
--- a/include/rdma/iw_cm.h
+++ b/include/rdma/iw_cm.h
@@ -62,7 +62,7 @@ struct iw_cm_event {
62 struct sockaddr_in remote_addr; 62 struct sockaddr_in remote_addr;
63 void *private_data; 63 void *private_data;
64 u8 private_data_len; 64 u8 private_data_len;
65 void* provider_data; 65 void *provider_data;
66}; 66};
67 67
68/** 68/**
diff --git a/include/rdma/rdma_cm.h b/include/rdma/rdma_cm.h
index 010f876f41d..22bb2e7bab1 100644
--- a/include/rdma/rdma_cm.h
+++ b/include/rdma/rdma_cm.h
@@ -2,29 +2,33 @@
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved. 2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved. 3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * 4 *
5 * This Software is licensed under one of the following licenses: 5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
6 * 10 *
7 * 1) under the terms of the "Common Public License 1.0" a copy of which is 11 * Redistribution and use in source and binary forms, with or
8 * available from the Open Source Initiative, see 12 * without modification, are permitted provided that the following
9 * http://www.opensource.org/licenses/cpl.php. 13 * conditions are met:
10 * 14 *
11 * 2) under the terms of the "The BSD License" a copy of which is 15 * - Redistributions of source code must retain the above
12 * available from the Open Source Initiative, see 16 * copyright notice, this list of conditions and the following
13 * http://www.opensource.org/licenses/bsd-license.php. 17 * disclaimer.
14 * 18 *
15 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 19 * - Redistributions in binary form must reproduce the above
16 * copy of which is available from the Open Source Initiative, see 20 * copyright notice, this list of conditions and the following
17 * http://www.opensource.org/licenses/gpl-license.php. 21 * disclaimer in the documentation and/or other materials
18 * 22 * provided with the distribution.
19 * Licensee has the right to choose one of the above licenses.
20 *
21 * Redistributions of source code must retain the above copyright
22 * notice and one of the license notices.
23 *
24 * Redistributions in binary form must reproduce both the above copyright
25 * notice, one of the license notices in the documentation
26 * and/or other materials provided with the distribution.
27 * 23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
28 */ 32 */
29 33
30#if !defined(RDMA_CM_H) 34#if !defined(RDMA_CM_H)
@@ -57,11 +61,11 @@ enum rdma_cm_event_type {
57}; 61};
58 62
59enum rdma_port_space { 63enum rdma_port_space {
60 RDMA_PS_SDP = 0x0001, 64 RDMA_PS_SDP = 0x0001,
61 RDMA_PS_IPOIB= 0x0002, 65 RDMA_PS_IPOIB = 0x0002,
62 RDMA_PS_TCP = 0x0106, 66 RDMA_PS_TCP = 0x0106,
63 RDMA_PS_UDP = 0x0111, 67 RDMA_PS_UDP = 0x0111,
64 RDMA_PS_SCTP = 0x0183 68 RDMA_PS_SCTP = 0x0183
65}; 69};
66 70
67struct rdma_addr { 71struct rdma_addr {
diff --git a/include/rdma/rdma_cm_ib.h b/include/rdma/rdma_cm_ib.h
index 950424b38f1..2389c3b4540 100644
--- a/include/rdma/rdma_cm_ib.h
+++ b/include/rdma/rdma_cm_ib.h
@@ -1,29 +1,33 @@
1/* 1/*
2 * Copyright (c) 2006 Intel Corporation. All rights reserved. 2 * Copyright (c) 2006 Intel Corporation. All rights reserved.
3 * 3 *
4 * This Software is licensed under one of the following licenses: 4 * This software is available to you under a choice of one of two
5 * 5 * licenses. You may choose to be licensed under the terms of the GNU
6 * 1) under the terms of the "Common Public License 1.0" a copy of which is 6 * General Public License (GPL) Version 2, available from the file
7 * available from the Open Source Initiative, see 7 * COPYING in the main directory of this source tree, or the
8 * http://www.opensource.org/licenses/cpl.php. 8 * OpenIB.org BSD license below:
9 * 9 *
10 * 2) under the terms of the "The BSD License" a copy of which is 10 * Redistribution and use in source and binary forms, with or
11 * available from the Open Source Initiative, see 11 * without modification, are permitted provided that the following
12 * http://www.opensource.org/licenses/bsd-license.php. 12 * conditions are met:
13 * 13 *
14 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 14 * - Redistributions of source code must retain the above
15 * copy of which is available from the Open Source Initiative, see 15 * copyright notice, this list of conditions and the following
16 * http://www.opensource.org/licenses/gpl-license.php. 16 * disclaimer.
17 * 17 *
18 * Licensee has the right to choose one of the above licenses. 18 * - Redistributions in binary form must reproduce the above
19 * 19 * copyright notice, this list of conditions and the following
20 * Redistributions of source code must retain the above copyright 20 * disclaimer in the documentation and/or other materials
21 * notice and one of the license notices. 21 * provided with the distribution.
22 * 22 *
23 * Redistributions in binary form must reproduce both the above copyright 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * notice, one of the license notices in the documentation 24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * and/or other materials provided with the distribution. 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * 26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
27 */ 31 */
28 32
29#if !defined(RDMA_CM_IB_H) 33#if !defined(RDMA_CM_IB_H)
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index f6a9fe0ef09..00b78763a1b 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -134,6 +134,7 @@ struct scsi_device {
134 unsigned no_start_on_add:1; /* do not issue start on add */ 134 unsigned no_start_on_add:1; /* do not issue start on add */
135 unsigned allow_restart:1; /* issue START_UNIT in error handler */ 135 unsigned allow_restart:1; /* issue START_UNIT in error handler */
136 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */ 136 unsigned manage_start_stop:1; /* Let HLD (sd) manage start/stop */
137 unsigned start_stop_pwr_cond:1; /* Set power cond. in START_STOP_UNIT */
137 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */ 138 unsigned no_uld_attach:1; /* disable connecting to upper level drivers */
138 unsigned select_no_atn:1; 139 unsigned select_no_atn:1;
139 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 140 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
diff --git a/init/main.c b/init/main.c
index f7fb20021d4..edeace036fd 100644
--- a/init/main.c
+++ b/init/main.c
@@ -31,6 +31,7 @@
31#include <linux/kernel_stat.h> 31#include <linux/kernel_stat.h>
32#include <linux/start_kernel.h> 32#include <linux/start_kernel.h>
33#include <linux/security.h> 33#include <linux/security.h>
34#include <linux/smp.h>
34#include <linux/workqueue.h> 35#include <linux/workqueue.h>
35#include <linux/profile.h> 36#include <linux/profile.h>
36#include <linux/rcupdate.h> 37#include <linux/rcupdate.h>
@@ -758,6 +759,7 @@ static void __init do_initcalls(void)
758 */ 759 */
759static void __init do_basic_setup(void) 760static void __init do_basic_setup(void)
760{ 761{
762 rcu_init_sched(); /* needed by module_init stage. */
761 /* drivers will send hotplug events */ 763 /* drivers will send hotplug events */
762 init_workqueues(); 764 init_workqueues();
763 usermodehelper_init(); 765 usermodehelper_init();
@@ -779,6 +781,7 @@ static void __init do_pre_smp_initcalls(void)
779{ 781{
780 extern int spawn_ksoftirqd(void); 782 extern int spawn_ksoftirqd(void);
781 783
784 init_call_single_data();
782 migration_init(); 785 migration_init();
783 spawn_ksoftirqd(); 786 spawn_ksoftirqd();
784 if (!nosoftlockup) 787 if (!nosoftlockup)
diff --git a/kernel/Makefile b/kernel/Makefile
index f6328e16dfd..0a7ed838984 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_RT_MUTEXES) += rtmutex.o
39obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o 39obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o
40obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o 40obj-$(CONFIG_RT_MUTEX_TESTER) += rtmutex-tester.o
41obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o 41obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
42obj-$(CONFIG_USE_GENERIC_SMP_HELPERS) += smp.o
42obj-$(CONFIG_SMP) += spinlock.o 43obj-$(CONFIG_SMP) += spinlock.o
43obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o 44obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
44obj-$(CONFIG_PROVE_LOCKING) += spinlock.o 45obj-$(CONFIG_PROVE_LOCKING) += spinlock.o
diff --git a/kernel/backtracetest.c b/kernel/backtracetest.c
index d1a7605c5b8..a5e026bc45c 100644
--- a/kernel/backtracetest.c
+++ b/kernel/backtracetest.c
@@ -10,30 +10,73 @@
10 * of the License. 10 * of the License.
11 */ 11 */
12 12
13#include <linux/completion.h>
14#include <linux/delay.h>
15#include <linux/interrupt.h>
13#include <linux/module.h> 16#include <linux/module.h>
14#include <linux/sched.h> 17#include <linux/sched.h>
15#include <linux/delay.h> 18#include <linux/stacktrace.h>
19
20static void backtrace_test_normal(void)
21{
22 printk("Testing a backtrace from process context.\n");
23 printk("The following trace is a kernel self test and not a bug!\n");
16 24
17static struct timer_list backtrace_timer; 25 dump_stack();
26}
18 27
19static void backtrace_test_timer(unsigned long data) 28static DECLARE_COMPLETION(backtrace_work);
29
30static void backtrace_test_irq_callback(unsigned long data)
31{
32 dump_stack();
33 complete(&backtrace_work);
34}
35
36static DECLARE_TASKLET(backtrace_tasklet, &backtrace_test_irq_callback, 0);
37
38static void backtrace_test_irq(void)
20{ 39{
21 printk("Testing a backtrace from irq context.\n"); 40 printk("Testing a backtrace from irq context.\n");
22 printk("The following trace is a kernel self test and not a bug!\n"); 41 printk("The following trace is a kernel self test and not a bug!\n");
23 dump_stack(); 42
43 init_completion(&backtrace_work);
44 tasklet_schedule(&backtrace_tasklet);
45 wait_for_completion(&backtrace_work);
46}
47
48#ifdef CONFIG_STACKTRACE
49static void backtrace_test_saved(void)
50{
51 struct stack_trace trace;
52 unsigned long entries[8];
53
54 printk("Testing a saved backtrace.\n");
55 printk("The following trace is a kernel self test and not a bug!\n");
56
57 trace.nr_entries = 0;
58 trace.max_entries = ARRAY_SIZE(entries);
59 trace.entries = entries;
60 trace.skip = 0;
61
62 save_stack_trace(&trace);
63 print_stack_trace(&trace, 0);
64}
65#else
66static void backtrace_test_saved(void)
67{
68 printk("Saved backtrace test skipped.\n");
24} 69}
70#endif
71
25static int backtrace_regression_test(void) 72static int backtrace_regression_test(void)
26{ 73{
27 printk("====[ backtrace testing ]===========\n"); 74 printk("====[ backtrace testing ]===========\n");
28 printk("Testing a backtrace from process context.\n");
29 printk("The following trace is a kernel self test and not a bug!\n");
30 dump_stack();
31 75
32 init_timer(&backtrace_timer); 76 backtrace_test_normal();
33 backtrace_timer.function = backtrace_test_timer; 77 backtrace_test_irq();
34 mod_timer(&backtrace_timer, jiffies + 10); 78 backtrace_test_saved();
35 79
36 msleep(10);
37 printk("====[ end of backtrace testing ]====\n"); 80 printk("====[ end of backtrace testing ]====\n");
38 return 0; 81 return 0;
39} 82}
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 27a83ee4144..b8e4dce80a7 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -300,11 +300,10 @@ EXPORT_SYMBOL_GPL(ktime_sub_ns);
300 */ 300 */
301u64 ktime_divns(const ktime_t kt, s64 div) 301u64 ktime_divns(const ktime_t kt, s64 div)
302{ 302{
303 u64 dclc, inc, dns; 303 u64 dclc;
304 int sft = 0; 304 int sft = 0;
305 305
306 dclc = dns = ktime_to_ns(kt); 306 dclc = ktime_to_ns(kt);
307 inc = div;
308 /* Make sure the divisor is less than 2^32: */ 307 /* Make sure the divisor is less than 2^32: */
309 while (div >> 32) { 308 while (div >> 32) {
310 sft++; 309 sft++;
@@ -623,7 +622,7 @@ static void retrigger_next_event(void *arg)
623void clock_was_set(void) 622void clock_was_set(void)
624{ 623{
625 /* Retrigger the CPU local events everywhere */ 624 /* Retrigger the CPU local events everywhere */
626 on_each_cpu(retrigger_next_event, NULL, 0, 1); 625 on_each_cpu(retrigger_next_event, NULL, 1);
627} 626}
628 627
629/* 628/*
@@ -632,8 +631,6 @@ void clock_was_set(void)
632 */ 631 */
633void hres_timers_resume(void) 632void hres_timers_resume(void)
634{ 633{
635 WARN_ON_ONCE(num_online_cpus() > 1);
636
637 /* Retrigger the CPU local events: */ 634 /* Retrigger the CPU local events: */
638 retrigger_next_event(NULL); 635 retrigger_next_event(NULL);
639} 636}
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 46d6611a33b..77a51be3601 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -17,6 +17,8 @@
17 17
18#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
19 19
20cpumask_t irq_default_affinity = CPU_MASK_ALL;
21
20/** 22/**
21 * synchronize_irq - wait for pending IRQ handlers (on other CPUs) 23 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
22 * @irq: interrupt number to wait for 24 * @irq: interrupt number to wait for
@@ -95,6 +97,27 @@ int irq_set_affinity(unsigned int irq, cpumask_t cpumask)
95 return 0; 97 return 0;
96} 98}
97 99
100#ifndef CONFIG_AUTO_IRQ_AFFINITY
101/*
102 * Generic version of the affinity autoselector.
103 */
104int irq_select_affinity(unsigned int irq)
105{
106 cpumask_t mask;
107
108 if (!irq_can_set_affinity(irq))
109 return 0;
110
111 cpus_and(mask, cpu_online_map, irq_default_affinity);
112
113 irq_desc[irq].affinity = mask;
114 irq_desc[irq].chip->set_affinity(irq, mask);
115
116 set_balance_irq_affinity(irq, mask);
117 return 0;
118}
119#endif
120
98#endif 121#endif
99 122
100/** 123/**
@@ -354,7 +377,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
354 377
355 /* Setup the type (level, edge polarity) if configured: */ 378 /* Setup the type (level, edge polarity) if configured: */
356 if (new->flags & IRQF_TRIGGER_MASK) { 379 if (new->flags & IRQF_TRIGGER_MASK) {
357 if (desc->chip && desc->chip->set_type) 380 if (desc->chip->set_type)
358 desc->chip->set_type(irq, 381 desc->chip->set_type(irq,
359 new->flags & IRQF_TRIGGER_MASK); 382 new->flags & IRQF_TRIGGER_MASK);
360 else 383 else
@@ -364,8 +387,7 @@ int setup_irq(unsigned int irq, struct irqaction *new)
364 */ 387 */
365 printk(KERN_WARNING "No IRQF_TRIGGER set_type " 388 printk(KERN_WARNING "No IRQF_TRIGGER set_type "
366 "function for IRQ %d (%s)\n", irq, 389 "function for IRQ %d (%s)\n", irq,
367 desc->chip ? desc->chip->name : 390 desc->chip->name);
368 "unknown");
369 } else 391 } else
370 compat_irq_chip_set_default_handler(desc); 392 compat_irq_chip_set_default_handler(desc);
371 393
@@ -382,6 +404,9 @@ int setup_irq(unsigned int irq, struct irqaction *new)
382 } else 404 } else
383 /* Undo nested disables: */ 405 /* Undo nested disables: */
384 desc->depth = 1; 406 desc->depth = 1;
407
408 /* Set default affinity mask once everything is setup */
409 irq_select_affinity(irq);
385 } 410 }
386 /* Reset broken irq detection when installing new handler */ 411 /* Reset broken irq detection when installing new handler */
387 desc->irq_count = 0; 412 desc->irq_count = 0;
@@ -571,8 +596,6 @@ int request_irq(unsigned int irq, irq_handler_t handler,
571 action->next = NULL; 596 action->next = NULL;
572 action->dev_id = dev_id; 597 action->dev_id = dev_id;
573 598
574 select_smp_affinity(irq);
575
576#ifdef CONFIG_DEBUG_SHIRQ 599#ifdef CONFIG_DEBUG_SHIRQ
577 if (irqflags & IRQF_SHARED) { 600 if (irqflags & IRQF_SHARED) {
578 /* 601 /*
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index c2f2ccb0549..6c6d35d68ee 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -44,7 +44,7 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
44 unsigned long count, void *data) 44 unsigned long count, void *data)
45{ 45{
46 unsigned int irq = (int)(long)data, full_count = count, err; 46 unsigned int irq = (int)(long)data, full_count = count, err;
47 cpumask_t new_value, tmp; 47 cpumask_t new_value;
48 48
49 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity || 49 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity ||
50 irq_balancing_disabled(irq)) 50 irq_balancing_disabled(irq))
@@ -62,17 +62,51 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
62 * way to make the system unusable accidentally :-) At least 62 * way to make the system unusable accidentally :-) At least
63 * one online CPU still has to be targeted. 63 * one online CPU still has to be targeted.
64 */ 64 */
65 cpus_and(tmp, new_value, cpu_online_map); 65 if (!cpus_intersects(new_value, cpu_online_map))
66 if (cpus_empty(tmp))
67 /* Special case for empty set - allow the architecture 66 /* Special case for empty set - allow the architecture
68 code to set default SMP affinity. */ 67 code to set default SMP affinity. */
69 return select_smp_affinity(irq) ? -EINVAL : full_count; 68 return irq_select_affinity(irq) ? -EINVAL : full_count;
70 69
71 irq_set_affinity(irq, new_value); 70 irq_set_affinity(irq, new_value);
72 71
73 return full_count; 72 return full_count;
74} 73}
75 74
75static int default_affinity_read(char *page, char **start, off_t off,
76 int count, int *eof, void *data)
77{
78 int len = cpumask_scnprintf(page, count, irq_default_affinity);
79 if (count - len < 2)
80 return -EINVAL;
81 len += sprintf(page + len, "\n");
82 return len;
83}
84
85static int default_affinity_write(struct file *file, const char __user *buffer,
86 unsigned long count, void *data)
87{
88 unsigned int full_count = count, err;
89 cpumask_t new_value;
90
91 err = cpumask_parse_user(buffer, count, new_value);
92 if (err)
93 return err;
94
95 if (!is_affinity_mask_valid(new_value))
96 return -EINVAL;
97
98 /*
99 * Do not allow disabling IRQs completely - it's a too easy
100 * way to make the system unusable accidentally :-) At least
101 * one online CPU still has to be targeted.
102 */
103 if (!cpus_intersects(new_value, cpu_online_map))
104 return -EINVAL;
105
106 irq_default_affinity = new_value;
107
108 return full_count;
109}
76#endif 110#endif
77 111
78static int irq_spurious_read(char *page, char **start, off_t off, 112static int irq_spurious_read(char *page, char **start, off_t off,
@@ -171,6 +205,21 @@ void unregister_handler_proc(unsigned int irq, struct irqaction *action)
171 remove_proc_entry(action->dir->name, irq_desc[irq].dir); 205 remove_proc_entry(action->dir->name, irq_desc[irq].dir);
172} 206}
173 207
208void register_default_affinity_proc(void)
209{
210#ifdef CONFIG_SMP
211 struct proc_dir_entry *entry;
212
213 /* create /proc/irq/default_smp_affinity */
214 entry = create_proc_entry("default_smp_affinity", 0600, root_irq_dir);
215 if (entry) {
216 entry->data = NULL;
217 entry->read_proc = default_affinity_read;
218 entry->write_proc = default_affinity_write;
219 }
220#endif
221}
222
174void init_irq_proc(void) 223void init_irq_proc(void)
175{ 224{
176 int i; 225 int i;
@@ -180,6 +229,8 @@ void init_irq_proc(void)
180 if (!root_irq_dir) 229 if (!root_irq_dir)
181 return; 230 return;
182 231
232 register_default_affinity_proc();
233
183 /* 234 /*
184 * Create entries for all existing IRQs. 235 * Create entries for all existing IRQs.
185 */ 236 */
diff --git a/kernel/pid.c b/kernel/pid.c
index 20d59fa2d49..30bd5d4b2ac 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -30,6 +30,7 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/rculist.h>
33#include <linux/bootmem.h> 34#include <linux/bootmem.h>
34#include <linux/hash.h> 35#include <linux/hash.h>
35#include <linux/pid_namespace.h> 36#include <linux/pid_namespace.h>
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index f1525ad06cb..c42a03aef36 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -1037,6 +1037,9 @@ static void check_thread_timers(struct task_struct *tsk,
1037 sig->rlim[RLIMIT_RTTIME].rlim_cur += 1037 sig->rlim[RLIMIT_RTTIME].rlim_cur +=
1038 USEC_PER_SEC; 1038 USEC_PER_SEC;
1039 } 1039 }
1040 printk(KERN_INFO
1041 "RT Watchdog Timeout: %s[%d]\n",
1042 tsk->comm, task_pid_nr(tsk));
1040 __group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk); 1043 __group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
1041 } 1044 }
1042 } 1045 }
diff --git a/kernel/profile.c b/kernel/profile.c
index ae7ead82cbc..58926411eb2 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -252,7 +252,7 @@ static void profile_flip_buffers(void)
252 mutex_lock(&profile_flip_mutex); 252 mutex_lock(&profile_flip_mutex);
253 j = per_cpu(cpu_profile_flip, get_cpu()); 253 j = per_cpu(cpu_profile_flip, get_cpu());
254 put_cpu(); 254 put_cpu();
255 on_each_cpu(__profile_flip_buffers, NULL, 0, 1); 255 on_each_cpu(__profile_flip_buffers, NULL, 1);
256 for_each_online_cpu(cpu) { 256 for_each_online_cpu(cpu) {
257 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[j]; 257 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[j];
258 for (i = 0; i < NR_PROFILE_HIT; ++i) { 258 for (i = 0; i < NR_PROFILE_HIT; ++i) {
@@ -275,7 +275,7 @@ static void profile_discard_flip_buffers(void)
275 mutex_lock(&profile_flip_mutex); 275 mutex_lock(&profile_flip_mutex);
276 i = per_cpu(cpu_profile_flip, get_cpu()); 276 i = per_cpu(cpu_profile_flip, get_cpu());
277 put_cpu(); 277 put_cpu();
278 on_each_cpu(__profile_flip_buffers, NULL, 0, 1); 278 on_each_cpu(__profile_flip_buffers, NULL, 1);
279 for_each_online_cpu(cpu) { 279 for_each_online_cpu(cpu) {
280 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i]; 280 struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
281 memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit)); 281 memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
@@ -558,7 +558,7 @@ static int __init create_hash_tables(void)
558out_cleanup: 558out_cleanup:
559 prof_on = 0; 559 prof_on = 0;
560 smp_mb(); 560 smp_mb();
561 on_each_cpu(profile_nop, NULL, 0, 1); 561 on_each_cpu(profile_nop, NULL, 1);
562 for_each_online_cpu(cpu) { 562 for_each_online_cpu(cpu) {
563 struct page *page; 563 struct page *page;
564 564
diff --git a/kernel/rcuclassic.c b/kernel/rcuclassic.c
index 65c0906080e..16eeeaa9d61 100644
--- a/kernel/rcuclassic.c
+++ b/kernel/rcuclassic.c
@@ -387,6 +387,10 @@ static void __rcu_offline_cpu(struct rcu_data *this_rdp,
387 rcu_move_batch(this_rdp, rdp->donelist, rdp->donetail); 387 rcu_move_batch(this_rdp, rdp->donelist, rdp->donetail);
388 rcu_move_batch(this_rdp, rdp->curlist, rdp->curtail); 388 rcu_move_batch(this_rdp, rdp->curlist, rdp->curtail);
389 rcu_move_batch(this_rdp, rdp->nxtlist, rdp->nxttail); 389 rcu_move_batch(this_rdp, rdp->nxtlist, rdp->nxttail);
390
391 local_irq_disable();
392 this_rdp->qlen += rdp->qlen;
393 local_irq_enable();
390} 394}
391 395
392static void rcu_offline_cpu(int cpu) 396static void rcu_offline_cpu(int cpu)
@@ -516,10 +520,38 @@ void rcu_check_callbacks(int cpu, int user)
516 if (user || 520 if (user ||
517 (idle_cpu(cpu) && !in_softirq() && 521 (idle_cpu(cpu) && !in_softirq() &&
518 hardirq_count() <= (1 << HARDIRQ_SHIFT))) { 522 hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
523
524 /*
525 * Get here if this CPU took its interrupt from user
526 * mode or from the idle loop, and if this is not a
527 * nested interrupt. In this case, the CPU is in
528 * a quiescent state, so count it.
529 *
530 * Also do a memory barrier. This is needed to handle
531 * the case where writes from a preempt-disable section
532 * of code get reordered into schedule() by this CPU's
533 * write buffer. The memory barrier makes sure that
534 * the rcu_qsctr_inc() and rcu_bh_qsctr_inc() are see
535 * by other CPUs to happen after any such write.
536 */
537
538 smp_mb(); /* See above block comment. */
519 rcu_qsctr_inc(cpu); 539 rcu_qsctr_inc(cpu);
520 rcu_bh_qsctr_inc(cpu); 540 rcu_bh_qsctr_inc(cpu);
521 } else if (!in_softirq()) 541
542 } else if (!in_softirq()) {
543
544 /*
545 * Get here if this CPU did not take its interrupt from
546 * softirq, in other words, if it is not interrupting
547 * a rcu_bh read-side critical section. This is an _bh
548 * critical section, so count it. The memory barrier
549 * is needed for the same reason as is the above one.
550 */
551
552 smp_mb(); /* See above block comment. */
522 rcu_bh_qsctr_inc(cpu); 553 rcu_bh_qsctr_inc(cpu);
554 }
523 raise_rcu_softirq(); 555 raise_rcu_softirq();
524} 556}
525 557
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index c09605f8d16..f14f372cf6f 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -39,16 +39,16 @@
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <asm/atomic.h> 40#include <asm/atomic.h>
41#include <linux/bitops.h> 41#include <linux/bitops.h>
42#include <linux/completion.h>
43#include <linux/percpu.h> 42#include <linux/percpu.h>
44#include <linux/notifier.h> 43#include <linux/notifier.h>
45#include <linux/cpu.h> 44#include <linux/cpu.h>
46#include <linux/mutex.h> 45#include <linux/mutex.h>
47#include <linux/module.h> 46#include <linux/module.h>
48 47
49struct rcu_synchronize { 48enum rcu_barrier {
50 struct rcu_head head; 49 RCU_BARRIER_STD,
51 struct completion completion; 50 RCU_BARRIER_BH,
51 RCU_BARRIER_SCHED,
52}; 52};
53 53
54static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL}; 54static DEFINE_PER_CPU(struct rcu_head, rcu_barrier_head) = {NULL};
@@ -60,7 +60,7 @@ static struct completion rcu_barrier_completion;
60 * Awaken the corresponding synchronize_rcu() instance now that a 60 * Awaken the corresponding synchronize_rcu() instance now that a
61 * grace period has elapsed. 61 * grace period has elapsed.
62 */ 62 */
63static void wakeme_after_rcu(struct rcu_head *head) 63void wakeme_after_rcu(struct rcu_head *head)
64{ 64{
65 struct rcu_synchronize *rcu; 65 struct rcu_synchronize *rcu;
66 66
@@ -77,17 +77,7 @@ static void wakeme_after_rcu(struct rcu_head *head)
77 * sections are delimited by rcu_read_lock() and rcu_read_unlock(), 77 * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
78 * and may be nested. 78 * and may be nested.
79 */ 79 */
80void synchronize_rcu(void) 80synchronize_rcu_xxx(synchronize_rcu, call_rcu)
81{
82 struct rcu_synchronize rcu;
83
84 init_completion(&rcu.completion);
85 /* Will wake me after RCU finished */
86 call_rcu(&rcu.head, wakeme_after_rcu);
87
88 /* Wait for it */
89 wait_for_completion(&rcu.completion);
90}
91EXPORT_SYMBOL_GPL(synchronize_rcu); 81EXPORT_SYMBOL_GPL(synchronize_rcu);
92 82
93static void rcu_barrier_callback(struct rcu_head *notused) 83static void rcu_barrier_callback(struct rcu_head *notused)
@@ -99,19 +89,30 @@ static void rcu_barrier_callback(struct rcu_head *notused)
99/* 89/*
100 * Called with preemption disabled, and from cross-cpu IRQ context. 90 * Called with preemption disabled, and from cross-cpu IRQ context.
101 */ 91 */
102static void rcu_barrier_func(void *notused) 92static void rcu_barrier_func(void *type)
103{ 93{
104 int cpu = smp_processor_id(); 94 int cpu = smp_processor_id();
105 struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu); 95 struct rcu_head *head = &per_cpu(rcu_barrier_head, cpu);
106 96
107 atomic_inc(&rcu_barrier_cpu_count); 97 atomic_inc(&rcu_barrier_cpu_count);
108 call_rcu(head, rcu_barrier_callback); 98 switch ((enum rcu_barrier)type) {
99 case RCU_BARRIER_STD:
100 call_rcu(head, rcu_barrier_callback);
101 break;
102 case RCU_BARRIER_BH:
103 call_rcu_bh(head, rcu_barrier_callback);
104 break;
105 case RCU_BARRIER_SCHED:
106 call_rcu_sched(head, rcu_barrier_callback);
107 break;
108 }
109} 109}
110 110
111/** 111/*
112 * rcu_barrier - Wait until all the in-flight RCUs are complete. 112 * Orchestrate the specified type of RCU barrier, waiting for all
113 * RCU callbacks of the specified type to complete.
113 */ 114 */
114void rcu_barrier(void) 115static void _rcu_barrier(enum rcu_barrier type)
115{ 116{
116 BUG_ON(in_interrupt()); 117 BUG_ON(in_interrupt());
117 /* Take cpucontrol mutex to protect against CPU hotplug */ 118 /* Take cpucontrol mutex to protect against CPU hotplug */
@@ -127,13 +128,39 @@ void rcu_barrier(void)
127 * until all the callbacks are queued. 128 * until all the callbacks are queued.
128 */ 129 */
129 rcu_read_lock(); 130 rcu_read_lock();
130 on_each_cpu(rcu_barrier_func, NULL, 0, 1); 131 on_each_cpu(rcu_barrier_func, (void *)type, 1);
131 rcu_read_unlock(); 132 rcu_read_unlock();
132 wait_for_completion(&rcu_barrier_completion); 133 wait_for_completion(&rcu_barrier_completion);
133 mutex_unlock(&rcu_barrier_mutex); 134 mutex_unlock(&rcu_barrier_mutex);
134} 135}
136
137/**
138 * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete.
139 */
140void rcu_barrier(void)
141{
142 _rcu_barrier(RCU_BARRIER_STD);
143}
135EXPORT_SYMBOL_GPL(rcu_barrier); 144EXPORT_SYMBOL_GPL(rcu_barrier);
136 145
146/**
147 * rcu_barrier_bh - Wait until all in-flight call_rcu_bh() callbacks complete.
148 */
149void rcu_barrier_bh(void)
150{
151 _rcu_barrier(RCU_BARRIER_BH);
152}
153EXPORT_SYMBOL_GPL(rcu_barrier_bh);
154
155/**
156 * rcu_barrier_sched - Wait for in-flight call_rcu_sched() callbacks.
157 */
158void rcu_barrier_sched(void)
159{
160 _rcu_barrier(RCU_BARRIER_SCHED);
161}
162EXPORT_SYMBOL_GPL(rcu_barrier_sched);
163
137void __init rcu_init(void) 164void __init rcu_init(void)
138{ 165{
139 __rcu_init(); 166 __rcu_init();
diff --git a/kernel/rcupreempt.c b/kernel/rcupreempt.c
index 9bf44566445..6f62b77d93c 100644
--- a/kernel/rcupreempt.c
+++ b/kernel/rcupreempt.c
@@ -46,11 +46,11 @@
46#include <asm/atomic.h> 46#include <asm/atomic.h>
47#include <linux/bitops.h> 47#include <linux/bitops.h>
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/kthread.h>
49#include <linux/completion.h> 50#include <linux/completion.h>
50#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
51#include <linux/percpu.h> 52#include <linux/percpu.h>
52#include <linux/notifier.h> 53#include <linux/notifier.h>
53#include <linux/rcupdate.h>
54#include <linux/cpu.h> 54#include <linux/cpu.h>
55#include <linux/random.h> 55#include <linux/random.h>
56#include <linux/delay.h> 56#include <linux/delay.h>
@@ -82,14 +82,18 @@ struct rcu_data {
82 spinlock_t lock; /* Protect rcu_data fields. */ 82 spinlock_t lock; /* Protect rcu_data fields. */
83 long completed; /* Number of last completed batch. */ 83 long completed; /* Number of last completed batch. */
84 int waitlistcount; 84 int waitlistcount;
85 struct tasklet_struct rcu_tasklet;
86 struct rcu_head *nextlist; 85 struct rcu_head *nextlist;
87 struct rcu_head **nexttail; 86 struct rcu_head **nexttail;
88 struct rcu_head *waitlist[GP_STAGES]; 87 struct rcu_head *waitlist[GP_STAGES];
89 struct rcu_head **waittail[GP_STAGES]; 88 struct rcu_head **waittail[GP_STAGES];
90 struct rcu_head *donelist; 89 struct rcu_head *donelist; /* from waitlist & waitschedlist */
91 struct rcu_head **donetail; 90 struct rcu_head **donetail;
92 long rcu_flipctr[2]; 91 long rcu_flipctr[2];
92 struct rcu_head *nextschedlist;
93 struct rcu_head **nextschedtail;
94 struct rcu_head *waitschedlist;
95 struct rcu_head **waitschedtail;
96 int rcu_sched_sleeping;
93#ifdef CONFIG_RCU_TRACE 97#ifdef CONFIG_RCU_TRACE
94 struct rcupreempt_trace trace; 98 struct rcupreempt_trace trace;
95#endif /* #ifdef CONFIG_RCU_TRACE */ 99#endif /* #ifdef CONFIG_RCU_TRACE */
@@ -131,11 +135,24 @@ enum rcu_try_flip_states {
131 rcu_try_flip_waitmb_state, 135 rcu_try_flip_waitmb_state,
132}; 136};
133 137
138/*
139 * States for rcu_ctrlblk.rcu_sched_sleep.
140 */
141
142enum rcu_sched_sleep_states {
143 rcu_sched_not_sleeping, /* Not sleeping, callbacks need GP. */
144 rcu_sched_sleep_prep, /* Thinking of sleeping, rechecking. */
145 rcu_sched_sleeping, /* Sleeping, awaken if GP needed. */
146};
147
134struct rcu_ctrlblk { 148struct rcu_ctrlblk {
135 spinlock_t fliplock; /* Protect state-machine transitions. */ 149 spinlock_t fliplock; /* Protect state-machine transitions. */
136 long completed; /* Number of last completed batch. */ 150 long completed; /* Number of last completed batch. */
137 enum rcu_try_flip_states rcu_try_flip_state; /* The current state of 151 enum rcu_try_flip_states rcu_try_flip_state; /* The current state of
138 the rcu state machine */ 152 the rcu state machine */
153 spinlock_t schedlock; /* Protect rcu_sched sleep state. */
154 enum rcu_sched_sleep_states sched_sleep; /* rcu_sched state. */
155 wait_queue_head_t sched_wq; /* Place for rcu_sched to sleep. */
139}; 156};
140 157
141static DEFINE_PER_CPU(struct rcu_data, rcu_data); 158static DEFINE_PER_CPU(struct rcu_data, rcu_data);
@@ -143,8 +160,12 @@ static struct rcu_ctrlblk rcu_ctrlblk = {
143 .fliplock = __SPIN_LOCK_UNLOCKED(rcu_ctrlblk.fliplock), 160 .fliplock = __SPIN_LOCK_UNLOCKED(rcu_ctrlblk.fliplock),
144 .completed = 0, 161 .completed = 0,
145 .rcu_try_flip_state = rcu_try_flip_idle_state, 162 .rcu_try_flip_state = rcu_try_flip_idle_state,
163 .schedlock = __SPIN_LOCK_UNLOCKED(rcu_ctrlblk.schedlock),
164 .sched_sleep = rcu_sched_not_sleeping,
165 .sched_wq = __WAIT_QUEUE_HEAD_INITIALIZER(rcu_ctrlblk.sched_wq),
146}; 166};
147 167
168static struct task_struct *rcu_sched_grace_period_task;
148 169
149#ifdef CONFIG_RCU_TRACE 170#ifdef CONFIG_RCU_TRACE
150static char *rcu_try_flip_state_names[] = 171static char *rcu_try_flip_state_names[] =
@@ -207,6 +228,8 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(enum rcu_mb_flag_values, rcu_mb_flag)
207 */ 228 */
208#define RCU_TRACE_RDP(f, rdp) RCU_TRACE(f, &((rdp)->trace)); 229#define RCU_TRACE_RDP(f, rdp) RCU_TRACE(f, &((rdp)->trace));
209 230
231#define RCU_SCHED_BATCH_TIME (HZ / 50)
232
210/* 233/*
211 * Return the number of RCU batches processed thus far. Useful 234 * Return the number of RCU batches processed thus far. Useful
212 * for debug and statistics. 235 * for debug and statistics.
@@ -411,32 +434,34 @@ static void __rcu_advance_callbacks(struct rcu_data *rdp)
411 } 434 }
412} 435}
413 436
414#ifdef CONFIG_NO_HZ 437DEFINE_PER_CPU_SHARED_ALIGNED(struct rcu_dyntick_sched, rcu_dyntick_sched) = {
438 .dynticks = 1,
439};
415 440
416DEFINE_PER_CPU(long, dynticks_progress_counter) = 1; 441#ifdef CONFIG_NO_HZ
417static DEFINE_PER_CPU(long, rcu_dyntick_snapshot);
418static DEFINE_PER_CPU(int, rcu_update_flag); 442static DEFINE_PER_CPU(int, rcu_update_flag);
419 443
420/** 444/**
421 * rcu_irq_enter - Called from Hard irq handlers and NMI/SMI. 445 * rcu_irq_enter - Called from Hard irq handlers and NMI/SMI.
422 * 446 *
423 * If the CPU was idle with dynamic ticks active, this updates the 447 * If the CPU was idle with dynamic ticks active, this updates the
424 * dynticks_progress_counter to let the RCU handling know that the 448 * rcu_dyntick_sched.dynticks to let the RCU handling know that the
425 * CPU is active. 449 * CPU is active.
426 */ 450 */
427void rcu_irq_enter(void) 451void rcu_irq_enter(void)
428{ 452{
429 int cpu = smp_processor_id(); 453 int cpu = smp_processor_id();
454 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
430 455
431 if (per_cpu(rcu_update_flag, cpu)) 456 if (per_cpu(rcu_update_flag, cpu))
432 per_cpu(rcu_update_flag, cpu)++; 457 per_cpu(rcu_update_flag, cpu)++;
433 458
434 /* 459 /*
435 * Only update if we are coming from a stopped ticks mode 460 * Only update if we are coming from a stopped ticks mode
436 * (dynticks_progress_counter is even). 461 * (rcu_dyntick_sched.dynticks is even).
437 */ 462 */
438 if (!in_interrupt() && 463 if (!in_interrupt() &&
439 (per_cpu(dynticks_progress_counter, cpu) & 0x1) == 0) { 464 (rdssp->dynticks & 0x1) == 0) {
440 /* 465 /*
441 * The following might seem like we could have a race 466 * The following might seem like we could have a race
442 * with NMI/SMIs. But this really isn't a problem. 467 * with NMI/SMIs. But this really isn't a problem.
@@ -459,12 +484,12 @@ void rcu_irq_enter(void)
459 * RCU read-side critical sections on this CPU would 484 * RCU read-side critical sections on this CPU would
460 * have already completed. 485 * have already completed.
461 */ 486 */
462 per_cpu(dynticks_progress_counter, cpu)++; 487 rdssp->dynticks++;
463 /* 488 /*
464 * The following memory barrier ensures that any 489 * The following memory barrier ensures that any
465 * rcu_read_lock() primitives in the irq handler 490 * rcu_read_lock() primitives in the irq handler
466 * are seen by other CPUs to follow the above 491 * are seen by other CPUs to follow the above
467 * increment to dynticks_progress_counter. This is 492 * increment to rcu_dyntick_sched.dynticks. This is
468 * required in order for other CPUs to correctly 493 * required in order for other CPUs to correctly
469 * determine when it is safe to advance the RCU 494 * determine when it is safe to advance the RCU
470 * grace-period state machine. 495 * grace-period state machine.
@@ -472,7 +497,7 @@ void rcu_irq_enter(void)
472 smp_mb(); /* see above block comment. */ 497 smp_mb(); /* see above block comment. */
473 /* 498 /*
474 * Since we can't determine the dynamic tick mode from 499 * Since we can't determine the dynamic tick mode from
475 * the dynticks_progress_counter after this routine, 500 * the rcu_dyntick_sched.dynticks after this routine,
476 * we use a second flag to acknowledge that we came 501 * we use a second flag to acknowledge that we came
477 * from an idle state with ticks stopped. 502 * from an idle state with ticks stopped.
478 */ 503 */
@@ -480,7 +505,7 @@ void rcu_irq_enter(void)
480 /* 505 /*
481 * If we take an NMI/SMI now, they will also increment 506 * If we take an NMI/SMI now, they will also increment
482 * the rcu_update_flag, and will not update the 507 * the rcu_update_flag, and will not update the
483 * dynticks_progress_counter on exit. That is for 508 * rcu_dyntick_sched.dynticks on exit. That is for
484 * this IRQ to do. 509 * this IRQ to do.
485 */ 510 */
486 } 511 }
@@ -490,12 +515,13 @@ void rcu_irq_enter(void)
490 * rcu_irq_exit - Called from exiting Hard irq context. 515 * rcu_irq_exit - Called from exiting Hard irq context.
491 * 516 *
492 * If the CPU was idle with dynamic ticks active, update the 517 * If the CPU was idle with dynamic ticks active, update the
493 * dynticks_progress_counter to put let the RCU handling be 518 * rcu_dyntick_sched.dynticks to put let the RCU handling be
494 * aware that the CPU is going back to idle with no ticks. 519 * aware that the CPU is going back to idle with no ticks.
495 */ 520 */
496void rcu_irq_exit(void) 521void rcu_irq_exit(void)
497{ 522{
498 int cpu = smp_processor_id(); 523 int cpu = smp_processor_id();
524 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
499 525
500 /* 526 /*
501 * rcu_update_flag is set if we interrupted the CPU 527 * rcu_update_flag is set if we interrupted the CPU
@@ -503,7 +529,7 @@ void rcu_irq_exit(void)
503 * Once this occurs, we keep track of interrupt nesting 529 * Once this occurs, we keep track of interrupt nesting
504 * because a NMI/SMI could also come in, and we still 530 * because a NMI/SMI could also come in, and we still
505 * only want the IRQ that started the increment of the 531 * only want the IRQ that started the increment of the
506 * dynticks_progress_counter to be the one that modifies 532 * rcu_dyntick_sched.dynticks to be the one that modifies
507 * it on exit. 533 * it on exit.
508 */ 534 */
509 if (per_cpu(rcu_update_flag, cpu)) { 535 if (per_cpu(rcu_update_flag, cpu)) {
@@ -515,28 +541,29 @@ void rcu_irq_exit(void)
515 541
516 /* 542 /*
517 * If an NMI/SMI happens now we are still 543 * If an NMI/SMI happens now we are still
518 * protected by the dynticks_progress_counter being odd. 544 * protected by the rcu_dyntick_sched.dynticks being odd.
519 */ 545 */
520 546
521 /* 547 /*
522 * The following memory barrier ensures that any 548 * The following memory barrier ensures that any
523 * rcu_read_unlock() primitives in the irq handler 549 * rcu_read_unlock() primitives in the irq handler
524 * are seen by other CPUs to preceed the following 550 * are seen by other CPUs to preceed the following
525 * increment to dynticks_progress_counter. This 551 * increment to rcu_dyntick_sched.dynticks. This
526 * is required in order for other CPUs to determine 552 * is required in order for other CPUs to determine
527 * when it is safe to advance the RCU grace-period 553 * when it is safe to advance the RCU grace-period
528 * state machine. 554 * state machine.
529 */ 555 */
530 smp_mb(); /* see above block comment. */ 556 smp_mb(); /* see above block comment. */
531 per_cpu(dynticks_progress_counter, cpu)++; 557 rdssp->dynticks++;
532 WARN_ON(per_cpu(dynticks_progress_counter, cpu) & 0x1); 558 WARN_ON(rdssp->dynticks & 0x1);
533 } 559 }
534} 560}
535 561
536static void dyntick_save_progress_counter(int cpu) 562static void dyntick_save_progress_counter(int cpu)
537{ 563{
538 per_cpu(rcu_dyntick_snapshot, cpu) = 564 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
539 per_cpu(dynticks_progress_counter, cpu); 565
566 rdssp->dynticks_snap = rdssp->dynticks;
540} 567}
541 568
542static inline int 569static inline int
@@ -544,9 +571,10 @@ rcu_try_flip_waitack_needed(int cpu)
544{ 571{
545 long curr; 572 long curr;
546 long snap; 573 long snap;
574 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
547 575
548 curr = per_cpu(dynticks_progress_counter, cpu); 576 curr = rdssp->dynticks;
549 snap = per_cpu(rcu_dyntick_snapshot, cpu); 577 snap = rdssp->dynticks_snap;
550 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */ 578 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */
551 579
552 /* 580 /*
@@ -567,7 +595,7 @@ rcu_try_flip_waitack_needed(int cpu)
567 * that this CPU already acknowledged the counter. 595 * that this CPU already acknowledged the counter.
568 */ 596 */
569 597
570 if ((curr - snap) > 2 || (snap & 0x1) == 0) 598 if ((curr - snap) > 2 || (curr & 0x1) == 0)
571 return 0; 599 return 0;
572 600
573 /* We need this CPU to explicitly acknowledge the counter flip. */ 601 /* We need this CPU to explicitly acknowledge the counter flip. */
@@ -580,9 +608,10 @@ rcu_try_flip_waitmb_needed(int cpu)
580{ 608{
581 long curr; 609 long curr;
582 long snap; 610 long snap;
611 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
583 612
584 curr = per_cpu(dynticks_progress_counter, cpu); 613 curr = rdssp->dynticks;
585 snap = per_cpu(rcu_dyntick_snapshot, cpu); 614 snap = rdssp->dynticks_snap;
586 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */ 615 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */
587 616
588 /* 617 /*
@@ -609,14 +638,86 @@ rcu_try_flip_waitmb_needed(int cpu)
609 return 1; 638 return 1;
610} 639}
611 640
641static void dyntick_save_progress_counter_sched(int cpu)
642{
643 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
644
645 rdssp->sched_dynticks_snap = rdssp->dynticks;
646}
647
648static int rcu_qsctr_inc_needed_dyntick(int cpu)
649{
650 long curr;
651 long snap;
652 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
653
654 curr = rdssp->dynticks;
655 snap = rdssp->sched_dynticks_snap;
656 smp_mb(); /* force ordering with cpu entering/leaving dynticks. */
657
658 /*
659 * If the CPU remained in dynticks mode for the entire time
660 * and didn't take any interrupts, NMIs, SMIs, or whatever,
661 * then it cannot be in the middle of an rcu_read_lock(), so
662 * the next rcu_read_lock() it executes must use the new value
663 * of the counter. Therefore, this CPU has been in a quiescent
664 * state the entire time, and we don't need to wait for it.
665 */
666
667 if ((curr == snap) && ((curr & 0x1) == 0))
668 return 0;
669
670 /*
671 * If the CPU passed through or entered a dynticks idle phase with
672 * no active irq handlers, then, as above, this CPU has already
673 * passed through a quiescent state.
674 */
675
676 if ((curr - snap) > 2 || (snap & 0x1) == 0)
677 return 0;
678
679 /* We need this CPU to go through a quiescent state. */
680
681 return 1;
682}
683
612#else /* !CONFIG_NO_HZ */ 684#else /* !CONFIG_NO_HZ */
613 685
614# define dyntick_save_progress_counter(cpu) do { } while (0) 686# define dyntick_save_progress_counter(cpu) do { } while (0)
615# define rcu_try_flip_waitack_needed(cpu) (1) 687# define rcu_try_flip_waitack_needed(cpu) (1)
616# define rcu_try_flip_waitmb_needed(cpu) (1) 688# define rcu_try_flip_waitmb_needed(cpu) (1)
689
690# define dyntick_save_progress_counter_sched(cpu) do { } while (0)
691# define rcu_qsctr_inc_needed_dyntick(cpu) (1)
617 692
618#endif /* CONFIG_NO_HZ */ 693#endif /* CONFIG_NO_HZ */
619 694
695static void save_qsctr_sched(int cpu)
696{
697 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
698
699 rdssp->sched_qs_snap = rdssp->sched_qs;
700}
701
702static inline int rcu_qsctr_inc_needed(int cpu)
703{
704 struct rcu_dyntick_sched *rdssp = &per_cpu(rcu_dyntick_sched, cpu);
705
706 /*
707 * If there has been a quiescent state, no more need to wait
708 * on this CPU.
709 */
710
711 if (rdssp->sched_qs != rdssp->sched_qs_snap) {
712 smp_mb(); /* force ordering with cpu entering schedule(). */
713 return 0;
714 }
715
716 /* We need this CPU to go through a quiescent state. */
717
718 return 1;
719}
720
620/* 721/*
621 * Get here when RCU is idle. Decide whether we need to 722 * Get here when RCU is idle. Decide whether we need to
622 * move out of idle state, and return non-zero if so. 723 * move out of idle state, and return non-zero if so.
@@ -819,6 +920,26 @@ void rcu_check_callbacks(int cpu, int user)
819 unsigned long flags; 920 unsigned long flags;
820 struct rcu_data *rdp = RCU_DATA_CPU(cpu); 921 struct rcu_data *rdp = RCU_DATA_CPU(cpu);
821 922
923 /*
924 * If this CPU took its interrupt from user mode or from the
925 * idle loop, and this is not a nested interrupt, then
926 * this CPU has to have exited all prior preept-disable
927 * sections of code. So increment the counter to note this.
928 *
929 * The memory barrier is needed to handle the case where
930 * writes from a preempt-disable section of code get reordered
931 * into schedule() by this CPU's write buffer. So the memory
932 * barrier makes sure that the rcu_qsctr_inc() is seen by other
933 * CPUs to happen after any such write.
934 */
935
936 if (user ||
937 (idle_cpu(cpu) && !in_softirq() &&
938 hardirq_count() <= (1 << HARDIRQ_SHIFT))) {
939 smp_mb(); /* Guard against aggressive schedule(). */
940 rcu_qsctr_inc(cpu);
941 }
942
822 rcu_check_mb(cpu); 943 rcu_check_mb(cpu);
823 if (rcu_ctrlblk.completed == rdp->completed) 944 if (rcu_ctrlblk.completed == rdp->completed)
824 rcu_try_flip(); 945 rcu_try_flip();
@@ -869,6 +990,8 @@ void rcu_offline_cpu(int cpu)
869 struct rcu_head *list = NULL; 990 struct rcu_head *list = NULL;
870 unsigned long flags; 991 unsigned long flags;
871 struct rcu_data *rdp = RCU_DATA_CPU(cpu); 992 struct rcu_data *rdp = RCU_DATA_CPU(cpu);
993 struct rcu_head *schedlist = NULL;
994 struct rcu_head **schedtail = &schedlist;
872 struct rcu_head **tail = &list; 995 struct rcu_head **tail = &list;
873 996
874 /* 997 /*
@@ -882,6 +1005,11 @@ void rcu_offline_cpu(int cpu)
882 rcu_offline_cpu_enqueue(rdp->waitlist[i], rdp->waittail[i], 1005 rcu_offline_cpu_enqueue(rdp->waitlist[i], rdp->waittail[i],
883 list, tail); 1006 list, tail);
884 rcu_offline_cpu_enqueue(rdp->nextlist, rdp->nexttail, list, tail); 1007 rcu_offline_cpu_enqueue(rdp->nextlist, rdp->nexttail, list, tail);
1008 rcu_offline_cpu_enqueue(rdp->waitschedlist, rdp->waitschedtail,
1009 schedlist, schedtail);
1010 rcu_offline_cpu_enqueue(rdp->nextschedlist, rdp->nextschedtail,
1011 schedlist, schedtail);
1012 rdp->rcu_sched_sleeping = 0;
885 spin_unlock_irqrestore(&rdp->lock, flags); 1013 spin_unlock_irqrestore(&rdp->lock, flags);
886 rdp->waitlistcount = 0; 1014 rdp->waitlistcount = 0;
887 1015
@@ -916,12 +1044,15 @@ void rcu_offline_cpu(int cpu)
916 * fix. 1044 * fix.
917 */ 1045 */
918 1046
919 local_irq_save(flags); 1047 local_irq_save(flags); /* disable preempt till we know what lock. */
920 rdp = RCU_DATA_ME(); 1048 rdp = RCU_DATA_ME();
921 spin_lock(&rdp->lock); 1049 spin_lock(&rdp->lock);
922 *rdp->nexttail = list; 1050 *rdp->nexttail = list;
923 if (list) 1051 if (list)
924 rdp->nexttail = tail; 1052 rdp->nexttail = tail;
1053 *rdp->nextschedtail = schedlist;
1054 if (schedlist)
1055 rdp->nextschedtail = schedtail;
925 spin_unlock_irqrestore(&rdp->lock, flags); 1056 spin_unlock_irqrestore(&rdp->lock, flags);
926} 1057}
927 1058
@@ -936,10 +1067,25 @@ void rcu_offline_cpu(int cpu)
936void __cpuinit rcu_online_cpu(int cpu) 1067void __cpuinit rcu_online_cpu(int cpu)
937{ 1068{
938 unsigned long flags; 1069 unsigned long flags;
1070 struct rcu_data *rdp;
939 1071
940 spin_lock_irqsave(&rcu_ctrlblk.fliplock, flags); 1072 spin_lock_irqsave(&rcu_ctrlblk.fliplock, flags);
941 cpu_set(cpu, rcu_cpu_online_map); 1073 cpu_set(cpu, rcu_cpu_online_map);
942 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags); 1074 spin_unlock_irqrestore(&rcu_ctrlblk.fliplock, flags);
1075
1076 /*
1077 * The rcu_sched grace-period processing might have bypassed
1078 * this CPU, given that it was not in the rcu_cpu_online_map
1079 * when the grace-period scan started. This means that the
1080 * grace-period task might sleep. So make sure that if this
1081 * should happen, the first callback posted to this CPU will
1082 * wake up the grace-period task if need be.
1083 */
1084
1085 rdp = RCU_DATA_CPU(cpu);
1086 spin_lock_irqsave(&rdp->lock, flags);
1087 rdp->rcu_sched_sleeping = 1;
1088 spin_unlock_irqrestore(&rdp->lock, flags);
943} 1089}
944 1090
945static void rcu_process_callbacks(struct softirq_action *unused) 1091static void rcu_process_callbacks(struct softirq_action *unused)
@@ -982,31 +1128,196 @@ void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
982 *rdp->nexttail = head; 1128 *rdp->nexttail = head;
983 rdp->nexttail = &head->next; 1129 rdp->nexttail = &head->next;
984 RCU_TRACE_RDP(rcupreempt_trace_next_add, rdp); 1130 RCU_TRACE_RDP(rcupreempt_trace_next_add, rdp);
985 spin_unlock(&rdp->lock); 1131 spin_unlock_irqrestore(&rdp->lock, flags);
986 local_irq_restore(flags);
987} 1132}
988EXPORT_SYMBOL_GPL(call_rcu); 1133EXPORT_SYMBOL_GPL(call_rcu);
989 1134
1135void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu))
1136{
1137 unsigned long flags;
1138 struct rcu_data *rdp;
1139 int wake_gp = 0;
1140
1141 head->func = func;
1142 head->next = NULL;
1143 local_irq_save(flags);
1144 rdp = RCU_DATA_ME();
1145 spin_lock(&rdp->lock);
1146 *rdp->nextschedtail = head;
1147 rdp->nextschedtail = &head->next;
1148 if (rdp->rcu_sched_sleeping) {
1149
1150 /* Grace-period processing might be sleeping... */
1151
1152 rdp->rcu_sched_sleeping = 0;
1153 wake_gp = 1;
1154 }
1155 spin_unlock_irqrestore(&rdp->lock, flags);
1156 if (wake_gp) {
1157
1158 /* Wake up grace-period processing, unless someone beat us. */
1159
1160 spin_lock_irqsave(&rcu_ctrlblk.schedlock, flags);
1161 if (rcu_ctrlblk.sched_sleep != rcu_sched_sleeping)
1162 wake_gp = 0;
1163 rcu_ctrlblk.sched_sleep = rcu_sched_not_sleeping;
1164 spin_unlock_irqrestore(&rcu_ctrlblk.schedlock, flags);
1165 if (wake_gp)
1166 wake_up_interruptible(&rcu_ctrlblk.sched_wq);
1167 }
1168}
1169EXPORT_SYMBOL_GPL(call_rcu_sched);
1170
990/* 1171/*
991 * Wait until all currently running preempt_disable() code segments 1172 * Wait until all currently running preempt_disable() code segments
992 * (including hardware-irq-disable segments) complete. Note that 1173 * (including hardware-irq-disable segments) complete. Note that
993 * in -rt this does -not- necessarily result in all currently executing 1174 * in -rt this does -not- necessarily result in all currently executing
994 * interrupt -handlers- having completed. 1175 * interrupt -handlers- having completed.
995 */ 1176 */
996void __synchronize_sched(void) 1177synchronize_rcu_xxx(__synchronize_sched, call_rcu_sched)
1178EXPORT_SYMBOL_GPL(__synchronize_sched);
1179
1180/*
1181 * kthread function that manages call_rcu_sched grace periods.
1182 */
1183static int rcu_sched_grace_period(void *arg)
997{ 1184{
998 cpumask_t oldmask; 1185 int couldsleep; /* might sleep after current pass. */
1186 int couldsleepnext = 0; /* might sleep after next pass. */
999 int cpu; 1187 int cpu;
1188 unsigned long flags;
1189 struct rcu_data *rdp;
1190 int ret;
1000 1191
1001 if (sched_getaffinity(0, &oldmask) < 0) 1192 /*
1002 oldmask = cpu_possible_map; 1193 * Each pass through the following loop handles one
1003 for_each_online_cpu(cpu) { 1194 * rcu_sched grace period cycle.
1004 sched_setaffinity(0, &cpumask_of_cpu(cpu)); 1195 */
1005 schedule(); 1196 do {
1006 } 1197 /* Save each CPU's current state. */
1007 sched_setaffinity(0, &oldmask); 1198
1199 for_each_online_cpu(cpu) {
1200 dyntick_save_progress_counter_sched(cpu);
1201 save_qsctr_sched(cpu);
1202 }
1203
1204 /*
1205 * Sleep for about an RCU grace-period's worth to
1206 * allow better batching and to consume less CPU.
1207 */
1208 schedule_timeout_interruptible(RCU_SCHED_BATCH_TIME);
1209
1210 /*
1211 * If there was nothing to do last time, prepare to
1212 * sleep at the end of the current grace period cycle.
1213 */
1214 couldsleep = couldsleepnext;
1215 couldsleepnext = 1;
1216 if (couldsleep) {
1217 spin_lock_irqsave(&rcu_ctrlblk.schedlock, flags);
1218 rcu_ctrlblk.sched_sleep = rcu_sched_sleep_prep;
1219 spin_unlock_irqrestore(&rcu_ctrlblk.schedlock, flags);
1220 }
1221
1222 /*
1223 * Wait on each CPU in turn to have either visited
1224 * a quiescent state or been in dynticks-idle mode.
1225 */
1226 for_each_online_cpu(cpu) {
1227 while (rcu_qsctr_inc_needed(cpu) &&
1228 rcu_qsctr_inc_needed_dyntick(cpu)) {
1229 /* resched_cpu(cpu); @@@ */
1230 schedule_timeout_interruptible(1);
1231 }
1232 }
1233
1234 /* Advance callbacks for each CPU. */
1235
1236 for_each_online_cpu(cpu) {
1237
1238 rdp = RCU_DATA_CPU(cpu);
1239 spin_lock_irqsave(&rdp->lock, flags);
1240
1241 /*
1242 * We are running on this CPU irq-disabled, so no
1243 * CPU can go offline until we re-enable irqs.
1244 * The current CPU might have already gone
1245 * offline (between the for_each_offline_cpu and
1246 * the spin_lock_irqsave), but in that case all its
1247 * callback lists will be empty, so no harm done.
1248 *
1249 * Advance the callbacks! We share normal RCU's
1250 * donelist, since callbacks are invoked the
1251 * same way in either case.
1252 */
1253 if (rdp->waitschedlist != NULL) {
1254 *rdp->donetail = rdp->waitschedlist;
1255 rdp->donetail = rdp->waitschedtail;
1256
1257 /*
1258 * Next rcu_check_callbacks() will
1259 * do the required raise_softirq().
1260 */
1261 }
1262 if (rdp->nextschedlist != NULL) {
1263 rdp->waitschedlist = rdp->nextschedlist;
1264 rdp->waitschedtail = rdp->nextschedtail;
1265 couldsleep = 0;
1266 couldsleepnext = 0;
1267 } else {
1268 rdp->waitschedlist = NULL;
1269 rdp->waitschedtail = &rdp->waitschedlist;
1270 }
1271 rdp->nextschedlist = NULL;
1272 rdp->nextschedtail = &rdp->nextschedlist;
1273
1274 /* Mark sleep intention. */
1275
1276 rdp->rcu_sched_sleeping = couldsleep;
1277
1278 spin_unlock_irqrestore(&rdp->lock, flags);
1279 }
1280
1281 /* If we saw callbacks on the last scan, go deal with them. */
1282
1283 if (!couldsleep)
1284 continue;
1285
1286 /* Attempt to block... */
1287
1288 spin_lock_irqsave(&rcu_ctrlblk.schedlock, flags);
1289 if (rcu_ctrlblk.sched_sleep != rcu_sched_sleep_prep) {
1290
1291 /*
1292 * Someone posted a callback after we scanned.
1293 * Go take care of it.
1294 */
1295 spin_unlock_irqrestore(&rcu_ctrlblk.schedlock, flags);
1296 couldsleepnext = 0;
1297 continue;
1298 }
1299
1300 /* Block until the next person posts a callback. */
1301
1302 rcu_ctrlblk.sched_sleep = rcu_sched_sleeping;
1303 spin_unlock_irqrestore(&rcu_ctrlblk.schedlock, flags);
1304 ret = 0;
1305 __wait_event_interruptible(rcu_ctrlblk.sched_wq,
1306 rcu_ctrlblk.sched_sleep != rcu_sched_sleeping,
1307 ret);
1308
1309 /*
1310 * Signals would prevent us from sleeping, and we cannot
1311 * do much with them in any case. So flush them.
1312 */
1313 if (ret)
1314 flush_signals(current);
1315 couldsleepnext = 0;
1316
1317 } while (!kthread_should_stop());
1318
1319 return (0);
1008} 1320}
1009EXPORT_SYMBOL_GPL(__synchronize_sched);
1010 1321
1011/* 1322/*
1012 * Check to see if any future RCU-related work will need to be done 1323 * Check to see if any future RCU-related work will need to be done
@@ -1023,7 +1334,9 @@ int rcu_needs_cpu(int cpu)
1023 1334
1024 return (rdp->donelist != NULL || 1335 return (rdp->donelist != NULL ||
1025 !!rdp->waitlistcount || 1336 !!rdp->waitlistcount ||
1026 rdp->nextlist != NULL); 1337 rdp->nextlist != NULL ||
1338 rdp->nextschedlist != NULL ||
1339 rdp->waitschedlist != NULL);
1027} 1340}
1028 1341
1029int rcu_pending(int cpu) 1342int rcu_pending(int cpu)
@@ -1034,7 +1347,9 @@ int rcu_pending(int cpu)
1034 1347
1035 if (rdp->donelist != NULL || 1348 if (rdp->donelist != NULL ||
1036 !!rdp->waitlistcount || 1349 !!rdp->waitlistcount ||
1037 rdp->nextlist != NULL) 1350 rdp->nextlist != NULL ||
1351 rdp->nextschedlist != NULL ||
1352 rdp->waitschedlist != NULL)
1038 return 1; 1353 return 1;
1039 1354
1040 /* The RCU core needs an acknowledgement from this CPU. */ 1355 /* The RCU core needs an acknowledgement from this CPU. */
@@ -1101,6 +1416,11 @@ void __init __rcu_init(void)
1101 rdp->donetail = &rdp->donelist; 1416 rdp->donetail = &rdp->donelist;
1102 rdp->rcu_flipctr[0] = 0; 1417 rdp->rcu_flipctr[0] = 0;
1103 rdp->rcu_flipctr[1] = 0; 1418 rdp->rcu_flipctr[1] = 0;
1419 rdp->nextschedlist = NULL;
1420 rdp->nextschedtail = &rdp->nextschedlist;
1421 rdp->waitschedlist = NULL;
1422 rdp->waitschedtail = &rdp->waitschedlist;
1423 rdp->rcu_sched_sleeping = 0;
1104 } 1424 }
1105 register_cpu_notifier(&rcu_nb); 1425 register_cpu_notifier(&rcu_nb);
1106 1426
@@ -1123,11 +1443,15 @@ void __init __rcu_init(void)
1123} 1443}
1124 1444
1125/* 1445/*
1126 * Deprecated, use synchronize_rcu() or synchronize_sched() instead. 1446 * Late-boot-time RCU initialization that must wait until after scheduler
1447 * has been initialized.
1127 */ 1448 */
1128void synchronize_kernel(void) 1449void __init rcu_init_sched(void)
1129{ 1450{
1130 synchronize_rcu(); 1451 rcu_sched_grace_period_task = kthread_run(rcu_sched_grace_period,
1452 NULL,
1453 "rcu_sched_grace_period");
1454 WARN_ON(IS_ERR(rcu_sched_grace_period_task));
1131} 1455}
1132 1456
1133#ifdef CONFIG_RCU_TRACE 1457#ifdef CONFIG_RCU_TRACE
diff --git a/kernel/rcupreempt_trace.c b/kernel/rcupreempt_trace.c
index 49ac4947af2..5edf82c34bb 100644
--- a/kernel/rcupreempt_trace.c
+++ b/kernel/rcupreempt_trace.c
@@ -38,7 +38,6 @@
38#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
39#include <linux/percpu.h> 39#include <linux/percpu.h>
40#include <linux/notifier.h> 40#include <linux/notifier.h>
41#include <linux/rcupdate.h>
42#include <linux/cpu.h> 41#include <linux/cpu.h>
43#include <linux/mutex.h> 42#include <linux/mutex.h>
44#include <linux/rcupreempt_trace.h> 43#include <linux/rcupreempt_trace.h>
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 33acc424667..90b5b123f7a 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -57,7 +57,9 @@ static int stat_interval; /* Interval between stats, in seconds. */
57 /* Defaults to "only at end of test". */ 57 /* Defaults to "only at end of test". */
58static int verbose; /* Print more debug info. */ 58static int verbose; /* Print more debug info. */
59static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */ 59static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
60static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/ 60static int shuffle_interval = 3; /* Interval between shuffles (in sec)*/
61static int stutter = 5; /* Start/stop testing interval (in sec) */
62static int irqreader = 1; /* RCU readers from irq (timers). */
61static char *torture_type = "rcu"; /* What RCU implementation to torture. */ 63static char *torture_type = "rcu"; /* What RCU implementation to torture. */
62 64
63module_param(nreaders, int, 0444); 65module_param(nreaders, int, 0444);
@@ -72,6 +74,10 @@ module_param(test_no_idle_hz, bool, 0444);
72MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs"); 74MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
73module_param(shuffle_interval, int, 0444); 75module_param(shuffle_interval, int, 0444);
74MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles"); 76MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
77module_param(stutter, int, 0444);
78MODULE_PARM_DESC(stutter, "Number of seconds to run/halt test");
79module_param(irqreader, int, 0444);
80MODULE_PARM_DESC(irqreader, "Allow RCU readers from irq handlers");
75module_param(torture_type, charp, 0444); 81module_param(torture_type, charp, 0444);
76MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)"); 82MODULE_PARM_DESC(torture_type, "Type of RCU to torture (rcu, rcu_bh, srcu)");
77 83
@@ -91,6 +97,7 @@ static struct task_struct **fakewriter_tasks;
91static struct task_struct **reader_tasks; 97static struct task_struct **reader_tasks;
92static struct task_struct *stats_task; 98static struct task_struct *stats_task;
93static struct task_struct *shuffler_task; 99static struct task_struct *shuffler_task;
100static struct task_struct *stutter_task;
94 101
95#define RCU_TORTURE_PIPE_LEN 10 102#define RCU_TORTURE_PIPE_LEN 10
96 103
@@ -117,8 +124,18 @@ static atomic_t n_rcu_torture_alloc_fail;
117static atomic_t n_rcu_torture_free; 124static atomic_t n_rcu_torture_free;
118static atomic_t n_rcu_torture_mberror; 125static atomic_t n_rcu_torture_mberror;
119static atomic_t n_rcu_torture_error; 126static atomic_t n_rcu_torture_error;
127static long n_rcu_torture_timers = 0;
120static struct list_head rcu_torture_removed; 128static struct list_head rcu_torture_removed;
121 129
130static int stutter_pause_test = 0;
131
132#if defined(MODULE) || defined(CONFIG_RCU_TORTURE_TEST_RUNNABLE)
133#define RCUTORTURE_RUNNABLE_INIT 1
134#else
135#define RCUTORTURE_RUNNABLE_INIT 0
136#endif
137int rcutorture_runnable = RCUTORTURE_RUNNABLE_INIT;
138
122/* 139/*
123 * Allocate an element from the rcu_tortures pool. 140 * Allocate an element from the rcu_tortures pool.
124 */ 141 */
@@ -179,6 +196,16 @@ rcu_random(struct rcu_random_state *rrsp)
179 return swahw32(rrsp->rrs_state); 196 return swahw32(rrsp->rrs_state);
180} 197}
181 198
199static void
200rcu_stutter_wait(void)
201{
202 while (stutter_pause_test || !rcutorture_runnable)
203 if (rcutorture_runnable)
204 schedule_timeout_interruptible(1);
205 else
206 schedule_timeout_interruptible(round_jiffies_relative(HZ));
207}
208
182/* 209/*
183 * Operations vector for selecting different types of tests. 210 * Operations vector for selecting different types of tests.
184 */ 211 */
@@ -192,7 +219,9 @@ struct rcu_torture_ops {
192 int (*completed)(void); 219 int (*completed)(void);
193 void (*deferredfree)(struct rcu_torture *p); 220 void (*deferredfree)(struct rcu_torture *p);
194 void (*sync)(void); 221 void (*sync)(void);
222 void (*cb_barrier)(void);
195 int (*stats)(char *page); 223 int (*stats)(char *page);
224 int irqcapable;
196 char *name; 225 char *name;
197}; 226};
198static struct rcu_torture_ops *cur_ops = NULL; 227static struct rcu_torture_ops *cur_ops = NULL;
@@ -265,7 +294,9 @@ static struct rcu_torture_ops rcu_ops = {
265 .completed = rcu_torture_completed, 294 .completed = rcu_torture_completed,
266 .deferredfree = rcu_torture_deferred_free, 295 .deferredfree = rcu_torture_deferred_free,
267 .sync = synchronize_rcu, 296 .sync = synchronize_rcu,
297 .cb_barrier = rcu_barrier,
268 .stats = NULL, 298 .stats = NULL,
299 .irqcapable = 1,
269 .name = "rcu" 300 .name = "rcu"
270}; 301};
271 302
@@ -304,7 +335,9 @@ static struct rcu_torture_ops rcu_sync_ops = {
304 .completed = rcu_torture_completed, 335 .completed = rcu_torture_completed,
305 .deferredfree = rcu_sync_torture_deferred_free, 336 .deferredfree = rcu_sync_torture_deferred_free,
306 .sync = synchronize_rcu, 337 .sync = synchronize_rcu,
338 .cb_barrier = NULL,
307 .stats = NULL, 339 .stats = NULL,
340 .irqcapable = 1,
308 .name = "rcu_sync" 341 .name = "rcu_sync"
309}; 342};
310 343
@@ -364,7 +397,9 @@ static struct rcu_torture_ops rcu_bh_ops = {
364 .completed = rcu_bh_torture_completed, 397 .completed = rcu_bh_torture_completed,
365 .deferredfree = rcu_bh_torture_deferred_free, 398 .deferredfree = rcu_bh_torture_deferred_free,
366 .sync = rcu_bh_torture_synchronize, 399 .sync = rcu_bh_torture_synchronize,
400 .cb_barrier = rcu_barrier_bh,
367 .stats = NULL, 401 .stats = NULL,
402 .irqcapable = 1,
368 .name = "rcu_bh" 403 .name = "rcu_bh"
369}; 404};
370 405
@@ -377,7 +412,9 @@ static struct rcu_torture_ops rcu_bh_sync_ops = {
377 .completed = rcu_bh_torture_completed, 412 .completed = rcu_bh_torture_completed,
378 .deferredfree = rcu_sync_torture_deferred_free, 413 .deferredfree = rcu_sync_torture_deferred_free,
379 .sync = rcu_bh_torture_synchronize, 414 .sync = rcu_bh_torture_synchronize,
415 .cb_barrier = NULL,
380 .stats = NULL, 416 .stats = NULL,
417 .irqcapable = 1,
381 .name = "rcu_bh_sync" 418 .name = "rcu_bh_sync"
382}; 419};
383 420
@@ -458,6 +495,7 @@ static struct rcu_torture_ops srcu_ops = {
458 .completed = srcu_torture_completed, 495 .completed = srcu_torture_completed,
459 .deferredfree = rcu_sync_torture_deferred_free, 496 .deferredfree = rcu_sync_torture_deferred_free,
460 .sync = srcu_torture_synchronize, 497 .sync = srcu_torture_synchronize,
498 .cb_barrier = NULL,
461 .stats = srcu_torture_stats, 499 .stats = srcu_torture_stats,
462 .name = "srcu" 500 .name = "srcu"
463}; 501};
@@ -482,6 +520,11 @@ static int sched_torture_completed(void)
482 return 0; 520 return 0;
483} 521}
484 522
523static void rcu_sched_torture_deferred_free(struct rcu_torture *p)
524{
525 call_rcu_sched(&p->rtort_rcu, rcu_torture_cb);
526}
527
485static void sched_torture_synchronize(void) 528static void sched_torture_synchronize(void)
486{ 529{
487 synchronize_sched(); 530 synchronize_sched();
@@ -494,12 +537,28 @@ static struct rcu_torture_ops sched_ops = {
494 .readdelay = rcu_read_delay, /* just reuse rcu's version. */ 537 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
495 .readunlock = sched_torture_read_unlock, 538 .readunlock = sched_torture_read_unlock,
496 .completed = sched_torture_completed, 539 .completed = sched_torture_completed,
497 .deferredfree = rcu_sync_torture_deferred_free, 540 .deferredfree = rcu_sched_torture_deferred_free,
498 .sync = sched_torture_synchronize, 541 .sync = sched_torture_synchronize,
542 .cb_barrier = rcu_barrier_sched,
499 .stats = NULL, 543 .stats = NULL,
544 .irqcapable = 1,
500 .name = "sched" 545 .name = "sched"
501}; 546};
502 547
548static struct rcu_torture_ops sched_ops_sync = {
549 .init = rcu_sync_torture_init,
550 .cleanup = NULL,
551 .readlock = sched_torture_read_lock,
552 .readdelay = rcu_read_delay, /* just reuse rcu's version. */
553 .readunlock = sched_torture_read_unlock,
554 .completed = sched_torture_completed,
555 .deferredfree = rcu_sync_torture_deferred_free,
556 .sync = sched_torture_synchronize,
557 .cb_barrier = NULL,
558 .stats = NULL,
559 .name = "sched_sync"
560};
561
503/* 562/*
504 * RCU torture writer kthread. Repeatedly substitutes a new structure 563 * RCU torture writer kthread. Repeatedly substitutes a new structure
505 * for that pointed to by rcu_torture_current, freeing the old structure 564 * for that pointed to by rcu_torture_current, freeing the old structure
@@ -537,6 +596,7 @@ rcu_torture_writer(void *arg)
537 } 596 }
538 rcu_torture_current_version++; 597 rcu_torture_current_version++;
539 oldbatch = cur_ops->completed(); 598 oldbatch = cur_ops->completed();
599 rcu_stutter_wait();
540 } while (!kthread_should_stop() && !fullstop); 600 } while (!kthread_should_stop() && !fullstop);
541 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping"); 601 VERBOSE_PRINTK_STRING("rcu_torture_writer task stopping");
542 while (!kthread_should_stop()) 602 while (!kthread_should_stop())
@@ -560,6 +620,7 @@ rcu_torture_fakewriter(void *arg)
560 schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10); 620 schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
561 udelay(rcu_random(&rand) & 0x3ff); 621 udelay(rcu_random(&rand) & 0x3ff);
562 cur_ops->sync(); 622 cur_ops->sync();
623 rcu_stutter_wait();
563 } while (!kthread_should_stop() && !fullstop); 624 } while (!kthread_should_stop() && !fullstop);
564 625
565 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping"); 626 VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task stopping");
@@ -569,6 +630,52 @@ rcu_torture_fakewriter(void *arg)
569} 630}
570 631
571/* 632/*
633 * RCU torture reader from timer handler. Dereferences rcu_torture_current,
634 * incrementing the corresponding element of the pipeline array. The
635 * counter in the element should never be greater than 1, otherwise, the
636 * RCU implementation is broken.
637 */
638static void rcu_torture_timer(unsigned long unused)
639{
640 int idx;
641 int completed;
642 static DEFINE_RCU_RANDOM(rand);
643 static DEFINE_SPINLOCK(rand_lock);
644 struct rcu_torture *p;
645 int pipe_count;
646
647 idx = cur_ops->readlock();
648 completed = cur_ops->completed();
649 p = rcu_dereference(rcu_torture_current);
650 if (p == NULL) {
651 /* Leave because rcu_torture_writer is not yet underway */
652 cur_ops->readunlock(idx);
653 return;
654 }
655 if (p->rtort_mbtest == 0)
656 atomic_inc(&n_rcu_torture_mberror);
657 spin_lock(&rand_lock);
658 cur_ops->readdelay(&rand);
659 n_rcu_torture_timers++;
660 spin_unlock(&rand_lock);
661 preempt_disable();
662 pipe_count = p->rtort_pipe_count;
663 if (pipe_count > RCU_TORTURE_PIPE_LEN) {
664 /* Should not happen, but... */
665 pipe_count = RCU_TORTURE_PIPE_LEN;
666 }
667 ++__get_cpu_var(rcu_torture_count)[pipe_count];
668 completed = cur_ops->completed() - completed;
669 if (completed > RCU_TORTURE_PIPE_LEN) {
670 /* Should not happen, but... */
671 completed = RCU_TORTURE_PIPE_LEN;
672 }
673 ++__get_cpu_var(rcu_torture_batch)[completed];
674 preempt_enable();
675 cur_ops->readunlock(idx);
676}
677
678/*
572 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current, 679 * RCU torture reader kthread. Repeatedly dereferences rcu_torture_current,
573 * incrementing the corresponding element of the pipeline array. The 680 * incrementing the corresponding element of the pipeline array. The
574 * counter in the element should never be greater than 1, otherwise, the 681 * counter in the element should never be greater than 1, otherwise, the
@@ -582,11 +689,18 @@ rcu_torture_reader(void *arg)
582 DEFINE_RCU_RANDOM(rand); 689 DEFINE_RCU_RANDOM(rand);
583 struct rcu_torture *p; 690 struct rcu_torture *p;
584 int pipe_count; 691 int pipe_count;
692 struct timer_list t;
585 693
586 VERBOSE_PRINTK_STRING("rcu_torture_reader task started"); 694 VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
587 set_user_nice(current, 19); 695 set_user_nice(current, 19);
696 if (irqreader && cur_ops->irqcapable)
697 setup_timer_on_stack(&t, rcu_torture_timer, 0);
588 698
589 do { 699 do {
700 if (irqreader && cur_ops->irqcapable) {
701 if (!timer_pending(&t))
702 mod_timer(&t, 1);
703 }
590 idx = cur_ops->readlock(); 704 idx = cur_ops->readlock();
591 completed = cur_ops->completed(); 705 completed = cur_ops->completed();
592 p = rcu_dereference(rcu_torture_current); 706 p = rcu_dereference(rcu_torture_current);
@@ -615,8 +729,11 @@ rcu_torture_reader(void *arg)
615 preempt_enable(); 729 preempt_enable();
616 cur_ops->readunlock(idx); 730 cur_ops->readunlock(idx);
617 schedule(); 731 schedule();
732 rcu_stutter_wait();
618 } while (!kthread_should_stop() && !fullstop); 733 } while (!kthread_should_stop() && !fullstop);
619 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping"); 734 VERBOSE_PRINTK_STRING("rcu_torture_reader task stopping");
735 if (irqreader && cur_ops->irqcapable)
736 del_timer_sync(&t);
620 while (!kthread_should_stop()) 737 while (!kthread_should_stop())
621 schedule_timeout_uninterruptible(1); 738 schedule_timeout_uninterruptible(1);
622 return 0; 739 return 0;
@@ -647,20 +764,22 @@ rcu_torture_printk(char *page)
647 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG); 764 cnt += sprintf(&page[cnt], "%s%s ", torture_type, TORTURE_FLAG);
648 cnt += sprintf(&page[cnt], 765 cnt += sprintf(&page[cnt],
649 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d " 766 "rtc: %p ver: %ld tfle: %d rta: %d rtaf: %d rtf: %d "
650 "rtmbe: %d", 767 "rtmbe: %d nt: %ld",
651 rcu_torture_current, 768 rcu_torture_current,
652 rcu_torture_current_version, 769 rcu_torture_current_version,
653 list_empty(&rcu_torture_freelist), 770 list_empty(&rcu_torture_freelist),
654 atomic_read(&n_rcu_torture_alloc), 771 atomic_read(&n_rcu_torture_alloc),
655 atomic_read(&n_rcu_torture_alloc_fail), 772 atomic_read(&n_rcu_torture_alloc_fail),
656 atomic_read(&n_rcu_torture_free), 773 atomic_read(&n_rcu_torture_free),
657 atomic_read(&n_rcu_torture_mberror)); 774 atomic_read(&n_rcu_torture_mberror),
775 n_rcu_torture_timers);
658 if (atomic_read(&n_rcu_torture_mberror) != 0) 776 if (atomic_read(&n_rcu_torture_mberror) != 0)
659 cnt += sprintf(&page[cnt], " !!!"); 777 cnt += sprintf(&page[cnt], " !!!");
660 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG); 778 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
661 if (i > 1) { 779 if (i > 1) {
662 cnt += sprintf(&page[cnt], "!!! "); 780 cnt += sprintf(&page[cnt], "!!! ");
663 atomic_inc(&n_rcu_torture_error); 781 atomic_inc(&n_rcu_torture_error);
782 WARN_ON_ONCE(1);
664 } 783 }
665 cnt += sprintf(&page[cnt], "Reader Pipe: "); 784 cnt += sprintf(&page[cnt], "Reader Pipe: ");
666 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) 785 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
@@ -785,15 +904,34 @@ rcu_torture_shuffle(void *arg)
785 return 0; 904 return 0;
786} 905}
787 906
907/* Cause the rcutorture test to "stutter", starting and stopping all
908 * threads periodically.
909 */
910static int
911rcu_torture_stutter(void *arg)
912{
913 VERBOSE_PRINTK_STRING("rcu_torture_stutter task started");
914 do {
915 schedule_timeout_interruptible(stutter * HZ);
916 stutter_pause_test = 1;
917 if (!kthread_should_stop())
918 schedule_timeout_interruptible(stutter * HZ);
919 stutter_pause_test = 0;
920 } while (!kthread_should_stop());
921 VERBOSE_PRINTK_STRING("rcu_torture_stutter task stopping");
922 return 0;
923}
924
788static inline void 925static inline void
789rcu_torture_print_module_parms(char *tag) 926rcu_torture_print_module_parms(char *tag)
790{ 927{
791 printk(KERN_ALERT "%s" TORTURE_FLAG 928 printk(KERN_ALERT "%s" TORTURE_FLAG
792 "--- %s: nreaders=%d nfakewriters=%d " 929 "--- %s: nreaders=%d nfakewriters=%d "
793 "stat_interval=%d verbose=%d test_no_idle_hz=%d " 930 "stat_interval=%d verbose=%d test_no_idle_hz=%d "
794 "shuffle_interval = %d\n", 931 "shuffle_interval=%d stutter=%d irqreader=%d\n",
795 torture_type, tag, nrealreaders, nfakewriters, 932 torture_type, tag, nrealreaders, nfakewriters,
796 stat_interval, verbose, test_no_idle_hz, shuffle_interval); 933 stat_interval, verbose, test_no_idle_hz, shuffle_interval,
934 stutter, irqreader);
797} 935}
798 936
799static void 937static void
@@ -802,6 +940,11 @@ rcu_torture_cleanup(void)
802 int i; 940 int i;
803 941
804 fullstop = 1; 942 fullstop = 1;
943 if (stutter_task) {
944 VERBOSE_PRINTK_STRING("Stopping rcu_torture_stutter task");
945 kthread_stop(stutter_task);
946 }
947 stutter_task = NULL;
805 if (shuffler_task) { 948 if (shuffler_task) {
806 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task"); 949 VERBOSE_PRINTK_STRING("Stopping rcu_torture_shuffle task");
807 kthread_stop(shuffler_task); 950 kthread_stop(shuffler_task);
@@ -848,7 +991,9 @@ rcu_torture_cleanup(void)
848 stats_task = NULL; 991 stats_task = NULL;
849 992
850 /* Wait for all RCU callbacks to fire. */ 993 /* Wait for all RCU callbacks to fire. */
851 rcu_barrier(); 994
995 if (cur_ops->cb_barrier != NULL)
996 cur_ops->cb_barrier();
852 997
853 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */ 998 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
854 999
@@ -868,7 +1013,7 @@ rcu_torture_init(void)
868 int firsterr = 0; 1013 int firsterr = 0;
869 static struct rcu_torture_ops *torture_ops[] = 1014 static struct rcu_torture_ops *torture_ops[] =
870 { &rcu_ops, &rcu_sync_ops, &rcu_bh_ops, &rcu_bh_sync_ops, 1015 { &rcu_ops, &rcu_sync_ops, &rcu_bh_ops, &rcu_bh_sync_ops,
871 &srcu_ops, &sched_ops, }; 1016 &srcu_ops, &sched_ops, &sched_ops_sync, };
872 1017
873 /* Process args and tell the world that the torturer is on the job. */ 1018 /* Process args and tell the world that the torturer is on the job. */
874 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) { 1019 for (i = 0; i < ARRAY_SIZE(torture_ops); i++) {
@@ -988,6 +1133,19 @@ rcu_torture_init(void)
988 goto unwind; 1133 goto unwind;
989 } 1134 }
990 } 1135 }
1136 if (stutter < 0)
1137 stutter = 0;
1138 if (stutter) {
1139 /* Create the stutter thread */
1140 stutter_task = kthread_run(rcu_torture_stutter, NULL,
1141 "rcu_torture_stutter");
1142 if (IS_ERR(stutter_task)) {
1143 firsterr = PTR_ERR(stutter_task);
1144 VERBOSE_PRINTK_ERRSTRING("Failed to create stutter");
1145 stutter_task = NULL;
1146 goto unwind;
1147 }
1148 }
991 return 0; 1149 return 0;
992 1150
993unwind: 1151unwind:
diff --git a/kernel/smp.c b/kernel/smp.c
new file mode 100644
index 00000000000..462c785ca1e
--- /dev/null
+++ b/kernel/smp.c
@@ -0,0 +1,383 @@
1/*
2 * Generic helpers for smp ipi calls
3 *
4 * (C) Jens Axboe <jens.axboe@oracle.com> 2008
5 *
6 */
7#include <linux/init.h>
8#include <linux/module.h>
9#include <linux/percpu.h>
10#include <linux/rcupdate.h>
11#include <linux/rculist.h>
12#include <linux/smp.h>
13
14static DEFINE_PER_CPU(struct call_single_queue, call_single_queue);
15static LIST_HEAD(call_function_queue);
16__cacheline_aligned_in_smp DEFINE_SPINLOCK(call_function_lock);
17
18enum {
19 CSD_FLAG_WAIT = 0x01,
20 CSD_FLAG_ALLOC = 0x02,
21};
22
23struct call_function_data {
24 struct call_single_data csd;
25 spinlock_t lock;
26 unsigned int refs;
27 cpumask_t cpumask;
28 struct rcu_head rcu_head;
29};
30
31struct call_single_queue {
32 struct list_head list;
33 spinlock_t lock;
34};
35
36void __cpuinit init_call_single_data(void)
37{
38 int i;
39
40 for_each_possible_cpu(i) {
41 struct call_single_queue *q = &per_cpu(call_single_queue, i);
42
43 spin_lock_init(&q->lock);
44 INIT_LIST_HEAD(&q->list);
45 }
46}
47
48static void csd_flag_wait(struct call_single_data *data)
49{
50 /* Wait for response */
51 do {
52 /*
53 * We need to see the flags store in the IPI handler
54 */
55 smp_mb();
56 if (!(data->flags & CSD_FLAG_WAIT))
57 break;
58 cpu_relax();
59 } while (1);
60}
61
62/*
63 * Insert a previously allocated call_single_data element for execution
64 * on the given CPU. data must already have ->func, ->info, and ->flags set.
65 */
66static void generic_exec_single(int cpu, struct call_single_data *data)
67{
68 struct call_single_queue *dst = &per_cpu(call_single_queue, cpu);
69 int wait = data->flags & CSD_FLAG_WAIT, ipi;
70 unsigned long flags;
71
72 spin_lock_irqsave(&dst->lock, flags);
73 ipi = list_empty(&dst->list);
74 list_add_tail(&data->list, &dst->list);
75 spin_unlock_irqrestore(&dst->lock, flags);
76
77 if (ipi)
78 arch_send_call_function_single_ipi(cpu);
79
80 if (wait)
81 csd_flag_wait(data);
82}
83
84static void rcu_free_call_data(struct rcu_head *head)
85{
86 struct call_function_data *data;
87
88 data = container_of(head, struct call_function_data, rcu_head);
89
90 kfree(data);
91}
92
93/*
94 * Invoked by arch to handle an IPI for call function. Must be called with
95 * interrupts disabled.
96 */
97void generic_smp_call_function_interrupt(void)
98{
99 struct call_function_data *data;
100 int cpu = get_cpu();
101
102 /*
103 * It's ok to use list_for_each_rcu() here even though we may delete
104 * 'pos', since list_del_rcu() doesn't clear ->next
105 */
106 rcu_read_lock();
107 list_for_each_entry_rcu(data, &call_function_queue, csd.list) {
108 int refs;
109
110 if (!cpu_isset(cpu, data->cpumask))
111 continue;
112
113 data->csd.func(data->csd.info);
114
115 spin_lock(&data->lock);
116 cpu_clear(cpu, data->cpumask);
117 WARN_ON(data->refs == 0);
118 data->refs--;
119 refs = data->refs;
120 spin_unlock(&data->lock);
121
122 if (refs)
123 continue;
124
125 spin_lock(&call_function_lock);
126 list_del_rcu(&data->csd.list);
127 spin_unlock(&call_function_lock);
128
129 if (data->csd.flags & CSD_FLAG_WAIT) {
130 /*
131 * serialize stores to data with the flag clear
132 * and wakeup
133 */
134 smp_wmb();
135 data->csd.flags &= ~CSD_FLAG_WAIT;
136 } else
137 call_rcu(&data->rcu_head, rcu_free_call_data);
138 }
139 rcu_read_unlock();
140
141 put_cpu();
142}
143
144/*
145 * Invoked by arch to handle an IPI for call function single. Must be called
146 * from the arch with interrupts disabled.
147 */
148void generic_smp_call_function_single_interrupt(void)
149{
150 struct call_single_queue *q = &__get_cpu_var(call_single_queue);
151 LIST_HEAD(list);
152
153 /*
154 * Need to see other stores to list head for checking whether
155 * list is empty without holding q->lock
156 */
157 smp_mb();
158 while (!list_empty(&q->list)) {
159 unsigned int data_flags;
160
161 spin_lock(&q->lock);
162 list_replace_init(&q->list, &list);
163 spin_unlock(&q->lock);
164
165 while (!list_empty(&list)) {
166 struct call_single_data *data;
167
168 data = list_entry(list.next, struct call_single_data,
169 list);
170 list_del(&data->list);
171
172 /*
173 * 'data' can be invalid after this call if
174 * flags == 0 (when called through
175 * generic_exec_single(), so save them away before
176 * making the call.
177 */
178 data_flags = data->flags;
179
180 data->func(data->info);
181
182 if (data_flags & CSD_FLAG_WAIT) {
183 smp_wmb();
184 data->flags &= ~CSD_FLAG_WAIT;
185 } else if (data_flags & CSD_FLAG_ALLOC)
186 kfree(data);
187 }
188 /*
189 * See comment on outer loop
190 */
191 smp_mb();
192 }
193}
194
195/*
196 * smp_call_function_single - Run a function on a specific CPU
197 * @func: The function to run. This must be fast and non-blocking.
198 * @info: An arbitrary pointer to pass to the function.
199 * @wait: If true, wait until function has completed on other CPUs.
200 *
201 * Returns 0 on success, else a negative status code. Note that @wait
202 * will be implicitly turned on in case of allocation failures, since
203 * we fall back to on-stack allocation.
204 */
205int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
206 int wait)
207{
208 struct call_single_data d;
209 unsigned long flags;
210 /* prevent preemption and reschedule on another processor */
211 int me = get_cpu();
212
213 /* Can deadlock when called with interrupts disabled */
214 WARN_ON(irqs_disabled());
215
216 if (cpu == me) {
217 local_irq_save(flags);
218 func(info);
219 local_irq_restore(flags);
220 } else {
221 struct call_single_data *data = NULL;
222
223 if (!wait) {
224 data = kmalloc(sizeof(*data), GFP_ATOMIC);
225 if (data)
226 data->flags = CSD_FLAG_ALLOC;
227 }
228 if (!data) {
229 data = &d;
230 data->flags = CSD_FLAG_WAIT;
231 }
232
233 data->func = func;
234 data->info = info;
235 generic_exec_single(cpu, data);
236 }
237
238 put_cpu();
239 return 0;
240}
241EXPORT_SYMBOL(smp_call_function_single);
242
243/**
244 * __smp_call_function_single(): Run a function on another CPU
245 * @cpu: The CPU to run on.
246 * @data: Pre-allocated and setup data structure
247 *
248 * Like smp_call_function_single(), but allow caller to pass in a pre-allocated
249 * data structure. Useful for embedding @data inside other structures, for
250 * instance.
251 *
252 */
253void __smp_call_function_single(int cpu, struct call_single_data *data)
254{
255 /* Can deadlock when called with interrupts disabled */
256 WARN_ON((data->flags & CSD_FLAG_WAIT) && irqs_disabled());
257
258 generic_exec_single(cpu, data);
259}
260
261/**
262 * smp_call_function_mask(): Run a function on a set of other CPUs.
263 * @mask: The set of cpus to run on.
264 * @func: The function to run. This must be fast and non-blocking.
265 * @info: An arbitrary pointer to pass to the function.
266 * @wait: If true, wait (atomically) until function has completed on other CPUs.
267 *
268 * Returns 0 on success, else a negative status code.
269 *
270 * If @wait is true, then returns once @func has returned. Note that @wait
271 * will be implicitly turned on in case of allocation failures, since
272 * we fall back to on-stack allocation.
273 *
274 * You must not call this function with disabled interrupts or from a
275 * hardware interrupt handler or from a bottom half handler. Preemption
276 * must be disabled when calling this function.
277 */
278int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
279 int wait)
280{
281 struct call_function_data d;
282 struct call_function_data *data = NULL;
283 cpumask_t allbutself;
284 unsigned long flags;
285 int cpu, num_cpus;
286
287 /* Can deadlock when called with interrupts disabled */
288 WARN_ON(irqs_disabled());
289
290 cpu = smp_processor_id();
291 allbutself = cpu_online_map;
292 cpu_clear(cpu, allbutself);
293 cpus_and(mask, mask, allbutself);
294 num_cpus = cpus_weight(mask);
295
296 /*
297 * If zero CPUs, return. If just a single CPU, turn this request
298 * into a targetted single call instead since it's faster.
299 */
300 if (!num_cpus)
301 return 0;
302 else if (num_cpus == 1) {
303 cpu = first_cpu(mask);
304 return smp_call_function_single(cpu, func, info, wait);
305 }
306
307 if (!wait) {
308 data = kmalloc(sizeof(*data), GFP_ATOMIC);
309 if (data)
310 data->csd.flags = CSD_FLAG_ALLOC;
311 }
312 if (!data) {
313 data = &d;
314 data->csd.flags = CSD_FLAG_WAIT;
315 wait = 1;
316 }
317
318 spin_lock_init(&data->lock);
319 data->csd.func = func;
320 data->csd.info = info;
321 data->refs = num_cpus;
322 data->cpumask = mask;
323
324 spin_lock_irqsave(&call_function_lock, flags);
325 list_add_tail_rcu(&data->csd.list, &call_function_queue);
326 spin_unlock_irqrestore(&call_function_lock, flags);
327
328 /* Send a message to all CPUs in the map */
329 arch_send_call_function_ipi(mask);
330
331 /* optionally wait for the CPUs to complete */
332 if (wait)
333 csd_flag_wait(&data->csd);
334
335 return 0;
336}
337EXPORT_SYMBOL(smp_call_function_mask);
338
339/**
340 * smp_call_function(): Run a function on all other CPUs.
341 * @func: The function to run. This must be fast and non-blocking.
342 * @info: An arbitrary pointer to pass to the function.
343 * @wait: If true, wait (atomically) until function has completed on other CPUs.
344 *
345 * Returns 0 on success, else a negative status code.
346 *
347 * If @wait is true, then returns once @func has returned; otherwise
348 * it returns just before the target cpu calls @func. In case of allocation
349 * failure, @wait will be implicitly turned on.
350 *
351 * You must not call this function with disabled interrupts or from a
352 * hardware interrupt handler or from a bottom half handler.
353 */
354int smp_call_function(void (*func)(void *), void *info, int wait)
355{
356 int ret;
357
358 preempt_disable();
359 ret = smp_call_function_mask(cpu_online_map, func, info, wait);
360 preempt_enable();
361 return ret;
362}
363EXPORT_SYMBOL(smp_call_function);
364
365void ipi_call_lock(void)
366{
367 spin_lock(&call_function_lock);
368}
369
370void ipi_call_unlock(void)
371{
372 spin_unlock(&call_function_lock);
373}
374
375void ipi_call_lock_irq(void)
376{
377 spin_lock_irq(&call_function_lock);
378}
379
380void ipi_call_unlock_irq(void)
381{
382 spin_unlock_irq(&call_function_lock);
383}
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 3e9e896fdc5..81e2fe0f983 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -645,12 +645,12 @@ __init int spawn_ksoftirqd(void)
645/* 645/*
646 * Call a function on all processors 646 * Call a function on all processors
647 */ 647 */
648int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait) 648int on_each_cpu(void (*func) (void *info), void *info, int wait)
649{ 649{
650 int ret = 0; 650 int ret = 0;
651 651
652 preempt_disable(); 652 preempt_disable();
653 ret = smp_call_function(func, info, retry, wait); 653 ret = smp_call_function(func, info, wait);
654 local_irq_disable(); 654 local_irq_disable();
655 func(info); 655 func(info);
656 local_irq_enable(); 656 local_irq_enable();
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index b71816e47a3..94b527ef1d1 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -6,19 +6,21 @@
6 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> 6 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 */ 7 */
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/module.h>
9#include <linux/kallsyms.h> 10#include <linux/kallsyms.h>
10#include <linux/stacktrace.h> 11#include <linux/stacktrace.h>
11 12
12void print_stack_trace(struct stack_trace *trace, int spaces) 13void print_stack_trace(struct stack_trace *trace, int spaces)
13{ 14{
14 int i, j; 15 int i;
15 16
16 for (i = 0; i < trace->nr_entries; i++) { 17 if (WARN_ON(!trace->entries))
17 unsigned long ip = trace->entries[i]; 18 return;
18 19
19 for (j = 0; j < spaces + 1; j++) 20 for (i = 0; i < trace->nr_entries; i++) {
20 printk(" "); 21 printk("%*c", 1 + spaces, ' ');
21 print_ip_sym(ip); 22 print_ip_sym(trace->entries[i]);
22 } 23 }
23} 24}
25EXPORT_SYMBOL_GPL(print_stack_trace);
24 26
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 0d562d6531e..6b16e16428d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -83,6 +83,9 @@ extern int maps_protect;
83extern int sysctl_stat_interval; 83extern int sysctl_stat_interval;
84extern int latencytop_enabled; 84extern int latencytop_enabled;
85extern int sysctl_nr_open_min, sysctl_nr_open_max; 85extern int sysctl_nr_open_min, sysctl_nr_open_max;
86#ifdef CONFIG_RCU_TORTURE_TEST
87extern int rcutorture_runnable;
88#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
86 89
87/* Constants used for minimum and maximum */ 90/* Constants used for minimum and maximum */
88#if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM) 91#if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM)
@@ -820,6 +823,16 @@ static struct ctl_table kern_table[] = {
820 .child = key_sysctls, 823 .child = key_sysctls,
821 }, 824 },
822#endif 825#endif
826#ifdef CONFIG_RCU_TORTURE_TEST
827 {
828 .ctl_name = CTL_UNNUMBERED,
829 .procname = "rcutorture_runnable",
830 .data = &rcutorture_runnable,
831 .maxlen = sizeof(int),
832 .mode = 0644,
833 .proc_handler = &proc_dointvec,
834 },
835#endif
823/* 836/*
824 * NOTE: do not add new entries to this table unless you have read 837 * NOTE: do not add new entries to this table unless you have read
825 * Documentation/sysctl/ctl_unnumbered.txt 838 * Documentation/sysctl/ctl_unnumbered.txt
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 67f80c26170..f48d0f09d32 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -268,7 +268,7 @@ void tick_broadcast_on_off(unsigned long reason, int *oncpu)
268 "offline CPU #%d\n", *oncpu); 268 "offline CPU #%d\n", *oncpu);
269 else 269 else
270 smp_call_function_single(*oncpu, tick_do_broadcast_on_off, 270 smp_call_function_single(*oncpu, tick_do_broadcast_on_off,
271 &reason, 1, 1); 271 &reason, 1);
272} 272}
273 273
274/* 274/*
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index d63008b09a4..beef7ccdf84 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -48,6 +48,13 @@ static void tick_do_update_jiffies64(ktime_t now)
48 unsigned long ticks = 0; 48 unsigned long ticks = 0;
49 ktime_t delta; 49 ktime_t delta;
50 50
51 /*
52 * Do a quick check without holding xtime_lock:
53 */
54 delta = ktime_sub(now, last_jiffies_update);
55 if (delta.tv64 < tick_period.tv64)
56 return;
57
51 /* Reevalute with xtime_lock held */ 58 /* Reevalute with xtime_lock held */
52 write_seqlock(&xtime_lock); 59 write_seqlock(&xtime_lock);
53 60
@@ -228,6 +235,7 @@ void tick_nohz_stop_sched_tick(void)
228 local_softirq_pending()); 235 local_softirq_pending());
229 ratelimit++; 236 ratelimit++;
230 } 237 }
238 goto end;
231 } 239 }
232 240
233 ts->idle_calls++; 241 ts->idle_calls++;
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d8b6279a9b4..df27132a56f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -419,7 +419,6 @@ config DEBUG_LOCKING_API_SELFTESTS
419 419
420config STACKTRACE 420config STACKTRACE
421 bool 421 bool
422 depends on DEBUG_KERNEL
423 depends on STACKTRACE_SUPPORT 422 depends on STACKTRACE_SUPPORT
424 423
425config DEBUG_KOBJECT 424config DEBUG_KOBJECT
@@ -531,16 +530,34 @@ config BOOT_PRINTK_DELAY
531config RCU_TORTURE_TEST 530config RCU_TORTURE_TEST
532 tristate "torture tests for RCU" 531 tristate "torture tests for RCU"
533 depends on DEBUG_KERNEL 532 depends on DEBUG_KERNEL
534 depends on m
535 default n 533 default n
536 help 534 help
537 This option provides a kernel module that runs torture tests 535 This option provides a kernel module that runs torture tests
538 on the RCU infrastructure. The kernel module may be built 536 on the RCU infrastructure. The kernel module may be built
539 after the fact on the running kernel to be tested, if desired. 537 after the fact on the running kernel to be tested, if desired.
540 538
539 Say Y here if you want RCU torture tests to be built into
540 the kernel.
541 Say M if you want the RCU torture tests to build as a module. 541 Say M if you want the RCU torture tests to build as a module.
542 Say N if you are unsure. 542 Say N if you are unsure.
543 543
544config RCU_TORTURE_TEST_RUNNABLE
545 bool "torture tests for RCU runnable by default"
546 depends on RCU_TORTURE_TEST = y
547 default n
548 help
549 This option provides a way to build the RCU torture tests
550 directly into the kernel without them starting up at boot
551 time. You can use /proc/sys/kernel/rcutorture_runnable
552 to manually override this setting. This /proc file is
553 available only when the RCU torture tests have been built
554 into the kernel.
555
556 Say Y here if you want the RCU torture tests to start during
557 boot (you probably don't).
558 Say N here if you want the RCU torture tests to start only
559 after being manually enabled via /proc.
560
544config KPROBES_SANITY_TEST 561config KPROBES_SANITY_TEST
545 bool "Kprobes sanity tests" 562 bool "Kprobes sanity tests"
546 depends on DEBUG_KERNEL 563 depends on DEBUG_KERNEL
@@ -563,6 +580,9 @@ config BACKTRACE_SELF_TEST
563 for distributions or general kernels, but only for kernel 580 for distributions or general kernels, but only for kernel
564 developers working on architecture code. 581 developers working on architecture code.
565 582
583 Note that if you want to also test saved backtraces, you will
584 have to enable STACKTRACE as well.
585
566 Say N if you are unsure. 586 Say N if you are unsure.
567 587
568config LKDTM 588config LKDTM
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 119174494cb..4a8ba4bf5f6 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL(__percpu_counter_add);
52 * Add up all the per-cpu counts, return the result. This is a more accurate 52 * Add up all the per-cpu counts, return the result. This is a more accurate
53 * but much slower version of percpu_counter_read_positive() 53 * but much slower version of percpu_counter_read_positive()
54 */ 54 */
55s64 __percpu_counter_sum(struct percpu_counter *fbc) 55s64 __percpu_counter_sum(struct percpu_counter *fbc, int set)
56{ 56{
57 s64 ret; 57 s64 ret;
58 int cpu; 58 int cpu;
@@ -62,7 +62,12 @@ s64 __percpu_counter_sum(struct percpu_counter *fbc)
62 for_each_online_cpu(cpu) { 62 for_each_online_cpu(cpu) {
63 s32 *pcount = per_cpu_ptr(fbc->counters, cpu); 63 s32 *pcount = per_cpu_ptr(fbc->counters, cpu);
64 ret += *pcount; 64 ret += *pcount;
65 if (set)
66 *pcount = 0;
65 } 67 }
68 if (set)
69 fbc->count = ret;
70
66 spin_unlock(&fbc->lock); 71 spin_unlock(&fbc->lock);
67 return ret; 72 return ret;
68} 73}
diff --git a/lib/textsearch.c b/lib/textsearch.c
index be8bda3862f..a3e500ad51d 100644
--- a/lib/textsearch.c
+++ b/lib/textsearch.c
@@ -97,6 +97,7 @@
97#include <linux/types.h> 97#include <linux/types.h>
98#include <linux/string.h> 98#include <linux/string.h>
99#include <linux/init.h> 99#include <linux/init.h>
100#include <linux/rculist.h>
100#include <linux/rcupdate.h> 101#include <linux/rcupdate.h>
101#include <linux/err.h> 102#include <linux/err.h>
102#include <linux/textsearch.h> 103#include <linux/textsearch.h>
diff --git a/mm/filemap.c b/mm/filemap.c
index 1e6a7d34874..65d9d9e2b75 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -236,11 +236,12 @@ int filemap_fdatawrite(struct address_space *mapping)
236} 236}
237EXPORT_SYMBOL(filemap_fdatawrite); 237EXPORT_SYMBOL(filemap_fdatawrite);
238 238
239static int filemap_fdatawrite_range(struct address_space *mapping, loff_t start, 239int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
240 loff_t end) 240 loff_t end)
241{ 241{
242 return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL); 242 return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL);
243} 243}
244EXPORT_SYMBOL(filemap_fdatawrite_range);
244 245
245/** 246/**
246 * filemap_flush - mostly a non-blocking flush 247 * filemap_flush - mostly a non-blocking flush
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index b38f700825f..94c6d8988ab 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -960,6 +960,9 @@ retry:
960 } 960 }
961 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 961 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
962 mapping->writeback_index = index; 962 mapping->writeback_index = index;
963
964 if (wbc->range_cont)
965 wbc->range_start = index << PAGE_CACHE_SHIFT;
963 return ret; 966 return ret;
964} 967}
965EXPORT_SYMBOL(write_cache_pages); 968EXPORT_SYMBOL(write_cache_pages);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f024b9b3a2a..79ac4afc908 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -918,7 +918,7 @@ void drain_local_pages(void *arg)
918 */ 918 */
919void drain_all_pages(void) 919void drain_all_pages(void)
920{ 920{
921 on_each_cpu(drain_local_pages, NULL, 0, 1); 921 on_each_cpu(drain_local_pages, NULL, 1);
922} 922}
923 923
924#ifdef CONFIG_HIBERNATION 924#ifdef CONFIG_HIBERNATION
diff --git a/mm/slab.c b/mm/slab.c
index 046607f05f3..052e7d64537 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1901,15 +1901,7 @@ static void check_poison_obj(struct kmem_cache *cachep, void *objp)
1901#endif 1901#endif
1902 1902
1903#if DEBUG 1903#if DEBUG
1904/** 1904static void slab_destroy_debugcheck(struct kmem_cache *cachep, struct slab *slabp)
1905 * slab_destroy_objs - destroy a slab and its objects
1906 * @cachep: cache pointer being destroyed
1907 * @slabp: slab pointer being destroyed
1908 *
1909 * Call the registered destructor for each object in a slab that is being
1910 * destroyed.
1911 */
1912static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1913{ 1905{
1914 int i; 1906 int i;
1915 for (i = 0; i < cachep->num; i++) { 1907 for (i = 0; i < cachep->num; i++) {
@@ -1938,7 +1930,7 @@ static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp)
1938 } 1930 }
1939} 1931}
1940#else 1932#else
1941static void slab_destroy_objs(struct kmem_cache *cachep, struct slab *slabp) 1933static void slab_destroy_debugcheck(struct kmem_cache *cachep, struct slab *slabp)
1942{ 1934{
1943} 1935}
1944#endif 1936#endif
@@ -1956,7 +1948,7 @@ static void slab_destroy(struct kmem_cache *cachep, struct slab *slabp)
1956{ 1948{
1957 void *addr = slabp->s_mem - slabp->colouroff; 1949 void *addr = slabp->s_mem - slabp->colouroff;
1958 1950
1959 slab_destroy_objs(cachep, slabp); 1951 slab_destroy_debugcheck(cachep, slabp);
1960 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) { 1952 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) {
1961 struct slab_rcu *slab_rcu; 1953 struct slab_rcu *slab_rcu;
1962 1954
@@ -2454,7 +2446,7 @@ static void drain_cpu_caches(struct kmem_cache *cachep)
2454 struct kmem_list3 *l3; 2446 struct kmem_list3 *l3;
2455 int node; 2447 int node;
2456 2448
2457 on_each_cpu(do_drain, cachep, 1, 1); 2449 on_each_cpu(do_drain, cachep, 1);
2458 check_irq_on(); 2450 check_irq_on();
2459 for_each_online_node(node) { 2451 for_each_online_node(node) {
2460 l3 = cachep->nodelists[node]; 2452 l3 = cachep->nodelists[node];
@@ -3939,7 +3931,7 @@ static int do_tune_cpucache(struct kmem_cache *cachep, int limit,
3939 } 3931 }
3940 new->cachep = cachep; 3932 new->cachep = cachep;
3941 3933
3942 on_each_cpu(do_ccupdate_local, (void *)new, 1, 1); 3934 on_each_cpu(do_ccupdate_local, (void *)new, 1);
3943 3935
3944 check_irq_on(); 3936 check_irq_on();
3945 cachep->batchcount = batchcount; 3937 cachep->batchcount = batchcount;
diff --git a/mm/slub.c b/mm/slub.c
index 5f6e2c4a2ba..35ab38a94b4 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -411,7 +411,7 @@ static void set_track(struct kmem_cache *s, void *object,
411 if (addr) { 411 if (addr) {
412 p->addr = addr; 412 p->addr = addr;
413 p->cpu = smp_processor_id(); 413 p->cpu = smp_processor_id();
414 p->pid = current ? current->pid : -1; 414 p->pid = current->pid;
415 p->when = jiffies; 415 p->when = jiffies;
416 } else 416 } else
417 memset(p, 0, sizeof(struct track)); 417 memset(p, 0, sizeof(struct track));
@@ -1496,7 +1496,7 @@ static void flush_cpu_slab(void *d)
1496static void flush_all(struct kmem_cache *s) 1496static void flush_all(struct kmem_cache *s)
1497{ 1497{
1498#ifdef CONFIG_SMP 1498#ifdef CONFIG_SMP
1499 on_each_cpu(flush_cpu_slab, s, 1, 1); 1499 on_each_cpu(flush_cpu_slab, s, 1);
1500#else 1500#else
1501 unsigned long flags; 1501 unsigned long flags;
1502 1502
@@ -2766,6 +2766,7 @@ void kfree(const void *x)
2766 2766
2767 page = virt_to_head_page(x); 2767 page = virt_to_head_page(x);
2768 if (unlikely(!PageSlab(page))) { 2768 if (unlikely(!PageSlab(page))) {
2769 BUG_ON(!PageCompound(page));
2769 put_page(page); 2770 put_page(page);
2770 return; 2771 return;
2771 } 2772 }
diff --git a/net/802/psnap.c b/net/802/psnap.c
index 31128cb92a2..ea464393144 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -20,6 +20,7 @@
20#include <linux/mm.h> 20#include <linux/mm.h>
21#include <linux/in.h> 21#include <linux/in.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/rculist.h>
23 24
24static LIST_HEAD(snap_list); 25static LIST_HEAD(snap_list);
25static DEFINE_SPINLOCK(snap_lock); 26static DEFINE_SPINLOCK(snap_lock);
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index ab2225da0ee..08f14f6c5fd 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -27,6 +27,7 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/in.h> 28#include <linux/in.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/rculist.h>
30#include <net/p8022.h> 31#include <net/p8022.h>
31#include <net/arp.h> 32#include <net/arp.h>
32#include <linux/rtnetlink.h> 33#include <linux/rtnetlink.h>
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 72c5976a5ce..142060f0205 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/rculist.h>
18#include <linux/spinlock.h> 19#include <linux/spinlock.h>
19#include <linux/times.h> 20#include <linux/times.h>
20#include <linux/netdevice.h> 21#include <linux/netdevice.h>
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c
index e38034aa56f..9e96ffcd29a 100644
--- a/net/bridge/br_stp.c
+++ b/net/bridge/br_stp.c
@@ -13,6 +13,7 @@
13 * 2 of the License, or (at your option) any later version. 13 * 2 of the License, or (at your option) any later version.
14 */ 14 */
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/rculist.h>
16 17
17#include "br_private.h" 18#include "br_private.h"
18#include "br_private_stp.h" 19#include "br_private_stp.h"
diff --git a/net/core/flow.c b/net/core/flow.c
index 19991175fde..5cf81052d04 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -298,7 +298,7 @@ void flow_cache_flush(void)
298 init_completion(&info.completion); 298 init_completion(&info.completion);
299 299
300 local_bh_disable(); 300 local_bh_disable();
301 smp_call_function(flow_cache_flush_per_cpu, &info, 1, 0); 301 smp_call_function(flow_cache_flush_per_cpu, &info, 0);
302 flow_cache_flush_tasklet((unsigned long)&info); 302 flow_cache_flush_tasklet((unsigned long)&info);
303 local_bh_enable(); 303 local_bh_enable();
304 304
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 7f82b761621..cc34ac769a3 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -480,7 +480,7 @@ static void iucv_setmask_mp(void)
480 if (cpu_isset(cpu, iucv_buffer_cpumask) && 480 if (cpu_isset(cpu, iucv_buffer_cpumask) &&
481 !cpu_isset(cpu, iucv_irq_cpumask)) 481 !cpu_isset(cpu, iucv_irq_cpumask))
482 smp_call_function_single(cpu, iucv_allow_cpu, 482 smp_call_function_single(cpu, iucv_allow_cpu,
483 NULL, 0, 1); 483 NULL, 1);
484 preempt_enable(); 484 preempt_enable();
485} 485}
486 486
@@ -498,7 +498,7 @@ static void iucv_setmask_up(void)
498 cpumask = iucv_irq_cpumask; 498 cpumask = iucv_irq_cpumask;
499 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask); 499 cpu_clear(first_cpu(iucv_irq_cpumask), cpumask);
500 for_each_cpu_mask(cpu, cpumask) 500 for_each_cpu_mask(cpu, cpumask)
501 smp_call_function_single(cpu, iucv_block_cpu, NULL, 0, 1); 501 smp_call_function_single(cpu, iucv_block_cpu, NULL, 1);
502} 502}
503 503
504/** 504/**
@@ -523,7 +523,7 @@ static int iucv_enable(void)
523 rc = -EIO; 523 rc = -EIO;
524 preempt_disable(); 524 preempt_disable();
525 for_each_online_cpu(cpu) 525 for_each_online_cpu(cpu)
526 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 0, 1); 526 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
527 preempt_enable(); 527 preempt_enable();
528 if (cpus_empty(iucv_buffer_cpumask)) 528 if (cpus_empty(iucv_buffer_cpumask))
529 /* No cpu could declare an iucv buffer. */ 529 /* No cpu could declare an iucv buffer. */
@@ -545,7 +545,7 @@ out:
545 */ 545 */
546static void iucv_disable(void) 546static void iucv_disable(void)
547{ 547{
548 on_each_cpu(iucv_retrieve_cpu, NULL, 0, 1); 548 on_each_cpu(iucv_retrieve_cpu, NULL, 1);
549 kfree(iucv_path_table); 549 kfree(iucv_path_table);
550} 550}
551 551
@@ -580,7 +580,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
580 case CPU_ONLINE_FROZEN: 580 case CPU_ONLINE_FROZEN:
581 case CPU_DOWN_FAILED: 581 case CPU_DOWN_FAILED:
582 case CPU_DOWN_FAILED_FROZEN: 582 case CPU_DOWN_FAILED_FROZEN:
583 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 0, 1); 583 smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
584 break; 584 break;
585 case CPU_DOWN_PREPARE: 585 case CPU_DOWN_PREPARE:
586 case CPU_DOWN_PREPARE_FROZEN: 586 case CPU_DOWN_PREPARE_FROZEN:
@@ -589,10 +589,10 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
589 if (cpus_empty(cpumask)) 589 if (cpus_empty(cpumask))
590 /* Can't offline last IUCV enabled cpu. */ 590 /* Can't offline last IUCV enabled cpu. */
591 return NOTIFY_BAD; 591 return NOTIFY_BAD;
592 smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 0, 1); 592 smp_call_function_single(cpu, iucv_retrieve_cpu, NULL, 1);
593 if (cpus_empty(iucv_irq_cpumask)) 593 if (cpus_empty(iucv_irq_cpumask))
594 smp_call_function_single(first_cpu(iucv_buffer_cpumask), 594 smp_call_function_single(first_cpu(iucv_buffer_cpumask),
595 iucv_allow_cpu, NULL, 0, 1); 595 iucv_allow_cpu, NULL, 1);
596 break; 596 break;
597 } 597 }
598 return NOTIFY_OK; 598 return NOTIFY_OK;
@@ -652,7 +652,7 @@ static void iucv_cleanup_queue(void)
652 * pending interrupts force them to the work queue by calling 652 * pending interrupts force them to the work queue by calling
653 * an empty function on all cpus. 653 * an empty function on all cpus.
654 */ 654 */
655 smp_call_function(__iucv_cleanup_queue, NULL, 0, 1); 655 smp_call_function(__iucv_cleanup_queue, NULL, 1);
656 spin_lock_irq(&iucv_queue_lock); 656 spin_lock_irq(&iucv_queue_lock);
657 list_for_each_entry_safe(p, n, &iucv_task_queue, list) { 657 list_for_each_entry_safe(p, n, &iucv_task_queue, list) {
658 /* Remove stale work items from the task queue. */ 658 /* Remove stale work items from the task queue. */
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 7d1b1170374..8e0b4c8f62a 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -20,6 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/netdevice.h> 22#include <linux/netdevice.h>
23#include <linux/rculist.h>
23 24
24#include <net/netfilter/nf_conntrack.h> 25#include <net/netfilter/nf_conntrack.h>
25#include <net/netfilter/nf_conntrack_l3proto.h> 26#include <net/netfilter/nf_conntrack_l3proto.h>
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 0edefcfc594..077bcd22879 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -18,6 +18,7 @@
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/rculist.h>
21#include <linux/types.h> 22#include <linux/types.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
23#include <linux/skbuff.h> 24#include <linux/skbuff.h>
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 02c2f7c0b25..643c032a3a5 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -30,8 +30,7 @@
30 */ 30 */
31 31
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/rcupdate.h> 33#include <linux/rculist.h>
34#include <linux/list.h>
35#include <linux/skbuff.h> 34#include <linux/skbuff.h>
36#include <linux/spinlock.h> 35#include <linux/spinlock.h>
37#include <linux/string.h> 36#include <linux/string.h>
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 91200feb3f9..63f131fc42e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -555,15 +555,13 @@ static int selinux_set_mnt_opts(struct super_block *sb,
555 struct task_security_struct *tsec = current->security; 555 struct task_security_struct *tsec = current->security;
556 struct superblock_security_struct *sbsec = sb->s_security; 556 struct superblock_security_struct *sbsec = sb->s_security;
557 const char *name = sb->s_type->name; 557 const char *name = sb->s_type->name;
558 struct dentry *root = sb->s_root; 558 struct inode *inode = sbsec->sb->s_root->d_inode;
559 struct inode *root_inode = root->d_inode; 559 struct inode_security_struct *root_isec = inode->i_security;
560 struct inode_security_struct *root_isec = root_inode->i_security;
561 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0; 560 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0;
562 u32 defcontext_sid = 0; 561 u32 defcontext_sid = 0;
563 char **mount_options = opts->mnt_opts; 562 char **mount_options = opts->mnt_opts;
564 int *flags = opts->mnt_opts_flags; 563 int *flags = opts->mnt_opts_flags;
565 int num_opts = opts->num_mnt_opts; 564 int num_opts = opts->num_mnt_opts;
566 bool can_xattr = false;
567 565
568 mutex_lock(&sbsec->lock); 566 mutex_lock(&sbsec->lock);
569 567
@@ -667,24 +665,14 @@ static int selinux_set_mnt_opts(struct super_block *sb,
667 goto out; 665 goto out;
668 } 666 }
669 667
670 if (strcmp(name, "proc") == 0) 668 if (strcmp(sb->s_type->name, "proc") == 0)
671 sbsec->proc = 1; 669 sbsec->proc = 1;
672 670
673 /*
674 * test if the fs supports xattrs, fs_use might make use of this if the
675 * fs has no definition in policy.
676 */
677 if (root_inode->i_op->getxattr) {
678 rc = root_inode->i_op->getxattr(root, XATTR_NAME_SELINUX, NULL, 0);
679 if (rc >= 0 || rc == -ENODATA)
680 can_xattr = true;
681 }
682
683 /* Determine the labeling behavior to use for this filesystem type. */ 671 /* Determine the labeling behavior to use for this filesystem type. */
684 rc = security_fs_use(name, &sbsec->behavior, &sbsec->sid, can_xattr); 672 rc = security_fs_use(sb->s_type->name, &sbsec->behavior, &sbsec->sid);
685 if (rc) { 673 if (rc) {
686 printk(KERN_WARNING "%s: security_fs_use(%s) returned %d\n", 674 printk(KERN_WARNING "%s: security_fs_use(%s) returned %d\n",
687 __func__, name, rc); 675 __func__, sb->s_type->name, rc);
688 goto out; 676 goto out;
689 } 677 }
690 678
diff --git a/security/selinux/include/security.h b/security/selinux/include/security.h
index 44cba2e21dc..7c543003d65 100644
--- a/security/selinux/include/security.h
+++ b/security/selinux/include/security.h
@@ -136,7 +136,7 @@ int security_get_allow_unknown(void);
136#define SECURITY_FS_USE_MNTPOINT 6 /* use mountpoint labeling */ 136#define SECURITY_FS_USE_MNTPOINT 6 /* use mountpoint labeling */
137 137
138int security_fs_use(const char *fstype, unsigned int *behavior, 138int security_fs_use(const char *fstype, unsigned int *behavior,
139 u32 *sid, bool can_xattr); 139 u32 *sid);
140 140
141int security_genfs_sid(const char *fstype, char *name, u16 sclass, 141int security_genfs_sid(const char *fstype, char *name, u16 sclass,
142 u32 *sid); 142 u32 *sid);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 8e42da12010..b52f923ce68 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -1934,8 +1934,7 @@ out:
1934int security_fs_use( 1934int security_fs_use(
1935 const char *fstype, 1935 const char *fstype,
1936 unsigned int *behavior, 1936 unsigned int *behavior,
1937 u32 *sid, 1937 u32 *sid)
1938 bool can_xattr)
1939{ 1938{
1940 int rc = 0; 1939 int rc = 0;
1941 struct ocontext *c; 1940 struct ocontext *c;
@@ -1949,7 +1948,6 @@ int security_fs_use(
1949 c = c->next; 1948 c = c->next;
1950 } 1949 }
1951 1950
1952 /* look for labeling behavior defined in policy */
1953 if (c) { 1951 if (c) {
1954 *behavior = c->v.behavior; 1952 *behavior = c->v.behavior;
1955 if (!c->sid[0]) { 1953 if (!c->sid[0]) {
@@ -1960,23 +1958,14 @@ int security_fs_use(
1960 goto out; 1958 goto out;
1961 } 1959 }
1962 *sid = c->sid[0]; 1960 *sid = c->sid[0];
1963 goto out;
1964 }
1965
1966 /* labeling behavior not in policy, use xattrs if possible */
1967 if (can_xattr) {
1968 *behavior = SECURITY_FS_USE_XATTR;
1969 *sid = SECINITSID_FS;
1970 goto out;
1971 }
1972
1973 /* no behavior in policy and can't use xattrs, try GENFS */
1974 rc = security_genfs_sid(fstype, "/", SECCLASS_DIR, sid);
1975 if (rc) {
1976 *behavior = SECURITY_FS_USE_NONE;
1977 rc = 0;
1978 } else { 1961 } else {
1979 *behavior = SECURITY_FS_USE_GENFS; 1962 rc = security_genfs_sid(fstype, "/", SECCLASS_DIR, sid);
1963 if (rc) {
1964 *behavior = SECURITY_FS_USE_NONE;
1965 rc = 0;
1966 } else {
1967 *behavior = SECURITY_FS_USE_GENFS;
1968 }
1980 } 1969 }
1981 1970
1982out: 1971out:
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 2d29e260da3..d4eae6af073 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1266,12 +1266,12 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
1266 case CPU_UP_CANCELED: 1266 case CPU_UP_CANCELED:
1267 printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", 1267 printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
1268 cpu); 1268 cpu);
1269 smp_call_function_single(cpu, hardware_disable, NULL, 0, 1); 1269 smp_call_function_single(cpu, hardware_disable, NULL, 1);
1270 break; 1270 break;
1271 case CPU_ONLINE: 1271 case CPU_ONLINE:
1272 printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n", 1272 printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n",
1273 cpu); 1273 cpu);
1274 smp_call_function_single(cpu, hardware_enable, NULL, 0, 1); 1274 smp_call_function_single(cpu, hardware_enable, NULL, 1);
1275 break; 1275 break;
1276 } 1276 }
1277 return NOTIFY_OK; 1277 return NOTIFY_OK;
@@ -1286,7 +1286,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val,
1286 * in vmx root mode. 1286 * in vmx root mode.
1287 */ 1287 */
1288 printk(KERN_INFO "kvm: exiting hardware virtualization\n"); 1288 printk(KERN_INFO "kvm: exiting hardware virtualization\n");
1289 on_each_cpu(hardware_disable, NULL, 0, 1); 1289 on_each_cpu(hardware_disable, NULL, 1);
1290 } 1290 }
1291 return NOTIFY_OK; 1291 return NOTIFY_OK;
1292} 1292}
@@ -1474,12 +1474,12 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
1474 for_each_online_cpu(cpu) { 1474 for_each_online_cpu(cpu) {
1475 smp_call_function_single(cpu, 1475 smp_call_function_single(cpu,
1476 kvm_arch_check_processor_compat, 1476 kvm_arch_check_processor_compat,
1477 &r, 0, 1); 1477 &r, 1);
1478 if (r < 0) 1478 if (r < 0)
1479 goto out_free_1; 1479 goto out_free_1;
1480 } 1480 }
1481 1481
1482 on_each_cpu(hardware_enable, NULL, 0, 1); 1482 on_each_cpu(hardware_enable, NULL, 1);
1483 r = register_cpu_notifier(&kvm_cpu_notifier); 1483 r = register_cpu_notifier(&kvm_cpu_notifier);
1484 if (r) 1484 if (r)
1485 goto out_free_2; 1485 goto out_free_2;
@@ -1525,7 +1525,7 @@ out_free_3:
1525 unregister_reboot_notifier(&kvm_reboot_notifier); 1525 unregister_reboot_notifier(&kvm_reboot_notifier);
1526 unregister_cpu_notifier(&kvm_cpu_notifier); 1526 unregister_cpu_notifier(&kvm_cpu_notifier);
1527out_free_2: 1527out_free_2:
1528 on_each_cpu(hardware_disable, NULL, 0, 1); 1528 on_each_cpu(hardware_disable, NULL, 1);
1529out_free_1: 1529out_free_1:
1530 kvm_arch_hardware_unsetup(); 1530 kvm_arch_hardware_unsetup();
1531out_free_0: 1531out_free_0:
@@ -1547,7 +1547,7 @@ void kvm_exit(void)
1547 sysdev_class_unregister(&kvm_sysdev_class); 1547 sysdev_class_unregister(&kvm_sysdev_class);
1548 unregister_reboot_notifier(&kvm_reboot_notifier); 1548 unregister_reboot_notifier(&kvm_reboot_notifier);
1549 unregister_cpu_notifier(&kvm_cpu_notifier); 1549 unregister_cpu_notifier(&kvm_cpu_notifier);
1550 on_each_cpu(hardware_disable, NULL, 0, 1); 1550 on_each_cpu(hardware_disable, NULL, 1);
1551 kvm_arch_hardware_unsetup(); 1551 kvm_arch_hardware_unsetup();
1552 kvm_arch_exit(); 1552 kvm_arch_exit();
1553 kvm_exit_debug(); 1553 kvm_exit_debug();