aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-12-07 04:57:19 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-07 04:57:19 -0500
commit8d1413b28033c49c7f1a4d320e815d7a5531acee (patch)
treeb37281abef014cd60803b81c100388d7a475d49e
parented25ffa16434724f5ed825aa48734c7f3aefa203 (diff)
parent620034c84d1d939717bdfbe02c51a3fee43541c3 (diff)
Merge branch 'master' into upstream
Conflicts: drivers/net/netxen/netxen_nic.h drivers/net/netxen/netxen_nic_main.c
-rw-r--r--Documentation/DocBook/Makefile10
-rw-r--r--Documentation/kernel-parameters.txt5
-rw-r--r--Documentation/powerpc/booting-without-of.txt39
-rw-r--r--Documentation/powerpc/mpc52xx-device-tree-bindings.txt189
-rw-r--r--Documentation/scsi/scsi_mid_low_api.txt31
-rw-r--r--MAINTAINERS7
-rw-r--r--README17
-rw-r--r--arch/arm/common/sharpsl_pm.c22
-rw-r--r--arch/arm/mach-omap1/board-h3.c3
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c6
-rw-r--r--arch/arm/mach-omap1/leds-osk.c4
-rw-r--r--arch/arm/mach-omap2/board-h4.c3
-rw-r--r--arch/arm/mach-pxa/akita-ioexp.c6
-rw-r--r--arch/i386/kernel/cpu/mcheck/non-fatal.c6
-rw-r--r--arch/i386/kernel/smpboot.c11
-rw-r--r--arch/i386/kernel/tsc.c4
-rw-r--r--arch/ia64/hp/sim/simserial.c4
-rw-r--r--arch/ia64/kernel/mca.c8
-rw-r--r--arch/ia64/kernel/smpboot.c12
-rw-r--r--arch/ia64/pci/pci.c4
-rw-r--r--arch/m68knommu/platform/5307/timers.c16
-rw-r--r--arch/m68knommu/platform/68360/config.c2
-rw-r--r--arch/mips/Kconfig27
-rw-r--r--arch/mips/dec/ecc-berr.c1
-rw-r--r--arch/mips/dec/ioasic-irq.c4
-rw-r--r--arch/mips/dec/kn01-berr.c2
-rw-r--r--arch/mips/dec/kn02-irq.c7
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c7
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c7
-rw-r--r--arch/mips/jazz/irq.c7
-rw-r--r--arch/mips/kernel/i8259.c162
-rw-r--r--arch/mips/kernel/irq-mv6434x.c10
-rw-r--r--arch/mips/kernel/irq-rm7000.c7
-rw-r--r--arch/mips/kernel/irq-rm9000.c8
-rw-r--r--arch/mips/kernel/irq.c2
-rw-r--r--arch/mips/kernel/irq_cpu.c10
-rw-r--r--arch/mips/kernel/kspd.c4
-rw-r--r--arch/mips/kernel/linux32.c578
-rw-r--r--arch/mips/kernel/scall64-n32.S14
-rw-r--r--arch/mips/kernel/smp.c6
-rw-r--r--arch/mips/lasat/interrupt.c7
-rw-r--r--arch/mips/lib-32/Makefile2
-rw-r--r--arch/mips/lib-32/csum_partial.S240
-rw-r--r--arch/mips/lib-64/Makefile2
-rw-r--r--arch/mips/lib-64/csum_partial.S242
-rw-r--r--arch/mips/lib/Makefile4
-rw-r--r--arch/mips/lib/csum_partial.S258
-rw-r--r--arch/mips/momentum/ocelot_c/cpci-irq.c10
-rw-r--r--arch/mips/momentum/ocelot_c/uart-irq.c10
-rw-r--r--arch/mips/philips/pnx8550/common/int.c8
-rw-r--r--arch/mips/sgi-ip22/ip22-int.c28
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c8
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c5
-rw-r--r--arch/mips/sibyte/swarm/setup.c8
-rw-r--r--arch/mips/tx4927/common/tx4927_irq.c26
-rw-r--r--arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c21
-rw-r--r--arch/mips/tx4938/common/irq.c20
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/irq.c10
-rw-r--r--arch/mips/vr41xx/Kconfig5
-rw-r--r--arch/mips/vr41xx/common/icu.c14
-rw-r--r--arch/powerpc/.gitignore1
-rw-r--r--arch/powerpc/Kconfig105
-rw-r--r--arch/powerpc/Kconfig.debug13
-rw-r--r--arch/powerpc/boot/.gitignore13
-rw-r--r--arch/powerpc/boot/Makefile15
-rw-r--r--arch/powerpc/boot/dts/kuroboxHG.dts148
-rw-r--r--arch/powerpc/boot/dts/lite5200.dts313
-rw-r--r--arch/powerpc/boot/dts/lite5200b.dts318
-rw-r--r--arch/powerpc/boot/dts/mpc7448hpc2.dts44
-rw-r--r--arch/powerpc/boot/flatdevtree.c880
-rw-r--r--arch/powerpc/boot/flatdevtree.h62
-rw-r--r--arch/powerpc/boot/flatdevtree_env.h47
-rw-r--r--arch/powerpc/boot/flatdevtree_misc.c51
-rw-r--r--arch/powerpc/boot/io.h53
-rw-r--r--arch/powerpc/boot/main.c57
-rw-r--r--arch/powerpc/boot/mktree.c152
-rw-r--r--arch/powerpc/boot/ns16550.c74
-rw-r--r--arch/powerpc/boot/of.c8
-rw-r--r--arch/powerpc/boot/ops.h26
-rw-r--r--arch/powerpc/boot/serial.c142
-rw-r--r--arch/powerpc/boot/simple_alloc.c149
-rw-r--r--arch/powerpc/boot/stdio.c3
-rw-r--r--arch/powerpc/boot/util.S88
-rwxr-xr-xarch/powerpc/boot/wrapper3
-rw-r--r--arch/powerpc/boot/zImage.coff.lds.S4
-rw-r--r--arch/powerpc/configs/cell_defconfig50
-rw-r--r--arch/powerpc/configs/linkstation_defconfig1583
-rw-r--r--arch/powerpc/configs/lite5200_defconfig931
-rw-r--r--arch/powerpc/configs/ppc64_defconfig4
-rw-r--r--arch/powerpc/configs/ps3_defconfig837
-rw-r--r--arch/powerpc/kernel/Makefile15
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/cpu_setup_ppc970.S16
-rw-r--r--arch/powerpc/kernel/cputable.c62
-rw-r--r--arch/powerpc/kernel/crash.c4
-rw-r--r--arch/powerpc/kernel/dma_64.c249
-rw-r--r--arch/powerpc/kernel/entry_64.S51
-rw-r--r--arch/powerpc/kernel/head_64.S163
-rw-r--r--arch/powerpc/kernel/ibmebus.c9
-rw-r--r--arch/powerpc/kernel/idle.c7
-rw-r--r--arch/powerpc/kernel/idle_power4.S8
-rw-r--r--arch/powerpc/kernel/io.c105
-rw-r--r--arch/powerpc/kernel/iomap.c2
-rw-r--r--arch/powerpc/kernel/iommu.c6
-rw-r--r--arch/powerpc/kernel/irq.c80
-rw-r--r--arch/powerpc/kernel/of_device.c173
-rw-r--r--arch/powerpc/kernel/of_platform.c489
-rw-r--r--arch/powerpc/kernel/pci_32.c96
-rw-r--r--arch/powerpc/kernel/pci_64.c70
-rw-r--r--arch/powerpc/kernel/pci_direct_iommu.c98
-rw-r--r--arch/powerpc/kernel/pci_iommu.c164
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c4
-rw-r--r--arch/powerpc/kernel/prom.c111
-rw-r--r--arch/powerpc/kernel/prom_init.c18
-rw-r--r--arch/powerpc/kernel/prom_parse.c290
-rw-r--r--arch/powerpc/kernel/rtas.c5
-rw-r--r--arch/powerpc/kernel/rtas_flash.c4
-rw-r--r--arch/powerpc/kernel/rtas_pci.c35
-rw-r--r--arch/powerpc/kernel/setup_32.c6
-rw-r--r--arch/powerpc/kernel/setup_64.c18
-rw-r--r--arch/powerpc/kernel/smp-tbsync.c5
-rw-r--r--arch/powerpc/kernel/smp.c1
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c1
-rw-r--r--arch/powerpc/kernel/sysfs.c76
-rw-r--r--arch/powerpc/kernel/time.c7
-rw-r--r--arch/powerpc/kernel/traps.c8
-rw-r--r--arch/powerpc/kernel/vio.c94
-rw-r--r--arch/powerpc/mm/Makefile2
-rw-r--r--arch/powerpc/mm/fault.c25
-rw-r--r--arch/powerpc/mm/hash_native_64.c2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c2
-rw-r--r--arch/powerpc/mm/init_64.c2
-rw-r--r--arch/powerpc/mm/pgtable_32.c33
-rw-r--r--arch/powerpc/mm/pgtable_64.c52
-rw-r--r--arch/powerpc/mm/slb.c13
-rw-r--r--arch/powerpc/oprofile/Makefile1
-rw-r--r--arch/powerpc/oprofile/common.c15
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c724
-rw-r--r--arch/powerpc/platforms/52xx/Makefile9
-rw-r--r--arch/powerpc/platforms/52xx/efika-pci.c119
-rw-r--r--arch/powerpc/platforms/52xx/efika-setup.c150
-rw-r--r--arch/powerpc/platforms/52xx/efika.h19
-rw-r--r--arch/powerpc/platforms/52xx/lite5200.c162
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_common.c126
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c473
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.h53
-rw-r--r--arch/powerpc/platforms/82xx/mpc82xx_ads.c13
-rw-r--r--arch/powerpc/platforms/83xx/mpc832x_mds.c2
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_itx.c3
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.c3
-rw-r--r--arch/powerpc/platforms/83xx/mpc8360e_pb.c2
-rw-r--r--arch/powerpc/platforms/83xx/mpc83xx.h1
-rw-r--r--arch/powerpc/platforms/83xx/pci.c9
-rw-r--r--arch/powerpc/platforms/85xx/misc.c8
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c11
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c10
-rw-r--r--arch/powerpc/platforms/Makefile4
-rw-r--r--arch/powerpc/platforms/cell/Kconfig14
-rw-r--r--arch/powerpc/platforms/cell/Makefile7
-rw-r--r--arch/powerpc/platforms/cell/cbe_cpufreq.c248
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.c71
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.h203
-rw-r--r--arch/powerpc/platforms/cell/cbe_thermal.c226
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c16
-rw-r--r--arch/powerpc/platforms/cell/interrupt.h2
-rw-r--r--arch/powerpc/platforms/cell/io-workarounds.c346
-rw-r--r--arch/powerpc/platforms/cell/iommu.c1049
-rw-r--r--arch/powerpc/platforms/cell/iommu.h65
-rw-r--r--arch/powerpc/platforms/cell/pervasive.c101
-rw-r--r--arch/powerpc/platforms/cell/pmu.c429
-rw-r--r--arch/powerpc/platforms/cell/setup.c78
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c415
-rw-r--r--arch/powerpc/platforms/cell/spu_coredump.c81
-rw-r--r--arch/powerpc/platforms/cell/spu_priv1_mmio.c428
-rw-r--r--arch/powerpc/platforms/cell/spu_priv1_mmio.h26
-rw-r--r--arch/powerpc/platforms/cell/spufs/Makefile2
-rw-r--r--arch/powerpc/platforms/cell/spufs/backing_ops.c31
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c27
-rw-r--r--arch/powerpc/platforms/cell/spufs/coredump.c238
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c536
-rw-r--r--arch/powerpc/platforms/cell/spufs/hw_ops.c51
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c58
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c149
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h33
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c63
-rw-r--r--arch/powerpc/platforms/chrp/chrp.h1
-rw-r--r--arch/powerpc/platforms/chrp/pci.c9
-rw-r--r--arch/powerpc/platforms/chrp/setup.c2
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig30
-rw-r--r--arch/powerpc/platforms/embedded6xx/Makefile1
-rw-r--r--arch/powerpc/platforms/embedded6xx/linkstation.c211
-rw-r--r--arch/powerpc/platforms/embedded6xx/ls_uart.c131
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c94
-rw-r--r--arch/powerpc/platforms/iseries/Makefile8
-rw-r--r--arch/powerpc/platforms/iseries/dt.c15
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c16
-rw-r--r--arch/powerpc/platforms/iseries/ksyms.c6
-rw-r--r--arch/powerpc/platforms/iseries/misc.S35
-rw-r--r--arch/powerpc/platforms/iseries/pci.c372
-rw-r--r--arch/powerpc/platforms/iseries/setup.c48
-rw-r--r--arch/powerpc/platforms/iseries/viopath.c3
-rw-r--r--arch/powerpc/platforms/maple/maple.h2
-rw-r--r--arch/powerpc/platforms/maple/pci.c47
-rw-r--r--arch/powerpc/platforms/maple/setup.c2
-rw-r--r--arch/powerpc/platforms/pasemi/pasemi.h1
-rw-r--r--arch/powerpc/platforms/pasemi/pci.c8
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c17
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c12
-rw-r--r--arch/powerpc/platforms/powermac/feature.c8
-rw-r--r--arch/powerpc/platforms/powermac/pci.c35
-rw-r--r--arch/powerpc/platforms/powermac/pmac.h2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c7
-rw-r--r--arch/powerpc/platforms/ps3/Kconfig43
-rw-r--r--arch/powerpc/platforms/ps3/Makefile4
-rw-r--r--arch/powerpc/platforms/ps3/exports.c27
-rw-r--r--arch/powerpc/platforms/ps3/htab.c277
-rw-r--r--arch/powerpc/platforms/ps3/hvcall.S804
-rw-r--r--arch/powerpc/platforms/ps3/interrupt.c575
-rw-r--r--arch/powerpc/platforms/ps3/mm.c831
-rw-r--r--arch/powerpc/platforms/ps3/os-area.c259
-rw-r--r--arch/powerpc/platforms/ps3/platform.h68
-rw-r--r--arch/powerpc/platforms/ps3/repository.c840
-rw-r--r--arch/powerpc/platforms/ps3/setup.c173
-rw-r--r--arch/powerpc/platforms/ps3/smp.c158
-rw-r--r--arch/powerpc/platforms/ps3/spu.c613
-rw-r--r--arch/powerpc/platforms/ps3/time.c104
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c6
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c90
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c4
-rw-r--r--arch/powerpc/platforms/pseries/pci.c35
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c6
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c3
-rw-r--r--arch/powerpc/platforms/pseries/setup.c5
-rw-r--r--arch/powerpc/platforms/pseries/xics.c68
-rw-r--r--arch/powerpc/sysdev/Makefile5
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c34
-rw-r--r--arch/powerpc/sysdev/dcr-low.S39
-rw-r--r--arch/powerpc/sysdev/dcr.c137
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c28
-rw-r--r--arch/powerpc/sysdev/mpic.c172
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c3
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_fast.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_slow.c4
-rw-r--r--arch/powerpc/sysdev/rom.c31
-rw-r--r--arch/powerpc/sysdev/todc.c392
-rw-r--r--arch/powerpc/sysdev/tsi108_pci.c48
-rw-r--r--arch/powerpc/xmon/Makefile9
-rw-r--r--arch/powerpc/xmon/dis-asm.h31
-rw-r--r--arch/powerpc/xmon/ppc-dis.c29
-rw-r--r--arch/powerpc/xmon/ppc-opc.c778
-rw-r--r--arch/powerpc/xmon/ppc.h39
-rw-r--r--arch/powerpc/xmon/spu-dis.c248
-rw-r--r--arch/powerpc/xmon/spu-insns.h410
-rw-r--r--arch/powerpc/xmon/spu-opc.c44
-rw-r--r--arch/powerpc/xmon/spu.h126
-rw-r--r--arch/powerpc/xmon/xmon.c356
-rw-r--r--arch/ppc/.gitignore1
-rw-r--r--arch/ppc/8260_io/fcc_enet.c21
-rw-r--r--arch/ppc/8xx_io/fec.c21
-rw-r--r--arch/ppc/Kconfig11
-rw-r--r--arch/ppc/boot/images/.gitignore6
-rw-r--r--arch/ppc/boot/lib/.gitignore3
-rw-r--r--arch/ppc/boot/utils/.gitignore3
-rw-r--r--arch/ppc/kernel/setup.c2
-rw-r--r--arch/ppc/kernel/traps.c2
-rw-r--r--arch/ppc/platforms/4xx/bubinga.c2
-rw-r--r--arch/ppc/platforms/4xx/cpci405.c2
-rw-r--r--arch/ppc/platforms/4xx/ep405.c2
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c4
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.c4
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.c4
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c6
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.c2
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c2
-rw-r--r--arch/ppc/platforms/85xx/tqm85xx.c4
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c6
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c4
-rw-r--r--arch/ppc/syslib/mpc8xx_devices.c8
-rw-r--r--arch/s390/appldata/appldata_base.c6
-rw-r--r--arch/sh/Kconfig100
-rw-r--r--arch/sh/Kconfig.debug22
-rw-r--r--arch/sh/Makefile26
-rw-r--r--arch/sh/boards/renesas/r7780rp/Makefile4
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq.c1
-rw-r--r--arch/sh/boards/renesas/r7780rp/psw.c122
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c29
-rw-r--r--arch/sh/boards/se/7206/Makefile7
-rw-r--r--arch/sh/boards/se/7206/io.c123
-rw-r--r--arch/sh/boards/se/7206/irq.c139
-rw-r--r--arch/sh/boards/se/7206/led.c57
-rw-r--r--arch/sh/boards/se/7206/setup.c79
-rw-r--r--arch/sh/boards/se/7619/Makefile5
-rw-r--r--arch/sh/boards/se/7619/io.c102
-rw-r--r--arch/sh/boards/se/7619/setup.c43
-rw-r--r--arch/sh/boards/titan/setup.c27
-rw-r--r--arch/sh/boot/compressed/misc.c3
-rw-r--r--arch/sh/configs/r7780rp_defconfig69
-rw-r--r--arch/sh/configs/se7206_defconfig826
-rw-r--r--arch/sh/drivers/Kconfig9
-rw-r--r--arch/sh/drivers/Makefile2
-rw-r--r--arch/sh/drivers/dma/Makefile4
-rw-r--r--arch/sh/drivers/dma/dma-api.c274
-rw-r--r--arch/sh/drivers/dma/dma-sh.c9
-rw-r--r--arch/sh/drivers/dma/dma-sysfs.c23
-rw-r--r--arch/sh/drivers/pci/ops-titan.c24
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c14
-rw-r--r--arch/sh/drivers/push-switch.c138
-rw-r--r--arch/sh/kernel/Makefile3
-rw-r--r--arch/sh/kernel/cpu/Makefile11
-rw-r--r--arch/sh/kernel/cpu/clock.c27
-rw-r--r--arch/sh/kernel/cpu/init.c2
-rw-r--r--arch/sh/kernel/cpu/irq/Makefile3
-rw-r--r--arch/sh/kernel/cpu/irq/imask.c5
-rw-r--r--arch/sh/kernel/cpu/irq/intc2.c25
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c93
-rw-r--r--arch/sh/kernel/cpu/sh2/Makefile3
-rw-r--r--arch/sh/kernel/cpu/sh2/clock-sh7619.c81
-rw-r--r--arch/sh/kernel/cpu/sh2/entry.S341
-rw-r--r--arch/sh/kernel/cpu/sh2/ex.S46
-rw-r--r--arch/sh/kernel/cpu/sh2/probe.c16
-rw-r--r--arch/sh/kernel/cpu/sh2/setup-sh7619.c53
-rw-r--r--arch/sh/kernel/cpu/sh2a/Makefile10
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7206.c85
-rw-r--r--arch/sh/kernel/cpu/sh2a/probe.c39
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7206.c58
-rw-r--r--arch/sh/kernel/cpu/sh3/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7709.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/entry.S (renamed from arch/sh/kernel/entry.S)546
-rw-r--r--arch/sh/kernel/cpu/sh4/Makefile3
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4-202.c4
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh7780.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/fpu.c25
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c19
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c70
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7780.c36
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c11
-rw-r--r--arch/sh/kernel/early_printk.c44
-rw-r--r--arch/sh/kernel/entry-common.S433
-rw-r--r--arch/sh/kernel/head.S17
-rw-r--r--arch/sh/kernel/irq.c55
-rw-r--r--arch/sh/kernel/process.c32
-rw-r--r--arch/sh/kernel/relocate_kernel.S14
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh/kernel/sh_ksyms.c2
-rw-r--r--arch/sh/kernel/signal.c36
-rw-r--r--arch/sh/kernel/stacktrace.c43
-rw-r--r--arch/sh/kernel/sys_sh.c7
-rw-r--r--arch/sh/kernel/time.c139
-rw-r--r--arch/sh/kernel/timers/Makefile2
-rw-r--r--arch/sh/kernel/timers/timer-cmt.c196
-rw-r--r--arch/sh/kernel/timers/timer-mtu2.c200
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c13
-rw-r--r--arch/sh/kernel/timers/timer.c6
-rw-r--r--arch/sh/kernel/traps.c200
-rw-r--r--arch/sh/mm/Kconfig77
-rw-r--r--arch/sh/mm/cache-sh2.c69
-rw-r--r--arch/sh/mm/cache-sh4.c18
-rw-r--r--arch/sh/mm/clear_page.S18
-rw-r--r--arch/sh/mm/copy_page.S16
-rw-r--r--arch/sh/mm/fault.c161
-rw-r--r--arch/sh/mm/init.c45
-rw-r--r--arch/sh/mm/ioremap.c4
-rw-r--r--arch/sh/mm/pg-dma.c2
-rw-r--r--arch/sh/mm/pg-sh4.c35
-rw-r--r--arch/sh/tools/mach-types2
-rw-r--r--arch/um/drivers/chan_kern.c2
-rw-r--r--arch/um/drivers/mconsole_kern.c4
-rw-r--r--arch/um/drivers/net_kern.c1
-rw-r--r--arch/um/drivers/port_kern.c4
-rw-r--r--arch/x86_64/kernel/mce.c6
-rw-r--r--arch/x86_64/kernel/smpboot.c12
-rw-r--r--arch/x86_64/kernel/time.c4
-rw-r--r--block/Kconfig6
-rw-r--r--block/as-iosched.c7
-rw-r--r--block/blktrace.c35
-rw-r--r--block/cfq-iosched.c8
-rw-r--r--block/ll_rw_blk.c8
-rw-r--r--block/scsi_ioctl.c2
-rw-r--r--crypto/cryptomgr.c7
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/acpi/osl.c25
-rw-r--r--drivers/ata/libata-core.c25
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-scsi.c14
-rw-r--r--drivers/ata/libata.h4
-rw-r--r--drivers/ata/pata_pcmcia.c15
-rw-r--r--drivers/atm/idt77252.c9
-rw-r--r--drivers/block/aoe/aoe.h2
-rw-r--r--drivers/block/aoe/aoecmd.c4
-rw-r--r--drivers/block/aoe/aoedev.c2
-rw-r--r--drivers/block/floppy.c10
-rw-r--r--drivers/block/paride/pd.c8
-rw-r--r--drivers/block/paride/pseudo.h10
-rw-r--r--drivers/block/sx8.c7
-rw-r--r--drivers/block/ub.c8
-rw-r--r--drivers/block/viodasd.c49
-rw-r--r--drivers/bluetooth/bcm203x.c7
-rw-r--r--drivers/bluetooth/bluecard_cs.c38
-rw-r--r--drivers/bluetooth/bt3c_cs.c20
-rw-r--r--drivers/bluetooth/btuart_cs.c20
-rw-r--r--drivers/bluetooth/dtl1_cs.c20
-rw-r--r--drivers/char/cyclades.c9
-rw-r--r--drivers/char/drm/via_dmablit.c6
-rw-r--r--drivers/char/epca.c8
-rw-r--r--drivers/char/esp.c14
-rw-r--r--drivers/char/genrtc.c4
-rw-r--r--drivers/char/hvsi.c16
-rw-r--r--drivers/char/ip2/i2lib.c12
-rw-r--r--drivers/char/ip2/ip2main.c23
-rw-r--r--drivers/char/isicom.c12
-rw-r--r--drivers/char/istallion.c8
-rw-r--r--drivers/char/moxa.c8
-rw-r--r--drivers/char/mxser.c9
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c26
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c26
-rw-r--r--drivers/char/pcmcia/synclink_cs.c15
-rw-r--r--drivers/char/random.c6
-rw-r--r--drivers/char/riscom8.c12
-rw-r--r--drivers/char/serial167.c6
-rw-r--r--drivers/char/sonypi.c4
-rw-r--r--drivers/char/specialix.c14
-rw-r--r--drivers/char/stallion.c10
-rw-r--r--drivers/char/synclink.c9
-rw-r--r--drivers/char/synclink_gt.c10
-rw-r--r--drivers/char/synclinkmp.c8
-rw-r--r--drivers/char/sysrq.c4
-rw-r--r--drivers/char/tpm/tpm.c6
-rw-r--r--drivers/char/tty_io.c31
-rw-r--r--drivers/char/vt.c6
-rw-r--r--drivers/connector/cn_queue.c8
-rw-r--r--drivers/connector/connector.c31
-rw-r--r--drivers/cpufreq/cpufreq.c10
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c7
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c28
-rw-r--r--drivers/i2c/chips/ds1374.c12
-rw-r--r--drivers/i2c/chips/m41t00.c9
-rw-r--r--drivers/ide/legacy/ide-cs.c20
-rw-r--r--drivers/ide/pci/via82cxxx.c4
-rw-r--r--drivers/ieee1394/hosts.c9
-rw-r--r--drivers/ieee1394/hosts.h2
-rw-r--r--drivers/ieee1394/sbp2.c28
-rw-r--r--drivers/ieee1394/sbp2.h2
-rw-r--r--drivers/infiniband/core/addr.c6
-rw-r--r--drivers/infiniband/core/cache.c7
-rw-r--r--drivers/infiniband/core/cm.c19
-rw-r--r--drivers/infiniband/core/cma.c10
-rw-r--r--drivers/infiniband/core/iwcm.c6
-rw-r--r--drivers/infiniband/core/mad.c25
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c18
-rw-r--r--drivers/infiniband/core/sa_query.c10
-rw-r--r--drivers/infiniband/core/uverbs_mem.c7
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_pages.c7
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h16
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c25
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c10
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c22
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c10
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c7
-rw-r--r--drivers/input/keyboard/atkbd.c6
-rw-r--r--drivers/input/keyboard/lkkbd.c6
-rw-r--r--drivers/input/keyboard/sunkbd.c6
-rw-r--r--drivers/input/mouse/psmouse-base.c7
-rw-r--r--drivers/input/serio/libps2.c6
-rw-r--r--drivers/isdn/act2000/capi.c4
-rw-r--r--drivers/isdn/act2000/capi.h2
-rw-r--r--drivers/isdn/act2000/module.c18
-rw-r--r--drivers/isdn/capi/kcapi.c14
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c36
-rw-r--r--drivers/isdn/hisax/amd7930_fn.c7
-rw-r--r--drivers/isdn/hisax/avma1_cs.c36
-rw-r--r--drivers/isdn/hisax/config.c9
-rw-r--r--drivers/isdn/hisax/elsa_cs.c17
-rw-r--r--drivers/isdn/hisax/hfc4s8s_l1.c5
-rw-r--r--drivers/isdn/hisax/hfc_2bds0.c9
-rw-r--r--drivers/isdn/hisax/hfc_pci.c6
-rw-r--r--drivers/isdn/hisax/hfc_sx.c6
-rw-r--r--drivers/isdn/hisax/icc.c6
-rw-r--r--drivers/isdn/hisax/isac.c6
-rw-r--r--drivers/isdn/hisax/isar.c6
-rw-r--r--drivers/isdn/hisax/isdnl1.c6
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c10
-rw-r--r--drivers/isdn/hisax/teles_cs.c17
-rw-r--r--drivers/isdn/hisax/w6692.c6
-rw-r--r--drivers/isdn/hysdn/boardergo.c5
-rw-r--r--drivers/isdn/i4l/isdn_net.c6
-rw-r--r--drivers/isdn/pcbit/drv.c4
-rw-r--r--drivers/isdn/pcbit/layer2.c6
-rw-r--r--drivers/isdn/pcbit/pcbit.h2
-rw-r--r--drivers/macintosh/Kconfig7
-rw-r--r--drivers/macintosh/Makefile1
-rw-r--r--drivers/macintosh/adb.c4
-rw-r--r--drivers/macintosh/rack-meter.c616
-rw-r--r--drivers/macintosh/smu.c7
-rw-r--r--drivers/macintosh/therm_adt746x.c2
-rw-r--r--drivers/macintosh/therm_pm72.c5
-rw-r--r--drivers/macintosh/therm_windtunnel.c7
-rw-r--r--drivers/md/dm-crypt.c8
-rw-r--r--drivers/md/dm-mpath.c18
-rw-r--r--drivers/md/dm-raid1.c4
-rw-r--r--drivers/md/dm-snap.c9
-rw-r--r--drivers/md/kcopyd.c4
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c9
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c18
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c19
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c7
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h2
-rw-r--r--drivers/media/video/cpia_pp.c20
-rw-r--r--drivers/media/video/cx88/cx88-input.c6
-rw-r--r--drivers/media/video/ir-kbd-i2c.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c13
-rw-r--r--drivers/media/video/saa6588.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c9
-rw-r--r--drivers/message/fusion/mptfc.c14
-rw-r--r--drivers/message/fusion/mptlan.c29
-rw-r--r--drivers/message/fusion/mptsas.c25
-rw-r--r--drivers/message/fusion/mptspi.c14
-rw-r--r--drivers/message/i2o/driver.c2
-rw-r--r--drivers/message/i2o/exec-osm.c13
-rw-r--r--drivers/message/i2o/i2o_block.c15
-rw-r--r--drivers/message/i2o/i2o_block.h2
-rw-r--r--drivers/misc/tifm_7xx1.c18
-rw-r--r--drivers/mmc/mmc.c14
-rw-r--r--drivers/mmc/mmc.h2
-rw-r--r--drivers/mmc/mmc_sysfs.c10
-rw-r--r--drivers/mmc/tifm_sd.c28
-rw-r--r--drivers/net/8139too.c26
-rw-r--r--drivers/net/bnx2.c6
-rw-r--r--drivers/net/cassini.c6
-rw-r--r--drivers/net/chelsio/common.h2
-rw-r--r--drivers/net/chelsio/cphy.h2
-rw-r--r--drivers/net/chelsio/cxgb2.c16
-rw-r--r--drivers/net/chelsio/my3126.c8
-rw-r--r--drivers/net/e100.c8
-rw-r--r--drivers/net/e1000/e1000_main.c10
-rw-r--r--drivers/net/ehea/ehea_main.c9
-rw-r--r--drivers/net/hamradio/baycom_epp.c14
-rw-r--r--drivers/net/hamradio/dmascc.c8
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.h6
-rw-r--r--drivers/net/ibmveth.c4
-rw-r--r--drivers/net/ibmveth.h1
-rw-r--r--drivers/net/irda/mcs7780.c6
-rw-r--r--drivers/net/irda/sir-dev.h2
-rw-r--r--drivers/net/irda/sir_dev.c8
-rw-r--r--drivers/net/iseries_veth.c12
-rw-r--r--drivers/net/ixgb/ixgb_main.c10
-rw-r--r--drivers/net/mv643xx_eth.c9
-rw-r--r--drivers/net/myri10ge/myri10ge.c7
-rw-r--r--drivers/net/netxen/netxen_nic.h5
-rw-r--r--drivers/net/netxen/netxen_nic_init.c5
-rw-r--r--drivers/net/netxen/netxen_nic_main.c19
-rw-r--r--drivers/net/ns83820.c10
-rw-r--r--drivers/net/pcmcia/3c574_cs.c25
-rw-r--r--drivers/net/pcmcia/3c589_cs.c19
-rw-r--r--drivers/net/pcmcia/axnet_cs.c6
-rw-r--r--drivers/net/pcmcia/com20020_cs.c13
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c40
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c12
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c12
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c30
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c59
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c40
-rw-r--r--drivers/net/phy/fixed.c2
-rw-r--r--drivers/net/phy/phy.c9
-rw-r--r--drivers/net/plip.c38
-rw-r--r--drivers/net/qla3xxx.c20
-rw-r--r--drivers/net/qla3xxx.h4
-rw-r--r--drivers/net/r8169.c23
-rw-r--r--drivers/net/s2io.c16
-rw-r--r--drivers/net/s2io.h2
-rw-r--r--drivers/net/sis190.c13
-rw-r--r--drivers/net/skge.c15
-rw-r--r--drivers/net/skge.h2
-rw-r--r--drivers/net/smc91x.c15
-rw-r--r--drivers/net/spider_net.c27
-rw-r--r--drivers/net/sungem.c6
-rw-r--r--drivers/net/tg3.c6
-rw-r--r--drivers/net/tlan.c23
-rw-r--r--drivers/net/tlan.h1
-rw-r--r--drivers/net/tokenring/ibmtr.c2
-rw-r--r--drivers/net/tulip/21142.c7
-rw-r--r--drivers/net/tulip/de4x5.c8
-rw-r--r--drivers/net/tulip/timer.c7
-rw-r--r--drivers/net/tulip/tulip.h7
-rw-r--r--drivers/net/tulip/tulip_core.c3
-rw-r--r--drivers/net/wan/pc300_tty.c23
-rw-r--r--drivers/net/wireless/airo_cs.c19
-rw-r--r--drivers/net/wireless/atmel_cs.c11
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c20
-rw-r--r--drivers/net/wireless/hostap/hostap.h2
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c19
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c13
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c21
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c6
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c8
-rw-r--r--drivers/net/wireless/ipw2100.c47
-rw-r--r--drivers/net/wireless/ipw2100.h10
-rw-r--r--drivers/net/wireless/ipw2200.c227
-rw-r--r--drivers/net/wireless/ipw2200.h16
-rw-r--r--drivers/net/wireless/netwave_cs.c18
-rw-r--r--drivers/net/wireless/orinoco.c28
-rw-r--r--drivers/net/wireless/orinoco_cs.c19
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c8
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.h4
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c5
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.c4
-rw-r--r--drivers/net/wireless/prism54/islpci_eth.h2
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c2
-rw-r--r--drivers/net/wireless/ray_cs.c30
-rw-r--r--drivers/net/wireless/spectrum_cs.c19
-rw-r--r--drivers/net/wireless/wavelan_cs.c33
-rw-r--r--drivers/net/wireless/wl3501_cs.c15
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c30
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h6
-rw-r--r--drivers/oprofile/cpu_buffer.c9
-rw-r--r--drivers/oprofile/cpu_buffer.h2
-rw-r--r--drivers/parport/parport_cs.c9
-rw-r--r--drivers/pci/hotplug/shpchp.h4
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c19
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c2
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c8
-rw-r--r--drivers/pcmcia/at91_cf.c69
-rw-r--r--drivers/pcmcia/cs_internal.h2
-rw-r--r--drivers/pcmcia/ds.c274
-rw-r--r--drivers/pcmcia/m32r_cfc.c2
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c7
-rw-r--r--drivers/pcmcia/pd6729.c8
-rw-r--r--drivers/pcmcia/socket_sysfs.c4
-rw-r--r--drivers/ps3/Makefile1
-rw-r--r--drivers/ps3/system-bus.c362
-rw-r--r--drivers/rtc/rtc-dev.c7
-rw-r--r--drivers/s390/block/dasd.c10
-rw-r--r--drivers/s390/cio/css.c9
-rw-r--r--drivers/s390/crypto/ap_bus.c6
-rw-r--r--drivers/s390/net/lcs.c8
-rw-r--r--drivers/s390/net/qeth_main.c6
-rw-r--r--drivers/scsi/53c700.c7
-rw-r--r--drivers/scsi/BusLogic.c12
-rw-r--r--drivers/scsi/Kconfig59
-rw-r--r--drivers/scsi/Makefile7
-rw-r--r--drivers/scsi/NCR5380.c11
-rw-r--r--drivers/scsi/NCR5380.h4
-rw-r--r--drivers/scsi/NCR53c406a.c5
-rw-r--r--drivers/scsi/aacraid/aacraid.h4
-rw-r--r--drivers/scsi/aacraid/commsup.c23
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/aha1740.c10
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm_pci.c1
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.c8
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_pci.h1
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c9
-rw-r--r--drivers/scsi/aic94xx/aic94xx_scb.c121
-rw-r--r--drivers/scsi/fd_mcs.c2
-rw-r--r--drivers/scsi/hosts.c8
-rw-r--r--drivers/scsi/ibmvscsi/Makefile2
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c960
-rw-r--r--drivers/scsi/imm.c12
-rw-r--r--drivers/scsi/initio.c2
-rw-r--r--drivers/scsi/ipr.c322
-rw-r--r--drivers/scsi/ipr.h83
-rw-r--r--drivers/scsi/ips.c28
-rw-r--r--drivers/scsi/ips.h9
-rw-r--r--drivers/scsi/libiscsi.c7
-rw-r--r--drivers/scsi/libsas/sas_discover.c22
-rw-r--r--drivers/scsi/libsas/sas_event.c14
-rw-r--r--drivers/scsi/libsas/sas_expander.c36
-rw-r--r--drivers/scsi/libsas/sas_init.c10
-rw-r--r--drivers/scsi/libsas/sas_internal.h12
-rw-r--r--drivers/scsi/libsas/sas_phy.c45
-rw-r--r--drivers/scsi/libsas/sas_port.c30
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c92
-rw-r--r--drivers/scsi/libsrp.c441
-rw-r--r--drivers/scsi/lpfc/lpfc.h6
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c118
-rw-r--r--drivers/scsi/lpfc/lpfc_ct.c24
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c34
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c229
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h35
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c136
-rw-r--r--drivers/scsi/lpfc/lpfc_logmsg.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c9
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c56
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c42
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h2
-rw-r--r--drivers/scsi/megaraid.c13
-rw-r--r--drivers/scsi/megaraid.h3
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c4
-rw-r--r--drivers/scsi/ncr53c8xx.c19
-rw-r--r--drivers/scsi/oktagon_esp.c6
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c7
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c5
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c6
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c11
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c12
-rw-r--r--drivers/scsi/ppa.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c94
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c66
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c8
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.c4
-rw-r--r--drivers/scsi/qla4xxx/ql4_def.h105
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h7
-rw-r--r--drivers/scsi/qla4xxx/ql4_glbl.h3
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c47
-rw-r--r--drivers/scsi/qla4xxx/ql4_inline.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_iocb.c6
-rw-r--r--drivers/scsi/qla4xxx/ql4_isr.c1
-rw-r--r--drivers/scsi/qla4xxx/ql4_nvram.c70
-rw-r--r--drivers/scsi/qla4xxx/ql4_nvram.h4
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c124
-rw-r--r--drivers/scsi/qla4xxx/ql4_version.h7
-rw-r--r--drivers/scsi/scsi.c45
-rw-r--r--drivers/scsi/scsi_error.c33
-rw-r--r--drivers/scsi/scsi_lib.c346
-rw-r--r--drivers/scsi/scsi_priv.h3
-rw-r--r--drivers/scsi/scsi_scan.c232
-rw-r--r--drivers/scsi/scsi_sysfs.c10
-rw-r--r--drivers/scsi/scsi_tgt_if.c352
-rw-r--r--drivers/scsi/scsi_tgt_lib.c745
-rw-r--r--drivers/scsi/scsi_tgt_priv.h25
-rw-r--r--drivers/scsi/scsi_transport_fc.c60
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c8
-rw-r--r--drivers/scsi/scsi_transport_spi.c7
-rw-r--r--drivers/scsi/scsi_wait_scan.c31
-rw-r--r--drivers/scsi/sd.c29
-rw-r--r--drivers/scsi/st.c16
-rw-r--r--drivers/scsi/stex.c130
-rw-r--r--drivers/scsi/t128.h39
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c2
-rw-r--r--drivers/serial/mcfserial.c54
-rw-r--r--drivers/serial/mpc52xx_uart.c469
-rw-r--r--drivers/serial/serial_cs.c67
-rw-r--r--drivers/serial/sh-sci.c6
-rw-r--r--drivers/serial/sh-sci.h37
-rw-r--r--drivers/spi/pxa2xx_spi.c9
-rw-r--r--drivers/spi/spi_bitbang.c7
-rw-r--r--drivers/telephony/ixj_pcmcia.c37
-rw-r--r--drivers/usb/atm/cxacru.c12
-rw-r--r--drivers/usb/atm/speedtch.c15
-rw-r--r--drivers/usb/atm/ueagle-atm.c6
-rw-r--r--drivers/usb/class/cdc-acm.c6
-rw-r--r--drivers/usb/core/hub.c20
-rw-r--r--drivers/usb/core/message.c7
-rw-r--r--drivers/usb/core/usb.c9
-rw-r--r--drivers/usb/gadget/ether.c6
-rw-r--r--drivers/usb/host/sl811_cs.c15
-rw-r--r--drivers/usb/host/u132-hcd.c62
-rw-r--r--drivers/usb/input/hid-core.c7
-rw-r--r--drivers/usb/misc/appledisplay.c11
-rw-r--r--drivers/usb/misc/ftdi-elan.c86
-rw-r--r--drivers/usb/misc/phidgetkit.c21
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c11
-rw-r--r--drivers/usb/net/kaweth.c9
-rw-r--r--drivers/usb/net/pegasus.c6
-rw-r--r--drivers/usb/net/pegasus.h2
-rw-r--r--drivers/usb/net/usbnet.c7
-rw-r--r--drivers/usb/serial/aircable.c13
-rw-r--r--drivers/usb/serial/digi_acceleport.c14
-rw-r--r--drivers/usb/serial/ftdi_sio.c19
-rw-r--r--drivers/usb/serial/keyspan_pda.c22
-rw-r--r--drivers/usb/serial/usb-serial.c7
-rw-r--r--drivers/usb/serial/whiteheat.c15
-rw-r--r--drivers/video/console/fbcon.c6
-rw-r--r--drivers/video/platinumfb.c5
-rw-r--r--drivers/video/pxafb.c7
-rw-r--r--fs/9p/mux.c16
-rw-r--r--fs/aio.c16
-rw-r--r--fs/binfmt_elf.c8
-rw-r--r--fs/bio.c6
-rw-r--r--fs/configfs/dir.c9
-rw-r--r--fs/file.c6
-rw-r--r--fs/gfs2/glock.c8
-rw-r--r--fs/ncpfs/inode.c8
-rw-r--r--fs/ncpfs/sock.c20
-rw-r--r--fs/nfs/client.c2
-rw-r--r--fs/nfs/namespace.c8
-rw-r--r--fs/nfs/nfs4_fs.h2
-rw-r--r--fs/nfs/nfs4renewd.c5
-rw-r--r--fs/nfsd/nfs4state.c7
-rw-r--r--fs/ocfs2/alloc.c99
-rw-r--r--fs/ocfs2/alloc.h2
-rw-r--r--fs/ocfs2/aops.c22
-rw-r--r--fs/ocfs2/aops.h2
-rw-r--r--fs/ocfs2/cluster/heartbeat.c10
-rw-r--r--fs/ocfs2/cluster/quorum.c4
-rw-r--r--fs/ocfs2/cluster/tcp.c78
-rw-r--r--fs/ocfs2/cluster/tcp_internal.h8
-rw-r--r--fs/ocfs2/dir.c33
-rw-r--r--fs/ocfs2/dir.h2
-rw-r--r--fs/ocfs2/dlm/dlmcommon.h2
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c5
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c5
-rw-r--r--fs/ocfs2/dlm/userdlm.c10
-rw-r--r--fs/ocfs2/dlmglue.c60
-rw-r--r--fs/ocfs2/dlmglue.h9
-rw-r--r--fs/ocfs2/export.c2
-rw-r--r--fs/ocfs2/file.c343
-rw-r--r--fs/ocfs2/file.h11
-rw-r--r--fs/ocfs2/inode.c33
-rw-r--r--fs/ocfs2/inode.h9
-rw-r--r--fs/ocfs2/ioctl.c10
-rw-r--r--fs/ocfs2/journal.c278
-rw-r--r--fs/ocfs2/journal.h80
-rw-r--r--fs/ocfs2/localalloc.c126
-rw-r--r--fs/ocfs2/localalloc.h3
-rw-r--r--fs/ocfs2/mmap.c11
-rw-r--r--fs/ocfs2/namei.c296
-rw-r--r--fs/ocfs2/namei.h2
-rw-r--r--fs/ocfs2/ocfs2.h6
-rw-r--r--fs/ocfs2/suballoc.c174
-rw-r--r--fs/ocfs2/suballoc.h16
-rw-r--r--fs/ocfs2/super.c34
-rw-r--r--fs/ocfs2/symlink.c4
-rw-r--r--fs/reiserfs/journal.c12
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c21
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c9
-rw-r--r--include/asm-arm/arch-omap/irda.h2
-rw-r--r--include/asm-avr32/types.h5
-rw-r--r--include/asm-h8300/types.h6
-rw-r--r--include/asm-i386/atomic.h2
-rw-r--r--include/asm-i386/spinlock_types.h4
-rw-r--r--include/asm-i386/types.h10
-rw-r--r--include/asm-m68knommu/irq.h1
-rw-r--r--include/asm-m68knommu/rtc.h1
-rw-r--r--include/asm-m68knommu/ucontext.h6
-rw-r--r--include/asm-mips/atomic.h39
-rw-r--r--include/asm-mips/barrier.h132
-rw-r--r--include/asm-mips/bitops.h27
-rw-r--r--include/asm-mips/compat.h68
-rw-r--r--include/asm-mips/futex.h22
-rw-r--r--include/asm-mips/i8259.h37
-rw-r--r--include/asm-mips/pgtable-32.h6
-rw-r--r--include/asm-mips/pgtable-64.h4
-rw-r--r--include/asm-mips/sn/klconfig.h2
-rw-r--r--include/asm-mips/spinlock.h53
-rw-r--r--include/asm-mips/system.h156
-rw-r--r--include/asm-mips/types.h10
-rw-r--r--include/asm-powerpc/Kbuild1
-rw-r--r--include/asm-powerpc/cell-pmu.h113
-rw-r--r--include/asm-powerpc/cputable.h31
-rw-r--r--include/asm-powerpc/dbdma.h8
-rw-r--r--include/asm-powerpc/dcr-mmio.h51
-rw-r--r--include/asm-powerpc/dcr-native.h39
-rw-r--r--include/asm-powerpc/dcr.h42
-rw-r--r--include/asm-powerpc/device.h19
-rw-r--r--include/asm-powerpc/dma-mapping.h182
-rw-r--r--include/asm-powerpc/eeh.h213
-rw-r--r--include/asm-powerpc/elf.h13
-rw-r--r--include/asm-powerpc/firmware.h17
-rw-r--r--include/asm-powerpc/hw_irq.h44
-rw-r--r--include/asm-powerpc/ibmebus.h1
-rw-r--r--include/asm-powerpc/ide.h8
-rw-r--r--include/asm-powerpc/immap_qe.h17
-rw-r--r--include/asm-powerpc/io-defs.h59
-rw-r--r--include/asm-powerpc/io.h845
-rw-r--r--include/asm-powerpc/iommu.h34
-rw-r--r--include/asm-powerpc/irq.h4
-rw-r--r--include/asm-powerpc/iseries/iommu.h4
-rw-r--r--include/asm-powerpc/lv1call.h345
-rw-r--r--include/asm-powerpc/machdep.h18
-rw-r--r--include/asm-powerpc/mmu.h15
-rw-r--r--include/asm-powerpc/mpc52xx.h254
-rw-r--r--include/asm-powerpc/mpc85xx.h8
-rw-r--r--include/asm-powerpc/mpic.h39
-rw-r--r--include/asm-powerpc/of_device.h36
-rw-r--r--include/asm-powerpc/of_platform.h60
-rw-r--r--include/asm-powerpc/oprofile_impl.h3
-rw-r--r--include/asm-powerpc/paca.h3
-rw-r--r--include/asm-powerpc/pci-bridge.h1
-rw-r--r--include/asm-powerpc/pci.h10
-rw-r--r--include/asm-powerpc/ppc-pci.h13
-rw-r--r--include/asm-powerpc/processor.h4
-rw-r--r--include/asm-powerpc/prom.h15
-rw-r--r--include/asm-powerpc/ps3.h462
-rw-r--r--include/asm-powerpc/rtas.h2
-rw-r--r--include/asm-powerpc/sparsemem.h6
-rw-r--r--include/asm-powerpc/spu.h30
-rw-r--r--include/asm-powerpc/spu_csa.h1
-rw-r--r--include/asm-powerpc/spu_info.h54
-rw-r--r--include/asm-powerpc/spu_priv1.h46
-rw-r--r--include/asm-powerpc/todc.h487
-rw-r--r--include/asm-powerpc/topology.h7
-rw-r--r--include/asm-powerpc/tsi108.h4
-rw-r--r--include/asm-powerpc/types.h10
-rw-r--r--include/asm-powerpc/uaccess.h4
-rw-r--r--include/asm-powerpc/unistd.h12
-rw-r--r--include/asm-powerpc/vio.h1
-rw-r--r--include/asm-powerpc/xmon.h2
-rw-r--r--include/asm-ppc/io.h28
-rw-r--r--include/asm-ppc/m48t35.h2
-rw-r--r--include/asm-ppc/mpc52xx.h11
-rw-r--r--include/asm-ppc/mpc83xx.h8
-rw-r--r--include/asm-ppc/mpc85xx.h8
-rw-r--r--include/asm-ppc/pci-bridge.h1
-rw-r--r--include/asm-s390/types.h10
-rw-r--r--include/asm-sh/atomic.h48
-rw-r--r--include/asm-sh/bugs.h8
-rw-r--r--include/asm-sh/clock.h12
-rw-r--r--include/asm-sh/cpu-sh2/cache.h22
-rw-r--r--include/asm-sh/cpu-sh2/freq.h18
-rw-r--r--include/asm-sh/cpu-sh2/mmu_context.h16
-rw-r--r--include/asm-sh/cpu-sh2/timer.h6
-rw-r--r--include/asm-sh/cpu-sh2a/addrspace.h1
-rw-r--r--include/asm-sh/cpu-sh2a/cache.h39
-rw-r--r--include/asm-sh/cpu-sh2a/cacheflush.h1
-rw-r--r--include/asm-sh/cpu-sh2a/dma.h1
-rw-r--r--include/asm-sh/cpu-sh2a/freq.h18
-rw-r--r--include/asm-sh/cpu-sh2a/mmu_context.h1
-rw-r--r--include/asm-sh/cpu-sh2a/timer.h1
-rw-r--r--include/asm-sh/cpu-sh2a/ubc.h1
-rw-r--r--include/asm-sh/cpu-sh2a/watchdog.h1
-rw-r--r--include/asm-sh/dma.h40
-rw-r--r--include/asm-sh/elf.h2
-rw-r--r--include/asm-sh/entry-macros.S33
-rw-r--r--include/asm-sh/irq-sh73180.h314
-rw-r--r--include/asm-sh/irq-sh7343.h317
-rw-r--r--include/asm-sh/irq-sh7780.h311
-rw-r--r--include/asm-sh/irq.h620
-rw-r--r--include/asm-sh/irqflags.h123
-rw-r--r--include/asm-sh/mmu_context.h44
-rw-r--r--include/asm-sh/page.h35
-rw-r--r--include/asm-sh/pgalloc.h20
-rw-r--r--include/asm-sh/pgtable-2level.h70
-rw-r--r--include/asm-sh/pgtable.h371
-rw-r--r--include/asm-sh/processor.h24
-rw-r--r--include/asm-sh/push-switch.h28
-rw-r--r--include/asm-sh/rwsem.h27
-rw-r--r--include/asm-sh/se7206.h13
-rw-r--r--include/asm-sh/system.h101
-rw-r--r--include/asm-sh/thread_info.h8
-rw-r--r--include/asm-sh/timer.h23
-rw-r--r--include/asm-sh/titan.h32
-rw-r--r--include/asm-sh/types.h10
-rw-r--r--include/asm-sh/unistd.h32
-rw-r--r--include/asm-x86_64/atomic.h2
-rw-r--r--include/asm-x86_64/spinlock_types.h4
-rw-r--r--include/asm-x86_64/types.h3
-rw-r--r--include/linux/aio.h2
-rw-r--r--include/linux/connector.h4
-rw-r--r--include/linux/cpu.h8
-rw-r--r--include/linux/elf.h7
-rw-r--r--include/linux/i2o.h2
-rw-r--r--include/linux/kbd_kern.h2
-rw-r--r--include/linux/libata.h7
-rw-r--r--include/linux/mmc/host.h2
-rw-r--r--include/linux/ncp_fs_sb.h8
-rw-r--r--include/linux/netpoll.h2
-rw-r--r--include/linux/nfs_fs_sb.h2
-rw-r--r--include/linux/reiserfs_fs_sb.h3
-rw-r--r--include/linux/relay.h2
-rw-r--r--include/linux/sunrpc/rpc_pipe_fs.h2
-rw-r--r--include/linux/sunrpc/xprt.h2
-rw-r--r--include/linux/tty.h2
-rw-r--r--include/linux/types.h14
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/linux/workqueue.h145
-rw-r--r--include/net/ieee80211softmac.h4
-rw-r--r--include/net/inet_timewait_sock.h2
-rw-r--r--include/net/sctp/structs.h2
-rw-r--r--include/pcmcia/ss.h5
-rw-r--r--include/scsi/libsas.h37
-rw-r--r--include/scsi/libsrp.h77
-rw-r--r--include/scsi/scsi_cmnd.h10
-rw-r--r--include/scsi/scsi_device.h30
-rw-r--r--include/scsi/scsi_host.h69
-rw-r--r--include/scsi/scsi_tgt.h19
-rw-r--r--include/scsi/scsi_tgt_if.h90
-rw-r--r--include/scsi/scsi_transport_fc.h4
-rw-r--r--include/scsi/scsi_transport_iscsi.h2
-rw-r--r--include/scsi/scsi_transport_sas.h2
-rw-r--r--include/sound/ac97_codec.h2
-rw-r--r--include/sound/ak4114.h2
-rw-r--r--ipc/util.c7
-rw-r--r--kernel/kmod.c16
-rw-r--r--kernel/kthread.c13
-rw-r--r--kernel/power/poweroff.c4
-rw-r--r--kernel/relay.c10
-rw-r--r--kernel/sys.c4
-rw-r--r--kernel/workqueue.c109
-rw-r--r--lib/iomap.c32
-rw-r--r--mm/filemap.c1
-rw-r--r--mm/nommu.c12
-rw-r--r--mm/slab.c12
-rw-r--r--mm/swap.c4
-rw-r--r--net/atm/lec.c9
-rw-r--r--net/atm/lec.h2
-rw-r--r--net/bluetooth/hci_sysfs.c12
-rw-r--r--net/bridge/br_if.c10
-rw-r--r--net/bridge/br_private.h2
-rw-r--r--net/core/link_watch.c13
-rw-r--r--net/core/netpoll.c11
-rw-r--r--net/dccp/minisocks.c3
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c18
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c23
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_event.c12
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_priv.h13
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_scan.c13
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c6
-rw-r--r--net/ipv4/inet_timewait_sock.c5
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c6
-rw-r--r--net/ipv4/tcp_minisocks.c3
-rw-r--r--net/irda/ircomm/ircomm_tty.c11
-rw-r--r--net/sctp/associola.c11
-rw-r--r--net/sctp/endpointola.c10
-rw-r--r--net/sctp/inqueue.c9
-rw-r--r--net/sunrpc/cache.c8
-rw-r--r--net/sunrpc/rpc_pipe.c8
-rw-r--r--net/sunrpc/sched.c8
-rw-r--r--net/sunrpc/xprt.c7
-rw-r--r--net/sunrpc/xprtsock.c20
-rw-r--r--net/xfrm/xfrm_policy.c8
-rw-r--r--net/xfrm/xfrm_state.c8
-rw-r--r--security/keys/key.c6
-rw-r--r--security/selinux/avc.c2
-rw-r--r--security/selinux/hooks.c2
-rw-r--r--security/selinux/include/avc.h8
-rw-r--r--sound/aoa/aoa-gpio.h2
-rw-r--r--sound/aoa/core/snd-aoa-gpio-feature.c16
-rw-r--r--sound/aoa/core/snd-aoa-gpio-pmf.c16
-rw-r--r--sound/i2c/other/ak4114.c8
-rw-r--r--sound/pci/ac97/ac97_codec.c7
-rw-r--r--sound/pci/hda/hda_codec.c10
-rw-r--r--sound/pci/hda/hda_local.h1
-rw-r--r--sound/pcmcia/pdaudiocf/pdaudiocf.c24
-rw-r--r--sound/pcmcia/vx/vxpocket.c26
-rw-r--r--sound/ppc/tumbler.c8
1032 files changed, 40295 insertions, 14596 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index db9499adbed4..36526a1e76d7 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -190,9 +190,13 @@ quiet_cmd_fig2png = FIG2PNG $@
190### 190###
191# Help targets as used by the top-level makefile 191# Help targets as used by the top-level makefile
192dochelp: 192dochelp:
193 @echo ' Linux kernel internal documentation in different formats:' 193 @echo ' Linux kernel internal documentation in different formats:'
194 @echo ' xmldocs (XML DocBook), psdocs (Postscript), pdfdocs (PDF)' 194 @echo ' htmldocs - HTML'
195 @echo ' htmldocs (HTML), mandocs (man pages, use installmandocs to install)' 195 @echo ' installmandocs - install man pages generated by mandocs'
196 @echo ' mandocs - man pages'
197 @echo ' pdfdocs - PDF'
198 @echo ' psdocs - Postscript'
199 @echo ' xmldocs - XML DocBook'
196 200
197### 201###
198# Temporary files left by various tools 202# Temporary files left by various tools
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 15e4fed127f6..2e1898e4e8fd 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1416,6 +1416,11 @@ and is between 256 and 4096 characters. It is defined in the file
1416 1416
1417 scsi_logging= [SCSI] 1417 scsi_logging= [SCSI]
1418 1418
1419 scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are
1420 discovered. async scans them in kernel threads,
1421 allowing boot to proceed. none ignores them, expecting
1422 user space to do the scan.
1423
1419 selinux [SELINUX] Disable or enable SELinux at boot time. 1424 selinux [SELINUX] Disable or enable SELinux at boot time.
1420 Format: { "0" | "1" } 1425 Format: { "0" | "1" }
1421 See security/selinux/Kconfig help text. 1426 See security/selinux/Kconfig help text.
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index 4ac2d641fcb6..b3bd36668db3 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -6,6 +6,8 @@
6 IBM Corp. 6 IBM Corp.
7(c) 2005 Becky Bruce <becky.bruce at freescale.com>, 7(c) 2005 Becky Bruce <becky.bruce at freescale.com>,
8 Freescale Semiconductor, FSL SOC and 32-bit additions 8 Freescale Semiconductor, FSL SOC and 32-bit additions
9(c) 2006 MontaVista Software, Inc.
10 Flash chip node definition
9 11
10 May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet. 12 May 18, 2005: Rev 0.1 - Initial draft, no chapter III yet.
11 13
@@ -1693,6 +1695,43 @@ platforms are moved over to use the flattened-device-tree model.
1693 }; 1695 };
1694 }; 1696 };
1695 1697
1698 g) Flash chip nodes
1699
1700 Flash chips (Memory Technology Devices) are often used for solid state
1701 file systems on embedded devices.
1702
1703 Required properties:
1704
1705 - device_type : has to be "rom"
1706 - compatible : Should specify what this ROM device is compatible with
1707 (i.e. "onenand"). Currently, this is most likely to be "direct-mapped"
1708 (which corresponds to the MTD physmap mapping driver).
1709 - regs : Offset and length of the register set (or memory mapping) for
1710 the device.
1711
1712 Recommended properties :
1713
1714 - bank-width : Width of the flash data bus in bytes. Required
1715 for the NOR flashes (compatible == "direct-mapped" and others) ONLY.
1716 - partitions : Several pairs of 32-bit values where the first value is
1717 partition's offset from the start of the device and the second one is
1718 partition size in bytes with LSB used to signify a read only
1719 partititon (so, the parition size should always be an even number).
1720 - partition-names : The list of concatenated zero terminated strings
1721 representing the partition names.
1722
1723 Example:
1724
1725 flash@ff000000 {
1726 device_type = "rom";
1727 compatible = "direct-mapped";
1728 regs = <ff000000 01000000>;
1729 bank-width = <4>;
1730 partitions = <00000000 00f80000
1731 00f80000 00080001>;
1732 partition-names = "fs\0firmware";
1733 };
1734
1696 More devices will be defined as this spec matures. 1735 More devices will be defined as this spec matures.
1697 1736
1698 1737
diff --git a/Documentation/powerpc/mpc52xx-device-tree-bindings.txt b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt
new file mode 100644
index 000000000000..d077d764f82b
--- /dev/null
+++ b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt
@@ -0,0 +1,189 @@
1MPC52xx Device Tree Bindings
2----------------------------
3
4(c) 2006 Secret Lab Technologies Ltd
5Grant Likely <grant.likely at secretlab.ca>
6
7I - Introduction
8================
9Boards supported by the arch/powerpc architecture require device tree be
10passed by the boot loader to the kernel at boot time. The device tree
11describes what devices are present on the board and how they are
12connected. The device tree can either be passed as a binary blob (as
13described in Documentation/powerpc/booting-without-of.txt), or passed
14by Open Firmare (IEEE 1275) compatible firmware using an OF compatible
15client interface API.
16
17This document specifies the requirements on the device-tree for mpc52xx
18based boards. These requirements are above and beyond the details
19specified in either the OpenFirmware spec or booting-without-of.txt
20
21All new mpc52xx-based boards are expected to match this document. In
22cases where this document is not sufficient to support a new board port,
23this document should be updated as part of adding the new board support.
24
25II - Philosophy
26===============
27The core of this document is naming convention. The whole point of
28defining this convention is to reduce or eliminate the number of
29special cases required to support a 52xx board. If all 52xx boards
30follow the same convention, then generic 52xx support code will work
31rather than coding special cases for each new board.
32
33This section tries to capture the thought process behind why the naming
34convention is what it is.
35
361. Node names
37-------------
38There is strong convention/requirements already established for children
39of the root node. 'cpus' describes the processor cores, 'memory'
40describes memory, and 'chosen' provides boot configuration. Other nodes
41are added to describe devices attached to the processor local bus.
42Following convention already established with other system-on-chip
43processors, MPC52xx boards must have an 'soc5200' node as a child of the
44root node.
45
46The soc5200 node holds child nodes for all on chip devices. Child nodes
47are typically named after the configured function. ie. the FEC node is
48named 'ethernet', and a PSC in uart mode is named 'serial'.
49
502. device_type property
51-----------------------
52similar to the node name convention above; the device_type reflects the
53configured function of a device. ie. 'serial' for a uart and 'spi' for
54an spi controller. However, while node names *should* reflect the
55configured function, device_type *must* match the configured function
56exactly.
57
583. compatible property
59----------------------
60Since device_type isn't enough to match devices to drivers, there also
61needs to be a naming convention for the compatible property. Compatible
62is an list of device descriptions sorted from specific to generic. For
63the mpc52xx, the required format for each compatible value is
64<chip>-<device>[-<mode>]. At the minimum, the list shall contain two
65items; the first specifying the exact chip, and the second specifying
66mpc52xx for the chip.
67
68ie. ethernet on mpc5200b: compatible = "mpc5200b-ethernet\0mpc52xx-ethernet"
69
70The idea here is that most drivers will match to the most generic field
71in the compatible list (mpc52xx-*), but can also test the more specific
72field for enabling bug fixes or extra features.
73
74Modal devices, like PSCs, also append the configured function to the
75end of the compatible field. ie. A PSC in i2s mode would specify
76"mpc52xx-psc-i2s", not "mpc52xx-i2s". This convention is chosen to
77avoid naming conflicts with non-psc devices providing the same
78function. For example, "mpc52xx-spi" and "mpc52xx-psc-spi" describe
79the mpc5200 simple spi device and a PSC spi mode respectively.
80
81If the soc device is more generic and present on other SOCs, the
82compatible property can specify the more generic device type also.
83
84ie. mscan: compatible = "mpc5200-mscan\0mpc52xx-mscan\0fsl,mscan";
85
86At the time of writing, exact chip may be either 'mpc5200' or
87'mpc5200b'.
88
89Device drivers should always try to match as generically as possible.
90
91III - Structure
92===============
93The device tree for an mpc52xx board follows the structure defined in
94booting-without-of.txt with the following additional notes:
95
960) the root node
97----------------
98Typical root description node; see booting-without-of
99
1001) The cpus node
101----------------
102The cpus node follows the basic layout described in booting-without-of.
103The bus-frequency property holds the XLB bus frequency
104The clock-frequency property holds the core frequency
105
1062) The memory node
107------------------
108Typical memory description node; see booting-without-of.
109
1103) The soc5200 node
111-------------------
112This node describes the on chip SOC peripherals. Every mpc52xx based
113board will have this node, and as such there is a common naming
114convention for SOC devices.
115
116Required properties:
117name type description
118---- ---- -----------
119device_type string must be "soc"
120ranges int should be <0 baseaddr baseaddr+10000>
121reg int must be <baseaddr 10000>
122
123Recommended properties:
124name type description
125---- ---- -----------
126compatible string should be "<chip>-soc\0mpc52xx-soc"
127 ie. "mpc5200b-soc\0mpc52xx-soc"
128#interrupt-cells int must be <3>. If it is not defined
129 here then it must be defined in every
130 soc device node.
131bus-frequency int IPB bus frequency in HZ. Clock rate
132 used by most of the soc devices.
133 Defining it here avoids needing it
134 added to every device node.
135
1364) soc5200 child nodes
137----------------------
138Any on chip SOC devices available to Linux must appear as soc5200 child nodes.
139
140Note: in the tables below, '*' matches all <chip> values. ie.
141*-pic would translate to "mpc5200-pic\0mpc52xx-pic"
142
143Required soc5200 child nodes:
144name device_type compatible Description
145---- ----------- ---------- -----------
146cdm@<addr> cdm *-cmd Clock Distribution
147pic@<addr> interrupt-controller *-pic need an interrupt
148 controller to boot
149bestcomm@<addr> dma-controller *-bestcomm 52xx pic also requires
150 the bestcomm device
151
152Recommended soc5200 child nodes; populate as needed for your board
153name device_type compatible Description
154---- ----------- ---------- -----------
155gpt@<addr> gpt *-gpt General purpose timers
156rtc@<addr> rtc *-rtc Real time clock
157mscan@<addr> mscan *-mscan CAN bus controller
158pci@<addr> pci *-pci PCI bridge
159serial@<addr> serial *-psc-uart PSC in serial mode
160i2s@<addr> i2s *-psc-i2s PSC in i2s mode
161ac97@<addr> ac97 *-psc-ac97 PSC in ac97 mode
162spi@<addr> spi *-psc-spi PSC in spi mode
163irda@<addr> irda *-psc-irda PSC in IrDA mode
164spi@<addr> spi *-spi MPC52xx spi device
165ethernet@<addr> network *-fec MPC52xx ethernet device
166ata@<addr> ata *-ata IDE ATA interface
167i2c@<addr> i2c *-i2c I2C controller
168usb@<addr> usb-ohci-be *-ohci,ohci-be USB controller
169xlb@<addr> xlb *-xlb XLB arbritrator
170
171IV - Extra Notes
172================
173
1741. Interrupt mapping
175--------------------
176The mpc52xx pic driver splits hardware IRQ numbers into two levels. The
177split reflects the layout of the PIC hardware itself, which groups
178interrupts into one of three groups; CRIT, MAIN or PERP. Also, the
179Bestcomm dma engine has it's own set of interrupt sources which are
180cascaded off of peripheral interrupt 0, which the driver interprets as a
181fourth group, SDMA.
182
183The interrupts property for device nodes using the mpc52xx pic consists
184of three cells; <L1 L2 level>
185
186 L1 := [CRIT=0, MAIN=1, PERP=2, SDMA=3]
187 L2 := interrupt number; directly mapped from the value in the
188 "ICTL PerStat, MainStat, CritStat Encoded Register"
189 level := [LEVEL_HIGH=0, EDGE_RISING=1, EDGE_FALLING=2, LEVEL_LOW=3]
diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt
index 75a535a975c3..6f70f2b9327e 100644
--- a/Documentation/scsi/scsi_mid_low_api.txt
+++ b/Documentation/scsi/scsi_mid_low_api.txt
@@ -375,7 +375,6 @@ Summary:
375 scsi_add_device - creates new scsi device (lu) instance 375 scsi_add_device - creates new scsi device (lu) instance
376 scsi_add_host - perform sysfs registration and set up transport class 376 scsi_add_host - perform sysfs registration and set up transport class
377 scsi_adjust_queue_depth - change the queue depth on a SCSI device 377 scsi_adjust_queue_depth - change the queue depth on a SCSI device
378 scsi_assign_lock - replace default host_lock with given lock
379 scsi_bios_ptable - return copy of block device's partition table 378 scsi_bios_ptable - return copy of block device's partition table
380 scsi_block_requests - prevent further commands being queued to given host 379 scsi_block_requests - prevent further commands being queued to given host
381 scsi_deactivate_tcq - turn off tag command queueing 380 scsi_deactivate_tcq - turn off tag command queueing
@@ -489,20 +488,6 @@ void scsi_adjust_queue_depth(struct scsi_device * sdev, int tagged,
489 488
490 489
491/** 490/**
492 * scsi_assign_lock - replace default host_lock with given lock
493 * @shost: a pointer to a scsi host instance
494 * @lock: pointer to lock to replace host_lock for this host
495 *
496 * Returns nothing
497 *
498 * Might block: no
499 *
500 * Defined in: include/scsi/scsi_host.h .
501 **/
502void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
503
504
505/**
506 * scsi_bios_ptable - return copy of block device's partition table 491 * scsi_bios_ptable - return copy of block device's partition table
507 * @dev: pointer to block device 492 * @dev: pointer to block device
508 * 493 *
@@ -1366,17 +1351,11 @@ Locks
1366Each struct Scsi_Host instance has a spin_lock called struct 1351Each struct Scsi_Host instance has a spin_lock called struct
1367Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in 1352Scsi_Host::default_lock which is initialized in scsi_host_alloc() [found in
1368hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer 1353hosts.c]. Within the same function the struct Scsi_Host::host_lock pointer
1369is initialized to point at default_lock with the scsi_assign_lock() function. 1354is initialized to point at default_lock. Thereafter lock and unlock
1370Thereafter lock and unlock operations performed by the mid level use the 1355operations performed by the mid level use the struct Scsi_Host::host_lock
1371struct Scsi_Host::host_lock pointer. 1356pointer. Previously drivers could override the host_lock pointer but
1372 1357this is not allowed anymore.
1373LLDs can override the use of struct Scsi_Host::default_lock by 1358
1374using scsi_assign_lock(). The earliest opportunity to do this would
1375be in the detect() function after it has invoked scsi_register(). It
1376could be replaced by a coarser grain lock (e.g. per driver) or a
1377lock of equal granularity (i.e. per host). Using finer grain locks
1378(e.g. per SCSI device) may be possible by juggling locks in
1379queuecommand().
1380 1359
1381Autosense 1360Autosense
1382========= 1361=========
diff --git a/MAINTAINERS b/MAINTAINERS
index 8385a69138a8..5dff26814a06 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2438,6 +2438,13 @@ M: promise@pnd-pc.demon.co.uk
2438W: http://www.pnd-pc.demon.co.uk/promise/ 2438W: http://www.pnd-pc.demon.co.uk/promise/
2439S: Maintained 2439S: Maintained
2440 2440
2441PS3 PLATFORM SUPPORT
2442P: Geoff Levand
2443M: geoffrey.levand@am.sony.com
2444L: linuxppc-dev@ozlabs.org
2445L: cbe-oss-dev@ozlabs.org
2446S: Supported
2447
2441PVRUSB2 VIDEO4LINUX DRIVER 2448PVRUSB2 VIDEO4LINUX DRIVER
2442P: Mike Isely 2449P: Mike Isely
2443M: isely@pobox.com 2450M: isely@pobox.com
diff --git a/README b/README
index 3e264723b863..c05561523029 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
1 Linux kernel release 2.6.xx <http://kernel.org> 1 Linux kernel release 2.6.xx <http://kernel.org/>
2 2
3These are the release notes for Linux version 2.6. Read them carefully, 3These are the release notes for Linux version 2.6. Read them carefully,
4as they tell you what this is all about, explain how to install the 4as they tell you what this is all about, explain how to install the
@@ -22,15 +22,17 @@ ON WHAT HARDWARE DOES IT RUN?
22 22
23 Although originally developed first for 32-bit x86-based PCs (386 or higher), 23 Although originally developed first for 32-bit x86-based PCs (386 or higher),
24 today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and 24 today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and
25 UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, 25 UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
26 IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS, 26 IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
27 and Renesas M32R architectures. 27 Cris, Xtensa, AVR32 and Renesas M32R architectures.
28 28
29 Linux is easily portable to most general-purpose 32- or 64-bit architectures 29 Linux is easily portable to most general-purpose 32- or 64-bit architectures
30 as long as they have a paged memory management unit (PMMU) and a port of the 30 as long as they have a paged memory management unit (PMMU) and a port of the
31 GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has 31 GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has
32 also been ported to a number of architectures without a PMMU, although 32 also been ported to a number of architectures without a PMMU, although
33 functionality is then obviously somewhat limited. 33 functionality is then obviously somewhat limited.
34 Linux has also been ported to itself. You can now run the kernel as a
35 userspace application - this is called UserMode Linux (UML).
34 36
35DOCUMENTATION: 37DOCUMENTATION:
36 38
@@ -113,6 +115,7 @@ INSTALLING the kernel:
113 version 2.6.12.2 and want to jump to 2.6.12.3, you must first 115 version 2.6.12.2 and want to jump to 2.6.12.3, you must first
114 reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying 116 reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying
115 the 2.6.12.3 patch. 117 the 2.6.12.3 patch.
118 You can read more on this in Documentation/applying-patches.txt
116 119
117 - Make sure you have no stale .o files and dependencies lying around: 120 - Make sure you have no stale .o files and dependencies lying around:
118 121
@@ -161,6 +164,7 @@ CONFIGURING the kernel:
161 only ask you for the answers to new questions. 164 only ask you for the answers to new questions.
162 165
163 - Alternate configuration commands are: 166 - Alternate configuration commands are:
167 "make config" Plain text interface.
164 "make menuconfig" Text based color menus, radiolists & dialogs. 168 "make menuconfig" Text based color menus, radiolists & dialogs.
165 "make xconfig" X windows (Qt) based configuration tool. 169 "make xconfig" X windows (Qt) based configuration tool.
166 "make gconfig" X windows (Gtk) based configuration tool. 170 "make gconfig" X windows (Gtk) based configuration tool.
@@ -303,8 +307,9 @@ IF SOMETHING GOES WRONG:
303 307
304 - If you compiled the kernel with CONFIG_KALLSYMS you can send the dump 308 - If you compiled the kernel with CONFIG_KALLSYMS you can send the dump
305 as is, otherwise you will have to use the "ksymoops" program to make 309 as is, otherwise you will have to use the "ksymoops" program to make
306 sense of the dump. This utility can be downloaded from 310 sense of the dump (but compiling with CONFIG_KALLSYMS is usually preferred).
307 ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops. 311 This utility can be downloaded from
312 ftp://ftp.<country>.kernel.org/pub/linux/utils/kernel/ksymoops/ .
308 Alternately you can do the dump lookup by hand: 313 Alternately you can do the dump lookup by hand:
309 314
310 - In debugging dumps like the above, it helps enormously if you can 315 - In debugging dumps like the above, it helps enormously if you can
@@ -336,7 +341,7 @@ IF SOMETHING GOES WRONG:
336 341
337 If you for some reason cannot do the above (you have a pre-compiled 342 If you for some reason cannot do the above (you have a pre-compiled
338 kernel image or similar), telling me as much about your setup as 343 kernel image or similar), telling me as much about your setup as
339 possible will help. 344 possible will help. Please read the REPORTING-BUGS document for details.
340 345
341 - Alternately, you can use gdb on a running kernel. (read-only; i.e. you 346 - Alternately, you can use gdb on a running kernel. (read-only; i.e. you
342 cannot change values or set break points.) To do this, first compile the 347 cannot change values or set break points.) To do this, first compile the
diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c
index 605dedf96790..b3599743093b 100644
--- a/arch/arm/common/sharpsl_pm.c
+++ b/arch/arm/common/sharpsl_pm.c
@@ -60,16 +60,16 @@ static int sharpsl_ac_check(void);
60static int sharpsl_fatal_check(void); 60static int sharpsl_fatal_check(void);
61static int sharpsl_average_value(int ad); 61static int sharpsl_average_value(int ad);
62static void sharpsl_average_clear(void); 62static void sharpsl_average_clear(void);
63static void sharpsl_charge_toggle(void *private_); 63static void sharpsl_charge_toggle(struct work_struct *private_);
64static void sharpsl_battery_thread(void *private_); 64static void sharpsl_battery_thread(struct work_struct *private_);
65 65
66 66
67/* 67/*
68 * Variables 68 * Variables
69 */ 69 */
70struct sharpsl_pm_status sharpsl_pm; 70struct sharpsl_pm_status sharpsl_pm;
71DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL); 71DECLARE_DELAYED_WORK(toggle_charger, sharpsl_charge_toggle);
72DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL); 72DECLARE_DELAYED_WORK(sharpsl_bat, sharpsl_battery_thread);
73DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger); 73DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger);
74 74
75 75
@@ -116,7 +116,7 @@ void sharpsl_battery_kick(void)
116EXPORT_SYMBOL(sharpsl_battery_kick); 116EXPORT_SYMBOL(sharpsl_battery_kick);
117 117
118 118
119static void sharpsl_battery_thread(void *private_) 119static void sharpsl_battery_thread(struct work_struct *private_)
120{ 120{
121 int voltage, percent, apm_status, i = 0; 121 int voltage, percent, apm_status, i = 0;
122 122
@@ -128,7 +128,7 @@ static void sharpsl_battery_thread(void *private_)
128 /* Corgi cannot confirm when battery fully charged so periodically kick! */ 128 /* Corgi cannot confirm when battery fully charged so periodically kick! */
129 if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON) 129 if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON)
130 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) 130 && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL))
131 schedule_work(&toggle_charger); 131 schedule_delayed_work(&toggle_charger, 0);
132 132
133 while(1) { 133 while(1) {
134 voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT); 134 voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
@@ -212,7 +212,7 @@ static void sharpsl_charge_off(void)
212 sharpsl_pm_led(SHARPSL_LED_OFF); 212 sharpsl_pm_led(SHARPSL_LED_OFF);
213 sharpsl_pm.charge_mode = CHRG_OFF; 213 sharpsl_pm.charge_mode = CHRG_OFF;
214 214
215 schedule_work(&sharpsl_bat); 215 schedule_delayed_work(&sharpsl_bat, 0);
216} 216}
217 217
218static void sharpsl_charge_error(void) 218static void sharpsl_charge_error(void)
@@ -222,7 +222,7 @@ static void sharpsl_charge_error(void)
222 sharpsl_pm.charge_mode = CHRG_ERROR; 222 sharpsl_pm.charge_mode = CHRG_ERROR;
223} 223}
224 224
225static void sharpsl_charge_toggle(void *private_) 225static void sharpsl_charge_toggle(struct work_struct *private_)
226{ 226{
227 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); 227 dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
228 228
@@ -254,7 +254,7 @@ static void sharpsl_ac_timer(unsigned long data)
254 else if (sharpsl_pm.charge_mode == CHRG_ON) 254 else if (sharpsl_pm.charge_mode == CHRG_ON)
255 sharpsl_charge_off(); 255 sharpsl_charge_off();
256 256
257 schedule_work(&sharpsl_bat); 257 schedule_delayed_work(&sharpsl_bat, 0);
258} 258}
259 259
260 260
@@ -279,10 +279,10 @@ static void sharpsl_chrg_full_timer(unsigned long data)
279 sharpsl_charge_off(); 279 sharpsl_charge_off();
280 } else if (sharpsl_pm.full_count < 2) { 280 } else if (sharpsl_pm.full_count < 2) {
281 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n"); 281 dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n");
282 schedule_work(&toggle_charger); 282 schedule_delayed_work(&toggle_charger, 0);
283 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) { 283 } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) {
284 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n"); 284 dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n");
285 schedule_work(&toggle_charger); 285 schedule_delayed_work(&toggle_charger, 0);
286 } else { 286 } else {
287 sharpsl_charge_off(); 287 sharpsl_charge_off();
288 sharpsl_pm.charge_mode = CHRG_DONE; 288 sharpsl_pm.charge_mode = CHRG_DONE;
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index f225a083dee1..9d2346fb68f4 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -323,7 +323,8 @@ static int h3_transceiver_mode(struct device *dev, int mode)
323 323
324 cancel_delayed_work(&irda_config->gpio_expa); 324 cancel_delayed_work(&irda_config->gpio_expa);
325 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode); 325 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
326 schedule_work(&irda_config->gpio_expa); 326#error this is not permitted - mode is an argument variable
327 schedule_delayed_work(&irda_config->gpio_expa, 0);
327 328
328 return 0; 329 return 0;
329} 330}
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index dbc555d209ff..cbe909bad79b 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -74,7 +74,7 @@ static struct omap_kp_platform_data nokia770_kp_data = {
74 .rows = 8, 74 .rows = 8,
75 .cols = 8, 75 .cols = 8,
76 .keymap = nokia770_keymap, 76 .keymap = nokia770_keymap,
77 .keymapsize = ARRAY_SIZE(nokia770_keymap) 77 .keymapsize = ARRAY_SIZE(nokia770_keymap),
78 .delay = 4, 78 .delay = 4,
79}; 79};
80 80
@@ -191,7 +191,7 @@ static void nokia770_audio_pwr_up(void)
191 printk("HP connected\n"); 191 printk("HP connected\n");
192} 192}
193 193
194static void codec_delayed_power_down(void *arg) 194static void codec_delayed_power_down(struct work_struct *work)
195{ 195{
196 down(&audio_pwr_sem); 196 down(&audio_pwr_sem);
197 if (audio_pwr_state == -1) 197 if (audio_pwr_state == -1)
@@ -200,7 +200,7 @@ static void codec_delayed_power_down(void *arg)
200 up(&audio_pwr_sem); 200 up(&audio_pwr_sem);
201} 201}
202 202
203static DECLARE_WORK(codec_power_down_work, codec_delayed_power_down, NULL); 203static DECLARE_DELAYED_WORK(codec_power_down_work, codec_delayed_power_down);
204 204
205static void nokia770_audio_pwr_down(void) 205static void nokia770_audio_pwr_down(void)
206{ 206{
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c
index 3b29e59b0e6f..0cbf1b0071f8 100644
--- a/arch/arm/mach-omap1/leds-osk.c
+++ b/arch/arm/mach-omap1/leds-osk.c
@@ -35,7 +35,7 @@ static u8 hw_led_state;
35 35
36static u8 tps_leds_change; 36static u8 tps_leds_change;
37 37
38static void tps_work(void *unused) 38static void tps_work(struct work_struct *unused)
39{ 39{
40 for (;;) { 40 for (;;) {
41 u8 leds; 41 u8 leds;
@@ -61,7 +61,7 @@ static void tps_work(void *unused)
61 } 61 }
62} 62}
63 63
64static DECLARE_WORK(work, tps_work, NULL); 64static DECLARE_WORK(work, tps_work);
65 65
66#ifdef CONFIG_OMAP_OSK_MISTRAL 66#ifdef CONFIG_OMAP_OSK_MISTRAL
67 67
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 26a95a642ad7..3b1ad1d981a3 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -206,7 +206,8 @@ static int h4_transceiver_mode(struct device *dev, int mode)
206 206
207 cancel_delayed_work(&irda_config->gpio_expa); 207 cancel_delayed_work(&irda_config->gpio_expa);
208 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode); 208 PREPARE_WORK(&irda_config->gpio_expa, set_trans_mode, &mode);
209 schedule_work(&irda_config->gpio_expa); 209#error this is not permitted - mode is an argument variable
210 schedule_delayed_work(&irda_config->gpio_expa, 0);
210 211
211 return 0; 212 return 0;
212} 213}
diff --git a/arch/arm/mach-pxa/akita-ioexp.c b/arch/arm/mach-pxa/akita-ioexp.c
index 1b398742ab56..12d2fe0ceff6 100644
--- a/arch/arm/mach-pxa/akita-ioexp.c
+++ b/arch/arm/mach-pxa/akita-ioexp.c
@@ -36,11 +36,11 @@ I2C_CLIENT_INSMOD;
36 36
37static int max7310_write(struct i2c_client *client, int address, int data); 37static int max7310_write(struct i2c_client *client, int address, int data);
38static struct i2c_client max7310_template; 38static struct i2c_client max7310_template;
39static void akita_ioexp_work(void *private_); 39static void akita_ioexp_work(struct work_struct *private_);
40 40
41static struct device *akita_ioexp_device; 41static struct device *akita_ioexp_device;
42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT; 42static unsigned char ioexp_output_value = AKITA_IOEXP_IO_OUT;
43DECLARE_WORK(akita_ioexp, akita_ioexp_work, NULL); 43DECLARE_WORK(akita_ioexp, akita_ioexp_work);
44 44
45 45
46/* 46/*
@@ -158,7 +158,7 @@ void akita_reset_ioexp(struct device *dev, unsigned char bit)
158EXPORT_SYMBOL(akita_set_ioexp); 158EXPORT_SYMBOL(akita_set_ioexp);
159EXPORT_SYMBOL(akita_reset_ioexp); 159EXPORT_SYMBOL(akita_reset_ioexp);
160 160
161static void akita_ioexp_work(void *private_) 161static void akita_ioexp_work(struct work_struct *private_)
162{ 162{
163 if (akita_ioexp_device) 163 if (akita_ioexp_device)
164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value); 164 max7310_set_ouputs(akita_ioexp_device, ioexp_output_value);
diff --git a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
index 1f9153ae5b03..6b5d3518a1c0 100644
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c
@@ -51,10 +51,10 @@ static void mce_checkregs (void *info)
51 } 51 }
52} 52}
53 53
54static void mce_work_fn(void *data); 54static void mce_work_fn(struct work_struct *work);
55static DECLARE_WORK(mce_work, mce_work_fn, NULL); 55static DECLARE_DELAYED_WORK(mce_work, mce_work_fn);
56 56
57static void mce_work_fn(void *data) 57static void mce_work_fn(struct work_struct *work)
58{ 58{
59 on_each_cpu(mce_checkregs, NULL, 1, 1); 59 on_each_cpu(mce_checkregs, NULL, 1, 1);
60 schedule_delayed_work(&mce_work, MCE_RATE); 60 schedule_delayed_work(&mce_work, MCE_RATE);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 4bb8b77cd65b..02a9b66b6ac3 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -1049,13 +1049,15 @@ void cpu_exit_clear(void)
1049 1049
1050struct warm_boot_cpu_info { 1050struct warm_boot_cpu_info {
1051 struct completion *complete; 1051 struct completion *complete;
1052 struct work_struct task;
1052 int apicid; 1053 int apicid;
1053 int cpu; 1054 int cpu;
1054}; 1055};
1055 1056
1056static void __cpuinit do_warm_boot_cpu(void *p) 1057static void __cpuinit do_warm_boot_cpu(struct work_struct *work)
1057{ 1058{
1058 struct warm_boot_cpu_info *info = p; 1059 struct warm_boot_cpu_info *info =
1060 container_of(work, struct warm_boot_cpu_info, task);
1059 do_boot_cpu(info->apicid, info->cpu); 1061 do_boot_cpu(info->apicid, info->cpu);
1060 complete(info->complete); 1062 complete(info->complete);
1061} 1063}
@@ -1064,7 +1066,6 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1064{ 1066{
1065 DECLARE_COMPLETION_ONSTACK(done); 1067 DECLARE_COMPLETION_ONSTACK(done);
1066 struct warm_boot_cpu_info info; 1068 struct warm_boot_cpu_info info;
1067 struct work_struct task;
1068 int apicid, ret; 1069 int apicid, ret;
1069 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu); 1070 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
1070 1071
@@ -1089,7 +1090,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1089 info.complete = &done; 1090 info.complete = &done;
1090 info.apicid = apicid; 1091 info.apicid = apicid;
1091 info.cpu = cpu; 1092 info.cpu = cpu;
1092 INIT_WORK(&task, do_warm_boot_cpu, &info); 1093 INIT_WORK(&info.task, do_warm_boot_cpu);
1093 1094
1094 tsc_sync_disabled = 1; 1095 tsc_sync_disabled = 1;
1095 1096
@@ -1097,7 +1098,7 @@ static int __cpuinit __smp_prepare_cpu(int cpu)
1097 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, 1098 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
1098 KERNEL_PGD_PTRS); 1099 KERNEL_PGD_PTRS);
1099 flush_tlb_all(); 1100 flush_tlb_all();
1100 schedule_work(&task); 1101 schedule_work(&info.task);
1101 wait_for_completion(&done); 1102 wait_for_completion(&done);
1102 1103
1103 tsc_sync_disabled = 0; 1104 tsc_sync_disabled = 0;
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index fbc95828cd74..9810c8c90750 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -217,7 +217,7 @@ static unsigned int cpufreq_delayed_issched = 0;
217static unsigned int cpufreq_init = 0; 217static unsigned int cpufreq_init = 0;
218static struct work_struct cpufreq_delayed_get_work; 218static struct work_struct cpufreq_delayed_get_work;
219 219
220static void handle_cpufreq_delayed_get(void *v) 220static void handle_cpufreq_delayed_get(struct work_struct *work)
221{ 221{
222 unsigned int cpu; 222 unsigned int cpu;
223 223
@@ -306,7 +306,7 @@ static int __init cpufreq_tsc(void)
306{ 306{
307 int ret; 307 int ret;
308 308
309 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 309 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
310 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block, 310 ret = cpufreq_register_notifier(&time_cpufreq_notifier_block,
311 CPUFREQ_TRANSITION_NOTIFIER); 311 CPUFREQ_TRANSITION_NOTIFIER);
312 if (!ret) 312 if (!ret)
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index caab986af70c..b62f0c4d2c7c 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -209,7 +209,7 @@ static void do_serial_bh(void)
209} 209}
210#endif 210#endif
211 211
212static void do_softint(void *private_) 212static void do_softint(struct work_struct *private_)
213{ 213{
214 printk(KERN_ERR "simserial: do_softint called\n"); 214 printk(KERN_ERR "simserial: do_softint called\n");
215} 215}
@@ -698,7 +698,7 @@ static int get_async_struct(int line, struct async_struct **ret_info)
698 info->flags = sstate->flags; 698 info->flags = sstate->flags;
699 info->xmit_fifo_size = sstate->xmit_fifo_size; 699 info->xmit_fifo_size = sstate->xmit_fifo_size;
700 info->line = line; 700 info->line = line;
701 INIT_WORK(&info->work, do_softint, info); 701 INIT_WORK(&info->work, do_softint);
702 info->state = sstate; 702 info->state = sstate;
703 if (sstate->info) { 703 if (sstate->info) {
704 kfree(info); 704 kfree(info);
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 7cfa63a98cb3..6bedd97570ca 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -678,7 +678,7 @@ ia64_mca_cmc_vector_enable (void *dummy)
678 * disable the cmc interrupt vector. 678 * disable the cmc interrupt vector.
679 */ 679 */
680static void 680static void
681ia64_mca_cmc_vector_disable_keventd(void *unused) 681ia64_mca_cmc_vector_disable_keventd(struct work_struct *unused)
682{ 682{
683 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0); 683 on_each_cpu(ia64_mca_cmc_vector_disable, NULL, 1, 0);
684} 684}
@@ -690,7 +690,7 @@ ia64_mca_cmc_vector_disable_keventd(void *unused)
690 * enable the cmc interrupt vector. 690 * enable the cmc interrupt vector.
691 */ 691 */
692static void 692static void
693ia64_mca_cmc_vector_enable_keventd(void *unused) 693ia64_mca_cmc_vector_enable_keventd(struct work_struct *unused)
694{ 694{
695 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0); 695 on_each_cpu(ia64_mca_cmc_vector_enable, NULL, 1, 0);
696} 696}
@@ -1247,8 +1247,8 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
1247 monarch_cpu = -1; 1247 monarch_cpu = -1;
1248} 1248}
1249 1249
1250static DECLARE_WORK(cmc_disable_work, ia64_mca_cmc_vector_disable_keventd, NULL); 1250static DECLARE_WORK(cmc_disable_work, ia64_mca_cmc_vector_disable_keventd);
1251static DECLARE_WORK(cmc_enable_work, ia64_mca_cmc_vector_enable_keventd, NULL); 1251static DECLARE_WORK(cmc_enable_work, ia64_mca_cmc_vector_enable_keventd);
1252 1252
1253/* 1253/*
1254 * ia64_mca_cmc_int_handler 1254 * ia64_mca_cmc_int_handler
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index f7d7f5668144..b21ddecea943 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -463,15 +463,17 @@ struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
463} 463}
464 464
465struct create_idle { 465struct create_idle {
466 struct work_struct work;
466 struct task_struct *idle; 467 struct task_struct *idle;
467 struct completion done; 468 struct completion done;
468 int cpu; 469 int cpu;
469}; 470};
470 471
471void 472void
472do_fork_idle(void *_c_idle) 473do_fork_idle(struct work_struct *work)
473{ 474{
474 struct create_idle *c_idle = _c_idle; 475 struct create_idle *c_idle =
476 container_of(work, struct create_idle, work);
475 477
476 c_idle->idle = fork_idle(c_idle->cpu); 478 c_idle->idle = fork_idle(c_idle->cpu);
477 complete(&c_idle->done); 479 complete(&c_idle->done);
@@ -482,10 +484,10 @@ do_boot_cpu (int sapicid, int cpu)
482{ 484{
483 int timeout; 485 int timeout;
484 struct create_idle c_idle = { 486 struct create_idle c_idle = {
487 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
485 .cpu = cpu, 488 .cpu = cpu,
486 .done = COMPLETION_INITIALIZER(c_idle.done), 489 .done = COMPLETION_INITIALIZER(c_idle.done),
487 }; 490 };
488 DECLARE_WORK(work, do_fork_idle, &c_idle);
489 491
490 c_idle.idle = get_idle_for_cpu(cpu); 492 c_idle.idle = get_idle_for_cpu(cpu);
491 if (c_idle.idle) { 493 if (c_idle.idle) {
@@ -497,9 +499,9 @@ do_boot_cpu (int sapicid, int cpu)
497 * We can't use kernel_thread since we must avoid to reschedule the child. 499 * We can't use kernel_thread since we must avoid to reschedule the child.
498 */ 500 */
499 if (!keventd_up() || current_is_keventd()) 501 if (!keventd_up() || current_is_keventd())
500 work.func(work.data); 502 c_idle.work.func(&c_idle.work);
501 else { 503 else {
502 schedule_work(&work); 504 schedule_work(&c_idle.work);
503 wait_for_completion(&c_idle.done); 505 wait_for_completion(&c_idle.done);
504 } 506 }
505 507
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index f4edfbf27134..eb92cef9cd0d 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -564,8 +564,8 @@ pcibios_enable_device (struct pci_dev *dev, int mask)
564void 564void
565pcibios_disable_device (struct pci_dev *dev) 565pcibios_disable_device (struct pci_dev *dev)
566{ 566{
567 if (dev->is_enabled) 567 BUG_ON(atomic_read(&dev->enable_cnt));
568 acpi_pci_irq_disable(dev); 568 acpi_pci_irq_disable(dev);
569} 569}
570 570
571void 571void
diff --git a/arch/m68knommu/platform/5307/timers.c b/arch/m68knommu/platform/5307/timers.c
index 24781f009337..e5668af19789 100644
--- a/arch/m68knommu/platform/5307/timers.c
+++ b/arch/m68knommu/platform/5307/timers.c
@@ -3,7 +3,7 @@
3/* 3/*
4 * timers.c -- generic ColdFire hardware timer support. 4 * timers.c -- generic ColdFire hardware timer support.
5 * 5 *
6 * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com) 6 * Copyright (C) 1999-2006, Greg Ungerer (gerg@snapgear.com)
7 */ 7 */
8 8
9/***************************************************************************/ 9/***************************************************************************/
@@ -44,6 +44,14 @@ unsigned int mcf_timerlevel = 5;
44extern void mcf_settimericr(int timer, int level); 44extern void mcf_settimericr(int timer, int level);
45extern int mcf_timerirqpending(int timer); 45extern int mcf_timerirqpending(int timer);
46 46
47#if defined(CONFIG_M532x)
48#define __raw_readtrr __raw_readl
49#define __raw_writetrr __raw_writel
50#else
51#define __raw_readtrr __raw_readw
52#define __raw_writetrr __raw_writew
53#endif
54
47/***************************************************************************/ 55/***************************************************************************/
48 56
49void coldfire_tick(void) 57void coldfire_tick(void)
@@ -57,7 +65,7 @@ void coldfire_tick(void)
57void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *)) 65void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *))
58{ 66{
59 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR)); 67 __raw_writew(MCFTIMER_TMR_DISABLE, TA(MCFTIMER_TMR));
60 __raw_writew(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR)); 68 __raw_writetrr(((MCF_BUSCLK / 16) / HZ), TA(MCFTIMER_TRR));
61 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 69 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
62 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR)); 70 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, TA(MCFTIMER_TMR));
63 71
@@ -76,7 +84,7 @@ unsigned long coldfire_timer_offset(void)
76 unsigned long trr, tcn, offset; 84 unsigned long trr, tcn, offset;
77 85
78 tcn = __raw_readw(TA(MCFTIMER_TCN)); 86 tcn = __raw_readw(TA(MCFTIMER_TCN));
79 trr = __raw_readw(TA(MCFTIMER_TRR)); 87 trr = __raw_readtrr(TA(MCFTIMER_TRR));
80 offset = (tcn * (1000000 / HZ)) / trr; 88 offset = (tcn * (1000000 / HZ)) / trr;
81 89
82 /* Check if we just wrapped the counters and maybe missed a tick */ 90 /* Check if we just wrapped the counters and maybe missed a tick */
@@ -120,7 +128,7 @@ void coldfire_profile_init(void)
120 /* Set up TIMER 2 as high speed profile clock */ 128 /* Set up TIMER 2 as high speed profile clock */
121 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR)); 129 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR));
122 130
123 __raw_writew(((MCF_CLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR)); 131 __raw_writetrr(((MCF_CLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR));
124 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 132 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
125 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR)); 133 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR));
126 134
diff --git a/arch/m68knommu/platform/68360/config.c b/arch/m68knommu/platform/68360/config.c
index c5482e3622eb..1b36f6261764 100644
--- a/arch/m68knommu/platform/68360/config.c
+++ b/arch/m68knommu/platform/68360/config.c
@@ -114,7 +114,7 @@ void BSP_gettod (int *yearp, int *monp, int *dayp,
114{ 114{
115} 115}
116 116
117int BSP_hwclk(int op, struct hwclk_time *t) 117int BSP_hwclk(int op, struct rtc_time *t)
118{ 118{
119 if (!op) { 119 if (!op) {
120 /* read */ 120 /* read */
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 27f83e642968..d8af858fe3f5 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -16,6 +16,7 @@ config MIPS_MTX1
16 bool "4G Systems MTX-1 board" 16 bool "4G Systems MTX-1 board"
17 select DMA_NONCOHERENT 17 select DMA_NONCOHERENT
18 select HW_HAS_PCI 18 select HW_HAS_PCI
19 select RESOURCES_64BIT if PCI
19 select SOC_AU1500 20 select SOC_AU1500
20 select SYS_HAS_CPU_MIPS32_R1 21 select SYS_HAS_CPU_MIPS32_R1
21 select SYS_SUPPORTS_LITTLE_ENDIAN 22 select SYS_SUPPORTS_LITTLE_ENDIAN
@@ -32,6 +33,7 @@ config MIPS_PB1000
32 select SOC_AU1000 33 select SOC_AU1000
33 select DMA_NONCOHERENT 34 select DMA_NONCOHERENT
34 select HW_HAS_PCI 35 select HW_HAS_PCI
36 select RESOURCES_64BIT if PCI
35 select SWAP_IO_SPACE 37 select SWAP_IO_SPACE
36 select SYS_HAS_CPU_MIPS32_R1 38 select SYS_HAS_CPU_MIPS32_R1
37 select SYS_SUPPORTS_LITTLE_ENDIAN 39 select SYS_SUPPORTS_LITTLE_ENDIAN
@@ -41,6 +43,7 @@ config MIPS_PB1100
41 select SOC_AU1100 43 select SOC_AU1100
42 select DMA_NONCOHERENT 44 select DMA_NONCOHERENT
43 select HW_HAS_PCI 45 select HW_HAS_PCI
46 select RESOURCES_64BIT if PCI
44 select SWAP_IO_SPACE 47 select SWAP_IO_SPACE
45 select SYS_HAS_CPU_MIPS32_R1 48 select SYS_HAS_CPU_MIPS32_R1
46 select SYS_SUPPORTS_LITTLE_ENDIAN 49 select SYS_SUPPORTS_LITTLE_ENDIAN
@@ -50,6 +53,7 @@ config MIPS_PB1500
50 select SOC_AU1500 53 select SOC_AU1500
51 select DMA_NONCOHERENT 54 select DMA_NONCOHERENT
52 select HW_HAS_PCI 55 select HW_HAS_PCI
56 select RESOURCES_64BIT if PCI
53 select SYS_HAS_CPU_MIPS32_R1 57 select SYS_HAS_CPU_MIPS32_R1
54 select SYS_SUPPORTS_LITTLE_ENDIAN 58 select SYS_SUPPORTS_LITTLE_ENDIAN
55 59
@@ -59,6 +63,7 @@ config MIPS_PB1550
59 select DMA_NONCOHERENT 63 select DMA_NONCOHERENT
60 select HW_HAS_PCI 64 select HW_HAS_PCI
61 select MIPS_DISABLE_OBSOLETE_IDE 65 select MIPS_DISABLE_OBSOLETE_IDE
66 select RESOURCES_64BIT if PCI
62 select SYS_HAS_CPU_MIPS32_R1 67 select SYS_HAS_CPU_MIPS32_R1
63 select SYS_SUPPORTS_LITTLE_ENDIAN 68 select SYS_SUPPORTS_LITTLE_ENDIAN
64 69
@@ -67,6 +72,7 @@ config MIPS_PB1200
67 select SOC_AU1200 72 select SOC_AU1200
68 select DMA_NONCOHERENT 73 select DMA_NONCOHERENT
69 select MIPS_DISABLE_OBSOLETE_IDE 74 select MIPS_DISABLE_OBSOLETE_IDE
75 select RESOURCES_64BIT if PCI
70 select SYS_HAS_CPU_MIPS32_R1 76 select SYS_HAS_CPU_MIPS32_R1
71 select SYS_SUPPORTS_LITTLE_ENDIAN 77 select SYS_SUPPORTS_LITTLE_ENDIAN
72 78
@@ -75,6 +81,7 @@ config MIPS_DB1000
75 select SOC_AU1000 81 select SOC_AU1000
76 select DMA_NONCOHERENT 82 select DMA_NONCOHERENT
77 select HW_HAS_PCI 83 select HW_HAS_PCI
84 select RESOURCES_64BIT if PCI
78 select SYS_HAS_CPU_MIPS32_R1 85 select SYS_HAS_CPU_MIPS32_R1
79 select SYS_SUPPORTS_LITTLE_ENDIAN 86 select SYS_SUPPORTS_LITTLE_ENDIAN
80 87
@@ -91,6 +98,7 @@ config MIPS_DB1500
91 select DMA_NONCOHERENT 98 select DMA_NONCOHERENT
92 select HW_HAS_PCI 99 select HW_HAS_PCI
93 select MIPS_DISABLE_OBSOLETE_IDE 100 select MIPS_DISABLE_OBSOLETE_IDE
101 select RESOURCES_64BIT if PCI
94 select SYS_HAS_CPU_MIPS32_R1 102 select SYS_HAS_CPU_MIPS32_R1
95 select SYS_SUPPORTS_BIG_ENDIAN 103 select SYS_SUPPORTS_BIG_ENDIAN
96 select SYS_SUPPORTS_LITTLE_ENDIAN 104 select SYS_SUPPORTS_LITTLE_ENDIAN
@@ -101,6 +109,7 @@ config MIPS_DB1550
101 select HW_HAS_PCI 109 select HW_HAS_PCI
102 select DMA_NONCOHERENT 110 select DMA_NONCOHERENT
103 select MIPS_DISABLE_OBSOLETE_IDE 111 select MIPS_DISABLE_OBSOLETE_IDE
112 select RESOURCES_64BIT if PCI
104 select SYS_HAS_CPU_MIPS32_R1 113 select SYS_HAS_CPU_MIPS32_R1
105 select SYS_SUPPORTS_LITTLE_ENDIAN 114 select SYS_SUPPORTS_LITTLE_ENDIAN
106 115
@@ -233,6 +242,7 @@ config LASAT
233 select SYS_SUPPORTS_32BIT_KERNEL 242 select SYS_SUPPORTS_32BIT_KERNEL
234 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL 243 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
235 select SYS_SUPPORTS_LITTLE_ENDIAN 244 select SYS_SUPPORTS_LITTLE_ENDIAN
245 select GENERIC_HARDIRQS_NO__DO_IRQ
236 246
237config MIPS_ATLAS 247config MIPS_ATLAS
238 bool "MIPS Atlas board" 248 bool "MIPS Atlas board"
@@ -256,6 +266,7 @@ config MIPS_ATLAS
256 select SYS_SUPPORTS_BIG_ENDIAN 266 select SYS_SUPPORTS_BIG_ENDIAN
257 select SYS_SUPPORTS_LITTLE_ENDIAN 267 select SYS_SUPPORTS_LITTLE_ENDIAN
258 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL 268 select SYS_SUPPORTS_MULTITHREADING if EXPERIMENTAL
269 select GENERIC_HARDIRQS_NO__DO_IRQ
259 help 270 help
260 This enables support for the MIPS Technologies Atlas evaluation 271 This enables support for the MIPS Technologies Atlas evaluation
261 board. 272 board.
@@ -410,6 +421,7 @@ config MOMENCO_OCELOT_C
410 select SYS_SUPPORTS_32BIT_KERNEL 421 select SYS_SUPPORTS_32BIT_KERNEL
411 select SYS_SUPPORTS_64BIT_KERNEL 422 select SYS_SUPPORTS_64BIT_KERNEL
412 select SYS_SUPPORTS_BIG_ENDIAN 423 select SYS_SUPPORTS_BIG_ENDIAN
424 select GENERIC_HARDIRQS_NO__DO_IRQ
413 help 425 help
414 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 426 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
415 Momentum Computer <http://www.momenco.com/>. 427 Momentum Computer <http://www.momenco.com/>.
@@ -560,6 +572,7 @@ config SGI_IP27
560 select SYS_SUPPORTS_BIG_ENDIAN 572 select SYS_SUPPORTS_BIG_ENDIAN
561 select SYS_SUPPORTS_NUMA 573 select SYS_SUPPORTS_NUMA
562 select SYS_SUPPORTS_SMP 574 select SYS_SUPPORTS_SMP
575 select GENERIC_HARDIRQS_NO__DO_IRQ
563 help 576 help
564 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics 577 This are the SGI Origin 200, Origin 2000 and Onyx 2 Graphics
565 workstations. To compile a Linux kernel that runs on these, say Y 578 workstations. To compile a Linux kernel that runs on these, say Y
@@ -826,6 +839,10 @@ config SCHED_NO_NO_OMIT_FRAME_POINTER
826 bool 839 bool
827 default y 840 default y
828 841
842config GENERIC_HARDIRQS_NO__DO_IRQ
843 bool
844 default n
845
829# 846#
830# Select some configuration options automatically based on user selections. 847# Select some configuration options automatically based on user selections.
831# 848#
@@ -987,6 +1004,7 @@ config SOC_PNX8550
987 select HW_HAS_PCI 1004 select HW_HAS_PCI
988 select SYS_HAS_CPU_MIPS32_R1 1005 select SYS_HAS_CPU_MIPS32_R1
989 select SYS_SUPPORTS_32BIT_KERNEL 1006 select SYS_SUPPORTS_32BIT_KERNEL
1007 select GENERIC_HARDIRQS_NO__DO_IRQ
990 1008
991config SWAP_IO_SPACE 1009config SWAP_IO_SPACE
992 bool 1010 bool
@@ -1268,6 +1286,7 @@ config CPU_RM9000
1268 select CPU_SUPPORTS_32BIT_KERNEL 1286 select CPU_SUPPORTS_32BIT_KERNEL
1269 select CPU_SUPPORTS_64BIT_KERNEL 1287 select CPU_SUPPORTS_64BIT_KERNEL
1270 select CPU_SUPPORTS_HIGHMEM 1288 select CPU_SUPPORTS_HIGHMEM
1289 select WEAK_ORDERING
1271 1290
1272config CPU_SB1 1291config CPU_SB1
1273 bool "SB1" 1292 bool "SB1"
@@ -1276,6 +1295,7 @@ config CPU_SB1
1276 select CPU_SUPPORTS_32BIT_KERNEL 1295 select CPU_SUPPORTS_32BIT_KERNEL
1277 select CPU_SUPPORTS_64BIT_KERNEL 1296 select CPU_SUPPORTS_64BIT_KERNEL
1278 select CPU_SUPPORTS_HIGHMEM 1297 select CPU_SUPPORTS_HIGHMEM
1298 select WEAK_ORDERING
1279 1299
1280endchoice 1300endchoice
1281 1301
@@ -1336,6 +1356,8 @@ config SYS_HAS_CPU_RM9000
1336config SYS_HAS_CPU_SB1 1356config SYS_HAS_CPU_SB1
1337 bool 1357 bool
1338 1358
1359config WEAK_ORDERING
1360 bool
1339endmenu 1361endmenu
1340 1362
1341# 1363#
@@ -1940,6 +1962,11 @@ config COMPAT
1940 depends on MIPS32_COMPAT 1962 depends on MIPS32_COMPAT
1941 default y 1963 default y
1942 1964
1965config SYSVIPC_COMPAT
1966 bool
1967 depends on COMPAT && SYSVIPC
1968 default y
1969
1943config MIPS32_O32 1970config MIPS32_O32
1944 bool "Kernel support for o32 binaries" 1971 bool "Kernel support for o32 binaries"
1945 depends on MIPS32_COMPAT 1972 depends on MIPS32_COMPAT
diff --git a/arch/mips/dec/ecc-berr.c b/arch/mips/dec/ecc-berr.c
index c8430c07355e..6d55e8aab668 100644
--- a/arch/mips/dec/ecc-berr.c
+++ b/arch/mips/dec/ecc-berr.c
@@ -25,6 +25,7 @@
25#include <asm/cpu.h> 25#include <asm/cpu.h>
26#include <asm/irq_regs.h> 26#include <asm/irq_regs.h>
27#include <asm/processor.h> 27#include <asm/processor.h>
28#include <asm/ptrace.h>
28#include <asm/system.h> 29#include <asm/system.h>
29#include <asm/traps.h> 30#include <asm/traps.h>
30 31
diff --git a/arch/mips/dec/ioasic-irq.c b/arch/mips/dec/ioasic-irq.c
index 269b22b34313..4c7cb4048d35 100644
--- a/arch/mips/dec/ioasic-irq.c
+++ b/arch/mips/dec/ioasic-irq.c
@@ -67,7 +67,6 @@ static struct irq_chip ioasic_irq_type = {
67 .mask = mask_ioasic_irq, 67 .mask = mask_ioasic_irq,
68 .mask_ack = ack_ioasic_irq, 68 .mask_ack = ack_ioasic_irq,
69 .unmask = unmask_ioasic_irq, 69 .unmask = unmask_ioasic_irq,
70 .end = end_ioasic_irq,
71}; 70};
72 71
73 72
@@ -106,8 +105,7 @@ void __init init_ioasic_irqs(int base)
106 set_irq_chip_and_handler(i, &ioasic_irq_type, 105 set_irq_chip_and_handler(i, &ioasic_irq_type,
107 handle_level_irq); 106 handle_level_irq);
108 for (; i < base + IO_IRQ_LINES; i++) 107 for (; i < base + IO_IRQ_LINES; i++)
109 set_irq_chip_and_handler(i, &ioasic_dma_irq_type, 108 set_irq_chip(i, &ioasic_dma_irq_type);
110 handle_level_irq);
111 109
112 ioasic_irq_base = base; 110 ioasic_irq_base = base;
113} 111}
diff --git a/arch/mips/dec/kn01-berr.c b/arch/mips/dec/kn01-berr.c
index f19b4617a0a6..d3b8002bf1e7 100644
--- a/arch/mips/dec/kn01-berr.c
+++ b/arch/mips/dec/kn01-berr.c
@@ -20,8 +20,10 @@
20#include <linux/types.h> 20#include <linux/types.h>
21 21
22#include <asm/inst.h> 22#include <asm/inst.h>
23#include <asm/irq_regs.h>
23#include <asm/mipsregs.h> 24#include <asm/mipsregs.h>
24#include <asm/page.h> 25#include <asm/page.h>
26#include <asm/ptrace.h>
25#include <asm/system.h> 27#include <asm/system.h>
26#include <asm/traps.h> 28#include <asm/traps.h>
27#include <asm/uaccess.h> 29#include <asm/uaccess.h>
diff --git a/arch/mips/dec/kn02-irq.c b/arch/mips/dec/kn02-irq.c
index 5a9be4c93584..916e46b8ccd8 100644
--- a/arch/mips/dec/kn02-irq.c
+++ b/arch/mips/dec/kn02-irq.c
@@ -57,19 +57,12 @@ static void ack_kn02_irq(unsigned int irq)
57 iob(); 57 iob();
58} 58}
59 59
60static void end_kn02_irq(unsigned int irq)
61{
62 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
63 unmask_kn02_irq(irq);
64}
65
66static struct irq_chip kn02_irq_type = { 60static struct irq_chip kn02_irq_type = {
67 .typename = "KN02-CSR", 61 .typename = "KN02-CSR",
68 .ack = ack_kn02_irq, 62 .ack = ack_kn02_irq,
69 .mask = mask_kn02_irq, 63 .mask = mask_kn02_irq,
70 .mask_ack = ack_kn02_irq, 64 .mask_ack = ack_kn02_irq,
71 .unmask = unmask_kn02_irq, 65 .unmask = unmask_kn02_irq,
72 .end = end_kn02_irq,
73}; 66};
74 67
75 68
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
index 59b98299c896..8d880f0b06ec 100644
--- a/arch/mips/emma2rh/common/irq_emma2rh.c
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -56,19 +56,12 @@ static void emma2rh_irq_disable(unsigned int irq)
56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base); 56 ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
57} 57}
58 58
59static void emma2rh_irq_end(unsigned int irq)
60{
61 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
62 ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
63}
64
65struct irq_chip emma2rh_irq_controller = { 59struct irq_chip emma2rh_irq_controller = {
66 .typename = "emma2rh_irq", 60 .typename = "emma2rh_irq",
67 .ack = emma2rh_irq_disable, 61 .ack = emma2rh_irq_disable,
68 .mask = emma2rh_irq_disable, 62 .mask = emma2rh_irq_disable,
69 .mask_ack = emma2rh_irq_disable, 63 .mask_ack = emma2rh_irq_disable,
70 .unmask = emma2rh_irq_enable, 64 .unmask = emma2rh_irq_enable,
71 .end = emma2rh_irq_end,
72}; 65};
73 66
74void emma2rh_irq_init(u32 irq_base) 67void emma2rh_irq_init(u32 irq_base)
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
index 3ac4e405ecdc..2116d9be5fa9 100644
--- a/arch/mips/emma2rh/markeins/irq_markeins.c
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -48,19 +48,12 @@ static void emma2rh_sw_irq_disable(unsigned int irq)
48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base); 48 ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
49} 49}
50 50
51static void emma2rh_sw_irq_end(unsigned int irq)
52{
53 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
54 ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
55}
56
57struct irq_chip emma2rh_sw_irq_controller = { 51struct irq_chip emma2rh_sw_irq_controller = {
58 .typename = "emma2rh_sw_irq", 52 .typename = "emma2rh_sw_irq",
59 .ack = emma2rh_sw_irq_disable, 53 .ack = emma2rh_sw_irq_disable,
60 .mask = emma2rh_sw_irq_disable, 54 .mask = emma2rh_sw_irq_disable,
61 .mask_ack = emma2rh_sw_irq_disable, 55 .mask_ack = emma2rh_sw_irq_disable,
62 .unmask = emma2rh_sw_irq_enable, 56 .unmask = emma2rh_sw_irq_enable,
63 .end = emma2rh_sw_irq_end,
64}; 57};
65 58
66void emma2rh_sw_irq_init(u32 irq_base) 59void emma2rh_sw_irq_init(u32 irq_base)
diff --git a/arch/mips/jazz/irq.c b/arch/mips/jazz/irq.c
index 5c4f50cdf157..f8d417b5c2bb 100644
--- a/arch/mips/jazz/irq.c
+++ b/arch/mips/jazz/irq.c
@@ -39,19 +39,12 @@ void disable_r4030_irq(unsigned int irq)
39 spin_unlock_irqrestore(&r4030_lock, flags); 39 spin_unlock_irqrestore(&r4030_lock, flags);
40} 40}
41 41
42static void end_r4030_irq(unsigned int irq)
43{
44 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
45 enable_r4030_irq(irq);
46}
47
48static struct irq_chip r4030_irq_type = { 42static struct irq_chip r4030_irq_type = {
49 .typename = "R4030", 43 .typename = "R4030",
50 .ack = disable_r4030_irq, 44 .ack = disable_r4030_irq,
51 .mask = disable_r4030_irq, 45 .mask = disable_r4030_irq,
52 .mask_ack = disable_r4030_irq, 46 .mask_ack = disable_r4030_irq,
53 .unmask = enable_r4030_irq, 47 .unmask = enable_r4030_irq,
54 .end = end_r4030_irq,
55}; 48};
56 49
57void __init init_r4030_ints(void) 50void __init init_r4030_ints(void)
diff --git a/arch/mips/kernel/i8259.c b/arch/mips/kernel/i8259.c
index 2526c0ca4d81..b59a676c6d0e 100644
--- a/arch/mips/kernel/i8259.c
+++ b/arch/mips/kernel/i8259.c
@@ -19,9 +19,6 @@
19#include <asm/i8259.h> 19#include <asm/i8259.h>
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22void enable_8259A_irq(unsigned int irq);
23void disable_8259A_irq(unsigned int irq);
24
25/* 22/*
26 * This is the 'legacy' 8259A Programmable Interrupt Controller, 23 * This is the 'legacy' 8259A Programmable Interrupt Controller,
27 * present in the majority of PC/AT boxes. 24 * present in the majority of PC/AT boxes.
@@ -31,23 +28,16 @@ void disable_8259A_irq(unsigned int irq);
31 * moves to arch independent land 28 * moves to arch independent land
32 */ 29 */
33 30
31static int i8259A_auto_eoi;
34DEFINE_SPINLOCK(i8259A_lock); 32DEFINE_SPINLOCK(i8259A_lock);
35 33/* some platforms call this... */
36static void end_8259A_irq (unsigned int irq)
37{
38 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
39 irq_desc[irq].action)
40 enable_8259A_irq(irq);
41}
42
43void mask_and_ack_8259A(unsigned int); 34void mask_and_ack_8259A(unsigned int);
44 35
45static struct irq_chip i8259A_irq_type = { 36static struct irq_chip i8259A_chip = {
46 .typename = "XT-PIC", 37 .name = "XT-PIC",
47 .enable = enable_8259A_irq, 38 .mask = disable_8259A_irq,
48 .disable = disable_8259A_irq, 39 .unmask = enable_8259A_irq,
49 .ack = mask_and_ack_8259A, 40 .mask_ack = mask_and_ack_8259A,
50 .end = end_8259A_irq,
51}; 41};
52 42
53/* 43/*
@@ -59,8 +49,8 @@ static struct irq_chip i8259A_irq_type = {
59 */ 49 */
60static unsigned int cached_irq_mask = 0xffff; 50static unsigned int cached_irq_mask = 0xffff;
61 51
62#define cached_21 (cached_irq_mask) 52#define cached_master_mask (cached_irq_mask)
63#define cached_A1 (cached_irq_mask >> 8) 53#define cached_slave_mask (cached_irq_mask >> 8)
64 54
65void disable_8259A_irq(unsigned int irq) 55void disable_8259A_irq(unsigned int irq)
66{ 56{
@@ -70,9 +60,9 @@ void disable_8259A_irq(unsigned int irq)
70 spin_lock_irqsave(&i8259A_lock, flags); 60 spin_lock_irqsave(&i8259A_lock, flags);
71 cached_irq_mask |= mask; 61 cached_irq_mask |= mask;
72 if (irq & 8) 62 if (irq & 8)
73 outb(cached_A1,0xA1); 63 outb(cached_slave_mask, PIC_SLAVE_IMR);
74 else 64 else
75 outb(cached_21,0x21); 65 outb(cached_master_mask, PIC_MASTER_IMR);
76 spin_unlock_irqrestore(&i8259A_lock, flags); 66 spin_unlock_irqrestore(&i8259A_lock, flags);
77} 67}
78 68
@@ -84,9 +74,9 @@ void enable_8259A_irq(unsigned int irq)
84 spin_lock_irqsave(&i8259A_lock, flags); 74 spin_lock_irqsave(&i8259A_lock, flags);
85 cached_irq_mask &= mask; 75 cached_irq_mask &= mask;
86 if (irq & 8) 76 if (irq & 8)
87 outb(cached_A1,0xA1); 77 outb(cached_slave_mask, PIC_SLAVE_IMR);
88 else 78 else
89 outb(cached_21,0x21); 79 outb(cached_master_mask, PIC_MASTER_IMR);
90 spin_unlock_irqrestore(&i8259A_lock, flags); 80 spin_unlock_irqrestore(&i8259A_lock, flags);
91} 81}
92 82
@@ -98,9 +88,9 @@ int i8259A_irq_pending(unsigned int irq)
98 88
99 spin_lock_irqsave(&i8259A_lock, flags); 89 spin_lock_irqsave(&i8259A_lock, flags);
100 if (irq < 8) 90 if (irq < 8)
101 ret = inb(0x20) & mask; 91 ret = inb(PIC_MASTER_CMD) & mask;
102 else 92 else
103 ret = inb(0xA0) & (mask >> 8); 93 ret = inb(PIC_SLAVE_CMD) & (mask >> 8);
104 spin_unlock_irqrestore(&i8259A_lock, flags); 94 spin_unlock_irqrestore(&i8259A_lock, flags);
105 95
106 return ret; 96 return ret;
@@ -109,7 +99,7 @@ int i8259A_irq_pending(unsigned int irq)
109void make_8259A_irq(unsigned int irq) 99void make_8259A_irq(unsigned int irq)
110{ 100{
111 disable_irq_nosync(irq); 101 disable_irq_nosync(irq);
112 set_irq_chip(irq, &i8259A_irq_type); 102 set_irq_chip_and_handler(irq, &i8259A_chip, handle_level_irq);
113 enable_irq(irq); 103 enable_irq(irq);
114} 104}
115 105
@@ -125,14 +115,14 @@ static inline int i8259A_irq_real(unsigned int irq)
125 int irqmask = 1 << irq; 115 int irqmask = 1 << irq;
126 116
127 if (irq < 8) { 117 if (irq < 8) {
128 outb(0x0B,0x20); /* ISR register */ 118 outb(0x0B,PIC_MASTER_CMD); /* ISR register */
129 value = inb(0x20) & irqmask; 119 value = inb(PIC_MASTER_CMD) & irqmask;
130 outb(0x0A,0x20); /* back to the IRR register */ 120 outb(0x0A,PIC_MASTER_CMD); /* back to the IRR register */
131 return value; 121 return value;
132 } 122 }
133 outb(0x0B,0xA0); /* ISR register */ 123 outb(0x0B,PIC_SLAVE_CMD); /* ISR register */
134 value = inb(0xA0) & (irqmask >> 8); 124 value = inb(PIC_SLAVE_CMD) & (irqmask >> 8);
135 outb(0x0A,0xA0); /* back to the IRR register */ 125 outb(0x0A,PIC_SLAVE_CMD); /* back to the IRR register */
136 return value; 126 return value;
137} 127}
138 128
@@ -149,17 +139,19 @@ void mask_and_ack_8259A(unsigned int irq)
149 139
150 spin_lock_irqsave(&i8259A_lock, flags); 140 spin_lock_irqsave(&i8259A_lock, flags);
151 /* 141 /*
152 * Lightweight spurious IRQ detection. We do not want to overdo 142 * Lightweight spurious IRQ detection. We do not want
153 * spurious IRQ handling - it's usually a sign of hardware problems, so 143 * to overdo spurious IRQ handling - it's usually a sign
154 * we only do the checks we can do without slowing down good hardware 144 * of hardware problems, so we only do the checks we can
155 * nnecesserily. 145 * do without slowing down good hardware unnecessarily.
156 * 146 *
157 * Note that IRQ7 and IRQ15 (the two spurious IRQs usually resulting 147 * Note that IRQ7 and IRQ15 (the two spurious IRQs
158 * rom the 8259A-1|2 PICs) occur even if the IRQ is masked in the 8259A. 148 * usually resulting from the 8259A-1|2 PICs) occur
159 * Thus we can check spurious 8259A IRQs without doing the quite slow 149 * even if the IRQ is masked in the 8259A. Thus we
160 * i8259A_irq_real() call for every IRQ. This does not cover 100% of 150 * can check spurious 8259A IRQs without doing the
161 * spurious interrupts, but should be enough to warn the user that 151 * quite slow i8259A_irq_real() call for every IRQ.
162 * there is something bad going on ... 152 * This does not cover 100% of spurious interrupts,
153 * but should be enough to warn the user that there
154 * is something bad going on ...
163 */ 155 */
164 if (cached_irq_mask & irqmask) 156 if (cached_irq_mask & irqmask)
165 goto spurious_8259A_irq; 157 goto spurious_8259A_irq;
@@ -167,14 +159,14 @@ void mask_and_ack_8259A(unsigned int irq)
167 159
168handle_real_irq: 160handle_real_irq:
169 if (irq & 8) { 161 if (irq & 8) {
170 inb(0xA1); /* DUMMY - (do we need this?) */ 162 inb(PIC_SLAVE_IMR); /* DUMMY - (do we need this?) */
171 outb(cached_A1,0xA1); 163 outb(cached_slave_mask, PIC_SLAVE_IMR);
172 outb(0x60+(irq&7),0xA0);/* 'Specific EOI' to slave */ 164 outb(0x60+(irq&7),PIC_SLAVE_CMD);/* 'Specific EOI' to slave */
173 outb(0x62,0x20); /* 'Specific EOI' to master-IRQ2 */ 165 outb(0x60+PIC_CASCADE_IR,PIC_MASTER_CMD); /* 'Specific EOI' to master-IRQ2 */
174 } else { 166 } else {
175 inb(0x21); /* DUMMY - (do we need this?) */ 167 inb(PIC_MASTER_IMR); /* DUMMY - (do we need this?) */
176 outb(cached_21,0x21); 168 outb(cached_master_mask, PIC_MASTER_IMR);
177 outb(0x60+irq,0x20); /* 'Specific EOI' to master */ 169 outb(0x60+irq,PIC_MASTER_CMD); /* 'Specific EOI to master */
178 } 170 }
179#ifdef CONFIG_MIPS_MT_SMTC 171#ifdef CONFIG_MIPS_MT_SMTC
180 if (irq_hwmask[irq] & ST0_IM) 172 if (irq_hwmask[irq] & ST0_IM)
@@ -195,7 +187,7 @@ spurious_8259A_irq:
195 goto handle_real_irq; 187 goto handle_real_irq;
196 188
197 { 189 {
198 static int spurious_irq_mask = 0; 190 static int spurious_irq_mask;
199 /* 191 /*
200 * At this point we can be sure the IRQ is spurious, 192 * At this point we can be sure the IRQ is spurious,
201 * lets ACK and report it. [once per IRQ] 193 * lets ACK and report it. [once per IRQ]
@@ -216,13 +208,25 @@ spurious_8259A_irq:
216 208
217static int i8259A_resume(struct sys_device *dev) 209static int i8259A_resume(struct sys_device *dev)
218{ 210{
219 init_8259A(0); 211 init_8259A(i8259A_auto_eoi);
212 return 0;
213}
214
215static int i8259A_shutdown(struct sys_device *dev)
216{
217 /* Put the i8259A into a quiescent state that
218 * the kernel initialization code can get it
219 * out of.
220 */
221 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
222 outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-1 */
220 return 0; 223 return 0;
221} 224}
222 225
223static struct sysdev_class i8259_sysdev_class = { 226static struct sysdev_class i8259_sysdev_class = {
224 set_kset_name("i8259"), 227 set_kset_name("i8259"),
225 .resume = i8259A_resume, 228 .resume = i8259A_resume,
229 .shutdown = i8259A_shutdown,
226}; 230};
227 231
228static struct sys_device device_i8259A = { 232static struct sys_device device_i8259A = {
@@ -244,41 +248,41 @@ void __init init_8259A(int auto_eoi)
244{ 248{
245 unsigned long flags; 249 unsigned long flags;
246 250
251 i8259A_auto_eoi = auto_eoi;
252
247 spin_lock_irqsave(&i8259A_lock, flags); 253 spin_lock_irqsave(&i8259A_lock, flags);
248 254
249 outb(0xff, 0x21); /* mask all of 8259A-1 */ 255 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
250 outb(0xff, 0xA1); /* mask all of 8259A-2 */ 256 outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
251 257
252 /* 258 /*
253 * outb_p - this has to work on a wide range of PC hardware. 259 * outb_p - this has to work on a wide range of PC hardware.
254 */ 260 */
255 outb_p(0x11, 0x20); /* ICW1: select 8259A-1 init */ 261 outb_p(0x11, PIC_MASTER_CMD); /* ICW1: select 8259A-1 init */
256 outb_p(0x00, 0x21); /* ICW2: 8259A-1 IR0-7 mapped to 0x00-0x07 */ 262 outb_p(I8259A_IRQ_BASE + 0, PIC_MASTER_IMR); /* ICW2: 8259A-1 IR0 mapped to I8259A_IRQ_BASE + 0x00 */
257 outb_p(0x04, 0x21); /* 8259A-1 (the master) has a slave on IR2 */ 263 outb_p(1U << PIC_CASCADE_IR, PIC_MASTER_IMR); /* 8259A-1 (the master) has a slave on IR2 */
258 if (auto_eoi) 264 if (auto_eoi) /* master does Auto EOI */
259 outb_p(0x03, 0x21); /* master does Auto EOI */ 265 outb_p(MASTER_ICW4_DEFAULT | PIC_ICW4_AEOI, PIC_MASTER_IMR);
260 else 266 else /* master expects normal EOI */
261 outb_p(0x01, 0x21); /* master expects normal EOI */ 267 outb_p(MASTER_ICW4_DEFAULT, PIC_MASTER_IMR);
262 268
263 outb_p(0x11, 0xA0); /* ICW1: select 8259A-2 init */ 269 outb_p(0x11, PIC_SLAVE_CMD); /* ICW1: select 8259A-2 init */
264 outb_p(0x08, 0xA1); /* ICW2: 8259A-2 IR0-7 mapped to 0x08-0x0f */ 270 outb_p(I8259A_IRQ_BASE + 8, PIC_SLAVE_IMR); /* ICW2: 8259A-2 IR0 mapped to I8259A_IRQ_BASE + 0x08 */
265 outb_p(0x02, 0xA1); /* 8259A-2 is a slave on master's IR2 */ 271 outb_p(PIC_CASCADE_IR, PIC_SLAVE_IMR); /* 8259A-2 is a slave on master's IR2 */
266 outb_p(0x01, 0xA1); /* (slave's support for AEOI in flat mode 272 outb_p(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR); /* (slave's support for AEOI in flat mode is to be investigated) */
267 is to be investigated) */
268
269 if (auto_eoi) 273 if (auto_eoi)
270 /* 274 /*
271 * in AEOI mode we just have to mask the interrupt 275 * In AEOI mode we just have to mask the interrupt
272 * when acking. 276 * when acking.
273 */ 277 */
274 i8259A_irq_type.ack = disable_8259A_irq; 278 i8259A_chip.mask_ack = disable_8259A_irq;
275 else 279 else
276 i8259A_irq_type.ack = mask_and_ack_8259A; 280 i8259A_chip.mask_ack = mask_and_ack_8259A;
277 281
278 udelay(100); /* wait for 8259A to initialize */ 282 udelay(100); /* wait for 8259A to initialize */
279 283
280 outb(cached_21, 0x21); /* restore master IRQ mask */ 284 outb(cached_master_mask, PIC_MASTER_IMR); /* restore master IRQ mask */
281 outb(cached_A1, 0xA1); /* restore slave IRQ mask */ 285 outb(cached_slave_mask, PIC_SLAVE_IMR); /* restore slave IRQ mask */
282 286
283 spin_unlock_irqrestore(&i8259A_lock, flags); 287 spin_unlock_irqrestore(&i8259A_lock, flags);
284} 288}
@@ -291,11 +295,17 @@ static struct irqaction irq2 = {
291}; 295};
292 296
293static struct resource pic1_io_resource = { 297static struct resource pic1_io_resource = {
294 .name = "pic1", .start = 0x20, .end = 0x21, .flags = IORESOURCE_BUSY 298 .name = "pic1",
299 .start = PIC_MASTER_CMD,
300 .end = PIC_MASTER_IMR,
301 .flags = IORESOURCE_BUSY
295}; 302};
296 303
297static struct resource pic2_io_resource = { 304static struct resource pic2_io_resource = {
298 .name = "pic2", .start = 0xa0, .end = 0xa1, .flags = IORESOURCE_BUSY 305 .name = "pic2",
306 .start = PIC_SLAVE_CMD,
307 .end = PIC_SLAVE_IMR,
308 .flags = IORESOURCE_BUSY
299}; 309};
300 310
301/* 311/*
@@ -313,7 +323,7 @@ void __init init_i8259_irqs (void)
313 init_8259A(0); 323 init_8259A(0);
314 324
315 for (i = 0; i < 16; i++) 325 for (i = 0; i < 16; i++)
316 set_irq_chip(i, &i8259A_irq_type); 326 set_irq_chip_and_handler(i, &i8259A_chip, handle_level_irq);
317 327
318 setup_irq(2, &irq2); 328 setup_irq(PIC_CASCADE_IR, &irq2);
319} 329}
diff --git a/arch/mips/kernel/irq-mv6434x.c b/arch/mips/kernel/irq-mv6434x.c
index 6cfb31cafde2..efbd219845b5 100644
--- a/arch/mips/kernel/irq-mv6434x.c
+++ b/arch/mips/kernel/irq-mv6434x.c
@@ -67,15 +67,6 @@ static inline void unmask_mv64340_irq(unsigned int irq)
67} 67}
68 68
69/* 69/*
70 * End IRQ processing
71 */
72static void end_mv64340_irq(unsigned int irq)
73{
74 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
75 unmask_mv64340_irq(irq);
76}
77
78/*
79 * Interrupt handler for interrupts coming from the Marvell chip. 70 * Interrupt handler for interrupts coming from the Marvell chip.
80 * It could be built in ethernet ports etc... 71 * It could be built in ethernet ports etc...
81 */ 72 */
@@ -106,7 +97,6 @@ struct irq_chip mv64340_irq_type = {
106 .mask = mask_mv64340_irq, 97 .mask = mask_mv64340_irq,
107 .mask_ack = mask_mv64340_irq, 98 .mask_ack = mask_mv64340_irq,
108 .unmask = unmask_mv64340_irq, 99 .unmask = unmask_mv64340_irq,
109 .end = end_mv64340_irq,
110}; 100};
111 101
112void __init mv64340_irq_init(unsigned int base) 102void __init mv64340_irq_init(unsigned int base)
diff --git a/arch/mips/kernel/irq-rm7000.c b/arch/mips/kernel/irq-rm7000.c
index ddcc2a5f8a06..123324ba8c14 100644
--- a/arch/mips/kernel/irq-rm7000.c
+++ b/arch/mips/kernel/irq-rm7000.c
@@ -29,19 +29,12 @@ static inline void mask_rm7k_irq(unsigned int irq)
29 clear_c0_intcontrol(0x100 << (irq - irq_base)); 29 clear_c0_intcontrol(0x100 << (irq - irq_base));
30} 30}
31 31
32static void rm7k_cpu_irq_end(unsigned int irq)
33{
34 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
35 unmask_rm7k_irq(irq);
36}
37
38static struct irq_chip rm7k_irq_controller = { 32static struct irq_chip rm7k_irq_controller = {
39 .typename = "RM7000", 33 .typename = "RM7000",
40 .ack = mask_rm7k_irq, 34 .ack = mask_rm7k_irq,
41 .mask = mask_rm7k_irq, 35 .mask = mask_rm7k_irq,
42 .mask_ack = mask_rm7k_irq, 36 .mask_ack = mask_rm7k_irq,
43 .unmask = unmask_rm7k_irq, 37 .unmask = unmask_rm7k_irq,
44 .end = rm7k_cpu_irq_end,
45}; 38};
46 39
47void __init rm7k_cpu_irq_init(int base) 40void __init rm7k_cpu_irq_init(int base)
diff --git a/arch/mips/kernel/irq-rm9000.c b/arch/mips/kernel/irq-rm9000.c
index ba6440c88abd..0e6f4c5349d2 100644
--- a/arch/mips/kernel/irq-rm9000.c
+++ b/arch/mips/kernel/irq-rm9000.c
@@ -80,19 +80,12 @@ static void rm9k_perfcounter_irq_shutdown(unsigned int irq)
80 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1); 80 on_each_cpu(local_rm9k_perfcounter_irq_shutdown, (void *) irq, 0, 1);
81} 81}
82 82
83static void rm9k_cpu_irq_end(unsigned int irq)
84{
85 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
86 unmask_rm9k_irq(irq);
87}
88
89static struct irq_chip rm9k_irq_controller = { 83static struct irq_chip rm9k_irq_controller = {
90 .typename = "RM9000", 84 .typename = "RM9000",
91 .ack = mask_rm9k_irq, 85 .ack = mask_rm9k_irq,
92 .mask = mask_rm9k_irq, 86 .mask = mask_rm9k_irq,
93 .mask_ack = mask_rm9k_irq, 87 .mask_ack = mask_rm9k_irq,
94 .unmask = unmask_rm9k_irq, 88 .unmask = unmask_rm9k_irq,
95 .end = rm9k_cpu_irq_end,
96}; 89};
97 90
98static struct irq_chip rm9k_perfcounter_irq = { 91static struct irq_chip rm9k_perfcounter_irq = {
@@ -103,7 +96,6 @@ static struct irq_chip rm9k_perfcounter_irq = {
103 .mask = mask_rm9k_irq, 96 .mask = mask_rm9k_irq,
104 .mask_ack = mask_rm9k_irq, 97 .mask_ack = mask_rm9k_irq,
105 .unmask = unmask_rm9k_irq, 98 .unmask = unmask_rm9k_irq,
106 .end = rm9k_cpu_irq_end,
107}; 99};
108 100
109unsigned int rm9000_perfcount_irq; 101unsigned int rm9000_perfcount_irq;
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index b339798b3172..2fe4c868a801 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -117,7 +117,7 @@ int show_interrupts(struct seq_file *p, void *v)
117 for_each_online_cpu(j) 117 for_each_online_cpu(j)
118 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); 118 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
119#endif 119#endif
120 seq_printf(p, " %14s", irq_desc[i].chip->typename); 120 seq_printf(p, " %14s", irq_desc[i].chip->name);
121 seq_printf(p, " %s", action->name); 121 seq_printf(p, " %s", action->name);
122 122
123 for (action=action->next; action; action = action->next) 123 for (action=action->next; action; action = action->next)
diff --git a/arch/mips/kernel/irq_cpu.c b/arch/mips/kernel/irq_cpu.c
index be5ac23d3812..fcc86b96ccf6 100644
--- a/arch/mips/kernel/irq_cpu.c
+++ b/arch/mips/kernel/irq_cpu.c
@@ -50,12 +50,6 @@ static inline void mask_mips_irq(unsigned int irq)
50 irq_disable_hazard(); 50 irq_disable_hazard();
51} 51}
52 52
53static void mips_cpu_irq_end(unsigned int irq)
54{
55 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
56 unmask_mips_irq(irq);
57}
58
59static struct irq_chip mips_cpu_irq_controller = { 53static struct irq_chip mips_cpu_irq_controller = {
60 .typename = "MIPS", 54 .typename = "MIPS",
61 .ack = mask_mips_irq, 55 .ack = mask_mips_irq,
@@ -63,7 +57,6 @@ static struct irq_chip mips_cpu_irq_controller = {
63 .mask_ack = mask_mips_irq, 57 .mask_ack = mask_mips_irq,
64 .unmask = unmask_mips_irq, 58 .unmask = unmask_mips_irq,
65 .eoi = unmask_mips_irq, 59 .eoi = unmask_mips_irq,
66 .end = mips_cpu_irq_end,
67}; 60};
68 61
69/* 62/*
@@ -96,8 +89,6 @@ static void mips_mt_cpu_irq_ack(unsigned int irq)
96 mask_mips_mt_irq(irq); 89 mask_mips_mt_irq(irq);
97} 90}
98 91
99#define mips_mt_cpu_irq_end mips_cpu_irq_end
100
101static struct irq_chip mips_mt_cpu_irq_controller = { 92static struct irq_chip mips_mt_cpu_irq_controller = {
102 .typename = "MIPS", 93 .typename = "MIPS",
103 .startup = mips_mt_cpu_irq_startup, 94 .startup = mips_mt_cpu_irq_startup,
@@ -106,7 +97,6 @@ static struct irq_chip mips_mt_cpu_irq_controller = {
106 .mask_ack = mips_mt_cpu_irq_ack, 97 .mask_ack = mips_mt_cpu_irq_ack,
107 .unmask = unmask_mips_mt_irq, 98 .unmask = unmask_mips_mt_irq,
108 .eoi = unmask_mips_mt_irq, 99 .eoi = unmask_mips_mt_irq,
109 .end = mips_mt_cpu_irq_end,
110}; 100};
111 101
112void __init mips_cpu_irq_init(int irq_base) 102void __init mips_cpu_irq_init(int irq_base)
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index f06a144c7881..2c82412b9efe 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -319,7 +319,7 @@ static void sp_cleanup(void)
319static int channel_open = 0; 319static int channel_open = 0;
320 320
321/* the work handler */ 321/* the work handler */
322static void sp_work(void *data) 322static void sp_work(struct work_struct *unused)
323{ 323{
324 if (!channel_open) { 324 if (!channel_open) {
325 if( rtlx_open(RTLX_CHANNEL_SYSIO, 1) != 0) { 325 if( rtlx_open(RTLX_CHANNEL_SYSIO, 1) != 0) {
@@ -354,7 +354,7 @@ static void startwork(int vpe)
354 return; 354 return;
355 } 355 }
356 356
357 INIT_WORK(&work, sp_work, NULL); 357 INIT_WORK(&work, sp_work);
358 queue_work(workqueue, &work); 358 queue_work(workqueue, &work);
359 } else 359 } else
360 queue_work(workqueue, &work); 360 queue_work(workqueue, &work);
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 7a3ebbeba1f3..b061c9aa6302 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -382,531 +382,6 @@ asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid,
382 return ret; 382 return ret;
383} 383}
384 384
385struct msgbuf32 { s32 mtype; char mtext[1]; };
386
387struct ipc_perm32
388{
389 key_t key;
390 __compat_uid_t uid;
391 __compat_gid_t gid;
392 __compat_uid_t cuid;
393 __compat_gid_t cgid;
394 compat_mode_t mode;
395 unsigned short seq;
396};
397
398struct ipc64_perm32 {
399 key_t key;
400 __compat_uid_t uid;
401 __compat_gid_t gid;
402 __compat_uid_t cuid;
403 __compat_gid_t cgid;
404 compat_mode_t mode;
405 unsigned short seq;
406 unsigned short __pad1;
407 unsigned int __unused1;
408 unsigned int __unused2;
409};
410
411struct semid_ds32 {
412 struct ipc_perm32 sem_perm; /* permissions .. see ipc.h */
413 compat_time_t sem_otime; /* last semop time */
414 compat_time_t sem_ctime; /* last change time */
415 u32 sem_base; /* ptr to first semaphore in array */
416 u32 sem_pending; /* pending operations to be processed */
417 u32 sem_pending_last; /* last pending operation */
418 u32 undo; /* undo requests on this array */
419 unsigned short sem_nsems; /* no. of semaphores in array */
420};
421
422struct semid64_ds32 {
423 struct ipc64_perm32 sem_perm;
424 compat_time_t sem_otime;
425 compat_time_t sem_ctime;
426 unsigned int sem_nsems;
427 unsigned int __unused1;
428 unsigned int __unused2;
429};
430
431struct msqid_ds32
432{
433 struct ipc_perm32 msg_perm;
434 u32 msg_first;
435 u32 msg_last;
436 compat_time_t msg_stime;
437 compat_time_t msg_rtime;
438 compat_time_t msg_ctime;
439 u32 wwait;
440 u32 rwait;
441 unsigned short msg_cbytes;
442 unsigned short msg_qnum;
443 unsigned short msg_qbytes;
444 compat_ipc_pid_t msg_lspid;
445 compat_ipc_pid_t msg_lrpid;
446};
447
448struct msqid64_ds32 {
449 struct ipc64_perm32 msg_perm;
450 compat_time_t msg_stime;
451 unsigned int __unused1;
452 compat_time_t msg_rtime;
453 unsigned int __unused2;
454 compat_time_t msg_ctime;
455 unsigned int __unused3;
456 unsigned int msg_cbytes;
457 unsigned int msg_qnum;
458 unsigned int msg_qbytes;
459 compat_pid_t msg_lspid;
460 compat_pid_t msg_lrpid;
461 unsigned int __unused4;
462 unsigned int __unused5;
463};
464
465struct shmid_ds32 {
466 struct ipc_perm32 shm_perm;
467 int shm_segsz;
468 compat_time_t shm_atime;
469 compat_time_t shm_dtime;
470 compat_time_t shm_ctime;
471 compat_ipc_pid_t shm_cpid;
472 compat_ipc_pid_t shm_lpid;
473 unsigned short shm_nattch;
474};
475
476struct shmid64_ds32 {
477 struct ipc64_perm32 shm_perm;
478 compat_size_t shm_segsz;
479 compat_time_t shm_atime;
480 compat_time_t shm_dtime;
481 compat_time_t shm_ctime;
482 compat_pid_t shm_cpid;
483 compat_pid_t shm_lpid;
484 unsigned int shm_nattch;
485 unsigned int __unused1;
486 unsigned int __unused2;
487};
488
489struct ipc_kludge32 {
490 u32 msgp;
491 s32 msgtyp;
492};
493
494static int
495do_sys32_semctl(int first, int second, int third, void __user *uptr)
496{
497 union semun fourth;
498 u32 pad;
499 int err, err2;
500 struct semid64_ds s;
501 mm_segment_t old_fs;
502
503 if (!uptr)
504 return -EINVAL;
505 err = -EFAULT;
506 if (get_user (pad, (u32 __user *)uptr))
507 return err;
508 if ((third & ~IPC_64) == SETVAL)
509 fourth.val = (int)pad;
510 else
511 fourth.__pad = (void __user *)A(pad);
512 switch (third & ~IPC_64) {
513 case IPC_INFO:
514 case IPC_RMID:
515 case IPC_SET:
516 case SEM_INFO:
517 case GETVAL:
518 case GETPID:
519 case GETNCNT:
520 case GETZCNT:
521 case GETALL:
522 case SETVAL:
523 case SETALL:
524 err = sys_semctl (first, second, third, fourth);
525 break;
526
527 case IPC_STAT:
528 case SEM_STAT:
529 fourth.__pad = (struct semid64_ds __user *)&s;
530 old_fs = get_fs();
531 set_fs(KERNEL_DS);
532 err = sys_semctl(first, second, third | IPC_64, fourth);
533 set_fs(old_fs);
534
535 if (third & IPC_64) {
536 struct semid64_ds32 __user *usp64 = (struct semid64_ds32 __user *) A(pad);
537
538 if (!access_ok(VERIFY_WRITE, usp64, sizeof(*usp64))) {
539 err = -EFAULT;
540 break;
541 }
542 err2 = __put_user(s.sem_perm.key, &usp64->sem_perm.key);
543 err2 |= __put_user(s.sem_perm.uid, &usp64->sem_perm.uid);
544 err2 |= __put_user(s.sem_perm.gid, &usp64->sem_perm.gid);
545 err2 |= __put_user(s.sem_perm.cuid, &usp64->sem_perm.cuid);
546 err2 |= __put_user(s.sem_perm.cgid, &usp64->sem_perm.cgid);
547 err2 |= __put_user(s.sem_perm.mode, &usp64->sem_perm.mode);
548 err2 |= __put_user(s.sem_perm.seq, &usp64->sem_perm.seq);
549 err2 |= __put_user(s.sem_otime, &usp64->sem_otime);
550 err2 |= __put_user(s.sem_ctime, &usp64->sem_ctime);
551 err2 |= __put_user(s.sem_nsems, &usp64->sem_nsems);
552 } else {
553 struct semid_ds32 __user *usp32 = (struct semid_ds32 __user *) A(pad);
554
555 if (!access_ok(VERIFY_WRITE, usp32, sizeof(*usp32))) {
556 err = -EFAULT;
557 break;
558 }
559 err2 = __put_user(s.sem_perm.key, &usp32->sem_perm.key);
560 err2 |= __put_user(s.sem_perm.uid, &usp32->sem_perm.uid);
561 err2 |= __put_user(s.sem_perm.gid, &usp32->sem_perm.gid);
562 err2 |= __put_user(s.sem_perm.cuid, &usp32->sem_perm.cuid);
563 err2 |= __put_user(s.sem_perm.cgid, &usp32->sem_perm.cgid);
564 err2 |= __put_user(s.sem_perm.mode, &usp32->sem_perm.mode);
565 err2 |= __put_user(s.sem_perm.seq, &usp32->sem_perm.seq);
566 err2 |= __put_user(s.sem_otime, &usp32->sem_otime);
567 err2 |= __put_user(s.sem_ctime, &usp32->sem_ctime);
568 err2 |= __put_user(s.sem_nsems, &usp32->sem_nsems);
569 }
570 if (err2)
571 err = -EFAULT;
572 break;
573
574 default:
575 err = - EINVAL;
576 break;
577 }
578
579 return err;
580}
581
582static int
583do_sys32_msgsnd (int first, int second, int third, void __user *uptr)
584{
585 struct msgbuf32 __user *up = (struct msgbuf32 __user *)uptr;
586 struct msgbuf *p;
587 mm_segment_t old_fs;
588 int err;
589
590 if (second < 0)
591 return -EINVAL;
592 p = kmalloc (second + sizeof (struct msgbuf)
593 + 4, GFP_USER);
594 if (!p)
595 return -ENOMEM;
596 err = get_user (p->mtype, &up->mtype);
597 if (err)
598 goto out;
599 err |= __copy_from_user (p->mtext, &up->mtext, second);
600 if (err)
601 goto out;
602 old_fs = get_fs ();
603 set_fs (KERNEL_DS);
604 err = sys_msgsnd (first, (struct msgbuf __user *)p, second, third);
605 set_fs (old_fs);
606out:
607 kfree (p);
608
609 return err;
610}
611
612static int
613do_sys32_msgrcv (int first, int second, int msgtyp, int third,
614 int version, void __user *uptr)
615{
616 struct msgbuf32 __user *up;
617 struct msgbuf *p;
618 mm_segment_t old_fs;
619 int err;
620
621 if (!version) {
622 struct ipc_kludge32 __user *uipck = (struct ipc_kludge32 __user *)uptr;
623 struct ipc_kludge32 ipck;
624
625 err = -EINVAL;
626 if (!uptr)
627 goto out;
628 err = -EFAULT;
629 if (copy_from_user (&ipck, uipck, sizeof (struct ipc_kludge32)))
630 goto out;
631 uptr = (void __user *)AA(ipck.msgp);
632 msgtyp = ipck.msgtyp;
633 }
634
635 if (second < 0)
636 return -EINVAL;
637 err = -ENOMEM;
638 p = kmalloc (second + sizeof (struct msgbuf) + 4, GFP_USER);
639 if (!p)
640 goto out;
641 old_fs = get_fs ();
642 set_fs (KERNEL_DS);
643 err = sys_msgrcv (first, (struct msgbuf __user *)p, second + 4, msgtyp, third);
644 set_fs (old_fs);
645 if (err < 0)
646 goto free_then_out;
647 up = (struct msgbuf32 __user *)uptr;
648 if (put_user (p->mtype, &up->mtype) ||
649 __copy_to_user (&up->mtext, p->mtext, err))
650 err = -EFAULT;
651free_then_out:
652 kfree (p);
653out:
654 return err;
655}
656
657static int
658do_sys32_msgctl (int first, int second, void __user *uptr)
659{
660 int err = -EINVAL, err2;
661 struct msqid64_ds m;
662 struct msqid_ds32 __user *up32 = (struct msqid_ds32 __user *)uptr;
663 struct msqid64_ds32 __user *up64 = (struct msqid64_ds32 __user *)uptr;
664 mm_segment_t old_fs;
665
666 switch (second & ~IPC_64) {
667 case IPC_INFO:
668 case IPC_RMID:
669 case MSG_INFO:
670 err = sys_msgctl (first, second, (struct msqid_ds __user *)uptr);
671 break;
672
673 case IPC_SET:
674 if (second & IPC_64) {
675 if (!access_ok(VERIFY_READ, up64, sizeof(*up64))) {
676 err = -EFAULT;
677 break;
678 }
679 err = __get_user(m.msg_perm.uid, &up64->msg_perm.uid);
680 err |= __get_user(m.msg_perm.gid, &up64->msg_perm.gid);
681 err |= __get_user(m.msg_perm.mode, &up64->msg_perm.mode);
682 err |= __get_user(m.msg_qbytes, &up64->msg_qbytes);
683 } else {
684 if (!access_ok(VERIFY_READ, up32, sizeof(*up32))) {
685 err = -EFAULT;
686 break;
687 }
688 err = __get_user(m.msg_perm.uid, &up32->msg_perm.uid);
689 err |= __get_user(m.msg_perm.gid, &up32->msg_perm.gid);
690 err |= __get_user(m.msg_perm.mode, &up32->msg_perm.mode);
691 err |= __get_user(m.msg_qbytes, &up32->msg_qbytes);
692 }
693 if (err)
694 break;
695 old_fs = get_fs();
696 set_fs(KERNEL_DS);
697 err = sys_msgctl(first, second | IPC_64, (struct msqid_ds __user *)&m);
698 set_fs(old_fs);
699 break;
700
701 case IPC_STAT:
702 case MSG_STAT:
703 old_fs = get_fs();
704 set_fs(KERNEL_DS);
705 err = sys_msgctl(first, second | IPC_64, (struct msqid_ds __user *)&m);
706 set_fs(old_fs);
707 if (second & IPC_64) {
708 if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) {
709 err = -EFAULT;
710 break;
711 }
712 err2 = __put_user(m.msg_perm.key, &up64->msg_perm.key);
713 err2 |= __put_user(m.msg_perm.uid, &up64->msg_perm.uid);
714 err2 |= __put_user(m.msg_perm.gid, &up64->msg_perm.gid);
715 err2 |= __put_user(m.msg_perm.cuid, &up64->msg_perm.cuid);
716 err2 |= __put_user(m.msg_perm.cgid, &up64->msg_perm.cgid);
717 err2 |= __put_user(m.msg_perm.mode, &up64->msg_perm.mode);
718 err2 |= __put_user(m.msg_perm.seq, &up64->msg_perm.seq);
719 err2 |= __put_user(m.msg_stime, &up64->msg_stime);
720 err2 |= __put_user(m.msg_rtime, &up64->msg_rtime);
721 err2 |= __put_user(m.msg_ctime, &up64->msg_ctime);
722 err2 |= __put_user(m.msg_cbytes, &up64->msg_cbytes);
723 err2 |= __put_user(m.msg_qnum, &up64->msg_qnum);
724 err2 |= __put_user(m.msg_qbytes, &up64->msg_qbytes);
725 err2 |= __put_user(m.msg_lspid, &up64->msg_lspid);
726 err2 |= __put_user(m.msg_lrpid, &up64->msg_lrpid);
727 if (err2)
728 err = -EFAULT;
729 } else {
730 if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) {
731 err = -EFAULT;
732 break;
733 }
734 err2 = __put_user(m.msg_perm.key, &up32->msg_perm.key);
735 err2 |= __put_user(m.msg_perm.uid, &up32->msg_perm.uid);
736 err2 |= __put_user(m.msg_perm.gid, &up32->msg_perm.gid);
737 err2 |= __put_user(m.msg_perm.cuid, &up32->msg_perm.cuid);
738 err2 |= __put_user(m.msg_perm.cgid, &up32->msg_perm.cgid);
739 err2 |= __put_user(m.msg_perm.mode, &up32->msg_perm.mode);
740 err2 |= __put_user(m.msg_perm.seq, &up32->msg_perm.seq);
741 err2 |= __put_user(m.msg_stime, &up32->msg_stime);
742 err2 |= __put_user(m.msg_rtime, &up32->msg_rtime);
743 err2 |= __put_user(m.msg_ctime, &up32->msg_ctime);
744 err2 |= __put_user(m.msg_cbytes, &up32->msg_cbytes);
745 err2 |= __put_user(m.msg_qnum, &up32->msg_qnum);
746 err2 |= __put_user(m.msg_qbytes, &up32->msg_qbytes);
747 err2 |= __put_user(m.msg_lspid, &up32->msg_lspid);
748 err2 |= __put_user(m.msg_lrpid, &up32->msg_lrpid);
749 if (err2)
750 err = -EFAULT;
751 }
752 break;
753 }
754
755 return err;
756}
757
758static int
759do_sys32_shmat (int first, int second, int third, int version, void __user *uptr)
760{
761 unsigned long raddr;
762 u32 __user *uaddr = (u32 __user *)A((u32)third);
763 int err = -EINVAL;
764
765 if (version == 1)
766 return err;
767 err = do_shmat (first, uptr, second, &raddr);
768 if (err)
769 return err;
770 err = put_user (raddr, uaddr);
771 return err;
772}
773
774struct shm_info32 {
775 int used_ids;
776 u32 shm_tot, shm_rss, shm_swp;
777 u32 swap_attempts, swap_successes;
778};
779
780static int
781do_sys32_shmctl (int first, int second, void __user *uptr)
782{
783 struct shmid64_ds32 __user *up64 = (struct shmid64_ds32 __user *)uptr;
784 struct shmid_ds32 __user *up32 = (struct shmid_ds32 __user *)uptr;
785 struct shm_info32 __user *uip = (struct shm_info32 __user *)uptr;
786 int err = -EFAULT, err2;
787 struct shmid64_ds s64;
788 mm_segment_t old_fs;
789 struct shm_info si;
790 struct shmid_ds s;
791
792 switch (second & ~IPC_64) {
793 case IPC_INFO:
794 second = IPC_INFO; /* So that we don't have to translate it */
795 case IPC_RMID:
796 case SHM_LOCK:
797 case SHM_UNLOCK:
798 err = sys_shmctl(first, second, (struct shmid_ds __user *)uptr);
799 break;
800 case IPC_SET:
801 if (second & IPC_64) {
802 err = get_user(s.shm_perm.uid, &up64->shm_perm.uid);
803 err |= get_user(s.shm_perm.gid, &up64->shm_perm.gid);
804 err |= get_user(s.shm_perm.mode, &up64->shm_perm.mode);
805 } else {
806 err = get_user(s.shm_perm.uid, &up32->shm_perm.uid);
807 err |= get_user(s.shm_perm.gid, &up32->shm_perm.gid);
808 err |= get_user(s.shm_perm.mode, &up32->shm_perm.mode);
809 }
810 if (err)
811 break;
812 old_fs = get_fs();
813 set_fs(KERNEL_DS);
814 err = sys_shmctl(first, second & ~IPC_64, (struct shmid_ds __user *)&s);
815 set_fs(old_fs);
816 break;
817
818 case IPC_STAT:
819 case SHM_STAT:
820 old_fs = get_fs();
821 set_fs(KERNEL_DS);
822 err = sys_shmctl(first, second | IPC_64, (void __user *) &s64);
823 set_fs(old_fs);
824 if (err < 0)
825 break;
826 if (second & IPC_64) {
827 if (!access_ok(VERIFY_WRITE, up64, sizeof(*up64))) {
828 err = -EFAULT;
829 break;
830 }
831 err2 = __put_user(s64.shm_perm.key, &up64->shm_perm.key);
832 err2 |= __put_user(s64.shm_perm.uid, &up64->shm_perm.uid);
833 err2 |= __put_user(s64.shm_perm.gid, &up64->shm_perm.gid);
834 err2 |= __put_user(s64.shm_perm.cuid, &up64->shm_perm.cuid);
835 err2 |= __put_user(s64.shm_perm.cgid, &up64->shm_perm.cgid);
836 err2 |= __put_user(s64.shm_perm.mode, &up64->shm_perm.mode);
837 err2 |= __put_user(s64.shm_perm.seq, &up64->shm_perm.seq);
838 err2 |= __put_user(s64.shm_atime, &up64->shm_atime);
839 err2 |= __put_user(s64.shm_dtime, &up64->shm_dtime);
840 err2 |= __put_user(s64.shm_ctime, &up64->shm_ctime);
841 err2 |= __put_user(s64.shm_segsz, &up64->shm_segsz);
842 err2 |= __put_user(s64.shm_nattch, &up64->shm_nattch);
843 err2 |= __put_user(s64.shm_cpid, &up64->shm_cpid);
844 err2 |= __put_user(s64.shm_lpid, &up64->shm_lpid);
845 } else {
846 if (!access_ok(VERIFY_WRITE, up32, sizeof(*up32))) {
847 err = -EFAULT;
848 break;
849 }
850 err2 = __put_user(s64.shm_perm.key, &up32->shm_perm.key);
851 err2 |= __put_user(s64.shm_perm.uid, &up32->shm_perm.uid);
852 err2 |= __put_user(s64.shm_perm.gid, &up32->shm_perm.gid);
853 err2 |= __put_user(s64.shm_perm.cuid, &up32->shm_perm.cuid);
854 err2 |= __put_user(s64.shm_perm.cgid, &up32->shm_perm.cgid);
855 err2 |= __put_user(s64.shm_perm.mode, &up32->shm_perm.mode);
856 err2 |= __put_user(s64.shm_perm.seq, &up32->shm_perm.seq);
857 err2 |= __put_user(s64.shm_atime, &up32->shm_atime);
858 err2 |= __put_user(s64.shm_dtime, &up32->shm_dtime);
859 err2 |= __put_user(s64.shm_ctime, &up32->shm_ctime);
860 err2 |= __put_user(s64.shm_segsz, &up32->shm_segsz);
861 err2 |= __put_user(s64.shm_nattch, &up32->shm_nattch);
862 err2 |= __put_user(s64.shm_cpid, &up32->shm_cpid);
863 err2 |= __put_user(s64.shm_lpid, &up32->shm_lpid);
864 }
865 if (err2)
866 err = -EFAULT;
867 break;
868
869 case SHM_INFO:
870 old_fs = get_fs();
871 set_fs(KERNEL_DS);
872 err = sys_shmctl(first, second, (void __user *)&si);
873 set_fs(old_fs);
874 if (err < 0)
875 break;
876 err2 = put_user(si.used_ids, &uip->used_ids);
877 err2 |= __put_user(si.shm_tot, &uip->shm_tot);
878 err2 |= __put_user(si.shm_rss, &uip->shm_rss);
879 err2 |= __put_user(si.shm_swp, &uip->shm_swp);
880 err2 |= __put_user(si.swap_attempts, &uip->swap_attempts);
881 err2 |= __put_user (si.swap_successes, &uip->swap_successes);
882 if (err2)
883 err = -EFAULT;
884 break;
885
886 default:
887 err = -EINVAL;
888 break;
889 }
890
891 return err;
892}
893
894static int sys32_semtimedop(int semid, struct sembuf __user *tsems, int nsems,
895 const struct compat_timespec __user *timeout32)
896{
897 struct compat_timespec t32;
898 struct timespec __user *t64 = compat_alloc_user_space(sizeof(*t64));
899
900 if (copy_from_user(&t32, timeout32, sizeof(t32)))
901 return -EFAULT;
902
903 if (put_user(t32.tv_sec, &t64->tv_sec) ||
904 put_user(t32.tv_nsec, &t64->tv_nsec))
905 return -EFAULT;
906
907 return sys_semtimedop(semid, tsems, nsems, t64);
908}
909
910asmlinkage long 385asmlinkage long
911sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth) 386sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth)
912{ 387{
@@ -918,48 +393,43 @@ sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth)
918 switch (call) { 393 switch (call) {
919 case SEMOP: 394 case SEMOP:
920 /* struct sembuf is the same on 32 and 64bit :)) */ 395 /* struct sembuf is the same on 32 and 64bit :)) */
921 err = sys_semtimedop (first, (struct sembuf __user *)AA(ptr), second, 396 err = sys_semtimedop(first, compat_ptr(ptr), second, NULL);
922 NULL);
923 break; 397 break;
924 case SEMTIMEDOP: 398 case SEMTIMEDOP:
925 err = sys32_semtimedop (first, (struct sembuf __user *)AA(ptr), second, 399 err = compat_sys_semtimedop(first, compat_ptr(ptr), second,
926 (const struct compat_timespec __user *)AA(fifth)); 400 compat_ptr(fifth));
927 break; 401 break;
928 case SEMGET: 402 case SEMGET:
929 err = sys_semget (first, second, third); 403 err = sys_semget(first, second, third);
930 break; 404 break;
931 case SEMCTL: 405 case SEMCTL:
932 err = do_sys32_semctl (first, second, third, 406 err = compat_sys_semctl(first, second, third, compat_ptr(ptr));
933 (void __user *)AA(ptr));
934 break; 407 break;
935
936 case MSGSND: 408 case MSGSND:
937 err = do_sys32_msgsnd (first, second, third, 409 err = compat_sys_msgsnd(first, second, third, compat_ptr(ptr));
938 (void __user *)AA(ptr));
939 break; 410 break;
940 case MSGRCV: 411 case MSGRCV:
941 err = do_sys32_msgrcv (first, second, fifth, third, 412 err = compat_sys_msgrcv(first, second, fifth, third,
942 version, (void __user *)AA(ptr)); 413 version, compat_ptr(ptr));
943 break; 414 break;
944 case MSGGET: 415 case MSGGET:
945 err = sys_msgget ((key_t) first, second); 416 err = sys_msgget((key_t) first, second);
946 break; 417 break;
947 case MSGCTL: 418 case MSGCTL:
948 err = do_sys32_msgctl (first, second, (void __user *)AA(ptr)); 419 err = compat_sys_msgctl(first, second, compat_ptr(ptr));
949 break; 420 break;
950
951 case SHMAT: 421 case SHMAT:
952 err = do_sys32_shmat (first, second, third, 422 err = compat_sys_shmat(first, second, third, version,
953 version, (void __user *)AA(ptr)); 423 compat_ptr(ptr));
954 break; 424 break;
955 case SHMDT: 425 case SHMDT:
956 err = sys_shmdt ((char __user *)A(ptr)); 426 err = sys_shmdt(compat_ptr(ptr));
957 break; 427 break;
958 case SHMGET: 428 case SHMGET:
959 err = sys_shmget (first, (unsigned)second, third); 429 err = sys_shmget(first, (unsigned)second, third);
960 break; 430 break;
961 case SHMCTL: 431 case SHMCTL:
962 err = do_sys32_shmctl (first, second, (void __user *)AA(ptr)); 432 err = compat_sys_shmctl(first, second, compat_ptr(ptr));
963 break; 433 break;
964 default: 434 default:
965 err = -EINVAL; 435 err = -EINVAL;
@@ -969,18 +439,16 @@ sys32_ipc (u32 call, int first, int second, int third, u32 ptr, u32 fifth)
969 return err; 439 return err;
970} 440}
971 441
972asmlinkage long sys32_shmat(int shmid, char __user *shmaddr, 442#ifdef CONFIG_MIPS32_N32
973 int shmflg, int32_t __user *addr) 443asmlinkage long sysn32_semctl(int semid, int semnum, int cmd, union semun arg)
974{ 444{
975 unsigned long raddr; 445 /* compat_sys_semctl expects a pointer to union semun */
976 int err; 446 u32 __user *uptr = compat_alloc_user_space(sizeof(u32));
977 447 if (put_user(ptr_to_compat(arg.__pad), uptr))
978 err = do_shmat(shmid, shmaddr, shmflg, &raddr); 448 return -EFAULT;
979 if (err) 449 return compat_sys_semctl(semid, semnum, cmd, uptr);
980 return err;
981
982 return put_user(raddr, addr);
983} 450}
451#endif
984 452
985struct sysctl_args32 453struct sysctl_args32
986{ 454{
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 5b18f265d75b..34567d81f940 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -149,8 +149,8 @@ EXPORT(sysn32_call_table)
149 PTR sys_mincore 149 PTR sys_mincore
150 PTR sys_madvise 150 PTR sys_madvise
151 PTR sys_shmget 151 PTR sys_shmget
152 PTR sys32_shmat 152 PTR sys_shmat
153 PTR sys_shmctl /* 6030 */ 153 PTR compat_sys_shmctl /* 6030 */
154 PTR sys_dup 154 PTR sys_dup
155 PTR sys_dup2 155 PTR sys_dup2
156 PTR sys_pause 156 PTR sys_pause
@@ -184,12 +184,12 @@ EXPORT(sysn32_call_table)
184 PTR sys32_newuname 184 PTR sys32_newuname
185 PTR sys_semget 185 PTR sys_semget
186 PTR sys_semop 186 PTR sys_semop
187 PTR sys_semctl 187 PTR sysn32_semctl
188 PTR sys_shmdt /* 6065 */ 188 PTR sys_shmdt /* 6065 */
189 PTR sys_msgget 189 PTR sys_msgget
190 PTR sys_msgsnd 190 PTR compat_sys_msgsnd
191 PTR sys_msgrcv 191 PTR compat_sys_msgrcv
192 PTR sys_msgctl 192 PTR compat_sys_msgctl
193 PTR compat_sys_fcntl /* 6070 */ 193 PTR compat_sys_fcntl /* 6070 */
194 PTR sys_flock 194 PTR sys_flock
195 PTR sys_fsync 195 PTR sys_fsync
@@ -335,7 +335,7 @@ EXPORT(sysn32_call_table)
335 PTR compat_sys_fcntl64 335 PTR compat_sys_fcntl64
336 PTR sys_set_tid_address 336 PTR sys_set_tid_address
337 PTR sys_restart_syscall 337 PTR sys_restart_syscall
338 PTR sys_semtimedop /* 6215 */ 338 PTR compat_sys_semtimedop /* 6215 */
339 PTR sys_fadvise64_64 339 PTR sys_fadvise64_64
340 PTR compat_sys_statfs64 340 PTR compat_sys_statfs64
341 PTR compat_sys_fstatfs64 341 PTR compat_sys_fstatfs64
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 49db516789e0..f2a8701e414d 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -172,7 +172,7 @@ int smp_call_function (void (*func) (void *info), void *info, int retry,
172 172
173 spin_lock(&smp_call_lock); 173 spin_lock(&smp_call_lock);
174 call_data = &data; 174 call_data = &data;
175 mb(); 175 smp_mb();
176 176
177 /* Send a message to all other CPUs and wait for them to respond */ 177 /* Send a message to all other CPUs and wait for them to respond */
178 for_each_online_cpu(i) 178 for_each_online_cpu(i)
@@ -204,7 +204,7 @@ void smp_call_function_interrupt(void)
204 * Notify initiating CPU that I've grabbed the data and am 204 * Notify initiating CPU that I've grabbed the data and am
205 * about to execute the function. 205 * about to execute the function.
206 */ 206 */
207 mb(); 207 smp_mb();
208 atomic_inc(&call_data->started); 208 atomic_inc(&call_data->started);
209 209
210 /* 210 /*
@@ -215,7 +215,7 @@ void smp_call_function_interrupt(void)
215 irq_exit(); 215 irq_exit();
216 216
217 if (wait) { 217 if (wait) {
218 mb(); 218 smp_mb();
219 atomic_inc(&call_data->finished); 219 atomic_inc(&call_data->finished);
220 } 220 }
221} 221}
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index 4a84a7beac53..2affa5ff171c 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -44,19 +44,12 @@ void enable_lasat_irq(unsigned int irq_nr)
44 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift; 44 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift;
45} 45}
46 46
47static void end_lasat_irq(unsigned int irq)
48{
49 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
50 enable_lasat_irq(irq);
51}
52
53static struct irq_chip lasat_irq_type = { 47static struct irq_chip lasat_irq_type = {
54 .typename = "Lasat", 48 .typename = "Lasat",
55 .ack = disable_lasat_irq, 49 .ack = disable_lasat_irq,
56 .mask = disable_lasat_irq, 50 .mask = disable_lasat_irq,
57 .mask_ack = disable_lasat_irq, 51 .mask_ack = disable_lasat_irq,
58 .unmask = enable_lasat_irq, 52 .unmask = enable_lasat_irq,
59 .end = end_lasat_irq,
60}; 53};
61 54
62static inline int ls1bit32(unsigned int x) 55static inline int ls1bit32(unsigned int x)
diff --git a/arch/mips/lib-32/Makefile b/arch/mips/lib-32/Makefile
index ad285786e74b..dcd4d2ed2ac4 100644
--- a/arch/mips/lib-32/Makefile
+++ b/arch/mips/lib-32/Makefile
@@ -2,7 +2,7 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o memset.o watch.o 5lib-y += memset.o watch.o
6 6
7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o 7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o 8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
diff --git a/arch/mips/lib-32/csum_partial.S b/arch/mips/lib-32/csum_partial.S
deleted file mode 100644
index ea257dbdcc40..000000000000
--- a/arch/mips/lib-32/csum_partial.S
+++ /dev/null
@@ -1,240 +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) 1998 Ralf Baechle
7 */
8#include <asm/asm.h>
9#include <asm/regdef.h>
10
11#define ADDC(sum,reg) \
12 addu sum, reg; \
13 sltu v1, sum, reg; \
14 addu sum, v1
15
16#define CSUM_BIGCHUNK(src, offset, sum, t0, t1, t2, t3) \
17 lw t0, (offset + 0x00)(src); \
18 lw t1, (offset + 0x04)(src); \
19 lw t2, (offset + 0x08)(src); \
20 lw t3, (offset + 0x0c)(src); \
21 ADDC(sum, t0); \
22 ADDC(sum, t1); \
23 ADDC(sum, t2); \
24 ADDC(sum, t3); \
25 lw t0, (offset + 0x10)(src); \
26 lw t1, (offset + 0x14)(src); \
27 lw t2, (offset + 0x18)(src); \
28 lw t3, (offset + 0x1c)(src); \
29 ADDC(sum, t0); \
30 ADDC(sum, t1); \
31 ADDC(sum, t2); \
32 ADDC(sum, t3); \
33
34/*
35 * a0: source address
36 * a1: length of the area to checksum
37 * a2: partial checksum
38 */
39
40#define src a0
41#define dest a1
42#define sum v0
43
44 .text
45 .set noreorder
46
47/* unknown src alignment and < 8 bytes to go */
48small_csumcpy:
49 move a1, t2
50
51 andi t0, a1, 4
52 beqz t0, 1f
53 andi t0, a1, 2
54
55 /* Still a full word to go */
56 ulw t1, (src)
57 addiu src, 4
58 ADDC(sum, t1)
59
601: move t1, zero
61 beqz t0, 1f
62 andi t0, a1, 1
63
64 /* Still a halfword to go */
65 ulhu t1, (src)
66 addiu src, 2
67
681: beqz t0, 1f
69 sll t1, t1, 16
70
71 lbu t2, (src)
72 nop
73
74#ifdef __MIPSEB__
75 sll t2, t2, 8
76#endif
77 or t1, t2
78
791: ADDC(sum, t1)
80
81 /* fold checksum */
82 sll v1, sum, 16
83 addu sum, v1
84 sltu v1, sum, v1
85 srl sum, sum, 16
86 addu sum, v1
87
88 /* odd buffer alignment? */
89 beqz t7, 1f
90 nop
91 sll v1, sum, 8
92 srl sum, sum, 8
93 or sum, v1
94 andi sum, 0xffff
951:
96 .set reorder
97 /* Add the passed partial csum. */
98 ADDC(sum, a2)
99 jr ra
100 .set noreorder
101
102/* ------------------------------------------------------------------------- */
103
104 .align 5
105LEAF(csum_partial)
106 move sum, zero
107 move t7, zero
108
109 sltiu t8, a1, 0x8
110 bnez t8, small_csumcpy /* < 8 bytes to copy */
111 move t2, a1
112
113 beqz a1, out
114 andi t7, src, 0x1 /* odd buffer? */
115
116hword_align:
117 beqz t7, word_align
118 andi t8, src, 0x2
119
120 lbu t0, (src)
121 subu a1, a1, 0x1
122#ifdef __MIPSEL__
123 sll t0, t0, 8
124#endif
125 ADDC(sum, t0)
126 addu src, src, 0x1
127 andi t8, src, 0x2
128
129word_align:
130 beqz t8, dword_align
131 sltiu t8, a1, 56
132
133 lhu t0, (src)
134 subu a1, a1, 0x2
135 ADDC(sum, t0)
136 sltiu t8, a1, 56
137 addu src, src, 0x2
138
139dword_align:
140 bnez t8, do_end_words
141 move t8, a1
142
143 andi t8, src, 0x4
144 beqz t8, qword_align
145 andi t8, src, 0x8
146
147 lw t0, 0x00(src)
148 subu a1, a1, 0x4
149 ADDC(sum, t0)
150 addu src, src, 0x4
151 andi t8, src, 0x8
152
153qword_align:
154 beqz t8, oword_align
155 andi t8, src, 0x10
156
157 lw t0, 0x00(src)
158 lw t1, 0x04(src)
159 subu a1, a1, 0x8
160 ADDC(sum, t0)
161 ADDC(sum, t1)
162 addu src, src, 0x8
163 andi t8, src, 0x10
164
165oword_align:
166 beqz t8, begin_movement
167 srl t8, a1, 0x7
168
169 lw t3, 0x08(src)
170 lw t4, 0x0c(src)
171 lw t0, 0x00(src)
172 lw t1, 0x04(src)
173 ADDC(sum, t3)
174 ADDC(sum, t4)
175 ADDC(sum, t0)
176 ADDC(sum, t1)
177 subu a1, a1, 0x10
178 addu src, src, 0x10
179 srl t8, a1, 0x7
180
181begin_movement:
182 beqz t8, 1f
183 andi t2, a1, 0x40
184
185move_128bytes:
186 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
187 CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
188 CSUM_BIGCHUNK(src, 0x40, sum, t0, t1, t3, t4)
189 CSUM_BIGCHUNK(src, 0x60, sum, t0, t1, t3, t4)
190 subu t8, t8, 0x01
191 bnez t8, move_128bytes
192 addu src, src, 0x80
193
1941:
195 beqz t2, 1f
196 andi t2, a1, 0x20
197
198move_64bytes:
199 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
200 CSUM_BIGCHUNK(src, 0x20, sum, t0, t1, t3, t4)
201 addu src, src, 0x40
202
2031:
204 beqz t2, do_end_words
205 andi t8, a1, 0x1c
206
207move_32bytes:
208 CSUM_BIGCHUNK(src, 0x00, sum, t0, t1, t3, t4)
209 andi t8, a1, 0x1c
210 addu src, src, 0x20
211
212do_end_words:
213 beqz t8, maybe_end_cruft
214 srl t8, t8, 0x2
215
216end_words:
217 lw t0, (src)
218 subu t8, t8, 0x1
219 ADDC(sum, t0)
220 bnez t8, end_words
221 addu src, src, 0x4
222
223maybe_end_cruft:
224 andi t2, a1, 0x3
225
226small_memcpy:
227 j small_csumcpy; move a1, t2
228 beqz t2, out
229 move a1, t2
230
231end_bytes:
232 lb t0, (src)
233 subu a1, a1, 0x1
234 bnez a2, end_bytes
235 addu src, src, 0x1
236
237out:
238 jr ra
239 move v0, sum
240 END(csum_partial)
diff --git a/arch/mips/lib-64/Makefile b/arch/mips/lib-64/Makefile
index ad285786e74b..dcd4d2ed2ac4 100644
--- a/arch/mips/lib-64/Makefile
+++ b/arch/mips/lib-64/Makefile
@@ -2,7 +2,7 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o memset.o watch.o 5lib-y += memset.o watch.o
6 6
7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o 7obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o
8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o 8obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o
diff --git a/arch/mips/lib-64/csum_partial.S b/arch/mips/lib-64/csum_partial.S
deleted file mode 100644
index 25aba660cc9c..000000000000
--- a/arch/mips/lib-64/csum_partial.S
+++ /dev/null
@@ -1,242 +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 * Quick'n'dirty IP checksum ...
7 *
8 * Copyright (C) 1998, 1999 Ralf Baechle
9 * Copyright (C) 1999 Silicon Graphics, Inc.
10 */
11#include <asm/asm.h>
12#include <asm/regdef.h>
13
14#define ADDC(sum,reg) \
15 addu sum, reg; \
16 sltu v1, sum, reg; \
17 addu sum, v1
18
19#define CSUM_BIGCHUNK(src, offset, sum, t0, t1, t2, t3) \
20 lw t0, (offset + 0x00)(src); \
21 lw t1, (offset + 0x04)(src); \
22 lw t2, (offset + 0x08)(src); \
23 lw t3, (offset + 0x0c)(src); \
24 ADDC(sum, t0); \
25 ADDC(sum, t1); \
26 ADDC(sum, t2); \
27 ADDC(sum, t3); \
28 lw t0, (offset + 0x10)(src); \
29 lw t1, (offset + 0x14)(src); \
30 lw t2, (offset + 0x18)(src); \
31 lw t3, (offset + 0x1c)(src); \
32 ADDC(sum, t0); \
33 ADDC(sum, t1); \
34 ADDC(sum, t2); \
35 ADDC(sum, t3); \
36
37/*
38 * a0: source address
39 * a1: length of the area to checksum
40 * a2: partial checksum
41 */
42
43#define src a0
44#define sum v0
45
46 .text
47 .set noreorder
48
49/* unknown src alignment and < 8 bytes to go */
50small_csumcpy:
51 move a1, ta2
52
53 andi ta0, a1, 4
54 beqz ta0, 1f
55 andi ta0, a1, 2
56
57 /* Still a full word to go */
58 ulw ta1, (src)
59 daddiu src, 4
60 ADDC(sum, ta1)
61
621: move ta1, zero
63 beqz ta0, 1f
64 andi ta0, a1, 1
65
66 /* Still a halfword to go */
67 ulhu ta1, (src)
68 daddiu src, 2
69
701: beqz ta0, 1f
71 sll ta1, ta1, 16
72
73 lbu ta2, (src)
74 nop
75
76#ifdef __MIPSEB__
77 sll ta2, ta2, 8
78#endif
79 or ta1, ta2
80
811: ADDC(sum, ta1)
82
83 /* fold checksum */
84 sll v1, sum, 16
85 addu sum, v1
86 sltu v1, sum, v1
87 srl sum, sum, 16
88 addu sum, v1
89
90 /* odd buffer alignment? */
91 beqz t3, 1f
92 nop
93 sll v1, sum, 8
94 srl sum, sum, 8
95 or sum, v1
96 andi sum, 0xffff
971:
98 .set reorder
99 /* Add the passed partial csum. */
100 ADDC(sum, a2)
101 jr ra
102 .set noreorder
103
104/* ------------------------------------------------------------------------- */
105
106 .align 5
107LEAF(csum_partial)
108 move sum, zero
109 move t3, zero
110
111 sltiu t8, a1, 0x8
112 bnez t8, small_csumcpy /* < 8 bytes to copy */
113 move ta2, a1
114
115 beqz a1, out
116 andi t3, src, 0x1 /* odd buffer? */
117
118hword_align:
119 beqz t3, word_align
120 andi t8, src, 0x2
121
122 lbu ta0, (src)
123 dsubu a1, a1, 0x1
124#ifdef __MIPSEL__
125 sll ta0, ta0, 8
126#endif
127 ADDC(sum, ta0)
128 daddu src, src, 0x1
129 andi t8, src, 0x2
130
131word_align:
132 beqz t8, dword_align
133 sltiu t8, a1, 56
134
135 lhu ta0, (src)
136 dsubu a1, a1, 0x2
137 ADDC(sum, ta0)
138 sltiu t8, a1, 56
139 daddu src, src, 0x2
140
141dword_align:
142 bnez t8, do_end_words
143 move t8, a1
144
145 andi t8, src, 0x4
146 beqz t8, qword_align
147 andi t8, src, 0x8
148
149 lw ta0, 0x00(src)
150 dsubu a1, a1, 0x4
151 ADDC(sum, ta0)
152 daddu src, src, 0x4
153 andi t8, src, 0x8
154
155qword_align:
156 beqz t8, oword_align
157 andi t8, src, 0x10
158
159 lw ta0, 0x00(src)
160 lw ta1, 0x04(src)
161 dsubu a1, a1, 0x8
162 ADDC(sum, ta0)
163 ADDC(sum, ta1)
164 daddu src, src, 0x8
165 andi t8, src, 0x10
166
167oword_align:
168 beqz t8, begin_movement
169 dsrl t8, a1, 0x7
170
171 lw ta3, 0x08(src)
172 lw t0, 0x0c(src)
173 lw ta0, 0x00(src)
174 lw ta1, 0x04(src)
175 ADDC(sum, ta3)
176 ADDC(sum, t0)
177 ADDC(sum, ta0)
178 ADDC(sum, ta1)
179 dsubu a1, a1, 0x10
180 daddu src, src, 0x10
181 dsrl t8, a1, 0x7
182
183begin_movement:
184 beqz t8, 1f
185 andi ta2, a1, 0x40
186
187move_128bytes:
188 CSUM_BIGCHUNK(src, 0x00, sum, ta0, ta1, ta3, t0)
189 CSUM_BIGCHUNK(src, 0x20, sum, ta0, ta1, ta3, t0)
190 CSUM_BIGCHUNK(src, 0x40, sum, ta0, ta1, ta3, t0)
191 CSUM_BIGCHUNK(src, 0x60, sum, ta0, ta1, ta3, t0)
192 dsubu t8, t8, 0x01
193 bnez t8, move_128bytes
194 daddu src, src, 0x80
195
1961:
197 beqz ta2, 1f
198 andi ta2, a1, 0x20
199
200move_64bytes:
201 CSUM_BIGCHUNK(src, 0x00, sum, ta0, ta1, ta3, t0)
202 CSUM_BIGCHUNK(src, 0x20, sum, ta0, ta1, ta3, t0)
203 daddu src, src, 0x40
204
2051:
206 beqz ta2, do_end_words
207 andi t8, a1, 0x1c
208
209move_32bytes:
210 CSUM_BIGCHUNK(src, 0x00, sum, ta0, ta1, ta3, t0)
211 andi t8, a1, 0x1c
212 daddu src, src, 0x20
213
214do_end_words:
215 beqz t8, maybe_end_cruft
216 dsrl t8, t8, 0x2
217
218end_words:
219 lw ta0, (src)
220 dsubu t8, t8, 0x1
221 ADDC(sum, ta0)
222 bnez t8, end_words
223 daddu src, src, 0x4
224
225maybe_end_cruft:
226 andi ta2, a1, 0x3
227
228small_memcpy:
229 j small_csumcpy; move a1, ta2 /* XXX ??? */
230 beqz t2, out
231 move a1, ta2
232
233end_bytes:
234 lb ta0, (src)
235 dsubu a1, a1, 0x1
236 bnez a2, end_bytes
237 daddu src, src, 0x1
238
239out:
240 jr ra
241 move v0, sum
242 END(csum_partial)
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index b225543f5302..888b61ea12fe 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -2,8 +2,8 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial_copy.o memcpy.o promlib.o strlen_user.o strncpy_user.o \ 5lib-y += csum_partial.o csum_partial_copy.o memcpy.o promlib.o \
6 strnlen_user.o uncached.o 6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o
7 7
8obj-y += iomap.o 8obj-y += iomap.o
9 9
diff --git a/arch/mips/lib/csum_partial.S b/arch/mips/lib/csum_partial.S
new file mode 100644
index 000000000000..15611d9df7ac
--- /dev/null
+++ b/arch/mips/lib/csum_partial.S
@@ -0,0 +1,258 @@
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 * Quick'n'dirty IP checksum ...
7 *
8 * Copyright (C) 1998, 1999 Ralf Baechle
9 * Copyright (C) 1999 Silicon Graphics, Inc.
10 */
11#include <asm/asm.h>
12#include <asm/regdef.h>
13
14#ifdef CONFIG_64BIT
15#define T0 ta0
16#define T1 ta1
17#define T2 ta2
18#define T3 ta3
19#define T4 t0
20#define T7 t3
21#else
22#define T0 t0
23#define T1 t1
24#define T2 t2
25#define T3 t3
26#define T4 t4
27#define T7 t7
28#endif
29
30#define ADDC(sum,reg) \
31 addu sum, reg; \
32 sltu v1, sum, reg; \
33 addu sum, v1
34
35#define CSUM_BIGCHUNK(src, offset, sum, _t0, _t1, _t2, _t3) \
36 lw _t0, (offset + 0x00)(src); \
37 lw _t1, (offset + 0x04)(src); \
38 lw _t2, (offset + 0x08)(src); \
39 lw _t3, (offset + 0x0c)(src); \
40 ADDC(sum, _t0); \
41 ADDC(sum, _t1); \
42 ADDC(sum, _t2); \
43 ADDC(sum, _t3); \
44 lw _t0, (offset + 0x10)(src); \
45 lw _t1, (offset + 0x14)(src); \
46 lw _t2, (offset + 0x18)(src); \
47 lw _t3, (offset + 0x1c)(src); \
48 ADDC(sum, _t0); \
49 ADDC(sum, _t1); \
50 ADDC(sum, _t2); \
51 ADDC(sum, _t3); \
52
53/*
54 * a0: source address
55 * a1: length of the area to checksum
56 * a2: partial checksum
57 */
58
59#define src a0
60#define sum v0
61
62 .text
63 .set noreorder
64
65/* unknown src alignment and < 8 bytes to go */
66small_csumcpy:
67 move a1, T2
68
69 andi T0, a1, 4
70 beqz T0, 1f
71 andi T0, a1, 2
72
73 /* Still a full word to go */
74 ulw T1, (src)
75 PTR_ADDIU src, 4
76 ADDC(sum, T1)
77
781: move T1, zero
79 beqz T0, 1f
80 andi T0, a1, 1
81
82 /* Still a halfword to go */
83 ulhu T1, (src)
84 PTR_ADDIU src, 2
85
861: beqz T0, 1f
87 sll T1, T1, 16
88
89 lbu T2, (src)
90 nop
91
92#ifdef __MIPSEB__
93 sll T2, T2, 8
94#endif
95 or T1, T2
96
971: ADDC(sum, T1)
98
99 /* fold checksum */
100 sll v1, sum, 16
101 addu sum, v1
102 sltu v1, sum, v1
103 srl sum, sum, 16
104 addu sum, v1
105
106 /* odd buffer alignment? */
107 beqz T7, 1f
108 nop
109 sll v1, sum, 8
110 srl sum, sum, 8
111 or sum, v1
112 andi sum, 0xffff
1131:
114 .set reorder
115 /* Add the passed partial csum. */
116 ADDC(sum, a2)
117 jr ra
118 .set noreorder
119
120/* ------------------------------------------------------------------------- */
121
122 .align 5
123LEAF(csum_partial)
124 move sum, zero
125 move T7, zero
126
127 sltiu t8, a1, 0x8
128 bnez t8, small_csumcpy /* < 8 bytes to copy */
129 move T2, a1
130
131 beqz a1, out
132 andi T7, src, 0x1 /* odd buffer? */
133
134hword_align:
135 beqz T7, word_align
136 andi t8, src, 0x2
137
138 lbu T0, (src)
139 LONG_SUBU a1, a1, 0x1
140#ifdef __MIPSEL__
141 sll T0, T0, 8
142#endif
143 ADDC(sum, T0)
144 PTR_ADDU src, src, 0x1
145 andi t8, src, 0x2
146
147word_align:
148 beqz t8, dword_align
149 sltiu t8, a1, 56
150
151 lhu T0, (src)
152 LONG_SUBU a1, a1, 0x2
153 ADDC(sum, T0)
154 sltiu t8, a1, 56
155 PTR_ADDU src, src, 0x2
156
157dword_align:
158 bnez t8, do_end_words
159 move t8, a1
160
161 andi t8, src, 0x4
162 beqz t8, qword_align
163 andi t8, src, 0x8
164
165 lw T0, 0x00(src)
166 LONG_SUBU a1, a1, 0x4
167 ADDC(sum, T0)
168 PTR_ADDU src, src, 0x4
169 andi t8, src, 0x8
170
171qword_align:
172 beqz t8, oword_align
173 andi t8, src, 0x10
174
175 lw T0, 0x00(src)
176 lw T1, 0x04(src)
177 LONG_SUBU a1, a1, 0x8
178 ADDC(sum, T0)
179 ADDC(sum, T1)
180 PTR_ADDU src, src, 0x8
181 andi t8, src, 0x10
182
183oword_align:
184 beqz t8, begin_movement
185 LONG_SRL t8, a1, 0x7
186
187 lw T3, 0x08(src)
188 lw T4, 0x0c(src)
189 lw T0, 0x00(src)
190 lw T1, 0x04(src)
191 ADDC(sum, T3)
192 ADDC(sum, T4)
193 ADDC(sum, T0)
194 ADDC(sum, T1)
195 LONG_SUBU a1, a1, 0x10
196 PTR_ADDU src, src, 0x10
197 LONG_SRL t8, a1, 0x7
198
199begin_movement:
200 beqz t8, 1f
201 andi T2, a1, 0x40
202
203move_128bytes:
204 CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
205 CSUM_BIGCHUNK(src, 0x20, sum, T0, T1, T3, T4)
206 CSUM_BIGCHUNK(src, 0x40, sum, T0, T1, T3, T4)
207 CSUM_BIGCHUNK(src, 0x60, sum, T0, T1, T3, T4)
208 LONG_SUBU t8, t8, 0x01
209 bnez t8, move_128bytes
210 PTR_ADDU src, src, 0x80
211
2121:
213 beqz T2, 1f
214 andi T2, a1, 0x20
215
216move_64bytes:
217 CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
218 CSUM_BIGCHUNK(src, 0x20, sum, T0, T1, T3, T4)
219 PTR_ADDU src, src, 0x40
220
2211:
222 beqz T2, do_end_words
223 andi t8, a1, 0x1c
224
225move_32bytes:
226 CSUM_BIGCHUNK(src, 0x00, sum, T0, T1, T3, T4)
227 andi t8, a1, 0x1c
228 PTR_ADDU src, src, 0x20
229
230do_end_words:
231 beqz t8, maybe_end_cruft
232 LONG_SRL t8, t8, 0x2
233
234end_words:
235 lw T0, (src)
236 LONG_SUBU t8, t8, 0x1
237 ADDC(sum, T0)
238 bnez t8, end_words
239 PTR_ADDU src, src, 0x4
240
241maybe_end_cruft:
242 andi T2, a1, 0x3
243
244small_memcpy:
245 j small_csumcpy; move a1, T2 /* XXX ??? */
246 beqz t2, out
247 move a1, T2
248
249end_bytes:
250 lb T0, (src)
251 LONG_SUBU a1, a1, 0x1
252 bnez a2, end_bytes
253 PTR_ADDU src, src, 0x1
254
255out:
256 jr ra
257 move v0, sum
258 END(csum_partial)
diff --git a/arch/mips/momentum/ocelot_c/cpci-irq.c b/arch/mips/momentum/ocelot_c/cpci-irq.c
index e5a4a0a8a7f0..bb11fef08472 100644
--- a/arch/mips/momentum/ocelot_c/cpci-irq.c
+++ b/arch/mips/momentum/ocelot_c/cpci-irq.c
@@ -66,15 +66,6 @@ static inline void unmask_cpci_irq(unsigned int irq)
66} 66}
67 67
68/* 68/*
69 * End IRQ processing
70 */
71static void end_cpci_irq(unsigned int irq)
72{
73 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
74 unmask_cpci_irq(irq);
75}
76
77/*
78 * Interrupt handler for interrupts coming from the FPGA chip. 69 * Interrupt handler for interrupts coming from the FPGA chip.
79 * It could be built in ethernet ports etc... 70 * It could be built in ethernet ports etc...
80 */ 71 */
@@ -98,7 +89,6 @@ struct irq_chip cpci_irq_type = {
98 .mask = mask_cpci_irq, 89 .mask = mask_cpci_irq,
99 .mask_ack = mask_cpci_irq, 90 .mask_ack = mask_cpci_irq,
100 .unmask = unmask_cpci_irq, 91 .unmask = unmask_cpci_irq,
101 .end = end_cpci_irq,
102}; 92};
103 93
104void cpci_irq_init(void) 94void cpci_irq_init(void)
diff --git a/arch/mips/momentum/ocelot_c/uart-irq.c b/arch/mips/momentum/ocelot_c/uart-irq.c
index 0029f0008dea..a7a80c0da569 100644
--- a/arch/mips/momentum/ocelot_c/uart-irq.c
+++ b/arch/mips/momentum/ocelot_c/uart-irq.c
@@ -60,15 +60,6 @@ static inline void unmask_uart_irq(unsigned int irq)
60} 60}
61 61
62/* 62/*
63 * End IRQ processing
64 */
65static void end_uart_irq(unsigned int irq)
66{
67 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
68 unmask_uart_irq(irq);
69}
70
71/*
72 * Interrupt handler for interrupts coming from the FPGA chip. 63 * Interrupt handler for interrupts coming from the FPGA chip.
73 */ 64 */
74void ll_uart_irq(void) 65void ll_uart_irq(void)
@@ -91,7 +82,6 @@ struct irq_chip uart_irq_type = {
91 .mask = mask_uart_irq, 82 .mask = mask_uart_irq,
92 .mask_ack = mask_uart_irq, 83 .mask_ack = mask_uart_irq,
93 .unmask = unmask_uart_irq, 84 .unmask = unmask_uart_irq,
94 .end = end_uart_irq,
95}; 85};
96 86
97void uart_irq_init(void) 87void uart_irq_init(void)
diff --git a/arch/mips/philips/pnx8550/common/int.c b/arch/mips/philips/pnx8550/common/int.c
index 0dc23930edbd..2c36c108c4d6 100644
--- a/arch/mips/philips/pnx8550/common/int.c
+++ b/arch/mips/philips/pnx8550/common/int.c
@@ -158,20 +158,12 @@ int pnx8550_set_gic_priority(int irq, int priority)
158 return prev_priority; 158 return prev_priority;
159} 159}
160 160
161static void end_irq(unsigned int irq)
162{
163 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
164 unmask_irq(irq);
165 }
166}
167
168static struct irq_chip level_irq_type = { 161static struct irq_chip level_irq_type = {
169 .typename = "PNX Level IRQ", 162 .typename = "PNX Level IRQ",
170 .ack = mask_irq, 163 .ack = mask_irq,
171 .mask = mask_irq, 164 .mask = mask_irq,
172 .mask_ack = mask_irq, 165 .mask_ack = mask_irq,
173 .unmask = unmask_irq, 166 .unmask = unmask_irq,
174 .end = end_irq,
175}; 167};
176 168
177static struct irqaction gic_action = { 169static struct irqaction gic_action = {
diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
index c7b138053159..c44f8be0644f 100644
--- a/arch/mips/sgi-ip22/ip22-int.c
+++ b/arch/mips/sgi-ip22/ip22-int.c
@@ -51,19 +51,12 @@ static void disable_local0_irq(unsigned int irq)
51 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0)); 51 sgint->imask0 &= ~(1 << (irq - SGINT_LOCAL0));
52} 52}
53 53
54static void end_local0_irq (unsigned int irq)
55{
56 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
57 enable_local0_irq(irq);
58}
59
60static struct irq_chip ip22_local0_irq_type = { 54static struct irq_chip ip22_local0_irq_type = {
61 .typename = "IP22 local 0", 55 .typename = "IP22 local 0",
62 .ack = disable_local0_irq, 56 .ack = disable_local0_irq,
63 .mask = disable_local0_irq, 57 .mask = disable_local0_irq,
64 .mask_ack = disable_local0_irq, 58 .mask_ack = disable_local0_irq,
65 .unmask = enable_local0_irq, 59 .unmask = enable_local0_irq,
66 .end = end_local0_irq,
67}; 60};
68 61
69static void enable_local1_irq(unsigned int irq) 62static void enable_local1_irq(unsigned int irq)
@@ -79,19 +72,12 @@ void disable_local1_irq(unsigned int irq)
79 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1)); 72 sgint->imask1 &= ~(1 << (irq - SGINT_LOCAL1));
80} 73}
81 74
82static void end_local1_irq (unsigned int irq)
83{
84 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
85 enable_local1_irq(irq);
86}
87
88static struct irq_chip ip22_local1_irq_type = { 75static struct irq_chip ip22_local1_irq_type = {
89 .typename = "IP22 local 1", 76 .typename = "IP22 local 1",
90 .ack = disable_local1_irq, 77 .ack = disable_local1_irq,
91 .mask = disable_local1_irq, 78 .mask = disable_local1_irq,
92 .mask_ack = disable_local1_irq, 79 .mask_ack = disable_local1_irq,
93 .unmask = enable_local1_irq, 80 .unmask = enable_local1_irq,
94 .end = end_local1_irq,
95}; 81};
96 82
97static void enable_local2_irq(unsigned int irq) 83static void enable_local2_irq(unsigned int irq)
@@ -107,19 +93,12 @@ void disable_local2_irq(unsigned int irq)
107 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0)); 93 sgint->imask0 &= ~(1 << (SGI_MAP_0_IRQ - SGINT_LOCAL0));
108} 94}
109 95
110static void end_local2_irq (unsigned int irq)
111{
112 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
113 enable_local2_irq(irq);
114}
115
116static struct irq_chip ip22_local2_irq_type = { 96static struct irq_chip ip22_local2_irq_type = {
117 .typename = "IP22 local 2", 97 .typename = "IP22 local 2",
118 .ack = disable_local2_irq, 98 .ack = disable_local2_irq,
119 .mask = disable_local2_irq, 99 .mask = disable_local2_irq,
120 .mask_ack = disable_local2_irq, 100 .mask_ack = disable_local2_irq,
121 .unmask = enable_local2_irq, 101 .unmask = enable_local2_irq,
122 .end = end_local2_irq,
123}; 102};
124 103
125static void enable_local3_irq(unsigned int irq) 104static void enable_local3_irq(unsigned int irq)
@@ -135,19 +114,12 @@ void disable_local3_irq(unsigned int irq)
135 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1)); 114 sgint->imask1 &= ~(1 << (SGI_MAP_1_IRQ - SGINT_LOCAL1));
136} 115}
137 116
138static void end_local3_irq (unsigned int irq)
139{
140 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
141 enable_local3_irq(irq);
142}
143
144static struct irq_chip ip22_local3_irq_type = { 117static struct irq_chip ip22_local3_irq_type = {
145 .typename = "IP22 local 3", 118 .typename = "IP22 local 3",
146 .ack = disable_local3_irq, 119 .ack = disable_local3_irq,
147 .mask = disable_local3_irq, 120 .mask = disable_local3_irq,
148 .mask_ack = disable_local3_irq, 121 .mask_ack = disable_local3_irq,
149 .unmask = enable_local3_irq, 122 .unmask = enable_local3_irq,
150 .end = end_local3_irq,
151}; 123};
152 124
153static void indy_local0_irqdispatch(void) 125static void indy_local0_irqdispatch(void)
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 5f8835b4e84a..319f8803ef6f 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -332,13 +332,6 @@ static inline void disable_bridge_irq(unsigned int irq)
332 intr_disconnect_level(cpu, swlevel); 332 intr_disconnect_level(cpu, swlevel);
333} 333}
334 334
335static void end_bridge_irq(unsigned int irq)
336{
337 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)) &&
338 irq_desc[irq].action)
339 enable_bridge_irq(irq);
340}
341
342static struct irq_chip bridge_irq_type = { 335static struct irq_chip bridge_irq_type = {
343 .typename = "bridge", 336 .typename = "bridge",
344 .startup = startup_bridge_irq, 337 .startup = startup_bridge_irq,
@@ -347,7 +340,6 @@ static struct irq_chip bridge_irq_type = {
347 .mask = disable_bridge_irq, 340 .mask = disable_bridge_irq,
348 .mask_ack = disable_bridge_irq, 341 .mask_ack = disable_bridge_irq,
349 .unmask = enable_bridge_irq, 342 .unmask = enable_bridge_irq,
350 .end = end_bridge_irq,
351}; 343};
352 344
353void __devinit register_bridge_irq(unsigned int irq) 345void __devinit register_bridge_irq(unsigned int irq)
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 7d361726bbfb..c20e9899b34b 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -180,10 +180,6 @@ static void disable_rt_irq(unsigned int irq)
180{ 180{
181} 181}
182 182
183static void end_rt_irq(unsigned int irq)
184{
185}
186
187static struct irq_chip rt_irq_type = { 183static struct irq_chip rt_irq_type = {
188 .typename = "SN HUB RT timer", 184 .typename = "SN HUB RT timer",
189 .ack = disable_rt_irq, 185 .ack = disable_rt_irq,
@@ -191,7 +187,6 @@ static struct irq_chip rt_irq_type = {
191 .mask_ack = disable_rt_irq, 187 .mask_ack = disable_rt_irq,
192 .unmask = enable_rt_irq, 188 .unmask = enable_rt_irq,
193 .eoi = enable_rt_irq, 189 .eoi = enable_rt_irq,
194 .end = end_rt_irq,
195}; 190};
196 191
197static struct irqaction rt_irqaction = { 192static struct irqaction rt_irqaction = {
diff --git a/arch/mips/sibyte/swarm/setup.c b/arch/mips/sibyte/swarm/setup.c
index ac342f5643c9..defa1f1452ad 100644
--- a/arch/mips/sibyte/swarm/setup.c
+++ b/arch/mips/sibyte/swarm/setup.c
@@ -43,7 +43,7 @@
43#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) 43#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
44#include <asm/sibyte/sb1250_regs.h> 44#include <asm/sibyte/sb1250_regs.h>
45#else 45#else
46#error invalid SiByte board configuation 46#error invalid SiByte board configuration
47#endif 47#endif
48#include <asm/sibyte/sb1250_genbus.h> 48#include <asm/sibyte/sb1250_genbus.h>
49#include <asm/sibyte/board.h> 49#include <asm/sibyte/board.h>
@@ -53,7 +53,7 @@ extern void bcm1480_setup(void);
53#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) 53#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
54extern void sb1250_setup(void); 54extern void sb1250_setup(void);
55#else 55#else
56#error invalid SiByte board configuation 56#error invalid SiByte board configuration
57#endif 57#endif
58 58
59extern int xicor_probe(void); 59extern int xicor_probe(void);
@@ -90,7 +90,7 @@ void __init plat_timer_setup(struct irqaction *irq)
90#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) 90#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
91 sb1250_time_init(); 91 sb1250_time_init();
92#else 92#else
93#error invalid SiByte board configuation 93#error invalid SiByte board configuration
94#endif 94#endif
95} 95}
96 96
@@ -111,7 +111,7 @@ void __init plat_mem_setup(void)
111#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) 111#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
112 sb1250_setup(); 112 sb1250_setup();
113#else 113#else
114#error invalid SiByte board configuation 114#error invalid SiByte board configuration
115#endif 115#endif
116 116
117 panic_timeout = 5; /* For debug. */ 117 panic_timeout = 5; /* For debug. */
diff --git a/arch/mips/tx4927/common/tx4927_irq.c b/arch/mips/tx4927/common/tx4927_irq.c
index 21873de49aa8..ed4a19adf361 100644
--- a/arch/mips/tx4927/common/tx4927_irq.c
+++ b/arch/mips/tx4927/common/tx4927_irq.c
@@ -66,12 +66,10 @@
66#define TX4927_IRQ_CP0_INIT ( 1 << 10 ) 66#define TX4927_IRQ_CP0_INIT ( 1 << 10 )
67#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 ) 67#define TX4927_IRQ_CP0_ENABLE ( 1 << 13 )
68#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 ) 68#define TX4927_IRQ_CP0_DISABLE ( 1 << 14 )
69#define TX4927_IRQ_CP0_ENDIRQ ( 1 << 16 )
70 69
71#define TX4927_IRQ_PIC_INIT ( 1 << 20 ) 70#define TX4927_IRQ_PIC_INIT ( 1 << 20 )
72#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 ) 71#define TX4927_IRQ_PIC_ENABLE ( 1 << 23 )
73#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 ) 72#define TX4927_IRQ_PIC_DISABLE ( 1 << 24 )
74#define TX4927_IRQ_PIC_ENDIRQ ( 1 << 26 )
75 73
76#define TX4927_IRQ_ALL 0xffffffff 74#define TX4927_IRQ_ALL 0xffffffff
77#endif 75#endif
@@ -82,12 +80,10 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
82 | TX4927_IRQ_WARN | TX4927_IRQ_EROR 80 | TX4927_IRQ_WARN | TX4927_IRQ_EROR
83// | TX4927_IRQ_CP0_INIT 81// | TX4927_IRQ_CP0_INIT
84// | TX4927_IRQ_CP0_ENABLE 82// | TX4927_IRQ_CP0_ENABLE
85// | TX4927_IRQ_CP0_DISABLE
86// | TX4927_IRQ_CP0_ENDIRQ 83// | TX4927_IRQ_CP0_ENDIRQ
87// | TX4927_IRQ_PIC_INIT 84// | TX4927_IRQ_PIC_INIT
88// | TX4927_IRQ_PIC_ENABLE 85// | TX4927_IRQ_PIC_ENABLE
89// | TX4927_IRQ_PIC_DISABLE 86// | TX4927_IRQ_PIC_DISABLE
90// | TX4927_IRQ_PIC_ENDIRQ
91// | TX4927_IRQ_INIT 87// | TX4927_IRQ_INIT
92// | TX4927_IRQ_NEST1 88// | TX4927_IRQ_NEST1
93// | TX4927_IRQ_NEST2 89// | TX4927_IRQ_NEST2
@@ -114,11 +110,9 @@ static const u32 tx4927_irq_debug_flag = (TX4927_IRQ_NONE
114 110
115static void tx4927_irq_cp0_enable(unsigned int irq); 111static void tx4927_irq_cp0_enable(unsigned int irq);
116static void tx4927_irq_cp0_disable(unsigned int irq); 112static void tx4927_irq_cp0_disable(unsigned int irq);
117static void tx4927_irq_cp0_end(unsigned int irq);
118 113
119static void tx4927_irq_pic_enable(unsigned int irq); 114static void tx4927_irq_pic_enable(unsigned int irq);
120static void tx4927_irq_pic_disable(unsigned int irq); 115static void tx4927_irq_pic_disable(unsigned int irq);
121static void tx4927_irq_pic_end(unsigned int irq);
122 116
123/* 117/*
124 * Kernel structs for all pic's 118 * Kernel structs for all pic's
@@ -131,7 +125,6 @@ static struct irq_chip tx4927_irq_cp0_type = {
131 .mask = tx4927_irq_cp0_disable, 125 .mask = tx4927_irq_cp0_disable,
132 .mask_ack = tx4927_irq_cp0_disable, 126 .mask_ack = tx4927_irq_cp0_disable,
133 .unmask = tx4927_irq_cp0_enable, 127 .unmask = tx4927_irq_cp0_enable,
134 .end = tx4927_irq_cp0_end,
135}; 128};
136 129
137#define TX4927_PIC_NAME "TX4927-PIC" 130#define TX4927_PIC_NAME "TX4927-PIC"
@@ -141,7 +134,6 @@ static struct irq_chip tx4927_irq_pic_type = {
141 .mask = tx4927_irq_pic_disable, 134 .mask = tx4927_irq_pic_disable,
142 .mask_ack = tx4927_irq_pic_disable, 135 .mask_ack = tx4927_irq_pic_disable,
143 .unmask = tx4927_irq_pic_enable, 136 .unmask = tx4927_irq_pic_enable,
144 .end = tx4927_irq_pic_end,
145}; 137};
146 138
147#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL } 139#define TX4927_PIC_ACTION(s) { no_action, 0, CPU_MASK_NONE, s, NULL, NULL }
@@ -214,15 +206,6 @@ static void tx4927_irq_cp0_disable(unsigned int irq)
214 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0); 206 tx4927_irq_cp0_modify(CCP0_STATUS, tx4927_irq_cp0_mask(irq), 0);
215} 207}
216 208
217static void tx4927_irq_cp0_end(unsigned int irq)
218{
219 TX4927_IRQ_DPRINTK(TX4927_IRQ_CP0_ENDIRQ, "irq=%d \n", irq);
220
221 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
222 tx4927_irq_cp0_enable(irq);
223 }
224}
225
226/* 209/*
227 * Functions for pic 210 * Functions for pic
228 */ 211 */
@@ -376,15 +359,6 @@ static void tx4927_irq_pic_disable(unsigned int irq)
376 tx4927_irq_pic_mask(irq), 0); 359 tx4927_irq_pic_mask(irq), 0);
377} 360}
378 361
379static void tx4927_irq_pic_end(unsigned int irq)
380{
381 TX4927_IRQ_DPRINTK(TX4927_IRQ_PIC_ENDIRQ, "irq=%d\n", irq);
382
383 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
384 tx4927_irq_pic_enable(irq);
385 }
386}
387
388/* 362/*
389 * Main init functions 363 * Main init functions
390 */ 364 */
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
index 34cdb2a240e9..5a5ea6c0b9f6 100644
--- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
+++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c
@@ -153,7 +153,6 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB
153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 ) 153#define TOSHIBA_RBTX4927_IRQ_IOC_INIT ( 1 << 10 )
154#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 ) 154#define TOSHIBA_RBTX4927_IRQ_IOC_ENABLE ( 1 << 13 )
155#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 ) 155#define TOSHIBA_RBTX4927_IRQ_IOC_DISABLE ( 1 << 14 )
156#define TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ ( 1 << 16 )
157 156
158#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 ) 157#define TOSHIBA_RBTX4927_IRQ_ISA_INIT ( 1 << 20 )
159#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 ) 158#define TOSHIBA_RBTX4927_IRQ_ISA_ENABLE ( 1 << 23 )
@@ -172,7 +171,6 @@ static const u32 toshiba_rbtx4927_irq_debug_flag =
172// | TOSHIBA_RBTX4927_IRQ_IOC_INIT 171// | TOSHIBA_RBTX4927_IRQ_IOC_INIT
173// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE 172// | TOSHIBA_RBTX4927_IRQ_IOC_ENABLE
174// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE 173// | TOSHIBA_RBTX4927_IRQ_IOC_DISABLE
175// | TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ
176// | TOSHIBA_RBTX4927_IRQ_ISA_INIT 174// | TOSHIBA_RBTX4927_IRQ_ISA_INIT
177// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE 175// | TOSHIBA_RBTX4927_IRQ_ISA_ENABLE
178// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE 176// | TOSHIBA_RBTX4927_IRQ_ISA_DISABLE
@@ -223,7 +221,6 @@ extern void mask_and_ack_8259A(unsigned int irq);
223 221
224static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq); 222static void toshiba_rbtx4927_irq_ioc_enable(unsigned int irq);
225static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq); 223static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq);
226static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq);
227 224
228#ifdef CONFIG_TOSHIBA_FPCIB0 225#ifdef CONFIG_TOSHIBA_FPCIB0
229static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq); 226static void toshiba_rbtx4927_irq_isa_enable(unsigned int irq);
@@ -239,7 +236,6 @@ static struct irq_chip toshiba_rbtx4927_irq_ioc_type = {
239 .mask = toshiba_rbtx4927_irq_ioc_disable, 236 .mask = toshiba_rbtx4927_irq_ioc_disable,
240 .mask_ack = toshiba_rbtx4927_irq_ioc_disable, 237 .mask_ack = toshiba_rbtx4927_irq_ioc_disable,
241 .unmask = toshiba_rbtx4927_irq_ioc_enable, 238 .unmask = toshiba_rbtx4927_irq_ioc_enable,
242 .end = toshiba_rbtx4927_irq_ioc_end,
243}; 239};
244#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000 240#define TOSHIBA_RBTX4927_IOC_INTR_ENAB 0xbc002000
245#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006 241#define TOSHIBA_RBTX4927_IOC_INTR_STAT 0xbc002006
@@ -388,23 +384,6 @@ static void toshiba_rbtx4927_irq_ioc_disable(unsigned int irq)
388 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v); 384 TOSHIBA_RBTX4927_WR08(TOSHIBA_RBTX4927_IOC_INTR_ENAB, v);
389} 385}
390 386
391static void toshiba_rbtx4927_irq_ioc_end(unsigned int irq)
392{
393 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_IOC_ENDIRQ,
394 "irq=%d\n", irq);
395
396 if (irq < TOSHIBA_RBTX4927_IRQ_IOC_BEG
397 || irq > TOSHIBA_RBTX4927_IRQ_IOC_END) {
398 TOSHIBA_RBTX4927_IRQ_DPRINTK(TOSHIBA_RBTX4927_IRQ_EROR,
399 "bad irq=%d\n", irq);
400 panic("\n");
401 }
402
403 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
404 toshiba_rbtx4927_irq_ioc_enable(irq);
405 }
406}
407
408 387
409/**********************************************************************************/ 388/**********************************************************************************/
410/* Functions for isa */ 389/* Functions for isa */
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c
index 42e127683ae9..a347b424d91c 100644
--- a/arch/mips/tx4938/common/irq.c
+++ b/arch/mips/tx4938/common/irq.c
@@ -39,11 +39,9 @@
39 39
40static void tx4938_irq_cp0_enable(unsigned int irq); 40static void tx4938_irq_cp0_enable(unsigned int irq);
41static void tx4938_irq_cp0_disable(unsigned int irq); 41static void tx4938_irq_cp0_disable(unsigned int irq);
42static void tx4938_irq_cp0_end(unsigned int irq);
43 42
44static void tx4938_irq_pic_enable(unsigned int irq); 43static void tx4938_irq_pic_enable(unsigned int irq);
45static void tx4938_irq_pic_disable(unsigned int irq); 44static void tx4938_irq_pic_disable(unsigned int irq);
46static void tx4938_irq_pic_end(unsigned int irq);
47 45
48/**********************************************************************************/ 46/**********************************************************************************/
49/* Kernel structs for all pic's */ 47/* Kernel structs for all pic's */
@@ -56,7 +54,6 @@ static struct irq_chip tx4938_irq_cp0_type = {
56 .mask = tx4938_irq_cp0_disable, 54 .mask = tx4938_irq_cp0_disable,
57 .mask_ack = tx4938_irq_cp0_disable, 55 .mask_ack = tx4938_irq_cp0_disable,
58 .unmask = tx4938_irq_cp0_enable, 56 .unmask = tx4938_irq_cp0_enable,
59 .end = tx4938_irq_cp0_end,
60}; 57};
61 58
62#define TX4938_PIC_NAME "TX4938-PIC" 59#define TX4938_PIC_NAME "TX4938-PIC"
@@ -66,7 +63,6 @@ static struct irq_chip tx4938_irq_pic_type = {
66 .mask = tx4938_irq_pic_disable, 63 .mask = tx4938_irq_pic_disable,
67 .mask_ack = tx4938_irq_pic_disable, 64 .mask_ack = tx4938_irq_pic_disable,
68 .unmask = tx4938_irq_pic_enable, 65 .unmask = tx4938_irq_pic_enable,
69 .end = tx4938_irq_pic_end,
70}; 66};
71 67
72static struct irqaction tx4938_irq_pic_action = { 68static struct irqaction tx4938_irq_pic_action = {
@@ -104,14 +100,6 @@ tx4938_irq_cp0_disable(unsigned int irq)
104 clear_c0_status(tx4938_irq_cp0_mask(irq)); 100 clear_c0_status(tx4938_irq_cp0_mask(irq));
105} 101}
106 102
107static void
108tx4938_irq_cp0_end(unsigned int irq)
109{
110 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
111 tx4938_irq_cp0_enable(irq);
112 }
113}
114
115/**********************************************************************************/ 103/**********************************************************************************/
116/* Functions for pic */ 104/* Functions for pic */
117/**********************************************************************************/ 105/**********************************************************************************/
@@ -269,14 +257,6 @@ tx4938_irq_pic_disable(unsigned int irq)
269 tx4938_irq_pic_mask(irq), 0); 257 tx4938_irq_pic_mask(irq), 0);
270} 258}
271 259
272static void
273tx4938_irq_pic_end(unsigned int irq)
274{
275 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
276 tx4938_irq_pic_enable(irq);
277 }
278}
279
280/**********************************************************************************/ 260/**********************************************************************************/
281/* Main init functions */ 261/* Main init functions */
282/**********************************************************************************/ 262/**********************************************************************************/
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
index 8c87a35f3068..b6f363d08011 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c
@@ -89,7 +89,6 @@ IRQ Device
89 89
90static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq); 90static void toshiba_rbtx4938_irq_ioc_enable(unsigned int irq);
91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq); 91static void toshiba_rbtx4938_irq_ioc_disable(unsigned int irq);
92static void toshiba_rbtx4938_irq_ioc_end(unsigned int irq);
93 92
94#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC" 93#define TOSHIBA_RBTX4938_IOC_NAME "RBTX4938-IOC"
95static struct irq_chip toshiba_rbtx4938_irq_ioc_type = { 94static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
@@ -98,7 +97,6 @@ static struct irq_chip toshiba_rbtx4938_irq_ioc_type = {
98 .mask = toshiba_rbtx4938_irq_ioc_disable, 97 .mask = toshiba_rbtx4938_irq_ioc_disable,
99 .mask_ack = toshiba_rbtx4938_irq_ioc_disable, 98 .mask_ack = toshiba_rbtx4938_irq_ioc_disable,
100 .unmask = toshiba_rbtx4938_irq_ioc_enable, 99 .unmask = toshiba_rbtx4938_irq_ioc_enable,
101 .end = toshiba_rbtx4938_irq_ioc_end,
102}; 100};
103 101
104#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000 102#define TOSHIBA_RBTX4938_IOC_INTR_ENAB 0xb7f02000
@@ -167,14 +165,6 @@ toshiba_rbtx4938_irq_ioc_disable(unsigned int irq)
167 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB); 165 TX4938_RD08(TOSHIBA_RBTX4938_IOC_INTR_ENAB);
168} 166}
169 167
170static void
171toshiba_rbtx4938_irq_ioc_end(unsigned int irq)
172{
173 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
174 toshiba_rbtx4938_irq_ioc_enable(irq);
175 }
176}
177
178extern void __init txx9_spi_irqinit(int irc_irq); 168extern void __init txx9_spi_irqinit(int irc_irq);
179 169
180void __init arch_init_irq(void) 170void __init arch_init_irq(void)
diff --git a/arch/mips/vr41xx/Kconfig b/arch/mips/vr41xx/Kconfig
index 92f41f6f934a..c8dfd8092cab 100644
--- a/arch/mips/vr41xx/Kconfig
+++ b/arch/mips/vr41xx/Kconfig
@@ -6,6 +6,7 @@ config CASIO_E55
6 select ISA 6 select ISA
7 select SYS_SUPPORTS_32BIT_KERNEL 7 select SYS_SUPPORTS_32BIT_KERNEL
8 select SYS_SUPPORTS_LITTLE_ENDIAN 8 select SYS_SUPPORTS_LITTLE_ENDIAN
9 select GENERIC_HARDIRQS_NO__DO_IRQ
9 10
10config IBM_WORKPAD 11config IBM_WORKPAD
11 bool "Support for IBM WorkPad z50" 12 bool "Support for IBM WorkPad z50"
@@ -15,6 +16,7 @@ config IBM_WORKPAD
15 select ISA 16 select ISA
16 select SYS_SUPPORTS_32BIT_KERNEL 17 select SYS_SUPPORTS_32BIT_KERNEL
17 select SYS_SUPPORTS_LITTLE_ENDIAN 18 select SYS_SUPPORTS_LITTLE_ENDIAN
19 select GENERIC_HARDIRQS_NO__DO_IRQ
18 20
19config NEC_CMBVR4133 21config NEC_CMBVR4133
20 bool "Support for NEC CMB-VR4133" 22 bool "Support for NEC CMB-VR4133"
@@ -39,6 +41,7 @@ config TANBAC_TB022X
39 select IRQ_CPU 41 select IRQ_CPU
40 select SYS_SUPPORTS_32BIT_KERNEL 42 select SYS_SUPPORTS_32BIT_KERNEL
41 select SYS_SUPPORTS_LITTLE_ENDIAN 43 select SYS_SUPPORTS_LITTLE_ENDIAN
44 select GENERIC_HARDIRQS_NO__DO_IRQ
42 help 45 help
43 The TANBAC VR4131 multichip module(TB0225) and 46 The TANBAC VR4131 multichip module(TB0225) and
44 the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms 47 the TANBAC VR4131DIMM(TB0229) are MIPS-based platforms
@@ -71,6 +74,7 @@ config VICTOR_MPC30X
71 select IRQ_CPU 74 select IRQ_CPU
72 select SYS_SUPPORTS_32BIT_KERNEL 75 select SYS_SUPPORTS_32BIT_KERNEL
73 select SYS_SUPPORTS_LITTLE_ENDIAN 76 select SYS_SUPPORTS_LITTLE_ENDIAN
77 select GENERIC_HARDIRQS_NO__DO_IRQ
74 78
75config ZAO_CAPCELLA 79config ZAO_CAPCELLA
76 bool "Support for ZAO Networks Capcella" 80 bool "Support for ZAO Networks Capcella"
@@ -80,6 +84,7 @@ config ZAO_CAPCELLA
80 select IRQ_CPU 84 select IRQ_CPU
81 select SYS_SUPPORTS_32BIT_KERNEL 85 select SYS_SUPPORTS_32BIT_KERNEL
82 select SYS_SUPPORTS_LITTLE_ENDIAN 86 select SYS_SUPPORTS_LITTLE_ENDIAN
87 select GENERIC_HARDIRQS_NO__DO_IRQ
83 88
84config PCI_VR41XX 89config PCI_VR41XX
85 bool "Add PCI control unit support of NEC VR4100 series" 90 bool "Add PCI control unit support of NEC VR4100 series"
diff --git a/arch/mips/vr41xx/common/icu.c b/arch/mips/vr41xx/common/icu.c
index 54b92a74c7ac..c075261976c5 100644
--- a/arch/mips/vr41xx/common/icu.c
+++ b/arch/mips/vr41xx/common/icu.c
@@ -427,19 +427,12 @@ static void enable_sysint1_irq(unsigned int irq)
427 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq)); 427 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
428} 428}
429 429
430static void end_sysint1_irq(unsigned int irq)
431{
432 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
433 icu1_set(MSYSINT1REG, 1 << SYSINT1_IRQ_TO_PIN(irq));
434}
435
436static struct irq_chip sysint1_irq_type = { 430static struct irq_chip sysint1_irq_type = {
437 .typename = "SYSINT1", 431 .typename = "SYSINT1",
438 .ack = disable_sysint1_irq, 432 .ack = disable_sysint1_irq,
439 .mask = disable_sysint1_irq, 433 .mask = disable_sysint1_irq,
440 .mask_ack = disable_sysint1_irq, 434 .mask_ack = disable_sysint1_irq,
441 .unmask = enable_sysint1_irq, 435 .unmask = enable_sysint1_irq,
442 .end = end_sysint1_irq,
443}; 436};
444 437
445static void disable_sysint2_irq(unsigned int irq) 438static void disable_sysint2_irq(unsigned int irq)
@@ -452,19 +445,12 @@ static void enable_sysint2_irq(unsigned int irq)
452 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq)); 445 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
453} 446}
454 447
455static void end_sysint2_irq(unsigned int irq)
456{
457 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
458 icu2_set(MSYSINT2REG, 1 << SYSINT2_IRQ_TO_PIN(irq));
459}
460
461static struct irq_chip sysint2_irq_type = { 448static struct irq_chip sysint2_irq_type = {
462 .typename = "SYSINT2", 449 .typename = "SYSINT2",
463 .ack = disable_sysint2_irq, 450 .ack = disable_sysint2_irq,
464 .mask = disable_sysint2_irq, 451 .mask = disable_sysint2_irq,
465 .mask_ack = disable_sysint2_irq, 452 .mask_ack = disable_sysint2_irq,
466 .unmask = enable_sysint2_irq, 453 .unmask = enable_sysint2_irq,
467 .end = end_sysint2_irq,
468}; 454};
469 455
470static inline int set_sysint1_assign(unsigned int irq, unsigned char assign) 456static inline int set_sysint1_assign(unsigned int irq, unsigned char assign)
diff --git a/arch/powerpc/.gitignore b/arch/powerpc/.gitignore
new file mode 100644
index 000000000000..a1a869c8c840
--- /dev/null
+++ b/arch/powerpc/.gitignore
@@ -0,0 +1 @@
include
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 116d7d3683ed..291c95ac4b31 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -112,7 +112,7 @@ choice
112 default 6xx 112 default 6xx
113 113
114config CLASSIC32 114config CLASSIC32
115 bool "6xx/7xx/74xx" 115 bool "52xx/6xx/7xx/74xx"
116 select PPC_FPU 116 select PPC_FPU
117 select 6xx 117 select 6xx
118 help 118 help
@@ -121,16 +121,18 @@ config CLASSIC32
121 versions (821, 823, 850, 855, 860, 52xx, 82xx, 83xx), the AMCC 121 versions (821, 823, 850, 855, 860, 52xx, 82xx, 83xx), the AMCC
122 embedded versions (403 and 405) and the high end 64 bit Power 122 embedded versions (403 and 405) and the high end 64 bit Power
123 processors (POWER 3, POWER4, and IBM PPC970 also known as G5). 123 processors (POWER 3, POWER4, and IBM PPC970 also known as G5).
124
125 This option is the catch-all for 6xx types, including some of the
126 embedded versions. Unless there is see an option for the specific
127 chip family you are using, you want this option.
128
129 You do not want this if you are building a kernel for a 64 bit
130 IBM RS/6000 or an Apple G5, choose 6xx.
131
132 If unsure, select this option
124 133
125 Unless you are building a kernel for one of the embedded processor
126 systems, 64 bit IBM RS/6000 or an Apple G5, choose 6xx.
127 Note that the kernel runs in 32-bit mode even on 64-bit chips. 134 Note that the kernel runs in 32-bit mode even on 64-bit chips.
128 135
129config PPC_52xx
130 bool "Freescale 52xx"
131 select 6xx
132 select PPC_FPU
133
134config PPC_82xx 136config PPC_82xx
135 bool "Freescale 82xx" 137 bool "Freescale 82xx"
136 select 6xx 138 select 6xx
@@ -160,9 +162,11 @@ config PPC_86xx
160 162
161config 40x 163config 40x
162 bool "AMCC 40x" 164 bool "AMCC 40x"
165 select PPC_DCR_NATIVE
163 166
164config 44x 167config 44x
165 bool "AMCC 44x" 168 bool "AMCC 44x"
169 select PPC_DCR_NATIVE
166 170
167config 8xx 171config 8xx
168 bool "Freescale 8xx" 172 bool "Freescale 8xx"
@@ -208,6 +212,24 @@ config PPC_FPU
208 bool 212 bool
209 default y if PPC64 213 default y if PPC64
210 214
215config PPC_DCR_NATIVE
216 bool
217 default n
218
219config PPC_DCR_MMIO
220 bool
221 default n
222
223config PPC_DCR
224 bool
225 depends on PPC_DCR_NATIVE || PPC_DCR_MMIO
226 default y
227
228config PPC_OF_PLATFORM_PCI
229 bool
230 depends on PPC64 # not supported on 32 bits yet
231 default n
232
211config BOOKE 233config BOOKE
212 bool 234 bool
213 depends on E200 || E500 235 depends on E200 || E500
@@ -227,6 +249,7 @@ config PTE_64BIT
227config PHYS_64BIT 249config PHYS_64BIT
228 bool 'Large physical address support' if E500 250 bool 'Large physical address support' if E500
229 depends on 44x || E500 251 depends on 44x || E500
252 select RESOURCES_64BIT
230 default y if 44x 253 default y if 44x
231 ---help--- 254 ---help---
232 This option enables kernel support for larger than 32-bit physical 255 This option enables kernel support for larger than 32-bit physical
@@ -369,11 +392,13 @@ config PPC_PSERIES
369 select PPC_RTAS 392 select PPC_RTAS
370 select RTAS_ERROR_LOGGING 393 select RTAS_ERROR_LOGGING
371 select PPC_UDBG_16550 394 select PPC_UDBG_16550
395 select PPC_NATIVE
372 default y 396 default y
373 397
374config PPC_ISERIES 398config PPC_ISERIES
375 bool "IBM Legacy iSeries" 399 bool "IBM Legacy iSeries"
376 depends on PPC_MULTIPLATFORM && PPC64 400 depends on PPC_MULTIPLATFORM && PPC64
401 select PPC_INDIRECT_IO
377 402
378config PPC_CHRP 403config PPC_CHRP
379 bool "Common Hardware Reference Platform (CHRP) based machines" 404 bool "Common Hardware Reference Platform (CHRP) based machines"
@@ -384,14 +409,35 @@ config PPC_CHRP
384 select PPC_RTAS 409 select PPC_RTAS
385 select PPC_MPC106 410 select PPC_MPC106
386 select PPC_UDBG_16550 411 select PPC_UDBG_16550
412 select PPC_NATIVE
413 default y
414
415config PPC_MPC52xx
416 bool
417 default n
418
419config PPC_EFIKA
420 bool "bPlan Efika 5k2. MPC5200B based computer"
421 depends on PPC_MULTIPLATFORM && PPC32
422 select PPC_RTAS
423 select RTAS_PROC
424 select PPC_MPC52xx
425 select PPC_NATIVE
387 default y 426 default y
388 427
428config PPC_LITE5200
429 bool "Freescale Lite5200 Eval Board"
430 depends on PPC_MULTIPLATFORM && PPC32
431 select PPC_MPC52xx
432 default n
433
389config PPC_PMAC 434config PPC_PMAC
390 bool "Apple PowerMac based machines" 435 bool "Apple PowerMac based machines"
391 depends on PPC_MULTIPLATFORM 436 depends on PPC_MULTIPLATFORM
392 select MPIC 437 select MPIC
393 select PPC_INDIRECT_PCI if PPC32 438 select PPC_INDIRECT_PCI if PPC32
394 select PPC_MPC106 if PPC32 439 select PPC_MPC106 if PPC32
440 select PPC_NATIVE
395 default y 441 default y
396 442
397config PPC_PMAC64 443config PPC_PMAC64
@@ -411,6 +457,7 @@ config PPC_PREP
411 select PPC_I8259 457 select PPC_I8259
412 select PPC_INDIRECT_PCI 458 select PPC_INDIRECT_PCI
413 select PPC_UDBG_16550 459 select PPC_UDBG_16550
460 select PPC_NATIVE
414 default y 461 default y
415 462
416config PPC_MAPLE 463config PPC_MAPLE
@@ -422,6 +469,7 @@ config PPC_MAPLE
422 select GENERIC_TBSYNC 469 select GENERIC_TBSYNC
423 select PPC_UDBG_16550 470 select PPC_UDBG_16550
424 select PPC_970_NAP 471 select PPC_970_NAP
472 select PPC_NATIVE
425 default n 473 default n
426 help 474 help
427 This option enables support for the Maple 970FX Evaluation Board. 475 This option enables support for the Maple 970FX Evaluation Board.
@@ -434,6 +482,7 @@ config PPC_PASEMI
434 select MPIC 482 select MPIC
435 select PPC_UDBG_16550 483 select PPC_UDBG_16550
436 select GENERIC_TBSYNC 484 select GENERIC_TBSYNC
485 select PPC_NATIVE
437 help 486 help
438 This option enables support for PA Semi's PWRficient line 487 This option enables support for PA Semi's PWRficient line
439 of SoC processors, including PA6T-1682M 488 of SoC processors, including PA6T-1682M
@@ -445,6 +494,11 @@ config PPC_CELL
445config PPC_CELL_NATIVE 494config PPC_CELL_NATIVE
446 bool 495 bool
447 select PPC_CELL 496 select PPC_CELL
497 select PPC_DCR_MMIO
498 select PPC_OF_PLATFORM_PCI
499 select PPC_INDIRECT_IO
500 select PPC_NATIVE
501 select MPIC
448 default n 502 default n
449 503
450config PPC_IBM_CELL_BLADE 504config PPC_IBM_CELL_BLADE
@@ -456,6 +510,22 @@ config PPC_IBM_CELL_BLADE
456 select PPC_UDBG_16550 510 select PPC_UDBG_16550
457 select UDBG_RTAS_CONSOLE 511 select UDBG_RTAS_CONSOLE
458 512
513config PPC_PS3
514 bool "Sony PS3"
515 depends on PPC_MULTIPLATFORM && PPC64
516 select PPC_CELL
517 help
518 This option enables support for the Sony PS3 game console
519 and other platforms using the PS3 hypervisor.
520
521config PPC_NATIVE
522 bool
523 depends on PPC_MULTIPLATFORM
524 help
525 Support for running natively on the hardware, i.e. without
526 a hypervisor. This option is not user-selectable but should
527 be selected by all platforms that need it.
528
459config UDBG_RTAS_CONSOLE 529config UDBG_RTAS_CONSOLE
460 bool "RTAS based debug console" 530 bool "RTAS based debug console"
461 depends on PPC_RTAS 531 depends on PPC_RTAS
@@ -517,6 +587,15 @@ config PPC_970_NAP
517 bool 587 bool
518 default n 588 default n
519 589
590config PPC_INDIRECT_IO
591 bool
592 select GENERIC_IOMAP
593 default n
594
595config GENERIC_IOMAP
596 bool
597 default n
598
520source "drivers/cpufreq/Kconfig" 599source "drivers/cpufreq/Kconfig"
521 600
522config CPU_FREQ_PMAC 601config CPU_FREQ_PMAC
@@ -594,12 +673,6 @@ config TAU_AVERAGE
594 673
595 If in doubt, say N here. 674 If in doubt, say N here.
596 675
597config PPC_TODC
598 depends on EMBEDDED6xx
599 bool "Generic Time-of-day Clock (TODC) support"
600 ---help---
601 This adds support for many TODC/RTC chips.
602
603endmenu 676endmenu
604 677
605source arch/powerpc/platforms/embedded6xx/Kconfig 678source arch/powerpc/platforms/embedded6xx/Kconfig
@@ -610,6 +683,7 @@ source arch/powerpc/platforms/85xx/Kconfig
610source arch/powerpc/platforms/86xx/Kconfig 683source arch/powerpc/platforms/86xx/Kconfig
611source arch/powerpc/platforms/8xx/Kconfig 684source arch/powerpc/platforms/8xx/Kconfig
612source arch/powerpc/platforms/cell/Kconfig 685source arch/powerpc/platforms/cell/Kconfig
686source arch/powerpc/platforms/ps3/Kconfig
613 687
614menu "Kernel options" 688menu "Kernel options"
615 689
@@ -790,7 +864,6 @@ source "arch/powerpc/platforms/prep/Kconfig"
790 864
791config CMDLINE_BOOL 865config CMDLINE_BOOL
792 bool "Default bootloader kernel arguments" 866 bool "Default bootloader kernel arguments"
793 depends on !PPC_ISERIES
794 867
795config CMDLINE 868config CMDLINE
796 string "Initial kernel command string" 869 string "Initial kernel command string"
@@ -880,7 +953,7 @@ config MCA
880 953
881config PCI 954config PCI
882 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \ 955 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
883 || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) || MPC7448HPC2 956 || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) || MPC7448HPC2 || PPC_PS3
884 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx \ 957 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx \
885 && !PPC_85xx && !PPC_86xx 958 && !PPC_85xx && !PPC_86xx
886 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS 959 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 5ad149b47e34..f0e51edde022 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -77,7 +77,7 @@ config KGDB_CONSOLE
77 77
78config XMON 78config XMON
79 bool "Include xmon kernel debugger" 79 bool "Include xmon kernel debugger"
80 depends on DEBUGGER && !PPC_ISERIES 80 depends on DEBUGGER
81 help 81 help
82 Include in-kernel hooks for the xmon kernel monitor/debugger. 82 Include in-kernel hooks for the xmon kernel monitor/debugger.
83 Unless you are intending to debug the kernel, say N here. 83 Unless you are intending to debug the kernel, say N here.
@@ -98,6 +98,15 @@ config XMON_DEFAULT
98 xmon is normally disabled unless booted with 'xmon=on'. 98 xmon is normally disabled unless booted with 'xmon=on'.
99 Use 'xmon=off' to disable xmon init during runtime. 99 Use 'xmon=off' to disable xmon init during runtime.
100 100
101config XMON_DISASSEMBLY
102 bool "Include disassembly support in xmon"
103 depends on XMON
104 default y
105 help
106 Include support for disassembling in xmon. You probably want
107 to say Y here, unless you're building for a memory-constrained
108 system.
109
101config IRQSTACKS 110config IRQSTACKS
102 bool "Use separate kernel stacks when processing interrupts" 111 bool "Use separate kernel stacks when processing interrupts"
103 depends on PPC64 112 depends on PPC64
@@ -116,7 +125,7 @@ config BDI_SWITCH
116 125
117config BOOTX_TEXT 126config BOOTX_TEXT
118 bool "Support for early boot text console (BootX or OpenFirmware only)" 127 bool "Support for early boot text console (BootX or OpenFirmware only)"
119 depends PPC_OF && !PPC_ISERIES 128 depends PPC_OF
120 help 129 help
121 Say Y here to see progress messages from the boot firmware in text 130 Say Y here to see progress messages from the boot firmware in text
122 mode. Requires either BootX or Open Firmware. 131 mode. Requires either BootX or Open Firmware.
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 45c9ad23526e..0734b2fc1d95 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -1,19 +1,32 @@
1addnote 1addnote
2empty.c
3hack-coff
2infblock.c 4infblock.c
3infblock.h 5infblock.h
4infcodes.c 6infcodes.c
5infcodes.h 7infcodes.h
6inffast.c 8inffast.c
7inffast.h 9inffast.h
10inffixed.h
8inflate.c 11inflate.c
12inflate.h
9inftrees.c 13inftrees.c
10inftrees.h 14inftrees.h
11infutil.c 15infutil.c
12infutil.h 16infutil.h
13kernel-vmlinux.strip.c 17kernel-vmlinux.strip.c
14kernel-vmlinux.strip.gz 18kernel-vmlinux.strip.gz
19mktree
15uImage 20uImage
16zImage 21zImage
22zImage.chrp
23zImage.coff
24zImage.coff.lds
25zImage.lds
26zImage.miboot
27zImage.pmac
28zImage.pseries
29zImage.sandpoint
17zImage.vmode 30zImage.vmode
18zconf.h 31zconf.h
19zlib.h 32zlib.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 4b2be611f77f..343dbcfdf08a 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -40,7 +40,8 @@ zliblinuxheader := zlib.h zconf.h zutil.h
40$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \ 40$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
41 $(addprefix $(obj)/,$(zlibheader)) 41 $(addprefix $(obj)/,$(zlibheader))
42 42
43src-wlib := string.S stdio.c main.c div64.S $(zlib) 43src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
44 ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib)
44src-plat := of.c 45src-plat := of.c
45src-boot := crt0.S $(src-wlib) $(src-plat) empty.c 46src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
46 47
@@ -74,7 +75,7 @@ $(obj)/zImage.lds $(obj)/zImage.coff.lds: $(obj)/%: $(srctree)/$(src)/%.S
74 @cp $< $@ 75 @cp $< $@
75 76
76clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ 77clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
77 $(obj)/empty.c 78 empty.c zImage zImage.coff.lds zImage.lds zImage.sandpoint
78 79
79quiet_cmd_bootcc = BOOTCC $@ 80quiet_cmd_bootcc = BOOTCC $@
80 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< 81 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
@@ -93,13 +94,13 @@ $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
93$(obj)/wrapper.a: $(obj-wlib) 94$(obj)/wrapper.a: $(obj-wlib)
94 $(call cmd,bootar) 95 $(call cmd,bootar)
95 96
96hostprogs-y := addnote addRamDisk hack-coff 97hostprogs-y := addnote addRamDisk hack-coff mktree
97 98
98extra-y := $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ 99extra-y := $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
99 $(obj)/zImage.lds $(obj)/zImage.coff.lds 100 $(obj)/zImage.lds $(obj)/zImage.coff.lds
100 101
101wrapper :=$(srctree)/$(src)/wrapper 102wrapper :=$(srctree)/$(src)/wrapper
102wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff) 103wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree)
103 104
104############# 105#############
105# Bits for building various flavours of zImage 106# Bits for building various flavours of zImage
@@ -148,13 +149,18 @@ $(obj)/zImage.miboot: vmlinux $(wrapperbits)
148$(obj)/zImage.initrd.miboot: vmlinux $(wrapperbits) 149$(obj)/zImage.initrd.miboot: vmlinux $(wrapperbits)
149 $(call cmd,wrap_initrd,miboot) 150 $(call cmd,wrap_initrd,miboot)
150 151
152$(obj)/zImage.ps3: vmlinux
153 $(STRIP) -s -R .comment $< -o $@
154
151$(obj)/uImage: vmlinux $(wrapperbits) 155$(obj)/uImage: vmlinux $(wrapperbits)
152 $(call cmd,wrap,uboot) 156 $(call cmd,wrap,uboot)
153 157
154image-$(CONFIG_PPC_PSERIES) += zImage.pseries 158image-$(CONFIG_PPC_PSERIES) += zImage.pseries
155image-$(CONFIG_PPC_MAPLE) += zImage.pseries 159image-$(CONFIG_PPC_MAPLE) += zImage.pseries
156image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries 160image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries
161image-$(CONFIG_PPC_PS3) += zImage.ps3
157image-$(CONFIG_PPC_CHRP) += zImage.chrp 162image-$(CONFIG_PPC_CHRP) += zImage.chrp
163image-$(CONFIG_PPC_EFIKA) += zImage.chrp
158image-$(CONFIG_PPC_PMAC) += zImage.pmac 164image-$(CONFIG_PPC_PMAC) += zImage.pmac
159image-$(CONFIG_DEFAULT_UIMAGE) += uImage 165image-$(CONFIG_DEFAULT_UIMAGE) += uImage
160 166
@@ -176,3 +182,4 @@ install: $(CONFIGURE) $(image-y)
176 182
177clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip.gz) 183clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip.gz)
178clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.bin.gz) 184clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.bin.gz)
185clean-files += $(image-)
diff --git a/arch/powerpc/boot/dts/kuroboxHG.dts b/arch/powerpc/boot/dts/kuroboxHG.dts
new file mode 100644
index 000000000000..d06b0b018899
--- /dev/null
+++ b/arch/powerpc/boot/dts/kuroboxHG.dts
@@ -0,0 +1,148 @@
1/*
2 * Device Tree Souce for Buffalo KuroboxHG
3 *
4 * Choose CONFIG_LINKSTATION to build a kernel for KuroboxHG, or use
5 * the default configuration linkstation_defconfig.
6 *
7 * Based on sandpoint.dts
8 *
9 * 2006 (c) G. Liakhovetski <g.liakhovetski@gmx.de>
10 *
11 * This file is licensed under
12 * the terms of the GNU General Public License version 2. This program
13 * is licensed "as is" without any warranty of any kind, whether express
14 * or implied.
15
16XXXX add flash parts, rtc, ??
17
18build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
19
20
21 */
22
23/ {
24 linux,phandle = <1000>;
25 model = "KuroboxHG";
26 compatible = "linkstation";
27 #address-cells = <1>;
28 #size-cells = <1>;
29
30 cpus {
31 linux,phandle = <2000>;
32 #cpus = <1>;
33 #address-cells = <1>;
34 #size-cells = <0>;
35
36 PowerPC,603e { /* Really 8241 */
37 linux,phandle = <2100>;
38 linux,boot-cpu;
39 device_type = "cpu";
40 reg = <0>;
41 clock-frequency = <fdad680>; /* Fixed by bootwrapper */
42 timebase-frequency = <1F04000>; /* Fixed by bootwrapper */
43 bus-frequency = <0>; /* From bootloader */
44 /* Following required by dtc but not used */
45 i-cache-line-size = <0>;
46 d-cache-line-size = <0>;
47 i-cache-size = <4000>;
48 d-cache-size = <4000>;
49 };
50 };
51
52 memory {
53 linux,phandle = <3000>;
54 device_type = "memory";
55 reg = <00000000 08000000>;
56 };
57
58 soc10x { /* AFAICT need to make soc for 8245's uarts to be defined */
59 linux,phandle = <4000>;
60 #address-cells = <1>;
61 #size-cells = <1>;
62 #interrupt-cells = <2>;
63 device_type = "soc";
64 compatible = "mpc10x";
65 store-gathering = <0>; /* 0 == off, !0 == on */
66 reg = <80000000 00100000>;
67 ranges = <80000000 80000000 70000000 /* pci mem space */
68 fc000000 fc000000 00100000 /* EUMB */
69 fe000000 fe000000 00c00000 /* pci i/o space */
70 fec00000 fec00000 00300000 /* pci cfg regs */
71 fef00000 fef00000 00100000>; /* pci iack */
72
73 i2c@80003000 {
74 linux,phandle = <4300>;
75 device_type = "i2c";
76 compatible = "fsl-i2c";
77 reg = <80003000 1000>;
78 interrupts = <5 2>;
79 interrupt-parent = <4400>;
80 };
81
82 serial@80004500 {
83 linux,phandle = <4511>;
84 device_type = "serial";
85 compatible = "ns16550";
86 reg = <80004500 8>;
87 clock-frequency = <7c044a8>;
88 current-speed = <2580>;
89 interrupts = <9 2>;
90 interrupt-parent = <4400>;
91 };
92
93 serial@80004600 {
94 linux,phandle = <4512>;
95 device_type = "serial";
96 compatible = "ns16550";
97 reg = <80004600 8>;
98 clock-frequency = <7c044a8>;
99 current-speed = <e100>;
100 interrupts = <a 0>;
101 interrupt-parent = <4400>;
102 };
103
104 pic@80040000 {
105 linux,phandle = <4400>;
106 #interrupt-cells = <2>;
107 #address-cells = <0>;
108 device_type = "open-pic";
109 compatible = "chrp,open-pic";
110 interrupt-controller;
111 reg = <80040000 40000>;
112 built-in;
113 };
114
115 pci@fec00000 {
116 linux,phandle = <4500>;
117 #address-cells = <3>;
118 #size-cells = <2>;
119 #interrupt-cells = <1>;
120 device_type = "pci";
121 compatible = "mpc10x-pci";
122 reg = <fec00000 400000>;
123 ranges = <01000000 0 0 fe000000 0 00c00000
124 02000000 0 80000000 80000000 0 70000000>;
125 bus-range = <0 ff>;
126 clock-frequency = <7f28155>;
127 interrupt-parent = <4400>;
128 interrupt-map-mask = <f800 0 0 7>;
129 interrupt-map = <
130 /* IDSEL 0x11 - IRQ0 ETH */
131 5800 0 0 1 4400 0 1
132 5800 0 0 2 4400 1 1
133 5800 0 0 3 4400 2 1
134 5800 0 0 4 4400 3 1
135 /* IDSEL 0x12 - IRQ1 IDE0 */
136 6000 0 0 1 4400 1 1
137 6000 0 0 2 4400 2 1
138 6000 0 0 3 4400 3 1
139 6000 0 0 4 4400 0 1
140 /* IDSEL 0x14 - IRQ3 USB2.0 */
141 7000 0 0 1 4400 3 1
142 7000 0 0 2 4400 3 1
143 7000 0 0 3 4400 3 1
144 7000 0 0 4 4400 3 1
145 >;
146 };
147 };
148};
diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
new file mode 100644
index 000000000000..8bc0d259796d
--- /dev/null
+++ b/arch/powerpc/boot/dts/lite5200.dts
@@ -0,0 +1,313 @@
1/*
2 * Lite5200 board Device Tree Source
3 *
4 * Copyright 2006 Secret Lab Technologies Ltd.
5 * Grant Likely <grant.likely@secretlab.ca>
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
13/ {
14 model = "Lite5200";
15 compatible = "lite5200\0lite52xx\0mpc5200\0mpc52xx";
16 #address-cells = <1>;
17 #size-cells = <1>;
18
19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>;
22 #size-cells = <0>;
23
24 PowerPC,5200@0 {
25 device_type = "cpu";
26 reg = <0>;
27 d-cache-line-size = <20>;
28 i-cache-line-size = <20>;
29 d-cache-size = <4000>; // L1, 16K
30 i-cache-size = <4000>; // L1, 16K
31 timebase-frequency = <0>; // from bootloader
32 bus-frequency = <0>; // from bootloader
33 clock-frequency = <0>; // from bootloader
34 32-bit;
35 };
36 };
37
38 memory {
39 device_type = "memory";
40 reg = <00000000 04000000>; // 64MB
41 };
42
43 soc5200@f0000000 {
44 #interrupt-cells = <3>;
45 device_type = "soc";
46 ranges = <0 f0000000 f0010000>;
47 reg = <f0000000 00010000>;
48 bus-frequency = <0>; // from bootloader
49
50 cdm@200 {
51 compatible = "mpc5200-cdm\0mpc52xx-cdm";
52 reg = <200 38>;
53 };
54
55 pic@500 {
56 // 5200 interrupts are encoded into two levels;
57 linux,phandle = <500>;
58 interrupt-controller;
59 #interrupt-cells = <3>;
60 device_type = "interrupt-controller";
61 compatible = "mpc5200-pic\0mpc52xx-pic";
62 reg = <500 80>;
63 built-in;
64 };
65
66 gpt@600 { // General Purpose Timer
67 compatible = "mpc5200-gpt\0mpc52xx-gpt";
68 device_type = "gpt";
69 reg = <600 10>;
70 interrupts = <1 9 0>;
71 interrupt-parent = <500>;
72 };
73
74 gpt@610 { // General Purpose Timer
75 compatible = "mpc5200-gpt\0mpc52xx-gpt";
76 device_type = "gpt";
77 reg = <610 10>;
78 interrupts = <1 a 0>;
79 interrupt-parent = <500>;
80 };
81
82 gpt@620 { // General Purpose Timer
83 compatible = "mpc5200-gpt\0mpc52xx-gpt";
84 device_type = "gpt";
85 reg = <620 10>;
86 interrupts = <1 b 0>;
87 interrupt-parent = <500>;
88 };
89
90 gpt@630 { // General Purpose Timer
91 compatible = "mpc5200-gpt\0mpc52xx-gpt";
92 device_type = "gpt";
93 reg = <630 10>;
94 interrupts = <1 c 0>;
95 interrupt-parent = <500>;
96 };
97
98 gpt@640 { // General Purpose Timer
99 compatible = "mpc5200-gpt\0mpc52xx-gpt";
100 device_type = "gpt";
101 reg = <640 10>;
102 interrupts = <1 d 0>;
103 interrupt-parent = <500>;
104 };
105
106 gpt@650 { // General Purpose Timer
107 compatible = "mpc5200-gpt\0mpc52xx-gpt";
108 device_type = "gpt";
109 reg = <650 10>;
110 interrupts = <1 e 0>;
111 interrupt-parent = <500>;
112 };
113
114 gpt@660 { // General Purpose Timer
115 compatible = "mpc5200-gpt\0mpc52xx-gpt";
116 device_type = "gpt";
117 reg = <660 10>;
118 interrupts = <1 f 0>;
119 interrupt-parent = <500>;
120 };
121
122 gpt@670 { // General Purpose Timer
123 compatible = "mpc5200-gpt\0mpc52xx-gpt";
124 device_type = "gpt";
125 reg = <670 10>;
126 interrupts = <1 10 0>;
127 interrupt-parent = <500>;
128 };
129
130 rtc@800 { // Real time clock
131 compatible = "mpc5200-rtc\0mpc52xx-rtc";
132 device_type = "rtc";
133 reg = <800 100>;
134 interrupts = <1 5 0 1 6 0>;
135 interrupt-parent = <500>;
136 };
137
138 mscan@900 {
139 device_type = "mscan";
140 compatible = "mpc5200-mscan\0mpc52xx-mscan";
141 interrupts = <2 11 0>;
142 interrupt-parent = <500>;
143 reg = <900 80>;
144 };
145
146 mscan@980 {
147 device_type = "mscan";
148 compatible = "mpc5200-mscan\0mpc52xx-mscan";
149 interrupts = <1 12 0>;
150 interrupt-parent = <500>;
151 reg = <980 80>;
152 };
153
154 gpio@b00 {
155 compatible = "mpc5200-gpio\0mpc52xx-gpio";
156 reg = <b00 40>;
157 interrupts = <1 7 0>;
158 interrupt-parent = <500>;
159 };
160
161 gpio-wkup@b00 {
162 compatible = "mpc5200-gpio-wkup\0mpc52xx-gpio-wkup";
163 reg = <c00 40>;
164 interrupts = <1 8 0 0 3 0>;
165 interrupt-parent = <500>;
166 };
167
168 pci@0d00 {
169 #interrupt-cells = <1>;
170 #size-cells = <2>;
171 #address-cells = <3>;
172 device_type = "pci";
173 compatible = "mpc5200-pci\0mpc52xx-pci";
174 reg = <d00 100>;
175 interrupt-map-mask = <f800 0 0 7>;
176 interrupt-map = <c000 0 0 1 500 0 0 3
177 c000 0 0 2 500 0 0 3
178 c000 0 0 3 500 0 0 3
179 c000 0 0 4 500 0 0 3>;
180 clock-frequency = <0>; // From boot loader
181 interrupts = <2 8 0 2 9 0 2 a 0>;
182 interrupt-parent = <500>;
183 bus-range = <0 0>;
184 ranges = <42000000 0 80000000 80000000 0 20000000
185 02000000 0 a0000000 a0000000 0 10000000
186 01000000 0 00000000 b0000000 0 01000000>;
187 };
188
189 spi@f00 {
190 device_type = "spi";
191 compatible = "mpc5200-spi\0mpc52xx-spi";
192 reg = <f00 20>;
193 interrupts = <2 d 0 2 e 0>;
194 interrupt-parent = <500>;
195 };
196
197 usb@1000 {
198 device_type = "usb-ohci-be";
199 compatible = "mpc5200-ohci\0mpc52xx-ohci\0ohci-be";
200 reg = <1000 ff>;
201 interrupts = <2 6 0>;
202 interrupt-parent = <500>;
203 };
204
205 bestcomm@1200 {
206 device_type = "dma-controller";
207 compatible = "mpc5200-bestcomm\0mpc52xx-bestcomm";
208 reg = <1200 80>;
209 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
210 3 4 0 3 5 0 3 6 0 3 7 0
211 3 8 0 3 9 0 3 a 0 3 b 0
212 3 c 0 3 d 0 3 e 0 3 f 0>;
213 interrupt-parent = <500>;
214 };
215
216 xlb@1f00 {
217 compatible = "mpc5200-xlb\0mpc52xx-xlb";
218 reg = <1f00 100>;
219 };
220
221 serial@2000 { // PSC1
222 device_type = "serial";
223 compatible = "mpc5200-psc-uart\0mpc52xx-psc-uart";
224 port-number = <0>; // Logical port assignment
225 reg = <2000 100>;
226 interrupts = <2 1 0>;
227 interrupt-parent = <500>;
228 };
229
230 // PSC2 in spi mode example
231 spi@2200 { // PSC2
232 device_type = "spi";
233 compatible = "mpc5200-psc-spi\0mpc52xx-psc-spi";
234 reg = <2200 100>;
235 interrupts = <2 2 0>;
236 interrupt-parent = <500>;
237 };
238
239 // PSC3 in CODEC mode example
240 i2s@2400 { // PSC3
241 device_type = "i2s";
242 compatible = "mpc5200-psc-i2s\0mpc52xx-psc-i2s";
243 reg = <2400 100>;
244 interrupts = <2 3 0>;
245 interrupt-parent = <500>;
246 };
247
248 // PSC4 unconfigured
249 //serial@2600 { // PSC4
250 // device_type = "serial";
251 // compatible = "mpc5200-psc-uart\0mpc52xx-psc-uart";
252 // reg = <2600 100>;
253 // interrupts = <2 b 0>;
254 // interrupt-parent = <500>;
255 //};
256
257 // PSC5 unconfigured
258 //serial@2800 { // PSC5
259 // device_type = "serial";
260 // compatible = "mpc5200-psc-uart\0mpc52xx-psc-uart";
261 // reg = <2800 100>;
262 // interrupts = <2 c 0>;
263 // interrupt-parent = <500>;
264 //};
265
266 // PSC6 in AC97 mode example
267 ac97@2c00 { // PSC6
268 device_type = "ac97";
269 compatible = "mpc5200-psc-ac97\0mpc52xx-psc-ac97";
270 reg = <2c00 100>;
271 interrupts = <2 4 0>;
272 interrupt-parent = <500>;
273 };
274
275 ethernet@3000 {
276 device_type = "network";
277 compatible = "mpc5200-fec\0mpc52xx-fec";
278 reg = <3000 800>;
279 mac-address = [ 02 03 04 05 06 07 ]; // Bad!
280 interrupts = <2 5 0>;
281 interrupt-parent = <500>;
282 };
283
284 ata@3a00 {
285 device_type = "ata";
286 compatible = "mpc5200-ata\0mpc52xx-ata";
287 reg = <3a00 100>;
288 interrupts = <2 7 0>;
289 interrupt-parent = <500>;
290 };
291
292 i2c@3d00 {
293 device_type = "i2c";
294 compatible = "mpc5200-i2c\0mpc52xx-i2c";
295 reg = <3d00 40>;
296 interrupts = <2 f 0>;
297 interrupt-parent = <500>;
298 };
299
300 i2c@3d40 {
301 device_type = "i2c";
302 compatible = "mpc5200-i2c\0mpc52xx-i2c";
303 reg = <3d40 40>;
304 interrupts = <2 10 0>;
305 interrupt-parent = <500>;
306 };
307 sram@8000 {
308 device_type = "sram";
309 compatible = "mpc5200-sram\0mpc52xx-sram\0sram";
310 reg = <8000 4000>;
311 };
312 };
313};
diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
new file mode 100644
index 000000000000..81cb76418a78
--- /dev/null
+++ b/arch/powerpc/boot/dts/lite5200b.dts
@@ -0,0 +1,318 @@
1/*
2 * Lite5200B board Device Tree Source
3 *
4 * Copyright 2006 Secret Lab Technologies Ltd.
5 * Grant Likely <grant.likely@secretlab.ca>
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
13/ {
14 model = "Lite5200b";
15 compatible = "lite5200b\0lite52xx\0mpc5200b\0mpc52xx";
16 #address-cells = <1>;
17 #size-cells = <1>;
18
19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>;
22 #size-cells = <0>;
23
24 PowerPC,5200@0 {
25 device_type = "cpu";
26 reg = <0>;
27 d-cache-line-size = <20>;
28 i-cache-line-size = <20>;
29 d-cache-size = <4000>; // L1, 16K
30 i-cache-size = <4000>; // L1, 16K
31 timebase-frequency = <0>; // from bootloader
32 bus-frequency = <0>; // from bootloader
33 clock-frequency = <0>; // from bootloader
34 32-bit;
35 };
36 };
37
38 memory {
39 device_type = "memory";
40 reg = <00000000 10000000>; // 256MB
41 };
42
43 soc5200@f0000000 {
44 #interrupt-cells = <3>;
45 device_type = "soc";
46 ranges = <0 f0000000 f0010000>;
47 reg = <f0000000 00010000>;
48 bus-frequency = <0>; // from bootloader
49
50 cdm@200 {
51 compatible = "mpc5200b-cdm\0mpc52xx-cdm";
52 reg = <200 38>;
53 };
54
55 pic@500 {
56 // 5200 interrupts are encoded into two levels;
57 linux,phandle = <500>;
58 interrupt-controller;
59 #interrupt-cells = <3>;
60 device_type = "interrupt-controller";
61 compatible = "mpc5200b-pic\0mpc52xx-pic";
62 reg = <500 80>;
63 built-in;
64 };
65
66 gpt@600 { // General Purpose Timer
67 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
68 device_type = "gpt";
69 reg = <600 10>;
70 interrupts = <1 9 0>;
71 interrupt-parent = <500>;
72 };
73
74 gpt@610 { // General Purpose Timer
75 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
76 device_type = "gpt";
77 reg = <610 10>;
78 interrupts = <1 a 0>;
79 interrupt-parent = <500>;
80 };
81
82 gpt@620 { // General Purpose Timer
83 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
84 device_type = "gpt";
85 reg = <620 10>;
86 interrupts = <1 b 0>;
87 interrupt-parent = <500>;
88 };
89
90 gpt@630 { // General Purpose Timer
91 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
92 device_type = "gpt";
93 reg = <630 10>;
94 interrupts = <1 c 0>;
95 interrupt-parent = <500>;
96 };
97
98 gpt@640 { // General Purpose Timer
99 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
100 device_type = "gpt";
101 reg = <640 10>;
102 interrupts = <1 d 0>;
103 interrupt-parent = <500>;
104 };
105
106 gpt@650 { // General Purpose Timer
107 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
108 device_type = "gpt";
109 reg = <650 10>;
110 interrupts = <1 e 0>;
111 interrupt-parent = <500>;
112 };
113
114 gpt@660 { // General Purpose Timer
115 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
116 device_type = "gpt";
117 reg = <660 10>;
118 interrupts = <1 f 0>;
119 interrupt-parent = <500>;
120 };
121
122 gpt@670 { // General Purpose Timer
123 compatible = "mpc5200b-gpt\0mpc52xx-gpt";
124 device_type = "gpt";
125 reg = <670 10>;
126 interrupts = <1 10 0>;
127 interrupt-parent = <500>;
128 };
129
130 rtc@800 { // Real time clock
131 compatible = "mpc5200b-rtc\0mpc52xx-rtc";
132 device_type = "rtc";
133 reg = <800 100>;
134 interrupts = <1 5 0 1 6 0>;
135 interrupt-parent = <500>;
136 };
137
138 mscan@900 {
139 device_type = "mscan";
140 compatible = "mpc5200b-mscan\0mpc52xx-mscan";
141 interrupts = <2 11 0>;
142 interrupt-parent = <500>;
143 reg = <900 80>;
144 };
145
146 mscan@980 {
147 device_type = "mscan";
148 compatible = "mpc5200b-mscan\0mpc52xx-mscan";
149 interrupts = <1 12 0>;
150 interrupt-parent = <500>;
151 reg = <980 80>;
152 };
153
154 gpio@b00 {
155 compatible = "mpc5200b-gpio\0mpc52xx-gpio";
156 reg = <b00 40>;
157 interrupts = <1 7 0>;
158 interrupt-parent = <500>;
159 };
160
161 gpio-wkup@b00 {
162 compatible = "mpc5200b-gpio-wkup\0mpc52xx-gpio-wkup";
163 reg = <c00 40>;
164 interrupts = <1 8 0 0 3 0>;
165 interrupt-parent = <500>;
166 };
167
168 pci@0d00 {
169 #interrupt-cells = <1>;
170 #size-cells = <2>;
171 #address-cells = <3>;
172 device_type = "pci";
173 compatible = "mpc5200b-pci\0mpc52xx-pci";
174 reg = <d00 100>;
175 interrupt-map-mask = <f800 0 0 7>;
176 interrupt-map = <c000 0 0 1 500 0 0 3 // 1st slot
177 c000 0 0 2 500 1 1 3
178 c000 0 0 3 500 1 2 3
179 c000 0 0 4 500 1 3 3
180
181 c800 0 0 1 500 1 1 3 // 2nd slot
182 c800 0 0 2 500 1 2 3
183 c800 0 0 3 500 1 3 3
184 c800 0 0 4 500 0 0 3>;
185 clock-frequency = <0>; // From boot loader
186 interrupts = <2 8 0 2 9 0 2 a 0>;
187 interrupt-parent = <500>;
188 bus-range = <0 0>;
189 ranges = <42000000 0 80000000 80000000 0 20000000
190 02000000 0 a0000000 a0000000 0 10000000
191 01000000 0 00000000 b0000000 0 01000000>;
192 };
193
194 spi@f00 {
195 device_type = "spi";
196 compatible = "mpc5200b-spi\0mpc52xx-spi";
197 reg = <f00 20>;
198 interrupts = <2 d 0 2 e 0>;
199 interrupt-parent = <500>;
200 };
201
202 usb@1000 {
203 device_type = "usb-ohci-be";
204 compatible = "mpc5200b-ohci\0mpc52xx-ohci\0ohci-be";
205 reg = <1000 ff>;
206 interrupts = <2 6 0>;
207 interrupt-parent = <500>;
208 };
209
210 bestcomm@1200 {
211 device_type = "dma-controller";
212 compatible = "mpc5200b-bestcomm\0mpc52xx-bestcomm";
213 reg = <1200 80>;
214 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
215 3 4 0 3 5 0 3 6 0 3 7 0
216 3 8 0 3 9 0 3 a 0 3 b 0
217 3 c 0 3 d 0 3 e 0 3 f 0>;
218 interrupt-parent = <500>;
219 };
220
221 xlb@1f00 {
222 compatible = "mpc5200b-xlb\0mpc52xx-xlb";
223 reg = <1f00 100>;
224 };
225
226 serial@2000 { // PSC1
227 device_type = "serial";
228 compatible = "mpc5200b-psc-uart\0mpc52xx-psc-uart";
229 port-number = <0>; // Logical port assignment
230 reg = <2000 100>;
231 interrupts = <2 1 0>;
232 interrupt-parent = <500>;
233 };
234
235 // PSC2 in spi mode example
236 spi@2200 { // PSC2
237 device_type = "spi";
238 compatible = "mpc5200b-psc-spi\0mpc52xx-psc-spi";
239 reg = <2200 100>;
240 interrupts = <2 2 0>;
241 interrupt-parent = <500>;
242 };
243
244 // PSC3 in CODEC mode example
245 i2s@2400 { // PSC3
246 device_type = "i2s";
247 compatible = "mpc5200b-psc-i2s\0mpc52xx-psc-i2s";
248 reg = <2400 100>;
249 interrupts = <2 3 0>;
250 interrupt-parent = <500>;
251 };
252
253 // PSC4 unconfigured
254 //serial@2600 { // PSC4
255 // device_type = "serial";
256 // compatible = "mpc5200b-psc-uart\0mpc52xx-psc-uart";
257 // reg = <2600 100>;
258 // interrupts = <2 b 0>;
259 // interrupt-parent = <500>;
260 //};
261
262 // PSC5 unconfigured
263 //serial@2800 { // PSC5
264 // device_type = "serial";
265 // compatible = "mpc5200b-psc-uart\0mpc52xx-psc-uart";
266 // reg = <2800 100>;
267 // interrupts = <2 c 0>;
268 // interrupt-parent = <500>;
269 //};
270
271 // PSC6 in AC97 mode example
272 ac97@2c00 { // PSC6
273 device_type = "ac97";
274 compatible = "mpc5200b-psc-ac97\0mpc52xx-psc-ac97";
275 reg = <2c00 100>;
276 interrupts = <2 4 0>;
277 interrupt-parent = <500>;
278 };
279
280 ethernet@3000 {
281 device_type = "network";
282 compatible = "mpc5200b-fec\0mpc52xx-fec";
283 reg = <3000 800>;
284 mac-address = [ 02 03 04 05 06 07 ]; // Bad!
285 interrupts = <2 5 0>;
286 interrupt-parent = <500>;
287 };
288
289 ata@3a00 {
290 device_type = "ata";
291 compatible = "mpc5200b-ata\0mpc52xx-ata";
292 reg = <3a00 100>;
293 interrupts = <2 7 0>;
294 interrupt-parent = <500>;
295 };
296
297 i2c@3d00 {
298 device_type = "i2c";
299 compatible = "mpc5200b-i2c\0mpc52xx-i2c";
300 reg = <3d00 40>;
301 interrupts = <2 f 0>;
302 interrupt-parent = <500>;
303 };
304
305 i2c@3d40 {
306 device_type = "i2c";
307 compatible = "mpc5200b-i2c\0mpc52xx-i2c";
308 reg = <3d40 40>;
309 interrupts = <2 10 0>;
310 interrupt-parent = <500>;
311 };
312 sram@8000 {
313 device_type = "sram";
314 compatible = "mpc5200b-sram\0mpc52xx-sram\0sram";
315 reg = <8000 4000>;
316 };
317 };
318};
diff --git a/arch/powerpc/boot/dts/mpc7448hpc2.dts b/arch/powerpc/boot/dts/mpc7448hpc2.dts
index d7b985e6bd2f..c4d9562cbaad 100644
--- a/arch/powerpc/boot/dts/mpc7448hpc2.dts
+++ b/arch/powerpc/boot/dts/mpc7448hpc2.dts
@@ -161,29 +161,41 @@
161 interrupt-map = < 161 interrupt-map = <
162 162
163 /* IDSEL 0x11 */ 163 /* IDSEL 0x11 */
164 0800 0 0 1 7400 24 0 164 0800 0 0 1 1180 24 0
165 0800 0 0 2 7400 25 0 165 0800 0 0 2 1180 25 0
166 0800 0 0 3 7400 26 0 166 0800 0 0 3 1180 26 0
167 0800 0 0 4 7400 27 0 167 0800 0 0 4 1180 27 0
168 168
169 /* IDSEL 0x12 */ 169 /* IDSEL 0x12 */
170 1000 0 0 1 7400 25 0 170 1000 0 0 1 1180 25 0
171 1000 0 0 2 7400 26 0 171 1000 0 0 2 1180 26 0
172 1000 0 0 3 7400 27 0 172 1000 0 0 3 1180 27 0
173 1000 0 0 4 7400 24 0 173 1000 0 0 4 1180 24 0
174 174
175 /* IDSEL 0x13 */ 175 /* IDSEL 0x13 */
176 1800 0 0 1 7400 26 0 176 1800 0 0 1 1180 26 0
177 1800 0 0 2 7400 27 0 177 1800 0 0 2 1180 27 0
178 1800 0 0 3 7400 24 0 178 1800 0 0 3 1180 24 0
179 1800 0 0 4 7400 25 0 179 1800 0 0 4 1180 25 0
180 180
181 /* IDSEL 0x14 */ 181 /* IDSEL 0x14 */
182 2000 0 0 1 7400 27 0 182 2000 0 0 1 1180 27 0
183 2000 0 0 2 7400 24 0 183 2000 0 0 2 1180 24 0
184 2000 0 0 3 7400 25 0 184 2000 0 0 3 1180 25 0
185 2000 0 0 4 7400 26 0 185 2000 0 0 4 1180 26 0
186 >; 186 >;
187 router@1180 {
188 linux,phandle = <1180>;
189 clock-frequency = <0>;
190 interrupt-controller;
191 device_type = "pic-router";
192 #address-cells = <0>;
193 #interrupt-cells = <2>;
194 built-in;
195 big-endian;
196 interrupts = <17 2>;
197 interrupt-parent = <7400>;
198 };
187 }; 199 };
188 }; 200 };
189 201
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
new file mode 100644
index 000000000000..c76c194715b2
--- /dev/null
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -0,0 +1,880 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 *
16 * Copyright Pantelis Antoniou 2006
17 * Copyright (C) IBM Corporation 2006
18 *
19 * Authors: Pantelis Antoniou <pantelis@embeddedalley.com>
20 * Hollis Blanchard <hollisb@us.ibm.com>
21 * Mark A. Greer <mgreer@mvista.com>
22 * Paul Mackerras <paulus@samba.org>
23 */
24
25#include <string.h>
26#include <stddef.h>
27#include "flatdevtree.h"
28#include "flatdevtree_env.h"
29
30#define _ALIGN(x, al) (((x) + (al) - 1) & ~((al) - 1))
31
32/* Routines for keeping node ptrs returned by ft_find_device current */
33/* First entry not used b/c it would return 0 and be taken as NULL/error */
34static void *ft_node_add(struct ft_cxt *cxt, char *node)
35{
36 unsigned int i;
37
38 for (i = 1; i < cxt->nodes_used; i++) /* already there? */
39 if (cxt->node_tbl[i] == node)
40 return (void *)i;
41
42 if (cxt->nodes_used < cxt->node_max) {
43 cxt->node_tbl[cxt->nodes_used] = node;
44 return (void *)cxt->nodes_used++;
45 }
46
47 return NULL;
48}
49
50static char *ft_node_ph2node(struct ft_cxt *cxt, const void *phandle)
51{
52 unsigned int i = (unsigned int)phandle;
53
54 if (i < cxt->nodes_used)
55 return cxt->node_tbl[i];
56 return NULL;
57}
58
59static void ft_node_update_before(struct ft_cxt *cxt, char *addr, int shift)
60{
61 unsigned int i;
62
63 if (shift == 0)
64 return;
65
66 for (i = 1; i < cxt->nodes_used; i++)
67 if (cxt->node_tbl[i] < addr)
68 cxt->node_tbl[i] += shift;
69}
70
71static void ft_node_update_after(struct ft_cxt *cxt, char *addr, int shift)
72{
73 unsigned int i;
74
75 if (shift == 0)
76 return;
77
78 for (i = 1; i < cxt->nodes_used; i++)
79 if (cxt->node_tbl[i] >= addr)
80 cxt->node_tbl[i] += shift;
81}
82
83/* Struct used to return info from ft_next() */
84struct ft_atom {
85 u32 tag;
86 const char *name;
87 void *data;
88 u32 size;
89};
90
91/* Set ptrs to current one's info; return addr of next one */
92static char *ft_next(struct ft_cxt *cxt, char *p, struct ft_atom *ret)
93{
94 u32 sz;
95
96 if (p >= cxt->rgn[FT_STRUCT].start + cxt->rgn[FT_STRUCT].size)
97 return NULL;
98
99 ret->tag = be32_to_cpu(*(u32 *) p);
100 p += 4;
101
102 switch (ret->tag) { /* Tag */
103 case OF_DT_BEGIN_NODE:
104 ret->name = p;
105 ret->data = (void *)(p - 4); /* start of node */
106 p += _ALIGN(strlen(p) + 1, 4);
107 break;
108 case OF_DT_PROP:
109 ret->size = sz = be32_to_cpu(*(u32 *) p);
110 ret->name = cxt->str_anchor + be32_to_cpu(*(u32 *) (p + 4));
111 ret->data = (void *)(p + 8);
112 p += 8 + _ALIGN(sz, 4);
113 break;
114 case OF_DT_END_NODE:
115 case OF_DT_NOP:
116 break;
117 case OF_DT_END:
118 default:
119 p = NULL;
120 break;
121 }
122
123 return p;
124}
125
126#define HDR_SIZE _ALIGN(sizeof(struct boot_param_header), 8)
127#define EXPAND_INCR 1024 /* alloc this much extra when expanding */
128
129/* See if the regions are in the standard order and non-overlapping */
130static int ft_ordered(struct ft_cxt *cxt)
131{
132 char *p = (char *)cxt->bph + HDR_SIZE;
133 enum ft_rgn_id r;
134
135 for (r = FT_RSVMAP; r <= FT_STRINGS; ++r) {
136 if (p > cxt->rgn[r].start)
137 return 0;
138 p = cxt->rgn[r].start + cxt->rgn[r].size;
139 }
140 return p <= (char *)cxt->bph + cxt->max_size;
141}
142
143/* Copy the tree to a newly-allocated region and put things in order */
144static int ft_reorder(struct ft_cxt *cxt, int nextra)
145{
146 unsigned long tot;
147 enum ft_rgn_id r;
148 char *p, *pend;
149 int stroff;
150
151 tot = HDR_SIZE + EXPAND_INCR;
152 for (r = FT_RSVMAP; r <= FT_STRINGS; ++r)
153 tot += cxt->rgn[r].size;
154 if (nextra > 0)
155 tot += nextra;
156 tot = _ALIGN(tot, 8);
157
158 if (!cxt->realloc)
159 return 0;
160 p = cxt->realloc(NULL, tot);
161 if (!p)
162 return 0;
163
164 memcpy(p, cxt->bph, sizeof(struct boot_param_header));
165 /* offsets get fixed up later */
166
167 cxt->bph = (struct boot_param_header *)p;
168 cxt->max_size = tot;
169 pend = p + tot;
170 p += HDR_SIZE;
171
172 memcpy(p, cxt->rgn[FT_RSVMAP].start, cxt->rgn[FT_RSVMAP].size);
173 cxt->rgn[FT_RSVMAP].start = p;
174 p += cxt->rgn[FT_RSVMAP].size;
175
176 memcpy(p, cxt->rgn[FT_STRUCT].start, cxt->rgn[FT_STRUCT].size);
177 ft_node_update_after(cxt, cxt->rgn[FT_STRUCT].start,
178 p - cxt->rgn[FT_STRUCT].start);
179 cxt->p += p - cxt->rgn[FT_STRUCT].start;
180 cxt->rgn[FT_STRUCT].start = p;
181
182 p = pend - cxt->rgn[FT_STRINGS].size;
183 memcpy(p, cxt->rgn[FT_STRINGS].start, cxt->rgn[FT_STRINGS].size);
184 stroff = cxt->str_anchor - cxt->rgn[FT_STRINGS].start;
185 cxt->rgn[FT_STRINGS].start = p;
186 cxt->str_anchor = p + stroff;
187
188 cxt->isordered = 1;
189 return 1;
190}
191
192static inline char *prev_end(struct ft_cxt *cxt, enum ft_rgn_id r)
193{
194 if (r > FT_RSVMAP)
195 return cxt->rgn[r - 1].start + cxt->rgn[r - 1].size;
196 return (char *)cxt->bph + HDR_SIZE;
197}
198
199static inline char *next_start(struct ft_cxt *cxt, enum ft_rgn_id r)
200{
201 if (r < FT_STRINGS)
202 return cxt->rgn[r + 1].start;
203 return (char *)cxt->bph + cxt->max_size;
204}
205
206/*
207 * See if we can expand region rgn by nextra bytes by using up
208 * free space after or before the region.
209 */
210static int ft_shuffle(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
211 int nextra)
212{
213 char *p = *pp;
214 char *rgn_start, *rgn_end;
215
216 rgn_start = cxt->rgn[rgn].start;
217 rgn_end = rgn_start + cxt->rgn[rgn].size;
218 if (nextra <= 0 || rgn_end + nextra <= next_start(cxt, rgn)) {
219 /* move following stuff */
220 if (p < rgn_end) {
221 if (nextra < 0)
222 memmove(p, p - nextra, rgn_end - p + nextra);
223 else
224 memmove(p + nextra, p, rgn_end - p);
225 if (rgn == FT_STRUCT)
226 ft_node_update_after(cxt, p, nextra);
227 }
228 cxt->rgn[rgn].size += nextra;
229 if (rgn == FT_STRINGS)
230 /* assumes strings only added at beginning */
231 cxt->str_anchor += nextra;
232 return 1;
233 }
234 if (prev_end(cxt, rgn) <= rgn_start - nextra) {
235 /* move preceding stuff */
236 if (p > rgn_start) {
237 memmove(rgn_start - nextra, rgn_start, p - rgn_start);
238 if (rgn == FT_STRUCT)
239 ft_node_update_before(cxt, p, -nextra);
240 }
241 *p -= nextra;
242 cxt->rgn[rgn].start -= nextra;
243 cxt->rgn[rgn].size += nextra;
244 return 1;
245 }
246 return 0;
247}
248
249static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
250 int nextra)
251{
252 unsigned long size, ssize, tot;
253 char *str, *next;
254 enum ft_rgn_id r;
255
256 if (!cxt->isordered && !ft_reorder(cxt, nextra))
257 return 0;
258 if (ft_shuffle(cxt, pp, rgn, nextra))
259 return 1;
260
261 /* See if there is space after the strings section */
262 ssize = cxt->rgn[FT_STRINGS].size;
263 if (cxt->rgn[FT_STRINGS].start + ssize
264 < (char *)cxt->bph + cxt->max_size) {
265 /* move strings up as far as possible */
266 str = (char *)cxt->bph + cxt->max_size - ssize;
267 cxt->str_anchor += str - cxt->rgn[FT_STRINGS].start;
268 memmove(str, cxt->rgn[FT_STRINGS].start, ssize);
269 cxt->rgn[FT_STRINGS].start = str;
270 /* enough space now? */
271 if (rgn >= FT_STRUCT && ft_shuffle(cxt, pp, rgn, nextra))
272 return 1;
273 }
274
275 /* how much total free space is there following this region? */
276 tot = 0;
277 for (r = rgn; r < FT_STRINGS; ++r) {
278 char *r_end = cxt->rgn[r].start + cxt->rgn[r].size;
279 tot += next_start(cxt, rgn) - r_end;
280 }
281
282 /* cast is to shut gcc up; we know nextra >= 0 */
283 if (tot < (unsigned int)nextra) {
284 /* have to reallocate */
285 char *newp, *new_start;
286 int shift;
287
288 if (!cxt->realloc)
289 return 0;
290 size = _ALIGN(cxt->max_size + (nextra - tot) + EXPAND_INCR, 8);
291 newp = cxt->realloc(cxt->bph, size);
292 if (!newp)
293 return 0;
294 cxt->max_size = size;
295 shift = newp - (char *)cxt->bph;
296
297 if (shift) { /* realloc can return same addr */
298 cxt->bph = (struct boot_param_header *)newp;
299 ft_node_update_after(cxt, cxt->rgn[FT_STRUCT].start,
300 shift);
301 for (r = FT_RSVMAP; r <= FT_STRINGS; ++r) {
302 new_start = cxt->rgn[r].start + shift;
303 cxt->rgn[r].start = new_start;
304 }
305 *pp += shift;
306 cxt->str_anchor += shift;
307 }
308
309 /* move strings up to the end */
310 str = newp + size - ssize;
311 cxt->str_anchor += str - cxt->rgn[FT_STRINGS].start;
312 memmove(str, cxt->rgn[FT_STRINGS].start, ssize);
313 cxt->rgn[FT_STRINGS].start = str;
314
315 if (ft_shuffle(cxt, pp, rgn, nextra))
316 return 1;
317 }
318
319 /* must be FT_RSVMAP and we need to move FT_STRUCT up */
320 if (rgn == FT_RSVMAP) {
321 next = cxt->rgn[FT_RSVMAP].start + cxt->rgn[FT_RSVMAP].size
322 + nextra;
323 ssize = cxt->rgn[FT_STRUCT].size;
324 if (next + ssize >= cxt->rgn[FT_STRINGS].start)
325 return 0; /* "can't happen" */
326 memmove(next, cxt->rgn[FT_STRUCT].start, ssize);
327 ft_node_update_after(cxt, cxt->rgn[FT_STRUCT].start, nextra);
328 cxt->rgn[FT_STRUCT].start = next;
329
330 if (ft_shuffle(cxt, pp, rgn, nextra))
331 return 1;
332 }
333
334 return 0; /* "can't happen" */
335}
336
337static void ft_put_word(struct ft_cxt *cxt, u32 v)
338{
339 *(u32 *) cxt->p = cpu_to_be32(v);
340 cxt->p += 4;
341}
342
343static void ft_put_bin(struct ft_cxt *cxt, const void *data, unsigned int sz)
344{
345 unsigned long sza = _ALIGN(sz, 4);
346
347 /* zero out the alignment gap if necessary */
348 if (sz < sza)
349 *(u32 *) (cxt->p + sza - 4) = 0;
350
351 /* copy in the data */
352 memcpy(cxt->p, data, sz);
353
354 cxt->p += sza;
355}
356
357int ft_begin_node(struct ft_cxt *cxt, const char *name)
358{
359 unsigned long nlen = strlen(name) + 1;
360 unsigned long len = 8 + _ALIGN(nlen, 4);
361
362 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len))
363 return -1;
364 ft_put_word(cxt, OF_DT_BEGIN_NODE);
365 ft_put_bin(cxt, name, strlen(name) + 1);
366 return 0;
367}
368
369void ft_end_node(struct ft_cxt *cxt)
370{
371 ft_put_word(cxt, OF_DT_END_NODE);
372}
373
374void ft_nop(struct ft_cxt *cxt)
375{
376 if (ft_make_space(cxt, &cxt->p, FT_STRUCT, 4))
377 ft_put_word(cxt, OF_DT_NOP);
378}
379
380#define NO_STRING 0x7fffffff
381
382static int lookup_string(struct ft_cxt *cxt, const char *name)
383{
384 char *p, *end;
385
386 p = cxt->rgn[FT_STRINGS].start;
387 end = p + cxt->rgn[FT_STRINGS].size;
388 while (p < end) {
389 if (strcmp(p, (char *)name) == 0)
390 return p - cxt->str_anchor;
391 p += strlen(p) + 1;
392 }
393
394 return NO_STRING;
395}
396
397/* lookup string and insert if not found */
398static int map_string(struct ft_cxt *cxt, const char *name)
399{
400 int off;
401 char *p;
402
403 off = lookup_string(cxt, name);
404 if (off != NO_STRING)
405 return off;
406 p = cxt->rgn[FT_STRINGS].start;
407 if (!ft_make_space(cxt, &p, FT_STRINGS, strlen(name) + 1))
408 return NO_STRING;
409 strcpy(p, name);
410 return p - cxt->str_anchor;
411}
412
413int ft_prop(struct ft_cxt *cxt, const char *name, const void *data,
414 unsigned int sz)
415{
416 int off, len;
417
418 off = lookup_string(cxt, name);
419 if (off == NO_STRING)
420 return -1;
421
422 len = 12 + _ALIGN(sz, 4);
423 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len))
424 return -1;
425
426 ft_put_word(cxt, OF_DT_PROP);
427 ft_put_word(cxt, sz);
428 ft_put_word(cxt, off);
429 ft_put_bin(cxt, data, sz);
430 return 0;
431}
432
433int ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str)
434{
435 return ft_prop(cxt, name, str, strlen(str) + 1);
436}
437
438int ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val)
439{
440 u32 v = cpu_to_be32((u32) val);
441
442 return ft_prop(cxt, name, &v, 4);
443}
444
445/* Calculate the size of the reserved map */
446static unsigned long rsvmap_size(struct ft_cxt *cxt)
447{
448 struct ft_reserve *res;
449
450 res = (struct ft_reserve *)cxt->rgn[FT_RSVMAP].start;
451 while (res->start || res->len)
452 ++res;
453 return (char *)(res + 1) - cxt->rgn[FT_RSVMAP].start;
454}
455
456/* Calculate the size of the struct region by stepping through it */
457static unsigned long struct_size(struct ft_cxt *cxt)
458{
459 char *p = cxt->rgn[FT_STRUCT].start;
460 char *next;
461 struct ft_atom atom;
462
463 /* make check in ft_next happy */
464 if (cxt->rgn[FT_STRUCT].size == 0)
465 cxt->rgn[FT_STRUCT].size = 0xfffffffful - (unsigned long)p;
466
467 while ((next = ft_next(cxt, p, &atom)) != NULL)
468 p = next;
469 return p + 4 - cxt->rgn[FT_STRUCT].start;
470}
471
472/* add `adj' on to all string offset values in the struct area */
473static void adjust_string_offsets(struct ft_cxt *cxt, int adj)
474{
475 char *p = cxt->rgn[FT_STRUCT].start;
476 char *next;
477 struct ft_atom atom;
478 int off;
479
480 while ((next = ft_next(cxt, p, &atom)) != NULL) {
481 if (atom.tag == OF_DT_PROP) {
482 off = be32_to_cpu(*(u32 *) (p + 8));
483 *(u32 *) (p + 8) = cpu_to_be32(off + adj);
484 }
485 p = next;
486 }
487}
488
489/* start construction of the flat OF tree from scratch */
490void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size,
491 void *(*realloc_fn) (void *, unsigned long))
492{
493 struct boot_param_header *bph = blob;
494 char *p;
495 struct ft_reserve *pres;
496
497 /* clear the cxt */
498 memset(cxt, 0, sizeof(*cxt));
499
500 cxt->bph = bph;
501 cxt->max_size = max_size;
502 cxt->realloc = realloc_fn;
503 cxt->isordered = 1;
504
505 /* zero everything in the header area */
506 memset(bph, 0, sizeof(*bph));
507
508 bph->magic = cpu_to_be32(OF_DT_HEADER);
509 bph->version = cpu_to_be32(0x10);
510 bph->last_comp_version = cpu_to_be32(0x10);
511
512 /* start pointers */
513 cxt->rgn[FT_RSVMAP].start = p = blob + HDR_SIZE;
514 cxt->rgn[FT_RSVMAP].size = sizeof(struct ft_reserve);
515 pres = (struct ft_reserve *)p;
516 cxt->rgn[FT_STRUCT].start = p += sizeof(struct ft_reserve);
517 cxt->rgn[FT_STRUCT].size = 4;
518 cxt->rgn[FT_STRINGS].start = blob + max_size;
519 cxt->rgn[FT_STRINGS].size = 0;
520
521 /* init rsvmap and struct */
522 pres->start = 0;
523 pres->len = 0;
524 *(u32 *) p = cpu_to_be32(OF_DT_END);
525
526 cxt->str_anchor = blob;
527}
528
529/* open up an existing blob to be examined or modified */
530int ft_open(struct ft_cxt *cxt, void *blob, unsigned int max_size,
531 unsigned int max_find_device,
532 void *(*realloc_fn) (void *, unsigned long))
533{
534 struct boot_param_header *bph = blob;
535
536 /* can't cope with version < 16 */
537 if (be32_to_cpu(bph->version) < 16)
538 return -1;
539
540 /* clear the cxt */
541 memset(cxt, 0, sizeof(*cxt));
542
543 /* alloc node_tbl to track node ptrs returned by ft_find_device */
544 ++max_find_device;
545 cxt->node_tbl = realloc_fn(NULL, max_find_device * sizeof(char *));
546 if (!cxt->node_tbl)
547 return -1;
548 memset(cxt->node_tbl, 0, max_find_device * sizeof(char *));
549 cxt->node_max = max_find_device;
550 cxt->nodes_used = 1; /* don't use idx 0 b/c looks like NULL */
551
552 cxt->bph = bph;
553 cxt->max_size = max_size;
554 cxt->realloc = realloc_fn;
555
556 cxt->rgn[FT_RSVMAP].start = blob + be32_to_cpu(bph->off_mem_rsvmap);
557 cxt->rgn[FT_RSVMAP].size = rsvmap_size(cxt);
558 cxt->rgn[FT_STRUCT].start = blob + be32_to_cpu(bph->off_dt_struct);
559 cxt->rgn[FT_STRUCT].size = struct_size(cxt);
560 cxt->rgn[FT_STRINGS].start = blob + be32_to_cpu(bph->off_dt_strings);
561 cxt->rgn[FT_STRINGS].size = be32_to_cpu(bph->dt_strings_size);
562 /* Leave as '0' to force first ft_make_space call to do a ft_reorder
563 * and move dt to an area allocated by realloc.
564 cxt->isordered = ft_ordered(cxt);
565 */
566
567 cxt->p = cxt->rgn[FT_STRUCT].start;
568 cxt->str_anchor = cxt->rgn[FT_STRINGS].start;
569
570 return 0;
571}
572
573/* add a reserver physical area to the rsvmap */
574int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
575{
576 char *p;
577 struct ft_reserve *pres;
578
579 p = cxt->rgn[FT_RSVMAP].start + cxt->rgn[FT_RSVMAP].size
580 - sizeof(struct ft_reserve);
581 if (!ft_make_space(cxt, &p, FT_RSVMAP, sizeof(struct ft_reserve)))
582 return -1;
583
584 pres = (struct ft_reserve *)p;
585 pres->start = cpu_to_be64(physaddr);
586 pres->len = cpu_to_be64(size);
587
588 return 0;
589}
590
591void ft_begin_tree(struct ft_cxt *cxt)
592{
593 cxt->p = cxt->rgn[FT_STRUCT].start;
594}
595
596void ft_end_tree(struct ft_cxt *cxt)
597{
598 struct boot_param_header *bph = cxt->bph;
599 char *p, *oldstr, *str, *endp;
600 unsigned long ssize;
601 int adj;
602
603 if (!cxt->isordered)
604 return; /* we haven't touched anything */
605
606 /* adjust string offsets */
607 oldstr = cxt->rgn[FT_STRINGS].start;
608 adj = cxt->str_anchor - oldstr;
609 if (adj)
610 adjust_string_offsets(cxt, adj);
611
612 /* make strings end on 8-byte boundary */
613 ssize = cxt->rgn[FT_STRINGS].size;
614 endp = (char *)_ALIGN((unsigned long)cxt->rgn[FT_STRUCT].start
615 + cxt->rgn[FT_STRUCT].size + ssize, 8);
616 str = endp - ssize;
617
618 /* move strings down to end of structs */
619 memmove(str, oldstr, ssize);
620 cxt->str_anchor = str;
621 cxt->rgn[FT_STRINGS].start = str;
622
623 /* fill in header fields */
624 p = (char *)bph;
625 bph->totalsize = cpu_to_be32(endp - p);
626 bph->off_mem_rsvmap = cpu_to_be32(cxt->rgn[FT_RSVMAP].start - p);
627 bph->off_dt_struct = cpu_to_be32(cxt->rgn[FT_STRUCT].start - p);
628 bph->off_dt_strings = cpu_to_be32(cxt->rgn[FT_STRINGS].start - p);
629 bph->dt_strings_size = cpu_to_be32(ssize);
630}
631
632void *ft_find_device(struct ft_cxt *cxt, const char *srch_path)
633{
634 char *node;
635
636 /* require absolute path */
637 if (srch_path[0] != '/')
638 return NULL;
639 node = ft_find_descendent(cxt, cxt->rgn[FT_STRUCT].start, srch_path);
640 return ft_node_add(cxt, node);
641}
642
643void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
644{
645 struct ft_atom atom;
646 char *p;
647 const char *cp, *q;
648 int cl;
649 int depth = -1;
650 int dmatch = 0;
651 const char *path_comp[FT_MAX_DEPTH];
652
653 cp = srch_path;
654 cl = 0;
655 p = top;
656
657 while ((p = ft_next(cxt, p, &atom)) != NULL) {
658 switch (atom.tag) {
659 case OF_DT_BEGIN_NODE:
660 ++depth;
661 if (depth != dmatch)
662 break;
663 cxt->genealogy[depth] = atom.data;
664 cxt->genealogy[depth + 1] = NULL;
665 if (depth && !(strncmp(atom.name, cp, cl) == 0
666 && (atom.name[cl] == '/'
667 || atom.name[cl] == '\0'
668 || atom.name[cl] == '@')))
669 break;
670 path_comp[dmatch] = cp;
671 /* it matches so far, advance to next path component */
672 cp += cl;
673 /* skip slashes */
674 while (*cp == '/')
675 ++cp;
676 /* we're done if this is the end of the string */
677 if (*cp == 0)
678 return atom.data;
679 /* look for end of this component */
680 q = strchr(cp, '/');
681 if (q)
682 cl = q - cp;
683 else
684 cl = strlen(cp);
685 ++dmatch;
686 break;
687 case OF_DT_END_NODE:
688 if (depth == 0)
689 return NULL;
690 if (dmatch > depth) {
691 --dmatch;
692 cl = cp - path_comp[dmatch] - 1;
693 cp = path_comp[dmatch];
694 while (cl > 0 && cp[cl - 1] == '/')
695 --cl;
696 }
697 --depth;
698 break;
699 }
700 }
701 return NULL;
702}
703
704void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
705{
706 void *node;
707 int d;
708 struct ft_atom atom;
709 char *p;
710
711 node = ft_node_ph2node(cxt, phandle);
712 if (node == NULL)
713 return NULL;
714
715 for (d = 0; cxt->genealogy[d] != NULL; ++d)
716 if (cxt->genealogy[d] == node)
717 return cxt->genealogy[d > 0 ? d - 1 : 0];
718
719 /* have to do it the hard way... */
720 p = cxt->rgn[FT_STRUCT].start;
721 d = 0;
722 while ((p = ft_next(cxt, p, &atom)) != NULL) {
723 switch (atom.tag) {
724 case OF_DT_BEGIN_NODE:
725 cxt->genealogy[d] = atom.data;
726 if (node == atom.data) {
727 /* found it */
728 cxt->genealogy[d + 1] = NULL;
729 return d > 0 ? cxt->genealogy[d - 1] : node;
730 }
731 ++d;
732 break;
733 case OF_DT_END_NODE:
734 --d;
735 break;
736 }
737 }
738 return NULL;
739}
740
741int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
742 void *buf, const unsigned int buflen)
743{
744 struct ft_atom atom;
745 void *node;
746 char *p;
747 int depth;
748 unsigned int size;
749
750 node = ft_node_ph2node(cxt, phandle);
751 if (node == NULL)
752 return -1;
753
754 depth = 0;
755 p = (char *)node;
756
757 while ((p = ft_next(cxt, p, &atom)) != NULL) {
758 switch (atom.tag) {
759 case OF_DT_BEGIN_NODE:
760 ++depth;
761 break;
762 case OF_DT_PROP:
763 if ((depth != 1) || strcmp(atom.name, propname))
764 break;
765 size = min(atom.size, buflen);
766 memcpy(buf, atom.data, size);
767 return atom.size;
768 case OF_DT_END_NODE:
769 if (--depth <= 0)
770 return -1;
771 }
772 }
773 return -1;
774}
775
776int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
777 const void *buf, const unsigned int buflen)
778{
779 struct ft_atom atom;
780 void *node;
781 char *p, *next;
782 int nextra, depth;
783
784 node = ft_node_ph2node(cxt, phandle);
785 if (node == NULL)
786 return -1;
787
788 depth = 0;
789 p = node;
790
791 while ((next = ft_next(cxt, p, &atom)) != NULL) {
792 switch (atom.tag) {
793 case OF_DT_BEGIN_NODE:
794 ++depth;
795 break;
796 case OF_DT_END_NODE:
797 if (--depth > 0)
798 break;
799 /* haven't found the property, insert here */
800 cxt->p = p;
801 return ft_prop(cxt, propname, buf, buflen);
802 case OF_DT_PROP:
803 if ((depth != 1) || strcmp(atom.name, propname))
804 break;
805 /* found an existing property, overwrite it */
806 nextra = _ALIGN(buflen, 4) - _ALIGN(atom.size, 4);
807 cxt->p = atom.data;
808 if (nextra && !ft_make_space(cxt, &cxt->p, FT_STRUCT,
809 nextra))
810 return -1;
811 *(u32 *) (cxt->p - 8) = cpu_to_be32(buflen);
812 ft_put_bin(cxt, buf, buflen);
813 return 0;
814 }
815 p = next;
816 }
817 return -1;
818}
819
820int ft_del_prop(struct ft_cxt *cxt, const void *phandle, const char *propname)
821{
822 struct ft_atom atom;
823 void *node;
824 char *p, *next;
825 int size;
826
827 node = ft_node_ph2node(cxt, phandle);
828 if (node == NULL)
829 return -1;
830
831 p = node;
832 while ((next = ft_next(cxt, p, &atom)) != NULL) {
833 switch (atom.tag) {
834 case OF_DT_BEGIN_NODE:
835 case OF_DT_END_NODE:
836 return -1;
837 case OF_DT_PROP:
838 if (strcmp(atom.name, propname))
839 break;
840 /* found the property, remove it */
841 size = 12 + -_ALIGN(atom.size, 4);
842 cxt->p = p;
843 if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, -size))
844 return -1;
845 return 0;
846 }
847 p = next;
848 }
849 return -1;
850}
851
852void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *path)
853{
854 struct ft_atom atom;
855 char *p, *next;
856 int depth = 0;
857
858 p = cxt->rgn[FT_STRUCT].start;
859 while ((next = ft_next(cxt, p, &atom)) != NULL) {
860 switch (atom.tag) {
861 case OF_DT_BEGIN_NODE:
862 ++depth;
863 if (depth == 1 && strcmp(atom.name, path) == 0)
864 /* duplicate node path, return error */
865 return NULL;
866 break;
867 case OF_DT_END_NODE:
868 --depth;
869 if (depth > 0)
870 break;
871 /* end of node, insert here */
872 cxt->p = p;
873 ft_begin_node(cxt, path);
874 ft_end_node(cxt);
875 return p;
876 }
877 p = next;
878 }
879 return NULL;
880}
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index 761c8dc84008..b9cd9f61f351 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -17,7 +17,7 @@
17#ifndef FLATDEVTREE_H 17#ifndef FLATDEVTREE_H
18#define FLATDEVTREE_H 18#define FLATDEVTREE_H
19 19
20#include "types.h" 20#include "flatdevtree_env.h"
21 21
22/* Definitions used by the flattened device tree */ 22/* Definitions used by the flattened device tree */
23#define OF_DT_HEADER 0xd00dfeed /* marker */ 23#define OF_DT_HEADER 0xd00dfeed /* marker */
@@ -43,4 +43,64 @@ struct boot_param_header {
43 u32 dt_strings_size; /* size of the DT strings block */ 43 u32 dt_strings_size; /* size of the DT strings block */
44}; 44};
45 45
46struct ft_reserve {
47 u64 start;
48 u64 len;
49};
50
51struct ft_region {
52 char *start;
53 unsigned long size;
54};
55
56enum ft_rgn_id {
57 FT_RSVMAP,
58 FT_STRUCT,
59 FT_STRINGS,
60 FT_N_REGION
61};
62
63#define FT_MAX_DEPTH 50
64
65struct ft_cxt {
66 struct boot_param_header *bph;
67 int max_size; /* maximum size of tree */
68 int isordered; /* everything in standard order */
69 void *(*realloc)(void *, unsigned long);
70 char *str_anchor;
71 char *p; /* current insertion point in structs */
72 struct ft_region rgn[FT_N_REGION];
73 void *genealogy[FT_MAX_DEPTH+1];
74 char **node_tbl;
75 unsigned int node_max;
76 unsigned int nodes_used;
77};
78
79int ft_begin_node(struct ft_cxt *cxt, const char *name);
80void ft_end_node(struct ft_cxt *cxt);
81
82void ft_begin_tree(struct ft_cxt *cxt);
83void ft_end_tree(struct ft_cxt *cxt);
84
85void ft_nop(struct ft_cxt *cxt);
86int ft_prop(struct ft_cxt *cxt, const char *name,
87 const void *data, unsigned int sz);
88int ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str);
89int ft_prop_int(struct ft_cxt *cxt, const char *name, unsigned int val);
90void ft_begin(struct ft_cxt *cxt, void *blob, unsigned int max_size,
91 void *(*realloc_fn)(void *, unsigned long));
92int ft_open(struct ft_cxt *cxt, void *blob, unsigned int max_size,
93 unsigned int max_find_device,
94 void *(*realloc_fn)(void *, unsigned long));
95int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
96
97void ft_dump_blob(const void *bphp);
98void ft_merge_blob(struct ft_cxt *cxt, void *blob);
99void *ft_find_device(struct ft_cxt *cxt, const char *srch_path);
100void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
101int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
102 void *buf, const unsigned int buflen);
103int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
104 const void *buf, const unsigned int buflen);
105
46#endif /* FLATDEVTREE_H */ 106#endif /* FLATDEVTREE_H */
diff --git a/arch/powerpc/boot/flatdevtree_env.h b/arch/powerpc/boot/flatdevtree_env.h
new file mode 100644
index 000000000000..83bc1c718836
--- /dev/null
+++ b/arch/powerpc/boot/flatdevtree_env.h
@@ -0,0 +1,47 @@
1/*
2 * This file adds the header file glue so that the shared files
3 * flatdevicetree.[ch] can compile and work in the powerpc bootwrapper.
4 *
5 * strncmp & strchr copied from <file:lib/strings.c>
6 * Copyright (C) 1991, 1992 Linus Torvalds
7 *
8 * Maintained by: Mark A. Greer <mgreer@mvista.com>
9 */
10#ifndef _PPC_BOOT_FLATDEVTREE_ENV_H_
11#define _PPC_BOOT_FLATDEVTREE_ENV_H_
12
13#include <stdarg.h>
14#include <stddef.h>
15#include "types.h"
16#include "string.h"
17#include "stdio.h"
18#include "ops.h"
19
20#define be16_to_cpu(x) (x)
21#define cpu_to_be16(x) (x)
22#define be32_to_cpu(x) (x)
23#define cpu_to_be32(x) (x)
24#define be64_to_cpu(x) (x)
25#define cpu_to_be64(x) (x)
26
27static inline int strncmp(const char *cs, const char *ct, size_t count)
28{
29 signed char __res = 0;
30
31 while (count) {
32 if ((__res = *cs - *ct++) != 0 || !*cs++)
33 break;
34 count--;
35 }
36 return __res;
37}
38
39static inline char *strchr(const char *s, int c)
40{
41 for (; *s != (char)c; ++s)
42 if (*s == '\0')
43 return NULL;
44 return (char *)s;
45}
46
47#endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
new file mode 100644
index 000000000000..04da38fa477f
--- /dev/null
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -0,0 +1,51 @@
1/*
2 * This file does the necessary interface mapping between the bootwrapper
3 * device tree operations and the interface provided by shared source
4 * files flatdevicetree.[ch].
5 *
6 * Author: Mark A. Greer <mgreer@mvista.com>
7 *
8 * 2006 (c) MontaVista Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
12 */
13#include <stddef.h>
14#include "flatdevtree.h"
15#include "ops.h"
16
17static struct ft_cxt cxt;
18
19static void *ft_finddevice(const char *name)
20{
21 return ft_find_device(&cxt, name);
22}
23
24static int ft_getprop(const void *phandle, const char *propname, void *buf,
25 const int buflen)
26{
27 return ft_get_prop(&cxt, phandle, propname, buf, buflen);
28}
29
30static int ft_setprop(const void *phandle, const char *propname,
31 const void *buf, const int buflen)
32{
33 return ft_set_prop(&cxt, phandle, propname, buf, buflen);
34}
35
36static unsigned long ft_finalize(void)
37{
38 ft_end_tree(&cxt);
39 return (unsigned long)cxt.bph;
40}
41
42int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
43{
44 dt_ops.finddevice = ft_finddevice;
45 dt_ops.getprop = ft_getprop;
46 dt_ops.setprop = ft_setprop;
47 dt_ops.finalize = ft_finalize;
48
49 return ft_open(&cxt, dt_blob, max_size, max_find_device,
50 platform_ops.realloc);
51}
diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
new file mode 100644
index 000000000000..32974ed49e02
--- /dev/null
+++ b/arch/powerpc/boot/io.h
@@ -0,0 +1,53 @@
1#ifndef _IO_H
2#define __IO_H
3/*
4 * Low-level I/O routines.
5 *
6 * Copied from <file:include/asm-powerpc/io.h> (which has no copyright)
7 */
8static inline int in_8(const volatile unsigned char *addr)
9{
10 int ret;
11
12 __asm__ __volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync"
13 : "=r" (ret) : "m" (*addr));
14 return ret;
15}
16
17static inline void out_8(volatile unsigned char *addr, int val)
18{
19 __asm__ __volatile__("stb%U0%X0 %1,%0; sync"
20 : "=m" (*addr) : "r" (val));
21}
22
23static inline unsigned in_le32(const volatile unsigned *addr)
24{
25 unsigned ret;
26
27 __asm__ __volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync"
28 : "=r" (ret) : "r" (addr), "m" (*addr));
29 return ret;
30}
31
32static inline unsigned in_be32(const volatile unsigned *addr)
33{
34 unsigned ret;
35
36 __asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync"
37 : "=r" (ret) : "m" (*addr));
38 return ret;
39}
40
41static inline void out_le32(volatile unsigned *addr, int val)
42{
43 __asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr)
44 : "r" (val), "r" (addr));
45}
46
47static inline void out_be32(volatile unsigned *addr, int val)
48{
49 __asm__ __volatile__("stw%U0%X0 %1,%0; sync"
50 : "=m" (*addr) : "r" (val));
51}
52
53#endif /* _IO_H */
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index d719bb9333d1..6f6b50d238b6 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -27,6 +27,8 @@ extern char _vmlinux_start[];
27extern char _vmlinux_end[]; 27extern char _vmlinux_end[];
28extern char _initrd_start[]; 28extern char _initrd_start[];
29extern char _initrd_end[]; 29extern char _initrd_end[];
30extern char _dtb_start[];
31extern char _dtb_end[];
30 32
31struct addr_range { 33struct addr_range {
32 unsigned long addr; 34 unsigned long addr;
@@ -167,7 +169,7 @@ static int is_elf32(void *hdr)
167 return 1; 169 return 1;
168} 170}
169 171
170static void prep_kernel(unsigned long *a1, unsigned long *a2) 172static void prep_kernel(unsigned long a1, unsigned long a2)
171{ 173{
172 int len; 174 int len;
173 175
@@ -203,11 +205,14 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
203 } 205 }
204 206
205 /* 207 /*
206 * Now we try to alloc memory for the initrd (and copy it there) 208 * Now find the initrd
209 *
210 * First see if we have an image attached to us. If so
211 * allocate memory for it and copy it there.
207 */ 212 */
208 initrd.size = (unsigned long)(_initrd_end - _initrd_start); 213 initrd.size = (unsigned long)(_initrd_end - _initrd_start);
209 initrd.memsize = initrd.size; 214 initrd.memsize = initrd.size;
210 if ( initrd.size > 0 ) { 215 if (initrd.size > 0) {
211 printf("Allocating 0x%lx bytes for initrd ...\n\r", 216 printf("Allocating 0x%lx bytes for initrd ...\n\r",
212 initrd.size); 217 initrd.size);
213 initrd.addr = (unsigned long)malloc((u32)initrd.size); 218 initrd.addr = (unsigned long)malloc((u32)initrd.size);
@@ -216,8 +221,6 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
216 "ramdisk !\n\r"); 221 "ramdisk !\n\r");
217 exit(); 222 exit();
218 } 223 }
219 *a1 = initrd.addr;
220 *a2 = initrd.size;
221 printf("initial ramdisk moving 0x%lx <- 0x%lx " 224 printf("initial ramdisk moving 0x%lx <- 0x%lx "
222 "(0x%lx bytes)\n\r", initrd.addr, 225 "(0x%lx bytes)\n\r", initrd.addr,
223 (unsigned long)_initrd_start, initrd.size); 226 (unsigned long)_initrd_start, initrd.size);
@@ -225,6 +228,12 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
225 initrd.size); 228 initrd.size);
226 printf("initrd head: 0x%lx\n\r", 229 printf("initrd head: 0x%lx\n\r",
227 *((unsigned long *)initrd.addr)); 230 *((unsigned long *)initrd.addr));
231 } else if (a2 != 0) {
232 /* Otherwise, see if yaboot or another loader gave us an initrd */
233 initrd.addr = a1;
234 initrd.memsize = initrd.size = a2;
235 printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
236 initrd.addr, initrd.size);
228 } 237 }
229 238
230 /* Eventually gunzip the kernel */ 239 /* Eventually gunzip the kernel */
@@ -250,10 +259,6 @@ static void prep_kernel(unsigned long *a1, unsigned long *a2)
250 flush_cache((void *)vmlinux.addr, vmlinux.size); 259 flush_cache((void *)vmlinux.addr, vmlinux.size);
251} 260}
252 261
253void __attribute__ ((weak)) ft_init(void *dt_blob)
254{
255}
256
257/* A buffer that may be edited by tools operating on a zImage binary so as to 262/* A buffer that may be edited by tools operating on a zImage binary so as to
258 * edit the command line passed to vmlinux (by setting /chosen/bootargs). 263 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
259 * The buffer is put in it's own section so that tools may locate it easier. 264 * The buffer is put in it's own section so that tools may locate it easier.
@@ -285,36 +290,22 @@ static void set_cmdline(char *buf)
285 setprop(devp, "bootargs", buf, strlen(buf) + 1); 290 setprop(devp, "bootargs", buf, strlen(buf) + 1);
286} 291}
287 292
288/* Section where ft can be tacked on after zImage is built */
289union blobspace {
290 struct boot_param_header hdr;
291 char space[8*1024];
292} dt_blob __attribute__((__section__("__builtin_ft")));
293
294struct platform_ops platform_ops; 293struct platform_ops platform_ops;
295struct dt_ops dt_ops; 294struct dt_ops dt_ops;
296struct console_ops console_ops; 295struct console_ops console_ops;
297 296
298void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) 297void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
299{ 298{
300 int have_dt = 0;
301 kernel_entry_t kentry; 299 kernel_entry_t kentry;
302 char cmdline[COMMAND_LINE_SIZE]; 300 char cmdline[COMMAND_LINE_SIZE];
301 unsigned long ft_addr = 0;
303 302
304 memset(__bss_start, 0, _end - __bss_start); 303 memset(__bss_start, 0, _end - __bss_start);
305 memset(&platform_ops, 0, sizeof(platform_ops)); 304 memset(&platform_ops, 0, sizeof(platform_ops));
306 memset(&dt_ops, 0, sizeof(dt_ops)); 305 memset(&dt_ops, 0, sizeof(dt_ops));
307 memset(&console_ops, 0, sizeof(console_ops)); 306 memset(&console_ops, 0, sizeof(console_ops));
308 307
309 /* Override the dt_ops and device tree if there was an flat dev 308 if (platform_init(promptr, _dtb_start, _dtb_end))
310 * tree attached to the zImage.
311 */
312 if (dt_blob.hdr.magic == OF_DT_HEADER) {
313 have_dt = 1;
314 ft_init(&dt_blob);
315 }
316
317 if (platform_init(promptr))
318 exit(); 309 exit();
319 if (console_ops.open && (console_ops.open() < 0)) 310 if (console_ops.open && (console_ops.open() < 0))
320 exit(); 311 exit();
@@ -324,7 +315,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
324 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", 315 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
325 _start, sp); 316 _start, sp);
326 317
327 prep_kernel(&a1, &a2); 318 prep_kernel(a1, a2);
328 319
329 /* If cmdline came from zimage wrapper or if we can edit the one 320 /* If cmdline came from zimage wrapper or if we can edit the one
330 * in the dt, print it out and edit it, if possible. 321 * in the dt, print it out and edit it, if possible.
@@ -338,15 +329,23 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
338 set_cmdline(cmdline); 329 set_cmdline(cmdline);
339 } 330 }
340 331
332 printf("Finalizing device tree...");
333 if (dt_ops.finalize)
334 ft_addr = dt_ops.finalize();
335 if (ft_addr)
336 printf(" flat tree at 0x%lx\n\r", ft_addr);
337 else
338 printf(" using OF tree (promptr=%p)\n\r", promptr);
339
341 if (console_ops.close) 340 if (console_ops.close)
342 console_ops.close(); 341 console_ops.close();
343 342
344 kentry = (kernel_entry_t) vmlinux.addr; 343 kentry = (kernel_entry_t) vmlinux.addr;
345 if (have_dt) 344 if (ft_addr)
346 kentry(dt_ops.ft_addr(), 0, NULL); 345 kentry(ft_addr, 0, NULL);
347 else 346 else
348 /* XXX initrd addr/size should be passed in properties */ 347 /* XXX initrd addr/size should be passed in properties */
349 kentry(a1, a2, promptr); 348 kentry(initrd.addr, initrd.size, promptr);
350 349
351 /* console closed so printf below may not work */ 350 /* console closed so printf below may not work */
352 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r"); 351 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");
diff --git a/arch/powerpc/boot/mktree.c b/arch/powerpc/boot/mktree.c
new file mode 100644
index 000000000000..4cb892993651
--- /dev/null
+++ b/arch/powerpc/boot/mktree.c
@@ -0,0 +1,152 @@
1/*
2 * Makes a tree bootable image for IBM Evaluation boards.
3 * Basically, just take a zImage, skip the ELF header, and stuff
4 * a 32 byte header on the front.
5 *
6 * We use htonl, which is a network macro, to make sure we're doing
7 * The Right Thing on an LE machine. It's non-obvious, but it should
8 * work on anything BSD'ish.
9 */
10
11#include <fcntl.h>
12#include <stdio.h>
13#include <stdlib.h>
14#include <string.h>
15#include <sys/stat.h>
16#include <unistd.h>
17#include <netinet/in.h>
18#ifdef __sun__
19#include <inttypes.h>
20#else
21#include <stdint.h>
22#endif
23
24/* This gets tacked on the front of the image. There are also a few
25 * bytes allocated after the _start label used by the boot rom (see
26 * head.S for details).
27 */
28typedef struct boot_block {
29 uint32_t bb_magic; /* 0x0052504F */
30 uint32_t bb_dest; /* Target address of the image */
31 uint32_t bb_num_512blocks; /* Size, rounded-up, in 512 byte blks */
32 uint32_t bb_debug_flag; /* Run debugger or image after load */
33 uint32_t bb_entry_point; /* The image address to start */
34 uint32_t bb_checksum; /* 32 bit checksum including header */
35 uint32_t reserved[2];
36} boot_block_t;
37
38#define IMGBLK 512
39char tmpbuf[IMGBLK];
40
41int main(int argc, char *argv[])
42{
43 int in_fd, out_fd;
44 int nblks, i;
45 uint cksum, *cp;
46 struct stat st;
47 boot_block_t bt;
48
49 if (argc < 3) {
50 fprintf(stderr, "usage: %s <zImage-file> <boot-image> [entry-point]\n",argv[0]);
51 exit(1);
52 }
53
54 if (stat(argv[1], &st) < 0) {
55 perror("stat");
56 exit(2);
57 }
58
59 nblks = (st.st_size + IMGBLK) / IMGBLK;
60
61 bt.bb_magic = htonl(0x0052504F);
62
63 /* If we have the optional entry point parameter, use it */
64 if (argc == 4)
65 bt.bb_dest = bt.bb_entry_point = htonl(strtoul(argv[3], NULL, 0));
66 else
67 bt.bb_dest = bt.bb_entry_point = htonl(0x500000);
68
69 /* We know these from the linker command.
70 * ...and then move it up into memory a little more so the
71 * relocation can happen.
72 */
73 bt.bb_num_512blocks = htonl(nblks);
74 bt.bb_debug_flag = 0;
75
76 bt.bb_checksum = 0;
77
78 /* To be neat and tidy :-).
79 */
80 bt.reserved[0] = 0;
81 bt.reserved[1] = 0;
82
83 if ((in_fd = open(argv[1], O_RDONLY)) < 0) {
84 perror("zImage open");
85 exit(3);
86 }
87
88 if ((out_fd = open(argv[2], (O_RDWR | O_CREAT | O_TRUNC), 0666)) < 0) {
89 perror("bootfile open");
90 exit(3);
91 }
92
93 cksum = 0;
94 cp = (void *)&bt;
95 for (i=0; i<sizeof(bt)/sizeof(uint); i++)
96 cksum += *cp++;
97
98 /* Assume zImage is an ELF file, and skip the 64K header.
99 */
100 if (read(in_fd, tmpbuf, IMGBLK) != IMGBLK) {
101 fprintf(stderr, "%s is too small to be an ELF image\n",
102 argv[1]);
103 exit(4);
104 }
105
106 if ((*(uint *)tmpbuf) != htonl(0x7f454c46)) {
107 fprintf(stderr, "%s is not an ELF image\n", argv[1]);
108 exit(4);
109 }
110
111 if (lseek(in_fd, (64 * 1024), SEEK_SET) < 0) {
112 fprintf(stderr, "%s failed to seek in ELF image\n", argv[1]);
113 exit(4);
114 }
115
116 nblks -= (64 * 1024) / IMGBLK;
117
118 /* And away we go......
119 */
120 if (write(out_fd, &bt, sizeof(bt)) != sizeof(bt)) {
121 perror("boot-image write");
122 exit(5);
123 }
124
125 while (nblks-- > 0) {
126 if (read(in_fd, tmpbuf, IMGBLK) < 0) {
127 perror("zImage read");
128 exit(5);
129 }
130 cp = (uint *)tmpbuf;
131 for (i=0; i<sizeof(tmpbuf)/sizeof(uint); i++)
132 cksum += *cp++;
133 if (write(out_fd, tmpbuf, sizeof(tmpbuf)) != sizeof(tmpbuf)) {
134 perror("boot-image write");
135 exit(5);
136 }
137 }
138
139 /* rewrite the header with the computed checksum.
140 */
141 bt.bb_checksum = htonl(cksum);
142 if (lseek(out_fd, 0, SEEK_SET) < 0) {
143 perror("rewrite seek");
144 exit(1);
145 }
146 if (write(out_fd, &bt, sizeof(bt)) != sizeof(bt)) {
147 perror("boot-image rewrite");
148 exit(1);
149 }
150
151 exit(0);
152}
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
new file mode 100644
index 000000000000..1ffe72e35cdc
--- /dev/null
+++ b/arch/powerpc/boot/ns16550.c
@@ -0,0 +1,74 @@
1/*
2 * 16550 serial console support.
3 *
4 * Original copied from <file:arch/ppc/boot/common/ns16550.c>
5 * (which had no copyright)
6 * Modifications: 2006 (c) MontaVista Software, Inc.
7 *
8 * Modified by: Mark A. Greer <mgreer@mvista.com>
9 */
10#include <stdarg.h>
11#include <stddef.h>
12#include "types.h"
13#include "string.h"
14#include "stdio.h"
15#include "io.h"
16#include "ops.h"
17
18#define UART_DLL 0 /* Out: Divisor Latch Low */
19#define UART_DLM 1 /* Out: Divisor Latch High */
20#define UART_FCR 2 /* Out: FIFO Control Register */
21#define UART_LCR 3 /* Out: Line Control Register */
22#define UART_MCR 4 /* Out: Modem Control Register */
23#define UART_LSR 5 /* In: Line Status Register */
24#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
25#define UART_LSR_DR 0x01 /* Receiver data ready */
26#define UART_MSR 6 /* In: Modem Status Register */
27#define UART_SCR 7 /* I/O: Scratch Register */
28
29static unsigned char *reg_base;
30static u32 reg_shift;
31
32static int ns16550_open(void)
33{
34 out_8(reg_base + (UART_FCR << reg_shift), 0x06);
35 return 0;
36}
37
38static void ns16550_putc(unsigned char c)
39{
40 while ((in_8(reg_base + (UART_LSR << reg_shift)) & UART_LSR_THRE) == 0);
41 out_8(reg_base, c);
42}
43
44static unsigned char ns16550_getc(void)
45{
46 while ((in_8(reg_base + (UART_LSR << reg_shift)) & UART_LSR_DR) == 0);
47 return in_8(reg_base);
48}
49
50static u8 ns16550_tstc(void)
51{
52 return ((in_8(reg_base + (UART_LSR << reg_shift)) & UART_LSR_DR) != 0);
53}
54
55int ns16550_console_init(void *devp, struct serial_console_data *scdp)
56{
57 int n;
58
59 n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base));
60 if (n != sizeof(reg_base))
61 return -1;
62
63 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
64 if (n != sizeof(reg_shift))
65 reg_shift = 0;
66
67 scdp->open = ns16550_open;
68 scdp->putc = ns16550_putc;
69 scdp->getc = ns16550_getc;
70 scdp->tstc = ns16550_tstc;
71 scdp->close = NULL;
72
73 return 0;
74}
diff --git a/arch/powerpc/boot/of.c b/arch/powerpc/boot/of.c
index 3a71845afc6c..0182f384f3e6 100644
--- a/arch/powerpc/boot/of.c
+++ b/arch/powerpc/boot/of.c
@@ -256,24 +256,18 @@ static void of_console_write(char *buf, int len)
256 call_prom("write", 3, 1, of_stdout_handle, buf, len); 256 call_prom("write", 3, 1, of_stdout_handle, buf, len);
257} 257}
258 258
259int platform_init(void *promptr) 259int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end)
260{ 260{
261 platform_ops.fixups = NULL;
262 platform_ops.image_hdr = of_image_hdr; 261 platform_ops.image_hdr = of_image_hdr;
263 platform_ops.malloc = of_try_claim; 262 platform_ops.malloc = of_try_claim;
264 platform_ops.free = NULL;
265 platform_ops.exit = of_exit; 263 platform_ops.exit = of_exit;
266 264
267 dt_ops.finddevice = of_finddevice; 265 dt_ops.finddevice = of_finddevice;
268 dt_ops.getprop = of_getprop; 266 dt_ops.getprop = of_getprop;
269 dt_ops.setprop = of_setprop; 267 dt_ops.setprop = of_setprop;
270 dt_ops.translate_addr = NULL;
271 268
272 console_ops.open = of_console_open; 269 console_ops.open = of_console_open;
273 console_ops.write = of_console_write; 270 console_ops.write = of_console_write;
274 console_ops.edit_cmdline = NULL;
275 console_ops.close = NULL;
276 console_ops.data = NULL;
277 271
278 prom = (int (*)(void *))promptr; 272 prom = (int (*)(void *))promptr;
279 return 0; 273 return 0;
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 135eb4bb03b4..8abb6516bb7c 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -22,7 +22,8 @@ struct platform_ops {
22 void (*fixups)(void); 22 void (*fixups)(void);
23 void (*image_hdr)(const void *); 23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size); 24 void * (*malloc)(u32 size);
25 void (*free)(void *ptr, u32 size); 25 void (*free)(void *ptr);
26 void * (*realloc)(void *ptr, unsigned long size);
26 void (*exit)(void); 27 void (*exit)(void);
27}; 28};
28extern struct platform_ops platform_ops; 29extern struct platform_ops platform_ops;
@@ -30,13 +31,11 @@ extern struct platform_ops platform_ops;
30/* Device Tree operations */ 31/* Device Tree operations */
31struct dt_ops { 32struct dt_ops {
32 void * (*finddevice)(const char *name); 33 void * (*finddevice)(const char *name);
33 int (*getprop)(const void *node, const char *name, void *buf, 34 int (*getprop)(const void *phandle, const char *name, void *buf,
34 const int buflen); 35 const int buflen);
35 int (*setprop)(const void *node, const char *name, 36 int (*setprop)(const void *phandle, const char *name,
36 const void *buf, const int buflen); 37 const void *buf, const int buflen);
37 u64 (*translate_addr)(const char *path, const u32 *in_addr, 38 unsigned long (*finalize)(void);
38 const u32 addr_len);
39 unsigned long (*ft_addr)(void);
40}; 39};
41extern struct dt_ops dt_ops; 40extern struct dt_ops dt_ops;
42 41
@@ -59,10 +58,13 @@ struct serial_console_data {
59 void (*close)(void); 58 void (*close)(void);
60}; 59};
61 60
62extern int platform_init(void *promptr); 61int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
63extern void simple_alloc_init(void); 62int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
64extern void ft_init(void *dt_blob); 63int serial_console_init(void);
65extern int serial_console_init(void); 64int ns16550_console_init(void *devp, struct serial_console_data *scdp);
65void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
66 u32 max_allocs);
67
66 68
67static inline void *finddevice(const char *name) 69static inline void *finddevice(const char *name)
68{ 70{
@@ -84,10 +86,10 @@ static inline void *malloc(u32 size)
84 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; 86 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
85} 87}
86 88
87static inline void free(void *ptr, u32 size) 89static inline void free(void *ptr)
88{ 90{
89 if (platform_ops.free) 91 if (platform_ops.free)
90 platform_ops.free(ptr, size); 92 platform_ops.free(ptr);
91} 93}
92 94
93static inline void exit(void) 95static inline void exit(void)
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
new file mode 100644
index 000000000000..e8de4cf59be7
--- /dev/null
+++ b/arch/powerpc/boot/serial.c
@@ -0,0 +1,142 @@
1/*
2 * Generic serial console support
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * Code in serial_edit_cmdline() copied from <file:arch/ppc/boot/simple/misc.c>
7 * and was written by Matt Porter <mporter@kernel.crashing.org>.
8 *
9 * 2001,2006 (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#include <stdarg.h>
15#include <stddef.h>
16#include "types.h"
17#include "string.h"
18#include "stdio.h"
19#include "io.h"
20#include "ops.h"
21
22extern void udelay(long delay);
23
24static int serial_open(void)
25{
26 struct serial_console_data *scdp = console_ops.data;
27 return scdp->open();
28}
29
30static void serial_write(char *buf, int len)
31{
32 struct serial_console_data *scdp = console_ops.data;
33
34 while (*buf != '\0')
35 scdp->putc(*buf++);
36}
37
38static void serial_edit_cmdline(char *buf, int len)
39{
40 int timer = 0, count;
41 char ch, *cp;
42 struct serial_console_data *scdp = console_ops.data;
43
44 cp = buf;
45 count = strlen(buf);
46 cp = &buf[count];
47 count++;
48
49 while (timer++ < 5*1000) {
50 if (scdp->tstc()) {
51 while (((ch = scdp->getc()) != '\n') && (ch != '\r')) {
52 /* Test for backspace/delete */
53 if ((ch == '\b') || (ch == '\177')) {
54 if (cp != buf) {
55 cp--;
56 count--;
57 printf("\b \b");
58 }
59 /* Test for ^x/^u (and wipe the line) */
60 } else if ((ch == '\030') || (ch == '\025')) {
61 while (cp != buf) {
62 cp--;
63 count--;
64 printf("\b \b");
65 }
66 } else if (count < len) {
67 *cp++ = ch;
68 count++;
69 scdp->putc(ch);
70 }
71 }
72 break; /* Exit 'timer' loop */
73 }
74 udelay(1000); /* 1 msec */
75 }
76 *cp = 0;
77}
78
79static void serial_close(void)
80{
81 struct serial_console_data *scdp = console_ops.data;
82
83 if (scdp->close)
84 scdp->close();
85}
86
87static void *serial_get_stdout_devp(void)
88{
89 void *devp;
90 char devtype[MAX_PROP_LEN];
91 char path[MAX_PATH_LEN];
92
93 devp = finddevice("/chosen");
94 if (devp == NULL)
95 goto err_out;
96
97 if (getprop(devp, "linux,stdout-path", path, MAX_PATH_LEN) > 0) {
98 devp = finddevice(path);
99 if (devp == NULL)
100 goto err_out;
101
102 if ((getprop(devp, "device_type", devtype, sizeof(devtype)) > 0)
103 && !strcmp(devtype, "serial"))
104 return devp;
105 }
106err_out:
107 return NULL;
108}
109
110static struct serial_console_data serial_cd;
111
112/* Node's "compatible" property determines which serial driver to use */
113int serial_console_init(void)
114{
115 void *devp;
116 int rc = -1;
117 char compat[MAX_PROP_LEN];
118
119 devp = serial_get_stdout_devp();
120 if (devp == NULL)
121 goto err_out;
122
123 if (getprop(devp, "compatible", compat, sizeof(compat)) < 0)
124 goto err_out;
125
126 if (!strcmp(compat, "ns16550"))
127 rc = ns16550_console_init(devp, &serial_cd);
128
129 /* Add other serial console driver calls here */
130
131 if (!rc) {
132 console_ops.open = serial_open;
133 console_ops.write = serial_write;
134 console_ops.edit_cmdline = serial_edit_cmdline;
135 console_ops.close = serial_close;
136 console_ops.data = &serial_cd;
137
138 return 0;
139 }
140err_out:
141 return -1;
142}
diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
new file mode 100644
index 000000000000..cfe3a7505ba0
--- /dev/null
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -0,0 +1,149 @@
1/*
2 * Implement primitive realloc(3) functionality.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2006 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#include <stddef.h>
13#include "types.h"
14#include "page.h"
15#include "string.h"
16#include "ops.h"
17
18#define ENTRY_BEEN_USED 0x01
19#define ENTRY_IN_USE 0x02
20
21static struct alloc_info {
22 u32 flags;
23 u32 base;
24 u32 size;
25} *alloc_tbl;
26
27static u32 tbl_entries;
28static u32 alloc_min;
29static u32 next_base;
30static u32 space_left;
31
32/*
33 * First time an entry is used, its base and size are set.
34 * An entry can be freed and re-malloc'd but its base & size don't change.
35 * Should be smart enough for needs of bootwrapper.
36 */
37static void *simple_malloc(u32 size)
38{
39 u32 i;
40 struct alloc_info *p = alloc_tbl;
41
42 if (size == 0)
43 goto err_out;
44
45 size = _ALIGN_UP(size, alloc_min);
46
47 for (i=0; i<tbl_entries; i++, p++)
48 if (!(p->flags & ENTRY_BEEN_USED)) { /* never been used */
49 if (size <= space_left) {
50 p->base = next_base;
51 p->size = size;
52 p->flags = ENTRY_BEEN_USED | ENTRY_IN_USE;
53 next_base += size;
54 space_left -= size;
55 return (void *)p->base;
56 }
57 goto err_out; /* not enough space left */
58 }
59 /* reuse an entry keeping same base & size */
60 else if (!(p->flags & ENTRY_IN_USE) && (size <= p->size)) {
61 p->flags |= ENTRY_IN_USE;
62 return (void *)p->base;
63 }
64err_out:
65 return NULL;
66}
67
68static struct alloc_info *simple_find_entry(void *ptr)
69{
70 u32 i;
71 struct alloc_info *p = alloc_tbl;
72
73 for (i=0; i<tbl_entries; i++,p++) {
74 if (!(p->flags & ENTRY_BEEN_USED))
75 break;
76 if ((p->flags & ENTRY_IN_USE) && (p->base == (u32)ptr))
77 return p;
78 }
79 return NULL;
80}
81
82static void simple_free(void *ptr)
83{
84 struct alloc_info *p = simple_find_entry(ptr);
85
86 if (p != NULL)
87 p->flags &= ~ENTRY_IN_USE;
88}
89
90/*
91 * Change size of area pointed to by 'ptr' to 'size'.
92 * If 'ptr' is NULL, then its a malloc(). If 'size' is 0, then its a free().
93 * 'ptr' must be NULL or a pointer to a non-freed area previously returned by
94 * simple_realloc() or simple_malloc().
95 */
96static void *simple_realloc(void *ptr, unsigned long size)
97{
98 struct alloc_info *p;
99 void *new;
100
101 if (size == 0) {
102 simple_free(ptr);
103 return NULL;
104 }
105
106 if (ptr == NULL)
107 return simple_malloc(size);
108
109 p = simple_find_entry(ptr);
110 if (p == NULL) /* ptr not from simple_malloc/simple_realloc */
111 return NULL;
112 if (size <= p->size) /* fits in current block */
113 return ptr;
114
115 new = simple_malloc(size);
116 memcpy(new, ptr, p->size);
117 simple_free(ptr);
118 return new;
119}
120
121/*
122 * Returns addr of first byte after heap so caller can see if it took
123 * too much space. If so, change args & try again.
124 */
125void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
126 u32 max_allocs)
127{
128 u32 heap_base, tbl_size;
129
130 heap_size = _ALIGN_UP(heap_size, granularity);
131 alloc_min = granularity;
132 tbl_entries = max_allocs;
133
134 tbl_size = tbl_entries * sizeof(struct alloc_info);
135
136 alloc_tbl = (struct alloc_info *)_ALIGN_UP((unsigned long)base, 8);
137 memset(alloc_tbl, 0, tbl_size);
138
139 heap_base = _ALIGN_UP((u32)alloc_tbl + tbl_size, alloc_min);
140
141 next_base = heap_base;
142 space_left = heap_size;
143
144 platform_ops.malloc = simple_malloc;
145 platform_ops.free = simple_free;
146 platform_ops.realloc = simple_realloc;
147
148 return (void *)(heap_base + heap_size);
149}
diff --git a/arch/powerpc/boot/stdio.c b/arch/powerpc/boot/stdio.c
index 6d5f6382e1ce..0a9feeb98342 100644
--- a/arch/powerpc/boot/stdio.c
+++ b/arch/powerpc/boot/stdio.c
@@ -320,6 +320,7 @@ printf(const char *fmt, ...)
320 va_start(args, fmt); 320 va_start(args, fmt);
321 n = vsprintf(sprint_buf, fmt, args); 321 n = vsprintf(sprint_buf, fmt, args);
322 va_end(args); 322 va_end(args);
323 console_ops.write(sprint_buf, n); 323 if (console_ops.write)
324 console_ops.write(sprint_buf, n);
324 return n; 325 return n;
325} 326}
diff --git a/arch/powerpc/boot/util.S b/arch/powerpc/boot/util.S
new file mode 100644
index 000000000000..427ddfc11991
--- /dev/null
+++ b/arch/powerpc/boot/util.S
@@ -0,0 +1,88 @@
1/*
2 * Copied from <file:arch/powerpc/kernel/misc_32.S>
3 *
4 * This file contains miscellaneous low-level functions.
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 *
7 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
8 * and Paul Mackerras.
9 *
10 * kexec bits:
11 * Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
12 * GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 *
19 */
20#include "ppc_asm.h"
21
22#define SPRN_PVR 0x11F /* Processor Version Register */
23
24 .text
25
26/* udelay (on non-601 processors) needs to know the period of the
27 * timebase in nanoseconds. This used to be hardcoded to be 60ns
28 * (period of 66MHz/4). Now a variable is used that is initialized to
29 * 60 for backward compatibility, but it can be overridden as necessary
30 * with code something like this:
31 * extern unsigned long timebase_period_ns;
32 * timebase_period_ns = 1000000000 / bd->bi_tbfreq;
33 */
34 .data
35 .globl timebase_period_ns
36timebase_period_ns:
37 .long 60
38
39 .text
40/*
41 * Delay for a number of microseconds
42 */
43 .globl udelay
44udelay:
45 mfspr r4,SPRN_PVR
46 srwi r4,r4,16
47 cmpwi 0,r4,1 /* 601 ? */
48 bne .udelay_not_601
4900: li r0,86 /* Instructions / microsecond? */
50 mtctr r0
5110: addi r0,r0,0 /* NOP */
52 bdnz 10b
53 subic. r3,r3,1
54 bne 00b
55 blr
56
57.udelay_not_601:
58 mulli r4,r3,1000 /* nanoseconds */
59 /* Change r4 to be the number of ticks using:
60 * (nanoseconds + (timebase_period_ns - 1 )) / timebase_period_ns
61 * timebase_period_ns defaults to 60 (16.6MHz) */
62 mflr r5
63 bl 0f
640: mflr r6
65 mtlr r5
66 lis r5,0b@ha
67 addi r5,r5,0b@l
68 subf r5,r5,r6 /* In case we're relocated */
69 addis r5,r5,timebase_period_ns@ha
70 lwz r5,timebase_period_ns@l(r5)
71 add r4,r4,r5
72 addi r4,r4,-1
73 divw r4,r4,r5 /* BUS ticks */
741: mftbu r5
75 mftb r6
76 mftbu r7
77 cmpw 0,r5,r7
78 bne 1b /* Get [synced] base time */
79 addc r9,r6,r4 /* Compute end time */
80 addze r8,r5
812: mftbu r5
82 cmpw 0,r5,r8
83 blt 2b
84 bgt 3f
85 mftb r6
86 cmpw 0,r6,r9
87 blt 2b
883: blr
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index b5fb1fee76f8..024e4d425c59 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -184,6 +184,9 @@ fi
184 184
185if [ -n "$dtb" ]; then 185if [ -n "$dtb" ]; then
186 addsec $tmp "$dtb" .kernel:dtb 186 addsec $tmp "$dtb" .kernel:dtb
187 if [ -n "$dts" ]; then
188 rm $dtb
189 fi
187fi 190fi
188 191
189if [ "$platform" != "miboot" ]; then 192if [ "$platform" != "miboot" ]; then
diff --git a/arch/powerpc/boot/zImage.coff.lds.S b/arch/powerpc/boot/zImage.coff.lds.S
index 05f32388b953..a360905e5428 100644
--- a/arch/powerpc/boot/zImage.coff.lds.S
+++ b/arch/powerpc/boot/zImage.coff.lds.S
@@ -21,6 +21,10 @@ SECTIONS
21 *(.got2) 21 *(.got2)
22 __got2_end = .; 22 __got2_end = .;
23 23
24 _dtb_start = .;
25 *(.kernel:dtb)
26 _dtb_end = .;
27
24 _vmlinux_start = .; 28 _vmlinux_start = .;
25 *(.kernel:vmlinux.strip) 29 *(.kernel:vmlinux.strip)
26 _vmlinux_end = .; 30 _vmlinux_end = .;
diff --git a/arch/powerpc/configs/cell_defconfig b/arch/powerpc/configs/cell_defconfig
index 0aba06d7d2ec..a98c982c73ad 100644
--- a/arch/powerpc/configs/cell_defconfig
+++ b/arch/powerpc/configs/cell_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc6
4# Wed Oct 4 15:30:50 2006 4# Wed Nov 22 15:33:04 2006
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -32,6 +32,10 @@ CONFIG_AUDIT_ARCH=y
32CONFIG_POWER3=y 32CONFIG_POWER3=y
33CONFIG_POWER4=y 33CONFIG_POWER4=y
34CONFIG_PPC_FPU=y 34CONFIG_PPC_FPU=y
35# CONFIG_PPC_DCR_NATIVE is not set
36CONFIG_PPC_DCR_MMIO=y
37CONFIG_PPC_DCR=y
38CONFIG_PPC_OF_PLATFORM_PCI=y
35CONFIG_ALTIVEC=y 39CONFIG_ALTIVEC=y
36CONFIG_PPC_STD_MMU=y 40CONFIG_PPC_STD_MMU=y
37CONFIG_VIRT_CPU_ACCOUNTING=y 41CONFIG_VIRT_CPU_ACCOUNTING=y
@@ -67,7 +71,7 @@ CONFIG_INITRAMFS_SOURCE=""
67CONFIG_CC_OPTIMIZE_FOR_SIZE=y 71CONFIG_CC_OPTIMIZE_FOR_SIZE=y
68CONFIG_SYSCTL=y 72CONFIG_SYSCTL=y
69# CONFIG_EMBEDDED is not set 73# CONFIG_EMBEDDED is not set
70# CONFIG_SYSCTL_SYSCALL is not set 74CONFIG_SYSCTL_SYSCALL=y
71CONFIG_KALLSYMS=y 75CONFIG_KALLSYMS=y
72# CONFIG_KALLSYMS_ALL is not set 76# CONFIG_KALLSYMS_ALL is not set
73# CONFIG_KALLSYMS_EXTRA_PASS is not set 77# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -131,6 +135,7 @@ CONFIG_PPC_CELL=y
131CONFIG_PPC_CELL_NATIVE=y 135CONFIG_PPC_CELL_NATIVE=y
132CONFIG_PPC_IBM_CELL_BLADE=y 136CONFIG_PPC_IBM_CELL_BLADE=y
133CONFIG_UDBG_RTAS_CONSOLE=y 137CONFIG_UDBG_RTAS_CONSOLE=y
138CONFIG_PPC_PS3=y
134# CONFIG_U3_DART is not set 139# CONFIG_U3_DART is not set
135CONFIG_PPC_RTAS=y 140CONFIG_PPC_RTAS=y
136# CONFIG_RTAS_ERROR_LOGGING is not set 141# CONFIG_RTAS_ERROR_LOGGING is not set
@@ -139,9 +144,23 @@ CONFIG_RTAS_FLASH=y
139CONFIG_MMIO_NVRAM=y 144CONFIG_MMIO_NVRAM=y
140# CONFIG_PPC_MPC106 is not set 145# CONFIG_PPC_MPC106 is not set
141# CONFIG_PPC_970_NAP is not set 146# CONFIG_PPC_970_NAP is not set
142# CONFIG_CPU_FREQ is not set 147CONFIG_PPC_INDIRECT_IO=y
148CONFIG_GENERIC_IOMAP=y
149CONFIG_CPU_FREQ=y
150CONFIG_CPU_FREQ_TABLE=y
151CONFIG_CPU_FREQ_DEBUG=y
152CONFIG_CPU_FREQ_STAT=y
153# CONFIG_CPU_FREQ_STAT_DETAILS is not set
154CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
155# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
156CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
157CONFIG_CPU_FREQ_GOV_POWERSAVE=y
158CONFIG_CPU_FREQ_GOV_USERSPACE=y
159CONFIG_CPU_FREQ_GOV_ONDEMAND=y
160CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
161# CONFIG_CPU_FREQ_PMAC64 is not set
143# CONFIG_WANT_EARLY_SERIAL is not set 162# CONFIG_WANT_EARLY_SERIAL is not set
144# CONFIG_MPIC is not set 163CONFIG_MPIC=y
145 164
146# 165#
147# Cell Broadband Engine options 166# Cell Broadband Engine options
@@ -149,6 +168,15 @@ CONFIG_MMIO_NVRAM=y
149CONFIG_SPU_FS=m 168CONFIG_SPU_FS=m
150CONFIG_SPU_BASE=y 169CONFIG_SPU_BASE=y
151CONFIG_CBE_RAS=y 170CONFIG_CBE_RAS=y
171CONFIG_CBE_THERM=m
172CONFIG_CBE_CPUFREQ=m
173
174#
175# PS3 Platform Options
176#
177CONFIG_PS3_HTAB_SIZE=20
178# CONFIG_PS3_DYNAMIC_DMA is not set
179CONFIG_PS3_USE_LPAR_ADDR=y
152 180
153# 181#
154# Kernel options 182# Kernel options
@@ -166,13 +194,14 @@ CONFIG_BINFMT_MISC=m
166CONFIG_FORCE_MAX_ZONEORDER=9 194CONFIG_FORCE_MAX_ZONEORDER=9
167# CONFIG_IOMMU_VMERGE is not set 195# CONFIG_IOMMU_VMERGE is not set
168CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 196CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
169CONFIG_KEXEC=y 197# CONFIG_KEXEC is not set
170# CONFIG_CRASH_DUMP is not set 198# CONFIG_CRASH_DUMP is not set
171CONFIG_IRQ_ALL_CPUS=y 199CONFIG_IRQ_ALL_CPUS=y
172CONFIG_NUMA=y 200CONFIG_NUMA=y
173CONFIG_NODES_SHIFT=4 201CONFIG_NODES_SHIFT=4
174CONFIG_ARCH_SELECT_MEMORY_MODEL=y 202CONFIG_ARCH_SELECT_MEMORY_MODEL=y
175CONFIG_ARCH_SPARSEMEM_ENABLE=y 203CONFIG_ARCH_SPARSEMEM_ENABLE=y
204CONFIG_ARCH_SPARSEMEM_DEFAULT=y
176CONFIG_ARCH_POPULATES_NODE_MAP=y 205CONFIG_ARCH_POPULATES_NODE_MAP=y
177CONFIG_SELECT_MEMORY_MODEL=y 206CONFIG_SELECT_MEMORY_MODEL=y
178# CONFIG_FLATMEM_MANUAL is not set 207# CONFIG_FLATMEM_MANUAL is not set
@@ -189,6 +218,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
189CONFIG_MIGRATION=y 218CONFIG_MIGRATION=y
190CONFIG_RESOURCES_64BIT=y 219CONFIG_RESOURCES_64BIT=y
191CONFIG_ARCH_MEMORY_PROBE=y 220CONFIG_ARCH_MEMORY_PROBE=y
221CONFIG_NODES_SPAN_OTHER_NODES=y
192CONFIG_PPC_64K_PAGES=y 222CONFIG_PPC_64K_PAGES=y
193CONFIG_SCHED_SMT=y 223CONFIG_SCHED_SMT=y
194CONFIG_PROC_DEVICETREE=y 224CONFIG_PROC_DEVICETREE=y
@@ -207,7 +237,6 @@ CONFIG_GENERIC_ISA_DMA=y
207CONFIG_PCI=y 237CONFIG_PCI=y
208CONFIG_PCI_DOMAINS=y 238CONFIG_PCI_DOMAINS=y
209CONFIG_PCIEPORTBUS=y 239CONFIG_PCIEPORTBUS=y
210# CONFIG_PCI_MULTITHREAD_PROBE is not set
211# CONFIG_PCI_DEBUG is not set 240# CONFIG_PCI_DEBUG is not set
212 241
213# 242#
@@ -280,7 +309,6 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=y
280# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 309# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
281# CONFIG_IPV6_SIT is not set 310# CONFIG_IPV6_SIT is not set
282CONFIG_IPV6_TUNNEL=m 311CONFIG_IPV6_TUNNEL=m
283# CONFIG_IPV6_SUBTREES is not set
284# CONFIG_IPV6_MULTIPLE_TABLES is not set 312# CONFIG_IPV6_MULTIPLE_TABLES is not set
285# CONFIG_NETWORK_SECMARK is not set 313# CONFIG_NETWORK_SECMARK is not set
286CONFIG_NETFILTER=y 314CONFIG_NETFILTER=y
@@ -1107,7 +1135,8 @@ CONFIG_PLIST=y
1107# 1135#
1108# Instrumentation Support 1136# Instrumentation Support
1109# 1137#
1110# CONFIG_PROFILING is not set 1138CONFIG_PROFILING=y
1139CONFIG_OPROFILE=y
1111# CONFIG_KPROBES is not set 1140# CONFIG_KPROBES is not set
1112 1141
1113# 1142#
@@ -1142,6 +1171,7 @@ CONFIG_DEBUG_FS=y
1142CONFIG_DEBUGGER=y 1171CONFIG_DEBUGGER=y
1143CONFIG_XMON=y 1172CONFIG_XMON=y
1144CONFIG_XMON_DEFAULT=y 1173CONFIG_XMON_DEFAULT=y
1174CONFIG_XMON_DISASSEMBLY=y
1145CONFIG_IRQSTACKS=y 1175CONFIG_IRQSTACKS=y
1146# CONFIG_BOOTX_TEXT is not set 1176# CONFIG_BOOTX_TEXT is not set
1147# CONFIG_PPC_EARLY_DEBUG is not set 1177# CONFIG_PPC_EARLY_DEBUG is not set
@@ -1159,7 +1189,7 @@ CONFIG_CRYPTO=y
1159CONFIG_CRYPTO_ALGAPI=y 1189CONFIG_CRYPTO_ALGAPI=y
1160CONFIG_CRYPTO_BLKCIPHER=m 1190CONFIG_CRYPTO_BLKCIPHER=m
1161CONFIG_CRYPTO_HASH=y 1191CONFIG_CRYPTO_HASH=y
1162# CONFIG_CRYPTO_MANAGER is not set 1192CONFIG_CRYPTO_MANAGER=y
1163CONFIG_CRYPTO_HMAC=y 1193CONFIG_CRYPTO_HMAC=y
1164# CONFIG_CRYPTO_NULL is not set 1194# CONFIG_CRYPTO_NULL is not set
1165# CONFIG_CRYPTO_MD4 is not set 1195# CONFIG_CRYPTO_MD4 is not set
diff --git a/arch/powerpc/configs/linkstation_defconfig b/arch/powerpc/configs/linkstation_defconfig
new file mode 100644
index 000000000000..23fd210eb56a
--- /dev/null
+++ b/arch/powerpc/configs/linkstation_defconfig
@@ -0,0 +1,1583 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc4
4# Wed Nov 15 20:36:30 2006
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_FIND_NEXT_BIT=y
16CONFIG_PPC=y
17CONFIG_EARLY_PRINTK=y
18CONFIG_GENERIC_NVRAM=y
19CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
20CONFIG_ARCH_MAY_HAVE_PC_FDC=y
21CONFIG_PPC_OF=y
22CONFIG_PPC_UDBG_16550=y
23# CONFIG_GENERIC_TBSYNC is not set
24CONFIG_AUDIT_ARCH=y
25# CONFIG_DEFAULT_UIMAGE is not set
26
27#
28# Processor support
29#
30CONFIG_CLASSIC32=y
31# CONFIG_PPC_52xx is not set
32# CONFIG_PPC_82xx is not set
33# CONFIG_PPC_83xx is not set
34# CONFIG_PPC_85xx is not set
35# CONFIG_PPC_86xx is not set
36# CONFIG_40x is not set
37# CONFIG_44x is not set
38# CONFIG_8xx is not set
39# CONFIG_E200 is not set
40CONFIG_6xx=y
41CONFIG_PPC_FPU=y
42# CONFIG_PPC_DCR_NATIVE is not set
43# CONFIG_PPC_DCR_MMIO is not set
44# CONFIG_ALTIVEC is not set
45CONFIG_PPC_STD_MMU=y
46CONFIG_PPC_STD_MMU_32=y
47# CONFIG_SMP is not set
48CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
49
50#
51# Code maturity level options
52#
53CONFIG_EXPERIMENTAL=y
54CONFIG_BROKEN_ON_SMP=y
55CONFIG_INIT_ENV_ARG_LIMIT=32
56
57#
58# General setup
59#
60CONFIG_LOCALVERSION="-kuroboxHG"
61CONFIG_LOCALVERSION_AUTO=y
62CONFIG_SWAP=y
63CONFIG_SYSVIPC=y
64# CONFIG_IPC_NS is not set
65CONFIG_POSIX_MQUEUE=y
66# CONFIG_BSD_PROCESS_ACCT is not set
67# CONFIG_TASKSTATS is not set
68# CONFIG_UTS_NS is not set
69# CONFIG_AUDIT is not set
70CONFIG_IKCONFIG=y
71CONFIG_IKCONFIG_PROC=y
72# CONFIG_RELAY is not set
73CONFIG_INITRAMFS_SOURCE=""
74# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
75CONFIG_SYSCTL=y
76# CONFIG_EMBEDDED is not set
77# CONFIG_SYSCTL_SYSCALL is not set
78CONFIG_KALLSYMS=y
79# CONFIG_KALLSYMS_ALL is not set
80# CONFIG_KALLSYMS_EXTRA_PASS is not set
81CONFIG_HOTPLUG=y
82CONFIG_PRINTK=y
83CONFIG_BUG=y
84CONFIG_ELF_CORE=y
85CONFIG_BASE_FULL=y
86CONFIG_FUTEX=y
87CONFIG_EPOLL=y
88CONFIG_SHMEM=y
89CONFIG_SLAB=y
90CONFIG_VM_EVENT_COUNTERS=y
91CONFIG_RT_MUTEXES=y
92# CONFIG_TINY_SHMEM is not set
93CONFIG_BASE_SMALL=0
94# CONFIG_SLOB is not set
95
96#
97# Loadable module support
98#
99CONFIG_MODULES=y
100CONFIG_MODULE_UNLOAD=y
101# CONFIG_MODULE_FORCE_UNLOAD is not set
102# CONFIG_MODVERSIONS is not set
103# CONFIG_MODULE_SRCVERSION_ALL is not set
104CONFIG_KMOD=y
105
106#
107# Block layer
108#
109CONFIG_BLOCK=y
110# CONFIG_LBD is not set
111# CONFIG_BLK_DEV_IO_TRACE is not set
112# CONFIG_LSF is not set
113
114#
115# IO Schedulers
116#
117CONFIG_IOSCHED_NOOP=y
118CONFIG_IOSCHED_AS=y
119CONFIG_IOSCHED_DEADLINE=y
120CONFIG_IOSCHED_CFQ=y
121CONFIG_DEFAULT_AS=y
122# CONFIG_DEFAULT_DEADLINE is not set
123# CONFIG_DEFAULT_CFQ is not set
124# CONFIG_DEFAULT_NOOP is not set
125CONFIG_DEFAULT_IOSCHED="anticipatory"
126
127#
128# Platform support
129#
130# CONFIG_PPC_MULTIPLATFORM is not set
131CONFIG_EMBEDDED6xx=y
132# CONFIG_APUS is not set
133# CONFIG_PPC_CELL is not set
134# CONFIG_PPC_CELL_NATIVE is not set
135# CONFIG_PPC_RTAS is not set
136# CONFIG_MMIO_NVRAM is not set
137# CONFIG_PPC_MPC106 is not set
138# CONFIG_PPC_970_NAP is not set
139# CONFIG_PPC_INDIRECT_IO is not set
140# CONFIG_GENERIC_IOMAP is not set
141# CONFIG_CPU_FREQ is not set
142# CONFIG_TAU is not set
143# CONFIG_KATANA is not set
144# CONFIG_WILLOW is not set
145# CONFIG_CPCI690 is not set
146# CONFIG_POWERPMC250 is not set
147# CONFIG_CHESTNUT is not set
148# CONFIG_SPRUCE is not set
149# CONFIG_HDPU is not set
150# CONFIG_EV64260 is not set
151# CONFIG_LOPEC is not set
152# CONFIG_MVME5100 is not set
153# CONFIG_PPLUS is not set
154# CONFIG_PRPMC750 is not set
155# CONFIG_PRPMC800 is not set
156# CONFIG_SANDPOINT is not set
157CONFIG_LINKSTATION=y
158# CONFIG_MPC7448HPC2 is not set
159# CONFIG_RADSTONE_PPC7D is not set
160# CONFIG_PAL4 is not set
161# CONFIG_GEMINI is not set
162# CONFIG_EST8260 is not set
163# CONFIG_SBC82xx is not set
164# CONFIG_SBS8260 is not set
165# CONFIG_RPX8260 is not set
166# CONFIG_TQM8260 is not set
167# CONFIG_ADS8272 is not set
168# CONFIG_PQ2FADS is not set
169# CONFIG_LITE5200 is not set
170# CONFIG_EV64360 is not set
171CONFIG_PPC_GEN550=y
172CONFIG_MPC10X_BRIDGE=y
173CONFIG_MPC10X_OPENPIC=y
174# CONFIG_MPC10X_STORE_GATHERING is not set
175# CONFIG_WANT_EARLY_SERIAL is not set
176CONFIG_MPIC=y
177
178#
179# Kernel options
180#
181# CONFIG_HIGHMEM is not set
182CONFIG_HZ_100=y
183# CONFIG_HZ_250 is not set
184# CONFIG_HZ_1000 is not set
185CONFIG_HZ=100
186CONFIG_PREEMPT_NONE=y
187# CONFIG_PREEMPT_VOLUNTARY is not set
188# CONFIG_PREEMPT is not set
189CONFIG_BINFMT_ELF=y
190# CONFIG_BINFMT_MISC is not set
191CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
192CONFIG_ARCH_FLATMEM_ENABLE=y
193CONFIG_ARCH_POPULATES_NODE_MAP=y
194CONFIG_SELECT_MEMORY_MODEL=y
195CONFIG_FLATMEM_MANUAL=y
196# CONFIG_DISCONTIGMEM_MANUAL is not set
197# CONFIG_SPARSEMEM_MANUAL is not set
198CONFIG_FLATMEM=y
199CONFIG_FLAT_NODE_MEM_MAP=y
200# CONFIG_SPARSEMEM_STATIC is not set
201CONFIG_SPLIT_PTLOCK_CPUS=4
202# CONFIG_RESOURCES_64BIT is not set
203CONFIG_PROC_DEVICETREE=y
204# CONFIG_CMDLINE_BOOL is not set
205# CONFIG_PM is not set
206# CONFIG_SECCOMP is not set
207CONFIG_ISA_DMA_API=y
208
209#
210# Bus options
211#
212CONFIG_GENERIC_ISA_DMA=y
213# CONFIG_MPIC_WEIRD is not set
214# CONFIG_PPC_I8259 is not set
215CONFIG_PPC_INDIRECT_PCI=y
216CONFIG_FSL_SOC=y
217CONFIG_PCI=y
218CONFIG_PCI_DOMAINS=y
219# CONFIG_PCIEPORTBUS is not set
220# CONFIG_PCI_MULTITHREAD_PROBE is not set
221# CONFIG_PCI_DEBUG is not set
222
223#
224# PCCARD (PCMCIA/CardBus) support
225#
226# CONFIG_PCCARD is not set
227
228#
229# PCI Hotplug Support
230#
231# CONFIG_HOTPLUG_PCI is not set
232
233#
234# Advanced setup
235#
236# CONFIG_ADVANCED_OPTIONS is not set
237
238#
239# Default settings for advanced configuration options are used
240#
241CONFIG_HIGHMEM_START=0xfe000000
242CONFIG_LOWMEM_SIZE=0x30000000
243CONFIG_KERNEL_START=0xc0000000
244CONFIG_TASK_SIZE=0x80000000
245CONFIG_BOOT_LOAD=0x00800000
246
247#
248# Networking
249#
250CONFIG_NET=y
251
252#
253# Networking options
254#
255# CONFIG_NETDEBUG is not set
256CONFIG_PACKET=y
257CONFIG_PACKET_MMAP=y
258CONFIG_UNIX=y
259CONFIG_XFRM=y
260# CONFIG_XFRM_USER is not set
261# CONFIG_XFRM_SUB_POLICY is not set
262# CONFIG_NET_KEY is not set
263CONFIG_INET=y
264CONFIG_IP_MULTICAST=y
265# CONFIG_IP_ADVANCED_ROUTER is not set
266CONFIG_IP_FIB_HASH=y
267CONFIG_IP_PNP=y
268CONFIG_IP_PNP_DHCP=y
269CONFIG_IP_PNP_BOOTP=y
270# CONFIG_IP_PNP_RARP is not set
271# CONFIG_NET_IPIP is not set
272# CONFIG_NET_IPGRE is not set
273# CONFIG_IP_MROUTE is not set
274# CONFIG_ARPD is not set
275# CONFIG_SYN_COOKIES is not set
276# CONFIG_INET_AH is not set
277# CONFIG_INET_ESP is not set
278# CONFIG_INET_IPCOMP is not set
279# CONFIG_INET_XFRM_TUNNEL is not set
280# CONFIG_INET_TUNNEL is not set
281CONFIG_INET_XFRM_MODE_TRANSPORT=y
282CONFIG_INET_XFRM_MODE_TUNNEL=y
283CONFIG_INET_XFRM_MODE_BEET=y
284CONFIG_INET_DIAG=y
285CONFIG_INET_TCP_DIAG=y
286# CONFIG_TCP_CONG_ADVANCED is not set
287CONFIG_TCP_CONG_CUBIC=y
288CONFIG_DEFAULT_TCP_CONG="cubic"
289
290#
291# IP: Virtual Server Configuration
292#
293# CONFIG_IP_VS is not set
294# CONFIG_IPV6 is not set
295# CONFIG_INET6_XFRM_TUNNEL is not set
296# CONFIG_INET6_TUNNEL is not set
297# CONFIG_NETWORK_SECMARK is not set
298CONFIG_NETFILTER=y
299# CONFIG_NETFILTER_DEBUG is not set
300
301#
302# Core Netfilter Configuration
303#
304# CONFIG_NETFILTER_NETLINK is not set
305CONFIG_NETFILTER_XTABLES=m
306CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
307# CONFIG_NETFILTER_XT_TARGET_DSCP is not set
308CONFIG_NETFILTER_XT_TARGET_MARK=m
309# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set
310# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
311# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set
312CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m
313# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
314# CONFIG_NETFILTER_XT_MATCH_DSCP is not set
315CONFIG_NETFILTER_XT_MATCH_ESP=m
316# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
317CONFIG_NETFILTER_XT_MATCH_LENGTH=m
318CONFIG_NETFILTER_XT_MATCH_LIMIT=m
319CONFIG_NETFILTER_XT_MATCH_MAC=m
320CONFIG_NETFILTER_XT_MATCH_MARK=m
321# CONFIG_NETFILTER_XT_MATCH_POLICY is not set
322CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m
323CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m
324# CONFIG_NETFILTER_XT_MATCH_QUOTA is not set
325# CONFIG_NETFILTER_XT_MATCH_REALM is not set
326# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
327CONFIG_NETFILTER_XT_MATCH_STATE=m
328# CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
329# CONFIG_NETFILTER_XT_MATCH_STRING is not set
330# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
331
332#
333# IP: Netfilter Configuration
334#
335CONFIG_IP_NF_CONNTRACK=m
336# CONFIG_IP_NF_CT_ACCT is not set
337# CONFIG_IP_NF_CONNTRACK_MARK is not set
338# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
339# CONFIG_IP_NF_CT_PROTO_SCTP is not set
340CONFIG_IP_NF_FTP=m
341CONFIG_IP_NF_IRC=m
342# CONFIG_IP_NF_NETBIOS_NS is not set
343CONFIG_IP_NF_TFTP=m
344# CONFIG_IP_NF_AMANDA is not set
345# CONFIG_IP_NF_PPTP is not set
346# CONFIG_IP_NF_H323 is not set
347# CONFIG_IP_NF_SIP is not set
348# CONFIG_IP_NF_QUEUE is not set
349CONFIG_IP_NF_IPTABLES=m
350CONFIG_IP_NF_MATCH_IPRANGE=m
351# CONFIG_IP_NF_MATCH_TOS is not set
352# CONFIG_IP_NF_MATCH_RECENT is not set
353# CONFIG_IP_NF_MATCH_ECN is not set
354# CONFIG_IP_NF_MATCH_AH is not set
355# CONFIG_IP_NF_MATCH_TTL is not set
356# CONFIG_IP_NF_MATCH_OWNER is not set
357# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
358# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
359CONFIG_IP_NF_FILTER=m
360CONFIG_IP_NF_TARGET_REJECT=m
361# CONFIG_IP_NF_TARGET_LOG is not set
362# CONFIG_IP_NF_TARGET_ULOG is not set
363# CONFIG_IP_NF_TARGET_TCPMSS is not set
364CONFIG_IP_NF_NAT=m
365CONFIG_IP_NF_NAT_NEEDED=y
366CONFIG_IP_NF_TARGET_MASQUERADE=m
367CONFIG_IP_NF_TARGET_REDIRECT=m
368CONFIG_IP_NF_TARGET_NETMAP=m
369CONFIG_IP_NF_TARGET_SAME=m
370# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
371CONFIG_IP_NF_NAT_IRC=m
372CONFIG_IP_NF_NAT_FTP=m
373CONFIG_IP_NF_NAT_TFTP=m
374CONFIG_IP_NF_MANGLE=m
375CONFIG_IP_NF_TARGET_TOS=m
376CONFIG_IP_NF_TARGET_ECN=m
377CONFIG_IP_NF_TARGET_TTL=m
378CONFIG_IP_NF_RAW=m
379CONFIG_IP_NF_ARPTABLES=m
380CONFIG_IP_NF_ARPFILTER=m
381CONFIG_IP_NF_ARP_MANGLE=m
382
383#
384# DCCP Configuration (EXPERIMENTAL)
385#
386# CONFIG_IP_DCCP is not set
387
388#
389# SCTP Configuration (EXPERIMENTAL)
390#
391# CONFIG_IP_SCTP is not set
392
393#
394# TIPC Configuration (EXPERIMENTAL)
395#
396# CONFIG_TIPC is not set
397# CONFIG_ATM is not set
398# CONFIG_BRIDGE is not set
399# CONFIG_VLAN_8021Q is not set
400# CONFIG_DECNET is not set
401# CONFIG_LLC2 is not set
402# CONFIG_IPX is not set
403# CONFIG_ATALK is not set
404# CONFIG_X25 is not set
405# CONFIG_LAPB is not set
406# CONFIG_ECONET is not set
407# CONFIG_WAN_ROUTER is not set
408
409#
410# QoS and/or fair queueing
411#
412# CONFIG_NET_SCHED is not set
413
414#
415# Network testing
416#
417# CONFIG_NET_PKTGEN is not set
418# CONFIG_HAMRADIO is not set
419# CONFIG_IRDA is not set
420# CONFIG_BT is not set
421CONFIG_IEEE80211=m
422CONFIG_IEEE80211_DEBUG=y
423CONFIG_IEEE80211_CRYPT_WEP=m
424CONFIG_IEEE80211_CRYPT_CCMP=m
425CONFIG_IEEE80211_CRYPT_TKIP=m
426CONFIG_IEEE80211_SOFTMAC=m
427CONFIG_IEEE80211_SOFTMAC_DEBUG=y
428CONFIG_WIRELESS_EXT=y
429
430#
431# Device Drivers
432#
433
434#
435# Generic Driver Options
436#
437CONFIG_STANDALONE=y
438CONFIG_PREVENT_FIRMWARE_BUILD=y
439CONFIG_FW_LOADER=m
440# CONFIG_DEBUG_DRIVER is not set
441# CONFIG_SYS_HYPERVISOR is not set
442
443#
444# Connector - unified userspace <-> kernelspace linker
445#
446# CONFIG_CONNECTOR is not set
447
448#
449# Memory Technology Devices (MTD)
450#
451CONFIG_MTD=y
452# CONFIG_MTD_DEBUG is not set
453CONFIG_MTD_CONCAT=y
454CONFIG_MTD_PARTITIONS=y
455# CONFIG_MTD_REDBOOT_PARTS is not set
456# CONFIG_MTD_CMDLINE_PARTS is not set
457
458#
459# User Modules And Translation Layers
460#
461CONFIG_MTD_CHAR=y
462CONFIG_MTD_BLOCK=y
463# CONFIG_FTL is not set
464# CONFIG_NFTL is not set
465# CONFIG_INFTL is not set
466# CONFIG_RFD_FTL is not set
467# CONFIG_SSFDC is not set
468
469#
470# RAM/ROM/Flash chip drivers
471#
472CONFIG_MTD_CFI=y
473CONFIG_MTD_JEDECPROBE=y
474CONFIG_MTD_GEN_PROBE=y
475CONFIG_MTD_CFI_ADV_OPTIONS=y
476CONFIG_MTD_CFI_NOSWAP=y
477# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
478# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
479CONFIG_MTD_CFI_GEOMETRY=y
480CONFIG_MTD_MAP_BANK_WIDTH_1=y
481# CONFIG_MTD_MAP_BANK_WIDTH_2 is not set
482# CONFIG_MTD_MAP_BANK_WIDTH_4 is not set
483# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
484# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
485# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
486CONFIG_MTD_CFI_I1=y
487# CONFIG_MTD_CFI_I2 is not set
488# CONFIG_MTD_CFI_I4 is not set
489# CONFIG_MTD_CFI_I8 is not set
490# CONFIG_MTD_OTP is not set
491# CONFIG_MTD_CFI_INTELEXT is not set
492CONFIG_MTD_CFI_AMDSTD=y
493# CONFIG_MTD_CFI_STAA is not set
494CONFIG_MTD_CFI_UTIL=y
495# CONFIG_MTD_RAM is not set
496# CONFIG_MTD_ROM is not set
497# CONFIG_MTD_ABSENT is not set
498# CONFIG_MTD_OBSOLETE_CHIPS is not set
499
500#
501# Mapping drivers for chip access
502#
503# CONFIG_MTD_COMPLEX_MAPPINGS is not set
504CONFIG_MTD_PHYSMAP=y
505CONFIG_MTD_PHYSMAP_START=0xffc00000
506CONFIG_MTD_PHYSMAP_LEN=0x400000
507CONFIG_MTD_PHYSMAP_BANKWIDTH=1
508# CONFIG_MTD_PLATRAM is not set
509
510#
511# Self-contained MTD device drivers
512#
513# CONFIG_MTD_PMC551 is not set
514# CONFIG_MTD_SLRAM is not set
515# CONFIG_MTD_PHRAM is not set
516# CONFIG_MTD_MTDRAM is not set
517# CONFIG_MTD_BLOCK2MTD is not set
518
519#
520# Disk-On-Chip Device Drivers
521#
522# CONFIG_MTD_DOC2000 is not set
523# CONFIG_MTD_DOC2001 is not set
524# CONFIG_MTD_DOC2001PLUS is not set
525
526#
527# NAND Flash Device Drivers
528#
529# CONFIG_MTD_NAND is not set
530
531#
532# OneNAND Flash Device Drivers
533#
534# CONFIG_MTD_ONENAND is not set
535
536#
537# Parallel port support
538#
539# CONFIG_PARPORT is not set
540
541#
542# Plug and Play support
543#
544
545#
546# Block devices
547#
548# CONFIG_BLK_DEV_FD is not set
549# CONFIG_BLK_CPQ_DA is not set
550# CONFIG_BLK_CPQ_CISS_DA is not set
551# CONFIG_BLK_DEV_DAC960 is not set
552# CONFIG_BLK_DEV_UMEM is not set
553# CONFIG_BLK_DEV_COW_COMMON is not set
554CONFIG_BLK_DEV_LOOP=y
555# CONFIG_BLK_DEV_CRYPTOLOOP is not set
556# CONFIG_BLK_DEV_NBD is not set
557# CONFIG_BLK_DEV_SX8 is not set
558# CONFIG_BLK_DEV_UB is not set
559CONFIG_BLK_DEV_RAM=y
560CONFIG_BLK_DEV_RAM_COUNT=2
561CONFIG_BLK_DEV_RAM_SIZE=8192
562CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
563CONFIG_BLK_DEV_INITRD=y
564# CONFIG_CDROM_PKTCDVD is not set
565# CONFIG_ATA_OVER_ETH is not set
566
567#
568# Misc devices
569#
570# CONFIG_SGI_IOC4 is not set
571# CONFIG_TIFM_CORE is not set
572
573#
574# ATA/ATAPI/MFM/RLL support
575#
576# CONFIG_IDE is not set
577
578#
579# SCSI device support
580#
581# CONFIG_RAID_ATTRS is not set
582CONFIG_SCSI=y
583# CONFIG_SCSI_NETLINK is not set
584CONFIG_SCSI_PROC_FS=y
585
586#
587# SCSI support type (disk, tape, CD-ROM)
588#
589CONFIG_BLK_DEV_SD=y
590# CONFIG_CHR_DEV_ST is not set
591# CONFIG_CHR_DEV_OSST is not set
592# CONFIG_BLK_DEV_SR is not set
593CONFIG_CHR_DEV_SG=y
594# CONFIG_CHR_DEV_SCH is not set
595
596#
597# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
598#
599CONFIG_SCSI_MULTI_LUN=y
600# CONFIG_SCSI_CONSTANTS is not set
601# CONFIG_SCSI_LOGGING is not set
602
603#
604# SCSI Transports
605#
606# CONFIG_SCSI_SPI_ATTRS is not set
607# CONFIG_SCSI_FC_ATTRS is not set
608# CONFIG_SCSI_ISCSI_ATTRS is not set
609# CONFIG_SCSI_SAS_ATTRS is not set
610# CONFIG_SCSI_SAS_LIBSAS is not set
611
612#
613# SCSI low-level drivers
614#
615# CONFIG_ISCSI_TCP is not set
616# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
617# CONFIG_SCSI_3W_9XXX is not set
618# CONFIG_SCSI_ACARD is not set
619# CONFIG_SCSI_AACRAID is not set
620# CONFIG_SCSI_AIC7XXX is not set
621# CONFIG_SCSI_AIC7XXX_OLD is not set
622# CONFIG_SCSI_AIC79XX is not set
623# CONFIG_SCSI_AIC94XX is not set
624# CONFIG_SCSI_DPT_I2O is not set
625# CONFIG_SCSI_ARCMSR is not set
626# CONFIG_MEGARAID_NEWGEN is not set
627# CONFIG_MEGARAID_LEGACY is not set
628# CONFIG_MEGARAID_SAS is not set
629# CONFIG_SCSI_HPTIOP is not set
630# CONFIG_SCSI_BUSLOGIC is not set
631# CONFIG_SCSI_DMX3191D is not set
632# CONFIG_SCSI_EATA is not set
633# CONFIG_SCSI_FUTURE_DOMAIN is not set
634# CONFIG_SCSI_GDTH is not set
635# CONFIG_SCSI_IPS is not set
636# CONFIG_SCSI_INITIO is not set
637# CONFIG_SCSI_INIA100 is not set
638# CONFIG_SCSI_STEX is not set
639# CONFIG_SCSI_SYM53C8XX_2 is not set
640# CONFIG_SCSI_IPR is not set
641# CONFIG_SCSI_QLOGIC_1280 is not set
642# CONFIG_SCSI_QLA_FC is not set
643# CONFIG_SCSI_QLA_ISCSI is not set
644# CONFIG_SCSI_LPFC is not set
645# CONFIG_SCSI_DC395x is not set
646# CONFIG_SCSI_DC390T is not set
647# CONFIG_SCSI_NSP32 is not set
648# CONFIG_SCSI_DEBUG is not set
649
650#
651# Serial ATA (prod) and Parallel ATA (experimental) drivers
652#
653CONFIG_ATA=y
654# CONFIG_SATA_AHCI is not set
655# CONFIG_SATA_SVW is not set
656# CONFIG_ATA_PIIX is not set
657# CONFIG_SATA_MV is not set
658# CONFIG_SATA_NV is not set
659# CONFIG_PDC_ADMA is not set
660# CONFIG_SATA_QSTOR is not set
661# CONFIG_SATA_PROMISE is not set
662# CONFIG_SATA_SX4 is not set
663# CONFIG_SATA_SIL is not set
664# CONFIG_SATA_SIL24 is not set
665# CONFIG_SATA_SIS is not set
666# CONFIG_SATA_ULI is not set
667# CONFIG_SATA_VIA is not set
668# CONFIG_SATA_VITESSE is not set
669# CONFIG_PATA_ALI is not set
670# CONFIG_PATA_AMD is not set
671# CONFIG_PATA_ARTOP is not set
672# CONFIG_PATA_ATIIXP is not set
673# CONFIG_PATA_CMD64X is not set
674# CONFIG_PATA_CS5520 is not set
675# CONFIG_PATA_CS5530 is not set
676# CONFIG_PATA_CYPRESS is not set
677# CONFIG_PATA_EFAR is not set
678# CONFIG_ATA_GENERIC is not set
679# CONFIG_PATA_HPT366 is not set
680# CONFIG_PATA_HPT37X is not set
681# CONFIG_PATA_HPT3X2N is not set
682# CONFIG_PATA_HPT3X3 is not set
683# CONFIG_PATA_IT821X is not set
684# CONFIG_PATA_JMICRON is not set
685# CONFIG_PATA_TRIFLEX is not set
686# CONFIG_PATA_MPIIX is not set
687# CONFIG_PATA_OLDPIIX is not set
688# CONFIG_PATA_NETCELL is not set
689# CONFIG_PATA_NS87410 is not set
690# CONFIG_PATA_OPTI is not set
691# CONFIG_PATA_OPTIDMA is not set
692# CONFIG_PATA_PDC_OLD is not set
693# CONFIG_PATA_RADISYS is not set
694# CONFIG_PATA_RZ1000 is not set
695# CONFIG_PATA_SC1200 is not set
696# CONFIG_PATA_SERVERWORKS is not set
697# CONFIG_PATA_PDC2027X is not set
698CONFIG_PATA_SIL680=y
699# CONFIG_PATA_SIS is not set
700# CONFIG_PATA_VIA is not set
701# CONFIG_PATA_WINBOND is not set
702
703#
704# Multi-device support (RAID and LVM)
705#
706# CONFIG_MD is not set
707
708#
709# Fusion MPT device support
710#
711# CONFIG_FUSION is not set
712# CONFIG_FUSION_SPI is not set
713# CONFIG_FUSION_FC is not set
714# CONFIG_FUSION_SAS is not set
715
716#
717# IEEE 1394 (FireWire) support
718#
719# CONFIG_IEEE1394 is not set
720
721#
722# I2O device support
723#
724# CONFIG_I2O is not set
725
726#
727# Macintosh device drivers
728#
729# CONFIG_WINDFARM is not set
730
731#
732# Network device support
733#
734CONFIG_NETDEVICES=y
735# CONFIG_DUMMY is not set
736# CONFIG_BONDING is not set
737# CONFIG_EQUALIZER is not set
738CONFIG_TUN=m
739
740#
741# ARCnet devices
742#
743# CONFIG_ARCNET is not set
744
745#
746# PHY device support
747#
748
749#
750# Ethernet (10 or 100Mbit)
751#
752# CONFIG_NET_ETHERNET is not set
753
754#
755# Ethernet (1000 Mbit)
756#
757# CONFIG_ACENIC is not set
758# CONFIG_DL2K is not set
759# CONFIG_E1000 is not set
760# CONFIG_NS83820 is not set
761# CONFIG_HAMACHI is not set
762# CONFIG_YELLOWFIN is not set
763CONFIG_R8169=y
764# CONFIG_R8169_NAPI is not set
765# CONFIG_SIS190 is not set
766# CONFIG_SKGE is not set
767# CONFIG_SKY2 is not set
768# CONFIG_SK98LIN is not set
769# CONFIG_TIGON3 is not set
770# CONFIG_BNX2 is not set
771# CONFIG_QLA3XXX is not set
772
773#
774# Ethernet (10000 Mbit)
775#
776# CONFIG_CHELSIO_T1 is not set
777# CONFIG_IXGB is not set
778# CONFIG_S2IO is not set
779# CONFIG_MYRI10GE is not set
780
781#
782# Token Ring devices
783#
784# CONFIG_TR is not set
785
786#
787# Wireless LAN (non-hamradio)
788#
789CONFIG_NET_RADIO=y
790# CONFIG_NET_WIRELESS_RTNETLINK is not set
791
792#
793# Obsolete Wireless cards support (pre-802.11)
794#
795# CONFIG_STRIP is not set
796
797#
798# Wireless 802.11b ISA/PCI cards support
799#
800# CONFIG_IPW2100 is not set
801# CONFIG_IPW2200 is not set
802# CONFIG_AIRO is not set
803# CONFIG_HERMES is not set
804# CONFIG_ATMEL is not set
805
806#
807# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
808#
809# CONFIG_PRISM54 is not set
810# CONFIG_USB_ZD1201 is not set
811# CONFIG_HOSTAP is not set
812# CONFIG_BCM43XX is not set
813# CONFIG_ZD1211RW is not set
814CONFIG_NET_WIRELESS=y
815
816#
817# Wan interfaces
818#
819# CONFIG_WAN is not set
820# CONFIG_FDDI is not set
821# CONFIG_HIPPI is not set
822# CONFIG_PPP is not set
823# CONFIG_SLIP is not set
824# CONFIG_NET_FC is not set
825# CONFIG_SHAPER is not set
826CONFIG_NETCONSOLE=y
827CONFIG_NETPOLL=y
828# CONFIG_NETPOLL_RX is not set
829# CONFIG_NETPOLL_TRAP is not set
830CONFIG_NET_POLL_CONTROLLER=y
831
832#
833# ISDN subsystem
834#
835# CONFIG_ISDN is not set
836
837#
838# Telephony Support
839#
840# CONFIG_PHONE is not set
841
842#
843# Input device support
844#
845CONFIG_INPUT=y
846# CONFIG_INPUT_FF_MEMLESS is not set
847
848#
849# Userland interfaces
850#
851CONFIG_INPUT_MOUSEDEV=y
852# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
853CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
854CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
855# CONFIG_INPUT_JOYDEV is not set
856# CONFIG_INPUT_TSDEV is not set
857CONFIG_INPUT_EVDEV=m
858# CONFIG_INPUT_EVBUG is not set
859
860#
861# Input Device Drivers
862#
863# CONFIG_INPUT_KEYBOARD is not set
864# CONFIG_INPUT_MOUSE is not set
865# CONFIG_INPUT_JOYSTICK is not set
866# CONFIG_INPUT_TOUCHSCREEN is not set
867CONFIG_INPUT_MISC=y
868CONFIG_INPUT_UINPUT=m
869
870#
871# Hardware I/O ports
872#
873CONFIG_SERIO=y
874# CONFIG_SERIO_I8042 is not set
875CONFIG_SERIO_SERPORT=y
876# CONFIG_SERIO_PCIPS2 is not set
877# CONFIG_SERIO_RAW is not set
878# CONFIG_GAMEPORT is not set
879
880#
881# Character devices
882#
883CONFIG_VT=y
884CONFIG_VT_CONSOLE=y
885CONFIG_HW_CONSOLE=y
886# CONFIG_VT_HW_CONSOLE_BINDING is not set
887# CONFIG_SERIAL_NONSTANDARD is not set
888
889#
890# Serial drivers
891#
892CONFIG_SERIAL_8250=y
893CONFIG_SERIAL_8250_CONSOLE=y
894CONFIG_SERIAL_8250_PCI=y
895CONFIG_SERIAL_8250_NR_UARTS=4
896CONFIG_SERIAL_8250_RUNTIME_UARTS=4
897# CONFIG_SERIAL_8250_EXTENDED is not set
898
899#
900# Non-8250 serial port support
901#
902CONFIG_SERIAL_CORE=y
903CONFIG_SERIAL_CORE_CONSOLE=y
904# CONFIG_SERIAL_JSM is not set
905CONFIG_UNIX98_PTYS=y
906CONFIG_LEGACY_PTYS=y
907CONFIG_LEGACY_PTY_COUNT=256
908
909#
910# IPMI
911#
912# CONFIG_IPMI_HANDLER is not set
913
914#
915# Watchdog Cards
916#
917# CONFIG_WATCHDOG is not set
918CONFIG_HW_RANDOM=y
919# CONFIG_NVRAM is not set
920# CONFIG_GEN_RTC is not set
921# CONFIG_DTLK is not set
922# CONFIG_R3964 is not set
923# CONFIG_APPLICOM is not set
924
925#
926# Ftape, the floppy tape device driver
927#
928# CONFIG_AGP is not set
929# CONFIG_DRM is not set
930# CONFIG_RAW_DRIVER is not set
931
932#
933# TPM devices
934#
935# CONFIG_TCG_TPM is not set
936
937#
938# I2C support
939#
940CONFIG_I2C=y
941CONFIG_I2C_CHARDEV=y
942
943#
944# I2C Algorithms
945#
946# CONFIG_I2C_ALGOBIT is not set
947# CONFIG_I2C_ALGOPCF is not set
948# CONFIG_I2C_ALGOPCA is not set
949
950#
951# I2C Hardware Bus support
952#
953# CONFIG_I2C_ALI1535 is not set
954# CONFIG_I2C_ALI1563 is not set
955# CONFIG_I2C_ALI15X3 is not set
956# CONFIG_I2C_AMD756 is not set
957# CONFIG_I2C_AMD8111 is not set
958# CONFIG_I2C_I801 is not set
959# CONFIG_I2C_I810 is not set
960# CONFIG_I2C_PIIX4 is not set
961CONFIG_I2C_MPC=y
962# CONFIG_I2C_NFORCE2 is not set
963# CONFIG_I2C_OCORES is not set
964# CONFIG_I2C_PARPORT_LIGHT is not set
965# CONFIG_I2C_PROSAVAGE is not set
966# CONFIG_I2C_SAVAGE4 is not set
967# CONFIG_I2C_SIS5595 is not set
968# CONFIG_I2C_SIS630 is not set
969# CONFIG_I2C_SIS96X is not set
970# CONFIG_I2C_STUB is not set
971# CONFIG_I2C_VIA is not set
972# CONFIG_I2C_VIAPRO is not set
973# CONFIG_I2C_VOODOO3 is not set
974# CONFIG_I2C_PCA_ISA is not set
975
976#
977# Miscellaneous I2C Chip support
978#
979# CONFIG_SENSORS_DS1337 is not set
980# CONFIG_SENSORS_DS1374 is not set
981CONFIG_SENSORS_EEPROM=m
982# CONFIG_SENSORS_PCF8574 is not set
983# CONFIG_SENSORS_PCA9539 is not set
984# CONFIG_SENSORS_PCF8591 is not set
985# CONFIG_SENSORS_M41T00 is not set
986# CONFIG_SENSORS_MAX6875 is not set
987# CONFIG_I2C_DEBUG_CORE is not set
988# CONFIG_I2C_DEBUG_ALGO is not set
989# CONFIG_I2C_DEBUG_BUS is not set
990# CONFIG_I2C_DEBUG_CHIP is not set
991
992#
993# SPI support
994#
995# CONFIG_SPI is not set
996# CONFIG_SPI_MASTER is not set
997
998#
999# Dallas's 1-wire bus
1000#
1001# CONFIG_W1 is not set
1002
1003#
1004# Hardware Monitoring support
1005#
1006CONFIG_HWMON=y
1007# CONFIG_HWMON_VID is not set
1008# CONFIG_SENSORS_ABITUGURU is not set
1009# CONFIG_SENSORS_ADM1021 is not set
1010# CONFIG_SENSORS_ADM1025 is not set
1011# CONFIG_SENSORS_ADM1026 is not set
1012# CONFIG_SENSORS_ADM1031 is not set
1013# CONFIG_SENSORS_ADM9240 is not set
1014# CONFIG_SENSORS_ASB100 is not set
1015# CONFIG_SENSORS_ATXP1 is not set
1016# CONFIG_SENSORS_DS1621 is not set
1017# CONFIG_SENSORS_F71805F is not set
1018# CONFIG_SENSORS_FSCHER is not set
1019# CONFIG_SENSORS_FSCPOS is not set
1020# CONFIG_SENSORS_GL518SM is not set
1021# CONFIG_SENSORS_GL520SM is not set
1022# CONFIG_SENSORS_IT87 is not set
1023# CONFIG_SENSORS_LM63 is not set
1024# CONFIG_SENSORS_LM75 is not set
1025# CONFIG_SENSORS_LM77 is not set
1026# CONFIG_SENSORS_LM78 is not set
1027# CONFIG_SENSORS_LM80 is not set
1028# CONFIG_SENSORS_LM83 is not set
1029# CONFIG_SENSORS_LM85 is not set
1030# CONFIG_SENSORS_LM87 is not set
1031# CONFIG_SENSORS_LM90 is not set
1032# CONFIG_SENSORS_LM92 is not set
1033# CONFIG_SENSORS_MAX1619 is not set
1034# CONFIG_SENSORS_PC87360 is not set
1035# CONFIG_SENSORS_SIS5595 is not set
1036# CONFIG_SENSORS_SMSC47M1 is not set
1037# CONFIG_SENSORS_SMSC47M192 is not set
1038# CONFIG_SENSORS_SMSC47B397 is not set
1039# CONFIG_SENSORS_VIA686A is not set
1040# CONFIG_SENSORS_VT1211 is not set
1041# CONFIG_SENSORS_VT8231 is not set
1042# CONFIG_SENSORS_W83781D is not set
1043# CONFIG_SENSORS_W83791D is not set
1044# CONFIG_SENSORS_W83792D is not set
1045# CONFIG_SENSORS_W83L785TS is not set
1046# CONFIG_SENSORS_W83627HF is not set
1047# CONFIG_SENSORS_W83627EHF is not set
1048# CONFIG_HWMON_DEBUG_CHIP is not set
1049
1050#
1051# Multimedia devices
1052#
1053# CONFIG_VIDEO_DEV is not set
1054
1055#
1056# Digital Video Broadcasting Devices
1057#
1058# CONFIG_DVB is not set
1059# CONFIG_USB_DABUSB is not set
1060
1061#
1062# Graphics support
1063#
1064CONFIG_FIRMWARE_EDID=y
1065# CONFIG_FB is not set
1066
1067#
1068# Console display driver support
1069#
1070# CONFIG_VGA_CONSOLE is not set
1071CONFIG_DUMMY_CONSOLE=y
1072# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1073
1074#
1075# Sound
1076#
1077# CONFIG_SOUND is not set
1078
1079#
1080# USB support
1081#
1082CONFIG_USB_ARCH_HAS_HCD=y
1083CONFIG_USB_ARCH_HAS_OHCI=y
1084CONFIG_USB_ARCH_HAS_EHCI=y
1085CONFIG_USB=y
1086# CONFIG_USB_DEBUG is not set
1087
1088#
1089# Miscellaneous USB options
1090#
1091CONFIG_USB_DEVICEFS=y
1092# CONFIG_USB_BANDWIDTH is not set
1093# CONFIG_USB_DYNAMIC_MINORS is not set
1094# CONFIG_USB_OTG is not set
1095
1096#
1097# USB Host Controller Drivers
1098#
1099CONFIG_USB_EHCI_HCD=y
1100# CONFIG_USB_EHCI_SPLIT_ISO is not set
1101# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1102# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1103# CONFIG_USB_ISP116X_HCD is not set
1104CONFIG_USB_OHCI_HCD=y
1105# CONFIG_USB_OHCI_BIG_ENDIAN is not set
1106CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1107# CONFIG_USB_UHCI_HCD is not set
1108# CONFIG_USB_SL811_HCD is not set
1109
1110#
1111# USB Device Class drivers
1112#
1113# CONFIG_USB_ACM is not set
1114# CONFIG_USB_PRINTER is not set
1115
1116#
1117# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
1118#
1119
1120#
1121# may also be needed; see USB_STORAGE Help for more information
1122#
1123CONFIG_USB_STORAGE=m
1124# CONFIG_USB_STORAGE_DEBUG is not set
1125# CONFIG_USB_STORAGE_DATAFAB is not set
1126# CONFIG_USB_STORAGE_FREECOM is not set
1127# CONFIG_USB_STORAGE_DPCM is not set
1128# CONFIG_USB_STORAGE_USBAT is not set
1129# CONFIG_USB_STORAGE_SDDR09 is not set
1130# CONFIG_USB_STORAGE_SDDR55 is not set
1131# CONFIG_USB_STORAGE_JUMPSHOT is not set
1132# CONFIG_USB_STORAGE_ALAUDA is not set
1133# CONFIG_USB_STORAGE_ONETOUCH is not set
1134# CONFIG_USB_STORAGE_KARMA is not set
1135# CONFIG_USB_LIBUSUAL is not set
1136
1137#
1138# USB Input Devices
1139#
1140# CONFIG_USB_HID is not set
1141
1142#
1143# USB HID Boot Protocol drivers
1144#
1145# CONFIG_USB_KBD is not set
1146# CONFIG_USB_MOUSE is not set
1147# CONFIG_USB_AIPTEK is not set
1148# CONFIG_USB_WACOM is not set
1149# CONFIG_USB_ACECAD is not set
1150# CONFIG_USB_KBTAB is not set
1151# CONFIG_USB_POWERMATE is not set
1152# CONFIG_USB_TOUCHSCREEN is not set
1153# CONFIG_USB_YEALINK is not set
1154# CONFIG_USB_XPAD is not set
1155# CONFIG_USB_ATI_REMOTE is not set
1156# CONFIG_USB_ATI_REMOTE2 is not set
1157# CONFIG_USB_KEYSPAN_REMOTE is not set
1158# CONFIG_USB_APPLETOUCH is not set
1159
1160#
1161# USB Imaging devices
1162#
1163# CONFIG_USB_MDC800 is not set
1164# CONFIG_USB_MICROTEK is not set
1165
1166#
1167# USB Network Adapters
1168#
1169# CONFIG_USB_CATC is not set
1170# CONFIG_USB_KAWETH is not set
1171# CONFIG_USB_PEGASUS is not set
1172# CONFIG_USB_RTL8150 is not set
1173# CONFIG_USB_USBNET is not set
1174CONFIG_USB_MON=y
1175
1176#
1177# USB port drivers
1178#
1179
1180#
1181# USB Serial Converter support
1182#
1183CONFIG_USB_SERIAL=y
1184CONFIG_USB_SERIAL_CONSOLE=y
1185# CONFIG_USB_SERIAL_GENERIC is not set
1186# CONFIG_USB_SERIAL_AIRCABLE is not set
1187# CONFIG_USB_SERIAL_AIRPRIME is not set
1188# CONFIG_USB_SERIAL_ARK3116 is not set
1189# CONFIG_USB_SERIAL_BELKIN is not set
1190# CONFIG_USB_SERIAL_WHITEHEAT is not set
1191# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1192# CONFIG_USB_SERIAL_CP2101 is not set
1193# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1194# CONFIG_USB_SERIAL_EMPEG is not set
1195CONFIG_USB_SERIAL_FTDI_SIO=y
1196# CONFIG_USB_SERIAL_FUNSOFT is not set
1197# CONFIG_USB_SERIAL_VISOR is not set
1198# CONFIG_USB_SERIAL_IPAQ is not set
1199# CONFIG_USB_SERIAL_IR is not set
1200# CONFIG_USB_SERIAL_EDGEPORT is not set
1201# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1202# CONFIG_USB_SERIAL_GARMIN is not set
1203# CONFIG_USB_SERIAL_IPW is not set
1204# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1205# CONFIG_USB_SERIAL_KEYSPAN is not set
1206# CONFIG_USB_SERIAL_KLSI is not set
1207# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1208# CONFIG_USB_SERIAL_MCT_U232 is not set
1209# CONFIG_USB_SERIAL_MOS7720 is not set
1210# CONFIG_USB_SERIAL_MOS7840 is not set
1211# CONFIG_USB_SERIAL_NAVMAN is not set
1212# CONFIG_USB_SERIAL_PL2303 is not set
1213# CONFIG_USB_SERIAL_HP4X is not set
1214# CONFIG_USB_SERIAL_SAFE is not set
1215# CONFIG_USB_SERIAL_SIERRAWIRELESS is not set
1216# CONFIG_USB_SERIAL_TI is not set
1217# CONFIG_USB_SERIAL_CYBERJACK is not set
1218# CONFIG_USB_SERIAL_XIRCOM is not set
1219# CONFIG_USB_SERIAL_OPTION is not set
1220# CONFIG_USB_SERIAL_OMNINET is not set
1221
1222#
1223# USB Miscellaneous drivers
1224#
1225# CONFIG_USB_EMI62 is not set
1226# CONFIG_USB_EMI26 is not set
1227# CONFIG_USB_ADUTUX is not set
1228# CONFIG_USB_AUERSWALD is not set
1229# CONFIG_USB_RIO500 is not set
1230# CONFIG_USB_LEGOTOWER is not set
1231# CONFIG_USB_LCD is not set
1232# CONFIG_USB_LED is not set
1233# CONFIG_USB_CYPRESS_CY7C63 is not set
1234# CONFIG_USB_CYTHERM is not set
1235# CONFIG_USB_PHIDGET is not set
1236# CONFIG_USB_IDMOUSE is not set
1237# CONFIG_USB_FTDI_ELAN is not set
1238# CONFIG_USB_APPLEDISPLAY is not set
1239# CONFIG_USB_SISUSBVGA is not set
1240# CONFIG_USB_LD is not set
1241# CONFIG_USB_TRANCEVIBRATOR is not set
1242# CONFIG_USB_TEST is not set
1243
1244#
1245# USB DSL modem support
1246#
1247
1248#
1249# USB Gadget Support
1250#
1251# CONFIG_USB_GADGET is not set
1252
1253#
1254# MMC/SD Card support
1255#
1256# CONFIG_MMC is not set
1257
1258#
1259# LED devices
1260#
1261# CONFIG_NEW_LEDS is not set
1262
1263#
1264# LED drivers
1265#
1266
1267#
1268# LED Triggers
1269#
1270
1271#
1272# InfiniBand support
1273#
1274# CONFIG_INFINIBAND is not set
1275
1276#
1277# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1278#
1279
1280#
1281# Real Time Clock
1282#
1283CONFIG_RTC_LIB=y
1284CONFIG_RTC_CLASS=y
1285CONFIG_RTC_HCTOSYS=y
1286CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
1287# CONFIG_RTC_DEBUG is not set
1288
1289#
1290# RTC interfaces
1291#
1292CONFIG_RTC_INTF_SYSFS=y
1293CONFIG_RTC_INTF_PROC=y
1294CONFIG_RTC_INTF_DEV=y
1295# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1296
1297#
1298# RTC drivers
1299#
1300# CONFIG_RTC_DRV_X1205 is not set
1301# CONFIG_RTC_DRV_DS1307 is not set
1302# CONFIG_RTC_DRV_DS1553 is not set
1303# CONFIG_RTC_DRV_ISL1208 is not set
1304# CONFIG_RTC_DRV_DS1672 is not set
1305# CONFIG_RTC_DRV_DS1742 is not set
1306# CONFIG_RTC_DRV_PCF8563 is not set
1307# CONFIG_RTC_DRV_PCF8583 is not set
1308CONFIG_RTC_DRV_RS5C372=y
1309# CONFIG_RTC_DRV_M48T86 is not set
1310# CONFIG_RTC_DRV_TEST is not set
1311# CONFIG_RTC_DRV_V3020 is not set
1312
1313#
1314# DMA Engine support
1315#
1316# CONFIG_DMA_ENGINE is not set
1317
1318#
1319# DMA Clients
1320#
1321
1322#
1323# DMA Devices
1324#
1325
1326#
1327# File systems
1328#
1329CONFIG_EXT2_FS=y
1330# CONFIG_EXT2_FS_XATTR is not set
1331# CONFIG_EXT2_FS_XIP is not set
1332CONFIG_EXT3_FS=y
1333CONFIG_EXT3_FS_XATTR=y
1334# CONFIG_EXT3_FS_POSIX_ACL is not set
1335# CONFIG_EXT3_FS_SECURITY is not set
1336# CONFIG_EXT4DEV_FS is not set
1337CONFIG_JBD=y
1338# CONFIG_JBD_DEBUG is not set
1339CONFIG_FS_MBCACHE=y
1340# CONFIG_REISERFS_FS is not set
1341# CONFIG_JFS_FS is not set
1342CONFIG_FS_POSIX_ACL=y
1343# CONFIG_XFS_FS is not set
1344# CONFIG_GFS2_FS is not set
1345# CONFIG_OCFS2_FS is not set
1346# CONFIG_MINIX_FS is not set
1347# CONFIG_ROMFS_FS is not set
1348CONFIG_INOTIFY=y
1349CONFIG_INOTIFY_USER=y
1350# CONFIG_QUOTA is not set
1351CONFIG_DNOTIFY=y
1352# CONFIG_AUTOFS_FS is not set
1353# CONFIG_AUTOFS4_FS is not set
1354# CONFIG_FUSE_FS is not set
1355
1356#
1357# CD-ROM/DVD Filesystems
1358#
1359CONFIG_ISO9660_FS=m
1360CONFIG_JOLIET=y
1361CONFIG_ZISOFS=y
1362CONFIG_ZISOFS_FS=m
1363CONFIG_UDF_FS=m
1364CONFIG_UDF_NLS=y
1365
1366#
1367# DOS/FAT/NT Filesystems
1368#
1369CONFIG_FAT_FS=m
1370CONFIG_MSDOS_FS=m
1371CONFIG_VFAT_FS=m
1372CONFIG_FAT_DEFAULT_CODEPAGE=437
1373CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1374CONFIG_NTFS_FS=m
1375# CONFIG_NTFS_DEBUG is not set
1376# CONFIG_NTFS_RW is not set
1377
1378#
1379# Pseudo filesystems
1380#
1381CONFIG_PROC_FS=y
1382CONFIG_PROC_KCORE=y
1383CONFIG_PROC_SYSCTL=y
1384CONFIG_SYSFS=y
1385CONFIG_TMPFS=y
1386# CONFIG_TMPFS_POSIX_ACL is not set
1387# CONFIG_HUGETLB_PAGE is not set
1388CONFIG_RAMFS=y
1389# CONFIG_CONFIGFS_FS is not set
1390
1391#
1392# Miscellaneous filesystems
1393#
1394# CONFIG_ADFS_FS is not set
1395# CONFIG_AFFS_FS is not set
1396# CONFIG_HFS_FS is not set
1397# CONFIG_HFSPLUS_FS is not set
1398# CONFIG_BEFS_FS is not set
1399# CONFIG_BFS_FS is not set
1400# CONFIG_EFS_FS is not set
1401# CONFIG_JFFS_FS is not set
1402# CONFIG_JFFS2_FS is not set
1403# CONFIG_CRAMFS is not set
1404# CONFIG_VXFS_FS is not set
1405# CONFIG_HPFS_FS is not set
1406# CONFIG_QNX4FS_FS is not set
1407# CONFIG_SYSV_FS is not set
1408# CONFIG_UFS_FS is not set
1409
1410#
1411# Network File Systems
1412#
1413CONFIG_NFS_FS=y
1414CONFIG_NFS_V3=y
1415CONFIG_NFS_V3_ACL=y
1416CONFIG_NFS_V4=y
1417# CONFIG_NFS_DIRECTIO is not set
1418CONFIG_NFSD=m
1419CONFIG_NFSD_V3=y
1420# CONFIG_NFSD_V3_ACL is not set
1421# CONFIG_NFSD_V4 is not set
1422CONFIG_NFSD_TCP=y
1423CONFIG_ROOT_NFS=y
1424CONFIG_LOCKD=y
1425CONFIG_LOCKD_V4=y
1426CONFIG_EXPORTFS=m
1427CONFIG_NFS_ACL_SUPPORT=y
1428CONFIG_NFS_COMMON=y
1429CONFIG_SUNRPC=y
1430CONFIG_SUNRPC_GSS=y
1431CONFIG_RPCSEC_GSS_KRB5=y
1432# CONFIG_RPCSEC_GSS_SPKM3 is not set
1433# CONFIG_SMB_FS is not set
1434# CONFIG_CIFS is not set
1435# CONFIG_NCP_FS is not set
1436# CONFIG_CODA_FS is not set
1437# CONFIG_AFS_FS is not set
1438# CONFIG_9P_FS is not set
1439
1440#
1441# Partition Types
1442#
1443# CONFIG_PARTITION_ADVANCED is not set
1444CONFIG_MSDOS_PARTITION=y
1445
1446#
1447# Native Language Support
1448#
1449CONFIG_NLS=m
1450CONFIG_NLS_DEFAULT="iso8859-1"
1451CONFIG_NLS_CODEPAGE_437=m
1452# CONFIG_NLS_CODEPAGE_737 is not set
1453# CONFIG_NLS_CODEPAGE_775 is not set
1454# CONFIG_NLS_CODEPAGE_850 is not set
1455# CONFIG_NLS_CODEPAGE_852 is not set
1456# CONFIG_NLS_CODEPAGE_855 is not set
1457# CONFIG_NLS_CODEPAGE_857 is not set
1458# CONFIG_NLS_CODEPAGE_860 is not set
1459# CONFIG_NLS_CODEPAGE_861 is not set
1460# CONFIG_NLS_CODEPAGE_862 is not set
1461# CONFIG_NLS_CODEPAGE_863 is not set
1462# CONFIG_NLS_CODEPAGE_864 is not set
1463# CONFIG_NLS_CODEPAGE_865 is not set
1464# CONFIG_NLS_CODEPAGE_866 is not set
1465# CONFIG_NLS_CODEPAGE_869 is not set
1466# CONFIG_NLS_CODEPAGE_936 is not set
1467# CONFIG_NLS_CODEPAGE_950 is not set
1468# CONFIG_NLS_CODEPAGE_932 is not set
1469# CONFIG_NLS_CODEPAGE_949 is not set
1470# CONFIG_NLS_CODEPAGE_874 is not set
1471# CONFIG_NLS_ISO8859_8 is not set
1472# CONFIG_NLS_CODEPAGE_1250 is not set
1473# CONFIG_NLS_CODEPAGE_1251 is not set
1474# CONFIG_NLS_ASCII is not set
1475CONFIG_NLS_ISO8859_1=m
1476# CONFIG_NLS_ISO8859_2 is not set
1477# CONFIG_NLS_ISO8859_3 is not set
1478# CONFIG_NLS_ISO8859_4 is not set
1479# CONFIG_NLS_ISO8859_5 is not set
1480# CONFIG_NLS_ISO8859_6 is not set
1481# CONFIG_NLS_ISO8859_7 is not set
1482# CONFIG_NLS_ISO8859_9 is not set
1483# CONFIG_NLS_ISO8859_13 is not set
1484# CONFIG_NLS_ISO8859_14 is not set
1485# CONFIG_NLS_ISO8859_15 is not set
1486# CONFIG_NLS_KOI8_R is not set
1487# CONFIG_NLS_KOI8_U is not set
1488CONFIG_NLS_UTF8=m
1489
1490#
1491# Library routines
1492#
1493# CONFIG_CRC_CCITT is not set
1494# CONFIG_CRC16 is not set
1495CONFIG_CRC32=y
1496CONFIG_LIBCRC32C=m
1497CONFIG_ZLIB_INFLATE=m
1498CONFIG_ZLIB_DEFLATE=m
1499CONFIG_PLIST=y
1500
1501#
1502# Instrumentation Support
1503#
1504CONFIG_PROFILING=y
1505CONFIG_OPROFILE=m
1506
1507#
1508# Kernel hacking
1509#
1510# CONFIG_PRINTK_TIME is not set
1511CONFIG_ENABLE_MUST_CHECK=y
1512CONFIG_MAGIC_SYSRQ=y
1513# CONFIG_UNUSED_SYMBOLS is not set
1514CONFIG_DEBUG_KERNEL=y
1515CONFIG_LOG_BUF_SHIFT=14
1516CONFIG_DETECT_SOFTLOCKUP=y
1517# CONFIG_SCHEDSTATS is not set
1518# CONFIG_DEBUG_SLAB is not set
1519# CONFIG_DEBUG_RT_MUTEXES is not set
1520# CONFIG_RT_MUTEX_TESTER is not set
1521# CONFIG_DEBUG_SPINLOCK is not set
1522# CONFIG_DEBUG_MUTEXES is not set
1523# CONFIG_DEBUG_RWSEMS is not set
1524# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1525# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1526# CONFIG_DEBUG_KOBJECT is not set
1527# CONFIG_DEBUG_INFO is not set
1528# CONFIG_DEBUG_FS is not set
1529# CONFIG_DEBUG_VM is not set
1530# CONFIG_DEBUG_LIST is not set
1531CONFIG_FORCED_INLINING=y
1532# CONFIG_HEADERS_CHECK is not set
1533# CONFIG_RCU_TORTURE_TEST is not set
1534# CONFIG_DEBUGGER is not set
1535# CONFIG_BDI_SWITCH is not set
1536# CONFIG_BOOTX_TEXT is not set
1537# CONFIG_SERIAL_TEXT_DEBUG is not set
1538# CONFIG_PPC_EARLY_DEBUG is not set
1539
1540#
1541# Security options
1542#
1543# CONFIG_KEYS is not set
1544# CONFIG_SECURITY is not set
1545
1546#
1547# Cryptographic options
1548#
1549CONFIG_CRYPTO=y
1550CONFIG_CRYPTO_ALGAPI=y
1551CONFIG_CRYPTO_BLKCIPHER=y
1552CONFIG_CRYPTO_MANAGER=y
1553# CONFIG_CRYPTO_HMAC is not set
1554# CONFIG_CRYPTO_NULL is not set
1555CONFIG_CRYPTO_MD4=m
1556CONFIG_CRYPTO_MD5=y
1557CONFIG_CRYPTO_SHA1=m
1558# CONFIG_CRYPTO_SHA256 is not set
1559# CONFIG_CRYPTO_SHA512 is not set
1560# CONFIG_CRYPTO_WP512 is not set
1561# CONFIG_CRYPTO_TGR192 is not set
1562CONFIG_CRYPTO_ECB=m
1563CONFIG_CRYPTO_CBC=y
1564CONFIG_CRYPTO_DES=y
1565CONFIG_CRYPTO_BLOWFISH=m
1566CONFIG_CRYPTO_TWOFISH=m
1567CONFIG_CRYPTO_TWOFISH_COMMON=m
1568CONFIG_CRYPTO_SERPENT=m
1569CONFIG_CRYPTO_AES=m
1570# CONFIG_CRYPTO_CAST5 is not set
1571# CONFIG_CRYPTO_CAST6 is not set
1572# CONFIG_CRYPTO_TEA is not set
1573CONFIG_CRYPTO_ARC4=m
1574# CONFIG_CRYPTO_KHAZAD is not set
1575# CONFIG_CRYPTO_ANUBIS is not set
1576CONFIG_CRYPTO_DEFLATE=m
1577CONFIG_CRYPTO_MICHAEL_MIC=m
1578CONFIG_CRYPTO_CRC32C=m
1579# CONFIG_CRYPTO_TEST is not set
1580
1581#
1582# Hardware crypto devices
1583#
diff --git a/arch/powerpc/configs/lite5200_defconfig b/arch/powerpc/configs/lite5200_defconfig
new file mode 100644
index 000000000000..ee7655776d45
--- /dev/null
+++ b/arch/powerpc/configs/lite5200_defconfig
@@ -0,0 +1,931 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc6
4# Mon Nov 27 11:08:20 2006
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_FIND_NEXT_BIT=y
16CONFIG_PPC=y
17CONFIG_EARLY_PRINTK=y
18CONFIG_GENERIC_NVRAM=y
19CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
20CONFIG_ARCH_MAY_HAVE_PC_FDC=y
21CONFIG_PPC_OF=y
22# CONFIG_PPC_UDBG_16550 is not set
23# CONFIG_GENERIC_TBSYNC is not set
24CONFIG_AUDIT_ARCH=y
25# CONFIG_DEFAULT_UIMAGE is not set
26
27#
28# Processor support
29#
30CONFIG_CLASSIC32=y
31# CONFIG_PPC_52xx is not set
32# CONFIG_PPC_82xx is not set
33# CONFIG_PPC_83xx is not set
34# CONFIG_PPC_85xx is not set
35# CONFIG_PPC_86xx is not set
36# CONFIG_40x is not set
37# CONFIG_44x is not set
38# CONFIG_8xx is not set
39# CONFIG_E200 is not set
40CONFIG_6xx=y
41CONFIG_PPC_FPU=y
42# CONFIG_PPC_DCR_NATIVE is not set
43# CONFIG_PPC_DCR_MMIO is not set
44# CONFIG_ALTIVEC is not set
45CONFIG_PPC_STD_MMU=y
46CONFIG_PPC_STD_MMU_32=y
47# CONFIG_SMP is not set
48CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
49
50#
51# Code maturity level options
52#
53CONFIG_EXPERIMENTAL=y
54CONFIG_BROKEN_ON_SMP=y
55CONFIG_INIT_ENV_ARG_LIMIT=32
56
57#
58# General setup
59#
60CONFIG_LOCALVERSION=""
61CONFIG_LOCALVERSION_AUTO=y
62CONFIG_SWAP=y
63CONFIG_SYSVIPC=y
64# CONFIG_IPC_NS is not set
65# CONFIG_POSIX_MQUEUE is not set
66# CONFIG_BSD_PROCESS_ACCT is not set
67# CONFIG_TASKSTATS is not set
68# CONFIG_UTS_NS is not set
69# CONFIG_AUDIT is not set
70# CONFIG_IKCONFIG is not set
71# CONFIG_RELAY is not set
72CONFIG_INITRAMFS_SOURCE=""
73# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
74CONFIG_SYSCTL=y
75CONFIG_EMBEDDED=y
76# CONFIG_SYSCTL_SYSCALL is not set
77# CONFIG_KALLSYMS is not set
78CONFIG_HOTPLUG=y
79CONFIG_PRINTK=y
80CONFIG_BUG=y
81CONFIG_ELF_CORE=y
82CONFIG_BASE_FULL=y
83CONFIG_FUTEX=y
84# CONFIG_EPOLL is not set
85CONFIG_SHMEM=y
86CONFIG_SLAB=y
87CONFIG_VM_EVENT_COUNTERS=y
88CONFIG_RT_MUTEXES=y
89# CONFIG_TINY_SHMEM is not set
90CONFIG_BASE_SMALL=0
91# CONFIG_SLOB is not set
92
93#
94# Loadable module support
95#
96CONFIG_MODULES=y
97CONFIG_MODULE_UNLOAD=y
98# CONFIG_MODULE_FORCE_UNLOAD is not set
99# CONFIG_MODVERSIONS is not set
100# CONFIG_MODULE_SRCVERSION_ALL is not set
101# CONFIG_KMOD is not set
102
103#
104# Block layer
105#
106CONFIG_BLOCK=y
107# CONFIG_LBD is not set
108# CONFIG_BLK_DEV_IO_TRACE is not set
109# CONFIG_LSF is not set
110
111#
112# IO Schedulers
113#
114CONFIG_IOSCHED_NOOP=y
115CONFIG_IOSCHED_AS=y
116CONFIG_IOSCHED_DEADLINE=y
117CONFIG_IOSCHED_CFQ=y
118CONFIG_DEFAULT_AS=y
119# CONFIG_DEFAULT_DEADLINE is not set
120# CONFIG_DEFAULT_CFQ is not set
121# CONFIG_DEFAULT_NOOP is not set
122CONFIG_DEFAULT_IOSCHED="anticipatory"
123
124#
125# Platform support
126#
127CONFIG_PPC_MULTIPLATFORM=y
128# CONFIG_EMBEDDED6xx is not set
129# CONFIG_APUS is not set
130# CONFIG_PPC_CHRP is not set
131CONFIG_PPC_MPC52xx=y
132# CONFIG_PPC_EFIKA is not set
133CONFIG_PPC_LITE5200=y
134# CONFIG_PPC_PMAC is not set
135# CONFIG_PPC_CELL is not set
136# CONFIG_PPC_CELL_NATIVE is not set
137# CONFIG_PPC_RTAS is not set
138# CONFIG_MMIO_NVRAM is not set
139# CONFIG_PPC_MPC106 is not set
140# CONFIG_PPC_970_NAP is not set
141# CONFIG_PPC_INDIRECT_IO is not set
142# CONFIG_GENERIC_IOMAP is not set
143# CONFIG_CPU_FREQ is not set
144# CONFIG_TAU is not set
145# CONFIG_WANT_EARLY_SERIAL is not set
146# CONFIG_MPIC is not set
147
148#
149# Kernel options
150#
151# CONFIG_HIGHMEM is not set
152# CONFIG_HZ_100 is not set
153CONFIG_HZ_250=y
154# CONFIG_HZ_1000 is not set
155CONFIG_HZ=250
156CONFIG_PREEMPT_NONE=y
157# CONFIG_PREEMPT_VOLUNTARY is not set
158# CONFIG_PREEMPT is not set
159CONFIG_BINFMT_ELF=y
160# CONFIG_BINFMT_MISC is not set
161CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
162# CONFIG_KEXEC is not set
163CONFIG_ARCH_FLATMEM_ENABLE=y
164CONFIG_ARCH_POPULATES_NODE_MAP=y
165CONFIG_SELECT_MEMORY_MODEL=y
166CONFIG_FLATMEM_MANUAL=y
167# CONFIG_DISCONTIGMEM_MANUAL is not set
168# CONFIG_SPARSEMEM_MANUAL is not set
169CONFIG_FLATMEM=y
170CONFIG_FLAT_NODE_MEM_MAP=y
171# CONFIG_SPARSEMEM_STATIC is not set
172CONFIG_SPLIT_PTLOCK_CPUS=4
173# CONFIG_RESOURCES_64BIT is not set
174CONFIG_PROC_DEVICETREE=y
175# CONFIG_CMDLINE_BOOL is not set
176CONFIG_PM=y
177# CONFIG_PM_LEGACY is not set
178# CONFIG_PM_DEBUG is not set
179# CONFIG_PM_SYSFS_DEPRECATED is not set
180# CONFIG_SOFTWARE_SUSPEND is not set
181CONFIG_SECCOMP=y
182CONFIG_ISA_DMA_API=y
183
184#
185# Bus options
186#
187CONFIG_GENERIC_ISA_DMA=y
188# CONFIG_MPIC_WEIRD is not set
189# CONFIG_PPC_I8259 is not set
190# CONFIG_PPC_INDIRECT_PCI is not set
191CONFIG_PCI=y
192CONFIG_PCI_DOMAINS=y
193# CONFIG_PCIEPORTBUS is not set
194# CONFIG_PCI_DEBUG is not set
195
196#
197# PCCARD (PCMCIA/CardBus) support
198#
199# CONFIG_PCCARD is not set
200
201#
202# PCI Hotplug Support
203#
204# CONFIG_HOTPLUG_PCI is not set
205
206#
207# Advanced setup
208#
209# CONFIG_ADVANCED_OPTIONS is not set
210
211#
212# Default settings for advanced configuration options are used
213#
214CONFIG_HIGHMEM_START=0xfe000000
215CONFIG_LOWMEM_SIZE=0x30000000
216CONFIG_KERNEL_START=0xc0000000
217CONFIG_TASK_SIZE=0x80000000
218CONFIG_BOOT_LOAD=0x00800000
219
220#
221# Networking
222#
223CONFIG_NET=y
224
225#
226# Networking options
227#
228# CONFIG_NETDEBUG is not set
229CONFIG_PACKET=y
230# CONFIG_PACKET_MMAP is not set
231CONFIG_UNIX=y
232CONFIG_XFRM=y
233CONFIG_XFRM_USER=m
234# CONFIG_XFRM_SUB_POLICY is not set
235# CONFIG_NET_KEY is not set
236CONFIG_INET=y
237CONFIG_IP_MULTICAST=y
238# CONFIG_IP_ADVANCED_ROUTER is not set
239CONFIG_IP_FIB_HASH=y
240CONFIG_IP_PNP=y
241CONFIG_IP_PNP_DHCP=y
242CONFIG_IP_PNP_BOOTP=y
243# CONFIG_IP_PNP_RARP is not set
244# CONFIG_NET_IPIP is not set
245# CONFIG_NET_IPGRE is not set
246# CONFIG_IP_MROUTE is not set
247# CONFIG_ARPD is not set
248CONFIG_SYN_COOKIES=y
249# CONFIG_INET_AH is not set
250# CONFIG_INET_ESP is not set
251# CONFIG_INET_IPCOMP is not set
252# CONFIG_INET_XFRM_TUNNEL is not set
253# CONFIG_INET_TUNNEL is not set
254CONFIG_INET_XFRM_MODE_TRANSPORT=y
255CONFIG_INET_XFRM_MODE_TUNNEL=y
256CONFIG_INET_XFRM_MODE_BEET=y
257CONFIG_INET_DIAG=y
258CONFIG_INET_TCP_DIAG=y
259# CONFIG_TCP_CONG_ADVANCED is not set
260CONFIG_TCP_CONG_CUBIC=y
261CONFIG_DEFAULT_TCP_CONG="cubic"
262# CONFIG_IPV6 is not set
263# CONFIG_INET6_XFRM_TUNNEL is not set
264# CONFIG_INET6_TUNNEL is not set
265# CONFIG_NETWORK_SECMARK is not set
266# CONFIG_NETFILTER is not set
267
268#
269# DCCP Configuration (EXPERIMENTAL)
270#
271# CONFIG_IP_DCCP is not set
272
273#
274# SCTP Configuration (EXPERIMENTAL)
275#
276# CONFIG_IP_SCTP is not set
277
278#
279# TIPC Configuration (EXPERIMENTAL)
280#
281# CONFIG_TIPC is not set
282# CONFIG_ATM is not set
283# CONFIG_BRIDGE is not set
284# CONFIG_VLAN_8021Q is not set
285# CONFIG_DECNET is not set
286# CONFIG_LLC2 is not set
287# CONFIG_IPX is not set
288# CONFIG_ATALK is not set
289# CONFIG_X25 is not set
290# CONFIG_LAPB is not set
291# CONFIG_ECONET is not set
292# CONFIG_WAN_ROUTER is not set
293
294#
295# QoS and/or fair queueing
296#
297# CONFIG_NET_SCHED is not set
298
299#
300# Network testing
301#
302# CONFIG_NET_PKTGEN is not set
303# CONFIG_HAMRADIO is not set
304# CONFIG_IRDA is not set
305# CONFIG_BT is not set
306# CONFIG_IEEE80211 is not set
307
308#
309# Device Drivers
310#
311
312#
313# Generic Driver Options
314#
315CONFIG_STANDALONE=y
316CONFIG_PREVENT_FIRMWARE_BUILD=y
317# CONFIG_FW_LOADER is not set
318# CONFIG_DEBUG_DRIVER is not set
319# CONFIG_SYS_HYPERVISOR is not set
320
321#
322# Connector - unified userspace <-> kernelspace linker
323#
324# CONFIG_CONNECTOR is not set
325
326#
327# Memory Technology Devices (MTD)
328#
329# CONFIG_MTD is not set
330
331#
332# Parallel port support
333#
334# CONFIG_PARPORT is not set
335
336#
337# Plug and Play support
338#
339
340#
341# Block devices
342#
343# CONFIG_BLK_DEV_FD is not set
344# CONFIG_BLK_CPQ_DA is not set
345# CONFIG_BLK_CPQ_CISS_DA is not set
346# CONFIG_BLK_DEV_DAC960 is not set
347# CONFIG_BLK_DEV_UMEM is not set
348# CONFIG_BLK_DEV_COW_COMMON is not set
349CONFIG_BLK_DEV_LOOP=y
350# CONFIG_BLK_DEV_CRYPTOLOOP is not set
351# CONFIG_BLK_DEV_NBD is not set
352# CONFIG_BLK_DEV_SX8 is not set
353CONFIG_BLK_DEV_RAM=y
354CONFIG_BLK_DEV_RAM_COUNT=16
355CONFIG_BLK_DEV_RAM_SIZE=32768
356CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
357CONFIG_BLK_DEV_INITRD=y
358# CONFIG_CDROM_PKTCDVD is not set
359# CONFIG_ATA_OVER_ETH is not set
360
361#
362# Misc devices
363#
364# CONFIG_SGI_IOC4 is not set
365# CONFIG_TIFM_CORE is not set
366
367#
368# ATA/ATAPI/MFM/RLL support
369#
370# CONFIG_IDE is not set
371
372#
373# SCSI device support
374#
375# CONFIG_RAID_ATTRS is not set
376CONFIG_SCSI=y
377# CONFIG_SCSI_NETLINK is not set
378# CONFIG_SCSI_PROC_FS is not set
379
380#
381# SCSI support type (disk, tape, CD-ROM)
382#
383# CONFIG_BLK_DEV_SD is not set
384# CONFIG_CHR_DEV_ST is not set
385# CONFIG_CHR_DEV_OSST is not set
386# CONFIG_BLK_DEV_SR is not set
387# CONFIG_CHR_DEV_SG is not set
388# CONFIG_CHR_DEV_SCH is not set
389
390#
391# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
392#
393# CONFIG_SCSI_MULTI_LUN is not set
394# CONFIG_SCSI_CONSTANTS is not set
395# CONFIG_SCSI_LOGGING is not set
396
397#
398# SCSI Transports
399#
400# CONFIG_SCSI_SPI_ATTRS is not set
401# CONFIG_SCSI_FC_ATTRS is not set
402# CONFIG_SCSI_ISCSI_ATTRS is not set
403# CONFIG_SCSI_SAS_ATTRS is not set
404# CONFIG_SCSI_SAS_LIBSAS is not set
405
406#
407# SCSI low-level drivers
408#
409# CONFIG_ISCSI_TCP is not set
410# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
411# CONFIG_SCSI_3W_9XXX is not set
412# CONFIG_SCSI_ACARD is not set
413# CONFIG_SCSI_AACRAID is not set
414# CONFIG_SCSI_AIC7XXX is not set
415# CONFIG_SCSI_AIC7XXX_OLD is not set
416# CONFIG_SCSI_AIC79XX is not set
417# CONFIG_SCSI_AIC94XX is not set
418# CONFIG_SCSI_DPT_I2O is not set
419# CONFIG_SCSI_ARCMSR is not set
420# CONFIG_MEGARAID_NEWGEN is not set
421# CONFIG_MEGARAID_LEGACY is not set
422# CONFIG_MEGARAID_SAS is not set
423# CONFIG_SCSI_HPTIOP is not set
424# CONFIG_SCSI_BUSLOGIC is not set
425# CONFIG_SCSI_DMX3191D is not set
426# CONFIG_SCSI_EATA is not set
427# CONFIG_SCSI_FUTURE_DOMAIN is not set
428# CONFIG_SCSI_GDTH is not set
429# CONFIG_SCSI_IPS is not set
430# CONFIG_SCSI_INITIO is not set
431# CONFIG_SCSI_INIA100 is not set
432# CONFIG_SCSI_STEX is not set
433# CONFIG_SCSI_SYM53C8XX_2 is not set
434# CONFIG_SCSI_IPR is not set
435# CONFIG_SCSI_QLOGIC_1280 is not set
436# CONFIG_SCSI_QLA_FC is not set
437# CONFIG_SCSI_QLA_ISCSI is not set
438# CONFIG_SCSI_LPFC is not set
439# CONFIG_SCSI_DC395x is not set
440# CONFIG_SCSI_DC390T is not set
441# CONFIG_SCSI_NSP32 is not set
442# CONFIG_SCSI_DEBUG is not set
443
444#
445# Serial ATA (prod) and Parallel ATA (experimental) drivers
446#
447CONFIG_ATA=y
448# CONFIG_SATA_AHCI is not set
449# CONFIG_SATA_SVW is not set
450# CONFIG_ATA_PIIX is not set
451# CONFIG_SATA_MV is not set
452# CONFIG_SATA_NV is not set
453# CONFIG_PDC_ADMA is not set
454# CONFIG_SATA_QSTOR is not set
455# CONFIG_SATA_PROMISE is not set
456# CONFIG_SATA_SX4 is not set
457# CONFIG_SATA_SIL is not set
458# CONFIG_SATA_SIL24 is not set
459# CONFIG_SATA_SIS is not set
460# CONFIG_SATA_ULI is not set
461# CONFIG_SATA_VIA is not set
462# CONFIG_SATA_VITESSE is not set
463# CONFIG_PATA_ALI is not set
464# CONFIG_PATA_AMD is not set
465# CONFIG_PATA_ARTOP is not set
466# CONFIG_PATA_ATIIXP is not set
467# CONFIG_PATA_CMD64X is not set
468# CONFIG_PATA_CS5520 is not set
469# CONFIG_PATA_CS5530 is not set
470# CONFIG_PATA_CYPRESS is not set
471# CONFIG_PATA_EFAR is not set
472# CONFIG_ATA_GENERIC is not set
473# CONFIG_PATA_HPT366 is not set
474# CONFIG_PATA_HPT37X is not set
475# CONFIG_PATA_HPT3X2N is not set
476# CONFIG_PATA_HPT3X3 is not set
477# CONFIG_PATA_IT821X is not set
478# CONFIG_PATA_JMICRON is not set
479# CONFIG_PATA_TRIFLEX is not set
480CONFIG_PATA_MPC52xx=y
481# CONFIG_PATA_MPIIX is not set
482# CONFIG_PATA_OLDPIIX is not set
483# CONFIG_PATA_NETCELL is not set
484# CONFIG_PATA_NS87410 is not set
485# CONFIG_PATA_OPTI is not set
486# CONFIG_PATA_OPTIDMA is not set
487# CONFIG_PATA_PDC_OLD is not set
488# CONFIG_PATA_RADISYS is not set
489# CONFIG_PATA_RZ1000 is not set
490# CONFIG_PATA_SC1200 is not set
491# CONFIG_PATA_SERVERWORKS is not set
492# CONFIG_PATA_PDC2027X is not set
493# CONFIG_PATA_SIL680 is not set
494# CONFIG_PATA_SIS is not set
495# CONFIG_PATA_VIA is not set
496# CONFIG_PATA_WINBOND is not set
497
498#
499# Multi-device support (RAID and LVM)
500#
501# CONFIG_MD is not set
502
503#
504# Fusion MPT device support
505#
506# CONFIG_FUSION is not set
507# CONFIG_FUSION_SPI is not set
508# CONFIG_FUSION_FC is not set
509# CONFIG_FUSION_SAS is not set
510
511#
512# IEEE 1394 (FireWire) support
513#
514# CONFIG_IEEE1394 is not set
515
516#
517# I2O device support
518#
519# CONFIG_I2O is not set
520
521#
522# Macintosh device drivers
523#
524# CONFIG_WINDFARM is not set
525
526#
527# Network device support
528#
529CONFIG_NETDEVICES=y
530# CONFIG_DUMMY is not set
531# CONFIG_BONDING is not set
532# CONFIG_EQUALIZER is not set
533# CONFIG_TUN is not set
534
535#
536# ARCnet devices
537#
538# CONFIG_ARCNET is not set
539
540#
541# PHY device support
542#
543
544#
545# Ethernet (10 or 100Mbit)
546#
547# CONFIG_NET_ETHERNET is not set
548
549#
550# Ethernet (1000 Mbit)
551#
552# CONFIG_ACENIC is not set
553# CONFIG_DL2K is not set
554# CONFIG_E1000 is not set
555# CONFIG_NS83820 is not set
556# CONFIG_HAMACHI is not set
557# CONFIG_YELLOWFIN is not set
558# CONFIG_R8169 is not set
559# CONFIG_SIS190 is not set
560# CONFIG_SKGE is not set
561# CONFIG_SKY2 is not set
562# CONFIG_SK98LIN is not set
563# CONFIG_TIGON3 is not set
564# CONFIG_BNX2 is not set
565# CONFIG_MV643XX_ETH is not set
566# CONFIG_QLA3XXX is not set
567
568#
569# Ethernet (10000 Mbit)
570#
571# CONFIG_CHELSIO_T1 is not set
572# CONFIG_IXGB is not set
573# CONFIG_S2IO is not set
574# CONFIG_MYRI10GE is not set
575
576#
577# Token Ring devices
578#
579# CONFIG_TR is not set
580
581#
582# Wireless LAN (non-hamradio)
583#
584# CONFIG_NET_RADIO is not set
585
586#
587# Wan interfaces
588#
589# CONFIG_WAN is not set
590# CONFIG_FDDI is not set
591# CONFIG_HIPPI is not set
592# CONFIG_PPP is not set
593# CONFIG_SLIP is not set
594# CONFIG_NET_FC is not set
595# CONFIG_SHAPER is not set
596# CONFIG_NETCONSOLE is not set
597# CONFIG_NETPOLL is not set
598# CONFIG_NET_POLL_CONTROLLER is not set
599
600#
601# ISDN subsystem
602#
603# CONFIG_ISDN is not set
604
605#
606# Telephony Support
607#
608# CONFIG_PHONE is not set
609
610#
611# Input device support
612#
613# CONFIG_INPUT is not set
614
615#
616# Hardware I/O ports
617#
618# CONFIG_SERIO is not set
619# CONFIG_GAMEPORT is not set
620
621#
622# Character devices
623#
624# CONFIG_VT is not set
625# CONFIG_SERIAL_NONSTANDARD is not set
626
627#
628# Serial drivers
629#
630# CONFIG_SERIAL_8250 is not set
631
632#
633# Non-8250 serial port support
634#
635CONFIG_SERIAL_CORE=y
636CONFIG_SERIAL_CORE_CONSOLE=y
637CONFIG_SERIAL_MPC52xx=y
638CONFIG_SERIAL_MPC52xx_CONSOLE=y
639CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=9600
640# CONFIG_SERIAL_JSM is not set
641CONFIG_UNIX98_PTYS=y
642CONFIG_LEGACY_PTYS=y
643CONFIG_LEGACY_PTY_COUNT=256
644
645#
646# IPMI
647#
648# CONFIG_IPMI_HANDLER is not set
649
650#
651# Watchdog Cards
652#
653# CONFIG_WATCHDOG is not set
654# CONFIG_HW_RANDOM is not set
655# CONFIG_NVRAM is not set
656# CONFIG_GEN_RTC is not set
657# CONFIG_DTLK is not set
658# CONFIG_R3964 is not set
659# CONFIG_APPLICOM is not set
660
661#
662# Ftape, the floppy tape device driver
663#
664# CONFIG_AGP is not set
665# CONFIG_DRM is not set
666# CONFIG_RAW_DRIVER is not set
667
668#
669# TPM devices
670#
671# CONFIG_TCG_TPM is not set
672
673#
674# I2C support
675#
676# CONFIG_I2C is not set
677
678#
679# SPI support
680#
681# CONFIG_SPI is not set
682# CONFIG_SPI_MASTER is not set
683
684#
685# Dallas's 1-wire bus
686#
687# CONFIG_W1 is not set
688
689#
690# Hardware Monitoring support
691#
692# CONFIG_HWMON is not set
693# CONFIG_HWMON_VID is not set
694
695#
696# Multimedia devices
697#
698# CONFIG_VIDEO_DEV is not set
699
700#
701# Digital Video Broadcasting Devices
702#
703# CONFIG_DVB is not set
704
705#
706# Graphics support
707#
708# CONFIG_FIRMWARE_EDID is not set
709# CONFIG_FB is not set
710# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
711
712#
713# Sound
714#
715# CONFIG_SOUND is not set
716
717#
718# USB support
719#
720CONFIG_USB_ARCH_HAS_HCD=y
721CONFIG_USB_ARCH_HAS_OHCI=y
722CONFIG_USB_ARCH_HAS_EHCI=y
723# CONFIG_USB is not set
724
725#
726# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
727#
728
729#
730# USB Gadget Support
731#
732# CONFIG_USB_GADGET is not set
733
734#
735# MMC/SD Card support
736#
737# CONFIG_MMC is not set
738
739#
740# LED devices
741#
742# CONFIG_NEW_LEDS is not set
743
744#
745# LED drivers
746#
747
748#
749# LED Triggers
750#
751
752#
753# InfiniBand support
754#
755# CONFIG_INFINIBAND is not set
756
757#
758# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
759#
760
761#
762# Real Time Clock
763#
764# CONFIG_RTC_CLASS is not set
765
766#
767# DMA Engine support
768#
769# CONFIG_DMA_ENGINE is not set
770
771#
772# DMA Clients
773#
774
775#
776# DMA Devices
777#
778
779#
780# File systems
781#
782CONFIG_EXT2_FS=y
783# CONFIG_EXT2_FS_XATTR is not set
784# CONFIG_EXT2_FS_XIP is not set
785CONFIG_EXT3_FS=y
786CONFIG_EXT3_FS_XATTR=y
787# CONFIG_EXT3_FS_POSIX_ACL is not set
788# CONFIG_EXT3_FS_SECURITY is not set
789# CONFIG_EXT4DEV_FS is not set
790CONFIG_JBD=y
791# CONFIG_JBD_DEBUG is not set
792CONFIG_FS_MBCACHE=y
793# CONFIG_REISERFS_FS is not set
794# CONFIG_JFS_FS is not set
795# CONFIG_FS_POSIX_ACL is not set
796# CONFIG_XFS_FS is not set
797# CONFIG_GFS2_FS is not set
798# CONFIG_OCFS2_FS is not set
799# CONFIG_MINIX_FS is not set
800# CONFIG_ROMFS_FS is not set
801CONFIG_INOTIFY=y
802CONFIG_INOTIFY_USER=y
803# CONFIG_QUOTA is not set
804CONFIG_DNOTIFY=y
805# CONFIG_AUTOFS_FS is not set
806# CONFIG_AUTOFS4_FS is not set
807# CONFIG_FUSE_FS is not set
808
809#
810# CD-ROM/DVD Filesystems
811#
812# CONFIG_ISO9660_FS is not set
813# CONFIG_UDF_FS is not set
814
815#
816# DOS/FAT/NT Filesystems
817#
818# CONFIG_MSDOS_FS is not set
819# CONFIG_VFAT_FS is not set
820# CONFIG_NTFS_FS is not set
821
822#
823# Pseudo filesystems
824#
825CONFIG_PROC_FS=y
826CONFIG_PROC_KCORE=y
827CONFIG_PROC_SYSCTL=y
828CONFIG_SYSFS=y
829CONFIG_TMPFS=y
830# CONFIG_TMPFS_POSIX_ACL is not set
831# CONFIG_HUGETLB_PAGE is not set
832CONFIG_RAMFS=y
833# CONFIG_CONFIGFS_FS is not set
834
835#
836# Miscellaneous filesystems
837#
838# CONFIG_ADFS_FS is not set
839# CONFIG_AFFS_FS is not set
840# CONFIG_HFS_FS is not set
841# CONFIG_HFSPLUS_FS is not set
842# CONFIG_BEFS_FS is not set
843# CONFIG_BFS_FS is not set
844# CONFIG_EFS_FS is not set
845# CONFIG_CRAMFS is not set
846# CONFIG_VXFS_FS is not set
847# CONFIG_HPFS_FS is not set
848# CONFIG_QNX4FS_FS is not set
849# CONFIG_SYSV_FS is not set
850# CONFIG_UFS_FS is not set
851
852#
853# Network File Systems
854#
855# CONFIG_NFS_FS is not set
856# CONFIG_NFSD is not set
857# CONFIG_SMB_FS is not set
858# CONFIG_CIFS is not set
859# CONFIG_NCP_FS is not set
860# CONFIG_CODA_FS is not set
861# CONFIG_AFS_FS is not set
862# CONFIG_9P_FS is not set
863
864#
865# Partition Types
866#
867# CONFIG_PARTITION_ADVANCED is not set
868CONFIG_MSDOS_PARTITION=y
869
870#
871# Native Language Support
872#
873# CONFIG_NLS is not set
874
875#
876# Library routines
877#
878# CONFIG_CRC_CCITT is not set
879# CONFIG_CRC16 is not set
880# CONFIG_CRC32 is not set
881# CONFIG_LIBCRC32C is not set
882CONFIG_PLIST=y
883
884#
885# Instrumentation Support
886#
887# CONFIG_PROFILING is not set
888
889#
890# Kernel hacking
891#
892CONFIG_PRINTK_TIME=y
893CONFIG_ENABLE_MUST_CHECK=y
894# CONFIG_MAGIC_SYSRQ is not set
895# CONFIG_UNUSED_SYMBOLS is not set
896CONFIG_DEBUG_KERNEL=y
897CONFIG_LOG_BUF_SHIFT=14
898CONFIG_DETECT_SOFTLOCKUP=y
899# CONFIG_SCHEDSTATS is not set
900# CONFIG_DEBUG_SLAB is not set
901# CONFIG_DEBUG_RT_MUTEXES is not set
902# CONFIG_RT_MUTEX_TESTER is not set
903# CONFIG_DEBUG_SPINLOCK is not set
904# CONFIG_DEBUG_MUTEXES is not set
905# CONFIG_DEBUG_RWSEMS is not set
906# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
907# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
908# CONFIG_DEBUG_KOBJECT is not set
909CONFIG_DEBUG_INFO=y
910# CONFIG_DEBUG_FS is not set
911# CONFIG_DEBUG_VM is not set
912# CONFIG_DEBUG_LIST is not set
913CONFIG_FORCED_INLINING=y
914# CONFIG_HEADERS_CHECK is not set
915# CONFIG_RCU_TORTURE_TEST is not set
916# CONFIG_DEBUGGER is not set
917# CONFIG_BDI_SWITCH is not set
918# CONFIG_BOOTX_TEXT is not set
919# CONFIG_SERIAL_TEXT_DEBUG is not set
920# CONFIG_PPC_EARLY_DEBUG is not set
921
922#
923# Security options
924#
925# CONFIG_KEYS is not set
926# CONFIG_SECURITY is not set
927
928#
929# Cryptographic options
930#
931# CONFIG_CRYPTO is not set
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index be11df7c11aa..1c009651f925 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -1386,8 +1386,8 @@ CONFIG_INOTIFY=y
1386CONFIG_INOTIFY_USER=y 1386CONFIG_INOTIFY_USER=y
1387# CONFIG_QUOTA is not set 1387# CONFIG_QUOTA is not set
1388CONFIG_DNOTIFY=y 1388CONFIG_DNOTIFY=y
1389CONFIG_AUTOFS_FS=y 1389# CONFIG_AUTOFS_FS is not set
1390# CONFIG_AUTOFS4_FS is not set 1390CONFIG_AUTOFS4_FS=m
1391# CONFIG_FUSE_FS is not set 1391# CONFIG_FUSE_FS is not set
1392 1392
1393# 1393#
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
new file mode 100644
index 000000000000..f2d888e014a9
--- /dev/null
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -0,0 +1,837 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc6
4# Tue Nov 21 19:38:53 2006
5#
6CONFIG_PPC64=y
7CONFIG_64BIT=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_GENERIC_HWEIGHT=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_FIND_NEXT_BIT=y
16CONFIG_PPC=y
17CONFIG_EARLY_PRINTK=y
18CONFIG_COMPAT=y
19CONFIG_SYSVIPC_COMPAT=y
20CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
21CONFIG_ARCH_MAY_HAVE_PC_FDC=y
22CONFIG_PPC_OF=y
23# CONFIG_PPC_UDBG_16550 is not set
24# CONFIG_GENERIC_TBSYNC is not set
25CONFIG_AUDIT_ARCH=y
26# CONFIG_DEFAULT_UIMAGE is not set
27
28#
29# Processor support
30#
31# CONFIG_POWER4_ONLY is not set
32CONFIG_POWER3=y
33CONFIG_POWER4=y
34CONFIG_PPC_FPU=y
35# CONFIG_PPC_DCR_NATIVE is not set
36# CONFIG_PPC_DCR_MMIO is not set
37# CONFIG_PPC_OF_PLATFORM_PCI is not set
38CONFIG_ALTIVEC=y
39CONFIG_PPC_STD_MMU=y
40CONFIG_VIRT_CPU_ACCOUNTING=y
41CONFIG_SMP=y
42CONFIG_NR_CPUS=2
43CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
44
45#
46# Code maturity level options
47#
48CONFIG_EXPERIMENTAL=y
49CONFIG_LOCK_KERNEL=y
50CONFIG_INIT_ENV_ARG_LIMIT=32
51
52#
53# General setup
54#
55CONFIG_LOCALVERSION=""
56CONFIG_LOCALVERSION_AUTO=y
57CONFIG_SWAP=y
58CONFIG_SYSVIPC=y
59# CONFIG_IPC_NS is not set
60# CONFIG_POSIX_MQUEUE is not set
61# CONFIG_BSD_PROCESS_ACCT is not set
62# CONFIG_TASKSTATS is not set
63# CONFIG_UTS_NS is not set
64# CONFIG_AUDIT is not set
65# CONFIG_IKCONFIG is not set
66# CONFIG_CPUSETS is not set
67# CONFIG_RELAY is not set
68CONFIG_INITRAMFS_SOURCE=""
69# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
70CONFIG_SYSCTL=y
71CONFIG_EMBEDDED=y
72# CONFIG_SYSCTL_SYSCALL is not set
73CONFIG_KALLSYMS=y
74CONFIG_KALLSYMS_ALL=y
75CONFIG_KALLSYMS_EXTRA_PASS=y
76CONFIG_HOTPLUG=y
77CONFIG_PRINTK=y
78CONFIG_BUG=y
79CONFIG_ELF_CORE=y
80CONFIG_BASE_FULL=y
81CONFIG_FUTEX=y
82CONFIG_EPOLL=y
83CONFIG_SHMEM=y
84CONFIG_SLAB=y
85CONFIG_VM_EVENT_COUNTERS=y
86CONFIG_RT_MUTEXES=y
87# CONFIG_TINY_SHMEM is not set
88CONFIG_BASE_SMALL=0
89# CONFIG_SLOB is not set
90
91#
92# Loadable module support
93#
94CONFIG_MODULES=y
95CONFIG_MODULE_UNLOAD=y
96# CONFIG_MODULE_FORCE_UNLOAD is not set
97# CONFIG_MODVERSIONS is not set
98# CONFIG_MODULE_SRCVERSION_ALL is not set
99CONFIG_KMOD=y
100CONFIG_STOP_MACHINE=y
101
102#
103# Block layer
104#
105CONFIG_BLOCK=y
106# CONFIG_BLK_DEV_IO_TRACE is not set
107
108#
109# IO Schedulers
110#
111CONFIG_IOSCHED_NOOP=y
112CONFIG_IOSCHED_AS=y
113CONFIG_IOSCHED_DEADLINE=y
114CONFIG_IOSCHED_CFQ=y
115CONFIG_DEFAULT_AS=y
116# CONFIG_DEFAULT_DEADLINE is not set
117# CONFIG_DEFAULT_CFQ is not set
118# CONFIG_DEFAULT_NOOP is not set
119CONFIG_DEFAULT_IOSCHED="anticipatory"
120
121#
122# Platform support
123#
124CONFIG_PPC_MULTIPLATFORM=y
125# CONFIG_EMBEDDED6xx is not set
126# CONFIG_APUS is not set
127# CONFIG_PPC_PSERIES is not set
128# CONFIG_PPC_ISERIES is not set
129# CONFIG_PPC_PMAC is not set
130# CONFIG_PPC_MAPLE is not set
131# CONFIG_PPC_PASEMI is not set
132CONFIG_PPC_CELL=y
133# CONFIG_PPC_CELL_NATIVE is not set
134# CONFIG_PPC_IBM_CELL_BLADE is not set
135CONFIG_PPC_PS3=y
136# CONFIG_U3_DART is not set
137# CONFIG_PPC_RTAS is not set
138# CONFIG_MMIO_NVRAM is not set
139# CONFIG_PPC_MPC106 is not set
140# CONFIG_PPC_970_NAP is not set
141# CONFIG_PPC_INDIRECT_IO is not set
142# CONFIG_GENERIC_IOMAP is not set
143# CONFIG_CPU_FREQ is not set
144# CONFIG_WANT_EARLY_SERIAL is not set
145# CONFIG_MPIC is not set
146
147#
148# Cell Broadband Engine options
149#
150CONFIG_SPU_FS=y
151CONFIG_SPU_BASE=y
152# CONFIG_CBE_RAS is not set
153
154#
155# PS3 Platform Options
156#
157CONFIG_PS3_HTAB_SIZE=20
158CONFIG_PS3_DYNAMIC_DMA=y
159CONFIG_PS3_USE_LPAR_ADDR=y
160
161#
162# Kernel options
163#
164# CONFIG_HZ_100 is not set
165CONFIG_HZ_250=y
166# CONFIG_HZ_1000 is not set
167CONFIG_HZ=250
168CONFIG_PREEMPT_NONE=y
169# CONFIG_PREEMPT_VOLUNTARY is not set
170# CONFIG_PREEMPT is not set
171# CONFIG_PREEMPT_BKL is not set
172CONFIG_BINFMT_ELF=y
173CONFIG_BINFMT_MISC=y
174CONFIG_FORCE_MAX_ZONEORDER=9
175# CONFIG_IOMMU_VMERGE is not set
176CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
177# CONFIG_KEXEC is not set
178# CONFIG_CRASH_DUMP is not set
179# CONFIG_IRQ_ALL_CPUS is not set
180# CONFIG_NUMA is not set
181CONFIG_ARCH_SELECT_MEMORY_MODEL=y
182CONFIG_ARCH_FLATMEM_ENABLE=y
183CONFIG_ARCH_SPARSEMEM_ENABLE=y
184CONFIG_ARCH_SPARSEMEM_DEFAULT=y
185CONFIG_ARCH_POPULATES_NODE_MAP=y
186CONFIG_SELECT_MEMORY_MODEL=y
187# CONFIG_FLATMEM_MANUAL is not set
188# CONFIG_DISCONTIGMEM_MANUAL is not set
189CONFIG_SPARSEMEM_MANUAL=y
190CONFIG_SPARSEMEM=y
191CONFIG_HAVE_MEMORY_PRESENT=y
192# CONFIG_SPARSEMEM_STATIC is not set
193CONFIG_SPARSEMEM_EXTREME=y
194CONFIG_MEMORY_HOTPLUG=y
195CONFIG_MEMORY_HOTPLUG_SPARSE=y
196CONFIG_SPLIT_PTLOCK_CPUS=4
197CONFIG_RESOURCES_64BIT=y
198CONFIG_ARCH_MEMORY_PROBE=y
199CONFIG_PPC_64K_PAGES=y
200# CONFIG_SCHED_SMT is not set
201CONFIG_PROC_DEVICETREE=y
202CONFIG_CMDLINE_BOOL=y
203CONFIG_CMDLINE="root=/dev/nfs rw ip=dhcp"
204# CONFIG_PM is not set
205# CONFIG_SECCOMP is not set
206CONFIG_ISA_DMA_API=y
207
208#
209# Bus options
210#
211CONFIG_GENERIC_ISA_DMA=y
212# CONFIG_MPIC_WEIRD is not set
213# CONFIG_PPC_I8259 is not set
214# CONFIG_PCI is not set
215# CONFIG_PCI_DOMAINS is not set
216
217#
218# PCCARD (PCMCIA/CardBus) support
219#
220# CONFIG_PCCARD is not set
221
222#
223# PCI Hotplug Support
224#
225CONFIG_KERNEL_START=0xc000000000000000
226
227#
228# Networking
229#
230CONFIG_NET=y
231
232#
233# Networking options
234#
235# CONFIG_NETDEBUG is not set
236# CONFIG_PACKET is not set
237CONFIG_UNIX=y
238# CONFIG_NET_KEY is not set
239CONFIG_INET=y
240# CONFIG_IP_MULTICAST is not set
241# CONFIG_IP_ADVANCED_ROUTER is not set
242CONFIG_IP_FIB_HASH=y
243CONFIG_IP_PNP=y
244CONFIG_IP_PNP_DHCP=y
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_ARPD 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
259# CONFIG_INET_DIAG is not set
260# CONFIG_TCP_CONG_ADVANCED is not set
261CONFIG_TCP_CONG_CUBIC=y
262CONFIG_DEFAULT_TCP_CONG="cubic"
263# CONFIG_IPV6 is not set
264# CONFIG_INET6_XFRM_TUNNEL is not set
265# CONFIG_INET6_TUNNEL is not set
266# CONFIG_NETWORK_SECMARK is not set
267# CONFIG_NETFILTER is not set
268
269#
270# DCCP Configuration (EXPERIMENTAL)
271#
272# CONFIG_IP_DCCP is not set
273
274#
275# SCTP Configuration (EXPERIMENTAL)
276#
277# CONFIG_IP_SCTP is not set
278
279#
280# TIPC Configuration (EXPERIMENTAL)
281#
282# CONFIG_TIPC is not set
283# CONFIG_ATM is not set
284# CONFIG_BRIDGE is not set
285# CONFIG_VLAN_8021Q is not set
286# CONFIG_DECNET is not set
287# CONFIG_LLC2 is not set
288# CONFIG_IPX is not set
289# CONFIG_ATALK is not set
290# CONFIG_X25 is not set
291# CONFIG_LAPB is not set
292# CONFIG_ECONET is not set
293# CONFIG_WAN_ROUTER is not set
294
295#
296# QoS and/or fair queueing
297#
298# CONFIG_NET_SCHED is not set
299
300#
301# Network testing
302#
303# CONFIG_NET_PKTGEN is not set
304# CONFIG_HAMRADIO is not set
305# CONFIG_IRDA is not set
306# CONFIG_BT is not set
307# CONFIG_IEEE80211 is not set
308
309#
310# Device Drivers
311#
312
313#
314# Generic Driver Options
315#
316CONFIG_STANDALONE=y
317CONFIG_PREVENT_FIRMWARE_BUILD=y
318# CONFIG_FW_LOADER is not set
319# CONFIG_DEBUG_DRIVER is not set
320# CONFIG_SYS_HYPERVISOR is not set
321
322#
323# Connector - unified userspace <-> kernelspace linker
324#
325# CONFIG_CONNECTOR is not set
326
327#
328# Memory Technology Devices (MTD)
329#
330# CONFIG_MTD is not set
331
332#
333# Parallel port support
334#
335# CONFIG_PARPORT is not set
336
337#
338# Plug and Play support
339#
340
341#
342# Block devices
343#
344# CONFIG_BLK_DEV_FD is not set
345# CONFIG_BLK_DEV_COW_COMMON is not set
346# CONFIG_BLK_DEV_LOOP is not set
347# CONFIG_BLK_DEV_NBD is not set
348# CONFIG_BLK_DEV_RAM is not set
349# CONFIG_BLK_DEV_INITRD is not set
350# CONFIG_CDROM_PKTCDVD is not set
351# CONFIG_ATA_OVER_ETH is not set
352
353#
354# Misc devices
355#
356# CONFIG_TIFM_CORE is not set
357
358#
359# ATA/ATAPI/MFM/RLL support
360#
361# CONFIG_IDE is not set
362
363#
364# SCSI device support
365#
366# CONFIG_RAID_ATTRS is not set
367CONFIG_SCSI=y
368# CONFIG_SCSI_NETLINK is not set
369CONFIG_SCSI_PROC_FS=y
370
371#
372# SCSI support type (disk, tape, CD-ROM)
373#
374# CONFIG_BLK_DEV_SD is not set
375# CONFIG_CHR_DEV_ST is not set
376# CONFIG_CHR_DEV_OSST is not set
377# CONFIG_BLK_DEV_SR is not set
378# CONFIG_CHR_DEV_SG is not set
379# CONFIG_CHR_DEV_SCH is not set
380
381#
382# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
383#
384# CONFIG_SCSI_MULTI_LUN is not set
385# CONFIG_SCSI_CONSTANTS is not set
386# CONFIG_SCSI_LOGGING is not set
387
388#
389# SCSI Transports
390#
391# CONFIG_SCSI_SPI_ATTRS is not set
392# CONFIG_SCSI_FC_ATTRS is not set
393# CONFIG_SCSI_ISCSI_ATTRS is not set
394# CONFIG_SCSI_SAS_ATTRS is not set
395# CONFIG_SCSI_SAS_LIBSAS is not set
396
397#
398# SCSI low-level drivers
399#
400# CONFIG_ISCSI_TCP is not set
401# CONFIG_SCSI_DEBUG is not set
402
403#
404# Serial ATA (prod) and Parallel ATA (experimental) drivers
405#
406# CONFIG_ATA is not set
407
408#
409# Multi-device support (RAID and LVM)
410#
411# CONFIG_MD is not set
412
413#
414# Fusion MPT device support
415#
416# CONFIG_FUSION is not set
417
418#
419# IEEE 1394 (FireWire) support
420#
421
422#
423# I2O device support
424#
425
426#
427# Macintosh device drivers
428#
429# CONFIG_WINDFARM is not set
430
431#
432# Network device support
433#
434CONFIG_NETDEVICES=y
435# CONFIG_DUMMY is not set
436# CONFIG_BONDING is not set
437# CONFIG_EQUALIZER is not set
438# CONFIG_TUN is not set
439
440#
441# PHY device support
442#
443
444#
445# Ethernet (10 or 100Mbit)
446#
447# CONFIG_NET_ETHERNET is not set
448
449#
450# Ethernet (1000 Mbit)
451#
452
453#
454# Ethernet (10000 Mbit)
455#
456
457#
458# Token Ring devices
459#
460
461#
462# Wireless LAN (non-hamradio)
463#
464# CONFIG_NET_RADIO is not set
465
466#
467# Wan interfaces
468#
469# CONFIG_WAN is not set
470# CONFIG_PPP is not set
471# CONFIG_SLIP is not set
472# CONFIG_SHAPER is not set
473# CONFIG_NETCONSOLE is not set
474# CONFIG_NETPOLL is not set
475# CONFIG_NET_POLL_CONTROLLER is not set
476
477#
478# ISDN subsystem
479#
480# CONFIG_ISDN is not set
481
482#
483# Telephony Support
484#
485# CONFIG_PHONE is not set
486
487#
488# Input device support
489#
490CONFIG_INPUT=y
491# CONFIG_INPUT_FF_MEMLESS is not set
492
493#
494# Userland interfaces
495#
496# CONFIG_INPUT_MOUSEDEV is not set
497# CONFIG_INPUT_JOYDEV is not set
498# CONFIG_INPUT_TSDEV is not set
499CONFIG_INPUT_EVDEV=y
500# CONFIG_INPUT_EVBUG is not set
501
502#
503# Input Device Drivers
504#
505# CONFIG_INPUT_KEYBOARD is not set
506# CONFIG_INPUT_MOUSE is not set
507# CONFIG_INPUT_JOYSTICK is not set
508# CONFIG_INPUT_TOUCHSCREEN is not set
509# CONFIG_INPUT_MISC is not set
510
511#
512# Hardware I/O ports
513#
514# CONFIG_SERIO is not set
515# CONFIG_GAMEPORT is not set
516
517#
518# Character devices
519#
520CONFIG_VT=y
521CONFIG_VT_CONSOLE=y
522CONFIG_HW_CONSOLE=y
523# CONFIG_VT_HW_CONSOLE_BINDING is not set
524# CONFIG_SERIAL_NONSTANDARD is not set
525
526#
527# Serial drivers
528#
529# CONFIG_SERIAL_8250 is not set
530
531#
532# Non-8250 serial port support
533#
534CONFIG_UNIX98_PTYS=y
535# CONFIG_LEGACY_PTYS is not set
536
537#
538# IPMI
539#
540# CONFIG_IPMI_HANDLER is not set
541
542#
543# Watchdog Cards
544#
545# CONFIG_WATCHDOG is not set
546# CONFIG_HW_RANDOM is not set
547CONFIG_GEN_RTC=y
548# CONFIG_GEN_RTC_X is not set
549# CONFIG_DTLK is not set
550# CONFIG_R3964 is not set
551
552#
553# Ftape, the floppy tape device driver
554#
555# CONFIG_RAW_DRIVER is not set
556# CONFIG_HANGCHECK_TIMER is not set
557
558#
559# TPM devices
560#
561# CONFIG_TCG_TPM is not set
562
563#
564# I2C support
565#
566# CONFIG_I2C is not set
567
568#
569# SPI support
570#
571# CONFIG_SPI is not set
572# CONFIG_SPI_MASTER is not set
573
574#
575# Dallas's 1-wire bus
576#
577# CONFIG_W1 is not set
578
579#
580# Hardware Monitoring support
581#
582# CONFIG_HWMON is not set
583# CONFIG_HWMON_VID is not set
584
585#
586# Multimedia devices
587#
588# CONFIG_VIDEO_DEV is not set
589
590#
591# Digital Video Broadcasting Devices
592#
593# CONFIG_DVB is not set
594
595#
596# Graphics support
597#
598# CONFIG_FIRMWARE_EDID is not set
599# CONFIG_FB is not set
600
601#
602# Console display driver support
603#
604# CONFIG_VGA_CONSOLE is not set
605CONFIG_DUMMY_CONSOLE=y
606# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
607
608#
609# Sound
610#
611# CONFIG_SOUND is not set
612
613#
614# USB support
615#
616# CONFIG_USB_ARCH_HAS_HCD is not set
617# CONFIG_USB_ARCH_HAS_OHCI is not set
618# CONFIG_USB_ARCH_HAS_EHCI is not set
619
620#
621# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
622#
623
624#
625# USB Gadget Support
626#
627# CONFIG_USB_GADGET is not set
628
629#
630# MMC/SD Card support
631#
632# CONFIG_MMC is not set
633
634#
635# LED devices
636#
637# CONFIG_NEW_LEDS is not set
638
639#
640# LED drivers
641#
642
643#
644# LED Triggers
645#
646
647#
648# InfiniBand support
649#
650
651#
652# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
653#
654
655#
656# Real Time Clock
657#
658# CONFIG_RTC_CLASS is not set
659
660#
661# DMA Engine support
662#
663# CONFIG_DMA_ENGINE is not set
664
665#
666# DMA Clients
667#
668
669#
670# DMA Devices
671#
672
673#
674# File systems
675#
676# CONFIG_EXT2_FS is not set
677# CONFIG_EXT3_FS is not set
678# CONFIG_EXT4DEV_FS is not set
679# CONFIG_REISERFS_FS is not set
680# CONFIG_JFS_FS is not set
681# CONFIG_FS_POSIX_ACL is not set
682# CONFIG_XFS_FS is not set
683# CONFIG_GFS2_FS is not set
684# CONFIG_OCFS2_FS is not set
685# CONFIG_MINIX_FS is not set
686# CONFIG_ROMFS_FS is not set
687CONFIG_INOTIFY=y
688CONFIG_INOTIFY_USER=y
689# CONFIG_QUOTA is not set
690CONFIG_DNOTIFY=y
691# CONFIG_AUTOFS_FS is not set
692# CONFIG_AUTOFS4_FS is not set
693# CONFIG_FUSE_FS is not set
694
695#
696# CD-ROM/DVD Filesystems
697#
698# CONFIG_ISO9660_FS is not set
699# CONFIG_UDF_FS is not set
700
701#
702# DOS/FAT/NT Filesystems
703#
704# CONFIG_MSDOS_FS is not set
705# CONFIG_VFAT_FS is not set
706# CONFIG_NTFS_FS is not set
707
708#
709# Pseudo filesystems
710#
711CONFIG_PROC_FS=y
712CONFIG_PROC_KCORE=y
713CONFIG_PROC_SYSCTL=y
714CONFIG_SYSFS=y
715CONFIG_TMPFS=y
716# CONFIG_TMPFS_POSIX_ACL is not set
717# CONFIG_HUGETLBFS is not set
718# CONFIG_HUGETLB_PAGE is not set
719CONFIG_RAMFS=y
720# CONFIG_CONFIGFS_FS is not set
721
722#
723# Miscellaneous filesystems
724#
725# CONFIG_ADFS_FS is not set
726# CONFIG_AFFS_FS is not set
727# CONFIG_HFS_FS is not set
728# CONFIG_HFSPLUS_FS is not set
729# CONFIG_BEFS_FS is not set
730# CONFIG_BFS_FS is not set
731# CONFIG_EFS_FS is not set
732# CONFIG_CRAMFS is not set
733# CONFIG_VXFS_FS is not set
734# CONFIG_HPFS_FS is not set
735# CONFIG_QNX4FS_FS is not set
736# CONFIG_SYSV_FS is not set
737# CONFIG_UFS_FS is not set
738
739#
740# Network File Systems
741#
742CONFIG_NFS_FS=y
743CONFIG_NFS_V3=y
744# CONFIG_NFS_V3_ACL is not set
745# CONFIG_NFS_V4 is not set
746# CONFIG_NFS_DIRECTIO is not set
747# CONFIG_NFSD is not set
748CONFIG_ROOT_NFS=y
749CONFIG_LOCKD=y
750CONFIG_LOCKD_V4=y
751CONFIG_NFS_COMMON=y
752CONFIG_SUNRPC=y
753# CONFIG_RPCSEC_GSS_KRB5 is not set
754# CONFIG_RPCSEC_GSS_SPKM3 is not set
755# CONFIG_SMB_FS is not set
756# CONFIG_CIFS is not set
757# CONFIG_NCP_FS is not set
758# CONFIG_CODA_FS is not set
759# CONFIG_AFS_FS is not set
760# CONFIG_9P_FS is not set
761
762#
763# Partition Types
764#
765# CONFIG_PARTITION_ADVANCED is not set
766CONFIG_MSDOS_PARTITION=y
767
768#
769# Native Language Support
770#
771# CONFIG_NLS is not set
772
773#
774# Library routines
775#
776# CONFIG_CRC_CCITT is not set
777# CONFIG_CRC16 is not set
778# CONFIG_CRC32 is not set
779# CONFIG_LIBCRC32C is not set
780CONFIG_PLIST=y
781
782#
783# Instrumentation Support
784#
785# CONFIG_PROFILING is not set
786# CONFIG_KPROBES is not set
787
788#
789# Kernel hacking
790#
791# CONFIG_PRINTK_TIME is not set
792CONFIG_ENABLE_MUST_CHECK=y
793# CONFIG_MAGIC_SYSRQ is not set
794# CONFIG_UNUSED_SYMBOLS is not set
795CONFIG_DEBUG_KERNEL=y
796CONFIG_LOG_BUF_SHIFT=17
797CONFIG_DETECT_SOFTLOCKUP=y
798# CONFIG_SCHEDSTATS is not set
799# CONFIG_DEBUG_SLAB is not set
800# CONFIG_DEBUG_RT_MUTEXES is not set
801# CONFIG_RT_MUTEX_TESTER is not set
802CONFIG_DEBUG_SPINLOCK=y
803# CONFIG_DEBUG_MUTEXES is not set
804# CONFIG_DEBUG_RWSEMS is not set
805CONFIG_DEBUG_SPINLOCK_SLEEP=y
806# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
807# CONFIG_DEBUG_KOBJECT is not set
808CONFIG_DEBUG_INFO=y
809# CONFIG_DEBUG_FS is not set
810# CONFIG_DEBUG_VM is not set
811CONFIG_DEBUG_LIST=y
812CONFIG_FORCED_INLINING=y
813# CONFIG_HEADERS_CHECK is not set
814# CONFIG_RCU_TORTURE_TEST is not set
815# CONFIG_DEBUG_STACKOVERFLOW is not set
816# CONFIG_DEBUG_STACK_USAGE is not set
817# CONFIG_DEBUGGER is not set
818CONFIG_IRQSTACKS=y
819# CONFIG_BOOTX_TEXT is not set
820CONFIG_PPC_EARLY_DEBUG=y
821# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
822# CONFIG_PPC_EARLY_DEBUG_G5 is not set
823# CONFIG_PPC_EARLY_DEBUG_RTAS_PANEL is not set
824# CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE is not set
825# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
826# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
827
828#
829# Security options
830#
831# CONFIG_KEYS is not set
832# CONFIG_SECURITY is not set
833
834#
835# Cryptographic options
836#
837# CONFIG_CRYPTO is not set
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 7af23c43fd4b..4fe53d08ab81 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -17,11 +17,11 @@ obj-y += vdso32/
17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ 17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \
18 signal_64.o ptrace32.o \ 18 signal_64.o ptrace32.o \
19 paca.o cpu_setup_ppc970.o \ 19 paca.o cpu_setup_ppc970.o \
20 firmware.o sysfs.o 20 firmware.o sysfs.o nvram_64.o
21obj-$(CONFIG_PPC64) += vdso64/ 21obj-$(CONFIG_PPC64) += vdso64/
22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o 22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o
23obj-$(CONFIG_PPC_970_NAP) += idle_power4.o 23obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
24obj-$(CONFIG_PPC_OF) += of_device.o prom_parse.o 24obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o
25procfs-$(CONFIG_PPC64) := proc_ppc64.o 25procfs-$(CONFIG_PPC64) := proc_ppc64.o
26obj-$(CONFIG_PROC_FS) += $(procfs-y) 26obj-$(CONFIG_PROC_FS) += $(procfs-y)
27rtaspci-$(CONFIG_PPC64) := rtas_pci.o 27rtaspci-$(CONFIG_PPC64) := rtas_pci.o
@@ -32,7 +32,6 @@ obj-$(CONFIG_LPARCFG) += lparcfg.o
32obj-$(CONFIG_IBMVIO) += vio.o 32obj-$(CONFIG_IBMVIO) += vio.o
33obj-$(CONFIG_IBMEBUS) += ibmebus.o 33obj-$(CONFIG_IBMEBUS) += ibmebus.o
34obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o 34obj-$(CONFIG_GENERIC_TBSYNC) += smp-tbsync.o
35obj64-$(CONFIG_PPC_MULTIPLATFORM) += nvram_64.o
36obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 35obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
37obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o 36obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
38obj-$(CONFIG_TAU) += tau_6xx.o 37obj-$(CONFIG_TAU) += tau_6xx.o
@@ -59,11 +58,11 @@ obj-$(CONFIG_BOOTX_TEXT) += btext.o
59obj-$(CONFIG_SMP) += smp.o 58obj-$(CONFIG_SMP) += smp.o
60obj-$(CONFIG_KPROBES) += kprobes.o 59obj-$(CONFIG_KPROBES) += kprobes.o
61obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o 60obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o
61
62module-$(CONFIG_PPC64) += module_64.o 62module-$(CONFIG_PPC64) += module_64.o
63obj-$(CONFIG_MODULES) += $(module-y) 63obj-$(CONFIG_MODULES) += $(module-y)
64 64
65pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o pci_iommu.o \ 65pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o
66 pci_direct_iommu.o iomap.o
67pci32-$(CONFIG_PPC32) := pci_32.o 66pci32-$(CONFIG_PPC32) := pci_32.o
68obj-$(CONFIG_PCI) += $(pci64-y) $(pci32-y) 67obj-$(CONFIG_PCI) += $(pci64-y) $(pci32-y)
69kexec-$(CONFIG_PPC64) := machine_kexec_64.o 68kexec-$(CONFIG_PPC64) := machine_kexec_64.o
@@ -72,8 +71,12 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o $(kexec-y)
72obj-$(CONFIG_AUDIT) += audit.o 71obj-$(CONFIG_AUDIT) += audit.o
73obj64-$(CONFIG_AUDIT) += compat_audit.o 72obj64-$(CONFIG_AUDIT) += compat_audit.o
74 73
74ifneq ($(CONFIG_PPC_INDIRECT_IO),y)
75obj-y += iomap.o
76endif
77
75ifeq ($(CONFIG_PPC_ISERIES),y) 78ifeq ($(CONFIG_PPC_ISERIES),y)
76$(obj)/head_64.o: $(obj)/lparmap.s 79extra-y += lparmap.s
77AFLAGS_head_64.o += -I$(obj) 80AFLAGS_head_64.o += -I$(obj)
78endif 81endif
79 82
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index d06f378597bb..e96521530d21 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -118,7 +118,8 @@ int main(void)
118 DEFINE(PACASTABRR, offsetof(struct paca_struct, stab_rr)); 118 DEFINE(PACASTABRR, offsetof(struct paca_struct, stab_rr));
119 DEFINE(PACAR1, offsetof(struct paca_struct, saved_r1)); 119 DEFINE(PACAR1, offsetof(struct paca_struct, saved_r1));
120 DEFINE(PACATOC, offsetof(struct paca_struct, kernel_toc)); 120 DEFINE(PACATOC, offsetof(struct paca_struct, kernel_toc));
121 DEFINE(PACAPROCENABLED, offsetof(struct paca_struct, proc_enabled)); 121 DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled));
122 DEFINE(PACAHARDIRQEN, offsetof(struct paca_struct, hard_enabled));
122 DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache)); 123 DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache));
123 DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr)); 124 DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr));
124 DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id)); 125 DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id));
diff --git a/arch/powerpc/kernel/cpu_setup_ppc970.S b/arch/powerpc/kernel/cpu_setup_ppc970.S
index 652594891d58..bf118c385752 100644
--- a/arch/powerpc/kernel/cpu_setup_ppc970.S
+++ b/arch/powerpc/kernel/cpu_setup_ppc970.S
@@ -83,6 +83,22 @@ _GLOBAL(__setup_cpu_ppc970)
83 rldimi r0,r11,52,8 /* set NAP and DPM */ 83 rldimi r0,r11,52,8 /* set NAP and DPM */
84 li r11,0 84 li r11,0
85 rldimi r0,r11,32,31 /* clear EN_ATTN */ 85 rldimi r0,r11,32,31 /* clear EN_ATTN */
86 b load_hids /* Jump to shared code */
87
88
89_GLOBAL(__setup_cpu_ppc970MP)
90 /* Do nothing if not running in HV mode */
91 mfmsr r0
92 rldicl. r0,r0,4,63
93 beqlr
94
95 mfspr r0,SPRN_HID0
96 li r11,0x15 /* clear DOZE and SLEEP */
97 rldimi r0,r11,52,6 /* set DEEPNAP, NAP and DPM */
98 li r11,0
99 rldimi r0,r11,32,31 /* clear EN_ATTN */
100
101load_hids:
86 mtspr SPRN_HID0,r0 102 mtspr SPRN_HID0,r0
87 mfspr r0,SPRN_HID0 103 mfspr r0,SPRN_HID0
88 mfspr r0,SPRN_HID0 104 mfspr r0,SPRN_HID0
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index bfd499ee3753..9d1614c3ce67 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -42,6 +42,7 @@ extern void __setup_cpu_745x(unsigned long offset, struct cpu_spec* spec);
42#endif /* CONFIG_PPC32 */ 42#endif /* CONFIG_PPC32 */
43#ifdef CONFIG_PPC64 43#ifdef CONFIG_PPC64
44extern void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec* spec); 44extern void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec* spec);
45extern void __setup_cpu_ppc970MP(unsigned long offset, struct cpu_spec* spec);
45extern void __restore_cpu_ppc970(void); 46extern void __restore_cpu_ppc970(void);
46#endif /* CONFIG_PPC64 */ 47#endif /* CONFIG_PPC64 */
47 48
@@ -222,9 +223,9 @@ static struct cpu_spec cpu_specs[] = {
222 .icache_bsize = 128, 223 .icache_bsize = 128,
223 .dcache_bsize = 128, 224 .dcache_bsize = 128,
224 .num_pmcs = 8, 225 .num_pmcs = 8,
225 .cpu_setup = __setup_cpu_ppc970, 226 .cpu_setup = __setup_cpu_ppc970MP,
226 .cpu_restore = __restore_cpu_ppc970, 227 .cpu_restore = __restore_cpu_ppc970,
227 .oprofile_cpu_type = "ppc64/970", 228 .oprofile_cpu_type = "ppc64/970MP",
228 .oprofile_type = PPC_OPROFILE_POWER4, 229 .oprofile_type = PPC_OPROFILE_POWER4,
229 .platform = "ppc970", 230 .platform = "ppc970",
230 }, 231 },
@@ -276,10 +277,45 @@ static struct cpu_spec cpu_specs[] = {
276 .oprofile_mmcra_sipr = MMCRA_SIPR, 277 .oprofile_mmcra_sipr = MMCRA_SIPR,
277 .platform = "power5+", 278 .platform = "power5+",
278 }, 279 },
280 { /* POWER6 in P5+ mode; 2.04-compliant processor */
281 .pvr_mask = 0xffffffff,
282 .pvr_value = 0x0f000001,
283 .cpu_name = "POWER5+",
284 .cpu_features = CPU_FTRS_POWER5,
285 .cpu_user_features = COMMON_USER_POWER5_PLUS,
286 .icache_bsize = 128,
287 .dcache_bsize = 128,
288 .num_pmcs = 6,
289 .oprofile_cpu_type = "ppc64/power6",
290 .oprofile_type = PPC_OPROFILE_POWER4,
291 .oprofile_mmcra_sihv = POWER6_MMCRA_SIHV,
292 .oprofile_mmcra_sipr = POWER6_MMCRA_SIPR,
293 .oprofile_mmcra_clear = POWER6_MMCRA_THRM |
294 POWER6_MMCRA_OTHER,
295 .platform = "power5+",
296 },
279 { /* Power6 */ 297 { /* Power6 */
280 .pvr_mask = 0xffff0000, 298 .pvr_mask = 0xffff0000,
281 .pvr_value = 0x003e0000, 299 .pvr_value = 0x003e0000,
282 .cpu_name = "POWER6", 300 .cpu_name = "POWER6 (raw)",
301 .cpu_features = CPU_FTRS_POWER6,
302 .cpu_user_features = COMMON_USER_POWER6 |
303 PPC_FEATURE_POWER6_EXT,
304 .icache_bsize = 128,
305 .dcache_bsize = 128,
306 .num_pmcs = 6,
307 .oprofile_cpu_type = "ppc64/power6",
308 .oprofile_type = PPC_OPROFILE_POWER4,
309 .oprofile_mmcra_sihv = POWER6_MMCRA_SIHV,
310 .oprofile_mmcra_sipr = POWER6_MMCRA_SIPR,
311 .oprofile_mmcra_clear = POWER6_MMCRA_THRM |
312 POWER6_MMCRA_OTHER,
313 .platform = "power6x",
314 },
315 { /* 2.05-compliant processor, i.e. Power6 "architected" mode */
316 .pvr_mask = 0xffffffff,
317 .pvr_value = 0x0f000002,
318 .cpu_name = "POWER6 (architected)",
283 .cpu_features = CPU_FTRS_POWER6, 319 .cpu_features = CPU_FTRS_POWER6,
284 .cpu_user_features = COMMON_USER_POWER6, 320 .cpu_user_features = COMMON_USER_POWER6,
285 .icache_bsize = 128, 321 .icache_bsize = 128,
@@ -303,6 +339,9 @@ static struct cpu_spec cpu_specs[] = {
303 PPC_FEATURE_SMT, 339 PPC_FEATURE_SMT,
304 .icache_bsize = 128, 340 .icache_bsize = 128,
305 .dcache_bsize = 128, 341 .dcache_bsize = 128,
342 .num_pmcs = 4,
343 .oprofile_cpu_type = "ppc64/cell-be",
344 .oprofile_type = PPC_OPROFILE_CELL,
306 .platform = "ppc-cell-be", 345 .platform = "ppc-cell-be",
307 }, 346 },
308 { /* PA Semi PA6T */ 347 { /* PA Semi PA6T */
@@ -801,6 +840,17 @@ static struct cpu_spec cpu_specs[] = {
801 .cpu_setup = __setup_cpu_603, 840 .cpu_setup = __setup_cpu_603,
802 .platform = "ppc603", 841 .platform = "ppc603",
803 }, 842 },
843 { /* e300c3 on 83xx */
844 .pvr_mask = 0x7fff0000,
845 .pvr_value = 0x00850000,
846 .cpu_name = "e300c3",
847 .cpu_features = CPU_FTRS_E300,
848 .cpu_user_features = COMMON_USER,
849 .icache_bsize = 32,
850 .dcache_bsize = 32,
851 .cpu_setup = __setup_cpu_603,
852 .platform = "ppc603",
853 },
804 { /* default match, we assume split I/D cache & TB (non-601)... */ 854 { /* default match, we assume split I/D cache & TB (non-601)... */
805 .pvr_mask = 0x00000000, 855 .pvr_mask = 0x00000000,
806 .pvr_value = 0x00000000, 856 .pvr_value = 0x00000000,
@@ -1169,19 +1219,15 @@ static struct cpu_spec cpu_specs[] = {
1169#endif /* CONFIG_PPC32 */ 1219#endif /* CONFIG_PPC32 */
1170}; 1220};
1171 1221
1172struct cpu_spec *identify_cpu(unsigned long offset) 1222struct cpu_spec *identify_cpu(unsigned long offset, unsigned int pvr)
1173{ 1223{
1174 struct cpu_spec *s = cpu_specs; 1224 struct cpu_spec *s = cpu_specs;
1175 struct cpu_spec **cur = &cur_cpu_spec; 1225 struct cpu_spec **cur = &cur_cpu_spec;
1176 unsigned int pvr = mfspr(SPRN_PVR);
1177 int i; 1226 int i;
1178 1227
1179 s = PTRRELOC(s); 1228 s = PTRRELOC(s);
1180 cur = PTRRELOC(cur); 1229 cur = PTRRELOC(cur);
1181 1230
1182 if (*cur != NULL)
1183 return PTRRELOC(*cur);
1184
1185 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++) 1231 for (i = 0; i < ARRAY_SIZE(cpu_specs); i++,s++)
1186 if ((pvr & s->pvr_mask) == s->pvr_value) { 1232 if ((pvr & s->pvr_mask) == s->pvr_value) {
1187 *cur = cpu_specs + i; 1233 *cur = cpu_specs + i;
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 1af41f7616dc..89b03c8da9d2 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -111,7 +111,7 @@ void crash_ipi_callback(struct pt_regs *regs)
111 if (!cpu_online(cpu)) 111 if (!cpu_online(cpu))
112 return; 112 return;
113 113
114 local_irq_disable(); 114 hard_irq_disable();
115 if (!cpu_isset(cpu, cpus_in_crash)) 115 if (!cpu_isset(cpu, cpus_in_crash))
116 crash_save_this_cpu(regs, cpu); 116 crash_save_this_cpu(regs, cpu);
117 cpu_set(cpu, cpus_in_crash); 117 cpu_set(cpu, cpus_in_crash);
@@ -289,7 +289,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
289 * an SMP system. 289 * an SMP system.
290 * The kernel is broken so disable interrupts. 290 * The kernel is broken so disable interrupts.
291 */ 291 */
292 local_irq_disable(); 292 hard_irq_disable();
293 293
294 for_each_irq(irq) { 294 for_each_irq(irq) {
295 struct irq_desc *desc = irq_desc + irq; 295 struct irq_desc *desc = irq_desc + irq;
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 6c168f6ea142..7b0e754383cf 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -1,151 +1,194 @@
1/* 1/*
2 * Copyright (C) 2004 IBM Corporation 2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation
3 * 3 *
4 * Implements the generic device dma API for ppc64. Handles 4 * Provide default implementations of the DMA mapping callbacks for
5 * the pci and vio busses 5 * directly mapped busses and busses using the iommu infrastructure
6 */ 6 */
7 7
8#include <linux/device.h> 8#include <linux/device.h>
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10/* Include the busses we support */
11#include <linux/pci.h>
12#include <asm/vio.h>
13#include <asm/ibmebus.h>
14#include <asm/scatterlist.h>
15#include <asm/bug.h> 10#include <asm/bug.h>
11#include <asm/iommu.h>
12#include <asm/abs_addr.h>
16 13
17static struct dma_mapping_ops *get_dma_ops(struct device *dev) 14/*
18{ 15 * Generic iommu implementation
19#ifdef CONFIG_PCI 16 */
20 if (dev->bus == &pci_bus_type)
21 return &pci_dma_ops;
22#endif
23#ifdef CONFIG_IBMVIO
24 if (dev->bus == &vio_bus_type)
25 return &vio_dma_ops;
26#endif
27#ifdef CONFIG_IBMEBUS
28 if (dev->bus == &ibmebus_bus_type)
29 return &ibmebus_dma_ops;
30#endif
31 return NULL;
32}
33 17
34int dma_supported(struct device *dev, u64 mask) 18static inline unsigned long device_to_mask(struct device *dev)
35{ 19{
36 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 20 if (dev->dma_mask && *dev->dma_mask)
21 return *dev->dma_mask;
22 /* Assume devices without mask can take 32 bit addresses */
23 return 0xfffffffful;
24}
37 25
38 BUG_ON(!dma_ops);
39 26
40 return dma_ops->dma_supported(dev, mask); 27/* Allocates a contiguous real buffer and creates mappings over it.
28 * Returns the virtual address of the buffer and sets dma_handle
29 * to the dma address (mapping) of the first page.
30 */
31static void *dma_iommu_alloc_coherent(struct device *dev, size_t size,
32 dma_addr_t *dma_handle, gfp_t flag)
33{
34 return iommu_alloc_coherent(dev->archdata.dma_data, size, dma_handle,
35 device_to_mask(dev), flag,
36 dev->archdata.numa_node);
41} 37}
42EXPORT_SYMBOL(dma_supported);
43 38
44int dma_set_mask(struct device *dev, u64 dma_mask) 39static void dma_iommu_free_coherent(struct device *dev, size_t size,
40 void *vaddr, dma_addr_t dma_handle)
45{ 41{
46#ifdef CONFIG_PCI 42 iommu_free_coherent(dev->archdata.dma_data, size, vaddr, dma_handle);
47 if (dev->bus == &pci_bus_type)
48 return pci_set_dma_mask(to_pci_dev(dev), dma_mask);
49#endif
50#ifdef CONFIG_IBMVIO
51 if (dev->bus == &vio_bus_type)
52 return -EIO;
53#endif /* CONFIG_IBMVIO */
54#ifdef CONFIG_IBMEBUS
55 if (dev->bus == &ibmebus_bus_type)
56 return -EIO;
57#endif
58 BUG();
59 return 0;
60} 43}
61EXPORT_SYMBOL(dma_set_mask);
62 44
63void *dma_alloc_coherent(struct device *dev, size_t size, 45/* Creates TCEs for a user provided buffer. The user buffer must be
64 dma_addr_t *dma_handle, gfp_t flag) 46 * contiguous real kernel storage (not vmalloc). The address of the buffer
47 * passed here is the kernel (virtual) address of the buffer. The buffer
48 * need not be page aligned, the dma_addr_t returned will point to the same
49 * byte within the page as vaddr.
50 */
51static dma_addr_t dma_iommu_map_single(struct device *dev, void *vaddr,
52 size_t size,
53 enum dma_data_direction direction)
65{ 54{
66 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 55 return iommu_map_single(dev->archdata.dma_data, vaddr, size,
67 56 device_to_mask(dev), direction);
68 BUG_ON(!dma_ops);
69
70 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
71} 57}
72EXPORT_SYMBOL(dma_alloc_coherent);
73 58
74void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 59
75 dma_addr_t dma_handle) 60static void dma_iommu_unmap_single(struct device *dev, dma_addr_t dma_handle,
61 size_t size,
62 enum dma_data_direction direction)
76{ 63{
77 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 64 iommu_unmap_single(dev->archdata.dma_data, dma_handle, size, direction);
65}
78 66
79 BUG_ON(!dma_ops);
80 67
81 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 68static int dma_iommu_map_sg(struct device *dev, struct scatterlist *sglist,
69 int nelems, enum dma_data_direction direction)
70{
71 return iommu_map_sg(dev->archdata.dma_data, sglist, nelems,
72 device_to_mask(dev), direction);
82} 73}
83EXPORT_SYMBOL(dma_free_coherent);
84 74
85dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size, 75static void dma_iommu_unmap_sg(struct device *dev, struct scatterlist *sglist,
86 enum dma_data_direction direction) 76 int nelems, enum dma_data_direction direction)
87{ 77{
88 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 78 iommu_unmap_sg(dev->archdata.dma_data, sglist, nelems, direction);
89
90 BUG_ON(!dma_ops);
91
92 return dma_ops->map_single(dev, cpu_addr, size, direction);
93} 79}
94EXPORT_SYMBOL(dma_map_single);
95 80
96void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, 81/* We support DMA to/from any memory page via the iommu */
97 enum dma_data_direction direction) 82static int dma_iommu_dma_supported(struct device *dev, u64 mask)
98{ 83{
99 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 84 struct iommu_table *tbl = dev->archdata.dma_data;
100 85
101 BUG_ON(!dma_ops); 86 if (!tbl || tbl->it_offset > mask) {
102 87 printk(KERN_INFO
103 dma_ops->unmap_single(dev, dma_addr, size, direction); 88 "Warning: IOMMU offset too big for device mask\n");
89 if (tbl)
90 printk(KERN_INFO
91 "mask: 0x%08lx, table offset: 0x%08lx\n",
92 mask, tbl->it_offset);
93 else
94 printk(KERN_INFO "mask: 0x%08lx, table unavailable\n",
95 mask);
96 return 0;
97 } else
98 return 1;
104} 99}
105EXPORT_SYMBOL(dma_unmap_single);
106 100
107dma_addr_t dma_map_page(struct device *dev, struct page *page, 101struct dma_mapping_ops dma_iommu_ops = {
108 unsigned long offset, size_t size, 102 .alloc_coherent = dma_iommu_alloc_coherent,
109 enum dma_data_direction direction) 103 .free_coherent = dma_iommu_free_coherent,
110{ 104 .map_single = dma_iommu_map_single,
111 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 105 .unmap_single = dma_iommu_unmap_single,
106 .map_sg = dma_iommu_map_sg,
107 .unmap_sg = dma_iommu_unmap_sg,
108 .dma_supported = dma_iommu_dma_supported,
109};
110EXPORT_SYMBOL(dma_iommu_ops);
112 111
113 BUG_ON(!dma_ops); 112/*
113 * Generic direct DMA implementation
114 *
115 * This implementation supports a global offset that can be applied if
116 * the address at which memory is visible to devices is not 0.
117 */
118unsigned long dma_direct_offset;
114 119
115 return dma_ops->map_single(dev, page_address(page) + offset, size, 120static void *dma_direct_alloc_coherent(struct device *dev, size_t size,
116 direction); 121 dma_addr_t *dma_handle, gfp_t flag)
122{
123 struct page *page;
124 void *ret;
125 int node = dev->archdata.numa_node;
126
127 /* TODO: Maybe use the numa node here too ? */
128 page = alloc_pages_node(node, flag, get_order(size));
129 if (page == NULL)
130 return NULL;
131 ret = page_address(page);
132 memset(ret, 0, size);
133 *dma_handle = virt_to_abs(ret) | dma_direct_offset;
134
135 return ret;
117} 136}
118EXPORT_SYMBOL(dma_map_page);
119 137
120void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size, 138static void dma_direct_free_coherent(struct device *dev, size_t size,
121 enum dma_data_direction direction) 139 void *vaddr, dma_addr_t dma_handle)
122{ 140{
123 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 141 free_pages((unsigned long)vaddr, get_order(size));
142}
124 143
125 BUG_ON(!dma_ops); 144static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr,
145 size_t size,
146 enum dma_data_direction direction)
147{
148 return virt_to_abs(ptr) | dma_direct_offset;
149}
126 150
127 dma_ops->unmap_single(dev, dma_address, size, direction); 151static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr,
152 size_t size,
153 enum dma_data_direction direction)
154{
128} 155}
129EXPORT_SYMBOL(dma_unmap_page);
130 156
131int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 157static int dma_direct_map_sg(struct device *dev, struct scatterlist *sg,
132 enum dma_data_direction direction) 158 int nents, enum dma_data_direction direction)
133{ 159{
134 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 160 int i;
135 161
136 BUG_ON(!dma_ops); 162 for (i = 0; i < nents; i++, sg++) {
163 sg->dma_address = (page_to_phys(sg->page) + sg->offset) |
164 dma_direct_offset;
165 sg->dma_length = sg->length;
166 }
137 167
138 return dma_ops->map_sg(dev, sg, nents, direction); 168 return nents;
139} 169}
140EXPORT_SYMBOL(dma_map_sg);
141 170
142void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries, 171static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
143 enum dma_data_direction direction) 172 int nents, enum dma_data_direction direction)
144{ 173{
145 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 174}
146
147 BUG_ON(!dma_ops);
148 175
149 dma_ops->unmap_sg(dev, sg, nhwentries, direction); 176static int dma_direct_dma_supported(struct device *dev, u64 mask)
177{
178 /* Could be improved to check for memory though it better be
179 * done via some global so platforms can set the limit in case
180 * they have limited DMA windows
181 */
182 return mask >= DMA_32BIT_MASK;
150} 183}
151EXPORT_SYMBOL(dma_unmap_sg); 184
185struct dma_mapping_ops dma_direct_ops = {
186 .alloc_coherent = dma_direct_alloc_coherent,
187 .free_coherent = dma_direct_free_coherent,
188 .map_single = dma_direct_map_single,
189 .unmap_single = dma_direct_unmap_single,
190 .map_sg = dma_direct_map_sg,
191 .unmap_sg = dma_direct_unmap_sg,
192 .dma_supported = dma_direct_dma_supported,
193};
194EXPORT_SYMBOL(dma_direct_ops);
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 748e74fcf541..1a3d4de197d2 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -87,15 +87,19 @@ system_call_common:
87 addi r9,r1,STACK_FRAME_OVERHEAD 87 addi r9,r1,STACK_FRAME_OVERHEAD
88 ld r11,exception_marker@toc(r2) 88 ld r11,exception_marker@toc(r2)
89 std r11,-16(r9) /* "regshere" marker */ 89 std r11,-16(r9) /* "regshere" marker */
90 li r10,1
91 stb r10,PACASOFTIRQEN(r13)
92 stb r10,PACAHARDIRQEN(r13)
93 std r10,SOFTE(r1)
90#ifdef CONFIG_PPC_ISERIES 94#ifdef CONFIG_PPC_ISERIES
91BEGIN_FW_FTR_SECTION 95BEGIN_FW_FTR_SECTION
92 /* Hack for handling interrupts when soft-enabling on iSeries */ 96 /* Hack for handling interrupts when soft-enabling on iSeries */
93 cmpdi cr1,r0,0x5555 /* syscall 0x5555 */ 97 cmpdi cr1,r0,0x5555 /* syscall 0x5555 */
94 andi. r10,r12,MSR_PR /* from kernel */ 98 andi. r10,r12,MSR_PR /* from kernel */
95 crand 4*cr0+eq,4*cr1+eq,4*cr0+eq 99 crand 4*cr0+eq,4*cr1+eq,4*cr0+eq
96 beq hardware_interrupt_entry 100 bne 2f
97 lbz r10,PACAPROCENABLED(r13) 101 b hardware_interrupt_entry
98 std r10,SOFTE(r1) 1022:
99END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 103END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
100#endif 104#endif
101 mfmsr r11 105 mfmsr r11
@@ -460,9 +464,9 @@ _GLOBAL(ret_from_except_lite)
460#endif 464#endif
461 465
462restore: 466restore:
467 ld r5,SOFTE(r1)
463#ifdef CONFIG_PPC_ISERIES 468#ifdef CONFIG_PPC_ISERIES
464BEGIN_FW_FTR_SECTION 469BEGIN_FW_FTR_SECTION
465 ld r5,SOFTE(r1)
466 cmpdi 0,r5,0 470 cmpdi 0,r5,0
467 beq 4f 471 beq 4f
468 /* Check for pending interrupts (iSeries) */ 472 /* Check for pending interrupts (iSeries) */
@@ -472,21 +476,25 @@ BEGIN_FW_FTR_SECTION
472 beq+ 4f /* skip do_IRQ if no interrupts */ 476 beq+ 4f /* skip do_IRQ if no interrupts */
473 477
474 li r3,0 478 li r3,0
475 stb r3,PACAPROCENABLED(r13) /* ensure we are soft-disabled */ 479 stb r3,PACASOFTIRQEN(r13) /* ensure we are soft-disabled */
476 ori r10,r10,MSR_EE 480 ori r10,r10,MSR_EE
477 mtmsrd r10 /* hard-enable again */ 481 mtmsrd r10 /* hard-enable again */
478 addi r3,r1,STACK_FRAME_OVERHEAD 482 addi r3,r1,STACK_FRAME_OVERHEAD
479 bl .do_IRQ 483 bl .do_IRQ
480 b .ret_from_except_lite /* loop back and handle more */ 484 b .ret_from_except_lite /* loop back and handle more */
481 4854:
4824: stb r5,PACAPROCENABLED(r13)
483END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 486END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
484#endif 487#endif
488 stb r5,PACASOFTIRQEN(r13)
485 489
486 ld r3,_MSR(r1) 490 ld r3,_MSR(r1)
487 andi. r0,r3,MSR_RI 491 andi. r0,r3,MSR_RI
488 beq- unrecov_restore 492 beq- unrecov_restore
489 493
494 /* extract EE bit and use it to restore paca->hard_enabled */
495 rldicl r4,r3,49,63 /* r0 = (r3 >> 15) & 1 */
496 stb r4,PACAHARDIRQEN(r13)
497
490 andi. r0,r3,MSR_PR 498 andi. r0,r3,MSR_PR
491 499
492 /* 500 /*
@@ -538,25 +546,15 @@ do_work:
538 /* Check that preempt_count() == 0 and interrupts are enabled */ 546 /* Check that preempt_count() == 0 and interrupts are enabled */
539 lwz r8,TI_PREEMPT(r9) 547 lwz r8,TI_PREEMPT(r9)
540 cmpwi cr1,r8,0 548 cmpwi cr1,r8,0
541#ifdef CONFIG_PPC_ISERIES
542BEGIN_FW_FTR_SECTION
543 ld r0,SOFTE(r1) 549 ld r0,SOFTE(r1)
544 cmpdi r0,0 550 cmpdi r0,0
545END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
546#endif
547BEGIN_FW_FTR_SECTION
548 andi. r0,r3,MSR_EE
549END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
550 crandc eq,cr1*4+eq,eq 551 crandc eq,cr1*4+eq,eq
551 bne restore 552 bne restore
552 /* here we are preempting the current task */ 553 /* here we are preempting the current task */
5531: 5541:
554#ifdef CONFIG_PPC_ISERIES
555BEGIN_FW_FTR_SECTION
556 li r0,1 555 li r0,1
557 stb r0,PACAPROCENABLED(r13) 556 stb r0,PACASOFTIRQEN(r13)
558END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 557 stb r0,PACAHARDIRQEN(r13)
559#endif
560 ori r10,r10,MSR_EE 558 ori r10,r10,MSR_EE
561 mtmsrd r10,1 /* reenable interrupts */ 559 mtmsrd r10,1 /* reenable interrupts */
562 bl .preempt_schedule 560 bl .preempt_schedule
@@ -639,8 +637,7 @@ _GLOBAL(enter_rtas)
639 /* There is no way it is acceptable to get here with interrupts enabled, 637 /* There is no way it is acceptable to get here with interrupts enabled,
640 * check it with the asm equivalent of WARN_ON 638 * check it with the asm equivalent of WARN_ON
641 */ 639 */
642 mfmsr r6 640 lbz r0,PACASOFTIRQEN(r13)
643 andi. r0,r6,MSR_EE
6441: tdnei r0,0 6411: tdnei r0,0
645.section __bug_table,"a" 642.section __bug_table,"a"
646 .llong 1b,__LINE__ + 0x1000000, 1f, 2f 643 .llong 1b,__LINE__ + 0x1000000, 1f, 2f
@@ -649,7 +646,13 @@ _GLOBAL(enter_rtas)
6491: .asciz __FILE__ 6461: .asciz __FILE__
6502: .asciz "enter_rtas" 6472: .asciz "enter_rtas"
651.previous 648.previous
652 649
650 /* Hard-disable interrupts */
651 mfmsr r6
652 rldicl r7,r6,48,1
653 rotldi r7,r7,16
654 mtmsrd r7,1
655
653 /* Unfortunately, the stack pointer and the MSR are also clobbered, 656 /* Unfortunately, the stack pointer and the MSR are also clobbered,
654 * so they are saved in the PACA which allows us to restore 657 * so they are saved in the PACA which allows us to restore
655 * our original state after RTAS returns. 658 * our original state after RTAS returns.
@@ -735,8 +738,6 @@ _STATIC(rtas_restore_regs)
735 738
736#endif /* CONFIG_PPC_RTAS */ 739#endif /* CONFIG_PPC_RTAS */
737 740
738#ifdef CONFIG_PPC_MULTIPLATFORM
739
740_GLOBAL(enter_prom) 741_GLOBAL(enter_prom)
741 mflr r0 742 mflr r0
742 std r0,16(r1) 743 std r0,16(r1)
@@ -821,5 +822,3 @@ _GLOBAL(enter_prom)
821 ld r0,16(r1) 822 ld r0,16(r1)
822 mtlr r0 823 mtlr r0
823 blr 824 blr
824
825#endif /* CONFIG_PPC_MULTIPLATFORM */
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index e720729f3e55..71b1fe58e9e4 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -35,9 +35,7 @@
35#include <asm/thread_info.h> 35#include <asm/thread_info.h>
36#include <asm/firmware.h> 36#include <asm/firmware.h>
37 37
38#ifdef CONFIG_PPC_ISERIES
39#define DO_SOFT_DISABLE 38#define DO_SOFT_DISABLE
40#endif
41 39
42/* 40/*
43 * We layout physical memory as follows: 41 * We layout physical memory as follows:
@@ -74,13 +72,11 @@
74 .text 72 .text
75 .globl _stext 73 .globl _stext
76_stext: 74_stext:
77#ifdef CONFIG_PPC_MULTIPLATFORM
78_GLOBAL(__start) 75_GLOBAL(__start)
79 /* NOP this out unconditionally */ 76 /* NOP this out unconditionally */
80BEGIN_FTR_SECTION 77BEGIN_FTR_SECTION
81 b .__start_initialization_multiplatform 78 b .__start_initialization_multiplatform
82END_FTR_SECTION(0, 1) 79END_FTR_SECTION(0, 1)
83#endif /* CONFIG_PPC_MULTIPLATFORM */
84 80
85 /* Catch branch to 0 in real mode */ 81 /* Catch branch to 0 in real mode */
86 trap 82 trap
@@ -308,7 +304,9 @@ exception_marker:
308 std r9,_LINK(r1); \ 304 std r9,_LINK(r1); \
309 mfctr r10; /* save CTR in stackframe */ \ 305 mfctr r10; /* save CTR in stackframe */ \
310 std r10,_CTR(r1); \ 306 std r10,_CTR(r1); \
307 lbz r10,PACASOFTIRQEN(r13); \
311 mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 308 mfspr r11,SPRN_XER; /* save XER in stackframe */ \
309 std r10,SOFTE(r1); \
312 std r11,_XER(r1); \ 310 std r11,_XER(r1); \
313 li r9,(n)+1; \ 311 li r9,(n)+1; \
314 std r9,_TRAP(r1); /* set trap number */ \ 312 std r9,_TRAP(r1); /* set trap number */ \
@@ -343,6 +341,34 @@ label##_pSeries: \
343 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) 341 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
344 342
345 343
344#define MASKABLE_EXCEPTION_PSERIES(n, label) \
345 . = n; \
346 .globl label##_pSeries; \
347label##_pSeries: \
348 HMT_MEDIUM; \
349 mtspr SPRN_SPRG1,r13; /* save r13 */ \
350 mfspr r13,SPRN_SPRG3; /* get paca address into r13 */ \
351 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \
352 std r10,PACA_EXGEN+EX_R10(r13); \
353 lbz r10,PACASOFTIRQEN(r13); \
354 mfcr r9; \
355 cmpwi r10,0; \
356 beq masked_interrupt; \
357 mfspr r10,SPRN_SPRG1; \
358 std r10,PACA_EXGEN+EX_R13(r13); \
359 std r11,PACA_EXGEN+EX_R11(r13); \
360 std r12,PACA_EXGEN+EX_R12(r13); \
361 clrrdi r12,r13,32; /* get high part of &label */ \
362 mfmsr r10; \
363 mfspr r11,SPRN_SRR0; /* save SRR0 */ \
364 LOAD_HANDLER(r12,label##_common) \
365 ori r10,r10,MSR_IR|MSR_DR|MSR_RI; \
366 mtspr SPRN_SRR0,r12; \
367 mfspr r12,SPRN_SRR1; /* and SRR1 */ \
368 mtspr SPRN_SRR1,r10; \
369 rfid; \
370 b . /* prevent speculative execution */
371
346#define STD_EXCEPTION_ISERIES(n, label, area) \ 372#define STD_EXCEPTION_ISERIES(n, label, area) \
347 .globl label##_iSeries; \ 373 .globl label##_iSeries; \
348label##_iSeries: \ 374label##_iSeries: \
@@ -358,40 +384,32 @@ label##_iSeries: \
358 HMT_MEDIUM; \ 384 HMT_MEDIUM; \
359 mtspr SPRN_SPRG1,r13; /* save r13 */ \ 385 mtspr SPRN_SPRG1,r13; /* save r13 */ \
360 EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN); \ 386 EXCEPTION_PROLOG_ISERIES_1(PACA_EXGEN); \
361 lbz r10,PACAPROCENABLED(r13); \ 387 lbz r10,PACASOFTIRQEN(r13); \
362 cmpwi 0,r10,0; \ 388 cmpwi 0,r10,0; \
363 beq- label##_iSeries_masked; \ 389 beq- label##_iSeries_masked; \
364 EXCEPTION_PROLOG_ISERIES_2; \ 390 EXCEPTION_PROLOG_ISERIES_2; \
365 b label##_common; \ 391 b label##_common; \
366 392
367#ifdef DO_SOFT_DISABLE 393#ifdef CONFIG_PPC_ISERIES
368#define DISABLE_INTS \ 394#define DISABLE_INTS \
369BEGIN_FW_FTR_SECTION; \
370 lbz r10,PACAPROCENABLED(r13); \
371 li r11,0; \ 395 li r11,0; \
372 std r10,SOFTE(r1); \ 396 stb r11,PACASOFTIRQEN(r13); \
397BEGIN_FW_FTR_SECTION; \
398 stb r11,PACAHARDIRQEN(r13); \
399END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES); \
400BEGIN_FW_FTR_SECTION; \
373 mfmsr r10; \ 401 mfmsr r10; \
374 stb r11,PACAPROCENABLED(r13); \
375 ori r10,r10,MSR_EE; \ 402 ori r10,r10,MSR_EE; \
376 mtmsrd r10,1; \ 403 mtmsrd r10,1; \
377END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 404END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
378 405
379#define ENABLE_INTS \ 406#else
380BEGIN_FW_FTR_SECTION; \ 407#define DISABLE_INTS \
381 lbz r10,PACAPROCENABLED(r13); \ 408 li r11,0; \
382 mfmsr r11; \ 409 stb r11,PACASOFTIRQEN(r13); \
383 std r10,SOFTE(r1); \ 410 stb r11,PACAHARDIRQEN(r13)
384 ori r11,r11,MSR_EE; \
385END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES); \
386BEGIN_FW_FTR_SECTION; \
387 ld r12,_MSR(r1); \
388 mfmsr r11; \
389 rlwimi r11,r12,0,MSR_EE; \
390END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES); \
391 mtmsrd r11,1
392 411
393#else /* hard enable/disable interrupts */ 412#endif /* CONFIG_PPC_ISERIES */
394#define DISABLE_INTS
395 413
396#define ENABLE_INTS \ 414#define ENABLE_INTS \
397 ld r12,_MSR(r1); \ 415 ld r12,_MSR(r1); \
@@ -399,8 +417,6 @@ END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES); \
399 rlwimi r11,r12,0,MSR_EE; \ 417 rlwimi r11,r12,0,MSR_EE; \
400 mtmsrd r11,1 418 mtmsrd r11,1
401 419
402#endif
403
404#define STD_EXCEPTION_COMMON(trap, label, hdlr) \ 420#define STD_EXCEPTION_COMMON(trap, label, hdlr) \
405 .align 7; \ 421 .align 7; \
406 .globl label##_common; \ 422 .globl label##_common; \
@@ -541,11 +557,11 @@ instruction_access_slb_pSeries:
541 mfspr r12,SPRN_SRR1 /* and SRR1 */ 557 mfspr r12,SPRN_SRR1 /* and SRR1 */
542 b .slb_miss_realmode /* Rel. branch works in real mode */ 558 b .slb_miss_realmode /* Rel. branch works in real mode */
543 559
544 STD_EXCEPTION_PSERIES(0x500, hardware_interrupt) 560 MASKABLE_EXCEPTION_PSERIES(0x500, hardware_interrupt)
545 STD_EXCEPTION_PSERIES(0x600, alignment) 561 STD_EXCEPTION_PSERIES(0x600, alignment)
546 STD_EXCEPTION_PSERIES(0x700, program_check) 562 STD_EXCEPTION_PSERIES(0x700, program_check)
547 STD_EXCEPTION_PSERIES(0x800, fp_unavailable) 563 STD_EXCEPTION_PSERIES(0x800, fp_unavailable)
548 STD_EXCEPTION_PSERIES(0x900, decrementer) 564 MASKABLE_EXCEPTION_PSERIES(0x900, decrementer)
549 STD_EXCEPTION_PSERIES(0xa00, trap_0a) 565 STD_EXCEPTION_PSERIES(0xa00, trap_0a)
550 STD_EXCEPTION_PSERIES(0xb00, trap_0b) 566 STD_EXCEPTION_PSERIES(0xb00, trap_0b)
551 567
@@ -597,7 +613,24 @@ system_call_pSeries:
597/*** pSeries interrupt support ***/ 613/*** pSeries interrupt support ***/
598 614
599 /* moved from 0xf00 */ 615 /* moved from 0xf00 */
600 STD_EXCEPTION_PSERIES(., performance_monitor) 616 MASKABLE_EXCEPTION_PSERIES(., performance_monitor)
617
618/*
619 * An interrupt came in while soft-disabled; clear EE in SRR1,
620 * clear paca->hard_enabled and return.
621 */
622masked_interrupt:
623 stb r10,PACAHARDIRQEN(r13)
624 mtcrf 0x80,r9
625 ld r9,PACA_EXGEN+EX_R9(r13)
626 mfspr r10,SPRN_SRR1
627 rldicl r10,r10,48,1 /* clear MSR_EE */
628 rotldi r10,r10,16
629 mtspr SPRN_SRR1,r10
630 ld r10,PACA_EXGEN+EX_R10(r13)
631 mfspr r13,SPRN_SPRG1
632 rfid
633 b .
601 634
602 .align 7 635 .align 7
603do_stab_bolted_pSeries: 636do_stab_bolted_pSeries:
@@ -792,7 +825,7 @@ system_reset_iSeries:
792 825
793 cmpwi 0,r23,0 826 cmpwi 0,r23,0
794 beq iSeries_secondary_smp_loop /* Loop until told to go */ 827 beq iSeries_secondary_smp_loop /* Loop until told to go */
795 bne .__secondary_start /* Loop until told to go */ 828 bne __secondary_start /* Loop until told to go */
796iSeries_secondary_smp_loop: 829iSeries_secondary_smp_loop:
797 /* Let the Hypervisor know we are alive */ 830 /* Let the Hypervisor know we are alive */
798 /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */ 831 /* 8002 is a call to HvCallCfg::getLps, a harmless Hypervisor function */
@@ -813,7 +846,6 @@ iSeries_secondary_smp_loop:
813 b 1b /* If SMP not configured, secondaries 846 b 1b /* If SMP not configured, secondaries
814 * loop forever */ 847 * loop forever */
815 848
816 .globl decrementer_iSeries_masked
817decrementer_iSeries_masked: 849decrementer_iSeries_masked:
818 /* We may not have a valid TOC pointer in here. */ 850 /* We may not have a valid TOC pointer in here. */
819 li r11,1 851 li r11,1
@@ -824,7 +856,6 @@ decrementer_iSeries_masked:
824 mtspr SPRN_DEC,r12 856 mtspr SPRN_DEC,r12
825 /* fall through */ 857 /* fall through */
826 858
827 .globl hardware_interrupt_iSeries_masked
828hardware_interrupt_iSeries_masked: 859hardware_interrupt_iSeries_masked:
829 mtcrf 0x80,r9 /* Restore regs */ 860 mtcrf 0x80,r9 /* Restore regs */
830 ld r12,PACALPPACAPTR(r13) 861 ld r12,PACALPPACAPTR(r13)
@@ -926,10 +957,18 @@ bad_stack:
926 * any task or sent any task a signal, you should use 957 * any task or sent any task a signal, you should use
927 * ret_from_except or ret_from_except_lite instead of this. 958 * ret_from_except or ret_from_except_lite instead of this.
928 */ 959 */
960fast_exc_return_irq: /* restores irq state too */
961 ld r3,SOFTE(r1)
962 ld r12,_MSR(r1)
963 stb r3,PACASOFTIRQEN(r13) /* restore paca->soft_enabled */
964 rldicl r4,r12,49,63 /* get MSR_EE to LSB */
965 stb r4,PACAHARDIRQEN(r13) /* restore paca->hard_enabled */
966 b 1f
967
929 .globl fast_exception_return 968 .globl fast_exception_return
930fast_exception_return: 969fast_exception_return:
931 ld r12,_MSR(r1) 970 ld r12,_MSR(r1)
932 ld r11,_NIP(r1) 9711: ld r11,_NIP(r1)
933 andi. r3,r12,MSR_RI /* check if RI is set */ 972 andi. r3,r12,MSR_RI /* check if RI is set */
934 beq- unrecov_fer 973 beq- unrecov_fer
935 974
@@ -952,7 +991,8 @@ fast_exception_return:
952 REST_8GPRS(2, r1) 991 REST_8GPRS(2, r1)
953 992
954 mfmsr r10 993 mfmsr r10
955 clrrdi r10,r10,2 /* clear RI (LE is 0 already) */ 994 rldicl r10,r10,48,1 /* clear EE */
995 rldicr r10,r10,16,61 /* clear RI (LE is 0 already) */
956 mtmsrd r10,1 996 mtmsrd r10,1
957 997
958 mtspr SPRN_SRR1,r12 998 mtspr SPRN_SRR1,r12
@@ -1326,6 +1366,16 @@ BEGIN_FW_FTR_SECTION
1326 * interrupts if necessary. 1366 * interrupts if necessary.
1327 */ 1367 */
1328 beq 13f 1368 beq 13f
1369END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
1370#endif
1371BEGIN_FW_FTR_SECTION
1372 /*
1373 * Here we have interrupts hard-disabled, so it is sufficient
1374 * to restore paca->{soft,hard}_enable and get out.
1375 */
1376 beq fast_exc_return_irq /* Return from exception on success */
1377END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
1378
1329 /* For a hash failure, we don't bother re-enabling interrupts */ 1379 /* For a hash failure, we don't bother re-enabling interrupts */
1330 ble- 12f 1380 ble- 12f
1331 1381
@@ -1337,14 +1387,6 @@ BEGIN_FW_FTR_SECTION
1337 ld r3,SOFTE(r1) 1387 ld r3,SOFTE(r1)
1338 bl .local_irq_restore 1388 bl .local_irq_restore
1339 b 11f 1389 b 11f
1340END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
1341#endif
1342BEGIN_FW_FTR_SECTION
1343 beq fast_exception_return /* Return from exception on success */
1344 ble- 12f /* Failure return from hash_page */
1345
1346 /* fall through */
1347END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
1348 1390
1349/* Here we have a page fault that hash_page can't handle. */ 1391/* Here we have a page fault that hash_page can't handle. */
1350handle_page_fault: 1392handle_page_fault:
@@ -1362,6 +1404,8 @@ handle_page_fault:
1362 bl .bad_page_fault 1404 bl .bad_page_fault
1363 b .ret_from_except 1405 b .ret_from_except
1364 1406
140713: b .ret_from_except_lite
1408
1365/* We have a page fault that hash_page could handle but HV refused 1409/* We have a page fault that hash_page could handle but HV refused
1366 * the PTE insertion 1410 * the PTE insertion
1367 */ 1411 */
@@ -1371,8 +1415,6 @@ handle_page_fault:
1371 bl .low_hash_fault 1415 bl .low_hash_fault
1372 b .ret_from_except 1416 b .ret_from_except
1373 1417
137413: b .ret_from_except_lite
1375
1376 /* here we have a segment miss */ 1418 /* here we have a segment miss */
1377do_ste_alloc: 1419do_ste_alloc:
1378 bl .ste_allocate /* try to insert stab entry */ 1420 bl .ste_allocate /* try to insert stab entry */
@@ -1560,7 +1602,7 @@ _GLOBAL(generic_secondary_smp_init)
1560 ld r1,PACAEMERGSP(r13) 1602 ld r1,PACAEMERGSP(r13)
1561 subi r1,r1,STACK_FRAME_OVERHEAD 1603 subi r1,r1,STACK_FRAME_OVERHEAD
1562 1604
1563 b .__secondary_start 1605 b __secondary_start
1564#endif 1606#endif
1565 1607
1566#ifdef CONFIG_PPC_ISERIES 1608#ifdef CONFIG_PPC_ISERIES
@@ -1595,7 +1637,6 @@ _STATIC(__start_initialization_iSeries)
1595 b .start_here_common 1637 b .start_here_common
1596#endif /* CONFIG_PPC_ISERIES */ 1638#endif /* CONFIG_PPC_ISERIES */
1597 1639
1598#ifdef CONFIG_PPC_MULTIPLATFORM
1599 1640
1600_STATIC(__mmu_off) 1641_STATIC(__mmu_off)
1601 mfmsr r3 1642 mfmsr r3
@@ -1621,13 +1662,11 @@ _STATIC(__mmu_off)
1621 * 1662 *
1622 */ 1663 */
1623_GLOBAL(__start_initialization_multiplatform) 1664_GLOBAL(__start_initialization_multiplatform)
1624#ifdef CONFIG_PPC_MULTIPLATFORM
1625 /* 1665 /*
1626 * Are we booted from a PROM Of-type client-interface ? 1666 * Are we booted from a PROM Of-type client-interface ?
1627 */ 1667 */
1628 cmpldi cr0,r5,0 1668 cmpldi cr0,r5,0
1629 bne .__boot_from_prom /* yes -> prom */ 1669 bne .__boot_from_prom /* yes -> prom */
1630#endif
1631 1670
1632 /* Save parameters */ 1671 /* Save parameters */
1633 mr r31,r3 1672 mr r31,r3
@@ -1656,7 +1695,6 @@ _GLOBAL(__start_initialization_multiplatform)
1656 bl .__mmu_off 1695 bl .__mmu_off
1657 b .__after_prom_start 1696 b .__after_prom_start
1658 1697
1659#ifdef CONFIG_PPC_MULTIPLATFORM
1660_STATIC(__boot_from_prom) 1698_STATIC(__boot_from_prom)
1661 /* Save parameters */ 1699 /* Save parameters */
1662 mr r31,r3 1700 mr r31,r3
@@ -1696,7 +1734,6 @@ _STATIC(__boot_from_prom)
1696 bl .prom_init 1734 bl .prom_init
1697 /* We never return */ 1735 /* We never return */
1698 trap 1736 trap
1699#endif
1700 1737
1701/* 1738/*
1702 * At this point, r3 contains the physical address we are running at, 1739 * At this point, r3 contains the physical address we are running at,
@@ -1752,8 +1789,6 @@ _STATIC(__after_prom_start)
1752 bl .copy_and_flush /* copy the rest */ 1789 bl .copy_and_flush /* copy the rest */
1753 b .start_here_multiplatform 1790 b .start_here_multiplatform
1754 1791
1755#endif /* CONFIG_PPC_MULTIPLATFORM */
1756
1757/* 1792/*
1758 * Copy routine used to copy the kernel to start at physical address 0 1793 * Copy routine used to copy the kernel to start at physical address 0
1759 * and flush and invalidate the caches as needed. 1794 * and flush and invalidate the caches as needed.
@@ -1836,7 +1871,7 @@ _GLOBAL(pmac_secondary_start)
1836 ld r1,PACAEMERGSP(r13) 1871 ld r1,PACAEMERGSP(r13)
1837 subi r1,r1,STACK_FRAME_OVERHEAD 1872 subi r1,r1,STACK_FRAME_OVERHEAD
1838 1873
1839 b .__secondary_start 1874 b __secondary_start
1840 1875
1841#endif /* CONFIG_PPC_PMAC */ 1876#endif /* CONFIG_PPC_PMAC */
1842 1877
@@ -1853,7 +1888,7 @@ _GLOBAL(pmac_secondary_start)
1853 * r13 = paca virtual address 1888 * r13 = paca virtual address
1854 * SPRG3 = paca virtual address 1889 * SPRG3 = paca virtual address
1855 */ 1890 */
1856_GLOBAL(__secondary_start) 1891__secondary_start:
1857 /* Set thread priority to MEDIUM */ 1892 /* Set thread priority to MEDIUM */
1858 HMT_MEDIUM 1893 HMT_MEDIUM
1859 1894
@@ -1877,11 +1912,16 @@ _GLOBAL(__secondary_start)
1877 /* enable MMU and jump to start_secondary */ 1912 /* enable MMU and jump to start_secondary */
1878 LOAD_REG_ADDR(r3, .start_secondary_prolog) 1913 LOAD_REG_ADDR(r3, .start_secondary_prolog)
1879 LOAD_REG_IMMEDIATE(r4, MSR_KERNEL) 1914 LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
1880#ifdef DO_SOFT_DISABLE 1915#ifdef CONFIG_PPC_ISERIES
1881BEGIN_FW_FTR_SECTION 1916BEGIN_FW_FTR_SECTION
1882 ori r4,r4,MSR_EE 1917 ori r4,r4,MSR_EE
1883END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 1918END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
1884#endif 1919#endif
1920BEGIN_FW_FTR_SECTION
1921 stb r7,PACASOFTIRQEN(r13)
1922 stb r7,PACAHARDIRQEN(r13)
1923END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
1924
1885 mtspr SPRN_SRR0,r3 1925 mtspr SPRN_SRR0,r3
1886 mtspr SPRN_SRR1,r4 1926 mtspr SPRN_SRR1,r4
1887 rfid 1927 rfid
@@ -1913,7 +1953,6 @@ _GLOBAL(enable_64b_mode)
1913 isync 1953 isync
1914 blr 1954 blr
1915 1955
1916#ifdef CONFIG_PPC_MULTIPLATFORM
1917/* 1956/*
1918 * This is where the main kernel code starts. 1957 * This is where the main kernel code starts.
1919 */ 1958 */
@@ -1977,7 +2016,6 @@ _STATIC(start_here_multiplatform)
1977 mtspr SPRN_SRR1,r4 2016 mtspr SPRN_SRR1,r4
1978 rfid 2017 rfid
1979 b . /* prevent speculative execution */ 2018 b . /* prevent speculative execution */
1980#endif /* CONFIG_PPC_MULTIPLATFORM */
1981 2019
1982 /* This is where all platforms converge execution */ 2020 /* This is where all platforms converge execution */
1983_STATIC(start_here_common) 2021_STATIC(start_here_common)
@@ -2005,15 +2043,18 @@ _STATIC(start_here_common)
2005 2043
2006 /* Load up the kernel context */ 2044 /* Load up the kernel context */
20075: 20455:
2008#ifdef DO_SOFT_DISABLE
2009BEGIN_FW_FTR_SECTION
2010 li r5,0 2046 li r5,0
2011 stb r5,PACAPROCENABLED(r13) /* Soft Disabled */ 2047 stb r5,PACASOFTIRQEN(r13) /* Soft Disabled */
2048#ifdef CONFIG_PPC_ISERIES
2049BEGIN_FW_FTR_SECTION
2012 mfmsr r5 2050 mfmsr r5
2013 ori r5,r5,MSR_EE /* Hard Enabled */ 2051 ori r5,r5,MSR_EE /* Hard Enabled */
2014 mtmsrd r5 2052 mtmsrd r5
2015END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES) 2053END_FW_FTR_SECTION_IFSET(FW_FEATURE_ISERIES)
2016#endif 2054#endif
2055BEGIN_FW_FTR_SECTION
2056 stb r5,PACAHARDIRQEN(r13)
2057END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
2017 2058
2018 bl .start_kernel 2059 bl .start_kernel
2019 2060
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 39db7a3affe1..82bd2f10770f 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -112,7 +112,7 @@ static int ibmebus_dma_supported(struct device *dev, u64 mask)
112 return 1; 112 return 1;
113} 113}
114 114
115struct dma_mapping_ops ibmebus_dma_ops = { 115static struct dma_mapping_ops ibmebus_dma_ops = {
116 .alloc_coherent = ibmebus_alloc_coherent, 116 .alloc_coherent = ibmebus_alloc_coherent,
117 .free_coherent = ibmebus_free_coherent, 117 .free_coherent = ibmebus_free_coherent,
118 .map_single = ibmebus_map_single, 118 .map_single = ibmebus_map_single,
@@ -176,6 +176,10 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_common(
176 dev->ofdev.dev.bus = &ibmebus_bus_type; 176 dev->ofdev.dev.bus = &ibmebus_bus_type;
177 dev->ofdev.dev.release = ibmebus_dev_release; 177 dev->ofdev.dev.release = ibmebus_dev_release;
178 178
179 dev->ofdev.dev.archdata.of_node = dev->ofdev.node;
180 dev->ofdev.dev.archdata.dma_ops = &ibmebus_dma_ops;
181 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node);
182
179 /* An ibmebusdev is based on a of_device. We have to change the 183 /* An ibmebusdev is based on a of_device. We have to change the
180 * bus type to use our own DMA mapping operations. 184 * bus type to use our own DMA mapping operations.
181 */ 185 */
@@ -210,11 +214,10 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
210 return NULL; 214 return NULL;
211 } 215 }
212 216
213 dev = kmalloc(sizeof(struct ibmebus_dev), GFP_KERNEL); 217 dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL);
214 if (!dev) { 218 if (!dev) {
215 return NULL; 219 return NULL;
216 } 220 }
217 memset(dev, 0, sizeof(struct ibmebus_dev));
218 221
219 dev->ofdev.node = of_node_get(dn); 222 dev->ofdev.node = of_node_get(dn);
220 223
diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
index 4180c3998b39..8994af327b47 100644
--- a/arch/powerpc/kernel/idle.c
+++ b/arch/powerpc/kernel/idle.c
@@ -39,6 +39,13 @@
39#define cpu_should_die() 0 39#define cpu_should_die() 0
40#endif 40#endif
41 41
42static int __init powersave_off(char *arg)
43{
44 ppc_md.power_save = NULL;
45 return 0;
46}
47__setup("powersave=off", powersave_off);
48
42/* 49/*
43 * The body of the idle task. 50 * The body of the idle task.
44 */ 51 */
diff --git a/arch/powerpc/kernel/idle_power4.S b/arch/powerpc/kernel/idle_power4.S
index 30de81da7b40..ba3195478600 100644
--- a/arch/powerpc/kernel/idle_power4.S
+++ b/arch/powerpc/kernel/idle_power4.S
@@ -30,6 +30,13 @@ END_FTR_SECTION_IFCLR(CPU_FTR_CAN_NAP)
30 beqlr 30 beqlr
31 31
32 /* Go to NAP now */ 32 /* Go to NAP now */
33 mfmsr r7
34 rldicl r0,r7,48,1
35 rotldi r0,r0,16
36 mtmsrd r0,1 /* hard-disable interrupts */
37 li r0,1
38 stb r0,PACASOFTIRQEN(r13) /* we'll hard-enable shortly */
39 stb r0,PACAHARDIRQEN(r13)
33BEGIN_FTR_SECTION 40BEGIN_FTR_SECTION
34 DSSALL 41 DSSALL
35 sync 42 sync
@@ -38,7 +45,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
38 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */ 45 ld r8,TI_LOCAL_FLAGS(r9) /* set napping bit */
39 ori r8,r8,_TLF_NAPPING /* so when we take an exception */ 46 ori r8,r8,_TLF_NAPPING /* so when we take an exception */
40 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */ 47 std r8,TI_LOCAL_FLAGS(r9) /* it will return to our caller */
41 mfmsr r7
42 ori r7,r7,MSR_EE 48 ori r7,r7,MSR_EE
43 oris r7,r7,MSR_POW@h 49 oris r7,r7,MSR_POW@h
441: sync 501: sync
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
index e98180686b35..34ae11494ddc 100644
--- a/arch/powerpc/kernel/io.c
+++ b/arch/powerpc/kernel/io.c
@@ -25,13 +25,11 @@
25#include <asm/firmware.h> 25#include <asm/firmware.h>
26#include <asm/bug.h> 26#include <asm/bug.h>
27 27
28void _insb(volatile u8 __iomem *port, void *buf, long count) 28void _insb(const volatile u8 __iomem *port, void *buf, long count)
29{ 29{
30 u8 *tbuf = buf; 30 u8 *tbuf = buf;
31 u8 tmp; 31 u8 tmp;
32 32
33 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
34
35 if (unlikely(count <= 0)) 33 if (unlikely(count <= 0))
36 return; 34 return;
37 asm volatile("sync"); 35 asm volatile("sync");
@@ -48,8 +46,6 @@ void _outsb(volatile u8 __iomem *port, const void *buf, long count)
48{ 46{
49 const u8 *tbuf = buf; 47 const u8 *tbuf = buf;
50 48
51 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
52
53 if (unlikely(count <= 0)) 49 if (unlikely(count <= 0))
54 return; 50 return;
55 asm volatile("sync"); 51 asm volatile("sync");
@@ -60,13 +56,11 @@ void _outsb(volatile u8 __iomem *port, const void *buf, long count)
60} 56}
61EXPORT_SYMBOL(_outsb); 57EXPORT_SYMBOL(_outsb);
62 58
63void _insw_ns(volatile u16 __iomem *port, void *buf, long count) 59void _insw_ns(const volatile u16 __iomem *port, void *buf, long count)
64{ 60{
65 u16 *tbuf = buf; 61 u16 *tbuf = buf;
66 u16 tmp; 62 u16 tmp;
67 63
68 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
69
70 if (unlikely(count <= 0)) 64 if (unlikely(count <= 0))
71 return; 65 return;
72 asm volatile("sync"); 66 asm volatile("sync");
@@ -83,8 +77,6 @@ void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count)
83{ 77{
84 const u16 *tbuf = buf; 78 const u16 *tbuf = buf;
85 79
86 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
87
88 if (unlikely(count <= 0)) 80 if (unlikely(count <= 0))
89 return; 81 return;
90 asm volatile("sync"); 82 asm volatile("sync");
@@ -95,13 +87,11 @@ void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count)
95} 87}
96EXPORT_SYMBOL(_outsw_ns); 88EXPORT_SYMBOL(_outsw_ns);
97 89
98void _insl_ns(volatile u32 __iomem *port, void *buf, long count) 90void _insl_ns(const volatile u32 __iomem *port, void *buf, long count)
99{ 91{
100 u32 *tbuf = buf; 92 u32 *tbuf = buf;
101 u32 tmp; 93 u32 tmp;
102 94
103 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
104
105 if (unlikely(count <= 0)) 95 if (unlikely(count <= 0))
106 return; 96 return;
107 asm volatile("sync"); 97 asm volatile("sync");
@@ -118,8 +108,6 @@ void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
118{ 108{
119 const u32 *tbuf = buf; 109 const u32 *tbuf = buf;
120 110
121 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
122
123 if (unlikely(count <= 0)) 111 if (unlikely(count <= 0))
124 return; 112 return;
125 asm volatile("sync"); 113 asm volatile("sync");
@@ -129,3 +117,90 @@ void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
129 asm volatile("sync"); 117 asm volatile("sync");
130} 118}
131EXPORT_SYMBOL(_outsl_ns); 119EXPORT_SYMBOL(_outsl_ns);
120
121#define IO_CHECK_ALIGN(v,a) ((((unsigned long)(v)) & ((a) - 1)) == 0)
122
123void _memset_io(volatile void __iomem *addr, int c, unsigned long n)
124{
125 void *p = (void __force *)addr;
126 u32 lc = c;
127 lc |= lc << 8;
128 lc |= lc << 16;
129
130 __asm__ __volatile__ ("sync" : : : "memory");
131 while(n && !IO_CHECK_ALIGN(p, 4)) {
132 *((volatile u8 *)p) = c;
133 p++;
134 n--;
135 }
136 while(n >= 4) {
137 *((volatile u32 *)p) = lc;
138 p += 4;
139 n -= 4;
140 }
141 while(n) {
142 *((volatile u8 *)p) = c;
143 p++;
144 n--;
145 }
146 __asm__ __volatile__ ("sync" : : : "memory");
147}
148EXPORT_SYMBOL(_memset_io);
149
150void _memcpy_fromio(void *dest, const volatile void __iomem *src,
151 unsigned long n)
152{
153 void *vsrc = (void __force *) src;
154
155 __asm__ __volatile__ ("sync" : : : "memory");
156 while(n && (!IO_CHECK_ALIGN(vsrc, 4) || !IO_CHECK_ALIGN(dest, 4))) {
157 *((u8 *)dest) = *((volatile u8 *)vsrc);
158 __asm__ __volatile__ ("eieio" : : : "memory");
159 vsrc++;
160 dest++;
161 n--;
162 }
163 while(n > 4) {
164 *((u32 *)dest) = *((volatile u32 *)vsrc);
165 __asm__ __volatile__ ("eieio" : : : "memory");
166 vsrc += 4;
167 dest += 4;
168 n -= 4;
169 }
170 while(n) {
171 *((u8 *)dest) = *((volatile u8 *)vsrc);
172 __asm__ __volatile__ ("eieio" : : : "memory");
173 vsrc++;
174 dest++;
175 n--;
176 }
177 __asm__ __volatile__ ("sync" : : : "memory");
178}
179EXPORT_SYMBOL(_memcpy_fromio);
180
181void _memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n)
182{
183 void *vdest = (void __force *) dest;
184
185 __asm__ __volatile__ ("sync" : : : "memory");
186 while(n && (!IO_CHECK_ALIGN(vdest, 4) || !IO_CHECK_ALIGN(src, 4))) {
187 *((volatile u8 *)vdest) = *((u8 *)src);
188 src++;
189 vdest++;
190 n--;
191 }
192 while(n > 4) {
193 *((volatile u32 *)vdest) = *((volatile u32 *)src);
194 src += 4;
195 vdest += 4;
196 n-=4;
197 }
198 while(n) {
199 *((volatile u8 *)vdest) = *((u8 *)src);
200 src++;
201 vdest++;
202 n--;
203 }
204 __asm__ __volatile__ ("sync" : : : "memory");
205}
206EXPORT_SYMBOL(_memcpy_toio);
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index a13a93dfc655..c68113371050 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -106,7 +106,7 @@ EXPORT_SYMBOL(iowrite32_rep);
106 106
107void __iomem *ioport_map(unsigned long port, unsigned int len) 107void __iomem *ioport_map(unsigned long port, unsigned int len)
108{ 108{
109 return (void __iomem *) (port+pci_io_base); 109 return (void __iomem *) (port + _IO_BASE);
110} 110}
111 111
112void ioport_unmap(void __iomem *addr) 112void ioport_unmap(void __iomem *addr)
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index ba6b7256084b..95edad4faf26 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -258,9 +258,9 @@ static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
258 spin_unlock_irqrestore(&(tbl->it_lock), flags); 258 spin_unlock_irqrestore(&(tbl->it_lock), flags);
259} 259}
260 260
261int iommu_map_sg(struct device *dev, struct iommu_table *tbl, 261int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
262 struct scatterlist *sglist, int nelems, 262 int nelems, unsigned long mask,
263 unsigned long mask, enum dma_data_direction direction) 263 enum dma_data_direction direction)
264{ 264{
265 dma_addr_t dma_next = 0, dma_addr; 265 dma_addr_t dma_next = 0, dma_addr;
266 unsigned long flags; 266 unsigned long flags;
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 5e37bf14ef2d..0bd8c7665834 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -64,8 +64,9 @@
64#include <asm/ptrace.h> 64#include <asm/ptrace.h>
65#include <asm/machdep.h> 65#include <asm/machdep.h>
66#include <asm/udbg.h> 66#include <asm/udbg.h>
67#ifdef CONFIG_PPC_ISERIES 67#ifdef CONFIG_PPC64
68#include <asm/paca.h> 68#include <asm/paca.h>
69#include <asm/firmware.h>
69#endif 70#endif
70 71
71int __irq_offset_value; 72int __irq_offset_value;
@@ -95,6 +96,74 @@ extern atomic_t ipi_sent;
95EXPORT_SYMBOL(irq_desc); 96EXPORT_SYMBOL(irq_desc);
96 97
97int distribute_irqs = 1; 98int distribute_irqs = 1;
99
100static inline unsigned long get_hard_enabled(void)
101{
102 unsigned long enabled;
103
104 __asm__ __volatile__("lbz %0,%1(13)"
105 : "=r" (enabled) : "i" (offsetof(struct paca_struct, hard_enabled)));
106
107 return enabled;
108}
109
110static inline void set_soft_enabled(unsigned long enable)
111{
112 __asm__ __volatile__("stb %0,%1(13)"
113 : : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled)));
114}
115
116void local_irq_restore(unsigned long en)
117{
118 /*
119 * get_paca()->soft_enabled = en;
120 * Is it ever valid to use local_irq_restore(0) when soft_enabled is 1?
121 * That was allowed before, and in such a case we do need to take care
122 * that gcc will set soft_enabled directly via r13, not choose to use
123 * an intermediate register, lest we're preempted to a different cpu.
124 */
125 set_soft_enabled(en);
126 if (!en)
127 return;
128
129 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
130 /*
131 * Do we need to disable preemption here? Not really: in the
132 * unlikely event that we're preempted to a different cpu in
133 * between getting r13, loading its lppaca_ptr, and loading
134 * its any_int, we might call iseries_handle_interrupts without
135 * an interrupt pending on the new cpu, but that's no disaster,
136 * is it? And the business of preempting us off the old cpu
137 * would itself involve a local_irq_restore which handles the
138 * interrupt to that cpu.
139 *
140 * But use "local_paca->lppaca_ptr" instead of "get_lppaca()"
141 * to avoid any preemption checking added into get_paca().
142 */
143 if (local_paca->lppaca_ptr->int_dword.any_int)
144 iseries_handle_interrupts();
145 return;
146 }
147
148 /*
149 * if (get_paca()->hard_enabled) return;
150 * But again we need to take care that gcc gets hard_enabled directly
151 * via r13, not choose to use an intermediate register, lest we're
152 * preempted to a different cpu in between the two instructions.
153 */
154 if (get_hard_enabled())
155 return;
156
157 /*
158 * Need to hard-enable interrupts here. Since currently disabled,
159 * no need to take further asm precautions against preemption; but
160 * use local_paca instead of get_paca() to avoid preemption checking.
161 */
162 local_paca->hard_enabled = en;
163 if ((int)mfspr(SPRN_DEC) < 0)
164 mtspr(SPRN_DEC, 1);
165 hard_irq_enable();
166}
98#endif /* CONFIG_PPC64 */ 167#endif /* CONFIG_PPC64 */
99 168
100int show_interrupts(struct seq_file *p, void *v) 169int show_interrupts(struct seq_file *p, void *v)
@@ -246,7 +315,8 @@ void do_IRQ(struct pt_regs *regs)
246 set_irq_regs(old_regs); 315 set_irq_regs(old_regs);
247 316
248#ifdef CONFIG_PPC_ISERIES 317#ifdef CONFIG_PPC_ISERIES
249 if (get_lppaca()->int_dword.fields.decr_int) { 318 if (firmware_has_feature(FW_FEATURE_ISERIES) &&
319 get_lppaca()->int_dword.fields.decr_int) {
250 get_lppaca()->int_dword.fields.decr_int = 0; 320 get_lppaca()->int_dword.fields.decr_int = 0;
251 /* Signal a fake decrementer interrupt */ 321 /* Signal a fake decrementer interrupt */
252 timer_interrupt(regs); 322 timer_interrupt(regs);
@@ -626,10 +696,14 @@ EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
626 696
627void irq_dispose_mapping(unsigned int virq) 697void irq_dispose_mapping(unsigned int virq)
628{ 698{
629 struct irq_host *host = irq_map[virq].host; 699 struct irq_host *host;
630 irq_hw_number_t hwirq; 700 irq_hw_number_t hwirq;
631 unsigned long flags; 701 unsigned long flags;
632 702
703 if (virq == NO_IRQ)
704 return;
705
706 host = irq_map[virq].host;
633 WARN_ON (host == NULL); 707 WARN_ON (host == NULL);
634 if (host == NULL) 708 if (host == NULL)
635 return; 709 return;
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 397c83eda20e..8a06724e029e 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -9,30 +9,26 @@
9#include <asm/of_device.h> 9#include <asm/of_device.h>
10 10
11/** 11/**
12 * of_match_device - Tell if an of_device structure has a matching 12 * of_match_node - Tell if an device_node has a matching of_match structure
13 * of_match structure
14 * @ids: array of of device match structures to search in 13 * @ids: array of of device match structures to search in
15 * @dev: the of device structure to match against 14 * @node: the of device structure to match against
16 * 15 *
17 * Used by a driver to check whether an of_device present in the 16 * Low level utility function used by device matching.
18 * system is in its list of supported devices.
19 */ 17 */
20const struct of_device_id *of_match_device(const struct of_device_id *matches, 18const struct of_device_id *of_match_node(const struct of_device_id *matches,
21 const struct of_device *dev) 19 const struct device_node *node)
22{ 20{
23 if (!dev->node)
24 return NULL;
25 while (matches->name[0] || matches->type[0] || matches->compatible[0]) { 21 while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
26 int match = 1; 22 int match = 1;
27 if (matches->name[0]) 23 if (matches->name[0])
28 match &= dev->node->name 24 match &= node->name
29 && !strcmp(matches->name, dev->node->name); 25 && !strcmp(matches->name, node->name);
30 if (matches->type[0]) 26 if (matches->type[0])
31 match &= dev->node->type 27 match &= node->type
32 && !strcmp(matches->type, dev->node->type); 28 && !strcmp(matches->type, node->type);
33 if (matches->compatible[0]) 29 if (matches->compatible[0])
34 match &= device_is_compatible(dev->node, 30 match &= device_is_compatible(node,
35 matches->compatible); 31 matches->compatible);
36 if (match) 32 if (match)
37 return matches; 33 return matches;
38 matches++; 34 matches++;
@@ -40,16 +36,21 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches,
40 return NULL; 36 return NULL;
41} 37}
42 38
43static int of_platform_bus_match(struct device *dev, struct device_driver *drv) 39/**
40 * of_match_device - Tell if an of_device structure has a matching
41 * of_match structure
42 * @ids: array of of device match structures to search in
43 * @dev: the of device structure to match against
44 *
45 * Used by a driver to check whether an of_device present in the
46 * system is in its list of supported devices.
47 */
48const struct of_device_id *of_match_device(const struct of_device_id *matches,
49 const struct of_device *dev)
44{ 50{
45 struct of_device * of_dev = to_of_device(dev); 51 if (!dev->node)
46 struct of_platform_driver * of_drv = to_of_platform_driver(drv); 52 return NULL;
47 const struct of_device_id * matches = of_drv->match_table; 53 return of_match_node(matches, dev->node);
48
49 if (!matches)
50 return 0;
51
52 return of_match_device(matches, of_dev) != NULL;
53} 54}
54 55
55struct of_device *of_dev_get(struct of_device *dev) 56struct of_device *of_dev_get(struct of_device *dev)
@@ -71,96 +72,8 @@ void of_dev_put(struct of_device *dev)
71 put_device(&dev->dev); 72 put_device(&dev->dev);
72} 73}
73 74
74 75static ssize_t dev_show_devspec(struct device *dev,
75static int of_device_probe(struct device *dev) 76 struct device_attribute *attr, char *buf)
76{
77 int error = -ENODEV;
78 struct of_platform_driver *drv;
79 struct of_device *of_dev;
80 const struct of_device_id *match;
81
82 drv = to_of_platform_driver(dev->driver);
83 of_dev = to_of_device(dev);
84
85 if (!drv->probe)
86 return error;
87
88 of_dev_get(of_dev);
89
90 match = of_match_device(drv->match_table, of_dev);
91 if (match)
92 error = drv->probe(of_dev, match);
93 if (error)
94 of_dev_put(of_dev);
95
96 return error;
97}
98
99static int of_device_remove(struct device *dev)
100{
101 struct of_device * of_dev = to_of_device(dev);
102 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
103
104 if (dev->driver && drv->remove)
105 drv->remove(of_dev);
106 return 0;
107}
108
109static int of_device_suspend(struct device *dev, pm_message_t state)
110{
111 struct of_device * of_dev = to_of_device(dev);
112 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
113 int error = 0;
114
115 if (dev->driver && drv->suspend)
116 error = drv->suspend(of_dev, state);
117 return error;
118}
119
120static int of_device_resume(struct device * dev)
121{
122 struct of_device * of_dev = to_of_device(dev);
123 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
124 int error = 0;
125
126 if (dev->driver && drv->resume)
127 error = drv->resume(of_dev);
128 return error;
129}
130
131struct bus_type of_platform_bus_type = {
132 .name = "of_platform",
133 .match = of_platform_bus_match,
134 .probe = of_device_probe,
135 .remove = of_device_remove,
136 .suspend = of_device_suspend,
137 .resume = of_device_resume,
138};
139
140static int __init of_bus_driver_init(void)
141{
142 return bus_register(&of_platform_bus_type);
143}
144
145postcore_initcall(of_bus_driver_init);
146
147int of_register_driver(struct of_platform_driver *drv)
148{
149 /* initialize common driver fields */
150 drv->driver.name = drv->name;
151 drv->driver.bus = &of_platform_bus_type;
152
153 /* register with core */
154 return driver_register(&drv->driver);
155}
156
157void of_unregister_driver(struct of_platform_driver *drv)
158{
159 driver_unregister(&drv->driver);
160}
161
162
163static ssize_t dev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
164{ 77{
165 struct of_device *ofdev; 78 struct of_device *ofdev;
166 79
@@ -208,41 +121,11 @@ void of_device_unregister(struct of_device *ofdev)
208 device_unregister(&ofdev->dev); 121 device_unregister(&ofdev->dev);
209} 122}
210 123
211struct of_device* of_platform_device_create(struct device_node *np,
212 const char *bus_id,
213 struct device *parent)
214{
215 struct of_device *dev;
216
217 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
218 if (!dev)
219 return NULL;
220 memset(dev, 0, sizeof(*dev));
221
222 dev->node = of_node_get(np);
223 dev->dma_mask = 0xffffffffUL;
224 dev->dev.dma_mask = &dev->dma_mask;
225 dev->dev.parent = parent;
226 dev->dev.bus = &of_platform_bus_type;
227 dev->dev.release = of_release_dev;
228
229 strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
230
231 if (of_device_register(dev) != 0) {
232 kfree(dev);
233 return NULL;
234 }
235
236 return dev;
237}
238 124
125EXPORT_SYMBOL(of_match_node);
239EXPORT_SYMBOL(of_match_device); 126EXPORT_SYMBOL(of_match_device);
240EXPORT_SYMBOL(of_platform_bus_type);
241EXPORT_SYMBOL(of_register_driver);
242EXPORT_SYMBOL(of_unregister_driver);
243EXPORT_SYMBOL(of_device_register); 127EXPORT_SYMBOL(of_device_register);
244EXPORT_SYMBOL(of_device_unregister); 128EXPORT_SYMBOL(of_device_unregister);
245EXPORT_SYMBOL(of_dev_get); 129EXPORT_SYMBOL(of_dev_get);
246EXPORT_SYMBOL(of_dev_put); 130EXPORT_SYMBOL(of_dev_put);
247EXPORT_SYMBOL(of_platform_device_create);
248EXPORT_SYMBOL(of_release_dev); 131EXPORT_SYMBOL(of_release_dev);
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
new file mode 100644
index 000000000000..b3189d0161b8
--- /dev/null
+++ b/arch/powerpc/kernel/of_platform.c
@@ -0,0 +1,489 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 * and Arnd Bergmann, IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#undef DEBUG
14
15#include <linux/string.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/module.h>
19#include <linux/mod_devicetable.h>
20#include <linux/slab.h>
21#include <linux/pci.h>
22
23#include <asm/errno.h>
24#include <asm/dcr.h>
25#include <asm/of_device.h>
26#include <asm/of_platform.h>
27#include <asm/topology.h>
28#include <asm/pci-bridge.h>
29#include <asm/ppc-pci.h>
30#include <asm/atomic.h>
31
32
33/*
34 * The list of OF IDs below is used for matching bus types in the
35 * system whose devices are to be exposed as of_platform_devices.
36 *
37 * This is the default list valid for most platforms. This file provides
38 * functions who can take an explicit list if necessary though
39 *
40 * The search is always performed recursively looking for children of
41 * the provided device_node and recursively if such a children matches
42 * a bus type in the list
43 */
44
45static struct of_device_id of_default_bus_ids[] = {
46 { .type = "soc", },
47 { .compatible = "soc", },
48 { .type = "spider", },
49 { .type = "axon", },
50 { .type = "plb5", },
51 { .type = "plb4", },
52 { .type = "opb", },
53 {},
54};
55
56static atomic_t bus_no_reg_magic;
57
58/*
59 *
60 * OF platform device type definition & base infrastructure
61 *
62 */
63
64static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
65{
66 struct of_device * of_dev = to_of_device(dev);
67 struct of_platform_driver * of_drv = to_of_platform_driver(drv);
68 const struct of_device_id * matches = of_drv->match_table;
69
70 if (!matches)
71 return 0;
72
73 return of_match_device(matches, of_dev) != NULL;
74}
75
76static int of_platform_device_probe(struct device *dev)
77{
78 int error = -ENODEV;
79 struct of_platform_driver *drv;
80 struct of_device *of_dev;
81 const struct of_device_id *match;
82
83 drv = to_of_platform_driver(dev->driver);
84 of_dev = to_of_device(dev);
85
86 if (!drv->probe)
87 return error;
88
89 of_dev_get(of_dev);
90
91 match = of_match_device(drv->match_table, of_dev);
92 if (match)
93 error = drv->probe(of_dev, match);
94 if (error)
95 of_dev_put(of_dev);
96
97 return error;
98}
99
100static int of_platform_device_remove(struct device *dev)
101{
102 struct of_device * of_dev = to_of_device(dev);
103 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
104
105 if (dev->driver && drv->remove)
106 drv->remove(of_dev);
107 return 0;
108}
109
110static int of_platform_device_suspend(struct device *dev, pm_message_t state)
111{
112 struct of_device * of_dev = to_of_device(dev);
113 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
114 int error = 0;
115
116 if (dev->driver && drv->suspend)
117 error = drv->suspend(of_dev, state);
118 return error;
119}
120
121static int of_platform_device_resume(struct device * dev)
122{
123 struct of_device * of_dev = to_of_device(dev);
124 struct of_platform_driver * drv = to_of_platform_driver(dev->driver);
125 int error = 0;
126
127 if (dev->driver && drv->resume)
128 error = drv->resume(of_dev);
129 return error;
130}
131
132struct bus_type of_platform_bus_type = {
133 .name = "of_platform",
134 .match = of_platform_bus_match,
135 .probe = of_platform_device_probe,
136 .remove = of_platform_device_remove,
137 .suspend = of_platform_device_suspend,
138 .resume = of_platform_device_resume,
139};
140EXPORT_SYMBOL(of_platform_bus_type);
141
142static int __init of_bus_driver_init(void)
143{
144 return bus_register(&of_platform_bus_type);
145}
146
147postcore_initcall(of_bus_driver_init);
148
149int of_register_platform_driver(struct of_platform_driver *drv)
150{
151 /* initialize common driver fields */
152 drv->driver.name = drv->name;
153 drv->driver.bus = &of_platform_bus_type;
154
155 /* register with core */
156 return driver_register(&drv->driver);
157}
158EXPORT_SYMBOL(of_register_platform_driver);
159
160void of_unregister_platform_driver(struct of_platform_driver *drv)
161{
162 driver_unregister(&drv->driver);
163}
164EXPORT_SYMBOL(of_unregister_platform_driver);
165
166static void of_platform_make_bus_id(struct of_device *dev)
167{
168 struct device_node *node = dev->node;
169 char *name = dev->dev.bus_id;
170 const u32 *reg;
171 u64 addr;
172 long magic;
173
174 /*
175 * If it's a DCR based device, use 'd' for native DCRs
176 * and 'D' for MMIO DCRs.
177 */
178#ifdef CONFIG_PPC_DCR
179 reg = get_property(node, "dcr-reg", NULL);
180 if (reg) {
181#ifdef CONFIG_PPC_DCR_NATIVE
182 snprintf(name, BUS_ID_SIZE, "d%x.%s",
183 *reg, node->name);
184#else /* CONFIG_PPC_DCR_NATIVE */
185 addr = of_translate_dcr_address(node, *reg, NULL);
186 if (addr != OF_BAD_ADDR) {
187 snprintf(name, BUS_ID_SIZE,
188 "D%llx.%s", (unsigned long long)addr,
189 node->name);
190 return;
191 }
192#endif /* !CONFIG_PPC_DCR_NATIVE */
193 }
194#endif /* CONFIG_PPC_DCR */
195
196 /*
197 * For MMIO, get the physical address
198 */
199 reg = get_property(node, "reg", NULL);
200 if (reg) {
201 addr = of_translate_address(node, reg);
202 if (addr != OF_BAD_ADDR) {
203 snprintf(name, BUS_ID_SIZE,
204 "%llx.%s", (unsigned long long)addr,
205 node->name);
206 return;
207 }
208 }
209
210 /*
211 * No BusID, use the node name and add a globally incremented
212 * counter (and pray...)
213 */
214 magic = atomic_add_return(1, &bus_no_reg_magic);
215 snprintf(name, BUS_ID_SIZE, "%s.%d", node->name, magic - 1);
216}
217
218struct of_device* of_platform_device_create(struct device_node *np,
219 const char *bus_id,
220 struct device *parent)
221{
222 struct of_device *dev;
223
224 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
225 if (!dev)
226 return NULL;
227 memset(dev, 0, sizeof(*dev));
228
229 dev->node = of_node_get(np);
230 dev->dma_mask = 0xffffffffUL;
231 dev->dev.dma_mask = &dev->dma_mask;
232 dev->dev.parent = parent;
233 dev->dev.bus = &of_platform_bus_type;
234 dev->dev.release = of_release_dev;
235 dev->dev.archdata.of_node = np;
236 dev->dev.archdata.numa_node = of_node_to_nid(np);
237
238 /* We do not fill the DMA ops for platform devices by default.
239 * This is currently the responsibility of the platform code
240 * to do such, possibly using a device notifier
241 */
242
243 if (bus_id)
244 strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
245 else
246 of_platform_make_bus_id(dev);
247
248 if (of_device_register(dev) != 0) {
249 kfree(dev);
250 return NULL;
251 }
252
253 return dev;
254}
255EXPORT_SYMBOL(of_platform_device_create);
256
257
258
259/**
260 * of_platform_bus_create - Create an OF device for a bus node and all its
261 * children. Optionally recursively instanciate matching busses.
262 * @bus: device node of the bus to instanciate
263 * @matches: match table, NULL to use the default, OF_NO_DEEP_PROBE to
264 * disallow recursive creation of child busses
265 */
266static int of_platform_bus_create(struct device_node *bus,
267 struct of_device_id *matches,
268 struct device *parent)
269{
270 struct device_node *child;
271 struct of_device *dev;
272 int rc = 0;
273
274 for (child = NULL; (child = of_get_next_child(bus, child)); ) {
275 pr_debug(" create child: %s\n", child->full_name);
276 dev = of_platform_device_create(child, NULL, parent);
277 if (dev == NULL)
278 rc = -ENOMEM;
279 else if (!of_match_node(matches, child))
280 continue;
281 if (rc == 0) {
282 pr_debug(" and sub busses\n");
283 rc = of_platform_bus_create(child, matches, &dev->dev);
284 } if (rc) {
285 of_node_put(child);
286 break;
287 }
288 }
289 return rc;
290}
291
292/**
293 * of_platform_bus_probe - Probe the device-tree for platform busses
294 * @root: parent of the first level to probe or NULL for the root of the tree
295 * @matches: match table, NULL to use the default
296 * @parent: parent to hook devices from, NULL for toplevel
297 *
298 * Note that children of the provided root are not instanciated as devices
299 * unless the specified root itself matches the bus list and is not NULL.
300 */
301
302int of_platform_bus_probe(struct device_node *root,
303 struct of_device_id *matches,
304 struct device *parent)
305{
306 struct device_node *child;
307 struct of_device *dev;
308 int rc = 0;
309
310 if (matches == NULL)
311 matches = of_default_bus_ids;
312 if (matches == OF_NO_DEEP_PROBE)
313 return -EINVAL;
314 if (root == NULL)
315 root = of_find_node_by_path("/");
316 else
317 of_node_get(root);
318
319 pr_debug("of_platform_bus_probe()\n");
320 pr_debug(" starting at: %s\n", root->full_name);
321
322 /* Do a self check of bus type, if there's a match, create
323 * children
324 */
325 if (of_match_node(matches, root)) {
326 pr_debug(" root match, create all sub devices\n");
327 dev = of_platform_device_create(root, NULL, parent);
328 if (dev == NULL) {
329 rc = -ENOMEM;
330 goto bail;
331 }
332 pr_debug(" create all sub busses\n");
333 rc = of_platform_bus_create(root, matches, &dev->dev);
334 goto bail;
335 }
336 for (child = NULL; (child = of_get_next_child(root, child)); ) {
337 if (!of_match_node(matches, child))
338 continue;
339
340 pr_debug(" match: %s\n", child->full_name);
341 dev = of_platform_device_create(child, NULL, parent);
342 if (dev == NULL)
343 rc = -ENOMEM;
344 else
345 rc = of_platform_bus_create(child, matches, &dev->dev);
346 if (rc) {
347 of_node_put(child);
348 break;
349 }
350 }
351 bail:
352 of_node_put(root);
353 return rc;
354}
355EXPORT_SYMBOL(of_platform_bus_probe);
356
357static int of_dev_node_match(struct device *dev, void *data)
358{
359 return to_of_device(dev)->node == data;
360}
361
362struct of_device *of_find_device_by_node(struct device_node *np)
363{
364 struct device *dev;
365
366 dev = bus_find_device(&of_platform_bus_type,
367 NULL, np, of_dev_node_match);
368 if (dev)
369 return to_of_device(dev);
370 return NULL;
371}
372EXPORT_SYMBOL(of_find_device_by_node);
373
374static int of_dev_phandle_match(struct device *dev, void *data)
375{
376 phandle *ph = data;
377 return to_of_device(dev)->node->linux_phandle == *ph;
378}
379
380struct of_device *of_find_device_by_phandle(phandle ph)
381{
382 struct device *dev;
383
384 dev = bus_find_device(&of_platform_bus_type,
385 NULL, &ph, of_dev_phandle_match);
386 if (dev)
387 return to_of_device(dev);
388 return NULL;
389}
390EXPORT_SYMBOL(of_find_device_by_phandle);
391
392
393#ifdef CONFIG_PPC_OF_PLATFORM_PCI
394
395/* The probing of PCI controllers from of_platform is currently
396 * 64 bits only, mostly due to gratuitous differences between
397 * the 32 and 64 bits PCI code on PowerPC and the 32 bits one
398 * lacking some bits needed here.
399 */
400
401static int __devinit of_pci_phb_probe(struct of_device *dev,
402 const struct of_device_id *match)
403{
404 struct pci_controller *phb;
405
406 /* Check if we can do that ... */
407 if (ppc_md.pci_setup_phb == NULL)
408 return -ENODEV;
409
410 printk(KERN_INFO "Setting up PCI bus %s\n", dev->node->full_name);
411
412 /* Alloc and setup PHB data structure */
413 phb = pcibios_alloc_controller(dev->node);
414 if (!phb)
415 return -ENODEV;
416
417 /* Setup parent in sysfs */
418 phb->parent = &dev->dev;
419
420 /* Setup the PHB using arch provided callback */
421 if (ppc_md.pci_setup_phb(phb)) {
422 pcibios_free_controller(phb);
423 return -ENODEV;
424 }
425
426 /* Process "ranges" property */
427 pci_process_bridge_OF_ranges(phb, dev->node, 0);
428
429 /* Setup IO space.
430 * This will not work properly for ISA IOs, something needs to be done
431 * about it if we ever generalize that way of probing PCI brigdes
432 */
433 pci_setup_phb_io_dynamic(phb, 0);
434
435 /* Init pci_dn data structures */
436 pci_devs_phb_init_dynamic(phb);
437
438 /* Register devices with EEH */
439#ifdef CONFIG_EEH
440 if (dev->node->child)
441 eeh_add_device_tree_early(dev->node);
442#endif /* CONFIG_EEH */
443
444 /* Scan the bus */
445 scan_phb(phb);
446
447 /* Claim resources. This might need some rework as well depending
448 * wether we are doing probe-only or not, like assigning unassigned
449 * resources etc...
450 */
451 pcibios_claim_one_bus(phb->bus);
452
453 /* Finish EEH setup */
454#ifdef CONFIG_EEH
455 eeh_add_device_tree_late(phb->bus);
456#endif
457
458 /* Add probed PCI devices to the device model */
459 pci_bus_add_devices(phb->bus);
460
461 return 0;
462}
463
464static struct of_device_id of_pci_phb_ids[] = {
465 { .type = "pci", },
466 { .type = "pcix", },
467 { .type = "pcie", },
468 { .type = "pciex", },
469 { .type = "ht", },
470 {}
471};
472
473static struct of_platform_driver of_pci_phb_driver = {
474 .name = "of-pci",
475 .match_table = of_pci_phb_ids,
476 .probe = of_pci_phb_probe,
477 .driver = {
478 .multithread_probe = 1,
479 },
480};
481
482static __init int of_pci_phb_init(void)
483{
484 return of_register_platform_driver(&of_pci_phb_driver);
485}
486
487device_initcall(of_pci_phb_init);
488
489#endif /* CONFIG_PPC_OF_PLATFORM_PCI */
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 0d9ff72e2852..2f54cd81dea5 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -12,6 +12,7 @@
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/bootmem.h> 13#include <linux/bootmem.h>
14#include <linux/irq.h> 14#include <linux/irq.h>
15#include <linux/list.h>
15 16
16#include <asm/processor.h> 17#include <asm/processor.h>
17#include <asm/io.h> 18#include <asm/io.h>
@@ -99,7 +100,7 @@ pcibios_fixup_resources(struct pci_dev *dev)
99 continue; 100 continue;
100 if (res->end == 0xffffffff) { 101 if (res->end == 0xffffffff) {
101 DBG("PCI:%s Resource %d [%016llx-%016llx] is unassigned\n", 102 DBG("PCI:%s Resource %d [%016llx-%016llx] is unassigned\n",
102 pci_name(dev), i, res->start, res->end); 103 pci_name(dev), i, (u64)res->start, (u64)res->end);
103 res->end -= res->start; 104 res->end -= res->start;
104 res->start = 0; 105 res->start = 0;
105 res->flags |= IORESOURCE_UNSET; 106 res->flags |= IORESOURCE_UNSET;
@@ -115,11 +116,9 @@ pcibios_fixup_resources(struct pci_dev *dev)
115 if (offset != 0) { 116 if (offset != 0) {
116 res->start += offset; 117 res->start += offset;
117 res->end += offset; 118 res->end += offset;
118#ifdef DEBUG 119 DBG("Fixup res %d (%lx) of dev %s: %llx -> %llx\n",
119 printk("Fixup res %d (%lx) of dev %s: %llx -> %llx\n", 120 i, res->flags, pci_name(dev),
120 i, res->flags, pci_name(dev), 121 (u64)res->start - offset, (u64)res->start);
121 res->start - offset, res->start);
122#endif
123 } 122 }
124 } 123 }
125 124
@@ -255,7 +254,7 @@ pcibios_allocate_bus_resources(struct list_head *bus_list)
255 } 254 }
256 255
257 DBG("PCI: bridge rsrc %llx..%llx (%lx), parent %p\n", 256 DBG("PCI: bridge rsrc %llx..%llx (%lx), parent %p\n",
258 res->start, res->end, res->flags, pr); 257 (u64)res->start, (u64)res->end, res->flags, pr);
259 if (pr) { 258 if (pr) {
260 if (request_resource(pr, res) == 0) 259 if (request_resource(pr, res) == 0)
261 continue; 260 continue;
@@ -306,7 +305,7 @@ reparent_resources(struct resource *parent, struct resource *res)
306 for (p = res->child; p != NULL; p = p->sibling) { 305 for (p = res->child; p != NULL; p = p->sibling) {
307 p->parent = res; 306 p->parent = res;
308 DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n", 307 DBG(KERN_INFO "PCI: reparented %s [%llx..%llx] under %s\n",
309 p->name, p->start, p->end, res->name); 308 p->name, (u64)p->start, (u64)p->end, res->name);
310 } 309 }
311 return 0; 310 return 0;
312} 311}
@@ -362,7 +361,7 @@ pci_relocate_bridge_resource(struct pci_bus *bus, int i)
362 } 361 }
363 if (request_resource(pr, res)) { 362 if (request_resource(pr, res)) {
364 DBG(KERN_ERR "PCI: huh? couldn't move to %llx..%llx\n", 363 DBG(KERN_ERR "PCI: huh? couldn't move to %llx..%llx\n",
365 res->start, res->end); 364 (u64)res->start, (u64)res->end);
366 return -1; /* "can't happen" */ 365 return -1; /* "can't happen" */
367 } 366 }
368 update_bridge_base(bus, i); 367 update_bridge_base(bus, i);
@@ -480,14 +479,14 @@ static inline void alloc_resource(struct pci_dev *dev, int idx)
480 struct resource *pr, *r = &dev->resource[idx]; 479 struct resource *pr, *r = &dev->resource[idx];
481 480
482 DBG("PCI:%s: Resource %d: %016llx-%016llx (f=%lx)\n", 481 DBG("PCI:%s: Resource %d: %016llx-%016llx (f=%lx)\n",
483 pci_name(dev), idx, r->start, r->end, r->flags); 482 pci_name(dev), idx, (u64)r->start, (u64)r->end, r->flags);
484 pr = pci_find_parent_resource(dev, r); 483 pr = pci_find_parent_resource(dev, r);
485 if (!pr || request_resource(pr, r) < 0) { 484 if (!pr || request_resource(pr, r) < 0) {
486 printk(KERN_ERR "PCI: Cannot allocate resource region %d" 485 printk(KERN_ERR "PCI: Cannot allocate resource region %d"
487 " of device %s\n", idx, pci_name(dev)); 486 " of device %s\n", idx, pci_name(dev));
488 if (pr) 487 if (pr)
489 DBG("PCI: parent is %p: %016llx-%016llx (f=%lx)\n", 488 DBG("PCI: parent is %p: %016llx-%016llx (f=%lx)\n",
490 pr, pr->start, pr->end, pr->flags); 489 pr, (u64)pr->start, (u64)pr->end, pr->flags);
491 /* We'll assign a new address later */ 490 /* We'll assign a new address later */
492 r->flags |= IORESOURCE_UNSET; 491 r->flags |= IORESOURCE_UNSET;
493 r->end -= r->start; 492 r->end -= r->start;
@@ -960,7 +959,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
960 res->flags = IORESOURCE_IO; 959 res->flags = IORESOURCE_IO;
961 res->start = ranges[2]; 960 res->start = ranges[2];
962 DBG("PCI: IO 0x%llx -> 0x%llx\n", 961 DBG("PCI: IO 0x%llx -> 0x%llx\n",
963 res->start, res->start + size - 1); 962 (u64)res->start, (u64)res->start + size - 1);
964 break; 963 break;
965 case 2: /* memory space */ 964 case 2: /* memory space */
966 memno = 0; 965 memno = 0;
@@ -982,7 +981,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
982 res->flags |= IORESOURCE_PREFETCH; 981 res->flags |= IORESOURCE_PREFETCH;
983 res->start = ranges[na+2]; 982 res->start = ranges[na+2];
984 DBG("PCI: MEM[%d] 0x%llx -> 0x%llx\n", memno, 983 DBG("PCI: MEM[%d] 0x%llx -> 0x%llx\n", memno,
985 res->start, res->start + size - 1); 984 (u64)res->start, (u64)res->start + size - 1);
986 } 985 }
987 break; 986 break;
988 } 987 }
@@ -1268,7 +1267,10 @@ pcibios_init(void)
1268 if (pci_assign_all_buses) 1267 if (pci_assign_all_buses)
1269 hose->first_busno = next_busno; 1268 hose->first_busno = next_busno;
1270 hose->last_busno = 0xff; 1269 hose->last_busno = 0xff;
1271 bus = pci_scan_bus(hose->first_busno, hose->ops, hose); 1270 bus = pci_scan_bus_parented(hose->parent, hose->first_busno,
1271 hose->ops, hose);
1272 if (bus)
1273 pci_bus_add_devices(bus);
1272 hose->last_busno = bus->subordinate; 1274 hose->last_busno = bus->subordinate;
1273 if (pci_assign_all_buses || next_busno <= hose->last_busno) 1275 if (pci_assign_all_buses || next_busno <= hose->last_busno)
1274 next_busno = hose->last_busno + pcibios_assign_bus_offset; 1276 next_busno = hose->last_busno + pcibios_assign_bus_offset;
@@ -1282,10 +1284,6 @@ pcibios_init(void)
1282 if (pci_assign_all_buses && have_of) 1284 if (pci_assign_all_buses && have_of)
1283 pcibios_make_OF_bus_map(); 1285 pcibios_make_OF_bus_map();
1284 1286
1285 /* Do machine dependent PCI interrupt routing */
1286 if (ppc_md.pci_swizzle && ppc_md.pci_map_irq)
1287 pci_fixup_irqs(ppc_md.pci_swizzle, ppc_md.pci_map_irq);
1288
1289 /* Call machine dependent fixup */ 1287 /* Call machine dependent fixup */
1290 if (ppc_md.pcibios_fixup) 1288 if (ppc_md.pcibios_fixup)
1291 ppc_md.pcibios_fixup(); 1289 ppc_md.pcibios_fixup();
@@ -1308,25 +1306,6 @@ pcibios_init(void)
1308 1306
1309subsys_initcall(pcibios_init); 1307subsys_initcall(pcibios_init);
1310 1308
1311unsigned char __init
1312common_swizzle(struct pci_dev *dev, unsigned char *pinp)
1313{
1314 struct pci_controller *hose = dev->sysdata;
1315
1316 if (dev->bus->number != hose->first_busno) {
1317 u8 pin = *pinp;
1318 do {
1319 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
1320 /* Move up the chain of bridges. */
1321 dev = dev->bus->self;
1322 } while (dev->bus->self);
1323 *pinp = pin;
1324
1325 /* The slot is the idsel of the last bridge. */
1326 }
1327 return PCI_SLOT(dev->devfn);
1328}
1329
1330unsigned long resource_fixup(struct pci_dev * dev, struct resource * res, 1309unsigned long resource_fixup(struct pci_dev * dev, struct resource * res,
1331 unsigned long start, unsigned long size) 1310 unsigned long start, unsigned long size)
1332{ 1311{
@@ -1338,6 +1317,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
1338 struct pci_controller *hose = (struct pci_controller *) bus->sysdata; 1317 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1339 unsigned long io_offset; 1318 unsigned long io_offset;
1340 struct resource *res; 1319 struct resource *res;
1320 struct pci_dev *dev;
1341 int i; 1321 int i;
1342 1322
1343 io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 1323 io_offset = (unsigned long)hose->io_base_virt - isa_io_base;
@@ -1390,8 +1370,16 @@ void __init pcibios_fixup_bus(struct pci_bus *bus)
1390 } 1370 }
1391 } 1371 }
1392 1372
1373 /* Platform specific bus fixups */
1393 if (ppc_md.pcibios_fixup_bus) 1374 if (ppc_md.pcibios_fixup_bus)
1394 ppc_md.pcibios_fixup_bus(bus); 1375 ppc_md.pcibios_fixup_bus(bus);
1376
1377 /* Read default IRQs and fixup if necessary */
1378 list_for_each_entry(dev, &bus->devices, bus_list) {
1379 pci_read_irq_line(dev);
1380 if (ppc_md.pci_irq_fixup)
1381 ppc_md.pci_irq_fixup(dev);
1382 }
1395} 1383}
1396 1384
1397char __init *pcibios_setup(char *str) 1385char __init *pcibios_setup(char *str)
@@ -1571,7 +1559,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
1571 *offset += hose->pci_mem_offset; 1559 *offset += hose->pci_mem_offset;
1572 res_bit = IORESOURCE_MEM; 1560 res_bit = IORESOURCE_MEM;
1573 } else { 1561 } else {
1574 io_offset = hose->io_base_virt - ___IO_BASE; 1562 io_offset = hose->io_base_virt - (void __iomem *)_IO_BASE;
1575 *offset += io_offset; 1563 *offset += io_offset;
1576 res_bit = IORESOURCE_IO; 1564 res_bit = IORESOURCE_IO;
1577 } 1565 }
@@ -1826,7 +1814,8 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar,
1826 return; 1814 return;
1827 1815
1828 if (rsrc->flags & IORESOURCE_IO) 1816 if (rsrc->flags & IORESOURCE_IO)
1829 offset = ___IO_BASE - hose->io_base_virt + hose->io_base_phys; 1817 offset = (void __iomem *)_IO_BASE - hose->io_base_virt
1818 + hose->io_base_phys;
1830 1819
1831 *start = rsrc->start + offset; 1820 *start = rsrc->start + offset;
1832 *end = rsrc->end + offset; 1821 *end = rsrc->end + offset;
@@ -1845,35 +1834,6 @@ pci_init_resource(struct resource *res, unsigned long start, unsigned long end,
1845 res->child = NULL; 1834 res->child = NULL;
1846} 1835}
1847 1836
1848void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
1849{
1850 unsigned long start = pci_resource_start(dev, bar);
1851 unsigned long len = pci_resource_len(dev, bar);
1852 unsigned long flags = pci_resource_flags(dev, bar);
1853
1854 if (!len)
1855 return NULL;
1856 if (max && len > max)
1857 len = max;
1858 if (flags & IORESOURCE_IO)
1859 return ioport_map(start, len);
1860 if (flags & IORESOURCE_MEM)
1861 /* Not checking IORESOURCE_CACHEABLE because PPC does
1862 * not currently distinguish between ioremap and
1863 * ioremap_nocache.
1864 */
1865 return ioremap(start, len);
1866 /* What? */
1867 return NULL;
1868}
1869
1870void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
1871{
1872 /* Nothing to do */
1873}
1874EXPORT_SYMBOL(pci_iomap);
1875EXPORT_SYMBOL(pci_iounmap);
1876
1877unsigned long pci_address_to_pio(phys_addr_t address) 1837unsigned long pci_address_to_pio(phys_addr_t address)
1878{ 1838{
1879 struct pci_controller* hose = hose_head; 1839 struct pci_controller* hose = hose_head;
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 9bae8a5bf671..6fa9a0a5c8db 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -42,11 +42,9 @@
42unsigned long pci_probe_only = 1; 42unsigned long pci_probe_only = 1;
43int pci_assign_all_buses = 0; 43int pci_assign_all_buses = 0;
44 44
45#ifdef CONFIG_PPC_MULTIPLATFORM
46static void fixup_resource(struct resource *res, struct pci_dev *dev); 45static void fixup_resource(struct resource *res, struct pci_dev *dev);
47static void do_bus_setup(struct pci_bus *bus); 46static void do_bus_setup(struct pci_bus *bus);
48static void phbs_remap_io(void); 47static void phbs_remap_io(void);
49#endif
50 48
51/* pci_io_base -- the base address from which io bars are offsets. 49/* pci_io_base -- the base address from which io bars are offsets.
52 * This is the lowest I/O base address (so bar values are always positive), 50 * This is the lowest I/O base address (so bar values are always positive),
@@ -63,7 +61,7 @@ void iSeries_pcibios_init(void);
63 61
64LIST_HEAD(hose_list); 62LIST_HEAD(hose_list);
65 63
66struct dma_mapping_ops pci_dma_ops; 64struct dma_mapping_ops *pci_dma_ops;
67EXPORT_SYMBOL(pci_dma_ops); 65EXPORT_SYMBOL(pci_dma_ops);
68 66
69int global_phb_number; /* Global phb counter */ 67int global_phb_number; /* Global phb counter */
@@ -212,6 +210,10 @@ struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
212 210
213void pcibios_free_controller(struct pci_controller *phb) 211void pcibios_free_controller(struct pci_controller *phb)
214{ 212{
213 spin_lock(&hose_spinlock);
214 list_del(&phb->list_node);
215 spin_unlock(&hose_spinlock);
216
215 if (phb->is_dynamic) 217 if (phb->is_dynamic)
216 kfree(phb); 218 kfree(phb);
217} 219}
@@ -251,7 +253,6 @@ static void __init pcibios_claim_of_setup(void)
251 pcibios_claim_one_bus(b); 253 pcibios_claim_one_bus(b);
252} 254}
253 255
254#ifdef CONFIG_PPC_MULTIPLATFORM
255static u32 get_int_prop(struct device_node *np, const char *name, u32 def) 256static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
256{ 257{
257 const u32 *prop; 258 const u32 *prop;
@@ -329,7 +330,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
329 struct pci_dev *dev; 330 struct pci_dev *dev;
330 const char *type; 331 const char *type;
331 332
332 dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL); 333 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
333 if (!dev) 334 if (!dev)
334 return NULL; 335 return NULL;
335 type = get_property(node, "device_type", NULL); 336 type = get_property(node, "device_type", NULL);
@@ -338,7 +339,6 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
338 339
339 DBG(" create device, devfn: %x, type: %s\n", devfn, type); 340 DBG(" create device, devfn: %x, type: %s\n", devfn, type);
340 341
341 memset(dev, 0, sizeof(struct pci_dev));
342 dev->bus = bus; 342 dev->bus = bus;
343 dev->sysdata = node; 343 dev->sysdata = node;
344 dev->dev.parent = bus->bridge; 344 dev->dev.parent = bus->bridge;
@@ -506,7 +506,6 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
506 pci_scan_child_bus(bus); 506 pci_scan_child_bus(bus);
507} 507}
508EXPORT_SYMBOL(of_scan_pci_bridge); 508EXPORT_SYMBOL(of_scan_pci_bridge);
509#endif /* CONFIG_PPC_MULTIPLATFORM */
510 509
511void __devinit scan_phb(struct pci_controller *hose) 510void __devinit scan_phb(struct pci_controller *hose)
512{ 511{
@@ -517,7 +516,7 @@ void __devinit scan_phb(struct pci_controller *hose)
517 516
518 DBG("Scanning PHB %s\n", node ? node->full_name : "<NO NAME>"); 517 DBG("Scanning PHB %s\n", node ? node->full_name : "<NO NAME>");
519 518
520 bus = pci_create_bus(NULL, hose->first_busno, hose->ops, node); 519 bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, node);
521 if (bus == NULL) { 520 if (bus == NULL) {
522 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n", 521 printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",
523 hose->global_number); 522 hose->global_number);
@@ -540,7 +539,7 @@ void __devinit scan_phb(struct pci_controller *hose)
540 } 539 }
541 540
542 mode = PCI_PROBE_NORMAL; 541 mode = PCI_PROBE_NORMAL;
543#ifdef CONFIG_PPC_MULTIPLATFORM 542
544 if (node && ppc_md.pci_probe_mode) 543 if (node && ppc_md.pci_probe_mode)
545 mode = ppc_md.pci_probe_mode(bus); 544 mode = ppc_md.pci_probe_mode(bus);
546 DBG(" probe mode: %d\n", mode); 545 DBG(" probe mode: %d\n", mode);
@@ -548,7 +547,7 @@ void __devinit scan_phb(struct pci_controller *hose)
548 bus->subordinate = hose->last_busno; 547 bus->subordinate = hose->last_busno;
549 of_scan_bus(node, bus); 548 of_scan_bus(node, bus);
550 } 549 }
551#endif /* CONFIG_PPC_MULTIPLATFORM */ 550
552 if (mode == PCI_PROBE_NORMAL) 551 if (mode == PCI_PROBE_NORMAL)
553 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); 552 hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);
554} 553}
@@ -592,11 +591,9 @@ static int __init pcibios_init(void)
592 if (ppc64_isabridge_dev != NULL) 591 if (ppc64_isabridge_dev != NULL)
593 printk(KERN_DEBUG "ISA bridge at %s\n", pci_name(ppc64_isabridge_dev)); 592 printk(KERN_DEBUG "ISA bridge at %s\n", pci_name(ppc64_isabridge_dev));
594 593
595#ifdef CONFIG_PPC_MULTIPLATFORM
596 if (!firmware_has_feature(FW_FEATURE_ISERIES)) 594 if (!firmware_has_feature(FW_FEATURE_ISERIES))
597 /* map in PCI I/O space */ 595 /* map in PCI I/O space */
598 phbs_remap_io(); 596 phbs_remap_io();
599#endif
600 597
601 printk(KERN_DEBUG "PCI: Probing PCI hardware done\n"); 598 printk(KERN_DEBUG "PCI: Probing PCI hardware done\n");
602 599
@@ -873,8 +870,6 @@ void pcibios_add_platform_entries(struct pci_dev *pdev)
873 device_create_file(&pdev->dev, &dev_attr_devspec); 870 device_create_file(&pdev->dev, &dev_attr_devspec);
874} 871}
875 872
876#ifdef CONFIG_PPC_MULTIPLATFORM
877
878#define ISA_SPACE_MASK 0x1 873#define ISA_SPACE_MASK 0x1
879#define ISA_SPACE_IO 0x1 874#define ISA_SPACE_IO 0x1
880 875
@@ -975,11 +970,7 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
975 res = NULL; 970 res = NULL;
976 pci_space = ranges[0]; 971 pci_space = ranges[0];
977 pci_addr = ((unsigned long)ranges[1] << 32) | ranges[2]; 972 pci_addr = ((unsigned long)ranges[1] << 32) | ranges[2];
978 973 cpu_phys_addr = of_translate_address(dev, &ranges[3]);
979 cpu_phys_addr = ranges[3];
980 if (na >= 2)
981 cpu_phys_addr = (cpu_phys_addr << 32) | ranges[4];
982
983 size = ((unsigned long)ranges[na+3] << 32) | ranges[na+4]; 974 size = ((unsigned long)ranges[na+3] << 32) | ranges[na+4];
984 ranges += np; 975 ranges += np;
985 if (size == 0) 976 if (size == 0)
@@ -1145,7 +1136,7 @@ int unmap_bus_range(struct pci_bus *bus)
1145 1136
1146 if (get_bus_io_range(bus, &start_phys, &start_virt, &size)) 1137 if (get_bus_io_range(bus, &start_phys, &start_virt, &size))
1147 return 1; 1138 return 1;
1148 if (iounmap_explicit((void __iomem *) start_virt, size)) 1139 if (__iounmap_explicit((void __iomem *) start_virt, size))
1149 return 1; 1140 return 1;
1150 1141
1151 return 0; 1142 return 0;
@@ -1213,23 +1204,52 @@ void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,
1213} 1204}
1214EXPORT_SYMBOL(pcibios_fixup_device_resources); 1205EXPORT_SYMBOL(pcibios_fixup_device_resources);
1215 1206
1207void __devinit pcibios_setup_new_device(struct pci_dev *dev)
1208{
1209 struct dev_archdata *sd = &dev->dev.archdata;
1210
1211 sd->of_node = pci_device_to_OF_node(dev);
1212
1213 DBG("PCI device %s OF node: %s\n", pci_name(dev),
1214 sd->of_node ? sd->of_node->full_name : "<none>");
1215
1216 sd->dma_ops = pci_dma_ops;
1217#ifdef CONFIG_NUMA
1218 sd->numa_node = pcibus_to_node(dev->bus);
1219#else
1220 sd->numa_node = -1;
1221#endif
1222 if (ppc_md.pci_dma_dev_setup)
1223 ppc_md.pci_dma_dev_setup(dev);
1224}
1225EXPORT_SYMBOL(pcibios_setup_new_device);
1216 1226
1217static void __devinit do_bus_setup(struct pci_bus *bus) 1227static void __devinit do_bus_setup(struct pci_bus *bus)
1218{ 1228{
1219 struct pci_dev *dev; 1229 struct pci_dev *dev;
1220 1230
1221 ppc_md.iommu_bus_setup(bus); 1231 if (ppc_md.pci_dma_bus_setup)
1232 ppc_md.pci_dma_bus_setup(bus);
1222 1233
1223 list_for_each_entry(dev, &bus->devices, bus_list) 1234 list_for_each_entry(dev, &bus->devices, bus_list)
1224 ppc_md.iommu_dev_setup(dev); 1235 pcibios_setup_new_device(dev);
1225 1236
1226 if (ppc_md.irq_bus_setup) 1237 /* Read default IRQs and fixup if necessary */
1227 ppc_md.irq_bus_setup(bus); 1238 list_for_each_entry(dev, &bus->devices, bus_list) {
1239 pci_read_irq_line(dev);
1240 if (ppc_md.pci_irq_fixup)
1241 ppc_md.pci_irq_fixup(dev);
1242 }
1228} 1243}
1229 1244
1230void __devinit pcibios_fixup_bus(struct pci_bus *bus) 1245void __devinit pcibios_fixup_bus(struct pci_bus *bus)
1231{ 1246{
1232 struct pci_dev *dev = bus->self; 1247 struct pci_dev *dev = bus->self;
1248 struct device_node *np;
1249
1250 np = pci_bus_to_OF_node(bus);
1251
1252 DBG("pcibios_fixup_bus(%s)\n", np ? np->full_name : "<???>");
1233 1253
1234 if (dev && pci_probe_only && 1254 if (dev && pci_probe_only &&
1235 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 1255 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
@@ -1343,8 +1363,6 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
1343 return NULL; 1363 return NULL;
1344} 1364}
1345 1365
1346#endif /* CONFIG_PPC_MULTIPLATFORM */
1347
1348unsigned long pci_address_to_pio(phys_addr_t address) 1366unsigned long pci_address_to_pio(phys_addr_t address)
1349{ 1367{
1350 struct pci_controller *hose, *tmp; 1368 struct pci_controller *hose, *tmp;
diff --git a/arch/powerpc/kernel/pci_direct_iommu.c b/arch/powerpc/kernel/pci_direct_iommu.c
deleted file mode 100644
index 72ce082ce738..000000000000
--- a/arch/powerpc/kernel/pci_direct_iommu.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * Support for DMA from PCI devices to main memory on
3 * machines without an iommu or with directly addressable
4 * RAM (typically a pmac with 2Gb of RAM or less)
5 *
6 * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
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/kernel.h>
15#include <linux/pci.h>
16#include <linux/delay.h>
17#include <linux/string.h>
18#include <linux/init.h>
19#include <linux/bootmem.h>
20#include <linux/mm.h>
21#include <linux/dma-mapping.h>
22
23#include <asm/sections.h>
24#include <asm/io.h>
25#include <asm/prom.h>
26#include <asm/pci-bridge.h>
27#include <asm/machdep.h>
28#include <asm/pmac_feature.h>
29#include <asm/abs_addr.h>
30#include <asm/ppc-pci.h>
31
32static void *pci_direct_alloc_coherent(struct device *hwdev, size_t size,
33 dma_addr_t *dma_handle, gfp_t flag)
34{
35 void *ret;
36
37 ret = (void *)__get_free_pages(flag, get_order(size));
38 if (ret != NULL) {
39 memset(ret, 0, size);
40 *dma_handle = virt_to_abs(ret);
41 }
42 return ret;
43}
44
45static void pci_direct_free_coherent(struct device *hwdev, size_t size,
46 void *vaddr, dma_addr_t dma_handle)
47{
48 free_pages((unsigned long)vaddr, get_order(size));
49}
50
51static dma_addr_t pci_direct_map_single(struct device *hwdev, void *ptr,
52 size_t size, enum dma_data_direction direction)
53{
54 return virt_to_abs(ptr);
55}
56
57static void pci_direct_unmap_single(struct device *hwdev, dma_addr_t dma_addr,
58 size_t size, enum dma_data_direction direction)
59{
60}
61
62static int pci_direct_map_sg(struct device *hwdev, struct scatterlist *sg,
63 int nents, enum dma_data_direction direction)
64{
65 int i;
66
67 for (i = 0; i < nents; i++, sg++) {
68 sg->dma_address = page_to_phys(sg->page) + sg->offset;
69 sg->dma_length = sg->length;
70 }
71
72 return nents;
73}
74
75static void pci_direct_unmap_sg(struct device *hwdev, struct scatterlist *sg,
76 int nents, enum dma_data_direction direction)
77{
78}
79
80static int pci_direct_dma_supported(struct device *dev, u64 mask)
81{
82 return mask < 0x100000000ull;
83}
84
85static struct dma_mapping_ops pci_direct_ops = {
86 .alloc_coherent = pci_direct_alloc_coherent,
87 .free_coherent = pci_direct_free_coherent,
88 .map_single = pci_direct_map_single,
89 .unmap_single = pci_direct_unmap_single,
90 .map_sg = pci_direct_map_sg,
91 .unmap_sg = pci_direct_unmap_sg,
92 .dma_supported = pci_direct_dma_supported,
93};
94
95void __init pci_direct_iommu_init(void)
96{
97 pci_dma_ops = pci_direct_ops;
98}
diff --git a/arch/powerpc/kernel/pci_iommu.c b/arch/powerpc/kernel/pci_iommu.c
deleted file mode 100644
index 0688b2534acb..000000000000
--- a/arch/powerpc/kernel/pci_iommu.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/*
2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
3 *
4 * Rewrite, cleanup, new allocation schemes:
5 * Copyright (C) 2004 Olof Johansson, IBM Corporation
6 *
7 * Dynamic DMA mapping support, platform-independent parts.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24
25#include <linux/init.h>
26#include <linux/types.h>
27#include <linux/slab.h>
28#include <linux/mm.h>
29#include <linux/spinlock.h>
30#include <linux/string.h>
31#include <linux/pci.h>
32#include <linux/dma-mapping.h>
33#include <asm/io.h>
34#include <asm/prom.h>
35#include <asm/iommu.h>
36#include <asm/pci-bridge.h>
37#include <asm/machdep.h>
38#include <asm/ppc-pci.h>
39
40/*
41 * We can use ->sysdata directly and avoid the extra work in
42 * pci_device_to_OF_node since ->sysdata will have been initialised
43 * in the iommu init code for all devices.
44 */
45#define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
46
47static inline struct iommu_table *device_to_table(struct device *hwdev)
48{
49 struct pci_dev *pdev;
50
51 if (!hwdev) {
52 pdev = ppc64_isabridge_dev;
53 if (!pdev)
54 return NULL;
55 } else
56 pdev = to_pci_dev(hwdev);
57
58 return PCI_DN(PCI_GET_DN(pdev))->iommu_table;
59}
60
61
62static inline unsigned long device_to_mask(struct device *hwdev)
63{
64 struct pci_dev *pdev;
65
66 if (!hwdev) {
67 pdev = ppc64_isabridge_dev;
68 if (!pdev) /* This is the best guess we can do */
69 return 0xfffffffful;
70 } else
71 pdev = to_pci_dev(hwdev);
72
73 if (pdev->dma_mask)
74 return pdev->dma_mask;
75
76 /* Assume devices without mask can take 32 bit addresses */
77 return 0xfffffffful;
78}
79
80
81/* Allocates a contiguous real buffer and creates mappings over it.
82 * Returns the virtual address of the buffer and sets dma_handle
83 * to the dma address (mapping) of the first page.
84 */
85static void *pci_iommu_alloc_coherent(struct device *hwdev, size_t size,
86 dma_addr_t *dma_handle, gfp_t flag)
87{
88 return iommu_alloc_coherent(device_to_table(hwdev), size, dma_handle,
89 device_to_mask(hwdev), flag,
90 pcibus_to_node(to_pci_dev(hwdev)->bus));
91}
92
93static void pci_iommu_free_coherent(struct device *hwdev, size_t size,
94 void *vaddr, dma_addr_t dma_handle)
95{
96 iommu_free_coherent(device_to_table(hwdev), size, vaddr, dma_handle);
97}
98
99/* Creates TCEs for a user provided buffer. The user buffer must be
100 * contiguous real kernel storage (not vmalloc). The address of the buffer
101 * passed here is the kernel (virtual) address of the buffer. The buffer
102 * need not be page aligned, the dma_addr_t returned will point to the same
103 * byte within the page as vaddr.
104 */
105static dma_addr_t pci_iommu_map_single(struct device *hwdev, void *vaddr,
106 size_t size, enum dma_data_direction direction)
107{
108 return iommu_map_single(device_to_table(hwdev), vaddr, size,
109 device_to_mask(hwdev), direction);
110}
111
112
113static void pci_iommu_unmap_single(struct device *hwdev, dma_addr_t dma_handle,
114 size_t size, enum dma_data_direction direction)
115{
116 iommu_unmap_single(device_to_table(hwdev), dma_handle, size, direction);
117}
118
119
120static int pci_iommu_map_sg(struct device *pdev, struct scatterlist *sglist,
121 int nelems, enum dma_data_direction direction)
122{
123 return iommu_map_sg(pdev, device_to_table(pdev), sglist,
124 nelems, device_to_mask(pdev), direction);
125}
126
127static void pci_iommu_unmap_sg(struct device *pdev, struct scatterlist *sglist,
128 int nelems, enum dma_data_direction direction)
129{
130 iommu_unmap_sg(device_to_table(pdev), sglist, nelems, direction);
131}
132
133/* We support DMA to/from any memory page via the iommu */
134static int pci_iommu_dma_supported(struct device *dev, u64 mask)
135{
136 struct iommu_table *tbl = device_to_table(dev);
137
138 if (!tbl || tbl->it_offset > mask) {
139 printk(KERN_INFO "Warning: IOMMU table offset too big for device mask\n");
140 if (tbl)
141 printk(KERN_INFO "mask: 0x%08lx, table offset: 0x%08lx\n",
142 mask, tbl->it_offset);
143 else
144 printk(KERN_INFO "mask: 0x%08lx, table unavailable\n",
145 mask);
146 return 0;
147 } else
148 return 1;
149}
150
151struct dma_mapping_ops pci_iommu_ops = {
152 .alloc_coherent = pci_iommu_alloc_coherent,
153 .free_coherent = pci_iommu_free_coherent,
154 .map_single = pci_iommu_map_single,
155 .unmap_single = pci_iommu_unmap_single,
156 .map_sg = pci_iommu_map_sg,
157 .unmap_sg = pci_iommu_unmap_sg,
158 .dma_supported = pci_iommu_dma_supported,
159};
160
161void pci_iommu_init(void)
162{
163 pci_dma_ops = pci_iommu_ops;
164}
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 807193a3c784..9179f0739ea2 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -49,6 +49,10 @@
49#include <asm/commproc.h> 49#include <asm/commproc.h>
50#endif 50#endif
51 51
52#ifdef CONFIG_PPC64
53EXPORT_SYMBOL(local_irq_restore);
54#endif
55
52#ifdef CONFIG_PPC32 56#ifdef CONFIG_PPC32
53extern void transfer_to_handler(void); 57extern void transfer_to_handler(void);
54extern void do_IRQ(struct pt_regs *regs); 58extern void do_IRQ(struct pt_regs *regs);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index bdb412d4b748..c18dbe77fdc2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -538,35 +538,31 @@ static struct ibm_pa_feature {
538 {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0}, 538 {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
539}; 539};
540 540
541static void __init check_cpu_pa_features(unsigned long node) 541static void __init scan_features(unsigned long node, unsigned char *ftrs,
542 unsigned long tablelen,
543 struct ibm_pa_feature *fp,
544 unsigned long ft_size)
542{ 545{
543 unsigned char *pa_ftrs; 546 unsigned long i, len, bit;
544 unsigned long len, tablelen, i, bit;
545
546 pa_ftrs = of_get_flat_dt_prop(node, "ibm,pa-features", &tablelen);
547 if (pa_ftrs == NULL)
548 return;
549 547
550 /* find descriptor with type == 0 */ 548 /* find descriptor with type == 0 */
551 for (;;) { 549 for (;;) {
552 if (tablelen < 3) 550 if (tablelen < 3)
553 return; 551 return;
554 len = 2 + pa_ftrs[0]; 552 len = 2 + ftrs[0];
555 if (tablelen < len) 553 if (tablelen < len)
556 return; /* descriptor 0 not found */ 554 return; /* descriptor 0 not found */
557 if (pa_ftrs[1] == 0) 555 if (ftrs[1] == 0)
558 break; 556 break;
559 tablelen -= len; 557 tablelen -= len;
560 pa_ftrs += len; 558 ftrs += len;
561 } 559 }
562 560
563 /* loop over bits we know about */ 561 /* loop over bits we know about */
564 for (i = 0; i < ARRAY_SIZE(ibm_pa_features); ++i) { 562 for (i = 0; i < ft_size; ++i, ++fp) {
565 struct ibm_pa_feature *fp = &ibm_pa_features[i]; 563 if (fp->pabyte >= ftrs[0])
566
567 if (fp->pabyte >= pa_ftrs[0])
568 continue; 564 continue;
569 bit = (pa_ftrs[2 + fp->pabyte] >> (7 - fp->pabit)) & 1; 565 bit = (ftrs[2 + fp->pabyte] >> (7 - fp->pabit)) & 1;
570 if (bit ^ fp->invert) { 566 if (bit ^ fp->invert) {
571 cur_cpu_spec->cpu_features |= fp->cpu_features; 567 cur_cpu_spec->cpu_features |= fp->cpu_features;
572 cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftrs; 568 cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftrs;
@@ -577,16 +573,59 @@ static void __init check_cpu_pa_features(unsigned long node)
577 } 573 }
578} 574}
579 575
576static void __init check_cpu_pa_features(unsigned long node)
577{
578 unsigned char *pa_ftrs;
579 unsigned long tablelen;
580
581 pa_ftrs = of_get_flat_dt_prop(node, "ibm,pa-features", &tablelen);
582 if (pa_ftrs == NULL)
583 return;
584
585 scan_features(node, pa_ftrs, tablelen,
586 ibm_pa_features, ARRAY_SIZE(ibm_pa_features));
587}
588
589static struct feature_property {
590 const char *name;
591 u32 min_value;
592 unsigned long cpu_feature;
593 unsigned long cpu_user_ftr;
594} feature_properties[] __initdata = {
595#ifdef CONFIG_ALTIVEC
596 {"altivec", 0, CPU_FTR_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC},
597 {"ibm,vmx", 1, CPU_FTR_ALTIVEC, PPC_FEATURE_HAS_ALTIVEC},
598#endif /* CONFIG_ALTIVEC */
599#ifdef CONFIG_PPC64
600 {"ibm,dfp", 1, 0, PPC_FEATURE_HAS_DFP},
601 {"ibm,purr", 1, CPU_FTR_PURR, 0},
602 {"ibm,spurr", 1, CPU_FTR_SPURR, 0},
603#endif /* CONFIG_PPC64 */
604};
605
606static void __init check_cpu_feature_properties(unsigned long node)
607{
608 unsigned long i;
609 struct feature_property *fp = feature_properties;
610 const u32 *prop;
611
612 for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) {
613 prop = of_get_flat_dt_prop(node, fp->name, NULL);
614 if (prop && *prop >= fp->min_value) {
615 cur_cpu_spec->cpu_features |= fp->cpu_feature;
616 cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftr;
617 }
618 }
619}
620
580static int __init early_init_dt_scan_cpus(unsigned long node, 621static int __init early_init_dt_scan_cpus(unsigned long node,
581 const char *uname, int depth, 622 const char *uname, int depth,
582 void *data) 623 void *data)
583{ 624{
584 static int logical_cpuid = 0; 625 static int logical_cpuid = 0;
585 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 626 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
586#ifdef CONFIG_ALTIVEC 627 const u32 *prop;
587 u32 *prop; 628 const u32 *intserv;
588#endif
589 u32 *intserv;
590 int i, nthreads; 629 int i, nthreads;
591 unsigned long len; 630 unsigned long len;
592 int found = 0; 631 int found = 0;
@@ -643,24 +682,27 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
643 intserv[i]); 682 intserv[i]);
644 boot_cpuid = logical_cpuid; 683 boot_cpuid = logical_cpuid;
645 set_hard_smp_processor_id(boot_cpuid, intserv[i]); 684 set_hard_smp_processor_id(boot_cpuid, intserv[i]);
646 }
647 685
648#ifdef CONFIG_ALTIVEC 686 /*
649 /* Check if we have a VMX and eventually update CPU features */ 687 * PAPR defines "logical" PVR values for cpus that
650 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,vmx", NULL); 688 * meet various levels of the architecture:
651 if (prop && (*prop) > 0) { 689 * 0x0f000001 Architecture version 2.04
652 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC; 690 * 0x0f000002 Architecture version 2.05
653 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 691 * If the cpu-version property in the cpu node contains
654 } 692 * such a value, we call identify_cpu again with the
655 693 * logical PVR value in order to use the cpu feature
656 /* Same goes for Apple's "altivec" property */ 694 * bits appropriate for the architecture level.
657 prop = (u32 *)of_get_flat_dt_prop(node, "altivec", NULL); 695 *
658 if (prop) { 696 * A POWER6 partition in "POWER6 architected" mode
659 cur_cpu_spec->cpu_features |= CPU_FTR_ALTIVEC; 697 * uses the 0x0f000002 PVR value; in POWER5+ mode
660 cur_cpu_spec->cpu_user_features |= PPC_FEATURE_HAS_ALTIVEC; 698 * it uses 0x0f000001.
699 */
700 prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
701 if (prop && (*prop & 0xff000000) == 0x0f000000)
702 identify_cpu(0, *prop);
661 } 703 }
662#endif /* CONFIG_ALTIVEC */
663 704
705 check_cpu_feature_properties(node);
664 check_cpu_pa_features(node); 706 check_cpu_pa_features(node);
665 707
666#ifdef CONFIG_PPC_PSERIES 708#ifdef CONFIG_PPC_PSERIES
@@ -1674,6 +1716,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
1674 } 1716 }
1675 return NULL; 1717 return NULL;
1676} 1718}
1719EXPORT_SYMBOL(of_get_cpu_node);
1677 1720
1678#ifdef DEBUG 1721#ifdef DEBUG
1679static struct debugfs_blob_wrapper flat_dt_blob; 1722static struct debugfs_blob_wrapper flat_dt_blob;
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index b91761639d96..46cf32670ddb 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -173,8 +173,8 @@ static unsigned long __initdata dt_string_start, dt_string_end;
173static unsigned long __initdata prom_initrd_start, prom_initrd_end; 173static unsigned long __initdata prom_initrd_start, prom_initrd_end;
174 174
175#ifdef CONFIG_PPC64 175#ifdef CONFIG_PPC64
176static int __initdata iommu_force_on; 176static int __initdata prom_iommu_force_on;
177static int __initdata ppc64_iommu_off; 177static int __initdata prom_iommu_off;
178static unsigned long __initdata prom_tce_alloc_start; 178static unsigned long __initdata prom_tce_alloc_start;
179static unsigned long __initdata prom_tce_alloc_end; 179static unsigned long __initdata prom_tce_alloc_end;
180#endif 180#endif
@@ -582,9 +582,9 @@ static void __init early_cmdline_parse(void)
582 while (*opt && *opt == ' ') 582 while (*opt && *opt == ' ')
583 opt++; 583 opt++;
584 if (!strncmp(opt, RELOC("off"), 3)) 584 if (!strncmp(opt, RELOC("off"), 3))
585 RELOC(ppc64_iommu_off) = 1; 585 RELOC(prom_iommu_off) = 1;
586 else if (!strncmp(opt, RELOC("force"), 5)) 586 else if (!strncmp(opt, RELOC("force"), 5))
587 RELOC(iommu_force_on) = 1; 587 RELOC(prom_iommu_force_on) = 1;
588 } 588 }
589#endif 589#endif
590} 590}
@@ -627,6 +627,7 @@ static void __init early_cmdline_parse(void)
627/* Option vector 3: processor options supported */ 627/* Option vector 3: processor options supported */
628#define OV3_FP 0x80 /* floating point */ 628#define OV3_FP 0x80 /* floating point */
629#define OV3_VMX 0x40 /* VMX/Altivec */ 629#define OV3_VMX 0x40 /* VMX/Altivec */
630#define OV3_DFP 0x20 /* decimal FP */
630 631
631/* Option vector 5: PAPR/OF options supported */ 632/* Option vector 5: PAPR/OF options supported */
632#define OV5_LPAR 0x80 /* logical partitioning supported */ 633#define OV5_LPAR 0x80 /* logical partitioning supported */
@@ -642,6 +643,7 @@ static void __init early_cmdline_parse(void)
642static unsigned char ibm_architecture_vec[] = { 643static unsigned char ibm_architecture_vec[] = {
643 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */ 644 W(0xfffe0000), W(0x003a0000), /* POWER5/POWER5+ */
644 W(0xffff0000), W(0x003e0000), /* POWER6 */ 645 W(0xffff0000), W(0x003e0000), /* POWER6 */
646 W(0xffffffff), W(0x0f000002), /* all 2.05-compliant */
645 W(0xfffffffe), W(0x0f000001), /* all 2.04-compliant and earlier */ 647 W(0xfffffffe), W(0x0f000001), /* all 2.04-compliant and earlier */
646 5 - 1, /* 5 option vectors */ 648 5 - 1, /* 5 option vectors */
647 649
@@ -668,7 +670,7 @@ static unsigned char ibm_architecture_vec[] = {
668 /* option vector 3: processor options supported */ 670 /* option vector 3: processor options supported */
669 3 - 2, /* length */ 671 3 - 2, /* length */
670 0, /* don't ignore, don't halt */ 672 0, /* don't ignore, don't halt */
671 OV3_FP | OV3_VMX, 673 OV3_FP | OV3_VMX | OV3_DFP,
672 674
673 /* option vector 4: IBM PAPR implementation */ 675 /* option vector 4: IBM PAPR implementation */
674 2 - 2, /* length */ 676 2 - 2, /* length */
@@ -1167,7 +1169,7 @@ static void __init prom_initialize_tce_table(void)
1167 u64 local_alloc_top, local_alloc_bottom; 1169 u64 local_alloc_top, local_alloc_bottom;
1168 u64 i; 1170 u64 i;
1169 1171
1170 if (RELOC(ppc64_iommu_off)) 1172 if (RELOC(prom_iommu_off))
1171 return; 1173 return;
1172 1174
1173 prom_debug("starting prom_initialize_tce_table\n"); 1175 prom_debug("starting prom_initialize_tce_table\n");
@@ -2283,11 +2285,11 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2283 * Fill in some infos for use by the kernel later on 2285 * Fill in some infos for use by the kernel later on
2284 */ 2286 */
2285#ifdef CONFIG_PPC64 2287#ifdef CONFIG_PPC64
2286 if (RELOC(ppc64_iommu_off)) 2288 if (RELOC(prom_iommu_off))
2287 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off", 2289 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-off",
2288 NULL, 0); 2290 NULL, 0);
2289 2291
2290 if (RELOC(iommu_force_on)) 2292 if (RELOC(prom_iommu_force_on))
2291 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-force-on", 2293 prom_setprop(_prom->chosen, "/chosen", "linux,iommu-force-on",
2292 NULL, 0); 2294 NULL, 0);
2293 2295
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 603dff3ad62a..0dfbe1cd28eb 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -25,6 +25,12 @@
25#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \ 25#define OF_CHECK_COUNTS(na, ns) ((na) > 0 && (na) <= OF_MAX_ADDR_CELLS && \
26 (ns) > 0) 26 (ns) > 0)
27 27
28static struct of_bus *of_match_bus(struct device_node *np);
29static int __of_address_to_resource(struct device_node *dev,
30 const u32 *addrp, u64 size, unsigned int flags,
31 struct resource *r);
32
33
28/* Debug utility */ 34/* Debug utility */
29#ifdef DEBUG 35#ifdef DEBUG
30static void of_dump_addr(const char *s, const u32 *addr, int na) 36static void of_dump_addr(const char *s, const u32 *addr, int na)
@@ -101,6 +107,7 @@ static unsigned int of_bus_default_get_flags(const u32 *addr)
101} 107}
102 108
103 109
110#ifdef CONFIG_PCI
104/* 111/*
105 * PCI bus specific translator 112 * PCI bus specific translator
106 */ 113 */
@@ -153,15 +160,156 @@ static unsigned int of_bus_pci_get_flags(const u32 *addr)
153 switch((w >> 24) & 0x03) { 160 switch((w >> 24) & 0x03) {
154 case 0x01: 161 case 0x01:
155 flags |= IORESOURCE_IO; 162 flags |= IORESOURCE_IO;
163 break;
156 case 0x02: /* 32 bits */ 164 case 0x02: /* 32 bits */
157 case 0x03: /* 64 bits */ 165 case 0x03: /* 64 bits */
158 flags |= IORESOURCE_MEM; 166 flags |= IORESOURCE_MEM;
167 break;
159 } 168 }
160 if (w & 0x40000000) 169 if (w & 0x40000000)
161 flags |= IORESOURCE_PREFETCH; 170 flags |= IORESOURCE_PREFETCH;
162 return flags; 171 return flags;
163} 172}
164 173
174const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
175 unsigned int *flags)
176{
177 const u32 *prop;
178 unsigned int psize;
179 struct device_node *parent;
180 struct of_bus *bus;
181 int onesize, i, na, ns;
182
183 /* Get parent & match bus type */
184 parent = of_get_parent(dev);
185 if (parent == NULL)
186 return NULL;
187 bus = of_match_bus(parent);
188 if (strcmp(bus->name, "pci")) {
189 of_node_put(parent);
190 return NULL;
191 }
192 bus->count_cells(dev, &na, &ns);
193 of_node_put(parent);
194 if (!OF_CHECK_COUNTS(na, ns))
195 return NULL;
196
197 /* Get "reg" or "assigned-addresses" property */
198 prop = get_property(dev, bus->addresses, &psize);
199 if (prop == NULL)
200 return NULL;
201 psize /= 4;
202
203 onesize = na + ns;
204 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
205 if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
206 if (size)
207 *size = of_read_number(prop + na, ns);
208 if (flags)
209 *flags = bus->get_flags(prop);
210 return prop;
211 }
212 return NULL;
213}
214EXPORT_SYMBOL(of_get_pci_address);
215
216int of_pci_address_to_resource(struct device_node *dev, int bar,
217 struct resource *r)
218{
219 const u32 *addrp;
220 u64 size;
221 unsigned int flags;
222
223 addrp = of_get_pci_address(dev, bar, &size, &flags);
224 if (addrp == NULL)
225 return -EINVAL;
226 return __of_address_to_resource(dev, addrp, size, flags, r);
227}
228EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
229
230static u8 of_irq_pci_swizzle(u8 slot, u8 pin)
231{
232 return (((pin - 1) + slot) % 4) + 1;
233}
234
235int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
236{
237 struct device_node *dn, *ppnode;
238 struct pci_dev *ppdev;
239 u32 lspec;
240 u32 laddr[3];
241 u8 pin;
242 int rc;
243
244 /* Check if we have a device node, if yes, fallback to standard OF
245 * parsing
246 */
247 dn = pci_device_to_OF_node(pdev);
248 if (dn)
249 return of_irq_map_one(dn, 0, out_irq);
250
251 /* Ok, we don't, time to have fun. Let's start by building up an
252 * interrupt spec. we assume #interrupt-cells is 1, which is standard
253 * for PCI. If you do different, then don't use that routine.
254 */
255 rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
256 if (rc != 0)
257 return rc;
258 /* No pin, exit */
259 if (pin == 0)
260 return -ENODEV;
261
262 /* Now we walk up the PCI tree */
263 lspec = pin;
264 for (;;) {
265 /* Get the pci_dev of our parent */
266 ppdev = pdev->bus->self;
267
268 /* Ouch, it's a host bridge... */
269 if (ppdev == NULL) {
270#ifdef CONFIG_PPC64
271 ppnode = pci_bus_to_OF_node(pdev->bus);
272#else
273 struct pci_controller *host;
274 host = pci_bus_to_host(pdev->bus);
275 ppnode = host ? host->arch_data : NULL;
276#endif
277 /* No node for host bridge ? give up */
278 if (ppnode == NULL)
279 return -EINVAL;
280 } else
281 /* We found a P2P bridge, check if it has a node */
282 ppnode = pci_device_to_OF_node(ppdev);
283
284 /* Ok, we have found a parent with a device-node, hand over to
285 * the OF parsing code.
286 * We build a unit address from the linux device to be used for
287 * resolution. Note that we use the linux bus number which may
288 * not match your firmware bus numbering.
289 * Fortunately, in most cases, interrupt-map-mask doesn't include
290 * the bus number as part of the matching.
291 * You should still be careful about that though if you intend
292 * to rely on this function (you ship a firmware that doesn't
293 * create device nodes for all PCI devices).
294 */
295 if (ppnode)
296 break;
297
298 /* We can only get here if we hit a P2P bridge with no node,
299 * let's do standard swizzling and try again
300 */
301 lspec = of_irq_pci_swizzle(PCI_SLOT(pdev->devfn), lspec);
302 pdev = ppdev;
303 }
304
305 laddr[0] = (pdev->bus->number << 16)
306 | (pdev->devfn << 8);
307 laddr[1] = laddr[2] = 0;
308 return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
309}
310EXPORT_SYMBOL_GPL(of_irq_map_pci);
311#endif /* CONFIG_PCI */
312
165/* 313/*
166 * ISA bus specific translator 314 * ISA bus specific translator
167 */ 315 */
@@ -223,6 +371,7 @@ static unsigned int of_bus_isa_get_flags(const u32 *addr)
223 */ 371 */
224 372
225static struct of_bus of_busses[] = { 373static struct of_bus of_busses[] = {
374#ifdef CONFIG_PCI
226 /* PCI */ 375 /* PCI */
227 { 376 {
228 .name = "pci", 377 .name = "pci",
@@ -233,6 +382,7 @@ static struct of_bus of_busses[] = {
233 .translate = of_bus_pci_translate, 382 .translate = of_bus_pci_translate,
234 .get_flags = of_bus_pci_get_flags, 383 .get_flags = of_bus_pci_get_flags,
235 }, 384 },
385#endif /* CONFIG_PCI */
236 /* ISA */ 386 /* ISA */
237 { 387 {
238 .name = "isa", 388 .name = "isa",
@@ -445,48 +595,6 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
445} 595}
446EXPORT_SYMBOL(of_get_address); 596EXPORT_SYMBOL(of_get_address);
447 597
448const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
449 unsigned int *flags)
450{
451 const u32 *prop;
452 unsigned int psize;
453 struct device_node *parent;
454 struct of_bus *bus;
455 int onesize, i, na, ns;
456
457 /* Get parent & match bus type */
458 parent = of_get_parent(dev);
459 if (parent == NULL)
460 return NULL;
461 bus = of_match_bus(parent);
462 if (strcmp(bus->name, "pci")) {
463 of_node_put(parent);
464 return NULL;
465 }
466 bus->count_cells(dev, &na, &ns);
467 of_node_put(parent);
468 if (!OF_CHECK_COUNTS(na, ns))
469 return NULL;
470
471 /* Get "reg" or "assigned-addresses" property */
472 prop = get_property(dev, bus->addresses, &psize);
473 if (prop == NULL)
474 return NULL;
475 psize /= 4;
476
477 onesize = na + ns;
478 for (i = 0; psize >= onesize; psize -= onesize, prop += onesize, i++)
479 if ((prop[0] & 0xff) == ((bar_no * 4) + PCI_BASE_ADDRESS_0)) {
480 if (size)
481 *size = of_read_number(prop + na, ns);
482 if (flags)
483 *flags = bus->get_flags(prop);
484 return prop;
485 }
486 return NULL;
487}
488EXPORT_SYMBOL(of_get_pci_address);
489
490static int __of_address_to_resource(struct device_node *dev, const u32 *addrp, 598static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
491 u64 size, unsigned int flags, 599 u64 size, unsigned int flags,
492 struct resource *r) 600 struct resource *r)
@@ -529,20 +637,6 @@ int of_address_to_resource(struct device_node *dev, int index,
529} 637}
530EXPORT_SYMBOL_GPL(of_address_to_resource); 638EXPORT_SYMBOL_GPL(of_address_to_resource);
531 639
532int of_pci_address_to_resource(struct device_node *dev, int bar,
533 struct resource *r)
534{
535 const u32 *addrp;
536 u64 size;
537 unsigned int flags;
538
539 addrp = of_get_pci_address(dev, bar, &size, &flags);
540 if (addrp == NULL)
541 return -EINVAL;
542 return __of_address_to_resource(dev, addrp, size, flags, r);
543}
544EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
545
546void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 640void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
547 unsigned long *busno, unsigned long *phys, unsigned long *size) 641 unsigned long *busno, unsigned long *phys, unsigned long *size)
548{ 642{
@@ -898,87 +992,3 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
898 return res; 992 return res;
899} 993}
900EXPORT_SYMBOL_GPL(of_irq_map_one); 994EXPORT_SYMBOL_GPL(of_irq_map_one);
901
902#ifdef CONFIG_PCI
903static u8 of_irq_pci_swizzle(u8 slot, u8 pin)
904{
905 return (((pin - 1) + slot) % 4) + 1;
906}
907
908int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq)
909{
910 struct device_node *dn, *ppnode;
911 struct pci_dev *ppdev;
912 u32 lspec;
913 u32 laddr[3];
914 u8 pin;
915 int rc;
916
917 /* Check if we have a device node, if yes, fallback to standard OF
918 * parsing
919 */
920 dn = pci_device_to_OF_node(pdev);
921 if (dn)
922 return of_irq_map_one(dn, 0, out_irq);
923
924 /* Ok, we don't, time to have fun. Let's start by building up an
925 * interrupt spec. we assume #interrupt-cells is 1, which is standard
926 * for PCI. If you do different, then don't use that routine.
927 */
928 rc = pci_read_config_byte(pdev, PCI_INTERRUPT_PIN, &pin);
929 if (rc != 0)
930 return rc;
931 /* No pin, exit */
932 if (pin == 0)
933 return -ENODEV;
934
935 /* Now we walk up the PCI tree */
936 lspec = pin;
937 for (;;) {
938 /* Get the pci_dev of our parent */
939 ppdev = pdev->bus->self;
940
941 /* Ouch, it's a host bridge... */
942 if (ppdev == NULL) {
943#ifdef CONFIG_PPC64
944 ppnode = pci_bus_to_OF_node(pdev->bus);
945#else
946 struct pci_controller *host;
947 host = pci_bus_to_host(pdev->bus);
948 ppnode = host ? host->arch_data : NULL;
949#endif
950 /* No node for host bridge ? give up */
951 if (ppnode == NULL)
952 return -EINVAL;
953 } else
954 /* We found a P2P bridge, check if it has a node */
955 ppnode = pci_device_to_OF_node(ppdev);
956
957 /* Ok, we have found a parent with a device-node, hand over to
958 * the OF parsing code.
959 * We build a unit address from the linux device to be used for
960 * resolution. Note that we use the linux bus number which may
961 * not match your firmware bus numbering.
962 * Fortunately, in most cases, interrupt-map-mask doesn't include
963 * the bus number as part of the matching.
964 * You should still be careful about that though if you intend
965 * to rely on this function (you ship a firmware that doesn't
966 * create device nodes for all PCI devices).
967 */
968 if (ppnode)
969 break;
970
971 /* We can only get here if we hit a P2P bridge with no node,
972 * let's do standard swizzling and try again
973 */
974 lspec = of_irq_pci_swizzle(PCI_SLOT(pdev->devfn), lspec);
975 pdev = ppdev;
976 }
977
978 laddr[0] = (pdev->bus->number << 16)
979 | (pdev->devfn << 8);
980 laddr[1] = laddr[2] = 0;
981 return of_irq_map_raw(ppnode, &lspec, 1, laddr, out_irq);
982}
983EXPORT_SYMBOL_GPL(of_irq_map_pci);
984#endif /* CONFIG_PCI */
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 6ef80d4e38d3..387ed0d9ad61 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -810,9 +810,9 @@ asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
810 return 0; 810 return 0;
811} 811}
812 812
813#ifdef CONFIG_HOTPLUG_CPU
813/* This version can't take the spinlock, because it never returns */ 814/* This version can't take the spinlock, because it never returns */
814 815static struct rtas_args rtas_stop_self_args = {
815struct rtas_args rtas_stop_self_args = {
816 /* The token is initialized for real in setup_system() */ 816 /* The token is initialized for real in setup_system() */
817 .token = RTAS_UNKNOWN_SERVICE, 817 .token = RTAS_UNKNOWN_SERVICE,
818 .nargs = 0, 818 .nargs = 0,
@@ -834,6 +834,7 @@ void rtas_stop_self(void)
834 834
835 panic("Alas, I survived.\n"); 835 panic("Alas, I survived.\n");
836} 836}
837#endif
837 838
838/* 839/*
839 * Call early during boot, before mem init or bootmem, to retrieve the RTAS 840 * Call early during boot, before mem init or bootmem, to retrieve the RTAS
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index 6f6fc977cb39..b9561d300516 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -681,14 +681,12 @@ static int initialize_flash_pde_data(const char *rtas_call_name,
681 int *status; 681 int *status;
682 int token; 682 int token;
683 683
684 dp->data = kmalloc(buf_size, GFP_KERNEL); 684 dp->data = kzalloc(buf_size, GFP_KERNEL);
685 if (dp->data == NULL) { 685 if (dp->data == NULL) {
686 remove_flash_pde(dp); 686 remove_flash_pde(dp);
687 return -ENOMEM; 687 return -ENOMEM;
688 } 688 }
689 689
690 memset(dp->data, 0, buf_size);
691
692 /* 690 /*
693 * This code assumes that the status int is the first member of the 691 * This code assumes that the status int is the first member of the
694 * struct 692 * struct
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index b4a0de79c060..ace9f4c86e67 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -38,6 +38,7 @@
38#include <asm/rtas.h> 38#include <asm/rtas.h>
39#include <asm/mpic.h> 39#include <asm/mpic.h>
40#include <asm/ppc-pci.h> 40#include <asm/ppc-pci.h>
41#include <asm/eeh.h>
41 42
42/* RTAS tokens */ 43/* RTAS tokens */
43static int read_pci_config; 44static int read_pci_config;
@@ -231,32 +232,13 @@ void __init init_pci_config_tokens (void)
231 232
232unsigned long __devinit get_phb_buid (struct device_node *phb) 233unsigned long __devinit get_phb_buid (struct device_node *phb)
233{ 234{
234 int addr_cells; 235 struct resource r;
235 const unsigned int *buid_vals;
236 unsigned int len;
237 unsigned long buid;
238
239 if (ibm_read_pci_config == -1) return 0;
240 236
241 /* PHB's will always be children of the root node, 237 if (ibm_read_pci_config == -1)
242 * or so it is promised by the current firmware. */
243 if (phb->parent == NULL)
244 return 0; 238 return 0;
245 if (phb->parent->parent) 239 if (of_address_to_resource(phb, 0, &r))
246 return 0;
247
248 buid_vals = get_property(phb, "reg", &len);
249 if (buid_vals == NULL)
250 return 0; 240 return 0;
251 241 return r.start;
252 addr_cells = prom_n_addr_cells(phb);
253 if (addr_cells == 1) {
254 buid = (unsigned long) buid_vals[0];
255 } else {
256 buid = (((unsigned long)buid_vals[0]) << 32UL) |
257 (((unsigned long)buid_vals[1]) & 0xffffffff);
258 }
259 return buid;
260} 242}
261 243
262static int phb_set_bus_ranges(struct device_node *dev, 244static int phb_set_bus_ranges(struct device_node *dev,
@@ -276,8 +258,10 @@ static int phb_set_bus_ranges(struct device_node *dev,
276 return 0; 258 return 0;
277} 259}
278 260
279int __devinit setup_phb(struct device_node *dev, struct pci_controller *phb) 261int __devinit rtas_setup_phb(struct pci_controller *phb)
280{ 262{
263 struct device_node *dev = phb->arch_data;
264
281 if (is_python(dev)) 265 if (is_python(dev))
282 python_countermeasures(dev); 266 python_countermeasures(dev);
283 267
@@ -309,7 +293,7 @@ unsigned long __init find_and_init_phbs(void)
309 phb = pcibios_alloc_controller(node); 293 phb = pcibios_alloc_controller(node);
310 if (!phb) 294 if (!phb)
311 continue; 295 continue;
312 setup_phb(node, phb); 296 rtas_setup_phb(phb);
313 pci_process_bridge_OF_ranges(phb, node, 0); 297 pci_process_bridge_OF_ranges(phb, node, 0);
314 pci_setup_phb_io(phb, index == 0); 298 pci_setup_phb_io(phb, index == 0);
315 index++; 299 index++;
@@ -381,7 +365,6 @@ int pcibios_remove_root_bus(struct pci_controller *phb)
381 } 365 }
382 } 366 }
383 367
384 list_del(&phb->list_node);
385 pcibios_free_controller(phb); 368 pcibios_free_controller(phb);
386 369
387 return 0; 370 return 0;
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index a4c2964a3ca6..61c65d19ef06 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -63,10 +63,6 @@ unsigned int DMA_MODE_WRITE;
63 63
64int have_of = 1; 64int have_of = 1;
65 65
66#ifdef CONFIG_PPC_MULTIPLATFORM
67dev_t boot_dev;
68#endif /* CONFIG_PPC_MULTIPLATFORM */
69
70#ifdef CONFIG_VGA_CONSOLE 66#ifdef CONFIG_VGA_CONSOLE
71unsigned long vgacon_remap_base; 67unsigned long vgacon_remap_base;
72#endif 68#endif
@@ -101,7 +97,7 @@ unsigned long __init early_init(unsigned long dt_ptr)
101 * Identify the CPU type and fix up code sections 97 * Identify the CPU type and fix up code sections
102 * that depend on which cpu we have. 98 * that depend on which cpu we have.
103 */ 99 */
104 spec = identify_cpu(offset); 100 spec = identify_cpu(offset, mfspr(SPRN_PVR));
105 101
106 do_feature_fixups(spec->cpu_features, 102 do_feature_fixups(spec->cpu_features,
107 PTRRELOC(&__start___ftr_fixup), 103 PTRRELOC(&__start___ftr_fixup),
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 16278968dab6..3733de30e84d 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -33,6 +33,7 @@
33#include <linux/serial.h> 33#include <linux/serial.h>
34#include <linux/serial_8250.h> 34#include <linux/serial_8250.h>
35#include <linux/bootmem.h> 35#include <linux/bootmem.h>
36#include <linux/pci.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/kdump.h> 38#include <asm/kdump.h>
38#include <asm/prom.h> 39#include <asm/prom.h>
@@ -71,7 +72,6 @@
71 72
72int have_of = 1; 73int have_of = 1;
73int boot_cpuid = 0; 74int boot_cpuid = 0;
74dev_t boot_dev;
75u64 ppc64_pft_size; 75u64 ppc64_pft_size;
76 76
77/* Pick defaults since we might want to patch instructions 77/* Pick defaults since we might want to patch instructions
@@ -171,7 +171,7 @@ void __init setup_paca(int cpu)
171void __init early_setup(unsigned long dt_ptr) 171void __init early_setup(unsigned long dt_ptr)
172{ 172{
173 /* Identify CPU type */ 173 /* Identify CPU type */
174 identify_cpu(0); 174 identify_cpu(0, mfspr(SPRN_PVR));
175 175
176 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */ 176 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */
177 setup_paca(0); 177 setup_paca(0);
@@ -226,8 +226,8 @@ void early_setup_secondary(void)
226{ 226{
227 struct paca_struct *lpaca = get_paca(); 227 struct paca_struct *lpaca = get_paca();
228 228
229 /* Mark enabled in PACA */ 229 /* Mark interrupts enabled in PACA */
230 lpaca->proc_enabled = 0; 230 lpaca->soft_enabled = 0;
231 231
232 /* Initialize hash table for that CPU */ 232 /* Initialize hash table for that CPU */
233 htab_initialize_secondary(); 233 htab_initialize_secondary();
@@ -392,7 +392,8 @@ void __init setup_system(void)
392 * setting up the hash table pointers. It also sets up some interrupt-mapping 392 * setting up the hash table pointers. It also sets up some interrupt-mapping
393 * related options that will be used by finish_device_tree() 393 * related options that will be used by finish_device_tree()
394 */ 394 */
395 ppc_md.init_early(); 395 if (ppc_md.init_early)
396 ppc_md.init_early();
396 397
397 /* 398 /*
398 * We can discover serial ports now since the above did setup the 399 * We can discover serial ports now since the above did setup the
@@ -598,3 +599,10 @@ void __init setup_per_cpu_areas(void)
598 } 599 }
599} 600}
600#endif 601#endif
602
603
604#ifdef CONFIG_PPC_INDIRECT_IO
605struct ppc_pci_io ppc_pci_io;
606EXPORT_SYMBOL(ppc_pci_io);
607#endif /* CONFIG_PPC_INDIRECT_IO */
608
diff --git a/arch/powerpc/kernel/smp-tbsync.c b/arch/powerpc/kernel/smp-tbsync.c
index de59c6c31a5b..bc892e69b4f7 100644
--- a/arch/powerpc/kernel/smp-tbsync.c
+++ b/arch/powerpc/kernel/smp-tbsync.c
@@ -78,7 +78,7 @@ static int __devinit start_contest(int cmd, long offset, int num)
78{ 78{
79 int i, score=0; 79 int i, score=0;
80 u64 tb; 80 u64 tb;
81 long mark; 81 u64 mark;
82 82
83 tbsync->cmd = cmd; 83 tbsync->cmd = cmd;
84 84
@@ -116,8 +116,7 @@ void __devinit smp_generic_give_timebase(void)
116 printk("Synchronizing timebase\n"); 116 printk("Synchronizing timebase\n");
117 117
118 /* if this fails then this kernel won't work anyway... */ 118 /* if this fails then this kernel won't work anyway... */
119 tbsync = kmalloc( sizeof(*tbsync), GFP_KERNEL ); 119 tbsync = kzalloc( sizeof(*tbsync), GFP_KERNEL );
120 memset( tbsync, 0, sizeof(*tbsync) );
121 mb(); 120 mb();
122 running = 1; 121 running = 1;
123 122
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 35c6309bdb76..9b28c238b6c0 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -65,6 +65,7 @@ cpumask_t cpu_sibling_map[NR_CPUS] = { [0 ... NR_CPUS-1] = CPU_MASK_NONE };
65 65
66EXPORT_SYMBOL(cpu_online_map); 66EXPORT_SYMBOL(cpu_online_map);
67EXPORT_SYMBOL(cpu_possible_map); 67EXPORT_SYMBOL(cpu_possible_map);
68EXPORT_SYMBOL(cpu_sibling_map);
68 69
69/* SMP operations for this machine */ 70/* SMP operations for this machine */
70struct smp_ops_t *smp_ops; 71struct smp_ops_t *smp_ops;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index d15c33e95959..03a2a2f30d66 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -51,6 +51,7 @@
51#include <asm/time.h> 51#include <asm/time.h>
52#include <asm/mmu_context.h> 52#include <asm/mmu_context.h>
53#include <asm/ppc-pci.h> 53#include <asm/ppc-pci.h>
54#include <asm/syscalls.h>
54 55
55/* readdir & getdents */ 56/* readdir & getdents */
56#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de))) 57#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index d45a168bdaca..22123a0d5416 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -200,10 +200,9 @@ static void register_cpu_online(unsigned int cpu)
200 struct cpu *c = &per_cpu(cpu_devices, cpu); 200 struct cpu *c = &per_cpu(cpu_devices, cpu);
201 struct sys_device *s = &c->sysdev; 201 struct sys_device *s = &c->sysdev;
202 202
203#ifndef CONFIG_PPC_ISERIES 203 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
204 if (cpu_has_feature(CPU_FTR_SMT)) 204 cpu_has_feature(CPU_FTR_SMT))
205 sysdev_create_file(s, &attr_smt_snooze_delay); 205 sysdev_create_file(s, &attr_smt_snooze_delay);
206#endif
207 206
208 /* PMC stuff */ 207 /* PMC stuff */
209 208
@@ -242,10 +241,9 @@ static void unregister_cpu_online(unsigned int cpu)
242 241
243 BUG_ON(c->no_control); 242 BUG_ON(c->no_control);
244 243
245#ifndef CONFIG_PPC_ISERIES 244 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
246 if (cpu_has_feature(CPU_FTR_SMT)) 245 cpu_has_feature(CPU_FTR_SMT))
247 sysdev_remove_file(s, &attr_smt_snooze_delay); 246 sysdev_remove_file(s, &attr_smt_snooze_delay);
248#endif
249 247
250 /* PMC stuff */ 248 /* PMC stuff */
251 249
@@ -299,6 +297,72 @@ static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
299 .notifier_call = sysfs_cpu_notify, 297 .notifier_call = sysfs_cpu_notify,
300}; 298};
301 299
300static DEFINE_MUTEX(cpu_mutex);
301
302int cpu_add_sysdev_attr(struct sysdev_attribute *attr)
303{
304 int cpu;
305
306 mutex_lock(&cpu_mutex);
307
308 for_each_possible_cpu(cpu) {
309 sysdev_create_file(get_cpu_sysdev(cpu), attr);
310 }
311
312 mutex_unlock(&cpu_mutex);
313 return 0;
314}
315EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr);
316
317int cpu_add_sysdev_attr_group(struct attribute_group *attrs)
318{
319 int cpu;
320 struct sys_device *sysdev;
321
322 mutex_lock(&cpu_mutex);
323
324 for_each_possible_cpu(cpu) {
325 sysdev = get_cpu_sysdev(cpu);
326 sysfs_create_group(&sysdev->kobj, attrs);
327 }
328
329 mutex_unlock(&cpu_mutex);
330 return 0;
331}
332EXPORT_SYMBOL_GPL(cpu_add_sysdev_attr_group);
333
334
335void cpu_remove_sysdev_attr(struct sysdev_attribute *attr)
336{
337 int cpu;
338
339 mutex_lock(&cpu_mutex);
340
341 for_each_possible_cpu(cpu) {
342 sysdev_remove_file(get_cpu_sysdev(cpu), attr);
343 }
344
345 mutex_unlock(&cpu_mutex);
346}
347EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr);
348
349void cpu_remove_sysdev_attr_group(struct attribute_group *attrs)
350{
351 int cpu;
352 struct sys_device *sysdev;
353
354 mutex_lock(&cpu_mutex);
355
356 for_each_possible_cpu(cpu) {
357 sysdev = get_cpu_sysdev(cpu);
358 sysfs_remove_group(&sysdev->kobj, attrs);
359 }
360
361 mutex_unlock(&cpu_mutex);
362}
363EXPORT_SYMBOL_GPL(cpu_remove_sysdev_attr_group);
364
365
302/* NUMA stuff */ 366/* NUMA stuff */
303 367
304#ifdef CONFIG_NUMA 368#ifdef CONFIG_NUMA
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 46a24de36fec..f6f0c6b07c4c 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -631,7 +631,8 @@ void timer_interrupt(struct pt_regs * regs)
631 calculate_steal_time(); 631 calculate_steal_time();
632 632
633#ifdef CONFIG_PPC_ISERIES 633#ifdef CONFIG_PPC_ISERIES
634 get_lppaca()->int_dword.fields.decr_int = 0; 634 if (firmware_has_feature(FW_FEATURE_ISERIES))
635 get_lppaca()->int_dword.fields.decr_int = 0;
635#endif 636#endif
636 637
637 while ((ticks = tb_ticks_since(per_cpu(last_jiffy, cpu))) 638 while ((ticks = tb_ticks_since(per_cpu(last_jiffy, cpu)))
@@ -674,7 +675,7 @@ void timer_interrupt(struct pt_regs * regs)
674 set_dec(next_dec); 675 set_dec(next_dec);
675 676
676#ifdef CONFIG_PPC_ISERIES 677#ifdef CONFIG_PPC_ISERIES
677 if (hvlpevent_is_pending()) 678 if (firmware_has_feature(FW_FEATURE_ISERIES) && hvlpevent_is_pending())
678 process_hvlpevents(); 679 process_hvlpevents();
679#endif 680#endif
680 681
@@ -774,7 +775,7 @@ int do_settimeofday(struct timespec *tv)
774 * settimeofday to perform this operation. 775 * settimeofday to perform this operation.
775 */ 776 */
776#ifdef CONFIG_PPC_ISERIES 777#ifdef CONFIG_PPC_ISERIES
777 if (first_settimeofday) { 778 if (firmware_has_feature(FW_FEATURE_ISERIES) && first_settimeofday) {
778 iSeries_tb_recal(); 779 iSeries_tb_recal();
779 first_settimeofday = 0; 780 first_settimeofday = 0;
780 } 781 }
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index c66b4771ef44..0d4e203fa7a0 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -53,10 +53,6 @@
53#endif 53#endif
54#include <asm/kexec.h> 54#include <asm/kexec.h>
55 55
56#ifdef CONFIG_PPC64 /* XXX */
57#define _IO_BASE pci_io_base
58#endif
59
60#ifdef CONFIG_DEBUGGER 56#ifdef CONFIG_DEBUGGER
61int (*__debugger)(struct pt_regs *regs); 57int (*__debugger)(struct pt_regs *regs);
62int (*__debugger_ipi)(struct pt_regs *regs); 58int (*__debugger_ipi)(struct pt_regs *regs);
@@ -241,7 +237,7 @@ void system_reset_exception(struct pt_regs *regs)
241 */ 237 */
242static inline int check_io_access(struct pt_regs *regs) 238static inline int check_io_access(struct pt_regs *regs)
243{ 239{
244#if defined(CONFIG_PPC_PMAC) && defined(CONFIG_PPC32) 240#ifdef CONFIG_PPC32
245 unsigned long msr = regs->msr; 241 unsigned long msr = regs->msr;
246 const struct exception_table_entry *entry; 242 const struct exception_table_entry *entry;
247 unsigned int *nip = (unsigned int *)regs->nip; 243 unsigned int *nip = (unsigned int *)regs->nip;
@@ -274,7 +270,7 @@ static inline int check_io_access(struct pt_regs *regs)
274 return 1; 270 return 1;
275 } 271 }
276 } 272 }
277#endif /* CONFIG_PPC_PMAC && CONFIG_PPC32 */ 273#endif /* CONFIG_PPC32 */
278 return 0; 274 return 0;
279} 275}
280 276
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index ed007878d1bf..a80f8f1d2e5d 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -81,15 +81,15 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
81 struct iommu_table *tbl; 81 struct iommu_table *tbl;
82 unsigned long offset, size; 82 unsigned long offset, size;
83 83
84 dma_window = get_property(dev->dev.platform_data, 84 dma_window = get_property(dev->dev.archdata.of_node,
85 "ibm,my-dma-window", NULL); 85 "ibm,my-dma-window", NULL);
86 if (!dma_window) 86 if (!dma_window)
87 return NULL; 87 return NULL;
88 88
89 tbl = kmalloc(sizeof(*tbl), GFP_KERNEL); 89 tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
90 90
91 of_parse_dma_window(dev->dev.platform_data, dma_window, 91 of_parse_dma_window(dev->dev.archdata.of_node, dma_window,
92 &tbl->it_index, &offset, &size); 92 &tbl->it_index, &offset, &size);
93 93
94 /* TCE table size - measured in tce entries */ 94 /* TCE table size - measured in tce entries */
95 tbl->it_size = size >> IOMMU_PAGE_SHIFT; 95 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
@@ -117,7 +117,8 @@ static const struct vio_device_id *vio_match_device(
117{ 117{
118 while (ids->type[0] != '\0') { 118 while (ids->type[0] != '\0') {
119 if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) && 119 if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) &&
120 device_is_compatible(dev->dev.platform_data, ids->compat)) 120 device_is_compatible(dev->dev.archdata.of_node,
121 ids->compat))
121 return ids; 122 return ids;
122 ids++; 123 ids++;
123 } 124 }
@@ -198,9 +199,9 @@ EXPORT_SYMBOL(vio_unregister_driver);
198/* vio_dev refcount hit 0 */ 199/* vio_dev refcount hit 0 */
199static void __devinit vio_dev_release(struct device *dev) 200static void __devinit vio_dev_release(struct device *dev)
200{ 201{
201 if (dev->platform_data) { 202 if (dev->archdata.of_node) {
202 /* XXX free TCE table */ 203 /* XXX should free TCE table */
203 of_node_put(dev->platform_data); 204 of_node_put(dev->archdata.of_node);
204 } 205 }
205 kfree(to_vio_dev(dev)); 206 kfree(to_vio_dev(dev));
206} 207}
@@ -210,7 +211,7 @@ static void __devinit vio_dev_release(struct device *dev)
210 * @of_node: The OF node for this device. 211 * @of_node: The OF node for this device.
211 * 212 *
212 * Creates and initializes a vio_dev structure from the data in 213 * Creates and initializes a vio_dev structure from the data in
213 * of_node (dev.platform_data) and adds it to the list of virtual devices. 214 * of_node and adds it to the list of virtual devices.
214 * Returns a pointer to the created vio_dev or NULL if node has 215 * Returns a pointer to the created vio_dev or NULL if node has
215 * NULL device_type or compatible fields. 216 * NULL device_type or compatible fields.
216 */ 217 */
@@ -240,8 +241,6 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
240 if (viodev == NULL) 241 if (viodev == NULL)
241 return NULL; 242 return NULL;
242 243
243 viodev->dev.platform_data = of_node_get(of_node);
244
245 viodev->irq = irq_of_parse_and_map(of_node, 0); 244 viodev->irq = irq_of_parse_and_map(of_node, 0);
246 245
247 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address); 246 snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
@@ -254,7 +253,10 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
254 if (unit_address != NULL) 253 if (unit_address != NULL)
255 viodev->unit_address = *unit_address; 254 viodev->unit_address = *unit_address;
256 } 255 }
257 viodev->iommu_table = vio_build_iommu_table(viodev); 256 viodev->dev.archdata.of_node = of_node_get(of_node);
257 viodev->dev.archdata.dma_ops = &dma_iommu_ops;
258 viodev->dev.archdata.dma_data = vio_build_iommu_table(viodev);
259 viodev->dev.archdata.numa_node = of_node_to_nid(of_node);
258 260
259 /* init generic 'struct device' fields: */ 261 /* init generic 'struct device' fields: */
260 viodev->dev.parent = &vio_bus_device.dev; 262 viodev->dev.parent = &vio_bus_device.dev;
@@ -285,10 +287,11 @@ static int __init vio_bus_init(void)
285#ifdef CONFIG_PPC_ISERIES 287#ifdef CONFIG_PPC_ISERIES
286 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 288 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
287 iommu_vio_init(); 289 iommu_vio_init();
288 vio_bus_device.iommu_table = &vio_iommu_table; 290 vio_bus_device.dev.archdata.dma_ops = &dma_iommu_ops;
291 vio_bus_device.dev.archdata.dma_data = &vio_iommu_table;
289 iSeries_vio_dev = &vio_bus_device.dev; 292 iSeries_vio_dev = &vio_bus_device.dev;
290 } 293 }
291#endif 294#endif /* CONFIG_PPC_ISERIES */
292 295
293 err = bus_register(&vio_bus_type); 296 err = bus_register(&vio_bus_type);
294 if (err) { 297 if (err) {
@@ -336,7 +339,7 @@ static ssize_t name_show(struct device *dev,
336static ssize_t devspec_show(struct device *dev, 339static ssize_t devspec_show(struct device *dev,
337 struct device_attribute *attr, char *buf) 340 struct device_attribute *attr, char *buf)
338{ 341{
339 struct device_node *of_node = dev->platform_data; 342 struct device_node *of_node = dev->archdata.of_node;
340 343
341 return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none"); 344 return sprintf(buf, "%s\n", of_node ? of_node->full_name : "none");
342} 345}
@@ -353,62 +356,6 @@ void __devinit vio_unregister_device(struct vio_dev *viodev)
353} 356}
354EXPORT_SYMBOL(vio_unregister_device); 357EXPORT_SYMBOL(vio_unregister_device);
355 358
356static dma_addr_t vio_map_single(struct device *dev, void *vaddr,
357 size_t size, enum dma_data_direction direction)
358{
359 return iommu_map_single(to_vio_dev(dev)->iommu_table, vaddr, size,
360 ~0ul, direction);
361}
362
363static void vio_unmap_single(struct device *dev, dma_addr_t dma_handle,
364 size_t size, enum dma_data_direction direction)
365{
366 iommu_unmap_single(to_vio_dev(dev)->iommu_table, dma_handle, size,
367 direction);
368}
369
370static int vio_map_sg(struct device *dev, struct scatterlist *sglist,
371 int nelems, enum dma_data_direction direction)
372{
373 return iommu_map_sg(dev, to_vio_dev(dev)->iommu_table, sglist,
374 nelems, ~0ul, direction);
375}
376
377static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
378 int nelems, enum dma_data_direction direction)
379{
380 iommu_unmap_sg(to_vio_dev(dev)->iommu_table, sglist, nelems, direction);
381}
382
383static void *vio_alloc_coherent(struct device *dev, size_t size,
384 dma_addr_t *dma_handle, gfp_t flag)
385{
386 return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
387 dma_handle, ~0ul, flag, -1);
388}
389
390static void vio_free_coherent(struct device *dev, size_t size,
391 void *vaddr, dma_addr_t dma_handle)
392{
393 iommu_free_coherent(to_vio_dev(dev)->iommu_table, size, vaddr,
394 dma_handle);
395}
396
397static int vio_dma_supported(struct device *dev, u64 mask)
398{
399 return 1;
400}
401
402struct dma_mapping_ops vio_dma_ops = {
403 .alloc_coherent = vio_alloc_coherent,
404 .free_coherent = vio_free_coherent,
405 .map_single = vio_map_single,
406 .unmap_single = vio_unmap_single,
407 .map_sg = vio_map_sg,
408 .unmap_sg = vio_unmap_sg,
409 .dma_supported = vio_dma_supported,
410};
411
412static int vio_bus_match(struct device *dev, struct device_driver *drv) 359static int vio_bus_match(struct device *dev, struct device_driver *drv)
413{ 360{
414 const struct vio_dev *vio_dev = to_vio_dev(dev); 361 const struct vio_dev *vio_dev = to_vio_dev(dev);
@@ -422,13 +369,14 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp,
422 char *buffer, int buffer_size) 369 char *buffer, int buffer_size)
423{ 370{
424 const struct vio_dev *vio_dev = to_vio_dev(dev); 371 const struct vio_dev *vio_dev = to_vio_dev(dev);
425 struct device_node *dn = dev->platform_data; 372 struct device_node *dn;
426 const char *cp; 373 const char *cp;
427 int length; 374 int length;
428 375
429 if (!num_envp) 376 if (!num_envp)
430 return -ENOMEM; 377 return -ENOMEM;
431 378
379 dn = dev->archdata.of_node;
432 if (!dn) 380 if (!dn)
433 return -ENODEV; 381 return -ENODEV;
434 cp = get_property(dn, "compatible", &length); 382 cp = get_property(dn, "compatible", &length);
@@ -465,7 +413,7 @@ struct bus_type vio_bus_type = {
465*/ 413*/
466const void *vio_get_attribute(struct vio_dev *vdev, char *which, int *length) 414const void *vio_get_attribute(struct vio_dev *vdev, char *which, int *length)
467{ 415{
468 return get_property(vdev->dev.platform_data, which, length); 416 return get_property(vdev->dev.archdata.of_node, which, length);
469} 417}
470EXPORT_SYMBOL(vio_get_attribute); 418EXPORT_SYMBOL(vio_get_attribute);
471 419
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 93441e7a2921..38a81967ca07 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -8,7 +8,7 @@ endif
8 8
9obj-y := fault.o mem.o lmb.o 9obj-y := fault.o mem.o lmb.o
10obj-$(CONFIG_PPC32) += init_32.o pgtable_32.o mmu_context_32.o 10obj-$(CONFIG_PPC32) += init_32.o pgtable_32.o mmu_context_32.o
11hash-$(CONFIG_PPC_MULTIPLATFORM) := hash_native_64.o 11hash-$(CONFIG_PPC_NATIVE) := hash_native_64.o
12obj-$(CONFIG_PPC64) += init_64.o pgtable_64.o mmu_context_64.o \ 12obj-$(CONFIG_PPC64) += init_64.o pgtable_64.o mmu_context_64.o \
13 hash_utils_64.o hash_low_64.o tlb_64.o \ 13 hash_utils_64.o hash_low_64.o tlb_64.o \
14 slb_low.o slb.o stab.o mmap.o imalloc.o \ 14 slb_low.o slb.o stab.o mmap.o imalloc.o \
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index e8fa50624b70..03aeb3a46077 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -426,18 +426,21 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)
426 426
427 /* kernel has accessed a bad area */ 427 /* kernel has accessed a bad area */
428 428
429 printk(KERN_ALERT "Unable to handle kernel paging request for ");
430 switch (regs->trap) { 429 switch (regs->trap) {
431 case 0x300: 430 case 0x300:
432 case 0x380: 431 case 0x380:
433 printk("data at address 0x%08lx\n", regs->dar); 432 printk(KERN_ALERT "Unable to handle kernel paging request for "
434 break; 433 "data at address 0x%08lx\n", regs->dar);
435 case 0x400: 434 break;
436 case 0x480: 435 case 0x400:
437 printk("instruction fetch\n"); 436 case 0x480:
438 break; 437 printk(KERN_ALERT "Unable to handle kernel paging request for "
439 default: 438 "instruction fetch\n");
440 printk("unknown fault\n"); 439 break;
440 default:
441 printk(KERN_ALERT "Unable to handle kernel paging request for "
442 "unknown fault\n");
443 break;
441 } 444 }
442 printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n", 445 printk(KERN_ALERT "Faulting instruction address: 0x%08lx\n",
443 regs->nip); 446 regs->nip);
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index c90f124f3c71..6f1016acdbf6 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -123,7 +123,7 @@ static inline void native_unlock_hpte(hpte_t *hptep)
123 clear_bit(HPTE_LOCK_BIT, word); 123 clear_bit(HPTE_LOCK_BIT, word);
124} 124}
125 125
126long native_hpte_insert(unsigned long hpte_group, unsigned long va, 126static long native_hpte_insert(unsigned long hpte_group, unsigned long va,
127 unsigned long pa, unsigned long rflags, 127 unsigned long pa, unsigned long rflags,
128 unsigned long vflags, int psize) 128 unsigned long vflags, int psize)
129{ 129{
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 1915661c2c81..c0d2a694fa30 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -277,7 +277,7 @@ static void __init htab_init_page_sizes(void)
277 * Not in the device-tree, let's fallback on known size 277 * Not in the device-tree, let's fallback on known size
278 * list for 16M capable GP & GR 278 * list for 16M capable GP & GR
279 */ 279 */
280 if (cpu_has_feature(CPU_FTR_16M_PAGE) && !machine_is(iseries)) 280 if (cpu_has_feature(CPU_FTR_16M_PAGE))
281 memcpy(mmu_psize_defs, mmu_psize_defaults_gp, 281 memcpy(mmu_psize_defs, mmu_psize_defaults_gp,
282 sizeof(mmu_psize_defaults_gp)); 282 sizeof(mmu_psize_defaults_gp));
283 found: 283 found:
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 3ff374697e34..9a178549cbcf 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -130,7 +130,7 @@ static int __init setup_kcore(void)
130 /* GFP_ATOMIC to avoid might_sleep warnings during boot */ 130 /* GFP_ATOMIC to avoid might_sleep warnings during boot */
131 kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC); 131 kcore_mem = kmalloc(sizeof(struct kcore_list), GFP_ATOMIC);
132 if (!kcore_mem) 132 if (!kcore_mem)
133 panic("mem_init: kmalloc failed\n"); 133 panic("%s: kmalloc failed\n", __FUNCTION__);
134 134
135 kclist_add(kcore_mem, __va(base), size); 135 kclist_add(kcore_mem, __va(base), size);
136 } 136 }
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 8fcacb0239da..1891dbeeb8e9 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -141,29 +141,19 @@ void pte_free(struct page *ptepage)
141 __free_page(ptepage); 141 __free_page(ptepage);
142} 142}
143 143
144#ifndef CONFIG_PHYS_64BIT
145void __iomem * 144void __iomem *
146ioremap(phys_addr_t addr, unsigned long size) 145ioremap(phys_addr_t addr, unsigned long size)
147{ 146{
148 return __ioremap(addr, size, _PAGE_NO_CACHE); 147 return __ioremap(addr, size, _PAGE_NO_CACHE);
149} 148}
150#else /* CONFIG_PHYS_64BIT */ 149EXPORT_SYMBOL(ioremap);
151void __iomem *
152ioremap64(unsigned long long addr, unsigned long size)
153{
154 return __ioremap(addr, size, _PAGE_NO_CACHE);
155}
156EXPORT_SYMBOL(ioremap64);
157 150
158void __iomem * 151void __iomem *
159ioremap(phys_addr_t addr, unsigned long size) 152ioremap_flags(phys_addr_t addr, unsigned long size, unsigned long flags)
160{ 153{
161 phys_addr_t addr64 = fixup_bigphys_addr(addr, size); 154 return __ioremap(addr, size, flags);
162
163 return ioremap64(addr64, size);
164} 155}
165#endif /* CONFIG_PHYS_64BIT */ 156EXPORT_SYMBOL(ioremap_flags);
166EXPORT_SYMBOL(ioremap);
167 157
168void __iomem * 158void __iomem *
169__ioremap(phys_addr_t addr, unsigned long size, unsigned long flags) 159__ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
@@ -264,20 +254,7 @@ void iounmap(volatile void __iomem *addr)
264} 254}
265EXPORT_SYMBOL(iounmap); 255EXPORT_SYMBOL(iounmap);
266 256
267void __iomem *ioport_map(unsigned long port, unsigned int len) 257int map_page(unsigned long va, phys_addr_t pa, int flags)
268{
269 return (void __iomem *) (port + _IO_BASE);
270}
271
272void ioport_unmap(void __iomem *addr)
273{
274 /* Nothing to do */
275}
276EXPORT_SYMBOL(ioport_map);
277EXPORT_SYMBOL(ioport_unmap);
278
279int
280map_page(unsigned long va, phys_addr_t pa, int flags)
281{ 258{
282 pmd_t *pd; 259 pmd_t *pd;
283 pte_t *pg; 260 pte_t *pg;
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index ac64f4aaa509..16e4ee1c2318 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -113,7 +113,7 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
113} 113}
114 114
115 115
116static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa, 116static void __iomem * __ioremap_com(phys_addr_t addr, unsigned long pa,
117 unsigned long ea, unsigned long size, 117 unsigned long ea, unsigned long size,
118 unsigned long flags) 118 unsigned long flags)
119{ 119{
@@ -129,22 +129,12 @@ static void __iomem * __ioremap_com(unsigned long addr, unsigned long pa,
129 return (void __iomem *) (ea + (addr & ~PAGE_MASK)); 129 return (void __iomem *) (ea + (addr & ~PAGE_MASK));
130} 130}
131 131
132 132void __iomem * __ioremap(phys_addr_t addr, unsigned long size,
133void __iomem *
134ioremap(unsigned long addr, unsigned long size)
135{
136 return __ioremap(addr, size, _PAGE_NO_CACHE | _PAGE_GUARDED);
137}
138
139void __iomem * __ioremap(unsigned long addr, unsigned long size,
140 unsigned long flags) 133 unsigned long flags)
141{ 134{
142 unsigned long pa, ea; 135 unsigned long pa, ea;
143 void __iomem *ret; 136 void __iomem *ret;
144 137
145 if (firmware_has_feature(FW_FEATURE_ISERIES))
146 return (void __iomem *)addr;
147
148 /* 138 /*
149 * Choose an address to map it to. 139 * Choose an address to map it to.
150 * Once the imalloc system is running, we use it. 140 * Once the imalloc system is running, we use it.
@@ -178,9 +168,28 @@ void __iomem * __ioremap(unsigned long addr, unsigned long size,
178 return ret; 168 return ret;
179} 169}
180 170
171
172void __iomem * ioremap(phys_addr_t addr, unsigned long size)
173{
174 unsigned long flags = _PAGE_NO_CACHE | _PAGE_GUARDED;
175
176 if (ppc_md.ioremap)
177 return ppc_md.ioremap(addr, size, flags);
178 return __ioremap(addr, size, flags);
179}
180
181void __iomem * ioremap_flags(phys_addr_t addr, unsigned long size,
182 unsigned long flags)
183{
184 if (ppc_md.ioremap)
185 return ppc_md.ioremap(addr, size, flags);
186 return __ioremap(addr, size, flags);
187}
188
189
181#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK)) 190#define IS_PAGE_ALIGNED(_val) ((_val) == ((_val) & PAGE_MASK))
182 191
183int __ioremap_explicit(unsigned long pa, unsigned long ea, 192int __ioremap_explicit(phys_addr_t pa, unsigned long ea,
184 unsigned long size, unsigned long flags) 193 unsigned long size, unsigned long flags)
185{ 194{
186 struct vm_struct *area; 195 struct vm_struct *area;
@@ -235,13 +244,10 @@ int __ioremap_explicit(unsigned long pa, unsigned long ea,
235 * 244 *
236 * XXX what about calls before mem_init_done (ie python_countermeasures()) 245 * XXX what about calls before mem_init_done (ie python_countermeasures())
237 */ 246 */
238void iounmap(volatile void __iomem *token) 247void __iounmap(volatile void __iomem *token)
239{ 248{
240 void *addr; 249 void *addr;
241 250
242 if (firmware_has_feature(FW_FEATURE_ISERIES))
243 return;
244
245 if (!mem_init_done) 251 if (!mem_init_done)
246 return; 252 return;
247 253
@@ -250,6 +256,14 @@ void iounmap(volatile void __iomem *token)
250 im_free(addr); 256 im_free(addr);
251} 257}
252 258
259void iounmap(volatile void __iomem *token)
260{
261 if (ppc_md.iounmap)
262 ppc_md.iounmap(token);
263 else
264 __iounmap(token);
265}
266
253static int iounmap_subset_regions(unsigned long addr, unsigned long size) 267static int iounmap_subset_regions(unsigned long addr, unsigned long size)
254{ 268{
255 struct vm_struct *area; 269 struct vm_struct *area;
@@ -268,7 +282,7 @@ static int iounmap_subset_regions(unsigned long addr, unsigned long size)
268 return 0; 282 return 0;
269} 283}
270 284
271int iounmap_explicit(volatile void __iomem *start, unsigned long size) 285int __iounmap_explicit(volatile void __iomem *start, unsigned long size)
272{ 286{
273 struct vm_struct *area; 287 struct vm_struct *area;
274 unsigned long addr; 288 unsigned long addr;
@@ -303,8 +317,10 @@ int iounmap_explicit(volatile void __iomem *start, unsigned long size)
303} 317}
304 318
305EXPORT_SYMBOL(ioremap); 319EXPORT_SYMBOL(ioremap);
320EXPORT_SYMBOL(ioremap_flags);
306EXPORT_SYMBOL(__ioremap); 321EXPORT_SYMBOL(__ioremap);
307EXPORT_SYMBOL(iounmap); 322EXPORT_SYMBOL(iounmap);
323EXPORT_SYMBOL(__iounmap);
308 324
309void __iomem * reserve_phb_iospace(unsigned long size) 325void __iomem * reserve_phb_iospace(unsigned long size)
310{ 326{
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index d3733912adb4..224e960650a0 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -23,6 +23,7 @@
23#include <asm/cputable.h> 23#include <asm/cputable.h>
24#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
25#include <asm/smp.h> 25#include <asm/smp.h>
26#include <asm/firmware.h>
26#include <linux/compiler.h> 27#include <linux/compiler.h>
27 28
28#ifdef DEBUG 29#ifdef DEBUG
@@ -193,6 +194,7 @@ static inline void patch_slb_encoding(unsigned int *insn_addr,
193void slb_initialize(void) 194void slb_initialize(void)
194{ 195{
195 unsigned long linear_llp, vmalloc_llp, io_llp; 196 unsigned long linear_llp, vmalloc_llp, io_llp;
197 unsigned long lflags, vflags;
196 static int slb_encoding_inited; 198 static int slb_encoding_inited;
197 extern unsigned int *slb_miss_kernel_load_linear; 199 extern unsigned int *slb_miss_kernel_load_linear;
198 extern unsigned int *slb_miss_kernel_load_io; 200 extern unsigned int *slb_miss_kernel_load_io;
@@ -225,11 +227,12 @@ void slb_initialize(void)
225#endif 227#endif
226 } 228 }
227 229
230 get_paca()->stab_rr = SLB_NUM_BOLTED;
231
228 /* On iSeries the bolted entries have already been set up by 232 /* On iSeries the bolted entries have already been set up by
229 * the hypervisor from the lparMap data in head.S */ 233 * the hypervisor from the lparMap data in head.S */
230#ifndef CONFIG_PPC_ISERIES 234 if (firmware_has_feature(FW_FEATURE_ISERIES))
231 { 235 return;
232 unsigned long lflags, vflags;
233 236
234 lflags = SLB_VSID_KERNEL | linear_llp; 237 lflags = SLB_VSID_KERNEL | linear_llp;
235 vflags = SLB_VSID_KERNEL | vmalloc_llp; 238 vflags = SLB_VSID_KERNEL | vmalloc_llp;
@@ -247,8 +250,4 @@ void slb_initialize(void)
247 * elsewhere, we'll call _switch() which will bolt in the new 250 * elsewhere, we'll call _switch() which will bolt in the new
248 * one. */ 251 * one. */
249 asm volatile("isync":::"memory"); 252 asm volatile("isync":::"memory");
250 }
251#endif /* CONFIG_PPC_ISERIES */
252
253 get_paca()->stab_rr = SLB_NUM_BOLTED;
254} 253}
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index 0b5df9c96ae0..4ccef2d5530c 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -11,6 +11,7 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
11 timer_int.o ) 11 timer_int.o )
12 12
13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
14oprofile-$(CONFIG_PPC_CELL_NATIVE) += op_model_cell.o
14oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o 15oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o
15oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o 16oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
16oprofile-$(CONFIG_6xx) += op_model_7450.o 17oprofile-$(CONFIG_6xx) += op_model_7450.o
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index 63bbef3b63f1..b6d82390b6a6 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -69,7 +69,10 @@ static void op_powerpc_cpu_start(void *dummy)
69 69
70static int op_powerpc_start(void) 70static int op_powerpc_start(void)
71{ 71{
72 on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1); 72 if (model->global_start)
73 model->global_start(ctr);
74 if (model->start)
75 on_each_cpu(op_powerpc_cpu_start, NULL, 0, 1);
73 return 0; 76 return 0;
74} 77}
75 78
@@ -80,7 +83,10 @@ static inline void op_powerpc_cpu_stop(void *dummy)
80 83
81static void op_powerpc_stop(void) 84static void op_powerpc_stop(void)
82{ 85{
83 on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1); 86 if (model->stop)
87 on_each_cpu(op_powerpc_cpu_stop, NULL, 0, 1);
88 if (model->global_stop)
89 model->global_stop();
84} 90}
85 91
86static int op_powerpc_create_files(struct super_block *sb, struct dentry *root) 92static int op_powerpc_create_files(struct super_block *sb, struct dentry *root)
@@ -141,6 +147,11 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
141 147
142 switch (cur_cpu_spec->oprofile_type) { 148 switch (cur_cpu_spec->oprofile_type) {
143#ifdef CONFIG_PPC64 149#ifdef CONFIG_PPC64
150#ifdef CONFIG_PPC_CELL_NATIVE
151 case PPC_OPROFILE_CELL:
152 model = &op_model_cell;
153 break;
154#endif
144 case PPC_OPROFILE_RS64: 155 case PPC_OPROFILE_RS64:
145 model = &op_model_rs64; 156 model = &op_model_rs64;
146 break; 157 break;
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
new file mode 100644
index 000000000000..2eb15f388103
--- /dev/null
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -0,0 +1,724 @@
1/*
2 * Cell Broadband Engine OProfile Support
3 *
4 * (C) Copyright IBM Corporation 2006
5 *
6 * Author: David Erb (djerb@us.ibm.com)
7 * Modifications:
8 * Carl Love <carll@us.ibm.com>
9 * Maynard Johnson <maynardj@us.ibm.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16
17#include <linux/cpufreq.h>
18#include <linux/delay.h>
19#include <linux/init.h>
20#include <linux/jiffies.h>
21#include <linux/kthread.h>
22#include <linux/oprofile.h>
23#include <linux/percpu.h>
24#include <linux/smp.h>
25#include <linux/spinlock.h>
26#include <linux/timer.h>
27#include <asm/cell-pmu.h>
28#include <asm/cputable.h>
29#include <asm/firmware.h>
30#include <asm/io.h>
31#include <asm/oprofile_impl.h>
32#include <asm/processor.h>
33#include <asm/prom.h>
34#include <asm/ptrace.h>
35#include <asm/reg.h>
36#include <asm/rtas.h>
37#include <asm/system.h>
38
39#include "../platforms/cell/interrupt.h"
40
41#define PPU_CYCLES_EVENT_NUM 1 /* event number for CYCLES */
42#define CBE_COUNT_ALL_CYCLES 0x42800000 /* PPU cycle event specifier */
43
44#define NUM_THREADS 2
45#define VIRT_CNTR_SW_TIME_NS 100000000 // 0.5 seconds
46
47struct pmc_cntrl_data {
48 unsigned long vcntr;
49 unsigned long evnts;
50 unsigned long masks;
51 unsigned long enabled;
52};
53
54/*
55 * ibm,cbe-perftools rtas parameters
56 */
57
58struct pm_signal {
59 u16 cpu; /* Processor to modify */
60 u16 sub_unit; /* hw subunit this applies to (if applicable) */
61 u16 signal_group; /* Signal Group to Enable/Disable */
62 u8 bus_word; /* Enable/Disable on this Trace/Trigger/Event
63 * Bus Word(s) (bitmask)
64 */
65 u8 bit; /* Trigger/Event bit (if applicable) */
66};
67
68/*
69 * rtas call arguments
70 */
71enum {
72 SUBFUNC_RESET = 1,
73 SUBFUNC_ACTIVATE = 2,
74 SUBFUNC_DEACTIVATE = 3,
75
76 PASSTHRU_IGNORE = 0,
77 PASSTHRU_ENABLE = 1,
78 PASSTHRU_DISABLE = 2,
79};
80
81struct pm_cntrl {
82 u16 enable;
83 u16 stop_at_max;
84 u16 trace_mode;
85 u16 freeze;
86 u16 count_mode;
87};
88
89static struct {
90 u32 group_control;
91 u32 debug_bus_control;
92 struct pm_cntrl pm_cntrl;
93 u32 pm07_cntrl[NR_PHYS_CTRS];
94} pm_regs;
95
96
97#define GET_SUB_UNIT(x) ((x & 0x0000f000) >> 12)
98#define GET_BUS_WORD(x) ((x & 0x000000f0) >> 4)
99#define GET_BUS_TYPE(x) ((x & 0x00000300) >> 8)
100#define GET_POLARITY(x) ((x & 0x00000002) >> 1)
101#define GET_COUNT_CYCLES(x) (x & 0x00000001)
102#define GET_INPUT_CONTROL(x) ((x & 0x00000004) >> 2)
103
104
105static DEFINE_PER_CPU(unsigned long[NR_PHYS_CTRS], pmc_values);
106
107static struct pmc_cntrl_data pmc_cntrl[NUM_THREADS][NR_PHYS_CTRS];
108
109/* Interpetation of hdw_thread:
110 * 0 - even virtual cpus 0, 2, 4,...
111 * 1 - odd virtual cpus 1, 3, 5, ...
112 */
113static u32 hdw_thread;
114
115static u32 virt_cntr_inter_mask;
116static struct timer_list timer_virt_cntr;
117
118/* pm_signal needs to be global since it is initialized in
119 * cell_reg_setup at the time when the necessary information
120 * is available.
121 */
122static struct pm_signal pm_signal[NR_PHYS_CTRS];
123static int pm_rtas_token;
124
125static u32 reset_value[NR_PHYS_CTRS];
126static int num_counters;
127static int oprofile_running;
128static spinlock_t virt_cntr_lock = SPIN_LOCK_UNLOCKED;
129
130static u32 ctr_enabled;
131
132static unsigned char trace_bus[4];
133static unsigned char input_bus[2];
134
135/*
136 * Firmware interface functions
137 */
138static int
139rtas_ibm_cbe_perftools(int subfunc, int passthru,
140 void *address, unsigned long length)
141{
142 u64 paddr = __pa(address);
143
144 return rtas_call(pm_rtas_token, 5, 1, NULL, subfunc, passthru,
145 paddr >> 32, paddr & 0xffffffff, length);
146}
147
148static void pm_rtas_reset_signals(u32 node)
149{
150 int ret;
151 struct pm_signal pm_signal_local;
152
153 /* The debug bus is being set to the passthru disable state.
154 * However, the FW still expects atleast one legal signal routing
155 * entry or it will return an error on the arguments. If we don't
156 * supply a valid entry, we must ignore all return values. Ignoring
157 * all return values means we might miss an error we should be
158 * concerned about.
159 */
160
161 /* fw expects physical cpu #. */
162 pm_signal_local.cpu = node;
163 pm_signal_local.signal_group = 21;
164 pm_signal_local.bus_word = 1;
165 pm_signal_local.sub_unit = 0;
166 pm_signal_local.bit = 0;
167
168 ret = rtas_ibm_cbe_perftools(SUBFUNC_RESET, PASSTHRU_DISABLE,
169 &pm_signal_local,
170 sizeof(struct pm_signal));
171
172 if (ret)
173 printk(KERN_WARNING "%s: rtas returned: %d\n",
174 __FUNCTION__, ret);
175}
176
177static void pm_rtas_activate_signals(u32 node, u32 count)
178{
179 int ret;
180 int j;
181 struct pm_signal pm_signal_local[NR_PHYS_CTRS];
182
183 for (j = 0; j < count; j++) {
184 /* fw expects physical cpu # */
185 pm_signal_local[j].cpu = node;
186 pm_signal_local[j].signal_group = pm_signal[j].signal_group;
187 pm_signal_local[j].bus_word = pm_signal[j].bus_word;
188 pm_signal_local[j].sub_unit = pm_signal[j].sub_unit;
189 pm_signal_local[j].bit = pm_signal[j].bit;
190 }
191
192 ret = rtas_ibm_cbe_perftools(SUBFUNC_ACTIVATE, PASSTHRU_ENABLE,
193 pm_signal_local,
194 count * sizeof(struct pm_signal));
195
196 if (ret)
197 printk(KERN_WARNING "%s: rtas returned: %d\n",
198 __FUNCTION__, ret);
199}
200
201/*
202 * PM Signal functions
203 */
204static void set_pm_event(u32 ctr, int event, u32 unit_mask)
205{
206 struct pm_signal *p;
207 u32 signal_bit;
208 u32 bus_word, bus_type, count_cycles, polarity, input_control;
209 int j, i;
210
211 if (event == PPU_CYCLES_EVENT_NUM) {
212 /* Special Event: Count all cpu cycles */
213 pm_regs.pm07_cntrl[ctr] = CBE_COUNT_ALL_CYCLES;
214 p = &(pm_signal[ctr]);
215 p->signal_group = 21;
216 p->bus_word = 1;
217 p->sub_unit = 0;
218 p->bit = 0;
219 goto out;
220 } else {
221 pm_regs.pm07_cntrl[ctr] = 0;
222 }
223
224 bus_word = GET_BUS_WORD(unit_mask);
225 bus_type = GET_BUS_TYPE(unit_mask);
226 count_cycles = GET_COUNT_CYCLES(unit_mask);
227 polarity = GET_POLARITY(unit_mask);
228 input_control = GET_INPUT_CONTROL(unit_mask);
229 signal_bit = (event % 100);
230
231 p = &(pm_signal[ctr]);
232
233 p->signal_group = event / 100;
234 p->bus_word = bus_word;
235 p->sub_unit = unit_mask & 0x0000f000;
236
237 pm_regs.pm07_cntrl[ctr] = 0;
238 pm_regs.pm07_cntrl[ctr] |= PM07_CTR_COUNT_CYCLES(count_cycles);
239 pm_regs.pm07_cntrl[ctr] |= PM07_CTR_POLARITY(polarity);
240 pm_regs.pm07_cntrl[ctr] |= PM07_CTR_INPUT_CONTROL(input_control);
241
242 if (input_control == 0) {
243 if (signal_bit > 31) {
244 signal_bit -= 32;
245 if (bus_word == 0x3)
246 bus_word = 0x2;
247 else if (bus_word == 0xc)
248 bus_word = 0x8;
249 }
250
251 if ((bus_type == 0) && p->signal_group >= 60)
252 bus_type = 2;
253 if ((bus_type == 1) && p->signal_group >= 50)
254 bus_type = 0;
255
256 pm_regs.pm07_cntrl[ctr] |= PM07_CTR_INPUT_MUX(signal_bit);
257 } else {
258 pm_regs.pm07_cntrl[ctr] = 0;
259 p->bit = signal_bit;
260 }
261
262 for (i = 0; i < 4; i++) {
263 if (bus_word & (1 << i)) {
264 pm_regs.debug_bus_control |=
265 (bus_type << (31 - (2 * i) + 1));
266
267 for (j = 0; j < 2; j++) {
268 if (input_bus[j] == 0xff) {
269 input_bus[j] = i;
270 pm_regs.group_control |=
271 (i << (31 - i));
272 break;
273 }
274 }
275 }
276 }
277out:
278 ;
279}
280
281static void write_pm_cntrl(int cpu, struct pm_cntrl *pm_cntrl)
282{
283 /* Oprofile will use 32 bit counters, set bits 7:10 to 0 */
284 u32 val = 0;
285 if (pm_cntrl->enable == 1)
286 val |= CBE_PM_ENABLE_PERF_MON;
287
288 if (pm_cntrl->stop_at_max == 1)
289 val |= CBE_PM_STOP_AT_MAX;
290
291 if (pm_cntrl->trace_mode == 1)
292 val |= CBE_PM_TRACE_MODE_SET(pm_cntrl->trace_mode);
293
294 if (pm_cntrl->freeze == 1)
295 val |= CBE_PM_FREEZE_ALL_CTRS;
296
297 /* Routine set_count_mode must be called previously to set
298 * the count mode based on the user selection of user and kernel.
299 */
300 val |= CBE_PM_COUNT_MODE_SET(pm_cntrl->count_mode);
301 cbe_write_pm(cpu, pm_control, val);
302}
303
304static inline void
305set_count_mode(u32 kernel, u32 user, struct pm_cntrl *pm_cntrl)
306{
307 /* The user must specify user and kernel if they want them. If
308 * neither is specified, OProfile will count in hypervisor mode
309 */
310 if (kernel) {
311 if (user)
312 pm_cntrl->count_mode = CBE_COUNT_ALL_MODES;
313 else
314 pm_cntrl->count_mode = CBE_COUNT_SUPERVISOR_MODE;
315 } else {
316 if (user)
317 pm_cntrl->count_mode = CBE_COUNT_PROBLEM_MODE;
318 else
319 pm_cntrl->count_mode = CBE_COUNT_HYPERVISOR_MODE;
320 }
321}
322
323static inline void enable_ctr(u32 cpu, u32 ctr, u32 * pm07_cntrl)
324{
325
326 pm07_cntrl[ctr] |= PM07_CTR_ENABLE(1);
327 cbe_write_pm07_control(cpu, ctr, pm07_cntrl[ctr]);
328}
329
330/*
331 * Oprofile is expected to collect data on all CPUs simultaneously.
332 * However, there is one set of performance counters per node. There are
333 * two hardware threads or virtual CPUs on each node. Hence, OProfile must
334 * multiplex in time the performance counter collection on the two virtual
335 * CPUs. The multiplexing of the performance counters is done by this
336 * virtual counter routine.
337 *
338 * The pmc_values used below is defined as 'per-cpu' but its use is
339 * more akin to 'per-node'. We need to store two sets of counter
340 * values per node -- one for the previous run and one for the next.
341 * The per-cpu[NR_PHYS_CTRS] gives us the storage we need. Each odd/even
342 * pair of per-cpu arrays is used for storing the previous and next
343 * pmc values for a given node.
344 * NOTE: We use the per-cpu variable to improve cache performance.
345 */
346static void cell_virtual_cntr(unsigned long data)
347{
348 /* This routine will alternate loading the virtual counters for
349 * virtual CPUs
350 */
351 int i, prev_hdw_thread, next_hdw_thread;
352 u32 cpu;
353 unsigned long flags;
354
355 /* Make sure that the interrupt_hander and
356 * the virt counter are not both playing with
357 * the counters on the same node.
358 */
359
360 spin_lock_irqsave(&virt_cntr_lock, flags);
361
362 prev_hdw_thread = hdw_thread;
363
364 /* switch the cpu handling the interrupts */
365 hdw_thread = 1 ^ hdw_thread;
366 next_hdw_thread = hdw_thread;
367
368 /* The following is done only once per each node, but
369 * we need cpu #, not node #, to pass to the cbe_xxx functions.
370 */
371 for_each_online_cpu(cpu) {
372 if (cbe_get_hw_thread_id(cpu))
373 continue;
374
375 /* stop counters, save counter values, restore counts
376 * for previous thread
377 */
378 cbe_disable_pm(cpu);
379 cbe_disable_pm_interrupts(cpu);
380 for (i = 0; i < num_counters; i++) {
381 per_cpu(pmc_values, cpu + prev_hdw_thread)[i]
382 = cbe_read_ctr(cpu, i);
383
384 if (per_cpu(pmc_values, cpu + next_hdw_thread)[i]
385 == 0xFFFFFFFF)
386 /* If the cntr value is 0xffffffff, we must
387 * reset that to 0xfffffff0 when the current
388 * thread is restarted. This will generate a new
389 * interrupt and make sure that we never restore
390 * the counters to the max value. If the counters
391 * were restored to the max value, they do not
392 * increment and no interrupts are generated. Hence
393 * no more samples will be collected on that cpu.
394 */
395 cbe_write_ctr(cpu, i, 0xFFFFFFF0);
396 else
397 cbe_write_ctr(cpu, i,
398 per_cpu(pmc_values,
399 cpu +
400 next_hdw_thread)[i]);
401 }
402
403 /* Switch to the other thread. Change the interrupt
404 * and control regs to be scheduled on the CPU
405 * corresponding to the thread to execute.
406 */
407 for (i = 0; i < num_counters; i++) {
408 if (pmc_cntrl[next_hdw_thread][i].enabled) {
409 /* There are some per thread events.
410 * Must do the set event, enable_cntr
411 * for each cpu.
412 */
413 set_pm_event(i,
414 pmc_cntrl[next_hdw_thread][i].evnts,
415 pmc_cntrl[next_hdw_thread][i].masks);
416 enable_ctr(cpu, i,
417 pm_regs.pm07_cntrl);
418 } else {
419 cbe_write_pm07_control(cpu, i, 0);
420 }
421 }
422
423 /* Enable interrupts on the CPU thread that is starting */
424 cbe_enable_pm_interrupts(cpu, next_hdw_thread,
425 virt_cntr_inter_mask);
426 cbe_enable_pm(cpu);
427 }
428
429 spin_unlock_irqrestore(&virt_cntr_lock, flags);
430
431 mod_timer(&timer_virt_cntr, jiffies + HZ / 10);
432}
433
434static void start_virt_cntrs(void)
435{
436 init_timer(&timer_virt_cntr);
437 timer_virt_cntr.function = cell_virtual_cntr;
438 timer_virt_cntr.data = 0UL;
439 timer_virt_cntr.expires = jiffies + HZ / 10;
440 add_timer(&timer_virt_cntr);
441}
442
443/* This function is called once for all cpus combined */
444static void
445cell_reg_setup(struct op_counter_config *ctr,
446 struct op_system_config *sys, int num_ctrs)
447{
448 int i, j, cpu;
449
450 pm_rtas_token = rtas_token("ibm,cbe-perftools");
451 if (pm_rtas_token == RTAS_UNKNOWN_SERVICE) {
452 printk(KERN_WARNING "%s: RTAS_UNKNOWN_SERVICE\n",
453 __FUNCTION__);
454 goto out;
455 }
456
457 num_counters = num_ctrs;
458
459 pm_regs.group_control = 0;
460 pm_regs.debug_bus_control = 0;
461
462 /* setup the pm_control register */
463 memset(&pm_regs.pm_cntrl, 0, sizeof(struct pm_cntrl));
464 pm_regs.pm_cntrl.stop_at_max = 1;
465 pm_regs.pm_cntrl.trace_mode = 0;
466 pm_regs.pm_cntrl.freeze = 1;
467
468 set_count_mode(sys->enable_kernel, sys->enable_user,
469 &pm_regs.pm_cntrl);
470
471 /* Setup the thread 0 events */
472 for (i = 0; i < num_ctrs; ++i) {
473
474 pmc_cntrl[0][i].evnts = ctr[i].event;
475 pmc_cntrl[0][i].masks = ctr[i].unit_mask;
476 pmc_cntrl[0][i].enabled = ctr[i].enabled;
477 pmc_cntrl[0][i].vcntr = i;
478
479 for_each_possible_cpu(j)
480 per_cpu(pmc_values, j)[i] = 0;
481 }
482
483 /* Setup the thread 1 events, map the thread 0 event to the
484 * equivalent thread 1 event.
485 */
486 for (i = 0; i < num_ctrs; ++i) {
487 if ((ctr[i].event >= 2100) && (ctr[i].event <= 2111))
488 pmc_cntrl[1][i].evnts = ctr[i].event + 19;
489 else if (ctr[i].event == 2203)
490 pmc_cntrl[1][i].evnts = ctr[i].event;
491 else if ((ctr[i].event >= 2200) && (ctr[i].event <= 2215))
492 pmc_cntrl[1][i].evnts = ctr[i].event + 16;
493 else
494 pmc_cntrl[1][i].evnts = ctr[i].event;
495
496 pmc_cntrl[1][i].masks = ctr[i].unit_mask;
497 pmc_cntrl[1][i].enabled = ctr[i].enabled;
498 pmc_cntrl[1][i].vcntr = i;
499 }
500
501 for (i = 0; i < 4; i++)
502 trace_bus[i] = 0xff;
503
504 for (i = 0; i < 2; i++)
505 input_bus[i] = 0xff;
506
507 /* Our counters count up, and "count" refers to
508 * how much before the next interrupt, and we interrupt
509 * on overflow. So we calculate the starting value
510 * which will give us "count" until overflow.
511 * Then we set the events on the enabled counters.
512 */
513 for (i = 0; i < num_counters; ++i) {
514 /* start with virtual counter set 0 */
515 if (pmc_cntrl[0][i].enabled) {
516 /* Using 32bit counters, reset max - count */
517 reset_value[i] = 0xFFFFFFFF - ctr[i].count;
518 set_pm_event(i,
519 pmc_cntrl[0][i].evnts,
520 pmc_cntrl[0][i].masks);
521
522 /* global, used by cell_cpu_setup */
523 ctr_enabled |= (1 << i);
524 }
525 }
526
527 /* initialize the previous counts for the virtual cntrs */
528 for_each_online_cpu(cpu)
529 for (i = 0; i < num_counters; ++i) {
530 per_cpu(pmc_values, cpu)[i] = reset_value[i];
531 }
532out:
533 ;
534}
535
536/* This function is called once for each cpu */
537static void cell_cpu_setup(struct op_counter_config *cntr)
538{
539 u32 cpu = smp_processor_id();
540 u32 num_enabled = 0;
541 int i;
542
543 /* There is one performance monitor per processor chip (i.e. node),
544 * so we only need to perform this function once per node.
545 */
546 if (cbe_get_hw_thread_id(cpu))
547 goto out;
548
549 if (pm_rtas_token == RTAS_UNKNOWN_SERVICE) {
550 printk(KERN_WARNING "%s: RTAS_UNKNOWN_SERVICE\n",
551 __FUNCTION__);
552 goto out;
553 }
554
555 /* Stop all counters */
556 cbe_disable_pm(cpu);
557 cbe_disable_pm_interrupts(cpu);
558
559 cbe_write_pm(cpu, pm_interval, 0);
560 cbe_write_pm(cpu, pm_start_stop, 0);
561 cbe_write_pm(cpu, group_control, pm_regs.group_control);
562 cbe_write_pm(cpu, debug_bus_control, pm_regs.debug_bus_control);
563 write_pm_cntrl(cpu, &pm_regs.pm_cntrl);
564
565 for (i = 0; i < num_counters; ++i) {
566 if (ctr_enabled & (1 << i)) {
567 pm_signal[num_enabled].cpu = cbe_cpu_to_node(cpu);
568 num_enabled++;
569 }
570 }
571
572 pm_rtas_activate_signals(cbe_cpu_to_node(cpu), num_enabled);
573out:
574 ;
575}
576
577static void cell_global_start(struct op_counter_config *ctr)
578{
579 u32 cpu;
580 u32 interrupt_mask = 0;
581 u32 i;
582
583 /* This routine gets called once for the system.
584 * There is one performance monitor per node, so we
585 * only need to perform this function once per node.
586 */
587 for_each_online_cpu(cpu) {
588 if (cbe_get_hw_thread_id(cpu))
589 continue;
590
591 interrupt_mask = 0;
592
593 for (i = 0; i < num_counters; ++i) {
594 if (ctr_enabled & (1 << i)) {
595 cbe_write_ctr(cpu, i, reset_value[i]);
596 enable_ctr(cpu, i, pm_regs.pm07_cntrl);
597 interrupt_mask |=
598 CBE_PM_CTR_OVERFLOW_INTR(i);
599 } else {
600 /* Disable counter */
601 cbe_write_pm07_control(cpu, i, 0);
602 }
603 }
604
605 cbe_clear_pm_interrupts(cpu);
606 cbe_enable_pm_interrupts(cpu, hdw_thread, interrupt_mask);
607 cbe_enable_pm(cpu);
608 }
609
610 virt_cntr_inter_mask = interrupt_mask;
611 oprofile_running = 1;
612 smp_wmb();
613
614 /* NOTE: start_virt_cntrs will result in cell_virtual_cntr() being
615 * executed which manipulates the PMU. We start the "virtual counter"
616 * here so that we do not need to synchronize access to the PMU in
617 * the above for-loop.
618 */
619 start_virt_cntrs();
620}
621
622static void cell_global_stop(void)
623{
624 int cpu;
625
626 /* This routine will be called once for the system.
627 * There is one performance monitor per node, so we
628 * only need to perform this function once per node.
629 */
630 del_timer_sync(&timer_virt_cntr);
631 oprofile_running = 0;
632 smp_wmb();
633
634 for_each_online_cpu(cpu) {
635 if (cbe_get_hw_thread_id(cpu))
636 continue;
637
638 cbe_sync_irq(cbe_cpu_to_node(cpu));
639 /* Stop the counters */
640 cbe_disable_pm(cpu);
641
642 /* Deactivate the signals */
643 pm_rtas_reset_signals(cbe_cpu_to_node(cpu));
644
645 /* Deactivate interrupts */
646 cbe_disable_pm_interrupts(cpu);
647 }
648}
649
650static void
651cell_handle_interrupt(struct pt_regs *regs, struct op_counter_config *ctr)
652{
653 u32 cpu;
654 u64 pc;
655 int is_kernel;
656 unsigned long flags = 0;
657 u32 interrupt_mask;
658 int i;
659
660 cpu = smp_processor_id();
661
662 /* Need to make sure the interrupt handler and the virt counter
663 * routine are not running at the same time. See the
664 * cell_virtual_cntr() routine for additional comments.
665 */
666 spin_lock_irqsave(&virt_cntr_lock, flags);
667
668 /* Need to disable and reenable the performance counters
669 * to get the desired behavior from the hardware. This
670 * is hardware specific.
671 */
672
673 cbe_disable_pm(cpu);
674
675 interrupt_mask = cbe_clear_pm_interrupts(cpu);
676
677 /* If the interrupt mask has been cleared, then the virt cntr
678 * has cleared the interrupt. When the thread that generated
679 * the interrupt is restored, the data count will be restored to
680 * 0xffffff0 to cause the interrupt to be regenerated.
681 */
682
683 if ((oprofile_running == 1) && (interrupt_mask != 0)) {
684 pc = regs->nip;
685 is_kernel = is_kernel_addr(pc);
686
687 for (i = 0; i < num_counters; ++i) {
688 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i))
689 && ctr[i].enabled) {
690 oprofile_add_pc(pc, is_kernel, i);
691 cbe_write_ctr(cpu, i, reset_value[i]);
692 }
693 }
694
695 /* The counters were frozen by the interrupt.
696 * Reenable the interrupt and restart the counters.
697 * If there was a race between the interrupt handler and
698 * the virtual counter routine. The virutal counter
699 * routine may have cleared the interrupts. Hence must
700 * use the virt_cntr_inter_mask to re-enable the interrupts.
701 */
702 cbe_enable_pm_interrupts(cpu, hdw_thread,
703 virt_cntr_inter_mask);
704
705 /* The writes to the various performance counters only writes
706 * to a latch. The new values (interrupt setting bits, reset
707 * counter value etc.) are not copied to the actual registers
708 * until the performance monitor is enabled. In order to get
709 * this to work as desired, the permormance monitor needs to
710 * be disabled while writting to the latches. This is a
711 * HW design issue.
712 */
713 cbe_enable_pm(cpu);
714 }
715 spin_unlock_irqrestore(&virt_cntr_lock, flags);
716}
717
718struct op_powerpc_model op_model_cell = {
719 .reg_setup = cell_reg_setup,
720 .cpu_setup = cell_cpu_setup,
721 .global_start = cell_global_start,
722 .global_stop = cell_global_stop,
723 .handle_interrupt = cell_handle_interrupt,
724};
diff --git a/arch/powerpc/platforms/52xx/Makefile b/arch/powerpc/platforms/52xx/Makefile
new file mode 100644
index 000000000000..a46184a0c750
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for 52xx based boards
3#
4ifeq ($(CONFIG_PPC_MERGE),y)
5obj-y += mpc52xx_pic.o mpc52xx_common.o
6endif
7
8obj-$(CONFIG_PPC_EFIKA) += efika-setup.o efika-pci.o
9obj-$(CONFIG_PPC_LITE5200) += lite5200.o
diff --git a/arch/powerpc/platforms/52xx/efika-pci.c b/arch/powerpc/platforms/52xx/efika-pci.c
new file mode 100644
index 000000000000..62e05b2a9227
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/efika-pci.c
@@ -0,0 +1,119 @@
1
2#include <linux/kernel.h>
3#include <linux/pci.h>
4#include <linux/string.h>
5#include <linux/init.h>
6
7#include <asm/io.h>
8#include <asm/irq.h>
9#include <asm/prom.h>
10#include <asm/machdep.h>
11#include <asm/sections.h>
12#include <asm/pci-bridge.h>
13#include <asm/rtas.h>
14
15#include "efika.h"
16
17#ifdef CONFIG_PCI
18/*
19 * Access functions for PCI config space using RTAS calls.
20 */
21static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
22 int len, u32 * val)
23{
24 struct pci_controller *hose = bus->sysdata;
25 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
26 | (((bus->number - hose->first_busno) & 0xff) << 16)
27 | (hose->index << 24);
28 int ret = -1;
29 int rval;
30
31 rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
32 *val = ret;
33 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
34}
35
36static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
37 int offset, int len, u32 val)
38{
39 struct pci_controller *hose = bus->sysdata;
40 unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
41 | (((bus->number - hose->first_busno) & 0xff) << 16)
42 | (hose->index << 24);
43 int rval;
44
45 rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
46 addr, len, val);
47 return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
48}
49
50static struct pci_ops rtas_pci_ops = {
51 rtas_read_config,
52 rtas_write_config
53};
54
55void __init efika_pcisetup(void)
56{
57 const int *bus_range;
58 int len;
59 struct pci_controller *hose;
60 struct device_node *root;
61 struct device_node *pcictrl;
62
63 root = of_find_node_by_path("/");
64 if (root == NULL) {
65 printk(KERN_WARNING EFIKA_PLATFORM_NAME
66 ": Unable to find the root node\n");
67 return;
68 }
69
70 for (pcictrl = NULL;;) {
71 pcictrl = of_get_next_child(root, pcictrl);
72 if ((pcictrl == NULL) || (strcmp(pcictrl->name, "pci") == 0))
73 break;
74 }
75
76 of_node_put(root);
77
78 if (pcictrl == NULL) {
79 printk(KERN_WARNING EFIKA_PLATFORM_NAME
80 ": Unable to find the PCI bridge node\n");
81 return;
82 }
83
84 bus_range = get_property(pcictrl, "bus-range", &len);
85 if (bus_range == NULL || len < 2 * sizeof(int)) {
86 printk(KERN_WARNING EFIKA_PLATFORM_NAME
87 ": Can't get bus-range for %s\n", pcictrl->full_name);
88 return;
89 }
90
91 if (bus_range[1] == bus_range[0])
92 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI bus %d",
93 bus_range[0]);
94 else
95 printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI buses %d..%d",
96 bus_range[0], bus_range[1]);
97 printk(" controlled by %s\n", pcictrl->full_name);
98 printk("\n");
99
100 hose = pcibios_alloc_controller();
101 if (!hose) {
102 printk(KERN_WARNING EFIKA_PLATFORM_NAME
103 ": Can't allocate PCI controller structure for %s\n",
104 pcictrl->full_name);
105 return;
106 }
107
108 hose->arch_data = of_node_get(pcictrl);
109 hose->first_busno = bus_range[0];
110 hose->last_busno = bus_range[1];
111 hose->ops = &rtas_pci_ops;
112
113 pci_process_bridge_OF_ranges(hose, pcictrl, 0);
114}
115
116#else
117void __init efika_pcisetup(void)
118{}
119#endif
diff --git a/arch/powerpc/platforms/52xx/efika-setup.c b/arch/powerpc/platforms/52xx/efika-setup.c
new file mode 100644
index 000000000000..110c980ed1e0
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/efika-setup.c
@@ -0,0 +1,150 @@
1/*
2 *
3 * Efika 5K2 platform setup
4 * Some code really inspired from the lite5200b platform.
5 *
6 * Copyright (C) 2006 bplan GmbH
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 *
12 */
13
14#include <linux/errno.h>
15#include <linux/kernel.h>
16#include <linux/slab.h>
17#include <linux/reboot.h>
18#include <linux/init.h>
19#include <linux/utsrelease.h>
20#include <linux/seq_file.h>
21#include <linux/root_dev.h>
22#include <linux/initrd.h>
23#include <linux/timer.h>
24#include <linux/pci.h>
25
26#include <asm/pgtable.h>
27#include <asm/prom.h>
28#include <asm/time.h>
29#include <asm/machdep.h>
30#include <asm/rtas.h>
31#include <asm/of_device.h>
32#include <asm/of_platform.h>
33#include <asm/mpc52xx.h>
34
35#include "efika.h"
36
37static void efika_show_cpuinfo(struct seq_file *m)
38{
39 struct device_node *root;
40 const char *revision = NULL;
41 const char *codegendescription = NULL;
42 const char *codegenvendor = NULL;
43
44 root = of_find_node_by_path("/");
45 if (root) {
46 revision = get_property(root, "revision", NULL);
47 codegendescription =
48 get_property(root, "CODEGEN,description", NULL);
49 codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
50
51 of_node_put(root);
52 }
53
54 if (codegendescription)
55 seq_printf(m, "machine\t\t: %s\n", codegendescription);
56 else
57 seq_printf(m, "machine\t\t: Efika\n");
58
59 if (revision)
60 seq_printf(m, "revision\t: %s\n", revision);
61
62 if (codegenvendor)
63 seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
64
65 of_node_put(root);
66}
67
68static void __init efika_setup_arch(void)
69{
70 rtas_initialize();
71
72#ifdef CONFIG_BLK_DEV_INITRD
73 initrd_below_start_ok = 1;
74
75 if (initrd_start)
76 ROOT_DEV = Root_RAM0;
77 else
78#endif
79 ROOT_DEV = Root_SDA2; /* sda2 (sda1 is for the kernel) */
80
81 efika_pcisetup();
82
83 if (ppc_md.progress)
84 ppc_md.progress("Linux/PPC " UTS_RELEASE " runnung on Efika ;-)\n", 0x0);
85}
86
87static void __init efika_init(void)
88{
89 struct device_node *np;
90 struct device_node *cnp = NULL;
91 const u32 *base;
92
93 /* Find every child of the SOC node and add it to of_platform */
94 np = of_find_node_by_name(NULL, "builtin");
95 if (np) {
96 char name[BUS_ID_SIZE];
97 while ((cnp = of_get_next_child(np, cnp))) {
98 strcpy(name, cnp->name);
99
100 base = get_property(cnp, "reg", NULL);
101 if (base == NULL)
102 continue;
103
104 snprintf(name+strlen(name), BUS_ID_SIZE, "@%x", *base);
105 of_platform_device_create(cnp, name, NULL);
106
107 printk(KERN_INFO EFIKA_PLATFORM_NAME" : Added %s (type '%s' at '%s') to the known devices\n", name, cnp->type, cnp->full_name);
108 }
109 }
110
111 if (ppc_md.progress)
112 ppc_md.progress(" Have fun with your Efika! ", 0x7777);
113}
114
115static int __init efika_probe(void)
116{
117 char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
118 "model", NULL);
119
120 if (model == NULL)
121 return 0;
122 if (strcmp(model, "EFIKA5K2"))
123 return 0;
124
125 ISA_DMA_THRESHOLD = ~0L;
126 DMA_MODE_READ = 0x44;
127 DMA_MODE_WRITE = 0x48;
128
129 return 1;
130}
131
132define_machine(efika)
133{
134 .name = EFIKA_PLATFORM_NAME,
135 .probe = efika_probe,
136 .setup_arch = efika_setup_arch,
137 .init = efika_init,
138 .show_cpuinfo = efika_show_cpuinfo,
139 .init_IRQ = mpc52xx_init_irq,
140 .get_irq = mpc52xx_get_irq,
141 .restart = rtas_restart,
142 .power_off = rtas_power_off,
143 .halt = rtas_halt,
144 .set_rtc_time = rtas_set_rtc_time,
145 .get_rtc_time = rtas_get_rtc_time,
146 .progress = rtas_progress,
147 .get_boot_time = rtas_get_boot_time,
148 .calibrate_decr = generic_calibrate_decr,
149 .phys_mem_access_prot = pci_phys_mem_access_prot,
150};
diff --git a/arch/powerpc/platforms/52xx/efika.h b/arch/powerpc/platforms/52xx/efika.h
new file mode 100644
index 000000000000..2f060fd097d7
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/efika.h
@@ -0,0 +1,19 @@
1/*
2 * Efika 5K2 platform setup - Header file
3 *
4 * Copyright (C) 2006 bplan GmbH
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 *
10 */
11
12#ifndef __ARCH_POWERPC_EFIKA__
13#define __ARCH_POWERPC_EFIKA__
14
15#define EFIKA_PLATFORM_NAME "Efika"
16
17extern void __init efika_pcisetup(void);
18
19#endif
diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c
new file mode 100644
index 000000000000..a375c15b4315
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/lite5200.c
@@ -0,0 +1,162 @@
1/*
2 * Freescale Lite5200 board support
3 *
4 * Written by: Grant Likely <grant.likely@secretlab.ca>
5 *
6 * Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.
7 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
8 *
9 * Description:
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#undef DEBUG
17
18#include <linux/stddef.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/errno.h>
22#include <linux/reboot.h>
23#include <linux/pci.h>
24#include <linux/kdev_t.h>
25#include <linux/major.h>
26#include <linux/console.h>
27#include <linux/delay.h>
28#include <linux/seq_file.h>
29#include <linux/root_dev.h>
30#include <linux/initrd.h>
31
32#include <asm/system.h>
33#include <asm/atomic.h>
34#include <asm/time.h>
35#include <asm/io.h>
36#include <asm/machdep.h>
37#include <asm/ipic.h>
38#include <asm/bootinfo.h>
39#include <asm/irq.h>
40#include <asm/prom.h>
41#include <asm/udbg.h>
42#include <sysdev/fsl_soc.h>
43#include <asm/qe.h>
44#include <asm/qe_ic.h>
45#include <asm/of_platform.h>
46
47#include <asm/mpc52xx.h>
48
49/* ************************************************************************
50 *
51 * Setup the architecture
52 *
53 */
54
55static void __init
56lite52xx_setup_cpu(void)
57{
58 struct mpc52xx_gpio __iomem *gpio;
59 u32 port_config;
60
61 /* Map zones */
62 gpio = mpc52xx_find_and_map("mpc52xx-gpio");
63 if (!gpio) {
64 printk(KERN_ERR __FILE__ ": "
65 "Error while mapping GPIO register for port config. "
66 "Expect some abnormal behavior\n");
67 goto error;
68 }
69
70 /* Set port config */
71 port_config = in_be32(&gpio->port_config);
72
73 port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
74
75 port_config &= ~0x00007000; /* USB port : Differential mode */
76 port_config |= 0x00001000; /* USB 1 only */
77
78 port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
79 port_config |= 0x01000000;
80
81 pr_debug("port_config: old:%x new:%x\n",
82 in_be32(&gpio->port_config), port_config);
83 out_be32(&gpio->port_config, port_config);
84
85 /* Unmap zone */
86error:
87 iounmap(gpio);
88}
89
90static void __init lite52xx_setup_arch(void)
91{
92 struct device_node *np;
93
94 if (ppc_md.progress)
95 ppc_md.progress("lite52xx_setup_arch()", 0);
96
97 np = of_find_node_by_type(NULL, "cpu");
98 if (np) {
99 unsigned int *fp =
100 (int *)get_property(np, "clock-frequency", NULL);
101 if (fp != 0)
102 loops_per_jiffy = *fp / HZ;
103 else
104 loops_per_jiffy = 50000000 / HZ;
105 of_node_put(np);
106 }
107
108 /* CPU & Port mux setup */
109 mpc52xx_setup_cpu(); /* Generic */
110 lite52xx_setup_cpu(); /* Platorm specific */
111
112#ifdef CONFIG_BLK_DEV_INITRD
113 if (initrd_start)
114 ROOT_DEV = Root_RAM0;
115 else
116#endif
117#ifdef CONFIG_ROOT_NFS
118 ROOT_DEV = Root_NFS;
119#else
120 ROOT_DEV = Root_HDA1;
121#endif
122
123}
124
125void lite52xx_show_cpuinfo(struct seq_file *m)
126{
127 struct device_node* np = of_find_all_nodes(NULL);
128 const char *model = NULL;
129
130 if (np)
131 model = get_property(np, "model", NULL);
132
133 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
134 seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
135
136 of_node_put(np);
137}
138
139/*
140 * Called very early, MMU is off, device-tree isn't unflattened
141 */
142static int __init lite52xx_probe(void)
143{
144 unsigned long node = of_get_flat_dt_root();
145 const char *model = of_get_flat_dt_prop(node, "model", NULL);
146
147 if (!of_flat_dt_is_compatible(node, "lite52xx"))
148 return 0;
149 pr_debug("%s board w/ mpc52xx found\n", model ? model : "unknown");
150
151 return 1;
152}
153
154define_machine(lite52xx) {
155 .name = "lite52xx",
156 .probe = lite52xx_probe,
157 .setup_arch = lite52xx_setup_arch,
158 .init_IRQ = mpc52xx_init_irq,
159 .get_irq = mpc52xx_get_irq,
160 .show_cpuinfo = lite52xx_show_cpuinfo,
161 .calibrate_decr = generic_calibrate_decr,
162};
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
new file mode 100644
index 000000000000..8331ff457770
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -0,0 +1,126 @@
1/*
2 *
3 * Utility functions for the Freescale MPC52xx.
4 *
5 * Copyright (C) 2006 Sylvain Munaut <tnt@246tNt.com>
6 *
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
10 *
11 */
12
13#undef DEBUG
14
15#include <linux/kernel.h>
16
17#include <asm/io.h>
18#include <asm/prom.h>
19#include <asm/of_platform.h>
20#include <asm/mpc52xx.h>
21
22
23void __iomem *
24mpc52xx_find_and_map(const char *compatible)
25{
26 struct device_node *ofn;
27 const u32 *regaddr_p;
28 u64 regaddr64, size64;
29
30 ofn = of_find_compatible_node(NULL, NULL, compatible);
31 if (!ofn)
32 return NULL;
33
34 regaddr_p = of_get_address(ofn, 0, &size64, NULL);
35 if (!regaddr_p) {
36 of_node_put(ofn);
37 return NULL;
38 }
39
40 regaddr64 = of_translate_address(ofn, regaddr_p);
41
42 of_node_put(ofn);
43
44 return ioremap((u32)regaddr64, (u32)size64);
45}
46EXPORT_SYMBOL(mpc52xx_find_and_map);
47
48
49/**
50 * mpc52xx_find_ipb_freq - Find the IPB bus frequency for a device
51 * @node: device node
52 *
53 * Returns IPB bus frequency, or 0 if the bus frequency cannot be found.
54 */
55unsigned int
56mpc52xx_find_ipb_freq(struct device_node *node)
57{
58 struct device_node *np;
59 const unsigned int *p_ipb_freq = NULL;
60
61 of_node_get(node);
62 while (node) {
63 p_ipb_freq = get_property(node, "bus-frequency", NULL);
64 if (p_ipb_freq)
65 break;
66
67 np = of_get_parent(node);
68 of_node_put(node);
69 node = np;
70 }
71 if (node)
72 of_node_put(node);
73
74 return p_ipb_freq ? *p_ipb_freq : 0;
75}
76EXPORT_SYMBOL(mpc52xx_find_ipb_freq);
77
78
79void __init
80mpc52xx_setup_cpu(void)
81{
82 struct mpc52xx_cdm __iomem *cdm;
83 struct mpc52xx_xlb __iomem *xlb;
84
85 /* Map zones */
86 cdm = mpc52xx_find_and_map("mpc52xx-cdm");
87 xlb = mpc52xx_find_and_map("mpc52xx-xlb");
88
89 if (!cdm || !xlb) {
90 printk(KERN_ERR __FILE__ ": "
91 "Error while mapping CDM/XLB during mpc52xx_setup_cpu. "
92 "Expect some abnormal behavior\n");
93 goto unmap_regs;
94 }
95
96 /* Use internal 48 Mhz */
97 out_8(&cdm->ext_48mhz_en, 0x00);
98 out_8(&cdm->fd_enable, 0x01);
99 if (in_be32(&cdm->rstcfg) & 0x40) /* Assumes 33Mhz clock */
100 out_be16(&cdm->fd_counters, 0x0001);
101 else
102 out_be16(&cdm->fd_counters, 0x5555);
103
104 /* Configure the XLB Arbiter priorities */
105 out_be32(&xlb->master_pri_enable, 0xff);
106 out_be32(&xlb->master_priority, 0x11111111);
107
108 /* Disable XLB pipelining */
109 /* (cfr errate 292. We could do this only just before ATA PIO
110 transaction and re-enable it afterwards ...) */
111 out_be32(&xlb->config, in_be32(&xlb->config) | MPC52xx_XLB_CFG_PLDIS);
112
113 /* Unmap zones */
114unmap_regs:
115 if (cdm) iounmap(cdm);
116 if (xlb) iounmap(xlb);
117}
118
119static int __init
120mpc52xx_declare_of_platform_devices(void)
121{
122 /* Find every child of the SOC node and add it to of_platform */
123 return of_platform_bus_probe(NULL, NULL, NULL);
124}
125
126device_initcall(mpc52xx_declare_of_platform_devices);
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
new file mode 100644
index 000000000000..cd91a6c3aafa
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -0,0 +1,473 @@
1/*
2 *
3 * Programmable Interrupt Controller functions for the Freescale MPC52xx.
4 *
5 * Copyright (C) 2006 bplan GmbH
6 *
7 * Based on the code from the 2.4 kernel by
8 * Dale Farnsworth <dfarnsworth@mvista.com> and Kent Borg.
9 *
10 * Copyright (C) 2004 Sylvain Munaut <tnt@246tNt.com>
11 * Copyright (C) 2003 Montavista Software, Inc
12 *
13 * This file is licensed under the terms of the GNU General Public License
14 * version 2. This program is licensed "as is" without any warranty of any
15 * kind, whether express or implied.
16 *
17 */
18
19#undef DEBUG
20
21#include <linux/stddef.h>
22#include <linux/init.h>
23#include <linux/sched.h>
24#include <linux/signal.h>
25#include <linux/stddef.h>
26#include <linux/delay.h>
27#include <linux/irq.h>
28#include <linux/hardirq.h>
29
30#include <asm/io.h>
31#include <asm/processor.h>
32#include <asm/system.h>
33#include <asm/irq.h>
34#include <asm/prom.h>
35#include <asm/mpc52xx.h>
36#include "mpc52xx_pic.h"
37
38/*
39 *
40*/
41
42static struct mpc52xx_intr __iomem *intr;
43static struct mpc52xx_sdma __iomem *sdma;
44static struct irq_host *mpc52xx_irqhost = NULL;
45
46static unsigned char mpc52xx_map_senses[4] = {
47 IRQ_TYPE_LEVEL_HIGH,
48 IRQ_TYPE_EDGE_RISING,
49 IRQ_TYPE_EDGE_FALLING,
50 IRQ_TYPE_LEVEL_LOW,
51};
52
53/*
54 *
55*/
56
57static inline void io_be_setbit(u32 __iomem *addr, int bitno)
58{
59 out_be32(addr, in_be32(addr) | (1 << bitno));
60}
61
62static inline void io_be_clrbit(u32 __iomem *addr, int bitno)
63{
64 out_be32(addr, in_be32(addr) & ~(1 << bitno));
65}
66
67/*
68 * IRQ[0-3] interrupt irq_chip
69*/
70
71static void mpc52xx_extirq_mask(unsigned int virq)
72{
73 int irq;
74 int l2irq;
75
76 irq = irq_map[virq].hwirq;
77 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
78
79 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
80
81 io_be_clrbit(&intr->ctrl, 11 - l2irq);
82}
83
84static void mpc52xx_extirq_unmask(unsigned int virq)
85{
86 int irq;
87 int l2irq;
88
89 irq = irq_map[virq].hwirq;
90 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
91
92 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
93
94 io_be_setbit(&intr->ctrl, 11 - l2irq);
95}
96
97static void mpc52xx_extirq_ack(unsigned int virq)
98{
99 int irq;
100 int l2irq;
101
102 irq = irq_map[virq].hwirq;
103 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
104
105 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
106
107 io_be_setbit(&intr->ctrl, 27-l2irq);
108}
109
110static struct irq_chip mpc52xx_extirq_irqchip = {
111 .typename = " MPC52xx IRQ[0-3] ",
112 .mask = mpc52xx_extirq_mask,
113 .unmask = mpc52xx_extirq_unmask,
114 .ack = mpc52xx_extirq_ack,
115};
116
117/*
118 * Main interrupt irq_chip
119*/
120
121static void mpc52xx_main_mask(unsigned int virq)
122{
123 int irq;
124 int l2irq;
125
126 irq = irq_map[virq].hwirq;
127 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
128
129 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
130
131 io_be_setbit(&intr->main_mask, 15 - l2irq);
132}
133
134static void mpc52xx_main_unmask(unsigned int virq)
135{
136 int irq;
137 int l2irq;
138
139 irq = irq_map[virq].hwirq;
140 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
141
142 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
143
144 io_be_clrbit(&intr->main_mask, 15 - l2irq);
145}
146
147static struct irq_chip mpc52xx_main_irqchip = {
148 .typename = "MPC52xx Main",
149 .mask = mpc52xx_main_mask,
150 .mask_ack = mpc52xx_main_mask,
151 .unmask = mpc52xx_main_unmask,
152};
153
154/*
155 * Peripherals interrupt irq_chip
156*/
157
158static void mpc52xx_periph_mask(unsigned int virq)
159{
160 int irq;
161 int l2irq;
162
163 irq = irq_map[virq].hwirq;
164 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
165
166 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
167
168 io_be_setbit(&intr->per_mask, 31 - l2irq);
169}
170
171static void mpc52xx_periph_unmask(unsigned int virq)
172{
173 int irq;
174 int l2irq;
175
176 irq = irq_map[virq].hwirq;
177 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
178
179 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
180
181 io_be_clrbit(&intr->per_mask, 31 - l2irq);
182}
183
184static struct irq_chip mpc52xx_periph_irqchip = {
185 .typename = "MPC52xx Peripherals",
186 .mask = mpc52xx_periph_mask,
187 .mask_ack = mpc52xx_periph_mask,
188 .unmask = mpc52xx_periph_unmask,
189};
190
191/*
192 * SDMA interrupt irq_chip
193*/
194
195static void mpc52xx_sdma_mask(unsigned int virq)
196{
197 int irq;
198 int l2irq;
199
200 irq = irq_map[virq].hwirq;
201 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
202
203 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
204
205 io_be_setbit(&sdma->IntMask, l2irq);
206}
207
208static void mpc52xx_sdma_unmask(unsigned int virq)
209{
210 int irq;
211 int l2irq;
212
213 irq = irq_map[virq].hwirq;
214 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
215
216 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
217
218 io_be_clrbit(&sdma->IntMask, l2irq);
219}
220
221static void mpc52xx_sdma_ack(unsigned int virq)
222{
223 int irq;
224 int l2irq;
225
226 irq = irq_map[virq].hwirq;
227 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
228
229 pr_debug("%s: irq=%x. l2=%d\n", __func__, irq, l2irq);
230
231 out_be32(&sdma->IntPend, 1 << l2irq);
232}
233
234static struct irq_chip mpc52xx_sdma_irqchip = {
235 .typename = "MPC52xx SDMA",
236 .mask = mpc52xx_sdma_mask,
237 .unmask = mpc52xx_sdma_unmask,
238 .ack = mpc52xx_sdma_ack,
239};
240
241/*
242 * irq_host
243*/
244
245static int mpc52xx_irqhost_match(struct irq_host *h, struct device_node *node)
246{
247 pr_debug("%s: node=%p\n", __func__, node);
248 return mpc52xx_irqhost->host_data == node;
249}
250
251static int mpc52xx_irqhost_xlate(struct irq_host *h, struct device_node *ct,
252 u32 * intspec, unsigned int intsize,
253 irq_hw_number_t * out_hwirq,
254 unsigned int *out_flags)
255{
256 int intrvect_l1;
257 int intrvect_l2;
258 int intrvect_type;
259 int intrvect_linux;
260
261 if (intsize != 3)
262 return -1;
263
264 intrvect_l1 = (int)intspec[0];
265 intrvect_l2 = (int)intspec[1];
266 intrvect_type = (int)intspec[2];
267
268 intrvect_linux =
269 (intrvect_l1 << MPC52xx_IRQ_L1_OFFSET) & MPC52xx_IRQ_L1_MASK;
270 intrvect_linux |=
271 (intrvect_l2 << MPC52xx_IRQ_L2_OFFSET) & MPC52xx_IRQ_L2_MASK;
272
273 pr_debug("return %x, l1=%d, l2=%d\n", intrvect_linux, intrvect_l1,
274 intrvect_l2);
275
276 *out_hwirq = intrvect_linux;
277 *out_flags = mpc52xx_map_senses[intrvect_type];
278
279 return 0;
280}
281
282/*
283 * this function retrieves the correct IRQ type out
284 * of the MPC regs
285 * Only externals IRQs needs this
286*/
287static int mpc52xx_irqx_gettype(int irq)
288{
289 int type;
290 u32 ctrl_reg;
291
292 ctrl_reg = in_be32(&intr->ctrl);
293 type = (ctrl_reg >> (22 - irq * 2)) & 0x3;
294
295 return mpc52xx_map_senses[type];
296}
297
298static int mpc52xx_irqhost_map(struct irq_host *h, unsigned int virq,
299 irq_hw_number_t irq)
300{
301 int l1irq;
302 int l2irq;
303 struct irq_chip *good_irqchip;
304 void *good_handle;
305 int type;
306
307 l1irq = (irq & MPC52xx_IRQ_L1_MASK) >> MPC52xx_IRQ_L1_OFFSET;
308 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
309
310 /*
311 * Most of ours IRQs will be level low
312 * Only external IRQs on some platform may be others
313 */
314 type = IRQ_TYPE_LEVEL_LOW;
315
316 switch (l1irq) {
317 case MPC52xx_IRQ_L1_CRIT:
318 pr_debug("%s: Critical. l2=%x\n", __func__, l2irq);
319
320 BUG_ON(l2irq != 0);
321
322 type = mpc52xx_irqx_gettype(l2irq);
323 good_irqchip = &mpc52xx_extirq_irqchip;
324 break;
325
326 case MPC52xx_IRQ_L1_MAIN:
327 pr_debug("%s: Main IRQ[1-3] l2=%x\n", __func__, l2irq);
328
329 if ((l2irq >= 1) && (l2irq <= 3)) {
330 type = mpc52xx_irqx_gettype(l2irq);
331 good_irqchip = &mpc52xx_extirq_irqchip;
332 } else {
333 good_irqchip = &mpc52xx_main_irqchip;
334 }
335 break;
336
337 case MPC52xx_IRQ_L1_PERP:
338 pr_debug("%s: Peripherals. l2=%x\n", __func__, l2irq);
339 good_irqchip = &mpc52xx_periph_irqchip;
340 break;
341
342 case MPC52xx_IRQ_L1_SDMA:
343 pr_debug("%s: SDMA. l2=%x\n", __func__, l2irq);
344 good_irqchip = &mpc52xx_sdma_irqchip;
345 break;
346
347 default:
348 pr_debug("%s: Error, unknown L1 IRQ (0x%x)\n", __func__, l1irq);
349 printk(KERN_ERR "Unknow IRQ!\n");
350 return -EINVAL;
351 }
352
353 switch (type) {
354 case IRQ_TYPE_EDGE_FALLING:
355 case IRQ_TYPE_EDGE_RISING:
356 good_handle = handle_edge_irq;
357 break;
358 default:
359 good_handle = handle_level_irq;
360 }
361
362 set_irq_chip_and_handler(virq, good_irqchip, good_handle);
363
364 pr_debug("%s: virq=%x, hw=%x. type=%x\n", __func__, virq,
365 (int)irq, type);
366
367 return 0;
368}
369
370static struct irq_host_ops mpc52xx_irqhost_ops = {
371 .match = mpc52xx_irqhost_match,
372 .xlate = mpc52xx_irqhost_xlate,
373 .map = mpc52xx_irqhost_map,
374};
375
376/*
377 * init (public)
378*/
379
380void __init mpc52xx_init_irq(void)
381{
382 u32 intr_ctrl;
383 struct device_node *picnode;
384
385 /* Remap the necessary zones */
386 picnode = of_find_compatible_node(NULL, NULL, "mpc52xx-pic");
387
388 intr = mpc52xx_find_and_map("mpc52xx-pic");
389 if (!intr)
390 panic(__FILE__ ": find_and_map failed on 'mpc52xx-pic'. "
391 "Check node !");
392
393 sdma = mpc52xx_find_and_map("mpc52xx-bestcomm");
394 if (!sdma)
395 panic(__FILE__ ": find_and_map failed on 'mpc52xx-bestcomm'. "
396 "Check node !");
397
398 /* Disable all interrupt sources. */
399 out_be32(&sdma->IntPend, 0xffffffff); /* 1 means clear pending */
400 out_be32(&sdma->IntMask, 0xffffffff); /* 1 means disabled */
401 out_be32(&intr->per_mask, 0x7ffffc00); /* 1 means disabled */
402 out_be32(&intr->main_mask, 0x00010fff); /* 1 means disabled */
403 intr_ctrl = in_be32(&intr->ctrl);
404 intr_ctrl &= 0x00ff0000; /* Keeps IRQ[0-3] config */
405 intr_ctrl |= 0x0f000000 | /* clear IRQ 0-3 */
406 0x00001000 | /* MEE master external enable */
407 0x00000000 | /* 0 means disable IRQ 0-3 */
408 0x00000001; /* CEb route critical normally */
409 out_be32(&intr->ctrl, intr_ctrl);
410
411 /* Zero a bunch of the priority settings. */
412 out_be32(&intr->per_pri1, 0);
413 out_be32(&intr->per_pri2, 0);
414 out_be32(&intr->per_pri3, 0);
415 out_be32(&intr->main_pri1, 0);
416 out_be32(&intr->main_pri2, 0);
417
418 /*
419 * As last step, add an irq host to translate the real
420 * hw irq information provided by the ofw to linux virq
421 */
422
423 mpc52xx_irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR,
424 MPC52xx_IRQ_HIGHTESTHWIRQ,
425 &mpc52xx_irqhost_ops, -1);
426
427 if (!mpc52xx_irqhost)
428 panic(__FILE__ ": Cannot allocate the IRQ host\n");
429
430 mpc52xx_irqhost->host_data = picnode;
431 printk(KERN_INFO "MPC52xx PIC is up and running!\n");
432}
433
434/*
435 * get_irq (public)
436*/
437unsigned int mpc52xx_get_irq(void)
438{
439 u32 status;
440 int irq = NO_IRQ_IGNORE;
441
442 status = in_be32(&intr->enc_status);
443 if (status & 0x00000400) { /* critical */
444 irq = (status >> 8) & 0x3;
445 if (irq == 2) /* high priority peripheral */
446 goto peripheral;
447 irq |= (MPC52xx_IRQ_L1_CRIT << MPC52xx_IRQ_L1_OFFSET) &
448 MPC52xx_IRQ_L1_MASK;
449 } else if (status & 0x00200000) { /* main */
450 irq = (status >> 16) & 0x1f;
451 if (irq == 4) /* low priority peripheral */
452 goto peripheral;
453 irq |= (MPC52xx_IRQ_L1_MAIN << MPC52xx_IRQ_L1_OFFSET) &
454 MPC52xx_IRQ_L1_MASK;
455 } else if (status & 0x20000000) { /* peripheral */
456 peripheral:
457 irq = (status >> 24) & 0x1f;
458 if (irq == 0) { /* bestcomm */
459 status = in_be32(&sdma->IntPend);
460 irq = ffs(status) - 1;
461 irq |= (MPC52xx_IRQ_L1_SDMA << MPC52xx_IRQ_L1_OFFSET) &
462 MPC52xx_IRQ_L1_MASK;
463 } else {
464 irq |= (MPC52xx_IRQ_L1_PERP << MPC52xx_IRQ_L1_OFFSET) &
465 MPC52xx_IRQ_L1_MASK;
466 }
467 }
468
469 pr_debug("%s: irq=%x. virq=%d\n", __func__, irq,
470 irq_linear_revmap(mpc52xx_irqhost, irq));
471
472 return irq_linear_revmap(mpc52xx_irqhost, irq);
473}
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.h b/arch/powerpc/platforms/52xx/mpc52xx_pic.h
new file mode 100644
index 000000000000..1a26bcdb3049
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.h
@@ -0,0 +1,53 @@
1/*
2 * Header file for Freescale MPC52xx Interrupt controller
3 *
4 * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com>
5 * Copyright (C) 2003 MontaVista, Software, Inc.
6 *
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.
10 */
11
12#ifndef __POWERPC_SYSDEV_MPC52xx_PIC_H__
13#define __POWERPC_SYSDEV_MPC52xx_PIC_H__
14
15#include <asm/types.h>
16
17
18/* HW IRQ mapping */
19#define MPC52xx_IRQ_L1_CRIT (0)
20#define MPC52xx_IRQ_L1_MAIN (1)
21#define MPC52xx_IRQ_L1_PERP (2)
22#define MPC52xx_IRQ_L1_SDMA (3)
23
24#define MPC52xx_IRQ_L1_OFFSET (6)
25#define MPC52xx_IRQ_L1_MASK (0x00c0)
26
27#define MPC52xx_IRQ_L2_OFFSET (0)
28#define MPC52xx_IRQ_L2_MASK (0x003f)
29
30#define MPC52xx_IRQ_HIGHTESTHWIRQ (0xd0)
31
32
33/* Interrupt controller Register set */
34struct mpc52xx_intr {
35 u32 per_mask; /* INTR + 0x00 */
36 u32 per_pri1; /* INTR + 0x04 */
37 u32 per_pri2; /* INTR + 0x08 */
38 u32 per_pri3; /* INTR + 0x0c */
39 u32 ctrl; /* INTR + 0x10 */
40 u32 main_mask; /* INTR + 0x14 */
41 u32 main_pri1; /* INTR + 0x18 */
42 u32 main_pri2; /* INTR + 0x1c */
43 u32 reserved1; /* INTR + 0x20 */
44 u32 enc_status; /* INTR + 0x24 */
45 u32 crit_status; /* INTR + 0x28 */
46 u32 main_status; /* INTR + 0x2c */
47 u32 per_status; /* INTR + 0x30 */
48 u32 reserved2; /* INTR + 0x34 */
49 u32 per_error; /* INTR + 0x38 */
50};
51
52#endif /* __POWERPC_SYSDEV_MPC52xx_PIC_H__ */
53
diff --git a/arch/powerpc/platforms/82xx/mpc82xx_ads.c b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
index bb9acbb98176..ea880f1f0dcd 100644
--- a/arch/powerpc/platforms/82xx/mpc82xx_ads.c
+++ b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
@@ -515,16 +515,6 @@ static int m82xx_pci_exclude_device(u_char bus, u_char devfn)
515 return PCIBIOS_SUCCESSFUL; 515 return PCIBIOS_SUCCESSFUL;
516} 516}
517 517
518static void
519__init mpc82xx_pcibios_fixup(void)
520{
521 struct pci_dev *dev = NULL;
522
523 for_each_pci_dev(dev) {
524 pci_read_irq_line(dev);
525 }
526}
527
528void __init add_bridge(struct device_node *np) 518void __init add_bridge(struct device_node *np)
529{ 519{
530 int len; 520 int len;
@@ -597,9 +587,6 @@ static void __init mpc82xx_ads_setup_arch(void)
597 add_bridge(np); 587 add_bridge(np);
598 588
599 of_node_put(np); 589 of_node_put(np);
600 ppc_md.pci_map_irq = NULL;
601 ppc_md.pcibios_fixup = mpc82xx_pcibios_fixup;
602 ppc_md.pcibios_fixup_bus = NULL;
603#endif 590#endif
604 591
605#ifdef CONFIG_ROOT_NFS 592#ifdef CONFIG_ROOT_NFS
diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c
index a43ac71ab740..f58c9780b66f 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c
@@ -97,8 +97,6 @@ static void __init mpc832x_sys_setup_arch(void)
97#ifdef CONFIG_PCI 97#ifdef CONFIG_PCI
98 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 98 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
99 add_bridge(np); 99 add_bridge(np);
100
101 ppc_md.pci_swizzle = common_swizzle;
102 ppc_md.pci_exclude_device = mpc83xx_exclude_device; 100 ppc_md.pci_exclude_device = mpc83xx_exclude_device;
103#endif 101#endif
104 102
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c
index e2bcaaf6b329..314c42ac6048 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c
@@ -118,7 +118,4 @@ define_machine(mpc834x_itx) {
118 .time_init = mpc83xx_time_init, 118 .time_init = mpc83xx_time_init,
119 .calibrate_decr = generic_calibrate_decr, 119 .calibrate_decr = generic_calibrate_decr,
120 .progress = udbg_progress, 120 .progress = udbg_progress,
121#ifdef CONFIG_PCI
122 .pcibios_fixup = mpc83xx_pcibios_fixup,
123#endif
124}; 121};
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c
index 677196187a4e..80b735a414d9 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
@@ -137,7 +137,4 @@ define_machine(mpc834x_sys) {
137 .time_init = mpc83xx_time_init, 137 .time_init = mpc83xx_time_init,
138 .calibrate_decr = generic_calibrate_decr, 138 .calibrate_decr = generic_calibrate_decr,
139 .progress = udbg_progress, 139 .progress = udbg_progress,
140#ifdef CONFIG_PCI
141 .pcibios_fixup = mpc83xx_pcibios_fixup,
142#endif
143}; 140};
diff --git a/arch/powerpc/platforms/83xx/mpc8360e_pb.c b/arch/powerpc/platforms/83xx/mpc8360e_pb.c
index 1a523c81c06e..7bfd47ad7233 100644
--- a/arch/powerpc/platforms/83xx/mpc8360e_pb.c
+++ b/arch/powerpc/platforms/83xx/mpc8360e_pb.c
@@ -102,8 +102,6 @@ static void __init mpc8360_sys_setup_arch(void)
102#ifdef CONFIG_PCI 102#ifdef CONFIG_PCI
103 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 103 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
104 add_bridge(np); 104 add_bridge(np);
105
106 ppc_md.pci_swizzle = common_swizzle;
107 ppc_md.pci_exclude_device = mpc83xx_exclude_device; 105 ppc_md.pci_exclude_device = mpc83xx_exclude_device;
108#endif 106#endif
109 107
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index 2c82bca9bfbb..01cae106912b 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -11,7 +11,6 @@
11 11
12extern int add_bridge(struct device_node *dev); 12extern int add_bridge(struct device_node *dev);
13extern int mpc83xx_exclude_device(u_char bus, u_char devfn); 13extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
14extern void mpc83xx_pcibios_fixup(void);
15extern void mpc83xx_restart(char *cmd); 14extern void mpc83xx_restart(char *cmd);
16extern long mpc83xx_time_init(void); 15extern long mpc83xx_time_init(void);
17 16
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 4557ac5255c1..9c3650555144 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -45,15 +45,6 @@ int mpc83xx_exclude_device(u_char bus, u_char devfn)
45 return PCIBIOS_SUCCESSFUL; 45 return PCIBIOS_SUCCESSFUL;
46} 46}
47 47
48void __init mpc83xx_pcibios_fixup(void)
49{
50 struct pci_dev *dev = NULL;
51
52 /* map all the PCI irqs */
53 for_each_pci_dev(dev)
54 pci_read_irq_line(dev);
55}
56
57int __init add_bridge(struct device_node *dev) 48int __init add_bridge(struct device_node *dev)
58{ 49{
59 int len; 50 int len;
diff --git a/arch/powerpc/platforms/85xx/misc.c b/arch/powerpc/platforms/85xx/misc.c
index 26c5e822c7c8..3e62fcb04c1c 100644
--- a/arch/powerpc/platforms/85xx/misc.c
+++ b/arch/powerpc/platforms/85xx/misc.c
@@ -21,11 +21,3 @@ void mpc85xx_restart(char *cmd)
21 local_irq_disable(); 21 local_irq_disable();
22 abort(); 22 abort();
23} 23}
24
25/* For now this is a pass through */
26phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
27{
28 return addr;
29};
30
31EXPORT_SYMBOL(fixup_bigphys_addr);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index d3e669d69c73..bda2e55e6c4c 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -53,15 +53,6 @@ mpc85xx_exclude_device(u_char bus, u_char devfn)
53 else 53 else
54 return PCIBIOS_SUCCESSFUL; 54 return PCIBIOS_SUCCESSFUL;
55} 55}
56
57void __init
58mpc85xx_pcibios_fixup(void)
59{
60 struct pci_dev *dev = NULL;
61
62 for_each_pci_dev(dev)
63 pci_read_irq_line(dev);
64}
65#endif /* CONFIG_PCI */ 56#endif /* CONFIG_PCI */
66 57
67#ifdef CONFIG_CPM2 58#ifdef CONFIG_CPM2
@@ -253,8 +244,6 @@ static void __init mpc85xx_ads_setup_arch(void)
253#ifdef CONFIG_PCI 244#ifdef CONFIG_PCI
254 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 245 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
255 add_bridge(np); 246 add_bridge(np);
256
257 ppc_md.pcibios_fixup = mpc85xx_pcibios_fixup;
258 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 247 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
259#endif 248#endif
260 249
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 1a1c226ad4d9..f4dd5f2f8a28 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -398,15 +398,6 @@ mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
398} 398}
399 399
400 400
401void __init mpc86xx_hpcn_pcibios_fixup(void)
402{
403 struct pci_dev *dev = NULL;
404
405 for_each_pci_dev(dev)
406 pci_read_irq_line(dev);
407}
408
409
410/* 401/*
411 * Called very early, device-tree isn't unflattened 402 * Called very early, device-tree isn't unflattened
412 */ 403 */
@@ -461,7 +452,6 @@ define_machine(mpc86xx_hpcn) {
461 .setup_arch = mpc86xx_hpcn_setup_arch, 452 .setup_arch = mpc86xx_hpcn_setup_arch,
462 .init_IRQ = mpc86xx_hpcn_init_irq, 453 .init_IRQ = mpc86xx_hpcn_init_irq,
463 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo, 454 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
464 .pcibios_fixup = mpc86xx_hpcn_pcibios_fixup,
465 .get_irq = mpic_get_irq, 455 .get_irq = mpic_get_irq,
466 .restart = mpc86xx_restart, 456 .restart = mpc86xx_restart,
467 .time_init = mpc86xx_time_init, 457 .time_init = mpc86xx_time_init,
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index e58fa953a50b..44d95eaf22e6 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -7,12 +7,14 @@ endif
7endif 7endif
8obj-$(CONFIG_PPC_CHRP) += chrp/ 8obj-$(CONFIG_PPC_CHRP) += chrp/
9obj-$(CONFIG_4xx) += 4xx/ 9obj-$(CONFIG_4xx) += 4xx/
10obj-$(CONFIG_PPC_MPC52xx) += 52xx/
10obj-$(CONFIG_PPC_83xx) += 83xx/ 11obj-$(CONFIG_PPC_83xx) += 83xx/
11obj-$(CONFIG_PPC_85xx) += 85xx/ 12obj-$(CONFIG_PPC_85xx) += 85xx/
12obj-$(CONFIG_PPC_86xx) += 86xx/ 13obj-$(CONFIG_PPC_86xx) += 86xx/
13obj-$(CONFIG_PPC_PSERIES) += pseries/ 14obj-$(CONFIG_PPC_PSERIES) += pseries/
14obj-$(CONFIG_PPC_ISERIES) += iseries/ 15obj-$(CONFIG_PPC_ISERIES) += iseries/
15obj-$(CONFIG_PPC_MAPLE) += maple/ 16obj-$(CONFIG_PPC_MAPLE) += maple/
16obj-$(CONFIG_PPC_PASEMI) += pasemi/ 17obj-$(CONFIG_PPC_PASEMI) += pasemi/
17obj-$(CONFIG_PPC_CELL) += cell/ 18obj-$(CONFIG_PPC_CELL) += cell/
19obj-$(CONFIG_PPC_PS3) += ps3/
18obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/ 20obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
index 3e430b489bb7..06a85b704331 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -20,4 +20,18 @@ config CBE_RAS
20 bool "RAS features for bare metal Cell BE" 20 bool "RAS features for bare metal Cell BE"
21 default y 21 default y
22 22
23config CBE_THERM
24 tristate "CBE thermal support"
25 default m
26 depends on CBE_RAS
27
28config CBE_CPUFREQ
29 tristate "CBE frequency scaling"
30 depends on CBE_RAS && CPU_FREQ
31 default m
32 help
33 This adds the cpufreq driver for Cell BE processors.
34 For details, take a look at <file:Documentation/cpu-freq/>.
35 If you don't have such processor, say N
36
23endmenu 37endmenu
diff --git a/arch/powerpc/platforms/cell/Makefile b/arch/powerpc/platforms/cell/Makefile
index c89cdd67383b..f90e8337796c 100644
--- a/arch/powerpc/platforms/cell/Makefile
+++ b/arch/powerpc/platforms/cell/Makefile
@@ -1,7 +1,11 @@
1obj-$(CONFIG_PPC_CELL_NATIVE) += interrupt.o iommu.o setup.o \ 1obj-$(CONFIG_PPC_CELL_NATIVE) += interrupt.o iommu.o setup.o \
2 cbe_regs.o spider-pic.o pervasive.o 2 cbe_regs.o spider-pic.o \
3 pervasive.o pmu.o io-workarounds.o
3obj-$(CONFIG_CBE_RAS) += ras.o 4obj-$(CONFIG_CBE_RAS) += ras.o
4 5
6obj-$(CONFIG_CBE_THERM) += cbe_thermal.o
7obj-$(CONFIG_CBE_CPUFREQ) += cbe_cpufreq.o
8
5ifeq ($(CONFIG_SMP),y) 9ifeq ($(CONFIG_SMP),y)
6obj-$(CONFIG_PPC_CELL_NATIVE) += smp.o 10obj-$(CONFIG_PPC_CELL_NATIVE) += smp.o
7endif 11endif
@@ -11,5 +15,6 @@ spufs-modular-$(CONFIG_SPU_FS) += spu_syscalls.o
11spu-priv1-$(CONFIG_PPC_CELL_NATIVE) += spu_priv1_mmio.o 15spu-priv1-$(CONFIG_PPC_CELL_NATIVE) += spu_priv1_mmio.o
12 16
13obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ 17obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \
18 spu_coredump.o \
14 $(spufs-modular-m) \ 19 $(spufs-modular-m) \
15 $(spu-priv1-y) spufs/ 20 $(spu-priv1-y) spufs/
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c
new file mode 100644
index 000000000000..a3850fd1e94c
--- /dev/null
+++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -0,0 +1,248 @@
1/*
2 * cpufreq driver for the cell processor
3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 *
6 * Author: Christian Krafft <krafft@de.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
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#include <linux/cpufreq.h>
24#include <linux/timer.h>
25
26#include <asm/hw_irq.h>
27#include <asm/io.h>
28#include <asm/processor.h>
29#include <asm/prom.h>
30#include <asm/time.h>
31
32#include "cbe_regs.h"
33
34static DEFINE_MUTEX(cbe_switch_mutex);
35
36
37/* the CBE supports an 8 step frequency scaling */
38static struct cpufreq_frequency_table cbe_freqs[] = {
39 {1, 0},
40 {2, 0},
41 {3, 0},
42 {4, 0},
43 {5, 0},
44 {6, 0},
45 {8, 0},
46 {10, 0},
47 {0, CPUFREQ_TABLE_END},
48};
49
50/* to write to MIC register */
51static u64 MIC_Slow_Fast_Timer_table[] = {
52 [0 ... 7] = 0x007fc00000000000ull,
53};
54
55/* more values for the MIC */
56static u64 MIC_Slow_Next_Timer_table[] = {
57 0x0000240000000000ull,
58 0x0000268000000000ull,
59 0x000029C000000000ull,
60 0x00002D0000000000ull,
61 0x0000300000000000ull,
62 0x0000334000000000ull,
63 0x000039C000000000ull,
64 0x00003FC000000000ull,
65};
66
67/*
68 * hardware specific functions
69 */
70
71static int get_pmode(int cpu)
72{
73 int ret;
74 struct cbe_pmd_regs __iomem *pmd_regs;
75
76 pmd_regs = cbe_get_cpu_pmd_regs(cpu);
77 ret = in_be64(&pmd_regs->pmsr) & 0x07;
78
79 return ret;
80}
81
82static int set_pmode(int cpu, unsigned int pmode)
83{
84 struct cbe_pmd_regs __iomem *pmd_regs;
85 struct cbe_mic_tm_regs __iomem *mic_tm_regs;
86 u64 flags;
87 u64 value;
88
89 local_irq_save(flags);
90
91 mic_tm_regs = cbe_get_cpu_mic_tm_regs(cpu);
92 pmd_regs = cbe_get_cpu_pmd_regs(cpu);
93
94 pr_debug("pm register is mapped at %p\n", &pmd_regs->pmcr);
95 pr_debug("mic register is mapped at %p\n", &mic_tm_regs->slow_fast_timer_0);
96
97 out_be64(&mic_tm_regs->slow_fast_timer_0, MIC_Slow_Fast_Timer_table[pmode]);
98 out_be64(&mic_tm_regs->slow_fast_timer_1, MIC_Slow_Fast_Timer_table[pmode]);
99
100 out_be64(&mic_tm_regs->slow_next_timer_0, MIC_Slow_Next_Timer_table[pmode]);
101 out_be64(&mic_tm_regs->slow_next_timer_1, MIC_Slow_Next_Timer_table[pmode]);
102
103 value = in_be64(&pmd_regs->pmcr);
104 /* set bits to zero */
105 value &= 0xFFFFFFFFFFFFFFF8ull;
106 /* set bits to next pmode */
107 value |= pmode;
108
109 out_be64(&pmd_regs->pmcr, value);
110
111 /* wait until new pmode appears in status register */
112 value = in_be64(&pmd_regs->pmsr) & 0x07;
113 while(value != pmode) {
114 cpu_relax();
115 value = in_be64(&pmd_regs->pmsr) & 0x07;
116 }
117
118 local_irq_restore(flags);
119
120 return 0;
121}
122
123/*
124 * cpufreq functions
125 */
126
127static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy)
128{
129 u32 *max_freq;
130 int i, cur_pmode;
131 struct device_node *cpu;
132
133 cpu = of_get_cpu_node(policy->cpu, NULL);
134
135 if(!cpu)
136 return -ENODEV;
137
138 pr_debug("init cpufreq on CPU %d\n", policy->cpu);
139
140 max_freq = (u32*) get_property(cpu, "clock-frequency", NULL);
141
142 if(!max_freq)
143 return -EINVAL;
144
145 // we need the freq in kHz
146 *max_freq /= 1000;
147
148 pr_debug("max clock-frequency is at %u kHz\n", *max_freq);
149 pr_debug("initializing frequency table\n");
150
151 // initialize frequency table
152 for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
153 cbe_freqs[i].frequency = *max_freq / cbe_freqs[i].index;
154 pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);
155 }
156
157 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
158 /* if DEBUG is enabled set_pmode() measures the correct latency of a transition */
159 policy->cpuinfo.transition_latency = 25000;
160
161 cur_pmode = get_pmode(policy->cpu);
162 pr_debug("current pmode is at %d\n",cur_pmode);
163
164 policy->cur = cbe_freqs[cur_pmode].frequency;
165
166#ifdef CONFIG_SMP
167 policy->cpus = cpu_sibling_map[policy->cpu];
168#endif
169
170 cpufreq_frequency_table_get_attr (cbe_freqs, policy->cpu);
171
172 /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */
173 return cpufreq_frequency_table_cpuinfo (policy, cbe_freqs);
174}
175
176static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
177{
178 cpufreq_frequency_table_put_attr(policy->cpu);
179 return 0;
180}
181
182static int cbe_cpufreq_verify(struct cpufreq_policy *policy)
183{
184 return cpufreq_frequency_table_verify(policy, cbe_freqs);
185}
186
187
188static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq,
189 unsigned int relation)
190{
191 int rc;
192 struct cpufreq_freqs freqs;
193 int cbe_pmode_new;
194
195 cpufreq_frequency_table_target(policy,
196 cbe_freqs,
197 target_freq,
198 relation,
199 &cbe_pmode_new);
200
201 freqs.old = policy->cur;
202 freqs.new = cbe_freqs[cbe_pmode_new].frequency;
203 freqs.cpu = policy->cpu;
204
205 mutex_lock (&cbe_switch_mutex);
206 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
207
208 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
209 policy->cpu,
210 cbe_freqs[cbe_pmode_new].frequency,
211 cbe_freqs[cbe_pmode_new].index);
212
213 rc = set_pmode(policy->cpu, cbe_pmode_new);
214 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
215 mutex_unlock(&cbe_switch_mutex);
216
217 return rc;
218}
219
220static struct cpufreq_driver cbe_cpufreq_driver = {
221 .verify = cbe_cpufreq_verify,
222 .target = cbe_cpufreq_target,
223 .init = cbe_cpufreq_cpu_init,
224 .exit = cbe_cpufreq_cpu_exit,
225 .name = "cbe-cpufreq",
226 .owner = THIS_MODULE,
227 .flags = CPUFREQ_CONST_LOOPS,
228};
229
230/*
231 * module init and destoy
232 */
233
234static int __init cbe_cpufreq_init(void)
235{
236 return cpufreq_register_driver(&cbe_cpufreq_driver);
237}
238
239static void __exit cbe_cpufreq_exit(void)
240{
241 cpufreq_unregister_driver(&cbe_cpufreq_driver);
242}
243
244module_init(cbe_cpufreq_init);
245module_exit(cbe_cpufreq_exit);
246
247MODULE_LICENSE("GPL");
248MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
diff --git a/arch/powerpc/platforms/cell/cbe_regs.c b/arch/powerpc/platforms/cell/cbe_regs.c
index 2f194ba29899..9a0ee62691d5 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.c
+++ b/arch/powerpc/platforms/cell/cbe_regs.c
@@ -8,6 +8,7 @@
8 8
9#include <linux/percpu.h> 9#include <linux/percpu.h>
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/module.h>
11 12
12#include <asm/io.h> 13#include <asm/io.h>
13#include <asm/pgtable.h> 14#include <asm/pgtable.h>
@@ -16,8 +17,6 @@
16 17
17#include "cbe_regs.h" 18#include "cbe_regs.h"
18 19
19#define MAX_CBE 2
20
21/* 20/*
22 * Current implementation uses "cpu" nodes. We build our own mapping 21 * Current implementation uses "cpu" nodes. We build our own mapping
23 * array of cpu numbers to cpu nodes locally for now to allow interrupt 22 * array of cpu numbers to cpu nodes locally for now to allow interrupt
@@ -30,6 +29,8 @@ static struct cbe_regs_map
30 struct device_node *cpu_node; 29 struct device_node *cpu_node;
31 struct cbe_pmd_regs __iomem *pmd_regs; 30 struct cbe_pmd_regs __iomem *pmd_regs;
32 struct cbe_iic_regs __iomem *iic_regs; 31 struct cbe_iic_regs __iomem *iic_regs;
32 struct cbe_mic_tm_regs __iomem *mic_tm_regs;
33 struct cbe_pmd_shadow_regs pmd_shadow_regs;
33} cbe_regs_maps[MAX_CBE]; 34} cbe_regs_maps[MAX_CBE];
34static int cbe_regs_map_count; 35static int cbe_regs_map_count;
35 36
@@ -42,6 +43,19 @@ static struct cbe_thread_map
42static struct cbe_regs_map *cbe_find_map(struct device_node *np) 43static struct cbe_regs_map *cbe_find_map(struct device_node *np)
43{ 44{
44 int i; 45 int i;
46 struct device_node *tmp_np;
47
48 if (strcasecmp(np->type, "spe") == 0) {
49 if (np->data == NULL) {
50 /* walk up path until cpu node was found */
51 tmp_np = np->parent;
52 while (tmp_np != NULL && strcasecmp(tmp_np->type, "cpu") != 0)
53 tmp_np = tmp_np->parent;
54
55 np->data = cbe_find_map(tmp_np);
56 }
57 return np->data;
58 }
45 59
46 for (i = 0; i < cbe_regs_map_count; i++) 60 for (i = 0; i < cbe_regs_map_count; i++)
47 if (cbe_regs_maps[i].cpu_node == np) 61 if (cbe_regs_maps[i].cpu_node == np)
@@ -56,6 +70,7 @@ struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np)
56 return NULL; 70 return NULL;
57 return map->pmd_regs; 71 return map->pmd_regs;
58} 72}
73EXPORT_SYMBOL_GPL(cbe_get_pmd_regs);
59 74
60struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu) 75struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu)
61{ 76{
@@ -64,7 +79,23 @@ struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu)
64 return NULL; 79 return NULL;
65 return map->pmd_regs; 80 return map->pmd_regs;
66} 81}
82EXPORT_SYMBOL_GPL(cbe_get_cpu_pmd_regs);
67 83
84struct cbe_pmd_shadow_regs *cbe_get_pmd_shadow_regs(struct device_node *np)
85{
86 struct cbe_regs_map *map = cbe_find_map(np);
87 if (map == NULL)
88 return NULL;
89 return &map->pmd_shadow_regs;
90}
91
92struct cbe_pmd_shadow_regs *cbe_get_cpu_pmd_shadow_regs(int cpu)
93{
94 struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
95 if (map == NULL)
96 return NULL;
97 return &map->pmd_shadow_regs;
98}
68 99
69struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np) 100struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np)
70{ 101{
@@ -73,6 +104,7 @@ struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np)
73 return NULL; 104 return NULL;
74 return map->iic_regs; 105 return map->iic_regs;
75} 106}
107
76struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu) 108struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu)
77{ 109{
78 struct cbe_regs_map *map = cbe_thread_map[cpu].regs; 110 struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
@@ -81,6 +113,36 @@ struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu)
81 return map->iic_regs; 113 return map->iic_regs;
82} 114}
83 115
116struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np)
117{
118 struct cbe_regs_map *map = cbe_find_map(np);
119 if (map == NULL)
120 return NULL;
121 return map->mic_tm_regs;
122}
123
124struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu)
125{
126 struct cbe_regs_map *map = cbe_thread_map[cpu].regs;
127 if (map == NULL)
128 return NULL;
129 return map->mic_tm_regs;
130}
131EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs);
132
133/* FIXME
134 * This is little more than a stub at the moment. It should be
135 * fleshed out so that it works for both SMT and non-SMT, no
136 * matter if the passed cpu is odd or even.
137 * For SMT enabled, returns 0 for even-numbered cpu; otherwise 1.
138 * For SMT disabled, returns 0 for all cpus.
139 */
140u32 cbe_get_hw_thread_id(int cpu)
141{
142 return (cpu & 1);
143}
144EXPORT_SYMBOL_GPL(cbe_get_hw_thread_id);
145
84void __init cbe_regs_init(void) 146void __init cbe_regs_init(void)
85{ 147{
86 int i; 148 int i;
@@ -119,6 +181,11 @@ void __init cbe_regs_init(void)
119 prop = get_property(cpu, "iic", NULL); 181 prop = get_property(cpu, "iic", NULL);
120 if (prop != NULL) 182 if (prop != NULL)
121 map->iic_regs = ioremap(prop->address, prop->len); 183 map->iic_regs = ioremap(prop->address, prop->len);
184
185 prop = (struct address_prop *)get_property(cpu, "mic-tm",
186 NULL);
187 if (prop != NULL)
188 map->mic_tm_regs = ioremap(prop->address, prop->len);
122 } 189 }
123} 190}
124 191
diff --git a/arch/powerpc/platforms/cell/cbe_regs.h b/arch/powerpc/platforms/cell/cbe_regs.h
index e76e4a6af5bc..440a7ecc66ea 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.h
+++ b/arch/powerpc/platforms/cell/cbe_regs.h
@@ -4,12 +4,19 @@
4 * This file is intended to hold the various register definitions for CBE 4 * This file is intended to hold the various register definitions for CBE
5 * on-chip system devices (memory controller, IO controller, etc...) 5 * on-chip system devices (memory controller, IO controller, etc...)
6 * 6 *
7 * (C) Copyright IBM Corporation 2001,2006
8 *
9 * Authors: Maximino Aguilar (maguilar@us.ibm.com)
10 * David J. Erb (djerb@us.ibm.com)
11 *
7 * (c) 2006 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp. 12 * (c) 2006 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
8 */ 13 */
9 14
10#ifndef CBE_REGS_H 15#ifndef CBE_REGS_H
11#define CBE_REGS_H 16#define CBE_REGS_H
12 17
18#include <asm/cell-pmu.h>
19
13/* 20/*
14 * 21 *
15 * Some HID register definitions 22 * Some HID register definitions
@@ -22,6 +29,7 @@
22#define HID0_CBE_THERM_INT_EN 0x0000000400000000ul 29#define HID0_CBE_THERM_INT_EN 0x0000000400000000ul
23#define HID0_CBE_SYSERR_INT_EN 0x0000000200000000ul 30#define HID0_CBE_SYSERR_INT_EN 0x0000000200000000ul
24 31
32#define MAX_CBE 2
25 33
26/* 34/*
27 * 35 *
@@ -29,51 +37,124 @@
29 * 37 *
30 */ 38 */
31 39
40union spe_reg {
41 u64 val;
42 u8 spe[8];
43};
44
45union ppe_spe_reg {
46 u64 val;
47 struct {
48 u32 ppe;
49 u32 spe;
50 };
51};
52
53
32struct cbe_pmd_regs { 54struct cbe_pmd_regs {
33 u8 pad_0x0000_0x0800[0x0800 - 0x0000]; /* 0x0000 */ 55 /* Debug Bus Control */
56 u64 pad_0x0000; /* 0x0000 */
57
58 u64 group_control; /* 0x0008 */
59
60 u8 pad_0x0010_0x00a8 [0x00a8 - 0x0010]; /* 0x0010 */
61
62 u64 debug_bus_control; /* 0x00a8 */
63
64 u8 pad_0x00b0_0x0100 [0x0100 - 0x00b0]; /* 0x00b0 */
65
66 u64 trace_aux_data; /* 0x0100 */
67 u64 trace_buffer_0_63; /* 0x0108 */
68 u64 trace_buffer_64_127; /* 0x0110 */
69 u64 trace_address; /* 0x0118 */
70 u64 ext_tr_timer; /* 0x0120 */
71
72 u8 pad_0x0128_0x0400 [0x0400 - 0x0128]; /* 0x0128 */
73
74 /* Performance Monitor */
75 u64 pm_status; /* 0x0400 */
76 u64 pm_control; /* 0x0408 */
77 u64 pm_interval; /* 0x0410 */
78 u64 pm_ctr[4]; /* 0x0418 */
79 u64 pm_start_stop; /* 0x0438 */
80 u64 pm07_control[8]; /* 0x0440 */
81
82 u8 pad_0x0480_0x0800 [0x0800 - 0x0480]; /* 0x0480 */
34 83
35 /* Thermal Sensor Registers */ 84 /* Thermal Sensor Registers */
36 u64 ts_ctsr1; /* 0x0800 */ 85 union spe_reg ts_ctsr1; /* 0x0800 */
37 u64 ts_ctsr2; /* 0x0808 */ 86 u64 ts_ctsr2; /* 0x0808 */
38 u64 ts_mtsr1; /* 0x0810 */ 87 union spe_reg ts_mtsr1; /* 0x0810 */
39 u64 ts_mtsr2; /* 0x0818 */ 88 u64 ts_mtsr2; /* 0x0818 */
40 u64 ts_itr1; /* 0x0820 */ 89 union spe_reg ts_itr1; /* 0x0820 */
41 u64 ts_itr2; /* 0x0828 */ 90 u64 ts_itr2; /* 0x0828 */
42 u64 ts_gitr; /* 0x0830 */ 91 u64 ts_gitr; /* 0x0830 */
43 u64 ts_isr; /* 0x0838 */ 92 u64 ts_isr; /* 0x0838 */
44 u64 ts_imr; /* 0x0840 */ 93 u64 ts_imr; /* 0x0840 */
45 u64 tm_cr1; /* 0x0848 */ 94 union spe_reg tm_cr1; /* 0x0848 */
46 u64 tm_cr2; /* 0x0850 */ 95 u64 tm_cr2; /* 0x0850 */
47 u64 tm_simr; /* 0x0858 */ 96 u64 tm_simr; /* 0x0858 */
48 u64 tm_tpr; /* 0x0860 */ 97 union ppe_spe_reg tm_tpr; /* 0x0860 */
49 u64 tm_str1; /* 0x0868 */ 98 union spe_reg tm_str1; /* 0x0868 */
50 u64 tm_str2; /* 0x0870 */ 99 u64 tm_str2; /* 0x0870 */
51 u64 tm_tsr; /* 0x0878 */ 100 union ppe_spe_reg tm_tsr; /* 0x0878 */
52 101
53 /* Power Management */ 102 /* Power Management */
54 u64 pm_control; /* 0x0880 */ 103 u64 pmcr; /* 0x0880 */
55#define CBE_PMD_PAUSE_ZERO_CONTROL 0x10000 104#define CBE_PMD_PAUSE_ZERO_CONTROL 0x10000
56 u64 pm_status; /* 0x0888 */ 105 u64 pmsr; /* 0x0888 */
57 106
58 /* Time Base Register */ 107 /* Time Base Register */
59 u64 tbr; /* 0x0890 */ 108 u64 tbr; /* 0x0890 */
60 109
61 u8 pad_0x0898_0x0c00 [0x0c00 - 0x0898]; /* 0x0898 */ 110 u8 pad_0x0898_0x0c00 [0x0c00 - 0x0898]; /* 0x0898 */
62 111
63 /* Fault Isolation Registers */ 112 /* Fault Isolation Registers */
64 u64 checkstop_fir; /* 0x0c00 */ 113 u64 checkstop_fir; /* 0x0c00 */
65 u64 recoverable_fir; 114 u64 recoverable_fir; /* 0x0c08 */
66 u64 spec_att_mchk_fir; 115 u64 spec_att_mchk_fir; /* 0x0c10 */
67 u64 fir_mode_reg; 116 u64 fir_mode_reg; /* 0x0c18 */
68 u64 fir_enable_mask; 117 u64 fir_enable_mask; /* 0x0c20 */
69 118
70 u8 pad_0x0c28_0x1000 [0x1000 - 0x0c28]; /* 0x0c28 */ 119 u8 pad_0x0c28_0x1000 [0x1000 - 0x0c28]; /* 0x0c28 */
71}; 120};
72 121
73extern struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np); 122extern struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np);
74extern struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu); 123extern struct cbe_pmd_regs __iomem *cbe_get_cpu_pmd_regs(int cpu);
75 124
76/* 125/*
126 * PMU shadow registers
127 *
128 * Many of the registers in the performance monitoring unit are write-only,
129 * so we need to save a copy of what we write to those registers.
130 *
131 * The actual data counters are read/write. However, writing to the counters
132 * only takes effect if the PMU is enabled. Otherwise the value is stored in
133 * a hardware latch until the next time the PMU is enabled. So we save a copy
134 * of the counter values if we need to read them back while the PMU is
135 * disabled. The counter_value_in_latch field is a bitmap indicating which
136 * counters currently have a value waiting to be written.
137 */
138
139struct cbe_pmd_shadow_regs {
140 u32 group_control;
141 u32 debug_bus_control;
142 u32 trace_address;
143 u32 ext_tr_timer;
144 u32 pm_status;
145 u32 pm_control;
146 u32 pm_interval;
147 u32 pm_start_stop;
148 u32 pm07_control[NR_CTRS];
149
150 u32 pm_ctr[NR_PHYS_CTRS];
151 u32 counter_value_in_latch;
152};
153
154extern struct cbe_pmd_shadow_regs *cbe_get_pmd_shadow_regs(struct device_node *np);
155extern struct cbe_pmd_shadow_regs *cbe_get_cpu_pmd_shadow_regs(int cpu);
156
157/*
77 * 158 *
78 * IIC unit register definitions 159 * IIC unit register definitions
79 * 160 *
@@ -102,18 +183,28 @@ struct cbe_iic_regs {
102 183
103 /* IIC interrupt registers */ 184 /* IIC interrupt registers */
104 struct cbe_iic_thread_regs thread[2]; /* 0x0400 */ 185 struct cbe_iic_thread_regs thread[2]; /* 0x0400 */
105 u64 iic_ir; /* 0x0440 */ 186
106 u64 iic_is; /* 0x0448 */ 187 u64 iic_ir; /* 0x0440 */
188#define CBE_IIC_IR_PRIO(x) (((x) & 0xf) << 12)
189#define CBE_IIC_IR_DEST_NODE(x) (((x) & 0xf) << 4)
190#define CBE_IIC_IR_DEST_UNIT(x) ((x) & 0xf)
191#define CBE_IIC_IR_IOC_0 0x0
192#define CBE_IIC_IR_IOC_1S 0xb
193#define CBE_IIC_IR_PT_0 0xe
194#define CBE_IIC_IR_PT_1 0xf
195
196 u64 iic_is; /* 0x0448 */
197#define CBE_IIC_IS_PMI 0x2
107 198
108 u8 pad_0x0450_0x0500[0x0500 - 0x0450]; /* 0x0450 */ 199 u8 pad_0x0450_0x0500[0x0500 - 0x0450]; /* 0x0450 */
109 200
110 /* IOC FIR */ 201 /* IOC FIR */
111 u64 ioc_fir_reset; /* 0x0500 */ 202 u64 ioc_fir_reset; /* 0x0500 */
112 u64 ioc_fir_set; 203 u64 ioc_fir_set; /* 0x0508 */
113 u64 ioc_checkstop_enable; 204 u64 ioc_checkstop_enable; /* 0x0510 */
114 u64 ioc_fir_error_mask; 205 u64 ioc_fir_error_mask; /* 0x0518 */
115 u64 ioc_syserr_enable; 206 u64 ioc_syserr_enable; /* 0x0520 */
116 u64 ioc_fir; 207 u64 ioc_fir; /* 0x0528 */
117 208
118 u8 pad_0x0530_0x1000[0x1000 - 0x0530]; /* 0x0530 */ 209 u8 pad_0x0530_0x1000[0x1000 - 0x0530]; /* 0x0530 */
119}; 210};
@@ -122,6 +213,48 @@ extern struct cbe_iic_regs __iomem *cbe_get_iic_regs(struct device_node *np);
122extern struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu); 213extern struct cbe_iic_regs __iomem *cbe_get_cpu_iic_regs(int cpu);
123 214
124 215
216struct cbe_mic_tm_regs {
217 u8 pad_0x0000_0x0040[0x0040 - 0x0000]; /* 0x0000 */
218
219 u64 mic_ctl_cnfg2; /* 0x0040 */
220#define CBE_MIC_ENABLE_AUX_TRC 0x8000000000000000LL
221#define CBE_MIC_DISABLE_PWR_SAV_2 0x0200000000000000LL
222#define CBE_MIC_DISABLE_AUX_TRC_WRAP 0x0100000000000000LL
223#define CBE_MIC_ENABLE_AUX_TRC_INT 0x0080000000000000LL
224
225 u64 pad_0x0048; /* 0x0048 */
226
227 u64 mic_aux_trc_base; /* 0x0050 */
228 u64 mic_aux_trc_max_addr; /* 0x0058 */
229 u64 mic_aux_trc_cur_addr; /* 0x0060 */
230 u64 mic_aux_trc_grf_addr; /* 0x0068 */
231 u64 mic_aux_trc_grf_data; /* 0x0070 */
232
233 u64 pad_0x0078; /* 0x0078 */
234
235 u64 mic_ctl_cnfg_0; /* 0x0080 */
236#define CBE_MIC_DISABLE_PWR_SAV_0 0x8000000000000000LL
237
238 u64 pad_0x0088; /* 0x0088 */
239
240 u64 slow_fast_timer_0; /* 0x0090 */
241 u64 slow_next_timer_0; /* 0x0098 */
242
243 u8 pad_0x00a0_0x01c0[0x01c0 - 0x0a0]; /* 0x00a0 */
244
245 u64 mic_ctl_cnfg_1; /* 0x01c0 */
246#define CBE_MIC_DISABLE_PWR_SAV_1 0x8000000000000000LL
247 u64 pad_0x01c8; /* 0x01c8 */
248
249 u64 slow_fast_timer_1; /* 0x01d0 */
250 u64 slow_next_timer_1; /* 0x01d8 */
251
252 u8 pad_0x01e0_0x1000[0x1000 - 0x01e0]; /* 0x01e0 */
253};
254
255extern struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np);
256extern struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu);
257
125/* Init this module early */ 258/* Init this module early */
126extern void cbe_regs_init(void); 259extern void cbe_regs_init(void);
127 260
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
new file mode 100644
index 000000000000..616a0a3fd0e2
--- /dev/null
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -0,0 +1,226 @@
1/*
2 * thermal support for the cell processor
3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 *
6 * Author: Christian Krafft <krafft@de.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
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#include <linux/module.h>
24#include <linux/sysdev.h>
25#include <linux/kernel.h>
26#include <linux/cpu.h>
27#include <asm/spu.h>
28#include <asm/io.h>
29#include <asm/prom.h>
30
31#include "cbe_regs.h"
32#include "spu_priv1_mmio.h"
33
34static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev)
35{
36 struct spu *spu;
37
38 spu = container_of(sysdev, struct spu, sysdev);
39
40 return cbe_get_pmd_regs(spu_devnode(spu));
41}
42
43/* returns the value for a given spu in a given register */
44static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iomem *reg)
45{
46 unsigned int *id;
47 union spe_reg value;
48 struct spu *spu;
49
50 /* getting the id from the reg attribute will not work on future device-tree layouts
51 * in future we should store the id to the spu struct and use it here */
52 spu = container_of(sysdev, struct spu, sysdev);
53 id = (unsigned int *)get_property(spu_devnode(spu), "reg", NULL);
54 value.val = in_be64(&reg->val);
55
56 return value.spe[*id];
57}
58
59static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
60{
61 int value;
62 struct cbe_pmd_regs __iomem *pmd_regs;
63
64 pmd_regs = get_pmd_regs(sysdev);
65
66 value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1);
67 /* clear all other bits */
68 value &= 0x3F;
69 /* temp is stored in steps of 2 degrees */
70 value *= 2;
71 /* base temp is 65 degrees */
72 value += 65;
73
74 return sprintf(buf, "%d\n", (int) value);
75}
76
77static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
78{
79 struct cbe_pmd_regs __iomem *pmd_regs;
80 u64 value;
81
82 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
83 value = in_be64(&pmd_regs->ts_ctsr2);
84
85 /* access the corresponding byte */
86 value >>= pos;
87 /* clear all other bits */
88 value &= 0x3F;
89 /* temp is stored in steps of 2 degrees */
90 value *= 2;
91 /* base temp is 65 degrees */
92 value += 65;
93
94 return sprintf(buf, "%d\n", (int) value);
95}
96
97
98/* shows the temperature of the DTS on the PPE,
99 * located near the linear thermal sensor */
100static ssize_t ppe_show_temp0(struct sys_device *sysdev, char *buf)
101{
102 return ppe_show_temp(sysdev, buf, 32);
103}
104
105/* shows the temperature of the second DTS on the PPE */
106static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf)
107{
108 return ppe_show_temp(sysdev, buf, 0);
109}
110
111static struct sysdev_attribute attr_spu_temperature = {
112 .attr = {.name = "temperature", .mode = 0400 },
113 .show = spu_show_temp,
114};
115
116static struct attribute *spu_attributes[] = {
117 &attr_spu_temperature.attr,
118};
119
120static struct attribute_group spu_attribute_group = {
121 .name = "thermal",
122 .attrs = spu_attributes,
123};
124
125static struct sysdev_attribute attr_ppe_temperature0 = {
126 .attr = {.name = "temperature0", .mode = 0400 },
127 .show = ppe_show_temp0,
128};
129
130static struct sysdev_attribute attr_ppe_temperature1 = {
131 .attr = {.name = "temperature1", .mode = 0400 },
132 .show = ppe_show_temp1,
133};
134
135static struct attribute *ppe_attributes[] = {
136 &attr_ppe_temperature0.attr,
137 &attr_ppe_temperature1.attr,
138};
139
140static struct attribute_group ppe_attribute_group = {
141 .name = "thermal",
142 .attrs = ppe_attributes,
143};
144
145/*
146 * initialize throttling with default values
147 */
148static void __init init_default_values(void)
149{
150 int cpu;
151 struct cbe_pmd_regs __iomem *pmd_regs;
152 struct sys_device *sysdev;
153 union ppe_spe_reg tpr;
154 union spe_reg str1;
155 u64 str2;
156 union spe_reg cr1;
157 u64 cr2;
158
159 /* TPR defaults */
160 /* ppe
161 * 1F - no full stop
162 * 08 - dynamic throttling starts if over 80 degrees
163 * 03 - dynamic throttling ceases if below 70 degrees */
164 tpr.ppe = 0x1F0803;
165 /* spe
166 * 10 - full stopped when over 96 degrees
167 * 08 - dynamic throttling starts if over 80 degrees
168 * 03 - dynamic throttling ceases if below 70 degrees
169 */
170 tpr.spe = 0x100803;
171
172 /* STR defaults */
173 /* str1
174 * 10 - stop 16 of 32 cycles
175 */
176 str1.val = 0x1010101010101010ull;
177 /* str2
178 * 10 - stop 16 of 32 cycles
179 */
180 str2 = 0x10;
181
182 /* CR defaults */
183 /* cr1
184 * 4 - normal operation
185 */
186 cr1.val = 0x0404040404040404ull;
187 /* cr2
188 * 4 - normal operation
189 */
190 cr2 = 0x04;
191
192 for_each_possible_cpu (cpu) {
193 pr_debug("processing cpu %d\n", cpu);
194 sysdev = get_cpu_sysdev(cpu);
195 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
196
197 out_be64(&pmd_regs->tm_str2, str2);
198 out_be64(&pmd_regs->tm_str1.val, str1.val);
199 out_be64(&pmd_regs->tm_tpr.val, tpr.val);
200 out_be64(&pmd_regs->tm_cr1.val, cr1.val);
201 out_be64(&pmd_regs->tm_cr2, cr2);
202 }
203}
204
205
206static int __init thermal_init(void)
207{
208 init_default_values();
209
210 spu_add_sysdev_attr_group(&spu_attribute_group);
211 cpu_add_sysdev_attr_group(&ppe_attribute_group);
212
213 return 0;
214}
215module_init(thermal_init);
216
217static void __exit thermal_exit(void)
218{
219 spu_remove_sysdev_attr_group(&spu_attribute_group);
220 cpu_remove_sysdev_attr_group(&ppe_attribute_group);
221}
222module_exit(thermal_exit);
223
224MODULE_LICENSE("GPL");
225MODULE_AUTHOR("Christian Krafft <krafft@de.ibm.com>");
226
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index a914c12b4060..6666d037eb44 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -396,3 +396,19 @@ void __init iic_init_IRQ(void)
396 /* Enable on current CPU */ 396 /* Enable on current CPU */
397 iic_setup_cpu(); 397 iic_setup_cpu();
398} 398}
399
400void iic_set_interrupt_routing(int cpu, int thread, int priority)
401{
402 struct cbe_iic_regs __iomem *iic_regs = cbe_get_cpu_iic_regs(cpu);
403 u64 iic_ir = 0;
404 int node = cpu >> 1;
405
406 /* Set which node and thread will handle the next interrupt */
407 iic_ir |= CBE_IIC_IR_PRIO(priority) |
408 CBE_IIC_IR_DEST_NODE(node);
409 if (thread == 0)
410 iic_ir |= CBE_IIC_IR_DEST_UNIT(CBE_IIC_IR_PT_0);
411 else
412 iic_ir |= CBE_IIC_IR_DEST_UNIT(CBE_IIC_IR_PT_1);
413 out_be64(&iic_regs->iic_ir, iic_ir);
414}
diff --git a/arch/powerpc/platforms/cell/interrupt.h b/arch/powerpc/platforms/cell/interrupt.h
index 9ba1d3c17b4b..942dc39d6045 100644
--- a/arch/powerpc/platforms/cell/interrupt.h
+++ b/arch/powerpc/platforms/cell/interrupt.h
@@ -83,5 +83,7 @@ extern u8 iic_get_target_id(int cpu);
83 83
84extern void spider_init_IRQ(void); 84extern void spider_init_IRQ(void);
85 85
86extern void iic_set_interrupt_routing(int cpu, int thread, int priority);
87
86#endif 88#endif
87#endif /* ASM_CELL_PIC_H */ 89#endif /* ASM_CELL_PIC_H */
diff --git a/arch/powerpc/platforms/cell/io-workarounds.c b/arch/powerpc/platforms/cell/io-workarounds.c
new file mode 100644
index 000000000000..580d42595912
--- /dev/null
+++ b/arch/powerpc/platforms/cell/io-workarounds.c
@@ -0,0 +1,346 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt <benh@kernel.crashing.org>
3 * IBM, Corp.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#undef DEBUG
10
11#include <linux/kernel.h>
12#include <linux/mm.h>
13#include <linux/pci.h>
14#include <asm/io.h>
15#include <asm/machdep.h>
16#include <asm/pci-bridge.h>
17#include <asm/ppc-pci.h>
18
19
20#define SPIDER_PCI_REG_BASE 0xd000
21#define SPIDER_PCI_VCI_CNTL_STAT 0x0110
22#define SPIDER_PCI_DUMMY_READ 0x0810
23#define SPIDER_PCI_DUMMY_READ_BASE 0x0814
24
25/* Undefine that to re-enable bogus prefetch
26 *
27 * Without that workaround, the chip will do bogus prefetch past
28 * page boundary from system memory. This setting will disable that,
29 * though the documentation is unclear as to the consequences of doing
30 * so, either purely performances, or possible misbehaviour... It's not
31 * clear wether the chip can handle unaligned accesses at all without
32 * prefetching enabled.
33 *
34 * For now, things appear to be behaving properly with that prefetching
35 * disabled and IDE, possibly because IDE isn't doing any unaligned
36 * access.
37 */
38#define SPIDER_DISABLE_PREFETCH
39
40#define MAX_SPIDERS 2
41
42static struct spider_pci_bus {
43 void __iomem *regs;
44 unsigned long mmio_start;
45 unsigned long mmio_end;
46 unsigned long pio_vstart;
47 unsigned long pio_vend;
48} spider_pci_busses[MAX_SPIDERS];
49static int spider_pci_count;
50
51static struct spider_pci_bus *spider_pci_find(unsigned long vaddr,
52 unsigned long paddr)
53{
54 int i;
55
56 for (i = 0; i < spider_pci_count; i++) {
57 struct spider_pci_bus *bus = &spider_pci_busses[i];
58 if (paddr && paddr >= bus->mmio_start && paddr < bus->mmio_end)
59 return bus;
60 if (vaddr && vaddr >= bus->pio_vstart && vaddr < bus->pio_vend)
61 return bus;
62 }
63 return NULL;
64}
65
66static void spider_io_flush(const volatile void __iomem *addr)
67{
68 struct spider_pci_bus *bus;
69 int token;
70
71 /* Get platform token (set by ioremap) from address */
72 token = PCI_GET_ADDR_TOKEN(addr);
73
74 /* Fast path if we have a non-0 token, it indicates which bus we
75 * are on.
76 *
77 * If the token is 0, that means either the the ioremap was done
78 * before we initialized this layer, or it's a PIO operation. We
79 * fallback to a low path in this case. Hopefully, internal devices
80 * which are ioremap'ed early should use in_XX/out_XX functions
81 * instead of the PCI ones and thus not suffer from the slowdown.
82 *
83 * Also note that currently, the workaround will not work for areas
84 * that are not mapped with PTEs (bolted in the hash table). This
85 * is the case for ioremaps done very early at boot (before
86 * mem_init_done) and includes the mapping of the ISA IO space.
87 *
88 * Fortunately, none of the affected devices is expected to do DMA
89 * and thus there should be no problem in practice.
90 *
91 * In order to improve performances, we only do the PTE search for
92 * addresses falling in the PHB IO space area. That means it will
93 * not work for hotplug'ed PHBs but those don't exist with Spider.
94 */
95 if (token && token <= spider_pci_count)
96 bus = &spider_pci_busses[token - 1];
97 else {
98 unsigned long vaddr, paddr;
99 pte_t *ptep;
100
101 /* Fixup physical address */
102 vaddr = (unsigned long)PCI_FIX_ADDR(addr);
103
104 /* Check if it's in allowed range for PIO */
105 if (vaddr < PHBS_IO_BASE || vaddr >= IMALLOC_BASE)
106 return;
107
108 /* Try to find a PTE. If not, clear the paddr, we'll do
109 * a vaddr only lookup (PIO only)
110 */
111 ptep = find_linux_pte(init_mm.pgd, vaddr);
112 if (ptep == NULL)
113 paddr = 0;
114 else
115 paddr = pte_pfn(*ptep) << PAGE_SHIFT;
116
117 bus = spider_pci_find(vaddr, paddr);
118 if (bus == NULL)
119 return;
120 }
121
122 /* Now do the workaround
123 */
124 (void)in_be32(bus->regs + SPIDER_PCI_DUMMY_READ);
125}
126
127static u8 spider_readb(const volatile void __iomem *addr)
128{
129 u8 val = __do_readb(addr);
130 spider_io_flush(addr);
131 return val;
132}
133
134static u16 spider_readw(const volatile void __iomem *addr)
135{
136 u16 val = __do_readw(addr);
137 spider_io_flush(addr);
138 return val;
139}
140
141static u32 spider_readl(const volatile void __iomem *addr)
142{
143 u32 val = __do_readl(addr);
144 spider_io_flush(addr);
145 return val;
146}
147
148static u64 spider_readq(const volatile void __iomem *addr)
149{
150 u64 val = __do_readq(addr);
151 spider_io_flush(addr);
152 return val;
153}
154
155static u16 spider_readw_be(const volatile void __iomem *addr)
156{
157 u16 val = __do_readw_be(addr);
158 spider_io_flush(addr);
159 return val;
160}
161
162static u32 spider_readl_be(const volatile void __iomem *addr)
163{
164 u32 val = __do_readl_be(addr);
165 spider_io_flush(addr);
166 return val;
167}
168
169static u64 spider_readq_be(const volatile void __iomem *addr)
170{
171 u64 val = __do_readq_be(addr);
172 spider_io_flush(addr);
173 return val;
174}
175
176static void spider_readsb(const volatile void __iomem *addr, void *buf,
177 unsigned long count)
178{
179 __do_readsb(addr, buf, count);
180 spider_io_flush(addr);
181}
182
183static void spider_readsw(const volatile void __iomem *addr, void *buf,
184 unsigned long count)
185{
186 __do_readsw(addr, buf, count);
187 spider_io_flush(addr);
188}
189
190static void spider_readsl(const volatile void __iomem *addr, void *buf,
191 unsigned long count)
192{
193 __do_readsl(addr, buf, count);
194 spider_io_flush(addr);
195}
196
197static void spider_memcpy_fromio(void *dest, const volatile void __iomem *src,
198 unsigned long n)
199{
200 __do_memcpy_fromio(dest, src, n);
201 spider_io_flush(src);
202}
203
204
205static void __iomem * spider_ioremap(unsigned long addr, unsigned long size,
206 unsigned long flags)
207{
208 struct spider_pci_bus *bus;
209 void __iomem *res = __ioremap(addr, size, flags);
210 int busno;
211
212 pr_debug("spider_ioremap(0x%lx, 0x%lx, 0x%lx) -> 0x%p\n",
213 addr, size, flags, res);
214
215 bus = spider_pci_find(0, addr);
216 if (bus != NULL) {
217 busno = bus - spider_pci_busses;
218 pr_debug(" found bus %d, setting token\n", busno);
219 PCI_SET_ADDR_TOKEN(res, busno + 1);
220 }
221 pr_debug(" result=0x%p\n", res);
222
223 return res;
224}
225
226static void __init spider_pci_setup_chip(struct spider_pci_bus *bus)
227{
228#ifdef SPIDER_DISABLE_PREFETCH
229 u32 val = in_be32(bus->regs + SPIDER_PCI_VCI_CNTL_STAT);
230 pr_debug(" PVCI_Control_Status was 0x%08x\n", val);
231 out_be32(bus->regs + SPIDER_PCI_VCI_CNTL_STAT, val | 0x8);
232#endif
233
234 /* Configure the dummy address for the workaround */
235 out_be32(bus->regs + SPIDER_PCI_DUMMY_READ_BASE, 0x80000000);
236}
237
238static void __init spider_pci_add_one(struct pci_controller *phb)
239{
240 struct spider_pci_bus *bus = &spider_pci_busses[spider_pci_count];
241 struct device_node *np = phb->arch_data;
242 struct resource rsrc;
243 void __iomem *regs;
244
245 if (spider_pci_count >= MAX_SPIDERS) {
246 printk(KERN_ERR "Too many spider bridges, workarounds"
247 " disabled for %s\n", np->full_name);
248 return;
249 }
250
251 /* Get the registers for the beast */
252 if (of_address_to_resource(np, 0, &rsrc)) {
253 printk(KERN_ERR "Failed to get registers for spider %s"
254 " workarounds disabled\n", np->full_name);
255 return;
256 }
257
258 /* Mask out some useless bits in there to get to the base of the
259 * spider chip
260 */
261 rsrc.start &= ~0xfffffffful;
262
263 /* Map them */
264 regs = ioremap(rsrc.start + SPIDER_PCI_REG_BASE, 0x1000);
265 if (regs == NULL) {
266 printk(KERN_ERR "Failed to map registers for spider %s"
267 " workarounds disabled\n", np->full_name);
268 return;
269 }
270
271 spider_pci_count++;
272
273 /* We assume spiders only have one MMIO resource */
274 bus->mmio_start = phb->mem_resources[0].start;
275 bus->mmio_end = phb->mem_resources[0].end + 1;
276
277 bus->pio_vstart = (unsigned long)phb->io_base_virt;
278 bus->pio_vend = bus->pio_vstart + phb->pci_io_size;
279
280 bus->regs = regs;
281
282 printk(KERN_INFO "PCI: Spider MMIO workaround for %s\n",np->full_name);
283
284 pr_debug(" mmio (P) = 0x%016lx..0x%016lx\n",
285 bus->mmio_start, bus->mmio_end);
286 pr_debug(" pio (V) = 0x%016lx..0x%016lx\n",
287 bus->pio_vstart, bus->pio_vend);
288 pr_debug(" regs (P) = 0x%016lx (V) = 0x%p\n",
289 rsrc.start + SPIDER_PCI_REG_BASE, bus->regs);
290
291 spider_pci_setup_chip(bus);
292}
293
294static struct ppc_pci_io __initdata spider_pci_io = {
295 .readb = spider_readb,
296 .readw = spider_readw,
297 .readl = spider_readl,
298 .readq = spider_readq,
299 .readw_be = spider_readw_be,
300 .readl_be = spider_readl_be,
301 .readq_be = spider_readq_be,
302 .readsb = spider_readsb,
303 .readsw = spider_readsw,
304 .readsl = spider_readsl,
305 .memcpy_fromio = spider_memcpy_fromio,
306};
307
308static int __init spider_pci_workaround_init(void)
309{
310 struct pci_controller *phb;
311
312 if (!machine_is(cell))
313 return 0;
314
315 /* Find spider bridges. We assume they have been all probed
316 * in setup_arch(). If that was to change, we would need to
317 * update this code to cope with dynamically added busses
318 */
319 list_for_each_entry(phb, &hose_list, list_node) {
320 struct device_node *np = phb->arch_data;
321 const char *model = get_property(np, "model", NULL);
322
323 /* If no model property or name isn't exactly "pci", skip */
324 if (model == NULL || strcmp(np->name, "pci"))
325 continue;
326 /* If model is not "Spider", skip */
327 if (strcmp(model, "Spider"))
328 continue;
329 spider_pci_add_one(phb);
330 }
331
332 /* No Spider PCI found, exit */
333 if (spider_pci_count == 0)
334 return 0;
335
336 /* Setup IO callbacks. We only setup MMIO reads. PIO reads will
337 * fallback to MMIO reads (though without a token, thus slower)
338 */
339 ppc_pci_io = spider_pci_io;
340
341 /* Setup ioremap callback */
342 ppc_md.ioremap = spider_ioremap;
343
344 return 0;
345}
346arch_initcall(spider_pci_workaround_init);
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index aca4c3db0dde..b43466ba8096 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -1,514 +1,747 @@
1/* 1/*
2 * IOMMU implementation for Cell Broadband Processor Architecture 2 * IOMMU implementation for Cell Broadband Processor Architecture
3 * We just establish a linear mapping at boot by setting all the
4 * IOPT cache entries in the CPU.
5 * The mapping functions should be identical to pci_direct_iommu,
6 * except for the handling of the high order bit that is required
7 * by the Spider bridge. These should be split into a separate
8 * file at the point where we get a different bridge chip.
9 * 3 *
10 * Copyright (C) 2005 IBM Deutschland Entwicklung GmbH, 4 * (C) Copyright IBM Corporation 2006
11 * Arnd Bergmann <arndb@de.ibm.com>
12 * 5 *
13 * Based on linear mapping 6 * Author: Jeremy Kerr <jk@ozlabs.org>
14 * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
15 * 7 *
16 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or modify
17 * modify it under the terms of the GNU General Public License 9 * it under the terms of the GNU General Public License as published by
18 * as published by the Free Software Foundation; either version 10 * the Free Software Foundation; either version 2, or (at your option)
19 * 2 of the License, or (at your option) any later version. 11 * any later version.
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.
20 */ 21 */
21 22
22#undef DEBUG 23#undef DEBUG
23 24
24#include <linux/kernel.h> 25#include <linux/kernel.h>
25#include <linux/pci.h>
26#include <linux/delay.h>
27#include <linux/string.h>
28#include <linux/init.h> 26#include <linux/init.h>
29#include <linux/bootmem.h> 27#include <linux/interrupt.h>
30#include <linux/mm.h> 28#include <linux/notifier.h>
31#include <linux/dma-mapping.h>
32#include <linux/kernel.h>
33#include <linux/compiler.h>
34 29
35#include <asm/sections.h>
36#include <asm/iommu.h>
37#include <asm/io.h>
38#include <asm/prom.h> 30#include <asm/prom.h>
39#include <asm/pci-bridge.h> 31#include <asm/iommu.h>
40#include <asm/machdep.h> 32#include <asm/machdep.h>
41#include <asm/pmac_feature.h> 33#include <asm/pci-bridge.h>
42#include <asm/abs_addr.h>
43#include <asm/system.h>
44#include <asm/ppc-pci.h>
45#include <asm/udbg.h> 34#include <asm/udbg.h>
35#include <asm/of_platform.h>
36#include <asm/lmb.h>
46 37
47#include "iommu.h" 38#include "cbe_regs.h"
39#include "interrupt.h"
48 40
49static inline unsigned long 41/* Define CELL_IOMMU_REAL_UNMAP to actually unmap non-used pages
50get_iopt_entry(unsigned long real_address, unsigned long ioid, 42 * instead of leaving them mapped to some dummy page. This can be
51 unsigned long prot) 43 * enabled once the appropriate workarounds for spider bugs have
52{ 44 * been enabled
53 return (prot & IOPT_PROT_MASK) 45 */
54 | (IOPT_COHERENT) 46#define CELL_IOMMU_REAL_UNMAP
55 | (IOPT_ORDER_VC)
56 | (real_address & IOPT_RPN_MASK)
57 | (ioid & IOPT_IOID_MASK);
58}
59 47
60typedef struct { 48/* Define CELL_IOMMU_STRICT_PROTECTION to enforce protection of
61 unsigned long val; 49 * IO PTEs based on the transfer direction. That can be enabled
62} ioste; 50 * once spider-net has been fixed to pass the correct direction
51 * to the DMA mapping functions
52 */
53#define CELL_IOMMU_STRICT_PROTECTION
54
55
56#define NR_IOMMUS 2
57
58/* IOC mmap registers */
59#define IOC_Reg_Size 0x2000
60
61#define IOC_IOPT_CacheInvd 0x908
62#define IOC_IOPT_CacheInvd_NE_Mask 0xffe0000000000000ul
63#define IOC_IOPT_CacheInvd_IOPTE_Mask 0x000003fffffffff8ul
64#define IOC_IOPT_CacheInvd_Busy 0x0000000000000001ul
65
66#define IOC_IOST_Origin 0x918
67#define IOC_IOST_Origin_E 0x8000000000000000ul
68#define IOC_IOST_Origin_HW 0x0000000000000800ul
69#define IOC_IOST_Origin_HL 0x0000000000000400ul
70
71#define IOC_IO_ExcpStat 0x920
72#define IOC_IO_ExcpStat_V 0x8000000000000000ul
73#define IOC_IO_ExcpStat_SPF_Mask 0x6000000000000000ul
74#define IOC_IO_ExcpStat_SPF_S 0x6000000000000000ul
75#define IOC_IO_ExcpStat_SPF_P 0x4000000000000000ul
76#define IOC_IO_ExcpStat_ADDR_Mask 0x00000007fffff000ul
77#define IOC_IO_ExcpStat_RW_Mask 0x0000000000000800ul
78#define IOC_IO_ExcpStat_IOID_Mask 0x00000000000007fful
79
80#define IOC_IO_ExcpMask 0x928
81#define IOC_IO_ExcpMask_SFE 0x4000000000000000ul
82#define IOC_IO_ExcpMask_PFE 0x2000000000000000ul
83
84#define IOC_IOCmd_Offset 0x1000
85
86#define IOC_IOCmd_Cfg 0xc00
87#define IOC_IOCmd_Cfg_TE 0x0000800000000000ul
88
89
90/* Segment table entries */
91#define IOSTE_V 0x8000000000000000ul /* valid */
92#define IOSTE_H 0x4000000000000000ul /* cache hint */
93#define IOSTE_PT_Base_RPN_Mask 0x3ffffffffffff000ul /* base RPN of IOPT */
94#define IOSTE_NPPT_Mask 0x0000000000000fe0ul /* no. pages in IOPT */
95#define IOSTE_PS_Mask 0x0000000000000007ul /* page size */
96#define IOSTE_PS_4K 0x0000000000000001ul /* - 4kB */
97#define IOSTE_PS_64K 0x0000000000000003ul /* - 64kB */
98#define IOSTE_PS_1M 0x0000000000000005ul /* - 1MB */
99#define IOSTE_PS_16M 0x0000000000000007ul /* - 16MB */
100
101/* Page table entries */
102#define IOPTE_PP_W 0x8000000000000000ul /* protection: write */
103#define IOPTE_PP_R 0x4000000000000000ul /* protection: read */
104#define IOPTE_M 0x2000000000000000ul /* coherency required */
105#define IOPTE_SO_R 0x1000000000000000ul /* ordering: writes */
106#define IOPTE_SO_RW 0x1800000000000000ul /* ordering: r & w */
107#define IOPTE_RPN_Mask 0x07fffffffffff000ul /* RPN */
108#define IOPTE_H 0x0000000000000800ul /* cache hint */
109#define IOPTE_IOID_Mask 0x00000000000007fful /* ioid */
110
111
112/* IOMMU sizing */
113#define IO_SEGMENT_SHIFT 28
114#define IO_PAGENO_BITS (IO_SEGMENT_SHIFT - IOMMU_PAGE_SHIFT)
115
116/* The high bit needs to be set on every DMA address */
117#define SPIDER_DMA_OFFSET 0x80000000ul
118
119struct iommu_window {
120 struct list_head list;
121 struct cbe_iommu *iommu;
122 unsigned long offset;
123 unsigned long size;
124 unsigned long pte_offset;
125 unsigned int ioid;
126 struct iommu_table table;
127};
63 128
64static inline ioste 129#define NAMESIZE 8
65mk_ioste(unsigned long val) 130struct cbe_iommu {
66{ 131 int nid;
67 ioste ioste = { .val = val, }; 132 char name[NAMESIZE];
68 return ioste; 133 void __iomem *xlate_regs;
69} 134 void __iomem *cmd_regs;
135 unsigned long *stab;
136 unsigned long *ptab;
137 void *pad_page;
138 struct list_head windows;
139};
140
141/* Static array of iommus, one per node
142 * each contains a list of windows, keyed from dma_window property
143 * - on bus setup, look for a matching window, or create one
144 * - on dev setup, assign iommu_table ptr
145 */
146static struct cbe_iommu iommus[NR_IOMMUS];
147static int cbe_nr_iommus;
70 148
71static inline ioste 149static void invalidate_tce_cache(struct cbe_iommu *iommu, unsigned long *pte,
72get_iost_entry(unsigned long iopt_base, unsigned long io_address, unsigned page_size) 150 long n_ptes)
73{ 151{
74 unsigned long ps; 152 unsigned long *reg, val;
75 unsigned long iostep; 153 long n;
76 unsigned long nnpt;
77 unsigned long shift;
78
79 switch (page_size) {
80 case 0x1000000:
81 ps = IOST_PS_16M;
82 nnpt = 0; /* one page per segment */
83 shift = 5; /* segment has 16 iopt entries */
84 break;
85
86 case 0x100000:
87 ps = IOST_PS_1M;
88 nnpt = 0; /* one page per segment */
89 shift = 1; /* segment has 256 iopt entries */
90 break;
91
92 case 0x10000:
93 ps = IOST_PS_64K;
94 nnpt = 0x07; /* 8 pages per io page table */
95 shift = 0; /* all entries are used */
96 break;
97
98 case 0x1000:
99 ps = IOST_PS_4K;
100 nnpt = 0x7f; /* 128 pages per io page table */
101 shift = 0; /* all entries are used */
102 break;
103
104 default: /* not a known compile time constant */
105 {
106 /* BUILD_BUG_ON() is not usable here */
107 extern void __get_iost_entry_bad_page_size(void);
108 __get_iost_entry_bad_page_size();
109 }
110 break;
111 }
112 154
113 iostep = iopt_base + 155 reg = iommu->xlate_regs + IOC_IOPT_CacheInvd;
114 /* need 8 bytes per iopte */
115 (((io_address / page_size * 8)
116 /* align io page tables on 4k page boundaries */
117 << shift)
118 /* nnpt+1 pages go into each iopt */
119 & ~(nnpt << 12));
120
121 nnpt++; /* this seems to work, but the documentation is not clear
122 about wether we put nnpt or nnpt-1 into the ioste bits.
123 In theory, this can't work for 4k pages. */
124 return mk_ioste(IOST_VALID_MASK
125 | (iostep & IOST_PT_BASE_MASK)
126 | ((nnpt << 5) & IOST_NNPT_MASK)
127 | (ps & IOST_PS_MASK));
128}
129 156
130/* compute the address of an io pte */ 157 while (n_ptes > 0) {
131static inline unsigned long 158 /* we can invalidate up to 1 << 11 PTEs at once */
132get_ioptep(ioste iost_entry, unsigned long io_address) 159 n = min(n_ptes, 1l << 11);
133{ 160 val = (((n /*- 1*/) << 53) & IOC_IOPT_CacheInvd_NE_Mask)
134 unsigned long iopt_base; 161 | (__pa(pte) & IOC_IOPT_CacheInvd_IOPTE_Mask)
135 unsigned long page_size; 162 | IOC_IOPT_CacheInvd_Busy;
136 unsigned long page_number;
137 unsigned long iopt_offset;
138
139 iopt_base = iost_entry.val & IOST_PT_BASE_MASK;
140 page_size = iost_entry.val & IOST_PS_MASK;
141
142 /* decode page size to compute page number */
143 page_number = (io_address & 0x0fffffff) >> (10 + 2 * page_size);
144 /* page number is an offset into the io page table */
145 iopt_offset = (page_number << 3) & 0x7fff8ul;
146 return iopt_base + iopt_offset;
147}
148 163
149/* compute the tag field of the iopt cache entry */ 164 out_be64(reg, val);
150static inline unsigned long 165 while (in_be64(reg) & IOC_IOPT_CacheInvd_Busy)
151get_ioc_tag(ioste iost_entry, unsigned long io_address) 166 ;
152{
153 unsigned long iopte = get_ioptep(iost_entry, io_address);
154 167
155 return IOPT_VALID_MASK 168 n_ptes -= n;
156 | ((iopte & 0x00000000000000ff8ul) >> 3) 169 pte += n;
157 | ((iopte & 0x0000003fffffc0000ul) >> 9); 170 }
158} 171}
159 172
160/* compute the hashed 6 bit index for the 4-way associative pte cache */ 173static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
161static inline unsigned long 174 unsigned long uaddr, enum dma_data_direction direction)
162get_ioc_hash(ioste iost_entry, unsigned long io_address)
163{ 175{
164 unsigned long iopte = get_ioptep(iost_entry, io_address); 176 int i;
165 177 unsigned long *io_pte, base_pte;
166 return ((iopte & 0x000000000000001f8ul) >> 3) 178 struct iommu_window *window =
167 ^ ((iopte & 0x00000000000020000ul) >> 17) 179 container_of(tbl, struct iommu_window, table);
168 ^ ((iopte & 0x00000000000010000ul) >> 15) 180
169 ^ ((iopte & 0x00000000000008000ul) >> 13) 181 /* implementing proper protection causes problems with the spidernet
170 ^ ((iopte & 0x00000000000004000ul) >> 11) 182 * driver - check mapping directions later, but allow read & write by
171 ^ ((iopte & 0x00000000000002000ul) >> 9) 183 * default for now.*/
172 ^ ((iopte & 0x00000000000001000ul) >> 7); 184#ifdef CELL_IOMMU_STRICT_PROTECTION
185 /* to avoid referencing a global, we use a trick here to setup the
186 * protection bit. "prot" is setup to be 3 fields of 4 bits apprended
187 * together for each of the 3 supported direction values. It is then
188 * shifted left so that the fields matching the desired direction
189 * lands on the appropriate bits, and other bits are masked out.
190 */
191 const unsigned long prot = 0xc48;
192 base_pte =
193 ((prot << (52 + 4 * direction)) & (IOPTE_PP_W | IOPTE_PP_R))
194 | IOPTE_M | IOPTE_SO_RW | (window->ioid & IOPTE_IOID_Mask);
195#else
196 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW |
197 (window->ioid & IOPTE_IOID_Mask);
198#endif
199
200 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset);
201
202 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE)
203 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask);
204
205 mb();
206
207 invalidate_tce_cache(window->iommu, io_pte, npages);
208
209 pr_debug("tce_build_cell(index=%lx,n=%lx,dir=%d,base_pte=%lx)\n",
210 index, npages, direction, base_pte);
173} 211}
174 212
175/* same as above, but pretend that we have a simpler 1-way associative 213static void tce_free_cell(struct iommu_table *tbl, long index, long npages)
176 pte cache with an 8 bit index */
177static inline unsigned long
178get_ioc_hash_1way(ioste iost_entry, unsigned long io_address)
179{ 214{
180 unsigned long iopte = get_ioptep(iost_entry, io_address);
181
182 return ((iopte & 0x000000000000001f8ul) >> 3)
183 ^ ((iopte & 0x00000000000020000ul) >> 17)
184 ^ ((iopte & 0x00000000000010000ul) >> 15)
185 ^ ((iopte & 0x00000000000008000ul) >> 13)
186 ^ ((iopte & 0x00000000000004000ul) >> 11)
187 ^ ((iopte & 0x00000000000002000ul) >> 9)
188 ^ ((iopte & 0x00000000000001000ul) >> 7)
189 ^ ((iopte & 0x0000000000000c000ul) >> 8);
190}
191 215
192static inline ioste 216 int i;
193get_iost_cache(void __iomem *base, unsigned long index) 217 unsigned long *io_pte, pte;
194{ 218 struct iommu_window *window =
195 unsigned long __iomem *p = (base + IOC_ST_CACHE_DIR); 219 container_of(tbl, struct iommu_window, table);
196 return mk_ioste(in_be64(&p[index]));
197}
198 220
199static inline void 221 pr_debug("tce_free_cell(index=%lx,n=%lx)\n", index, npages);
200set_iost_cache(void __iomem *base, unsigned long index, ioste ste)
201{
202 unsigned long __iomem *p = (base + IOC_ST_CACHE_DIR);
203 pr_debug("ioste %02lx was %016lx, store %016lx", index,
204 get_iost_cache(base, index).val, ste.val);
205 out_be64(&p[index], ste.val);
206 pr_debug(" now %016lx\n", get_iost_cache(base, index).val);
207}
208 222
209static inline unsigned long 223#ifdef CELL_IOMMU_REAL_UNMAP
210get_iopt_cache(void __iomem *base, unsigned long index, unsigned long *tag) 224 pte = 0;
211{ 225#else
212 unsigned long __iomem *tags = (void *)(base + IOC_PT_CACHE_DIR); 226 /* spider bridge does PCI reads after freeing - insert a mapping
213 unsigned long __iomem *p = (void *)(base + IOC_PT_CACHE_REG); 227 * to a scratch page instead of an invalid entry */
228 pte = IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW | __pa(window->iommu->pad_page)
229 | (window->ioid & IOPTE_IOID_Mask);
230#endif
214 231
215 *tag = tags[index]; 232 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset);
216 rmb();
217 return *p;
218}
219 233
220static inline void 234 for (i = 0; i < npages; i++)
221set_iopt_cache(void __iomem *base, unsigned long index, 235 io_pte[i] = pte;
222 unsigned long tag, unsigned long val) 236
223{ 237 mb();
224 unsigned long __iomem *tags = base + IOC_PT_CACHE_DIR;
225 unsigned long __iomem *p = base + IOC_PT_CACHE_REG;
226 238
227 out_be64(p, val); 239 invalidate_tce_cache(window->iommu, io_pte, npages);
228 out_be64(&tags[index], tag);
229} 240}
230 241
231static inline void 242static irqreturn_t ioc_interrupt(int irq, void *data)
232set_iost_origin(void __iomem *base)
233{ 243{
234 unsigned long __iomem *p = base + IOC_ST_ORIGIN; 244 unsigned long stat;
235 unsigned long origin = IOSTO_ENABLE | IOSTO_SW; 245 struct cbe_iommu *iommu = data;
236 246
237 pr_debug("iost_origin %016lx, now %016lx\n", in_be64(p), origin); 247 stat = in_be64(iommu->xlate_regs + IOC_IO_ExcpStat);
238 out_be64(p, origin); 248
249 /* Might want to rate limit it */
250 printk(KERN_ERR "iommu: DMA exception 0x%016lx\n", stat);
251 printk(KERN_ERR " V=%d, SPF=[%c%c], RW=%s, IOID=0x%04x\n",
252 !!(stat & IOC_IO_ExcpStat_V),
253 (stat & IOC_IO_ExcpStat_SPF_S) ? 'S' : ' ',
254 (stat & IOC_IO_ExcpStat_SPF_P) ? 'P' : ' ',
255 (stat & IOC_IO_ExcpStat_RW_Mask) ? "Read" : "Write",
256 (unsigned int)(stat & IOC_IO_ExcpStat_IOID_Mask));
257 printk(KERN_ERR " page=0x%016lx\n",
258 stat & IOC_IO_ExcpStat_ADDR_Mask);
259
260 /* clear interrupt */
261 stat &= ~IOC_IO_ExcpStat_V;
262 out_be64(iommu->xlate_regs + IOC_IO_ExcpStat, stat);
263
264 return IRQ_HANDLED;
239} 265}
240 266
241static inline void 267static int cell_iommu_find_ioc(int nid, unsigned long *base)
242set_iocmd_config(void __iomem *base)
243{ 268{
244 unsigned long __iomem *p = base + 0xc00; 269 struct device_node *np;
245 unsigned long conf; 270 struct resource r;
271
272 *base = 0;
273
274 /* First look for new style /be nodes */
275 for_each_node_by_name(np, "ioc") {
276 if (of_node_to_nid(np) != nid)
277 continue;
278 if (of_address_to_resource(np, 0, &r)) {
279 printk(KERN_ERR "iommu: can't get address for %s\n",
280 np->full_name);
281 continue;
282 }
283 *base = r.start;
284 of_node_put(np);
285 return 0;
286 }
246 287
247 conf = in_be64(p); 288 /* Ok, let's try the old way */
248 pr_debug("iost_conf %016lx, now %016lx\n", conf, conf | IOCMD_CONF_TE); 289 for_each_node_by_type(np, "cpu") {
249 out_be64(p, conf | IOCMD_CONF_TE); 290 const unsigned int *nidp;
291 const unsigned long *tmp;
292
293 nidp = get_property(np, "node-id", NULL);
294 if (nidp && *nidp == nid) {
295 tmp = get_property(np, "ioc-translation", NULL);
296 if (tmp) {
297 *base = *tmp;
298 of_node_put(np);
299 return 0;
300 }
301 }
302 }
303
304 return -ENODEV;
250} 305}
251 306
252static void enable_mapping(void __iomem *base, void __iomem *mmio_base) 307static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, unsigned long size)
253{ 308{
254 set_iocmd_config(base); 309 struct page *page;
255 set_iost_origin(mmio_base); 310 int ret, i;
256} 311 unsigned long reg, segments, pages_per_segment, ptab_size, n_pte_pages;
312 unsigned long xlate_base;
313 unsigned int virq;
314
315 if (cell_iommu_find_ioc(iommu->nid, &xlate_base))
316 panic("%s: missing IOC register mappings for node %d\n",
317 __FUNCTION__, iommu->nid);
318
319 iommu->xlate_regs = ioremap(xlate_base, IOC_Reg_Size);
320 iommu->cmd_regs = iommu->xlate_regs + IOC_IOCmd_Offset;
321
322 segments = size >> IO_SEGMENT_SHIFT;
323 pages_per_segment = 1ull << IO_PAGENO_BITS;
324
325 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n",
326 __FUNCTION__, iommu->nid, segments, pages_per_segment);
327
328 /* set up the segment table */
329 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0);
330 BUG_ON(!page);
331 iommu->stab = page_address(page);
332 clear_page(iommu->stab);
333
334 /* ... and the page tables. Since these are contiguous, we can treat
335 * the page tables as one array of ptes, like pSeries does.
336 */
337 ptab_size = segments * pages_per_segment * sizeof(unsigned long);
338 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__,
339 iommu->nid, ptab_size, get_order(ptab_size));
340 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size));
341 BUG_ON(!page);
342
343 iommu->ptab = page_address(page);
344 memset(iommu->ptab, 0, ptab_size);
345
346 /* allocate a bogus page for the end of each mapping */
347 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0);
348 BUG_ON(!page);
349 iommu->pad_page = page_address(page);
350 clear_page(iommu->pad_page);
351
352 /* number of pages needed for a page table */
353 n_pte_pages = (pages_per_segment *
354 sizeof(unsigned long)) >> IOMMU_PAGE_SHIFT;
355
356 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n",
357 __FUNCTION__, iommu->nid, iommu->stab, iommu->ptab,
358 n_pte_pages);
359
360 /* initialise the STEs */
361 reg = IOSTE_V | ((n_pte_pages - 1) << 5);
362
363 if (IOMMU_PAGE_SIZE == 0x1000)
364 reg |= IOSTE_PS_4K;
365 else if (IOMMU_PAGE_SIZE == 0x10000)
366 reg |= IOSTE_PS_64K;
367 else {
368 extern void __unknown_page_size_error(void);
369 __unknown_page_size_error();
370 }
371
372 pr_debug("Setting up IOMMU stab:\n");
373 for (i = 0; i * (1ul << IO_SEGMENT_SHIFT) < size; i++) {
374 iommu->stab[i] = reg |
375 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i);
376 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]);
377 }
257 378
258static void iommu_dev_setup_null(struct pci_dev *d) { } 379 /* ensure that the STEs have updated */
259static void iommu_bus_setup_null(struct pci_bus *b) { } 380 mb();
260 381
261struct cell_iommu { 382 /* setup interrupts for the iommu. */
262 unsigned long base; 383 reg = in_be64(iommu->xlate_regs + IOC_IO_ExcpStat);
263 unsigned long mmio_base; 384 out_be64(iommu->xlate_regs + IOC_IO_ExcpStat,
264 void __iomem *mapped_base; 385 reg & ~IOC_IO_ExcpStat_V);
265 void __iomem *mapped_mmio_base; 386 out_be64(iommu->xlate_regs + IOC_IO_ExcpMask,
266}; 387 IOC_IO_ExcpMask_PFE | IOC_IO_ExcpMask_SFE);
267 388
268static struct cell_iommu cell_iommus[NR_CPUS]; 389 virq = irq_create_mapping(NULL,
390 IIC_IRQ_IOEX_ATI | (iommu->nid << IIC_IRQ_NODE_SHIFT));
391 BUG_ON(virq == NO_IRQ);
269 392
270/* initialize the iommu to support a simple linear mapping 393 ret = request_irq(virq, ioc_interrupt, IRQF_DISABLED,
271 * for each DMA window used by any device. For now, we 394 iommu->name, iommu);
272 * happen to know that there is only one DMA window in use, 395 BUG_ON(ret);
273 * starting at iopt_phys_offset. */
274static void cell_do_map_iommu(struct cell_iommu *iommu,
275 unsigned int ioid,
276 unsigned long map_start,
277 unsigned long map_size)
278{
279 unsigned long io_address, real_address;
280 void __iomem *ioc_base, *ioc_mmio_base;
281 ioste ioste;
282 unsigned long index;
283 396
284 /* we pretend the io page table was at a very high address */ 397 /* set the IOC segment table origin register (and turn on the iommu) */
285 const unsigned long fake_iopt = 0x10000000000ul; 398 reg = IOC_IOST_Origin_E | __pa(iommu->stab) | IOC_IOST_Origin_HW;
286 const unsigned long io_page_size = 0x1000000; /* use 16M pages */ 399 out_be64(iommu->xlate_regs + IOC_IOST_Origin, reg);
287 const unsigned long io_segment_size = 0x10000000; /* 256M */ 400 in_be64(iommu->xlate_regs + IOC_IOST_Origin);
288 401
289 ioc_base = iommu->mapped_base; 402 /* turn on IO translation */
290 ioc_mmio_base = iommu->mapped_mmio_base; 403 reg = in_be64(iommu->cmd_regs + IOC_IOCmd_Cfg) | IOC_IOCmd_Cfg_TE;
291 404 out_be64(iommu->cmd_regs + IOC_IOCmd_Cfg, reg);
292 for (real_address = 0, io_address = map_start;
293 io_address <= map_start + map_size;
294 real_address += io_page_size, io_address += io_page_size) {
295 ioste = get_iost_entry(fake_iopt, io_address, io_page_size);
296 if ((real_address % io_segment_size) == 0) /* segment start */
297 set_iost_cache(ioc_mmio_base,
298 io_address >> 28, ioste);
299 index = get_ioc_hash_1way(ioste, io_address);
300 pr_debug("addr %08lx, index %02lx, ioste %016lx\n",
301 io_address, index, ioste.val);
302 set_iopt_cache(ioc_mmio_base,
303 get_ioc_hash_1way(ioste, io_address),
304 get_ioc_tag(ioste, io_address),
305 get_iopt_entry(real_address, ioid, IOPT_PROT_RW));
306 }
307} 405}
308 406
309static void iommu_devnode_setup(struct device_node *d) 407#if 0/* Unused for now */
408static struct iommu_window *find_window(struct cbe_iommu *iommu,
409 unsigned long offset, unsigned long size)
310{ 410{
311 const unsigned int *ioid; 411 struct iommu_window *window;
312 unsigned long map_start, map_size, token;
313 const unsigned long *dma_window;
314 struct cell_iommu *iommu;
315 412
316 ioid = get_property(d, "ioid", NULL); 413 /* todo: check for overlapping (but not equal) windows) */
317 if (!ioid)
318 pr_debug("No ioid entry found !\n");
319 414
320 dma_window = get_property(d, "ibm,dma-window", NULL); 415 list_for_each_entry(window, &(iommu->windows), list) {
321 if (!dma_window) 416 if (window->offset == offset && window->size == size)
322 pr_debug("No ibm,dma-window entry found !\n"); 417 return window;
418 }
323 419
324 map_start = dma_window[1]; 420 return NULL;
325 map_size = dma_window[2]; 421}
326 token = dma_window[0] >> 32; 422#endif
327 423
328 iommu = &cell_iommus[token]; 424static struct iommu_window * __init
425cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
426 unsigned long offset, unsigned long size,
427 unsigned long pte_offset)
428{
429 struct iommu_window *window;
430 const unsigned int *ioid;
329 431
330 cell_do_map_iommu(iommu, *ioid, map_start, map_size); 432 ioid = get_property(np, "ioid", NULL);
433 if (ioid == NULL)
434 printk(KERN_WARNING "iommu: missing ioid for %s using 0\n",
435 np->full_name);
436
437 window = kmalloc_node(sizeof(*window), GFP_KERNEL, iommu->nid);
438 BUG_ON(window == NULL);
439
440 window->offset = offset;
441 window->size = size;
442 window->ioid = ioid ? *ioid : 0;
443 window->iommu = iommu;
444 window->pte_offset = pte_offset;
445
446 window->table.it_blocksize = 16;
447 window->table.it_base = (unsigned long)iommu->ptab;
448 window->table.it_index = iommu->nid;
449 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) +
450 window->pte_offset;
451 window->table.it_size = size >> IOMMU_PAGE_SHIFT;
452
453 iommu_init_table(&window->table, iommu->nid);
454
455 pr_debug("\tioid %d\n", window->ioid);
456 pr_debug("\tblocksize %ld\n", window->table.it_blocksize);
457 pr_debug("\tbase 0x%016lx\n", window->table.it_base);
458 pr_debug("\toffset 0x%lx\n", window->table.it_offset);
459 pr_debug("\tsize %ld\n", window->table.it_size);
460
461 list_add(&window->list, &iommu->windows);
462
463 if (offset != 0)
464 return window;
465
466 /* We need to map and reserve the first IOMMU page since it's used
467 * by the spider workaround. In theory, we only need to do that when
468 * running on spider but it doesn't really matter.
469 *
470 * This code also assumes that we have a window that starts at 0,
471 * which is the case on all spider based blades.
472 */
473 __set_bit(0, window->table.it_map);
474 tce_build_cell(&window->table, window->table.it_offset, 1,
475 (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
476 window->table.it_hint = window->table.it_blocksize;
477
478 return window;
331} 479}
332 480
333static void iommu_bus_setup(struct pci_bus *b) 481static struct cbe_iommu *cell_iommu_for_node(int nid)
334{ 482{
335 struct device_node *d = (struct device_node *)b->sysdata; 483 int i;
336 iommu_devnode_setup(d);
337}
338 484
485 for (i = 0; i < cbe_nr_iommus; i++)
486 if (iommus[i].nid == nid)
487 return &iommus[i];
488 return NULL;
489}
339 490
340static int cell_map_iommu_hardcoded(int num_nodes) 491static void cell_dma_dev_setup(struct device *dev)
341{ 492{
342 struct cell_iommu *iommu = NULL; 493 struct iommu_window *window;
343 494 struct cbe_iommu *iommu;
344 pr_debug("%s(%d): Using hardcoded defaults\n", __FUNCTION__, __LINE__); 495 struct dev_archdata *archdata = &dev->archdata;
496
497 /* If we run without iommu, no need to do anything */
498 if (pci_dma_ops == &dma_direct_ops)
499 return;
500
501 /* Current implementation uses the first window available in that
502 * node's iommu. We -might- do something smarter later though it may
503 * never be necessary
504 */
505 iommu = cell_iommu_for_node(archdata->numa_node);
506 if (iommu == NULL || list_empty(&iommu->windows)) {
507 printk(KERN_ERR "iommu: missing iommu for %s (node %d)\n",
508 archdata->of_node ? archdata->of_node->full_name : "?",
509 archdata->numa_node);
510 return;
511 }
512 window = list_entry(iommu->windows.next, struct iommu_window, list);
345 513
346 /* node 0 */ 514 archdata->dma_data = &window->table;
347 iommu = &cell_iommus[0]; 515}
348 iommu->mapped_base = ioremap(0x20000511000ul, 0x1000);
349 iommu->mapped_mmio_base = ioremap(0x20000510000ul, 0x1000);
350 516
351 enable_mapping(iommu->mapped_base, iommu->mapped_mmio_base); 517static void cell_pci_dma_dev_setup(struct pci_dev *dev)
518{
519 cell_dma_dev_setup(&dev->dev);
520}
352 521
353 cell_do_map_iommu(iommu, 0x048a, 522static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,
354 0x20000000ul,0x20000000ul); 523 void *data)
524{
525 struct device *dev = data;
355 526
356 if (num_nodes < 2) 527 /* We are only intereted in device addition */
528 if (action != BUS_NOTIFY_ADD_DEVICE)
357 return 0; 529 return 0;
358 530
359 /* node 1 */ 531 /* We use the PCI DMA ops */
360 iommu = &cell_iommus[1]; 532 dev->archdata.dma_ops = pci_dma_ops;
361 iommu->mapped_base = ioremap(0x30000511000ul, 0x1000);
362 iommu->mapped_mmio_base = ioremap(0x30000510000ul, 0x1000);
363
364 enable_mapping(iommu->mapped_base, iommu->mapped_mmio_base);
365 533
366 cell_do_map_iommu(iommu, 0x048a, 534 cell_dma_dev_setup(dev);
367 0x20000000,0x20000000ul);
368 535
369 return 0; 536 return 0;
370} 537}
371 538
539static struct notifier_block cell_of_bus_notifier = {
540 .notifier_call = cell_of_bus_notify
541};
372 542
373static int cell_map_iommu(void) 543static int __init cell_iommu_get_window(struct device_node *np,
544 unsigned long *base,
545 unsigned long *size)
374{ 546{
375 unsigned int num_nodes = 0; 547 const void *dma_window;
376 const unsigned int *node_id; 548 unsigned long index;
377 const unsigned long *base, *mmio_base;
378 struct device_node *dn;
379 struct cell_iommu *iommu = NULL;
380
381 /* determine number of nodes (=iommus) */
382 pr_debug("%s(%d): determining number of nodes...", __FUNCTION__, __LINE__);
383 for(dn = of_find_node_by_type(NULL, "cpu");
384 dn;
385 dn = of_find_node_by_type(dn, "cpu")) {
386 node_id = get_property(dn, "node-id", NULL);
387
388 if (num_nodes < *node_id)
389 num_nodes = *node_id;
390 }
391
392 num_nodes++;
393 pr_debug("%i found.\n", num_nodes);
394 549
395 /* map the iommu registers for each node */ 550 /* Use ibm,dma-window if available, else, hard code ! */
396 pr_debug("%s(%d): Looping through nodes\n", __FUNCTION__, __LINE__); 551 dma_window = get_property(np, "ibm,dma-window", NULL);
397 for(dn = of_find_node_by_type(NULL, "cpu"); 552 if (dma_window == NULL) {
398 dn; 553 *base = 0;
399 dn = of_find_node_by_type(dn, "cpu")) { 554 *size = 0x80000000u;
555 return -ENODEV;
556 }
400 557
401 node_id = get_property(dn, "node-id", NULL); 558 of_parse_dma_window(np, dma_window, &index, base, size);
402 base = get_property(dn, "ioc-cache", NULL); 559 return 0;
403 mmio_base = get_property(dn, "ioc-translation", NULL); 560}
404 561
405 if (!base || !mmio_base || !node_id) 562static void __init cell_iommu_init_one(struct device_node *np, unsigned long offset)
406 return cell_map_iommu_hardcoded(num_nodes); 563{
564 struct cbe_iommu *iommu;
565 unsigned long base, size;
566 int nid, i;
567
568 /* Get node ID */
569 nid = of_node_to_nid(np);
570 if (nid < 0) {
571 printk(KERN_ERR "iommu: failed to get node for %s\n",
572 np->full_name);
573 return;
574 }
575 pr_debug("iommu: setting up iommu for node %d (%s)\n",
576 nid, np->full_name);
577
578 /* XXX todo: If we can have multiple windows on the same IOMMU, which
579 * isn't the case today, we probably want here to check wether the
580 * iommu for that node is already setup.
581 * However, there might be issue with getting the size right so let's
582 * ignore that for now. We might want to completely get rid of the
583 * multiple window support since the cell iommu supports per-page ioids
584 */
585
586 if (cbe_nr_iommus >= NR_IOMMUS) {
587 printk(KERN_ERR "iommu: too many IOMMUs detected ! (%s)\n",
588 np->full_name);
589 return;
590 }
407 591
408 iommu = &cell_iommus[*node_id]; 592 /* Init base fields */
409 iommu->base = *base; 593 i = cbe_nr_iommus++;
410 iommu->mmio_base = *mmio_base; 594 iommu = &iommus[i];
595 iommu->stab = 0;
596 iommu->nid = nid;
597 snprintf(iommu->name, sizeof(iommu->name), "iommu%d", i);
598 INIT_LIST_HEAD(&iommu->windows);
411 599
412 iommu->mapped_base = ioremap(*base, 0x1000); 600 /* Obtain a window for it */
413 iommu->mapped_mmio_base = ioremap(*mmio_base, 0x1000); 601 cell_iommu_get_window(np, &base, &size);
414 602
415 enable_mapping(iommu->mapped_base, 603 pr_debug("\ttranslating window 0x%lx...0x%lx\n",
416 iommu->mapped_mmio_base); 604 base, base + size - 1);
417 605
418 /* everything else will be done in iommu_bus_setup */ 606 /* Initialize the hardware */
419 } 607 cell_iommu_setup_hardware(iommu, size);
420 608
421 return 1; 609 /* Setup the iommu_table */
610 cell_iommu_setup_window(iommu, np, base, size,
611 offset >> IOMMU_PAGE_SHIFT);
422} 612}
423 613
424static void *cell_alloc_coherent(struct device *hwdev, size_t size, 614static void __init cell_disable_iommus(void)
425 dma_addr_t *dma_handle, gfp_t flag)
426{ 615{
427 void *ret; 616 int node;
428 617 unsigned long base, val;
429 ret = (void *)__get_free_pages(flag, get_order(size)); 618 void __iomem *xregs, *cregs;
430 if (ret != NULL) { 619
431 memset(ret, 0, size); 620 /* Make sure IOC translation is disabled on all nodes */
432 *dma_handle = virt_to_abs(ret) | CELL_DMA_VALID; 621 for_each_online_node(node) {
622 if (cell_iommu_find_ioc(node, &base))
623 continue;
624 xregs = ioremap(base, IOC_Reg_Size);
625 if (xregs == NULL)
626 continue;
627 cregs = xregs + IOC_IOCmd_Offset;
628
629 pr_debug("iommu: cleaning up iommu on node %d\n", node);
630
631 out_be64(xregs + IOC_IOST_Origin, 0);
632 (void)in_be64(xregs + IOC_IOST_Origin);
633 val = in_be64(cregs + IOC_IOCmd_Cfg);
634 val &= ~IOC_IOCmd_Cfg_TE;
635 out_be64(cregs + IOC_IOCmd_Cfg, val);
636 (void)in_be64(cregs + IOC_IOCmd_Cfg);
637
638 iounmap(xregs);
433 } 639 }
434 return ret;
435} 640}
436 641
437static void cell_free_coherent(struct device *hwdev, size_t size, 642static int __init cell_iommu_init_disabled(void)
438 void *vaddr, dma_addr_t dma_handle)
439{ 643{
440 free_pages((unsigned long)vaddr, get_order(size)); 644 struct device_node *np = NULL;
441} 645 unsigned long base = 0, size;
646
647 /* When no iommu is present, we use direct DMA ops */
648 pci_dma_ops = &dma_direct_ops;
649
650 /* First make sure all IOC translation is turned off */
651 cell_disable_iommus();
652
653 /* If we have no Axon, we set up the spider DMA magic offset */
654 if (of_find_node_by_name(NULL, "axon") == NULL)
655 dma_direct_offset = SPIDER_DMA_OFFSET;
656
657 /* Now we need to check to see where the memory is mapped
658 * in PCI space. We assume that all busses use the same dma
659 * window which is always the case so far on Cell, thus we
660 * pick up the first pci-internal node we can find and check
661 * the DMA window from there.
662 */
663 for_each_node_by_name(np, "axon") {
664 if (np->parent == NULL || np->parent->parent != NULL)
665 continue;
666 if (cell_iommu_get_window(np, &base, &size) == 0)
667 break;
668 }
669 if (np == NULL) {
670 for_each_node_by_name(np, "pci-internal") {
671 if (np->parent == NULL || np->parent->parent != NULL)
672 continue;
673 if (cell_iommu_get_window(np, &base, &size) == 0)
674 break;
675 }
676 }
677 of_node_put(np);
678
679 /* If we found a DMA window, we check if it's big enough to enclose
680 * all of physical memory. If not, we force enable IOMMU
681 */
682 if (np && size < lmb_end_of_DRAM()) {
683 printk(KERN_WARNING "iommu: force-enabled, dma window"
684 " (%ldMB) smaller than total memory (%ldMB)\n",
685 size >> 20, lmb_end_of_DRAM() >> 20);
686 return -ENODEV;
687 }
442 688
443static dma_addr_t cell_map_single(struct device *hwdev, void *ptr, 689 dma_direct_offset += base;
444 size_t size, enum dma_data_direction direction)
445{
446 return virt_to_abs(ptr) | CELL_DMA_VALID;
447}
448 690
449static void cell_unmap_single(struct device *hwdev, dma_addr_t dma_addr, 691 printk("iommu: disabled, direct DMA offset is 0x%lx\n",
450 size_t size, enum dma_data_direction direction) 692 dma_direct_offset);
451{ 693
694 return 0;
452} 695}
453 696
454static int cell_map_sg(struct device *hwdev, struct scatterlist *sg, 697static int __init cell_iommu_init(void)
455 int nents, enum dma_data_direction direction)
456{ 698{
457 int i; 699 struct device_node *np;
700
701 if (!machine_is(cell))
702 return -ENODEV;
703
704 /* If IOMMU is disabled or we have little enough RAM to not need
705 * to enable it, we setup a direct mapping.
706 *
707 * Note: should we make sure we have the IOMMU actually disabled ?
708 */
709 if (iommu_is_off ||
710 (!iommu_force_on && lmb_end_of_DRAM() <= 0x80000000ull))
711 if (cell_iommu_init_disabled() == 0)
712 goto bail;
713
714 /* Setup various ppc_md. callbacks */
715 ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup;
716 ppc_md.tce_build = tce_build_cell;
717 ppc_md.tce_free = tce_free_cell;
718
719 /* Create an iommu for each /axon node. */
720 for_each_node_by_name(np, "axon") {
721 if (np->parent == NULL || np->parent->parent != NULL)
722 continue;
723 cell_iommu_init_one(np, 0);
724 }
458 725
459 for (i = 0; i < nents; i++, sg++) { 726 /* Create an iommu for each toplevel /pci-internal node for
460 sg->dma_address = (page_to_phys(sg->page) + sg->offset) 727 * old hardware/firmware
461 | CELL_DMA_VALID; 728 */
462 sg->dma_length = sg->length; 729 for_each_node_by_name(np, "pci-internal") {
730 if (np->parent == NULL || np->parent->parent != NULL)
731 continue;
732 cell_iommu_init_one(np, SPIDER_DMA_OFFSET);
463 } 733 }
464 734
465 return nents; 735 /* Setup default PCI iommu ops */
466} 736 pci_dma_ops = &dma_iommu_ops;
467 737
468static void cell_unmap_sg(struct device *hwdev, struct scatterlist *sg, 738 bail:
469 int nents, enum dma_data_direction direction) 739 /* Register callbacks on OF platform device addition/removal
470{ 740 * to handle linking them to the right DMA operations
471} 741 */
742 bus_register_notifier(&of_platform_bus_type, &cell_of_bus_notifier);
472 743
473static int cell_dma_supported(struct device *dev, u64 mask) 744 return 0;
474{
475 return mask < 0x100000000ull;
476} 745}
746arch_initcall(cell_iommu_init);
477 747
478static struct dma_mapping_ops cell_iommu_ops = {
479 .alloc_coherent = cell_alloc_coherent,
480 .free_coherent = cell_free_coherent,
481 .map_single = cell_map_single,
482 .unmap_single = cell_unmap_single,
483 .map_sg = cell_map_sg,
484 .unmap_sg = cell_unmap_sg,
485 .dma_supported = cell_dma_supported,
486};
487
488void cell_init_iommu(void)
489{
490 int setup_bus = 0;
491
492 if (of_find_node_by_path("/mambo")) {
493 pr_info("Not using iommu on systemsim\n");
494 } else {
495
496 if (!(of_chosen &&
497 get_property(of_chosen, "linux,iommu-off", NULL)))
498 setup_bus = cell_map_iommu();
499
500 if (setup_bus) {
501 pr_debug("%s: IOMMU mapping activated\n", __FUNCTION__);
502 ppc_md.iommu_dev_setup = iommu_dev_setup_null;
503 ppc_md.iommu_bus_setup = iommu_bus_setup;
504 } else {
505 pr_debug("%s: IOMMU mapping activated, "
506 "no device action necessary\n", __FUNCTION__);
507 /* Direct I/O, IOMMU off */
508 ppc_md.iommu_dev_setup = iommu_dev_setup_null;
509 ppc_md.iommu_bus_setup = iommu_bus_setup_null;
510 }
511 }
512
513 pci_dma_ops = cell_iommu_ops;
514}
diff --git a/arch/powerpc/platforms/cell/iommu.h b/arch/powerpc/platforms/cell/iommu.h
deleted file mode 100644
index 490d77abfe85..000000000000
--- a/arch/powerpc/platforms/cell/iommu.h
+++ /dev/null
@@ -1,65 +0,0 @@
1#ifndef CELL_IOMMU_H
2#define CELL_IOMMU_H
3
4/* some constants */
5enum {
6 /* segment table entries */
7 IOST_VALID_MASK = 0x8000000000000000ul,
8 IOST_TAG_MASK = 0x3000000000000000ul,
9 IOST_PT_BASE_MASK = 0x000003fffffff000ul,
10 IOST_NNPT_MASK = 0x0000000000000fe0ul,
11 IOST_PS_MASK = 0x000000000000000ful,
12
13 IOST_PS_4K = 0x1,
14 IOST_PS_64K = 0x3,
15 IOST_PS_1M = 0x5,
16 IOST_PS_16M = 0x7,
17
18 /* iopt tag register */
19 IOPT_VALID_MASK = 0x0000000200000000ul,
20 IOPT_TAG_MASK = 0x00000001fffffffful,
21
22 /* iopt cache register */
23 IOPT_PROT_MASK = 0xc000000000000000ul,
24 IOPT_PROT_NONE = 0x0000000000000000ul,
25 IOPT_PROT_READ = 0x4000000000000000ul,
26 IOPT_PROT_WRITE = 0x8000000000000000ul,
27 IOPT_PROT_RW = 0xc000000000000000ul,
28 IOPT_COHERENT = 0x2000000000000000ul,
29
30 IOPT_ORDER_MASK = 0x1800000000000000ul,
31 /* order access to same IOID/VC on same address */
32 IOPT_ORDER_ADDR = 0x0800000000000000ul,
33 /* similar, but only after a write access */
34 IOPT_ORDER_WRITES = 0x1000000000000000ul,
35 /* Order all accesses to same IOID/VC */
36 IOPT_ORDER_VC = 0x1800000000000000ul,
37
38 IOPT_RPN_MASK = 0x000003fffffff000ul,
39 IOPT_HINT_MASK = 0x0000000000000800ul,
40 IOPT_IOID_MASK = 0x00000000000007fful,
41
42 IOSTO_ENABLE = 0x8000000000000000ul,
43 IOSTO_ORIGIN = 0x000003fffffff000ul,
44 IOSTO_HW = 0x0000000000000800ul,
45 IOSTO_SW = 0x0000000000000400ul,
46
47 IOCMD_CONF_TE = 0x0000800000000000ul,
48
49 /* memory mapped registers */
50 IOC_PT_CACHE_DIR = 0x000,
51 IOC_ST_CACHE_DIR = 0x800,
52 IOC_PT_CACHE_REG = 0x910,
53 IOC_ST_ORIGIN = 0x918,
54 IOC_CONF = 0x930,
55
56 /* The high bit needs to be set on every DMA address,
57 only 2GB are addressable */
58 CELL_DMA_VALID = 0x80000000,
59 CELL_DMA_MASK = 0x7fffffff,
60};
61
62
63void cell_init_iommu(void);
64
65#endif
diff --git a/arch/powerpc/platforms/cell/pervasive.c b/arch/powerpc/platforms/cell/pervasive.c
index 9f2e4ed20a57..8c20f0fb8651 100644
--- a/arch/powerpc/platforms/cell/pervasive.c
+++ b/arch/powerpc/platforms/cell/pervasive.c
@@ -38,32 +38,25 @@
38#include "pervasive.h" 38#include "pervasive.h"
39#include "cbe_regs.h" 39#include "cbe_regs.h"
40 40
41static DEFINE_SPINLOCK(cbe_pervasive_lock); 41static void cbe_power_save(void)
42
43static void __init cbe_enable_pause_zero(void)
44{ 42{
45 unsigned long thread_switch_control; 43 unsigned long ctrl, thread_switch_control;
46 unsigned long temp_register;
47 struct cbe_pmd_regs __iomem *pregs;
48
49 spin_lock_irq(&cbe_pervasive_lock);
50 pregs = cbe_get_cpu_pmd_regs(smp_processor_id());
51 if (pregs == NULL)
52 goto out;
53 44
54 pr_debug("Power Management: CPU %d\n", smp_processor_id()); 45 /*
55 46 * We need to hard disable interrupts, but we also need to mark them
56 /* Enable Pause(0) control bit */ 47 * hard disabled in the PACA so that the local_irq_enable() done by
57 temp_register = in_be64(&pregs->pm_control); 48 * our caller upon return propertly hard enables.
49 */
50 hard_irq_disable();
51 get_paca()->hard_enabled = 0;
58 52
59 out_be64(&pregs->pm_control, 53 ctrl = mfspr(SPRN_CTRLF);
60 temp_register | CBE_PMD_PAUSE_ZERO_CONTROL);
61 54
62 /* Enable DEC and EE interrupt request */ 55 /* Enable DEC and EE interrupt request */
63 thread_switch_control = mfspr(SPRN_TSC_CELL); 56 thread_switch_control = mfspr(SPRN_TSC_CELL);
64 thread_switch_control |= TSC_CELL_EE_ENABLE | TSC_CELL_EE_BOOST; 57 thread_switch_control |= TSC_CELL_EE_ENABLE | TSC_CELL_EE_BOOST;
65 58
66 switch ((mfspr(SPRN_CTRLF) & CTRL_CT)) { 59 switch (ctrl & CTRL_CT) {
67 case CTRL_CT0: 60 case CTRL_CT0:
68 thread_switch_control |= TSC_CELL_DEC_ENABLE_0; 61 thread_switch_control |= TSC_CELL_DEC_ENABLE_0;
69 break; 62 break;
@@ -75,58 +68,21 @@ static void __init cbe_enable_pause_zero(void)
75 __FUNCTION__); 68 __FUNCTION__);
76 break; 69 break;
77 } 70 }
78
79 mtspr(SPRN_TSC_CELL, thread_switch_control); 71 mtspr(SPRN_TSC_CELL, thread_switch_control);
80 72
81out: 73 /*
82 spin_unlock_irq(&cbe_pervasive_lock); 74 * go into low thread priority, medium priority will be
83} 75 * restored for us after wake-up.
84 76 */
85static void cbe_idle(void) 77 HMT_low();
86{
87 unsigned long ctrl;
88 78
89 /* Why do we do that on every idle ? Couldn't that be done once for 79 /*
90 * all or do we lose the state some way ? Also, the pm_control 80 * atomically disable thread execution and runlatch.
91 * register setting, that can't be set once at boot ? We really want 81 * External and Decrementer exceptions are still handled when the
92 * to move that away in order to implement a simple powersave 82 * thread is disabled but now enter in cbe_system_reset_exception()
93 */ 83 */
94 cbe_enable_pause_zero(); 84 ctrl &= ~(CTRL_RUNLATCH | CTRL_TE);
95 85 mtspr(SPRN_CTRLT, ctrl);
96 while (1) {
97 if (!need_resched()) {
98 local_irq_disable();
99 while (!need_resched()) {
100 /* go into low thread priority */
101 HMT_low();
102
103 /*
104 * atomically disable thread execution
105 * and runlatch.
106 * External and Decrementer exceptions
107 * are still handled when the thread
108 * is disabled but now enter in
109 * cbe_system_reset_exception()
110 */
111 ctrl = mfspr(SPRN_CTRLF);
112 ctrl &= ~(CTRL_RUNLATCH | CTRL_TE);
113 mtspr(SPRN_CTRLT, ctrl);
114 }
115 /* restore thread prio */
116 HMT_medium();
117 local_irq_enable();
118 }
119
120 /*
121 * turn runlatch on again before scheduling the
122 * process we just woke up
123 */
124 ppc64_runlatch_on();
125
126 preempt_enable_no_resched();
127 schedule();
128 preempt_disable();
129 }
130} 86}
131 87
132static int cbe_system_reset_exception(struct pt_regs *regs) 88static int cbe_system_reset_exception(struct pt_regs *regs)
@@ -158,9 +114,20 @@ static int cbe_system_reset_exception(struct pt_regs *regs)
158 114
159void __init cbe_pervasive_init(void) 115void __init cbe_pervasive_init(void)
160{ 116{
117 int cpu;
161 if (!cpu_has_feature(CPU_FTR_PAUSE_ZERO)) 118 if (!cpu_has_feature(CPU_FTR_PAUSE_ZERO))
162 return; 119 return;
163 120
164 ppc_md.idle_loop = cbe_idle; 121 for_each_possible_cpu(cpu) {
122 struct cbe_pmd_regs __iomem *regs = cbe_get_cpu_pmd_regs(cpu);
123 if (!regs)
124 continue;
125
126 /* Enable Pause(0) control bit */
127 out_be64(&regs->pmcr, in_be64(&regs->pmcr) |
128 CBE_PMD_PAUSE_ZERO_CONTROL);
129 }
130
131 ppc_md.power_save = cbe_power_save;
165 ppc_md.system_reset_exception = cbe_system_reset_exception; 132 ppc_md.system_reset_exception = cbe_system_reset_exception;
166} 133}
diff --git a/arch/powerpc/platforms/cell/pmu.c b/arch/powerpc/platforms/cell/pmu.c
new file mode 100644
index 000000000000..99c612025e8f
--- /dev/null
+++ b/arch/powerpc/platforms/cell/pmu.c
@@ -0,0 +1,429 @@
1/*
2 * Cell Broadband Engine Performance Monitor
3 *
4 * (C) Copyright IBM Corporation 2001,2006
5 *
6 * Author:
7 * David Erb (djerb@us.ibm.com)
8 * Kevin Corry (kevcorry@us.ibm.com)
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, or (at your option)
13 * 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#include <linux/interrupt.h>
26#include <linux/types.h>
27#include <asm/io.h>
28#include <asm/irq_regs.h>
29#include <asm/machdep.h>
30#include <asm/pmc.h>
31#include <asm/reg.h>
32#include <asm/spu.h>
33
34#include "cbe_regs.h"
35#include "interrupt.h"
36
37/*
38 * When writing to write-only mmio addresses, save a shadow copy. All of the
39 * registers are 32-bit, but stored in the upper-half of a 64-bit field in
40 * pmd_regs.
41 */
42
43#define WRITE_WO_MMIO(reg, x) \
44 do { \
45 u32 _x = (x); \
46 struct cbe_pmd_regs __iomem *pmd_regs; \
47 struct cbe_pmd_shadow_regs *shadow_regs; \
48 pmd_regs = cbe_get_cpu_pmd_regs(cpu); \
49 shadow_regs = cbe_get_cpu_pmd_shadow_regs(cpu); \
50 out_be64(&(pmd_regs->reg), (((u64)_x) << 32)); \
51 shadow_regs->reg = _x; \
52 } while (0)
53
54#define READ_SHADOW_REG(val, reg) \
55 do { \
56 struct cbe_pmd_shadow_regs *shadow_regs; \
57 shadow_regs = cbe_get_cpu_pmd_shadow_regs(cpu); \
58 (val) = shadow_regs->reg; \
59 } while (0)
60
61#define READ_MMIO_UPPER32(val, reg) \
62 do { \
63 struct cbe_pmd_regs __iomem *pmd_regs; \
64 pmd_regs = cbe_get_cpu_pmd_regs(cpu); \
65 (val) = (u32)(in_be64(&pmd_regs->reg) >> 32); \
66 } while (0)
67
68/*
69 * Physical counter registers.
70 * Each physical counter can act as one 32-bit counter or two 16-bit counters.
71 */
72
73u32 cbe_read_phys_ctr(u32 cpu, u32 phys_ctr)
74{
75 u32 val_in_latch, val = 0;
76
77 if (phys_ctr < NR_PHYS_CTRS) {
78 READ_SHADOW_REG(val_in_latch, counter_value_in_latch);
79
80 /* Read the latch or the actual counter, whichever is newer. */
81 if (val_in_latch & (1 << phys_ctr)) {
82 READ_SHADOW_REG(val, pm_ctr[phys_ctr]);
83 } else {
84 READ_MMIO_UPPER32(val, pm_ctr[phys_ctr]);
85 }
86 }
87
88 return val;
89}
90EXPORT_SYMBOL_GPL(cbe_read_phys_ctr);
91
92void cbe_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val)
93{
94 struct cbe_pmd_shadow_regs *shadow_regs;
95 u32 pm_ctrl;
96
97 if (phys_ctr < NR_PHYS_CTRS) {
98 /* Writing to a counter only writes to a hardware latch.
99 * The new value is not propagated to the actual counter
100 * until the performance monitor is enabled.
101 */
102 WRITE_WO_MMIO(pm_ctr[phys_ctr], val);
103
104 pm_ctrl = cbe_read_pm(cpu, pm_control);
105 if (pm_ctrl & CBE_PM_ENABLE_PERF_MON) {
106 /* The counters are already active, so we need to
107 * rewrite the pm_control register to "re-enable"
108 * the PMU.
109 */
110 cbe_write_pm(cpu, pm_control, pm_ctrl);
111 } else {
112 shadow_regs = cbe_get_cpu_pmd_shadow_regs(cpu);
113 shadow_regs->counter_value_in_latch |= (1 << phys_ctr);
114 }
115 }
116}
117EXPORT_SYMBOL_GPL(cbe_write_phys_ctr);
118
119/*
120 * "Logical" counter registers.
121 * These will read/write 16-bits or 32-bits depending on the
122 * current size of the counter. Counters 4 - 7 are always 16-bit.
123 */
124
125u32 cbe_read_ctr(u32 cpu, u32 ctr)
126{
127 u32 val;
128 u32 phys_ctr = ctr & (NR_PHYS_CTRS - 1);
129
130 val = cbe_read_phys_ctr(cpu, phys_ctr);
131
132 if (cbe_get_ctr_size(cpu, phys_ctr) == 16)
133 val = (ctr < NR_PHYS_CTRS) ? (val >> 16) : (val & 0xffff);
134
135 return val;
136}
137EXPORT_SYMBOL_GPL(cbe_read_ctr);
138
139void cbe_write_ctr(u32 cpu, u32 ctr, u32 val)
140{
141 u32 phys_ctr;
142 u32 phys_val;
143
144 phys_ctr = ctr & (NR_PHYS_CTRS - 1);
145
146 if (cbe_get_ctr_size(cpu, phys_ctr) == 16) {
147 phys_val = cbe_read_phys_ctr(cpu, phys_ctr);
148
149 if (ctr < NR_PHYS_CTRS)
150 val = (val << 16) | (phys_val & 0xffff);
151 else
152 val = (val & 0xffff) | (phys_val & 0xffff0000);
153 }
154
155 cbe_write_phys_ctr(cpu, phys_ctr, val);
156}
157EXPORT_SYMBOL_GPL(cbe_write_ctr);
158
159/*
160 * Counter-control registers.
161 * Each "logical" counter has a corresponding control register.
162 */
163
164u32 cbe_read_pm07_control(u32 cpu, u32 ctr)
165{
166 u32 pm07_control = 0;
167
168 if (ctr < NR_CTRS)
169 READ_SHADOW_REG(pm07_control, pm07_control[ctr]);
170
171 return pm07_control;
172}
173EXPORT_SYMBOL_GPL(cbe_read_pm07_control);
174
175void cbe_write_pm07_control(u32 cpu, u32 ctr, u32 val)
176{
177 if (ctr < NR_CTRS)
178 WRITE_WO_MMIO(pm07_control[ctr], val);
179}
180EXPORT_SYMBOL_GPL(cbe_write_pm07_control);
181
182/*
183 * Other PMU control registers. Most of these are write-only.
184 */
185
186u32 cbe_read_pm(u32 cpu, enum pm_reg_name reg)
187{
188 u32 val = 0;
189
190 switch (reg) {
191 case group_control:
192 READ_SHADOW_REG(val, group_control);
193 break;
194
195 case debug_bus_control:
196 READ_SHADOW_REG(val, debug_bus_control);
197 break;
198
199 case trace_address:
200 READ_MMIO_UPPER32(val, trace_address);
201 break;
202
203 case ext_tr_timer:
204 READ_SHADOW_REG(val, ext_tr_timer);
205 break;
206
207 case pm_status:
208 READ_MMIO_UPPER32(val, pm_status);
209 break;
210
211 case pm_control:
212 READ_SHADOW_REG(val, pm_control);
213 break;
214
215 case pm_interval:
216 READ_SHADOW_REG(val, pm_interval);
217 break;
218
219 case pm_start_stop:
220 READ_SHADOW_REG(val, pm_start_stop);
221 break;
222 }
223
224 return val;
225}
226EXPORT_SYMBOL_GPL(cbe_read_pm);
227
228void cbe_write_pm(u32 cpu, enum pm_reg_name reg, u32 val)
229{
230 switch (reg) {
231 case group_control:
232 WRITE_WO_MMIO(group_control, val);
233 break;
234
235 case debug_bus_control:
236 WRITE_WO_MMIO(debug_bus_control, val);
237 break;
238
239 case trace_address:
240 WRITE_WO_MMIO(trace_address, val);
241 break;
242
243 case ext_tr_timer:
244 WRITE_WO_MMIO(ext_tr_timer, val);
245 break;
246
247 case pm_status:
248 WRITE_WO_MMIO(pm_status, val);
249 break;
250
251 case pm_control:
252 WRITE_WO_MMIO(pm_control, val);
253 break;
254
255 case pm_interval:
256 WRITE_WO_MMIO(pm_interval, val);
257 break;
258
259 case pm_start_stop:
260 WRITE_WO_MMIO(pm_start_stop, val);
261 break;
262 }
263}
264EXPORT_SYMBOL_GPL(cbe_write_pm);
265
266/*
267 * Get/set the size of a physical counter to either 16 or 32 bits.
268 */
269
270u32 cbe_get_ctr_size(u32 cpu, u32 phys_ctr)
271{
272 u32 pm_ctrl, size = 0;
273
274 if (phys_ctr < NR_PHYS_CTRS) {
275 pm_ctrl = cbe_read_pm(cpu, pm_control);
276 size = (pm_ctrl & CBE_PM_16BIT_CTR(phys_ctr)) ? 16 : 32;
277 }
278
279 return size;
280}
281EXPORT_SYMBOL_GPL(cbe_get_ctr_size);
282
283void cbe_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size)
284{
285 u32 pm_ctrl;
286
287 if (phys_ctr < NR_PHYS_CTRS) {
288 pm_ctrl = cbe_read_pm(cpu, pm_control);
289 switch (ctr_size) {
290 case 16:
291 pm_ctrl |= CBE_PM_16BIT_CTR(phys_ctr);
292 break;
293
294 case 32:
295 pm_ctrl &= ~CBE_PM_16BIT_CTR(phys_ctr);
296 break;
297 }
298 cbe_write_pm(cpu, pm_control, pm_ctrl);
299 }
300}
301EXPORT_SYMBOL_GPL(cbe_set_ctr_size);
302
303/*
304 * Enable/disable the entire performance monitoring unit.
305 * When we enable the PMU, all pending writes to counters get committed.
306 */
307
308void cbe_enable_pm(u32 cpu)
309{
310 struct cbe_pmd_shadow_regs *shadow_regs;
311 u32 pm_ctrl;
312
313 shadow_regs = cbe_get_cpu_pmd_shadow_regs(cpu);
314 shadow_regs->counter_value_in_latch = 0;
315
316 pm_ctrl = cbe_read_pm(cpu, pm_control) | CBE_PM_ENABLE_PERF_MON;
317 cbe_write_pm(cpu, pm_control, pm_ctrl);
318}
319EXPORT_SYMBOL_GPL(cbe_enable_pm);
320
321void cbe_disable_pm(u32 cpu)
322{
323 u32 pm_ctrl;
324 pm_ctrl = cbe_read_pm(cpu, pm_control) & ~CBE_PM_ENABLE_PERF_MON;
325 cbe_write_pm(cpu, pm_control, pm_ctrl);
326}
327EXPORT_SYMBOL_GPL(cbe_disable_pm);
328
329/*
330 * Reading from the trace_buffer.
331 * The trace buffer is two 64-bit registers. Reading from
332 * the second half automatically increments the trace_address.
333 */
334
335void cbe_read_trace_buffer(u32 cpu, u64 *buf)
336{
337 struct cbe_pmd_regs __iomem *pmd_regs = cbe_get_cpu_pmd_regs(cpu);
338
339 *buf++ = in_be64(&pmd_regs->trace_buffer_0_63);
340 *buf++ = in_be64(&pmd_regs->trace_buffer_64_127);
341}
342EXPORT_SYMBOL_GPL(cbe_read_trace_buffer);
343
344/*
345 * Enabling/disabling interrupts for the entire performance monitoring unit.
346 */
347
348u32 cbe_query_pm_interrupts(u32 cpu)
349{
350 return cbe_read_pm(cpu, pm_status);
351}
352EXPORT_SYMBOL_GPL(cbe_query_pm_interrupts);
353
354u32 cbe_clear_pm_interrupts(u32 cpu)
355{
356 /* Reading pm_status clears the interrupt bits. */
357 return cbe_query_pm_interrupts(cpu);
358}
359EXPORT_SYMBOL_GPL(cbe_clear_pm_interrupts);
360
361void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask)
362{
363 /* Set which node and thread will handle the next interrupt. */
364 iic_set_interrupt_routing(cpu, thread, 0);
365
366 /* Enable the interrupt bits in the pm_status register. */
367 if (mask)
368 cbe_write_pm(cpu, pm_status, mask);
369}
370EXPORT_SYMBOL_GPL(cbe_enable_pm_interrupts);
371
372void cbe_disable_pm_interrupts(u32 cpu)
373{
374 cbe_clear_pm_interrupts(cpu);
375 cbe_write_pm(cpu, pm_status, 0);
376}
377EXPORT_SYMBOL_GPL(cbe_disable_pm_interrupts);
378
379static irqreturn_t cbe_pm_irq(int irq, void *dev_id)
380{
381 perf_irq(get_irq_regs());
382 return IRQ_HANDLED;
383}
384
385int __init cbe_init_pm_irq(void)
386{
387 unsigned int irq;
388 int rc, node;
389
390 for_each_node(node) {
391 irq = irq_create_mapping(NULL, IIC_IRQ_IOEX_PMI |
392 (node << IIC_IRQ_NODE_SHIFT));
393 if (irq == NO_IRQ) {
394 printk("ERROR: Unable to allocate irq for node %d\n",
395 node);
396 return -EINVAL;
397 }
398
399 rc = request_irq(irq, cbe_pm_irq,
400 IRQF_DISABLED, "cbe-pmu-0", NULL);
401 if (rc) {
402 printk("ERROR: Request for irq on node %d failed\n",
403 node);
404 return rc;
405 }
406 }
407
408 return 0;
409}
410arch_initcall(cbe_init_pm_irq);
411
412void cbe_sync_irq(int node)
413{
414 unsigned int irq;
415
416 irq = irq_find_mapping(NULL,
417 IIC_IRQ_IOEX_PMI
418 | (node << IIC_IRQ_NODE_SHIFT));
419
420 if (irq == NO_IRQ) {
421 printk(KERN_WARNING "ERROR, unable to get existing irq %d " \
422 "for node %d\n", irq, node);
423 return;
424 }
425
426 synchronize_irq(irq);
427}
428EXPORT_SYMBOL_GPL(cbe_sync_irq);
429
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 22c228a49c33..36989c2eee66 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -50,9 +50,10 @@
50#include <asm/spu.h> 50#include <asm/spu.h>
51#include <asm/spu_priv1.h> 51#include <asm/spu_priv1.h>
52#include <asm/udbg.h> 52#include <asm/udbg.h>
53#include <asm/mpic.h>
54#include <asm/of_platform.h>
53 55
54#include "interrupt.h" 56#include "interrupt.h"
55#include "iommu.h"
56#include "cbe_regs.h" 57#include "cbe_regs.h"
57#include "pervasive.h" 58#include "pervasive.h"
58#include "ras.h" 59#include "ras.h"
@@ -80,24 +81,72 @@ static void cell_progress(char *s, unsigned short hex)
80 printk("*** %04x : %s\n", hex, s ? s : ""); 81 printk("*** %04x : %s\n", hex, s ? s : "");
81} 82}
82 83
83static void __init cell_pcibios_fixup(void) 84static int __init cell_publish_devices(void)
84{ 85{
85 struct pci_dev *dev = NULL; 86 if (!machine_is(cell))
87 return 0;
88
89 /* Publish OF platform devices for southbridge IOs */
90 of_platform_bus_probe(NULL, NULL, NULL);
91
92 return 0;
93}
94device_initcall(cell_publish_devices);
95
96static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
97{
98 struct mpic *mpic = desc->handler_data;
99 unsigned int virq;
100
101 virq = mpic_get_one_irq(mpic);
102 if (virq != NO_IRQ)
103 generic_handle_irq(virq);
104 desc->chip->eoi(irq);
105}
86 106
87 for_each_pci_dev(dev) 107static void __init mpic_init_IRQ(void)
88 pci_read_irq_line(dev); 108{
109 struct device_node *dn;
110 struct mpic *mpic;
111 unsigned int virq;
112
113 for (dn = NULL;
114 (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
115 if (!device_is_compatible(dn, "CBEA,platform-open-pic"))
116 continue;
117
118 /* The MPIC driver will get everything it needs from the
119 * device-tree, just pass 0 to all arguments
120 */
121 mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC ");
122 if (mpic == NULL)
123 continue;
124 mpic_init(mpic);
125
126 virq = irq_of_parse_and_map(dn, 0);
127 if (virq == NO_IRQ)
128 continue;
129
130 printk(KERN_INFO "%s : hooking up to IRQ %d\n",
131 dn->full_name, virq);
132 set_irq_data(virq, mpic);
133 set_irq_chained_handler(virq, cell_mpic_cascade);
134 }
89} 135}
90 136
137
91static void __init cell_init_irq(void) 138static void __init cell_init_irq(void)
92{ 139{
93 iic_init_IRQ(); 140 iic_init_IRQ();
94 spider_init_IRQ(); 141 spider_init_IRQ();
142 mpic_init_IRQ();
95} 143}
96 144
97static void __init cell_setup_arch(void) 145static void __init cell_setup_arch(void)
98{ 146{
99#ifdef CONFIG_SPU_BASE 147#ifdef CONFIG_SPU_BASE
100 spu_priv1_ops = &spu_priv1_mmio_ops; 148 spu_priv1_ops = &spu_priv1_mmio_ops;
149 spu_management_ops = &spu_management_of_ops;
101#endif 150#endif
102 151
103 cbe_regs_init(); 152 cbe_regs_init();
@@ -109,7 +158,6 @@ static void __init cell_setup_arch(void)
109#ifdef CONFIG_SMP 158#ifdef CONFIG_SMP
110 smp_init_cell(); 159 smp_init_cell();
111#endif 160#endif
112
113 /* init to some ~sane value until calibrate_delay() runs */ 161 /* init to some ~sane value until calibrate_delay() runs */
114 loops_per_jiffy = 50000000; 162 loops_per_jiffy = 50000000;
115 163
@@ -129,19 +177,6 @@ static void __init cell_setup_arch(void)
129 mmio_nvram_init(); 177 mmio_nvram_init();
130} 178}
131 179
132/*
133 * Early initialization. Relocation is on but do not reference unbolted pages
134 */
135static void __init cell_init_early(void)
136{
137 DBG(" -> cell_init_early()\n");
138
139 cell_init_iommu();
140
141 DBG(" <- cell_init_early()\n");
142}
143
144
145static int __init cell_probe(void) 180static int __init cell_probe(void)
146{ 181{
147 unsigned long root = of_get_flat_dt_root(); 182 unsigned long root = of_get_flat_dt_root();
@@ -168,7 +203,6 @@ define_machine(cell) {
168 .name = "Cell", 203 .name = "Cell",
169 .probe = cell_probe, 204 .probe = cell_probe,
170 .setup_arch = cell_setup_arch, 205 .setup_arch = cell_setup_arch,
171 .init_early = cell_init_early,
172 .show_cpuinfo = cell_show_cpuinfo, 206 .show_cpuinfo = cell_show_cpuinfo,
173 .restart = rtas_restart, 207 .restart = rtas_restart,
174 .power_off = rtas_power_off, 208 .power_off = rtas_power_off,
@@ -180,7 +214,7 @@ define_machine(cell) {
180 .check_legacy_ioport = cell_check_legacy_ioport, 214 .check_legacy_ioport = cell_check_legacy_ioport,
181 .progress = cell_progress, 215 .progress = cell_progress,
182 .init_IRQ = cell_init_irq, 216 .init_IRQ = cell_init_irq,
183 .pcibios_fixup = cell_pcibios_fixup, 217 .pci_setup_phb = rtas_setup_phb,
184#ifdef CONFIG_KEXEC 218#ifdef CONFIG_KEXEC
185 .machine_kexec = default_machine_kexec, 219 .machine_kexec = default_machine_kexec,
186 .machine_kexec_prepare = default_machine_kexec_prepare, 220 .machine_kexec_prepare = default_machine_kexec_prepare,
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 7aa809d5a244..bd7bffc3ddd0 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -25,22 +25,17 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/list.h> 26#include <linux/list.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/pci.h>
29#include <linux/poll.h>
30#include <linux/ptrace.h> 28#include <linux/ptrace.h>
31#include <linux/slab.h> 29#include <linux/slab.h>
32#include <linux/wait.h> 30#include <linux/wait.h>
33 31#include <linux/mm.h>
34#include <asm/firmware.h> 32#include <linux/io.h>
35#include <asm/io.h>
36#include <asm/prom.h>
37#include <linux/mutex.h> 33#include <linux/mutex.h>
38#include <asm/spu.h> 34#include <asm/spu.h>
39#include <asm/spu_priv1.h> 35#include <asm/spu_priv1.h>
40#include <asm/mmu_context.h> 36#include <asm/xmon.h>
41
42#include "interrupt.h"
43 37
38const struct spu_management_ops *spu_management_ops;
44const struct spu_priv1_ops *spu_priv1_ops; 39const struct spu_priv1_ops *spu_priv1_ops;
45 40
46EXPORT_SYMBOL_GPL(spu_priv1_ops); 41EXPORT_SYMBOL_GPL(spu_priv1_ops);
@@ -89,7 +84,30 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea)
89 printk("%s: invalid access during switch!\n", __func__); 84 printk("%s: invalid access during switch!\n", __func__);
90 return 1; 85 return 1;
91 } 86 }
92 if (!mm || (REGION_ID(ea) != USER_REGION_ID)) { 87 esid = (ea & ESID_MASK) | SLB_ESID_V;
88
89 switch(REGION_ID(ea)) {
90 case USER_REGION_ID:
91#ifdef CONFIG_HUGETLB_PAGE
92 if (in_hugepage_area(mm->context, ea))
93 llp = mmu_psize_defs[mmu_huge_psize].sllp;
94 else
95#endif
96 llp = mmu_psize_defs[mmu_virtual_psize].sllp;
97 vsid = (get_vsid(mm->context.id, ea) << SLB_VSID_SHIFT) |
98 SLB_VSID_USER | llp;
99 break;
100 case VMALLOC_REGION_ID:
101 llp = mmu_psize_defs[mmu_virtual_psize].sllp;
102 vsid = (get_kernel_vsid(ea) << SLB_VSID_SHIFT) |
103 SLB_VSID_KERNEL | llp;
104 break;
105 case KERNEL_REGION_ID:
106 llp = mmu_psize_defs[mmu_linear_psize].sllp;
107 vsid = (get_kernel_vsid(ea) << SLB_VSID_SHIFT) |
108 SLB_VSID_KERNEL | llp;
109 break;
110 default:
93 /* Future: support kernel segments so that drivers 111 /* Future: support kernel segments so that drivers
94 * can use SPUs. 112 * can use SPUs.
95 */ 113 */
@@ -97,16 +115,6 @@ static int __spu_trap_data_seg(struct spu *spu, unsigned long ea)
97 return 1; 115 return 1;
98 } 116 }
99 117
100 esid = (ea & ESID_MASK) | SLB_ESID_V;
101#ifdef CONFIG_HUGETLB_PAGE
102 if (in_hugepage_area(mm->context, ea))
103 llp = mmu_psize_defs[mmu_huge_psize].sllp;
104 else
105#endif
106 llp = mmu_psize_defs[mmu_virtual_psize].sllp;
107 vsid = (get_vsid(mm->context.id, ea) << SLB_VSID_SHIFT) |
108 SLB_VSID_USER | llp;
109
110 out_be64(&priv2->slb_index_W, spu->slb_replace); 118 out_be64(&priv2->slb_index_W, spu->slb_replace);
111 out_be64(&priv2->slb_vsid_RW, vsid); 119 out_be64(&priv2->slb_vsid_RW, vsid);
112 out_be64(&priv2->slb_esid_RW, esid); 120 out_be64(&priv2->slb_esid_RW, esid);
@@ -320,6 +328,7 @@ static void spu_free_irqs(struct spu *spu)
320} 328}
321 329
322static struct list_head spu_list[MAX_NUMNODES]; 330static struct list_head spu_list[MAX_NUMNODES];
331static LIST_HEAD(spu_full_list);
323static DEFINE_MUTEX(spu_mutex); 332static DEFINE_MUTEX(spu_mutex);
324 333
325static void spu_init_channels(struct spu *spu) 334static void spu_init_channels(struct spu *spu)
@@ -364,8 +373,7 @@ struct spu *spu_alloc_node(int node)
364 if (!list_empty(&spu_list[node])) { 373 if (!list_empty(&spu_list[node])) {
365 spu = list_entry(spu_list[node].next, struct spu, list); 374 spu = list_entry(spu_list[node].next, struct spu, list);
366 list_del_init(&spu->list); 375 list_del_init(&spu->list);
367 pr_debug("Got SPU %x %d %d\n", 376 pr_debug("Got SPU %d %d\n", spu->number, spu->node);
368 spu->isrc, spu->number, spu->node);
369 spu_init_channels(spu); 377 spu_init_channels(spu);
370 } 378 }
371 mutex_unlock(&spu_mutex); 379 mutex_unlock(&spu_mutex);
@@ -493,280 +501,65 @@ int spu_irq_class_1_bottom(struct spu *spu)
493 if (!error) { 501 if (!error) {
494 spu_restart_dma(spu); 502 spu_restart_dma(spu);
495 } else { 503 } else {
496 __spu_trap_invalid_dma(spu); 504 spu->dma_callback(spu, SPE_EVENT_SPE_DATA_STORAGE);
497 } 505 }
498 return ret; 506 return ret;
499} 507}
500 508
501static int __init find_spu_node_id(struct device_node *spe) 509struct sysdev_class spu_sysdev_class = {
502{ 510 set_kset_name("spu")
503 const unsigned int *id; 511};
504 struct device_node *cpu;
505 cpu = spe->parent->parent;
506 id = get_property(cpu, "node-id", NULL);
507 return id ? *id : 0;
508}
509
510static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
511 const char *prop)
512{
513 static DEFINE_MUTEX(add_spumem_mutex);
514
515 const struct address_prop {
516 unsigned long address;
517 unsigned int len;
518 } __attribute__((packed)) *p;
519 int proplen;
520
521 unsigned long start_pfn, nr_pages;
522 struct pglist_data *pgdata;
523 struct zone *zone;
524 int ret;
525
526 p = get_property(spe, prop, &proplen);
527 WARN_ON(proplen != sizeof (*p));
528
529 start_pfn = p->address >> PAGE_SHIFT;
530 nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
531
532 pgdata = NODE_DATA(spu->nid);
533 zone = pgdata->node_zones;
534
535 /* XXX rethink locking here */
536 mutex_lock(&add_spumem_mutex);
537 ret = __add_pages(zone, start_pfn, nr_pages);
538 mutex_unlock(&add_spumem_mutex);
539
540 return ret;
541}
542 512
543static void __iomem * __init map_spe_prop(struct spu *spu, 513int spu_add_sysdev_attr(struct sysdev_attribute *attr)
544 struct device_node *n, const char *name)
545{ 514{
546 const struct address_prop { 515 struct spu *spu;
547 unsigned long address; 516 mutex_lock(&spu_mutex);
548 unsigned int len;
549 } __attribute__((packed)) *prop;
550
551 const void *p;
552 int proplen;
553 void __iomem *ret = NULL;
554 int err = 0;
555
556 p = get_property(n, name, &proplen);
557 if (proplen != sizeof (struct address_prop))
558 return NULL;
559
560 prop = p;
561
562 err = cell_spuprop_present(spu, n, name);
563 if (err && (err != -EEXIST))
564 goto out;
565
566 ret = ioremap(prop->address, prop->len);
567
568 out:
569 return ret;
570}
571 517
572static void spu_unmap(struct spu *spu) 518 list_for_each_entry(spu, &spu_full_list, full_list)
573{ 519 sysdev_create_file(&spu->sysdev, attr);
574 iounmap(spu->priv2);
575 iounmap(spu->priv1);
576 iounmap(spu->problem);
577 iounmap((__force u8 __iomem *)spu->local_store);
578}
579 520
580/* This function shall be abstracted for HV platforms */ 521 mutex_unlock(&spu_mutex);
581static int __init spu_map_interrupts_old(struct spu *spu, struct device_node *np) 522 return 0;
582{
583 unsigned int isrc;
584 const u32 *tmp;
585
586 /* Get the interrupt source unit from the device-tree */
587 tmp = get_property(np, "isrc", NULL);
588 if (!tmp)
589 return -ENODEV;
590 isrc = tmp[0];
591
592 /* Add the node number */
593 isrc |= spu->node << IIC_IRQ_NODE_SHIFT;
594 spu->isrc = isrc;
595
596 /* Now map interrupts of all 3 classes */
597 spu->irqs[0] = irq_create_mapping(NULL, IIC_IRQ_CLASS_0 | isrc);
598 spu->irqs[1] = irq_create_mapping(NULL, IIC_IRQ_CLASS_1 | isrc);
599 spu->irqs[2] = irq_create_mapping(NULL, IIC_IRQ_CLASS_2 | isrc);
600
601 /* Right now, we only fail if class 2 failed */
602 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
603} 523}
524EXPORT_SYMBOL_GPL(spu_add_sysdev_attr);
604 525
605static int __init spu_map_device_old(struct spu *spu, struct device_node *node) 526int spu_add_sysdev_attr_group(struct attribute_group *attrs)
606{ 527{
607 const char *prop; 528 struct spu *spu;
608 int ret; 529 mutex_lock(&spu_mutex);
609
610 ret = -ENODEV;
611 spu->name = get_property(node, "name", NULL);
612 if (!spu->name)
613 goto out;
614
615 prop = get_property(node, "local-store", NULL);
616 if (!prop)
617 goto out;
618 spu->local_store_phys = *(unsigned long *)prop;
619
620 /* we use local store as ram, not io memory */
621 spu->local_store = (void __force *)
622 map_spe_prop(spu, node, "local-store");
623 if (!spu->local_store)
624 goto out;
625
626 prop = get_property(node, "problem", NULL);
627 if (!prop)
628 goto out_unmap;
629 spu->problem_phys = *(unsigned long *)prop;
630
631 spu->problem= map_spe_prop(spu, node, "problem");
632 if (!spu->problem)
633 goto out_unmap;
634
635 spu->priv1= map_spe_prop(spu, node, "priv1");
636 /* priv1 is not available on a hypervisor */
637
638 spu->priv2= map_spe_prop(spu, node, "priv2");
639 if (!spu->priv2)
640 goto out_unmap;
641 ret = 0;
642 goto out;
643
644out_unmap:
645 spu_unmap(spu);
646out:
647 return ret;
648}
649 530
650static int __init spu_map_interrupts(struct spu *spu, struct device_node *np) 531 list_for_each_entry(spu, &spu_full_list, full_list)
651{ 532 sysfs_create_group(&spu->sysdev.kobj, attrs);
652 struct of_irq oirq;
653 int ret;
654 int i;
655 533
656 for (i=0; i < 3; i++) { 534 mutex_unlock(&spu_mutex);
657 ret = of_irq_map_one(np, i, &oirq);
658 if (ret) {
659 pr_debug("spu_new: failed to get irq %d\n", i);
660 goto err;
661 }
662 ret = -EINVAL;
663 pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0],
664 oirq.controller->full_name);
665 spu->irqs[i] = irq_create_of_mapping(oirq.controller,
666 oirq.specifier, oirq.size);
667 if (spu->irqs[i] == NO_IRQ) {
668 pr_debug("spu_new: failed to map it !\n");
669 goto err;
670 }
671 }
672 return 0; 535 return 0;
673
674err:
675 pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier, spu->name);
676 for (; i >= 0; i--) {
677 if (spu->irqs[i] != NO_IRQ)
678 irq_dispose_mapping(spu->irqs[i]);
679 }
680 return ret;
681} 536}
537EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group);
682 538
683static int spu_map_resource(struct device_node *node, int nr,
684 void __iomem** virt, unsigned long *phys)
685{
686 struct resource resource = { };
687 int ret;
688
689 ret = of_address_to_resource(node, nr, &resource);
690 if (ret)
691 goto out;
692 539
693 if (phys) 540void spu_remove_sysdev_attr(struct sysdev_attribute *attr)
694 *phys = resource.start;
695 *virt = ioremap(resource.start, resource.end - resource.start);
696 if (!*virt)
697 ret = -EINVAL;
698
699out:
700 return ret;
701}
702
703static int __init spu_map_device(struct spu *spu, struct device_node *node)
704{ 541{
705 int ret = -ENODEV; 542 struct spu *spu;
706 spu->name = get_property(node, "name", NULL); 543 mutex_lock(&spu_mutex);
707 if (!spu->name)
708 goto out;
709
710 ret = spu_map_resource(node, 0, (void __iomem**)&spu->local_store,
711 &spu->local_store_phys);
712 if (ret) {
713 pr_debug("spu_new: failed to map %s resource 0\n",
714 node->full_name);
715 goto out;
716 }
717 ret = spu_map_resource(node, 1, (void __iomem**)&spu->problem,
718 &spu->problem_phys);
719 if (ret) {
720 pr_debug("spu_new: failed to map %s resource 1\n",
721 node->full_name);
722 goto out_unmap;
723 }
724 ret = spu_map_resource(node, 2, (void __iomem**)&spu->priv2,
725 NULL);
726 if (ret) {
727 pr_debug("spu_new: failed to map %s resource 2\n",
728 node->full_name);
729 goto out_unmap;
730 }
731
732 if (!firmware_has_feature(FW_FEATURE_LPAR))
733 ret = spu_map_resource(node, 3, (void __iomem**)&spu->priv1,
734 NULL);
735 if (ret) {
736 pr_debug("spu_new: failed to map %s resource 3\n",
737 node->full_name);
738 goto out_unmap;
739 }
740 pr_debug("spu_new: %s maps:\n", node->full_name);
741 pr_debug(" local store : 0x%016lx -> 0x%p\n",
742 spu->local_store_phys, spu->local_store);
743 pr_debug(" problem state : 0x%016lx -> 0x%p\n",
744 spu->problem_phys, spu->problem);
745 pr_debug(" priv2 : 0x%p\n", spu->priv2);
746 pr_debug(" priv1 : 0x%p\n", spu->priv1);
747 544
748 return 0; 545 list_for_each_entry(spu, &spu_full_list, full_list)
546 sysdev_remove_file(&spu->sysdev, attr);
749 547
750out_unmap: 548 mutex_unlock(&spu_mutex);
751 spu_unmap(spu);
752out:
753 pr_debug("failed to map spe %s: %d\n", spu->name, ret);
754 return ret;
755} 549}
550EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr);
756 551
757struct sysdev_class spu_sysdev_class = { 552void spu_remove_sysdev_attr_group(struct attribute_group *attrs)
758 set_kset_name("spu")
759};
760
761static ssize_t spu_show_isrc(struct sys_device *sysdev, char *buf)
762{ 553{
763 struct spu *spu = container_of(sysdev, struct spu, sysdev); 554 struct spu *spu;
764 return sprintf(buf, "%d\n", spu->isrc); 555 mutex_lock(&spu_mutex);
765 556
766} 557 list_for_each_entry(spu, &spu_full_list, full_list)
767static SYSDEV_ATTR(isrc, 0400, spu_show_isrc, NULL); 558 sysfs_remove_group(&spu->sysdev.kobj, attrs);
768 559
769extern int attach_sysdev_to_node(struct sys_device *dev, int nid); 560 mutex_unlock(&spu_mutex);
561}
562EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr_group);
770 563
771static int spu_create_sysdev(struct spu *spu) 564static int spu_create_sysdev(struct spu *spu)
772{ 565{
@@ -781,21 +574,18 @@ static int spu_create_sysdev(struct spu *spu)
781 return ret; 574 return ret;
782 } 575 }
783 576
784 if (spu->isrc != 0) 577 sysfs_add_device_to_node(&spu->sysdev, spu->node);
785 sysdev_create_file(&spu->sysdev, &attr_isrc);
786 sysfs_add_device_to_node(&spu->sysdev, spu->nid);
787 578
788 return 0; 579 return 0;
789} 580}
790 581
791static void spu_destroy_sysdev(struct spu *spu) 582static void spu_destroy_sysdev(struct spu *spu)
792{ 583{
793 sysdev_remove_file(&spu->sysdev, &attr_isrc); 584 sysfs_remove_device_from_node(&spu->sysdev, spu->node);
794 sysfs_remove_device_from_node(&spu->sysdev, spu->nid);
795 sysdev_unregister(&spu->sysdev); 585 sysdev_unregister(&spu->sysdev);
796} 586}
797 587
798static int __init create_spu(struct device_node *spe) 588static int __init create_spu(void *data)
799{ 589{
800 struct spu *spu; 590 struct spu *spu;
801 int ret; 591 int ret;
@@ -806,57 +596,37 @@ static int __init create_spu(struct device_node *spe)
806 if (!spu) 596 if (!spu)
807 goto out; 597 goto out;
808 598
809 spu->node = find_spu_node_id(spe); 599 spin_lock_init(&spu->register_lock);
810 if (spu->node >= MAX_NUMNODES) { 600 mutex_lock(&spu_mutex);
811 printk(KERN_WARNING "SPE %s on node %d ignored," 601 spu->number = number++;
812 " node number too big\n", spe->full_name, spu->node); 602 mutex_unlock(&spu_mutex);
813 printk(KERN_WARNING "Check if CONFIG_NUMA is enabled.\n"); 603
814 return -ENODEV; 604 ret = spu_create_spu(spu, data);
815 }
816 spu->nid = of_node_to_nid(spe);
817 if (spu->nid == -1)
818 spu->nid = 0;
819 605
820 ret = spu_map_device(spu, spe);
821 /* try old method */
822 if (ret)
823 ret = spu_map_device_old(spu, spe);
824 if (ret) 606 if (ret)
825 goto out_free; 607 goto out_free;
826 608
827 ret = spu_map_interrupts(spu, spe); 609 spu_mfc_sdr_setup(spu);
828 if (ret)
829 ret = spu_map_interrupts_old(spu, spe);
830 if (ret)
831 goto out_unmap;
832 spin_lock_init(&spu->register_lock);
833 spu_mfc_sdr_set(spu, mfspr(SPRN_SDR1));
834 spu_mfc_sr1_set(spu, 0x33); 610 spu_mfc_sr1_set(spu, 0x33);
835 mutex_lock(&spu_mutex);
836
837 spu->number = number++;
838 ret = spu_request_irqs(spu); 611 ret = spu_request_irqs(spu);
839 if (ret) 612 if (ret)
840 goto out_unlock; 613 goto out_destroy;
841 614
842 ret = spu_create_sysdev(spu); 615 ret = spu_create_sysdev(spu);
843 if (ret) 616 if (ret)
844 goto out_free_irqs; 617 goto out_free_irqs;
845 618
619 mutex_lock(&spu_mutex);
846 list_add(&spu->list, &spu_list[spu->node]); 620 list_add(&spu->list, &spu_list[spu->node]);
621 list_add(&spu->full_list, &spu_full_list);
847 mutex_unlock(&spu_mutex); 622 mutex_unlock(&spu_mutex);
848 623
849 pr_debug(KERN_DEBUG "Using SPE %s %02x %p %p %p %p %d\n",
850 spu->name, spu->isrc, spu->local_store,
851 spu->problem, spu->priv1, spu->priv2, spu->number);
852 goto out; 624 goto out;
853 625
854out_free_irqs: 626out_free_irqs:
855 spu_free_irqs(spu); 627 spu_free_irqs(spu);
856out_unlock: 628out_destroy:
857 mutex_unlock(&spu_mutex); 629 spu_destroy_spu(spu);
858out_unmap:
859 spu_unmap(spu);
860out_free: 630out_free:
861 kfree(spu); 631 kfree(spu);
862out: 632out:
@@ -866,10 +636,11 @@ out:
866static void destroy_spu(struct spu *spu) 636static void destroy_spu(struct spu *spu)
867{ 637{
868 list_del_init(&spu->list); 638 list_del_init(&spu->list);
639 list_del_init(&spu->full_list);
869 640
870 spu_destroy_sysdev(spu); 641 spu_destroy_sysdev(spu);
871 spu_free_irqs(spu); 642 spu_free_irqs(spu);
872 spu_unmap(spu); 643 spu_destroy_spu(spu);
873 kfree(spu); 644 kfree(spu);
874} 645}
875 646
@@ -890,9 +661,11 @@ module_exit(cleanup_spu_base);
890 661
891static int __init init_spu_base(void) 662static int __init init_spu_base(void)
892{ 663{
893 struct device_node *node;
894 int i, ret; 664 int i, ret;
895 665
666 if (!spu_management_ops)
667 return 0;
668
896 /* create sysdev class for spus */ 669 /* create sysdev class for spus */
897 ret = sysdev_class_register(&spu_sysdev_class); 670 ret = sysdev_class_register(&spu_sysdev_class);
898 if (ret) 671 if (ret)
@@ -901,17 +674,17 @@ static int __init init_spu_base(void)
901 for (i = 0; i < MAX_NUMNODES; i++) 674 for (i = 0; i < MAX_NUMNODES; i++)
902 INIT_LIST_HEAD(&spu_list[i]); 675 INIT_LIST_HEAD(&spu_list[i]);
903 676
904 ret = -ENODEV; 677 ret = spu_enumerate_spus(create_spu);
905 for (node = of_find_node_by_type(NULL, "spe"); 678
906 node; node = of_find_node_by_type(node, "spe")) { 679 if (ret) {
907 ret = create_spu(node); 680 printk(KERN_WARNING "%s: Error initializing spus\n",
908 if (ret) { 681 __FUNCTION__);
909 printk(KERN_WARNING "%s: Error initializing %s\n", 682 cleanup_spu_base();
910 __FUNCTION__, node->name); 683 return ret;
911 cleanup_spu_base();
912 break;
913 }
914 } 684 }
685
686 xmon_register_spus(&spu_full_list);
687
915 return ret; 688 return ret;
916} 689}
917module_init(init_spu_base); 690module_init(init_spu_base);
diff --git a/arch/powerpc/platforms/cell/spu_coredump.c b/arch/powerpc/platforms/cell/spu_coredump.c
new file mode 100644
index 000000000000..6915b418ee73
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spu_coredump.c
@@ -0,0 +1,81 @@
1/*
2 * SPU core dump code
3 *
4 * (C) Copyright 2006 IBM Corp.
5 *
6 * Author: Dwayne Grant McConnell <decimal@us.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
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#include <linux/file.h>
24#include <linux/module.h>
25#include <linux/syscalls.h>
26
27#include <asm/spu.h>
28
29static struct spu_coredump_calls spu_coredump_calls;
30static DEFINE_MUTEX(spu_coredump_mutex);
31
32int arch_notes_size(void)
33{
34 long ret;
35 struct module *owner = spu_coredump_calls.owner;
36
37 ret = -ENOSYS;
38 mutex_lock(&spu_coredump_mutex);
39 if (owner && try_module_get(owner)) {
40 ret = spu_coredump_calls.arch_notes_size();
41 module_put(owner);
42 }
43 mutex_unlock(&spu_coredump_mutex);
44 return ret;
45}
46
47void arch_write_notes(struct file *file)
48{
49 struct module *owner = spu_coredump_calls.owner;
50
51 mutex_lock(&spu_coredump_mutex);
52 if (owner && try_module_get(owner)) {
53 spu_coredump_calls.arch_write_notes(file);
54 module_put(owner);
55 }
56 mutex_unlock(&spu_coredump_mutex);
57}
58
59int register_arch_coredump_calls(struct spu_coredump_calls *calls)
60{
61 if (spu_coredump_calls.owner)
62 return -EBUSY;
63
64 mutex_lock(&spu_coredump_mutex);
65 spu_coredump_calls.arch_notes_size = calls->arch_notes_size;
66 spu_coredump_calls.arch_write_notes = calls->arch_write_notes;
67 spu_coredump_calls.owner = calls->owner;
68 mutex_unlock(&spu_coredump_mutex);
69 return 0;
70}
71EXPORT_SYMBOL_GPL(register_arch_coredump_calls);
72
73void unregister_arch_coredump_calls(struct spu_coredump_calls *calls)
74{
75 BUG_ON(spu_coredump_calls.owner != calls->owner);
76
77 mutex_lock(&spu_coredump_mutex);
78 spu_coredump_calls.owner = NULL;
79 mutex_unlock(&spu_coredump_mutex);
80}
81EXPORT_SYMBOL_GPL(unregister_arch_coredump_calls);
diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.c b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
index 71b69f0a1a48..a5de0430c56d 100644
--- a/arch/powerpc/platforms/cell/spu_priv1_mmio.c
+++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
@@ -18,120 +18,498 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 20
21#include <linux/interrupt.h>
22#include <linux/list.h>
21#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/ptrace.h>
25#include <linux/slab.h>
26#include <linux/wait.h>
27#include <linux/mm.h>
28#include <linux/io.h>
29#include <linux/mutex.h>
30#include <linux/device.h>
22 31
23#include <asm/io.h>
24#include <asm/spu.h> 32#include <asm/spu.h>
25#include <asm/spu_priv1.h> 33#include <asm/spu_priv1.h>
34#include <asm/firmware.h>
35#include <asm/prom.h>
26 36
27#include "interrupt.h" 37#include "interrupt.h"
38#include "spu_priv1_mmio.h"
39
40struct spu_pdata {
41 int nid;
42 struct device_node *devnode;
43 struct spu_priv1 __iomem *priv1;
44};
45
46static struct spu_pdata *spu_get_pdata(struct spu *spu)
47{
48 BUG_ON(!spu->pdata);
49 return spu->pdata;
50}
51
52struct device_node *spu_devnode(struct spu *spu)
53{
54 return spu_get_pdata(spu)->devnode;
55}
56
57EXPORT_SYMBOL_GPL(spu_devnode);
58
59static int __init find_spu_node_id(struct device_node *spe)
60{
61 const unsigned int *id;
62 struct device_node *cpu;
63 cpu = spe->parent->parent;
64 id = get_property(cpu, "node-id", NULL);
65 return id ? *id : 0;
66}
67
68static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
69 const char *prop)
70{
71 static DEFINE_MUTEX(add_spumem_mutex);
72
73 const struct address_prop {
74 unsigned long address;
75 unsigned int len;
76 } __attribute__((packed)) *p;
77 int proplen;
78
79 unsigned long start_pfn, nr_pages;
80 struct pglist_data *pgdata;
81 struct zone *zone;
82 int ret;
83
84 p = get_property(spe, prop, &proplen);
85 WARN_ON(proplen != sizeof (*p));
86
87 start_pfn = p->address >> PAGE_SHIFT;
88 nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
89
90 pgdata = NODE_DATA(spu_get_pdata(spu)->nid);
91 zone = pgdata->node_zones;
92
93 /* XXX rethink locking here */
94 mutex_lock(&add_spumem_mutex);
95 ret = __add_pages(zone, start_pfn, nr_pages);
96 mutex_unlock(&add_spumem_mutex);
97
98 return ret;
99}
100
101static void __iomem * __init map_spe_prop(struct spu *spu,
102 struct device_node *n, const char *name)
103{
104 const struct address_prop {
105 unsigned long address;
106 unsigned int len;
107 } __attribute__((packed)) *prop;
108
109 const void *p;
110 int proplen;
111 void __iomem *ret = NULL;
112 int err = 0;
113
114 p = get_property(n, name, &proplen);
115 if (proplen != sizeof (struct address_prop))
116 return NULL;
117
118 prop = p;
119
120 err = cell_spuprop_present(spu, n, name);
121 if (err && (err != -EEXIST))
122 goto out;
123
124 ret = ioremap(prop->address, prop->len);
125
126 out:
127 return ret;
128}
129
130static void spu_unmap(struct spu *spu)
131{
132 iounmap(spu->priv2);
133 iounmap(spu_get_pdata(spu)->priv1);
134 iounmap(spu->problem);
135 iounmap((__force u8 __iomem *)spu->local_store);
136}
137
138static int __init spu_map_interrupts_old(struct spu *spu,
139 struct device_node *np)
140{
141 unsigned int isrc;
142 const u32 *tmp;
143
144 /* Get the interrupt source unit from the device-tree */
145 tmp = get_property(np, "isrc", NULL);
146 if (!tmp)
147 return -ENODEV;
148 isrc = tmp[0];
149
150 /* Add the node number */
151 isrc |= spu->node << IIC_IRQ_NODE_SHIFT;
152
153 /* Now map interrupts of all 3 classes */
154 spu->irqs[0] = irq_create_mapping(NULL, IIC_IRQ_CLASS_0 | isrc);
155 spu->irqs[1] = irq_create_mapping(NULL, IIC_IRQ_CLASS_1 | isrc);
156 spu->irqs[2] = irq_create_mapping(NULL, IIC_IRQ_CLASS_2 | isrc);
157
158 /* Right now, we only fail if class 2 failed */
159 return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
160}
161
162static int __init spu_map_device_old(struct spu *spu, struct device_node *node)
163{
164 const char *prop;
165 int ret;
166
167 ret = -ENODEV;
168 spu->name = get_property(node, "name", NULL);
169 if (!spu->name)
170 goto out;
171
172 prop = get_property(node, "local-store", NULL);
173 if (!prop)
174 goto out;
175 spu->local_store_phys = *(unsigned long *)prop;
176
177 /* we use local store as ram, not io memory */
178 spu->local_store = (void __force *)
179 map_spe_prop(spu, node, "local-store");
180 if (!spu->local_store)
181 goto out;
182
183 prop = get_property(node, "problem", NULL);
184 if (!prop)
185 goto out_unmap;
186 spu->problem_phys = *(unsigned long *)prop;
187
188 spu->problem= map_spe_prop(spu, node, "problem");
189 if (!spu->problem)
190 goto out_unmap;
191
192 spu_get_pdata(spu)->priv1= map_spe_prop(spu, node, "priv1");
193
194 spu->priv2= map_spe_prop(spu, node, "priv2");
195 if (!spu->priv2)
196 goto out_unmap;
197 ret = 0;
198 goto out;
199
200out_unmap:
201 spu_unmap(spu);
202out:
203 return ret;
204}
205
206static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
207{
208 struct of_irq oirq;
209 int ret;
210 int i;
211
212 for (i=0; i < 3; i++) {
213 ret = of_irq_map_one(np, i, &oirq);
214 if (ret) {
215 pr_debug("spu_new: failed to get irq %d\n", i);
216 goto err;
217 }
218 ret = -EINVAL;
219 pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0],
220 oirq.controller->full_name);
221 spu->irqs[i] = irq_create_of_mapping(oirq.controller,
222 oirq.specifier, oirq.size);
223 if (spu->irqs[i] == NO_IRQ) {
224 pr_debug("spu_new: failed to map it !\n");
225 goto err;
226 }
227 }
228 return 0;
229
230err:
231 pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier,
232 spu->name);
233 for (; i >= 0; i--) {
234 if (spu->irqs[i] != NO_IRQ)
235 irq_dispose_mapping(spu->irqs[i]);
236 }
237 return ret;
238}
239
240static int spu_map_resource(struct device_node *node, int nr,
241 void __iomem** virt, unsigned long *phys)
242{
243 struct resource resource = { };
244 int ret;
245
246 ret = of_address_to_resource(node, nr, &resource);
247 if (ret)
248 goto out;
249
250 if (phys)
251 *phys = resource.start;
252 *virt = ioremap(resource.start, resource.end - resource.start);
253 if (!*virt)
254 ret = -EINVAL;
255
256out:
257 return ret;
258}
259
260static int __init spu_map_device(struct spu *spu, struct device_node *node)
261{
262 int ret = -ENODEV;
263 spu->name = get_property(node, "name", NULL);
264 if (!spu->name)
265 goto out;
266
267 ret = spu_map_resource(node, 0, (void __iomem**)&spu->local_store,
268 &spu->local_store_phys);
269 if (ret) {
270 pr_debug("spu_new: failed to map %s resource 0\n",
271 node->full_name);
272 goto out;
273 }
274 ret = spu_map_resource(node, 1, (void __iomem**)&spu->problem,
275 &spu->problem_phys);
276 if (ret) {
277 pr_debug("spu_new: failed to map %s resource 1\n",
278 node->full_name);
279 goto out_unmap;
280 }
281 ret = spu_map_resource(node, 2, (void __iomem**)&spu->priv2,
282 NULL);
283 if (ret) {
284 pr_debug("spu_new: failed to map %s resource 2\n",
285 node->full_name);
286 goto out_unmap;
287 }
288 if (!firmware_has_feature(FW_FEATURE_LPAR))
289 ret = spu_map_resource(node, 3,
290 (void __iomem**)&spu_get_pdata(spu)->priv1, NULL);
291 if (ret) {
292 pr_debug("spu_new: failed to map %s resource 3\n",
293 node->full_name);
294 goto out_unmap;
295 }
296 pr_debug("spu_new: %s maps:\n", node->full_name);
297 pr_debug(" local store : 0x%016lx -> 0x%p\n",
298 spu->local_store_phys, spu->local_store);
299 pr_debug(" problem state : 0x%016lx -> 0x%p\n",
300 spu->problem_phys, spu->problem);
301 pr_debug(" priv2 : 0x%p\n", spu->priv2);
302 pr_debug(" priv1 : 0x%p\n",
303 spu_get_pdata(spu)->priv1);
304
305 return 0;
306
307out_unmap:
308 spu_unmap(spu);
309out:
310 pr_debug("failed to map spe %s: %d\n", spu->name, ret);
311 return ret;
312}
313
314static int __init of_enumerate_spus(int (*fn)(void *data))
315{
316 int ret;
317 struct device_node *node;
318
319 ret = -ENODEV;
320 for (node = of_find_node_by_type(NULL, "spe");
321 node; node = of_find_node_by_type(node, "spe")) {
322 ret = fn(node);
323 if (ret) {
324 printk(KERN_WARNING "%s: Error initializing %s\n",
325 __FUNCTION__, node->name);
326 break;
327 }
328 }
329 return ret;
330}
331
332static int __init of_create_spu(struct spu *spu, void *data)
333{
334 int ret;
335 struct device_node *spe = (struct device_node *)data;
336
337 spu->pdata = kzalloc(sizeof(struct spu_pdata),
338 GFP_KERNEL);
339 if (!spu->pdata) {
340 ret = -ENOMEM;
341 goto out;
342 }
343
344 spu->node = find_spu_node_id(spe);
345 if (spu->node >= MAX_NUMNODES) {
346 printk(KERN_WARNING "SPE %s on node %d ignored,"
347 " node number too big\n", spe->full_name, spu->node);
348 printk(KERN_WARNING "Check if CONFIG_NUMA is enabled.\n");
349 ret = -ENODEV;
350 goto out_free;
351 }
352
353 spu_get_pdata(spu)->nid = of_node_to_nid(spe);
354 if (spu_get_pdata(spu)->nid == -1)
355 spu_get_pdata(spu)->nid = 0;
356
357 ret = spu_map_device(spu, spe);
358 /* try old method */
359 if (ret)
360 ret = spu_map_device_old(spu, spe);
361 if (ret)
362 goto out_free;
363
364 ret = spu_map_interrupts(spu, spe);
365 if (ret)
366 ret = spu_map_interrupts_old(spu, spe);
367 if (ret)
368 goto out_unmap;
369
370 spu_get_pdata(spu)->devnode = of_node_get(spe);
371
372 pr_debug(KERN_DEBUG "Using SPE %s %p %p %p %p %d\n", spu->name,
373 spu->local_store, spu->problem, spu_get_pdata(spu)->priv1,
374 spu->priv2, spu->number);
375 goto out;
376
377out_unmap:
378 spu_unmap(spu);
379out_free:
380 kfree(spu->pdata);
381 spu->pdata = NULL;
382out:
383 return ret;
384}
385
386static int of_destroy_spu(struct spu *spu)
387{
388 spu_unmap(spu);
389 of_node_put(spu_get_pdata(spu)->devnode);
390 kfree(spu->pdata);
391 spu->pdata = NULL;
392 return 0;
393}
394
395const struct spu_management_ops spu_management_of_ops = {
396 .enumerate_spus = of_enumerate_spus,
397 .create_spu = of_create_spu,
398 .destroy_spu = of_destroy_spu,
399};
28 400
29static void int_mask_and(struct spu *spu, int class, u64 mask) 401static void int_mask_and(struct spu *spu, int class, u64 mask)
30{ 402{
31 u64 old_mask; 403 u64 old_mask;
32 404
33 old_mask = in_be64(&spu->priv1->int_mask_RW[class]); 405 old_mask = in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
34 out_be64(&spu->priv1->int_mask_RW[class], old_mask & mask); 406 out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class],
407 old_mask & mask);
35} 408}
36 409
37static void int_mask_or(struct spu *spu, int class, u64 mask) 410static void int_mask_or(struct spu *spu, int class, u64 mask)
38{ 411{
39 u64 old_mask; 412 u64 old_mask;
40 413
41 old_mask = in_be64(&spu->priv1->int_mask_RW[class]); 414 old_mask = in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
42 out_be64(&spu->priv1->int_mask_RW[class], old_mask | mask); 415 out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class],
416 old_mask | mask);
43} 417}
44 418
45static void int_mask_set(struct spu *spu, int class, u64 mask) 419static void int_mask_set(struct spu *spu, int class, u64 mask)
46{ 420{
47 out_be64(&spu->priv1->int_mask_RW[class], mask); 421 out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class], mask);
48} 422}
49 423
50static u64 int_mask_get(struct spu *spu, int class) 424static u64 int_mask_get(struct spu *spu, int class)
51{ 425{
52 return in_be64(&spu->priv1->int_mask_RW[class]); 426 return in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
53} 427}
54 428
55static void int_stat_clear(struct spu *spu, int class, u64 stat) 429static void int_stat_clear(struct spu *spu, int class, u64 stat)
56{ 430{
57 out_be64(&spu->priv1->int_stat_RW[class], stat); 431 out_be64(&spu_get_pdata(spu)->priv1->int_stat_RW[class], stat);
58} 432}
59 433
60static u64 int_stat_get(struct spu *spu, int class) 434static u64 int_stat_get(struct spu *spu, int class)
61{ 435{
62 return in_be64(&spu->priv1->int_stat_RW[class]); 436 return in_be64(&spu_get_pdata(spu)->priv1->int_stat_RW[class]);
63} 437}
64 438
65static void cpu_affinity_set(struct spu *spu, int cpu) 439static void cpu_affinity_set(struct spu *spu, int cpu)
66{ 440{
67 u64 target = iic_get_target_id(cpu); 441 u64 target = iic_get_target_id(cpu);
68 u64 route = target << 48 | target << 32 | target << 16; 442 u64 route = target << 48 | target << 32 | target << 16;
69 out_be64(&spu->priv1->int_route_RW, route); 443 out_be64(&spu_get_pdata(spu)->priv1->int_route_RW, route);
70} 444}
71 445
72static u64 mfc_dar_get(struct spu *spu) 446static u64 mfc_dar_get(struct spu *spu)
73{ 447{
74 return in_be64(&spu->priv1->mfc_dar_RW); 448 return in_be64(&spu_get_pdata(spu)->priv1->mfc_dar_RW);
75} 449}
76 450
77static u64 mfc_dsisr_get(struct spu *spu) 451static u64 mfc_dsisr_get(struct spu *spu)
78{ 452{
79 return in_be64(&spu->priv1->mfc_dsisr_RW); 453 return in_be64(&spu_get_pdata(spu)->priv1->mfc_dsisr_RW);
80} 454}
81 455
82static void mfc_dsisr_set(struct spu *spu, u64 dsisr) 456static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
83{ 457{
84 out_be64(&spu->priv1->mfc_dsisr_RW, dsisr); 458 out_be64(&spu_get_pdata(spu)->priv1->mfc_dsisr_RW, dsisr);
85} 459}
86 460
87static void mfc_sdr_set(struct spu *spu, u64 sdr) 461static void mfc_sdr_setup(struct spu *spu)
88{ 462{
89 out_be64(&spu->priv1->mfc_sdr_RW, sdr); 463 out_be64(&spu_get_pdata(spu)->priv1->mfc_sdr_RW, mfspr(SPRN_SDR1));
90} 464}
91 465
92static void mfc_sr1_set(struct spu *spu, u64 sr1) 466static void mfc_sr1_set(struct spu *spu, u64 sr1)
93{ 467{
94 out_be64(&spu->priv1->mfc_sr1_RW, sr1); 468 out_be64(&spu_get_pdata(spu)->priv1->mfc_sr1_RW, sr1);
95} 469}
96 470
97static u64 mfc_sr1_get(struct spu *spu) 471static u64 mfc_sr1_get(struct spu *spu)
98{ 472{
99 return in_be64(&spu->priv1->mfc_sr1_RW); 473 return in_be64(&spu_get_pdata(spu)->priv1->mfc_sr1_RW);
100} 474}
101 475
102static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id) 476static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
103{ 477{
104 out_be64(&spu->priv1->mfc_tclass_id_RW, tclass_id); 478 out_be64(&spu_get_pdata(spu)->priv1->mfc_tclass_id_RW, tclass_id);
105} 479}
106 480
107static u64 mfc_tclass_id_get(struct spu *spu) 481static u64 mfc_tclass_id_get(struct spu *spu)
108{ 482{
109 return in_be64(&spu->priv1->mfc_tclass_id_RW); 483 return in_be64(&spu_get_pdata(spu)->priv1->mfc_tclass_id_RW);
110} 484}
111 485
112static void tlb_invalidate(struct spu *spu) 486static void tlb_invalidate(struct spu *spu)
113{ 487{
114 out_be64(&spu->priv1->tlb_invalidate_entry_W, 0ul); 488 out_be64(&spu_get_pdata(spu)->priv1->tlb_invalidate_entry_W, 0ul);
115} 489}
116 490
117static void resource_allocation_groupID_set(struct spu *spu, u64 id) 491static void resource_allocation_groupID_set(struct spu *spu, u64 id)
118{ 492{
119 out_be64(&spu->priv1->resource_allocation_groupID_RW, id); 493 out_be64(&spu_get_pdata(spu)->priv1->resource_allocation_groupID_RW,
494 id);
120} 495}
121 496
122static u64 resource_allocation_groupID_get(struct spu *spu) 497static u64 resource_allocation_groupID_get(struct spu *spu)
123{ 498{
124 return in_be64(&spu->priv1->resource_allocation_groupID_RW); 499 return in_be64(
500 &spu_get_pdata(spu)->priv1->resource_allocation_groupID_RW);
125} 501}
126 502
127static void resource_allocation_enable_set(struct spu *spu, u64 enable) 503static void resource_allocation_enable_set(struct spu *spu, u64 enable)
128{ 504{
129 out_be64(&spu->priv1->resource_allocation_enable_RW, enable); 505 out_be64(&spu_get_pdata(spu)->priv1->resource_allocation_enable_RW,
506 enable);
130} 507}
131 508
132static u64 resource_allocation_enable_get(struct spu *spu) 509static u64 resource_allocation_enable_get(struct spu *spu)
133{ 510{
134 return in_be64(&spu->priv1->resource_allocation_enable_RW); 511 return in_be64(
512 &spu_get_pdata(spu)->priv1->resource_allocation_enable_RW);
135} 513}
136 514
137const struct spu_priv1_ops spu_priv1_mmio_ops = 515const struct spu_priv1_ops spu_priv1_mmio_ops =
@@ -146,7 +524,7 @@ const struct spu_priv1_ops spu_priv1_mmio_ops =
146 .mfc_dar_get = mfc_dar_get, 524 .mfc_dar_get = mfc_dar_get,
147 .mfc_dsisr_get = mfc_dsisr_get, 525 .mfc_dsisr_get = mfc_dsisr_get,
148 .mfc_dsisr_set = mfc_dsisr_set, 526 .mfc_dsisr_set = mfc_dsisr_set,
149 .mfc_sdr_set = mfc_sdr_set, 527 .mfc_sdr_setup = mfc_sdr_setup,
150 .mfc_sr1_set = mfc_sr1_set, 528 .mfc_sr1_set = mfc_sr1_set,
151 .mfc_sr1_get = mfc_sr1_get, 529 .mfc_sr1_get = mfc_sr1_get,
152 .mfc_tclass_id_set = mfc_tclass_id_set, 530 .mfc_tclass_id_set = mfc_tclass_id_set,
diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.h b/arch/powerpc/platforms/cell/spu_priv1_mmio.h
new file mode 100644
index 000000000000..7b62bd1cc256
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.h
@@ -0,0 +1,26 @@
1/*
2 * spu hypervisor abstraction for direct hardware access.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef SPU_PRIV1_MMIO_H
22#define SPU_PRIV1_MMIO_H
23
24struct device_node *spu_devnode(struct spu *spu);
25
26#endif /* SPU_PRIV1_MMIO_H */
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile
index ecdfbb35f82e..472217d19faf 100644
--- a/arch/powerpc/platforms/cell/spufs/Makefile
+++ b/arch/powerpc/platforms/cell/spufs/Makefile
@@ -1,7 +1,7 @@
1obj-y += switch.o 1obj-y += switch.o
2 2
3obj-$(CONFIG_SPU_FS) += spufs.o 3obj-$(CONFIG_SPU_FS) += spufs.o
4spufs-y += inode.o file.o context.o syscalls.o 4spufs-y += inode.o file.o context.o syscalls.o coredump.o
5spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o 5spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o
6 6
7# Rules to build switch.o with the help of SPU tool chain 7# Rules to build switch.o with the help of SPU tool chain
diff --git a/arch/powerpc/platforms/cell/spufs/backing_ops.c b/arch/powerpc/platforms/cell/spufs/backing_ops.c
index 2d22cd59d6fc..1898f0d3a8b8 100644
--- a/arch/powerpc/platforms/cell/spufs/backing_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/backing_ops.c
@@ -36,6 +36,7 @@
36#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/spu.h> 37#include <asm/spu.h>
38#include <asm/spu_csa.h> 38#include <asm/spu_csa.h>
39#include <asm/spu_info.h>
39#include <asm/mmu_context.h> 40#include <asm/mmu_context.h>
40#include "spufs.h" 41#include "spufs.h"
41 42
@@ -267,6 +268,11 @@ static char *spu_backing_get_ls(struct spu_context *ctx)
267 return ctx->csa.lscsa->ls; 268 return ctx->csa.lscsa->ls;
268} 269}
269 270
271static u32 spu_backing_runcntl_read(struct spu_context *ctx)
272{
273 return ctx->csa.prob.spu_runcntl_RW;
274}
275
270static void spu_backing_runcntl_write(struct spu_context *ctx, u32 val) 276static void spu_backing_runcntl_write(struct spu_context *ctx, u32 val)
271{ 277{
272 spin_lock(&ctx->csa.register_lock); 278 spin_lock(&ctx->csa.register_lock);
@@ -279,9 +285,26 @@ static void spu_backing_runcntl_write(struct spu_context *ctx, u32 val)
279 spin_unlock(&ctx->csa.register_lock); 285 spin_unlock(&ctx->csa.register_lock);
280} 286}
281 287
282static void spu_backing_runcntl_stop(struct spu_context *ctx) 288static void spu_backing_master_start(struct spu_context *ctx)
289{
290 struct spu_state *csa = &ctx->csa;
291 u64 sr1;
292
293 spin_lock(&csa->register_lock);
294 sr1 = csa->priv1.mfc_sr1_RW | MFC_STATE1_MASTER_RUN_CONTROL_MASK;
295 csa->priv1.mfc_sr1_RW = sr1;
296 spin_unlock(&csa->register_lock);
297}
298
299static void spu_backing_master_stop(struct spu_context *ctx)
283{ 300{
284 spu_backing_runcntl_write(ctx, SPU_RUNCNTL_STOP); 301 struct spu_state *csa = &ctx->csa;
302 u64 sr1;
303
304 spin_lock(&csa->register_lock);
305 sr1 = csa->priv1.mfc_sr1_RW & ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
306 csa->priv1.mfc_sr1_RW = sr1;
307 spin_unlock(&csa->register_lock);
285} 308}
286 309
287static int spu_backing_set_mfc_query(struct spu_context * ctx, u32 mask, 310static int spu_backing_set_mfc_query(struct spu_context * ctx, u32 mask,
@@ -345,8 +368,10 @@ struct spu_context_ops spu_backing_ops = {
345 .npc_write = spu_backing_npc_write, 368 .npc_write = spu_backing_npc_write,
346 .status_read = spu_backing_status_read, 369 .status_read = spu_backing_status_read,
347 .get_ls = spu_backing_get_ls, 370 .get_ls = spu_backing_get_ls,
371 .runcntl_read = spu_backing_runcntl_read,
348 .runcntl_write = spu_backing_runcntl_write, 372 .runcntl_write = spu_backing_runcntl_write,
349 .runcntl_stop = spu_backing_runcntl_stop, 373 .master_start = spu_backing_master_start,
374 .master_stop = spu_backing_master_stop,
350 .set_mfc_query = spu_backing_set_mfc_query, 375 .set_mfc_query = spu_backing_set_mfc_query,
351 .read_mfc_tagstatus = spu_backing_read_mfc_tagstatus, 376 .read_mfc_tagstatus = spu_backing_read_mfc_tagstatus,
352 .get_mfc_free_elements = spu_backing_get_mfc_free_elements, 377 .get_mfc_free_elements = spu_backing_get_mfc_free_elements,
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 034cf6af53a2..0870009f56db 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -120,6 +120,33 @@ void spu_unmap_mappings(struct spu_context *ctx)
120 unmap_mapping_range(ctx->signal2, 0, 0x4000, 1); 120 unmap_mapping_range(ctx->signal2, 0, 0x4000, 1);
121} 121}
122 122
123int spu_acquire_exclusive(struct spu_context *ctx)
124{
125 int ret = 0;
126
127 down_write(&ctx->state_sema);
128 /* ctx is about to be freed, can't acquire any more */
129 if (!ctx->owner) {
130 ret = -EINVAL;
131 goto out;
132 }
133
134 if (ctx->state == SPU_STATE_SAVED) {
135 ret = spu_activate(ctx, 0);
136 if (ret)
137 goto out;
138 ctx->state = SPU_STATE_RUNNABLE;
139 } else {
140 /* We need to exclude userspace access to the context. */
141 spu_unmap_mappings(ctx);
142 }
143
144out:
145 if (ret)
146 up_write(&ctx->state_sema);
147 return ret;
148}
149
123int spu_acquire_runnable(struct spu_context *ctx) 150int spu_acquire_runnable(struct spu_context *ctx)
124{ 151{
125 int ret = 0; 152 int ret = 0;
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
new file mode 100644
index 000000000000..26945c491f6b
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -0,0 +1,238 @@
1/*
2 * SPU core dump code
3 *
4 * (C) Copyright 2006 IBM Corp.
5 *
6 * Author: Dwayne Grant McConnell <decimal@us.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
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#include <linux/elf.h>
24#include <linux/file.h>
25#include <linux/fs.h>
26#include <linux/list.h>
27#include <linux/module.h>
28#include <linux/syscalls.h>
29
30#include <asm/uaccess.h>
31
32#include "spufs.h"
33
34struct spufs_ctx_info {
35 struct list_head list;
36 int dfd;
37 int memsize; /* in bytes */
38 struct spu_context *ctx;
39};
40
41static LIST_HEAD(ctx_info_list);
42
43static ssize_t do_coredump_read(int num, struct spu_context *ctx, void __user *buffer,
44 size_t size, loff_t *off)
45{
46 u64 data;
47 int ret;
48
49 if (spufs_coredump_read[num].read)
50 return spufs_coredump_read[num].read(ctx, buffer, size, off);
51
52 data = spufs_coredump_read[num].get(ctx);
53 ret = copy_to_user(buffer, &data, 8);
54 return ret ? -EFAULT : 8;
55}
56
57/*
58 * These are the only things you should do on a core-file: use only these
59 * functions to write out all the necessary info.
60 */
61static int spufs_dump_write(struct file *file, const void *addr, int nr)
62{
63 return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
64}
65
66static int spufs_dump_seek(struct file *file, loff_t off)
67{
68 if (file->f_op->llseek) {
69 if (file->f_op->llseek(file, off, 0) != off)
70 return 0;
71 } else
72 file->f_pos = off;
73 return 1;
74}
75
76static void spufs_fill_memsize(struct spufs_ctx_info *ctx_info)
77{
78 struct spu_context *ctx;
79 unsigned long long lslr;
80
81 ctx = ctx_info->ctx;
82 lslr = ctx->csa.priv2.spu_lslr_RW;
83 ctx_info->memsize = lslr + 1;
84}
85
86static int spufs_ctx_note_size(struct spufs_ctx_info *ctx_info)
87{
88 int dfd, memsize, i, sz, total = 0;
89 char *name;
90 char fullname[80];
91
92 dfd = ctx_info->dfd;
93 memsize = ctx_info->memsize;
94
95 for (i = 0; spufs_coredump_read[i].name; i++) {
96 name = spufs_coredump_read[i].name;
97 sz = spufs_coredump_read[i].size;
98
99 sprintf(fullname, "SPU/%d/%s", dfd, name);
100
101 total += sizeof(struct elf_note);
102 total += roundup(strlen(fullname) + 1, 4);
103 if (!strcmp(name, "mem"))
104 total += roundup(memsize, 4);
105 else
106 total += roundup(sz, 4);
107 }
108
109 return total;
110}
111
112static int spufs_add_one_context(struct file *file, int dfd)
113{
114 struct spu_context *ctx;
115 struct spufs_ctx_info *ctx_info;
116 int size;
117
118 ctx = SPUFS_I(file->f_dentry->d_inode)->i_ctx;
119 if (ctx->flags & SPU_CREATE_NOSCHED)
120 return 0;
121
122 ctx_info = kzalloc(sizeof(*ctx_info), GFP_KERNEL);
123 if (unlikely(!ctx_info))
124 return -ENOMEM;
125
126 ctx_info->dfd = dfd;
127 ctx_info->ctx = ctx;
128
129 spufs_fill_memsize(ctx_info);
130
131 size = spufs_ctx_note_size(ctx_info);
132 list_add(&ctx_info->list, &ctx_info_list);
133 return size;
134}
135
136/*
137 * The additional architecture-specific notes for Cell are various
138 * context files in the spu context.
139 *
140 * This function iterates over all open file descriptors and sees
141 * if they are a directory in spufs. In that case we use spufs
142 * internal functionality to dump them without needing to actually
143 * open the files.
144 */
145static int spufs_arch_notes_size(void)
146{
147 struct fdtable *fdt = files_fdtable(current->files);
148 int size = 0, fd;
149
150 for (fd = 0; fd < fdt->max_fdset && fd < fdt->max_fds; fd++) {
151 if (FD_ISSET(fd, fdt->open_fds)) {
152 struct file *file = fcheck(fd);
153
154 if (file && file->f_op == &spufs_context_fops) {
155 int rval = spufs_add_one_context(file, fd);
156 if (rval < 0)
157 break;
158 size += rval;
159 }
160 }
161 }
162
163 return size;
164}
165
166static void spufs_arch_write_note(struct spufs_ctx_info *ctx_info, int i,
167 struct file *file)
168{
169 struct spu_context *ctx;
170 loff_t pos = 0;
171 int sz, dfd, rc, total = 0;
172 const int bufsz = 4096;
173 char *name;
174 char fullname[80], *buf;
175 struct elf_note en;
176
177 buf = kmalloc(bufsz, GFP_KERNEL);
178 if (!buf)
179 return;
180
181 dfd = ctx_info->dfd;
182 name = spufs_coredump_read[i].name;
183
184 if (!strcmp(name, "mem"))
185 sz = ctx_info->memsize;
186 else
187 sz = spufs_coredump_read[i].size;
188
189 ctx = ctx_info->ctx;
190 if (!ctx) {
191 return;
192 }
193
194 sprintf(fullname, "SPU/%d/%s", dfd, name);
195 en.n_namesz = strlen(fullname) + 1;
196 en.n_descsz = sz;
197 en.n_type = NT_SPU;
198
199 if (!spufs_dump_write(file, &en, sizeof(en)))
200 return;
201 if (!spufs_dump_write(file, fullname, en.n_namesz))
202 return;
203 if (!spufs_dump_seek(file, roundup((unsigned long)file->f_pos, 4)))
204 return;
205
206 do {
207 rc = do_coredump_read(i, ctx, buf, bufsz, &pos);
208 if (rc > 0) {
209 if (!spufs_dump_write(file, buf, rc))
210 return;
211 total += rc;
212 }
213 } while (rc == bufsz && total < sz);
214
215 spufs_dump_seek(file, roundup((unsigned long)file->f_pos
216 - total + sz, 4));
217}
218
219static void spufs_arch_write_notes(struct file *file)
220{
221 int j;
222 struct spufs_ctx_info *ctx_info, *next;
223
224 list_for_each_entry_safe(ctx_info, next, &ctx_info_list, list) {
225 spu_acquire_saved(ctx_info->ctx);
226 for (j = 0; j < spufs_coredump_num_notes; j++)
227 spufs_arch_write_note(ctx_info, j, file);
228 spu_release(ctx_info->ctx);
229 list_del(&ctx_info->list);
230 kfree(ctx_info);
231 }
232}
233
234struct spu_coredump_calls spufs_coredump_calls = {
235 .arch_notes_size = spufs_arch_notes_size,
236 .arch_write_notes = spufs_arch_write_notes,
237 .owner = THIS_MODULE,
238};
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 533e2723e184..347eff56fcbd 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -32,13 +32,13 @@
32#include <asm/io.h> 32#include <asm/io.h>
33#include <asm/semaphore.h> 33#include <asm/semaphore.h>
34#include <asm/spu.h> 34#include <asm/spu.h>
35#include <asm/spu_info.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
37#include "spufs.h" 38#include "spufs.h"
38 39
39#define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000) 40#define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
40 41
41
42static int 42static int
43spufs_mem_open(struct inode *inode, struct file *file) 43spufs_mem_open(struct inode *inode, struct file *file)
44{ 44{
@@ -51,18 +51,23 @@ spufs_mem_open(struct inode *inode, struct file *file)
51} 51}
52 52
53static ssize_t 53static ssize_t
54__spufs_mem_read(struct spu_context *ctx, char __user *buffer,
55 size_t size, loff_t *pos)
56{
57 char *local_store = ctx->ops->get_ls(ctx);
58 return simple_read_from_buffer(buffer, size, pos, local_store,
59 LS_SIZE);
60}
61
62static ssize_t
54spufs_mem_read(struct file *file, char __user *buffer, 63spufs_mem_read(struct file *file, char __user *buffer,
55 size_t size, loff_t *pos) 64 size_t size, loff_t *pos)
56{ 65{
57 struct spu_context *ctx = file->private_data;
58 char *local_store;
59 int ret; 66 int ret;
67 struct spu_context *ctx = file->private_data;
60 68
61 spu_acquire(ctx); 69 spu_acquire(ctx);
62 70 ret = __spufs_mem_read(ctx, buffer, size, pos);
63 local_store = ctx->ops->get_ls(ctx);
64 ret = simple_read_from_buffer(buffer, size, pos, local_store, LS_SIZE);
65
66 spu_release(ctx); 71 spu_release(ctx);
67 return ret; 72 return ret;
68} 73}
@@ -104,11 +109,11 @@ spufs_mem_mmap_nopage(struct vm_area_struct *vma,
104 109
105 if (ctx->state == SPU_STATE_SAVED) { 110 if (ctx->state == SPU_STATE_SAVED) {
106 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 111 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
107 & ~(_PAGE_NO_CACHE | _PAGE_GUARDED)); 112 & ~_PAGE_NO_CACHE);
108 page = vmalloc_to_page(ctx->csa.lscsa->ls + offset); 113 page = vmalloc_to_page(ctx->csa.lscsa->ls + offset);
109 } else { 114 } else {
110 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 115 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
111 | _PAGE_NO_CACHE | _PAGE_GUARDED); 116 | _PAGE_NO_CACHE);
112 page = pfn_to_page((ctx->spu->local_store_phys + offset) 117 page = pfn_to_page((ctx->spu->local_store_phys + offset)
113 >> PAGE_SHIFT); 118 >> PAGE_SHIFT);
114 } 119 }
@@ -131,7 +136,7 @@ spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
131 if (!(vma->vm_flags & VM_SHARED)) 136 if (!(vma->vm_flags & VM_SHARED))
132 return -EINVAL; 137 return -EINVAL;
133 138
134 /* FIXME: */ 139 vma->vm_flags |= VM_IO;
135 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 140 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
136 | _PAGE_NO_CACHE); 141 | _PAGE_NO_CACHE);
137 142
@@ -200,7 +205,7 @@ static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
200 if (!(vma->vm_flags & VM_SHARED)) 205 if (!(vma->vm_flags & VM_SHARED))
201 return -EINVAL; 206 return -EINVAL;
202 207
203 vma->vm_flags |= VM_RESERVED; 208 vma->vm_flags |= VM_IO;
204 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 209 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
205 | _PAGE_NO_CACHE | _PAGE_GUARDED); 210 | _PAGE_NO_CACHE | _PAGE_GUARDED);
206 211
@@ -261,18 +266,23 @@ spufs_regs_open(struct inode *inode, struct file *file)
261} 266}
262 267
263static ssize_t 268static ssize_t
269__spufs_regs_read(struct spu_context *ctx, char __user *buffer,
270 size_t size, loff_t *pos)
271{
272 struct spu_lscsa *lscsa = ctx->csa.lscsa;
273 return simple_read_from_buffer(buffer, size, pos,
274 lscsa->gprs, sizeof lscsa->gprs);
275}
276
277static ssize_t
264spufs_regs_read(struct file *file, char __user *buffer, 278spufs_regs_read(struct file *file, char __user *buffer,
265 size_t size, loff_t *pos) 279 size_t size, loff_t *pos)
266{ 280{
267 struct spu_context *ctx = file->private_data;
268 struct spu_lscsa *lscsa = ctx->csa.lscsa;
269 int ret; 281 int ret;
282 struct spu_context *ctx = file->private_data;
270 283
271 spu_acquire_saved(ctx); 284 spu_acquire_saved(ctx);
272 285 ret = __spufs_regs_read(ctx, buffer, size, pos);
273 ret = simple_read_from_buffer(buffer, size, pos,
274 lscsa->gprs, sizeof lscsa->gprs);
275
276 spu_release(ctx); 286 spu_release(ctx);
277 return ret; 287 return ret;
278} 288}
@@ -307,18 +317,23 @@ static struct file_operations spufs_regs_fops = {
307}; 317};
308 318
309static ssize_t 319static ssize_t
320__spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
321 size_t size, loff_t * pos)
322{
323 struct spu_lscsa *lscsa = ctx->csa.lscsa;
324 return simple_read_from_buffer(buffer, size, pos,
325 &lscsa->fpcr, sizeof(lscsa->fpcr));
326}
327
328static ssize_t
310spufs_fpcr_read(struct file *file, char __user * buffer, 329spufs_fpcr_read(struct file *file, char __user * buffer,
311 size_t size, loff_t * pos) 330 size_t size, loff_t * pos)
312{ 331{
313 struct spu_context *ctx = file->private_data;
314 struct spu_lscsa *lscsa = ctx->csa.lscsa;
315 int ret; 332 int ret;
333 struct spu_context *ctx = file->private_data;
316 334
317 spu_acquire_saved(ctx); 335 spu_acquire_saved(ctx);
318 336 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
319 ret = simple_read_from_buffer(buffer, size, pos,
320 &lscsa->fpcr, sizeof(lscsa->fpcr));
321
322 spu_release(ctx); 337 spu_release(ctx);
323 return ret; 338 return ret;
324} 339}
@@ -718,23 +733,41 @@ static int spufs_signal1_open(struct inode *inode, struct file *file)
718 return nonseekable_open(inode, file); 733 return nonseekable_open(inode, file);
719} 734}
720 735
721static ssize_t spufs_signal1_read(struct file *file, char __user *buf, 736static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
722 size_t len, loff_t *pos) 737 size_t len, loff_t *pos)
723{ 738{
724 struct spu_context *ctx = file->private_data; 739 int ret = 0;
725 u32 data; 740 u32 data;
726 741
727 if (len < 4) 742 if (len < 4)
728 return -EINVAL; 743 return -EINVAL;
729 744
730 spu_acquire(ctx); 745 if (ctx->csa.spu_chnlcnt_RW[3]) {
731 data = ctx->ops->signal1_read(ctx); 746 data = ctx->csa.spu_chnldata_RW[3];
732 spu_release(ctx); 747 ret = 4;
748 }
749
750 if (!ret)
751 goto out;
733 752
734 if (copy_to_user(buf, &data, 4)) 753 if (copy_to_user(buf, &data, 4))
735 return -EFAULT; 754 return -EFAULT;
736 755
737 return 4; 756out:
757 return ret;
758}
759
760static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
761 size_t len, loff_t *pos)
762{
763 int ret;
764 struct spu_context *ctx = file->private_data;
765
766 spu_acquire_saved(ctx);
767 ret = __spufs_signal1_read(ctx, buf, len, pos);
768 spu_release(ctx);
769
770 return ret;
738} 771}
739 772
740static ssize_t spufs_signal1_write(struct file *file, const char __user *buf, 773static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
@@ -782,7 +815,7 @@ static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
782 if (!(vma->vm_flags & VM_SHARED)) 815 if (!(vma->vm_flags & VM_SHARED))
783 return -EINVAL; 816 return -EINVAL;
784 817
785 vma->vm_flags |= VM_RESERVED; 818 vma->vm_flags |= VM_IO;
786 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 819 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
787 | _PAGE_NO_CACHE | _PAGE_GUARDED); 820 | _PAGE_NO_CACHE | _PAGE_GUARDED);
788 821
@@ -807,25 +840,41 @@ static int spufs_signal2_open(struct inode *inode, struct file *file)
807 return nonseekable_open(inode, file); 840 return nonseekable_open(inode, file);
808} 841}
809 842
810static ssize_t spufs_signal2_read(struct file *file, char __user *buf, 843static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
811 size_t len, loff_t *pos) 844 size_t len, loff_t *pos)
812{ 845{
813 struct spu_context *ctx; 846 int ret = 0;
814 u32 data; 847 u32 data;
815 848
816 ctx = file->private_data;
817
818 if (len < 4) 849 if (len < 4)
819 return -EINVAL; 850 return -EINVAL;
820 851
821 spu_acquire(ctx); 852 if (ctx->csa.spu_chnlcnt_RW[4]) {
822 data = ctx->ops->signal2_read(ctx); 853 data = ctx->csa.spu_chnldata_RW[4];
823 spu_release(ctx); 854 ret = 4;
855 }
856
857 if (!ret)
858 goto out;
824 859
825 if (copy_to_user(buf, &data, 4)) 860 if (copy_to_user(buf, &data, 4))
826 return -EFAULT; 861 return -EFAULT;
827 862
828 return 4; 863out:
864 return ret;
865}
866
867static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
868 size_t len, loff_t *pos)
869{
870 struct spu_context *ctx = file->private_data;
871 int ret;
872
873 spu_acquire_saved(ctx);
874 ret = __spufs_signal2_read(ctx, buf, len, pos);
875 spu_release(ctx);
876
877 return ret;
829} 878}
830 879
831static ssize_t spufs_signal2_write(struct file *file, const char __user *buf, 880static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
@@ -874,8 +923,7 @@ static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
874 if (!(vma->vm_flags & VM_SHARED)) 923 if (!(vma->vm_flags & VM_SHARED))
875 return -EINVAL; 924 return -EINVAL;
876 925
877 /* FIXME: */ 926 vma->vm_flags |= VM_IO;
878 vma->vm_flags |= VM_RESERVED;
879 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 927 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
880 | _PAGE_NO_CACHE | _PAGE_GUARDED); 928 | _PAGE_NO_CACHE | _PAGE_GUARDED);
881 929
@@ -902,13 +950,19 @@ static void spufs_signal1_type_set(void *data, u64 val)
902 spu_release(ctx); 950 spu_release(ctx);
903} 951}
904 952
953static u64 __spufs_signal1_type_get(void *data)
954{
955 struct spu_context *ctx = data;
956 return ctx->ops->signal1_type_get(ctx);
957}
958
905static u64 spufs_signal1_type_get(void *data) 959static u64 spufs_signal1_type_get(void *data)
906{ 960{
907 struct spu_context *ctx = data; 961 struct spu_context *ctx = data;
908 u64 ret; 962 u64 ret;
909 963
910 spu_acquire(ctx); 964 spu_acquire(ctx);
911 ret = ctx->ops->signal1_type_get(ctx); 965 ret = __spufs_signal1_type_get(data);
912 spu_release(ctx); 966 spu_release(ctx);
913 967
914 return ret; 968 return ret;
@@ -925,13 +979,19 @@ static void spufs_signal2_type_set(void *data, u64 val)
925 spu_release(ctx); 979 spu_release(ctx);
926} 980}
927 981
982static u64 __spufs_signal2_type_get(void *data)
983{
984 struct spu_context *ctx = data;
985 return ctx->ops->signal2_type_get(ctx);
986}
987
928static u64 spufs_signal2_type_get(void *data) 988static u64 spufs_signal2_type_get(void *data)
929{ 989{
930 struct spu_context *ctx = data; 990 struct spu_context *ctx = data;
931 u64 ret; 991 u64 ret;
932 992
933 spu_acquire(ctx); 993 spu_acquire(ctx);
934 ret = ctx->ops->signal2_type_get(ctx); 994 ret = __spufs_signal2_type_get(data);
935 spu_release(ctx); 995 spu_release(ctx);
936 996
937 return ret; 997 return ret;
@@ -958,7 +1018,7 @@ static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
958 if (!(vma->vm_flags & VM_SHARED)) 1018 if (!(vma->vm_flags & VM_SHARED))
959 return -EINVAL; 1019 return -EINVAL;
960 1020
961 vma->vm_flags |= VM_RESERVED; 1021 vma->vm_flags |= VM_IO;
962 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 1022 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
963 | _PAGE_NO_CACHE | _PAGE_GUARDED); 1023 | _PAGE_NO_CACHE | _PAGE_GUARDED);
964 1024
@@ -1000,7 +1060,7 @@ static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1000 if (!(vma->vm_flags & VM_SHARED)) 1060 if (!(vma->vm_flags & VM_SHARED))
1001 return -EINVAL; 1061 return -EINVAL;
1002 1062
1003 vma->vm_flags |= VM_RESERVED; 1063 vma->vm_flags |= VM_IO;
1004 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 1064 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1005 | _PAGE_NO_CACHE | _PAGE_GUARDED); 1065 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1006 1066
@@ -1041,7 +1101,7 @@ static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1041 if (!(vma->vm_flags & VM_SHARED)) 1101 if (!(vma->vm_flags & VM_SHARED))
1042 return -EINVAL; 1102 return -EINVAL;
1043 1103
1044 vma->vm_flags |= VM_RESERVED; 1104 vma->vm_flags |= VM_IO;
1045 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) 1105 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1046 | _PAGE_NO_CACHE | _PAGE_GUARDED); 1106 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1047 1107
@@ -1265,6 +1325,7 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1265 goto out; 1325 goto out;
1266 1326
1267 ctx->tagwait |= 1 << cmd.tag; 1327 ctx->tagwait |= 1 << cmd.tag;
1328 ret = size;
1268 1329
1269out: 1330out:
1270 return ret; 1331 return ret;
@@ -1360,7 +1421,8 @@ static u64 spufs_npc_get(void *data)
1360 spu_release(ctx); 1421 spu_release(ctx);
1361 return ret; 1422 return ret;
1362} 1423}
1363DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set, "%llx\n") 1424DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1425 "0x%llx\n")
1364 1426
1365static void spufs_decr_set(void *data, u64 val) 1427static void spufs_decr_set(void *data, u64 val)
1366{ 1428{
@@ -1371,18 +1433,24 @@ static void spufs_decr_set(void *data, u64 val)
1371 spu_release(ctx); 1433 spu_release(ctx);
1372} 1434}
1373 1435
1374static u64 spufs_decr_get(void *data) 1436static u64 __spufs_decr_get(void *data)
1375{ 1437{
1376 struct spu_context *ctx = data; 1438 struct spu_context *ctx = data;
1377 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1439 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1440 return lscsa->decr.slot[0];
1441}
1442
1443static u64 spufs_decr_get(void *data)
1444{
1445 struct spu_context *ctx = data;
1378 u64 ret; 1446 u64 ret;
1379 spu_acquire_saved(ctx); 1447 spu_acquire_saved(ctx);
1380 ret = lscsa->decr.slot[0]; 1448 ret = __spufs_decr_get(data);
1381 spu_release(ctx); 1449 spu_release(ctx);
1382 return ret; 1450 return ret;
1383} 1451}
1384DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set, 1452DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1385 "%llx\n") 1453 "0x%llx\n")
1386 1454
1387static void spufs_decr_status_set(void *data, u64 val) 1455static void spufs_decr_status_set(void *data, u64 val)
1388{ 1456{
@@ -1393,62 +1461,76 @@ static void spufs_decr_status_set(void *data, u64 val)
1393 spu_release(ctx); 1461 spu_release(ctx);
1394} 1462}
1395 1463
1396static u64 spufs_decr_status_get(void *data) 1464static u64 __spufs_decr_status_get(void *data)
1397{ 1465{
1398 struct spu_context *ctx = data; 1466 struct spu_context *ctx = data;
1399 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1467 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1468 return lscsa->decr_status.slot[0];
1469}
1470
1471static u64 spufs_decr_status_get(void *data)
1472{
1473 struct spu_context *ctx = data;
1400 u64 ret; 1474 u64 ret;
1401 spu_acquire_saved(ctx); 1475 spu_acquire_saved(ctx);
1402 ret = lscsa->decr_status.slot[0]; 1476 ret = __spufs_decr_status_get(data);
1403 spu_release(ctx); 1477 spu_release(ctx);
1404 return ret; 1478 return ret;
1405} 1479}
1406DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get, 1480DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1407 spufs_decr_status_set, "%llx\n") 1481 spufs_decr_status_set, "0x%llx\n")
1408 1482
1409static void spufs_spu_tag_mask_set(void *data, u64 val) 1483static void spufs_event_mask_set(void *data, u64 val)
1410{ 1484{
1411 struct spu_context *ctx = data; 1485 struct spu_context *ctx = data;
1412 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1486 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1413 spu_acquire_saved(ctx); 1487 spu_acquire_saved(ctx);
1414 lscsa->tag_mask.slot[0] = (u32) val; 1488 lscsa->event_mask.slot[0] = (u32) val;
1415 spu_release(ctx); 1489 spu_release(ctx);
1416} 1490}
1417 1491
1418static u64 spufs_spu_tag_mask_get(void *data) 1492static u64 __spufs_event_mask_get(void *data)
1419{ 1493{
1420 struct spu_context *ctx = data; 1494 struct spu_context *ctx = data;
1421 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1495 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1496 return lscsa->event_mask.slot[0];
1497}
1498
1499static u64 spufs_event_mask_get(void *data)
1500{
1501 struct spu_context *ctx = data;
1422 u64 ret; 1502 u64 ret;
1423 spu_acquire_saved(ctx); 1503 spu_acquire_saved(ctx);
1424 ret = lscsa->tag_mask.slot[0]; 1504 ret = __spufs_event_mask_get(data);
1425 spu_release(ctx); 1505 spu_release(ctx);
1426 return ret; 1506 return ret;
1427} 1507}
1428DEFINE_SIMPLE_ATTRIBUTE(spufs_spu_tag_mask_ops, spufs_spu_tag_mask_get, 1508DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1429 spufs_spu_tag_mask_set, "%llx\n") 1509 spufs_event_mask_set, "0x%llx\n")
1430 1510
1431static void spufs_event_mask_set(void *data, u64 val) 1511static u64 __spufs_event_status_get(void *data)
1432{ 1512{
1433 struct spu_context *ctx = data; 1513 struct spu_context *ctx = data;
1434 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1514 struct spu_state *state = &ctx->csa;
1435 spu_acquire_saved(ctx); 1515 u64 stat;
1436 lscsa->event_mask.slot[0] = (u32) val; 1516 stat = state->spu_chnlcnt_RW[0];
1437 spu_release(ctx); 1517 if (stat)
1518 return state->spu_chnldata_RW[0];
1519 return 0;
1438} 1520}
1439 1521
1440static u64 spufs_event_mask_get(void *data) 1522static u64 spufs_event_status_get(void *data)
1441{ 1523{
1442 struct spu_context *ctx = data; 1524 struct spu_context *ctx = data;
1443 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1525 u64 ret = 0;
1444 u64 ret; 1526
1445 spu_acquire_saved(ctx); 1527 spu_acquire_saved(ctx);
1446 ret = lscsa->event_mask.slot[0]; 1528 ret = __spufs_event_status_get(data);
1447 spu_release(ctx); 1529 spu_release(ctx);
1448 return ret; 1530 return ret;
1449} 1531}
1450DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get, 1532DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1451 spufs_event_mask_set, "%llx\n") 1533 NULL, "0x%llx\n")
1452 1534
1453static void spufs_srr0_set(void *data, u64 val) 1535static void spufs_srr0_set(void *data, u64 val)
1454{ 1536{
@@ -1470,7 +1552,7 @@ static u64 spufs_srr0_get(void *data)
1470 return ret; 1552 return ret;
1471} 1553}
1472DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set, 1554DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1473 "%llx\n") 1555 "0x%llx\n")
1474 1556
1475static u64 spufs_id_get(void *data) 1557static u64 spufs_id_get(void *data)
1476{ 1558{
@@ -1488,12 +1570,18 @@ static u64 spufs_id_get(void *data)
1488} 1570}
1489DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n") 1571DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n")
1490 1572
1491static u64 spufs_object_id_get(void *data) 1573static u64 __spufs_object_id_get(void *data)
1492{ 1574{
1493 struct spu_context *ctx = data; 1575 struct spu_context *ctx = data;
1494 return ctx->object_id; 1576 return ctx->object_id;
1495} 1577}
1496 1578
1579static u64 spufs_object_id_get(void *data)
1580{
1581 /* FIXME: Should there really be no locking here? */
1582 return __spufs_object_id_get(data);
1583}
1584
1497static void spufs_object_id_set(void *data, u64 id) 1585static void spufs_object_id_set(void *data, u64 id)
1498{ 1586{
1499 struct spu_context *ctx = data; 1587 struct spu_context *ctx = data;
@@ -1503,6 +1591,250 @@ static void spufs_object_id_set(void *data, u64 id)
1503DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get, 1591DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
1504 spufs_object_id_set, "0x%llx\n"); 1592 spufs_object_id_set, "0x%llx\n");
1505 1593
1594static u64 __spufs_lslr_get(void *data)
1595{
1596 struct spu_context *ctx = data;
1597 return ctx->csa.priv2.spu_lslr_RW;
1598}
1599
1600static u64 spufs_lslr_get(void *data)
1601{
1602 struct spu_context *ctx = data;
1603 u64 ret;
1604
1605 spu_acquire_saved(ctx);
1606 ret = __spufs_lslr_get(data);
1607 spu_release(ctx);
1608
1609 return ret;
1610}
1611DEFINE_SIMPLE_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n")
1612
1613static int spufs_info_open(struct inode *inode, struct file *file)
1614{
1615 struct spufs_inode_info *i = SPUFS_I(inode);
1616 struct spu_context *ctx = i->i_ctx;
1617 file->private_data = ctx;
1618 return 0;
1619}
1620
1621static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
1622 char __user *buf, size_t len, loff_t *pos)
1623{
1624 u32 mbox_stat;
1625 u32 data;
1626
1627 mbox_stat = ctx->csa.prob.mb_stat_R;
1628 if (mbox_stat & 0x0000ff) {
1629 data = ctx->csa.prob.pu_mb_R;
1630 }
1631
1632 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1633}
1634
1635static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1636 size_t len, loff_t *pos)
1637{
1638 int ret;
1639 struct spu_context *ctx = file->private_data;
1640
1641 if (!access_ok(VERIFY_WRITE, buf, len))
1642 return -EFAULT;
1643
1644 spu_acquire_saved(ctx);
1645 spin_lock(&ctx->csa.register_lock);
1646 ret = __spufs_mbox_info_read(ctx, buf, len, pos);
1647 spin_unlock(&ctx->csa.register_lock);
1648 spu_release(ctx);
1649
1650 return ret;
1651}
1652
1653static struct file_operations spufs_mbox_info_fops = {
1654 .open = spufs_info_open,
1655 .read = spufs_mbox_info_read,
1656 .llseek = generic_file_llseek,
1657};
1658
1659static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
1660 char __user *buf, size_t len, loff_t *pos)
1661{
1662 u32 ibox_stat;
1663 u32 data;
1664
1665 ibox_stat = ctx->csa.prob.mb_stat_R;
1666 if (ibox_stat & 0xff0000) {
1667 data = ctx->csa.priv2.puint_mb_R;
1668 }
1669
1670 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1671}
1672
1673static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
1674 size_t len, loff_t *pos)
1675{
1676 struct spu_context *ctx = file->private_data;
1677 int ret;
1678
1679 if (!access_ok(VERIFY_WRITE, buf, len))
1680 return -EFAULT;
1681
1682 spu_acquire_saved(ctx);
1683 spin_lock(&ctx->csa.register_lock);
1684 ret = __spufs_ibox_info_read(ctx, buf, len, pos);
1685 spin_unlock(&ctx->csa.register_lock);
1686 spu_release(ctx);
1687
1688 return ret;
1689}
1690
1691static struct file_operations spufs_ibox_info_fops = {
1692 .open = spufs_info_open,
1693 .read = spufs_ibox_info_read,
1694 .llseek = generic_file_llseek,
1695};
1696
1697static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
1698 char __user *buf, size_t len, loff_t *pos)
1699{
1700 int i, cnt;
1701 u32 data[4];
1702 u32 wbox_stat;
1703
1704 wbox_stat = ctx->csa.prob.mb_stat_R;
1705 cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
1706 for (i = 0; i < cnt; i++) {
1707 data[i] = ctx->csa.spu_mailbox_data[i];
1708 }
1709
1710 return simple_read_from_buffer(buf, len, pos, &data,
1711 cnt * sizeof(u32));
1712}
1713
1714static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
1715 size_t len, loff_t *pos)
1716{
1717 struct spu_context *ctx = file->private_data;
1718 int ret;
1719
1720 if (!access_ok(VERIFY_WRITE, buf, len))
1721 return -EFAULT;
1722
1723 spu_acquire_saved(ctx);
1724 spin_lock(&ctx->csa.register_lock);
1725 ret = __spufs_wbox_info_read(ctx, buf, len, pos);
1726 spin_unlock(&ctx->csa.register_lock);
1727 spu_release(ctx);
1728
1729 return ret;
1730}
1731
1732static struct file_operations spufs_wbox_info_fops = {
1733 .open = spufs_info_open,
1734 .read = spufs_wbox_info_read,
1735 .llseek = generic_file_llseek,
1736};
1737
1738static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
1739 char __user *buf, size_t len, loff_t *pos)
1740{
1741 struct spu_dma_info info;
1742 struct mfc_cq_sr *qp, *spuqp;
1743 int i;
1744
1745 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
1746 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
1747 info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
1748 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
1749 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
1750 for (i = 0; i < 16; i++) {
1751 qp = &info.dma_info_command_data[i];
1752 spuqp = &ctx->csa.priv2.spuq[i];
1753
1754 qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
1755 qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
1756 qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
1757 qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
1758 }
1759
1760 return simple_read_from_buffer(buf, len, pos, &info,
1761 sizeof info);
1762}
1763
1764static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
1765 size_t len, loff_t *pos)
1766{
1767 struct spu_context *ctx = file->private_data;
1768 int ret;
1769
1770 if (!access_ok(VERIFY_WRITE, buf, len))
1771 return -EFAULT;
1772
1773 spu_acquire_saved(ctx);
1774 spin_lock(&ctx->csa.register_lock);
1775 ret = __spufs_dma_info_read(ctx, buf, len, pos);
1776 spin_unlock(&ctx->csa.register_lock);
1777 spu_release(ctx);
1778
1779 return ret;
1780}
1781
1782static struct file_operations spufs_dma_info_fops = {
1783 .open = spufs_info_open,
1784 .read = spufs_dma_info_read,
1785};
1786
1787static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
1788 char __user *buf, size_t len, loff_t *pos)
1789{
1790 struct spu_proxydma_info info;
1791 struct mfc_cq_sr *qp, *puqp;
1792 int ret = sizeof info;
1793 int i;
1794
1795 if (len < ret)
1796 return -EINVAL;
1797
1798 if (!access_ok(VERIFY_WRITE, buf, len))
1799 return -EFAULT;
1800
1801 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
1802 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
1803 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
1804 for (i = 0; i < 8; i++) {
1805 qp = &info.proxydma_info_command_data[i];
1806 puqp = &ctx->csa.priv2.puq[i];
1807
1808 qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
1809 qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
1810 qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
1811 qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
1812 }
1813
1814 return simple_read_from_buffer(buf, len, pos, &info,
1815 sizeof info);
1816}
1817
1818static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
1819 size_t len, loff_t *pos)
1820{
1821 struct spu_context *ctx = file->private_data;
1822 int ret;
1823
1824 spu_acquire_saved(ctx);
1825 spin_lock(&ctx->csa.register_lock);
1826 ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
1827 spin_unlock(&ctx->csa.register_lock);
1828 spu_release(ctx);
1829
1830 return ret;
1831}
1832
1833static struct file_operations spufs_proxydma_info_fops = {
1834 .open = spufs_info_open,
1835 .read = spufs_proxydma_info_read,
1836};
1837
1506struct tree_descr spufs_dir_contents[] = { 1838struct tree_descr spufs_dir_contents[] = {
1507 { "mem", &spufs_mem_fops, 0666, }, 1839 { "mem", &spufs_mem_fops, 0666, },
1508 { "regs", &spufs_regs_fops, 0666, }, 1840 { "regs", &spufs_regs_fops, 0666, },
@@ -1516,18 +1848,70 @@ struct tree_descr spufs_dir_contents[] = {
1516 { "signal2", &spufs_signal2_fops, 0666, }, 1848 { "signal2", &spufs_signal2_fops, 0666, },
1517 { "signal1_type", &spufs_signal1_type, 0666, }, 1849 { "signal1_type", &spufs_signal1_type, 0666, },
1518 { "signal2_type", &spufs_signal2_type, 0666, }, 1850 { "signal2_type", &spufs_signal2_type, 0666, },
1519 { "mss", &spufs_mss_fops, 0666, },
1520 { "mfc", &spufs_mfc_fops, 0666, },
1521 { "cntl", &spufs_cntl_fops, 0666, }, 1851 { "cntl", &spufs_cntl_fops, 0666, },
1522 { "npc", &spufs_npc_ops, 0666, },
1523 { "fpcr", &spufs_fpcr_fops, 0666, }, 1852 { "fpcr", &spufs_fpcr_fops, 0666, },
1853 { "lslr", &spufs_lslr_ops, 0444, },
1854 { "mfc", &spufs_mfc_fops, 0666, },
1855 { "mss", &spufs_mss_fops, 0666, },
1856 { "npc", &spufs_npc_ops, 0666, },
1857 { "srr0", &spufs_srr0_ops, 0666, },
1524 { "decr", &spufs_decr_ops, 0666, }, 1858 { "decr", &spufs_decr_ops, 0666, },
1525 { "decr_status", &spufs_decr_status_ops, 0666, }, 1859 { "decr_status", &spufs_decr_status_ops, 0666, },
1526 { "spu_tag_mask", &spufs_spu_tag_mask_ops, 0666, },
1527 { "event_mask", &spufs_event_mask_ops, 0666, }, 1860 { "event_mask", &spufs_event_mask_ops, 0666, },
1528 { "srr0", &spufs_srr0_ops, 0666, }, 1861 { "event_status", &spufs_event_status_ops, 0444, },
1862 { "psmap", &spufs_psmap_fops, 0666, },
1863 { "phys-id", &spufs_id_ops, 0666, },
1864 { "object-id", &spufs_object_id_ops, 0666, },
1865 { "mbox_info", &spufs_mbox_info_fops, 0444, },
1866 { "ibox_info", &spufs_ibox_info_fops, 0444, },
1867 { "wbox_info", &spufs_wbox_info_fops, 0444, },
1868 { "dma_info", &spufs_dma_info_fops, 0444, },
1869 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
1870 {},
1871};
1872
1873struct tree_descr spufs_dir_nosched_contents[] = {
1874 { "mem", &spufs_mem_fops, 0666, },
1875 { "mbox", &spufs_mbox_fops, 0444, },
1876 { "ibox", &spufs_ibox_fops, 0444, },
1877 { "wbox", &spufs_wbox_fops, 0222, },
1878 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1879 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1880 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1881 { "signal1", &spufs_signal1_fops, 0666, },
1882 { "signal2", &spufs_signal2_fops, 0666, },
1883 { "signal1_type", &spufs_signal1_type, 0666, },
1884 { "signal2_type", &spufs_signal2_type, 0666, },
1885 { "mss", &spufs_mss_fops, 0666, },
1886 { "mfc", &spufs_mfc_fops, 0666, },
1887 { "cntl", &spufs_cntl_fops, 0666, },
1888 { "npc", &spufs_npc_ops, 0666, },
1529 { "psmap", &spufs_psmap_fops, 0666, }, 1889 { "psmap", &spufs_psmap_fops, 0666, },
1530 { "phys-id", &spufs_id_ops, 0666, }, 1890 { "phys-id", &spufs_id_ops, 0666, },
1531 { "object-id", &spufs_object_id_ops, 0666, }, 1891 { "object-id", &spufs_object_id_ops, 0666, },
1532 {}, 1892 {},
1533}; 1893};
1894
1895struct spufs_coredump_reader spufs_coredump_read[] = {
1896 { "regs", __spufs_regs_read, NULL, 128 * 16 },
1897 { "fpcr", __spufs_fpcr_read, NULL, 16 },
1898 { "lslr", NULL, __spufs_lslr_get, 11 },
1899 { "decr", NULL, __spufs_decr_get, 11 },
1900 { "decr_status", NULL, __spufs_decr_status_get, 11 },
1901 { "mem", __spufs_mem_read, NULL, 256 * 1024, },
1902 { "signal1", __spufs_signal1_read, NULL, 4 },
1903 { "signal1_type", NULL, __spufs_signal1_type_get, 2 },
1904 { "signal2", __spufs_signal2_read, NULL, 4 },
1905 { "signal2_type", NULL, __spufs_signal2_type_get, 2 },
1906 { "event_mask", NULL, __spufs_event_mask_get, 8 },
1907 { "event_status", NULL, __spufs_event_status_get, 8 },
1908 { "mbox_info", __spufs_mbox_info_read, NULL, 4 },
1909 { "ibox_info", __spufs_ibox_info_read, NULL, 4 },
1910 { "wbox_info", __spufs_wbox_info_read, NULL, 16 },
1911 { "dma_info", __spufs_dma_info_read, NULL, 69 * 8 },
1912 { "proxydma_info", __spufs_proxydma_info_read, NULL, 35 * 8 },
1913 { "object-id", NULL, __spufs_object_id_get, 19 },
1914 { },
1915};
1916int spufs_coredump_num_notes = ARRAY_SIZE(spufs_coredump_read) - 1;
1917
diff --git a/arch/powerpc/platforms/cell/spufs/hw_ops.c b/arch/powerpc/platforms/cell/spufs/hw_ops.c
index d805ffed892d..ae42e03b8c86 100644
--- a/arch/powerpc/platforms/cell/spufs/hw_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/hw_ops.c
@@ -135,21 +135,11 @@ static int spu_hw_wbox_write(struct spu_context *ctx, u32 data)
135 return ret; 135 return ret;
136} 136}
137 137
138static u32 spu_hw_signal1_read(struct spu_context *ctx)
139{
140 return in_be32(&ctx->spu->problem->signal_notify1);
141}
142
143static void spu_hw_signal1_write(struct spu_context *ctx, u32 data) 138static void spu_hw_signal1_write(struct spu_context *ctx, u32 data)
144{ 139{
145 out_be32(&ctx->spu->problem->signal_notify1, data); 140 out_be32(&ctx->spu->problem->signal_notify1, data);
146} 141}
147 142
148static u32 spu_hw_signal2_read(struct spu_context *ctx)
149{
150 return in_be32(&ctx->spu->problem->signal_notify2);
151}
152
153static void spu_hw_signal2_write(struct spu_context *ctx, u32 data) 143static void spu_hw_signal2_write(struct spu_context *ctx, u32 data)
154{ 144{
155 out_be32(&ctx->spu->problem->signal_notify2, data); 145 out_be32(&ctx->spu->problem->signal_notify2, data);
@@ -217,21 +207,42 @@ static char *spu_hw_get_ls(struct spu_context *ctx)
217 return ctx->spu->local_store; 207 return ctx->spu->local_store;
218} 208}
219 209
220static void spu_hw_runcntl_write(struct spu_context *ctx, u32 val) 210static u32 spu_hw_runcntl_read(struct spu_context *ctx)
221{ 211{
222 eieio(); 212 return in_be32(&ctx->spu->problem->spu_runcntl_RW);
223 out_be32(&ctx->spu->problem->spu_runcntl_RW, val);
224} 213}
225 214
226static void spu_hw_runcntl_stop(struct spu_context *ctx) 215static void spu_hw_runcntl_write(struct spu_context *ctx, u32 val)
227{ 216{
228 spin_lock_irq(&ctx->spu->register_lock); 217 spin_lock_irq(&ctx->spu->register_lock);
229 out_be32(&ctx->spu->problem->spu_runcntl_RW, SPU_RUNCNTL_STOP); 218 if (val & SPU_RUNCNTL_ISOLATE)
230 while (in_be32(&ctx->spu->problem->spu_status_R) & SPU_STATUS_RUNNING) 219 out_be64(&ctx->spu->priv2->spu_privcntl_RW, 4LL);
231 cpu_relax(); 220 out_be32(&ctx->spu->problem->spu_runcntl_RW, val);
232 spin_unlock_irq(&ctx->spu->register_lock); 221 spin_unlock_irq(&ctx->spu->register_lock);
233} 222}
234 223
224static void spu_hw_master_start(struct spu_context *ctx)
225{
226 struct spu *spu = ctx->spu;
227 u64 sr1;
228
229 spin_lock_irq(&spu->register_lock);
230 sr1 = spu_mfc_sr1_get(spu) | MFC_STATE1_MASTER_RUN_CONTROL_MASK;
231 spu_mfc_sr1_set(spu, sr1);
232 spin_unlock_irq(&spu->register_lock);
233}
234
235static void spu_hw_master_stop(struct spu_context *ctx)
236{
237 struct spu *spu = ctx->spu;
238 u64 sr1;
239
240 spin_lock_irq(&spu->register_lock);
241 sr1 = spu_mfc_sr1_get(spu) & ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
242 spu_mfc_sr1_set(spu, sr1);
243 spin_unlock_irq(&spu->register_lock);
244}
245
235static int spu_hw_set_mfc_query(struct spu_context * ctx, u32 mask, u32 mode) 246static int spu_hw_set_mfc_query(struct spu_context * ctx, u32 mask, u32 mode)
236{ 247{
237 struct spu_problem __iomem *prob = ctx->spu->problem; 248 struct spu_problem __iomem *prob = ctx->spu->problem;
@@ -291,9 +302,7 @@ struct spu_context_ops spu_hw_ops = {
291 .mbox_stat_poll = spu_hw_mbox_stat_poll, 302 .mbox_stat_poll = spu_hw_mbox_stat_poll,
292 .ibox_read = spu_hw_ibox_read, 303 .ibox_read = spu_hw_ibox_read,
293 .wbox_write = spu_hw_wbox_write, 304 .wbox_write = spu_hw_wbox_write,
294 .signal1_read = spu_hw_signal1_read,
295 .signal1_write = spu_hw_signal1_write, 305 .signal1_write = spu_hw_signal1_write,
296 .signal2_read = spu_hw_signal2_read,
297 .signal2_write = spu_hw_signal2_write, 306 .signal2_write = spu_hw_signal2_write,
298 .signal1_type_set = spu_hw_signal1_type_set, 307 .signal1_type_set = spu_hw_signal1_type_set,
299 .signal1_type_get = spu_hw_signal1_type_get, 308 .signal1_type_get = spu_hw_signal1_type_get,
@@ -303,8 +312,10 @@ struct spu_context_ops spu_hw_ops = {
303 .npc_write = spu_hw_npc_write, 312 .npc_write = spu_hw_npc_write,
304 .status_read = spu_hw_status_read, 313 .status_read = spu_hw_status_read,
305 .get_ls = spu_hw_get_ls, 314 .get_ls = spu_hw_get_ls,
315 .runcntl_read = spu_hw_runcntl_read,
306 .runcntl_write = spu_hw_runcntl_write, 316 .runcntl_write = spu_hw_runcntl_write,
307 .runcntl_stop = spu_hw_runcntl_stop, 317 .master_start = spu_hw_master_start,
318 .master_stop = spu_hw_master_stop,
308 .set_mfc_query = spu_hw_set_mfc_query, 319 .set_mfc_query = spu_hw_set_mfc_query,
309 .read_mfc_tagstatus = spu_hw_read_mfc_tagstatus, 320 .read_mfc_tagstatus = spu_hw_read_mfc_tagstatus,
310 .get_mfc_free_elements = spu_hw_get_mfc_free_elements, 321 .get_mfc_free_elements = spu_hw_get_mfc_free_elements,
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 427d00a4f6a0..c7d010749a18 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -33,7 +33,7 @@
33#include <linux/slab.h> 33#include <linux/slab.h>
34#include <linux/parser.h> 34#include <linux/parser.h>
35 35
36#include <asm/io.h> 36#include <asm/prom.h>
37#include <asm/semaphore.h> 37#include <asm/semaphore.h>
38#include <asm/spu.h> 38#include <asm/spu.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
@@ -41,6 +41,7 @@
41#include "spufs.h" 41#include "spufs.h"
42 42
43static kmem_cache_t *spufs_inode_cache; 43static kmem_cache_t *spufs_inode_cache;
44char *isolated_loader;
44 45
45static struct inode * 46static struct inode *
46spufs_alloc_inode(struct super_block *sb) 47spufs_alloc_inode(struct super_block *sb)
@@ -231,6 +232,7 @@ struct file_operations spufs_context_fops = {
231 .readdir = dcache_readdir, 232 .readdir = dcache_readdir,
232 .fsync = simple_sync_file, 233 .fsync = simple_sync_file,
233}; 234};
235EXPORT_SYMBOL_GPL(spufs_context_fops);
234 236
235static int 237static int
236spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags, 238spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
@@ -255,10 +257,14 @@ spufs_mkdir(struct inode *dir, struct dentry *dentry, unsigned int flags,
255 goto out_iput; 257 goto out_iput;
256 258
257 ctx->flags = flags; 259 ctx->flags = flags;
258
259 inode->i_op = &spufs_dir_inode_operations; 260 inode->i_op = &spufs_dir_inode_operations;
260 inode->i_fop = &simple_dir_operations; 261 inode->i_fop = &simple_dir_operations;
261 ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx); 262 if (flags & SPU_CREATE_NOSCHED)
263 ret = spufs_fill_dir(dentry, spufs_dir_nosched_contents,
264 mode, ctx);
265 else
266 ret = spufs_fill_dir(dentry, spufs_dir_contents, mode, ctx);
267
262 if (ret) 268 if (ret)
263 goto out_free_ctx; 269 goto out_free_ctx;
264 270
@@ -307,6 +313,20 @@ static int spufs_create_context(struct inode *inode,
307{ 313{
308 int ret; 314 int ret;
309 315
316 ret = -EPERM;
317 if ((flags & SPU_CREATE_NOSCHED) &&
318 !capable(CAP_SYS_NICE))
319 goto out_unlock;
320
321 ret = -EINVAL;
322 if ((flags & (SPU_CREATE_NOSCHED | SPU_CREATE_ISOLATE))
323 == SPU_CREATE_ISOLATE)
324 goto out_unlock;
325
326 ret = -ENODEV;
327 if ((flags & SPU_CREATE_ISOLATE) && !isolated_loader)
328 goto out_unlock;
329
310 ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO); 330 ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO);
311 if (ret) 331 if (ret)
312 goto out_unlock; 332 goto out_unlock;
@@ -540,6 +560,30 @@ spufs_parse_options(char *options, struct inode *root)
540 return 1; 560 return 1;
541} 561}
542 562
563static void
564spufs_init_isolated_loader(void)
565{
566 struct device_node *dn;
567 const char *loader;
568 int size;
569
570 dn = of_find_node_by_path("/spu-isolation");
571 if (!dn)
572 return;
573
574 loader = get_property(dn, "loader", &size);
575 if (!loader)
576 return;
577
578 /* kmalloc should align on a 16 byte boundary..* */
579 isolated_loader = kmalloc(size, GFP_KERNEL);
580 if (!isolated_loader)
581 return;
582
583 memcpy(isolated_loader, loader, size);
584 printk(KERN_INFO "spufs: SPU isolation mode enabled\n");
585}
586
543static int 587static int
544spufs_create_root(struct super_block *sb, void *data) 588spufs_create_root(struct super_block *sb, void *data)
545{ 589{
@@ -608,6 +652,7 @@ static struct file_system_type spufs_type = {
608static int __init spufs_init(void) 652static int __init spufs_init(void)
609{ 653{
610 int ret; 654 int ret;
655
611 ret = -ENOMEM; 656 ret = -ENOMEM;
612 spufs_inode_cache = kmem_cache_create("spufs_inode_cache", 657 spufs_inode_cache = kmem_cache_create("spufs_inode_cache",
613 sizeof(struct spufs_inode_info), 0, 658 sizeof(struct spufs_inode_info), 0,
@@ -625,6 +670,12 @@ static int __init spufs_init(void)
625 ret = register_spu_syscalls(&spufs_calls); 670 ret = register_spu_syscalls(&spufs_calls);
626 if (ret) 671 if (ret)
627 goto out_fs; 672 goto out_fs;
673 ret = register_arch_coredump_calls(&spufs_coredump_calls);
674 if (ret)
675 goto out_fs;
676
677 spufs_init_isolated_loader();
678
628 return 0; 679 return 0;
629out_fs: 680out_fs:
630 unregister_filesystem(&spufs_type); 681 unregister_filesystem(&spufs_type);
@@ -638,6 +689,7 @@ module_init(spufs_init);
638static void __exit spufs_exit(void) 689static void __exit spufs_exit(void)
639{ 690{
640 spu_sched_exit(); 691 spu_sched_exit();
692 unregister_arch_coredump_calls(&spufs_coredump_calls);
641 unregister_spu_syscalls(&spufs_calls); 693 unregister_spu_syscalls(&spufs_calls);
642 unregister_filesystem(&spufs_type); 694 unregister_filesystem(&spufs_type);
643 kmem_cache_destroy(spufs_inode_cache); 695 kmem_cache_destroy(spufs_inode_cache);
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index 63df8cf4ba16..1acc2ffef8c8 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -1,7 +1,11 @@
1#define DEBUG
2
1#include <linux/wait.h> 3#include <linux/wait.h>
2#include <linux/ptrace.h> 4#include <linux/ptrace.h>
3 5
4#include <asm/spu.h> 6#include <asm/spu.h>
7#include <asm/spu_priv1.h>
8#include <asm/io.h>
5#include <asm/unistd.h> 9#include <asm/unistd.h>
6 10
7#include "spufs.h" 11#include "spufs.h"
@@ -24,6 +28,7 @@ void spufs_dma_callback(struct spu *spu, int type)
24 } else { 28 } else {
25 switch (type) { 29 switch (type) {
26 case SPE_EVENT_DMA_ALIGNMENT: 30 case SPE_EVENT_DMA_ALIGNMENT:
31 case SPE_EVENT_SPE_DATA_STORAGE:
27 case SPE_EVENT_INVALID_DMA: 32 case SPE_EVENT_INVALID_DMA:
28 force_sig(SIGBUS, /* info, */ current); 33 force_sig(SIGBUS, /* info, */ current);
29 break; 34 break;
@@ -48,15 +53,122 @@ static inline int spu_stopped(struct spu_context *ctx, u32 * stat)
48 return (!(*stat & 0x1) || pte_fault || spu->class_0_pending) ? 1 : 0; 53 return (!(*stat & 0x1) || pte_fault || spu->class_0_pending) ? 1 : 0;
49} 54}
50 55
56static int spu_setup_isolated(struct spu_context *ctx)
57{
58 int ret;
59 u64 __iomem *mfc_cntl;
60 u64 sr1;
61 u32 status;
62 unsigned long timeout;
63 const u32 status_loading = SPU_STATUS_RUNNING
64 | SPU_STATUS_ISOLATED_STATE | SPU_STATUS_ISOLATED_LOAD_STATUS;
65
66 if (!isolated_loader)
67 return -ENODEV;
68
69 ret = spu_acquire_exclusive(ctx);
70 if (ret)
71 goto out;
72
73 mfc_cntl = &ctx->spu->priv2->mfc_control_RW;
74
75 /* purge the MFC DMA queue to ensure no spurious accesses before we
76 * enter kernel mode */
77 timeout = jiffies + HZ;
78 out_be64(mfc_cntl, MFC_CNTL_PURGE_DMA_REQUEST);
79 while ((in_be64(mfc_cntl) & MFC_CNTL_PURGE_DMA_STATUS_MASK)
80 != MFC_CNTL_PURGE_DMA_COMPLETE) {
81 if (time_after(jiffies, timeout)) {
82 printk(KERN_ERR "%s: timeout flushing MFC DMA queue\n",
83 __FUNCTION__);
84 ret = -EIO;
85 goto out_unlock;
86 }
87 cond_resched();
88 }
89
90 /* put the SPE in kernel mode to allow access to the loader */
91 sr1 = spu_mfc_sr1_get(ctx->spu);
92 sr1 &= ~MFC_STATE1_PROBLEM_STATE_MASK;
93 spu_mfc_sr1_set(ctx->spu, sr1);
94
95 /* start the loader */
96 ctx->ops->signal1_write(ctx, (unsigned long)isolated_loader >> 32);
97 ctx->ops->signal2_write(ctx,
98 (unsigned long)isolated_loader & 0xffffffff);
99
100 ctx->ops->runcntl_write(ctx,
101 SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
102
103 ret = 0;
104 timeout = jiffies + HZ;
105 while (((status = ctx->ops->status_read(ctx)) & status_loading) ==
106 status_loading) {
107 if (time_after(jiffies, timeout)) {
108 printk(KERN_ERR "%s: timeout waiting for loader\n",
109 __FUNCTION__);
110 ret = -EIO;
111 goto out_drop_priv;
112 }
113 cond_resched();
114 }
115
116 if (!(status & SPU_STATUS_RUNNING)) {
117 /* If isolated LOAD has failed: run SPU, we will get a stop-and
118 * signal later. */
119 pr_debug("%s: isolated LOAD failed\n", __FUNCTION__);
120 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
121 ret = -EACCES;
122
123 } else if (!(status & SPU_STATUS_ISOLATED_STATE)) {
124 /* This isn't allowed by the CBEA, but check anyway */
125 pr_debug("%s: SPU fell out of isolated mode?\n", __FUNCTION__);
126 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_STOP);
127 ret = -EINVAL;
128 }
129
130out_drop_priv:
131 /* Finished accessing the loader. Drop kernel mode */
132 sr1 |= MFC_STATE1_PROBLEM_STATE_MASK;
133 spu_mfc_sr1_set(ctx->spu, sr1);
134
135out_unlock:
136 spu_release_exclusive(ctx);
137out:
138 return ret;
139}
140
51static inline int spu_run_init(struct spu_context *ctx, u32 * npc) 141static inline int spu_run_init(struct spu_context *ctx, u32 * npc)
52{ 142{
53 int ret; 143 int ret;
144 unsigned long runcntl = SPU_RUNCNTL_RUNNABLE;
54 145
55 if ((ret = spu_acquire_runnable(ctx)) != 0) 146 ret = spu_acquire_runnable(ctx);
147 if (ret)
56 return ret; 148 return ret;
57 ctx->ops->npc_write(ctx, *npc); 149
58 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE); 150 if (ctx->flags & SPU_CREATE_ISOLATE) {
59 return 0; 151 if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) {
152 /* Need to release ctx, because spu_setup_isolated will
153 * acquire it exclusively.
154 */
155 spu_release(ctx);
156 ret = spu_setup_isolated(ctx);
157 if (!ret)
158 ret = spu_acquire_runnable(ctx);
159 }
160
161 /* if userspace has set the runcntrl register (eg, to issue an
162 * isolated exit), we need to re-set it here */
163 runcntl = ctx->ops->runcntl_read(ctx) &
164 (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
165 if (runcntl == 0)
166 runcntl = SPU_RUNCNTL_RUNNABLE;
167 } else
168 ctx->ops->npc_write(ctx, *npc);
169
170 ctx->ops->runcntl_write(ctx, runcntl);
171 return ret;
60} 172}
61 173
62static inline int spu_run_fini(struct spu_context *ctx, u32 * npc, 174static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
@@ -70,13 +182,7 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
70 182
71 if (signal_pending(current)) 183 if (signal_pending(current))
72 ret = -ERESTARTSYS; 184 ret = -ERESTARTSYS;
73 if (unlikely(current->ptrace & PT_PTRACED)) { 185
74 if ((*status & SPU_STATUS_STOPPED_BY_STOP)
75 && (*status >> SPU_STOP_STATUS_SHIFT) == 0x3fff) {
76 force_sig(SIGTRAP, current);
77 ret = -ERESTARTSYS;
78 }
79 }
80 return ret; 186 return ret;
81} 187}
82 188
@@ -204,6 +310,7 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
204 if (down_interruptible(&ctx->run_sema)) 310 if (down_interruptible(&ctx->run_sema))
205 return -ERESTARTSYS; 311 return -ERESTARTSYS;
206 312
313 ctx->ops->master_start(ctx);
207 ctx->event_return = 0; 314 ctx->event_return = 0;
208 ret = spu_run_init(ctx, npc); 315 ret = spu_run_init(ctx, npc);
209 if (ret) 316 if (ret)
@@ -223,7 +330,7 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
223 if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) { 330 if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) {
224 ret = spu_reacquire_runnable(ctx, npc, &status); 331 ret = spu_reacquire_runnable(ctx, npc, &status);
225 if (ret) 332 if (ret)
226 goto out; 333 goto out2;
227 continue; 334 continue;
228 } 335 }
229 ret = spu_process_events(ctx); 336 ret = spu_process_events(ctx);
@@ -231,12 +338,24 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
231 } while (!ret && !(status & (SPU_STATUS_STOPPED_BY_STOP | 338 } while (!ret && !(status & (SPU_STATUS_STOPPED_BY_STOP |
232 SPU_STATUS_STOPPED_BY_HALT))); 339 SPU_STATUS_STOPPED_BY_HALT)));
233 340
234 ctx->ops->runcntl_stop(ctx); 341 ctx->ops->master_stop(ctx);
235 ret = spu_run_fini(ctx, npc, &status); 342 ret = spu_run_fini(ctx, npc, &status);
236 if (!ret)
237 ret = status;
238 spu_yield(ctx); 343 spu_yield(ctx);
239 344
345out2:
346 if ((ret == 0) ||
347 ((ret == -ERESTARTSYS) &&
348 ((status & SPU_STATUS_STOPPED_BY_HALT) ||
349 ((status & SPU_STATUS_STOPPED_BY_STOP) &&
350 (status >> SPU_STOP_STATUS_SHIFT != 0x2104)))))
351 ret = status;
352
353 if ((status & SPU_STATUS_STOPPED_BY_STOP)
354 && (status >> SPU_STOP_STATUS_SHIFT) == 0x3fff) {
355 force_sig(SIGTRAP, current);
356 ret = -ERESTARTSYS;
357 }
358
240out: 359out:
241 *event = ctx->event_return; 360 *event = ctx->event_return;
242 up(&ctx->run_sema); 361 up(&ctx->run_sema);
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index a0f55ca2d488..70fb13395c04 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -29,6 +29,7 @@
29 29
30#include <asm/spu.h> 30#include <asm/spu.h>
31#include <asm/spu_csa.h> 31#include <asm/spu_csa.h>
32#include <asm/spu_info.h>
32 33
33/* The magic number for our file system */ 34/* The magic number for our file system */
34enum { 35enum {
@@ -114,13 +115,19 @@ struct spu_context_ops {
114 void (*npc_write) (struct spu_context * ctx, u32 data); 115 void (*npc_write) (struct spu_context * ctx, u32 data);
115 u32(*status_read) (struct spu_context * ctx); 116 u32(*status_read) (struct spu_context * ctx);
116 char*(*get_ls) (struct spu_context * ctx); 117 char*(*get_ls) (struct spu_context * ctx);
118 u32 (*runcntl_read) (struct spu_context * ctx);
117 void (*runcntl_write) (struct spu_context * ctx, u32 data); 119 void (*runcntl_write) (struct spu_context * ctx, u32 data);
118 void (*runcntl_stop) (struct spu_context * ctx); 120 void (*master_start) (struct spu_context * ctx);
121 void (*master_stop) (struct spu_context * ctx);
119 int (*set_mfc_query)(struct spu_context * ctx, u32 mask, u32 mode); 122 int (*set_mfc_query)(struct spu_context * ctx, u32 mask, u32 mode);
120 u32 (*read_mfc_tagstatus)(struct spu_context * ctx); 123 u32 (*read_mfc_tagstatus)(struct spu_context * ctx);
121 u32 (*get_mfc_free_elements)(struct spu_context *ctx); 124 u32 (*get_mfc_free_elements)(struct spu_context *ctx);
122 int (*send_mfc_command)(struct spu_context *ctx, 125 int (*send_mfc_command)(struct spu_context * ctx,
123 struct mfc_dma_command *cmd); 126 struct mfc_dma_command * cmd);
127 void (*dma_info_read) (struct spu_context * ctx,
128 struct spu_dma_info * info);
129 void (*proxydma_info_read) (struct spu_context * ctx,
130 struct spu_proxydma_info * info);
124}; 131};
125 132
126extern struct spu_context_ops spu_hw_ops; 133extern struct spu_context_ops spu_hw_ops;
@@ -135,6 +142,7 @@ struct spufs_inode_info {
135 container_of(inode, struct spufs_inode_info, vfs_inode) 142 container_of(inode, struct spufs_inode_info, vfs_inode)
136 143
137extern struct tree_descr spufs_dir_contents[]; 144extern struct tree_descr spufs_dir_contents[];
145extern struct tree_descr spufs_dir_nosched_contents[];
138 146
139/* system call implementation */ 147/* system call implementation */
140long spufs_run_spu(struct file *file, 148long spufs_run_spu(struct file *file,
@@ -162,6 +170,12 @@ void spu_acquire(struct spu_context *ctx);
162void spu_release(struct spu_context *ctx); 170void spu_release(struct spu_context *ctx);
163int spu_acquire_runnable(struct spu_context *ctx); 171int spu_acquire_runnable(struct spu_context *ctx);
164void spu_acquire_saved(struct spu_context *ctx); 172void spu_acquire_saved(struct spu_context *ctx);
173int spu_acquire_exclusive(struct spu_context *ctx);
174
175static inline void spu_release_exclusive(struct spu_context *ctx)
176{
177 up_write(&ctx->state_sema);
178}
165 179
166int spu_activate(struct spu_context *ctx, u64 flags); 180int spu_activate(struct spu_context *ctx, u64 flags);
167void spu_deactivate(struct spu_context *ctx); 181void spu_deactivate(struct spu_context *ctx);
@@ -169,6 +183,8 @@ void spu_yield(struct spu_context *ctx);
169int __init spu_sched_init(void); 183int __init spu_sched_init(void);
170void __exit spu_sched_exit(void); 184void __exit spu_sched_exit(void);
171 185
186extern char *isolated_loader;
187
172/* 188/*
173 * spufs_wait 189 * spufs_wait
174 * Same as wait_event_interruptible(), except that here 190 * Same as wait_event_interruptible(), except that here
@@ -207,4 +223,15 @@ void spufs_stop_callback(struct spu *spu);
207void spufs_mfc_callback(struct spu *spu); 223void spufs_mfc_callback(struct spu *spu);
208void spufs_dma_callback(struct spu *spu, int type); 224void spufs_dma_callback(struct spu *spu, int type);
209 225
226extern struct spu_coredump_calls spufs_coredump_calls;
227struct spufs_coredump_reader {
228 char *name;
229 ssize_t (*read)(struct spu_context *ctx,
230 char __user *buffer, size_t size, loff_t *pos);
231 u64 (*get)(void *data);
232 size_t size;
233};
234extern struct spufs_coredump_reader spufs_coredump_read[];
235extern int spufs_coredump_num_notes;
236
210#endif 237#endif
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 0f782ca662ba..c08981ff7fc6 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -102,7 +102,7 @@ static inline int check_spu_isolate(struct spu_state *csa, struct spu *spu)
102 * saved at this time. 102 * saved at this time.
103 */ 103 */
104 isolate_state = SPU_STATUS_ISOLATED_STATE | 104 isolate_state = SPU_STATUS_ISOLATED_STATE |
105 SPU_STATUS_ISOLATED_LOAD_STAUTUS | SPU_STATUS_ISOLATED_EXIT_STAUTUS; 105 SPU_STATUS_ISOLATED_LOAD_STATUS | SPU_STATUS_ISOLATED_EXIT_STATUS;
106 return (in_be32(&prob->spu_status_R) & isolate_state) ? 1 : 0; 106 return (in_be32(&prob->spu_status_R) & isolate_state) ? 1 : 0;
107} 107}
108 108
@@ -1046,12 +1046,12 @@ static inline int suspend_spe(struct spu_state *csa, struct spu *spu)
1046 */ 1046 */
1047 if (in_be32(&prob->spu_status_R) & SPU_STATUS_RUNNING) { 1047 if (in_be32(&prob->spu_status_R) & SPU_STATUS_RUNNING) {
1048 if (in_be32(&prob->spu_status_R) & 1048 if (in_be32(&prob->spu_status_R) &
1049 SPU_STATUS_ISOLATED_EXIT_STAUTUS) { 1049 SPU_STATUS_ISOLATED_EXIT_STATUS) {
1050 POLL_WHILE_TRUE(in_be32(&prob->spu_status_R) & 1050 POLL_WHILE_TRUE(in_be32(&prob->spu_status_R) &
1051 SPU_STATUS_RUNNING); 1051 SPU_STATUS_RUNNING);
1052 } 1052 }
1053 if ((in_be32(&prob->spu_status_R) & 1053 if ((in_be32(&prob->spu_status_R) &
1054 SPU_STATUS_ISOLATED_LOAD_STAUTUS) 1054 SPU_STATUS_ISOLATED_LOAD_STATUS)
1055 || (in_be32(&prob->spu_status_R) & 1055 || (in_be32(&prob->spu_status_R) &
1056 SPU_STATUS_ISOLATED_STATE)) { 1056 SPU_STATUS_ISOLATED_STATE)) {
1057 out_be32(&prob->spu_runcntl_RW, SPU_RUNCNTL_STOP); 1057 out_be32(&prob->spu_runcntl_RW, SPU_RUNCNTL_STOP);
@@ -1085,7 +1085,7 @@ static inline void clear_spu_status(struct spu_state *csa, struct spu *spu)
1085 */ 1085 */
1086 if (!(in_be32(&prob->spu_status_R) & SPU_STATUS_RUNNING)) { 1086 if (!(in_be32(&prob->spu_status_R) & SPU_STATUS_RUNNING)) {
1087 if (in_be32(&prob->spu_status_R) & 1087 if (in_be32(&prob->spu_status_R) &
1088 SPU_STATUS_ISOLATED_EXIT_STAUTUS) { 1088 SPU_STATUS_ISOLATED_EXIT_STATUS) {
1089 spu_mfc_sr1_set(spu, 1089 spu_mfc_sr1_set(spu,
1090 MFC_STATE1_MASTER_RUN_CONTROL_MASK); 1090 MFC_STATE1_MASTER_RUN_CONTROL_MASK);
1091 eieio(); 1091 eieio();
@@ -1095,7 +1095,7 @@ static inline void clear_spu_status(struct spu_state *csa, struct spu *spu)
1095 SPU_STATUS_RUNNING); 1095 SPU_STATUS_RUNNING);
1096 } 1096 }
1097 if ((in_be32(&prob->spu_status_R) & 1097 if ((in_be32(&prob->spu_status_R) &
1098 SPU_STATUS_ISOLATED_LOAD_STAUTUS) 1098 SPU_STATUS_ISOLATED_LOAD_STATUS)
1099 || (in_be32(&prob->spu_status_R) & 1099 || (in_be32(&prob->spu_status_R) &
1100 SPU_STATUS_ISOLATED_STATE)) { 1100 SPU_STATUS_ISOLATED_STATE)) {
1101 spu_mfc_sr1_set(spu, 1101 spu_mfc_sr1_set(spu,
@@ -1916,6 +1916,51 @@ static void save_lscsa(struct spu_state *prev, struct spu *spu)
1916 wait_spu_stopped(prev, spu); /* Step 57. */ 1916 wait_spu_stopped(prev, spu); /* Step 57. */
1917} 1917}
1918 1918
1919static void force_spu_isolate_exit(struct spu *spu)
1920{
1921 struct spu_problem __iomem *prob = spu->problem;
1922 struct spu_priv2 __iomem *priv2 = spu->priv2;
1923
1924 /* Stop SPE execution and wait for completion. */
1925 out_be32(&prob->spu_runcntl_RW, SPU_RUNCNTL_STOP);
1926 iobarrier_rw();
1927 POLL_WHILE_TRUE(in_be32(&prob->spu_status_R) & SPU_STATUS_RUNNING);
1928
1929 /* Restart SPE master runcntl. */
1930 spu_mfc_sr1_set(spu, MFC_STATE1_MASTER_RUN_CONTROL_MASK);
1931 iobarrier_w();
1932
1933 /* Initiate isolate exit request and wait for completion. */
1934 out_be64(&priv2->spu_privcntl_RW, 4LL);
1935 iobarrier_w();
1936 out_be32(&prob->spu_runcntl_RW, 2);
1937 iobarrier_rw();
1938 POLL_WHILE_FALSE((in_be32(&prob->spu_status_R)
1939 & SPU_STATUS_STOPPED_BY_STOP));
1940
1941 /* Reset load request to normal. */
1942 out_be64(&priv2->spu_privcntl_RW, SPU_PRIVCNT_LOAD_REQUEST_NORMAL);
1943 iobarrier_w();
1944}
1945
1946/**
1947 * stop_spu_isolate
1948 * Check SPU run-control state and force isolated
1949 * exit function as necessary.
1950 */
1951static void stop_spu_isolate(struct spu *spu)
1952{
1953 struct spu_problem __iomem *prob = spu->problem;
1954
1955 if (in_be32(&prob->spu_status_R) & SPU_STATUS_ISOLATED_STATE) {
1956 /* The SPU is in isolated state; the only way
1957 * to get it out is to perform an isolated
1958 * exit (clean) operation.
1959 */
1960 force_spu_isolate_exit(spu);
1961 }
1962}
1963
1919static void harvest(struct spu_state *prev, struct spu *spu) 1964static void harvest(struct spu_state *prev, struct spu *spu)
1920{ 1965{
1921 /* 1966 /*
@@ -1928,6 +1973,7 @@ static void harvest(struct spu_state *prev, struct spu *spu)
1928 inhibit_user_access(prev, spu); /* Step 3. */ 1973 inhibit_user_access(prev, spu); /* Step 3. */
1929 terminate_spu_app(prev, spu); /* Step 4. */ 1974 terminate_spu_app(prev, spu); /* Step 4. */
1930 set_switch_pending(prev, spu); /* Step 5. */ 1975 set_switch_pending(prev, spu); /* Step 5. */
1976 stop_spu_isolate(spu); /* NEW. */
1931 remove_other_spu_access(prev, spu); /* Step 6. */ 1977 remove_other_spu_access(prev, spu); /* Step 6. */
1932 suspend_mfc(prev, spu); /* Step 7. */ 1978 suspend_mfc(prev, spu); /* Step 7. */
1933 wait_suspend_mfc_complete(prev, spu); /* Step 8. */ 1979 wait_suspend_mfc_complete(prev, spu); /* Step 8. */
@@ -2096,11 +2142,11 @@ int spu_save(struct spu_state *prev, struct spu *spu)
2096 acquire_spu_lock(spu); /* Step 1. */ 2142 acquire_spu_lock(spu); /* Step 1. */
2097 rc = __do_spu_save(prev, spu); /* Steps 2-53. */ 2143 rc = __do_spu_save(prev, spu); /* Steps 2-53. */
2098 release_spu_lock(spu); 2144 release_spu_lock(spu);
2099 if (rc) { 2145 if (rc != 0 && rc != 2 && rc != 6) {
2100 panic("%s failed on SPU[%d], rc=%d.\n", 2146 panic("%s failed on SPU[%d], rc=%d.\n",
2101 __func__, spu->number, rc); 2147 __func__, spu->number, rc);
2102 } 2148 }
2103 return rc; 2149 return 0;
2104} 2150}
2105EXPORT_SYMBOL_GPL(spu_save); 2151EXPORT_SYMBOL_GPL(spu_save);
2106 2152
@@ -2165,9 +2211,6 @@ static void init_priv1(struct spu_state *csa)
2165 MFC_STATE1_PROBLEM_STATE_MASK | 2211 MFC_STATE1_PROBLEM_STATE_MASK |
2166 MFC_STATE1_RELOCATE_MASK | MFC_STATE1_BUS_TLBIE_MASK; 2212 MFC_STATE1_RELOCATE_MASK | MFC_STATE1_BUS_TLBIE_MASK;
2167 2213
2168 /* Set storage description. */
2169 csa->priv1.mfc_sdr_RW = mfspr(SPRN_SDR1);
2170
2171 /* Enable OS-specific set of interrupts. */ 2214 /* Enable OS-specific set of interrupts. */
2172 csa->priv1.int_mask_class0_RW = CLASS0_ENABLE_DMA_ALIGNMENT_INTR | 2215 csa->priv1.int_mask_class0_RW = CLASS0_ENABLE_DMA_ALIGNMENT_INTR |
2173 CLASS0_ENABLE_INVALID_DMA_COMMAND_INTR | 2216 CLASS0_ENABLE_INVALID_DMA_COMMAND_INTR |
diff --git a/arch/powerpc/platforms/chrp/chrp.h b/arch/powerpc/platforms/chrp/chrp.h
index 996c28744e96..63f0aee4c158 100644
--- a/arch/powerpc/platforms/chrp/chrp.h
+++ b/arch/powerpc/platforms/chrp/chrp.h
@@ -9,4 +9,3 @@ extern long chrp_time_init(void);
9 9
10extern void chrp_find_bridges(void); 10extern void chrp_find_bridges(void);
11extern void chrp_event_scan(unsigned long); 11extern void chrp_event_scan(unsigned long);
12extern void chrp_pcibios_fixup(void);
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index 0f4340506c75..ddb4a116ea89 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -156,15 +156,6 @@ hydra_init(void)
156 return 1; 156 return 1;
157} 157}
158 158
159void __init
160chrp_pcibios_fixup(void)
161{
162 struct pci_dev *dev = NULL;
163
164 for_each_pci_dev(dev)
165 pci_read_irq_line(dev);
166}
167
168#define PRG_CL_RESET_VALID 0x00010000 159#define PRG_CL_RESET_VALID 0x00010000
169 160
170static void __init 161static void __init
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 49b8dabcbc99..e1f51d455984 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -588,7 +588,6 @@ static int __init chrp_probe(void)
588 ISA_DMA_THRESHOLD = ~0L; 588 ISA_DMA_THRESHOLD = ~0L;
589 DMA_MODE_READ = 0x44; 589 DMA_MODE_READ = 0x44;
590 DMA_MODE_WRITE = 0x48; 590 DMA_MODE_WRITE = 0x48;
591 isa_io_base = CHRP_ISA_IO_BASE; /* default value */
592 591
593 return 1; 592 return 1;
594} 593}
@@ -600,7 +599,6 @@ define_machine(chrp) {
600 .init = chrp_init2, 599 .init = chrp_init2,
601 .show_cpuinfo = chrp_show_cpuinfo, 600 .show_cpuinfo = chrp_show_cpuinfo,
602 .init_IRQ = chrp_init_IRQ, 601 .init_IRQ = chrp_init_IRQ,
603 .pcibios_fixup = chrp_pcibios_fixup,
604 .restart = rtas_restart, 602 .restart = rtas_restart,
605 .power_off = rtas_power_off, 603 .power_off = rtas_power_off,
606 .halt = rtas_halt, 604 .halt = rtas_halt,
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 234a861870a8..ddbe398fbd48 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -74,6 +74,18 @@ config SANDPOINT
74 Select SANDPOINT if configuring for a Motorola Sandpoint X3 74 Select SANDPOINT if configuring for a Motorola Sandpoint X3
75 (any flavor). 75 (any flavor).
76 76
77config LINKSTATION
78 bool "Linkstation / Kurobox(HG) from Buffalo"
79 select MPIC
80 select FSL_SOC
81 select PPC_UDBG_16550 if SERIAL_8250
82 help
83 Select LINKSTATION if configuring for one of PPC- (MPC8241)
84 based NAS systems from Buffalo Technology. So far only
85 KuroboxHG has been tested. In the future classical Kurobox,
86 Linkstation-I HD-HLAN and HD-HGLAN versions, and PPC-based
87 Terastation systems should be supported too.
88
77config MPC7448HPC2 89config MPC7448HPC2
78 bool "Freescale MPC7448HPC2(Taiga)" 90 bool "Freescale MPC7448HPC2(Taiga)"
79 select TSI108_BRIDGE 91 select TSI108_BRIDGE
@@ -146,15 +158,6 @@ config PQ2FADS
146 Select PQ2FADS if you wish to configure for a Freescale 158 Select PQ2FADS if you wish to configure for a Freescale
147 PQ2FADS board (-VR or -ZU). 159 PQ2FADS board (-VR or -ZU).
148 160
149config LITE5200
150 bool "Freescale LITE5200 / (IceCube)"
151 select PPC_MPC52xx
152 help
153 Support for the LITE5200 dev board for the MPC5200 from Freescale.
154 This is for the LITE5200 version 2.0 board. Don't know if it changes
155 much but it's only been tested on this board version. I think this
156 board is also known as IceCube.
157
158config EV64360 161config EV64360
159 bool "Marvell-EV64360BP" 162 bool "Marvell-EV64360BP"
160 help 163 help
@@ -172,9 +175,6 @@ config TQM8xxL
172 depends on 8xx && (TQM823L || TQM850L || FPS850L || TQM855L || TQM860L) 175 depends on 8xx && (TQM823L || TQM850L || FPS850L || TQM855L || TQM860L)
173 default y 176 default y
174 177
175config PPC_MPC52xx
176 bool
177
178config 8260 178config 8260
179 bool "CPM2 Support" if WILLOW 179 bool "CPM2 Support" if WILLOW
180 depends on 6xx 180 depends on 6xx
@@ -208,7 +208,7 @@ config PPC_GEN550
208 depends on SANDPOINT || SPRUCE || PPLUS || \ 208 depends on SANDPOINT || SPRUCE || PPLUS || \
209 PRPMC750 || PRPMC800 || LOPEC || \ 209 PRPMC750 || PRPMC800 || LOPEC || \
210 (EV64260 && !SERIAL_MPSC) || CHESTNUT || RADSTONE_PPC7D || \ 210 (EV64260 && !SERIAL_MPSC) || CHESTNUT || RADSTONE_PPC7D || \
211 83xx 211 83xx || LINKSTATION
212 default y 212 default y
213 213
214config FORCE 214config FORCE
@@ -282,13 +282,13 @@ config EPIC_SERIAL_MODE
282 282
283config MPC10X_BRIDGE 283config MPC10X_BRIDGE
284 bool 284 bool
285 depends on POWERPMC250 || LOPEC || SANDPOINT 285 depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION
286 select PPC_INDIRECT_PCI 286 select PPC_INDIRECT_PCI
287 default y 287 default y
288 288
289config MPC10X_OPENPIC 289config MPC10X_OPENPIC
290 bool 290 bool
291 depends on POWERPMC250 || LOPEC || SANDPOINT 291 depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION
292 default y 292 default y
293 293
294config MPC10X_STORE_GATHERING 294config MPC10X_STORE_GATHERING
diff --git a/arch/powerpc/platforms/embedded6xx/Makefile b/arch/powerpc/platforms/embedded6xx/Makefile
index fa499fe59291..d3d11a3cd656 100644
--- a/arch/powerpc/platforms/embedded6xx/Makefile
+++ b/arch/powerpc/platforms/embedded6xx/Makefile
@@ -2,3 +2,4 @@
2# Makefile for the 6xx/7xx/7xxxx linux kernel. 2# Makefile for the 6xx/7xx/7xxxx linux kernel.
3# 3#
4obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o 4obj-$(CONFIG_MPC7448HPC2) += mpc7448_hpc2.o
5obj-$(CONFIG_LINKSTATION) += linkstation.o ls_uart.o
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
new file mode 100644
index 000000000000..61599d919ea8
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -0,0 +1,211 @@
1/*
2 * Board setup routines for the Buffalo Linkstation / Kurobox Platform.
3 *
4 * Copyright (C) 2006 G. Liakhovetski (g.liakhovetski@gmx.de)
5 *
6 * Based on sandpoint.c by Mark A. Greer
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of
10 * any kind, whether express or implied.
11 */
12
13#include <linux/kernel.h>
14#include <linux/pci.h>
15#include <linux/initrd.h>
16#include <linux/root_dev.h>
17#include <linux/mtd/physmap.h>
18
19#include <asm/time.h>
20#include <asm/prom.h>
21#include <asm/mpic.h>
22#include <asm/mpc10x.h>
23#include <asm/pci-bridge.h>
24
25static struct mtd_partition linkstation_physmap_partitions[] = {
26 {
27 .name = "mtd_firmimg",
28 .offset = 0x000000,
29 .size = 0x300000,
30 },
31 {
32 .name = "mtd_bootcode",
33 .offset = 0x300000,
34 .size = 0x070000,
35 },
36 {
37 .name = "mtd_status",
38 .offset = 0x370000,
39 .size = 0x010000,
40 },
41 {
42 .name = "mtd_conf",
43 .offset = 0x380000,
44 .size = 0x080000,
45 },
46 {
47 .name = "mtd_allflash",
48 .offset = 0x000000,
49 .size = 0x400000,
50 },
51 {
52 .name = "mtd_data",
53 .offset = 0x310000,
54 .size = 0x0f0000,
55 },
56};
57
58static int __init add_bridge(struct device_node *dev)
59{
60 int len;
61 struct pci_controller *hose;
62 int *bus_range;
63
64 printk("Adding PCI host bridge %s\n", dev->full_name);
65
66 bus_range = (int *) get_property(dev, "bus-range", &len);
67 if (bus_range == NULL || len < 2 * sizeof(int))
68 printk(KERN_WARNING "Can't get bus-range for %s, assume"
69 " bus 0\n", dev->full_name);
70
71 hose = pcibios_alloc_controller();
72 if (hose == NULL)
73 return -ENOMEM;
74 hose->first_busno = bus_range ? bus_range[0] : 0;
75 hose->last_busno = bus_range ? bus_range[1] : 0xff;
76 hose->arch_data = dev;
77 setup_indirect_pci(hose, 0xfec00000, 0xfee00000);
78
79 /* Interpret the "ranges" property */
80 /* This also maps the I/O region and sets isa_io/mem_base */
81 pci_process_bridge_OF_ranges(hose, dev, 1);
82
83 return 0;
84}
85
86static void __init linkstation_setup_arch(void)
87{
88 struct device_node *np;
89#ifdef CONFIG_MTD_PHYSMAP
90 physmap_set_partitions(linkstation_physmap_partitions,
91 ARRAY_SIZE(linkstation_physmap_partitions));
92#endif
93
94#ifdef CONFIG_BLK_DEV_INITRD
95 if (initrd_start)
96 ROOT_DEV = Root_RAM0;
97 else
98#endif
99#ifdef CONFIG_ROOT_NFS
100 ROOT_DEV = Root_NFS;
101#else
102 ROOT_DEV = Root_HDA1;
103#endif
104
105 /* Lookup PCI host bridges */
106 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
107 add_bridge(np);
108
109 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
110 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
111}
112
113/*
114 * Interrupt setup and service. Interrrupts on the linkstation come
115 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
116 */
117static void __init linkstation_init_IRQ(void)
118{
119 struct mpic *mpic;
120 struct device_node *dnp;
121 void *prop;
122 int size;
123 phys_addr_t paddr;
124
125 dnp = of_find_node_by_type(NULL, "open-pic");
126 if (dnp == NULL)
127 return;
128
129 prop = (struct device_node *)get_property(dnp, "reg", &size);
130 paddr = (phys_addr_t)of_translate_address(dnp, prop);
131
132 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
133 BUG_ON(mpic == NULL);
134
135 /* PCI IRQs */
136 mpic_assign_isu(mpic, 0, paddr + 0x10200);
137
138 /* I2C */
139 mpic_assign_isu(mpic, 1, paddr + 0x11000);
140
141 /* ttyS0, ttyS1 */
142 mpic_assign_isu(mpic, 2, paddr + 0x11100);
143
144 mpic_init(mpic);
145}
146
147extern void avr_uart_configure(void);
148extern void avr_uart_send(const char);
149
150static void linkstation_restart(char *cmd)
151{
152 local_irq_disable();
153
154 /* Reset system via AVR */
155 avr_uart_configure();
156 /* Send reboot command */
157 avr_uart_send('C');
158
159 for(;;) /* Spin until reset happens */
160 avr_uart_send('G'); /* "kick" */
161}
162
163static void linkstation_power_off(void)
164{
165 local_irq_disable();
166
167 /* Power down system via AVR */
168 avr_uart_configure();
169 /* send shutdown command */
170 avr_uart_send('E');
171
172 for(;;) /* Spin until power-off happens */
173 avr_uart_send('G'); /* "kick" */
174 /* NOTREACHED */
175}
176
177static void linkstation_halt(void)
178{
179 linkstation_power_off();
180 /* NOTREACHED */
181}
182
183static void linkstation_show_cpuinfo(struct seq_file *m)
184{
185 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
186 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
187}
188
189static int __init linkstation_probe(void)
190{
191 unsigned long root;
192
193 root = of_get_flat_dt_root();
194
195 if (!of_flat_dt_is_compatible(root, "linkstation"))
196 return 0;
197 return 1;
198}
199
200define_machine(linkstation){
201 .name = "Buffalo Linkstation",
202 .probe = linkstation_probe,
203 .setup_arch = linkstation_setup_arch,
204 .init_IRQ = linkstation_init_IRQ,
205 .show_cpuinfo = linkstation_show_cpuinfo,
206 .get_irq = mpic_get_irq,
207 .restart = linkstation_restart,
208 .power_off = linkstation_power_off,
209 .halt = linkstation_halt,
210 .calibrate_decr = generic_calibrate_decr,
211};
diff --git a/arch/powerpc/platforms/embedded6xx/ls_uart.c b/arch/powerpc/platforms/embedded6xx/ls_uart.c
new file mode 100644
index 000000000000..0e837762cc5b
--- /dev/null
+++ b/arch/powerpc/platforms/embedded6xx/ls_uart.c
@@ -0,0 +1,131 @@
1#include <linux/workqueue.h>
2#include <linux/string.h>
3#include <linux/delay.h>
4#include <linux/serial_reg.h>
5#include <linux/serial_8250.h>
6#include <asm/io.h>
7#include <asm/mpc10x.h>
8#include <asm/ppc_sys.h>
9#include <asm/prom.h>
10#include <asm/termbits.h>
11
12static void __iomem *avr_addr;
13static unsigned long avr_clock;
14
15static struct work_struct wd_work;
16
17static void wd_stop(struct work_struct *unused)
18{
19 const char string[] = "AAAAFFFFJJJJ>>>>VVVV>>>>ZZZZVVVVKKKK";
20 int i = 0, rescue = 8;
21 int len = strlen(string);
22
23 while (rescue--) {
24 int j;
25 char lsr = in_8(avr_addr + UART_LSR);
26
27 if (lsr & (UART_LSR_THRE | UART_LSR_TEMT)) {
28 for (j = 0; j < 16 && i < len; j++, i++)
29 out_8(avr_addr + UART_TX, string[i]);
30 if (i == len) {
31 /* Read "OK" back: 4ms for the last "KKKK"
32 plus a couple bytes back */
33 msleep(7);
34 printk("linkstation: disarming the AVR watchdog: ");
35 while (in_8(avr_addr + UART_LSR) & UART_LSR_DR)
36 printk("%c", in_8(avr_addr + UART_RX));
37 break;
38 }
39 }
40 msleep(17);
41 }
42 printk("\n");
43}
44
45#define AVR_QUOT(clock) ((clock) + 8 * 9600) / (16 * 9600)
46
47void avr_uart_configure(void)
48{
49 unsigned char cval = UART_LCR_WLEN8;
50 unsigned int quot = AVR_QUOT(avr_clock);
51
52 if (!avr_addr || !avr_clock)
53 return;
54
55 out_8(avr_addr + UART_LCR, cval); /* initialise UART */
56 out_8(avr_addr + UART_MCR, 0);
57 out_8(avr_addr + UART_IER, 0);
58
59 cval |= UART_LCR_STOP | UART_LCR_PARITY | UART_LCR_EPAR;
60
61 out_8(avr_addr + UART_LCR, cval); /* Set character format */
62
63 out_8(avr_addr + UART_LCR, cval | UART_LCR_DLAB); /* set DLAB */
64 out_8(avr_addr + UART_DLL, quot & 0xff); /* LS of divisor */
65 out_8(avr_addr + UART_DLM, quot >> 8); /* MS of divisor */
66 out_8(avr_addr + UART_LCR, cval); /* reset DLAB */
67 out_8(avr_addr + UART_FCR, UART_FCR_ENABLE_FIFO); /* enable FIFO */
68}
69
70void avr_uart_send(const char c)
71{
72 if (!avr_addr || !avr_clock)
73 return;
74
75 out_8(avr_addr + UART_TX, c);
76 out_8(avr_addr + UART_TX, c);
77 out_8(avr_addr + UART_TX, c);
78 out_8(avr_addr + UART_TX, c);
79}
80
81static void __init ls_uart_init(void)
82{
83 local_irq_disable();
84
85#ifndef CONFIG_SERIAL_8250
86 out_8(avr_addr + UART_FCR, UART_FCR_ENABLE_FIFO); /* enable FIFO */
87 out_8(avr_addr + UART_FCR, UART_FCR_ENABLE_FIFO |
88 UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT); /* clear FIFOs */
89 out_8(avr_addr + UART_FCR, 0);
90 out_8(avr_addr + UART_IER, 0);
91
92 /* Clear up interrupts */
93 (void) in_8(avr_addr + UART_LSR);
94 (void) in_8(avr_addr + UART_RX);
95 (void) in_8(avr_addr + UART_IIR);
96 (void) in_8(avr_addr + UART_MSR);
97#endif
98 avr_uart_configure();
99
100 local_irq_enable();
101}
102
103static int __init ls_uarts_init(void)
104{
105 struct device_node *avr;
106 phys_addr_t phys_addr;
107 int len;
108
109 avr = of_find_node_by_path("/soc10x/serial@80004500");
110 if (!avr)
111 return -EINVAL;
112
113 avr_clock = *(u32*)get_property(avr, "clock-frequency", &len);
114 phys_addr = ((u32*)get_property(avr, "reg", &len))[0];
115
116 if (!avr_clock || !phys_addr)
117 return -EINVAL;
118
119 avr_addr = ioremap(phys_addr, 32);
120 if (!avr_addr)
121 return -EFAULT;
122
123 ls_uart_init();
124
125 INIT_WORK(&wd_work, wd_stop);
126 schedule_work(&wd_work);
127
128 return 0;
129}
130
131late_initcall(ls_uarts_init);
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index bdb475c65cba..3fcc85f60fbf 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -60,7 +60,7 @@ pci_dram_offset = MPC7448_HPC2_PCI_MEM_OFFSET;
60 60
61extern int tsi108_setup_pci(struct device_node *dev); 61extern int tsi108_setup_pci(struct device_node *dev);
62extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val); 62extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
63extern void tsi108_pci_int_init(void); 63extern void tsi108_pci_int_init(struct device_node *node);
64extern void tsi108_irq_cascade(unsigned int irq, struct irq_desc *desc); 64extern void tsi108_irq_cascade(unsigned int irq, struct irq_desc *desc);
65 65
66int mpc7448_hpc2_exclude_device(u_char bus, u_char devfn) 66int mpc7448_hpc2_exclude_device(u_char bus, u_char devfn)
@@ -71,65 +71,6 @@ int mpc7448_hpc2_exclude_device(u_char bus, u_char devfn)
71 return PCIBIOS_SUCCESSFUL; 71 return PCIBIOS_SUCCESSFUL;
72} 72}
73 73
74/*
75 * find pci slot by devfn in interrupt map of OF tree
76 */
77u8 find_slot_by_devfn(unsigned int *interrupt_map, unsigned int devfn)
78{
79 int i;
80 unsigned int tmp;
81 for (i = 0; i < 4; i++){
82 tmp = interrupt_map[i*4*7];
83 if ((tmp >> 11) == (devfn >> 3))
84 return i;
85 }
86 return i;
87}
88
89/*
90 * Scans the interrupt map for pci device
91 */
92void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
93{
94 struct pci_controller *hose;
95 struct device_node *node;
96 const unsigned int *interrupt;
97 int busnr;
98 int len;
99 u8 slot;
100 u8 pin;
101
102 /* Lookup the hose */
103 busnr = dev->bus->number;
104 hose = pci_bus_to_hose(busnr);
105 if (!hose)
106 printk(KERN_ERR "No pci hose found\n");
107
108 /* Check it has an OF node associated */
109 node = (struct device_node *) hose->arch_data;
110 if (!node)
111 printk(KERN_ERR "No pci node found\n");
112
113 interrupt = get_property(node, "interrupt-map", &len);
114 slot = find_slot_by_devfn(interrupt, dev->devfn);
115 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
116 if (pin == 0 || pin > 4)
117 pin = 1;
118 pin--;
119 dev->irq = interrupt[slot*4*7 + pin*7 + 5];
120 DBG("TSI_PCI: dev->irq = 0x%x\n", dev->irq);
121}
122/* temporary pci irq map fixup*/
123
124void __init mpc7448_hpc2_pcibios_fixup(void)
125{
126 struct pci_dev *dev = NULL;
127 for_each_pci_dev(dev) {
128 mpc7448_hpc2_fixup_irq(dev);
129 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
130 }
131}
132
133static void __init mpc7448_hpc2_setup_arch(void) 74static void __init mpc7448_hpc2_setup_arch(void)
134{ 75{
135 struct device_node *cpu; 76 struct device_node *cpu;
@@ -192,9 +133,12 @@ static void __init mpc7448_hpc2_init_IRQ(void)
192{ 133{
193 struct mpic *mpic; 134 struct mpic *mpic;
194 phys_addr_t mpic_paddr = 0; 135 phys_addr_t mpic_paddr = 0;
136 struct device_node *tsi_pic;
137#ifdef CONFIG_PCI
195 unsigned int cascade_pci_irq; 138 unsigned int cascade_pci_irq;
196 struct device_node *tsi_pci; 139 struct device_node *tsi_pci;
197 struct device_node *tsi_pic; 140 struct device_node *cascade_node = NULL;
141#endif
198 142
199 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 143 tsi_pic = of_find_node_by_type(NULL, "open-pic");
200 if (tsi_pic) { 144 if (tsi_pic) {
@@ -208,31 +152,41 @@ static void __init mpc7448_hpc2_init_IRQ(void)
208 return; 152 return;
209 } 153 }
210 154
211 DBG("%s: tsi108pic phys_addr = 0x%x\n", __FUNCTION__, 155 DBG("%s: tsi108 pic phys_addr = 0x%x\n", __FUNCTION__,
212 (u32) mpic_paddr); 156 (u32) mpic_paddr);
213 157
214 mpic = mpic_alloc(tsi_pic, mpic_paddr, 158 mpic = mpic_alloc(tsi_pic, mpic_paddr,
215 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET | 159 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
216 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108, 160 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
217 0, /* num_sources used */ 161 24,
218 0, /* num_sources used */ 162 NR_IRQS-4, /* num_sources used */
219 "Tsi108_PIC"); 163 "Tsi108_PIC");
220 164
221 BUG_ON(mpic == NULL); /* XXXX */ 165 BUG_ON(mpic == NULL);
166
167 mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);
168
222 mpic_init(mpic); 169 mpic_init(mpic);
223 170
171#ifdef CONFIG_PCI
224 tsi_pci = of_find_node_by_type(NULL, "pci"); 172 tsi_pci = of_find_node_by_type(NULL, "pci");
225 if (tsi_pci == 0) { 173 if (tsi_pci == NULL) {
226 printk("%s: No tsi108 pci node found !\n", __FUNCTION__); 174 printk("%s: No tsi108 pci node found !\n", __FUNCTION__);
227 return; 175 return;
228 } 176 }
177 cascade_node = of_find_node_by_type(NULL, "pic-router");
178 if (cascade_node == NULL) {
179 printk("%s: No tsi108 pci cascade node found !\n", __FUNCTION__);
180 return;
181 }
229 182
230 cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0); 183 cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0);
184 DBG("%s: tsi108 cascade_pci_irq = 0x%x\n", __FUNCTION__,
185 (u32) cascade_pci_irq);
186 tsi108_pci_int_init(cascade_node);
231 set_irq_data(cascade_pci_irq, mpic); 187 set_irq_data(cascade_pci_irq, mpic);
232 set_irq_chained_handler(cascade_pci_irq, tsi108_irq_cascade); 188 set_irq_chained_handler(cascade_pci_irq, tsi108_irq_cascade);
233 189#endif
234 tsi108_pci_int_init();
235
236 /* Configure MPIC outputs to CPU0 */ 190 /* Configure MPIC outputs to CPU0 */
237 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0); 191 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
238 of_node_put(tsi_pic); 192 of_node_put(tsi_pic);
@@ -290,7 +244,6 @@ static int mpc7448_machine_check_exception(struct pt_regs *regs)
290 return 1; 244 return 1;
291 } 245 }
292 return 0; 246 return 0;
293
294} 247}
295 248
296define_machine(mpc7448_hpc2){ 249define_machine(mpc7448_hpc2){
@@ -300,7 +253,6 @@ define_machine(mpc7448_hpc2){
300 .init_IRQ = mpc7448_hpc2_init_IRQ, 253 .init_IRQ = mpc7448_hpc2_init_IRQ,
301 .show_cpuinfo = mpc7448_hpc2_show_cpuinfo, 254 .show_cpuinfo = mpc7448_hpc2_show_cpuinfo,
302 .get_irq = mpic_get_irq, 255 .get_irq = mpic_get_irq,
303 .pcibios_fixup = mpc7448_hpc2_pcibios_fixup,
304 .restart = mpc7448_hpc2_restart, 256 .restart = mpc7448_hpc2_restart,
305 .calibrate_decr = generic_calibrate_decr, 257 .calibrate_decr = generic_calibrate_decr,
306 .machine_check_exception= mpc7448_machine_check_exception, 258 .machine_check_exception= mpc7448_machine_check_exception,
diff --git a/arch/powerpc/platforms/iseries/Makefile b/arch/powerpc/platforms/iseries/Makefile
index dee4eb4d8bec..13ac3015d91c 100644
--- a/arch/powerpc/platforms/iseries/Makefile
+++ b/arch/powerpc/platforms/iseries/Makefile
@@ -1,5 +1,7 @@
1EXTRA_CFLAGS += -mno-minimal-toc 1EXTRA_CFLAGS += -mno-minimal-toc
2 2
3extra-y += dt.o
4
3obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt_mod.o mf.o lpevents.o \ 5obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt_mod.o mf.o lpevents.o \
4 hvcall.o proc.o htab.o iommu.o misc.o irq.o 6 hvcall.o proc.o htab.o iommu.o misc.o irq.o
5obj-$(CONFIG_PCI) += pci.o vpdinfo.o 7obj-$(CONFIG_PCI) += pci.o vpdinfo.o
@@ -7,5 +9,9 @@ obj-$(CONFIG_SMP) += smp.o
7obj-$(CONFIG_VIOPATH) += viopath.o 9obj-$(CONFIG_VIOPATH) += viopath.o
8obj-$(CONFIG_MODULES) += ksyms.o 10obj-$(CONFIG_MODULES) += ksyms.o
9 11
12quiet_cmd_dt_strings = DT_STR $@
13 cmd_dt_strings = $(OBJCOPY) --rename-section .rodata.str1.8=.dt_strings \
14 $< $@
15
10$(obj)/dt_mod.o: $(obj)/dt.o 16$(obj)/dt_mod.o: $(obj)/dt.o
11 @$(OBJCOPY) --rename-section .rodata.str1.8=.dt_strings $(obj)/dt.o $(obj)/dt_mod.o 17 $(call if_changed,dt_strings)
diff --git a/arch/powerpc/platforms/iseries/dt.c b/arch/powerpc/platforms/iseries/dt.c
index e305deee7f44..9e8a334a518a 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -41,6 +41,7 @@
41#include "call_pci.h" 41#include "call_pci.h"
42#include "pci.h" 42#include "pci.h"
43#include "it_exp_vpd_panel.h" 43#include "it_exp_vpd_panel.h"
44#include "naca.h"
44 45
45#ifdef DEBUG 46#ifdef DEBUG
46#define DBG(fmt...) udbg_printf(fmt) 47#define DBG(fmt...) udbg_printf(fmt)
@@ -205,13 +206,11 @@ static void __init dt_prop_u32(struct iseries_flat_dt *dt, const char *name,
205 dt_prop(dt, name, &data, sizeof(u32)); 206 dt_prop(dt, name, &data, sizeof(u32));
206} 207}
207 208
208#ifdef notyet
209static void __init dt_prop_u64(struct iseries_flat_dt *dt, const char *name, 209static void __init dt_prop_u64(struct iseries_flat_dt *dt, const char *name,
210 u64 data) 210 u64 data)
211{ 211{
212 dt_prop(dt, name, &data, sizeof(u64)); 212 dt_prop(dt, name, &data, sizeof(u64));
213} 213}
214#endif
215 214
216static void __init dt_prop_u64_list(struct iseries_flat_dt *dt, 215static void __init dt_prop_u64_list(struct iseries_flat_dt *dt,
217 const char *name, u64 *data, int n) 216 const char *name, u64 *data, int n)
@@ -306,6 +305,17 @@ static void __init dt_model(struct iseries_flat_dt *dt)
306 dt_prop_u32(dt, "ibm,partition-no", HvLpConfig_getLpIndex()); 305 dt_prop_u32(dt, "ibm,partition-no", HvLpConfig_getLpIndex());
307} 306}
308 307
308static void __init dt_initrd(struct iseries_flat_dt *dt)
309{
310#ifdef CONFIG_BLK_DEV_INITRD
311 if (naca.xRamDisk) {
312 dt_prop_u64(dt, "linux,initrd-start", (u64)naca.xRamDisk);
313 dt_prop_u64(dt, "linux,initrd-end",
314 (u64)naca.xRamDisk + naca.xRamDiskSize * HW_PAGE_SIZE);
315 }
316#endif
317}
318
309static void __init dt_do_vdevice(struct iseries_flat_dt *dt, 319static void __init dt_do_vdevice(struct iseries_flat_dt *dt,
310 const char *name, u32 reg, int unit, 320 const char *name, u32 reg, int unit,
311 const char *type, const char *compat, int end) 321 const char *type, const char *compat, int end)
@@ -641,6 +651,7 @@ void * __init build_flat_dt(unsigned long phys_mem_size)
641 /* /chosen */ 651 /* /chosen */
642 dt_start_node(iseries_dt, "chosen"); 652 dt_start_node(iseries_dt, "chosen");
643 dt_prop_str(iseries_dt, "bootargs", cmd_line); 653 dt_prop_str(iseries_dt, "bootargs", cmd_line);
654 dt_initrd(iseries_dt);
644 dt_end_node(iseries_dt); 655 dt_end_node(iseries_dt);
645 656
646 dt_cpus(iseries_dt); 657 dt_cpus(iseries_dt);
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index 218817d13c5c..d7a756d5135c 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -27,6 +27,7 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <linux/list.h> 29#include <linux/list.h>
30#include <linux/pci.h>
30 31
31#include <asm/iommu.h> 32#include <asm/iommu.h>
32#include <asm/tce.h> 33#include <asm/tce.h>
@@ -114,12 +115,10 @@ void iommu_table_getparms_iSeries(unsigned long busno,
114{ 115{
115 struct iommu_table_cb *parms; 116 struct iommu_table_cb *parms;
116 117
117 parms = kmalloc(sizeof(*parms), GFP_KERNEL); 118 parms = kzalloc(sizeof(*parms), GFP_KERNEL);
118 if (parms == NULL) 119 if (parms == NULL)
119 panic("PCI_DMA: TCE Table Allocation failed."); 120 panic("PCI_DMA: TCE Table Allocation failed.");
120 121
121 memset(parms, 0, sizeof(*parms));
122
123 parms->itc_busno = busno; 122 parms->itc_busno = busno;
124 parms->itc_slotno = slotno; 123 parms->itc_slotno = slotno;
125 parms->itc_virtbus = virtbus; 124 parms->itc_virtbus = virtbus;
@@ -168,7 +167,7 @@ static struct iommu_table *iommu_table_find(struct iommu_table * tbl)
168} 167}
169 168
170 169
171void iommu_devnode_init_iSeries(struct device_node *dn) 170void iommu_devnode_init_iSeries(struct pci_dev *pdev, struct device_node *dn)
172{ 171{
173 struct iommu_table *tbl; 172 struct iommu_table *tbl;
174 struct pci_dn *pdn = PCI_DN(dn); 173 struct pci_dn *pdn = PCI_DN(dn);
@@ -186,19 +185,14 @@ void iommu_devnode_init_iSeries(struct device_node *dn)
186 pdn->iommu_table = iommu_init_table(tbl, -1); 185 pdn->iommu_table = iommu_init_table(tbl, -1);
187 else 186 else
188 kfree(tbl); 187 kfree(tbl);
188 pdev->dev.archdata.dma_data = pdn->iommu_table;
189} 189}
190#endif 190#endif
191 191
192static void iommu_dev_setup_iSeries(struct pci_dev *dev) { }
193static void iommu_bus_setup_iSeries(struct pci_bus *bus) { }
194
195void iommu_init_early_iSeries(void) 192void iommu_init_early_iSeries(void)
196{ 193{
197 ppc_md.tce_build = tce_build_iSeries; 194 ppc_md.tce_build = tce_build_iSeries;
198 ppc_md.tce_free = tce_free_iSeries; 195 ppc_md.tce_free = tce_free_iSeries;
199 196
200 ppc_md.iommu_dev_setup = iommu_dev_setup_iSeries; 197 pci_dma_ops = &dma_iommu_ops;
201 ppc_md.iommu_bus_setup = iommu_bus_setup_iSeries;
202
203 pci_iommu_init();
204} 198}
diff --git a/arch/powerpc/platforms/iseries/ksyms.c b/arch/powerpc/platforms/iseries/ksyms.c
index a2200842f4e5..2430848b98e7 100644
--- a/arch/powerpc/platforms/iseries/ksyms.c
+++ b/arch/powerpc/platforms/iseries/ksyms.c
@@ -19,9 +19,3 @@ EXPORT_SYMBOL(HvCall4);
19EXPORT_SYMBOL(HvCall5); 19EXPORT_SYMBOL(HvCall5);
20EXPORT_SYMBOL(HvCall6); 20EXPORT_SYMBOL(HvCall6);
21EXPORT_SYMBOL(HvCall7); 21EXPORT_SYMBOL(HvCall7);
22
23#ifdef CONFIG_SMP
24EXPORT_SYMBOL(local_get_flags);
25EXPORT_SYMBOL(local_irq_disable);
26EXPORT_SYMBOL(local_irq_restore);
27#endif
diff --git a/arch/powerpc/platforms/iseries/misc.S b/arch/powerpc/platforms/iseries/misc.S
index 7641fc7e550a..2c6ff0fdac98 100644
--- a/arch/powerpc/platforms/iseries/misc.S
+++ b/arch/powerpc/platforms/iseries/misc.S
@@ -19,39 +19,8 @@
19 19
20 .text 20 .text
21 21
22/* unsigned long local_save_flags(void) */ 22/* Handle pending interrupts in interrupt context */
23_GLOBAL(local_get_flags) 23_GLOBAL(iseries_handle_interrupts)
24 lbz r3,PACAPROCENABLED(r13)
25 blr
26
27/* unsigned long local_irq_disable(void) */
28_GLOBAL(local_irq_disable)
29 lbz r3,PACAPROCENABLED(r13)
30 li r4,0
31 stb r4,PACAPROCENABLED(r13)
32 blr /* Done */
33
34/* void local_irq_restore(unsigned long flags) */
35_GLOBAL(local_irq_restore)
36 lbz r5,PACAPROCENABLED(r13)
37 /* Check if things are setup the way we want _already_. */
38 cmpw 0,r3,r5
39 beqlr
40 /* are we enabling interrupts? */
41 cmpdi 0,r3,0
42 stb r3,PACAPROCENABLED(r13)
43 beqlr
44 /* Check pending interrupts */
45 /* A decrementer, IPI or PMC interrupt may have occurred
46 * while we were in the hypervisor (which enables) */
47 ld r4,PACALPPACAPTR(r13)
48 ld r4,LPPACAANYINT(r4)
49 cmpdi r4,0
50 beqlr
51
52 /*
53 * Handle pending interrupts in interrupt context
54 */
55 li r0,0x5555 24 li r0,0x5555
56 sc 25 sc
57 blr 26 blr
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 4aa165e010d9..4a06d9c34986 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -156,53 +156,6 @@ static void pci_Log_Error(char *Error_Text, int Bus, int SubBus,
156} 156}
157 157
158/* 158/*
159 * iSeries_pcibios_init
160 *
161 * Description:
162 * This function checks for all possible system PCI host bridges that connect
163 * PCI buses. The system hypervisor is queried as to the guest partition
164 * ownership status. A pci_controller is built for any bus which is partially
165 * owned or fully owned by this guest partition.
166 */
167void iSeries_pcibios_init(void)
168{
169 struct pci_controller *phb;
170 struct device_node *root = of_find_node_by_path("/");
171 struct device_node *node = NULL;
172
173 if (root == NULL) {
174 printk(KERN_CRIT "iSeries_pcibios_init: can't find root "
175 "of device tree\n");
176 return;
177 }
178 while ((node = of_get_next_child(root, node)) != NULL) {
179 HvBusNumber bus;
180 const u32 *busp;
181
182 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
183 continue;
184
185 busp = get_property(node, "bus-range", NULL);
186 if (busp == NULL)
187 continue;
188 bus = *busp;
189 printk("bus %d appears to exist\n", bus);
190 phb = pcibios_alloc_controller(node);
191 if (phb == NULL)
192 continue;
193
194 phb->pci_mem_offset = phb->local_number = bus;
195 phb->first_busno = bus;
196 phb->last_busno = bus;
197 phb->ops = &iSeries_pci_ops;
198 }
199
200 of_node_put(root);
201
202 pci_devs_phb_init();
203}
204
205/*
206 * iSeries_pci_final_fixup(void) 159 * iSeries_pci_final_fixup(void)
207 */ 160 */
208void __init iSeries_pci_final_fixup(void) 161void __init iSeries_pci_final_fixup(void)
@@ -253,7 +206,7 @@ void __init iSeries_pci_final_fixup(void)
253 PCI_DN(node)->pcidev = pdev; 206 PCI_DN(node)->pcidev = pdev;
254 allocate_device_bars(pdev); 207 allocate_device_bars(pdev);
255 iSeries_Device_Information(pdev, DeviceCount); 208 iSeries_Device_Information(pdev, DeviceCount);
256 iommu_devnode_init_iSeries(node); 209 iommu_devnode_init_iSeries(pdev, node);
257 } else 210 } else
258 printk("PCI: Device Tree not found for 0x%016lX\n", 211 printk("PCI: Device Tree not found for 0x%016lX\n",
259 (unsigned long)pdev); 212 (unsigned long)pdev);
@@ -438,11 +391,7 @@ static inline struct device_node *xlate_iomm_address(
438/* 391/*
439 * Read MM I/O Instructions for the iSeries 392 * Read MM I/O Instructions for the iSeries
440 * On MM I/O error, all ones are returned and iSeries_pci_IoError is cal 393 * On MM I/O error, all ones are returned and iSeries_pci_IoError is cal
441 * else, data is returned in big Endian format. 394 * else, data is returned in Big Endian format.
442 *
443 * iSeries_Read_Byte = Read Byte ( 8 bit)
444 * iSeries_Read_Word = Read Word (16 bit)
445 * iSeries_Read_Long = Read Long (32 bit)
446 */ 395 */
447static u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress) 396static u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
448{ 397{
@@ -462,14 +411,15 @@ static u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
462 num_printed = 0; 411 num_printed = 0;
463 } 412 }
464 if (num_printed++ < 10) 413 if (num_printed++ < 10)
465 printk(KERN_ERR "iSeries_Read_Byte: invalid access at IO address %p\n", IoAddress); 414 printk(KERN_ERR "iSeries_Read_Byte: invalid access at IO address %p\n",
415 IoAddress);
466 return 0xff; 416 return 0xff;
467 } 417 }
468 do { 418 do {
469 HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, BarOffset, 0); 419 HvCall3Ret16(HvCallPciBarLoad8, &ret, dsa, BarOffset, 0);
470 } while (CheckReturnCode("RDB", DevNode, &retry, ret.rc) != 0); 420 } while (CheckReturnCode("RDB", DevNode, &retry, ret.rc) != 0);
471 421
472 return (u8)ret.value; 422 return ret.value;
473} 423}
474 424
475static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress) 425static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
@@ -490,7 +440,8 @@ static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
490 num_printed = 0; 440 num_printed = 0;
491 } 441 }
492 if (num_printed++ < 10) 442 if (num_printed++ < 10)
493 printk(KERN_ERR "iSeries_Read_Word: invalid access at IO address %p\n", IoAddress); 443 printk(KERN_ERR "iSeries_Read_Word: invalid access at IO address %p\n",
444 IoAddress);
494 return 0xffff; 445 return 0xffff;
495 } 446 }
496 do { 447 do {
@@ -498,7 +449,7 @@ static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
498 BarOffset, 0); 449 BarOffset, 0);
499 } while (CheckReturnCode("RDW", DevNode, &retry, ret.rc) != 0); 450 } while (CheckReturnCode("RDW", DevNode, &retry, ret.rc) != 0);
500 451
501 return swab16((u16)ret.value); 452 return ret.value;
502} 453}
503 454
504static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress) 455static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
@@ -519,7 +470,8 @@ static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
519 num_printed = 0; 470 num_printed = 0;
520 } 471 }
521 if (num_printed++ < 10) 472 if (num_printed++ < 10)
522 printk(KERN_ERR "iSeries_Read_Long: invalid access at IO address %p\n", IoAddress); 473 printk(KERN_ERR "iSeries_Read_Long: invalid access at IO address %p\n",
474 IoAddress);
523 return 0xffffffff; 475 return 0xffffffff;
524 } 476 }
525 do { 477 do {
@@ -527,15 +479,12 @@ static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
527 BarOffset, 0); 479 BarOffset, 0);
528 } while (CheckReturnCode("RDL", DevNode, &retry, ret.rc) != 0); 480 } while (CheckReturnCode("RDL", DevNode, &retry, ret.rc) != 0);
529 481
530 return swab32((u32)ret.value); 482 return ret.value;
531} 483}
532 484
533/* 485/*
534 * Write MM I/O Instructions for the iSeries 486 * Write MM I/O Instructions for the iSeries
535 * 487 *
536 * iSeries_Write_Byte = Write Byte (8 bit)
537 * iSeries_Write_Word = Write Word(16 bit)
538 * iSeries_Write_Long = Write Long(32 bit)
539 */ 488 */
540static void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress) 489static void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
541{ 490{
@@ -581,11 +530,12 @@ static void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
581 num_printed = 0; 530 num_printed = 0;
582 } 531 }
583 if (num_printed++ < 10) 532 if (num_printed++ < 10)
584 printk(KERN_ERR "iSeries_Write_Word: invalid access at IO address %p\n", IoAddress); 533 printk(KERN_ERR "iSeries_Write_Word: invalid access at IO address %p\n",
534 IoAddress);
585 return; 535 return;
586 } 536 }
587 do { 537 do {
588 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0); 538 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, data, 0);
589 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0); 539 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0);
590} 540}
591 541
@@ -607,231 +557,221 @@ static void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
607 num_printed = 0; 557 num_printed = 0;
608 } 558 }
609 if (num_printed++ < 10) 559 if (num_printed++ < 10)
610 printk(KERN_ERR "iSeries_Write_Long: invalid access at IO address %p\n", IoAddress); 560 printk(KERN_ERR "iSeries_Write_Long: invalid access at IO address %p\n",
561 IoAddress);
611 return; 562 return;
612 } 563 }
613 do { 564 do {
614 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0); 565 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, data, 0);
615 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0); 566 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0);
616} 567}
617 568
618extern unsigned char __raw_readb(const volatile void __iomem *addr) 569static u8 iseries_readb(const volatile void __iomem *addr)
619{ 570{
620 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 571 return iSeries_Read_Byte(addr);
621
622 return *(volatile unsigned char __force *)addr;
623} 572}
624EXPORT_SYMBOL(__raw_readb);
625 573
626extern unsigned short __raw_readw(const volatile void __iomem *addr) 574static u16 iseries_readw(const volatile void __iomem *addr)
627{ 575{
628 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 576 return le16_to_cpu(iSeries_Read_Word(addr));
629
630 return *(volatile unsigned short __force *)addr;
631} 577}
632EXPORT_SYMBOL(__raw_readw);
633 578
634extern unsigned int __raw_readl(const volatile void __iomem *addr) 579static u32 iseries_readl(const volatile void __iomem *addr)
635{ 580{
636 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 581 return le32_to_cpu(iSeries_Read_Long(addr));
637
638 return *(volatile unsigned int __force *)addr;
639} 582}
640EXPORT_SYMBOL(__raw_readl);
641 583
642extern unsigned long __raw_readq(const volatile void __iomem *addr) 584static u16 iseries_readw_be(const volatile void __iomem *addr)
643{ 585{
644 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 586 return iSeries_Read_Word(addr);
645
646 return *(volatile unsigned long __force *)addr;
647} 587}
648EXPORT_SYMBOL(__raw_readq);
649 588
650extern void __raw_writeb(unsigned char v, volatile void __iomem *addr) 589static u32 iseries_readl_be(const volatile void __iomem *addr)
651{ 590{
652 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 591 return iSeries_Read_Long(addr);
653
654 *(volatile unsigned char __force *)addr = v;
655} 592}
656EXPORT_SYMBOL(__raw_writeb);
657 593
658extern void __raw_writew(unsigned short v, volatile void __iomem *addr) 594static void iseries_writeb(u8 data, volatile void __iomem *addr)
659{ 595{
660 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 596 iSeries_Write_Byte(data, addr);
661
662 *(volatile unsigned short __force *)addr = v;
663} 597}
664EXPORT_SYMBOL(__raw_writew);
665 598
666extern void __raw_writel(unsigned int v, volatile void __iomem *addr) 599static void iseries_writew(u16 data, volatile void __iomem *addr)
667{ 600{
668 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 601 iSeries_Write_Word(cpu_to_le16(data), addr);
669
670 *(volatile unsigned int __force *)addr = v;
671} 602}
672EXPORT_SYMBOL(__raw_writel);
673 603
674extern void __raw_writeq(unsigned long v, volatile void __iomem *addr) 604static void iseries_writel(u32 data, volatile void __iomem *addr)
675{ 605{
676 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 606 iSeries_Write_Long(cpu_to_le32(data), addr);
677
678 *(volatile unsigned long __force *)addr = v;
679} 607}
680EXPORT_SYMBOL(__raw_writeq);
681 608
682int in_8(const volatile unsigned char __iomem *addr) 609static void iseries_writew_be(u16 data, volatile void __iomem *addr)
683{ 610{
684 if (firmware_has_feature(FW_FEATURE_ISERIES)) 611 iSeries_Write_Word(data, addr);
685 return iSeries_Read_Byte(addr);
686 return __in_8(addr);
687} 612}
688EXPORT_SYMBOL(in_8);
689 613
690void out_8(volatile unsigned char __iomem *addr, int val) 614static void iseries_writel_be(u32 data, volatile void __iomem *addr)
691{ 615{
692 if (firmware_has_feature(FW_FEATURE_ISERIES)) 616 iSeries_Write_Long(data, addr);
693 iSeries_Write_Byte(val, addr);
694 else
695 __out_8(addr, val);
696} 617}
697EXPORT_SYMBOL(out_8);
698 618
699int in_le16(const volatile unsigned short __iomem *addr) 619static void iseries_readsb(const volatile void __iomem *addr, void *buf,
620 unsigned long count)
700{ 621{
701 if (firmware_has_feature(FW_FEATURE_ISERIES)) 622 u8 *dst = buf;
702 return iSeries_Read_Word(addr); 623 while(count-- > 0)
703 return __in_le16(addr); 624 *(dst++) = iSeries_Read_Byte(addr);
704} 625}
705EXPORT_SYMBOL(in_le16);
706 626
707int in_be16(const volatile unsigned short __iomem *addr) 627static void iseries_readsw(const volatile void __iomem *addr, void *buf,
628 unsigned long count)
708{ 629{
709 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 630 u16 *dst = buf;
710 631 while(count-- > 0)
711 return __in_be16(addr); 632 *(dst++) = iSeries_Read_Word(addr);
712} 633}
713EXPORT_SYMBOL(in_be16);
714 634
715void out_le16(volatile unsigned short __iomem *addr, int val) 635static void iseries_readsl(const volatile void __iomem *addr, void *buf,
636 unsigned long count)
716{ 637{
717 if (firmware_has_feature(FW_FEATURE_ISERIES)) 638 u32 *dst = buf;
718 iSeries_Write_Word(val, addr); 639 while(count-- > 0)
719 else 640 *(dst++) = iSeries_Read_Long(addr);
720 __out_le16(addr, val);
721} 641}
722EXPORT_SYMBOL(out_le16);
723 642
724void out_be16(volatile unsigned short __iomem *addr, int val) 643static void iseries_writesb(volatile void __iomem *addr, const void *buf,
644 unsigned long count)
725{ 645{
726 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 646 const u8 *src = buf;
727 647 while(count-- > 0)
728 __out_be16(addr, val); 648 iSeries_Write_Byte(*(src++), addr);
729} 649}
730EXPORT_SYMBOL(out_be16);
731 650
732unsigned in_le32(const volatile unsigned __iomem *addr) 651static void iseries_writesw(volatile void __iomem *addr, const void *buf,
652 unsigned long count)
733{ 653{
734 if (firmware_has_feature(FW_FEATURE_ISERIES)) 654 const u16 *src = buf;
735 return iSeries_Read_Long(addr); 655 while(count-- > 0)
736 return __in_le32(addr); 656 iSeries_Write_Word(*(src++), addr);
737} 657}
738EXPORT_SYMBOL(in_le32);
739 658
740unsigned in_be32(const volatile unsigned __iomem *addr) 659static void iseries_writesl(volatile void __iomem *addr, const void *buf,
660 unsigned long count)
741{ 661{
742 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 662 const u32 *src = buf;
743 663 while(count-- > 0)
744 return __in_be32(addr); 664 iSeries_Write_Long(*(src++), addr);
745} 665}
746EXPORT_SYMBOL(in_be32);
747 666
748void out_le32(volatile unsigned __iomem *addr, int val) 667static void iseries_memset_io(volatile void __iomem *addr, int c,
668 unsigned long n)
749{ 669{
750 if (firmware_has_feature(FW_FEATURE_ISERIES)) 670 volatile char __iomem *d = addr;
751 iSeries_Write_Long(val, addr);
752 else
753 __out_le32(addr, val);
754}
755EXPORT_SYMBOL(out_le32);
756 671
757void out_be32(volatile unsigned __iomem *addr, int val) 672 while (n-- > 0)
758{ 673 iSeries_Write_Byte(c, d++);
759 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
760
761 __out_be32(addr, val);
762} 674}
763EXPORT_SYMBOL(out_be32);
764 675
765unsigned long in_le64(const volatile unsigned long __iomem *addr) 676static void iseries_memcpy_fromio(void *dest, const volatile void __iomem *src,
677 unsigned long n)
766{ 678{
767 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 679 char *d = dest;
680 const volatile char __iomem *s = src;
768 681
769 return __in_le64(addr); 682 while (n-- > 0)
683 *d++ = iSeries_Read_Byte(s++);
770} 684}
771EXPORT_SYMBOL(in_le64);
772 685
773unsigned long in_be64(const volatile unsigned long __iomem *addr) 686static void iseries_memcpy_toio(volatile void __iomem *dest, const void *src,
687 unsigned long n)
774{ 688{
775 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 689 const char *s = src;
690 volatile char __iomem *d = dest;
776 691
777 return __in_be64(addr); 692 while (n-- > 0)
693 iSeries_Write_Byte(*s++, d++);
778} 694}
779EXPORT_SYMBOL(in_be64);
780
781void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
782{
783 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
784 695
785 __out_le64(addr, val); 696/* We only set MMIO ops. The default PIO ops will be default
786} 697 * to the MMIO ops + pci_io_base which is 0 on iSeries as
787EXPORT_SYMBOL(out_le64); 698 * expected so both should work.
699 *
700 * Note that we don't implement the readq/writeq versions as
701 * I don't know of an HV call for doing so. Thus, the default
702 * operation will be used instead, which will fault a the value
703 * return by iSeries for MMIO addresses always hits a non mapped
704 * area. This is as good as the BUG() we used to have there.
705 */
706static struct ppc_pci_io __initdata iseries_pci_io = {
707 .readb = iseries_readb,
708 .readw = iseries_readw,
709 .readl = iseries_readl,
710 .readw_be = iseries_readw_be,
711 .readl_be = iseries_readl_be,
712 .writeb = iseries_writeb,
713 .writew = iseries_writew,
714 .writel = iseries_writel,
715 .writew_be = iseries_writew_be,
716 .writel_be = iseries_writel_be,
717 .readsb = iseries_readsb,
718 .readsw = iseries_readsw,
719 .readsl = iseries_readsl,
720 .writesb = iseries_writesb,
721 .writesw = iseries_writesw,
722 .writesl = iseries_writesl,
723 .memset_io = iseries_memset_io,
724 .memcpy_fromio = iseries_memcpy_fromio,
725 .memcpy_toio = iseries_memcpy_toio,
726};
788 727
789void out_be64(volatile unsigned long __iomem *addr, unsigned long val) 728/*
729 * iSeries_pcibios_init
730 *
731 * Description:
732 * This function checks for all possible system PCI host bridges that connect
733 * PCI buses. The system hypervisor is queried as to the guest partition
734 * ownership status. A pci_controller is built for any bus which is partially
735 * owned or fully owned by this guest partition.
736 */
737void __init iSeries_pcibios_init(void)
790{ 738{
791 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES)); 739 struct pci_controller *phb;
740 struct device_node *root = of_find_node_by_path("/");
741 struct device_node *node = NULL;
792 742
793 __out_be64(addr, val); 743 /* Install IO hooks */
794} 744 ppc_pci_io = iseries_pci_io;
795EXPORT_SYMBOL(out_be64);
796 745
797void memset_io(volatile void __iomem *addr, int c, unsigned long n) 746 if (root == NULL) {
798{ 747 printk(KERN_CRIT "iSeries_pcibios_init: can't find root "
799 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 748 "of device tree\n");
800 volatile char __iomem *d = addr; 749 return;
750 }
751 while ((node = of_get_next_child(root, node)) != NULL) {
752 HvBusNumber bus;
753 const u32 *busp;
801 754
802 while (n-- > 0) { 755 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
803 iSeries_Write_Byte(c, d++); 756 continue;
804 }
805 } else
806 eeh_memset_io(addr, c, n);
807}
808EXPORT_SYMBOL(memset_io);
809 757
810void memcpy_fromio(void *dest, const volatile void __iomem *src, 758 busp = get_property(node, "bus-range", NULL);
811 unsigned long n) 759 if (busp == NULL)
812{ 760 continue;
813 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 761 bus = *busp;
814 char *d = dest; 762 printk("bus %d appears to exist\n", bus);
815 const volatile char __iomem *s = src; 763 phb = pcibios_alloc_controller(node);
764 if (phb == NULL)
765 continue;
816 766
817 while (n-- > 0) { 767 phb->pci_mem_offset = phb->local_number = bus;
818 *d++ = iSeries_Read_Byte(s++); 768 phb->first_busno = bus;
819 } 769 phb->last_busno = bus;
820 } else 770 phb->ops = &iSeries_pci_ops;
821 eeh_memcpy_fromio(dest, src, n); 771 }
822}
823EXPORT_SYMBOL(memcpy_fromio);
824 772
825void memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n) 773 of_node_put(root);
826{
827 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
828 const char *s = src;
829 volatile char __iomem *d = dest;
830 774
831 while (n-- > 0) { 775 pci_devs_phb_init();
832 iSeries_Write_Byte(*s++, d++);
833 }
834 } else
835 eeh_memcpy_toio(dest, src, n);
836} 776}
837EXPORT_SYMBOL(memcpy_toio); 777
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 6f73469fd3b0..bdf2afbb60c1 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -21,7 +21,6 @@
21#include <linux/smp.h> 21#include <linux/smp.h>
22#include <linux/param.h> 22#include <linux/param.h>
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/initrd.h>
25#include <linux/seq_file.h> 24#include <linux/seq_file.h>
26#include <linux/kdev_t.h> 25#include <linux/kdev_t.h>
27#include <linux/major.h> 26#include <linux/major.h>
@@ -80,8 +79,6 @@ extern void iSeries_pci_final_fixup(void);
80static void iSeries_pci_final_fixup(void) { } 79static void iSeries_pci_final_fixup(void) { }
81#endif 80#endif
82 81
83extern int rd_size; /* Defined in drivers/block/rd.c */
84
85extern unsigned long iSeries_recal_tb; 82extern unsigned long iSeries_recal_tb;
86extern unsigned long iSeries_recal_titan; 83extern unsigned long iSeries_recal_titan;
87 84
@@ -295,24 +292,6 @@ static void __init iSeries_init_early(void)
295{ 292{
296 DBG(" -> iSeries_init_early()\n"); 293 DBG(" -> iSeries_init_early()\n");
297 294
298#if defined(CONFIG_BLK_DEV_INITRD)
299 /*
300 * If the init RAM disk has been configured and there is
301 * a non-zero starting address for it, set it up
302 */
303 if (naca.xRamDisk) {
304 initrd_start = (unsigned long)__va(naca.xRamDisk);
305 initrd_end = initrd_start + naca.xRamDiskSize * HW_PAGE_SIZE;
306 initrd_below_start_ok = 1; // ramdisk in kernel space
307 ROOT_DEV = Root_RAM0;
308 if (((rd_size * 1024) / HW_PAGE_SIZE) < naca.xRamDiskSize)
309 rd_size = (naca.xRamDiskSize * HW_PAGE_SIZE) / 1024;
310 } else
311#endif /* CONFIG_BLK_DEV_INITRD */
312 {
313 /* ROOT_DEV = MKDEV(VIODASD_MAJOR, 1); */
314 }
315
316 iSeries_recal_tb = get_tb(); 295 iSeries_recal_tb = get_tb();
317 iSeries_recal_titan = HvCallXm_loadTod(); 296 iSeries_recal_titan = HvCallXm_loadTod();
318 297
@@ -331,17 +310,6 @@ static void __init iSeries_init_early(void)
331 310
332 mf_init(); 311 mf_init();
333 312
334 /* If we were passed an initrd, set the ROOT_DEV properly if the values
335 * look sensible. If not, clear initrd reference.
336 */
337#ifdef CONFIG_BLK_DEV_INITRD
338 if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE &&
339 initrd_end > initrd_start)
340 ROOT_DEV = Root_RAM0;
341 else
342 initrd_start = initrd_end = 0;
343#endif /* CONFIG_BLK_DEV_INITRD */
344
345 DBG(" <- iSeries_init_early()\n"); 313 DBG(" <- iSeries_init_early()\n");
346} 314}
347 315
@@ -649,6 +617,16 @@ static void iseries_dedicated_idle(void)
649void __init iSeries_init_IRQ(void) { } 617void __init iSeries_init_IRQ(void) { }
650#endif 618#endif
651 619
620static void __iomem *iseries_ioremap(phys_addr_t address, unsigned long size,
621 unsigned long flags)
622{
623 return (void __iomem *)address;
624}
625
626static void iseries_iounmap(volatile void __iomem *token)
627{
628}
629
652/* 630/*
653 * iSeries has no legacy IO, anything calling this function has to 631 * iSeries has no legacy IO, anything calling this function has to
654 * fail or bad things will happen 632 * fail or bad things will happen
@@ -665,6 +643,8 @@ static int __init iseries_probe(void)
665 return 0; 643 return 0;
666 644
667 hpte_init_iSeries(); 645 hpte_init_iSeries();
646 /* iSeries does not support 16M pages */
647 cur_cpu_spec->cpu_features &= ~CPU_FTR_16M_PAGE;
668 648
669 return 1; 649 return 1;
670} 650}
@@ -687,6 +667,8 @@ define_machine(iseries) {
687 .progress = iSeries_progress, 667 .progress = iSeries_progress,
688 .probe = iseries_probe, 668 .probe = iseries_probe,
689 .check_legacy_ioport = iseries_check_legacy_ioport, 669 .check_legacy_ioport = iseries_check_legacy_ioport,
670 .ioremap = iseries_ioremap,
671 .iounmap = iseries_iounmap,
690 /* XXX Implement enable_pmcs for iSeries */ 672 /* XXX Implement enable_pmcs for iSeries */
691}; 673};
692 674
@@ -697,7 +679,7 @@ void * __init iSeries_early_setup(void)
697 /* Identify CPU type. This is done again by the common code later 679 /* Identify CPU type. This is done again by the common code later
698 * on but calling this function multiple times is fine. 680 * on but calling this function multiple times is fine.
699 */ 681 */
700 identify_cpu(0); 682 identify_cpu(0, mfspr(SPRN_PVR));
701 683
702 powerpc_firmware_features |= FW_FEATURE_ISERIES; 684 powerpc_firmware_features |= FW_FEATURE_ISERIES;
703 powerpc_firmware_features |= FW_FEATURE_LPAR; 685 powerpc_firmware_features |= FW_FEATURE_LPAR;
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index 04e07e5da0c1..84e7ee2c086f 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -119,10 +119,9 @@ static int proc_viopath_show(struct seq_file *m, void *v)
119 struct device_node *node; 119 struct device_node *node;
120 const char *sysid; 120 const char *sysid;
121 121
122 buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL); 122 buf = kzalloc(HW_PAGE_SIZE, GFP_KERNEL);
123 if (!buf) 123 if (!buf)
124 return 0; 124 return 0;
125 memset(buf, 0, HW_PAGE_SIZE);
126 125
127 handle = dma_map_single(iSeries_vio_dev, buf, HW_PAGE_SIZE, 126 handle = dma_map_single(iSeries_vio_dev, buf, HW_PAGE_SIZE,
128 DMA_FROM_DEVICE); 127 DMA_FROM_DEVICE);
diff --git a/arch/powerpc/platforms/maple/maple.h b/arch/powerpc/platforms/maple/maple.h
index 0657c579b840..c6911ddc479f 100644
--- a/arch/powerpc/platforms/maple/maple.h
+++ b/arch/powerpc/platforms/maple/maple.h
@@ -8,5 +8,5 @@ extern void maple_get_rtc_time(struct rtc_time *tm);
8extern unsigned long maple_get_boot_time(void); 8extern unsigned long maple_get_boot_time(void);
9extern void maple_calibrate_decr(void); 9extern void maple_calibrate_decr(void);
10extern void maple_pci_init(void); 10extern void maple_pci_init(void);
11extern void maple_pcibios_fixup(void); 11extern void maple_pci_irq_fixup(struct pci_dev *dev);
12extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel); 12extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel);
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 63b4d1bff359..3a32deda765d 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -502,38 +502,29 @@ static int __init add_bridge(struct device_node *dev)
502} 502}
503 503
504 504
505void __init maple_pcibios_fixup(void) 505void __devinit maple_pci_irq_fixup(struct pci_dev *dev)
506{ 506{
507 struct pci_dev *dev = NULL; 507 DBG(" -> maple_pci_irq_fixup\n");
508 508
509 DBG(" -> maple_pcibios_fixup\n"); 509 /* Fixup IRQ for PCIe host */
510 510 if (u4_pcie != NULL && dev->bus->number == 0 &&
511 for_each_pci_dev(dev) { 511 pci_bus_to_host(dev->bus) == u4_pcie) {
512 /* Fixup IRQ for PCIe host */ 512 printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n");
513 if (u4_pcie != NULL && dev->bus->number == 0 && 513 dev->irq = irq_create_mapping(NULL, 1);
514 pci_bus_to_host(dev->bus) == u4_pcie) { 514 if (dev->irq != NO_IRQ)
515 printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n"); 515 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
516 dev->irq = irq_create_mapping(NULL, 1); 516 }
517 if (dev->irq != NO_IRQ)
518 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
519 continue;
520 }
521
522 /* Hide AMD8111 IDE interrupt when in legacy mode so
523 * the driver calls pci_get_legacy_ide_irq()
524 */
525 if (dev->vendor == PCI_VENDOR_ID_AMD &&
526 dev->device == PCI_DEVICE_ID_AMD_8111_IDE &&
527 (dev->class & 5) != 5) {
528 dev->irq = NO_IRQ;
529 continue;
530 }
531 517
532 /* For all others, map the interrupt from the device-tree */ 518 /* Hide AMD8111 IDE interrupt when in legacy mode so
533 pci_read_irq_line(dev); 519 * the driver calls pci_get_legacy_ide_irq()
520 */
521 if (dev->vendor == PCI_VENDOR_ID_AMD &&
522 dev->device == PCI_DEVICE_ID_AMD_8111_IDE &&
523 (dev->class & 5) != 5) {
524 dev->irq = NO_IRQ;
534 } 525 }
535 526
536 DBG(" <- maple_pcibios_fixup\n"); 527 DBG(" <- maple_pci_irq_fixup\n");
537} 528}
538 529
539static void __init maple_fixup_phb_resources(void) 530static void __init maple_fixup_phb_resources(void)
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index fe6b9bff61b9..094989d50bab 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -312,7 +312,7 @@ define_machine(maple_md) {
312 .setup_arch = maple_setup_arch, 312 .setup_arch = maple_setup_arch,
313 .init_early = maple_init_early, 313 .init_early = maple_init_early,
314 .init_IRQ = maple_init_IRQ, 314 .init_IRQ = maple_init_IRQ,
315 .pcibios_fixup = maple_pcibios_fixup, 315 .pci_irq_fixup = maple_pci_irq_fixup,
316 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq, 316 .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
317 .restart = maple_restart, 317 .restart = maple_restart,
318 .power_off = maple_power_off, 318 .power_off = maple_power_off,
diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h
index fd71d72736b2..51c2a2397ecf 100644
--- a/arch/powerpc/platforms/pasemi/pasemi.h
+++ b/arch/powerpc/platforms/pasemi/pasemi.h
@@ -3,6 +3,5 @@
3 3
4extern unsigned long pas_get_boot_time(void); 4extern unsigned long pas_get_boot_time(void);
5extern void pas_pci_init(void); 5extern void pas_pci_init(void);
6extern void pas_pcibios_fixup(void);
7 6
8#endif /* _PASEMI_PASEMI_H */ 7#endif /* _PASEMI_PASEMI_H */
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
index 39020c1fa13d..faa618e04047 100644
--- a/arch/powerpc/platforms/pasemi/pci.c
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -148,14 +148,6 @@ static int __init add_bridge(struct device_node *dev)
148} 148}
149 149
150 150
151void __init pas_pcibios_fixup(void)
152{
153 struct pci_dev *dev = NULL;
154
155 for_each_pci_dev(dev)
156 pci_read_irq_line(dev);
157}
158
159static void __init pas_fixup_phb_resources(void) 151static void __init pas_fixup_phb_resources(void)
160{ 152{
161 struct pci_controller *hose, *tmp; 153 struct pci_controller *hose, *tmp;
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 106896c3b60a..89d6e295dbf7 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -26,6 +26,7 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/console.h> 28#include <linux/console.h>
29#include <linux/pci.h>
29 30
30#include <asm/prom.h> 31#include <asm/prom.h>
31#include <asm/system.h> 32#include <asm/system.h>
@@ -71,6 +72,9 @@ void __init pas_setup_arch(void)
71 /* Setup SMP callback */ 72 /* Setup SMP callback */
72 smp_ops = &pas_smp_ops; 73 smp_ops = &pas_smp_ops;
73#endif 74#endif
75 /* no iommu yet */
76 pci_dma_ops = &dma_direct_ops;
77
74 /* Lookup PCI hosts */ 78 /* Lookup PCI hosts */
75 pas_pci_init(); 79 pas_pci_init();
76 80
@@ -81,17 +85,6 @@ void __init pas_setup_arch(void)
81 printk(KERN_DEBUG "Using default idle loop\n"); 85 printk(KERN_DEBUG "Using default idle loop\n");
82} 86}
83 87
84static void iommu_dev_setup_null(struct pci_dev *dev) { }
85static void iommu_bus_setup_null(struct pci_bus *bus) { }
86
87static void __init pas_init_early(void)
88{
89 /* No iommu code yet */
90 ppc_md.iommu_dev_setup = iommu_dev_setup_null;
91 ppc_md.iommu_bus_setup = iommu_bus_setup_null;
92 pci_direct_iommu_init();
93}
94
95/* No legacy IO on our parts */ 88/* No legacy IO on our parts */
96static int pas_check_legacy_ioport(unsigned int baseport) 89static int pas_check_legacy_ioport(unsigned int baseport)
97{ 90{
@@ -173,10 +166,8 @@ define_machine(pas) {
173 .name = "PA Semi PA6T-1682M", 166 .name = "PA Semi PA6T-1682M",
174 .probe = pas_probe, 167 .probe = pas_probe,
175 .setup_arch = pas_setup_arch, 168 .setup_arch = pas_setup_arch,
176 .init_early = pas_init_early,
177 .init_IRQ = pas_init_IRQ, 169 .init_IRQ = pas_init_IRQ,
178 .get_irq = mpic_get_irq, 170 .get_irq = mpic_get_irq,
179 .pcibios_fixup = pas_pcibios_fixup,
180 .restart = pas_restart, 171 .restart = pas_restart,
181 .power_off = pas_power_off, 172 .power_off = pas_power_off,
182 .halt = pas_halt, 173 .halt = pas_halt,
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index afa593a8544a..c3a89414ddc0 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -18,11 +18,11 @@
18 18
19#define OLD_BACKLIGHT_MAX 15 19#define OLD_BACKLIGHT_MAX 15
20 20
21static void pmac_backlight_key_worker(void *data); 21static void pmac_backlight_key_worker(struct work_struct *work);
22static void pmac_backlight_set_legacy_worker(void *data); 22static void pmac_backlight_set_legacy_worker(struct work_struct *work);
23 23
24static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL); 24static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker);
25static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker, NULL); 25static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker);
26 26
27/* Although these variables are used in interrupt context, it makes no sense to 27/* Although these variables are used in interrupt context, it makes no sense to
28 * protect them. No user is able to produce enough key events per second and 28 * protect them. No user is able to produce enough key events per second and
@@ -94,7 +94,7 @@ int pmac_backlight_curve_lookup(struct fb_info *info, int value)
94 return level; 94 return level;
95} 95}
96 96
97static void pmac_backlight_key_worker(void *data) 97static void pmac_backlight_key_worker(struct work_struct *work)
98{ 98{
99 if (atomic_read(&kernel_backlight_disabled)) 99 if (atomic_read(&kernel_backlight_disabled))
100 return; 100 return;
@@ -166,7 +166,7 @@ static int __pmac_backlight_set_legacy_brightness(int brightness)
166 return error; 166 return error;
167} 167}
168 168
169static void pmac_backlight_set_legacy_worker(void *data) 169static void pmac_backlight_set_legacy_worker(struct work_struct *work)
170{ 170{
171 if (atomic_read(&kernel_backlight_disabled)) 171 if (atomic_read(&kernel_backlight_disabled))
172 return; 172 return;
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index e49621be6640..c29a6a064d22 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -486,10 +486,6 @@ static long heathrow_sound_enable(struct device_node *node, long param,
486 486
487static u32 save_fcr[6]; 487static u32 save_fcr[6];
488static u32 save_mbcr; 488static u32 save_mbcr;
489static u32 save_gpio_levels[2];
490static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT];
491static u8 save_gpio_normal[KEYLARGO_GPIO_CNT];
492static u32 save_unin_clock_ctl;
493static struct dbdma_regs save_dbdma[13]; 489static struct dbdma_regs save_dbdma[13];
494static struct dbdma_regs save_alt_dbdma[13]; 490static struct dbdma_regs save_alt_dbdma[13];
495 491
@@ -1548,6 +1544,10 @@ void g5_phy_disable_cpu1(void)
1548 1544
1549 1545
1550#ifdef CONFIG_PM 1546#ifdef CONFIG_PM
1547static u32 save_gpio_levels[2];
1548static u8 save_gpio_extint[KEYLARGO_GPIO_EXTINT_CNT];
1549static u8 save_gpio_normal[KEYLARGO_GPIO_CNT];
1550static u32 save_unin_clock_ctl;
1551 1551
1552static void keylargo_shutdown(struct macio_chip *macio, int sleep_mode) 1552static void keylargo_shutdown(struct macio_chip *macio, int sleep_mode)
1553{ 1553{
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 257dc9068468..f42475b27c15 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -984,30 +984,23 @@ static int __init add_bridge(struct device_node *dev)
984 return 0; 984 return 0;
985} 985}
986 986
987void __init pmac_pcibios_fixup(void) 987void __devinit pmac_pci_irq_fixup(struct pci_dev *dev)
988{ 988{
989 struct pci_dev* dev = NULL;
990
991 for_each_pci_dev(dev) {
992 /* Read interrupt from the device-tree */
993 pci_read_irq_line(dev);
994
995#ifdef CONFIG_PPC32 989#ifdef CONFIG_PPC32
996 /* Fixup interrupt for the modem/ethernet combo controller. 990 /* Fixup interrupt for the modem/ethernet combo controller.
997 * on machines with a second ohare chip. 991 * on machines with a second ohare chip.
998 * The number in the device tree (27) is bogus (correct for 992 * The number in the device tree (27) is bogus (correct for
999 * the ethernet-only board but not the combo ethernet/modem 993 * the ethernet-only board but not the combo ethernet/modem
1000 * board). The real interrupt is 28 on the second controller 994 * board). The real interrupt is 28 on the second controller
1001 * -> 28+32 = 60. 995 * -> 28+32 = 60.
1002 */ 996 */
1003 if (has_second_ohare && 997 if (has_second_ohare &&
1004 dev->vendor == PCI_VENDOR_ID_DEC && 998 dev->vendor == PCI_VENDOR_ID_DEC &&
1005 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) { 999 dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) {
1006 dev->irq = irq_create_mapping(NULL, 60); 1000 dev->irq = irq_create_mapping(NULL, 60);
1007 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 1001 set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
1008 }
1009#endif /* CONFIG_PPC32 */
1010 } 1002 }
1003#endif /* CONFIG_PPC32 */
1011} 1004}
1012 1005
1013#ifdef CONFIG_PPC64 1006#ifdef CONFIG_PPC64
diff --git a/arch/powerpc/platforms/powermac/pmac.h b/arch/powerpc/platforms/powermac/pmac.h
index 94e7b24b840b..6e090a7dea83 100644
--- a/arch/powerpc/platforms/powermac/pmac.h
+++ b/arch/powerpc/platforms/powermac/pmac.h
@@ -20,7 +20,7 @@ extern void pmac_get_rtc_time(struct rtc_time *);
20extern int pmac_set_rtc_time(struct rtc_time *); 20extern int pmac_set_rtc_time(struct rtc_time *);
21extern void pmac_read_rtc_time(void); 21extern void pmac_read_rtc_time(void);
22extern void pmac_calibrate_decr(void); 22extern void pmac_calibrate_decr(void);
23extern void pmac_pcibios_fixup(void); 23extern void pmac_pci_irq_fixup(struct pci_dev *);
24extern void pmac_pci_init(void); 24extern void pmac_pci_init(void);
25extern unsigned long pmac_ide_get_base(int index); 25extern unsigned long pmac_ide_get_base(int index);
26extern void pmac_ide_init_hwif_ports(hw_regs_t *hw, 26extern void pmac_ide_init_hwif_ports(hw_regs_t *hw,
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 824a618396ab..d949e9df41ef 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -70,6 +70,7 @@
70#include <asm/pmac_feature.h> 70#include <asm/pmac_feature.h>
71#include <asm/time.h> 71#include <asm/time.h>
72#include <asm/of_device.h> 72#include <asm/of_device.h>
73#include <asm/of_platform.h>
73#include <asm/mmu_context.h> 74#include <asm/mmu_context.h>
74#include <asm/iommu.h> 75#include <asm/iommu.h>
75#include <asm/smu.h> 76#include <asm/smu.h>
@@ -361,7 +362,7 @@ char *bootdevice;
361void *boot_host; 362void *boot_host;
362int boot_target; 363int boot_target;
363int boot_part; 364int boot_part;
364extern dev_t boot_dev; 365static dev_t boot_dev;
365 366
366#ifdef CONFIG_SCSI 367#ifdef CONFIG_SCSI
367void __init note_scsi_host(struct device_node *node, void *host) 368void __init note_scsi_host(struct device_node *node, void *host)
@@ -676,8 +677,6 @@ static int __init pmac_probe(void)
676 677
677#ifdef CONFIG_PPC32 678#ifdef CONFIG_PPC32
678 /* isa_io_base gets set in pmac_pci_init */ 679 /* isa_io_base gets set in pmac_pci_init */
679 isa_mem_base = PMAC_ISA_MEM_BASE;
680 pci_dram_offset = PMAC_PCI_DRAM_OFFSET;
681 ISA_DMA_THRESHOLD = ~0L; 680 ISA_DMA_THRESHOLD = ~0L;
682 DMA_MODE_READ = 1; 681 DMA_MODE_READ = 1;
683 DMA_MODE_WRITE = 2; 682 DMA_MODE_WRITE = 2;
@@ -727,7 +726,7 @@ define_machine(powermac) {
727 .show_cpuinfo = pmac_show_cpuinfo, 726 .show_cpuinfo = pmac_show_cpuinfo,
728 .init_IRQ = pmac_pic_init, 727 .init_IRQ = pmac_pic_init,
729 .get_irq = NULL, /* changed later */ 728 .get_irq = NULL, /* changed later */
730 .pcibios_fixup = pmac_pcibios_fixup, 729 .pci_irq_fixup = pmac_pci_irq_fixup,
731 .restart = pmac_restart, 730 .restart = pmac_restart,
732 .power_off = pmac_power_off, 731 .power_off = pmac_power_off,
733 .halt = pmac_halt, 732 .halt = pmac_halt,
diff --git a/arch/powerpc/platforms/ps3/Kconfig b/arch/powerpc/platforms/ps3/Kconfig
new file mode 100644
index 000000000000..451bfcd5502e
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -0,0 +1,43 @@
1menu "PS3 Platform Options"
2 depends on PPC_PS3
3
4config PS3_HTAB_SIZE
5 depends on PPC_PS3
6 int "PS3 Platform pagetable size"
7 range 18 20
8 default 20
9 help
10 This option is only for experts who may have the desire to fine
11 tune the pagetable size on their system. The value here is
12 expressed as the log2 of the page table size. Valid values are
13 18, 19, and 20, corresponding to 256KB, 512KB and 1MB respectively.
14
15 If unsure, choose the default (20) with the confidence that your
16 system will have optimal runtime performance.
17
18config PS3_DYNAMIC_DMA
19 depends on PPC_PS3 && EXPERIMENTAL
20 bool "PS3 Platform dynamic DMA page table management"
21 default n
22 help
23 This option will enable kernel support to take advantage of the
24 per device dynamic DMA page table management provided by the Cell
25 processor's IO Controller. This support incurs some runtime
26 overhead and also slightly increases kernel memory usage. The
27 current implementation should be considered experimental.
28
29 This support is mainly for Linux kernel development. If unsure,
30 say N.
31
32config PS3_USE_LPAR_ADDR
33 depends on PPC_PS3 && EXPERIMENTAL
34 bool "PS3 use lpar address space"
35 default y
36 help
37 This option is solely for experimentation by experts. Disables
38 translation of lpar addresses. SPE support currently won't work
39 without this set to y.
40
41 If you have any doubt, choose the default y.
42
43endmenu
diff --git a/arch/powerpc/platforms/ps3/Makefile b/arch/powerpc/platforms/ps3/Makefile
new file mode 100644
index 000000000000..3757cfabc8ce
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/Makefile
@@ -0,0 +1,4 @@
1obj-y += setup.o mm.o smp.o time.o hvcall.o htab.o repository.o
2obj-y += interrupt.o exports.o os-area.o
3
4obj-$(CONFIG_SPU_BASE) += spu.o
diff --git a/arch/powerpc/platforms/ps3/exports.c b/arch/powerpc/platforms/ps3/exports.c
new file mode 100644
index 000000000000..a7e8ffd24a65
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/exports.c
@@ -0,0 +1,27 @@
1/*
2 * PS3 hvcall exports for modules.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
22
23#define LV1_CALL(name, in, out, num) \
24 extern s64 _lv1_##name(LV1_##in##_IN_##out##_OUT_ARG_DECL); \
25 EXPORT_SYMBOL(_lv1_##name);
26
27#include <asm/lv1call.h>
diff --git a/arch/powerpc/platforms/ps3/htab.c b/arch/powerpc/platforms/ps3/htab.c
new file mode 100644
index 000000000000..8fe1769655a3
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -0,0 +1,277 @@
1/*
2 * PS3 pagetable management routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22
23#include <asm/machdep.h>
24#include <asm/lmb.h>
25#include <asm/udbg.h>
26#include <asm/ps3.h>
27#include <asm/lv1call.h>
28
29#include "platform.h"
30
31#if defined(DEBUG)
32#define DBG(fmt...) udbg_printf(fmt)
33#else
34#define DBG(fmt...) do{if(0)printk(fmt);}while(0)
35#endif
36
37static hpte_t *htab;
38static unsigned long htab_addr;
39static unsigned char *bolttab;
40static unsigned char *inusetab;
41
42static spinlock_t ps3_bolttab_lock = SPIN_LOCK_UNLOCKED;
43
44#define debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g) \
45 _debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
46static void _debug_dump_hpte(unsigned long pa, unsigned long va,
47 unsigned long group, unsigned long bitmap, hpte_t lhpte, int psize,
48 unsigned long slot, const char* func, int line)
49{
50 DBG("%s:%d: pa = %lxh\n", func, line, pa);
51 DBG("%s:%d: lpar = %lxh\n", func, line,
52 ps3_mm_phys_to_lpar(pa));
53 DBG("%s:%d: va = %lxh\n", func, line, va);
54 DBG("%s:%d: group = %lxh\n", func, line, group);
55 DBG("%s:%d: bitmap = %lxh\n", func, line, bitmap);
56 DBG("%s:%d: hpte.v = %lxh\n", func, line, lhpte.v);
57 DBG("%s:%d: hpte.r = %lxh\n", func, line, lhpte.r);
58 DBG("%s:%d: psize = %xh\n", func, line, psize);
59 DBG("%s:%d: slot = %lxh\n", func, line, slot);
60}
61
62static long ps3_hpte_insert(unsigned long hpte_group, unsigned long va,
63 unsigned long pa, unsigned long rflags, unsigned long vflags, int psize)
64{
65 unsigned long slot;
66 hpte_t lhpte;
67 int secondary = 0;
68 unsigned long result;
69 unsigned long bitmap;
70 unsigned long flags;
71 unsigned long p_pteg, s_pteg, b_index, b_mask, cb, ci;
72
73 vflags &= ~HPTE_V_SECONDARY; /* this bit is ignored */
74
75 lhpte.v = hpte_encode_v(va, psize) | vflags | HPTE_V_VALID;
76 lhpte.r = hpte_encode_r(ps3_mm_phys_to_lpar(pa), psize) | rflags;
77
78 p_pteg = hpte_group / HPTES_PER_GROUP;
79 s_pteg = ~p_pteg & htab_hash_mask;
80
81 spin_lock_irqsave(&ps3_bolttab_lock, flags);
82
83 BUG_ON(bolttab[p_pteg] == 0xff && bolttab[s_pteg] == 0xff);
84
85 bitmap = (inusetab[p_pteg] << 8) | inusetab[s_pteg];
86
87 if (bitmap == 0xffff) {
88 /*
89 * PTEG is full. Search for victim.
90 */
91 bitmap &= ~((bolttab[p_pteg] << 8) | bolttab[s_pteg]);
92 do {
93 ci = mftb() & 15;
94 cb = 0x8000UL >> ci;
95 } while ((cb & bitmap) == 0);
96 } else {
97 /*
98 * search free slot in hardware order
99 * [primary] 0, 2, 4, 6, 1, 3, 5, 7
100 * [secondary] 0, 2, 4, 6, 1, 3, 5, 7
101 */
102 for (ci = 0; ci < HPTES_PER_GROUP; ci += 2) {
103 cb = 0x8000UL >> ci;
104 if ((cb & bitmap) == 0)
105 goto found;
106 }
107 for (ci = 1; ci < HPTES_PER_GROUP; ci += 2) {
108 cb = 0x8000UL >> ci;
109 if ((cb & bitmap) == 0)
110 goto found;
111 }
112 for (ci = HPTES_PER_GROUP; ci < HPTES_PER_GROUP*2; ci += 2) {
113 cb = 0x8000UL >> ci;
114 if ((cb & bitmap) == 0)
115 goto found;
116 }
117 for (ci = HPTES_PER_GROUP+1; ci < HPTES_PER_GROUP*2; ci += 2) {
118 cb = 0x8000UL >> ci;
119 if ((cb & bitmap) == 0)
120 goto found;
121 }
122 }
123
124found:
125 if (ci < HPTES_PER_GROUP) {
126 slot = p_pteg * HPTES_PER_GROUP + ci;
127 } else {
128 slot = s_pteg * HPTES_PER_GROUP + (ci & 7);
129 /* lhpte.dw0.dw0.h = 1; */
130 vflags |= HPTE_V_SECONDARY;
131 lhpte.v |= HPTE_V_SECONDARY;
132 }
133
134 result = lv1_write_htab_entry(0, slot, lhpte.v, lhpte.r);
135
136 if (result) {
137 debug_dump_hpte(pa, va, hpte_group, bitmap, lhpte, psize, slot);
138 BUG();
139 }
140
141 /*
142 * If used slot is not in primary HPTE group,
143 * the slot should be in secondary HPTE group.
144 */
145
146 if ((hpte_group ^ slot) & ~(HPTES_PER_GROUP - 1)) {
147 secondary = 1;
148 b_index = s_pteg;
149 } else {
150 secondary = 0;
151 b_index = p_pteg;
152 }
153
154 b_mask = (lhpte.v & HPTE_V_BOLTED) ? 1 << 7 : 0 << 7;
155 bolttab[b_index] |= b_mask >> (slot & 7);
156 b_mask = 1 << 7;
157 inusetab[b_index] |= b_mask >> (slot & 7);
158 spin_unlock_irqrestore(&ps3_bolttab_lock, flags);
159
160 return (slot & 7) | (secondary << 3);
161}
162
163static long ps3_hpte_remove(unsigned long hpte_group)
164{
165 panic("ps3_hpte_remove() not implemented");
166 return 0;
167}
168
169static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp,
170 unsigned long va, int psize, int local)
171{
172 unsigned long flags;
173 unsigned long result;
174 unsigned long pteg, bit;
175 unsigned long hpte_v, want_v;
176
177 want_v = hpte_encode_v(va, psize);
178
179 spin_lock_irqsave(&ps3_bolttab_lock, flags);
180
181 hpte_v = htab[slot].v;
182 if (!HPTE_V_COMPARE(hpte_v, want_v) || !(hpte_v & HPTE_V_VALID)) {
183 spin_unlock_irqrestore(&ps3_bolttab_lock, flags);
184
185 /* ps3_hpte_insert() will be used to update PTE */
186 return -1;
187 }
188
189 result = lv1_write_htab_entry(0, slot, 0, 0);
190
191 if (result) {
192 DBG("%s: va=%lx slot=%lx psize=%d result = %ld (0x%lx)\n",
193 __func__, va, slot, psize, result, result);
194 BUG();
195 }
196
197 pteg = slot / HPTES_PER_GROUP;
198 bit = slot % HPTES_PER_GROUP;
199 inusetab[pteg] &= ~(0x80 >> bit);
200
201 spin_unlock_irqrestore(&ps3_bolttab_lock, flags);
202
203 /* ps3_hpte_insert() will be used to update PTE */
204 return -1;
205}
206
207static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
208 int psize)
209{
210 panic("ps3_hpte_updateboltedpp() not implemented");
211}
212
213static void ps3_hpte_invalidate(unsigned long slot, unsigned long va,
214 int psize, int local)
215{
216 unsigned long flags;
217 unsigned long result;
218 unsigned long pteg, bit;
219
220 spin_lock_irqsave(&ps3_bolttab_lock, flags);
221 result = lv1_write_htab_entry(0, slot, 0, 0);
222
223 if (result) {
224 DBG("%s: va=%lx slot=%lx psize=%d result = %ld (0x%lx)\n",
225 __func__, va, slot, psize, result, result);
226 BUG();
227 }
228
229 pteg = slot / HPTES_PER_GROUP;
230 bit = slot % HPTES_PER_GROUP;
231 inusetab[pteg] &= ~(0x80 >> bit);
232 spin_unlock_irqrestore(&ps3_bolttab_lock, flags);
233}
234
235static void ps3_hpte_clear(void)
236{
237 lv1_unmap_htab(htab_addr);
238}
239
240void __init ps3_hpte_init(unsigned long htab_size)
241{
242 long bitmap_size;
243
244 DBG(" -> %s:%d\n", __func__, __LINE__);
245
246 ppc_md.hpte_invalidate = ps3_hpte_invalidate;
247 ppc_md.hpte_updatepp = ps3_hpte_updatepp;
248 ppc_md.hpte_updateboltedpp = ps3_hpte_updateboltedpp;
249 ppc_md.hpte_insert = ps3_hpte_insert;
250 ppc_md.hpte_remove = ps3_hpte_remove;
251 ppc_md.hpte_clear_all = ps3_hpte_clear;
252
253 ppc64_pft_size = __ilog2(htab_size);
254
255 bitmap_size = htab_size / sizeof(hpte_t) / 8;
256
257 bolttab = __va(lmb_alloc(bitmap_size, 1));
258 inusetab = __va(lmb_alloc(bitmap_size, 1));
259
260 memset(bolttab, 0, bitmap_size);
261 memset(inusetab, 0, bitmap_size);
262
263 DBG(" <- %s:%d\n", __func__, __LINE__);
264}
265
266void __init ps3_map_htab(void)
267{
268 long result;
269 unsigned long htab_size = (1UL << ppc64_pft_size);
270
271 result = lv1_map_htab(0, &htab_addr);
272
273 htab = (hpte_t *)__ioremap(htab_addr, htab_size, PAGE_READONLY_X);
274
275 DBG("%s:%d: lpar %016lxh, virt %016lxh\n", __func__, __LINE__,
276 htab_addr, (unsigned long)htab);
277}
diff --git a/arch/powerpc/platforms/ps3/hvcall.S b/arch/powerpc/platforms/ps3/hvcall.S
new file mode 100644
index 000000000000..54be6523a0e8
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/hvcall.S
@@ -0,0 +1,804 @@
1/*
2 * PS3 hvcall interface.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
6 * Copyright 2003, 2004 (c) MontaVista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <asm/processor.h>
23#include <asm/ppc_asm.h>
24
25#define lv1call .long 0x44000022; extsw r3, r3
26
27#define LV1_N_IN_0_OUT(API_NAME, API_NUMBER) \
28_GLOBAL(_##API_NAME) \
29 \
30 mflr r0; \
31 std r0, 16(r1); \
32 \
33 li r11, API_NUMBER; \
34 lv1call; \
35 \
36 ld r0, 16(r1); \
37 mtlr r0; \
38 blr
39
40#define LV1_0_IN_0_OUT LV1_N_IN_0_OUT
41#define LV1_1_IN_0_OUT LV1_N_IN_0_OUT
42#define LV1_2_IN_0_OUT LV1_N_IN_0_OUT
43#define LV1_3_IN_0_OUT LV1_N_IN_0_OUT
44#define LV1_4_IN_0_OUT LV1_N_IN_0_OUT
45#define LV1_5_IN_0_OUT LV1_N_IN_0_OUT
46#define LV1_6_IN_0_OUT LV1_N_IN_0_OUT
47#define LV1_7_IN_0_OUT LV1_N_IN_0_OUT
48
49#define LV1_0_IN_1_OUT(API_NAME, API_NUMBER) \
50_GLOBAL(_##API_NAME) \
51 \
52 mflr r0; \
53 std r0, 16(r1); \
54 \
55 stdu r3, -8(r1); \
56 \
57 li r11, API_NUMBER; \
58 lv1call; \
59 \
60 addi r1, r1, 8; \
61 ld r11, -8(r1); \
62 std r4, 0(r11); \
63 \
64 ld r0, 16(r1); \
65 mtlr r0; \
66 blr
67
68#define LV1_0_IN_2_OUT(API_NAME, API_NUMBER) \
69_GLOBAL(_##API_NAME) \
70 \
71 mflr r0; \
72 std r0, 16(r1); \
73 \
74 std r3, -8(r1); \
75 stdu r4, -16(r1); \
76 \
77 li r11, API_NUMBER; \
78 lv1call; \
79 \
80 addi r1, r1, 16; \
81 ld r11, -8(r1); \
82 std r4, 0(r11); \
83 ld r11, -16(r1); \
84 std r5, 0(r11); \
85 \
86 ld r0, 16(r1); \
87 mtlr r0; \
88 blr
89
90#define LV1_0_IN_3_OUT(API_NAME, API_NUMBER) \
91_GLOBAL(_##API_NAME) \
92 \
93 mflr r0; \
94 std r0, 16(r1); \
95 \
96 std r3, -8(r1); \
97 std r4, -16(r1); \
98 stdu r5, -24(r1); \
99 \
100 li r11, API_NUMBER; \
101 lv1call; \
102 \
103 addi r1, r1, 24; \
104 ld r11, -8(r1); \
105 std r4, 0(r11); \
106 ld r11, -16(r1); \
107 std r5, 0(r11); \
108 ld r11, -24(r1); \
109 std r6, 0(r11); \
110 \
111 ld r0, 16(r1); \
112 mtlr r0; \
113 blr
114
115#define LV1_0_IN_7_OUT(API_NAME, API_NUMBER) \
116_GLOBAL(_##API_NAME) \
117 \
118 mflr r0; \
119 std r0, 16(r1); \
120 \
121 std r3, -8(r1); \
122 std r4, -16(r1); \
123 std r5, -24(r1); \
124 std r6, -32(r1); \
125 std r7, -40(r1); \
126 std r8, -48(r1); \
127 stdu r9, -56(r1); \
128 \
129 li r11, API_NUMBER; \
130 lv1call; \
131 \
132 addi r1, r1, 56; \
133 ld r11, -8(r1); \
134 std r4, 0(r11); \
135 ld r11, -16(r1); \
136 std r5, 0(r11); \
137 ld r11, -24(r1); \
138 std r6, 0(r11); \
139 ld r11, -32(r1); \
140 std r7, 0(r11); \
141 ld r11, -40(r1); \
142 std r8, 0(r11); \
143 ld r11, -48(r1); \
144 std r9, 0(r11); \
145 ld r11, -56(r1); \
146 std r10, 0(r11); \
147 \
148 ld r0, 16(r1); \
149 mtlr r0; \
150 blr
151
152#define LV1_1_IN_1_OUT(API_NAME, API_NUMBER) \
153_GLOBAL(_##API_NAME) \
154 \
155 mflr r0; \
156 std r0, 16(r1); \
157 \
158 stdu r4, -8(r1); \
159 \
160 li r11, API_NUMBER; \
161 lv1call; \
162 \
163 addi r1, r1, 8; \
164 ld r11, -8(r1); \
165 std r4, 0(r11); \
166 \
167 ld r0, 16(r1); \
168 mtlr r0; \
169 blr
170
171#define LV1_1_IN_2_OUT(API_NAME, API_NUMBER) \
172_GLOBAL(_##API_NAME) \
173 \
174 mflr r0; \
175 std r0, 16(r1); \
176 \
177 std r4, -8(r1); \
178 stdu r5, -16(r1); \
179 \
180 li r11, API_NUMBER; \
181 lv1call; \
182 \
183 addi r1, r1, 16; \
184 ld r11, -8(r1); \
185 std r4, 0(r11); \
186 ld r11, -16(r1); \
187 std r5, 0(r11); \
188 \
189 ld r0, 16(r1); \
190 mtlr r0; \
191 blr
192
193#define LV1_1_IN_3_OUT(API_NAME, API_NUMBER) \
194_GLOBAL(_##API_NAME) \
195 \
196 mflr r0; \
197 std r0, 16(r1); \
198 \
199 std r4, -8(r1); \
200 std r5, -16(r1); \
201 stdu r6, -24(r1); \
202 \
203 li r11, API_NUMBER; \
204 lv1call; \
205 \
206 addi r1, r1, 24; \
207 ld r11, -8(r1); \
208 std r4, 0(r11); \
209 ld r11, -16(r1); \
210 std r5, 0(r11); \
211 ld r11, -24(r1); \
212 std r6, 0(r11); \
213 \
214 ld r0, 16(r1); \
215 mtlr r0; \
216 blr
217
218#define LV1_1_IN_4_OUT(API_NAME, API_NUMBER) \
219_GLOBAL(_##API_NAME) \
220 \
221 mflr r0; \
222 std r0, 16(r1); \
223 \
224 std r4, -8(r1); \
225 std r5, -16(r1); \
226 std r6, -24(r1); \
227 stdu r7, -32(r1); \
228 \
229 li r11, API_NUMBER; \
230 lv1call; \
231 \
232 addi r1, r1, 32; \
233 ld r11, -8(r1); \
234 std r4, 0(r11); \
235 ld r11, -16(r1); \
236 std r5, 0(r11); \
237 ld r11, -24(r1); \
238 std r6, 0(r11); \
239 ld r11, -32(r1); \
240 std r7, 0(r11); \
241 \
242 ld r0, 16(r1); \
243 mtlr r0; \
244 blr
245
246#define LV1_1_IN_5_OUT(API_NAME, API_NUMBER) \
247_GLOBAL(_##API_NAME) \
248 \
249 mflr r0; \
250 std r0, 16(r1); \
251 \
252 std r4, -8(r1); \
253 std r5, -16(r1); \
254 std r6, -24(r1); \
255 std r7, -32(r1); \
256 stdu r8, -40(r1); \
257 \
258 li r11, API_NUMBER; \
259 lv1call; \
260 \
261 addi r1, r1, 40; \
262 ld r11, -8(r1); \
263 std r4, 0(r11); \
264 ld r11, -16(r1); \
265 std r5, 0(r11); \
266 ld r11, -24(r1); \
267 std r6, 0(r11); \
268 ld r11, -32(r1); \
269 std r7, 0(r11); \
270 ld r11, -40(r1); \
271 std r8, 0(r11); \
272 \
273 ld r0, 16(r1); \
274 mtlr r0; \
275 blr
276
277#define LV1_1_IN_6_OUT(API_NAME, API_NUMBER) \
278_GLOBAL(_##API_NAME) \
279 \
280 mflr r0; \
281 std r0, 16(r1); \
282 \
283 std r4, -8(r1); \
284 std r5, -16(r1); \
285 std r6, -24(r1); \
286 std r7, -32(r1); \
287 std r8, -40(r1); \
288 stdu r9, -48(r1); \
289 \
290 li r11, API_NUMBER; \
291 lv1call; \
292 \
293 addi r1, r1, 48; \
294 ld r11, -8(r1); \
295 std r4, 0(r11); \
296 ld r11, -16(r1); \
297 std r5, 0(r11); \
298 ld r11, -24(r1); \
299 std r6, 0(r11); \
300 ld r11, -32(r1); \
301 std r7, 0(r11); \
302 ld r11, -40(r1); \
303 std r8, 0(r11); \
304 ld r11, -48(r1); \
305 std r9, 0(r11); \
306 \
307 ld r0, 16(r1); \
308 mtlr r0; \
309 blr
310
311#define LV1_1_IN_7_OUT(API_NAME, API_NUMBER) \
312_GLOBAL(_##API_NAME) \
313 \
314 mflr r0; \
315 std r0, 16(r1); \
316 \
317 std r4, -8(r1); \
318 std r5, -16(r1); \
319 std r6, -24(r1); \
320 std r7, -32(r1); \
321 std r8, -40(r1); \
322 std r9, -48(r1); \
323 stdu r10, -56(r1); \
324 \
325 li r11, API_NUMBER; \
326 lv1call; \
327 \
328 addi r1, r1, 56; \
329 ld r11, -8(r1); \
330 std r4, 0(r11); \
331 ld r11, -16(r1); \
332 std r5, 0(r11); \
333 ld r11, -24(r1); \
334 std r6, 0(r11); \
335 ld r11, -32(r1); \
336 std r7, 0(r11); \
337 ld r11, -40(r1); \
338 std r8, 0(r11); \
339 ld r11, -48(r1); \
340 std r9, 0(r11); \
341 ld r11, -56(r1); \
342 std r10, 0(r11); \
343 \
344 ld r0, 16(r1); \
345 mtlr r0; \
346 blr
347
348#define LV1_2_IN_1_OUT(API_NAME, API_NUMBER) \
349_GLOBAL(_##API_NAME) \
350 \
351 mflr r0; \
352 std r0, 16(r1); \
353 \
354 stdu r5, -8(r1); \
355 \
356 li r11, API_NUMBER; \
357 lv1call; \
358 \
359 addi r1, r1, 8; \
360 ld r11, -8(r1); \
361 std r4, 0(r11); \
362 \
363 ld r0, 16(r1); \
364 mtlr r0; \
365 blr
366
367#define LV1_2_IN_2_OUT(API_NAME, API_NUMBER) \
368_GLOBAL(_##API_NAME) \
369 \
370 mflr r0; \
371 std r0, 16(r1); \
372 \
373 std r5, -8(r1); \
374 stdu r6, -16(r1); \
375 \
376 li r11, API_NUMBER; \
377 lv1call; \
378 \
379 addi r1, r1, 16; \
380 ld r11, -8(r1); \
381 std r4, 0(r11); \
382 ld r11, -16(r1); \
383 std r5, 0(r11); \
384 \
385 ld r0, 16(r1); \
386 mtlr r0; \
387 blr
388
389#define LV1_2_IN_3_OUT(API_NAME, API_NUMBER) \
390_GLOBAL(_##API_NAME) \
391 \
392 mflr r0; \
393 std r0, 16(r1); \
394 \
395 std r5, -8(r1); \
396 std r6, -16(r1); \
397 stdu r7, -24(r1); \
398 \
399 li r11, API_NUMBER; \
400 lv1call; \
401 \
402 addi r1, r1, 24; \
403 ld r11, -8(r1); \
404 std r4, 0(r11); \
405 ld r11, -16(r1); \
406 std r5, 0(r11); \
407 ld r11, -24(r1); \
408 std r6, 0(r11); \
409 \
410 ld r0, 16(r1); \
411 mtlr r0; \
412 blr
413
414#define LV1_2_IN_4_OUT(API_NAME, API_NUMBER) \
415_GLOBAL(_##API_NAME) \
416 \
417 mflr r0; \
418 std r0, 16(r1); \
419 \
420 std r5, -8(r1); \
421 std r6, -16(r1); \
422 std r7, -24(r1); \
423 stdu r8, -32(r1); \
424 \
425 li r11, API_NUMBER; \
426 lv1call; \
427 \
428 addi r1, r1, 32; \
429 ld r11, -8(r1); \
430 std r4, 0(r11); \
431 ld r11, -16(r1); \
432 std r5, 0(r11); \
433 ld r11, -24(r1); \
434 std r6, 0(r11); \
435 ld r11, -32(r1); \
436 std r7, 0(r11); \
437 \
438 ld r0, 16(r1); \
439 mtlr r0; \
440 blr
441
442#define LV1_2_IN_5_OUT(API_NAME, API_NUMBER) \
443_GLOBAL(_##API_NAME) \
444 \
445 mflr r0; \
446 std r0, 16(r1); \
447 \
448 std r5, -8(r1); \
449 std r6, -16(r1); \
450 std r7, -24(r1); \
451 std r8, -32(r1); \
452 stdu r9, -40(r1); \
453 \
454 li r11, API_NUMBER; \
455 lv1call; \
456 \
457 addi r1, r1, 40; \
458 ld r11, -8(r1); \
459 std r4, 0(r11); \
460 ld r11, -16(r1); \
461 std r5, 0(r11); \
462 ld r11, -24(r1); \
463 std r6, 0(r11); \
464 ld r11, -32(r1); \
465 std r7, 0(r11); \
466 ld r11, -40(r1); \
467 std r8, 0(r11); \
468 \
469 ld r0, 16(r1); \
470 mtlr r0; \
471 blr
472
473#define LV1_3_IN_1_OUT(API_NAME, API_NUMBER) \
474_GLOBAL(_##API_NAME) \
475 \
476 mflr r0; \
477 std r0, 16(r1); \
478 \
479 stdu r6, -8(r1); \
480 \
481 li r11, API_NUMBER; \
482 lv1call; \
483 \
484 addi r1, r1, 8; \
485 ld r11, -8(r1); \
486 std r4, 0(r11); \
487 \
488 ld r0, 16(r1); \
489 mtlr r0; \
490 blr
491
492#define LV1_3_IN_2_OUT(API_NAME, API_NUMBER) \
493_GLOBAL(_##API_NAME) \
494 \
495 mflr r0; \
496 std r0, 16(r1); \
497 \
498 std r6, -8(r1); \
499 stdu r7, -16(r1); \
500 \
501 li r11, API_NUMBER; \
502 lv1call; \
503 \
504 addi r1, r1, 16; \
505 ld r11, -8(r1); \
506 std r4, 0(r11); \
507 ld r11, -16(r1); \
508 std r5, 0(r11); \
509 \
510 ld r0, 16(r1); \
511 mtlr r0; \
512 blr
513
514#define LV1_3_IN_3_OUT(API_NAME, API_NUMBER) \
515_GLOBAL(_##API_NAME) \
516 \
517 mflr r0; \
518 std r0, 16(r1); \
519 \
520 std r6, -8(r1); \
521 std r7, -16(r1); \
522 stdu r8, -24(r1); \
523 \
524 li r11, API_NUMBER; \
525 lv1call; \
526 \
527 addi r1, r1, 24; \
528 ld r11, -8(r1); \
529 std r4, 0(r11); \
530 ld r11, -16(r1); \
531 std r5, 0(r11); \
532 ld r11, -24(r1); \
533 std r6, 0(r11); \
534 \
535 ld r0, 16(r1); \
536 mtlr r0; \
537 blr
538
539#define LV1_4_IN_1_OUT(API_NAME, API_NUMBER) \
540_GLOBAL(_##API_NAME) \
541 \
542 mflr r0; \
543 std r0, 16(r1); \
544 \
545 stdu r7, -8(r1); \
546 \
547 li r11, API_NUMBER; \
548 lv1call; \
549 \
550 addi r1, r1, 8; \
551 ld r11, -8(r1); \
552 std r4, 0(r11); \
553 \
554 ld r0, 16(r1); \
555 mtlr r0; \
556 blr
557
558#define LV1_4_IN_2_OUT(API_NAME, API_NUMBER) \
559_GLOBAL(_##API_NAME) \
560 \
561 mflr r0; \
562 std r0, 16(r1); \
563 \
564 std r7, -8(r1); \
565 stdu r8, -16(r1); \
566 \
567 li r11, API_NUMBER; \
568 lv1call; \
569 \
570 addi r1, r1, 16; \
571 ld r11, -8(r1); \
572 std r4, 0(r11); \
573 ld r11, -16(r1); \
574 std r5, 0(r11); \
575 \
576 ld r0, 16(r1); \
577 mtlr r0; \
578 blr
579
580#define LV1_4_IN_3_OUT(API_NAME, API_NUMBER) \
581_GLOBAL(_##API_NAME) \
582 \
583 mflr r0; \
584 std r0, 16(r1); \
585 \
586 std r7, -8(r1); \
587 std r8, -16(r1); \
588 stdu r9, -24(r1); \
589 \
590 li r11, API_NUMBER; \
591 lv1call; \
592 \
593 addi r1, r1, 24; \
594 ld r11, -8(r1); \
595 std r4, 0(r11); \
596 ld r11, -16(r1); \
597 std r5, 0(r11); \
598 ld r11, -24(r1); \
599 std r6, 0(r11); \
600 \
601 ld r0, 16(r1); \
602 mtlr r0; \
603 blr
604
605#define LV1_5_IN_1_OUT(API_NAME, API_NUMBER) \
606_GLOBAL(_##API_NAME) \
607 \
608 mflr r0; \
609 std r0, 16(r1); \
610 \
611 stdu r8, -8(r1); \
612 \
613 li r11, API_NUMBER; \
614 lv1call; \
615 \
616 addi r1, r1, 8; \
617 ld r11, -8(r1); \
618 std r4, 0(r11); \
619 \
620 ld r0, 16(r1); \
621 mtlr r0; \
622 blr
623
624#define LV1_5_IN_2_OUT(API_NAME, API_NUMBER) \
625_GLOBAL(_##API_NAME) \
626 \
627 mflr r0; \
628 std r0, 16(r1); \
629 \
630 std r8, -8(r1); \
631 stdu r9, -16(r1); \
632 \
633 li r11, API_NUMBER; \
634 lv1call; \
635 \
636 addi r1, r1, 16; \
637 ld r11, -8(r1); \
638 std r4, 0(r11); \
639 ld r11, -16(r1); \
640 std r5, 0(r11); \
641 \
642 ld r0, 16(r1); \
643 mtlr r0; \
644 blr
645
646#define LV1_5_IN_3_OUT(API_NAME, API_NUMBER) \
647_GLOBAL(_##API_NAME) \
648 \
649 mflr r0; \
650 std r0, 16(r1); \
651 \
652 std r8, -8(r1); \
653 std r9, -16(r1); \
654 stdu r10, -24(r1); \
655 \
656 li r11, API_NUMBER; \
657 lv1call; \
658 \
659 addi r1, r1, 24; \
660 ld r11, -8(r1); \
661 std r4, 0(r11); \
662 ld r11, -16(r1); \
663 std r5, 0(r11); \
664 ld r11, -24(r1); \
665 std r6, 0(r11); \
666 \
667 ld r0, 16(r1); \
668 mtlr r0; \
669 blr
670
671#define LV1_6_IN_1_OUT(API_NAME, API_NUMBER) \
672_GLOBAL(_##API_NAME) \
673 \
674 mflr r0; \
675 std r0, 16(r1); \
676 \
677 stdu r9, -8(r1); \
678 \
679 li r11, API_NUMBER; \
680 lv1call; \
681 \
682 addi r1, r1, 8; \
683 ld r11, -8(r1); \
684 std r4, 0(r11); \
685 \
686 ld r0, 16(r1); \
687 mtlr r0; \
688 blr
689
690#define LV1_6_IN_2_OUT(API_NAME, API_NUMBER) \
691_GLOBAL(_##API_NAME) \
692 \
693 mflr r0; \
694 std r0, 16(r1); \
695 \
696 std r9, -8(r1); \
697 stdu r10, -16(r1); \
698 \
699 li r11, API_NUMBER; \
700 lv1call; \
701 \
702 addi r1, r1, 16; \
703 ld r11, -8(r1); \
704 std r4, 0(r11); \
705 ld r11, -16(r1); \
706 std r5, 0(r11); \
707 \
708 ld r0, 16(r1); \
709 mtlr r0; \
710 blr
711
712#define LV1_6_IN_3_OUT(API_NAME, API_NUMBER) \
713_GLOBAL(_##API_NAME) \
714 \
715 mflr r0; \
716 std r0, 16(r1); \
717 \
718 std r9, -8(r1); \
719 stdu r10, -16(r1); \
720 \
721 li r11, API_NUMBER; \
722 lv1call; \
723 \
724 addi r1, r1, 16; \
725 ld r11, -8(r1); \
726 std r4, 0(r11); \
727 ld r11, -16(r1); \
728 std r5, 0(r11); \
729 ld r11, 48+8*8(r1); \
730 std r6, 0(r11); \
731 \
732 ld r0, 16(r1); \
733 mtlr r0; \
734 blr
735
736#define LV1_7_IN_1_OUT(API_NAME, API_NUMBER) \
737_GLOBAL(_##API_NAME) \
738 \
739 mflr r0; \
740 std r0, 16(r1); \
741 \
742 stdu r10, -8(r1); \
743 \
744 li r11, API_NUMBER; \
745 lv1call; \
746 \
747 addi r1, r1, 8; \
748 ld r11, -8(r1); \
749 std r4, 0(r11); \
750 \
751 ld r0, 16(r1); \
752 mtlr r0; \
753 blr
754
755#define LV1_7_IN_6_OUT(API_NAME, API_NUMBER) \
756_GLOBAL(_##API_NAME) \
757 \
758 mflr r0; \
759 std r0, 16(r1); \
760 \
761 std r10, 48+8*7(r1); \
762 \
763 li r11, API_NUMBER; \
764 lv1call; \
765 \
766 ld r11, 48+8*7(r1); \
767 std r4, 0(r11); \
768 ld r11, 48+8*8(r1); \
769 std r5, 0(r11); \
770 ld r11, 48+8*9(r1); \
771 std r6, 0(r11); \
772 ld r11, 48+8*10(r1); \
773 std r7, 0(r11); \
774 ld r11, 48+8*11(r1); \
775 std r8, 0(r11); \
776 ld r11, 48+8*12(r1); \
777 std r9, 0(r11); \
778 \
779 ld r0, 16(r1); \
780 mtlr r0; \
781 blr
782
783#define LV1_8_IN_1_OUT(API_NAME, API_NUMBER) \
784_GLOBAL(_##API_NAME) \
785 \
786 mflr r0; \
787 std r0, 16(r1); \
788 \
789 li r11, API_NUMBER; \
790 lv1call; \
791 \
792 ld r11, 48+8*8(r1); \
793 std r4, 0(r11); \
794 \
795 ld r0, 16(r1); \
796 mtlr r0; \
797 blr
798
799 .text
800
801/* the lv1 underscored call definitions expand here */
802
803#define LV1_CALL(name, in, out, num) LV1_##in##_IN_##out##_OUT(lv1_##name, num)
804#include <asm/lv1call.h>
diff --git a/arch/powerpc/platforms/ps3/interrupt.c b/arch/powerpc/platforms/ps3/interrupt.c
new file mode 100644
index 000000000000..056c1e4141ba
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/interrupt.c
@@ -0,0 +1,575 @@
1/*
2 * PS3 interrupt routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/irq.h>
24
25#include <asm/machdep.h>
26#include <asm/udbg.h>
27#include <asm/ps3.h>
28#include <asm/lv1call.h>
29
30#include "platform.h"
31
32#if defined(DEBUG)
33#define DBG(fmt...) udbg_printf(fmt)
34#else
35#define DBG(fmt...) do{if(0)printk(fmt);}while(0)
36#endif
37
38/**
39 * ps3_alloc_io_irq - Assign a virq to a system bus device.
40 * interrupt_id: The device interrupt id read from the system repository.
41 * @virq: The assigned Linux virq.
42 *
43 * An io irq represents a non-virtualized device interrupt. interrupt_id
44 * coresponds to the interrupt number of the interrupt controller.
45 */
46
47int ps3_alloc_io_irq(unsigned int interrupt_id, unsigned int *virq)
48{
49 int result;
50 unsigned long outlet;
51
52 result = lv1_construct_io_irq_outlet(interrupt_id, &outlet);
53
54 if (result) {
55 pr_debug("%s:%d: lv1_construct_io_irq_outlet failed: %s\n",
56 __func__, __LINE__, ps3_result(result));
57 return result;
58 }
59
60 *virq = irq_create_mapping(NULL, outlet);
61
62 pr_debug("%s:%d: interrupt_id %u => outlet %lu, virq %u\n",
63 __func__, __LINE__, interrupt_id, outlet, *virq);
64
65 return 0;
66}
67
68int ps3_free_io_irq(unsigned int virq)
69{
70 int result;
71
72 result = lv1_destruct_io_irq_outlet(virq_to_hw(virq));
73
74 if (!result)
75 pr_debug("%s:%d: lv1_destruct_io_irq_outlet failed: %s\n",
76 __func__, __LINE__, ps3_result(result));
77
78 irq_dispose_mapping(virq);
79
80 return result;
81}
82
83/**
84 * ps3_alloc_event_irq - Allocate a virq for use with a system event.
85 * @virq: The assigned Linux virq.
86 *
87 * The virq can be used with lv1_connect_interrupt_event_receive_port() to
88 * arrange to receive events, or with ps3_send_event_locally() to signal
89 * events.
90 */
91
92int ps3_alloc_event_irq(unsigned int *virq)
93{
94 int result;
95 unsigned long outlet;
96
97 result = lv1_construct_event_receive_port(&outlet);
98
99 if (result) {
100 pr_debug("%s:%d: lv1_construct_event_receive_port failed: %s\n",
101 __func__, __LINE__, ps3_result(result));
102 *virq = NO_IRQ;
103 return result;
104 }
105
106 *virq = irq_create_mapping(NULL, outlet);
107
108 pr_debug("%s:%d: outlet %lu, virq %u\n", __func__, __LINE__, outlet,
109 *virq);
110
111 return 0;
112}
113
114int ps3_free_event_irq(unsigned int virq)
115{
116 int result;
117
118 pr_debug(" -> %s:%d\n", __func__, __LINE__);
119
120 result = lv1_destruct_event_receive_port(virq_to_hw(virq));
121
122 if (result)
123 pr_debug("%s:%d: lv1_destruct_event_receive_port failed: %s\n",
124 __func__, __LINE__, ps3_result(result));
125
126 irq_dispose_mapping(virq);
127
128 pr_debug(" <- %s:%d\n", __func__, __LINE__);
129 return result;
130}
131
132int ps3_send_event_locally(unsigned int virq)
133{
134 return lv1_send_event_locally(virq_to_hw(virq));
135}
136
137/**
138 * ps3_connect_event_irq - Assign a virq to a system bus device.
139 * @did: The HV device identifier read from the system repository.
140 * @interrupt_id: The device interrupt id read from the system repository.
141 * @virq: The assigned Linux virq.
142 *
143 * An event irq represents a virtual device interrupt. The interrupt_id
144 * coresponds to the software interrupt number.
145 */
146
147int ps3_connect_event_irq(const struct ps3_device_id *did,
148 unsigned int interrupt_id, unsigned int *virq)
149{
150 int result;
151
152 result = ps3_alloc_event_irq(virq);
153
154 if (result)
155 return result;
156
157 result = lv1_connect_interrupt_event_receive_port(did->bus_id,
158 did->dev_id, virq_to_hw(*virq), interrupt_id);
159
160 if (result) {
161 pr_debug("%s:%d: lv1_connect_interrupt_event_receive_port"
162 " failed: %s\n", __func__, __LINE__,
163 ps3_result(result));
164 ps3_free_event_irq(*virq);
165 *virq = NO_IRQ;
166 return result;
167 }
168
169 pr_debug("%s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__,
170 interrupt_id, *virq);
171
172 return 0;
173}
174
175int ps3_disconnect_event_irq(const struct ps3_device_id *did,
176 unsigned int interrupt_id, unsigned int virq)
177{
178 int result;
179
180 pr_debug(" -> %s:%d: interrupt_id %u, virq %u\n", __func__, __LINE__,
181 interrupt_id, virq);
182
183 result = lv1_disconnect_interrupt_event_receive_port(did->bus_id,
184 did->dev_id, virq_to_hw(virq), interrupt_id);
185
186 if (result)
187 pr_debug("%s:%d: lv1_disconnect_interrupt_event_receive_port"
188 " failed: %s\n", __func__, __LINE__,
189 ps3_result(result));
190
191 ps3_free_event_irq(virq);
192
193 pr_debug(" <- %s:%d\n", __func__, __LINE__);
194 return result;
195}
196
197/**
198 * ps3_alloc_vuart_irq - Configure the system virtual uart virq.
199 * @virt_addr_bmp: The caller supplied virtual uart interrupt bitmap.
200 * @virq: The assigned Linux virq.
201 *
202 * The system supports only a single virtual uart, so multiple calls without
203 * freeing the interrupt will return a wrong state error.
204 */
205
206int ps3_alloc_vuart_irq(void* virt_addr_bmp, unsigned int *virq)
207{
208 int result;
209 unsigned long outlet;
210 unsigned long lpar_addr;
211
212 BUG_ON(!is_kernel_addr((unsigned long)virt_addr_bmp));
213
214 lpar_addr = ps3_mm_phys_to_lpar(__pa(virt_addr_bmp));
215
216 result = lv1_configure_virtual_uart_irq(lpar_addr, &outlet);
217
218 if (result) {
219 pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n",
220 __func__, __LINE__, ps3_result(result));
221 return result;
222 }
223
224 *virq = irq_create_mapping(NULL, outlet);
225
226 pr_debug("%s:%d: outlet %lu, virq %u\n", __func__, __LINE__,
227 outlet, *virq);
228
229 return 0;
230}
231
232int ps3_free_vuart_irq(unsigned int virq)
233{
234 int result;
235
236 result = lv1_deconfigure_virtual_uart_irq();
237
238 if (result) {
239 pr_debug("%s:%d: lv1_configure_virtual_uart_irq failed: %s\n",
240 __func__, __LINE__, ps3_result(result));
241 return result;
242 }
243
244 irq_dispose_mapping(virq);
245
246 return result;
247}
248
249/**
250 * ps3_alloc_spe_irq - Configure an spe virq.
251 * @spe_id: The spe_id returned from lv1_construct_logical_spe().
252 * @class: The spe interrupt class {0,1,2}.
253 * @virq: The assigned Linux virq.
254 *
255 */
256
257int ps3_alloc_spe_irq(unsigned long spe_id, unsigned int class,
258 unsigned int *virq)
259{
260 int result;
261 unsigned long outlet;
262
263 BUG_ON(class > 2);
264
265 result = lv1_get_spe_irq_outlet(spe_id, class, &outlet);
266
267 if (result) {
268 pr_debug("%s:%d: lv1_get_spe_irq_outlet failed: %s\n",
269 __func__, __LINE__, ps3_result(result));
270 return result;
271 }
272
273 *virq = irq_create_mapping(NULL, outlet);
274
275 pr_debug("%s:%d: spe_id %lu, class %u, outlet %lu, virq %u\n",
276 __func__, __LINE__, spe_id, class, outlet, *virq);
277
278 return 0;
279}
280
281int ps3_free_spe_irq(unsigned int virq)
282{
283 irq_dispose_mapping(virq);
284 return 0;
285}
286
287#define PS3_INVALID_OUTLET ((irq_hw_number_t)-1)
288#define PS3_PLUG_MAX 63
289
290/**
291 * struct bmp - a per cpu irq status and mask bitmap structure
292 * @status: 256 bit status bitmap indexed by plug
293 * @unused_1:
294 * @mask: 256 bit mask bitmap indexed by plug
295 * @unused_2:
296 * @lock:
297 * @ipi_debug_brk_mask:
298 *
299 * The HV mantains per SMT thread mappings of HV outlet to HV plug on
300 * behalf of the guest. These mappings are implemented as 256 bit guest
301 * supplied bitmaps indexed by plug number. The address of the bitmaps are
302 * registered with the HV through lv1_configure_irq_state_bitmap().
303 *
304 * The HV supports 256 plugs per thread, assigned as {0..255}, for a total
305 * of 512 plugs supported on a processor. To simplify the logic this
306 * implementation equates HV plug value to linux virq value, constrains each
307 * interrupt to have a system wide unique plug number, and limits the range
308 * of the plug values to map into the first dword of the bitmaps. This
309 * gives a usable range of plug values of {NUM_ISA_INTERRUPTS..63}. Note
310 * that there is no constraint on how many in this set an individual thread
311 * can aquire.
312 */
313
314struct bmp {
315 struct {
316 unsigned long status;
317 unsigned long unused_1[3];
318 unsigned long mask;
319 unsigned long unused_2[3];
320 } __attribute__ ((packed));
321 spinlock_t lock;
322 unsigned long ipi_debug_brk_mask;
323};
324
325/**
326 * struct private - a per cpu data structure
327 * @node: HV node id
328 * @cpu: HV thread id
329 * @bmp: an HV bmp structure
330 */
331
332struct private {
333 unsigned long node;
334 unsigned int cpu;
335 struct bmp bmp;
336};
337
338#if defined(DEBUG)
339static void _dump_64_bmp(const char *header, const unsigned long *p, unsigned cpu,
340 const char* func, int line)
341{
342 pr_debug("%s:%d: %s %u {%04lx_%04lx_%04lx_%04lx}\n",
343 func, line, header, cpu,
344 *p >> 48, (*p >> 32) & 0xffff, (*p >> 16) & 0xffff,
345 *p & 0xffff);
346}
347
348static void __attribute__ ((unused)) _dump_256_bmp(const char *header,
349 const unsigned long *p, unsigned cpu, const char* func, int line)
350{
351 pr_debug("%s:%d: %s %u {%016lx:%016lx:%016lx:%016lx}\n",
352 func, line, header, cpu, p[0], p[1], p[2], p[3]);
353}
354
355#define dump_bmp(_x) _dump_bmp(_x, __func__, __LINE__)
356static void _dump_bmp(struct private* pd, const char* func, int line)
357{
358 unsigned long flags;
359
360 spin_lock_irqsave(&pd->bmp.lock, flags);
361 _dump_64_bmp("stat", &pd->bmp.status, pd->cpu, func, line);
362 _dump_64_bmp("mask", &pd->bmp.mask, pd->cpu, func, line);
363 spin_unlock_irqrestore(&pd->bmp.lock, flags);
364}
365
366#define dump_mask(_x) _dump_mask(_x, __func__, __LINE__)
367static void __attribute__ ((unused)) _dump_mask(struct private* pd,
368 const char* func, int line)
369{
370 unsigned long flags;
371
372 spin_lock_irqsave(&pd->bmp.lock, flags);
373 _dump_64_bmp("mask", &pd->bmp.mask, pd->cpu, func, line);
374 spin_unlock_irqrestore(&pd->bmp.lock, flags);
375}
376#else
377static void dump_bmp(struct private* pd) {};
378#endif /* defined(DEBUG) */
379
380static void chip_mask(unsigned int virq)
381{
382 unsigned long flags;
383 struct private *pd = get_irq_chip_data(virq);
384
385 pr_debug("%s:%d: cpu %u, virq %d\n", __func__, __LINE__, pd->cpu, virq);
386
387 BUG_ON(virq < NUM_ISA_INTERRUPTS);
388 BUG_ON(virq > PS3_PLUG_MAX);
389
390 spin_lock_irqsave(&pd->bmp.lock, flags);
391 pd->bmp.mask &= ~(0x8000000000000000UL >> virq);
392 spin_unlock_irqrestore(&pd->bmp.lock, flags);
393
394 lv1_did_update_interrupt_mask(pd->node, pd->cpu);
395}
396
397static void chip_unmask(unsigned int virq)
398{
399 unsigned long flags;
400 struct private *pd = get_irq_chip_data(virq);
401
402 pr_debug("%s:%d: cpu %u, virq %d\n", __func__, __LINE__, pd->cpu, virq);
403
404 BUG_ON(virq < NUM_ISA_INTERRUPTS);
405 BUG_ON(virq > PS3_PLUG_MAX);
406
407 spin_lock_irqsave(&pd->bmp.lock, flags);
408 pd->bmp.mask |= (0x8000000000000000UL >> virq);
409 spin_unlock_irqrestore(&pd->bmp.lock, flags);
410
411 lv1_did_update_interrupt_mask(pd->node, pd->cpu);
412}
413
414static void chip_eoi(unsigned int virq)
415{
416 lv1_end_of_interrupt(virq);
417}
418
419static struct irq_chip irq_chip = {
420 .typename = "ps3",
421 .mask = chip_mask,
422 .unmask = chip_unmask,
423 .eoi = chip_eoi,
424};
425
426static void host_unmap(struct irq_host *h, unsigned int virq)
427{
428 int result;
429
430 pr_debug("%s:%d: virq %d\n", __func__, __LINE__, virq);
431
432 lv1_disconnect_irq_plug(virq);
433
434 result = set_irq_chip_data(virq, NULL);
435 BUG_ON(result);
436}
437
438static DEFINE_PER_CPU(struct private, private);
439
440static int host_map(struct irq_host *h, unsigned int virq,
441 irq_hw_number_t hwirq)
442{
443 int result;
444 unsigned int cpu;
445
446 pr_debug(" -> %s:%d\n", __func__, __LINE__);
447 pr_debug("%s:%d: hwirq %lu => virq %u\n", __func__, __LINE__, hwirq,
448 virq);
449
450 /* bind this virq to a cpu */
451
452 preempt_disable();
453 cpu = smp_processor_id();
454 result = lv1_connect_irq_plug(virq, hwirq);
455 preempt_enable();
456
457 if (result) {
458 pr_info("%s:%d: lv1_connect_irq_plug failed:"
459 " %s\n", __func__, __LINE__, ps3_result(result));
460 return -EPERM;
461 }
462
463 result = set_irq_chip_data(virq, &per_cpu(private, cpu));
464 BUG_ON(result);
465
466 set_irq_chip_and_handler(virq, &irq_chip, handle_fasteoi_irq);
467
468 pr_debug(" <- %s:%d\n", __func__, __LINE__);
469 return result;
470}
471
472static struct irq_host_ops host_ops = {
473 .map = host_map,
474 .unmap = host_unmap,
475};
476
477void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq)
478{
479 struct private *pd = &per_cpu(private, cpu);
480
481 pd->bmp.ipi_debug_brk_mask = 0x8000000000000000UL >> virq;
482
483 pr_debug("%s:%d: cpu %u, virq %u, mask %lxh\n", __func__, __LINE__,
484 cpu, virq, pd->bmp.ipi_debug_brk_mask);
485}
486
487static int bmp_get_and_clear_status_bit(struct bmp *m)
488{
489 unsigned long flags;
490 unsigned int bit;
491 unsigned long x;
492
493 spin_lock_irqsave(&m->lock, flags);
494
495 /* check for ipi break first to stop this cpu ASAP */
496
497 if (m->status & m->ipi_debug_brk_mask) {
498 m->status &= ~m->ipi_debug_brk_mask;
499 spin_unlock_irqrestore(&m->lock, flags);
500 return __ilog2(m->ipi_debug_brk_mask);
501 }
502
503 x = (m->status & m->mask);
504
505 for (bit = NUM_ISA_INTERRUPTS, x <<= bit; x; bit++, x <<= 1)
506 if (x & 0x8000000000000000UL) {
507 m->status &= ~(0x8000000000000000UL >> bit);
508 spin_unlock_irqrestore(&m->lock, flags);
509 return bit;
510 }
511
512 spin_unlock_irqrestore(&m->lock, flags);
513
514 pr_debug("%s:%d: not found\n", __func__, __LINE__);
515 return -1;
516}
517
518unsigned int ps3_get_irq(void)
519{
520 int plug;
521
522 struct private *pd = &__get_cpu_var(private);
523
524 plug = bmp_get_and_clear_status_bit(&pd->bmp);
525
526 if (plug < 1) {
527 pr_debug("%s:%d: no plug found: cpu %u\n", __func__, __LINE__,
528 pd->cpu);
529 dump_bmp(&per_cpu(private, 0));
530 dump_bmp(&per_cpu(private, 1));
531 return NO_IRQ;
532 }
533
534#if defined(DEBUG)
535 if (plug < NUM_ISA_INTERRUPTS || plug > PS3_PLUG_MAX) {
536 dump_bmp(&per_cpu(private, 0));
537 dump_bmp(&per_cpu(private, 1));
538 BUG();
539 }
540#endif
541 return plug;
542}
543
544void __init ps3_init_IRQ(void)
545{
546 int result;
547 unsigned long node;
548 unsigned cpu;
549 struct irq_host *host;
550
551 lv1_get_logical_ppe_id(&node);
552
553 host = irq_alloc_host(IRQ_HOST_MAP_NOMAP, 0, &host_ops,
554 PS3_INVALID_OUTLET);
555 irq_set_default_host(host);
556 irq_set_virq_count(PS3_PLUG_MAX + 1);
557
558 for_each_possible_cpu(cpu) {
559 struct private *pd = &per_cpu(private, cpu);
560
561 pd->node = node;
562 pd->cpu = cpu;
563 spin_lock_init(&pd->bmp.lock);
564
565 result = lv1_configure_irq_state_bitmap(node, cpu,
566 ps3_mm_phys_to_lpar(__pa(&pd->bmp.status)));
567
568 if (result)
569 pr_debug("%s:%d: lv1_configure_irq_state_bitmap failed:"
570 " %s\n", __func__, __LINE__,
571 ps3_result(result));
572 }
573
574 ppc_md.get_irq = ps3_get_irq;
575}
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
new file mode 100644
index 000000000000..49c0d010d491
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -0,0 +1,831 @@
1/*
2 * PS3 address space management.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/memory_hotplug.h>
24
25#include <asm/firmware.h>
26#include <asm/lmb.h>
27#include <asm/udbg.h>
28#include <asm/ps3.h>
29#include <asm/lv1call.h>
30
31#include "platform.h"
32
33#if defined(DEBUG)
34#define DBG(fmt...) udbg_printf(fmt)
35#else
36#define DBG(fmt...) do{if(0)printk(fmt);}while(0)
37#endif
38
39enum {
40#if defined(CONFIG_PS3_USE_LPAR_ADDR)
41 USE_LPAR_ADDR = 1,
42#else
43 USE_LPAR_ADDR = 0,
44#endif
45#if defined(CONFIG_PS3_DYNAMIC_DMA)
46 USE_DYNAMIC_DMA = 1,
47#else
48 USE_DYNAMIC_DMA = 0,
49#endif
50};
51
52enum {
53 PAGE_SHIFT_4K = 12U,
54 PAGE_SHIFT_64K = 16U,
55 PAGE_SHIFT_16M = 24U,
56};
57
58static unsigned long make_page_sizes(unsigned long a, unsigned long b)
59{
60 return (a << 56) | (b << 48);
61}
62
63enum {
64 ALLOCATE_MEMORY_TRY_ALT_UNIT = 0X04,
65 ALLOCATE_MEMORY_ADDR_ZERO = 0X08,
66};
67
68/* valid htab sizes are {18,19,20} = 256K, 512K, 1M */
69
70enum {
71 HTAB_SIZE_MAX = 20U, /* HV limit of 1MB */
72 HTAB_SIZE_MIN = 18U, /* CPU limit of 256KB */
73};
74
75/*============================================================================*/
76/* virtual address space routines */
77/*============================================================================*/
78
79/**
80 * struct mem_region - memory region structure
81 * @base: base address
82 * @size: size in bytes
83 * @offset: difference between base and rm.size
84 */
85
86struct mem_region {
87 unsigned long base;
88 unsigned long size;
89 unsigned long offset;
90};
91
92/**
93 * struct map - address space state variables holder
94 * @total: total memory available as reported by HV
95 * @vas_id - HV virtual address space id
96 * @htab_size: htab size in bytes
97 *
98 * The HV virtual address space (vas) allows for hotplug memory regions.
99 * Memory regions can be created and destroyed in the vas at runtime.
100 * @rm: real mode (bootmem) region
101 * @r1: hotplug memory region(s)
102 *
103 * ps3 addresses
104 * virt_addr: a cpu 'translated' effective address
105 * phys_addr: an address in what Linux thinks is the physical address space
106 * lpar_addr: an address in the HV virtual address space
107 * bus_addr: an io controller 'translated' address on a device bus
108 */
109
110struct map {
111 unsigned long total;
112 unsigned long vas_id;
113 unsigned long htab_size;
114 struct mem_region rm;
115 struct mem_region r1;
116};
117
118#define debug_dump_map(x) _debug_dump_map(x, __func__, __LINE__)
119static void _debug_dump_map(const struct map* m, const char* func, int line)
120{
121 DBG("%s:%d: map.total = %lxh\n", func, line, m->total);
122 DBG("%s:%d: map.rm.size = %lxh\n", func, line, m->rm.size);
123 DBG("%s:%d: map.vas_id = %lu\n", func, line, m->vas_id);
124 DBG("%s:%d: map.htab_size = %lxh\n", func, line, m->htab_size);
125 DBG("%s:%d: map.r1.base = %lxh\n", func, line, m->r1.base);
126 DBG("%s:%d: map.r1.offset = %lxh\n", func, line, m->r1.offset);
127 DBG("%s:%d: map.r1.size = %lxh\n", func, line, m->r1.size);
128}
129
130static struct map map;
131
132/**
133 * ps3_mm_phys_to_lpar - translate a linux physical address to lpar address
134 * @phys_addr: linux physical address
135 */
136
137unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr)
138{
139 BUG_ON(is_kernel_addr(phys_addr));
140 if (USE_LPAR_ADDR)
141 return phys_addr;
142 else
143 return (phys_addr < map.rm.size || phys_addr >= map.total)
144 ? phys_addr : phys_addr + map.r1.offset;
145}
146
147EXPORT_SYMBOL(ps3_mm_phys_to_lpar);
148
149/**
150 * ps3_mm_vas_create - create the virtual address space
151 */
152
153void __init ps3_mm_vas_create(unsigned long* htab_size)
154{
155 int result;
156 unsigned long start_address;
157 unsigned long size;
158 unsigned long access_right;
159 unsigned long max_page_size;
160 unsigned long flags;
161
162 result = lv1_query_logical_partition_address_region_info(0,
163 &start_address, &size, &access_right, &max_page_size,
164 &flags);
165
166 if (result) {
167 DBG("%s:%d: lv1_query_logical_partition_address_region_info "
168 "failed: %s\n", __func__, __LINE__,
169 ps3_result(result));
170 goto fail;
171 }
172
173 if (max_page_size < PAGE_SHIFT_16M) {
174 DBG("%s:%d: bad max_page_size %lxh\n", __func__, __LINE__,
175 max_page_size);
176 goto fail;
177 }
178
179 BUILD_BUG_ON(CONFIG_PS3_HTAB_SIZE > HTAB_SIZE_MAX);
180 BUILD_BUG_ON(CONFIG_PS3_HTAB_SIZE < HTAB_SIZE_MIN);
181
182 result = lv1_construct_virtual_address_space(CONFIG_PS3_HTAB_SIZE,
183 2, make_page_sizes(PAGE_SHIFT_16M, PAGE_SHIFT_64K),
184 &map.vas_id, &map.htab_size);
185
186 if (result) {
187 DBG("%s:%d: lv1_construct_virtual_address_space failed: %s\n",
188 __func__, __LINE__, ps3_result(result));
189 goto fail;
190 }
191
192 result = lv1_select_virtual_address_space(map.vas_id);
193
194 if (result) {
195 DBG("%s:%d: lv1_select_virtual_address_space failed: %s\n",
196 __func__, __LINE__, ps3_result(result));
197 goto fail;
198 }
199
200 *htab_size = map.htab_size;
201
202 debug_dump_map(&map);
203
204 return;
205
206fail:
207 panic("ps3_mm_vas_create failed");
208}
209
210/**
211 * ps3_mm_vas_destroy -
212 */
213
214void ps3_mm_vas_destroy(void)
215{
216 if (map.vas_id) {
217 lv1_select_virtual_address_space(0);
218 lv1_destruct_virtual_address_space(map.vas_id);
219 map.vas_id = 0;
220 }
221}
222
223/*============================================================================*/
224/* memory hotplug routines */
225/*============================================================================*/
226
227/**
228 * ps3_mm_region_create - create a memory region in the vas
229 * @r: pointer to a struct mem_region to accept initialized values
230 * @size: requested region size
231 *
232 * This implementation creates the region with the vas large page size.
233 * @size is rounded down to a multiple of the vas large page size.
234 */
235
236int ps3_mm_region_create(struct mem_region *r, unsigned long size)
237{
238 int result;
239 unsigned long muid;
240
241 r->size = _ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M);
242
243 DBG("%s:%d requested %lxh\n", __func__, __LINE__, size);
244 DBG("%s:%d actual %lxh\n", __func__, __LINE__, r->size);
245 DBG("%s:%d difference %lxh (%luMB)\n", __func__, __LINE__,
246 (unsigned long)(size - r->size),
247 (size - r->size) / 1024 / 1024);
248
249 if (r->size == 0) {
250 DBG("%s:%d: size == 0\n", __func__, __LINE__);
251 result = -1;
252 goto zero_region;
253 }
254
255 result = lv1_allocate_memory(r->size, PAGE_SHIFT_16M, 0,
256 ALLOCATE_MEMORY_TRY_ALT_UNIT, &r->base, &muid);
257
258 if (result || r->base < map.rm.size) {
259 DBG("%s:%d: lv1_allocate_memory failed: %s\n",
260 __func__, __LINE__, ps3_result(result));
261 goto zero_region;
262 }
263
264 r->offset = r->base - map.rm.size;
265 return result;
266
267zero_region:
268 r->size = r->base = r->offset = 0;
269 return result;
270}
271
272/**
273 * ps3_mm_region_destroy - destroy a memory region
274 * @r: pointer to struct mem_region
275 */
276
277void ps3_mm_region_destroy(struct mem_region *r)
278{
279 if (r->base) {
280 lv1_release_memory(r->base);
281 r->size = r->base = r->offset = 0;
282 map.total = map.rm.size;
283 }
284}
285
286/**
287 * ps3_mm_add_memory - hot add memory
288 */
289
290static int __init ps3_mm_add_memory(void)
291{
292 int result;
293 unsigned long start_addr;
294 unsigned long start_pfn;
295 unsigned long nr_pages;
296
297 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
298 return 0;
299
300 BUG_ON(!mem_init_done);
301
302 start_addr = USE_LPAR_ADDR ? map.r1.base : map.rm.size;
303 start_pfn = start_addr >> PAGE_SHIFT;
304 nr_pages = (map.r1.size + PAGE_SIZE - 1) >> PAGE_SHIFT;
305
306 DBG("%s:%d: start_addr %lxh, start_pfn %lxh, nr_pages %lxh\n",
307 __func__, __LINE__, start_addr, start_pfn, nr_pages);
308
309 result = add_memory(0, start_addr, map.r1.size);
310
311 if (result) {
312 DBG("%s:%d: add_memory failed: (%d)\n",
313 __func__, __LINE__, result);
314 return result;
315 }
316
317 result = online_pages(start_pfn, nr_pages);
318
319 if (result)
320 DBG("%s:%d: online_pages failed: (%d)\n",
321 __func__, __LINE__, result);
322
323 return result;
324}
325
326core_initcall(ps3_mm_add_memory);
327
328/*============================================================================*/
329/* dma routines */
330/*============================================================================*/
331
332/**
333 * dma_lpar_to_bus - Translate an lpar address to ioc mapped bus address.
334 * @r: pointer to dma region structure
335 * @lpar_addr: HV lpar address
336 */
337
338static unsigned long dma_lpar_to_bus(struct ps3_dma_region *r,
339 unsigned long lpar_addr)
340{
341 BUG_ON(lpar_addr >= map.r1.base + map.r1.size);
342 return r->bus_addr + (lpar_addr <= map.rm.size ? lpar_addr
343 : lpar_addr - map.r1.offset);
344}
345
346#define dma_dump_region(_a) _dma_dump_region(_a, __func__, __LINE__)
347static void _dma_dump_region(const struct ps3_dma_region *r, const char* func,
348 int line)
349{
350 DBG("%s:%d: dev %u:%u\n", func, line, r->did.bus_id,
351 r->did.dev_id);
352 DBG("%s:%d: page_size %u\n", func, line, r->page_size);
353 DBG("%s:%d: bus_addr %lxh\n", func, line, r->bus_addr);
354 DBG("%s:%d: len %lxh\n", func, line, r->len);
355}
356
357/**
358 * dma_chunk - A chunk of dma pages mapped by the io controller.
359 * @region - The dma region that owns this chunk.
360 * @lpar_addr: Starting lpar address of the area to map.
361 * @bus_addr: Starting ioc bus address of the area to map.
362 * @len: Length in bytes of the area to map.
363 * @link: A struct list_head used with struct ps3_dma_region.chunk_list, the
364 * list of all chuncks owned by the region.
365 *
366 * This implementation uses a very simple dma page manager
367 * based on the dma_chunk structure. This scheme assumes
368 * that all drivers use very well behaved dma ops.
369 */
370
371struct dma_chunk {
372 struct ps3_dma_region *region;
373 unsigned long lpar_addr;
374 unsigned long bus_addr;
375 unsigned long len;
376 struct list_head link;
377 unsigned int usage_count;
378};
379
380#define dma_dump_chunk(_a) _dma_dump_chunk(_a, __func__, __LINE__)
381static void _dma_dump_chunk (const struct dma_chunk* c, const char* func,
382 int line)
383{
384 DBG("%s:%d: r.dev %u:%u\n", func, line,
385 c->region->did.bus_id, c->region->did.dev_id);
386 DBG("%s:%d: r.bus_addr %lxh\n", func, line, c->region->bus_addr);
387 DBG("%s:%d: r.page_size %u\n", func, line, c->region->page_size);
388 DBG("%s:%d: r.len %lxh\n", func, line, c->region->len);
389 DBG("%s:%d: c.lpar_addr %lxh\n", func, line, c->lpar_addr);
390 DBG("%s:%d: c.bus_addr %lxh\n", func, line, c->bus_addr);
391 DBG("%s:%d: c.len %lxh\n", func, line, c->len);
392}
393
394static struct dma_chunk * dma_find_chunk(struct ps3_dma_region *r,
395 unsigned long bus_addr, unsigned long len)
396{
397 struct dma_chunk *c;
398 unsigned long aligned_bus = _ALIGN_DOWN(bus_addr, 1 << r->page_size);
399 unsigned long aligned_len = _ALIGN_UP(len, 1 << r->page_size);
400
401 list_for_each_entry(c, &r->chunk_list.head, link) {
402 /* intersection */
403 if (aligned_bus >= c->bus_addr
404 && aligned_bus < c->bus_addr + c->len
405 && aligned_bus + aligned_len <= c->bus_addr + c->len) {
406 return c;
407 }
408 /* below */
409 if (aligned_bus + aligned_len <= c->bus_addr) {
410 continue;
411 }
412 /* above */
413 if (aligned_bus >= c->bus_addr + c->len) {
414 continue;
415 }
416
417 /* we don't handle the multi-chunk case for now */
418
419 dma_dump_chunk(c);
420 BUG();
421 }
422 return NULL;
423}
424
425static int dma_free_chunk(struct dma_chunk *c)
426{
427 int result = 0;
428
429 if (c->bus_addr) {
430 result = lv1_unmap_device_dma_region(c->region->did.bus_id,
431 c->region->did.dev_id, c->bus_addr, c->len);
432 BUG_ON(result);
433 }
434
435 kfree(c);
436 return result;
437}
438
439/**
440 * dma_map_pages - Maps dma pages into the io controller bus address space.
441 * @r: Pointer to a struct ps3_dma_region.
442 * @phys_addr: Starting physical address of the area to map.
443 * @len: Length in bytes of the area to map.
444 * c_out: A pointer to receive an allocated struct dma_chunk for this area.
445 *
446 * This is the lowest level dma mapping routine, and is the one that will
447 * make the HV call to add the pages into the io controller address space.
448 */
449
450static int dma_map_pages(struct ps3_dma_region *r, unsigned long phys_addr,
451 unsigned long len, struct dma_chunk **c_out)
452{
453 int result;
454 struct dma_chunk *c;
455
456 c = kzalloc(sizeof(struct dma_chunk), GFP_ATOMIC);
457
458 if (!c) {
459 result = -ENOMEM;
460 goto fail_alloc;
461 }
462
463 c->region = r;
464 c->lpar_addr = ps3_mm_phys_to_lpar(phys_addr);
465 c->bus_addr = dma_lpar_to_bus(r, c->lpar_addr);
466 c->len = len;
467
468 result = lv1_map_device_dma_region(c->region->did.bus_id,
469 c->region->did.dev_id, c->lpar_addr, c->bus_addr, c->len,
470 0xf800000000000000UL);
471
472 if (result) {
473 DBG("%s:%d: lv1_map_device_dma_region failed: %s\n",
474 __func__, __LINE__, ps3_result(result));
475 goto fail_map;
476 }
477
478 list_add(&c->link, &r->chunk_list.head);
479
480 *c_out = c;
481 return 0;
482
483fail_map:
484 kfree(c);
485fail_alloc:
486 *c_out = NULL;
487 DBG(" <- %s:%d\n", __func__, __LINE__);
488 return result;
489}
490
491/**
492 * dma_region_create - Create a device dma region.
493 * @r: Pointer to a struct ps3_dma_region.
494 *
495 * This is the lowest level dma region create routine, and is the one that
496 * will make the HV call to create the region.
497 */
498
499static int dma_region_create(struct ps3_dma_region* r)
500{
501 int result;
502
503 r->len = _ALIGN_UP(map.total, 1 << r->page_size);
504 INIT_LIST_HEAD(&r->chunk_list.head);
505 spin_lock_init(&r->chunk_list.lock);
506
507 result = lv1_allocate_device_dma_region(r->did.bus_id, r->did.dev_id,
508 r->len, r->page_size, r->region_type, &r->bus_addr);
509
510 dma_dump_region(r);
511
512 if (result) {
513 DBG("%s:%d: lv1_allocate_device_dma_region failed: %s\n",
514 __func__, __LINE__, ps3_result(result));
515 r->len = r->bus_addr = 0;
516 }
517
518 return result;
519}
520
521/**
522 * dma_region_free - Free a device dma region.
523 * @r: Pointer to a struct ps3_dma_region.
524 *
525 * This is the lowest level dma region free routine, and is the one that
526 * will make the HV call to free the region.
527 */
528
529static int dma_region_free(struct ps3_dma_region* r)
530{
531 int result;
532 struct dma_chunk *c;
533 struct dma_chunk *tmp;
534
535 list_for_each_entry_safe(c, tmp, &r->chunk_list.head, link) {
536 list_del(&c->link);
537 dma_free_chunk(c);
538 }
539
540 result = lv1_free_device_dma_region(r->did.bus_id, r->did.dev_id,
541 r->bus_addr);
542
543 if (result)
544 DBG("%s:%d: lv1_free_device_dma_region failed: %s\n",
545 __func__, __LINE__, ps3_result(result));
546
547 r->len = r->bus_addr = 0;
548
549 return result;
550}
551
552/**
553 * dma_map_area - Map an area of memory into a device dma region.
554 * @r: Pointer to a struct ps3_dma_region.
555 * @virt_addr: Starting virtual address of the area to map.
556 * @len: Length in bytes of the area to map.
557 * @bus_addr: A pointer to return the starting ioc bus address of the area to
558 * map.
559 *
560 * This is the common dma mapping routine.
561 */
562
563static int dma_map_area(struct ps3_dma_region *r, unsigned long virt_addr,
564 unsigned long len, unsigned long *bus_addr)
565{
566 int result;
567 unsigned long flags;
568 struct dma_chunk *c;
569 unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
570 : virt_addr;
571
572 *bus_addr = dma_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
573
574 if (!USE_DYNAMIC_DMA) {
575 unsigned long lpar_addr = ps3_mm_phys_to_lpar(phys_addr);
576 DBG(" -> %s:%d\n", __func__, __LINE__);
577 DBG("%s:%d virt_addr %lxh\n", __func__, __LINE__,
578 virt_addr);
579 DBG("%s:%d phys_addr %lxh\n", __func__, __LINE__,
580 phys_addr);
581 DBG("%s:%d lpar_addr %lxh\n", __func__, __LINE__,
582 lpar_addr);
583 DBG("%s:%d len %lxh\n", __func__, __LINE__, len);
584 DBG("%s:%d bus_addr %lxh (%lxh)\n", __func__, __LINE__,
585 *bus_addr, len);
586 }
587
588 spin_lock_irqsave(&r->chunk_list.lock, flags);
589 c = dma_find_chunk(r, *bus_addr, len);
590
591 if (c) {
592 c->usage_count++;
593 spin_unlock_irqrestore(&r->chunk_list.lock, flags);
594 return 0;
595 }
596
597 result = dma_map_pages(r, _ALIGN_DOWN(phys_addr, 1 << r->page_size),
598 _ALIGN_UP(len, 1 << r->page_size), &c);
599
600 if (result) {
601 *bus_addr = 0;
602 DBG("%s:%d: dma_map_pages failed (%d)\n",
603 __func__, __LINE__, result);
604 spin_unlock_irqrestore(&r->chunk_list.lock, flags);
605 return result;
606 }
607
608 c->usage_count = 1;
609
610 spin_unlock_irqrestore(&r->chunk_list.lock, flags);
611 return result;
612}
613
614/**
615 * dma_unmap_area - Unmap an area of memory from a device dma region.
616 * @r: Pointer to a struct ps3_dma_region.
617 * @bus_addr: The starting ioc bus address of the area to unmap.
618 * @len: Length in bytes of the area to unmap.
619 *
620 * This is the common dma unmap routine.
621 */
622
623int dma_unmap_area(struct ps3_dma_region *r, unsigned long bus_addr,
624 unsigned long len)
625{
626 unsigned long flags;
627 struct dma_chunk *c;
628
629 spin_lock_irqsave(&r->chunk_list.lock, flags);
630 c = dma_find_chunk(r, bus_addr, len);
631
632 if (!c) {
633 unsigned long aligned_bus = _ALIGN_DOWN(bus_addr,
634 1 << r->page_size);
635 unsigned long aligned_len = _ALIGN_UP(len, 1 << r->page_size);
636 DBG("%s:%d: not found: bus_addr %lxh\n",
637 __func__, __LINE__, bus_addr);
638 DBG("%s:%d: not found: len %lxh\n",
639 __func__, __LINE__, len);
640 DBG("%s:%d: not found: aligned_bus %lxh\n",
641 __func__, __LINE__, aligned_bus);
642 DBG("%s:%d: not found: aligned_len %lxh\n",
643 __func__, __LINE__, aligned_len);
644 BUG();
645 }
646
647 c->usage_count--;
648
649 if (!c->usage_count) {
650 list_del(&c->link);
651 dma_free_chunk(c);
652 }
653
654 spin_unlock_irqrestore(&r->chunk_list.lock, flags);
655 return 0;
656}
657
658/**
659 * dma_region_create_linear - Setup a linear dma maping for a device.
660 * @r: Pointer to a struct ps3_dma_region.
661 *
662 * This routine creates an HV dma region for the device and maps all available
663 * ram into the io controller bus address space.
664 */
665
666static int dma_region_create_linear(struct ps3_dma_region *r)
667{
668 int result;
669 unsigned long tmp;
670
671 /* force 16M dma pages for linear mapping */
672
673 if (r->page_size != PS3_DMA_16M) {
674 pr_info("%s:%d: forcing 16M pages for linear map\n",
675 __func__, __LINE__);
676 r->page_size = PS3_DMA_16M;
677 }
678
679 result = dma_region_create(r);
680 BUG_ON(result);
681
682 result = dma_map_area(r, map.rm.base, map.rm.size, &tmp);
683 BUG_ON(result);
684
685 if (USE_LPAR_ADDR)
686 result = dma_map_area(r, map.r1.base, map.r1.size,
687 &tmp);
688 else
689 result = dma_map_area(r, map.rm.size, map.r1.size,
690 &tmp);
691
692 BUG_ON(result);
693
694 return result;
695}
696
697/**
698 * dma_region_free_linear - Free a linear dma mapping for a device.
699 * @r: Pointer to a struct ps3_dma_region.
700 *
701 * This routine will unmap all mapped areas and free the HV dma region.
702 */
703
704static int dma_region_free_linear(struct ps3_dma_region *r)
705{
706 int result;
707
708 result = dma_unmap_area(r, dma_lpar_to_bus(r, 0), map.rm.size);
709 BUG_ON(result);
710
711 result = dma_unmap_area(r, dma_lpar_to_bus(r, map.r1.base),
712 map.r1.size);
713 BUG_ON(result);
714
715 result = dma_region_free(r);
716 BUG_ON(result);
717
718 return result;
719}
720
721/**
722 * dma_map_area_linear - Map an area of memory into a device dma region.
723 * @r: Pointer to a struct ps3_dma_region.
724 * @virt_addr: Starting virtual address of the area to map.
725 * @len: Length in bytes of the area to map.
726 * @bus_addr: A pointer to return the starting ioc bus address of the area to
727 * map.
728 *
729 * This routine just returns the coresponding bus address. Actual mapping
730 * occurs in dma_region_create_linear().
731 */
732
733static int dma_map_area_linear(struct ps3_dma_region *r,
734 unsigned long virt_addr, unsigned long len, unsigned long *bus_addr)
735{
736 unsigned long phys_addr = is_kernel_addr(virt_addr) ? __pa(virt_addr)
737 : virt_addr;
738 *bus_addr = dma_lpar_to_bus(r, ps3_mm_phys_to_lpar(phys_addr));
739 return 0;
740}
741
742/**
743 * dma_unmap_area_linear - Unmap an area of memory from a device dma region.
744 * @r: Pointer to a struct ps3_dma_region.
745 * @bus_addr: The starting ioc bus address of the area to unmap.
746 * @len: Length in bytes of the area to unmap.
747 *
748 * This routine does nothing. Unmapping occurs in dma_region_free_linear().
749 */
750
751static int dma_unmap_area_linear(struct ps3_dma_region *r,
752 unsigned long bus_addr, unsigned long len)
753{
754 return 0;
755}
756
757int ps3_dma_region_create(struct ps3_dma_region *r)
758{
759 return (USE_DYNAMIC_DMA)
760 ? dma_region_create(r)
761 : dma_region_create_linear(r);
762}
763
764int ps3_dma_region_free(struct ps3_dma_region *r)
765{
766 return (USE_DYNAMIC_DMA)
767 ? dma_region_free(r)
768 : dma_region_free_linear(r);
769}
770
771int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
772 unsigned long len, unsigned long *bus_addr)
773{
774 return (USE_DYNAMIC_DMA)
775 ? dma_map_area(r, virt_addr, len, bus_addr)
776 : dma_map_area_linear(r, virt_addr, len, bus_addr);
777}
778
779int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
780 unsigned long len)
781{
782 return (USE_DYNAMIC_DMA) ? dma_unmap_area(r, bus_addr, len)
783 : dma_unmap_area_linear(r, bus_addr, len);
784}
785
786/*============================================================================*/
787/* system startup routines */
788/*============================================================================*/
789
790/**
791 * ps3_mm_init - initialize the address space state variables
792 */
793
794void __init ps3_mm_init(void)
795{
796 int result;
797
798 DBG(" -> %s:%d\n", __func__, __LINE__);
799
800 result = ps3_repository_read_mm_info(&map.rm.base, &map.rm.size,
801 &map.total);
802
803 if (result)
804 panic("ps3_repository_read_mm_info() failed");
805
806 map.rm.offset = map.rm.base;
807 map.vas_id = map.htab_size = 0;
808
809 /* this implementation assumes map.rm.base is zero */
810
811 BUG_ON(map.rm.base);
812 BUG_ON(!map.rm.size);
813
814 lmb_add(map.rm.base, map.rm.size);
815 lmb_analyze();
816
817 /* arrange to do this in ps3_mm_add_memory */
818 ps3_mm_region_create(&map.r1, map.total - map.rm.size);
819
820 DBG(" <- %s:%d\n", __func__, __LINE__);
821}
822
823/**
824 * ps3_mm_shutdown - final cleanup of address space
825 */
826
827void ps3_mm_shutdown(void)
828{
829 ps3_mm_region_destroy(&map.r1);
830 map.total = map.rm.size;
831}
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
new file mode 100644
index 000000000000..58358305dc10
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -0,0 +1,259 @@
1/*
2 * PS3 'Other OS' area data.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/io.h>
23
24#include <asm/lmb.h>
25#include <asm/ps3.h>
26
27#include "platform.h"
28
29enum {
30 OS_AREA_SEGMENT_SIZE = 0X200,
31};
32
33enum {
34 HEADER_LDR_FORMAT_RAW = 0,
35 HEADER_LDR_FORMAT_GZIP = 1,
36};
37
38/**
39 * struct os_area_header - os area header segment.
40 * @magic_num: Always 'cell_ext_os_area'.
41 * @hdr_version: Header format version number.
42 * @os_area_offset: Starting segment number of os image area.
43 * @ldr_area_offset: Starting segment number of bootloader image area.
44 * @ldr_format: HEADER_LDR_FORMAT flag.
45 * @ldr_size: Size of bootloader image in bytes.
46 *
47 * Note that the docs refer to area offsets. These are offsets in units of
48 * segments from the start of the os area (top of the header). These are
49 * better thought of as segment numbers. The os area of the os area is
50 * reserved for the os image.
51 */
52
53struct os_area_header {
54 s8 magic_num[16];
55 u32 hdr_version;
56 u32 os_area_offset;
57 u32 ldr_area_offset;
58 u32 _reserved_1;
59 u32 ldr_format;
60 u32 ldr_size;
61 u32 _reserved_2[6];
62} __attribute__ ((packed));
63
64enum {
65 PARAM_BOOT_FLAG_GAME_OS = 0,
66 PARAM_BOOT_FLAG_OTHER_OS = 1,
67};
68
69enum {
70 PARAM_AV_MULTI_OUT_NTSC = 0,
71 PARAM_AV_MULTI_OUT_PAL_RGB = 1,
72 PARAM_AV_MULTI_OUT_PAL_YCBCR = 2,
73 PARAM_AV_MULTI_OUT_SECAM = 3,
74};
75
76enum {
77 PARAM_CTRL_BUTTON_O_IS_YES = 0,
78 PARAM_CTRL_BUTTON_X_IS_YES = 1,
79};
80
81/**
82 * struct os_area_params - os area params segment.
83 * @boot_flag: User preference of operating system, PARAM_BOOT_FLAG flag.
84 * @num_params: Number of params in this (params) segment.
85 * @rtc_diff: Difference in seconds between 1970 and the ps3 rtc value.
86 * @av_multi_out: User preference of AV output, PARAM_AV_MULTI_OUT flag.
87 * @ctrl_button: User preference of controller button config, PARAM_CTRL_BUTTON
88 * flag.
89 * @static_ip_addr: User preference of static IP address.
90 * @network_mask: User preference of static network mask.
91 * @default_gateway: User preference of static default gateway.
92 * @dns_primary: User preference of static primary dns server.
93 * @dns_secondary: User preference of static secondary dns server.
94 *
95 * User preference of zero for static_ip_addr means use dhcp.
96 */
97
98struct os_area_params {
99 u32 boot_flag;
100 u32 _reserved_1[3];
101 u32 num_params;
102 u32 _reserved_2[3];
103 /* param 0 */
104 s64 rtc_diff;
105 u8 av_multi_out;
106 u8 ctrl_button;
107 u8 _reserved_3[6];
108 /* param 1 */
109 u8 static_ip_addr[4];
110 u8 network_mask[4];
111 u8 default_gateway[4];
112 u8 _reserved_4[4];
113 /* param 2 */
114 u8 dns_primary[4];
115 u8 dns_secondary[4];
116 u8 _reserved_5[8];
117} __attribute__ ((packed));
118
119/**
120 * struct saved_params - Static working copies of data from the 'Other OS' area.
121 *
122 * For the convinience of the guest, the HV makes a copy of the 'Other OS' area
123 * in flash to a high address in the boot memory region and then puts that RAM
124 * address and the byte count into the repository for retreval by the guest.
125 * We copy the data we want into a static variable and allow the memory setup
126 * by the HV to be claimed by the lmb manager.
127 */
128
129struct saved_params {
130 /* param 0 */
131 s64 rtc_diff;
132 unsigned int av_multi_out;
133 unsigned int ctrl_button;
134 /* param 1 */
135 u8 static_ip_addr[4];
136 u8 network_mask[4];
137 u8 default_gateway[4];
138 /* param 2 */
139 u8 dns_primary[4];
140 u8 dns_secondary[4];
141} static saved_params;
142
143#define dump_header(_a) _dump_header(_a, __func__, __LINE__)
144static void _dump_header(const struct os_area_header __iomem *h, const char* func,
145 int line)
146{
147 pr_debug("%s:%d: h.magic_num: '%s'\n", func, line,
148 h->magic_num);
149 pr_debug("%s:%d: h.hdr_version: %u\n", func, line,
150 h->hdr_version);
151 pr_debug("%s:%d: h.os_area_offset: %u\n", func, line,
152 h->os_area_offset);
153 pr_debug("%s:%d: h.ldr_area_offset: %u\n", func, line,
154 h->ldr_area_offset);
155 pr_debug("%s:%d: h.ldr_format: %u\n", func, line,
156 h->ldr_format);
157 pr_debug("%s:%d: h.ldr_size: %xh\n", func, line,
158 h->ldr_size);
159}
160
161#define dump_params(_a) _dump_params(_a, __func__, __LINE__)
162static void _dump_params(const struct os_area_params __iomem *p, const char* func,
163 int line)
164{
165 pr_debug("%s:%d: p.boot_flag: %u\n", func, line, p->boot_flag);
166 pr_debug("%s:%d: p.num_params: %u\n", func, line, p->num_params);
167 pr_debug("%s:%d: p.rtc_diff %ld\n", func, line, p->rtc_diff);
168 pr_debug("%s:%d: p.av_multi_out %u\n", func, line, p->av_multi_out);
169 pr_debug("%s:%d: p.ctrl_button: %u\n", func, line, p->ctrl_button);
170 pr_debug("%s:%d: p.static_ip_addr: %u.%u.%u.%u\n", func, line,
171 p->static_ip_addr[0], p->static_ip_addr[1],
172 p->static_ip_addr[2], p->static_ip_addr[3]);
173 pr_debug("%s:%d: p.network_mask: %u.%u.%u.%u\n", func, line,
174 p->network_mask[0], p->network_mask[1],
175 p->network_mask[2], p->network_mask[3]);
176 pr_debug("%s:%d: p.default_gateway: %u.%u.%u.%u\n", func, line,
177 p->default_gateway[0], p->default_gateway[1],
178 p->default_gateway[2], p->default_gateway[3]);
179 pr_debug("%s:%d: p.dns_primary: %u.%u.%u.%u\n", func, line,
180 p->dns_primary[0], p->dns_primary[1],
181 p->dns_primary[2], p->dns_primary[3]);
182 pr_debug("%s:%d: p.dns_secondary: %u.%u.%u.%u\n", func, line,
183 p->dns_secondary[0], p->dns_secondary[1],
184 p->dns_secondary[2], p->dns_secondary[3]);
185}
186
187static int __init verify_header(const struct os_area_header *header)
188{
189 if (memcmp(header->magic_num, "cell_ext_os_area", 16)) {
190 pr_debug("%s:%d magic_num failed\n", __func__, __LINE__);
191 return -1;
192 }
193
194 if (header->hdr_version < 1) {
195 pr_debug("%s:%d hdr_version failed\n", __func__, __LINE__);
196 return -1;
197 }
198
199 if (header->os_area_offset > header->ldr_area_offset) {
200 pr_debug("%s:%d offsets failed\n", __func__, __LINE__);
201 return -1;
202 }
203
204 return 0;
205}
206
207int __init ps3_os_area_init(void)
208{
209 int result;
210 u64 lpar_addr;
211 unsigned int size;
212 struct os_area_header *header;
213 struct os_area_params *params;
214
215 result = ps3_repository_read_boot_dat_info(&lpar_addr, &size);
216
217 if (result) {
218 pr_debug("%s:%d ps3_repository_read_boot_dat_info failed\n",
219 __func__, __LINE__);
220 return result;
221 }
222
223 header = (struct os_area_header *)__va(lpar_addr);
224 params = (struct os_area_params *)__va(lpar_addr + OS_AREA_SEGMENT_SIZE);
225
226 result = verify_header(header);
227
228 if (result) {
229 pr_debug("%s:%d verify_header failed\n", __func__, __LINE__);
230 dump_header(header);
231 return -EIO;
232 }
233
234 dump_header(header);
235 dump_params(params);
236
237 saved_params.rtc_diff = params->rtc_diff;
238 saved_params.av_multi_out = params->av_multi_out;
239 saved_params.ctrl_button = params->ctrl_button;
240 memcpy(saved_params.static_ip_addr, params->static_ip_addr, 4);
241 memcpy(saved_params.network_mask, params->network_mask, 4);
242 memcpy(saved_params.default_gateway, params->default_gateway, 4);
243 memcpy(saved_params.dns_secondary, params->dns_secondary, 4);
244
245 return result;
246}
247
248/**
249 * ps3_os_area_rtc_diff - Returns the ps3 rtc diff value.
250 *
251 * The ps3 rtc maintains a value that approximates seconds since
252 * 2000-01-01 00:00:00 UTC. Returns the exact number of seconds from 1970 to
253 * 2000 when saved_params.rtc_diff has not been properly set up.
254 */
255
256u64 ps3_os_area_rtc_diff(void)
257{
258 return saved_params.rtc_diff ? saved_params.rtc_diff : 946684800UL;
259}
diff --git a/arch/powerpc/platforms/ps3/platform.h b/arch/powerpc/platforms/ps3/platform.h
new file mode 100644
index 000000000000..23b111bea9d0
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/platform.h
@@ -0,0 +1,68 @@
1/*
2 * PS3 platform declarations.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#if !defined(_PS3_PLATFORM_H)
22#define _PS3_PLATFORM_H
23
24#include <linux/rtc.h>
25
26/* htab */
27
28void __init ps3_hpte_init(unsigned long htab_size);
29void __init ps3_map_htab(void);
30
31/* mm */
32
33void __init ps3_mm_init(void);
34void __init ps3_mm_vas_create(unsigned long* htab_size);
35void ps3_mm_vas_destroy(void);
36void ps3_mm_shutdown(void);
37
38/* irq */
39
40void ps3_init_IRQ(void);
41void __init ps3_register_ipi_debug_brk(unsigned int cpu, unsigned int virq);
42
43/* smp */
44
45void smp_init_ps3(void);
46void ps3_smp_cleanup_cpu(int cpu);
47
48/* time */
49
50void __init ps3_calibrate_decr(void);
51unsigned long __init ps3_get_boot_time(void);
52void ps3_get_rtc_time(struct rtc_time *time);
53int ps3_set_rtc_time(struct rtc_time *time);
54
55/* os area */
56
57int __init ps3_os_area_init(void);
58u64 ps3_os_area_rtc_diff(void);
59
60/* spu */
61
62#if defined(CONFIG_SPU_BASE)
63void ps3_spu_set_platform (void);
64#else
65static inline void ps3_spu_set_platform (void) {}
66#endif
67
68#endif
diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c
new file mode 100644
index 000000000000..273a0d621bdd
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/repository.c
@@ -0,0 +1,840 @@
1/*
2 * PS3 repository routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <asm/ps3.h>
22#include <asm/lv1call.h>
23
24enum ps3_vendor_id {
25 PS3_VENDOR_ID_NONE = 0,
26 PS3_VENDOR_ID_SONY = 0x8000000000000000UL,
27};
28
29enum ps3_lpar_id {
30 PS3_LPAR_ID_CURRENT = 0,
31 PS3_LPAR_ID_PME = 1,
32};
33
34#define dump_field(_a, _b) _dump_field(_a, _b, __func__, __LINE__)
35static void _dump_field(const char *hdr, u64 n, const char* func, int line)
36{
37#if defined(DEBUG)
38 char s[16];
39 const char *const in = (const char *)&n;
40 unsigned int i;
41
42 for (i = 0; i < 8; i++)
43 s[i] = (in[i] <= 126 && in[i] >= 32) ? in[i] : '.';
44 s[i] = 0;
45
46 pr_debug("%s:%d: %s%016lx : %s\n", func, line, hdr, n, s);
47#endif
48}
49
50#define dump_node_name(_a, _b, _c, _d, _e) \
51 _dump_node_name(_a, _b, _c, _d, _e, __func__, __LINE__)
52static void _dump_node_name (unsigned int lpar_id, u64 n1, u64 n2, u64 n3,
53 u64 n4, const char* func, int line)
54{
55 pr_debug("%s:%d: lpar: %u\n", func, line, lpar_id);
56 _dump_field("n1: ", n1, func, line);
57 _dump_field("n2: ", n2, func, line);
58 _dump_field("n3: ", n3, func, line);
59 _dump_field("n4: ", n4, func, line);
60}
61
62#define dump_node(_a, _b, _c, _d, _e, _f, _g) \
63 _dump_node(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
64static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
65 u64 v1, u64 v2, const char* func, int line)
66{
67 pr_debug("%s:%d: lpar: %u\n", func, line, lpar_id);
68 _dump_field("n1: ", n1, func, line);
69 _dump_field("n2: ", n2, func, line);
70 _dump_field("n3: ", n3, func, line);
71 _dump_field("n4: ", n4, func, line);
72 pr_debug("%s:%d: v1: %016lx\n", func, line, v1);
73 pr_debug("%s:%d: v2: %016lx\n", func, line, v2);
74}
75
76/**
77 * make_first_field - Make the first field of a repository node name.
78 * @text: Text portion of the field.
79 * @index: Numeric index portion of the field. Use zero for 'don't care'.
80 *
81 * This routine sets the vendor id to zero (non-vendor specific).
82 * Returns field value.
83 */
84
85static u64 make_first_field(const char *text, u64 index)
86{
87 u64 n;
88
89 strncpy((char *)&n, text, 8);
90 return PS3_VENDOR_ID_NONE + (n >> 32) + index;
91}
92
93/**
94 * make_field - Make subsequent fields of a repository node name.
95 * @text: Text portion of the field. Use "" for 'don't care'.
96 * @index: Numeric index portion of the field. Use zero for 'don't care'.
97 *
98 * Returns field value.
99 */
100
101static u64 make_field(const char *text, u64 index)
102{
103 u64 n;
104
105 strncpy((char *)&n, text, 8);
106 return n + index;
107}
108
109/**
110 * read_node - Read a repository node from raw fields.
111 * @n1: First field of node name.
112 * @n2: Second field of node name. Use zero for 'don't care'.
113 * @n3: Third field of node name. Use zero for 'don't care'.
114 * @n4: Fourth field of node name. Use zero for 'don't care'.
115 * @v1: First repository value (high word).
116 * @v2: Second repository value (low word). Optional parameter, use zero
117 * for 'don't care'.
118 */
119
120static int read_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
121 u64 *_v1, u64 *_v2)
122{
123 int result;
124 u64 v1;
125 u64 v2;
126
127 if (lpar_id == PS3_LPAR_ID_CURRENT) {
128 u64 id;
129 lv1_get_logical_partition_id(&id);
130 lpar_id = id;
131 }
132
133 result = lv1_get_repository_node_value(lpar_id, n1, n2, n3, n4, &v1,
134 &v2);
135
136 if (result) {
137 pr_debug("%s:%d: lv1_get_repository_node_value failed: %s\n",
138 __func__, __LINE__, ps3_result(result));
139 dump_node_name(lpar_id, n1, n2, n3, n4);
140 return result;
141 }
142
143 dump_node(lpar_id, n1, n2, n3, n4, v1, v2);
144
145 if (_v1)
146 *_v1 = v1;
147 if (_v2)
148 *_v2 = v2;
149
150 if (v1 && !_v1)
151 pr_debug("%s:%d: warning: discarding non-zero v1: %016lx\n",
152 __func__, __LINE__, v1);
153 if (v2 && !_v2)
154 pr_debug("%s:%d: warning: discarding non-zero v2: %016lx\n",
155 __func__, __LINE__, v2);
156
157 return result;
158}
159
160int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
161 u64 *value)
162{
163 return read_node(PS3_LPAR_ID_PME,
164 make_first_field("bus", bus_index),
165 make_field(bus_str, 0),
166 0, 0,
167 value, 0);
168}
169
170int ps3_repository_read_bus_id(unsigned int bus_index, unsigned int *bus_id)
171{
172 int result;
173 u64 v1;
174 u64 v2; /* unused */
175
176 result = read_node(PS3_LPAR_ID_PME,
177 make_first_field("bus", bus_index),
178 make_field("id", 0),
179 0, 0,
180 &v1, &v2);
181 *bus_id = v1;
182 return result;
183}
184
185int ps3_repository_read_bus_type(unsigned int bus_index,
186 enum ps3_bus_type *bus_type)
187{
188 int result;
189 u64 v1;
190
191 result = read_node(PS3_LPAR_ID_PME,
192 make_first_field("bus", bus_index),
193 make_field("type", 0),
194 0, 0,
195 &v1, 0);
196 *bus_type = v1;
197 return result;
198}
199
200int ps3_repository_read_bus_num_dev(unsigned int bus_index,
201 unsigned int *num_dev)
202{
203 int result;
204 u64 v1;
205
206 result = read_node(PS3_LPAR_ID_PME,
207 make_first_field("bus", bus_index),
208 make_field("num_dev", 0),
209 0, 0,
210 &v1, 0);
211 *num_dev = v1;
212 return result;
213}
214
215int ps3_repository_read_dev_str(unsigned int bus_index,
216 unsigned int dev_index, const char *dev_str, u64 *value)
217{
218 return read_node(PS3_LPAR_ID_PME,
219 make_first_field("bus", bus_index),
220 make_field("dev", dev_index),
221 make_field(dev_str, 0),
222 0,
223 value, 0);
224}
225
226int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
227 unsigned int *dev_id)
228{
229 int result;
230 u64 v1;
231
232 result = read_node(PS3_LPAR_ID_PME,
233 make_first_field("bus", bus_index),
234 make_field("dev", dev_index),
235 make_field("id", 0),
236 0,
237 &v1, 0);
238 *dev_id = v1;
239 return result;
240}
241
242int ps3_repository_read_dev_type(unsigned int bus_index,
243 unsigned int dev_index, enum ps3_dev_type *dev_type)
244{
245 int result;
246 u64 v1;
247
248 result = read_node(PS3_LPAR_ID_PME,
249 make_first_field("bus", bus_index),
250 make_field("dev", dev_index),
251 make_field("type", 0),
252 0,
253 &v1, 0);
254 *dev_type = v1;
255 return result;
256}
257
258int ps3_repository_read_dev_intr(unsigned int bus_index,
259 unsigned int dev_index, unsigned int intr_index,
260 unsigned int *intr_type, unsigned int* interrupt_id)
261{
262 int result;
263 u64 v1;
264 u64 v2;
265
266 result = read_node(PS3_LPAR_ID_PME,
267 make_first_field("bus", bus_index),
268 make_field("dev", dev_index),
269 make_field("intr", intr_index),
270 0,
271 &v1, &v2);
272 *intr_type = v1;
273 *interrupt_id = v2;
274 return result;
275}
276
277int ps3_repository_read_dev_reg_type(unsigned int bus_index,
278 unsigned int dev_index, unsigned int reg_index, unsigned int *reg_type)
279{
280 int result;
281 u64 v1;
282
283 result = read_node(PS3_LPAR_ID_PME,
284 make_first_field("bus", bus_index),
285 make_field("dev", dev_index),
286 make_field("reg", reg_index),
287 make_field("type", 0),
288 &v1, 0);
289 *reg_type = v1;
290 return result;
291}
292
293int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
294 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr, u64 *len)
295{
296 return read_node(PS3_LPAR_ID_PME,
297 make_first_field("bus", bus_index),
298 make_field("dev", dev_index),
299 make_field("reg", reg_index),
300 make_field("data", 0),
301 bus_addr, len);
302}
303
304int ps3_repository_read_dev_reg(unsigned int bus_index,
305 unsigned int dev_index, unsigned int reg_index, unsigned int *reg_type,
306 u64 *bus_addr, u64 *len)
307{
308 int result = ps3_repository_read_dev_reg_type(bus_index, dev_index,
309 reg_index, reg_type);
310 return result ? result
311 : ps3_repository_read_dev_reg_addr(bus_index, dev_index,
312 reg_index, bus_addr, len);
313}
314
315#if defined(DEBUG)
316int ps3_repository_dump_resource_info(unsigned int bus_index,
317 unsigned int dev_index)
318{
319 int result = 0;
320 unsigned int res_index;
321
322 pr_debug(" -> %s:%d: (%u:%u)\n", __func__, __LINE__,
323 bus_index, dev_index);
324
325 for (res_index = 0; res_index < 10; res_index++) {
326 enum ps3_interrupt_type intr_type;
327 unsigned int interrupt_id;
328
329 result = ps3_repository_read_dev_intr(bus_index, dev_index,
330 res_index, &intr_type, &interrupt_id);
331
332 if (result) {
333 if (result != LV1_NO_ENTRY)
334 pr_debug("%s:%d ps3_repository_read_dev_intr"
335 " (%u:%u) failed\n", __func__, __LINE__,
336 bus_index, dev_index);
337 break;
338 }
339
340 pr_debug("%s:%d (%u:%u) intr_type %u, interrupt_id %u\n",
341 __func__, __LINE__, bus_index, dev_index, intr_type,
342 interrupt_id);
343 }
344
345 for (res_index = 0; res_index < 10; res_index++) {
346 enum ps3_region_type reg_type;
347 u64 bus_addr;
348 u64 len;
349
350 result = ps3_repository_read_dev_reg(bus_index, dev_index,
351 res_index, &reg_type, &bus_addr, &len);
352
353 if (result) {
354 if (result != LV1_NO_ENTRY)
355 pr_debug("%s:%d ps3_repository_read_dev_reg"
356 " (%u:%u) failed\n", __func__, __LINE__,
357 bus_index, dev_index);
358 break;
359 }
360
361 pr_debug("%s:%d (%u:%u) reg_type %u, bus_addr %lxh, len %lxh\n",
362 __func__, __LINE__, bus_index, dev_index, reg_type,
363 bus_addr, len);
364 }
365
366 pr_debug(" <- %s:%d\n", __func__, __LINE__);
367 return result;
368}
369
370static int dump_device_info(unsigned int bus_index, unsigned int num_dev)
371{
372 int result = 0;
373 unsigned int dev_index;
374
375 pr_debug(" -> %s:%d: bus_%u\n", __func__, __LINE__, bus_index);
376
377 for (dev_index = 0; dev_index < num_dev; dev_index++) {
378 enum ps3_dev_type dev_type;
379 unsigned int dev_id;
380
381 result = ps3_repository_read_dev_type(bus_index, dev_index,
382 &dev_type);
383
384 if (result) {
385 pr_debug("%s:%d ps3_repository_read_dev_type"
386 " (%u:%u) failed\n", __func__, __LINE__,
387 bus_index, dev_index);
388 break;
389 }
390
391 result = ps3_repository_read_dev_id(bus_index, dev_index,
392 &dev_id);
393
394 if (result) {
395 pr_debug("%s:%d ps3_repository_read_dev_id"
396 " (%u:%u) failed\n", __func__, __LINE__,
397 bus_index, dev_index);
398 continue;
399 }
400
401 pr_debug("%s:%d (%u:%u): dev_type %u, dev_id %u\n", __func__,
402 __LINE__, bus_index, dev_index, dev_type, dev_id);
403
404 ps3_repository_dump_resource_info(bus_index, dev_index);
405 }
406
407 pr_debug(" <- %s:%d\n", __func__, __LINE__);
408 return result;
409}
410
411int ps3_repository_dump_bus_info(void)
412{
413 int result = 0;
414 unsigned int bus_index;
415
416 pr_debug(" -> %s:%d\n", __func__, __LINE__);
417
418 for (bus_index = 0; bus_index < 10; bus_index++) {
419 enum ps3_bus_type bus_type;
420 unsigned int bus_id;
421 unsigned int num_dev;
422
423 result = ps3_repository_read_bus_type(bus_index, &bus_type);
424
425 if (result) {
426 pr_debug("%s:%d read_bus_type(%u) failed\n",
427 __func__, __LINE__, bus_index);
428 break;
429 }
430
431 result = ps3_repository_read_bus_id(bus_index, &bus_id);
432
433 if (result) {
434 pr_debug("%s:%d read_bus_id(%u) failed\n",
435 __func__, __LINE__, bus_index);
436 continue;
437 }
438
439 if (bus_index != bus_id)
440 pr_debug("%s:%d bus_index != bus_id\n",
441 __func__, __LINE__);
442
443 result = ps3_repository_read_bus_num_dev(bus_index, &num_dev);
444
445 if (result) {
446 pr_debug("%s:%d read_bus_num_dev(%u) failed\n",
447 __func__, __LINE__, bus_index);
448 continue;
449 }
450
451 pr_debug("%s:%d bus_%u: bus_type %u, bus_id %u, num_dev %u\n",
452 __func__, __LINE__, bus_index, bus_type, bus_id,
453 num_dev);
454
455 dump_device_info(bus_index, num_dev);
456 }
457
458 pr_debug(" <- %s:%d\n", __func__, __LINE__);
459 return result;
460}
461#endif /* defined(DEBUG) */
462
463static int find_device(unsigned int bus_index, unsigned int num_dev,
464 unsigned int start_dev_index, enum ps3_dev_type dev_type,
465 struct ps3_repository_device *dev)
466{
467 int result = 0;
468 unsigned int dev_index;
469
470 pr_debug("%s:%d: find dev_type %u\n", __func__, __LINE__, dev_type);
471
472 dev->dev_index = UINT_MAX;
473
474 for (dev_index = start_dev_index; dev_index < num_dev; dev_index++) {
475 enum ps3_dev_type x;
476
477 result = ps3_repository_read_dev_type(bus_index, dev_index,
478 &x);
479
480 if (result) {
481 pr_debug("%s:%d read_dev_type failed\n",
482 __func__, __LINE__);
483 return result;
484 }
485
486 if (x == dev_type)
487 break;
488 }
489
490 BUG_ON(dev_index == num_dev);
491
492 pr_debug("%s:%d: found dev_type %u at dev_index %u\n",
493 __func__, __LINE__, dev_type, dev_index);
494
495 result = ps3_repository_read_dev_id(bus_index, dev_index,
496 &dev->did.dev_id);
497
498 if (result) {
499 pr_debug("%s:%d read_dev_id failed\n",
500 __func__, __LINE__);
501 return result;
502 }
503
504 dev->dev_index = dev_index;
505
506 pr_debug("%s:%d found: dev_id %u\n", __func__, __LINE__,
507 dev->did.dev_id);
508
509 return result;
510}
511
512int ps3_repository_find_device (enum ps3_bus_type bus_type,
513 enum ps3_dev_type dev_type,
514 const struct ps3_repository_device *start_dev,
515 struct ps3_repository_device *dev)
516{
517 int result = 0;
518 unsigned int bus_index;
519 unsigned int num_dev;
520
521 pr_debug("%s:%d: find bus_type %u, dev_type %u\n", __func__, __LINE__,
522 bus_type, dev_type);
523
524 dev->bus_index = UINT_MAX;
525
526 for (bus_index = start_dev ? start_dev->bus_index : 0; bus_index < 10;
527 bus_index++) {
528 enum ps3_bus_type x;
529
530 result = ps3_repository_read_bus_type(bus_index, &x);
531
532 if (result) {
533 pr_debug("%s:%d read_bus_type failed\n",
534 __func__, __LINE__);
535 return result;
536 }
537 if (x == bus_type)
538 break;
539 }
540
541 BUG_ON(bus_index == 10);
542
543 pr_debug("%s:%d: found bus_type %u at bus_index %u\n",
544 __func__, __LINE__, bus_type, bus_index);
545
546 result = ps3_repository_read_bus_num_dev(bus_index, &num_dev);
547
548 if (result) {
549 pr_debug("%s:%d read_bus_num_dev failed\n",
550 __func__, __LINE__);
551 return result;
552 }
553
554 result = find_device(bus_index, num_dev, start_dev
555 ? start_dev->dev_index + 1 : 0, dev_type, dev);
556
557 if (result) {
558 pr_debug("%s:%d get_did failed\n", __func__, __LINE__);
559 return result;
560 }
561
562 result = ps3_repository_read_bus_id(bus_index, &dev->did.bus_id);
563
564 if (result) {
565 pr_debug("%s:%d read_bus_id failed\n",
566 __func__, __LINE__);
567 return result;
568 }
569
570 dev->bus_index = bus_index;
571
572 pr_debug("%s:%d found: bus_id %u, dev_id %u\n",
573 __func__, __LINE__, dev->did.bus_id, dev->did.dev_id);
574
575 return result;
576}
577
578int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
579 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id)
580{
581 int result = 0;
582 unsigned int res_index;
583
584 pr_debug("%s:%d: find intr_type %u\n", __func__, __LINE__, intr_type);
585
586 *interrupt_id = UINT_MAX;
587
588 for (res_index = 0; res_index < 10; res_index++) {
589 enum ps3_interrupt_type t;
590 unsigned int id;
591
592 result = ps3_repository_read_dev_intr(dev->bus_index,
593 dev->dev_index, res_index, &t, &id);
594
595 if (result) {
596 pr_debug("%s:%d read_dev_intr failed\n",
597 __func__, __LINE__);
598 return result;
599 }
600
601 if (t == intr_type) {
602 *interrupt_id = id;
603 break;
604 }
605 }
606
607 BUG_ON(res_index == 10);
608
609 pr_debug("%s:%d: found intr_type %u at res_index %u\n",
610 __func__, __LINE__, intr_type, res_index);
611
612 return result;
613}
614
615int ps3_repository_find_region(const struct ps3_repository_device *dev,
616 enum ps3_region_type reg_type, u64 *bus_addr, u64 *len)
617{
618 int result = 0;
619 unsigned int res_index;
620
621 pr_debug("%s:%d: find reg_type %u\n", __func__, __LINE__, reg_type);
622
623 *bus_addr = *len = 0;
624
625 for (res_index = 0; res_index < 10; res_index++) {
626 enum ps3_region_type t;
627 u64 a;
628 u64 l;
629
630 result = ps3_repository_read_dev_reg(dev->bus_index,
631 dev->dev_index, res_index, &t, &a, &l);
632
633 if (result) {
634 pr_debug("%s:%d read_dev_reg failed\n",
635 __func__, __LINE__);
636 return result;
637 }
638
639 if (t == reg_type) {
640 *bus_addr = a;
641 *len = l;
642 break;
643 }
644 }
645
646 BUG_ON(res_index == 10);
647
648 pr_debug("%s:%d: found reg_type %u at res_index %u\n",
649 __func__, __LINE__, reg_type, res_index);
650
651 return result;
652}
653
654int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size)
655{
656 return read_node(PS3_LPAR_ID_CURRENT,
657 make_first_field("bi", 0),
658 make_field("pu", 0),
659 ppe_id,
660 make_field("rm_size", 0),
661 rm_size, 0);
662}
663
664int ps3_repository_read_region_total(u64 *region_total)
665{
666 return read_node(PS3_LPAR_ID_CURRENT,
667 make_first_field("bi", 0),
668 make_field("rgntotal", 0),
669 0, 0,
670 region_total, 0);
671}
672
673/**
674 * ps3_repository_read_mm_info - Read mm info for single pu system.
675 * @rm_base: Real mode memory base address.
676 * @rm_size: Real mode memory size.
677 * @region_total: Maximum memory region size.
678 */
679
680int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size, u64 *region_total)
681{
682 int result;
683 u64 ppe_id;
684
685 lv1_get_logical_ppe_id(&ppe_id);
686 *rm_base = 0;
687 result = ps3_repository_read_rm_size(ppe_id, rm_size);
688 return result ? result
689 : ps3_repository_read_region_total(region_total);
690}
691
692/**
693 * ps3_repository_read_num_spu_reserved - Number of physical spus reserved.
694 * @num_spu: Number of physical spus.
695 */
696
697int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved)
698{
699 int result;
700 u64 v1;
701
702 result = read_node(PS3_LPAR_ID_CURRENT,
703 make_first_field("bi", 0),
704 make_field("spun", 0),
705 0, 0,
706 &v1, 0);
707 *num_spu_reserved = v1;
708 return result;
709}
710
711/**
712 * ps3_repository_read_num_spu_resource_id - Number of spu resource reservations.
713 * @num_resource_id: Number of spu resource ids.
714 */
715
716int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id)
717{
718 int result;
719 u64 v1;
720
721 result = read_node(PS3_LPAR_ID_CURRENT,
722 make_first_field("bi", 0),
723 make_field("spursvn", 0),
724 0, 0,
725 &v1, 0);
726 *num_resource_id = v1;
727 return result;
728}
729
730/**
731 * ps3_repository_read_spu_resource_id - spu resource reservation id value.
732 * @res_index: Resource reservation index.
733 * @resource_type: Resource reservation type.
734 * @resource_id: Resource reservation id.
735 */
736
737int ps3_repository_read_spu_resource_id(unsigned int res_index,
738 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id)
739{
740 int result;
741 u64 v1;
742 u64 v2;
743
744 result = read_node(PS3_LPAR_ID_CURRENT,
745 make_first_field("bi", 0),
746 make_field("spursv", 0),
747 res_index,
748 0,
749 &v1, &v2);
750 *resource_type = v1;
751 *resource_id = v2;
752 return result;
753}
754
755int ps3_repository_read_boot_dat_address(u64 *address)
756{
757 return read_node(PS3_LPAR_ID_CURRENT,
758 make_first_field("bi", 0),
759 make_field("boot_dat", 0),
760 make_field("address", 0),
761 0,
762 address, 0);
763}
764
765int ps3_repository_read_boot_dat_size(unsigned int *size)
766{
767 int result;
768 u64 v1;
769
770 result = read_node(PS3_LPAR_ID_CURRENT,
771 make_first_field("bi", 0),
772 make_field("boot_dat", 0),
773 make_field("size", 0),
774 0,
775 &v1, 0);
776 *size = v1;
777 return result;
778}
779
780/**
781 * ps3_repository_read_boot_dat_info - Get address and size of cell_ext_os_area.
782 * address: lpar address of cell_ext_os_area
783 * @size: size of cell_ext_os_area
784 */
785
786int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size)
787{
788 int result;
789
790 *size = 0;
791 result = ps3_repository_read_boot_dat_address(lpar_addr);
792 return result ? result
793 : ps3_repository_read_boot_dat_size(size);
794}
795
796int ps3_repository_read_num_be(unsigned int *num_be)
797{
798 int result;
799 u64 v1;
800
801 result = read_node(PS3_LPAR_ID_PME,
802 make_first_field("ben", 0),
803 0,
804 0,
805 0,
806 &v1, 0);
807 *num_be = v1;
808 return result;
809}
810
811int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id)
812{
813 return read_node(PS3_LPAR_ID_PME,
814 make_first_field("be", be_index),
815 0,
816 0,
817 0,
818 node_id, 0);
819}
820
821int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq)
822{
823 return read_node(PS3_LPAR_ID_PME,
824 make_first_field("be", 0),
825 node_id,
826 make_field("clock", 0),
827 0,
828 tb_freq, 0);
829}
830
831int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq)
832{
833 int result;
834 u64 node_id;
835
836 *tb_freq = 0;
837 result = ps3_repository_read_be_node_id(0, &node_id);
838 return result ? result
839 : ps3_repository_read_tb_freq(node_id, tb_freq);
840}
diff --git a/arch/powerpc/platforms/ps3/setup.c b/arch/powerpc/platforms/ps3/setup.c
new file mode 100644
index 000000000000..d8b5cadbe80e
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/setup.c
@@ -0,0 +1,173 @@
1/*
2 * PS3 platform setup routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/delay.h>
23#include <linux/fs.h>
24#include <linux/root_dev.h>
25#include <linux/console.h>
26#include <linux/kexec.h>
27
28#include <asm/machdep.h>
29#include <asm/firmware.h>
30#include <asm/time.h>
31#include <asm/iommu.h>
32#include <asm/udbg.h>
33#include <asm/prom.h>
34#include <asm/lv1call.h>
35
36#include "platform.h"
37
38#if defined(DEBUG)
39#define DBG(fmt...) udbg_printf(fmt)
40#else
41#define DBG(fmt...) do{if(0)printk(fmt);}while(0)
42#endif
43
44static void ps3_show_cpuinfo(struct seq_file *m)
45{
46 seq_printf(m, "machine\t\t: %s\n", ppc_md.name);
47}
48
49static void ps3_power_save(void)
50{
51 /*
52 * lv1_pause() puts the PPE thread into inactive state until an
53 * irq on an unmasked plug exists. MSR[EE] has no effect.
54 * flags: 0 = wake on DEC interrupt, 1 = ignore DEC interrupt.
55 */
56
57 lv1_pause(0);
58}
59
60static void ps3_panic(char *str)
61{
62 DBG("%s:%d %s\n", __func__, __LINE__, str);
63
64#ifdef CONFIG_SMP
65 smp_send_stop();
66#endif
67 printk("\n");
68 printk(" System does not reboot automatically.\n");
69 printk(" Please press POWER button.\n");
70 printk("\n");
71
72 for (;;) ;
73}
74
75static void __init ps3_setup_arch(void)
76{
77 DBG(" -> %s:%d\n", __func__, __LINE__);
78
79 ps3_spu_set_platform();
80 ps3_map_htab();
81
82#ifdef CONFIG_SMP
83 smp_init_ps3();
84#endif
85
86#ifdef CONFIG_DUMMY_CONSOLE
87 conswitchp = &dummy_con;
88#endif
89
90 ppc_md.power_save = ps3_power_save;
91
92 DBG(" <- %s:%d\n", __func__, __LINE__);
93}
94
95static void __init ps3_progress(char *s, unsigned short hex)
96{
97 printk("*** %04x : %s\n", hex, s ? s : "");
98}
99
100static int __init ps3_probe(void)
101{
102 unsigned long htab_size;
103 unsigned long dt_root;
104
105 DBG(" -> %s:%d\n", __func__, __LINE__);
106
107 dt_root = of_get_flat_dt_root();
108 if (!of_flat_dt_is_compatible(dt_root, "PS3"))
109 return 0;
110
111 powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
112
113 ps3_os_area_init();
114 ps3_mm_init();
115 ps3_mm_vas_create(&htab_size);
116 ps3_hpte_init(htab_size);
117
118 DBG(" <- %s:%d\n", __func__, __LINE__);
119 return 1;
120}
121
122#if defined(CONFIG_KEXEC)
123static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
124{
125 DBG(" -> %s:%d\n", __func__, __LINE__);
126
127 if (secondary) {
128 int cpu;
129 for_each_online_cpu(cpu)
130 if (cpu)
131 ps3_smp_cleanup_cpu(cpu);
132 } else
133 ps3_smp_cleanup_cpu(0);
134
135 DBG(" <- %s:%d\n", __func__, __LINE__);
136}
137
138static void ps3_machine_kexec(struct kimage *image)
139{
140 unsigned long ppe_id;
141
142 DBG(" -> %s:%d\n", __func__, __LINE__);
143
144 lv1_get_logical_ppe_id(&ppe_id);
145 lv1_configure_irq_state_bitmap(ppe_id, 0, 0);
146 ps3_mm_shutdown();
147 ps3_mm_vas_destroy();
148
149 default_machine_kexec(image);
150
151 DBG(" <- %s:%d\n", __func__, __LINE__);
152}
153#endif
154
155define_machine(ps3) {
156 .name = "PS3",
157 .probe = ps3_probe,
158 .setup_arch = ps3_setup_arch,
159 .show_cpuinfo = ps3_show_cpuinfo,
160 .init_IRQ = ps3_init_IRQ,
161 .panic = ps3_panic,
162 .get_boot_time = ps3_get_boot_time,
163 .set_rtc_time = ps3_set_rtc_time,
164 .get_rtc_time = ps3_get_rtc_time,
165 .calibrate_decr = ps3_calibrate_decr,
166 .progress = ps3_progress,
167#if defined(CONFIG_KEXEC)
168 .kexec_cpu_down = ps3_kexec_cpu_down,
169 .machine_kexec = ps3_machine_kexec,
170 .machine_kexec_prepare = default_machine_kexec_prepare,
171 .machine_crash_shutdown = default_machine_crash_shutdown,
172#endif
173};
diff --git a/arch/powerpc/platforms/ps3/smp.c b/arch/powerpc/platforms/ps3/smp.c
new file mode 100644
index 000000000000..11d2080607ed
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/smp.c
@@ -0,0 +1,158 @@
1/*
2 * PS3 SMP routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/smp.h>
23
24#include <asm/machdep.h>
25#include <asm/udbg.h>
26#include <asm/ps3.h>
27
28#include "platform.h"
29
30#if defined(DEBUG)
31#define DBG(fmt...) udbg_printf(fmt)
32#else
33#define DBG(fmt...) do{if(0)printk(fmt);}while(0)
34#endif
35
36static irqreturn_t ipi_function_handler(int irq, void *msg)
37{
38 smp_message_recv((int)(long)msg);
39 return IRQ_HANDLED;
40}
41
42/**
43 * virqs - a per cpu array of virqs for ipi use
44 */
45
46#define MSG_COUNT 4
47static DEFINE_PER_CPU(unsigned int, virqs[MSG_COUNT]);
48
49static const char *names[MSG_COUNT] = {
50 "ipi call",
51 "ipi reschedule",
52 "ipi migrate",
53 "ipi debug brk"
54};
55
56static void do_message_pass(int target, int msg)
57{
58 int result;
59 unsigned int virq;
60
61 if (msg >= MSG_COUNT) {
62 DBG("%s:%d: bad msg: %d\n", __func__, __LINE__, msg);
63 return;
64 }
65
66 virq = per_cpu(virqs, target)[msg];
67 result = ps3_send_event_locally(virq);
68
69 if (result)
70 DBG("%s:%d: ps3_send_event_locally(%d, %d) failed"
71 " (%d)\n", __func__, __LINE__, target, msg, result);
72}
73
74static void ps3_smp_message_pass(int target, int msg)
75{
76 int cpu;
77
78 if (target < NR_CPUS)
79 do_message_pass(target, msg);
80 else if (target == MSG_ALL_BUT_SELF) {
81 for_each_online_cpu(cpu)
82 if (cpu != smp_processor_id())
83 do_message_pass(cpu, msg);
84 } else {
85 for_each_online_cpu(cpu)
86 do_message_pass(cpu, msg);
87 }
88}
89
90static int ps3_smp_probe(void)
91{
92 return 2;
93}
94
95static void __init ps3_smp_setup_cpu(int cpu)
96{
97 int result;
98 unsigned int *virqs = per_cpu(virqs, cpu);
99 int i;
100
101 DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
102
103 /*
104 * Check assumptions on virqs[] indexing. If this
105 * check fails, then a different mapping of PPC_MSG_
106 * to index needs to be setup.
107 */
108
109 BUILD_BUG_ON(PPC_MSG_CALL_FUNCTION != 0);
110 BUILD_BUG_ON(PPC_MSG_RESCHEDULE != 1);
111 BUILD_BUG_ON(PPC_MSG_DEBUGGER_BREAK != 3);
112
113 for (i = 0; i < MSG_COUNT; i++) {
114 result = ps3_alloc_event_irq(&virqs[i]);
115
116 if (result)
117 continue;
118
119 DBG("%s:%d: (%d, %d) => virq %u\n",
120 __func__, __LINE__, cpu, i, virqs[i]);
121
122
123 request_irq(virqs[i], ipi_function_handler, IRQF_DISABLED,
124 names[i], (void*)(long)i);
125 }
126
127 ps3_register_ipi_debug_brk(cpu, virqs[PPC_MSG_DEBUGGER_BREAK]);
128
129 DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
130}
131
132void ps3_smp_cleanup_cpu(int cpu)
133{
134 unsigned int *virqs = per_cpu(virqs, cpu);
135 int i;
136
137 DBG(" -> %s:%d: (%d)\n", __func__, __LINE__, cpu);
138 for (i = 0; i < MSG_COUNT; i++) {
139 ps3_free_event_irq(virqs[i]);
140 free_irq(virqs[i], (void*)(long)i);
141 virqs[i] = NO_IRQ;
142 }
143 DBG(" <- %s:%d: (%d)\n", __func__, __LINE__, cpu);
144}
145
146static struct smp_ops_t ps3_smp_ops = {
147 .probe = ps3_smp_probe,
148 .message_pass = ps3_smp_message_pass,
149 .kick_cpu = smp_generic_kick_cpu,
150 .setup_cpu = ps3_smp_setup_cpu,
151};
152
153void smp_init_ps3(void)
154{
155 DBG(" -> %s\n", __func__);
156 smp_ops = &ps3_smp_ops;
157 DBG(" <- %s\n", __func__);
158}
diff --git a/arch/powerpc/platforms/ps3/spu.c b/arch/powerpc/platforms/ps3/spu.c
new file mode 100644
index 000000000000..644532c3b7c4
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/spu.c
@@ -0,0 +1,613 @@
1/*
2 * PS3 Platform spu routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/mmzone.h>
24#include <linux/io.h>
25#include <linux/mm.h>
26
27#include <asm/spu.h>
28#include <asm/spu_priv1.h>
29#include <asm/ps3.h>
30#include <asm/lv1call.h>
31
32/* spu_management_ops */
33
34/**
35 * enum spe_type - Type of spe to create.
36 * @spe_type_logical: Standard logical spe.
37 *
38 * For use with lv1_construct_logical_spe(). The current HV does not support
39 * any types other than those listed.
40 */
41
42enum spe_type {
43 SPE_TYPE_LOGICAL = 0,
44};
45
46/**
47 * struct spe_shadow - logical spe shadow register area.
48 *
49 * Read-only shadow of spe registers.
50 */
51
52struct spe_shadow {
53 u8 padding_0000[0x0140];
54 u64 int_status_class0_RW; /* 0x0140 */
55 u64 int_status_class1_RW; /* 0x0148 */
56 u64 int_status_class2_RW; /* 0x0150 */
57 u8 padding_0158[0x0610-0x0158];
58 u64 mfc_dsisr_RW; /* 0x0610 */
59 u8 padding_0618[0x0620-0x0618];
60 u64 mfc_dar_RW; /* 0x0620 */
61 u8 padding_0628[0x0800-0x0628];
62 u64 mfc_dsipr_R; /* 0x0800 */
63 u8 padding_0808[0x0810-0x0808];
64 u64 mfc_lscrr_R; /* 0x0810 */
65 u8 padding_0818[0x0c00-0x0818];
66 u64 mfc_cer_R; /* 0x0c00 */
67 u8 padding_0c08[0x0f00-0x0c08];
68 u64 spe_execution_status; /* 0x0f00 */
69 u8 padding_0f08[0x1000-0x0f08];
70} __attribute__ ((packed));
71
72
73/**
74 * enum spe_ex_state - Logical spe execution state.
75 * @spe_ex_state_unexecutable: Uninitialized.
76 * @spe_ex_state_executable: Enabled, not ready.
77 * @spe_ex_state_executed: Ready for use.
78 *
79 * The execution state (status) of the logical spe as reported in
80 * struct spe_shadow:spe_execution_status.
81 */
82
83enum spe_ex_state {
84 SPE_EX_STATE_UNEXECUTABLE = 0,
85 SPE_EX_STATE_EXECUTABLE = 2,
86 SPE_EX_STATE_EXECUTED = 3,
87};
88
89/**
90 * struct priv1_cache - Cached values of priv1 registers.
91 * @masks[]: Array of cached spe interrupt masks, indexed by class.
92 * @sr1: Cached mfc_sr1 register.
93 * @tclass_id: Cached mfc_tclass_id register.
94 */
95
96struct priv1_cache {
97 u64 masks[3];
98 u64 sr1;
99 u64 tclass_id;
100};
101
102/**
103 * struct spu_pdata - Platform state variables.
104 * @spe_id: HV spe id returned by lv1_construct_logical_spe().
105 * @resource_id: HV spe resource id returned by
106 * ps3_repository_read_spe_resource_id().
107 * @priv2_addr: lpar address of spe priv2 area returned by
108 * lv1_construct_logical_spe().
109 * @shadow_addr: lpar address of spe register shadow area returned by
110 * lv1_construct_logical_spe().
111 * @shadow: Virtual (ioremap) address of spe register shadow area.
112 * @cache: Cached values of priv1 registers.
113 */
114
115struct spu_pdata {
116 u64 spe_id;
117 u64 resource_id;
118 u64 priv2_addr;
119 u64 shadow_addr;
120 struct spe_shadow __iomem *shadow;
121 struct priv1_cache cache;
122};
123
124static struct spu_pdata *spu_pdata(struct spu *spu)
125{
126 return spu->pdata;
127}
128
129#define dump_areas(_a, _b, _c, _d, _e) \
130 _dump_areas(_a, _b, _c, _d, _e, __func__, __LINE__)
131static void _dump_areas(unsigned int spe_id, unsigned long priv2,
132 unsigned long problem, unsigned long ls, unsigned long shadow,
133 const char* func, int line)
134{
135 pr_debug("%s:%d: spe_id: %xh (%u)\n", func, line, spe_id, spe_id);
136 pr_debug("%s:%d: priv2: %lxh\n", func, line, priv2);
137 pr_debug("%s:%d: problem: %lxh\n", func, line, problem);
138 pr_debug("%s:%d: ls: %lxh\n", func, line, ls);
139 pr_debug("%s:%d: shadow: %lxh\n", func, line, shadow);
140}
141
142static unsigned long get_vas_id(void)
143{
144 unsigned long id;
145
146 lv1_get_logical_ppe_id(&id);
147 lv1_get_virtual_address_space_id_of_ppe(id, &id);
148
149 return id;
150}
151
152static int __init construct_spu(struct spu *spu)
153{
154 int result;
155 unsigned long unused;
156
157 result = lv1_construct_logical_spe(PAGE_SHIFT, PAGE_SHIFT, PAGE_SHIFT,
158 PAGE_SHIFT, PAGE_SHIFT, get_vas_id(), SPE_TYPE_LOGICAL,
159 &spu_pdata(spu)->priv2_addr, &spu->problem_phys,
160 &spu->local_store_phys, &unused,
161 &spu_pdata(spu)->shadow_addr,
162 &spu_pdata(spu)->spe_id);
163
164 if (result) {
165 pr_debug("%s:%d: lv1_construct_logical_spe failed: %s\n",
166 __func__, __LINE__, ps3_result(result));
167 return result;
168 }
169
170 return result;
171}
172
173static int __init add_spu_pages(unsigned long start_addr, unsigned long size)
174{
175 int result;
176 unsigned long start_pfn;
177 unsigned long nr_pages;
178 struct pglist_data *pgdata;
179 struct zone *zone;
180
181 BUG_ON(!mem_init_done);
182
183 start_pfn = start_addr >> PAGE_SHIFT;
184 nr_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
185
186 pgdata = NODE_DATA(0);
187 zone = pgdata->node_zones;
188
189 result = __add_pages(zone, start_pfn, nr_pages);
190
191 if (result)
192 pr_debug("%s:%d: __add_pages failed: (%d)\n",
193 __func__, __LINE__, result);
194
195 return result;
196}
197
198static void spu_unmap(struct spu *spu)
199{
200 iounmap(spu->priv2);
201 iounmap(spu->problem);
202 iounmap((__force u8 __iomem *)spu->local_store);
203 iounmap(spu_pdata(spu)->shadow);
204}
205
206static int __init setup_areas(struct spu *spu)
207{
208 struct table {char* name; unsigned long addr; unsigned long size;};
209 int result;
210
211 /* setup pages */
212
213 result = add_spu_pages(spu->local_store_phys, LS_SIZE);
214 if (result)
215 goto fail_add;
216
217 result = add_spu_pages(spu->problem_phys, sizeof(struct spu_problem));
218 if (result)
219 goto fail_add;
220
221 /* ioremap */
222
223 spu_pdata(spu)->shadow = __ioremap(
224 spu_pdata(spu)->shadow_addr, sizeof(struct spe_shadow),
225 PAGE_READONLY | _PAGE_NO_CACHE | _PAGE_GUARDED);
226 if (!spu_pdata(spu)->shadow) {
227 pr_debug("%s:%d: ioremap shadow failed\n", __func__, __LINE__);
228 goto fail_ioremap;
229 }
230
231 spu->local_store = ioremap(spu->local_store_phys, LS_SIZE);
232 if (!spu->local_store) {
233 pr_debug("%s:%d: ioremap local_store failed\n",
234 __func__, __LINE__);
235 goto fail_ioremap;
236 }
237
238 spu->problem = ioremap(spu->problem_phys,
239 sizeof(struct spu_problem));
240 if (!spu->problem) {
241 pr_debug("%s:%d: ioremap problem failed\n", __func__, __LINE__);
242 goto fail_ioremap;
243 }
244
245 spu->priv2 = ioremap(spu_pdata(spu)->priv2_addr,
246 sizeof(struct spu_priv2));
247 if (!spu->priv2) {
248 pr_debug("%s:%d: ioremap priv2 failed\n", __func__, __LINE__);
249 goto fail_ioremap;
250 }
251
252 dump_areas(spu_pdata(spu)->spe_id, spu_pdata(spu)->priv2_addr,
253 spu->problem_phys, spu->local_store_phys,
254 spu_pdata(spu)->shadow_addr);
255 dump_areas(spu_pdata(spu)->spe_id, (unsigned long)spu->priv2,
256 (unsigned long)spu->problem, (unsigned long)spu->local_store,
257 (unsigned long)spu_pdata(spu)->shadow);
258
259 return 0;
260
261fail_ioremap:
262 spu_unmap(spu);
263fail_add:
264 return result;
265}
266
267static int __init setup_interrupts(struct spu *spu)
268{
269 int result;
270
271 result = ps3_alloc_spe_irq(spu_pdata(spu)->spe_id, 0,
272 &spu->irqs[0]);
273
274 if (result)
275 goto fail_alloc_0;
276
277 result = ps3_alloc_spe_irq(spu_pdata(spu)->spe_id, 1,
278 &spu->irqs[1]);
279
280 if (result)
281 goto fail_alloc_1;
282
283 result = ps3_alloc_spe_irq(spu_pdata(spu)->spe_id, 2,
284 &spu->irqs[2]);
285
286 if (result)
287 goto fail_alloc_2;
288
289 return result;
290
291fail_alloc_2:
292 ps3_free_spe_irq(spu->irqs[1]);
293fail_alloc_1:
294 ps3_free_spe_irq(spu->irqs[0]);
295fail_alloc_0:
296 spu->irqs[0] = spu->irqs[1] = spu->irqs[2] = NO_IRQ;
297 return result;
298}
299
300static int __init enable_spu(struct spu *spu)
301{
302 int result;
303
304 result = lv1_enable_logical_spe(spu_pdata(spu)->spe_id,
305 spu_pdata(spu)->resource_id);
306
307 if (result) {
308 pr_debug("%s:%d: lv1_enable_logical_spe failed: %s\n",
309 __func__, __LINE__, ps3_result(result));
310 goto fail_enable;
311 }
312
313 result = setup_areas(spu);
314
315 if (result)
316 goto fail_areas;
317
318 result = setup_interrupts(spu);
319
320 if (result)
321 goto fail_interrupts;
322
323 return 0;
324
325fail_interrupts:
326 spu_unmap(spu);
327fail_areas:
328 lv1_disable_logical_spe(spu_pdata(spu)->spe_id, 0);
329fail_enable:
330 return result;
331}
332
333static int ps3_destroy_spu(struct spu *spu)
334{
335 int result;
336
337 pr_debug("%s:%d spu_%d\n", __func__, __LINE__, spu->number);
338
339 result = lv1_disable_logical_spe(spu_pdata(spu)->spe_id, 0);
340 BUG_ON(result);
341
342 ps3_free_spe_irq(spu->irqs[2]);
343 ps3_free_spe_irq(spu->irqs[1]);
344 ps3_free_spe_irq(spu->irqs[0]);
345
346 spu->irqs[0] = spu->irqs[1] = spu->irqs[2] = NO_IRQ;
347
348 spu_unmap(spu);
349
350 result = lv1_destruct_logical_spe(spu_pdata(spu)->spe_id);
351 BUG_ON(result);
352
353 kfree(spu->pdata);
354 spu->pdata = NULL;
355
356 return 0;
357}
358
359static int __init ps3_create_spu(struct spu *spu, void *data)
360{
361 int result;
362
363 pr_debug("%s:%d spu_%d\n", __func__, __LINE__, spu->number);
364
365 spu->pdata = kzalloc(sizeof(struct spu_pdata),
366 GFP_KERNEL);
367
368 if (!spu->pdata) {
369 result = -ENOMEM;
370 goto fail_malloc;
371 }
372
373 spu_pdata(spu)->resource_id = (unsigned long)data;
374
375 /* Init cached reg values to HV defaults. */
376
377 spu_pdata(spu)->cache.sr1 = 0x33;
378
379 result = construct_spu(spu);
380
381 if (result)
382 goto fail_construct;
383
384 /* For now, just go ahead and enable it. */
385
386 result = enable_spu(spu);
387
388 if (result)
389 goto fail_enable;
390
391 /* Make sure the spu is in SPE_EX_STATE_EXECUTED. */
392
393 /* need something better here!!! */
394 while (in_be64(&spu_pdata(spu)->shadow->spe_execution_status)
395 != SPE_EX_STATE_EXECUTED)
396 (void)0;
397
398 return result;
399
400fail_enable:
401fail_construct:
402 ps3_destroy_spu(spu);
403fail_malloc:
404 return result;
405}
406
407static int __init ps3_enumerate_spus(int (*fn)(void *data))
408{
409 int result;
410 unsigned int num_resource_id;
411 unsigned int i;
412
413 result = ps3_repository_read_num_spu_resource_id(&num_resource_id);
414
415 pr_debug("%s:%d: num_resource_id %u\n", __func__, __LINE__,
416 num_resource_id);
417
418 /*
419 * For now, just create logical spus equal to the number
420 * of physical spus reserved for the partition.
421 */
422
423 for (i = 0; i < num_resource_id; i++) {
424 enum ps3_spu_resource_type resource_type;
425 unsigned int resource_id;
426
427 result = ps3_repository_read_spu_resource_id(i,
428 &resource_type, &resource_id);
429
430 if (result)
431 break;
432
433 if (resource_type == PS3_SPU_RESOURCE_TYPE_EXCLUSIVE) {
434 result = fn((void*)(unsigned long)resource_id);
435
436 if (result)
437 break;
438 }
439 }
440
441 if (result)
442 printk(KERN_WARNING "%s:%d: Error initializing spus\n",
443 __func__, __LINE__);
444
445 return result;
446}
447
448const struct spu_management_ops spu_management_ps3_ops = {
449 .enumerate_spus = ps3_enumerate_spus,
450 .create_spu = ps3_create_spu,
451 .destroy_spu = ps3_destroy_spu,
452};
453
454/* spu_priv1_ops */
455
456static void int_mask_and(struct spu *spu, int class, u64 mask)
457{
458 u64 old_mask;
459
460 /* are these serialized by caller??? */
461 old_mask = spu_int_mask_get(spu, class);
462 spu_int_mask_set(spu, class, old_mask & mask);
463}
464
465static void int_mask_or(struct spu *spu, int class, u64 mask)
466{
467 u64 old_mask;
468
469 old_mask = spu_int_mask_get(spu, class);
470 spu_int_mask_set(spu, class, old_mask | mask);
471}
472
473static void int_mask_set(struct spu *spu, int class, u64 mask)
474{
475 spu_pdata(spu)->cache.masks[class] = mask;
476 lv1_set_spe_interrupt_mask(spu_pdata(spu)->spe_id, class,
477 spu_pdata(spu)->cache.masks[class]);
478}
479
480static u64 int_mask_get(struct spu *spu, int class)
481{
482 return spu_pdata(spu)->cache.masks[class];
483}
484
485static void int_stat_clear(struct spu *spu, int class, u64 stat)
486{
487 /* Note that MFC_DSISR will be cleared when class1[MF] is set. */
488
489 lv1_clear_spe_interrupt_status(spu_pdata(spu)->spe_id, class,
490 stat, 0);
491}
492
493static u64 int_stat_get(struct spu *spu, int class)
494{
495 u64 stat;
496
497 lv1_get_spe_interrupt_status(spu_pdata(spu)->spe_id, class, &stat);
498 return stat;
499}
500
501static void cpu_affinity_set(struct spu *spu, int cpu)
502{
503 /* No support. */
504}
505
506static u64 mfc_dar_get(struct spu *spu)
507{
508 return in_be64(&spu_pdata(spu)->shadow->mfc_dar_RW);
509}
510
511static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
512{
513 /* Nothing to do, cleared in int_stat_clear(). */
514}
515
516static u64 mfc_dsisr_get(struct spu *spu)
517{
518 return in_be64(&spu_pdata(spu)->shadow->mfc_dsisr_RW);
519}
520
521static void mfc_sdr_setup(struct spu *spu)
522{
523 /* Nothing to do. */
524}
525
526static void mfc_sr1_set(struct spu *spu, u64 sr1)
527{
528 /* Check bits allowed by HV. */
529
530 static const u64 allowed = ~(MFC_STATE1_LOCAL_STORAGE_DECODE_MASK
531 | MFC_STATE1_PROBLEM_STATE_MASK);
532
533 BUG_ON((sr1 & allowed) != (spu_pdata(spu)->cache.sr1 & allowed));
534
535 spu_pdata(spu)->cache.sr1 = sr1;
536 lv1_set_spe_privilege_state_area_1_register(
537 spu_pdata(spu)->spe_id,
538 offsetof(struct spu_priv1, mfc_sr1_RW),
539 spu_pdata(spu)->cache.sr1);
540}
541
542static u64 mfc_sr1_get(struct spu *spu)
543{
544 return spu_pdata(spu)->cache.sr1;
545}
546
547static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
548{
549 spu_pdata(spu)->cache.tclass_id = tclass_id;
550 lv1_set_spe_privilege_state_area_1_register(
551 spu_pdata(spu)->spe_id,
552 offsetof(struct spu_priv1, mfc_tclass_id_RW),
553 spu_pdata(spu)->cache.tclass_id);
554}
555
556static u64 mfc_tclass_id_get(struct spu *spu)
557{
558 return spu_pdata(spu)->cache.tclass_id;
559}
560
561static void tlb_invalidate(struct spu *spu)
562{
563 /* Nothing to do. */
564}
565
566static void resource_allocation_groupID_set(struct spu *spu, u64 id)
567{
568 /* No support. */
569}
570
571static u64 resource_allocation_groupID_get(struct spu *spu)
572{
573 return 0; /* No support. */
574}
575
576static void resource_allocation_enable_set(struct spu *spu, u64 enable)
577{
578 /* No support. */
579}
580
581static u64 resource_allocation_enable_get(struct spu *spu)
582{
583 return 0; /* No support. */
584}
585
586const struct spu_priv1_ops spu_priv1_ps3_ops = {
587 .int_mask_and = int_mask_and,
588 .int_mask_or = int_mask_or,
589 .int_mask_set = int_mask_set,
590 .int_mask_get = int_mask_get,
591 .int_stat_clear = int_stat_clear,
592 .int_stat_get = int_stat_get,
593 .cpu_affinity_set = cpu_affinity_set,
594 .mfc_dar_get = mfc_dar_get,
595 .mfc_dsisr_set = mfc_dsisr_set,
596 .mfc_dsisr_get = mfc_dsisr_get,
597 .mfc_sdr_setup = mfc_sdr_setup,
598 .mfc_sr1_set = mfc_sr1_set,
599 .mfc_sr1_get = mfc_sr1_get,
600 .mfc_tclass_id_set = mfc_tclass_id_set,
601 .mfc_tclass_id_get = mfc_tclass_id_get,
602 .tlb_invalidate = tlb_invalidate,
603 .resource_allocation_groupID_set = resource_allocation_groupID_set,
604 .resource_allocation_groupID_get = resource_allocation_groupID_get,
605 .resource_allocation_enable_set = resource_allocation_enable_set,
606 .resource_allocation_enable_get = resource_allocation_enable_get,
607};
608
609void ps3_spu_set_platform(void)
610{
611 spu_priv1_ops = &spu_priv1_ps3_ops;
612 spu_management_ops = &spu_management_ps3_ops;
613}
diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c
new file mode 100644
index 000000000000..1bae8b19b363
--- /dev/null
+++ b/arch/powerpc/platforms/ps3/time.c
@@ -0,0 +1,104 @@
1/*
2 * PS3 time and rtc routines.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22
23#include <asm/rtc.h>
24#include <asm/lv1call.h>
25#include <asm/ps3.h>
26
27#include "platform.h"
28
29#define dump_tm(_a) _dump_tm(_a, __func__, __LINE__)
30static void _dump_tm(const struct rtc_time *tm, const char* func, int line)
31{
32 pr_debug("%s:%d tm_sec %d\n", func, line, tm->tm_sec);
33 pr_debug("%s:%d tm_min %d\n", func, line, tm->tm_min);
34 pr_debug("%s:%d tm_hour %d\n", func, line, tm->tm_hour);
35 pr_debug("%s:%d tm_mday %d\n", func, line, tm->tm_mday);
36 pr_debug("%s:%d tm_mon %d\n", func, line, tm->tm_mon);
37 pr_debug("%s:%d tm_year %d\n", func, line, tm->tm_year);
38 pr_debug("%s:%d tm_wday %d\n", func, line, tm->tm_wday);
39}
40
41#define dump_time(_a) _dump_time(_a, __func__, __LINE__)
42static void __attribute__ ((unused)) _dump_time(int time, const char* func,
43 int line)
44{
45 struct rtc_time tm;
46
47 to_tm(time, &tm);
48
49 pr_debug("%s:%d time %d\n", func, line, time);
50 _dump_tm(&tm, func, line);
51}
52
53/**
54 * rtc_shift - Difference in seconds between 1970 and the ps3 rtc value.
55 */
56
57static s64 rtc_shift;
58
59void __init ps3_calibrate_decr(void)
60{
61 int result;
62 u64 tmp;
63
64 result = ps3_repository_read_be_tb_freq(0, &tmp);
65 BUG_ON(result);
66
67 ppc_tb_freq = tmp;
68 ppc_proc_freq = ppc_tb_freq * 40;
69
70 rtc_shift = ps3_os_area_rtc_diff();
71}
72
73static u64 read_rtc(void)
74{
75 int result;
76 u64 rtc_val;
77 u64 tb_val;
78
79 result = lv1_get_rtc(&rtc_val, &tb_val);
80 BUG_ON(result);
81
82 return rtc_val;
83}
84
85int ps3_set_rtc_time(struct rtc_time *tm)
86{
87 u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
88 tm->tm_hour, tm->tm_min, tm->tm_sec);
89
90 rtc_shift = now - read_rtc();
91 return 0;
92}
93
94void ps3_get_rtc_time(struct rtc_time *tm)
95{
96 to_tm(read_rtc() + rtc_shift, tm);
97 tm->tm_year -= 1900;
98 tm->tm_mon -= 1;
99}
100
101unsigned long __init ps3_get_boot_time(void)
102{
103 return read_rtc() + rtc_shift;
104}
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 137077451316..49037edf7d39 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -37,8 +37,8 @@
37/* EEH event workqueue setup. */ 37/* EEH event workqueue setup. */
38static DEFINE_SPINLOCK(eeh_eventlist_lock); 38static DEFINE_SPINLOCK(eeh_eventlist_lock);
39LIST_HEAD(eeh_eventlist); 39LIST_HEAD(eeh_eventlist);
40static void eeh_thread_launcher(void *); 40static void eeh_thread_launcher(struct work_struct *);
41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher, NULL); 41DECLARE_WORK(eeh_event_wq, eeh_thread_launcher);
42 42
43/* Serialize reset sequences for a given pci device */ 43/* Serialize reset sequences for a given pci device */
44DEFINE_MUTEX(eeh_event_mutex); 44DEFINE_MUTEX(eeh_event_mutex);
@@ -103,7 +103,7 @@ static int eeh_event_handler(void * dummy)
103 * eeh_thread_launcher 103 * eeh_thread_launcher
104 * @dummy - unused 104 * @dummy - unused
105 */ 105 */
106static void eeh_thread_launcher(void *dummy) 106static void eeh_thread_launcher(struct work_struct *dummy)
107{ 107{
108 if (kernel_thread(eeh_event_handler, NULL, CLONE_KERNEL) < 0) 108 if (kernel_thread(eeh_event_handler, NULL, CLONE_KERNEL) < 0)
109 printk(KERN_ERR "Failed to start EEH daemon\n"); 109 printk(KERN_ERR "Failed to start EEH daemon\n");
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 556c279a789d..3c95392f4f41 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -309,7 +309,7 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb,
309 tbl->it_size = size >> IOMMU_PAGE_SHIFT; 309 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
310} 310}
311 311
312static void iommu_bus_setup_pSeries(struct pci_bus *bus) 312static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)
313{ 313{
314 struct device_node *dn; 314 struct device_node *dn;
315 struct iommu_table *tbl; 315 struct iommu_table *tbl;
@@ -318,10 +318,9 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus)
318 struct pci_dn *pci; 318 struct pci_dn *pci;
319 int children; 319 int children;
320 320
321 DBG("iommu_bus_setup_pSeries, bus %p, bus->self %p\n", bus, bus->self);
322
323 dn = pci_bus_to_OF_node(bus); 321 dn = pci_bus_to_OF_node(bus);
324 pci = PCI_DN(dn); 322
323 DBG("pci_dma_bus_setup_pSeries: setting up bus %s\n", dn->full_name);
325 324
326 if (bus->self) { 325 if (bus->self) {
327 /* This is not a root bus, any setup will be done for the 326 /* This is not a root bus, any setup will be done for the
@@ -329,6 +328,7 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus)
329 */ 328 */
330 return; 329 return;
331 } 330 }
331 pci = PCI_DN(dn);
332 332
333 /* Check if the ISA bus on the system is under 333 /* Check if the ISA bus on the system is under
334 * this PHB. 334 * this PHB.
@@ -390,17 +390,17 @@ static void iommu_bus_setup_pSeries(struct pci_bus *bus)
390} 390}
391 391
392 392
393static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus) 393static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
394{ 394{
395 struct iommu_table *tbl; 395 struct iommu_table *tbl;
396 struct device_node *dn, *pdn; 396 struct device_node *dn, *pdn;
397 struct pci_dn *ppci; 397 struct pci_dn *ppci;
398 const void *dma_window = NULL; 398 const void *dma_window = NULL;
399 399
400 DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self);
401
402 dn = pci_bus_to_OF_node(bus); 400 dn = pci_bus_to_OF_node(bus);
403 401
402 DBG("pci_dma_bus_setup_pSeriesLP: setting up bus %s\n", dn->full_name);
403
404 /* Find nearest ibm,dma-window, walking up the device tree */ 404 /* Find nearest ibm,dma-window, walking up the device tree */
405 for (pdn = dn; pdn != NULL; pdn = pdn->parent) { 405 for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
406 dma_window = get_property(pdn, "ibm,dma-window", NULL); 406 dma_window = get_property(pdn, "ibm,dma-window", NULL);
@@ -409,11 +409,15 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
409 } 409 }
410 410
411 if (dma_window == NULL) { 411 if (dma_window == NULL) {
412 DBG("iommu_bus_setup_pSeriesLP: bus %s seems to have no ibm,dma-window property\n", dn->full_name); 412 DBG(" no ibm,dma-window property !\n");
413 return; 413 return;
414 } 414 }
415 415
416 ppci = PCI_DN(pdn); 416 ppci = PCI_DN(pdn);
417
418 DBG(" parent is %s, iommu_table: 0x%p\n",
419 pdn->full_name, ppci->iommu_table);
420
417 if (!ppci->iommu_table) { 421 if (!ppci->iommu_table) {
418 /* Bussubno hasn't been copied yet. 422 /* Bussubno hasn't been copied yet.
419 * Do it now because iommu_table_setparms_lpar needs it. 423 * Do it now because iommu_table_setparms_lpar needs it.
@@ -427,6 +431,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
427 iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window); 431 iommu_table_setparms_lpar(ppci->phb, pdn, tbl, dma_window);
428 432
429 ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node); 433 ppci->iommu_table = iommu_init_table(tbl, ppci->phb->node);
434 DBG(" created table: %p\n", ppci->iommu_table);
430 } 435 }
431 436
432 if (pdn != dn) 437 if (pdn != dn)
@@ -434,27 +439,27 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
434} 439}
435 440
436 441
437static void iommu_dev_setup_pSeries(struct pci_dev *dev) 442static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
438{ 443{
439 struct device_node *dn, *mydn; 444 struct device_node *dn;
440 struct iommu_table *tbl; 445 struct iommu_table *tbl;
441 446
442 DBG("iommu_dev_setup_pSeries, dev %p (%s)\n", dev, pci_name(dev)); 447 DBG("pci_dma_dev_setup_pSeries: %s\n", pci_name(dev));
443 448
444 mydn = dn = pci_device_to_OF_node(dev); 449 dn = dev->dev.archdata.of_node;
445 450
446 /* If we're the direct child of a root bus, then we need to allocate 451 /* If we're the direct child of a root bus, then we need to allocate
447 * an iommu table ourselves. The bus setup code should have setup 452 * an iommu table ourselves. The bus setup code should have setup
448 * the window sizes already. 453 * the window sizes already.
449 */ 454 */
450 if (!dev->bus->self) { 455 if (!dev->bus->self) {
456 struct pci_controller *phb = PCI_DN(dn)->phb;
457
451 DBG(" --> first child, no bridge. Allocating iommu table.\n"); 458 DBG(" --> first child, no bridge. Allocating iommu table.\n");
452 tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL, 459 tbl = kmalloc_node(sizeof(struct iommu_table), GFP_KERNEL,
453 PCI_DN(dn)->phb->node); 460 phb->node);
454 iommu_table_setparms(PCI_DN(dn)->phb, dn, tbl); 461 iommu_table_setparms(phb, dn, tbl);
455 PCI_DN(dn)->iommu_table = iommu_init_table(tbl, 462 dev->dev.archdata.dma_data = iommu_init_table(tbl, phb->node);
456 PCI_DN(dn)->phb->node);
457
458 return; 463 return;
459 } 464 }
460 465
@@ -465,11 +470,11 @@ static void iommu_dev_setup_pSeries(struct pci_dev *dev)
465 while (dn && PCI_DN(dn) && PCI_DN(dn)->iommu_table == NULL) 470 while (dn && PCI_DN(dn) && PCI_DN(dn)->iommu_table == NULL)
466 dn = dn->parent; 471 dn = dn->parent;
467 472
468 if (dn && PCI_DN(dn)) { 473 if (dn && PCI_DN(dn))
469 PCI_DN(mydn)->iommu_table = PCI_DN(dn)->iommu_table; 474 dev->dev.archdata.dma_data = PCI_DN(dn)->iommu_table;
470 } else { 475 else
471 DBG("iommu_dev_setup_pSeries, dev %p (%s) has no iommu table\n", dev, pci_name(dev)); 476 printk(KERN_WARNING "iommu: Device %s has no iommu table\n",
472 } 477 pci_name(dev));
473} 478}
474 479
475static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node) 480static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
@@ -495,13 +500,15 @@ static struct notifier_block iommu_reconfig_nb = {
495 .notifier_call = iommu_reconfig_notifier, 500 .notifier_call = iommu_reconfig_notifier,
496}; 501};
497 502
498static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev) 503static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
499{ 504{
500 struct device_node *pdn, *dn; 505 struct device_node *pdn, *dn;
501 struct iommu_table *tbl; 506 struct iommu_table *tbl;
502 const void *dma_window = NULL; 507 const void *dma_window = NULL;
503 struct pci_dn *pci; 508 struct pci_dn *pci;
504 509
510 DBG("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev));
511
505 /* dev setup for LPAR is a little tricky, since the device tree might 512 /* dev setup for LPAR is a little tricky, since the device tree might
506 * contain the dma-window properties per-device and not neccesarily 513 * contain the dma-window properties per-device and not neccesarily
507 * for the bus. So we need to search upwards in the tree until we 514 * for the bus. So we need to search upwards in the tree until we
@@ -509,9 +516,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
509 * already allocated. 516 * already allocated.
510 */ 517 */
511 dn = pci_device_to_OF_node(dev); 518 dn = pci_device_to_OF_node(dev);
512 519 DBG(" node is %s\n", dn->full_name);
513 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s) %s\n",
514 dev, pci_name(dev), dn->full_name);
515 520
516 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table; 521 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
517 pdn = pdn->parent) { 522 pdn = pdn->parent) {
@@ -520,16 +525,17 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
520 break; 525 break;
521 } 526 }
522 527
528 DBG(" parent is %s\n", pdn->full_name);
529
523 /* Check for parent == NULL so we don't try to setup the empty EADS 530 /* Check for parent == NULL so we don't try to setup the empty EADS
524 * slots on POWER4 machines. 531 * slots on POWER4 machines.
525 */ 532 */
526 if (dma_window == NULL || pdn->parent == NULL) { 533 if (dma_window == NULL || pdn->parent == NULL) {
527 DBG("No dma window for device, linking to parent\n"); 534 DBG(" no dma window for device, linking to parent\n");
528 PCI_DN(dn)->iommu_table = PCI_DN(pdn)->iommu_table; 535 dev->dev.archdata.dma_data = PCI_DN(pdn)->iommu_table;
529 return; 536 return;
530 } else {
531 DBG("Found DMA window, allocating table\n");
532 } 537 }
538 DBG(" found DMA window, table: %p\n", pci->iommu_table);
533 539
534 pci = PCI_DN(pdn); 540 pci = PCI_DN(pdn);
535 if (!pci->iommu_table) { 541 if (!pci->iommu_table) {
@@ -542,24 +548,20 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
542 iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window); 548 iommu_table_setparms_lpar(pci->phb, pdn, tbl, dma_window);
543 549
544 pci->iommu_table = iommu_init_table(tbl, pci->phb->node); 550 pci->iommu_table = iommu_init_table(tbl, pci->phb->node);
551 DBG(" created table: %p\n", pci->iommu_table);
545 } 552 }
546 553
547 if (pdn != dn) 554 dev->dev.archdata.dma_data = pci->iommu_table;
548 PCI_DN(dn)->iommu_table = pci->iommu_table;
549} 555}
550 556
551static void iommu_bus_setup_null(struct pci_bus *b) { }
552static void iommu_dev_setup_null(struct pci_dev *d) { }
553
554/* These are called very early. */ 557/* These are called very early. */
555void iommu_init_early_pSeries(void) 558void iommu_init_early_pSeries(void)
556{ 559{
557 if (of_chosen && get_property(of_chosen, "linux,iommu-off", NULL)) { 560 if (of_chosen && get_property(of_chosen, "linux,iommu-off", NULL)) {
558 /* Direct I/O, IOMMU off */ 561 /* Direct I/O, IOMMU off */
559 ppc_md.iommu_dev_setup = iommu_dev_setup_null; 562 ppc_md.pci_dma_dev_setup = NULL;
560 ppc_md.iommu_bus_setup = iommu_bus_setup_null; 563 ppc_md.pci_dma_bus_setup = NULL;
561 pci_direct_iommu_init(); 564 pci_dma_ops = &dma_direct_ops;
562
563 return; 565 return;
564 } 566 }
565 567
@@ -572,19 +574,19 @@ void iommu_init_early_pSeries(void)
572 ppc_md.tce_free = tce_free_pSeriesLP; 574 ppc_md.tce_free = tce_free_pSeriesLP;
573 } 575 }
574 ppc_md.tce_get = tce_get_pSeriesLP; 576 ppc_md.tce_get = tce_get_pSeriesLP;
575 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeriesLP; 577 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeriesLP;
576 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeriesLP; 578 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeriesLP;
577 } else { 579 } else {
578 ppc_md.tce_build = tce_build_pSeries; 580 ppc_md.tce_build = tce_build_pSeries;
579 ppc_md.tce_free = tce_free_pSeries; 581 ppc_md.tce_free = tce_free_pSeries;
580 ppc_md.tce_get = tce_get_pseries; 582 ppc_md.tce_get = tce_get_pseries;
581 ppc_md.iommu_bus_setup = iommu_bus_setup_pSeries; 583 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeries;
582 ppc_md.iommu_dev_setup = iommu_dev_setup_pSeries; 584 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeries;
583 } 585 }
584 586
585 587
586 pSeries_reconfig_notifier_register(&iommu_reconfig_nb); 588 pSeries_reconfig_notifier_register(&iommu_reconfig_nb);
587 589
588 pci_iommu_init(); 590 pci_dma_ops = &dma_iommu_ops;
589} 591}
590 592
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 1820a0b0a8c6..721436db3ef0 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -282,7 +282,7 @@ void vpa_init(int cpu)
282 } 282 }
283} 283}
284 284
285long pSeries_lpar_hpte_insert(unsigned long hpte_group, 285static long pSeries_lpar_hpte_insert(unsigned long hpte_group,
286 unsigned long va, unsigned long pa, 286 unsigned long va, unsigned long pa,
287 unsigned long rflags, unsigned long vflags, 287 unsigned long rflags, unsigned long vflags,
288 int psize) 288 int psize)
@@ -506,7 +506,7 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va,
506 * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie 506 * Take a spinlock around flushes to avoid bouncing the hypervisor tlbie
507 * lock. 507 * lock.
508 */ 508 */
509void pSeries_lpar_flush_hash_range(unsigned long number, int local) 509static void pSeries_lpar_flush_hash_range(unsigned long number, int local)
510{ 510{
511 int i; 511 int i;
512 unsigned long flags = 0; 512 unsigned long flags = 0;
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 410a6bcc4ca0..715db5c89908 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -29,8 +29,6 @@
29#include <asm/prom.h> 29#include <asm/prom.h>
30#include <asm/ppc-pci.h> 30#include <asm/ppc-pci.h>
31 31
32static int __devinitdata s7a_workaround = -1;
33
34#if 0 32#if 0
35void pcibios_name_device(struct pci_dev *dev) 33void pcibios_name_device(struct pci_dev *dev)
36{ 34{
@@ -57,39 +55,6 @@ void pcibios_name_device(struct pci_dev *dev)
57DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device); 55DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
58#endif 56#endif
59 57
60static void __devinit check_s7a(void)
61{
62 struct device_node *root;
63 const char *model;
64
65 s7a_workaround = 0;
66 root = of_find_node_by_path("/");
67 if (root) {
68 model = get_property(root, "model", NULL);
69 if (model && !strcmp(model, "IBM,7013-S7A"))
70 s7a_workaround = 1;
71 of_node_put(root);
72 }
73}
74
75void __devinit pSeries_irq_bus_setup(struct pci_bus *bus)
76{
77 struct pci_dev *dev;
78
79 if (s7a_workaround < 0)
80 check_s7a();
81 list_for_each_entry(dev, &bus->devices, bus_list) {
82 pci_read_irq_line(dev);
83 if (s7a_workaround) {
84 if (dev->irq > 16) {
85 dev->irq -= 3;
86 pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
87 dev->irq);
88 }
89 }
90 }
91}
92
93static void __init pSeries_request_regions(void) 58static void __init pSeries_request_regions(void)
94{ 59{
95 if (!isa_io_base) 60 if (!isa_io_base)
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index 6bfacc217085..ac56b868913a 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -93,8 +93,8 @@ pcibios_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
93 if (list_empty(&dev->global_list)) { 93 if (list_empty(&dev->global_list)) {
94 int i; 94 int i;
95 95
96 /* Need to setup IOMMU tables */ 96 /* Fill device archdata and setup iommu table */
97 ppc_md.iommu_dev_setup(dev); 97 pcibios_setup_new_device(dev);
98 98
99 if(fix_bus) 99 if(fix_bus)
100 pcibios_fixup_device_resources(dev, bus); 100 pcibios_fixup_device_resources(dev, bus);
@@ -195,7 +195,7 @@ struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn)
195 phb = pcibios_alloc_controller(dn); 195 phb = pcibios_alloc_controller(dn);
196 if (!phb) 196 if (!phb)
197 return NULL; 197 return NULL;
198 setup_phb(dn, phb); 198 rtas_setup_phb(phb);
199 pci_process_bridge_OF_ranges(phb, dn, 0); 199 pci_process_bridge_OF_ranges(phb, dn, 0);
200 200
201 pci_setup_phb_io_dynamic(phb, primary); 201 pci_setup_phb_io_dynamic(phb, primary);
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 1773103354be..4ad33e41b008 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -268,11 +268,10 @@ static char * parse_next_property(char *buf, char *end, char **name, int *length
268static struct property *new_property(const char *name, const int length, 268static struct property *new_property(const char *name, const int length,
269 const unsigned char *value, struct property *last) 269 const unsigned char *value, struct property *last)
270{ 270{
271 struct property *new = kmalloc(sizeof(*new), GFP_KERNEL); 271 struct property *new = kzalloc(sizeof(*new), GFP_KERNEL);
272 272
273 if (!new) 273 if (!new)
274 return NULL; 274 return NULL;
275 memset(new, 0, sizeof(*new));
276 275
277 if (!(new->name = kmalloc(strlen(name) + 1, GFP_KERNEL))) 276 if (!(new->name = kmalloc(strlen(name) + 1, GFP_KERNEL)))
278 goto cleanup; 277 goto cleanup;
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 89a8119f988d..0dc2548ca9bc 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -347,6 +347,7 @@ static int __init pSeries_init_panel(void)
347} 347}
348arch_initcall(pSeries_init_panel); 348arch_initcall(pSeries_init_panel);
349 349
350#ifdef CONFIG_HOTPLUG_CPU
350static void pSeries_mach_cpu_die(void) 351static void pSeries_mach_cpu_die(void)
351{ 352{
352 local_irq_disable(); 353 local_irq_disable();
@@ -357,6 +358,9 @@ static void pSeries_mach_cpu_die(void)
357 BUG(); 358 BUG();
358 for(;;); 359 for(;;);
359} 360}
361#else
362#define pSeries_mach_cpu_die NULL
363#endif
360 364
361static int pseries_set_dabr(unsigned long dabr) 365static int pseries_set_dabr(unsigned long dabr)
362{ 366{
@@ -553,7 +557,6 @@ define_machine(pseries) {
553 .log_error = pSeries_log_error, 557 .log_error = pSeries_log_error,
554 .pcibios_fixup = pSeries_final_fixup, 558 .pcibios_fixup = pSeries_final_fixup,
555 .pci_probe_mode = pSeries_pci_probe_mode, 559 .pci_probe_mode = pSeries_pci_probe_mode,
556 .irq_bus_setup = pSeries_irq_bus_setup,
557 .restart = rtas_restart, 560 .restart = rtas_restart,
558 .power_off = rtas_power_off, 561 .power_off = rtas_power_off,
559 .halt = rtas_halt, 562 .halt = rtas_halt,
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index d071abe78ab1..b5b2b1103de8 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -656,13 +656,38 @@ static void __init xics_setup_8259_cascade(void)
656 set_irq_chained_handler(cascade, pseries_8259_cascade); 656 set_irq_chained_handler(cascade, pseries_8259_cascade);
657} 657}
658 658
659static struct device_node *cpuid_to_of_node(int cpu)
660{
661 struct device_node *np;
662 u32 hcpuid = get_hard_smp_processor_id(cpu);
663
664 for_each_node_by_type(np, "cpu") {
665 int i, len;
666 const u32 *intserv;
667
668 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len);
669
670 if (!intserv)
671 intserv = get_property(np, "reg", &len);
672
673 i = len / sizeof(u32);
674
675 while (i--)
676 if (intserv[i] == hcpuid)
677 return np;
678 }
679
680 return NULL;
681}
682
659void __init xics_init_IRQ(void) 683void __init xics_init_IRQ(void)
660{ 684{
661 int i; 685 int i, j;
662 struct device_node *np; 686 struct device_node *np;
663 u32 ilen, indx = 0; 687 u32 ilen, indx = 0;
664 const u32 *ireg; 688 const u32 *ireg, *isize;
665 int found = 0; 689 int found = 0;
690 u32 hcpuid;
666 691
667 ppc64_boot_msg(0x20, "XICS Init"); 692 ppc64_boot_msg(0x20, "XICS Init");
668 693
@@ -683,26 +708,31 @@ void __init xics_init_IRQ(void)
683 xics_init_host(); 708 xics_init_host();
684 709
685 /* Find the server numbers for the boot cpu. */ 710 /* Find the server numbers for the boot cpu. */
686 for (np = of_find_node_by_type(NULL, "cpu"); 711 np = cpuid_to_of_node(boot_cpuid);
687 np; 712 BUG_ON(!np);
688 np = of_find_node_by_type(np, "cpu")) { 713 ireg = get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
689 ireg = get_property(np, "reg", &ilen); 714 if (!ireg)
690 if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) { 715 goto skip_gserver_check;
691 ireg = get_property(np, 716 i = ilen / sizeof(int);
692 "ibm,ppc-interrupt-gserver#s", &ilen); 717 hcpuid = get_hard_smp_processor_id(boot_cpuid);
693 i = ilen / sizeof(int); 718
694 if (ireg && i > 0) { 719 /* Global interrupt distribution server is specified in the last
695 default_server = ireg[0]; 720 * entry of "ibm,ppc-interrupt-gserver#s" property. Get the last
696 /* take last element */ 721 * entry fom this property for current boot cpu id and use it as
697 default_distrib_server = ireg[i-1]; 722 * default distribution server
698 } 723 */
699 ireg = get_property(np, 724 for (j = 0; j < i; j += 2) {
725 if (ireg[j] == hcpuid) {
726 default_server = hcpuid;
727 default_distrib_server = ireg[j+1];
728
729 isize = get_property(np,
700 "ibm,interrupt-server#-size", NULL); 730 "ibm,interrupt-server#-size", NULL);
701 if (ireg) 731 if (isize)
702 interrupt_server_size = *ireg; 732 interrupt_server_size = *isize;
703 break;
704 } 733 }
705 } 734 }
735skip_gserver_check:
706 of_node_put(np); 736 of_node_put(np);
707 737
708 if (firmware_has_feature(FW_FEATURE_LPAR)) 738 if (firmware_has_feature(FW_FEATURE_LPAR))
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 91f052d8cce0..6cc34597a620 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -5,14 +5,13 @@ endif
5obj-$(CONFIG_MPIC) += mpic.o 5obj-$(CONFIG_MPIC) += mpic.o
6obj-$(CONFIG_PPC_INDIRECT_PCI) += indirect_pci.o 6obj-$(CONFIG_PPC_INDIRECT_PCI) += indirect_pci.o
7obj-$(CONFIG_PPC_MPC106) += grackle.o 7obj-$(CONFIG_PPC_MPC106) += grackle.o
8obj-$(CONFIG_BOOKE) += dcr.o 8obj-$(CONFIG_PPC_DCR) += dcr.o dcr-low.o
9obj-$(CONFIG_40x) += dcr.o
10obj-$(CONFIG_U3_DART) += dart_iommu.o 9obj-$(CONFIG_U3_DART) += dart_iommu.o
11obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o 10obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
12obj-$(CONFIG_FSL_SOC) += fsl_soc.o 11obj-$(CONFIG_FSL_SOC) += fsl_soc.o
13obj-$(CONFIG_PPC_TODC) += todc.o
14obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o 12obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
15obj-$(CONFIG_QUICC_ENGINE) += qe_lib/ 13obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
14obj-$(CONFIG_MTD) += rom.o
16 15
17ifeq ($(CONFIG_PPC_MERGE),y) 16ifeq ($(CONFIG_PPC_MERGE),y)
18obj-$(CONFIG_PPC_I8259) += i8259.o 17obj-$(CONFIG_PPC_I8259) += i8259.o
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 572b7846cc77..1488535b0e13 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -48,9 +48,6 @@
48 48
49#include "dart.h" 49#include "dart.h"
50 50
51extern int iommu_is_off;
52extern int iommu_force_on;
53
54/* Physical base address and size of the DART table */ 51/* Physical base address and size of the DART table */
55unsigned long dart_tablebase; /* exported to htab_initialize */ 52unsigned long dart_tablebase; /* exported to htab_initialize */
56static unsigned long dart_tablesize; 53static unsigned long dart_tablesize;
@@ -289,24 +286,15 @@ static void iommu_table_dart_setup(void)
289 set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map); 286 set_bit(iommu_table_dart.it_size - 1, iommu_table_dart.it_map);
290} 287}
291 288
292static void iommu_dev_setup_dart(struct pci_dev *dev) 289static void pci_dma_dev_setup_dart(struct pci_dev *dev)
293{ 290{
294 struct device_node *dn;
295
296 /* We only have one iommu table on the mac for now, which makes 291 /* We only have one iommu table on the mac for now, which makes
297 * things simple. Setup all PCI devices to point to this table 292 * things simple. Setup all PCI devices to point to this table
298 *
299 * We must use pci_device_to_OF_node() to make sure that
300 * we get the real "final" pointer to the device in the
301 * pci_dev sysdata and not the temporary PHB one
302 */ 293 */
303 dn = pci_device_to_OF_node(dev); 294 dev->dev.archdata.dma_data = &iommu_table_dart;
304
305 if (dn)
306 PCI_DN(dn)->iommu_table = &iommu_table_dart;
307} 295}
308 296
309static void iommu_bus_setup_dart(struct pci_bus *bus) 297static void pci_dma_bus_setup_dart(struct pci_bus *bus)
310{ 298{
311 struct device_node *dn; 299 struct device_node *dn;
312 300
@@ -321,9 +309,6 @@ static void iommu_bus_setup_dart(struct pci_bus *bus)
321 PCI_DN(dn)->iommu_table = &iommu_table_dart; 309 PCI_DN(dn)->iommu_table = &iommu_table_dart;
322} 310}
323 311
324static void iommu_dev_setup_null(struct pci_dev *dev) { }
325static void iommu_bus_setup_null(struct pci_bus *bus) { }
326
327void iommu_init_early_dart(void) 312void iommu_init_early_dart(void)
328{ 313{
329 struct device_node *dn; 314 struct device_node *dn;
@@ -344,22 +329,21 @@ void iommu_init_early_dart(void)
344 329
345 /* Initialize the DART HW */ 330 /* Initialize the DART HW */
346 if (dart_init(dn) == 0) { 331 if (dart_init(dn) == 0) {
347 ppc_md.iommu_dev_setup = iommu_dev_setup_dart; 332 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart;
348 ppc_md.iommu_bus_setup = iommu_bus_setup_dart; 333 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart;
349 334
350 /* Setup pci_dma ops */ 335 /* Setup pci_dma ops */
351 pci_iommu_init(); 336 pci_dma_ops = &dma_iommu_ops;
352
353 return; 337 return;
354 } 338 }
355 339
356 bail: 340 bail:
357 /* If init failed, use direct iommu and null setup functions */ 341 /* If init failed, use direct iommu and null setup functions */
358 ppc_md.iommu_dev_setup = iommu_dev_setup_null; 342 ppc_md.pci_dma_dev_setup = NULL;
359 ppc_md.iommu_bus_setup = iommu_bus_setup_null; 343 ppc_md.pci_dma_bus_setup = NULL;
360 344
361 /* Setup pci_dma ops */ 345 /* Setup pci_dma ops */
362 pci_direct_iommu_init(); 346 pci_dma_ops = &dma_direct_ops;
363} 347}
364 348
365 349
diff --git a/arch/powerpc/sysdev/dcr-low.S b/arch/powerpc/sysdev/dcr-low.S
new file mode 100644
index 000000000000..2078f39e2f17
--- /dev/null
+++ b/arch/powerpc/sysdev/dcr-low.S
@@ -0,0 +1,39 @@
1/*
2 * "Indirect" DCR access
3 *
4 * Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <asm/ppc_asm.h>
13#include <asm/processor.h>
14
15#define DCR_ACCESS_PROLOG(table) \
16 rlwinm r3,r3,4,18,27; \
17 lis r5,table@h; \
18 ori r5,r5,table@l; \
19 add r3,r3,r5; \
20 mtctr r3; \
21 bctr
22
23_GLOBAL(__mfdcr)
24 DCR_ACCESS_PROLOG(__mfdcr_table)
25
26_GLOBAL(__mtdcr)
27 DCR_ACCESS_PROLOG(__mtdcr_table)
28
29__mfdcr_table:
30 mfdcr r3,0; blr
31__mtdcr_table:
32 mtdcr 0,r4; blr
33
34dcr = 1
35 .rept 1023
36 mfdcr r3,dcr; blr
37 mtdcr dcr,r4; blr
38 dcr = dcr + 1
39 .endr
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
new file mode 100644
index 000000000000..dffeeaeca1d9
--- /dev/null
+++ b/arch/powerpc/sysdev/dcr.c
@@ -0,0 +1,137 @@
1/*
2 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#undef DEBUG
21
22#include <linux/kernel.h>
23#include <asm/prom.h>
24#include <asm/dcr.h>
25
26unsigned int dcr_resource_start(struct device_node *np, unsigned int index)
27{
28 unsigned int ds;
29 const u32 *dr = get_property(np, "dcr-reg", &ds);
30
31 if (dr == NULL || ds & 1 || index >= (ds / 8))
32 return 0;
33
34 return dr[index * 2];
35}
36
37unsigned int dcr_resource_len(struct device_node *np, unsigned int index)
38{
39 unsigned int ds;
40 const u32 *dr = get_property(np, "dcr-reg", &ds);
41
42 if (dr == NULL || ds & 1 || index >= (ds / 8))
43 return 0;
44
45 return dr[index * 2 + 1];
46}
47
48#ifndef CONFIG_PPC_DCR_NATIVE
49
50static struct device_node * find_dcr_parent(struct device_node * node)
51{
52 struct device_node *par, *tmp;
53 const u32 *p;
54
55 for (par = of_node_get(node); par;) {
56 if (get_property(par, "dcr-controller", NULL))
57 break;
58 p = get_property(par, "dcr-parent", NULL);
59 tmp = par;
60 if (p == NULL)
61 par = of_get_parent(par);
62 else
63 par = of_find_node_by_phandle(*p);
64 of_node_put(tmp);
65 }
66 return par;
67}
68
69u64 of_translate_dcr_address(struct device_node *dev,
70 unsigned int dcr_n,
71 unsigned int *out_stride)
72{
73 struct device_node *dp;
74 const u32 *p;
75 unsigned int stride;
76 u64 ret;
77
78 dp = find_dcr_parent(dev);
79 if (dp == NULL)
80 return OF_BAD_ADDR;
81
82 /* Stride is not properly defined yet, default to 0x10 for Axon */
83 p = get_property(dp, "dcr-mmio-stride", NULL);
84 stride = (p == NULL) ? 0x10 : *p;
85
86 /* XXX FIXME: Which property name is to use of the 2 following ? */
87 p = get_property(dp, "dcr-mmio-range", NULL);
88 if (p == NULL)
89 p = get_property(dp, "dcr-mmio-space", NULL);
90 if (p == NULL)
91 return OF_BAD_ADDR;
92
93 /* Maybe could do some better range checking here */
94 ret = of_translate_address(dp, p);
95 if (ret != OF_BAD_ADDR)
96 ret += (u64)(stride) * (u64)dcr_n;
97 if (out_stride)
98 *out_stride = stride;
99 return ret;
100}
101
102dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
103 unsigned int dcr_c)
104{
105 dcr_host_t ret = { .token = NULL, .stride = 0 };
106 u64 addr;
107
108 pr_debug("dcr_map(%s, 0x%x, 0x%x)\n",
109 dev->full_name, dcr_n, dcr_c);
110
111 addr = of_translate_dcr_address(dev, dcr_n, &ret.stride);
112 pr_debug("translates to addr: 0x%lx, stride: 0x%x\n",
113 addr, ret.stride);
114 if (addr == OF_BAD_ADDR)
115 return ret;
116 pr_debug("mapping 0x%x bytes\n", dcr_c * ret.stride);
117 ret.token = ioremap(addr, dcr_c * ret.stride);
118 if (ret.token == NULL)
119 return ret;
120 pr_debug("mapped at 0x%p -> base is 0x%p\n",
121 ret.token, ret.token - dcr_n * ret.stride);
122 ret.token -= dcr_n * ret.stride;
123 return ret;
124}
125
126void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c)
127{
128 dcr_host_t h = host;
129
130 if (h.token == NULL)
131 return;
132 h.token -= dcr_n * h.stride;
133 iounmap(h.token);
134 h.token = NULL;
135}
136
137#endif /* !defined(CONFIG_PPC_DCR_NATIVE) */
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index dbe92ae20333..ad31e56e892b 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/phy.h>
25#include <linux/fsl_devices.h> 26#include <linux/fsl_devices.h>
26#include <linux/fs_enet_pd.h> 27#include <linux/fs_enet_pd.h>
27#include <linux/fs_uart_pd.h> 28#include <linux/fs_uart_pd.h>
@@ -146,7 +147,7 @@ static int __init gfar_mdio_of_init(void)
146 } 147 }
147 148
148 for (k = 0; k < 32; k++) 149 for (k = 0; k < 32; k++)
149 mdio_data.irq[k] = -1; 150 mdio_data.irq[k] = PHY_POLL;
150 151
151 while ((child = of_get_next_child(np, child)) != NULL) { 152 while ((child = of_get_next_child(np, child)) != NULL) {
152 int irq = irq_of_parse_and_map(child, 0); 153 int irq = irq_of_parse_and_map(child, 0);
@@ -177,6 +178,7 @@ static const char *gfar_tx_intr = "tx";
177static const char *gfar_rx_intr = "rx"; 178static const char *gfar_rx_intr = "rx";
178static const char *gfar_err_intr = "error"; 179static const char *gfar_err_intr = "error";
179 180
181
180static int __init gfar_of_init(void) 182static int __init gfar_of_init(void)
181{ 183{
182 struct device_node *np; 184 struct device_node *np;
@@ -204,8 +206,7 @@ static int __init gfar_of_init(void)
204 if (ret) 206 if (ret)
205 goto err; 207 goto err;
206 208
207 r[1].start = r[1].end = irq_of_parse_and_map(np, 0); 209 of_irq_to_resource(np, 0, &r[1]);
208 r[1].flags = IORESOURCE_IRQ;
209 210
210 model = get_property(np, "model", NULL); 211 model = get_property(np, "model", NULL);
211 212
@@ -214,12 +215,10 @@ static int __init gfar_of_init(void)
214 r[1].name = gfar_tx_intr; 215 r[1].name = gfar_tx_intr;
215 216
216 r[2].name = gfar_rx_intr; 217 r[2].name = gfar_rx_intr;
217 r[2].start = r[2].end = irq_of_parse_and_map(np, 1); 218 of_irq_to_resource(np, 1, &r[2]);
218 r[2].flags = IORESOURCE_IRQ;
219 219
220 r[3].name = gfar_err_intr; 220 r[3].name = gfar_err_intr;
221 r[3].start = r[3].end = irq_of_parse_and_map(np, 2); 221 of_irq_to_resource(np, 2, &r[3]);
222 r[3].flags = IORESOURCE_IRQ;
223 222
224 n_res += 2; 223 n_res += 2;
225 } 224 }
@@ -323,8 +322,7 @@ static int __init fsl_i2c_of_init(void)
323 if (ret) 322 if (ret)
324 goto err; 323 goto err;
325 324
326 r[1].start = r[1].end = irq_of_parse_and_map(np, 0); 325 of_irq_to_resource(np, 0, &r[1]);
327 r[1].flags = IORESOURCE_IRQ;
328 326
329 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); 327 i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
330 if (IS_ERR(i2c_dev)) { 328 if (IS_ERR(i2c_dev)) {
@@ -459,8 +457,7 @@ static int __init fsl_usb_of_init(void)
459 if (ret) 457 if (ret)
460 goto err; 458 goto err;
461 459
462 r[1].start = r[1].end = irq_of_parse_and_map(np, 0); 460 of_irq_to_resource(np, 0, &r[1]);
463 r[1].flags = IORESOURCE_IRQ;
464 461
465 usb_dev_mph = 462 usb_dev_mph =
466 platform_device_register_simple("fsl-ehci", i, r, 2); 463 platform_device_register_simple("fsl-ehci", i, r, 2);
@@ -507,8 +504,7 @@ static int __init fsl_usb_of_init(void)
507 if (ret) 504 if (ret)
508 goto unreg_mph; 505 goto unreg_mph;
509 506
510 r[1].start = r[1].end = irq_of_parse_and_map(np, 0); 507 of_irq_to_resource(np, 0, &r[1]);
511 r[1].flags = IORESOURCE_IRQ;
512 508
513 usb_dev_dr = 509 usb_dev_dr =
514 platform_device_register_simple("fsl-ehci", i, r, 2); 510 platform_device_register_simple("fsl-ehci", i, r, 2);
@@ -591,8 +587,7 @@ static int __init fs_enet_of_init(void)
591 r[2].name = fcc_regs_c; 587 r[2].name = fcc_regs_c;
592 fs_enet_data.fcc_regs_c = r[2].start; 588 fs_enet_data.fcc_regs_c = r[2].start;
593 589
594 r[3].start = r[3].end = irq_of_parse_and_map(np, 0); 590 of_irq_to_resource(np, 0, &r[3]);
595 r[3].flags = IORESOURCE_IRQ;
596 591
597 fs_enet_dev = 592 fs_enet_dev =
598 platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4); 593 platform_device_register_simple("fsl-cpm-fcc", i, &r[0], 4);
@@ -754,8 +749,7 @@ static int __init cpm_uart_of_init(void)
754 goto err; 749 goto err;
755 r[1].name = scc_pram; 750 r[1].name = scc_pram;
756 751
757 r[2].start = r[2].end = irq_of_parse_and_map(np, 0); 752 of_irq_to_resource(np, 0, &r[2]);
758 r[2].flags = IORESOURCE_IRQ;
759 753
760 cpm_uart_dev = 754 cpm_uart_dev =
761 platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3); 755 platform_device_register_simple("fsl-cpm-scc:uart", i, &r[0], 3);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index ba4833f57d47..411480d5c626 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -147,33 +147,51 @@ static u32 mpic_infos[][MPIC_IDX_END] = {
147 */ 147 */
148 148
149 149
150static inline u32 _mpic_read(unsigned int be, volatile u32 __iomem *base, 150static inline u32 _mpic_read(enum mpic_reg_type type,
151 unsigned int reg) 151 struct mpic_reg_bank *rb,
152 unsigned int reg)
152{ 153{
153 if (be) 154 switch(type) {
154 return in_be32(base + (reg >> 2)); 155#ifdef CONFIG_PPC_DCR
155 else 156 case mpic_access_dcr:
156 return in_le32(base + (reg >> 2)); 157 return dcr_read(rb->dhost,
158 rb->dbase + reg + rb->doff);
159#endif
160 case mpic_access_mmio_be:
161 return in_be32(rb->base + (reg >> 2));
162 case mpic_access_mmio_le:
163 default:
164 return in_le32(rb->base + (reg >> 2));
165 }
157} 166}
158 167
159static inline void _mpic_write(unsigned int be, volatile u32 __iomem *base, 168static inline void _mpic_write(enum mpic_reg_type type,
160 unsigned int reg, u32 value) 169 struct mpic_reg_bank *rb,
170 unsigned int reg, u32 value)
161{ 171{
162 if (be) 172 switch(type) {
163 out_be32(base + (reg >> 2), value); 173#ifdef CONFIG_PPC_DCR
164 else 174 case mpic_access_dcr:
165 out_le32(base + (reg >> 2), value); 175 return dcr_write(rb->dhost,
176 rb->dbase + reg + rb->doff, value);
177#endif
178 case mpic_access_mmio_be:
179 return out_be32(rb->base + (reg >> 2), value);
180 case mpic_access_mmio_le:
181 default:
182 return out_le32(rb->base + (reg >> 2), value);
183 }
166} 184}
167 185
168static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi) 186static inline u32 _mpic_ipi_read(struct mpic *mpic, unsigned int ipi)
169{ 187{
170 unsigned int be = (mpic->flags & MPIC_BIG_ENDIAN) != 0; 188 enum mpic_reg_type type = mpic->reg_type;
171 unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) + 189 unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) +
172 (ipi * MPIC_INFO(GREG_IPI_STRIDE)); 190 (ipi * MPIC_INFO(GREG_IPI_STRIDE));
173 191
174 if (mpic->flags & MPIC_BROKEN_IPI) 192 if ((mpic->flags & MPIC_BROKEN_IPI) && type == mpic_access_mmio_le)
175 be = !be; 193 type = mpic_access_mmio_be;
176 return _mpic_read(be, mpic->gregs, offset); 194 return _mpic_read(type, &mpic->gregs, offset);
177} 195}
178 196
179static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value) 197static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 value)
@@ -181,7 +199,7 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu
181 unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) + 199 unsigned int offset = MPIC_INFO(GREG_IPI_VECTOR_PRI_0) +
182 (ipi * MPIC_INFO(GREG_IPI_STRIDE)); 200 (ipi * MPIC_INFO(GREG_IPI_STRIDE));
183 201
184 _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->gregs, offset, value); 202 _mpic_write(mpic->reg_type, &mpic->gregs, offset, value);
185} 203}
186 204
187static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) 205static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
@@ -190,8 +208,7 @@ static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
190 208
191 if (mpic->flags & MPIC_PRIMARY) 209 if (mpic->flags & MPIC_PRIMARY)
192 cpu = hard_smp_processor_id(); 210 cpu = hard_smp_processor_id();
193 return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, 211 return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg);
194 mpic->cpuregs[cpu], reg);
195} 212}
196 213
197static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) 214static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
@@ -201,7 +218,7 @@ static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 valu
201 if (mpic->flags & MPIC_PRIMARY) 218 if (mpic->flags & MPIC_PRIMARY)
202 cpu = hard_smp_processor_id(); 219 cpu = hard_smp_processor_id();
203 220
204 _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->cpuregs[cpu], reg, value); 221 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value);
205} 222}
206 223
207static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg) 224static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigned int reg)
@@ -209,7 +226,7 @@ static inline u32 _mpic_irq_read(struct mpic *mpic, unsigned int src_no, unsigne
209 unsigned int isu = src_no >> mpic->isu_shift; 226 unsigned int isu = src_no >> mpic->isu_shift;
210 unsigned int idx = src_no & mpic->isu_mask; 227 unsigned int idx = src_no & mpic->isu_mask;
211 228
212 return _mpic_read(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu], 229 return _mpic_read(mpic->reg_type, &mpic->isus[isu],
213 reg + (idx * MPIC_INFO(IRQ_STRIDE))); 230 reg + (idx * MPIC_INFO(IRQ_STRIDE)));
214} 231}
215 232
@@ -219,12 +236,12 @@ static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
219 unsigned int isu = src_no >> mpic->isu_shift; 236 unsigned int isu = src_no >> mpic->isu_shift;
220 unsigned int idx = src_no & mpic->isu_mask; 237 unsigned int idx = src_no & mpic->isu_mask;
221 238
222 _mpic_write(mpic->flags & MPIC_BIG_ENDIAN, mpic->isus[isu], 239 _mpic_write(mpic->reg_type, &mpic->isus[isu],
223 reg + (idx * MPIC_INFO(IRQ_STRIDE)), value); 240 reg + (idx * MPIC_INFO(IRQ_STRIDE)), value);
224} 241}
225 242
226#define mpic_read(b,r) _mpic_read(mpic->flags & MPIC_BIG_ENDIAN,(b),(r)) 243#define mpic_read(b,r) _mpic_read(mpic->reg_type,&(b),(r))
227#define mpic_write(b,r,v) _mpic_write(mpic->flags & MPIC_BIG_ENDIAN,(b),(r),(v)) 244#define mpic_write(b,r,v) _mpic_write(mpic->reg_type,&(b),(r),(v))
228#define mpic_ipi_read(i) _mpic_ipi_read(mpic,(i)) 245#define mpic_ipi_read(i) _mpic_ipi_read(mpic,(i))
229#define mpic_ipi_write(i,v) _mpic_ipi_write(mpic,(i),(v)) 246#define mpic_ipi_write(i,v) _mpic_ipi_write(mpic,(i),(v))
230#define mpic_cpu_read(i) _mpic_cpu_read(mpic,(i)) 247#define mpic_cpu_read(i) _mpic_cpu_read(mpic,(i))
@@ -238,6 +255,38 @@ static inline void _mpic_irq_write(struct mpic *mpic, unsigned int src_no,
238 */ 255 */
239 256
240 257
258static void _mpic_map_mmio(struct mpic *mpic, unsigned long phys_addr,
259 struct mpic_reg_bank *rb, unsigned int offset,
260 unsigned int size)
261{
262 rb->base = ioremap(phys_addr + offset, size);
263 BUG_ON(rb->base == NULL);
264}
265
266#ifdef CONFIG_PPC_DCR
267static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
268 unsigned int offset, unsigned int size)
269{
270 rb->dbase = mpic->dcr_base;
271 rb->doff = offset;
272 rb->dhost = dcr_map(mpic->of_node, rb->dbase + rb->doff, size);
273 BUG_ON(!DCR_MAP_OK(rb->dhost));
274}
275
276static inline void mpic_map(struct mpic *mpic, unsigned long phys_addr,
277 struct mpic_reg_bank *rb, unsigned int offset,
278 unsigned int size)
279{
280 if (mpic->flags & MPIC_USES_DCR)
281 _mpic_map_dcr(mpic, rb, offset, size);
282 else
283 _mpic_map_mmio(mpic, phys_addr, rb, offset, size);
284}
285#else /* CONFIG_PPC_DCR */
286#define mpic_map(m,p,b,o,s) _mpic_map_mmio(m,p,b,o,s)
287#endif /* !CONFIG_PPC_DCR */
288
289
241 290
242/* Check if we have one of those nice broken MPICs with a flipped endian on 291/* Check if we have one of those nice broken MPICs with a flipped endian on
243 * reads from IPI registers 292 * reads from IPI registers
@@ -845,7 +894,7 @@ static struct irq_host_ops mpic_host_ops = {
845 */ 894 */
846 895
847struct mpic * __init mpic_alloc(struct device_node *node, 896struct mpic * __init mpic_alloc(struct device_node *node,
848 unsigned long phys_addr, 897 phys_addr_t phys_addr,
849 unsigned int flags, 898 unsigned int flags,
850 unsigned int isu_size, 899 unsigned int isu_size,
851 unsigned int irq_count, 900 unsigned int irq_count,
@@ -855,6 +904,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
855 u32 reg; 904 u32 reg;
856 const char *vers; 905 const char *vers;
857 int i; 906 int i;
907 u64 paddr = phys_addr;
858 908
859 mpic = alloc_bootmem(sizeof(struct mpic)); 909 mpic = alloc_bootmem(sizeof(struct mpic));
860 if (mpic == NULL) 910 if (mpic == NULL)
@@ -883,6 +933,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
883 if (flags & MPIC_PRIMARY) 933 if (flags & MPIC_PRIMARY)
884 mpic->hc_ht_irq.set_affinity = mpic_set_affinity; 934 mpic->hc_ht_irq.set_affinity = mpic_set_affinity;
885#endif /* CONFIG_MPIC_BROKEN_U3 */ 935#endif /* CONFIG_MPIC_BROKEN_U3 */
936
886#ifdef CONFIG_SMP 937#ifdef CONFIG_SMP
887 mpic->hc_ipi = mpic_ipi_chip; 938 mpic->hc_ipi = mpic_ipi_chip;
888 mpic->hc_ipi.typename = name; 939 mpic->hc_ipi.typename = name;
@@ -893,15 +944,52 @@ struct mpic * __init mpic_alloc(struct device_node *node,
893 mpic->irq_count = irq_count; 944 mpic->irq_count = irq_count;
894 mpic->num_sources = 0; /* so far */ 945 mpic->num_sources = 0; /* so far */
895 946
947 /* Check for "big-endian" in device-tree */
948 if (node && get_property(node, "big-endian", NULL) != NULL)
949 mpic->flags |= MPIC_BIG_ENDIAN;
950
951
896#ifdef CONFIG_MPIC_WEIRD 952#ifdef CONFIG_MPIC_WEIRD
897 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)]; 953 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)];
898#endif 954#endif
899 955
956 /* default register type */
957 mpic->reg_type = (flags & MPIC_BIG_ENDIAN) ?
958 mpic_access_mmio_be : mpic_access_mmio_le;
959
960 /* If no physical address is passed in, a device-node is mandatory */
961 BUG_ON(paddr == 0 && node == NULL);
962
963 /* If no physical address passed in, check if it's dcr based */
964 if (paddr == 0 && get_property(node, "dcr-reg", NULL) != NULL)
965 mpic->flags |= MPIC_USES_DCR;
966
967#ifdef CONFIG_PPC_DCR
968 if (mpic->flags & MPIC_USES_DCR) {
969 const u32 *dbasep;
970 dbasep = get_property(node, "dcr-reg", NULL);
971 BUG_ON(dbasep == NULL);
972 mpic->dcr_base = *dbasep;
973 mpic->reg_type = mpic_access_dcr;
974 }
975#else
976 BUG_ON (mpic->flags & MPIC_USES_DCR);
977#endif /* CONFIG_PPC_DCR */
978
979 /* If the MPIC is not DCR based, and no physical address was passed
980 * in, try to obtain one
981 */
982 if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
983 const u32 *reg;
984 reg = get_property(node, "reg", NULL);
985 BUG_ON(reg == NULL);
986 paddr = of_translate_address(node, reg);
987 BUG_ON(paddr == OF_BAD_ADDR);
988 }
989
900 /* Map the global registers */ 990 /* Map the global registers */
901 mpic->gregs = ioremap(phys_addr + MPIC_INFO(GREG_BASE), 0x1000); 991 mpic_map(mpic, paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
902 mpic->tmregs = mpic->gregs + 992 mpic_map(mpic, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
903 ((MPIC_INFO(TIMER_BASE) - MPIC_INFO(GREG_BASE)) >> 2);
904 BUG_ON(mpic->gregs == NULL);
905 993
906 /* Reset */ 994 /* Reset */
907 if (flags & MPIC_WANTS_RESET) { 995 if (flags & MPIC_WANTS_RESET) {
@@ -926,17 +1014,16 @@ struct mpic * __init mpic_alloc(struct device_node *node,
926 1014
927 /* Map the per-CPU registers */ 1015 /* Map the per-CPU registers */
928 for (i = 0; i < mpic->num_cpus; i++) { 1016 for (i = 0; i < mpic->num_cpus; i++) {
929 mpic->cpuregs[i] = ioremap(phys_addr + MPIC_INFO(CPU_BASE) + 1017 mpic_map(mpic, paddr, &mpic->cpuregs[i],
930 i * MPIC_INFO(CPU_STRIDE), 0x1000); 1018 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
931 BUG_ON(mpic->cpuregs[i] == NULL); 1019 0x1000);
932 } 1020 }
933 1021
934 /* Initialize main ISU if none provided */ 1022 /* Initialize main ISU if none provided */
935 if (mpic->isu_size == 0) { 1023 if (mpic->isu_size == 0) {
936 mpic->isu_size = mpic->num_sources; 1024 mpic->isu_size = mpic->num_sources;
937 mpic->isus[0] = ioremap(phys_addr + MPIC_INFO(IRQ_BASE), 1025 mpic_map(mpic, paddr, &mpic->isus[0],
938 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1026 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
939 BUG_ON(mpic->isus[0] == NULL);
940 } 1027 }
941 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1); 1028 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
942 mpic->isu_mask = (1 << mpic->isu_shift) - 1; 1029 mpic->isu_mask = (1 << mpic->isu_shift) - 1;
@@ -956,10 +1043,11 @@ struct mpic * __init mpic_alloc(struct device_node *node,
956 vers = "<unknown>"; 1043 vers = "<unknown>";
957 break; 1044 break;
958 } 1045 }
959 printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %lx, max %d CPUs\n", 1046 printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx,"
960 name, vers, phys_addr, mpic->num_cpus); 1047 " max %d CPUs\n",
961 printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", mpic->isu_size, 1048 name, vers, (unsigned long long)paddr, mpic->num_cpus);
962 mpic->isu_shift, mpic->isu_mask); 1049 printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n",
1050 mpic->isu_size, mpic->isu_shift, mpic->isu_mask);
963 1051
964 mpic->next = mpics; 1052 mpic->next = mpics;
965 mpics = mpic; 1053 mpics = mpic;
@@ -973,14 +1061,14 @@ struct mpic * __init mpic_alloc(struct device_node *node,
973} 1061}
974 1062
975void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, 1063void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
976 unsigned long phys_addr) 1064 phys_addr_t paddr)
977{ 1065{
978 unsigned int isu_first = isu_num * mpic->isu_size; 1066 unsigned int isu_first = isu_num * mpic->isu_size;
979 1067
980 BUG_ON(isu_num >= MPIC_MAX_ISU); 1068 BUG_ON(isu_num >= MPIC_MAX_ISU);
981 1069
982 mpic->isus[isu_num] = ioremap(phys_addr, 1070 mpic_map(mpic, paddr, &mpic->isus[isu_num], 0,
983 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1071 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
984 if ((isu_first + mpic->isu_size) > mpic->num_sources) 1072 if ((isu_first + mpic->isu_size) > mpic->num_sources)
985 mpic->num_sources = isu_first + mpic->isu_size; 1073 mpic->num_sources = isu_first + mpic->isu_size;
986} 1074}
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index e4223226a7a8..e3d71e083f35 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -174,8 +174,7 @@ void qe_setbrg(u32 brg, u32 rate)
174 u32 divisor, tempval; 174 u32 divisor, tempval;
175 int div16 = 0; 175 int div16 = 0;
176 176
177 bp = &qe_immr->brg.brgc1; 177 bp = &qe_immr->brg.brgc[brg];
178 bp += brg;
179 178
180 divisor = (get_brg_clk() / rate); 179 divisor = (get_brg_clk() / rate);
181 if (divisor > QE_BRGC_DIVISOR_MAX + 1) { 180 if (divisor > QE_BRGC_DIVISOR_MAX + 1) {
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_fast.c b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
index 75fa3104a43a..e657559bea93 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_fast.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_fast.c
@@ -216,14 +216,12 @@ int ucc_fast_init(struct ucc_fast_info * uf_info, struct ucc_fast_private ** ucc
216 return -EINVAL; 216 return -EINVAL;
217 } 217 }
218 218
219 uccf = (struct ucc_fast_private *) 219 uccf = kzalloc(sizeof(struct ucc_fast_private), GFP_KERNEL);
220 kmalloc(sizeof(struct ucc_fast_private), GFP_KERNEL);
221 if (!uccf) { 220 if (!uccf) {
222 uccf_err 221 uccf_err
223 ("ucc_fast_init: No memory for UCC slow data structure!"); 222 ("ucc_fast_init: No memory for UCC slow data structure!");
224 return -ENOMEM; 223 return -ENOMEM;
225 } 224 }
226 memset(uccf, 0, sizeof(struct ucc_fast_private));
227 225
228 /* Fill fast UCC structure */ 226 /* Fill fast UCC structure */
229 uccf->uf_info = uf_info; 227 uccf->uf_info = uf_info;
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_slow.c b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
index a49da6b73ecf..47b56203f47e 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_slow.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
@@ -168,14 +168,12 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
168 return -EINVAL; 168 return -EINVAL;
169 } 169 }
170 170
171 uccs = (struct ucc_slow_private *) 171 uccs = kzalloc(sizeof(struct ucc_slow_private), GFP_KERNEL);
172 kmalloc(sizeof(struct ucc_slow_private), GFP_KERNEL);
173 if (!uccs) { 172 if (!uccs) {
174 uccs_err 173 uccs_err
175 ("ucc_slow_init: No memory for UCC slow data structure!"); 174 ("ucc_slow_init: No memory for UCC slow data structure!");
176 return -ENOMEM; 175 return -ENOMEM;
177 } 176 }
178 memset(uccs, 0, sizeof(struct ucc_slow_private));
179 177
180 /* Fill slow UCC structure */ 178 /* Fill slow UCC structure */
181 uccs->us_info = us_info; 179 uccs->us_info = us_info;
diff --git a/arch/powerpc/sysdev/rom.c b/arch/powerpc/sysdev/rom.c
new file mode 100644
index 000000000000..bf5b3f10e6c6
--- /dev/null
+++ b/arch/powerpc/sysdev/rom.c
@@ -0,0 +1,31 @@
1/*
2 * ROM device registration
3 *
4 * (C) 2006 MontaVista Software, Inc. This file is licensed under
5 * the terms of the GNU General Public License version 2. This program
6 * is licensed "as is" without any warranty of any kind, whether express
7 * or implied.
8 */
9
10#include <linux/kernel.h>
11#include <asm/of_device.h>
12
13static int __init powerpc_flash_init(void)
14{
15 struct device_node *node = NULL;
16
17 /*
18 * Register all the devices which type is "rom"
19 */
20 while ((node = of_find_node_by_type(node, "rom")) != NULL) {
21 if (node->name == NULL) {
22 printk(KERN_WARNING "powerpc_flash_init: found 'rom' "
23 "device, but with no name, skipping...\n");
24 continue;
25 }
26 of_platform_device_create(node, node->name, NULL);
27 }
28 return 0;
29}
30
31arch_initcall(powerpc_flash_init);
diff --git a/arch/powerpc/sysdev/todc.c b/arch/powerpc/sysdev/todc.c
deleted file mode 100644
index 0a65980efb50..000000000000
--- a/arch/powerpc/sysdev/todc.c
+++ /dev/null
@@ -1,392 +0,0 @@
1/*
2 * Time of Day Clock support for the M48T35, M48T37, M48T59, and MC146818
3 * Real Time Clocks/Timekeepers.
4 *
5 * Author: Mark A. Greer <mgreer@mvista.com>
6 *
7 * 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12#include <linux/errno.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/time.h>
16#include <linux/timex.h>
17#include <linux/bcd.h>
18#include <linux/mc146818rtc.h>
19
20#include <asm/machdep.h>
21#include <asm/io.h>
22#include <asm/time.h>
23#include <asm/todc.h>
24
25/*
26 * Depending on the hardware on your board and your board design, the
27 * RTC/NVRAM may be accessed either directly (like normal memory) or via
28 * address/data registers. If your board uses the direct method, set
29 * 'nvram_data' to the base address of your nvram and leave 'nvram_as0' and
30 * 'nvram_as1' NULL. If your board uses address/data regs to access nvram,
31 * set 'nvram_as0' to the address of the lower byte, set 'nvram_as1' to the
32 * address of the upper byte (leave NULL if using mc146818), and set
33 * 'nvram_data' to the address of the 8-bit data register.
34 *
35 * Note: Even though the documentation for the various RTC chips say that it
36 * take up to a second before it starts updating once the 'R' bit is
37 * cleared, they always seem to update even though we bang on it many
38 * times a second. This is true, except for the Dallas Semi 1746/1747
39 * (possibly others). Those chips seem to have a real problem whenever
40 * we set the 'R' bit before reading them, they basically stop counting.
41 * --MAG
42 */
43
44/*
45 * 'todc_info' should be initialized in your *_setup.c file to
46 * point to a fully initialized 'todc_info_t' structure.
47 * This structure holds all the register offsets for your particular
48 * TODC/RTC chip.
49 * TODC_ALLOC()/TODC_INIT() will allocate and initialize this table for you.
50 */
51
52#ifdef RTC_FREQ_SELECT
53#undef RTC_FREQ_SELECT
54#define RTC_FREQ_SELECT control_b /* Register A */
55#endif
56
57#ifdef RTC_CONTROL
58#undef RTC_CONTROL
59#define RTC_CONTROL control_a /* Register B */
60#endif
61
62#ifdef RTC_INTR_FLAGS
63#undef RTC_INTR_FLAGS
64#define RTC_INTR_FLAGS watchdog /* Register C */
65#endif
66
67#ifdef RTC_VALID
68#undef RTC_VALID
69#define RTC_VALID interrupts /* Register D */
70#endif
71
72/* Access routines when RTC accessed directly (like normal memory) */
73u_char
74todc_direct_read_val(int addr)
75{
76 return readb((void __iomem *)(todc_info->nvram_data + addr));
77}
78
79void
80todc_direct_write_val(int addr, unsigned char val)
81{
82 writeb(val, (void __iomem *)(todc_info->nvram_data + addr));
83 return;
84}
85
86/* Access routines for accessing m48txx type chips via addr/data regs */
87u_char
88todc_m48txx_read_val(int addr)
89{
90 outb(addr, todc_info->nvram_as0);
91 outb(addr>>todc_info->as0_bits, todc_info->nvram_as1);
92 return inb(todc_info->nvram_data);
93}
94
95void
96todc_m48txx_write_val(int addr, unsigned char val)
97{
98 outb(addr, todc_info->nvram_as0);
99 outb(addr>>todc_info->as0_bits, todc_info->nvram_as1);
100 outb(val, todc_info->nvram_data);
101 return;
102}
103
104/* Access routines for accessing mc146818 type chips via addr/data regs */
105u_char
106todc_mc146818_read_val(int addr)
107{
108 outb_p(addr, todc_info->nvram_as0);
109 return inb_p(todc_info->nvram_data);
110}
111
112void
113todc_mc146818_write_val(int addr, unsigned char val)
114{
115 outb_p(addr, todc_info->nvram_as0);
116 outb_p(val, todc_info->nvram_data);
117}
118
119
120/*
121 * Routines to make RTC chips with NVRAM buried behind an addr/data pair
122 * have the NVRAM and clock regs appear at the same level.
123 * The NVRAM will appear to start at addr 0 and the clock regs will appear
124 * to start immediately after the NVRAM (actually, start at offset
125 * todc_info->nvram_size).
126 */
127static inline u_char
128todc_read_val(int addr)
129{
130 u_char val;
131
132 if (todc_info->sw_flags & TODC_FLAG_2_LEVEL_NVRAM) {
133 if (addr < todc_info->nvram_size) { /* NVRAM */
134 ppc_md.rtc_write_val(todc_info->nvram_addr_reg, addr);
135 val = ppc_md.rtc_read_val(todc_info->nvram_data_reg);
136 } else { /* Clock Reg */
137 addr -= todc_info->nvram_size;
138 val = ppc_md.rtc_read_val(addr);
139 }
140 } else
141 val = ppc_md.rtc_read_val(addr);
142
143 return val;
144}
145
146static inline void
147todc_write_val(int addr, u_char val)
148{
149 if (todc_info->sw_flags & TODC_FLAG_2_LEVEL_NVRAM) {
150 if (addr < todc_info->nvram_size) { /* NVRAM */
151 ppc_md.rtc_write_val(todc_info->nvram_addr_reg, addr);
152 ppc_md.rtc_write_val(todc_info->nvram_data_reg, val);
153 } else { /* Clock Reg */
154 addr -= todc_info->nvram_size;
155 ppc_md.rtc_write_val(addr, val);
156 }
157 } else
158 ppc_md.rtc_write_val(addr, val);
159}
160
161/*
162 * TODC routines
163 *
164 * There is some ugly stuff in that there are assumptions for the mc146818.
165 *
166 * Assumptions:
167 * - todc_info->control_a has the offset as mc146818 Register B reg
168 * - todc_info->control_b has the offset as mc146818 Register A reg
169 * - m48txx control reg's write enable or 'W' bit is same as
170 * mc146818 Register B 'SET' bit (i.e., 0x80)
171 *
172 * These assumptions were made to make the code simpler.
173 */
174long __init
175todc_time_init(void)
176{
177 u_char cntl_b;
178
179 if (!ppc_md.rtc_read_val)
180 ppc_md.rtc_read_val = ppc_md.nvram_read_val;
181 if (!ppc_md.rtc_write_val)
182 ppc_md.rtc_write_val = ppc_md.nvram_write_val;
183
184 cntl_b = todc_read_val(todc_info->control_b);
185
186 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
187 if ((cntl_b & 0x70) != 0x20) {
188 printk(KERN_INFO "TODC real-time-clock was stopped."
189 " Now starting...");
190 cntl_b &= ~0x70;
191 cntl_b |= 0x20;
192 }
193
194 todc_write_val(todc_info->control_b, cntl_b);
195 } else if (todc_info->rtc_type == TODC_TYPE_DS17285) {
196 u_char mode;
197
198 mode = todc_read_val(TODC_TYPE_DS17285_CNTL_A);
199 /* Make sure countdown clear is not set */
200 mode &= ~0x40;
201 /* Enable oscillator, extended register set */
202 mode |= 0x30;
203 todc_write_val(TODC_TYPE_DS17285_CNTL_A, mode);
204
205 } else if (todc_info->rtc_type == TODC_TYPE_DS1501) {
206 u_char month;
207
208 todc_info->enable_read = TODC_DS1501_CNTL_B_TE;
209 todc_info->enable_write = TODC_DS1501_CNTL_B_TE;
210
211 month = todc_read_val(todc_info->month);
212
213 if ((month & 0x80) == 0x80) {
214 printk(KERN_INFO "TODC %s %s\n",
215 "real-time-clock was stopped.",
216 "Now starting...");
217 month &= ~0x80;
218 todc_write_val(todc_info->month, month);
219 }
220
221 cntl_b &= ~TODC_DS1501_CNTL_B_TE;
222 todc_write_val(todc_info->control_b, cntl_b);
223 } else { /* must be a m48txx type */
224 u_char cntl_a;
225
226 todc_info->enable_read = TODC_MK48TXX_CNTL_A_R;
227 todc_info->enable_write = TODC_MK48TXX_CNTL_A_W;
228
229 cntl_a = todc_read_val(todc_info->control_a);
230
231 /* Check & clear STOP bit in control B register */
232 if (cntl_b & TODC_MK48TXX_DAY_CB) {
233 printk(KERN_INFO "TODC %s %s\n",
234 "real-time-clock was stopped.",
235 "Now starting...");
236
237 cntl_a |= todc_info->enable_write;
238 cntl_b &= ~TODC_MK48TXX_DAY_CB;/* Start Oscil */
239
240 todc_write_val(todc_info->control_a, cntl_a);
241 todc_write_val(todc_info->control_b, cntl_b);
242 }
243
244 /* Make sure READ & WRITE bits are cleared. */
245 cntl_a &= ~(todc_info->enable_write | todc_info->enable_read);
246 todc_write_val(todc_info->control_a, cntl_a);
247 }
248
249 return 0;
250}
251
252/*
253 * There is some ugly stuff in that there are assumptions that for a mc146818,
254 * the todc_info->control_a has the offset of the mc146818 Register B reg and
255 * that the register'ss 'SET' bit is the same as the m48txx's write enable
256 * bit in the control register of the m48txx (i.e., 0x80).
257 *
258 * It was done to make the code look simpler.
259 */
260void
261todc_get_rtc_time(struct rtc_time *tm)
262{
263 uint year = 0, mon = 0, mday = 0, hour = 0, min = 0, sec = 0;
264 uint limit, i;
265 u_char save_control, uip = 0;
266 extern void GregorianDay(struct rtc_time *);
267
268 spin_lock(&rtc_lock);
269 save_control = todc_read_val(todc_info->control_a);
270
271 if (todc_info->rtc_type != TODC_TYPE_MC146818) {
272 limit = 1;
273
274 switch (todc_info->rtc_type) {
275 case TODC_TYPE_DS1553:
276 case TODC_TYPE_DS1557:
277 case TODC_TYPE_DS1743:
278 case TODC_TYPE_DS1746: /* XXXX BAD HACK -> FIX */
279 case TODC_TYPE_DS1747:
280 case TODC_TYPE_DS17285:
281 break;
282 default:
283 todc_write_val(todc_info->control_a,
284 (save_control | todc_info->enable_read));
285 }
286 } else
287 limit = 100000000;
288
289 for (i=0; i<limit; i++) {
290 if (todc_info->rtc_type == TODC_TYPE_MC146818)
291 uip = todc_read_val(todc_info->RTC_FREQ_SELECT);
292
293 sec = todc_read_val(todc_info->seconds) & 0x7f;
294 min = todc_read_val(todc_info->minutes) & 0x7f;
295 hour = todc_read_val(todc_info->hours) & 0x3f;
296 mday = todc_read_val(todc_info->day_of_month) & 0x3f;
297 mon = todc_read_val(todc_info->month) & 0x1f;
298 year = todc_read_val(todc_info->year) & 0xff;
299
300 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
301 uip |= todc_read_val(todc_info->RTC_FREQ_SELECT);
302 if ((uip & RTC_UIP) == 0)
303 break;
304 }
305 }
306
307 if (todc_info->rtc_type != TODC_TYPE_MC146818) {
308 switch (todc_info->rtc_type) {
309 case TODC_TYPE_DS1553:
310 case TODC_TYPE_DS1557:
311 case TODC_TYPE_DS1743:
312 case TODC_TYPE_DS1746: /* XXXX BAD HACK -> FIX */
313 case TODC_TYPE_DS1747:
314 case TODC_TYPE_DS17285:
315 break;
316 default:
317 save_control &= ~(todc_info->enable_read);
318 todc_write_val(todc_info->control_a, save_control);
319 }
320 }
321 spin_unlock(&rtc_lock);
322
323 if ((todc_info->rtc_type != TODC_TYPE_MC146818)
324 || ((save_control & RTC_DM_BINARY) == 0)
325 || RTC_ALWAYS_BCD) {
326 BCD_TO_BIN(sec);
327 BCD_TO_BIN(min);
328 BCD_TO_BIN(hour);
329 BCD_TO_BIN(mday);
330 BCD_TO_BIN(mon);
331 BCD_TO_BIN(year);
332 }
333
334 if ((year + 1900) < 1970) {
335 year += 100;
336 }
337
338 tm->tm_sec = sec;
339 tm->tm_min = min;
340 tm->tm_hour = hour;
341 tm->tm_mday = mday;
342 tm->tm_mon = mon;
343 tm->tm_year = year;
344
345 GregorianDay(tm);
346}
347
348int
349todc_set_rtc_time(struct rtc_time *tm)
350{
351 u_char save_control, save_freq_select = 0;
352
353 spin_lock(&rtc_lock);
354 save_control = todc_read_val(todc_info->control_a);
355
356 /* Assuming MK48T59_RTC_CA_WRITE & RTC_SET are equal */
357 todc_write_val(todc_info->control_a,
358 (save_control | todc_info->enable_write));
359 save_control &= ~(todc_info->enable_write); /* in case it was set */
360
361 if (todc_info->rtc_type == TODC_TYPE_MC146818) {
362 save_freq_select = todc_read_val(todc_info->RTC_FREQ_SELECT);
363 todc_write_val(todc_info->RTC_FREQ_SELECT,
364 save_freq_select | RTC_DIV_RESET2);
365 }
366
367 if ((todc_info->rtc_type != TODC_TYPE_MC146818)
368 || ((save_control & RTC_DM_BINARY) == 0)
369 || RTC_ALWAYS_BCD) {
370 BIN_TO_BCD(tm->tm_sec);
371 BIN_TO_BCD(tm->tm_min);
372 BIN_TO_BCD(tm->tm_hour);
373 BIN_TO_BCD(tm->tm_mon);
374 BIN_TO_BCD(tm->tm_mday);
375 BIN_TO_BCD(tm->tm_year);
376 }
377
378 todc_write_val(todc_info->seconds, tm->tm_sec);
379 todc_write_val(todc_info->minutes, tm->tm_min);
380 todc_write_val(todc_info->hours, tm->tm_hour);
381 todc_write_val(todc_info->month, tm->tm_mon);
382 todc_write_val(todc_info->day_of_month, tm->tm_mday);
383 todc_write_val(todc_info->year, tm->tm_year);
384
385 todc_write_val(todc_info->control_a, save_control);
386
387 if (todc_info->rtc_type == TODC_TYPE_MC146818)
388 todc_write_val(todc_info->RTC_FREQ_SELECT, save_freq_select);
389
390 spin_unlock(&rtc_lock);
391 return 0;
392}
diff --git a/arch/powerpc/sysdev/tsi108_pci.c b/arch/powerpc/sysdev/tsi108_pci.c
index 322f86e93de5..ae249c6bbbcf 100644
--- a/arch/powerpc/sysdev/tsi108_pci.c
+++ b/arch/powerpc/sysdev/tsi108_pci.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * 2004-2005 (c) Tundra Semiconductor Corp. 4 * 2004-2005 (c) Tundra Semiconductor Corp.
5 * Author: Alex Bounine (alexandreb@tundra.com) 5 * Author: Alex Bounine (alexandreb@tundra.com)
6 * Author: Roy Zang (tie-fei.zang@freescale.com)
7 * Add pci interrupt router host
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free 10 * under the terms of the GNU General Public License as published by the Free
@@ -48,6 +50,8 @@
48 50
49u32 tsi108_pci_cfg_base; 51u32 tsi108_pci_cfg_base;
50u32 tsi108_csr_vir_base; 52u32 tsi108_csr_vir_base;
53static struct device_node *pci_irq_node;
54static struct irq_host *pci_irq_host;
51 55
52extern u32 get_vir_csrbase(void); 56extern u32 get_vir_csrbase(void);
53extern u32 tsi108_read_reg(u32 reg_offset); 57extern u32 tsi108_read_reg(u32 reg_offset);
@@ -378,6 +382,38 @@ static struct irq_chip tsi108_pci_irq = {
378 .unmask = tsi108_pci_irq_enable, 382 .unmask = tsi108_pci_irq_enable,
379}; 383};
380 384
385static int pci_irq_host_xlate(struct irq_host *h, struct device_node *ct,
386 u32 *intspec, unsigned int intsize,
387 irq_hw_number_t *out_hwirq, unsigned int *out_flags)
388{
389 *out_hwirq = intspec[0];
390 *out_flags = IRQ_TYPE_LEVEL_HIGH;
391 return 0;
392}
393
394static int pci_irq_host_map(struct irq_host *h, unsigned int virq,
395 irq_hw_number_t hw)
396{ unsigned int irq;
397 DBG("%s(%d, 0x%lx)\n", __FUNCTION__, virq, hw);
398 if ((virq >= 1) && (virq <= 4)){
399 irq = virq + IRQ_PCI_INTAD_BASE - 1;
400 get_irq_desc(irq)->status |= IRQ_LEVEL;
401 set_irq_chip(irq, &tsi108_pci_irq);
402 }
403 return 0;
404}
405
406static int pci_irq_host_match(struct irq_host *h, struct device_node *node)
407{
408 return pci_irq_node == node;
409}
410
411static struct irq_host_ops pci_irq_host_ops = {
412 .match = pci_irq_host_match,
413 .map = pci_irq_host_map,
414 .xlate = pci_irq_host_xlate,
415};
416
381/* 417/*
382 * Exported functions 418 * Exported functions
383 */ 419 */
@@ -391,15 +427,15 @@ static struct irq_chip tsi108_pci_irq = {
391 * to the MPIC. 427 * to the MPIC.
392 */ 428 */
393 429
394void __init tsi108_pci_int_init(void) 430void __init tsi108_pci_int_init(struct device_node *node)
395{ 431{
396 u_int i;
397
398 DBG("Tsi108_pci_int_init: initializing PCI interrupts\n"); 432 DBG("Tsi108_pci_int_init: initializing PCI interrupts\n");
399 433
400 for (i = 0; i < NUM_PCI_IRQS; i++) { 434 pci_irq_node = of_node_get(node);
401 irq_desc[i + IRQ_PCI_INTAD_BASE].chip = &tsi108_pci_irq; 435 pci_irq_host = irq_alloc_host(IRQ_HOST_MAP_LEGACY, 0, &pci_irq_host_ops, 0);
402 irq_desc[i + IRQ_PCI_INTAD_BASE].status |= IRQ_LEVEL; 436 if (pci_irq_host == NULL) {
437 printk(KERN_ERR "pci_irq_host: failed to allocate irq host !\n");
438 return;
403 } 439 }
404 440
405 init_pci_source(); 441 init_pci_source();
diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index 109d874ecfbe..51d97588e762 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -3,5 +3,10 @@
3ifdef CONFIG_PPC64 3ifdef CONFIG_PPC64
4EXTRA_CFLAGS += -mno-minimal-toc 4EXTRA_CFLAGS += -mno-minimal-toc
5endif 5endif
6obj-y += xmon.o ppc-dis.o ppc-opc.o setjmp.o start.o \ 6
7 nonstdio.o 7obj-y += xmon.o setjmp.o start.o nonstdio.o
8
9ifdef CONFIG_XMON_DISASSEMBLY
10obj-y += ppc-dis.o ppc-opc.o
11obj-$(CONFIG_SPU_BASE) += spu-dis.o spu-opc.o
12endif
diff --git a/arch/powerpc/xmon/dis-asm.h b/arch/powerpc/xmon/dis-asm.h
new file mode 100644
index 000000000000..be3533b93f30
--- /dev/null
+++ b/arch/powerpc/xmon/dis-asm.h
@@ -0,0 +1,31 @@
1#ifndef _POWERPC_XMON_DIS_ASM_H
2#define _POWERPC_XMON_DIS_ASM_H
3/*
4 * Copyright (C) 2006 Michael Ellerman, IBM Corporation.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12extern void print_address (unsigned long memaddr);
13
14#ifdef CONFIG_XMON_DISASSEMBLY
15extern int print_insn_powerpc(unsigned long insn, unsigned long memaddr);
16extern int print_insn_spu(unsigned long insn, unsigned long memaddr);
17#else
18static inline int print_insn_powerpc(unsigned long insn, unsigned long memaddr)
19{
20 printf("%.8x", insn);
21 return 0;
22}
23
24static inline int print_insn_spu(unsigned long insn, unsigned long memaddr)
25{
26 printf("%.8x", insn);
27 return 0;
28}
29#endif
30
31#endif /* _POWERPC_XMON_DIS_ASM_H */
diff --git a/arch/powerpc/xmon/ppc-dis.c b/arch/powerpc/xmon/ppc-dis.c
index ac0a9d2427e0..89098f320ad5 100644
--- a/arch/powerpc/xmon/ppc-dis.c
+++ b/arch/powerpc/xmon/ppc-dis.c
@@ -1,5 +1,6 @@
1/* ppc-dis.c -- Disassemble PowerPC instructions 1/* ppc-dis.c -- Disassemble PowerPC instructions
2 Copyright 1994 Free Software Foundation, Inc. 2 Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
4 5
5This file is part of GDB, GAS, and the GNU binutils. 6This file is part of GDB, GAS, and the GNU binutils.
@@ -16,27 +17,36 @@ the GNU General Public License for more details.
16 17
17You should have received a copy of the GNU General Public License 18You should have received a copy of the GNU General Public License
18along with this file; see the file COPYING. If not, write to the Free 19along with this file; see the file COPYING. If not, write to the Free
19Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20 21
22#include <asm/cputable.h>
21#include "nonstdio.h" 23#include "nonstdio.h"
22#include "ansidecl.h" 24#include "ansidecl.h"
23#include "ppc.h" 25#include "ppc.h"
24 26#include "dis-asm.h"
25extern void print_address (unsigned long memaddr);
26 27
27/* Print a PowerPC or POWER instruction. */ 28/* Print a PowerPC or POWER instruction. */
28 29
29int 30int
30print_insn_powerpc (unsigned long insn, unsigned long memaddr, int dialect) 31print_insn_powerpc (unsigned long insn, unsigned long memaddr)
31{ 32{
32 const struct powerpc_opcode *opcode; 33 const struct powerpc_opcode *opcode;
33 const struct powerpc_opcode *opcode_end; 34 const struct powerpc_opcode *opcode_end;
34 unsigned long op; 35 unsigned long op;
36 int dialect;
35 37
36 if (dialect == 0) 38 dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON
37 dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON
38 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC; 39 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC;
39 40
41 if (cpu_has_feature(CPU_FTRS_POWER5))
42 dialect |= PPC_OPCODE_POWER5;
43
44 if (cpu_has_feature(CPU_FTRS_CELL))
45 dialect |= PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC;
46
47 if (cpu_has_feature(CPU_FTRS_POWER6))
48 dialect |= PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC;
49
40 /* Get the major opcode of the instruction. */ 50 /* Get the major opcode of the instruction. */
41 op = PPC_OP (insn); 51 op = PPC_OP (insn);
42 52
@@ -121,7 +131,8 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr, int dialect)
121 } 131 }
122 132
123 /* Print the operand as directed by the flags. */ 133 /* Print the operand as directed by the flags. */
124 if ((operand->flags & PPC_OPERAND_GPR) != 0) 134 if ((operand->flags & PPC_OPERAND_GPR) != 0
135 || ((operand->flags & PPC_OPERAND_GPR_0) != 0 && value != 0))
125 printf("r%ld", value); 136 printf("r%ld", value);
126 else if ((operand->flags & PPC_OPERAND_FPR) != 0) 137 else if ((operand->flags & PPC_OPERAND_FPR) != 0)
127 printf("f%ld", value); 138 printf("f%ld", value);
@@ -137,7 +148,7 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr, int dialect)
137 else 148 else
138 { 149 {
139 if (operand->bits == 3) 150 if (operand->bits == 3)
140 printf("cr%d", value); 151 printf("cr%ld", value);
141 else 152 else
142 { 153 {
143 static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; 154 static const char *cbnames[4] = { "lt", "gt", "eq", "so" };
diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index 5ee8fc32f824..5d841f4b3530 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -1,6 +1,6 @@
1/* ppc-opc.c -- PowerPC opcode list 1/* ppc-opc.c -- PowerPC opcode list
2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003 2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
3 Free Software Foundation, Inc. 3 2005 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
5 5
6 This file is part of GDB, GAS, and the GNU binutils. 6 This file is part of GDB, GAS, and the GNU binutils.
@@ -17,8 +17,8 @@
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this file; see the file COPYING. If not, write to the Free 19 along with this file; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 02111-1307, USA. */ 21 02110-1301, USA. */
22 22
23#include <linux/stddef.h> 23#include <linux/stddef.h>
24#include "nonstdio.h" 24#include "nonstdio.h"
@@ -86,6 +86,8 @@ static unsigned long insert_sh6 (unsigned long, long, int, const char **);
86static long extract_sh6 (unsigned long, int, int *); 86static long extract_sh6 (unsigned long, int, int *);
87static unsigned long insert_spr (unsigned long, long, int, const char **); 87static unsigned long insert_spr (unsigned long, long, int, const char **);
88static long extract_spr (unsigned long, int, int *); 88static long extract_spr (unsigned long, int, int *);
89static unsigned long insert_sprg (unsigned long, long, int, const char **);
90static long extract_sprg (unsigned long, int, int *);
89static unsigned long insert_tbr (unsigned long, long, int, const char **); 91static unsigned long insert_tbr (unsigned long, long, int, const char **);
90static long extract_tbr (unsigned long, int, int *); 92static long extract_tbr (unsigned long, int, int *);
91static unsigned long insert_ev2 (unsigned long, long, int, const char **); 93static unsigned long insert_ev2 (unsigned long, long, int, const char **);
@@ -196,8 +198,11 @@ const struct powerpc_operand powerpc_operands[] =
196#define BOE BO + 1 198#define BOE BO + 1
197 { 5, 21, insert_boe, extract_boe, 0 }, 199 { 5, 21, insert_boe, extract_boe, 0 },
198 200
201#define BH BOE + 1
202 { 2, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
203
199 /* The BT field in an X or XL form instruction. */ 204 /* The BT field in an X or XL form instruction. */
200#define BT BOE + 1 205#define BT BH + 1
201 { 5, 21, NULL, NULL, PPC_OPERAND_CR }, 206 { 5, 21, NULL, NULL, PPC_OPERAND_CR },
202 207
203 /* The condition register number portion of the BI field in a B form 208 /* The condition register number portion of the BI field in a B form
@@ -301,10 +306,14 @@ const struct powerpc_operand powerpc_operands[] =
301#define L FXM4 + 1 306#define L FXM4 + 1
302 { 1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 307 { 1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
303 308
304 /* The LEV field in a POWER SC form instruction. */ 309 /* The LEV field in a POWER SVC form instruction. */
305#define LEV L + 1 310#define SVC_LEV L + 1
306 { 7, 5, NULL, NULL, 0 }, 311 { 7, 5, NULL, NULL, 0 },
307 312
313 /* The LEV field in an SC form instruction. */
314#define LEV SVC_LEV + 1
315 { 7, 5, NULL, NULL, PPC_OPERAND_OPTIONAL },
316
308 /* The LI field in an I form instruction. The lower two bits are 317 /* The LI field in an I form instruction. The lower two bits are
309 forced to zero. */ 318 forced to zero. */
310#define LI LEV + 1 319#define LI LEV + 1
@@ -346,7 +355,7 @@ const struct powerpc_operand powerpc_operands[] =
346 355
347 /* The MO field in an mbar instruction. */ 356 /* The MO field in an mbar instruction. */
348#define MO MB6 + 1 357#define MO MB6 + 1
349 { 5, 21, NULL, NULL, 0 }, 358 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
350 359
351 /* The NB field in an X form instruction. The value 32 is stored as 360 /* The NB field in an X form instruction. The value 32 is stored as
352 0. */ 361 0. */
@@ -364,30 +373,38 @@ const struct powerpc_operand powerpc_operands[] =
364#define RA_MASK (0x1f << 16) 373#define RA_MASK (0x1f << 16)
365 { 5, 16, NULL, NULL, PPC_OPERAND_GPR }, 374 { 5, 16, NULL, NULL, PPC_OPERAND_GPR },
366 375
376 /* As above, but 0 in the RA field means zero, not r0. */
377#define RA0 RA + 1
378 { 5, 16, NULL, NULL, PPC_OPERAND_GPR_0 },
379
367 /* The RA field in the DQ form lq instruction, which has special 380 /* The RA field in the DQ form lq instruction, which has special
368 value restrictions. */ 381 value restrictions. */
369#define RAQ RA + 1 382#define RAQ RA0 + 1
370 { 5, 16, insert_raq, NULL, PPC_OPERAND_GPR }, 383 { 5, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 },
371 384
372 /* The RA field in a D or X form instruction which is an updating 385 /* The RA field in a D or X form instruction which is an updating
373 load, which means that the RA field may not be zero and may not 386 load, which means that the RA field may not be zero and may not
374 equal the RT field. */ 387 equal the RT field. */
375#define RAL RAQ + 1 388#define RAL RAQ + 1
376 { 5, 16, insert_ral, NULL, PPC_OPERAND_GPR }, 389 { 5, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 },
377 390
378 /* The RA field in an lmw instruction, which has special value 391 /* The RA field in an lmw instruction, which has special value
379 restrictions. */ 392 restrictions. */
380#define RAM RAL + 1 393#define RAM RAL + 1
381 { 5, 16, insert_ram, NULL, PPC_OPERAND_GPR }, 394 { 5, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 },
382 395
383 /* The RA field in a D or X form instruction which is an updating 396 /* The RA field in a D or X form instruction which is an updating
384 store or an updating floating point load, which means that the RA 397 store or an updating floating point load, which means that the RA
385 field may not be zero. */ 398 field may not be zero. */
386#define RAS RAM + 1 399#define RAS RAM + 1
387 { 5, 16, insert_ras, NULL, PPC_OPERAND_GPR }, 400 { 5, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 },
401
402 /* The RA field of the tlbwe instruction, which is optional. */
403#define RAOPT RAS + 1
404 { 5, 16, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
388 405
389 /* The RB field in an X, XO, M, or MDS form instruction. */ 406 /* The RB field in an X, XO, M, or MDS form instruction. */
390#define RB RAS + 1 407#define RB RAOPT + 1
391#define RB_MASK (0x1f << 11) 408#define RB_MASK (0x1f << 11)
392 { 5, 11, NULL, NULL, PPC_OPERAND_GPR }, 409 { 5, 11, NULL, NULL, PPC_OPERAND_GPR },
393 410
@@ -408,15 +425,20 @@ const struct powerpc_operand powerpc_operands[] =
408 /* The RS field of the DS form stq instruction, which has special 425 /* The RS field of the DS form stq instruction, which has special
409 value restrictions. */ 426 value restrictions. */
410#define RSQ RS + 1 427#define RSQ RS + 1
411 { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR }, 428 { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR_0 },
412 429
413 /* The RT field of the DQ form lq instruction, which has special 430 /* The RT field of the DQ form lq instruction, which has special
414 value restrictions. */ 431 value restrictions. */
415#define RTQ RSQ + 1 432#define RTQ RSQ + 1
416 { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR }, 433 { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR_0 },
434
435 /* The RS field of the tlbwe instruction, which is optional. */
436#define RSO RTQ + 1
437#define RTO RSO
438 { 5, 21, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
417 439
418 /* The SH field in an X or M form instruction. */ 440 /* The SH field in an X or M form instruction. */
419#define SH RTQ + 1 441#define SH RSO + 1
420#define SH_MASK (0x1f << 11) 442#define SH_MASK (0x1f << 11)
421 { 5, 11, NULL, NULL, 0 }, 443 { 5, 11, NULL, NULL, 0 },
422 444
@@ -425,8 +447,12 @@ const struct powerpc_operand powerpc_operands[] =
425#define SH6_MASK ((0x1f << 11) | (1 << 1)) 447#define SH6_MASK ((0x1f << 11) | (1 << 1))
426 { 6, 1, insert_sh6, extract_sh6, 0 }, 448 { 6, 1, insert_sh6, extract_sh6, 0 },
427 449
450 /* The SH field of the tlbwe instruction, which is optional. */
451#define SHO SH6 + 1
452 { 5, 11,NULL, NULL, PPC_OPERAND_OPTIONAL },
453
428 /* The SI field in a D form instruction. */ 454 /* The SI field in a D form instruction. */
429#define SI SH6 + 1 455#define SI SHO + 1
430 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED }, 456 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED },
431 457
432 /* The SI field in a D form instruction when we accept a wide range 458 /* The SI field in a D form instruction when we accept a wide range
@@ -448,8 +474,7 @@ const struct powerpc_operand powerpc_operands[] =
448 474
449 /* The SPRG register number in an XFX form m[ft]sprg instruction. */ 475 /* The SPRG register number in an XFX form m[ft]sprg instruction. */
450#define SPRG SPRBAT + 1 476#define SPRG SPRBAT + 1
451#define SPRG_MASK (0x3 << 16) 477 { 5, 16, insert_sprg, extract_sprg, 0 },
452 { 2, 16, NULL, NULL, 0 },
453 478
454 /* The SR field in an X form instruction. */ 479 /* The SR field in an X form instruction. */
455#define SR SPRG + 1 480#define SR SPRG + 1
@@ -536,10 +561,45 @@ const struct powerpc_operand powerpc_operands[] =
536#define WS_MASK (0x7 << 11) 561#define WS_MASK (0x7 << 11)
537 { 3, 11, NULL, NULL, 0 }, 562 { 3, 11, NULL, NULL, 0 },
538 563
539 /* The L field in an mtmsrd instruction */ 564 /* The L field in an mtmsrd or A form instruction. */
540#define MTMSRD_L WS + 1 565#define MTMSRD_L WS + 1
566#define A_L MTMSRD_L
541 { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL }, 567 { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },
542 568
569 /* The DCM field in a Z form instruction. */
570#define DCM MTMSRD_L + 1
571 { 6, 16, NULL, NULL, 0 },
572
573 /* Likewise, the DGM field in a Z form instruction. */
574#define DGM DCM + 1
575 { 6, 16, NULL, NULL, 0 },
576
577#define TE DGM + 1
578 { 5, 11, NULL, NULL, 0 },
579
580#define RMC TE + 1
581 { 2, 21, NULL, NULL, 0 },
582
583#define R RMC + 1
584 { 1, 15, NULL, NULL, 0 },
585
586#define SP R + 1
587 { 2, 11, NULL, NULL, 0 },
588
589#define S SP + 1
590 { 1, 11, NULL, NULL, 0 },
591
592 /* SH field starting at bit position 16. */
593#define SH16 S + 1
594 { 6, 10, NULL, NULL, 0 },
595
596 /* The L field in an X form with the RT field fixed instruction. */
597#define XRT_L SH16 + 1
598 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
599
600 /* The EH field in larx instruction. */
601#define EH XRT_L + 1
602 { 1, 0, NULL, NULL, PPC_OPERAND_OPTIONAL },
543}; 603};
544 604
545/* The functions used to insert and extract complicated operands. */ 605/* The functions used to insert and extract complicated operands. */
@@ -550,7 +610,6 @@ const struct powerpc_operand powerpc_operands[] =
550 and the extraction function just checks that the fields are the 610 and the extraction function just checks that the fields are the
551 same. */ 611 same. */
552 612
553/*ARGSUSED*/
554static unsigned long 613static unsigned long
555insert_bat (unsigned long insn, 614insert_bat (unsigned long insn,
556 long value ATTRIBUTE_UNUSED, 615 long value ATTRIBUTE_UNUSED,
@@ -576,7 +635,6 @@ extract_bat (unsigned long insn,
576 and the extraction function just checks that the fields are the 635 and the extraction function just checks that the fields are the
577 same. */ 636 same. */
578 637
579/*ARGSUSED*/
580static unsigned long 638static unsigned long
581insert_bba (unsigned long insn, 639insert_bba (unsigned long insn,
582 long value ATTRIBUTE_UNUSED, 640 long value ATTRIBUTE_UNUSED,
@@ -599,7 +657,6 @@ extract_bba (unsigned long insn,
599/* The BD field in a B form instruction. The lower two bits are 657/* The BD field in a B form instruction. The lower two bits are
600 forced to zero. */ 658 forced to zero. */
601 659
602/*ARGSUSED*/
603static unsigned long 660static unsigned long
604insert_bd (unsigned long insn, 661insert_bd (unsigned long insn,
605 long value, 662 long value,
@@ -609,7 +666,6 @@ insert_bd (unsigned long insn,
609 return insn | (value & 0xfffc); 666 return insn | (value & 0xfffc);
610} 667}
611 668
612/*ARGSUSED*/
613static long 669static long
614extract_bd (unsigned long insn, 670extract_bd (unsigned long insn,
615 int dialect ATTRIBUTE_UNUSED, 671 int dialect ATTRIBUTE_UNUSED,
@@ -631,7 +687,6 @@ extract_bd (unsigned long insn,
631 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000 687 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000
632 for branch on CTR. We only handle the taken/not-taken hint here. */ 688 for branch on CTR. We only handle the taken/not-taken hint here. */
633 689
634/*ARGSUSED*/
635static unsigned long 690static unsigned long
636insert_bdm (unsigned long insn, 691insert_bdm (unsigned long insn,
637 long value, 692 long value,
@@ -677,7 +732,6 @@ extract_bdm (unsigned long insn,
677 This is like BDM, above, except that the branch is expected to be 732 This is like BDM, above, except that the branch is expected to be
678 taken. */ 733 taken. */
679 734
680/*ARGSUSED*/
681static unsigned long 735static unsigned long
682insert_bdp (unsigned long insn, 736insert_bdp (unsigned long insn,
683 long value, 737 long value,
@@ -831,7 +885,6 @@ extract_boe (unsigned long insn,
831/* The DQ field in a DQ form instruction. This is like D, but the 885/* The DQ field in a DQ form instruction. This is like D, but the
832 lower four bits are forced to zero. */ 886 lower four bits are forced to zero. */
833 887
834/*ARGSUSED*/
835static unsigned long 888static unsigned long
836insert_dq (unsigned long insn, 889insert_dq (unsigned long insn,
837 long value, 890 long value,
@@ -843,7 +896,6 @@ insert_dq (unsigned long insn,
843 return insn | (value & 0xfff0); 896 return insn | (value & 0xfff0);
844} 897}
845 898
846/*ARGSUSED*/
847static long 899static long
848extract_dq (unsigned long insn, 900extract_dq (unsigned long insn,
849 int dialect ATTRIBUTE_UNUSED, 901 int dialect ATTRIBUTE_UNUSED,
@@ -918,7 +970,6 @@ extract_ev8 (unsigned long insn,
918/* The DS field in a DS form instruction. This is like D, but the 970/* The DS field in a DS form instruction. This is like D, but the
919 lower two bits are forced to zero. */ 971 lower two bits are forced to zero. */
920 972
921/*ARGSUSED*/
922static unsigned long 973static unsigned long
923insert_ds (unsigned long insn, 974insert_ds (unsigned long insn,
924 long value, 975 long value,
@@ -930,7 +981,6 @@ insert_ds (unsigned long insn,
930 return insn | (value & 0xfffc); 981 return insn | (value & 0xfffc);
931} 982}
932 983
933/*ARGSUSED*/
934static long 984static long
935extract_ds (unsigned long insn, 985extract_ds (unsigned long insn,
936 int dialect ATTRIBUTE_UNUSED, 986 int dialect ATTRIBUTE_UNUSED,
@@ -941,7 +991,6 @@ extract_ds (unsigned long insn,
941 991
942/* The DE field in a DE form instruction. */ 992/* The DE field in a DE form instruction. */
943 993
944/*ARGSUSED*/
945static unsigned long 994static unsigned long
946insert_de (unsigned long insn, 995insert_de (unsigned long insn,
947 long value, 996 long value,
@@ -953,7 +1002,6 @@ insert_de (unsigned long insn,
953 return insn | ((value << 4) & 0xfff0); 1002 return insn | ((value << 4) & 0xfff0);
954} 1003}
955 1004
956/*ARGSUSED*/
957static long 1005static long
958extract_de (unsigned long insn, 1006extract_de (unsigned long insn,
959 int dialect ATTRIBUTE_UNUSED, 1007 int dialect ATTRIBUTE_UNUSED,
@@ -964,7 +1012,6 @@ extract_de (unsigned long insn,
964 1012
965/* The DES field in a DES form instruction. */ 1013/* The DES field in a DES form instruction. */
966 1014
967/*ARGSUSED*/
968static unsigned long 1015static unsigned long
969insert_des (unsigned long insn, 1016insert_des (unsigned long insn,
970 long value, 1017 long value,
@@ -978,7 +1025,6 @@ insert_des (unsigned long insn,
978 return insn | ((value << 2) & 0xfff0); 1025 return insn | ((value << 2) & 0xfff0);
979} 1026}
980 1027
981/*ARGSUSED*/
982static long 1028static long
983extract_des (unsigned long insn, 1029extract_des (unsigned long insn,
984 int dialect ATTRIBUTE_UNUSED, 1030 int dialect ATTRIBUTE_UNUSED,
@@ -995,17 +1041,33 @@ insert_fxm (unsigned long insn,
995 int dialect, 1041 int dialect,
996 const char **errmsg) 1042 const char **errmsg)
997{ 1043{
1044 /* If we're handling the mfocrf and mtocrf insns ensure that exactly
1045 one bit of the mask field is set. */
1046 if ((insn & (1 << 20)) != 0)
1047 {
1048 if (value == 0 || (value & -value) != value)
1049 {
1050 *errmsg = _("invalid mask field");
1051 value = 0;
1052 }
1053 }
1054
998 /* If the optional field on mfcr is missing that means we want to use 1055 /* If the optional field on mfcr is missing that means we want to use
999 the old form of the instruction that moves the whole cr. In that 1056 the old form of the instruction that moves the whole cr. In that
1000 case we'll have VALUE zero. There doesn't seem to be a way to 1057 case we'll have VALUE zero. There doesn't seem to be a way to
1001 distinguish this from the case where someone writes mfcr %r3,0. */ 1058 distinguish this from the case where someone writes mfcr %r3,0. */
1002 if (value == 0) 1059 else if (value == 0)
1003 ; 1060 ;
1004 1061
1005 /* If only one bit of the FXM field is set, we can use the new form 1062 /* If only one bit of the FXM field is set, we can use the new form
1006 of the instruction, which is faster. Unlike the Power4 branch hint 1063 of the instruction, which is faster. Unlike the Power4 branch hint
1007 encoding, this is not backward compatible. */ 1064 encoding, this is not backward compatible. Do not generate the
1008 else if ((dialect & PPC_OPCODE_POWER4) != 0 && (value & -value) == value) 1065 new form unless -mpower4 has been given, or -many and the two
1066 operand form of mfcr was used. */
1067 else if ((value & -value) == value
1068 && ((dialect & PPC_OPCODE_POWER4) != 0
1069 || ((dialect & PPC_OPCODE_ANY) != 0
1070 && (insn & (0x3ff << 1)) == 19 << 1)))
1009 insn |= 1 << 20; 1071 insn |= 1 << 20;
1010 1072
1011 /* Any other value on mfcr is an error. */ 1073 /* Any other value on mfcr is an error. */
@@ -1020,7 +1082,7 @@ insert_fxm (unsigned long insn,
1020 1082
1021static long 1083static long
1022extract_fxm (unsigned long insn, 1084extract_fxm (unsigned long insn,
1023 int dialect, 1085 int dialect ATTRIBUTE_UNUSED,
1024 int *invalid) 1086 int *invalid)
1025{ 1087{
1026 long mask = (insn >> 12) & 0xff; 1088 long mask = (insn >> 12) & 0xff;
@@ -1028,14 +1090,9 @@ extract_fxm (unsigned long insn,
1028 /* Is this a Power4 insn? */ 1090 /* Is this a Power4 insn? */
1029 if ((insn & (1 << 20)) != 0) 1091 if ((insn & (1 << 20)) != 0)
1030 { 1092 {
1031 if ((dialect & PPC_OPCODE_POWER4) == 0) 1093 /* Exactly one bit of MASK should be set. */
1094 if (mask == 0 || (mask & -mask) != mask)
1032 *invalid = 1; 1095 *invalid = 1;
1033 else
1034 {
1035 /* Exactly one bit of MASK should be set. */
1036 if (mask == 0 || (mask & -mask) != mask)
1037 *invalid = 1;
1038 }
1039 } 1096 }
1040 1097
1041 /* Check that non-power4 form of mfcr has a zero MASK. */ 1098 /* Check that non-power4 form of mfcr has a zero MASK. */
@@ -1051,7 +1108,6 @@ extract_fxm (unsigned long insn,
1051/* The LI field in an I form instruction. The lower two bits are 1108/* The LI field in an I form instruction. The lower two bits are
1052 forced to zero. */ 1109 forced to zero. */
1053 1110
1054/*ARGSUSED*/
1055static unsigned long 1111static unsigned long
1056insert_li (unsigned long insn, 1112insert_li (unsigned long insn,
1057 long value, 1113 long value,
@@ -1063,7 +1119,6 @@ insert_li (unsigned long insn,
1063 return insn | (value & 0x3fffffc); 1119 return insn | (value & 0x3fffffc);
1064} 1120}
1065 1121
1066/*ARGSUSED*/
1067static long 1122static long
1068extract_li (unsigned long insn, 1123extract_li (unsigned long insn,
1069 int dialect ATTRIBUTE_UNUSED, 1124 int dialect ATTRIBUTE_UNUSED,
@@ -1163,7 +1218,6 @@ extract_mbe (unsigned long insn,
1163/* The MB or ME field in an MD or MDS form instruction. The high bit 1218/* The MB or ME field in an MD or MDS form instruction. The high bit
1164 is wrapped to the low end. */ 1219 is wrapped to the low end. */
1165 1220
1166/*ARGSUSED*/
1167static unsigned long 1221static unsigned long
1168insert_mb6 (unsigned long insn, 1222insert_mb6 (unsigned long insn,
1169 long value, 1223 long value,
@@ -1173,7 +1227,6 @@ insert_mb6 (unsigned long insn,
1173 return insn | ((value & 0x1f) << 6) | (value & 0x20); 1227 return insn | ((value & 0x1f) << 6) | (value & 0x20);
1174} 1228}
1175 1229
1176/*ARGSUSED*/
1177static long 1230static long
1178extract_mb6 (unsigned long insn, 1231extract_mb6 (unsigned long insn,
1179 int dialect ATTRIBUTE_UNUSED, 1232 int dialect ATTRIBUTE_UNUSED,
@@ -1198,7 +1251,6 @@ insert_nb (unsigned long insn,
1198 return insn | ((value & 0x1f) << 11); 1251 return insn | ((value & 0x1f) << 11);
1199} 1252}
1200 1253
1201/*ARGSUSED*/
1202static long 1254static long
1203extract_nb (unsigned long insn, 1255extract_nb (unsigned long insn,
1204 int dialect ATTRIBUTE_UNUSED, 1256 int dialect ATTRIBUTE_UNUSED,
@@ -1217,7 +1269,6 @@ extract_nb (unsigned long insn,
1217 invalid, since we never want to recognize an instruction which uses 1269 invalid, since we never want to recognize an instruction which uses
1218 a field of this type. */ 1270 a field of this type. */
1219 1271
1220/*ARGSUSED*/
1221static unsigned long 1272static unsigned long
1222insert_nsi (unsigned long insn, 1273insert_nsi (unsigned long insn,
1223 long value, 1274 long value,
@@ -1269,7 +1320,6 @@ insert_ram (unsigned long insn,
1269/* The RA field in the DQ form lq instruction, which has special 1320/* The RA field in the DQ form lq instruction, which has special
1270 value restrictions. */ 1321 value restrictions. */
1271 1322
1272/*ARGSUSED*/
1273static unsigned long 1323static unsigned long
1274insert_raq (unsigned long insn, 1324insert_raq (unsigned long insn,
1275 long value, 1325 long value,
@@ -1304,7 +1354,6 @@ insert_ras (unsigned long insn,
1304 function just copies the BT field into the BA field, and the 1354 function just copies the BT field into the BA field, and the
1305 extraction function just checks that the fields are the same. */ 1355 extraction function just checks that the fields are the same. */
1306 1356
1307/*ARGSUSED*/
1308static unsigned long 1357static unsigned long
1309insert_rbs (unsigned long insn, 1358insert_rbs (unsigned long insn,
1310 long value ATTRIBUTE_UNUSED, 1359 long value ATTRIBUTE_UNUSED,
@@ -1327,7 +1376,6 @@ extract_rbs (unsigned long insn,
1327/* The RT field of the DQ form lq instruction, which has special 1376/* The RT field of the DQ form lq instruction, which has special
1328 value restrictions. */ 1377 value restrictions. */
1329 1378
1330/*ARGSUSED*/
1331static unsigned long 1379static unsigned long
1332insert_rtq (unsigned long insn, 1380insert_rtq (unsigned long insn,
1333 long value, 1381 long value,
@@ -1342,7 +1390,6 @@ insert_rtq (unsigned long insn,
1342/* The RS field of the DS form stq instruction, which has special 1390/* The RS field of the DS form stq instruction, which has special
1343 value restrictions. */ 1391 value restrictions. */
1344 1392
1345/*ARGSUSED*/
1346static unsigned long 1393static unsigned long
1347insert_rsq (unsigned long insn, 1394insert_rsq (unsigned long insn,
1348 long value ATTRIBUTE_UNUSED, 1395 long value ATTRIBUTE_UNUSED,
@@ -1356,7 +1403,6 @@ insert_rsq (unsigned long insn,
1356 1403
1357/* The SH field in an MD form instruction. This is split. */ 1404/* The SH field in an MD form instruction. This is split. */
1358 1405
1359/*ARGSUSED*/
1360static unsigned long 1406static unsigned long
1361insert_sh6 (unsigned long insn, 1407insert_sh6 (unsigned long insn,
1362 long value, 1408 long value,
@@ -1366,7 +1412,6 @@ insert_sh6 (unsigned long insn,
1366 return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4); 1412 return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
1367} 1413}
1368 1414
1369/*ARGSUSED*/
1370static long 1415static long
1371extract_sh6 (unsigned long insn, 1416extract_sh6 (unsigned long insn,
1372 int dialect ATTRIBUTE_UNUSED, 1417 int dialect ATTRIBUTE_UNUSED,
@@ -1395,6 +1440,47 @@ extract_spr (unsigned long insn,
1395 return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0); 1440 return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
1396} 1441}
1397 1442
1443/* Some dialects have 8 SPRG registers instead of the standard 4. */
1444
1445static unsigned long
1446insert_sprg (unsigned long insn,
1447 long value,
1448 int dialect,
1449 const char **errmsg)
1450{
1451 /* This check uses PPC_OPCODE_403 because PPC405 is later defined
1452 as a synonym. If ever a 405 specific dialect is added this
1453 check should use that instead. */
1454 if (value > 7
1455 || (value > 3
1456 && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))
1457 *errmsg = _("invalid sprg number");
1458
1459 /* If this is mfsprg4..7 then use spr 260..263 which can be read in
1460 user mode. Anything else must use spr 272..279. */
1461 if (value <= 3 || (insn & 0x100) != 0)
1462 value |= 0x10;
1463
1464 return insn | ((value & 0x17) << 16);
1465}
1466
1467static long
1468extract_sprg (unsigned long insn,
1469 int dialect,
1470 int *invalid)
1471{
1472 unsigned long val = (insn >> 16) & 0x1f;
1473
1474 /* mfsprg can use 260..263 and 272..279. mtsprg only uses spr 272..279
1475 If not BOOKE or 405, then both use only 272..275. */
1476 if (val <= 3
1477 || (val < 0x10 && (insn & 0x100) != 0)
1478 || (val - 0x10 > 3
1479 && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))
1480 *invalid = 1;
1481 return val & 7;
1482}
1483
1398/* The TBR field in an XFX instruction. This is just like SPR, but it 1484/* The TBR field in an XFX instruction. This is just like SPR, but it
1399 is optional. When TBR is omitted, it must be inserted as 268 (the 1485 is optional. When TBR is omitted, it must be inserted as 268 (the
1400 magic number of the TB register). These functions treat 0 1486 magic number of the TB register). These functions treat 0
@@ -1460,6 +1546,9 @@ extract_tbr (unsigned long insn,
1460/* An A_MASK with the FRA and FRC fields fixed. */ 1546/* An A_MASK with the FRA and FRC fields fixed. */
1461#define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK) 1547#define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK)
1462 1548
1549/* An AFRAFRC_MASK, but with L bit clear. */
1550#define AFRALFRC_MASK (AFRAFRC_MASK & ~((unsigned long) 1 << 16))
1551
1463/* A B form instruction. */ 1552/* A B form instruction. */
1464#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1)) 1553#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1))
1465#define B_MASK B (0x3f, 1, 1) 1554#define B_MASK B (0x3f, 1, 1)
@@ -1494,11 +1583,11 @@ extract_tbr (unsigned long insn,
1494 1583
1495/* An Context form instruction. */ 1584/* An Context form instruction. */
1496#define CTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7)) 1585#define CTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7))
1497#define CTX_MASK CTX(0x3f, 0x7) 1586#define CTX_MASK CTX(0x3f, 0x7)
1498 1587
1499/* An User Context form instruction. */ 1588/* An User Context form instruction. */
1500#define UCTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f)) 1589#define UCTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f))
1501#define UCTX_MASK UCTX(0x3f, 0x1f) 1590#define UCTX_MASK UCTX(0x3f, 0x1f)
1502 1591
1503/* The main opcode mask with the RA field clear. */ 1592/* The main opcode mask with the RA field clear. */
1504#define DRA_MASK (OP_MASK | RA_MASK) 1593#define DRA_MASK (OP_MASK | RA_MASK)
@@ -1570,12 +1659,21 @@ extract_tbr (unsigned long insn,
1570/* An X form instruction. */ 1659/* An X form instruction. */
1571#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1)) 1660#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
1572 1661
1662/* A Z form instruction. */
1663#define Z(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1))
1664
1573/* An X form instruction with the RC bit specified. */ 1665/* An X form instruction with the RC bit specified. */
1574#define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1)) 1666#define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1))
1575 1667
1668/* A Z form instruction with the RC bit specified. */
1669#define ZRC(op, xop, rc) (Z ((op), (xop)) | ((rc) & 1))
1670
1576/* The mask for an X form instruction. */ 1671/* The mask for an X form instruction. */
1577#define X_MASK XRC (0x3f, 0x3ff, 1) 1672#define X_MASK XRC (0x3f, 0x3ff, 1)
1578 1673
1674/* The mask for a Z form instruction. */
1675#define Z_MASK ZRC (0x3f, 0x1ff, 1)
1676
1579/* An X_MASK with the RA field fixed. */ 1677/* An X_MASK with the RA field fixed. */
1580#define XRA_MASK (X_MASK | RA_MASK) 1678#define XRA_MASK (X_MASK | RA_MASK)
1581 1679
@@ -1585,6 +1683,9 @@ extract_tbr (unsigned long insn,
1585/* An X_MASK with the RT field fixed. */ 1683/* An X_MASK with the RT field fixed. */
1586#define XRT_MASK (X_MASK | RT_MASK) 1684#define XRT_MASK (X_MASK | RT_MASK)
1587 1685
1686/* An XRT_MASK mask with the L bits clear. */
1687#define XLRT_MASK (XRT_MASK & ~((unsigned long) 0x3 << 21))
1688
1588/* An X_MASK with the RA and RB fields fixed. */ 1689/* An X_MASK with the RA and RB fields fixed. */
1589#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK) 1690#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
1590 1691
@@ -1597,8 +1698,8 @@ extract_tbr (unsigned long insn,
1597/* An XRTRA_MASK, but with L bit clear. */ 1698/* An XRTRA_MASK, but with L bit clear. */
1598#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21)) 1699#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21))
1599 1700
1600/* An X form comparison instruction. */ 1701/* An X form instruction with the L bit specified. */
1601#define XCMPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21)) 1702#define XOPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21))
1602 1703
1603/* The mask for an X form comparison instruction. */ 1704/* The mask for an X form comparison instruction. */
1604#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22)) 1705#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22))
@@ -1621,6 +1722,9 @@ extract_tbr (unsigned long insn,
1621/* An X form sync instruction with everything filled in except the LS field. */ 1722/* An X form sync instruction with everything filled in except the LS field. */
1622#define XSYNC_MASK (0xff9fffff) 1723#define XSYNC_MASK (0xff9fffff)
1623 1724
1725/* An X_MASK, but with the EH bit clear. */
1726#define XEH_MASK (X_MASK & ~((unsigned long )1))
1727
1624/* An X form AltiVec dss instruction. */ 1728/* An X form AltiVec dss instruction. */
1625#define XDSS(op, xop, a) (X ((op), (xop)) | ((((unsigned long)(a)) & 1) << 25)) 1729#define XDSS(op, xop, a) (X ((op), (xop)) | ((((unsigned long)(a)) & 1) << 25))
1626#define XDSS_MASK XDSS(0x3f, 0x3ff, 1) 1730#define XDSS_MASK XDSS(0x3f, 0x3ff, 1)
@@ -1663,6 +1767,9 @@ extract_tbr (unsigned long insn,
1663#define XLYBB_MASK (XLYLK_MASK | BB_MASK) 1767#define XLYBB_MASK (XLYLK_MASK | BB_MASK)
1664#define XLBOCBBB_MASK (XLOCB_MASK | BB_MASK) 1768#define XLBOCBBB_MASK (XLOCB_MASK | BB_MASK)
1665 1769
1770/* A mask for branch instructions using the BH field. */
1771#define XLBH_MASK (XL_MASK | (0x1c << 11))
1772
1666/* An XL_MASK with the BO and BB fields fixed. */ 1773/* An XL_MASK with the BO and BB fields fixed. */
1667#define XLBOBB_MASK (XL_MASK | BO_MASK | BB_MASK) 1774#define XLBOBB_MASK (XL_MASK | BO_MASK | BB_MASK)
1668 1775
@@ -1682,11 +1789,12 @@ extract_tbr (unsigned long insn,
1682#define XS_MASK XS (0x3f, 0x1ff, 1) 1789#define XS_MASK XS (0x3f, 0x1ff, 1)
1683 1790
1684/* A mask for the FXM version of an XFX form instruction. */ 1791/* A mask for the FXM version of an XFX form instruction. */
1685#define XFXFXM_MASK (X_MASK | (1 << 11)) 1792#define XFXFXM_MASK (X_MASK | (1 << 11) | (1 << 20))
1686 1793
1687/* An XFX form instruction with the FXM field filled in. */ 1794/* An XFX form instruction with the FXM field filled in. */
1688#define XFXM(op, xop, fxm) \ 1795#define XFXM(op, xop, fxm, p4) \
1689 (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12)) 1796 (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12) \
1797 | ((unsigned long)(p4) << 20))
1690 1798
1691/* An XFX form instruction with the SPR field filled in. */ 1799/* An XFX form instruction with the SPR field filled in. */
1692#define XSPR(op, xop, spr) \ 1800#define XSPR(op, xop, spr) \
@@ -1699,7 +1807,7 @@ extract_tbr (unsigned long insn,
1699 1807
1700/* An XFX form instruction with the SPR field filled in except for the 1808/* An XFX form instruction with the SPR field filled in except for the
1701 SPRG field. */ 1809 SPRG field. */
1702#define XSPRG_MASK (XSPR_MASK &~ SPRG_MASK) 1810#define XSPRG_MASK (XSPR_MASK & ~(0x17 << 16))
1703 1811
1704/* An X form instruction with everything filled in except the E field. */ 1812/* An X form instruction with everything filled in except the E field. */
1705#define XE_MASK (0xffff7fff) 1813#define XE_MASK (0xffff7fff)
@@ -1769,6 +1877,9 @@ extract_tbr (unsigned long insn,
1769#define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON 1877#define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON
1770#define NOPOWER4 PPC_OPCODE_NOPOWER4 | PPCCOM 1878#define NOPOWER4 PPC_OPCODE_NOPOWER4 | PPCCOM
1771#define POWER4 PPC_OPCODE_POWER4 1879#define POWER4 PPC_OPCODE_POWER4
1880#define POWER5 PPC_OPCODE_POWER5
1881#define POWER6 PPC_OPCODE_POWER6
1882#define CELL PPC_OPCODE_CELL
1772#define PPC32 PPC_OPCODE_32 | PPC_OPCODE_PPC 1883#define PPC32 PPC_OPCODE_32 | PPC_OPCODE_PPC
1773#define PPC64 PPC_OPCODE_64 | PPC_OPCODE_PPC 1884#define PPC64 PPC_OPCODE_64 | PPC_OPCODE_PPC
1774#define PPC403 PPC_OPCODE_403 1885#define PPC403 PPC_OPCODE_403
@@ -1776,7 +1887,7 @@ extract_tbr (unsigned long insn,
1776#define PPC440 PPC_OPCODE_440 1887#define PPC440 PPC_OPCODE_440
1777#define PPC750 PPC 1888#define PPC750 PPC
1778#define PPC860 PPC 1889#define PPC860 PPC
1779#define PPCVEC PPC_OPCODE_ALTIVEC | PPC_OPCODE_PPC 1890#define PPCVEC PPC_OPCODE_ALTIVEC
1780#define POWER PPC_OPCODE_POWER 1891#define POWER PPC_OPCODE_POWER
1781#define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2 1892#define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2
1782#define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2 1893#define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2
@@ -1790,6 +1901,7 @@ extract_tbr (unsigned long insn,
1790#define BOOKE PPC_OPCODE_BOOKE 1901#define BOOKE PPC_OPCODE_BOOKE
1791#define BOOKE64 PPC_OPCODE_BOOKE64 1902#define BOOKE64 PPC_OPCODE_BOOKE64
1792#define CLASSIC PPC_OPCODE_CLASSIC 1903#define CLASSIC PPC_OPCODE_CLASSIC
1904#define PPCE300 PPC_OPCODE_E300
1793#define PPCSPE PPC_OPCODE_SPE 1905#define PPCSPE PPC_OPCODE_SPE
1794#define PPCISEL PPC_OPCODE_ISEL 1906#define PPCISEL PPC_OPCODE_ISEL
1795#define PPCEFS PPC_OPCODE_EFS 1907#define PPCEFS PPC_OPCODE_EFS
@@ -1952,6 +2064,41 @@ const struct powerpc_opcode powerpc_opcodes[] = {
1952{ "nmaclhwso.", XO(4,494,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 2064{ "nmaclhwso.", XO(4,494,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } },
1953{ "mfvscr", VX(4, 1540), VX_MASK, PPCVEC, { VD } }, 2065{ "mfvscr", VX(4, 1540), VX_MASK, PPCVEC, { VD } },
1954{ "mtvscr", VX(4, 1604), VX_MASK, PPCVEC, { VB } }, 2066{ "mtvscr", VX(4, 1604), VX_MASK, PPCVEC, { VB } },
2067
2068 /* Double-precision opcodes. */
2069 /* Some of these conflict with AltiVec, so move them before, since
2070 PPCVEC includes the PPC_OPCODE_PPC set. */
2071{ "efscfd", VX(4, 719), VX_MASK, PPCEFS, { RS, RB } },
2072{ "efdabs", VX(4, 740), VX_MASK, PPCEFS, { RS, RA } },
2073{ "efdnabs", VX(4, 741), VX_MASK, PPCEFS, { RS, RA } },
2074{ "efdneg", VX(4, 742), VX_MASK, PPCEFS, { RS, RA } },
2075{ "efdadd", VX(4, 736), VX_MASK, PPCEFS, { RS, RA, RB } },
2076{ "efdsub", VX(4, 737), VX_MASK, PPCEFS, { RS, RA, RB } },
2077{ "efdmul", VX(4, 744), VX_MASK, PPCEFS, { RS, RA, RB } },
2078{ "efddiv", VX(4, 745), VX_MASK, PPCEFS, { RS, RA, RB } },
2079{ "efdcmpgt", VX(4, 748), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2080{ "efdcmplt", VX(4, 749), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2081{ "efdcmpeq", VX(4, 750), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2082{ "efdtstgt", VX(4, 764), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2083{ "efdtstlt", VX(4, 765), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2084{ "efdtsteq", VX(4, 766), VX_MASK, PPCEFS, { CRFD, RA, RB } },
2085{ "efdcfsi", VX(4, 753), VX_MASK, PPCEFS, { RS, RB } },
2086{ "efdcfsid", VX(4, 739), VX_MASK, PPCEFS, { RS, RB } },
2087{ "efdcfui", VX(4, 752), VX_MASK, PPCEFS, { RS, RB } },
2088{ "efdcfuid", VX(4, 738), VX_MASK, PPCEFS, { RS, RB } },
2089{ "efdcfsf", VX(4, 755), VX_MASK, PPCEFS, { RS, RB } },
2090{ "efdcfuf", VX(4, 754), VX_MASK, PPCEFS, { RS, RB } },
2091{ "efdctsi", VX(4, 757), VX_MASK, PPCEFS, { RS, RB } },
2092{ "efdctsidz",VX(4, 747), VX_MASK, PPCEFS, { RS, RB } },
2093{ "efdctsiz", VX(4, 762), VX_MASK, PPCEFS, { RS, RB } },
2094{ "efdctui", VX(4, 756), VX_MASK, PPCEFS, { RS, RB } },
2095{ "efdctuidz",VX(4, 746), VX_MASK, PPCEFS, { RS, RB } },
2096{ "efdctuiz", VX(4, 760), VX_MASK, PPCEFS, { RS, RB } },
2097{ "efdctsf", VX(4, 759), VX_MASK, PPCEFS, { RS, RB } },
2098{ "efdctuf", VX(4, 758), VX_MASK, PPCEFS, { RS, RB } },
2099{ "efdcfs", VX(4, 751), VX_MASK, PPCEFS, { RS, RB } },
2100 /* End of double-precision opcodes. */
2101
1955{ "vaddcuw", VX(4, 384), VX_MASK, PPCVEC, { VD, VA, VB } }, 2102{ "vaddcuw", VX(4, 384), VX_MASK, PPCVEC, { VD, VA, VB } },
1956{ "vaddfp", VX(4, 10), VX_MASK, PPCVEC, { VD, VA, VB } }, 2103{ "vaddfp", VX(4, 10), VX_MASK, PPCVEC, { VD, VA, VB } },
1957{ "vaddsbs", VX(4, 768), VX_MASK, PPCVEC, { VD, VA, VB } }, 2104{ "vaddsbs", VX(4, 768), VX_MASK, PPCVEC, { VD, VA, VB } },
@@ -2389,16 +2536,16 @@ const struct powerpc_opcode powerpc_opcodes[] = {
2389 2536
2390{ "li", OP(14), DRA_MASK, PPCCOM, { RT, SI } }, 2537{ "li", OP(14), DRA_MASK, PPCCOM, { RT, SI } },
2391{ "lil", OP(14), DRA_MASK, PWRCOM, { RT, SI } }, 2538{ "lil", OP(14), DRA_MASK, PWRCOM, { RT, SI } },
2392{ "addi", OP(14), OP_MASK, PPCCOM, { RT, RA, SI } }, 2539{ "addi", OP(14), OP_MASK, PPCCOM, { RT, RA0, SI } },
2393{ "cal", OP(14), OP_MASK, PWRCOM, { RT, D, RA } }, 2540{ "cal", OP(14), OP_MASK, PWRCOM, { RT, D, RA0 } },
2394{ "subi", OP(14), OP_MASK, PPCCOM, { RT, RA, NSI } }, 2541{ "subi", OP(14), OP_MASK, PPCCOM, { RT, RA0, NSI } },
2395{ "la", OP(14), OP_MASK, PPCCOM, { RT, D, RA } }, 2542{ "la", OP(14), OP_MASK, PPCCOM, { RT, D, RA0 } },
2396 2543
2397{ "lis", OP(15), DRA_MASK, PPCCOM, { RT, SISIGNOPT } }, 2544{ "lis", OP(15), DRA_MASK, PPCCOM, { RT, SISIGNOPT } },
2398{ "liu", OP(15), DRA_MASK, PWRCOM, { RT, SISIGNOPT } }, 2545{ "liu", OP(15), DRA_MASK, PWRCOM, { RT, SISIGNOPT } },
2399{ "addis", OP(15), OP_MASK, PPCCOM, { RT,RA,SISIGNOPT } }, 2546{ "addis", OP(15), OP_MASK, PPCCOM, { RT,RA0,SISIGNOPT } },
2400{ "cau", OP(15), OP_MASK, PWRCOM, { RT,RA,SISIGNOPT } }, 2547{ "cau", OP(15), OP_MASK, PWRCOM, { RT,RA0,SISIGNOPT } },
2401{ "subis", OP(15), OP_MASK, PPCCOM, { RT, RA, NSI } }, 2548{ "subis", OP(15), OP_MASK, PPCCOM, { RT, RA0, NSI } },
2402 2549
2403{ "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } }, 2550{ "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } },
2404{ "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } }, 2551{ "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } },
@@ -2665,9 +2812,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
2665{ "bcla+", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDPA } }, 2812{ "bcla+", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDPA } },
2666{ "bcla", B(16,1,1), B_MASK, COM, { BO, BI, BDA } }, 2813{ "bcla", B(16,1,1), B_MASK, COM, { BO, BI, BDA } },
2667 2814
2668{ "sc", SC(17,1,0), 0xffffffff, PPC, { 0 } }, 2815{ "sc", SC(17,1,0), SC_MASK, PPC, { LEV } },
2669{ "svc", SC(17,0,0), SC_MASK, POWER, { LEV, FL1, FL2 } }, 2816{ "svc", SC(17,0,0), SC_MASK, POWER, { SVC_LEV, FL1, FL2 } },
2670{ "svcl", SC(17,0,1), SC_MASK, POWER, { LEV, FL1, FL2 } }, 2817{ "svcl", SC(17,0,1), SC_MASK, POWER, { SVC_LEV, FL1, FL2 } },
2671{ "svca", SC(17,1,0), SC_MASK, PWRCOM, { SV } }, 2818{ "svca", SC(17,1,0), SC_MASK, PWRCOM, { SV } },
2672{ "svcla", SC(17,1,1), SC_MASK, POWER, { SV } }, 2819{ "svcla", SC(17,1,1), SC_MASK, POWER, { SV } },
2673 2820
@@ -2890,12 +3037,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
2890{ "bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 3037{ "bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, { BI } },
2891{ "bdzflrl-",XLO(19,BODZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 3038{ "bdzflrl-",XLO(19,BODZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } },
2892{ "bdzflrl+",XLO(19,BODZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 3039{ "bdzflrl+",XLO(19,BODZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } },
2893{ "bclr", XLLK(19,16,0), XLYBB_MASK, PPCCOM, { BO, BI } },
2894{ "bclrl", XLLK(19,16,1), XLYBB_MASK, PPCCOM, { BO, BI } },
2895{ "bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3040{ "bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } },
2896{ "bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3041{ "bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } },
2897{ "bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3042{ "bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } },
2898{ "bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3043{ "bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } },
3044{ "bclr", XLLK(19,16,0), XLBH_MASK, PPCCOM, { BO, BI, BH } },
3045{ "bclrl", XLLK(19,16,1), XLBH_MASK, PPCCOM, { BO, BI, BH } },
2899{ "bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, { BO, BI } }, 3046{ "bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, { BO, BI } },
2900{ "bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, { BO, BI } }, 3047{ "bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, { BO, BI } },
2901{ "bclre", XLLK(19,17,0), XLBB_MASK, BOOKE64, { BO, BI } }, 3048{ "bclre", XLLK(19,17,0), XLBB_MASK, BOOKE64, { BO, BI } },
@@ -2924,14 +3071,23 @@ const struct powerpc_opcode powerpc_opcodes[] = {
2924 3071
2925{ "crand", XL(19,257), XL_MASK, COM, { BT, BA, BB } }, 3072{ "crand", XL(19,257), XL_MASK, COM, { BT, BA, BB } },
2926 3073
3074{ "hrfid", XL(19,274), 0xffffffff, POWER5 | CELL, { 0 } },
3075
2927{ "crset", XL(19,289), XL_MASK, PPCCOM, { BT, BAT, BBA } }, 3076{ "crset", XL(19,289), XL_MASK, PPCCOM, { BT, BAT, BBA } },
2928{ "creqv", XL(19,289), XL_MASK, COM, { BT, BA, BB } }, 3077{ "creqv", XL(19,289), XL_MASK, COM, { BT, BA, BB } },
2929 3078
3079{ "doze", XL(19,402), 0xffffffff, POWER6, { 0 } },
3080
2930{ "crorc", XL(19,417), XL_MASK, COM, { BT, BA, BB } }, 3081{ "crorc", XL(19,417), XL_MASK, COM, { BT, BA, BB } },
2931 3082
3083{ "nap", XL(19,434), 0xffffffff, POWER6, { 0 } },
3084
2932{ "crmove", XL(19,449), XL_MASK, PPCCOM, { BT, BA, BBA } }, 3085{ "crmove", XL(19,449), XL_MASK, PPCCOM, { BT, BA, BBA } },
2933{ "cror", XL(19,449), XL_MASK, COM, { BT, BA, BB } }, 3086{ "cror", XL(19,449), XL_MASK, COM, { BT, BA, BB } },
2934 3087
3088{ "sleep", XL(19,466), 0xffffffff, POWER6, { 0 } },
3089{ "rvwinkle", XL(19,498), 0xffffffff, POWER6, { 0 } },
3090
2935{ "bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, { 0 } }, 3091{ "bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, { 0 } },
2936{ "bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, { 0 } }, 3092{ "bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, { 0 } },
2937{ "bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 3093{ "bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } },
@@ -3074,12 +3230,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3074{ "bfctrl-", XLO(19,BOFM4,528,1), XLBOBB_MASK, POWER4, { BI } }, 3230{ "bfctrl-", XLO(19,BOFM4,528,1), XLBOBB_MASK, POWER4, { BI } },
3075{ "bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, 3231{ "bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, NOPOWER4, { BI } },
3076{ "bfctrl+", XLO(19,BOFP4,528,1), XLBOBB_MASK, POWER4, { BI } }, 3232{ "bfctrl+", XLO(19,BOFP4,528,1), XLBOBB_MASK, POWER4, { BI } },
3077{ "bcctr", XLLK(19,528,0), XLYBB_MASK, PPCCOM, { BO, BI } },
3078{ "bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3233{ "bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } },
3079{ "bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3234{ "bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } },
3080{ "bcctrl", XLLK(19,528,1), XLYBB_MASK, PPCCOM, { BO, BI } },
3081{ "bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3235{ "bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } },
3082{ "bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 3236{ "bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } },
3237{ "bcctr", XLLK(19,528,0), XLBH_MASK, PPCCOM, { BO, BI, BH } },
3238{ "bcctrl", XLLK(19,528,1), XLBH_MASK, PPCCOM, { BO, BI, BH } },
3083{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } }, 3239{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } },
3084{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } }, 3240{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } },
3085{ "bcctre", XLLK(19,529,0), XLYBB_MASK, BOOKE64, { BO, BI } }, 3241{ "bcctre", XLLK(19,529,0), XLYBB_MASK, BOOKE64, { BO, BI } },
@@ -3158,8 +3314,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3158{ "rldcr", MDS(30,9,0), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, 3314{ "rldcr", MDS(30,9,0), MDS_MASK, PPC64, { RA, RS, RB, ME6 } },
3159{ "rldcr.", MDS(30,9,1), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, 3315{ "rldcr.", MDS(30,9,1), MDS_MASK, PPC64, { RA, RS, RB, ME6 } },
3160 3316
3161{ "cmpw", XCMPL(31,0,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, 3317{ "cmpw", XOPL(31,0,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } },
3162{ "cmpd", XCMPL(31,0,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, 3318{ "cmpd", XOPL(31,0,1), XCMPL_MASK, PPC64, { OBF, RA, RB } },
3163{ "cmp", X(31,0), XCMP_MASK, PPC, { BF, L, RA, RB } }, 3319{ "cmp", X(31,0), XCMP_MASK, PPC, { BF, L, RA, RB } },
3164{ "cmp", X(31,0), XCMPL_MASK, PWRCOM, { BF, RA, RB } }, 3320{ "cmp", X(31,0), XCMPL_MASK, PWRCOM, { BF, RA, RB } },
3165 3321
@@ -3228,17 +3384,18 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3228{ "iseleq", X(31,79), X_MASK, PPCISEL, { RT, RA, RB } }, 3384{ "iseleq", X(31,79), X_MASK, PPCISEL, { RT, RA, RB } },
3229{ "isel", XISEL(31,15), XISEL_MASK, PPCISEL, { RT, RA, RB, CRB } }, 3385{ "isel", XISEL(31,15), XISEL_MASK, PPCISEL, { RT, RA, RB, CRB } },
3230 3386
3231{ "mfcr", X(31,19), XRARB_MASK, NOPOWER4, { RT } }, 3387{ "mfocrf", XFXM(31,19,0,1), XFXFXM_MASK, COM, { RT, FXM } },
3388{ "mfcr", X(31,19), XRARB_MASK, NOPOWER4 | COM, { RT } },
3232{ "mfcr", X(31,19), XFXFXM_MASK, POWER4, { RT, FXM4 } }, 3389{ "mfcr", X(31,19), XFXFXM_MASK, POWER4, { RT, FXM4 } },
3233 3390
3234{ "lwarx", X(31,20), X_MASK, PPC, { RT, RA, RB } }, 3391{ "lwarx", X(31,20), XEH_MASK, PPC, { RT, RA0, RB, EH } },
3235 3392
3236{ "ldx", X(31,21), X_MASK, PPC64, { RT, RA, RB } }, 3393{ "ldx", X(31,21), X_MASK, PPC64, { RT, RA0, RB } },
3237 3394
3238{ "icbt", X(31,22), X_MASK, BOOKE, { CT, RA, RB } }, 3395{ "icbt", X(31,22), X_MASK, BOOKE|PPCE300, { CT, RA, RB } },
3239{ "icbt", X(31,262), XRT_MASK, PPC403, { RA, RB } }, 3396{ "icbt", X(31,262), XRT_MASK, PPC403, { RA, RB } },
3240 3397
3241{ "lwzx", X(31,23), X_MASK, PPCCOM, { RT, RA, RB } }, 3398{ "lwzx", X(31,23), X_MASK, PPCCOM, { RT, RA0, RB } },
3242{ "lx", X(31,23), X_MASK, PWRCOM, { RT, RA, RB } }, 3399{ "lx", X(31,23), X_MASK, PWRCOM, { RT, RA, RB } },
3243 3400
3244{ "slw", XRC(31,24,0), X_MASK, PPCCOM, { RA, RS, RB } }, 3401{ "slw", XRC(31,24,0), X_MASK, PPCCOM, { RA, RS, RB } },
@@ -3262,10 +3419,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3262 3419
3263{ "icbte", X(31,30), X_MASK, BOOKE64, { CT, RA, RB } }, 3420{ "icbte", X(31,30), X_MASK, BOOKE64, { CT, RA, RB } },
3264 3421
3265{ "lwzxe", X(31,31), X_MASK, BOOKE64, { RT, RA, RB } }, 3422{ "lwzxe", X(31,31), X_MASK, BOOKE64, { RT, RA0, RB } },
3266 3423
3267{ "cmplw", XCMPL(31,32,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, 3424{ "cmplw", XOPL(31,32,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } },
3268{ "cmpld", XCMPL(31,32,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, 3425{ "cmpld", XOPL(31,32,1), XCMPL_MASK, PPC64, { OBF, RA, RB } },
3269{ "cmpl", X(31,32), XCMP_MASK, PPC, { BF, L, RA, RB } }, 3426{ "cmpl", X(31,32), XCMP_MASK, PPC, { BF, L, RA, RB } },
3270{ "cmpl", X(31,32), XCMPL_MASK, PWRCOM, { BF, RA, RB } }, 3427{ "cmpl", X(31,32), XCMPL_MASK, PWRCOM, { BF, RA, RB } },
3271 3428
@@ -3324,15 +3481,16 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3324 3481
3325{ "mfmsr", X(31,83), XRARB_MASK, COM, { RT } }, 3482{ "mfmsr", X(31,83), XRARB_MASK, COM, { RT } },
3326 3483
3327{ "ldarx", X(31,84), X_MASK, PPC64, { RT, RA, RB } }, 3484{ "ldarx", X(31,84), XEH_MASK, PPC64, { RT, RA0, RB, EH } },
3328 3485
3329{ "dcbf", X(31,86), XRT_MASK, PPC, { RA, RB } }, 3486{ "dcbfl", XOPL(31,86,1), XRT_MASK, POWER5, { RA, RB } },
3487{ "dcbf", X(31,86), XLRT_MASK, PPC, { RA, RB, XRT_L } },
3330 3488
3331{ "lbzx", X(31,87), X_MASK, COM, { RT, RA, RB } }, 3489{ "lbzx", X(31,87), X_MASK, COM, { RT, RA0, RB } },
3332 3490
3333{ "dcbfe", X(31,94), XRT_MASK, BOOKE64, { RA, RB } }, 3491{ "dcbfe", X(31,94), XRT_MASK, BOOKE64, { RA, RB } },
3334 3492
3335{ "lbzxe", X(31,95), X_MASK, BOOKE64, { RT, RA, RB } }, 3493{ "lbzxe", X(31,95), X_MASK, BOOKE64, { RT, RA0, RB } },
3336 3494
3337{ "neg", XO(31,104,0,0), XORB_MASK, COM, { RT, RA } }, 3495{ "neg", XO(31,104,0,0), XORB_MASK, COM, { RT, RA } },
3338{ "neg.", XO(31,104,0,1), XORB_MASK, COM, { RT, RA } }, 3496{ "neg.", XO(31,104,0,1), XORB_MASK, COM, { RT, RA } },
@@ -3350,12 +3508,14 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3350 3508
3351{ "lbzux", X(31,119), X_MASK, COM, { RT, RAL, RB } }, 3509{ "lbzux", X(31,119), X_MASK, COM, { RT, RAL, RB } },
3352 3510
3511{ "popcntb", X(31,122), XRB_MASK, POWER5, { RA, RS } },
3512
3353{ "not", XRC(31,124,0), X_MASK, COM, { RA, RS, RBS } }, 3513{ "not", XRC(31,124,0), X_MASK, COM, { RA, RS, RBS } },
3354{ "nor", XRC(31,124,0), X_MASK, COM, { RA, RS, RB } }, 3514{ "nor", XRC(31,124,0), X_MASK, COM, { RA, RS, RB } },
3355{ "not.", XRC(31,124,1), X_MASK, COM, { RA, RS, RBS } }, 3515{ "not.", XRC(31,124,1), X_MASK, COM, { RA, RS, RBS } },
3356{ "nor.", XRC(31,124,1), X_MASK, COM, { RA, RS, RB } }, 3516{ "nor.", XRC(31,124,1), X_MASK, COM, { RA, RS, RB } },
3357 3517
3358{ "lwarxe", X(31,126), X_MASK, BOOKE64, { RT, RA, RB } }, 3518{ "lwarxe", X(31,126), X_MASK, BOOKE64, { RT, RA0, RB } },
3359 3519
3360{ "lbzuxe", X(31,127), X_MASK, BOOKE64, { RT, RAL, RB } }, 3520{ "lbzuxe", X(31,127), X_MASK, BOOKE64, { RT, RAL, RB } },
3361 3521
@@ -3383,21 +3543,22 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3383 3543
3384{ "dcbtstlse",X(31,142),X_MASK, PPCCHLK64, { CT, RA, RB }}, 3544{ "dcbtstlse",X(31,142),X_MASK, PPCCHLK64, { CT, RA, RB }},
3385 3545
3386{ "mtcr", XFXM(31,144,0xff), XRARB_MASK, COM, { RS }}, 3546{ "mtocrf", XFXM(31,144,0,1), XFXFXM_MASK, COM, { FXM, RS } },
3547{ "mtcr", XFXM(31,144,0xff,0), XRARB_MASK, COM, { RS }},
3387{ "mtcrf", X(31,144), XFXFXM_MASK, COM, { FXM, RS } }, 3548{ "mtcrf", X(31,144), XFXFXM_MASK, COM, { FXM, RS } },
3388 3549
3389{ "mtmsr", X(31,146), XRARB_MASK, COM, { RS } }, 3550{ "mtmsr", X(31,146), XRARB_MASK, COM, { RS } },
3390 3551
3391{ "stdx", X(31,149), X_MASK, PPC64, { RS, RA, RB } }, 3552{ "stdx", X(31,149), X_MASK, PPC64, { RS, RA0, RB } },
3392 3553
3393{ "stwcx.", XRC(31,150,1), X_MASK, PPC, { RS, RA, RB } }, 3554{ "stwcx.", XRC(31,150,1), X_MASK, PPC, { RS, RA0, RB } },
3394 3555
3395{ "stwx", X(31,151), X_MASK, PPCCOM, { RS, RA, RB } }, 3556{ "stwx", X(31,151), X_MASK, PPCCOM, { RS, RA0, RB } },
3396{ "stx", X(31,151), X_MASK, PWRCOM, { RS, RA, RB } }, 3557{ "stx", X(31,151), X_MASK, PWRCOM, { RS, RA, RB } },
3397 3558
3398{ "stwcxe.", XRC(31,158,1), X_MASK, BOOKE64, { RS, RA, RB } }, 3559{ "stwcxe.", XRC(31,158,1), X_MASK, BOOKE64, { RS, RA0, RB } },
3399 3560
3400{ "stwxe", X(31,159), X_MASK, BOOKE64, { RS, RA, RB } }, 3561{ "stwxe", X(31,159), X_MASK, BOOKE64, { RS, RA0, RB } },
3401 3562
3402{ "slq", XRC(31,152,0), X_MASK, M601, { RA, RS, RB } }, 3563{ "slq", XRC(31,152,0), X_MASK, M601, { RA, RS, RB } },
3403{ "slq.", XRC(31,152,1), X_MASK, M601, { RA, RS, RB } }, 3564{ "slq.", XRC(31,152,1), X_MASK, M601, { RA, RS, RB } },
@@ -3405,6 +3566,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3405{ "sle", XRC(31,153,0), X_MASK, M601, { RA, RS, RB } }, 3566{ "sle", XRC(31,153,0), X_MASK, M601, { RA, RS, RB } },
3406{ "sle.", XRC(31,153,1), X_MASK, M601, { RA, RS, RB } }, 3567{ "sle.", XRC(31,153,1), X_MASK, M601, { RA, RS, RB } },
3407 3568
3569{ "prtyw", X(31,154), XRB_MASK, POWER6, { RA, RS } },
3570
3408{ "wrteei", X(31,163), XE_MASK, PPC403 | BOOKE, { E } }, 3571{ "wrteei", X(31,163), XE_MASK, PPC403 | BOOKE, { E } },
3409 3572
3410{ "dcbtls", X(31,166), X_MASK, PPCCHLK, { CT, RA, RB }}, 3573{ "dcbtls", X(31,166), X_MASK, PPCCHLK, { CT, RA, RB }},
@@ -3415,11 +3578,13 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3415{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } }, 3578{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } },
3416 3579
3417{ "stwux", X(31,183), X_MASK, PPCCOM, { RS, RAS, RB } }, 3580{ "stwux", X(31,183), X_MASK, PPCCOM, { RS, RAS, RB } },
3418{ "stux", X(31,183), X_MASK, PWRCOM, { RS, RA, RB } }, 3581{ "stux", X(31,183), X_MASK, PWRCOM, { RS, RA0, RB } },
3419 3582
3420{ "sliq", XRC(31,184,0), X_MASK, M601, { RA, RS, SH } }, 3583{ "sliq", XRC(31,184,0), X_MASK, M601, { RA, RS, SH } },
3421{ "sliq.", XRC(31,184,1), X_MASK, M601, { RA, RS, SH } }, 3584{ "sliq.", XRC(31,184,1), X_MASK, M601, { RA, RS, SH } },
3422 3585
3586{ "prtyd", X(31,186), XRB_MASK, POWER6, { RA, RS } },
3587
3423{ "stwuxe", X(31,191), X_MASK, BOOKE64, { RS, RAS, RB } }, 3588{ "stwuxe", X(31,191), X_MASK, BOOKE64, { RS, RAS, RB } },
3424 3589
3425{ "subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, { RT, RA } }, 3590{ "subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, { RT, RA } },
@@ -3442,9 +3607,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3442 3607
3443{ "mtsr", X(31,210), XRB_MASK|(1<<20), COM32, { SR, RS } }, 3608{ "mtsr", X(31,210), XRB_MASK|(1<<20), COM32, { SR, RS } },
3444 3609
3445{ "stdcx.", XRC(31,214,1), X_MASK, PPC64, { RS, RA, RB } }, 3610{ "stdcx.", XRC(31,214,1), X_MASK, PPC64, { RS, RA0, RB } },
3446 3611
3447{ "stbx", X(31,215), X_MASK, COM, { RS, RA, RB } }, 3612{ "stbx", X(31,215), X_MASK, COM, { RS, RA0, RB } },
3448 3613
3449{ "sllq", XRC(31,216,0), X_MASK, M601, { RA, RS, RB } }, 3614{ "sllq", XRC(31,216,0), X_MASK, M601, { RA, RS, RB } },
3450{ "sllq.", XRC(31,216,1), X_MASK, M601, { RA, RS, RB } }, 3615{ "sllq.", XRC(31,216,1), X_MASK, M601, { RA, RS, RB } },
@@ -3452,7 +3617,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3452{ "sleq", XRC(31,217,0), X_MASK, M601, { RA, RS, RB } }, 3617{ "sleq", XRC(31,217,0), X_MASK, M601, { RA, RS, RB } },
3453{ "sleq.", XRC(31,217,1), X_MASK, M601, { RA, RS, RB } }, 3618{ "sleq.", XRC(31,217,1), X_MASK, M601, { RA, RS, RB } },
3454 3619
3455{ "stbxe", X(31,223), X_MASK, BOOKE64, { RS, RA, RB } }, 3620{ "stbxe", X(31,223), X_MASK, BOOKE64, { RS, RA0, RB } },
3456 3621
3457{ "icblc", X(31,230), X_MASK, PPCCHLK, { CT, RA, RB }}, 3622{ "icblc", X(31,230), X_MASK, PPCCHLK, { CT, RA, RB }},
3458 3623
@@ -3492,7 +3657,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3492{ "mtsrin", X(31,242), XRA_MASK, PPC32, { RS, RB } }, 3657{ "mtsrin", X(31,242), XRA_MASK, PPC32, { RS, RB } },
3493{ "mtsri", X(31,242), XRA_MASK, POWER32, { RS, RB } }, 3658{ "mtsri", X(31,242), XRA_MASK, POWER32, { RS, RB } },
3494 3659
3495{ "dcbtst", X(31,246), XRT_MASK, PPC, { CT, RA, RB } }, 3660{ "dcbtst", X(31,246), X_MASK, PPC, { CT, RA, RB } },
3496 3661
3497{ "stbux", X(31,247), X_MASK, COM, { RS, RAS, RB } }, 3662{ "stbux", X(31,247), X_MASK, COM, { RS, RAS, RB } },
3498 3663
@@ -3519,26 +3684,26 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3519{ "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, 3684{ "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3520{ "caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, { RT, RA, RB } }, 3685{ "caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3521 3686
3522{ "tlbiel", X(31,274), XRTRA_MASK, POWER4, { RB } }, 3687{ "tlbiel", X(31,274), XRTLRA_MASK, POWER4, { RB, L } },
3523 3688
3524{ "mfapidi", X(31,275), X_MASK, BOOKE, { RT, RA } }, 3689{ "mfapidi", X(31,275), X_MASK, BOOKE, { RT, RA } },
3525 3690
3526{ "lscbx", XRC(31,277,0), X_MASK, M601, { RT, RA, RB } }, 3691{ "lscbx", XRC(31,277,0), X_MASK, M601, { RT, RA, RB } },
3527{ "lscbx.", XRC(31,277,1), X_MASK, M601, { RT, RA, RB } }, 3692{ "lscbx.", XRC(31,277,1), X_MASK, M601, { RT, RA, RB } },
3528 3693
3529{ "dcbt", X(31,278), XRT_MASK, PPC, { CT, RA, RB } }, 3694{ "dcbt", X(31,278), X_MASK, PPC, { CT, RA, RB } },
3530 3695
3531{ "lhzx", X(31,279), X_MASK, COM, { RT, RA, RB } }, 3696{ "lhzx", X(31,279), X_MASK, COM, { RT, RA0, RB } },
3532 3697
3533{ "eqv", XRC(31,284,0), X_MASK, COM, { RA, RS, RB } }, 3698{ "eqv", XRC(31,284,0), X_MASK, COM, { RA, RS, RB } },
3534{ "eqv.", XRC(31,284,1), X_MASK, COM, { RA, RS, RB } }, 3699{ "eqv.", XRC(31,284,1), X_MASK, COM, { RA, RS, RB } },
3535 3700
3536{ "dcbte", X(31,286), X_MASK, BOOKE64, { CT, RA, RB } }, 3701{ "dcbte", X(31,286), X_MASK, BOOKE64, { CT, RA, RB } },
3537 3702
3538{ "lhzxe", X(31,287), X_MASK, BOOKE64, { RT, RA, RB } }, 3703{ "lhzxe", X(31,287), X_MASK, BOOKE64, { RT, RA0, RB } },
3539 3704
3540{ "tlbie", X(31,306), XRTLRA_MASK, PPC, { RB, L } }, 3705{ "tlbie", X(31,306), XRTLRA_MASK, PPC, { RB, L } },
3541{ "tlbi", X(31,306), XRT_MASK, POWER, { RA, RB } }, 3706{ "tlbi", X(31,306), XRT_MASK, POWER, { RA0, RB } },
3542 3707
3543{ "eciwx", X(31,310), X_MASK, PPC, { RT, RA, RB } }, 3708{ "eciwx", X(31,310), X_MASK, PPC, { RT, RA, RB } },
3544 3709
@@ -3607,6 +3772,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3607{ "mfsdr1", XSPR(31,339,25), XSPR_MASK, COM, { RT } }, 3772{ "mfsdr1", XSPR(31,339,25), XSPR_MASK, COM, { RT } },
3608{ "mfsrr0", XSPR(31,339,26), XSPR_MASK, COM, { RT } }, 3773{ "mfsrr0", XSPR(31,339,26), XSPR_MASK, COM, { RT } },
3609{ "mfsrr1", XSPR(31,339,27), XSPR_MASK, COM, { RT } }, 3774{ "mfsrr1", XSPR(31,339,27), XSPR_MASK, COM, { RT } },
3775{ "mfcfar", XSPR(31,339,28), XSPR_MASK, POWER6, { RT } },
3610{ "mfpid", XSPR(31,339,48), XSPR_MASK, BOOKE, { RT } }, 3776{ "mfpid", XSPR(31,339,48), XSPR_MASK, BOOKE, { RT } },
3611{ "mfpid", XSPR(31,339,945), XSPR_MASK, PPC403, { RT } }, 3777{ "mfpid", XSPR(31,339,945), XSPR_MASK, PPC403, { RT } },
3612{ "mfcsrr0", XSPR(31,339,58), XSPR_MASK, BOOKE, { RT } }, 3778{ "mfcsrr0", XSPR(31,339,58), XSPR_MASK, BOOKE, { RT } },
@@ -3634,21 +3800,21 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3634{ "mfbar", XSPR(31,339,159), XSPR_MASK, PPC860, { RT } }, 3800{ "mfbar", XSPR(31,339,159), XSPR_MASK, PPC860, { RT } },
3635{ "mfvrsave", XSPR(31,339,256), XSPR_MASK, PPCVEC, { RT } }, 3801{ "mfvrsave", XSPR(31,339,256), XSPR_MASK, PPCVEC, { RT } },
3636{ "mfusprg0", XSPR(31,339,256), XSPR_MASK, BOOKE, { RT } }, 3802{ "mfusprg0", XSPR(31,339,256), XSPR_MASK, BOOKE, { RT } },
3637{ "mfsprg4", XSPR(31,339,260), XSPR_MASK, PPC405, { RT } },
3638{ "mfsprg5", XSPR(31,339,261), XSPR_MASK, PPC405, { RT } },
3639{ "mfsprg6", XSPR(31,339,262), XSPR_MASK, PPC405, { RT } },
3640{ "mfsprg7", XSPR(31,339,263), XSPR_MASK, PPC405, { RT } },
3641{ "mftb", X(31,371), X_MASK, CLASSIC, { RT, TBR } }, 3803{ "mftb", X(31,371), X_MASK, CLASSIC, { RT, TBR } },
3642{ "mftb", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } }, 3804{ "mftb", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } },
3643{ "mftbl", XSPR(31,371,268), XSPR_MASK, CLASSIC, { RT } }, 3805{ "mftbl", XSPR(31,371,268), XSPR_MASK, CLASSIC, { RT } },
3644{ "mftbl", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } }, 3806{ "mftbl", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } },
3645{ "mftbu", XSPR(31,371,269), XSPR_MASK, CLASSIC, { RT } }, 3807{ "mftbu", XSPR(31,371,269), XSPR_MASK, CLASSIC, { RT } },
3646{ "mftbu", XSPR(31,339,269), XSPR_MASK, BOOKE, { RT } }, 3808{ "mftbu", XSPR(31,339,269), XSPR_MASK, BOOKE, { RT } },
3647{ "mfsprg", XSPR(31,339,272), XSPRG_MASK, PPC, { RT, SPRG } }, 3809{ "mfsprg", XSPR(31,339,256), XSPRG_MASK, PPC, { RT, SPRG } },
3648{ "mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, { RT } }, 3810{ "mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, { RT } },
3649{ "mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, { RT } }, 3811{ "mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, { RT } },
3650{ "mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, { RT } }, 3812{ "mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, { RT } },
3651{ "mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, { RT } }, 3813{ "mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, { RT } },
3814{ "mfsprg4", XSPR(31,339,260), XSPR_MASK, PPC405 | BOOKE, { RT } },
3815{ "mfsprg5", XSPR(31,339,261), XSPR_MASK, PPC405 | BOOKE, { RT } },
3816{ "mfsprg6", XSPR(31,339,262), XSPR_MASK, PPC405 | BOOKE, { RT } },
3817{ "mfsprg7", XSPR(31,339,263), XSPR_MASK, PPC405 | BOOKE, { RT } },
3652{ "mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, { RT } }, 3818{ "mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, { RT } },
3653{ "mfear", XSPR(31,339,282), XSPR_MASK, PPC, { RT } }, 3819{ "mfear", XSPR(31,339,282), XSPR_MASK, PPC, { RT } },
3654{ "mfpir", XSPR(31,339,286), XSPR_MASK, BOOKE, { RT } }, 3820{ "mfpir", XSPR(31,339,286), XSPR_MASK, BOOKE, { RT } },
@@ -3699,6 +3865,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3699{ "mfspefscr", XSPR(31,339,512), XSPR_MASK, PPCSPE, { RT } }, 3865{ "mfspefscr", XSPR(31,339,512), XSPR_MASK, PPCSPE, { RT } },
3700{ "mfbbear", XSPR(31,339,513), XSPR_MASK, PPCBRLK, { RT } }, 3866{ "mfbbear", XSPR(31,339,513), XSPR_MASK, PPCBRLK, { RT } },
3701{ "mfbbtar", XSPR(31,339,514), XSPR_MASK, PPCBRLK, { RT } }, 3867{ "mfbbtar", XSPR(31,339,514), XSPR_MASK, PPCBRLK, { RT } },
3868{ "mfivor32", XSPR(31,339,528), XSPR_MASK, PPCSPE, { RT } },
3869{ "mfivor33", XSPR(31,339,529), XSPR_MASK, PPCSPE, { RT } },
3870{ "mfivor34", XSPR(31,339,530), XSPR_MASK, PPCSPE, { RT } },
3871{ "mfivor35", XSPR(31,339,531), XSPR_MASK, PPCPMR, { RT } },
3702{ "mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, 3872{ "mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3703{ "mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, 3873{ "mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3704{ "mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, 3874{ "mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
@@ -3708,10 +3878,11 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3708{ "mfic_dat", XSPR(31,339,562), XSPR_MASK, PPC860, { RT } }, 3878{ "mfic_dat", XSPR(31,339,562), XSPR_MASK, PPC860, { RT } },
3709{ "mfdc_cst", XSPR(31,339,568), XSPR_MASK, PPC860, { RT } }, 3879{ "mfdc_cst", XSPR(31,339,568), XSPR_MASK, PPC860, { RT } },
3710{ "mfdc_adr", XSPR(31,339,569), XSPR_MASK, PPC860, { RT } }, 3880{ "mfdc_adr", XSPR(31,339,569), XSPR_MASK, PPC860, { RT } },
3711{ "mfdc_dat", XSPR(31,339,570), XSPR_MASK, PPC860, { RT } },
3712{ "mfmcsrr0", XSPR(31,339,570), XSPR_MASK, PPCRFMCI, { RT } }, 3881{ "mfmcsrr0", XSPR(31,339,570), XSPR_MASK, PPCRFMCI, { RT } },
3882{ "mfdc_dat", XSPR(31,339,570), XSPR_MASK, PPC860, { RT } },
3713{ "mfmcsrr1", XSPR(31,339,571), XSPR_MASK, PPCRFMCI, { RT } }, 3883{ "mfmcsrr1", XSPR(31,339,571), XSPR_MASK, PPCRFMCI, { RT } },
3714{ "mfmcsr", XSPR(31,339,572), XSPR_MASK, PPCRFMCI, { RT } }, 3884{ "mfmcsr", XSPR(31,339,572), XSPR_MASK, PPCRFMCI, { RT } },
3885{ "mfmcar", XSPR(31,339,573), XSPR_MASK, PPCRFMCI, { RT } },
3715{ "mfdpdr", XSPR(31,339,630), XSPR_MASK, PPC860, { RT } }, 3886{ "mfdpdr", XSPR(31,339,630), XSPR_MASK, PPC860, { RT } },
3716{ "mfdpir", XSPR(31,339,631), XSPR_MASK, PPC860, { RT } }, 3887{ "mfdpir", XSPR(31,339,631), XSPR_MASK, PPC860, { RT } },
3717{ "mfimmr", XSPR(31,339,638), XSPR_MASK, PPC860, { RT } }, 3888{ "mfimmr", XSPR(31,339,638), XSPR_MASK, PPC860, { RT } },
@@ -3775,14 +3946,14 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3775{ "mfpbu2", XSPR(31,339,1023), XSPR_MASK, PPC403, { RT } }, 3946{ "mfpbu2", XSPR(31,339,1023), XSPR_MASK, PPC403, { RT } },
3776{ "mfspr", X(31,339), X_MASK, COM, { RT, SPR } }, 3947{ "mfspr", X(31,339), X_MASK, COM, { RT, SPR } },
3777 3948
3778{ "lwax", X(31,341), X_MASK, PPC64, { RT, RA, RB } }, 3949{ "lwax", X(31,341), X_MASK, PPC64, { RT, RA0, RB } },
3779 3950
3780{ "dst", XDSS(31,342,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, 3951{ "dst", XDSS(31,342,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3781{ "dstt", XDSS(31,342,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, 3952{ "dstt", XDSS(31,342,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3782 3953
3783{ "lhax", X(31,343), X_MASK, COM, { RT, RA, RB } }, 3954{ "lhax", X(31,343), X_MASK, COM, { RT, RA0, RB } },
3784 3955
3785{ "lhaxe", X(31,351), X_MASK, BOOKE64, { RT, RA, RB } }, 3956{ "lhaxe", X(31,351), X_MASK, BOOKE64, { RT, RA0, RB } },
3786 3957
3787{ "dstst", XDSS(31,374,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, 3958{ "dstst", XDSS(31,374,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3788{ "dststt", XDSS(31,374,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, 3959{ "dststt", XDSS(31,374,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
@@ -3821,14 +3992,20 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3821 3992
3822{ "slbmte", X(31,402), XRA_MASK, PPC64, { RS, RB } }, 3993{ "slbmte", X(31,402), XRA_MASK, PPC64, { RS, RB } },
3823 3994
3824{ "sthx", X(31,407), X_MASK, COM, { RS, RA, RB } }, 3995{ "sthx", X(31,407), X_MASK, COM, { RS, RA0, RB } },
3996
3997{ "cmpb", X(31,508), X_MASK, POWER6, { RA, RS, RB } },
3825 3998
3826{ "lfqx", X(31,791), X_MASK, POWER2, { FRT, RA, RB } }, 3999{ "lfqx", X(31,791), X_MASK, POWER2, { FRT, RA, RB } },
3827 4000
4001{ "lfdpx", X(31,791), X_MASK, POWER6, { FRT, RA, RB } },
4002
3828{ "lfqux", X(31,823), X_MASK, POWER2, { FRT, RA, RB } }, 4003{ "lfqux", X(31,823), X_MASK, POWER2, { FRT, RA, RB } },
3829 4004
3830{ "stfqx", X(31,919), X_MASK, POWER2, { FRS, RA, RB } }, 4005{ "stfqx", X(31,919), X_MASK, POWER2, { FRS, RA, RB } },
3831 4006
4007{ "stfdpx", X(31,919), X_MASK, POWER6, { FRS, RA, RB } },
4008
3832{ "stfqux", X(31,951), X_MASK, POWER2, { FRS, RA, RB } }, 4009{ "stfqux", X(31,951), X_MASK, POWER2, { FRS, RA, RB } },
3833 4010
3834{ "orc", XRC(31,412,0), X_MASK, COM, { RA, RS, RB } }, 4011{ "orc", XRC(31,412,0), X_MASK, COM, { RA, RS, RB } },
@@ -3837,7 +4014,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3837{ "sradi", XS(31,413,0), XS_MASK, PPC64, { RA, RS, SH6 } }, 4014{ "sradi", XS(31,413,0), XS_MASK, PPC64, { RA, RS, SH6 } },
3838{ "sradi.", XS(31,413,1), XS_MASK, PPC64, { RA, RS, SH6 } }, 4015{ "sradi.", XS(31,413,1), XS_MASK, PPC64, { RA, RS, SH6 } },
3839 4016
3840{ "sthxe", X(31,415), X_MASK, BOOKE64, { RS, RA, RB } }, 4017{ "sthxe", X(31,415), X_MASK, BOOKE64, { RS, RA0, RB } },
3841 4018
3842{ "slbie", X(31,434), XRTRA_MASK, PPC64, { RB } }, 4019{ "slbie", X(31,434), XRTRA_MASK, PPC64, { RB } },
3843 4020
@@ -3918,6 +4095,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3918{ "mtsdr1", XSPR(31,467,25), XSPR_MASK, COM, { RS } }, 4095{ "mtsdr1", XSPR(31,467,25), XSPR_MASK, COM, { RS } },
3919{ "mtsrr0", XSPR(31,467,26), XSPR_MASK, COM, { RS } }, 4096{ "mtsrr0", XSPR(31,467,26), XSPR_MASK, COM, { RS } },
3920{ "mtsrr1", XSPR(31,467,27), XSPR_MASK, COM, { RS } }, 4097{ "mtsrr1", XSPR(31,467,27), XSPR_MASK, COM, { RS } },
4098{ "mtcfar", XSPR(31,467,28), XSPR_MASK, POWER6, { RS } },
3921{ "mtpid", XSPR(31,467,48), XSPR_MASK, BOOKE, { RS } }, 4099{ "mtpid", XSPR(31,467,48), XSPR_MASK, BOOKE, { RS } },
3922{ "mtpid", XSPR(31,467,945), XSPR_MASK, PPC403, { RS } }, 4100{ "mtpid", XSPR(31,467,945), XSPR_MASK, PPC403, { RS } },
3923{ "mtdecar", XSPR(31,467,54), XSPR_MASK, BOOKE, { RS } }, 4101{ "mtdecar", XSPR(31,467,54), XSPR_MASK, BOOKE, { RS } },
@@ -3946,7 +4124,7 @@ const struct powerpc_opcode powerpc_opcodes[] = {
3946{ "mtbar", XSPR(31,467,159), XSPR_MASK, PPC860, { RS } }, 4124{ "mtbar", XSPR(31,467,159), XSPR_MASK, PPC860, { RS } },
3947{ "mtvrsave", XSPR(31,467,256), XSPR_MASK, PPCVEC, { RS } }, 4125{ "mtvrsave", XSPR(31,467,256), XSPR_MASK, PPCVEC, { RS } },
3948{ "mtusprg0", XSPR(31,467,256), XSPR_MASK, BOOKE, { RS } }, 4126{ "mtusprg0", XSPR(31,467,256), XSPR_MASK, BOOKE, { RS } },
3949{ "mtsprg", XSPR(31,467,272), XSPRG_MASK,PPC, { SPRG, RS } }, 4127{ "mtsprg", XSPR(31,467,256), XSPRG_MASK,PPC, { SPRG, RS } },
3950{ "mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, { RS } }, 4128{ "mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, { RS } },
3951{ "mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, { RS } }, 4129{ "mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, { RS } },
3952{ "mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, { RS } }, 4130{ "mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, { RS } },
@@ -4005,6 +4183,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4005{ "mtspefscr", XSPR(31,467,512), XSPR_MASK, PPCSPE, { RS } }, 4183{ "mtspefscr", XSPR(31,467,512), XSPR_MASK, PPCSPE, { RS } },
4006{ "mtbbear", XSPR(31,467,513), XSPR_MASK, PPCBRLK, { RS } }, 4184{ "mtbbear", XSPR(31,467,513), XSPR_MASK, PPCBRLK, { RS } },
4007{ "mtbbtar", XSPR(31,467,514), XSPR_MASK, PPCBRLK, { RS } }, 4185{ "mtbbtar", XSPR(31,467,514), XSPR_MASK, PPCBRLK, { RS } },
4186{ "mtivor32", XSPR(31,467,528), XSPR_MASK, PPCSPE, { RS } },
4187{ "mtivor33", XSPR(31,467,529), XSPR_MASK, PPCSPE, { RS } },
4188{ "mtivor34", XSPR(31,467,530), XSPR_MASK, PPCSPE, { RS } },
4189{ "mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, { RS } },
4008{ "mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, 4190{ "mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4009{ "mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, 4191{ "mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4010{ "mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, 4192{ "mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
@@ -4101,13 +4283,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4101 4283
4102{ "clcs", X(31,531), XRB_MASK, M601, { RT, RA } }, 4284{ "clcs", X(31,531), XRB_MASK, M601, { RT, RA } },
4103 4285
4104{ "lswx", X(31,533), X_MASK, PPCCOM, { RT, RA, RB } }, 4286{ "ldbrx", X(31,532), X_MASK, CELL, { RT, RA0, RB } },
4287
4288{ "lswx", X(31,533), X_MASK, PPCCOM, { RT, RA0, RB } },
4105{ "lsx", X(31,533), X_MASK, PWRCOM, { RT, RA, RB } }, 4289{ "lsx", X(31,533), X_MASK, PWRCOM, { RT, RA, RB } },
4106 4290
4107{ "lwbrx", X(31,534), X_MASK, PPCCOM, { RT, RA, RB } }, 4291{ "lwbrx", X(31,534), X_MASK, PPCCOM, { RT, RA0, RB } },
4108{ "lbrx", X(31,534), X_MASK, PWRCOM, { RT, RA, RB } }, 4292{ "lbrx", X(31,534), X_MASK, PWRCOM, { RT, RA, RB } },
4109 4293
4110{ "lfsx", X(31,535), X_MASK, COM, { FRT, RA, RB } }, 4294{ "lfsx", X(31,535), X_MASK, COM, { FRT, RA0, RB } },
4111 4295
4112{ "srw", XRC(31,536,0), X_MASK, PPCCOM, { RA, RS, RB } }, 4296{ "srw", XRC(31,536,0), X_MASK, PPCCOM, { RA, RS, RB } },
4113{ "sr", XRC(31,536,0), X_MASK, PWRCOM, { RA, RS, RB } }, 4297{ "sr", XRC(31,536,0), X_MASK, PWRCOM, { RA, RS, RB } },
@@ -4123,11 +4307,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4123{ "maskir", XRC(31,541,0), X_MASK, M601, { RA, RS, RB } }, 4307{ "maskir", XRC(31,541,0), X_MASK, M601, { RA, RS, RB } },
4124{ "maskir.", XRC(31,541,1), X_MASK, M601, { RA, RS, RB } }, 4308{ "maskir.", XRC(31,541,1), X_MASK, M601, { RA, RS, RB } },
4125 4309
4126{ "lwbrxe", X(31,542), X_MASK, BOOKE64, { RT, RA, RB } }, 4310{ "lwbrxe", X(31,542), X_MASK, BOOKE64, { RT, RA0, RB } },
4127 4311
4128{ "lfsxe", X(31,543), X_MASK, BOOKE64, { FRT, RA, RB } }, 4312{ "lfsxe", X(31,543), X_MASK, BOOKE64, { FRT, RA0, RB } },
4129 4313
4130{ "bbelr", X(31,550), X_MASK, PPCBRLK, { 0 }}, 4314{ "bbelr", X(31,550), X_MASK, PPCBRLK, { 0 }},
4315
4131{ "tlbsync", X(31,566), 0xffffffff, PPC, { 0 } }, 4316{ "tlbsync", X(31,566), 0xffffffff, PPC, { 0 } },
4132 4317
4133{ "lfsux", X(31,567), X_MASK, COM, { FRT, RAS, RB } }, 4318{ "lfsux", X(31,567), X_MASK, COM, { FRT, RAS, RB } },
@@ -4136,8 +4321,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4136 4321
4137{ "mfsr", X(31,595), XRB_MASK|(1<<20), COM32, { RT, SR } }, 4322{ "mfsr", X(31,595), XRB_MASK|(1<<20), COM32, { RT, SR } },
4138 4323
4139{ "lswi", X(31,597), X_MASK, PPCCOM, { RT, RA, NB } }, 4324{ "lswi", X(31,597), X_MASK, PPCCOM, { RT, RA0, NB } },
4140{ "lsi", X(31,597), X_MASK, PWRCOM, { RT, RA, NB } }, 4325{ "lsi", X(31,597), X_MASK, PWRCOM, { RT, RA0, NB } },
4141 4326
4142{ "lwsync", XSYNC(31,598,1), 0xffffffff, PPC, { 0 } }, 4327{ "lwsync", XSYNC(31,598,1), 0xffffffff, PPC, { 0 } },
4143{ "ptesync", XSYNC(31,598,2), 0xffffffff, PPC64, { 0 } }, 4328{ "ptesync", XSYNC(31,598,2), 0xffffffff, PPC64, { 0 } },
@@ -4145,9 +4330,11 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4145{ "sync", X(31,598), XSYNC_MASK, PPCCOM, { LS } }, 4330{ "sync", X(31,598), XSYNC_MASK, PPCCOM, { LS } },
4146{ "dcs", X(31,598), 0xffffffff, PWRCOM, { 0 } }, 4331{ "dcs", X(31,598), 0xffffffff, PWRCOM, { 0 } },
4147 4332
4148{ "lfdx", X(31,599), X_MASK, COM, { FRT, RA, RB } }, 4333{ "lfdx", X(31,599), X_MASK, COM, { FRT, RA0, RB } },
4334
4335{ "lfdxe", X(31,607), X_MASK, BOOKE64, { FRT, RA0, RB } },
4149 4336
4150{ "lfdxe", X(31,607), X_MASK, BOOKE64, { FRT, RA, RB } }, 4337{ "mffgpr", XRC(31,607,0), XRA_MASK, POWER6, { FRT, RB } },
4151 4338
4152{ "mfsri", X(31,627), X_MASK, PWRCOM, { RT, RA, RB } }, 4339{ "mfsri", X(31,627), X_MASK, PWRCOM, { RT, RA, RB } },
4153 4340
@@ -4159,13 +4346,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4159 4346
4160{ "mfsrin", X(31,659), XRA_MASK, PPC32, { RT, RB } }, 4347{ "mfsrin", X(31,659), XRA_MASK, PPC32, { RT, RB } },
4161 4348
4162{ "stswx", X(31,661), X_MASK, PPCCOM, { RS, RA, RB } }, 4349{ "stdbrx", X(31,660), X_MASK, CELL, { RS, RA0, RB } },
4163{ "stsx", X(31,661), X_MASK, PWRCOM, { RS, RA, RB } }, 4350
4351{ "stswx", X(31,661), X_MASK, PPCCOM, { RS, RA0, RB } },
4352{ "stsx", X(31,661), X_MASK, PWRCOM, { RS, RA0, RB } },
4164 4353
4165{ "stwbrx", X(31,662), X_MASK, PPCCOM, { RS, RA, RB } }, 4354{ "stwbrx", X(31,662), X_MASK, PPCCOM, { RS, RA0, RB } },
4166{ "stbrx", X(31,662), X_MASK, PWRCOM, { RS, RA, RB } }, 4355{ "stbrx", X(31,662), X_MASK, PWRCOM, { RS, RA0, RB } },
4167 4356
4168{ "stfsx", X(31,663), X_MASK, COM, { FRS, RA, RB } }, 4357{ "stfsx", X(31,663), X_MASK, COM, { FRS, RA0, RB } },
4169 4358
4170{ "srq", XRC(31,664,0), X_MASK, M601, { RA, RS, RB } }, 4359{ "srq", XRC(31,664,0), X_MASK, M601, { RA, RS, RB } },
4171{ "srq.", XRC(31,664,1), X_MASK, M601, { RA, RS, RB } }, 4360{ "srq.", XRC(31,664,1), X_MASK, M601, { RA, RS, RB } },
@@ -4173,9 +4362,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4173{ "sre", XRC(31,665,0), X_MASK, M601, { RA, RS, RB } }, 4362{ "sre", XRC(31,665,0), X_MASK, M601, { RA, RS, RB } },
4174{ "sre.", XRC(31,665,1), X_MASK, M601, { RA, RS, RB } }, 4363{ "sre.", XRC(31,665,1), X_MASK, M601, { RA, RS, RB } },
4175 4364
4176{ "stwbrxe", X(31,670), X_MASK, BOOKE64, { RS, RA, RB } }, 4365{ "stwbrxe", X(31,670), X_MASK, BOOKE64, { RS, RA0, RB } },
4177 4366
4178{ "stfsxe", X(31,671), X_MASK, BOOKE64, { FRS, RA, RB } }, 4367{ "stfsxe", X(31,671), X_MASK, BOOKE64, { FRS, RA0, RB } },
4179 4368
4180{ "stfsux", X(31,695), X_MASK, COM, { FRS, RAS, RB } }, 4369{ "stfsux", X(31,695), X_MASK, COM, { FRS, RAS, RB } },
4181 4370
@@ -4184,10 +4373,10 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4184 4373
4185{ "stfsuxe", X(31,703), X_MASK, BOOKE64, { FRS, RAS, RB } }, 4374{ "stfsuxe", X(31,703), X_MASK, BOOKE64, { FRS, RAS, RB } },
4186 4375
4187{ "stswi", X(31,725), X_MASK, PPCCOM, { RS, RA, NB } }, 4376{ "stswi", X(31,725), X_MASK, PPCCOM, { RS, RA0, NB } },
4188{ "stsi", X(31,725), X_MASK, PWRCOM, { RS, RA, NB } }, 4377{ "stsi", X(31,725), X_MASK, PWRCOM, { RS, RA0, NB } },
4189 4378
4190{ "stfdx", X(31,727), X_MASK, COM, { FRS, RA, RB } }, 4379{ "stfdx", X(31,727), X_MASK, COM, { FRS, RA0, RB } },
4191 4380
4192{ "srlq", XRC(31,728,0), X_MASK, M601, { RA, RS, RB } }, 4381{ "srlq", XRC(31,728,0), X_MASK, M601, { RA, RS, RB } },
4193{ "srlq.", XRC(31,728,1), X_MASK, M601, { RA, RS, RB } }, 4382{ "srlq.", XRC(31,728,1), X_MASK, M601, { RA, RS, RB } },
@@ -4195,7 +4384,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4195{ "sreq", XRC(31,729,0), X_MASK, M601, { RA, RS, RB } }, 4384{ "sreq", XRC(31,729,0), X_MASK, M601, { RA, RS, RB } },
4196{ "sreq.", XRC(31,729,1), X_MASK, M601, { RA, RS, RB } }, 4385{ "sreq.", XRC(31,729,1), X_MASK, M601, { RA, RS, RB } },
4197 4386
4198{ "stfdxe", X(31,735), X_MASK, BOOKE64, { FRS, RA, RB } }, 4387{ "stfdxe", X(31,735), X_MASK, BOOKE64, { FRS, RA0, RB } },
4388
4389{ "mftgpr", XRC(31,735,0), XRA_MASK, POWER6, { RT, FRB } },
4199 4390
4200{ "dcba", X(31,758), XRT_MASK, PPC405 | BOOKE, { RA, RB } }, 4391{ "dcba", X(31,758), XRT_MASK, PPC405 | BOOKE, { RA, RB } },
4201 4392
@@ -4211,7 +4402,9 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4211{ "tlbivax", X(31,786), XRT_MASK, BOOKE, { RA, RB } }, 4402{ "tlbivax", X(31,786), XRT_MASK, BOOKE, { RA, RB } },
4212{ "tlbivaxe",X(31,787), XRT_MASK, BOOKE64, { RA, RB } }, 4403{ "tlbivaxe",X(31,787), XRT_MASK, BOOKE64, { RA, RB } },
4213 4404
4214{ "lhbrx", X(31,790), X_MASK, COM, { RT, RA, RB } }, 4405{ "lwzcix", X(31,789), X_MASK, POWER6, { RT, RA0, RB } },
4406
4407{ "lhbrx", X(31,790), X_MASK, COM, { RT, RA0, RB } },
4215 4408
4216{ "sraw", XRC(31,792,0), X_MASK, PPCCOM, { RA, RS, RB } }, 4409{ "sraw", XRC(31,792,0), X_MASK, PPCCOM, { RA, RS, RB } },
4217{ "sra", XRC(31,792,0), X_MASK, PWRCOM, { RA, RS, RB } }, 4410{ "sra", XRC(31,792,0), X_MASK, PWRCOM, { RA, RS, RB } },
@@ -4221,13 +4414,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4221{ "srad", XRC(31,794,0), X_MASK, PPC64, { RA, RS, RB } }, 4414{ "srad", XRC(31,794,0), X_MASK, PPC64, { RA, RS, RB } },
4222{ "srad.", XRC(31,794,1), X_MASK, PPC64, { RA, RS, RB } }, 4415{ "srad.", XRC(31,794,1), X_MASK, PPC64, { RA, RS, RB } },
4223 4416
4224{ "lhbrxe", X(31,798), X_MASK, BOOKE64, { RT, RA, RB } }, 4417{ "lhbrxe", X(31,798), X_MASK, BOOKE64, { RT, RA0, RB } },
4225 4418
4226{ "ldxe", X(31,799), X_MASK, BOOKE64, { RT, RA, RB } }, 4419{ "ldxe", X(31,799), X_MASK, BOOKE64, { RT, RA0, RB } },
4227{ "lduxe", X(31,831), X_MASK, BOOKE64, { RT, RA, RB } }, 4420{ "lduxe", X(31,831), X_MASK, BOOKE64, { RT, RA0, RB } },
4228 4421
4229{ "rac", X(31,818), X_MASK, PWRCOM, { RT, RA, RB } }, 4422{ "rac", X(31,818), X_MASK, PWRCOM, { RT, RA, RB } },
4230 4423
4424{ "lhzcix", X(31,821), X_MASK, POWER6, { RT, RA0, RB } },
4425
4231{ "dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, { STRM } }, 4426{ "dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, { STRM } },
4232{ "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { 0 } }, 4427{ "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { 0 } },
4233 4428
@@ -4238,19 +4433,25 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4238 4433
4239{ "slbmfev", X(31,851), XRA_MASK, PPC64, { RT, RB } }, 4434{ "slbmfev", X(31,851), XRA_MASK, PPC64, { RT, RB } },
4240 4435
4436{ "lbzcix", X(31,853), X_MASK, POWER6, { RT, RA0, RB } },
4437
4241{ "mbar", X(31,854), X_MASK, BOOKE, { MO } }, 4438{ "mbar", X(31,854), X_MASK, BOOKE, { MO } },
4242{ "eieio", X(31,854), 0xffffffff, PPC, { 0 } }, 4439{ "eieio", X(31,854), 0xffffffff, PPC, { 0 } },
4243 4440
4244{ "tlbsx", XRC(31,914,0), X_MASK, BOOKE, { RA, RB } }, 4441{ "lfiwax", X(31,855), X_MASK, POWER6, { FRT, RA0, RB } },
4245{ "tlbsx", XRC(31,914,0), X_MASK, PPC403, { RT, RA, RB } }, 4442
4246{ "tlbsx.", XRC(31,914,1), X_MASK, BOOKE, { RA, RB } }, 4443{ "ldcix", X(31,885), X_MASK, POWER6, { RT, RA0, RB } },
4247{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403, { RT, RA, RB } }, 4444
4445{ "tlbsx", XRC(31,914,0), X_MASK, PPC403|BOOKE, { RTO, RA, RB } },
4446{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403|BOOKE, { RTO, RA, RB } },
4248{ "tlbsxe", XRC(31,915,0), X_MASK, BOOKE64, { RA, RB } }, 4447{ "tlbsxe", XRC(31,915,0), X_MASK, BOOKE64, { RA, RB } },
4249{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE64, { RA, RB } }, 4448{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE64, { RA, RB } },
4250 4449
4251{ "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } }, 4450{ "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } },
4252 4451
4253{ "sthbrx", X(31,918), X_MASK, COM, { RS, RA, RB } }, 4452{ "stwcix", X(31,917), X_MASK, POWER6, { RS, RA0, RB } },
4453
4454{ "sthbrx", X(31,918), X_MASK, COM, { RS, RA0, RB } },
4254 4455
4255{ "sraq", XRC(31,920,0), X_MASK, M601, { RA, RS, RB } }, 4456{ "sraq", XRC(31,920,0), X_MASK, M601, { RA, RS, RB } },
4256{ "sraq.", XRC(31,920,1), X_MASK, M601, { RA, RS, RB } }, 4457{ "sraq.", XRC(31,920,1), X_MASK, M601, { RA, RS, RB } },
@@ -4263,14 +4464,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4263{ "extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, { RA, RS } }, 4464{ "extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, { RA, RS } },
4264{ "exts.", XRC(31,922,1), XRB_MASK, PWRCOM, { RA, RS } }, 4465{ "exts.", XRC(31,922,1), XRB_MASK, PWRCOM, { RA, RS } },
4265 4466
4266{ "sthbrxe", X(31,926), X_MASK, BOOKE64, { RS, RA, RB } }, 4467{ "sthbrxe", X(31,926), X_MASK, BOOKE64, { RS, RA0, RB } },
4267 4468
4268{ "stdxe", X(31,927), X_MASK, BOOKE64, { RS, RA, RB } }, 4469{ "stdxe", X(31,927), X_MASK, BOOKE64, { RS, RA0, RB } },
4269 4470
4270{ "tlbrehi", XTLB(31,946,0), XTLB_MASK, PPC403, { RT, RA } }, 4471{ "tlbrehi", XTLB(31,946,0), XTLB_MASK, PPC403, { RT, RA } },
4271{ "tlbrelo", XTLB(31,946,1), XTLB_MASK, PPC403, { RT, RA } }, 4472{ "tlbrelo", XTLB(31,946,1), XTLB_MASK, PPC403, { RT, RA } },
4272{ "tlbre", X(31,946), X_MASK, BOOKE, { 0 } }, 4473{ "tlbre", X(31,946), X_MASK, PPC403|BOOKE, { RSO, RAOPT, SHO } },
4273{ "tlbre", X(31,946), X_MASK, PPC403, { RS, RA, SH } }, 4474
4475{ "sthcix", X(31,949), X_MASK, POWER6, { RS, RA0, RB } },
4274 4476
4275{ "sraiq", XRC(31,952,0), X_MASK, M601, { RA, RS, SH } }, 4477{ "sraiq", XRC(31,952,0), X_MASK, M601, { RA, RS, SH } },
4276{ "sraiq.", XRC(31,952,1), X_MASK, M601, { RA, RS, SH } }, 4478{ "sraiq.", XRC(31,952,1), X_MASK, M601, { RA, RS, SH } },
@@ -4284,13 +4486,14 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4284 4486
4285{ "tlbwehi", XTLB(31,978,0), XTLB_MASK, PPC403, { RT, RA } }, 4487{ "tlbwehi", XTLB(31,978,0), XTLB_MASK, PPC403, { RT, RA } },
4286{ "tlbwelo", XTLB(31,978,1), XTLB_MASK, PPC403, { RT, RA } }, 4488{ "tlbwelo", XTLB(31,978,1), XTLB_MASK, PPC403, { RT, RA } },
4287{ "tlbwe", X(31,978), X_MASK, BOOKE, { 0 } }, 4489{ "tlbwe", X(31,978), X_MASK, PPC403|BOOKE, { RSO, RAOPT, SHO } },
4288{ "tlbwe", X(31,978), X_MASK, PPC403, { RS, RA, SH } },
4289{ "tlbld", X(31,978), XRTRA_MASK, PPC, { RB } }, 4490{ "tlbld", X(31,978), XRTRA_MASK, PPC, { RB } },
4290 4491
4492{ "stbcix", X(31,981), X_MASK, POWER6, { RS, RA0, RB } },
4493
4291{ "icbi", X(31,982), XRT_MASK, PPC, { RA, RB } }, 4494{ "icbi", X(31,982), XRT_MASK, PPC, { RA, RB } },
4292 4495
4293{ "stfiwx", X(31,983), X_MASK, PPC, { FRS, RA, RB } }, 4496{ "stfiwx", X(31,983), X_MASK, PPC, { FRS, RA0, RB } },
4294 4497
4295{ "extsw", XRC(31,986,0), XRB_MASK, PPC64 | BOOKE64,{ RA, RS } }, 4498{ "extsw", XRC(31,986,0), XRB_MASK, PPC64 | BOOKE64,{ RA, RS } },
4296{ "extsw.", XRC(31,986,1), XRB_MASK, PPC64, { RA, RS } }, 4499{ "extsw.", XRC(31,986,1), XRB_MASK, PPC64, { RA, RS } },
@@ -4298,10 +4501,13 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4298{ "icread", X(31,998), XRT_MASK, PPC403|PPC440, { RA, RB } }, 4501{ "icread", X(31,998), XRT_MASK, PPC403|PPC440, { RA, RB } },
4299 4502
4300{ "icbie", X(31,990), XRT_MASK, BOOKE64, { RA, RB } }, 4503{ "icbie", X(31,990), XRT_MASK, BOOKE64, { RA, RB } },
4301{ "stfiwxe", X(31,991), X_MASK, BOOKE64, { FRS, RA, RB } }, 4504{ "stfiwxe", X(31,991), X_MASK, BOOKE64, { FRS, RA0, RB } },
4302 4505
4303{ "tlbli", X(31,1010), XRTRA_MASK, PPC, { RB } }, 4506{ "tlbli", X(31,1010), XRTRA_MASK, PPC, { RB } },
4304 4507
4508{ "stdcix", X(31,1013), X_MASK, POWER6, { RS, RA0, RB } },
4509
4510{ "dcbzl", XOPL(31,1014,1), XRT_MASK,POWER4, { RA, RB } },
4305{ "dcbz", X(31,1014), XRT_MASK, PPC, { RA, RB } }, 4511{ "dcbz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
4306{ "dclz", X(31,1014), XRT_MASK, PPC, { RA, RB } }, 4512{ "dclz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
4307 4513
@@ -4320,86 +4526,104 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4320{ "stvx", X(31, 231), X_MASK, PPCVEC, { VS, RA, RB } }, 4526{ "stvx", X(31, 231), X_MASK, PPCVEC, { VS, RA, RB } },
4321{ "stvxl", X(31, 487), X_MASK, PPCVEC, { VS, RA, RB } }, 4527{ "stvxl", X(31, 487), X_MASK, PPCVEC, { VS, RA, RB } },
4322 4528
4323{ "lwz", OP(32), OP_MASK, PPCCOM, { RT, D, RA } }, 4529/* New load/store left/right index vector instructions that are in the Cell only. */
4324{ "l", OP(32), OP_MASK, PWRCOM, { RT, D, RA } }, 4530{ "lvlx", X(31, 519), X_MASK, CELL, { VD, RA0, RB } },
4531{ "lvlxl", X(31, 775), X_MASK, CELL, { VD, RA0, RB } },
4532{ "lvrx", X(31, 551), X_MASK, CELL, { VD, RA0, RB } },
4533{ "lvrxl", X(31, 807), X_MASK, CELL, { VD, RA0, RB } },
4534{ "stvlx", X(31, 647), X_MASK, CELL, { VS, RA0, RB } },
4535{ "stvlxl", X(31, 903), X_MASK, CELL, { VS, RA0, RB } },
4536{ "stvrx", X(31, 679), X_MASK, CELL, { VS, RA0, RB } },
4537{ "stvrxl", X(31, 935), X_MASK, CELL, { VS, RA0, RB } },
4538
4539{ "lwz", OP(32), OP_MASK, PPCCOM, { RT, D, RA0 } },
4540{ "l", OP(32), OP_MASK, PWRCOM, { RT, D, RA0 } },
4325 4541
4326{ "lwzu", OP(33), OP_MASK, PPCCOM, { RT, D, RAL } }, 4542{ "lwzu", OP(33), OP_MASK, PPCCOM, { RT, D, RAL } },
4327{ "lu", OP(33), OP_MASK, PWRCOM, { RT, D, RA } }, 4543{ "lu", OP(33), OP_MASK, PWRCOM, { RT, D, RA0 } },
4328 4544
4329{ "lbz", OP(34), OP_MASK, COM, { RT, D, RA } }, 4545{ "lbz", OP(34), OP_MASK, COM, { RT, D, RA0 } },
4330 4546
4331{ "lbzu", OP(35), OP_MASK, COM, { RT, D, RAL } }, 4547{ "lbzu", OP(35), OP_MASK, COM, { RT, D, RAL } },
4332 4548
4333{ "stw", OP(36), OP_MASK, PPCCOM, { RS, D, RA } }, 4549{ "stw", OP(36), OP_MASK, PPCCOM, { RS, D, RA0 } },
4334{ "st", OP(36), OP_MASK, PWRCOM, { RS, D, RA } }, 4550{ "st", OP(36), OP_MASK, PWRCOM, { RS, D, RA0 } },
4335 4551
4336{ "stwu", OP(37), OP_MASK, PPCCOM, { RS, D, RAS } }, 4552{ "stwu", OP(37), OP_MASK, PPCCOM, { RS, D, RAS } },
4337{ "stu", OP(37), OP_MASK, PWRCOM, { RS, D, RA } }, 4553{ "stu", OP(37), OP_MASK, PWRCOM, { RS, D, RA0 } },
4338 4554
4339{ "stb", OP(38), OP_MASK, COM, { RS, D, RA } }, 4555{ "stb", OP(38), OP_MASK, COM, { RS, D, RA0 } },
4340 4556
4341{ "stbu", OP(39), OP_MASK, COM, { RS, D, RAS } }, 4557{ "stbu", OP(39), OP_MASK, COM, { RS, D, RAS } },
4342 4558
4343{ "lhz", OP(40), OP_MASK, COM, { RT, D, RA } }, 4559{ "lhz", OP(40), OP_MASK, COM, { RT, D, RA0 } },
4344 4560
4345{ "lhzu", OP(41), OP_MASK, COM, { RT, D, RAL } }, 4561{ "lhzu", OP(41), OP_MASK, COM, { RT, D, RAL } },
4346 4562
4347{ "lha", OP(42), OP_MASK, COM, { RT, D, RA } }, 4563{ "lha", OP(42), OP_MASK, COM, { RT, D, RA0 } },
4348 4564
4349{ "lhau", OP(43), OP_MASK, COM, { RT, D, RAL } }, 4565{ "lhau", OP(43), OP_MASK, COM, { RT, D, RAL } },
4350 4566
4351{ "sth", OP(44), OP_MASK, COM, { RS, D, RA } }, 4567{ "sth", OP(44), OP_MASK, COM, { RS, D, RA0 } },
4352 4568
4353{ "sthu", OP(45), OP_MASK, COM, { RS, D, RAS } }, 4569{ "sthu", OP(45), OP_MASK, COM, { RS, D, RAS } },
4354 4570
4355{ "lmw", OP(46), OP_MASK, PPCCOM, { RT, D, RAM } }, 4571{ "lmw", OP(46), OP_MASK, PPCCOM, { RT, D, RAM } },
4356{ "lm", OP(46), OP_MASK, PWRCOM, { RT, D, RA } }, 4572{ "lm", OP(46), OP_MASK, PWRCOM, { RT, D, RA0 } },
4357 4573
4358{ "stmw", OP(47), OP_MASK, PPCCOM, { RS, D, RA } }, 4574{ "stmw", OP(47), OP_MASK, PPCCOM, { RS, D, RA0 } },
4359{ "stm", OP(47), OP_MASK, PWRCOM, { RS, D, RA } }, 4575{ "stm", OP(47), OP_MASK, PWRCOM, { RS, D, RA0 } },
4360 4576
4361{ "lfs", OP(48), OP_MASK, COM, { FRT, D, RA } }, 4577{ "lfs", OP(48), OP_MASK, COM, { FRT, D, RA0 } },
4362 4578
4363{ "lfsu", OP(49), OP_MASK, COM, { FRT, D, RAS } }, 4579{ "lfsu", OP(49), OP_MASK, COM, { FRT, D, RAS } },
4364 4580
4365{ "lfd", OP(50), OP_MASK, COM, { FRT, D, RA } }, 4581{ "lfd", OP(50), OP_MASK, COM, { FRT, D, RA0 } },
4366 4582
4367{ "lfdu", OP(51), OP_MASK, COM, { FRT, D, RAS } }, 4583{ "lfdu", OP(51), OP_MASK, COM, { FRT, D, RAS } },
4368 4584
4369{ "stfs", OP(52), OP_MASK, COM, { FRS, D, RA } }, 4585{ "stfs", OP(52), OP_MASK, COM, { FRS, D, RA0 } },
4370 4586
4371{ "stfsu", OP(53), OP_MASK, COM, { FRS, D, RAS } }, 4587{ "stfsu", OP(53), OP_MASK, COM, { FRS, D, RAS } },
4372 4588
4373{ "stfd", OP(54), OP_MASK, COM, { FRS, D, RA } }, 4589{ "stfd", OP(54), OP_MASK, COM, { FRS, D, RA0 } },
4374 4590
4375{ "stfdu", OP(55), OP_MASK, COM, { FRS, D, RAS } }, 4591{ "stfdu", OP(55), OP_MASK, COM, { FRS, D, RAS } },
4376 4592
4377{ "lq", OP(56), OP_MASK, POWER4, { RTQ, DQ, RAQ } }, 4593{ "lq", OP(56), OP_MASK, POWER4, { RTQ, DQ, RAQ } },
4378 4594
4379{ "lfq", OP(56), OP_MASK, POWER2, { FRT, D, RA } }, 4595{ "lfq", OP(56), OP_MASK, POWER2, { FRT, D, RA0 } },
4596
4597{ "lfqu", OP(57), OP_MASK, POWER2, { FRT, D, RA0 } },
4380 4598
4381{ "lfqu", OP(57), OP_MASK, POWER2, { FRT, D, RA } }, 4599{ "lfdp", OP(57), OP_MASK, POWER6, { FRT, D, RA0 } },
4382 4600
4383{ "lbze", DEO(58,0), DE_MASK, BOOKE64, { RT, DE, RA } }, 4601{ "lbze", DEO(58,0), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4384{ "lbzue", DEO(58,1), DE_MASK, BOOKE64, { RT, DE, RAL } }, 4602{ "lbzue", DEO(58,1), DE_MASK, BOOKE64, { RT, DE, RAL } },
4385{ "lhze", DEO(58,2), DE_MASK, BOOKE64, { RT, DE, RA } }, 4603{ "lhze", DEO(58,2), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4386{ "lhzue", DEO(58,3), DE_MASK, BOOKE64, { RT, DE, RAL } }, 4604{ "lhzue", DEO(58,3), DE_MASK, BOOKE64, { RT, DE, RAL } },
4387{ "lhae", DEO(58,4), DE_MASK, BOOKE64, { RT, DE, RA } }, 4605{ "lhae", DEO(58,4), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4388{ "lhaue", DEO(58,5), DE_MASK, BOOKE64, { RT, DE, RAL } }, 4606{ "lhaue", DEO(58,5), DE_MASK, BOOKE64, { RT, DE, RAL } },
4389{ "lwze", DEO(58,6), DE_MASK, BOOKE64, { RT, DE, RA } }, 4607{ "lwze", DEO(58,6), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4390{ "lwzue", DEO(58,7), DE_MASK, BOOKE64, { RT, DE, RAL } }, 4608{ "lwzue", DEO(58,7), DE_MASK, BOOKE64, { RT, DE, RAL } },
4391{ "stbe", DEO(58,8), DE_MASK, BOOKE64, { RS, DE, RA } }, 4609{ "stbe", DEO(58,8), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4392{ "stbue", DEO(58,9), DE_MASK, BOOKE64, { RS, DE, RAS } }, 4610{ "stbue", DEO(58,9), DE_MASK, BOOKE64, { RS, DE, RAS } },
4393{ "sthe", DEO(58,10), DE_MASK, BOOKE64, { RS, DE, RA } }, 4611{ "sthe", DEO(58,10), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4394{ "sthue", DEO(58,11), DE_MASK, BOOKE64, { RS, DE, RAS } }, 4612{ "sthue", DEO(58,11), DE_MASK, BOOKE64, { RS, DE, RAS } },
4395{ "stwe", DEO(58,14), DE_MASK, BOOKE64, { RS, DE, RA } }, 4613{ "stwe", DEO(58,14), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4396{ "stwue", DEO(58,15), DE_MASK, BOOKE64, { RS, DE, RAS } }, 4614{ "stwue", DEO(58,15), DE_MASK, BOOKE64, { RS, DE, RAS } },
4397 4615
4398{ "ld", DSO(58,0), DS_MASK, PPC64, { RT, DS, RA } }, 4616{ "ld", DSO(58,0), DS_MASK, PPC64, { RT, DS, RA0 } },
4399 4617
4400{ "ldu", DSO(58,1), DS_MASK, PPC64, { RT, DS, RAL } }, 4618{ "ldu", DSO(58,1), DS_MASK, PPC64, { RT, DS, RAL } },
4401 4619
4402{ "lwa", DSO(58,2), DS_MASK, PPC64, { RT, DS, RA } }, 4620{ "lwa", DSO(58,2), DS_MASK, PPC64, { RT, DS, RA0 } },
4621
4622{ "dadd", XRC(59,2,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4623{ "dadd.", XRC(59,2,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4624
4625{ "dqua", ZRC(59,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4626{ "dqua.", ZRC(59,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4403 4627
4404{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 4628{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } },
4405{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 4629{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
@@ -4413,12 +4637,15 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4413{ "fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4637{ "fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, { FRT, FRB } },
4414{ "fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4638{ "fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, { FRT, FRB } },
4415 4639
4416{ "fres", A(59,24,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4640{ "fres", A(59,24,0), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4417{ "fres.", A(59,24,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4641{ "fres.", A(59,24,1), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4418 4642
4419{ "fmuls", A(59,25,0), AFRB_MASK, PPC, { FRT, FRA, FRC } }, 4643{ "fmuls", A(59,25,0), AFRB_MASK, PPC, { FRT, FRA, FRC } },
4420{ "fmuls.", A(59,25,1), AFRB_MASK, PPC, { FRT, FRA, FRC } }, 4644{ "fmuls.", A(59,25,1), AFRB_MASK, PPC, { FRT, FRA, FRC } },
4421 4645
4646{ "frsqrtes", A(59,26,0), AFRALFRC_MASK,POWER5, { FRT, FRB, A_L } },
4647{ "frsqrtes.",A(59,26,1), AFRALFRC_MASK,POWER5, { FRT, FRB, A_L } },
4648
4422{ "fmsubs", A(59,28,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4649{ "fmsubs", A(59,28,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4423{ "fmsubs.", A(59,28,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4650{ "fmsubs.", A(59,28,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4424 4651
@@ -4431,31 +4658,103 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4431{ "fnmadds", A(59,31,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4658{ "fnmadds", A(59,31,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4432{ "fnmadds.",A(59,31,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4659{ "fnmadds.",A(59,31,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4433 4660
4661{ "dmul", XRC(59,34,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4662{ "dmul.", XRC(59,34,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4663
4664{ "drrnd", ZRC(59,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4665{ "drrnd.", ZRC(59,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4666
4667{ "dscli", ZRC(59,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4668{ "dscli.", ZRC(59,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4669
4670{ "dquai", ZRC(59,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } },
4671{ "dquai.", ZRC(59,67,1), Z_MASK, POWER6, { TE, FRT, FRB, RMC } },
4672
4673{ "dscri", ZRC(59,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4674{ "dscri.", ZRC(59,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4675
4676{ "drintx", ZRC(59,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4677{ "drintx.", ZRC(59,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4678
4679{ "dcmpo", X(59,130), X_MASK, POWER6, { BF, FRA, FRB } },
4680
4681{ "dtstex", X(59,162), X_MASK, POWER6, { BF, FRA, FRB } },
4682{ "dtstdc", Z(59,194), Z_MASK, POWER6, { BF, FRA, DCM } },
4683{ "dtstdg", Z(59,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4684
4685{ "drintn", ZRC(59,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4686{ "drintn.", ZRC(59,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4687
4688{ "dctdp", XRC(59,258,0), X_MASK, POWER6, { FRT, FRB } },
4689{ "dctdp.", XRC(59,258,1), X_MASK, POWER6, { FRT, FRB } },
4690
4691{ "dctfix", XRC(59,290,0), X_MASK, POWER6, { FRT, FRB } },
4692{ "dctfix.", XRC(59,290,1), X_MASK, POWER6, { FRT, FRB } },
4693
4694{ "ddedpd", XRC(59,322,0), X_MASK, POWER6, { SP, FRT, FRB } },
4695{ "ddedpd.", XRC(59,322,1), X_MASK, POWER6, { SP, FRT, FRB } },
4696
4697{ "dxex", XRC(59,354,0), X_MASK, POWER6, { FRT, FRB } },
4698{ "dxex.", XRC(59,354,1), X_MASK, POWER6, { FRT, FRB } },
4699
4700{ "dsub", XRC(59,514,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4701{ "dsub.", XRC(59,514,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4702
4703{ "ddiv", XRC(59,546,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4704{ "ddiv.", XRC(59,546,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4705
4706{ "dcmpu", X(59,642), X_MASK, POWER6, { BF, FRA, FRB } },
4707
4708{ "dtstsf", X(59,674), X_MASK, POWER6, { BF, FRA, FRB } },
4709
4710{ "drsp", XRC(59,770,0), X_MASK, POWER6, { FRT, FRB } },
4711{ "drsp.", XRC(59,770,1), X_MASK, POWER6, { FRT, FRB } },
4712
4713{ "dcffix", XRC(59,802,0), X_MASK, POWER6, { FRT, FRB } },
4714{ "dcffix.", XRC(59,802,1), X_MASK, POWER6, { FRT, FRB } },
4715
4716{ "denbcd", XRC(59,834,0), X_MASK, POWER6, { S, FRT, FRB } },
4717{ "denbcd.", XRC(59,834,1), X_MASK, POWER6, { S, FRT, FRB } },
4718
4719{ "diex", XRC(59,866,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4720{ "diex.", XRC(59,866,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4721
4434{ "stfq", OP(60), OP_MASK, POWER2, { FRS, D, RA } }, 4722{ "stfq", OP(60), OP_MASK, POWER2, { FRS, D, RA } },
4435 4723
4436{ "stfqu", OP(61), OP_MASK, POWER2, { FRS, D, RA } }, 4724{ "stfqu", OP(61), OP_MASK, POWER2, { FRS, D, RA } },
4437 4725
4438{ "lde", DEO(62,0), DE_MASK, BOOKE64, { RT, DES, RA } }, 4726{ "stfdp", OP(61), OP_MASK, POWER6, { FRT, D, RA0 } },
4439{ "ldue", DEO(62,1), DE_MASK, BOOKE64, { RT, DES, RA } }, 4727
4440{ "lfse", DEO(62,4), DE_MASK, BOOKE64, { FRT, DES, RA } }, 4728{ "lde", DEO(62,0), DE_MASK, BOOKE64, { RT, DES, RA0 } },
4729{ "ldue", DEO(62,1), DE_MASK, BOOKE64, { RT, DES, RA0 } },
4730{ "lfse", DEO(62,4), DE_MASK, BOOKE64, { FRT, DES, RA0 } },
4441{ "lfsue", DEO(62,5), DE_MASK, BOOKE64, { FRT, DES, RAS } }, 4731{ "lfsue", DEO(62,5), DE_MASK, BOOKE64, { FRT, DES, RAS } },
4442{ "lfde", DEO(62,6), DE_MASK, BOOKE64, { FRT, DES, RA } }, 4732{ "lfde", DEO(62,6), DE_MASK, BOOKE64, { FRT, DES, RA0 } },
4443{ "lfdue", DEO(62,7), DE_MASK, BOOKE64, { FRT, DES, RAS } }, 4733{ "lfdue", DEO(62,7), DE_MASK, BOOKE64, { FRT, DES, RAS } },
4444{ "stde", DEO(62,8), DE_MASK, BOOKE64, { RS, DES, RA } }, 4734{ "stde", DEO(62,8), DE_MASK, BOOKE64, { RS, DES, RA0 } },
4445{ "stdue", DEO(62,9), DE_MASK, BOOKE64, { RS, DES, RAS } }, 4735{ "stdue", DEO(62,9), DE_MASK, BOOKE64, { RS, DES, RAS } },
4446{ "stfse", DEO(62,12), DE_MASK, BOOKE64, { FRS, DES, RA } }, 4736{ "stfse", DEO(62,12), DE_MASK, BOOKE64, { FRS, DES, RA0 } },
4447{ "stfsue", DEO(62,13), DE_MASK, BOOKE64, { FRS, DES, RAS } }, 4737{ "stfsue", DEO(62,13), DE_MASK, BOOKE64, { FRS, DES, RAS } },
4448{ "stfde", DEO(62,14), DE_MASK, BOOKE64, { FRS, DES, RA } }, 4738{ "stfde", DEO(62,14), DE_MASK, BOOKE64, { FRS, DES, RA0 } },
4449{ "stfdue", DEO(62,15), DE_MASK, BOOKE64, { FRS, DES, RAS } }, 4739{ "stfdue", DEO(62,15), DE_MASK, BOOKE64, { FRS, DES, RAS } },
4450 4740
4451{ "std", DSO(62,0), DS_MASK, PPC64, { RS, DS, RA } }, 4741{ "std", DSO(62,0), DS_MASK, PPC64, { RS, DS, RA0 } },
4452 4742
4453{ "stdu", DSO(62,1), DS_MASK, PPC64, { RS, DS, RAS } }, 4743{ "stdu", DSO(62,1), DS_MASK, PPC64, { RS, DS, RAS } },
4454 4744
4455{ "stq", DSO(62,2), DS_MASK, POWER4, { RSQ, DS, RA } }, 4745{ "stq", DSO(62,2), DS_MASK, POWER4, { RSQ, DS, RA0 } },
4456 4746
4457{ "fcmpu", X(63,0), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, 4747{ "fcmpu", X(63,0), X_MASK|(3<<21), COM, { BF, FRA, FRB } },
4458 4748
4749{ "daddq", XRC(63,2,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4750{ "daddq.", XRC(63,2,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4751
4752{ "dquaq", ZRC(63,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4753{ "dquaq.", ZRC(63,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4754
4755{ "fcpsgn", XRC(63,8,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4756{ "fcpsgn.", XRC(63,8,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4757
4459{ "frsp", XRC(63,12,0), XRA_MASK, COM, { FRT, FRB } }, 4758{ "frsp", XRC(63,12,0), XRA_MASK, COM, { FRT, FRB } },
4460{ "frsp.", XRC(63,12,1), XRA_MASK, COM, { FRT, FRB } }, 4759{ "frsp.", XRC(63,12,1), XRA_MASK, COM, { FRT, FRB } },
4461 4760
@@ -4490,13 +4789,16 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4490{ "fsel", A(63,23,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4789{ "fsel", A(63,23,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4491{ "fsel.", A(63,23,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 4790{ "fsel.", A(63,23,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4492 4791
4792{ "fre", A(63,24,0), AFRALFRC_MASK, POWER5, { FRT, FRB, A_L } },
4793{ "fre.", A(63,24,1), AFRALFRC_MASK, POWER5, { FRT, FRB, A_L } },
4794
4493{ "fmul", A(63,25,0), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } }, 4795{ "fmul", A(63,25,0), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } },
4494{ "fm", A(63,25,0), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } }, 4796{ "fm", A(63,25,0), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
4495{ "fmul.", A(63,25,1), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } }, 4797{ "fmul.", A(63,25,1), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } },
4496{ "fm.", A(63,25,1), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } }, 4798{ "fm.", A(63,25,1), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
4497 4799
4498{ "frsqrte", A(63,26,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4800{ "frsqrte", A(63,26,0), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4499{ "frsqrte.",A(63,26,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, 4801{ "frsqrte.",A(63,26,1), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4500 4802
4501{ "fmsub", A(63,28,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, 4803{ "fmsub", A(63,28,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
4502{ "fms", A(63,28,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } }, 4804{ "fms", A(63,28,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
@@ -4520,6 +4822,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4520 4822
4521{ "fcmpo", X(63,32), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, 4823{ "fcmpo", X(63,32), X_MASK|(3<<21), COM, { BF, FRA, FRB } },
4522 4824
4825{ "dmulq", XRC(63,34,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4826{ "dmulq.", XRC(63,34,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4827
4828{ "drrndq", ZRC(63,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4829{ "drrndq.", ZRC(63,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4830
4523{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } }, 4831{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } },
4524{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } }, 4832{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } },
4525 4833
@@ -4528,36 +4836,100 @@ const struct powerpc_opcode powerpc_opcodes[] = {
4528 4836
4529{ "mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } }, 4837{ "mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } },
4530 4838
4839{ "dscliq", ZRC(63,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4840{ "dscliq.", ZRC(63,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4841
4842{ "dquaiq", ZRC(63,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } },
4843{ "dquaiq.", ZRC(63,67,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4844
4531{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } }, 4845{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } },
4532{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } }, 4846{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } },
4533 4847
4534{ "fmr", XRC(63,72,0), XRA_MASK, COM, { FRT, FRB } }, 4848{ "fmr", XRC(63,72,0), XRA_MASK, COM, { FRT, FRB } },
4535{ "fmr.", XRC(63,72,1), XRA_MASK, COM, { FRT, FRB } }, 4849{ "fmr.", XRC(63,72,1), XRA_MASK, COM, { FRT, FRB } },
4536 4850
4851{ "dscriq", ZRC(63,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4852{ "dscriq.", ZRC(63,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4853
4854{ "drintxq", ZRC(63,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4855{ "drintxq.",ZRC(63,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4856
4857{ "dcmpoq", X(63,130), X_MASK, POWER6, { BF, FRA, FRB } },
4858
4537{ "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, 4859{ "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } },
4538{ "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, 4860{ "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } },
4539 4861
4540{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } }, 4862{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } },
4541{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } }, 4863{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } },
4542 4864
4865{ "dtstexq", X(63,162), X_MASK, POWER6, { BF, FRA, FRB } },
4866{ "dtstdcq", Z(63,194), Z_MASK, POWER6, { BF, FRA, DCM } },
4867{ "dtstdgq", Z(63,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4868
4869{ "drintnq", ZRC(63,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4870{ "drintnq.",ZRC(63,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4871
4872{ "dctqpq", XRC(63,258,0), X_MASK, POWER6, { FRT, FRB } },
4873{ "dctqpq.", XRC(63,258,1), X_MASK, POWER6, { FRT, FRB } },
4874
4543{ "fabs", XRC(63,264,0), XRA_MASK, COM, { FRT, FRB } }, 4875{ "fabs", XRC(63,264,0), XRA_MASK, COM, { FRT, FRB } },
4544{ "fabs.", XRC(63,264,1), XRA_MASK, COM, { FRT, FRB } }, 4876{ "fabs.", XRC(63,264,1), XRA_MASK, COM, { FRT, FRB } },
4545 4877
4878{ "dctfixq", XRC(63,290,0), X_MASK, POWER6, { FRT, FRB } },
4879{ "dctfixq.",XRC(63,290,1), X_MASK, POWER6, { FRT, FRB } },
4880
4881{ "ddedpdq", XRC(63,322,0), X_MASK, POWER6, { SP, FRT, FRB } },
4882{ "ddedpdq.",XRC(63,322,1), X_MASK, POWER6, { SP, FRT, FRB } },
4883
4884{ "dxexq", XRC(63,354,0), X_MASK, POWER6, { FRT, FRB } },
4885{ "dxexq.", XRC(63,354,1), X_MASK, POWER6, { FRT, FRB } },
4886
4887{ "frin", XRC(63,392,0), XRA_MASK, POWER5, { FRT, FRB } },
4888{ "frin.", XRC(63,392,1), XRA_MASK, POWER5, { FRT, FRB } },
4889{ "friz", XRC(63,424,0), XRA_MASK, POWER5, { FRT, FRB } },
4890{ "friz.", XRC(63,424,1), XRA_MASK, POWER5, { FRT, FRB } },
4891{ "frip", XRC(63,456,0), XRA_MASK, POWER5, { FRT, FRB } },
4892{ "frip.", XRC(63,456,1), XRA_MASK, POWER5, { FRT, FRB } },
4893{ "frim", XRC(63,488,0), XRA_MASK, POWER5, { FRT, FRB } },
4894{ "frim.", XRC(63,488,1), XRA_MASK, POWER5, { FRT, FRB } },
4895
4896{ "dsubq", XRC(63,514,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4897{ "dsubq.", XRC(63,514,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4898
4899{ "ddivq", XRC(63,546,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4900{ "ddivq.", XRC(63,546,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4901
4546{ "mffs", XRC(63,583,0), XRARB_MASK, COM, { FRT } }, 4902{ "mffs", XRC(63,583,0), XRARB_MASK, COM, { FRT } },
4547{ "mffs.", XRC(63,583,1), XRARB_MASK, COM, { FRT } }, 4903{ "mffs.", XRC(63,583,1), XRARB_MASK, COM, { FRT } },
4548 4904
4905{ "dcmpuq", X(63,642), X_MASK, POWER6, { BF, FRA, FRB } },
4906
4907{ "dtstsfq", X(63,674), X_MASK, POWER6, { BF, FRA, FRB } },
4908
4549{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } }, 4909{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } },
4550{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } }, 4910{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } },
4551 4911
4912{ "drdpq", XRC(63,770,0), X_MASK, POWER6, { FRT, FRB } },
4913{ "drdpq.", XRC(63,770,1), X_MASK, POWER6, { FRT, FRB } },
4914
4915{ "dcffixq", XRC(63,802,0), X_MASK, POWER6, { FRT, FRB } },
4916{ "dcffixq.",XRC(63,802,1), X_MASK, POWER6, { FRT, FRB } },
4917
4552{ "fctid", XRC(63,814,0), XRA_MASK, PPC64, { FRT, FRB } }, 4918{ "fctid", XRC(63,814,0), XRA_MASK, PPC64, { FRT, FRB } },
4553{ "fctid.", XRC(63,814,1), XRA_MASK, PPC64, { FRT, FRB } }, 4919{ "fctid.", XRC(63,814,1), XRA_MASK, PPC64, { FRT, FRB } },
4554 4920
4555{ "fctidz", XRC(63,815,0), XRA_MASK, PPC64, { FRT, FRB } }, 4921{ "fctidz", XRC(63,815,0), XRA_MASK, PPC64, { FRT, FRB } },
4556{ "fctidz.", XRC(63,815,1), XRA_MASK, PPC64, { FRT, FRB } }, 4922{ "fctidz.", XRC(63,815,1), XRA_MASK, PPC64, { FRT, FRB } },
4557 4923
4924{ "denbcdq", XRC(63,834,0), X_MASK, POWER6, { S, FRT, FRB } },
4925{ "denbcdq.",XRC(63,834,1), X_MASK, POWER6, { S, FRT, FRB } },
4926
4558{ "fcfid", XRC(63,846,0), XRA_MASK, PPC64, { FRT, FRB } }, 4927{ "fcfid", XRC(63,846,0), XRA_MASK, PPC64, { FRT, FRB } },
4559{ "fcfid.", XRC(63,846,1), XRA_MASK, PPC64, { FRT, FRB } }, 4928{ "fcfid.", XRC(63,846,1), XRA_MASK, PPC64, { FRT, FRB } },
4560 4929
4930{ "diexq", XRC(63,866,0), X_MASK, POWER6, { FRT, FRA, FRB } },
4931{ "diexq.", XRC(63,866,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4932
4561}; 4933};
4562 4934
4563const int powerpc_num_opcodes = 4935const int powerpc_num_opcodes =
diff --git a/arch/powerpc/xmon/ppc.h b/arch/powerpc/xmon/ppc.h
index 342237e8dd69..110df96354b4 100644
--- a/arch/powerpc/xmon/ppc.h
+++ b/arch/powerpc/xmon/ppc.h
@@ -1,5 +1,5 @@
1/* ppc.h -- Header file for PowerPC opcode table 1/* ppc.h -- Header file for PowerPC opcode table
2 Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003 2 Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 4 Written by Ian Lance Taylor, Cygnus Support
5 5
@@ -17,7 +17,7 @@ the GNU General Public License for more details.
17 17
18You should have received a copy of the GNU General Public License 18You should have received a copy of the GNU General Public License
19along with this file; see the file COPYING. If not, write to the Free 19along with this file; see the file COPYING. If not, write to the Free
20Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 20Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
21 21
22#ifndef PPC_H 22#ifndef PPC_H
23#define PPC_H 23#define PPC_H
@@ -134,6 +134,18 @@ extern const int powerpc_num_opcodes;
134/* Opcode is supported by machine check APU. */ 134/* Opcode is supported by machine check APU. */
135#define PPC_OPCODE_RFMCI 0x800000 135#define PPC_OPCODE_RFMCI 0x800000
136 136
137/* Opcode is only supported by Power5 architecture. */
138#define PPC_OPCODE_POWER5 0x1000000
139
140/* Opcode is supported by PowerPC e300 family. */
141#define PPC_OPCODE_E300 0x2000000
142
143/* Opcode is only supported by Power6 architecture. */
144#define PPC_OPCODE_POWER6 0x4000000
145
146/* Opcode is only supported by PowerPC Cell family. */
147#define PPC_OPCODE_CELL 0x8000000
148
137/* A macro to extract the major opcode from an instruction. */ 149/* A macro to extract the major opcode from an instruction. */
138#define PPC_OP(i) (((i) >> 26) & 0x3f) 150#define PPC_OP(i) (((i) >> 26) & 0x3f)
139 151
@@ -233,25 +245,28 @@ extern const struct powerpc_operand powerpc_operands[];
233 register names with a leading 'r'. */ 245 register names with a leading 'r'. */
234#define PPC_OPERAND_GPR (040) 246#define PPC_OPERAND_GPR (040)
235 247
248/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */
249#define PPC_OPERAND_GPR_0 (0100)
250
236/* This operand names a floating point register. The disassembler 251/* This operand names a floating point register. The disassembler
237 prints these with a leading 'f'. */ 252 prints these with a leading 'f'. */
238#define PPC_OPERAND_FPR (0100) 253#define PPC_OPERAND_FPR (0200)
239 254
240/* This operand is a relative branch displacement. The disassembler 255/* This operand is a relative branch displacement. The disassembler
241 prints these symbolically if possible. */ 256 prints these symbolically if possible. */
242#define PPC_OPERAND_RELATIVE (0200) 257#define PPC_OPERAND_RELATIVE (0400)
243 258
244/* This operand is an absolute branch address. The disassembler 259/* This operand is an absolute branch address. The disassembler
245 prints these symbolically if possible. */ 260 prints these symbolically if possible. */
246#define PPC_OPERAND_ABSOLUTE (0400) 261#define PPC_OPERAND_ABSOLUTE (01000)
247 262
248/* This operand is optional, and is zero if omitted. This is used for 263/* This operand is optional, and is zero if omitted. This is used for
249 the optional BF and L fields in the comparison instructions. The 264 example, in the optional BF field in the comparison instructions. The
250 assembler must count the number of operands remaining on the line, 265 assembler must count the number of operands remaining on the line,
251 and the number of operands remaining for the opcode, and decide 266 and the number of operands remaining for the opcode, and decide
252 whether this operand is present or not. The disassembler should 267 whether this operand is present or not. The disassembler should
253 print this operand out only if it is not zero. */ 268 print this operand out only if it is not zero. */
254#define PPC_OPERAND_OPTIONAL (01000) 269#define PPC_OPERAND_OPTIONAL (02000)
255 270
256/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand 271/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
257 is omitted, then for the next operand use this operand value plus 272 is omitted, then for the next operand use this operand value plus
@@ -259,24 +274,24 @@ extern const struct powerpc_operand powerpc_operands[];
259 hack is needed because the Power rotate instructions can take 274 hack is needed because the Power rotate instructions can take
260 either 4 or 5 operands. The disassembler should print this operand 275 either 4 or 5 operands. The disassembler should print this operand
261 out regardless of the PPC_OPERAND_OPTIONAL field. */ 276 out regardless of the PPC_OPERAND_OPTIONAL field. */
262#define PPC_OPERAND_NEXT (02000) 277#define PPC_OPERAND_NEXT (04000)
263 278
264/* This operand should be regarded as a negative number for the 279/* This operand should be regarded as a negative number for the
265 purposes of overflow checking (i.e., the normal most negative 280 purposes of overflow checking (i.e., the normal most negative
266 number is disallowed and one more than the normal most positive 281 number is disallowed and one more than the normal most positive
267 number is allowed). This flag will only be set for a signed 282 number is allowed). This flag will only be set for a signed
268 operand. */ 283 operand. */
269#define PPC_OPERAND_NEGATIVE (04000) 284#define PPC_OPERAND_NEGATIVE (010000)
270 285
271/* This operand names a vector unit register. The disassembler 286/* This operand names a vector unit register. The disassembler
272 prints these with a leading 'v'. */ 287 prints these with a leading 'v'. */
273#define PPC_OPERAND_VR (010000) 288#define PPC_OPERAND_VR (020000)
274 289
275/* This operand is for the DS field in a DS form instruction. */ 290/* This operand is for the DS field in a DS form instruction. */
276#define PPC_OPERAND_DS (020000) 291#define PPC_OPERAND_DS (040000)
277 292
278/* This operand is for the DQ field in a DQ form instruction. */ 293/* This operand is for the DQ field in a DQ form instruction. */
279#define PPC_OPERAND_DQ (040000) 294#define PPC_OPERAND_DQ (0100000)
280 295
281/* The POWER and PowerPC assemblers use a few macros. We keep them 296/* The POWER and PowerPC assemblers use a few macros. We keep them
282 with the operands table for simplicity. The macro table is an 297 with the operands table for simplicity. The macro table is an
diff --git a/arch/powerpc/xmon/spu-dis.c b/arch/powerpc/xmon/spu-dis.c
new file mode 100644
index 000000000000..ee929c641bf3
--- /dev/null
+++ b/arch/powerpc/xmon/spu-dis.c
@@ -0,0 +1,248 @@
1/* Disassemble SPU instructions
2
3 Copyright 2006 Free Software Foundation, Inc.
4
5 This file is part of GDB, GAS, and the GNU binutils.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21#include <linux/string.h>
22#include "nonstdio.h"
23#include "ansidecl.h"
24#include "spu.h"
25#include "dis-asm.h"
26
27/* This file provides a disassembler function which uses
28 the disassembler interface defined in dis-asm.h. */
29
30extern const struct spu_opcode spu_opcodes[];
31extern const int spu_num_opcodes;
32
33#define SPU_DISASM_TBL_SIZE (1 << 11)
34static const struct spu_opcode *spu_disassemble_table[SPU_DISASM_TBL_SIZE];
35
36static void
37init_spu_disassemble (void)
38{
39 int i;
40
41 /* If two instructions have the same opcode then we prefer the first
42 * one. In most cases it is just an alternate mnemonic. */
43 for (i = 0; i < spu_num_opcodes; i++)
44 {
45 int o = spu_opcodes[i].opcode;
46 if (o >= SPU_DISASM_TBL_SIZE)
47 continue; /* abort (); */
48 if (spu_disassemble_table[o] == 0)
49 spu_disassemble_table[o] = &spu_opcodes[i];
50 }
51}
52
53/* Determine the instruction from the 10 least significant bits. */
54static const struct spu_opcode *
55get_index_for_opcode (unsigned int insn)
56{
57 const struct spu_opcode *index;
58 unsigned int opcode = insn >> (32-11);
59
60 /* Init the table. This assumes that element 0/opcode 0 (currently
61 * NOP) is always used */
62 if (spu_disassemble_table[0] == 0)
63 init_spu_disassemble ();
64
65 if ((index = spu_disassemble_table[opcode & 0x780]) != 0
66 && index->insn_type == RRR)
67 return index;
68
69 if ((index = spu_disassemble_table[opcode & 0x7f0]) != 0
70 && (index->insn_type == RI18 || index->insn_type == LBT))
71 return index;
72
73 if ((index = spu_disassemble_table[opcode & 0x7f8]) != 0
74 && index->insn_type == RI10)
75 return index;
76
77 if ((index = spu_disassemble_table[opcode & 0x7fc]) != 0
78 && (index->insn_type == RI16))
79 return index;
80
81 if ((index = spu_disassemble_table[opcode & 0x7fe]) != 0
82 && (index->insn_type == RI8))
83 return index;
84
85 if ((index = spu_disassemble_table[opcode & 0x7ff]) != 0)
86 return index;
87
88 return 0;
89}
90
91/* Print a Spu instruction. */
92
93int
94print_insn_spu (unsigned long insn, unsigned long memaddr)
95{
96 int value;
97 int hex_value;
98 const struct spu_opcode *index;
99 enum spu_insns tag;
100
101 index = get_index_for_opcode (insn);
102
103 if (index == 0)
104 {
105 printf(".long 0x%x", insn);
106 }
107 else
108 {
109 int i;
110 int paren = 0;
111 tag = (enum spu_insns)(index - spu_opcodes);
112 printf("%s", index->mnemonic);
113 if (tag == M_BI || tag == M_BISL || tag == M_IRET || tag == M_BISLED
114 || tag == M_BIHNZ || tag == M_BIHZ || tag == M_BINZ || tag == M_BIZ
115 || tag == M_SYNC || tag == M_HBR)
116 {
117 int fb = (insn >> (32-18)) & 0x7f;
118 if (fb & 0x40)
119 printf(tag == M_SYNC ? "c" : "p");
120 if (fb & 0x20)
121 printf("d");
122 if (fb & 0x10)
123 printf("e");
124 }
125 if (index->arg[0] != 0)
126 printf("\t");
127 hex_value = 0;
128 for (i = 1; i <= index->arg[0]; i++)
129 {
130 int arg = index->arg[i];
131 if (arg != A_P && !paren && i > 1)
132 printf(",");
133
134 switch (arg)
135 {
136 case A_T:
137 printf("$%d",
138 DECODE_INSN_RT (insn));
139 break;
140 case A_A:
141 printf("$%d",
142 DECODE_INSN_RA (insn));
143 break;
144 case A_B:
145 printf("$%d",
146 DECODE_INSN_RB (insn));
147 break;
148 case A_C:
149 printf("$%d",
150 DECODE_INSN_RC (insn));
151 break;
152 case A_S:
153 printf("$sp%d",
154 DECODE_INSN_RA (insn));
155 break;
156 case A_H:
157 printf("$ch%d",
158 DECODE_INSN_RA (insn));
159 break;
160 case A_P:
161 paren++;
162 printf("(");
163 break;
164 case A_U7A:
165 printf("%d",
166 173 - DECODE_INSN_U8 (insn));
167 break;
168 case A_U7B:
169 printf("%d",
170 155 - DECODE_INSN_U8 (insn));
171 break;
172 case A_S3:
173 case A_S6:
174 case A_S7:
175 case A_S7N:
176 case A_U3:
177 case A_U5:
178 case A_U6:
179 case A_U7:
180 hex_value = DECODE_INSN_I7 (insn);
181 printf("%d", hex_value);
182 break;
183 case A_S11:
184 print_address(memaddr + DECODE_INSN_I9a (insn) * 4);
185 break;
186 case A_S11I:
187 print_address(memaddr + DECODE_INSN_I9b (insn) * 4);
188 break;
189 case A_S10:
190 case A_S10B:
191 hex_value = DECODE_INSN_I10 (insn);
192 printf("%d", hex_value);
193 break;
194 case A_S14:
195 hex_value = DECODE_INSN_I10 (insn) * 16;
196 printf("%d", hex_value);
197 break;
198 case A_S16:
199 hex_value = DECODE_INSN_I16 (insn);
200 printf("%d", hex_value);
201 break;
202 case A_X16:
203 hex_value = DECODE_INSN_U16 (insn);
204 printf("%u", hex_value);
205 break;
206 case A_R18:
207 value = DECODE_INSN_I16 (insn) * 4;
208 if (value == 0)
209 printf("%d", value);
210 else
211 {
212 hex_value = memaddr + value;
213 print_address(hex_value & 0x3ffff);
214 }
215 break;
216 case A_S18:
217 value = DECODE_INSN_U16 (insn) * 4;
218 if (value == 0)
219 printf("%d", value);
220 else
221 print_address(value);
222 break;
223 case A_U18:
224 value = DECODE_INSN_U18 (insn);
225 if (value == 0 || 1)
226 {
227 hex_value = value;
228 printf("%u", value);
229 }
230 else
231 print_address(value);
232 break;
233 case A_U14:
234 hex_value = DECODE_INSN_U14 (insn);
235 printf("%u", hex_value);
236 break;
237 }
238 if (arg != A_P && paren)
239 {
240 printf(")");
241 paren--;
242 }
243 }
244 if (hex_value > 16)
245 printf("\t# %x", hex_value);
246 }
247 return 4;
248}
diff --git a/arch/powerpc/xmon/spu-insns.h b/arch/powerpc/xmon/spu-insns.h
new file mode 100644
index 000000000000..99dc452821ac
--- /dev/null
+++ b/arch/powerpc/xmon/spu-insns.h
@@ -0,0 +1,410 @@
1/* SPU ELF support for BFD.
2
3 Copyright 2006 Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21/* SPU Opcode Table
22
23-=-=-= FORMAT =-=-=-
24
25 +----+-------+-------+-------+-------+ +------------+-------+-------+-------+
26RRR | op | RC | RB | RA | RT | RI7 | op | I7 | RA | RT |
27 +----+-------+-------+-------+-------+ +------------+-------+-------+-------+
28 0 3 1 1 2 3 0 1 1 2 3
29 0 7 4 1 0 7 4 1
30
31 +-----------+--------+-------+-------+ +---------+----------+-------+-------+
32RI8 | op | I8 | RA | RT | RI10 | op | I10 | RA | RT |
33 +-----------+--------+-------+-------+ +---------+----------+-------+-------+
34 0 9 1 2 3 0 7 1 2 3
35 7 4 1 7 4 1
36
37 +----------+-----------------+-------+ +--------+-------------------+-------+
38RI16 | op | I16 | RT | RI18 | op | I18 | RT |
39 +----------+-----------------+-------+ +--------+-------------------+-------+
40 0 8 2 3 0 6 2 3
41 4 1 4 1
42
43 +------------+-------+-------+-------+ +-------+--+-----------------+-------+
44RR | op | RB | RA | RT | LBT | op |RO| I16 | RO |
45 +------------+-------+-------+-------+ +-------+--+-----------------+-------+
46 0 1 1 2 3 0 6 8 2 3
47 0 7 4 1 4 1
48
49 +------------+----+--+-------+-------+
50 LBTI | op | // |RO| RA | RO |
51 +------------+----+--+-------+-------+
52 0 1 1 1 2 3
53 0 5 7 4 1
54
55-=-=-= OPCODE =-=-=-
56
57OPCODE field specifies the most significant 11bit of the instruction. Some formats don't have 11bits for opcode field, and in this
58case, bit field other than op are defined as 0s. For example, opcode of fma instruction which is RRR format is defined as 0x700,
59since 0x700 -> 11'b11100000000, this means opcode is 4'b1110, and other 7bits are defined as 7'b0000000.
60
61-=-=-= ASM_FORMAT =-=-=-
62
63RRR category RI7 category
64 ASM_RRR mnemonic RC, RA, RB, RT ASM_RI4 mnemonic RT, RA, I4
65 ASM_RI7 mnemonic RT, RA, I7
66
67RI8 category RI10 category
68 ASM_RUI8 mnemonic RT, RA, UI8 ASM_AI10 mnemonic RA, I10
69 ASM_RI10 mnemonic RT, RA, R10
70 ASM_RI10IDX mnemonic RT, I10(RA)
71
72RI16 category RI18 category
73 ASM_I16W mnemonic I16W ASM_RI18 mnemonic RT, I18
74 ASM_RI16 mnemonic RT, I16
75 ASM_RI16W mnemonic RT, I16W
76
77RR category LBT category
78 ASM_MFSPR mnemonic RT, SA ASM_LBT mnemonic brinst, brtarg
79 ASM_MTSPR mnemonic SA, RT
80 ASM_NOOP mnemonic LBTI category
81 ASM_RA mnemonic RA ASM_LBTI mnemonic brinst, RA
82 ASM_RAB mnemonic RA, RB
83 ASM_RDCH mnemonic RT, CA
84 ASM_RR mnemonic RT, RA, RB
85 ASM_RT mnemonic RT
86 ASM_RTA mnemonic RT, RA
87 ASM_WRCH mnemonic CA, RT
88
89Note that RRR instructions have the names for RC and RT reversed from
90what's in the ISA, in order to put RT in the same position it appears
91for other formats.
92
93-=-=-= DEPENDENCY =-=-=-
94
95DEPENDENCY filed consists of 5 digits. This represents which register is used as source and which register is used as target.
96The first(most significant) digit is always 0. Then it is followd by RC, RB, RA and RT digits.
97If the digit is 0, this means the corresponding register is not used in the instruction.
98If the digit is 1, this means the corresponding register is used as a source in the instruction.
99If the digit is 2, this means the corresponding register is used as a target in the instruction.
100If the digit is 3, this means the corresponding register is used as both source and target in the instruction.
101For example, fms instruction has 00113 as the DEPENDENCY field. This means RC is not used in this operation, RB and RA are
102used as sources and RT is the target.
103
104-=-=-= PIPE =-=-=-
105
106This field shows which execution pipe is used for the instruction
107
108pipe0 execution pipelines:
109 FP6 SP floating pipeline
110 FP7 integer operations executed in SP floating pipeline
111 FPD DP floating pipeline
112 FX2 FXU pipeline
113 FX3 Rotate/Shift pipeline
114 FXB Byte pipeline
115 NOP No pipeline
116
117pipe1 execution pipelines:
118 BR Branch pipeline
119 LNOP No pipeline
120 LS Load/Store pipeline
121 SHUF Shuffle pipeline
122 SPR SPR/CH pipeline
123
124*/
125
126#define _A0() {0}
127#define _A1(a) {1,a}
128#define _A2(a,b) {2,a,b}
129#define _A3(a,b,c) {3,a,b,c}
130#define _A4(a,b,c,d) {4,a,b,c,d}
131
132/* TAG FORMAT OPCODE MNEMONIC ASM_FORMAT DEPENDENCY PIPE COMMENT */
133/* 0[RC][RB][RA][RT] */
134/* 1:src, 2:target */
135
136APUOP(M_BR, RI16, 0x190, "br", _A1(A_R18), 00000, BR) /* BRel IP<-IP+I16 */
137APUOP(M_BRSL, RI16, 0x198, "brsl", _A2(A_T,A_R18), 00002, BR) /* BRelSetLink RT,IP<-IP,IP+I16 */
138APUOP(M_BRA, RI16, 0x180, "bra", _A1(A_S18), 00000, BR) /* BRAbs IP<-I16 */
139APUOP(M_BRASL, RI16, 0x188, "brasl", _A2(A_T,A_S18), 00002, BR) /* BRAbsSetLink RT,IP<-IP,I16 */
140APUOP(M_FSMBI, RI16, 0x194, "fsmbi", _A2(A_T,A_X16), 00002, SHUF) /* FormSelMask%I RT<-fsm(I16) */
141APUOP(M_LQA, RI16, 0x184, "lqa", _A2(A_T,A_S18), 00002, LS) /* LoadQAbs RT<-M[I16] */
142APUOP(M_LQR, RI16, 0x19C, "lqr", _A2(A_T,A_R18), 00002, LS) /* LoadQRel RT<-M[IP+I16] */
143APUOP(M_STOP, RR, 0x000, "stop", _A0(), 00000, BR) /* STOP stop */
144APUOP(M_STOP2, RR, 0x000, "stop", _A1(A_U14), 00000, BR) /* STOP stop */
145APUOP(M_STOPD, RR, 0x140, "stopd", _A3(A_T,A_A,A_B), 00111, BR) /* STOPD stop (with register dependencies) */
146APUOP(M_LNOP, RR, 0x001, "lnop", _A0(), 00000, LNOP) /* LNOP no_operation */
147APUOP(M_SYNC, RR, 0x002, "sync", _A0(), 00000, BR) /* SYNC flush_pipe */
148APUOP(M_DSYNC, RR, 0x003, "dsync", _A0(), 00000, BR) /* DSYNC flush_store_queue */
149APUOP(M_MFSPR, RR, 0x00c, "mfspr", _A2(A_T,A_S), 00002, SPR) /* MFSPR RT<-SA */
150APUOP(M_RDCH, RR, 0x00d, "rdch", _A2(A_T,A_H), 00002, SPR) /* ReaDCHannel RT<-CA:data */
151APUOP(M_RCHCNT, RR, 0x00f, "rchcnt", _A2(A_T,A_H), 00002, SPR) /* ReaDCHanCouNT RT<-CA:count */
152APUOP(M_HBRA, LBT, 0x080, "hbra", _A2(A_S11,A_S18), 00000, LS) /* HBRA BTB[B9]<-M[I16] */
153APUOP(M_HBRR, LBT, 0x090, "hbrr", _A2(A_S11,A_R18), 00000, LS) /* HBRR BTB[B9]<-M[IP+I16] */
154APUOP(M_BRZ, RI16, 0x100, "brz", _A2(A_T,A_R18), 00001, BR) /* BRZ IP<-IP+I16_if(RT) */
155APUOP(M_BRNZ, RI16, 0x108, "brnz", _A2(A_T,A_R18), 00001, BR) /* BRNZ IP<-IP+I16_if(RT) */
156APUOP(M_BRHZ, RI16, 0x110, "brhz", _A2(A_T,A_R18), 00001, BR) /* BRHZ IP<-IP+I16_if(RT) */
157APUOP(M_BRHNZ, RI16, 0x118, "brhnz", _A2(A_T,A_R18), 00001, BR) /* BRHNZ IP<-IP+I16_if(RT) */
158APUOP(M_STQA, RI16, 0x104, "stqa", _A2(A_T,A_S18), 00001, LS) /* SToreQAbs M[I16]<-RT */
159APUOP(M_STQR, RI16, 0x11C, "stqr", _A2(A_T,A_R18), 00001, LS) /* SToreQRel M[IP+I16]<-RT */
160APUOP(M_MTSPR, RR, 0x10c, "mtspr", _A2(A_S,A_T), 00001, SPR) /* MTSPR SA<-RT */
161APUOP(M_WRCH, RR, 0x10d, "wrch", _A2(A_H,A_T), 00001, SPR) /* ChanWRite CA<-RT */
162APUOP(M_LQD, RI10, 0x1a0, "lqd", _A4(A_T,A_S14,A_P,A_A), 00012, LS) /* LoadQDisp RT<-M[Ra+I10] */
163APUOP(M_BI, RR, 0x1a8, "bi", _A1(A_A), 00010, BR) /* BI IP<-RA */
164APUOP(M_BISL, RR, 0x1a9, "bisl", _A2(A_T,A_A), 00012, BR) /* BISL RT,IP<-IP,RA */
165APUOP(M_IRET, RR, 0x1aa, "iret", _A1(A_A), 00010, BR) /* IRET IP<-SRR0 */
166APUOP(M_IRET2, RR, 0x1aa, "iret", _A0(), 00010, BR) /* IRET IP<-SRR0 */
167APUOP(M_BISLED, RR, 0x1ab, "bisled", _A2(A_T,A_A), 00012, BR) /* BISLED RT,IP<-IP,RA_if(ext) */
168APUOP(M_HBR, LBTI, 0x1ac, "hbr", _A2(A_S11I,A_A), 00010, LS) /* HBR BTB[B9]<-M[Ra] */
169APUOP(M_FREST, RR, 0x1b8, "frest", _A2(A_T,A_A), 00012, SHUF) /* FREST RT<-recip(RA) */
170APUOP(M_FRSQEST, RR, 0x1b9, "frsqest", _A2(A_T,A_A), 00012, SHUF) /* FRSQEST RT<-rsqrt(RA) */
171APUOP(M_FSM, RR, 0x1b4, "fsm", _A2(A_T,A_A), 00012, SHUF) /* FormSelMask% RT<-expand(Ra) */
172APUOP(M_FSMH, RR, 0x1b5, "fsmh", _A2(A_T,A_A), 00012, SHUF) /* FormSelMask% RT<-expand(Ra) */
173APUOP(M_FSMB, RR, 0x1b6, "fsmb", _A2(A_T,A_A), 00012, SHUF) /* FormSelMask% RT<-expand(Ra) */
174APUOP(M_GB, RR, 0x1b0, "gb", _A2(A_T,A_A), 00012, SHUF) /* GatherBits% RT<-gather(RA) */
175APUOP(M_GBH, RR, 0x1b1, "gbh", _A2(A_T,A_A), 00012, SHUF) /* GatherBits% RT<-gather(RA) */
176APUOP(M_GBB, RR, 0x1b2, "gbb", _A2(A_T,A_A), 00012, SHUF) /* GatherBits% RT<-gather(RA) */
177APUOP(M_CBD, RI7, 0x1f4, "cbd", _A4(A_T,A_U7,A_P,A_A), 00012, SHUF) /* genCtl%%insD RT<-sta(Ra+I4,siz) */
178APUOP(M_CHD, RI7, 0x1f5, "chd", _A4(A_T,A_U7,A_P,A_A), 00012, SHUF) /* genCtl%%insD RT<-sta(Ra+I4,siz) */
179APUOP(M_CWD, RI7, 0x1f6, "cwd", _A4(A_T,A_U7,A_P,A_A), 00012, SHUF) /* genCtl%%insD RT<-sta(Ra+I4,siz) */
180APUOP(M_CDD, RI7, 0x1f7, "cdd", _A4(A_T,A_U7,A_P,A_A), 00012, SHUF) /* genCtl%%insD RT<-sta(Ra+I4,siz) */
181APUOP(M_ROTQBII, RI7, 0x1f8, "rotqbii", _A3(A_T,A_A,A_U3), 00012, SHUF) /* ROTQBII RT<-RA<<<I7 */
182APUOP(M_ROTQBYI, RI7, 0x1fc, "rotqbyi", _A3(A_T,A_A,A_S7N), 00012, SHUF) /* ROTQBYI RT<-RA<<<(I7*8) */
183APUOP(M_ROTQMBII, RI7, 0x1f9, "rotqmbii", _A3(A_T,A_A,A_S3), 00012, SHUF) /* ROTQMBII RT<-RA<<I7 */
184APUOP(M_ROTQMBYI, RI7, 0x1fd, "rotqmbyi", _A3(A_T,A_A,A_S6), 00012, SHUF) /* ROTQMBYI RT<-RA<<I7 */
185APUOP(M_SHLQBII, RI7, 0x1fb, "shlqbii", _A3(A_T,A_A,A_U3), 00012, SHUF) /* SHLQBII RT<-RA<<I7 */
186APUOP(M_SHLQBYI, RI7, 0x1ff, "shlqbyi", _A3(A_T,A_A,A_U5), 00012, SHUF) /* SHLQBYI RT<-RA<<I7 */
187APUOP(M_STQD, RI10, 0x120, "stqd", _A4(A_T,A_S14,A_P,A_A), 00011, LS) /* SToreQDisp M[Ra+I10]<-RT */
188APUOP(M_BIHNZ, RR, 0x12b, "bihnz", _A2(A_T,A_A), 00011, BR) /* BIHNZ IP<-RA_if(RT) */
189APUOP(M_BIHZ, RR, 0x12a, "bihz", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
190APUOP(M_BINZ, RR, 0x129, "binz", _A2(A_T,A_A), 00011, BR) /* BINZ IP<-RA_if(RT) */
191APUOP(M_BIZ, RR, 0x128, "biz", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
192APUOP(M_CBX, RR, 0x1d4, "cbx", _A3(A_T,A_A,A_B), 00112, SHUF) /* genCtl%%insX RT<-sta(Ra+Rb,siz) */
193APUOP(M_CHX, RR, 0x1d5, "chx", _A3(A_T,A_A,A_B), 00112, SHUF) /* genCtl%%insX RT<-sta(Ra+Rb,siz) */
194APUOP(M_CWX, RR, 0x1d6, "cwx", _A3(A_T,A_A,A_B), 00112, SHUF) /* genCtl%%insX RT<-sta(Ra+Rb,siz) */
195APUOP(M_CDX, RR, 0x1d7, "cdx", _A3(A_T,A_A,A_B), 00112, SHUF) /* genCtl%%insX RT<-sta(Ra+Rb,siz) */
196APUOP(M_LQX, RR, 0x1c4, "lqx", _A3(A_T,A_A,A_B), 00112, LS) /* LoadQindeX RT<-M[Ra+Rb] */
197APUOP(M_ROTQBI, RR, 0x1d8, "rotqbi", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQBI RT<-RA<<<Rb */
198APUOP(M_ROTQMBI, RR, 0x1d9, "rotqmbi", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQMBI RT<-RA<<Rb */
199APUOP(M_SHLQBI, RR, 0x1db, "shlqbi", _A3(A_T,A_A,A_B), 00112, SHUF) /* SHLQBI RT<-RA<<Rb */
200APUOP(M_ROTQBY, RR, 0x1dc, "rotqby", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQBY RT<-RA<<<(Rb*8) */
201APUOP(M_ROTQMBY, RR, 0x1dd, "rotqmby", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQMBY RT<-RA<<Rb */
202APUOP(M_SHLQBY, RR, 0x1df, "shlqby", _A3(A_T,A_A,A_B), 00112, SHUF) /* SHLQBY RT<-RA<<Rb */
203APUOP(M_ROTQBYBI, RR, 0x1cc, "rotqbybi", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQBYBI RT<-RA<<Rb */
204APUOP(M_ROTQMBYBI, RR, 0x1cd, "rotqmbybi", _A3(A_T,A_A,A_B), 00112, SHUF) /* ROTQMBYBI RT<-RA<<Rb */
205APUOP(M_SHLQBYBI, RR, 0x1cf, "shlqbybi", _A3(A_T,A_A,A_B), 00112, SHUF) /* SHLQBYBI RT<-RA<<Rb */
206APUOP(M_STQX, RR, 0x144, "stqx", _A3(A_T,A_A,A_B), 00111, LS) /* SToreQindeX M[Ra+Rb]<-RT */
207APUOP(M_SHUFB, RRR, 0x580, "shufb", _A4(A_C,A_A,A_B,A_T), 02111, SHUF) /* SHUFfleBytes RC<-f(RA,RB,RT) */
208APUOP(M_IL, RI16, 0x204, "il", _A2(A_T,A_S16), 00002, FX2) /* ImmLoad RT<-sxt(I16) */
209APUOP(M_ILH, RI16, 0x20c, "ilh", _A2(A_T,A_X16), 00002, FX2) /* ImmLoadH RT<-I16 */
210APUOP(M_ILHU, RI16, 0x208, "ilhu", _A2(A_T,A_X16), 00002, FX2) /* ImmLoadHUpper RT<-I16<<16 */
211APUOP(M_ILA, RI18, 0x210, "ila", _A2(A_T,A_U18), 00002, FX2) /* ImmLoadAddr RT<-zxt(I18) */
212APUOP(M_NOP, RR, 0x201, "nop", _A1(A_T), 00000, NOP) /* XNOP no_operation */
213APUOP(M_NOP2, RR, 0x201, "nop", _A0(), 00000, NOP) /* XNOP no_operation */
214APUOP(M_IOHL, RI16, 0x304, "iohl", _A2(A_T,A_X16), 00003, FX2) /* AddImmeXt RT<-RT+sxt(I16) */
215APUOP(M_ANDBI, RI10, 0x0b0, "andbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* AND%I RT<-RA&I10 */
216APUOP(M_ANDHI, RI10, 0x0a8, "andhi", _A3(A_T,A_A,A_S10), 00012, FX2) /* AND%I RT<-RA&I10 */
217APUOP(M_ANDI, RI10, 0x0a0, "andi", _A3(A_T,A_A,A_S10), 00012, FX2) /* AND%I RT<-RA&I10 */
218APUOP(M_ORBI, RI10, 0x030, "orbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* OR%I RT<-RA|I10 */
219APUOP(M_ORHI, RI10, 0x028, "orhi", _A3(A_T,A_A,A_S10), 00012, FX2) /* OR%I RT<-RA|I10 */
220APUOP(M_ORI, RI10, 0x020, "ori", _A3(A_T,A_A,A_S10), 00012, FX2) /* OR%I RT<-RA|I10 */
221APUOP(M_ORX, RR, 0x1f0, "orx", _A2(A_T,A_A), 00012, BR) /* ORX RT<-RA.w0|RA.w1|RA.w2|RA.w3 */
222APUOP(M_XORBI, RI10, 0x230, "xorbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* XOR%I RT<-RA^I10 */
223APUOP(M_XORHI, RI10, 0x228, "xorhi", _A3(A_T,A_A,A_S10), 00012, FX2) /* XOR%I RT<-RA^I10 */
224APUOP(M_XORI, RI10, 0x220, "xori", _A3(A_T,A_A,A_S10), 00012, FX2) /* XOR%I RT<-RA^I10 */
225APUOP(M_AHI, RI10, 0x0e8, "ahi", _A3(A_T,A_A,A_S10), 00012, FX2) /* Add%Immed RT<-RA+I10 */
226APUOP(M_AI, RI10, 0x0e0, "ai", _A3(A_T,A_A,A_S10), 00012, FX2) /* Add%Immed RT<-RA+I10 */
227APUOP(M_SFHI, RI10, 0x068, "sfhi", _A3(A_T,A_A,A_S10), 00012, FX2) /* SubFrom%Imm RT<-I10-RA */
228APUOP(M_SFI, RI10, 0x060, "sfi", _A3(A_T,A_A,A_S10), 00012, FX2) /* SubFrom%Imm RT<-I10-RA */
229APUOP(M_CGTBI, RI10, 0x270, "cgtbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* CGT%I RT<-(RA>I10) */
230APUOP(M_CGTHI, RI10, 0x268, "cgthi", _A3(A_T,A_A,A_S10), 00012, FX2) /* CGT%I RT<-(RA>I10) */
231APUOP(M_CGTI, RI10, 0x260, "cgti", _A3(A_T,A_A,A_S10), 00012, FX2) /* CGT%I RT<-(RA>I10) */
232APUOP(M_CLGTBI, RI10, 0x2f0, "clgtbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* CLGT%I RT<-(RA>I10) */
233APUOP(M_CLGTHI, RI10, 0x2e8, "clgthi", _A3(A_T,A_A,A_S10), 00012, FX2) /* CLGT%I RT<-(RA>I10) */
234APUOP(M_CLGTI, RI10, 0x2e0, "clgti", _A3(A_T,A_A,A_S10), 00012, FX2) /* CLGT%I RT<-(RA>I10) */
235APUOP(M_CEQBI, RI10, 0x3f0, "ceqbi", _A3(A_T,A_A,A_S10B), 00012, FX2) /* CEQ%I RT<-(RA=I10) */
236APUOP(M_CEQHI, RI10, 0x3e8, "ceqhi", _A3(A_T,A_A,A_S10), 00012, FX2) /* CEQ%I RT<-(RA=I10) */
237APUOP(M_CEQI, RI10, 0x3e0, "ceqi", _A3(A_T,A_A,A_S10), 00012, FX2) /* CEQ%I RT<-(RA=I10) */
238APUOP(M_HGTI, RI10, 0x278, "hgti", _A3(A_T,A_A,A_S10), 00010, FX2) /* HaltGTI halt_if(RA>I10) */
239APUOP(M_HGTI2, RI10, 0x278, "hgti", _A2(A_A,A_S10), 00010, FX2) /* HaltGTI halt_if(RA>I10) */
240APUOP(M_HLGTI, RI10, 0x2f8, "hlgti", _A3(A_T,A_A,A_S10), 00010, FX2) /* HaltLGTI halt_if(RA>I10) */
241APUOP(M_HLGTI2, RI10, 0x2f8, "hlgti", _A2(A_A,A_S10), 00010, FX2) /* HaltLGTI halt_if(RA>I10) */
242APUOP(M_HEQI, RI10, 0x3f8, "heqi", _A3(A_T,A_A,A_S10), 00010, FX2) /* HaltEQImm halt_if(RA=I10) */
243APUOP(M_HEQI2, RI10, 0x3f8, "heqi", _A2(A_A,A_S10), 00010, FX2) /* HaltEQImm halt_if(RA=I10) */
244APUOP(M_MPYI, RI10, 0x3a0, "mpyi", _A3(A_T,A_A,A_S10), 00012, FP7) /* MPYI RT<-RA*I10 */
245APUOP(M_MPYUI, RI10, 0x3a8, "mpyui", _A3(A_T,A_A,A_S10), 00012, FP7) /* MPYUI RT<-RA*I10 */
246APUOP(M_CFLTS, RI8, 0x3b0, "cflts", _A3(A_T,A_A,A_U7A), 00012, FP7) /* CFLTS RT<-int(RA,I8) */
247APUOP(M_CFLTU, RI8, 0x3b2, "cfltu", _A3(A_T,A_A,A_U7A), 00012, FP7) /* CFLTU RT<-int(RA,I8) */
248APUOP(M_CSFLT, RI8, 0x3b4, "csflt", _A3(A_T,A_A,A_U7B), 00012, FP7) /* CSFLT RT<-flt(RA,I8) */
249APUOP(M_CUFLT, RI8, 0x3b6, "cuflt", _A3(A_T,A_A,A_U7B), 00012, FP7) /* CUFLT RT<-flt(RA,I8) */
250APUOP(M_FESD, RR, 0x3b8, "fesd", _A2(A_T,A_A), 00012, FPD) /* FESD RT<-double(RA) */
251APUOP(M_FRDS, RR, 0x3b9, "frds", _A2(A_T,A_A), 00012, FPD) /* FRDS RT<-single(RA) */
252APUOP(M_FSCRRD, RR, 0x398, "fscrrd", _A1(A_T), 00002, FPD) /* FSCRRD RT<-FP_status */
253APUOP(M_FSCRWR, RR, 0x3ba, "fscrwr", _A2(A_T,A_A), 00010, FP7) /* FSCRWR FP_status<-RA */
254APUOP(M_FSCRWR2, RR, 0x3ba, "fscrwr", _A1(A_A), 00010, FP7) /* FSCRWR FP_status<-RA */
255APUOP(M_CLZ, RR, 0x2a5, "clz", _A2(A_T,A_A), 00012, FX2) /* CLZ RT<-clz(RA) */
256APUOP(M_CNTB, RR, 0x2b4, "cntb", _A2(A_T,A_A), 00012, FXB) /* CNT RT<-pop(RA) */
257APUOP(M_XSBH, RR, 0x2b6, "xsbh", _A2(A_T,A_A), 00012, FX2) /* eXtSignBtoH RT<-sign_ext(RA) */
258APUOP(M_XSHW, RR, 0x2ae, "xshw", _A2(A_T,A_A), 00012, FX2) /* eXtSignHtoW RT<-sign_ext(RA) */
259APUOP(M_XSWD, RR, 0x2a6, "xswd", _A2(A_T,A_A), 00012, FX2) /* eXtSignWtoD RT<-sign_ext(RA) */
260APUOP(M_ROTI, RI7, 0x078, "roti", _A3(A_T,A_A,A_S7N), 00012, FX3) /* ROT%I RT<-RA<<<I7 */
261APUOP(M_ROTMI, RI7, 0x079, "rotmi", _A3(A_T,A_A,A_S7), 00012, FX3) /* ROT%MI RT<-RA<<I7 */
262APUOP(M_ROTMAI, RI7, 0x07a, "rotmai", _A3(A_T,A_A,A_S7), 00012, FX3) /* ROTMA%I RT<-RA<<I7 */
263APUOP(M_SHLI, RI7, 0x07b, "shli", _A3(A_T,A_A,A_U6), 00012, FX3) /* SHL%I RT<-RA<<I7 */
264APUOP(M_ROTHI, RI7, 0x07c, "rothi", _A3(A_T,A_A,A_S7N), 00012, FX3) /* ROT%I RT<-RA<<<I7 */
265APUOP(M_ROTHMI, RI7, 0x07d, "rothmi", _A3(A_T,A_A,A_S6), 00012, FX3) /* ROT%MI RT<-RA<<I7 */
266APUOP(M_ROTMAHI, RI7, 0x07e, "rotmahi", _A3(A_T,A_A,A_S6), 00012, FX3) /* ROTMA%I RT<-RA<<I7 */
267APUOP(M_SHLHI, RI7, 0x07f, "shlhi", _A3(A_T,A_A,A_U5), 00012, FX3) /* SHL%I RT<-RA<<I7 */
268APUOP(M_A, RR, 0x0c0, "a", _A3(A_T,A_A,A_B), 00112, FX2) /* Add% RT<-RA+RB */
269APUOP(M_AH, RR, 0x0c8, "ah", _A3(A_T,A_A,A_B), 00112, FX2) /* Add% RT<-RA+RB */
270APUOP(M_SF, RR, 0x040, "sf", _A3(A_T,A_A,A_B), 00112, FX2) /* SubFrom% RT<-RB-RA */
271APUOP(M_SFH, RR, 0x048, "sfh", _A3(A_T,A_A,A_B), 00112, FX2) /* SubFrom% RT<-RB-RA */
272APUOP(M_CGT, RR, 0x240, "cgt", _A3(A_T,A_A,A_B), 00112, FX2) /* CGT% RT<-(RA>RB) */
273APUOP(M_CGTB, RR, 0x250, "cgtb", _A3(A_T,A_A,A_B), 00112, FX2) /* CGT% RT<-(RA>RB) */
274APUOP(M_CGTH, RR, 0x248, "cgth", _A3(A_T,A_A,A_B), 00112, FX2) /* CGT% RT<-(RA>RB) */
275APUOP(M_CLGT, RR, 0x2c0, "clgt", _A3(A_T,A_A,A_B), 00112, FX2) /* CLGT% RT<-(RA>RB) */
276APUOP(M_CLGTB, RR, 0x2d0, "clgtb", _A3(A_T,A_A,A_B), 00112, FX2) /* CLGT% RT<-(RA>RB) */
277APUOP(M_CLGTH, RR, 0x2c8, "clgth", _A3(A_T,A_A,A_B), 00112, FX2) /* CLGT% RT<-(RA>RB) */
278APUOP(M_CEQ, RR, 0x3c0, "ceq", _A3(A_T,A_A,A_B), 00112, FX2) /* CEQ% RT<-(RA=RB) */
279APUOP(M_CEQB, RR, 0x3d0, "ceqb", _A3(A_T,A_A,A_B), 00112, FX2) /* CEQ% RT<-(RA=RB) */
280APUOP(M_CEQH, RR, 0x3c8, "ceqh", _A3(A_T,A_A,A_B), 00112, FX2) /* CEQ% RT<-(RA=RB) */
281APUOP(M_HGT, RR, 0x258, "hgt", _A3(A_T,A_A,A_B), 00110, FX2) /* HaltGT halt_if(RA>RB) */
282APUOP(M_HGT2, RR, 0x258, "hgt", _A2(A_A,A_B), 00110, FX2) /* HaltGT halt_if(RA>RB) */
283APUOP(M_HLGT, RR, 0x2d8, "hlgt", _A3(A_T,A_A,A_B), 00110, FX2) /* HaltLGT halt_if(RA>RB) */
284APUOP(M_HLGT2, RR, 0x2d8, "hlgt", _A2(A_A,A_B), 00110, FX2) /* HaltLGT halt_if(RA>RB) */
285APUOP(M_HEQ, RR, 0x3d8, "heq", _A3(A_T,A_A,A_B), 00110, FX2) /* HaltEQ halt_if(RA=RB) */
286APUOP(M_HEQ2, RR, 0x3d8, "heq", _A2(A_A,A_B), 00110, FX2) /* HaltEQ halt_if(RA=RB) */
287APUOP(M_FCEQ, RR, 0x3c2, "fceq", _A3(A_T,A_A,A_B), 00112, FX2) /* FCEQ RT<-(RA=RB) */
288APUOP(M_FCMEQ, RR, 0x3ca, "fcmeq", _A3(A_T,A_A,A_B), 00112, FX2) /* FCMEQ RT<-(|RA|=|RB|) */
289APUOP(M_FCGT, RR, 0x2c2, "fcgt", _A3(A_T,A_A,A_B), 00112, FX2) /* FCGT RT<-(RA<RB) */
290APUOP(M_FCMGT, RR, 0x2ca, "fcmgt", _A3(A_T,A_A,A_B), 00112, FX2) /* FCMGT RT<-(|RA|<|RB|) */
291APUOP(M_AND, RR, 0x0c1, "and", _A3(A_T,A_A,A_B), 00112, FX2) /* AND RT<-RA&RB */
292APUOP(M_NAND, RR, 0x0c9, "nand", _A3(A_T,A_A,A_B), 00112, FX2) /* NAND RT<-!(RA&RB) */
293APUOP(M_OR, RR, 0x041, "or", _A3(A_T,A_A,A_B), 00112, FX2) /* OR RT<-RA|RB */
294APUOP(M_NOR, RR, 0x049, "nor", _A3(A_T,A_A,A_B), 00112, FX2) /* NOR RT<-!(RA&RB) */
295APUOP(M_XOR, RR, 0x241, "xor", _A3(A_T,A_A,A_B), 00112, FX2) /* XOR RT<-RA^RB */
296APUOP(M_EQV, RR, 0x249, "eqv", _A3(A_T,A_A,A_B), 00112, FX2) /* EQuiValent RT<-!(RA^RB) */
297APUOP(M_ANDC, RR, 0x2c1, "andc", _A3(A_T,A_A,A_B), 00112, FX2) /* ANDComplement RT<-RA&!RB */
298APUOP(M_ORC, RR, 0x2c9, "orc", _A3(A_T,A_A,A_B), 00112, FX2) /* ORComplement RT<-RA|!RB */
299APUOP(M_ABSDB, RR, 0x053, "absdb", _A3(A_T,A_A,A_B), 00112, FXB) /* ABSoluteDiff RT<-|RA-RB| */
300APUOP(M_AVGB, RR, 0x0d3, "avgb", _A3(A_T,A_A,A_B), 00112, FXB) /* AVG% RT<-(RA+RB+1)/2 */
301APUOP(M_SUMB, RR, 0x253, "sumb", _A3(A_T,A_A,A_B), 00112, FXB) /* SUM% RT<-f(RA,RB) */
302APUOP(M_DFA, RR, 0x2cc, "dfa", _A3(A_T,A_A,A_B), 00112, FPD) /* DFAdd RT<-RA+RB */
303APUOP(M_DFM, RR, 0x2ce, "dfm", _A3(A_T,A_A,A_B), 00112, FPD) /* DFMul RT<-RA*RB */
304APUOP(M_DFS, RR, 0x2cd, "dfs", _A3(A_T,A_A,A_B), 00112, FPD) /* DFSub RT<-RA-RB */
305APUOP(M_FA, RR, 0x2c4, "fa", _A3(A_T,A_A,A_B), 00112, FP6) /* FAdd RT<-RA+RB */
306APUOP(M_FM, RR, 0x2c6, "fm", _A3(A_T,A_A,A_B), 00112, FP6) /* FMul RT<-RA*RB */
307APUOP(M_FS, RR, 0x2c5, "fs", _A3(A_T,A_A,A_B), 00112, FP6) /* FSub RT<-RA-RB */
308APUOP(M_MPY, RR, 0x3c4, "mpy", _A3(A_T,A_A,A_B), 00112, FP7) /* MPY RT<-RA*RB */
309APUOP(M_MPYH, RR, 0x3c5, "mpyh", _A3(A_T,A_A,A_B), 00112, FP7) /* MPYH RT<-(RAh*RB)<<16 */
310APUOP(M_MPYHH, RR, 0x3c6, "mpyhh", _A3(A_T,A_A,A_B), 00112, FP7) /* MPYHH RT<-RAh*RBh */
311APUOP(M_MPYHHU, RR, 0x3ce, "mpyhhu", _A3(A_T,A_A,A_B), 00112, FP7) /* MPYHHU RT<-RAh*RBh */
312APUOP(M_MPYS, RR, 0x3c7, "mpys", _A3(A_T,A_A,A_B), 00112, FP7) /* MPYS RT<-(RA*RB)>>16 */
313APUOP(M_MPYU, RR, 0x3cc, "mpyu", _A3(A_T,A_A,A_B), 00112, FP7) /* MPYU RT<-RA*RB */
314APUOP(M_FI, RR, 0x3d4, "fi", _A3(A_T,A_A,A_B), 00112, FP7) /* FInterpolate RT<-f(RA,RB) */
315APUOP(M_ROT, RR, 0x058, "rot", _A3(A_T,A_A,A_B), 00112, FX3) /* ROT% RT<-RA<<<RB */
316APUOP(M_ROTM, RR, 0x059, "rotm", _A3(A_T,A_A,A_B), 00112, FX3) /* ROT%M RT<-RA<<Rb */
317APUOP(M_ROTMA, RR, 0x05a, "rotma", _A3(A_T,A_A,A_B), 00112, FX3) /* ROTMA% RT<-RA<<Rb */
318APUOP(M_SHL, RR, 0x05b, "shl", _A3(A_T,A_A,A_B), 00112, FX3) /* SHL% RT<-RA<<Rb */
319APUOP(M_ROTH, RR, 0x05c, "roth", _A3(A_T,A_A,A_B), 00112, FX3) /* ROT% RT<-RA<<<RB */
320APUOP(M_ROTHM, RR, 0x05d, "rothm", _A3(A_T,A_A,A_B), 00112, FX3) /* ROT%M RT<-RA<<Rb */
321APUOP(M_ROTMAH, RR, 0x05e, "rotmah", _A3(A_T,A_A,A_B), 00112, FX3) /* ROTMA% RT<-RA<<Rb */
322APUOP(M_SHLH, RR, 0x05f, "shlh", _A3(A_T,A_A,A_B), 00112, FX3) /* SHL% RT<-RA<<Rb */
323APUOP(M_MPYHHA, RR, 0x346, "mpyhha", _A3(A_T,A_A,A_B), 00113, FP7) /* MPYHHA RT<-RAh*RBh+RT */
324APUOP(M_MPYHHAU, RR, 0x34e, "mpyhhau", _A3(A_T,A_A,A_B), 00113, FP7) /* MPYHHAU RT<-RAh*RBh+RT */
325APUOP(M_DFMA, RR, 0x35c, "dfma", _A3(A_T,A_A,A_B), 00113, FPD) /* DFMAdd RT<-RT+RA*RB */
326APUOP(M_DFMS, RR, 0x35d, "dfms", _A3(A_T,A_A,A_B), 00113, FPD) /* DFMSub RT<-RA*RB-RT */
327APUOP(M_DFNMS, RR, 0x35e, "dfnms", _A3(A_T,A_A,A_B), 00113, FPD) /* DFNMSub RT<-RT-RA*RB */
328APUOP(M_DFNMA, RR, 0x35f, "dfnma", _A3(A_T,A_A,A_B), 00113, FPD) /* DFNMAdd RT<-(-RT)-RA*RB */
329APUOP(M_FMA, RRR, 0x700, "fma", _A4(A_C,A_A,A_B,A_T), 02111, FP6) /* FMAdd RC<-RT+RA*RB */
330APUOP(M_FMS, RRR, 0x780, "fms", _A4(A_C,A_A,A_B,A_T), 02111, FP6) /* FMSub RC<-RA*RB-RT */
331APUOP(M_FNMS, RRR, 0x680, "fnms", _A4(A_C,A_A,A_B,A_T), 02111, FP6) /* FNMSub RC<-RT-RA*RB */
332APUOP(M_MPYA, RRR, 0x600, "mpya", _A4(A_C,A_A,A_B,A_T), 02111, FP7) /* MPYA RC<-RA*RB+RT */
333APUOP(M_SELB, RRR, 0x400, "selb", _A4(A_C,A_A,A_B,A_T), 02111, FX2) /* SELectBits RC<-RA&RT|RB&!RT */
334/* for system function call, this uses op-code of mtspr */
335APUOP(M_SYSCALL, RI7, 0x10c, "syscall", _A3(A_T,A_A,A_S7N), 00002, SPR) /* System Call */
336/*
337pseudo instruction:
338system call
339value of I9 operation
3400 halt
3411 rt[0] = open(MEM[ra[0]], ra[1])
3422 rt[0] = close(ra[0])
3433 rt[0] = read(ra[0], MEM[ra[1]], ra[2])
3444 rt[0] = write(ra[0], MEM[ra[1]], ra[2])
3455 printf(MEM[ra[0]], ra[1], ra[2], ra[3])
34642 rt[0] = clock()
34752 rt[0] = lseek(ra0, ra1, ra2)
348
349*/
350
351
352/* new multiprecision add/sub */
353APUOP(M_ADDX, RR, 0x340, "addx", _A3(A_T,A_A,A_B), 00113, FX2) /* Add_eXtended RT<-RA+RB+RT */
354APUOP(M_CG, RR, 0x0c2, "cg", _A3(A_T,A_A,A_B), 00112, FX2) /* CarryGenerate RT<-cout(RA+RB) */
355APUOP(M_CGX, RR, 0x342, "cgx", _A3(A_T,A_A,A_B), 00113, FX2) /* CarryGen_eXtd RT<-cout(RA+RB+RT) */
356APUOP(M_SFX, RR, 0x341, "sfx", _A3(A_T,A_A,A_B), 00113, FX2) /* Add_eXtended RT<-RA+RB+RT */
357APUOP(M_BG, RR, 0x042, "bg", _A3(A_T,A_A,A_B), 00112, FX2) /* CarryGenerate RT<-cout(RA+RB) */
358APUOP(M_BGX, RR, 0x343, "bgx", _A3(A_T,A_A,A_B), 00113, FX2) /* CarryGen_eXtd RT<-cout(RA+RB+RT) */
359
360/*
361
362The following ops are a subset of above except with feature bits set.
363Feature bits are bits 11-17 of the instruction:
364
365 11 - C & P feature bit
366 12 - disable interrupts
367 13 - enable interrupts
368
369*/
370APUOPFB(M_BID, RR, 0x1a8, 0x20, "bid", _A1(A_A), 00010, BR) /* BI IP<-RA */
371APUOPFB(M_BIE, RR, 0x1a8, 0x10, "bie", _A1(A_A), 00010, BR) /* BI IP<-RA */
372APUOPFB(M_BISLD, RR, 0x1a9, 0x20, "bisld", _A2(A_T,A_A), 00012, BR) /* BISL RT,IP<-IP,RA */
373APUOPFB(M_BISLE, RR, 0x1a9, 0x10, "bisle", _A2(A_T,A_A), 00012, BR) /* BISL RT,IP<-IP,RA */
374APUOPFB(M_IRETD, RR, 0x1aa, 0x20, "iretd", _A1(A_A), 00010, BR) /* IRET IP<-SRR0 */
375APUOPFB(M_IRETD2, RR, 0x1aa, 0x20, "iretd", _A0(), 00010, BR) /* IRET IP<-SRR0 */
376APUOPFB(M_IRETE, RR, 0x1aa, 0x10, "irete", _A1(A_A), 00010, BR) /* IRET IP<-SRR0 */
377APUOPFB(M_IRETE2, RR, 0x1aa, 0x10, "irete", _A0(), 00010, BR) /* IRET IP<-SRR0 */
378APUOPFB(M_BISLEDD, RR, 0x1ab, 0x20, "bisledd", _A2(A_T,A_A), 00012, BR) /* BISLED RT,IP<-IP,RA_if(ext) */
379APUOPFB(M_BISLEDE, RR, 0x1ab, 0x10, "bislede", _A2(A_T,A_A), 00012, BR) /* BISLED RT,IP<-IP,RA_if(ext) */
380APUOPFB(M_BIHNZD, RR, 0x12b, 0x20, "bihnzd", _A2(A_T,A_A), 00011, BR) /* BIHNZ IP<-RA_if(RT) */
381APUOPFB(M_BIHNZE, RR, 0x12b, 0x10, "bihnze", _A2(A_T,A_A), 00011, BR) /* BIHNZ IP<-RA_if(RT) */
382APUOPFB(M_BIHZD, RR, 0x12a, 0x20, "bihzd", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
383APUOPFB(M_BIHZE, RR, 0x12a, 0x10, "bihze", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
384APUOPFB(M_BINZD, RR, 0x129, 0x20, "binzd", _A2(A_T,A_A), 00011, BR) /* BINZ IP<-RA_if(RT) */
385APUOPFB(M_BINZE, RR, 0x129, 0x10, "binze", _A2(A_T,A_A), 00011, BR) /* BINZ IP<-RA_if(RT) */
386APUOPFB(M_BIZD, RR, 0x128, 0x20, "bizd", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
387APUOPFB(M_BIZE, RR, 0x128, 0x10, "bize", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
388APUOPFB(M_SYNCC, RR, 0x002, 0x40, "syncc", _A0(), 00000, BR) /* SYNCC flush_pipe */
389APUOPFB(M_HBRP, LBTI, 0x1ac, 0x40, "hbrp", _A0(), 00010, LS) /* HBR BTB[B9]<-M[Ra] */
390
391/* Synonyms required by the AS manual. */
392APUOP(M_LR, RI10, 0x020, "lr", _A2(A_T,A_A), 00012, FX2) /* OR%I RT<-RA|I10 */
393APUOP(M_BIHT, RR, 0x12b, "biht", _A2(A_T,A_A), 00011, BR) /* BIHNZ IP<-RA_if(RT) */
394APUOP(M_BIHF, RR, 0x12a, "bihf", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
395APUOP(M_BIT, RR, 0x129, "bit", _A2(A_T,A_A), 00011, BR) /* BINZ IP<-RA_if(RT) */
396APUOP(M_BIF, RR, 0x128, "bif", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
397APUOPFB(M_BIHTD, RR, 0x12b, 0x20, "bihtd", _A2(A_T,A_A), 00011, BR) /* BIHNF IP<-RA_if(RT) */
398APUOPFB(M_BIHTE, RR, 0x12b, 0x10, "bihte", _A2(A_T,A_A), 00011, BR) /* BIHNF IP<-RA_if(RT) */
399APUOPFB(M_BIHFD, RR, 0x12a, 0x20, "bihfd", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
400APUOPFB(M_BIHFE, RR, 0x12a, 0x10, "bihfe", _A2(A_T,A_A), 00011, BR) /* BIHZ IP<-RA_if(RT) */
401APUOPFB(M_BITD, RR, 0x129, 0x20, "bitd", _A2(A_T,A_A), 00011, BR) /* BINF IP<-RA_if(RT) */
402APUOPFB(M_BITE, RR, 0x129, 0x10, "bite", _A2(A_T,A_A), 00011, BR) /* BINF IP<-RA_if(RT) */
403APUOPFB(M_BIFD, RR, 0x128, 0x20, "bifd", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
404APUOPFB(M_BIFE, RR, 0x128, 0x10, "bife", _A2(A_T,A_A), 00011, BR) /* BIZ IP<-RA_if(RT) */
405
406#undef _A0
407#undef _A1
408#undef _A2
409#undef _A3
410#undef _A4
diff --git a/arch/powerpc/xmon/spu-opc.c b/arch/powerpc/xmon/spu-opc.c
new file mode 100644
index 000000000000..efffde9edc6e
--- /dev/null
+++ b/arch/powerpc/xmon/spu-opc.c
@@ -0,0 +1,44 @@
1/* SPU opcode list
2
3 Copyright 2006 Free Software Foundation, Inc.
4
5 This file is part of GDB, GAS, and the GNU binutils.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21#include "spu.h"
22
23/* This file holds the Spu opcode table */
24
25
26/*
27 Example contents of spu-insn.h
28 id_tag mode mode type opcode mnemonic asmtype dependency FPU L/S? branch? instruction
29 QUAD WORD (0,RC,RB,RA,RT) latency
30 APUOP(M_LQD, 1, 0, RI9, 0x1f8, "lqd", ASM_RI9IDX, 00012, FXU, 1, 0) Load Quadword d-form
31 */
32
33const struct spu_opcode spu_opcodes[] = {
34#define APUOP(TAG,MACFORMAT,OPCODE,MNEMONIC,ASMFORMAT,DEP,PIPE) \
35 { MACFORMAT, OPCODE, MNEMONIC, ASMFORMAT },
36#define APUOPFB(TAG,MACFORMAT,OPCODE,FB,MNEMONIC,ASMFORMAT,DEP,PIPE) \
37 { MACFORMAT, OPCODE, MNEMONIC, ASMFORMAT },
38#include "spu-insns.h"
39#undef APUOP
40#undef APUOPFB
41};
42
43const int spu_num_opcodes =
44 sizeof (spu_opcodes) / sizeof (spu_opcodes[0]);
diff --git a/arch/powerpc/xmon/spu.h b/arch/powerpc/xmon/spu.h
new file mode 100644
index 000000000000..c761fc8f35d8
--- /dev/null
+++ b/arch/powerpc/xmon/spu.h
@@ -0,0 +1,126 @@
1/* SPU ELF support for BFD.
2
3 Copyright 2006 Free Software Foundation, Inc.
4
5 This file is part of GDB, GAS, and the GNU binutils.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20
21
22/* These two enums are from rel_apu/common/spu_asm_format.h */
23/* definition of instruction format */
24typedef enum {
25 RRR,
26 RI18,
27 RI16,
28 RI10,
29 RI8,
30 RI7,
31 RR,
32 LBT,
33 LBTI,
34 IDATA,
35 UNKNOWN_IFORMAT
36} spu_iformat;
37
38/* These values describe assembly instruction arguments. They indicate
39 * how to encode, range checking and which relocation to use. */
40typedef enum {
41 A_T, /* register at pos 0 */
42 A_A, /* register at pos 7 */
43 A_B, /* register at pos 14 */
44 A_C, /* register at pos 21 */
45 A_S, /* special purpose register at pos 7 */
46 A_H, /* channel register at pos 7 */
47 A_P, /* parenthesis, this has to separate regs from immediates */
48 A_S3,
49 A_S6,
50 A_S7N,
51 A_S7,
52 A_U7A,
53 A_U7B,
54 A_S10B,
55 A_S10,
56 A_S11,
57 A_S11I,
58 A_S14,
59 A_S16,
60 A_S18,
61 A_R18,
62 A_U3,
63 A_U5,
64 A_U6,
65 A_U7,
66 A_U14,
67 A_X16,
68 A_U18,
69 A_MAX
70} spu_aformat;
71
72enum spu_insns {
73#define APUOP(TAG,MACFORMAT,OPCODE,MNEMONIC,ASMFORMAT,DEP,PIPE) \
74 TAG,
75#define APUOPFB(TAG,MACFORMAT,OPCODE,FB,MNEMONIC,ASMFORMAT,DEP,PIPE) \
76 TAG,
77#include "spu-insns.h"
78#undef APUOP
79#undef APUOPFB
80 M_SPU_MAX
81};
82
83struct spu_opcode
84{
85 spu_iformat insn_type;
86 unsigned int opcode;
87 char *mnemonic;
88 int arg[5];
89};
90
91#define SIGNED_EXTRACT(insn,size,pos) (((int)((insn) << (32-size-pos))) >> (32-size))
92#define UNSIGNED_EXTRACT(insn,size,pos) (((insn) >> pos) & ((1 << size)-1))
93
94#define DECODE_INSN_RT(insn) (insn & 0x7f)
95#define DECODE_INSN_RA(insn) ((insn >> 7) & 0x7f)
96#define DECODE_INSN_RB(insn) ((insn >> 14) & 0x7f)
97#define DECODE_INSN_RC(insn) ((insn >> 21) & 0x7f)
98
99#define DECODE_INSN_I10(insn) SIGNED_EXTRACT(insn,10,14)
100#define DECODE_INSN_U10(insn) UNSIGNED_EXTRACT(insn,10,14)
101
102/* For branching, immediate loads, hbr and lqa/stqa. */
103#define DECODE_INSN_I16(insn) SIGNED_EXTRACT(insn,16,7)
104#define DECODE_INSN_U16(insn) UNSIGNED_EXTRACT(insn,16,7)
105
106/* for stop */
107#define DECODE_INSN_U14(insn) UNSIGNED_EXTRACT(insn,14,0)
108
109/* For ila */
110#define DECODE_INSN_I18(insn) SIGNED_EXTRACT(insn,18,7)
111#define DECODE_INSN_U18(insn) UNSIGNED_EXTRACT(insn,18,7)
112
113/* For rotate and shift and generate control mask */
114#define DECODE_INSN_I7(insn) SIGNED_EXTRACT(insn,7,14)
115#define DECODE_INSN_U7(insn) UNSIGNED_EXTRACT(insn,7,14)
116
117/* For float <-> int conversion */
118#define DECODE_INSN_I8(insn) SIGNED_EXTRACT(insn,8,14)
119#define DECODE_INSN_U8(insn) UNSIGNED_EXTRACT(insn,8,14)
120
121/* For hbr */
122#define DECODE_INSN_I9a(insn) ((SIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
123#define DECODE_INSN_I9b(insn) ((SIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))
124#define DECODE_INSN_U9a(insn) ((UNSIGNED_EXTRACT(insn,2,23) << 7) | UNSIGNED_EXTRACT(insn,7,0))
125#define DECODE_INSN_U9b(insn) ((UNSIGNED_EXTRACT(insn,2,14) << 7) | UNSIGNED_EXTRACT(insn,7,0))
126
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index f56ffef4defa..a34ed49e0356 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -37,13 +37,18 @@
37#include <asm/sstep.h> 37#include <asm/sstep.h>
38#include <asm/bug.h> 38#include <asm/bug.h>
39#include <asm/irq_regs.h> 39#include <asm/irq_regs.h>
40#include <asm/spu.h>
41#include <asm/spu_priv1.h>
42#include <asm/firmware.h>
40 43
41#ifdef CONFIG_PPC64 44#ifdef CONFIG_PPC64
42#include <asm/hvcall.h> 45#include <asm/hvcall.h>
43#include <asm/paca.h> 46#include <asm/paca.h>
47#include <asm/iseries/it_lp_reg_save.h>
44#endif 48#endif
45 49
46#include "nonstdio.h" 50#include "nonstdio.h"
51#include "dis-asm.h"
47 52
48#define scanhex xmon_scanhex 53#define scanhex xmon_scanhex
49#define skipbl xmon_skipbl 54#define skipbl xmon_skipbl
@@ -107,7 +112,6 @@ static int bsesc(void);
107static void dump(void); 112static void dump(void);
108static void prdump(unsigned long, long); 113static void prdump(unsigned long, long);
109static int ppc_inst_dump(unsigned long, long, int); 114static int ppc_inst_dump(unsigned long, long, int);
110void print_address(unsigned long);
111static void backtrace(struct pt_regs *); 115static void backtrace(struct pt_regs *);
112static void excprint(struct pt_regs *); 116static void excprint(struct pt_regs *);
113static void prregs(struct pt_regs *); 117static void prregs(struct pt_regs *);
@@ -147,9 +151,9 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
147 const char *after); 151 const char *after);
148static const char *getvecname(unsigned long vec); 152static const char *getvecname(unsigned long vec);
149 153
150int xmon_no_auto_backtrace; 154static int do_spu_cmd(void);
151 155
152extern int print_insn_powerpc(unsigned long, unsigned long, int); 156int xmon_no_auto_backtrace;
153 157
154extern void xmon_enter(void); 158extern void xmon_enter(void);
155extern void xmon_leave(void); 159extern void xmon_leave(void);
@@ -209,8 +213,15 @@ Commands:\n\
209 mi show information about memory allocation\n\ 213 mi show information about memory allocation\n\
210 p call a procedure\n\ 214 p call a procedure\n\
211 r print registers\n\ 215 r print registers\n\
212 s single step\n\ 216 s single step\n"
213 S print special registers\n\ 217#ifdef CONFIG_SPU_BASE
218" ss stop execution on all spus\n\
219 sr restore execution on stopped spus\n\
220 sf # dump spu fields for spu # (in hex)\n\
221 sd # dump spu local store for spu # (in hex)\
222 sdi # disassemble spu local store for spu # (in hex)\n"
223#endif
224" S print special registers\n\
214 t print backtrace\n\ 225 t print backtrace\n\
215 x exit monitor and recover\n\ 226 x exit monitor and recover\n\
216 X exit monitor and dont recover\n" 227 X exit monitor and dont recover\n"
@@ -518,6 +529,7 @@ int xmon(struct pt_regs *excp)
518 xmon_save_regs(&regs); 529 xmon_save_regs(&regs);
519 excp = &regs; 530 excp = &regs;
520 } 531 }
532
521 return xmon_core(excp, 0); 533 return xmon_core(excp, 0);
522} 534}
523EXPORT_SYMBOL(xmon); 535EXPORT_SYMBOL(xmon);
@@ -809,6 +821,8 @@ cmds(struct pt_regs *excp)
809 cacheflush(); 821 cacheflush();
810 break; 822 break;
811 case 's': 823 case 's':
824 if (do_spu_cmd() == 0)
825 break;
812 if (do_step(excp)) 826 if (do_step(excp))
813 return cmd; 827 return cmd;
814 break; 828 break;
@@ -1555,11 +1569,6 @@ void super_regs(void)
1555{ 1569{
1556 int cmd; 1570 int cmd;
1557 unsigned long val; 1571 unsigned long val;
1558#ifdef CONFIG_PPC_ISERIES
1559 struct paca_struct *ptrPaca = NULL;
1560 struct lppaca *ptrLpPaca = NULL;
1561 struct ItLpRegSave *ptrLpRegSave = NULL;
1562#endif
1563 1572
1564 cmd = skipbl(); 1573 cmd = skipbl();
1565 if (cmd == '\n') { 1574 if (cmd == '\n') {
@@ -1576,26 +1585,32 @@ void super_regs(void)
1576 printf("sp = "REG" sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3)); 1585 printf("sp = "REG" sprg3= "REG"\n", sp, mfspr(SPRN_SPRG3));
1577 printf("toc = "REG" dar = "REG"\n", toc, mfspr(SPRN_DAR)); 1586 printf("toc = "REG" dar = "REG"\n", toc, mfspr(SPRN_DAR));
1578#ifdef CONFIG_PPC_ISERIES 1587#ifdef CONFIG_PPC_ISERIES
1579 // Dump out relevant Paca data areas. 1588 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
1580 printf("Paca: \n"); 1589 struct paca_struct *ptrPaca;
1581 ptrPaca = get_paca(); 1590 struct lppaca *ptrLpPaca;
1582 1591 struct ItLpRegSave *ptrLpRegSave;
1583 printf(" Local Processor Control Area (LpPaca): \n"); 1592
1584 ptrLpPaca = ptrPaca->lppaca_ptr; 1593 /* Dump out relevant Paca data areas. */
1585 printf(" Saved Srr0=%.16lx Saved Srr1=%.16lx \n", 1594 printf("Paca: \n");
1586 ptrLpPaca->saved_srr0, ptrLpPaca->saved_srr1); 1595 ptrPaca = get_paca();
1587 printf(" Saved Gpr3=%.16lx Saved Gpr4=%.16lx \n", 1596
1588 ptrLpPaca->saved_gpr3, ptrLpPaca->saved_gpr4); 1597 printf(" Local Processor Control Area (LpPaca): \n");
1589 printf(" Saved Gpr5=%.16lx \n", ptrLpPaca->saved_gpr5); 1598 ptrLpPaca = ptrPaca->lppaca_ptr;
1590 1599 printf(" Saved Srr0=%.16lx Saved Srr1=%.16lx \n",
1591 printf(" Local Processor Register Save Area (LpRegSave): \n"); 1600 ptrLpPaca->saved_srr0, ptrLpPaca->saved_srr1);
1592 ptrLpRegSave = ptrPaca->reg_save_ptr; 1601 printf(" Saved Gpr3=%.16lx Saved Gpr4=%.16lx \n",
1593 printf(" Saved Sprg0=%.16lx Saved Sprg1=%.16lx \n", 1602 ptrLpPaca->saved_gpr3, ptrLpPaca->saved_gpr4);
1594 ptrLpRegSave->xSPRG0, ptrLpRegSave->xSPRG0); 1603 printf(" Saved Gpr5=%.16lx \n", ptrLpPaca->saved_gpr5);
1595 printf(" Saved Sprg2=%.16lx Saved Sprg3=%.16lx \n", 1604
1596 ptrLpRegSave->xSPRG2, ptrLpRegSave->xSPRG3); 1605 printf(" Local Processor Register Save Area (LpRegSave): \n");
1597 printf(" Saved Msr =%.16lx Saved Nia =%.16lx \n", 1606 ptrLpRegSave = ptrPaca->reg_save_ptr;
1598 ptrLpRegSave->xMSR, ptrLpRegSave->xNIA); 1607 printf(" Saved Sprg0=%.16lx Saved Sprg1=%.16lx \n",
1608 ptrLpRegSave->xSPRG0, ptrLpRegSave->xSPRG0);
1609 printf(" Saved Sprg2=%.16lx Saved Sprg3=%.16lx \n",
1610 ptrLpRegSave->xSPRG2, ptrLpRegSave->xSPRG3);
1611 printf(" Saved Msr =%.16lx Saved Nia =%.16lx \n",
1612 ptrLpRegSave->xMSR, ptrLpRegSave->xNIA);
1613 }
1599#endif 1614#endif
1600 1615
1601 return; 1616 return;
@@ -2053,8 +2068,11 @@ prdump(unsigned long adrs, long ndump)
2053 } 2068 }
2054} 2069}
2055 2070
2071typedef int (*instruction_dump_func)(unsigned long inst, unsigned long addr);
2072
2056int 2073int
2057ppc_inst_dump(unsigned long adr, long count, int praddr) 2074generic_inst_dump(unsigned long adr, long count, int praddr,
2075 instruction_dump_func dump_func)
2058{ 2076{
2059 int nr, dotted; 2077 int nr, dotted;
2060 unsigned long first_adr; 2078 unsigned long first_adr;
@@ -2084,12 +2102,18 @@ ppc_inst_dump(unsigned long adr, long count, int praddr)
2084 if (praddr) 2102 if (praddr)
2085 printf(REG" %.8x", adr, inst); 2103 printf(REG" %.8x", adr, inst);
2086 printf("\t"); 2104 printf("\t");
2087 print_insn_powerpc(inst, adr, 0); /* always returns 4 */ 2105 dump_func(inst, adr);
2088 printf("\n"); 2106 printf("\n");
2089 } 2107 }
2090 return adr - first_adr; 2108 return adr - first_adr;
2091} 2109}
2092 2110
2111int
2112ppc_inst_dump(unsigned long adr, long count, int praddr)
2113{
2114 return generic_inst_dump(adr, count, praddr, print_insn_powerpc);
2115}
2116
2093void 2117void
2094print_address(unsigned long addr) 2118print_address(unsigned long addr)
2095{ 2119{
@@ -2557,6 +2581,10 @@ void dump_segments(void)
2557 2581
2558void xmon_init(int enable) 2582void xmon_init(int enable)
2559{ 2583{
2584#ifdef CONFIG_PPC_ISERIES
2585 if (firmware_has_feature(FW_FEATURE_ISERIES))
2586 return;
2587#endif
2560 if (enable) { 2588 if (enable) {
2561 __debugger = xmon; 2589 __debugger = xmon;
2562 __debugger_ipi = xmon_ipi; 2590 __debugger_ipi = xmon_ipi;
@@ -2594,6 +2622,10 @@ static struct sysrq_key_op sysrq_xmon_op =
2594 2622
2595static int __init setup_xmon_sysrq(void) 2623static int __init setup_xmon_sysrq(void)
2596{ 2624{
2625#ifdef CONFIG_PPC_ISERIES
2626 if (firmware_has_feature(FW_FEATURE_ISERIES))
2627 return 0;
2628#endif
2597 register_sysrq_key('x', &sysrq_xmon_op); 2629 register_sysrq_key('x', &sysrq_xmon_op);
2598 return 0; 2630 return 0;
2599} 2631}
@@ -2630,3 +2662,263 @@ void __init xmon_setup(void)
2630 if (xmon_early) 2662 if (xmon_early)
2631 debugger(NULL); 2663 debugger(NULL);
2632} 2664}
2665
2666#ifdef CONFIG_SPU_BASE
2667
2668struct spu_info {
2669 struct spu *spu;
2670 u64 saved_mfc_sr1_RW;
2671 u32 saved_spu_runcntl_RW;
2672 unsigned long dump_addr;
2673 u8 stopped_ok;
2674};
2675
2676#define XMON_NUM_SPUS 16 /* Enough for current hardware */
2677
2678static struct spu_info spu_info[XMON_NUM_SPUS];
2679
2680void xmon_register_spus(struct list_head *list)
2681{
2682 struct spu *spu;
2683
2684 list_for_each_entry(spu, list, full_list) {
2685 if (spu->number >= XMON_NUM_SPUS) {
2686 WARN_ON(1);
2687 continue;
2688 }
2689
2690 spu_info[spu->number].spu = spu;
2691 spu_info[spu->number].stopped_ok = 0;
2692 spu_info[spu->number].dump_addr = (unsigned long)
2693 spu_info[spu->number].spu->local_store;
2694 }
2695}
2696
2697static void stop_spus(void)
2698{
2699 struct spu *spu;
2700 int i;
2701 u64 tmp;
2702
2703 for (i = 0; i < XMON_NUM_SPUS; i++) {
2704 if (!spu_info[i].spu)
2705 continue;
2706
2707 if (setjmp(bus_error_jmp) == 0) {
2708 catch_memory_errors = 1;
2709 sync();
2710
2711 spu = spu_info[i].spu;
2712
2713 spu_info[i].saved_spu_runcntl_RW =
2714 in_be32(&spu->problem->spu_runcntl_RW);
2715
2716 tmp = spu_mfc_sr1_get(spu);
2717 spu_info[i].saved_mfc_sr1_RW = tmp;
2718
2719 tmp &= ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
2720 spu_mfc_sr1_set(spu, tmp);
2721
2722 sync();
2723 __delay(200);
2724
2725 spu_info[i].stopped_ok = 1;
2726
2727 printf("Stopped spu %.2d (was %s)\n", i,
2728 spu_info[i].saved_spu_runcntl_RW ?
2729 "running" : "stopped");
2730 } else {
2731 catch_memory_errors = 0;
2732 printf("*** Error stopping spu %.2d\n", i);
2733 }
2734 catch_memory_errors = 0;
2735 }
2736}
2737
2738static void restart_spus(void)
2739{
2740 struct spu *spu;
2741 int i;
2742
2743 for (i = 0; i < XMON_NUM_SPUS; i++) {
2744 if (!spu_info[i].spu)
2745 continue;
2746
2747 if (!spu_info[i].stopped_ok) {
2748 printf("*** Error, spu %d was not successfully stopped"
2749 ", not restarting\n", i);
2750 continue;
2751 }
2752
2753 if (setjmp(bus_error_jmp) == 0) {
2754 catch_memory_errors = 1;
2755 sync();
2756
2757 spu = spu_info[i].spu;
2758 spu_mfc_sr1_set(spu, spu_info[i].saved_mfc_sr1_RW);
2759 out_be32(&spu->problem->spu_runcntl_RW,
2760 spu_info[i].saved_spu_runcntl_RW);
2761
2762 sync();
2763 __delay(200);
2764
2765 printf("Restarted spu %.2d\n", i);
2766 } else {
2767 catch_memory_errors = 0;
2768 printf("*** Error restarting spu %.2d\n", i);
2769 }
2770 catch_memory_errors = 0;
2771 }
2772}
2773
2774#define DUMP_WIDTH 23
2775#define DUMP_VALUE(format, field, value) \
2776do { \
2777 if (setjmp(bus_error_jmp) == 0) { \
2778 catch_memory_errors = 1; \
2779 sync(); \
2780 printf(" %-*s = "format"\n", DUMP_WIDTH, \
2781 #field, value); \
2782 sync(); \
2783 __delay(200); \
2784 } else { \
2785 catch_memory_errors = 0; \
2786 printf(" %-*s = *** Error reading field.\n", \
2787 DUMP_WIDTH, #field); \
2788 } \
2789 catch_memory_errors = 0; \
2790} while (0)
2791
2792#define DUMP_FIELD(obj, format, field) \
2793 DUMP_VALUE(format, field, obj->field)
2794
2795static void dump_spu_fields(struct spu *spu)
2796{
2797 printf("Dumping spu fields at address %p:\n", spu);
2798
2799 DUMP_FIELD(spu, "0x%x", number);
2800 DUMP_FIELD(spu, "%s", name);
2801 DUMP_FIELD(spu, "0x%lx", local_store_phys);
2802 DUMP_FIELD(spu, "0x%p", local_store);
2803 DUMP_FIELD(spu, "0x%lx", ls_size);
2804 DUMP_FIELD(spu, "0x%x", node);
2805 DUMP_FIELD(spu, "0x%lx", flags);
2806 DUMP_FIELD(spu, "0x%lx", dar);
2807 DUMP_FIELD(spu, "0x%lx", dsisr);
2808 DUMP_FIELD(spu, "%d", class_0_pending);
2809 DUMP_FIELD(spu, "0x%lx", irqs[0]);
2810 DUMP_FIELD(spu, "0x%lx", irqs[1]);
2811 DUMP_FIELD(spu, "0x%lx", irqs[2]);
2812 DUMP_FIELD(spu, "0x%x", slb_replace);
2813 DUMP_FIELD(spu, "%d", pid);
2814 DUMP_FIELD(spu, "%d", prio);
2815 DUMP_FIELD(spu, "0x%p", mm);
2816 DUMP_FIELD(spu, "0x%p", ctx);
2817 DUMP_FIELD(spu, "0x%p", rq);
2818 DUMP_FIELD(spu, "0x%p", timestamp);
2819 DUMP_FIELD(spu, "0x%lx", problem_phys);
2820 DUMP_FIELD(spu, "0x%p", problem);
2821 DUMP_VALUE("0x%x", problem->spu_runcntl_RW,
2822 in_be32(&spu->problem->spu_runcntl_RW));
2823 DUMP_VALUE("0x%x", problem->spu_status_R,
2824 in_be32(&spu->problem->spu_status_R));
2825 DUMP_VALUE("0x%x", problem->spu_npc_RW,
2826 in_be32(&spu->problem->spu_npc_RW));
2827 DUMP_FIELD(spu, "0x%p", priv2);
2828 DUMP_FIELD(spu, "0x%p", pdata);
2829}
2830
2831int
2832spu_inst_dump(unsigned long adr, long count, int praddr)
2833{
2834 return generic_inst_dump(adr, count, praddr, print_insn_spu);
2835}
2836
2837static void dump_spu_ls(unsigned long num, int subcmd)
2838{
2839 unsigned long offset, addr, ls_addr;
2840
2841 if (setjmp(bus_error_jmp) == 0) {
2842 catch_memory_errors = 1;
2843 sync();
2844 ls_addr = (unsigned long)spu_info[num].spu->local_store;
2845 sync();
2846 __delay(200);
2847 } else {
2848 catch_memory_errors = 0;
2849 printf("*** Error: accessing spu info for spu %d\n", num);
2850 return;
2851 }
2852 catch_memory_errors = 0;
2853
2854 if (scanhex(&offset))
2855 addr = ls_addr + offset;
2856 else
2857 addr = spu_info[num].dump_addr;
2858
2859 if (addr >= ls_addr + LS_SIZE) {
2860 printf("*** Error: address outside of local store\n");
2861 return;
2862 }
2863
2864 switch (subcmd) {
2865 case 'i':
2866 addr += spu_inst_dump(addr, 16, 1);
2867 last_cmd = "sdi\n";
2868 break;
2869 default:
2870 prdump(addr, 64);
2871 addr += 64;
2872 last_cmd = "sd\n";
2873 break;
2874 }
2875
2876 spu_info[num].dump_addr = addr;
2877}
2878
2879static int do_spu_cmd(void)
2880{
2881 static unsigned long num = 0;
2882 int cmd, subcmd = 0;
2883
2884 cmd = inchar();
2885 switch (cmd) {
2886 case 's':
2887 stop_spus();
2888 break;
2889 case 'r':
2890 restart_spus();
2891 break;
2892 case 'd':
2893 subcmd = inchar();
2894 if (isxdigit(subcmd) || subcmd == '\n')
2895 termch = subcmd;
2896 case 'f':
2897 scanhex(&num);
2898 if (num >= XMON_NUM_SPUS || !spu_info[num].spu) {
2899 printf("*** Error: invalid spu number\n");
2900 return 0;
2901 }
2902
2903 switch (cmd) {
2904 case 'f':
2905 dump_spu_fields(spu_info[num].spu);
2906 break;
2907 default:
2908 dump_spu_ls(num, subcmd);
2909 break;
2910 }
2911
2912 break;
2913 default:
2914 return -1;
2915 }
2916
2917 return 0;
2918}
2919#else /* ! CONFIG_SPU_BASE */
2920static int do_spu_cmd(void)
2921{
2922 return -1;
2923}
2924#endif
diff --git a/arch/ppc/.gitignore b/arch/ppc/.gitignore
new file mode 100644
index 000000000000..a1a869c8c840
--- /dev/null
+++ b/arch/ppc/.gitignore
@@ -0,0 +1 @@
include
diff --git a/arch/ppc/8260_io/fcc_enet.c b/arch/ppc/8260_io/fcc_enet.c
index 2e1943e27819..709952c25f29 100644
--- a/arch/ppc/8260_io/fcc_enet.c
+++ b/arch/ppc/8260_io/fcc_enet.c
@@ -385,6 +385,7 @@ struct fcc_enet_private {
385 phy_info_t *phy; 385 phy_info_t *phy;
386 struct work_struct phy_relink; 386 struct work_struct phy_relink;
387 struct work_struct phy_display_config; 387 struct work_struct phy_display_config;
388 struct net_device *dev;
388 389
389 uint sequence_done; 390 uint sequence_done;
390 391
@@ -1391,10 +1392,11 @@ static phy_info_t *phy_info[] = {
1391 NULL 1392 NULL
1392}; 1393};
1393 1394
1394static void mii_display_status(void *data) 1395static void mii_display_status(struct work_struct *work)
1395{ 1396{
1396 struct net_device *dev = data; 1397 volatile struct fcc_enet_private *fep =
1397 volatile struct fcc_enet_private *fep = dev->priv; 1398 container_of(work, struct fcc_enet_private, phy_relink);
1399 struct net_device *dev = fep->dev;
1398 uint s = fep->phy_status; 1400 uint s = fep->phy_status;
1399 1401
1400 if (!fep->link && !fep->old_link) { 1402 if (!fep->link && !fep->old_link) {
@@ -1428,10 +1430,12 @@ static void mii_display_status(void *data)
1428 printk(".\n"); 1430 printk(".\n");
1429} 1431}
1430 1432
1431static void mii_display_config(void *data) 1433static void mii_display_config(struct work_struct *work)
1432{ 1434{
1433 struct net_device *dev = data; 1435 volatile struct fcc_enet_private *fep =
1434 volatile struct fcc_enet_private *fep = dev->priv; 1436 container_of(work, struct fcc_enet_private,
1437 phy_display_config);
1438 struct net_device *dev = fep->dev;
1435 uint s = fep->phy_status; 1439 uint s = fep->phy_status;
1436 1440
1437 printk("%s: config: auto-negotiation ", dev->name); 1441 printk("%s: config: auto-negotiation ", dev->name);
@@ -1758,8 +1762,9 @@ static int __init fec_enet_init(void)
1758 cep->phy_id_done = 0; 1762 cep->phy_id_done = 0;
1759 cep->phy_addr = fip->fc_phyaddr; 1763 cep->phy_addr = fip->fc_phyaddr;
1760 mii_queue(dev, mk_mii_read(MII_PHYSID1), mii_discover_phy); 1764 mii_queue(dev, mk_mii_read(MII_PHYSID1), mii_discover_phy);
1761 INIT_WORK(&cep->phy_relink, mii_display_status, dev); 1765 INIT_WORK(&cep->phy_relink, mii_display_status);
1762 INIT_WORK(&cep->phy_display_config, mii_display_config, dev); 1766 INIT_WORK(&cep->phy_display_config, mii_display_config);
1767 cep->dev = dev;
1763#endif /* CONFIG_USE_MDIO */ 1768#endif /* CONFIG_USE_MDIO */
1764 1769
1765 fip++; 1770 fip++;
diff --git a/arch/ppc/8xx_io/fec.c b/arch/ppc/8xx_io/fec.c
index 2f9fa9e3d331..e6c28fb423b2 100644
--- a/arch/ppc/8xx_io/fec.c
+++ b/arch/ppc/8xx_io/fec.c
@@ -173,6 +173,7 @@ struct fec_enet_private {
173 uint phy_speed; 173 uint phy_speed;
174 phy_info_t *phy; 174 phy_info_t *phy;
175 struct work_struct phy_task; 175 struct work_struct phy_task;
176 struct net_device *dev;
176 177
177 uint sequence_done; 178 uint sequence_done;
178 179
@@ -1263,10 +1264,11 @@ static void mii_display_status(struct net_device *dev)
1263 printk(".\n"); 1264 printk(".\n");
1264} 1265}
1265 1266
1266static void mii_display_config(void *priv) 1267static void mii_display_config(struct work_struct *work)
1267{ 1268{
1268 struct net_device *dev = (struct net_device *)priv; 1269 struct fec_enet_private *fep =
1269 struct fec_enet_private *fep = dev->priv; 1270 container_of(work, struct fec_enet_private, phy_task);
1271 struct net_device *dev = fep->dev;
1270 volatile uint *s = &(fep->phy_status); 1272 volatile uint *s = &(fep->phy_status);
1271 1273
1272 printk("%s: config: auto-negotiation ", dev->name); 1274 printk("%s: config: auto-negotiation ", dev->name);
@@ -1295,10 +1297,11 @@ static void mii_display_config(void *priv)
1295 fep->sequence_done = 1; 1297 fep->sequence_done = 1;
1296} 1298}
1297 1299
1298static void mii_relink(void *priv) 1300static void mii_relink(struct work_struct *work)
1299{ 1301{
1300 struct net_device *dev = (struct net_device *)priv; 1302 struct fec_enet_private *fep =
1301 struct fec_enet_private *fep = dev->priv; 1303 container_of(work, struct fec_enet_private, phy_task);
1304 struct net_device *dev = fep->dev;
1302 int duplex; 1305 int duplex;
1303 1306
1304 fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0; 1307 fep->link = (fep->phy_status & PHY_STAT_LINK) ? 1 : 0;
@@ -1325,7 +1328,8 @@ static void mii_queue_relink(uint mii_reg, struct net_device *dev)
1325{ 1328{
1326 struct fec_enet_private *fep = dev->priv; 1329 struct fec_enet_private *fep = dev->priv;
1327 1330
1328 INIT_WORK(&fep->phy_task, mii_relink, (void *)dev); 1331 fep->dev = dev;
1332 INIT_WORK(&fep->phy_task, mii_relink);
1329 schedule_work(&fep->phy_task); 1333 schedule_work(&fep->phy_task);
1330} 1334}
1331 1335
@@ -1333,7 +1337,8 @@ static void mii_queue_config(uint mii_reg, struct net_device *dev)
1333{ 1337{
1334 struct fec_enet_private *fep = dev->priv; 1338 struct fec_enet_private *fep = dev->priv;
1335 1339
1336 INIT_WORK(&fep->phy_task, mii_display_config, (void *)dev); 1340 fep->dev = dev;
1341 INIT_WORK(&fep->phy_task, mii_display_config);
1337 schedule_work(&fep->phy_task); 1342 schedule_work(&fep->phy_task);
1338} 1343}
1339 1344
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index ef018e25fb07..edf71a4ecc95 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -77,9 +77,11 @@ config 6xx
77 77
78config 40x 78config 40x
79 bool "40x" 79 bool "40x"
80 select PPC_DCR_NATIVE
80 81
81config 44x 82config 44x
82 bool "44x" 83 bool "44x"
84 select PPC_DCR_NATIVE
83 85
84config 8xx 86config 8xx
85 bool "8xx" 87 bool "8xx"
@@ -95,6 +97,15 @@ endchoice
95config PPC_FPU 97config PPC_FPU
96 bool 98 bool
97 99
100config PPC_DCR_NATIVE
101 bool
102 default n
103
104config PPC_DCR
105 bool
106 depends on PPC_DCR_NATIVE
107 default y
108
98config BOOKE 109config BOOKE
99 bool 110 bool
100 depends on E200 || E500 111 depends on E200 || E500
diff --git a/arch/ppc/boot/images/.gitignore b/arch/ppc/boot/images/.gitignore
new file mode 100644
index 000000000000..21c2dc5b6b78
--- /dev/null
+++ b/arch/ppc/boot/images/.gitignore
@@ -0,0 +1,6 @@
1sImage
2vmapus
3vmlinux*
4miboot*
5zImage*
6uImage
diff --git a/arch/ppc/boot/lib/.gitignore b/arch/ppc/boot/lib/.gitignore
new file mode 100644
index 000000000000..1629a6167755
--- /dev/null
+++ b/arch/ppc/boot/lib/.gitignore
@@ -0,0 +1,3 @@
1inffast.c
2inflate.c
3inftrees.c
diff --git a/arch/ppc/boot/utils/.gitignore b/arch/ppc/boot/utils/.gitignore
new file mode 100644
index 000000000000..bbdfb3b9c532
--- /dev/null
+++ b/arch/ppc/boot/utils/.gitignore
@@ -0,0 +1,3 @@
1mkprep
2mkbugboot
3mktree
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index 27faeca2c7a2..3c506af19880 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -313,7 +313,7 @@ early_init(int r3, int r4, int r5)
313 * Identify the CPU type and fix up code sections 313 * Identify the CPU type and fix up code sections
314 * that depend on which cpu we have. 314 * that depend on which cpu we have.
315 */ 315 */
316 spec = identify_cpu(offset); 316 spec = identify_cpu(offset, mfspr(SPRN_PVR));
317 do_feature_fixups(spec->cpu_features, 317 do_feature_fixups(spec->cpu_features,
318 PTRRELOC(&__start___ftr_fixup), 318 PTRRELOC(&__start___ftr_fixup),
319 PTRRELOC(&__stop___ftr_fixup)); 319 PTRRELOC(&__stop___ftr_fixup));
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 9661a91183b3..2f835b9e95e4 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -316,7 +316,7 @@ void machine_check_exception(struct pt_regs *regs)
316 if (reason & MCSR_BUS_RBERR) 316 if (reason & MCSR_BUS_RBERR)
317 printk("Bus - Read Data Bus Error\n"); 317 printk("Bus - Read Data Bus Error\n");
318 if (reason & MCSR_BUS_WBERR) 318 if (reason & MCSR_BUS_WBERR)
319 printk("Bus - Read Data Bus Error\n"); 319 printk("Bus - Write Data Bus Error\n");
320 if (reason & MCSR_BUS_IPERR) 320 if (reason & MCSR_BUS_IPERR)
321 printk("Bus - Instruction Parity Error\n"); 321 printk("Bus - Instruction Parity Error\n");
322 if (reason & MCSR_BUS_RPERR) 322 if (reason & MCSR_BUS_RPERR)
diff --git a/arch/ppc/platforms/4xx/bubinga.c b/arch/ppc/platforms/4xx/bubinga.c
index 4009f4983ca6..75857b38e894 100644
--- a/arch/ppc/platforms/4xx/bubinga.c
+++ b/arch/ppc/platforms/4xx/bubinga.c
@@ -116,6 +116,7 @@ bubinga_early_serial_map(void)
116void __init 116void __init
117bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip) 117bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
118{ 118{
119#ifdef CONFIG_PCI
119 120
120 unsigned int bar_response, bar; 121 unsigned int bar_response, bar;
121 /* 122 /*
@@ -212,6 +213,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
212 printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la))); 213 printk(" ptm2la\t0x%x\n", in_le32(&(pcip->ptm2la)));
213 214
214#endif 215#endif
216#endif
215} 217}
216 218
217void __init 219void __init
diff --git a/arch/ppc/platforms/4xx/cpci405.c b/arch/ppc/platforms/4xx/cpci405.c
index 367430998fc5..8474b05b795a 100644
--- a/arch/ppc/platforms/4xx/cpci405.c
+++ b/arch/ppc/platforms/4xx/cpci405.c
@@ -126,6 +126,7 @@ cpci405_setup_arch(void)
126void __init 126void __init
127bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip) 127bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
128{ 128{
129#ifdef CONFIG_PCI
129 unsigned int bar_response, bar; 130 unsigned int bar_response, bar;
130 131
131 /* Disable region first */ 132 /* Disable region first */
@@ -167,6 +168,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
167 PCI_FUNC(hose->first_busno), bar, 168 PCI_FUNC(hose->first_busno), bar,
168 &bar_response); 169 &bar_response);
169 } 170 }
171#endif
170} 172}
171 173
172void __init 174void __init
diff --git a/arch/ppc/platforms/4xx/ep405.c b/arch/ppc/platforms/4xx/ep405.c
index ae5c82081c95..e5adf9ba1fca 100644
--- a/arch/ppc/platforms/4xx/ep405.c
+++ b/arch/ppc/platforms/4xx/ep405.c
@@ -68,6 +68,7 @@ ep405_setup_arch(void)
68void __init 68void __init
69bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip) 69bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
70{ 70{
71#ifdef CONFIG_PCI
71 unsigned int bar_response, bar; 72 unsigned int bar_response, bar;
72 /* 73 /*
73 * Expected PCI mapping: 74 * Expected PCI mapping:
@@ -130,6 +131,7 @@ bios_fixup(struct pci_controller *hose, struct pcil0_regs *pcip)
130 PCI_FUNC(hose->first_busno), bar, bar_response); 131 PCI_FUNC(hose->first_busno), bar, bar_response);
131 } 132 }
132 /* end work arround */ 133 /* end work arround */
134#endif
133} 135}
134 136
135void __init 137void __init
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c
index 3397f0de1592..b84f8df325c4 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.c
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.c
@@ -121,8 +121,8 @@ mpc834x_sys_setup_arch(void)
121 121
122 mdata->irq[0] = MPC83xx_IRQ_EXT1; 122 mdata->irq[0] = MPC83xx_IRQ_EXT1;
123 mdata->irq[1] = MPC83xx_IRQ_EXT2; 123 mdata->irq[1] = MPC83xx_IRQ_EXT2;
124 mdata->irq[2] = -1; 124 mdata->irq[2] = PHY_POLL;
125 mdata->irq[31] = -1; 125 mdata->irq[31] = PHY_POLL;
126 126
127 /* setup the board related information for the enet controllers */ 127 /* setup the board related information for the enet controllers */
128 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC1); 128 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC83xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
index 4f839da6782f..00a3ba57063f 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.c
@@ -92,9 +92,9 @@ mpc8540ads_setup_arch(void)
92 92
93 mdata->irq[0] = MPC85xx_IRQ_EXT5; 93 mdata->irq[0] = MPC85xx_IRQ_EXT5;
94 mdata->irq[1] = MPC85xx_IRQ_EXT5; 94 mdata->irq[1] = MPC85xx_IRQ_EXT5;
95 mdata->irq[2] = -1; 95 mdata->irq[2] = PHY_POLL;
96 mdata->irq[3] = MPC85xx_IRQ_EXT5; 96 mdata->irq[3] = MPC85xx_IRQ_EXT5;
97 mdata->irq[31] = -1; 97 mdata->irq[31] = PHY_POLL;
98 98
99 /* setup the board related information for the enet controllers */ 99 /* setup the board related information for the enet controllers */
100 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 100 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
index 14ecec7bbed7..3a060468dd95 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c
@@ -156,9 +156,9 @@ mpc8560ads_setup_arch(void)
156 156
157 mdata->irq[0] = MPC85xx_IRQ_EXT5; 157 mdata->irq[0] = MPC85xx_IRQ_EXT5;
158 mdata->irq[1] = MPC85xx_IRQ_EXT5; 158 mdata->irq[1] = MPC85xx_IRQ_EXT5;
159 mdata->irq[2] = -1; 159 mdata->irq[2] = PHY_POLL;
160 mdata->irq[3] = MPC85xx_IRQ_EXT5; 160 mdata->irq[3] = MPC85xx_IRQ_EXT5;
161 mdata->irq[31] = -1; 161 mdata->irq[31] = PHY_POLL;
162 162
163 /* setup the board related information for the enet controllers */ 163 /* setup the board related information for the enet controllers */
164 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 164 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index 5ce0f69c1db6..2d59eb776c95 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -451,9 +451,9 @@ mpc85xx_cds_setup_arch(void)
451 451
452 mdata->irq[0] = MPC85xx_IRQ_EXT5; 452 mdata->irq[0] = MPC85xx_IRQ_EXT5;
453 mdata->irq[1] = MPC85xx_IRQ_EXT5; 453 mdata->irq[1] = MPC85xx_IRQ_EXT5;
454 mdata->irq[2] = -1; 454 mdata->irq[2] = PHY_POLL;
455 mdata->irq[3] = -1; 455 mdata->irq[3] = PHY_POLL;
456 mdata->irq[31] = -1; 456 mdata->irq[31] = PHY_POLL;
457 457
458 /* setup the board related information for the enet controllers */ 458 /* setup the board related information for the enet controllers */
459 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 459 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
index 764d580ff535..1d10ab98f66d 100644
--- a/arch/ppc/platforms/85xx/sbc8560.c
+++ b/arch/ppc/platforms/85xx/sbc8560.c
@@ -129,7 +129,7 @@ sbc8560_setup_arch(void)
129 129
130 mdata->irq[25] = MPC85xx_IRQ_EXT6; 130 mdata->irq[25] = MPC85xx_IRQ_EXT6;
131 mdata->irq[26] = MPC85xx_IRQ_EXT7; 131 mdata->irq[26] = MPC85xx_IRQ_EXT7;
132 mdata->irq[31] = -1; 132 mdata->irq[31] = PHY_POLL;
133 133
134 /* setup the board related information for the enet controllers */ 134 /* setup the board related information for the enet controllers */
135 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 135 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index 4bb18ab27672..b1f5b737c70d 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -123,7 +123,7 @@ gp3_setup_arch(void)
123 123
124 mdata->irq[2] = MPC85xx_IRQ_EXT5; 124 mdata->irq[2] = MPC85xx_IRQ_EXT5;
125 mdata->irq[4] = MPC85xx_IRQ_EXT5; 125 mdata->irq[4] = MPC85xx_IRQ_EXT5;
126 mdata->irq[31] = -1; 126 mdata->irq[31] = PHY_POLL;
127 127
128 /* setup the board related information for the enet controllers */ 128 /* setup the board related information for the enet controllers */
129 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 129 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/85xx/tqm85xx.c b/arch/ppc/platforms/85xx/tqm85xx.c
index dd45f2e18449..4ee2bd156dc5 100644
--- a/arch/ppc/platforms/85xx/tqm85xx.c
+++ b/arch/ppc/platforms/85xx/tqm85xx.c
@@ -137,9 +137,9 @@ tqm85xx_setup_arch(void)
137 137
138 mdata->irq[0] = MPC85xx_IRQ_EXT8; 138 mdata->irq[0] = MPC85xx_IRQ_EXT8;
139 mdata->irq[1] = MPC85xx_IRQ_EXT8; 139 mdata->irq[1] = MPC85xx_IRQ_EXT8;
140 mdata->irq[2] = -1; 140 mdata->irq[2] = PHY_POLL;
141 mdata->irq[3] = MPC85xx_IRQ_EXT8; 141 mdata->irq[3] = MPC85xx_IRQ_EXT8;
142 mdata->irq[31] = -1; 142 mdata->irq[31] = PHY_POLL;
143 143
144 /* setup the board related information for the enet controllers */ 144 /* setup the board related information for the enet controllers */
145 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1); 145 pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_TSEC1);
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
index 1f9ea36837b1..0bc06768cf24 100644
--- a/arch/ppc/platforms/mpc8272ads_setup.c
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -266,10 +266,10 @@ static void __init mpc8272ads_fixup_mdio_pdata(struct platform_device *pdev,
266 int idx) 266 int idx)
267{ 267{
268 m82xx_mii_bb_pdata.irq[0] = PHY_INTERRUPT; 268 m82xx_mii_bb_pdata.irq[0] = PHY_INTERRUPT;
269 m82xx_mii_bb_pdata.irq[1] = -1; 269 m82xx_mii_bb_pdata.irq[1] = PHY_POLL;
270 m82xx_mii_bb_pdata.irq[2] = -1; 270 m82xx_mii_bb_pdata.irq[2] = PHY_POLL;
271 m82xx_mii_bb_pdata.irq[3] = PHY_INTERRUPT; 271 m82xx_mii_bb_pdata.irq[3] = PHY_INTERRUPT;
272 m82xx_mii_bb_pdata.irq[31] = -1; 272 m82xx_mii_bb_pdata.irq[31] = PHY_POLL;
273 273
274 274
275 m82xx_mii_bb_pdata.mdio_dat.offset = 275 m82xx_mii_bb_pdata.mdio_dat.offset =
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
index e95d2c111747..8a0c07eb4449 100644
--- a/arch/ppc/platforms/mpc866ads_setup.c
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -361,7 +361,7 @@ int __init mpc866ads_init(void)
361 361
362 fmpi->mii_speed = ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1; 362 fmpi->mii_speed = ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1;
363 /* No PHY interrupt line here */ 363 /* No PHY interrupt line here */
364 fmpi->irq[0xf] = -1; 364 fmpi->irq[0xf] = PHY_POLL;
365 365
366/* Since either of the uarts could be used as console, they need to ready */ 366/* Since either of the uarts could be used as console, they need to ready */
367#ifdef CONFIG_SERIAL_CPM_SMC1 367#ifdef CONFIG_SERIAL_CPM_SMC1
@@ -380,7 +380,7 @@ int __init mpc866ads_init(void)
380 380
381 fmpi->mii_speed = ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1; 381 fmpi->mii_speed = ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1;
382 /* No PHY interrupt line here */ 382 /* No PHY interrupt line here */
383 fmpi->irq[0xf] = -1; 383 fmpi->irq[0xf] = PHY_POLL;
384 384
385 return 0; 385 return 0;
386} 386}
diff --git a/arch/ppc/syslib/mpc8xx_devices.c b/arch/ppc/syslib/mpc8xx_devices.c
index cf5ab47487a7..31fb56593d17 100644
--- a/arch/ppc/syslib/mpc8xx_devices.c
+++ b/arch/ppc/syslib/mpc8xx_devices.c
@@ -78,7 +78,7 @@ struct platform_device ppc_sys_platform_devices[] = {
78 { 78 {
79 .name = "pram", 79 .name = "pram",
80 .start = 0x3c00, 80 .start = 0x3c00,
81 .end = 0x3c80, 81 .end = 0x3c7f,
82 .flags = IORESOURCE_MEM, 82 .flags = IORESOURCE_MEM,
83 }, 83 },
84 { 84 {
@@ -103,7 +103,7 @@ struct platform_device ppc_sys_platform_devices[] = {
103 { 103 {
104 .name = "pram", 104 .name = "pram",
105 .start = 0x3d00, 105 .start = 0x3d00,
106 .end = 0x3d80, 106 .end = 0x3d7f,
107 .flags = IORESOURCE_MEM, 107 .flags = IORESOURCE_MEM,
108 }, 108 },
109 109
@@ -129,7 +129,7 @@ struct platform_device ppc_sys_platform_devices[] = {
129 { 129 {
130 .name = "pram", 130 .name = "pram",
131 .start = 0x3e00, 131 .start = 0x3e00,
132 .end = 0x3e80, 132 .end = 0x3e7f,
133 .flags = IORESOURCE_MEM, 133 .flags = IORESOURCE_MEM,
134 }, 134 },
135 135
@@ -155,7 +155,7 @@ struct platform_device ppc_sys_platform_devices[] = {
155 { 155 {
156 .name = "pram", 156 .name = "pram",
157 .start = 0x3f00, 157 .start = 0x3f00,
158 .end = 0x3f80, 158 .end = 0x3f7f,
159 .flags = IORESOURCE_MEM, 159 .flags = IORESOURCE_MEM,
160 }, 160 },
161 161
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index af1e8fc7d985..67d5cf9cba83 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -92,8 +92,8 @@ static int appldata_timer_active;
92 * Work queue 92 * Work queue
93 */ 93 */
94static struct workqueue_struct *appldata_wq; 94static struct workqueue_struct *appldata_wq;
95static void appldata_work_fn(void *data); 95static void appldata_work_fn(struct work_struct *work);
96static DECLARE_WORK(appldata_work, appldata_work_fn, NULL); 96static DECLARE_WORK(appldata_work, appldata_work_fn);
97 97
98 98
99/* 99/*
@@ -125,7 +125,7 @@ static void appldata_timer_function(unsigned long data)
125 * 125 *
126 * call data gathering function for each (active) module 126 * call data gathering function for each (active) module
127 */ 127 */
128static void appldata_work_fn(void *data) 128static void appldata_work_fn(struct work_struct *work)
129{ 129{
130 struct list_head *lh; 130 struct list_head *lh;
131 struct appldata_ops *ops; 131 struct appldata_ops *ops;
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index bffc7e176970..d83d64af31f2 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -51,6 +51,14 @@ config GENERIC_TIME
51config ARCH_MAY_HAVE_PC_FDC 51config ARCH_MAY_HAVE_PC_FDC
52 bool 52 bool
53 53
54config STACKTRACE_SUPPORT
55 bool
56 default y
57
58config LOCKDEP_SUPPORT
59 bool
60 default y
61
54source "init/Kconfig" 62source "init/Kconfig"
55 63
56menu "System type" 64menu "System type"
@@ -219,6 +227,20 @@ config SH_SHMIN
219 help 227 help
220 Select SHMIN if configuring for the SHMIN board. 228 Select SHMIN if configuring for the SHMIN board.
221 229
230config SH_7206_SOLUTION_ENGINE
231 bool "SolutionEngine7206"
232 select CPU_SUBTYPE_SH7206
233 help
234 Select 7206 SolutionEngine if configuring for a Hitachi SH7206
235 evaluation board.
236
237config SH_7619_SOLUTION_ENGINE
238 bool "SolutionEngine7619"
239 select CPU_SUBTYPE_SH7619
240 help
241 Select 7619 SolutionEngine if configuring for a Hitachi SH7619
242 evaluation board.
243
222config SH_UNKNOWN 244config SH_UNKNOWN
223 bool "BareCPU" 245 bool "BareCPU"
224 help 246 help
@@ -280,12 +302,20 @@ config CF_BASE_ADDR
280 302
281menu "Processor features" 303menu "Processor features"
282 304
283config CPU_LITTLE_ENDIAN 305choice
284 bool "Little Endian" 306 prompt "Endianess selection"
307 default CPU_LITTLE_ENDIAN
285 help 308 help
286 Some SuperH machines can be configured for either little or big 309 Some SuperH machines can be configured for either little or big
287 endian byte order. These modes require different kernels. Say Y if 310 endian byte order. These modes require different kernels.
288 your machine is little endian, N if it's a big endian machine. 311
312config CPU_LITTLE_ENDIAN
313 bool "Little Endian"
314
315config CPU_BIG_ENDIAN
316 bool "Big Endian"
317
318endchoice
289 319
290config SH_FPU 320config SH_FPU
291 bool "FPU support" 321 bool "FPU support"
@@ -345,6 +375,9 @@ config CPU_HAS_MASKREG_IRQ
345config CPU_HAS_INTC2_IRQ 375config CPU_HAS_INTC2_IRQ
346 bool 376 bool
347 377
378config CPU_HAS_IPR_IRQ
379 bool
380
348config CPU_HAS_SR_RB 381config CPU_HAS_SR_RB
349 bool "CPU has SR.RB" 382 bool "CPU has SR.RB"
350 depends on CPU_SH3 || CPU_SH4 383 depends on CPU_SH3 || CPU_SH4
@@ -357,6 +390,9 @@ config CPU_HAS_SR_RB
357 See <file:Documentation/sh/register-banks.txt> for further 390 See <file:Documentation/sh/register-banks.txt> for further
358 information on SR.RB and register banking in the kernel in general. 391 information on SR.RB and register banking in the kernel in general.
359 392
393config CPU_HAS_PTEA
394 bool
395
360endmenu 396endmenu
361 397
362menu "Timer support" 398menu "Timer support"
@@ -364,10 +400,25 @@ depends on !GENERIC_TIME
364 400
365config SH_TMU 401config SH_TMU
366 bool "TMU timer support" 402 bool "TMU timer support"
403 depends on CPU_SH3 || CPU_SH4
367 default y 404 default y
368 help 405 help
369 This enables the use of the TMU as the system timer. 406 This enables the use of the TMU as the system timer.
370 407
408config SH_CMT
409 bool "CMT timer support"
410 depends on CPU_SH2
411 default y
412 help
413 This enables the use of the CMT as the system timer.
414
415config SH_MTU2
416 bool "MTU2 timer support"
417 depends on CPU_SH2A
418 default n
419 help
420 This enables the use of the MTU2 as the system timer.
421
371endmenu 422endmenu
372 423
373source "arch/sh/boards/renesas/hs7751rvoip/Kconfig" 424source "arch/sh/boards/renesas/hs7751rvoip/Kconfig"
@@ -376,19 +427,52 @@ source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
376 427
377source "arch/sh/boards/renesas/r7780rp/Kconfig" 428source "arch/sh/boards/renesas/r7780rp/Kconfig"
378 429
430config SH_TIMER_IRQ
431 int
432 default "28" if CPU_SUBTYPE_SH7780
433 default "86" if CPU_SUBTYPE_SH7619
434 default "140" if CPU_SUBTYPE_SH7206
435 default "16"
436
437config NO_IDLE_HZ
438 bool "Dynamic tick timer"
439 help
440 Select this option if you want to disable continuous timer ticks
441 and have them programmed to occur as required. This option saves
442 power as the system can remain in idle state for longer.
443
444 By default dynamic tick is disabled during the boot, and can be
445 manually enabled with:
446
447 echo 1 > /sys/devices/system/timer/timer0/dyn_tick
448
449 Alternatively, if you want dynamic tick automatically enabled
450 during boot, pass "dyntick=enable" via the kernel command string.
451
452 Please note that dynamic tick may affect the accuracy of
453 timekeeping on some platforms depending on the implementation.
454
379config SH_PCLK_FREQ 455config SH_PCLK_FREQ
380 int "Peripheral clock frequency (in Hz)" 456 int "Peripheral clock frequency (in Hz)"
457 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343
458 default "31250000" if CPU_SUBTYPE_SH7619
459 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \
460 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705 || \
461 CPU_SUBTYPE_SH7206
381 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780 462 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780
382 default "60000000" if CPU_SUBTYPE_SH7751 463 default "60000000" if CPU_SUBTYPE_SH7751
383 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \
384 CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7705
385 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343
386 default "66000000" if CPU_SUBTYPE_SH4_202 464 default "66000000" if CPU_SUBTYPE_SH4_202
387 help 465 help
388 This option is used to specify the peripheral clock frequency. 466 This option is used to specify the peripheral clock frequency.
389 This is necessary for determining the reference clock value on 467 This is necessary for determining the reference clock value on
390 platforms lacking an RTC. 468 platforms lacking an RTC.
391 469
470config SH_CLK_MD
471 int "CPU Mode Pin Setting"
472 depends on CPU_SUBTYPE_SH7619 || CPU_SUBTYPE_SH7206
473 help
474 MD2 - MD0 Setting.
475
392menu "CPU Frequency scaling" 476menu "CPU Frequency scaling"
393 477
394source "drivers/cpufreq/Kconfig" 478source "drivers/cpufreq/Kconfig"
@@ -421,6 +505,8 @@ config HEARTBEAT
421 behavior is platform-dependent, but normally the flash frequency is 505 behavior is platform-dependent, but normally the flash frequency is
422 a hyperbolic function of the 5-minute load average. 506 a hyperbolic function of the 5-minute load average.
423 507
508source "arch/sh/drivers/Kconfig"
509
424endmenu 510endmenu
425 511
426config ISA_DMA_API 512config ISA_DMA_API
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 48479e014dac..66a25ef4ef1b 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -1,5 +1,9 @@
1menu "Kernel hacking" 1menu "Kernel hacking"
2 2
3config TRACE_IRQFLAGS_SUPPORT
4 bool
5 default y
6
3source "lib/Kconfig.debug" 7source "lib/Kconfig.debug"
4 8
5config SH_STANDARD_BIOS 9config SH_STANDARD_BIOS
@@ -17,7 +21,18 @@ config SH_STANDARD_BIOS
17 21
18config EARLY_SCIF_CONSOLE 22config EARLY_SCIF_CONSOLE
19 bool "Use early SCIF console" 23 bool "Use early SCIF console"
20 depends on CPU_SH4 || CPU_SH2A && !SH_STANDARD_BIOS 24 help
25 This enables an early console using a fixed SCIF port. This can
26 be used by platforms that are either not running the SH
27 standard BIOS, or do not wish to use the BIOS callbacks for the
28 serial I/O.
29
30config EARLY_SCIF_CONSOLE_PORT
31 hex "SCIF port for early console"
32 depends on EARLY_SCIF_CONSOLE
33 default "0xffe00000" if CPU_SUBTYPE_SH7780
34 default "0xfffe9800" if CPU_SUBTYPE_SH72060
35 default "0xffe80000" if CPU_SH4
21 36
22config EARLY_PRINTK 37config EARLY_PRINTK
23 bool "Early printk support" 38 bool "Early printk support"
@@ -30,6 +45,11 @@ config EARLY_PRINTK
30 when the kernel may crash or hang before the serial console is 45 when the kernel may crash or hang before the serial console is
31 initialised. If unsure, say N. 46 initialised. If unsure, say N.
32 47
48 On devices that are running SH-IPL and want to keep the port
49 initialization consistent while not using the BIOS callbacks,
50 select both the EARLY_SCIF_CONSOLE and SH_STANDARD_BIOS, using
51 the kernel command line option to toggle back and forth.
52
33config DEBUG_STACKOVERFLOW 53config DEBUG_STACKOVERFLOW
34 bool "Check for stack overflows" 54 bool "Check for stack overflows"
35 depends on DEBUG_KERNEL 55 depends on DEBUG_KERNEL
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 26d62ff51a64..d10bba5e1074 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -13,10 +13,6 @@
13# for "archclean" and "archdep" for cleaning up and making dependencies for 13# for "archclean" and "archdep" for cleaning up and making dependencies for
14# this architecture 14# this architecture
15# 15#
16
17cflags-y := -mb
18cflags-$(CONFIG_CPU_LITTLE_ENDIAN) := -ml
19
20isa-y := any 16isa-y := any
21isa-$(CONFIG_SH_DSP) := sh 17isa-$(CONFIG_SH_DSP) := sh
22isa-$(CONFIG_CPU_SH2) := sh2 18isa-$(CONFIG_CPU_SH2) := sh2
@@ -38,13 +34,16 @@ isa-y := $(isa-y)-nofpu
38endif 34endif
39endif 35endif
40 36
41cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) 37cflags-$(CONFIG_CPU_SH2) := -m2
42 38cflags-$(CONFIG_CPU_SH3) := -m3
43cflags-$(CONFIG_CPU_SH2) += -m2 39cflags-$(CONFIG_CPU_SH4) := -m4 \
44cflags-$(CONFIG_CPU_SH3) += -m3
45cflags-$(CONFIG_CPU_SH4) += -m4 \
46 $(call cc-option,-mno-implicit-fp,-m4-nofpu) 40 $(call cc-option,-mno-implicit-fp,-m4-nofpu)
47cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a-nofpu,) 41cflags-$(CONFIG_CPU_SH4A) := -m4a $(call cc-option,-m4a-nofpu,)
42
43cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
44cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
45
46cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) -ffreestanding
48 47
49cflags-$(CONFIG_SH_DSP) += -Wa,-dsp 48cflags-$(CONFIG_SH_DSP) += -Wa,-dsp
50cflags-$(CONFIG_SH_KGDB) += -g 49cflags-$(CONFIG_SH_KGDB) += -g
@@ -59,7 +58,9 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -R .stab -R .stabstr -S
59# never be used by anyone. Use a board-specific defconfig that has a 58# never be used by anyone. Use a board-specific defconfig that has a
60# reasonable chance of being current instead. 59# reasonable chance of being current instead.
61# 60#
62KBUILD_DEFCONFIG := rts7751r2d_defconfig 61KBUILD_DEFCONFIG := r7780rp_defconfig
62
63KBUILD_IMAGE := arch/sh/boot/zImage
63 64
64# 65#
65# Choosing incompatible machines durings configuration will result in 66# Choosing incompatible machines durings configuration will result in
@@ -109,6 +110,8 @@ machdir-$(CONFIG_SH_SH4202_MICRODEV) := superh/microdev
109machdir-$(CONFIG_SH_LANDISK) := landisk 110machdir-$(CONFIG_SH_LANDISK) := landisk
110machdir-$(CONFIG_SH_TITAN) := titan 111machdir-$(CONFIG_SH_TITAN) := titan
111machdir-$(CONFIG_SH_SHMIN) := shmin 112machdir-$(CONFIG_SH_SHMIN) := shmin
113machdir-$(CONFIG_SH_7206_SOLUTION_ENGINE) := se/7206
114machdir-$(CONFIG_SH_7619_SOLUTION_ENGINE) := se/7619
112machdir-$(CONFIG_SH_UNKNOWN) := unknown 115machdir-$(CONFIG_SH_UNKNOWN) := unknown
113 116
114incdir-y := $(notdir $(machdir-y)) 117incdir-y := $(notdir $(machdir-y))
@@ -124,6 +127,7 @@ core-$(CONFIG_HD64465) += arch/sh/cchips/hd6446x/hd64465/
124core-$(CONFIG_VOYAGERGX) += arch/sh/cchips/voyagergx/ 127core-$(CONFIG_VOYAGERGX) += arch/sh/cchips/voyagergx/
125 128
126cpuincdir-$(CONFIG_CPU_SH2) := cpu-sh2 129cpuincdir-$(CONFIG_CPU_SH2) := cpu-sh2
130cpuincdir-$(CONFIG_CPU_SH2A) := cpu-sh2a
127cpuincdir-$(CONFIG_CPU_SH3) := cpu-sh3 131cpuincdir-$(CONFIG_CPU_SH3) := cpu-sh3
128cpuincdir-$(CONFIG_CPU_SH4) := cpu-sh4 132cpuincdir-$(CONFIG_CPU_SH4) := cpu-sh4
129 133
diff --git a/arch/sh/boards/renesas/r7780rp/Makefile b/arch/sh/boards/renesas/r7780rp/Makefile
index f1776d027978..574b0316ed56 100644
--- a/arch/sh/boards/renesas/r7780rp/Makefile
+++ b/arch/sh/boards/renesas/r7780rp/Makefile
@@ -3,4 +3,6 @@
3# 3#
4 4
5obj-y := setup.o io.o irq.o 5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o 6
7obj-$(CONFIG_HEARTBEAT) += led.o
8obj-$(CONFIG_PUSH_SWITCH) += psw.o
diff --git a/arch/sh/boards/renesas/r7780rp/irq.c b/arch/sh/boards/renesas/r7780rp/irq.c
index aa15ec5bc69e..cc381e197783 100644
--- a/arch/sh/boards/renesas/r7780rp/irq.c
+++ b/arch/sh/boards/renesas/r7780rp/irq.c
@@ -10,6 +10,7 @@
10 */ 10 */
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <linux/interrupt.h>
13#include <linux/io.h> 14#include <linux/io.h>
14#include <asm/r7780rp.h> 15#include <asm/r7780rp.h>
15 16
diff --git a/arch/sh/boards/renesas/r7780rp/psw.c b/arch/sh/boards/renesas/r7780rp/psw.c
new file mode 100644
index 000000000000..c844dfa5d58d
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/psw.c
@@ -0,0 +1,122 @@
1/*
2 * arch/sh/boards/renesas/r7780rp/psw.c
3 *
4 * push switch support for RDBRP-1/RDBREVRP-1 debug boards.
5 *
6 * Copyright (C) 2006 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/io.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <asm/mach/r7780rp.h>
17#include <asm/push-switch.h>
18
19static irqreturn_t psw_irq_handler(int irq, void *arg)
20{
21 struct platform_device *pdev = arg;
22 struct push_switch *psw = platform_get_drvdata(pdev);
23 struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
24 unsigned int l, mask;
25 int ret = 0;
26
27 l = ctrl_inw(PA_DBSW);
28
29 /* Nothing to do if there's no state change */
30 if (psw->state) {
31 ret = 1;
32 goto out;
33 }
34
35 mask = l & 0x70;
36 /* Figure out who raised it */
37 if (mask & (1 << psw_info->bit)) {
38 psw->state = !!(mask & (1 << psw_info->bit));
39 if (psw->state) /* debounce */
40 mod_timer(&psw->debounce, jiffies + 50);
41
42 ret = 1;
43 }
44
45out:
46 /* Clear the switch IRQs */
47 l |= (0x7 << 12);
48 ctrl_outw(l, PA_DBSW);
49
50 return IRQ_RETVAL(ret);
51}
52
53static struct resource psw_resources[] = {
54 [0] = {
55 .start = IRQ_PSW,
56 .flags = IORESOURCE_IRQ,
57 },
58};
59
60static struct push_switch_platform_info s2_platform_data = {
61 .name = "s2",
62 .bit = 6,
63 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
64 IRQF_SHARED,
65 .irq_handler = psw_irq_handler,
66};
67
68static struct platform_device s2_switch_device = {
69 .name = "push-switch",
70 .id = 0,
71 .num_resources = ARRAY_SIZE(psw_resources),
72 .resource = psw_resources,
73 .dev = {
74 .platform_data = &s2_platform_data,
75 },
76};
77
78static struct push_switch_platform_info s3_platform_data = {
79 .name = "s3",
80 .bit = 5,
81 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
82 IRQF_SHARED,
83 .irq_handler = psw_irq_handler,
84};
85
86static struct platform_device s3_switch_device = {
87 .name = "push-switch",
88 .id = 1,
89 .num_resources = ARRAY_SIZE(psw_resources),
90 .resource = psw_resources,
91 .dev = {
92 .platform_data = &s3_platform_data,
93 },
94};
95
96static struct push_switch_platform_info s4_platform_data = {
97 .name = "s4",
98 .bit = 4,
99 .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
100 IRQF_SHARED,
101 .irq_handler = psw_irq_handler,
102};
103
104static struct platform_device s4_switch_device = {
105 .name = "push-switch",
106 .id = 2,
107 .num_resources = ARRAY_SIZE(psw_resources),
108 .resource = psw_resources,
109 .dev = {
110 .platform_data = &s4_platform_data,
111 },
112};
113
114static struct platform_device *psw_devices[] = {
115 &s2_switch_device, &s3_switch_device, &s4_switch_device,
116};
117
118static int __init psw_init(void)
119{
120 return platform_add_devices(psw_devices, ARRAY_SIZE(psw_devices));
121}
122module_init(psw_init);
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index c331caeb694b..9f89c8de9db9 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -44,8 +44,37 @@ static struct platform_device m66596_usb_host_device = {
44 .resource = m66596_usb_host_resources, 44 .resource = m66596_usb_host_resources,
45}; 45};
46 46
47static struct resource cf_ide_resources[] = {
48 [0] = {
49 .start = 0x1f0,
50 .end = 0x1f0 + 8,
51 .flags = IORESOURCE_IO,
52 },
53 [1] = {
54 .start = 0x1f0 + 0x206,
55 .end = 0x1f0 + 8 + 0x206 + 8,
56 .flags = IORESOURCE_IO,
57 },
58 [2] = {
59#ifdef CONFIG_SH_R7780MP
60 .start = 1,
61#else
62 .start = 4,
63#endif
64 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct platform_device cf_ide_device = {
69 .name = "pata_platform",
70 .id = -1,
71 .num_resources = ARRAY_SIZE(cf_ide_resources),
72 .resource = cf_ide_resources,
73};
74
47static struct platform_device *r7780rp_devices[] __initdata = { 75static struct platform_device *r7780rp_devices[] __initdata = {
48 &m66596_usb_host_device, 76 &m66596_usb_host_device,
77 &cf_ide_device,
49}; 78};
50 79
51static int __init r7780rp_devices_setup(void) 80static int __init r7780rp_devices_setup(void)
diff --git a/arch/sh/boards/se/7206/Makefile b/arch/sh/boards/se/7206/Makefile
new file mode 100644
index 000000000000..63950f4f2453
--- /dev/null
+++ b/arch/sh/boards/se/7206/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the 7206 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o
7
diff --git a/arch/sh/boards/se/7206/io.c b/arch/sh/boards/se/7206/io.c
new file mode 100644
index 000000000000..b557273e0cbe
--- /dev/null
+++ b/arch/sh/boards/se/7206/io.c
@@ -0,0 +1,123 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $
2 *
3 * linux/arch/sh/boards/se/7206/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7206 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7206.h>
15
16
17static inline void delay(void)
18{
19 ctrl_inw(0x20000000); /* P2 ROM Area */
20}
21
22/* MS7750 requires special versions of in*, out* routines, since
23 PC-like io ports are located at upper half byte of 16-bit word which
24 can be accessed only with 16-bit wide. */
25
26static inline volatile __u16 *
27port2adr(unsigned int port)
28{
29 if (port >= 0x2000)
30 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
31 else if (port >= 0x300 || port < 0x310)
32 return (volatile __u16 *) (PA_SMSC + (port - 0x300));
33}
34
35unsigned char se7206_inb(unsigned long port)
36{
37 return (*port2adr(port))&0xff;
38}
39
40unsigned char se7206_inb_p(unsigned long port)
41{
42 unsigned long v;
43
44 v = (*port2adr(port))&0xff;
45 delay();
46 return v;
47}
48
49unsigned short se7206_inw(unsigned long port)
50{
51 return *port2adr(port);;
52}
53
54unsigned int se7206_inl(unsigned long port)
55{
56 maybebadio(port);
57 return 0;
58}
59
60void se7206_outb(unsigned char value, unsigned long port)
61{
62 *(port2adr(port)) = value;
63}
64
65void se7206_outb_p(unsigned char value, unsigned long port)
66{
67 *(port2adr(port)) = value;
68 delay();
69}
70
71void se7206_outw(unsigned short value, unsigned long port)
72{
73 *port2adr(port) = value;
74}
75
76void se7206_outl(unsigned int value, unsigned long port)
77{
78 maybebadio(port);
79}
80
81void se7206_insb(unsigned long port, void *addr, unsigned long count)
82{
83 volatile __u16 *p = port2adr(port);
84 __u8 *ap = addr;
85
86 while (count--)
87 *ap++ = *p;
88}
89
90void se7206_insw(unsigned long port, void *addr, unsigned long count)
91{
92 volatile __u16 *p = port2adr(port);
93 __u16 *ap = addr;
94 while (count--)
95 *ap++ = *p;
96}
97
98void se7206_insl(unsigned long port, void *addr, unsigned long count)
99{
100 maybebadio(port);
101}
102
103void se7206_outsb(unsigned long port, const void *addr, unsigned long count)
104{
105 volatile __u16 *p = port2adr(port);
106 const __u8 *ap = addr;
107
108 while (count--)
109 *p = *ap++;
110}
111
112void se7206_outsw(unsigned long port, const void *addr, unsigned long count)
113{
114 volatile __u16 *p = port2adr(port);
115 const __u16 *ap = addr;
116 while (count--)
117 *p = *ap++;
118}
119
120void se7206_outsl(unsigned long port, const void *addr, unsigned long count)
121{
122 maybebadio(port);
123}
diff --git a/arch/sh/boards/se/7206/irq.c b/arch/sh/boards/se/7206/irq.c
new file mode 100644
index 000000000000..3fb0c5f5b23a
--- /dev/null
+++ b/arch/sh/boards/se/7206/irq.c
@@ -0,0 +1,139 @@
1/*
2 * linux/arch/sh/boards/se/7206/irq.c
3 *
4 * Copyright (C) 2005,2006 Yoshinori Sato
5 *
6 * Hitachi SolutionEngine Support.
7 *
8 */
9#include <linux/init.h>
10#include <linux/irq.h>
11#include <linux/io.h>
12#include <linux/irq.h>
13#include <asm/se7206.h>
14
15#define INTSTS0 0x31800000
16#define INTSTS1 0x31800002
17#define INTMSK0 0x31800004
18#define INTMSK1 0x31800006
19#define INTSEL 0x31800008
20
21static void disable_se7206_irq(unsigned int irq)
22{
23 unsigned short val;
24 unsigned short mask = 0xffff ^ (0x0f << 4 * (3 - (IRQ0_IRQ - irq)));
25 unsigned short msk0,msk1;
26
27 /* Set the priority in IPR to 0 */
28 val = ctrl_inw(INTC_IPR01);
29 val &= mask;
30 ctrl_outw(val, INTC_IPR01);
31 /* FPGA mask set */
32 msk0 = ctrl_inw(INTMSK0);
33 msk1 = ctrl_inw(INTMSK1);
34
35 switch (irq) {
36 case IRQ0_IRQ:
37 msk0 |= 0x0010;
38 break;
39 case IRQ1_IRQ:
40 msk0 |= 0x000f;
41 break;
42 case IRQ2_IRQ:
43 msk0 |= 0x0f00;
44 msk1 |= 0x00ff;
45 break;
46 }
47 ctrl_outw(msk0, INTMSK0);
48 ctrl_outw(msk1, INTMSK1);
49}
50
51static void enable_se7206_irq(unsigned int irq)
52{
53 unsigned short val;
54 unsigned short value = (0x0001 << 4 * (3 - (IRQ0_IRQ - irq)));
55 unsigned short msk0,msk1;
56
57 /* Set priority in IPR back to original value */
58 val = ctrl_inw(INTC_IPR01);
59 val |= value;
60 ctrl_outw(val, INTC_IPR01);
61
62 /* FPGA mask reset */
63 msk0 = ctrl_inw(INTMSK0);
64 msk1 = ctrl_inw(INTMSK1);
65
66 switch (irq) {
67 case IRQ0_IRQ:
68 msk0 &= ~0x0010;
69 break;
70 case IRQ1_IRQ:
71 msk0 &= ~0x000f;
72 break;
73 case IRQ2_IRQ:
74 msk0 &= ~0x0f00;
75 msk1 &= ~0x00ff;
76 break;
77 }
78 ctrl_outw(msk0, INTMSK0);
79 ctrl_outw(msk1, INTMSK1);
80}
81
82static void eoi_se7206_irq(unsigned int irq)
83{
84 unsigned short sts0,sts1;
85
86 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
87 enable_se7206_irq(irq);
88 /* FPGA isr clear */
89 sts0 = ctrl_inw(INTSTS0);
90 sts1 = ctrl_inw(INTSTS1);
91
92 switch (irq) {
93 case IRQ0_IRQ:
94 sts0 &= ~0x0010;
95 break;
96 case IRQ1_IRQ:
97 sts0 &= ~0x000f;
98 break;
99 case IRQ2_IRQ:
100 sts0 &= ~0x0f00;
101 sts1 &= ~0x00ff;
102 break;
103 }
104 ctrl_outw(sts0, INTSTS0);
105 ctrl_outw(sts1, INTSTS1);
106}
107
108static struct irq_chip se7206_irq_chip __read_mostly = {
109 .name = "SE7206-FPGA-IRQ",
110 .mask = disable_se7206_irq,
111 .unmask = enable_se7206_irq,
112 .mask_ack = disable_se7206_irq,
113 .eoi = eoi_se7206_irq,
114};
115
116static void make_se7206_irq(unsigned int irq)
117{
118 disable_irq_nosync(irq);
119 set_irq_chip_and_handler_name(irq, &se7206_irq_chip,
120 handle_level_irq, "level");
121 disable_se7206_irq(irq);
122}
123
124/*
125 * Initialize IRQ setting
126 */
127void __init init_se7206_IRQ(void)
128{
129 make_se7206_irq(IRQ0_IRQ); /* SMC91C111 */
130 make_se7206_irq(IRQ1_IRQ); /* ATA */
131 make_se7206_irq(IRQ3_IRQ); /* SLOT / PCM */
132 ctrl_outw(inw(INTC_ICR1) | 0x000b ,INTC_ICR1 ) ; /* ICR1 */
133
134 /* FPGA System register setup*/
135 ctrl_outw(0x0000,INTSTS0); /* Clear INTSTS0 */
136 ctrl_outw(0x0000,INTSTS1); /* Clear INTSTS1 */
137 /* IRQ0=LAN, IRQ1=ATA, IRQ3=SLT,PCM */
138 ctrl_outw(0x0001,INTSEL);
139}
diff --git a/arch/sh/boards/se/7206/led.c b/arch/sh/boards/se/7206/led.c
new file mode 100644
index 000000000000..ef794601ab86
--- /dev/null
+++ b/arch/sh/boards/se/7206/led.c
@@ -0,0 +1,57 @@
1/*
2 * linux/arch/sh/kernel/led_se.c
3 *
4 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * This file contains Solution Engine specific LED code.
10 */
11
12#include <linux/config.h>
13#include <asm/se7206.h>
14
15#ifdef CONFIG_HEARTBEAT
16
17#include <linux/sched.h>
18
19/* Cycle the LED's in the clasic Knightrider/Sun pattern */
20void heartbeat_se(void)
21{
22 static unsigned int cnt = 0, period = 0;
23 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
24 static unsigned bit = 0, up = 1;
25
26 cnt += 1;
27 if (cnt < period) {
28 return;
29 }
30
31 cnt = 0;
32
33 /* Go through the points (roughly!):
34 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
35 */
36 period = 110 - ( (300<<FSHIFT)/
37 ((avenrun[0]/5) + (3<<FSHIFT)) );
38
39 if (up) {
40 if (bit == 7) {
41 bit--;
42 up=0;
43 } else {
44 bit ++;
45 }
46 } else {
47 if (bit == 0) {
48 bit++;
49 up=1;
50 } else {
51 bit--;
52 }
53 }
54 *p = 1<<(bit+8);
55
56}
57#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/se/7206/setup.c b/arch/sh/boards/se/7206/setup.c
new file mode 100644
index 000000000000..0f42e91a3238
--- /dev/null
+++ b/arch/sh/boards/se/7206/setup.c
@@ -0,0 +1,79 @@
1/*
2 *
3 * linux/arch/sh/boards/se/7206/setup.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * Hitachi 7206 SolutionEngine Support.
8 *
9 */
10
11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <asm/se7206.h>
14#include <asm/io.h>
15#include <asm/machvec.h>
16
17static struct resource smc91x_resources[] = {
18 [0] = {
19 .start = 0x300,
20 .end = 0x300 + 0x020 - 1,
21 .flags = IORESOURCE_MEM,
22 },
23 [1] = {
24 .start = 64,
25 .end = 64,
26 .flags = IORESOURCE_IRQ,
27 },
28};
29
30static struct platform_device smc91x_device = {
31 .name = "smc91x",
32 .id = -1,
33 .num_resources = ARRAY_SIZE(smc91x_resources),
34 .resource = smc91x_resources,
35};
36
37static int __init se7206_devices_setup(void)
38{
39 return platform_device_register(&smc91x_device);
40}
41
42__initcall(se7206_devices_setup);
43
44void heartbeat_se(void);
45
46/*
47 * The Machine Vector
48 */
49
50struct sh_machine_vector mv_se __initmv = {
51 .mv_name = "SolutionEngine",
52 .mv_nr_irqs = 256,
53 .mv_inb = se7206_inb,
54 .mv_inw = se7206_inw,
55 .mv_inl = se7206_inl,
56 .mv_outb = se7206_outb,
57 .mv_outw = se7206_outw,
58 .mv_outl = se7206_outl,
59
60 .mv_inb_p = se7206_inb_p,
61 .mv_inw_p = se7206_inw,
62 .mv_inl_p = se7206_inl,
63 .mv_outb_p = se7206_outb_p,
64 .mv_outw_p = se7206_outw,
65 .mv_outl_p = se7206_outl,
66
67 .mv_insb = se7206_insb,
68 .mv_insw = se7206_insw,
69 .mv_insl = se7206_insl,
70 .mv_outsb = se7206_outsb,
71 .mv_outsw = se7206_outsw,
72 .mv_outsl = se7206_outsl,
73
74 .mv_init_irq = init_se7206_IRQ,
75#ifdef CONFIG_HEARTBEAT
76 .mv_heartbeat = heartbeat_se,
77#endif
78};
79ALIAS_MV(se)
diff --git a/arch/sh/boards/se/7619/Makefile b/arch/sh/boards/se/7619/Makefile
new file mode 100644
index 000000000000..3666eca8a658
--- /dev/null
+++ b/arch/sh/boards/se/7619/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the 7619 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/se/7619/io.c b/arch/sh/boards/se/7619/io.c
new file mode 100644
index 000000000000..176f1f39cd9d
--- /dev/null
+++ b/arch/sh/boards/se/7619/io.c
@@ -0,0 +1,102 @@
1/*
2 *
3 * linux/arch/sh/boards/se/7619/io.c
4 *
5 * Copyright (C) 2006 Yoshinori Sato
6 *
7 * I/O routine for Hitachi 7619 SolutionEngine.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <asm/io.h>
14#include <asm/se7619.h>
15#include <asm/irq.h>
16
17/* FIXME: M3A-ZAB7 Compact Flash Slot support */
18
19static inline void delay(void)
20{
21 ctrl_inw(0xa0000000); /* Uncached ROM area (P2) */
22}
23
24#define badio(name,port) \
25 printk("bad I/O operation (%s) for port 0x%lx at 0x%08x\n", \
26 #name, (port), (__u32) __builtin_return_address(0))
27
28unsigned char se7619___inb(unsigned long port)
29{
30 badio(inb, port);
31 return 0;
32}
33
34unsigned char se7619___inb_p(unsigned long port)
35{
36 badio(inb_p, port);
37 delay();
38 return 0;
39}
40
41unsigned short se7619___inw(unsigned long port)
42{
43 badio(inw, port);
44 return 0;
45}
46
47unsigned int se7619___inl(unsigned long port)
48{
49 badio(inl, port);
50 return 0;
51}
52
53void se7619___outb(unsigned char value, unsigned long port)
54{
55 badio(outb, port);
56}
57
58void se7619___outb_p(unsigned char value, unsigned long port)
59{
60 badio(outb_p, port);
61 delay();
62}
63
64void se7619___outw(unsigned short value, unsigned long port)
65{
66 badio(outw, port);
67}
68
69void se7619___outl(unsigned int value, unsigned long port)
70{
71 badio(outl, port);
72}
73
74void se7619___insb(unsigned long port, void *addr, unsigned long count)
75{
76 badio(inw, port);
77}
78
79void se7619___insw(unsigned long port, void *addr, unsigned long count)
80{
81 badio(inw, port);
82}
83
84void se7619___insl(unsigned long port, void *addr, unsigned long count)
85{
86 badio(insl, port);
87}
88
89void se7619___outsb(unsigned long port, const void *addr, unsigned long count)
90{
91 badio(insl, port);
92}
93
94void se7619___outsw(unsigned long port, const void *addr, unsigned long count)
95{
96 badio(insl, port);
97}
98
99void se7619___outsl(unsigned long port, const void *addr, unsigned long count)
100{
101 badio(outsw, port);
102}
diff --git a/arch/sh/boards/se/7619/setup.c b/arch/sh/boards/se/7619/setup.c
new file mode 100644
index 000000000000..e627b26de0d0
--- /dev/null
+++ b/arch/sh/boards/se/7619/setup.c
@@ -0,0 +1,43 @@
1/*
2 * arch/sh/boards/se/7619/setup.c
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * Hitachi SH7619 SolutionEngine Support.
7 */
8
9#include <linux/init.h>
10#include <linux/platform_device.h>
11#include <asm/io.h>
12#include <asm/se7619.h>
13#include <asm/machvec.h>
14
15/*
16 * The Machine Vector
17 */
18
19struct sh_machine_vector mv_se __initmv = {
20 .mv_name = "SolutionEngine",
21 .mv_nr_irqs = 108,
22 .mv_inb = se7619___inb,
23 .mv_inw = se7619___inw,
24 .mv_inl = se7619___inl,
25 .mv_outb = se7619___outb,
26 .mv_outw = se7619___outw,
27 .mv_outl = se7619___outl,
28
29 .mv_inb_p = se7619___inb_p,
30 .mv_inw_p = se7619___inw,
31 .mv_inl_p = se7619___inl,
32 .mv_outb_p = se7619___outb_p,
33 .mv_outw_p = se7619___outw,
34 .mv_outl_p = se7619___outl,
35
36 .mv_insb = se7619___insb,
37 .mv_insw = se7619___insw,
38 .mv_insl = se7619___insl,
39 .mv_outsb = se7619___outsb,
40 .mv_outsw = se7619___outsw,
41 .mv_outsl = se7619___outsl,
42};
43ALIAS_MV(se)
diff --git a/arch/sh/boards/titan/setup.c b/arch/sh/boards/titan/setup.c
index a6046d93758b..6bcd939bfaed 100644
--- a/arch/sh/boards/titan/setup.c
+++ b/arch/sh/boards/titan/setup.c
@@ -1,26 +1,30 @@
1/* 1/*
2 * Setup for Titan 2 * arch/sh/boards/titan/setup.c - Setup for Titan
3 *
4 * Copyright (C) 2006 Jamie Lenehan
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
3 */ 9 */
4
5#include <linux/init.h> 10#include <linux/init.h>
6#include <asm/irq.h> 11#include <linux/irq.h>
7#include <asm/titan.h> 12#include <asm/titan.h>
8#include <asm/io.h> 13#include <asm/io.h>
9 14
10extern void __init pcibios_init_platform(void);
11
12static struct ipr_data titan_ipr_map[] = { 15static struct ipr_data titan_ipr_map[] = {
13 { TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY }, 16 /* IRQ, IPR idx, shift, prio */
14 { TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY }, 17 { TITAN_IRQ_WAN, 3, 12, 8 }, /* eth0 (WAN) */
15 { TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY }, 18 { TITAN_IRQ_LAN, 3, 8, 8 }, /* eth1 (LAN) */
16 { TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY }, 19 { TITAN_IRQ_MPCIA, 3, 4, 8 }, /* mPCI A (top) */
20 { TITAN_IRQ_USB, 3, 0, 8 }, /* mPCI B (bottom), USB */
17}; 21};
18 22
19static void __init init_titan_irq(void) 23static void __init init_titan_irq(void)
20{ 24{
21 /* enable individual interrupt mode for externals */ 25 /* enable individual interrupt mode for externals */
22 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 26 ipr_irq_enable_irlm();
23 27 /* register ipr irqs */
24 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map)); 28 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map));
25} 29}
26 30
@@ -47,6 +51,5 @@ struct sh_machine_vector mv_titan __initmv = {
47 .mv_ioport_map = titan_ioport_map, 51 .mv_ioport_map = titan_ioport_map,
48 52
49 .mv_init_irq = init_titan_irq, 53 .mv_init_irq = init_titan_irq,
50 .mv_init_pci = pcibios_init_platform,
51}; 54};
52ALIAS_MV(titan) 55ALIAS_MV(titan)
diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
index f2fed5ce5cc3..35452d85b7f7 100644
--- a/arch/sh/boot/compressed/misc.c
+++ b/arch/sh/boot/compressed/misc.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <asm/uaccess.h> 14#include <asm/uaccess.h>
15#include <asm/addrspace.h>
15#ifdef CONFIG_SH_STANDARD_BIOS 16#ifdef CONFIG_SH_STANDARD_BIOS
16#include <asm/sh_bios.h> 17#include <asm/sh_bios.h>
17#endif 18#endif
@@ -228,7 +229,7 @@ long* stack_start = &user_stack[STACK_SIZE];
228void decompress_kernel(void) 229void decompress_kernel(void)
229{ 230{
230 output_data = 0; 231 output_data = 0;
231 output_ptr = (unsigned long)&_text+0x20001000; 232 output_ptr = P2SEGADDR((unsigned long)&_text+0x1000);
232 free_mem_ptr = (unsigned long)&_end; 233 free_mem_ptr = (unsigned long)&_end;
233 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE; 234 free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
234 235
diff --git a/arch/sh/configs/r7780rp_defconfig b/arch/sh/configs/r7780rp_defconfig
index 34e2046c3213..2b75b4896ba5 100644
--- a/arch/sh/configs/r7780rp_defconfig
+++ b/arch/sh/configs/r7780rp_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.19-rc3 3# Linux kernel version: 2.6.19
4# Tue Oct 31 12:32:06 2006 4# Wed Dec 6 11:59:38 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -11,6 +11,8 @@ CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set 13# CONFIG_GENERIC_TIME is not set
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_LOCKDEP_SUPPORT=y
14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 16CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
15 17
16# 18#
@@ -37,6 +39,7 @@ CONFIG_BSD_PROCESS_ACCT=y
37# CONFIG_AUDIT is not set 39# CONFIG_AUDIT is not set
38CONFIG_IKCONFIG=y 40CONFIG_IKCONFIG=y
39CONFIG_IKCONFIG_PROC=y 41CONFIG_IKCONFIG_PROC=y
42# CONFIG_SYSFS_DEPRECATED is not set
40# CONFIG_RELAY is not set 43# CONFIG_RELAY is not set
41CONFIG_INITRAMFS_SOURCE="" 44CONFIG_INITRAMFS_SOURCE=""
42CONFIG_CC_OPTIMIZE_FOR_SIZE=y 45CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -118,6 +121,8 @@ CONFIG_SH_R7780RP=y
118# CONFIG_SH_LANDISK is not set 121# CONFIG_SH_LANDISK is not set
119# CONFIG_SH_TITAN is not set 122# CONFIG_SH_TITAN is not set
120# CONFIG_SH_SHMIN is not set 123# CONFIG_SH_SHMIN is not set
124# CONFIG_SH_7206_SOLUTION_ENGINE is not set
125# CONFIG_SH_7619_SOLUTION_ENGINE is not set
121# CONFIG_SH_UNKNOWN is not set 126# CONFIG_SH_UNKNOWN is not set
122 127
123# 128#
@@ -130,6 +135,12 @@ CONFIG_CPU_SH4A=y
130# SH-2 Processor Support 135# SH-2 Processor Support
131# 136#
132# CONFIG_CPU_SUBTYPE_SH7604 is not set 137# CONFIG_CPU_SUBTYPE_SH7604 is not set
138# CONFIG_CPU_SUBTYPE_SH7619 is not set
139
140#
141# SH-2A Processor Support
142#
143# CONFIG_CPU_SUBTYPE_SH7206 is not set
133 144
134# 145#
135# SH-3 Processor Support 146# SH-3 Processor Support
@@ -165,6 +176,7 @@ CONFIG_CPU_SH4A=y
165# 176#
166# CONFIG_CPU_SUBTYPE_SH7770 is not set 177# CONFIG_CPU_SUBTYPE_SH7770 is not set
167CONFIG_CPU_SUBTYPE_SH7780=y 178CONFIG_CPU_SUBTYPE_SH7780=y
179# CONFIG_CPU_SUBTYPE_SH7785 is not set
168 180
169# 181#
170# SH4AL-DSP Processor Support 182# SH4AL-DSP Processor Support
@@ -181,8 +193,14 @@ CONFIG_MEMORY_START=0x08000000
181CONFIG_MEMORY_SIZE=0x08000000 193CONFIG_MEMORY_SIZE=0x08000000
182# CONFIG_32BIT is not set 194# CONFIG_32BIT is not set
183CONFIG_VSYSCALL=y 195CONFIG_VSYSCALL=y
196CONFIG_PAGE_SIZE_4KB=y
197# CONFIG_PAGE_SIZE_8KB is not set
198# CONFIG_PAGE_SIZE_64KB is not set
184CONFIG_HUGETLB_PAGE_SIZE_64K=y 199CONFIG_HUGETLB_PAGE_SIZE_64K=y
200# CONFIG_HUGETLB_PAGE_SIZE_256K is not set
185# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set 201# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
202# CONFIG_HUGETLB_PAGE_SIZE_4MB is not set
203# CONFIG_HUGETLB_PAGE_SIZE_64MB is not set
186CONFIG_SELECT_MEMORY_MODEL=y 204CONFIG_SELECT_MEMORY_MODEL=y
187CONFIG_FLATMEM_MANUAL=y 205CONFIG_FLATMEM_MANUAL=y
188# CONFIG_DISCONTIGMEM_MANUAL is not set 206# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -204,12 +222,14 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
204# Processor features 222# Processor features
205# 223#
206CONFIG_CPU_LITTLE_ENDIAN=y 224CONFIG_CPU_LITTLE_ENDIAN=y
225# CONFIG_CPU_BIG_ENDIAN is not set
207CONFIG_SH_FPU=y 226CONFIG_SH_FPU=y
208# CONFIG_SH_DSP is not set 227# CONFIG_SH_DSP is not set
209CONFIG_SH_STORE_QUEUES=y 228CONFIG_SH_STORE_QUEUES=y
210CONFIG_CPU_HAS_INTEVT=y 229CONFIG_CPU_HAS_INTEVT=y
211CONFIG_CPU_HAS_INTC2_IRQ=y 230CONFIG_CPU_HAS_INTC2_IRQ=y
212CONFIG_CPU_HAS_SR_RB=y 231CONFIG_CPU_HAS_SR_RB=y
232CONFIG_CPU_HAS_PTEA=y
213 233
214# 234#
215# Timer support 235# Timer support
@@ -220,6 +240,8 @@ CONFIG_SH_TMU=y
220# R7780RP options 240# R7780RP options
221# 241#
222CONFIG_SH_R7780MP=y 242CONFIG_SH_R7780MP=y
243CONFIG_SH_TIMER_IRQ=28
244CONFIG_NO_IDLE_HZ=y
223CONFIG_SH_PCLK_FREQ=32000000 245CONFIG_SH_PCLK_FREQ=32000000
224 246
225# 247#
@@ -238,13 +260,18 @@ CONFIG_SH_PCLK_FREQ=32000000
238# CONFIG_HD6446X_SERIES is not set 260# CONFIG_HD6446X_SERIES is not set
239 261
240# 262#
263# Additional SuperH Device Drivers
264#
265CONFIG_PUSH_SWITCH=y
266
267#
241# Kernel features 268# Kernel features
242# 269#
243# CONFIG_HZ_100 is not set 270# CONFIG_HZ_100 is not set
244CONFIG_HZ_250=y 271CONFIG_HZ_250=y
245# CONFIG_HZ_1000 is not set 272# CONFIG_HZ_1000 is not set
246CONFIG_HZ=250 273CONFIG_HZ=250
247# CONFIG_KEXEC is not set 274CONFIG_KEXEC=y
248# CONFIG_SMP is not set 275# CONFIG_SMP is not set
249# CONFIG_PREEMPT_NONE is not set 276# CONFIG_PREEMPT_NONE is not set
250# CONFIG_PREEMPT_VOLUNTARY is not set 277# CONFIG_PREEMPT_VOLUNTARY is not set
@@ -278,10 +305,7 @@ CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
278# 305#
279# PCI Hotplug Support 306# PCI Hotplug Support
280# 307#
281CONFIG_HOTPLUG_PCI=y 308# CONFIG_HOTPLUG_PCI is not set
282# CONFIG_HOTPLUG_PCI_FAKE is not set
283# CONFIG_HOTPLUG_PCI_CPCI is not set
284# CONFIG_HOTPLUG_PCI_SHPC is not set
285 309
286# 310#
287# Executable file formats 311# Executable file formats
@@ -341,6 +365,7 @@ CONFIG_INET_TCP_DIAG=y
341# CONFIG_TCP_CONG_ADVANCED is not set 365# CONFIG_TCP_CONG_ADVANCED is not set
342CONFIG_TCP_CONG_CUBIC=y 366CONFIG_TCP_CONG_CUBIC=y
343CONFIG_DEFAULT_TCP_CONG="cubic" 367CONFIG_DEFAULT_TCP_CONG="cubic"
368# CONFIG_TCP_MD5SIG is not set
344# CONFIG_IPV6 is not set 369# CONFIG_IPV6 is not set
345# CONFIG_INET6_XFRM_TUNNEL is not set 370# CONFIG_INET6_XFRM_TUNNEL is not set
346# CONFIG_INET6_TUNNEL is not set 371# CONFIG_INET6_TUNNEL is not set
@@ -556,6 +581,7 @@ CONFIG_SATA_SIL=y
556# CONFIG_PATA_IT821X is not set 581# CONFIG_PATA_IT821X is not set
557# CONFIG_PATA_JMICRON is not set 582# CONFIG_PATA_JMICRON is not set
558# CONFIG_PATA_TRIFLEX is not set 583# CONFIG_PATA_TRIFLEX is not set
584# CONFIG_PATA_MARVELL is not set
559# CONFIG_PATA_MPIIX is not set 585# CONFIG_PATA_MPIIX is not set
560# CONFIG_PATA_OLDPIIX is not set 586# CONFIG_PATA_OLDPIIX is not set
561# CONFIG_PATA_NETCELL is not set 587# CONFIG_PATA_NETCELL is not set
@@ -572,6 +598,7 @@ CONFIG_SATA_SIL=y
572# CONFIG_PATA_SIS is not set 598# CONFIG_PATA_SIS is not set
573# CONFIG_PATA_VIA is not set 599# CONFIG_PATA_VIA is not set
574# CONFIG_PATA_WINBOND is not set 600# CONFIG_PATA_WINBOND is not set
601CONFIG_PATA_PLATFORM=y
575 602
576# 603#
577# Multi-device support (RAID and LVM) 604# Multi-device support (RAID and LVM)
@@ -688,6 +715,7 @@ CONFIG_R8169=y
688# CONFIG_IXGB is not set 715# CONFIG_IXGB is not set
689# CONFIG_S2IO is not set 716# CONFIG_S2IO is not set
690# CONFIG_MYRI10GE is not set 717# CONFIG_MYRI10GE is not set
718# CONFIG_NETXEN_NIC is not set
691 719
692# 720#
693# Token Ring devices 721# Token Ring devices
@@ -830,10 +858,6 @@ CONFIG_HW_RANDOM=y
830# CONFIG_DTLK is not set 858# CONFIG_DTLK is not set
831# CONFIG_R3964 is not set 859# CONFIG_R3964 is not set
832# CONFIG_APPLICOM is not set 860# CONFIG_APPLICOM is not set
833
834#
835# Ftape, the floppy tape device driver
836#
837# CONFIG_DRM is not set 861# CONFIG_DRM is not set
838# CONFIG_RAW_DRIVER is not set 862# CONFIG_RAW_DRIVER is not set
839 863
@@ -1020,7 +1044,7 @@ CONFIG_INOTIFY_USER=y
1020CONFIG_DNOTIFY=y 1044CONFIG_DNOTIFY=y
1021# CONFIG_AUTOFS_FS is not set 1045# CONFIG_AUTOFS_FS is not set
1022# CONFIG_AUTOFS4_FS is not set 1046# CONFIG_AUTOFS4_FS is not set
1023# CONFIG_FUSE_FS is not set 1047CONFIG_FUSE_FS=m
1024 1048
1025# 1049#
1026# CD-ROM/DVD Filesystems 1050# CD-ROM/DVD Filesystems
@@ -1052,7 +1076,7 @@ CONFIG_TMPFS=y
1052CONFIG_HUGETLBFS=y 1076CONFIG_HUGETLBFS=y
1053CONFIG_HUGETLB_PAGE=y 1077CONFIG_HUGETLB_PAGE=y
1054CONFIG_RAMFS=y 1078CONFIG_RAMFS=y
1055# CONFIG_CONFIGFS_FS is not set 1079CONFIG_CONFIGFS_FS=m
1056 1080
1057# 1081#
1058# Miscellaneous filesystems 1082# Miscellaneous filesystems
@@ -1153,28 +1177,33 @@ CONFIG_NLS_ISO8859_1=y
1153# 1177#
1154# Profiling support 1178# Profiling support
1155# 1179#
1156# CONFIG_PROFILING is not set 1180CONFIG_PROFILING=y
1181CONFIG_OPROFILE=m
1157 1182
1158# 1183#
1159# Kernel hacking 1184# Kernel hacking
1160# 1185#
1161# CONFIG_PRINTK_TIME is not set 1186CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1187CONFIG_PRINTK_TIME=y
1162CONFIG_ENABLE_MUST_CHECK=y 1188CONFIG_ENABLE_MUST_CHECK=y
1163# CONFIG_MAGIC_SYSRQ is not set 1189CONFIG_MAGIC_SYSRQ=y
1164# CONFIG_UNUSED_SYMBOLS is not set 1190# CONFIG_UNUSED_SYMBOLS is not set
1165CONFIG_DEBUG_KERNEL=y 1191CONFIG_DEBUG_KERNEL=y
1166CONFIG_LOG_BUF_SHIFT=14 1192CONFIG_LOG_BUF_SHIFT=14
1167CONFIG_DETECT_SOFTLOCKUP=y 1193CONFIG_DETECT_SOFTLOCKUP=y
1168# CONFIG_SCHEDSTATS is not set 1194# CONFIG_SCHEDSTATS is not set
1169# CONFIG_DEBUG_SLAB is not set 1195# CONFIG_DEBUG_SLAB is not set
1170CONFIG_DEBUG_SPINLOCK=y 1196# CONFIG_DEBUG_PREEMPT is not set
1197# CONFIG_DEBUG_SPINLOCK is not set
1171# CONFIG_DEBUG_MUTEXES is not set 1198# CONFIG_DEBUG_MUTEXES is not set
1172# CONFIG_DEBUG_RWSEMS is not set 1199# CONFIG_DEBUG_RWSEMS is not set
1200# CONFIG_DEBUG_LOCK_ALLOC is not set
1201# CONFIG_PROVE_LOCKING is not set
1173# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1202# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1174# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1203# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1175# CONFIG_DEBUG_KOBJECT is not set 1204# CONFIG_DEBUG_KOBJECT is not set
1176# CONFIG_DEBUG_BUGVERBOSE is not set 1205CONFIG_DEBUG_BUGVERBOSE=y
1177# CONFIG_DEBUG_INFO is not set 1206CONFIG_DEBUG_INFO=y
1178CONFIG_DEBUG_FS=y 1207CONFIG_DEBUG_FS=y
1179# CONFIG_DEBUG_VM is not set 1208# CONFIG_DEBUG_VM is not set
1180# CONFIG_DEBUG_LIST is not set 1209# CONFIG_DEBUG_LIST is not set
@@ -1184,7 +1213,7 @@ CONFIG_FORCED_INLINING=y
1184# CONFIG_RCU_TORTURE_TEST is not set 1213# CONFIG_RCU_TORTURE_TEST is not set
1185# CONFIG_SH_STANDARD_BIOS is not set 1214# CONFIG_SH_STANDARD_BIOS is not set
1186# CONFIG_EARLY_SCIF_CONSOLE is not set 1215# CONFIG_EARLY_SCIF_CONSOLE is not set
1187# CONFIG_DEBUG_STACKOVERFLOW is not set 1216CONFIG_DEBUG_STACKOVERFLOW=y
1188# CONFIG_DEBUG_STACK_USAGE is not set 1217# CONFIG_DEBUG_STACK_USAGE is not set
1189# CONFIG_4KSTACKS is not set 1218# CONFIG_4KSTACKS is not set
1190# CONFIG_KGDB is not set 1219# CONFIG_KGDB is not set
diff --git a/arch/sh/configs/se7206_defconfig b/arch/sh/configs/se7206_defconfig
new file mode 100644
index 000000000000..36cec0b6e7c1
--- /dev/null
+++ b/arch/sh/configs/se7206_defconfig
@@ -0,0 +1,826 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc4
4# Sun Nov 5 16:20:10 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
15
16#
17# Code maturity level options
18#
19CONFIG_EXPERIMENTAL=y
20CONFIG_BROKEN_ON_SMP=y
21CONFIG_INIT_ENV_ARG_LIMIT=32
22
23#
24# General setup
25#
26CONFIG_LOCALVERSION=""
27# CONFIG_LOCALVERSION_AUTO is not set
28# CONFIG_SYSVIPC is not set
29# CONFIG_POSIX_MQUEUE is not set
30# CONFIG_BSD_PROCESS_ACCT is not set
31# CONFIG_TASKSTATS is not set
32# CONFIG_UTS_NS is not set
33# CONFIG_AUDIT is not set
34# CONFIG_IKCONFIG is not set
35# CONFIG_RELAY is not set
36CONFIG_INITRAMFS_SOURCE=""
37# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
38CONFIG_SYSCTL=y
39CONFIG_EMBEDDED=y
40CONFIG_UID16=y
41# CONFIG_SYSCTL_SYSCALL is not set
42CONFIG_KALLSYMS=y
43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44# CONFIG_HOTPLUG is not set
45CONFIG_PRINTK=y
46CONFIG_BUG=y
47CONFIG_ELF_CORE=y
48CONFIG_BASE_FULL=y
49# CONFIG_FUTEX is not set
50# CONFIG_EPOLL is not set
51CONFIG_SLAB=y
52CONFIG_VM_EVENT_COUNTERS=y
53CONFIG_TINY_SHMEM=y
54CONFIG_BASE_SMALL=0
55# CONFIG_SLOB is not set
56
57#
58# Loadable module support
59#
60# CONFIG_MODULES is not set
61
62#
63# Block layer
64#
65CONFIG_BLOCK=y
66# CONFIG_LBD is not set
67# CONFIG_LSF is not set
68
69#
70# IO Schedulers
71#
72CONFIG_IOSCHED_NOOP=y
73# CONFIG_IOSCHED_AS is not set
74# CONFIG_IOSCHED_DEADLINE is not set
75# CONFIG_IOSCHED_CFQ is not set
76# CONFIG_DEFAULT_AS is not set
77# CONFIG_DEFAULT_DEADLINE is not set
78# CONFIG_DEFAULT_CFQ is not set
79CONFIG_DEFAULT_NOOP=y
80CONFIG_DEFAULT_IOSCHED="noop"
81
82#
83# System type
84#
85# CONFIG_SH_SOLUTION_ENGINE is not set
86# CONFIG_SH_7751_SOLUTION_ENGINE is not set
87# CONFIG_SH_7300_SOLUTION_ENGINE is not set
88# CONFIG_SH_7343_SOLUTION_ENGINE is not set
89# CONFIG_SH_73180_SOLUTION_ENGINE is not set
90# CONFIG_SH_7751_SYSTEMH is not set
91# CONFIG_SH_HP6XX is not set
92# CONFIG_SH_EC3104 is not set
93# CONFIG_SH_SATURN is not set
94# CONFIG_SH_DREAMCAST is not set
95# CONFIG_SH_BIGSUR is not set
96# CONFIG_SH_MPC1211 is not set
97# CONFIG_SH_SH03 is not set
98# CONFIG_SH_SECUREEDGE5410 is not set
99# CONFIG_SH_HS7751RVOIP is not set
100# CONFIG_SH_7710VOIPGW is not set
101# CONFIG_SH_RTS7751R2D is not set
102# CONFIG_SH_R7780RP is not set
103# CONFIG_SH_EDOSK7705 is not set
104# CONFIG_SH_SH4202_MICRODEV is not set
105# CONFIG_SH_LANDISK is not set
106# CONFIG_SH_TITAN is not set
107# CONFIG_SH_SHMIN is not set
108CONFIG_SH_7206_SOLUTION_ENGINE=y
109# CONFIG_SH_7619_SOLUTION_ENGINE is not set
110# CONFIG_SH_UNKNOWN is not set
111
112#
113# Processor selection
114#
115CONFIG_CPU_SH2=y
116CONFIG_CPU_SH2A=y
117
118#
119# SH-2 Processor Support
120#
121# CONFIG_CPU_SUBTYPE_SH7604 is not set
122# CONFIG_CPU_SUBTYPE_SH7619 is not set
123
124#
125# SH-2A Processor Support
126#
127CONFIG_CPU_SUBTYPE_SH7206=y
128
129#
130# SH-3 Processor Support
131#
132# CONFIG_CPU_SUBTYPE_SH7300 is not set
133# CONFIG_CPU_SUBTYPE_SH7705 is not set
134# CONFIG_CPU_SUBTYPE_SH7706 is not set
135# CONFIG_CPU_SUBTYPE_SH7707 is not set
136# CONFIG_CPU_SUBTYPE_SH7708 is not set
137# CONFIG_CPU_SUBTYPE_SH7709 is not set
138# CONFIG_CPU_SUBTYPE_SH7710 is not set
139
140#
141# SH-4 Processor Support
142#
143# CONFIG_CPU_SUBTYPE_SH7750 is not set
144# CONFIG_CPU_SUBTYPE_SH7091 is not set
145# CONFIG_CPU_SUBTYPE_SH7750R is not set
146# CONFIG_CPU_SUBTYPE_SH7750S is not set
147# CONFIG_CPU_SUBTYPE_SH7751 is not set
148# CONFIG_CPU_SUBTYPE_SH7751R is not set
149# CONFIG_CPU_SUBTYPE_SH7760 is not set
150# CONFIG_CPU_SUBTYPE_SH4_202 is not set
151
152#
153# ST40 Processor Support
154#
155# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
156# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
157
158#
159# SH-4A Processor Support
160#
161# CONFIG_CPU_SUBTYPE_SH7770 is not set
162# CONFIG_CPU_SUBTYPE_SH7780 is not set
163
164#
165# SH4AL-DSP Processor Support
166#
167# CONFIG_CPU_SUBTYPE_SH73180 is not set
168# CONFIG_CPU_SUBTYPE_SH7343 is not set
169
170#
171# Memory management options
172#
173CONFIG_PAGE_OFFSET=0x00000000
174CONFIG_MEMORY_START=0x0c000000
175CONFIG_MEMORY_SIZE=0x02000000
176CONFIG_SELECT_MEMORY_MODEL=y
177CONFIG_FLATMEM_MANUAL=y
178# CONFIG_DISCONTIGMEM_MANUAL is not set
179# CONFIG_SPARSEMEM_MANUAL is not set
180CONFIG_FLATMEM=y
181CONFIG_FLAT_NODE_MEM_MAP=y
182# CONFIG_SPARSEMEM_STATIC is not set
183CONFIG_SPLIT_PTLOCK_CPUS=4
184# CONFIG_RESOURCES_64BIT is not set
185
186#
187# Cache configuration
188#
189# CONFIG_SH_DIRECT_MAPPED is not set
190# CONFIG_SH_WRITETHROUGH is not set
191# CONFIG_SH_OCRAM is not set
192
193#
194# Processor features
195#
196# CONFIG_CPU_LITTLE_ENDIAN is not set
197# CONFIG_SH_FPU is not set
198# CONFIG_SH_FPU_EMU is not set
199# CONFIG_SH_DSP is not set
200
201#
202# Timer support
203#
204CONFIG_SH_CMT=y
205# CONFIG_SH_MTU2 is not set
206CONFIG_SH_PCLK_FREQ=33333333
207CONFIG_SH_CLK_MD=6
208
209#
210# CPU Frequency scaling
211#
212# CONFIG_CPU_FREQ is not set
213
214#
215# DMA support
216#
217# CONFIG_SH_DMA is not set
218
219#
220# Companion Chips
221#
222# CONFIG_HD6446X_SERIES is not set
223
224#
225# Kernel features
226#
227CONFIG_HZ_100=y
228# CONFIG_HZ_250 is not set
229# CONFIG_HZ_1000 is not set
230CONFIG_HZ=100
231# CONFIG_KEXEC is not set
232# CONFIG_SMP is not set
233CONFIG_PREEMPT_NONE=y
234# CONFIG_PREEMPT_VOLUNTARY is not set
235# CONFIG_PREEMPT is not set
236
237#
238# Boot options
239#
240CONFIG_ZERO_PAGE_OFFSET=0x00001000
241CONFIG_BOOT_LINK_OFFSET=0x00800000
242# CONFIG_UBC_WAKEUP is not set
243# CONFIG_CMDLINE_BOOL is not set
244
245#
246# Bus options
247#
248# CONFIG_PCI is not set
249
250#
251# PCCARD (PCMCIA/CardBus) support
252#
253
254#
255# PCI Hotplug Support
256#
257
258#
259# Executable file formats
260#
261CONFIG_BINFMT_FLAT=y
262CONFIG_BINFMT_ZFLAT=y
263# CONFIG_BINFMT_SHARED_FLAT is not set
264# CONFIG_BINFMT_MISC is not set
265
266#
267# Power management options (EXPERIMENTAL)
268#
269# CONFIG_PM is not set
270
271#
272# Networking
273#
274CONFIG_NET=y
275
276#
277# Networking options
278#
279# CONFIG_NETDEBUG is not set
280# CONFIG_PACKET is not set
281# CONFIG_UNIX is not set
282CONFIG_XFRM=y
283# CONFIG_XFRM_USER is not set
284# CONFIG_XFRM_SUB_POLICY is not set
285# CONFIG_NET_KEY is not set
286CONFIG_INET=y
287# CONFIG_IP_MULTICAST is not set
288# CONFIG_IP_ADVANCED_ROUTER is not set
289CONFIG_IP_FIB_HASH=y
290# CONFIG_IP_PNP is not set
291# CONFIG_NET_IPIP is not set
292# CONFIG_NET_IPGRE is not set
293# CONFIG_ARPD is not set
294# CONFIG_SYN_COOKIES is not set
295# CONFIG_INET_AH is not set
296# CONFIG_INET_ESP is not set
297# CONFIG_INET_IPCOMP is not set
298# CONFIG_INET_XFRM_TUNNEL is not set
299# CONFIG_INET_TUNNEL is not set
300CONFIG_INET_XFRM_MODE_TRANSPORT=y
301CONFIG_INET_XFRM_MODE_TUNNEL=y
302CONFIG_INET_XFRM_MODE_BEET=y
303# CONFIG_INET_DIAG is not set
304# CONFIG_TCP_CONG_ADVANCED is not set
305CONFIG_TCP_CONG_CUBIC=y
306CONFIG_DEFAULT_TCP_CONG="cubic"
307# CONFIG_IPV6 is not set
308# CONFIG_INET6_XFRM_TUNNEL is not set
309# CONFIG_INET6_TUNNEL is not set
310# CONFIG_NETWORK_SECMARK is not set
311# CONFIG_NETFILTER is not set
312
313#
314# DCCP Configuration (EXPERIMENTAL)
315#
316# CONFIG_IP_DCCP is not set
317
318#
319# SCTP Configuration (EXPERIMENTAL)
320#
321# CONFIG_IP_SCTP is not set
322
323#
324# TIPC Configuration (EXPERIMENTAL)
325#
326# CONFIG_TIPC is not set
327# CONFIG_ATM is not set
328# CONFIG_BRIDGE is not set
329# CONFIG_VLAN_8021Q is not set
330# CONFIG_DECNET is not set
331# CONFIG_LLC2 is not set
332# CONFIG_IPX is not set
333# CONFIG_ATALK is not set
334# CONFIG_X25 is not set
335# CONFIG_LAPB is not set
336# CONFIG_ECONET is not set
337# CONFIG_WAN_ROUTER is not set
338
339#
340# QoS and/or fair queueing
341#
342# CONFIG_NET_SCHED is not set
343
344#
345# Network testing
346#
347# CONFIG_NET_PKTGEN is not set
348# CONFIG_HAMRADIO is not set
349# CONFIG_IRDA is not set
350# CONFIG_BT is not set
351# CONFIG_IEEE80211 is not set
352
353#
354# Device Drivers
355#
356
357#
358# Generic Driver Options
359#
360# CONFIG_STANDALONE is not set
361# CONFIG_PREVENT_FIRMWARE_BUILD is not set
362# CONFIG_SYS_HYPERVISOR is not set
363
364#
365# Connector - unified userspace <-> kernelspace linker
366#
367# CONFIG_CONNECTOR is not set
368
369#
370# Memory Technology Devices (MTD)
371#
372CONFIG_MTD=y
373# CONFIG_MTD_DEBUG is not set
374# CONFIG_MTD_CONCAT is not set
375CONFIG_MTD_PARTITIONS=y
376CONFIG_MTD_REDBOOT_PARTS=y
377CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
378# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
379# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
380# CONFIG_MTD_CMDLINE_PARTS is not set
381
382#
383# User Modules And Translation Layers
384#
385CONFIG_MTD_CHAR=y
386CONFIG_MTD_BLOCK=y
387# CONFIG_FTL is not set
388# CONFIG_NFTL is not set
389# CONFIG_INFTL is not set
390# CONFIG_RFD_FTL is not set
391# CONFIG_SSFDC is not set
392
393#
394# RAM/ROM/Flash chip drivers
395#
396CONFIG_MTD_CFI=y
397# CONFIG_MTD_JEDECPROBE is not set
398CONFIG_MTD_GEN_PROBE=y
399# CONFIG_MTD_CFI_ADV_OPTIONS is not set
400CONFIG_MTD_MAP_BANK_WIDTH_1=y
401CONFIG_MTD_MAP_BANK_WIDTH_2=y
402CONFIG_MTD_MAP_BANK_WIDTH_4=y
403# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
404# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
405# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
406CONFIG_MTD_CFI_I1=y
407CONFIG_MTD_CFI_I2=y
408# CONFIG_MTD_CFI_I4 is not set
409# CONFIG_MTD_CFI_I8 is not set
410# CONFIG_MTD_CFI_INTELEXT is not set
411CONFIG_MTD_CFI_AMDSTD=y
412# CONFIG_MTD_CFI_STAA is not set
413CONFIG_MTD_CFI_UTIL=y
414# CONFIG_MTD_RAM is not set
415# CONFIG_MTD_ROM is not set
416# CONFIG_MTD_ABSENT is not set
417# CONFIG_MTD_OBSOLETE_CHIPS is not set
418
419#
420# Mapping drivers for chip access
421#
422# CONFIG_MTD_COMPLEX_MAPPINGS is not set
423CONFIG_MTD_PHYSMAP=y
424CONFIG_MTD_PHYSMAP_START=0x20000000
425CONFIG_MTD_PHYSMAP_LEN=0x1000000
426CONFIG_MTD_PHYSMAP_BANKWIDTH=4
427# CONFIG_MTD_SOLUTIONENGINE is not set
428# CONFIG_MTD_UCLINUX is not set
429# CONFIG_MTD_PLATRAM is not set
430
431#
432# Self-contained MTD device drivers
433#
434# CONFIG_MTD_SLRAM is not set
435# CONFIG_MTD_PHRAM is not set
436# CONFIG_MTD_MTDRAM is not set
437# CONFIG_MTD_BLOCK2MTD is not set
438
439#
440# Disk-On-Chip Device Drivers
441#
442# CONFIG_MTD_DOC2000 is not set
443# CONFIG_MTD_DOC2001 is not set
444# CONFIG_MTD_DOC2001PLUS is not set
445
446#
447# NAND Flash Device Drivers
448#
449# CONFIG_MTD_NAND is not set
450
451#
452# OneNAND Flash Device Drivers
453#
454# CONFIG_MTD_ONENAND is not set
455
456#
457# Parallel port support
458#
459# CONFIG_PARPORT is not set
460
461#
462# Plug and Play support
463#
464
465#
466# Block devices
467#
468# CONFIG_BLK_DEV_COW_COMMON is not set
469# CONFIG_BLK_DEV_LOOP is not set
470# CONFIG_BLK_DEV_NBD is not set
471CONFIG_BLK_DEV_RAM=y
472CONFIG_BLK_DEV_RAM_COUNT=16
473CONFIG_BLK_DEV_RAM_SIZE=4096
474CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
475# CONFIG_BLK_DEV_INITRD is not set
476# CONFIG_CDROM_PKTCDVD is not set
477# CONFIG_ATA_OVER_ETH is not set
478
479#
480# Misc devices
481#
482# CONFIG_TIFM_CORE is not set
483
484#
485# ATA/ATAPI/MFM/RLL support
486#
487# CONFIG_IDE is not set
488
489#
490# SCSI device support
491#
492# CONFIG_RAID_ATTRS is not set
493# CONFIG_SCSI is not set
494# CONFIG_SCSI_NETLINK is not set
495
496#
497# Serial ATA (prod) and Parallel ATA (experimental) drivers
498#
499# CONFIG_ATA is not set
500
501#
502# Multi-device support (RAID and LVM)
503#
504# CONFIG_MD is not set
505
506#
507# Fusion MPT device support
508#
509# CONFIG_FUSION is not set
510
511#
512# IEEE 1394 (FireWire) support
513#
514
515#
516# I2O device support
517#
518
519#
520# Network device support
521#
522# CONFIG_NETDEVICES is not set
523# CONFIG_NETPOLL is not set
524# CONFIG_NET_POLL_CONTROLLER is not set
525
526#
527# ISDN subsystem
528#
529# CONFIG_ISDN is not set
530
531#
532# Telephony Support
533#
534# CONFIG_PHONE is not set
535
536#
537# Input device support
538#
539# CONFIG_INPUT is not set
540
541#
542# Hardware I/O ports
543#
544# CONFIG_SERIO is not set
545# CONFIG_GAMEPORT is not set
546
547#
548# Character devices
549#
550# CONFIG_VT is not set
551# CONFIG_SERIAL_NONSTANDARD is not set
552
553#
554# Serial drivers
555#
556# CONFIG_SERIAL_8250 is not set
557
558#
559# Non-8250 serial port support
560#
561CONFIG_SERIAL_SH_SCI=y
562CONFIG_SERIAL_SH_SCI_NR_UARTS=4
563CONFIG_SERIAL_SH_SCI_CONSOLE=y
564CONFIG_SERIAL_CORE=y
565CONFIG_SERIAL_CORE_CONSOLE=y
566# CONFIG_UNIX98_PTYS is not set
567CONFIG_LEGACY_PTYS=y
568CONFIG_LEGACY_PTY_COUNT=256
569
570#
571# IPMI
572#
573# CONFIG_IPMI_HANDLER is not set
574
575#
576# Watchdog Cards
577#
578# CONFIG_WATCHDOG is not set
579CONFIG_HW_RANDOM=y
580# CONFIG_GEN_RTC is not set
581# CONFIG_DTLK is not set
582# CONFIG_R3964 is not set
583
584#
585# Ftape, the floppy tape device driver
586#
587# CONFIG_RAW_DRIVER is not set
588
589#
590# TPM devices
591#
592# CONFIG_TCG_TPM is not set
593
594#
595# I2C support
596#
597# CONFIG_I2C is not set
598
599#
600# SPI support
601#
602# CONFIG_SPI is not set
603# CONFIG_SPI_MASTER is not set
604
605#
606# Dallas's 1-wire bus
607#
608# CONFIG_W1 is not set
609
610#
611# Hardware Monitoring support
612#
613CONFIG_HWMON=y
614# CONFIG_HWMON_VID is not set
615# CONFIG_SENSORS_ABITUGURU is not set
616# CONFIG_SENSORS_F71805F is not set
617# CONFIG_SENSORS_VT1211 is not set
618# CONFIG_HWMON_DEBUG_CHIP is not set
619
620#
621# Multimedia devices
622#
623# CONFIG_VIDEO_DEV is not set
624
625#
626# Digital Video Broadcasting Devices
627#
628# CONFIG_DVB is not set
629
630#
631# Graphics support
632#
633CONFIG_FIRMWARE_EDID=y
634# CONFIG_FB is not set
635
636#
637# Sound
638#
639# CONFIG_SOUND is not set
640
641#
642# USB support
643#
644# CONFIG_USB_ARCH_HAS_HCD is not set
645# CONFIG_USB_ARCH_HAS_OHCI is not set
646# CONFIG_USB_ARCH_HAS_EHCI is not set
647
648#
649# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
650#
651
652#
653# USB Gadget Support
654#
655# CONFIG_USB_GADGET is not set
656
657#
658# MMC/SD Card support
659#
660# CONFIG_MMC is not set
661
662#
663# LED devices
664#
665# CONFIG_NEW_LEDS is not set
666
667#
668# LED drivers
669#
670
671#
672# LED Triggers
673#
674
675#
676# InfiniBand support
677#
678
679#
680# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
681#
682
683#
684# Real Time Clock
685#
686# CONFIG_RTC_CLASS is not set
687
688#
689# DMA Engine support
690#
691# CONFIG_DMA_ENGINE is not set
692
693#
694# DMA Clients
695#
696
697#
698# DMA Devices
699#
700
701#
702# File systems
703#
704CONFIG_EXT2_FS=y
705# CONFIG_EXT2_FS_XATTR is not set
706# CONFIG_EXT3_FS is not set
707# CONFIG_EXT4DEV_FS is not set
708# CONFIG_REISERFS_FS is not set
709# CONFIG_JFS_FS is not set
710# CONFIG_FS_POSIX_ACL is not set
711# CONFIG_XFS_FS is not set
712# CONFIG_GFS2_FS is not set
713# CONFIG_MINIX_FS is not set
714CONFIG_ROMFS_FS=y
715# CONFIG_INOTIFY is not set
716# CONFIG_QUOTA is not set
717# CONFIG_DNOTIFY is not set
718# CONFIG_AUTOFS_FS is not set
719# CONFIG_AUTOFS4_FS is not set
720# CONFIG_FUSE_FS is not set
721
722#
723# CD-ROM/DVD Filesystems
724#
725# CONFIG_ISO9660_FS is not set
726# CONFIG_UDF_FS is not set
727
728#
729# DOS/FAT/NT Filesystems
730#
731# CONFIG_MSDOS_FS is not set
732# CONFIG_VFAT_FS is not set
733# CONFIG_NTFS_FS is not set
734
735#
736# Pseudo filesystems
737#
738CONFIG_PROC_FS=y
739CONFIG_PROC_SYSCTL=y
740# CONFIG_SYSFS is not set
741# CONFIG_TMPFS is not set
742# CONFIG_HUGETLBFS is not set
743# CONFIG_HUGETLB_PAGE is not set
744CONFIG_RAMFS=y
745
746#
747# Miscellaneous filesystems
748#
749# CONFIG_ADFS_FS is not set
750# CONFIG_AFFS_FS is not set
751# CONFIG_HFS_FS is not set
752# CONFIG_HFSPLUS_FS is not set
753# CONFIG_BEFS_FS is not set
754# CONFIG_BFS_FS is not set
755# CONFIG_EFS_FS is not set
756# CONFIG_JFFS_FS is not set
757# CONFIG_JFFS2_FS is not set
758CONFIG_CRAMFS=y
759# CONFIG_VXFS_FS is not set
760# CONFIG_HPFS_FS is not set
761# CONFIG_QNX4FS_FS is not set
762# CONFIG_SYSV_FS is not set
763# CONFIG_UFS_FS is not set
764
765#
766# Network File Systems
767#
768# CONFIG_NFS_FS is not set
769# CONFIG_NFSD is not set
770# CONFIG_SMB_FS is not set
771# CONFIG_CIFS is not set
772# CONFIG_NCP_FS is not set
773# CONFIG_CODA_FS is not set
774# CONFIG_AFS_FS is not set
775# CONFIG_9P_FS is not set
776
777#
778# Partition Types
779#
780# CONFIG_PARTITION_ADVANCED is not set
781CONFIG_MSDOS_PARTITION=y
782
783#
784# Native Language Support
785#
786# CONFIG_NLS is not set
787
788#
789# Profiling support
790#
791# CONFIG_PROFILING is not set
792
793#
794# Kernel hacking
795#
796# CONFIG_PRINTK_TIME is not set
797CONFIG_ENABLE_MUST_CHECK=y
798# CONFIG_MAGIC_SYSRQ is not set
799# CONFIG_UNUSED_SYMBOLS is not set
800# CONFIG_DEBUG_KERNEL is not set
801CONFIG_LOG_BUF_SHIFT=14
802# CONFIG_DEBUG_BUGVERBOSE is not set
803# CONFIG_UNWIND_INFO is not set
804# CONFIG_HEADERS_CHECK is not set
805# CONFIG_SH_STANDARD_BIOS is not set
806# CONFIG_EARLY_SCIF_CONSOLE is not set
807# CONFIG_KGDB is not set
808
809#
810# Security options
811#
812# CONFIG_KEYS is not set
813
814#
815# Cryptographic options
816#
817# CONFIG_CRYPTO is not set
818
819#
820# Library routines
821#
822CONFIG_CRC_CCITT=y
823# CONFIG_CRC16 is not set
824CONFIG_CRC32=y
825# CONFIG_LIBCRC32C is not set
826CONFIG_ZLIB_INFLATE=y
diff --git a/arch/sh/drivers/Kconfig b/arch/sh/drivers/Kconfig
new file mode 100644
index 000000000000..c54c758e6243
--- /dev/null
+++ b/arch/sh/drivers/Kconfig
@@ -0,0 +1,9 @@
1menu "Additional SuperH Device Drivers"
2
3config PUSH_SWITCH
4 tristate "Push switch support"
5 help
6 This enables support for the push switch framework, a simple
7 framework that allows for sysfs driven switch status reporting.
8
9endmenu
diff --git a/arch/sh/drivers/Makefile b/arch/sh/drivers/Makefile
index 338c3729d270..bf18dbfb6787 100644
--- a/arch/sh/drivers/Makefile
+++ b/arch/sh/drivers/Makefile
@@ -5,4 +5,4 @@
5obj-$(CONFIG_PCI) += pci/ 5obj-$(CONFIG_PCI) += pci/
6obj-$(CONFIG_SH_DMA) += dma/ 6obj-$(CONFIG_SH_DMA) += dma/
7obj-$(CONFIG_SUPERHYWAY) += superhyway/ 7obj-$(CONFIG_SUPERHYWAY) += superhyway/
8 8obj-$(CONFIG_PUSH_SWITCH) += push-switch.o
diff --git a/arch/sh/drivers/dma/Makefile b/arch/sh/drivers/dma/Makefile
index 065d4c90970e..db1295d32268 100644
--- a/arch/sh/drivers/dma/Makefile
+++ b/arch/sh/drivers/dma/Makefile
@@ -2,8 +2,8 @@
2# Makefile for the SuperH DMA specific kernel interface routines under Linux. 2# Makefile for the SuperH DMA specific kernel interface routines under Linux.
3# 3#
4 4
5obj-y += dma-api.o dma-isa.o 5obj-y += dma-api.o
6obj-$(CONFIG_ISA_DMA_API) += dma-isa.o
6obj-$(CONFIG_SYSFS) += dma-sysfs.o 7obj-$(CONFIG_SYSFS) += dma-sysfs.o
7obj-$(CONFIG_SH_DMA) += dma-sh.o 8obj-$(CONFIG_SH_DMA) += dma-sh.o
8obj-$(CONFIG_SH_DREAMCAST) += dma-pvr2.o dma-g2.o 9obj-$(CONFIG_SH_DREAMCAST) += dma-pvr2.o dma-g2.o
9
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index 47c3e837599b..e062067edd24 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -11,61 +11,27 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
16#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
17#include <linux/list.h> 16#include <linux/list.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/mm.h>
19#include <asm/dma.h> 19#include <asm/dma.h>
20 20
21DEFINE_SPINLOCK(dma_spin_lock); 21DEFINE_SPINLOCK(dma_spin_lock);
22static LIST_HEAD(registered_dmac_list); 22static LIST_HEAD(registered_dmac_list);
23 23
24/*
25 * A brief note about the reasons for this API as it stands.
26 *
27 * For starters, the old ISA DMA API didn't work for us for a number of
28 * reasons, for one, the vast majority of channels on the SH DMAC are
29 * dual-address mode only, and both the new and the old DMA APIs are after the
30 * concept of managing a DMA buffer, which doesn't overly fit this model very
31 * well. In addition to which, the new API is largely geared at IOMMUs and
32 * GARTs, and doesn't even support the channel notion very well.
33 *
34 * The other thing that's a marginal issue, is the sheer number of random DMA
35 * engines that are present (ie, in boards like the Dreamcast), some of which
36 * cascade off of the SH DMAC, and others do not. As such, there was a real
37 * need for a scalable subsystem that could deal with both single and
38 * dual-address mode usage, in addition to interoperating with cascaded DMACs.
39 *
40 * There really isn't any reason why this needs to be SH specific, though I'm
41 * not aware of too many other processors (with the exception of some MIPS)
42 * that have the same concept of a dual address mode, or any real desire to
43 * actually make use of the DMAC even if such a subsystem were exposed
44 * elsewhere.
45 *
46 * The idea for this was derived from the ARM port, which acted as an excellent
47 * reference when trying to address these issues.
48 *
49 * It should also be noted that the decision to add Yet Another DMA API(tm) to
50 * the kernel wasn't made easily, and was only decided upon after conferring
51 * with jejb with regards to the state of the old and new APIs as they applied
52 * to these circumstances. Philip Blundell was also a great help in figuring
53 * out some single-address mode DMA semantics that were otherwise rather
54 * confusing.
55 */
56
57struct dma_info *get_dma_info(unsigned int chan) 24struct dma_info *get_dma_info(unsigned int chan)
58{ 25{
59 struct dma_info *info; 26 struct dma_info *info;
60 unsigned int total = 0;
61 27
62 /* 28 /*
63 * Look for each DMAC's range to determine who the owner of 29 * Look for each DMAC's range to determine who the owner of
64 * the channel is. 30 * the channel is.
65 */ 31 */
66 list_for_each_entry(info, &registered_dmac_list, list) { 32 list_for_each_entry(info, &registered_dmac_list, list) {
67 total += info->nr_channels; 33 if ((chan < info->first_channel_nr) ||
68 if (chan > total) 34 (chan >= info->first_channel_nr + info->nr_channels))
69 continue; 35 continue;
70 36
71 return info; 37 return info;
@@ -73,6 +39,22 @@ struct dma_info *get_dma_info(unsigned int chan)
73 39
74 return NULL; 40 return NULL;
75} 41}
42EXPORT_SYMBOL(get_dma_info);
43
44struct dma_info *get_dma_info_by_name(const char *dmac_name)
45{
46 struct dma_info *info;
47
48 list_for_each_entry(info, &registered_dmac_list, list) {
49 if (dmac_name && (strcmp(dmac_name, info->name) != 0))
50 continue;
51 else
52 return info;
53 }
54
55 return NULL;
56}
57EXPORT_SYMBOL(get_dma_info_by_name);
76 58
77static unsigned int get_nr_channels(void) 59static unsigned int get_nr_channels(void)
78{ 60{
@@ -91,63 +73,161 @@ static unsigned int get_nr_channels(void)
91struct dma_channel *get_dma_channel(unsigned int chan) 73struct dma_channel *get_dma_channel(unsigned int chan)
92{ 74{
93 struct dma_info *info = get_dma_info(chan); 75 struct dma_info *info = get_dma_info(chan);
76 struct dma_channel *channel;
77 int i;
94 78
95 if (!info) 79 if (unlikely(!info))
96 return ERR_PTR(-EINVAL); 80 return ERR_PTR(-EINVAL);
97 81
98 return info->channels + chan; 82 for (i = 0; i < info->nr_channels; i++) {
83 channel = &info->channels[i];
84 if (channel->chan == chan)
85 return channel;
86 }
87
88 return NULL;
99} 89}
90EXPORT_SYMBOL(get_dma_channel);
100 91
101int get_dma_residue(unsigned int chan) 92int get_dma_residue(unsigned int chan)
102{ 93{
103 struct dma_info *info = get_dma_info(chan); 94 struct dma_info *info = get_dma_info(chan);
104 struct dma_channel *channel = &info->channels[chan]; 95 struct dma_channel *channel = get_dma_channel(chan);
105 96
106 if (info->ops->get_residue) 97 if (info->ops->get_residue)
107 return info->ops->get_residue(channel); 98 return info->ops->get_residue(channel);
108 99
109 return 0; 100 return 0;
110} 101}
102EXPORT_SYMBOL(get_dma_residue);
111 103
112int request_dma(unsigned int chan, const char *dev_id) 104static int search_cap(const char **haystack, const char *needle)
113{ 105{
114 struct dma_info *info = get_dma_info(chan); 106 const char **p;
115 struct dma_channel *channel = &info->channels[chan]; 107
108 for (p = haystack; *p; p++)
109 if (strcmp(*p, needle) == 0)
110 return 1;
111
112 return 0;
113}
114
115/**
116 * request_dma_bycap - Allocate a DMA channel based on its capabilities
117 * @dmac: List of DMA controllers to search
118 * @caps: List of capabilites
119 *
120 * Search all channels of all DMA controllers to find a channel which
121 * matches the requested capabilities. The result is the channel
122 * number if a match is found, or %-ENODEV if no match is found.
123 *
124 * Note that not all DMA controllers export capabilities, in which
125 * case they can never be allocated using this API, and so
126 * request_dma() must be used specifying the channel number.
127 */
128int request_dma_bycap(const char **dmac, const char **caps, const char *dev_id)
129{
130 unsigned int found = 0;
131 struct dma_info *info;
132 const char **p;
133 int i;
134
135 BUG_ON(!dmac || !caps);
136
137 list_for_each_entry(info, &registered_dmac_list, list)
138 if (strcmp(*dmac, info->name) == 0) {
139 found = 1;
140 break;
141 }
142
143 if (!found)
144 return -ENODEV;
145
146 for (i = 0; i < info->nr_channels; i++) {
147 struct dma_channel *channel = &info->channels[i];
148
149 if (unlikely(!channel->caps))
150 continue;
151
152 for (p = caps; *p; p++) {
153 if (!search_cap(channel->caps, *p))
154 break;
155 if (request_dma(channel->chan, dev_id) == 0)
156 return channel->chan;
157 }
158 }
159
160 return -EINVAL;
161}
162EXPORT_SYMBOL(request_dma_bycap);
163
164int dmac_search_free_channel(const char *dev_id)
165{
166 struct dma_channel *channel = { 0 };
167 struct dma_info *info = get_dma_info(0);
168 int i;
169
170 for (i = 0; i < info->nr_channels; i++) {
171 channel = &info->channels[i];
172 if (unlikely(!channel))
173 return -ENODEV;
174
175 if (atomic_read(&channel->busy) == 0)
176 break;
177 }
116 178
117 down(&channel->sem); 179 if (info->ops->request) {
180 int result = info->ops->request(channel);
181 if (result)
182 return result;
118 183
119 if (!info->ops || chan >= MAX_DMA_CHANNELS) { 184 atomic_set(&channel->busy, 1);
120 up(&channel->sem); 185 return channel->chan;
121 return -EINVAL;
122 } 186 }
123 187
124 atomic_set(&channel->busy, 1); 188 return -ENOSYS;
189}
190
191int request_dma(unsigned int chan, const char *dev_id)
192{
193 struct dma_channel *channel = { 0 };
194 struct dma_info *info = get_dma_info(chan);
195 int result;
196
197 channel = get_dma_channel(chan);
198 if (atomic_xchg(&channel->busy, 1))
199 return -EBUSY;
125 200
126 strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id)); 201 strlcpy(channel->dev_id, dev_id, sizeof(channel->dev_id));
127 202
128 up(&channel->sem); 203 if (info->ops->request) {
204 result = info->ops->request(channel);
205 if (result)
206 atomic_set(&channel->busy, 0);
129 207
130 if (info->ops->request) 208 return result;
131 return info->ops->request(channel); 209 }
132 210
133 return 0; 211 return 0;
134} 212}
213EXPORT_SYMBOL(request_dma);
135 214
136void free_dma(unsigned int chan) 215void free_dma(unsigned int chan)
137{ 216{
138 struct dma_info *info = get_dma_info(chan); 217 struct dma_info *info = get_dma_info(chan);
139 struct dma_channel *channel = &info->channels[chan]; 218 struct dma_channel *channel = get_dma_channel(chan);
140 219
141 if (info->ops->free) 220 if (info->ops->free)
142 info->ops->free(channel); 221 info->ops->free(channel);
143 222
144 atomic_set(&channel->busy, 0); 223 atomic_set(&channel->busy, 0);
145} 224}
225EXPORT_SYMBOL(free_dma);
146 226
147void dma_wait_for_completion(unsigned int chan) 227void dma_wait_for_completion(unsigned int chan)
148{ 228{
149 struct dma_info *info = get_dma_info(chan); 229 struct dma_info *info = get_dma_info(chan);
150 struct dma_channel *channel = &info->channels[chan]; 230 struct dma_channel *channel = get_dma_channel(chan);
151 231
152 if (channel->flags & DMA_TEI_CAPABLE) { 232 if (channel->flags & DMA_TEI_CAPABLE) {
153 wait_event(channel->wait_queue, 233 wait_event(channel->wait_queue,
@@ -158,21 +238,52 @@ void dma_wait_for_completion(unsigned int chan)
158 while (info->ops->get_residue(channel)) 238 while (info->ops->get_residue(channel))
159 cpu_relax(); 239 cpu_relax();
160} 240}
241EXPORT_SYMBOL(dma_wait_for_completion);
242
243int register_chan_caps(const char *dmac, struct dma_chan_caps *caps)
244{
245 struct dma_info *info;
246 unsigned int found = 0;
247 int i;
248
249 list_for_each_entry(info, &registered_dmac_list, list)
250 if (strcmp(dmac, info->name) == 0) {
251 found = 1;
252 break;
253 }
254
255 if (unlikely(!found))
256 return -ENODEV;
257
258 for (i = 0; i < info->nr_channels; i++, caps++) {
259 struct dma_channel *channel;
260
261 if ((info->first_channel_nr + i) != caps->ch_num)
262 return -EINVAL;
263
264 channel = &info->channels[i];
265 channel->caps = caps->caplist;
266 }
267
268 return 0;
269}
270EXPORT_SYMBOL(register_chan_caps);
161 271
162void dma_configure_channel(unsigned int chan, unsigned long flags) 272void dma_configure_channel(unsigned int chan, unsigned long flags)
163{ 273{
164 struct dma_info *info = get_dma_info(chan); 274 struct dma_info *info = get_dma_info(chan);
165 struct dma_channel *channel = &info->channels[chan]; 275 struct dma_channel *channel = get_dma_channel(chan);
166 276
167 if (info->ops->configure) 277 if (info->ops->configure)
168 info->ops->configure(channel, flags); 278 info->ops->configure(channel, flags);
169} 279}
280EXPORT_SYMBOL(dma_configure_channel);
170 281
171int dma_xfer(unsigned int chan, unsigned long from, 282int dma_xfer(unsigned int chan, unsigned long from,
172 unsigned long to, size_t size, unsigned int mode) 283 unsigned long to, size_t size, unsigned int mode)
173{ 284{
174 struct dma_info *info = get_dma_info(chan); 285 struct dma_info *info = get_dma_info(chan);
175 struct dma_channel *channel = &info->channels[chan]; 286 struct dma_channel *channel = get_dma_channel(chan);
176 287
177 channel->sar = from; 288 channel->sar = from;
178 channel->dar = to; 289 channel->dar = to;
@@ -181,8 +292,20 @@ int dma_xfer(unsigned int chan, unsigned long from,
181 292
182 return info->ops->xfer(channel); 293 return info->ops->xfer(channel);
183} 294}
295EXPORT_SYMBOL(dma_xfer);
296
297int dma_extend(unsigned int chan, unsigned long op, void *param)
298{
299 struct dma_info *info = get_dma_info(chan);
300 struct dma_channel *channel = get_dma_channel(chan);
301
302 if (info->ops->extend)
303 return info->ops->extend(channel, op, param);
304
305 return -ENOSYS;
306}
307EXPORT_SYMBOL(dma_extend);
184 308
185#ifdef CONFIG_PROC_FS
186static int dma_read_proc(char *buf, char **start, off_t off, 309static int dma_read_proc(char *buf, char **start, off_t off,
187 int len, int *eof, void *data) 310 int len, int *eof, void *data)
188{ 311{
@@ -214,8 +337,6 @@ static int dma_read_proc(char *buf, char **start, off_t off,
214 337
215 return p - buf; 338 return p - buf;
216} 339}
217#endif
218
219 340
220int register_dmac(struct dma_info *info) 341int register_dmac(struct dma_info *info)
221{ 342{
@@ -224,8 +345,7 @@ int register_dmac(struct dma_info *info)
224 INIT_LIST_HEAD(&info->list); 345 INIT_LIST_HEAD(&info->list);
225 346
226 printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n", 347 printk(KERN_INFO "DMA: Registering %s handler (%d channel%s).\n",
227 info->name, info->nr_channels, 348 info->name, info->nr_channels, info->nr_channels > 1 ? "s" : "");
228 info->nr_channels > 1 ? "s" : "");
229 349
230 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels); 350 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
231 351
@@ -242,28 +362,26 @@ int register_dmac(struct dma_info *info)
242 362
243 size = sizeof(struct dma_channel) * info->nr_channels; 363 size = sizeof(struct dma_channel) * info->nr_channels;
244 364
245 info->channels = kmalloc(size, GFP_KERNEL); 365 info->channels = kzalloc(size, GFP_KERNEL);
246 if (!info->channels) 366 if (!info->channels)
247 return -ENOMEM; 367 return -ENOMEM;
248
249 memset(info->channels, 0, size);
250 } 368 }
251 369
252 total_channels = get_nr_channels(); 370 total_channels = get_nr_channels();
253 for (i = 0; i < info->nr_channels; i++) { 371 for (i = 0; i < info->nr_channels; i++) {
254 struct dma_channel *chan = info->channels + i; 372 struct dma_channel *chan = &info->channels[i];
373
374 atomic_set(&chan->busy, 0);
255 375
256 chan->chan = i; 376 chan->chan = info->first_channel_nr + i;
257 chan->vchan = i + total_channels; 377 chan->vchan = info->first_channel_nr + i + total_channels;
258 378
259 memcpy(chan->dev_id, "Unused", 7); 379 memcpy(chan->dev_id, "Unused", 7);
260 380
261 if (info->flags & DMAC_CHANNELS_TEI_CAPABLE) 381 if (info->flags & DMAC_CHANNELS_TEI_CAPABLE)
262 chan->flags |= DMA_TEI_CAPABLE; 382 chan->flags |= DMA_TEI_CAPABLE;
263 383
264 init_MUTEX(&chan->sem);
265 init_waitqueue_head(&chan->wait_queue); 384 init_waitqueue_head(&chan->wait_queue);
266
267 dma_create_sysfs_files(chan, info); 385 dma_create_sysfs_files(chan, info);
268 } 386 }
269 387
@@ -271,6 +389,7 @@ int register_dmac(struct dma_info *info)
271 389
272 return 0; 390 return 0;
273} 391}
392EXPORT_SYMBOL(register_dmac);
274 393
275void unregister_dmac(struct dma_info *info) 394void unregister_dmac(struct dma_info *info)
276{ 395{
@@ -285,31 +404,16 @@ void unregister_dmac(struct dma_info *info)
285 list_del(&info->list); 404 list_del(&info->list);
286 platform_device_unregister(info->pdev); 405 platform_device_unregister(info->pdev);
287} 406}
407EXPORT_SYMBOL(unregister_dmac);
288 408
289static int __init dma_api_init(void) 409static int __init dma_api_init(void)
290{ 410{
291 printk("DMA: Registering DMA API.\n"); 411 printk(KERN_NOTICE "DMA: Registering DMA API.\n");
292
293#ifdef CONFIG_PROC_FS
294 create_proc_read_entry("dma", 0, 0, dma_read_proc, 0); 412 create_proc_read_entry("dma", 0, 0, dma_read_proc, 0);
295#endif
296
297 return 0; 413 return 0;
298} 414}
299
300subsys_initcall(dma_api_init); 415subsys_initcall(dma_api_init);
301 416
302MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>"); 417MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
303MODULE_DESCRIPTION("DMA API for SuperH"); 418MODULE_DESCRIPTION("DMA API for SuperH");
304MODULE_LICENSE("GPL"); 419MODULE_LICENSE("GPL");
305
306EXPORT_SYMBOL(request_dma);
307EXPORT_SYMBOL(free_dma);
308EXPORT_SYMBOL(register_dmac);
309EXPORT_SYMBOL(get_dma_residue);
310EXPORT_SYMBOL(get_dma_info);
311EXPORT_SYMBOL(get_dma_channel);
312EXPORT_SYMBOL(dma_xfer);
313EXPORT_SYMBOL(dma_wait_for_completion);
314EXPORT_SYMBOL(dma_configure_channel);
315
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index 660786013350..f63721ed86c2 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -94,20 +94,13 @@ static int sh_dmac_request_dma(struct dma_channel *chan)
94 if (unlikely(!chan->flags & DMA_TEI_CAPABLE)) 94 if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
95 return 0; 95 return 0;
96 96
97 chan->name = kzalloc(32, GFP_KERNEL);
98 if (unlikely(chan->name == NULL))
99 return -ENOMEM;
100 snprintf(chan->name, 32, "DMAC Transfer End (Channel %d)",
101 chan->chan);
102
103 return request_irq(get_dmte_irq(chan->chan), dma_tei, 97 return request_irq(get_dmte_irq(chan->chan), dma_tei,
104 IRQF_DISABLED, chan->name, chan); 98 IRQF_DISABLED, chan->dev_id, chan);
105} 99}
106 100
107static void sh_dmac_free_dma(struct dma_channel *chan) 101static void sh_dmac_free_dma(struct dma_channel *chan)
108{ 102{
109 free_irq(get_dmte_irq(chan->chan), chan); 103 free_irq(get_dmte_irq(chan->chan), chan);
110 kfree(chan->name);
111} 104}
112 105
113static void 106static void
diff --git a/arch/sh/drivers/dma/dma-sysfs.c b/arch/sh/drivers/dma/dma-sysfs.c
index 29b8ef9873d1..eebcd4768bbf 100644
--- a/arch/sh/drivers/dma/dma-sysfs.c
+++ b/arch/sh/drivers/dma/dma-sysfs.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * sysfs interface for SH DMA API 4 * sysfs interface for SH DMA API
5 * 5 *
6 * Copyright (C) 2004, 2005 Paul Mundt 6 * Copyright (C) 2004 - 2006 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -21,7 +21,6 @@
21static struct sysdev_class dma_sysclass = { 21static struct sysdev_class dma_sysclass = {
22 set_kset_name("dma"), 22 set_kset_name("dma"),
23}; 23};
24
25EXPORT_SYMBOL(dma_sysclass); 24EXPORT_SYMBOL(dma_sysclass);
26 25
27static ssize_t dma_show_devices(struct sys_device *dev, char *buf) 26static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
@@ -31,7 +30,10 @@ static ssize_t dma_show_devices(struct sys_device *dev, char *buf)
31 30
32 for (i = 0; i < MAX_DMA_CHANNELS; i++) { 31 for (i = 0; i < MAX_DMA_CHANNELS; i++) {
33 struct dma_info *info = get_dma_info(i); 32 struct dma_info *info = get_dma_info(i);
34 struct dma_channel *channel = &info->channels[i]; 33 struct dma_channel *channel = get_dma_channel(i);
34
35 if (unlikely(!info) || !channel)
36 continue;
35 37
36 len += sprintf(buf + len, "%2d: %14s %s\n", 38 len += sprintf(buf + len, "%2d: %14s %s\n",
37 channel->chan, info->name, 39 channel->chan, info->name,
@@ -125,11 +127,16 @@ int dma_create_sysfs_files(struct dma_channel *chan, struct dma_info *info)
125 if (ret) 127 if (ret)
126 return ret; 128 return ret;
127 129
128 sysdev_create_file(dev, &attr_dev_id); 130 ret |= sysdev_create_file(dev, &attr_dev_id);
129 sysdev_create_file(dev, &attr_count); 131 ret |= sysdev_create_file(dev, &attr_count);
130 sysdev_create_file(dev, &attr_mode); 132 ret |= sysdev_create_file(dev, &attr_mode);
131 sysdev_create_file(dev, &attr_flags); 133 ret |= sysdev_create_file(dev, &attr_flags);
132 sysdev_create_file(dev, &attr_config); 134 ret |= sysdev_create_file(dev, &attr_config);
135
136 if (unlikely(ret)) {
137 dev_err(&info->pdev->dev, "Failed creating attrs\n");
138 return ret;
139 }
133 140
134 snprintf(name, sizeof(name), "dma%d", chan->chan); 141 snprintf(name, sizeof(name), "dma%d", chan->chan);
135 return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name); 142 return sysfs_create_link(&info->pdev->dev.kobj, &dev->kobj, name);
diff --git a/arch/sh/drivers/pci/ops-titan.c b/arch/sh/drivers/pci/ops-titan.c
index cd56d53375e7..ac8ee2312cd8 100644
--- a/arch/sh/drivers/pci/ops-titan.c
+++ b/arch/sh/drivers/pci/ops-titan.c
@@ -15,25 +15,21 @@
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include <asm/io.h> 18#include <linux/io.h>
19#include <asm/titan.h> 19#include <asm/titan.h>
20#include "pci-sh4.h" 20#include "pci-sh4.h"
21 21
22static char titan_irq_tab[] __initdata = {
23 TITAN_IRQ_WAN,
24 TITAN_IRQ_LAN,
25 TITAN_IRQ_MPCIA,
26 TITAN_IRQ_MPCIB,
27 TITAN_IRQ_USB,
28};
29
22int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin) 30int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
23{ 31{
24 int irq = -1; 32 int irq = titan_irq_tab[slot];
25
26 switch (slot) {
27 case 0: irq = TITAN_IRQ_WAN; break; /* eth0 (WAN) */
28 case 1: irq = TITAN_IRQ_LAN; break; /* eth1 (LAN) */
29 case 2: irq = TITAN_IRQ_MPCIA; break; /* mPCI A */
30 case 3: irq = TITAN_IRQ_MPCIB; break; /* mPCI B */
31 case 4: irq = TITAN_IRQ_USB; break; /* USB */
32 default:
33 printk(KERN_INFO "PCI: Bad IRQ mapping "
34 "request for slot %d\n", slot);
35 return -1;
36 }
37 33
38 printk("PCI: Mapping TITAN IRQ for slot %d, pin %c to irq %d\n", 34 printk("PCI: Mapping TITAN IRQ for slot %d, pin %c to irq %d\n",
39 slot, pin - 1 + 'A', irq); 35 slot, pin - 1 + 'A', irq);
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index d6e635296534..602b644c35ad 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -22,6 +22,20 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include "pci-sh4.h" 23#include "pci-sh4.h"
24 24
25#define INTC_BASE 0xffd00000
26#define INTC_ICR0 (INTC_BASE+0x0)
27#define INTC_ICR1 (INTC_BASE+0x1c)
28#define INTC_INTPRI (INTC_BASE+0x10)
29#define INTC_INTREQ (INTC_BASE+0x24)
30#define INTC_INTMSK0 (INTC_BASE+0x44)
31#define INTC_INTMSK1 (INTC_BASE+0x48)
32#define INTC_INTMSK2 (INTC_BASE+0x40080)
33#define INTC_INTMSKCLR0 (INTC_BASE+0x64)
34#define INTC_INTMSKCLR1 (INTC_BASE+0x68)
35#define INTC_INTMSKCLR2 (INTC_BASE+0x40084)
36#define INTC_INT2MSKR (INTC_BASE+0x40038)
37#define INTC_INT2MSKCR (INTC_BASE+0x4003c)
38
25/* 39/*
26 * Initialization. Try all known PCI access methods. Note that we support 40 * Initialization. Try all known PCI access methods. Note that we support
27 * using both PCI BIOS and direct access: in such cases, we use I/O ports 41 * using both PCI BIOS and direct access: in such cases, we use I/O ports
diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
new file mode 100644
index 000000000000..f2b9157c314f
--- /dev/null
+++ b/arch/sh/drivers/push-switch.c
@@ -0,0 +1,138 @@
1/*
2 * Generic push-switch framework
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/interrupt.h>
13#include <linux/platform_device.h>
14#include <asm/push-switch.h>
15
16#define DRV_NAME "push-switch"
17#define DRV_VERSION "0.1.0"
18
19static ssize_t switch_show(struct device *dev,
20 struct device_attribute *attr,
21 char *buf)
22{
23 struct push_switch_platform_info *psw_info = dev->platform_data;
24 return sprintf(buf, "%s\n", psw_info->name);
25}
26static DEVICE_ATTR(switch, S_IRUGO, switch_show, NULL);
27
28static void switch_timer(unsigned long data)
29{
30 struct push_switch *psw = (struct push_switch *)data;
31
32 schedule_work(&psw->work);
33}
34
35static void switch_work_handler(void *data)
36{
37 struct platform_device *pdev = data;
38 struct push_switch *psw = platform_get_drvdata(pdev);
39
40 psw->state = 0;
41
42 kobject_uevent(&pdev->dev.kobj, KOBJ_CHANGE);
43}
44
45static int switch_drv_probe(struct platform_device *pdev)
46{
47 struct push_switch_platform_info *psw_info;
48 struct push_switch *psw;
49 int ret, irq;
50
51 psw = kzalloc(sizeof(struct push_switch), GFP_KERNEL);
52 if (unlikely(!psw))
53 return -ENOMEM;
54
55 irq = platform_get_irq(pdev, 0);
56 if (unlikely(irq < 0)) {
57 ret = -ENODEV;
58 goto err;
59 }
60
61 psw_info = pdev->dev.platform_data;
62 BUG_ON(!psw_info);
63
64 ret = request_irq(irq, psw_info->irq_handler,
65 IRQF_DISABLED | psw_info->irq_flags,
66 psw_info->name ? psw_info->name : DRV_NAME, pdev);
67 if (unlikely(ret < 0))
68 goto err;
69
70 if (psw_info->name) {
71 ret = device_create_file(&pdev->dev, &dev_attr_switch);
72 if (unlikely(ret)) {
73 dev_err(&pdev->dev, "Failed creating device attrs\n");
74 ret = -EINVAL;
75 goto err_irq;
76 }
77 }
78
79 INIT_WORK(&psw->work, switch_work_handler, pdev);
80 init_timer(&psw->debounce);
81
82 psw->debounce.function = switch_timer;
83 psw->debounce.data = (unsigned long)psw;
84
85 platform_set_drvdata(pdev, psw);
86
87 return 0;
88
89err_irq:
90 free_irq(irq, pdev);
91err:
92 kfree(psw);
93 return ret;
94}
95
96static int switch_drv_remove(struct platform_device *pdev)
97{
98 struct push_switch *psw = platform_get_drvdata(pdev);
99 struct push_switch_platform_info *psw_info = pdev->dev.platform_data;
100 int irq = platform_get_irq(pdev, 0);
101
102 if (psw_info->name)
103 device_remove_file(&pdev->dev, &dev_attr_switch);
104
105 platform_set_drvdata(pdev, NULL);
106 flush_scheduled_work();
107 del_timer_sync(&psw->debounce);
108 free_irq(irq, pdev);
109
110 kfree(psw);
111
112 return 0;
113}
114
115static struct platform_driver switch_driver = {
116 .probe = switch_drv_probe,
117 .remove = switch_drv_remove,
118 .driver = {
119 .name = DRV_NAME,
120 },
121};
122
123static int __init switch_init(void)
124{
125 printk(KERN_NOTICE DRV_NAME ": version %s loaded\n", DRV_VERSION);
126 return platform_driver_register(&switch_driver);
127}
128
129static void __exit switch_exit(void)
130{
131 platform_driver_unregister(&switch_driver);
132}
133module_init(switch_init);
134module_exit(switch_exit);
135
136MODULE_VERSION(DRV_VERSION);
137MODULE_AUTHOR("Paul Mundt");
138MODULE_LICENSE("GPLv2");
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index 5da88a43d350..99c7e5249f7a 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -4,7 +4,7 @@
4 4
5extra-y := head.o init_task.o vmlinux.lds 5extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y := process.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o traps.o irq.o \
8 ptrace.o setup.o time.o sys_sh.o semaphore.o \ 8 ptrace.o setup.o time.o sys_sh.o semaphore.o \
9 io.o io_generic.o sh_ksyms.o syscalls.o 9 io.o io_generic.o sh_ksyms.o syscalls.o
10 10
@@ -21,3 +21,4 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
21obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 21obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
22obj-$(CONFIG_APM) += apm.o 22obj-$(CONFIG_APM) += apm.o
23obj-$(CONFIG_PM) += pm.o 23obj-$(CONFIG_PM) += pm.o
24obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index fb5dac069382..0582e6712b79 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -2,11 +2,12 @@
2# Makefile for the Linux/SuperH CPU-specifc backends. 2# Makefile for the Linux/SuperH CPU-specifc backends.
3# 3#
4 4
5obj-y += irq/ init.o clock.o 5obj-$(CONFIG_CPU_SH2) = sh2/
6 6obj-$(CONFIG_CPU_SH2A) = sh2a/
7obj-$(CONFIG_CPU_SH2) += sh2/ 7obj-$(CONFIG_CPU_SH3) = sh3/
8obj-$(CONFIG_CPU_SH3) += sh3/ 8obj-$(CONFIG_CPU_SH4) = sh4/
9obj-$(CONFIG_CPU_SH4) += sh4/
10 9
11obj-$(CONFIG_UBC_WAKEUP) += ubc.o 10obj-$(CONFIG_UBC_WAKEUP) += ubc.o
12obj-$(CONFIG_SH_ADC) += adc.o 11obj-$(CONFIG_SH_ADC) += adc.o
12
13obj-y += irq/ init.o clock.o
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 51ec64cdf348..abb586b12565 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -5,9 +5,11 @@
5 * 5 *
6 * This clock framework is derived from the OMAP version by: 6 * This clock framework is derived from the OMAP version by:
7 * 7 *
8 * Copyright (C) 2004 Nokia Corporation 8 * Copyright (C) 2004 - 2005 Nokia Corporation
9 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> 9 * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
10 * 10 *
11 * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com>
12 *
11 * This file is subject to the terms and conditions of the GNU General Public 13 * 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 14 * License. See the file "COPYING" in the main directory of this archive
13 * for more details. 15 * for more details.
@@ -20,6 +22,7 @@
20#include <linux/kref.h> 22#include <linux/kref.h>
21#include <linux/seq_file.h> 23#include <linux/seq_file.h>
22#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/platform_device.h>
23#include <asm/clock.h> 26#include <asm/clock.h>
24#include <asm/timer.h> 27#include <asm/timer.h>
25 28
@@ -195,17 +198,37 @@ void clk_recalc_rate(struct clk *clk)
195 propagate_rate(clk); 198 propagate_rate(clk);
196} 199}
197 200
198struct clk *clk_get(const char *id) 201/*
202 * Returns a clock. Note that we first try to use device id on the bus
203 * and clock name. If this fails, we try to use clock name only.
204 */
205struct clk *clk_get(struct device *dev, const char *id)
199{ 206{
200 struct clk *p, *clk = ERR_PTR(-ENOENT); 207 struct clk *p, *clk = ERR_PTR(-ENOENT);
208 int idno;
209
210 if (dev == NULL || dev->bus != &platform_bus_type)
211 idno = -1;
212 else
213 idno = to_platform_device(dev)->id;
201 214
202 mutex_lock(&clock_list_sem); 215 mutex_lock(&clock_list_sem);
203 list_for_each_entry(p, &clock_list, node) { 216 list_for_each_entry(p, &clock_list, node) {
217 if (p->id == idno &&
218 strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
219 clk = p;
220 goto found;
221 }
222 }
223
224 list_for_each_entry(p, &clock_list, node) {
204 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 225 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
205 clk = p; 226 clk = p;
206 break; 227 break;
207 } 228 }
208 } 229 }
230
231found:
209 mutex_unlock(&clock_list_sem); 232 mutex_unlock(&clock_list_sem);
210 233
211 return clk; 234 return clk;
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index bfb90eb0b7a6..48121766e8d2 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -68,12 +68,14 @@ static void __init cache_init(void)
68 68
69 waysize = cpu_data->dcache.sets; 69 waysize = cpu_data->dcache.sets;
70 70
71#ifdef CCR_CACHE_ORA
71 /* 72 /*
72 * If the OC is already in RAM mode, we only have 73 * If the OC is already in RAM mode, we only have
73 * half of the entries to flush.. 74 * half of the entries to flush..
74 */ 75 */
75 if (ccr & CCR_CACHE_ORA) 76 if (ccr & CCR_CACHE_ORA)
76 waysize >>= 1; 77 waysize >>= 1;
78#endif
77 79
78 waysize <<= cpu_data->dcache.entry_shift; 80 waysize <<= cpu_data->dcache.entry_shift;
79 81
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile
index 1c034c283f59..0049d217561a 100644
--- a/arch/sh/kernel/cpu/irq/Makefile
+++ b/arch/sh/kernel/cpu/irq/Makefile
@@ -1,8 +1,9 @@
1# 1#
2# Makefile for the Linux/SuperH CPU-specifc IRQ handlers. 2# Makefile for the Linux/SuperH CPU-specifc IRQ handlers.
3# 3#
4obj-y += ipr.o imask.o 4obj-y += imask.o
5 5
6obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o
6obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o 7obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
7obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o 8obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
8obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o 9obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
diff --git a/arch/sh/kernel/cpu/irq/imask.c b/arch/sh/kernel/cpu/irq/imask.c
index a33ae3e0a5a5..301b505c4278 100644
--- a/arch/sh/kernel/cpu/irq/imask.c
+++ b/arch/sh/kernel/cpu/irq/imask.c
@@ -53,7 +53,10 @@ void static inline set_interrupt_registers(int ip)
53{ 53{
54 unsigned long __dummy; 54 unsigned long __dummy;
55 55
56 asm volatile("ldc %2, r6_bank\n\t" 56 asm volatile(
57#ifdef CONFIG_CPU_HAS_SR_RB
58 "ldc %2, r6_bank\n\t"
59#endif
57 "stc sr, %0\n\t" 60 "stc sr, %0\n\t"
58 "and #0xf0, %0\n\t" 61 "and #0xf0, %0\n\t"
59 "shlr2 %0\n\t" 62 "shlr2 %0\n\t"
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c
index 74ca576a7ce5..74defe76a058 100644
--- a/arch/sh/kernel/cpu/irq/intc2.c
+++ b/arch/sh/kernel/cpu/irq/intc2.c
@@ -11,22 +11,29 @@
11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780. 11 * Hitachi 7751, the STM ST40 STB1, SH7760, and SH7780.
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/irq.h> 14#include <linux/interrupt.h>
15#include <linux/io.h> 15#include <linux/io.h>
16#include <asm/system.h> 16
17#if defined(CONFIG_CPU_SUBTYPE_SH7760)
18#define INTC2_BASE 0xfe080000
19#define INTC2_INTMSK (INTC2_BASE + 0x40)
20#define INTC2_INTMSKCLR (INTC2_BASE + 0x60)
21#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
22#define INTC2_BASE 0xffd40000
23#define INTC2_INTMSK (INTC2_BASE + 0x38)
24#define INTC2_INTMSKCLR (INTC2_BASE + 0x3c)
25#endif
17 26
18static void disable_intc2_irq(unsigned int irq) 27static void disable_intc2_irq(unsigned int irq)
19{ 28{
20 struct intc2_data *p = get_irq_chip_data(irq); 29 struct intc2_data *p = get_irq_chip_data(irq);
21 ctrl_outl(1 << p->msk_shift, 30 ctrl_outl(1 << p->msk_shift, INTC2_INTMSK + p->msk_offset);
22 INTC2_BASE + INTC2_INTMSK_OFFSET + p->msk_offset);
23} 31}
24 32
25static void enable_intc2_irq(unsigned int irq) 33static void enable_intc2_irq(unsigned int irq)
26{ 34{
27 struct intc2_data *p = get_irq_chip_data(irq); 35 struct intc2_data *p = get_irq_chip_data(irq);
28 ctrl_outl(1 << p->msk_shift, 36 ctrl_outl(1 << p->msk_shift, INTC2_INTMSKCLR + p->msk_offset);
29 INTC2_BASE + INTC2_INTMSKCLR_OFFSET + p->msk_offset);
30} 37}
31 38
32static struct irq_chip intc2_irq_chip = { 39static struct irq_chip intc2_irq_chip = {
@@ -61,12 +68,10 @@ void make_intc2_irq(struct intc2_data *table, unsigned int nr_irqs)
61 /* Set the priority level */ 68 /* Set the priority level */
62 local_irq_save(flags); 69 local_irq_save(flags);
63 70
64 ipr = ctrl_inl(INTC2_BASE + INTC2_INTPRI_OFFSET + 71 ipr = ctrl_inl(INTC2_BASE + p->ipr_offset);
65 p->ipr_offset);
66 ipr &= ~(0xf << p->ipr_shift); 72 ipr &= ~(0xf << p->ipr_shift);
67 ipr |= p->priority << p->ipr_shift; 73 ipr |= p->priority << p->ipr_shift;
68 ctrl_outl(ipr, INTC2_BASE + INTC2_INTPRI_OFFSET + 74 ctrl_outl(ipr, INTC2_BASE + p->ipr_offset);
69 p->ipr_offset);
70 75
71 local_irq_restore(flags); 76 local_irq_restore(flags);
72 77
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index a0089563cbfc..35eb5751a3aa 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -19,25 +19,21 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <asm/system.h> 22#include <linux/io.h>
23#include <asm/io.h> 23#include <linux/interrupt.h>
24#include <asm/machvec.h>
25
26 24
27static void disable_ipr_irq(unsigned int irq) 25static void disable_ipr_irq(unsigned int irq)
28{ 26{
29 struct ipr_data *p = get_irq_chip_data(irq); 27 struct ipr_data *p = get_irq_chip_data(irq);
30 int shift = p->shift*4;
31 /* Set the priority in IPR to 0 */ 28 /* Set the priority in IPR to 0 */
32 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << shift)), p->addr); 29 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr);
33} 30}
34 31
35static void enable_ipr_irq(unsigned int irq) 32static void enable_ipr_irq(unsigned int irq)
36{ 33{
37 struct ipr_data *p = get_irq_chip_data(irq); 34 struct ipr_data *p = get_irq_chip_data(irq);
38 int shift = p->shift*4;
39 /* Set priority in IPR back to original value */ 35 /* Set priority in IPR back to original value */
40 ctrl_outw(ctrl_inw(p->addr) | (p->priority << shift), p->addr); 36 ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr);
41} 37}
42 38
43static struct irq_chip ipr_irq_chip = { 39static struct irq_chip ipr_irq_chip = {
@@ -53,6 +49,10 @@ void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
53 49
54 for (i = 0; i < nr_irqs; i++) { 50 for (i = 0; i < nr_irqs; i++) {
55 unsigned int irq = table[i].irq; 51 unsigned int irq = table[i].irq;
52 table[i].addr = map_ipridx_to_addr(table[i].ipr_idx);
53 /* could the IPR index be mapped, if not we ignore this */
54 if (table[i].addr == 0)
55 continue;
56 disable_irq_nosync(irq); 56 disable_irq_nosync(irq);
57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip, 57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
58 handle_level_irq, "level"); 58 handle_level_irq, "level");
@@ -62,83 +62,6 @@ void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
62} 62}
63EXPORT_SYMBOL(make_ipr_irq); 63EXPORT_SYMBOL(make_ipr_irq);
64 64
65static struct ipr_data sys_ipr_map[] = {
66#ifndef CONFIG_CPU_SUBTYPE_SH7780
67 { TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY },
68 { TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY },
69#ifdef RTC_IRQ
70 { RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY },
71#endif
72#ifdef SCI_ERI_IRQ
73 { SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
74 { SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
75 { SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
76#endif
77#ifdef SCIF1_ERI_IRQ
78 { SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
79 { SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
80 { SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
81 { SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
82#endif
83#if defined(CONFIG_CPU_SUBTYPE_SH7300)
84 { SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
85 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
86 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
87 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
88#endif
89#ifdef SCIF_ERI_IRQ
90 { SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
91 { SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
92 { SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
93 { SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
94#endif
95#ifdef IRDA_ERI_IRQ
96 { IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
97 { IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
98 { IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
99 { IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
100#endif
101#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
102 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
103 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
104 /*
105 * Initialize the Interrupt Controller (INTC)
106 * registers to their power on values
107 */
108
109 /*
110 * Enable external irq (INTC IRQ mode).
111 * You should set corresponding bits of PFC to "00"
112 * to enable these interrupts.
113 */
114 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY },
115 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
116 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
117 { IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY },
118 { IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY },
119 { IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY },
120#endif
121#endif
122};
123
124void __init init_IRQ(void)
125{
126 make_ipr_irq(sys_ipr_map, ARRAY_SIZE(sys_ipr_map));
127
128#ifdef CONFIG_CPU_HAS_PINT_IRQ
129 init_IRQ_pint();
130#endif
131
132#ifdef CONFIG_CPU_HAS_INTC2_IRQ
133 init_IRQ_intc2();
134#endif
135 /* Perform the machine specific initialisation */
136 if (sh_mv.mv_init_irq != NULL)
137 sh_mv.mv_init_irq();
138
139 irq_ctx_init(smp_processor_id());
140}
141
142#if !defined(CONFIG_CPU_HAS_PINT_IRQ) 65#if !defined(CONFIG_CPU_HAS_PINT_IRQ)
143int ipr_irq_demux(int irq) 66int ipr_irq_demux(int irq)
144{ 67{
diff --git a/arch/sh/kernel/cpu/sh2/Makefile b/arch/sh/kernel/cpu/sh2/Makefile
index 389353fba608..f0f059acfcfb 100644
--- a/arch/sh/kernel/cpu/sh2/Makefile
+++ b/arch/sh/kernel/cpu/sh2/Makefile
@@ -2,5 +2,6 @@
2# Makefile for the Linux/SuperH SH-2 backends. 2# Makefile for the Linux/SuperH SH-2 backends.
3# 3#
4 4
5obj-y := probe.o 5obj-y := ex.o probe.o entry.o
6 6
7obj-$(CONFIG_CPU_SUBTYPE_SH7619) += setup-sh7619.o clock-sh7619.o
diff --git a/arch/sh/kernel/cpu/sh2/clock-sh7619.c b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
new file mode 100644
index 000000000000..d0440b269702
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
@@ -0,0 +1,81 @@
1/*
2 * arch/sh/kernel/cpu/sh2/clock-sh7619.c
3 *
4 * SH7619 support for the clock framework
5 *
6 * Copyright (C) 2006 Yoshinori Sato
7 *
8 * Based on clock-sh4.c
9 * Copyright (C) 2005 Paul Mundt
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <asm/clock.h>
18#include <asm/freq.h>
19#include <asm/io.h>
20
21const static int pll1rate[]={1,2};
22const static int pfc_divisors[]={1,2,0,4};
23
24#if (CONFIG_SH_CLK_MD == 1) || (CONFIG_SH_CLK_MD == 2)
25#define PLL2 (4)
26#elif (CONFIG_SH_CLK_MD == 5) || (CONFIG_SH_CLK_MD == 6)
27#define PLL2 (2)
28#else
29#error "Illigal Clock Mode!"
30#endif
31
32static void master_clk_init(struct clk *clk)
33{
34 clk->rate *= PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
35}
36
37static struct clk_ops sh7619_master_clk_ops = {
38 .init = master_clk_init,
39};
40
41static void module_clk_recalc(struct clk *clk)
42{
43 int idx = (ctrl_inw(FREQCR) & 0x0007);
44 clk->rate = clk->parent->rate / pfc_divisors[idx];
45}
46
47static struct clk_ops sh7619_module_clk_ops = {
48 .recalc = module_clk_recalc,
49};
50
51static void bus_clk_recalc(struct clk *clk)
52{
53 clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
54}
55
56static struct clk_ops sh7619_bus_clk_ops = {
57 .recalc = bus_clk_recalc,
58};
59
60static void cpu_clk_recalc(struct clk *clk)
61{
62 clk->rate = clk->parent->rate;
63}
64
65static struct clk_ops sh7619_cpu_clk_ops = {
66 .recalc = cpu_clk_recalc,
67};
68
69static struct clk_ops *sh7619_clk_ops[] = {
70 &sh7619_master_clk_ops,
71 &sh7619_module_clk_ops,
72 &sh7619_bus_clk_ops,
73 &sh7619_cpu_clk_ops,
74};
75
76void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
77{
78 if (idx < ARRAY_SIZE(sh7619_clk_ops))
79 *ops = sh7619_clk_ops[idx];
80}
81
diff --git a/arch/sh/kernel/cpu/sh2/entry.S b/arch/sh/kernel/cpu/sh2/entry.S
new file mode 100644
index 000000000000..34d51b3745ea
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/entry.S
@@ -0,0 +1,341 @@
1/*
2 * arch/sh/kernel/cpu/sh2/entry.S
3 *
4 * The SH-2 exception entry
5 *
6 * Copyright (C) 2005,2006 Yoshinori Sato
7 * Copyright (C) 2005 AXE,Inc.
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13
14#include <linux/linkage.h>
15#include <asm/asm-offsets.h>
16#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/unistd.h>
19#include <asm/errno.h>
20#include <asm/page.h>
21
22/* Offsets to the stack */
23OFF_R0 = 0 /* Return value. New ABI also arg4 */
24OFF_R1 = 4 /* New ABI: arg5 */
25OFF_R2 = 8 /* New ABI: arg6 */
26OFF_R3 = 12 /* New ABI: syscall_nr */
27OFF_R4 = 16 /* New ABI: arg0 */
28OFF_R5 = 20 /* New ABI: arg1 */
29OFF_R6 = 24 /* New ABI: arg2 */
30OFF_R7 = 28 /* New ABI: arg3 */
31OFF_SP = (15*4)
32OFF_PC = (16*4)
33OFF_SR = (16*4+2*4)
34OFF_TRA = (16*4+6*4)
35
36#include <asm/entry-macros.S>
37
38ENTRY(exception_handler)
39 ! already saved r0/r1
40 mov.l r2,@-sp
41 mov.l r3,@-sp
42 mov r0,r1
43 cli
44 mov.l $cpu_mode,r2
45 mov.l @r2,r0
46 mov.l @(5*4,r15),r3 ! previous SR
47 shll2 r3 ! set "S" flag
48 rotl r0 ! T <- "S" flag
49 rotl r0 ! "S" flag is LSB
50 rotcr r3 ! T -> r3:b30
51 shlr r3
52 shlr r0
53 bt/s 1f
54 mov.l r3,@(5*4,r15) ! copy cpu mode to SR
55 ! switch to kernel mode
56 mov #1,r0
57 rotr r0
58 rotr r0
59 mov.l r0,@r2 ! enter kernel mode
60 mov.l $current_thread_info,r2
61 mov.l @r2,r2
62 mov #0x20,r0
63 shll8 r0
64 add r2,r0
65 mov r15,r2 ! r2 = user stack top
66 mov r0,r15 ! switch kernel stack
67 add #-4,r15 ! dummy
68 mov.l r1,@-r15 ! TRA
69 sts.l macl, @-r15
70 sts.l mach, @-r15
71 stc.l gbr, @-r15
72 mov.l @(4*4,r2),r0
73 mov.l @(5*4,r2),r1
74 mov.l r1,@-r15 ! original SR
75 sts.l pr,@-r15
76 mov.l r0,@-r15 ! original PC
77 mov r2,r3
78 add #(4+2)*4,r3 ! rewind r0 - r3 + exception frame
79 mov.l r3,@-r15 ! original SP
80 mov.l r14,@-r15
81 mov.l r13,@-r15
82 mov.l r12,@-r15
83 mov.l r11,@-r15
84 mov.l r10,@-r15
85 mov.l r9,@-r15
86 mov.l r8,@-r15
87 mov.l r7,@-r15
88 mov.l r6,@-r15
89 mov.l r5,@-r15
90 mov.l r4,@-r15
91 mov r2,r8 ! copy user -> kernel stack
92 mov.l @r8+,r3
93 mov.l r3,@-r15
94 mov.l @r8+,r2
95 mov.l r2,@-r15
96 mov.l @r8+,r1
97 mov.l r1,@-r15
98 mov.l @r8+,r0
99 bra 2f
100 mov.l r0,@-r15
1011:
102 ! in kernel exception
103 mov #(22-4-4-1)*4+4,r0
104 mov r15,r2
105 sub r0,r15
106 mov.l @r2+,r0 ! old R3
107 mov.l r0,@-r15
108 mov.l @r2+,r0 ! old R2
109 mov.l r0,@-r15
110 mov.l @r2+,r0 ! old R1
111 mov.l r0,@-r15
112 mov.l @r2+,r0 ! old R0
113 mov.l r0,@-r15
114 mov.l @r2+,r3 ! old PC
115 mov.l @r2+,r0 ! old SR
116 add #-4,r2 ! exception frame stub (sr)
117 mov.l r1,@-r2 ! TRA
118 sts.l macl, @-r2
119 sts.l mach, @-r2
120 stc.l gbr, @-r2
121 mov.l r0,@-r2 ! save old SR
122 sts.l pr,@-r2
123 mov.l r3,@-r2 ! save old PC
124 mov r2,r0
125 add #8*4,r0
126 mov.l r0,@-r2 ! save old SP
127 mov.l r14,@-r2
128 mov.l r13,@-r2
129 mov.l r12,@-r2
130 mov.l r11,@-r2
131 mov.l r10,@-r2
132 mov.l r9,@-r2
133 mov.l r8,@-r2
134 mov.l r7,@-r2
135 mov.l r6,@-r2
136 mov.l r5,@-r2
137 mov.l r4,@-r2
138 mov.l @(OFF_R0,r15),r0
139 mov.l @(OFF_R1,r15),r1
140 mov.l @(OFF_R2,r15),r2
141 mov.l @(OFF_R3,r15),r3
1422:
143 mov #OFF_TRA,r8
144 add r15,r8
145 mov.l @r8,r9
146 mov #64,r8
147 cmp/hs r8,r9
148 bt interrupt_entry ! vec >= 64 is interrupt
149 mov #32,r8
150 cmp/hs r8,r9
151 bt trap_entry ! 64 > vec >= 32 is trap
152 mov.l 4f,r8
153 mov r9,r4
154 shll2 r9
155 add r9,r8
156 mov.l @r8,r8
157 mov #0,r9
158 cmp/eq r9,r8
159 bf 3f
160 mov.l 8f,r8 ! unhandled exception
1613:
162 mov.l 5f,r10
163 jmp @r8
164 lds r10,pr
165
166interrupt_entry:
167 mov r9,r4
168 mov.l 6f,r9
169 mov.l 7f,r8
170 jmp @r8
171 lds r9,pr
172
173 .align 2
1744: .long exception_handling_table
1755: .long ret_from_exception
1766: .long ret_from_irq
1777: .long do_IRQ
1788: .long do_exception_error
179
180trap_entry:
181 add #-0x10,r9
182 shll2 r9 ! TRA
183 mov #OFF_TRA,r8
184 add r15,r8
185 mov.l r9,@r8
186 mov r9,r8
187#ifdef CONFIG_TRACE_IRQFLAGS
188 mov.l 5f, r9
189 jsr @r9
190 nop
191#endif
192 sti
193 bra system_call
194 nop
195
196 .align 2
1971: .long syscall_exit
1982: .long break_point_trap_software
1993: .long NR_syscalls
2004: .long sys_call_table
201#ifdef CONFIG_TRACE_IRQFLAGS
2025: .long trace_hardirqs_on
203#endif
204
205#if defined(CONFIG_SH_STANDARD_BIOS)
206 /* Unwind the stack and jmp to the debug entry */
207debug_kernel_fw:
208 mov r15,r0
209 add #(22-4)*4-4,r0
210 ldc.l @r0+,gbr
211 lds.l @r0+,mach
212 lds.l @r0+,macl
213 mov r15,r0
214 mov.l @(OFF_SP,r0),r1
215 mov #OFF_SR,r2
216 mov.l @(r0,r2),r3
217 mov.l r3,@-r1
218 mov #OFF_SP,r2
219 mov.l @(r0,r2),r3
220 mov.l r3,@-r1
221 mov r15,r0
222 add #(22-4)*4-8,r0
223 mov.l 1f,r2
224 mov.l @r2,r2
225 stc sr,r3
226 mov.l r2,@r0
227 mov.l r3,@r0
228 mov.l r1,@(8,r0)
229 mov.l @r15+, r0
230 mov.l @r15+, r1
231 mov.l @r15+, r2
232 mov.l @r15+, r3
233 mov.l @r15+, r4
234 mov.l @r15+, r5
235 mov.l @r15+, r6
236 mov.l @r15+, r7
237 mov.l @r15+, r8
238 mov.l @r15+, r9
239 mov.l @r15+, r10
240 mov.l @r15+, r11
241 mov.l @r15+, r12
242 mov.l @r15+, r13
243 mov.l @r15+, r14
244 add #8,r15
245 lds.l @r15+, pr
246 rte
247 mov.l @r15+,r15
248 .align 2
2491: .long gdb_vbr_vector
250#endif /* CONFIG_SH_STANDARD_BIOS */
251
252ENTRY(address_error_handler)
253 mov r15,r4 ! regs
254 add #4,r4
255 mov #OFF_PC,r0
256 mov.l @(r0,r15),r6 ! pc
257 mov.l 1f,r0
258 jmp @r0
259 mov #0,r5 ! writeaccess is unknown
260 .align 2
261
2621: .long do_address_error
263
264restore_all:
265 cli
266#ifdef CONFIG_TRACE_IRQFLAGS
267 mov.l 3f, r0
268 jsr @r0
269 nop
270#endif
271 mov r15,r0
272 mov.l $cpu_mode,r2
273 mov #OFF_SR,r3
274 mov.l @(r0,r3),r1
275 mov.l r1,@r2
276 shll2 r1 ! clear MD bit
277 shlr2 r1
278 mov.l @(OFF_SP,r0),r2
279 add #-8,r2
280 mov.l r2,@(OFF_SP,r0) ! point exception frame top
281 mov.l r1,@(4,r2) ! set sr
282 mov #OFF_PC,r3
283 mov.l @(r0,r3),r1
284 mov.l r1,@r2 ! set pc
285 add #4*16+4,r0
286 lds.l @r0+,pr
287 add #4,r0 ! skip sr
288 ldc.l @r0+,gbr
289 lds.l @r0+,mach
290 lds.l @r0+,macl
291 get_current_thread_info r0, r1
292 mov.l $current_thread_info,r1
293 mov.l r0,@r1
294 mov.l @r15+,r0
295 mov.l @r15+,r1
296 mov.l @r15+,r2
297 mov.l @r15+,r3
298 mov.l @r15+,r4
299 mov.l @r15+,r5
300 mov.l @r15+,r6
301 mov.l @r15+,r7
302 mov.l @r15+,r8
303 mov.l @r15+,r9
304 mov.l @r15+,r10
305 mov.l @r15+,r11
306 mov.l @r15+,r12
307 mov.l @r15+,r13
308 mov.l @r15+,r14
309 mov.l @r15,r15
310 rte
311 nop
3122:
313 mov.l 1f,r8
314 mov.l 2f,r9
315 jmp @r9
316 lds r8,pr
317
318 .align 2
319$current_thread_info:
320 .long __current_thread_info
321$cpu_mode:
322 .long __cpu_mode
323#ifdef CONFIG_TRACE_IRQFLAGS
3243: .long trace_hardirqs_off
325#endif
326
327! common exception handler
328#include "../../entry-common.S"
329
330 .data
331! cpu operation mode
332! bit30 = MD (compatible SH3/4)
333__cpu_mode:
334 .long 0x40000000
335
336 .section .bss
337__current_thread_info:
338 .long 0
339
340ENTRY(exception_handling_table)
341 .space 4*32
diff --git a/arch/sh/kernel/cpu/sh2/ex.S b/arch/sh/kernel/cpu/sh2/ex.S
new file mode 100644
index 000000000000..6d285af7846c
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/ex.S
@@ -0,0 +1,46 @@
1/*
2 * arch/sh/kernel/cpu/sh2/ex.S
3 *
4 * The SH-2 exception vector table
5 *
6 * Copyright (C) 2005 Yoshinori Sato
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/linkage.h>
14
15!
16! convert Exception Vector to Exception Number
17!
18exception_entry:
19no = 0
20 .rept 256
21 mov.l r0,@-sp
22 mov #no,r0
23 bra exception_trampoline
24 and #0xff,r0
25no = no + 1
26 .endr
27exception_trampoline:
28 mov.l r1,@-sp
29 mov.l $exception_handler,r1
30 jmp @r1
31
32 .align 2
33$exception_entry:
34 .long exception_entry
35$exception_handler:
36 .long exception_handler
37!
38! Exception Vector Base
39!
40 .align 2
41ENTRY(vbr_base)
42vector = 0
43 .rept 256
44 .long exception_entry + vector * 8
45vector = vector + 1
46 .endr
diff --git a/arch/sh/kernel/cpu/sh2/probe.c b/arch/sh/kernel/cpu/sh2/probe.c
index f17a2a0d588e..ba527d9b5024 100644
--- a/arch/sh/kernel/cpu/sh2/probe.c
+++ b/arch/sh/kernel/cpu/sh2/probe.c
@@ -17,17 +17,23 @@
17 17
18int __init detect_cpu_and_cache_system(void) 18int __init detect_cpu_and_cache_system(void)
19{ 19{
20 /* 20#if defined(CONFIG_CPU_SUBTYPE_SH7604)
21 * For now, assume SH7604 .. fix this later.
22 */
23 cpu_data->type = CPU_SH7604; 21 cpu_data->type = CPU_SH7604;
24 cpu_data->dcache.ways = 4; 22 cpu_data->dcache.ways = 4;
25 cpu_data->dcache.way_shift = 6; 23 cpu_data->dcache.way_incr = (1<<10);
26 cpu_data->dcache.sets = 64; 24 cpu_data->dcache.sets = 64;
27 cpu_data->dcache.entry_shift = 4; 25 cpu_data->dcache.entry_shift = 4;
28 cpu_data->dcache.linesz = L1_CACHE_BYTES; 26 cpu_data->dcache.linesz = L1_CACHE_BYTES;
29 cpu_data->dcache.flags = 0; 27 cpu_data->dcache.flags = 0;
30 28#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
29 cpu_data->type = CPU_SH7619;
30 cpu_data->dcache.ways = 4;
31 cpu_data->dcache.way_incr = (1<<12);
32 cpu_data->dcache.sets = 256;
33 cpu_data->dcache.entry_shift = 4;
34 cpu_data->dcache.linesz = L1_CACHE_BYTES;
35 cpu_data->dcache.flags = 0;
36#endif
31 /* 37 /*
32 * SH-2 doesn't have separate caches 38 * SH-2 doesn't have separate caches
33 */ 39 */
diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
new file mode 100644
index 000000000000..82c2d905152f
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
@@ -0,0 +1,53 @@
1/*
2 * SH7619 Setup
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xf8400000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 88, 89, 91, 90},
21 }, {
22 .mapbase = 0xf8410000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 92, 93, 95, 94},
26 }, {
27 .mapbase = 0xf8420000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 96, 97, 99, 98},
31 }, {
32 .flags = 0,
33 }
34};
35
36static struct platform_device sci_device = {
37 .name = "sh-sci",
38 .id = -1,
39 .dev = {
40 .platform_data = sci_platform_data,
41 },
42};
43
44static struct platform_device *sh7619_devices[] __initdata = {
45 &sci_device,
46};
47
48static int __init sh7619_devices_setup(void)
49{
50 return platform_add_devices(sh7619_devices,
51 ARRAY_SIZE(sh7619_devices));
52}
53__initcall(sh7619_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh2a/Makefile b/arch/sh/kernel/cpu/sh2a/Makefile
new file mode 100644
index 000000000000..350972ae9410
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/Makefile
@@ -0,0 +1,10 @@
1#
2# Makefile for the Linux/SuperH SH-2A backends.
3#
4
5obj-y := common.o probe.o
6
7common-y += $(addprefix ../sh2/, ex.o)
8common-y += $(addprefix ../sh2/, entry.o)
9
10obj-$(CONFIG_CPU_SUBTYPE_SH7206) += setup-sh7206.o clock-sh7206.o
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7206.c b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
new file mode 100644
index 000000000000..a9ad309c6a33
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
@@ -0,0 +1,85 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/clock-sh7206.c
3 *
4 * SH7206 support for the clock framework
5 *
6 * Copyright (C) 2006 Yoshinori Sato
7 *
8 * Based on clock-sh4.c
9 * Copyright (C) 2005 Paul Mundt
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <asm/clock.h>
18#include <asm/freq.h>
19#include <asm/io.h>
20
21const static int pll1rate[]={1,2,3,4,6,8};
22const static int pfc_divisors[]={1,2,3,4,6,8,12};
23#define ifc_divisors pfc_divisors
24
25#if (CONFIG_SH_CLK_MD == 2)
26#define PLL2 (4)
27#elif (CONFIG_SH_CLK_MD == 6)
28#define PLL2 (2)
29#elif (CONFIG_SH_CLK_MD == 7)
30#define PLL2 (1)
31#else
32#error "Illigal Clock Mode!"
33#endif
34
35static void master_clk_init(struct clk *clk)
36{
37 clk->rate *= PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
38}
39
40static struct clk_ops sh7206_master_clk_ops = {
41 .init = master_clk_init,
42};
43
44static void module_clk_recalc(struct clk *clk)
45{
46 int idx = (ctrl_inw(FREQCR) & 0x0007);
47 clk->rate = clk->parent->rate / pfc_divisors[idx];
48}
49
50static struct clk_ops sh7206_module_clk_ops = {
51 .recalc = module_clk_recalc,
52};
53
54static void bus_clk_recalc(struct clk *clk)
55{
56 clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
57}
58
59static struct clk_ops sh7206_bus_clk_ops = {
60 .recalc = bus_clk_recalc,
61};
62
63static void cpu_clk_recalc(struct clk *clk)
64{
65 int idx = (ctrl_inw(FREQCR) & 0x0007);
66 clk->rate = clk->parent->rate / ifc_divisors[idx];
67}
68
69static struct clk_ops sh7206_cpu_clk_ops = {
70 .recalc = cpu_clk_recalc,
71};
72
73static struct clk_ops *sh7206_clk_ops[] = {
74 &sh7206_master_clk_ops,
75 &sh7206_module_clk_ops,
76 &sh7206_bus_clk_ops,
77 &sh7206_cpu_clk_ops,
78};
79
80void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
81{
82 if (idx < ARRAY_SIZE(sh7206_clk_ops))
83 *ops = sh7206_clk_ops[idx];
84}
85
diff --git a/arch/sh/kernel/cpu/sh2a/probe.c b/arch/sh/kernel/cpu/sh2a/probe.c
new file mode 100644
index 000000000000..87c6c0542089
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/probe.c
@@ -0,0 +1,39 @@
1/*
2 * arch/sh/kernel/cpu/sh2a/probe.c
3 *
4 * CPU Subtype Probing for SH-2A.
5 *
6 * Copyright (C) 2004, 2005 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/init.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16
17int __init detect_cpu_and_cache_system(void)
18{
19 /* Just SH7206 for now .. */
20 cpu_data->type = CPU_SH7206;
21
22 cpu_data->dcache.ways = 4;
23 cpu_data->dcache.way_incr = (1 << 11);
24 cpu_data->dcache.sets = 128;
25 cpu_data->dcache.entry_shift = 4;
26 cpu_data->dcache.linesz = L1_CACHE_BYTES;
27 cpu_data->dcache.flags = 0;
28
29 /*
30 * The icache is the same as the dcache as far as this setup is
31 * concerned. The only real difference in hardware is that the icache
32 * lacks the U bit that the dcache has, none of this has any bearing
33 * on the cache info.
34 */
35 cpu_data->icache = cpu_data->dcache;
36
37 return 0;
38}
39
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
new file mode 100644
index 000000000000..cdfeef49e62e
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
@@ -0,0 +1,58 @@
1/*
2 * SH7206 Setup
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xfffe8000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 240, 241, 242, 243},
21 }, {
22 .mapbase = 0xfffe8800,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 244, 245, 246, 247},
26 }, {
27 .mapbase = 0xfffe9000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 248, 249, 250, 251},
31 }, {
32 .mapbase = 0xfffe9800,
33 .flags = UPF_BOOT_AUTOCONF,
34 .type = PORT_SCIF,
35 .irqs = { 252, 253, 254, 255},
36 }, {
37 .flags = 0,
38 }
39};
40
41static struct platform_device sci_device = {
42 .name = "sh-sci",
43 .id = -1,
44 .dev = {
45 .platform_data = sci_platform_data,
46 },
47};
48
49static struct platform_device *sh7206_devices[] __initdata = {
50 &sci_device,
51};
52
53static int __init sh7206_devices_setup(void)
54{
55 return platform_add_devices(sh7206_devices,
56 ARRAY_SIZE(sh7206_devices));
57}
58__initcall(sh7206_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
index 58d3815695ff..83905e4e4387 100644
--- a/arch/sh/kernel/cpu/sh3/Makefile
+++ b/arch/sh/kernel/cpu/sh3/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH SH-3 backends. 2# Makefile for the Linux/SuperH SH-3 backends.
3# 3#
4 4
5obj-y := ex.o probe.o 5obj-y := ex.o probe.o entry.o
6 6
7# CPU subtype setup 7# CPU subtype setup
8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o 8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7709.c b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
index 10461a745e5f..b791a29fdb62 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7709.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
@@ -24,7 +24,7 @@ static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 };
24 24
25static void set_bus_parent(struct clk *clk) 25static void set_bus_parent(struct clk *clk)
26{ 26{
27 struct clk *bus_clk = clk_get("bus_clk"); 27 struct clk *bus_clk = clk_get(NULL, "bus_clk");
28 clk->parent = bus_clk; 28 clk->parent = bus_clk;
29 clk_put(bus_clk); 29 clk_put(bus_clk);
30} 30}
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/cpu/sh3/entry.S
index 39aaefb2d83f..8c0dc2700c69 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/cpu/sh3/entry.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/arch/sh/entry.S 2 * arch/sh/kernel/entry.S
3 * 3 *
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2003 - 2006 Paul Mundt 5 * Copyright (C) 2003 - 2006 Paul Mundt
@@ -7,15 +7,16 @@
7 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details. 9 * for more details.
10 *
11 */ 10 */
12#include <linux/sys.h> 11#include <linux/sys.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
14#include <linux/linkage.h> 13#include <linux/linkage.h>
15#include <asm/asm-offsets.h> 14#include <asm/asm-offsets.h>
16#include <asm/thread_info.h> 15#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/unistd.h> 16#include <asm/unistd.h>
17#include <asm/cpu/mmu_context.h>
18#include <asm/pgtable.h>
19#include <asm/page.h>
19 20
20! NOTE: 21! NOTE:
21! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address 22! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address
@@ -81,6 +82,8 @@ OFF_TRA = (16*4+6*4)
81#define k_g_imask r6_bank /* r6_bank1 */ 82#define k_g_imask r6_bank /* r6_bank1 */
82#define current r7 /* r7_bank1 */ 83#define current r7 /* r7_bank1 */
83 84
85#include <asm/entry-macros.S>
86
84/* 87/*
85 * Kernel mode register usage: 88 * Kernel mode register usage:
86 * k0 scratch 89 * k0 scratch
@@ -107,26 +110,6 @@ OFF_TRA = (16*4+6*4)
107! this first version depends *much* on C implementation. 110! this first version depends *much* on C implementation.
108! 111!
109 112
110#define CLI() \
111 stc sr, r0; \
112 or #0xf0, r0; \
113 ldc r0, sr
114
115#define STI() \
116 mov.l __INV_IMASK, r11; \
117 stc sr, r10; \
118 and r11, r10; \
119 stc k_g_imask, r11; \
120 or r11, r10; \
121 ldc r10, sr
122
123#if defined(CONFIG_PREEMPT)
124# define preempt_stop() CLI()
125#else
126# define preempt_stop()
127# define resume_kernel restore_all
128#endif
129
130#if defined(CONFIG_MMU) 113#if defined(CONFIG_MMU)
131 .align 2 114 .align 2
132ENTRY(tlb_miss_load) 115ENTRY(tlb_miss_load)
@@ -155,29 +138,14 @@ ENTRY(tlb_protection_violation_store)
155 138
156call_dpf: 139call_dpf:
157 mov.l 1f, r0 140 mov.l 1f, r0
158 mov r5, r8 141 mov.l @r0, r6 ! address
159 mov.l @r0, r6
160 mov r6, r9
161 mov.l 2f, r0
162 sts pr, r10
163 jsr @r0
164 mov r15, r4
165 !
166 tst r0, r0
167 bf/s 0f
168 lds r10, pr
169 rts
170 nop
1710: STI()
172 mov.l 3f, r0 142 mov.l 3f, r0
173 mov r9, r6 143
174 mov r8, r5
175 jmp @r0 144 jmp @r0
176 mov r15, r4 145 mov r15, r4 ! regs
177 146
178 .align 2 147 .align 2
1791: .long MMU_TEA 1481: .long MMU_TEA
1802: .long __do_page_fault
1813: .long do_page_fault 1493: .long do_page_fault
182 150
183 .align 2 151 .align 2
@@ -203,32 +171,6 @@ call_dae:
2032: .long do_address_error 1712: .long do_address_error
204#endif /* CONFIG_MMU */ 172#endif /* CONFIG_MMU */
205 173
206#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
207! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
208! If both are configured, handle the debug traps (breakpoints) in SW,
209! but still allow BIOS traps to FW.
210
211 .align 2
212debug_kernel:
213#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
214 /* Force BIOS call to FW (debug_trap put TRA in r8) */
215 mov r8,r0
216 shlr2 r0
217 cmp/eq #0x3f,r0
218 bt debug_kernel_fw
219#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
220
221debug_enter:
222#if defined(CONFIG_SH_KGDB)
223 /* Jump to kgdb, pass stacked regs as arg */
224debug_kernel_sw:
225 mov.l 3f, r0
226 jmp @r0
227 mov r15, r4
228 .align 2
2293: .long kgdb_handle_exception
230#endif /* CONFIG_SH_KGDB */
231
232#if defined(CONFIG_SH_STANDARD_BIOS) 174#if defined(CONFIG_SH_STANDARD_BIOS)
233 /* Unwind the stack and jmp to the debug entry */ 175 /* Unwind the stack and jmp to the debug entry */
234debug_kernel_fw: 176debug_kernel_fw:
@@ -269,276 +211,6 @@ debug_kernel_fw:
2692: .long gdb_vbr_vector 2112: .long gdb_vbr_vector
270#endif /* CONFIG_SH_STANDARD_BIOS */ 212#endif /* CONFIG_SH_STANDARD_BIOS */
271 213
272#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
273
274
275 .align 2
276debug_trap:
277#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
278 mov #OFF_SR, r0
279 mov.l @(r0,r15), r0 ! get status register
280 shll r0
281 shll r0 ! kernel space?
282 bt/s debug_kernel
283#endif
284 mov.l @r15, r0 ! Restore R0 value
285 mov.l 1f, r8
286 jmp @r8
287 nop
288
289 .align 2
290ENTRY(exception_error)
291 !
292 STI()
293 mov.l 2f, r0
294 jmp @r0
295 nop
296
297!
298 .align 2
2991: .long break_point_trap_software
3002: .long do_exception_error
301
302 .align 2
303ret_from_exception:
304 preempt_stop()
305ENTRY(ret_from_irq)
306 !
307 mov #OFF_SR, r0
308 mov.l @(r0,r15), r0 ! get status register
309 shll r0
310 shll r0 ! kernel space?
311 bt/s resume_kernel ! Yes, it's from kernel, go back soon
312 GET_THREAD_INFO(r8)
313
314#ifdef CONFIG_PREEMPT
315 bra resume_userspace
316 nop
317ENTRY(resume_kernel)
318 mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count
319 tst r0, r0
320 bf noresched
321need_resched:
322 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
323 tst #_TIF_NEED_RESCHED, r0 ! need_resched set?
324 bt noresched
325
326 mov #OFF_SR, r0
327 mov.l @(r0,r15), r0 ! get status register
328 and #0xf0, r0 ! interrupts off (exception path)?
329 cmp/eq #0xf0, r0
330 bt noresched
331
332 mov.l 1f, r0
333 mov.l r0, @(TI_PRE_COUNT,r8)
334
335 STI()
336 mov.l 2f, r0
337 jsr @r0
338 nop
339 mov #0, r0
340 mov.l r0, @(TI_PRE_COUNT,r8)
341 CLI()
342
343 bra need_resched
344 nop
345noresched:
346 bra restore_all
347 nop
348
349 .align 2
3501: .long PREEMPT_ACTIVE
3512: .long schedule
352#endif
353
354ENTRY(resume_userspace)
355 ! r8: current_thread_info
356 CLI()
357 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
358 tst #_TIF_WORK_MASK, r0
359 bt/s restore_all
360 tst #_TIF_NEED_RESCHED, r0
361
362 .align 2
363work_pending:
364 ! r0: current_thread_info->flags
365 ! r8: current_thread_info
366 ! t: result of "tst #_TIF_NEED_RESCHED, r0"
367 bf/s work_resched
368 tst #(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r0
369work_notifysig:
370 bt/s restore_all
371 mov r15, r4
372 mov r12, r5 ! set arg1(save_r0)
373 mov r0, r6
374 mov.l 2f, r1
375 mova restore_all, r0
376 jmp @r1
377 lds r0, pr
378work_resched:
379#ifndef CONFIG_PREEMPT
380 ! gUSA handling
381 mov.l @(OFF_SP,r15), r0 ! get user space stack pointer
382 mov r0, r1
383 shll r0
384 bf/s 1f
385 shll r0
386 bf/s 1f
387 mov #OFF_PC, r0
388 ! SP >= 0xc0000000 : gUSA mark
389 mov.l @(r0,r15), r2 ! get user space PC (program counter)
390 mov.l @(OFF_R0,r15), r3 ! end point
391 cmp/hs r3, r2 ! r2 >= r3?
392 bt 1f
393 add r3, r1 ! rewind point #2
394 mov.l r1, @(r0,r15) ! reset PC to rewind point #2
395 !
3961:
397#endif
398 mov.l 1f, r1
399 jsr @r1 ! schedule
400 nop
401 CLI()
402 !
403 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
404 tst #_TIF_WORK_MASK, r0
405 bt restore_all
406 bra work_pending
407 tst #_TIF_NEED_RESCHED, r0
408
409 .align 2
4101: .long schedule
4112: .long do_notify_resume
412
413 .align 2
414syscall_exit_work:
415 ! r0: current_thread_info->flags
416 ! r8: current_thread_info
417 tst #_TIF_SYSCALL_TRACE, r0
418 bt/s work_pending
419 tst #_TIF_NEED_RESCHED, r0
420 STI()
421 ! XXX setup arguments...
422 mov.l 4f, r0 ! do_syscall_trace
423 jsr @r0
424 nop
425 bra resume_userspace
426 nop
427
428 .align 2
429syscall_trace_entry:
430 ! Yes it is traced.
431 ! XXX setup arguments...
432 mov.l 4f, r11 ! Call do_syscall_trace which notifies
433 jsr @r11 ! superior (will chomp R[0-7])
434 nop
435 ! Reload R0-R4 from kernel stack, where the
436 ! parent may have modified them using
437 ! ptrace(POKEUSR). (Note that R0-R2 are
438 ! used by the system call handler directly
439 ! from the kernel stack anyway, so don't need
440 ! to be reloaded here.) This allows the parent
441 ! to rewrite system calls and args on the fly.
442 mov.l @(OFF_R4,r15), r4 ! arg0
443 mov.l @(OFF_R5,r15), r5
444 mov.l @(OFF_R6,r15), r6
445 mov.l @(OFF_R7,r15), r7 ! arg3
446 mov.l @(OFF_R3,r15), r3 ! syscall_nr
447 ! Arrange for do_syscall_trace to be called
448 ! again as the system call returns.
449 mov.l 2f, r10 ! Number of syscalls
450 cmp/hs r10, r3
451 bf syscall_call
452 mov #-ENOSYS, r0
453 bra syscall_exit
454 mov.l r0, @(OFF_R0,r15) ! Return value
455
456/*
457 * Syscall interface:
458 *
459 * Syscall #: R3
460 * Arguments #0 to #3: R4--R7
461 * Arguments #4 to #6: R0, R1, R2
462 * TRA: (number of arguments + 0x10) x 4
463 *
464 * This code also handles delegating other traps to the BIOS/gdb stub
465 * according to:
466 *
467 * Trap number
468 * (TRA>>2) Purpose
469 * -------- -------
470 * 0x0-0xf old syscall ABI
471 * 0x10-0x1f new syscall ABI
472 * 0x20-0xff delegated through debug_trap to BIOS/gdb stub.
473 *
474 * Note: When we're first called, the TRA value must be shifted
475 * right 2 bits in order to get the value that was used as the "trapa"
476 * argument.
477 */
478
479 .align 2
480 .globl ret_from_fork
481ret_from_fork:
482 mov.l 1f, r8
483 jsr @r8
484 mov r0, r4
485 bra syscall_exit
486 nop
487 .align 2
4881: .long schedule_tail
489 !
490ENTRY(system_call)
491 mov.l 1f, r9
492 mov.l @r9, r8 ! Read from TRA (Trap Address) Register
493 !
494 ! Is the trap argument >= 0x20? (TRA will be >= 0x80)
495 mov #0x7f, r9
496 cmp/hi r9, r8
497 bt/s 0f
498 mov #OFF_TRA, r9
499 add r15, r9
500 !
501 mov.l r8, @r9 ! set TRA value to tra
502 STI()
503 ! Call the system call handler through the table.
504 ! First check for bad syscall number
505 mov r3, r9
506 mov.l 2f, r8 ! Number of syscalls
507 cmp/hs r8, r9
508 bf/s good_system_call
509 GET_THREAD_INFO(r8)
510syscall_badsys: ! Bad syscall number
511 mov #-ENOSYS, r0
512 bra resume_userspace
513 mov.l r0, @(OFF_R0,r15) ! Return value
514 !
5150:
516 bra debug_trap
517 nop
518 !
519good_system_call: ! Good syscall number
520 mov.l @(TI_FLAGS,r8), r8
521 mov #_TIF_SYSCALL_TRACE, r10
522 tst r10, r8
523 bf syscall_trace_entry
524 !
525syscall_call:
526 shll2 r9 ! x4
527 mov.l 3f, r8 ! Load the address of sys_call_table
528 add r8, r9
529 mov.l @r9, r8
530 jsr @r8 ! jump to specific syscall handler
531 nop
532 mov.l @(OFF_R0,r15), r12 ! save r0
533 mov.l r0, @(OFF_R0,r15) ! save the return value
534 !
535syscall_exit:
536 CLI()
537 !
538 GET_THREAD_INFO(r8)
539 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
540 tst #_TIF_ALLWORK_MASK, r0
541 bf syscall_exit_work
542restore_all: 214restore_all:
543 mov.l @r15+, r0 215 mov.l @r15+, r0
544 mov.l @r15+, r1 216 mov.l @r15+, r1
@@ -606,7 +278,9 @@ skip_restore:
606 ! 278 !
607 ! Calculate new SR value 279 ! Calculate new SR value
608 mov k3, k2 ! original SR value 280 mov k3, k2 ! original SR value
609 mov.l 9f, k1 281 mov #0xf0, k1
282 extu.b k1, k1
283 not k1, k1
610 and k1, k2 ! Mask orignal SR value 284 and k1, k2 ! Mask orignal SR value
611 ! 285 !
612 mov k3, k0 ! Calculate IMASK-bits 286 mov k3, k0 ! Calculate IMASK-bits
@@ -632,16 +306,12 @@ skip_restore:
632 nop 306 nop
633 307
634 .align 2 308 .align 2
6351: .long TRA
6362: .long NR_syscalls
6373: .long sys_call_table
6384: .long do_syscall_trace
6395: .long 0x00001000 ! DSP 3095: .long 0x00001000 ! DSP
6407: .long 0x30000000 3107: .long 0x30000000
6419:
642__INV_IMASK:
643 .long 0xffffff0f ! ~(IMASK)
644 311
312! common exception handler
313#include "../../entry-common.S"
314
645! Exception Vector Base 315! Exception Vector Base
646! 316!
647! Should be aligned page boundary. 317! Should be aligned page boundary.
@@ -661,9 +331,176 @@ general_exception:
6612: .long ret_from_exception 3312: .long ret_from_exception
662! 332!
663! 333!
334
335/* This code makes some assumptions to improve performance.
336 * Make sure they are stil true. */
337#if PTRS_PER_PGD != PTRS_PER_PTE
338#error PGD and PTE sizes don't match
339#endif
340
341/* gas doesn't flag impossible values for mov #immediate as an error */
342#if (_PAGE_PRESENT >> 2) > 0x7f
343#error cannot load PAGE_PRESENT as an immediate
344#endif
345#if _PAGE_DIRTY > 0x7f
346#error cannot load PAGE_DIRTY as an immediate
347#endif
348#if (_PAGE_PRESENT << 2) != _PAGE_ACCESSED
349#error cannot derive PAGE_ACCESSED from PAGE_PRESENT
350#endif
351
352#if defined(CONFIG_CPU_SH4)
353#define ldmmupteh(r) mov.l 8f, r
354#else
355#define ldmmupteh(r) mov #MMU_PTEH, r
356#endif
357
664 .balign 1024,0,1024 358 .balign 1024,0,1024
665tlb_miss: 359tlb_miss:
666 mov.l 1f, k2 360#ifdef COUNT_EXCEPTIONS
361 ! Increment the counts
362 mov.l 9f, k1
363 mov.l @k1, k2
364 add #1, k2
365 mov.l k2, @k1
366#endif
367
368 ! k0 scratch
369 ! k1 pgd and pte pointers
370 ! k2 faulting address
371 ! k3 pgd and pte index masks
372 ! k4 shift
373
374 ! Load up the pgd entry (k1)
375
376 ldmmupteh(k0) ! 9 LS (latency=2) MMU_PTEH
377
378 mov.w 4f, k3 ! 8 LS (latency=2) (PTRS_PER_PGD-1) << 2
379 mov #-(PGDIR_SHIFT-2), k4 ! 6 EX
380
381 mov.l @(MMU_TEA-MMU_PTEH,k0), k2 ! 18 LS (latency=2)
382
383 mov.l @(MMU_TTB-MMU_PTEH,k0), k1 ! 18 LS (latency=2)
384
385 mov k2, k0 ! 5 MT (latency=0)
386 shld k4, k0 ! 99 EX
387
388 and k3, k0 ! 78 EX
389
390 mov.l @(k0, k1), k1 ! 21 LS (latency=2)
391 mov #-(PAGE_SHIFT-2), k4 ! 6 EX
392
393 ! Load up the pte entry (k2)
394
395 mov k2, k0 ! 5 MT (latency=0)
396 shld k4, k0 ! 99 EX
397
398 tst k1, k1 ! 86 MT
399
400 bt 20f ! 110 BR
401
402 and k3, k0 ! 78 EX
403 mov.w 5f, k4 ! 8 LS (latency=2) _PAGE_PRESENT
404
405 mov.l @(k0, k1), k2 ! 21 LS (latency=2)
406 add k0, k1 ! 49 EX
407
408#ifdef CONFIG_CPU_HAS_PTEA
409 ! Test the entry for present and _PAGE_ACCESSED
410
411 mov #-28, k3 ! 6 EX
412 mov k2, k0 ! 5 MT (latency=0)
413
414 tst k4, k2 ! 68 MT
415 shld k3, k0 ! 99 EX
416
417 bt 20f ! 110 BR
418
419 ! Set PTEA register
420 ! MMU_PTEA = ((pteval >> 28) & 0xe) | (pteval & 0x1)
421 !
422 ! k0=pte>>28, k1=pte*, k2=pte, k3=<unused>, k4=_PAGE_PRESENT
423
424 and #0xe, k0 ! 79 EX
425
426 mov k0, k3 ! 5 MT (latency=0)
427 mov k2, k0 ! 5 MT (latency=0)
428
429 and #1, k0 ! 79 EX
430
431 or k0, k3 ! 82 EX
432
433 ldmmupteh(k0) ! 9 LS (latency=2)
434 shll2 k4 ! 101 EX _PAGE_ACCESSED
435
436 tst k4, k2 ! 68 MT
437
438 mov.l k3, @(MMU_PTEA-MMU_PTEH,k0) ! 27 LS
439
440 mov.l 7f, k3 ! 9 LS (latency=2) _PAGE_FLAGS_HARDWARE_MASK
441
442 ! k0=MMU_PTEH, k1=pte*, k2=pte, k3=_PAGE_FLAGS_HARDWARE, k4=_PAGE_ACCESSED
443#else
444
445 ! Test the entry for present and _PAGE_ACCESSED
446
447 mov.l 7f, k3 ! 9 LS (latency=2) _PAGE_FLAGS_HARDWARE_MASK
448 tst k4, k2 ! 68 MT
449
450 shll2 k4 ! 101 EX _PAGE_ACCESSED
451 ldmmupteh(k0) ! 9 LS (latency=2)
452
453 bt 20f ! 110 BR
454 tst k4, k2 ! 68 MT
455
456 ! k0=MMU_PTEH, k1=pte*, k2=pte, k3=_PAGE_FLAGS_HARDWARE, k4=_PAGE_ACCESSED
457
458#endif
459
460 ! Set up the entry
461
462 and k2, k3 ! 78 EX
463 bt/s 10f ! 108 BR
464
465 mov.l k3, @(MMU_PTEL-MMU_PTEH,k0) ! 27 LS
466
467 ldtlb ! 128 CO
468
469 ! At least one instruction between ldtlb and rte
470 nop ! 119 NOP
471
472 rte ! 126 CO
473
474 nop ! 119 NOP
475
476
47710: or k4, k2 ! 82 EX
478
479 ldtlb ! 128 CO
480
481 ! At least one instruction between ldtlb and rte
482 mov.l k2, @k1 ! 27 LS
483
484 rte ! 126 CO
485
486 ! Note we cannot execute mov here, because it is executed after
487 ! restoring SSR, so would be executed in user space.
488 nop ! 119 NOP
489
490
491 .align 5
492 ! Once cache line if possible...
4931: .long swapper_pg_dir
4944: .short (PTRS_PER_PGD-1) << 2
4955: .short _PAGE_PRESENT
4967: .long _PAGE_FLAGS_HARDWARE_MASK
4978: .long MMU_PTEH
498#ifdef COUNT_EXCEPTIONS
4999: .long exception_count_miss
500#endif
501
502 ! Either pgd or pte not present
50320: mov.l 1f, k2
667 mov.l 4f, k3 504 mov.l 4f, k3
668 bra handle_exception 505 bra handle_exception
669 mov.l @k2, k2 506 mov.l @k2, k2
@@ -710,8 +547,9 @@ ENTRY(handle_exception)
710 bt/s 1f ! It's a kernel to kernel transition. 547 bt/s 1f ! It's a kernel to kernel transition.
711 mov r15, k0 ! save original stack to k0 548 mov r15, k0 ! save original stack to k0
712 /* User space to kernel */ 549 /* User space to kernel */
713 mov #(THREAD_SIZE >> 8), k1 550 mov #(THREAD_SIZE >> 10), k1
714 shll8 k1 ! k1 := THREAD_SIZE 551 shll8 k1 ! k1 := THREAD_SIZE
552 shll2 k1
715 add current, k1 553 add current, k1
716 mov k1, r15 ! change to kernel stack 554 mov k1, r15 ! change to kernel stack
717 ! 555 !
@@ -761,7 +599,7 @@ skip_save:
761 ! Save the user registers on the stack. 599 ! Save the user registers on the stack.
762 mov.l k2, @-r15 ! EXPEVT 600 mov.l k2, @-r15 ! EXPEVT
763 601
764 mov #-1, k4 602 mov #-1, k4
765 mov.l k4, @-r15 ! set TRA (default: -1) 603 mov.l k4, @-r15 ! set TRA (default: -1)
766 ! 604 !
767 sts.l macl, @-r15 605 sts.l macl, @-r15
@@ -813,6 +651,15 @@ skip_save:
813 bf interrupt_exception 651 bf interrupt_exception
814 shlr2 r8 652 shlr2 r8
815 shlr r8 653 shlr r8
654
655#ifdef COUNT_EXCEPTIONS
656 mov.l 5f, r9
657 add r8, r9
658 mov.l @r9, r10
659 add #1, r10
660 mov.l r10, @r9
661#endif
662
816 mov.l 4f, r9 663 mov.l 4f, r9
817 add r8, r9 664 add r8, r9
818 mov.l @r9, r9 665 mov.l @r9, r9
@@ -826,6 +673,9 @@ skip_save:
8262: .long 0x000080f0 ! FD=1, IMASK=15 6732: .long 0x000080f0 ! FD=1, IMASK=15
8273: .long 0xcfffffff ! RB=0, BL=0 6743: .long 0xcfffffff ! RB=0, BL=0
8284: .long exception_handling_table 6754: .long exception_handling_table
676#ifdef COUNT_EXCEPTIONS
6775: .long exception_count_table
678#endif
829 679
830interrupt_exception: 680interrupt_exception:
831 mov.l 1f, r9 681 mov.l 1f, r9
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
index 8dbf3895ece7..6e415baf04b4 100644
--- a/arch/sh/kernel/cpu/sh4/Makefile
+++ b/arch/sh/kernel/cpu/sh4/Makefile
@@ -2,7 +2,8 @@
2# Makefile for the Linux/SuperH SH-4 backends. 2# Makefile for the Linux/SuperH SH-4 backends.
3# 3#
4 4
5obj-y := ex.o probe.o 5obj-y := ex.o probe.o common.o
6common-y += $(addprefix ../sh3/, entry.o)
6 7
7obj-$(CONFIG_SH_FPU) += fpu.o 8obj-$(CONFIG_SH_FPU) += fpu.o
8obj-$(CONFIG_SH_STORE_QUEUES) += sq.o 9obj-$(CONFIG_SH_STORE_QUEUES) += sq.o
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index bfdf5fe8d948..fa2019aabd74 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -97,7 +97,7 @@ static void shoc_clk_recalc(struct clk *clk)
97 97
98static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate) 98static int shoc_clk_verify_rate(struct clk *clk, unsigned long rate)
99{ 99{
100 struct clk *bclk = clk_get("bus_clk"); 100 struct clk *bclk = clk_get(NULL, "bus_clk");
101 unsigned long bclk_rate = clk_get_rate(bclk); 101 unsigned long bclk_rate = clk_get_rate(bclk);
102 102
103 clk_put(bclk); 103 clk_put(bclk);
@@ -151,7 +151,7 @@ static struct clk *sh4202_onchip_clocks[] = {
151 151
152static int __init sh4202_clk_init(void) 152static int __init sh4202_clk_init(void)
153{ 153{
154 struct clk *clk = clk_get("master_clk"); 154 struct clk *clk = clk_get(NULL, "master_clk");
155 int i; 155 int i;
156 156
157 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) { 157 for (i = 0; i < ARRAY_SIZE(sh4202_onchip_clocks); i++) {
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh7780.c b/arch/sh/kernel/cpu/sh4/clock-sh7780.c
index 93ad367342c9..9e6a216750c8 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh7780.c
@@ -98,7 +98,7 @@ static struct clk *sh7780_onchip_clocks[] = {
98 98
99static int __init sh7780_clk_init(void) 99static int __init sh7780_clk_init(void)
100{ 100{
101 struct clk *clk = clk_get("master_clk"); 101 struct clk *clk = clk_get(NULL, "master_clk");
102 int i; 102 int i;
103 103
104 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { 104 for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) {
diff --git a/arch/sh/kernel/cpu/sh4/fpu.c b/arch/sh/kernel/cpu/sh4/fpu.c
index f486c07e10e2..7624677f6628 100644
--- a/arch/sh/kernel/cpu/sh4/fpu.c
+++ b/arch/sh/kernel/cpu/sh4/fpu.c
@@ -282,11 +282,8 @@ ieee_fpe_handler (struct pt_regs *regs)
282 grab_fpu(regs); 282 grab_fpu(regs);
283 restore_fpu(tsk); 283 restore_fpu(tsk);
284 set_tsk_thread_flag(tsk, TIF_USEDFPU); 284 set_tsk_thread_flag(tsk, TIF_USEDFPU);
285 } else { 285 } else
286 tsk->thread.trap_no = 11;
287 tsk->thread.error_code = 0;
288 force_sig(SIGFPE, tsk); 286 force_sig(SIGFPE, tsk);
289 }
290 287
291 regs->pc = nextpc; 288 regs->pc = nextpc;
292 return 1; 289 return 1;
@@ -296,29 +293,29 @@ ieee_fpe_handler (struct pt_regs *regs)
296} 293}
297 294
298asmlinkage void 295asmlinkage void
299do_fpu_error(unsigned long r4, unsigned long r5, unsigned long r6, unsigned long r7, 296do_fpu_error(unsigned long r4, unsigned long r5, unsigned long r6,
300 struct pt_regs regs) 297 unsigned long r7, struct pt_regs __regs)
301{ 298{
299 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
302 struct task_struct *tsk = current; 300 struct task_struct *tsk = current;
303 301
304 if (ieee_fpe_handler (&regs)) 302 if (ieee_fpe_handler(regs))
305 return; 303 return;
306 304
307 regs.pc += 2; 305 regs->pc += 2;
308 save_fpu(tsk, &regs); 306 save_fpu(tsk, regs);
309 tsk->thread.trap_no = 11;
310 tsk->thread.error_code = 0;
311 force_sig(SIGFPE, tsk); 307 force_sig(SIGFPE, tsk);
312} 308}
313 309
314asmlinkage void 310asmlinkage void
315do_fpu_state_restore(unsigned long r4, unsigned long r5, unsigned long r6, 311do_fpu_state_restore(unsigned long r4, unsigned long r5, unsigned long r6,
316 unsigned long r7, struct pt_regs regs) 312 unsigned long r7, struct pt_regs __regs)
317{ 313{
314 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
318 struct task_struct *tsk = current; 315 struct task_struct *tsk = current;
319 316
320 grab_fpu(&regs); 317 grab_fpu(regs);
321 if (!user_mode(&regs)) { 318 if (!user_mode(regs)) {
322 printk(KERN_ERR "BUG: FPU is used in kernel mode.\n"); 319 printk(KERN_ERR "BUG: FPU is used in kernel mode.\n");
323 return; 320 return;
324 } 321 }
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index c294de1e14a3..afe0f1b1c030 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -79,16 +79,16 @@ int __init detect_cpu_and_cache_system(void)
79 case 0x205: 79 case 0x205:
80 cpu_data->type = CPU_SH7750; 80 cpu_data->type = CPU_SH7750;
81 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU | 81 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
82 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA; 82 CPU_HAS_PERF_COUNTER;
83 break; 83 break;
84 case 0x206: 84 case 0x206:
85 cpu_data->type = CPU_SH7750S; 85 cpu_data->type = CPU_SH7750S;
86 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU | 86 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
87 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA; 87 CPU_HAS_PERF_COUNTER;
88 break; 88 break;
89 case 0x1100: 89 case 0x1100:
90 cpu_data->type = CPU_SH7751; 90 cpu_data->type = CPU_SH7751;
91 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 91 cpu_data->flags |= CPU_HAS_FPU;
92 break; 92 break;
93 case 0x2000: 93 case 0x2000:
94 cpu_data->type = CPU_SH73180; 94 cpu_data->type = CPU_SH73180;
@@ -126,23 +126,22 @@ int __init detect_cpu_and_cache_system(void)
126 break; 126 break;
127 case 0x8000: 127 case 0x8000:
128 cpu_data->type = CPU_ST40RA; 128 cpu_data->type = CPU_ST40RA;
129 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 129 cpu_data->flags |= CPU_HAS_FPU;
130 break; 130 break;
131 case 0x8100: 131 case 0x8100:
132 cpu_data->type = CPU_ST40GX1; 132 cpu_data->type = CPU_ST40GX1;
133 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 133 cpu_data->flags |= CPU_HAS_FPU;
134 break; 134 break;
135 case 0x700: 135 case 0x700:
136 cpu_data->type = CPU_SH4_501; 136 cpu_data->type = CPU_SH4_501;
137 cpu_data->icache.ways = 2; 137 cpu_data->icache.ways = 2;
138 cpu_data->dcache.ways = 2; 138 cpu_data->dcache.ways = 2;
139 cpu_data->flags |= CPU_HAS_PTEA;
140 break; 139 break;
141 case 0x600: 140 case 0x600:
142 cpu_data->type = CPU_SH4_202; 141 cpu_data->type = CPU_SH4_202;
143 cpu_data->icache.ways = 2; 142 cpu_data->icache.ways = 2;
144 cpu_data->dcache.ways = 2; 143 cpu_data->dcache.ways = 2;
145 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 144 cpu_data->flags |= CPU_HAS_FPU;
146 break; 145 break;
147 case 0x500 ... 0x501: 146 case 0x500 ... 0x501:
148 switch (prr) { 147 switch (prr) {
@@ -160,7 +159,7 @@ int __init detect_cpu_and_cache_system(void)
160 cpu_data->icache.ways = 2; 159 cpu_data->icache.ways = 2;
161 cpu_data->dcache.ways = 2; 160 cpu_data->dcache.ways = 2;
162 161
163 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA; 162 cpu_data->flags |= CPU_HAS_FPU;
164 163
165 break; 164 break;
166 default: 165 default:
@@ -173,6 +172,10 @@ int __init detect_cpu_and_cache_system(void)
173 cpu_data->dcache.ways = 1; 172 cpu_data->dcache.ways = 1;
174#endif 173#endif
175 174
175#ifdef CONFIG_CPU_HAS_PTEA
176 cpu_data->flags |= CPU_HAS_PTEA;
177#endif
178
176 /* 179 /*
177 * On anything that's not a direct-mapped cache, look to the CVR 180 * On anything that's not a direct-mapped cache, look to the CVR
178 * for I/D-cache specifics. 181 * for I/D-cache specifics.
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
index 50812d57c1c1..bbcb06f18b04 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -2,6 +2,7 @@
2 * SH7750/SH7751 Setup 2 * SH7750/SH7751 Setup
3 * 3 *
4 * Copyright (C) 2006 Paul Mundt 4 * Copyright (C) 2006 Paul Mundt
5 * Copyright (C) 2006 Jamie Lenehan
5 * 6 *
6 * This file is subject to the terms and conditions of the GNU General Public 7 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 8 * License. See the file "COPYING" in the main directory of this archive
@@ -10,6 +11,7 @@
10#include <linux/platform_device.h> 11#include <linux/platform_device.h>
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/serial.h> 13#include <linux/serial.h>
14#include <linux/io.h>
13#include <asm/sci.h> 15#include <asm/sci.h>
14 16
15static struct plat_sci_port sci_platform_data[] = { 17static struct plat_sci_port sci_platform_data[] = {
@@ -46,3 +48,71 @@ static int __init sh7750_devices_setup(void)
46 ARRAY_SIZE(sh7750_devices)); 48 ARRAY_SIZE(sh7750_devices));
47} 49}
48__initcall(sh7750_devices_setup); 50__initcall(sh7750_devices_setup);
51
52static struct ipr_data sh7750_ipr_map[] = {
53 /* IRQ, IPR-idx, shift, priority */
54 { 16, 0, 12, 2 }, /* TMU0 TUNI*/
55 { 17, 0, 12, 2 }, /* TMU1 TUNI */
56 { 18, 0, 4, 2 }, /* TMU2 TUNI */
57 { 19, 0, 4, 2 }, /* TMU2 TIPCI */
58 { 27, 1, 12, 2 }, /* WDT ITI */
59 { 20, 0, 0, 2 }, /* RTC ATI (alarm) */
60 { 21, 0, 0, 2 }, /* RTC PRI (period) */
61 { 22, 0, 0, 2 }, /* RTC CUI (carry) */
62 { 23, 1, 4, 3 }, /* SCI ERI */
63 { 24, 1, 4, 3 }, /* SCI RXI */
64 { 25, 1, 4, 3 }, /* SCI TXI */
65 { 40, 2, 4, 3 }, /* SCIF ERI */
66 { 41, 2, 4, 3 }, /* SCIF RXI */
67 { 42, 2, 4, 3 }, /* SCIF BRI */
68 { 43, 2, 4, 3 }, /* SCIF TXI */
69 { 34, 2, 8, 7 }, /* DMAC DMTE0 */
70 { 35, 2, 8, 7 }, /* DMAC DMTE1 */
71 { 36, 2, 8, 7 }, /* DMAC DMTE2 */
72 { 37, 2, 8, 7 }, /* DMAC DMTE3 */
73 { 28, 2, 8, 7 }, /* DMAC DMAE */
74};
75
76static struct ipr_data sh7751_ipr_map[] = {
77 { 44, 2, 8, 7 }, /* DMAC DMTE4 */
78 { 45, 2, 8, 7 }, /* DMAC DMTE5 */
79 { 46, 2, 8, 7 }, /* DMAC DMTE6 */
80 { 47, 2, 8, 7 }, /* DMAC DMTE7 */
81 /* The following use INTC_INPRI00 for masking, which is a 32-bit
82 register, not a 16-bit register like the IPRx registers, so it
83 would need special support */
84 /*{ 72, INTPRI00, 8, ? },*/ /* TMU3 TUNI */
85 /*{ 76, INTPRI00, 12, ? },*/ /* TMU4 TUNI */
86};
87
88static unsigned long ipr_offsets[] = {
89 0xffd00004UL, /* 0: IPRA */
90 0xffd00008UL, /* 1: IPRB */
91 0xffd0000cUL, /* 2: IPRC */
92 0xffd00010UL, /* 3: IPRD */
93};
94
95/* given the IPR index return the address of the IPR register */
96unsigned int map_ipridx_to_addr(int idx)
97{
98 if (idx >= ARRAY_SIZE(ipr_offsets))
99 return 0;
100 return ipr_offsets[idx];
101}
102
103#define INTC_ICR 0xffd00000UL
104#define INTC_ICR_IRLM (1<<7)
105
106/* enable individual interrupt mode for external interupts */
107void ipr_irq_enable_irlm(void)
108{
109 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
110}
111
112void __init init_IRQ_ipr()
113{
114 make_ipr_irq(sh7750_ipr_map, ARRAY_SIZE(sh7750_ipr_map));
115#ifdef CONFIG_CPU_SUBTYPE_SH7751
116 make_ipr_irq(sh7751_ipr_map, ARRAY_SIZE(sh7751_ipr_map));
117#endif
118}
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7780.c b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
index 814ddb226531..9aeaa2ddaa28 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
@@ -79,25 +79,27 @@ static int __init sh7780_devices_setup(void)
79__initcall(sh7780_devices_setup); 79__initcall(sh7780_devices_setup);
80 80
81static struct intc2_data intc2_irq_table[] = { 81static struct intc2_data intc2_irq_table[] = {
82 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2 }, 82 { 28, 0, 24, 0, 0, 2 }, /* TMU0 */
83 { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
84 { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
85 { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
86 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
87 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
88 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
89 { SCIF0_TXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
90 83
91 { SCIF1_ERI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 84 { 21, 1, 0, 0, 2, 2 },
92 { SCIF1_RXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 85 { 22, 1, 1, 0, 2, 2 },
93 { SCIF1_BRI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY }, 86 { 23, 1, 2, 0, 2, 2 },
94 { SCIF1_TXI_IRQ, 8, 16, 0, INTC_SCIF1_MSK, SCIF1_PRIORITY },
95 87
96 { PCIC0_IRQ, 0x10, 8, 0, INTC_PCIC0_MSK, PCIC0_PRIORITY }, 88 { 40, 8, 24, 0, 3, 3 }, /* SCIF0 ERI */
97 { PCIC1_IRQ, 0x10, 0, 0, INTC_PCIC1_MSK, PCIC1_PRIORITY }, 89 { 41, 8, 24, 0, 3, 3 }, /* SCIF0 RXI */
98 { PCIC2_IRQ, 0x14, 24, 0, INTC_PCIC2_MSK, PCIC2_PRIORITY }, 90 { 42, 8, 24, 0, 3, 3 }, /* SCIF0 BRI */
99 { PCIC3_IRQ, 0x14, 16, 0, INTC_PCIC3_MSK, PCIC3_PRIORITY }, 91 { 43, 8, 24, 0, 3, 3 }, /* SCIF0 TXI */
100 { PCIC4_IRQ, 0x14, 8, 0, INTC_PCIC4_MSK, PCIC4_PRIORITY }, 92
93 { 76, 8, 16, 0, 4, 3 }, /* SCIF1 ERI */
94 { 77, 8, 16, 0, 4, 3 }, /* SCIF1 RXI */
95 { 78, 8, 16, 0, 4, 3 }, /* SCIF1 BRI */
96 { 79, 8, 16, 0, 4, 3 }, /* SCIF1 TXI */
97
98 { 64, 0x10, 8, 0, 14, 2 }, /* PCIC0 */
99 { 65, 0x10, 0, 0, 15, 2 }, /* PCIC1 */
100 { 66, 0x14, 24, 0, 16, 2 }, /* PCIC2 */
101 { 67, 0x14, 16, 0, 17, 2 }, /* PCIC3 */
102 { 68, 0x14, 8, 0, 18, 2 }, /* PCIC4 */
101}; 103};
102 104
103void __init init_IRQ_intc2(void) 105void __init init_IRQ_intc2(void)
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 7bcc73f9b8df..55f43506995a 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -19,7 +19,7 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <asm/io.h> 22#include <linux/io.h>
23#include <asm/page.h> 23#include <asm/page.h>
24#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
25#include <asm/cpu/sq.h> 25#include <asm/cpu/sq.h>
@@ -67,6 +67,7 @@ void sq_flush_range(unsigned long start, unsigned int len)
67 /* Wait for completion */ 67 /* Wait for completion */
68 store_queue_barrier(); 68 store_queue_barrier();
69} 69}
70EXPORT_SYMBOL(sq_flush_range);
70 71
71static inline void sq_mapping_list_add(struct sq_mapping *map) 72static inline void sq_mapping_list_add(struct sq_mapping *map)
72{ 73{
@@ -166,7 +167,7 @@ unsigned long sq_remap(unsigned long phys, unsigned int size,
166 map->size = size; 167 map->size = size;
167 map->name = name; 168 map->name = name;
168 169
169 page = bitmap_find_free_region(sq_bitmap, 0x04000000, 170 page = bitmap_find_free_region(sq_bitmap, 0x04000000 >> PAGE_SHIFT,
170 get_order(map->size)); 171 get_order(map->size));
171 if (unlikely(page < 0)) { 172 if (unlikely(page < 0)) {
172 ret = -ENOSPC; 173 ret = -ENOSPC;
@@ -193,6 +194,7 @@ out:
193 kmem_cache_free(sq_cache, map); 194 kmem_cache_free(sq_cache, map);
194 return ret; 195 return ret;
195} 196}
197EXPORT_SYMBOL(sq_remap);
196 198
197/** 199/**
198 * sq_unmap - Unmap a Store Queue allocation 200 * sq_unmap - Unmap a Store Queue allocation
@@ -234,6 +236,7 @@ void sq_unmap(unsigned long vaddr)
234 236
235 kmem_cache_free(sq_cache, map); 237 kmem_cache_free(sq_cache, map);
236} 238}
239EXPORT_SYMBOL(sq_unmap);
237 240
238/* 241/*
239 * Needlessly complex sysfs interface. Unfortunately it doesn't seem like 242 * Needlessly complex sysfs interface. Unfortunately it doesn't seem like
@@ -402,7 +405,3 @@ module_exit(sq_api_exit);
402MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>"); 405MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
403MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues"); 406MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");
404MODULE_LICENSE("GPL"); 407MODULE_LICENSE("GPL");
405
406EXPORT_SYMBOL(sq_remap);
407EXPORT_SYMBOL(sq_unmap);
408EXPORT_SYMBOL(sq_flush_range);
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
index a00022722e9e..60340823798a 100644
--- a/arch/sh/kernel/early_printk.c
+++ b/arch/sh/kernel/early_printk.c
@@ -12,7 +12,7 @@
12#include <linux/console.h> 12#include <linux/console.h>
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <asm/io.h> 15#include <linux/io.h>
16 16
17#ifdef CONFIG_SH_STANDARD_BIOS 17#ifdef CONFIG_SH_STANDARD_BIOS
18#include <asm/sh_bios.h> 18#include <asm/sh_bios.h>
@@ -62,17 +62,9 @@ static struct console bios_console = {
62#include <linux/serial_core.h> 62#include <linux/serial_core.h>
63#include "../../../drivers/serial/sh-sci.h" 63#include "../../../drivers/serial/sh-sci.h"
64 64
65#ifdef CONFIG_CPU_SH4
66#define SCIF_REG 0xffe80000
67#elif defined(CONFIG_CPU_SUBTYPE_SH72060)
68#define SCIF_REG 0xfffe9800
69#else
70#error "Undefined SCIF for this subtype"
71#endif
72
73static struct uart_port scif_port = { 65static struct uart_port scif_port = {
74 .mapbase = SCIF_REG, 66 .mapbase = CONFIG_EARLY_SCIF_CONSOLE_PORT,
75 .membase = (char __iomem *)SCIF_REG, 67 .membase = (char __iomem *)CONFIG_EARLY_SCIF_CONSOLE_PORT,
76}; 68};
77 69
78static void scif_sercon_putc(int c) 70static void scif_sercon_putc(int c)
@@ -113,23 +105,29 @@ static struct console scif_console = {
113 .index = -1, 105 .index = -1,
114}; 106};
115 107
108#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
109/*
110 * Simple SCIF init, primarily aimed at SH7750 and other similar SH-4
111 * devices that aren't using sh-ipl+g.
112 */
116static void scif_sercon_init(int baud) 113static void scif_sercon_init(int baud)
117{ 114{
118 ctrl_outw(0, SCIF_REG + 8); 115 ctrl_outw(0, scif_port.mapbase + 8);
119 ctrl_outw(0, SCIF_REG); 116 ctrl_outw(0, scif_port.mapbase);
120 117
121 /* Set baud rate */ 118 /* Set baud rate */
122 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) / 119 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) /
123 (32 * baud) - 1, SCIF_REG + 4); 120 (32 * baud) - 1, scif_port.mapbase + 4);
124 121
125 ctrl_outw(12, SCIF_REG + 24); 122 ctrl_outw(12, scif_port.mapbase + 24);
126 ctrl_outw(8, SCIF_REG + 24); 123 ctrl_outw(8, scif_port.mapbase + 24);
127 ctrl_outw(0, SCIF_REG + 32); 124 ctrl_outw(0, scif_port.mapbase + 32);
128 ctrl_outw(0x60, SCIF_REG + 16); 125 ctrl_outw(0x60, scif_port.mapbase + 16);
129 ctrl_outw(0, SCIF_REG + 36); 126 ctrl_outw(0, scif_port.mapbase + 36);
130 ctrl_outw(0x30, SCIF_REG + 8); 127 ctrl_outw(0x30, scif_port.mapbase + 8);
131} 128}
132#endif 129#endif /* CONFIG_CPU_SH4 && !CONFIG_SH_STANDARD_BIOS */
130#endif /* CONFIG_EARLY_SCIF_CONSOLE */
133 131
134/* 132/*
135 * Setup a default console, if more than one is compiled in, rely on the 133 * Setup a default console, if more than one is compiled in, rely on the
@@ -168,7 +166,7 @@ int __init setup_early_printk(char *opt)
168 if (!strncmp(buf, "serial", 6)) { 166 if (!strncmp(buf, "serial", 6)) {
169 early_console = &scif_console; 167 early_console = &scif_console;
170 168
171#ifdef CONFIG_CPU_SH4 169#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_STANDARD_BIOS)
172 scif_sercon_init(115200); 170 scif_sercon_init(115200);
173#endif 171#endif
174 } 172 }
diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S
new file mode 100644
index 000000000000..29136a35d7c7
--- /dev/null
+++ b/arch/sh/kernel/entry-common.S
@@ -0,0 +1,433 @@
1/* $Id: entry.S,v 1.37 2004/06/11 13:02:46 doyu Exp $
2 *
3 * linux/arch/sh/entry.S
4 *
5 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 *
12 */
13
14! NOTE:
15! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address
16! to be jumped is too far, but it causes illegal slot exception.
17
18/*
19 * entry.S contains the system-call and fault low-level handling routines.
20 * This also contains the timer-interrupt handler, as well as all interrupts
21 * and faults that can result in a task-switch.
22 *
23 * NOTE: This code handles signal-recognition, which happens every time
24 * after a timer-interrupt and after each system call.
25 *
26 * NOTE: This code uses a convention that instructions in the delay slot
27 * of a transfer-control instruction are indented by an extra space, thus:
28 *
29 * jmp @k0 ! control-transfer instruction
30 * ldc k1, ssr ! delay slot
31 *
32 * Stack layout in 'ret_from_syscall':
33 * ptrace needs to have all regs on the stack.
34 * if the order here is changed, it needs to be
35 * updated in ptrace.c and ptrace.h
36 *
37 * r0
38 * ...
39 * r15 = stack pointer
40 * spc
41 * pr
42 * ssr
43 * gbr
44 * mach
45 * macl
46 * syscall #
47 *
48 */
49
50#if defined(CONFIG_PREEMPT)
51# define preempt_stop() cli
52#else
53# define preempt_stop()
54# define resume_kernel __restore_all
55#endif
56
57#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
58! Handle kernel debug if either kgdb (SW) or gdb-stub (FW) is present.
59! If both are configured, handle the debug traps (breakpoints) in SW,
60! but still allow BIOS traps to FW.
61
62 .align 2
63debug_kernel:
64#if defined(CONFIG_SH_STANDARD_BIOS) && defined(CONFIG_SH_KGDB)
65 /* Force BIOS call to FW (debug_trap put TRA in r8) */
66 mov r8,r0
67 shlr2 r0
68 cmp/eq #0x3f,r0
69 bt debug_kernel_fw
70#endif /* CONFIG_SH_STANDARD_BIOS && CONFIG_SH_KGDB */
71
72debug_enter:
73#if defined(CONFIG_SH_KGDB)
74 /* Jump to kgdb, pass stacked regs as arg */
75debug_kernel_sw:
76 mov.l 3f, r0
77 jmp @r0
78 mov r15, r4
79 .align 2
803: .long kgdb_handle_exception
81#endif /* CONFIG_SH_KGDB */
82
83#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
84
85
86 .align 2
87debug_trap:
88#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
89 mov #OFF_SR, r0
90 mov.l @(r0,r15), r0 ! get status register
91 shll r0
92 shll r0 ! kernel space?
93 bt/s debug_kernel
94#endif
95 mov.l @r15, r0 ! Restore R0 value
96 mov.l 1f, r8
97 jmp @r8
98 nop
99
100 .align 2
101ENTRY(exception_error)
102 !
103#ifdef CONFIG_TRACE_IRQFLAGS
104 mov.l 3f, r0
105 jsr @r0
106 nop
107#endif
108 sti
109 mov.l 2f, r0
110 jmp @r0
111 nop
112
113!
114 .align 2
1151: .long break_point_trap_software
1162: .long do_exception_error
117#ifdef CONFIG_TRACE_IRQFLAGS
1183: .long trace_hardirqs_on
119#endif
120
121 .align 2
122ret_from_exception:
123 preempt_stop()
124#ifdef CONFIG_TRACE_IRQFLAGS
125 mov.l 4f, r0
126 jsr @r0
127 nop
128#endif
129ENTRY(ret_from_irq)
130 !
131 mov #OFF_SR, r0
132 mov.l @(r0,r15), r0 ! get status register
133 shll r0
134 shll r0 ! kernel space?
135 get_current_thread_info r8, r0
136 bt resume_kernel ! Yes, it's from kernel, go back soon
137
138#ifdef CONFIG_PREEMPT
139 bra resume_userspace
140 nop
141ENTRY(resume_kernel)
142 mov.l @(TI_PRE_COUNT,r8), r0 ! current_thread_info->preempt_count
143 tst r0, r0
144 bf noresched
145need_resched:
146 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
147 tst #_TIF_NEED_RESCHED, r0 ! need_resched set?
148 bt noresched
149
150 mov #OFF_SR, r0
151 mov.l @(r0,r15), r0 ! get status register
152 and #0xf0, r0 ! interrupts off (exception path)?
153 cmp/eq #0xf0, r0
154 bt noresched
155
156 mov.l 1f, r0
157 mov.l r0, @(TI_PRE_COUNT,r8)
158
159#ifdef CONFIG_TRACE_IRQFLAGS
160 mov.l 3f, r0
161 jsr @r0
162 nop
163#endif
164 sti
165 mov.l 2f, r0
166 jsr @r0
167 nop
168 mov #0, r0
169 mov.l r0, @(TI_PRE_COUNT,r8)
170 cli
171#ifdef CONFIG_TRACE_IRQFLAGS
172 mov.l 4f, r0
173 jsr @r0
174 nop
175#endif
176
177 bra need_resched
178 nop
179
180noresched:
181 bra __restore_all
182 nop
183
184 .align 2
1851: .long PREEMPT_ACTIVE
1862: .long schedule
187#ifdef CONFIG_TRACE_IRQFLAGS
1883: .long trace_hardirqs_on
1894: .long trace_hardirqs_off
190#endif
191#endif
192
193ENTRY(resume_userspace)
194 ! r8: current_thread_info
195 cli
196#ifdef CONFIG_TRACE_IRQFLAGS
197 mov.l 5f, r0
198 jsr @r0
199 nop
200#endif
201 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
202 tst #_TIF_WORK_MASK, r0
203 bt/s __restore_all
204 tst #_TIF_NEED_RESCHED, r0
205
206 .align 2
207work_pending:
208 ! r0: current_thread_info->flags
209 ! r8: current_thread_info
210 ! t: result of "tst #_TIF_NEED_RESCHED, r0"
211 bf/s work_resched
212 tst #(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r0
213work_notifysig:
214 bt/s __restore_all
215 mov r15, r4
216 mov r12, r5 ! set arg1(save_r0)
217 mov r0, r6
218 mov.l 2f, r1
219 mov.l 3f, r0
220 jmp @r1
221 lds r0, pr
222work_resched:
223#ifndef CONFIG_PREEMPT
224 ! gUSA handling
225 mov.l @(OFF_SP,r15), r0 ! get user space stack pointer
226 mov r0, r1
227 shll r0
228 bf/s 1f
229 shll r0
230 bf/s 1f
231 mov #OFF_PC, r0
232 ! SP >= 0xc0000000 : gUSA mark
233 mov.l @(r0,r15), r2 ! get user space PC (program counter)
234 mov.l @(OFF_R0,r15), r3 ! end point
235 cmp/hs r3, r2 ! r2 >= r3?
236 bt 1f
237 add r3, r1 ! rewind point #2
238 mov.l r1, @(r0,r15) ! reset PC to rewind point #2
239 !
2401:
241#endif
242 mov.l 1f, r1
243 jsr @r1 ! schedule
244 nop
245 cli
246#ifdef CONFIG_TRACE_IRQFLAGS
247 mov.l 5f, r0
248 jsr @r0
249 nop
250#endif
251 !
252 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
253 tst #_TIF_WORK_MASK, r0
254 bt __restore_all
255 bra work_pending
256 tst #_TIF_NEED_RESCHED, r0
257
258 .align 2
2591: .long schedule
2602: .long do_notify_resume
2613: .long restore_all
262#ifdef CONFIG_TRACE_IRQFLAGS
2634: .long trace_hardirqs_on
2645: .long trace_hardirqs_off
265#endif
266
267 .align 2
268syscall_exit_work:
269 ! r0: current_thread_info->flags
270 ! r8: current_thread_info
271 tst #_TIF_SYSCALL_TRACE, r0
272 bt/s work_pending
273 tst #_TIF_NEED_RESCHED, r0
274#ifdef CONFIG_TRACE_IRQFLAGS
275 mov.l 5f, r0
276 jsr @r0
277 nop
278#endif
279 sti
280 ! XXX setup arguments...
281 mov.l 4f, r0 ! do_syscall_trace
282 jsr @r0
283 nop
284 bra resume_userspace
285 nop
286
287 .align 2
288syscall_trace_entry:
289 ! Yes it is traced.
290 ! XXX setup arguments...
291 mov.l 4f, r11 ! Call do_syscall_trace which notifies
292 jsr @r11 ! superior (will chomp R[0-7])
293 nop
294 ! Reload R0-R4 from kernel stack, where the
295 ! parent may have modified them using
296 ! ptrace(POKEUSR). (Note that R0-R2 are
297 ! used by the system call handler directly
298 ! from the kernel stack anyway, so don't need
299 ! to be reloaded here.) This allows the parent
300 ! to rewrite system calls and args on the fly.
301 mov.l @(OFF_R4,r15), r4 ! arg0
302 mov.l @(OFF_R5,r15), r5
303 mov.l @(OFF_R6,r15), r6
304 mov.l @(OFF_R7,r15), r7 ! arg3
305 mov.l @(OFF_R3,r15), r3 ! syscall_nr
306 !
307 mov.l 2f, r10 ! Number of syscalls
308 cmp/hs r10, r3
309 bf syscall_call
310 mov #-ENOSYS, r0
311 bra syscall_exit
312 mov.l r0, @(OFF_R0,r15) ! Return value
313
314__restore_all:
315 mov.l 1f, r0
316 jmp @r0
317 nop
318
319 .align 2
3201: .long restore_all
321
322 .align 2
323not_syscall_tra:
324 bra debug_trap
325 nop
326
327 .align 2
328syscall_badsys: ! Bad syscall number
329 mov #-ENOSYS, r0
330 bra resume_userspace
331 mov.l r0, @(OFF_R0,r15) ! Return value
332
333
334/*
335 * Syscall interface:
336 *
337 * Syscall #: R3
338 * Arguments #0 to #3: R4--R7
339 * Arguments #4 to #6: R0, R1, R2
340 * TRA: (number of arguments + 0x10) x 4
341 *
342 * This code also handles delegating other traps to the BIOS/gdb stub
343 * according to:
344 *
345 * Trap number
346 * (TRA>>2) Purpose
347 * -------- -------
348 * 0x0-0xf old syscall ABI
349 * 0x10-0x1f new syscall ABI
350 * 0x20-0xff delegated through debug_trap to BIOS/gdb stub.
351 *
352 * Note: When we're first called, the TRA value must be shifted
353 * right 2 bits in order to get the value that was used as the "trapa"
354 * argument.
355 */
356
357 .align 2
358 .globl ret_from_fork
359ret_from_fork:
360 mov.l 1f, r8
361 jsr @r8
362 mov r0, r4
363 bra syscall_exit
364 nop
365 .align 2
3661: .long schedule_tail
367 !
368ENTRY(system_call)
369#if !defined(CONFIG_CPU_SH2)
370 mov.l 1f, r9
371 mov.l @r9, r8 ! Read from TRA (Trap Address) Register
372#endif
373 !
374 ! Is the trap argument >= 0x20? (TRA will be >= 0x80)
375 mov #0x7f, r9
376 cmp/hi r9, r8
377 bt/s not_syscall_tra
378 mov #OFF_TRA, r9
379 add r15, r9
380 mov.l r8, @r9 ! set TRA value to tra
381#ifdef CONFIG_TRACE_IRQFLAGS
382 mov.l 5f, r10
383 jsr @r10
384 nop
385#endif
386 sti
387
388 !
389 get_current_thread_info r8, r10
390 mov.l @(TI_FLAGS,r8), r8
391 mov #_TIF_SYSCALL_TRACE, r10
392 tst r10, r8
393 bf syscall_trace_entry
394 !
395 mov.l 2f, r8 ! Number of syscalls
396 cmp/hs r8, r3
397 bt syscall_badsys
398 !
399syscall_call:
400 shll2 r3 ! x4
401 mov.l 3f, r8 ! Load the address of sys_call_table
402 add r8, r3
403 mov.l @r3, r8
404 jsr @r8 ! jump to specific syscall handler
405 nop
406 mov.l @(OFF_R0,r15), r12 ! save r0
407 mov.l r0, @(OFF_R0,r15) ! save the return value
408 !
409syscall_exit:
410 cli
411#ifdef CONFIG_TRACE_IRQFLAGS
412 mov.l 6f, r0
413 jsr @r0
414 nop
415#endif
416 !
417 get_current_thread_info r8, r0
418 mov.l @(TI_FLAGS,r8), r0 ! current_thread_info->flags
419 tst #_TIF_ALLWORK_MASK, r0
420 bf syscall_exit_work
421 bra __restore_all
422 nop
423 .align 2
424#if !defined(CONFIG_CPU_SH2)
4251: .long TRA
426#endif
4272: .long NR_syscalls
4283: .long sys_call_table
4294: .long do_syscall_trace
430#ifdef CONFIG_TRACE_IRQFLAGS
4315: .long trace_hardirqs_on
4326: .long trace_hardirqs_off
433#endif
diff --git a/arch/sh/kernel/head.S b/arch/sh/kernel/head.S
index f5f53d14f245..6aca4bc6ec5d 100644
--- a/arch/sh/kernel/head.S
+++ b/arch/sh/kernel/head.S
@@ -33,7 +33,7 @@ ENTRY(empty_zero_page)
33 .long 0x00360000 /* INITRD_START */ 33 .long 0x00360000 /* INITRD_START */
34 .long 0x000a0000 /* INITRD_SIZE */ 34 .long 0x000a0000 /* INITRD_SIZE */
35 .long 0 35 .long 0
36 .balign 4096,0,4096 36 .balign PAGE_SIZE,0,PAGE_SIZE
37 37
38 .text 38 .text
39/* 39/*
@@ -53,8 +53,10 @@ ENTRY(_stext)
53 ldc r0, sr 53 ldc r0, sr
54 ! Initialize global interrupt mask 54 ! Initialize global interrupt mask
55 mov #0, r0 55 mov #0, r0
56#ifdef CONFIG_CPU_HAS_SR_RB
56 ldc r0, r6_bank 57 ldc r0, r6_bank
57 58#endif
59
58 /* 60 /*
59 * Prefetch if possible to reduce cache miss penalty. 61 * Prefetch if possible to reduce cache miss penalty.
60 * 62 *
@@ -68,11 +70,14 @@ ENTRY(_stext)
68 ! 70 !
69 mov.l 2f, r0 71 mov.l 2f, r0
70 mov r0, r15 ! Set initial r15 (stack pointer) 72 mov r0, r15 ! Set initial r15 (stack pointer)
71 mov #(THREAD_SIZE >> 8), r1 73 mov #(THREAD_SIZE >> 10), r1
72 shll8 r1 ! r1 = THREAD_SIZE 74 shll8 r1 ! r1 = THREAD_SIZE
75 shll2 r1
73 sub r1, r0 ! 76 sub r1, r0 !
77#ifdef CONFIG_CPU_HAS_SR_RB
74 ldc r0, r7_bank ! ... and initial thread_info 78 ldc r0, r7_bank ! ... and initial thread_info
75 79#endif
80
76 ! Clear BSS area 81 ! Clear BSS area
77 mov.l 3f, r1 82 mov.l 3f, r1
78 add #4, r1 83 add #4, r1
@@ -95,7 +100,11 @@ ENTRY(_stext)
95 nop 100 nop
96 101
97 .balign 4 102 .balign 4
103#if defined(CONFIG_CPU_SH2)
1041: .long 0x000000F0 ! IMASK=0xF
105#else
981: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF 1061: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
107#endif
992: .long init_thread_union+THREAD_SIZE 1082: .long init_thread_union+THREAD_SIZE
1003: .long __bss_start 1093: .long __bss_start
1014: .long _end 1104: .long _end
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 944128ce9706..67be2b6e8cd1 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -12,7 +12,7 @@
12#include <linux/kernel_stat.h> 12#include <linux/kernel_stat.h>
13#include <linux/seq_file.h> 13#include <linux/seq_file.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <asm/irq.h> 15#include <linux/irq.h>
16#include <asm/processor.h> 16#include <asm/processor.h>
17#include <asm/uaccess.h> 17#include <asm/uaccess.h>
18#include <asm/thread_info.h> 18#include <asm/thread_info.h>
@@ -78,15 +78,16 @@ union irq_ctx {
78 u32 stack[THREAD_SIZE/sizeof(u32)]; 78 u32 stack[THREAD_SIZE/sizeof(u32)];
79}; 79};
80 80
81static union irq_ctx *hardirq_ctx[NR_CPUS]; 81static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
82static union irq_ctx *softirq_ctx[NR_CPUS]; 82static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
83#endif 83#endif
84 84
85asmlinkage int do_IRQ(unsigned long r4, unsigned long r5, 85asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
86 unsigned long r6, unsigned long r7, 86 unsigned long r6, unsigned long r7,
87 struct pt_regs regs) 87 struct pt_regs __regs)
88{ 88{
89 struct pt_regs *old_regs = set_irq_regs(&regs); 89 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
90 struct pt_regs *old_regs = set_irq_regs(regs);
90 int irq; 91 int irq;
91#ifdef CONFIG_4KSTACKS 92#ifdef CONFIG_4KSTACKS
92 union irq_ctx *curctx, *irqctx; 93 union irq_ctx *curctx, *irqctx;
@@ -111,7 +112,7 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
111#endif 112#endif
112 113
113#ifdef CONFIG_CPU_HAS_INTEVT 114#ifdef CONFIG_CPU_HAS_INTEVT
114 irq = (ctrl_inl(INTEVT) >> 5) - 16; 115 irq = evt2irq(ctrl_inl(INTEVT));
115#else 116#else
116 irq = r4; 117 irq = r4;
117#endif 118#endif
@@ -135,17 +136,24 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
135 irqctx->tinfo.task = curctx->tinfo.task; 136 irqctx->tinfo.task = curctx->tinfo.task;
136 irqctx->tinfo.previous_sp = current_stack_pointer; 137 irqctx->tinfo.previous_sp = current_stack_pointer;
137 138
139 /*
140 * Copy the softirq bits in preempt_count so that the
141 * softirq checks work in the hardirq context.
142 */
143 irqctx->tinfo.preempt_count =
144 (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
145 (curctx->tinfo.preempt_count & SOFTIRQ_MASK);
146
138 __asm__ __volatile__ ( 147 __asm__ __volatile__ (
139 "mov %0, r4 \n" 148 "mov %0, r4 \n"
140 "mov r15, r9 \n" 149 "mov r15, r8 \n"
141 "jsr @%1 \n" 150 "jsr @%1 \n"
142 /* swith to the irq stack */ 151 /* swith to the irq stack */
143 " mov %2, r15 \n" 152 " mov %2, r15 \n"
144 /* restore the stack (ring zero) */ 153 /* restore the stack (ring zero) */
145 "mov r9, r15 \n" 154 "mov r8, r15 \n"
146 : /* no outputs */ 155 : /* no outputs */
147 : "r" (irq), "r" (generic_handle_irq), "r" (isp) 156 : "r" (irq), "r" (generic_handle_irq), "r" (isp)
148 /* XXX: A somewhat excessive clobber list? -PFM */
149 : "memory", "r0", "r1", "r2", "r3", "r4", 157 : "memory", "r0", "r1", "r2", "r3", "r4",
150 "r5", "r6", "r7", "r8", "t", "pr" 158 "r5", "r6", "r7", "r8", "t", "pr"
151 ); 159 );
@@ -193,7 +201,7 @@ void irq_ctx_init(int cpu)
193 irqctx->tinfo.task = NULL; 201 irqctx->tinfo.task = NULL;
194 irqctx->tinfo.exec_domain = NULL; 202 irqctx->tinfo.exec_domain = NULL;
195 irqctx->tinfo.cpu = cpu; 203 irqctx->tinfo.cpu = cpu;
196 irqctx->tinfo.preempt_count = SOFTIRQ_OFFSET; 204 irqctx->tinfo.preempt_count = 0;
197 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); 205 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
198 206
199 softirq_ctx[cpu] = irqctx; 207 softirq_ctx[cpu] = irqctx;
@@ -239,13 +247,38 @@ asmlinkage void do_softirq(void)
239 "mov r9, r15 \n" 247 "mov r9, r15 \n"
240 : /* no outputs */ 248 : /* no outputs */
241 : "r" (__do_softirq), "r" (isp) 249 : "r" (__do_softirq), "r" (isp)
242 /* XXX: A somewhat excessive clobber list? -PFM */
243 : "memory", "r0", "r1", "r2", "r3", "r4", 250 : "memory", "r0", "r1", "r2", "r3", "r4",
244 "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr" 251 "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr"
245 ); 252 );
253
254 /*
255 * Shouldnt happen, we returned above if in_interrupt():
256 */
257 WARN_ON_ONCE(softirq_count());
246 } 258 }
247 259
248 local_irq_restore(flags); 260 local_irq_restore(flags);
249} 261}
250EXPORT_SYMBOL(do_softirq); 262EXPORT_SYMBOL(do_softirq);
251#endif 263#endif
264
265void __init init_IRQ(void)
266{
267#ifdef CONFIG_CPU_HAS_PINT_IRQ
268 init_IRQ_pint();
269#endif
270
271#ifdef CONFIG_CPU_HAS_INTC2_IRQ
272 init_IRQ_intc2();
273#endif
274
275#ifdef CONFIG_CPU_HAS_IPR_IRQ
276 init_IRQ_ipr();
277#endif
278
279 /* Perform the machine specific initialisation */
280 if (sh_mv.mv_init_irq)
281 sh_mv.mv_init_irq();
282
283 irq_ctx_init(smp_processor_id());
284}
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index a52b13ac6b7f..f3e2631be144 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -385,10 +385,11 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
385 385
386asmlinkage int sys_fork(unsigned long r4, unsigned long r5, 386asmlinkage int sys_fork(unsigned long r4, unsigned long r5,
387 unsigned long r6, unsigned long r7, 387 unsigned long r6, unsigned long r7,
388 struct pt_regs regs) 388 struct pt_regs __regs)
389{ 389{
390 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
390#ifdef CONFIG_MMU 391#ifdef CONFIG_MMU
391 return do_fork(SIGCHLD, regs.regs[15], &regs, 0, NULL, NULL); 392 return do_fork(SIGCHLD, regs->regs[15], regs, 0, NULL, NULL);
392#else 393#else
393 /* fork almost works, enough to trick you into looking elsewhere :-( */ 394 /* fork almost works, enough to trick you into looking elsewhere :-( */
394 return -EINVAL; 395 return -EINVAL;
@@ -398,11 +399,12 @@ asmlinkage int sys_fork(unsigned long r4, unsigned long r5,
398asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, 399asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
399 unsigned long parent_tidptr, 400 unsigned long parent_tidptr,
400 unsigned long child_tidptr, 401 unsigned long child_tidptr,
401 struct pt_regs regs) 402 struct pt_regs __regs)
402{ 403{
404 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
403 if (!newsp) 405 if (!newsp)
404 newsp = regs.regs[15]; 406 newsp = regs->regs[15];
405 return do_fork(clone_flags, newsp, &regs, 0, 407 return do_fork(clone_flags, newsp, regs, 0,
406 (int __user *)parent_tidptr, (int __user *)child_tidptr); 408 (int __user *)parent_tidptr, (int __user *)child_tidptr);
407} 409}
408 410
@@ -418,9 +420,10 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
418 */ 420 */
419asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, 421asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
420 unsigned long r6, unsigned long r7, 422 unsigned long r6, unsigned long r7,
421 struct pt_regs regs) 423 struct pt_regs __regs)
422{ 424{
423 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs.regs[15], &regs, 425 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
426 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->regs[15], regs,
424 0, NULL, NULL); 427 0, NULL, NULL);
425} 428}
426 429
@@ -429,8 +432,9 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
429 */ 432 */
430asmlinkage int sys_execve(char *ufilename, char **uargv, 433asmlinkage int sys_execve(char *ufilename, char **uargv,
431 char **uenvp, unsigned long r7, 434 char **uenvp, unsigned long r7,
432 struct pt_regs regs) 435 struct pt_regs __regs)
433{ 436{
437 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
434 int error; 438 int error;
435 char *filename; 439 char *filename;
436 440
@@ -442,7 +446,7 @@ asmlinkage int sys_execve(char *ufilename, char **uargv,
442 error = do_execve(filename, 446 error = do_execve(filename,
443 (char __user * __user *)uargv, 447 (char __user * __user *)uargv,
444 (char __user * __user *)uenvp, 448 (char __user * __user *)uenvp,
445 &regs); 449 regs);
446 if (error == 0) { 450 if (error == 0) {
447 task_lock(current); 451 task_lock(current);
448 current->ptrace &= ~PT_DTRACE; 452 current->ptrace &= ~PT_DTRACE;
@@ -472,9 +476,7 @@ unsigned long get_wchan(struct task_struct *p)
472 return pc; 476 return pc;
473} 477}
474 478
475asmlinkage void break_point_trap(unsigned long r4, unsigned long r5, 479asmlinkage void break_point_trap(void)
476 unsigned long r6, unsigned long r7,
477 struct pt_regs regs)
478{ 480{
479 /* Clear tracing. */ 481 /* Clear tracing. */
480#if defined(CONFIG_CPU_SH4A) 482#if defined(CONFIG_CPU_SH4A)
@@ -492,8 +494,10 @@ asmlinkage void break_point_trap(unsigned long r4, unsigned long r5,
492 494
493asmlinkage void break_point_trap_software(unsigned long r4, unsigned long r5, 495asmlinkage void break_point_trap_software(unsigned long r4, unsigned long r5,
494 unsigned long r6, unsigned long r7, 496 unsigned long r6, unsigned long r7,
495 struct pt_regs regs) 497 struct pt_regs __regs)
496{ 498{
497 regs.pc -= 2; 499 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
500
501 regs->pc -= 2;
498 force_sig(SIGTRAP, current); 502 force_sig(SIGTRAP, current);
499} 503}
diff --git a/arch/sh/kernel/relocate_kernel.S b/arch/sh/kernel/relocate_kernel.S
index 8221b37c9773..c66cb3209db5 100644
--- a/arch/sh/kernel/relocate_kernel.S
+++ b/arch/sh/kernel/relocate_kernel.S
@@ -7,11 +7,9 @@
7 * This source code is licensed under the GNU General Public License, 7 * This source code is licensed under the GNU General Public License,
8 * Version 2. See the file COPYING for more details. 8 * Version 2. See the file COPYING for more details.
9 */ 9 */
10
11#include <linux/linkage.h> 10#include <linux/linkage.h>
12 11#include <asm/addrspace.h>
13#define PAGE_SIZE 4096 /* must be same value as in <asm/page.h> */ 12#include <asm/page.h>
14
15 13
16 .globl relocate_new_kernel 14 .globl relocate_new_kernel
17relocate_new_kernel: 15relocate_new_kernel:
@@ -20,8 +18,8 @@ relocate_new_kernel:
20 /* r6 = start_address */ 18 /* r6 = start_address */
21 /* r7 = vbr_reg */ 19 /* r7 = vbr_reg */
22 20
23 mov.l 10f,r8 /* 4096 */ 21 mov.l 10f,r8 /* PAGE_SIZE */
24 mov.l 11f,r9 /* 0xa0000000 */ 22 mov.l 11f,r9 /* P2SEG */
25 23
26 /* stack setting */ 24 /* stack setting */
27 add r8,r5 25 add r8,r5
@@ -32,7 +30,7 @@ relocate_new_kernel:
320: 300:
33 mov.l @r4+,r0 /* cmd = *ind++ */ 31 mov.l @r4+,r0 /* cmd = *ind++ */
34 32
351: /* addr = (cmd | 0xa0000000) & 0xfffffff0 */ 331: /* addr = (cmd | P2SEG) & 0xfffffff0 */
36 mov r0,r2 34 mov r0,r2
37 or r9,r2 35 or r9,r2
38 mov #-16,r1 36 mov #-16,r1
@@ -92,7 +90,7 @@ relocate_new_kernel:
9210: 9010:
93 .long PAGE_SIZE 91 .long PAGE_SIZE
9411: 9211:
95 .long 0xa0000000 93 .long P2SEG
96 94
97relocate_new_kernel_end: 95relocate_new_kernel_end:
98 96
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 36d86f9ac38a..696ca75752d9 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -392,6 +392,7 @@ static int __init topology_init(void)
392subsys_initcall(topology_init); 392subsys_initcall(topology_init);
393 393
394static const char *cpu_name[] = { 394static const char *cpu_name[] = {
395 [CPU_SH7206] = "SH7206", [CPU_SH7619] = "SH7619",
395 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300", 396 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300",
396 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706", 397 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
397 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708", 398 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
@@ -404,6 +405,7 @@ static const char *cpu_name[] = {
404 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501", 405 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
405 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780", 406 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780",
406 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343", 407 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343",
408 [CPU_SH7785] = "SH7785",
407 [CPU_SH_NONE] = "Unknown" 409 [CPU_SH_NONE] = "Unknown"
408}; 410};
409 411
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 8a2fd19dc9eb..c706f3bfd897 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -73,8 +73,6 @@ DECLARE_EXPORT(__lshrdi3);
73DECLARE_EXPORT(__movstr); 73DECLARE_EXPORT(__movstr);
74DECLARE_EXPORT(__movstrSI16); 74DECLARE_EXPORT(__movstrSI16);
75 75
76EXPORT_SYMBOL(strcpy);
77
78#ifdef CONFIG_CPU_SH4 76#ifdef CONFIG_CPU_SH4
79DECLARE_EXPORT(__movstr_i4_even); 77DECLARE_EXPORT(__movstr_i4_even);
80DECLARE_EXPORT(__movstr_i4_odd); 78DECLARE_EXPORT(__movstr_i4_odd);
diff --git a/arch/sh/kernel/signal.c b/arch/sh/kernel/signal.c
index 5213f5bc6ce0..50d7c4993bef 100644
--- a/arch/sh/kernel/signal.c
+++ b/arch/sh/kernel/signal.c
@@ -37,7 +37,7 @@
37asmlinkage int 37asmlinkage int
38sys_sigsuspend(old_sigset_t mask, 38sys_sigsuspend(old_sigset_t mask,
39 unsigned long r5, unsigned long r6, unsigned long r7, 39 unsigned long r5, unsigned long r6, unsigned long r7,
40 struct pt_regs regs) 40 struct pt_regs __regs)
41{ 41{
42 mask &= _BLOCKABLE; 42 mask &= _BLOCKABLE;
43 spin_lock_irq(&current->sighand->siglock); 43 spin_lock_irq(&current->sighand->siglock);
@@ -52,7 +52,7 @@ sys_sigsuspend(old_sigset_t mask,
52 return -ERESTARTNOHAND; 52 return -ERESTARTNOHAND;
53} 53}
54 54
55asmlinkage int 55asmlinkage int
56sys_sigaction(int sig, const struct old_sigaction __user *act, 56sys_sigaction(int sig, const struct old_sigaction __user *act,
57 struct old_sigaction __user *oact) 57 struct old_sigaction __user *oact)
58{ 58{
@@ -87,9 +87,11 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
87asmlinkage int 87asmlinkage int
88sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 88sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
89 unsigned long r6, unsigned long r7, 89 unsigned long r6, unsigned long r7,
90 struct pt_regs regs) 90 struct pt_regs __regs)
91{ 91{
92 return do_sigaltstack(uss, uoss, regs.regs[15]); 92 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
93
94 return do_sigaltstack(uss, uoss, regs->regs[15]);
93} 95}
94 96
95 97
@@ -98,7 +100,11 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
98 */ 100 */
99 101
100#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */ 102#define MOVW(n) (0x9300|((n)-2)) /* Move mem word at PC+n to R3 */
101#define TRAP16 0xc310 /* Syscall w/no args (NR in R3) */ 103#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A)
104#define TRAP_NOARG 0xc320 /* Syscall w/no args (NR in R3) */
105#else
106#define TRAP_NOARG 0xc310 /* Syscall w/no args (NR in R3) */
107#endif
102#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */ 108#define OR_R0_R0 0x200b /* or r0,r0 (insert to avoid hardware bug) */
103 109
104struct sigframe 110struct sigframe
@@ -194,9 +200,10 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
194 200
195asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5, 201asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
196 unsigned long r6, unsigned long r7, 202 unsigned long r6, unsigned long r7,
197 struct pt_regs regs) 203 struct pt_regs __regs)
198{ 204{
199 struct sigframe __user *frame = (struct sigframe __user *)regs.regs[15]; 205 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
206 struct sigframe __user *frame = (struct sigframe __user *)regs->regs[15];
200 sigset_t set; 207 sigset_t set;
201 int r0; 208 int r0;
202 209
@@ -216,7 +223,7 @@ asmlinkage int sys_sigreturn(unsigned long r4, unsigned long r5,
216 recalc_sigpending(); 223 recalc_sigpending();
217 spin_unlock_irq(&current->sighand->siglock); 224 spin_unlock_irq(&current->sighand->siglock);
218 225
219 if (restore_sigcontext(&regs, &frame->sc, &r0)) 226 if (restore_sigcontext(regs, &frame->sc, &r0))
220 goto badframe; 227 goto badframe;
221 return r0; 228 return r0;
222 229
@@ -227,9 +234,10 @@ badframe:
227 234
228asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5, 235asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
229 unsigned long r6, unsigned long r7, 236 unsigned long r6, unsigned long r7,
230 struct pt_regs regs) 237 struct pt_regs __regs)
231{ 238{
232 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs.regs[15]; 239 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
240 struct rt_sigframe __user *frame = (struct rt_sigframe __user *)regs->regs[15];
233 sigset_t set; 241 sigset_t set;
234 stack_t st; 242 stack_t st;
235 int r0; 243 int r0;
@@ -246,14 +254,14 @@ asmlinkage int sys_rt_sigreturn(unsigned long r4, unsigned long r5,
246 recalc_sigpending(); 254 recalc_sigpending();
247 spin_unlock_irq(&current->sighand->siglock); 255 spin_unlock_irq(&current->sighand->siglock);
248 256
249 if (restore_sigcontext(&regs, &frame->uc.uc_mcontext, &r0)) 257 if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
250 goto badframe; 258 goto badframe;
251 259
252 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st))) 260 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
253 goto badframe; 261 goto badframe;
254 /* It is more difficult to avoid calling this function than to 262 /* It is more difficult to avoid calling this function than to
255 call it and ignore errors. */ 263 call it and ignore errors. */
256 do_sigaltstack(&st, NULL, regs.regs[15]); 264 do_sigaltstack(&st, NULL, regs->regs[15]);
257 265
258 return r0; 266 return r0;
259 267
@@ -350,7 +358,7 @@ static int setup_frame(int sig, struct k_sigaction *ka,
350 } else { 358 } else {
351 /* Generate return code (system call to sigreturn) */ 359 /* Generate return code (system call to sigreturn) */
352 err |= __put_user(MOVW(7), &frame->retcode[0]); 360 err |= __put_user(MOVW(7), &frame->retcode[0]);
353 err |= __put_user(TRAP16, &frame->retcode[1]); 361 err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
354 err |= __put_user(OR_R0_R0, &frame->retcode[2]); 362 err |= __put_user(OR_R0_R0, &frame->retcode[2]);
355 err |= __put_user(OR_R0_R0, &frame->retcode[3]); 363 err |= __put_user(OR_R0_R0, &frame->retcode[3]);
356 err |= __put_user(OR_R0_R0, &frame->retcode[4]); 364 err |= __put_user(OR_R0_R0, &frame->retcode[4]);
@@ -430,7 +438,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
430 } else { 438 } else {
431 /* Generate return code (system call to rt_sigreturn) */ 439 /* Generate return code (system call to rt_sigreturn) */
432 err |= __put_user(MOVW(7), &frame->retcode[0]); 440 err |= __put_user(MOVW(7), &frame->retcode[0]);
433 err |= __put_user(TRAP16, &frame->retcode[1]); 441 err |= __put_user(TRAP_NOARG, &frame->retcode[1]);
434 err |= __put_user(OR_R0_R0, &frame->retcode[2]); 442 err |= __put_user(OR_R0_R0, &frame->retcode[2]);
435 err |= __put_user(OR_R0_R0, &frame->retcode[3]); 443 err |= __put_user(OR_R0_R0, &frame->retcode[3]);
436 err |= __put_user(OR_R0_R0, &frame->retcode[4]); 444 err |= __put_user(OR_R0_R0, &frame->retcode[4]);
diff --git a/arch/sh/kernel/stacktrace.c b/arch/sh/kernel/stacktrace.c
new file mode 100644
index 000000000000..0d5268afe80f
--- /dev/null
+++ b/arch/sh/kernel/stacktrace.c
@@ -0,0 +1,43 @@
1/*
2 * arch/sh/kernel/stacktrace.c
3 *
4 * Stack trace management functions
5 *
6 * Copyright (C) 2006 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/sched.h>
13#include <linux/stacktrace.h>
14#include <linux/thread_info.h>
15#include <asm/ptrace.h>
16
17/*
18 * Save stack-backtrace addresses into a stack_trace buffer.
19 */
20void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
21{
22 unsigned long *sp;
23
24 if (!task)
25 task = current;
26 if (task == current)
27 sp = (unsigned long *)current_stack_pointer;
28 else
29 sp = (unsigned long *)task->thread.sp;
30
31 while (!kstack_end(sp)) {
32 unsigned long addr = *sp++;
33
34 if (__kernel_text_address(addr)) {
35 if (trace->skip > 0)
36 trace->skip--;
37 else
38 trace->entries[trace->nr_entries++] = addr;
39 if (trace->nr_entries >= trace->max_entries)
40 break;
41 }
42 }
43}
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 8fde95001c34..5083b6ed4b39 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -33,14 +33,15 @@
33 */ 33 */
34asmlinkage int sys_pipe(unsigned long r4, unsigned long r5, 34asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
35 unsigned long r6, unsigned long r7, 35 unsigned long r6, unsigned long r7,
36 struct pt_regs regs) 36 struct pt_regs __regs)
37{ 37{
38 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
38 int fd[2]; 39 int fd[2];
39 int error; 40 int error;
40 41
41 error = do_pipe(fd); 42 error = do_pipe(fd);
42 if (!error) { 43 if (!error) {
43 regs.regs[1] = fd[1]; 44 regs->regs[1] = fd[1];
44 return fd[0]; 45 return fd[0];
45 } 46 }
46 return error; 47 return error;
@@ -50,6 +51,7 @@ unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */
50 51
51EXPORT_SYMBOL(shm_align_mask); 52EXPORT_SYMBOL(shm_align_mask);
52 53
54#ifdef CONFIG_MMU
53/* 55/*
54 * To avoid cache aliases, we map the shared page with same color. 56 * To avoid cache aliases, we map the shared page with same color.
55 */ 57 */
@@ -135,6 +137,7 @@ full_search:
135 addr = COLOUR_ALIGN(addr, pgoff); 137 addr = COLOUR_ALIGN(addr, pgoff);
136 } 138 }
137} 139}
140#endif /* CONFIG_MMU */
138 141
139static inline long 142static inline long
140do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 143do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index 57e708d7b52d..c206c9504c4b 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -13,6 +13,8 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/profile.h> 15#include <linux/profile.h>
16#include <linux/timex.h>
17#include <linux/sched.h>
16#include <asm/clock.h> 18#include <asm/clock.h>
17#include <asm/rtc.h> 19#include <asm/rtc.h>
18#include <asm/timer.h> 20#include <asm/timer.h>
@@ -50,15 +52,20 @@ unsigned long long __attribute__ ((weak)) sched_clock(void)
50#ifndef CONFIG_GENERIC_TIME 52#ifndef CONFIG_GENERIC_TIME
51void do_gettimeofday(struct timeval *tv) 53void do_gettimeofday(struct timeval *tv)
52{ 54{
55 unsigned long flags;
53 unsigned long seq; 56 unsigned long seq;
54 unsigned long usec, sec; 57 unsigned long usec, sec;
55 58
56 do { 59 do {
57 seq = read_seqbegin(&xtime_lock); 60 /*
61 * Turn off IRQs when grabbing xtime_lock, so that
62 * the sys_timer get_offset code doesn't have to handle it.
63 */
64 seq = read_seqbegin_irqsave(&xtime_lock, flags);
58 usec = get_timer_offset(); 65 usec = get_timer_offset();
59 sec = xtime.tv_sec; 66 sec = xtime.tv_sec;
60 usec += xtime.tv_nsec / 1000; 67 usec += xtime.tv_nsec / NSEC_PER_USEC;
61 } while (read_seqretry(&xtime_lock, seq)); 68 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
62 69
63 while (usec >= 1000000) { 70 while (usec >= 1000000) {
64 usec -= 1000000; 71 usec -= 1000000;
@@ -85,7 +92,7 @@ int do_settimeofday(struct timespec *tv)
85 * wall time. Discover what correction gettimeofday() would have 92 * wall time. Discover what correction gettimeofday() would have
86 * made, and then undo it! 93 * made, and then undo it!
87 */ 94 */
88 nsec -= 1000 * get_timer_offset(); 95 nsec -= get_timer_offset() * NSEC_PER_USEC;
89 96
90 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec); 97 wtm_sec = wall_to_monotonic.tv_sec + (xtime.tv_sec - sec);
91 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec); 98 wtm_nsec = wall_to_monotonic.tv_nsec + (xtime.tv_nsec - nsec);
@@ -169,6 +176,108 @@ static struct sysdev_class timer_sysclass = {
169 .resume = timer_resume, 176 .resume = timer_resume,
170}; 177};
171 178
179#ifdef CONFIG_NO_IDLE_HZ
180static int timer_dyn_tick_enable(void)
181{
182 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
183 unsigned long flags;
184 int ret = -ENODEV;
185
186 if (dyn_tick) {
187 spin_lock_irqsave(&dyn_tick->lock, flags);
188 ret = 0;
189 if (!(dyn_tick->state & DYN_TICK_ENABLED)) {
190 ret = dyn_tick->enable();
191
192 if (ret == 0)
193 dyn_tick->state |= DYN_TICK_ENABLED;
194 }
195 spin_unlock_irqrestore(&dyn_tick->lock, flags);
196 }
197
198 return ret;
199}
200
201static int timer_dyn_tick_disable(void)
202{
203 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
204 unsigned long flags;
205 int ret = -ENODEV;
206
207 if (dyn_tick) {
208 spin_lock_irqsave(&dyn_tick->lock, flags);
209 ret = 0;
210 if (dyn_tick->state & DYN_TICK_ENABLED) {
211 ret = dyn_tick->disable();
212
213 if (ret == 0)
214 dyn_tick->state &= ~DYN_TICK_ENABLED;
215 }
216 spin_unlock_irqrestore(&dyn_tick->lock, flags);
217 }
218
219 return ret;
220}
221
222/*
223 * Reprogram the system timer for at least the calculated time interval.
224 * This function should be called from the idle thread with IRQs disabled,
225 * immediately before sleeping.
226 */
227void timer_dyn_reprogram(void)
228{
229 struct dyn_tick_timer *dyn_tick = sys_timer->dyn_tick;
230 unsigned long next, seq, flags;
231
232 if (!dyn_tick)
233 return;
234
235 spin_lock_irqsave(&dyn_tick->lock, flags);
236 if (dyn_tick->state & DYN_TICK_ENABLED) {
237 next = next_timer_interrupt();
238 do {
239 seq = read_seqbegin(&xtime_lock);
240 dyn_tick->reprogram(next - jiffies);
241 } while (read_seqretry(&xtime_lock, seq));
242 }
243 spin_unlock_irqrestore(&dyn_tick->lock, flags);
244}
245
246static ssize_t timer_show_dyn_tick(struct sys_device *dev, char *buf)
247{
248 return sprintf(buf, "%i\n",
249 (sys_timer->dyn_tick->state & DYN_TICK_ENABLED) >> 1);
250}
251
252static ssize_t timer_set_dyn_tick(struct sys_device *dev, const char *buf,
253 size_t count)
254{
255 unsigned int enable = simple_strtoul(buf, NULL, 2);
256
257 if (enable)
258 timer_dyn_tick_enable();
259 else
260 timer_dyn_tick_disable();
261
262 return count;
263}
264static SYSDEV_ATTR(dyn_tick, 0644, timer_show_dyn_tick, timer_set_dyn_tick);
265
266/*
267 * dyntick=enable|disable
268 */
269static char dyntick_str[4] __initdata = "";
270
271static int __init dyntick_setup(char *str)
272{
273 if (str)
274 strlcpy(dyntick_str, str, sizeof(dyntick_str));
275 return 1;
276}
277
278__setup("dyntick=", dyntick_setup);
279#endif
280
172static int __init timer_init_sysfs(void) 281static int __init timer_init_sysfs(void)
173{ 282{
174 int ret = sysdev_class_register(&timer_sysclass); 283 int ret = sysdev_class_register(&timer_sysclass);
@@ -176,7 +285,22 @@ static int __init timer_init_sysfs(void)
176 return ret; 285 return ret;
177 286
178 sys_timer->dev.cls = &timer_sysclass; 287 sys_timer->dev.cls = &timer_sysclass;
179 return sysdev_register(&sys_timer->dev); 288 ret = sysdev_register(&sys_timer->dev);
289
290#ifdef CONFIG_NO_IDLE_HZ
291 if (ret == 0 && sys_timer->dyn_tick) {
292 ret = sysdev_create_file(&sys_timer->dev, &attr_dyn_tick);
293
294 /*
295 * Turn on dynamic tick after calibrate delay
296 * for correct bogomips
297 */
298 if (ret == 0 && dyntick_str[0] == 'e')
299 ret = timer_dyn_tick_enable();
300 }
301#endif
302
303 return ret;
180} 304}
181device_initcall(timer_init_sysfs); 305device_initcall(timer_init_sysfs);
182 306
@@ -200,6 +324,11 @@ void __init time_init(void)
200 sys_timer = get_sys_timer(); 324 sys_timer = get_sys_timer();
201 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name); 325 printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
202 326
327#ifdef CONFIG_NO_IDLE_HZ
328 if (sys_timer->dyn_tick)
329 spin_lock_init(&sys_timer->dyn_tick->lock);
330#endif
331
203#if defined(CONFIG_SH_KGDB) 332#if defined(CONFIG_SH_KGDB)
204 /* 333 /*
205 * Set up kgdb as requested. We do it here because the serial 334 * Set up kgdb as requested. We do it here because the serial
diff --git a/arch/sh/kernel/timers/Makefile b/arch/sh/kernel/timers/Makefile
index 151a6a304cec..bcf244ff6a12 100644
--- a/arch/sh/kernel/timers/Makefile
+++ b/arch/sh/kernel/timers/Makefile
@@ -5,4 +5,6 @@
5obj-y := timer.o 5obj-y := timer.o
6 6
7obj-$(CONFIG_SH_TMU) += timer-tmu.o 7obj-$(CONFIG_SH_TMU) += timer-tmu.o
8obj-$(CONFIG_SH_MTU2) += timer-mtu2.o
9obj-$(CONFIG_SH_CMT) += timer-cmt.o
8 10
diff --git a/arch/sh/kernel/timers/timer-cmt.c b/arch/sh/kernel/timers/timer-cmt.c
new file mode 100644
index 000000000000..a574b93a4e7b
--- /dev/null
+++ b/arch/sh/kernel/timers/timer-cmt.c
@@ -0,0 +1,196 @@
1/*
2 * arch/sh/kernel/timers/timer-cmt.c - CMT Timer Support
3 *
4 * Copyright (C) 2005 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/interrupt.h>
14#include <linux/seqlock.h>
15#include <asm/timer.h>
16#include <asm/rtc.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/clock.h>
20
21#if defined(CONFIG_CPU_SUBTYPE_SH7619)
22#define CMT_CMSTR 0xf84a0070
23#define CMT_CMCSR_0 0xf84a0072
24#define CMT_CMCNT_0 0xf84a0074
25#define CMT_CMCOR_0 0xf84a0076
26#define CMT_CMCSR_1 0xf84a0078
27#define CMT_CMCNT_1 0xf84a007a
28#define CMT_CMCOR_1 0xf84a007c
29
30#define STBCR3 0xf80a0000
31#define cmt_clock_enable() do { ctrl_outb(ctrl_inb(STBCR3) & ~0x10, STBCR3); } while(0)
32#define CMT_CMCSR_INIT 0x0040
33#define CMT_CMCSR_CALIB 0x0000
34#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
35#define CMT_CMSTR 0xfffec000
36#define CMT_CMCSR_0 0xfffec002
37#define CMT_CMCNT_0 0xfffec004
38#define CMT_CMCOR_0 0xfffec006
39
40#define STBCR4 0xfffe040c
41#define cmt_clock_enable() do { ctrl_outb(ctrl_inb(STBCR4) & ~0x04, STBCR4); } while(0)
42#define CMT_CMCSR_INIT 0x0040
43#define CMT_CMCSR_CALIB 0x0000
44#else
45#error "Unknown CPU SUBTYPE"
46#endif
47
48static unsigned long cmt_timer_get_offset(void)
49{
50 int count;
51 static unsigned short count_p = 0xffff; /* for the first call after boot */
52 static unsigned long jiffies_p = 0;
53
54 /*
55 * cache volatile jiffies temporarily; we have IRQs turned off.
56 */
57 unsigned long jiffies_t;
58
59 /* timer count may underflow right here */
60 count = ctrl_inw(CMT_CMCOR_0);
61 count -= ctrl_inw(CMT_CMCNT_0);
62
63 jiffies_t = jiffies;
64
65 /*
66 * avoiding timer inconsistencies (they are rare, but they happen)...
67 * there is one kind of problem that must be avoided here:
68 * 1. the timer counter underflows
69 */
70
71 if (jiffies_t == jiffies_p) {
72 if (count > count_p) {
73 /* the nutcase */
74 if (ctrl_inw(CMT_CMCSR_0) & 0x80) { /* Check CMF bit */
75 count -= LATCH;
76 } else {
77 printk("%s (): hardware timer problem?\n",
78 __FUNCTION__);
79 }
80 }
81 } else
82 jiffies_p = jiffies_t;
83
84 count_p = count;
85
86 count = ((LATCH-1) - count) * TICK_SIZE;
87 count = (count + LATCH/2) / LATCH;
88
89 return count;
90}
91
92static irqreturn_t cmt_timer_interrupt(int irq, void *dev_id)
93{
94 unsigned long timer_status;
95
96 /* Clear CMF bit */
97 timer_status = ctrl_inw(CMT_CMCSR_0);
98 timer_status &= ~0x80;
99 ctrl_outw(timer_status, CMT_CMCSR_0);
100
101 /*
102 * Here we are in the timer irq handler. We just have irqs locally
103 * disabled but we don't know if the timer_bh is running on the other
104 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
105 * the irq version of write_lock because as just said we have irq
106 * locally disabled. -arca
107 */
108 write_seqlock(&xtime_lock);
109 handle_timer_tick();
110 write_sequnlock(&xtime_lock);
111
112 return IRQ_HANDLED;
113}
114
115static struct irqaction cmt_irq = {
116 .name = "timer",
117 .handler = cmt_timer_interrupt,
118 .flags = IRQF_DISABLED | IRQF_TIMER,
119 .mask = CPU_MASK_NONE,
120};
121
122static void cmt_clk_init(struct clk *clk)
123{
124 u8 divisor = CMT_CMCSR_INIT & 0x3;
125 ctrl_inw(CMT_CMCSR_0);
126 ctrl_outw(CMT_CMCSR_INIT, CMT_CMCSR_0);
127 clk->parent = clk_get(NULL, "module_clk");
128 clk->rate = clk->parent->rate / (8 << (divisor << 1));
129}
130
131static void cmt_clk_recalc(struct clk *clk)
132{
133 u8 divisor = ctrl_inw(CMT_CMCSR_0) & 0x3;
134 clk->rate = clk->parent->rate / (8 << (divisor << 1));
135}
136
137static struct clk_ops cmt_clk_ops = {
138 .init = cmt_clk_init,
139 .recalc = cmt_clk_recalc,
140};
141
142static struct clk cmt0_clk = {
143 .name = "cmt0_clk",
144 .ops = &cmt_clk_ops,
145};
146
147static int cmt_timer_start(void)
148{
149 ctrl_outw(ctrl_inw(CMT_CMSTR) | 0x01, CMT_CMSTR);
150 return 0;
151}
152
153static int cmt_timer_stop(void)
154{
155 ctrl_outw(ctrl_inw(CMT_CMSTR) & ~0x01, CMT_CMSTR);
156 return 0;
157}
158
159static int cmt_timer_init(void)
160{
161 unsigned long interval;
162
163 cmt_clock_enable();
164
165 setup_irq(CONFIG_SH_TIMER_IRQ, &cmt_irq);
166
167 cmt0_clk.parent = clk_get(NULL, "module_clk");
168
169 cmt_timer_stop();
170
171 interval = cmt0_clk.parent->rate / 8 / HZ;
172 printk(KERN_INFO "Interval = %ld\n", interval);
173
174 ctrl_outw(interval, CMT_CMCOR_0);
175
176 clk_register(&cmt0_clk);
177 clk_enable(&cmt0_clk);
178
179 cmt_timer_start();
180
181 return 0;
182}
183
184struct sys_timer_ops cmt_timer_ops = {
185 .init = cmt_timer_init,
186 .start = cmt_timer_start,
187 .stop = cmt_timer_stop,
188#ifndef CONFIG_GENERIC_TIME
189 .get_offset = cmt_timer_get_offset,
190#endif
191};
192
193struct sys_timer cmt_timer = {
194 .name = "cmt",
195 .ops = &cmt_timer_ops,
196};
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c
new file mode 100644
index 000000000000..fffcd1c09873
--- /dev/null
+++ b/arch/sh/kernel/timers/timer-mtu2.c
@@ -0,0 +1,200 @@
1/*
2 * arch/sh/kernel/timers/timer-mtu2.c - MTU2 Timer Support
3 *
4 * Copyright (C) 2005 Paul Mundt
5 *
6 * Based off of arch/sh/kernel/timers/timer-tmu.c
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/interrupt.h>
15#include <linux/seqlock.h>
16#include <asm/timer.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/clock.h>
20
21/*
22 * We use channel 1 for our lowly system timer. Channel 2 would be the other
23 * likely candidate, but we leave it alone as it has higher divisors that
24 * would be of more use to other more interesting applications.
25 *
26 * TODO: Presently we only implement a 16-bit single-channel system timer.
27 * However, we can implement channel cascade if we go the overflow route and
28 * get away with using 2 MTU2 channels as a 32-bit timer.
29 */
30#define MTU2_TSTR 0xfffe4280
31#define MTU2_TCR_1 0xfffe4380
32#define MTU2_TMDR_1 0xfffe4381
33#define MTU2_TIOR_1 0xfffe4382
34#define MTU2_TIER_1 0xfffe4384
35#define MTU2_TSR_1 0xfffe4385
36#define MTU2_TCNT_1 0xfffe4386 /* 16-bit counter */
37#define MTU2_TGRA_1 0xfffe438a
38
39#define STBCR3 0xfffe0408
40
41#define MTU2_TSTR_CST1 (1 << 1) /* Counter Start 1 */
42
43#define MTU2_TSR_TGFA (1 << 0) /* GRA compare match */
44
45#define MTU2_TIER_TGIEA (1 << 0) /* GRA compare match interrupt enable */
46
47#define MTU2_TCR_INIT 0x22
48
49#define MTU2_TCR_CALIB 0x00
50
51static unsigned long mtu2_timer_get_offset(void)
52{
53 int count;
54 static int count_p = 0x7fff; /* for the first call after boot */
55 static unsigned long jiffies_p = 0;
56
57 /*
58 * cache volatile jiffies temporarily; we have IRQs turned off.
59 */
60 unsigned long jiffies_t;
61
62 /* timer count may underflow right here */
63 count = ctrl_inw(MTU2_TCNT_1); /* read the latched count */
64
65 jiffies_t = jiffies;
66
67 /*
68 * avoiding timer inconsistencies (they are rare, but they happen)...
69 * there is one kind of problem that must be avoided here:
70 * 1. the timer counter underflows
71 */
72
73 if (jiffies_t == jiffies_p) {
74 if (count > count_p) {
75 if (ctrl_inb(MTU2_TSR_1) & MTU2_TSR_TGFA) {
76 count -= LATCH;
77 } else {
78 printk("%s (): hardware timer problem?\n",
79 __FUNCTION__);
80 }
81 }
82 } else
83 jiffies_p = jiffies_t;
84
85 count_p = count;
86
87 count = ((LATCH-1) - count) * TICK_SIZE;
88 count = (count + LATCH/2) / LATCH;
89
90 return count;
91}
92
93static irqreturn_t mtu2_timer_interrupt(int irq, void *dev_id)
94{
95 unsigned long timer_status;
96
97 /* Clear TGFA bit */
98 timer_status = ctrl_inb(MTU2_TSR_1);
99 timer_status &= ~MTU2_TSR_TGFA;
100 ctrl_outb(timer_status, MTU2_TSR_1);
101
102 /* Do timer tick */
103 write_seqlock(&xtime_lock);
104 handle_timer_tick();
105 write_sequnlock(&xtime_lock);
106
107 return IRQ_HANDLED;
108}
109
110static struct irqaction mtu2_irq = {
111 .name = "timer",
112 .handler = mtu2_timer_interrupt,
113 .flags = IRQF_DISABLED | IRQF_TIMER,
114 .mask = CPU_MASK_NONE,
115};
116
117static unsigned int divisors[] = { 1, 4, 16, 64, 1, 1, 256 };
118
119static void mtu2_clk_init(struct clk *clk)
120{
121 u8 idx = MTU2_TCR_INIT & 0x7;
122
123 clk->rate = clk->parent->rate / divisors[idx];
124 /* Start TCNT counting */
125 ctrl_outb(ctrl_inb(MTU2_TSTR) | MTU2_TSTR_CST1, MTU2_TSTR);
126
127}
128
129static void mtu2_clk_recalc(struct clk *clk)
130{
131 u8 idx = ctrl_inb(MTU2_TCR_1) & 0x7;
132 clk->rate = clk->parent->rate / divisors[idx];
133}
134
135static struct clk_ops mtu2_clk_ops = {
136 .init = mtu2_clk_init,
137 .recalc = mtu2_clk_recalc,
138};
139
140static struct clk mtu2_clk1 = {
141 .name = "mtu2_clk1",
142 .ops = &mtu2_clk_ops,
143};
144
145static int mtu2_timer_start(void)
146{
147 ctrl_outb(ctrl_inb(MTU2_TSTR) | MTU2_TSTR_CST1, MTU2_TSTR);
148 return 0;
149}
150
151static int mtu2_timer_stop(void)
152{
153 ctrl_outb(ctrl_inb(MTU2_TSTR) & ~MTU2_TSTR_CST1, MTU2_TSTR);
154 return 0;
155}
156
157static int mtu2_timer_init(void)
158{
159 u8 tmp;
160 unsigned long interval;
161
162 setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq);
163
164 mtu2_clk1.parent = clk_get(NULL, "module_clk");
165
166 ctrl_outb(ctrl_inb(STBCR3) & (~0x20), STBCR3);
167
168 /* Normal operation */
169 ctrl_outb(0, MTU2_TMDR_1);
170 ctrl_outb(MTU2_TCR_INIT, MTU2_TCR_1);
171 ctrl_outb(0x01, MTU2_TIOR_1);
172
173 /* Enable underflow interrupt */
174 ctrl_outb(ctrl_inb(MTU2_TIER_1) | MTU2_TIER_TGIEA, MTU2_TIER_1);
175
176 interval = CONFIG_SH_PCLK_FREQ / 16 / HZ;
177 printk(KERN_INFO "Interval = %ld\n", interval);
178
179 ctrl_outw(interval, MTU2_TGRA_1);
180 ctrl_outw(0, MTU2_TCNT_1);
181
182 clk_register(&mtu2_clk1);
183 clk_enable(&mtu2_clk1);
184
185 return 0;
186}
187
188struct sys_timer_ops mtu2_timer_ops = {
189 .init = mtu2_timer_init,
190 .start = mtu2_timer_start,
191 .stop = mtu2_timer_stop,
192#ifndef CONFIG_GENERIC_TIME
193 .get_offset = mtu2_timer_get_offset,
194#endif
195};
196
197struct sys_timer mtu2_timer = {
198 .name = "mtu2",
199 .ops = &mtu2_timer_ops,
200};
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 24927015dc31..e060e71d0785 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -17,7 +17,6 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/spinlock.h>
21#include <linux/seqlock.h> 20#include <linux/seqlock.h>
22#include <asm/timer.h> 21#include <asm/timer.h>
23#include <asm/rtc.h> 22#include <asm/rtc.h>
@@ -31,13 +30,9 @@
31 30
32#define TMU0_TCR_CALIB 0x0000 31#define TMU0_TCR_CALIB 0x0000
33 32
34static DEFINE_SPINLOCK(tmu0_lock);
35
36static unsigned long tmu_timer_get_offset(void) 33static unsigned long tmu_timer_get_offset(void)
37{ 34{
38 int count; 35 int count;
39 unsigned long flags;
40
41 static int count_p = 0x7fffffff; /* for the first call after boot */ 36 static int count_p = 0x7fffffff; /* for the first call after boot */
42 static unsigned long jiffies_p = 0; 37 static unsigned long jiffies_p = 0;
43 38
@@ -46,7 +41,6 @@ static unsigned long tmu_timer_get_offset(void)
46 */ 41 */
47 unsigned long jiffies_t; 42 unsigned long jiffies_t;
48 43
49 spin_lock_irqsave(&tmu0_lock, flags);
50 /* timer count may underflow right here */ 44 /* timer count may underflow right here */
51 count = ctrl_inl(TMU0_TCNT); /* read the latched count */ 45 count = ctrl_inl(TMU0_TCNT); /* read the latched count */
52 46
@@ -72,7 +66,6 @@ static unsigned long tmu_timer_get_offset(void)
72 jiffies_p = jiffies_t; 66 jiffies_p = jiffies_t;
73 67
74 count_p = count; 68 count_p = count;
75 spin_unlock_irqrestore(&tmu0_lock, flags);
76 69
77 count = ((LATCH-1) - count) * TICK_SIZE; 70 count = ((LATCH-1) - count) * TICK_SIZE;
78 count = (count + LATCH/2) / LATCH; 71 count = (count + LATCH/2) / LATCH;
@@ -106,7 +99,7 @@ static irqreturn_t tmu_timer_interrupt(int irq, void *dummy)
106static struct irqaction tmu_irq = { 99static struct irqaction tmu_irq = {
107 .name = "timer", 100 .name = "timer",
108 .handler = tmu_timer_interrupt, 101 .handler = tmu_timer_interrupt,
109 .flags = IRQF_DISABLED, 102 .flags = IRQF_DISABLED | IRQF_TIMER,
110 .mask = CPU_MASK_NONE, 103 .mask = CPU_MASK_NONE,
111}; 104};
112 105
@@ -149,9 +142,9 @@ static int tmu_timer_init(void)
149{ 142{
150 unsigned long interval; 143 unsigned long interval;
151 144
152 setup_irq(TIMER_IRQ, &tmu_irq); 145 setup_irq(CONFIG_SH_TIMER_IRQ, &tmu_irq);
153 146
154 tmu0_clk.parent = clk_get("module_clk"); 147 tmu0_clk.parent = clk_get(NULL, "module_clk");
155 148
156 /* Start TMU0 */ 149 /* Start TMU0 */
157 tmu_timer_stop(); 150 tmu_timer_stop();
diff --git a/arch/sh/kernel/timers/timer.c b/arch/sh/kernel/timers/timer.c
index dc1f631053a8..a6bcc913d25e 100644
--- a/arch/sh/kernel/timers/timer.c
+++ b/arch/sh/kernel/timers/timer.c
@@ -17,6 +17,12 @@ static struct sys_timer *sys_timers[] __initdata = {
17#ifdef CONFIG_SH_TMU 17#ifdef CONFIG_SH_TMU
18 &tmu_timer, 18 &tmu_timer,
19#endif 19#endif
20#ifdef CONFIG_SH_MTU2
21 &mtu2_timer,
22#endif
23#ifdef CONFIG_SH_CMT
24 &cmt_timer,
25#endif
20 NULL, 26 NULL,
21}; 27};
22 28
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index 53dfa55f3156..3762d9dc2046 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -18,13 +18,14 @@
18#include <linux/module.h> 18#include <linux/module.h>
19#include <linux/kallsyms.h> 19#include <linux/kallsyms.h>
20#include <linux/io.h> 20#include <linux/io.h>
21#include <linux/debug_locks.h>
21#include <asm/system.h> 22#include <asm/system.h>
22#include <asm/uaccess.h> 23#include <asm/uaccess.h>
23 24
24#ifdef CONFIG_SH_KGDB 25#ifdef CONFIG_SH_KGDB
25#include <asm/kgdb.h> 26#include <asm/kgdb.h>
26#define CHK_REMOTE_DEBUG(regs) \ 27#define CHK_REMOTE_DEBUG(regs) \
27{ \ 28{ \
28 if (kgdb_debug_hook && !user_mode(regs))\ 29 if (kgdb_debug_hook && !user_mode(regs))\
29 (*kgdb_debug_hook)(regs); \ 30 (*kgdb_debug_hook)(regs); \
30} 31}
@@ -33,8 +34,13 @@
33#endif 34#endif
34 35
35#ifdef CONFIG_CPU_SH2 36#ifdef CONFIG_CPU_SH2
36#define TRAP_RESERVED_INST 4 37# define TRAP_RESERVED_INST 4
37#define TRAP_ILLEGAL_SLOT_INST 6 38# define TRAP_ILLEGAL_SLOT_INST 6
39# define TRAP_ADDRESS_ERROR 9
40# ifdef CONFIG_CPU_SH2A
41# define TRAP_DIVZERO_ERROR 17
42# define TRAP_DIVOVF_ERROR 18
43# endif
38#else 44#else
39#define TRAP_RESERVED_INST 12 45#define TRAP_RESERVED_INST 12
40#define TRAP_ILLEGAL_SLOT_INST 13 46#define TRAP_ILLEGAL_SLOT_INST 13
@@ -88,7 +94,7 @@ void die(const char * str, struct pt_regs * regs, long err)
88 94
89 if (!user_mode(regs) || in_interrupt()) 95 if (!user_mode(regs) || in_interrupt())
90 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE + 96 dump_mem("Stack: ", regs->regs[15], THREAD_SIZE +
91 (unsigned long)task_stack_page(current)); 97 (unsigned long)task_stack_page(current));
92 98
93 bust_spinlocks(0); 99 bust_spinlocks(0);
94 spin_unlock_irq(&die_lock); 100 spin_unlock_irq(&die_lock);
@@ -102,8 +108,6 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs,
102 die(str, regs, err); 108 die(str, regs, err);
103} 109}
104 110
105static int handle_unaligned_notify_count = 10;
106
107/* 111/*
108 * try and fix up kernelspace address errors 112 * try and fix up kernelspace address errors
109 * - userspace errors just cause EFAULT to be returned, resulting in SEGV 113 * - userspace errors just cause EFAULT to be returned, resulting in SEGV
@@ -198,7 +202,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
198 if (copy_to_user(dst,src,4)) 202 if (copy_to_user(dst,src,4))
199 goto fetch_fault; 203 goto fetch_fault;
200 ret = 0; 204 ret = 0;
201 break; 205 break;
202 206
203 case 2: /* mov.[bwl] to memory, possibly with pre-decrement */ 207 case 2: /* mov.[bwl] to memory, possibly with pre-decrement */
204 if (instruction & 4) 208 if (instruction & 4)
@@ -222,7 +226,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
222 if (copy_from_user(dst,src,4)) 226 if (copy_from_user(dst,src,4))
223 goto fetch_fault; 227 goto fetch_fault;
224 ret = 0; 228 ret = 0;
225 break; 229 break;
226 230
227 case 6: /* mov.[bwl] from memory, possibly with post-increment */ 231 case 6: /* mov.[bwl] from memory, possibly with post-increment */
228 src = (unsigned char*) *rm; 232 src = (unsigned char*) *rm;
@@ -230,7 +234,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
230 *rm += count; 234 *rm += count;
231 dst = (unsigned char*) rn; 235 dst = (unsigned char*) rn;
232 *(unsigned long*)dst = 0; 236 *(unsigned long*)dst = 0;
233 237
234#ifdef __LITTLE_ENDIAN__ 238#ifdef __LITTLE_ENDIAN__
235 if (copy_from_user(dst, src, count)) 239 if (copy_from_user(dst, src, count))
236 goto fetch_fault; 240 goto fetch_fault;
@@ -241,7 +245,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
241 } 245 }
242#else 246#else
243 dst += 4-count; 247 dst += 4-count;
244 248
245 if (copy_from_user(dst, src, count)) 249 if (copy_from_user(dst, src, count))
246 goto fetch_fault; 250 goto fetch_fault;
247 251
@@ -320,7 +324,8 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
320 return -EFAULT; 324 return -EFAULT;
321 325
322 /* kernel */ 326 /* kernel */
323 die("delay-slot-insn faulting in handle_unaligned_delayslot", regs, 0); 327 die("delay-slot-insn faulting in handle_unaligned_delayslot",
328 regs, 0);
324 } 329 }
325 330
326 return handle_unaligned_ins(instruction,regs); 331 return handle_unaligned_ins(instruction,regs);
@@ -342,6 +347,13 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
342#define SH_PC_8BIT_OFFSET(instr) ((((signed char)(instr))*2) + 4) 347#define SH_PC_8BIT_OFFSET(instr) ((((signed char)(instr))*2) + 4)
343#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4) 348#define SH_PC_12BIT_OFFSET(instr) ((((signed short)(instr<<4))>>3) + 4)
344 349
350/*
351 * XXX: SH-2A needs this too, but it needs an overhaul thanks to mixed 32-bit
352 * opcodes..
353 */
354#ifndef CONFIG_CPU_SH2A
355static int handle_unaligned_notify_count = 10;
356
345static int handle_unaligned_access(u16 instruction, struct pt_regs *regs) 357static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
346{ 358{
347 u_int rm; 359 u_int rm;
@@ -354,7 +366,8 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
354 if (user_mode(regs) && handle_unaligned_notify_count>0) { 366 if (user_mode(regs) && handle_unaligned_notify_count>0) {
355 handle_unaligned_notify_count--; 367 handle_unaligned_notify_count--;
356 368
357 printk("Fixing up unaligned userspace access in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", 369 printk(KERN_NOTICE "Fixing up unaligned userspace access "
370 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
358 current->comm,current->pid,(u16*)regs->pc,instruction); 371 current->comm,current->pid,(u16*)regs->pc,instruction);
359 } 372 }
360 373
@@ -478,32 +491,58 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
478 regs->pc += 2; 491 regs->pc += 2;
479 return ret; 492 return ret;
480} 493}
494#endif /* CONFIG_CPU_SH2A */
495
496#ifdef CONFIG_CPU_HAS_SR_RB
497#define lookup_exception_vector(x) \
498 __asm__ __volatile__ ("stc r2_bank, %0\n\t" : "=r" ((x)))
499#else
500#define lookup_exception_vector(x) \
501 __asm__ __volatile__ ("mov r4, %0\n\t" : "=r" ((x)))
502#endif
481 503
482/* 504/*
483 * Handle various address error exceptions 505 * Handle various address error exceptions:
506 * - instruction address error:
507 * misaligned PC
508 * PC >= 0x80000000 in user mode
509 * - data address error (read and write)
510 * misaligned data access
511 * access to >= 0x80000000 is user mode
512 * Unfortuntaly we can't distinguish between instruction address error
513 * and data address errors caused by read acceses.
484 */ 514 */
485asmlinkage void do_address_error(struct pt_regs *regs, 515asmlinkage void do_address_error(struct pt_regs *regs,
486 unsigned long writeaccess, 516 unsigned long writeaccess,
487 unsigned long address) 517 unsigned long address)
488{ 518{
489 unsigned long error_code; 519 unsigned long error_code = 0;
490 mm_segment_t oldfs; 520 mm_segment_t oldfs;
521 siginfo_t info;
522#ifndef CONFIG_CPU_SH2A
491 u16 instruction; 523 u16 instruction;
492 int tmp; 524 int tmp;
525#endif
493 526
494 asm volatile("stc r2_bank,%0": "=r" (error_code)); 527 /* Intentional ifdef */
528#ifdef CONFIG_CPU_HAS_SR_RB
529 lookup_exception_vector(error_code);
530#endif
495 531
496 oldfs = get_fs(); 532 oldfs = get_fs();
497 533
498 if (user_mode(regs)) { 534 if (user_mode(regs)) {
535 int si_code = BUS_ADRERR;
536
499 local_irq_enable(); 537 local_irq_enable();
500 current->thread.error_code = error_code;
501 current->thread.trap_no = (writeaccess) ? 8 : 7;
502 538
503 /* bad PC is not something we can fix */ 539 /* bad PC is not something we can fix */
504 if (regs->pc & 1) 540 if (regs->pc & 1) {
541 si_code = BUS_ADRALN;
505 goto uspace_segv; 542 goto uspace_segv;
543 }
506 544
545#ifndef CONFIG_CPU_SH2A
507 set_fs(USER_DS); 546 set_fs(USER_DS);
508 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 547 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
509 /* Argh. Fault on the instruction itself. 548 /* Argh. Fault on the instruction itself.
@@ -518,14 +557,23 @@ asmlinkage void do_address_error(struct pt_regs *regs,
518 557
519 if (tmp==0) 558 if (tmp==0)
520 return; /* sorted */ 559 return; /* sorted */
560#endif
521 561
522 uspace_segv: 562uspace_segv:
523 printk(KERN_NOTICE "Killing process \"%s\" due to unaligned access\n", current->comm); 563 printk(KERN_NOTICE "Sending SIGBUS to \"%s\" due to unaligned "
524 force_sig(SIGSEGV, current); 564 "access (PC %lx PR %lx)\n", current->comm, regs->pc,
565 regs->pr);
566
567 info.si_signo = SIGBUS;
568 info.si_errno = 0;
569 info.si_code = si_code;
570 info.si_addr = (void *) address;
571 force_sig_info(SIGBUS, &info, current);
525 } else { 572 } else {
526 if (regs->pc & 1) 573 if (regs->pc & 1)
527 die("unaligned program counter", regs, error_code); 574 die("unaligned program counter", regs, error_code);
528 575
576#ifndef CONFIG_CPU_SH2A
529 set_fs(KERNEL_DS); 577 set_fs(KERNEL_DS);
530 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 578 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) {
531 /* Argh. Fault on the instruction itself. 579 /* Argh. Fault on the instruction itself.
@@ -537,6 +585,12 @@ asmlinkage void do_address_error(struct pt_regs *regs,
537 585
538 handle_unaligned_access(instruction, regs); 586 handle_unaligned_access(instruction, regs);
539 set_fs(oldfs); 587 set_fs(oldfs);
588#else
589 printk(KERN_NOTICE "Killing process \"%s\" due to unaligned "
590 "access\n", current->comm);
591
592 force_sig(SIGSEGV, current);
593#endif
540 } 594 }
541} 595}
542 596
@@ -548,7 +602,7 @@ int is_dsp_inst(struct pt_regs *regs)
548{ 602{
549 unsigned short inst; 603 unsigned short inst;
550 604
551 /* 605 /*
552 * Safe guard if DSP mode is already enabled or we're lacking 606 * Safe guard if DSP mode is already enabled or we're lacking
553 * the DSP altogether. 607 * the DSP altogether.
554 */ 608 */
@@ -569,27 +623,49 @@ int is_dsp_inst(struct pt_regs *regs)
569#define is_dsp_inst(regs) (0) 623#define is_dsp_inst(regs) (0)
570#endif /* CONFIG_SH_DSP */ 624#endif /* CONFIG_SH_DSP */
571 625
626#ifdef CONFIG_CPU_SH2A
627asmlinkage void do_divide_error(unsigned long r4, unsigned long r5,
628 unsigned long r6, unsigned long r7,
629 struct pt_regs __regs)
630{
631 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
632 siginfo_t info;
633
634 switch (r4) {
635 case TRAP_DIVZERO_ERROR:
636 info.si_code = FPE_INTDIV;
637 break;
638 case TRAP_DIVOVF_ERROR:
639 info.si_code = FPE_INTOVF;
640 break;
641 }
642
643 force_sig_info(SIGFPE, &info, current);
644}
645#endif
646
572/* arch/sh/kernel/cpu/sh4/fpu.c */ 647/* arch/sh/kernel/cpu/sh4/fpu.c */
573extern int do_fpu_inst(unsigned short, struct pt_regs *); 648extern int do_fpu_inst(unsigned short, struct pt_regs *);
574extern asmlinkage void do_fpu_state_restore(unsigned long r4, unsigned long r5, 649extern asmlinkage void do_fpu_state_restore(unsigned long r4, unsigned long r5,
575 unsigned long r6, unsigned long r7, struct pt_regs regs); 650 unsigned long r6, unsigned long r7, struct pt_regs __regs);
576 651
577asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, 652asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
578 unsigned long r6, unsigned long r7, 653 unsigned long r6, unsigned long r7,
579 struct pt_regs regs) 654 struct pt_regs __regs)
580{ 655{
656 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
581 unsigned long error_code; 657 unsigned long error_code;
582 struct task_struct *tsk = current; 658 struct task_struct *tsk = current;
583 659
584#ifdef CONFIG_SH_FPU_EMU 660#ifdef CONFIG_SH_FPU_EMU
585 unsigned short inst; 661 unsigned short inst = 0;
586 int err; 662 int err;
587 663
588 get_user(inst, (unsigned short*)regs.pc); 664 get_user(inst, (unsigned short*)regs->pc);
589 665
590 err = do_fpu_inst(inst, &regs); 666 err = do_fpu_inst(inst, regs);
591 if (!err) { 667 if (!err) {
592 regs.pc += 2; 668 regs->pc += 2;
593 return; 669 return;
594 } 670 }
595 /* not a FPU inst. */ 671 /* not a FPU inst. */
@@ -597,20 +673,19 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
597 673
598#ifdef CONFIG_SH_DSP 674#ifdef CONFIG_SH_DSP
599 /* Check if it's a DSP instruction */ 675 /* Check if it's a DSP instruction */
600 if (is_dsp_inst(&regs)) { 676 if (is_dsp_inst(regs)) {
601 /* Enable DSP mode, and restart instruction. */ 677 /* Enable DSP mode, and restart instruction. */
602 regs.sr |= SR_DSP; 678 regs->sr |= SR_DSP;
603 return; 679 return;
604 } 680 }
605#endif 681#endif
606 682
607 asm volatile("stc r2_bank, %0": "=r" (error_code)); 683 lookup_exception_vector(error_code);
684
608 local_irq_enable(); 685 local_irq_enable();
609 tsk->thread.error_code = error_code; 686 CHK_REMOTE_DEBUG(regs);
610 tsk->thread.trap_no = TRAP_RESERVED_INST;
611 CHK_REMOTE_DEBUG(&regs);
612 force_sig(SIGILL, tsk); 687 force_sig(SIGILL, tsk);
613 die_if_no_fixup("reserved instruction", &regs, error_code); 688 die_if_no_fixup("reserved instruction", regs, error_code);
614} 689}
615 690
616#ifdef CONFIG_SH_FPU_EMU 691#ifdef CONFIG_SH_FPU_EMU
@@ -658,39 +733,41 @@ static int emulate_branch(unsigned short inst, struct pt_regs* regs)
658 733
659asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5, 734asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5,
660 unsigned long r6, unsigned long r7, 735 unsigned long r6, unsigned long r7,
661 struct pt_regs regs) 736 struct pt_regs __regs)
662{ 737{
738 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
663 unsigned long error_code; 739 unsigned long error_code;
664 struct task_struct *tsk = current; 740 struct task_struct *tsk = current;
665#ifdef CONFIG_SH_FPU_EMU 741#ifdef CONFIG_SH_FPU_EMU
666 unsigned short inst; 742 unsigned short inst = 0;
667 743
668 get_user(inst, (unsigned short *)regs.pc + 1); 744 get_user(inst, (unsigned short *)regs->pc + 1);
669 if (!do_fpu_inst(inst, &regs)) { 745 if (!do_fpu_inst(inst, regs)) {
670 get_user(inst, (unsigned short *)regs.pc); 746 get_user(inst, (unsigned short *)regs->pc);
671 if (!emulate_branch(inst, &regs)) 747 if (!emulate_branch(inst, regs))
672 return; 748 return;
673 /* fault in branch.*/ 749 /* fault in branch.*/
674 } 750 }
675 /* not a FPU inst. */ 751 /* not a FPU inst. */
676#endif 752#endif
677 753
678 asm volatile("stc r2_bank, %0": "=r" (error_code)); 754 lookup_exception_vector(error_code);
755
679 local_irq_enable(); 756 local_irq_enable();
680 tsk->thread.error_code = error_code; 757 CHK_REMOTE_DEBUG(regs);
681 tsk->thread.trap_no = TRAP_RESERVED_INST;
682 CHK_REMOTE_DEBUG(&regs);
683 force_sig(SIGILL, tsk); 758 force_sig(SIGILL, tsk);
684 die_if_no_fixup("illegal slot instruction", &regs, error_code); 759 die_if_no_fixup("illegal slot instruction", regs, error_code);
685} 760}
686 761
687asmlinkage void do_exception_error(unsigned long r4, unsigned long r5, 762asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
688 unsigned long r6, unsigned long r7, 763 unsigned long r6, unsigned long r7,
689 struct pt_regs regs) 764 struct pt_regs __regs)
690{ 765{
766 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
691 long ex; 767 long ex;
692 asm volatile("stc r2_bank, %0" : "=r" (ex)); 768
693 die_if_kernel("exception", &regs, ex); 769 lookup_exception_vector(ex);
770 die_if_kernel("exception", regs, ex);
694} 771}
695 772
696#if defined(CONFIG_SH_STANDARD_BIOS) 773#if defined(CONFIG_SH_STANDARD_BIOS)
@@ -735,12 +812,16 @@ void *set_exception_table_vec(unsigned int vec, void *handler)
735{ 812{
736 extern void *exception_handling_table[]; 813 extern void *exception_handling_table[];
737 void *old_handler; 814 void *old_handler;
738 815
739 old_handler = exception_handling_table[vec]; 816 old_handler = exception_handling_table[vec];
740 exception_handling_table[vec] = handler; 817 exception_handling_table[vec] = handler;
741 return old_handler; 818 return old_handler;
742} 819}
743 820
821extern asmlinkage void address_error_handler(unsigned long r4, unsigned long r5,
822 unsigned long r6, unsigned long r7,
823 struct pt_regs __regs);
824
744void __init trap_init(void) 825void __init trap_init(void)
745{ 826{
746 set_exception_table_vec(TRAP_RESERVED_INST, do_reserved_inst); 827 set_exception_table_vec(TRAP_RESERVED_INST, do_reserved_inst);
@@ -759,7 +840,15 @@ void __init trap_init(void)
759 set_exception_table_evt(0x800, do_fpu_state_restore); 840 set_exception_table_evt(0x800, do_fpu_state_restore);
760 set_exception_table_evt(0x820, do_fpu_state_restore); 841 set_exception_table_evt(0x820, do_fpu_state_restore);
761#endif 842#endif
762 843
844#ifdef CONFIG_CPU_SH2
845 set_exception_table_vec(TRAP_ADDRESS_ERROR, address_error_handler);
846#endif
847#ifdef CONFIG_CPU_SH2A
848 set_exception_table_vec(TRAP_DIVZERO_ERROR, do_divide_error);
849 set_exception_table_vec(TRAP_DIVOVF_ERROR, do_divide_error);
850#endif
851
763 /* Setup VBR for boot cpu */ 852 /* Setup VBR for boot cpu */
764 per_cpu_trap_init(); 853 per_cpu_trap_init();
765} 854}
@@ -784,6 +873,11 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
784 } 873 }
785 874
786 printk("\n"); 875 printk("\n");
876
877 if (!tsk)
878 tsk = current;
879
880 debug_show_held_locks(tsk);
787} 881}
788 882
789void show_stack(struct task_struct *tsk, unsigned long *sp) 883void show_stack(struct task_struct *tsk, unsigned long *sp)
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index 9dd606464d23..4e0362f50384 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -4,8 +4,12 @@ menu "Processor selection"
4# Processor families 4# Processor families
5# 5#
6config CPU_SH2 6config CPU_SH2
7 select SH_WRITETHROUGH if !CPU_SH2A
7 bool 8 bool
8 select SH_WRITETHROUGH 9
10config CPU_SH2A
11 bool
12 select CPU_SH2
9 13
10config CPU_SH3 14config CPU_SH3
11 bool 15 bool
@@ -16,6 +20,7 @@ config CPU_SH4
16 bool 20 bool
17 select CPU_HAS_INTEVT 21 select CPU_HAS_INTEVT
18 select CPU_HAS_SR_RB 22 select CPU_HAS_SR_RB
23 select CPU_HAS_PTEA if !CPU_SUBTYPE_ST40
19 24
20config CPU_SH4A 25config CPU_SH4A
21 bool 26 bool
@@ -40,6 +45,16 @@ config CPU_SUBTYPE_SH7604
40 bool "Support SH7604 processor" 45 bool "Support SH7604 processor"
41 select CPU_SH2 46 select CPU_SH2
42 47
48config CPU_SUBTYPE_SH7619
49 bool "Support SH7619 processor"
50 select CPU_SH2
51
52comment "SH-2A Processor Support"
53
54config CPU_SUBTYPE_SH7206
55 bool "Support SH7206 processor"
56 select CPU_SH2A
57
43comment "SH-3 Processor Support" 58comment "SH-3 Processor Support"
44 59
45config CPU_SUBTYPE_SH7300 60config CPU_SUBTYPE_SH7300
@@ -89,6 +104,7 @@ comment "SH-4 Processor Support"
89config CPU_SUBTYPE_SH7750 104config CPU_SUBTYPE_SH7750
90 bool "Support SH7750 processor" 105 bool "Support SH7750 processor"
91 select CPU_SH4 106 select CPU_SH4
107 select CPU_HAS_IPR_IRQ
92 help 108 help
93 Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU. 109 Select SH7750 if you have a 200 Mhz SH-4 HD6417750 CPU.
94 110
@@ -104,15 +120,18 @@ config CPU_SUBTYPE_SH7750R
104 bool "Support SH7750R processor" 120 bool "Support SH7750R processor"
105 select CPU_SH4 121 select CPU_SH4
106 select CPU_SUBTYPE_SH7750 122 select CPU_SUBTYPE_SH7750
123 select CPU_HAS_IPR_IRQ
107 124
108config CPU_SUBTYPE_SH7750S 125config CPU_SUBTYPE_SH7750S
109 bool "Support SH7750S processor" 126 bool "Support SH7750S processor"
110 select CPU_SH4 127 select CPU_SH4
111 select CPU_SUBTYPE_SH7750 128 select CPU_SUBTYPE_SH7750
129 select CPU_HAS_IPR_IRQ
112 130
113config CPU_SUBTYPE_SH7751 131config CPU_SUBTYPE_SH7751
114 bool "Support SH7751 processor" 132 bool "Support SH7751 processor"
115 select CPU_SH4 133 select CPU_SH4
134 select CPU_HAS_IPR_IRQ
116 help 135 help
117 Select SH7751 if you have a 166 Mhz SH-4 HD6417751 CPU, 136 Select SH7751 if you have a 166 Mhz SH-4 HD6417751 CPU,
118 or if you have a HD6417751R CPU. 137 or if you have a HD6417751R CPU.
@@ -121,6 +140,7 @@ config CPU_SUBTYPE_SH7751R
121 bool "Support SH7751R processor" 140 bool "Support SH7751R processor"
122 select CPU_SH4 141 select CPU_SH4
123 select CPU_SUBTYPE_SH7751 142 select CPU_SUBTYPE_SH7751
143 select CPU_HAS_IPR_IRQ
124 144
125config CPU_SUBTYPE_SH7760 145config CPU_SUBTYPE_SH7760
126 bool "Support SH7760 processor" 146 bool "Support SH7760 processor"
@@ -157,6 +177,11 @@ config CPU_SUBTYPE_SH7780
157 select CPU_SH4A 177 select CPU_SH4A
158 select CPU_HAS_INTC2_IRQ 178 select CPU_HAS_INTC2_IRQ
159 179
180config CPU_SUBTYPE_SH7785
181 bool "Support SH7785 processor"
182 select CPU_SH4A
183 select CPU_HAS_INTC2_IRQ
184
160comment "SH4AL-DSP Processor Support" 185comment "SH4AL-DSP Processor Support"
161 186
162config CPU_SUBTYPE_SH73180 187config CPU_SUBTYPE_SH73180
@@ -216,13 +241,22 @@ config MEMORY_SIZE
216 241
217config 32BIT 242config 32BIT
218 bool "Support 32-bit physical addressing through PMB" 243 bool "Support 32-bit physical addressing through PMB"
219 depends on CPU_SH4A && MMU 244 depends on CPU_SH4A && MMU && (!X2TLB || BROKEN)
220 default y 245 default y
221 help 246 help
222 If you say Y here, physical addressing will be extended to 247 If you say Y here, physical addressing will be extended to
223 32-bits through the SH-4A PMB. If this is not set, legacy 248 32-bits through the SH-4A PMB. If this is not set, legacy
224 29-bit physical addressing will be used. 249 29-bit physical addressing will be used.
225 250
251config X2TLB
252 bool "Enable extended TLB mode"
253 depends on CPU_SUBTYPE_SH7785 && MMU && EXPERIMENTAL
254 help
255 Selecting this option will enable the extended mode of the SH-X2
256 TLB. For legacy SH-X behaviour and interoperability, say N. For
257 all of the fun new features and a willingless to submit bug reports,
258 say Y.
259
226config VSYSCALL 260config VSYSCALL
227 bool "Support vsyscall page" 261 bool "Support vsyscall page"
228 depends on MMU 262 depends on MMU
@@ -237,16 +271,52 @@ config VSYSCALL
237 (the default value) say Y. 271 (the default value) say Y.
238 272
239choice 273choice
274 prompt "Kernel page size"
275 default PAGE_SIZE_4KB
276
277config PAGE_SIZE_4KB
278 bool "4kB"
279 help
280 This is the default page size used by all SuperH CPUs.
281
282config PAGE_SIZE_8KB
283 bool "8kB"
284 depends on EXPERIMENTAL && X2TLB
285 help
286 This enables 8kB pages as supported by SH-X2 and later MMUs.
287
288config PAGE_SIZE_64KB
289 bool "64kB"
290 depends on EXPERIMENTAL && CPU_SH4
291 help
292 This enables support for 64kB pages, possible on all SH-4
293 CPUs and later. Highly experimental, not recommended.
294
295endchoice
296
297choice
240 prompt "HugeTLB page size" 298 prompt "HugeTLB page size"
241 depends on HUGETLB_PAGE && CPU_SH4 && MMU 299 depends on HUGETLB_PAGE && CPU_SH4 && MMU
242 default HUGETLB_PAGE_SIZE_64K 300 default HUGETLB_PAGE_SIZE_64K
243 301
244config HUGETLB_PAGE_SIZE_64K 302config HUGETLB_PAGE_SIZE_64K
245 bool "64K" 303 bool "64kB"
304
305config HUGETLB_PAGE_SIZE_256K
306 bool "256kB"
307 depends on X2TLB
246 308
247config HUGETLB_PAGE_SIZE_1MB 309config HUGETLB_PAGE_SIZE_1MB
248 bool "1MB" 310 bool "1MB"
249 311
312config HUGETLB_PAGE_SIZE_4MB
313 bool "4MB"
314 depends on X2TLB
315
316config HUGETLB_PAGE_SIZE_64MB
317 bool "64MB"
318 depends on X2TLB
319
250endchoice 320endchoice
251 321
252source "mm/Kconfig" 322source "mm/Kconfig"
@@ -274,7 +344,6 @@ config SH_DIRECT_MAPPED
274 344
275config SH_WRITETHROUGH 345config SH_WRITETHROUGH
276 bool "Use write-through caching" 346 bool "Use write-through caching"
277 default y if CPU_SH2
278 help 347 help
279 Selecting this option will configure the caches in write-through 348 Selecting this option will configure the caches in write-through
280 mode, as opposed to the default write-back configuration. 349 mode, as opposed to the default write-back configuration.
diff --git a/arch/sh/mm/cache-sh2.c b/arch/sh/mm/cache-sh2.c
index 2689cb24ea2b..6614033f6be9 100644
--- a/arch/sh/mm/cache-sh2.c
+++ b/arch/sh/mm/cache-sh2.c
@@ -5,6 +5,7 @@
5 * 5 *
6 * Released under the terms of the GNU GPL v2.0. 6 * Released under the terms of the GNU GPL v2.0.
7 */ 7 */
8
8#include <linux/init.h> 9#include <linux/init.h>
9#include <linux/mm.h> 10#include <linux/mm.h>
10 11
@@ -14,37 +15,43 @@
14#include <asm/cacheflush.h> 15#include <asm/cacheflush.h>
15#include <asm/io.h> 16#include <asm/io.h>
16 17
17/* 18void __flush_wback_region(void *start, int size)
18 * Calculate the OC address and set the way bit on the SH-2.
19 *
20 * We must have already jump_to_P2()'ed prior to calling this
21 * function, since we rely on CCR manipulation to do the
22 * Right Thing(tm).
23 */
24unsigned long __get_oc_addr(unsigned long set, unsigned long way)
25{ 19{
26 unsigned long ccr; 20 unsigned long v;
27 21 unsigned long begin, end;
28 /* 22
29 * On SH-2 the way bit isn't tracked in the address field 23 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
30 * if we're doing address array access .. instead, we need 24 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
31 * to manually switch out the way in the CCR. 25 & ~(L1_CACHE_BYTES-1);
32 */ 26 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
33 ccr = ctrl_inl(CCR); 27 /* FIXME cache purge */
34 ccr &= ~0x00c0; 28 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
35 ccr |= way << cpu_data->dcache.way_shift; 29 }
36 30}
37 /* 31
38 * Despite the number of sets being halved, we end up losing 32void __flush_purge_region(void *start, int size)
39 * the first 2 ways to OCRAM instead of the last 2 (if we're 33{
40 * 4-way). As a result, forcibly setting the W1 bit handily 34 unsigned long v;
41 * bumps us up 2 ways. 35 unsigned long begin, end;
42 */ 36
43 if (ccr & CCR_CACHE_ORA) 37 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
44 ccr |= 1 << (cpu_data->dcache.way_shift + 1); 38 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
45 39 & ~(L1_CACHE_BYTES-1);
46 ctrl_outl(ccr, CCR); 40 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
47 41 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
48 return CACHE_OC_ADDRESS_ARRAY | (set << cpu_data->dcache.entry_shift); 42 }
43}
44
45void __flush_invalidate_region(void *start, int size)
46{
47 unsigned long v;
48 unsigned long begin, end;
49
50 begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
51 end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
52 & ~(L1_CACHE_BYTES-1);
53 for (v = begin; v < end; v+=L1_CACHE_BYTES) {
54 ctrl_outl((v & 0x1ffffc00), (v & 0x00000ff0) | 0x00000008);
55 }
49} 56}
50 57
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index e48cc22724d9..ae531affccbd 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -11,12 +11,8 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/addrspace.h> 14#include <linux/io.h>
15#include <asm/pgtable.h> 15#include <linux/mutex.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18#include <asm/io.h>
19#include <asm/pgalloc.h>
20#include <asm/mmu_context.h> 16#include <asm/mmu_context.h>
21#include <asm/cacheflush.h> 17#include <asm/cacheflush.h>
22 18
@@ -83,9 +79,9 @@ static void __init emit_cache_params(void)
83 */ 79 */
84 80
85/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */ 81/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */
86#define MAX_P3_SEMAPHORES 16 82#define MAX_P3_MUTEXES 16
87 83
88struct semaphore p3map_sem[MAX_P3_SEMAPHORES]; 84struct mutex p3map_mutex[MAX_P3_MUTEXES];
89 85
90void __init p3_cache_init(void) 86void __init p3_cache_init(void)
91{ 87{
@@ -115,7 +111,7 @@ void __init p3_cache_init(void)
115 panic("%s failed.", __FUNCTION__); 111 panic("%s failed.", __FUNCTION__);
116 112
117 for (i = 0; i < cpu_data->dcache.n_aliases; i++) 113 for (i = 0; i < cpu_data->dcache.n_aliases; i++)
118 sema_init(&p3map_sem[i], 1); 114 mutex_init(&p3map_mutex[i]);
119} 115}
120 116
121/* 117/*
@@ -229,7 +225,7 @@ static inline void flush_cache_4096(unsigned long start,
229 */ 225 */
230 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) || 226 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) ||
231 (start < CACHE_OC_ADDRESS_ARRAY)) 227 (start < CACHE_OC_ADDRESS_ARRAY))
232 exec_offset = 0x20000000; 228 exec_offset = 0x20000000;
233 229
234 local_irq_save(flags); 230 local_irq_save(flags);
235 __flush_cache_4096(start | SH_CACHE_ASSOC, 231 __flush_cache_4096(start | SH_CACHE_ASSOC,
@@ -250,7 +246,7 @@ void flush_dcache_page(struct page *page)
250 246
251 /* Loop all the D-cache */ 247 /* Loop all the D-cache */
252 n = cpu_data->dcache.n_aliases; 248 n = cpu_data->dcache.n_aliases;
253 for (i = 0; i < n; i++, addr += PAGE_SIZE) 249 for (i = 0; i < n; i++, addr += 4096)
254 flush_cache_4096(addr, phys); 250 flush_cache_4096(addr, phys);
255 } 251 }
256 252
diff --git a/arch/sh/mm/clear_page.S b/arch/sh/mm/clear_page.S
index 7b96425ae270..8a706131e521 100644
--- a/arch/sh/mm/clear_page.S
+++ b/arch/sh/mm/clear_page.S
@@ -1,12 +1,12 @@
1/* $Id: clear_page.S,v 1.13 2003/08/25 17:03:10 lethal Exp $ 1/*
2 *
3 * __clear_user_page, __clear_user, clear_page implementation of SuperH 2 * __clear_user_page, __clear_user, clear_page implementation of SuperH
4 * 3 *
5 * Copyright (C) 2001 Kaz Kojima 4 * Copyright (C) 2001 Kaz Kojima
6 * Copyright (C) 2001, 2002 Niibe Yutaka 5 * Copyright (C) 2001, 2002 Niibe Yutaka
7 * 6 * Copyright (C) 2006 Paul Mundt
8 */ 7 */
9#include <linux/linkage.h> 8#include <linux/linkage.h>
9#include <asm/page.h>
10 10
11/* 11/*
12 * clear_page_slow 12 * clear_page_slow
@@ -18,11 +18,11 @@
18/* 18/*
19 * r0 --- scratch 19 * r0 --- scratch
20 * r4 --- to 20 * r4 --- to
21 * r5 --- to + 4096 21 * r5 --- to + PAGE_SIZE
22 */ 22 */
23ENTRY(clear_page_slow) 23ENTRY(clear_page_slow)
24 mov r4,r5 24 mov r4,r5
25 mov.w .Llimit,r0 25 mov.l .Llimit,r0
26 add r0,r5 26 add r0,r5
27 mov #0,r0 27 mov #0,r0
28 ! 28 !
@@ -50,7 +50,7 @@ ENTRY(clear_page_slow)
50 ! 50 !
51 rts 51 rts
52 nop 52 nop
53.Llimit: .word (4096-28) 53.Llimit: .long (PAGE_SIZE-28)
54 54
55ENTRY(__clear_user) 55ENTRY(__clear_user)
56 ! 56 !
@@ -164,10 +164,10 @@ ENTRY(__clear_user)
164 * r0 --- scratch 164 * r0 --- scratch
165 * r4 --- to 165 * r4 --- to
166 * r5 --- orig_to 166 * r5 --- orig_to
167 * r6 --- to + 4096 167 * r6 --- to + PAGE_SIZE
168 */ 168 */
169ENTRY(__clear_user_page) 169ENTRY(__clear_user_page)
170 mov.w .L4096,r0 170 mov.l .Lpsz,r0
171 mov r4,r6 171 mov r4,r6
172 add r0,r6 172 add r0,r6
173 mov #0,r0 173 mov #0,r0
@@ -191,7 +191,7 @@ ENTRY(__clear_user_page)
191 ! 191 !
192 rts 192 rts
193 nop 193 nop
194.L4096: .word 4096 194.Lpsz: .long PAGE_SIZE
195 195
196#endif 196#endif
197 197
diff --git a/arch/sh/mm/copy_page.S b/arch/sh/mm/copy_page.S
index 1addffe117c3..397c94c97315 100644
--- a/arch/sh/mm/copy_page.S
+++ b/arch/sh/mm/copy_page.S
@@ -1,12 +1,12 @@
1/* $Id: copy_page.S,v 1.8 2003/08/25 17:03:10 lethal Exp $ 1/*
2 *
3 * copy_page, __copy_user_page, __copy_user implementation of SuperH 2 * copy_page, __copy_user_page, __copy_user implementation of SuperH
4 * 3 *
5 * Copyright (C) 2001 Niibe Yutaka & Kaz Kojima 4 * Copyright (C) 2001 Niibe Yutaka & Kaz Kojima
6 * Copyright (C) 2002 Toshinobu Sugioka 5 * Copyright (C) 2002 Toshinobu Sugioka
7 * 6 * Copyright (C) 2006 Paul Mundt
8 */ 7 */
9#include <linux/linkage.h> 8#include <linux/linkage.h>
9#include <asm/page.h>
10 10
11/* 11/*
12 * copy_page_slow 12 * copy_page_slow
@@ -18,7 +18,7 @@
18 18
19/* 19/*
20 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 20 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch
21 * r8 --- from + 4096 21 * r8 --- from + PAGE_SIZE
22 * r9 --- not used 22 * r9 --- not used
23 * r10 --- to 23 * r10 --- to
24 * r11 --- from 24 * r11 --- from
@@ -30,7 +30,7 @@ ENTRY(copy_page_slow)
30 mov r4,r10 30 mov r4,r10
31 mov r5,r11 31 mov r5,r11
32 mov r5,r8 32 mov r5,r8
33 mov.w .L4096,r0 33 mov.l .Lpsz,r0
34 add r0,r8 34 add r0,r8
35 ! 35 !
361: mov.l @r11+,r0 361: mov.l @r11+,r0
@@ -80,7 +80,7 @@ ENTRY(copy_page_slow)
80 80
81/* 81/*
82 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch 82 * r0, r1, r2, r3, r4, r5, r6, r7 --- scratch
83 * r8 --- from + 4096 83 * r8 --- from + PAGE_SIZE
84 * r9 --- orig_to 84 * r9 --- orig_to
85 * r10 --- to 85 * r10 --- to
86 * r11 --- from 86 * r11 --- from
@@ -94,7 +94,7 @@ ENTRY(__copy_user_page)
94 mov r5,r11 94 mov r5,r11
95 mov r6,r9 95 mov r6,r9
96 mov r5,r8 96 mov r5,r8
97 mov.w .L4096,r0 97 mov.l .Lpsz,r0
98 add r0,r8 98 add r0,r8
99 ! 99 !
1001: ocbi @r9 1001: ocbi @r9
@@ -129,7 +129,7 @@ ENTRY(__copy_user_page)
129 rts 129 rts
130 nop 130 nop
131#endif 131#endif
132.L4096: .word 4096 132.Lpsz: .long PAGE_SIZE
133/* 133/*
134 * __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); 134 * __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
135 * Return the number of bytes NOT copied 135 * Return the number of bytes NOT copied
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 68663b8f99ae..716ebf568af2 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -26,13 +26,19 @@ extern void die(const char *,struct pt_regs *,long);
26 * and the problem, and then passes it off to one of the appropriate 26 * and the problem, and then passes it off to one of the appropriate
27 * routines. 27 * routines.
28 */ 28 */
29asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess, 29asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
30 unsigned long address) 30 unsigned long writeaccess,
31 unsigned long address)
31{ 32{
32 struct task_struct *tsk; 33 struct task_struct *tsk;
33 struct mm_struct *mm; 34 struct mm_struct *mm;
34 struct vm_area_struct * vma; 35 struct vm_area_struct * vma;
35 unsigned long page; 36 unsigned long page;
37 int si_code;
38 siginfo_t info;
39
40 trace_hardirqs_on();
41 local_irq_enable();
36 42
37#ifdef CONFIG_SH_KGDB 43#ifdef CONFIG_SH_KGDB
38 if (kgdb_nofault && kgdb_bus_err_hook) 44 if (kgdb_nofault && kgdb_bus_err_hook)
@@ -41,6 +47,46 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
41 47
42 tsk = current; 48 tsk = current;
43 mm = tsk->mm; 49 mm = tsk->mm;
50 si_code = SEGV_MAPERR;
51
52 if (unlikely(address >= TASK_SIZE)) {
53 /*
54 * Synchronize this task's top level page-table
55 * with the 'reference' page table.
56 *
57 * Do _not_ use "tsk" here. We might be inside
58 * an interrupt in the middle of a task switch..
59 */
60 int offset = pgd_index(address);
61 pgd_t *pgd, *pgd_k;
62 pud_t *pud, *pud_k;
63 pmd_t *pmd, *pmd_k;
64
65 pgd = get_TTB() + offset;
66 pgd_k = swapper_pg_dir + offset;
67
68 /* This will never happen with the folded page table. */
69 if (!pgd_present(*pgd)) {
70 if (!pgd_present(*pgd_k))
71 goto bad_area_nosemaphore;
72 set_pgd(pgd, *pgd_k);
73 return;
74 }
75
76 pud = pud_offset(pgd, address);
77 pud_k = pud_offset(pgd_k, address);
78 if (pud_present(*pud) || !pud_present(*pud_k))
79 goto bad_area_nosemaphore;
80 set_pud(pud, *pud_k);
81
82 pmd = pmd_offset(pud, address);
83 pmd_k = pmd_offset(pud_k, address);
84 if (pmd_present(*pmd) || !pmd_present(*pmd_k))
85 goto bad_area_nosemaphore;
86 set_pmd(pmd, *pmd_k);
87
88 return;
89 }
44 90
45 /* 91 /*
46 * If we're in an interrupt or have no user 92 * If we're in an interrupt or have no user
@@ -65,6 +111,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
65 * we can handle it.. 111 * we can handle it..
66 */ 112 */
67good_area: 113good_area:
114 si_code = SEGV_ACCERR;
68 if (writeaccess) { 115 if (writeaccess) {
69 if (!(vma->vm_flags & VM_WRITE)) 116 if (!(vma->vm_flags & VM_WRITE))
70 goto bad_area; 117 goto bad_area;
@@ -104,10 +151,13 @@ survive:
104bad_area: 151bad_area:
105 up_read(&mm->mmap_sem); 152 up_read(&mm->mmap_sem);
106 153
154bad_area_nosemaphore:
107 if (user_mode(regs)) { 155 if (user_mode(regs)) {
108 tsk->thread.address = address; 156 info.si_signo = SIGSEGV;
109 tsk->thread.error_code = writeaccess; 157 info.si_errno = 0;
110 force_sig(SIGSEGV, tsk); 158 info.si_code = si_code;
159 info.si_addr = (void *) address;
160 force_sig_info(SIGSEGV, &info, tsk);
111 return; 161 return;
112 } 162 }
113 163
@@ -127,11 +177,9 @@ no_context:
127 printk(KERN_ALERT "Unable to handle kernel paging request"); 177 printk(KERN_ALERT "Unable to handle kernel paging request");
128 printk(" at virtual address %08lx\n", address); 178 printk(" at virtual address %08lx\n", address);
129 printk(KERN_ALERT "pc = %08lx\n", regs->pc); 179 printk(KERN_ALERT "pc = %08lx\n", regs->pc);
130 asm volatile("mov.l %1, %0" 180 page = (unsigned long)get_TTB();
131 : "=r" (page)
132 : "m" (__m(MMU_TTB)));
133 if (page) { 181 if (page) {
134 page = ((unsigned long *) page)[address >> 22]; 182 page = ((unsigned long *) page)[address >> PGDIR_SHIFT];
135 printk(KERN_ALERT "*pde = %08lx\n", page); 183 printk(KERN_ALERT "*pde = %08lx\n", page);
136 if (page & _PAGE_PRESENT) { 184 if (page & _PAGE_PRESENT) {
137 page &= PAGE_MASK; 185 page &= PAGE_MASK;
@@ -166,98 +214,13 @@ do_sigbus:
166 * Send a sigbus, regardless of whether we were in kernel 214 * Send a sigbus, regardless of whether we were in kernel
167 * or user mode. 215 * or user mode.
168 */ 216 */
169 tsk->thread.address = address; 217 info.si_signo = SIGBUS;
170 tsk->thread.error_code = writeaccess; 218 info.si_errno = 0;
171 tsk->thread.trap_no = 14; 219 info.si_code = BUS_ADRERR;
172 force_sig(SIGBUS, tsk); 220 info.si_addr = (void *)address;
221 force_sig_info(SIGBUS, &info, tsk);
173 222
174 /* Kernel mode? Handle exceptions or die */ 223 /* Kernel mode? Handle exceptions or die */
175 if (!user_mode(regs)) 224 if (!user_mode(regs))
176 goto no_context; 225 goto no_context;
177} 226}
178
179#ifdef CONFIG_SH_STORE_QUEUES
180/*
181 * This is a special case for the SH-4 store queues, as pages for this
182 * space still need to be faulted in before it's possible to flush the
183 * store queue cache for writeout to the remapped region.
184 */
185#define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000)
186#else
187#define P3_ADDR_MAX P4SEG
188#endif
189
190/*
191 * Called with interrupts disabled.
192 */
193asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
194 unsigned long writeaccess,
195 unsigned long address)
196{
197 pgd_t *pgd;
198 pud_t *pud;
199 pmd_t *pmd;
200 pte_t *pte;
201 pte_t entry;
202 struct mm_struct *mm = current->mm;
203 spinlock_t *ptl;
204 int ret = 1;
205
206#ifdef CONFIG_SH_KGDB
207 if (kgdb_nofault && kgdb_bus_err_hook)
208 kgdb_bus_err_hook();
209#endif
210
211 /*
212 * We don't take page faults for P1, P2, and parts of P4, these
213 * are always mapped, whether it be due to legacy behaviour in
214 * 29-bit mode, or due to PMB configuration in 32-bit mode.
215 */
216 if (address >= P3SEG && address < P3_ADDR_MAX) {
217 pgd = pgd_offset_k(address);
218 mm = NULL;
219 } else {
220 if (unlikely(address >= TASK_SIZE || !mm))
221 return 1;
222
223 pgd = pgd_offset(mm, address);
224 }
225
226 pud = pud_offset(pgd, address);
227 if (pud_none_or_clear_bad(pud))
228 return 1;
229 pmd = pmd_offset(pud, address);
230 if (pmd_none_or_clear_bad(pmd))
231 return 1;
232
233 if (mm)
234 pte = pte_offset_map_lock(mm, pmd, address, &ptl);
235 else
236 pte = pte_offset_kernel(pmd, address);
237
238 entry = *pte;
239 if (unlikely(pte_none(entry) || pte_not_present(entry)))
240 goto unlock;
241 if (unlikely(writeaccess && !pte_write(entry)))
242 goto unlock;
243
244 if (writeaccess)
245 entry = pte_mkdirty(entry);
246 entry = pte_mkyoung(entry);
247
248#ifdef CONFIG_CPU_SH4
249 /*
250 * ITLB is not affected by "ldtlb" instruction.
251 * So, we need to flush the entry by ourselves.
252 */
253 __flush_tlb_page(get_asid(), address & PAGE_MASK);
254#endif
255
256 set_pte(pte, entry);
257 update_mmu_cache(NULL, address, entry);
258 ret = 0;
259unlock:
260 if (mm)
261 pte_unmap_unlock(pte, ptl);
262 return ret;
263}
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 7154d1ce9785..59f4cc18235b 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -84,30 +84,22 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
84 pmd_t *pmd; 84 pmd_t *pmd;
85 pte_t *pte; 85 pte_t *pte;
86 86
87 pgd = swapper_pg_dir + pgd_index(addr); 87 pgd = pgd_offset_k(addr);
88 if (pgd_none(*pgd)) { 88 if (pgd_none(*pgd)) {
89 pgd_ERROR(*pgd); 89 pgd_ERROR(*pgd);
90 return; 90 return;
91 } 91 }
92 92
93 pud = pud_offset(pgd, addr); 93 pud = pud_alloc(NULL, pgd, addr);
94 if (pud_none(*pud)) { 94 if (unlikely(!pud)) {
95 pmd = (pmd_t *)get_zeroed_page(GFP_ATOMIC); 95 pud_ERROR(*pud);
96 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER)); 96 return;
97 if (pmd != pmd_offset(pud, 0)) {
98 pud_ERROR(*pud);
99 return;
100 }
101 } 97 }
102 98
103 pmd = pmd_offset(pud, addr); 99 pmd = pmd_alloc(NULL, pud, addr);
104 if (pmd_none(*pmd)) { 100 if (unlikely(!pmd)) {
105 pte = (pte_t *)get_zeroed_page(GFP_ATOMIC); 101 pmd_ERROR(*pmd);
106 set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER)); 102 return;
107 if (pte != pte_offset_kernel(pmd, 0)) {
108 pmd_ERROR(*pmd);
109 return;
110 }
111 } 103 }
112 104
113 pte = pte_offset_kernel(pmd, addr); 105 pte = pte_offset_kernel(pmd, addr);
@@ -155,9 +147,6 @@ extern char __init_begin, __init_end;
155 147
156/* 148/*
157 * paging_init() sets up the page tables 149 * paging_init() sets up the page tables
158 *
159 * This routines also unmaps the page at virtual kernel address 0, so
160 * that we can trap those pesky NULL-reference errors in the kernel.
161 */ 150 */
162void __init paging_init(void) 151void __init paging_init(void)
163{ 152{
@@ -180,14 +169,11 @@ void __init paging_init(void)
180 */ 169 */
181 { 170 {
182 unsigned long max_dma, low, start_pfn; 171 unsigned long max_dma, low, start_pfn;
183 pgd_t *pg_dir;
184 int i;
185
186 /* We don't need kernel mapping as hardware support that. */
187 pg_dir = swapper_pg_dir;
188 172
189 for (i = 0; i < PTRS_PER_PGD; i++) 173 /* We don't need to map the kernel through the TLB, as
190 pgd_val(pg_dir[i]) = 0; 174 * it is permanatly mapped using P1. So clear the
175 * entire pgd. */
176 memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));
191 177
192 /* Turn on the MMU */ 178 /* Turn on the MMU */
193 enable_mmu(); 179 enable_mmu();
@@ -206,6 +192,10 @@ void __init paging_init(void)
206 } 192 }
207 } 193 }
208 194
195 /* Set an initial value for the MMU.TTB so we don't have to
196 * check for a null value. */
197 set_TTB(swapper_pg_dir);
198
209#elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4) 199#elif defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4)
210 /* 200 /*
211 * If we don't have CONFIG_MMU set and the processor in question 201 * If we don't have CONFIG_MMU set and the processor in question
@@ -227,7 +217,6 @@ static struct kcore_list kcore_mem, kcore_vmalloc;
227 217
228void __init mem_init(void) 218void __init mem_init(void)
229{ 219{
230 extern unsigned long empty_zero_page[1024];
231 int codesize, reservedpages, datasize, initsize; 220 int codesize, reservedpages, datasize, initsize;
232 int tmp; 221 int tmp;
233 extern unsigned long memory_start; 222 extern unsigned long memory_start;
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index a9fe80cfc233..11d54c149821 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -28,9 +28,7 @@ static inline void remap_area_pte(pte_t * pte, unsigned long address,
28{ 28{
29 unsigned long end; 29 unsigned long end;
30 unsigned long pfn; 30 unsigned long pfn;
31 pgprot_t pgprot = __pgprot(_PAGE_PRESENT | _PAGE_RW | 31 pgprot_t pgprot = __pgprot(pgprot_val(PAGE_KERNEL_NOCACHE) | flags);
32 _PAGE_DIRTY | _PAGE_ACCESSED |
33 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | flags);
34 32
35 address &= ~PMD_MASK; 33 address &= ~PMD_MASK;
36 end = address + size; 34 end = address + size;
diff --git a/arch/sh/mm/pg-dma.c b/arch/sh/mm/pg-dma.c
index 1406d2e348ca..bb23679369d6 100644
--- a/arch/sh/mm/pg-dma.c
+++ b/arch/sh/mm/pg-dma.c
@@ -39,8 +39,6 @@ static void copy_page_dma(void *to, void *from)
39 39
40static void clear_page_dma(void *to) 40static void clear_page_dma(void *to)
41{ 41{
42 extern unsigned long empty_zero_page[1024];
43
44 /* 42 /*
45 * We get invoked quite early on, if the DMAC hasn't been initialized 43 * We get invoked quite early on, if the DMAC hasn't been initialized
46 * yet, fall back on the slow manual implementation. 44 * yet, fall back on the slow manual implementation.
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index 07371ed7a313..3f98d2a4f936 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -6,22 +6,12 @@
6 * 6 *
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
9#include <linux/init.h>
10#include <linux/mman.h>
11#include <linux/mm.h> 9#include <linux/mm.h>
12#include <linux/threads.h> 10#include <linux/mutex.h>
13#include <asm/addrspace.h>
14#include <asm/page.h>
15#include <asm/pgtable.h>
16#include <asm/processor.h>
17#include <asm/cache.h>
18#include <asm/io.h>
19#include <asm/uaccess.h>
20#include <asm/pgalloc.h>
21#include <asm/mmu_context.h> 11#include <asm/mmu_context.h>
22#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
23 13
24extern struct semaphore p3map_sem[]; 14extern struct mutex p3map_mutex[];
25 15
26#define CACHE_ALIAS (cpu_data->dcache.alias_mask) 16#define CACHE_ALIAS (cpu_data->dcache.alias_mask)
27 17
@@ -37,10 +27,6 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
37 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 27 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
38 clear_page(to); 28 clear_page(to);
39 else { 29 else {
40 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
41 _PAGE_RW | _PAGE_CACHABLE |
42 _PAGE_DIRTY | _PAGE_ACCESSED |
43 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
44 unsigned long phys_addr = PHYSADDR(to); 30 unsigned long phys_addr = PHYSADDR(to);
45 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 31 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
46 pgd_t *pgd = pgd_offset_k(p3_addr); 32 pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -50,8 +36,8 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
50 pte_t entry; 36 pte_t entry;
51 unsigned long flags; 37 unsigned long flags;
52 38
53 entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); 39 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
54 down(&p3map_sem[(address & CACHE_ALIAS)>>12]); 40 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
55 set_pte(pte, entry); 41 set_pte(pte, entry);
56 local_irq_save(flags); 42 local_irq_save(flags);
57 __flush_tlb_page(get_asid(), p3_addr); 43 __flush_tlb_page(get_asid(), p3_addr);
@@ -59,7 +45,7 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
59 update_mmu_cache(NULL, p3_addr, entry); 45 update_mmu_cache(NULL, p3_addr, entry);
60 __clear_user_page((void *)p3_addr, to); 46 __clear_user_page((void *)p3_addr, to);
61 pte_clear(&init_mm, p3_addr, pte); 47 pte_clear(&init_mm, p3_addr, pte);
62 up(&p3map_sem[(address & CACHE_ALIAS)>>12]); 48 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
63 } 49 }
64} 50}
65 51
@@ -77,10 +63,6 @@ void copy_user_page(void *to, void *from, unsigned long address,
77 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 63 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
78 copy_page(to, from); 64 copy_page(to, from);
79 else { 65 else {
80 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
81 _PAGE_RW | _PAGE_CACHABLE |
82 _PAGE_DIRTY | _PAGE_ACCESSED |
83 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
84 unsigned long phys_addr = PHYSADDR(to); 66 unsigned long phys_addr = PHYSADDR(to);
85 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 67 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
86 pgd_t *pgd = pgd_offset_k(p3_addr); 68 pgd_t *pgd = pgd_offset_k(p3_addr);
@@ -90,8 +72,8 @@ void copy_user_page(void *to, void *from, unsigned long address,
90 pte_t entry; 72 pte_t entry;
91 unsigned long flags; 73 unsigned long flags;
92 74
93 entry = pfn_pte(phys_addr >> PAGE_SHIFT, pgprot); 75 entry = pfn_pte(phys_addr >> PAGE_SHIFT, PAGE_KERNEL);
94 down(&p3map_sem[(address & CACHE_ALIAS)>>12]); 76 mutex_lock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
95 set_pte(pte, entry); 77 set_pte(pte, entry);
96 local_irq_save(flags); 78 local_irq_save(flags);
97 __flush_tlb_page(get_asid(), p3_addr); 79 __flush_tlb_page(get_asid(), p3_addr);
@@ -99,7 +81,7 @@ void copy_user_page(void *to, void *from, unsigned long address,
99 update_mmu_cache(NULL, p3_addr, entry); 81 update_mmu_cache(NULL, p3_addr, entry);
100 __copy_user_page((void *)p3_addr, from, to); 82 __copy_user_page((void *)p3_addr, from, to);
101 pte_clear(&init_mm, p3_addr, pte); 83 pte_clear(&init_mm, p3_addr, pte);
102 up(&p3map_sem[(address & CACHE_ALIAS)>>12]); 84 mutex_unlock(&p3map_mutex[(address & CACHE_ALIAS)>>12]);
103 } 85 }
104} 86}
105 87
@@ -122,4 +104,3 @@ inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t
122 } 104 }
123 return pte; 105 return pte;
124} 106}
125
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index ac57638977ee..0571755e9a84 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -30,3 +30,5 @@ R7780MP SH_R7780MP
30TITAN SH_TITAN 30TITAN SH_TITAN
31SHMIN SH_SHMIN 31SHMIN SH_SHMIN
327710VOIPGW SH_7710VOIPGW 327710VOIPGW SH_7710VOIPGW
337206SE SH_7206_SOLUTION_ENGINE
347619SE SH_7619_SOLUTION_ENGINE
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 3576b3cc505e..7d4190e55654 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -638,7 +638,7 @@ int chan_out_fd(struct list_head *chans)
638 return -1; 638 return -1;
639} 639}
640 640
641void chan_interrupt(struct list_head *chans, struct work_struct *task, 641void chan_interrupt(struct list_head *chans, struct delayed_work *task,
642 struct tty_struct *tty, int irq) 642 struct tty_struct *tty, int irq)
643{ 643{
644 struct list_head *ele, *next; 644 struct list_head *ele, *next;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index 7b172160fe04..96f0189327af 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -56,7 +56,7 @@ static struct notifier_block reboot_notifier = {
56 56
57static LIST_HEAD(mc_requests); 57static LIST_HEAD(mc_requests);
58 58
59static void mc_work_proc(void *unused) 59static void mc_work_proc(struct work_struct *unused)
60{ 60{
61 struct mconsole_entry *req; 61 struct mconsole_entry *req;
62 unsigned long flags; 62 unsigned long flags;
@@ -72,7 +72,7 @@ static void mc_work_proc(void *unused)
72 } 72 }
73} 73}
74 74
75static DECLARE_WORK(mconsole_work, mc_work_proc, NULL); 75static DECLARE_WORK(mconsole_work, mc_work_proc);
76 76
77static irqreturn_t mconsole_interrupt(int irq, void *dev_id) 77static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
78{ 78{
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index ec9eb8bd9432..286bc0b3207f 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -99,6 +99,7 @@ irqreturn_t uml_net_interrupt(int irq, void *dev_id)
99 * same device, since it tests for (dev->flags & IFF_UP). So 99 * same device, since it tests for (dev->flags & IFF_UP). So
100 * there's no harm in delaying the device shutdown. */ 100 * there's no harm in delaying the device shutdown. */
101 schedule_work(&close_work); 101 schedule_work(&close_work);
102#error this is not permitted - close_work will go out of scope
102 goto out; 103 goto out;
103 } 104 }
104 reactivate_fd(lp->fd, UM_ETH_IRQ); 105 reactivate_fd(lp->fd, UM_ETH_IRQ);
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index ce9f3733f73e..6dfe632f1c14 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -132,7 +132,7 @@ static int port_accept(struct port_list *port)
132DECLARE_MUTEX(ports_sem); 132DECLARE_MUTEX(ports_sem);
133struct list_head ports = LIST_HEAD_INIT(ports); 133struct list_head ports = LIST_HEAD_INIT(ports);
134 134
135void port_work_proc(void *unused) 135void port_work_proc(struct work_struct *unused)
136{ 136{
137 struct port_list *port; 137 struct port_list *port;
138 struct list_head *ele; 138 struct list_head *ele;
@@ -150,7 +150,7 @@ void port_work_proc(void *unused)
150 local_irq_restore(flags); 150 local_irq_restore(flags);
151} 151}
152 152
153DECLARE_WORK(port_work, port_work_proc, NULL); 153DECLARE_WORK(port_work, port_work_proc);
154 154
155static irqreturn_t port_interrupt(int irq, void *data) 155static irqreturn_t port_interrupt(int irq, void *data)
156{ 156{
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index bbea88801d88..c7587fc39015 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -306,8 +306,8 @@ void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
306 */ 306 */
307 307
308static int check_interval = 5 * 60; /* 5 minutes */ 308static int check_interval = 5 * 60; /* 5 minutes */
309static void mcheck_timer(void *data); 309static void mcheck_timer(struct work_struct *work);
310static DECLARE_WORK(mcheck_work, mcheck_timer, NULL); 310static DECLARE_DELAYED_WORK(mcheck_work, mcheck_timer);
311 311
312static void mcheck_check_cpu(void *info) 312static void mcheck_check_cpu(void *info)
313{ 313{
@@ -315,7 +315,7 @@ static void mcheck_check_cpu(void *info)
315 do_machine_check(NULL, 0); 315 do_machine_check(NULL, 0);
316} 316}
317 317
318static void mcheck_timer(void *data) 318static void mcheck_timer(struct work_struct *work)
319{ 319{
320 on_each_cpu(mcheck_check_cpu, NULL, 1, 1); 320 on_each_cpu(mcheck_check_cpu, NULL, 1, 1);
321 schedule_delayed_work(&mcheck_work, check_interval * HZ); 321 schedule_delayed_work(&mcheck_work, check_interval * HZ);
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 62c2e747af58..9800147c4c68 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -753,14 +753,16 @@ static int __cpuinit wakeup_secondary_via_INIT(int phys_apicid, unsigned int sta
753} 753}
754 754
755struct create_idle { 755struct create_idle {
756 struct work_struct work;
756 struct task_struct *idle; 757 struct task_struct *idle;
757 struct completion done; 758 struct completion done;
758 int cpu; 759 int cpu;
759}; 760};
760 761
761void do_fork_idle(void *_c_idle) 762void do_fork_idle(struct work_struct *work)
762{ 763{
763 struct create_idle *c_idle = _c_idle; 764 struct create_idle *c_idle =
765 container_of(work, struct create_idle, work);
764 766
765 c_idle->idle = fork_idle(c_idle->cpu); 767 c_idle->idle = fork_idle(c_idle->cpu);
766 complete(&c_idle->done); 768 complete(&c_idle->done);
@@ -775,10 +777,10 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
775 int timeout; 777 int timeout;
776 unsigned long start_rip; 778 unsigned long start_rip;
777 struct create_idle c_idle = { 779 struct create_idle c_idle = {
780 .work = __WORK_INITIALIZER(c_idle.work, do_fork_idle),
778 .cpu = cpu, 781 .cpu = cpu,
779 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done), 782 .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
780 }; 783 };
781 DECLARE_WORK(work, do_fork_idle, &c_idle);
782 784
783 /* allocate memory for gdts of secondary cpus. Hotplug is considered */ 785 /* allocate memory for gdts of secondary cpus. Hotplug is considered */
784 if (!cpu_gdt_descr[cpu].address && 786 if (!cpu_gdt_descr[cpu].address &&
@@ -825,9 +827,9 @@ static int __cpuinit do_boot_cpu(int cpu, int apicid)
825 * thread. 827 * thread.
826 */ 828 */
827 if (!keventd_up() || current_is_keventd()) 829 if (!keventd_up() || current_is_keventd())
828 work.func(work.data); 830 c_idle.work.func(&c_idle.work);
829 else { 831 else {
830 schedule_work(&work); 832 schedule_work(&c_idle.work);
831 wait_for_completion(&c_idle.done); 833 wait_for_completion(&c_idle.done);
832 } 834 }
833 835
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index e3ef544d2cfb..9f05bc9b2dad 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -563,7 +563,7 @@ static unsigned int cpufreq_delayed_issched = 0;
563static unsigned int cpufreq_init = 0; 563static unsigned int cpufreq_init = 0;
564static struct work_struct cpufreq_delayed_get_work; 564static struct work_struct cpufreq_delayed_get_work;
565 565
566static void handle_cpufreq_delayed_get(void *v) 566static void handle_cpufreq_delayed_get(struct work_struct *v)
567{ 567{
568 unsigned int cpu; 568 unsigned int cpu;
569 for_each_online_cpu(cpu) { 569 for_each_online_cpu(cpu) {
@@ -639,7 +639,7 @@ static struct notifier_block time_cpufreq_notifier_block = {
639 639
640static int __init cpufreq_tsc(void) 640static int __init cpufreq_tsc(void)
641{ 641{
642 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get, NULL); 642 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get);
643 if (!cpufreq_register_notifier(&time_cpufreq_notifier_block, 643 if (!cpufreq_register_notifier(&time_cpufreq_notifier_block,
644 CPUFREQ_TRANSITION_NOTIFIER)) 644 CPUFREQ_TRANSITION_NOTIFIER))
645 cpufreq_init = 1; 645 cpufreq_init = 1;
diff --git a/block/Kconfig b/block/Kconfig
index 83766a6bdee2..a50f48111647 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -19,11 +19,9 @@ config BLOCK
19 19
20if BLOCK 20if BLOCK
21 21
22#XXX - it makes sense to enable this only for 32-bit subarch's, not for x86_64
23#for instance.
24config LBD 22config LBD
25 bool "Support for Large Block Devices" 23 bool "Support for Large Block Devices"
26 depends on X86 || (MIPS && 32BIT) || PPC32 || (S390 && !64BIT) || SUPERH || UML 24 depends on !64BIT
27 help 25 help
28 Say Y here if you want to attach large (bigger than 2TB) discs to 26 Say Y here if you want to attach large (bigger than 2TB) discs to
29 your machine, or if you want to have a raid or loopback device 27 your machine, or if you want to have a raid or loopback device
@@ -44,7 +42,7 @@ config BLK_DEV_IO_TRACE
44 42
45config LSF 43config LSF
46 bool "Support for Large Single Files" 44 bool "Support for Large Single Files"
47 depends on X86 || (MIPS && 32BIT) || PPC32 || ARCH_S390_31 || SUPERH || UML 45 depends on !64BIT
48 help 46 help
49 Say Y here if you want to be able to handle very large files (bigger 47 Say Y here if you want to be able to handle very large files (bigger
50 than 2TB), otherwise say N. 48 than 2TB), otherwise say N.
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 00242111a457..5934c4bfd52a 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -1274,9 +1274,10 @@ static void as_merged_requests(request_queue_t *q, struct request *req,
1274 * 1274 *
1275 * FIXME! dispatch queue is not a queue at all! 1275 * FIXME! dispatch queue is not a queue at all!
1276 */ 1276 */
1277static void as_work_handler(void *data) 1277static void as_work_handler(struct work_struct *work)
1278{ 1278{
1279 struct request_queue *q = data; 1279 struct as_data *ad = container_of(work, struct as_data, antic_work);
1280 struct request_queue *q = ad->q;
1280 unsigned long flags; 1281 unsigned long flags;
1281 1282
1282 spin_lock_irqsave(q->queue_lock, flags); 1283 spin_lock_irqsave(q->queue_lock, flags);
@@ -1332,7 +1333,7 @@ static void *as_init_queue(request_queue_t *q)
1332 ad->antic_timer.function = as_antic_timeout; 1333 ad->antic_timer.function = as_antic_timeout;
1333 ad->antic_timer.data = (unsigned long)q; 1334 ad->antic_timer.data = (unsigned long)q;
1334 init_timer(&ad->antic_timer); 1335 init_timer(&ad->antic_timer);
1335 INIT_WORK(&ad->antic_work, as_work_handler, q); 1336 INIT_WORK(&ad->antic_work, as_work_handler);
1336 1337
1337 INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]); 1338 INIT_LIST_HEAD(&ad->fifo_list[REQ_SYNC]);
1338 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]); 1339 INIT_LIST_HEAD(&ad->fifo_list[REQ_ASYNC]);
diff --git a/block/blktrace.c b/block/blktrace.c
index 562ca7cbf858..74e02c04b2da 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -31,26 +31,24 @@ static unsigned int blktrace_seq __read_mostly = 1;
31/* 31/*
32 * Send out a notify message. 32 * Send out a notify message.
33 */ 33 */
34static inline unsigned int trace_note(struct blk_trace *bt, 34static void trace_note(struct blk_trace *bt, pid_t pid, int action,
35 pid_t pid, int action, 35 const void *data, size_t len)
36 const void *data, size_t len)
37{ 36{
38 struct blk_io_trace *t; 37 struct blk_io_trace *t;
39 int cpu = smp_processor_id();
40 38
41 t = relay_reserve(bt->rchan, sizeof(*t) + len); 39 t = relay_reserve(bt->rchan, sizeof(*t) + len);
42 if (t == NULL) 40 if (t) {
43 return 0; 41 const int cpu = smp_processor_id();
44 42
45 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION; 43 t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
46 t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu); 44 t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu);
47 t->device = bt->dev; 45 t->device = bt->dev;
48 t->action = action; 46 t->action = action;
49 t->pid = pid; 47 t->pid = pid;
50 t->cpu = cpu; 48 t->cpu = cpu;
51 t->pdu_len = len; 49 t->pdu_len = len;
52 memcpy((void *) t + sizeof(*t), data, len); 50 memcpy((void *) t + sizeof(*t), data, len);
53 return blktrace_seq; 51 }
54} 52}
55 53
56/* 54/*
@@ -59,9 +57,8 @@ static inline unsigned int trace_note(struct blk_trace *bt,
59 */ 57 */
60static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk) 58static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk)
61{ 59{
62 tsk->btrace_seq = trace_note(bt, tsk->pid, 60 tsk->btrace_seq = blktrace_seq;
63 BLK_TN_PROCESS, 61 trace_note(bt, tsk->pid, BLK_TN_PROCESS, tsk->comm, sizeof(tsk->comm));
64 tsk->comm, sizeof(tsk->comm));
65} 62}
66 63
67static void trace_note_time(struct blk_trace *bt) 64static void trace_note_time(struct blk_trace *bt)
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index e9019ed39b73..84e9be073180 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1840,9 +1840,11 @@ queue_fail:
1840 return 1; 1840 return 1;
1841} 1841}
1842 1842
1843static void cfq_kick_queue(void *data) 1843static void cfq_kick_queue(struct work_struct *work)
1844{ 1844{
1845 request_queue_t *q = data; 1845 struct cfq_data *cfqd =
1846 container_of(work, struct cfq_data, unplug_work);
1847 request_queue_t *q = cfqd->queue;
1846 unsigned long flags; 1848 unsigned long flags;
1847 1849
1848 spin_lock_irqsave(q->queue_lock, flags); 1850 spin_lock_irqsave(q->queue_lock, flags);
@@ -1986,7 +1988,7 @@ static void *cfq_init_queue(request_queue_t *q)
1986 cfqd->idle_class_timer.function = cfq_idle_class_timer; 1988 cfqd->idle_class_timer.function = cfq_idle_class_timer;
1987 cfqd->idle_class_timer.data = (unsigned long) cfqd; 1989 cfqd->idle_class_timer.data = (unsigned long) cfqd;
1988 1990
1989 INIT_WORK(&cfqd->unplug_work, cfq_kick_queue, q); 1991 INIT_WORK(&cfqd->unplug_work, cfq_kick_queue);
1990 1992
1991 cfqd->cfq_quantum = cfq_quantum; 1993 cfqd->cfq_quantum = cfq_quantum;
1992 cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0]; 1994 cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0];
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 0f82e12f7b67..cc6e95f8e5d9 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -34,7 +34,7 @@
34 */ 34 */
35#include <scsi/scsi_cmnd.h> 35#include <scsi/scsi_cmnd.h>
36 36
37static void blk_unplug_work(void *data); 37static void blk_unplug_work(struct work_struct *work);
38static void blk_unplug_timeout(unsigned long data); 38static void blk_unplug_timeout(unsigned long data);
39static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io); 39static void drive_stat_acct(struct request *rq, int nr_sectors, int new_io);
40static void init_request_from_bio(struct request *req, struct bio *bio); 40static void init_request_from_bio(struct request *req, struct bio *bio);
@@ -227,7 +227,7 @@ void blk_queue_make_request(request_queue_t * q, make_request_fn * mfn)
227 if (q->unplug_delay == 0) 227 if (q->unplug_delay == 0)
228 q->unplug_delay = 1; 228 q->unplug_delay = 1;
229 229
230 INIT_WORK(&q->unplug_work, blk_unplug_work, q); 230 INIT_WORK(&q->unplug_work, blk_unplug_work);
231 231
232 q->unplug_timer.function = blk_unplug_timeout; 232 q->unplug_timer.function = blk_unplug_timeout;
233 q->unplug_timer.data = (unsigned long)q; 233 q->unplug_timer.data = (unsigned long)q;
@@ -1631,9 +1631,9 @@ static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
1631 } 1631 }
1632} 1632}
1633 1633
1634static void blk_unplug_work(void *data) 1634static void blk_unplug_work(struct work_struct *work)
1635{ 1635{
1636 request_queue_t *q = data; 1636 request_queue_t *q = container_of(work, request_queue_t, unplug_work);
1637 1637
1638 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL, 1638 blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL,
1639 q->rq.count[READ] + q->rq.count[WRITE]); 1639 q->rq.count[READ] + q->rq.count[WRITE]);
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 5493c2fbbab1..b3e210723a71 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -277,7 +277,7 @@ static int sg_io(struct file *file, request_queue_t *q,
277 if (rq->bio) 277 if (rq->bio)
278 blk_queue_bounce(q, &rq->bio); 278 blk_queue_bounce(q, &rq->bio);
279 279
280 rq->timeout = (hdr->timeout * HZ) / 1000; 280 rq->timeout = jiffies_to_msecs(hdr->timeout);
281 if (!rq->timeout) 281 if (!rq->timeout)
282 rq->timeout = q->sg_timeout; 282 rq->timeout = q->sg_timeout;
283 if (!rq->timeout) 283 if (!rq->timeout)
diff --git a/crypto/cryptomgr.c b/crypto/cryptomgr.c
index 9b5b15601068..2ebffb84f1d9 100644
--- a/crypto/cryptomgr.c
+++ b/crypto/cryptomgr.c
@@ -40,9 +40,10 @@ struct cryptomgr_param {
40 char template[CRYPTO_MAX_ALG_NAME]; 40 char template[CRYPTO_MAX_ALG_NAME];
41}; 41};
42 42
43static void cryptomgr_probe(void *data) 43static void cryptomgr_probe(struct work_struct *work)
44{ 44{
45 struct cryptomgr_param *param = data; 45 struct cryptomgr_param *param =
46 container_of(work, struct cryptomgr_param, work);
46 struct crypto_template *tmpl; 47 struct crypto_template *tmpl;
47 struct crypto_instance *inst; 48 struct crypto_instance *inst;
48 int err; 49 int err;
@@ -112,7 +113,7 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
112 param->larval.type = larval->alg.cra_flags; 113 param->larval.type = larval->alg.cra_flags;
113 param->larval.mask = larval->mask; 114 param->larval.mask = larval->mask;
114 115
115 INIT_WORK(&param->work, cryptomgr_probe, param); 116 INIT_WORK(&param->work, cryptomgr_probe);
116 schedule_work(&param->work); 117 schedule_work(&param->work);
117 118
118 return NOTIFY_STOP; 119 return NOTIFY_STOP;
diff --git a/drivers/Makefile b/drivers/Makefile
index 4ac14dab3079..67711770b1d9 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -77,3 +77,4 @@ obj-$(CONFIG_CRYPTO) += crypto/
77obj-$(CONFIG_SUPERH) += sh/ 77obj-$(CONFIG_SUPERH) += sh/
78obj-$(CONFIG_GENERIC_TIME) += clocksource/ 78obj-$(CONFIG_GENERIC_TIME) += clocksource/
79obj-$(CONFIG_DMA_ENGINE) += dma/ 79obj-$(CONFIG_DMA_ENGINE) += dma/
80obj-$(CONFIG_PPC_PS3) += ps3/
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 068fe4f100b0..02b30ae6a68e 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -50,6 +50,7 @@ ACPI_MODULE_NAME("osl")
50struct acpi_os_dpc { 50struct acpi_os_dpc {
51 acpi_osd_exec_callback function; 51 acpi_osd_exec_callback function;
52 void *context; 52 void *context;
53 struct work_struct work;
53}; 54};
54 55
55#ifdef CONFIG_ACPI_CUSTOM_DSDT 56#ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -564,12 +565,9 @@ void acpi_os_derive_pci_id(acpi_handle rhandle, /* upper bound */
564 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number); 565 acpi_os_derive_pci_id_2(rhandle, chandle, id, &is_bridge, &bus_number);
565} 566}
566 567
567static void acpi_os_execute_deferred(void *context) 568static void acpi_os_execute_deferred(struct work_struct *work)
568{ 569{
569 struct acpi_os_dpc *dpc = NULL; 570 struct acpi_os_dpc *dpc = container_of(work, struct acpi_os_dpc, work);
570
571
572 dpc = (struct acpi_os_dpc *)context;
573 if (!dpc) { 571 if (!dpc) {
574 printk(KERN_ERR PREFIX "Invalid (NULL) context\n"); 572 printk(KERN_ERR PREFIX "Invalid (NULL) context\n");
575 return; 573 return;
@@ -602,7 +600,6 @@ acpi_status acpi_os_execute(acpi_execute_type type,
602{ 600{
603 acpi_status status = AE_OK; 601 acpi_status status = AE_OK;
604 struct acpi_os_dpc *dpc; 602 struct acpi_os_dpc *dpc;
605 struct work_struct *task;
606 603
607 ACPI_FUNCTION_TRACE("os_queue_for_execution"); 604 ACPI_FUNCTION_TRACE("os_queue_for_execution");
608 605
@@ -615,28 +612,22 @@ acpi_status acpi_os_execute(acpi_execute_type type,
615 612
616 /* 613 /*
617 * Allocate/initialize DPC structure. Note that this memory will be 614 * Allocate/initialize DPC structure. Note that this memory will be
618 * freed by the callee. The kernel handles the tq_struct list in a 615 * freed by the callee. The kernel handles the work_struct list in a
619 * way that allows us to also free its memory inside the callee. 616 * way that allows us to also free its memory inside the callee.
620 * Because we may want to schedule several tasks with different 617 * Because we may want to schedule several tasks with different
621 * parameters we can't use the approach some kernel code uses of 618 * parameters we can't use the approach some kernel code uses of
622 * having a static tq_struct. 619 * having a static work_struct.
623 * We can save time and code by allocating the DPC and tq_structs
624 * from the same memory.
625 */ 620 */
626 621
627 dpc = 622 dpc = kmalloc(sizeof(struct acpi_os_dpc), GFP_ATOMIC);
628 kmalloc(sizeof(struct acpi_os_dpc) + sizeof(struct work_struct),
629 GFP_ATOMIC);
630 if (!dpc) 623 if (!dpc)
631 return_ACPI_STATUS(AE_NO_MEMORY); 624 return_ACPI_STATUS(AE_NO_MEMORY);
632 625
633 dpc->function = function; 626 dpc->function = function;
634 dpc->context = context; 627 dpc->context = context;
635 628
636 task = (void *)(dpc + 1); 629 INIT_WORK(&dpc->work, acpi_os_execute_deferred);
637 INIT_WORK(task, acpi_os_execute_deferred, (void *)dpc); 630 if (!queue_work(kacpid_wq, &dpc->work)) {
638
639 if (!queue_work(kacpid_wq, task)) {
640 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 631 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
641 "Call to queue_work() failed.\n")); 632 "Call to queue_work() failed.\n"));
642 kfree(dpc); 633 kfree(dpc);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index f8ec3896b793..8816e30fb7a4 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1081,7 +1081,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
1081 * ata_port_queue_task - Queue port_task 1081 * ata_port_queue_task - Queue port_task
1082 * @ap: The ata_port to queue port_task for 1082 * @ap: The ata_port to queue port_task for
1083 * @fn: workqueue function to be scheduled 1083 * @fn: workqueue function to be scheduled
1084 * @data: data value to pass to workqueue function 1084 * @data: data for @fn to use
1085 * @delay: delay time for workqueue function 1085 * @delay: delay time for workqueue function
1086 * 1086 *
1087 * Schedule @fn(@data) for execution after @delay jiffies using 1087 * Schedule @fn(@data) for execution after @delay jiffies using
@@ -1096,7 +1096,7 @@ static unsigned int ata_id_xfermask(const u16 *id)
1096 * LOCKING: 1096 * LOCKING:
1097 * Inherited from caller. 1097 * Inherited from caller.
1098 */ 1098 */
1099void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data, 1099void ata_port_queue_task(struct ata_port *ap, work_func_t fn, void *data,
1100 unsigned long delay) 1100 unsigned long delay)
1101{ 1101{
1102 int rc; 1102 int rc;
@@ -1104,12 +1104,10 @@ void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), void *data,
1104 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK) 1104 if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK)
1105 return; 1105 return;
1106 1106
1107 PREPARE_WORK(&ap->port_task, fn, data); 1107 PREPARE_DELAYED_WORK(&ap->port_task, fn);
1108 ap->port_task_data = data;
1108 1109
1109 if (!delay) 1110 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
1110 rc = queue_work(ata_wq, &ap->port_task);
1111 else
1112 rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
1113 1111
1114 /* rc == 0 means that another user is using port task */ 1112 /* rc == 0 means that another user is using port task */
1115 WARN_ON(rc == 0); 1113 WARN_ON(rc == 0);
@@ -4588,10 +4586,11 @@ fsm_start:
4588 return poll_next; 4586 return poll_next;
4589} 4587}
4590 4588
4591static void ata_pio_task(void *_data) 4589static void ata_pio_task(struct work_struct *work)
4592{ 4590{
4593 struct ata_queued_cmd *qc = _data; 4591 struct ata_port *ap =
4594 struct ata_port *ap = qc->ap; 4592 container_of(work, struct ata_port, port_task.work);
4593 struct ata_queued_cmd *qc = ap->port_task_data;
4595 u8 status; 4594 u8 status;
4596 int poll_next; 4595 int poll_next;
4597 4596
@@ -5635,9 +5634,9 @@ void ata_port_init(struct ata_port *ap, struct ata_host *host,
5635 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN; 5634 ap->msg_enable = ATA_MSG_DRV | ATA_MSG_ERR | ATA_MSG_WARN;
5636#endif 5635#endif
5637 5636
5638 INIT_WORK(&ap->port_task, NULL, NULL); 5637 INIT_DELAYED_WORK(&ap->port_task, NULL);
5639 INIT_WORK(&ap->hotplug_task, ata_scsi_hotplug, ap); 5638 INIT_DELAYED_WORK(&ap->hotplug_task, ata_scsi_hotplug);
5640 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan, ap); 5639 INIT_WORK(&ap->scsi_rescan_task, ata_scsi_dev_rescan);
5641 INIT_LIST_HEAD(&ap->eh_done_q); 5640 INIT_LIST_HEAD(&ap->eh_done_q);
5642 init_waitqueue_head(&ap->eh_wait_q); 5641 init_waitqueue_head(&ap->eh_wait_q);
5643 5642
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 76a85dfb7307..08ad44b3e48f 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -332,7 +332,7 @@ void ata_scsi_error(struct Scsi_Host *host)
332 if (ap->pflags & ATA_PFLAG_LOADING) 332 if (ap->pflags & ATA_PFLAG_LOADING)
333 ap->pflags &= ~ATA_PFLAG_LOADING; 333 ap->pflags &= ~ATA_PFLAG_LOADING;
334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) 334 else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG)
335 queue_work(ata_aux_wq, &ap->hotplug_task); 335 queue_delayed_work(ata_aux_wq, &ap->hotplug_task, 0);
336 336
337 if (ap->pflags & ATA_PFLAG_RECOVERED) 337 if (ap->pflags & ATA_PFLAG_RECOVERED)
338 ata_port_printk(ap, KERN_INFO, "EH complete\n"); 338 ata_port_printk(ap, KERN_INFO, "EH complete\n");
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 8eaace94d963..664e1377b54c 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2963,7 +2963,7 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
2963 2963
2964/** 2964/**
2965 * ata_scsi_hotplug - SCSI part of hotplug 2965 * ata_scsi_hotplug - SCSI part of hotplug
2966 * @data: Pointer to ATA port to perform SCSI hotplug on 2966 * @work: Pointer to ATA port to perform SCSI hotplug on
2967 * 2967 *
2968 * Perform SCSI part of hotplug. It's executed from a separate 2968 * Perform SCSI part of hotplug. It's executed from a separate
2969 * workqueue after EH completes. This is necessary because SCSI 2969 * workqueue after EH completes. This is necessary because SCSI
@@ -2973,9 +2973,10 @@ static void ata_scsi_remove_dev(struct ata_device *dev)
2973 * LOCKING: 2973 * LOCKING:
2974 * Kernel thread context (may sleep). 2974 * Kernel thread context (may sleep).
2975 */ 2975 */
2976void ata_scsi_hotplug(void *data) 2976void ata_scsi_hotplug(struct work_struct *work)
2977{ 2977{
2978 struct ata_port *ap = data; 2978 struct ata_port *ap =
2979 container_of(work, struct ata_port, hotplug_task.work);
2979 int i; 2980 int i;
2980 2981
2981 if (ap->pflags & ATA_PFLAG_UNLOADING) { 2982 if (ap->pflags & ATA_PFLAG_UNLOADING) {
@@ -3076,7 +3077,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3076 3077
3077/** 3078/**
3078 * ata_scsi_dev_rescan - initiate scsi_rescan_device() 3079 * ata_scsi_dev_rescan - initiate scsi_rescan_device()
3079 * @data: Pointer to ATA port to perform scsi_rescan_device() 3080 * @work: Pointer to ATA port to perform scsi_rescan_device()
3080 * 3081 *
3081 * After ATA pass thru (SAT) commands are executed successfully, 3082 * After ATA pass thru (SAT) commands are executed successfully,
3082 * libata need to propagate the changes to SCSI layer. This 3083 * libata need to propagate the changes to SCSI layer. This
@@ -3086,9 +3087,10 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3086 * LOCKING: 3087 * LOCKING:
3087 * Kernel thread context (may sleep). 3088 * Kernel thread context (may sleep).
3088 */ 3089 */
3089void ata_scsi_dev_rescan(void *data) 3090void ata_scsi_dev_rescan(struct work_struct *work)
3090{ 3091{
3091 struct ata_port *ap = data; 3092 struct ata_port *ap =
3093 container_of(work, struct ata_port, scsi_rescan_task);
3092 unsigned long flags; 3094 unsigned long flags;
3093 unsigned int i; 3095 unsigned int i;
3094 3096
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 107b2b565229..81ae41d5f23f 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -94,7 +94,7 @@ extern struct scsi_transport_template ata_scsi_transport_template;
94 94
95extern void ata_scsi_scan_host(struct ata_port *ap); 95extern void ata_scsi_scan_host(struct ata_port *ap);
96extern int ata_scsi_offline_dev(struct ata_device *dev); 96extern int ata_scsi_offline_dev(struct ata_device *dev);
97extern void ata_scsi_hotplug(void *data); 97extern void ata_scsi_hotplug(struct work_struct *work);
98extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 98extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
99 unsigned int buflen); 99 unsigned int buflen);
100 100
@@ -124,7 +124,7 @@ extern void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
124 unsigned int (*actor) (struct ata_scsi_args *args, 124 unsigned int (*actor) (struct ata_scsi_args *args,
125 u8 *rbuf, unsigned int buflen)); 125 u8 *rbuf, unsigned int buflen));
126extern void ata_schedule_scsi_eh(struct Scsi_Host *shost); 126extern void ata_schedule_scsi_eh(struct Scsi_Host *shost);
127extern void ata_scsi_dev_rescan(void *data); 127extern void ata_scsi_dev_rescan(struct work_struct *work);
128extern int ata_bus_probe(struct ata_port *ap); 128extern int ata_bus_probe(struct ata_port *ap);
129 129
130/* libata-eh.c */ 130/* libata-eh.c */
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index 4ca6fa5dcb42..9ed7f58424a3 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -154,19 +154,12 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
154 tuple.TupleOffset = 0; 154 tuple.TupleOffset = 0;
155 tuple.TupleDataMax = 255; 155 tuple.TupleDataMax = 255;
156 tuple.Attributes = 0; 156 tuple.Attributes = 0;
157 tuple.DesiredTuple = CISTPL_CONFIG;
158
159 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(pdev, &tuple));
160 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(pdev, &tuple));
161 CS_CHECK(ParseTuple, pcmcia_parse_tuple(pdev, &tuple, &stk->parse));
162 pdev->conf.ConfigBase = stk->parse.config.base;
163 pdev->conf.Present = stk->parse.config.rmask[0];
164 157
165 /* See if we have a manufacturer identifier. Use it to set is_kme for 158 /* See if we have a manufacturer identifier. Use it to set is_kme for
166 vendor quirks */ 159 vendor quirks */
167 tuple.DesiredTuple = CISTPL_MANFID; 160 is_kme = ((pdev->manf_id == MANFID_KME) &&
168 if (!pcmcia_get_first_tuple(pdev, &tuple) && !pcmcia_get_tuple_data(pdev, &tuple) && !pcmcia_parse_tuple(pdev, &tuple, &stk->parse)) 161 ((pdev->card_id == PRODID_KME_KXLC005_A) ||
169 is_kme = ((stk->parse.manfid.manf == MANFID_KME) && ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) || (stk->parse.manfid.card == PRODID_KME_KXLC005_B))); 162 (pdev->card_id == PRODID_KME_KXLC005_B)));
170 163
171 /* Not sure if this is right... look up the current Vcc */ 164 /* Not sure if this is right... look up the current Vcc */
172 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf)); 165 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(pdev, &stk->conf));
@@ -356,8 +349,10 @@ static struct pcmcia_device_id pcmcia_devices[] = {
356 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6), 349 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6),
357 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 350 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
358 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 351 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
352 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
359 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 353 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
360 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 354 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
355 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
361 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 356 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
362 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 357 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
363 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), 358 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6),
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index 87b17c33b3f9..f40786121948 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -135,7 +135,7 @@ static int idt77252_change_qos(struct atm_vcc *vcc, struct atm_qos *qos,
135 int flags); 135 int flags);
136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos, 136static int idt77252_proc_read(struct atm_dev *dev, loff_t * pos,
137 char *page); 137 char *page);
138static void idt77252_softint(void *dev_id); 138static void idt77252_softint(struct work_struct *work);
139 139
140 140
141static struct atmdev_ops idt77252_ops = 141static struct atmdev_ops idt77252_ops =
@@ -2866,9 +2866,10 @@ out:
2866} 2866}
2867 2867
2868static void 2868static void
2869idt77252_softint(void *dev_id) 2869idt77252_softint(struct work_struct *work)
2870{ 2870{
2871 struct idt77252_dev *card = dev_id; 2871 struct idt77252_dev *card =
2872 container_of(work, struct idt77252_dev, tqueue);
2872 u32 stat; 2873 u32 stat;
2873 int done; 2874 int done;
2874 2875
@@ -3697,7 +3698,7 @@ idt77252_init_one(struct pci_dev *pcidev, const struct pci_device_id *id)
3697 card->pcidev = pcidev; 3698 card->pcidev = pcidev;
3698 sprintf(card->name, "idt77252-%d", card->index); 3699 sprintf(card->name, "idt77252-%d", card->index);
3699 3700
3700 INIT_WORK(&card->tqueue, idt77252_softint, (void *)card); 3701 INIT_WORK(&card->tqueue, idt77252_softint);
3701 3702
3702 membase = pci_resource_start(pcidev, 1); 3703 membase = pci_resource_start(pcidev, 1);
3703 srambase = pci_resource_start(pcidev, 2); 3704 srambase = pci_resource_start(pcidev, 2);
diff --git a/drivers/block/aoe/aoe.h b/drivers/block/aoe/aoe.h
index 6d111228cfac..2308e83e5f33 100644
--- a/drivers/block/aoe/aoe.h
+++ b/drivers/block/aoe/aoe.h
@@ -159,7 +159,7 @@ void aoecmd_work(struct aoedev *d);
159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); 159void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor);
160void aoecmd_ata_rsp(struct sk_buff *); 160void aoecmd_ata_rsp(struct sk_buff *);
161void aoecmd_cfg_rsp(struct sk_buff *); 161void aoecmd_cfg_rsp(struct sk_buff *);
162void aoecmd_sleepwork(void *vp); 162void aoecmd_sleepwork(struct work_struct *);
163struct sk_buff *new_skb(ulong); 163struct sk_buff *new_skb(ulong);
164 164
165int aoedev_init(void); 165int aoedev_init(void);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 8a13b1af8bab..97f7f535f412 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -408,9 +408,9 @@ rexmit_timer(ulong vp)
408/* this function performs work that has been deferred until sleeping is OK 408/* this function performs work that has been deferred until sleeping is OK
409 */ 409 */
410void 410void
411aoecmd_sleepwork(void *vp) 411aoecmd_sleepwork(struct work_struct *work)
412{ 412{
413 struct aoedev *d = (struct aoedev *) vp; 413 struct aoedev *d = container_of(work, struct aoedev, work);
414 414
415 if (d->flags & DEVFL_GDALLOC) 415 if (d->flags & DEVFL_GDALLOC)
416 aoeblk_gdalloc(d); 416 aoeblk_gdalloc(d);
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index 6125921bbec4..05a97197c918 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -88,7 +88,7 @@ aoedev_newdev(ulong nframes)
88 kfree(d); 88 kfree(d);
89 return NULL; 89 return NULL;
90 } 90 }
91 INIT_WORK(&d->work, aoecmd_sleepwork, d); 91 INIT_WORK(&d->work, aoecmd_sleepwork);
92 spin_lock_init(&d->lock); 92 spin_lock_init(&d->lock);
93 init_timer(&d->timer); 93 init_timer(&d->timer);
94 d->timer.data = (ulong) d; 94 d->timer.data = (ulong) d;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 9e6d3a87cbe3..3f1b38276e96 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -992,11 +992,11 @@ static void empty(void)
992{ 992{
993} 993}
994 994
995static DECLARE_WORK(floppy_work, NULL, NULL); 995static DECLARE_WORK(floppy_work, NULL);
996 996
997static void schedule_bh(void (*handler) (void)) 997static void schedule_bh(void (*handler) (void))
998{ 998{
999 PREPARE_WORK(&floppy_work, (void (*)(void *))handler, NULL); 999 PREPARE_WORK(&floppy_work, (work_func_t)handler);
1000 schedule_work(&floppy_work); 1000 schedule_work(&floppy_work);
1001} 1001}
1002 1002
@@ -1008,7 +1008,7 @@ static void cancel_activity(void)
1008 1008
1009 spin_lock_irqsave(&floppy_lock, flags); 1009 spin_lock_irqsave(&floppy_lock, flags);
1010 do_floppy = NULL; 1010 do_floppy = NULL;
1011 PREPARE_WORK(&floppy_work, (void *)empty, NULL); 1011 PREPARE_WORK(&floppy_work, (work_func_t)empty);
1012 del_timer(&fd_timer); 1012 del_timer(&fd_timer);
1013 spin_unlock_irqrestore(&floppy_lock, flags); 1013 spin_unlock_irqrestore(&floppy_lock, flags);
1014} 1014}
@@ -1868,7 +1868,7 @@ static void show_floppy(void)
1868 printk("fdc_busy=%lu\n", fdc_busy); 1868 printk("fdc_busy=%lu\n", fdc_busy);
1869 if (do_floppy) 1869 if (do_floppy)
1870 printk("do_floppy=%p\n", do_floppy); 1870 printk("do_floppy=%p\n", do_floppy);
1871 if (floppy_work.pending) 1871 if (work_pending(&floppy_work))
1872 printk("floppy_work.func=%p\n", floppy_work.func); 1872 printk("floppy_work.func=%p\n", floppy_work.func);
1873 if (timer_pending(&fd_timer)) 1873 if (timer_pending(&fd_timer))
1874 printk("fd_timer.function=%p\n", fd_timer.function); 1874 printk("fd_timer.function=%p\n", fd_timer.function);
@@ -4498,7 +4498,7 @@ static void floppy_release_irq_and_dma(void)
4498 printk("floppy timer still active:%s\n", timeout_message); 4498 printk("floppy timer still active:%s\n", timeout_message);
4499 if (timer_pending(&fd_timer)) 4499 if (timer_pending(&fd_timer))
4500 printk("auxiliary floppy timer still active\n"); 4500 printk("auxiliary floppy timer still active\n");
4501 if (floppy_work.pending) 4501 if (work_pending(&floppy_work))
4502 printk("work still pending\n"); 4502 printk("work still pending\n");
4503#endif 4503#endif
4504 old_fdc = fdc; 4504 old_fdc = fdc;
diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c
index 40a11e567970..9d9bff23f426 100644
--- a/drivers/block/paride/pd.c
+++ b/drivers/block/paride/pd.c
@@ -352,19 +352,19 @@ static enum action (*phase)(void);
352 352
353static void run_fsm(void); 353static void run_fsm(void);
354 354
355static void ps_tq_int( void *data); 355static void ps_tq_int(struct work_struct *work);
356 356
357static DECLARE_WORK(fsm_tq, ps_tq_int, NULL); 357static DECLARE_DELAYED_WORK(fsm_tq, ps_tq_int);
358 358
359static void schedule_fsm(void) 359static void schedule_fsm(void)
360{ 360{
361 if (!nice) 361 if (!nice)
362 schedule_work(&fsm_tq); 362 schedule_delayed_work(&fsm_tq, 0);
363 else 363 else
364 schedule_delayed_work(&fsm_tq, nice-1); 364 schedule_delayed_work(&fsm_tq, nice-1);
365} 365}
366 366
367static void ps_tq_int(void *data) 367static void ps_tq_int(struct work_struct *work)
368{ 368{
369 run_fsm(); 369 run_fsm();
370} 370}
diff --git a/drivers/block/paride/pseudo.h b/drivers/block/paride/pseudo.h
index 932342d7a8eb..bc3703294143 100644
--- a/drivers/block/paride/pseudo.h
+++ b/drivers/block/paride/pseudo.h
@@ -35,7 +35,7 @@
35#include <linux/sched.h> 35#include <linux/sched.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37 37
38static void ps_tq_int( void *data); 38static void ps_tq_int(struct work_struct *work);
39 39
40static void (* ps_continuation)(void); 40static void (* ps_continuation)(void);
41static int (* ps_ready)(void); 41static int (* ps_ready)(void);
@@ -45,7 +45,7 @@ static int ps_nice = 0;
45 45
46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused))); 46static DEFINE_SPINLOCK(ps_spinlock __attribute__((unused)));
47 47
48static DECLARE_WORK(ps_tq, ps_tq_int, NULL); 48static DECLARE_DELAYED_WORK(ps_tq, ps_tq_int);
49 49
50static void ps_set_intr(void (*continuation)(void), 50static void ps_set_intr(void (*continuation)(void),
51 int (*ready)(void), 51 int (*ready)(void),
@@ -63,14 +63,14 @@ static void ps_set_intr(void (*continuation)(void),
63 if (!ps_tq_active) { 63 if (!ps_tq_active) {
64 ps_tq_active = 1; 64 ps_tq_active = 1;
65 if (!ps_nice) 65 if (!ps_nice)
66 schedule_work(&ps_tq); 66 schedule_delayed_work(&ps_tq, 0);
67 else 67 else
68 schedule_delayed_work(&ps_tq, ps_nice-1); 68 schedule_delayed_work(&ps_tq, ps_nice-1);
69 } 69 }
70 spin_unlock_irqrestore(&ps_spinlock,flags); 70 spin_unlock_irqrestore(&ps_spinlock,flags);
71} 71}
72 72
73static void ps_tq_int(void *data) 73static void ps_tq_int(struct work_struct *work)
74{ 74{
75 void (*con)(void); 75 void (*con)(void);
76 unsigned long flags; 76 unsigned long flags;
@@ -92,7 +92,7 @@ static void ps_tq_int(void *data)
92 } 92 }
93 ps_tq_active = 1; 93 ps_tq_active = 1;
94 if (!ps_nice) 94 if (!ps_nice)
95 schedule_work(&ps_tq); 95 schedule_delayed_work(&ps_tq, 0);
96 else 96 else
97 schedule_delayed_work(&ps_tq, ps_nice-1); 97 schedule_delayed_work(&ps_tq, ps_nice-1);
98 spin_unlock_irqrestore(&ps_spinlock,flags); 98 spin_unlock_irqrestore(&ps_spinlock,flags);
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 47d6975268ff..54509eb3391b 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1244,9 +1244,10 @@ out:
1244 return IRQ_RETVAL(handled); 1244 return IRQ_RETVAL(handled);
1245} 1245}
1246 1246
1247static void carm_fsm_task (void *_data) 1247static void carm_fsm_task (struct work_struct *work)
1248{ 1248{
1249 struct carm_host *host = _data; 1249 struct carm_host *host =
1250 container_of(work, struct carm_host, fsm_task);
1250 unsigned long flags; 1251 unsigned long flags;
1251 unsigned int state; 1252 unsigned int state;
1252 int rc, i, next_dev; 1253 int rc, i, next_dev;
@@ -1619,7 +1620,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1619 host->pdev = pdev; 1620 host->pdev = pdev;
1620 host->flags = pci_dac ? FL_DAC : 0; 1621 host->flags = pci_dac ? FL_DAC : 0;
1621 spin_lock_init(&host->lock); 1622 spin_lock_init(&host->lock);
1622 INIT_WORK(&host->fsm_task, carm_fsm_task, host); 1623 INIT_WORK(&host->fsm_task, carm_fsm_task);
1623 init_completion(&host->probe_comp); 1624 init_completion(&host->probe_comp);
1624 1625
1625 for (i = 0; i < ARRAY_SIZE(host->req); i++) 1626 for (i = 0; i < ARRAY_SIZE(host->req); i++)
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 0d5c73f07265..2098eff91e14 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -376,7 +376,7 @@ static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
376 int stalled_pipe); 376 int stalled_pipe);
377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 377static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
378static void ub_reset_enter(struct ub_dev *sc, int try); 378static void ub_reset_enter(struct ub_dev *sc, int try);
379static void ub_reset_task(void *arg); 379static void ub_reset_task(struct work_struct *work);
380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); 380static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, 381static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
382 struct ub_capacity *ret); 382 struct ub_capacity *ret);
@@ -1558,9 +1558,9 @@ static void ub_reset_enter(struct ub_dev *sc, int try)
1558 schedule_work(&sc->reset_work); 1558 schedule_work(&sc->reset_work);
1559} 1559}
1560 1560
1561static void ub_reset_task(void *arg) 1561static void ub_reset_task(struct work_struct *work)
1562{ 1562{
1563 struct ub_dev *sc = arg; 1563 struct ub_dev *sc = container_of(work, struct ub_dev, reset_work);
1564 unsigned long flags; 1564 unsigned long flags;
1565 struct list_head *p; 1565 struct list_head *p;
1566 struct ub_lun *lun; 1566 struct ub_lun *lun;
@@ -2179,7 +2179,7 @@ static int ub_probe(struct usb_interface *intf,
2179 usb_init_urb(&sc->work_urb); 2179 usb_init_urb(&sc->work_urb);
2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); 2180 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc);
2181 atomic_set(&sc->poison, 0); 2181 atomic_set(&sc->poison, 0);
2182 INIT_WORK(&sc->reset_work, ub_reset_task, sc); 2182 INIT_WORK(&sc->reset_work, ub_reset_task);
2183 init_waitqueue_head(&sc->reset_wait); 2183 init_waitqueue_head(&sc->reset_wait);
2184 2184
2185 init_timer(&sc->work_timer); 2185 init_timer(&sc->work_timer);
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index ec5a1b90a0a2..e19ba4ebcd4e 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -759,6 +759,8 @@ static struct vio_driver viodasd_driver = {
759 } 759 }
760}; 760};
761 761
762static int need_delete_probe;
763
762/* 764/*
763 * Initialize the whole device driver. Handle module and non-module 765 * Initialize the whole device driver. Handle module and non-module
764 * versions 766 * versions
@@ -773,46 +775,67 @@ static int __init viodasd_init(void)
773 775
774 if (viopath_hostLp == HvLpIndexInvalid) { 776 if (viopath_hostLp == HvLpIndexInvalid) {
775 printk(VIOD_KERN_WARNING "invalid hosting partition\n"); 777 printk(VIOD_KERN_WARNING "invalid hosting partition\n");
776 return -EIO; 778 rc = -EIO;
779 goto early_fail;
777 } 780 }
778 781
779 printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n", 782 printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n",
780 viopath_hostLp); 783 viopath_hostLp);
781 784
782 /* register the block device */ 785 /* register the block device */
783 if (register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME)) { 786 rc = register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
787 if (rc) {
784 printk(VIOD_KERN_WARNING 788 printk(VIOD_KERN_WARNING
785 "Unable to get major number %d for %s\n", 789 "Unable to get major number %d for %s\n",
786 VIODASD_MAJOR, VIOD_GENHD_NAME); 790 VIODASD_MAJOR, VIOD_GENHD_NAME);
787 return -EIO; 791 goto early_fail;
788 } 792 }
789 /* Actually open the path to the hosting partition */ 793 /* Actually open the path to the hosting partition */
790 if (viopath_open(viopath_hostLp, viomajorsubtype_blockio, 794 rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio,
791 VIOMAXREQ + 2)) { 795 VIOMAXREQ + 2);
796 if (rc) {
792 printk(VIOD_KERN_WARNING 797 printk(VIOD_KERN_WARNING
793 "error opening path to host partition %d\n", 798 "error opening path to host partition %d\n",
794 viopath_hostLp); 799 viopath_hostLp);
795 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); 800 goto unregister_blk;
796 return -EIO;
797 } 801 }
798 802
799 /* Initialize our request handler */ 803 /* Initialize our request handler */
800 vio_setHandler(viomajorsubtype_blockio, handle_block_event); 804 vio_setHandler(viomajorsubtype_blockio, handle_block_event);
801 805
802 rc = vio_register_driver(&viodasd_driver); 806 rc = vio_register_driver(&viodasd_driver);
803 if (rc == 0) 807 if (rc) {
804 driver_create_file(&viodasd_driver.driver, &driver_attr_probe); 808 printk(VIOD_KERN_WARNING "vio_register_driver failed\n");
809 goto unset_handler;
810 }
811
812 /*
813 * If this call fails, it just means that we cannot dynamically
814 * add virtual disks, but the driver will still work fine for
815 * all existing disk, so ignore the failure.
816 */
817 if (!driver_create_file(&viodasd_driver.driver, &driver_attr_probe))
818 need_delete_probe = 1;
819
820 return 0;
821
822unset_handler:
823 vio_clearHandler(viomajorsubtype_blockio);
824 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2);
825unregister_blk:
826 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
827early_fail:
805 return rc; 828 return rc;
806} 829}
807module_init(viodasd_init); 830module_init(viodasd_init);
808 831
809void viodasd_exit(void) 832void __exit viodasd_exit(void)
810{ 833{
811 driver_remove_file(&viodasd_driver.driver, &driver_attr_probe); 834 if (need_delete_probe)
835 driver_remove_file(&viodasd_driver.driver, &driver_attr_probe);
812 vio_unregister_driver(&viodasd_driver); 836 vio_unregister_driver(&viodasd_driver);
813 vio_clearHandler(viomajorsubtype_blockio); 837 vio_clearHandler(viomajorsubtype_blockio);
814 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
815 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2); 838 viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2);
839 unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
816} 840}
817
818module_exit(viodasd_exit); 841module_exit(viodasd_exit);
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 516751754aa9..9256985cbe36 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -157,9 +157,10 @@ static void bcm203x_complete(struct urb *urb)
157 } 157 }
158} 158}
159 159
160static void bcm203x_work(void *user_data) 160static void bcm203x_work(struct work_struct *work)
161{ 161{
162 struct bcm203x_data *data = user_data; 162 struct bcm203x_data *data =
163 container_of(work, struct bcm203x_data, work);
163 164
164 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0) 165 if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
165 BT_ERR("Can't submit URB"); 166 BT_ERR("Can't submit URB");
@@ -246,7 +247,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
246 247
247 release_firmware(firmware); 248 release_firmware(firmware);
248 249
249 INIT_WORK(&data->work, bcm203x_work, (void *) data); 250 INIT_WORK(&data->work, bcm203x_work);
250 251
251 usb_set_intfdata(intf, data); 252 usb_set_intfdata(intf, data);
252 253
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index cbc07250b898..acfb6a430dcc 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -892,43 +892,10 @@ static void bluecard_detach(struct pcmcia_device *link)
892} 892}
893 893
894 894
895static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse)
896{
897 int i;
898
899 i = pcmcia_get_first_tuple(handle, tuple);
900 if (i != CS_SUCCESS)
901 return CS_NO_MORE_ITEMS;
902
903 i = pcmcia_get_tuple_data(handle, tuple);
904 if (i != CS_SUCCESS)
905 return i;
906
907 return pcmcia_parse_tuple(handle, tuple, parse);
908}
909
910static int bluecard_config(struct pcmcia_device *link) 895static int bluecard_config(struct pcmcia_device *link)
911{ 896{
912 bluecard_info_t *info = link->priv; 897 bluecard_info_t *info = link->priv;
913 tuple_t tuple; 898 int i, n;
914 u_short buf[256];
915 cisparse_t parse;
916 int i, n, last_ret, last_fn;
917
918 tuple.TupleData = (cisdata_t *)buf;
919 tuple.TupleOffset = 0;
920 tuple.TupleDataMax = 255;
921 tuple.Attributes = 0;
922
923 /* Get configuration register information */
924 tuple.DesiredTuple = CISTPL_CONFIG;
925 last_ret = first_tuple(link, &tuple, &parse);
926 if (last_ret != CS_SUCCESS) {
927 last_fn = ParseTuple;
928 goto cs_failed;
929 }
930 link->conf.ConfigBase = parse.config.base;
931 link->conf.Present = parse.config.rmask[0];
932 899
933 link->conf.ConfigIndex = 0x20; 900 link->conf.ConfigIndex = 0x20;
934 link->io.NumPorts1 = 64; 901 link->io.NumPorts1 = 64;
@@ -966,9 +933,6 @@ static int bluecard_config(struct pcmcia_device *link)
966 933
967 return 0; 934 return 0;
968 935
969cs_failed:
970 cs_error(link, last_fn, last_ret);
971
972failed: 936failed:
973 bluecard_release(link); 937 bluecard_release(link);
974 return -ENODEV; 938 return -ENODEV;
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 3a96a0babc6a..aae3abace586 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -713,22 +713,7 @@ static int bt3c_config(struct pcmcia_device *link)
713 u_short buf[256]; 713 u_short buf[256];
714 cisparse_t parse; 714 cisparse_t parse;
715 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 715 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
716 int i, j, try, last_ret, last_fn; 716 int i, j, try;
717
718 tuple.TupleData = (cisdata_t *)buf;
719 tuple.TupleOffset = 0;
720 tuple.TupleDataMax = 255;
721 tuple.Attributes = 0;
722
723 /* Get configuration register information */
724 tuple.DesiredTuple = CISTPL_CONFIG;
725 last_ret = first_tuple(link, &tuple, &parse);
726 if (last_ret != CS_SUCCESS) {
727 last_fn = ParseTuple;
728 goto cs_failed;
729 }
730 link->conf.ConfigBase = parse.config.base;
731 link->conf.Present = parse.config.rmask[0];
732 717
733 /* First pass: look for a config entry that looks normal. */ 718 /* First pass: look for a config entry that looks normal. */
734 tuple.TupleData = (cisdata_t *)buf; 719 tuple.TupleData = (cisdata_t *)buf;
@@ -802,9 +787,6 @@ found_port:
802 787
803 return 0; 788 return 0;
804 789
805cs_failed:
806 cs_error(link, last_fn, last_ret);
807
808failed: 790failed:
809 bt3c_release(link); 791 bt3c_release(link);
810 return -ENODEV; 792 return -ENODEV;
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 3b29086b7c3f..92648ef2f5d0 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -644,22 +644,7 @@ static int btuart_config(struct pcmcia_device *link)
644 u_short buf[256]; 644 u_short buf[256];
645 cisparse_t parse; 645 cisparse_t parse;
646 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 646 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
647 int i, j, try, last_ret, last_fn; 647 int i, j, try;
648
649 tuple.TupleData = (cisdata_t *)buf;
650 tuple.TupleOffset = 0;
651 tuple.TupleDataMax = 255;
652 tuple.Attributes = 0;
653
654 /* Get configuration register information */
655 tuple.DesiredTuple = CISTPL_CONFIG;
656 last_ret = first_tuple(link, &tuple, &parse);
657 if (last_ret != CS_SUCCESS) {
658 last_fn = ParseTuple;
659 goto cs_failed;
660 }
661 link->conf.ConfigBase = parse.config.base;
662 link->conf.Present = parse.config.rmask[0];
663 648
664 /* First pass: look for a config entry that looks normal. */ 649 /* First pass: look for a config entry that looks normal. */
665 tuple.TupleData = (cisdata_t *) buf; 650 tuple.TupleData = (cisdata_t *) buf;
@@ -734,9 +719,6 @@ found_port:
734 719
735 return 0; 720 return 0;
736 721
737cs_failed:
738 cs_error(link, last_fn, last_ret);
739
740failed: 722failed:
741 btuart_release(link); 723 btuart_release(link);
742 return -ENODEV; 724 return -ENODEV;
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 07eafbc5dc3a..77b99eecbc49 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -626,22 +626,7 @@ static int dtl1_config(struct pcmcia_device *link)
626 u_short buf[256]; 626 u_short buf[256];
627 cisparse_t parse; 627 cisparse_t parse;
628 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 628 cistpl_cftable_entry_t *cf = &parse.cftable_entry;
629 int i, last_ret, last_fn; 629 int i;
630
631 tuple.TupleData = (cisdata_t *)buf;
632 tuple.TupleOffset = 0;
633 tuple.TupleDataMax = 255;
634 tuple.Attributes = 0;
635
636 /* Get configuration register information */
637 tuple.DesiredTuple = CISTPL_CONFIG;
638 last_ret = first_tuple(link, &tuple, &parse);
639 if (last_ret != CS_SUCCESS) {
640 last_fn = ParseTuple;
641 goto cs_failed;
642 }
643 link->conf.ConfigBase = parse.config.base;
644 link->conf.Present = parse.config.rmask[0];
645 630
646 tuple.TupleData = (cisdata_t *)buf; 631 tuple.TupleData = (cisdata_t *)buf;
647 tuple.TupleOffset = 0; 632 tuple.TupleOffset = 0;
@@ -690,9 +675,6 @@ static int dtl1_config(struct pcmcia_device *link)
690 675
691 return 0; 676 return 0;
692 677
693cs_failed:
694 cs_error(link, last_fn, last_ret);
695
696failed: 678failed:
697 dtl1_release(link); 679 dtl1_release(link);
698 return -ENODEV; 680 return -ENODEV;
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index e608dadece2f..acb2de5e3a98 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -926,9 +926,10 @@ cy_sched_event(struct cyclades_port *info, int event)
926 * had to poll every port to see if that port needed servicing. 926 * had to poll every port to see if that port needed servicing.
927 */ 927 */
928static void 928static void
929do_softint(void *private_) 929do_softint(struct work_struct *work)
930{ 930{
931 struct cyclades_port *info = (struct cyclades_port *) private_; 931 struct cyclades_port *info =
932 container_of(work, struct cyclades_port, tqueue);
932 struct tty_struct *tty; 933 struct tty_struct *tty;
933 934
934 tty = info->tty; 935 tty = info->tty;
@@ -5328,7 +5329,7 @@ cy_init(void)
5328 info->blocked_open = 0; 5329 info->blocked_open = 0;
5329 info->default_threshold = 0; 5330 info->default_threshold = 0;
5330 info->default_timeout = 0; 5331 info->default_timeout = 0;
5331 INIT_WORK(&info->tqueue, do_softint, info); 5332 INIT_WORK(&info->tqueue, do_softint);
5332 init_waitqueue_head(&info->open_wait); 5333 init_waitqueue_head(&info->open_wait);
5333 init_waitqueue_head(&info->close_wait); 5334 init_waitqueue_head(&info->close_wait);
5334 init_waitqueue_head(&info->shutdown_wait); 5335 init_waitqueue_head(&info->shutdown_wait);
@@ -5403,7 +5404,7 @@ cy_init(void)
5403 info->blocked_open = 0; 5404 info->blocked_open = 0;
5404 info->default_threshold = 0; 5405 info->default_threshold = 0;
5405 info->default_timeout = 0; 5406 info->default_timeout = 0;
5406 INIT_WORK(&info->tqueue, do_softint, info); 5407 INIT_WORK(&info->tqueue, do_softint);
5407 init_waitqueue_head(&info->open_wait); 5408 init_waitqueue_head(&info->open_wait);
5408 init_waitqueue_head(&info->close_wait); 5409 init_waitqueue_head(&info->close_wait);
5409 init_waitqueue_head(&info->shutdown_wait); 5410 init_waitqueue_head(&info->shutdown_wait);
diff --git a/drivers/char/drm/via_dmablit.c b/drivers/char/drm/via_dmablit.c
index 60c1695db300..806f9ce5f47b 100644
--- a/drivers/char/drm/via_dmablit.c
+++ b/drivers/char/drm/via_dmablit.c
@@ -500,9 +500,9 @@ via_dmablit_timer(unsigned long data)
500 500
501 501
502static void 502static void
503via_dmablit_workqueue(void *data) 503via_dmablit_workqueue(struct work_struct *work)
504{ 504{
505 drm_via_blitq_t *blitq = (drm_via_blitq_t *) data; 505 drm_via_blitq_t *blitq = container_of(work, drm_via_blitq_t, wq);
506 drm_device_t *dev = blitq->dev; 506 drm_device_t *dev = blitq->dev;
507 unsigned long irqsave; 507 unsigned long irqsave;
508 drm_via_sg_info_t *cur_sg; 508 drm_via_sg_info_t *cur_sg;
@@ -571,7 +571,7 @@ via_init_dmablit(drm_device_t *dev)
571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j); 571 DRM_INIT_WAITQUEUE(blitq->blit_queue + j);
572 } 572 }
573 DRM_INIT_WAITQUEUE(&blitq->busy_queue); 573 DRM_INIT_WAITQUEUE(&blitq->busy_queue);
574 INIT_WORK(&blitq->wq, via_dmablit_workqueue, blitq); 574 INIT_WORK(&blitq->wq, via_dmablit_workqueue);
575 init_timer(&blitq->poll_timer); 575 init_timer(&blitq->poll_timer);
576 blitq->poll_timer.function = &via_dmablit_timer; 576 blitq->poll_timer.function = &via_dmablit_timer;
577 blitq->poll_timer.data = (unsigned long) blitq; 577 blitq->poll_timer.data = (unsigned long) blitq;
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index 706733c0b36a..7c71eb779802 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -200,7 +200,7 @@ static int pc_ioctl(struct tty_struct *, struct file *,
200static int info_ioctl(struct tty_struct *, struct file *, 200static int info_ioctl(struct tty_struct *, struct file *,
201 unsigned int, unsigned long); 201 unsigned int, unsigned long);
202static void pc_set_termios(struct tty_struct *, struct termios *); 202static void pc_set_termios(struct tty_struct *, struct termios *);
203static void do_softint(void *); 203static void do_softint(struct work_struct *work);
204static void pc_stop(struct tty_struct *); 204static void pc_stop(struct tty_struct *);
205static void pc_start(struct tty_struct *); 205static void pc_start(struct tty_struct *);
206static void pc_throttle(struct tty_struct * tty); 206static void pc_throttle(struct tty_struct * tty);
@@ -1505,7 +1505,7 @@ static void post_fep_init(unsigned int crd)
1505 1505
1506 ch->brdchan = bc; 1506 ch->brdchan = bc;
1507 ch->mailbox = gd; 1507 ch->mailbox = gd;
1508 INIT_WORK(&ch->tqueue, do_softint, ch); 1508 INIT_WORK(&ch->tqueue, do_softint);
1509 ch->board = &boards[crd]; 1509 ch->board = &boards[crd];
1510 1510
1511 spin_lock_irqsave(&epca_lock, flags); 1511 spin_lock_irqsave(&epca_lock, flags);
@@ -2566,9 +2566,9 @@ static void pc_set_termios(struct tty_struct *tty, struct termios *old_termios)
2566 2566
2567/* --------------------- Begin do_softint ----------------------- */ 2567/* --------------------- Begin do_softint ----------------------- */
2568 2568
2569static void do_softint(void *private_) 2569static void do_softint(struct work_struct *work)
2570{ /* Begin do_softint */ 2570{ /* Begin do_softint */
2571 struct channel *ch = (struct channel *) private_; 2571 struct channel *ch = container_of(work, struct channel, tqueue);
2572 /* Called in response to a modem change event */ 2572 /* Called in response to a modem change event */
2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */ 2573 if (ch && ch->magic == EPCA_MAGIC) { /* Begin EPCA_MAGIC */
2574 struct tty_struct *tty = ch->tty; 2574 struct tty_struct *tty = ch->tty;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index 15a4ea896328..93b551962513 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -723,9 +723,10 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
723 * ------------------------------------------------------------------- 723 * -------------------------------------------------------------------
724 */ 724 */
725 725
726static void do_softint(void *private_) 726static void do_softint(struct work_struct *work)
727{ 727{
728 struct esp_struct *info = (struct esp_struct *) private_; 728 struct esp_struct *info =
729 container_of(work, struct esp_struct, tqueue);
729 struct tty_struct *tty; 730 struct tty_struct *tty;
730 731
731 tty = info->tty; 732 tty = info->tty;
@@ -746,9 +747,10 @@ static void do_softint(void *private_)
746 * do_serial_hangup() -> tty->hangup() -> esp_hangup() 747 * do_serial_hangup() -> tty->hangup() -> esp_hangup()
747 * 748 *
748 */ 749 */
749static void do_serial_hangup(void *private_) 750static void do_serial_hangup(struct work_struct *work)
750{ 751{
751 struct esp_struct *info = (struct esp_struct *) private_; 752 struct esp_struct *info =
753 container_of(work, struct esp_struct, tqueue_hangup);
752 struct tty_struct *tty; 754 struct tty_struct *tty;
753 755
754 tty = info->tty; 756 tty = info->tty;
@@ -2501,8 +2503,8 @@ static int __init espserial_init(void)
2501 info->magic = ESP_MAGIC; 2503 info->magic = ESP_MAGIC;
2502 info->close_delay = 5*HZ/10; 2504 info->close_delay = 5*HZ/10;
2503 info->closing_wait = 30*HZ; 2505 info->closing_wait = 30*HZ;
2504 INIT_WORK(&info->tqueue, do_softint, info); 2506 INIT_WORK(&info->tqueue, do_softint);
2505 INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info); 2507 INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
2506 info->config.rx_timeout = rx_timeout; 2508 info->config.rx_timeout = rx_timeout;
2507 info->config.flow_on = flow_on; 2509 info->config.flow_on = flow_on;
2508 info->config.flow_off = flow_off; 2510 info->config.flow_off = flow_off;
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
index 817dc409ac20..23b25ada65ea 100644
--- a/drivers/char/genrtc.c
+++ b/drivers/char/genrtc.c
@@ -102,7 +102,7 @@ static void gen_rtc_interrupt(unsigned long arg);
102 * Routine to poll RTC seconds field for change as often as possible, 102 * Routine to poll RTC seconds field for change as often as possible,
103 * after first RTC_UIE use timer to reduce polling 103 * after first RTC_UIE use timer to reduce polling
104 */ 104 */
105static void genrtc_troutine(void *data) 105static void genrtc_troutine(struct work_struct *work)
106{ 106{
107 unsigned int tmp = get_rtc_ss(); 107 unsigned int tmp = get_rtc_ss();
108 108
@@ -255,7 +255,7 @@ static inline int gen_set_rtc_irq_bit(unsigned char bit)
255 irq_active = 1; 255 irq_active = 1;
256 stop_rtc_timers = 0; 256 stop_rtc_timers = 0;
257 lostint = 0; 257 lostint = 0;
258 INIT_WORK(&genrtc_task, genrtc_troutine, NULL); 258 INIT_WORK(&genrtc_task, genrtc_troutine);
259 oldsecs = get_rtc_ss(); 259 oldsecs = get_rtc_ss();
260 init_timer(&timer_task); 260 init_timer(&timer_task);
261 261
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 2cf63e7305a3..82a41d5b4ed0 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -69,7 +69,7 @@
69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long)))) 69#define __ALIGNED__ __attribute__((__aligned__(sizeof(long))))
70 70
71struct hvsi_struct { 71struct hvsi_struct {
72 struct work_struct writer; 72 struct delayed_work writer;
73 struct work_struct handshaker; 73 struct work_struct handshaker;
74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */ 74 wait_queue_head_t emptyq; /* woken when outbuf is emptied */
75 wait_queue_head_t stateq; /* woken when HVSI state changes */ 75 wait_queue_head_t stateq; /* woken when HVSI state changes */
@@ -744,9 +744,10 @@ static int hvsi_handshake(struct hvsi_struct *hp)
744 return 0; 744 return 0;
745} 745}
746 746
747static void hvsi_handshaker(void *arg) 747static void hvsi_handshaker(struct work_struct *work)
748{ 748{
749 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 749 struct hvsi_struct *hp =
750 container_of(work, struct hvsi_struct, handshaker);
750 751
751 if (hvsi_handshake(hp) >= 0) 752 if (hvsi_handshake(hp) >= 0)
752 return; 753 return;
@@ -951,9 +952,10 @@ static void hvsi_push(struct hvsi_struct *hp)
951} 952}
952 953
953/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */ 954/* hvsi_write_worker will keep rescheduling itself until outbuf is empty */
954static void hvsi_write_worker(void *arg) 955static void hvsi_write_worker(struct work_struct *work)
955{ 956{
956 struct hvsi_struct *hp = (struct hvsi_struct *)arg; 957 struct hvsi_struct *hp =
958 container_of(work, struct hvsi_struct, writer.work);
957 unsigned long flags; 959 unsigned long flags;
958#ifdef DEBUG 960#ifdef DEBUG
959 static long start_j = 0; 961 static long start_j = 0;
@@ -1287,8 +1289,8 @@ static int __init hvsi_console_init(void)
1287 } 1289 }
1288 1290
1289 hp = &hvsi_ports[hvsi_count]; 1291 hp = &hvsi_ports[hvsi_count];
1290 INIT_WORK(&hp->writer, hvsi_write_worker, hp); 1292 INIT_DELAYED_WORK(&hp->writer, hvsi_write_worker);
1291 INIT_WORK(&hp->handshaker, hvsi_handshaker, hp); 1293 INIT_WORK(&hp->handshaker, hvsi_handshaker);
1292 init_waitqueue_head(&hp->emptyq); 1294 init_waitqueue_head(&hp->emptyq);
1293 init_waitqueue_head(&hp->stateq); 1295 init_waitqueue_head(&hp->stateq);
1294 spin_lock_init(&hp->lock); 1296 spin_lock_init(&hp->lock);
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 54d93f0345e8..c213fdbdb2b0 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -84,8 +84,8 @@ static void iiSendPendingMail(i2eBordStrPtr);
84static void serviceOutgoingFifo(i2eBordStrPtr); 84static void serviceOutgoingFifo(i2eBordStrPtr);
85 85
86// Functions defined in ip2.c as part of interrupt handling 86// Functions defined in ip2.c as part of interrupt handling
87static void do_input(void *); 87static void do_input(struct work_struct *);
88static void do_status(void *); 88static void do_status(struct work_struct *);
89 89
90//*************** 90//***************
91//* Debug Data * 91//* Debug Data *
@@ -331,8 +331,8 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
331 pCh->ClosingWaitTime = 30*HZ; 331 pCh->ClosingWaitTime = 30*HZ;
332 332
333 // Initialize task queue objects 333 // Initialize task queue objects
334 INIT_WORK(&pCh->tqueue_input, do_input, pCh); 334 INIT_WORK(&pCh->tqueue_input, do_input);
335 INIT_WORK(&pCh->tqueue_status, do_status, pCh); 335 INIT_WORK(&pCh->tqueue_status, do_status);
336 336
337#ifdef IP2DEBUG_TRACE 337#ifdef IP2DEBUG_TRACE
338 pCh->trace = ip2trace; 338 pCh->trace = ip2trace;
@@ -1573,7 +1573,7 @@ i2StripFifo(i2eBordStrPtr pB)
1573#ifdef USE_IQ 1573#ifdef USE_IQ
1574 schedule_work(&pCh->tqueue_input); 1574 schedule_work(&pCh->tqueue_input);
1575#else 1575#else
1576 do_input(pCh); 1576 do_input(&pCh->tqueue_input);
1577#endif 1577#endif
1578 1578
1579 // Note we do not need to maintain any flow-control credits at this 1579 // Note we do not need to maintain any flow-control credits at this
@@ -1810,7 +1810,7 @@ i2StripFifo(i2eBordStrPtr pB)
1810#ifdef USE_IQ 1810#ifdef USE_IQ
1811 schedule_work(&pCh->tqueue_status); 1811 schedule_work(&pCh->tqueue_status);
1812#else 1812#else
1813 do_status(pCh); 1813 do_status(&pCh->tqueue_status);
1814#endif 1814#endif
1815 } 1815 }
1816 } 1816 }
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index a3f32d46d2f8..cda2459c1d60 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -189,12 +189,12 @@ static int ip2_tiocmset(struct tty_struct *tty, struct file *file,
189 unsigned int set, unsigned int clear); 189 unsigned int set, unsigned int clear);
190 190
191static void set_irq(int, int); 191static void set_irq(int, int);
192static void ip2_interrupt_bh(i2eBordStrPtr pB); 192static void ip2_interrupt_bh(struct work_struct *work);
193static irqreturn_t ip2_interrupt(int irq, void *dev_id); 193static irqreturn_t ip2_interrupt(int irq, void *dev_id);
194static void ip2_poll(unsigned long arg); 194static void ip2_poll(unsigned long arg);
195static inline void service_all_boards(void); 195static inline void service_all_boards(void);
196static void do_input(void *p); 196static void do_input(struct work_struct *);
197static void do_status(void *p); 197static void do_status(struct work_struct *);
198 198
199static void ip2_wait_until_sent(PTTY,int); 199static void ip2_wait_until_sent(PTTY,int);
200 200
@@ -918,7 +918,7 @@ ip2_init_board( int boardnum )
918 pCh++; 918 pCh++;
919 } 919 }
920ex_exit: 920ex_exit:
921 INIT_WORK(&pB->tqueue_interrupt, (void(*)(void*)) ip2_interrupt_bh, pB); 921 INIT_WORK(&pB->tqueue_interrupt, ip2_interrupt_bh);
922 return; 922 return;
923 923
924err_release_region: 924err_release_region:
@@ -1125,8 +1125,8 @@ service_all_boards(void)
1125 1125
1126 1126
1127/******************************************************************************/ 1127/******************************************************************************/
1128/* Function: ip2_interrupt_bh(pB) */ 1128/* Function: ip2_interrupt_bh(work) */
1129/* Parameters: pB - pointer to the board structure */ 1129/* Parameters: work - pointer to the board structure */
1130/* Returns: Nothing */ 1130/* Returns: Nothing */
1131/* */ 1131/* */
1132/* Description: */ 1132/* Description: */
@@ -1135,8 +1135,9 @@ service_all_boards(void)
1135/* */ 1135/* */
1136/******************************************************************************/ 1136/******************************************************************************/
1137static void 1137static void
1138ip2_interrupt_bh(i2eBordStrPtr pB) 1138ip2_interrupt_bh(struct work_struct *work)
1139{ 1139{
1140 i2eBordStrPtr pB = container_of(work, i2eBordStr, tqueue_interrupt);
1140// pB better well be set or we have a problem! We can only get 1141// pB better well be set or we have a problem! We can only get
1141// here from the IMMEDIATE queue. Here, we process the boards. 1142// here from the IMMEDIATE queue. Here, we process the boards.
1142// Checking pB doesn't cost much and it saves us from the sanity checkers. 1143// Checking pB doesn't cost much and it saves us from the sanity checkers.
@@ -1245,9 +1246,9 @@ ip2_poll(unsigned long arg)
1245 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 ); 1246 ip2trace (ITRC_NO_PORT, ITRC_INTR, ITRC_RETURN, 0 );
1246} 1247}
1247 1248
1248static void do_input(void *p) 1249static void do_input(struct work_struct *work)
1249{ 1250{
1250 i2ChanStrPtr pCh = p; 1251 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_input);
1251 unsigned long flags; 1252 unsigned long flags;
1252 1253
1253 ip2trace(CHANN, ITRC_INPUT, 21, 0 ); 1254 ip2trace(CHANN, ITRC_INPUT, 21, 0 );
@@ -1279,9 +1280,9 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
1279 } 1280 }
1280} 1281}
1281 1282
1282static void do_status(void *p) 1283static void do_status(struct work_struct *work)
1283{ 1284{
1284 i2ChanStrPtr pCh = p; 1285 i2ChanStrPtr pCh = container_of(work, i2ChanStr, tqueue_status);
1285 int status; 1286 int status;
1286 1287
1287 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) ); 1288 status = i2GetStatus( pCh, (I2_BRK|I2_PAR|I2_FRA|I2_OVR) );
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 58c955e390b3..1637c1d9a4ba 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -530,9 +530,9 @@ sched_again:
530/* Interrupt handlers */ 530/* Interrupt handlers */
531 531
532 532
533static void isicom_bottomhalf(void *data) 533static void isicom_bottomhalf(struct work_struct *work)
534{ 534{
535 struct isi_port *port = (struct isi_port *) data; 535 struct isi_port *port = container_of(work, struct isi_port, bh_tqueue);
536 struct tty_struct *tty = port->tty; 536 struct tty_struct *tty = port->tty;
537 537
538 if (!tty) 538 if (!tty)
@@ -1474,9 +1474,9 @@ static void isicom_start(struct tty_struct *tty)
1474} 1474}
1475 1475
1476/* hangup et all */ 1476/* hangup et all */
1477static void do_isicom_hangup(void *data) 1477static void do_isicom_hangup(struct work_struct *work)
1478{ 1478{
1479 struct isi_port *port = data; 1479 struct isi_port *port = container_of(work, struct isi_port, hangup_tq);
1480 struct tty_struct *tty; 1480 struct tty_struct *tty;
1481 1481
1482 tty = port->tty; 1482 tty = port->tty;
@@ -1966,8 +1966,8 @@ static int __devinit isicom_setup(void)
1966 port->channel = channel; 1966 port->channel = channel;
1967 port->close_delay = 50 * HZ/100; 1967 port->close_delay = 50 * HZ/100;
1968 port->closing_wait = 3000 * HZ/100; 1968 port->closing_wait = 3000 * HZ/100;
1969 INIT_WORK(&port->hangup_tq, do_isicom_hangup, port); 1969 INIT_WORK(&port->hangup_tq, do_isicom_hangup);
1970 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf, port); 1970 INIT_WORK(&port->bh_tqueue, isicom_bottomhalf);
1971 port->status = 0; 1971 port->status = 0;
1972 init_waitqueue_head(&port->open_wait); 1972 init_waitqueue_head(&port->open_wait);
1973 init_waitqueue_head(&port->close_wait); 1973 init_waitqueue_head(&port->close_wait);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index ffdf9df1a67a..bd9195e17956 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -663,7 +663,7 @@ static int stli_initopen(stlibrd_t *brdp, stliport_t *portp);
663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 663static int stli_rawopen(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait); 664static int stli_rawclose(stlibrd_t *brdp, stliport_t *portp, unsigned long arg, int wait);
665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp); 665static int stli_waitcarrier(stlibrd_t *brdp, stliport_t *portp, struct file *filp);
666static void stli_dohangup(void *arg); 666static void stli_dohangup(struct work_struct *);
667static int stli_setport(stliport_t *portp); 667static int stli_setport(stliport_t *portp);
668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 668static int stli_cmdwait(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback); 669static void stli_sendcmd(stlibrd_t *brdp, stliport_t *portp, unsigned long cmd, void *arg, int size, int copyback);
@@ -1990,9 +1990,9 @@ static void stli_start(struct tty_struct *tty)
1990 * aren't that time critical). 1990 * aren't that time critical).
1991 */ 1991 */
1992 1992
1993static void stli_dohangup(void *arg) 1993static void stli_dohangup(struct work_struct *ugly_api)
1994{ 1994{
1995 stliport_t *portp = (stliport_t *) arg; 1995 stliport_t *portp = container_of(ugly_api, stliport_t, tqhangup);
1996 if (portp->tty != NULL) { 1996 if (portp->tty != NULL) {
1997 tty_hangup(portp->tty); 1997 tty_hangup(portp->tty);
1998 } 1998 }
@@ -2898,7 +2898,7 @@ static int stli_initports(stlibrd_t *brdp)
2898 portp->baud_base = STL_BAUDBASE; 2898 portp->baud_base = STL_BAUDBASE;
2899 portp->close_delay = STL_CLOSEDELAY; 2899 portp->close_delay = STL_CLOSEDELAY;
2900 portp->closing_wait = 30 * HZ; 2900 portp->closing_wait = 30 * HZ;
2901 INIT_WORK(&portp->tqhangup, stli_dohangup, portp); 2901 INIT_WORK(&portp->tqhangup, stli_dohangup);
2902 init_waitqueue_head(&portp->open_wait); 2902 init_waitqueue_head(&portp->open_wait);
2903 init_waitqueue_head(&portp->close_wait); 2903 init_waitqueue_head(&portp->close_wait);
2904 init_waitqueue_head(&portp->raw_wait); 2904 init_waitqueue_head(&portp->raw_wait);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 96cb1f07332b..2d025a9fd14d 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -222,7 +222,7 @@ static struct semaphore moxaBuffSem;
222/* 222/*
223 * static functions: 223 * static functions:
224 */ 224 */
225static void do_moxa_softint(void *); 225static void do_moxa_softint(struct work_struct *);
226static int moxa_open(struct tty_struct *, struct file *); 226static int moxa_open(struct tty_struct *, struct file *);
227static void moxa_close(struct tty_struct *, struct file *); 227static void moxa_close(struct tty_struct *, struct file *);
228static int moxa_write(struct tty_struct *, const unsigned char *, int); 228static int moxa_write(struct tty_struct *, const unsigned char *, int);
@@ -363,7 +363,7 @@ static int __init moxa_init(void)
363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { 363 for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) {
364 ch->type = PORT_16550A; 364 ch->type = PORT_16550A;
365 ch->port = i; 365 ch->port = i;
366 INIT_WORK(&ch->tqueue, do_moxa_softint, ch); 366 INIT_WORK(&ch->tqueue, do_moxa_softint);
367 ch->tty = NULL; 367 ch->tty = NULL;
368 ch->close_delay = 5 * HZ / 10; 368 ch->close_delay = 5 * HZ / 10;
369 ch->closing_wait = 30 * HZ; 369 ch->closing_wait = 30 * HZ;
@@ -509,9 +509,9 @@ static void __exit moxa_exit(void)
509module_init(moxa_init); 509module_init(moxa_init);
510module_exit(moxa_exit); 510module_exit(moxa_exit);
511 511
512static void do_moxa_softint(void *private_) 512static void do_moxa_softint(struct work_struct *work)
513{ 513{
514 struct moxa_str *ch = (struct moxa_str *) private_; 514 struct moxa_str *ch = container_of(work, struct moxa_str, tqueue);
515 struct tty_struct *tty; 515 struct tty_struct *tty;
516 516
517 if (ch && (tty = ch->tty)) { 517 if (ch && (tty = ch->tty)) {
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 048d91142c17..5ed2486b7581 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -389,7 +389,7 @@ static int mxser_init(void);
389/* static void mxser_poll(unsigned long); */ 389/* static void mxser_poll(unsigned long); */
390static int mxser_get_ISA_conf(int, struct mxser_hwconf *); 390static int mxser_get_ISA_conf(int, struct mxser_hwconf *);
391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *); 391static int mxser_get_PCI_conf(int, int, int, struct mxser_hwconf *);
392static void mxser_do_softint(void *); 392static void mxser_do_softint(struct work_struct *);
393static int mxser_open(struct tty_struct *, struct file *); 393static int mxser_open(struct tty_struct *, struct file *);
394static void mxser_close(struct tty_struct *, struct file *); 394static void mxser_close(struct tty_struct *, struct file *);
395static int mxser_write(struct tty_struct *, const unsigned char *, int); 395static int mxser_write(struct tty_struct *, const unsigned char *, int);
@@ -590,7 +590,7 @@ static int mxser_initbrd(int board, struct mxser_hwconf *hwconf)
590 info->custom_divisor = hwconf->baud_base[i] * 16; 590 info->custom_divisor = hwconf->baud_base[i] * 16;
591 info->close_delay = 5 * HZ / 10; 591 info->close_delay = 5 * HZ / 10;
592 info->closing_wait = 30 * HZ; 592 info->closing_wait = 30 * HZ;
593 INIT_WORK(&info->tqueue, mxser_do_softint, info); 593 INIT_WORK(&info->tqueue, mxser_do_softint);
594 info->normal_termios = mxvar_sdriver->init_termios; 594 info->normal_termios = mxvar_sdriver->init_termios;
595 init_waitqueue_head(&info->open_wait); 595 init_waitqueue_head(&info->open_wait);
596 init_waitqueue_head(&info->close_wait); 596 init_waitqueue_head(&info->close_wait);
@@ -917,9 +917,10 @@ static int mxser_init(void)
917 return 0; 917 return 0;
918} 918}
919 919
920static void mxser_do_softint(void *private_) 920static void mxser_do_softint(struct work_struct *work)
921{ 921{
922 struct mxser_struct *info = private_; 922 struct mxser_struct *info =
923 container_of(work, struct mxser_struct, tqueue);
923 struct tty_struct *tty; 924 struct tty_struct *tty;
924 925
925 tty = info->tty; 926 tty = info->tty;
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 50d20aafeb18..211c93fda6fc 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -1764,29 +1764,11 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1764 int rc; 1764 int rc;
1765 1765
1766 /* read the config-tuples */ 1766 /* read the config-tuples */
1767 tuple.DesiredTuple = CISTPL_CONFIG;
1768 tuple.Attributes = 0; 1767 tuple.Attributes = 0;
1769 tuple.TupleData = buf; 1768 tuple.TupleData = buf;
1770 tuple.TupleDataMax = sizeof(buf); 1769 tuple.TupleDataMax = sizeof(buf);
1771 tuple.TupleOffset = 0; 1770 tuple.TupleOffset = 0;
1772 1771
1773 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
1774 fail_fn = GetFirstTuple;
1775 goto cs_failed;
1776 }
1777 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
1778 fail_fn = GetTupleData;
1779 goto cs_failed;
1780 }
1781 if ((fail_rc =
1782 pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) {
1783 fail_fn = ParseTuple;
1784 goto cs_failed;
1785 }
1786
1787 link->conf.ConfigBase = parse.config.base;
1788 link->conf.Present = parse.config.rmask[0];
1789
1790 link->io.BasePort2 = 0; 1772 link->io.BasePort2 = 0;
1791 link->io.NumPorts2 = 0; 1773 link->io.NumPorts2 = 0;
1792 link->io.Attributes2 = 0; 1774 link->io.Attributes2 = 0;
@@ -1841,8 +1823,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
1841 1823
1842 return 0; 1824 return 0;
1843 1825
1844cs_failed:
1845 cs_error(link, fail_fn, fail_rc);
1846cs_release: 1826cs_release:
1847 cm4000_release(link); 1827 cm4000_release(link);
1848 return -ENODEV; 1828 return -ENODEV;
@@ -1973,14 +1953,14 @@ static int __init cmm_init(void)
1973 printk(KERN_INFO "%s\n", version); 1953 printk(KERN_INFO "%s\n", version);
1974 1954
1975 cmm_class = class_create(THIS_MODULE, "cardman_4000"); 1955 cmm_class = class_create(THIS_MODULE, "cardman_4000");
1976 if (!cmm_class) 1956 if (IS_ERR(cmm_class))
1977 return -1; 1957 return PTR_ERR(cmm_class);
1978 1958
1979 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); 1959 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
1980 if (major < 0) { 1960 if (major < 0) {
1981 printk(KERN_WARNING MODULE_NAME 1961 printk(KERN_WARNING MODULE_NAME
1982 ": could not get major number\n"); 1962 ": could not get major number\n");
1983 return -1; 1963 return major;
1984 } 1964 }
1985 1965
1986 rc = pcmcia_register_driver(&cm4000_driver); 1966 rc = pcmcia_register_driver(&cm4000_driver);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 55cf4be42976..9b1ff7e8f896 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -523,29 +523,11 @@ static int reader_config(struct pcmcia_device *link, int devno)
523 int fail_fn, fail_rc; 523 int fail_fn, fail_rc;
524 int rc; 524 int rc;
525 525
526 tuple.DesiredTuple = CISTPL_CONFIG;
527 tuple.Attributes = 0; 526 tuple.Attributes = 0;
528 tuple.TupleData = buf; 527 tuple.TupleData = buf;
529 tuple.TupleDataMax = sizeof(buf); 528 tuple.TupleDataMax = sizeof(buf);
530 tuple.TupleOffset = 0; 529 tuple.TupleOffset = 0;
531 530
532 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
533 fail_fn = GetFirstTuple;
534 goto cs_failed;
535 }
536 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
537 fail_fn = GetTupleData;
538 goto cs_failed;
539 }
540 if ((fail_rc = pcmcia_parse_tuple(link, &tuple, &parse))
541 != CS_SUCCESS) {
542 fail_fn = ParseTuple;
543 goto cs_failed;
544 }
545
546 link->conf.ConfigBase = parse.config.base;
547 link->conf.Present = parse.config.rmask[0];
548
549 link->io.BasePort2 = 0; 531 link->io.BasePort2 = 0;
550 link->io.NumPorts2 = 0; 532 link->io.NumPorts2 = 0;
551 link->io.Attributes2 = 0; 533 link->io.Attributes2 = 0;
@@ -609,8 +591,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
609 591
610 return 0; 592 return 0;
611 593
612cs_failed:
613 cs_error(link, fail_fn, fail_rc);
614cs_release: 594cs_release:
615 reader_release(link); 595 reader_release(link);
616 return -ENODEV; 596 return -ENODEV;
@@ -721,14 +701,14 @@ static int __init cm4040_init(void)
721 701
722 printk(KERN_INFO "%s\n", version); 702 printk(KERN_INFO "%s\n", version);
723 cmx_class = class_create(THIS_MODULE, "cardman_4040"); 703 cmx_class = class_create(THIS_MODULE, "cardman_4040");
724 if (!cmx_class) 704 if (IS_ERR(cmx_class))
725 return -1; 705 return PTR_ERR(cmx_class);
726 706
727 major = register_chrdev(0, DEVICE_NAME, &reader_fops); 707 major = register_chrdev(0, DEVICE_NAME, &reader_fops);
728 if (major < 0) { 708 if (major < 0) {
729 printk(KERN_WARNING MODULE_NAME 709 printk(KERN_WARNING MODULE_NAME
730 ": could not get major number\n"); 710 ": could not get major number\n");
731 return -1; 711 return major;
732 } 712 }
733 713
734 rc = pcmcia_register_driver(&reader_driver); 714 rc = pcmcia_register_driver(&reader_driver);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 1a0bc30b79d1..1bd12296dca5 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -421,7 +421,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id);
421/* 421/*
422 * Bottom half interrupt handlers 422 * Bottom half interrupt handlers
423 */ 423 */
424static void bh_handler(void* Context); 424static void bh_handler(struct work_struct *work);
425static void bh_transmit(MGSLPC_INFO *info); 425static void bh_transmit(MGSLPC_INFO *info);
426static void bh_status(MGSLPC_INFO *info); 426static void bh_status(MGSLPC_INFO *info);
427 427
@@ -547,7 +547,7 @@ static int mgslpc_probe(struct pcmcia_device *link)
547 547
548 memset(info, 0, sizeof(MGSLPC_INFO)); 548 memset(info, 0, sizeof(MGSLPC_INFO));
549 info->magic = MGSLPC_MAGIC; 549 info->magic = MGSLPC_MAGIC;
550 INIT_WORK(&info->task, bh_handler, info); 550 INIT_WORK(&info->task, bh_handler);
551 info->max_frame_size = 4096; 551 info->max_frame_size = 4096;
552 info->close_delay = 5*HZ/10; 552 info->close_delay = 5*HZ/10;
553 info->closing_wait = 30*HZ; 553 info->closing_wait = 30*HZ;
@@ -604,17 +604,10 @@ static int mgslpc_config(struct pcmcia_device *link)
604 if (debug_level >= DEBUG_LEVEL_INFO) 604 if (debug_level >= DEBUG_LEVEL_INFO)
605 printk("mgslpc_config(0x%p)\n", link); 605 printk("mgslpc_config(0x%p)\n", link);
606 606
607 /* read CONFIG tuple to find its configuration registers */
608 tuple.DesiredTuple = CISTPL_CONFIG;
609 tuple.Attributes = 0; 607 tuple.Attributes = 0;
610 tuple.TupleData = buf; 608 tuple.TupleData = buf;
611 tuple.TupleDataMax = sizeof(buf); 609 tuple.TupleDataMax = sizeof(buf);
612 tuple.TupleOffset = 0; 610 tuple.TupleOffset = 0;
613 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
614 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
615 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
616 link->conf.ConfigBase = parse.config.base;
617 link->conf.Present = parse.config.rmask[0];
618 611
619 /* get CIS configuration entry */ 612 /* get CIS configuration entry */
620 613
@@ -842,9 +835,9 @@ static int bh_action(MGSLPC_INFO *info)
842 return rc; 835 return rc;
843} 836}
844 837
845static void bh_handler(void* Context) 838static void bh_handler(struct work_struct *work)
846{ 839{
847 MGSLPC_INFO *info = (MGSLPC_INFO*)Context; 840 MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task);
848 int action; 841 int action;
849 842
850 if (!info) 843 if (!info)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d40df30c2b10..4c6782a1ecdb 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1422,9 +1422,9 @@ static struct keydata {
1422 1422
1423static unsigned int ip_cnt; 1423static unsigned int ip_cnt;
1424 1424
1425static void rekey_seq_generator(void *private_); 1425static void rekey_seq_generator(struct work_struct *work);
1426 1426
1427static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL); 1427static DECLARE_DELAYED_WORK(rekey_work, rekey_seq_generator);
1428 1428
1429/* 1429/*
1430 * Lock avoidance: 1430 * Lock avoidance:
@@ -1438,7 +1438,7 @@ static DECLARE_WORK(rekey_work, rekey_seq_generator, NULL);
1438 * happen, and even if that happens only a not perfectly compliant 1438 * happen, and even if that happens only a not perfectly compliant
1439 * ISN is generated, nothing fatal. 1439 * ISN is generated, nothing fatal.
1440 */ 1440 */
1441static void rekey_seq_generator(void *private_) 1441static void rekey_seq_generator(struct work_struct *work)
1442{ 1442{
1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)]; 1443 struct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];
1444 1444
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 5ab32b38f45a..722dd3e74185 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1516,9 +1516,9 @@ static void rc_start(struct tty_struct * tty)
1516 * do_rc_hangup() -> tty->hangup() -> rc_hangup() 1516 * do_rc_hangup() -> tty->hangup() -> rc_hangup()
1517 * 1517 *
1518 */ 1518 */
1519static void do_rc_hangup(void *private_) 1519static void do_rc_hangup(struct work_struct *ugly_api)
1520{ 1520{
1521 struct riscom_port *port = (struct riscom_port *) private_; 1521 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue_hangup);
1522 struct tty_struct *tty; 1522 struct tty_struct *tty;
1523 1523
1524 tty = port->tty; 1524 tty = port->tty;
@@ -1567,9 +1567,9 @@ static void rc_set_termios(struct tty_struct * tty, struct termios * old_termios
1567 } 1567 }
1568} 1568}
1569 1569
1570static void do_softint(void *private_) 1570static void do_softint(struct work_struct *ugly_api)
1571{ 1571{
1572 struct riscom_port *port = (struct riscom_port *) private_; 1572 struct riscom_port *port = container_of(ugly_api, struct riscom_port, tqueue);
1573 struct tty_struct *tty; 1573 struct tty_struct *tty;
1574 1574
1575 if(!(tty = port->tty)) 1575 if(!(tty = port->tty))
@@ -1632,8 +1632,8 @@ static inline int rc_init_drivers(void)
1632 memset(rc_port, 0, sizeof(rc_port)); 1632 memset(rc_port, 0, sizeof(rc_port));
1633 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { 1633 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1634 rc_port[i].magic = RISCOM8_MAGIC; 1634 rc_port[i].magic = RISCOM8_MAGIC;
1635 INIT_WORK(&rc_port[i].tqueue, do_softint, &rc_port[i]); 1635 INIT_WORK(&rc_port[i].tqueue, do_softint);
1636 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup, &rc_port[i]); 1636 INIT_WORK(&rc_port[i].tqueue_hangup, do_rc_hangup);
1637 rc_port[i].close_delay = 50 * HZ/100; 1637 rc_port[i].close_delay = 50 * HZ/100;
1638 rc_port[i].closing_wait = 3000 * HZ/100; 1638 rc_port[i].closing_wait = 3000 * HZ/100;
1639 init_waitqueue_head(&rc_port[i].open_wait); 1639 init_waitqueue_head(&rc_port[i].open_wait);
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index 3af7f0958c5d..9ba13af234be 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -706,9 +706,9 @@ cd2401_rx_interrupt(int irq, void *dev_id)
706 * had to poll every port to see if that port needed servicing. 706 * had to poll every port to see if that port needed servicing.
707 */ 707 */
708static void 708static void
709do_softint(void *private_) 709do_softint(struct work_struct *ugly_api)
710{ 710{
711 struct cyclades_port *info = (struct cyclades_port *) private_; 711 struct cyclades_port *info = container_of(ugly_api, struct cyclades_port, tqueue);
712 struct tty_struct *tty; 712 struct tty_struct *tty;
713 713
714 tty = info->tty; 714 tty = info->tty;
@@ -2273,7 +2273,7 @@ scrn[1] = '\0';
2273 info->blocked_open = 0; 2273 info->blocked_open = 0;
2274 info->default_threshold = 0; 2274 info->default_threshold = 0;
2275 info->default_timeout = 0; 2275 info->default_timeout = 0;
2276 INIT_WORK(&info->tqueue, do_softint, info); 2276 INIT_WORK(&info->tqueue, do_softint);
2277 init_waitqueue_head(&info->open_wait); 2277 init_waitqueue_head(&info->open_wait);
2278 init_waitqueue_head(&info->close_wait); 2278 init_waitqueue_head(&info->close_wait);
2279 /* info->session */ 2279 /* info->session */
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c084149153de..fc87070f1866 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -765,7 +765,7 @@ static void sonypi_setbluetoothpower(u8 state)
765 sonypi_device.bluetooth_power = state; 765 sonypi_device.bluetooth_power = state;
766} 766}
767 767
768static void input_keyrelease(void *data) 768static void input_keyrelease(struct work_struct *work)
769{ 769{
770 struct sonypi_keypress kp; 770 struct sonypi_keypress kp;
771 771
@@ -1412,7 +1412,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
1412 goto err_inpdev_unregister; 1412 goto err_inpdev_unregister;
1413 } 1413 }
1414 1414
1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease, NULL); 1415 INIT_WORK(&sonypi_device.input_work, input_keyrelease);
1416 } 1416 }
1417 1417
1418 sonypi_enable(0); 1418 sonypi_enable(0);
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 7e1bd9562c2a..99137ab66b62 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -2261,9 +2261,10 @@ static void sx_start(struct tty_struct * tty)
2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup() 2261 * do_sx_hangup() -> tty->hangup() -> sx_hangup()
2262 * 2262 *
2263 */ 2263 */
2264static void do_sx_hangup(void *private_) 2264static void do_sx_hangup(struct work_struct *work)
2265{ 2265{
2266 struct specialix_port *port = (struct specialix_port *) private_; 2266 struct specialix_port *port =
2267 container_of(work, struct specialix_port, tqueue_hangup);
2267 struct tty_struct *tty; 2268 struct tty_struct *tty;
2268 2269
2269 func_enter(); 2270 func_enter();
@@ -2336,9 +2337,10 @@ static void sx_set_termios(struct tty_struct * tty, struct termios * old_termios
2336} 2337}
2337 2338
2338 2339
2339static void do_softint(void *private_) 2340static void do_softint(struct work_struct *work)
2340{ 2341{
2341 struct specialix_port *port = (struct specialix_port *) private_; 2342 struct specialix_port *port =
2343 container_of(work, struct specialix_port, tqueue);
2342 struct tty_struct *tty; 2344 struct tty_struct *tty;
2343 2345
2344 func_enter(); 2346 func_enter();
@@ -2411,8 +2413,8 @@ static int sx_init_drivers(void)
2411 memset(sx_port, 0, sizeof(sx_port)); 2413 memset(sx_port, 0, sizeof(sx_port));
2412 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) { 2414 for (i = 0; i < SX_NPORT * SX_NBOARD; i++) {
2413 sx_port[i].magic = SPECIALIX_MAGIC; 2415 sx_port[i].magic = SPECIALIX_MAGIC;
2414 INIT_WORK(&sx_port[i].tqueue, do_softint, &sx_port[i]); 2416 INIT_WORK(&sx_port[i].tqueue, do_softint);
2415 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup, &sx_port[i]); 2417 INIT_WORK(&sx_port[i].tqueue_hangup, do_sx_hangup);
2416 sx_port[i].close_delay = 50 * HZ/100; 2418 sx_port[i].close_delay = 50 * HZ/100;
2417 sx_port[i].closing_wait = 3000 * HZ/100; 2419 sx_port[i].closing_wait = 3000 * HZ/100;
2418 init_waitqueue_head(&sx_port[i].open_wait); 2420 init_waitqueue_head(&sx_port[i].open_wait);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 522e88e395cc..5e2de62bce70 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -500,7 +500,7 @@ static int stl_echatintr(stlbrd_t *brdp);
500static int stl_echmcaintr(stlbrd_t *brdp); 500static int stl_echmcaintr(stlbrd_t *brdp);
501static int stl_echpciintr(stlbrd_t *brdp); 501static int stl_echpciintr(stlbrd_t *brdp);
502static int stl_echpci64intr(stlbrd_t *brdp); 502static int stl_echpci64intr(stlbrd_t *brdp);
503static void stl_offintr(void *private); 503static void stl_offintr(struct work_struct *);
504static stlbrd_t *stl_allocbrd(void); 504static stlbrd_t *stl_allocbrd(void);
505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr); 505static stlport_t *stl_getport(int brdnr, int panelnr, int portnr);
506 506
@@ -2081,14 +2081,12 @@ static int stl_echpci64intr(stlbrd_t *brdp)
2081/* 2081/*
2082 * Service an off-level request for some channel. 2082 * Service an off-level request for some channel.
2083 */ 2083 */
2084static void stl_offintr(void *private) 2084static void stl_offintr(struct work_struct *work)
2085{ 2085{
2086 stlport_t *portp; 2086 stlport_t *portp = container_of(work, stlport_t, tqueue);
2087 struct tty_struct *tty; 2087 struct tty_struct *tty;
2088 unsigned int oldsigs; 2088 unsigned int oldsigs;
2089 2089
2090 portp = private;
2091
2092#ifdef DEBUG 2090#ifdef DEBUG
2093 printk("stl_offintr(portp=%x)\n", (int) portp); 2091 printk("stl_offintr(portp=%x)\n", (int) portp);
2094#endif 2092#endif
@@ -2156,7 +2154,7 @@ static int __init stl_initports(stlbrd_t *brdp, stlpanel_t *panelp)
2156 portp->baud_base = STL_BAUDBASE; 2154 portp->baud_base = STL_BAUDBASE;
2157 portp->close_delay = STL_CLOSEDELAY; 2155 portp->close_delay = STL_CLOSEDELAY;
2158 portp->closing_wait = 30 * HZ; 2156 portp->closing_wait = 30 * HZ;
2159 INIT_WORK(&portp->tqueue, stl_offintr, portp); 2157 INIT_WORK(&portp->tqueue, stl_offintr);
2160 init_waitqueue_head(&portp->open_wait); 2158 init_waitqueue_head(&portp->open_wait);
2161 init_waitqueue_head(&portp->close_wait); 2159 init_waitqueue_head(&portp->close_wait);
2162 portp->stats.brd = portp->brdnr; 2160 portp->stats.brd = portp->brdnr;
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 06784adcc35c..147c30da81ea 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -802,7 +802,7 @@ static int save_tx_buffer_request(struct mgsl_struct *info,const char *Buffer, u
802/* 802/*
803 * Bottom half interrupt handlers 803 * Bottom half interrupt handlers
804 */ 804 */
805static void mgsl_bh_handler(void* Context); 805static void mgsl_bh_handler(struct work_struct *work);
806static void mgsl_bh_receive(struct mgsl_struct *info); 806static void mgsl_bh_receive(struct mgsl_struct *info);
807static void mgsl_bh_transmit(struct mgsl_struct *info); 807static void mgsl_bh_transmit(struct mgsl_struct *info);
808static void mgsl_bh_status(struct mgsl_struct *info); 808static void mgsl_bh_status(struct mgsl_struct *info);
@@ -1071,9 +1071,10 @@ static int mgsl_bh_action(struct mgsl_struct *info)
1071/* 1071/*
1072 * Perform bottom half processing of work items queued by ISR. 1072 * Perform bottom half processing of work items queued by ISR.
1073 */ 1073 */
1074static void mgsl_bh_handler(void* Context) 1074static void mgsl_bh_handler(struct work_struct *work)
1075{ 1075{
1076 struct mgsl_struct *info = (struct mgsl_struct*)Context; 1076 struct mgsl_struct *info =
1077 container_of(work, struct mgsl_struct, task);
1077 int action; 1078 int action;
1078 1079
1079 if (!info) 1080 if (!info)
@@ -4337,7 +4338,7 @@ static struct mgsl_struct* mgsl_allocate_device(void)
4337 } else { 4338 } else {
4338 memset(info, 0, sizeof(struct mgsl_struct)); 4339 memset(info, 0, sizeof(struct mgsl_struct));
4339 info->magic = MGSL_MAGIC; 4340 info->magic = MGSL_MAGIC;
4340 INIT_WORK(&info->task, mgsl_bh_handler, info); 4341 INIT_WORK(&info->task, mgsl_bh_handler);
4341 info->max_frame_size = 4096; 4342 info->max_frame_size = 4096;
4342 info->close_delay = 5*HZ/10; 4343 info->close_delay = 5*HZ/10;
4343 info->closing_wait = 30*HZ; 4344 info->closing_wait = 30*HZ;
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index d4334c79f8d4..07f34d43dc7f 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -485,7 +485,7 @@ static void enable_loopback(struct slgt_info *info);
485static void set_rate(struct slgt_info *info, u32 data_rate); 485static void set_rate(struct slgt_info *info, u32 data_rate);
486 486
487static int bh_action(struct slgt_info *info); 487static int bh_action(struct slgt_info *info);
488static void bh_handler(void* context); 488static void bh_handler(struct work_struct *work);
489static void bh_transmit(struct slgt_info *info); 489static void bh_transmit(struct slgt_info *info);
490static void isr_serial(struct slgt_info *info); 490static void isr_serial(struct slgt_info *info);
491static void isr_rdma(struct slgt_info *info); 491static void isr_rdma(struct slgt_info *info);
@@ -1878,9 +1878,9 @@ static int bh_action(struct slgt_info *info)
1878/* 1878/*
1879 * perform bottom half processing 1879 * perform bottom half processing
1880 */ 1880 */
1881static void bh_handler(void* context) 1881static void bh_handler(struct work_struct *work)
1882{ 1882{
1883 struct slgt_info *info = context; 1883 struct slgt_info *info = container_of(work, struct slgt_info, task);
1884 int action; 1884 int action;
1885 1885
1886 if (!info) 1886 if (!info)
@@ -3326,7 +3326,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
3326 } else { 3326 } else {
3327 memset(info, 0, sizeof(struct slgt_info)); 3327 memset(info, 0, sizeof(struct slgt_info));
3328 info->magic = MGSL_MAGIC; 3328 info->magic = MGSL_MAGIC;
3329 INIT_WORK(&info->task, bh_handler, info); 3329 INIT_WORK(&info->task, bh_handler);
3330 info->max_frame_size = 4096; 3330 info->max_frame_size = 4096;
3331 info->raw_rx_size = DMABUFSIZE; 3331 info->raw_rx_size = DMABUFSIZE;
3332 info->close_delay = 5*HZ/10; 3332 info->close_delay = 5*HZ/10;
@@ -4799,6 +4799,6 @@ static void rx_timeout(unsigned long context)
4799 spin_lock_irqsave(&info->lock, flags); 4799 spin_lock_irqsave(&info->lock, flags);
4800 info->pending_bh |= BH_RECEIVE; 4800 info->pending_bh |= BH_RECEIVE;
4801 spin_unlock_irqrestore(&info->lock, flags); 4801 spin_unlock_irqrestore(&info->lock, flags);
4802 bh_handler(info); 4802 bh_handler(&info->task);
4803} 4803}
4804 4804
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 3e932b681371..13a57245cf2e 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -602,7 +602,7 @@ static void enable_loopback(SLMP_INFO *info, int enable);
602static void set_rate(SLMP_INFO *info, u32 data_rate); 602static void set_rate(SLMP_INFO *info, u32 data_rate);
603 603
604static int bh_action(SLMP_INFO *info); 604static int bh_action(SLMP_INFO *info);
605static void bh_handler(void* Context); 605static void bh_handler(struct work_struct *work);
606static void bh_receive(SLMP_INFO *info); 606static void bh_receive(SLMP_INFO *info);
607static void bh_transmit(SLMP_INFO *info); 607static void bh_transmit(SLMP_INFO *info);
608static void bh_status(SLMP_INFO *info); 608static void bh_status(SLMP_INFO *info);
@@ -2063,9 +2063,9 @@ int bh_action(SLMP_INFO *info)
2063 2063
2064/* Perform bottom half processing of work items queued by ISR. 2064/* Perform bottom half processing of work items queued by ISR.
2065 */ 2065 */
2066void bh_handler(void* Context) 2066void bh_handler(struct work_struct *work)
2067{ 2067{
2068 SLMP_INFO *info = (SLMP_INFO*)Context; 2068 SLMP_INFO *info = container_of(work, SLMP_INFO, task);
2069 int action; 2069 int action;
2070 2070
2071 if (!info) 2071 if (!info)
@@ -3805,7 +3805,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
3805 } else { 3805 } else {
3806 memset(info, 0, sizeof(SLMP_INFO)); 3806 memset(info, 0, sizeof(SLMP_INFO));
3807 info->magic = MGSL_MAGIC; 3807 info->magic = MGSL_MAGIC;
3808 INIT_WORK(&info->task, bh_handler, info); 3808 INIT_WORK(&info->task, bh_handler);
3809 info->max_frame_size = 4096; 3809 info->max_frame_size = 4096;
3810 info->close_delay = 5*HZ/10; 3810 info->close_delay = 5*HZ/10;
3811 info->closing_wait = 30*HZ; 3811 info->closing_wait = 30*HZ;
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5f49280779fb..c64f5bcff947 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -219,13 +219,13 @@ static struct sysrq_key_op sysrq_term_op = {
219 .enable_mask = SYSRQ_ENABLE_SIGNAL, 219 .enable_mask = SYSRQ_ENABLE_SIGNAL,
220}; 220};
221 221
222static void moom_callback(void *ignored) 222static void moom_callback(struct work_struct *ignored)
223{ 223{
224 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], 224 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
225 GFP_KERNEL, 0); 225 GFP_KERNEL, 0);
226} 226}
227 227
228static DECLARE_WORK(moom_work, moom_callback, NULL); 228static DECLARE_WORK(moom_work, moom_callback);
229 229
230static void sysrq_handle_moom(int key, struct tty_struct *tty) 230static void sysrq_handle_moom(int key, struct tty_struct *tty)
231{ 231{
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 6e1329d404d2..774fa861169a 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -325,9 +325,9 @@ static void user_reader_timeout(unsigned long ptr)
325 schedule_work(&chip->work); 325 schedule_work(&chip->work);
326} 326}
327 327
328static void timeout_work(void *ptr) 328static void timeout_work(struct work_struct *work)
329{ 329{
330 struct tpm_chip *chip = ptr; 330 struct tpm_chip *chip = container_of(work, struct tpm_chip, work);
331 331
332 down(&chip->buffer_mutex); 332 down(&chip->buffer_mutex);
333 atomic_set(&chip->data_pending, 0); 333 atomic_set(&chip->data_pending, 0);
@@ -1105,7 +1105,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1105 init_MUTEX(&chip->tpm_mutex); 1105 init_MUTEX(&chip->tpm_mutex);
1106 INIT_LIST_HEAD(&chip->list); 1106 INIT_LIST_HEAD(&chip->list);
1107 1107
1108 INIT_WORK(&chip->work, timeout_work, chip); 1108 INIT_WORK(&chip->work, timeout_work);
1109 1109
1110 init_timer(&chip->user_read_timer); 1110 init_timer(&chip->user_read_timer);
1111 chip->user_read_timer.function = user_reader_timeout; 1111 chip->user_read_timer.function = user_reader_timeout;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 50dc49205a23..b3cfc8bc613c 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1254,7 +1254,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1254 1254
1255/** 1255/**
1256 * do_tty_hangup - actual handler for hangup events 1256 * do_tty_hangup - actual handler for hangup events
1257 * @data: tty device 1257 * @work: tty device
1258 * 1258 *
1259 * This can be called by the "eventd" kernel thread. That is process 1259 * This can be called by the "eventd" kernel thread. That is process
1260 * synchronous but doesn't hold any locks, so we need to make sure we 1260 * synchronous but doesn't hold any locks, so we need to make sure we
@@ -1274,9 +1274,10 @@ EXPORT_SYMBOL_GPL(tty_ldisc_flush);
1274 * tasklist_lock to walk task list for hangup event 1274 * tasklist_lock to walk task list for hangup event
1275 * 1275 *
1276 */ 1276 */
1277static void do_tty_hangup(void *data) 1277static void do_tty_hangup(struct work_struct *work)
1278{ 1278{
1279 struct tty_struct *tty = (struct tty_struct *) data; 1279 struct tty_struct *tty =
1280 container_of(work, struct tty_struct, hangup_work);
1280 struct file * cons_filp = NULL; 1281 struct file * cons_filp = NULL;
1281 struct file *filp, *f = NULL; 1282 struct file *filp, *f = NULL;
1282 struct task_struct *p; 1283 struct task_struct *p;
@@ -1433,7 +1434,7 @@ void tty_vhangup(struct tty_struct * tty)
1433 1434
1434 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf)); 1435 printk(KERN_DEBUG "%s vhangup...\n", tty_name(tty, buf));
1435#endif 1436#endif
1436 do_tty_hangup((void *) tty); 1437 do_tty_hangup(&tty->hangup_work);
1437} 1438}
1438EXPORT_SYMBOL(tty_vhangup); 1439EXPORT_SYMBOL(tty_vhangup);
1439 1440
@@ -3304,12 +3305,13 @@ int tty_ioctl(struct inode * inode, struct file * file,
3304 * Nasty bug: do_SAK is being called in interrupt context. This can 3305 * Nasty bug: do_SAK is being called in interrupt context. This can
3305 * deadlock. We punt it up to process context. AKPM - 16Mar2001 3306 * deadlock. We punt it up to process context. AKPM - 16Mar2001
3306 */ 3307 */
3307static void __do_SAK(void *arg) 3308static void __do_SAK(struct work_struct *work)
3308{ 3309{
3310 struct tty_struct *tty =
3311 container_of(work, struct tty_struct, SAK_work);
3309#ifdef TTY_SOFT_SAK 3312#ifdef TTY_SOFT_SAK
3310 tty_hangup(tty); 3313 tty_hangup(tty);
3311#else 3314#else
3312 struct tty_struct *tty = arg;
3313 struct task_struct *g, *p; 3315 struct task_struct *g, *p;
3314 int session; 3316 int session;
3315 int i; 3317 int i;
@@ -3388,7 +3390,7 @@ void do_SAK(struct tty_struct *tty)
3388{ 3390{
3389 if (!tty) 3391 if (!tty)
3390 return; 3392 return;
3391 PREPARE_WORK(&tty->SAK_work, __do_SAK, tty); 3393 PREPARE_WORK(&tty->SAK_work, __do_SAK);
3392 schedule_work(&tty->SAK_work); 3394 schedule_work(&tty->SAK_work);
3393} 3395}
3394 3396
@@ -3396,7 +3398,7 @@ EXPORT_SYMBOL(do_SAK);
3396 3398
3397/** 3399/**
3398 * flush_to_ldisc 3400 * flush_to_ldisc
3399 * @private_: tty structure passed from work queue. 3401 * @work: tty structure passed from work queue.
3400 * 3402 *
3401 * This routine is called out of the software interrupt to flush data 3403 * This routine is called out of the software interrupt to flush data
3402 * from the buffer chain to the line discipline. 3404 * from the buffer chain to the line discipline.
@@ -3406,9 +3408,10 @@ EXPORT_SYMBOL(do_SAK);
3406 * receive_buf method is single threaded for each tty instance. 3408 * receive_buf method is single threaded for each tty instance.
3407 */ 3409 */
3408 3410
3409static void flush_to_ldisc(void *private_) 3411static void flush_to_ldisc(struct work_struct *work)
3410{ 3412{
3411 struct tty_struct *tty = (struct tty_struct *) private_; 3413 struct tty_struct *tty =
3414 container_of(work, struct tty_struct, buf.work.work);
3412 unsigned long flags; 3415 unsigned long flags;
3413 struct tty_ldisc *disc; 3416 struct tty_ldisc *disc;
3414 struct tty_buffer *tbuf, *head; 3417 struct tty_buffer *tbuf, *head;
@@ -3553,7 +3556,7 @@ void tty_flip_buffer_push(struct tty_struct *tty)
3553 spin_unlock_irqrestore(&tty->buf.lock, flags); 3556 spin_unlock_irqrestore(&tty->buf.lock, flags);
3554 3557
3555 if (tty->low_latency) 3558 if (tty->low_latency)
3556 flush_to_ldisc((void *) tty); 3559 flush_to_ldisc(&tty->buf.work.work);
3557 else 3560 else
3558 schedule_delayed_work(&tty->buf.work, 1); 3561 schedule_delayed_work(&tty->buf.work, 1);
3559} 3562}
@@ -3580,17 +3583,17 @@ static void initialize_tty_struct(struct tty_struct *tty)
3580 tty->overrun_time = jiffies; 3583 tty->overrun_time = jiffies;
3581 tty->buf.head = tty->buf.tail = NULL; 3584 tty->buf.head = tty->buf.tail = NULL;
3582 tty_buffer_init(tty); 3585 tty_buffer_init(tty);
3583 INIT_WORK(&tty->buf.work, flush_to_ldisc, tty); 3586 INIT_DELAYED_WORK(&tty->buf.work, flush_to_ldisc);
3584 init_MUTEX(&tty->buf.pty_sem); 3587 init_MUTEX(&tty->buf.pty_sem);
3585 mutex_init(&tty->termios_mutex); 3588 mutex_init(&tty->termios_mutex);
3586 init_waitqueue_head(&tty->write_wait); 3589 init_waitqueue_head(&tty->write_wait);
3587 init_waitqueue_head(&tty->read_wait); 3590 init_waitqueue_head(&tty->read_wait);
3588 INIT_WORK(&tty->hangup_work, do_tty_hangup, tty); 3591 INIT_WORK(&tty->hangup_work, do_tty_hangup);
3589 mutex_init(&tty->atomic_read_lock); 3592 mutex_init(&tty->atomic_read_lock);
3590 mutex_init(&tty->atomic_write_lock); 3593 mutex_init(&tty->atomic_write_lock);
3591 spin_lock_init(&tty->read_lock); 3594 spin_lock_init(&tty->read_lock);
3592 INIT_LIST_HEAD(&tty->tty_files); 3595 INIT_LIST_HEAD(&tty->tty_files);
3593 INIT_WORK(&tty->SAK_work, NULL, NULL); 3596 INIT_WORK(&tty->SAK_work, NULL);
3594} 3597}
3595 3598
3596/* 3599/*
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 87587b4385ab..75ff0286e1ad 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -155,7 +155,7 @@ static void con_flush_chars(struct tty_struct *tty);
155static void set_vesa_blanking(char __user *p); 155static void set_vesa_blanking(char __user *p);
156static void set_cursor(struct vc_data *vc); 156static void set_cursor(struct vc_data *vc);
157static void hide_cursor(struct vc_data *vc); 157static void hide_cursor(struct vc_data *vc);
158static void console_callback(void *ignored); 158static void console_callback(struct work_struct *ignored);
159static void blank_screen_t(unsigned long dummy); 159static void blank_screen_t(unsigned long dummy);
160static void set_palette(struct vc_data *vc); 160static void set_palette(struct vc_data *vc);
161 161
@@ -174,7 +174,7 @@ static int vesa_blank_mode; /* 0:none 1:suspendV 2:suspendH 3:powerdown */
174static int blankinterval = 10*60*HZ; 174static int blankinterval = 10*60*HZ;
175static int vesa_off_interval; 175static int vesa_off_interval;
176 176
177static DECLARE_WORK(console_work, console_callback, NULL); 177static DECLARE_WORK(console_work, console_callback);
178 178
179/* 179/*
180 * fg_console is the current virtual console, 180 * fg_console is the current virtual console,
@@ -2154,7 +2154,7 @@ out:
2154 * with other console code and prevention of re-entrancy is 2154 * with other console code and prevention of re-entrancy is
2155 * ensured with console_sem. 2155 * ensured with console_sem.
2156 */ 2156 */
2157static void console_callback(void *ignored) 2157static void console_callback(struct work_struct *ignored)
2158{ 2158{
2159 acquire_console_sem(); 2159 acquire_console_sem();
2160 2160
diff --git a/drivers/connector/cn_queue.c b/drivers/connector/cn_queue.c
index 05f8ce2cfb4a..b418b16e910e 100644
--- a/drivers/connector/cn_queue.c
+++ b/drivers/connector/cn_queue.c
@@ -31,9 +31,11 @@
31#include <linux/connector.h> 31#include <linux/connector.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33 33
34void cn_queue_wrapper(void *data) 34void cn_queue_wrapper(struct work_struct *work)
35{ 35{
36 struct cn_callback_data *d = data; 36 struct cn_callback_entry *cbq =
37 container_of(work, struct cn_callback_entry, work.work);
38 struct cn_callback_data *d = &cbq->data;
37 39
38 d->callback(d->callback_priv); 40 d->callback(d->callback_priv);
39 41
@@ -57,7 +59,7 @@ static struct cn_callback_entry *cn_queue_alloc_callback_entry(char *name, struc
57 memcpy(&cbq->id.id, id, sizeof(struct cb_id)); 59 memcpy(&cbq->id.id, id, sizeof(struct cb_id));
58 cbq->data.callback = callback; 60 cbq->data.callback = callback;
59 61
60 INIT_WORK(&cbq->work, &cn_queue_wrapper, &cbq->data); 62 INIT_DELAYED_WORK(&cbq->work, &cn_queue_wrapper);
61 return cbq; 63 return cbq;
62} 64}
63 65
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index b49bacfd8de8..5e7cd45d10ee 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -135,40 +135,39 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
135 spin_lock_bh(&dev->cbdev->queue_lock); 135 spin_lock_bh(&dev->cbdev->queue_lock);
136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) { 136 list_for_each_entry(__cbq, &dev->cbdev->queue_list, callback_entry) {
137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) { 137 if (cn_cb_equal(&__cbq->id.id, &msg->id)) {
138 if (likely(!test_bit(0, &__cbq->work.pending) && 138 if (likely(!test_bit(WORK_STRUCT_PENDING,
139 &__cbq->work.work.management) &&
139 __cbq->data.ddata == NULL)) { 140 __cbq->data.ddata == NULL)) {
140 __cbq->data.callback_priv = msg; 141 __cbq->data.callback_priv = msg;
141 142
142 __cbq->data.ddata = data; 143 __cbq->data.ddata = data;
143 __cbq->data.destruct_data = destruct_data; 144 __cbq->data.destruct_data = destruct_data;
144 145
145 if (queue_work(dev->cbdev->cn_queue, 146 if (queue_delayed_work(
146 &__cbq->work)) 147 dev->cbdev->cn_queue,
148 &__cbq->work, 0))
147 err = 0; 149 err = 0;
148 } else { 150 } else {
149 struct work_struct *w;
150 struct cn_callback_data *d; 151 struct cn_callback_data *d;
151 152
152 w = kzalloc(sizeof(*w) + sizeof(*d), GFP_ATOMIC); 153 __cbq = kzalloc(sizeof(*__cbq), GFP_ATOMIC);
153 if (w) { 154 if (__cbq) {
154 d = (struct cn_callback_data *)(w+1); 155 d = &__cbq->data;
155
156 d->callback_priv = msg; 156 d->callback_priv = msg;
157 d->callback = __cbq->data.callback; 157 d->callback = __cbq->data.callback;
158 d->ddata = data; 158 d->ddata = data;
159 d->destruct_data = destruct_data; 159 d->destruct_data = destruct_data;
160 d->free = w; 160 d->free = __cbq;
161 161
162 INIT_LIST_HEAD(&w->entry); 162 INIT_DELAYED_WORK(&__cbq->work,
163 w->pending = 0; 163 &cn_queue_wrapper);
164 w->func = &cn_queue_wrapper;
165 w->data = d;
166 init_timer(&w->timer);
167 164
168 if (queue_work(dev->cbdev->cn_queue, w)) 165 if (queue_delayed_work(
166 dev->cbdev->cn_queue,
167 &__cbq->work, 0))
169 err = 0; 168 err = 0;
170 else { 169 else {
171 kfree(w); 170 kfree(__cbq);
172 err = -EINVAL; 171 err = -EINVAL;
173 } 172 }
174 } else 173 } else
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index dd0c2623e27b..7a7c6e6dfe4f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -42,7 +42,7 @@ static DEFINE_SPINLOCK(cpufreq_driver_lock);
42 42
43/* internal prototypes */ 43/* internal prototypes */
44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event); 44static int __cpufreq_governor(struct cpufreq_policy *policy, unsigned int event);
45static void handle_update(void *data); 45static void handle_update(struct work_struct *work);
46 46
47/** 47/**
48 * Two notifier lists: the "policy" list is involved in the 48 * Two notifier lists: the "policy" list is involved in the
@@ -665,7 +665,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
665 mutex_init(&policy->lock); 665 mutex_init(&policy->lock);
666 mutex_lock(&policy->lock); 666 mutex_lock(&policy->lock);
667 init_completion(&policy->kobj_unregister); 667 init_completion(&policy->kobj_unregister);
668 INIT_WORK(&policy->update, handle_update, (void *)(long)cpu); 668 INIT_WORK(&policy->update, handle_update);
669 669
670 /* call driver. From then on the cpufreq must be able 670 /* call driver. From then on the cpufreq must be able
671 * to accept all calls to ->verify and ->setpolicy for this CPU 671 * to accept all calls to ->verify and ->setpolicy for this CPU
@@ -895,9 +895,11 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
895} 895}
896 896
897 897
898static void handle_update(void *data) 898static void handle_update(struct work_struct *work)
899{ 899{
900 unsigned int cpu = (unsigned int)(long)data; 900 struct cpufreq_policy *policy =
901 container_of(work, struct cpufreq_policy, update);
902 unsigned int cpu = policy->cpu;
901 dprintk("handle_update for cpu %u called\n", cpu); 903 dprintk("handle_update for cpu %u called\n", cpu);
902 cpufreq_update_policy(cpu); 904 cpufreq_update_policy(cpu);
903} 905}
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index c4c578defabf..5ef5ede5b884 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -59,7 +59,7 @@ static unsigned int def_sampling_rate;
59#define MAX_SAMPLING_DOWN_FACTOR (10) 59#define MAX_SAMPLING_DOWN_FACTOR (10)
60#define TRANSITION_LATENCY_LIMIT (10 * 1000) 60#define TRANSITION_LATENCY_LIMIT (10 * 1000)
61 61
62static void do_dbs_timer(void *data); 62static void do_dbs_timer(struct work_struct *work);
63 63
64struct cpu_dbs_info_s { 64struct cpu_dbs_info_s {
65 struct cpufreq_policy *cur_policy; 65 struct cpufreq_policy *cur_policy;
@@ -82,7 +82,7 @@ static unsigned int dbs_enable; /* number of CPUs using this policy */
82 * is recursive for the same process. -Venki 82 * is recursive for the same process. -Venki
83 */ 83 */
84static DEFINE_MUTEX (dbs_mutex); 84static DEFINE_MUTEX (dbs_mutex);
85static DECLARE_WORK (dbs_work, do_dbs_timer, NULL); 85static DECLARE_DELAYED_WORK(dbs_work, do_dbs_timer);
86 86
87struct dbs_tuners { 87struct dbs_tuners {
88 unsigned int sampling_rate; 88 unsigned int sampling_rate;
@@ -420,7 +420,7 @@ static void dbs_check_cpu(int cpu)
420 } 420 }
421} 421}
422 422
423static void do_dbs_timer(void *data) 423static void do_dbs_timer(struct work_struct *work)
424{ 424{
425 int i; 425 int i;
426 lock_cpu_hotplug(); 426 lock_cpu_hotplug();
@@ -435,7 +435,6 @@ static void do_dbs_timer(void *data)
435 435
436static inline void dbs_timer_init(void) 436static inline void dbs_timer_init(void)
437{ 437{
438 INIT_WORK(&dbs_work, do_dbs_timer, NULL);
439 schedule_delayed_work(&dbs_work, 438 schedule_delayed_work(&dbs_work,
440 usecs_to_jiffies(dbs_tuners_ins.sampling_rate)); 439 usecs_to_jiffies(dbs_tuners_ins.sampling_rate));
441 return; 440 return;
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index bf8aa45d4f01..e1cc5113c2ae 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -47,13 +47,17 @@ static unsigned int def_sampling_rate;
47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000) 47#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
48#define TRANSITION_LATENCY_LIMIT (10 * 1000) 48#define TRANSITION_LATENCY_LIMIT (10 * 1000)
49 49
50static void do_dbs_timer(void *data); 50static void do_dbs_timer(struct work_struct *work);
51
52/* Sampling types */
53enum dbs_sample {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
51 54
52struct cpu_dbs_info_s { 55struct cpu_dbs_info_s {
53 cputime64_t prev_cpu_idle; 56 cputime64_t prev_cpu_idle;
54 cputime64_t prev_cpu_wall; 57 cputime64_t prev_cpu_wall;
55 struct cpufreq_policy *cur_policy; 58 struct cpufreq_policy *cur_policy;
56 struct work_struct work; 59 struct delayed_work work;
60 enum dbs_sample sample_type;
57 unsigned int enable; 61 unsigned int enable;
58 struct cpufreq_frequency_table *freq_table; 62 struct cpufreq_frequency_table *freq_table;
59 unsigned int freq_lo; 63 unsigned int freq_lo;
@@ -407,30 +411,31 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
407 } 411 }
408} 412}
409 413
410/* Sampling types */ 414static void do_dbs_timer(struct work_struct *work)
411enum {DBS_NORMAL_SAMPLE, DBS_SUB_SAMPLE};
412
413static void do_dbs_timer(void *data)
414{ 415{
415 unsigned int cpu = smp_processor_id(); 416 unsigned int cpu = smp_processor_id();
416 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu); 417 struct cpu_dbs_info_s *dbs_info = &per_cpu(cpu_dbs_info, cpu);
418 enum dbs_sample sample_type = dbs_info->sample_type;
417 /* We want all CPUs to do sampling nearly on same jiffy */ 419 /* We want all CPUs to do sampling nearly on same jiffy */
418 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 420 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
421
422 /* Permit rescheduling of this work item */
423 work_release(work);
424
419 delay -= jiffies % delay; 425 delay -= jiffies % delay;
420 426
421 if (!dbs_info->enable) 427 if (!dbs_info->enable)
422 return; 428 return;
423 /* Common NORMAL_SAMPLE setup */ 429 /* Common NORMAL_SAMPLE setup */
424 INIT_WORK(&dbs_info->work, do_dbs_timer, (void *)DBS_NORMAL_SAMPLE); 430 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
425 if (!dbs_tuners_ins.powersave_bias || 431 if (!dbs_tuners_ins.powersave_bias ||
426 (unsigned long) data == DBS_NORMAL_SAMPLE) { 432 sample_type == DBS_NORMAL_SAMPLE) {
427 lock_cpu_hotplug(); 433 lock_cpu_hotplug();
428 dbs_check_cpu(dbs_info); 434 dbs_check_cpu(dbs_info);
429 unlock_cpu_hotplug(); 435 unlock_cpu_hotplug();
430 if (dbs_info->freq_lo) { 436 if (dbs_info->freq_lo) {
431 /* Setup timer for SUB_SAMPLE */ 437 /* Setup timer for SUB_SAMPLE */
432 INIT_WORK(&dbs_info->work, do_dbs_timer, 438 dbs_info->sample_type = DBS_SUB_SAMPLE;
433 (void *)DBS_SUB_SAMPLE);
434 delay = dbs_info->freq_hi_jiffies; 439 delay = dbs_info->freq_hi_jiffies;
435 } 440 }
436 } else { 441 } else {
@@ -449,7 +454,8 @@ static inline void dbs_timer_init(unsigned int cpu)
449 delay -= jiffies % delay; 454 delay -= jiffies % delay;
450 455
451 ondemand_powersave_bias_init(); 456 ondemand_powersave_bias_init();
452 INIT_WORK(&dbs_info->work, do_dbs_timer, NULL); 457 INIT_DELAYED_WORK_NAR(&dbs_info->work, do_dbs_timer);
458 dbs_info->sample_type = DBS_NORMAL_SAMPLE;
453 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay); 459 queue_delayed_work_on(cpu, kondemand_wq, &dbs_info->work, delay);
454} 460}
455 461
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index 4630f1969a09..15edf40828b4 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -140,12 +140,14 @@ ulong ds1374_get_rtc_time(void)
140 return t1; 140 return t1;
141} 141}
142 142
143static void ds1374_set_work(void *arg) 143static ulong new_time;
144
145static void ds1374_set_work(struct work_struct *work)
144{ 146{
145 ulong t1, t2; 147 ulong t1, t2;
146 int limit = 10; /* arbitrary retry limit */ 148 int limit = 10; /* arbitrary retry limit */
147 149
148 t1 = *(ulong *) arg; 150 t1 = new_time;
149 151
150 mutex_lock(&ds1374_mutex); 152 mutex_lock(&ds1374_mutex);
151 153
@@ -167,11 +169,9 @@ static void ds1374_set_work(void *arg)
167 "can't confirm time set from rtc chip\n"); 169 "can't confirm time set from rtc chip\n");
168} 170}
169 171
170static ulong new_time;
171
172static struct workqueue_struct *ds1374_workqueue; 172static struct workqueue_struct *ds1374_workqueue;
173 173
174static DECLARE_WORK(ds1374_work, ds1374_set_work, &new_time); 174static DECLARE_WORK(ds1374_work, ds1374_set_work);
175 175
176int ds1374_set_rtc_time(ulong nowtime) 176int ds1374_set_rtc_time(ulong nowtime)
177{ 177{
@@ -180,7 +180,7 @@ int ds1374_set_rtc_time(ulong nowtime)
180 if (in_interrupt()) 180 if (in_interrupt())
181 queue_work(ds1374_workqueue, &ds1374_work); 181 queue_work(ds1374_workqueue, &ds1374_work);
182 else 182 else
183 ds1374_set_work(&new_time); 183 ds1374_set_work(NULL);
184 184
185 return 0; 185 return 0;
186} 186}
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 2dd0a34d9472..420377c86422 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -215,8 +215,15 @@ m41t00_set(void *arg)
215} 215}
216 216
217static ulong new_time; 217static ulong new_time;
218/* well, isn't this API just _lovely_? */
219static void
220m41t00_barf(struct work_struct *unusable)
221{
222 m41t00_set(&new_time);
223}
224
218static struct workqueue_struct *m41t00_wq; 225static struct workqueue_struct *m41t00_wq;
219static DECLARE_WORK(m41t00_work, m41t00_set, &new_time); 226static DECLARE_WORK(m41t00_work, m41t00_barf);
220 227
221int 228int
222m41t00_set_rtc_time(ulong nowtime) 229m41t00_set_rtc_time(ulong nowtime)
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index bef4759f70e5..7efd28ac21ed 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -192,20 +192,10 @@ static int ide_config(struct pcmcia_device *link)
192 tuple.TupleOffset = 0; 192 tuple.TupleOffset = 0;
193 tuple.TupleDataMax = 255; 193 tuple.TupleDataMax = 255;
194 tuple.Attributes = 0; 194 tuple.Attributes = 0;
195 tuple.DesiredTuple = CISTPL_CONFIG; 195
196 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 196 is_kme = ((link->manf_id == MANFID_KME) &&
197 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 197 ((link->card_id == PRODID_KME_KXLC005_A) ||
198 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &stk->parse)); 198 (link->card_id == PRODID_KME_KXLC005_B)));
199 link->conf.ConfigBase = stk->parse.config.base;
200 link->conf.Present = stk->parse.config.rmask[0];
201
202 tuple.DesiredTuple = CISTPL_MANFID;
203 if (!pcmcia_get_first_tuple(link, &tuple) &&
204 !pcmcia_get_tuple_data(link, &tuple) &&
205 !pcmcia_parse_tuple(link, &tuple, &stk->parse))
206 is_kme = ((stk->parse.manfid.manf == MANFID_KME) &&
207 ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) ||
208 (stk->parse.manfid.card == PRODID_KME_KXLC005_B)));
209 199
210 /* Not sure if this is right... look up the current Vcc */ 200 /* Not sure if this is right... look up the current Vcc */
211 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 201 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf));
@@ -408,8 +398,10 @@ static struct pcmcia_device_id ide_ids[] = {
408 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6), 398 PCMCIA_DEVICE_PROD_ID12("SMI VENDOR", "SMI PRODUCT", 0x30896c92, 0x703cc5f6),
409 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), 399 PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003),
410 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443), 400 PCMCIA_DEVICE_PROD_ID1("TRANSCEND 512M ", 0xd0909443),
401 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS1GCF80", 0x709b1bf1, 0x2a54d4b1),
411 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8), 402 PCMCIA_DEVICE_PROD_ID12("TRANSCEND", "TS4GCF120", 0x709b1bf1, 0xf54a91c8),
412 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), 403 PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852),
404 PCMCIA_DEVICE_PROD_ID12("WEIDA", "TWTTI", 0xcc7cf69c, 0x212bb918),
413 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), 405 PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209),
414 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e), 406 PCMCIA_DEVICE_PROD_ID12("STI", "Flash 5.0", 0xbf2df18d, 0x8cb57a0e),
415 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6), 407 PCMCIA_MFC_DEVICE_PROD_ID12(1, "SanDisk", "ConnectPlus", 0x7a954bd9, 0x74be00c6),
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 2af634d7acf4..eb7ab112c050 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -35,7 +35,7 @@
35#include <linux/ide.h> 35#include <linux/ide.h>
36#include <asm/io.h> 36#include <asm/io.h>
37 37
38#ifdef CONFIG_PPC_MULTIPLATFORM 38#ifdef CONFIG_PPC_CHRP
39#include <asm/processor.h> 39#include <asm/processor.h>
40#endif 40#endif
41 41
@@ -442,7 +442,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
442 hwif->speedproc = &via_set_drive; 442 hwif->speedproc = &via_set_drive;
443 443
444 444
445#if defined(CONFIG_PPC_CHRP) && defined(CONFIG_PPC32) 445#ifdef CONFIG_PPC_CHRP
446 if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) { 446 if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) {
447 hwif->irq = hwif->channel ? 15 : 14; 447 hwif->irq = hwif->channel ? 15 : 14;
448 } 448 }
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index d90a3a1898c0..8f4378a1631c 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -31,9 +31,10 @@
31#include "config_roms.h" 31#include "config_roms.h"
32 32
33 33
34static void delayed_reset_bus(void * __reset_info) 34static void delayed_reset_bus(struct work_struct *work)
35{ 35{
36 struct hpsb_host *host = (struct hpsb_host*)__reset_info; 36 struct hpsb_host *host =
37 container_of(work, struct hpsb_host, delayed_reset.work);
37 int generation = host->csr.generation + 1; 38 int generation = host->csr.generation + 1;
38 39
39 /* The generation field rolls over to 2 rather than 0 per IEEE 40 /* The generation field rolls over to 2 rather than 0 per IEEE
@@ -145,7 +146,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
145 146
146 atomic_set(&h->generation, 0); 147 atomic_set(&h->generation, 0);
147 148
148 INIT_WORK(&h->delayed_reset, delayed_reset_bus, h); 149 INIT_DELAYED_WORK(&h->delayed_reset, delayed_reset_bus);
149 150
150 init_timer(&h->timeout); 151 init_timer(&h->timeout);
151 h->timeout.data = (unsigned long) h; 152 h->timeout.data = (unsigned long) h;
@@ -234,7 +235,7 @@ int hpsb_update_config_rom_image(struct hpsb_host *host)
234 * Config ROM in the near future. */ 235 * Config ROM in the near future. */
235 reset_delay = HZ; 236 reset_delay = HZ;
236 237
237 PREPARE_WORK(&host->delayed_reset, delayed_reset_bus, host); 238 PREPARE_DELAYED_WORK(&host->delayed_reset, delayed_reset_bus);
238 schedule_delayed_work(&host->delayed_reset, reset_delay); 239 schedule_delayed_work(&host->delayed_reset, reset_delay);
239 240
240 return 0; 241 return 0;
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index bc6dbfadb891..d553e38c9543 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -62,7 +62,7 @@ struct hpsb_host {
62 struct class_device class_dev; 62 struct class_device class_dev;
63 63
64 int update_config_rom; 64 int update_config_rom;
65 struct work_struct delayed_reset; 65 struct delayed_work delayed_reset;
66 unsigned int config_roms; 66 unsigned int config_roms;
67 67
68 struct list_head addr_space; 68 struct list_head addr_space;
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 6986ac188281..cd156d4e779e 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -493,20 +493,25 @@ static void sbp2util_notify_fetch_agent(struct scsi_id_instance_data *scsi_id,
493 scsi_unblock_requests(scsi_id->scsi_host); 493 scsi_unblock_requests(scsi_id->scsi_host);
494} 494}
495 495
496static void sbp2util_write_orb_pointer(void *p) 496static void sbp2util_write_orb_pointer(struct work_struct *work)
497{ 497{
498 struct scsi_id_instance_data *scsi_id =
499 container_of(work, struct scsi_id_instance_data,
500 protocol_work.work);
498 quadlet_t data[2]; 501 quadlet_t data[2];
499 502
500 data[0] = ORB_SET_NODE_ID( 503 data[0] = ORB_SET_NODE_ID(scsi_id->hi->host->node_id);
501 ((struct scsi_id_instance_data *)p)->hi->host->node_id); 504 data[1] = scsi_id->last_orb_dma;
502 data[1] = ((struct scsi_id_instance_data *)p)->last_orb_dma;
503 sbp2util_cpu_to_be32_buffer(data, 8); 505 sbp2util_cpu_to_be32_buffer(data, 8);
504 sbp2util_notify_fetch_agent(p, SBP2_ORB_POINTER_OFFSET, data, 8); 506 sbp2util_notify_fetch_agent(scsi_id, SBP2_ORB_POINTER_OFFSET, data, 8);
505} 507}
506 508
507static void sbp2util_write_doorbell(void *p) 509static void sbp2util_write_doorbell(struct work_struct *work)
508{ 510{
509 sbp2util_notify_fetch_agent(p, SBP2_DOORBELL_OFFSET, NULL, 4); 511 struct scsi_id_instance_data *scsi_id =
512 container_of(work, struct scsi_id_instance_data,
513 protocol_work.work);
514 sbp2util_notify_fetch_agent(scsi_id, SBP2_DOORBELL_OFFSET, NULL, 4);
510} 515}
511 516
512/* 517/*
@@ -843,7 +848,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
843 INIT_LIST_HEAD(&scsi_id->scsi_list); 848 INIT_LIST_HEAD(&scsi_id->scsi_list);
844 spin_lock_init(&scsi_id->sbp2_command_orb_lock); 849 spin_lock_init(&scsi_id->sbp2_command_orb_lock);
845 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING); 850 atomic_set(&scsi_id->state, SBP2LU_STATE_RUNNING);
846 INIT_WORK(&scsi_id->protocol_work, NULL, NULL); 851 INIT_DELAYED_WORK(&scsi_id->protocol_work, NULL);
847 852
848 ud->device.driver_data = scsi_id; 853 ud->device.driver_data = scsi_id;
849 854
@@ -2047,11 +2052,10 @@ static void sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2047 * We do not accept new commands until the job is over. 2052 * We do not accept new commands until the job is over.
2048 */ 2053 */
2049 scsi_block_requests(scsi_id->scsi_host); 2054 scsi_block_requests(scsi_id->scsi_host);
2050 PREPARE_WORK(&scsi_id->protocol_work, 2055 PREPARE_DELAYED_WORK(&scsi_id->protocol_work,
2051 last_orb ? sbp2util_write_doorbell: 2056 last_orb ? sbp2util_write_doorbell:
2052 sbp2util_write_orb_pointer, 2057 sbp2util_write_orb_pointer);
2053 scsi_id); 2058 schedule_delayed_work(&scsi_id->protocol_work, 0);
2054 schedule_work(&scsi_id->protocol_work);
2055 } 2059 }
2056} 2060}
2057 2061
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index abbe48e646c3..1b16d6b9cf11 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -348,7 +348,7 @@ struct scsi_id_instance_data {
348 unsigned workarounds; 348 unsigned workarounds;
349 349
350 atomic_t state; 350 atomic_t state;
351 struct work_struct protocol_work; 351 struct delayed_work protocol_work;
352}; 352};
353 353
354/* For use in scsi_id_instance_data.state */ 354/* For use in scsi_id_instance_data.state */
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 7767a11b6890..af939796750d 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -55,11 +55,11 @@ struct addr_req {
55 int status; 55 int status;
56}; 56};
57 57
58static void process_req(void *data); 58static void process_req(struct work_struct *work);
59 59
60static DEFINE_MUTEX(lock); 60static DEFINE_MUTEX(lock);
61static LIST_HEAD(req_list); 61static LIST_HEAD(req_list);
62static DECLARE_WORK(work, process_req, NULL); 62static DECLARE_DELAYED_WORK(work, process_req);
63static struct workqueue_struct *addr_wq; 63static struct workqueue_struct *addr_wq;
64 64
65void rdma_addr_register_client(struct rdma_addr_client *client) 65void rdma_addr_register_client(struct rdma_addr_client *client)
@@ -215,7 +215,7 @@ out:
215 return ret; 215 return ret;
216} 216}
217 217
218static void process_req(void *data) 218static void process_req(struct work_struct *work)
219{ 219{
220 struct addr_req *req, *temp_req; 220 struct addr_req *req, *temp_req;
221 struct sockaddr_in *src_in, *dst_in; 221 struct sockaddr_in *src_in, *dst_in;
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 20e9f64e67a6..98272fbbfb31 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -285,9 +285,10 @@ err:
285 kfree(tprops); 285 kfree(tprops);
286} 286}
287 287
288static void ib_cache_task(void *work_ptr) 288static void ib_cache_task(struct work_struct *_work)
289{ 289{
290 struct ib_update_work *work = work_ptr; 290 struct ib_update_work *work =
291 container_of(_work, struct ib_update_work, work);
291 292
292 ib_cache_update(work->device, work->port_num); 293 ib_cache_update(work->device, work->port_num);
293 kfree(work); 294 kfree(work);
@@ -306,7 +307,7 @@ static void ib_cache_event(struct ib_event_handler *handler,
306 event->event == IB_EVENT_CLIENT_REREGISTER) { 307 event->event == IB_EVENT_CLIENT_REREGISTER) {
307 work = kmalloc(sizeof *work, GFP_ATOMIC); 308 work = kmalloc(sizeof *work, GFP_ATOMIC);
308 if (work) { 309 if (work) {
309 INIT_WORK(&work->work, ib_cache_task, work); 310 INIT_WORK(&work->work, ib_cache_task);
310 work->device = event->device; 311 work->device = event->device;
311 work->port_num = event->element.port_num; 312 work->port_num = event->element.port_num;
312 schedule_work(&work->work); 313 schedule_work(&work->work);
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index e5dc4530808a..79c937bf6962 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -101,7 +101,7 @@ struct cm_av {
101}; 101};
102 102
103struct cm_work { 103struct cm_work {
104 struct work_struct work; 104 struct delayed_work work;
105 struct list_head list; 105 struct list_head list;
106 struct cm_port *port; 106 struct cm_port *port;
107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */ 107 struct ib_mad_recv_wc *mad_recv_wc; /* Received MADs */
@@ -161,7 +161,7 @@ struct cm_id_private {
161 atomic_t work_count; 161 atomic_t work_count;
162}; 162};
163 163
164static void cm_work_handler(void *data); 164static void cm_work_handler(struct work_struct *work);
165 165
166static inline void cm_deref_id(struct cm_id_private *cm_id_priv) 166static inline void cm_deref_id(struct cm_id_private *cm_id_priv)
167{ 167{
@@ -668,8 +668,7 @@ static struct cm_timewait_info * cm_create_timewait_info(__be32 local_id)
668 return ERR_PTR(-ENOMEM); 668 return ERR_PTR(-ENOMEM);
669 669
670 timewait_info->work.local_id = local_id; 670 timewait_info->work.local_id = local_id;
671 INIT_WORK(&timewait_info->work.work, cm_work_handler, 671 INIT_DELAYED_WORK(&timewait_info->work.work, cm_work_handler);
672 &timewait_info->work);
673 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT; 672 timewait_info->work.cm_event.event = IB_CM_TIMEWAIT_EXIT;
674 return timewait_info; 673 return timewait_info;
675} 674}
@@ -2995,9 +2994,9 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
2995 } 2994 }
2996} 2995}
2997 2996
2998static void cm_work_handler(void *data) 2997static void cm_work_handler(struct work_struct *_work)
2999{ 2998{
3000 struct cm_work *work = data; 2999 struct cm_work *work = container_of(_work, struct cm_work, work.work);
3001 int ret; 3000 int ret;
3002 3001
3003 switch (work->cm_event.event) { 3002 switch (work->cm_event.event) {
@@ -3087,12 +3086,12 @@ static int cm_establish(struct ib_cm_id *cm_id)
3087 * we need to find the cm_id once we're in the context of the 3086 * we need to find the cm_id once we're in the context of the
3088 * worker thread, rather than holding a reference on it. 3087 * worker thread, rather than holding a reference on it.
3089 */ 3088 */
3090 INIT_WORK(&work->work, cm_work_handler, work); 3089 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3091 work->local_id = cm_id->local_id; 3090 work->local_id = cm_id->local_id;
3092 work->remote_id = cm_id->remote_id; 3091 work->remote_id = cm_id->remote_id;
3093 work->mad_recv_wc = NULL; 3092 work->mad_recv_wc = NULL;
3094 work->cm_event.event = IB_CM_USER_ESTABLISHED; 3093 work->cm_event.event = IB_CM_USER_ESTABLISHED;
3095 queue_work(cm.wq, &work->work); 3094 queue_delayed_work(cm.wq, &work->work, 0);
3096out: 3095out:
3097 return ret; 3096 return ret;
3098} 3097}
@@ -3191,11 +3190,11 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
3191 return; 3190 return;
3192 } 3191 }
3193 3192
3194 INIT_WORK(&work->work, cm_work_handler, work); 3193 INIT_DELAYED_WORK(&work->work, cm_work_handler);
3195 work->cm_event.event = event; 3194 work->cm_event.event = event;
3196 work->mad_recv_wc = mad_recv_wc; 3195 work->mad_recv_wc = mad_recv_wc;
3197 work->port = (struct cm_port *)mad_agent->context; 3196 work->port = (struct cm_port *)mad_agent->context;
3198 queue_work(cm.wq, &work->work); 3197 queue_delayed_work(cm.wq, &work->work, 0);
3199} 3198}
3200 3199
3201static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv, 3200static int cm_init_qp_init_attr(struct cm_id_private *cm_id_priv,
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index cf48f2697434..985a6b564d8f 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1340,9 +1340,9 @@ static int cma_query_ib_route(struct rdma_id_private *id_priv, int timeout_ms,
1340 return (id_priv->query_id < 0) ? id_priv->query_id : 0; 1340 return (id_priv->query_id < 0) ? id_priv->query_id : 0;
1341} 1341}
1342 1342
1343static void cma_work_handler(void *data) 1343static void cma_work_handler(struct work_struct *_work)
1344{ 1344{
1345 struct cma_work *work = data; 1345 struct cma_work *work = container_of(_work, struct cma_work, work);
1346 struct rdma_id_private *id_priv = work->id; 1346 struct rdma_id_private *id_priv = work->id;
1347 int destroy = 0; 1347 int destroy = 0;
1348 1348
@@ -1373,7 +1373,7 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
1373 return -ENOMEM; 1373 return -ENOMEM;
1374 1374
1375 work->id = id_priv; 1375 work->id = id_priv;
1376 INIT_WORK(&work->work, cma_work_handler, work); 1376 INIT_WORK(&work->work, cma_work_handler);
1377 work->old_state = CMA_ROUTE_QUERY; 1377 work->old_state = CMA_ROUTE_QUERY;
1378 work->new_state = CMA_ROUTE_RESOLVED; 1378 work->new_state = CMA_ROUTE_RESOLVED;
1379 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1379 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1430,7 +1430,7 @@ static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
1430 return -ENOMEM; 1430 return -ENOMEM;
1431 1431
1432 work->id = id_priv; 1432 work->id = id_priv;
1433 INIT_WORK(&work->work, cma_work_handler, work); 1433 INIT_WORK(&work->work, cma_work_handler);
1434 work->old_state = CMA_ROUTE_QUERY; 1434 work->old_state = CMA_ROUTE_QUERY;
1435 work->new_state = CMA_ROUTE_RESOLVED; 1435 work->new_state = CMA_ROUTE_RESOLVED;
1436 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED; 1436 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
@@ -1583,7 +1583,7 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv)
1583 } 1583 }
1584 1584
1585 work->id = id_priv; 1585 work->id = id_priv;
1586 INIT_WORK(&work->work, cma_work_handler, work); 1586 INIT_WORK(&work->work, cma_work_handler);
1587 work->old_state = CMA_ADDR_QUERY; 1587 work->old_state = CMA_ADDR_QUERY;
1588 work->new_state = CMA_ADDR_RESOLVED; 1588 work->new_state = CMA_ADDR_RESOLVED;
1589 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED; 1589 work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c
index cf797d7aea09..1039ad57d53b 100644
--- a/drivers/infiniband/core/iwcm.c
+++ b/drivers/infiniband/core/iwcm.c
@@ -828,9 +828,9 @@ static int process_event(struct iwcm_id_private *cm_id_priv,
828 * thread asleep on the destroy_comp list vs. an object destroyed 828 * thread asleep on the destroy_comp list vs. an object destroyed
829 * here synchronously when the last reference is removed. 829 * here synchronously when the last reference is removed.
830 */ 830 */
831static void cm_work_handler(void *arg) 831static void cm_work_handler(struct work_struct *_work)
832{ 832{
833 struct iwcm_work *work = arg; 833 struct iwcm_work *work = container_of(_work, struct iwcm_work, work);
834 struct iw_cm_event levent; 834 struct iw_cm_event levent;
835 struct iwcm_id_private *cm_id_priv = work->cm_id; 835 struct iwcm_id_private *cm_id_priv = work->cm_id;
836 unsigned long flags; 836 unsigned long flags;
@@ -900,7 +900,7 @@ static int cm_event_handler(struct iw_cm_id *cm_id,
900 goto out; 900 goto out;
901 } 901 }
902 902
903 INIT_WORK(&work->work, cm_work_handler, work); 903 INIT_WORK(&work->work, cm_work_handler);
904 work->cm_id = cm_id_priv; 904 work->cm_id = cm_id_priv;
905 work->event = *iw_event; 905 work->event = *iw_event;
906 906
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 3f9c16232c4d..15f38d94b3a8 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -65,8 +65,8 @@ static struct ib_mad_agent_private *find_mad_agent(
65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info, 65static int ib_mad_post_receive_mads(struct ib_mad_qp_info *qp_info,
66 struct ib_mad_private *mad); 66 struct ib_mad_private *mad);
67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv); 67static void cancel_mads(struct ib_mad_agent_private *mad_agent_priv);
68static void timeout_sends(void *data); 68static void timeout_sends(struct work_struct *work);
69static void local_completions(void *data); 69static void local_completions(struct work_struct *work);
70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req, 70static int add_nonoui_reg_req(struct ib_mad_reg_req *mad_reg_req,
71 struct ib_mad_agent_private *agent_priv, 71 struct ib_mad_agent_private *agent_priv,
72 u8 mgmt_class); 72 u8 mgmt_class);
@@ -356,10 +356,9 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device,
356 INIT_LIST_HEAD(&mad_agent_priv->wait_list); 356 INIT_LIST_HEAD(&mad_agent_priv->wait_list);
357 INIT_LIST_HEAD(&mad_agent_priv->done_list); 357 INIT_LIST_HEAD(&mad_agent_priv->done_list);
358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list); 358 INIT_LIST_HEAD(&mad_agent_priv->rmpp_list);
359 INIT_WORK(&mad_agent_priv->timed_work, timeout_sends, mad_agent_priv); 359 INIT_DELAYED_WORK(&mad_agent_priv->timed_work, timeout_sends);
360 INIT_LIST_HEAD(&mad_agent_priv->local_list); 360 INIT_LIST_HEAD(&mad_agent_priv->local_list);
361 INIT_WORK(&mad_agent_priv->local_work, local_completions, 361 INIT_WORK(&mad_agent_priv->local_work, local_completions);
362 mad_agent_priv);
363 atomic_set(&mad_agent_priv->refcount, 1); 362 atomic_set(&mad_agent_priv->refcount, 1);
364 init_completion(&mad_agent_priv->comp); 363 init_completion(&mad_agent_priv->comp);
365 364
@@ -2198,12 +2197,12 @@ static void mad_error_handler(struct ib_mad_port_private *port_priv,
2198/* 2197/*
2199 * IB MAD completion callback 2198 * IB MAD completion callback
2200 */ 2199 */
2201static void ib_mad_completion_handler(void *data) 2200static void ib_mad_completion_handler(struct work_struct *work)
2202{ 2201{
2203 struct ib_mad_port_private *port_priv; 2202 struct ib_mad_port_private *port_priv;
2204 struct ib_wc wc; 2203 struct ib_wc wc;
2205 2204
2206 port_priv = (struct ib_mad_port_private *)data; 2205 port_priv = container_of(work, struct ib_mad_port_private, work);
2207 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP); 2206 ib_req_notify_cq(port_priv->cq, IB_CQ_NEXT_COMP);
2208 2207
2209 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) { 2208 while (ib_poll_cq(port_priv->cq, 1, &wc) == 1) {
@@ -2324,7 +2323,7 @@ void ib_cancel_mad(struct ib_mad_agent *mad_agent,
2324} 2323}
2325EXPORT_SYMBOL(ib_cancel_mad); 2324EXPORT_SYMBOL(ib_cancel_mad);
2326 2325
2327static void local_completions(void *data) 2326static void local_completions(struct work_struct *work)
2328{ 2327{
2329 struct ib_mad_agent_private *mad_agent_priv; 2328 struct ib_mad_agent_private *mad_agent_priv;
2330 struct ib_mad_local_private *local; 2329 struct ib_mad_local_private *local;
@@ -2334,7 +2333,8 @@ static void local_completions(void *data)
2334 struct ib_wc wc; 2333 struct ib_wc wc;
2335 struct ib_mad_send_wc mad_send_wc; 2334 struct ib_mad_send_wc mad_send_wc;
2336 2335
2337 mad_agent_priv = (struct ib_mad_agent_private *)data; 2336 mad_agent_priv =
2337 container_of(work, struct ib_mad_agent_private, local_work);
2338 2338
2339 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2339 spin_lock_irqsave(&mad_agent_priv->lock, flags);
2340 while (!list_empty(&mad_agent_priv->local_list)) { 2340 while (!list_empty(&mad_agent_priv->local_list)) {
@@ -2434,14 +2434,15 @@ static int retry_send(struct ib_mad_send_wr_private *mad_send_wr)
2434 return ret; 2434 return ret;
2435} 2435}
2436 2436
2437static void timeout_sends(void *data) 2437static void timeout_sends(struct work_struct *work)
2438{ 2438{
2439 struct ib_mad_agent_private *mad_agent_priv; 2439 struct ib_mad_agent_private *mad_agent_priv;
2440 struct ib_mad_send_wr_private *mad_send_wr; 2440 struct ib_mad_send_wr_private *mad_send_wr;
2441 struct ib_mad_send_wc mad_send_wc; 2441 struct ib_mad_send_wc mad_send_wc;
2442 unsigned long flags, delay; 2442 unsigned long flags, delay;
2443 2443
2444 mad_agent_priv = (struct ib_mad_agent_private *)data; 2444 mad_agent_priv = container_of(work, struct ib_mad_agent_private,
2445 timed_work.work);
2445 mad_send_wc.vendor_err = 0; 2446 mad_send_wc.vendor_err = 0;
2446 2447
2447 spin_lock_irqsave(&mad_agent_priv->lock, flags); 2448 spin_lock_irqsave(&mad_agent_priv->lock, flags);
@@ -2799,7 +2800,7 @@ static int ib_mad_port_open(struct ib_device *device,
2799 ret = -ENOMEM; 2800 ret = -ENOMEM;
2800 goto error8; 2801 goto error8;
2801 } 2802 }
2802 INIT_WORK(&port_priv->work, ib_mad_completion_handler, port_priv); 2803 INIT_WORK(&port_priv->work, ib_mad_completion_handler);
2803 2804
2804 spin_lock_irqsave(&ib_mad_port_list_lock, flags); 2805 spin_lock_irqsave(&ib_mad_port_list_lock, flags);
2805 list_add_tail(&port_priv->port_list, &ib_mad_port_list); 2806 list_add_tail(&port_priv->port_list, &ib_mad_port_list);
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index d06b59083f6e..d5548e73e068 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -102,7 +102,7 @@ struct ib_mad_agent_private {
102 struct list_head send_list; 102 struct list_head send_list;
103 struct list_head wait_list; 103 struct list_head wait_list;
104 struct list_head done_list; 104 struct list_head done_list;
105 struct work_struct timed_work; 105 struct delayed_work timed_work;
106 unsigned long timeout; 106 unsigned long timeout;
107 struct list_head local_list; 107 struct list_head local_list;
108 struct work_struct local_work; 108 struct work_struct local_work;
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index 1ef79d015a1e..3663fd7022be 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -45,8 +45,8 @@ enum rmpp_state {
45struct mad_rmpp_recv { 45struct mad_rmpp_recv {
46 struct ib_mad_agent_private *agent; 46 struct ib_mad_agent_private *agent;
47 struct list_head list; 47 struct list_head list;
48 struct work_struct timeout_work; 48 struct delayed_work timeout_work;
49 struct work_struct cleanup_work; 49 struct delayed_work cleanup_work;
50 struct completion comp; 50 struct completion comp;
51 enum rmpp_state state; 51 enum rmpp_state state;
52 spinlock_t lock; 52 spinlock_t lock;
@@ -233,9 +233,10 @@ static void nack_recv(struct ib_mad_agent_private *agent,
233 } 233 }
234} 234}
235 235
236static void recv_timeout_handler(void *data) 236static void recv_timeout_handler(struct work_struct *work)
237{ 237{
238 struct mad_rmpp_recv *rmpp_recv = data; 238 struct mad_rmpp_recv *rmpp_recv =
239 container_of(work, struct mad_rmpp_recv, timeout_work.work);
239 struct ib_mad_recv_wc *rmpp_wc; 240 struct ib_mad_recv_wc *rmpp_wc;
240 unsigned long flags; 241 unsigned long flags;
241 242
@@ -254,9 +255,10 @@ static void recv_timeout_handler(void *data)
254 ib_free_recv_mad(rmpp_wc); 255 ib_free_recv_mad(rmpp_wc);
255} 256}
256 257
257static void recv_cleanup_handler(void *data) 258static void recv_cleanup_handler(struct work_struct *work)
258{ 259{
259 struct mad_rmpp_recv *rmpp_recv = data; 260 struct mad_rmpp_recv *rmpp_recv =
261 container_of(work, struct mad_rmpp_recv, cleanup_work.work);
260 unsigned long flags; 262 unsigned long flags;
261 263
262 spin_lock_irqsave(&rmpp_recv->agent->lock, flags); 264 spin_lock_irqsave(&rmpp_recv->agent->lock, flags);
@@ -285,8 +287,8 @@ create_rmpp_recv(struct ib_mad_agent_private *agent,
285 287
286 rmpp_recv->agent = agent; 288 rmpp_recv->agent = agent;
287 init_completion(&rmpp_recv->comp); 289 init_completion(&rmpp_recv->comp);
288 INIT_WORK(&rmpp_recv->timeout_work, recv_timeout_handler, rmpp_recv); 290 INIT_DELAYED_WORK(&rmpp_recv->timeout_work, recv_timeout_handler);
289 INIT_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler, rmpp_recv); 291 INIT_DELAYED_WORK(&rmpp_recv->cleanup_work, recv_cleanup_handler);
290 spin_lock_init(&rmpp_recv->lock); 292 spin_lock_init(&rmpp_recv->lock);
291 rmpp_recv->state = RMPP_STATE_ACTIVE; 293 rmpp_recv->state = RMPP_STATE_ACTIVE;
292 atomic_set(&rmpp_recv->refcount, 1); 294 atomic_set(&rmpp_recv->refcount, 1);
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 1706d3c7e95e..e45afba75341 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -360,9 +360,10 @@ static void free_sm_ah(struct kref *kref)
360 kfree(sm_ah); 360 kfree(sm_ah);
361} 361}
362 362
363static void update_sm_ah(void *port_ptr) 363static void update_sm_ah(struct work_struct *work)
364{ 364{
365 struct ib_sa_port *port = port_ptr; 365 struct ib_sa_port *port =
366 container_of(work, struct ib_sa_port, update_task);
366 struct ib_sa_sm_ah *new_ah, *old_ah; 367 struct ib_sa_sm_ah *new_ah, *old_ah;
367 struct ib_port_attr port_attr; 368 struct ib_port_attr port_attr;
368 struct ib_ah_attr ah_attr; 369 struct ib_ah_attr ah_attr;
@@ -992,8 +993,7 @@ static void ib_sa_add_one(struct ib_device *device)
992 if (IS_ERR(sa_dev->port[i].agent)) 993 if (IS_ERR(sa_dev->port[i].agent))
993 goto err; 994 goto err;
994 995
995 INIT_WORK(&sa_dev->port[i].update_task, 996 INIT_WORK(&sa_dev->port[i].update_task, update_sm_ah);
996 update_sm_ah, &sa_dev->port[i]);
997 } 997 }
998 998
999 ib_set_client_data(device, &sa_client, sa_dev); 999 ib_set_client_data(device, &sa_client, sa_dev);
@@ -1010,7 +1010,7 @@ static void ib_sa_add_one(struct ib_device *device)
1010 goto err; 1010 goto err;
1011 1011
1012 for (i = 0; i <= e - s; ++i) 1012 for (i = 0; i <= e - s; ++i)
1013 update_sm_ah(&sa_dev->port[i]); 1013 update_sm_ah(&sa_dev->port[i].update_task);
1014 1014
1015 return; 1015 return;
1016 1016
diff --git a/drivers/infiniband/core/uverbs_mem.c b/drivers/infiniband/core/uverbs_mem.c
index efe147dbeb42..db12cc0841df 100644
--- a/drivers/infiniband/core/uverbs_mem.c
+++ b/drivers/infiniband/core/uverbs_mem.c
@@ -179,9 +179,10 @@ void ib_umem_release(struct ib_device *dev, struct ib_umem *umem)
179 up_write(&current->mm->mmap_sem); 179 up_write(&current->mm->mmap_sem);
180} 180}
181 181
182static void ib_umem_account(void *work_ptr) 182static void ib_umem_account(struct work_struct *_work)
183{ 183{
184 struct ib_umem_account_work *work = work_ptr; 184 struct ib_umem_account_work *work =
185 container_of(_work, struct ib_umem_account_work, work);
185 186
186 down_write(&work->mm->mmap_sem); 187 down_write(&work->mm->mmap_sem);
187 work->mm->locked_vm -= work->diff; 188 work->mm->locked_vm -= work->diff;
@@ -216,7 +217,7 @@ void ib_umem_release_on_close(struct ib_device *dev, struct ib_umem *umem)
216 return; 217 return;
217 } 218 }
218 219
219 INIT_WORK(&work->work, ib_umem_account, work); 220 INIT_WORK(&work->work, ib_umem_account);
220 work->mm = mm; 221 work->mm = mm;
221 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT; 222 work->diff = PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT;
222 223
diff --git a/drivers/infiniband/hw/ipath/ipath_user_pages.c b/drivers/infiniband/hw/ipath/ipath_user_pages.c
index 413754b1d8a2..8536aeb96af8 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ b/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -214,9 +214,10 @@ struct ipath_user_pages_work {
214 unsigned long num_pages; 214 unsigned long num_pages;
215}; 215};
216 216
217static void user_pages_account(void *ptr) 217static void user_pages_account(struct work_struct *_work)
218{ 218{
219 struct ipath_user_pages_work *work = ptr; 219 struct ipath_user_pages_work *work =
220 container_of(_work, struct ipath_user_pages_work, work);
220 221
221 down_write(&work->mm->mmap_sem); 222 down_write(&work->mm->mmap_sem);
222 work->mm->locked_vm -= work->num_pages; 223 work->mm->locked_vm -= work->num_pages;
@@ -242,7 +243,7 @@ void ipath_release_user_pages_on_close(struct page **p, size_t num_pages)
242 243
243 goto bail; 244 goto bail;
244 245
245 INIT_WORK(&work->work, user_pages_account, work); 246 INIT_WORK(&work->work, user_pages_account);
246 work->mm = mm; 247 work->mm = mm;
247 work->num_pages = num_pages; 248 work->num_pages = num_pages;
248 249
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index cd044ea2dfa4..e948158a28d9 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -57,7 +57,7 @@ static int catas_reset_disable;
57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644); 57module_param_named(catas_reset_disable, catas_reset_disable, int, 0644);
58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero"); 58MODULE_PARM_DESC(catas_reset_disable, "disable reset on catastrophic event if nonzero");
59 59
60static void catas_reset(void *work_ptr) 60static void catas_reset(struct work_struct *work)
61{ 61{
62 struct mthca_dev *dev, *tmpdev; 62 struct mthca_dev *dev, *tmpdev;
63 LIST_HEAD(tlist); 63 LIST_HEAD(tlist);
@@ -203,7 +203,7 @@ void mthca_stop_catas_poll(struct mthca_dev *dev)
203 203
204int __init mthca_catas_init(void) 204int __init mthca_catas_init(void)
205{ 205{
206 INIT_WORK(&catas_work, catas_reset, NULL); 206 INIT_WORK(&catas_work, catas_reset);
207 207
208 catas_wq = create_singlethread_workqueue("mthca_catas"); 208 catas_wq = create_singlethread_workqueue("mthca_catas");
209 if (!catas_wq) 209 if (!catas_wq)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index f2b61851a49c..99547996aba2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -136,11 +136,11 @@ struct ipoib_dev_priv {
136 struct list_head multicast_list; 136 struct list_head multicast_list;
137 struct rb_root multicast_tree; 137 struct rb_root multicast_tree;
138 138
139 struct work_struct pkey_task; 139 struct delayed_work pkey_task;
140 struct work_struct mcast_task; 140 struct delayed_work mcast_task;
141 struct work_struct flush_task; 141 struct work_struct flush_task;
142 struct work_struct restart_task; 142 struct work_struct restart_task;
143 struct work_struct ah_reap_task; 143 struct delayed_work ah_reap_task;
144 144
145 struct ib_device *ca; 145 struct ib_device *ca;
146 u8 port; 146 u8 port;
@@ -254,13 +254,13 @@ int ipoib_add_pkey_attr(struct net_device *dev);
254 254
255void ipoib_send(struct net_device *dev, struct sk_buff *skb, 255void ipoib_send(struct net_device *dev, struct sk_buff *skb,
256 struct ipoib_ah *address, u32 qpn); 256 struct ipoib_ah *address, u32 qpn);
257void ipoib_reap_ah(void *dev_ptr); 257void ipoib_reap_ah(struct work_struct *work);
258 258
259void ipoib_flush_paths(struct net_device *dev); 259void ipoib_flush_paths(struct net_device *dev);
260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 260struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
261 261
262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 262int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
263void ipoib_ib_dev_flush(void *dev); 263void ipoib_ib_dev_flush(struct work_struct *work);
264void ipoib_ib_dev_cleanup(struct net_device *dev); 264void ipoib_ib_dev_cleanup(struct net_device *dev);
265 265
266int ipoib_ib_dev_open(struct net_device *dev); 266int ipoib_ib_dev_open(struct net_device *dev);
@@ -271,10 +271,10 @@ int ipoib_ib_dev_stop(struct net_device *dev);
271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 271int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
272void ipoib_dev_cleanup(struct net_device *dev); 272void ipoib_dev_cleanup(struct net_device *dev);
273 273
274void ipoib_mcast_join_task(void *dev_ptr); 274void ipoib_mcast_join_task(struct work_struct *work);
275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb); 275void ipoib_mcast_send(struct net_device *dev, void *mgid, struct sk_buff *skb);
276 276
277void ipoib_mcast_restart_task(void *dev_ptr); 277void ipoib_mcast_restart_task(struct work_struct *work);
278int ipoib_mcast_start_thread(struct net_device *dev); 278int ipoib_mcast_start_thread(struct net_device *dev);
279int ipoib_mcast_stop_thread(struct net_device *dev, int flush); 279int ipoib_mcast_stop_thread(struct net_device *dev, int flush);
280 280
@@ -312,7 +312,7 @@ void ipoib_event(struct ib_event_handler *handler,
312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey); 312int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey);
313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey); 313int ipoib_vlan_delete(struct net_device *pdev, unsigned short pkey);
314 314
315void ipoib_pkey_poll(void *dev); 315void ipoib_pkey_poll(struct work_struct *work);
316int ipoib_pkey_dev_delay_open(struct net_device *dev); 316int ipoib_pkey_dev_delay_open(struct net_device *dev);
317 317
318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 318#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 8bf5e9ec7c95..f10fba5d3265 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -400,10 +400,11 @@ static void __ipoib_reap_ah(struct net_device *dev)
400 spin_unlock_irq(&priv->tx_lock); 400 spin_unlock_irq(&priv->tx_lock);
401} 401}
402 402
403void ipoib_reap_ah(void *dev_ptr) 403void ipoib_reap_ah(struct work_struct *work)
404{ 404{
405 struct net_device *dev = dev_ptr; 405 struct ipoib_dev_priv *priv =
406 struct ipoib_dev_priv *priv = netdev_priv(dev); 406 container_of(work, struct ipoib_dev_priv, ah_reap_task.work);
407 struct net_device *dev = priv->dev;
407 408
408 __ipoib_reap_ah(dev); 409 __ipoib_reap_ah(dev);
409 410
@@ -613,10 +614,11 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
613 return 0; 614 return 0;
614} 615}
615 616
616void ipoib_ib_dev_flush(void *_dev) 617void ipoib_ib_dev_flush(struct work_struct *work)
617{ 618{
618 struct net_device *dev = (struct net_device *)_dev; 619 struct ipoib_dev_priv *cpriv, *priv =
619 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv; 620 container_of(work, struct ipoib_dev_priv, flush_task);
621 struct net_device *dev = priv->dev;
620 622
621 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) { 623 if (!test_bit(IPOIB_FLAG_INITIALIZED, &priv->flags) ) {
622 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n"); 624 ipoib_dbg(priv, "Not flushing - IPOIB_FLAG_INITIALIZED not set.\n");
@@ -638,14 +640,14 @@ void ipoib_ib_dev_flush(void *_dev)
638 */ 640 */
639 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 641 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
640 ipoib_ib_dev_up(dev); 642 ipoib_ib_dev_up(dev);
641 ipoib_mcast_restart_task(dev); 643 ipoib_mcast_restart_task(&priv->restart_task);
642 } 644 }
643 645
644 mutex_lock(&priv->vlan_mutex); 646 mutex_lock(&priv->vlan_mutex);
645 647
646 /* Flush any child interfaces too */ 648 /* Flush any child interfaces too */
647 list_for_each_entry(cpriv, &priv->child_intfs, list) 649 list_for_each_entry(cpriv, &priv->child_intfs, list)
648 ipoib_ib_dev_flush(cpriv->dev); 650 ipoib_ib_dev_flush(&cpriv->flush_task);
649 651
650 mutex_unlock(&priv->vlan_mutex); 652 mutex_unlock(&priv->vlan_mutex);
651} 653}
@@ -672,10 +674,11 @@ void ipoib_ib_dev_cleanup(struct net_device *dev)
672 * change async notification is available. 674 * change async notification is available.
673 */ 675 */
674 676
675void ipoib_pkey_poll(void *dev_ptr) 677void ipoib_pkey_poll(struct work_struct *work)
676{ 678{
677 struct net_device *dev = dev_ptr; 679 struct ipoib_dev_priv *priv =
678 struct ipoib_dev_priv *priv = netdev_priv(dev); 680 container_of(work, struct ipoib_dev_priv, pkey_task.work);
681 struct net_device *dev = priv->dev;
679 682
680 ipoib_pkey_dev_check_presence(dev); 683 ipoib_pkey_dev_check_presence(dev);
681 684
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 5ba3154320b4..c09280243726 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -940,11 +940,11 @@ static void ipoib_setup(struct net_device *dev)
940 INIT_LIST_HEAD(&priv->dead_ahs); 940 INIT_LIST_HEAD(&priv->dead_ahs);
941 INIT_LIST_HEAD(&priv->multicast_list); 941 INIT_LIST_HEAD(&priv->multicast_list);
942 942
943 INIT_WORK(&priv->pkey_task, ipoib_pkey_poll, priv->dev); 943 INIT_DELAYED_WORK(&priv->pkey_task, ipoib_pkey_poll);
944 INIT_WORK(&priv->mcast_task, ipoib_mcast_join_task, priv->dev); 944 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
945 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush, priv->dev); 945 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush);
946 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task, priv->dev); 946 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
947 INIT_WORK(&priv->ah_reap_task, ipoib_reap_ah, priv->dev); 947 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
948} 948}
949 949
950struct ipoib_dev_priv *ipoib_intf_alloc(const char *name) 950struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d282d65e3ee0..b04b72ca32ed 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -399,7 +399,8 @@ static void ipoib_mcast_join_complete(int status,
399 mcast->backoff = 1; 399 mcast->backoff = 1;
400 mutex_lock(&mcast_mutex); 400 mutex_lock(&mcast_mutex);
401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) 401 if (test_bit(IPOIB_MCAST_RUN, &priv->flags))
402 queue_work(ipoib_workqueue, &priv->mcast_task); 402 queue_delayed_work(ipoib_workqueue,
403 &priv->mcast_task, 0);
403 mutex_unlock(&mcast_mutex); 404 mutex_unlock(&mcast_mutex);
404 complete(&mcast->done); 405 complete(&mcast->done);
405 return; 406 return;
@@ -435,7 +436,8 @@ static void ipoib_mcast_join_complete(int status,
435 436
436 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) { 437 if (test_bit(IPOIB_MCAST_RUN, &priv->flags)) {
437 if (status == -ETIMEDOUT) 438 if (status == -ETIMEDOUT)
438 queue_work(ipoib_workqueue, &priv->mcast_task); 439 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
440 0);
439 else 441 else
440 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 442 queue_delayed_work(ipoib_workqueue, &priv->mcast_task,
441 mcast->backoff * HZ); 443 mcast->backoff * HZ);
@@ -517,10 +519,11 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
517 mcast->query_id = ret; 519 mcast->query_id = ret;
518} 520}
519 521
520void ipoib_mcast_join_task(void *dev_ptr) 522void ipoib_mcast_join_task(struct work_struct *work)
521{ 523{
522 struct net_device *dev = dev_ptr; 524 struct ipoib_dev_priv *priv =
523 struct ipoib_dev_priv *priv = netdev_priv(dev); 525 container_of(work, struct ipoib_dev_priv, mcast_task.work);
526 struct net_device *dev = priv->dev;
524 527
525 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags)) 528 if (!test_bit(IPOIB_MCAST_RUN, &priv->flags))
526 return; 529 return;
@@ -610,7 +613,7 @@ int ipoib_mcast_start_thread(struct net_device *dev)
610 613
611 mutex_lock(&mcast_mutex); 614 mutex_lock(&mcast_mutex);
612 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags)) 615 if (!test_and_set_bit(IPOIB_MCAST_RUN, &priv->flags))
613 queue_work(ipoib_workqueue, &priv->mcast_task); 616 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0);
614 mutex_unlock(&mcast_mutex); 617 mutex_unlock(&mcast_mutex);
615 618
616 spin_lock_irq(&priv->lock); 619 spin_lock_irq(&priv->lock);
@@ -818,10 +821,11 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
818 } 821 }
819} 822}
820 823
821void ipoib_mcast_restart_task(void *dev_ptr) 824void ipoib_mcast_restart_task(struct work_struct *work)
822{ 825{
823 struct net_device *dev = dev_ptr; 826 struct ipoib_dev_priv *priv =
824 struct ipoib_dev_priv *priv = netdev_priv(dev); 827 container_of(work, struct ipoib_dev_priv, restart_task);
828 struct net_device *dev = priv->dev;
825 struct dev_mc_list *mclist; 829 struct dev_mc_list *mclist;
826 struct ipoib_mcast *mcast, *tmcast; 830 struct ipoib_mcast *mcast, *tmcast;
827 LIST_HEAD(remove_list); 831 LIST_HEAD(remove_list);
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index 18a000034996..693b77002897 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -48,7 +48,7 @@
48 48
49static void iser_cq_tasklet_fn(unsigned long data); 49static void iser_cq_tasklet_fn(unsigned long data);
50static void iser_cq_callback(struct ib_cq *cq, void *cq_context); 50static void iser_cq_callback(struct ib_cq *cq, void *cq_context);
51static void iser_comp_error_worker(void *data); 51static void iser_comp_error_worker(struct work_struct *work);
52 52
53static void iser_cq_event_callback(struct ib_event *cause, void *context) 53static void iser_cq_event_callback(struct ib_event *cause, void *context)
54{ 54{
@@ -480,8 +480,7 @@ int iser_conn_init(struct iser_conn **ibconn)
480 init_waitqueue_head(&ib_conn->wait); 480 init_waitqueue_head(&ib_conn->wait);
481 atomic_set(&ib_conn->post_recv_buf_count, 0); 481 atomic_set(&ib_conn->post_recv_buf_count, 0);
482 atomic_set(&ib_conn->post_send_buf_count, 0); 482 atomic_set(&ib_conn->post_send_buf_count, 0);
483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker, 483 INIT_WORK(&ib_conn->comperror_work, iser_comp_error_worker);
484 ib_conn);
485 INIT_LIST_HEAD(&ib_conn->conn_list); 484 INIT_LIST_HEAD(&ib_conn->conn_list);
486 spin_lock_init(&ib_conn->lock); 485 spin_lock_init(&ib_conn->lock);
487 486
@@ -754,9 +753,10 @@ int iser_post_send(struct iser_desc *tx_desc)
754 return ret_val; 753 return ret_val;
755} 754}
756 755
757static void iser_comp_error_worker(void *data) 756static void iser_comp_error_worker(struct work_struct *work)
758{ 757{
759 struct iser_conn *ib_conn = data; 758 struct iser_conn *ib_conn =
759 container_of(work, struct iser_conn, comperror_work);
760 760
761 /* getting here when the state is UP means that the conn is being * 761 /* getting here when the state is UP means that the conn is being *
762 * terminated asynchronously from the iSCSI layer's perspective. */ 762 * terminated asynchronously from the iSCSI layer's perspective. */
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 64ab5fc7cca3..a6289595557b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -390,9 +390,10 @@ static void srp_disconnect_target(struct srp_target_port *target)
390 wait_for_completion(&target->done); 390 wait_for_completion(&target->done);
391} 391}
392 392
393static void srp_remove_work(void *target_ptr) 393static void srp_remove_work(struct work_struct *work)
394{ 394{
395 struct srp_target_port *target = target_ptr; 395 struct srp_target_port *target =
396 container_of(work, struct srp_target_port, work);
396 397
397 spin_lock_irq(target->scsi_host->host_lock); 398 spin_lock_irq(target->scsi_host->host_lock);
398 if (target->state != SRP_TARGET_DEAD) { 399 if (target->state != SRP_TARGET_DEAD) {
@@ -575,7 +576,7 @@ err:
575 spin_lock_irq(target->scsi_host->host_lock); 576 spin_lock_irq(target->scsi_host->host_lock);
576 if (target->state == SRP_TARGET_CONNECTING) { 577 if (target->state == SRP_TARGET_CONNECTING) {
577 target->state = SRP_TARGET_DEAD; 578 target->state = SRP_TARGET_DEAD;
578 INIT_WORK(&target->work, srp_remove_work, target); 579 INIT_WORK(&target->work, srp_remove_work);
579 schedule_work(&target->work); 580 schedule_work(&target->work);
580 } 581 }
581 spin_unlock_irq(target->scsi_host->host_lock); 582 spin_unlock_irq(target->scsi_host->host_lock);
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index cbb93669d1ce..8451b29a3db5 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -567,9 +567,9 @@ static int atkbd_set_leds(struct atkbd *atkbd)
567 * interrupt context. 567 * interrupt context.
568 */ 568 */
569 569
570static void atkbd_event_work(void *data) 570static void atkbd_event_work(struct work_struct *work)
571{ 571{
572 struct atkbd *atkbd = data; 572 struct atkbd *atkbd = container_of(work, struct atkbd, event_work);
573 573
574 mutex_lock(&atkbd->event_mutex); 574 mutex_lock(&atkbd->event_mutex);
575 575
@@ -943,7 +943,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
943 943
944 atkbd->dev = dev; 944 atkbd->dev = dev;
945 ps2_init(&atkbd->ps2dev, serio); 945 ps2_init(&atkbd->ps2dev, serio);
946 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd); 946 INIT_WORK(&atkbd->event_work, atkbd_event_work);
947 mutex_init(&atkbd->event_mutex); 947 mutex_init(&atkbd->event_mutex);
948 948
949 switch (serio->id.type) { 949 switch (serio->id.type) {
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 979b93e33da7..b7f049b45b6b 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -572,9 +572,9 @@ lkkbd_event (struct input_dev *dev, unsigned int type, unsigned int code,
572 * were in. 572 * were in.
573 */ 573 */
574static void 574static void
575lkkbd_reinit (void *data) 575lkkbd_reinit (struct work_struct *work)
576{ 576{
577 struct lkkbd *lk = data; 577 struct lkkbd *lk = container_of(work, struct lkkbd, tq);
578 int division; 578 int division;
579 unsigned char leds_on = 0; 579 unsigned char leds_on = 0;
580 unsigned char leds_off = 0; 580 unsigned char leds_off = 0;
@@ -651,7 +651,7 @@ lkkbd_connect (struct serio *serio, struct serio_driver *drv)
651 651
652 lk->serio = serio; 652 lk->serio = serio;
653 lk->dev = input_dev; 653 lk->dev = input_dev;
654 INIT_WORK (&lk->tq, lkkbd_reinit, lk); 654 INIT_WORK (&lk->tq, lkkbd_reinit);
655 lk->bell_volume = bell_volume; 655 lk->bell_volume = bell_volume;
656 lk->keyclick_volume = keyclick_volume; 656 lk->keyclick_volume = keyclick_volume;
657 lk->ctrlclick_volume = ctrlclick_volume; 657 lk->ctrlclick_volume = ctrlclick_volume;
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c
index cac4781103c3..6cd887c5eb0a 100644
--- a/drivers/input/keyboard/sunkbd.c
+++ b/drivers/input/keyboard/sunkbd.c
@@ -208,9 +208,9 @@ static int sunkbd_initialize(struct sunkbd *sunkbd)
208 * were in. 208 * were in.
209 */ 209 */
210 210
211static void sunkbd_reinit(void *data) 211static void sunkbd_reinit(struct work_struct *work)
212{ 212{
213 struct sunkbd *sunkbd = data; 213 struct sunkbd *sunkbd = container_of(work, struct sunkbd, tq);
214 214
215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); 215 wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ);
216 216
@@ -248,7 +248,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv)
248 sunkbd->serio = serio; 248 sunkbd->serio = serio;
249 sunkbd->dev = input_dev; 249 sunkbd->dev = input_dev;
250 init_waitqueue_head(&sunkbd->wait); 250 init_waitqueue_head(&sunkbd->wait);
251 INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); 251 INIT_WORK(&sunkbd->tq, sunkbd_reinit);
252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); 252 snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys);
253 253
254 serio_set_drvdata(serio, sunkbd); 254 serio_set_drvdata(serio, sunkbd);
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 6f9b2c7cc9c2..52bb2226ce2f 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -888,9 +888,10 @@ static int psmouse_poll(struct psmouse *psmouse)
888 * psmouse_resync() attempts to re-validate current protocol. 888 * psmouse_resync() attempts to re-validate current protocol.
889 */ 889 */
890 890
891static void psmouse_resync(void *p) 891static void psmouse_resync(struct work_struct *work)
892{ 892{
893 struct psmouse *psmouse = p, *parent = NULL; 893 struct psmouse *parent = NULL, *psmouse =
894 container_of(work, struct psmouse, resync_work);
894 struct serio *serio = psmouse->ps2dev.serio; 895 struct serio *serio = psmouse->ps2dev.serio;
895 psmouse_ret_t rc = PSMOUSE_GOOD_DATA; 896 psmouse_ret_t rc = PSMOUSE_GOOD_DATA;
896 int failed = 0, enabled = 0; 897 int failed = 0, enabled = 0;
@@ -1121,7 +1122,7 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1121 goto out; 1122 goto out;
1122 1123
1123 ps2_init(&psmouse->ps2dev, serio); 1124 ps2_init(&psmouse->ps2dev, serio);
1124 INIT_WORK(&psmouse->resync_work, psmouse_resync, psmouse); 1125 INIT_WORK(&psmouse->resync_work, psmouse_resync);
1125 psmouse->dev = input_dev; 1126 psmouse->dev = input_dev;
1126 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys); 1127 snprintf(psmouse->phys, sizeof(psmouse->phys), "%s/input0", serio->phys);
1127 1128
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index e5b1b60757bb..b3e84d3bb7f7 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -251,9 +251,9 @@ EXPORT_SYMBOL(ps2_command);
251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.) 251 * ps2_schedule_command(), to a PS/2 device (keyboard, mouse, etc.)
252 */ 252 */
253 253
254static void ps2_execute_scheduled_command(void *data) 254static void ps2_execute_scheduled_command(struct work_struct *work)
255{ 255{
256 struct ps2work *ps2work = data; 256 struct ps2work *ps2work = container_of(work, struct ps2work, work);
257 257
258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command); 258 ps2_command(ps2work->ps2dev, ps2work->param, ps2work->command);
259 kfree(ps2work); 259 kfree(ps2work);
@@ -278,7 +278,7 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
278 ps2work->ps2dev = ps2dev; 278 ps2work->ps2dev = ps2dev;
279 ps2work->command = command; 279 ps2work->command = command;
280 memcpy(ps2work->param, param, send); 280 memcpy(ps2work->param, param, send);
281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command, ps2work); 281 INIT_WORK(&ps2work->work, ps2_execute_scheduled_command);
282 282
283 if (!schedule_work(&ps2work->work)) { 283 if (!schedule_work(&ps2work->work)) {
284 kfree(ps2work); 284 kfree(ps2work);
diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
index 6ae6eb322111..946c38cf6f8a 100644
--- a/drivers/isdn/act2000/capi.c
+++ b/drivers/isdn/act2000/capi.c
@@ -627,8 +627,10 @@ handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) {
627} 627}
628 628
629void 629void
630actcapi_dispatch(act2000_card *card) 630actcapi_dispatch(struct work_struct *work)
631{ 631{
632 struct act2000_card *card =
633 container_of(work, struct act2000_card, rcv_tq);
632 struct sk_buff *skb; 634 struct sk_buff *skb;
633 actcapi_msg *msg; 635 actcapi_msg *msg;
634 __u16 ccmd; 636 __u16 ccmd;
diff --git a/drivers/isdn/act2000/capi.h b/drivers/isdn/act2000/capi.h
index 49f453c53c64..e55f6a931f66 100644
--- a/drivers/isdn/act2000/capi.h
+++ b/drivers/isdn/act2000/capi.h
@@ -356,7 +356,7 @@ extern int actcapi_connect_req(act2000_card *, act2000_chan *, char *, char, int
356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *); 356extern void actcapi_select_b2_protocol_req(act2000_card *, act2000_chan *);
357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *); 357extern void actcapi_disconnect_b3_req(act2000_card *, act2000_chan *);
358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8); 358extern void actcapi_connect_resp(act2000_card *, act2000_chan *, __u8);
359extern void actcapi_dispatch(act2000_card *); 359extern void actcapi_dispatch(struct work_struct *);
360#ifdef DEBUG_MSG 360#ifdef DEBUG_MSG
361extern void actcapi_debug_msg(struct sk_buff *skb, int); 361extern void actcapi_debug_msg(struct sk_buff *skb, int);
362#else 362#else
diff --git a/drivers/isdn/act2000/module.c b/drivers/isdn/act2000/module.c
index d89dcde4eade..90593e2ef872 100644
--- a/drivers/isdn/act2000/module.c
+++ b/drivers/isdn/act2000/module.c
@@ -192,8 +192,11 @@ act2000_set_msn(act2000_card *card, char *eazmsn)
192} 192}
193 193
194static void 194static void
195act2000_transmit(struct act2000_card *card) 195act2000_transmit(struct work_struct *work)
196{ 196{
197 struct act2000_card *card =
198 container_of(work, struct act2000_card, snd_tq);
199
197 switch (card->bus) { 200 switch (card->bus) {
198 case ACT2000_BUS_ISA: 201 case ACT2000_BUS_ISA:
199 act2000_isa_send(card); 202 act2000_isa_send(card);
@@ -207,8 +210,11 @@ act2000_transmit(struct act2000_card *card)
207} 210}
208 211
209static void 212static void
210act2000_receive(struct act2000_card *card) 213act2000_receive(struct work_struct *work)
211{ 214{
215 struct act2000_card *card =
216 container_of(work, struct act2000_card, poll_tq);
217
212 switch (card->bus) { 218 switch (card->bus) {
213 case ACT2000_BUS_ISA: 219 case ACT2000_BUS_ISA:
214 act2000_isa_receive(card); 220 act2000_isa_receive(card);
@@ -227,7 +233,7 @@ act2000_poll(unsigned long data)
227 act2000_card * card = (act2000_card *)data; 233 act2000_card * card = (act2000_card *)data;
228 unsigned long flags; 234 unsigned long flags;
229 235
230 act2000_receive(card); 236 act2000_receive(&card->poll_tq);
231 spin_lock_irqsave(&card->lock, flags); 237 spin_lock_irqsave(&card->lock, flags);
232 mod_timer(&card->ptimer, jiffies+3); 238 mod_timer(&card->ptimer, jiffies+3);
233 spin_unlock_irqrestore(&card->lock, flags); 239 spin_unlock_irqrestore(&card->lock, flags);
@@ -578,9 +584,9 @@ act2000_alloccard(int bus, int port, int irq, char *id)
578 skb_queue_head_init(&card->sndq); 584 skb_queue_head_init(&card->sndq);
579 skb_queue_head_init(&card->rcvq); 585 skb_queue_head_init(&card->rcvq);
580 skb_queue_head_init(&card->ackq); 586 skb_queue_head_init(&card->ackq);
581 INIT_WORK(&card->snd_tq, (void *) (void *) act2000_transmit, card); 587 INIT_WORK(&card->snd_tq, act2000_transmit);
582 INIT_WORK(&card->rcv_tq, (void *) (void *) actcapi_dispatch, card); 588 INIT_WORK(&card->rcv_tq, actcapi_dispatch);
583 INIT_WORK(&card->poll_tq, (void *) (void *) act2000_receive, card); 589 INIT_WORK(&card->poll_tq, act2000_receive);
584 init_timer(&card->ptimer); 590 init_timer(&card->ptimer);
585 card->interface.owner = THIS_MODULE; 591 card->interface.owner = THIS_MODULE;
586 card->interface.channels = ACT2000_BCH; 592 card->interface.channels = ACT2000_BCH;
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index 8c4fcb9027b3..783a25526315 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -208,9 +208,10 @@ static void notify_down(u32 contr)
208 } 208 }
209} 209}
210 210
211static void notify_handler(void *data) 211static void notify_handler(struct work_struct *work)
212{ 212{
213 struct capi_notifier *np = data; 213 struct capi_notifier *np =
214 container_of(work, struct capi_notifier, work);
214 215
215 switch (np->cmd) { 216 switch (np->cmd) {
216 case KCI_CONTRUP: 217 case KCI_CONTRUP:
@@ -235,7 +236,7 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
235 if (!np) 236 if (!np)
236 return -ENOMEM; 237 return -ENOMEM;
237 238
238 INIT_WORK(&np->work, notify_handler, np); 239 INIT_WORK(&np->work, notify_handler);
239 np->cmd = cmd; 240 np->cmd = cmd;
240 np->controller = controller; 241 np->controller = controller;
241 np->applid = applid; 242 np->applid = applid;
@@ -248,10 +249,11 @@ static int notify_push(unsigned int cmd, u32 controller, u16 applid, u32 ncci)
248 249
249/* -------- Receiver ------------------------------------------ */ 250/* -------- Receiver ------------------------------------------ */
250 251
251static void recv_handler(void *_ap) 252static void recv_handler(struct work_struct *work)
252{ 253{
253 struct sk_buff *skb; 254 struct sk_buff *skb;
254 struct capi20_appl *ap = (struct capi20_appl *) _ap; 255 struct capi20_appl *ap =
256 container_of(work, struct capi20_appl, recv_work);
255 257
256 if ((!ap) || (ap->release_in_progress)) 258 if ((!ap) || (ap->release_in_progress))
257 return; 259 return;
@@ -527,7 +529,7 @@ u16 capi20_register(struct capi20_appl *ap)
527 ap->callback = NULL; 529 ap->callback = NULL;
528 init_MUTEX(&ap->recv_sem); 530 init_MUTEX(&ap->recv_sem);
529 skb_queue_head_init(&ap->recv_queue); 531 skb_queue_head_init(&ap->recv_queue);
530 INIT_WORK(&ap->recv_work, recv_handler, (void *)ap); 532 INIT_WORK(&ap->recv_work, recv_handler);
531 ap->release_in_progress = 0; 533 ap->release_in_progress = 0;
532 534
533 write_unlock_irqrestore(&application_lock, flags); 535 write_unlock_irqrestore(&application_lock, flags);
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 7bbfd85ab793..fd5d7364a487 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -194,41 +194,11 @@ static int avmcs_config(struct pcmcia_device *link)
194 194
195 dev = link->priv; 195 dev = link->priv;
196 196
197 /*
198 This reads the card's CONFIG tuple to find its configuration
199 registers.
200 */
201 do { 197 do {
202 tuple.DesiredTuple = CISTPL_CONFIG;
203 i = pcmcia_get_first_tuple(link, &tuple);
204 if (i != CS_SUCCESS) break;
205 tuple.TupleData = buf;
206 tuple.TupleDataMax = 64;
207 tuple.TupleOffset = 0;
208 i = pcmcia_get_tuple_data(link, &tuple);
209 if (i != CS_SUCCESS) break;
210 i = pcmcia_parse_tuple(link, &tuple, &parse);
211 if (i != CS_SUCCESS) break;
212 link->conf.ConfigBase = parse.config.base;
213 } while (0);
214 if (i != CS_SUCCESS) {
215 cs_error(link, ParseTuple, i);
216 return -ENODEV;
217 }
218
219 do {
220
221 tuple.Attributes = 0;
222 tuple.TupleData = buf;
223 tuple.TupleDataMax = 254;
224 tuple.TupleOffset = 0;
225 tuple.DesiredTuple = CISTPL_VERS_1;
226
227 devname[0] = 0; 198 devname[0] = 0;
228 if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 199 if (link->prod_id[1])
229 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 200 strlcpy(devname, link->prod_id[1], sizeof(devname));
230 sizeof(devname)); 201
231 }
232 /* 202 /*
233 * find IO port 203 * find IO port
234 */ 204 */
diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
index bec59010bc66..3b19caeba258 100644
--- a/drivers/isdn/hisax/amd7930_fn.c
+++ b/drivers/isdn/hisax/amd7930_fn.c
@@ -232,9 +232,10 @@ Amd7930_new_ph(struct IsdnCardState *cs)
232 232
233 233
234static void 234static void
235Amd7930_bh(struct IsdnCardState *cs) 235Amd7930_bh(struct work_struct *work)
236{ 236{
237 237 struct IsdnCardState *cs =
238 container_of(work, struct IsdnCardState, tqueue);
238 struct PStack *stptr; 239 struct PStack *stptr;
239 240
240 if (!cs) 241 if (!cs)
@@ -789,7 +790,7 @@ Amd7930_init(struct IsdnCardState *cs)
789void __devinit 790void __devinit
790setup_Amd7930(struct IsdnCardState *cs) 791setup_Amd7930(struct IsdnCardState *cs)
791{ 792{
792 INIT_WORK(&cs->tqueue, (void *)(void *) Amd7930_bh, cs); 793 INIT_WORK(&cs->tqueue, Amd7930_bh);
793 cs->dbusytimer.function = (void *) dbusy_timer_handler; 794 cs->dbusytimer.function = (void *) dbusy_timer_handler;
794 cs->dbusytimer.data = (long) cs; 795 cs->dbusytimer.data = (long) cs;
795 init_timer(&cs->dbusytimer); 796 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index ac28e3278ad9..876fec6c6be8 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -216,41 +216,11 @@ static int avma1cs_config(struct pcmcia_device *link)
216 216
217 DEBUG(0, "avma1cs_config(0x%p)\n", link); 217 DEBUG(0, "avma1cs_config(0x%p)\n", link);
218 218
219 /*
220 This reads the card's CONFIG tuple to find its configuration
221 registers.
222 */
223 do { 219 do {
224 tuple.DesiredTuple = CISTPL_CONFIG;
225 i = pcmcia_get_first_tuple(link, &tuple);
226 if (i != CS_SUCCESS) break;
227 tuple.TupleData = buf;
228 tuple.TupleDataMax = 64;
229 tuple.TupleOffset = 0;
230 i = pcmcia_get_tuple_data(link, &tuple);
231 if (i != CS_SUCCESS) break;
232 i = pcmcia_parse_tuple(link, &tuple, &parse);
233 if (i != CS_SUCCESS) break;
234 link->conf.ConfigBase = parse.config.base;
235 } while (0);
236 if (i != CS_SUCCESS) {
237 cs_error(link, ParseTuple, i);
238 return -ENODEV;
239 }
240
241 do {
242
243 tuple.Attributes = 0;
244 tuple.TupleData = buf;
245 tuple.TupleDataMax = 254;
246 tuple.TupleOffset = 0;
247 tuple.DesiredTuple = CISTPL_VERS_1;
248
249 devname[0] = 0; 220 devname[0] = 0;
250 if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 221 if (link->prod_id[1])
251 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 222 strlcpy(devname, link->prod_id[1], sizeof(devname));
252 sizeof(devname)); 223
253 }
254 /* 224 /*
255 * find IO port 225 * find IO port
256 */ 226 */
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index 785b08554fca..cede72cdbb31 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -1137,7 +1137,6 @@ static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockow
1137 cs->tx_skb = NULL; 1137 cs->tx_skb = NULL;
1138 cs->tx_cnt = 0; 1138 cs->tx_cnt = 0;
1139 cs->event = 0; 1139 cs->event = 0;
1140 cs->tqueue.data = cs;
1141 1140
1142 skb_queue_head_init(&cs->rq); 1141 skb_queue_head_init(&cs->rq);
1143 skb_queue_head_init(&cs->sq); 1142 skb_queue_head_init(&cs->sq);
@@ -1554,7 +1553,7 @@ static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1554static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg); 1553static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1555static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs); 1554static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1556static void hisax_bc_close(struct BCState *bcs); 1555static void hisax_bc_close(struct BCState *bcs);
1557static void hisax_bh(struct IsdnCardState *cs); 1556static void hisax_bh(struct work_struct *work);
1558static void EChannel_proc_rcv(struct hisax_d_if *d_if); 1557static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1559 1558
1560int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[], 1559int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
@@ -1586,7 +1585,7 @@ int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1586 hisax_d_if->cs = cs; 1585 hisax_d_if->cs = cs;
1587 cs->hw.hisax_d_if = hisax_d_if; 1586 cs->hw.hisax_d_if = hisax_d_if;
1588 cs->cardmsg = hisax_cardmsg; 1587 cs->cardmsg = hisax_cardmsg;
1589 INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs); 1588 INIT_WORK(&cs->tqueue, hisax_bh);
1590 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1; 1589 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1591 for (i = 0; i < 2; i++) { 1590 for (i = 0; i < 2; i++) {
1592 cs->bcs[i].BC_SetStack = hisax_bc_setstack; 1591 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
@@ -1618,8 +1617,10 @@ static void hisax_sched_event(struct IsdnCardState *cs, int event)
1618 schedule_work(&cs->tqueue); 1617 schedule_work(&cs->tqueue);
1619} 1618}
1620 1619
1621static void hisax_bh(struct IsdnCardState *cs) 1620static void hisax_bh(struct work_struct *work)
1622{ 1621{
1622 struct IsdnCardState *cs =
1623 container_of(work, struct IsdnCardState, tqueue);
1623 struct PStack *st; 1624 struct PStack *st;
1624 int pr; 1625 int pr;
1625 1626
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index e18e75be8ed3..4e180d210faa 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -242,23 +242,6 @@ static int elsa_cs_config(struct pcmcia_device *link)
242 DEBUG(0, "elsa_config(0x%p)\n", link); 242 DEBUG(0, "elsa_config(0x%p)\n", link);
243 dev = link->priv; 243 dev = link->priv;
244 244
245 /*
246 This reads the card's CONFIG tuple to find its configuration
247 registers.
248 */
249 tuple.DesiredTuple = CISTPL_CONFIG;
250 tuple.TupleData = (cisdata_t *)buf;
251 tuple.TupleDataMax = 255;
252 tuple.TupleOffset = 0;
253 tuple.Attributes = 0;
254 i = first_tuple(link, &tuple, &parse);
255 if (i != CS_SUCCESS) {
256 last_fn = ParseTuple;
257 goto cs_failed;
258 }
259 link->conf.ConfigBase = parse.config.base;
260 link->conf.Present = parse.config.rmask[0];
261
262 tuple.TupleData = (cisdata_t *)buf; 245 tuple.TupleData = (cisdata_t *)buf;
263 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 246 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
264 tuple.Attributes = 0; 247 tuple.Attributes = 0;
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c
index d852c9d998b2..de9b1a4d6bac 100644
--- a/drivers/isdn/hisax/hfc4s8s_l1.c
+++ b/drivers/isdn/hisax/hfc4s8s_l1.c
@@ -1083,8 +1083,9 @@ tx_b_frame(struct hfc4s8s_btype *bch)
1083/* bottom half handler for interrupt */ 1083/* bottom half handler for interrupt */
1084/*************************************/ 1084/*************************************/
1085static void 1085static void
1086hfc4s8s_bh(hfc4s8s_hw * hw) 1086hfc4s8s_bh(struct work_struct *work)
1087{ 1087{
1088 hfc4s8s_hw *hw = container_of(work, hfc4s8s_hw, tqueue);
1088 u_char b; 1089 u_char b;
1089 struct hfc4s8s_l1 *l1p; 1090 struct hfc4s8s_l1 *l1p;
1090 volatile u_char *fifo_stat; 1091 volatile u_char *fifo_stat;
@@ -1550,7 +1551,7 @@ setup_instance(hfc4s8s_hw * hw)
1550 goto out; 1551 goto out;
1551 } 1552 }
1552 1553
1553 INIT_WORK(&hw->tqueue, (void *) (void *) hfc4s8s_bh, hw); 1554 INIT_WORK(&hw->tqueue, hfc4s8s_bh);
1554 1555
1555 if (request_irq 1556 if (request_irq
1556 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) { 1557 (hw->irq, hfc4s8s_interrupt, IRQF_SHARED, hw->card_name, hw)) {
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c
index 6360e8214720..8d9864453a23 100644
--- a/drivers/isdn/hisax/hfc_2bds0.c
+++ b/drivers/isdn/hisax/hfc_2bds0.c
@@ -549,10 +549,11 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
549} 549}
550 550
551static void 551static void
552hfcd_bh(struct IsdnCardState *cs) 552hfcd_bh(struct work_struct *work)
553{ 553{
554 if (!cs) 554 struct IsdnCardState *cs =
555 return; 555 container_of(work, struct IsdnCardState, tqueue);
556
556 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) { 557 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
557 switch (cs->dc.hfcd.ph_state) { 558 switch (cs->dc.hfcd.ph_state) {
558 case (0): 559 case (0):
@@ -1072,5 +1073,5 @@ set_cs_func(struct IsdnCardState *cs)
1072 cs->dbusytimer.function = (void *) hfc_dbusy_timer; 1073 cs->dbusytimer.function = (void *) hfc_dbusy_timer;
1073 cs->dbusytimer.data = (long) cs; 1074 cs->dbusytimer.data = (long) cs;
1074 init_timer(&cs->dbusytimer); 1075 init_timer(&cs->dbusytimer);
1075 INIT_WORK(&cs->tqueue, (void *)(void *) hfcd_bh, cs); 1076 INIT_WORK(&cs->tqueue, hfcd_bh);
1076} 1077}
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
index 93f60b563515..5db0a85b827f 100644
--- a/drivers/isdn/hisax/hfc_pci.c
+++ b/drivers/isdn/hisax/hfc_pci.c
@@ -1506,8 +1506,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1506/* handle L1 state changes */ 1506/* handle L1 state changes */
1507/***************************/ 1507/***************************/
1508static void 1508static void
1509hfcpci_bh(struct IsdnCardState *cs) 1509hfcpci_bh(struct work_struct *work)
1510{ 1510{
1511 struct IsdnCardState *cs =
1512 container_of(work, struct IsdnCardState, tqueue);
1511 u_long flags; 1513 u_long flags;
1512// struct PStack *stptr; 1514// struct PStack *stptr;
1513 1515
@@ -1722,7 +1724,7 @@ setup_hfcpci(struct IsdnCard *card)
1722 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); 1724 Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
1723 /* At this point the needed PCI config is done */ 1725 /* At this point the needed PCI config is done */
1724 /* fifos are still not enabled */ 1726 /* fifos are still not enabled */
1725 INIT_WORK(&cs->tqueue, (void *)(void *) hfcpci_bh, cs); 1727 INIT_WORK(&cs->tqueue, hfcpci_bh);
1726 cs->setstack_d = setstack_hfcpci; 1728 cs->setstack_d = setstack_hfcpci;
1727 cs->BC_Send_Data = &hfcpci_send_data; 1729 cs->BC_Send_Data = &hfcpci_send_data;
1728 cs->readisac = NULL; 1730 cs->readisac = NULL;
diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
index 954d1536db1f..4fd09d21a27f 100644
--- a/drivers/isdn/hisax/hfc_sx.c
+++ b/drivers/isdn/hisax/hfc_sx.c
@@ -1251,8 +1251,10 @@ setstack_2b(struct PStack *st, struct BCState *bcs)
1251/* handle L1 state changes */ 1251/* handle L1 state changes */
1252/***************************/ 1252/***************************/
1253static void 1253static void
1254hfcsx_bh(struct IsdnCardState *cs) 1254hfcsx_bh(struct work_struct *work)
1255{ 1255{
1256 struct IsdnCardState *cs =
1257 container_of(work, struct IsdnCardState, tqueue);
1256 u_long flags; 1258 u_long flags;
1257 1259
1258 if (!cs) 1260 if (!cs)
@@ -1499,7 +1501,7 @@ setup_hfcsx(struct IsdnCard *card)
1499 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer; 1501 cs->dbusytimer.function = (void *) hfcsx_dbusy_timer;
1500 cs->dbusytimer.data = (long) cs; 1502 cs->dbusytimer.data = (long) cs;
1501 init_timer(&cs->dbusytimer); 1503 init_timer(&cs->dbusytimer);
1502 INIT_WORK(&cs->tqueue, (void *)(void *) hfcsx_bh, cs); 1504 INIT_WORK(&cs->tqueue, hfcsx_bh);
1503 cs->readisac = NULL; 1505 cs->readisac = NULL;
1504 cs->writeisac = NULL; 1506 cs->writeisac = NULL;
1505 cs->readisacfifo = NULL; 1507 cs->readisacfifo = NULL;
diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
index da706925d54d..682cac32f259 100644
--- a/drivers/isdn/hisax/icc.c
+++ b/drivers/isdn/hisax/icc.c
@@ -77,8 +77,10 @@ icc_new_ph(struct IsdnCardState *cs)
77} 77}
78 78
79static void 79static void
80icc_bh(struct IsdnCardState *cs) 80icc_bh(struct work_struct *work)
81{ 81{
82 struct IsdnCardState *cs =
83 container_of(work, struct IsdnCardState, tqueue);
82 struct PStack *stptr; 84 struct PStack *stptr;
83 85
84 if (!cs) 86 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_icc_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_icc(struct IsdnCardState *cs) 677setup_icc(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) icc_bh, cs); 679 INIT_WORK(&cs->tqueue, icc_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
index 282f349408bc..4e9f23803dae 100644
--- a/drivers/isdn/hisax/isac.c
+++ b/drivers/isdn/hisax/isac.c
@@ -81,8 +81,10 @@ isac_new_ph(struct IsdnCardState *cs)
81} 81}
82 82
83static void 83static void
84isac_bh(struct IsdnCardState *cs) 84isac_bh(struct work_struct *work)
85{ 85{
86 struct IsdnCardState *cs =
87 container_of(work, struct IsdnCardState, tqueue);
86 struct PStack *stptr; 88 struct PStack *stptr;
87 89
88 if (!cs) 90 if (!cs)
@@ -674,7 +676,7 @@ clear_pending_isac_ints(struct IsdnCardState *cs)
674void __devinit 676void __devinit
675setup_isac(struct IsdnCardState *cs) 677setup_isac(struct IsdnCardState *cs)
676{ 678{
677 INIT_WORK(&cs->tqueue, (void *)(void *) isac_bh, cs); 679 INIT_WORK(&cs->tqueue, isac_bh);
678 cs->dbusytimer.function = (void *) dbusy_timer_handler; 680 cs->dbusytimer.function = (void *) dbusy_timer_handler;
679 cs->dbusytimer.data = (long) cs; 681 cs->dbusytimer.data = (long) cs;
680 init_timer(&cs->dbusytimer); 682 init_timer(&cs->dbusytimer);
diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
index 674af673ff96..6f1a6583b17d 100644
--- a/drivers/isdn/hisax/isar.c
+++ b/drivers/isdn/hisax/isar.c
@@ -437,8 +437,10 @@ extern void BChannel_bh(struct BCState *);
437#define B_LL_OK 10 437#define B_LL_OK 10
438 438
439static void 439static void
440isar_bh(struct BCState *bcs) 440isar_bh(struct work_struct *work)
441{ 441{
442 struct BCState *bcs = container_of(work, struct BCState, tqueue);
443
442 BChannel_bh(bcs); 444 BChannel_bh(bcs);
443 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event)) 445 if (test_and_clear_bit(B_LL_NOCARRIER, &bcs->event))
444 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR); 446 ll_deliver_faxstat(bcs, ISDN_FAX_CLASS1_NOCARR);
@@ -1580,7 +1582,7 @@ isar_setup(struct IsdnCardState *cs)
1580 cs->bcs[i].mode = 0; 1582 cs->bcs[i].mode = 0;
1581 cs->bcs[i].hw.isar.dpath = i + 1; 1583 cs->bcs[i].hw.isar.dpath = i + 1;
1582 modeisar(&cs->bcs[i], 0, 0); 1584 modeisar(&cs->bcs[i], 0, 0);
1583 INIT_WORK(&cs->bcs[i].tqueue, (void *)(void *) isar_bh, &cs->bcs[i]); 1585 INIT_WORK(&cs->bcs[i].tqueue, isar_bh);
1584 } 1586 }
1585} 1587}
1586 1588
diff --git a/drivers/isdn/hisax/isdnl1.c b/drivers/isdn/hisax/isdnl1.c
index bab356886483..a14204ec88ee 100644
--- a/drivers/isdn/hisax/isdnl1.c
+++ b/drivers/isdn/hisax/isdnl1.c
@@ -315,8 +315,10 @@ BChannel_proc_ack(struct BCState *bcs)
315} 315}
316 316
317void 317void
318BChannel_bh(struct BCState *bcs) 318BChannel_bh(struct work_struct *work)
319{ 319{
320 struct BCState *bcs = container_of(work, struct BCState, tqueue);
321
320 if (!bcs) 322 if (!bcs)
321 return; 323 return;
322 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event)) 324 if (test_and_clear_bit(B_RCVBUFREADY, &bcs->event))
@@ -362,7 +364,7 @@ init_bcstate(struct IsdnCardState *cs, int bc)
362 364
363 bcs->cs = cs; 365 bcs->cs = cs;
364 bcs->channel = bc; 366 bcs->channel = bc;
365 INIT_WORK(&bcs->tqueue, (void *)(void *) BChannel_bh, bcs); 367 INIT_WORK(&bcs->tqueue, BChannel_bh);
366 spin_lock_init(&bcs->aclock); 368 spin_lock_init(&bcs->aclock);
367 bcs->BC_SetStack = NULL; 369 bcs->BC_SetStack = NULL;
368 bcs->BC_Close = NULL; 370 bcs->BC_Close = NULL;
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index f9c14a2970bc..46ed65334c51 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -233,20 +233,10 @@ static int sedlbauer_config(struct pcmcia_device *link)
233 233
234 DEBUG(0, "sedlbauer_config(0x%p)\n", link); 234 DEBUG(0, "sedlbauer_config(0x%p)\n", link);
235 235
236 /*
237 This reads the card's CONFIG tuple to find its configuration
238 registers.
239 */
240 tuple.DesiredTuple = CISTPL_CONFIG;
241 tuple.Attributes = 0; 236 tuple.Attributes = 0;
242 tuple.TupleData = buf; 237 tuple.TupleData = buf;
243 tuple.TupleDataMax = sizeof(buf); 238 tuple.TupleDataMax = sizeof(buf);
244 tuple.TupleOffset = 0; 239 tuple.TupleOffset = 0;
245 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
246 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
247 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
248 link->conf.ConfigBase = parse.config.base;
249 link->conf.Present = parse.config.rmask[0];
250 240
251 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 241 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));
252 242
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index afcc2aeadb34..6b754f183796 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -232,23 +232,6 @@ static int teles_cs_config(struct pcmcia_device *link)
232 DEBUG(0, "teles_config(0x%p)\n", link); 232 DEBUG(0, "teles_config(0x%p)\n", link);
233 dev = link->priv; 233 dev = link->priv;
234 234
235 /*
236 This reads the card's CONFIG tuple to find its configuration
237 registers.
238 */
239 tuple.DesiredTuple = CISTPL_CONFIG;
240 tuple.TupleData = (cisdata_t *)buf;
241 tuple.TupleDataMax = 255;
242 tuple.TupleOffset = 0;
243 tuple.Attributes = 0;
244 i = first_tuple(link, &tuple, &parse);
245 if (i != CS_SUCCESS) {
246 last_fn = ParseTuple;
247 goto cs_failed;
248 }
249 link->conf.ConfigBase = parse.config.base;
250 link->conf.Present = parse.config.rmask[0];
251
252 tuple.TupleData = (cisdata_t *)buf; 235 tuple.TupleData = (cisdata_t *)buf;
253 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 236 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
254 tuple.Attributes = 0; 237 tuple.Attributes = 0;
diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
index 1655341797a9..3aeceaf9769e 100644
--- a/drivers/isdn/hisax/w6692.c
+++ b/drivers/isdn/hisax/w6692.c
@@ -101,8 +101,10 @@ W6692_new_ph(struct IsdnCardState *cs)
101} 101}
102 102
103static void 103static void
104W6692_bh(struct IsdnCardState *cs) 104W6692_bh(struct work_struct *work)
105{ 105{
106 struct IsdnCardState *cs =
107 container_of(work, struct IsdnCardState, tqueue);
106 struct PStack *stptr; 108 struct PStack *stptr;
107 109
108 if (!cs) 110 if (!cs)
@@ -1070,7 +1072,7 @@ setup_w6692(struct IsdnCard *card)
1070 id_list[cs->subtyp].card_name, cs->irq, 1072 id_list[cs->subtyp].card_name, cs->irq,
1071 cs->hw.w6692.iobase); 1073 cs->hw.w6692.iobase);
1072 1074
1073 INIT_WORK(&cs->tqueue, (void *)(void *) W6692_bh, cs); 1075 INIT_WORK(&cs->tqueue, W6692_bh);
1074 cs->readW6692 = &ReadW6692; 1076 cs->readW6692 = &ReadW6692;
1075 cs->writeW6692 = &WriteW6692; 1077 cs->writeW6692 = &WriteW6692;
1076 cs->readisacfifo = &ReadISACfifo; 1078 cs->readisacfifo = &ReadISACfifo;
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 82e42a80dc4b..a1206498a1cf 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -71,8 +71,9 @@ ergo_interrupt(int intno, void *dev_id)
71/* may be queued from everywhere (interrupts included). */ 71/* may be queued from everywhere (interrupts included). */
72/******************************************************************************/ 72/******************************************************************************/
73static void 73static void
74ergo_irq_bh(hysdn_card * card) 74ergo_irq_bh(struct work_struct *ugli_api)
75{ 75{
76 hysdn_card * card = container_of(ugli_api, hysdn_card, irq_queue);
76 tErgDpram *dpr; 77 tErgDpram *dpr;
77 int again; 78 int again;
78 unsigned long flags; 79 unsigned long flags;
@@ -442,7 +443,7 @@ ergo_inithardware(hysdn_card * card)
442 card->writebootseq = ergo_writebootseq; 443 card->writebootseq = ergo_writebootseq;
443 card->waitpofready = ergo_waitpofready; 444 card->waitpofready = ergo_waitpofready;
444 card->set_errlog_state = ergo_set_errlog_state; 445 card->set_errlog_state = ergo_set_errlog_state;
445 INIT_WORK(&card->irq_queue, (void *) (void *) ergo_irq_bh, card); 446 INIT_WORK(&card->irq_queue, ergo_irq_bh);
446 card->hysdn_lock = SPIN_LOCK_UNLOCKED; 447 card->hysdn_lock = SPIN_LOCK_UNLOCKED;
447 448
448 return (0); 449 return (0);
diff --git a/drivers/isdn/i4l/isdn_net.c b/drivers/isdn/i4l/isdn_net.c
index 1f8d6ae66b41..2e4daebfb7e0 100644
--- a/drivers/isdn/i4l/isdn_net.c
+++ b/drivers/isdn/i4l/isdn_net.c
@@ -984,9 +984,9 @@ void isdn_net_write_super(isdn_net_local *lp, struct sk_buff *skb)
984/* 984/*
985 * called from tq_immediate 985 * called from tq_immediate
986 */ 986 */
987static void isdn_net_softint(void *private) 987static void isdn_net_softint(struct work_struct *work)
988{ 988{
989 isdn_net_local *lp = private; 989 isdn_net_local *lp = container_of(work, isdn_net_local, tqueue);
990 struct sk_buff *skb; 990 struct sk_buff *skb;
991 991
992 spin_lock_bh(&lp->xmit_lock); 992 spin_lock_bh(&lp->xmit_lock);
@@ -2596,7 +2596,7 @@ isdn_net_new(char *name, struct net_device *master)
2596 netdev->local->netdev = netdev; 2596 netdev->local->netdev = netdev;
2597 netdev->local->next = netdev->local; 2597 netdev->local->next = netdev->local;
2598 2598
2599 INIT_WORK(&netdev->local->tqueue, (void *)(void *) isdn_net_softint, netdev->local); 2599 INIT_WORK(&netdev->local->tqueue, isdn_net_softint);
2600 spin_lock_init(&netdev->local->xmit_lock); 2600 spin_lock_init(&netdev->local->xmit_lock);
2601 2601
2602 netdev->local->isdn_device = -1; 2602 netdev->local->isdn_device = -1;
diff --git a/drivers/isdn/pcbit/drv.c b/drivers/isdn/pcbit/drv.c
index 6ead5e1508b7..1966f3410a13 100644
--- a/drivers/isdn/pcbit/drv.c
+++ b/drivers/isdn/pcbit/drv.c
@@ -68,8 +68,6 @@ static void pcbit_set_msn(struct pcbit_dev *dev, char *list);
68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn); 68static int pcbit_check_msn(struct pcbit_dev *dev, char *msn);
69 69
70 70
71extern void pcbit_deliver(void * data);
72
73int pcbit_init_dev(int board, int mem_base, int irq) 71int pcbit_init_dev(int board, int mem_base, int irq)
74{ 72{
75 struct pcbit_dev *dev; 73 struct pcbit_dev *dev;
@@ -129,7 +127,7 @@ int pcbit_init_dev(int board, int mem_base, int irq)
129 memset(dev->b2, 0, sizeof(struct pcbit_chan)); 127 memset(dev->b2, 0, sizeof(struct pcbit_chan));
130 dev->b2->id = 1; 128 dev->b2->id = 1;
131 129
132 INIT_WORK(&dev->qdelivery, pcbit_deliver, dev); 130 INIT_WORK(&dev->qdelivery, pcbit_deliver);
133 131
134 /* 132 /*
135 * interrupts 133 * interrupts
diff --git a/drivers/isdn/pcbit/layer2.c b/drivers/isdn/pcbit/layer2.c
index 937fd2120381..0c9f6df873fc 100644
--- a/drivers/isdn/pcbit/layer2.c
+++ b/drivers/isdn/pcbit/layer2.c
@@ -67,7 +67,6 @@ extern void pcbit_l3_receive(struct pcbit_dev *dev, ulong msg,
67 * Prototypes 67 * Prototypes
68 */ 68 */
69 69
70void pcbit_deliver(void *data);
71static void pcbit_transmit(struct pcbit_dev *dev); 70static void pcbit_transmit(struct pcbit_dev *dev);
72 71
73static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack); 72static void pcbit_recv_ack(struct pcbit_dev *dev, unsigned char ack);
@@ -299,11 +298,12 @@ pcbit_transmit(struct pcbit_dev *dev)
299 */ 298 */
300 299
301void 300void
302pcbit_deliver(void *data) 301pcbit_deliver(struct work_struct *work)
303{ 302{
304 struct frame_buf *frame; 303 struct frame_buf *frame;
305 unsigned long flags, msg; 304 unsigned long flags, msg;
306 struct pcbit_dev *dev = (struct pcbit_dev *) data; 305 struct pcbit_dev *dev =
306 container_of(work, struct pcbit_dev, qdelivery);
307 307
308 spin_lock_irqsave(&dev->lock, flags); 308 spin_lock_irqsave(&dev->lock, flags);
309 309
diff --git a/drivers/isdn/pcbit/pcbit.h b/drivers/isdn/pcbit/pcbit.h
index 388bacefd23a..19c18e88ff16 100644
--- a/drivers/isdn/pcbit/pcbit.h
+++ b/drivers/isdn/pcbit/pcbit.h
@@ -166,4 +166,6 @@ struct pcbit_ioctl {
166#define L2_RUNNING 5 166#define L2_RUNNING 5
167#define L2_ERROR 6 167#define L2_ERROR 6
168 168
169extern void pcbit_deliver(struct work_struct *work);
170
169#endif 171#endif
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 7f8477d3a661..92ccee85e2a2 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -228,4 +228,11 @@ config ANSLCD
228 tristate "Support for ANS LCD display" 228 tristate "Support for ANS LCD display"
229 depends on ADB_CUDA && PPC_PMAC 229 depends on ADB_CUDA && PPC_PMAC
230 230
231config PMAC_RACKMETER
232 tristate "Support for Apple XServe front panel LEDs"
233 depends on PPC_PMAC
234 help
235 This driver procides some support to control the front panel
236 blue LEDs "vu-meter" of the XServer macs.
237
231endmenu 238endmenu
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
index b53d45f87b0b..2dfc3f4eaf42 100644
--- a/drivers/macintosh/Makefile
+++ b/drivers/macintosh/Makefile
@@ -42,3 +42,4 @@ obj-$(CONFIG_WINDFARM_PM112) += windfarm_pm112.o windfarm_smu_sat.o \
42 windfarm_smu_sensors.o \ 42 windfarm_smu_sensors.o \
43 windfarm_max6690_sensor.o \ 43 windfarm_max6690_sensor.o \
44 windfarm_lm75_sensor.o windfarm_pid.o 44 windfarm_lm75_sensor.o windfarm_pid.o
45obj-$(CONFIG_PMAC_RACKMETER) += rack-meter.o
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index be0bd34ff6f9..d43ea81d6df9 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -267,12 +267,12 @@ adb_probe_task(void *x)
267} 267}
268 268
269static void 269static void
270__adb_probe_task(void *data) 270__adb_probe_task(struct work_struct *bullshit)
271{ 271{
272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL); 272 adb_probe_task_pid = kernel_thread(adb_probe_task, NULL, SIGCHLD | CLONE_KERNEL);
273} 273}
274 274
275static DECLARE_WORK(adb_reset_work, __adb_probe_task, NULL); 275static DECLARE_WORK(adb_reset_work, __adb_probe_task);
276 276
277int 277int
278adb_reset_bus(void) 278adb_reset_bus(void)
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
new file mode 100644
index 000000000000..5ed41fe84e57
--- /dev/null
+++ b/drivers/macintosh/rack-meter.c
@@ -0,0 +1,616 @@
1/*
2 * RackMac vu-meter driver
3 *
4 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
5 * <benh@kernel.crashing.org>
6 *
7 * Released under the term of the GNU GPL v2.
8 *
9 * Support the CPU-meter LEDs of the Xserve G5
10 *
11 * TODO: Implement PWM to do variable intensity and provide userland
12 * interface for fun. Also, the CPU-meter could be made nicer by being
13 * a bit less "immediate" but giving instead a more average load over
14 * time. Patches welcome :-)
15 *
16 */
17#undef DEBUG
18
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <linux/device.h>
22#include <linux/interrupt.h>
23#include <linux/module.h>
24#include <linux/pci.h>
25#include <linux/dma-mapping.h>
26#include <linux/kernel_stat.h>
27
28#include <asm/io.h>
29#include <asm/prom.h>
30#include <asm/machdep.h>
31#include <asm/pmac_feature.h>
32#include <asm/dbdma.h>
33#include <asm/dbdma.h>
34#include <asm/macio.h>
35#include <asm/keylargo.h>
36
37/* Number of samples in a sample buffer */
38#define SAMPLE_COUNT 256
39
40/* CPU meter sampling rate in ms */
41#define CPU_SAMPLING_RATE 250
42
43struct rackmeter_dma {
44 struct dbdma_cmd cmd[4] ____cacheline_aligned;
45 u32 mark ____cacheline_aligned;
46 u32 buf1[SAMPLE_COUNT] ____cacheline_aligned;
47 u32 buf2[SAMPLE_COUNT] ____cacheline_aligned;
48} ____cacheline_aligned;
49
50struct rackmeter_cpu {
51 struct delayed_work sniffer;
52 struct rackmeter *rm;
53 cputime64_t prev_wall;
54 cputime64_t prev_idle;
55 int zero;
56} ____cacheline_aligned;
57
58struct rackmeter {
59 struct macio_dev *mdev;
60 unsigned int irq;
61 struct device_node *i2s;
62 u8 *ubuf;
63 struct dbdma_regs __iomem *dma_regs;
64 void __iomem *i2s_regs;
65 dma_addr_t dma_buf_p;
66 struct rackmeter_dma *dma_buf_v;
67 int stale_irq;
68 struct rackmeter_cpu cpu[2];
69 int paused;
70 struct mutex sem;
71};
72
73/* To be set as a tunable */
74static int rackmeter_ignore_nice;
75
76/* This GPIO is whacked by the OS X driver when initializing */
77#define RACKMETER_MAGIC_GPIO 0x78
78
79/* This is copied from cpufreq_ondemand, maybe we should put it in
80 * a common header somewhere
81 */
82static inline cputime64_t get_cpu_idle_time(unsigned int cpu)
83{
84 cputime64_t retval;
85
86 retval = cputime64_add(kstat_cpu(cpu).cpustat.idle,
87 kstat_cpu(cpu).cpustat.iowait);
88
89 if (rackmeter_ignore_nice)
90 retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice);
91
92 return retval;
93}
94
95static void rackmeter_setup_i2s(struct rackmeter *rm)
96{
97 struct macio_chip *macio = rm->mdev->bus->chip;
98
99 /* First whack magic GPIO */
100 pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, RACKMETER_MAGIC_GPIO, 5);
101
102
103 /* Call feature code to enable the sound channel and the proper
104 * clock sources
105 */
106 pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, rm->i2s, 0, 1);
107
108 /* Power i2s and stop i2s clock. We whack MacIO FCRs directly for now.
109 * This is a bit racy, thus we should add new platform functions to
110 * handle that. snd-aoa needs that too
111 */
112 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE);
113 MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT);
114 (void)MACIO_IN32(KEYLARGO_FCR1);
115 udelay(10);
116
117 /* Then setup i2s. For now, we use the same magic value that
118 * the OS X driver seems to use. We might want to play around
119 * with the clock divisors later
120 */
121 out_le32(rm->i2s_regs + 0x10, 0x01fa0000);
122 (void)in_le32(rm->i2s_regs + 0x10);
123 udelay(10);
124
125 /* Fully restart i2s*/
126 MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE |
127 KL1_I2S0_CLK_ENABLE_BIT);
128 (void)MACIO_IN32(KEYLARGO_FCR1);
129 udelay(10);
130}
131
132static void rackmeter_set_default_pattern(struct rackmeter *rm)
133{
134 int i;
135
136 for (i = 0; i < 16; i++) {
137 if (i < 8)
138 rm->ubuf[i] = (i & 1) * 255;
139 else
140 rm->ubuf[i] = ((~i) & 1) * 255;
141 }
142}
143
144static void rackmeter_do_pause(struct rackmeter *rm, int pause)
145{
146 struct rackmeter_dma *rdma = rm->dma_buf_v;
147
148 pr_debug("rackmeter: %s\n", pause ? "paused" : "started");
149
150 rm->paused = pause;
151 if (pause) {
152 DBDMA_DO_STOP(rm->dma_regs);
153 return;
154 }
155 memset(rdma->buf1, 0, SAMPLE_COUNT & sizeof(u32));
156 memset(rdma->buf2, 0, SAMPLE_COUNT & sizeof(u32));
157
158 rm->dma_buf_v->mark = 0;
159
160 mb();
161 out_le32(&rm->dma_regs->cmdptr_hi, 0);
162 out_le32(&rm->dma_regs->cmdptr, rm->dma_buf_p);
163 out_le32(&rm->dma_regs->control, (RUN << 16) | RUN);
164}
165
166static void rackmeter_setup_dbdma(struct rackmeter *rm)
167{
168 struct rackmeter_dma *db = rm->dma_buf_v;
169 struct dbdma_cmd *cmd = db->cmd;
170
171 /* Make sure dbdma is reset */
172 DBDMA_DO_RESET(rm->dma_regs);
173
174 pr_debug("rackmeter: mark offset=0x%lx\n",
175 offsetof(struct rackmeter_dma, mark));
176 pr_debug("rackmeter: buf1 offset=0x%lx\n",
177 offsetof(struct rackmeter_dma, buf1));
178 pr_debug("rackmeter: buf2 offset=0x%lx\n",
179 offsetof(struct rackmeter_dma, buf2));
180
181 /* Prepare 4 dbdma commands for the 2 buffers */
182 memset(cmd, 0, 4 * sizeof(struct dbdma_cmd));
183 st_le16(&cmd->req_count, 4);
184 st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
185 st_le32(&cmd->phy_addr, rm->dma_buf_p +
186 offsetof(struct rackmeter_dma, mark));
187 st_le32(&cmd->cmd_dep, 0x02000000);
188 cmd++;
189
190 st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
191 st_le16(&cmd->command, OUTPUT_MORE);
192 st_le32(&cmd->phy_addr, rm->dma_buf_p +
193 offsetof(struct rackmeter_dma, buf1));
194 cmd++;
195
196 st_le16(&cmd->req_count, 4);
197 st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM);
198 st_le32(&cmd->phy_addr, rm->dma_buf_p +
199 offsetof(struct rackmeter_dma, mark));
200 st_le32(&cmd->cmd_dep, 0x01000000);
201 cmd++;
202
203 st_le16(&cmd->req_count, SAMPLE_COUNT * 4);
204 st_le16(&cmd->command, OUTPUT_MORE | BR_ALWAYS);
205 st_le32(&cmd->phy_addr, rm->dma_buf_p +
206 offsetof(struct rackmeter_dma, buf2));
207 st_le32(&cmd->cmd_dep, rm->dma_buf_p);
208
209 rackmeter_do_pause(rm, 0);
210}
211
212static void rackmeter_do_timer(struct work_struct *work)
213{
214 struct rackmeter_cpu *rcpu =
215 container_of(work, struct rackmeter_cpu, sniffer.work);
216 struct rackmeter *rm = rcpu->rm;
217 unsigned int cpu = smp_processor_id();
218 cputime64_t cur_jiffies, total_idle_ticks;
219 unsigned int total_ticks, idle_ticks;
220 int i, offset, load, cumm, pause;
221
222 cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
223 total_ticks = (unsigned int)cputime64_sub(cur_jiffies,
224 rcpu->prev_wall);
225 rcpu->prev_wall = cur_jiffies;
226
227 total_idle_ticks = get_cpu_idle_time(cpu);
228 idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks,
229 rcpu->prev_idle);
230 rcpu->prev_idle = total_idle_ticks;
231
232 /* We do a very dumb calculation to update the LEDs for now,
233 * we'll do better once we have actual PWM implemented
234 */
235 load = (9 * (total_ticks - idle_ticks)) / total_ticks;
236
237 offset = cpu << 3;
238 cumm = 0;
239 for (i = 0; i < 8; i++) {
240 u8 ub = (load > i) ? 0xff : 0;
241 rm->ubuf[i + offset] = ub;
242 cumm |= ub;
243 }
244 rcpu->zero = (cumm == 0);
245
246 /* Now check if LEDs are all 0, we can stop DMA */
247 pause = (rm->cpu[0].zero && rm->cpu[1].zero);
248 if (pause != rm->paused) {
249 mutex_lock(&rm->sem);
250 pause = (rm->cpu[0].zero && rm->cpu[1].zero);
251 rackmeter_do_pause(rm, pause);
252 mutex_unlock(&rm->sem);
253 }
254 schedule_delayed_work_on(cpu, &rcpu->sniffer,
255 msecs_to_jiffies(CPU_SAMPLING_RATE));
256}
257
258static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm)
259{
260 unsigned int cpu;
261
262 /* This driver works only with 1 or 2 CPUs numbered 0 and 1,
263 * but that's really all we have on Apple Xserve. It doesn't
264 * play very nice with CPU hotplug neither but we don't do that
265 * on those machines yet
266 */
267
268 rm->cpu[0].rm = rm;
269 INIT_DELAYED_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer);
270 rm->cpu[1].rm = rm;
271 INIT_DELAYED_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer);
272
273 for_each_online_cpu(cpu) {
274 struct rackmeter_cpu *rcpu;
275
276 if (cpu > 1)
277 continue;
278 rcpu = &rm->cpu[cpu];;
279 rcpu->prev_idle = get_cpu_idle_time(cpu);
280 rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64());
281 schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer,
282 msecs_to_jiffies(CPU_SAMPLING_RATE));
283 }
284}
285
286static void __devexit rackmeter_stop_cpu_sniffer(struct rackmeter *rm)
287{
288 cancel_rearming_delayed_work(&rm->cpu[0].sniffer);
289 cancel_rearming_delayed_work(&rm->cpu[1].sniffer);
290}
291
292static int rackmeter_setup(struct rackmeter *rm)
293{
294 pr_debug("rackmeter: setting up i2s..\n");
295 rackmeter_setup_i2s(rm);
296
297 pr_debug("rackmeter: setting up default pattern..\n");
298 rackmeter_set_default_pattern(rm);
299
300 pr_debug("rackmeter: setting up dbdma..\n");
301 rackmeter_setup_dbdma(rm);
302
303 pr_debug("rackmeter: start CPU measurements..\n");
304 rackmeter_init_cpu_sniffer(rm);
305
306 printk(KERN_INFO "RackMeter initialized\n");
307
308 return 0;
309}
310
311/* XXX FIXME: No PWM yet, this is 0/1 */
312static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index)
313{
314 int led;
315 u32 sample = 0;
316
317 for (led = 0; led < 16; led++) {
318 sample >>= 1;
319 sample |= ((rm->ubuf[led] >= 0x80) << 15);
320 }
321 return (sample << 17) | (sample >> 15);
322}
323
324static irqreturn_t rackmeter_irq(int irq, void *arg)
325{
326 struct rackmeter *rm = arg;
327 struct rackmeter_dma *db = rm->dma_buf_v;
328 unsigned int mark, i;
329 u32 *buf;
330
331 /* Flush PCI buffers with an MMIO read. Maybe we could actually
332 * check the status one day ... in case things go wrong, though
333 * this never happened to me
334 */
335 (void)in_le32(&rm->dma_regs->status);
336
337 /* Make sure the CPU gets us in order */
338 rmb();
339
340 /* Read mark */
341 mark = db->mark;
342 if (mark != 1 && mark != 2) {
343 printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n",
344 mark);
345 /* We allow for 3 errors like that (stale DBDMA irqs) */
346 if (++rm->stale_irq > 3) {
347 printk(KERN_ERR "rackmeter: Too many errors,"
348 " stopping DMA\n");
349 DBDMA_DO_RESET(rm->dma_regs);
350 }
351 return IRQ_HANDLED;
352 }
353
354 /* Next buffer we need to fill is mark value */
355 buf = mark == 1 ? db->buf1 : db->buf2;
356
357 /* Fill it now. This routine converts the 8 bits depth sample array
358 * into the PWM bitmap for each LED.
359 */
360 for (i = 0; i < SAMPLE_COUNT; i++)
361 buf[i] = rackmeter_calc_sample(rm, i);
362
363
364 return IRQ_HANDLED;
365}
366
367static int __devinit rackmeter_probe(struct macio_dev* mdev,
368 const struct of_device_id *match)
369{
370 struct device_node *i2s = NULL, *np = NULL;
371 struct rackmeter *rm = NULL;
372 struct resource ri2s, rdma;
373 int rc = -ENODEV;
374
375 pr_debug("rackmeter_probe()\n");
376
377 /* Get i2s-a node */
378 while ((i2s = of_get_next_child(mdev->ofdev.node, i2s)) != NULL)
379 if (strcmp(i2s->name, "i2s-a") == 0)
380 break;
381 if (i2s == NULL) {
382 pr_debug(" i2s-a child not found\n");
383 goto bail;
384 }
385 /* Get lightshow or virtual sound */
386 while ((np = of_get_next_child(i2s, np)) != NULL) {
387 if (strcmp(np->name, "lightshow") == 0)
388 break;
389 if ((strcmp(np->name, "sound") == 0) &&
390 get_property(np, "virtual", NULL) != NULL)
391 break;
392 }
393 if (np == NULL) {
394 pr_debug(" lightshow or sound+virtual child not found\n");
395 goto bail;
396 }
397
398 /* Create and initialize our instance data */
399 rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL);
400 if (rm == NULL) {
401 printk(KERN_ERR "rackmeter: failed to allocate memory !\n");
402 rc = -ENOMEM;
403 goto bail_release;
404 }
405 rm->mdev = mdev;
406 rm->i2s = i2s;
407 mutex_init(&rm->sem);
408 dev_set_drvdata(&mdev->ofdev.dev, rm);
409 /* Check resources availability. We need at least resource 0 and 1 */
410#if 0 /* Use that when i2s-a is finally an mdev per-se */
411 if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) {
412 printk(KERN_ERR
413 "rackmeter: found match but lacks resources: %s"
414 " (%d resources, %d interrupts)\n",
415 mdev->ofdev.node->full_name);
416 rc = -ENXIO;
417 goto bail_free;
418 }
419 if (macio_request_resources(mdev, "rackmeter")) {
420 printk(KERN_ERR
421 "rackmeter: failed to request resources: %s\n",
422 mdev->ofdev.node->full_name);
423 rc = -EBUSY;
424 goto bail_free;
425 }
426 rm->irq = macio_irq(mdev, 1);
427#else
428 rm->irq = irq_of_parse_and_map(i2s, 1);
429 if (rm->irq == NO_IRQ ||
430 of_address_to_resource(i2s, 0, &ri2s) ||
431 of_address_to_resource(i2s, 1, &rdma)) {
432 printk(KERN_ERR
433 "rackmeter: found match but lacks resources: %s",
434 mdev->ofdev.node->full_name);
435 rc = -ENXIO;
436 goto bail_free;
437 }
438#endif
439
440 pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start);
441 pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start);
442 pr_debug(" irq %d\n", rm->irq);
443
444 rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL);
445 if (rm->ubuf == NULL) {
446 printk(KERN_ERR
447 "rackmeter: failed to allocate samples page !\n");
448 rc = -ENOMEM;
449 goto bail_release;
450 }
451
452 rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev,
453 sizeof(struct rackmeter_dma),
454 &rm->dma_buf_p, GFP_KERNEL);
455 if (rm->dma_buf_v == NULL) {
456 printk(KERN_ERR
457 "rackmeter: failed to allocate dma buffer !\n");
458 rc = -ENOMEM;
459 goto bail_free_samples;
460 }
461#if 0
462 rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000);
463#else
464 rm->i2s_regs = ioremap(ri2s.start, 0x1000);
465#endif
466 if (rm->i2s_regs == NULL) {
467 printk(KERN_ERR
468 "rackmeter: failed to map i2s registers !\n");
469 rc = -ENXIO;
470 goto bail_free_dma;
471 }
472#if 0
473 rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100);
474#else
475 rm->dma_regs = ioremap(rdma.start, 0x100);
476#endif
477 if (rm->dma_regs == NULL) {
478 printk(KERN_ERR
479 "rackmeter: failed to map dma registers !\n");
480 rc = -ENXIO;
481 goto bail_unmap_i2s;
482 }
483
484 rc = rackmeter_setup(rm);
485 if (rc) {
486 printk(KERN_ERR
487 "rackmeter: failed to initialize !\n");
488 rc = -ENXIO;
489 goto bail_unmap_dma;
490 }
491
492 rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm);
493 if (rc != 0) {
494 printk(KERN_ERR
495 "rackmeter: failed to request interrupt !\n");
496 goto bail_stop_dma;
497 }
498 of_node_put(np);
499 return 0;
500
501 bail_stop_dma:
502 DBDMA_DO_RESET(rm->dma_regs);
503 bail_unmap_dma:
504 iounmap(rm->dma_regs);
505 bail_unmap_i2s:
506 iounmap(rm->i2s_regs);
507 bail_free_dma:
508 dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
509 sizeof(struct rackmeter_dma),
510 rm->dma_buf_v, rm->dma_buf_p);
511 bail_free_samples:
512 free_page((unsigned long)rm->ubuf);
513 bail_release:
514#if 0
515 macio_release_resources(mdev);
516#endif
517 bail_free:
518 kfree(rm);
519 bail:
520 of_node_put(i2s);
521 of_node_put(np);
522 dev_set_drvdata(&mdev->ofdev.dev, NULL);
523 return rc;
524}
525
526static int __devexit rackmeter_remove(struct macio_dev* mdev)
527{
528 struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
529
530 /* Stop CPU sniffer timer & work queues */
531 rackmeter_stop_cpu_sniffer(rm);
532
533 /* Clear reference to private data */
534 dev_set_drvdata(&mdev->ofdev.dev, NULL);
535
536 /* Stop/reset dbdma */
537 DBDMA_DO_RESET(rm->dma_regs);
538
539 /* Release the IRQ */
540 free_irq(rm->irq, rm);
541
542 /* Unmap registers */
543 iounmap(rm->dma_regs);
544 iounmap(rm->i2s_regs);
545
546 /* Free DMA */
547 dma_free_coherent(&macio_get_pci_dev(mdev)->dev,
548 sizeof(struct rackmeter_dma),
549 rm->dma_buf_v, rm->dma_buf_p);
550
551 /* Free samples */
552 free_page((unsigned long)rm->ubuf);
553
554#if 0
555 /* Release resources */
556 macio_release_resources(mdev);
557#endif
558
559 /* Get rid of me */
560 kfree(rm);
561
562 return 0;
563}
564
565static int rackmeter_shutdown(struct macio_dev* mdev)
566{
567 struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev);
568
569 if (rm == NULL)
570 return -ENODEV;
571
572 /* Stop CPU sniffer timer & work queues */
573 rackmeter_stop_cpu_sniffer(rm);
574
575 /* Stop/reset dbdma */
576 DBDMA_DO_RESET(rm->dma_regs);
577
578 return 0;
579}
580
581static struct of_device_id rackmeter_match[] = {
582 { .name = "i2s" },
583 { }
584};
585
586static struct macio_driver rackmeter_drv = {
587 .name = "rackmeter",
588 .owner = THIS_MODULE,
589 .match_table = rackmeter_match,
590 .probe = rackmeter_probe,
591 .remove = rackmeter_remove,
592 .shutdown = rackmeter_shutdown,
593};
594
595
596static int __init rackmeter_init(void)
597{
598 pr_debug("rackmeter_init()\n");
599
600 return macio_register_driver(&rackmeter_drv);
601}
602
603static void __exit rackmeter_exit(void)
604{
605 pr_debug("rackmeter_exit()\n");
606
607 macio_unregister_driver(&rackmeter_drv);
608}
609
610module_init(rackmeter_init);
611module_exit(rackmeter_exit);
612
613
614MODULE_LICENSE("GPL");
615MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>");
616MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel");
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index ade25b3fbb35..6dde27ab79a8 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -46,6 +46,7 @@
46#include <asm/abs_addr.h> 46#include <asm/abs_addr.h>
47#include <asm/uaccess.h> 47#include <asm/uaccess.h>
48#include <asm/of_device.h> 48#include <asm/of_device.h>
49#include <asm/of_platform.h>
49 50
50#define VERSION "0.7" 51#define VERSION "0.7"
51#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." 52#define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp."
@@ -600,7 +601,7 @@ core_initcall(smu_late_init);
600 * sysfs visibility 601 * sysfs visibility
601 */ 602 */
602 603
603static void smu_expose_childs(void *unused) 604static void smu_expose_childs(struct work_struct *unused)
604{ 605{
605 struct device_node *np; 606 struct device_node *np;
606 607
@@ -610,7 +611,7 @@ static void smu_expose_childs(void *unused)
610 &smu->of_dev->dev); 611 &smu->of_dev->dev);
611} 612}
612 613
613static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); 614static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs);
614 615
615static int smu_platform_probe(struct of_device* dev, 616static int smu_platform_probe(struct of_device* dev,
616 const struct of_device_id *match) 617 const struct of_device_id *match)
@@ -653,7 +654,7 @@ static int __init smu_init_sysfs(void)
653 * I'm a bit too far from figuring out how that works with those 654 * I'm a bit too far from figuring out how that works with those
654 * new chipsets, but that will come back and bite us 655 * new chipsets, but that will come back and bite us
655 */ 656 */
656 of_register_driver(&smu_of_platform_driver); 657 of_register_platform_driver(&smu_of_platform_driver);
657 return 0; 658 return 0;
658} 659}
659 660
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index a0f30d0853ea..13b953ae8ebc 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -30,7 +30,7 @@
30#include <asm/io.h> 30#include <asm/io.h>
31#include <asm/system.h> 31#include <asm/system.h>
32#include <asm/sections.h> 32#include <asm/sections.h>
33#include <asm/of_device.h> 33#include <asm/of_platform.h>
34 34
35#undef DEBUG 35#undef DEBUG
36 36
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index d00c0c37a12e..2e4ad44a8636 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -129,6 +129,7 @@
129#include <asm/sections.h> 129#include <asm/sections.h>
130#include <asm/of_device.h> 130#include <asm/of_device.h>
131#include <asm/macio.h> 131#include <asm/macio.h>
132#include <asm/of_platform.h>
132 133
133#include "therm_pm72.h" 134#include "therm_pm72.h"
134 135
@@ -2236,14 +2237,14 @@ static int __init therm_pm72_init(void)
2236 return -ENODEV; 2237 return -ENODEV;
2237 } 2238 }
2238 2239
2239 of_register_driver(&fcu_of_platform_driver); 2240 of_register_platform_driver(&fcu_of_platform_driver);
2240 2241
2241 return 0; 2242 return 0;
2242} 2243}
2243 2244
2244static void __exit therm_pm72_exit(void) 2245static void __exit therm_pm72_exit(void)
2245{ 2246{
2246 of_unregister_driver(&fcu_of_platform_driver); 2247 of_unregister_platform_driver(&fcu_of_platform_driver);
2247 2248
2248 if (of_dev) 2249 if (of_dev)
2249 of_device_unregister(of_dev); 2250 of_device_unregister(of_dev);
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 738faab1b22c..a1d3a987cb3a 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -36,12 +36,13 @@
36#include <linux/i2c.h> 36#include <linux/i2c.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/init.h> 38#include <linux/init.h>
39
39#include <asm/prom.h> 40#include <asm/prom.h>
40#include <asm/machdep.h> 41#include <asm/machdep.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/sections.h> 44#include <asm/sections.h>
44#include <asm/of_device.h> 45#include <asm/of_platform.h>
45#include <asm/macio.h> 46#include <asm/macio.h>
46 47
47#define LOG_TEMP 0 /* continously log temperature */ 48#define LOG_TEMP 0 /* continously log temperature */
@@ -511,14 +512,14 @@ g4fan_init( void )
511 return -ENODEV; 512 return -ENODEV;
512 } 513 }
513 514
514 of_register_driver( &therm_of_driver ); 515 of_register_platform_driver( &therm_of_driver );
515 return 0; 516 return 0;
516} 517}
517 518
518static void __exit 519static void __exit
519g4fan_exit( void ) 520g4fan_exit( void )
520{ 521{
521 of_unregister_driver( &therm_of_driver ); 522 of_unregister_platform_driver( &therm_of_driver );
522 523
523 if( x.of_dev ) 524 if( x.of_dev )
524 of_device_unregister( x.of_dev ); 525 of_device_unregister( x.of_dev );
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 08a40f4e4f60..ed2d4ef27fd8 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -458,11 +458,11 @@ static void dec_pending(struct crypt_io *io, int error)
458 * interrupt context. 458 * interrupt context.
459 */ 459 */
460static struct workqueue_struct *_kcryptd_workqueue; 460static struct workqueue_struct *_kcryptd_workqueue;
461static void kcryptd_do_work(void *data); 461static void kcryptd_do_work(struct work_struct *work);
462 462
463static void kcryptd_queue_io(struct crypt_io *io) 463static void kcryptd_queue_io(struct crypt_io *io)
464{ 464{
465 INIT_WORK(&io->work, kcryptd_do_work, io); 465 INIT_WORK(&io->work, kcryptd_do_work);
466 queue_work(_kcryptd_workqueue, &io->work); 466 queue_work(_kcryptd_workqueue, &io->work);
467} 467}
468 468
@@ -618,9 +618,9 @@ static void process_read_endio(struct crypt_io *io)
618 dec_pending(io, crypt_convert(cc, &ctx)); 618 dec_pending(io, crypt_convert(cc, &ctx));
619} 619}
620 620
621static void kcryptd_do_work(void *data) 621static void kcryptd_do_work(struct work_struct *work)
622{ 622{
623 struct crypt_io *io = data; 623 struct crypt_io *io = container_of(work, struct crypt_io, work);
624 624
625 if (io->post_process) 625 if (io->post_process)
626 process_read_endio(io); 626 process_read_endio(io);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index d754e0bc6e90..e77ee6fd1044 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -104,8 +104,8 @@ typedef int (*action_fn) (struct pgpath *pgpath);
104static kmem_cache_t *_mpio_cache; 104static kmem_cache_t *_mpio_cache;
105 105
106struct workqueue_struct *kmultipathd; 106struct workqueue_struct *kmultipathd;
107static void process_queued_ios(void *data); 107static void process_queued_ios(struct work_struct *work);
108static void trigger_event(void *data); 108static void trigger_event(struct work_struct *work);
109 109
110 110
111/*----------------------------------------------- 111/*-----------------------------------------------
@@ -173,8 +173,8 @@ static struct multipath *alloc_multipath(struct dm_target *ti)
173 INIT_LIST_HEAD(&m->priority_groups); 173 INIT_LIST_HEAD(&m->priority_groups);
174 spin_lock_init(&m->lock); 174 spin_lock_init(&m->lock);
175 m->queue_io = 1; 175 m->queue_io = 1;
176 INIT_WORK(&m->process_queued_ios, process_queued_ios, m); 176 INIT_WORK(&m->process_queued_ios, process_queued_ios);
177 INIT_WORK(&m->trigger_event, trigger_event, m); 177 INIT_WORK(&m->trigger_event, trigger_event);
178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); 178 m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache);
179 if (!m->mpio_pool) { 179 if (!m->mpio_pool) {
180 kfree(m); 180 kfree(m);
@@ -379,9 +379,10 @@ static void dispatch_queued_ios(struct multipath *m)
379 } 379 }
380} 380}
381 381
382static void process_queued_ios(void *data) 382static void process_queued_ios(struct work_struct *work)
383{ 383{
384 struct multipath *m = (struct multipath *) data; 384 struct multipath *m =
385 container_of(work, struct multipath, process_queued_ios);
385 struct hw_handler *hwh = &m->hw_handler; 386 struct hw_handler *hwh = &m->hw_handler;
386 struct pgpath *pgpath = NULL; 387 struct pgpath *pgpath = NULL;
387 unsigned init_required = 0, must_queue = 1; 388 unsigned init_required = 0, must_queue = 1;
@@ -421,9 +422,10 @@ out:
421 * An event is triggered whenever a path is taken out of use. 422 * An event is triggered whenever a path is taken out of use.
422 * Includes path failure and PG bypass. 423 * Includes path failure and PG bypass.
423 */ 424 */
424static void trigger_event(void *data) 425static void trigger_event(struct work_struct *work)
425{ 426{
426 struct multipath *m = (struct multipath *) data; 427 struct multipath *m =
428 container_of(work, struct multipath, trigger_event);
427 429
428 dm_table_event(m->ti->table); 430 dm_table_event(m->ti->table);
429} 431}
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 48a653b3f518..fc8cbb168e3e 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -883,7 +883,7 @@ static void do_mirror(struct mirror_set *ms)
883 do_writes(ms, &writes); 883 do_writes(ms, &writes);
884} 884}
885 885
886static void do_work(void *ignored) 886static void do_work(struct work_struct *ignored)
887{ 887{
888 struct mirror_set *ms; 888 struct mirror_set *ms;
889 889
@@ -1269,7 +1269,7 @@ static int __init dm_mirror_init(void)
1269 dm_dirty_log_exit(); 1269 dm_dirty_log_exit();
1270 return r; 1270 return r;
1271 } 1271 }
1272 INIT_WORK(&_kmirrord_work, do_work, NULL); 1272 INIT_WORK(&_kmirrord_work, do_work);
1273 1273
1274 r = dm_register_target(&mirror_target); 1274 r = dm_register_target(&mirror_target);
1275 if (r < 0) { 1275 if (r < 0) {
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 5281e0094072..91c7aa1fed0e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -40,7 +40,7 @@
40#define SNAPSHOT_PAGES 256 40#define SNAPSHOT_PAGES 256
41 41
42struct workqueue_struct *ksnapd; 42struct workqueue_struct *ksnapd;
43static void flush_queued_bios(void *data); 43static void flush_queued_bios(struct work_struct *work);
44 44
45struct pending_exception { 45struct pending_exception {
46 struct exception e; 46 struct exception e;
@@ -528,7 +528,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
528 } 528 }
529 529
530 bio_list_init(&s->queued_bios); 530 bio_list_init(&s->queued_bios);
531 INIT_WORK(&s->queued_bios_work, flush_queued_bios, s); 531 INIT_WORK(&s->queued_bios_work, flush_queued_bios);
532 532
533 /* Add snapshot to the list of snapshots for this origin */ 533 /* Add snapshot to the list of snapshots for this origin */
534 /* Exceptions aren't triggered till snapshot_resume() is called */ 534 /* Exceptions aren't triggered till snapshot_resume() is called */
@@ -603,9 +603,10 @@ static void flush_bios(struct bio *bio)
603 } 603 }
604} 604}
605 605
606static void flush_queued_bios(void *data) 606static void flush_queued_bios(struct work_struct *work)
607{ 607{
608 struct dm_snapshot *s = (struct dm_snapshot *) data; 608 struct dm_snapshot *s =
609 container_of(work, struct dm_snapshot, queued_bios_work);
609 struct bio *queued_bios; 610 struct bio *queued_bios;
610 unsigned long flags; 611 unsigned long flags;
611 612
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index f1db6eff4857..b3c01496c737 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -417,7 +417,7 @@ static int process_jobs(struct list_head *jobs, int (*fn) (struct kcopyd_job *))
417/* 417/*
418 * kcopyd does this every time it's woken up. 418 * kcopyd does this every time it's woken up.
419 */ 419 */
420static void do_work(void *ignored) 420static void do_work(struct work_struct *ignored)
421{ 421{
422 /* 422 /*
423 * The order that these are called is *very* important. 423 * The order that these are called is *very* important.
@@ -628,7 +628,7 @@ static int kcopyd_init(void)
628 } 628 }
629 629
630 kcopyd_clients++; 630 kcopyd_clients++;
631 INIT_WORK(&_kcopyd_work, do_work, NULL); 631 INIT_WORK(&_kcopyd_work, do_work);
632 mutex_unlock(&kcopyd_init_lock); 632 mutex_unlock(&kcopyd_init_lock);
633 return 0; 633 return 0;
634} 634}
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
index 06893243f3d4..6e166801505d 100644
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ b/drivers/media/dvb/b2c2/flexcop-pci.c
@@ -63,7 +63,7 @@ struct flexcop_pci {
63 63
64 unsigned long last_irq; 64 unsigned long last_irq;
65 65
66 struct work_struct irq_check_work; 66 struct delayed_work irq_check_work;
67 67
68 struct flexcop_device *fc_dev; 68 struct flexcop_device *fc_dev;
69}; 69};
@@ -97,9 +97,10 @@ static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi
97 return 0; 97 return 0;
98} 98}
99 99
100static void flexcop_pci_irq_check_work(void *data) 100static void flexcop_pci_irq_check_work(struct work_struct *work)
101{ 101{
102 struct flexcop_pci *fc_pci = data; 102 struct flexcop_pci *fc_pci =
103 container_of(work, struct flexcop_pci, irq_check_work.work);
103 struct flexcop_device *fc = fc_pci->fc_dev; 104 struct flexcop_device *fc = fc_pci->fc_dev;
104 105
105 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714); 106 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
@@ -371,7 +372,7 @@ static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
371 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0) 372 if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
372 goto err_fc_exit; 373 goto err_fc_exit;
373 374
374 INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci); 375 INIT_DELAYED_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work);
375 376
376 return ret; 377 return ret;
377 378
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 8a7dd507cf6e..206c13e47a06 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -128,7 +128,7 @@ struct cinergyt2 {
128 128
129 struct dvbt_set_parameters_msg param; 129 struct dvbt_set_parameters_msg param;
130 struct dvbt_get_status_msg status; 130 struct dvbt_get_status_msg status;
131 struct work_struct query_work; 131 struct delayed_work query_work;
132 132
133 wait_queue_head_t poll_wq; 133 wait_queue_head_t poll_wq;
134 int pending_fe_events; 134 int pending_fe_events;
@@ -142,7 +142,7 @@ struct cinergyt2 {
142#ifdef ENABLE_RC 142#ifdef ENABLE_RC
143 struct input_dev *rc_input_dev; 143 struct input_dev *rc_input_dev;
144 char phys[64]; 144 char phys[64];
145 struct work_struct rc_query_work; 145 struct delayed_work rc_query_work;
146 int rc_input_event; 146 int rc_input_event;
147 u32 rc_last_code; 147 u32 rc_last_code;
148 unsigned long last_event_jiffies; 148 unsigned long last_event_jiffies;
@@ -723,9 +723,10 @@ static struct dvb_device cinergyt2_fe_template = {
723 723
724#ifdef ENABLE_RC 724#ifdef ENABLE_RC
725 725
726static void cinergyt2_query_rc (void *data) 726static void cinergyt2_query_rc (struct work_struct *work)
727{ 727{
728 struct cinergyt2 *cinergyt2 = data; 728 struct cinergyt2 *cinergyt2 =
729 container_of(work, struct cinergyt2, rc_query_work.work);
729 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS }; 730 char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
730 struct cinergyt2_rc_event rc_events[12]; 731 struct cinergyt2_rc_event rc_events[12];
731 int n, len, i; 732 int n, len, i;
@@ -806,7 +807,7 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
806 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys)); 807 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
807 cinergyt2->rc_input_event = KEY_MAX; 808 cinergyt2->rc_input_event = KEY_MAX;
808 cinergyt2->rc_last_code = ~0; 809 cinergyt2->rc_last_code = ~0;
809 INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2); 810 INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc);
810 811
811 input_dev->name = DRIVER_NAME " remote control"; 812 input_dev->name = DRIVER_NAME " remote control";
812 input_dev->phys = cinergyt2->phys; 813 input_dev->phys = cinergyt2->phys;
@@ -847,9 +848,10 @@ static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
847 848
848#endif /* ENABLE_RC */ 849#endif /* ENABLE_RC */
849 850
850static void cinergyt2_query (void *data) 851static void cinergyt2_query (struct work_struct *work)
851{ 852{
852 struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data; 853 struct cinergyt2 *cinergyt2 =
854 container_of(work, struct cinergyt2, query_work.work);
853 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS }; 855 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
854 struct dvbt_get_status_msg *s = &cinergyt2->status; 856 struct dvbt_get_status_msg *s = &cinergyt2->status;
855 uint8_t lock_bits; 857 uint8_t lock_bits;
@@ -893,7 +895,7 @@ static int cinergyt2_probe (struct usb_interface *intf,
893 895
894 mutex_init(&cinergyt2->sem); 896 mutex_init(&cinergyt2->sem);
895 init_waitqueue_head (&cinergyt2->poll_wq); 897 init_waitqueue_head (&cinergyt2->poll_wq);
896 INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2); 898 INIT_DELAYED_WORK(&cinergyt2->query_work, cinergyt2_query);
897 899
898 cinergyt2->udev = interface_to_usbdev(intf); 900 cinergyt2->udev = interface_to_usbdev(intf);
899 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; 901 cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 8859ab74f0fe..ebf4dc5190f6 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -127,6 +127,7 @@ struct dvb_net_priv {
127 int in_use; 127 int in_use;
128 struct net_device_stats stats; 128 struct net_device_stats stats;
129 u16 pid; 129 u16 pid;
130 struct net_device *net;
130 struct dvb_net *host; 131 struct dvb_net *host;
131 struct dmx_demux *demux; 132 struct dmx_demux *demux;
132 struct dmx_section_feed *secfeed; 133 struct dmx_section_feed *secfeed;
@@ -1123,10 +1124,11 @@ static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
1123} 1124}
1124 1125
1125 1126
1126static void wq_set_multicast_list (void *data) 1127static void wq_set_multicast_list (struct work_struct *work)
1127{ 1128{
1128 struct net_device *dev = data; 1129 struct dvb_net_priv *priv =
1129 struct dvb_net_priv *priv = dev->priv; 1130 container_of(work, struct dvb_net_priv, set_multicast_list_wq);
1131 struct net_device *dev = priv->net;
1130 1132
1131 dvb_net_feed_stop(dev); 1133 dvb_net_feed_stop(dev);
1132 priv->rx_mode = RX_MODE_UNI; 1134 priv->rx_mode = RX_MODE_UNI;
@@ -1167,9 +1169,11 @@ static void dvb_net_set_multicast_list (struct net_device *dev)
1167} 1169}
1168 1170
1169 1171
1170static void wq_restart_net_feed (void *data) 1172static void wq_restart_net_feed (struct work_struct *work)
1171{ 1173{
1172 struct net_device *dev = data; 1174 struct dvb_net_priv *priv =
1175 container_of(work, struct dvb_net_priv, restart_net_feed_wq);
1176 struct net_device *dev = priv->net;
1173 1177
1174 if (netif_running(dev)) { 1178 if (netif_running(dev)) {
1175 dvb_net_feed_stop(dev); 1179 dvb_net_feed_stop(dev);
@@ -1276,6 +1280,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1276 dvbnet->device[if_num] = net; 1280 dvbnet->device[if_num] = net;
1277 1281
1278 priv = net->priv; 1282 priv = net->priv;
1283 priv->net = net;
1279 priv->demux = dvbnet->demux; 1284 priv->demux = dvbnet->demux;
1280 priv->pid = pid; 1285 priv->pid = pid;
1281 priv->rx_mode = RX_MODE_UNI; 1286 priv->rx_mode = RX_MODE_UNI;
@@ -1284,8 +1289,8 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1284 priv->feedtype = feedtype; 1289 priv->feedtype = feedtype;
1285 reset_ule(priv); 1290 reset_ule(priv);
1286 1291
1287 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1292 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list);
1288 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1293 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed);
1289 mutex_init(&priv->mutex); 1294 mutex_init(&priv->mutex);
1290 1295
1291 net->base_addr = pid; 1296 net->base_addr = pid;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
index 0a3a0b6c2350..794e4471561c 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
@@ -13,9 +13,10 @@
13 * 13 *
14 * TODO: Fix the repeat rate of the input device. 14 * TODO: Fix the repeat rate of the input device.
15 */ 15 */
16static void dvb_usb_read_remote_control(void *data) 16static void dvb_usb_read_remote_control(struct work_struct *work)
17{ 17{
18 struct dvb_usb_device *d = data; 18 struct dvb_usb_device *d =
19 container_of(work, struct dvb_usb_device, rc_query_work.work);
19 u32 event; 20 u32 event;
20 int state; 21 int state;
21 22
@@ -128,7 +129,7 @@ int dvb_usb_remote_init(struct dvb_usb_device *d)
128 129
129 input_register_device(d->rc_input_dev); 130 input_register_device(d->rc_input_dev);
130 131
131 INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d); 132 INIT_DELAYED_WORK(&d->rc_query_work, dvb_usb_read_remote_control);
132 133
133 info("schedule remote query interval to %d msecs.", d->props.rc_interval); 134 info("schedule remote query interval to %d msecs.", d->props.rc_interval);
134 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval)); 135 schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 376c45a8e779..0d721731a524 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -369,7 +369,7 @@ struct dvb_usb_device {
369 /* remote control */ 369 /* remote control */
370 struct input_dev *rc_input_dev; 370 struct input_dev *rc_input_dev;
371 char rc_phys[64]; 371 char rc_phys[64];
372 struct work_struct rc_query_work; 372 struct delayed_work rc_query_work;
373 u32 last_event; 373 u32 last_event;
374 int last_state; 374 int last_state;
375 375
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 41f4b8d17559..b12cec94f4cc 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -82,6 +82,8 @@ struct pp_cam_entry {
82 struct pardevice *pdev; 82 struct pardevice *pdev;
83 struct parport *port; 83 struct parport *port;
84 struct work_struct cb_task; 84 struct work_struct cb_task;
85 void (*cb_func)(void *cbdata);
86 void *cb_data;
85 int open_count; 87 int open_count;
86 wait_queue_head_t wq_stream; 88 wait_queue_head_t wq_stream;
87 /* image state flags */ 89 /* image state flags */
@@ -130,6 +132,20 @@ static void cpia_parport_disable_irq( struct parport *port ) {
130#define PARPORT_CHUNK_SIZE PAGE_SIZE 132#define PARPORT_CHUNK_SIZE PAGE_SIZE
131 133
132 134
135static void cpia_pp_run_callback(struct work_struct *work)
136{
137 void (*cb_func)(void *cbdata);
138 void *cb_data;
139 struct pp_cam_entry *cam;
140
141 cam = container_of(work, struct pp_cam_entry, cb_task);
142 cb_func = cam->cb_func;
143 cb_data = cam->cb_data;
144 work_release(work);
145
146 cb_func(cb_data);
147}
148
133/**************************************************************************** 149/****************************************************************************
134 * 150 *
135 * CPiA-specific low-level parport functions for nibble uploads 151 * CPiA-specific low-level parport functions for nibble uploads
@@ -664,7 +680,9 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
664 int retval = 0; 680 int retval = 0;
665 681
666 if(cam->port->irq != PARPORT_IRQ_NONE) { 682 if(cam->port->irq != PARPORT_IRQ_NONE) {
667 INIT_WORK(&cam->cb_task, cb, cbdata); 683 cam->cb_func = cb;
684 cam->cb_data = cbdata;
685 INIT_WORK_NAR(&cam->cb_task, cpia_pp_run_callback);
668 } else { 686 } else {
669 retval = -1; 687 retval = -1;
670 } 688 }
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 57e1c024a547..e60a0a52e4b2 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -145,9 +145,9 @@ static void ir_timer(unsigned long data)
145 schedule_work(&ir->work); 145 schedule_work(&ir->work);
146} 146}
147 147
148static void cx88_ir_work(void *data) 148static void cx88_ir_work(struct work_struct *work)
149{ 149{
150 struct cx88_IR *ir = data; 150 struct cx88_IR *ir = container_of(work, struct cx88_IR, work);
151 unsigned long timeout; 151 unsigned long timeout;
152 152
153 cx88_ir_handle_key(ir); 153 cx88_ir_handle_key(ir);
@@ -308,7 +308,7 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
308 core->ir = ir; 308 core->ir = ir;
309 309
310 if (ir->polling) { 310 if (ir->polling) {
311 INIT_WORK(&ir->work, cx88_ir_work, ir); 311 INIT_WORK(&ir->work, cx88_ir_work);
312 init_timer(&ir->timer); 312 init_timer(&ir->timer);
313 ir->timer.function = ir_timer; 313 ir->timer.function = ir_timer;
314 ir->timer.data = (unsigned long)ir; 314 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 1457b1602221..ab87e7bfe84f 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -268,9 +268,9 @@ static void ir_timer(unsigned long data)
268 schedule_work(&ir->work); 268 schedule_work(&ir->work);
269} 269}
270 270
271static void ir_work(void *data) 271static void ir_work(struct work_struct *work)
272{ 272{
273 struct IR_i2c *ir = data; 273 struct IR_i2c *ir = container_of(work, struct IR_i2c, work);
274 ir_key_poll(ir); 274 ir_key_poll(ir);
275 mod_timer(&ir->timer, jiffies+HZ/10); 275 mod_timer(&ir->timer, jiffies+HZ/10);
276} 276}
@@ -400,7 +400,7 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
400 ir->input->name,ir->input->phys,adap->name); 400 ir->input->name,ir->input->phys,adap->name);
401 401
402 /* start polling via eventd */ 402 /* start polling via eventd */
403 INIT_WORK(&ir->work, ir_work, ir); 403 INIT_WORK(&ir->work, ir_work);
404 init_timer(&ir->timer); 404 init_timer(&ir->timer);
405 ir->timer.function = ir_timer; 405 ir->timer.function = ir_timer;
406 ir->timer.data = (unsigned long)ir; 406 ir->timer.data = (unsigned long)ir;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index f129f316d20e..cf129746205d 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -45,16 +45,21 @@ static void pvr2_context_trigger_poll(struct pvr2_context *mp)
45} 45}
46 46
47 47
48static void pvr2_context_poll(struct pvr2_context *mp) 48static void pvr2_context_poll(struct work_struct *work)
49{ 49{
50 struct pvr2_context *mp =
51 container_of(work, struct pvr2_context, workpoll);
50 pvr2_context_enter(mp); do { 52 pvr2_context_enter(mp); do {
51 pvr2_hdw_poll(mp->hdw); 53 pvr2_hdw_poll(mp->hdw);
52 } while (0); pvr2_context_exit(mp); 54 } while (0); pvr2_context_exit(mp);
53} 55}
54 56
55 57
56static void pvr2_context_setup(struct pvr2_context *mp) 58static void pvr2_context_setup(struct work_struct *work)
57{ 59{
60 struct pvr2_context *mp =
61 container_of(work, struct pvr2_context, workinit);
62
58 pvr2_context_enter(mp); do { 63 pvr2_context_enter(mp); do {
59 if (!pvr2_hdw_dev_ok(mp->hdw)) break; 64 if (!pvr2_hdw_dev_ok(mp->hdw)) break;
60 pvr2_hdw_setup(mp->hdw); 65 pvr2_hdw_setup(mp->hdw);
@@ -92,8 +97,8 @@ struct pvr2_context *pvr2_context_create(
92 } 97 }
93 98
94 mp->workqueue = create_singlethread_workqueue("pvrusb2"); 99 mp->workqueue = create_singlethread_workqueue("pvrusb2");
95 INIT_WORK(&mp->workinit,(void (*)(void*))pvr2_context_setup,mp); 100 INIT_WORK(&mp->workinit, pvr2_context_setup);
96 INIT_WORK(&mp->workpoll,(void (*)(void*))pvr2_context_poll,mp); 101 INIT_WORK(&mp->workpoll, pvr2_context_poll);
97 queue_work(mp->workqueue,&mp->workinit); 102 queue_work(mp->workqueue,&mp->workinit);
98 done: 103 done:
99 return mp; 104 return mp;
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index 7b9859c33018..92eabf88a09b 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -324,9 +324,9 @@ static void saa6588_timer(unsigned long data)
324 schedule_work(&s->work); 324 schedule_work(&s->work);
325} 325}
326 326
327static void saa6588_work(void *data) 327static void saa6588_work(struct work_struct *work)
328{ 328{
329 struct saa6588 *s = (struct saa6588 *)data; 329 struct saa6588 *s = container_of(work, struct saa6588, work);
330 330
331 saa6588_i2c_poll(s); 331 saa6588_i2c_poll(s);
332 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20)); 332 mod_timer(&s->timer, jiffies + msecs_to_jiffies(20));
@@ -419,7 +419,7 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind)
419 saa6588_configure(s); 419 saa6588_configure(s);
420 420
421 /* start polling via eventd */ 421 /* start polling via eventd */
422 INIT_WORK(&s->work, saa6588_work, s); 422 INIT_WORK(&s->work, saa6588_work);
423 init_timer(&s->timer); 423 init_timer(&s->timer);
424 s->timer.function = saa6588_timer; 424 s->timer.function = saa6588_timer;
425 s->timer.data = (unsigned long)s; 425 s->timer.data = (unsigned long)s;
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 65d044086ce9..daaae870a2c4 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -343,9 +343,10 @@ static struct video_device saa7134_empress_template =
343 .minor = -1, 343 .minor = -1,
344}; 344};
345 345
346static void empress_signal_update(void* data) 346static void empress_signal_update(struct work_struct *work)
347{ 347{
348 struct saa7134_dev* dev = (struct saa7134_dev*) data; 348 struct saa7134_dev* dev =
349 container_of(work, struct saa7134_dev, empress_workqueue);
349 350
350 if (dev->nosignal) { 351 if (dev->nosignal) {
351 dprintk("no video signal\n"); 352 dprintk("no video signal\n");
@@ -378,7 +379,7 @@ static int empress_init(struct saa7134_dev *dev)
378 "%s empress (%s)", dev->name, 379 "%s empress (%s)", dev->name,
379 saa7134_boards[dev->board].name); 380 saa7134_boards[dev->board].name);
380 381
381 INIT_WORK(&dev->empress_workqueue, empress_signal_update, (void*) dev); 382 INIT_WORK(&dev->empress_workqueue, empress_signal_update);
382 383
383 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER, 384 err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
384 empress_nr[dev->nr]); 385 empress_nr[dev->nr]);
@@ -399,7 +400,7 @@ static int empress_init(struct saa7134_dev *dev)
399 sizeof(struct saa7134_buf), 400 sizeof(struct saa7134_buf),
400 dev); 401 dev);
401 402
402 empress_signal_update(dev); 403 empress_signal_update(&dev->empress_workqueue);
403 return 0; 404 return 0;
404} 405}
405 406
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 1dd491773150..ef2b55e19910 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -1018,9 +1018,10 @@ mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
1018} 1018}
1019 1019
1020static void 1020static void
1021mptfc_setup_reset(void *arg) 1021mptfc_setup_reset(struct work_struct *work)
1022{ 1022{
1023 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1023 MPT_ADAPTER *ioc =
1024 container_of(work, MPT_ADAPTER, fc_setup_reset_work);
1024 u64 pn; 1025 u64 pn;
1025 struct mptfc_rport_info *ri; 1026 struct mptfc_rport_info *ri;
1026 1027
@@ -1043,9 +1044,10 @@ mptfc_setup_reset(void *arg)
1043} 1044}
1044 1045
1045static void 1046static void
1046mptfc_rescan_devices(void *arg) 1047mptfc_rescan_devices(struct work_struct *work)
1047{ 1048{
1048 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 1049 MPT_ADAPTER *ioc =
1050 container_of(work, MPT_ADAPTER, fc_rescan_work);
1049 int ii; 1051 int ii;
1050 u64 pn; 1052 u64 pn;
1051 struct mptfc_rport_info *ri; 1053 struct mptfc_rport_info *ri;
@@ -1154,8 +1156,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1154 } 1156 }
1155 1157
1156 spin_lock_init(&ioc->fc_rescan_work_lock); 1158 spin_lock_init(&ioc->fc_rescan_work_lock);
1157 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices,(void *)ioc); 1159 INIT_WORK(&ioc->fc_rescan_work, mptfc_rescan_devices);
1158 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset, (void *)ioc); 1160 INIT_WORK(&ioc->fc_setup_reset_work, mptfc_setup_reset);
1159 1161
1160 spin_lock_irqsave(&ioc->FreeQlock, flags); 1162 spin_lock_irqsave(&ioc->FreeQlock, flags);
1161 1163
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c
index 314c3a27585d..b7c4407c5e3f 100644
--- a/drivers/message/fusion/mptlan.c
+++ b/drivers/message/fusion/mptlan.c
@@ -111,7 +111,8 @@ struct mpt_lan_priv {
111 u32 total_received; 111 u32 total_received;
112 struct net_device_stats stats; /* Per device statistics */ 112 struct net_device_stats stats; /* Per device statistics */
113 113
114 struct work_struct post_buckets_task; 114 struct delayed_work post_buckets_task;
115 struct net_device *dev;
115 unsigned long post_buckets_active; 116 unsigned long post_buckets_active;
116}; 117};
117 118
@@ -132,7 +133,7 @@ static int lan_reply (MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf,
132static int mpt_lan_open(struct net_device *dev); 133static int mpt_lan_open(struct net_device *dev);
133static int mpt_lan_reset(struct net_device *dev); 134static int mpt_lan_reset(struct net_device *dev);
134static int mpt_lan_close(struct net_device *dev); 135static int mpt_lan_close(struct net_device *dev);
135static void mpt_lan_post_receive_buckets(void *dev_id); 136static void mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv);
136static void mpt_lan_wake_post_buckets_task(struct net_device *dev, 137static void mpt_lan_wake_post_buckets_task(struct net_device *dev,
137 int priority); 138 int priority);
138static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg); 139static int mpt_lan_receive_post_turbo(struct net_device *dev, u32 tmsg);
@@ -345,7 +346,7 @@ mpt_lan_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
345 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i; 346 priv->mpt_rxfidx[++priv->mpt_rxfidx_tail] = i;
346 spin_unlock_irqrestore(&priv->rxfidx_lock, flags); 347 spin_unlock_irqrestore(&priv->rxfidx_lock, flags);
347 } else { 348 } else {
348 mpt_lan_post_receive_buckets(dev); 349 mpt_lan_post_receive_buckets(priv);
349 netif_wake_queue(dev); 350 netif_wake_queue(dev);
350 } 351 }
351 352
@@ -441,7 +442,7 @@ mpt_lan_open(struct net_device *dev)
441 442
442 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n")); 443 dlprintk((KERN_INFO MYNAM "/lo: Finished initializing RcvCtl\n"));
443 444
444 mpt_lan_post_receive_buckets(dev); 445 mpt_lan_post_receive_buckets(priv);
445 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n", 446 printk(KERN_INFO MYNAM ": %s/%s: interface up & active\n",
446 IOC_AND_NETDEV_NAMES_s_s(dev)); 447 IOC_AND_NETDEV_NAMES_s_s(dev));
447 448
@@ -854,7 +855,7 @@ mpt_lan_wake_post_buckets_task(struct net_device *dev, int priority)
854 855
855 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) { 856 if (test_and_set_bit(0, &priv->post_buckets_active) == 0) {
856 if (priority) { 857 if (priority) {
857 schedule_work(&priv->post_buckets_task); 858 schedule_delayed_work(&priv->post_buckets_task, 0);
858 } else { 859 } else {
859 schedule_delayed_work(&priv->post_buckets_task, 1); 860 schedule_delayed_work(&priv->post_buckets_task, 1);
860 dioprintk((KERN_INFO MYNAM ": post_buckets queued on " 861 dioprintk((KERN_INFO MYNAM ": post_buckets queued on "
@@ -1188,10 +1189,9 @@ mpt_lan_receive_post_reply(struct net_device *dev,
1188/* Simple SGE's only at the moment */ 1189/* Simple SGE's only at the moment */
1189 1190
1190static void 1191static void
1191mpt_lan_post_receive_buckets(void *dev_id) 1192mpt_lan_post_receive_buckets(struct mpt_lan_priv *priv)
1192{ 1193{
1193 struct net_device *dev = dev_id; 1194 struct net_device *dev = priv->dev;
1194 struct mpt_lan_priv *priv = dev->priv;
1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev; 1195 MPT_ADAPTER *mpt_dev = priv->mpt_dev;
1196 MPT_FRAME_HDR *mf; 1196 MPT_FRAME_HDR *mf;
1197 LANReceivePostRequest_t *pRecvReq; 1197 LANReceivePostRequest_t *pRecvReq;
@@ -1335,6 +1335,13 @@ out:
1335 clear_bit(0, &priv->post_buckets_active); 1335 clear_bit(0, &priv->post_buckets_active);
1336} 1336}
1337 1337
1338static void
1339mpt_lan_post_receive_buckets_work(struct work_struct *work)
1340{
1341 mpt_lan_post_receive_buckets(container_of(work, struct mpt_lan_priv,
1342 post_buckets_task.work));
1343}
1344
1338/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1345/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1339static struct net_device * 1346static struct net_device *
1340mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) 1347mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
@@ -1350,11 +1357,13 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
1350 1357
1351 priv = netdev_priv(dev); 1358 priv = netdev_priv(dev);
1352 1359
1360 priv->dev = dev;
1353 priv->mpt_dev = mpt_dev; 1361 priv->mpt_dev = mpt_dev;
1354 priv->pnum = pnum; 1362 priv->pnum = pnum;
1355 1363
1356 memset(&priv->post_buckets_task, 0, sizeof(struct work_struct)); 1364 memset(&priv->post_buckets_task, 0, sizeof(priv->post_buckets_task));
1357 INIT_WORK(&priv->post_buckets_task, mpt_lan_post_receive_buckets, dev); 1365 INIT_DELAYED_WORK(&priv->post_buckets_task,
1366 mpt_lan_post_receive_buckets_work);
1358 priv->post_buckets_active = 0; 1367 priv->post_buckets_active = 0;
1359 1368
1360 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n", 1369 dlprintk((KERN_INFO MYNAM "@%d: bucketlen = %d\n",
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index b752a479f6db..4f0c530e47b0 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2006,9 +2006,10 @@ __mptsas_discovery_work(MPT_ADAPTER *ioc)
2006 *(Mutex LOCKED) 2006 *(Mutex LOCKED)
2007 */ 2007 */
2008static void 2008static void
2009mptsas_discovery_work(void * arg) 2009mptsas_discovery_work(struct work_struct *work)
2010{ 2010{
2011 struct mptsas_discovery_event *ev = arg; 2011 struct mptsas_discovery_event *ev =
2012 container_of(work, struct mptsas_discovery_event, work);
2012 MPT_ADAPTER *ioc = ev->ioc; 2013 MPT_ADAPTER *ioc = ev->ioc;
2013 2014
2014 mutex_lock(&ioc->sas_discovery_mutex); 2015 mutex_lock(&ioc->sas_discovery_mutex);
@@ -2068,9 +2069,9 @@ mptsas_find_phyinfo_by_target(MPT_ADAPTER *ioc, u32 id)
2068 * Work queue thread to clear the persitency table 2069 * Work queue thread to clear the persitency table
2069 */ 2070 */
2070static void 2071static void
2071mptsas_persist_clear_table(void * arg) 2072mptsas_persist_clear_table(struct work_struct *work)
2072{ 2073{
2073 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg; 2074 MPT_ADAPTER *ioc = container_of(work, MPT_ADAPTER, sas_persist_task);
2074 2075
2075 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT); 2076 mptbase_sas_persist_operation(ioc, MPI_SAS_OP_CLEAR_NOT_PRESENT);
2076} 2077}
@@ -2093,9 +2094,10 @@ mptsas_reprobe_target(struct scsi_target *starget, int uld_attach)
2093 * Work queue thread to handle SAS hotplug events 2094 * Work queue thread to handle SAS hotplug events
2094 */ 2095 */
2095static void 2096static void
2096mptsas_hotplug_work(void *arg) 2097mptsas_hotplug_work(struct work_struct *work)
2097{ 2098{
2098 struct mptsas_hotplug_event *ev = arg; 2099 struct mptsas_hotplug_event *ev =
2100 container_of(work, struct mptsas_hotplug_event, work);
2099 MPT_ADAPTER *ioc = ev->ioc; 2101 MPT_ADAPTER *ioc = ev->ioc;
2100 struct mptsas_phyinfo *phy_info; 2102 struct mptsas_phyinfo *phy_info;
2101 struct sas_rphy *rphy; 2103 struct sas_rphy *rphy;
@@ -2341,7 +2343,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2341 break; 2343 break;
2342 } 2344 }
2343 2345
2344 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2346 INIT_WORK(&ev->work, mptsas_hotplug_work);
2345 ev->ioc = ioc; 2347 ev->ioc = ioc;
2346 ev->handle = le16_to_cpu(sas_event_data->DevHandle); 2348 ev->handle = le16_to_cpu(sas_event_data->DevHandle);
2347 ev->parent_handle = 2349 ev->parent_handle =
@@ -2366,7 +2368,7 @@ mptsas_send_sas_event(MPT_ADAPTER *ioc,
2366 * Persistent table is full. 2368 * Persistent table is full.
2367 */ 2369 */
2368 INIT_WORK(&ioc->sas_persist_task, 2370 INIT_WORK(&ioc->sas_persist_task,
2369 mptsas_persist_clear_table, (void *)ioc); 2371 mptsas_persist_clear_table);
2370 schedule_work(&ioc->sas_persist_task); 2372 schedule_work(&ioc->sas_persist_task);
2371 break; 2373 break;
2372 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA: 2374 case MPI_EVENT_SAS_DEV_STAT_RC_SMART_DATA:
@@ -2395,7 +2397,7 @@ mptsas_send_raid_event(MPT_ADAPTER *ioc,
2395 return; 2397 return;
2396 } 2398 }
2397 2399
2398 INIT_WORK(&ev->work, mptsas_hotplug_work, ev); 2400 INIT_WORK(&ev->work, mptsas_hotplug_work);
2399 ev->ioc = ioc; 2401 ev->ioc = ioc;
2400 ev->id = raid_event_data->VolumeID; 2402 ev->id = raid_event_data->VolumeID;
2401 ev->event_type = MPTSAS_IGNORE_EVENT; 2403 ev->event_type = MPTSAS_IGNORE_EVENT;
@@ -2474,7 +2476,7 @@ mptsas_send_discovery_event(MPT_ADAPTER *ioc,
2474 ev = kzalloc(sizeof(*ev), GFP_ATOMIC); 2476 ev = kzalloc(sizeof(*ev), GFP_ATOMIC);
2475 if (!ev) 2477 if (!ev)
2476 return; 2478 return;
2477 INIT_WORK(&ev->work, mptsas_discovery_work, ev); 2479 INIT_WORK(&ev->work, mptsas_discovery_work);
2478 ev->ioc = ioc; 2480 ev->ioc = ioc;
2479 schedule_work(&ev->work); 2481 schedule_work(&ev->work);
2480}; 2482};
@@ -2511,8 +2513,7 @@ mptsas_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *reply)
2511 break; 2513 break;
2512 case MPI_EVENT_PERSISTENT_TABLE_FULL: 2514 case MPI_EVENT_PERSISTENT_TABLE_FULL:
2513 INIT_WORK(&ioc->sas_persist_task, 2515 INIT_WORK(&ioc->sas_persist_task,
2514 mptsas_persist_clear_table, 2516 mptsas_persist_clear_table);
2515 (void *)ioc);
2516 schedule_work(&ioc->sas_persist_task); 2517 schedule_work(&ioc->sas_persist_task);
2517 break; 2518 break;
2518 case MPI_EVENT_SAS_DISCOVERY: 2519 case MPI_EVENT_SAS_DISCOVERY:
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index e4cc3dd5fc9f..f422c0d0621c 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -646,9 +646,10 @@ struct work_queue_wrapper {
646 int disk; 646 int disk;
647}; 647};
648 648
649static void mpt_work_wrapper(void *data) 649static void mpt_work_wrapper(struct work_struct *work)
650{ 650{
651 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 651 struct work_queue_wrapper *wqw =
652 container_of(work, struct work_queue_wrapper, work);
652 struct _MPT_SCSI_HOST *hd = wqw->hd; 653 struct _MPT_SCSI_HOST *hd = wqw->hd;
653 struct Scsi_Host *shost = hd->ioc->sh; 654 struct Scsi_Host *shost = hd->ioc->sh;
654 struct scsi_device *sdev; 655 struct scsi_device *sdev;
@@ -695,7 +696,7 @@ static void mpt_dv_raid(struct _MPT_SCSI_HOST *hd, int disk)
695 disk); 696 disk);
696 return; 697 return;
697 } 698 }
698 INIT_WORK(&wqw->work, mpt_work_wrapper, wqw); 699 INIT_WORK(&wqw->work, mpt_work_wrapper);
699 wqw->hd = hd; 700 wqw->hd = hd;
700 wqw->disk = disk; 701 wqw->disk = disk;
701 702
@@ -784,9 +785,10 @@ MODULE_DEVICE_TABLE(pci, mptspi_pci_table);
784 * renegotiate for a given target 785 * renegotiate for a given target
785 */ 786 */
786static void 787static void
787mptspi_dv_renegotiate_work(void *data) 788mptspi_dv_renegotiate_work(struct work_struct *work)
788{ 789{
789 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 790 struct work_queue_wrapper *wqw =
791 container_of(work, struct work_queue_wrapper, work);
790 struct _MPT_SCSI_HOST *hd = wqw->hd; 792 struct _MPT_SCSI_HOST *hd = wqw->hd;
791 struct scsi_device *sdev; 793 struct scsi_device *sdev;
792 794
@@ -804,7 +806,7 @@ mptspi_dv_renegotiate(struct _MPT_SCSI_HOST *hd)
804 if (!wqw) 806 if (!wqw)
805 return; 807 return;
806 808
807 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work, wqw); 809 INIT_WORK(&wqw->work, mptspi_dv_renegotiate_work);
808 wqw->hd = hd; 810 wqw->hd = hd;
809 811
810 schedule_work(&wqw->work); 812 schedule_work(&wqw->work);
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 64130227574f..7fc7399bd2ec 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -232,7 +232,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
232 break; 232 break;
233 } 233 }
234 234
235 INIT_WORK(&evt->work, (void (*)(void *))drv->event, evt); 235 INIT_WORK(&evt->work, drv->event);
236 queue_work(drv->event_queue, &evt->work); 236 queue_work(drv->event_queue, &evt->work);
237 return 1; 237 return 1;
238 } 238 }
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index a2350640384b..9e529d8dd5cb 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -371,8 +371,10 @@ static int i2o_exec_remove(struct device *dev)
371 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY 371 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
372 * again, otherwise send LCT NOTIFY to get informed on next LCT change. 372 * again, otherwise send LCT NOTIFY to get informed on next LCT change.
373 */ 373 */
374static void i2o_exec_lct_modified(struct i2o_exec_lct_notify_work *work) 374static void i2o_exec_lct_modified(struct work_struct *_work)
375{ 375{
376 struct i2o_exec_lct_notify_work *work =
377 container_of(_work, struct i2o_exec_lct_notify_work, work);
376 u32 change_ind = 0; 378 u32 change_ind = 0;
377 struct i2o_controller *c = work->c; 379 struct i2o_controller *c = work->c;
378 380
@@ -439,8 +441,7 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
439 441
440 work->c = c; 442 work->c = c;
441 443
442 INIT_WORK(&work->work, (void (*)(void *))i2o_exec_lct_modified, 444 INIT_WORK(&work->work, i2o_exec_lct_modified);
443 work);
444 queue_work(i2o_exec_driver.event_queue, &work->work); 445 queue_work(i2o_exec_driver.event_queue, &work->work);
445 return 1; 446 return 1;
446 } 447 }
@@ -460,13 +461,15 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
460 461
461/** 462/**
462 * i2o_exec_event - Event handling function 463 * i2o_exec_event - Event handling function
463 * @evt: Event which occurs 464 * @work: Work item in occurring event
464 * 465 *
465 * Handles events send by the Executive device. At the moment does not do 466 * Handles events send by the Executive device. At the moment does not do
466 * anything useful. 467 * anything useful.
467 */ 468 */
468static void i2o_exec_event(struct i2o_event *evt) 469static void i2o_exec_event(struct work_struct *work)
469{ 470{
471 struct i2o_event *evt = container_of(work, struct i2o_event, work);
472
470 if (likely(evt->i2o_dev)) 473 if (likely(evt->i2o_dev))
471 osm_debug("Event received from device: %d\n", 474 osm_debug("Event received from device: %d\n",
472 evt->i2o_dev->lct_data.tid); 475 evt->i2o_dev->lct_data.tid);
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index eaba81bf2eca..70ae00253321 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -419,16 +419,18 @@ static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
419 419
420/** 420/**
421 * i2o_block_delayed_request_fn - delayed request queue function 421 * i2o_block_delayed_request_fn - delayed request queue function
422 * delayed_request: the delayed request with the queue to start 422 * @work: the delayed request with the queue to start
423 * 423 *
424 * If the request queue is stopped for a disk, and there is no open 424 * If the request queue is stopped for a disk, and there is no open
425 * request, a new event is created, which calls this function to start 425 * request, a new event is created, which calls this function to start
426 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never 426 * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never
427 * be started again. 427 * be started again.
428 */ 428 */
429static void i2o_block_delayed_request_fn(void *delayed_request) 429static void i2o_block_delayed_request_fn(struct work_struct *work)
430{ 430{
431 struct i2o_block_delayed_request *dreq = delayed_request; 431 struct i2o_block_delayed_request *dreq =
432 container_of(work, struct i2o_block_delayed_request,
433 work.work);
432 struct request_queue *q = dreq->queue; 434 struct request_queue *q = dreq->queue;
433 unsigned long flags; 435 unsigned long flags;
434 436
@@ -538,8 +540,9 @@ static int i2o_block_reply(struct i2o_controller *c, u32 m,
538 return 1; 540 return 1;
539}; 541};
540 542
541static void i2o_block_event(struct i2o_event *evt) 543static void i2o_block_event(struct work_struct *work)
542{ 544{
545 struct i2o_event *evt = container_of(work, struct i2o_event, work);
543 osm_debug("event received\n"); 546 osm_debug("event received\n");
544 kfree(evt); 547 kfree(evt);
545}; 548};
@@ -938,8 +941,8 @@ static void i2o_block_request_fn(struct request_queue *q)
938 continue; 941 continue;
939 942
940 dreq->queue = q; 943 dreq->queue = q;
941 INIT_WORK(&dreq->work, i2o_block_delayed_request_fn, 944 INIT_DELAYED_WORK(&dreq->work,
942 dreq); 945 i2o_block_delayed_request_fn);
943 946
944 if (!queue_delayed_work(i2o_block_driver.event_queue, 947 if (!queue_delayed_work(i2o_block_driver.event_queue,
945 &dreq->work, 948 &dreq->work,
diff --git a/drivers/message/i2o/i2o_block.h b/drivers/message/i2o/i2o_block.h
index 4fdaa5bda412..d9fdc95b440d 100644
--- a/drivers/message/i2o/i2o_block.h
+++ b/drivers/message/i2o/i2o_block.h
@@ -96,7 +96,7 @@ struct i2o_block_request {
96 96
97/* I2O Block device delayed request */ 97/* I2O Block device delayed request */
98struct i2o_block_delayed_request { 98struct i2o_block_delayed_request {
99 struct work_struct work; 99 struct delayed_work work;
100 struct request_queue *queue; 100 struct request_queue *queue;
101}; 101};
102 102
diff --git a/drivers/misc/tifm_7xx1.c b/drivers/misc/tifm_7xx1.c
index 1ba8754e9383..2ab7add78f94 100644
--- a/drivers/misc/tifm_7xx1.c
+++ b/drivers/misc/tifm_7xx1.c
@@ -33,9 +33,10 @@ static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
33 spin_unlock_irqrestore(&fm->lock, flags); 33 spin_unlock_irqrestore(&fm->lock, flags);
34} 34}
35 35
36static void tifm_7xx1_remove_media(void *adapter) 36static void tifm_7xx1_remove_media(struct work_struct *work)
37{ 37{
38 struct tifm_adapter *fm = adapter; 38 struct tifm_adapter *fm =
39 container_of(work, struct tifm_adapter, media_remover);
39 unsigned long flags; 40 unsigned long flags;
40 int cnt; 41 int cnt;
41 struct tifm_dev *sock; 42 struct tifm_dev *sock;
@@ -169,9 +170,10 @@ tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
169 return base_addr + ((sock_num + 1) << 10); 170 return base_addr + ((sock_num + 1) << 10);
170} 171}
171 172
172static void tifm_7xx1_insert_media(void *adapter) 173static void tifm_7xx1_insert_media(struct work_struct *work)
173{ 174{
174 struct tifm_adapter *fm = adapter; 175 struct tifm_adapter *fm =
176 container_of(work, struct tifm_adapter, media_inserter);
175 unsigned long flags; 177 unsigned long flags;
176 tifm_media_id media_id; 178 tifm_media_id media_id;
177 char *card_name = "xx"; 179 char *card_name = "xx";
@@ -261,7 +263,7 @@ static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
261 spin_unlock_irqrestore(&fm->lock, flags); 263 spin_unlock_irqrestore(&fm->lock, flags);
262 flush_workqueue(fm->wq); 264 flush_workqueue(fm->wq);
263 265
264 tifm_7xx1_remove_media(fm); 266 tifm_7xx1_remove_media(&fm->media_remover);
265 267
266 pci_set_power_state(dev, PCI_D3hot); 268 pci_set_power_state(dev, PCI_D3hot);
267 pci_disable_device(dev); 269 pci_disable_device(dev);
@@ -328,8 +330,8 @@ static int tifm_7xx1_probe(struct pci_dev *dev,
328 if (!fm->sockets) 330 if (!fm->sockets)
329 goto err_out_free; 331 goto err_out_free;
330 332
331 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media, fm); 333 INIT_WORK(&fm->media_inserter, tifm_7xx1_insert_media);
332 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media, fm); 334 INIT_WORK(&fm->media_remover, tifm_7xx1_remove_media);
333 fm->eject = tifm_7xx1_eject; 335 fm->eject = tifm_7xx1_eject;
334 pci_set_drvdata(dev, fm); 336 pci_set_drvdata(dev, fm);
335 337
@@ -384,7 +386,7 @@ static void tifm_7xx1_remove(struct pci_dev *dev)
384 386
385 flush_workqueue(fm->wq); 387 flush_workqueue(fm->wq);
386 388
387 tifm_7xx1_remove_media(fm); 389 tifm_7xx1_remove_media(&fm->media_remover);
388 390
389 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE); 391 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
390 free_irq(dev->irq, fm); 392 free_irq(dev->irq, fm);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 9d190022a490..6f2a282e2b97 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1419,18 +1419,16 @@ static void mmc_setup(struct mmc_host *host)
1419 */ 1419 */
1420void mmc_detect_change(struct mmc_host *host, unsigned long delay) 1420void mmc_detect_change(struct mmc_host *host, unsigned long delay)
1421{ 1421{
1422 if (delay) 1422 mmc_schedule_delayed_work(&host->detect, delay);
1423 mmc_schedule_delayed_work(&host->detect, delay);
1424 else
1425 mmc_schedule_work(&host->detect);
1426} 1423}
1427 1424
1428EXPORT_SYMBOL(mmc_detect_change); 1425EXPORT_SYMBOL(mmc_detect_change);
1429 1426
1430 1427
1431static void mmc_rescan(void *data) 1428static void mmc_rescan(struct work_struct *work)
1432{ 1429{
1433 struct mmc_host *host = data; 1430 struct mmc_host *host =
1431 container_of(work, struct mmc_host, detect.work);
1434 struct list_head *l, *n; 1432 struct list_head *l, *n;
1435 unsigned char power_mode; 1433 unsigned char power_mode;
1436 1434
@@ -1513,7 +1511,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
1513 spin_lock_init(&host->lock); 1511 spin_lock_init(&host->lock);
1514 init_waitqueue_head(&host->wq); 1512 init_waitqueue_head(&host->wq);
1515 INIT_LIST_HEAD(&host->cards); 1513 INIT_LIST_HEAD(&host->cards);
1516 INIT_WORK(&host->detect, mmc_rescan, host); 1514 INIT_DELAYED_WORK(&host->detect, mmc_rescan);
1517 1515
1518 /* 1516 /*
1519 * By default, hosts do not support SGIO or large requests. 1517 * By default, hosts do not support SGIO or large requests.
@@ -1611,7 +1609,7 @@ EXPORT_SYMBOL(mmc_suspend_host);
1611 */ 1609 */
1612int mmc_resume_host(struct mmc_host *host) 1610int mmc_resume_host(struct mmc_host *host)
1613{ 1611{
1614 mmc_rescan(host); 1612 mmc_rescan(&host->detect.work);
1615 1613
1616 return 0; 1614 return 0;
1617} 1615}
diff --git a/drivers/mmc/mmc.h b/drivers/mmc/mmc.h
index cd5e0ab3d84b..149affe0b686 100644
--- a/drivers/mmc/mmc.h
+++ b/drivers/mmc/mmc.h
@@ -20,6 +20,6 @@ void mmc_remove_host_sysfs(struct mmc_host *host);
20void mmc_free_host_sysfs(struct mmc_host *host); 20void mmc_free_host_sysfs(struct mmc_host *host);
21 21
22int mmc_schedule_work(struct work_struct *work); 22int mmc_schedule_work(struct work_struct *work);
23int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay); 23int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay);
24void mmc_flush_scheduled_work(void); 24void mmc_flush_scheduled_work(void);
25#endif 25#endif
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index ac5329636045..e334acd045bc 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -321,17 +321,9 @@ void mmc_free_host_sysfs(struct mmc_host *host)
321static struct workqueue_struct *workqueue; 321static struct workqueue_struct *workqueue;
322 322
323/* 323/*
324 * Internal function. Schedule work in the MMC work queue.
325 */
326int mmc_schedule_work(struct work_struct *work)
327{
328 return queue_work(workqueue, work);
329}
330
331/*
332 * Internal function. Schedule delayed work in the MMC work queue. 324 * Internal function. Schedule delayed work in the MMC work queue.
333 */ 325 */
334int mmc_schedule_delayed_work(struct work_struct *work, unsigned long delay) 326int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay)
335{ 327{
336 return queue_delayed_work(workqueue, work, delay); 328 return queue_delayed_work(workqueue, work, delay);
337} 329}
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 0fdc55b08a6d..e846499a004c 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -99,7 +99,7 @@ struct tifm_sd {
99 99
100 struct mmc_request *req; 100 struct mmc_request *req;
101 struct work_struct cmd_handler; 101 struct work_struct cmd_handler;
102 struct work_struct abort_handler; 102 struct delayed_work abort_handler;
103 wait_queue_head_t can_eject; 103 wait_queue_head_t can_eject;
104 104
105 size_t written_blocks; 105 size_t written_blocks;
@@ -496,9 +496,9 @@ err_out:
496 mmc_request_done(mmc, mrq); 496 mmc_request_done(mmc, mrq);
497} 497}
498 498
499static void tifm_sd_end_cmd(void *data) 499static void tifm_sd_end_cmd(struct work_struct *work)
500{ 500{
501 struct tifm_sd *host = data; 501 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
502 struct tifm_dev *sock = host->dev; 502 struct tifm_dev *sock = host->dev;
503 struct mmc_host *mmc = tifm_get_drvdata(sock); 503 struct mmc_host *mmc = tifm_get_drvdata(sock);
504 struct mmc_request *mrq; 504 struct mmc_request *mrq;
@@ -608,9 +608,9 @@ err_out:
608 mmc_request_done(mmc, mrq); 608 mmc_request_done(mmc, mrq);
609} 609}
610 610
611static void tifm_sd_end_cmd_nodma(void *data) 611static void tifm_sd_end_cmd_nodma(struct work_struct *work)
612{ 612{
613 struct tifm_sd *host = (struct tifm_sd*)data; 613 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
614 struct tifm_dev *sock = host->dev; 614 struct tifm_dev *sock = host->dev;
615 struct mmc_host *mmc = tifm_get_drvdata(sock); 615 struct mmc_host *mmc = tifm_get_drvdata(sock);
616 struct mmc_request *mrq; 616 struct mmc_request *mrq;
@@ -661,11 +661,14 @@ static void tifm_sd_end_cmd_nodma(void *data)
661 mmc_request_done(mmc, mrq); 661 mmc_request_done(mmc, mrq);
662} 662}
663 663
664static void tifm_sd_abort(void *data) 664static void tifm_sd_abort(struct work_struct *work)
665{ 665{
666 struct tifm_sd *host =
667 container_of(work, struct tifm_sd, abort_handler.work);
668
666 printk(KERN_ERR DRIVER_NAME 669 printk(KERN_ERR DRIVER_NAME
667 ": card failed to respond for a long period of time"); 670 ": card failed to respond for a long period of time");
668 tifm_eject(((struct tifm_sd*)data)->dev); 671 tifm_eject(host->dev);
669} 672}
670 673
671static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios) 674static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
@@ -762,9 +765,9 @@ static struct mmc_host_ops tifm_sd_ops = {
762 .get_ro = tifm_sd_ro 765 .get_ro = tifm_sd_ro
763}; 766};
764 767
765static void tifm_sd_register_host(void *data) 768static void tifm_sd_register_host(struct work_struct *work)
766{ 769{
767 struct tifm_sd *host = (struct tifm_sd*)data; 770 struct tifm_sd *host = container_of(work, struct tifm_sd, cmd_handler);
768 struct tifm_dev *sock = host->dev; 771 struct tifm_dev *sock = host->dev;
769 struct mmc_host *mmc = tifm_get_drvdata(sock); 772 struct mmc_host *mmc = tifm_get_drvdata(sock);
770 unsigned long flags; 773 unsigned long flags;
@@ -772,8 +775,7 @@ static void tifm_sd_register_host(void *data)
772 spin_lock_irqsave(&sock->lock, flags); 775 spin_lock_irqsave(&sock->lock, flags);
773 host->flags |= HOST_REG; 776 host->flags |= HOST_REG;
774 PREPARE_WORK(&host->cmd_handler, 777 PREPARE_WORK(&host->cmd_handler,
775 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd, 778 no_dma ? tifm_sd_end_cmd_nodma : tifm_sd_end_cmd);
776 data);
777 spin_unlock_irqrestore(&sock->lock, flags); 779 spin_unlock_irqrestore(&sock->lock, flags);
778 dev_dbg(&sock->dev, "adding host\n"); 780 dev_dbg(&sock->dev, "adding host\n");
779 mmc_add_host(mmc); 781 mmc_add_host(mmc);
@@ -799,8 +801,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
799 host->dev = sock; 801 host->dev = sock;
800 host->clk_div = 61; 802 host->clk_div = 61;
801 init_waitqueue_head(&host->can_eject); 803 init_waitqueue_head(&host->can_eject);
802 INIT_WORK(&host->cmd_handler, tifm_sd_register_host, host); 804 INIT_WORK(&host->cmd_handler, tifm_sd_register_host);
803 INIT_WORK(&host->abort_handler, tifm_sd_abort, host); 805 INIT_DELAYED_WORK(&host->abort_handler, tifm_sd_abort);
804 806
805 tifm_set_drvdata(sock, mmc); 807 tifm_set_drvdata(sock, mmc);
806 sock->signal_irq = tifm_sd_signal_irq; 808 sock->signal_irq = tifm_sd_signal_irq;
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index d02ed51abfcc..931028f672de 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -594,7 +594,7 @@ struct rtl8139_private {
594 u32 rx_config; 594 u32 rx_config;
595 struct rtl_extra_stats xstats; 595 struct rtl_extra_stats xstats;
596 596
597 struct work_struct thread; 597 struct delayed_work thread;
598 598
599 struct mii_if_info mii; 599 struct mii_if_info mii;
600 unsigned int regs_len; 600 unsigned int regs_len;
@@ -636,8 +636,8 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev);
636static void rtl8139_set_rx_mode (struct net_device *dev); 636static void rtl8139_set_rx_mode (struct net_device *dev);
637static void __set_rx_mode (struct net_device *dev); 637static void __set_rx_mode (struct net_device *dev);
638static void rtl8139_hw_start (struct net_device *dev); 638static void rtl8139_hw_start (struct net_device *dev);
639static void rtl8139_thread (void *_data); 639static void rtl8139_thread (struct work_struct *work);
640static void rtl8139_tx_timeout_task(void *_data); 640static void rtl8139_tx_timeout_task(struct work_struct *work);
641static const struct ethtool_ops rtl8139_ethtool_ops; 641static const struct ethtool_ops rtl8139_ethtool_ops;
642 642
643/* write MMIO register, with flush */ 643/* write MMIO register, with flush */
@@ -1010,7 +1010,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1)); 1010 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1));
1011 spin_lock_init (&tp->lock); 1011 spin_lock_init (&tp->lock);
1012 spin_lock_init (&tp->rx_lock); 1012 spin_lock_init (&tp->rx_lock);
1013 INIT_WORK(&tp->thread, rtl8139_thread, dev); 1013 INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
1014 tp->mii.dev = dev; 1014 tp->mii.dev = dev;
1015 tp->mii.mdio_read = mdio_read; 1015 tp->mii.mdio_read = mdio_read;
1016 tp->mii.mdio_write = mdio_write; 1016 tp->mii.mdio_write = mdio_write;
@@ -1596,15 +1596,16 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1596 RTL_R8 (Config1)); 1596 RTL_R8 (Config1));
1597} 1597}
1598 1598
1599static void rtl8139_thread (void *_data) 1599static void rtl8139_thread (struct work_struct *work)
1600{ 1600{
1601 struct net_device *dev = _data; 1601 struct rtl8139_private *tp =
1602 struct rtl8139_private *tp = netdev_priv(dev); 1602 container_of(work, struct rtl8139_private, thread.work);
1603 struct net_device *dev = tp->mii.dev;
1603 unsigned long thr_delay = next_tick; 1604 unsigned long thr_delay = next_tick;
1604 1605
1605 if (tp->watchdog_fired) { 1606 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0; 1607 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data); 1608 rtl8139_tx_timeout_task(work);
1608 } else if (rtnl_trylock()) { 1609 } else if (rtnl_trylock()) {
1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1610 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1610 rtnl_unlock (); 1611 rtnl_unlock ();
@@ -1646,10 +1647,11 @@ static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1646 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ 1647 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */
1647} 1648}
1648 1649
1649static void rtl8139_tx_timeout_task (void *_data) 1650static void rtl8139_tx_timeout_task (struct work_struct *work)
1650{ 1651{
1651 struct net_device *dev = _data; 1652 struct rtl8139_private *tp =
1652 struct rtl8139_private *tp = netdev_priv(dev); 1653 container_of(work, struct rtl8139_private, thread.work);
1654 struct net_device *dev = tp->mii.dev;
1653 void __iomem *ioaddr = tp->mmio_addr; 1655 void __iomem *ioaddr = tp->mmio_addr;
1654 int i; 1656 int i;
1655 u8 tmp8; 1657 u8 tmp8;
@@ -1695,7 +1697,7 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1695 struct rtl8139_private *tp = netdev_priv(dev); 1697 struct rtl8139_private *tp = netdev_priv(dev);
1696 1698
1697 if (!tp->have_thread) { 1699 if (!tp->have_thread) {
1698 INIT_WORK(&tp->thread, rtl8139_tx_timeout_task, dev); 1700 INIT_DELAYED_WORK(&tp->thread, rtl8139_tx_timeout_task);
1699 schedule_delayed_work(&tp->thread, next_tick); 1701 schedule_delayed_work(&tp->thread, next_tick);
1700 } else 1702 } else
1701 tp->watchdog_fired = 1; 1703 tp->watchdog_fired = 1;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index fc2f1d1c7ead..5bacb7587df4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -4411,9 +4411,9 @@ bnx2_open(struct net_device *dev)
4411} 4411}
4412 4412
4413static void 4413static void
4414bnx2_reset_task(void *data) 4414bnx2_reset_task(struct work_struct *work)
4415{ 4415{
4416 struct bnx2 *bp = data; 4416 struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
4417 4417
4418 if (!netif_running(bp->dev)) 4418 if (!netif_running(bp->dev))
4419 return; 4419 return;
@@ -5702,7 +5702,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5702 bp->pdev = pdev; 5702 bp->pdev = pdev;
5703 5703
5704 spin_lock_init(&bp->phy_lock); 5704 spin_lock_init(&bp->phy_lock);
5705 INIT_WORK(&bp->reset_task, bnx2_reset_task, bp); 5705 INIT_WORK(&bp->reset_task, bnx2_reset_task);
5706 5706
5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 5707 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1); 5708 mem_len = MB_GET_CID_ADDR(TX_TSS_CID + 1);
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index fd2cc13f7d97..c8126484c2be 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4066,9 +4066,9 @@ static int cas_alloc_rxds(struct cas *cp)
4066 return 0; 4066 return 0;
4067} 4067}
4068 4068
4069static void cas_reset_task(void *data) 4069static void cas_reset_task(struct work_struct *work)
4070{ 4070{
4071 struct cas *cp = (struct cas *) data; 4071 struct cas *cp = container_of(work, struct cas, reset_task);
4072#if 0 4072#if 0
4073 int pending = atomic_read(&cp->reset_task_pending); 4073 int pending = atomic_read(&cp->reset_task_pending);
4074#else 4074#else
@@ -5006,7 +5006,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5006 atomic_set(&cp->reset_task_pending_spare, 0); 5006 atomic_set(&cp->reset_task_pending_spare, 0);
5007 atomic_set(&cp->reset_task_pending_mtu, 0); 5007 atomic_set(&cp->reset_task_pending_mtu, 0);
5008#endif 5008#endif
5009 INIT_WORK(&cp->reset_task, cas_reset_task, cp); 5009 INIT_WORK(&cp->reset_task, cas_reset_task);
5010 5010
5011 /* Default link parameters */ 5011 /* Default link parameters */
5012 if (link_mode >= 0 && link_mode <= 6) 5012 if (link_mode >= 0 && link_mode <= 6)
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index b265941e1372..74758d2c7af8 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -279,7 +279,7 @@ struct adapter {
279 struct petp *tp; 279 struct petp *tp;
280 280
281 struct port_info port[MAX_NPORTS]; 281 struct port_info port[MAX_NPORTS];
282 struct work_struct stats_update_task; 282 struct delayed_work stats_update_task;
283 struct timer_list stats_update_timer; 283 struct timer_list stats_update_timer;
284 284
285 spinlock_t tpi_lock; 285 spinlock_t tpi_lock;
diff --git a/drivers/net/chelsio/cphy.h b/drivers/net/chelsio/cphy.h
index 60901f25014e..cf9143499882 100644
--- a/drivers/net/chelsio/cphy.h
+++ b/drivers/net/chelsio/cphy.h
@@ -91,7 +91,7 @@ struct cphy {
91 int state; /* Link status state machine */ 91 int state; /* Link status state machine */
92 adapter_t *adapter; /* associated adapter */ 92 adapter_t *adapter; /* associated adapter */
93 93
94 struct work_struct phy_update; 94 struct delayed_work phy_update;
95 95
96 u16 bmsr; 96 u16 bmsr;
97 int count; 97 int count;
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 53bec6739812..de48eadddbc4 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -953,10 +953,11 @@ static void t1_netpoll(struct net_device *dev)
953 * Periodic accumulation of MAC statistics. This is used only if the MAC 953 * Periodic accumulation of MAC statistics. This is used only if the MAC
954 * does not have any other way to prevent stats counter overflow. 954 * does not have any other way to prevent stats counter overflow.
955 */ 955 */
956static void mac_stats_task(void *data) 956static void mac_stats_task(struct work_struct *work)
957{ 957{
958 int i; 958 int i;
959 struct adapter *adapter = data; 959 struct adapter *adapter =
960 container_of(work, struct adapter, stats_update_task.work);
960 961
961 for_each_port(adapter, i) { 962 for_each_port(adapter, i) {
962 struct port_info *p = &adapter->port[i]; 963 struct port_info *p = &adapter->port[i];
@@ -977,9 +978,10 @@ static void mac_stats_task(void *data)
977/* 978/*
978 * Processes elmer0 external interrupts in process context. 979 * Processes elmer0 external interrupts in process context.
979 */ 980 */
980static void ext_intr_task(void *data) 981static void ext_intr_task(struct work_struct *work)
981{ 982{
982 struct adapter *adapter = data; 983 struct adapter *adapter =
984 container_of(work, struct adapter, ext_intr_handler_task);
983 985
984 t1_elmer0_ext_intr_handler(adapter); 986 t1_elmer0_ext_intr_handler(adapter);
985 987
@@ -1113,9 +1115,9 @@ static int __devinit init_one(struct pci_dev *pdev,
1113 spin_lock_init(&adapter->mac_lock); 1115 spin_lock_init(&adapter->mac_lock);
1114 1116
1115 INIT_WORK(&adapter->ext_intr_handler_task, 1117 INIT_WORK(&adapter->ext_intr_handler_task,
1116 ext_intr_task, adapter); 1118 ext_intr_task);
1117 INIT_WORK(&adapter->stats_update_task, mac_stats_task, 1119 INIT_DELAYED_WORK(&adapter->stats_update_task,
1118 adapter); 1120 mac_stats_task);
1119 1121
1120 pci_set_drvdata(pdev, netdev); 1122 pci_set_drvdata(pdev, netdev);
1121 } 1123 }
diff --git a/drivers/net/chelsio/my3126.c b/drivers/net/chelsio/my3126.c
index 0b90014d5b3e..c7731b6f9de3 100644
--- a/drivers/net/chelsio/my3126.c
+++ b/drivers/net/chelsio/my3126.c
@@ -93,9 +93,11 @@ static int my3126_interrupt_handler(struct cphy *cphy)
93 return cphy_cause_link_change; 93 return cphy_cause_link_change;
94} 94}
95 95
96static void my3216_poll(void *arg) 96static void my3216_poll(struct work_struct *work)
97{ 97{
98 my3126_interrupt_handler(arg); 98 struct cphy *cphy = container_of(work, struct cphy, phy_update.work);
99
100 my3126_interrupt_handler(cphy);
99} 101}
100 102
101static int my3126_set_loopback(struct cphy *cphy, int on) 103static int my3126_set_loopback(struct cphy *cphy, int on)
@@ -171,7 +173,7 @@ static struct cphy *my3126_phy_create(adapter_t *adapter,
171 if (cphy) 173 if (cphy)
172 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops); 174 cphy_init(cphy, adapter, phy_addr, &my3126_ops, mdio_ops);
173 175
174 INIT_WORK(&cphy->phy_update, my3216_poll, cphy); 176 INIT_DELAYED_WORK(&cphy->phy_update, my3216_poll);
175 cphy->bmsr = 0; 177 cphy->bmsr = 0;
176 178
177 return (cphy); 179 return (cphy);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 3a8df479cbda..03bf164f9e8d 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2102,9 +2102,10 @@ static void e100_tx_timeout(struct net_device *netdev)
2102 schedule_work(&nic->tx_timeout_task); 2102 schedule_work(&nic->tx_timeout_task);
2103} 2103}
2104 2104
2105static void e100_tx_timeout_task(struct net_device *netdev) 2105static void e100_tx_timeout_task(struct work_struct *work)
2106{ 2106{
2107 struct nic *nic = netdev_priv(netdev); 2107 struct nic *nic = container_of(work, struct nic, tx_timeout_task);
2108 struct net_device *netdev = nic->netdev;
2108 2109
2109 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n", 2110 DPRINTK(TX_ERR, DEBUG, "scb.status=0x%02X\n",
2110 readb(&nic->csr->scb.status)); 2111 readb(&nic->csr->scb.status));
@@ -2637,8 +2638,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2637 nic->blink_timer.function = e100_blink_led; 2638 nic->blink_timer.function = e100_blink_led;
2638 nic->blink_timer.data = (unsigned long)nic; 2639 nic->blink_timer.data = (unsigned long)nic;
2639 2640
2640 INIT_WORK(&nic->tx_timeout_task, 2641 INIT_WORK(&nic->tx_timeout_task, e100_tx_timeout_task);
2641 (void (*)(void *))e100_tx_timeout_task, netdev);
2642 2642
2643 if((err = e100_alloc(nic))) { 2643 if((err = e100_alloc(nic))) {
2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n"); 2644 DPRINTK(PROBE, ERR, "Cannot alloc driver memory, aborting.\n");
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 32dde0adb683..73f3a85fd238 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -190,7 +190,7 @@ void e1000_set_ethtool_ops(struct net_device *netdev);
190static void e1000_enter_82542_rst(struct e1000_adapter *adapter); 190static void e1000_enter_82542_rst(struct e1000_adapter *adapter);
191static void e1000_leave_82542_rst(struct e1000_adapter *adapter); 191static void e1000_leave_82542_rst(struct e1000_adapter *adapter);
192static void e1000_tx_timeout(struct net_device *dev); 192static void e1000_tx_timeout(struct net_device *dev);
193static void e1000_reset_task(struct net_device *dev); 193static void e1000_reset_task(struct work_struct *work);
194static void e1000_smartspeed(struct e1000_adapter *adapter); 194static void e1000_smartspeed(struct e1000_adapter *adapter);
195static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, 195static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
196 struct sk_buff *skb); 196 struct sk_buff *skb);
@@ -914,8 +914,7 @@ e1000_probe(struct pci_dev *pdev,
914 adapter->phy_info_timer.function = &e1000_update_phy_info; 914 adapter->phy_info_timer.function = &e1000_update_phy_info;
915 adapter->phy_info_timer.data = (unsigned long) adapter; 915 adapter->phy_info_timer.data = (unsigned long) adapter;
916 916
917 INIT_WORK(&adapter->reset_task, 917 INIT_WORK(&adapter->reset_task, e1000_reset_task);
918 (void (*)(void *))e1000_reset_task, netdev);
919 918
920 e1000_check_options(adapter); 919 e1000_check_options(adapter);
921 920
@@ -3306,9 +3305,10 @@ e1000_tx_timeout(struct net_device *netdev)
3306} 3305}
3307 3306
3308static void 3307static void
3309e1000_reset_task(struct net_device *netdev) 3308e1000_reset_task(struct work_struct *work)
3310{ 3309{
3311 struct e1000_adapter *adapter = netdev_priv(netdev); 3310 struct e1000_adapter *adapter =
3311 container_of(work, struct e1000_adapter, reset_task);
3312 3312
3313 e1000_reinit_locked(adapter); 3313 e1000_reinit_locked(adapter);
3314} 3314}
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 6ad696101418..83fa32f72398 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -2224,11 +2224,12 @@ static int ehea_stop(struct net_device *dev)
2224 return ret; 2224 return ret;
2225} 2225}
2226 2226
2227static void ehea_reset_port(void *data) 2227static void ehea_reset_port(struct work_struct *work)
2228{ 2228{
2229 int ret; 2229 int ret;
2230 struct net_device *dev = data; 2230 struct ehea_port *port =
2231 struct ehea_port *port = netdev_priv(dev); 2231 container_of(work, struct ehea_port, reset_task);
2232 struct net_device *dev = port->netdev;
2232 2233
2233 port->resets++; 2234 port->resets++;
2234 down(&port->port_lock); 2235 down(&port->port_lock);
@@ -2379,7 +2380,7 @@ static int ehea_setup_single_port(struct ehea_port *port,
2379 dev->tx_timeout = &ehea_tx_watchdog; 2380 dev->tx_timeout = &ehea_tx_watchdog;
2380 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT; 2381 dev->watchdog_timeo = EHEA_WATCH_DOG_TIMEOUT;
2381 2382
2382 INIT_WORK(&port->reset_task, ehea_reset_port, dev); 2383 INIT_WORK(&port->reset_task, ehea_reset_port);
2383 2384
2384 ehea_set_ethtool_ops(dev); 2385 ehea_set_ethtool_ops(dev);
2385 2386
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c
index 1ed9cccd3c11..3c33d6f6a6a6 100644
--- a/drivers/net/hamradio/baycom_epp.c
+++ b/drivers/net/hamradio/baycom_epp.c
@@ -168,8 +168,9 @@ struct baycom_state {
168 int magic; 168 int magic;
169 169
170 struct pardevice *pdev; 170 struct pardevice *pdev;
171 struct net_device *dev;
171 unsigned int work_running; 172 unsigned int work_running;
172 struct work_struct run_work; 173 struct delayed_work run_work;
173 unsigned int modem; 174 unsigned int modem;
174 unsigned int bitrate; 175 unsigned int bitrate;
175 unsigned char stat; 176 unsigned char stat;
@@ -659,16 +660,18 @@ static int receive(struct net_device *dev, int cnt)
659#define GETTICK(x) 660#define GETTICK(x)
660#endif /* __i386__ */ 661#endif /* __i386__ */
661 662
662static void epp_bh(struct net_device *dev) 663static void epp_bh(struct work_struct *work)
663{ 664{
665 struct net_device *dev;
664 struct baycom_state *bc; 666 struct baycom_state *bc;
665 struct parport *pp; 667 struct parport *pp;
666 unsigned char stat; 668 unsigned char stat;
667 unsigned char tmp[2]; 669 unsigned char tmp[2];
668 unsigned int time1 = 0, time2 = 0, time3 = 0; 670 unsigned int time1 = 0, time2 = 0, time3 = 0;
669 int cnt, cnt2; 671 int cnt, cnt2;
670 672
671 bc = netdev_priv(dev); 673 bc = container_of(work, struct baycom_state, run_work.work);
674 dev = bc->dev;
672 if (!bc->work_running) 675 if (!bc->work_running)
673 return; 676 return;
674 baycom_int_freq(bc); 677 baycom_int_freq(bc);
@@ -889,7 +892,7 @@ static int epp_open(struct net_device *dev)
889 return -EBUSY; 892 return -EBUSY;
890 } 893 }
891 dev->irq = /*pp->irq*/ 0; 894 dev->irq = /*pp->irq*/ 0;
892 INIT_WORK(&bc->run_work, (void *)(void *)epp_bh, dev); 895 INIT_DELAYED_WORK(&bc->run_work, epp_bh);
893 bc->work_running = 1; 896 bc->work_running = 1;
894 bc->modem = EPP_CONVENTIONAL; 897 bc->modem = EPP_CONVENTIONAL;
895 if (eppconfig(bc)) 898 if (eppconfig(bc))
@@ -1213,6 +1216,7 @@ static void __init baycom_epp_dev_setup(struct net_device *dev)
1213 /* 1216 /*
1214 * initialize part of the baycom_state struct 1217 * initialize part of the baycom_state struct
1215 */ 1218 */
1219 bc->dev = dev;
1216 bc->magic = BAYCOM_MAGIC; 1220 bc->magic = BAYCOM_MAGIC;
1217 bc->cfg.fclk = 19666600; 1221 bc->cfg.fclk = 19666600;
1218 bc->cfg.bps = 9600; 1222 bc->cfg.bps = 9600;
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0f8b9afd55b4..e6e721aff6f6 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -252,7 +252,7 @@ static inline void z8530_isr(struct scc_info *info);
252static irqreturn_t scc_isr(int irq, void *dev_id); 252static irqreturn_t scc_isr(int irq, void *dev_id);
253static void rx_isr(struct scc_priv *priv); 253static void rx_isr(struct scc_priv *priv);
254static void special_condition(struct scc_priv *priv, int rc); 254static void special_condition(struct scc_priv *priv, int rc);
255static void rx_bh(void *arg); 255static void rx_bh(struct work_struct *);
256static void tx_isr(struct scc_priv *priv); 256static void tx_isr(struct scc_priv *priv);
257static void es_isr(struct scc_priv *priv); 257static void es_isr(struct scc_priv *priv);
258static void tm_isr(struct scc_priv *priv); 258static void tm_isr(struct scc_priv *priv);
@@ -579,7 +579,7 @@ static int __init setup_adapter(int card_base, int type, int n)
579 priv->param.clocks = TCTRxCP | RCRTxCP; 579 priv->param.clocks = TCTRxCP | RCRTxCP;
580 priv->param.persist = 256; 580 priv->param.persist = 256;
581 priv->param.dma = -1; 581 priv->param.dma = -1;
582 INIT_WORK(&priv->rx_work, rx_bh, priv); 582 INIT_WORK(&priv->rx_work, rx_bh);
583 dev->priv = priv; 583 dev->priv = priv;
584 sprintf(dev->name, "dmascc%i", 2 * n + i); 584 sprintf(dev->name, "dmascc%i", 2 * n + i);
585 dev->base_addr = card_base; 585 dev->base_addr = card_base;
@@ -1272,9 +1272,9 @@ static void special_condition(struct scc_priv *priv, int rc)
1272} 1272}
1273 1273
1274 1274
1275static void rx_bh(void *arg) 1275static void rx_bh(struct work_struct *ugli_api)
1276{ 1276{
1277 struct scc_priv *priv = arg; 1277 struct scc_priv *priv = container_of(ugli_api, struct scc_priv, rx_work);
1278 int i = priv->rx_tail; 1278 int i = priv->rx_tail;
1279 int cb; 1279 int cb;
1280 unsigned long flags; 1280 unsigned long flags;
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index f73f10a0a562..407d2acbf7c7 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -24,6 +24,7 @@
24#include <linux/netdevice.h> 24#include <linux/netdevice.h>
25 25
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/dcr.h>
27 28
28/* 29/*
29 * These MAL "versions" probably aren't the real versions IBM uses for these 30 * These MAL "versions" probably aren't the real versions IBM uses for these
@@ -191,6 +192,7 @@ struct mal_commac {
191 192
192struct ibm_ocp_mal { 193struct ibm_ocp_mal {
193 int dcrbase; 194 int dcrbase;
195 dcr_host_t dcrhost;
194 196
195 struct list_head poll_list; 197 struct list_head poll_list;
196 struct net_device poll_dev; 198 struct net_device poll_dev;
@@ -207,12 +209,12 @@ struct ibm_ocp_mal {
207 209
208static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg) 210static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg)
209{ 211{
210 return mfdcr(mal->dcrbase + reg); 212 return dcr_read(mal->dcrhost, mal->dcrbase + reg);
211} 213}
212 214
213static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val) 215static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val)
214{ 216{
215 mtdcr(mal->dcrbase + reg, val); 217 dcr_write(mal->dcrhost, mal->dcrbase + reg, val);
216} 218}
217 219
218/* Register MAL devices */ 220/* Register MAL devices */
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 44c9f993dcc4..99343b5836b8 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -50,7 +50,6 @@
50#include <asm/semaphore.h> 50#include <asm/semaphore.h>
51#include <asm/hvcall.h> 51#include <asm/hvcall.h>
52#include <asm/atomic.h> 52#include <asm/atomic.h>
53#include <asm/iommu.h>
54#include <asm/vio.h> 53#include <asm/vio.h>
55#include <asm/uaccess.h> 54#include <asm/uaccess.h>
56#include <linux/seq_file.h> 55#include <linux/seq_file.h>
@@ -1000,8 +999,6 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_
1000 adapter->mac_addr = 0; 999 adapter->mac_addr = 0;
1001 memcpy(&adapter->mac_addr, mac_addr_p, 6); 1000 memcpy(&adapter->mac_addr, mac_addr_p, 6);
1002 1001
1003 adapter->liobn = dev->iommu_table->it_index;
1004
1005 netdev->irq = dev->irq; 1002 netdev->irq = dev->irq;
1006 netdev->open = ibmveth_open; 1003 netdev->open = ibmveth_open;
1007 netdev->poll = ibmveth_poll; 1004 netdev->poll = ibmveth_poll;
@@ -1115,7 +1112,6 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v)
1115 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); 1112 seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version);
1116 1113
1117 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); 1114 seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address);
1118 seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn);
1119 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", 1115 seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
1120 current_mac[0], current_mac[1], current_mac[2], 1116 current_mac[0], current_mac[1], current_mac[2],
1121 current_mac[3], current_mac[4], current_mac[5]); 1117 current_mac[3], current_mac[4], current_mac[5]);
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h
index f5b25bff1540..bb69ccae8ace 100644
--- a/drivers/net/ibmveth.h
+++ b/drivers/net/ibmveth.h
@@ -118,7 +118,6 @@ struct ibmveth_adapter {
118 struct net_device_stats stats; 118 struct net_device_stats stats;
119 unsigned int mcastFilterSize; 119 unsigned int mcastFilterSize;
120 unsigned long mac_addr; 120 unsigned long mac_addr;
121 unsigned long liobn;
122 void * buffer_list_addr; 121 void * buffer_list_addr;
123 void * filter_list_addr; 122 void * filter_list_addr;
124 dma_addr_t buffer_list_dma; 123 dma_addr_t buffer_list_dma;
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index b32c52ed19d7..f0c61f3b2a82 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -560,9 +560,9 @@ static inline int mcs_find_endpoints(struct mcs_cb *mcs,
560 return ret; 560 return ret;
561} 561}
562 562
563static void mcs_speed_work(void *arg) 563static void mcs_speed_work(struct work_struct *work)
564{ 564{
565 struct mcs_cb *mcs = arg; 565 struct mcs_cb *mcs = container_of(work, struct mcs_cb, work);
566 struct net_device *netdev = mcs->netdev; 566 struct net_device *netdev = mcs->netdev;
567 567
568 mcs_speed_change(mcs); 568 mcs_speed_change(mcs);
@@ -927,7 +927,7 @@ static int mcs_probe(struct usb_interface *intf,
927 irda_qos_bits_to_value(&mcs->qos); 927 irda_qos_bits_to_value(&mcs->qos);
928 928
929 /* Speed change work initialisation*/ 929 /* Speed change work initialisation*/
930 INIT_WORK(&mcs->work, mcs_speed_work, mcs); 930 INIT_WORK(&mcs->work, mcs_speed_work);
931 931
932 /* Override the network functions we need to use */ 932 /* Override the network functions we need to use */
933 ndev->hard_start_xmit = mcs_hard_xmit; 933 ndev->hard_start_xmit = mcs_hard_xmit;
diff --git a/drivers/net/irda/sir-dev.h b/drivers/net/irda/sir-dev.h
index 9fa294a546d6..2a57bc67ce35 100644
--- a/drivers/net/irda/sir-dev.h
+++ b/drivers/net/irda/sir-dev.h
@@ -22,7 +22,7 @@
22 22
23struct sir_fsm { 23struct sir_fsm {
24 struct semaphore sem; 24 struct semaphore sem;
25 struct work_struct work; 25 struct delayed_work work;
26 unsigned state, substate; 26 unsigned state, substate;
27 int param; 27 int param;
28 int result; 28 int result;
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 3b5854d10c17..17b0c3ab6201 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -100,9 +100,9 @@ static int sirdev_tx_complete_fsm(struct sir_dev *dev)
100 * Both must be unlocked/restarted on completion - but only on final exit. 100 * Both must be unlocked/restarted on completion - but only on final exit.
101 */ 101 */
102 102
103static void sirdev_config_fsm(void *data) 103static void sirdev_config_fsm(struct work_struct *work)
104{ 104{
105 struct sir_dev *dev = data; 105 struct sir_dev *dev = container_of(work, struct sir_dev, fsm.work.work);
106 struct sir_fsm *fsm = &dev->fsm; 106 struct sir_fsm *fsm = &dev->fsm;
107 int next_state; 107 int next_state;
108 int ret = -1; 108 int ret = -1;
@@ -309,8 +309,8 @@ int sirdev_schedule_request(struct sir_dev *dev, int initial_state, unsigned par
309 fsm->param = param; 309 fsm->param = param;
310 fsm->result = 0; 310 fsm->result = 0;
311 311
312 INIT_WORK(&fsm->work, sirdev_config_fsm, dev); 312 INIT_DELAYED_WORK(&fsm->work, sirdev_config_fsm);
313 queue_work(irda_sir_wq, &fsm->work); 313 queue_delayed_work(irda_sir_wq, &fsm->work, 0);
314 return 0; 314 return 0;
315} 315}
316 316
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index 2284e2ce1692..d6f4f185bf37 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -166,7 +166,7 @@ struct veth_msg {
166 166
167struct veth_lpar_connection { 167struct veth_lpar_connection {
168 HvLpIndex remote_lp; 168 HvLpIndex remote_lp;
169 struct work_struct statemachine_wq; 169 struct delayed_work statemachine_wq;
170 struct veth_msg *msgs; 170 struct veth_msg *msgs;
171 int num_events; 171 int num_events;
172 struct veth_cap_data local_caps; 172 struct veth_cap_data local_caps;
@@ -456,7 +456,7 @@ static struct kobj_type veth_port_ktype = {
456 456
457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx) 457static inline void veth_kick_statemachine(struct veth_lpar_connection *cnx)
458{ 458{
459 schedule_work(&cnx->statemachine_wq); 459 schedule_delayed_work(&cnx->statemachine_wq, 0);
460} 460}
461 461
462static void veth_take_cap(struct veth_lpar_connection *cnx, 462static void veth_take_cap(struct veth_lpar_connection *cnx,
@@ -638,9 +638,11 @@ static int veth_process_caps(struct veth_lpar_connection *cnx)
638} 638}
639 639
640/* FIXME: The gotos here are a bit dubious */ 640/* FIXME: The gotos here are a bit dubious */
641static void veth_statemachine(void *p) 641static void veth_statemachine(struct work_struct *work)
642{ 642{
643 struct veth_lpar_connection *cnx = (struct veth_lpar_connection *)p; 643 struct veth_lpar_connection *cnx =
644 container_of(work, struct veth_lpar_connection,
645 statemachine_wq.work);
644 int rlp = cnx->remote_lp; 646 int rlp = cnx->remote_lp;
645 int rc; 647 int rc;
646 648
@@ -827,7 +829,7 @@ static int veth_init_connection(u8 rlp)
827 829
828 cnx->remote_lp = rlp; 830 cnx->remote_lp = rlp;
829 spin_lock_init(&cnx->lock); 831 spin_lock_init(&cnx->lock);
830 INIT_WORK(&cnx->statemachine_wq, veth_statemachine, cnx); 832 INIT_DELAYED_WORK(&cnx->statemachine_wq, veth_statemachine);
831 833
832 init_timer(&cnx->ack_timer); 834 init_timer(&cnx->ack_timer);
833 cnx->ack_timer.function = veth_timed_ack; 835 cnx->ack_timer.function = veth_timed_ack;
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 7b127212e62b..e628126c9c49 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -106,7 +106,7 @@ static boolean_t ixgb_clean_rx_irq(struct ixgb_adapter *adapter);
106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter); 106static void ixgb_alloc_rx_buffers(struct ixgb_adapter *adapter);
107void ixgb_set_ethtool_ops(struct net_device *netdev); 107void ixgb_set_ethtool_ops(struct net_device *netdev);
108static void ixgb_tx_timeout(struct net_device *dev); 108static void ixgb_tx_timeout(struct net_device *dev);
109static void ixgb_tx_timeout_task(struct net_device *dev); 109static void ixgb_tx_timeout_task(struct work_struct *work);
110static void ixgb_vlan_rx_register(struct net_device *netdev, 110static void ixgb_vlan_rx_register(struct net_device *netdev,
111 struct vlan_group *grp); 111 struct vlan_group *grp);
112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid); 112static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
@@ -489,8 +489,7 @@ ixgb_probe(struct pci_dev *pdev,
489 adapter->watchdog_timer.function = &ixgb_watchdog; 489 adapter->watchdog_timer.function = &ixgb_watchdog;
490 adapter->watchdog_timer.data = (unsigned long)adapter; 490 adapter->watchdog_timer.data = (unsigned long)adapter;
491 491
492 INIT_WORK(&adapter->tx_timeout_task, 492 INIT_WORK(&adapter->tx_timeout_task, ixgb_tx_timeout_task);
493 (void (*)(void *))ixgb_tx_timeout_task, netdev);
494 493
495 strcpy(netdev->name, "eth%d"); 494 strcpy(netdev->name, "eth%d");
496 if((err = register_netdev(netdev))) 495 if((err = register_netdev(netdev)))
@@ -1493,9 +1492,10 @@ ixgb_tx_timeout(struct net_device *netdev)
1493} 1492}
1494 1493
1495static void 1494static void
1496ixgb_tx_timeout_task(struct net_device *netdev) 1495ixgb_tx_timeout_task(struct work_struct *work)
1497{ 1496{
1498 struct ixgb_adapter *adapter = netdev_priv(netdev); 1497 struct ixgb_adapter *adapter =
1498 container_of(work, struct ixgb_adapter, tx_timeout_task);
1499 1499
1500 adapter->tx_timeout_count++; 1500 adapter->tx_timeout_count++;
1501 ixgb_down(adapter, TRUE); 1501 ixgb_down(adapter, TRUE);
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 21d0137b6004..c41ae4286eea 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -277,9 +277,11 @@ static void mv643xx_eth_tx_timeout(struct net_device *dev)
277 * 277 *
278 * Actual routine to reset the adapter when a timeout on Tx has occurred 278 * Actual routine to reset the adapter when a timeout on Tx has occurred
279 */ 279 */
280static void mv643xx_eth_tx_timeout_task(struct net_device *dev) 280static void mv643xx_eth_tx_timeout_task(struct work_struct *ugly)
281{ 281{
282 struct mv643xx_private *mp = netdev_priv(dev); 282 struct mv643xx_private *mp = container_of(ugly, struct mv643xx_private,
283 tx_timeout_task);
284 struct net_device *dev = mp->mii.dev; /* yuck */
283 285
284 if (!netif_running(dev)) 286 if (!netif_running(dev))
285 return; 287 return;
@@ -1360,8 +1362,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1360#endif 1362#endif
1361 1363
1362 /* Configure the timeout task */ 1364 /* Configure the timeout task */
1363 INIT_WORK(&mp->tx_timeout_task, 1365 INIT_WORK(&mp->tx_timeout_task, mv643xx_eth_tx_timeout_task);
1364 (void (*)(void *))mv643xx_eth_tx_timeout_task, dev);
1365 1366
1366 spin_lock_init(&mp->lock); 1367 spin_lock_init(&mp->lock);
1367 1368
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index d320bbeeeff6..b8f57df1091a 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2620,9 +2620,10 @@ static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
2620 * This watchdog is used to check whether the board has suffered 2620 * This watchdog is used to check whether the board has suffered
2621 * from a parity error and needs to be recovered. 2621 * from a parity error and needs to be recovered.
2622 */ 2622 */
2623static void myri10ge_watchdog(void *arg) 2623static void myri10ge_watchdog(struct work_struct *work)
2624{ 2624{
2625 struct myri10ge_priv *mgp = arg; 2625 struct myri10ge_priv *mgp =
2626 container_of(work, struct myri10ge_priv, watchdog_work);
2626 u32 reboot; 2627 u32 reboot;
2627 int status; 2628 int status;
2628 u16 cmd, vendor; 2629 u16 cmd, vendor;
@@ -2892,7 +2893,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2892 (unsigned long)mgp); 2893 (unsigned long)mgp);
2893 2894
2894 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops); 2895 SET_ETHTOOL_OPS(netdev, &myri10ge_ethtool_ops);
2895 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog, mgp); 2896 INIT_WORK(&mgp->watchdog_work, myri10ge_watchdog);
2896 status = register_netdev(netdev); 2897 status = register_netdev(netdev);
2897 if (status != 0) { 2898 if (status != 0) {
2898 dev_err(&pdev->dev, "register_netdev failed: %d\n", status); 2899 dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 3151aaa7906e..b5410bee5f21 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -852,7 +852,8 @@ struct netxen_adapter {
852 spinlock_t tx_lock; 852 spinlock_t tx_lock;
853 spinlock_t lock; 853 spinlock_t lock;
854 struct work_struct watchdog_task; 854 struct work_struct watchdog_task;
855 struct work_struct tx_timeout_task[NETXEN_MAX_PORTS]; 855 struct work_struct tx_timeout_task;
856 struct net_device *netdev;
856 struct timer_list watchdog_timer; 857 struct timer_list watchdog_timer;
857 858
858 u32 curr_window; 859 u32 curr_window;
@@ -1071,7 +1072,7 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1071 struct netxen_port *port); 1072 struct netxen_port *port);
1072int netxen_nic_rx_has_work(struct netxen_adapter *adapter); 1073int netxen_nic_rx_has_work(struct netxen_adapter *adapter);
1073int netxen_nic_tx_has_work(struct netxen_adapter *adapter); 1074int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
1074void netxen_watchdog_task(unsigned long v); 1075void netxen_watchdog_task(struct work_struct *work);
1075void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 1076void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
1076 u32 ringid); 1077 u32 ringid);
1077void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx, 1078void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx,
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index f78668030ec6..290145ec08e7 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -746,12 +746,13 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
746 return rv; 746 return rv;
747} 747}
748 748
749void netxen_watchdog_task(unsigned long v) 749void netxen_watchdog_task(struct work_struct *work)
750{ 750{
751 int port_num; 751 int port_num;
752 struct netxen_port *port; 752 struct netxen_port *port;
753 struct net_device *netdev; 753 struct net_device *netdev;
754 struct netxen_adapter *adapter = (struct netxen_adapter *)v; 754 struct netxen_adapter *adapter =
755 container_of(work, struct netxen_adapter, watchdog_task);
755 756
756 if (netxen_nic_check_temp(adapter)) 757 if (netxen_nic_check_temp(adapter))
757 return; 758 return;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 06c4778f5200..913e8147114f 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -72,7 +72,7 @@ static int netxen_nic_open(struct net_device *netdev);
72static int netxen_nic_close(struct net_device *netdev); 72static int netxen_nic_close(struct net_device *netdev);
73static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *); 73static int netxen_nic_xmit_frame(struct sk_buff *, struct net_device *);
74static void netxen_tx_timeout(struct net_device *netdev); 74static void netxen_tx_timeout(struct net_device *netdev);
75static void netxen_tx_timeout_task(struct net_device *netdev); 75static void netxen_tx_timeout_task(struct work_struct *work);
76static void netxen_watchdog(unsigned long); 76static void netxen_watchdog(unsigned long);
77static int netxen_handle_int(struct netxen_adapter *, struct net_device *); 77static int netxen_handle_int(struct netxen_adapter *, struct net_device *);
78static int netxen_nic_ioctl(struct net_device *netdev, 78static int netxen_nic_ioctl(struct net_device *netdev,
@@ -318,8 +318,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
318 adapter->ahw.xg_linkup = 0; 318 adapter->ahw.xg_linkup = 0;
319 adapter->watchdog_timer.function = &netxen_watchdog; 319 adapter->watchdog_timer.function = &netxen_watchdog;
320 adapter->watchdog_timer.data = (unsigned long)adapter; 320 adapter->watchdog_timer.data = (unsigned long)adapter;
321 INIT_WORK(&adapter->watchdog_task, 321 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
322 (void (*)(void *))netxen_watchdog_task, adapter);
323 adapter->ahw.pdev = pdev; 322 adapter->ahw.pdev = pdev;
324 adapter->proc_cmd_buf_counter = 0; 323 adapter->proc_cmd_buf_counter = 0;
325 adapter->ahw.revision_id = nx_p2_id; 324 adapter->ahw.revision_id = nx_p2_id;
@@ -429,8 +428,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
429 netdev->dev_addr); 428 netdev->dev_addr);
430 } 429 }
431 } 430 }
432 INIT_WORK(adapter->tx_timeout_task + i, 431 adapter->netdev = netdev;
433 (void (*)(void *))netxen_tx_timeout_task, netdev); 432 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
434 netif_carrier_off(netdev); 433 netif_carrier_off(netdev);
435 netif_stop_queue(netdev); 434 netif_stop_queue(netdev);
436 435
@@ -973,18 +972,20 @@ static void netxen_tx_timeout(struct net_device *netdev)
973 SCHEDULE_WORK(port->adapter->tx_timeout_task + port->portnum); 972 SCHEDULE_WORK(port->adapter->tx_timeout_task + port->portnum);
974} 973}
975 974
976static void netxen_tx_timeout_task(struct net_device *netdev) 975static void netxen_tx_timeout_task(struct work_struct *work)
977{ 976{
978 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); 977 struct netxen_adapter *adapter =
978 container_of(work, struct netxen_adapter, tx_timeout_task);
979 struct net_device *netdev = adapter->netdev;
979 unsigned long flags; 980 unsigned long flags;
980 981
981 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", 982 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
982 netxen_nic_driver_name, netdev->name); 983 netxen_nic_driver_name, netdev->name);
983 984
984 spin_lock_irqsave(&port->adapter->lock, flags); 985 spin_lock_irqsave(&adapter->lock, flags);
985 netxen_nic_close(netdev); 986 netxen_nic_close(netdev);
986 netxen_nic_open(netdev); 987 netxen_nic_open(netdev);
987 spin_unlock_irqrestore(&port->adapter->lock, flags); 988 spin_unlock_irqrestore(&adapter->lock, flags);
988 netdev->trans_start = jiffies; 989 netdev->trans_start = jiffies;
989 netif_wake_queue(netdev); 990 netif_wake_queue(netdev);
990} 991}
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index eb0e119bc0d6..568daeb3e9d8 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -427,6 +427,7 @@ struct ns83820 {
427 u8 __iomem *base; 427 u8 __iomem *base;
428 428
429 struct pci_dev *pci_dev; 429 struct pci_dev *pci_dev;
430 struct net_device *ndev;
430 431
431#ifdef NS83820_VLAN_ACCEL_SUPPORT 432#ifdef NS83820_VLAN_ACCEL_SUPPORT
432 struct vlan_group *vlgrp; 433 struct vlan_group *vlgrp;
@@ -631,10 +632,10 @@ static void fastcall rx_refill_atomic(struct net_device *ndev)
631} 632}
632 633
633/* REFILL */ 634/* REFILL */
634static inline void queue_refill(void *_dev) 635static inline void queue_refill(struct work_struct *work)
635{ 636{
636 struct net_device *ndev = _dev; 637 struct ns83820 *dev = container_of(work, struct ns83820, tq_refill);
637 struct ns83820 *dev = PRIV(ndev); 638 struct net_device *ndev = dev->ndev;
638 639
639 rx_refill(ndev, GFP_KERNEL); 640 rx_refill(ndev, GFP_KERNEL);
640 if (dev->rx_info.up) 641 if (dev->rx_info.up)
@@ -1844,6 +1845,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1844 1845
1845 ndev = alloc_etherdev(sizeof(struct ns83820)); 1846 ndev = alloc_etherdev(sizeof(struct ns83820));
1846 dev = PRIV(ndev); 1847 dev = PRIV(ndev);
1848 dev->ndev = ndev;
1847 err = -ENOMEM; 1849 err = -ENOMEM;
1848 if (!dev) 1850 if (!dev)
1849 goto out; 1851 goto out;
@@ -1856,7 +1858,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1856 SET_MODULE_OWNER(ndev); 1858 SET_MODULE_OWNER(ndev);
1857 SET_NETDEV_DEV(ndev, &pci_dev->dev); 1859 SET_NETDEV_DEV(ndev, &pci_dev->dev);
1858 1860
1859 INIT_WORK(&dev->tq_refill, queue_refill, ndev); 1861 INIT_WORK(&dev->tq_refill, queue_refill);
1860 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev); 1862 tasklet_init(&dev->rx_tasklet, rx_action, (unsigned long)ndev);
1861 1863
1862 err = pci_enable_device(pci_dev); 1864 err = pci_enable_device(pci_dev);
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 046009928526..794cc61819dd 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -338,7 +338,6 @@ static int tc574_config(struct pcmcia_device *link)
338 struct net_device *dev = link->priv; 338 struct net_device *dev = link->priv;
339 struct el3_private *lp = netdev_priv(dev); 339 struct el3_private *lp = netdev_priv(dev);
340 tuple_t tuple; 340 tuple_t tuple;
341 cisparse_t parse;
342 unsigned short buf[32]; 341 unsigned short buf[32];
343 int last_fn, last_ret, i, j; 342 int last_fn, last_ret, i, j;
344 kio_addr_t ioaddr; 343 kio_addr_t ioaddr;
@@ -350,17 +349,6 @@ static int tc574_config(struct pcmcia_device *link)
350 349
351 DEBUG(0, "3c574_config(0x%p)\n", link); 350 DEBUG(0, "3c574_config(0x%p)\n", link);
352 351
353 tuple.Attributes = 0;
354 tuple.DesiredTuple = CISTPL_CONFIG;
355 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
356 tuple.TupleData = (cisdata_t *)buf;
357 tuple.TupleDataMax = 64;
358 tuple.TupleOffset = 0;
359 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
360 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
361 link->conf.ConfigBase = parse.config.base;
362 link->conf.Present = parse.config.rmask[0];
363
364 link->io.IOAddrLines = 16; 352 link->io.IOAddrLines = 16;
365 for (i = j = 0; j < 0x400; j += 0x20) { 353 for (i = j = 0; j < 0x400; j += 0x20) {
366 link->io.BasePort1 = j ^ 0x300; 354 link->io.BasePort1 = j ^ 0x300;
@@ -382,6 +370,10 @@ static int tc574_config(struct pcmcia_device *link)
382 /* The 3c574 normally uses an EEPROM for configuration info, including 370 /* The 3c574 normally uses an EEPROM for configuration info, including
383 the hardware address. The future products may include a modem chip 371 the hardware address. The future products may include a modem chip
384 and put the address in the CIS. */ 372 and put the address in the CIS. */
373 tuple.Attributes = 0;
374 tuple.TupleData = (cisdata_t *)buf;
375 tuple.TupleDataMax = 64;
376 tuple.TupleOffset = 0;
385 tuple.DesiredTuple = 0x88; 377 tuple.DesiredTuple = 0x88;
386 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 378 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
387 pcmcia_get_tuple_data(link, &tuple); 379 pcmcia_get_tuple_data(link, &tuple);
@@ -397,12 +389,9 @@ static int tc574_config(struct pcmcia_device *link)
397 goto failed; 389 goto failed;
398 } 390 }
399 } 391 }
400 tuple.DesiredTuple = CISTPL_VERS_1; 392 if (link->prod_id[1])
401 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS && 393 cardname = link->prod_id[1];
402 pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS && 394 else
403 pcmcia_parse_tuple(link, &tuple, &parse) == CS_SUCCESS) {
404 cardname = parse.version_1.str + parse.version_1.ofs[1];
405 } else
406 cardname = "3Com 3c574"; 395 cardname = "3Com 3c574";
407 396
408 { 397 {
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 231fa2c9ec6c..1e73ff7d5d8e 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -253,7 +253,6 @@ static int tc589_config(struct pcmcia_device *link)
253 struct net_device *dev = link->priv; 253 struct net_device *dev = link->priv;
254 struct el3_private *lp = netdev_priv(dev); 254 struct el3_private *lp = netdev_priv(dev);
255 tuple_t tuple; 255 tuple_t tuple;
256 cisparse_t parse;
257 u16 buf[32], *phys_addr; 256 u16 buf[32], *phys_addr;
258 int last_fn, last_ret, i, j, multi = 0, fifo; 257 int last_fn, last_ret, i, j, multi = 0, fifo;
259 kio_addr_t ioaddr; 258 kio_addr_t ioaddr;
@@ -263,26 +262,16 @@ static int tc589_config(struct pcmcia_device *link)
263 262
264 phys_addr = (u16 *)dev->dev_addr; 263 phys_addr = (u16 *)dev->dev_addr;
265 tuple.Attributes = 0; 264 tuple.Attributes = 0;
266 tuple.DesiredTuple = CISTPL_CONFIG;
267 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
268 tuple.TupleData = (cisdata_t *)buf; 265 tuple.TupleData = (cisdata_t *)buf;
269 tuple.TupleDataMax = sizeof(buf); 266 tuple.TupleDataMax = sizeof(buf);
270 tuple.TupleOffset = 0; 267 tuple.TupleOffset = 0;
271 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
272 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
273 link->conf.ConfigBase = parse.config.base;
274 link->conf.Present = parse.config.rmask[0];
275
276 /* Is this a 3c562? */
277 tuple.DesiredTuple = CISTPL_MANFID;
278 tuple.Attributes = TUPLE_RETURN_COMMON; 268 tuple.Attributes = TUPLE_RETURN_COMMON;
279 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 269
280 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) { 270 /* Is this a 3c562? */
281 if (le16_to_cpu(buf[0]) != MANFID_3COM) 271 if (link->manf_id != MANFID_3COM)
282 printk(KERN_INFO "3c589_cs: hmmm, is this really a " 272 printk(KERN_INFO "3c589_cs: hmmm, is this really a "
283 "3Com card??\n"); 273 "3Com card??\n");
284 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562); 274 multi = (link->card_id == PRODID_3COM_3C562);
285 }
286 275
287 /* For the 3c562, the base address must be xx00-xx7f */ 276 /* For the 3c562, the base address must be xx00-xx7f */
288 link->io.IOAddrLines = 16; 277 link->io.IOAddrLines = 16;
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5ddd5742f779..6139048f8117 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -299,11 +299,7 @@ static int axnet_config(struct pcmcia_device *link)
299 tuple.TupleData = (cisdata_t *)buf; 299 tuple.TupleData = (cisdata_t *)buf;
300 tuple.TupleDataMax = sizeof(buf); 300 tuple.TupleDataMax = sizeof(buf);
301 tuple.TupleOffset = 0; 301 tuple.TupleOffset = 0;
302 tuple.DesiredTuple = CISTPL_CONFIG; 302
303 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
304 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
305 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
306 link->conf.ConfigBase = parse.config.base;
307 /* don't trust the CIS on this; Linksys got it wrong */ 303 /* don't trust the CIS on this; Linksys got it wrong */
308 link->conf.Present = 0x63; 304 link->conf.Present = 0x63;
309 305
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 48434d7924eb..91f65e91cd5f 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -249,12 +249,9 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
249static int com20020_config(struct pcmcia_device *link) 249static int com20020_config(struct pcmcia_device *link)
250{ 250{
251 struct arcnet_local *lp; 251 struct arcnet_local *lp;
252 tuple_t tuple;
253 cisparse_t parse;
254 com20020_dev_t *info; 252 com20020_dev_t *info;
255 struct net_device *dev; 253 struct net_device *dev;
256 int i, last_ret, last_fn; 254 int i, last_ret, last_fn;
257 u_char buf[64];
258 int ioaddr; 255 int ioaddr;
259 256
260 info = link->priv; 257 info = link->priv;
@@ -264,16 +261,6 @@ static int com20020_config(struct pcmcia_device *link)
264 261
265 DEBUG(0, "com20020_config(0x%p)\n", link); 262 DEBUG(0, "com20020_config(0x%p)\n", link);
266 263
267 tuple.Attributes = 0;
268 tuple.TupleData = buf;
269 tuple.TupleDataMax = 64;
270 tuple.TupleOffset = 0;
271 tuple.DesiredTuple = CISTPL_CONFIG;
272 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
273 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
274 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
275 link->conf.ConfigBase = parse.config.base;
276
277 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 264 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1);
278 i = !CS_SUCCESS; 265 i = !CS_SUCCESS;
279 if (!link->io.BasePort1) 266 if (!link->io.BasePort1)
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 65f6fdf43725..0d7de617e535 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -342,7 +342,7 @@ static int fmvj18x_config(struct pcmcia_device *link)
342 tuple_t tuple; 342 tuple_t tuple;
343 cisparse_t parse; 343 cisparse_t parse;
344 u_short buf[32]; 344 u_short buf[32];
345 int i, last_fn, last_ret, ret; 345 int i, last_fn = 0, last_ret = 0, ret;
346 kio_addr_t ioaddr; 346 kio_addr_t ioaddr;
347 cardtype_t cardtype; 347 cardtype_t cardtype;
348 char *card_name = "unknown"; 348 char *card_name = "unknown";
@@ -350,21 +350,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
350 350
351 DEBUG(0, "fmvj18x_config(0x%p)\n", link); 351 DEBUG(0, "fmvj18x_config(0x%p)\n", link);
352 352
353 /*
354 This reads the card's CONFIG tuple to find its configuration
355 registers.
356 */
357 tuple.DesiredTuple = CISTPL_CONFIG;
358 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
359 tuple.TupleData = (u_char *)buf; 353 tuple.TupleData = (u_char *)buf;
360 tuple.TupleDataMax = 64; 354 tuple.TupleDataMax = 64;
361 tuple.TupleOffset = 0; 355 tuple.TupleOffset = 0;
362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
364
365 link->conf.ConfigBase = parse.config.base;
366 link->conf.Present = parse.config.rmask[0];
367
368 tuple.DesiredTuple = CISTPL_FUNCE; 356 tuple.DesiredTuple = CISTPL_FUNCE;
369 tuple.TupleOffset = 0; 357 tuple.TupleOffset = 0;
370 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 358 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) {
@@ -374,17 +362,12 @@ static int fmvj18x_config(struct pcmcia_device *link)
374 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 362 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
375 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 363 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
376 link->conf.ConfigIndex = parse.cftable_entry.index; 364 link->conf.ConfigIndex = parse.cftable_entry.index;
377 tuple.DesiredTuple = CISTPL_MANFID; 365 switch (link->manf_id) {
378 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
379 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
380 else
381 buf[0] = 0xffff;
382 switch (le16_to_cpu(buf[0])) {
383 case MANFID_TDK: 366 case MANFID_TDK:
384 cardtype = TDK; 367 cardtype = TDK;
385 if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410 368 if (link->card_id == PRODID_TDK_GN3410
386 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610 369 || link->card_id == PRODID_TDK_NP9610
387 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) { 370 || link->card_id == PRODID_TDK_MN3200) {
388 /* MultiFunction Card */ 371 /* MultiFunction Card */
389 link->conf.ConfigBase = 0x800; 372 link->conf.ConfigBase = 0x800;
390 link->conf.ConfigIndex = 0x47; 373 link->conf.ConfigIndex = 0x47;
@@ -395,11 +378,11 @@ static int fmvj18x_config(struct pcmcia_device *link)
395 cardtype = CONTEC; 378 cardtype = CONTEC;
396 break; 379 break;
397 case MANFID_FUJITSU: 380 case MANFID_FUJITSU:
398 if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10302) 381 if (link->card_id == PRODID_FUJITSU_MBH10302)
399 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302), 382 /* RATOC REX-5588/9822/4886's PRODID are 0004(=MBH10302),
400 but these are MBH10304 based card. */ 383 but these are MBH10304 based card. */
401 cardtype = MBH10304; 384 cardtype = MBH10304;
402 else if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10304) 385 else if (link->card_id == PRODID_FUJITSU_MBH10304)
403 cardtype = MBH10304; 386 cardtype = MBH10304;
404 else 387 else
405 cardtype = LA501; 388 cardtype = LA501;
@@ -409,14 +392,9 @@ static int fmvj18x_config(struct pcmcia_device *link)
409 } 392 }
410 } else { 393 } else {
411 /* old type card */ 394 /* old type card */
412 tuple.DesiredTuple = CISTPL_MANFID; 395 switch (link->manf_id) {
413 if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS)
414 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
415 else
416 buf[0] = 0xffff;
417 switch (le16_to_cpu(buf[0])) {
418 case MANFID_FUJITSU: 396 case MANFID_FUJITSU:
419 if (le16_to_cpu(buf[1]) == PRODID_FUJITSU_MBH10304) { 397 if (link->card_id == PRODID_FUJITSU_MBH10304) {
420 cardtype = XXX10304; /* MBH10304 with buggy CIS */ 398 cardtype = XXX10304; /* MBH10304 with buggy CIS */
421 link->conf.ConfigIndex = 0x20; 399 link->conf.ConfigIndex = 0x20;
422 } else { 400 } else {
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index bc0ca41a0542..a956a51d284f 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -222,24 +222,12 @@ static int ibmtr_config(struct pcmcia_device *link)
222 ibmtr_dev_t *info = link->priv; 222 ibmtr_dev_t *info = link->priv;
223 struct net_device *dev = info->dev; 223 struct net_device *dev = info->dev;
224 struct tok_info *ti = netdev_priv(dev); 224 struct tok_info *ti = netdev_priv(dev);
225 tuple_t tuple;
226 cisparse_t parse;
227 win_req_t req; 225 win_req_t req;
228 memreq_t mem; 226 memreq_t mem;
229 int i, last_ret, last_fn; 227 int i, last_ret, last_fn;
230 u_char buf[64];
231 228
232 DEBUG(0, "ibmtr_config(0x%p)\n", link); 229 DEBUG(0, "ibmtr_config(0x%p)\n", link);
233 230
234 tuple.Attributes = 0;
235 tuple.TupleData = buf;
236 tuple.TupleDataMax = 64;
237 tuple.TupleOffset = 0;
238 tuple.DesiredTuple = CISTPL_CONFIG;
239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
242 link->conf.ConfigBase = parse.config.base;
243 link->conf.ConfigIndex = 0x61; 231 link->conf.ConfigIndex = 0x61;
244 232
245 /* Determine if this is PRIMARY or ALTERNATE. */ 233 /* Determine if this is PRIMARY or ALTERNATE. */
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index e77110e4c288..3b707747a811 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -656,23 +656,12 @@ static int nmclan_config(struct pcmcia_device *link)
656 struct net_device *dev = link->priv; 656 struct net_device *dev = link->priv;
657 mace_private *lp = netdev_priv(dev); 657 mace_private *lp = netdev_priv(dev);
658 tuple_t tuple; 658 tuple_t tuple;
659 cisparse_t parse;
660 u_char buf[64]; 659 u_char buf[64];
661 int i, last_ret, last_fn; 660 int i, last_ret, last_fn;
662 kio_addr_t ioaddr; 661 kio_addr_t ioaddr;
663 662
664 DEBUG(0, "nmclan_config(0x%p)\n", link); 663 DEBUG(0, "nmclan_config(0x%p)\n", link);
665 664
666 tuple.Attributes = 0;
667 tuple.TupleData = buf;
668 tuple.TupleDataMax = 64;
669 tuple.TupleOffset = 0;
670 tuple.DesiredTuple = CISTPL_CONFIG;
671 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
672 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
673 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
674 link->conf.ConfigBase = parse.config.base;
675
676 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 665 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
677 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 666 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
678 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 667 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
@@ -686,6 +675,7 @@ static int nmclan_config(struct pcmcia_device *link)
686 tuple.TupleData = buf; 675 tuple.TupleData = buf;
687 tuple.TupleDataMax = 64; 676 tuple.TupleDataMax = 64;
688 tuple.TupleOffset = 0; 677 tuple.TupleOffset = 0;
678 tuple.Attributes = 0;
689 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 679 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
690 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 680 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
691 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); 681 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index c51cc5d8789a..2b1238e2dbdb 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -519,31 +519,15 @@ static int pcnet_config(struct pcmcia_device *link)
519 tuple_t tuple; 519 tuple_t tuple;
520 cisparse_t parse; 520 cisparse_t parse;
521 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; 521 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
522 int manfid = 0, prodid = 0, has_shmem = 0; 522 int has_shmem = 0;
523 u_short buf[64]; 523 u_short buf[64];
524 hw_info_t *hw_info; 524 hw_info_t *hw_info;
525 525
526 DEBUG(0, "pcnet_config(0x%p)\n", link); 526 DEBUG(0, "pcnet_config(0x%p)\n", link);
527 527
528 tuple.Attributes = 0;
529 tuple.TupleData = (cisdata_t *)buf; 528 tuple.TupleData = (cisdata_t *)buf;
530 tuple.TupleDataMax = sizeof(buf); 529 tuple.TupleDataMax = sizeof(buf);
531 tuple.TupleOffset = 0; 530 tuple.TupleOffset = 0;
532 tuple.DesiredTuple = CISTPL_CONFIG;
533 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
534 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
535 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
536 link->conf.ConfigBase = parse.config.base;
537 link->conf.Present = parse.config.rmask[0];
538
539 tuple.DesiredTuple = CISTPL_MANFID;
540 tuple.Attributes = TUPLE_RETURN_COMMON;
541 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
542 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) {
543 manfid = le16_to_cpu(buf[0]);
544 prodid = le16_to_cpu(buf[1]);
545 }
546
547 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 531 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
548 tuple.Attributes = 0; 532 tuple.Attributes = 0;
549 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 533 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -589,8 +573,8 @@ static int pcnet_config(struct pcmcia_device *link)
589 link->conf.Attributes |= CONF_ENABLE_SPKR; 573 link->conf.Attributes |= CONF_ENABLE_SPKR;
590 link->conf.Status = CCSR_AUDIO_ENA; 574 link->conf.Status = CCSR_AUDIO_ENA;
591 } 575 }
592 if ((manfid == MANFID_IBM) && 576 if ((link->manf_id == MANFID_IBM) &&
593 (prodid == PRODID_IBM_HOME_AND_AWAY)) 577 (link->card_id == PRODID_IBM_HOME_AND_AWAY))
594 link->conf.ConfigIndex |= 0x10; 578 link->conf.ConfigIndex |= 0x10;
595 579
596 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 580 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
@@ -624,10 +608,10 @@ static int pcnet_config(struct pcmcia_device *link)
624 info->flags = hw_info->flags; 608 info->flags = hw_info->flags;
625 /* Check for user overrides */ 609 /* Check for user overrides */
626 info->flags |= (delay_output) ? DELAY_OUTPUT : 0; 610 info->flags |= (delay_output) ? DELAY_OUTPUT : 0;
627 if ((manfid == MANFID_SOCKET) && 611 if ((link->manf_id == MANFID_SOCKET) &&
628 ((prodid == PRODID_SOCKET_LPE) || 612 ((link->card_id == PRODID_SOCKET_LPE) ||
629 (prodid == PRODID_SOCKET_LPE_CF) || 613 (link->card_id == PRODID_SOCKET_LPE_CF) ||
630 (prodid == PRODID_SOCKET_EIO))) 614 (link->card_id == PRODID_SOCKET_EIO)))
631 info->flags &= ~USE_BIG_BUF; 615 info->flags &= ~USE_BIG_BUF;
632 if (!use_big_buf) 616 if (!use_big_buf)
633 info->flags &= ~USE_BIG_BUF; 617 info->flags &= ~USE_BIG_BUF;
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index 20fcc3576202..530df8883fe5 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -560,16 +560,8 @@ static int mhz_setup(struct pcmcia_device *link)
560 560
561 /* Read the station address from the CIS. It is stored as the last 561 /* Read the station address from the CIS. It is stored as the last
562 (fourth) string in the Version 1 Version/ID tuple. */ 562 (fourth) string in the Version 1 Version/ID tuple. */
563 tuple->DesiredTuple = CISTPL_VERS_1; 563 if (link->prod_id[3]) {
564 if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 564 station_addr = link->prod_id[3];
565 rc = -1;
566 goto free_cfg_mem;
567 }
568 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */
569 if (next_tuple(link, tuple, parse) != CS_SUCCESS)
570 first_tuple(link, tuple, parse);
571 if (parse->version_1.ns > 3) {
572 station_addr = parse->version_1.str + parse->version_1.ofs[3];
573 if (cvt_ascii_address(dev, station_addr) == 0) { 565 if (cvt_ascii_address(dev, station_addr) == 0) {
574 rc = 0; 566 rc = 0;
575 goto free_cfg_mem; 567 goto free_cfg_mem;
@@ -744,15 +736,12 @@ static int smc_setup(struct pcmcia_device *link)
744 } 736 }
745 } 737 }
746 /* Try the third string in the Version 1 Version/ID tuple. */ 738 /* Try the third string in the Version 1 Version/ID tuple. */
747 tuple->DesiredTuple = CISTPL_VERS_1; 739 if (link->prod_id[2]) {
748 if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 740 station_addr = link->prod_id[2];
749 rc = -1; 741 if (cvt_ascii_address(dev, station_addr) == 0) {
750 goto free_cfg_mem; 742 rc = 0;
751 } 743 goto free_cfg_mem;
752 station_addr = parse->version_1.str + parse->version_1.ofs[2]; 744 }
753 if (cvt_ascii_address(dev, station_addr) == 0) {
754 rc = 0;
755 goto free_cfg_mem;
756 } 745 }
757 746
758 rc = -1; 747 rc = -1;
@@ -970,10 +959,6 @@ static int smc91c92_config(struct pcmcia_device *link)
970{ 959{
971 struct net_device *dev = link->priv; 960 struct net_device *dev = link->priv;
972 struct smc_private *smc = netdev_priv(dev); 961 struct smc_private *smc = netdev_priv(dev);
973 struct smc_cfg_mem *cfg_mem;
974 tuple_t *tuple;
975 cisparse_t *parse;
976 u_char *buf;
977 char *name; 962 char *name;
978 int i, j, rev; 963 int i, j, rev;
979 kio_addr_t ioaddr; 964 kio_addr_t ioaddr;
@@ -981,30 +966,8 @@ static int smc91c92_config(struct pcmcia_device *link)
981 966
982 DEBUG(0, "smc91c92_config(0x%p)\n", link); 967 DEBUG(0, "smc91c92_config(0x%p)\n", link);
983 968
984 cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); 969 smc->manfid = link->manf_id;
985 if (!cfg_mem) 970 smc->cardid = link->card_id;
986 goto config_failed;
987
988 tuple = &cfg_mem->tuple;
989 parse = &cfg_mem->parse;
990 buf = cfg_mem->buf;
991
992 tuple->Attributes = tuple->TupleOffset = 0;
993 tuple->TupleData = (cisdata_t *)buf;
994 tuple->TupleDataMax = 64;
995
996 tuple->DesiredTuple = CISTPL_CONFIG;
997 i = first_tuple(link, tuple, parse);
998 CS_EXIT_TEST(i, ParseTuple, config_failed);
999 link->conf.ConfigBase = parse->config.base;
1000 link->conf.Present = parse->config.rmask[0];
1001
1002 tuple->DesiredTuple = CISTPL_MANFID;
1003 tuple->Attributes = TUPLE_RETURN_COMMON;
1004 if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
1005 smc->manfid = parse->manfid.manf;
1006 smc->cardid = parse->manfid.card;
1007 }
1008 971
1009 if ((smc->manfid == MANFID_OSITECH) && 972 if ((smc->manfid == MANFID_OSITECH) &&
1010 (smc->cardid != PRODID_OSITECH_SEVEN)) { 973 (smc->cardid != PRODID_OSITECH_SEVEN)) {
@@ -1134,14 +1097,12 @@ static int smc91c92_config(struct pcmcia_device *link)
1134 printk(KERN_NOTICE " No MII transceivers found!\n"); 1097 printk(KERN_NOTICE " No MII transceivers found!\n");
1135 } 1098 }
1136 } 1099 }
1137 kfree(cfg_mem);
1138 return 0; 1100 return 0;
1139 1101
1140config_undo: 1102config_undo:
1141 unregister_netdev(dev); 1103 unregister_netdev(dev);
1142config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1104config_failed: /* CS_EXIT_TEST() calls jump to here... */
1143 smc91c92_release(link); 1105 smc91c92_release(link);
1144 kfree(cfg_mem);
1145 return -ENODEV; 1106 return -ENODEV;
1146} /* smc91c92_config */ 1107} /* smc91c92_config */
1147 1108
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index f3914f58d67f..8478dca3d8d1 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -332,6 +332,7 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
332 */ 332 */
333 333
334typedef struct local_info_t { 334typedef struct local_info_t {
335 struct net_device *dev;
335 struct pcmcia_device *p_dev; 336 struct pcmcia_device *p_dev;
336 dev_node_t node; 337 dev_node_t node;
337 struct net_device_stats stats; 338 struct net_device_stats stats;
@@ -353,7 +354,7 @@ typedef struct local_info_t {
353 */ 354 */
354static int do_start_xmit(struct sk_buff *skb, struct net_device *dev); 355static int do_start_xmit(struct sk_buff *skb, struct net_device *dev);
355static void do_tx_timeout(struct net_device *dev); 356static void do_tx_timeout(struct net_device *dev);
356static void xirc2ps_tx_timeout_task(void *data); 357static void xirc2ps_tx_timeout_task(struct work_struct *work);
357static struct net_device_stats *do_get_stats(struct net_device *dev); 358static struct net_device_stats *do_get_stats(struct net_device *dev);
358static void set_addresses(struct net_device *dev); 359static void set_addresses(struct net_device *dev);
359static void set_multicast_list(struct net_device *dev); 360static void set_multicast_list(struct net_device *dev);
@@ -567,6 +568,7 @@ xirc2ps_probe(struct pcmcia_device *link)
567 if (!dev) 568 if (!dev)
568 return -ENOMEM; 569 return -ENOMEM;
569 local = netdev_priv(dev); 570 local = netdev_priv(dev);
571 local->dev = dev;
570 local->p_dev = link; 572 local->p_dev = link;
571 link->priv = dev; 573 link->priv = dev;
572 574
@@ -591,7 +593,7 @@ xirc2ps_probe(struct pcmcia_device *link)
591#ifdef HAVE_TX_TIMEOUT 593#ifdef HAVE_TX_TIMEOUT
592 dev->tx_timeout = do_tx_timeout; 594 dev->tx_timeout = do_tx_timeout;
593 dev->watchdog_timeo = TX_TIMEOUT; 595 dev->watchdog_timeo = TX_TIMEOUT;
594 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task, dev); 596 INIT_WORK(&local->tx_timeout_task, xirc2ps_tx_timeout_task);
595#endif 597#endif
596 598
597 return xirc2ps_config(link); 599 return xirc2ps_config(link);
@@ -707,22 +709,11 @@ set_card_type(struct pcmcia_device *link, const void *s)
707 * Returns: true if this is a CE2 709 * Returns: true if this is a CE2
708 */ 710 */
709static int 711static int
710has_ce2_string(struct pcmcia_device * link) 712has_ce2_string(struct pcmcia_device * p_dev)
711{ 713{
712 tuple_t tuple; 714 if (p_dev->prod_id[2] && strstr(p_dev->prod_id[2], "CE2"))
713 cisparse_t parse; 715 return 1;
714 u_char buf[256]; 716 return 0;
715
716 tuple.Attributes = 0;
717 tuple.TupleData = buf;
718 tuple.TupleDataMax = 254;
719 tuple.TupleOffset = 0;
720 tuple.DesiredTuple = CISTPL_VERS_1;
721 if (!first_tuple(link, &tuple, &parse) && parse.version_1.ns > 2) {
722 if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2"))
723 return 1;
724 }
725 return 0;
726} 717}
727 718
728/**************** 719/****************
@@ -792,13 +783,6 @@ xirc2ps_config(struct pcmcia_device * link)
792 goto failure; 783 goto failure;
793 } 784 }
794 785
795 /* get configuration stuff */
796 tuple.DesiredTuple = CISTPL_CONFIG;
797 if ((err=first_tuple(link, &tuple, &parse)))
798 goto cis_error;
799 link->conf.ConfigBase = parse.config.base;
800 link->conf.Present = parse.config.rmask[0];
801
802 /* get the ethernet address from the CIS */ 786 /* get the ethernet address from the CIS */
803 tuple.DesiredTuple = CISTPL_FUNCE; 787 tuple.DesiredTuple = CISTPL_FUNCE;
804 for (err = first_tuple(link, &tuple, &parse); !err; 788 for (err = first_tuple(link, &tuple, &parse); !err;
@@ -1062,8 +1046,6 @@ xirc2ps_config(struct pcmcia_device * link)
1062 xirc2ps_release(link); 1046 xirc2ps_release(link);
1063 return -ENODEV; 1047 return -ENODEV;
1064 1048
1065 cis_error:
1066 printk(KNOT_XIRC "unable to parse CIS\n");
1067 failure: 1049 failure:
1068 return -ENODEV; 1050 return -ENODEV;
1069} /* xirc2ps_config */ 1051} /* xirc2ps_config */
@@ -1344,9 +1326,11 @@ xirc2ps_interrupt(int irq, void *dev_id)
1344/*====================================================================*/ 1326/*====================================================================*/
1345 1327
1346static void 1328static void
1347xirc2ps_tx_timeout_task(void *data) 1329xirc2ps_tx_timeout_task(struct work_struct *work)
1348{ 1330{
1349 struct net_device *dev = data; 1331 local_info_t *local =
1332 container_of(work, local_info_t, tx_timeout_task);
1333 struct net_device *dev = local->dev;
1350 /* reset the card */ 1334 /* reset the card */
1351 do_reset(dev,1); 1335 do_reset(dev,1);
1352 dev->trans_start = jiffies; 1336 dev->trans_start = jiffies;
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index f14e99276dba..096d4a100bf2 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -254,7 +254,7 @@ static int fixed_mdio_register_device(int number, int speed, int duplex)
254 goto device_create_fail; 254 goto device_create_fail;
255 } 255 }
256 256
257 phydev->irq = -1; 257 phydev->irq = PHY_IGNORE_INTERRUPT;
258 phydev->dev.bus = &mdio_bus_type; 258 phydev->dev.bus = &mdio_bus_type;
259 259
260 if(number) 260 if(number)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 88237bdb5255..4044bb1ada86 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -397,7 +397,7 @@ out_unlock:
397EXPORT_SYMBOL(phy_start_aneg); 397EXPORT_SYMBOL(phy_start_aneg);
398 398
399 399
400static void phy_change(void *data); 400static void phy_change(struct work_struct *work);
401static void phy_timer(unsigned long data); 401static void phy_timer(unsigned long data);
402 402
403/* phy_start_machine: 403/* phy_start_machine:
@@ -555,7 +555,7 @@ int phy_start_interrupts(struct phy_device *phydev)
555{ 555{
556 int err = 0; 556 int err = 0;
557 557
558 INIT_WORK(&phydev->phy_queue, phy_change, phydev); 558 INIT_WORK(&phydev->phy_queue, phy_change);
559 559
560 if (request_irq(phydev->irq, phy_interrupt, 560 if (request_irq(phydev->irq, phy_interrupt,
561 IRQF_SHARED, 561 IRQF_SHARED,
@@ -598,10 +598,11 @@ EXPORT_SYMBOL(phy_stop_interrupts);
598 598
599 599
600/* Scheduled by the phy_interrupt/timer to handle PHY changes */ 600/* Scheduled by the phy_interrupt/timer to handle PHY changes */
601static void phy_change(void *data) 601static void phy_change(struct work_struct *work)
602{ 602{
603 int err; 603 int err;
604 struct phy_device *phydev = data; 604 struct phy_device *phydev =
605 container_of(work, struct phy_device, phy_queue);
605 606
606 err = phy_disable_interrupts(phydev); 607 err = phy_disable_interrupts(phydev);
607 608
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 71afb274498f..6bb085f54437 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -138,9 +138,9 @@ static const unsigned int net_debug = NET_DEBUG;
138#define PLIP_NIBBLE_WAIT 3000 138#define PLIP_NIBBLE_WAIT 3000
139 139
140/* Bottom halves */ 140/* Bottom halves */
141static void plip_kick_bh(struct net_device *dev); 141static void plip_kick_bh(struct work_struct *work);
142static void plip_bh(struct net_device *dev); 142static void plip_bh(struct work_struct *work);
143static void plip_timer_bh(struct net_device *dev); 143static void plip_timer_bh(struct work_struct *work);
144 144
145/* Interrupt handler */ 145/* Interrupt handler */
146static void plip_interrupt(int irq, void *dev_id); 146static void plip_interrupt(int irq, void *dev_id);
@@ -207,9 +207,10 @@ struct plip_local {
207 207
208struct net_local { 208struct net_local {
209 struct net_device_stats enet_stats; 209 struct net_device_stats enet_stats;
210 struct net_device *dev;
210 struct work_struct immediate; 211 struct work_struct immediate;
211 struct work_struct deferred; 212 struct delayed_work deferred;
212 struct work_struct timer; 213 struct delayed_work timer;
213 struct plip_local snd_data; 214 struct plip_local snd_data;
214 struct plip_local rcv_data; 215 struct plip_local rcv_data;
215 struct pardevice *pardev; 216 struct pardevice *pardev;
@@ -306,11 +307,11 @@ plip_init_netdev(struct net_device *dev)
306 nl->nibble = PLIP_NIBBLE_WAIT; 307 nl->nibble = PLIP_NIBBLE_WAIT;
307 308
308 /* Initialize task queue structures */ 309 /* Initialize task queue structures */
309 INIT_WORK(&nl->immediate, (void (*)(void *))plip_bh, dev); 310 INIT_WORK(&nl->immediate, plip_bh);
310 INIT_WORK(&nl->deferred, (void (*)(void *))plip_kick_bh, dev); 311 INIT_DELAYED_WORK(&nl->deferred, plip_kick_bh);
311 312
312 if (dev->irq == -1) 313 if (dev->irq == -1)
313 INIT_WORK(&nl->timer, (void (*)(void *))plip_timer_bh, dev); 314 INIT_DELAYED_WORK(&nl->timer, plip_timer_bh);
314 315
315 spin_lock_init(&nl->lock); 316 spin_lock_init(&nl->lock);
316} 317}
@@ -319,9 +320,10 @@ plip_init_netdev(struct net_device *dev)
319 This routine is kicked by do_timer(). 320 This routine is kicked by do_timer().
320 Request `plip_bh' to be invoked. */ 321 Request `plip_bh' to be invoked. */
321static void 322static void
322plip_kick_bh(struct net_device *dev) 323plip_kick_bh(struct work_struct *work)
323{ 324{
324 struct net_local *nl = netdev_priv(dev); 325 struct net_local *nl =
326 container_of(work, struct net_local, deferred.work);
325 327
326 if (nl->is_deferred) 328 if (nl->is_deferred)
327 schedule_work(&nl->immediate); 329 schedule_work(&nl->immediate);
@@ -362,9 +364,9 @@ static const plip_func connection_state_table[] =
362 364
363/* Bottom half handler of PLIP. */ 365/* Bottom half handler of PLIP. */
364static void 366static void
365plip_bh(struct net_device *dev) 367plip_bh(struct work_struct *work)
366{ 368{
367 struct net_local *nl = netdev_priv(dev); 369 struct net_local *nl = container_of(work, struct net_local, immediate);
368 struct plip_local *snd = &nl->snd_data; 370 struct plip_local *snd = &nl->snd_data;
369 struct plip_local *rcv = &nl->rcv_data; 371 struct plip_local *rcv = &nl->rcv_data;
370 plip_func f; 372 plip_func f;
@@ -372,20 +374,21 @@ plip_bh(struct net_device *dev)
372 374
373 nl->is_deferred = 0; 375 nl->is_deferred = 0;
374 f = connection_state_table[nl->connection]; 376 f = connection_state_table[nl->connection];
375 if ((r = (*f)(dev, nl, snd, rcv)) != OK 377 if ((r = (*f)(nl->dev, nl, snd, rcv)) != OK
376 && (r = plip_bh_timeout_error(dev, nl, snd, rcv, r)) != OK) { 378 && (r = plip_bh_timeout_error(nl->dev, nl, snd, rcv, r)) != OK) {
377 nl->is_deferred = 1; 379 nl->is_deferred = 1;
378 schedule_delayed_work(&nl->deferred, 1); 380 schedule_delayed_work(&nl->deferred, 1);
379 } 381 }
380} 382}
381 383
382static void 384static void
383plip_timer_bh(struct net_device *dev) 385plip_timer_bh(struct work_struct *work)
384{ 386{
385 struct net_local *nl = netdev_priv(dev); 387 struct net_local *nl =
388 container_of(work, struct net_local, timer.work);
386 389
387 if (!(atomic_read (&nl->kill_timer))) { 390 if (!(atomic_read (&nl->kill_timer))) {
388 plip_interrupt (-1, dev); 391 plip_interrupt (-1, nl->dev);
389 392
390 schedule_delayed_work(&nl->timer, 1); 393 schedule_delayed_work(&nl->timer, 1);
391 } 394 }
@@ -1284,6 +1287,7 @@ static void plip_attach (struct parport *port)
1284 } 1287 }
1285 1288
1286 nl = netdev_priv(dev); 1289 nl = netdev_priv(dev);
1290 nl->dev = dev;
1287 nl->pardev = parport_register_device(port, name, plip_preempt, 1291 nl->pardev = parport_register_device(port, name, plip_preempt,
1288 plip_wakeup, plip_interrupt, 1292 plip_wakeup, plip_interrupt,
1289 0, dev); 1293 0, dev);
diff --git a/drivers/net/qla3xxx.c b/drivers/net/qla3xxx.c
index ec640f6229ae..d79d141a601d 100644
--- a/drivers/net/qla3xxx.c
+++ b/drivers/net/qla3xxx.c
@@ -2008,7 +2008,7 @@ static irqreturn_t ql3xxx_isr(int irq, void *dev_id)
2008 "%s: Another function issued a reset to the " 2008 "%s: Another function issued a reset to the "
2009 "chip. ISR value = %x.\n", ndev->name, value); 2009 "chip. ISR value = %x.\n", ndev->name, value);
2010 } 2010 }
2011 queue_work(qdev->workqueue, &qdev->reset_work); 2011 queue_delayed_work(qdev->workqueue, &qdev->reset_work, 0);
2012 spin_unlock(&qdev->adapter_lock); 2012 spin_unlock(&qdev->adapter_lock);
2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) { 2013 } else if (value & ISP_IMR_DISABLE_CMPL_INT) {
2014 ql_disable_interrupts(qdev); 2014 ql_disable_interrupts(qdev);
@@ -3182,11 +3182,13 @@ static void ql3xxx_tx_timeout(struct net_device *ndev)
3182 /* 3182 /*
3183 * Wake up the worker to process this event. 3183 * Wake up the worker to process this event.
3184 */ 3184 */
3185 queue_work(qdev->workqueue, &qdev->tx_timeout_work); 3185 queue_delayed_work(qdev->workqueue, &qdev->tx_timeout_work, 0);
3186} 3186}
3187 3187
3188static void ql_reset_work(struct ql3_adapter *qdev) 3188static void ql_reset_work(struct work_struct *work)
3189{ 3189{
3190 struct ql3_adapter *qdev =
3191 container_of(work, struct ql3_adapter, reset_work.work);
3190 struct net_device *ndev = qdev->ndev; 3192 struct net_device *ndev = qdev->ndev;
3191 u32 value; 3193 u32 value;
3192 struct ql_tx_buf_cb *tx_cb; 3194 struct ql_tx_buf_cb *tx_cb;
@@ -3278,9 +3280,12 @@ static void ql_reset_work(struct ql3_adapter *qdev)
3278 } 3280 }
3279} 3281}
3280 3282
3281static void ql_tx_timeout_work(struct ql3_adapter *qdev) 3283static void ql_tx_timeout_work(struct work_struct *work)
3282{ 3284{
3283 ql_cycle_adapter(qdev,QL_DO_RESET); 3285 struct ql3_adapter *qdev =
3286 container_of(work, struct ql3_adapter, tx_timeout_work.work);
3287
3288 ql_cycle_adapter(qdev, QL_DO_RESET);
3284} 3289}
3285 3290
3286static void ql_get_board_info(struct ql3_adapter *qdev) 3291static void ql_get_board_info(struct ql3_adapter *qdev)
@@ -3459,9 +3464,8 @@ static int __devinit ql3xxx_probe(struct pci_dev *pdev,
3459 netif_stop_queue(ndev); 3464 netif_stop_queue(ndev);
3460 3465
3461 qdev->workqueue = create_singlethread_workqueue(ndev->name); 3466 qdev->workqueue = create_singlethread_workqueue(ndev->name);
3462 INIT_WORK(&qdev->reset_work, (void (*)(void *))ql_reset_work, qdev); 3467 INIT_DELAYED_WORK(&qdev->reset_work, ql_reset_work);
3463 INIT_WORK(&qdev->tx_timeout_work, 3468 INIT_DELAYED_WORK(&qdev->tx_timeout_work, ql_tx_timeout_work);
3464 (void (*)(void *))ql_tx_timeout_work, qdev);
3465 3469
3466 init_timer(&qdev->adapter_timer); 3470 init_timer(&qdev->adapter_timer);
3467 qdev->adapter_timer.function = ql3xxx_timer; 3471 qdev->adapter_timer.function = ql3xxx_timer;
diff --git a/drivers/net/qla3xxx.h b/drivers/net/qla3xxx.h
index 65da2c0bfda6..ea94de7fd071 100644
--- a/drivers/net/qla3xxx.h
+++ b/drivers/net/qla3xxx.h
@@ -1186,8 +1186,8 @@ struct ql3_adapter {
1186 u32 numPorts; 1186 u32 numPorts;
1187 struct net_device_stats stats; 1187 struct net_device_stats stats;
1188 struct workqueue_struct *workqueue; 1188 struct workqueue_struct *workqueue;
1189 struct work_struct reset_work; 1189 struct delayed_work reset_work;
1190 struct work_struct tx_timeout_work; 1190 struct delayed_work tx_timeout_work;
1191 u32 max_frame_size; 1191 u32 max_frame_size;
1192}; 1192};
1193 1193
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 45d3ca431957..85a392fab5cc 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -424,6 +424,7 @@ struct ring_info {
424struct rtl8169_private { 424struct rtl8169_private {
425 void __iomem *mmio_addr; /* memory map physical address */ 425 void __iomem *mmio_addr; /* memory map physical address */
426 struct pci_dev *pci_dev; /* Index of PCI device */ 426 struct pci_dev *pci_dev; /* Index of PCI device */
427 struct net_device *dev;
427 struct net_device_stats stats; /* statistics of net device */ 428 struct net_device_stats stats; /* statistics of net device */
428 spinlock_t lock; /* spin lock flag */ 429 spinlock_t lock; /* spin lock flag */
429 u32 msg_enable; 430 u32 msg_enable;
@@ -455,7 +456,7 @@ struct rtl8169_private {
455 void (*phy_reset_enable)(void __iomem *); 456 void (*phy_reset_enable)(void __iomem *);
456 unsigned int (*phy_reset_pending)(void __iomem *); 457 unsigned int (*phy_reset_pending)(void __iomem *);
457 unsigned int (*link_ok)(void __iomem *); 458 unsigned int (*link_ok)(void __iomem *);
458 struct work_struct task; 459 struct delayed_work task;
459 unsigned wol_enabled : 1; 460 unsigned wol_enabled : 1;
460}; 461};
461 462
@@ -1510,6 +1511,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1510 SET_MODULE_OWNER(dev); 1511 SET_MODULE_OWNER(dev);
1511 SET_NETDEV_DEV(dev, &pdev->dev); 1512 SET_NETDEV_DEV(dev, &pdev->dev);
1512 tp = netdev_priv(dev); 1513 tp = netdev_priv(dev);
1514 tp->dev = dev;
1513 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); 1515 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
1514 1516
1515 /* enable device (incl. PCI PM wakeup and hotplug setup) */ 1517 /* enable device (incl. PCI PM wakeup and hotplug setup) */
@@ -1782,7 +1784,7 @@ static int rtl8169_open(struct net_device *dev)
1782 if (retval < 0) 1784 if (retval < 0)
1783 goto err_free_rx; 1785 goto err_free_rx;
1784 1786
1785 INIT_WORK(&tp->task, NULL, dev); 1787 INIT_DELAYED_WORK(&tp->task, NULL);
1786 1788
1787 rtl8169_hw_start(dev); 1789 rtl8169_hw_start(dev);
1788 1790
@@ -2105,11 +2107,11 @@ static void rtl8169_tx_clear(struct rtl8169_private *tp)
2105 tp->cur_tx = tp->dirty_tx = 0; 2107 tp->cur_tx = tp->dirty_tx = 0;
2106} 2108}
2107 2109
2108static void rtl8169_schedule_work(struct net_device *dev, void (*task)(void *)) 2110static void rtl8169_schedule_work(struct net_device *dev, work_func_t task)
2109{ 2111{
2110 struct rtl8169_private *tp = netdev_priv(dev); 2112 struct rtl8169_private *tp = netdev_priv(dev);
2111 2113
2112 PREPARE_WORK(&tp->task, task, dev); 2114 PREPARE_DELAYED_WORK(&tp->task, task);
2113 schedule_delayed_work(&tp->task, 4); 2115 schedule_delayed_work(&tp->task, 4);
2114} 2116}
2115 2117
@@ -2128,9 +2130,11 @@ static void rtl8169_wait_for_quiescence(struct net_device *dev)
2128 netif_poll_enable(dev); 2130 netif_poll_enable(dev);
2129} 2131}
2130 2132
2131static void rtl8169_reinit_task(void *_data) 2133static void rtl8169_reinit_task(struct work_struct *work)
2132{ 2134{
2133 struct net_device *dev = _data; 2135 struct rtl8169_private *tp =
2136 container_of(work, struct rtl8169_private, task.work);
2137 struct net_device *dev = tp->dev;
2134 int ret; 2138 int ret;
2135 2139
2136 if (netif_running(dev)) { 2140 if (netif_running(dev)) {
@@ -2153,10 +2157,11 @@ static void rtl8169_reinit_task(void *_data)
2153 } 2157 }
2154} 2158}
2155 2159
2156static void rtl8169_reset_task(void *_data) 2160static void rtl8169_reset_task(struct work_struct *work)
2157{ 2161{
2158 struct net_device *dev = _data; 2162 struct rtl8169_private *tp =
2159 struct rtl8169_private *tp = netdev_priv(dev); 2163 container_of(work, struct rtl8169_private, task.work);
2164 struct net_device *dev = tp->dev;
2160 2165
2161 if (!netif_running(dev)) 2166 if (!netif_running(dev))
2162 return; 2167 return;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 33569ec9dbfc..250cdbeefdfd 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5872,9 +5872,9 @@ static void s2io_tasklet(unsigned long dev_addr)
5872 * Description: Sets the link status for the adapter 5872 * Description: Sets the link status for the adapter
5873 */ 5873 */
5874 5874
5875static void s2io_set_link(unsigned long data) 5875static void s2io_set_link(struct work_struct *work)
5876{ 5876{
5877 nic_t *nic = (nic_t *) data; 5877 nic_t *nic = container_of(work, nic_t, set_link_task);
5878 struct net_device *dev = nic->dev; 5878 struct net_device *dev = nic->dev;
5879 XENA_dev_config_t __iomem *bar0 = nic->bar0; 5879 XENA_dev_config_t __iomem *bar0 = nic->bar0;
5880 register u64 val64; 5880 register u64 val64;
@@ -6379,10 +6379,10 @@ static int s2io_card_up(nic_t * sp)
6379 * spin lock. 6379 * spin lock.
6380 */ 6380 */
6381 6381
6382static void s2io_restart_nic(unsigned long data) 6382static void s2io_restart_nic(struct work_struct *work)
6383{ 6383{
6384 struct net_device *dev = (struct net_device *) data; 6384 nic_t *sp = container_of(work, nic_t, rst_timer_task);
6385 nic_t *sp = dev->priv; 6385 struct net_device *dev = sp->dev;
6386 6386
6387 s2io_card_down(sp); 6387 s2io_card_down(sp);
6388 if (s2io_card_up(sp)) { 6388 if (s2io_card_up(sp)) {
@@ -6992,10 +6992,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
6992 6992
6993 dev->tx_timeout = &s2io_tx_watchdog; 6993 dev->tx_timeout = &s2io_tx_watchdog;
6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT; 6994 dev->watchdog_timeo = WATCH_DOG_TIMEOUT;
6995 INIT_WORK(&sp->rst_timer_task, 6995 INIT_WORK(&sp->rst_timer_task, s2io_restart_nic);
6996 (void (*)(void *)) s2io_restart_nic, dev); 6996 INIT_WORK(&sp->set_link_task, s2io_set_link);
6997 INIT_WORK(&sp->set_link_task,
6998 (void (*)(void *)) s2io_set_link, sp);
6999 6997
7000 pci_save_state(sp->pdev); 6998 pci_save_state(sp->pdev);
7001 6999
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 12b719f4d00f..3b0bafd273c8 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -1000,7 +1000,7 @@ s2io_msix_fifo_handle(int irq, void *dev_id);
1000static irqreturn_t s2io_isr(int irq, void *dev_id); 1000static irqreturn_t s2io_isr(int irq, void *dev_id);
1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag); 1001static int verify_xena_quiescence(nic_t *sp, u64 val64, int flag);
1002static const struct ethtool_ops netdev_ethtool_ops; 1002static const struct ethtool_ops netdev_ethtool_ops;
1003static void s2io_set_link(unsigned long data); 1003static void s2io_set_link(struct work_struct *work);
1004static int s2io_set_swapper(nic_t * sp); 1004static int s2io_set_swapper(nic_t * sp);
1005static void s2io_card_down(nic_t *nic); 1005static void s2io_card_down(nic_t *nic);
1006static int s2io_card_up(nic_t *nic); 1006static int s2io_card_up(nic_t *nic);
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index aaba458584fb..b70ed79d4121 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -280,6 +280,7 @@ enum sis190_feature {
280struct sis190_private { 280struct sis190_private {
281 void __iomem *mmio_addr; 281 void __iomem *mmio_addr;
282 struct pci_dev *pci_dev; 282 struct pci_dev *pci_dev;
283 struct net_device *dev;
283 struct net_device_stats stats; 284 struct net_device_stats stats;
284 spinlock_t lock; 285 spinlock_t lock;
285 u32 rx_buf_sz; 286 u32 rx_buf_sz;
@@ -897,10 +898,11 @@ static void sis190_hw_start(struct net_device *dev)
897 netif_start_queue(dev); 898 netif_start_queue(dev);
898} 899}
899 900
900static void sis190_phy_task(void * data) 901static void sis190_phy_task(struct work_struct *work)
901{ 902{
902 struct net_device *dev = data; 903 struct sis190_private *tp =
903 struct sis190_private *tp = netdev_priv(dev); 904 container_of(work, struct sis190_private, phy_task);
905 struct net_device *dev = tp->dev;
904 void __iomem *ioaddr = tp->mmio_addr; 906 void __iomem *ioaddr = tp->mmio_addr;
905 int phy_id = tp->mii_if.phy_id; 907 int phy_id = tp->mii_if.phy_id;
906 u16 val; 908 u16 val;
@@ -1047,7 +1049,7 @@ static int sis190_open(struct net_device *dev)
1047 if (rc < 0) 1049 if (rc < 0)
1048 goto err_free_rx_1; 1050 goto err_free_rx_1;
1049 1051
1050 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1052 INIT_WORK(&tp->phy_task, sis190_phy_task);
1051 1053
1052 sis190_request_timer(dev); 1054 sis190_request_timer(dev);
1053 1055
@@ -1436,6 +1438,7 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1436 SET_NETDEV_DEV(dev, &pdev->dev); 1438 SET_NETDEV_DEV(dev, &pdev->dev);
1437 1439
1438 tp = netdev_priv(dev); 1440 tp = netdev_priv(dev);
1441 tp->dev = dev;
1439 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT); 1442 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT);
1440 1443
1441 rc = pci_enable_device(pdev); 1444 rc = pci_enable_device(pdev);
@@ -1798,7 +1801,7 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1798 1801
1799 sis190_init_rxfilter(dev); 1802 sis190_init_rxfilter(dev);
1800 1803
1801 INIT_WORK(&tp->phy_task, sis190_phy_task, dev); 1804 INIT_WORK(&tp->phy_task, sis190_phy_task);
1802 1805
1803 dev->open = sis190_open; 1806 dev->open = sis190_open;
1804 dev->stop = sis190_close; 1807 dev->stop = sis190_close;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 5513907e8393..b60f0451f6cd 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -1327,10 +1327,11 @@ static void xm_check_link(struct net_device *dev)
1327 * Since internal PHY is wired to a level triggered pin, can't 1327 * Since internal PHY is wired to a level triggered pin, can't
1328 * get an interrupt when carrier is detected. 1328 * get an interrupt when carrier is detected.
1329 */ 1329 */
1330static void xm_link_timer(void *arg) 1330static void xm_link_timer(struct work_struct *work)
1331{ 1331{
1332 struct net_device *dev = arg; 1332 struct skge_port *skge =
1333 struct skge_port *skge = netdev_priv(arg); 1333 container_of(work, struct skge_port, link_thread.work);
1334 struct net_device *dev = skge->netdev;
1334 struct skge_hw *hw = skge->hw; 1335 struct skge_hw *hw = skge->hw;
1335 int port = skge->port; 1336 int port = skge->port;
1336 1337
@@ -3072,9 +3073,9 @@ static void skge_error_irq(struct skge_hw *hw)
3072 * because accessing phy registers requires spin wait which might 3073 * because accessing phy registers requires spin wait which might
3073 * cause excess interrupt latency. 3074 * cause excess interrupt latency.
3074 */ 3075 */
3075static void skge_extirq(void *arg) 3076static void skge_extirq(struct work_struct *work)
3076{ 3077{
3077 struct skge_hw *hw = arg; 3078 struct skge_hw *hw = container_of(work, struct skge_hw, phy_work);
3078 int port; 3079 int port;
3079 3080
3080 mutex_lock(&hw->phy_mutex); 3081 mutex_lock(&hw->phy_mutex);
@@ -3456,7 +3457,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3456 skge->port = port; 3457 skge->port = port;
3457 3458
3458 /* Only used for Genesis XMAC */ 3459 /* Only used for Genesis XMAC */
3459 INIT_WORK(&skge->link_thread, xm_link_timer, dev); 3460 INIT_DELAYED_WORK(&skge->link_thread, xm_link_timer);
3460 3461
3461 if (hw->chip_id != CHIP_ID_GENESIS) { 3462 if (hw->chip_id != CHIP_ID_GENESIS) {
3462 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3463 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
@@ -3543,7 +3544,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3543 3544
3544 hw->pdev = pdev; 3545 hw->pdev = pdev;
3545 mutex_init(&hw->phy_mutex); 3546 mutex_init(&hw->phy_mutex);
3546 INIT_WORK(&hw->phy_work, skge_extirq, hw); 3547 INIT_WORK(&hw->phy_work, skge_extirq);
3547 spin_lock_init(&hw->hw_lock); 3548 spin_lock_init(&hw->hw_lock);
3548 3549
3549 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000); 3550 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 537c0aaa1db8..23e5275d920c 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2456,7 +2456,7 @@ struct skge_port {
2456 2456
2457 struct net_device_stats net_stats; 2457 struct net_device_stats net_stats;
2458 2458
2459 struct work_struct link_thread; 2459 struct delayed_work link_thread;
2460 enum pause_control flow_control; 2460 enum pause_control flow_control;
2461 enum pause_status flow_status; 2461 enum pause_status flow_status;
2462 u8 rx_csum; 2462 u8 rx_csum;
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 95b6478f55c6..e62a9586fb95 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -210,6 +210,7 @@ struct smc_local {
210 210
211 /* work queue */ 211 /* work queue */
212 struct work_struct phy_configure; 212 struct work_struct phy_configure;
213 struct net_device *dev;
213 int work_pending; 214 int work_pending;
214 215
215 spinlock_t lock; 216 spinlock_t lock;
@@ -1114,10 +1115,11 @@ static void smc_phy_check_media(struct net_device *dev, int init)
1114 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection 1115 * of autonegotiation.) If the RPC ANEG bit is cleared, the selection
1115 * is controlled by the RPC SPEED and RPC DPLX bits. 1116 * is controlled by the RPC SPEED and RPC DPLX bits.
1116 */ 1117 */
1117static void smc_phy_configure(void *data) 1118static void smc_phy_configure(struct work_struct *work)
1118{ 1119{
1119 struct net_device *dev = data; 1120 struct smc_local *lp =
1120 struct smc_local *lp = netdev_priv(dev); 1121 container_of(work, struct smc_local, phy_configure);
1122 struct net_device *dev = lp->dev;
1121 void __iomem *ioaddr = lp->base; 1123 void __iomem *ioaddr = lp->base;
1122 int phyaddr = lp->mii.phy_id; 1124 int phyaddr = lp->mii.phy_id;
1123 int my_phy_caps; /* My PHY capabilities */ 1125 int my_phy_caps; /* My PHY capabilities */
@@ -1592,7 +1594,7 @@ smc_open(struct net_device *dev)
1592 1594
1593 /* Configure the PHY, initialize the link state */ 1595 /* Configure the PHY, initialize the link state */
1594 if (lp->phy_type != 0) 1596 if (lp->phy_type != 0)
1595 smc_phy_configure(dev); 1597 smc_phy_configure(&lp->phy_configure);
1596 else { 1598 else {
1597 spin_lock_irq(&lp->lock); 1599 spin_lock_irq(&lp->lock);
1598 smc_10bt_check_media(dev, 1); 1600 smc_10bt_check_media(dev, 1);
@@ -1972,7 +1974,8 @@ static int __init smc_probe(struct net_device *dev, void __iomem *ioaddr)
1972#endif 1974#endif
1973 1975
1974 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev); 1976 tasklet_init(&lp->tx_task, smc_hardware_send_pkt, (unsigned long)dev);
1975 INIT_WORK(&lp->phy_configure, smc_phy_configure, dev); 1977 INIT_WORK(&lp->phy_configure, smc_phy_configure);
1978 lp->dev = dev;
1976 lp->mii.phy_id_mask = 0x1f; 1979 lp->mii.phy_id_mask = 0x1f;
1977 lp->mii.reg_num_mask = 0x1f; 1980 lp->mii.reg_num_mask = 0x1f;
1978 lp->mii.force_media = 0; 1981 lp->mii.force_media = 0;
@@ -2322,7 +2325,7 @@ static int smc_drv_resume(struct platform_device *dev)
2322 smc_reset(ndev); 2325 smc_reset(ndev);
2323 smc_enable(ndev); 2326 smc_enable(ndev);
2324 if (lp->phy_type != 0) 2327 if (lp->phy_type != 0)
2325 smc_phy_configure(ndev); 2328 smc_phy_configure(&lp->phy_configure);
2326 netif_device_attach(ndev); 2329 netif_device_attach(ndev);
2327 } 2330 }
2328 } 2331 }
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index cef7e6671c49..ebb6aa39f9c7 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -88,12 +88,11 @@ MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl);
88static inline u32 88static inline u32
89spider_net_read_reg(struct spider_net_card *card, u32 reg) 89spider_net_read_reg(struct spider_net_card *card, u32 reg)
90{ 90{
91 u32 value; 91 /* We use the powerpc specific variants instead of readl_be() because
92 92 * we know spidernet is not a real PCI device and we can thus avoid the
93 value = readl(card->regs + reg); 93 * performance hit caused by the PCI workarounds.
94 value = le32_to_cpu(value); 94 */
95 95 return in_be32(card->regs + reg);
96 return value;
97} 96}
98 97
99/** 98/**
@@ -105,8 +104,11 @@ spider_net_read_reg(struct spider_net_card *card, u32 reg)
105static inline void 104static inline void
106spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) 105spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value)
107{ 106{
108 value = cpu_to_le32(value); 107 /* We use the powerpc specific variants instead of writel_be() because
109 writel(value, card->regs + reg); 108 * we know spidernet is not a real PCI device and we can thus avoid the
109 * performance hit caused by the PCI workarounds.
110 */
111 out_be32(card->regs + reg, value);
110} 112}
111 113
112/** spider_net_write_phy - write to phy register 114/** spider_net_write_phy - write to phy register
@@ -1937,10 +1939,11 @@ spider_net_stop(struct net_device *netdev)
1937 * called as task when tx hangs, resets interface (if interface is up) 1939 * called as task when tx hangs, resets interface (if interface is up)
1938 */ 1940 */
1939static void 1941static void
1940spider_net_tx_timeout_task(void *data) 1942spider_net_tx_timeout_task(struct work_struct *work)
1941{ 1943{
1942 struct net_device *netdev = data; 1944 struct spider_net_card *card =
1943 struct spider_net_card *card = netdev_priv(netdev); 1945 container_of(work, struct spider_net_card, tx_timeout_task);
1946 struct net_device *netdev = card->netdev;
1944 1947
1945 if (!(netdev->flags & IFF_UP)) 1948 if (!(netdev->flags & IFF_UP))
1946 goto out; 1949 goto out;
@@ -2114,7 +2117,7 @@ spider_net_alloc_card(void)
2114 card = netdev_priv(netdev); 2117 card = netdev_priv(netdev);
2115 card->netdev = netdev; 2118 card->netdev = netdev;
2116 card->msg_enable = SPIDER_NET_DEFAULT_MSG; 2119 card->msg_enable = SPIDER_NET_DEFAULT_MSG;
2117 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task, netdev); 2120 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task);
2118 init_waitqueue_head(&card->waitq); 2121 init_waitqueue_head(&card->waitq);
2119 atomic_set(&card->tx_timeout_task_counter, 0); 2122 atomic_set(&card->tx_timeout_task_counter, 0);
2120 2123
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index cf44e72399b9..785e4a535f9e 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2282,9 +2282,9 @@ static void gem_do_stop(struct net_device *dev, int wol)
2282 } 2282 }
2283} 2283}
2284 2284
2285static void gem_reset_task(void *data) 2285static void gem_reset_task(struct work_struct *work)
2286{ 2286{
2287 struct gem *gp = (struct gem *) data; 2287 struct gem *gp = container_of(work, struct gem, reset_task);
2288 2288
2289 mutex_lock(&gp->pm_mutex); 2289 mutex_lock(&gp->pm_mutex);
2290 2290
@@ -3044,7 +3044,7 @@ static int __devinit gem_init_one(struct pci_dev *pdev,
3044 gp->link_timer.function = gem_link_timer; 3044 gp->link_timer.function = gem_link_timer;
3045 gp->link_timer.data = (unsigned long) gp; 3045 gp->link_timer.data = (unsigned long) gp;
3046 3046
3047 INIT_WORK(&gp->reset_task, gem_reset_task, gp); 3047 INIT_WORK(&gp->reset_task, gem_reset_task);
3048 3048
3049 gp->lstate = link_down; 3049 gp->lstate = link_down;
3050 gp->timer_ticks = 0; 3050 gp->timer_ticks = 0;
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index c20bb998e0e5..d9123c9adc1e 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -3654,9 +3654,9 @@ static void tg3_poll_controller(struct net_device *dev)
3654} 3654}
3655#endif 3655#endif
3656 3656
3657static void tg3_reset_task(void *_data) 3657static void tg3_reset_task(struct work_struct *work)
3658{ 3658{
3659 struct tg3 *tp = _data; 3659 struct tg3 *tp = container_of(work, struct tg3, reset_task);
3660 unsigned int restart_timer; 3660 unsigned int restart_timer;
3661 3661
3662 tg3_full_lock(tp, 0); 3662 tg3_full_lock(tp, 0);
@@ -11734,7 +11734,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11734#endif 11734#endif
11735 spin_lock_init(&tp->lock); 11735 spin_lock_init(&tp->lock);
11736 spin_lock_init(&tp->indirect_lock); 11736 spin_lock_init(&tp->indirect_lock);
11737 INIT_WORK(&tp->reset_task, tg3_reset_task, tp); 11737 INIT_WORK(&tp->reset_task, tg3_reset_task);
11738 11738
11739 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len); 11739 tp->regs = ioremap_nocache(tg3reg_base, tg3reg_len);
11740 if (tp->regs == 0UL) { 11740 if (tp->regs == 0UL) {
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index e14f5a00f65a..f85f00251123 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -296,6 +296,7 @@ static void TLan_SetMulticastList( struct net_device *);
296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd); 296static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd);
297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent); 297static int TLan_probe1( struct pci_dev *pdev, long ioaddr, int irq, int rev, const struct pci_device_id *ent);
298static void TLan_tx_timeout( struct net_device *dev); 298static void TLan_tx_timeout( struct net_device *dev);
299static void TLan_tx_timeout_work(struct work_struct *work);
299static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent); 300static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent);
300 301
301static u32 TLan_HandleInvalid( struct net_device *, u16 ); 302static u32 TLan_HandleInvalid( struct net_device *, u16 );
@@ -562,6 +563,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
562 priv = netdev_priv(dev); 563 priv = netdev_priv(dev);
563 564
564 priv->pciDev = pdev; 565 priv->pciDev = pdev;
566 priv->dev = dev;
565 567
566 /* Is this a PCI device? */ 568 /* Is this a PCI device? */
567 if (pdev) { 569 if (pdev) {
@@ -634,7 +636,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
634 636
635 /* This will be used when we get an adapter error from 637 /* This will be used when we get an adapter error from
636 * within our irq handler */ 638 * within our irq handler */
637 INIT_WORK(&priv->tlan_tqueue, (void *)(void*)TLan_tx_timeout, dev); 639 INIT_WORK(&priv->tlan_tqueue, TLan_tx_timeout_work);
638 640
639 spin_lock_init(&priv->lock); 641 spin_lock_init(&priv->lock);
640 642
@@ -1040,6 +1042,25 @@ static void TLan_tx_timeout(struct net_device *dev)
1040} 1042}
1041 1043
1042 1044
1045 /***************************************************************
1046 * TLan_tx_timeout_work
1047 *
1048 * Returns: nothing
1049 *
1050 * Params:
1051 * work work item of device which timed out
1052 *
1053 **************************************************************/
1054
1055static void TLan_tx_timeout_work(struct work_struct *work)
1056{
1057 TLanPrivateInfo *priv =
1058 container_of(work, TLanPrivateInfo, tlan_tqueue);
1059
1060 TLan_tx_timeout(priv->dev);
1061}
1062
1063
1043 1064
1044 /*************************************************************** 1065 /***************************************************************
1045 * TLan_StartTx 1066 * TLan_StartTx
diff --git a/drivers/net/tlan.h b/drivers/net/tlan.h
index a44e2f2ef62a..41ce0b665937 100644
--- a/drivers/net/tlan.h
+++ b/drivers/net/tlan.h
@@ -170,6 +170,7 @@ typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
170typedef struct tlan_private_tag { 170typedef struct tlan_private_tag {
171 struct net_device *nextDevice; 171 struct net_device *nextDevice;
172 struct pci_dev *pciDev; 172 struct pci_dev *pciDev;
173 struct net_device *dev;
173 void *dmaStorage; 174 void *dmaStorage;
174 dma_addr_t dmaStorageDMA; 175 dma_addr_t dmaStorageDMA;
175 unsigned int dmaSize; 176 unsigned int dmaSize;
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index bfe59865b1dd..0d97e10ccac5 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -1826,7 +1826,7 @@ static void tr_rx(struct net_device *dev)
1826 skb->protocol = tr_type_trans(skb, dev); 1826 skb->protocol = tr_type_trans(skb, dev);
1827 if (IPv4_p) { 1827 if (IPv4_p) {
1828 skb->csum = chksum; 1828 skb->csum = chksum;
1829 skb->ip_summed = 1; 1829 skb->ip_summed = CHECKSUM_COMPLETE;
1830 } 1830 }
1831 netif_rx(skb); 1831 netif_rx(skb);
1832 dev->last_rx = jiffies; 1832 dev->last_rx = jiffies;
diff --git a/drivers/net/tulip/21142.c b/drivers/net/tulip/21142.c
index fa3a2bb105ad..942b839ccc5b 100644
--- a/drivers/net/tulip/21142.c
+++ b/drivers/net/tulip/21142.c
@@ -26,10 +26,11 @@ static u16 t21142_csr15[] = { 0x0008, 0x0006, 0x000E, 0x0008, 0x0008, };
26 26
27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list 27/* Handle the 21143 uniquely: do autoselect with NWay, not the EEPROM list
28 of available transceivers. */ 28 of available transceivers. */
29void t21142_media_task(void *data) 29void t21142_media_task(struct work_struct *work)
30{ 30{
31 struct net_device *dev = data; 31 struct tulip_private *tp =
32 struct tulip_private *tp = netdev_priv(dev); 32 container_of(work, struct tulip_private, media_work);
33 struct net_device *dev = tp->dev;
33 void __iomem *ioaddr = tp->base_addr; 34 void __iomem *ioaddr = tp->base_addr;
34 int csr12 = ioread32(ioaddr + CSR12); 35 int csr12 = ioread32(ioaddr + CSR12);
35 int next_tick = 60*HZ; 36 int next_tick = 60*HZ;
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 3f4b6408b755..4b3cd3d8b62a 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -473,9 +473,9 @@
473#include <asm/byteorder.h> 473#include <asm/byteorder.h>
474#include <asm/unaligned.h> 474#include <asm/unaligned.h>
475#include <asm/uaccess.h> 475#include <asm/uaccess.h>
476#ifdef CONFIG_PPC_MULTIPLATFORM 476#ifdef CONFIG_PPC_PMAC
477#include <asm/machdep.h> 477#include <asm/machdep.h>
478#endif /* CONFIG_PPC_MULTIPLATFORM */ 478#endif /* CONFIG_PPC_PMAC */
479 479
480#include "de4x5.h" 480#include "de4x5.h"
481 481
@@ -4151,7 +4151,7 @@ get_hw_addr(struct net_device *dev)
4151 /* If possible, try to fix a broken card - SMC only so far */ 4151 /* If possible, try to fix a broken card - SMC only so far */
4152 srom_repair(dev, broken); 4152 srom_repair(dev, broken);
4153 4153
4154#ifdef CONFIG_PPC_MULTIPLATFORM 4154#ifdef CONFIG_PPC_PMAC
4155 /* 4155 /*
4156 ** If the address starts with 00 a0, we have to bit-reverse 4156 ** If the address starts with 00 a0, we have to bit-reverse
4157 ** each byte of the address. 4157 ** each byte of the address.
@@ -4168,7 +4168,7 @@ get_hw_addr(struct net_device *dev)
4168 dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1); 4168 dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1);
4169 } 4169 }
4170 } 4170 }
4171#endif /* CONFIG_PPC_MULTIPLATFORM */ 4171#endif /* CONFIG_PPC_PMAC */
4172 4172
4173 /* Test for a bad enet address */ 4173 /* Test for a bad enet address */
4174 status = test_bad_enet(dev, status); 4174 status = test_bad_enet(dev, status);
diff --git a/drivers/net/tulip/timer.c b/drivers/net/tulip/timer.c
index 066e5d6bcbd8..df326fe1cc8f 100644
--- a/drivers/net/tulip/timer.c
+++ b/drivers/net/tulip/timer.c
@@ -18,10 +18,11 @@
18#include "tulip.h" 18#include "tulip.h"
19 19
20 20
21void tulip_media_task(void *data) 21void tulip_media_task(struct work_struct *work)
22{ 22{
23 struct net_device *dev = data; 23 struct tulip_private *tp =
24 struct tulip_private *tp = netdev_priv(dev); 24 container_of(work, struct tulip_private, media_work);
25 struct net_device *dev = tp->dev;
25 void __iomem *ioaddr = tp->base_addr; 26 void __iomem *ioaddr = tp->base_addr;
26 u32 csr12 = ioread32(ioaddr + CSR12); 27 u32 csr12 = ioread32(ioaddr + CSR12);
27 int next_tick = 2*HZ; 28 int next_tick = 2*HZ;
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index ad107f45c7b1..25f25da76917 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -44,7 +44,7 @@ struct tulip_chip_table {
44 int valid_intrs; /* CSR7 interrupt enable settings */ 44 int valid_intrs; /* CSR7 interrupt enable settings */
45 int flags; 45 int flags;
46 void (*media_timer) (unsigned long); 46 void (*media_timer) (unsigned long);
47 void (*media_task) (void *); 47 work_func_t media_task;
48}; 48};
49 49
50 50
@@ -392,6 +392,7 @@ struct tulip_private {
392 int csr12_shadow; 392 int csr12_shadow;
393 int pad0; /* Used for 8-byte alignment */ 393 int pad0; /* Used for 8-byte alignment */
394 struct work_struct media_work; 394 struct work_struct media_work;
395 struct net_device *dev;
395}; 396};
396 397
397 398
@@ -406,7 +407,7 @@ struct eeprom_fixup {
406 407
407/* 21142.c */ 408/* 21142.c */
408extern u16 t21142_csr14[]; 409extern u16 t21142_csr14[];
409void t21142_media_task(void *data); 410void t21142_media_task(struct work_struct *work);
410void t21142_start_nway(struct net_device *dev); 411void t21142_start_nway(struct net_device *dev);
411void t21142_lnk_change(struct net_device *dev, int csr5); 412void t21142_lnk_change(struct net_device *dev, int csr5);
412 413
@@ -444,7 +445,7 @@ void pnic_lnk_change(struct net_device *dev, int csr5);
444void pnic_timer(unsigned long data); 445void pnic_timer(unsigned long data);
445 446
446/* timer.c */ 447/* timer.c */
447void tulip_media_task(void *data); 448void tulip_media_task(struct work_struct *work);
448void mxic_timer(unsigned long data); 449void mxic_timer(unsigned long data);
449void comet_timer(unsigned long data); 450void comet_timer(unsigned long data);
450 451
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 0aee618f883c..5a35354aa523 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1367,6 +1367,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1367 * it is zeroed and aligned in alloc_etherdev 1367 * it is zeroed and aligned in alloc_etherdev
1368 */ 1368 */
1369 tp = netdev_priv(dev); 1369 tp = netdev_priv(dev);
1370 tp->dev = dev;
1370 1371
1371 tp->rx_ring = pci_alloc_consistent(pdev, 1372 tp->rx_ring = pci_alloc_consistent(pdev,
1372 sizeof(struct tulip_rx_desc) * RX_RING_SIZE + 1373 sizeof(struct tulip_rx_desc) * RX_RING_SIZE +
@@ -1389,7 +1390,7 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1389 tp->timer.data = (unsigned long)dev; 1390 tp->timer.data = (unsigned long)dev;
1390 tp->timer.function = tulip_tbl[tp->chip_id].media_timer; 1391 tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
1391 1392
1392 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task, dev); 1393 INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
1393 1394
1394 dev->base_addr = (unsigned long)ioaddr; 1395 dev->base_addr = (unsigned long)ioaddr;
1395 1396
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 931cbdf6d791..b2a23aed4428 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -125,8 +125,8 @@ static int cpc_tty_write_room(struct tty_struct *tty);
125static int cpc_tty_chars_in_buffer(struct tty_struct *tty); 125static int cpc_tty_chars_in_buffer(struct tty_struct *tty);
126static void cpc_tty_flush_buffer(struct tty_struct *tty); 126static void cpc_tty_flush_buffer(struct tty_struct *tty);
127static void cpc_tty_hangup(struct tty_struct *tty); 127static void cpc_tty_hangup(struct tty_struct *tty);
128static void cpc_tty_rx_work(void *data); 128static void cpc_tty_rx_work(struct work_struct *work);
129static void cpc_tty_tx_work(void *data); 129static void cpc_tty_tx_work(struct work_struct *work);
130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len); 130static int cpc_tty_send_to_card(pc300dev_t *dev,void *buf, int len);
131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx); 131static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx);
132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char); 132static void cpc_tty_signal_off(pc300dev_t *pc300dev, unsigned char);
@@ -261,8 +261,8 @@ void cpc_tty_init(pc300dev_t *pc300dev)
261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START; 261 cpc_tty->tty_minor = port + CPC_TTY_MINOR_START;
262 cpc_tty->pc300dev = pc300dev; 262 cpc_tty->pc300dev = pc300dev;
263 263
264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work, (void *)cpc_tty); 264 INIT_WORK(&cpc_tty->tty_tx_work, cpc_tty_tx_work);
265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work, (void *)port); 265 INIT_WORK(&cpc_tty->tty_rx_work, cpc_tty_rx_work);
266 266
267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL; 267 cpc_tty->buf_rx.first = cpc_tty->buf_rx.last = NULL;
268 268
@@ -659,21 +659,23 @@ static void cpc_tty_hangup(struct tty_struct *tty)
659 * o call the line disc. read 659 * o call the line disc. read
660 * o free memory 660 * o free memory
661 */ 661 */
662static void cpc_tty_rx_work(void * data) 662static void cpc_tty_rx_work(struct work_struct *work)
663{ 663{
664 st_cpc_tty_area *cpc_tty;
664 unsigned long port; 665 unsigned long port;
665 int i, j; 666 int i, j;
666 st_cpc_tty_area *cpc_tty;
667 volatile st_cpc_rx_buf *buf; 667 volatile st_cpc_rx_buf *buf;
668 char flags=0,flg_rx=1; 668 char flags=0,flg_rx=1;
669 struct tty_ldisc *ld; 669 struct tty_ldisc *ld;
670 670
671 if (cpc_tty_cnt == 0) return; 671 if (cpc_tty_cnt == 0) return;
672
673 672
674 for (i=0; (i < 4) && flg_rx ; i++) { 673 for (i=0; (i < 4) && flg_rx ; i++) {
675 flg_rx = 0; 674 flg_rx = 0;
676 port = (unsigned long)data; 675
676 cpc_tty = container_of(work, st_cpc_tty_area, tty_rx_work);
677 port = cpc_tty - cpc_tty_area;
678
677 for (j=0; j < CPC_TTY_NPORTS; j++) { 679 for (j=0; j < CPC_TTY_NPORTS; j++) {
678 cpc_tty = &cpc_tty_area[port]; 680 cpc_tty = &cpc_tty_area[port];
679 681
@@ -882,9 +884,10 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
882 * o if need call line discipline wakeup 884 * o if need call line discipline wakeup
883 * o call wake_up_interruptible 885 * o call wake_up_interruptible
884 */ 886 */
885static void cpc_tty_tx_work(void *data) 887static void cpc_tty_tx_work(struct work_struct *work)
886{ 888{
887 st_cpc_tty_area *cpc_tty = (st_cpc_tty_area *) data; 889 st_cpc_tty_area *cpc_tty =
890 container_of(work, st_cpc_tty_area, tty_tx_work);
888 struct tty_struct *tty; 891 struct tty_struct *tty;
889 892
890 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name); 893 CPC_TTY_DBG("%s: cpc_tty_tx_work init\n",cpc_tty->name);
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index ac9437d497f0..f12355398fe7 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -219,21 +219,6 @@ static int airo_config(struct pcmcia_device *link)
219 dev = link->priv; 219 dev = link->priv;
220 220
221 DEBUG(0, "airo_config(0x%p)\n", link); 221 DEBUG(0, "airo_config(0x%p)\n", link);
222
223 /*
224 This reads the card's CONFIG tuple to find its configuration
225 registers.
226 */
227 tuple.DesiredTuple = CISTPL_CONFIG;
228 tuple.Attributes = 0;
229 tuple.TupleData = buf;
230 tuple.TupleDataMax = sizeof(buf);
231 tuple.TupleOffset = 0;
232 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
233 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
234 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
235 link->conf.ConfigBase = parse.config.base;
236 link->conf.Present = parse.config.rmask[0];
237 222
238 /* 223 /*
239 In this loop, we scan the CIS for configuration table entries, 224 In this loop, we scan the CIS for configuration table entries,
@@ -247,6 +232,10 @@ static int airo_config(struct pcmcia_device *link)
247 these things without consulting the CIS, and most client drivers 232 these things without consulting the CIS, and most client drivers
248 will only use the CIS to fill in implementation-defined details. 233 will only use the CIS to fill in implementation-defined details.
249 */ 234 */
235 tuple.Attributes = 0;
236 tuple.TupleData = buf;
237 tuple.TupleDataMax = sizeof(buf);
238 tuple.TupleOffset = 0;
250 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 239 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
251 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 240 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
252 while (1) { 241 while (1) {
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 5c410989c4d7..12617cd0b78e 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -244,17 +244,6 @@ static int atmel_config(struct pcmcia_device *link)
244 tuple.TupleOffset = 0; 244 tuple.TupleOffset = 0;
245 245
246 /* 246 /*
247 This reads the card's CONFIG tuple to find its configuration
248 registers.
249 */
250 tuple.DesiredTuple = CISTPL_CONFIG;
251 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
252 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
253 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
254 link->conf.ConfigBase = parse.config.base;
255 link->conf.Present = parse.config.rmask[0];
256
257 /*
258 In this loop, we scan the CIS for configuration table entries, 247 In this loop, we scan the CIS for configuration table entries,
259 each of which describes a valid card configuration, including 248 each of which describes a valid card configuration, including
260 voltage, IO window, memory window, and interrupt settings. 249 voltage, IO window, memory window, and interrupt settings.
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 94dfb92fab5c..8286678513b9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -819,7 +819,7 @@ struct bcm43xx_private {
819 struct tasklet_struct isr_tasklet; 819 struct tasklet_struct isr_tasklet;
820 820
821 /* Periodic tasks */ 821 /* Periodic tasks */
822 struct work_struct periodic_work; 822 struct delayed_work periodic_work;
823 unsigned int periodic_state; 823 unsigned int periodic_state;
824 824
825 struct work_struct restart_work; 825 struct work_struct restart_work;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 5b3c27359a18..2ec2e5afce67 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -3215,9 +3215,10 @@ static void do_periodic_work(struct bcm43xx_private *bcm)
3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15); 3215 schedule_delayed_work(&bcm->periodic_work, HZ * 15);
3216} 3216}
3217 3217
3218static void bcm43xx_periodic_work_handler(void *d) 3218static void bcm43xx_periodic_work_handler(struct work_struct *work)
3219{ 3219{
3220 struct bcm43xx_private *bcm = d; 3220 struct bcm43xx_private *bcm =
3221 container_of(work, struct bcm43xx_private, periodic_work.work);
3221 struct net_device *net_dev = bcm->net_dev; 3222 struct net_device *net_dev = bcm->net_dev;
3222 unsigned long flags; 3223 unsigned long flags;
3223 u32 savedirqs = 0; 3224 u32 savedirqs = 0;
@@ -3279,11 +3280,11 @@ void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
3279 3280
3280void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm) 3281void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
3281{ 3282{
3282 struct work_struct *work = &(bcm->periodic_work); 3283 struct delayed_work *work = &bcm->periodic_work;
3283 3284
3284 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED); 3285 assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
3285 INIT_WORK(work, bcm43xx_periodic_work_handler, bcm); 3286 INIT_DELAYED_WORK(work, bcm43xx_periodic_work_handler);
3286 schedule_work(work); 3287 schedule_delayed_work(work, 0);
3287} 3288}
3288 3289
3289static void bcm43xx_security_init(struct bcm43xx_private *bcm) 3290static void bcm43xx_security_init(struct bcm43xx_private *bcm)
@@ -3635,7 +3636,7 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3635 bcm43xx_periodic_tasks_setup(bcm); 3636 bcm43xx_periodic_tasks_setup(bcm);
3636 3637
3637 /*FIXME: This should be handled by softmac instead. */ 3638 /*FIXME: This should be handled by softmac instead. */
3638 schedule_work(&bcm->softmac->associnfo.work); 3639 schedule_delayed_work(&bcm->softmac->associnfo.work, 0);
3639 3640
3640out: 3641out:
3641 mutex_unlock(&(bcm)->mutex); 3642 mutex_unlock(&(bcm)->mutex);
@@ -4182,9 +4183,10 @@ static void __devexit bcm43xx_remove_one(struct pci_dev *pdev)
4182/* Hard-reset the chip. Do not call this directly. 4183/* Hard-reset the chip. Do not call this directly.
4183 * Use bcm43xx_controller_restart() 4184 * Use bcm43xx_controller_restart()
4184 */ 4185 */
4185static void bcm43xx_chip_reset(void *_bcm) 4186static void bcm43xx_chip_reset(struct work_struct *work)
4186{ 4187{
4187 struct bcm43xx_private *bcm = _bcm; 4188 struct bcm43xx_private *bcm =
4189 container_of(work, struct bcm43xx_private, restart_work);
4188 struct bcm43xx_phyinfo *phy; 4190 struct bcm43xx_phyinfo *phy;
4189 int err = -ENODEV; 4191 int err = -ENODEV;
4190 4192
@@ -4211,7 +4213,7 @@ void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
4211 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) 4213 if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
4212 return; 4214 return;
4213 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason); 4215 printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
4214 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm); 4216 INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset);
4215 schedule_work(&bcm->restart_work); 4217 schedule_work(&bcm->restart_work);
4216} 4218}
4217 4219
diff --git a/drivers/net/wireless/hostap/hostap.h b/drivers/net/wireless/hostap/hostap.h
index e663518bd570..e89c890d16fd 100644
--- a/drivers/net/wireless/hostap/hostap.h
+++ b/drivers/net/wireless/hostap/hostap.h
@@ -35,7 +35,7 @@ int hostap_80211_get_hdrlen(u16 fc);
35struct net_device_stats *hostap_get_stats(struct net_device *dev); 35struct net_device_stats *hostap_get_stats(struct net_device *dev);
36void hostap_setup_dev(struct net_device *dev, local_info_t *local, 36void hostap_setup_dev(struct net_device *dev, local_info_t *local,
37 int main_dev); 37 int main_dev);
38void hostap_set_multicast_list_queue(void *data); 38void hostap_set_multicast_list_queue(struct work_struct *work);
39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked); 39int hostap_set_hostapd(local_info_t *local, int val, int rtnl_locked);
40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked); 40int hostap_set_hostapd_sta(local_info_t *local, int val, int rtnl_locked);
41void hostap_cleanup(local_info_t *local); 41void hostap_cleanup(local_info_t *local);
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index ba13125024cb..08bc57a4b895 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -49,10 +49,10 @@ MODULE_PARM_DESC(autom_ap_wds, "Add WDS connections to other APs "
49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta); 49static struct sta_info* ap_get_sta(struct ap_data *ap, u8 *sta);
50static void hostap_event_expired_sta(struct net_device *dev, 50static void hostap_event_expired_sta(struct net_device *dev,
51 struct sta_info *sta); 51 struct sta_info *sta);
52static void handle_add_proc_queue(void *data); 52static void handle_add_proc_queue(struct work_struct *work);
53 53
54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 54#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
55static void handle_wds_oper_queue(void *data); 55static void handle_wds_oper_queue(struct work_struct *work);
56static void prism2_send_mgmt(struct net_device *dev, 56static void prism2_send_mgmt(struct net_device *dev,
57 u16 type_subtype, char *body, 57 u16 type_subtype, char *body,
58 int body_len, u8 *addr, u16 tx_cb_idx); 58 int body_len, u8 *addr, u16 tx_cb_idx);
@@ -807,7 +807,7 @@ void hostap_init_data(local_info_t *local)
807 INIT_LIST_HEAD(&ap->sta_list); 807 INIT_LIST_HEAD(&ap->sta_list);
808 808
809 /* Initialize task queue structure for AP management */ 809 /* Initialize task queue structure for AP management */
810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue, ap); 810 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue);
811 811
812 ap->tx_callback_idx = 812 ap->tx_callback_idx =
813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap); 813 hostap_tx_callback_register(local, hostap_ap_tx_cb, ap);
@@ -815,7 +815,7 @@ void hostap_init_data(local_info_t *local)
815 printk(KERN_WARNING "%s: failed to register TX callback for " 815 printk(KERN_WARNING "%s: failed to register TX callback for "
816 "AP\n", local->dev->name); 816 "AP\n", local->dev->name);
817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 817#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue, local); 818 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue);
819 819
820 ap->tx_callback_auth = 820 ap->tx_callback_auth =
821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap); 821 hostap_tx_callback_register(local, hostap_ap_tx_cb_auth, ap);
@@ -1062,9 +1062,10 @@ static int prism2_sta_proc_read(char *page, char **start, off_t off,
1062} 1062}
1063 1063
1064 1064
1065static void handle_add_proc_queue(void *data) 1065static void handle_add_proc_queue(struct work_struct *work)
1066{ 1066{
1067 struct ap_data *ap = (struct ap_data *) data; 1067 struct ap_data *ap = container_of(work, struct ap_data,
1068 add_sta_proc_queue);
1068 struct sta_info *sta; 1069 struct sta_info *sta;
1069 char name[20]; 1070 char name[20];
1070 struct add_sta_proc_data *entry, *prev; 1071 struct add_sta_proc_data *entry, *prev;
@@ -1952,9 +1953,11 @@ static void handle_pspoll(local_info_t *local,
1952 1953
1953#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 1954#ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1954 1955
1955static void handle_wds_oper_queue(void *data) 1956static void handle_wds_oper_queue(struct work_struct *work)
1956{ 1957{
1957 local_info_t *local = data; 1958 struct ap_data *ap = container_of(work, struct ap_data,
1959 wds_oper_queue);
1960 local_info_t *local = ap->local;
1958 struct wds_oper_data *entry, *prev; 1961 struct wds_oper_data *entry, *prev;
1959 1962
1960 spin_lock_bh(&local->lock); 1963 spin_lock_bh(&local->lock);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index f63909e4bc32..ee542ec6d6a8 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -293,15 +293,12 @@ static int sandisk_enable_wireless(struct net_device *dev)
293 goto done; 293 goto done;
294 } 294 }
295 295
296 tuple.DesiredTuple = CISTPL_MANFID;
297 tuple.Attributes = TUPLE_RETURN_COMMON; 296 tuple.Attributes = TUPLE_RETURN_COMMON;
298 tuple.TupleData = buf; 297 tuple.TupleData = buf;
299 tuple.TupleDataMax = sizeof(buf); 298 tuple.TupleDataMax = sizeof(buf);
300 tuple.TupleOffset = 0; 299 tuple.TupleOffset = 0;
301 if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || 300
302 pcmcia_get_tuple_data(hw_priv->link, &tuple) || 301 if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) {
303 pcmcia_parse_tuple(hw_priv->link, &tuple, parse) ||
304 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
305 /* No SanDisk manfid found */ 302 /* No SanDisk manfid found */
306 ret = -ENODEV; 303 ret = -ENODEV;
307 goto done; 304 goto done;
@@ -573,16 +570,10 @@ static int prism2_config(struct pcmcia_device *link)
573 } 570 }
574 memset(hw_priv, 0, sizeof(*hw_priv)); 571 memset(hw_priv, 0, sizeof(*hw_priv));
575 572
576 tuple.DesiredTuple = CISTPL_CONFIG;
577 tuple.Attributes = 0; 573 tuple.Attributes = 0;
578 tuple.TupleData = buf; 574 tuple.TupleData = buf;
579 tuple.TupleDataMax = sizeof(buf); 575 tuple.TupleDataMax = sizeof(buf);
580 tuple.TupleOffset = 0; 576 tuple.TupleOffset = 0;
581 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
582 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
583 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
584 link->conf.ConfigBase = parse->config.base;
585 link->conf.Present = parse->config.rmask[0];
586 577
587 CS_CHECK(GetConfigurationInfo, 578 CS_CHECK(GetConfigurationInfo,
588 pcmcia_get_configuration_info(link, &conf)); 579 pcmcia_get_configuration_info(link, &conf));
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index ed00ebb6e7f4..c19e68636a1c 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -1645,9 +1645,9 @@ static void prism2_schedule_reset(local_info_t *local)
1645 1645
1646/* Called only as scheduled task after noticing card timeout in interrupt 1646/* Called only as scheduled task after noticing card timeout in interrupt
1647 * context */ 1647 * context */
1648static void handle_reset_queue(void *data) 1648static void handle_reset_queue(struct work_struct *work)
1649{ 1649{
1650 local_info_t *local = (local_info_t *) data; 1650 local_info_t *local = container_of(work, local_info_t, reset_queue);
1651 1651
1652 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name); 1652 printk(KERN_DEBUG "%s: scheduled card reset\n", local->dev->name);
1653 prism2_hw_reset(local->dev); 1653 prism2_hw_reset(local->dev);
@@ -2896,9 +2896,10 @@ static void hostap_passive_scan(unsigned long data)
2896 2896
2897/* Called only as a scheduled task when communications quality values should 2897/* Called only as a scheduled task when communications quality values should
2898 * be updated. */ 2898 * be updated. */
2899static void handle_comms_qual_update(void *data) 2899static void handle_comms_qual_update(struct work_struct *work)
2900{ 2900{
2901 local_info_t *local = data; 2901 local_info_t *local =
2902 container_of(work, local_info_t, comms_qual_update);
2902 prism2_update_comms_qual(local->dev); 2903 prism2_update_comms_qual(local->dev);
2903} 2904}
2904 2905
@@ -3050,9 +3051,9 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
3050} 3051}
3051 3052
3052 3053
3053static void handle_set_tim_queue(void *data) 3054static void handle_set_tim_queue(struct work_struct *work)
3054{ 3055{
3055 local_info_t *local = (local_info_t *) data; 3056 local_info_t *local = container_of(work, local_info_t, set_tim_queue);
3056 struct set_tim_data *entry; 3057 struct set_tim_data *entry;
3057 u16 val; 3058 u16 val;
3058 3059
@@ -3209,15 +3210,15 @@ prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3209 local->scan_channel_mask = 0xffff; 3210 local->scan_channel_mask = 0xffff;
3210 3211
3211 /* Initialize task queue structures */ 3212 /* Initialize task queue structures */
3212 INIT_WORK(&local->reset_queue, handle_reset_queue, local); 3213 INIT_WORK(&local->reset_queue, handle_reset_queue);
3213 INIT_WORK(&local->set_multicast_list_queue, 3214 INIT_WORK(&local->set_multicast_list_queue,
3214 hostap_set_multicast_list_queue, local->dev); 3215 hostap_set_multicast_list_queue);
3215 3216
3216 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue, local); 3217 INIT_WORK(&local->set_tim_queue, handle_set_tim_queue);
3217 INIT_LIST_HEAD(&local->set_tim_list); 3218 INIT_LIST_HEAD(&local->set_tim_list);
3218 spin_lock_init(&local->set_tim_lock); 3219 spin_lock_init(&local->set_tim_lock);
3219 3220
3220 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update, local); 3221 INIT_WORK(&local->comms_qual_update, handle_comms_qual_update);
3221 3222
3222 /* Initialize tasklets for handling hardware IRQ related operations 3223 /* Initialize tasklets for handling hardware IRQ related operations
3223 * outside hw IRQ handler */ 3224 * outside hw IRQ handler */
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 50f72d831cf4..5fd2b1ad7f5e 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -474,9 +474,9 @@ static void handle_info_queue_scanresults(local_info_t *local)
474 474
475/* Called only as scheduled task after receiving info frames (used to avoid 475/* Called only as scheduled task after receiving info frames (used to avoid
476 * pending too much time in HW IRQ handler). */ 476 * pending too much time in HW IRQ handler). */
477static void handle_info_queue(void *data) 477static void handle_info_queue(struct work_struct *work)
478{ 478{
479 local_info_t *local = (local_info_t *) data; 479 local_info_t *local = container_of(work, local_info_t, info_queue);
480 480
481 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS, 481 if (test_and_clear_bit(PRISM2_INFO_PENDING_LINKSTATUS,
482 &local->pending_info)) 482 &local->pending_info))
@@ -493,7 +493,7 @@ void hostap_info_init(local_info_t *local)
493{ 493{
494 skb_queue_head_init(&local->info_list); 494 skb_queue_head_init(&local->info_list);
495#ifndef PRISM2_NO_STATION_MODES 495#ifndef PRISM2_NO_STATION_MODES
496 INIT_WORK(&local->info_queue, handle_info_queue, local); 496 INIT_WORK(&local->info_queue, handle_info_queue);
497#endif /* PRISM2_NO_STATION_MODES */ 497#endif /* PRISM2_NO_STATION_MODES */
498} 498}
499 499
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 53374fcba77e..0796be9d9e77 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -767,14 +767,14 @@ static int prism2_set_mac_address(struct net_device *dev, void *p)
767 767
768/* TODO: to be further implemented as soon as Prism2 fully supports 768/* TODO: to be further implemented as soon as Prism2 fully supports
769 * GroupAddresses and correct documentation is available */ 769 * GroupAddresses and correct documentation is available */
770void hostap_set_multicast_list_queue(void *data) 770void hostap_set_multicast_list_queue(struct work_struct *work)
771{ 771{
772 struct net_device *dev = (struct net_device *) data; 772 local_info_t *local =
773 container_of(work, local_info_t, set_multicast_list_queue);
774 struct net_device *dev = local->dev;
773 struct hostap_interface *iface; 775 struct hostap_interface *iface;
774 local_info_t *local;
775 776
776 iface = netdev_priv(dev); 777 iface = netdev_priv(dev);
777 local = iface->local;
778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE, 778 if (hostap_set_word(dev, HFA384X_RID_PROMISCUOUSMODE,
779 local->is_promisc)) { 779 local->is_promisc)) {
780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n", 780 printk(KERN_INFO "%s: %sabling promiscuous mode failed\n",
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 79607b8b877c..1bcd352a813b 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -316,7 +316,7 @@ static void ipw2100_release_firmware(struct ipw2100_priv *priv,
316 struct ipw2100_fw *fw); 316 struct ipw2100_fw *fw);
317static int ipw2100_ucode_download(struct ipw2100_priv *priv, 317static int ipw2100_ucode_download(struct ipw2100_priv *priv,
318 struct ipw2100_fw *fw); 318 struct ipw2100_fw *fw);
319static void ipw2100_wx_event_work(struct ipw2100_priv *priv); 319static void ipw2100_wx_event_work(struct work_struct *work);
320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev); 320static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev);
321static struct iw_handler_def ipw2100_wx_handler_def; 321static struct iw_handler_def ipw2100_wx_handler_def;
322 322
@@ -679,7 +679,8 @@ static void schedule_reset(struct ipw2100_priv *priv)
679 queue_delayed_work(priv->workqueue, &priv->reset_work, 679 queue_delayed_work(priv->workqueue, &priv->reset_work,
680 priv->reset_backoff * HZ); 680 priv->reset_backoff * HZ);
681 else 681 else
682 queue_work(priv->workqueue, &priv->reset_work); 682 queue_delayed_work(priv->workqueue, &priv->reset_work,
683 0);
683 684
684 if (priv->reset_backoff < MAX_RESET_BACKOFF) 685 if (priv->reset_backoff < MAX_RESET_BACKOFF)
685 priv->reset_backoff++; 686 priv->reset_backoff++;
@@ -1873,8 +1874,10 @@ static void ipw2100_down(struct ipw2100_priv *priv)
1873 netif_stop_queue(priv->net_dev); 1874 netif_stop_queue(priv->net_dev);
1874} 1875}
1875 1876
1876static void ipw2100_reset_adapter(struct ipw2100_priv *priv) 1877static void ipw2100_reset_adapter(struct work_struct *work)
1877{ 1878{
1879 struct ipw2100_priv *priv =
1880 container_of(work, struct ipw2100_priv, reset_work.work);
1878 unsigned long flags; 1881 unsigned long flags;
1879 union iwreq_data wrqu = { 1882 union iwreq_data wrqu = {
1880 .ap_addr = { 1883 .ap_addr = {
@@ -2071,9 +2074,9 @@ static void isr_indicate_association_lost(struct ipw2100_priv *priv, u32 status)
2071 return; 2074 return;
2072 2075
2073 if (priv->status & STATUS_SECURITY_UPDATED) 2076 if (priv->status & STATUS_SECURITY_UPDATED)
2074 queue_work(priv->workqueue, &priv->security_work); 2077 queue_delayed_work(priv->workqueue, &priv->security_work, 0);
2075 2078
2076 queue_work(priv->workqueue, &priv->wx_event_work); 2079 queue_delayed_work(priv->workqueue, &priv->wx_event_work, 0);
2077} 2080}
2078 2081
2079static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) 2082static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status)
@@ -5524,8 +5527,11 @@ static int ipw2100_configure_security(struct ipw2100_priv *priv, int batch_mode)
5524 return err; 5527 return err;
5525} 5528}
5526 5529
5527static void ipw2100_security_work(struct ipw2100_priv *priv) 5530static void ipw2100_security_work(struct work_struct *work)
5528{ 5531{
5532 struct ipw2100_priv *priv =
5533 container_of(work, struct ipw2100_priv, security_work.work);
5534
5529 /* If we happen to have reconnected before we get a chance to 5535 /* If we happen to have reconnected before we get a chance to
5530 * process this, then update the security settings--which causes 5536 * process this, then update the security settings--which causes
5531 * a disassociation to occur */ 5537 * a disassociation to occur */
@@ -5748,7 +5754,7 @@ static int ipw2100_set_address(struct net_device *dev, void *p)
5748 5754
5749 priv->reset_backoff = 0; 5755 priv->reset_backoff = 0;
5750 mutex_unlock(&priv->action_mutex); 5756 mutex_unlock(&priv->action_mutex);
5751 ipw2100_reset_adapter(priv); 5757 ipw2100_reset_adapter(&priv->reset_work.work);
5752 return 0; 5758 return 0;
5753 5759
5754 done: 5760 done:
@@ -5910,9 +5916,10 @@ static const struct ethtool_ops ipw2100_ethtool_ops = {
5910 .get_drvinfo = ipw_ethtool_get_drvinfo, 5916 .get_drvinfo = ipw_ethtool_get_drvinfo,
5911}; 5917};
5912 5918
5913static void ipw2100_hang_check(void *adapter) 5919static void ipw2100_hang_check(struct work_struct *work)
5914{ 5920{
5915 struct ipw2100_priv *priv = adapter; 5921 struct ipw2100_priv *priv =
5922 container_of(work, struct ipw2100_priv, hang_check.work);
5916 unsigned long flags; 5923 unsigned long flags;
5917 u32 rtc = 0xa5a5a5a5; 5924 u32 rtc = 0xa5a5a5a5;
5918 u32 len = sizeof(rtc); 5925 u32 len = sizeof(rtc);
@@ -5952,9 +5959,10 @@ static void ipw2100_hang_check(void *adapter)
5952 spin_unlock_irqrestore(&priv->low_lock, flags); 5959 spin_unlock_irqrestore(&priv->low_lock, flags);
5953} 5960}
5954 5961
5955static void ipw2100_rf_kill(void *adapter) 5962static void ipw2100_rf_kill(struct work_struct *work)
5956{ 5963{
5957 struct ipw2100_priv *priv = adapter; 5964 struct ipw2100_priv *priv =
5965 container_of(work, struct ipw2100_priv, rf_kill.work);
5958 unsigned long flags; 5966 unsigned long flags;
5959 5967
5960 spin_lock_irqsave(&priv->low_lock, flags); 5968 spin_lock_irqsave(&priv->low_lock, flags);
@@ -6103,14 +6111,11 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6103 6111
6104 priv->workqueue = create_workqueue(DRV_NAME); 6112 priv->workqueue = create_workqueue(DRV_NAME);
6105 6113
6106 INIT_WORK(&priv->reset_work, 6114 INIT_DELAYED_WORK(&priv->reset_work, ipw2100_reset_adapter);
6107 (void (*)(void *))ipw2100_reset_adapter, priv); 6115 INIT_DELAYED_WORK(&priv->security_work, ipw2100_security_work);
6108 INIT_WORK(&priv->security_work, 6116 INIT_DELAYED_WORK(&priv->wx_event_work, ipw2100_wx_event_work);
6109 (void (*)(void *))ipw2100_security_work, priv); 6117 INIT_DELAYED_WORK(&priv->hang_check, ipw2100_hang_check);
6110 INIT_WORK(&priv->wx_event_work, 6118 INIT_DELAYED_WORK(&priv->rf_kill, ipw2100_rf_kill);
6111 (void (*)(void *))ipw2100_wx_event_work, priv);
6112 INIT_WORK(&priv->hang_check, ipw2100_hang_check, priv);
6113 INIT_WORK(&priv->rf_kill, ipw2100_rf_kill, priv);
6114 6119
6115 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 6120 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
6116 ipw2100_irq_tasklet, (unsigned long)priv); 6121 ipw2100_irq_tasklet, (unsigned long)priv);
@@ -8281,8 +8286,10 @@ static struct iw_handler_def ipw2100_wx_handler_def = {
8281 .get_wireless_stats = ipw2100_wx_wireless_stats, 8286 .get_wireless_stats = ipw2100_wx_wireless_stats,
8282}; 8287};
8283 8288
8284static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8289static void ipw2100_wx_event_work(struct work_struct *work)
8285{ 8290{
8291 struct ipw2100_priv *priv =
8292 container_of(work, struct ipw2100_priv, wx_event_work.work);
8286 union iwreq_data wrqu; 8293 union iwreq_data wrqu;
8287 int len = ETH_ALEN; 8294 int len = ETH_ALEN;
8288 8295
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 55b7227198df..de7d384d38af 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -583,11 +583,11 @@ struct ipw2100_priv {
583 struct tasklet_struct irq_tasklet; 583 struct tasklet_struct irq_tasklet;
584 584
585 struct workqueue_struct *workqueue; 585 struct workqueue_struct *workqueue;
586 struct work_struct reset_work; 586 struct delayed_work reset_work;
587 struct work_struct security_work; 587 struct delayed_work security_work;
588 struct work_struct wx_event_work; 588 struct delayed_work wx_event_work;
589 struct work_struct hang_check; 589 struct delayed_work hang_check;
590 struct work_struct rf_kill; 590 struct delayed_work rf_kill;
591 591
592 u32 interrupts; 592 u32 interrupts;
593 int tx_interrupts; 593 int tx_interrupts;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index c692d01a76ca..e82e56bb85e1 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -187,9 +187,9 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *);
187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *); 187static void ipw_rx_queue_free(struct ipw_priv *, struct ipw_rx_queue *);
188static void ipw_rx_queue_replenish(void *); 188static void ipw_rx_queue_replenish(void *);
189static int ipw_up(struct ipw_priv *); 189static int ipw_up(struct ipw_priv *);
190static void ipw_bg_up(void *); 190static void ipw_bg_up(struct work_struct *work);
191static void ipw_down(struct ipw_priv *); 191static void ipw_down(struct ipw_priv *);
192static void ipw_bg_down(void *); 192static void ipw_bg_down(struct work_struct *work);
193static int ipw_config(struct ipw_priv *); 193static int ipw_config(struct ipw_priv *);
194static int init_supported_rates(struct ipw_priv *priv, 194static int init_supported_rates(struct ipw_priv *priv,
195 struct ipw_supported_rates *prates); 195 struct ipw_supported_rates *prates);
@@ -862,11 +862,12 @@ static void ipw_led_link_on(struct ipw_priv *priv)
862 spin_unlock_irqrestore(&priv->lock, flags); 862 spin_unlock_irqrestore(&priv->lock, flags);
863} 863}
864 864
865static void ipw_bg_led_link_on(void *data) 865static void ipw_bg_led_link_on(struct work_struct *work)
866{ 866{
867 struct ipw_priv *priv = data; 867 struct ipw_priv *priv =
868 container_of(work, struct ipw_priv, led_link_on.work);
868 mutex_lock(&priv->mutex); 869 mutex_lock(&priv->mutex);
869 ipw_led_link_on(data); 870 ipw_led_link_on(priv);
870 mutex_unlock(&priv->mutex); 871 mutex_unlock(&priv->mutex);
871} 872}
872 873
@@ -906,11 +907,12 @@ static void ipw_led_link_off(struct ipw_priv *priv)
906 spin_unlock_irqrestore(&priv->lock, flags); 907 spin_unlock_irqrestore(&priv->lock, flags);
907} 908}
908 909
909static void ipw_bg_led_link_off(void *data) 910static void ipw_bg_led_link_off(struct work_struct *work)
910{ 911{
911 struct ipw_priv *priv = data; 912 struct ipw_priv *priv =
913 container_of(work, struct ipw_priv, led_link_off.work);
912 mutex_lock(&priv->mutex); 914 mutex_lock(&priv->mutex);
913 ipw_led_link_off(data); 915 ipw_led_link_off(priv);
914 mutex_unlock(&priv->mutex); 916 mutex_unlock(&priv->mutex);
915} 917}
916 918
@@ -985,11 +987,12 @@ static void ipw_led_activity_off(struct ipw_priv *priv)
985 spin_unlock_irqrestore(&priv->lock, flags); 987 spin_unlock_irqrestore(&priv->lock, flags);
986} 988}
987 989
988static void ipw_bg_led_activity_off(void *data) 990static void ipw_bg_led_activity_off(struct work_struct *work)
989{ 991{
990 struct ipw_priv *priv = data; 992 struct ipw_priv *priv =
993 container_of(work, struct ipw_priv, led_act_off.work);
991 mutex_lock(&priv->mutex); 994 mutex_lock(&priv->mutex);
992 ipw_led_activity_off(data); 995 ipw_led_activity_off(priv);
993 mutex_unlock(&priv->mutex); 996 mutex_unlock(&priv->mutex);
994} 997}
995 998
@@ -2228,11 +2231,12 @@ static void ipw_adapter_restart(void *adapter)
2228 } 2231 }
2229} 2232}
2230 2233
2231static void ipw_bg_adapter_restart(void *data) 2234static void ipw_bg_adapter_restart(struct work_struct *work)
2232{ 2235{
2233 struct ipw_priv *priv = data; 2236 struct ipw_priv *priv =
2237 container_of(work, struct ipw_priv, adapter_restart);
2234 mutex_lock(&priv->mutex); 2238 mutex_lock(&priv->mutex);
2235 ipw_adapter_restart(data); 2239 ipw_adapter_restart(priv);
2236 mutex_unlock(&priv->mutex); 2240 mutex_unlock(&priv->mutex);
2237} 2241}
2238 2242
@@ -2249,11 +2253,12 @@ static void ipw_scan_check(void *data)
2249 } 2253 }
2250} 2254}
2251 2255
2252static void ipw_bg_scan_check(void *data) 2256static void ipw_bg_scan_check(struct work_struct *work)
2253{ 2257{
2254 struct ipw_priv *priv = data; 2258 struct ipw_priv *priv =
2259 container_of(work, struct ipw_priv, scan_check.work);
2255 mutex_lock(&priv->mutex); 2260 mutex_lock(&priv->mutex);
2256 ipw_scan_check(data); 2261 ipw_scan_check(priv);
2257 mutex_unlock(&priv->mutex); 2262 mutex_unlock(&priv->mutex);
2258} 2263}
2259 2264
@@ -3831,17 +3836,19 @@ static int ipw_disassociate(void *data)
3831 return 1; 3836 return 1;
3832} 3837}
3833 3838
3834static void ipw_bg_disassociate(void *data) 3839static void ipw_bg_disassociate(struct work_struct *work)
3835{ 3840{
3836 struct ipw_priv *priv = data; 3841 struct ipw_priv *priv =
3842 container_of(work, struct ipw_priv, disassociate);
3837 mutex_lock(&priv->mutex); 3843 mutex_lock(&priv->mutex);
3838 ipw_disassociate(data); 3844 ipw_disassociate(priv);
3839 mutex_unlock(&priv->mutex); 3845 mutex_unlock(&priv->mutex);
3840} 3846}
3841 3847
3842static void ipw_system_config(void *data) 3848static void ipw_system_config(struct work_struct *work)
3843{ 3849{
3844 struct ipw_priv *priv = data; 3850 struct ipw_priv *priv =
3851 container_of(work, struct ipw_priv, system_config);
3845 3852
3846#ifdef CONFIG_IPW2200_PROMISCUOUS 3853#ifdef CONFIG_IPW2200_PROMISCUOUS
3847 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) { 3854 if (priv->prom_net_dev && netif_running(priv->prom_net_dev)) {
@@ -4208,11 +4215,12 @@ static void ipw_gather_stats(struct ipw_priv *priv)
4208 IPW_STATS_INTERVAL); 4215 IPW_STATS_INTERVAL);
4209} 4216}
4210 4217
4211static void ipw_bg_gather_stats(void *data) 4218static void ipw_bg_gather_stats(struct work_struct *work)
4212{ 4219{
4213 struct ipw_priv *priv = data; 4220 struct ipw_priv *priv =
4221 container_of(work, struct ipw_priv, gather_stats.work);
4214 mutex_lock(&priv->mutex); 4222 mutex_lock(&priv->mutex);
4215 ipw_gather_stats(data); 4223 ipw_gather_stats(priv);
4216 mutex_unlock(&priv->mutex); 4224 mutex_unlock(&priv->mutex);
4217} 4225}
4218 4226
@@ -4268,8 +4276,8 @@ static void ipw_handle_missed_beacon(struct ipw_priv *priv,
4268 if (!(priv->status & STATUS_ROAMING)) { 4276 if (!(priv->status & STATUS_ROAMING)) {
4269 priv->status |= STATUS_ROAMING; 4277 priv->status |= STATUS_ROAMING;
4270 if (!(priv->status & STATUS_SCANNING)) 4278 if (!(priv->status & STATUS_SCANNING))
4271 queue_work(priv->workqueue, 4279 queue_delayed_work(priv->workqueue,
4272 &priv->request_scan); 4280 &priv->request_scan, 0);
4273 } 4281 }
4274 return; 4282 return;
4275 } 4283 }
@@ -4607,8 +4615,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4607#ifdef CONFIG_IPW2200_MONITOR 4615#ifdef CONFIG_IPW2200_MONITOR
4608 if (priv->ieee->iw_mode == IW_MODE_MONITOR) { 4616 if (priv->ieee->iw_mode == IW_MODE_MONITOR) {
4609 priv->status |= STATUS_SCAN_FORCED; 4617 priv->status |= STATUS_SCAN_FORCED;
4610 queue_work(priv->workqueue, 4618 queue_delayed_work(priv->workqueue,
4611 &priv->request_scan); 4619 &priv->request_scan, 0);
4612 break; 4620 break;
4613 } 4621 }
4614 priv->status &= ~STATUS_SCAN_FORCED; 4622 priv->status &= ~STATUS_SCAN_FORCED;
@@ -4631,8 +4639,8 @@ static void ipw_rx_notification(struct ipw_priv *priv,
4631 /* Don't schedule if we aborted the scan */ 4639 /* Don't schedule if we aborted the scan */
4632 priv->status &= ~STATUS_ROAMING; 4640 priv->status &= ~STATUS_ROAMING;
4633 } else if (priv->status & STATUS_SCAN_PENDING) 4641 } else if (priv->status & STATUS_SCAN_PENDING)
4634 queue_work(priv->workqueue, 4642 queue_delayed_work(priv->workqueue,
4635 &priv->request_scan); 4643 &priv->request_scan, 0);
4636 else if (priv->config & CFG_BACKGROUND_SCAN 4644 else if (priv->config & CFG_BACKGROUND_SCAN
4637 && priv->status & STATUS_ASSOCIATED) 4645 && priv->status & STATUS_ASSOCIATED)
4638 queue_delayed_work(priv->workqueue, 4646 queue_delayed_work(priv->workqueue,
@@ -5055,11 +5063,12 @@ static void ipw_rx_queue_replenish(void *data)
5055 ipw_rx_queue_restock(priv); 5063 ipw_rx_queue_restock(priv);
5056} 5064}
5057 5065
5058static void ipw_bg_rx_queue_replenish(void *data) 5066static void ipw_bg_rx_queue_replenish(struct work_struct *work)
5059{ 5067{
5060 struct ipw_priv *priv = data; 5068 struct ipw_priv *priv =
5069 container_of(work, struct ipw_priv, rx_replenish);
5061 mutex_lock(&priv->mutex); 5070 mutex_lock(&priv->mutex);
5062 ipw_rx_queue_replenish(data); 5071 ipw_rx_queue_replenish(priv);
5063 mutex_unlock(&priv->mutex); 5072 mutex_unlock(&priv->mutex);
5064} 5073}
5065 5074
@@ -5489,9 +5498,10 @@ static int ipw_find_adhoc_network(struct ipw_priv *priv,
5489 return 1; 5498 return 1;
5490} 5499}
5491 5500
5492static void ipw_merge_adhoc_network(void *data) 5501static void ipw_merge_adhoc_network(struct work_struct *work)
5493{ 5502{
5494 struct ipw_priv *priv = data; 5503 struct ipw_priv *priv =
5504 container_of(work, struct ipw_priv, merge_networks);
5495 struct ieee80211_network *network = NULL; 5505 struct ieee80211_network *network = NULL;
5496 struct ipw_network_match match = { 5506 struct ipw_network_match match = {
5497 .network = priv->assoc_network 5507 .network = priv->assoc_network
@@ -5948,11 +5958,12 @@ static void ipw_adhoc_check(void *data)
5948 priv->assoc_request.beacon_interval); 5958 priv->assoc_request.beacon_interval);
5949} 5959}
5950 5960
5951static void ipw_bg_adhoc_check(void *data) 5961static void ipw_bg_adhoc_check(struct work_struct *work)
5952{ 5962{
5953 struct ipw_priv *priv = data; 5963 struct ipw_priv *priv =
5964 container_of(work, struct ipw_priv, adhoc_check.work);
5954 mutex_lock(&priv->mutex); 5965 mutex_lock(&priv->mutex);
5955 ipw_adhoc_check(data); 5966 ipw_adhoc_check(priv);
5956 mutex_unlock(&priv->mutex); 5967 mutex_unlock(&priv->mutex);
5957} 5968}
5958 5969
@@ -6299,19 +6310,26 @@ done:
6299 return err; 6310 return err;
6300} 6311}
6301 6312
6302static int ipw_request_passive_scan(struct ipw_priv *priv) { 6313static void ipw_request_passive_scan(struct work_struct *work)
6303 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE); 6314{
6315 struct ipw_priv *priv =
6316 container_of(work, struct ipw_priv, request_passive_scan);
6317 ipw_request_scan_helper(priv, IW_SCAN_TYPE_PASSIVE);
6304} 6318}
6305 6319
6306static int ipw_request_scan(struct ipw_priv *priv) { 6320static void ipw_request_scan(struct work_struct *work)
6307 return ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE); 6321{
6322 struct ipw_priv *priv =
6323 container_of(work, struct ipw_priv, request_scan.work);
6324 ipw_request_scan_helper(priv, IW_SCAN_TYPE_ACTIVE);
6308} 6325}
6309 6326
6310static void ipw_bg_abort_scan(void *data) 6327static void ipw_bg_abort_scan(struct work_struct *work)
6311{ 6328{
6312 struct ipw_priv *priv = data; 6329 struct ipw_priv *priv =
6330 container_of(work, struct ipw_priv, abort_scan);
6313 mutex_lock(&priv->mutex); 6331 mutex_lock(&priv->mutex);
6314 ipw_abort_scan(data); 6332 ipw_abort_scan(priv);
6315 mutex_unlock(&priv->mutex); 6333 mutex_unlock(&priv->mutex);
6316} 6334}
6317 6335
@@ -7084,9 +7102,10 @@ static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
7084/* 7102/*
7085* background support to run QoS activate functionality 7103* background support to run QoS activate functionality
7086*/ 7104*/
7087static void ipw_bg_qos_activate(void *data) 7105static void ipw_bg_qos_activate(struct work_struct *work)
7088{ 7106{
7089 struct ipw_priv *priv = data; 7107 struct ipw_priv *priv =
7108 container_of(work, struct ipw_priv, qos_activate);
7090 7109
7091 if (priv == NULL) 7110 if (priv == NULL)
7092 return; 7111 return;
@@ -7394,11 +7413,12 @@ static void ipw_roam(void *data)
7394 priv->status &= ~STATUS_ROAMING; 7413 priv->status &= ~STATUS_ROAMING;
7395} 7414}
7396 7415
7397static void ipw_bg_roam(void *data) 7416static void ipw_bg_roam(struct work_struct *work)
7398{ 7417{
7399 struct ipw_priv *priv = data; 7418 struct ipw_priv *priv =
7419 container_of(work, struct ipw_priv, roam);
7400 mutex_lock(&priv->mutex); 7420 mutex_lock(&priv->mutex);
7401 ipw_roam(data); 7421 ipw_roam(priv);
7402 mutex_unlock(&priv->mutex); 7422 mutex_unlock(&priv->mutex);
7403} 7423}
7404 7424
@@ -7479,8 +7499,8 @@ static int ipw_associate(void *data)
7479 &priv->request_scan, 7499 &priv->request_scan,
7480 SCAN_INTERVAL); 7500 SCAN_INTERVAL);
7481 else 7501 else
7482 queue_work(priv->workqueue, 7502 queue_delayed_work(priv->workqueue,
7483 &priv->request_scan); 7503 &priv->request_scan, 0);
7484 } 7504 }
7485 7505
7486 return 0; 7506 return 0;
@@ -7491,11 +7511,12 @@ static int ipw_associate(void *data)
7491 return 1; 7511 return 1;
7492} 7512}
7493 7513
7494static void ipw_bg_associate(void *data) 7514static void ipw_bg_associate(struct work_struct *work)
7495{ 7515{
7496 struct ipw_priv *priv = data; 7516 struct ipw_priv *priv =
7517 container_of(work, struct ipw_priv, associate);
7497 mutex_lock(&priv->mutex); 7518 mutex_lock(&priv->mutex);
7498 ipw_associate(data); 7519 ipw_associate(priv);
7499 mutex_unlock(&priv->mutex); 7520 mutex_unlock(&priv->mutex);
7500} 7521}
7501 7522
@@ -9410,7 +9431,7 @@ static int ipw_wx_set_scan(struct net_device *dev,
9410 9431
9411 IPW_DEBUG_WX("Start scan\n"); 9432 IPW_DEBUG_WX("Start scan\n");
9412 9433
9413 queue_work(priv->workqueue, &priv->request_scan); 9434 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
9414 9435
9415 return 0; 9436 return 0;
9416} 9437}
@@ -10547,11 +10568,12 @@ static void ipw_rf_kill(void *adapter)
10547 spin_unlock_irqrestore(&priv->lock, flags); 10568 spin_unlock_irqrestore(&priv->lock, flags);
10548} 10569}
10549 10570
10550static void ipw_bg_rf_kill(void *data) 10571static void ipw_bg_rf_kill(struct work_struct *work)
10551{ 10572{
10552 struct ipw_priv *priv = data; 10573 struct ipw_priv *priv =
10574 container_of(work, struct ipw_priv, rf_kill.work);
10553 mutex_lock(&priv->mutex); 10575 mutex_lock(&priv->mutex);
10554 ipw_rf_kill(data); 10576 ipw_rf_kill(priv);
10555 mutex_unlock(&priv->mutex); 10577 mutex_unlock(&priv->mutex);
10556} 10578}
10557 10579
@@ -10582,11 +10604,12 @@ static void ipw_link_up(struct ipw_priv *priv)
10582 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ); 10604 queue_delayed_work(priv->workqueue, &priv->request_scan, HZ);
10583} 10605}
10584 10606
10585static void ipw_bg_link_up(void *data) 10607static void ipw_bg_link_up(struct work_struct *work)
10586{ 10608{
10587 struct ipw_priv *priv = data; 10609 struct ipw_priv *priv =
10610 container_of(work, struct ipw_priv, link_up);
10588 mutex_lock(&priv->mutex); 10611 mutex_lock(&priv->mutex);
10589 ipw_link_up(data); 10612 ipw_link_up(priv);
10590 mutex_unlock(&priv->mutex); 10613 mutex_unlock(&priv->mutex);
10591} 10614}
10592 10615
@@ -10606,15 +10629,16 @@ static void ipw_link_down(struct ipw_priv *priv)
10606 10629
10607 if (!(priv->status & STATUS_EXIT_PENDING)) { 10630 if (!(priv->status & STATUS_EXIT_PENDING)) {
10608 /* Queue up another scan... */ 10631 /* Queue up another scan... */
10609 queue_work(priv->workqueue, &priv->request_scan); 10632 queue_delayed_work(priv->workqueue, &priv->request_scan, 0);
10610 } 10633 }
10611} 10634}
10612 10635
10613static void ipw_bg_link_down(void *data) 10636static void ipw_bg_link_down(struct work_struct *work)
10614{ 10637{
10615 struct ipw_priv *priv = data; 10638 struct ipw_priv *priv =
10639 container_of(work, struct ipw_priv, link_down);
10616 mutex_lock(&priv->mutex); 10640 mutex_lock(&priv->mutex);
10617 ipw_link_down(data); 10641 ipw_link_down(priv);
10618 mutex_unlock(&priv->mutex); 10642 mutex_unlock(&priv->mutex);
10619} 10643}
10620 10644
@@ -10626,38 +10650,30 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)
10626 init_waitqueue_head(&priv->wait_command_queue); 10650 init_waitqueue_head(&priv->wait_command_queue);
10627 init_waitqueue_head(&priv->wait_state); 10651 init_waitqueue_head(&priv->wait_state);
10628 10652
10629 INIT_WORK(&priv->adhoc_check, ipw_bg_adhoc_check, priv); 10653 INIT_DELAYED_WORK(&priv->adhoc_check, ipw_bg_adhoc_check);
10630 INIT_WORK(&priv->associate, ipw_bg_associate, priv); 10654 INIT_WORK(&priv->associate, ipw_bg_associate);
10631 INIT_WORK(&priv->disassociate, ipw_bg_disassociate, priv); 10655 INIT_WORK(&priv->disassociate, ipw_bg_disassociate);
10632 INIT_WORK(&priv->system_config, ipw_system_config, priv); 10656 INIT_WORK(&priv->system_config, ipw_system_config);
10633 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish, priv); 10657 INIT_WORK(&priv->rx_replenish, ipw_bg_rx_queue_replenish);
10634 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart, priv); 10658 INIT_WORK(&priv->adapter_restart, ipw_bg_adapter_restart);
10635 INIT_WORK(&priv->rf_kill, ipw_bg_rf_kill, priv); 10659 INIT_DELAYED_WORK(&priv->rf_kill, ipw_bg_rf_kill);
10636 INIT_WORK(&priv->up, (void (*)(void *))ipw_bg_up, priv); 10660 INIT_WORK(&priv->up, ipw_bg_up);
10637 INIT_WORK(&priv->down, (void (*)(void *))ipw_bg_down, priv); 10661 INIT_WORK(&priv->down, ipw_bg_down);
10638 INIT_WORK(&priv->request_scan, 10662 INIT_DELAYED_WORK(&priv->request_scan, ipw_request_scan);
10639 (void (*)(void *))ipw_request_scan, priv); 10663 INIT_WORK(&priv->request_passive_scan, ipw_request_passive_scan);
10640 INIT_WORK(&priv->request_passive_scan, 10664 INIT_DELAYED_WORK(&priv->gather_stats, ipw_bg_gather_stats);
10641 (void (*)(void *))ipw_request_passive_scan, priv); 10665 INIT_WORK(&priv->abort_scan, ipw_bg_abort_scan);
10642 INIT_WORK(&priv->gather_stats, 10666 INIT_WORK(&priv->roam, ipw_bg_roam);
10643 (void (*)(void *))ipw_bg_gather_stats, priv); 10667 INIT_DELAYED_WORK(&priv->scan_check, ipw_bg_scan_check);
10644 INIT_WORK(&priv->abort_scan, (void (*)(void *))ipw_bg_abort_scan, priv); 10668 INIT_WORK(&priv->link_up, ipw_bg_link_up);
10645 INIT_WORK(&priv->roam, ipw_bg_roam, priv); 10669 INIT_WORK(&priv->link_down, ipw_bg_link_down);
10646 INIT_WORK(&priv->scan_check, ipw_bg_scan_check, priv); 10670 INIT_DELAYED_WORK(&priv->led_link_on, ipw_bg_led_link_on);
10647 INIT_WORK(&priv->link_up, (void (*)(void *))ipw_bg_link_up, priv); 10671 INIT_DELAYED_WORK(&priv->led_link_off, ipw_bg_led_link_off);
10648 INIT_WORK(&priv->link_down, (void (*)(void *))ipw_bg_link_down, priv); 10672 INIT_DELAYED_WORK(&priv->led_act_off, ipw_bg_led_activity_off);
10649 INIT_WORK(&priv->led_link_on, (void (*)(void *))ipw_bg_led_link_on, 10673 INIT_WORK(&priv->merge_networks, ipw_merge_adhoc_network);
10650 priv);
10651 INIT_WORK(&priv->led_link_off, (void (*)(void *))ipw_bg_led_link_off,
10652 priv);
10653 INIT_WORK(&priv->led_act_off, (void (*)(void *))ipw_bg_led_activity_off,
10654 priv);
10655 INIT_WORK(&priv->merge_networks,
10656 (void (*)(void *))ipw_merge_adhoc_network, priv);
10657 10674
10658#ifdef CONFIG_IPW2200_QOS 10675#ifdef CONFIG_IPW2200_QOS
10659 INIT_WORK(&priv->qos_activate, (void (*)(void *))ipw_bg_qos_activate, 10676 INIT_WORK(&priv->qos_activate, ipw_bg_qos_activate);
10660 priv);
10661#endif /* CONFIG_IPW2200_QOS */ 10677#endif /* CONFIG_IPW2200_QOS */
10662 10678
10663 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) 10679 tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long))
@@ -11190,7 +11206,8 @@ static int ipw_up(struct ipw_priv *priv)
11190 11206
11191 /* If configure to try and auto-associate, kick 11207 /* If configure to try and auto-associate, kick
11192 * off a scan. */ 11208 * off a scan. */
11193 queue_work(priv->workqueue, &priv->request_scan); 11209 queue_delayed_work(priv->workqueue,
11210 &priv->request_scan, 0);
11194 11211
11195 return 0; 11212 return 0;
11196 } 11213 }
@@ -11211,11 +11228,12 @@ static int ipw_up(struct ipw_priv *priv)
11211 return -EIO; 11228 return -EIO;
11212} 11229}
11213 11230
11214static void ipw_bg_up(void *data) 11231static void ipw_bg_up(struct work_struct *work)
11215{ 11232{
11216 struct ipw_priv *priv = data; 11233 struct ipw_priv *priv =
11234 container_of(work, struct ipw_priv, up);
11217 mutex_lock(&priv->mutex); 11235 mutex_lock(&priv->mutex);
11218 ipw_up(data); 11236 ipw_up(priv);
11219 mutex_unlock(&priv->mutex); 11237 mutex_unlock(&priv->mutex);
11220} 11238}
11221 11239
@@ -11282,11 +11300,12 @@ static void ipw_down(struct ipw_priv *priv)
11282 ipw_led_radio_off(priv); 11300 ipw_led_radio_off(priv);
11283} 11301}
11284 11302
11285static void ipw_bg_down(void *data) 11303static void ipw_bg_down(struct work_struct *work)
11286{ 11304{
11287 struct ipw_priv *priv = data; 11305 struct ipw_priv *priv =
11306 container_of(work, struct ipw_priv, down);
11288 mutex_lock(&priv->mutex); 11307 mutex_lock(&priv->mutex);
11289 ipw_down(data); 11308 ipw_down(priv);
11290 mutex_unlock(&priv->mutex); 11309 mutex_unlock(&priv->mutex);
11291} 11310}
11292 11311
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index dad5eedefbf1..626a240a87d8 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -1290,21 +1290,21 @@ struct ipw_priv {
1290 1290
1291 struct workqueue_struct *workqueue; 1291 struct workqueue_struct *workqueue;
1292 1292
1293 struct work_struct adhoc_check; 1293 struct delayed_work adhoc_check;
1294 struct work_struct associate; 1294 struct work_struct associate;
1295 struct work_struct disassociate; 1295 struct work_struct disassociate;
1296 struct work_struct system_config; 1296 struct work_struct system_config;
1297 struct work_struct rx_replenish; 1297 struct work_struct rx_replenish;
1298 struct work_struct request_scan; 1298 struct delayed_work request_scan;
1299 struct work_struct request_passive_scan; 1299 struct work_struct request_passive_scan;
1300 struct work_struct adapter_restart; 1300 struct work_struct adapter_restart;
1301 struct work_struct rf_kill; 1301 struct delayed_work rf_kill;
1302 struct work_struct up; 1302 struct work_struct up;
1303 struct work_struct down; 1303 struct work_struct down;
1304 struct work_struct gather_stats; 1304 struct delayed_work gather_stats;
1305 struct work_struct abort_scan; 1305 struct work_struct abort_scan;
1306 struct work_struct roam; 1306 struct work_struct roam;
1307 struct work_struct scan_check; 1307 struct delayed_work scan_check;
1308 struct work_struct link_up; 1308 struct work_struct link_up;
1309 struct work_struct link_down; 1309 struct work_struct link_down;
1310 1310
@@ -1319,9 +1319,9 @@ struct ipw_priv {
1319 u32 led_ofdm_on; 1319 u32 led_ofdm_on;
1320 u32 led_ofdm_off; 1320 u32 led_ofdm_off;
1321 1321
1322 struct work_struct led_link_on; 1322 struct delayed_work led_link_on;
1323 struct work_struct led_link_off; 1323 struct delayed_work led_link_off;
1324 struct work_struct led_act_off; 1324 struct delayed_work led_act_off;
1325 struct work_struct merge_networks; 1325 struct work_struct merge_networks;
1326 1326
1327 struct ipw_cmd_log *cmdlog; 1327 struct ipw_cmd_log *cmdlog;
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 6714e0dfa8d6..644b4741ef74 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -735,10 +735,7 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
735static int netwave_pcmcia_config(struct pcmcia_device *link) { 735static int netwave_pcmcia_config(struct pcmcia_device *link) {
736 struct net_device *dev = link->priv; 736 struct net_device *dev = link->priv;
737 netwave_private *priv = netdev_priv(dev); 737 netwave_private *priv = netdev_priv(dev);
738 tuple_t tuple;
739 cisparse_t parse;
740 int i, j, last_ret, last_fn; 738 int i, j, last_ret, last_fn;
741 u_char buf[64];
742 win_req_t req; 739 win_req_t req;
743 memreq_t mem; 740 memreq_t mem;
744 u_char __iomem *ramBase = NULL; 741 u_char __iomem *ramBase = NULL;
@@ -746,21 +743,6 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
746 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link); 743 DEBUG(0, "netwave_pcmcia_config(0x%p)\n", link);
747 744
748 /* 745 /*
749 This reads the card's CONFIG tuple to find its configuration
750 registers.
751 */
752 tuple.Attributes = 0;
753 tuple.TupleData = (cisdata_t *) buf;
754 tuple.TupleDataMax = 64;
755 tuple.TupleOffset = 0;
756 tuple.DesiredTuple = CISTPL_CONFIG;
757 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
758 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
759 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
760 link->conf.ConfigBase = parse.config.base;
761 link->conf.Present = parse.config.rmask[0];
762
763 /*
764 * Try allocating IO ports. This tries a few fixed addresses. 746 * Try allocating IO ports. This tries a few fixed addresses.
765 * If you want, you can also read the card's config table to 747 * If you want, you can also read the card's config table to
766 * pick addresses -- see the serial driver for an example. 748 * pick addresses -- see the serial driver for an example.
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 336cabac13b3..936c888e03e1 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -980,9 +980,11 @@ static void print_linkstatus(struct net_device *dev, u16 status)
980} 980}
981 981
982/* Search scan results for requested BSSID, join it if found */ 982/* Search scan results for requested BSSID, join it if found */
983static void orinoco_join_ap(struct net_device *dev) 983static void orinoco_join_ap(struct work_struct *work)
984{ 984{
985 struct orinoco_private *priv = netdev_priv(dev); 985 struct orinoco_private *priv =
986 container_of(work, struct orinoco_private, join_work);
987 struct net_device *dev = priv->ndev;
986 struct hermes *hw = &priv->hw; 988 struct hermes *hw = &priv->hw;
987 int err; 989 int err;
988 unsigned long flags; 990 unsigned long flags;
@@ -1055,9 +1057,11 @@ static void orinoco_join_ap(struct net_device *dev)
1055} 1057}
1056 1058
1057/* Send new BSSID to userspace */ 1059/* Send new BSSID to userspace */
1058static void orinoco_send_wevents(struct net_device *dev) 1060static void orinoco_send_wevents(struct work_struct *work)
1059{ 1061{
1060 struct orinoco_private *priv = netdev_priv(dev); 1062 struct orinoco_private *priv =
1063 container_of(work, struct orinoco_private, wevent_work);
1064 struct net_device *dev = priv->ndev;
1061 struct hermes *hw = &priv->hw; 1065 struct hermes *hw = &priv->hw;
1062 union iwreq_data wrqu; 1066 union iwreq_data wrqu;
1063 int err; 1067 int err;
@@ -1864,9 +1868,11 @@ __orinoco_set_multicast_list(struct net_device *dev)
1864 1868
1865/* This must be called from user context, without locks held - use 1869/* This must be called from user context, without locks held - use
1866 * schedule_work() */ 1870 * schedule_work() */
1867static void orinoco_reset(struct net_device *dev) 1871static void orinoco_reset(struct work_struct *work)
1868{ 1872{
1869 struct orinoco_private *priv = netdev_priv(dev); 1873 struct orinoco_private *priv =
1874 container_of(work, struct orinoco_private, reset_work);
1875 struct net_device *dev = priv->ndev;
1870 struct hermes *hw = &priv->hw; 1876 struct hermes *hw = &priv->hw;
1871 int err; 1877 int err;
1872 unsigned long flags; 1878 unsigned long flags;
@@ -2434,9 +2440,9 @@ struct net_device *alloc_orinocodev(int sizeof_card,
2434 priv->hw_unavailable = 1; /* orinoco_init() must clear this 2440 priv->hw_unavailable = 1; /* orinoco_init() must clear this
2435 * before anything else touches the 2441 * before anything else touches the
2436 * hardware */ 2442 * hardware */
2437 INIT_WORK(&priv->reset_work, (void (*)(void *))orinoco_reset, dev); 2443 INIT_WORK(&priv->reset_work, orinoco_reset);
2438 INIT_WORK(&priv->join_work, (void (*)(void *))orinoco_join_ap, dev); 2444 INIT_WORK(&priv->join_work, orinoco_join_ap);
2439 INIT_WORK(&priv->wevent_work, (void (*)(void *))orinoco_send_wevents, dev); 2445 INIT_WORK(&priv->wevent_work, orinoco_send_wevents);
2440 2446
2441 netif_carrier_off(dev); 2447 netif_carrier_off(dev);
2442 priv->last_linkstatus = 0xffff; 2448 priv->last_linkstatus = 0xffff;
@@ -3608,7 +3614,7 @@ static int orinoco_ioctl_reset(struct net_device *dev,
3608 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name); 3614 printk(KERN_DEBUG "%s: Forcing reset!\n", dev->name);
3609 3615
3610 /* Firmware reset */ 3616 /* Firmware reset */
3611 orinoco_reset(dev); 3617 orinoco_reset(&priv->reset_work);
3612 } else { 3618 } else {
3613 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name); 3619 printk(KERN_DEBUG "%s: Force scheduling reset!\n", dev->name);
3614 3620
@@ -4154,7 +4160,7 @@ static int orinoco_ioctl_commit(struct net_device *dev,
4154 return 0; 4160 return 0;
4155 4161
4156 if (priv->broken_disableport) { 4162 if (priv->broken_disableport) {
4157 orinoco_reset(dev); 4163 orinoco_reset(&priv->reset_work);
4158 return 0; 4164 return 0;
4159 } 4165 }
4160 4166
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index bc14689cbf24..d08ae8d2726c 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -178,21 +178,6 @@ orinoco_cs_config(struct pcmcia_device *link)
178 cisparse_t parse; 178 cisparse_t parse;
179 void __iomem *mem; 179 void __iomem *mem;
180 180
181 /*
182 * This reads the card's CONFIG tuple to find its
183 * configuration registers.
184 */
185 tuple.DesiredTuple = CISTPL_CONFIG;
186 tuple.Attributes = 0;
187 tuple.TupleData = buf;
188 tuple.TupleDataMax = sizeof(buf);
189 tuple.TupleOffset = 0;
190 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
191 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
192 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
193 link->conf.ConfigBase = parse.config.base;
194 link->conf.Present = parse.config.rmask[0];
195
196 /* Look up the current Vcc */ 181 /* Look up the current Vcc */
197 CS_CHECK(GetConfigurationInfo, 182 CS_CHECK(GetConfigurationInfo,
198 pcmcia_get_configuration_info(link, &conf)); 183 pcmcia_get_configuration_info(link, &conf));
@@ -211,6 +196,10 @@ orinoco_cs_config(struct pcmcia_device *link)
211 * and most client drivers will only use the CIS to fill in 196 * and most client drivers will only use the CIS to fill in
212 * implementation-defined details. 197 * implementation-defined details.
213 */ 198 */
199 tuple.Attributes = 0;
200 tuple.TupleData = buf;
201 tuple.TupleDataMax = sizeof(buf);
202 tuple.TupleOffset = 0;
214 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 203 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
215 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 204 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
216 while (1) { 205 while (1) {
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index 4a20e45de3ca..a87eb51886c8 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -157,8 +157,9 @@ prism54_mib_init(islpci_private *priv)
157 * schedule_work(), thus we can as well use sleeping semaphore 157 * schedule_work(), thus we can as well use sleeping semaphore
158 * locking */ 158 * locking */
159void 159void
160prism54_update_stats(islpci_private *priv) 160prism54_update_stats(struct work_struct *work)
161{ 161{
162 islpci_private *priv = container_of(work, islpci_private, stats_work);
162 char *data; 163 char *data;
163 int j; 164 int j;
164 struct obj_bss bss, *bss2; 165 struct obj_bss bss, *bss2;
@@ -2493,9 +2494,10 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2493 * interrupt context, no locks held. 2494 * interrupt context, no locks held.
2494 */ 2495 */
2495void 2496void
2496prism54_process_trap(void *data) 2497prism54_process_trap(struct work_struct *work)
2497{ 2498{
2498 struct islpci_mgmtframe *frame = data; 2499 struct islpci_mgmtframe *frame =
2500 container_of(work, struct islpci_mgmtframe, ws);
2499 struct net_device *ndev = frame->ndev; 2501 struct net_device *ndev = frame->ndev;
2500 enum oid_num_t n = mgt_oidtonum(frame->header->oid); 2502 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2501 2503
diff --git a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h
index e8183d30c52e..bcfbfb9281d2 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.h
+++ b/drivers/net/wireless/prism54/isl_ioctl.h
@@ -31,12 +31,12 @@
31void prism54_mib_init(islpci_private *); 31void prism54_mib_init(islpci_private *);
32 32
33struct iw_statistics *prism54_get_wireless_stats(struct net_device *); 33struct iw_statistics *prism54_get_wireless_stats(struct net_device *);
34void prism54_update_stats(islpci_private *); 34void prism54_update_stats(struct work_struct *);
35 35
36void prism54_acl_init(struct islpci_acl *); 36void prism54_acl_init(struct islpci_acl *);
37void prism54_acl_clean(struct islpci_acl *); 37void prism54_acl_clean(struct islpci_acl *);
38 38
39void prism54_process_trap(void *); 39void prism54_process_trap(struct work_struct *);
40 40
41void prism54_wpa_bss_ie_init(islpci_private *priv); 41void prism54_wpa_bss_ie_init(islpci_private *priv);
42void prism54_wpa_bss_ie_clean(islpci_private *priv); 42void prism54_wpa_bss_ie_clean(islpci_private *priv);
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 1e0603ca436c..f057fd9fcd79 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -860,11 +860,10 @@ islpci_setup(struct pci_dev *pdev)
860 priv->state_off = 1; 860 priv->state_off = 1;
861 861
862 /* initialize workqueue's */ 862 /* initialize workqueue's */
863 INIT_WORK(&priv->stats_work, 863 INIT_WORK(&priv->stats_work, prism54_update_stats);
864 (void (*)(void *)) prism54_update_stats, priv);
865 priv->stats_timestamp = 0; 864 priv->stats_timestamp = 0;
866 865
867 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake, priv); 866 INIT_WORK(&priv->reset_task, islpci_do_reset_and_wake);
868 priv->reset_task_pending = 0; 867 priv->reset_task_pending = 0;
869 868
870 /* allocate various memory areas */ 869 /* allocate various memory areas */
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c
index 676d83813dc8..b1122912ee2d 100644
--- a/drivers/net/wireless/prism54/islpci_eth.c
+++ b/drivers/net/wireless/prism54/islpci_eth.c
@@ -480,9 +480,9 @@ islpci_eth_receive(islpci_private *priv)
480} 480}
481 481
482void 482void
483islpci_do_reset_and_wake(void *data) 483islpci_do_reset_and_wake(struct work_struct *work)
484{ 484{
485 islpci_private *priv = data; 485 islpci_private *priv = container_of(work, islpci_private, reset_task);
486 486
487 islpci_reset(priv, 1); 487 islpci_reset(priv, 1);
488 priv->reset_task_pending = 0; 488 priv->reset_task_pending = 0;
diff --git a/drivers/net/wireless/prism54/islpci_eth.h b/drivers/net/wireless/prism54/islpci_eth.h
index 26789454067c..5bf820defbd0 100644
--- a/drivers/net/wireless/prism54/islpci_eth.h
+++ b/drivers/net/wireless/prism54/islpci_eth.h
@@ -67,6 +67,6 @@ void islpci_eth_cleanup_transmit(islpci_private *, isl38xx_control_block *);
67int islpci_eth_transmit(struct sk_buff *, struct net_device *); 67int islpci_eth_transmit(struct sk_buff *, struct net_device *);
68int islpci_eth_receive(islpci_private *); 68int islpci_eth_receive(islpci_private *);
69void islpci_eth_tx_timeout(struct net_device *); 69void islpci_eth_tx_timeout(struct net_device *);
70void islpci_do_reset_and_wake(void *data); 70void islpci_do_reset_and_wake(struct work_struct *);
71 71
72#endif /* _ISL_GEN_H */ 72#endif /* _ISL_GEN_H */
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 036a875054c9..2246f7930b4e 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -386,7 +386,7 @@ islpci_mgt_receive(struct net_device *ndev)
386 386
387 /* Create work to handle trap out of interrupt 387 /* Create work to handle trap out of interrupt
388 * context. */ 388 * context. */
389 INIT_WORK(&frame->ws, prism54_process_trap, frame); 389 INIT_WORK(&frame->ws, prism54_process_trap);
390 schedule_work(&frame->ws); 390 schedule_work(&frame->ws);
391 391
392 } else { 392 } else {
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 7fbfc9e41d07..88e10c9bc4ac 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -408,11 +408,8 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
408#define MAX_TUPLE_SIZE 128 408#define MAX_TUPLE_SIZE 128
409static int ray_config(struct pcmcia_device *link) 409static int ray_config(struct pcmcia_device *link)
410{ 410{
411 tuple_t tuple;
412 cisparse_t parse;
413 int last_fn = 0, last_ret = 0; 411 int last_fn = 0, last_ret = 0;
414 int i; 412 int i;
415 u_char buf[MAX_TUPLE_SIZE];
416 win_req_t req; 413 win_req_t req;
417 memreq_t mem; 414 memreq_t mem;
418 struct net_device *dev = (struct net_device *)link->priv; 415 struct net_device *dev = (struct net_device *)link->priv;
@@ -420,29 +417,12 @@ static int ray_config(struct pcmcia_device *link)
420 417
421 DEBUG(1, "ray_config(0x%p)\n", link); 418 DEBUG(1, "ray_config(0x%p)\n", link);
422 419
423 /* This reads the card's CONFIG tuple to find its configuration regs */
424 tuple.DesiredTuple = CISTPL_CONFIG;
425 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
426 tuple.TupleData = buf;
427 tuple.TupleDataMax = MAX_TUPLE_SIZE;
428 tuple.TupleOffset = 0;
429 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
430 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
431 link->conf.ConfigBase = parse.config.base;
432 link->conf.Present = parse.config.rmask[0];
433
434 /* Determine card type and firmware version */ 420 /* Determine card type and firmware version */
435 buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; 421 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
436 tuple.DesiredTuple = CISTPL_VERS_1; 422 link->prod_id[0] ? link->prod_id[0] : " ",
437 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 423 link->prod_id[1] ? link->prod_id[1] : " ",
438 tuple.TupleData = buf; 424 link->prod_id[2] ? link->prod_id[2] : " ",
439 tuple.TupleDataMax = MAX_TUPLE_SIZE; 425 link->prod_id[3] ? link->prod_id[3] : " ");
440 tuple.TupleOffset = 2;
441 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
442
443 for (i=0; i<tuple.TupleDataLen - 4; i++)
444 if (buf[i] == 0) buf[i] = ' ';
445 printk(KERN_INFO "ray_cs Detected: %s\n",buf);
446 426
447 /* Now allocate an interrupt line. Note that this does not 427 /* Now allocate an interrupt line. Note that this does not
448 actually assign a handler to the interrupt. 428 actually assign a handler to the interrupt.
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index bcc7038130f6..cf2d1486b01d 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -647,21 +647,6 @@ spectrum_cs_config(struct pcmcia_device *link)
647 cisparse_t parse; 647 cisparse_t parse;
648 void __iomem *mem; 648 void __iomem *mem;
649 649
650 /*
651 * This reads the card's CONFIG tuple to find its
652 * configuration registers.
653 */
654 tuple.DesiredTuple = CISTPL_CONFIG;
655 tuple.Attributes = 0;
656 tuple.TupleData = buf;
657 tuple.TupleDataMax = sizeof(buf);
658 tuple.TupleOffset = 0;
659 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
660 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
661 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
662 link->conf.ConfigBase = parse.config.base;
663 link->conf.Present = parse.config.rmask[0];
664
665 /* Look up the current Vcc */ 650 /* Look up the current Vcc */
666 CS_CHECK(GetConfigurationInfo, 651 CS_CHECK(GetConfigurationInfo,
667 pcmcia_get_configuration_info(link, &conf)); 652 pcmcia_get_configuration_info(link, &conf));
@@ -681,6 +666,10 @@ spectrum_cs_config(struct pcmcia_device *link)
681 * implementation-defined details. 666 * implementation-defined details.
682 */ 667 */
683 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 668 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
669 tuple.Attributes = 0;
670 tuple.TupleData = buf;
671 tuple.TupleDataMax = sizeof(buf);
672 tuple.TupleOffset = 0;
684 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 673 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
685 while (1) { 674 while (1) {
686 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 675 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index aafb301041b1..233d906c08f0 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -3939,11 +3939,8 @@ wv_hw_reset(struct net_device * dev)
3939static inline int 3939static inline int
3940wv_pcmcia_config(struct pcmcia_device * link) 3940wv_pcmcia_config(struct pcmcia_device * link)
3941{ 3941{
3942 tuple_t tuple;
3943 cisparse_t parse;
3944 struct net_device * dev = (struct net_device *) link->priv; 3942 struct net_device * dev = (struct net_device *) link->priv;
3945 int i; 3943 int i;
3946 u_char buf[64];
3947 win_req_t req; 3944 win_req_t req;
3948 memreq_t mem; 3945 memreq_t mem;
3949 net_local * lp = netdev_priv(dev); 3946 net_local * lp = netdev_priv(dev);
@@ -3953,36 +3950,6 @@ wv_pcmcia_config(struct pcmcia_device * link)
3953 printk(KERN_DEBUG "->wv_pcmcia_config(0x%p)\n", link); 3950 printk(KERN_DEBUG "->wv_pcmcia_config(0x%p)\n", link);
3954#endif 3951#endif
3955 3952
3956 /*
3957 * This reads the card's CONFIG tuple to find its configuration
3958 * registers.
3959 */
3960 do
3961 {
3962 tuple.Attributes = 0;
3963 tuple.DesiredTuple = CISTPL_CONFIG;
3964 i = pcmcia_get_first_tuple(link, &tuple);
3965 if(i != CS_SUCCESS)
3966 break;
3967 tuple.TupleData = (cisdata_t *)buf;
3968 tuple.TupleDataMax = 64;
3969 tuple.TupleOffset = 0;
3970 i = pcmcia_get_tuple_data(link, &tuple);
3971 if(i != CS_SUCCESS)
3972 break;
3973 i = pcmcia_parse_tuple(link, &tuple, &parse);
3974 if(i != CS_SUCCESS)
3975 break;
3976 link->conf.ConfigBase = parse.config.base;
3977 link->conf.Present = parse.config.rmask[0];
3978 }
3979 while(0);
3980 if(i != CS_SUCCESS)
3981 {
3982 cs_error(link, ParseTuple, i);
3983 return FALSE;
3984 }
3985
3986 do 3953 do
3987 { 3954 {
3988 i = pcmcia_request_io(link, &link->io); 3955 i = pcmcia_request_io(link, &link->io);
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 5b98a7876982..583e0d655a98 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1966,25 +1966,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
1966 */ 1966 */
1967static int wl3501_config(struct pcmcia_device *link) 1967static int wl3501_config(struct pcmcia_device *link)
1968{ 1968{
1969 tuple_t tuple;
1970 cisparse_t parse;
1971 struct net_device *dev = link->priv; 1969 struct net_device *dev = link->priv;
1972 int i = 0, j, last_fn, last_ret; 1970 int i = 0, j, last_fn, last_ret;
1973 unsigned char bf[64];
1974 struct wl3501_card *this; 1971 struct wl3501_card *this;
1975 1972
1976 /* This reads the card's CONFIG tuple to find its config registers. */
1977 tuple.Attributes = 0;
1978 tuple.DesiredTuple = CISTPL_CONFIG;
1979 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
1980 tuple.TupleData = bf;
1981 tuple.TupleDataMax = sizeof(bf);
1982 tuple.TupleOffset = 0;
1983 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
1984 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
1985 link->conf.ConfigBase = parse.config.base;
1986 link->conf.Present = parse.config.rmask[0];
1987
1988 /* Try allocating IO ports. This tries a few fixed addresses. If you 1973 /* Try allocating IO ports. This tries a few fixed addresses. If you
1989 * want, you can also read the card's config table to pick addresses -- 1974 * want, you can also read the card's config table to pick addresses --
1990 * see the serial driver for an example. */ 1975 * see the serial driver for an example. */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 2696f95b9278..f1573a9c2336 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -32,8 +32,8 @@
32 32
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35static void set_rts_cts_work(void *d); 35static void set_rts_cts_work(struct work_struct *work);
36static void set_basic_rates_work(void *d); 36static void set_basic_rates_work(struct work_struct *work);
37 37
38static void housekeeping_init(struct zd_mac *mac); 38static void housekeeping_init(struct zd_mac *mac);
39static void housekeeping_enable(struct zd_mac *mac); 39static void housekeeping_enable(struct zd_mac *mac);
@@ -48,8 +48,8 @@ int zd_mac_init(struct zd_mac *mac,
48 memset(mac, 0, sizeof(*mac)); 48 memset(mac, 0, sizeof(*mac));
49 spin_lock_init(&mac->lock); 49 spin_lock_init(&mac->lock);
50 mac->netdev = netdev; 50 mac->netdev = netdev;
51 INIT_WORK(&mac->set_rts_cts_work, set_rts_cts_work, mac); 51 INIT_DELAYED_WORK(&mac->set_rts_cts_work, set_rts_cts_work);
52 INIT_WORK(&mac->set_basic_rates_work, set_basic_rates_work, mac); 52 INIT_DELAYED_WORK(&mac->set_basic_rates_work, set_basic_rates_work);
53 53
54 ieee_init(ieee); 54 ieee_init(ieee);
55 softmac_init(ieee80211_priv(netdev)); 55 softmac_init(ieee80211_priv(netdev));
@@ -366,9 +366,10 @@ static void try_enable_tx(struct zd_mac *mac)
366 spin_unlock_irqrestore(&mac->lock, flags); 366 spin_unlock_irqrestore(&mac->lock, flags);
367} 367}
368 368
369static void set_rts_cts_work(void *d) 369static void set_rts_cts_work(struct work_struct *work)
370{ 370{
371 struct zd_mac *mac = d; 371 struct zd_mac *mac =
372 container_of(work, struct zd_mac, set_rts_cts_work.work);
372 unsigned long flags; 373 unsigned long flags;
373 u8 rts_rate; 374 u8 rts_rate;
374 unsigned int short_preamble; 375 unsigned int short_preamble;
@@ -387,9 +388,10 @@ static void set_rts_cts_work(void *d)
387 try_enable_tx(mac); 388 try_enable_tx(mac);
388} 389}
389 390
390static void set_basic_rates_work(void *d) 391static void set_basic_rates_work(struct work_struct *work)
391{ 392{
392 struct zd_mac *mac = d; 393 struct zd_mac *mac =
394 container_of(work, struct zd_mac, set_basic_rates_work.work);
393 unsigned long flags; 395 unsigned long flags;
394 u16 basic_rates; 396 u16 basic_rates;
395 397
@@ -467,12 +469,13 @@ static void bssinfo_change(struct net_device *netdev, u32 changes)
467 if (need_set_rts_cts && !mac->updating_rts_rate) { 469 if (need_set_rts_cts && !mac->updating_rts_rate) {
468 mac->updating_rts_rate = 1; 470 mac->updating_rts_rate = 1;
469 netif_stop_queue(mac->netdev); 471 netif_stop_queue(mac->netdev);
470 queue_work(zd_workqueue, &mac->set_rts_cts_work); 472 queue_delayed_work(zd_workqueue, &mac->set_rts_cts_work, 0);
471 } 473 }
472 if (need_set_rates && !mac->updating_basic_rates) { 474 if (need_set_rates && !mac->updating_basic_rates) {
473 mac->updating_basic_rates = 1; 475 mac->updating_basic_rates = 1;
474 netif_stop_queue(mac->netdev); 476 netif_stop_queue(mac->netdev);
475 queue_work(zd_workqueue, &mac->set_basic_rates_work); 477 queue_delayed_work(zd_workqueue, &mac->set_basic_rates_work,
478 0);
476 } 479 }
477 spin_unlock_irqrestore(&mac->lock, flags); 480 spin_unlock_irqrestore(&mac->lock, flags);
478} 481}
@@ -1182,9 +1185,10 @@ struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
1182 1185
1183#define LINK_LED_WORK_DELAY HZ 1186#define LINK_LED_WORK_DELAY HZ
1184 1187
1185static void link_led_handler(void *p) 1188static void link_led_handler(struct work_struct *work)
1186{ 1189{
1187 struct zd_mac *mac = p; 1190 struct zd_mac *mac =
1191 container_of(work, struct zd_mac, housekeeping.link_led_work.work);
1188 struct zd_chip *chip = &mac->chip; 1192 struct zd_chip *chip = &mac->chip;
1189 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev); 1193 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev);
1190 int is_associated; 1194 int is_associated;
@@ -1205,7 +1209,7 @@ static void link_led_handler(void *p)
1205 1209
1206static void housekeeping_init(struct zd_mac *mac) 1210static void housekeeping_init(struct zd_mac *mac)
1207{ 1211{
1208 INIT_WORK(&mac->housekeeping.link_led_work, link_led_handler, mac); 1212 INIT_DELAYED_WORK(&mac->housekeeping.link_led_work, link_led_handler);
1209} 1213}
1210 1214
1211static void housekeeping_enable(struct zd_mac *mac) 1215static void housekeeping_enable(struct zd_mac *mac)
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 5dcfb251f02e..d4e8b870409d 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -119,7 +119,7 @@ struct rx_status {
119#define ZD_RX_ERROR 0x80 119#define ZD_RX_ERROR 0x80
120 120
121struct housekeeping { 121struct housekeeping {
122 struct work_struct link_led_work; 122 struct delayed_work link_led_work;
123}; 123};
124 124
125#define ZD_MAC_STATS_BUFFER_SIZE 16 125#define ZD_MAC_STATS_BUFFER_SIZE 16
@@ -133,8 +133,8 @@ struct zd_mac {
133 struct iw_statistics iw_stats; 133 struct iw_statistics iw_stats;
134 134
135 struct housekeeping housekeeping; 135 struct housekeeping housekeeping;
136 struct work_struct set_rts_cts_work; 136 struct delayed_work set_rts_cts_work;
137 struct work_struct set_basic_rates_work; 137 struct delayed_work set_basic_rates_work;
138 138
139 unsigned int stats_count; 139 unsigned int stats_count;
140 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 140 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index fc4bc9b94c74..a83c3db7d18f 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -29,7 +29,7 @@
29 29
30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned; 30struct oprofile_cpu_buffer cpu_buffer[NR_CPUS] __cacheline_aligned;
31 31
32static void wq_sync_buffer(void *); 32static void wq_sync_buffer(struct work_struct *work);
33 33
34#define DEFAULT_TIMER_EXPIRE (HZ / 10) 34#define DEFAULT_TIMER_EXPIRE (HZ / 10)
35static int work_enabled; 35static int work_enabled;
@@ -65,7 +65,7 @@ int alloc_cpu_buffers(void)
65 b->sample_received = 0; 65 b->sample_received = 0;
66 b->sample_lost_overflow = 0; 66 b->sample_lost_overflow = 0;
67 b->cpu = i; 67 b->cpu = i;
68 INIT_WORK(&b->work, wq_sync_buffer, b); 68 INIT_DELAYED_WORK(&b->work, wq_sync_buffer);
69 } 69 }
70 return 0; 70 return 0;
71 71
@@ -282,9 +282,10 @@ void oprofile_add_trace(unsigned long pc)
282 * By using schedule_delayed_work_on and then schedule_delayed_work 282 * By using schedule_delayed_work_on and then schedule_delayed_work
283 * we guarantee this will stay on the correct cpu 283 * we guarantee this will stay on the correct cpu
284 */ 284 */
285static void wq_sync_buffer(void * data) 285static void wq_sync_buffer(struct work_struct *work)
286{ 286{
287 struct oprofile_cpu_buffer * b = data; 287 struct oprofile_cpu_buffer * b =
288 container_of(work, struct oprofile_cpu_buffer, work.work);
288 if (b->cpu != smp_processor_id()) { 289 if (b->cpu != smp_processor_id()) {
289 printk("WQ on CPU%d, prefer CPU%d\n", 290 printk("WQ on CPU%d, prefer CPU%d\n",
290 smp_processor_id(), b->cpu); 291 smp_processor_id(), b->cpu);
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 09abb80e0570..49900d9e3235 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -43,7 +43,7 @@ struct oprofile_cpu_buffer {
43 unsigned long sample_lost_overflow; 43 unsigned long sample_lost_overflow;
44 unsigned long backtrace_aborted; 44 unsigned long backtrace_aborted;
45 int cpu; 45 int cpu;
46 struct work_struct work; 46 struct delayed_work work;
47} ____cacheline_aligned; 47} ____cacheline_aligned;
48 48
49extern struct oprofile_cpu_buffer cpu_buffer[]; 49extern struct oprofile_cpu_buffer cpu_buffer[];
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index b953d5907c05..e60b4bf6bae8 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -166,14 +166,6 @@ static int parport_config(struct pcmcia_device *link)
166 166
167 tuple.TupleData = (cisdata_t *)buf; 167 tuple.TupleData = (cisdata_t *)buf;
168 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 168 tuple.TupleOffset = 0; tuple.TupleDataMax = 255;
169 tuple.Attributes = 0;
170 tuple.DesiredTuple = CISTPL_CONFIG;
171 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
172 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
173 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
174 link->conf.ConfigBase = parse.config.base;
175 link->conf.Present = parse.config.rmask[0];
176
177 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 169 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
178 tuple.Attributes = 0; 170 tuple.Attributes = 0;
179 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 171 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
@@ -263,6 +255,7 @@ void parport_cs_release(struct pcmcia_device *link)
263 255
264static struct pcmcia_device_id parport_ids[] = { 256static struct pcmcia_device_id parport_ids[] = {
265 PCMCIA_DEVICE_FUNC_ID(3), 257 PCMCIA_DEVICE_FUNC_ID(3),
258 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial+Parallel Port: SP230",0x3beb8cf2,0xdb9e58bc),
266 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), 259 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003),
267 PCMCIA_DEVICE_NULL 260 PCMCIA_DEVICE_NULL
268}; 261};
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index ea2087c34149..50757695844f 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -70,7 +70,7 @@ struct slot {
70 struct hotplug_slot *hotplug_slot; 70 struct hotplug_slot *hotplug_slot;
71 struct list_head slot_list; 71 struct list_head slot_list;
72 char name[SLOT_NAME_SIZE]; 72 char name[SLOT_NAME_SIZE];
73 struct work_struct work; /* work for button event */ 73 struct delayed_work work; /* work for button event */
74 struct mutex lock; 74 struct mutex lock;
75}; 75};
76 76
@@ -187,7 +187,7 @@ extern int shpchp_configure_device(struct slot *p_slot);
187extern int shpchp_unconfigure_device(struct slot *p_slot); 187extern int shpchp_unconfigure_device(struct slot *p_slot);
188extern void shpchp_remove_ctrl_files(struct controller *ctrl); 188extern void shpchp_remove_ctrl_files(struct controller *ctrl);
189extern void cleanup_slots(struct controller *ctrl); 189extern void cleanup_slots(struct controller *ctrl);
190extern void queue_pushbutton_work(void *data); 190extern void queue_pushbutton_work(struct work_struct *work);
191 191
192 192
193#ifdef CONFIG_ACPI 193#ifdef CONFIG_ACPI
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 235c18a22393..4eac85b3d90e 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -159,7 +159,7 @@ static int init_slots(struct controller *ctrl)
159 goto error_info; 159 goto error_info;
160 160
161 slot->number = sun; 161 slot->number = sun;
162 INIT_WORK(&slot->work, queue_pushbutton_work, slot); 162 INIT_DELAYED_WORK(&slot->work, queue_pushbutton_work);
163 163
164 /* register this slot with the hotplug pci core */ 164 /* register this slot with the hotplug pci core */
165 hotplug_slot->private = slot; 165 hotplug_slot->private = slot;
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index c39901dbff20..158ac7836096 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -36,7 +36,7 @@
36#include "../pci.h" 36#include "../pci.h"
37#include "shpchp.h" 37#include "shpchp.h"
38 38
39static void interrupt_event_handler(void *data); 39static void interrupt_event_handler(struct work_struct *work);
40static int shpchp_enable_slot(struct slot *p_slot); 40static int shpchp_enable_slot(struct slot *p_slot);
41static int shpchp_disable_slot(struct slot *p_slot); 41static int shpchp_disable_slot(struct slot *p_slot);
42 42
@@ -50,7 +50,7 @@ static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
50 50
51 info->event_type = event_type; 51 info->event_type = event_type;
52 info->p_slot = p_slot; 52 info->p_slot = p_slot;
53 INIT_WORK(&info->work, interrupt_event_handler, info); 53 INIT_WORK(&info->work, interrupt_event_handler);
54 54
55 schedule_work(&info->work); 55 schedule_work(&info->work);
56 56
@@ -408,9 +408,10 @@ struct pushbutton_work_info {
408 * Handles all pending events and exits. 408 * Handles all pending events and exits.
409 * 409 *
410 */ 410 */
411static void shpchp_pushbutton_thread(void *data) 411static void shpchp_pushbutton_thread(struct work_struct *work)
412{ 412{
413 struct pushbutton_work_info *info = data; 413 struct pushbutton_work_info *info =
414 container_of(work, struct pushbutton_work_info, work);
414 struct slot *p_slot = info->p_slot; 415 struct slot *p_slot = info->p_slot;
415 416
416 mutex_lock(&p_slot->lock); 417 mutex_lock(&p_slot->lock);
@@ -436,9 +437,9 @@ static void shpchp_pushbutton_thread(void *data)
436 kfree(info); 437 kfree(info);
437} 438}
438 439
439void queue_pushbutton_work(void *data) 440void queue_pushbutton_work(struct work_struct *work)
440{ 441{
441 struct slot *p_slot = data; 442 struct slot *p_slot = container_of(work, struct slot, work.work);
442 struct pushbutton_work_info *info; 443 struct pushbutton_work_info *info;
443 444
444 info = kmalloc(sizeof(*info), GFP_KERNEL); 445 info = kmalloc(sizeof(*info), GFP_KERNEL);
@@ -447,7 +448,7 @@ void queue_pushbutton_work(void *data)
447 return; 448 return;
448 } 449 }
449 info->p_slot = p_slot; 450 info->p_slot = p_slot;
450 INIT_WORK(&info->work, shpchp_pushbutton_thread, info); 451 INIT_WORK(&info->work, shpchp_pushbutton_thread);
451 452
452 mutex_lock(&p_slot->lock); 453 mutex_lock(&p_slot->lock);
453 switch (p_slot->state) { 454 switch (p_slot->state) {
@@ -541,9 +542,9 @@ static void handle_button_press_event(struct slot *p_slot)
541 } 542 }
542} 543}
543 544
544static void interrupt_event_handler(void *data) 545static void interrupt_event_handler(struct work_struct *work)
545{ 546{
546 struct event_info *info = data; 547 struct event_info *info = container_of(work, struct event_info, work);
547 struct slot *p_slot = info->p_slot; 548 struct slot *p_slot = info->p_slot;
548 549
549 mutex_lock(&p_slot->lock); 550 mutex_lock(&p_slot->lock);
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
index 04c43ef529ac..55866b6b26fa 100644
--- a/drivers/pci/pcie/aer/aerdrv.c
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -160,7 +160,7 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
160 rpc->e_lock = SPIN_LOCK_UNLOCKED; 160 rpc->e_lock = SPIN_LOCK_UNLOCKED;
161 161
162 rpc->rpd = dev; 162 rpc->rpd = dev;
163 INIT_WORK(&rpc->dpc_handler, aer_isr, (void *)dev); 163 INIT_WORK(&rpc->dpc_handler, aer_isr);
164 rpc->prod_idx = rpc->cons_idx = 0; 164 rpc->prod_idx = rpc->cons_idx = 0;
165 mutex_init(&rpc->rpc_mutex); 165 mutex_init(&rpc->rpc_mutex);
166 init_waitqueue_head(&rpc->wait_release); 166 init_waitqueue_head(&rpc->wait_release);
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
index daf0cad88fc8..3c0a58f64dd8 100644
--- a/drivers/pci/pcie/aer/aerdrv.h
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -118,7 +118,7 @@ extern struct bus_type pcie_port_bus_type;
118extern void aer_enable_rootport(struct aer_rpc *rpc); 118extern void aer_enable_rootport(struct aer_rpc *rpc);
119extern void aer_delete_rootport(struct aer_rpc *rpc); 119extern void aer_delete_rootport(struct aer_rpc *rpc);
120extern int aer_init(struct pcie_device *dev); 120extern int aer_init(struct pcie_device *dev);
121extern void aer_isr(void *context); 121extern void aer_isr(struct work_struct *work);
122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info); 122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
123extern int aer_osc_setup(struct pci_dev *dev); 123extern int aer_osc_setup(struct pci_dev *dev);
124 124
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 1c7e660d6535..08e13033ced8 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -690,14 +690,14 @@ static void aer_isr_one_error(struct pcie_device *p_device,
690 690
691/** 691/**
692 * aer_isr - consume errors detected by root port 692 * aer_isr - consume errors detected by root port
693 * @context: pointer to a private data of pcie device 693 * @work: definition of this work item
694 * 694 *
695 * Invoked, as DPC, when root port records new detected error 695 * Invoked, as DPC, when root port records new detected error
696 **/ 696 **/
697void aer_isr(void *context) 697void aer_isr(struct work_struct *work)
698{ 698{
699 struct pcie_device *p_device = (struct pcie_device *) context; 699 struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
700 struct aer_rpc *rpc = get_service_data(p_device); 700 struct pcie_device *p_device = rpc->rpd;
701 struct aer_err_source *e_src; 701 struct aer_err_source *e_src;
702 702
703 mutex_lock(&rpc->rpc_mutex); 703 mutex_lock(&rpc->rpc_mutex);
diff --git a/drivers/pcmcia/at91_cf.c b/drivers/pcmcia/at91_cf.c
index 3bcb7dc32995..b6746301d9a9 100644
--- a/drivers/pcmcia/at91_cf.c
+++ b/drivers/pcmcia/at91_cf.c
@@ -32,10 +32,11 @@
32 * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW; 32 * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW;
33 * some other bit in {A24,A22..A11} is nREG to flag memory access 33 * some other bit in {A24,A22..A11} is nREG to flag memory access
34 * (vs attributes). So more than 2KB/region would just be waste. 34 * (vs attributes). So more than 2KB/region would just be waste.
35 * Note: These are offsets from the physical base address.
35 */ 36 */
36#define CF_ATTR_PHYS (AT91_CF_BASE) 37#define CF_ATTR_PHYS (0)
37#define CF_IO_PHYS (AT91_CF_BASE + (1 << 23)) 38#define CF_IO_PHYS (1 << 23)
38#define CF_MEM_PHYS (AT91_CF_BASE + 0x017ff800) 39#define CF_MEM_PHYS (0x017ff800)
39 40
40/*--------------------------------------------------------------------------*/ 41/*--------------------------------------------------------------------------*/
41 42
@@ -48,6 +49,8 @@ struct at91_cf_socket {
48 49
49 struct platform_device *pdev; 50 struct platform_device *pdev;
50 struct at91_cf_data *board; 51 struct at91_cf_data *board;
52
53 unsigned long phys_baseaddr;
51}; 54};
52 55
53#define SZ_2K (2 * SZ_1K) 56#define SZ_2K (2 * SZ_1K)
@@ -154,9 +157,8 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
154 157
155 /* 158 /*
156 * Use 16 bit accesses unless/until we need 8-bit i/o space. 159 * Use 16 bit accesses unless/until we need 8-bit i/o space.
157 * Always set CSR4 ... PCMCIA won't always unmap things.
158 */ 160 */
159 csr = at91_sys_read(AT91_SMC_CSR(4)) & ~AT91_SMC_DBW; 161 csr = at91_sys_read(AT91_SMC_CSR(cf->board->chipselect)) & ~AT91_SMC_DBW;
160 162
161 /* 163 /*
162 * NOTE: this CF controller ignores IOIS16, so we can't really do 164 * NOTE: this CF controller ignores IOIS16, so we can't really do
@@ -168,14 +170,14 @@ static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
168 * some cards only like that way to get at the odd byte, despite 170 * some cards only like that way to get at the odd byte, despite
169 * CF 3.0 spec table 35 also giving the D8-D15 option. 171 * CF 3.0 spec table 35 also giving the D8-D15 option.
170 */ 172 */
171 if (!(io->flags & (MAP_16BIT|MAP_AUTOSZ))) { 173 if (!(io->flags & (MAP_16BIT | MAP_AUTOSZ))) {
172 csr |= AT91_SMC_DBW_8; 174 csr |= AT91_SMC_DBW_8;
173 pr_debug("%s: 8bit i/o bus\n", driver_name); 175 pr_debug("%s: 8bit i/o bus\n", driver_name);
174 } else { 176 } else {
175 csr |= AT91_SMC_DBW_16; 177 csr |= AT91_SMC_DBW_16;
176 pr_debug("%s: 16bit i/o bus\n", driver_name); 178 pr_debug("%s: 16bit i/o bus\n", driver_name);
177 } 179 }
178 at91_sys_write(AT91_SMC_CSR(4), csr); 180 at91_sys_write(AT91_SMC_CSR(cf->board->chipselect), csr);
179 181
180 io->start = cf->socket.io_offset; 182 io->start = cf->socket.io_offset;
181 io->stop = io->start + SZ_2K - 1; 183 io->stop = io->start + SZ_2K - 1;
@@ -194,11 +196,11 @@ at91_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
194 196
195 cf = container_of(s, struct at91_cf_socket, socket); 197 cf = container_of(s, struct at91_cf_socket, socket);
196 198
197 map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; 199 map->flags &= (MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT);
198 if (map->flags & MAP_ATTRIB) 200 if (map->flags & MAP_ATTRIB)
199 map->static_start = CF_ATTR_PHYS; 201 map->static_start = cf->phys_baseaddr + CF_ATTR_PHYS;
200 else 202 else
201 map->static_start = CF_MEM_PHYS; 203 map->static_start = cf->phys_baseaddr + CF_MEM_PHYS;
202 204
203 return 0; 205 return 0;
204} 206}
@@ -219,7 +221,6 @@ static int __init at91_cf_probe(struct platform_device *pdev)
219 struct at91_cf_socket *cf; 221 struct at91_cf_socket *cf;
220 struct at91_cf_data *board = pdev->dev.platform_data; 222 struct at91_cf_data *board = pdev->dev.platform_data;
221 struct resource *io; 223 struct resource *io;
222 unsigned int csa;
223 int status; 224 int status;
224 225
225 if (!board || !board->det_pin || !board->rst_pin) 226 if (!board || !board->det_pin || !board->rst_pin)
@@ -235,33 +236,11 @@ static int __init at91_cf_probe(struct platform_device *pdev)
235 236
236 cf->board = board; 237 cf->board = board;
237 cf->pdev = pdev; 238 cf->pdev = pdev;
239 cf->phys_baseaddr = io->start;
238 platform_set_drvdata(pdev, cf); 240 platform_set_drvdata(pdev, cf);
239 241
240 /* CF takes over CS4, CS5, CS6 */
241 csa = at91_sys_read(AT91_EBI_CSA);
242 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
243
244 /* nWAIT is _not_ a default setting */
245 (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */
246
247 /*
248 * Static memory controller timing adjustments.
249 * REVISIT: these timings are in terms of MCK cycles, so
250 * when MCK changes (cpufreq etc) so must these values...
251 */
252 at91_sys_write(AT91_SMC_CSR(4),
253 AT91_SMC_ACSS_STD
254 | AT91_SMC_DBW_16
255 | AT91_SMC_BAT
256 | AT91_SMC_WSEN
257 | AT91_SMC_NWS_(32) /* wait states */
258 | AT91_SMC_RWSETUP_(6) /* setup time */
259 | AT91_SMC_RWHOLD_(4) /* hold time */
260 );
261
262 /* must be a GPIO; ergo must trigger on both edges */ 242 /* must be a GPIO; ergo must trigger on both edges */
263 status = request_irq(board->det_pin, at91_cf_irq, 243 status = request_irq(board->det_pin, at91_cf_irq, 0, driver_name, cf);
264 IRQF_SAMPLE_RANDOM, driver_name, cf);
265 if (status < 0) 244 if (status < 0)
266 goto fail0; 245 goto fail0;
267 device_init_wakeup(&pdev->dev, 1); 246 device_init_wakeup(&pdev->dev, 1);
@@ -282,14 +261,18 @@ static int __init at91_cf_probe(struct platform_device *pdev)
282 cf->socket.pci_irq = NR_IRQS + 1; 261 cf->socket.pci_irq = NR_IRQS + 1;
283 262
284 /* pcmcia layer only remaps "real" memory not iospace */ 263 /* pcmcia layer only remaps "real" memory not iospace */
285 cf->socket.io_offset = (unsigned long) ioremap(CF_IO_PHYS, SZ_2K); 264 cf->socket.io_offset = (unsigned long) ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
286 if (!cf->socket.io_offset) 265 if (!cf->socket.io_offset) {
266 status = -ENXIO;
287 goto fail1; 267 goto fail1;
268 }
288 269
289 /* reserve CS4, CS5, and CS6 regions; but use just CS4 */ 270 /* reserve chip-select regions */
290 if (!request_mem_region(io->start, io->end + 1 - io->start, 271 if (!request_mem_region(io->start, io->end + 1 - io->start,
291 driver_name)) 272 driver_name)) {
273 status = -ENXIO;
292 goto fail1; 274 goto fail1;
275 }
293 276
294 pr_info("%s: irqs det #%d, io #%d\n", driver_name, 277 pr_info("%s: irqs det #%d, io #%d\n", driver_name,
295 board->det_pin, board->irq_pin); 278 board->det_pin, board->irq_pin);
@@ -319,9 +302,7 @@ fail1:
319fail0a: 302fail0a:
320 device_init_wakeup(&pdev->dev, 0); 303 device_init_wakeup(&pdev->dev, 0);
321 free_irq(board->det_pin, cf); 304 free_irq(board->det_pin, cf);
322 device_init_wakeup(&pdev->dev, 0);
323fail0: 305fail0:
324 at91_sys_write(AT91_EBI_CSA, csa);
325 kfree(cf); 306 kfree(cf);
326 return status; 307 return status;
327} 308}
@@ -331,19 +312,15 @@ static int __exit at91_cf_remove(struct platform_device *pdev)
331 struct at91_cf_socket *cf = platform_get_drvdata(pdev); 312 struct at91_cf_socket *cf = platform_get_drvdata(pdev);
332 struct at91_cf_data *board = cf->board; 313 struct at91_cf_data *board = cf->board;
333 struct resource *io = cf->socket.io[0].res; 314 struct resource *io = cf->socket.io[0].res;
334 unsigned int csa;
335 315
336 pcmcia_unregister_socket(&cf->socket); 316 pcmcia_unregister_socket(&cf->socket);
337 if (board->irq_pin) 317 if (board->irq_pin)
338 free_irq(board->irq_pin, cf); 318 free_irq(board->irq_pin, cf);
339 free_irq(board->det_pin, cf);
340 device_init_wakeup(&pdev->dev, 0); 319 device_init_wakeup(&pdev->dev, 0);
320 free_irq(board->det_pin, cf);
341 iounmap((void __iomem *) cf->socket.io_offset); 321 iounmap((void __iomem *) cf->socket.io_offset);
342 release_mem_region(io->start, io->end + 1 - io->start); 322 release_mem_region(io->start, io->end + 1 - io->start);
343 323
344 csa = at91_sys_read(AT91_EBI_CSA);
345 at91_sys_write(AT91_EBI_CSA, csa & ~AT91_EBI_CS4A);
346
347 kfree(cf); 324 kfree(cf);
348 return 0; 325 return 0;
349} 326}
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index d6164cd583fd..f573ea04db6f 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -135,7 +135,7 @@ int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_s
135struct pcmcia_callback{ 135struct pcmcia_callback{
136 struct module *owner; 136 struct module *owner;
137 int (*event) (struct pcmcia_socket *s, event_t event, int priority); 137 int (*event) (struct pcmcia_socket *s, event_t event, int priority);
138 void (*requery) (struct pcmcia_socket *s); 138 void (*requery) (struct pcmcia_socket *s, int new_cis);
139 int (*suspend) (struct pcmcia_socket *s); 139 int (*suspend) (struct pcmcia_socket *s);
140 int (*resume) (struct pcmcia_socket *s); 140 int (*resume) (struct pcmcia_socket *s);
141}; 141};
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 21d83a895b21..7355eb455a88 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -231,65 +231,6 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
231} 231}
232 232
233 233
234#ifdef CONFIG_PCMCIA_LOAD_CIS
235
236/**
237 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
238 * @dev - the pcmcia device which needs a CIS override
239 * @filename - requested filename in /lib/firmware/
240 *
241 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
242 * the one provided by the card is broken. The firmware files reside in
243 * /lib/firmware/ in userspace.
244 */
245static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
246{
247 struct pcmcia_socket *s = dev->socket;
248 const struct firmware *fw;
249 char path[20];
250 int ret=-ENOMEM;
251 cisdump_t *cis;
252
253 if (!filename)
254 return -EINVAL;
255
256 ds_dbg(1, "trying to load firmware %s\n", filename);
257
258 if (strlen(filename) > 14)
259 return -EINVAL;
260
261 snprintf(path, 20, "%s", filename);
262
263 if (request_firmware(&fw, path, &dev->dev) == 0) {
264 if (fw->size >= CISTPL_MAX_CIS_SIZE)
265 goto release;
266
267 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
268 if (!cis)
269 goto release;
270
271 cis->Length = fw->size + 1;
272 memcpy(cis->Data, fw->data, fw->size);
273
274 if (!pcmcia_replace_cis(s, cis))
275 ret = 0;
276 }
277 release:
278 release_firmware(fw);
279
280 return (ret);
281}
282
283#else /* !CONFIG_PCMCIA_LOAD_CIS */
284
285static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
286{
287 return -ENODEV;
288}
289
290#endif
291
292
293/*======================================================================*/ 234/*======================================================================*/
294 235
295 236
@@ -309,6 +250,8 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
309 driver->drv.bus = &pcmcia_bus_type; 250 driver->drv.bus = &pcmcia_bus_type;
310 driver->drv.owner = driver->owner; 251 driver->drv.owner = driver->owner;
311 252
253 ds_dbg(3, "registering driver %s\n", driver->drv.name);
254
312 return driver_register(&driver->drv); 255 return driver_register(&driver->drv);
313} 256}
314EXPORT_SYMBOL(pcmcia_register_driver); 257EXPORT_SYMBOL(pcmcia_register_driver);
@@ -318,6 +261,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
318 */ 261 */
319void pcmcia_unregister_driver(struct pcmcia_driver *driver) 262void pcmcia_unregister_driver(struct pcmcia_driver *driver)
320{ 263{
264 ds_dbg(3, "unregistering driver %s\n", driver->drv.name);
321 driver_unregister(&driver->drv); 265 driver_unregister(&driver->drv);
322} 266}
323EXPORT_SYMBOL(pcmcia_unregister_driver); 267EXPORT_SYMBOL(pcmcia_unregister_driver);
@@ -343,23 +287,27 @@ void pcmcia_put_dev(struct pcmcia_device *p_dev)
343static void pcmcia_release_function(struct kref *ref) 287static void pcmcia_release_function(struct kref *ref)
344{ 288{
345 struct config_t *c = container_of(ref, struct config_t, ref); 289 struct config_t *c = container_of(ref, struct config_t, ref);
290 ds_dbg(1, "releasing config_t\n");
346 kfree(c); 291 kfree(c);
347} 292}
348 293
349static void pcmcia_release_dev(struct device *dev) 294static void pcmcia_release_dev(struct device *dev)
350{ 295{
351 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 296 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
352 ds_dbg(1, "releasing dev %p\n", p_dev); 297 ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id);
353 pcmcia_put_socket(p_dev->socket); 298 pcmcia_put_socket(p_dev->socket);
354 kfree(p_dev->devname); 299 kfree(p_dev->devname);
355 kref_put(&p_dev->function_config->ref, pcmcia_release_function); 300 kref_put(&p_dev->function_config->ref, pcmcia_release_function);
356 kfree(p_dev); 301 kfree(p_dev);
357} 302}
358 303
359static void pcmcia_add_pseudo_device(struct pcmcia_socket *s) 304static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
360{ 305{
361 if (!s->pcmcia_state.device_add_pending) { 306 if (!s->pcmcia_state.device_add_pending) {
307 ds_dbg(1, "scheduling to add %s secondary"
308 " device to %d\n", mfc ? "mfc" : "pfc", s->sock);
362 s->pcmcia_state.device_add_pending = 1; 309 s->pcmcia_state.device_add_pending = 1;
310 s->pcmcia_state.mfc_pfc = mfc;
363 schedule_work(&s->device_add); 311 schedule_work(&s->device_add);
364 } 312 }
365 return; 313 return;
@@ -371,6 +319,7 @@ static int pcmcia_device_probe(struct device * dev)
371 struct pcmcia_driver *p_drv; 319 struct pcmcia_driver *p_drv;
372 struct pcmcia_device_id *did; 320 struct pcmcia_device_id *did;
373 struct pcmcia_socket *s; 321 struct pcmcia_socket *s;
322 cistpl_config_t cis_config;
374 int ret = 0; 323 int ret = 0;
375 324
376 dev = get_device(dev); 325 dev = get_device(dev);
@@ -381,15 +330,33 @@ static int pcmcia_device_probe(struct device * dev)
381 p_drv = to_pcmcia_drv(dev->driver); 330 p_drv = to_pcmcia_drv(dev->driver);
382 s = p_dev->socket; 331 s = p_dev->socket;
383 332
333 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id,
334 p_drv->drv.name);
335
384 if ((!p_drv->probe) || (!p_dev->function_config) || 336 if ((!p_drv->probe) || (!p_dev->function_config) ||
385 (!try_module_get(p_drv->owner))) { 337 (!try_module_get(p_drv->owner))) {
386 ret = -EINVAL; 338 ret = -EINVAL;
387 goto put_dev; 339 goto put_dev;
388 } 340 }
389 341
342 /* set up some more device information */
343 ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG,
344 &cis_config);
345 if (!ret) {
346 p_dev->conf.ConfigBase = cis_config.base;
347 p_dev->conf.Present = cis_config.rmask[0];
348 } else {
349 printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n");
350 p_dev->conf.ConfigBase = 0;
351 p_dev->conf.Present = 0;
352 }
353
390 ret = p_drv->probe(p_dev); 354 ret = p_drv->probe(p_dev);
391 if (ret) 355 if (ret) {
356 ds_dbg(1, "binding %s to %s failed with %d\n",
357 p_dev->dev.bus_id, p_drv->drv.name, ret);
392 goto put_module; 358 goto put_module;
359 }
393 360
394 /* handle pseudo multifunction devices: 361 /* handle pseudo multifunction devices:
395 * there are at most two pseudo multifunction devices. 362 * there are at most two pseudo multifunction devices.
@@ -400,7 +367,7 @@ static int pcmcia_device_probe(struct device * dev)
400 did = p_dev->dev.driver_data; 367 did = p_dev->dev.driver_data;
401 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && 368 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
402 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) 369 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
403 pcmcia_add_pseudo_device(p_dev->socket); 370 pcmcia_add_device_later(p_dev->socket, 0);
404 371
405 put_module: 372 put_module:
406 if (ret) 373 if (ret)
@@ -421,8 +388,8 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
421 struct pcmcia_device *tmp; 388 struct pcmcia_device *tmp;
422 unsigned long flags; 389 unsigned long flags;
423 390
424 ds_dbg(2, "unbind_request(%d)\n", s->sock); 391 ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock,
425 392 leftover ? leftover->devname : "");
426 393
427 if (!leftover) 394 if (!leftover)
428 s->device_count = 0; 395 s->device_count = 0;
@@ -439,6 +406,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
439 p_dev->_removed=1; 406 p_dev->_removed=1;
440 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 407 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
441 408
409 ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id);
442 device_unregister(&p_dev->dev); 410 device_unregister(&p_dev->dev);
443 } 411 }
444 412
@@ -455,6 +423,8 @@ static int pcmcia_device_remove(struct device * dev)
455 p_dev = to_pcmcia_dev(dev); 423 p_dev = to_pcmcia_dev(dev);
456 p_drv = to_pcmcia_drv(dev->driver); 424 p_drv = to_pcmcia_drv(dev->driver);
457 425
426 ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id);
427
458 /* If we're removing the primary module driving a 428 /* If we're removing the primary module driving a
459 * pseudo multi-function card, we need to unbind 429 * pseudo multi-function card, we need to unbind
460 * all devices 430 * all devices
@@ -587,8 +557,10 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
587 557
588 mutex_lock(&device_add_lock); 558 mutex_lock(&device_add_lock);
589 559
590 /* max of 2 devices per card */ 560 ds_dbg(3, "adding device to %d, function %d\n", s->sock, function);
591 if (s->device_count == 2) 561
562 /* max of 4 devices per card */
563 if (s->device_count == 4)
592 goto err_put; 564 goto err_put;
593 565
594 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL); 566 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL);
@@ -598,8 +570,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
598 p_dev->socket = s; 570 p_dev->socket = s;
599 p_dev->device_no = (s->device_count++); 571 p_dev->device_no = (s->device_count++);
600 p_dev->func = function; 572 p_dev->func = function;
601 if (s->functions <= function)
602 s->functions = function + 1;
603 573
604 p_dev->dev.bus = &pcmcia_bus_type; 574 p_dev->dev.bus = &pcmcia_bus_type;
605 p_dev->dev.parent = s->dev.dev; 575 p_dev->dev.parent = s->dev.dev;
@@ -610,8 +580,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
610 if (!p_dev->devname) 580 if (!p_dev->devname)
611 goto err_free; 581 goto err_free;
612 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 582 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
583 ds_dbg(3, "devname is %s\n", p_dev->devname);
613 584
614 /* compat */
615 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 585 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
616 586
617 /* 587 /*
@@ -631,6 +601,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
631 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 601 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
632 602
633 if (!p_dev->function_config) { 603 if (!p_dev->function_config) {
604 ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id);
634 p_dev->function_config = kzalloc(sizeof(struct config_t), 605 p_dev->function_config = kzalloc(sizeof(struct config_t),
635 GFP_KERNEL); 606 GFP_KERNEL);
636 if (!p_dev->function_config) 607 if (!p_dev->function_config)
@@ -674,11 +645,16 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
674 unsigned int no_funcs, i; 645 unsigned int no_funcs, i;
675 int ret = 0; 646 int ret = 0;
676 647
677 if (!(s->resource_setup_done)) 648 if (!(s->resource_setup_done)) {
649 ds_dbg(3, "no resources available, delaying card_add\n");
678 return -EAGAIN; /* try again, but later... */ 650 return -EAGAIN; /* try again, but later... */
651 }
679 652
680 if (pcmcia_validate_mem(s)) 653 if (pcmcia_validate_mem(s)) {
654 ds_dbg(3, "validating mem resources failed, "
655 "delaying card_add\n");
681 return -EAGAIN; /* try again, but later... */ 656 return -EAGAIN; /* try again, but later... */
657 }
682 658
683 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); 659 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo);
684 if (ret || !cisinfo.Chains) { 660 if (ret || !cisinfo.Chains) {
@@ -690,6 +666,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
690 no_funcs = mfc.nfn; 666 no_funcs = mfc.nfn;
691 else 667 else
692 no_funcs = 1; 668 no_funcs = 1;
669 s->functions = no_funcs;
693 670
694 for (i=0; i < no_funcs; i++) 671 for (i=0; i < no_funcs; i++)
695 pcmcia_device_add(s, i); 672 pcmcia_device_add(s, i);
@@ -698,38 +675,50 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
698} 675}
699 676
700 677
701static void pcmcia_delayed_add_pseudo_device(void *data) 678static void pcmcia_delayed_add_device(struct work_struct *work)
702{ 679{
703 struct pcmcia_socket *s = data; 680 struct pcmcia_socket *s =
704 pcmcia_device_add(s, 0); 681 container_of(work, struct pcmcia_socket, device_add);
682 ds_dbg(1, "adding additional device to %d\n", s->sock);
683 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
705 s->pcmcia_state.device_add_pending = 0; 684 s->pcmcia_state.device_add_pending = 0;
685 s->pcmcia_state.mfc_pfc = 0;
706} 686}
707 687
708static int pcmcia_requery(struct device *dev, void * _data) 688static int pcmcia_requery(struct device *dev, void * _data)
709{ 689{
710 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 690 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
711 if (!p_dev->dev.driver) 691 if (!p_dev->dev.driver) {
692 ds_dbg(1, "update device information for %s\n",
693 p_dev->dev.bus_id);
712 pcmcia_device_query(p_dev); 694 pcmcia_device_query(p_dev);
695 }
713 696
714 return 0; 697 return 0;
715} 698}
716 699
717static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 700static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
718{ 701{
719 int no_devices=0; 702 int no_devices = 0;
720 int ret = 0; 703 int ret = 0;
721 unsigned long flags; 704 unsigned long flags;
722 705
723 /* must be called with skt_mutex held */ 706 /* must be called with skt_mutex held */
707 ds_dbg(0, "re-scanning socket %d\n", skt->sock);
708
724 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 709 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
725 if (list_empty(&skt->devices_list)) 710 if (list_empty(&skt->devices_list))
726 no_devices=1; 711 no_devices = 1;
727 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 712 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
728 713
714 /* If this is because of a CIS override, start over */
715 if (new_cis && !no_devices)
716 pcmcia_card_remove(skt, NULL);
717
729 /* if no devices were added for this socket yet because of 718 /* if no devices were added for this socket yet because of
730 * missing resource information or other trouble, we need to 719 * missing resource information or other trouble, we need to
731 * do this now. */ 720 * do this now. */
732 if (no_devices) { 721 if (no_devices || new_cis) {
733 ret = pcmcia_card_add(skt); 722 ret = pcmcia_card_add(skt);
734 if (ret) 723 if (ret)
735 return; 724 return;
@@ -747,6 +736,97 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
747 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n"); 736 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
748} 737}
749 738
739#ifdef CONFIG_PCMCIA_LOAD_CIS
740
741/**
742 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
743 * @dev - the pcmcia device which needs a CIS override
744 * @filename - requested filename in /lib/firmware/
745 *
746 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
747 * the one provided by the card is broken. The firmware files reside in
748 * /lib/firmware/ in userspace.
749 */
750static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
751{
752 struct pcmcia_socket *s = dev->socket;
753 const struct firmware *fw;
754 char path[20];
755 int ret = -ENOMEM;
756 int no_funcs;
757 int old_funcs;
758 cisdump_t *cis;
759 cistpl_longlink_mfc_t mfc;
760
761 if (!filename)
762 return -EINVAL;
763
764 ds_dbg(1, "trying to load CIS file %s\n", filename);
765
766 if (strlen(filename) > 14) {
767 printk(KERN_WARNING "pcmcia: CIS filename is too long\n");
768 return -EINVAL;
769 }
770
771 snprintf(path, 20, "%s", filename);
772
773 if (request_firmware(&fw, path, &dev->dev) == 0) {
774 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
775 ret = -EINVAL;
776 printk(KERN_ERR "pcmcia: CIS override is too big\n");
777 goto release;
778 }
779
780 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
781 if (!cis) {
782 ret = -ENOMEM;
783 goto release;
784 }
785
786 cis->Length = fw->size + 1;
787 memcpy(cis->Data, fw->data, fw->size);
788
789 if (!pcmcia_replace_cis(s, cis))
790 ret = 0;
791 else {
792 printk(KERN_ERR "pcmcia: CIS override failed\n");
793 goto release;
794 }
795
796
797 /* update information */
798 pcmcia_device_query(dev);
799
800 /* does this cis override add or remove functions? */
801 old_funcs = s->functions;
802
803 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
804 no_funcs = mfc.nfn;
805 else
806 no_funcs = 1;
807 s->functions = no_funcs;
808
809 if (old_funcs > no_funcs)
810 pcmcia_card_remove(s, dev);
811 else if (no_funcs > old_funcs)
812 pcmcia_add_device_later(s, 1);
813 }
814 release:
815 release_firmware(fw);
816
817 return (ret);
818}
819
820#else /* !CONFIG_PCMCIA_LOAD_CIS */
821
822static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
823{
824 return -ENODEV;
825}
826
827#endif
828
829
750static inline int pcmcia_devmatch(struct pcmcia_device *dev, 830static inline int pcmcia_devmatch(struct pcmcia_device *dev,
751 struct pcmcia_device_id *did) 831 struct pcmcia_device_id *did)
752{ 832{
@@ -813,11 +893,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
813 * after it has re-checked that there is no possible module 893 * after it has re-checked that there is no possible module
814 * with a prod_id/manf_id/card_id match. 894 * with a prod_id/manf_id/card_id match.
815 */ 895 */
896 ds_dbg(0, "skipping FUNC_ID match for %s until userspace "
897 "interaction\n", dev->dev.bus_id);
816 if (!dev->allow_func_id_match) 898 if (!dev->allow_func_id_match)
817 return 0; 899 return 0;
818 } 900 }
819 901
820 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 902 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
903 ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id);
821 if (!dev->socket->fake_cis) 904 if (!dev->socket->fake_cis)
822 pcmcia_load_firmware(dev, did->cisfile); 905 pcmcia_load_firmware(dev, did->cisfile);
823 906
@@ -847,13 +930,21 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
847 930
848#ifdef CONFIG_PCMCIA_IOCTL 931#ifdef CONFIG_PCMCIA_IOCTL
849 /* matching by cardmgr */ 932 /* matching by cardmgr */
850 if (p_dev->cardmgr == p_drv) 933 if (p_dev->cardmgr == p_drv) {
934 ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id,
935 drv->name);
851 return 1; 936 return 1;
937 }
852#endif 938#endif
853 939
854 while (did && did->match_flags) { 940 while (did && did->match_flags) {
855 if (pcmcia_devmatch(p_dev, did)) 941 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id,
942 drv->name);
943 if (pcmcia_devmatch(p_dev, did)) {
944 ds_dbg(0, "matched %s to %s\n", dev->bus_id,
945 drv->name);
856 return 1; 946 return 1;
947 }
857 did++; 948 did++;
858 } 949 }
859 950
@@ -1044,6 +1135,8 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1044 struct pcmcia_driver *p_drv = NULL; 1135 struct pcmcia_driver *p_drv = NULL;
1045 int ret = 0; 1136 int ret = 0;
1046 1137
1138 ds_dbg(2, "suspending %s\n", dev->bus_id);
1139
1047 if (dev->driver) 1140 if (dev->driver)
1048 p_drv = to_pcmcia_drv(dev->driver); 1141 p_drv = to_pcmcia_drv(dev->driver);
1049 1142
@@ -1052,12 +1145,18 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1052 1145
1053 if (p_drv->suspend) { 1146 if (p_drv->suspend) {
1054 ret = p_drv->suspend(p_dev); 1147 ret = p_drv->suspend(p_dev);
1055 if (ret) 1148 if (ret) {
1149 printk(KERN_ERR "pcmcia: device %s (driver %s) did "
1150 "not want to go to sleep (%d)\n",
1151 p_dev->devname, p_drv->drv.name, ret);
1056 goto out; 1152 goto out;
1153 }
1057 } 1154 }
1058 1155
1059 if (p_dev->device_no == p_dev->func) 1156 if (p_dev->device_no == p_dev->func) {
1157 ds_dbg(2, "releasing configuration for %s\n", dev->bus_id);
1060 pcmcia_release_configuration(p_dev); 1158 pcmcia_release_configuration(p_dev);
1159 }
1061 1160
1062 out: 1161 out:
1063 if (!ret) 1162 if (!ret)
@@ -1072,6 +1171,8 @@ static int pcmcia_dev_resume(struct device * dev)
1072 struct pcmcia_driver *p_drv = NULL; 1171 struct pcmcia_driver *p_drv = NULL;
1073 int ret = 0; 1172 int ret = 0;
1074 1173
1174 ds_dbg(2, "resuming %s\n", dev->bus_id);
1175
1075 if (dev->driver) 1176 if (dev->driver)
1076 p_drv = to_pcmcia_drv(dev->driver); 1177 p_drv = to_pcmcia_drv(dev->driver);
1077 1178
@@ -1079,6 +1180,7 @@ static int pcmcia_dev_resume(struct device * dev)
1079 goto out; 1180 goto out;
1080 1181
1081 if (p_dev->device_no == p_dev->func) { 1182 if (p_dev->device_no == p_dev->func) {
1183 ds_dbg(2, "requesting configuration for %s\n", dev->bus_id);
1082 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1184 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1083 if (ret) 1185 if (ret)
1084 goto out; 1186 goto out;
@@ -1120,12 +1222,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1120 1222
1121static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1223static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1122{ 1224{
1225 ds_dbg(2, "resuming socket %d\n", skt->sock);
1123 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1226 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1124 return 0; 1227 return 0;
1125} 1228}
1126 1229
1127static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1230static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1128{ 1231{
1232 ds_dbg(2, "suspending socket %d\n", skt->sock);
1129 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1233 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1130 pcmcia_bus_suspend_callback)) { 1234 pcmcia_bus_suspend_callback)) {
1131 pcmcia_bus_resume(skt); 1235 pcmcia_bus_resume(skt);
@@ -1246,7 +1350,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1246 init_waitqueue_head(&socket->queue); 1350 init_waitqueue_head(&socket->queue);
1247#endif 1351#endif
1248 INIT_LIST_HEAD(&socket->devices_list); 1352 INIT_LIST_HEAD(&socket->devices_list);
1249 INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device, socket); 1353 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device);
1250 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1354 memset(&socket->pcmcia_state, 0, sizeof(u8));
1251 socket->device_count = 0; 1355 socket->device_count = 0;
1252 1356
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 36fdaa58458c..3c22ac4625c2 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -398,7 +398,7 @@ static irqreturn_t pcc_interrupt(int irq, void *dev)
398static void pcc_interrupt_wrapper(u_long data) 398static void pcc_interrupt_wrapper(u_long data)
399{ 399{
400 debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n"); 400 debug(3, "m32r_cfc: pcc_interrupt_wrapper:\n");
401 pcc_interrupt(0, NULL, NULL); 401 pcc_interrupt(0, NULL);
402 init_timer(&poll_timer); 402 init_timer(&poll_timer);
403 poll_timer.expires = jiffies + poll_interval; 403 poll_timer.expires = jiffies + poll_interval;
404 add_timer(&poll_timer); 404 add_timer(&poll_timer);
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 310ede575caa..d077870c6731 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -594,7 +594,12 @@ static int ds_ioctl(struct inode * inode, struct file * file,
594 594
595 err = ret = 0; 595 err = ret = 0;
596 596
597 if (cmd & IOC_IN) __copy_from_user((char *)buf, uarg, size); 597 if (cmd & IOC_IN) {
598 if (__copy_from_user((char *)buf, uarg, size)) {
599 err = -EFAULT;
600 goto free_out;
601 }
602 }
598 603
599 switch (cmd) { 604 switch (cmd) {
600 case DS_ADJUST_RESOURCE_INFO: 605 case DS_ADJUST_RESOURCE_INFO:
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index a70f97fdbbdd..360c24896548 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -581,10 +581,10 @@ static irqreturn_t pd6729_test(int irq, void *dev)
581 return IRQ_HANDLED; 581 return IRQ_HANDLED;
582} 582}
583 583
584static int pd6729_check_irq(int irq, int flags) 584static int pd6729_check_irq(int irq)
585{ 585{
586 if (request_irq(irq, pd6729_test, flags, "x", pd6729_test) != 0) 586 if (request_irq(irq, pd6729_test, IRQF_PROBE_SHARED, "x", pd6729_test)
587 return -1; 587 != 0) return -1;
588 free_irq(irq, pd6729_test); 588 free_irq(irq, pd6729_test);
589 return 0; 589 return 0;
590} 590}
@@ -610,7 +610,7 @@ static u_int __devinit pd6729_isa_scan(void)
610 610
611 /* just find interrupts that aren't in use */ 611 /* just find interrupts that aren't in use */
612 for (i = 0; i < 16; i++) 612 for (i = 0; i < 16; i++)
613 if ((mask0 & (1 << i)) && (pd6729_check_irq(i, 0) == 0)) 613 if ((mask0 & (1 << i)) && (pd6729_check_irq(i) == 0))
614 mask |= (1 << i); 614 mask |= (1 << i);
615 615
616 printk(KERN_INFO "pd6729: ISA irqs = "); 616 printk(KERN_INFO "pd6729: ISA irqs = ");
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 933cd864a5c9..b005602d6b53 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -188,7 +188,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf,
188 (s->state & SOCKET_PRESENT) && 188 (s->state & SOCKET_PRESENT) &&
189 !(s->state & SOCKET_CARDBUS)) { 189 !(s->state & SOCKET_CARDBUS)) {
190 if (try_module_get(s->callback->owner)) { 190 if (try_module_get(s->callback->owner)) {
191 s->callback->requery(s); 191 s->callback->requery(s, 0);
192 module_put(s->callback->owner); 192 module_put(s->callback->owner);
193 } 193 }
194 } 194 }
@@ -325,7 +325,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
325 if ((s->callback) && (s->state & SOCKET_PRESENT) && 325 if ((s->callback) && (s->state & SOCKET_PRESENT) &&
326 !(s->state & SOCKET_CARDBUS)) { 326 !(s->state & SOCKET_CARDBUS)) {
327 if (try_module_get(s->callback->owner)) { 327 if (try_module_get(s->callback->owner)) {
328 s->callback->requery(s); 328 s->callback->requery(s, 1);
329 module_put(s->callback->owner); 329 module_put(s->callback->owner);
330 } 330 }
331 } 331 }
diff --git a/drivers/ps3/Makefile b/drivers/ps3/Makefile
new file mode 100644
index 000000000000..b52d547b7a78
--- /dev/null
+++ b/drivers/ps3/Makefile
@@ -0,0 +1 @@
obj-y += system-bus.o
diff --git a/drivers/ps3/system-bus.c b/drivers/ps3/system-bus.c
new file mode 100644
index 000000000000..d79f949bcb2a
--- /dev/null
+++ b/drivers/ps3/system-bus.c
@@ -0,0 +1,362 @@
1/*
2 * PS3 system bus driver.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/dma-mapping.h>
25#include <linux/err.h>
26
27#include <asm/udbg.h>
28#include <asm/ps3.h>
29#include <asm/lv1call.h>
30#include <asm/firmware.h>
31
32#define dump_mmio_region(_a) _dump_mmio_region(_a, __func__, __LINE__)
33static void _dump_mmio_region(const struct ps3_mmio_region* r,
34 const char* func, int line)
35{
36 pr_debug("%s:%d: dev %u:%u\n", func, line, r->did.bus_id,
37 r->did.dev_id);
38 pr_debug("%s:%d: bus_addr %lxh\n", func, line, r->bus_addr);
39 pr_debug("%s:%d: len %lxh\n", func, line, r->len);
40 pr_debug("%s:%d: lpar_addr %lxh\n", func, line, r->lpar_addr);
41}
42
43int ps3_mmio_region_create(struct ps3_mmio_region *r)
44{
45 int result;
46
47 result = lv1_map_device_mmio_region(r->did.bus_id, r->did.dev_id,
48 r->bus_addr, r->len, r->page_size, &r->lpar_addr);
49
50 if (result) {
51 pr_debug("%s:%d: lv1_map_device_mmio_region failed: %s\n",
52 __func__, __LINE__, ps3_result(result));
53 r->lpar_addr = r->len = r->bus_addr = 0;
54 }
55
56 dump_mmio_region(r);
57 return result;
58}
59
60int ps3_free_mmio_region(struct ps3_mmio_region *r)
61{
62 int result;
63
64 result = lv1_unmap_device_mmio_region(r->did.bus_id, r->did.dev_id,
65 r->bus_addr);
66
67 if (result)
68 pr_debug("%s:%d: lv1_unmap_device_mmio_region failed: %s\n",
69 __func__, __LINE__, ps3_result(result));
70
71 r->lpar_addr = r->len = r->bus_addr = 0;
72 return result;
73}
74
75static int ps3_system_bus_match(struct device *_dev,
76 struct device_driver *_drv)
77{
78 int result;
79 struct ps3_system_bus_driver *drv = to_ps3_system_bus_driver(_drv);
80 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
81
82 result = dev->match_id == drv->match_id;
83
84 pr_info("%s:%d: dev=%u(%s), drv=%u(%s): %s\n", __func__, __LINE__,
85 dev->match_id, dev->core.bus_id, drv->match_id, drv->core.name,
86 (result ? "match" : "miss"));
87 return result;
88}
89
90static int ps3_system_bus_probe(struct device *_dev)
91{
92 int result;
93 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
94 struct ps3_system_bus_driver *drv =
95 to_ps3_system_bus_driver(_dev->driver);
96
97 result = lv1_open_device(dev->did.bus_id, dev->did.dev_id, 0);
98
99 if (result) {
100 pr_debug("%s:%d: lv1_open_device failed (%d)\n",
101 __func__, __LINE__, result);
102 result = -EACCES;
103 goto clean_none;
104 }
105
106 if (dev->d_region->did.bus_id) {
107 result = ps3_dma_region_create(dev->d_region);
108
109 if (result) {
110 pr_debug("%s:%d: ps3_dma_region_create failed (%d)\n",
111 __func__, __LINE__, result);
112 BUG_ON("check region type");
113 result = -EINVAL;
114 goto clean_device;
115 }
116 }
117
118 BUG_ON(!drv);
119
120 if (drv->probe)
121 result = drv->probe(dev);
122 else
123 pr_info("%s:%d: %s no probe method\n", __func__, __LINE__,
124 dev->core.bus_id);
125
126 if (result) {
127 pr_debug("%s:%d: drv->probe failed\n", __func__, __LINE__);
128 goto clean_dma;
129 }
130
131 return result;
132
133clean_dma:
134 ps3_dma_region_free(dev->d_region);
135clean_device:
136 lv1_close_device(dev->did.bus_id, dev->did.dev_id);
137clean_none:
138 return result;
139}
140
141static int ps3_system_bus_remove(struct device *_dev)
142{
143 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
144 struct ps3_system_bus_driver *drv =
145 to_ps3_system_bus_driver(_dev->driver);
146
147 if (drv->remove)
148 drv->remove(dev);
149 else
150 pr_info("%s:%d: %s no remove method\n", __func__, __LINE__,
151 dev->core.bus_id);
152
153 ps3_dma_region_free(dev->d_region);
154 ps3_free_mmio_region(dev->m_region);
155 lv1_close_device(dev->did.bus_id, dev->did.dev_id);
156
157 return 0;
158}
159
160struct bus_type ps3_system_bus_type = {
161 .name = "ps3_system_bus",
162 .match = ps3_system_bus_match,
163 .probe = ps3_system_bus_probe,
164 .remove = ps3_system_bus_remove,
165};
166
167int __init ps3_system_bus_init(void)
168{
169 int result;
170
171 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
172 return 0;
173
174 result = bus_register(&ps3_system_bus_type);
175 BUG_ON(result);
176 return result;
177}
178
179core_initcall(ps3_system_bus_init);
180
181/* Allocates a contiguous real buffer and creates mappings over it.
182 * Returns the virtual address of the buffer and sets dma_handle
183 * to the dma address (mapping) of the first page.
184 */
185
186static void * ps3_alloc_coherent(struct device *_dev, size_t size,
187 dma_addr_t *dma_handle, gfp_t flag)
188{
189 int result;
190 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
191 unsigned long virt_addr;
192
193 BUG_ON(!dev->d_region->bus_addr);
194
195 flag &= ~(__GFP_DMA | __GFP_HIGHMEM);
196 flag |= __GFP_ZERO;
197
198 virt_addr = __get_free_pages(flag, get_order(size));
199
200 if (!virt_addr) {
201 pr_debug("%s:%d: get_free_pages failed\n", __func__, __LINE__);
202 goto clean_none;
203 }
204
205 result = ps3_dma_map(dev->d_region, virt_addr, size, dma_handle);
206
207 if (result) {
208 pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
209 __func__, __LINE__, result);
210 BUG_ON("check region type");
211 goto clean_alloc;
212 }
213
214 return (void*)virt_addr;
215
216clean_alloc:
217 free_pages(virt_addr, get_order(size));
218clean_none:
219 dma_handle = NULL;
220 return NULL;
221}
222
223static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr,
224 dma_addr_t dma_handle)
225{
226 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
227
228 ps3_dma_unmap(dev->d_region, dma_handle, size);
229 free_pages((unsigned long)vaddr, get_order(size));
230}
231
232/* Creates TCEs for a user provided buffer. The user buffer must be
233 * contiguous real kernel storage (not vmalloc). The address of the buffer
234 * passed here is the kernel (virtual) address of the buffer. The buffer
235 * need not be page aligned, the dma_addr_t returned will point to the same
236 * byte within the page as vaddr.
237 */
238
239static dma_addr_t ps3_map_single(struct device *_dev, void *ptr, size_t size,
240 enum dma_data_direction direction)
241{
242 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
243 int result;
244 unsigned long bus_addr;
245
246 result = ps3_dma_map(dev->d_region, (unsigned long)ptr, size,
247 &bus_addr);
248
249 if (result) {
250 pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
251 __func__, __LINE__, result);
252 }
253
254 return bus_addr;
255}
256
257static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr,
258 size_t size, enum dma_data_direction direction)
259{
260 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
261 int result;
262
263 result = ps3_dma_unmap(dev->d_region, dma_addr, size);
264
265 if (result) {
266 pr_debug("%s:%d: ps3_dma_unmap failed (%d)\n",
267 __func__, __LINE__, result);
268 }
269}
270
271static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents,
272 enum dma_data_direction direction)
273{
274#if defined(CONFIG_PS3_DYNAMIC_DMA)
275 BUG_ON("do");
276#endif
277 return 0;
278}
279
280static void ps3_unmap_sg(struct device *_dev, struct scatterlist *sg,
281 int nents, enum dma_data_direction direction)
282{
283#if defined(CONFIG_PS3_DYNAMIC_DMA)
284 BUG_ON("do");
285#endif
286}
287
288static int ps3_dma_supported(struct device *_dev, u64 mask)
289{
290 return 1;
291}
292
293static struct dma_mapping_ops ps3_dma_ops = {
294 .alloc_coherent = ps3_alloc_coherent,
295 .free_coherent = ps3_free_coherent,
296 .map_single = ps3_map_single,
297 .unmap_single = ps3_unmap_single,
298 .map_sg = ps3_map_sg,
299 .unmap_sg = ps3_unmap_sg,
300 .dma_supported = ps3_dma_supported
301};
302
303/**
304 * ps3_system_bus_release_device - remove a device from the system bus
305 */
306
307static void ps3_system_bus_release_device(struct device *_dev)
308{
309 struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
310 kfree(dev);
311}
312
313/**
314 * ps3_system_bus_device_register - add a device to the system bus
315 *
316 * ps3_system_bus_device_register() expects the dev object to be allocated
317 * dynamically by the caller. The system bus takes ownership of the dev
318 * object and frees the object in ps3_system_bus_release_device().
319 */
320
321int ps3_system_bus_device_register(struct ps3_system_bus_device *dev)
322{
323 int result;
324 static unsigned int dev_count = 1;
325
326 dev->core.parent = NULL;
327 dev->core.bus = &ps3_system_bus_type;
328 dev->core.release = ps3_system_bus_release_device;
329
330 dev->core.archdata.of_node = NULL;
331 dev->core.archdata.dma_ops = &ps3_dma_ops;
332 dev->core.archdata.numa_node = 0;
333
334 snprintf(dev->core.bus_id, sizeof(dev->core.bus_id), "sb_%02x",
335 dev_count++);
336
337 pr_debug("%s:%d add %s\n", __func__, __LINE__, dev->core.bus_id);
338
339 result = device_register(&dev->core);
340 return result;
341}
342
343EXPORT_SYMBOL_GPL(ps3_system_bus_device_register);
344
345int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv)
346{
347 int result;
348
349 drv->core.bus = &ps3_system_bus_type;
350
351 result = driver_register(&drv->core);
352 return result;
353}
354
355EXPORT_SYMBOL_GPL(ps3_system_bus_driver_register);
356
357void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv)
358{
359 driver_unregister(&drv->core);
360}
361
362EXPORT_SYMBOL_GPL(ps3_system_bus_driver_unregister);
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
index 814b9e1873f5..828b329e08e0 100644
--- a/drivers/rtc/rtc-dev.c
+++ b/drivers/rtc/rtc-dev.c
@@ -53,9 +53,10 @@ static int rtc_dev_open(struct inode *inode, struct file *file)
53 * Routine to poll RTC seconds field for change as often as possible, 53 * Routine to poll RTC seconds field for change as often as possible,
54 * after first RTC_UIE use timer to reduce polling 54 * after first RTC_UIE use timer to reduce polling
55 */ 55 */
56static void rtc_uie_task(void *data) 56static void rtc_uie_task(struct work_struct *work)
57{ 57{
58 struct rtc_device *rtc = data; 58 struct rtc_device *rtc =
59 container_of(work, struct rtc_device, uie_task);
59 struct rtc_time tm; 60 struct rtc_time tm;
60 int num = 0; 61 int num = 0;
61 int err; 62 int err;
@@ -411,7 +412,7 @@ static int rtc_dev_add_device(struct class_device *class_dev,
411 spin_lock_init(&rtc->irq_lock); 412 spin_lock_init(&rtc->irq_lock);
412 init_waitqueue_head(&rtc->irq_queue); 413 init_waitqueue_head(&rtc->irq_queue);
413#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL 414#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
414 INIT_WORK(&rtc->uie_task, rtc_uie_task, rtc); 415 INIT_WORK(&rtc->uie_task, rtc_uie_task);
415 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc); 416 setup_timer(&rtc->uie_timer, rtc_uie_timer, (unsigned long)rtc);
416#endif 417#endif
417 418
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index a2cef57d7bcb..2af2d9b53d18 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -54,7 +54,7 @@ static void dasd_flush_request_queue(struct dasd_device *);
54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); 54static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
55static int dasd_flush_ccw_queue(struct dasd_device *, int); 55static int dasd_flush_ccw_queue(struct dasd_device *, int);
56static void dasd_tasklet(struct dasd_device *); 56static void dasd_tasklet(struct dasd_device *);
57static void do_kick_device(void *data); 57static void do_kick_device(struct work_struct *);
58 58
59/* 59/*
60 * SECTION: Operations on the device structure. 60 * SECTION: Operations on the device structure.
@@ -100,7 +100,7 @@ dasd_alloc_device(void)
100 (unsigned long) device); 100 (unsigned long) device);
101 INIT_LIST_HEAD(&device->ccw_queue); 101 INIT_LIST_HEAD(&device->ccw_queue);
102 init_timer(&device->timer); 102 init_timer(&device->timer);
103 INIT_WORK(&device->kick_work, do_kick_device, device); 103 INIT_WORK(&device->kick_work, do_kick_device);
104 device->state = DASD_STATE_NEW; 104 device->state = DASD_STATE_NEW;
105 device->target = DASD_STATE_NEW; 105 device->target = DASD_STATE_NEW;
106 106
@@ -407,11 +407,9 @@ dasd_change_state(struct dasd_device *device)
407 * event daemon. 407 * event daemon.
408 */ 408 */
409static void 409static void
410do_kick_device(void *data) 410do_kick_device(struct work_struct *work)
411{ 411{
412 struct dasd_device *device; 412 struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
413
414 device = (struct dasd_device *) data;
415 dasd_change_state(device); 413 dasd_change_state(device);
416 dasd_schedule_bh(device); 414 dasd_schedule_bh(device);
417 dasd_put_device(device); 415 dasd_put_device(device);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index ad7f7e1c0163..26cf2f5ae2e7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -334,7 +334,7 @@ static LIST_HEAD(slow_subchannels_head);
334static DEFINE_SPINLOCK(slow_subchannel_lock); 334static DEFINE_SPINLOCK(slow_subchannel_lock);
335 335
336static void 336static void
337css_trigger_slow_path(void) 337css_trigger_slow_path(struct work_struct *unused)
338{ 338{
339 CIO_TRACE_EVENT(4, "slowpath"); 339 CIO_TRACE_EVENT(4, "slowpath");
340 340
@@ -359,8 +359,7 @@ css_trigger_slow_path(void)
359 spin_unlock_irq(&slow_subchannel_lock); 359 spin_unlock_irq(&slow_subchannel_lock);
360} 360}
361 361
362typedef void (*workfunc)(void *); 362DECLARE_WORK(slow_path_work, css_trigger_slow_path);
363DECLARE_WORK(slow_path_work, (workfunc)css_trigger_slow_path, NULL);
364struct workqueue_struct *slow_path_wq; 363struct workqueue_struct *slow_path_wq;
365 364
366/* Reprobe subchannel if unregistered. */ 365/* Reprobe subchannel if unregistered. */
@@ -397,7 +396,7 @@ static int reprobe_subchannel(struct subchannel_id schid, void *data)
397} 396}
398 397
399/* Work function used to reprobe all unregistered subchannels. */ 398/* Work function used to reprobe all unregistered subchannels. */
400static void reprobe_all(void *data) 399static void reprobe_all(struct work_struct *unused)
401{ 400{
402 int ret; 401 int ret;
403 402
@@ -413,7 +412,7 @@ static void reprobe_all(void *data)
413 need_reprobe); 412 need_reprobe);
414} 413}
415 414
416DECLARE_WORK(css_reprobe_work, reprobe_all, NULL); 415DECLARE_WORK(css_reprobe_work, reprobe_all);
417 416
418/* Schedule reprobing of all unregistered subchannels. */ 417/* Schedule reprobing of all unregistered subchannels. */
419void css_schedule_reprobe(void) 418void css_schedule_reprobe(void)
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 6a54334ffe09..e4dc947e74e9 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -37,7 +37,7 @@
37#include "ap_bus.h" 37#include "ap_bus.h"
38 38
39/* Some prototypes. */ 39/* Some prototypes. */
40static void ap_scan_bus(void *); 40static void ap_scan_bus(struct work_struct *);
41static void ap_poll_all(unsigned long); 41static void ap_poll_all(unsigned long);
42static void ap_poll_timeout(unsigned long); 42static void ap_poll_timeout(unsigned long);
43static int ap_poll_thread_start(void); 43static int ap_poll_thread_start(void);
@@ -71,7 +71,7 @@ static struct device *ap_root_device = NULL;
71static struct workqueue_struct *ap_work_queue; 71static struct workqueue_struct *ap_work_queue;
72static struct timer_list ap_config_timer; 72static struct timer_list ap_config_timer;
73static int ap_config_time = AP_CONFIG_TIME; 73static int ap_config_time = AP_CONFIG_TIME;
74static DECLARE_WORK(ap_config_work, ap_scan_bus, NULL); 74static DECLARE_WORK(ap_config_work, ap_scan_bus);
75 75
76/** 76/**
77 * Tasklet & timer for AP request polling. 77 * Tasklet & timer for AP request polling.
@@ -732,7 +732,7 @@ static void ap_device_release(struct device *dev)
732 kfree(ap_dev); 732 kfree(ap_dev);
733} 733}
734 734
735static void ap_scan_bus(void *data) 735static void ap_scan_bus(struct work_struct *unused)
736{ 736{
737 struct ap_device *ap_dev; 737 struct ap_device *ap_dev;
738 struct device *dev; 738 struct device *dev;
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 08d4e47070bd..e5665b6743a1 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -67,7 +67,7 @@ static char debug_buffer[255];
67 * Some prototypes. 67 * Some prototypes.
68 */ 68 */
69static void lcs_tasklet(unsigned long); 69static void lcs_tasklet(unsigned long);
70static void lcs_start_kernel_thread(struct lcs_card *card); 70static void lcs_start_kernel_thread(struct work_struct *);
71static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *); 71static void lcs_get_frames_cb(struct lcs_channel *, struct lcs_buffer *);
72static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *); 72static int lcs_send_delipm(struct lcs_card *, struct lcs_ipm_list *);
73static int lcs_recovery(void *ptr); 73static int lcs_recovery(void *ptr);
@@ -1724,8 +1724,9 @@ lcs_stopcard(struct lcs_card *card)
1724 * Kernel Thread helper functions for LGW initiated commands 1724 * Kernel Thread helper functions for LGW initiated commands
1725 */ 1725 */
1726static void 1726static void
1727lcs_start_kernel_thread(struct lcs_card *card) 1727lcs_start_kernel_thread(struct work_struct *work)
1728{ 1728{
1729 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter);
1729 LCS_DBF_TEXT(5, trace, "krnthrd"); 1730 LCS_DBF_TEXT(5, trace, "krnthrd");
1730 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) 1731 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD))
1731 kernel_thread(lcs_recovery, (void *) card, SIGCHLD); 1732 kernel_thread(lcs_recovery, (void *) card, SIGCHLD);
@@ -2053,8 +2054,7 @@ lcs_probe_device(struct ccwgroup_device *ccwgdev)
2053 ccwgdev->cdev[0]->handler = lcs_irq; 2054 ccwgdev->cdev[0]->handler = lcs_irq;
2054 ccwgdev->cdev[1]->handler = lcs_irq; 2055 ccwgdev->cdev[1]->handler = lcs_irq;
2055 card->gdev = ccwgdev; 2056 card->gdev = ccwgdev;
2056 INIT_WORK(&card->kernel_thread_starter, 2057 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread);
2057 (void *) lcs_start_kernel_thread, card);
2058 card->thread_start_mask = 0; 2058 card->thread_start_mask = 0;
2059 card->thread_allowed_mask = 0; 2059 card->thread_allowed_mask = 0;
2060 card->thread_running_mask = 0; 2060 card->thread_running_mask = 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 7fdc5272c446..2bde4f1fb9c2 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1039,8 +1039,9 @@ qeth_do_start_thread(struct qeth_card *card, unsigned long thread)
1039} 1039}
1040 1040
1041static void 1041static void
1042qeth_start_kernel_thread(struct qeth_card *card) 1042qeth_start_kernel_thread(struct work_struct *work)
1043{ 1043{
1044 struct qeth_card *card = container_of(work, struct qeth_card, kernel_thread_starter);
1044 QETH_DBF_TEXT(trace , 2, "strthrd"); 1045 QETH_DBF_TEXT(trace , 2, "strthrd");
1045 1046
1046 if (card->read.state != CH_STATE_UP && 1047 if (card->read.state != CH_STATE_UP &&
@@ -1103,8 +1104,7 @@ qeth_setup_card(struct qeth_card *card)
1103 card->thread_start_mask = 0; 1104 card->thread_start_mask = 0;
1104 card->thread_allowed_mask = 0; 1105 card->thread_allowed_mask = 0;
1105 card->thread_running_mask = 0; 1106 card->thread_running_mask = 0;
1106 INIT_WORK(&card->kernel_thread_starter, 1107 INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread);
1107 (void *)qeth_start_kernel_thread,card);
1108 INIT_LIST_HEAD(&card->ip_list); 1108 INIT_LIST_HEAD(&card->ip_list);
1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL); 1109 card->ip_tbd_list = kmalloc(sizeof(struct list_head), GFP_KERNEL);
1110 if (!card->ip_tbd_list) { 1110 if (!card->ip_tbd_list) {
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 562432d017b0..335a25540c08 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -622,8 +622,10 @@ NCR_700_scsi_done(struct NCR_700_Host_Parameters *hostdata,
622 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 622 dma_unmap_single(hostdata->dev, slot->dma_handle, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
623 /* restore the old result if the request sense was 623 /* restore the old result if the request sense was
624 * successful */ 624 * successful */
625 if(result == 0) 625 if (result == 0)
626 result = cmnd[7]; 626 result = cmnd[7];
627 /* restore the original length */
628 SCp->cmd_len = cmnd[8];
627 } else 629 } else
628 NCR_700_unmap(hostdata, SCp, slot); 630 NCR_700_unmap(hostdata, SCp, slot);
629 631
@@ -1007,6 +1009,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1007 * of the command */ 1009 * of the command */
1008 cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC; 1010 cmnd[6] = NCR_700_INTERNAL_SENSE_MAGIC;
1009 cmnd[7] = hostdata->status[0]; 1011 cmnd[7] = hostdata->status[0];
1012 cmnd[8] = SCp->cmd_len;
1013 SCp->cmd_len = 6; /* command length for
1014 * REQUEST_SENSE */
1010 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE); 1015 slot->pCmd = dma_map_single(hostdata->dev, cmnd, MAX_COMMAND_SIZE, DMA_TO_DEVICE);
1011 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1016 slot->dma_handle = dma_map_single(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1012 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer)); 1017 slot->SG[0].ins = bS_to_host(SCRIPT_MOVE_DATA_IN | sizeof(SCp->sense_buffer));
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index cdd033724786..3075204915c8 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2186,21 +2186,21 @@ static int __init BusLogic_init(void)
2186 2186
2187 if (BusLogic_ProbeOptions.NoProbe) 2187 if (BusLogic_ProbeOptions.NoProbe)
2188 return -ENODEV; 2188 return -ENODEV;
2189 BusLogic_ProbeInfoList = (struct BusLogic_ProbeInfo *) 2189 BusLogic_ProbeInfoList =
2190 kmalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_ATOMIC); 2190 kzalloc(BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo), GFP_KERNEL);
2191 if (BusLogic_ProbeInfoList == NULL) { 2191 if (BusLogic_ProbeInfoList == NULL) {
2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL); 2192 BusLogic_Error("BusLogic: Unable to allocate Probe Info List\n", NULL);
2193 return -ENOMEM; 2193 return -ENOMEM;
2194 } 2194 }
2195 memset(BusLogic_ProbeInfoList, 0, BusLogic_MaxHostAdapters * sizeof(struct BusLogic_ProbeInfo)); 2195
2196 PrototypeHostAdapter = (struct BusLogic_HostAdapter *) 2196 PrototypeHostAdapter =
2197 kmalloc(sizeof(struct BusLogic_HostAdapter), GFP_ATOMIC); 2197 kzalloc(sizeof(struct BusLogic_HostAdapter), GFP_KERNEL);
2198 if (PrototypeHostAdapter == NULL) { 2198 if (PrototypeHostAdapter == NULL) {
2199 kfree(BusLogic_ProbeInfoList); 2199 kfree(BusLogic_ProbeInfoList);
2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL); 2200 BusLogic_Error("BusLogic: Unable to allocate Prototype " "Host Adapter\n", NULL);
2201 return -ENOMEM; 2201 return -ENOMEM;
2202 } 2202 }
2203 memset(PrototypeHostAdapter, 0, sizeof(struct BusLogic_HostAdapter)); 2203
2204#ifdef MODULE 2204#ifdef MODULE
2205 if (BusLogic != NULL) 2205 if (BusLogic != NULL)
2206 BusLogic_Setup(BusLogic); 2206 BusLogic_Setup(BusLogic);
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 9540eb8efdcb..69569096dae5 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -29,6 +29,13 @@ config SCSI
29 However, do not compile this as a module if your root file system 29 However, do not compile this as a module if your root file system
30 (the one containing the directory /) is located on a SCSI device. 30 (the one containing the directory /) is located on a SCSI device.
31 31
32config SCSI_TGT
33 tristate "SCSI target support"
34 depends on SCSI && EXPERIMENTAL
35 ---help---
36 If you want to use SCSI target mode drivers enable this option.
37 If you choose M, the module will be called scsi_tgt.
38
32config SCSI_NETLINK 39config SCSI_NETLINK
33 bool 40 bool
34 default n 41 default n
@@ -216,6 +223,23 @@ config SCSI_LOGGING
216 there should be no noticeable performance impact as long as you have 223 there should be no noticeable performance impact as long as you have
217 logging turned off. 224 logging turned off.
218 225
226config SCSI_SCAN_ASYNC
227 bool "Asynchronous SCSI scanning"
228 depends on SCSI
229 help
230 The SCSI subsystem can probe for devices while the rest of the
231 system continues booting, and even probe devices on different
232 busses in parallel, leading to a significant speed-up.
233 If you have built SCSI as modules, enabling this option can
234 be a problem as the devices may not have been found by the
235 time your system expects them to have been. You can load the
236 scsi_wait_scan module to ensure that all scans have completed.
237 If you build your SCSI drivers into the kernel, then everything
238 will work fine if you say Y here.
239
240 You can override this choice by specifying scsi_mod.scan="sync"
241 or "async" on the kernel's command line.
242
219menu "SCSI Transports" 243menu "SCSI Transports"
220 depends on SCSI 244 depends on SCSI
221 245
@@ -797,6 +821,20 @@ config SCSI_IBMVSCSI
797 To compile this driver as a module, choose M here: the 821 To compile this driver as a module, choose M here: the
798 module will be called ibmvscsic. 822 module will be called ibmvscsic.
799 823
824config SCSI_IBMVSCSIS
825 tristate "IBM Virtual SCSI Server support"
826 depends on PPC_PSERIES && SCSI_TGT && SCSI_SRP
827 help
828 This is the SRP target driver for IBM pSeries virtual environments.
829
830 The userspace component needed to initialize the driver and
831 documentation can be found:
832
833 http://stgt.berlios.de/
834
835 To compile this driver as a module, choose M here: the
836 module will be called ibmvstgt.
837
800config SCSI_INITIO 838config SCSI_INITIO
801 tristate "Initio 9100U(W) support" 839 tristate "Initio 9100U(W) support"
802 depends on PCI && SCSI 840 depends on PCI && SCSI
@@ -944,8 +982,13 @@ config SCSI_STEX
944 tristate "Promise SuperTrak EX Series support" 982 tristate "Promise SuperTrak EX Series support"
945 depends on PCI && SCSI 983 depends on PCI && SCSI
946 ---help--- 984 ---help---
947 This driver supports Promise SuperTrak EX8350/8300/16350/16300 985 This driver supports Promise SuperTrak EX series storage controllers.
948 Storage controllers. 986
987 Promise provides Linux RAID configuration utility for these
988 controllers. Please visit <http://www.promise.com> to download.
989
990 To compile this driver as a module, choose M here: the
991 module will be called stex.
949 992
950config SCSI_SYM53C8XX_2 993config SCSI_SYM53C8XX_2
951 tristate "SYM53C8XX Version 2 SCSI support" 994 tristate "SYM53C8XX Version 2 SCSI support"
@@ -1026,6 +1069,7 @@ config SCSI_IPR
1026config SCSI_IPR_TRACE 1069config SCSI_IPR_TRACE
1027 bool "enable driver internal trace" 1070 bool "enable driver internal trace"
1028 depends on SCSI_IPR 1071 depends on SCSI_IPR
1072 default y
1029 help 1073 help
1030 If you say Y here, the driver will trace all commands issued 1074 If you say Y here, the driver will trace all commands issued
1031 to the adapter. Performance impact is minimal. Trace can be 1075 to the adapter. Performance impact is minimal. Trace can be
@@ -1034,6 +1078,7 @@ config SCSI_IPR_TRACE
1034config SCSI_IPR_DUMP 1078config SCSI_IPR_DUMP
1035 bool "enable adapter dump support" 1079 bool "enable adapter dump support"
1036 depends on SCSI_IPR 1080 depends on SCSI_IPR
1081 default y
1037 help 1082 help
1038 If you say Y here, the driver will support adapter crash dump. 1083 If you say Y here, the driver will support adapter crash dump.
1039 If you enable this support, the iprdump daemon can be used 1084 If you enable this support, the iprdump daemon can be used
@@ -1734,6 +1779,16 @@ config ZFCP
1734 called zfcp. If you want to compile it as a module, say M here 1779 called zfcp. If you want to compile it as a module, say M here
1735 and read <file:Documentation/modules.txt>. 1780 and read <file:Documentation/modules.txt>.
1736 1781
1782config SCSI_SRP
1783 tristate "SCSI RDMA Protocol helper library"
1784 depends on SCSI && PCI
1785 select SCSI_TGT
1786 help
1787 If you wish to use SRP target drivers, say Y.
1788
1789 To compile this driver as a module, choose M here: the
1790 module will be called libsrp.
1791
1737endmenu 1792endmenu
1738 1793
1739source "drivers/scsi/pcmcia/Kconfig" 1794source "drivers/scsi/pcmcia/Kconfig"
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index bcca39c3bcbf..bd7c9888f7f4 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -21,6 +21,7 @@ CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
21subdir-$(CONFIG_PCMCIA) += pcmcia 21subdir-$(CONFIG_PCMCIA) += pcmcia
22 22
23obj-$(CONFIG_SCSI) += scsi_mod.o 23obj-$(CONFIG_SCSI) += scsi_mod.o
24obj-$(CONFIG_SCSI_TGT) += scsi_tgt.o
24 25
25obj-$(CONFIG_RAID_ATTRS) += raid_class.o 26obj-$(CONFIG_RAID_ATTRS) += raid_class.o
26 27
@@ -125,7 +126,9 @@ obj-$(CONFIG_SCSI_FCAL) += fcal.o
125obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o 126obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
126obj-$(CONFIG_SCSI_NSP32) += nsp32.o 127obj-$(CONFIG_SCSI_NSP32) += nsp32.o
127obj-$(CONFIG_SCSI_IPR) += ipr.o 128obj-$(CONFIG_SCSI_IPR) += ipr.o
129obj-$(CONFIG_SCSI_SRP) += libsrp.o
128obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ 130obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
131obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/
129obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o 132obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
130obj-$(CONFIG_SCSI_STEX) += stex.o 133obj-$(CONFIG_SCSI_STEX) += stex.o
131 134
@@ -141,6 +144,8 @@ obj-$(CONFIG_CHR_DEV_SCH) += ch.o
141# This goes last, so that "real" scsi devices probe earlier 144# This goes last, so that "real" scsi devices probe earlier
142obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o 145obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
143 146
147obj-$(CONFIG_SCSI) += scsi_wait_scan.o
148
144scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ 149scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
145 scsicam.o scsi_error.o scsi_lib.o \ 150 scsicam.o scsi_error.o scsi_lib.o \
146 scsi_scan.o scsi_sysfs.o \ 151 scsi_scan.o scsi_sysfs.o \
@@ -149,6 +154,8 @@ scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
149scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o 154scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
150scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o 155scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
151 156
157scsi_tgt-y += scsi_tgt_lib.o scsi_tgt_if.o
158
152sd_mod-objs := sd.o 159sd_mod-objs := sd.o
153sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o 160sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
154ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \ 161ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index a6aa91072880..bb3cb3360541 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -849,7 +849,7 @@ static int __devinit NCR5380_init(struct Scsi_Host *instance, int flags)
849 hostdata->issue_queue = NULL; 849 hostdata->issue_queue = NULL;
850 hostdata->disconnected_queue = NULL; 850 hostdata->disconnected_queue = NULL;
851 851
852 INIT_WORK(&hostdata->coroutine, NCR5380_main, hostdata); 852 INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);
853 853
854#ifdef NCR5380_STATS 854#ifdef NCR5380_STATS
855 for (i = 0; i < 8; ++i) { 855 for (i = 0; i < 8; ++i) {
@@ -1016,7 +1016,7 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1016 1016
1017 /* Run the coroutine if it isn't already running. */ 1017 /* Run the coroutine if it isn't already running. */
1018 /* Kick off command processing */ 1018 /* Kick off command processing */
1019 schedule_work(&hostdata->coroutine); 1019 schedule_delayed_work(&hostdata->coroutine, 0);
1020 return 0; 1020 return 0;
1021} 1021}
1022 1022
@@ -1033,9 +1033,10 @@ static int NCR5380_queue_command(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
1033 * host lock and called routines may take the isa dma lock. 1033 * host lock and called routines may take the isa dma lock.
1034 */ 1034 */
1035 1035
1036static void NCR5380_main(void *p) 1036static void NCR5380_main(struct work_struct *work)
1037{ 1037{
1038 struct NCR5380_hostdata *hostdata = p; 1038 struct NCR5380_hostdata *hostdata =
1039 container_of(work, struct NCR5380_hostdata, coroutine.work);
1039 struct Scsi_Host *instance = hostdata->host; 1040 struct Scsi_Host *instance = hostdata->host;
1040 Scsi_Cmnd *tmp, *prev; 1041 Scsi_Cmnd *tmp, *prev;
1041 int done; 1042 int done;
@@ -1221,7 +1222,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id)
1221 } /* if BASR_IRQ */ 1222 } /* if BASR_IRQ */
1222 spin_unlock_irqrestore(instance->host_lock, flags); 1223 spin_unlock_irqrestore(instance->host_lock, flags);
1223 if(!done) 1224 if(!done)
1224 schedule_work(&hostdata->coroutine); 1225 schedule_delayed_work(&hostdata->coroutine, 0);
1225 } while (!done); 1226 } while (!done);
1226 return IRQ_HANDLED; 1227 return IRQ_HANDLED;
1227} 1228}
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 1bc73de496b0..713a108c02ef 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -271,7 +271,7 @@ struct NCR5380_hostdata {
271 unsigned long time_expires; /* in jiffies, set prior to sleeping */ 271 unsigned long time_expires; /* in jiffies, set prior to sleeping */
272 int select_time; /* timer in select for target response */ 272 int select_time; /* timer in select for target response */
273 volatile Scsi_Cmnd *selecting; 273 volatile Scsi_Cmnd *selecting;
274 struct work_struct coroutine; /* our co-routine */ 274 struct delayed_work coroutine; /* our co-routine */
275#ifdef NCR5380_STATS 275#ifdef NCR5380_STATS
276 unsigned timebase; /* Base for time calcs */ 276 unsigned timebase; /* Base for time calcs */
277 long time_read[8]; /* time to do reads */ 277 long time_read[8]; /* time to do reads */
@@ -298,7 +298,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance);
298#ifndef DONT_USE_INTR 298#ifndef DONT_USE_INTR
299static irqreturn_t NCR5380_intr(int irq, void *dev_id); 299static irqreturn_t NCR5380_intr(int irq, void *dev_id);
300#endif 300#endif
301static void NCR5380_main(void *ptr); 301static void NCR5380_main(struct work_struct *work);
302static void NCR5380_print_options(struct Scsi_Host *instance); 302static void NCR5380_print_options(struct Scsi_Host *instance);
303#ifdef NDEBUG 303#ifdef NDEBUG
304static void NCR5380_print_phase(struct Scsi_Host *instance); 304static void NCR5380_print_phase(struct Scsi_Host *instance);
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index d4613815f685..8578555d58fd 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -220,9 +220,11 @@ static void *addresses[] = {
220static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 }; 220static unsigned short ports[] = { 0x230, 0x330, 0x280, 0x290, 0x330, 0x340, 0x300, 0x310, 0x348, 0x350 };
221#define PORT_COUNT ARRAY_SIZE(ports) 221#define PORT_COUNT ARRAY_SIZE(ports)
222 222
223#ifndef MODULE
223/* possible interrupt channels */ 224/* possible interrupt channels */
224static unsigned short intrs[] = { 10, 11, 12, 15 }; 225static unsigned short intrs[] = { 10, 11, 12, 15 };
225#define INTR_COUNT ARRAY_SIZE(intrs) 226#define INTR_COUNT ARRAY_SIZE(intrs)
227#endif /* !MODULE */
226 228
227/* signatures for NCR 53c406a based controllers */ 229/* signatures for NCR 53c406a based controllers */
228#if USE_BIOS 230#if USE_BIOS
@@ -605,6 +607,7 @@ static int NCR53c406a_release(struct Scsi_Host *shost)
605 return 0; 607 return 0;
606} 608}
607 609
610#ifndef MODULE
608/* called from init/main.c */ 611/* called from init/main.c */
609static int __init NCR53c406a_setup(char *str) 612static int __init NCR53c406a_setup(char *str)
610{ 613{
@@ -661,6 +664,8 @@ static int __init NCR53c406a_setup(char *str)
661 664
662__setup("ncr53c406a=", NCR53c406a_setup); 665__setup("ncr53c406a=", NCR53c406a_setup);
663 666
667#endif /* !MODULE */
668
664static const char *NCR53c406a_info(struct Scsi_Host *SChost) 669static const char *NCR53c406a_info(struct Scsi_Host *SChost)
665{ 670{
666 DEB(printk("NCR53c406a_info called\n")); 671 DEB(printk("NCR53c406a_info called\n"));
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index eb3ed91bac79..4f8b4c53d435 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -11,8 +11,8 @@
11 *----------------------------------------------------------------------------*/ 11 *----------------------------------------------------------------------------*/
12 12
13#ifndef AAC_DRIVER_BUILD 13#ifndef AAC_DRIVER_BUILD
14# define AAC_DRIVER_BUILD 2409 14# define AAC_DRIVER_BUILD 2423
15# define AAC_DRIVER_BRANCH "-mh2" 15# define AAC_DRIVER_BRANCH "-mh3"
16#endif 16#endif
17#define MAXIMUM_NUM_CONTAINERS 32 17#define MAXIMUM_NUM_CONTAINERS 32
18 18
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 19e42ac07cb2..4893a6d06a33 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -518,6 +518,7 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
518 */ 518 */
519 unsigned long count = 36000000L; /* 3 minutes */ 519 unsigned long count = 36000000L; /* 3 minutes */
520 while (down_trylock(&fibptr->event_wait)) { 520 while (down_trylock(&fibptr->event_wait)) {
521 int blink;
521 if (--count == 0) { 522 if (--count == 0) {
522 spin_lock_irqsave(q->lock, qflags); 523 spin_lock_irqsave(q->lock, qflags);
523 q->numpending--; 524 q->numpending--;
@@ -530,6 +531,14 @@ int aac_fib_send(u16 command, struct fib *fibptr, unsigned long size,
530 } 531 }
531 return -ETIMEDOUT; 532 return -ETIMEDOUT;
532 } 533 }
534 if ((blink = aac_adapter_check_health(dev)) > 0) {
535 if (wait == -1) {
536 printk(KERN_ERR "aacraid: aac_fib_send: adapter blinkLED 0x%x.\n"
537 "Usually a result of a serious unrecoverable hardware problem\n",
538 blink);
539 }
540 return -EFAULT;
541 }
533 udelay(5); 542 udelay(5);
534 } 543 }
535 } else if (down_interruptible(&fibptr->event_wait)) { 544 } else if (down_interruptible(&fibptr->event_wait)) {
@@ -1093,6 +1102,20 @@ static int _aac_reset_adapter(struct aac_dev *aac)
1093 goto out; 1102 goto out;
1094 } 1103 }
1095 1104
1105 /*
1106 * Loop through the fibs, close the synchronous FIBS
1107 */
1108 for (index = 0; index < (aac->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB); index++) {
1109 struct fib *fib = &aac->fibs[index];
1110 if (!(fib->hw_fib->header.XferState & cpu_to_le32(NoResponseExpected | Async)) &&
1111 (fib->hw_fib->header.XferState & cpu_to_le32(ResponseExpected))) {
1112 unsigned long flagv;
1113 spin_lock_irqsave(&fib->event_lock, flagv);
1114 up(&fib->event_wait);
1115 spin_unlock_irqrestore(&fib->event_lock, flagv);
1116 schedule();
1117 }
1118 }
1096 index = aac->cardtype; 1119 index = aac->cardtype;
1097 1120
1098 /* 1121 /*
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 306f46b85a55..0cec742d12e9 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1443,7 +1443,7 @@ static struct work_struct aha152x_tq;
1443 * Run service completions on the card with interrupts enabled. 1443 * Run service completions on the card with interrupts enabled.
1444 * 1444 *
1445 */ 1445 */
1446static void run(void) 1446static void run(struct work_struct *work)
1447{ 1447{
1448 struct aha152x_hostdata *hd; 1448 struct aha152x_hostdata *hd;
1449 1449
@@ -1499,7 +1499,7 @@ static irqreturn_t intr(int irqno, void *dev_id)
1499 HOSTDATA(shpnt)->service=1; 1499 HOSTDATA(shpnt)->service=1;
1500 1500
1501 /* Poke the BH handler */ 1501 /* Poke the BH handler */
1502 INIT_WORK(&aha152x_tq, (void *) run, NULL); 1502 INIT_WORK(&aha152x_tq, run);
1503 schedule_work(&aha152x_tq); 1503 schedule_work(&aha152x_tq);
1504 } 1504 }
1505 DO_UNLOCK(flags); 1505 DO_UNLOCK(flags);
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index c3c38a7e8d32..d7af9c63a04d 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -586,7 +586,7 @@ static struct scsi_host_template aha1740_template = {
586 586
587static int aha1740_probe (struct device *dev) 587static int aha1740_probe (struct device *dev)
588{ 588{
589 int slotbase; 589 int slotbase, rc;
590 unsigned int irq_level, irq_type, translation; 590 unsigned int irq_level, irq_type, translation;
591 struct Scsi_Host *shpnt; 591 struct Scsi_Host *shpnt;
592 struct aha1740_hostdata *host; 592 struct aha1740_hostdata *host;
@@ -641,10 +641,16 @@ static int aha1740_probe (struct device *dev)
641 } 641 }
642 642
643 eisa_set_drvdata (edev, shpnt); 643 eisa_set_drvdata (edev, shpnt);
644 scsi_add_host (shpnt, dev); /* XXX handle failure */ 644
645 rc = scsi_add_host (shpnt, dev);
646 if (rc)
647 goto err_irq;
648
645 scsi_scan_host (shpnt); 649 scsi_scan_host (shpnt);
646 return 0; 650 return 0;
647 651
652 err_irq:
653 free_irq(irq_level, shpnt);
648 err_unmap: 654 err_unmap:
649 dma_unmap_single (&edev->dev, host->ecb_dma_addr, 655 dma_unmap_single (&edev->dev, host->ecb_dma_addr,
650 sizeof (host->ecb), DMA_BIDIRECTIONAL); 656 sizeof (host->ecb), DMA_BIDIRECTIONAL);
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
index 2001fe890e71..1a3ab6aa856b 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -62,6 +62,7 @@ static struct pci_device_id ahd_linux_pci_id_table[] = {
62 /* aic7901 based controllers */ 62 /* aic7901 based controllers */
63 ID(ID_AHA_29320A), 63 ID(ID_AHA_29320A),
64 ID(ID_AHA_29320ALP), 64 ID(ID_AHA_29320ALP),
65 ID(ID_AHA_29320LPE),
65 /* aic7902 based controllers */ 66 /* aic7902 based controllers */
66 ID(ID_AHA_29320), 67 ID(ID_AHA_29320),
67 ID(ID_AHA_29320B), 68 ID(ID_AHA_29320B),
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
index c07735819cd1..2cf7bb3123f0 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.c
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
@@ -109,7 +109,13 @@ static struct ahd_pci_identity ahd_pci_ident_table [] =
109 { 109 {
110 ID_AHA_29320ALP, 110 ID_AHA_29320ALP,
111 ID_ALL_MASK, 111 ID_ALL_MASK,
112 "Adaptec 29320ALP Ultra320 SCSI adapter", 112 "Adaptec 29320ALP PCIx Ultra320 SCSI adapter",
113 ahd_aic7901_setup
114 },
115 {
116 ID_AHA_29320LPE,
117 ID_ALL_MASK,
118 "Adaptec 29320LPE PCIe Ultra320 SCSI adapter",
113 ahd_aic7901_setup 119 ahd_aic7901_setup
114 }, 120 },
115 /* aic7901A based controllers */ 121 /* aic7901A based controllers */
diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.h b/drivers/scsi/aic7xxx/aic79xx_pci.h
index da45153668c7..16b7c70a673c 100644
--- a/drivers/scsi/aic7xxx/aic79xx_pci.h
+++ b/drivers/scsi/aic7xxx/aic79xx_pci.h
@@ -51,6 +51,7 @@
51#define ID_AIC7901 0x800F9005FFFF9005ull 51#define ID_AIC7901 0x800F9005FFFF9005ull
52#define ID_AHA_29320A 0x8000900500609005ull 52#define ID_AHA_29320A 0x8000900500609005ull
53#define ID_AHA_29320ALP 0x8017900500449005ull 53#define ID_AHA_29320ALP 0x8017900500449005ull
54#define ID_AHA_29320LPE 0x8017900500459005ull
54 55
55#define ID_AIC7901A 0x801E9005FFFF9005ull 56#define ID_AIC7901A 0x801E9005FFFF9005ull
56#define ID_AHA_29320LP 0x8014900500449005ull 57#define ID_AHA_29320LP 0x8014900500449005ull
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 57c5ba4043f2..42302ef05ee5 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -724,6 +724,15 @@ static void asd_free_queues(struct asd_ha_struct *asd_ha)
724 724
725 list_for_each_safe(pos, n, &pending) { 725 list_for_each_safe(pos, n, &pending) {
726 struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list); 726 struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list);
727 /*
728 * Delete unexpired ascb timers. This may happen if we issue
729 * a CONTROL PHY scb to an adapter and rmmod before the scb
730 * times out. Apparently we don't wait for the CONTROL PHY
731 * to complete, so it doesn't matter if we kill the timer.
732 */
733 del_timer_sync(&ascb->timer);
734 WARN_ON(ascb->scb->header.opcode != CONTROL_PHY);
735
727 list_del_init(pos); 736 list_del_init(pos);
728 ASD_DPRINTK("freeing from pending\n"); 737 ASD_DPRINTK("freeing from pending\n");
729 asd_ascb_free(ascb); 738 asd_ascb_free(ascb);
diff --git a/drivers/scsi/aic94xx/aic94xx_scb.c b/drivers/scsi/aic94xx/aic94xx_scb.c
index b15caf1c8fa2..75ed6b0569d1 100644
--- a/drivers/scsi/aic94xx/aic94xx_scb.c
+++ b/drivers/scsi/aic94xx/aic94xx_scb.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/pci.h> 27#include <linux/pci.h>
28#include <scsi/scsi_host.h>
28 29
29#include "aic94xx.h" 30#include "aic94xx.h"
30#include "aic94xx_reg.h" 31#include "aic94xx_reg.h"
@@ -412,6 +413,40 @@ void asd_invalidate_edb(struct asd_ascb *ascb, int edb_id)
412 } 413 }
413} 414}
414 415
416/* hard reset a phy later */
417static void do_phy_reset_later(struct work_struct *work)
418{
419 struct sas_phy *sas_phy =
420 container_of(work, struct sas_phy, reset_work);
421 int error;
422
423 ASD_DPRINTK("%s: About to hard reset phy %d\n", __FUNCTION__,
424 sas_phy->identify.phy_identifier);
425 /* Reset device port */
426 error = sas_phy_reset(sas_phy, 1);
427 if (error)
428 ASD_DPRINTK("%s: Hard reset of phy %d failed (%d).\n",
429 __FUNCTION__, sas_phy->identify.phy_identifier, error);
430}
431
432static void phy_reset_later(struct sas_phy *sas_phy, struct Scsi_Host *shost)
433{
434 INIT_WORK(&sas_phy->reset_work, do_phy_reset_later);
435 queue_work(shost->work_q, &sas_phy->reset_work);
436}
437
438/* start up the ABORT TASK tmf... */
439static void task_kill_later(struct asd_ascb *ascb)
440{
441 struct asd_ha_struct *asd_ha = ascb->ha;
442 struct sas_ha_struct *sas_ha = &asd_ha->sas_ha;
443 struct Scsi_Host *shost = sas_ha->core.shost;
444 struct sas_task *task = ascb->uldd_task;
445
446 INIT_WORK(&task->abort_work, sas_task_abort);
447 queue_work(shost->work_q, &task->abort_work);
448}
449
415static void escb_tasklet_complete(struct asd_ascb *ascb, 450static void escb_tasklet_complete(struct asd_ascb *ascb,
416 struct done_list_struct *dl) 451 struct done_list_struct *dl)
417{ 452{
@@ -439,6 +474,74 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
439 ascb->scb->header.opcode); 474 ascb->scb->header.opcode);
440 } 475 }
441 476
477 /* Catch these before we mask off the sb_opcode bits */
478 switch (sb_opcode) {
479 case REQ_TASK_ABORT: {
480 struct asd_ascb *a, *b;
481 u16 tc_abort;
482
483 tc_abort = *((u16*)(&dl->status_block[1]));
484 tc_abort = le16_to_cpu(tc_abort);
485
486 ASD_DPRINTK("%s: REQ_TASK_ABORT, reason=0x%X\n",
487 __FUNCTION__, dl->status_block[3]);
488
489 /* Find the pending task and abort it. */
490 list_for_each_entry_safe(a, b, &asd_ha->seq.pend_q, list)
491 if (a->tc_index == tc_abort) {
492 task_kill_later(a);
493 break;
494 }
495 goto out;
496 }
497 case REQ_DEVICE_RESET: {
498 struct Scsi_Host *shost = sas_ha->core.shost;
499 struct sas_phy *dev_phy;
500 struct asd_ascb *a;
501 u16 conn_handle;
502
503 conn_handle = *((u16*)(&dl->status_block[1]));
504 conn_handle = le16_to_cpu(conn_handle);
505
506 ASD_DPRINTK("%s: REQ_DEVICE_RESET, reason=0x%X\n", __FUNCTION__,
507 dl->status_block[3]);
508
509 /* Kill all pending tasks and reset the device */
510 dev_phy = NULL;
511 list_for_each_entry(a, &asd_ha->seq.pend_q, list) {
512 struct sas_task *task;
513 struct domain_device *dev;
514 u16 x;
515
516 task = a->uldd_task;
517 if (!task)
518 continue;
519 dev = task->dev;
520
521 x = (unsigned long)dev->lldd_dev;
522 if (x == conn_handle) {
523 dev_phy = dev->port->phy;
524 task_kill_later(a);
525 }
526 }
527
528 /* Reset device port */
529 if (!dev_phy) {
530 ASD_DPRINTK("%s: No pending commands; can't reset.\n",
531 __FUNCTION__);
532 goto out;
533 }
534 phy_reset_later(dev_phy, shost);
535 goto out;
536 }
537 case SIGNAL_NCQ_ERROR:
538 ASD_DPRINTK("%s: SIGNAL_NCQ_ERROR\n", __FUNCTION__);
539 goto out;
540 case CLEAR_NCQ_ERROR:
541 ASD_DPRINTK("%s: CLEAR_NCQ_ERROR\n", __FUNCTION__);
542 goto out;
543 }
544
442 sb_opcode &= ~DL_PHY_MASK; 545 sb_opcode &= ~DL_PHY_MASK;
443 546
444 switch (sb_opcode) { 547 switch (sb_opcode) {
@@ -469,22 +572,6 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
469 asd_deform_port(asd_ha, phy); 572 asd_deform_port(asd_ha, phy);
470 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT); 573 sas_ha->notify_port_event(sas_phy, PORTE_TIMER_EVENT);
471 break; 574 break;
472 case REQ_TASK_ABORT:
473 ASD_DPRINTK("%s: phy%d: REQ_TASK_ABORT\n", __FUNCTION__,
474 phy_id);
475 break;
476 case REQ_DEVICE_RESET:
477 ASD_DPRINTK("%s: phy%d: REQ_DEVICE_RESET\n", __FUNCTION__,
478 phy_id);
479 break;
480 case SIGNAL_NCQ_ERROR:
481 ASD_DPRINTK("%s: phy%d: SIGNAL_NCQ_ERROR\n", __FUNCTION__,
482 phy_id);
483 break;
484 case CLEAR_NCQ_ERROR:
485 ASD_DPRINTK("%s: phy%d: CLEAR_NCQ_ERROR\n", __FUNCTION__,
486 phy_id);
487 break;
488 default: 575 default:
489 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__, 576 ASD_DPRINTK("%s: phy%d: unknown event:0x%x\n", __FUNCTION__,
490 phy_id, sb_opcode); 577 phy_id, sb_opcode);
@@ -504,7 +591,7 @@ static void escb_tasklet_complete(struct asd_ascb *ascb,
504 591
505 break; 592 break;
506 } 593 }
507 594out:
508 asd_invalidate_edb(ascb, edb); 595 asd_invalidate_edb(ascb, edb);
509} 596}
510 597
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index ef8285c326e4..668569e8856b 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -294,6 +294,7 @@ static struct Scsi_Host *hosts[FD_MAX_HOSTS + 1] = { NULL };
294static int user_fifo_count = 0; 294static int user_fifo_count = 0;
295static int user_fifo_size = 0; 295static int user_fifo_size = 0;
296 296
297#ifndef MODULE
297static int __init fd_mcs_setup(char *str) 298static int __init fd_mcs_setup(char *str)
298{ 299{
299 static int done_setup = 0; 300 static int done_setup = 0;
@@ -311,6 +312,7 @@ static int __init fd_mcs_setup(char *str)
311} 312}
312 313
313__setup("fd_mcs=", fd_mcs_setup); 314__setup("fd_mcs=", fd_mcs_setup);
315#endif /* !MODULE */
314 316
315static void print_banner(struct Scsi_Host *shpnt) 317static void print_banner(struct Scsi_Host *shpnt)
316{ 318{
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 68ef1636678d..38c3a291efac 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -263,6 +263,10 @@ static void scsi_host_dev_release(struct device *dev)
263 kthread_stop(shost->ehandler); 263 kthread_stop(shost->ehandler);
264 if (shost->work_q) 264 if (shost->work_q)
265 destroy_workqueue(shost->work_q); 265 destroy_workqueue(shost->work_q);
266 if (shost->uspace_req_q) {
267 kfree(shost->uspace_req_q->queuedata);
268 scsi_free_queue(shost->uspace_req_q);
269 }
266 270
267 scsi_destroy_command_freelist(shost); 271 scsi_destroy_command_freelist(shost);
268 if (shost->bqt) 272 if (shost->bqt)
@@ -301,8 +305,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
301 if (!shost) 305 if (!shost)
302 return NULL; 306 return NULL;
303 307
304 spin_lock_init(&shost->default_lock); 308 shost->host_lock = &shost->default_lock;
305 scsi_assign_lock(shost, &shost->default_lock); 309 spin_lock_init(shost->host_lock);
306 shost->shost_state = SHOST_CREATED; 310 shost->shost_state = SHOST_CREATED;
307 INIT_LIST_HEAD(&shost->__devices); 311 INIT_LIST_HEAD(&shost->__devices);
308 INIT_LIST_HEAD(&shost->__targets); 312 INIT_LIST_HEAD(&shost->__targets);
diff --git a/drivers/scsi/ibmvscsi/Makefile b/drivers/scsi/ibmvscsi/Makefile
index 4e247b6b8700..6ac0633d5452 100644
--- a/drivers/scsi/ibmvscsi/Makefile
+++ b/drivers/scsi/ibmvscsi/Makefile
@@ -3,3 +3,5 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsic.o
3ibmvscsic-y += ibmvscsi.o 3ibmvscsic-y += ibmvscsi.o
4ibmvscsic-$(CONFIG_PPC_ISERIES) += iseries_vscsi.o 4ibmvscsic-$(CONFIG_PPC_ISERIES) += iseries_vscsi.o
5ibmvscsic-$(CONFIG_PPC_PSERIES) += rpa_vscsi.o 5ibmvscsic-$(CONFIG_PPC_PSERIES) += rpa_vscsi.o
6
7obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvstgt.o
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
new file mode 100644
index 000000000000..e28260f05d6b
--- /dev/null
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -0,0 +1,960 @@
1/*
2 * IBM eServer i/pSeries Virtual SCSI Target Driver
3 * Copyright (C) 2003-2005 Dave Boutcher (boutcher@us.ibm.com) IBM Corp.
4 * Santiago Leon (santil@us.ibm.com) IBM Corp.
5 * Linda Xie (lxie@us.ibm.com) IBM Corp.
6 *
7 * Copyright (C) 2005-2006 FUJITA Tomonori <tomof@acm.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 */
24#include <linux/interrupt.h>
25#include <linux/module.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_host.h>
28#include <scsi/scsi_tgt.h>
29#include <scsi/libsrp.h>
30#include <asm/hvcall.h>
31#include <asm/iommu.h>
32#include <asm/prom.h>
33#include <asm/vio.h>
34
35#include "ibmvscsi.h"
36
37#define INITIAL_SRP_LIMIT 16
38#define DEFAULT_MAX_SECTORS 512
39
40#define TGT_NAME "ibmvstgt"
41
42/*
43 * Hypervisor calls.
44 */
45#define h_copy_rdma(l, sa, sb, da, db) \
46 plpar_hcall_norets(H_COPY_RDMA, l, sa, sb, da, db)
47#define h_send_crq(ua, l, h) \
48 plpar_hcall_norets(H_SEND_CRQ, ua, l, h)
49#define h_reg_crq(ua, tok, sz)\
50 plpar_hcall_norets(H_REG_CRQ, ua, tok, sz);
51#define h_free_crq(ua) \
52 plpar_hcall_norets(H_FREE_CRQ, ua);
53
54/* tmp - will replace with SCSI logging stuff */
55#define eprintk(fmt, args...) \
56do { \
57 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
58} while (0)
59/* #define dprintk eprintk */
60#define dprintk(fmt, args...)
61
62struct vio_port {
63 struct vio_dev *dma_dev;
64
65 struct crq_queue crq_queue;
66 struct work_struct crq_work;
67
68 unsigned long liobn;
69 unsigned long riobn;
70 struct srp_target *target;
71};
72
73static struct workqueue_struct *vtgtd;
74
75/*
76 * These are fixed for the system and come from the Open Firmware device tree.
77 * We just store them here to save getting them every time.
78 */
79static char system_id[64] = "";
80static char partition_name[97] = "UNKNOWN";
81static unsigned int partition_number = -1;
82
83static struct vio_port *target_to_port(struct srp_target *target)
84{
85 return (struct vio_port *) target->ldata;
86}
87
88static inline union viosrp_iu *vio_iu(struct iu_entry *iue)
89{
90 return (union viosrp_iu *) (iue->sbuf->buf);
91}
92
93static int send_iu(struct iu_entry *iue, uint64_t length, uint8_t format)
94{
95 struct srp_target *target = iue->target;
96 struct vio_port *vport = target_to_port(target);
97 long rc, rc1;
98 union {
99 struct viosrp_crq cooked;
100 uint64_t raw[2];
101 } crq;
102
103 /* First copy the SRP */
104 rc = h_copy_rdma(length, vport->liobn, iue->sbuf->dma,
105 vport->riobn, iue->remote_token);
106
107 if (rc)
108 eprintk("Error %ld transferring data\n", rc);
109
110 crq.cooked.valid = 0x80;
111 crq.cooked.format = format;
112 crq.cooked.reserved = 0x00;
113 crq.cooked.timeout = 0x00;
114 crq.cooked.IU_length = length;
115 crq.cooked.IU_data_ptr = vio_iu(iue)->srp.rsp.tag;
116
117 if (rc == 0)
118 crq.cooked.status = 0x99; /* Just needs to be non-zero */
119 else
120 crq.cooked.status = 0x00;
121
122 rc1 = h_send_crq(vport->dma_dev->unit_address, crq.raw[0], crq.raw[1]);
123
124 if (rc1) {
125 eprintk("%ld sending response\n", rc1);
126 return rc1;
127 }
128
129 return rc;
130}
131
132#define SRP_RSP_SENSE_DATA_LEN 18
133
134static int send_rsp(struct iu_entry *iue, struct scsi_cmnd *sc,
135 unsigned char status, unsigned char asc)
136{
137 union viosrp_iu *iu = vio_iu(iue);
138 uint64_t tag = iu->srp.rsp.tag;
139
140 /* If the linked bit is on and status is good */
141 if (test_bit(V_LINKED, &iue->flags) && (status == NO_SENSE))
142 status = 0x10;
143
144 memset(iu, 0, sizeof(struct srp_rsp));
145 iu->srp.rsp.opcode = SRP_RSP;
146 iu->srp.rsp.req_lim_delta = 1;
147 iu->srp.rsp.tag = tag;
148
149 if (test_bit(V_DIOVER, &iue->flags))
150 iu->srp.rsp.flags |= SRP_RSP_FLAG_DIOVER;
151
152 iu->srp.rsp.data_in_res_cnt = 0;
153 iu->srp.rsp.data_out_res_cnt = 0;
154
155 iu->srp.rsp.flags &= ~SRP_RSP_FLAG_RSPVALID;
156
157 iu->srp.rsp.resp_data_len = 0;
158 iu->srp.rsp.status = status;
159 if (status) {
160 uint8_t *sense = iu->srp.rsp.data;
161
162 if (sc) {
163 iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID;
164 iu->srp.rsp.sense_data_len = SCSI_SENSE_BUFFERSIZE;
165 memcpy(sense, sc->sense_buffer, SCSI_SENSE_BUFFERSIZE);
166 } else {
167 iu->srp.rsp.status = SAM_STAT_CHECK_CONDITION;
168 iu->srp.rsp.flags |= SRP_RSP_FLAG_SNSVALID;
169 iu->srp.rsp.sense_data_len = SRP_RSP_SENSE_DATA_LEN;
170
171 /* Valid bit and 'current errors' */
172 sense[0] = (0x1 << 7 | 0x70);
173 /* Sense key */
174 sense[2] = status;
175 /* Additional sense length */
176 sense[7] = 0xa; /* 10 bytes */
177 /* Additional sense code */
178 sense[12] = asc;
179 }
180 }
181
182 send_iu(iue, sizeof(iu->srp.rsp) + SRP_RSP_SENSE_DATA_LEN,
183 VIOSRP_SRP_FORMAT);
184
185 return 0;
186}
187
188static void handle_cmd_queue(struct srp_target *target)
189{
190 struct Scsi_Host *shost = target->shost;
191 struct iu_entry *iue;
192 struct srp_cmd *cmd;
193 unsigned long flags;
194 int err;
195
196retry:
197 spin_lock_irqsave(&target->lock, flags);
198
199 list_for_each_entry(iue, &target->cmd_queue, ilist) {
200 if (!test_and_set_bit(V_FLYING, &iue->flags)) {
201 spin_unlock_irqrestore(&target->lock, flags);
202 cmd = iue->sbuf->buf;
203 err = srp_cmd_queue(shost, cmd, iue, 0);
204 if (err) {
205 eprintk("cannot queue cmd %p %d\n", cmd, err);
206 srp_iu_put(iue);
207 }
208 goto retry;
209 }
210 }
211
212 spin_unlock_irqrestore(&target->lock, flags);
213}
214
215static int ibmvstgt_rdma(struct scsi_cmnd *sc, struct scatterlist *sg, int nsg,
216 struct srp_direct_buf *md, int nmd,
217 enum dma_data_direction dir, unsigned int rest)
218{
219 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
220 struct srp_target *target = iue->target;
221 struct vio_port *vport = target_to_port(target);
222 dma_addr_t token;
223 long err;
224 unsigned int done = 0;
225 int i, sidx, soff;
226
227 sidx = soff = 0;
228 token = sg_dma_address(sg + sidx);
229
230 for (i = 0; i < nmd && rest; i++) {
231 unsigned int mdone, mlen;
232
233 mlen = min(rest, md[i].len);
234 for (mdone = 0; mlen;) {
235 int slen = min(sg_dma_len(sg + sidx) - soff, mlen);
236
237 if (dir == DMA_TO_DEVICE)
238 err = h_copy_rdma(slen,
239 vport->riobn,
240 md[i].va + mdone,
241 vport->liobn,
242 token + soff);
243 else
244 err = h_copy_rdma(slen,
245 vport->liobn,
246 token + soff,
247 vport->riobn,
248 md[i].va + mdone);
249
250 if (err != H_SUCCESS) {
251 eprintk("rdma error %d %d\n", dir, slen);
252 goto out;
253 }
254
255 mlen -= slen;
256 mdone += slen;
257 soff += slen;
258 done += slen;
259
260 if (soff == sg_dma_len(sg + sidx)) {
261 sidx++;
262 soff = 0;
263 token = sg_dma_address(sg + sidx);
264
265 if (sidx > nsg) {
266 eprintk("out of sg %p %d %d\n",
267 iue, sidx, nsg);
268 goto out;
269 }
270 }
271 };
272
273 rest -= mlen;
274 }
275out:
276
277 return 0;
278}
279
280static int ibmvstgt_transfer_data(struct scsi_cmnd *sc,
281 void (*done)(struct scsi_cmnd *))
282{
283 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
284 int err;
285
286 err = srp_transfer_data(sc, &vio_iu(iue)->srp.cmd, ibmvstgt_rdma, 1, 1);
287
288 done(sc);
289
290 return err;
291}
292
293static int ibmvstgt_cmd_done(struct scsi_cmnd *sc,
294 void (*done)(struct scsi_cmnd *))
295{
296 unsigned long flags;
297 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
298 struct srp_target *target = iue->target;
299
300 dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]);
301
302 spin_lock_irqsave(&target->lock, flags);
303 list_del(&iue->ilist);
304 spin_unlock_irqrestore(&target->lock, flags);
305
306 if (sc->result != SAM_STAT_GOOD) {
307 eprintk("operation failed %p %d %x\n",
308 iue, sc->result, vio_iu(iue)->srp.cmd.cdb[0]);
309 send_rsp(iue, sc, HARDWARE_ERROR, 0x00);
310 } else
311 send_rsp(iue, sc, NO_SENSE, 0x00);
312
313 done(sc);
314 srp_iu_put(iue);
315 return 0;
316}
317
318int send_adapter_info(struct iu_entry *iue,
319 dma_addr_t remote_buffer, uint16_t length)
320{
321 struct srp_target *target = iue->target;
322 struct vio_port *vport = target_to_port(target);
323 struct Scsi_Host *shost = target->shost;
324 dma_addr_t data_token;
325 struct mad_adapter_info_data *info;
326 int err;
327
328 info = dma_alloc_coherent(target->dev, sizeof(*info), &data_token,
329 GFP_KERNEL);
330 if (!info) {
331 eprintk("bad dma_alloc_coherent %p\n", target);
332 return 1;
333 }
334
335 /* Get remote info */
336 err = h_copy_rdma(sizeof(*info), vport->riobn, remote_buffer,
337 vport->liobn, data_token);
338 if (err == H_SUCCESS) {
339 dprintk("Client connect: %s (%d)\n",
340 info->partition_name, info->partition_number);
341 }
342
343 memset(info, 0, sizeof(*info));
344
345 strcpy(info->srp_version, "16.a");
346 strncpy(info->partition_name, partition_name,
347 sizeof(info->partition_name));
348 info->partition_number = partition_number;
349 info->mad_version = 1;
350 info->os_type = 2;
351 info->port_max_txu[0] = shost->hostt->max_sectors << 9;
352
353 /* Send our info to remote */
354 err = h_copy_rdma(sizeof(*info), vport->liobn, data_token,
355 vport->riobn, remote_buffer);
356
357 dma_free_coherent(target->dev, sizeof(*info), info, data_token);
358
359 if (err != H_SUCCESS) {
360 eprintk("Error sending adapter info %d\n", err);
361 return 1;
362 }
363
364 return 0;
365}
366
367static void process_login(struct iu_entry *iue)
368{
369 union viosrp_iu *iu = vio_iu(iue);
370 struct srp_login_rsp *rsp = &iu->srp.login_rsp;
371 uint64_t tag = iu->srp.rsp.tag;
372
373 /* TODO handle case that requested size is wrong and
374 * buffer format is wrong
375 */
376 memset(iu, 0, sizeof(struct srp_login_rsp));
377 rsp->opcode = SRP_LOGIN_RSP;
378 rsp->req_lim_delta = INITIAL_SRP_LIMIT;
379 rsp->tag = tag;
380 rsp->max_it_iu_len = sizeof(union srp_iu);
381 rsp->max_ti_iu_len = sizeof(union srp_iu);
382 /* direct and indirect */
383 rsp->buf_fmt = SRP_BUF_FORMAT_DIRECT | SRP_BUF_FORMAT_INDIRECT;
384
385 send_iu(iue, sizeof(*rsp), VIOSRP_SRP_FORMAT);
386}
387
388static inline void queue_cmd(struct iu_entry *iue)
389{
390 struct srp_target *target = iue->target;
391 unsigned long flags;
392
393 spin_lock_irqsave(&target->lock, flags);
394 list_add_tail(&iue->ilist, &target->cmd_queue);
395 spin_unlock_irqrestore(&target->lock, flags);
396}
397
398static int process_tsk_mgmt(struct iu_entry *iue)
399{
400 union viosrp_iu *iu = vio_iu(iue);
401 int fn;
402
403 dprintk("%p %u\n", iue, iu->srp.tsk_mgmt.tsk_mgmt_func);
404
405 switch (iu->srp.tsk_mgmt.tsk_mgmt_func) {
406 case SRP_TSK_ABORT_TASK:
407 fn = ABORT_TASK;
408 break;
409 case SRP_TSK_ABORT_TASK_SET:
410 fn = ABORT_TASK_SET;
411 break;
412 case SRP_TSK_CLEAR_TASK_SET:
413 fn = CLEAR_TASK_SET;
414 break;
415 case SRP_TSK_LUN_RESET:
416 fn = LOGICAL_UNIT_RESET;
417 break;
418 case SRP_TSK_CLEAR_ACA:
419 fn = CLEAR_ACA;
420 break;
421 default:
422 fn = 0;
423 }
424 if (fn)
425 scsi_tgt_tsk_mgmt_request(iue->target->shost, fn,
426 iu->srp.tsk_mgmt.task_tag,
427 (struct scsi_lun *) &iu->srp.tsk_mgmt.lun,
428 iue);
429 else
430 send_rsp(iue, NULL, ILLEGAL_REQUEST, 0x20);
431
432 return !fn;
433}
434
435static int process_mad_iu(struct iu_entry *iue)
436{
437 union viosrp_iu *iu = vio_iu(iue);
438 struct viosrp_adapter_info *info;
439 struct viosrp_host_config *conf;
440
441 switch (iu->mad.empty_iu.common.type) {
442 case VIOSRP_EMPTY_IU_TYPE:
443 eprintk("%s\n", "Unsupported EMPTY MAD IU");
444 break;
445 case VIOSRP_ERROR_LOG_TYPE:
446 eprintk("%s\n", "Unsupported ERROR LOG MAD IU");
447 iu->mad.error_log.common.status = 1;
448 send_iu(iue, sizeof(iu->mad.error_log), VIOSRP_MAD_FORMAT);
449 break;
450 case VIOSRP_ADAPTER_INFO_TYPE:
451 info = &iu->mad.adapter_info;
452 info->common.status = send_adapter_info(iue, info->buffer,
453 info->common.length);
454 send_iu(iue, sizeof(*info), VIOSRP_MAD_FORMAT);
455 break;
456 case VIOSRP_HOST_CONFIG_TYPE:
457 conf = &iu->mad.host_config;
458 conf->common.status = 1;
459 send_iu(iue, sizeof(*conf), VIOSRP_MAD_FORMAT);
460 break;
461 default:
462 eprintk("Unknown type %u\n", iu->srp.rsp.opcode);
463 }
464
465 return 1;
466}
467
468static int process_srp_iu(struct iu_entry *iue)
469{
470 union viosrp_iu *iu = vio_iu(iue);
471 int done = 1;
472 u8 opcode = iu->srp.rsp.opcode;
473
474 switch (opcode) {
475 case SRP_LOGIN_REQ:
476 process_login(iue);
477 break;
478 case SRP_TSK_MGMT:
479 done = process_tsk_mgmt(iue);
480 break;
481 case SRP_CMD:
482 queue_cmd(iue);
483 done = 0;
484 break;
485 case SRP_LOGIN_RSP:
486 case SRP_I_LOGOUT:
487 case SRP_T_LOGOUT:
488 case SRP_RSP:
489 case SRP_CRED_REQ:
490 case SRP_CRED_RSP:
491 case SRP_AER_REQ:
492 case SRP_AER_RSP:
493 eprintk("Unsupported type %u\n", opcode);
494 break;
495 default:
496 eprintk("Unknown type %u\n", opcode);
497 }
498
499 return done;
500}
501
502static void process_iu(struct viosrp_crq *crq, struct srp_target *target)
503{
504 struct vio_port *vport = target_to_port(target);
505 struct iu_entry *iue;
506 long err, done;
507
508 iue = srp_iu_get(target);
509 if (!iue) {
510 eprintk("Error getting IU from pool, %p\n", target);
511 return;
512 }
513
514 iue->remote_token = crq->IU_data_ptr;
515
516 err = h_copy_rdma(crq->IU_length, vport->riobn,
517 iue->remote_token, vport->liobn, iue->sbuf->dma);
518
519 if (err != H_SUCCESS) {
520 eprintk("%ld transferring data error %p\n", err, iue);
521 done = 1;
522 goto out;
523 }
524
525 if (crq->format == VIOSRP_MAD_FORMAT)
526 done = process_mad_iu(iue);
527 else
528 done = process_srp_iu(iue);
529out:
530 if (done)
531 srp_iu_put(iue);
532}
533
534static irqreturn_t ibmvstgt_interrupt(int irq, void *data)
535{
536 struct srp_target *target = (struct srp_target *) data;
537 struct vio_port *vport = target_to_port(target);
538
539 vio_disable_interrupts(vport->dma_dev);
540 queue_work(vtgtd, &vport->crq_work);
541
542 return IRQ_HANDLED;
543}
544
545static int crq_queue_create(struct crq_queue *queue, struct srp_target *target)
546{
547 int err;
548 struct vio_port *vport = target_to_port(target);
549
550 queue->msgs = (struct viosrp_crq *) get_zeroed_page(GFP_KERNEL);
551 if (!queue->msgs)
552 goto malloc_failed;
553 queue->size = PAGE_SIZE / sizeof(*queue->msgs);
554
555 queue->msg_token = dma_map_single(target->dev, queue->msgs,
556 queue->size * sizeof(*queue->msgs),
557 DMA_BIDIRECTIONAL);
558
559 if (dma_mapping_error(queue->msg_token))
560 goto map_failed;
561
562 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token,
563 PAGE_SIZE);
564
565 /* If the adapter was left active for some reason (like kexec)
566 * try freeing and re-registering
567 */
568 if (err == H_RESOURCE) {
569 do {
570 err = h_free_crq(vport->dma_dev->unit_address);
571 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
572
573 err = h_reg_crq(vport->dma_dev->unit_address, queue->msg_token,
574 PAGE_SIZE);
575 }
576
577 if (err != H_SUCCESS && err != 2) {
578 eprintk("Error 0x%x opening virtual adapter\n", err);
579 goto reg_crq_failed;
580 }
581
582 err = request_irq(vport->dma_dev->irq, &ibmvstgt_interrupt,
583 SA_INTERRUPT, "ibmvstgt", target);
584 if (err)
585 goto req_irq_failed;
586
587 vio_enable_interrupts(vport->dma_dev);
588
589 h_send_crq(vport->dma_dev->unit_address, 0xC001000000000000, 0);
590
591 queue->cur = 0;
592 spin_lock_init(&queue->lock);
593
594 return 0;
595
596req_irq_failed:
597 do {
598 err = h_free_crq(vport->dma_dev->unit_address);
599 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
600
601reg_crq_failed:
602 dma_unmap_single(target->dev, queue->msg_token,
603 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
604map_failed:
605 free_page((unsigned long) queue->msgs);
606
607malloc_failed:
608 return -ENOMEM;
609}
610
611static void crq_queue_destroy(struct srp_target *target)
612{
613 struct vio_port *vport = target_to_port(target);
614 struct crq_queue *queue = &vport->crq_queue;
615 int err;
616
617 free_irq(vport->dma_dev->irq, target);
618 do {
619 err = h_free_crq(vport->dma_dev->unit_address);
620 } while (err == H_BUSY || H_IS_LONG_BUSY(err));
621
622 dma_unmap_single(target->dev, queue->msg_token,
623 queue->size * sizeof(*queue->msgs), DMA_BIDIRECTIONAL);
624
625 free_page((unsigned long) queue->msgs);
626}
627
628static void process_crq(struct viosrp_crq *crq, struct srp_target *target)
629{
630 struct vio_port *vport = target_to_port(target);
631 dprintk("%x %x\n", crq->valid, crq->format);
632
633 switch (crq->valid) {
634 case 0xC0:
635 /* initialization */
636 switch (crq->format) {
637 case 0x01:
638 h_send_crq(vport->dma_dev->unit_address,
639 0xC002000000000000, 0);
640 break;
641 case 0x02:
642 break;
643 default:
644 eprintk("Unknown format %u\n", crq->format);
645 }
646 break;
647 case 0xFF:
648 /* transport event */
649 break;
650 case 0x80:
651 /* real payload */
652 switch (crq->format) {
653 case VIOSRP_SRP_FORMAT:
654 case VIOSRP_MAD_FORMAT:
655 process_iu(crq, target);
656 break;
657 case VIOSRP_OS400_FORMAT:
658 case VIOSRP_AIX_FORMAT:
659 case VIOSRP_LINUX_FORMAT:
660 case VIOSRP_INLINE_FORMAT:
661 eprintk("Unsupported format %u\n", crq->format);
662 break;
663 default:
664 eprintk("Unknown format %u\n", crq->format);
665 }
666 break;
667 default:
668 eprintk("unknown message type 0x%02x!?\n", crq->valid);
669 }
670}
671
672static inline struct viosrp_crq *next_crq(struct crq_queue *queue)
673{
674 struct viosrp_crq *crq;
675 unsigned long flags;
676
677 spin_lock_irqsave(&queue->lock, flags);
678 crq = &queue->msgs[queue->cur];
679 if (crq->valid & 0x80) {
680 if (++queue->cur == queue->size)
681 queue->cur = 0;
682 } else
683 crq = NULL;
684 spin_unlock_irqrestore(&queue->lock, flags);
685
686 return crq;
687}
688
689static void handle_crq(struct work_struct *work)
690{
691 struct vio_port *vport = container_of(work, struct vio_port, crq_work);
692 struct srp_target *target = vport->target;
693 struct viosrp_crq *crq;
694 int done = 0;
695
696 while (!done) {
697 while ((crq = next_crq(&vport->crq_queue)) != NULL) {
698 process_crq(crq, target);
699 crq->valid = 0x00;
700 }
701
702 vio_enable_interrupts(vport->dma_dev);
703
704 crq = next_crq(&vport->crq_queue);
705 if (crq) {
706 vio_disable_interrupts(vport->dma_dev);
707 process_crq(crq, target);
708 crq->valid = 0x00;
709 } else
710 done = 1;
711 }
712
713 handle_cmd_queue(target);
714}
715
716
717static int ibmvstgt_eh_abort_handler(struct scsi_cmnd *sc)
718{
719 unsigned long flags;
720 struct iu_entry *iue = (struct iu_entry *) sc->SCp.ptr;
721 struct srp_target *target = iue->target;
722
723 dprintk("%p %p %x\n", iue, target, vio_iu(iue)->srp.cmd.cdb[0]);
724
725 spin_lock_irqsave(&target->lock, flags);
726 list_del(&iue->ilist);
727 spin_unlock_irqrestore(&target->lock, flags);
728
729 srp_iu_put(iue);
730
731 return 0;
732}
733
734static int ibmvstgt_tsk_mgmt_response(u64 mid, int result)
735{
736 struct iu_entry *iue = (struct iu_entry *) ((void *) mid);
737 union viosrp_iu *iu = vio_iu(iue);
738 unsigned char status, asc;
739
740 eprintk("%p %d\n", iue, result);
741 status = NO_SENSE;
742 asc = 0;
743
744 switch (iu->srp.tsk_mgmt.tsk_mgmt_func) {
745 case SRP_TSK_ABORT_TASK:
746 asc = 0x14;
747 if (result)
748 status = ABORTED_COMMAND;
749 break;
750 default:
751 break;
752 }
753
754 send_rsp(iue, NULL, status, asc);
755 srp_iu_put(iue);
756
757 return 0;
758}
759
760static ssize_t system_id_show(struct class_device *cdev, char *buf)
761{
762 return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
763}
764
765static ssize_t partition_number_show(struct class_device *cdev, char *buf)
766{
767 return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
768}
769
770static ssize_t unit_address_show(struct class_device *cdev, char *buf)
771{
772 struct Scsi_Host *shost = class_to_shost(cdev);
773 struct srp_target *target = host_to_srp_target(shost);
774 struct vio_port *vport = target_to_port(target);
775 return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address);
776}
777
778static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
779static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
780static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
781
782static struct class_device_attribute *ibmvstgt_attrs[] = {
783 &class_device_attr_system_id,
784 &class_device_attr_partition_number,
785 &class_device_attr_unit_address,
786 NULL,
787};
788
789static struct scsi_host_template ibmvstgt_sht = {
790 .name = TGT_NAME,
791 .module = THIS_MODULE,
792 .can_queue = INITIAL_SRP_LIMIT,
793 .sg_tablesize = SG_ALL,
794 .use_clustering = DISABLE_CLUSTERING,
795 .max_sectors = DEFAULT_MAX_SECTORS,
796 .transfer_response = ibmvstgt_cmd_done,
797 .transfer_data = ibmvstgt_transfer_data,
798 .eh_abort_handler = ibmvstgt_eh_abort_handler,
799 .tsk_mgmt_response = ibmvstgt_tsk_mgmt_response,
800 .shost_attrs = ibmvstgt_attrs,
801 .proc_name = TGT_NAME,
802};
803
804static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
805{
806 struct Scsi_Host *shost;
807 struct srp_target *target;
808 struct vio_port *vport;
809 unsigned int *dma, dma_size;
810 int err = -ENOMEM;
811
812 vport = kzalloc(sizeof(struct vio_port), GFP_KERNEL);
813 if (!vport)
814 return err;
815 shost = scsi_host_alloc(&ibmvstgt_sht, sizeof(struct srp_target));
816 if (!shost)
817 goto free_vport;
818 err = scsi_tgt_alloc_queue(shost);
819 if (err)
820 goto put_host;
821
822 target = host_to_srp_target(shost);
823 target->shost = shost;
824 vport->dma_dev = dev;
825 target->ldata = vport;
826 vport->target = target;
827 err = srp_target_alloc(target, &dev->dev, INITIAL_SRP_LIMIT,
828 SRP_MAX_IU_LEN);
829 if (err)
830 goto put_host;
831
832 dma = (unsigned int *) vio_get_attribute(dev, "ibm,my-dma-window",
833 &dma_size);
834 if (!dma || dma_size != 40) {
835 eprintk("Couldn't get window property %d\n", dma_size);
836 err = -EIO;
837 goto free_srp_target;
838 }
839 vport->liobn = dma[0];
840 vport->riobn = dma[5];
841
842 INIT_WORK(&vport->crq_work, handle_crq);
843
844 err = crq_queue_create(&vport->crq_queue, target);
845 if (err)
846 goto free_srp_target;
847
848 err = scsi_add_host(shost, target->dev);
849 if (err)
850 goto destroy_queue;
851 return 0;
852
853destroy_queue:
854 crq_queue_destroy(target);
855free_srp_target:
856 srp_target_free(target);
857put_host:
858 scsi_host_put(shost);
859free_vport:
860 kfree(vport);
861 return err;
862}
863
864static int ibmvstgt_remove(struct vio_dev *dev)
865{
866 struct srp_target *target = (struct srp_target *) dev->dev.driver_data;
867 struct Scsi_Host *shost = target->shost;
868 struct vio_port *vport = target->ldata;
869
870 crq_queue_destroy(target);
871 scsi_remove_host(shost);
872 scsi_tgt_free_queue(shost);
873 srp_target_free(target);
874 kfree(vport);
875 scsi_host_put(shost);
876 return 0;
877}
878
879static struct vio_device_id ibmvstgt_device_table[] __devinitdata = {
880 {"v-scsi-host", "IBM,v-scsi-host"},
881 {"",""}
882};
883
884MODULE_DEVICE_TABLE(vio, ibmvstgt_device_table);
885
886static struct vio_driver ibmvstgt_driver = {
887 .id_table = ibmvstgt_device_table,
888 .probe = ibmvstgt_probe,
889 .remove = ibmvstgt_remove,
890 .driver = {
891 .name = "ibmvscsis",
892 .owner = THIS_MODULE,
893 }
894};
895
896static int get_system_info(void)
897{
898 struct device_node *rootdn;
899 const char *id, *model, *name;
900 unsigned int *num;
901
902 rootdn = find_path_device("/");
903 if (!rootdn)
904 return -ENOENT;
905
906 model = get_property(rootdn, "model", NULL);
907 id = get_property(rootdn, "system-id", NULL);
908 if (model && id)
909 snprintf(system_id, sizeof(system_id), "%s-%s", model, id);
910
911 name = get_property(rootdn, "ibm,partition-name", NULL);
912 if (name)
913 strncpy(partition_name, name, sizeof(partition_name));
914
915 num = (unsigned int *) get_property(rootdn, "ibm,partition-no", NULL);
916 if (num)
917 partition_number = *num;
918
919 return 0;
920}
921
922static int ibmvstgt_init(void)
923{
924 int err = -ENOMEM;
925
926 printk("IBM eServer i/pSeries Virtual SCSI Target Driver\n");
927
928 vtgtd = create_workqueue("ibmvtgtd");
929 if (!vtgtd)
930 return err;
931
932 err = get_system_info();
933 if (err)
934 goto destroy_wq;
935
936 err = vio_register_driver(&ibmvstgt_driver);
937 if (err)
938 goto destroy_wq;
939
940 return 0;
941
942destroy_wq:
943 destroy_workqueue(vtgtd);
944 return err;
945}
946
947static void ibmvstgt_exit(void)
948{
949 printk("Unregister IBM virtual SCSI driver\n");
950
951 destroy_workqueue(vtgtd);
952 vio_unregister_driver(&ibmvstgt_driver);
953}
954
955MODULE_DESCRIPTION("IBM Virtual SCSI Target");
956MODULE_AUTHOR("Santiago Leon");
957MODULE_LICENSE("GPL");
958
959module_init(ibmvstgt_init);
960module_exit(ibmvstgt_exit);
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index e31f6122106f..0464c182c577 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -36,7 +36,7 @@ typedef struct {
36 int base_hi; /* Hi Base address for ECP-ISA chipset */ 36 int base_hi; /* Hi Base address for ECP-ISA chipset */
37 int mode; /* Transfer mode */ 37 int mode; /* Transfer mode */
38 struct scsi_cmnd *cur_cmd; /* Current queued command */ 38 struct scsi_cmnd *cur_cmd; /* Current queued command */
39 struct work_struct imm_tq; /* Polling interrupt stuff */ 39 struct delayed_work imm_tq; /* Polling interrupt stuff */
40 unsigned long jstart; /* Jiffies at start */ 40 unsigned long jstart; /* Jiffies at start */
41 unsigned failed:1; /* Failure flag */ 41 unsigned failed:1; /* Failure flag */
42 unsigned dp:1; /* Data phase present */ 42 unsigned dp:1; /* Data phase present */
@@ -733,9 +733,9 @@ static int imm_completion(struct scsi_cmnd *cmd)
733 * the scheduler's task queue to generate a stream of call-backs and 733 * the scheduler's task queue to generate a stream of call-backs and
734 * complete the request when the drive is ready. 734 * complete the request when the drive is ready.
735 */ 735 */
736static void imm_interrupt(void *data) 736static void imm_interrupt(struct work_struct *work)
737{ 737{
738 imm_struct *dev = (imm_struct *) data; 738 imm_struct *dev = container_of(work, imm_struct, imm_tq.work);
739 struct scsi_cmnd *cmd = dev->cur_cmd; 739 struct scsi_cmnd *cmd = dev->cur_cmd;
740 struct Scsi_Host *host = cmd->device->host; 740 struct Scsi_Host *host = cmd->device->host;
741 unsigned long flags; 741 unsigned long flags;
@@ -745,7 +745,6 @@ static void imm_interrupt(void *data)
745 return; 745 return;
746 } 746 }
747 if (imm_engine(dev, cmd)) { 747 if (imm_engine(dev, cmd)) {
748 INIT_WORK(&dev->imm_tq, imm_interrupt, (void *) dev);
749 schedule_delayed_work(&dev->imm_tq, 1); 748 schedule_delayed_work(&dev->imm_tq, 1);
750 return; 749 return;
751 } 750 }
@@ -953,8 +952,7 @@ static int imm_queuecommand(struct scsi_cmnd *cmd,
953 cmd->result = DID_ERROR << 16; /* default return code */ 952 cmd->result = DID_ERROR << 16; /* default return code */
954 cmd->SCp.phase = 0; /* bus free */ 953 cmd->SCp.phase = 0; /* bus free */
955 954
956 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 955 schedule_delayed_work(&dev->imm_tq, 0);
957 schedule_work(&dev->imm_tq);
958 956
959 imm_pb_claim(dev); 957 imm_pb_claim(dev);
960 958
@@ -1225,7 +1223,7 @@ static int __imm_attach(struct parport *pb)
1225 else 1223 else
1226 ports = 8; 1224 ports = 8;
1227 1225
1228 INIT_WORK(&dev->imm_tq, imm_interrupt, dev); 1226 INIT_DELAYED_WORK(&dev->imm_tq, imm_interrupt);
1229 1227
1230 err = -ENOMEM; 1228 err = -ENOMEM;
1231 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *)); 1229 host = scsi_host_alloc(&imm_template, sizeof(imm_struct *));
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index afed293dd7b9..f160357e37a6 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -170,7 +170,7 @@ static int setup_debug = 0;
170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb); 170static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
171 171
172/* PCI Devices supported by this driver */ 172/* PCI Devices supported by this driver */
173static struct pci_device_id i91u_pci_devices[] __devinitdata = { 173static struct pci_device_id i91u_pci_devices[] = {
174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 174 { PCI_VENDOR_ID_INIT, I950_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 175 { PCI_VENDOR_ID_INIT, I940_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 176 { PCI_VENDOR_ID_INIT, I935_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 2dde821025f3..ccd4dafce8e2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -79,7 +79,6 @@
79#include <scsi/scsi_tcq.h> 79#include <scsi/scsi_tcq.h>
80#include <scsi/scsi_eh.h> 80#include <scsi/scsi_eh.h>
81#include <scsi/scsi_cmnd.h> 81#include <scsi/scsi_cmnd.h>
82#include <scsi/scsi_transport.h>
83#include "ipr.h" 82#include "ipr.h"
84 83
85/* 84/*
@@ -98,7 +97,7 @@ static DEFINE_SPINLOCK(ipr_driver_lock);
98 97
99/* This table describes the differences between DMA controller chips */ 98/* This table describes the differences between DMA controller chips */
100static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { 99static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
101 { /* Gemstone, Citrine, and Obsidian */ 100 { /* Gemstone, Citrine, Obsidian, and Obsidian-E */
102 .mailbox = 0x0042C, 101 .mailbox = 0x0042C,
103 .cache_line_size = 0x20, 102 .cache_line_size = 0x20,
104 { 103 {
@@ -135,6 +134,7 @@ static const struct ipr_chip_t ipr_chip[] = {
135 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] }, 134 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] },
136 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] }, 135 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] },
137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] }, 136 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] },
137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, &ipr_chip_cfg[0] },
138 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] }, 138 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] },
139 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] } 139 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] }
140}; 140};
@@ -1249,19 +1249,23 @@ static void ipr_log_array_error(struct ipr_ioa_cfg *ioa_cfg,
1249 1249
1250/** 1250/**
1251 * ipr_log_hex_data - Log additional hex IOA error data. 1251 * ipr_log_hex_data - Log additional hex IOA error data.
1252 * @ioa_cfg: ioa config struct
1252 * @data: IOA error data 1253 * @data: IOA error data
1253 * @len: data length 1254 * @len: data length
1254 * 1255 *
1255 * Return value: 1256 * Return value:
1256 * none 1257 * none
1257 **/ 1258 **/
1258static void ipr_log_hex_data(u32 *data, int len) 1259static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, u32 *data, int len)
1259{ 1260{
1260 int i; 1261 int i;
1261 1262
1262 if (len == 0) 1263 if (len == 0)
1263 return; 1264 return;
1264 1265
1266 if (ioa_cfg->log_level <= IPR_DEFAULT_LOG_LEVEL)
1267 len = min_t(int, len, IPR_DEFAULT_MAX_ERROR_DUMP);
1268
1265 for (i = 0; i < len / 4; i += 4) { 1269 for (i = 0; i < len / 4; i += 4) {
1266 ipr_err("%08X: %08X %08X %08X %08X\n", i*4, 1270 ipr_err("%08X: %08X %08X %08X %08X\n", i*4,
1267 be32_to_cpu(data[i]), 1271 be32_to_cpu(data[i]),
@@ -1290,7 +1294,7 @@ static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1290 ipr_err("%s\n", error->failure_reason); 1294 ipr_err("%s\n", error->failure_reason);
1291 ipr_err("Remote Adapter VPD:\n"); 1295 ipr_err("Remote Adapter VPD:\n");
1292 ipr_log_ext_vpd(&error->vpd); 1296 ipr_log_ext_vpd(&error->vpd);
1293 ipr_log_hex_data(error->data, 1297 ipr_log_hex_data(ioa_cfg, error->data,
1294 be32_to_cpu(hostrcb->hcam.length) - 1298 be32_to_cpu(hostrcb->hcam.length) -
1295 (offsetof(struct ipr_hostrcb_error, u) + 1299 (offsetof(struct ipr_hostrcb_error, u) +
1296 offsetof(struct ipr_hostrcb_type_17_error, data))); 1300 offsetof(struct ipr_hostrcb_type_17_error, data)));
@@ -1315,12 +1319,225 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1315 ipr_err("%s\n", error->failure_reason); 1319 ipr_err("%s\n", error->failure_reason);
1316 ipr_err("Remote Adapter VPD:\n"); 1320 ipr_err("Remote Adapter VPD:\n");
1317 ipr_log_vpd(&error->vpd); 1321 ipr_log_vpd(&error->vpd);
1318 ipr_log_hex_data(error->data, 1322 ipr_log_hex_data(ioa_cfg, error->data,
1319 be32_to_cpu(hostrcb->hcam.length) - 1323 be32_to_cpu(hostrcb->hcam.length) -
1320 (offsetof(struct ipr_hostrcb_error, u) + 1324 (offsetof(struct ipr_hostrcb_error, u) +
1321 offsetof(struct ipr_hostrcb_type_07_error, data))); 1325 offsetof(struct ipr_hostrcb_type_07_error, data)));
1322} 1326}
1323 1327
1328static const struct {
1329 u8 active;
1330 char *desc;
1331} path_active_desc[] = {
1332 { IPR_PATH_NO_INFO, "Path" },
1333 { IPR_PATH_ACTIVE, "Active path" },
1334 { IPR_PATH_NOT_ACTIVE, "Inactive path" }
1335};
1336
1337static const struct {
1338 u8 state;
1339 char *desc;
1340} path_state_desc[] = {
1341 { IPR_PATH_STATE_NO_INFO, "has no path state information available" },
1342 { IPR_PATH_HEALTHY, "is healthy" },
1343 { IPR_PATH_DEGRADED, "is degraded" },
1344 { IPR_PATH_FAILED, "is failed" }
1345};
1346
1347/**
1348 * ipr_log_fabric_path - Log a fabric path error
1349 * @hostrcb: hostrcb struct
1350 * @fabric: fabric descriptor
1351 *
1352 * Return value:
1353 * none
1354 **/
1355static void ipr_log_fabric_path(struct ipr_hostrcb *hostrcb,
1356 struct ipr_hostrcb_fabric_desc *fabric)
1357{
1358 int i, j;
1359 u8 path_state = fabric->path_state;
1360 u8 active = path_state & IPR_PATH_ACTIVE_MASK;
1361 u8 state = path_state & IPR_PATH_STATE_MASK;
1362
1363 for (i = 0; i < ARRAY_SIZE(path_active_desc); i++) {
1364 if (path_active_desc[i].active != active)
1365 continue;
1366
1367 for (j = 0; j < ARRAY_SIZE(path_state_desc); j++) {
1368 if (path_state_desc[j].state != state)
1369 continue;
1370
1371 if (fabric->cascaded_expander == 0xff && fabric->phy == 0xff) {
1372 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d\n",
1373 path_active_desc[i].desc, path_state_desc[j].desc,
1374 fabric->ioa_port);
1375 } else if (fabric->cascaded_expander == 0xff) {
1376 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Phy=%d\n",
1377 path_active_desc[i].desc, path_state_desc[j].desc,
1378 fabric->ioa_port, fabric->phy);
1379 } else if (fabric->phy == 0xff) {
1380 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d\n",
1381 path_active_desc[i].desc, path_state_desc[j].desc,
1382 fabric->ioa_port, fabric->cascaded_expander);
1383 } else {
1384 ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d, Phy=%d\n",
1385 path_active_desc[i].desc, path_state_desc[j].desc,
1386 fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
1387 }
1388 return;
1389 }
1390 }
1391
1392 ipr_err("Path state=%02X IOA Port=%d Cascade=%d Phy=%d\n", path_state,
1393 fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
1394}
1395
1396static const struct {
1397 u8 type;
1398 char *desc;
1399} path_type_desc[] = {
1400 { IPR_PATH_CFG_IOA_PORT, "IOA port" },
1401 { IPR_PATH_CFG_EXP_PORT, "Expander port" },
1402 { IPR_PATH_CFG_DEVICE_PORT, "Device port" },
1403 { IPR_PATH_CFG_DEVICE_LUN, "Device LUN" }
1404};
1405
1406static const struct {
1407 u8 status;
1408 char *desc;
1409} path_status_desc[] = {
1410 { IPR_PATH_CFG_NO_PROB, "Functional" },
1411 { IPR_PATH_CFG_DEGRADED, "Degraded" },
1412 { IPR_PATH_CFG_FAILED, "Failed" },
1413 { IPR_PATH_CFG_SUSPECT, "Suspect" },
1414 { IPR_PATH_NOT_DETECTED, "Missing" },
1415 { IPR_PATH_INCORRECT_CONN, "Incorrectly connected" }
1416};
1417
1418static const char *link_rate[] = {
1419 "unknown",
1420 "disabled",
1421 "phy reset problem",
1422 "spinup hold",
1423 "port selector",
1424 "unknown",
1425 "unknown",
1426 "unknown",
1427 "1.5Gbps",
1428 "3.0Gbps",
1429 "unknown",
1430 "unknown",
1431 "unknown",
1432 "unknown",
1433 "unknown",
1434 "unknown"
1435};
1436
1437/**
1438 * ipr_log_path_elem - Log a fabric path element.
1439 * @hostrcb: hostrcb struct
1440 * @cfg: fabric path element struct
1441 *
1442 * Return value:
1443 * none
1444 **/
1445static void ipr_log_path_elem(struct ipr_hostrcb *hostrcb,
1446 struct ipr_hostrcb_config_element *cfg)
1447{
1448 int i, j;
1449 u8 type = cfg->type_status & IPR_PATH_CFG_TYPE_MASK;
1450 u8 status = cfg->type_status & IPR_PATH_CFG_STATUS_MASK;
1451
1452 if (type == IPR_PATH_CFG_NOT_EXIST)
1453 return;
1454
1455 for (i = 0; i < ARRAY_SIZE(path_type_desc); i++) {
1456 if (path_type_desc[i].type != type)
1457 continue;
1458
1459 for (j = 0; j < ARRAY_SIZE(path_status_desc); j++) {
1460 if (path_status_desc[j].status != status)
1461 continue;
1462
1463 if (type == IPR_PATH_CFG_IOA_PORT) {
1464 ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, WWN=%08X%08X\n",
1465 path_status_desc[j].desc, path_type_desc[i].desc,
1466 cfg->phy, link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1467 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1468 } else {
1469 if (cfg->cascaded_expander == 0xff && cfg->phy == 0xff) {
1470 ipr_hcam_err(hostrcb, "%s %s: Link rate=%s, WWN=%08X%08X\n",
1471 path_status_desc[j].desc, path_type_desc[i].desc,
1472 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1473 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1474 } else if (cfg->cascaded_expander == 0xff) {
1475 ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, "
1476 "WWN=%08X%08X\n", path_status_desc[j].desc,
1477 path_type_desc[i].desc, cfg->phy,
1478 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1479 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1480 } else if (cfg->phy == 0xff) {
1481 ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Link rate=%s, "
1482 "WWN=%08X%08X\n", path_status_desc[j].desc,
1483 path_type_desc[i].desc, cfg->cascaded_expander,
1484 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1485 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1486 } else {
1487 ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Phy=%d, Link rate=%s "
1488 "WWN=%08X%08X\n", path_status_desc[j].desc,
1489 path_type_desc[i].desc, cfg->cascaded_expander, cfg->phy,
1490 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1491 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1492 }
1493 }
1494 return;
1495 }
1496 }
1497
1498 ipr_hcam_err(hostrcb, "Path element=%02X: Cascade=%d Phy=%d Link rate=%s "
1499 "WWN=%08X%08X\n", cfg->type_status, cfg->cascaded_expander, cfg->phy,
1500 link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
1501 be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
1502}
1503
1504/**
1505 * ipr_log_fabric_error - Log a fabric error.
1506 * @ioa_cfg: ioa config struct
1507 * @hostrcb: hostrcb struct
1508 *
1509 * Return value:
1510 * none
1511 **/
1512static void ipr_log_fabric_error(struct ipr_ioa_cfg *ioa_cfg,
1513 struct ipr_hostrcb *hostrcb)
1514{
1515 struct ipr_hostrcb_type_20_error *error;
1516 struct ipr_hostrcb_fabric_desc *fabric;
1517 struct ipr_hostrcb_config_element *cfg;
1518 int i, add_len;
1519
1520 error = &hostrcb->hcam.u.error.u.type_20_error;
1521 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1522 ipr_hcam_err(hostrcb, "%s\n", error->failure_reason);
1523
1524 add_len = be32_to_cpu(hostrcb->hcam.length) -
1525 (offsetof(struct ipr_hostrcb_error, u) +
1526 offsetof(struct ipr_hostrcb_type_20_error, desc));
1527
1528 for (i = 0, fabric = error->desc; i < error->num_entries; i++) {
1529 ipr_log_fabric_path(hostrcb, fabric);
1530 for_each_fabric_cfg(fabric, cfg)
1531 ipr_log_path_elem(hostrcb, cfg);
1532
1533 add_len -= be16_to_cpu(fabric->length);
1534 fabric = (struct ipr_hostrcb_fabric_desc *)
1535 ((unsigned long)fabric + be16_to_cpu(fabric->length));
1536 }
1537
1538 ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len);
1539}
1540
1324/** 1541/**
1325 * ipr_log_generic_error - Log an adapter error. 1542 * ipr_log_generic_error - Log an adapter error.
1326 * @ioa_cfg: ioa config struct 1543 * @ioa_cfg: ioa config struct
@@ -1332,7 +1549,7 @@ static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1332static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg, 1549static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg,
1333 struct ipr_hostrcb *hostrcb) 1550 struct ipr_hostrcb *hostrcb)
1334{ 1551{
1335 ipr_log_hex_data(hostrcb->hcam.u.raw.data, 1552 ipr_log_hex_data(ioa_cfg, hostrcb->hcam.u.raw.data,
1336 be32_to_cpu(hostrcb->hcam.length)); 1553 be32_to_cpu(hostrcb->hcam.length));
1337} 1554}
1338 1555
@@ -1394,13 +1611,7 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1394 if (!ipr_error_table[error_index].log_hcam) 1611 if (!ipr_error_table[error_index].log_hcam)
1395 return; 1612 return;
1396 1613
1397 if (ipr_is_device(&hostrcb->hcam.u.error.failing_dev_res_addr)) { 1614 ipr_hcam_err(hostrcb, "%s\n", ipr_error_table[error_index].error);
1398 ipr_ra_err(ioa_cfg, hostrcb->hcam.u.error.failing_dev_res_addr,
1399 "%s\n", ipr_error_table[error_index].error);
1400 } else {
1401 dev_err(&ioa_cfg->pdev->dev, "%s\n",
1402 ipr_error_table[error_index].error);
1403 }
1404 1615
1405 /* Set indication we have logged an error */ 1616 /* Set indication we have logged an error */
1406 ioa_cfg->errors_logged++; 1617 ioa_cfg->errors_logged++;
@@ -1437,6 +1648,9 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1437 case IPR_HOST_RCB_OVERLAY_ID_17: 1648 case IPR_HOST_RCB_OVERLAY_ID_17:
1438 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb); 1649 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb);
1439 break; 1650 break;
1651 case IPR_HOST_RCB_OVERLAY_ID_20:
1652 ipr_log_fabric_error(ioa_cfg, hostrcb);
1653 break;
1440 case IPR_HOST_RCB_OVERLAY_ID_1: 1654 case IPR_HOST_RCB_OVERLAY_ID_1:
1441 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT: 1655 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT:
1442 default: 1656 default:
@@ -2093,7 +2307,7 @@ static void ipr_release_dump(struct kref *kref)
2093 2307
2094/** 2308/**
2095 * ipr_worker_thread - Worker thread 2309 * ipr_worker_thread - Worker thread
2096 * @data: ioa config struct 2310 * @work: ioa config struct
2097 * 2311 *
2098 * Called at task level from a work thread. This function takes care 2312 * Called at task level from a work thread. This function takes care
2099 * of adding and removing device from the mid-layer as configuration 2313 * of adding and removing device from the mid-layer as configuration
@@ -2102,13 +2316,14 @@ static void ipr_release_dump(struct kref *kref)
2102 * Return value: 2316 * Return value:
2103 * nothing 2317 * nothing
2104 **/ 2318 **/
2105static void ipr_worker_thread(void *data) 2319static void ipr_worker_thread(struct work_struct *work)
2106{ 2320{
2107 unsigned long lock_flags; 2321 unsigned long lock_flags;
2108 struct ipr_resource_entry *res; 2322 struct ipr_resource_entry *res;
2109 struct scsi_device *sdev; 2323 struct scsi_device *sdev;
2110 struct ipr_dump *dump; 2324 struct ipr_dump *dump;
2111 struct ipr_ioa_cfg *ioa_cfg = data; 2325 struct ipr_ioa_cfg *ioa_cfg =
2326 container_of(work, struct ipr_ioa_cfg, work_q);
2112 u8 bus, target, lun; 2327 u8 bus, target, lun;
2113 int did_work; 2328 int did_work;
2114 2329
@@ -2969,7 +3184,6 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
2969 struct ipr_dump *dump; 3184 struct ipr_dump *dump;
2970 unsigned long lock_flags = 0; 3185 unsigned long lock_flags = 0;
2971 3186
2972 ENTER;
2973 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL); 3187 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL);
2974 3188
2975 if (!dump) { 3189 if (!dump) {
@@ -2996,7 +3210,6 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
2996 } 3210 }
2997 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3211 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2998 3212
2999 LEAVE;
3000 return 0; 3213 return 0;
3001} 3214}
3002 3215
@@ -3573,6 +3786,12 @@ static int ipr_sata_reset(struct ata_port *ap, unsigned int *classes)
3573 3786
3574 ENTER; 3787 ENTER;
3575 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); 3788 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3789 while(ioa_cfg->in_reset_reload) {
3790 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
3791 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
3792 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3793 }
3794
3576 res = sata_port->res; 3795 res = sata_port->res;
3577 if (res) { 3796 if (res) {
3578 rc = ipr_device_reset(ioa_cfg, res); 3797 rc = ipr_device_reset(ioa_cfg, res);
@@ -3636,6 +3855,10 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
3636 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) { 3855 if (ipr_cmd->ioarcb.res_handle == res->cfgte.res_handle) {
3637 if (ipr_cmd->scsi_cmd) 3856 if (ipr_cmd->scsi_cmd)
3638 ipr_cmd->done = ipr_scsi_eh_done; 3857 ipr_cmd->done = ipr_scsi_eh_done;
3858 if (ipr_cmd->qc && !(ipr_cmd->qc->flags & ATA_QCFLAG_FAILED)) {
3859 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT;
3860 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED;
3861 }
3639 } 3862 }
3640 } 3863 }
3641 3864
@@ -3770,7 +3993,7 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
3770 */ 3993 */
3771 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead) 3994 if (ioa_cfg->in_reset_reload || ioa_cfg->ioa_is_dead)
3772 return FAILED; 3995 return FAILED;
3773 if (!res || (!ipr_is_gscsi(res) && !ipr_is_vset_device(res))) 3996 if (!res || !ipr_is_gscsi(res))
3774 return FAILED; 3997 return FAILED;
3775 3998
3776 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 3999 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
@@ -4615,7 +4838,7 @@ static int ipr_queuecommand(struct scsi_cmnd *scsi_cmd,
4615 * Return value: 4838 * Return value:
4616 * 0 on success / other on failure 4839 * 0 on success / other on failure
4617 **/ 4840 **/
4618int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 4841static int ipr_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
4619{ 4842{
4620 struct ipr_resource_entry *res; 4843 struct ipr_resource_entry *res;
4621 4844
@@ -4648,40 +4871,6 @@ static const char * ipr_ioa_info(struct Scsi_Host *host)
4648 return buffer; 4871 return buffer;
4649} 4872}
4650 4873
4651/**
4652 * ipr_scsi_timed_out - Handle scsi command timeout
4653 * @scsi_cmd: scsi command struct
4654 *
4655 * Return value:
4656 * EH_NOT_HANDLED
4657 **/
4658enum scsi_eh_timer_return ipr_scsi_timed_out(struct scsi_cmnd *scsi_cmd)
4659{
4660 struct ipr_ioa_cfg *ioa_cfg;
4661 struct ipr_cmnd *ipr_cmd;
4662 unsigned long flags;
4663
4664 ENTER;
4665 spin_lock_irqsave(scsi_cmd->device->host->host_lock, flags);
4666 ioa_cfg = (struct ipr_ioa_cfg *)scsi_cmd->device->host->hostdata;
4667
4668 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
4669 if (ipr_cmd->qc && ipr_cmd->qc->scsicmd == scsi_cmd) {
4670 ipr_cmd->qc->err_mask |= AC_ERR_TIMEOUT;
4671 ipr_cmd->qc->flags |= ATA_QCFLAG_FAILED;
4672 break;
4673 }
4674 }
4675
4676 spin_unlock_irqrestore(scsi_cmd->device->host->host_lock, flags);
4677 LEAVE;
4678 return EH_NOT_HANDLED;
4679}
4680
4681static struct scsi_transport_template ipr_transport_template = {
4682 .eh_timed_out = ipr_scsi_timed_out
4683};
4684
4685static struct scsi_host_template driver_template = { 4874static struct scsi_host_template driver_template = {
4686 .module = THIS_MODULE, 4875 .module = THIS_MODULE,
4687 .name = "IPR", 4876 .name = "IPR",
@@ -4776,6 +4965,12 @@ static void ipr_ata_post_internal(struct ata_queued_cmd *qc)
4776 unsigned long flags; 4965 unsigned long flags;
4777 4966
4778 spin_lock_irqsave(ioa_cfg->host->host_lock, flags); 4967 spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
4968 while(ioa_cfg->in_reset_reload) {
4969 spin_unlock_irqrestore(ioa_cfg->host->host_lock, flags);
4970 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
4971 spin_lock_irqsave(ioa_cfg->host->host_lock, flags);
4972 }
4973
4779 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) { 4974 list_for_each_entry(ipr_cmd, &ioa_cfg->pending_q, queue) {
4780 if (ipr_cmd->qc == qc) { 4975 if (ipr_cmd->qc == qc) {
4781 ipr_device_reset(ioa_cfg, sata_port->res); 4976 ipr_device_reset(ioa_cfg, sata_port->res);
@@ -6832,6 +7027,7 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
6832 7027
6833 ioa_cfg->hostrcb[i]->hostrcb_dma = 7028 ioa_cfg->hostrcb[i]->hostrcb_dma =
6834 ioa_cfg->hostrcb_dma[i] + offsetof(struct ipr_hostrcb, hcam); 7029 ioa_cfg->hostrcb_dma[i] + offsetof(struct ipr_hostrcb, hcam);
7030 ioa_cfg->hostrcb[i]->ioa_cfg = ioa_cfg;
6835 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); 7031 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q);
6836 } 7032 }
6837 7033
@@ -6926,7 +7122,7 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
6926 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q); 7122 INIT_LIST_HEAD(&ioa_cfg->hostrcb_pending_q);
6927 INIT_LIST_HEAD(&ioa_cfg->free_res_q); 7123 INIT_LIST_HEAD(&ioa_cfg->free_res_q);
6928 INIT_LIST_HEAD(&ioa_cfg->used_res_q); 7124 INIT_LIST_HEAD(&ioa_cfg->used_res_q);
6929 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread, ioa_cfg); 7125 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread);
6930 init_waitqueue_head(&ioa_cfg->reset_wait_q); 7126 init_waitqueue_head(&ioa_cfg->reset_wait_q);
6931 ioa_cfg->sdt_state = INACTIVE; 7127 ioa_cfg->sdt_state = INACTIVE;
6932 if (ipr_enable_cache) 7128 if (ipr_enable_cache)
@@ -7017,7 +7213,6 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
7017 7213
7018 ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata; 7214 ioa_cfg = (struct ipr_ioa_cfg *)host->hostdata;
7019 memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg)); 7215 memset(ioa_cfg, 0, sizeof(struct ipr_ioa_cfg));
7020 host->transportt = &ipr_transport_template;
7021 ata_host_init(&ioa_cfg->ata_host, &pdev->dev, 7216 ata_host_init(&ioa_cfg->ata_host, &pdev->dev,
7022 sata_port_info.flags, &ipr_sata_ops); 7217 sata_port_info.flags, &ipr_sata_ops);
7023 7218
@@ -7351,12 +7546,24 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
7351 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, 7546 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7352 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7547 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
7353 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7548 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7549 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
7550 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C,
7551 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7354 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7552 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7355 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A, 7553 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
7356 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7554 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7357 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 7555 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7358 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B, 7556 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
7359 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 7557 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7558 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7559 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575C,
7560 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7561 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
7562 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B8,
7563 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7564 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E,
7565 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_57B7,
7566 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
7360 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 7567 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
7361 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 7568 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780,
7362 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7569 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
@@ -7366,6 +7573,9 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
7366 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 7573 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7367 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F, 7574 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F,
7368 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 7575 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
7576 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
7577 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572F,
7578 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
7369 { } 7579 { }
7370}; 7580};
7371MODULE_DEVICE_TABLE(pci, ipr_pci_table); 7581MODULE_DEVICE_TABLE(pci, ipr_pci_table);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 6d035283af08..9f62a1d4d511 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -37,8 +37,8 @@
37/* 37/*
38 * Literals 38 * Literals
39 */ 39 */
40#define IPR_DRIVER_VERSION "2.2.0" 40#define IPR_DRIVER_VERSION "2.3.0"
41#define IPR_DRIVER_DATE "(September 25, 2006)" 41#define IPR_DRIVER_DATE "(November 8, 2006)"
42 42
43/* 43/*
44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding 44 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -54,6 +54,8 @@
54 */ 54 */
55#define IPR_NUM_BASE_CMD_BLKS 100 55#define IPR_NUM_BASE_CMD_BLKS 100
56 56
57#define PCI_DEVICE_ID_IBM_OBSIDIAN_E 0x0339
58
57#define IPR_SUBS_DEV_ID_2780 0x0264 59#define IPR_SUBS_DEV_ID_2780 0x0264
58#define IPR_SUBS_DEV_ID_5702 0x0266 60#define IPR_SUBS_DEV_ID_5702 0x0266
59#define IPR_SUBS_DEV_ID_5703 0x0278 61#define IPR_SUBS_DEV_ID_5703 0x0278
@@ -66,7 +68,11 @@
66#define IPR_SUBS_DEV_ID_571F 0x02D5 68#define IPR_SUBS_DEV_ID_571F 0x02D5
67#define IPR_SUBS_DEV_ID_572A 0x02C1 69#define IPR_SUBS_DEV_ID_572A 0x02C1
68#define IPR_SUBS_DEV_ID_572B 0x02C2 70#define IPR_SUBS_DEV_ID_572B 0x02C2
71#define IPR_SUBS_DEV_ID_572F 0x02C3
69#define IPR_SUBS_DEV_ID_575B 0x030D 72#define IPR_SUBS_DEV_ID_575B 0x030D
73#define IPR_SUBS_DEV_ID_575C 0x0338
74#define IPR_SUBS_DEV_ID_57B7 0x0360
75#define IPR_SUBS_DEV_ID_57B8 0x02C2
70 76
71#define IPR_NAME "ipr" 77#define IPR_NAME "ipr"
72 78
@@ -98,6 +104,7 @@
98#define IPR_IOASC_IOA_WAS_RESET 0x10000001 104#define IPR_IOASC_IOA_WAS_RESET 0x10000001
99#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002 105#define IPR_IOASC_PCI_ACCESS_ERROR 0x10000002
100 106
107#define IPR_DEFAULT_MAX_ERROR_DUMP 984
101#define IPR_NUM_LOG_HCAMS 2 108#define IPR_NUM_LOG_HCAMS 2
102#define IPR_NUM_CFG_CHG_HCAMS 2 109#define IPR_NUM_CFG_CHG_HCAMS 2
103#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS) 110#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
@@ -731,6 +738,64 @@ struct ipr_hostrcb_type_17_error {
731 u32 data[476]; 738 u32 data[476];
732}__attribute__((packed, aligned (4))); 739}__attribute__((packed, aligned (4)));
733 740
741struct ipr_hostrcb_config_element {
742 u8 type_status;
743#define IPR_PATH_CFG_TYPE_MASK 0xF0
744#define IPR_PATH_CFG_NOT_EXIST 0x00
745#define IPR_PATH_CFG_IOA_PORT 0x10
746#define IPR_PATH_CFG_EXP_PORT 0x20
747#define IPR_PATH_CFG_DEVICE_PORT 0x30
748#define IPR_PATH_CFG_DEVICE_LUN 0x40
749
750#define IPR_PATH_CFG_STATUS_MASK 0x0F
751#define IPR_PATH_CFG_NO_PROB 0x00
752#define IPR_PATH_CFG_DEGRADED 0x01
753#define IPR_PATH_CFG_FAILED 0x02
754#define IPR_PATH_CFG_SUSPECT 0x03
755#define IPR_PATH_NOT_DETECTED 0x04
756#define IPR_PATH_INCORRECT_CONN 0x05
757
758 u8 cascaded_expander;
759 u8 phy;
760 u8 link_rate;
761#define IPR_PHY_LINK_RATE_MASK 0x0F
762
763 __be32 wwid[2];
764}__attribute__((packed, aligned (4)));
765
766struct ipr_hostrcb_fabric_desc {
767 __be16 length;
768 u8 ioa_port;
769 u8 cascaded_expander;
770 u8 phy;
771 u8 path_state;
772#define IPR_PATH_ACTIVE_MASK 0xC0
773#define IPR_PATH_NO_INFO 0x00
774#define IPR_PATH_ACTIVE 0x40
775#define IPR_PATH_NOT_ACTIVE 0x80
776
777#define IPR_PATH_STATE_MASK 0x0F
778#define IPR_PATH_STATE_NO_INFO 0x00
779#define IPR_PATH_HEALTHY 0x01
780#define IPR_PATH_DEGRADED 0x02
781#define IPR_PATH_FAILED 0x03
782
783 __be16 num_entries;
784 struct ipr_hostrcb_config_element elem[1];
785}__attribute__((packed, aligned (4)));
786
787#define for_each_fabric_cfg(fabric, cfg) \
788 for (cfg = (fabric)->elem; \
789 cfg < ((fabric)->elem + be16_to_cpu((fabric)->num_entries)); \
790 cfg++)
791
792struct ipr_hostrcb_type_20_error {
793 u8 failure_reason[64];
794 u8 reserved[3];
795 u8 num_entries;
796 struct ipr_hostrcb_fabric_desc desc[1];
797}__attribute__((packed, aligned (4)));
798
734struct ipr_hostrcb_error { 799struct ipr_hostrcb_error {
735 __be32 failing_dev_ioasc; 800 __be32 failing_dev_ioasc;
736 struct ipr_res_addr failing_dev_res_addr; 801 struct ipr_res_addr failing_dev_res_addr;
@@ -747,6 +812,7 @@ struct ipr_hostrcb_error {
747 struct ipr_hostrcb_type_13_error type_13_error; 812 struct ipr_hostrcb_type_13_error type_13_error;
748 struct ipr_hostrcb_type_14_error type_14_error; 813 struct ipr_hostrcb_type_14_error type_14_error;
749 struct ipr_hostrcb_type_17_error type_17_error; 814 struct ipr_hostrcb_type_17_error type_17_error;
815 struct ipr_hostrcb_type_20_error type_20_error;
750 } u; 816 } u;
751}__attribute__((packed, aligned (4))); 817}__attribute__((packed, aligned (4)));
752 818
@@ -786,6 +852,7 @@ struct ipr_hcam {
786#define IPR_HOST_RCB_OVERLAY_ID_14 0x14 852#define IPR_HOST_RCB_OVERLAY_ID_14 0x14
787#define IPR_HOST_RCB_OVERLAY_ID_16 0x16 853#define IPR_HOST_RCB_OVERLAY_ID_16 0x16
788#define IPR_HOST_RCB_OVERLAY_ID_17 0x17 854#define IPR_HOST_RCB_OVERLAY_ID_17 0x17
855#define IPR_HOST_RCB_OVERLAY_ID_20 0x20
789#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF 856#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF
790 857
791 u8 reserved1[3]; 858 u8 reserved1[3];
@@ -805,6 +872,7 @@ struct ipr_hostrcb {
805 struct ipr_hcam hcam; 872 struct ipr_hcam hcam;
806 dma_addr_t hostrcb_dma; 873 dma_addr_t hostrcb_dma;
807 struct list_head queue; 874 struct list_head queue;
875 struct ipr_ioa_cfg *ioa_cfg;
808}; 876};
809 877
810/* IPR smart dump table structures */ 878/* IPR smart dump table structures */
@@ -1283,6 +1351,17 @@ struct ipr_ucode_image_header {
1283 } \ 1351 } \
1284} 1352}
1285 1353
1354#define ipr_hcam_err(hostrcb, fmt, ...) \
1355{ \
1356 if (ipr_is_device(&(hostrcb)->hcam.u.error.failing_dev_res_addr)) { \
1357 ipr_ra_err((hostrcb)->ioa_cfg, \
1358 (hostrcb)->hcam.u.error.failing_dev_res_addr, \
1359 fmt, ##__VA_ARGS__); \
1360 } else { \
1361 dev_err(&(hostrcb)->ioa_cfg->pdev->dev, fmt, ##__VA_ARGS__); \
1362 } \
1363}
1364
1286#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ 1365#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
1287 __FILE__, __FUNCTION__, __LINE__) 1366 __FILE__, __FUNCTION__, __LINE__)
1288 1367
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index f06a06ae6092..8b704f73055a 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -5001,7 +5001,7 @@ ips_init_copperhead(ips_ha_t * ha)
5001 break; 5001 break;
5002 5002
5003 /* Delay for 1 Second */ 5003 /* Delay for 1 Second */
5004 msleep(IPS_ONE_SEC); 5004 MDELAY(IPS_ONE_SEC);
5005 } 5005 }
5006 5006
5007 if (j >= 45) 5007 if (j >= 45)
@@ -5027,7 +5027,7 @@ ips_init_copperhead(ips_ha_t * ha)
5027 break; 5027 break;
5028 5028
5029 /* Delay for 1 Second */ 5029 /* Delay for 1 Second */
5030 msleep(IPS_ONE_SEC); 5030 MDELAY(IPS_ONE_SEC);
5031 } 5031 }
5032 5032
5033 if (j >= 240) 5033 if (j >= 240)
@@ -5045,7 +5045,7 @@ ips_init_copperhead(ips_ha_t * ha)
5045 break; 5045 break;
5046 5046
5047 /* Delay for 1 Second */ 5047 /* Delay for 1 Second */
5048 msleep(IPS_ONE_SEC); 5048 MDELAY(IPS_ONE_SEC);
5049 } 5049 }
5050 5050
5051 if (i >= 240) 5051 if (i >= 240)
@@ -5095,7 +5095,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5095 break; 5095 break;
5096 5096
5097 /* Delay for 1 Second */ 5097 /* Delay for 1 Second */
5098 msleep(IPS_ONE_SEC); 5098 MDELAY(IPS_ONE_SEC);
5099 } 5099 }
5100 5100
5101 if (j >= 45) 5101 if (j >= 45)
@@ -5121,7 +5121,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5121 break; 5121 break;
5122 5122
5123 /* Delay for 1 Second */ 5123 /* Delay for 1 Second */
5124 msleep(IPS_ONE_SEC); 5124 MDELAY(IPS_ONE_SEC);
5125 } 5125 }
5126 5126
5127 if (j >= 240) 5127 if (j >= 240)
@@ -5139,7 +5139,7 @@ ips_init_copperhead_memio(ips_ha_t * ha)
5139 break; 5139 break;
5140 5140
5141 /* Delay for 1 Second */ 5141 /* Delay for 1 Second */
5142 msleep(IPS_ONE_SEC); 5142 MDELAY(IPS_ONE_SEC);
5143 } 5143 }
5144 5144
5145 if (i >= 240) 5145 if (i >= 240)
@@ -5191,7 +5191,7 @@ ips_init_morpheus(ips_ha_t * ha)
5191 break; 5191 break;
5192 5192
5193 /* Delay for 1 Second */ 5193 /* Delay for 1 Second */
5194 msleep(IPS_ONE_SEC); 5194 MDELAY(IPS_ONE_SEC);
5195 } 5195 }
5196 5196
5197 if (i >= 45) { 5197 if (i >= 45) {
@@ -5217,7 +5217,7 @@ ips_init_morpheus(ips_ha_t * ha)
5217 if (Post != 0x4F00) 5217 if (Post != 0x4F00)
5218 break; 5218 break;
5219 /* Delay for 1 Second */ 5219 /* Delay for 1 Second */
5220 msleep(IPS_ONE_SEC); 5220 MDELAY(IPS_ONE_SEC);
5221 } 5221 }
5222 5222
5223 if (i >= 120) { 5223 if (i >= 120) {
@@ -5247,7 +5247,7 @@ ips_init_morpheus(ips_ha_t * ha)
5247 break; 5247 break;
5248 5248
5249 /* Delay for 1 Second */ 5249 /* Delay for 1 Second */
5250 msleep(IPS_ONE_SEC); 5250 MDELAY(IPS_ONE_SEC);
5251 } 5251 }
5252 5252
5253 if (i >= 240) { 5253 if (i >= 240) {
@@ -5307,12 +5307,12 @@ ips_reset_copperhead(ips_ha_t * ha)
5307 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR); 5307 outb(IPS_BIT_RST, ha->io_addr + IPS_REG_SCPR);
5308 5308
5309 /* Delay for 1 Second */ 5309 /* Delay for 1 Second */
5310 msleep(IPS_ONE_SEC); 5310 MDELAY(IPS_ONE_SEC);
5311 5311
5312 outb(0, ha->io_addr + IPS_REG_SCPR); 5312 outb(0, ha->io_addr + IPS_REG_SCPR);
5313 5313
5314 /* Delay for 1 Second */ 5314 /* Delay for 1 Second */
5315 msleep(IPS_ONE_SEC); 5315 MDELAY(IPS_ONE_SEC);
5316 5316
5317 if ((*ha->func.init) (ha)) 5317 if ((*ha->func.init) (ha))
5318 break; 5318 break;
@@ -5352,12 +5352,12 @@ ips_reset_copperhead_memio(ips_ha_t * ha)
5352 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR); 5352 writeb(IPS_BIT_RST, ha->mem_ptr + IPS_REG_SCPR);
5353 5353
5354 /* Delay for 1 Second */ 5354 /* Delay for 1 Second */
5355 msleep(IPS_ONE_SEC); 5355 MDELAY(IPS_ONE_SEC);
5356 5356
5357 writeb(0, ha->mem_ptr + IPS_REG_SCPR); 5357 writeb(0, ha->mem_ptr + IPS_REG_SCPR);
5358 5358
5359 /* Delay for 1 Second */ 5359 /* Delay for 1 Second */
5360 msleep(IPS_ONE_SEC); 5360 MDELAY(IPS_ONE_SEC);
5361 5361
5362 if ((*ha->func.init) (ha)) 5362 if ((*ha->func.init) (ha))
5363 break; 5363 break;
@@ -5398,7 +5398,7 @@ ips_reset_morpheus(ips_ha_t * ha)
5398 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR); 5398 writel(0x80000000, ha->mem_ptr + IPS_REG_I960_IDR);
5399 5399
5400 /* Delay for 5 Seconds */ 5400 /* Delay for 5 Seconds */
5401 msleep(5 * IPS_ONE_SEC); 5401 MDELAY(5 * IPS_ONE_SEC);
5402 5402
5403 /* Do a PCI config read to wait for adapter */ 5403 /* Do a PCI config read to wait for adapter */
5404 pci_read_config_byte(ha->pcidev, 4, &junk); 5404 pci_read_config_byte(ha->pcidev, 4, &junk);
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index 34680f3dd452..b726dcc424b1 100644
--- a/drivers/scsi/ips.h
+++ b/drivers/scsi/ips.h
@@ -51,6 +51,7 @@
51 #define _IPS_H_ 51 #define _IPS_H_
52 52
53#include <linux/version.h> 53#include <linux/version.h>
54#include <linux/nmi.h>
54 #include <asm/uaccess.h> 55 #include <asm/uaccess.h>
55 #include <asm/io.h> 56 #include <asm/io.h>
56 57
@@ -116,9 +117,11 @@
116 dev_printk(level , &((pcidev)->dev) , format , ## arg) 117 dev_printk(level , &((pcidev)->dev) , format , ## arg)
117 #endif 118 #endif
118 119
119 #ifndef MDELAY 120 #define MDELAY(n) \
120 #define MDELAY mdelay 121 do { \
121 #endif 122 mdelay(n); \
123 touch_nmi_watchdog(); \
124 } while (0)
122 125
123 #ifndef min 126 #ifndef min
124 #define min(x,y) ((x) < (y) ? x : y) 127 #define min(x,y) ((x) < (y) ? x : y)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 5d8862189485..e11b23c641e2 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -719,9 +719,10 @@ again:
719 return rc; 719 return rc;
720} 720}
721 721
722static void iscsi_xmitworker(void *data) 722static void iscsi_xmitworker(struct work_struct *work)
723{ 723{
724 struct iscsi_conn *conn = data; 724 struct iscsi_conn *conn =
725 container_of(work, struct iscsi_conn, xmitwork);
725 int rc; 726 int rc;
726 /* 727 /*
727 * serialize Xmit worker on a per-connection basis. 728 * serialize Xmit worker on a per-connection basis.
@@ -1512,7 +1513,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
1512 if (conn->mgmtqueue == ERR_PTR(-ENOMEM)) 1513 if (conn->mgmtqueue == ERR_PTR(-ENOMEM))
1513 goto mgmtqueue_alloc_fail; 1514 goto mgmtqueue_alloc_fail;
1514 1515
1515 INIT_WORK(&conn->xmitwork, iscsi_xmitworker, conn); 1516 INIT_WORK(&conn->xmitwork, iscsi_xmitworker);
1516 1517
1517 /* allocate login_mtask used for the login/text sequences */ 1518 /* allocate login_mtask used for the login/text sequences */
1518 spin_lock_bh(&session->lock); 1519 spin_lock_bh(&session->lock);
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index d977bd492d8d..fb7df7b75811 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -647,10 +647,12 @@ void sas_unregister_domain_devices(struct asd_sas_port *port)
647 * Discover process only interrogates devices in order to discover the 647 * Discover process only interrogates devices in order to discover the
648 * domain. 648 * domain.
649 */ 649 */
650static void sas_discover_domain(void *data) 650static void sas_discover_domain(struct work_struct *work)
651{ 651{
652 int error = 0; 652 int error = 0;
653 struct asd_sas_port *port = data; 653 struct sas_discovery_event *ev =
654 container_of(work, struct sas_discovery_event, work);
655 struct asd_sas_port *port = ev->port;
654 656
655 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock, 657 sas_begin_event(DISCE_DISCOVER_DOMAIN, &port->disc.disc_event_lock,
656 &port->disc.pending); 658 &port->disc.pending);
@@ -692,10 +694,12 @@ static void sas_discover_domain(void *data)
692 current->pid, error); 694 current->pid, error);
693} 695}
694 696
695static void sas_revalidate_domain(void *data) 697static void sas_revalidate_domain(struct work_struct *work)
696{ 698{
697 int res = 0; 699 int res = 0;
698 struct asd_sas_port *port = data; 700 struct sas_discovery_event *ev =
701 container_of(work, struct sas_discovery_event, work);
702 struct asd_sas_port *port = ev->port;
699 703
700 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock, 704 sas_begin_event(DISCE_REVALIDATE_DOMAIN, &port->disc.disc_event_lock,
701 &port->disc.pending); 705 &port->disc.pending);
@@ -722,7 +726,7 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
722 BUG_ON(ev >= DISC_NUM_EVENTS); 726 BUG_ON(ev >= DISC_NUM_EVENTS);
723 727
724 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending, 728 sas_queue_event(ev, &disc->disc_event_lock, &disc->pending,
725 &disc->disc_work[ev], port->ha->core.shost); 729 &disc->disc_work[ev].work, port->ha->core.shost);
726 730
727 return 0; 731 return 0;
728} 732}
@@ -737,13 +741,15 @@ void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port)
737{ 741{
738 int i; 742 int i;
739 743
740 static void (*sas_event_fns[DISC_NUM_EVENTS])(void *) = { 744 static const work_func_t sas_event_fns[DISC_NUM_EVENTS] = {
741 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain, 745 [DISCE_DISCOVER_DOMAIN] = sas_discover_domain,
742 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain, 746 [DISCE_REVALIDATE_DOMAIN] = sas_revalidate_domain,
743 }; 747 };
744 748
745 spin_lock_init(&disc->disc_event_lock); 749 spin_lock_init(&disc->disc_event_lock);
746 disc->pending = 0; 750 disc->pending = 0;
747 for (i = 0; i < DISC_NUM_EVENTS; i++) 751 for (i = 0; i < DISC_NUM_EVENTS; i++) {
748 INIT_WORK(&disc->disc_work[i], sas_event_fns[i], port); 752 INIT_WORK(&disc->disc_work[i].work, sas_event_fns[i]);
753 disc->disc_work[i].port = port;
754 }
749} 755}
diff --git a/drivers/scsi/libsas/sas_event.c b/drivers/scsi/libsas/sas_event.c
index 19110ed1c89c..d83392ee6823 100644
--- a/drivers/scsi/libsas/sas_event.c
+++ b/drivers/scsi/libsas/sas_event.c
@@ -31,7 +31,7 @@ static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
31 BUG_ON(event >= HA_NUM_EVENTS); 31 BUG_ON(event >= HA_NUM_EVENTS);
32 32
33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending, 33 sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending,
34 &sas_ha->ha_events[event], sas_ha->core.shost); 34 &sas_ha->ha_events[event].work, sas_ha->core.shost);
35} 35}
36 36
37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event) 37static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
@@ -41,7 +41,7 @@ static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
41 BUG_ON(event >= PORT_NUM_EVENTS); 41 BUG_ON(event >= PORT_NUM_EVENTS);
42 42
43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending, 43 sas_queue_event(event, &ha->event_lock, &phy->port_events_pending,
44 &phy->port_events[event], ha->core.shost); 44 &phy->port_events[event].work, ha->core.shost);
45} 45}
46 46
47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event) 47static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
@@ -51,12 +51,12 @@ static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
51 BUG_ON(event >= PHY_NUM_EVENTS); 51 BUG_ON(event >= PHY_NUM_EVENTS);
52 52
53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending, 53 sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending,
54 &phy->phy_events[event], ha->core.shost); 54 &phy->phy_events[event].work, ha->core.shost);
55} 55}
56 56
57int sas_init_events(struct sas_ha_struct *sas_ha) 57int sas_init_events(struct sas_ha_struct *sas_ha)
58{ 58{
59 static void (*sas_ha_event_fns[HA_NUM_EVENTS])(void *) = { 59 static const work_func_t sas_ha_event_fns[HA_NUM_EVENTS] = {
60 [HAE_RESET] = sas_hae_reset, 60 [HAE_RESET] = sas_hae_reset,
61 }; 61 };
62 62
@@ -64,8 +64,10 @@ int sas_init_events(struct sas_ha_struct *sas_ha)
64 64
65 spin_lock_init(&sas_ha->event_lock); 65 spin_lock_init(&sas_ha->event_lock);
66 66
67 for (i = 0; i < HA_NUM_EVENTS; i++) 67 for (i = 0; i < HA_NUM_EVENTS; i++) {
68 INIT_WORK(&sas_ha->ha_events[i], sas_ha_event_fns[i], sas_ha); 68 INIT_WORK(&sas_ha->ha_events[i].work, sas_ha_event_fns[i]);
69 sas_ha->ha_events[i].ha = sas_ha;
70 }
69 71
70 sas_ha->notify_ha_event = notify_ha_event; 72 sas_ha->notify_ha_event = notify_ha_event;
71 sas_ha->notify_port_event = notify_port_event; 73 sas_ha->notify_port_event = notify_port_event;
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index e34a93435497..d31e6fa466f7 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -597,10 +597,15 @@ static struct domain_device *sas_ex_discover_end_dev(
597 child->iproto = phy->attached_iproto; 597 child->iproto = phy->attached_iproto;
598 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); 598 memcpy(child->sas_addr, phy->attached_sas_addr, SAS_ADDR_SIZE);
599 sas_hash_addr(child->hashed_sas_addr, child->sas_addr); 599 sas_hash_addr(child->hashed_sas_addr, child->sas_addr);
600 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id); 600 if (!phy->port) {
601 BUG_ON(!phy->port); 601 phy->port = sas_port_alloc(&parent->rphy->dev, phy_id);
602 /* FIXME: better error handling*/ 602 if (unlikely(!phy->port))
603 BUG_ON(sas_port_add(phy->port) != 0); 603 goto out_err;
604 if (unlikely(sas_port_add(phy->port) != 0)) {
605 sas_port_free(phy->port);
606 goto out_err;
607 }
608 }
604 sas_ex_get_linkrate(parent, child, phy); 609 sas_ex_get_linkrate(parent, child, phy);
605 610
606 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) { 611 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) {
@@ -615,8 +620,7 @@ static struct domain_device *sas_ex_discover_end_dev(
615 SAS_DPRINTK("report phy sata to %016llx:0x%x returned " 620 SAS_DPRINTK("report phy sata to %016llx:0x%x returned "
616 "0x%x\n", SAS_ADDR(parent->sas_addr), 621 "0x%x\n", SAS_ADDR(parent->sas_addr),
617 phy_id, res); 622 phy_id, res);
618 kfree(child); 623 goto out_free;
619 return NULL;
620 } 624 }
621 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis, 625 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis,
622 sizeof(struct dev_to_host_fis)); 626 sizeof(struct dev_to_host_fis));
@@ -627,14 +631,14 @@ static struct domain_device *sas_ex_discover_end_dev(
627 "%016llx:0x%x returned 0x%x\n", 631 "%016llx:0x%x returned 0x%x\n",
628 SAS_ADDR(child->sas_addr), 632 SAS_ADDR(child->sas_addr),
629 SAS_ADDR(parent->sas_addr), phy_id, res); 633 SAS_ADDR(parent->sas_addr), phy_id, res);
630 kfree(child); 634 goto out_free;
631 return NULL;
632 } 635 }
633 } else if (phy->attached_tproto & SAS_PROTO_SSP) { 636 } else if (phy->attached_tproto & SAS_PROTO_SSP) {
634 child->dev_type = SAS_END_DEV; 637 child->dev_type = SAS_END_DEV;
635 rphy = sas_end_device_alloc(phy->port); 638 rphy = sas_end_device_alloc(phy->port);
636 /* FIXME: error handling */ 639 /* FIXME: error handling */
637 BUG_ON(!rphy); 640 if (unlikely(!rphy))
641 goto out_free;
638 child->tproto = phy->attached_tproto; 642 child->tproto = phy->attached_tproto;
639 sas_init_dev(child); 643 sas_init_dev(child);
640 644
@@ -651,9 +655,7 @@ static struct domain_device *sas_ex_discover_end_dev(
651 "at %016llx:0x%x returned 0x%x\n", 655 "at %016llx:0x%x returned 0x%x\n",
652 SAS_ADDR(child->sas_addr), 656 SAS_ADDR(child->sas_addr),
653 SAS_ADDR(parent->sas_addr), phy_id, res); 657 SAS_ADDR(parent->sas_addr), phy_id, res);
654 /* FIXME: this kfrees list elements without removing them */ 658 goto out_list_del;
655 //kfree(child);
656 return NULL;
657 } 659 }
658 } else { 660 } else {
659 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", 661 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n",
@@ -663,6 +665,16 @@ static struct domain_device *sas_ex_discover_end_dev(
663 665
664 list_add_tail(&child->siblings, &parent_ex->children); 666 list_add_tail(&child->siblings, &parent_ex->children);
665 return child; 667 return child;
668
669 out_list_del:
670 list_del(&child->dev_list_node);
671 sas_rphy_free(rphy);
672 out_free:
673 sas_port_delete(phy->port);
674 out_err:
675 phy->port = NULL;
676 kfree(child);
677 return NULL;
666} 678}
667 679
668static struct domain_device *sas_ex_discover_expander( 680static struct domain_device *sas_ex_discover_expander(
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index c836a237fb79..d65bc4e0f214 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -65,9 +65,11 @@ void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
65 65
66/* ---------- HA events ---------- */ 66/* ---------- HA events ---------- */
67 67
68void sas_hae_reset(void *data) 68void sas_hae_reset(struct work_struct *work)
69{ 69{
70 struct sas_ha_struct *ha = data; 70 struct sas_ha_event *ev =
71 container_of(work, struct sas_ha_event, work);
72 struct sas_ha_struct *ha = ev->ha;
71 73
72 sas_begin_event(HAE_RESET, &ha->event_lock, 74 sas_begin_event(HAE_RESET, &ha->event_lock,
73 &ha->pending); 75 &ha->pending);
@@ -112,6 +114,8 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
112 } 114 }
113 } 115 }
114 116
117 INIT_LIST_HEAD(&sas_ha->eh_done_q);
118
115 return 0; 119 return 0;
116 120
117Undo_ports: 121Undo_ports:
@@ -142,7 +146,7 @@ static int sas_get_linkerrors(struct sas_phy *phy)
142 return sas_smp_get_phy_events(phy); 146 return sas_smp_get_phy_events(phy);
143} 147}
144 148
145static int sas_phy_reset(struct sas_phy *phy, int hard_reset) 149int sas_phy_reset(struct sas_phy *phy, int hard_reset)
146{ 150{
147 int ret; 151 int ret;
148 enum phy_func reset_type; 152 enum phy_func reset_type;
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index bffcee474921..137d7e496b6d 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -60,11 +60,11 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha);
60 60
61void sas_deform_port(struct asd_sas_phy *phy); 61void sas_deform_port(struct asd_sas_phy *phy);
62 62
63void sas_porte_bytes_dmaed(void *); 63void sas_porte_bytes_dmaed(struct work_struct *work);
64void sas_porte_broadcast_rcvd(void *); 64void sas_porte_broadcast_rcvd(struct work_struct *work);
65void sas_porte_link_reset_err(void *); 65void sas_porte_link_reset_err(struct work_struct *work);
66void sas_porte_timer_event(void *); 66void sas_porte_timer_event(struct work_struct *work);
67void sas_porte_hard_reset(void *); 67void sas_porte_hard_reset(struct work_struct *work);
68 68
69int sas_notify_lldd_dev_found(struct domain_device *); 69int sas_notify_lldd_dev_found(struct domain_device *);
70void sas_notify_lldd_dev_gone(struct domain_device *); 70void sas_notify_lldd_dev_gone(struct domain_device *);
@@ -75,7 +75,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy);
75 75
76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy); 76struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy);
77 77
78void sas_hae_reset(void *); 78void sas_hae_reset(struct work_struct *work);
79 79
80static inline void sas_queue_event(int event, spinlock_t *lock, 80static inline void sas_queue_event(int event, spinlock_t *lock,
81 unsigned long *pending, 81 unsigned long *pending,
diff --git a/drivers/scsi/libsas/sas_phy.c b/drivers/scsi/libsas/sas_phy.c
index 9340cdbae4a3..b459c4b635b1 100644
--- a/drivers/scsi/libsas/sas_phy.c
+++ b/drivers/scsi/libsas/sas_phy.c
@@ -30,9 +30,11 @@
30 30
31/* ---------- Phy events ---------- */ 31/* ---------- Phy events ---------- */
32 32
33static void sas_phye_loss_of_signal(void *data) 33static void sas_phye_loss_of_signal(struct work_struct *work)
34{ 34{
35 struct asd_sas_phy *phy = data; 35 struct asd_sas_event *ev =
36 container_of(work, struct asd_sas_event, work);
37 struct asd_sas_phy *phy = ev->phy;
36 38
37 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock, 39 sas_begin_event(PHYE_LOSS_OF_SIGNAL, &phy->ha->event_lock,
38 &phy->phy_events_pending); 40 &phy->phy_events_pending);
@@ -40,18 +42,22 @@ static void sas_phye_loss_of_signal(void *data)
40 sas_deform_port(phy); 42 sas_deform_port(phy);
41} 43}
42 44
43static void sas_phye_oob_done(void *data) 45static void sas_phye_oob_done(struct work_struct *work)
44{ 46{
45 struct asd_sas_phy *phy = data; 47 struct asd_sas_event *ev =
48 container_of(work, struct asd_sas_event, work);
49 struct asd_sas_phy *phy = ev->phy;
46 50
47 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock, 51 sas_begin_event(PHYE_OOB_DONE, &phy->ha->event_lock,
48 &phy->phy_events_pending); 52 &phy->phy_events_pending);
49 phy->error = 0; 53 phy->error = 0;
50} 54}
51 55
52static void sas_phye_oob_error(void *data) 56static void sas_phye_oob_error(struct work_struct *work)
53{ 57{
54 struct asd_sas_phy *phy = data; 58 struct asd_sas_event *ev =
59 container_of(work, struct asd_sas_event, work);
60 struct asd_sas_phy *phy = ev->phy;
55 struct sas_ha_struct *sas_ha = phy->ha; 61 struct sas_ha_struct *sas_ha = phy->ha;
56 struct asd_sas_port *port = phy->port; 62 struct asd_sas_port *port = phy->port;
57 struct sas_internal *i = 63 struct sas_internal *i =
@@ -80,9 +86,11 @@ static void sas_phye_oob_error(void *data)
80 } 86 }
81} 87}
82 88
83static void sas_phye_spinup_hold(void *data) 89static void sas_phye_spinup_hold(struct work_struct *work)
84{ 90{
85 struct asd_sas_phy *phy = data; 91 struct asd_sas_event *ev =
92 container_of(work, struct asd_sas_event, work);
93 struct asd_sas_phy *phy = ev->phy;
86 struct sas_ha_struct *sas_ha = phy->ha; 94 struct sas_ha_struct *sas_ha = phy->ha;
87 struct sas_internal *i = 95 struct sas_internal *i =
88 to_sas_internal(sas_ha->core.shost->transportt); 96 to_sas_internal(sas_ha->core.shost->transportt);
@@ -100,14 +108,14 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
100{ 108{
101 int i; 109 int i;
102 110
103 static void (*sas_phy_event_fns[PHY_NUM_EVENTS])(void *) = { 111 static const work_func_t sas_phy_event_fns[PHY_NUM_EVENTS] = {
104 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal, 112 [PHYE_LOSS_OF_SIGNAL] = sas_phye_loss_of_signal,
105 [PHYE_OOB_DONE] = sas_phye_oob_done, 113 [PHYE_OOB_DONE] = sas_phye_oob_done,
106 [PHYE_OOB_ERROR] = sas_phye_oob_error, 114 [PHYE_OOB_ERROR] = sas_phye_oob_error,
107 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold, 115 [PHYE_SPINUP_HOLD] = sas_phye_spinup_hold,
108 }; 116 };
109 117
110 static void (*sas_port_event_fns[PORT_NUM_EVENTS])(void *) = { 118 static const work_func_t sas_port_event_fns[PORT_NUM_EVENTS] = {
111 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed, 119 [PORTE_BYTES_DMAED] = sas_porte_bytes_dmaed,
112 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd, 120 [PORTE_BROADCAST_RCVD] = sas_porte_broadcast_rcvd,
113 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err, 121 [PORTE_LINK_RESET_ERR] = sas_porte_link_reset_err,
@@ -122,13 +130,18 @@ int sas_register_phys(struct sas_ha_struct *sas_ha)
122 130
123 phy->error = 0; 131 phy->error = 0;
124 INIT_LIST_HEAD(&phy->port_phy_el); 132 INIT_LIST_HEAD(&phy->port_phy_el);
125 for (k = 0; k < PORT_NUM_EVENTS; k++) 133 for (k = 0; k < PORT_NUM_EVENTS; k++) {
126 INIT_WORK(&phy->port_events[k], sas_port_event_fns[k], 134 INIT_WORK(&phy->port_events[k].work,
127 phy); 135 sas_port_event_fns[k]);
136 phy->port_events[k].phy = phy;
137 }
138
139 for (k = 0; k < PHY_NUM_EVENTS; k++) {
140 INIT_WORK(&phy->phy_events[k].work,
141 sas_phy_event_fns[k]);
142 phy->phy_events[k].phy = phy;
143 }
128 144
129 for (k = 0; k < PHY_NUM_EVENTS; k++)
130 INIT_WORK(&phy->phy_events[k], sas_phy_event_fns[k],
131 phy);
132 phy->port = NULL; 145 phy->port = NULL;
133 phy->ha = sas_ha; 146 phy->ha = sas_ha;
134 spin_lock_init(&phy->frame_rcvd_lock); 147 spin_lock_init(&phy->frame_rcvd_lock);
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index 253cdcf306a2..971c37ceecb4 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -181,9 +181,11 @@ void sas_deform_port(struct asd_sas_phy *phy)
181 181
182/* ---------- SAS port events ---------- */ 182/* ---------- SAS port events ---------- */
183 183
184void sas_porte_bytes_dmaed(void *data) 184void sas_porte_bytes_dmaed(struct work_struct *work)
185{ 185{
186 struct asd_sas_phy *phy = data; 186 struct asd_sas_event *ev =
187 container_of(work, struct asd_sas_event, work);
188 struct asd_sas_phy *phy = ev->phy;
187 189
188 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock, 190 sas_begin_event(PORTE_BYTES_DMAED, &phy->ha->event_lock,
189 &phy->port_events_pending); 191 &phy->port_events_pending);
@@ -191,11 +193,13 @@ void sas_porte_bytes_dmaed(void *data)
191 sas_form_port(phy); 193 sas_form_port(phy);
192} 194}
193 195
194void sas_porte_broadcast_rcvd(void *data) 196void sas_porte_broadcast_rcvd(struct work_struct *work)
195{ 197{
198 struct asd_sas_event *ev =
199 container_of(work, struct asd_sas_event, work);
200 struct asd_sas_phy *phy = ev->phy;
196 unsigned long flags; 201 unsigned long flags;
197 u32 prim; 202 u32 prim;
198 struct asd_sas_phy *phy = data;
199 203
200 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock, 204 sas_begin_event(PORTE_BROADCAST_RCVD, &phy->ha->event_lock,
201 &phy->port_events_pending); 205 &phy->port_events_pending);
@@ -208,9 +212,11 @@ void sas_porte_broadcast_rcvd(void *data)
208 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN); 212 sas_discover_event(phy->port, DISCE_REVALIDATE_DOMAIN);
209} 213}
210 214
211void sas_porte_link_reset_err(void *data) 215void sas_porte_link_reset_err(struct work_struct *work)
212{ 216{
213 struct asd_sas_phy *phy = data; 217 struct asd_sas_event *ev =
218 container_of(work, struct asd_sas_event, work);
219 struct asd_sas_phy *phy = ev->phy;
214 220
215 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock, 221 sas_begin_event(PORTE_LINK_RESET_ERR, &phy->ha->event_lock,
216 &phy->port_events_pending); 222 &phy->port_events_pending);
@@ -218,9 +224,11 @@ void sas_porte_link_reset_err(void *data)
218 sas_deform_port(phy); 224 sas_deform_port(phy);
219} 225}
220 226
221void sas_porte_timer_event(void *data) 227void sas_porte_timer_event(struct work_struct *work)
222{ 228{
223 struct asd_sas_phy *phy = data; 229 struct asd_sas_event *ev =
230 container_of(work, struct asd_sas_event, work);
231 struct asd_sas_phy *phy = ev->phy;
224 232
225 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock, 233 sas_begin_event(PORTE_TIMER_EVENT, &phy->ha->event_lock,
226 &phy->port_events_pending); 234 &phy->port_events_pending);
@@ -228,9 +236,11 @@ void sas_porte_timer_event(void *data)
228 sas_deform_port(phy); 236 sas_deform_port(phy);
229} 237}
230 238
231void sas_porte_hard_reset(void *data) 239void sas_porte_hard_reset(struct work_struct *work)
232{ 240{
233 struct asd_sas_phy *phy = data; 241 struct asd_sas_event *ev =
242 container_of(work, struct asd_sas_event, work);
243 struct asd_sas_phy *phy = ev->phy;
234 244
235 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock, 245 sas_begin_event(PORTE_HARD_RESET, &phy->ha->event_lock,
236 &phy->port_events_pending); 246 &phy->port_events_pending);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index e46e79355b77..22672d54aa27 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -29,9 +29,11 @@
29#include <scsi/scsi_device.h> 29#include <scsi/scsi_device.h>
30#include <scsi/scsi_tcq.h> 30#include <scsi/scsi_tcq.h>
31#include <scsi/scsi.h> 31#include <scsi/scsi.h>
32#include <scsi/scsi_eh.h>
32#include <scsi/scsi_transport.h> 33#include <scsi/scsi_transport.h>
33#include <scsi/scsi_transport_sas.h> 34#include <scsi/scsi_transport_sas.h>
34#include "../scsi_sas_internal.h" 35#include "../scsi_sas_internal.h"
36#include "../scsi_transport_api.h"
35 37
36#include <linux/err.h> 38#include <linux/err.h>
37#include <linux/blkdev.h> 39#include <linux/blkdev.h>
@@ -46,6 +48,7 @@ static void sas_scsi_task_done(struct sas_task *task)
46{ 48{
47 struct task_status_struct *ts = &task->task_status; 49 struct task_status_struct *ts = &task->task_status;
48 struct scsi_cmnd *sc = task->uldd_task; 50 struct scsi_cmnd *sc = task->uldd_task;
51 struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(sc->device->host);
49 unsigned ts_flags = task->task_state_flags; 52 unsigned ts_flags = task->task_state_flags;
50 int hs = 0, stat = 0; 53 int hs = 0, stat = 0;
51 54
@@ -116,7 +119,7 @@ static void sas_scsi_task_done(struct sas_task *task)
116 sas_free_task(task); 119 sas_free_task(task);
117 /* This is very ugly but this is how SCSI Core works. */ 120 /* This is very ugly but this is how SCSI Core works. */
118 if (ts_flags & SAS_TASK_STATE_ABORTED) 121 if (ts_flags & SAS_TASK_STATE_ABORTED)
119 scsi_finish_command(sc); 122 scsi_eh_finish_cmd(sc, &sas_ha->eh_done_q);
120 else 123 else
121 sc->scsi_done(sc); 124 sc->scsi_done(sc);
122} 125}
@@ -307,6 +310,15 @@ static enum task_disposition sas_scsi_find_task(struct sas_task *task)
307 spin_unlock_irqrestore(&core->task_queue_lock, flags); 310 spin_unlock_irqrestore(&core->task_queue_lock, flags);
308 } 311 }
309 312
313 spin_lock_irqsave(&task->task_state_lock, flags);
314 if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) {
315 spin_unlock_irqrestore(&task->task_state_lock, flags);
316 SAS_DPRINTK("%s: task 0x%p already aborted\n",
317 __FUNCTION__, task);
318 return TASK_IS_ABORTED;
319 }
320 spin_unlock_irqrestore(&task->task_state_lock, flags);
321
310 for (i = 0; i < 5; i++) { 322 for (i = 0; i < 5; i++) {
311 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task); 323 SAS_DPRINTK("%s: aborting task 0x%p\n", __FUNCTION__, task);
312 res = si->dft->lldd_abort_task(task); 324 res = si->dft->lldd_abort_task(task);
@@ -409,13 +421,16 @@ Again:
409 SAS_DPRINTK("going over list...\n"); 421 SAS_DPRINTK("going over list...\n");
410 list_for_each_entry_safe(cmd, n, &error_q, eh_entry) { 422 list_for_each_entry_safe(cmd, n, &error_q, eh_entry) {
411 struct sas_task *task = TO_SAS_TASK(cmd); 423 struct sas_task *task = TO_SAS_TASK(cmd);
424 list_del_init(&cmd->eh_entry);
412 425
426 if (!task) {
427 SAS_DPRINTK("%s: taskless cmd?!\n", __FUNCTION__);
428 continue;
429 }
413 SAS_DPRINTK("trying to find task 0x%p\n", task); 430 SAS_DPRINTK("trying to find task 0x%p\n", task);
414 list_del_init(&cmd->eh_entry);
415 res = sas_scsi_find_task(task); 431 res = sas_scsi_find_task(task);
416 432
417 cmd->eh_eflags = 0; 433 cmd->eh_eflags = 0;
418 shost->host_failed--;
419 434
420 switch (res) { 435 switch (res) {
421 case TASK_IS_DONE: 436 case TASK_IS_DONE:
@@ -491,6 +506,7 @@ Again:
491 } 506 }
492 } 507 }
493out: 508out:
509 scsi_eh_flush_done_q(&ha->eh_done_q);
494 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__); 510 SAS_DPRINTK("--- Exit %s\n", __FUNCTION__);
495 return; 511 return;
496clear_q: 512clear_q:
@@ -508,12 +524,18 @@ enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
508 unsigned long flags; 524 unsigned long flags;
509 525
510 if (!task) { 526 if (!task) {
511 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", 527 SAS_DPRINTK("command 0x%p, task 0x%p, gone: EH_HANDLED\n",
512 cmd, task); 528 cmd, task);
513 return EH_HANDLED; 529 return EH_HANDLED;
514 } 530 }
515 531
516 spin_lock_irqsave(&task->task_state_lock, flags); 532 spin_lock_irqsave(&task->task_state_lock, flags);
533 if (task->task_state_flags & SAS_TASK_INITIATOR_ABORTED) {
534 spin_unlock_irqrestore(&task->task_state_lock, flags);
535 SAS_DPRINTK("command 0x%p, task 0x%p, aborted by initiator: "
536 "EH_NOT_HANDLED\n", cmd, task);
537 return EH_NOT_HANDLED;
538 }
517 if (task->task_state_flags & SAS_TASK_STATE_DONE) { 539 if (task->task_state_flags & SAS_TASK_STATE_DONE) {
518 spin_unlock_irqrestore(&task->task_state_lock, flags); 540 spin_unlock_irqrestore(&task->task_state_lock, flags);
519 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", 541 SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n",
@@ -777,6 +799,66 @@ void sas_shutdown_queue(struct sas_ha_struct *sas_ha)
777 spin_unlock_irqrestore(&core->task_queue_lock, flags); 799 spin_unlock_irqrestore(&core->task_queue_lock, flags);
778} 800}
779 801
802static int do_sas_task_abort(struct sas_task *task)
803{
804 struct scsi_cmnd *sc = task->uldd_task;
805 struct sas_internal *si =
806 to_sas_internal(task->dev->port->ha->core.shost->transportt);
807 unsigned long flags;
808 int res;
809
810 spin_lock_irqsave(&task->task_state_lock, flags);
811 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
812 spin_unlock_irqrestore(&task->task_state_lock, flags);
813 SAS_DPRINTK("%s: Task %p already aborted.\n", __FUNCTION__,
814 task);
815 return 0;
816 }
817
818 task->task_state_flags |= SAS_TASK_INITIATOR_ABORTED;
819 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
820 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
821 spin_unlock_irqrestore(&task->task_state_lock, flags);
822
823 if (!si->dft->lldd_abort_task)
824 return -ENODEV;
825
826 res = si->dft->lldd_abort_task(task);
827 if ((task->task_state_flags & SAS_TASK_STATE_DONE) ||
828 (res == TMF_RESP_FUNC_COMPLETE))
829 {
830 /* SMP commands don't have scsi_cmds(?) */
831 if (!sc) {
832 task->task_done(task);
833 return 0;
834 }
835 scsi_req_abort_cmd(sc);
836 scsi_schedule_eh(sc->device->host);
837 return 0;
838 }
839
840 spin_lock_irqsave(&task->task_state_lock, flags);
841 task->task_state_flags &= ~SAS_TASK_INITIATOR_ABORTED;
842 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
843 task->task_state_flags &= ~SAS_TASK_STATE_ABORTED;
844 spin_unlock_irqrestore(&task->task_state_lock, flags);
845
846 return -EAGAIN;
847}
848
849void sas_task_abort(struct work_struct *work)
850{
851 struct sas_task *task =
852 container_of(work, struct sas_task, abort_work);
853 int i;
854
855 for (i = 0; i < 5; i++)
856 if (!do_sas_task_abort(task))
857 return;
858
859 SAS_DPRINTK("%s: Could not kill task!\n", __FUNCTION__);
860}
861
780EXPORT_SYMBOL_GPL(sas_queuecommand); 862EXPORT_SYMBOL_GPL(sas_queuecommand);
781EXPORT_SYMBOL_GPL(sas_target_alloc); 863EXPORT_SYMBOL_GPL(sas_target_alloc);
782EXPORT_SYMBOL_GPL(sas_slave_configure); 864EXPORT_SYMBOL_GPL(sas_slave_configure);
@@ -784,3 +866,5 @@ EXPORT_SYMBOL_GPL(sas_slave_destroy);
784EXPORT_SYMBOL_GPL(sas_change_queue_depth); 866EXPORT_SYMBOL_GPL(sas_change_queue_depth);
785EXPORT_SYMBOL_GPL(sas_change_queue_type); 867EXPORT_SYMBOL_GPL(sas_change_queue_type);
786EXPORT_SYMBOL_GPL(sas_bios_param); 868EXPORT_SYMBOL_GPL(sas_bios_param);
869EXPORT_SYMBOL_GPL(sas_task_abort);
870EXPORT_SYMBOL_GPL(sas_phy_reset);
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c
new file mode 100644
index 000000000000..89403b00e042
--- /dev/null
+++ b/drivers/scsi/libsrp.c
@@ -0,0 +1,441 @@
1/*
2 * SCSI RDAM Protocol lib functions
3 *
4 * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301 USA
20 */
21#include <linux/err.h>
22#include <linux/kfifo.h>
23#include <linux/scatterlist.h>
24#include <linux/dma-mapping.h>
25#include <linux/pci.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_tcq.h>
29#include <scsi/scsi_tgt.h>
30#include <scsi/srp.h>
31#include <scsi/libsrp.h>
32
33enum srp_task_attributes {
34 SRP_SIMPLE_TASK = 0,
35 SRP_HEAD_TASK = 1,
36 SRP_ORDERED_TASK = 2,
37 SRP_ACA_TASK = 4
38};
39
40/* tmp - will replace with SCSI logging stuff */
41#define eprintk(fmt, args...) \
42do { \
43 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
44} while (0)
45/* #define dprintk eprintk */
46#define dprintk(fmt, args...)
47
48static int srp_iu_pool_alloc(struct srp_queue *q, size_t max,
49 struct srp_buf **ring)
50{
51 int i;
52 struct iu_entry *iue;
53
54 q->pool = kcalloc(max, sizeof(struct iu_entry *), GFP_KERNEL);
55 if (!q->pool)
56 return -ENOMEM;
57 q->items = kcalloc(max, sizeof(struct iu_entry), GFP_KERNEL);
58 if (!q->items)
59 goto free_pool;
60
61 spin_lock_init(&q->lock);
62 q->queue = kfifo_init((void *) q->pool, max * sizeof(void *),
63 GFP_KERNEL, &q->lock);
64 if (IS_ERR(q->queue))
65 goto free_item;
66
67 for (i = 0, iue = q->items; i < max; i++) {
68 __kfifo_put(q->queue, (void *) &iue, sizeof(void *));
69 iue->sbuf = ring[i];
70 iue++;
71 }
72 return 0;
73
74free_item:
75 kfree(q->items);
76free_pool:
77 kfree(q->pool);
78 return -ENOMEM;
79}
80
81static void srp_iu_pool_free(struct srp_queue *q)
82{
83 kfree(q->items);
84 kfree(q->pool);
85}
86
87static struct srp_buf **srp_ring_alloc(struct device *dev,
88 size_t max, size_t size)
89{
90 int i;
91 struct srp_buf **ring;
92
93 ring = kcalloc(max, sizeof(struct srp_buf *), GFP_KERNEL);
94 if (!ring)
95 return NULL;
96
97 for (i = 0; i < max; i++) {
98 ring[i] = kzalloc(sizeof(struct srp_buf), GFP_KERNEL);
99 if (!ring[i])
100 goto out;
101 ring[i]->buf = dma_alloc_coherent(dev, size, &ring[i]->dma,
102 GFP_KERNEL);
103 if (!ring[i]->buf)
104 goto out;
105 }
106 return ring;
107
108out:
109 for (i = 0; i < max && ring[i]; i++) {
110 if (ring[i]->buf)
111 dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma);
112 kfree(ring[i]);
113 }
114 kfree(ring);
115
116 return NULL;
117}
118
119static void srp_ring_free(struct device *dev, struct srp_buf **ring, size_t max,
120 size_t size)
121{
122 int i;
123
124 for (i = 0; i < max; i++) {
125 dma_free_coherent(dev, size, ring[i]->buf, ring[i]->dma);
126 kfree(ring[i]);
127 }
128}
129
130int srp_target_alloc(struct srp_target *target, struct device *dev,
131 size_t nr, size_t iu_size)
132{
133 int err;
134
135 spin_lock_init(&target->lock);
136 INIT_LIST_HEAD(&target->cmd_queue);
137
138 target->dev = dev;
139 target->dev->driver_data = target;
140
141 target->srp_iu_size = iu_size;
142 target->rx_ring_size = nr;
143 target->rx_ring = srp_ring_alloc(target->dev, nr, iu_size);
144 if (!target->rx_ring)
145 return -ENOMEM;
146 err = srp_iu_pool_alloc(&target->iu_queue, nr, target->rx_ring);
147 if (err)
148 goto free_ring;
149
150 return 0;
151
152free_ring:
153 srp_ring_free(target->dev, target->rx_ring, nr, iu_size);
154 return -ENOMEM;
155}
156EXPORT_SYMBOL_GPL(srp_target_alloc);
157
158void srp_target_free(struct srp_target *target)
159{
160 srp_ring_free(target->dev, target->rx_ring, target->rx_ring_size,
161 target->srp_iu_size);
162 srp_iu_pool_free(&target->iu_queue);
163}
164EXPORT_SYMBOL_GPL(srp_target_free);
165
166struct iu_entry *srp_iu_get(struct srp_target *target)
167{
168 struct iu_entry *iue = NULL;
169
170 kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *));
171 if (!iue)
172 return iue;
173 iue->target = target;
174 INIT_LIST_HEAD(&iue->ilist);
175 iue->flags = 0;
176 return iue;
177}
178EXPORT_SYMBOL_GPL(srp_iu_get);
179
180void srp_iu_put(struct iu_entry *iue)
181{
182 kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *));
183}
184EXPORT_SYMBOL_GPL(srp_iu_put);
185
186static int srp_direct_data(struct scsi_cmnd *sc, struct srp_direct_buf *md,
187 enum dma_data_direction dir, srp_rdma_t rdma_io,
188 int dma_map, int ext_desc)
189{
190 struct iu_entry *iue = NULL;
191 struct scatterlist *sg = NULL;
192 int err, nsg = 0, len;
193
194 if (dma_map) {
195 iue = (struct iu_entry *) sc->SCp.ptr;
196 sg = sc->request_buffer;
197
198 dprintk("%p %u %u %d\n", iue, sc->request_bufflen,
199 md->len, sc->use_sg);
200
201 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg,
202 DMA_BIDIRECTIONAL);
203 if (!nsg) {
204 printk("fail to map %p %d\n", iue, sc->use_sg);
205 return 0;
206 }
207 len = min(sc->request_bufflen, md->len);
208 } else
209 len = md->len;
210
211 err = rdma_io(sc, sg, nsg, md, 1, dir, len);
212
213 if (dma_map)
214 dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
215
216 return err;
217}
218
219static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
220 struct srp_indirect_buf *id,
221 enum dma_data_direction dir, srp_rdma_t rdma_io,
222 int dma_map, int ext_desc)
223{
224 struct iu_entry *iue = NULL;
225 struct srp_direct_buf *md = NULL;
226 struct scatterlist dummy, *sg = NULL;
227 dma_addr_t token = 0;
228 long err;
229 unsigned int done = 0;
230 int nmd, nsg = 0, len;
231
232 if (dma_map || ext_desc) {
233 iue = (struct iu_entry *) sc->SCp.ptr;
234 sg = sc->request_buffer;
235
236 dprintk("%p %u %u %d %d\n",
237 iue, sc->request_bufflen, id->len,
238 cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
239 }
240
241 nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
242
243 if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
244 (dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) {
245 md = &id->desc_list[0];
246 goto rdma;
247 }
248
249 if (ext_desc && dma_map) {
250 md = dma_alloc_coherent(iue->target->dev, id->table_desc.len,
251 &token, GFP_KERNEL);
252 if (!md) {
253 eprintk("Can't get dma memory %u\n", id->table_desc.len);
254 return -ENOMEM;
255 }
256
257 sg_init_one(&dummy, md, id->table_desc.len);
258 sg_dma_address(&dummy) = token;
259 err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
260 id->table_desc.len);
261 if (err < 0) {
262 eprintk("Error copying indirect table %ld\n", err);
263 goto free_mem;
264 }
265 } else {
266 eprintk("This command uses external indirect buffer\n");
267 return -EINVAL;
268 }
269
270rdma:
271 if (dma_map) {
272 nsg = dma_map_sg(iue->target->dev, sg, sc->use_sg, DMA_BIDIRECTIONAL);
273 if (!nsg) {
274 eprintk("fail to map %p %d\n", iue, sc->use_sg);
275 goto free_mem;
276 }
277 len = min(sc->request_bufflen, id->len);
278 } else
279 len = id->len;
280
281 err = rdma_io(sc, sg, nsg, md, nmd, dir, len);
282
283 if (dma_map)
284 dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
285
286free_mem:
287 if (token && dma_map)
288 dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
289
290 return done;
291}
292
293static int data_out_desc_size(struct srp_cmd *cmd)
294{
295 int size = 0;
296 u8 fmt = cmd->buf_fmt >> 4;
297
298 switch (fmt) {
299 case SRP_NO_DATA_DESC:
300 break;
301 case SRP_DATA_DESC_DIRECT:
302 size = sizeof(struct srp_direct_buf);
303 break;
304 case SRP_DATA_DESC_INDIRECT:
305 size = sizeof(struct srp_indirect_buf) +
306 sizeof(struct srp_direct_buf) * cmd->data_out_desc_cnt;
307 break;
308 default:
309 eprintk("client error. Invalid data_out_format %x\n", fmt);
310 break;
311 }
312 return size;
313}
314
315/*
316 * TODO: this can be called multiple times for a single command if it
317 * has very long data.
318 */
319int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
320 srp_rdma_t rdma_io, int dma_map, int ext_desc)
321{
322 struct srp_direct_buf *md;
323 struct srp_indirect_buf *id;
324 enum dma_data_direction dir;
325 int offset, err = 0;
326 u8 format;
327
328 offset = cmd->add_cdb_len * 4;
329
330 dir = srp_cmd_direction(cmd);
331 if (dir == DMA_FROM_DEVICE)
332 offset += data_out_desc_size(cmd);
333
334 if (dir == DMA_TO_DEVICE)
335 format = cmd->buf_fmt >> 4;
336 else
337 format = cmd->buf_fmt & ((1U << 4) - 1);
338
339 switch (format) {
340 case SRP_NO_DATA_DESC:
341 break;
342 case SRP_DATA_DESC_DIRECT:
343 md = (struct srp_direct_buf *)
344 (cmd->add_data + offset);
345 err = srp_direct_data(sc, md, dir, rdma_io, dma_map, ext_desc);
346 break;
347 case SRP_DATA_DESC_INDIRECT:
348 id = (struct srp_indirect_buf *)
349 (cmd->add_data + offset);
350 err = srp_indirect_data(sc, cmd, id, dir, rdma_io, dma_map,
351 ext_desc);
352 break;
353 default:
354 eprintk("Unknown format %d %x\n", dir, format);
355 break;
356 }
357
358 return err;
359}
360EXPORT_SYMBOL_GPL(srp_transfer_data);
361
362static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir)
363{
364 struct srp_direct_buf *md;
365 struct srp_indirect_buf *id;
366 int len = 0, offset = cmd->add_cdb_len * 4;
367 u8 fmt;
368
369 if (dir == DMA_TO_DEVICE)
370 fmt = cmd->buf_fmt >> 4;
371 else {
372 fmt = cmd->buf_fmt & ((1U << 4) - 1);
373 offset += data_out_desc_size(cmd);
374 }
375
376 switch (fmt) {
377 case SRP_NO_DATA_DESC:
378 break;
379 case SRP_DATA_DESC_DIRECT:
380 md = (struct srp_direct_buf *) (cmd->add_data + offset);
381 len = md->len;
382 break;
383 case SRP_DATA_DESC_INDIRECT:
384 id = (struct srp_indirect_buf *) (cmd->add_data + offset);
385 len = id->len;
386 break;
387 default:
388 eprintk("invalid data format %x\n", fmt);
389 break;
390 }
391 return len;
392}
393
394int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info,
395 u64 addr)
396{
397 enum dma_data_direction dir;
398 struct scsi_cmnd *sc;
399 int tag, len, err;
400
401 switch (cmd->task_attr) {
402 case SRP_SIMPLE_TASK:
403 tag = MSG_SIMPLE_TAG;
404 break;
405 case SRP_ORDERED_TASK:
406 tag = MSG_ORDERED_TAG;
407 break;
408 case SRP_HEAD_TASK:
409 tag = MSG_HEAD_TAG;
410 break;
411 default:
412 eprintk("Task attribute %d not supported\n", cmd->task_attr);
413 tag = MSG_ORDERED_TAG;
414 }
415
416 dir = srp_cmd_direction(cmd);
417 len = vscsis_data_length(cmd, dir);
418
419 dprintk("%p %x %lx %d %d %d %llx\n", info, cmd->cdb[0],
420 cmd->lun, dir, len, tag, (unsigned long long) cmd->tag);
421
422 sc = scsi_host_get_command(shost, dir, GFP_KERNEL);
423 if (!sc)
424 return -ENOMEM;
425
426 sc->SCp.ptr = info;
427 memcpy(sc->cmnd, cmd->cdb, MAX_COMMAND_SIZE);
428 sc->request_bufflen = len;
429 sc->request_buffer = (void *) (unsigned long) addr;
430 sc->tag = tag;
431 err = scsi_tgt_queue_command(sc, (struct scsi_lun *) &cmd->lun, cmd->tag);
432 if (err)
433 scsi_host_put_command(shost, sc);
434
435 return err;
436}
437EXPORT_SYMBOL_GPL(srp_cmd_queue);
438
439MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions");
440MODULE_AUTHOR("FUJITA Tomonori");
441MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 3f7f5f8abd75..a7de0bca5bdd 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -296,13 +296,17 @@ struct lpfc_hba {
296 uint32_t cfg_cr_delay; 296 uint32_t cfg_cr_delay;
297 uint32_t cfg_cr_count; 297 uint32_t cfg_cr_count;
298 uint32_t cfg_multi_ring_support; 298 uint32_t cfg_multi_ring_support;
299 uint32_t cfg_multi_ring_rctl;
300 uint32_t cfg_multi_ring_type;
299 uint32_t cfg_fdmi_on; 301 uint32_t cfg_fdmi_on;
300 uint32_t cfg_discovery_threads; 302 uint32_t cfg_discovery_threads;
301 uint32_t cfg_max_luns; 303 uint32_t cfg_max_luns;
302 uint32_t cfg_poll; 304 uint32_t cfg_poll;
303 uint32_t cfg_poll_tmo; 305 uint32_t cfg_poll_tmo;
306 uint32_t cfg_use_msi;
304 uint32_t cfg_sg_seg_cnt; 307 uint32_t cfg_sg_seg_cnt;
305 uint32_t cfg_sg_dma_buf_size; 308 uint32_t cfg_sg_dma_buf_size;
309 uint64_t cfg_soft_wwnn;
306 uint64_t cfg_soft_wwpn; 310 uint64_t cfg_soft_wwpn;
307 311
308 uint32_t dev_loss_tmo_changed; 312 uint32_t dev_loss_tmo_changed;
@@ -355,7 +359,7 @@ struct lpfc_hba {
355#define VPD_PORT 0x8 /* valid vpd port data */ 359#define VPD_PORT 0x8 /* valid vpd port data */
356#define VPD_MASK 0xf /* mask for any vpd data */ 360#define VPD_MASK 0xf /* mask for any vpd data */
357 361
358 uint8_t soft_wwpn_enable; 362 uint8_t soft_wwn_enable;
359 363
360 struct timer_list fcp_poll_timer; 364 struct timer_list fcp_poll_timer;
361 struct timer_list els_tmofunc; 365 struct timer_list els_tmofunc;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 2a4e02e7a392..f247e786af99 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -552,10 +552,10 @@ static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
552static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 552static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
553 553
554 554
555static char *lpfc_soft_wwpn_key = "C99G71SL8032A"; 555static char *lpfc_soft_wwn_key = "C99G71SL8032A";
556 556
557static ssize_t 557static ssize_t
558lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf, 558lpfc_soft_wwn_enable_store(struct class_device *cdev, const char *buf,
559 size_t count) 559 size_t count)
560{ 560{
561 struct Scsi_Host *host = class_to_shost(cdev); 561 struct Scsi_Host *host = class_to_shost(cdev);
@@ -579,15 +579,15 @@ lpfc_soft_wwpn_enable_store(struct class_device *cdev, const char *buf,
579 if (buf[cnt-1] == '\n') 579 if (buf[cnt-1] == '\n')
580 cnt--; 580 cnt--;
581 581
582 if ((cnt != strlen(lpfc_soft_wwpn_key)) || 582 if ((cnt != strlen(lpfc_soft_wwn_key)) ||
583 (strncmp(buf, lpfc_soft_wwpn_key, strlen(lpfc_soft_wwpn_key)) != 0)) 583 (strncmp(buf, lpfc_soft_wwn_key, strlen(lpfc_soft_wwn_key)) != 0))
584 return -EINVAL; 584 return -EINVAL;
585 585
586 phba->soft_wwpn_enable = 1; 586 phba->soft_wwn_enable = 1;
587 return count; 587 return count;
588} 588}
589static CLASS_DEVICE_ATTR(lpfc_soft_wwpn_enable, S_IWUSR, NULL, 589static CLASS_DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
590 lpfc_soft_wwpn_enable_store); 590 lpfc_soft_wwn_enable_store);
591 591
592static ssize_t 592static ssize_t
593lpfc_soft_wwpn_show(struct class_device *cdev, char *buf) 593lpfc_soft_wwpn_show(struct class_device *cdev, char *buf)
@@ -613,12 +613,12 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
613 if (buf[cnt-1] == '\n') 613 if (buf[cnt-1] == '\n')
614 cnt--; 614 cnt--;
615 615
616 if (!phba->soft_wwpn_enable || (cnt < 16) || (cnt > 18) || 616 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
617 ((cnt == 17) && (*buf++ != 'x')) || 617 ((cnt == 17) && (*buf++ != 'x')) ||
618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x')))) 618 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
619 return -EINVAL; 619 return -EINVAL;
620 620
621 phba->soft_wwpn_enable = 0; 621 phba->soft_wwn_enable = 0;
622 622
623 memset(wwpn, 0, sizeof(wwpn)); 623 memset(wwpn, 0, sizeof(wwpn));
624 624
@@ -639,6 +639,8 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
639 } 639 }
640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn); 640 phba->cfg_soft_wwpn = wwn_to_u64(wwpn);
641 fc_host_port_name(host) = phba->cfg_soft_wwpn; 641 fc_host_port_name(host) = phba->cfg_soft_wwpn;
642 if (phba->cfg_soft_wwnn)
643 fc_host_node_name(host) = phba->cfg_soft_wwnn;
642 644
643 dev_printk(KERN_NOTICE, &phba->pcidev->dev, 645 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
644 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no); 646 "lpfc%d: Reinitializing to use soft_wwpn\n", phba->brd_no);
@@ -664,6 +666,66 @@ lpfc_soft_wwpn_store(struct class_device *cdev, const char *buf, size_t count)
664static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ 666static CLASS_DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\
665 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); 667 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
666 668
669static ssize_t
670lpfc_soft_wwnn_show(struct class_device *cdev, char *buf)
671{
672 struct Scsi_Host *host = class_to_shost(cdev);
673 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
674 return snprintf(buf, PAGE_SIZE, "0x%llx\n",
675 (unsigned long long)phba->cfg_soft_wwnn);
676}
677
678
679static ssize_t
680lpfc_soft_wwnn_store(struct class_device *cdev, const char *buf, size_t count)
681{
682 struct Scsi_Host *host = class_to_shost(cdev);
683 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
684 unsigned int i, j, cnt=count;
685 u8 wwnn[8];
686
687 /* count may include a LF at end of string */
688 if (buf[cnt-1] == '\n')
689 cnt--;
690
691 if (!phba->soft_wwn_enable || (cnt < 16) || (cnt > 18) ||
692 ((cnt == 17) && (*buf++ != 'x')) ||
693 ((cnt == 18) && ((*buf++ != '0') || (*buf++ != 'x'))))
694 return -EINVAL;
695
696 /*
697 * Allow wwnn to be set many times, as long as the enable is set.
698 * However, once the wwpn is set, everything locks.
699 */
700
701 memset(wwnn, 0, sizeof(wwnn));
702
703 /* Validate and store the new name */
704 for (i=0, j=0; i < 16; i++) {
705 if ((*buf >= 'a') && (*buf <= 'f'))
706 j = ((j << 4) | ((*buf++ -'a') + 10));
707 else if ((*buf >= 'A') && (*buf <= 'F'))
708 j = ((j << 4) | ((*buf++ -'A') + 10));
709 else if ((*buf >= '0') && (*buf <= '9'))
710 j = ((j << 4) | (*buf++ -'0'));
711 else
712 return -EINVAL;
713 if (i % 2) {
714 wwnn[i/2] = j & 0xff;
715 j = 0;
716 }
717 }
718 phba->cfg_soft_wwnn = wwn_to_u64(wwnn);
719
720 dev_printk(KERN_NOTICE, &phba->pcidev->dev,
721 "lpfc%d: soft_wwnn set. Value will take effect upon "
722 "setting of the soft_wwpn\n", phba->brd_no);
723
724 return count;
725}
726static CLASS_DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR,\
727 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
728
667 729
668static int lpfc_poll = 0; 730static int lpfc_poll = 0;
669module_param(lpfc_poll, int, 0); 731module_param(lpfc_poll, int, 0);
@@ -802,12 +864,11 @@ static CLASS_DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR,
802# LOG_MBOX 0x4 Mailbox events 864# LOG_MBOX 0x4 Mailbox events
803# LOG_INIT 0x8 Initialization events 865# LOG_INIT 0x8 Initialization events
804# LOG_LINK_EVENT 0x10 Link events 866# LOG_LINK_EVENT 0x10 Link events
805# LOG_IP 0x20 IP traffic history
806# LOG_FCP 0x40 FCP traffic history 867# LOG_FCP 0x40 FCP traffic history
807# LOG_NODE 0x80 Node table events 868# LOG_NODE 0x80 Node table events
808# LOG_MISC 0x400 Miscellaneous events 869# LOG_MISC 0x400 Miscellaneous events
809# LOG_SLI 0x800 SLI events 870# LOG_SLI 0x800 SLI events
810# LOG_CHK_COND 0x1000 FCP Check condition flag 871# LOG_FCP_ERROR 0x1000 Only log FCP errors
811# LOG_LIBDFC 0x2000 LIBDFC events 872# LOG_LIBDFC 0x2000 LIBDFC events
812# LOG_ALL_MSG 0xffff LOG all messages 873# LOG_ALL_MSG 0xffff LOG all messages
813*/ 874*/
@@ -916,6 +977,22 @@ LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
916 "SLI rings to spread IOCB entries across"); 977 "SLI rings to spread IOCB entries across");
917 978
918/* 979/*
980# lpfc_multi_ring_rctl: If lpfc_multi_ring_support is enabled, this
981# identifies what rctl value to configure the additional ring for.
982# Value range is [1,0xff]. Default value is 4 (Unsolicated Data).
983*/
984LPFC_ATTR_R(multi_ring_rctl, FC_UNSOL_DATA, 1,
985 255, "Identifies RCTL for additional ring configuration");
986
987/*
988# lpfc_multi_ring_type: If lpfc_multi_ring_support is enabled, this
989# identifies what type value to configure the additional ring for.
990# Value range is [1,0xff]. Default value is 5 (LLC/SNAP).
991*/
992LPFC_ATTR_R(multi_ring_type, FC_LLC_SNAP, 1,
993 255, "Identifies TYPE for additional ring configuration");
994
995/*
919# lpfc_fdmi_on: controls FDMI support. 996# lpfc_fdmi_on: controls FDMI support.
920# 0 = no FDMI support 997# 0 = no FDMI support
921# 1 = support FDMI without attribute of hostname 998# 1 = support FDMI without attribute of hostname
@@ -946,6 +1023,15 @@ LPFC_ATTR_R(max_luns, 255, 0, 65535,
946LPFC_ATTR_RW(poll_tmo, 10, 1, 255, 1023LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
947 "Milliseconds driver will wait between polling FCP ring"); 1024 "Milliseconds driver will wait between polling FCP ring");
948 1025
1026/*
1027# lpfc_use_msi: Use MSI (Message Signaled Interrupts) in systems that
1028# support this feature
1029# 0 = MSI disabled (default)
1030# 1 = MSI enabled
1031# Value range is [0,1]. Default value is 0.
1032*/
1033LPFC_ATTR_R(use_msi, 0, 0, 1, "Use Message Signaled Interrupts, if possible");
1034
949 1035
950struct class_device_attribute *lpfc_host_attrs[] = { 1036struct class_device_attribute *lpfc_host_attrs[] = {
951 &class_device_attr_info, 1037 &class_device_attr_info,
@@ -974,6 +1060,8 @@ struct class_device_attribute *lpfc_host_attrs[] = {
974 &class_device_attr_lpfc_cr_delay, 1060 &class_device_attr_lpfc_cr_delay,
975 &class_device_attr_lpfc_cr_count, 1061 &class_device_attr_lpfc_cr_count,
976 &class_device_attr_lpfc_multi_ring_support, 1062 &class_device_attr_lpfc_multi_ring_support,
1063 &class_device_attr_lpfc_multi_ring_rctl,
1064 &class_device_attr_lpfc_multi_ring_type,
977 &class_device_attr_lpfc_fdmi_on, 1065 &class_device_attr_lpfc_fdmi_on,
978 &class_device_attr_lpfc_max_luns, 1066 &class_device_attr_lpfc_max_luns,
979 &class_device_attr_nport_evt_cnt, 1067 &class_device_attr_nport_evt_cnt,
@@ -982,8 +1070,10 @@ struct class_device_attribute *lpfc_host_attrs[] = {
982 &class_device_attr_issue_reset, 1070 &class_device_attr_issue_reset,
983 &class_device_attr_lpfc_poll, 1071 &class_device_attr_lpfc_poll,
984 &class_device_attr_lpfc_poll_tmo, 1072 &class_device_attr_lpfc_poll_tmo,
1073 &class_device_attr_lpfc_use_msi,
1074 &class_device_attr_lpfc_soft_wwnn,
985 &class_device_attr_lpfc_soft_wwpn, 1075 &class_device_attr_lpfc_soft_wwpn,
986 &class_device_attr_lpfc_soft_wwpn_enable, 1076 &class_device_attr_lpfc_soft_wwn_enable,
987 NULL, 1077 NULL,
988}; 1078};
989 1079
@@ -1771,6 +1861,8 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1771 lpfc_cr_delay_init(phba, lpfc_cr_delay); 1861 lpfc_cr_delay_init(phba, lpfc_cr_delay);
1772 lpfc_cr_count_init(phba, lpfc_cr_count); 1862 lpfc_cr_count_init(phba, lpfc_cr_count);
1773 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support); 1863 lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
1864 lpfc_multi_ring_rctl_init(phba, lpfc_multi_ring_rctl);
1865 lpfc_multi_ring_type_init(phba, lpfc_multi_ring_type);
1774 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth); 1866 lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
1775 lpfc_fcp_class_init(phba, lpfc_fcp_class); 1867 lpfc_fcp_class_init(phba, lpfc_fcp_class);
1776 lpfc_use_adisc_init(phba, lpfc_use_adisc); 1868 lpfc_use_adisc_init(phba, lpfc_use_adisc);
@@ -1782,9 +1874,11 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1782 lpfc_discovery_threads_init(phba, lpfc_discovery_threads); 1874 lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
1783 lpfc_max_luns_init(phba, lpfc_max_luns); 1875 lpfc_max_luns_init(phba, lpfc_max_luns);
1784 lpfc_poll_tmo_init(phba, lpfc_poll_tmo); 1876 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
1877 lpfc_use_msi_init(phba, lpfc_use_msi);
1785 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo); 1878 lpfc_devloss_tmo_init(phba, lpfc_devloss_tmo);
1786 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo); 1879 lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
1787 phba->cfg_poll = lpfc_poll; 1880 phba->cfg_poll = lpfc_poll;
1881 phba->cfg_soft_wwnn = 0L;
1788 phba->cfg_soft_wwpn = 0L; 1882 phba->cfg_soft_wwpn = 0L;
1789 1883
1790 /* 1884 /*
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 3add7c237859..a51a41b7f15d 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -558,6 +558,14 @@ lpfc_cmpl_ct_cmd_rsnn_nn(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
558 return; 558 return;
559} 559}
560 560
561static void
562lpfc_cmpl_ct_cmd_rff_id(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
563 struct lpfc_iocbq * rspiocb)
564{
565 lpfc_cmpl_ct_cmd_rft_id(phba, cmdiocb, rspiocb);
566 return;
567}
568
561void 569void
562lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp) 570lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp)
563{ 571{
@@ -629,6 +637,8 @@ lpfc_ns_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
629 bpl->tus.f.bdeSize = RNN_REQUEST_SZ; 637 bpl->tus.f.bdeSize = RNN_REQUEST_SZ;
630 else if (cmdcode == SLI_CTNS_RSNN_NN) 638 else if (cmdcode == SLI_CTNS_RSNN_NN)
631 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ; 639 bpl->tus.f.bdeSize = RSNN_REQUEST_SZ;
640 else if (cmdcode == SLI_CTNS_RFF_ID)
641 bpl->tus.f.bdeSize = RFF_REQUEST_SZ;
632 else 642 else
633 bpl->tus.f.bdeSize = 0; 643 bpl->tus.f.bdeSize = 0;
634 bpl->tus.w = le32_to_cpu(bpl->tus.w); 644 bpl->tus.w = le32_to_cpu(bpl->tus.w);
@@ -660,6 +670,17 @@ lpfc_ns_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
660 cmpl = lpfc_cmpl_ct_cmd_rft_id; 670 cmpl = lpfc_cmpl_ct_cmd_rft_id;
661 break; 671 break;
662 672
673 case SLI_CTNS_RFF_ID:
674 CtReq->CommandResponse.bits.CmdRsp =
675 be16_to_cpu(SLI_CTNS_RFF_ID);
676 CtReq->un.rff.PortId = be32_to_cpu(phba->fc_myDID);
677 CtReq->un.rff.feature_res = 0;
678 CtReq->un.rff.feature_tgt = 0;
679 CtReq->un.rff.type_code = FC_FCP_DATA;
680 CtReq->un.rff.feature_init = 1;
681 cmpl = lpfc_cmpl_ct_cmd_rff_id;
682 break;
683
663 case SLI_CTNS_RNN_ID: 684 case SLI_CTNS_RNN_ID:
664 CtReq->CommandResponse.bits.CmdRsp = 685 CtReq->CommandResponse.bits.CmdRsp =
665 be16_to_cpu(SLI_CTNS_RNN_ID); 686 be16_to_cpu(SLI_CTNS_RNN_ID);
@@ -934,7 +955,8 @@ lpfc_fdmi_cmd(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, int cmdcode)
934 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size); 955 ae = (ATTRIBUTE_ENTRY *) ((uint8_t *) rh + size);
935 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION); 956 ae->ad.bits.AttrType = be16_to_cpu(OS_NAME_VERSION);
936 sprintf(ae->un.OsNameVersion, "%s %s %s", 957 sprintf(ae->un.OsNameVersion, "%s %s %s",
937 init_utsname()->sysname, init_utsname()->release, 958 init_utsname()->sysname,
959 init_utsname()->release,
938 init_utsname()->version); 960 init_utsname()->version);
939 len = strlen(ae->un.OsNameVersion); 961 len = strlen(ae->un.OsNameVersion);
940 len += (len & 3) ? (4 - (len & 3)) : 4; 962 len += (len & 3) ? (4 - (len & 3)) : 4;
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index 71864cdc6c71..a5f33a0dd4e7 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -243,6 +243,7 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
243 struct serv_parm *sp, IOCB_t *irsp) 243 struct serv_parm *sp, IOCB_t *irsp)
244{ 244{
245 LPFC_MBOXQ_t *mbox; 245 LPFC_MBOXQ_t *mbox;
246 struct lpfc_dmabuf *mp;
246 int rc; 247 int rc;
247 248
248 spin_lock_irq(phba->host->host_lock); 249 spin_lock_irq(phba->host->host_lock);
@@ -307,10 +308,14 @@ lpfc_cmpl_els_flogi_fabric(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp,
307 308
308 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB); 309 rc = lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT | MBX_STOP_IOCB);
309 if (rc == MBX_NOT_FINISHED) 310 if (rc == MBX_NOT_FINISHED)
310 goto fail_free_mbox; 311 goto fail_issue_reg_login;
311 312
312 return 0; 313 return 0;
313 314
315 fail_issue_reg_login:
316 mp = (struct lpfc_dmabuf *) mbox->context1;
317 lpfc_mbuf_free(phba, mp->virt, mp->phys);
318 kfree(mp);
314 fail_free_mbox: 319 fail_free_mbox:
315 mempool_free(mbox, phba->mbox_mem_pool); 320 mempool_free(mbox, phba->mbox_mem_pool);
316 fail: 321 fail:
@@ -657,6 +662,12 @@ lpfc_plogi_confirm_nport(struct lpfc_hba * phba, struct lpfc_dmabuf *prsp,
657 uint8_t name[sizeof (struct lpfc_name)]; 662 uint8_t name[sizeof (struct lpfc_name)];
658 uint32_t rc; 663 uint32_t rc;
659 664
665 /* Fabric nodes can have the same WWPN so we don't bother searching
666 * by WWPN. Just return the ndlp that was given to us.
667 */
668 if (ndlp->nlp_type & NLP_FABRIC)
669 return ndlp;
670
660 lp = (uint32_t *) prsp->virt; 671 lp = (uint32_t *) prsp->virt;
661 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t)); 672 sp = (struct serv_parm *) ((uint8_t *) lp + sizeof (uint32_t));
662 memset(name, 0, sizeof (struct lpfc_name)); 673 memset(name, 0, sizeof (struct lpfc_name));
@@ -1122,7 +1133,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1122 mempool_free(mbox, 1133 mempool_free(mbox,
1123 phba->mbox_mem_pool); 1134 phba->mbox_mem_pool);
1124 lpfc_disc_flush_list(phba); 1135 lpfc_disc_flush_list(phba);
1125 psli->ring[(psli->ip_ring)]. 1136 psli->ring[(psli->extra_ring)].
1126 flag &= 1137 flag &=
1127 ~LPFC_STOP_IOCB_EVENT; 1138 ~LPFC_STOP_IOCB_EVENT;
1128 psli->ring[(psli->fcp_ring)]. 1139 psli->ring[(psli->fcp_ring)].
@@ -1851,6 +1862,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1851 IOCB_t *irsp; 1862 IOCB_t *irsp;
1852 struct lpfc_nodelist *ndlp; 1863 struct lpfc_nodelist *ndlp;
1853 LPFC_MBOXQ_t *mbox = NULL; 1864 LPFC_MBOXQ_t *mbox = NULL;
1865 struct lpfc_dmabuf *mp;
1854 1866
1855 irsp = &rspiocb->iocb; 1867 irsp = &rspiocb->iocb;
1856 1868
@@ -1862,6 +1874,11 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1862 /* Check to see if link went down during discovery */ 1874 /* Check to see if link went down during discovery */
1863 if ((lpfc_els_chk_latt(phba)) || !ndlp) { 1875 if ((lpfc_els_chk_latt(phba)) || !ndlp) {
1864 if (mbox) { 1876 if (mbox) {
1877 mp = (struct lpfc_dmabuf *) mbox->context1;
1878 if (mp) {
1879 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1880 kfree(mp);
1881 }
1865 mempool_free( mbox, phba->mbox_mem_pool); 1882 mempool_free( mbox, phba->mbox_mem_pool);
1866 } 1883 }
1867 goto out; 1884 goto out;
@@ -1893,9 +1910,7 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1893 } 1910 }
1894 /* NOTE: we should have messages for unsuccessful 1911 /* NOTE: we should have messages for unsuccessful
1895 reglogin */ 1912 reglogin */
1896 mempool_free( mbox, phba->mbox_mem_pool);
1897 } else { 1913 } else {
1898 mempool_free( mbox, phba->mbox_mem_pool);
1899 /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */ 1914 /* Do not call NO_LIST for lpfc_els_abort'ed ELS cmds */
1900 if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1915 if (!((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
1901 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1916 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
@@ -1907,6 +1922,12 @@ lpfc_cmpl_els_acc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1907 } 1922 }
1908 } 1923 }
1909 } 1924 }
1925 mp = (struct lpfc_dmabuf *) mbox->context1;
1926 if (mp) {
1927 lpfc_mbuf_free(phba, mp->virt, mp->phys);
1928 kfree(mp);
1929 }
1930 mempool_free(mbox, phba->mbox_mem_pool);
1910 } 1931 }
1911out: 1932out:
1912 if (ndlp) { 1933 if (ndlp) {
@@ -2644,6 +2665,7 @@ lpfc_els_handle_rscn(struct lpfc_hba * phba)
2644 ndlp->nlp_type |= NLP_FABRIC; 2665 ndlp->nlp_type |= NLP_FABRIC;
2645 ndlp->nlp_prev_state = ndlp->nlp_state; 2666 ndlp->nlp_prev_state = ndlp->nlp_state;
2646 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE; 2667 ndlp->nlp_state = NLP_STE_PLOGI_ISSUE;
2668 lpfc_nlp_list(phba, ndlp, NLP_PLOGI_LIST);
2647 lpfc_issue_els_plogi(phba, NameServer_DID, 0); 2669 lpfc_issue_els_plogi(phba, NameServer_DID, 0);
2648 /* Wait for NameServer login cmpl before we can 2670 /* Wait for NameServer login cmpl before we can
2649 continue */ 2671 continue */
@@ -3039,7 +3061,7 @@ lpfc_els_rcv_farp(struct lpfc_hba * phba,
3039 /* FARP-REQ received from DID <did> */ 3061 /* FARP-REQ received from DID <did> */
3040 lpfc_printf_log(phba, 3062 lpfc_printf_log(phba,
3041 KERN_INFO, 3063 KERN_INFO,
3042 LOG_IP, 3064 LOG_ELS,
3043 "%d:0601 FARP-REQ received from DID x%x\n", 3065 "%d:0601 FARP-REQ received from DID x%x\n",
3044 phba->brd_no, did); 3066 phba->brd_no, did);
3045 3067
@@ -3101,7 +3123,7 @@ lpfc_els_rcv_farpr(struct lpfc_hba * phba,
3101 /* FARP-RSP received from DID <did> */ 3123 /* FARP-RSP received from DID <did> */
3102 lpfc_printf_log(phba, 3124 lpfc_printf_log(phba,
3103 KERN_INFO, 3125 KERN_INFO,
3104 LOG_IP, 3126 LOG_ELS,
3105 "%d:0600 FARP-RSP received from DID x%x\n", 3127 "%d:0600 FARP-RSP received from DID x%x\n",
3106 phba->brd_no, did); 3128 phba->brd_no, did);
3107 3129
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 19c79a0549a7..c39564e85e94 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -525,7 +525,7 @@ lpfc_mbx_cmpl_clear_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
525 psli = &phba->sli; 525 psli = &phba->sli;
526 mb = &pmb->mb; 526 mb = &pmb->mb;
527 /* Since we don't do discovery right now, turn these off here */ 527 /* Since we don't do discovery right now, turn these off here */
528 psli->ring[psli->ip_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 528 psli->ring[psli->extra_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
529 psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 529 psli->ring[psli->fcp_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
530 psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT; 530 psli->ring[psli->next_ring].flag &= ~LPFC_STOP_IOCB_EVENT;
531 531
@@ -641,7 +641,7 @@ out:
641 if (rc == MBX_NOT_FINISHED) { 641 if (rc == MBX_NOT_FINISHED) {
642 mempool_free(pmb, phba->mbox_mem_pool); 642 mempool_free(pmb, phba->mbox_mem_pool);
643 lpfc_disc_flush_list(phba); 643 lpfc_disc_flush_list(phba);
644 psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 644 psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
645 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 645 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
646 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 646 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
647 phba->hba_state = LPFC_HBA_READY; 647 phba->hba_state = LPFC_HBA_READY;
@@ -672,6 +672,8 @@ lpfc_mbx_cmpl_read_sparam(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
672 672
673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt, 673 memcpy((uint8_t *) & phba->fc_sparam, (uint8_t *) mp->virt,
674 sizeof (struct serv_parm)); 674 sizeof (struct serv_parm));
675 if (phba->cfg_soft_wwnn)
676 u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn);
675 if (phba->cfg_soft_wwpn) 677 if (phba->cfg_soft_wwpn)
676 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 678 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn);
677 memcpy((uint8_t *) & phba->fc_nodename, 679 memcpy((uint8_t *) & phba->fc_nodename,
@@ -696,7 +698,7 @@ out:
696 == MBX_NOT_FINISHED) { 698 == MBX_NOT_FINISHED) {
697 mempool_free( pmb, phba->mbox_mem_pool); 699 mempool_free( pmb, phba->mbox_mem_pool);
698 lpfc_disc_flush_list(phba); 700 lpfc_disc_flush_list(phba);
699 psli->ring[(psli->ip_ring)].flag &= 701 psli->ring[(psli->extra_ring)].flag &=
700 ~LPFC_STOP_IOCB_EVENT; 702 ~LPFC_STOP_IOCB_EVENT;
701 psli->ring[(psli->fcp_ring)].flag &= 703 psli->ring[(psli->fcp_ring)].flag &=
702 ~LPFC_STOP_IOCB_EVENT; 704 ~LPFC_STOP_IOCB_EVENT;
@@ -715,6 +717,9 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
715{ 717{
716 int i; 718 int i;
717 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox; 719 LPFC_MBOXQ_t *sparam_mbox, *cfglink_mbox;
720 struct lpfc_dmabuf *mp;
721 int rc;
722
718 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 723 sparam_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
719 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); 724 cfglink_mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
720 725
@@ -793,16 +798,27 @@ lpfc_mbx_process_link_up(struct lpfc_hba *phba, READ_LA_VAR *la)
793 if (sparam_mbox) { 798 if (sparam_mbox) {
794 lpfc_read_sparam(phba, sparam_mbox); 799 lpfc_read_sparam(phba, sparam_mbox);
795 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam; 800 sparam_mbox->mbox_cmpl = lpfc_mbx_cmpl_read_sparam;
796 lpfc_sli_issue_mbox(phba, sparam_mbox, 801 rc = lpfc_sli_issue_mbox(phba, sparam_mbox,
797 (MBX_NOWAIT | MBX_STOP_IOCB)); 802 (MBX_NOWAIT | MBX_STOP_IOCB));
803 if (rc == MBX_NOT_FINISHED) {
804 mp = (struct lpfc_dmabuf *) sparam_mbox->context1;
805 lpfc_mbuf_free(phba, mp->virt, mp->phys);
806 kfree(mp);
807 mempool_free(sparam_mbox, phba->mbox_mem_pool);
808 if (cfglink_mbox)
809 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
810 return;
811 }
798 } 812 }
799 813
800 if (cfglink_mbox) { 814 if (cfglink_mbox) {
801 phba->hba_state = LPFC_LOCAL_CFG_LINK; 815 phba->hba_state = LPFC_LOCAL_CFG_LINK;
802 lpfc_config_link(phba, cfglink_mbox); 816 lpfc_config_link(phba, cfglink_mbox);
803 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link; 817 cfglink_mbox->mbox_cmpl = lpfc_mbx_cmpl_local_config_link;
804 lpfc_sli_issue_mbox(phba, cfglink_mbox, 818 rc = lpfc_sli_issue_mbox(phba, cfglink_mbox,
805 (MBX_NOWAIT | MBX_STOP_IOCB)); 819 (MBX_NOWAIT | MBX_STOP_IOCB));
820 if (rc == MBX_NOT_FINISHED)
821 mempool_free(cfglink_mbox, phba->mbox_mem_pool);
806 } 822 }
807} 823}
808 824
@@ -1067,6 +1083,7 @@ lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb)
1067 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID); 1083 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RNN_ID);
1068 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN); 1084 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RSNN_NN);
1069 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID); 1085 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFT_ID);
1086 lpfc_ns_cmd(phba, ndlp, SLI_CTNS_RFF_ID);
1070 } 1087 }
1071 1088
1072 phba->fc_ns_retry = 0; 1089 phba->fc_ns_retry = 0;
@@ -1423,7 +1440,7 @@ lpfc_check_sli_ndlp(struct lpfc_hba * phba,
1423 if (iocb->context1 == (uint8_t *) ndlp) 1440 if (iocb->context1 == (uint8_t *) ndlp)
1424 return 1; 1441 return 1;
1425 } 1442 }
1426 } else if (pring->ringno == psli->ip_ring) { 1443 } else if (pring->ringno == psli->extra_ring) {
1427 1444
1428 } else if (pring->ringno == psli->fcp_ring) { 1445 } else if (pring->ringno == psli->fcp_ring) {
1429 /* Skip match check if waiting to relogin to FCP target */ 1446 /* Skip match check if waiting to relogin to FCP target */
@@ -1680,112 +1697,38 @@ lpfc_matchdid(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp, uint32_t did)
1680struct lpfc_nodelist * 1697struct lpfc_nodelist *
1681lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did) 1698lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
1682{ 1699{
1683 struct lpfc_nodelist *ndlp, *next_ndlp; 1700 struct lpfc_nodelist *ndlp;
1701 struct list_head *lists[]={&phba->fc_nlpunmap_list,
1702 &phba->fc_nlpmap_list,
1703 &phba->fc_plogi_list,
1704 &phba->fc_adisc_list,
1705 &phba->fc_reglogin_list,
1706 &phba->fc_prli_list,
1707 &phba->fc_npr_list,
1708 &phba->fc_unused_list};
1709 uint32_t search[]={NLP_SEARCH_UNMAPPED,
1710 NLP_SEARCH_MAPPED,
1711 NLP_SEARCH_PLOGI,
1712 NLP_SEARCH_ADISC,
1713 NLP_SEARCH_REGLOGIN,
1714 NLP_SEARCH_PRLI,
1715 NLP_SEARCH_NPR,
1716 NLP_SEARCH_UNUSED};
1717 int i;
1684 uint32_t data1; 1718 uint32_t data1;
1685 1719
1686 spin_lock_irq(phba->host->host_lock); 1720 spin_lock_irq(phba->host->host_lock);
1687 if (order & NLP_SEARCH_UNMAPPED) { 1721 for (i = 0; i < ARRAY_SIZE(lists); i++ ) {
1688 list_for_each_entry_safe(ndlp, next_ndlp, 1722 if (!(order & search[i]))
1689 &phba->fc_nlpunmap_list, nlp_listp) { 1723 continue;
1690 if (lpfc_matchdid(phba, ndlp, did)) { 1724 list_for_each_entry(ndlp, lists[i], nlp_listp) {
1691 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1692 ((uint32_t) ndlp->nlp_xri << 16) |
1693 ((uint32_t) ndlp->nlp_type << 8) |
1694 ((uint32_t) ndlp->nlp_rpi & 0xff));
1695 /* FIND node DID unmapped */
1696 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1697 "%d:0929 FIND node DID unmapped"
1698 " Data: x%p x%x x%x x%x\n",
1699 phba->brd_no,
1700 ndlp, ndlp->nlp_DID,
1701 ndlp->nlp_flag, data1);
1702 spin_unlock_irq(phba->host->host_lock);
1703 return ndlp;
1704 }
1705 }
1706 }
1707
1708 if (order & NLP_SEARCH_MAPPED) {
1709 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_nlpmap_list,
1710 nlp_listp) {
1711 if (lpfc_matchdid(phba, ndlp, did)) {
1712
1713 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1714 ((uint32_t) ndlp->nlp_xri << 16) |
1715 ((uint32_t) ndlp->nlp_type << 8) |
1716 ((uint32_t) ndlp->nlp_rpi & 0xff));
1717 /* FIND node DID mapped */
1718 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1719 "%d:0930 FIND node DID mapped "
1720 "Data: x%p x%x x%x x%x\n",
1721 phba->brd_no,
1722 ndlp, ndlp->nlp_DID,
1723 ndlp->nlp_flag, data1);
1724 spin_unlock_irq(phba->host->host_lock);
1725 return ndlp;
1726 }
1727 }
1728 }
1729
1730 if (order & NLP_SEARCH_PLOGI) {
1731 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_plogi_list,
1732 nlp_listp) {
1733 if (lpfc_matchdid(phba, ndlp, did)) {
1734
1735 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1736 ((uint32_t) ndlp->nlp_xri << 16) |
1737 ((uint32_t) ndlp->nlp_type << 8) |
1738 ((uint32_t) ndlp->nlp_rpi & 0xff));
1739 /* LOG change to PLOGI */
1740 /* FIND node DID plogi */
1741 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1742 "%d:0908 FIND node DID plogi "
1743 "Data: x%p x%x x%x x%x\n",
1744 phba->brd_no,
1745 ndlp, ndlp->nlp_DID,
1746 ndlp->nlp_flag, data1);
1747 spin_unlock_irq(phba->host->host_lock);
1748 return ndlp;
1749 }
1750 }
1751 }
1752
1753 if (order & NLP_SEARCH_ADISC) {
1754 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1755 nlp_listp) {
1756 if (lpfc_matchdid(phba, ndlp, did)) {
1757
1758 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1759 ((uint32_t) ndlp->nlp_xri << 16) |
1760 ((uint32_t) ndlp->nlp_type << 8) |
1761 ((uint32_t) ndlp->nlp_rpi & 0xff));
1762 /* LOG change to ADISC */
1763 /* FIND node DID adisc */
1764 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1765 "%d:0931 FIND node DID adisc "
1766 "Data: x%p x%x x%x x%x\n",
1767 phba->brd_no,
1768 ndlp, ndlp->nlp_DID,
1769 ndlp->nlp_flag, data1);
1770 spin_unlock_irq(phba->host->host_lock);
1771 return ndlp;
1772 }
1773 }
1774 }
1775
1776 if (order & NLP_SEARCH_REGLOGIN) {
1777 list_for_each_entry_safe(ndlp, next_ndlp,
1778 &phba->fc_reglogin_list, nlp_listp) {
1779 if (lpfc_matchdid(phba, ndlp, did)) { 1725 if (lpfc_matchdid(phba, ndlp, did)) {
1780
1781 data1 = (((uint32_t) ndlp->nlp_state << 24) | 1726 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1782 ((uint32_t) ndlp->nlp_xri << 16) | 1727 ((uint32_t) ndlp->nlp_xri << 16) |
1783 ((uint32_t) ndlp->nlp_type << 8) | 1728 ((uint32_t) ndlp->nlp_type << 8) |
1784 ((uint32_t) ndlp->nlp_rpi & 0xff)); 1729 ((uint32_t) ndlp->nlp_rpi & 0xff));
1785 /* LOG change to REGLOGIN */
1786 /* FIND node DID reglogin */
1787 lpfc_printf_log(phba, KERN_INFO, LOG_NODE, 1730 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1788 "%d:0901 FIND node DID reglogin" 1731 "%d:0929 FIND node DID "
1789 " Data: x%p x%x x%x x%x\n", 1732 " Data: x%p x%x x%x x%x\n",
1790 phba->brd_no, 1733 phba->brd_no,
1791 ndlp, ndlp->nlp_DID, 1734 ndlp, ndlp->nlp_DID,
@@ -1795,86 +1738,12 @@ lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order, uint32_t did)
1795 } 1738 }
1796 } 1739 }
1797 } 1740 }
1798
1799 if (order & NLP_SEARCH_PRLI) {
1800 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_prli_list,
1801 nlp_listp) {
1802 if (lpfc_matchdid(phba, ndlp, did)) {
1803
1804 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1805 ((uint32_t) ndlp->nlp_xri << 16) |
1806 ((uint32_t) ndlp->nlp_type << 8) |
1807 ((uint32_t) ndlp->nlp_rpi & 0xff));
1808 /* LOG change to PRLI */
1809 /* FIND node DID prli */
1810 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1811 "%d:0902 FIND node DID prli "
1812 "Data: x%p x%x x%x x%x\n",
1813 phba->brd_no,
1814 ndlp, ndlp->nlp_DID,
1815 ndlp->nlp_flag, data1);
1816 spin_unlock_irq(phba->host->host_lock);
1817 return ndlp;
1818 }
1819 }
1820 }
1821
1822 if (order & NLP_SEARCH_NPR) {
1823 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_npr_list,
1824 nlp_listp) {
1825 if (lpfc_matchdid(phba, ndlp, did)) {
1826
1827 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1828 ((uint32_t) ndlp->nlp_xri << 16) |
1829 ((uint32_t) ndlp->nlp_type << 8) |
1830 ((uint32_t) ndlp->nlp_rpi & 0xff));
1831 /* LOG change to NPR */
1832 /* FIND node DID npr */
1833 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1834 "%d:0903 FIND node DID npr "
1835 "Data: x%p x%x x%x x%x\n",
1836 phba->brd_no,
1837 ndlp, ndlp->nlp_DID,
1838 ndlp->nlp_flag, data1);
1839 spin_unlock_irq(phba->host->host_lock);
1840 return ndlp;
1841 }
1842 }
1843 }
1844
1845 if (order & NLP_SEARCH_UNUSED) {
1846 list_for_each_entry_safe(ndlp, next_ndlp, &phba->fc_adisc_list,
1847 nlp_listp) {
1848 if (lpfc_matchdid(phba, ndlp, did)) {
1849
1850 data1 = (((uint32_t) ndlp->nlp_state << 24) |
1851 ((uint32_t) ndlp->nlp_xri << 16) |
1852 ((uint32_t) ndlp->nlp_type << 8) |
1853 ((uint32_t) ndlp->nlp_rpi & 0xff));
1854 /* LOG change to UNUSED */
1855 /* FIND node DID unused */
1856 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1857 "%d:0905 FIND node DID unused "
1858 "Data: x%p x%x x%x x%x\n",
1859 phba->brd_no,
1860 ndlp, ndlp->nlp_DID,
1861 ndlp->nlp_flag, data1);
1862 spin_unlock_irq(phba->host->host_lock);
1863 return ndlp;
1864 }
1865 }
1866 }
1867
1868 spin_unlock_irq(phba->host->host_lock); 1741 spin_unlock_irq(phba->host->host_lock);
1869 1742
1870 /* FIND node did <did> NOT FOUND */ 1743 /* FIND node did <did> NOT FOUND */
1871 lpfc_printf_log(phba, 1744 lpfc_printf_log(phba, KERN_INFO, LOG_NODE,
1872 KERN_INFO,
1873 LOG_NODE,
1874 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n", 1745 "%d:0932 FIND node did x%x NOT FOUND Data: x%x\n",
1875 phba->brd_no, did, order); 1746 phba->brd_no, did, order);
1876
1877 /* no match found */
1878 return NULL; 1747 return NULL;
1879} 1748}
1880 1749
@@ -2036,7 +1905,7 @@ lpfc_disc_start(struct lpfc_hba * phba)
2036 if (rc == MBX_NOT_FINISHED) { 1905 if (rc == MBX_NOT_FINISHED) {
2037 mempool_free( mbox, phba->mbox_mem_pool); 1906 mempool_free( mbox, phba->mbox_mem_pool);
2038 lpfc_disc_flush_list(phba); 1907 lpfc_disc_flush_list(phba);
2039 psli->ring[(psli->ip_ring)].flag &= 1908 psli->ring[(psli->extra_ring)].flag &=
2040 ~LPFC_STOP_IOCB_EVENT; 1909 ~LPFC_STOP_IOCB_EVENT;
2041 psli->ring[(psli->fcp_ring)].flag &= 1910 psli->ring[(psli->fcp_ring)].flag &=
2042 ~LPFC_STOP_IOCB_EVENT; 1911 ~LPFC_STOP_IOCB_EVENT;
@@ -2415,7 +2284,7 @@ lpfc_disc_timeout_handler(struct lpfc_hba *phba)
2415 2284
2416 if (clrlaerr) { 2285 if (clrlaerr) {
2417 lpfc_disc_flush_list(phba); 2286 lpfc_disc_flush_list(phba);
2418 psli->ring[(psli->ip_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2287 psli->ring[(psli->extra_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2419 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2288 psli->ring[(psli->fcp_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2420 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT; 2289 psli->ring[(psli->next_ring)].flag &= ~LPFC_STOP_IOCB_EVENT;
2421 phba->hba_state = LPFC_HBA_READY; 2290 phba->hba_state = LPFC_HBA_READY;
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index eedf98801366..f79cb6136906 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -42,14 +42,14 @@
42#define FCELSSIZE 1024 /* maximum ELS transfer size */ 42#define FCELSSIZE 1024 /* maximum ELS transfer size */
43 43
44#define LPFC_FCP_RING 0 /* ring 0 for FCP initiator commands */ 44#define LPFC_FCP_RING 0 /* ring 0 for FCP initiator commands */
45#define LPFC_IP_RING 1 /* ring 1 for IP commands */ 45#define LPFC_EXTRA_RING 1 /* ring 1 for other protocols */
46#define LPFC_ELS_RING 2 /* ring 2 for ELS commands */ 46#define LPFC_ELS_RING 2 /* ring 2 for ELS commands */
47#define LPFC_FCP_NEXT_RING 3 47#define LPFC_FCP_NEXT_RING 3
48 48
49#define SLI2_IOCB_CMD_R0_ENTRIES 172 /* SLI-2 FCP command ring entries */ 49#define SLI2_IOCB_CMD_R0_ENTRIES 172 /* SLI-2 FCP command ring entries */
50#define SLI2_IOCB_RSP_R0_ENTRIES 134 /* SLI-2 FCP response ring entries */ 50#define SLI2_IOCB_RSP_R0_ENTRIES 134 /* SLI-2 FCP response ring entries */
51#define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 IP command ring entries */ 51#define SLI2_IOCB_CMD_R1_ENTRIES 4 /* SLI-2 extra command ring entries */
52#define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 IP response ring entries */ 52#define SLI2_IOCB_RSP_R1_ENTRIES 4 /* SLI-2 extra response ring entries */
53#define SLI2_IOCB_CMD_R1XTRA_ENTRIES 36 /* SLI-2 extra FCP cmd ring entries */ 53#define SLI2_IOCB_CMD_R1XTRA_ENTRIES 36 /* SLI-2 extra FCP cmd ring entries */
54#define SLI2_IOCB_RSP_R1XTRA_ENTRIES 52 /* SLI-2 extra FCP rsp ring entries */ 54#define SLI2_IOCB_RSP_R1XTRA_ENTRIES 52 /* SLI-2 extra FCP rsp ring entries */
55#define SLI2_IOCB_CMD_R2_ENTRIES 20 /* SLI-2 ELS command ring entries */ 55#define SLI2_IOCB_CMD_R2_ENTRIES 20 /* SLI-2 ELS command ring entries */
@@ -121,6 +121,20 @@ struct lpfc_sli_ct_request {
121 121
122 uint32_t rsvd[7]; 122 uint32_t rsvd[7];
123 } rft; 123 } rft;
124 struct rff {
125 uint32_t PortId;
126 uint8_t reserved[2];
127#ifdef __BIG_ENDIAN_BITFIELD
128 uint8_t feature_res:6;
129 uint8_t feature_init:1;
130 uint8_t feature_tgt:1;
131#else /* __LITTLE_ENDIAN_BITFIELD */
132 uint8_t feature_tgt:1;
133 uint8_t feature_init:1;
134 uint8_t feature_res:6;
135#endif
136 uint8_t type_code; /* type=8 for FCP */
137 } rff;
124 struct rnn { 138 struct rnn {
125 uint32_t PortId; /* For RNN_ID requests */ 139 uint32_t PortId; /* For RNN_ID requests */
126 uint8_t wwnn[8]; 140 uint8_t wwnn[8];
@@ -136,6 +150,7 @@ struct lpfc_sli_ct_request {
136#define SLI_CT_REVISION 1 150#define SLI_CT_REVISION 1
137#define GID_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 260) 151#define GID_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 260)
138#define RFT_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 228) 152#define RFT_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 228)
153#define RFF_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 235)
139#define RNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 252) 154#define RNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request) - 252)
140#define RSNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request)) 155#define RSNN_REQUEST_SZ (sizeof(struct lpfc_sli_ct_request))
141 156
@@ -225,6 +240,7 @@ struct lpfc_sli_ct_request {
225#define SLI_CTNS_RNN_ID 0x0213 240#define SLI_CTNS_RNN_ID 0x0213
226#define SLI_CTNS_RCS_ID 0x0214 241#define SLI_CTNS_RCS_ID 0x0214
227#define SLI_CTNS_RFT_ID 0x0217 242#define SLI_CTNS_RFT_ID 0x0217
243#define SLI_CTNS_RFF_ID 0x021F
228#define SLI_CTNS_RSPN_ID 0x0218 244#define SLI_CTNS_RSPN_ID 0x0218
229#define SLI_CTNS_RPT_ID 0x021A 245#define SLI_CTNS_RPT_ID 0x021A
230#define SLI_CTNS_RIP_NN 0x0235 246#define SLI_CTNS_RIP_NN 0x0235
@@ -1089,12 +1105,6 @@ typedef struct {
1089#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11 1105#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11
1090#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12 1106#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12
1091 1107
1092#define PCI_SUBSYSTEM_ID_LP11000S 0xfc11
1093#define PCI_SUBSYSTEM_ID_LP11002S 0xfc12
1094#define PCI_SUBSYSTEM_ID_LPE11000S 0xfc21
1095#define PCI_SUBSYSTEM_ID_LPE11002S 0xfc22
1096#define PCI_SUBSYSTEM_ID_LPE11010S 0xfc2A
1097
1098#define JEDEC_ID_ADDRESS 0x0080001c 1108#define JEDEC_ID_ADDRESS 0x0080001c
1099#define FIREFLY_JEDEC_ID 0x1ACC 1109#define FIREFLY_JEDEC_ID 0x1ACC
1100#define SUPERFLY_JEDEC_ID 0x0020 1110#define SUPERFLY_JEDEC_ID 0x0020
@@ -1284,6 +1294,10 @@ typedef struct { /* FireFly BIU registers */
1284#define CMD_FCP_IREAD_CX 0x1B 1294#define CMD_FCP_IREAD_CX 0x1B
1285#define CMD_FCP_ICMND_CR 0x1C 1295#define CMD_FCP_ICMND_CR 0x1C
1286#define CMD_FCP_ICMND_CX 0x1D 1296#define CMD_FCP_ICMND_CX 0x1D
1297#define CMD_FCP_TSEND_CX 0x1F
1298#define CMD_FCP_TRECEIVE_CX 0x21
1299#define CMD_FCP_TRSP_CX 0x23
1300#define CMD_FCP_AUTO_TRSP_CX 0x29
1287 1301
1288#define CMD_ADAPTER_MSG 0x20 1302#define CMD_ADAPTER_MSG 0x20
1289#define CMD_ADAPTER_DUMP 0x22 1303#define CMD_ADAPTER_DUMP 0x22
@@ -1310,6 +1324,9 @@ typedef struct { /* FireFly BIU registers */
1310#define CMD_FCP_IREAD64_CX 0x9B 1324#define CMD_FCP_IREAD64_CX 0x9B
1311#define CMD_FCP_ICMND64_CR 0x9C 1325#define CMD_FCP_ICMND64_CR 0x9C
1312#define CMD_FCP_ICMND64_CX 0x9D 1326#define CMD_FCP_ICMND64_CX 0x9D
1327#define CMD_FCP_TSEND64_CX 0x9F
1328#define CMD_FCP_TRECEIVE64_CX 0xA1
1329#define CMD_FCP_TRSP64_CX 0xA3
1313 1330
1314#define CMD_GEN_REQUEST64_CR 0xC2 1331#define CMD_GEN_REQUEST64_CR 0xC2
1315#define CMD_GEN_REQUEST64_CX 0xC3 1332#define CMD_GEN_REQUEST64_CX 0xC3
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index a5723ad0a099..afca45cdbcef 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -268,6 +268,8 @@ lpfc_config_port_post(struct lpfc_hba * phba)
268 kfree(mp); 268 kfree(mp);
269 pmb->context1 = NULL; 269 pmb->context1 = NULL;
270 270
271 if (phba->cfg_soft_wwnn)
272 u64_to_wwn(phba->cfg_soft_wwnn, phba->fc_sparam.nodeName.u.wwn);
271 if (phba->cfg_soft_wwpn) 273 if (phba->cfg_soft_wwpn)
272 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn); 274 u64_to_wwn(phba->cfg_soft_wwpn, phba->fc_sparam.portName.u.wwn);
273 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName, 275 memcpy(&phba->fc_nodename, &phba->fc_sparam.nodeName,
@@ -349,8 +351,8 @@ lpfc_config_port_post(struct lpfc_hba * phba)
349 phba->hba_state = LPFC_LINK_DOWN; 351 phba->hba_state = LPFC_LINK_DOWN;
350 352
351 /* Only process IOCBs on ring 0 till hba_state is READY */ 353 /* Only process IOCBs on ring 0 till hba_state is READY */
352 if (psli->ring[psli->ip_ring].cmdringaddr) 354 if (psli->ring[psli->extra_ring].cmdringaddr)
353 psli->ring[psli->ip_ring].flag |= LPFC_STOP_IOCB_EVENT; 355 psli->ring[psli->extra_ring].flag |= LPFC_STOP_IOCB_EVENT;
354 if (psli->ring[psli->fcp_ring].cmdringaddr) 356 if (psli->ring[psli->fcp_ring].cmdringaddr)
355 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT; 357 psli->ring[psli->fcp_ring].flag |= LPFC_STOP_IOCB_EVENT;
356 if (psli->ring[psli->next_ring].cmdringaddr) 358 if (psli->ring[psli->next_ring].cmdringaddr)
@@ -517,7 +519,8 @@ lpfc_handle_eratt(struct lpfc_hba * phba)
517 struct lpfc_sli_ring *pring; 519 struct lpfc_sli_ring *pring;
518 uint32_t event_data; 520 uint32_t event_data;
519 521
520 if (phba->work_hs & HS_FFER6) { 522 if (phba->work_hs & HS_FFER6 ||
523 phba->work_hs & HS_FFER5) {
521 /* Re-establishing Link */ 524 /* Re-establishing Link */
522 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT, 525 lpfc_printf_log(phba, KERN_INFO, LOG_LINK_EVENT,
523 "%d:1301 Re-establishing Link " 526 "%d:1301 Re-establishing Link "
@@ -611,7 +614,7 @@ lpfc_handle_latt(struct lpfc_hba * phba)
611 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la; 614 pmb->mbox_cmpl = lpfc_mbx_cmpl_read_la;
612 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB)); 615 rc = lpfc_sli_issue_mbox (phba, pmb, (MBX_NOWAIT | MBX_STOP_IOCB));
613 if (rc == MBX_NOT_FINISHED) 616 if (rc == MBX_NOT_FINISHED)
614 goto lpfc_handle_latt_free_mp; 617 goto lpfc_handle_latt_free_mbuf;
615 618
616 /* Clear Link Attention in HA REG */ 619 /* Clear Link Attention in HA REG */
617 spin_lock_irq(phba->host->host_lock); 620 spin_lock_irq(phba->host->host_lock);
@@ -621,6 +624,8 @@ lpfc_handle_latt(struct lpfc_hba * phba)
621 624
622 return; 625 return;
623 626
627lpfc_handle_latt_free_mbuf:
628 lpfc_mbuf_free(phba, mp->virt, mp->phys);
624lpfc_handle_latt_free_mp: 629lpfc_handle_latt_free_mp:
625 kfree(mp); 630 kfree(mp);
626lpfc_handle_latt_free_pmb: 631lpfc_handle_latt_free_pmb:
@@ -802,19 +807,13 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
802{ 807{
803 lpfc_vpd_t *vp; 808 lpfc_vpd_t *vp;
804 uint16_t dev_id = phba->pcidev->device; 809 uint16_t dev_id = phba->pcidev->device;
805 uint16_t dev_subid = phba->pcidev->subsystem_device;
806 uint8_t hdrtype;
807 int max_speed; 810 int max_speed;
808 char * ports;
809 struct { 811 struct {
810 char * name; 812 char * name;
811 int max_speed; 813 int max_speed;
812 char * ports;
813 char * bus; 814 char * bus;
814 } m = {"<Unknown>", 0, "", ""}; 815 } m = {"<Unknown>", 0, ""};
815 816
816 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
817 ports = (hdrtype == 0x80) ? "2-port " : "";
818 if (mdp && mdp[0] != '\0' 817 if (mdp && mdp[0] != '\0'
819 && descp && descp[0] != '\0') 818 && descp && descp[0] != '\0')
820 return; 819 return;
@@ -834,130 +833,93 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
834 833
835 switch (dev_id) { 834 switch (dev_id) {
836 case PCI_DEVICE_ID_FIREFLY: 835 case PCI_DEVICE_ID_FIREFLY:
837 m = (typeof(m)){"LP6000", max_speed, "", "PCI"}; 836 m = (typeof(m)){"LP6000", max_speed, "PCI"};
838 break; 837 break;
839 case PCI_DEVICE_ID_SUPERFLY: 838 case PCI_DEVICE_ID_SUPERFLY:
840 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) 839 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
841 m = (typeof(m)){"LP7000", max_speed, "", "PCI"}; 840 m = (typeof(m)){"LP7000", max_speed, "PCI"};
842 else 841 else
843 m = (typeof(m)){"LP7000E", max_speed, "", "PCI"}; 842 m = (typeof(m)){"LP7000E", max_speed, "PCI"};
844 break; 843 break;
845 case PCI_DEVICE_ID_DRAGONFLY: 844 case PCI_DEVICE_ID_DRAGONFLY:
846 m = (typeof(m)){"LP8000", max_speed, "", "PCI"}; 845 m = (typeof(m)){"LP8000", max_speed, "PCI"};
847 break; 846 break;
848 case PCI_DEVICE_ID_CENTAUR: 847 case PCI_DEVICE_ID_CENTAUR:
849 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) 848 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
850 m = (typeof(m)){"LP9002", max_speed, "", "PCI"}; 849 m = (typeof(m)){"LP9002", max_speed, "PCI"};
851 else 850 else
852 m = (typeof(m)){"LP9000", max_speed, "", "PCI"}; 851 m = (typeof(m)){"LP9000", max_speed, "PCI"};
853 break; 852 break;
854 case PCI_DEVICE_ID_RFLY: 853 case PCI_DEVICE_ID_RFLY:
855 m = (typeof(m)){"LP952", max_speed, "", "PCI"}; 854 m = (typeof(m)){"LP952", max_speed, "PCI"};
856 break; 855 break;
857 case PCI_DEVICE_ID_PEGASUS: 856 case PCI_DEVICE_ID_PEGASUS:
858 m = (typeof(m)){"LP9802", max_speed, "", "PCI-X"}; 857 m = (typeof(m)){"LP9802", max_speed, "PCI-X"};
859 break; 858 break;
860 case PCI_DEVICE_ID_THOR: 859 case PCI_DEVICE_ID_THOR:
861 if (hdrtype == 0x80) 860 m = (typeof(m)){"LP10000", max_speed, "PCI-X"};
862 m = (typeof(m)){"LP10000DC",
863 max_speed, ports, "PCI-X"};
864 else
865 m = (typeof(m)){"LP10000",
866 max_speed, ports, "PCI-X"};
867 break; 861 break;
868 case PCI_DEVICE_ID_VIPER: 862 case PCI_DEVICE_ID_VIPER:
869 m = (typeof(m)){"LPX1000", max_speed, "", "PCI-X"}; 863 m = (typeof(m)){"LPX1000", max_speed, "PCI-X"};
870 break; 864 break;
871 case PCI_DEVICE_ID_PFLY: 865 case PCI_DEVICE_ID_PFLY:
872 m = (typeof(m)){"LP982", max_speed, "", "PCI-X"}; 866 m = (typeof(m)){"LP982", max_speed, "PCI-X"};
873 break; 867 break;
874 case PCI_DEVICE_ID_TFLY: 868 case PCI_DEVICE_ID_TFLY:
875 if (hdrtype == 0x80) 869 m = (typeof(m)){"LP1050", max_speed, "PCI-X"};
876 m = (typeof(m)){"LP1050DC", max_speed, ports, "PCI-X"};
877 else
878 m = (typeof(m)){"LP1050", max_speed, ports, "PCI-X"};
879 break; 870 break;
880 case PCI_DEVICE_ID_HELIOS: 871 case PCI_DEVICE_ID_HELIOS:
881 if (hdrtype == 0x80) 872 m = (typeof(m)){"LP11000", max_speed, "PCI-X2"};
882 m = (typeof(m)){"LP11002", max_speed, ports, "PCI-X2"};
883 else
884 m = (typeof(m)){"LP11000", max_speed, ports, "PCI-X2"};
885 break; 873 break;
886 case PCI_DEVICE_ID_HELIOS_SCSP: 874 case PCI_DEVICE_ID_HELIOS_SCSP:
887 m = (typeof(m)){"LP11000-SP", max_speed, ports, "PCI-X2"}; 875 m = (typeof(m)){"LP11000-SP", max_speed, "PCI-X2"};
888 break; 876 break;
889 case PCI_DEVICE_ID_HELIOS_DCSP: 877 case PCI_DEVICE_ID_HELIOS_DCSP:
890 m = (typeof(m)){"LP11002-SP", max_speed, ports, "PCI-X2"}; 878 m = (typeof(m)){"LP11002-SP", max_speed, "PCI-X2"};
891 break; 879 break;
892 case PCI_DEVICE_ID_NEPTUNE: 880 case PCI_DEVICE_ID_NEPTUNE:
893 if (hdrtype == 0x80) 881 m = (typeof(m)){"LPe1000", max_speed, "PCIe"};
894 m = (typeof(m)){"LPe1002", max_speed, ports, "PCIe"};
895 else
896 m = (typeof(m)){"LPe1000", max_speed, ports, "PCIe"};
897 break; 882 break;
898 case PCI_DEVICE_ID_NEPTUNE_SCSP: 883 case PCI_DEVICE_ID_NEPTUNE_SCSP:
899 m = (typeof(m)){"LPe1000-SP", max_speed, ports, "PCIe"}; 884 m = (typeof(m)){"LPe1000-SP", max_speed, "PCIe"};
900 break; 885 break;
901 case PCI_DEVICE_ID_NEPTUNE_DCSP: 886 case PCI_DEVICE_ID_NEPTUNE_DCSP:
902 m = (typeof(m)){"LPe1002-SP", max_speed, ports, "PCIe"}; 887 m = (typeof(m)){"LPe1002-SP", max_speed, "PCIe"};
903 break; 888 break;
904 case PCI_DEVICE_ID_BMID: 889 case PCI_DEVICE_ID_BMID:
905 m = (typeof(m)){"LP1150", max_speed, ports, "PCI-X2"}; 890 m = (typeof(m)){"LP1150", max_speed, "PCI-X2"};
906 break; 891 break;
907 case PCI_DEVICE_ID_BSMB: 892 case PCI_DEVICE_ID_BSMB:
908 m = (typeof(m)){"LP111", max_speed, ports, "PCI-X2"}; 893 m = (typeof(m)){"LP111", max_speed, "PCI-X2"};
909 break; 894 break;
910 case PCI_DEVICE_ID_ZEPHYR: 895 case PCI_DEVICE_ID_ZEPHYR:
911 if (hdrtype == 0x80) 896 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
912 m = (typeof(m)){"LPe11002", max_speed, ports, "PCIe"};
913 else
914 m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"};
915 break; 897 break;
916 case PCI_DEVICE_ID_ZEPHYR_SCSP: 898 case PCI_DEVICE_ID_ZEPHYR_SCSP:
917 m = (typeof(m)){"LPe11000", max_speed, ports, "PCIe"}; 899 m = (typeof(m)){"LPe11000", max_speed, "PCIe"};
918 break; 900 break;
919 case PCI_DEVICE_ID_ZEPHYR_DCSP: 901 case PCI_DEVICE_ID_ZEPHYR_DCSP:
920 m = (typeof(m)){"LPe11002-SP", max_speed, ports, "PCIe"}; 902 m = (typeof(m)){"LPe11002-SP", max_speed, "PCIe"};
921 break; 903 break;
922 case PCI_DEVICE_ID_ZMID: 904 case PCI_DEVICE_ID_ZMID:
923 m = (typeof(m)){"LPe1150", max_speed, ports, "PCIe"}; 905 m = (typeof(m)){"LPe1150", max_speed, "PCIe"};
924 break; 906 break;
925 case PCI_DEVICE_ID_ZSMB: 907 case PCI_DEVICE_ID_ZSMB:
926 m = (typeof(m)){"LPe111", max_speed, ports, "PCIe"}; 908 m = (typeof(m)){"LPe111", max_speed, "PCIe"};
927 break; 909 break;
928 case PCI_DEVICE_ID_LP101: 910 case PCI_DEVICE_ID_LP101:
929 m = (typeof(m)){"LP101", max_speed, ports, "PCI-X"}; 911 m = (typeof(m)){"LP101", max_speed, "PCI-X"};
930 break; 912 break;
931 case PCI_DEVICE_ID_LP10000S: 913 case PCI_DEVICE_ID_LP10000S:
932 m = (typeof(m)){"LP10000-S", max_speed, ports, "PCI"}; 914 m = (typeof(m)){"LP10000-S", max_speed, "PCI"};
933 break; 915 break;
934 case PCI_DEVICE_ID_LP11000S: 916 case PCI_DEVICE_ID_LP11000S:
917 m = (typeof(m)){"LP11000-S", max_speed,
918 "PCI-X2"};
919 break;
935 case PCI_DEVICE_ID_LPE11000S: 920 case PCI_DEVICE_ID_LPE11000S:
936 switch (dev_subid) { 921 m = (typeof(m)){"LPe11000-S", max_speed,
937 case PCI_SUBSYSTEM_ID_LP11000S: 922 "PCIe"};
938 m = (typeof(m)){"LP11000-S", max_speed,
939 ports, "PCI-X2"};
940 break;
941 case PCI_SUBSYSTEM_ID_LP11002S:
942 m = (typeof(m)){"LP11002-S", max_speed,
943 ports, "PCI-X2"};
944 break;
945 case PCI_SUBSYSTEM_ID_LPE11000S:
946 m = (typeof(m)){"LPe11000-S", max_speed,
947 ports, "PCIe"};
948 break;
949 case PCI_SUBSYSTEM_ID_LPE11002S:
950 m = (typeof(m)){"LPe11002-S", max_speed,
951 ports, "PCIe"};
952 break;
953 case PCI_SUBSYSTEM_ID_LPE11010S:
954 m = (typeof(m)){"LPe11010-S", max_speed,
955 "10-port ", "PCIe"};
956 break;
957 default:
958 m = (typeof(m)){ NULL };
959 break;
960 }
961 break; 923 break;
962 default: 924 default:
963 m = (typeof(m)){ NULL }; 925 m = (typeof(m)){ NULL };
@@ -968,8 +930,8 @@ lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
968 snprintf(mdp, 79,"%s", m.name); 930 snprintf(mdp, 79,"%s", m.name);
969 if (descp && descp[0] == '\0') 931 if (descp && descp[0] == '\0')
970 snprintf(descp, 255, 932 snprintf(descp, 255,
971 "Emulex %s %dGb %s%s Fibre Channel Adapter", 933 "Emulex %s %dGb %s Fibre Channel Adapter",
972 m.name, m.max_speed, m.ports, m.bus); 934 m.name, m.max_speed, m.bus);
973} 935}
974 936
975/**************************************************/ 937/**************************************************/
@@ -1651,6 +1613,14 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1651 if (error) 1613 if (error)
1652 goto out_remove_host; 1614 goto out_remove_host;
1653 1615
1616 if (phba->cfg_use_msi) {
1617 error = pci_enable_msi(phba->pcidev);
1618 if (error)
1619 lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "%d:0452 "
1620 "Enable MSI failed, continuing with "
1621 "IRQ\n", phba->brd_no);
1622 }
1623
1654 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED, 1624 error = request_irq(phba->pcidev->irq, lpfc_intr_handler, IRQF_SHARED,
1655 LPFC_DRIVER_NAME, phba); 1625 LPFC_DRIVER_NAME, phba);
1656 if (error) { 1626 if (error) {
@@ -1730,6 +1700,7 @@ out_free_irq:
1730 lpfc_stop_timer(phba); 1700 lpfc_stop_timer(phba);
1731 phba->work_hba_events = 0; 1701 phba->work_hba_events = 0;
1732 free_irq(phba->pcidev->irq, phba); 1702 free_irq(phba->pcidev->irq, phba);
1703 pci_disable_msi(phba->pcidev);
1733out_free_sysfs_attr: 1704out_free_sysfs_attr:
1734 lpfc_free_sysfs_attr(phba); 1705 lpfc_free_sysfs_attr(phba);
1735out_remove_host: 1706out_remove_host:
@@ -1796,6 +1767,7 @@ lpfc_pci_remove_one(struct pci_dev *pdev)
1796 1767
1797 /* Release the irq reservation */ 1768 /* Release the irq reservation */
1798 free_irq(phba->pcidev->irq, phba); 1769 free_irq(phba->pcidev->irq, phba);
1770 pci_disable_msi(phba->pcidev);
1799 1771
1800 lpfc_cleanup(phba, 0); 1772 lpfc_cleanup(phba, 0);
1801 lpfc_stop_timer(phba); 1773 lpfc_stop_timer(phba);
diff --git a/drivers/scsi/lpfc/lpfc_logmsg.h b/drivers/scsi/lpfc/lpfc_logmsg.h
index 62c8ca862e9e..438cbcd9eb13 100644
--- a/drivers/scsi/lpfc/lpfc_logmsg.h
+++ b/drivers/scsi/lpfc/lpfc_logmsg.h
@@ -28,7 +28,7 @@
28#define LOG_NODE 0x80 /* Node table events */ 28#define LOG_NODE 0x80 /* Node table events */
29#define LOG_MISC 0x400 /* Miscellaneous events */ 29#define LOG_MISC 0x400 /* Miscellaneous events */
30#define LOG_SLI 0x800 /* SLI events */ 30#define LOG_SLI 0x800 /* SLI events */
31#define LOG_CHK_COND 0x1000 /* FCP Check condition flag */ 31#define LOG_FCP_ERROR 0x1000 /* log errors, not underruns */
32#define LOG_LIBDFC 0x2000 /* Libdfc events */ 32#define LOG_LIBDFC 0x2000 /* Libdfc events */
33#define LOG_ALL_MSG 0xffff /* LOG all messages */ 33#define LOG_ALL_MSG 0xffff /* LOG all messages */
34 34
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index d5f415007db2..0c7e731dc45a 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -739,7 +739,7 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
739 uint32_t evt) 739 uint32_t evt)
740{ 740{
741 struct lpfc_iocbq *cmdiocb, *rspiocb; 741 struct lpfc_iocbq *cmdiocb, *rspiocb;
742 struct lpfc_dmabuf *pcmd, *prsp; 742 struct lpfc_dmabuf *pcmd, *prsp, *mp;
743 uint32_t *lp; 743 uint32_t *lp;
744 IOCB_t *irsp; 744 IOCB_t *irsp;
745 struct serv_parm *sp; 745 struct serv_parm *sp;
@@ -829,6 +829,9 @@ lpfc_cmpl_plogi_plogi_issue(struct lpfc_hba * phba,
829 NLP_REGLOGIN_LIST); 829 NLP_REGLOGIN_LIST);
830 return ndlp->nlp_state; 830 return ndlp->nlp_state;
831 } 831 }
832 mp = (struct lpfc_dmabuf *)mbox->context1;
833 lpfc_mbuf_free(phba, mp->virt, mp->phys);
834 kfree(mp);
832 mempool_free(mbox, phba->mbox_mem_pool); 835 mempool_free(mbox, phba->mbox_mem_pool);
833 } else { 836 } else {
834 mempool_free(mbox, phba->mbox_mem_pool); 837 mempool_free(mbox, phba->mbox_mem_pool);
@@ -1620,8 +1623,8 @@ lpfc_rcv_padisc_npr_node(struct lpfc_hba * phba,
1620 * or discovery in progress for this node. Starting discovery 1623 * or discovery in progress for this node. Starting discovery
1621 * here will affect the counting of discovery threads. 1624 * here will affect the counting of discovery threads.
1622 */ 1625 */
1623 if ((!(ndlp->nlp_flag & NLP_DELAY_TMO)) && 1626 if (!(ndlp->nlp_flag & NLP_DELAY_TMO) &&
1624 (ndlp->nlp_flag & NLP_NPR_2B_DISC)){ 1627 !(ndlp->nlp_flag & NLP_NPR_2B_DISC)){
1625 if (ndlp->nlp_flag & NLP_NPR_ADISC) { 1628 if (ndlp->nlp_flag & NLP_NPR_ADISC) {
1626 ndlp->nlp_prev_state = NLP_STE_NPR_NODE; 1629 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;
1627 ndlp->nlp_state = NLP_STE_ADISC_ISSUE; 1630 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 97ae98dc95d0..c3e68e0d8f74 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -297,8 +297,10 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm; 297 uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm;
298 uint32_t resp_info = fcprsp->rspStatus2; 298 uint32_t resp_info = fcprsp->rspStatus2;
299 uint32_t scsi_status = fcprsp->rspStatus3; 299 uint32_t scsi_status = fcprsp->rspStatus3;
300 uint32_t *lp;
300 uint32_t host_status = DID_OK; 301 uint32_t host_status = DID_OK;
301 uint32_t rsplen = 0; 302 uint32_t rsplen = 0;
303 uint32_t logit = LOG_FCP | LOG_FCP_ERROR;
302 304
303 /* 305 /*
304 * If this is a task management command, there is no 306 * If this is a task management command, there is no
@@ -310,10 +312,25 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
310 goto out; 312 goto out;
311 } 313 }
312 314
313 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 315 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
314 "%d:0730 FCP command failed: RSP " 316 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
315 "Data: x%x x%x x%x x%x x%x x%x\n", 317 if (snslen > SCSI_SENSE_BUFFERSIZE)
316 phba->brd_no, resp_info, scsi_status, 318 snslen = SCSI_SENSE_BUFFERSIZE;
319
320 if (resp_info & RSP_LEN_VALID)
321 rsplen = be32_to_cpu(fcprsp->rspRspLen);
322 memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
323 }
324 lp = (uint32_t *)cmnd->sense_buffer;
325
326 if (!scsi_status && (resp_info & RESID_UNDER))
327 logit = LOG_FCP;
328
329 lpfc_printf_log(phba, KERN_WARNING, logit,
330 "%d:0730 FCP command x%x failed: x%x SNS x%x x%x "
331 "Data: x%x x%x x%x x%x x%x\n",
332 phba->brd_no, cmnd->cmnd[0], scsi_status,
333 be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
317 be32_to_cpu(fcprsp->rspResId), 334 be32_to_cpu(fcprsp->rspResId),
318 be32_to_cpu(fcprsp->rspSnsLen), 335 be32_to_cpu(fcprsp->rspSnsLen),
319 be32_to_cpu(fcprsp->rspRspLen), 336 be32_to_cpu(fcprsp->rspRspLen),
@@ -328,14 +345,6 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
328 } 345 }
329 } 346 }
330 347
331 if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
332 uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
333 if (snslen > SCSI_SENSE_BUFFERSIZE)
334 snslen = SCSI_SENSE_BUFFERSIZE;
335
336 memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
337 }
338
339 cmnd->resid = 0; 348 cmnd->resid = 0;
340 if (resp_info & RESID_UNDER) { 349 if (resp_info & RESID_UNDER) {
341 cmnd->resid = be32_to_cpu(fcprsp->rspResId); 350 cmnd->resid = be32_to_cpu(fcprsp->rspResId);
@@ -378,7 +387,7 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
378 */ 387 */
379 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm && 388 } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
380 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) { 389 (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
381 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 390 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
382 "%d:0734 FCP Read Check Error Data: " 391 "%d:0734 FCP Read Check Error Data: "
383 "x%x x%x x%x x%x\n", phba->brd_no, 392 "x%x x%x x%x x%x\n", phba->brd_no,
384 be32_to_cpu(fcpcmd->fcpDl), 393 be32_to_cpu(fcpcmd->fcpDl),
@@ -670,6 +679,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
670 struct lpfc_iocbq *iocbqrsp; 679 struct lpfc_iocbq *iocbqrsp;
671 int ret; 680 int ret;
672 681
682 if (!rdata->pnode)
683 return FAILED;
684
673 lpfc_cmd->rdata = rdata; 685 lpfc_cmd->rdata = rdata;
674 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun, 686 ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun,
675 FCP_TARGET_RESET); 687 FCP_TARGET_RESET);
@@ -976,20 +988,34 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
976 988
977 lpfc_block_error_handler(cmnd); 989 lpfc_block_error_handler(cmnd);
978 spin_lock_irq(shost->host_lock); 990 spin_lock_irq(shost->host_lock);
991 loopcnt = 0;
979 /* 992 /*
980 * If target is not in a MAPPED state, delay the reset until 993 * If target is not in a MAPPED state, delay the reset until
981 * target is rediscovered or devloss timeout expires. 994 * target is rediscovered or devloss timeout expires.
982 */ 995 */
983 while ( 1 ) { 996 while ( 1 ) {
984 if (!pnode) 997 if (!pnode)
985 break; 998 return FAILED;
986 999
987 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) { 1000 if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
988 spin_unlock_irq(phba->host->host_lock); 1001 spin_unlock_irq(phba->host->host_lock);
989 schedule_timeout_uninterruptible(msecs_to_jiffies(500)); 1002 schedule_timeout_uninterruptible(msecs_to_jiffies(500));
990 spin_lock_irq(phba->host->host_lock); 1003 spin_lock_irq(phba->host->host_lock);
1004 loopcnt++;
1005 rdata = cmnd->device->hostdata;
1006 if (!rdata ||
1007 (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) {
1008 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1009 "%d:0721 LUN Reset rport failure:"
1010 " cnt x%x rdata x%p\n",
1011 phba->brd_no, loopcnt, rdata);
1012 goto out;
1013 }
1014 pnode = rdata->pnode;
1015 if (!pnode)
1016 return FAILED;
991 } 1017 }
992 if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE)) 1018 if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
993 break; 1019 break;
994 } 1020 }
995 1021
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 582f5ea4e84e..a4128e19338a 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -117,6 +117,10 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
117 case CMD_FCP_IREAD_CX: 117 case CMD_FCP_IREAD_CX:
118 case CMD_FCP_ICMND_CR: 118 case CMD_FCP_ICMND_CR:
119 case CMD_FCP_ICMND_CX: 119 case CMD_FCP_ICMND_CX:
120 case CMD_FCP_TSEND_CX:
121 case CMD_FCP_TRSP_CX:
122 case CMD_FCP_TRECEIVE_CX:
123 case CMD_FCP_AUTO_TRSP_CX:
120 case CMD_ADAPTER_MSG: 124 case CMD_ADAPTER_MSG:
121 case CMD_ADAPTER_DUMP: 125 case CMD_ADAPTER_DUMP:
122 case CMD_XMIT_SEQUENCE64_CR: 126 case CMD_XMIT_SEQUENCE64_CR:
@@ -131,6 +135,9 @@ lpfc_sli_iocb_cmd_type(uint8_t iocb_cmnd)
131 case CMD_FCP_IREAD64_CX: 135 case CMD_FCP_IREAD64_CX:
132 case CMD_FCP_ICMND64_CR: 136 case CMD_FCP_ICMND64_CR:
133 case CMD_FCP_ICMND64_CX: 137 case CMD_FCP_ICMND64_CX:
138 case CMD_FCP_TSEND64_CX:
139 case CMD_FCP_TRSP64_CX:
140 case CMD_FCP_TRECEIVE64_CX:
134 case CMD_GEN_REQUEST64_CR: 141 case CMD_GEN_REQUEST64_CR:
135 case CMD_GEN_REQUEST64_CX: 142 case CMD_GEN_REQUEST64_CX:
136 case CMD_XMIT_ELS_RSP64_CX: 143 case CMD_XMIT_ELS_RSP64_CX:
@@ -1098,6 +1105,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1098 lpfc_sli_pcimem_bcopy((uint32_t *) entry, 1105 lpfc_sli_pcimem_bcopy((uint32_t *) entry,
1099 (uint32_t *) &rspiocbq.iocb, 1106 (uint32_t *) &rspiocbq.iocb,
1100 sizeof (IOCB_t)); 1107 sizeof (IOCB_t));
1108 INIT_LIST_HEAD(&(rspiocbq.list));
1101 irsp = &rspiocbq.iocb; 1109 irsp = &rspiocbq.iocb;
1102 1110
1103 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); 1111 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK);
@@ -1149,6 +1157,11 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1149 } 1157 }
1150 } 1158 }
1151 break; 1159 break;
1160 case LPFC_UNSOL_IOCB:
1161 spin_unlock_irqrestore(phba->host->host_lock, iflag);
1162 lpfc_sli_process_unsol_iocb(phba, pring, &rspiocbq);
1163 spin_lock_irqsave(phba->host->host_lock, iflag);
1164 break;
1152 default: 1165 default:
1153 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { 1166 if (irsp->ulpCommand == CMD_ADAPTER_MSG) {
1154 char adaptermsg[LPFC_MAX_ADPTMSG]; 1167 char adaptermsg[LPFC_MAX_ADPTMSG];
@@ -2472,13 +2485,17 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba)
2472 psli = &phba->sli; 2485 psli = &phba->sli;
2473 2486
2474 /* Adjust cmd/rsp ring iocb entries more evenly */ 2487 /* Adjust cmd/rsp ring iocb entries more evenly */
2488
2489 /* Take some away from the FCP ring */
2475 pring = &psli->ring[psli->fcp_ring]; 2490 pring = &psli->ring[psli->fcp_ring];
2476 pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2491 pring->numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES;
2477 pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2492 pring->numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES;
2478 pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; 2493 pring->numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES;
2479 pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; 2494 pring->numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES;
2480 2495
2481 pring = &psli->ring[1]; 2496 /* and give them to the extra ring */
2497 pring = &psli->ring[psli->extra_ring];
2498
2482 pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; 2499 pring->numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES;
2483 pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; 2500 pring->numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES;
2484 pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; 2501 pring->numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES;
@@ -2488,8 +2505,8 @@ lpfc_extra_ring_setup( struct lpfc_hba *phba)
2488 pring->iotag_max = 4096; 2505 pring->iotag_max = 4096;
2489 pring->num_mask = 1; 2506 pring->num_mask = 1;
2490 pring->prt[0].profile = 0; /* Mask 0 */ 2507 pring->prt[0].profile = 0; /* Mask 0 */
2491 pring->prt[0].rctl = FC_UNSOL_DATA; 2508 pring->prt[0].rctl = phba->cfg_multi_ring_rctl;
2492 pring->prt[0].type = 5; 2509 pring->prt[0].type = phba->cfg_multi_ring_type;
2493 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; 2510 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL;
2494 return 0; 2511 return 0;
2495} 2512}
@@ -2505,7 +2522,7 @@ lpfc_sli_setup(struct lpfc_hba *phba)
2505 psli->sli_flag = 0; 2522 psli->sli_flag = 0;
2506 psli->fcp_ring = LPFC_FCP_RING; 2523 psli->fcp_ring = LPFC_FCP_RING;
2507 psli->next_ring = LPFC_FCP_NEXT_RING; 2524 psli->next_ring = LPFC_FCP_NEXT_RING;
2508 psli->ip_ring = LPFC_IP_RING; 2525 psli->extra_ring = LPFC_EXTRA_RING;
2509 2526
2510 psli->iocbq_lookup = NULL; 2527 psli->iocbq_lookup = NULL;
2511 psli->iocbq_lookup_len = 0; 2528 psli->iocbq_lookup_len = 0;
@@ -2528,7 +2545,7 @@ lpfc_sli_setup(struct lpfc_hba *phba)
2528 pring->fast_iotag = pring->iotag_max; 2545 pring->fast_iotag = pring->iotag_max;
2529 pring->num_mask = 0; 2546 pring->num_mask = 0;
2530 break; 2547 break;
2531 case LPFC_IP_RING: /* ring 1 - IP */ 2548 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */
2532 /* numCiocb and numRiocb are used in config_port */ 2549 /* numCiocb and numRiocb are used in config_port */
2533 pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; 2550 pring->numCiocb = SLI2_IOCB_CMD_R1_ENTRIES;
2534 pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; 2551 pring->numRiocb = SLI2_IOCB_RSP_R1_ENTRIES;
@@ -3238,6 +3255,21 @@ lpfc_intr_handler(int irq, void *dev_id)
3238 lpfc_sli_handle_fast_ring_event(phba, 3255 lpfc_sli_handle_fast_ring_event(phba,
3239 &phba->sli.ring[LPFC_FCP_RING], 3256 &phba->sli.ring[LPFC_FCP_RING],
3240 status); 3257 status);
3258
3259 if (phba->cfg_multi_ring_support == 2) {
3260 /*
3261 * Process all events on extra ring. Take the optimized path
3262 * for extra ring IO. Any other IO is slow path and is handled
3263 * by the worker thread.
3264 */
3265 status = (ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING)));
3266 status >>= (4*LPFC_EXTRA_RING);
3267 if (status & HA_RXATT) {
3268 lpfc_sli_handle_fast_ring_event(phba,
3269 &phba->sli.ring[LPFC_EXTRA_RING],
3270 status);
3271 }
3272 }
3241 return IRQ_HANDLED; 3273 return IRQ_HANDLED;
3242 3274
3243} /* lpfc_intr_handler */ 3275} /* lpfc_intr_handler */
diff --git a/drivers/scsi/lpfc/lpfc_sli.h b/drivers/scsi/lpfc/lpfc_sli.h
index e26de6809358..a43549959dc7 100644
--- a/drivers/scsi/lpfc/lpfc_sli.h
+++ b/drivers/scsi/lpfc/lpfc_sli.h
@@ -198,7 +198,7 @@ struct lpfc_sli {
198 int fcp_ring; /* ring used for FCP initiator commands */ 198 int fcp_ring; /* ring used for FCP initiator commands */
199 int next_ring; 199 int next_ring;
200 200
201 int ip_ring; /* ring used for IP network drv cmds */ 201 int extra_ring; /* extra ring used for other protocols */
202 202
203 struct lpfc_sli_stat slistat; /* SLI statistical info */ 203 struct lpfc_sli_stat slistat; /* SLI statistical info */
204 struct list_head mboxq; 204 struct list_head mboxq;
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index ac417908b407..a61ef3d1e7f1 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.1.10" 21#define LPFC_DRIVER_VERSION "8.1.11"
22 22
23#define LPFC_DRIVER_NAME "lpfc" 23#define LPFC_DRIVER_NAME "lpfc"
24 24
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 86099fde1b2a..77d9d3804ccf 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -73,10 +73,10 @@ static unsigned short int max_mbox_busy_wait = MBOX_BUSY_WAIT;
73module_param(max_mbox_busy_wait, ushort, 0); 73module_param(max_mbox_busy_wait, ushort, 0);
74MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)"); 74MODULE_PARM_DESC(max_mbox_busy_wait, "Maximum wait for mailbox in microseconds if busy (default=MBOX_BUSY_WAIT=10)");
75 75
76#define RDINDOOR(adapter) readl((adapter)->base + 0x20) 76#define RDINDOOR(adapter) readl((adapter)->mmio_base + 0x20)
77#define RDOUTDOOR(adapter) readl((adapter)->base + 0x2C) 77#define RDOUTDOOR(adapter) readl((adapter)->mmio_base + 0x2C)
78#define WRINDOOR(adapter,value) writel(value, (adapter)->base + 0x20) 78#define WRINDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x20)
79#define WROUTDOOR(adapter,value) writel(value, (adapter)->base + 0x2C) 79#define WROUTDOOR(adapter,value) writel(value, (adapter)->mmio_base + 0x2C)
80 80
81/* 81/*
82 * Global variables 82 * Global variables
@@ -1386,7 +1386,8 @@ megaraid_isr_memmapped(int irq, void *devp)
1386 1386
1387 handled = 1; 1387 handled = 1;
1388 1388
1389 while( RDINDOOR(adapter) & 0x02 ) cpu_relax(); 1389 while( RDINDOOR(adapter) & 0x02 )
1390 cpu_relax();
1390 1391
1391 mega_cmd_done(adapter, completed, nstatus, status); 1392 mega_cmd_done(adapter, completed, nstatus, status);
1392 1393
@@ -4668,6 +4669,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4668 host->host_no, mega_baseport, irq); 4669 host->host_no, mega_baseport, irq);
4669 4670
4670 adapter->base = mega_baseport; 4671 adapter->base = mega_baseport;
4672 if (flag & BOARD_MEMMAP)
4673 adapter->mmio_base = (void __iomem *) mega_baseport;
4671 4674
4672 INIT_LIST_HEAD(&adapter->free_list); 4675 INIT_LIST_HEAD(&adapter->free_list);
4673 INIT_LIST_HEAD(&adapter->pending_list); 4676 INIT_LIST_HEAD(&adapter->pending_list);
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 66529f11d23c..c6e74643abe2 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -801,7 +801,8 @@ typedef struct {
801 clustering is available */ 801 clustering is available */
802 u32 flag; 802 u32 flag;
803 803
804 unsigned long base; 804 unsigned long base;
805 void __iomem *mmio_base;
805 806
806 /* mbox64 with mbox not aligned on 16-byte boundry */ 807 /* mbox64 with mbox not aligned on 16-byte boundry */
807 mbox64_t *una_mbox64; 808 mbox64_t *una_mbox64;
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 7e4262f2af96..046223b4ae57 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -517,7 +517,7 @@ megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp,
517 * Returns the number of frames required for numnber of sge's (sge_count) 517 * Returns the number of frames required for numnber of sge's (sge_count)
518 */ 518 */
519 519
520u32 megasas_get_frame_count(u8 sge_count) 520static u32 megasas_get_frame_count(u8 sge_count)
521{ 521{
522 int num_cnt; 522 int num_cnt;
523 int sge_bytes; 523 int sge_bytes;
@@ -1733,7 +1733,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance,
1733 * 1733 *
1734 * Tasklet to complete cmds 1734 * Tasklet to complete cmds
1735 */ 1735 */
1736void megasas_complete_cmd_dpc(unsigned long instance_addr) 1736static void megasas_complete_cmd_dpc(unsigned long instance_addr)
1737{ 1737{
1738 u32 producer; 1738 u32 producer;
1739 u32 consumer; 1739 u32 consumer;
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index adb8eb4f5fd1..bbf521cbc55d 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -589,10 +589,12 @@ static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
589static struct ncr_driver_setup 589static struct ncr_driver_setup
590 driver_setup = SCSI_NCR_DRIVER_SETUP; 590 driver_setup = SCSI_NCR_DRIVER_SETUP;
591 591
592#ifndef MODULE
592#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT 593#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
593static struct ncr_driver_setup 594static struct ncr_driver_setup
594 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP; 595 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
595#endif 596#endif
597#endif /* !MODULE */
596 598
597#define initverbose (driver_setup.verbose) 599#define initverbose (driver_setup.verbose)
598#define bootverbose (np->verbose) 600#define bootverbose (np->verbose)
@@ -641,6 +643,13 @@ static struct ncr_driver_setup
641#define OPT_IARB 26 643#define OPT_IARB 26
642#endif 644#endif
643 645
646#ifdef MODULE
647#define ARG_SEP ' '
648#else
649#define ARG_SEP ','
650#endif
651
652#ifndef MODULE
644static char setup_token[] __initdata = 653static char setup_token[] __initdata =
645 "tags:" "mpar:" 654 "tags:" "mpar:"
646 "spar:" "disc:" 655 "spar:" "disc:"
@@ -660,12 +669,6 @@ static char setup_token[] __initdata =
660#endif 669#endif
661 ; /* DONNOT REMOVE THIS ';' */ 670 ; /* DONNOT REMOVE THIS ';' */
662 671
663#ifdef MODULE
664#define ARG_SEP ' '
665#else
666#define ARG_SEP ','
667#endif
668
669static int __init get_setup_token(char *p) 672static int __init get_setup_token(char *p)
670{ 673{
671 char *cur = setup_token; 674 char *cur = setup_token;
@@ -682,7 +685,6 @@ static int __init get_setup_token(char *p)
682 return 0; 685 return 0;
683} 686}
684 687
685
686static int __init sym53c8xx__setup(char *str) 688static int __init sym53c8xx__setup(char *str)
687{ 689{
688#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT 690#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
@@ -804,6 +806,7 @@ static int __init sym53c8xx__setup(char *str)
804#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */ 806#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
805 return 1; 807 return 1;
806} 808}
809#endif /* !MODULE */
807 810
808/*=================================================================== 811/*===================================================================
809** 812**
@@ -8321,12 +8324,12 @@ char *ncr53c8xx; /* command line passed by insmod */
8321module_param(ncr53c8xx, charp, 0); 8324module_param(ncr53c8xx, charp, 0);
8322#endif 8325#endif
8323 8326
8327#ifndef MODULE
8324static int __init ncr53c8xx_setup(char *str) 8328static int __init ncr53c8xx_setup(char *str)
8325{ 8329{
8326 return sym53c8xx__setup(str); 8330 return sym53c8xx__setup(str);
8327} 8331}
8328 8332
8329#ifndef MODULE
8330__setup("ncr53c8xx=", ncr53c8xx_setup); 8333__setup("ncr53c8xx=", ncr53c8xx_setup);
8331#endif 8334#endif
8332 8335
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index dd67a68c5c23..c116a6ae3c54 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -72,12 +72,12 @@ static void dma_advance_sg(Scsi_Cmnd *);
72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x); 72static int oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x);
73 73
74#ifdef USE_BOTTOM_HALF 74#ifdef USE_BOTTOM_HALF
75static void dma_commit(void *opaque); 75static void dma_commit(struct work_struct *unused);
76 76
77long oktag_to_io(long *paddr, long *addr, long len); 77long oktag_to_io(long *paddr, long *addr, long len);
78long oktag_from_io(long *addr, long *paddr, long len); 78long oktag_from_io(long *addr, long *paddr, long len);
79 79
80static DECLARE_WORK(tq_fake_dma, dma_commit, NULL); 80static DECLARE_WORK(tq_fake_dma, dma_commit);
81 81
82#define DMA_MAXTRANSFER 0x8000 82#define DMA_MAXTRANSFER 0x8000
83 83
@@ -266,7 +266,7 @@ oktagon_notify_reboot(struct notifier_block *this, unsigned long code, void *x)
266 */ 266 */
267 267
268 268
269static void dma_commit(void *opaque) 269static void dma_commit(struct work_struct *unused)
270{ 270{
271 long wait,len2,pos; 271 long wait,len2,pos;
272 struct NCR_ESP *esp; 272 struct NCR_ESP *esp;
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index ee449b29fc82..aad362ba02e0 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -154,16 +154,11 @@ static int aha152x_config_cs(struct pcmcia_device *link)
154 154
155 DEBUG(0, "aha152x_config(0x%p)\n", link); 155 DEBUG(0, "aha152x_config(0x%p)\n", link);
156 156
157 tuple.DesiredTuple = CISTPL_CONFIG;
158 tuple.TupleData = tuple_data; 157 tuple.TupleData = tuple_data;
159 tuple.TupleDataMax = 64; 158 tuple.TupleDataMax = 64;
160 tuple.TupleOffset = 0; 159 tuple.TupleOffset = 0;
161 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
162 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
163 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
164 link->conf.ConfigBase = parse.config.base;
165
166 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 160 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
161 tuple.Attributes = 0;
167 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 162 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
168 while (1) { 163 while (1) {
169 if (pcmcia_get_tuple_data(link, &tuple) != 0 || 164 if (pcmcia_get_tuple_data(link, &tuple) != 0 ||
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 85f7ffac19a0..a1c5f265069f 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -136,14 +136,9 @@ static int fdomain_config(struct pcmcia_device *link)
136 136
137 DEBUG(0, "fdomain_config(0x%p)\n", link); 137 DEBUG(0, "fdomain_config(0x%p)\n", link);
138 138
139 tuple.DesiredTuple = CISTPL_CONFIG;
140 tuple.TupleData = tuple_data; 139 tuple.TupleData = tuple_data;
141 tuple.TupleDataMax = 64; 140 tuple.TupleDataMax = 64;
142 tuple.TupleOffset = 0; 141 tuple.TupleOffset = 0;
143 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
144 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
145 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
146 link->conf.ConfigBase = parse.config.base;
147 142
148 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 143 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
149 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 144 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index f2d79c3f0b8e..d72df5dae4ee 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1685,16 +1685,10 @@ static int nsp_cs_config(struct pcmcia_device *link)
1685 1685
1686 nsp_dbg(NSP_DEBUG_INIT, "in"); 1686 nsp_dbg(NSP_DEBUG_INIT, "in");
1687 1687
1688 tuple.DesiredTuple = CISTPL_CONFIG;
1689 tuple.Attributes = 0; 1688 tuple.Attributes = 0;
1690 tuple.TupleData = tuple_data; 1689 tuple.TupleData = tuple_data;
1691 tuple.TupleDataMax = sizeof(tuple_data); 1690 tuple.TupleDataMax = sizeof(tuple_data);
1692 tuple.TupleOffset = 0; 1691 tuple.TupleOffset = 0;
1693 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
1694 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
1695 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
1696 link->conf.ConfigBase = parse.config.base;
1697 link->conf.Present = parse.config.rmask[0];
1698 1692
1699 /* Look up the current Vcc */ 1693 /* Look up the current Vcc */
1700 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 1694 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf));
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 86c2ac6ae623..9d431fe7f47f 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -208,18 +208,11 @@ static int qlogic_config(struct pcmcia_device * link)
208 208
209 DEBUG(0, "qlogic_config(0x%p)\n", link); 209 DEBUG(0, "qlogic_config(0x%p)\n", link);
210 210
211 info->manf_id = link->manf_id;
212
211 tuple.TupleData = (cisdata_t *) tuple_data; 213 tuple.TupleData = (cisdata_t *) tuple_data;
212 tuple.TupleDataMax = 64; 214 tuple.TupleDataMax = 64;
213 tuple.TupleOffset = 0; 215 tuple.TupleOffset = 0;
214 tuple.DesiredTuple = CISTPL_CONFIG;
215 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
216 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
217 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
218 link->conf.ConfigBase = parse.config.base;
219
220 tuple.DesiredTuple = CISTPL_MANFID;
221 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS))
222 info->manf_id = le16_to_cpu(tuple.TupleData[0]);
223 216
224 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 217 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
225 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 218 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 72fe5d055de1..fb7acea60286 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -722,19 +722,11 @@ SYM53C500_config(struct pcmcia_device *link)
722 722
723 DEBUG(0, "SYM53C500_config(0x%p)\n", link); 723 DEBUG(0, "SYM53C500_config(0x%p)\n", link);
724 724
725 info->manf_id = link->manf_id;
726
725 tuple.TupleData = (cisdata_t *)tuple_data; 727 tuple.TupleData = (cisdata_t *)tuple_data;
726 tuple.TupleDataMax = 64; 728 tuple.TupleDataMax = 64;
727 tuple.TupleOffset = 0; 729 tuple.TupleOffset = 0;
728 tuple.DesiredTuple = CISTPL_CONFIG;
729 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
730 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
731 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
732 link->conf.ConfigBase = parse.config.base;
733
734 tuple.DesiredTuple = CISTPL_MANFID;
735 if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) &&
736 (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS))
737 info->manf_id = le16_to_cpu(tuple.TupleData[0]);
738 730
739 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 731 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
740 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 732 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index 89a2a9f11e41..584ba4d6e038 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -31,7 +31,7 @@ typedef struct {
31 int base; /* Actual port address */ 31 int base; /* Actual port address */
32 int mode; /* Transfer mode */ 32 int mode; /* Transfer mode */
33 struct scsi_cmnd *cur_cmd; /* Current queued command */ 33 struct scsi_cmnd *cur_cmd; /* Current queued command */
34 struct work_struct ppa_tq; /* Polling interrupt stuff */ 34 struct delayed_work ppa_tq; /* Polling interrupt stuff */
35 unsigned long jstart; /* Jiffies at start */ 35 unsigned long jstart; /* Jiffies at start */
36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */ 36 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
37 unsigned int failed:1; /* Failure flag */ 37 unsigned int failed:1; /* Failure flag */
@@ -627,9 +627,9 @@ static int ppa_completion(struct scsi_cmnd *cmd)
627 * the scheduler's task queue to generate a stream of call-backs and 627 * the scheduler's task queue to generate a stream of call-backs and
628 * complete the request when the drive is ready. 628 * complete the request when the drive is ready.
629 */ 629 */
630static void ppa_interrupt(void *data) 630static void ppa_interrupt(struct work_struct *work)
631{ 631{
632 ppa_struct *dev = (ppa_struct *) data; 632 ppa_struct *dev = container_of(work, ppa_struct, ppa_tq.work);
633 struct scsi_cmnd *cmd = dev->cur_cmd; 633 struct scsi_cmnd *cmd = dev->cur_cmd;
634 634
635 if (!cmd) { 635 if (!cmd) {
@@ -637,7 +637,6 @@ static void ppa_interrupt(void *data)
637 return; 637 return;
638 } 638 }
639 if (ppa_engine(dev, cmd)) { 639 if (ppa_engine(dev, cmd)) {
640 dev->ppa_tq.data = (void *) dev;
641 schedule_delayed_work(&dev->ppa_tq, 1); 640 schedule_delayed_work(&dev->ppa_tq, 1);
642 return; 641 return;
643 } 642 }
@@ -822,8 +821,7 @@ static int ppa_queuecommand(struct scsi_cmnd *cmd,
822 cmd->result = DID_ERROR << 16; /* default return code */ 821 cmd->result = DID_ERROR << 16; /* default return code */
823 cmd->SCp.phase = 0; /* bus free */ 822 cmd->SCp.phase = 0; /* bus free */
824 823
825 dev->ppa_tq.data = dev; 824 schedule_delayed_work(&dev->ppa_tq, 0);
826 schedule_work(&dev->ppa_tq);
827 825
828 ppa_pb_claim(dev); 826 ppa_pb_claim(dev);
829 827
@@ -1086,7 +1084,7 @@ static int __ppa_attach(struct parport *pb)
1086 else 1084 else
1087 ports = 8; 1085 ports = 8;
1088 1086
1089 INIT_WORK(&dev->ppa_tq, ppa_interrupt, dev); 1087 INIT_DELAYED_WORK(&dev->ppa_tq, ppa_interrupt);
1090 1088
1091 err = -ENOMEM; 1089 err = -ENOMEM;
1092 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *)); 1090 host = scsi_host_alloc(&ppa_template, sizeof(ppa_struct *));
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 285c8e8ff1a0..7b18a6c7b7eb 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -390,7 +390,7 @@ static struct sysfs_entry {
390 { "optrom_ctl", &sysfs_optrom_ctl_attr, }, 390 { "optrom_ctl", &sysfs_optrom_ctl_attr, },
391 { "vpd", &sysfs_vpd_attr, 1 }, 391 { "vpd", &sysfs_vpd_attr, 1 },
392 { "sfp", &sysfs_sfp_attr, 1 }, 392 { "sfp", &sysfs_sfp_attr, 1 },
393 { 0 }, 393 { NULL },
394}; 394};
395 395
396void 396void
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 08cb5e3fb553..a823f0bc519d 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -59,9 +59,6 @@ int
59qla2x00_initialize_adapter(scsi_qla_host_t *ha) 59qla2x00_initialize_adapter(scsi_qla_host_t *ha)
60{ 60{
61 int rval; 61 int rval;
62 uint8_t restart_risc = 0;
63 uint8_t retry;
64 uint32_t wait_time;
65 62
66 /* Clear adapter flags. */ 63 /* Clear adapter flags. */
67 ha->flags.online = 0; 64 ha->flags.online = 0;
@@ -104,87 +101,15 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
104 101
105 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 102 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
106 103
107 retry = 10; 104 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
108 /* 105 rval = ha->isp_ops.chip_diag(ha);
109 * Try to configure the loop. 106 if (rval)
110 */ 107 return (rval);
111 do { 108 rval = qla2x00_setup_chip(ha);
112 restart_risc = 0; 109 if (rval)
113 110 return (rval);
114 /* If firmware needs to be loaded */
115 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
116 if ((rval = ha->isp_ops.chip_diag(ha)) == QLA_SUCCESS) {
117 rval = qla2x00_setup_chip(ha);
118 }
119 }
120
121 if (rval == QLA_SUCCESS &&
122 (rval = qla2x00_init_rings(ha)) == QLA_SUCCESS) {
123check_fw_ready_again:
124 /*
125 * Wait for a successful LIP up to a maximum
126 * of (in seconds): RISC login timeout value,
127 * RISC retry count value, and port down retry
128 * value OR a minimum of 4 seconds OR If no
129 * cable, only 5 seconds.
130 */
131 rval = qla2x00_fw_ready(ha);
132 if (rval == QLA_SUCCESS) {
133 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
134
135 /* Issue a marker after FW becomes ready. */
136 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
137
138 /*
139 * Wait at most MAX_TARGET RSCNs for a stable
140 * link.
141 */
142 wait_time = 256;
143 do {
144 clear_bit(LOOP_RESYNC_NEEDED,
145 &ha->dpc_flags);
146 rval = qla2x00_configure_loop(ha);
147
148 if (test_and_clear_bit(ISP_ABORT_NEEDED,
149 &ha->dpc_flags)) {
150 restart_risc = 1;
151 break;
152 }
153
154 /*
155 * If loop state change while we were
156 * discoverying devices then wait for
157 * LIP to complete
158 */
159
160 if (atomic_read(&ha->loop_state) !=
161 LOOP_READY && retry--) {
162 goto check_fw_ready_again;
163 }
164 wait_time--;
165 } while (!atomic_read(&ha->loop_down_timer) &&
166 retry &&
167 wait_time &&
168 (test_bit(LOOP_RESYNC_NEEDED,
169 &ha->dpc_flags)));
170
171 if (wait_time == 0)
172 rval = QLA_FUNCTION_FAILED;
173 } else if (ha->device_flags & DFLG_NO_CABLE)
174 /* If no cable, then all is good. */
175 rval = QLA_SUCCESS;
176 }
177 } while (restart_risc && retry--);
178
179 if (rval == QLA_SUCCESS) {
180 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
181 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
182 ha->marker_needed = 0;
183
184 ha->flags.online = 1;
185 } else {
186 DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__));
187 } 111 }
112 rval = qla2x00_init_rings(ha);
188 113
189 return (rval); 114 return (rval);
190} 115}
@@ -2208,8 +2133,7 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2208 2133
2209 atomic_set(&fcport->state, FCS_ONLINE); 2134 atomic_set(&fcport->state, FCS_ONLINE);
2210 2135
2211 if (ha->flags.init_done) 2136 qla2x00_reg_remote_port(ha, fcport);
2212 qla2x00_reg_remote_port(ha, fcport);
2213} 2137}
2214 2138
2215void 2139void
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 208607be78c7..cbe0cad83b68 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -95,6 +95,8 @@ MODULE_PARM_DESC(ql2xqfullrampup,
95 */ 95 */
96static int qla2xxx_slave_configure(struct scsi_device * device); 96static int qla2xxx_slave_configure(struct scsi_device * device);
97static int qla2xxx_slave_alloc(struct scsi_device *); 97static int qla2xxx_slave_alloc(struct scsi_device *);
98static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
99static void qla2xxx_scan_start(struct Scsi_Host *);
98static void qla2xxx_slave_destroy(struct scsi_device *); 100static void qla2xxx_slave_destroy(struct scsi_device *);
99static int qla2x00_queuecommand(struct scsi_cmnd *cmd, 101static int qla2x00_queuecommand(struct scsi_cmnd *cmd,
100 void (*fn)(struct scsi_cmnd *)); 102 void (*fn)(struct scsi_cmnd *));
@@ -124,6 +126,8 @@ static struct scsi_host_template qla2x00_driver_template = {
124 126
125 .slave_alloc = qla2xxx_slave_alloc, 127 .slave_alloc = qla2xxx_slave_alloc,
126 .slave_destroy = qla2xxx_slave_destroy, 128 .slave_destroy = qla2xxx_slave_destroy,
129 .scan_finished = qla2xxx_scan_finished,
130 .scan_start = qla2xxx_scan_start,
127 .change_queue_depth = qla2x00_change_queue_depth, 131 .change_queue_depth = qla2x00_change_queue_depth,
128 .change_queue_type = qla2x00_change_queue_type, 132 .change_queue_type = qla2x00_change_queue_type,
129 .this_id = -1, 133 .this_id = -1,
@@ -287,7 +291,7 @@ qla24xx_pci_info_str(struct scsi_qla_host *ha, char *str)
287 return str; 291 return str;
288} 292}
289 293
290char * 294static char *
291qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str) 295qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
292{ 296{
293 char un_str[10]; 297 char un_str[10];
@@ -325,7 +329,7 @@ qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
325 return (str); 329 return (str);
326} 330}
327 331
328char * 332static char *
329qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str) 333qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str)
330{ 334{
331 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, 335 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
@@ -634,7 +638,7 @@ qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
634* Note: 638* Note:
635* Only return FAILED if command not returned by firmware. 639* Only return FAILED if command not returned by firmware.
636**************************************************************************/ 640**************************************************************************/
637int 641static int
638qla2xxx_eh_abort(struct scsi_cmnd *cmd) 642qla2xxx_eh_abort(struct scsi_cmnd *cmd)
639{ 643{
640 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 644 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -771,7 +775,7 @@ qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t *ha, unsigned int t)
771* SUCCESS/FAILURE (defined as macro in scsi.h). 775* SUCCESS/FAILURE (defined as macro in scsi.h).
772* 776*
773**************************************************************************/ 777**************************************************************************/
774int 778static int
775qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) 779qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
776{ 780{
777 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 781 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -902,7 +906,7 @@ qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *ha)
902* SUCCESS/FAILURE (defined as macro in scsi.h). 906* SUCCESS/FAILURE (defined as macro in scsi.h).
903* 907*
904**************************************************************************/ 908**************************************************************************/
905int 909static int
906qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) 910qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
907{ 911{
908 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 912 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -963,7 +967,7 @@ eh_bus_reset_done:
963* 967*
964* Note: 968* Note:
965**************************************************************************/ 969**************************************************************************/
966int 970static int
967qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) 971qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
968{ 972{
969 scsi_qla_host_t *ha = to_qla_host(cmd->device->host); 973 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);
@@ -1366,6 +1370,29 @@ qla24xx_disable_intrs(scsi_qla_host_t *ha)
1366 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1370 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1367} 1371}
1368 1372
1373static void
1374qla2xxx_scan_start(struct Scsi_Host *shost)
1375{
1376 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1377
1378 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
1379 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1380 set_bit(RSCN_UPDATE, &ha->dpc_flags);
1381}
1382
1383static int
1384qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
1385{
1386 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
1387
1388 if (!ha->host)
1389 return 1;
1390 if (time > ha->loop_reset_delay * HZ)
1391 return 1;
1392
1393 return atomic_read(&ha->loop_state) == LOOP_READY;
1394}
1395
1369/* 1396/*
1370 * PCI driver interface 1397 * PCI driver interface
1371 */ 1398 */
@@ -1377,10 +1404,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1377 struct Scsi_Host *host; 1404 struct Scsi_Host *host;
1378 scsi_qla_host_t *ha; 1405 scsi_qla_host_t *ha;
1379 unsigned long flags = 0; 1406 unsigned long flags = 0;
1380 unsigned long wait_switch = 0;
1381 char pci_info[20]; 1407 char pci_info[20];
1382 char fw_str[30]; 1408 char fw_str[30];
1383 fc_port_t *fcport;
1384 struct scsi_host_template *sht; 1409 struct scsi_host_template *sht;
1385 1410
1386 if (pci_enable_device(pdev)) 1411 if (pci_enable_device(pdev))
@@ -1631,30 +1656,19 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1631 1656
1632 ha->isp_ops.enable_intrs(ha); 1657 ha->isp_ops.enable_intrs(ha);
1633 1658
1634 /* v2.19.5b6 */
1635 /*
1636 * Wait around max loop_reset_delay secs for the devices to come
1637 * on-line. We don't want Linux scanning before we are ready.
1638 *
1639 */
1640 for (wait_switch = jiffies + (ha->loop_reset_delay * HZ);
1641 time_before(jiffies,wait_switch) &&
1642 !(ha->device_flags & (DFLG_NO_CABLE | DFLG_FABRIC_DEVICES))
1643 && (ha->device_flags & SWITCH_FOUND) ;) {
1644
1645 qla2x00_check_fabric_devices(ha);
1646
1647 msleep(10);
1648 }
1649
1650 pci_set_drvdata(pdev, ha); 1659 pci_set_drvdata(pdev, ha);
1660
1651 ha->flags.init_done = 1; 1661 ha->flags.init_done = 1;
1662 ha->flags.online = 1;
1663
1652 num_hosts++; 1664 num_hosts++;
1653 1665
1654 ret = scsi_add_host(host, &pdev->dev); 1666 ret = scsi_add_host(host, &pdev->dev);
1655 if (ret) 1667 if (ret)
1656 goto probe_failed; 1668 goto probe_failed;
1657 1669
1670 scsi_scan_host(host);
1671
1658 qla2x00_alloc_sysfs_attr(ha); 1672 qla2x00_alloc_sysfs_attr(ha);
1659 1673
1660 qla2x00_init_host_attr(ha); 1674 qla2x00_init_host_attr(ha);
@@ -1669,10 +1683,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1669 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no, 1683 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no,
1670 ha->isp_ops.fw_version_str(ha, fw_str)); 1684 ha->isp_ops.fw_version_str(ha, fw_str));
1671 1685
1672 /* Go with fc_rport registration. */
1673 list_for_each_entry(fcport, &ha->fcports, list)
1674 qla2x00_reg_remote_port(ha, fcport);
1675
1676 return 0; 1686 return 0;
1677 1687
1678probe_failed: 1688probe_failed:
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index c71dbd5bd543..15390ad87456 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -449,7 +449,7 @@ nvram_data_to_access_addr(uint32_t naddr)
449 return FARX_ACCESS_NVRAM_DATA | naddr; 449 return FARX_ACCESS_NVRAM_DATA | naddr;
450} 450}
451 451
452uint32_t 452static uint32_t
453qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr) 453qla24xx_read_flash_dword(scsi_qla_host_t *ha, uint32_t addr)
454{ 454{
455 int rval; 455 int rval;
@@ -490,7 +490,7 @@ qla24xx_read_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
490 return dwptr; 490 return dwptr;
491} 491}
492 492
493int 493static int
494qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data) 494qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
495{ 495{
496 int rval; 496 int rval;
@@ -512,7 +512,7 @@ qla24xx_write_flash_dword(scsi_qla_host_t *ha, uint32_t addr, uint32_t data)
512 return rval; 512 return rval;
513} 513}
514 514
515void 515static void
516qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id, 516qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
517 uint8_t *flash_id) 517 uint8_t *flash_id)
518{ 518{
@@ -537,7 +537,7 @@ qla24xx_get_flash_manufacturer(scsi_qla_host_t *ha, uint8_t *man_id,
537 } 537 }
538} 538}
539 539
540int 540static int
541qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr, 541qla24xx_write_flash_data(scsi_qla_host_t *ha, uint32_t *dwptr, uint32_t faddr,
542 uint32_t dwords) 542 uint32_t dwords)
543{ 543{
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.c b/drivers/scsi/qla4xxx/ql4_dbg.c
index 752031fadfef..7b4e077a39c1 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.c
+++ b/drivers/scsi/qla4xxx/ql4_dbg.c
@@ -71,7 +71,7 @@ void __dump_registers(struct scsi_qla_host *ha)
71 readw(&ha->reg->u1.isp4010.nvram)); 71 readw(&ha->reg->u1.isp4010.nvram));
72 } 72 }
73 73
74 else if (is_qla4022(ha)) { 74 else if (is_qla4022(ha) | is_qla4032(ha)) {
75 printk(KERN_INFO "0x%02X intr_mask = 0x%08X\n", 75 printk(KERN_INFO "0x%02X intr_mask = 0x%08X\n",
76 (uint8_t) offsetof(struct isp_reg, 76 (uint8_t) offsetof(struct isp_reg,
77 u1.isp4022.intr_mask), 77 u1.isp4022.intr_mask),
@@ -119,7 +119,7 @@ void __dump_registers(struct scsi_qla_host *ha)
119 readw(&ha->reg->u2.isp4010.port_err_status)); 119 readw(&ha->reg->u2.isp4010.port_err_status));
120 } 120 }
121 121
122 else if (is_qla4022(ha)) { 122 else if (is_qla4022(ha) | is_qla4032(ha)) {
123 printk(KERN_INFO "Page 0 Registers:\n"); 123 printk(KERN_INFO "Page 0 Registers:\n");
124 printk(KERN_INFO "0x%02X ext_hw_conf = 0x%08X\n", 124 printk(KERN_INFO "0x%02X ext_hw_conf = 0x%08X\n",
125 (uint8_t) offsetof(struct isp_reg, 125 (uint8_t) offsetof(struct isp_reg,
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index a7f6c7b1c590..4249e52a5592 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -40,7 +40,11 @@
40 40
41#ifndef PCI_DEVICE_ID_QLOGIC_ISP4022 41#ifndef PCI_DEVICE_ID_QLOGIC_ISP4022
42#define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022 42#define PCI_DEVICE_ID_QLOGIC_ISP4022 0x4022
43#endif /* */ 43#endif
44
45#ifndef PCI_DEVICE_ID_QLOGIC_ISP4032
46#define PCI_DEVICE_ID_QLOGIC_ISP4032 0x4032
47#endif
44 48
45#define QLA_SUCCESS 0 49#define QLA_SUCCESS 0
46#define QLA_ERROR 1 50#define QLA_ERROR 1
@@ -277,7 +281,6 @@ struct scsi_qla_host {
277#define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */ 281#define AF_INTERRUPTS_ON 6 /* 0x00000040 Not Used */
278#define AF_GET_CRASH_RECORD 7 /* 0x00000080 */ 282#define AF_GET_CRASH_RECORD 7 /* 0x00000080 */
279#define AF_LINK_UP 8 /* 0x00000100 */ 283#define AF_LINK_UP 8 /* 0x00000100 */
280#define AF_TOPCAT_CHIP_PRESENT 9 /* 0x00000200 */
281#define AF_IRQ_ATTACHED 10 /* 0x00000400 */ 284#define AF_IRQ_ATTACHED 10 /* 0x00000400 */
282#define AF_ISNS_CMD_IN_PROCESS 12 /* 0x00001000 */ 285#define AF_ISNS_CMD_IN_PROCESS 12 /* 0x00001000 */
283#define AF_ISNS_CMD_DONE 13 /* 0x00002000 */ 286#define AF_ISNS_CMD_DONE 13 /* 0x00002000 */
@@ -317,16 +320,17 @@ struct scsi_qla_host {
317 /* NVRAM registers */ 320 /* NVRAM registers */
318 struct eeprom_data *nvram; 321 struct eeprom_data *nvram;
319 spinlock_t hardware_lock ____cacheline_aligned; 322 spinlock_t hardware_lock ____cacheline_aligned;
320 spinlock_t list_lock;
321 uint32_t eeprom_cmd_data; 323 uint32_t eeprom_cmd_data;
322 324
323 /* Counters for general statistics */ 325 /* Counters for general statistics */
326 uint64_t isr_count;
324 uint64_t adapter_error_count; 327 uint64_t adapter_error_count;
325 uint64_t device_error_count; 328 uint64_t device_error_count;
326 uint64_t total_io_count; 329 uint64_t total_io_count;
327 uint64_t total_mbytes_xferred; 330 uint64_t total_mbytes_xferred;
328 uint64_t link_failure_count; 331 uint64_t link_failure_count;
329 uint64_t invalid_crc_count; 332 uint64_t invalid_crc_count;
333 uint32_t bytes_xfered;
330 uint32_t spurious_int_count; 334 uint32_t spurious_int_count;
331 uint32_t aborted_io_count; 335 uint32_t aborted_io_count;
332 uint32_t io_timeout_count; 336 uint32_t io_timeout_count;
@@ -438,6 +442,11 @@ static inline int is_qla4022(struct scsi_qla_host *ha)
438 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022; 442 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4022;
439} 443}
440 444
445static inline int is_qla4032(struct scsi_qla_host *ha)
446{
447 return ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP4032;
448}
449
441static inline int adapter_up(struct scsi_qla_host *ha) 450static inline int adapter_up(struct scsi_qla_host *ha)
442{ 451{
443 return (test_bit(AF_ONLINE, &ha->flags) != 0) && 452 return (test_bit(AF_ONLINE, &ha->flags) != 0) &&
@@ -451,58 +460,58 @@ static inline struct scsi_qla_host* to_qla_host(struct Scsi_Host *shost)
451 460
452static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha) 461static inline void __iomem* isp_semaphore(struct scsi_qla_host *ha)
453{ 462{
454 return (is_qla4022(ha) ? 463 return (is_qla4010(ha) ?
455 &ha->reg->u1.isp4022.semaphore : 464 &ha->reg->u1.isp4010.nvram :
456 &ha->reg->u1.isp4010.nvram); 465 &ha->reg->u1.isp4022.semaphore);
457} 466}
458 467
459static inline void __iomem* isp_nvram(struct scsi_qla_host *ha) 468static inline void __iomem* isp_nvram(struct scsi_qla_host *ha)
460{ 469{
461 return (is_qla4022(ha) ? 470 return (is_qla4010(ha) ?
462 &ha->reg->u1.isp4022.nvram : 471 &ha->reg->u1.isp4010.nvram :
463 &ha->reg->u1.isp4010.nvram); 472 &ha->reg->u1.isp4022.nvram);
464} 473}
465 474
466static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha) 475static inline void __iomem* isp_ext_hw_conf(struct scsi_qla_host *ha)
467{ 476{
468 return (is_qla4022(ha) ? 477 return (is_qla4010(ha) ?
469 &ha->reg->u2.isp4022.p0.ext_hw_conf : 478 &ha->reg->u2.isp4010.ext_hw_conf :
470 &ha->reg->u2.isp4010.ext_hw_conf); 479 &ha->reg->u2.isp4022.p0.ext_hw_conf);
471} 480}
472 481
473static inline void __iomem* isp_port_status(struct scsi_qla_host *ha) 482static inline void __iomem* isp_port_status(struct scsi_qla_host *ha)
474{ 483{
475 return (is_qla4022(ha) ? 484 return (is_qla4010(ha) ?
476 &ha->reg->u2.isp4022.p0.port_status : 485 &ha->reg->u2.isp4010.port_status :
477 &ha->reg->u2.isp4010.port_status); 486 &ha->reg->u2.isp4022.p0.port_status);
478} 487}
479 488
480static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha) 489static inline void __iomem* isp_port_ctrl(struct scsi_qla_host *ha)
481{ 490{
482 return (is_qla4022(ha) ? 491 return (is_qla4010(ha) ?
483 &ha->reg->u2.isp4022.p0.port_ctrl : 492 &ha->reg->u2.isp4010.port_ctrl :
484 &ha->reg->u2.isp4010.port_ctrl); 493 &ha->reg->u2.isp4022.p0.port_ctrl);
485} 494}
486 495
487static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha) 496static inline void __iomem* isp_port_error_status(struct scsi_qla_host *ha)
488{ 497{
489 return (is_qla4022(ha) ? 498 return (is_qla4010(ha) ?
490 &ha->reg->u2.isp4022.p0.port_err_status : 499 &ha->reg->u2.isp4010.port_err_status :
491 &ha->reg->u2.isp4010.port_err_status); 500 &ha->reg->u2.isp4022.p0.port_err_status);
492} 501}
493 502
494static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha) 503static inline void __iomem * isp_gp_out(struct scsi_qla_host *ha)
495{ 504{
496 return (is_qla4022(ha) ? 505 return (is_qla4010(ha) ?
497 &ha->reg->u2.isp4022.p0.gp_out : 506 &ha->reg->u2.isp4010.gp_out :
498 &ha->reg->u2.isp4010.gp_out); 507 &ha->reg->u2.isp4022.p0.gp_out);
499} 508}
500 509
501static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha) 510static inline int eeprom_ext_hw_conf_offset(struct scsi_qla_host *ha)
502{ 511{
503 return (is_qla4022(ha) ? 512 return (is_qla4010(ha) ?
504 offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2 : 513 offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2 :
505 offsetof(struct eeprom_data, isp4010.ext_hw_conf) / 2); 514 offsetof(struct eeprom_data, isp4022.ext_hw_conf) / 2);
506} 515}
507 516
508int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits); 517int ql4xxx_sem_spinlock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
@@ -511,59 +520,59 @@ int ql4xxx_sem_lock(struct scsi_qla_host * ha, u32 sem_mask, u32 sem_bits);
511 520
512static inline int ql4xxx_lock_flash(struct scsi_qla_host *a) 521static inline int ql4xxx_lock_flash(struct scsi_qla_host *a)
513{ 522{
514 if (is_qla4022(a)) 523 if (is_qla4010(a))
524 return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK,
525 QL4010_FLASH_SEM_BITS);
526 else
515 return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK, 527 return ql4xxx_sem_spinlock(a, QL4022_FLASH_SEM_MASK,
516 (QL4022_RESOURCE_BITS_BASE_CODE | 528 (QL4022_RESOURCE_BITS_BASE_CODE |
517 (a->mac_index)) << 13); 529 (a->mac_index)) << 13);
518 else
519 return ql4xxx_sem_spinlock(a, QL4010_FLASH_SEM_MASK,
520 QL4010_FLASH_SEM_BITS);
521} 530}
522 531
523static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a) 532static inline void ql4xxx_unlock_flash(struct scsi_qla_host *a)
524{ 533{
525 if (is_qla4022(a)) 534 if (is_qla4010(a))
526 ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK);
527 else
528 ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK); 535 ql4xxx_sem_unlock(a, QL4010_FLASH_SEM_MASK);
536 else
537 ql4xxx_sem_unlock(a, QL4022_FLASH_SEM_MASK);
529} 538}
530 539
531static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a) 540static inline int ql4xxx_lock_nvram(struct scsi_qla_host *a)
532{ 541{
533 if (is_qla4022(a)) 542 if (is_qla4010(a))
543 return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK,
544 QL4010_NVRAM_SEM_BITS);
545 else
534 return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK, 546 return ql4xxx_sem_spinlock(a, QL4022_NVRAM_SEM_MASK,
535 (QL4022_RESOURCE_BITS_BASE_CODE | 547 (QL4022_RESOURCE_BITS_BASE_CODE |
536 (a->mac_index)) << 10); 548 (a->mac_index)) << 10);
537 else
538 return ql4xxx_sem_spinlock(a, QL4010_NVRAM_SEM_MASK,
539 QL4010_NVRAM_SEM_BITS);
540} 549}
541 550
542static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a) 551static inline void ql4xxx_unlock_nvram(struct scsi_qla_host *a)
543{ 552{
544 if (is_qla4022(a)) 553 if (is_qla4010(a))
545 ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK);
546 else
547 ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK); 554 ql4xxx_sem_unlock(a, QL4010_NVRAM_SEM_MASK);
555 else
556 ql4xxx_sem_unlock(a, QL4022_NVRAM_SEM_MASK);
548} 557}
549 558
550static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a) 559static inline int ql4xxx_lock_drvr(struct scsi_qla_host *a)
551{ 560{
552 if (is_qla4022(a)) 561 if (is_qla4010(a))
562 return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK,
563 QL4010_DRVR_SEM_BITS);
564 else
553 return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK, 565 return ql4xxx_sem_lock(a, QL4022_DRVR_SEM_MASK,
554 (QL4022_RESOURCE_BITS_BASE_CODE | 566 (QL4022_RESOURCE_BITS_BASE_CODE |
555 (a->mac_index)) << 1); 567 (a->mac_index)) << 1);
556 else
557 return ql4xxx_sem_lock(a, QL4010_DRVR_SEM_MASK,
558 QL4010_DRVR_SEM_BITS);
559} 568}
560 569
561static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a) 570static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a)
562{ 571{
563 if (is_qla4022(a)) 572 if (is_qla4010(a))
564 ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
565 else
566 ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK); 573 ql4xxx_sem_unlock(a, QL4010_DRVR_SEM_MASK);
574 else
575 ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
567} 576}
568 577
569/*---------------------------------------------------------------------------*/ 578/*---------------------------------------------------------------------------*/
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 427489de64bc..4eea8c571916 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -296,7 +296,6 @@ static inline uint32_t clr_rmask(uint32_t val)
296/* ISP Semaphore definitions */ 296/* ISP Semaphore definitions */
297 297
298/* ISP General Purpose Output definitions */ 298/* ISP General Purpose Output definitions */
299#define GPOR_TOPCAT_RESET 0x00000004
300 299
301/* shadow registers (DMA'd from HA to system memory. read only) */ 300/* shadow registers (DMA'd from HA to system memory. read only) */
302struct shadow_regs { 301struct shadow_regs {
@@ -339,10 +338,13 @@ union external_hw_config_reg {
339/* Mailbox command definitions */ 338/* Mailbox command definitions */
340#define MBOX_CMD_ABOUT_FW 0x0009 339#define MBOX_CMD_ABOUT_FW 0x0009
341#define MBOX_CMD_LUN_RESET 0x0016 340#define MBOX_CMD_LUN_RESET 0x0016
341#define MBOX_CMD_GET_MANAGEMENT_DATA 0x001E
342#define MBOX_CMD_GET_FW_STATUS 0x001F 342#define MBOX_CMD_GET_FW_STATUS 0x001F
343#define MBOX_CMD_SET_ISNS_SERVICE 0x0021 343#define MBOX_CMD_SET_ISNS_SERVICE 0x0021
344#define ISNS_DISABLE 0 344#define ISNS_DISABLE 0
345#define ISNS_ENABLE 1 345#define ISNS_ENABLE 1
346#define MBOX_CMD_COPY_FLASH 0x0024
347#define MBOX_CMD_WRITE_FLASH 0x0025
346#define MBOX_CMD_READ_FLASH 0x0026 348#define MBOX_CMD_READ_FLASH 0x0026
347#define MBOX_CMD_CLEAR_DATABASE_ENTRY 0x0031 349#define MBOX_CMD_CLEAR_DATABASE_ENTRY 0x0031
348#define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT 0x0056 350#define MBOX_CMD_CONN_CLOSE_SESS_LOGOUT 0x0056
@@ -360,10 +362,13 @@ union external_hw_config_reg {
360#define DDB_DS_SESSION_FAILED 0x06 362#define DDB_DS_SESSION_FAILED 0x06
361#define DDB_DS_LOGIN_IN_PROCESS 0x07 363#define DDB_DS_LOGIN_IN_PROCESS 0x07
362#define MBOX_CMD_GET_FW_STATE 0x0069 364#define MBOX_CMD_GET_FW_STATE 0x0069
365#define MBOX_CMD_GET_INIT_FW_CTRL_BLOCK_DEFAULTS 0x006A
366#define MBOX_CMD_RESTORE_FACTORY_DEFAULTS 0x0087
363 367
364/* Mailbox 1 */ 368/* Mailbox 1 */
365#define FW_STATE_READY 0x0000 369#define FW_STATE_READY 0x0000
366#define FW_STATE_CONFIG_WAIT 0x0001 370#define FW_STATE_CONFIG_WAIT 0x0001
371#define FW_STATE_WAIT_LOGIN 0x0002
367#define FW_STATE_ERROR 0x0004 372#define FW_STATE_ERROR 0x0004
368#define FW_STATE_DHCP_IN_PROGRESS 0x0008 373#define FW_STATE_DHCP_IN_PROGRESS 0x0008
369 374
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 1b221ff0f6f7..2122967bbf0b 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -8,6 +8,7 @@
8#ifndef __QLA4x_GBL_H 8#ifndef __QLA4x_GBL_H
9#define __QLA4x_GBL_H 9#define __QLA4x_GBL_H
10 10
11int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a);
11int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port); 12int qla4xxx_send_tgts(struct scsi_qla_host *ha, char *ip, uint16_t port);
12int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb); 13int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb);
13int qla4xxx_initialize_adapter(struct scsi_qla_host * ha, 14int qla4xxx_initialize_adapter(struct scsi_qla_host * ha,
@@ -75,4 +76,4 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host * ha,
75extern int ql4xextended_error_logging; 76extern int ql4xextended_error_logging;
76extern int ql4xdiscoverywait; 77extern int ql4xdiscoverywait;
77extern int ql4xdontresethba; 78extern int ql4xdontresethba;
78#endif /* _QLA4x_GBL_H */ 79#endif /* _QLA4x_GBL_H */
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index bb3a1c11f44c..cc210f297a78 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -259,10 +259,16 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
259 "seconds expired= %d\n", ha->host_no, __func__, 259 "seconds expired= %d\n", ha->host_no, __func__,
260 ha->firmware_state, ha->addl_fw_state, 260 ha->firmware_state, ha->addl_fw_state,
261 timeout_count)); 261 timeout_count));
262 if (is_qla4032(ha) &&
263 !(ha->addl_fw_state & FW_ADDSTATE_LINK_UP) &&
264 (timeout_count < ADAPTER_INIT_TOV - 5)) {
265 break;
266 }
267
262 msleep(1000); 268 msleep(1000);
263 } /* end of for */ 269 } /* end of for */
264 270
265 if (timeout_count <= 0) 271 if (timeout_count == 0)
266 DEBUG2(printk("scsi%ld: %s: FW Initialization timed out!\n", 272 DEBUG2(printk("scsi%ld: %s: FW Initialization timed out!\n",
267 ha->host_no, __func__)); 273 ha->host_no, __func__));
268 274
@@ -806,32 +812,6 @@ int qla4xxx_relogin_device(struct scsi_qla_host *ha,
806 return QLA_SUCCESS; 812 return QLA_SUCCESS;
807} 813}
808 814
809/**
810 * qla4010_get_topcat_presence - check if it is QLA4040 TopCat Chip
811 * @ha: Pointer to host adapter structure.
812 *
813 **/
814static int qla4010_get_topcat_presence(struct scsi_qla_host *ha)
815{
816 unsigned long flags;
817 uint16_t topcat;
818
819 if (ql4xxx_lock_nvram(ha) != QLA_SUCCESS)
820 return QLA_ERROR;
821 spin_lock_irqsave(&ha->hardware_lock, flags);
822 topcat = rd_nvram_word(ha, offsetof(struct eeprom_data,
823 isp4010.topcat));
824 spin_unlock_irqrestore(&ha->hardware_lock, flags);
825
826 if ((topcat & TOPCAT_MASK) == TOPCAT_PRESENT)
827 set_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags);
828 else
829 clear_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags);
830 ql4xxx_unlock_nvram(ha);
831 return QLA_SUCCESS;
832}
833
834
835static int qla4xxx_config_nvram(struct scsi_qla_host *ha) 815static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
836{ 816{
837 unsigned long flags; 817 unsigned long flags;
@@ -866,7 +846,7 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
866 /* set defaults */ 846 /* set defaults */
867 if (is_qla4010(ha)) 847 if (is_qla4010(ha))
868 extHwConfig.Asuint32_t = 0x1912; 848 extHwConfig.Asuint32_t = 0x1912;
869 else if (is_qla4022(ha)) 849 else if (is_qla4022(ha) | is_qla4032(ha))
870 extHwConfig.Asuint32_t = 0x0023; 850 extHwConfig.Asuint32_t = 0x0023;
871 } 851 }
872 DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n", 852 DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n",
@@ -927,7 +907,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
927 907
928 spin_lock_irqsave(&ha->hardware_lock, flags); 908 spin_lock_irqsave(&ha->hardware_lock, flags);
929 writel(jiffies, &ha->reg->mailbox[7]); 909 writel(jiffies, &ha->reg->mailbox[7]);
930 if (is_qla4022(ha)) 910 if (is_qla4022(ha) | is_qla4032(ha))
931 writel(set_rmask(NVR_WRITE_ENABLE), 911 writel(set_rmask(NVR_WRITE_ENABLE),
932 &ha->reg->u1.isp4022.nvram); 912 &ha->reg->u1.isp4022.nvram);
933 913
@@ -978,7 +958,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
978 return status; 958 return status;
979} 959}
980 960
981static int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a) 961int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
982{ 962{
983#define QL4_LOCK_DRVR_WAIT 300 963#define QL4_LOCK_DRVR_WAIT 300
984#define QL4_LOCK_DRVR_SLEEP 100 964#define QL4_LOCK_DRVR_SLEEP 100
@@ -1018,12 +998,7 @@ static int qla4xxx_start_firmware(struct scsi_qla_host *ha)
1018 int soft_reset = 1; 998 int soft_reset = 1;
1019 int config_chip = 0; 999 int config_chip = 0;
1020 1000
1021 if (is_qla4010(ha)){ 1001 if (is_qla4022(ha) | is_qla4032(ha))
1022 if (qla4010_get_topcat_presence(ha) != QLA_SUCCESS)
1023 return QLA_ERROR;
1024 }
1025
1026 if (is_qla4022(ha))
1027 ql4xxx_set_mac_number(ha); 1002 ql4xxx_set_mac_number(ha);
1028 1003
1029 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS) 1004 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS)
diff --git a/drivers/scsi/qla4xxx/ql4_inline.h b/drivers/scsi/qla4xxx/ql4_inline.h
index 0d61797af7da..6375eb017dd3 100644
--- a/drivers/scsi/qla4xxx/ql4_inline.h
+++ b/drivers/scsi/qla4xxx/ql4_inline.h
@@ -38,7 +38,7 @@ qla4xxx_lookup_ddb_by_fw_index(struct scsi_qla_host *ha, uint32_t fw_ddb_index)
38static inline void 38static inline void
39__qla4xxx_enable_intrs(struct scsi_qla_host *ha) 39__qla4xxx_enable_intrs(struct scsi_qla_host *ha)
40{ 40{
41 if (is_qla4022(ha)) { 41 if (is_qla4022(ha) | is_qla4032(ha)) {
42 writel(set_rmask(IMR_SCSI_INTR_ENABLE), 42 writel(set_rmask(IMR_SCSI_INTR_ENABLE),
43 &ha->reg->u1.isp4022.intr_mask); 43 &ha->reg->u1.isp4022.intr_mask);
44 readl(&ha->reg->u1.isp4022.intr_mask); 44 readl(&ha->reg->u1.isp4022.intr_mask);
@@ -52,7 +52,7 @@ __qla4xxx_enable_intrs(struct scsi_qla_host *ha)
52static inline void 52static inline void
53__qla4xxx_disable_intrs(struct scsi_qla_host *ha) 53__qla4xxx_disable_intrs(struct scsi_qla_host *ha)
54{ 54{
55 if (is_qla4022(ha)) { 55 if (is_qla4022(ha) | is_qla4032(ha)) {
56 writel(clr_rmask(IMR_SCSI_INTR_ENABLE), 56 writel(clr_rmask(IMR_SCSI_INTR_ENABLE),
57 &ha->reg->u1.isp4022.intr_mask); 57 &ha->reg->u1.isp4022.intr_mask);
58 readl(&ha->reg->u1.isp4022.intr_mask); 58 readl(&ha->reg->u1.isp4022.intr_mask);
diff --git a/drivers/scsi/qla4xxx/ql4_iocb.c b/drivers/scsi/qla4xxx/ql4_iocb.c
index c0a254b89a30..d41ce380eedc 100644
--- a/drivers/scsi/qla4xxx/ql4_iocb.c
+++ b/drivers/scsi/qla4xxx/ql4_iocb.c
@@ -294,6 +294,12 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
294 cmd_entry->control_flags = CF_WRITE; 294 cmd_entry->control_flags = CF_WRITE;
295 else if (cmd->sc_data_direction == DMA_FROM_DEVICE) 295 else if (cmd->sc_data_direction == DMA_FROM_DEVICE)
296 cmd_entry->control_flags = CF_READ; 296 cmd_entry->control_flags = CF_READ;
297
298 ha->bytes_xfered += cmd->request_bufflen;
299 if (ha->bytes_xfered & ~0xFFFFF){
300 ha->total_mbytes_xferred += ha->bytes_xfered >> 20;
301 ha->bytes_xfered &= 0xFFFFF;
302 }
297 } 303 }
298 304
299 /* Set tagged queueing control flags */ 305 /* Set tagged queueing control flags */
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index 1e283321a59d..ef975e0dc87f 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -627,6 +627,7 @@ irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
627 627
628 spin_lock_irqsave(&ha->hardware_lock, flags); 628 spin_lock_irqsave(&ha->hardware_lock, flags);
629 629
630 ha->isr_count++;
630 /* 631 /*
631 * Repeatedly service interrupts up to a maximum of 632 * Repeatedly service interrupts up to a maximum of
632 * MAX_REQS_SERVICED_PER_INTR 633 * MAX_REQS_SERVICED_PER_INTR
diff --git a/drivers/scsi/qla4xxx/ql4_nvram.c b/drivers/scsi/qla4xxx/ql4_nvram.c
index e3957ca5b645..58afd135aa1d 100644
--- a/drivers/scsi/qla4xxx/ql4_nvram.c
+++ b/drivers/scsi/qla4xxx/ql4_nvram.c
@@ -7,15 +7,22 @@
7 7
8#include "ql4_def.h" 8#include "ql4_def.h"
9 9
10static inline void eeprom_cmd(uint32_t cmd, struct scsi_qla_host *ha)
11{
12 writel(cmd, isp_nvram(ha));
13 readl(isp_nvram(ha));
14 udelay(1);
15}
16
10static inline int eeprom_size(struct scsi_qla_host *ha) 17static inline int eeprom_size(struct scsi_qla_host *ha)
11{ 18{
12 return is_qla4022(ha) ? FM93C86A_SIZE_16 : FM93C66A_SIZE_16; 19 return is_qla4010(ha) ? FM93C66A_SIZE_16 : FM93C86A_SIZE_16;
13} 20}
14 21
15static inline int eeprom_no_addr_bits(struct scsi_qla_host *ha) 22static inline int eeprom_no_addr_bits(struct scsi_qla_host *ha)
16{ 23{
17 return is_qla4022(ha) ? FM93C86A_NO_ADDR_BITS_16 : 24 return is_qla4010(ha) ? FM93C56A_NO_ADDR_BITS_16 :
18 FM93C56A_NO_ADDR_BITS_16; 25 FM93C86A_NO_ADDR_BITS_16 ;
19} 26}
20 27
21static inline int eeprom_no_data_bits(struct scsi_qla_host *ha) 28static inline int eeprom_no_data_bits(struct scsi_qla_host *ha)
@@ -28,8 +35,7 @@ static int fm93c56a_select(struct scsi_qla_host * ha)
28 DEBUG5(printk(KERN_ERR "fm93c56a_select:\n")); 35 DEBUG5(printk(KERN_ERR "fm93c56a_select:\n"));
29 36
30 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_1 | 0x000f0000; 37 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_1 | 0x000f0000;
31 writel(ha->eeprom_cmd_data, isp_nvram(ha)); 38 eeprom_cmd(ha->eeprom_cmd_data, ha);
32 readl(isp_nvram(ha));
33 return 1; 39 return 1;
34} 40}
35 41
@@ -41,12 +47,13 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
41 int previousBit; 47 int previousBit;
42 48
43 /* Clock in a zero, then do the start bit. */ 49 /* Clock in a zero, then do the start bit. */
44 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, isp_nvram(ha)); 50 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1, ha);
45 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 51
46 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 52 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
47 writel(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 | 53 AUBURN_EEPROM_CLK_RISE, ha);
48 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 54 eeprom_cmd(ha->eeprom_cmd_data | AUBURN_EEPROM_DO_1 |
49 readl(isp_nvram(ha)); 55 AUBURN_EEPROM_CLK_FALL, ha);
56
50 mask = 1 << (FM93C56A_CMD_BITS - 1); 57 mask = 1 << (FM93C56A_CMD_BITS - 1);
51 58
52 /* Force the previous data bit to be different. */ 59 /* Force the previous data bit to be different. */
@@ -60,14 +67,14 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
60 * If the bit changed, then change the DO state to 67 * If the bit changed, then change the DO state to
61 * match. 68 * match.
62 */ 69 */
63 writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 70 eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha);
64 previousBit = dataBit; 71 previousBit = dataBit;
65 } 72 }
66 writel(ha->eeprom_cmd_data | dataBit | 73 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
67 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 74 AUBURN_EEPROM_CLK_RISE, ha);
68 writel(ha->eeprom_cmd_data | dataBit | 75 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
69 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 76 AUBURN_EEPROM_CLK_FALL, ha);
70 readl(isp_nvram(ha)); 77
71 cmd = cmd << 1; 78 cmd = cmd << 1;
72 } 79 }
73 mask = 1 << (eeprom_no_addr_bits(ha) - 1); 80 mask = 1 << (eeprom_no_addr_bits(ha) - 1);
@@ -82,14 +89,15 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
82 * If the bit changed, then change the DO state to 89 * If the bit changed, then change the DO state to
83 * match. 90 * match.
84 */ 91 */
85 writel(ha->eeprom_cmd_data | dataBit, isp_nvram(ha)); 92 eeprom_cmd(ha->eeprom_cmd_data | dataBit, ha);
93
86 previousBit = dataBit; 94 previousBit = dataBit;
87 } 95 }
88 writel(ha->eeprom_cmd_data | dataBit | 96 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
89 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 97 AUBURN_EEPROM_CLK_RISE, ha);
90 writel(ha->eeprom_cmd_data | dataBit | 98 eeprom_cmd(ha->eeprom_cmd_data | dataBit |
91 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 99 AUBURN_EEPROM_CLK_FALL, ha);
92 readl(isp_nvram(ha)); 100
93 addr = addr << 1; 101 addr = addr << 1;
94 } 102 }
95 return 1; 103 return 1;
@@ -98,8 +106,7 @@ static int fm93c56a_cmd(struct scsi_qla_host * ha, int cmd, int addr)
98static int fm93c56a_deselect(struct scsi_qla_host * ha) 106static int fm93c56a_deselect(struct scsi_qla_host * ha)
99{ 107{
100 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_0 | 0x000f0000; 108 ha->eeprom_cmd_data = AUBURN_EEPROM_CS_0 | 0x000f0000;
101 writel(ha->eeprom_cmd_data, isp_nvram(ha)); 109 eeprom_cmd(ha->eeprom_cmd_data, ha);
102 readl(isp_nvram(ha));
103 return 1; 110 return 1;
104} 111}
105 112
@@ -112,12 +119,13 @@ static int fm93c56a_datain(struct scsi_qla_host * ha, unsigned short *value)
112 /* Read the data bits 119 /* Read the data bits
113 * The first bit is a dummy. Clock right over it. */ 120 * The first bit is a dummy. Clock right over it. */
114 for (i = 0; i < eeprom_no_data_bits(ha); i++) { 121 for (i = 0; i < eeprom_no_data_bits(ha); i++) {
115 writel(ha->eeprom_cmd_data | 122 eeprom_cmd(ha->eeprom_cmd_data |
116 AUBURN_EEPROM_CLK_RISE, isp_nvram(ha)); 123 AUBURN_EEPROM_CLK_RISE, ha);
117 writel(ha->eeprom_cmd_data | 124 eeprom_cmd(ha->eeprom_cmd_data |
118 AUBURN_EEPROM_CLK_FALL, isp_nvram(ha)); 125 AUBURN_EEPROM_CLK_FALL, ha);
119 dataBit = 126
120 (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0; 127 dataBit = (readw(isp_nvram(ha)) & AUBURN_EEPROM_DI_1) ? 1 : 0;
128
121 data = (data << 1) | dataBit; 129 data = (data << 1) | dataBit;
122 } 130 }
123 131
diff --git a/drivers/scsi/qla4xxx/ql4_nvram.h b/drivers/scsi/qla4xxx/ql4_nvram.h
index 08e2aed8c6cc..b47b4fc59d83 100644
--- a/drivers/scsi/qla4xxx/ql4_nvram.h
+++ b/drivers/scsi/qla4xxx/ql4_nvram.h
@@ -134,9 +134,7 @@ struct eeprom_data {
134 u16 phyConfig; /* x36 */ 134 u16 phyConfig; /* x36 */
135#define PHY_CONFIG_PHY_ADDR_MASK 0x1f 135#define PHY_CONFIG_PHY_ADDR_MASK 0x1f
136#define PHY_CONFIG_ENABLE_FW_MANAGEMENT_MASK 0x20 136#define PHY_CONFIG_ENABLE_FW_MANAGEMENT_MASK 0x20
137 u16 topcat; /* x38 */ 137 u16 reserved_56; /* x38 */
138#define TOPCAT_PRESENT 0x0100
139#define TOPCAT_MASK 0xFF00
140 138
141#define EEPROM_UNUSED_1_SIZE 2 139#define EEPROM_UNUSED_1_SIZE 2
142 u8 unused_1[EEPROM_UNUSED_1_SIZE]; /* x3A */ 140 u8 unused_1[EEPROM_UNUSED_1_SIZE]; /* x3A */
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 5b8db6109536..969c9e431028 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -708,10 +708,10 @@ static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
708} 708}
709 709
710/** 710/**
711 * qla4010_soft_reset - performs soft reset. 711 * qla4xxx_soft_reset - performs soft reset.
712 * @ha: Pointer to host adapter structure. 712 * @ha: Pointer to host adapter structure.
713 **/ 713 **/
714static int qla4010_soft_reset(struct scsi_qla_host *ha) 714int qla4xxx_soft_reset(struct scsi_qla_host *ha)
715{ 715{
716 uint32_t max_wait_time; 716 uint32_t max_wait_time;
717 unsigned long flags = 0; 717 unsigned long flags = 0;
@@ -817,29 +817,6 @@ static int qla4010_soft_reset(struct scsi_qla_host *ha)
817} 817}
818 818
819/** 819/**
820 * qla4xxx_topcat_reset - performs hard reset of TopCat Chip.
821 * @ha: Pointer to host adapter structure.
822 **/
823static int qla4xxx_topcat_reset(struct scsi_qla_host *ha)
824{
825 unsigned long flags;
826
827 ql4xxx_lock_nvram(ha);
828 spin_lock_irqsave(&ha->hardware_lock, flags);
829 writel(set_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha));
830 readl(isp_gp_out(ha));
831 mdelay(1);
832
833 writel(clr_rmask(GPOR_TOPCAT_RESET), isp_gp_out(ha));
834 readl(isp_gp_out(ha));
835 spin_unlock_irqrestore(&ha->hardware_lock, flags);
836 mdelay(2523);
837
838 ql4xxx_unlock_nvram(ha);
839 return QLA_SUCCESS;
840}
841
842/**
843 * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S. 820 * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S.
844 * @ha: Pointer to host adapter structure. 821 * @ha: Pointer to host adapter structure.
845 * 822 *
@@ -867,26 +844,6 @@ static void qla4xxx_flush_active_srbs(struct scsi_qla_host *ha)
867} 844}
868 845
869/** 846/**
870 * qla4xxx_hard_reset - performs HBA Hard Reset
871 * @ha: Pointer to host adapter structure.
872 **/
873static int qla4xxx_hard_reset(struct scsi_qla_host *ha)
874{
875 /* The QLA4010 really doesn't have an equivalent to a hard reset */
876 qla4xxx_flush_active_srbs(ha);
877 if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) {
878 int status = QLA_ERROR;
879
880 if ((qla4010_soft_reset(ha) == QLA_SUCCESS) &&
881 (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) &&
882 (qla4010_soft_reset(ha) == QLA_SUCCESS))
883 status = QLA_SUCCESS;
884 return status;
885 } else
886 return qla4010_soft_reset(ha);
887}
888
889/**
890 * qla4xxx_recover_adapter - recovers adapter after a fatal error 847 * qla4xxx_recover_adapter - recovers adapter after a fatal error
891 * @ha: Pointer to host adapter structure. 848 * @ha: Pointer to host adapter structure.
892 * @renew_ddb_list: Indicates what to do with the adapter's ddb list 849 * @renew_ddb_list: Indicates what to do with the adapter's ddb list
@@ -919,18 +876,11 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
919 if (status == QLA_SUCCESS) { 876 if (status == QLA_SUCCESS) {
920 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 877 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n",
921 ha->host_no, __func__)); 878 ha->host_no, __func__));
922 status = qla4xxx_soft_reset(ha); 879 qla4xxx_flush_active_srbs(ha);
923 } 880 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
924 /* FIXMEkaren: Do we want to keep interrupts enabled and process 881 status = qla4xxx_soft_reset(ha);
925 AENs after soft reset */ 882 else
926 883 status = QLA_ERROR;
927 /* If firmware (SOFT) reset failed, or if all outstanding
928 * commands have not returned, then do a HARD reset.
929 */
930 if (status == QLA_ERROR) {
931 DEBUG2(printk("scsi%ld: %s - Performing hard reset..\n",
932 ha->host_no, __func__));
933 status = qla4xxx_hard_reset(ha);
934 } 884 }
935 885
936 /* Flush any pending ddb changed AENs */ 886 /* Flush any pending ddb changed AENs */
@@ -1011,18 +961,15 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
1011 * the mid-level tries to sleep when it reaches the driver threshold 961 * the mid-level tries to sleep when it reaches the driver threshold
1012 * "host->can_queue". This can cause a panic if we were in our interrupt code. 962 * "host->can_queue". This can cause a panic if we were in our interrupt code.
1013 **/ 963 **/
1014static void qla4xxx_do_dpc(void *data) 964static void qla4xxx_do_dpc(struct work_struct *work)
1015{ 965{
1016 struct scsi_qla_host *ha = (struct scsi_qla_host *) data; 966 struct scsi_qla_host *ha =
967 container_of(work, struct scsi_qla_host, dpc_work);
1017 struct ddb_entry *ddb_entry, *dtemp; 968 struct ddb_entry *ddb_entry, *dtemp;
1018 969
1019 DEBUG2(printk("scsi%ld: %s: DPC handler waking up.\n", 970 DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
1020 ha->host_no, __func__)); 971 "flags = 0x%08lx, dpc_flags = 0x%08lx\n",
1021 972 ha->host_no, __func__, ha->flags, ha->dpc_flags));
1022 DEBUG2(printk("scsi%ld: %s: ha->flags = 0x%08lx\n",
1023 ha->host_no, __func__, ha->flags));
1024 DEBUG2(printk("scsi%ld: %s: ha->dpc_flags = 0x%08lx\n",
1025 ha->host_no, __func__, ha->dpc_flags));
1026 973
1027 /* Initialization not yet finished. Don't do anything yet. */ 974 /* Initialization not yet finished. Don't do anything yet. */
1028 if (!test_bit(AF_INIT_DONE, &ha->flags)) 975 if (!test_bit(AF_INIT_DONE, &ha->flags))
@@ -1032,16 +979,8 @@ static void qla4xxx_do_dpc(void *data)
1032 test_bit(DPC_RESET_HA, &ha->dpc_flags) || 979 test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
1033 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || 980 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
1034 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) { 981 test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
1035 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) 982 if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
1036 /* 983 test_bit(DPC_RESET_HA, &ha->dpc_flags))
1037 * dg 09/23 Never initialize ddb list
1038 * once we up and running
1039 * qla4xxx_recover_adapter(ha,
1040 * REBUILD_DDB_LIST);
1041 */
1042 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1043
1044 if (test_bit(DPC_RESET_HA, &ha->dpc_flags))
1045 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST); 984 qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
1046 985
1047 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { 986 if (test_and_clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
@@ -1122,7 +1061,8 @@ static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
1122 destroy_workqueue(ha->dpc_thread); 1061 destroy_workqueue(ha->dpc_thread);
1123 1062
1124 /* Issue Soft Reset to put firmware in unknown state */ 1063 /* Issue Soft Reset to put firmware in unknown state */
1125 qla4xxx_soft_reset(ha); 1064 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
1065 qla4xxx_soft_reset(ha);
1126 1066
1127 /* Remove timer thread, if present */ 1067 /* Remove timer thread, if present */
1128 if (ha->timer_active) 1068 if (ha->timer_active)
@@ -1261,7 +1201,6 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1261 init_waitqueue_head(&ha->mailbox_wait_queue); 1201 init_waitqueue_head(&ha->mailbox_wait_queue);
1262 1202
1263 spin_lock_init(&ha->hardware_lock); 1203 spin_lock_init(&ha->hardware_lock);
1264 spin_lock_init(&ha->list_lock);
1265 1204
1266 /* Allocate dma buffers */ 1205 /* Allocate dma buffers */
1267 if (qla4xxx_mem_alloc(ha)) { 1206 if (qla4xxx_mem_alloc(ha)) {
@@ -1315,7 +1254,7 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
1315 ret = -ENODEV; 1254 ret = -ENODEV;
1316 goto probe_failed; 1255 goto probe_failed;
1317 } 1256 }
1318 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc, ha); 1257 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
1319 1258
1320 ret = request_irq(pdev->irq, qla4xxx_intr_handler, 1259 ret = request_irq(pdev->irq, qla4xxx_intr_handler,
1321 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha); 1260 SA_INTERRUPT|SA_SHIRQ, "qla4xxx", ha);
@@ -1468,27 +1407,6 @@ struct srb * qla4xxx_del_from_active_array(struct scsi_qla_host *ha, uint32_t in
1468} 1407}
1469 1408
1470/** 1409/**
1471 * qla4xxx_soft_reset - performs a SOFT RESET of hba.
1472 * @ha: Pointer to host adapter structure.
1473 **/
1474int qla4xxx_soft_reset(struct scsi_qla_host *ha)
1475{
1476
1477 DEBUG2(printk(KERN_WARNING "scsi%ld: %s: chip reset!\n", ha->host_no,
1478 __func__));
1479 if (test_bit(AF_TOPCAT_CHIP_PRESENT, &ha->flags)) {
1480 int status = QLA_ERROR;
1481
1482 if ((qla4010_soft_reset(ha) == QLA_SUCCESS) &&
1483 (qla4xxx_topcat_reset(ha) == QLA_SUCCESS) &&
1484 (qla4010_soft_reset(ha) == QLA_SUCCESS) )
1485 status = QLA_SUCCESS;
1486 return status;
1487 } else
1488 return qla4010_soft_reset(ha);
1489}
1490
1491/**
1492 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware 1410 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
1493 * @ha: actual ha whose done queue will contain the comd returned by firmware. 1411 * @ha: actual ha whose done queue will contain the comd returned by firmware.
1494 * @cmd: Scsi Command to wait on. 1412 * @cmd: Scsi Command to wait on.
@@ -1686,6 +1604,12 @@ static struct pci_device_id qla4xxx_pci_tbl[] = {
1686 .subvendor = PCI_ANY_ID, 1604 .subvendor = PCI_ANY_ID,
1687 .subdevice = PCI_ANY_ID, 1605 .subdevice = PCI_ANY_ID,
1688 }, 1606 },
1607 {
1608 .vendor = PCI_VENDOR_ID_QLOGIC,
1609 .device = PCI_DEVICE_ID_QLOGIC_ISP4032,
1610 .subvendor = PCI_ANY_ID,
1611 .subdevice = PCI_ANY_ID,
1612 },
1689 {0, 0}, 1613 {0, 0},
1690}; 1614};
1691MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl); 1615MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl);
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index b3fe7e68988e..454e19c8ad68 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,9 +5,4 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7 7
8#define QLA4XXX_DRIVER_VERSION "5.00.05b9-k" 8#define QLA4XXX_DRIVER_VERSION "5.00.07-k"
9
10#define QL4_DRIVER_MAJOR_VER 5
11#define QL4_DRIVER_MINOR_VER 0
12#define QL4_DRIVER_PATCH_VER 5
13#define QL4_DRIVER_BETA_VER 9
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index c59f31533ab4..fafc00deaade 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -156,8 +156,7 @@ static struct scsi_host_cmd_pool scsi_cmd_dma_pool = {
156 156
157static DEFINE_MUTEX(host_cmd_pool_mutex); 157static DEFINE_MUTEX(host_cmd_pool_mutex);
158 158
159static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, 159struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost, gfp_t gfp_mask)
160 gfp_t gfp_mask)
161{ 160{
162 struct scsi_cmnd *cmd; 161 struct scsi_cmnd *cmd;
163 162
@@ -178,6 +177,7 @@ static struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *shost,
178 177
179 return cmd; 178 return cmd;
180} 179}
180EXPORT_SYMBOL_GPL(__scsi_get_command);
181 181
182/* 182/*
183 * Function: scsi_get_command() 183 * Function: scsi_get_command()
@@ -214,9 +214,29 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
214 put_device(&dev->sdev_gendev); 214 put_device(&dev->sdev_gendev);
215 215
216 return cmd; 216 return cmd;
217} 217}
218EXPORT_SYMBOL(scsi_get_command); 218EXPORT_SYMBOL(scsi_get_command);
219 219
220void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd,
221 struct device *dev)
222{
223 unsigned long flags;
224
225 /* changing locks here, don't need to restore the irq state */
226 spin_lock_irqsave(&shost->free_list_lock, flags);
227 if (unlikely(list_empty(&shost->free_list))) {
228 list_add(&cmd->list, &shost->free_list);
229 cmd = NULL;
230 }
231 spin_unlock_irqrestore(&shost->free_list_lock, flags);
232
233 if (likely(cmd != NULL))
234 kmem_cache_free(shost->cmd_pool->slab, cmd);
235
236 put_device(dev);
237}
238EXPORT_SYMBOL(__scsi_put_command);
239
220/* 240/*
221 * Function: scsi_put_command() 241 * Function: scsi_put_command()
222 * 242 *
@@ -231,26 +251,15 @@ EXPORT_SYMBOL(scsi_get_command);
231void scsi_put_command(struct scsi_cmnd *cmd) 251void scsi_put_command(struct scsi_cmnd *cmd)
232{ 252{
233 struct scsi_device *sdev = cmd->device; 253 struct scsi_device *sdev = cmd->device;
234 struct Scsi_Host *shost = sdev->host;
235 unsigned long flags; 254 unsigned long flags;
236 255
237 /* serious error if the command hasn't come from a device list */ 256 /* serious error if the command hasn't come from a device list */
238 spin_lock_irqsave(&cmd->device->list_lock, flags); 257 spin_lock_irqsave(&cmd->device->list_lock, flags);
239 BUG_ON(list_empty(&cmd->list)); 258 BUG_ON(list_empty(&cmd->list));
240 list_del_init(&cmd->list); 259 list_del_init(&cmd->list);
241 spin_unlock(&cmd->device->list_lock); 260 spin_unlock_irqrestore(&cmd->device->list_lock, flags);
242 /* changing locks here, don't need to restore the irq state */
243 spin_lock(&shost->free_list_lock);
244 if (unlikely(list_empty(&shost->free_list))) {
245 list_add(&cmd->list, &shost->free_list);
246 cmd = NULL;
247 }
248 spin_unlock_irqrestore(&shost->free_list_lock, flags);
249
250 if (likely(cmd != NULL))
251 kmem_cache_free(shost->cmd_pool->slab, cmd);
252 261
253 put_device(&sdev->sdev_gendev); 262 __scsi_put_command(cmd->device->host, cmd, &sdev->sdev_gendev);
254} 263}
255EXPORT_SYMBOL(scsi_put_command); 264EXPORT_SYMBOL(scsi_put_command);
256 265
@@ -871,9 +880,9 @@ EXPORT_SYMBOL(scsi_device_get);
871 */ 880 */
872void scsi_device_put(struct scsi_device *sdev) 881void scsi_device_put(struct scsi_device *sdev)
873{ 882{
883#ifdef CONFIG_MODULE_UNLOAD
874 struct module *module = sdev->host->hostt->module; 884 struct module *module = sdev->host->hostt->module;
875 885
876#ifdef CONFIG_MODULE_UNLOAD
877 /* The module refcount will be zero if scsi_device_get() 886 /* The module refcount will be zero if scsi_device_get()
878 * was called from a module removal routine */ 887 * was called from a module removal routine */
879 if (module && module_refcount(module) != 0) 888 if (module && module_refcount(module) != 0)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index aff1b0cfd4b2..2ecb6ff42444 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -453,9 +453,18 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
453} 453}
454 454
455/** 455/**
456 * scsi_send_eh_cmnd - send a cmd to a device as part of error recovery. 456 * scsi_send_eh_cmnd - submit a scsi command as part of error recory
457 * @scmd: SCSI Cmd to send. 457 * @scmd: SCSI command structure to hijack
458 * @timeout: Timeout for cmd. 458 * @cmnd: CDB to send
459 * @cmnd_size: size in bytes of @cmnd
460 * @timeout: timeout for this request
461 * @copy_sense: request sense data if set to 1
462 *
463 * This function is used to send a scsi command down to a target device
464 * as part of the error recovery process. If @copy_sense is 0 the command
465 * sent must be one that does not transfer any data. If @copy_sense is 1
466 * the command must be REQUEST_SENSE and this functions copies out the
467 * sense buffer it got into @scmd->sense_buffer.
459 * 468 *
460 * Return value: 469 * Return value:
461 * SUCCESS or FAILED or NEEDS_RETRY 470 * SUCCESS or FAILED or NEEDS_RETRY
@@ -469,6 +478,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
469 DECLARE_COMPLETION_ONSTACK(done); 478 DECLARE_COMPLETION_ONSTACK(done);
470 unsigned long timeleft; 479 unsigned long timeleft;
471 unsigned long flags; 480 unsigned long flags;
481 struct scatterlist sgl;
472 unsigned char old_cmnd[MAX_COMMAND_SIZE]; 482 unsigned char old_cmnd[MAX_COMMAND_SIZE];
473 enum dma_data_direction old_data_direction; 483 enum dma_data_direction old_data_direction;
474 unsigned short old_use_sg; 484 unsigned short old_use_sg;
@@ -500,19 +510,24 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
500 if (shost->hostt->unchecked_isa_dma) 510 if (shost->hostt->unchecked_isa_dma)
501 gfp_mask |= __GFP_DMA; 511 gfp_mask |= __GFP_DMA;
502 512
503 scmd->sc_data_direction = DMA_FROM_DEVICE; 513 sgl.page = alloc_page(gfp_mask);
504 scmd->request_bufflen = 252; 514 if (!sgl.page)
505 scmd->request_buffer = kzalloc(scmd->request_bufflen, gfp_mask);
506 if (!scmd->request_buffer)
507 return FAILED; 515 return FAILED;
516 sgl.offset = 0;
517 sgl.length = 252;
518
519 scmd->sc_data_direction = DMA_FROM_DEVICE;
520 scmd->request_bufflen = sgl.length;
521 scmd->request_buffer = &sgl;
522 scmd->use_sg = 1;
508 } else { 523 } else {
509 scmd->request_buffer = NULL; 524 scmd->request_buffer = NULL;
510 scmd->request_bufflen = 0; 525 scmd->request_bufflen = 0;
511 scmd->sc_data_direction = DMA_NONE; 526 scmd->sc_data_direction = DMA_NONE;
527 scmd->use_sg = 0;
512 } 528 }
513 529
514 scmd->underflow = 0; 530 scmd->underflow = 0;
515 scmd->use_sg = 0;
516 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]); 531 scmd->cmd_len = COMMAND_SIZE(scmd->cmnd[0]);
517 532
518 if (sdev->scsi_level <= SCSI_2) 533 if (sdev->scsi_level <= SCSI_2)
@@ -583,7 +598,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
583 memcpy(scmd->sense_buffer, scmd->request_buffer, 598 memcpy(scmd->sense_buffer, scmd->request_buffer,
584 sizeof(scmd->sense_buffer)); 599 sizeof(scmd->sense_buffer));
585 } 600 }
586 kfree(scmd->request_buffer); 601 __free_page(sgl.page);
587 } 602 }
588 603
589 604
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3ac4890ce086..fb616c69151f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -704,7 +704,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
704 return NULL; 704 return NULL;
705} 705}
706 706
707static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask) 707struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
708{ 708{
709 struct scsi_host_sg_pool *sgp; 709 struct scsi_host_sg_pool *sgp;
710 struct scatterlist *sgl; 710 struct scatterlist *sgl;
@@ -745,7 +745,9 @@ static struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_m
745 return sgl; 745 return sgl;
746} 746}
747 747
748static void scsi_free_sgtable(struct scatterlist *sgl, int index) 748EXPORT_SYMBOL(scsi_alloc_sgtable);
749
750void scsi_free_sgtable(struct scatterlist *sgl, int index)
749{ 751{
750 struct scsi_host_sg_pool *sgp; 752 struct scsi_host_sg_pool *sgp;
751 753
@@ -755,6 +757,8 @@ static void scsi_free_sgtable(struct scatterlist *sgl, int index)
755 mempool_free(sgl, sgp->pool); 757 mempool_free(sgl, sgp->pool);
756} 758}
757 759
760EXPORT_SYMBOL(scsi_free_sgtable);
761
758/* 762/*
759 * Function: scsi_release_buffers() 763 * Function: scsi_release_buffers()
760 * 764 *
@@ -996,25 +1000,14 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
996 int count; 1000 int count;
997 1001
998 /* 1002 /*
999 * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer 1003 * We used to not use scatter-gather for single segment request,
1000 */
1001 if (blk_pc_request(req) && !req->bio) {
1002 cmd->request_bufflen = req->data_len;
1003 cmd->request_buffer = req->data;
1004 req->buffer = req->data;
1005 cmd->use_sg = 0;
1006 return 0;
1007 }
1008
1009 /*
1010 * we used to not use scatter-gather for single segment request,
1011 * but now we do (it makes highmem I/O easier to support without 1004 * but now we do (it makes highmem I/O easier to support without
1012 * kmapping pages) 1005 * kmapping pages)
1013 */ 1006 */
1014 cmd->use_sg = req->nr_phys_segments; 1007 cmd->use_sg = req->nr_phys_segments;
1015 1008
1016 /* 1009 /*
1017 * if sg table allocation fails, requeue request later. 1010 * If sg table allocation fails, requeue request later.
1018 */ 1011 */
1019 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); 1012 sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC);
1020 if (unlikely(!sgpnt)) { 1013 if (unlikely(!sgpnt)) {
@@ -1022,24 +1015,21 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1022 return BLKPREP_DEFER; 1015 return BLKPREP_DEFER;
1023 } 1016 }
1024 1017
1018 req->buffer = NULL;
1025 cmd->request_buffer = (char *) sgpnt; 1019 cmd->request_buffer = (char *) sgpnt;
1026 cmd->request_bufflen = req->nr_sectors << 9;
1027 if (blk_pc_request(req)) 1020 if (blk_pc_request(req))
1028 cmd->request_bufflen = req->data_len; 1021 cmd->request_bufflen = req->data_len;
1029 req->buffer = NULL; 1022 else
1023 cmd->request_bufflen = req->nr_sectors << 9;
1030 1024
1031 /* 1025 /*
1032 * Next, walk the list, and fill in the addresses and sizes of 1026 * Next, walk the list, and fill in the addresses and sizes of
1033 * each segment. 1027 * each segment.
1034 */ 1028 */
1035 count = blk_rq_map_sg(req->q, req, cmd->request_buffer); 1029 count = blk_rq_map_sg(req->q, req, cmd->request_buffer);
1036
1037 /*
1038 * mapped well, send it off
1039 */
1040 if (likely(count <= cmd->use_sg)) { 1030 if (likely(count <= cmd->use_sg)) {
1041 cmd->use_sg = count; 1031 cmd->use_sg = count;
1042 return 0; 1032 return BLKPREP_OK;
1043 } 1033 }
1044 1034
1045 printk(KERN_ERR "Incorrect number of segments after building list\n"); 1035 printk(KERN_ERR "Incorrect number of segments after building list\n");
@@ -1069,6 +1059,27 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1069 return -EOPNOTSUPP; 1059 return -EOPNOTSUPP;
1070} 1060}
1071 1061
1062static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
1063 struct request *req)
1064{
1065 struct scsi_cmnd *cmd;
1066
1067 if (!req->special) {
1068 cmd = scsi_get_command(sdev, GFP_ATOMIC);
1069 if (unlikely(!cmd))
1070 return NULL;
1071 req->special = cmd;
1072 } else {
1073 cmd = req->special;
1074 }
1075
1076 /* pull a tag out of the request if we have one */
1077 cmd->tag = req->tag;
1078 cmd->request = req;
1079
1080 return cmd;
1081}
1082
1072static void scsi_blk_pc_done(struct scsi_cmnd *cmd) 1083static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
1073{ 1084{
1074 BUG_ON(!blk_pc_request(cmd->request)); 1085 BUG_ON(!blk_pc_request(cmd->request));
@@ -1081,9 +1092,37 @@ static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
1081 scsi_io_completion(cmd, cmd->request_bufflen); 1092 scsi_io_completion(cmd, cmd->request_bufflen);
1082} 1093}
1083 1094
1084static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd) 1095static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
1085{ 1096{
1086 struct request *req = cmd->request; 1097 struct scsi_cmnd *cmd;
1098
1099 cmd = scsi_get_cmd_from_req(sdev, req);
1100 if (unlikely(!cmd))
1101 return BLKPREP_DEFER;
1102
1103 /*
1104 * BLOCK_PC requests may transfer data, in which case they must
1105 * a bio attached to them. Or they might contain a SCSI command
1106 * that does not transfer data, in which case they may optionally
1107 * submit a request without an attached bio.
1108 */
1109 if (req->bio) {
1110 int ret;
1111
1112 BUG_ON(!req->nr_phys_segments);
1113
1114 ret = scsi_init_io(cmd);
1115 if (unlikely(ret))
1116 return ret;
1117 } else {
1118 BUG_ON(req->data_len);
1119 BUG_ON(req->data);
1120
1121 cmd->request_bufflen = 0;
1122 cmd->request_buffer = NULL;
1123 cmd->use_sg = 0;
1124 req->buffer = NULL;
1125 }
1087 1126
1088 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd)); 1127 BUILD_BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1089 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1128 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
@@ -1099,154 +1138,138 @@ static void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1099 cmd->allowed = req->retries; 1138 cmd->allowed = req->retries;
1100 cmd->timeout_per_command = req->timeout; 1139 cmd->timeout_per_command = req->timeout;
1101 cmd->done = scsi_blk_pc_done; 1140 cmd->done = scsi_blk_pc_done;
1141 return BLKPREP_OK;
1102} 1142}
1103 1143
1104static int scsi_prep_fn(struct request_queue *q, struct request *req) 1144/*
1145 * Setup a REQ_TYPE_FS command. These are simple read/write request
1146 * from filesystems that still need to be translated to SCSI CDBs from
1147 * the ULD.
1148 */
1149static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
1105{ 1150{
1106 struct scsi_device *sdev = q->queuedata;
1107 struct scsi_cmnd *cmd; 1151 struct scsi_cmnd *cmd;
1108 int specials_only = 0; 1152 struct scsi_driver *drv;
1153 int ret;
1109 1154
1110 /* 1155 /*
1111 * Just check to see if the device is online. If it isn't, we 1156 * Filesystem requests must transfer data.
1112 * refuse to process any commands. The device must be brought
1113 * online before trying any recovery commands
1114 */ 1157 */
1115 if (unlikely(!scsi_device_online(sdev))) { 1158 BUG_ON(!req->nr_phys_segments);
1116 sdev_printk(KERN_ERR, sdev, 1159
1117 "rejecting I/O to offline device\n"); 1160 cmd = scsi_get_cmd_from_req(sdev, req);
1118 goto kill; 1161 if (unlikely(!cmd))
1119 } 1162 return BLKPREP_DEFER;
1120 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { 1163
1121 /* OK, we're not in a running state don't prep 1164 ret = scsi_init_io(cmd);
1122 * user commands */ 1165 if (unlikely(ret))
1123 if (sdev->sdev_state == SDEV_DEL) { 1166 return ret;
1124 /* Device is fully deleted, no commands 1167
1125 * at all allowed down */ 1168 /*
1126 sdev_printk(KERN_ERR, sdev, 1169 * Initialize the actual SCSI command for this request.
1127 "rejecting I/O to dead device\n"); 1170 */
1128 goto kill; 1171 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1129 } 1172 if (unlikely(!drv->init_command(cmd))) {
1130 /* OK, we only allow special commands (i.e. not 1173 scsi_release_buffers(cmd);
1131 * user initiated ones */ 1174 scsi_put_command(cmd);
1132 specials_only = sdev->sdev_state; 1175 return BLKPREP_KILL;
1133 } 1176 }
1134 1177
1178 return BLKPREP_OK;
1179}
1180
1181static int scsi_prep_fn(struct request_queue *q, struct request *req)
1182{
1183 struct scsi_device *sdev = q->queuedata;
1184 int ret = BLKPREP_OK;
1185
1135 /* 1186 /*
1136 * Find the actual device driver associated with this command. 1187 * If the device is not in running state we will reject some
1137 * The SPECIAL requests are things like character device or 1188 * or all commands.
1138 * ioctls, which did not originate from ll_rw_blk. Note that
1139 * the special field is also used to indicate the cmd for
1140 * the remainder of a partially fulfilled request that can
1141 * come up when there is a medium error. We have to treat
1142 * these two cases differently. We differentiate by looking
1143 * at request->cmd, as this tells us the real story.
1144 */ 1189 */
1145 if (blk_special_request(req) && req->special) 1190 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
1146 cmd = req->special; 1191 switch (sdev->sdev_state) {
1147 else if (blk_pc_request(req) || blk_fs_request(req)) { 1192 case SDEV_OFFLINE:
1148 if (unlikely(specials_only) && !(req->cmd_flags & REQ_PREEMPT)){ 1193 /*
1149 if (specials_only == SDEV_QUIESCE || 1194 * If the device is offline we refuse to process any
1150 specials_only == SDEV_BLOCK) 1195 * commands. The device must be brought online
1151 goto defer; 1196 * before trying any recovery commands.
1152 1197 */
1153 sdev_printk(KERN_ERR, sdev, 1198 sdev_printk(KERN_ERR, sdev,
1154 "rejecting I/O to device being removed\n"); 1199 "rejecting I/O to offline device\n");
1155 goto kill; 1200 ret = BLKPREP_KILL;
1201 break;
1202 case SDEV_DEL:
1203 /*
1204 * If the device is fully deleted, we refuse to
1205 * process any commands as well.
1206 */
1207 sdev_printk(KERN_ERR, sdev,
1208 "rejecting I/O to dead device\n");
1209 ret = BLKPREP_KILL;
1210 break;
1211 case SDEV_QUIESCE:
1212 case SDEV_BLOCK:
1213 /*
1214 * If the devices is blocked we defer normal commands.
1215 */
1216 if (!(req->cmd_flags & REQ_PREEMPT))
1217 ret = BLKPREP_DEFER;
1218 break;
1219 default:
1220 /*
1221 * For any other not fully online state we only allow
1222 * special commands. In particular any user initiated
1223 * command is not allowed.
1224 */
1225 if (!(req->cmd_flags & REQ_PREEMPT))
1226 ret = BLKPREP_KILL;
1227 break;
1156 } 1228 }
1157 1229
1158 /* 1230 if (ret != BLKPREP_OK)
1159 * Now try and find a command block that we can use. 1231 goto out;
1160 */
1161 if (!req->special) {
1162 cmd = scsi_get_command(sdev, GFP_ATOMIC);
1163 if (unlikely(!cmd))
1164 goto defer;
1165 } else
1166 cmd = req->special;
1167
1168 /* pull a tag out of the request if we have one */
1169 cmd->tag = req->tag;
1170 } else {
1171 blk_dump_rq_flags(req, "SCSI bad req");
1172 goto kill;
1173 } 1232 }
1174
1175 /* note the overloading of req->special. When the tag
1176 * is active it always means cmd. If the tag goes
1177 * back for re-queueing, it may be reset */
1178 req->special = cmd;
1179 cmd->request = req;
1180
1181 /*
1182 * FIXME: drop the lock here because the functions below
1183 * expect to be called without the queue lock held. Also,
1184 * previously, we dequeued the request before dropping the
1185 * lock. We hope REQ_STARTED prevents anything untoward from
1186 * happening now.
1187 */
1188 if (blk_fs_request(req) || blk_pc_request(req)) {
1189 int ret;
1190 1233
1234 switch (req->cmd_type) {
1235 case REQ_TYPE_BLOCK_PC:
1236 ret = scsi_setup_blk_pc_cmnd(sdev, req);
1237 break;
1238 case REQ_TYPE_FS:
1239 ret = scsi_setup_fs_cmnd(sdev, req);
1240 break;
1241 default:
1191 /* 1242 /*
1192 * This will do a couple of things: 1243 * All other command types are not supported.
1193 * 1) Fill in the actual SCSI command.
1194 * 2) Fill in any other upper-level specific fields
1195 * (timeout).
1196 * 1244 *
1197 * If this returns 0, it means that the request failed 1245 * Note that these days the SCSI subsystem does not use
1198 * (reading past end of disk, reading offline device, 1246 * REQ_TYPE_SPECIAL requests anymore. These are only used
1199 * etc). This won't actually talk to the device, but 1247 * (directly or via blk_insert_request) by non-SCSI drivers.
1200 * some kinds of consistency checking may cause the
1201 * request to be rejected immediately.
1202 */ 1248 */
1249 blk_dump_rq_flags(req, "SCSI bad req");
1250 ret = BLKPREP_KILL;
1251 break;
1252 }
1203 1253
1204 /* 1254 out:
1205 * This sets up the scatter-gather table (allocating if 1255 switch (ret) {
1206 * required). 1256 case BLKPREP_KILL:
1207 */ 1257 req->errors = DID_NO_CONNECT << 16;
1208 ret = scsi_init_io(cmd); 1258 break;
1209 switch(ret) { 1259 case BLKPREP_DEFER:
1210 /* For BLKPREP_KILL/DEFER the cmd was released */
1211 case BLKPREP_KILL:
1212 goto kill;
1213 case BLKPREP_DEFER:
1214 goto defer;
1215 }
1216
1217 /* 1260 /*
1218 * Initialize the actual SCSI command for this request. 1261 * If we defer, the elv_next_request() returns NULL, but the
1262 * queue must be restarted, so we plug here if no returning
1263 * command will automatically do that.
1219 */ 1264 */
1220 if (blk_pc_request(req)) { 1265 if (sdev->device_busy == 0)
1221 scsi_setup_blk_pc_cmnd(cmd); 1266 blk_plug_device(q);
1222 } else if (req->rq_disk) { 1267 break;
1223 struct scsi_driver *drv; 1268 default:
1224 1269 req->cmd_flags |= REQ_DONTPREP;
1225 drv = *(struct scsi_driver **)req->rq_disk->private_data;
1226 if (unlikely(!drv->init_command(cmd))) {
1227 scsi_release_buffers(cmd);
1228 scsi_put_command(cmd);
1229 goto kill;
1230 }
1231 }
1232 } 1270 }
1233 1271
1234 /* 1272 return ret;
1235 * The request is now prepped, no need to come back here
1236 */
1237 req->cmd_flags |= REQ_DONTPREP;
1238 return BLKPREP_OK;
1239
1240 defer:
1241 /* If we defer, the elv_next_request() returns NULL, but the
1242 * queue must be restarted, so we plug here if no returning
1243 * command will automatically do that. */
1244 if (sdev->device_busy == 0)
1245 blk_plug_device(q);
1246 return BLKPREP_DEFER;
1247 kill:
1248 req->errors = DID_NO_CONNECT << 16;
1249 return BLKPREP_KILL;
1250} 1273}
1251 1274
1252/* 1275/*
@@ -1548,29 +1571,40 @@ u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)
1548} 1571}
1549EXPORT_SYMBOL(scsi_calculate_bounce_limit); 1572EXPORT_SYMBOL(scsi_calculate_bounce_limit);
1550 1573
1551struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) 1574struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
1575 request_fn_proc *request_fn)
1552{ 1576{
1553 struct Scsi_Host *shost = sdev->host;
1554 struct request_queue *q; 1577 struct request_queue *q;
1555 1578
1556 q = blk_init_queue(scsi_request_fn, NULL); 1579 q = blk_init_queue(request_fn, NULL);
1557 if (!q) 1580 if (!q)
1558 return NULL; 1581 return NULL;
1559 1582
1560 blk_queue_prep_rq(q, scsi_prep_fn);
1561
1562 blk_queue_max_hw_segments(q, shost->sg_tablesize); 1583 blk_queue_max_hw_segments(q, shost->sg_tablesize);
1563 blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS); 1584 blk_queue_max_phys_segments(q, SCSI_MAX_PHYS_SEGMENTS);
1564 blk_queue_max_sectors(q, shost->max_sectors); 1585 blk_queue_max_sectors(q, shost->max_sectors);
1565 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost)); 1586 blk_queue_bounce_limit(q, scsi_calculate_bounce_limit(shost));
1566 blk_queue_segment_boundary(q, shost->dma_boundary); 1587 blk_queue_segment_boundary(q, shost->dma_boundary);
1567 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1568 blk_queue_softirq_done(q, scsi_softirq_done);
1569 1588
1570 if (!shost->use_clustering) 1589 if (!shost->use_clustering)
1571 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 1590 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
1572 return q; 1591 return q;
1573} 1592}
1593EXPORT_SYMBOL(__scsi_alloc_queue);
1594
1595struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
1596{
1597 struct request_queue *q;
1598
1599 q = __scsi_alloc_queue(sdev->host, scsi_request_fn);
1600 if (!q)
1601 return NULL;
1602
1603 blk_queue_prep_rq(q, scsi_prep_fn);
1604 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1605 blk_queue_softirq_done(q, scsi_softirq_done);
1606 return q;
1607}
1574 1608
1575void scsi_free_queue(struct request_queue *q) 1609void scsi_free_queue(struct request_queue *q)
1576{ 1610{
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 5d023d44e5e7..f458c2f686d2 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -39,6 +39,9 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
39 { }; 39 { };
40#endif 40#endif
41 41
42/* scsi_scan.c */
43int scsi_complete_async_scans(void);
44
42/* scsi_devinfo.c */ 45/* scsi_devinfo.c */
43extern int scsi_get_device_flags(struct scsi_device *sdev, 46extern int scsi_get_device_flags(struct scsi_device *sdev,
44 const unsigned char *vendor, 47 const unsigned char *vendor,
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 94a274645f6f..14e635aa44ce 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -29,7 +29,9 @@
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/init.h> 30#include <linux/init.h>
31#include <linux/blkdev.h> 31#include <linux/blkdev.h>
32#include <asm/semaphore.h> 32#include <linux/delay.h>
33#include <linux/kthread.h>
34#include <linux/spinlock.h>
33 35
34#include <scsi/scsi.h> 36#include <scsi/scsi.h>
35#include <scsi/scsi_cmnd.h> 37#include <scsi/scsi_cmnd.h>
@@ -87,6 +89,17 @@ module_param_named(max_luns, max_scsi_luns, int, S_IRUGO|S_IWUSR);
87MODULE_PARM_DESC(max_luns, 89MODULE_PARM_DESC(max_luns,
88 "last scsi LUN (should be between 1 and 2^32-1)"); 90 "last scsi LUN (should be between 1 and 2^32-1)");
89 91
92#ifdef CONFIG_SCSI_SCAN_ASYNC
93#define SCSI_SCAN_TYPE_DEFAULT "async"
94#else
95#define SCSI_SCAN_TYPE_DEFAULT "sync"
96#endif
97
98static char scsi_scan_type[6] = SCSI_SCAN_TYPE_DEFAULT;
99
100module_param_string(scan, scsi_scan_type, sizeof(scsi_scan_type), S_IRUGO);
101MODULE_PARM_DESC(scan, "sync, async or none");
102
90/* 103/*
91 * max_scsi_report_luns: the maximum number of LUNS that will be 104 * max_scsi_report_luns: the maximum number of LUNS that will be
92 * returned from the REPORT LUNS command. 8 times this value must 105 * returned from the REPORT LUNS command. 8 times this value must
@@ -108,6 +121,68 @@ MODULE_PARM_DESC(inq_timeout,
108 "Timeout (in seconds) waiting for devices to answer INQUIRY." 121 "Timeout (in seconds) waiting for devices to answer INQUIRY."
109 " Default is 5. Some non-compliant devices need more."); 122 " Default is 5. Some non-compliant devices need more.");
110 123
124static DEFINE_SPINLOCK(async_scan_lock);
125static LIST_HEAD(scanning_hosts);
126
127struct async_scan_data {
128 struct list_head list;
129 struct Scsi_Host *shost;
130 struct completion prev_finished;
131};
132
133/**
134 * scsi_complete_async_scans - Wait for asynchronous scans to complete
135 *
136 * Asynchronous scans add themselves to the scanning_hosts list. Once
137 * that list is empty, we know that the scans are complete. Rather than
138 * waking up periodically to check the state of the list, we pretend to be
139 * a scanning task by adding ourselves at the end of the list and going to
140 * sleep. When the task before us wakes us up, we take ourselves off the
141 * list and return.
142 */
143int scsi_complete_async_scans(void)
144{
145 struct async_scan_data *data;
146
147 do {
148 if (list_empty(&scanning_hosts))
149 return 0;
150 /* If we can't get memory immediately, that's OK. Just
151 * sleep a little. Even if we never get memory, the async
152 * scans will finish eventually.
153 */
154 data = kmalloc(sizeof(*data), GFP_KERNEL);
155 if (!data)
156 msleep(1);
157 } while (!data);
158
159 data->shost = NULL;
160 init_completion(&data->prev_finished);
161
162 spin_lock(&async_scan_lock);
163 /* Check that there's still somebody else on the list */
164 if (list_empty(&scanning_hosts))
165 goto done;
166 list_add_tail(&data->list, &scanning_hosts);
167 spin_unlock(&async_scan_lock);
168
169 printk(KERN_INFO "scsi: waiting for bus probes to complete ...\n");
170 wait_for_completion(&data->prev_finished);
171
172 spin_lock(&async_scan_lock);
173 list_del(&data->list);
174 done:
175 spin_unlock(&async_scan_lock);
176
177 kfree(data);
178 return 0;
179}
180
181#ifdef MODULE
182/* Only exported for the benefit of scsi_wait_scan */
183EXPORT_SYMBOL_GPL(scsi_complete_async_scans);
184#endif
185
111/** 186/**
112 * scsi_unlock_floptical - unlock device via a special MODE SENSE command 187 * scsi_unlock_floptical - unlock device via a special MODE SENSE command
113 * @sdev: scsi device to send command to 188 * @sdev: scsi device to send command to
@@ -362,9 +437,10 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
362 goto retry; 437 goto retry;
363} 438}
364 439
365static void scsi_target_reap_usercontext(void *data) 440static void scsi_target_reap_usercontext(struct work_struct *work)
366{ 441{
367 struct scsi_target *starget = data; 442 struct scsi_target *starget =
443 container_of(work, struct scsi_target, ew.work);
368 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 444 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
369 unsigned long flags; 445 unsigned long flags;
370 446
@@ -400,7 +476,7 @@ void scsi_target_reap(struct scsi_target *starget)
400 starget->state = STARGET_DEL; 476 starget->state = STARGET_DEL;
401 spin_unlock_irqrestore(shost->host_lock, flags); 477 spin_unlock_irqrestore(shost->host_lock, flags);
402 execute_in_process_context(scsi_target_reap_usercontext, 478 execute_in_process_context(scsi_target_reap_usercontext,
403 starget, &starget->ew); 479 &starget->ew);
404 return; 480 return;
405 481
406 } 482 }
@@ -619,7 +695,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,
619 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized 695 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
620 **/ 696 **/
621static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, 697static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
622 int *bflags) 698 int *bflags, int async)
623{ 699{
624 /* 700 /*
625 * XXX do not save the inquiry, since it can change underneath us, 701 * XXX do not save the inquiry, since it can change underneath us,
@@ -805,7 +881,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
805 * register it and tell the rest of the kernel 881 * register it and tell the rest of the kernel
806 * about it. 882 * about it.
807 */ 883 */
808 if (scsi_sysfs_add_sdev(sdev) != 0) 884 if (!async && scsi_sysfs_add_sdev(sdev) != 0)
809 return SCSI_SCAN_NO_RESPONSE; 885 return SCSI_SCAN_NO_RESPONSE;
810 886
811 return SCSI_SCAN_LUN_PRESENT; 887 return SCSI_SCAN_LUN_PRESENT;
@@ -974,7 +1050,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
974 goto out_free_result; 1050 goto out_free_result;
975 } 1051 }
976 1052
977 res = scsi_add_lun(sdev, result, &bflags); 1053 res = scsi_add_lun(sdev, result, &bflags, shost->async_scan);
978 if (res == SCSI_SCAN_LUN_PRESENT) { 1054 if (res == SCSI_SCAN_LUN_PRESENT) {
979 if (bflags & BLIST_KEY) { 1055 if (bflags & BLIST_KEY) {
980 sdev->lockable = 0; 1056 sdev->lockable = 0;
@@ -1474,6 +1550,12 @@ void scsi_scan_target(struct device *parent, unsigned int channel,
1474{ 1550{
1475 struct Scsi_Host *shost = dev_to_shost(parent); 1551 struct Scsi_Host *shost = dev_to_shost(parent);
1476 1552
1553 if (strncmp(scsi_scan_type, "none", 4) == 0)
1554 return;
1555
1556 if (!shost->async_scan)
1557 scsi_complete_async_scans();
1558
1477 mutex_lock(&shost->scan_mutex); 1559 mutex_lock(&shost->scan_mutex);
1478 if (scsi_host_scan_allowed(shost)) 1560 if (scsi_host_scan_allowed(shost))
1479 __scsi_scan_target(parent, channel, id, lun, rescan); 1561 __scsi_scan_target(parent, channel, id, lun, rescan);
@@ -1519,6 +1601,9 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1519 "%s: <%u:%u:%u>\n", 1601 "%s: <%u:%u:%u>\n",
1520 __FUNCTION__, channel, id, lun)); 1602 __FUNCTION__, channel, id, lun));
1521 1603
1604 if (!shost->async_scan)
1605 scsi_complete_async_scans();
1606
1522 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) || 1607 if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
1523 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) || 1608 ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
1524 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) 1609 ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
@@ -1539,14 +1624,143 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
1539 return 0; 1624 return 0;
1540} 1625}
1541 1626
1627static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
1628{
1629 struct scsi_device *sdev;
1630 shost_for_each_device(sdev, shost) {
1631 if (scsi_sysfs_add_sdev(sdev) != 0)
1632 scsi_destroy_sdev(sdev);
1633 }
1634}
1635
1636/**
1637 * scsi_prep_async_scan - prepare for an async scan
1638 * @shost: the host which will be scanned
1639 * Returns: a cookie to be passed to scsi_finish_async_scan()
1640 *
1641 * Tells the midlayer this host is going to do an asynchronous scan.
1642 * It reserves the host's position in the scanning list and ensures
1643 * that other asynchronous scans started after this one won't affect the
1644 * ordering of the discovered devices.
1645 */
1646static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
1647{
1648 struct async_scan_data *data;
1649
1650 if (strncmp(scsi_scan_type, "sync", 4) == 0)
1651 return NULL;
1652
1653 if (shost->async_scan) {
1654 printk("%s called twice for host %d", __FUNCTION__,
1655 shost->host_no);
1656 dump_stack();
1657 return NULL;
1658 }
1659
1660 data = kmalloc(sizeof(*data), GFP_KERNEL);
1661 if (!data)
1662 goto err;
1663 data->shost = scsi_host_get(shost);
1664 if (!data->shost)
1665 goto err;
1666 init_completion(&data->prev_finished);
1667
1668 spin_lock(&async_scan_lock);
1669 shost->async_scan = 1;
1670 if (list_empty(&scanning_hosts))
1671 complete(&data->prev_finished);
1672 list_add_tail(&data->list, &scanning_hosts);
1673 spin_unlock(&async_scan_lock);
1674
1675 return data;
1676
1677 err:
1678 kfree(data);
1679 return NULL;
1680}
1681
1682/**
1683 * scsi_finish_async_scan - asynchronous scan has finished
1684 * @data: cookie returned from earlier call to scsi_prep_async_scan()
1685 *
1686 * All the devices currently attached to this host have been found.
1687 * This function announces all the devices it has found to the rest
1688 * of the system.
1689 */
1690static void scsi_finish_async_scan(struct async_scan_data *data)
1691{
1692 struct Scsi_Host *shost;
1693
1694 if (!data)
1695 return;
1696
1697 shost = data->shost;
1698 if (!shost->async_scan) {
1699 printk("%s called twice for host %d", __FUNCTION__,
1700 shost->host_no);
1701 dump_stack();
1702 return;
1703 }
1704
1705 wait_for_completion(&data->prev_finished);
1706
1707 scsi_sysfs_add_devices(shost);
1708
1709 spin_lock(&async_scan_lock);
1710 shost->async_scan = 0;
1711 list_del(&data->list);
1712 if (!list_empty(&scanning_hosts)) {
1713 struct async_scan_data *next = list_entry(scanning_hosts.next,
1714 struct async_scan_data, list);
1715 complete(&next->prev_finished);
1716 }
1717 spin_unlock(&async_scan_lock);
1718
1719 scsi_host_put(shost);
1720 kfree(data);
1721}
1722
1723static void do_scsi_scan_host(struct Scsi_Host *shost)
1724{
1725 if (shost->hostt->scan_finished) {
1726 unsigned long start = jiffies;
1727 if (shost->hostt->scan_start)
1728 shost->hostt->scan_start(shost);
1729
1730 while (!shost->hostt->scan_finished(shost, jiffies - start))
1731 msleep(10);
1732 } else {
1733 scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD,
1734 SCAN_WILD_CARD, 0);
1735 }
1736}
1737
1738static int do_scan_async(void *_data)
1739{
1740 struct async_scan_data *data = _data;
1741 do_scsi_scan_host(data->shost);
1742 scsi_finish_async_scan(data);
1743 return 0;
1744}
1745
1542/** 1746/**
1543 * scsi_scan_host - scan the given adapter 1747 * scsi_scan_host - scan the given adapter
1544 * @shost: adapter to scan 1748 * @shost: adapter to scan
1545 **/ 1749 **/
1546void scsi_scan_host(struct Scsi_Host *shost) 1750void scsi_scan_host(struct Scsi_Host *shost)
1547{ 1751{
1548 scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, 1752 struct async_scan_data *data;
1549 SCAN_WILD_CARD, 0); 1753
1754 if (strncmp(scsi_scan_type, "none", 4) == 0)
1755 return;
1756
1757 data = scsi_prep_async_scan(shost);
1758 if (!data) {
1759 do_scsi_scan_host(shost);
1760 return;
1761 }
1762
1763 kthread_run(do_scan_async, data, "scsi_scan_%d", shost->host_no);
1550} 1764}
1551EXPORT_SYMBOL(scsi_scan_host); 1765EXPORT_SYMBOL(scsi_scan_host);
1552 1766
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index e1a91665d1c2..259c90cfa367 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -218,16 +218,16 @@ static void scsi_device_cls_release(struct class_device *class_dev)
218 put_device(&sdev->sdev_gendev); 218 put_device(&sdev->sdev_gendev);
219} 219}
220 220
221static void scsi_device_dev_release_usercontext(void *data) 221static void scsi_device_dev_release_usercontext(struct work_struct *work)
222{ 222{
223 struct device *dev = data;
224 struct scsi_device *sdev; 223 struct scsi_device *sdev;
225 struct device *parent; 224 struct device *parent;
226 struct scsi_target *starget; 225 struct scsi_target *starget;
227 unsigned long flags; 226 unsigned long flags;
228 227
229 parent = dev->parent; 228 sdev = container_of(work, struct scsi_device, ew.work);
230 sdev = to_scsi_device(dev); 229
230 parent = sdev->sdev_gendev.parent;
231 starget = to_scsi_target(parent); 231 starget = to_scsi_target(parent);
232 232
233 spin_lock_irqsave(sdev->host->host_lock, flags); 233 spin_lock_irqsave(sdev->host->host_lock, flags);
@@ -258,7 +258,7 @@ static void scsi_device_dev_release_usercontext(void *data)
258static void scsi_device_dev_release(struct device *dev) 258static void scsi_device_dev_release(struct device *dev)
259{ 259{
260 struct scsi_device *sdp = to_scsi_device(dev); 260 struct scsi_device *sdp = to_scsi_device(dev);
261 execute_in_process_context(scsi_device_dev_release_usercontext, dev, 261 execute_in_process_context(scsi_device_dev_release_usercontext,
262 &sdp->ew); 262 &sdp->ew);
263} 263}
264 264
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c
new file mode 100644
index 000000000000..37bbfbdb870f
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_if.c
@@ -0,0 +1,352 @@
1/*
2 * SCSI target kernel/user interface functions
3 *
4 * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
5 * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/miscdevice.h>
23#include <linux/file.h>
24#include <net/tcp.h>
25#include <scsi/scsi.h>
26#include <scsi/scsi_cmnd.h>
27#include <scsi/scsi_device.h>
28#include <scsi/scsi_host.h>
29#include <scsi/scsi_tgt.h>
30#include <scsi/scsi_tgt_if.h>
31
32#include <asm/cacheflush.h>
33
34#include "scsi_tgt_priv.h"
35
36struct tgt_ring {
37 u32 tr_idx;
38 unsigned long tr_pages[TGT_RING_PAGES];
39 spinlock_t tr_lock;
40};
41
42/* tx_ring : kernel->user, rx_ring : user->kernel */
43static struct tgt_ring tx_ring, rx_ring;
44static DECLARE_WAIT_QUEUE_HEAD(tgt_poll_wait);
45
46static inline void tgt_ring_idx_inc(struct tgt_ring *ring)
47{
48 if (ring->tr_idx == TGT_MAX_EVENTS - 1)
49 ring->tr_idx = 0;
50 else
51 ring->tr_idx++;
52}
53
54static struct tgt_event *tgt_head_event(struct tgt_ring *ring, u32 idx)
55{
56 u32 pidx, off;
57
58 pidx = idx / TGT_EVENT_PER_PAGE;
59 off = idx % TGT_EVENT_PER_PAGE;
60
61 return (struct tgt_event *)
62 (ring->tr_pages[pidx] + sizeof(struct tgt_event) * off);
63}
64
65static int tgt_uspace_send_event(u32 type, struct tgt_event *p)
66{
67 struct tgt_event *ev;
68 struct tgt_ring *ring = &tx_ring;
69 unsigned long flags;
70 int err = 0;
71
72 spin_lock_irqsave(&ring->tr_lock, flags);
73
74 ev = tgt_head_event(ring, ring->tr_idx);
75 if (!ev->hdr.status)
76 tgt_ring_idx_inc(ring);
77 else
78 err = -BUSY;
79
80 spin_unlock_irqrestore(&ring->tr_lock, flags);
81
82 if (err)
83 return err;
84
85 memcpy(ev, p, sizeof(*ev));
86 ev->hdr.type = type;
87 mb();
88 ev->hdr.status = 1;
89
90 flush_dcache_page(virt_to_page(ev));
91
92 wake_up_interruptible(&tgt_poll_wait);
93
94 return 0;
95}
96
97int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun, u64 tag)
98{
99 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
100 struct tgt_event ev;
101 int err;
102
103 memset(&ev, 0, sizeof(ev));
104 ev.p.cmd_req.host_no = shost->host_no;
105 ev.p.cmd_req.data_len = cmd->request_bufflen;
106 memcpy(ev.p.cmd_req.scb, cmd->cmnd, sizeof(ev.p.cmd_req.scb));
107 memcpy(ev.p.cmd_req.lun, lun, sizeof(ev.p.cmd_req.lun));
108 ev.p.cmd_req.attribute = cmd->tag;
109 ev.p.cmd_req.tag = tag;
110
111 dprintk("%p %d %u %x %llx\n", cmd, shost->host_no,
112 ev.p.cmd_req.data_len, cmd->tag,
113 (unsigned long long) ev.p.cmd_req.tag);
114
115 err = tgt_uspace_send_event(TGT_KEVENT_CMD_REQ, &ev);
116 if (err)
117 eprintk("tx buf is full, could not send\n");
118
119 return err;
120}
121
122int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag)
123{
124 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
125 struct tgt_event ev;
126 int err;
127
128 memset(&ev, 0, sizeof(ev));
129 ev.p.cmd_done.host_no = shost->host_no;
130 ev.p.cmd_done.tag = tag;
131 ev.p.cmd_done.result = cmd->result;
132
133 dprintk("%p %d %llu %u %x\n", cmd, shost->host_no,
134 (unsigned long long) ev.p.cmd_req.tag,
135 ev.p.cmd_req.data_len, cmd->tag);
136
137 err = tgt_uspace_send_event(TGT_KEVENT_CMD_DONE, &ev);
138 if (err)
139 eprintk("tx buf is full, could not send\n");
140
141 return err;
142}
143
144int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
145 struct scsi_lun *scsilun, void *data)
146{
147 struct tgt_event ev;
148 int err;
149
150 memset(&ev, 0, sizeof(ev));
151 ev.p.tsk_mgmt_req.host_no = host_no;
152 ev.p.tsk_mgmt_req.function = function;
153 ev.p.tsk_mgmt_req.tag = tag;
154 memcpy(ev.p.tsk_mgmt_req.lun, scsilun, sizeof(ev.p.tsk_mgmt_req.lun));
155 ev.p.tsk_mgmt_req.mid = (u64) (unsigned long) data;
156
157 dprintk("%d %x %llx %llx\n", host_no, function, (unsigned long long) tag,
158 (unsigned long long) ev.p.tsk_mgmt_req.mid);
159
160 err = tgt_uspace_send_event(TGT_KEVENT_TSK_MGMT_REQ, &ev);
161 if (err)
162 eprintk("tx buf is full, could not send\n");
163
164 return err;
165}
166
167static int event_recv_msg(struct tgt_event *ev)
168{
169 int err = 0;
170
171 switch (ev->hdr.type) {
172 case TGT_UEVENT_CMD_RSP:
173 err = scsi_tgt_kspace_exec(ev->p.cmd_rsp.host_no,
174 ev->p.cmd_rsp.tag,
175 ev->p.cmd_rsp.result,
176 ev->p.cmd_rsp.len,
177 ev->p.cmd_rsp.uaddr,
178 ev->p.cmd_rsp.rw);
179 break;
180 case TGT_UEVENT_TSK_MGMT_RSP:
181 err = scsi_tgt_kspace_tsk_mgmt(ev->p.tsk_mgmt_rsp.host_no,
182 ev->p.tsk_mgmt_rsp.mid,
183 ev->p.tsk_mgmt_rsp.result);
184 break;
185 default:
186 eprintk("unknown type %d\n", ev->hdr.type);
187 err = -EINVAL;
188 }
189
190 return err;
191}
192
193static ssize_t tgt_write(struct file *file, const char __user * buffer,
194 size_t count, loff_t * ppos)
195{
196 struct tgt_event *ev;
197 struct tgt_ring *ring = &rx_ring;
198
199 while (1) {
200 ev = tgt_head_event(ring, ring->tr_idx);
201 /* do we need this? */
202 flush_dcache_page(virt_to_page(ev));
203
204 if (!ev->hdr.status)
205 break;
206
207 tgt_ring_idx_inc(ring);
208 event_recv_msg(ev);
209 ev->hdr.status = 0;
210 };
211
212 return count;
213}
214
215static unsigned int tgt_poll(struct file * file, struct poll_table_struct *wait)
216{
217 struct tgt_event *ev;
218 struct tgt_ring *ring = &tx_ring;
219 unsigned long flags;
220 unsigned int mask = 0;
221 u32 idx;
222
223 poll_wait(file, &tgt_poll_wait, wait);
224
225 spin_lock_irqsave(&ring->tr_lock, flags);
226
227 idx = ring->tr_idx ? ring->tr_idx - 1 : TGT_MAX_EVENTS - 1;
228 ev = tgt_head_event(ring, idx);
229 if (ev->hdr.status)
230 mask |= POLLIN | POLLRDNORM;
231
232 spin_unlock_irqrestore(&ring->tr_lock, flags);
233
234 return mask;
235}
236
237static int uspace_ring_map(struct vm_area_struct *vma, unsigned long addr,
238 struct tgt_ring *ring)
239{
240 int i, err;
241
242 for (i = 0; i < TGT_RING_PAGES; i++) {
243 struct page *page = virt_to_page(ring->tr_pages[i]);
244 err = vm_insert_page(vma, addr, page);
245 if (err)
246 return err;
247 addr += PAGE_SIZE;
248 }
249
250 return 0;
251}
252
253static int tgt_mmap(struct file *filp, struct vm_area_struct *vma)
254{
255 unsigned long addr;
256 int err;
257
258 if (vma->vm_pgoff)
259 return -EINVAL;
260
261 if (vma->vm_end - vma->vm_start != TGT_RING_SIZE * 2) {
262 eprintk("mmap size must be %lu, not %lu \n",
263 TGT_RING_SIZE * 2, vma->vm_end - vma->vm_start);
264 return -EINVAL;
265 }
266
267 addr = vma->vm_start;
268 err = uspace_ring_map(vma, addr, &tx_ring);
269 if (err)
270 return err;
271 err = uspace_ring_map(vma, addr + TGT_RING_SIZE, &rx_ring);
272
273 return err;
274}
275
276static int tgt_open(struct inode *inode, struct file *file)
277{
278 tx_ring.tr_idx = rx_ring.tr_idx = 0;
279
280 return 0;
281}
282
283static struct file_operations tgt_fops = {
284 .owner = THIS_MODULE,
285 .open = tgt_open,
286 .poll = tgt_poll,
287 .write = tgt_write,
288 .mmap = tgt_mmap,
289};
290
291static struct miscdevice tgt_miscdev = {
292 .minor = MISC_DYNAMIC_MINOR,
293 .name = "tgt",
294 .fops = &tgt_fops,
295};
296
297static void tgt_ring_exit(struct tgt_ring *ring)
298{
299 int i;
300
301 for (i = 0; i < TGT_RING_PAGES; i++)
302 free_page(ring->tr_pages[i]);
303}
304
305static int tgt_ring_init(struct tgt_ring *ring)
306{
307 int i;
308
309 spin_lock_init(&ring->tr_lock);
310
311 for (i = 0; i < TGT_RING_PAGES; i++) {
312 ring->tr_pages[i] = get_zeroed_page(GFP_KERNEL);
313 if (!ring->tr_pages[i]) {
314 eprintk("out of memory\n");
315 return -ENOMEM;
316 }
317 }
318
319 return 0;
320}
321
322void scsi_tgt_if_exit(void)
323{
324 tgt_ring_exit(&tx_ring);
325 tgt_ring_exit(&rx_ring);
326 misc_deregister(&tgt_miscdev);
327}
328
329int scsi_tgt_if_init(void)
330{
331 int err;
332
333 err = tgt_ring_init(&tx_ring);
334 if (err)
335 return err;
336
337 err = tgt_ring_init(&rx_ring);
338 if (err)
339 goto free_tx_ring;
340
341 err = misc_register(&tgt_miscdev);
342 if (err)
343 goto free_rx_ring;
344
345 return 0;
346free_rx_ring:
347 tgt_ring_exit(&rx_ring);
348free_tx_ring:
349 tgt_ring_exit(&tx_ring);
350
351 return err;
352}
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
new file mode 100644
index 000000000000..386dbae17b44
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -0,0 +1,745 @@
1/*
2 * SCSI target lib functions
3 *
4 * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
5 * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#include <linux/blkdev.h>
23#include <linux/hash.h>
24#include <linux/module.h>
25#include <linux/pagemap.h>
26#include <scsi/scsi.h>
27#include <scsi/scsi_cmnd.h>
28#include <scsi/scsi_device.h>
29#include <scsi/scsi_host.h>
30#include <scsi/scsi_tgt.h>
31#include <../drivers/md/dm-bio-list.h>
32
33#include "scsi_tgt_priv.h"
34
35static struct workqueue_struct *scsi_tgtd;
36static kmem_cache_t *scsi_tgt_cmd_cache;
37
38/*
39 * TODO: this struct will be killed when the block layer supports large bios
40 * and James's work struct code is in
41 */
42struct scsi_tgt_cmd {
43 /* TODO replace work with James b's code */
44 struct work_struct work;
45 /* TODO replace the lists with a large bio */
46 struct bio_list xfer_done_list;
47 struct bio_list xfer_list;
48
49 struct list_head hash_list;
50 struct request *rq;
51 u64 tag;
52
53 void *buffer;
54 unsigned bufflen;
55};
56
57#define TGT_HASH_ORDER 4
58#define cmd_hashfn(tag) hash_long((unsigned long) (tag), TGT_HASH_ORDER)
59
60struct scsi_tgt_queuedata {
61 struct Scsi_Host *shost;
62 struct list_head cmd_hash[1 << TGT_HASH_ORDER];
63 spinlock_t cmd_hash_lock;
64};
65
66/*
67 * Function: scsi_host_get_command()
68 *
69 * Purpose: Allocate and setup a scsi command block and blk request
70 *
71 * Arguments: shost - scsi host
72 * data_dir - dma data dir
73 * gfp_mask- allocator flags
74 *
75 * Returns: The allocated scsi command structure.
76 *
77 * This should be called by target LLDs to get a command.
78 */
79struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *shost,
80 enum dma_data_direction data_dir,
81 gfp_t gfp_mask)
82{
83 int write = (data_dir == DMA_TO_DEVICE);
84 struct request *rq;
85 struct scsi_cmnd *cmd;
86 struct scsi_tgt_cmd *tcmd;
87
88 /* Bail if we can't get a reference to the device */
89 if (!get_device(&shost->shost_gendev))
90 return NULL;
91
92 tcmd = kmem_cache_alloc(scsi_tgt_cmd_cache, GFP_ATOMIC);
93 if (!tcmd)
94 goto put_dev;
95
96 rq = blk_get_request(shost->uspace_req_q, write, gfp_mask);
97 if (!rq)
98 goto free_tcmd;
99
100 cmd = __scsi_get_command(shost, gfp_mask);
101 if (!cmd)
102 goto release_rq;
103
104 memset(cmd, 0, sizeof(*cmd));
105 cmd->sc_data_direction = data_dir;
106 cmd->jiffies_at_alloc = jiffies;
107 cmd->request = rq;
108
109 rq->special = cmd;
110 rq->cmd_type = REQ_TYPE_SPECIAL;
111 rq->cmd_flags |= REQ_TYPE_BLOCK_PC;
112 rq->end_io_data = tcmd;
113
114 bio_list_init(&tcmd->xfer_list);
115 bio_list_init(&tcmd->xfer_done_list);
116 tcmd->rq = rq;
117
118 return cmd;
119
120release_rq:
121 blk_put_request(rq);
122free_tcmd:
123 kmem_cache_free(scsi_tgt_cmd_cache, tcmd);
124put_dev:
125 put_device(&shost->shost_gendev);
126 return NULL;
127
128}
129EXPORT_SYMBOL_GPL(scsi_host_get_command);
130
131/*
132 * Function: scsi_host_put_command()
133 *
134 * Purpose: Free a scsi command block
135 *
136 * Arguments: shost - scsi host
137 * cmd - command block to free
138 *
139 * Returns: Nothing.
140 *
141 * Notes: The command must not belong to any lists.
142 */
143void scsi_host_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
144{
145 struct request_queue *q = shost->uspace_req_q;
146 struct request *rq = cmd->request;
147 struct scsi_tgt_cmd *tcmd = rq->end_io_data;
148 unsigned long flags;
149
150 kmem_cache_free(scsi_tgt_cmd_cache, tcmd);
151
152 spin_lock_irqsave(q->queue_lock, flags);
153 __blk_put_request(q, rq);
154 spin_unlock_irqrestore(q->queue_lock, flags);
155
156 __scsi_put_command(shost, cmd, &shost->shost_gendev);
157}
158EXPORT_SYMBOL_GPL(scsi_host_put_command);
159
160static void scsi_unmap_user_pages(struct scsi_tgt_cmd *tcmd)
161{
162 struct bio *bio;
163
164 /* must call bio_endio in case bio was bounced */
165 while ((bio = bio_list_pop(&tcmd->xfer_done_list))) {
166 bio_endio(bio, bio->bi_size, 0);
167 bio_unmap_user(bio);
168 }
169
170 while ((bio = bio_list_pop(&tcmd->xfer_list))) {
171 bio_endio(bio, bio->bi_size, 0);
172 bio_unmap_user(bio);
173 }
174}
175
176static void cmd_hashlist_del(struct scsi_cmnd *cmd)
177{
178 struct request_queue *q = cmd->request->q;
179 struct scsi_tgt_queuedata *qdata = q->queuedata;
180 unsigned long flags;
181 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
182
183 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
184 list_del(&tcmd->hash_list);
185 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
186}
187
188static void scsi_tgt_cmd_destroy(struct work_struct *work)
189{
190 struct scsi_tgt_cmd *tcmd =
191 container_of(work, struct scsi_tgt_cmd, work);
192 struct scsi_cmnd *cmd = tcmd->rq->special;
193
194 dprintk("cmd %p %d %lu\n", cmd, cmd->sc_data_direction,
195 rq_data_dir(cmd->request));
196 /*
197 * We fix rq->cmd_flags here since when we told bio_map_user
198 * to write vm for WRITE commands, blk_rq_bio_prep set
199 * rq_data_dir the flags to READ.
200 */
201 if (cmd->sc_data_direction == DMA_TO_DEVICE)
202 cmd->request->cmd_flags |= REQ_RW;
203 else
204 cmd->request->cmd_flags &= ~REQ_RW;
205
206 scsi_unmap_user_pages(tcmd);
207 scsi_host_put_command(scsi_tgt_cmd_to_host(cmd), cmd);
208}
209
210static void init_scsi_tgt_cmd(struct request *rq, struct scsi_tgt_cmd *tcmd,
211 u64 tag)
212{
213 struct scsi_tgt_queuedata *qdata = rq->q->queuedata;
214 unsigned long flags;
215 struct list_head *head;
216
217 tcmd->tag = tag;
218 INIT_WORK(&tcmd->work, scsi_tgt_cmd_destroy);
219 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
220 head = &qdata->cmd_hash[cmd_hashfn(tag)];
221 list_add(&tcmd->hash_list, head);
222 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
223}
224
225/*
226 * scsi_tgt_alloc_queue - setup queue used for message passing
227 * shost: scsi host
228 *
229 * This should be called by the LLD after host allocation.
230 * And will be released when the host is released.
231 */
232int scsi_tgt_alloc_queue(struct Scsi_Host *shost)
233{
234 struct scsi_tgt_queuedata *queuedata;
235 struct request_queue *q;
236 int err, i;
237
238 /*
239 * Do we need to send a netlink event or should uspace
240 * just respond to the hotplug event?
241 */
242 q = __scsi_alloc_queue(shost, NULL);
243 if (!q)
244 return -ENOMEM;
245
246 queuedata = kzalloc(sizeof(*queuedata), GFP_KERNEL);
247 if (!queuedata) {
248 err = -ENOMEM;
249 goto cleanup_queue;
250 }
251 queuedata->shost = shost;
252 q->queuedata = queuedata;
253
254 /*
255 * this is a silly hack. We should probably just queue as many
256 * command as is recvd to userspace. uspace can then make
257 * sure we do not overload the HBA
258 */
259 q->nr_requests = shost->hostt->can_queue;
260 /*
261 * We currently only support software LLDs so this does
262 * not matter for now. Do we need this for the cards we support?
263 * If so we should make it a host template value.
264 */
265 blk_queue_dma_alignment(q, 0);
266 shost->uspace_req_q = q;
267
268 for (i = 0; i < ARRAY_SIZE(queuedata->cmd_hash); i++)
269 INIT_LIST_HEAD(&queuedata->cmd_hash[i]);
270 spin_lock_init(&queuedata->cmd_hash_lock);
271
272 return 0;
273
274cleanup_queue:
275 blk_cleanup_queue(q);
276 return err;
277}
278EXPORT_SYMBOL_GPL(scsi_tgt_alloc_queue);
279
280void scsi_tgt_free_queue(struct Scsi_Host *shost)
281{
282 int i;
283 unsigned long flags;
284 struct request_queue *q = shost->uspace_req_q;
285 struct scsi_cmnd *cmd;
286 struct scsi_tgt_queuedata *qdata = q->queuedata;
287 struct scsi_tgt_cmd *tcmd, *n;
288 LIST_HEAD(cmds);
289
290 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
291
292 for (i = 0; i < ARRAY_SIZE(qdata->cmd_hash); i++) {
293 list_for_each_entry_safe(tcmd, n, &qdata->cmd_hash[i],
294 hash_list) {
295 list_del(&tcmd->hash_list);
296 list_add(&tcmd->hash_list, &cmds);
297 }
298 }
299
300 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
301
302 while (!list_empty(&cmds)) {
303 tcmd = list_entry(cmds.next, struct scsi_tgt_cmd, hash_list);
304 list_del(&tcmd->hash_list);
305 cmd = tcmd->rq->special;
306
307 shost->hostt->eh_abort_handler(cmd);
308 scsi_tgt_cmd_destroy(&tcmd->work);
309 }
310}
311EXPORT_SYMBOL_GPL(scsi_tgt_free_queue);
312
313struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *cmd)
314{
315 struct scsi_tgt_queuedata *queue = cmd->request->q->queuedata;
316 return queue->shost;
317}
318EXPORT_SYMBOL_GPL(scsi_tgt_cmd_to_host);
319
320/*
321 * scsi_tgt_queue_command - queue command for userspace processing
322 * @cmd: scsi command
323 * @scsilun: scsi lun
324 * @tag: unique value to identify this command for tmf
325 */
326int scsi_tgt_queue_command(struct scsi_cmnd *cmd, struct scsi_lun *scsilun,
327 u64 tag)
328{
329 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
330 int err;
331
332 init_scsi_tgt_cmd(cmd->request, tcmd, tag);
333 err = scsi_tgt_uspace_send_cmd(cmd, scsilun, tag);
334 if (err)
335 cmd_hashlist_del(cmd);
336
337 return err;
338}
339EXPORT_SYMBOL_GPL(scsi_tgt_queue_command);
340
341/*
342 * This is run from a interrpt handler normally and the unmap
343 * needs process context so we must queue
344 */
345static void scsi_tgt_cmd_done(struct scsi_cmnd *cmd)
346{
347 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
348
349 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
350
351 scsi_tgt_uspace_send_status(cmd, tcmd->tag);
352 queue_work(scsi_tgtd, &tcmd->work);
353}
354
355static int __scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
356{
357 struct Scsi_Host *shost = scsi_tgt_cmd_to_host(cmd);
358 int err;
359
360 dprintk("cmd %p %lu\n", cmd, rq_data_dir(cmd->request));
361
362 err = shost->hostt->transfer_response(cmd, scsi_tgt_cmd_done);
363 switch (err) {
364 case SCSI_MLQUEUE_HOST_BUSY:
365 case SCSI_MLQUEUE_DEVICE_BUSY:
366 return -EAGAIN;
367 }
368
369 return 0;
370}
371
372static void scsi_tgt_transfer_response(struct scsi_cmnd *cmd)
373{
374 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
375 int err;
376
377 err = __scsi_tgt_transfer_response(cmd);
378 if (!err)
379 return;
380
381 cmd->result = DID_BUS_BUSY << 16;
382 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
383 if (err <= 0)
384 /* the eh will have to pick this up */
385 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
386}
387
388static int scsi_tgt_init_cmd(struct scsi_cmnd *cmd, gfp_t gfp_mask)
389{
390 struct request *rq = cmd->request;
391 struct scsi_tgt_cmd *tcmd = rq->end_io_data;
392 int count;
393
394 cmd->use_sg = rq->nr_phys_segments;
395 cmd->request_buffer = scsi_alloc_sgtable(cmd, gfp_mask);
396 if (!cmd->request_buffer)
397 return -ENOMEM;
398
399 cmd->request_bufflen = rq->data_len;
400
401 dprintk("cmd %p addr %p cnt %d %lu\n", cmd, tcmd->buffer, cmd->use_sg,
402 rq_data_dir(rq));
403 count = blk_rq_map_sg(rq->q, rq, cmd->request_buffer);
404 if (likely(count <= cmd->use_sg)) {
405 cmd->use_sg = count;
406 return 0;
407 }
408
409 eprintk("cmd %p addr %p cnt %d\n", cmd, tcmd->buffer, cmd->use_sg);
410 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
411 return -EINVAL;
412}
413
414/* TODO: test this crap and replace bio_map_user with new interface maybe */
415static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
416 int rw)
417{
418 struct request_queue *q = cmd->request->q;
419 struct request *rq = cmd->request;
420 void *uaddr = tcmd->buffer;
421 unsigned int len = tcmd->bufflen;
422 struct bio *bio;
423 int err;
424
425 while (len > 0) {
426 dprintk("%lx %u\n", (unsigned long) uaddr, len);
427 bio = bio_map_user(q, NULL, (unsigned long) uaddr, len, rw);
428 if (IS_ERR(bio)) {
429 err = PTR_ERR(bio);
430 dprintk("fail to map %lx %u %d %x\n",
431 (unsigned long) uaddr, len, err, cmd->cmnd[0]);
432 goto unmap_bios;
433 }
434
435 uaddr += bio->bi_size;
436 len -= bio->bi_size;
437
438 /*
439 * The first bio is added and merged. We could probably
440 * try to add others using scsi_merge_bio() but for now
441 * we keep it simple. The first bio should be pretty large
442 * (either hitting the 1 MB bio pages limit or a queue limit)
443 * already but for really large IO we may want to try and
444 * merge these.
445 */
446 if (!rq->bio) {
447 blk_rq_bio_prep(q, rq, bio);
448 rq->data_len = bio->bi_size;
449 } else
450 /* put list of bios to transfer in next go around */
451 bio_list_add(&tcmd->xfer_list, bio);
452 }
453
454 cmd->offset = 0;
455 err = scsi_tgt_init_cmd(cmd, GFP_KERNEL);
456 if (err)
457 goto unmap_bios;
458
459 return 0;
460
461unmap_bios:
462 if (rq->bio) {
463 bio_unmap_user(rq->bio);
464 while ((bio = bio_list_pop(&tcmd->xfer_list)))
465 bio_unmap_user(bio);
466 }
467
468 return err;
469}
470
471static int scsi_tgt_transfer_data(struct scsi_cmnd *);
472
473static void scsi_tgt_data_transfer_done(struct scsi_cmnd *cmd)
474{
475 struct scsi_tgt_cmd *tcmd = cmd->request->end_io_data;
476 struct bio *bio;
477 int err;
478
479 /* should we free resources here on error ? */
480 if (cmd->result) {
481send_uspace_err:
482 err = scsi_tgt_uspace_send_status(cmd, tcmd->tag);
483 if (err <= 0)
484 /* the tgt uspace eh will have to pick this up */
485 printk(KERN_ERR "Could not send cmd %p status\n", cmd);
486 return;
487 }
488
489 dprintk("cmd %p request_bufflen %u bufflen %u\n",
490 cmd, cmd->request_bufflen, tcmd->bufflen);
491
492 scsi_free_sgtable(cmd->request_buffer, cmd->sglist_len);
493 bio_list_add(&tcmd->xfer_done_list, cmd->request->bio);
494
495 tcmd->buffer += cmd->request_bufflen;
496 cmd->offset += cmd->request_bufflen;
497
498 if (!tcmd->xfer_list.head) {
499 scsi_tgt_transfer_response(cmd);
500 return;
501 }
502
503 dprintk("cmd2 %p request_bufflen %u bufflen %u\n",
504 cmd, cmd->request_bufflen, tcmd->bufflen);
505
506 bio = bio_list_pop(&tcmd->xfer_list);
507 BUG_ON(!bio);
508
509 blk_rq_bio_prep(cmd->request->q, cmd->request, bio);
510 cmd->request->data_len = bio->bi_size;
511 err = scsi_tgt_init_cmd(cmd, GFP_ATOMIC);
512 if (err) {
513 cmd->result = DID_ERROR << 16;
514 goto send_uspace_err;
515 }
516
517 if (scsi_tgt_transfer_data(cmd)) {
518 cmd->result = DID_NO_CONNECT << 16;
519 goto send_uspace_err;
520 }
521}
522
523static int scsi_tgt_transfer_data(struct scsi_cmnd *cmd)
524{
525 int err;
526 struct Scsi_Host *host = scsi_tgt_cmd_to_host(cmd);
527
528 err = host->hostt->transfer_data(cmd, scsi_tgt_data_transfer_done);
529 switch (err) {
530 case SCSI_MLQUEUE_HOST_BUSY:
531 case SCSI_MLQUEUE_DEVICE_BUSY:
532 return -EAGAIN;
533 default:
534 return 0;
535 }
536}
537
538static int scsi_tgt_copy_sense(struct scsi_cmnd *cmd, unsigned long uaddr,
539 unsigned len)
540{
541 char __user *p = (char __user *) uaddr;
542
543 if (copy_from_user(cmd->sense_buffer, p,
544 min_t(unsigned, SCSI_SENSE_BUFFERSIZE, len))) {
545 printk(KERN_ERR "Could not copy the sense buffer\n");
546 return -EIO;
547 }
548 return 0;
549}
550
551static int scsi_tgt_abort_cmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
552{
553 struct scsi_tgt_cmd *tcmd;
554 int err;
555
556 err = shost->hostt->eh_abort_handler(cmd);
557 if (err)
558 eprintk("fail to abort %p\n", cmd);
559
560 tcmd = cmd->request->end_io_data;
561 scsi_tgt_cmd_destroy(&tcmd->work);
562 return err;
563}
564
565static struct request *tgt_cmd_hash_lookup(struct request_queue *q, u64 tag)
566{
567 struct scsi_tgt_queuedata *qdata = q->queuedata;
568 struct request *rq = NULL;
569 struct list_head *head;
570 struct scsi_tgt_cmd *tcmd;
571 unsigned long flags;
572
573 head = &qdata->cmd_hash[cmd_hashfn(tag)];
574 spin_lock_irqsave(&qdata->cmd_hash_lock, flags);
575 list_for_each_entry(tcmd, head, hash_list) {
576 if (tcmd->tag == tag) {
577 rq = tcmd->rq;
578 list_del(&tcmd->hash_list);
579 break;
580 }
581 }
582 spin_unlock_irqrestore(&qdata->cmd_hash_lock, flags);
583
584 return rq;
585}
586
587int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
588 unsigned long uaddr, u8 rw)
589{
590 struct Scsi_Host *shost;
591 struct scsi_cmnd *cmd;
592 struct request *rq;
593 struct scsi_tgt_cmd *tcmd;
594 int err = 0;
595
596 dprintk("%d %llu %d %u %lx %u\n", host_no, (unsigned long long) tag,
597 result, len, uaddr, rw);
598
599 /* TODO: replace with a O(1) alg */
600 shost = scsi_host_lookup(host_no);
601 if (IS_ERR(shost)) {
602 printk(KERN_ERR "Could not find host no %d\n", host_no);
603 return -EINVAL;
604 }
605
606 if (!shost->uspace_req_q) {
607 printk(KERN_ERR "Not target scsi host %d\n", host_no);
608 goto done;
609 }
610
611 rq = tgt_cmd_hash_lookup(shost->uspace_req_q, tag);
612 if (!rq) {
613 printk(KERN_ERR "Could not find tag %llu\n",
614 (unsigned long long) tag);
615 err = -EINVAL;
616 goto done;
617 }
618 cmd = rq->special;
619
620 dprintk("cmd %p result %d len %d bufflen %u %lu %x\n", cmd,
621 result, len, cmd->request_bufflen, rq_data_dir(rq), cmd->cmnd[0]);
622
623 if (result == TASK_ABORTED) {
624 scsi_tgt_abort_cmd(shost, cmd);
625 goto done;
626 }
627 /*
628 * store the userspace values here, the working values are
629 * in the request_* values
630 */
631 tcmd = cmd->request->end_io_data;
632 tcmd->buffer = (void *)uaddr;
633 tcmd->bufflen = len;
634 cmd->result = result;
635
636 if (!tcmd->bufflen || cmd->request_buffer) {
637 err = __scsi_tgt_transfer_response(cmd);
638 goto done;
639 }
640
641 /*
642 * TODO: Do we need to handle case where request does not
643 * align with LLD.
644 */
645 err = scsi_map_user_pages(rq->end_io_data, cmd, rw);
646 if (err) {
647 eprintk("%p %d\n", cmd, err);
648 err = -EAGAIN;
649 goto done;
650 }
651
652 /* userspace failure */
653 if (cmd->result) {
654 if (status_byte(cmd->result) == CHECK_CONDITION)
655 scsi_tgt_copy_sense(cmd, uaddr, len);
656 err = __scsi_tgt_transfer_response(cmd);
657 goto done;
658 }
659 /* ask the target LLD to transfer the data to the buffer */
660 err = scsi_tgt_transfer_data(cmd);
661
662done:
663 scsi_host_put(shost);
664 return err;
665}
666
667int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *shost, int function, u64 tag,
668 struct scsi_lun *scsilun, void *data)
669{
670 int err;
671
672 /* TODO: need to retry if this fails. */
673 err = scsi_tgt_uspace_send_tsk_mgmt(shost->host_no, function,
674 tag, scsilun, data);
675 if (err < 0)
676 eprintk("The task management request lost!\n");
677 return err;
678}
679EXPORT_SYMBOL_GPL(scsi_tgt_tsk_mgmt_request);
680
681int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result)
682{
683 struct Scsi_Host *shost;
684 int err = -EINVAL;
685
686 dprintk("%d %d %llx\n", host_no, result, (unsigned long long) mid);
687
688 shost = scsi_host_lookup(host_no);
689 if (IS_ERR(shost)) {
690 printk(KERN_ERR "Could not find host no %d\n", host_no);
691 return err;
692 }
693
694 if (!shost->uspace_req_q) {
695 printk(KERN_ERR "Not target scsi host %d\n", host_no);
696 goto done;
697 }
698
699 err = shost->hostt->tsk_mgmt_response(mid, result);
700done:
701 scsi_host_put(shost);
702 return err;
703}
704
705static int __init scsi_tgt_init(void)
706{
707 int err;
708
709 scsi_tgt_cmd_cache = kmem_cache_create("scsi_tgt_cmd",
710 sizeof(struct scsi_tgt_cmd),
711 0, 0, NULL, NULL);
712 if (!scsi_tgt_cmd_cache)
713 return -ENOMEM;
714
715 scsi_tgtd = create_workqueue("scsi_tgtd");
716 if (!scsi_tgtd) {
717 err = -ENOMEM;
718 goto free_kmemcache;
719 }
720
721 err = scsi_tgt_if_init();
722 if (err)
723 goto destroy_wq;
724
725 return 0;
726
727destroy_wq:
728 destroy_workqueue(scsi_tgtd);
729free_kmemcache:
730 kmem_cache_destroy(scsi_tgt_cmd_cache);
731 return err;
732}
733
734static void __exit scsi_tgt_exit(void)
735{
736 destroy_workqueue(scsi_tgtd);
737 scsi_tgt_if_exit();
738 kmem_cache_destroy(scsi_tgt_cmd_cache);
739}
740
741module_init(scsi_tgt_init);
742module_exit(scsi_tgt_exit);
743
744MODULE_DESCRIPTION("SCSI target core");
745MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/scsi_tgt_priv.h b/drivers/scsi/scsi_tgt_priv.h
new file mode 100644
index 000000000000..84488c51ff62
--- /dev/null
+++ b/drivers/scsi/scsi_tgt_priv.h
@@ -0,0 +1,25 @@
1struct scsi_cmnd;
2struct scsi_lun;
3struct Scsi_Host;
4struct task_struct;
5
6/* tmp - will replace with SCSI logging stuff */
7#define eprintk(fmt, args...) \
8do { \
9 printk("%s(%d) " fmt, __FUNCTION__, __LINE__, ##args); \
10} while (0)
11
12#define dprintk(fmt, args...)
13/* #define dprintk eprintk */
14
15extern void scsi_tgt_if_exit(void);
16extern int scsi_tgt_if_init(void);
17
18extern int scsi_tgt_uspace_send_cmd(struct scsi_cmnd *cmd, struct scsi_lun *lun,
19 u64 tag);
20extern int scsi_tgt_uspace_send_status(struct scsi_cmnd *cmd, u64 tag);
21extern int scsi_tgt_kspace_exec(int host_no, u64 tag, int result, u32 len,
22 unsigned long uaddr, u8 rw);
23extern int scsi_tgt_uspace_send_tsk_mgmt(int host_no, int function, u64 tag,
24 struct scsi_lun *scsilun, void *data);
25extern int scsi_tgt_kspace_tsk_mgmt(int host_no, u64 mid, int result);
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 38c215a78f69..3571ce8934e7 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -241,9 +241,9 @@ fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
241#define FC_MGMTSRVR_PORTID 0x00000a 241#define FC_MGMTSRVR_PORTID 0x00000a
242 242
243 243
244static void fc_timeout_deleted_rport(void *data); 244static void fc_timeout_deleted_rport(struct work_struct *work);
245static void fc_timeout_fail_rport_io(void *data); 245static void fc_timeout_fail_rport_io(struct work_struct *work);
246static void fc_scsi_scan_rport(void *data); 246static void fc_scsi_scan_rport(struct work_struct *work);
247 247
248/* 248/*
249 * Attribute counts pre object type... 249 * Attribute counts pre object type...
@@ -1613,7 +1613,7 @@ fc_flush_work(struct Scsi_Host *shost)
1613 * 1 on success / 0 already queued / < 0 for error 1613 * 1 on success / 0 already queued / < 0 for error
1614 **/ 1614 **/
1615static int 1615static int
1616fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work, 1616fc_queue_devloss_work(struct Scsi_Host *shost, struct delayed_work *work,
1617 unsigned long delay) 1617 unsigned long delay)
1618{ 1618{
1619 if (unlikely(!fc_host_devloss_work_q(shost))) { 1619 if (unlikely(!fc_host_devloss_work_q(shost))) {
@@ -1625,9 +1625,6 @@ fc_queue_devloss_work(struct Scsi_Host *shost, struct work_struct *work,
1625 return -EINVAL; 1625 return -EINVAL;
1626 } 1626 }
1627 1627
1628 if (delay == 0)
1629 return queue_work(fc_host_devloss_work_q(shost), work);
1630
1631 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay); 1628 return queue_delayed_work(fc_host_devloss_work_q(shost), work, delay);
1632} 1629}
1633 1630
@@ -1712,12 +1709,13 @@ EXPORT_SYMBOL(fc_remove_host);
1712 * fc_starget_delete - called to delete the scsi decendents of an rport 1709 * fc_starget_delete - called to delete the scsi decendents of an rport
1713 * (target and all sdevs) 1710 * (target and all sdevs)
1714 * 1711 *
1715 * @data: remote port to be operated on. 1712 * @work: remote port to be operated on.
1716 **/ 1713 **/
1717static void 1714static void
1718fc_starget_delete(void *data) 1715fc_starget_delete(struct work_struct *work)
1719{ 1716{
1720 struct fc_rport *rport = (struct fc_rport *)data; 1717 struct fc_rport *rport =
1718 container_of(work, struct fc_rport, stgt_delete_work);
1721 struct Scsi_Host *shost = rport_to_shost(rport); 1719 struct Scsi_Host *shost = rport_to_shost(rport);
1722 unsigned long flags; 1720 unsigned long flags;
1723 struct fc_internal *i = to_fc_internal(shost->transportt); 1721 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1751,12 +1749,13 @@ fc_starget_delete(void *data)
1751/** 1749/**
1752 * fc_rport_final_delete - finish rport termination and delete it. 1750 * fc_rport_final_delete - finish rport termination and delete it.
1753 * 1751 *
1754 * @data: remote port to be deleted. 1752 * @work: remote port to be deleted.
1755 **/ 1753 **/
1756static void 1754static void
1757fc_rport_final_delete(void *data) 1755fc_rport_final_delete(struct work_struct *work)
1758{ 1756{
1759 struct fc_rport *rport = (struct fc_rport *)data; 1757 struct fc_rport *rport =
1758 container_of(work, struct fc_rport, rport_delete_work);
1760 struct device *dev = &rport->dev; 1759 struct device *dev = &rport->dev;
1761 struct Scsi_Host *shost = rport_to_shost(rport); 1760 struct Scsi_Host *shost = rport_to_shost(rport);
1762 struct fc_internal *i = to_fc_internal(shost->transportt); 1761 struct fc_internal *i = to_fc_internal(shost->transportt);
@@ -1770,7 +1769,7 @@ fc_rport_final_delete(void *data)
1770 1769
1771 /* Delete SCSI target and sdevs */ 1770 /* Delete SCSI target and sdevs */
1772 if (rport->scsi_target_id != -1) 1771 if (rport->scsi_target_id != -1)
1773 fc_starget_delete(data); 1772 fc_starget_delete(&rport->stgt_delete_work);
1774 else if (i->f->dev_loss_tmo_callbk) 1773 else if (i->f->dev_loss_tmo_callbk)
1775 i->f->dev_loss_tmo_callbk(rport); 1774 i->f->dev_loss_tmo_callbk(rport);
1776 else if (i->f->terminate_rport_io) 1775 else if (i->f->terminate_rport_io)
@@ -1829,11 +1828,11 @@ fc_rport_create(struct Scsi_Host *shost, int channel,
1829 rport->channel = channel; 1828 rport->channel = channel;
1830 rport->fast_io_fail_tmo = -1; 1829 rport->fast_io_fail_tmo = -1;
1831 1830
1832 INIT_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport, rport); 1831 INIT_DELAYED_WORK(&rport->dev_loss_work, fc_timeout_deleted_rport);
1833 INIT_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io, rport); 1832 INIT_DELAYED_WORK(&rport->fail_io_work, fc_timeout_fail_rport_io);
1834 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport, rport); 1833 INIT_WORK(&rport->scan_work, fc_scsi_scan_rport);
1835 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete, rport); 1834 INIT_WORK(&rport->stgt_delete_work, fc_starget_delete);
1836 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete, rport); 1835 INIT_WORK(&rport->rport_delete_work, fc_rport_final_delete);
1837 1836
1838 spin_lock_irqsave(shost->host_lock, flags); 1837 spin_lock_irqsave(shost->host_lock, flags);
1839 1838
@@ -1963,7 +1962,7 @@ fc_remote_port_add(struct Scsi_Host *shost, int channel,
1963 } 1962 }
1964 1963
1965 if (match) { 1964 if (match) {
1966 struct work_struct *work = 1965 struct delayed_work *work =
1967 &rport->dev_loss_work; 1966 &rport->dev_loss_work;
1968 1967
1969 memcpy(&rport->node_name, &ids->node_name, 1968 memcpy(&rport->node_name, &ids->node_name,
@@ -2267,12 +2266,13 @@ EXPORT_SYMBOL(fc_remote_port_rolechg);
2267 * was a SCSI target (thus was blocked), and failed 2266 * was a SCSI target (thus was blocked), and failed
2268 * to return in the alloted time. 2267 * to return in the alloted time.
2269 * 2268 *
2270 * @data: rport target that failed to reappear in the alloted time. 2269 * @work: rport target that failed to reappear in the alloted time.
2271 **/ 2270 **/
2272static void 2271static void
2273fc_timeout_deleted_rport(void *data) 2272fc_timeout_deleted_rport(struct work_struct *work)
2274{ 2273{
2275 struct fc_rport *rport = (struct fc_rport *)data; 2274 struct fc_rport *rport =
2275 container_of(work, struct fc_rport, dev_loss_work.work);
2276 struct Scsi_Host *shost = rport_to_shost(rport); 2276 struct Scsi_Host *shost = rport_to_shost(rport);
2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost); 2277 struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
2278 unsigned long flags; 2278 unsigned long flags;
@@ -2366,15 +2366,16 @@ fc_timeout_deleted_rport(void *data)
2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a 2366 * fc_timeout_fail_rport_io - Timeout handler for a fast io failing on a
2367 * disconnected SCSI target. 2367 * disconnected SCSI target.
2368 * 2368 *
2369 * @data: rport to terminate io on. 2369 * @work: rport to terminate io on.
2370 * 2370 *
2371 * Notes: Only requests the failure of the io, not that all are flushed 2371 * Notes: Only requests the failure of the io, not that all are flushed
2372 * prior to returning. 2372 * prior to returning.
2373 **/ 2373 **/
2374static void 2374static void
2375fc_timeout_fail_rport_io(void *data) 2375fc_timeout_fail_rport_io(struct work_struct *work)
2376{ 2376{
2377 struct fc_rport *rport = (struct fc_rport *)data; 2377 struct fc_rport *rport =
2378 container_of(work, struct fc_rport, fail_io_work.work);
2378 struct Scsi_Host *shost = rport_to_shost(rport); 2379 struct Scsi_Host *shost = rport_to_shost(rport);
2379 struct fc_internal *i = to_fc_internal(shost->transportt); 2380 struct fc_internal *i = to_fc_internal(shost->transportt);
2380 2381
@@ -2387,12 +2388,13 @@ fc_timeout_fail_rport_io(void *data)
2387/** 2388/**
2388 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port. 2389 * fc_scsi_scan_rport - called to perform a scsi scan on a remote port.
2389 * 2390 *
2390 * @data: remote port to be scanned. 2391 * @work: remote port to be scanned.
2391 **/ 2392 **/
2392static void 2393static void
2393fc_scsi_scan_rport(void *data) 2394fc_scsi_scan_rport(struct work_struct *work)
2394{ 2395{
2395 struct fc_rport *rport = (struct fc_rport *)data; 2396 struct fc_rport *rport =
2397 container_of(work, struct fc_rport, scan_work);
2396 struct Scsi_Host *shost = rport_to_shost(rport); 2398 struct Scsi_Host *shost = rport_to_shost(rport);
2397 unsigned long flags; 2399 unsigned long flags;
2398 2400
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 9b25124a989e..9c22f1342715 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -234,9 +234,11 @@ static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
234 return 0; 234 return 0;
235} 235}
236 236
237static void session_recovery_timedout(void *data) 237static void session_recovery_timedout(struct work_struct *work)
238{ 238{
239 struct iscsi_cls_session *session = data; 239 struct iscsi_cls_session *session =
240 container_of(work, struct iscsi_cls_session,
241 recovery_work.work);
240 242
241 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed " 243 dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed "
242 "out after %d secs\n", session->recovery_tmo); 244 "out after %d secs\n", session->recovery_tmo);
@@ -276,7 +278,7 @@ iscsi_alloc_session(struct Scsi_Host *shost,
276 278
277 session->transport = transport; 279 session->transport = transport;
278 session->recovery_tmo = 120; 280 session->recovery_tmo = 120;
279 INIT_WORK(&session->recovery_work, session_recovery_timedout, session); 281 INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
280 INIT_LIST_HEAD(&session->host_list); 282 INIT_LIST_HEAD(&session->host_list);
281 INIT_LIST_HEAD(&session->sess_list); 283 INIT_LIST_HEAD(&session->sess_list);
282 284
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 9f070f0d0f2b..3fded4831460 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -964,9 +964,10 @@ struct work_queue_wrapper {
964}; 964};
965 965
966static void 966static void
967spi_dv_device_work_wrapper(void *data) 967spi_dv_device_work_wrapper(struct work_struct *work)
968{ 968{
969 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data; 969 struct work_queue_wrapper *wqw =
970 container_of(work, struct work_queue_wrapper, work);
970 struct scsi_device *sdev = wqw->sdev; 971 struct scsi_device *sdev = wqw->sdev;
971 972
972 kfree(wqw); 973 kfree(wqw);
@@ -1006,7 +1007,7 @@ spi_schedule_dv_device(struct scsi_device *sdev)
1006 return; 1007 return;
1007 } 1008 }
1008 1009
1009 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper, wqw); 1010 INIT_WORK(&wqw->work, spi_dv_device_work_wrapper);
1010 wqw->sdev = sdev; 1011 wqw->sdev = sdev;
1011 1012
1012 schedule_work(&wqw->work); 1013 schedule_work(&wqw->work);
diff --git a/drivers/scsi/scsi_wait_scan.c b/drivers/scsi/scsi_wait_scan.c
new file mode 100644
index 000000000000..8a636103083d
--- /dev/null
+++ b/drivers/scsi/scsi_wait_scan.c
@@ -0,0 +1,31 @@
1/*
2 * scsi_wait_scan.c
3 *
4 * Copyright (C) 2006 James Bottomley <James.Bottomley@SteelEye.com>
5 *
6 * This is a simple module to wait until all the async scans are
7 * complete. The idea is to use it in initrd/initramfs scripts. You
8 * modprobe it after all the modprobes of the root SCSI drivers and it
9 * will wait until they have all finished scanning their busses before
10 * allowing the boot to proceed
11 */
12
13#include <linux/module.h>
14#include "scsi_priv.h"
15
16static int __init wait_scan_init(void)
17{
18 scsi_complete_async_scans();
19 return 0;
20}
21
22static void __exit wait_scan_exit(void)
23{
24}
25
26MODULE_DESCRIPTION("SCSI wait for scans");
27MODULE_AUTHOR("James Bottomley");
28MODULE_LICENSE("GPL");
29
30late_initcall(wait_scan_init);
31module_exit(wait_scan_exit);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 84ff203ffedd..f6a452846fab 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1051,6 +1051,14 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1051 &sshdr, SD_TIMEOUT, 1051 &sshdr, SD_TIMEOUT,
1052 SD_MAX_RETRIES); 1052 SD_MAX_RETRIES);
1053 1053
1054 /*
1055 * If the drive has indicated to us that it
1056 * doesn't have any media in it, don't bother
1057 * with any more polling.
1058 */
1059 if (media_not_present(sdkp, &sshdr))
1060 return;
1061
1054 if (the_result) 1062 if (the_result)
1055 sense_valid = scsi_sense_valid(&sshdr); 1063 sense_valid = scsi_sense_valid(&sshdr);
1056 retries++; 1064 retries++;
@@ -1059,14 +1067,6 @@ sd_spinup_disk(struct scsi_disk *sdkp, char *diskname)
1059 ((driver_byte(the_result) & DRIVER_SENSE) && 1067 ((driver_byte(the_result) & DRIVER_SENSE) &&
1060 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 1068 sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
1061 1069
1062 /*
1063 * If the drive has indicated to us that it doesn't have
1064 * any media in it, don't bother with any of the rest of
1065 * this crap.
1066 */
1067 if (media_not_present(sdkp, &sshdr))
1068 return;
1069
1070 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) { 1070 if ((driver_byte(the_result) & DRIVER_SENSE) == 0) {
1071 /* no sense, TUR either succeeded or failed 1071 /* no sense, TUR either succeeded or failed
1072 * with a status error */ 1072 * with a status error */
@@ -1467,7 +1467,6 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1467 res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr); 1467 res = sd_do_mode_sense(sdp, dbd, modepage, buffer, len, &data, &sshdr);
1468 1468
1469 if (scsi_status_is_good(res)) { 1469 if (scsi_status_is_good(res)) {
1470 int ct = 0;
1471 int offset = data.header_length + data.block_descriptor_length; 1470 int offset = data.header_length + data.block_descriptor_length;
1472 1471
1473 if (offset >= SD_BUF_SIZE - 2) { 1472 if (offset >= SD_BUF_SIZE - 2) {
@@ -1496,11 +1495,13 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1496 sdkp->DPOFUA = 0; 1495 sdkp->DPOFUA = 0;
1497 } 1496 }
1498 1497
1499 ct = sdkp->RCD + 2*sdkp->WCE; 1498 printk(KERN_NOTICE "SCSI device %s: "
1500 1499 "write cache: %s, read cache: %s, %s\n",
1501 printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n", 1500 diskname,
1502 diskname, sd_cache_types[ct], 1501 sdkp->WCE ? "enabled" : "disabled",
1503 sdkp->DPOFUA ? " w/ FUA" : ""); 1502 sdkp->RCD ? "disabled" : "enabled",
1503 sdkp->DPOFUA ? "supports DPO and FUA"
1504 : "doesn't support DPO or FUA");
1504 1505
1505 return; 1506 return;
1506 } 1507 }
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index e1a52c525ed4..587274dd7059 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -9,7 +9,7 @@
9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, 9 Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky,
10 Michael Schaefer, J"org Weule, and Eric Youngdale. 10 Michael Schaefer, J"org Weule, and Eric Youngdale.
11 11
12 Copyright 1992 - 2005 Kai Makisara 12 Copyright 1992 - 2006 Kai Makisara
13 email Kai.Makisara@kolumbus.fi 13 email Kai.Makisara@kolumbus.fi
14 14
15 Some small formal changes - aeb, 950809 15 Some small formal changes - aeb, 950809
@@ -17,7 +17,7 @@
17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 */ 18 */
19 19
20static const char *verstr = "20050830"; 20static const char *verstr = "20061107";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23 23
@@ -999,7 +999,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
999 STp->min_block = ((STp->buffer)->b_data[4] << 8) | 999 STp->min_block = ((STp->buffer)->b_data[4] << 8) |
1000 (STp->buffer)->b_data[5]; 1000 (STp->buffer)->b_data[5];
1001 if ( DEB( debugging || ) !STp->inited) 1001 if ( DEB( debugging || ) !STp->inited)
1002 printk(KERN_WARNING 1002 printk(KERN_INFO
1003 "%s: Block limits %d - %d bytes.\n", name, 1003 "%s: Block limits %d - %d bytes.\n", name,
1004 STp->min_block, STp->max_block); 1004 STp->min_block, STp->max_block);
1005 } else { 1005 } else {
@@ -1224,7 +1224,7 @@ static int st_flush(struct file *filp, fl_owner_t id)
1224 } 1224 }
1225 1225
1226 DEBC( if (STp->nbr_requests) 1226 DEBC( if (STp->nbr_requests)
1227 printk(KERN_WARNING "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", 1227 printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n",
1228 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable)); 1228 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable));
1229 1229
1230 if (STps->rw == ST_WRITING && !STp->pos_unknown) { 1230 if (STps->rw == ST_WRITING && !STp->pos_unknown) {
@@ -4056,11 +4056,11 @@ static int st_probe(struct device *dev)
4056 goto out_free_tape; 4056 goto out_free_tape;
4057 } 4057 }
4058 4058
4059 sdev_printk(KERN_WARNING, SDp, 4059 sdev_printk(KERN_NOTICE, SDp,
4060 "Attached scsi tape %s\n", tape_name(tpnt)); 4060 "Attached scsi tape %s\n", tape_name(tpnt));
4061 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n", 4061 sdev_printk(KERN_INFO, SDp, "%s: try direct i/o: %s (alignment %d B)\n",
4062 tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4062 tape_name(tpnt), tpnt->try_dio ? "yes" : "no",
4063 queue_dma_alignment(SDp->request_queue) + 1); 4063 queue_dma_alignment(SDp->request_queue) + 1);
4064 4064
4065 return 0; 4065 return 0;
4066 4066
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index 185c270bb043..ba6bcdaf2a6a 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -11,8 +11,6 @@
11 * Written By: 11 * Written By:
12 * Ed Lin <promise_linux@promise.com> 12 * Ed Lin <promise_linux@promise.com>
13 * 13 *
14 * Version: 3.0.0.1
15 *
16 */ 14 */
17 15
18#include <linux/init.h> 16#include <linux/init.h>
@@ -37,9 +35,9 @@
37#include <scsi/scsi_tcq.h> 35#include <scsi/scsi_tcq.h>
38 36
39#define DRV_NAME "stex" 37#define DRV_NAME "stex"
40#define ST_DRIVER_VERSION "3.0.0.1" 38#define ST_DRIVER_VERSION "3.1.0.1"
41#define ST_VER_MAJOR 3 39#define ST_VER_MAJOR 3
42#define ST_VER_MINOR 0 40#define ST_VER_MINOR 1
43#define ST_OEM 0 41#define ST_OEM 0
44#define ST_BUILD_VER 1 42#define ST_BUILD_VER 1
45 43
@@ -76,8 +74,10 @@ enum {
76 MU_STATE_STARTED = 4, 74 MU_STATE_STARTED = 4,
77 MU_STATE_RESETTING = 5, 75 MU_STATE_RESETTING = 5,
78 76
79 MU_MAX_DELAY_TIME = 240000, 77 MU_MAX_DELAY = 120,
80 MU_HANDSHAKE_SIGNATURE = 0x55aaaa55, 78 MU_HANDSHAKE_SIGNATURE = 0x55aaaa55,
79 MU_HANDSHAKE_SIGNATURE_HALF = 0x5a5a0000,
80 MU_HARD_RESET_WAIT = 30000,
81 HMU_PARTNER_TYPE = 2, 81 HMU_PARTNER_TYPE = 2,
82 82
83 /* firmware returned values */ 83 /* firmware returned values */
@@ -120,7 +120,8 @@ enum {
120 120
121 st_shasta = 0, 121 st_shasta = 0,
122 st_vsc = 1, 122 st_vsc = 1,
123 st_yosemite = 2, 123 st_vsc1 = 2,
124 st_yosemite = 3,
124 125
125 PASSTHRU_REQ_TYPE = 0x00000001, 126 PASSTHRU_REQ_TYPE = 0x00000001,
126 PASSTHRU_REQ_NO_WAKEUP = 0x00000100, 127 PASSTHRU_REQ_NO_WAKEUP = 0x00000100,
@@ -150,6 +151,8 @@ enum {
150 MGT_CMD_SIGNATURE = 0xba, 151 MGT_CMD_SIGNATURE = 0xba,
151 152
152 INQUIRY_EVPD = 0x01, 153 INQUIRY_EVPD = 0x01,
154
155 ST_ADDITIONAL_MEM = 0x200000,
153}; 156};
154 157
155/* SCSI inquiry data */ 158/* SCSI inquiry data */
@@ -211,7 +214,9 @@ struct handshake_frame {
211 __le32 partner_ver_minor; 214 __le32 partner_ver_minor;
212 __le32 partner_ver_oem; 215 __le32 partner_ver_oem;
213 __le32 partner_ver_build; 216 __le32 partner_ver_build;
214 u32 reserved1[4]; 217 __le32 extra_offset; /* NEW */
218 __le32 extra_size; /* NEW */
219 u32 reserved1[2];
215}; 220};
216 221
217struct req_msg { 222struct req_msg {
@@ -302,6 +307,7 @@ struct st_hba {
302 void __iomem *mmio_base; /* iomapped PCI memory space */ 307 void __iomem *mmio_base; /* iomapped PCI memory space */
303 void *dma_mem; 308 void *dma_mem;
304 dma_addr_t dma_handle; 309 dma_addr_t dma_handle;
310 size_t dma_size;
305 311
306 struct Scsi_Host *host; 312 struct Scsi_Host *host;
307 struct pci_dev *pdev; 313 struct pci_dev *pdev;
@@ -507,6 +513,7 @@ static void stex_controller_info(struct st_hba *hba, struct st_ccb *ccb)
507 size_t count = sizeof(struct st_frame); 513 size_t count = sizeof(struct st_frame);
508 514
509 p = hba->copy_buffer; 515 p = hba->copy_buffer;
516 stex_internal_copy(ccb->cmd, p, &count, ccb->sg_count, ST_FROM_CMD);
510 memset(p->base, 0, sizeof(u32)*6); 517 memset(p->base, 0, sizeof(u32)*6);
511 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0); 518 *(unsigned long *)(p->base) = pci_resource_start(hba->pdev, 0);
512 p->rom_addr = 0; 519 p->rom_addr = 0;
@@ -901,27 +908,34 @@ static int stex_handshake(struct st_hba *hba)
901 void __iomem *base = hba->mmio_base; 908 void __iomem *base = hba->mmio_base;
902 struct handshake_frame *h; 909 struct handshake_frame *h;
903 dma_addr_t status_phys; 910 dma_addr_t status_phys;
904 int i; 911 u32 data;
912 unsigned long before;
905 913
906 if (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) { 914 if (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
907 writel(MU_INBOUND_DOORBELL_HANDSHAKE, base + IDBL); 915 writel(MU_INBOUND_DOORBELL_HANDSHAKE, base + IDBL);
908 readl(base + IDBL); 916 readl(base + IDBL);
909 for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 917 before = jiffies;
910 && i < MU_MAX_DELAY_TIME; i++) { 918 while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
919 if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) {
920 printk(KERN_ERR DRV_NAME
921 "(%s): no handshake signature\n",
922 pci_name(hba->pdev));
923 return -1;
924 }
911 rmb(); 925 rmb();
912 msleep(1); 926 msleep(1);
913 } 927 }
914
915 if (i == MU_MAX_DELAY_TIME) {
916 printk(KERN_ERR DRV_NAME
917 "(%s): no handshake signature\n",
918 pci_name(hba->pdev));
919 return -1;
920 }
921 } 928 }
922 929
923 udelay(10); 930 udelay(10);
924 931
932 data = readl(base + OMR1);
933 if ((data & 0xffff0000) == MU_HANDSHAKE_SIGNATURE_HALF) {
934 data &= 0x0000ffff;
935 if (hba->host->can_queue > data)
936 hba->host->can_queue = data;
937 }
938
925 h = (struct handshake_frame *)(hba->dma_mem + MU_REQ_BUFFER_SIZE); 939 h = (struct handshake_frame *)(hba->dma_mem + MU_REQ_BUFFER_SIZE);
926 h->rb_phy = cpu_to_le32(hba->dma_handle); 940 h->rb_phy = cpu_to_le32(hba->dma_handle);
927 h->rb_phy_hi = cpu_to_le32((hba->dma_handle >> 16) >> 16); 941 h->rb_phy_hi = cpu_to_le32((hba->dma_handle >> 16) >> 16);
@@ -931,6 +945,11 @@ static int stex_handshake(struct st_hba *hba)
931 h->status_cnt = cpu_to_le16(MU_STATUS_COUNT); 945 h->status_cnt = cpu_to_le16(MU_STATUS_COUNT);
932 stex_gettime(&h->hosttime); 946 stex_gettime(&h->hosttime);
933 h->partner_type = HMU_PARTNER_TYPE; 947 h->partner_type = HMU_PARTNER_TYPE;
948 if (hba->dma_size > STEX_BUFFER_SIZE) {
949 h->extra_offset = cpu_to_le32(STEX_BUFFER_SIZE);
950 h->extra_size = cpu_to_le32(ST_ADDITIONAL_MEM);
951 } else
952 h->extra_offset = h->extra_size = 0;
934 953
935 status_phys = hba->dma_handle + MU_REQ_BUFFER_SIZE; 954 status_phys = hba->dma_handle + MU_REQ_BUFFER_SIZE;
936 writel(status_phys, base + IMR0); 955 writel(status_phys, base + IMR0);
@@ -944,19 +963,18 @@ static int stex_handshake(struct st_hba *hba)
944 readl(base + IDBL); /* flush */ 963 readl(base + IDBL); /* flush */
945 964
946 udelay(10); 965 udelay(10);
947 for (i = 0; readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE 966 before = jiffies;
948 && i < MU_MAX_DELAY_TIME; i++) { 967 while (readl(base + OMR0) != MU_HANDSHAKE_SIGNATURE) {
968 if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) {
969 printk(KERN_ERR DRV_NAME
970 "(%s): no signature after handshake frame\n",
971 pci_name(hba->pdev));
972 return -1;
973 }
949 rmb(); 974 rmb();
950 msleep(1); 975 msleep(1);
951 } 976 }
952 977
953 if (i == MU_MAX_DELAY_TIME) {
954 printk(KERN_ERR DRV_NAME
955 "(%s): no signature after handshake frame\n",
956 pci_name(hba->pdev));
957 return -1;
958 }
959
960 writel(0, base + IMR0); 978 writel(0, base + IMR0);
961 readl(base + IMR0); 979 readl(base + IMR0);
962 writel(0, base + OMR0); 980 writel(0, base + OMR0);
@@ -1038,9 +1056,9 @@ static void stex_hard_reset(struct st_hba *hba)
1038 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET; 1056 pci_bctl &= ~PCI_BRIDGE_CTL_BUS_RESET;
1039 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl); 1057 pci_write_config_byte(bus->self, PCI_BRIDGE_CONTROL, pci_bctl);
1040 1058
1041 for (i = 0; i < MU_MAX_DELAY_TIME; i++) { 1059 for (i = 0; i < MU_HARD_RESET_WAIT; i++) {
1042 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd); 1060 pci_read_config_word(hba->pdev, PCI_COMMAND, &pci_cmd);
1043 if (pci_cmd & PCI_COMMAND_MASTER) 1061 if (pci_cmd != 0xffff && (pci_cmd & PCI_COMMAND_MASTER))
1044 break; 1062 break;
1045 msleep(1); 1063 msleep(1);
1046 } 1064 }
@@ -1100,18 +1118,18 @@ static int stex_reset(struct scsi_cmnd *cmd)
1100static int stex_biosparam(struct scsi_device *sdev, 1118static int stex_biosparam(struct scsi_device *sdev,
1101 struct block_device *bdev, sector_t capacity, int geom[]) 1119 struct block_device *bdev, sector_t capacity, int geom[])
1102{ 1120{
1103 int heads = 255, sectors = 63, cylinders; 1121 int heads = 255, sectors = 63;
1104 1122
1105 if (capacity < 0x200000) { 1123 if (capacity < 0x200000) {
1106 heads = 64; 1124 heads = 64;
1107 sectors = 32; 1125 sectors = 32;
1108 } 1126 }
1109 1127
1110 cylinders = sector_div(capacity, heads * sectors); 1128 sector_div(capacity, heads * sectors);
1111 1129
1112 geom[0] = heads; 1130 geom[0] = heads;
1113 geom[1] = sectors; 1131 geom[1] = sectors;
1114 geom[2] = cylinders; 1132 geom[2] = capacity;
1115 1133
1116 return 0; 1134 return 0;
1117} 1135}
@@ -1193,8 +1211,13 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1193 goto out_iounmap; 1211 goto out_iounmap;
1194 } 1212 }
1195 1213
1214 hba->cardtype = (unsigned int) id->driver_data;
1215 if (hba->cardtype == st_vsc && (pdev->subsystem_device & 0xf) == 0x1)
1216 hba->cardtype = st_vsc1;
1217 hba->dma_size = (hba->cardtype == st_vsc1) ?
1218 (STEX_BUFFER_SIZE + ST_ADDITIONAL_MEM) : (STEX_BUFFER_SIZE);
1196 hba->dma_mem = dma_alloc_coherent(&pdev->dev, 1219 hba->dma_mem = dma_alloc_coherent(&pdev->dev,
1197 STEX_BUFFER_SIZE, &hba->dma_handle, GFP_KERNEL); 1220 hba->dma_size, &hba->dma_handle, GFP_KERNEL);
1198 if (!hba->dma_mem) { 1221 if (!hba->dma_mem) {
1199 err = -ENOMEM; 1222 err = -ENOMEM;
1200 printk(KERN_ERR DRV_NAME "(%s): dma mem alloc failed\n", 1223 printk(KERN_ERR DRV_NAME "(%s): dma mem alloc failed\n",
@@ -1207,8 +1230,6 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1207 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE; 1230 hba->copy_buffer = hba->dma_mem + MU_BUFFER_SIZE;
1208 hba->mu_status = MU_STATE_STARTING; 1231 hba->mu_status = MU_STATE_STARTING;
1209 1232
1210 hba->cardtype = (unsigned int) id->driver_data;
1211
1212 /* firmware uses id/lun pair for a logical drive, but lun would be 1233 /* firmware uses id/lun pair for a logical drive, but lun would be
1213 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use 1234 always 0 if CONFIG_SCSI_MULTI_LUN not configured, so we use
1214 channel to map lun here */ 1235 channel to map lun here */
@@ -1233,7 +1254,7 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1233 if (err) 1254 if (err)
1234 goto out_free_irq; 1255 goto out_free_irq;
1235 1256
1236 err = scsi_init_shared_tag_map(host, ST_CAN_QUEUE); 1257 err = scsi_init_shared_tag_map(host, host->can_queue);
1237 if (err) { 1258 if (err) {
1238 printk(KERN_ERR DRV_NAME "(%s): init shared queue failed\n", 1259 printk(KERN_ERR DRV_NAME "(%s): init shared queue failed\n",
1239 pci_name(pdev)); 1260 pci_name(pdev));
@@ -1256,7 +1277,7 @@ stex_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1256out_free_irq: 1277out_free_irq:
1257 free_irq(pdev->irq, hba); 1278 free_irq(pdev->irq, hba);
1258out_pci_free: 1279out_pci_free:
1259 dma_free_coherent(&pdev->dev, STEX_BUFFER_SIZE, 1280 dma_free_coherent(&pdev->dev, hba->dma_size,
1260 hba->dma_mem, hba->dma_handle); 1281 hba->dma_mem, hba->dma_handle);
1261out_iounmap: 1282out_iounmap:
1262 iounmap(hba->mmio_base); 1283 iounmap(hba->mmio_base);
@@ -1317,7 +1338,7 @@ static void stex_hba_free(struct st_hba *hba)
1317 1338
1318 pci_release_regions(hba->pdev); 1339 pci_release_regions(hba->pdev);
1319 1340
1320 dma_free_coherent(&hba->pdev->dev, STEX_BUFFER_SIZE, 1341 dma_free_coherent(&hba->pdev->dev, hba->dma_size,
1321 hba->dma_mem, hba->dma_handle); 1342 hba->dma_mem, hba->dma_handle);
1322} 1343}
1323 1344
@@ -1346,15 +1367,32 @@ static void stex_shutdown(struct pci_dev *pdev)
1346} 1367}
1347 1368
1348static struct pci_device_id stex_pci_tbl[] = { 1369static struct pci_device_id stex_pci_tbl[] = {
1349 { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1370 /* st_shasta */
1350 { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1371 { 0x105a, 0x8350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1351 { 0x105a, 0xf350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1372 st_shasta }, /* SuperTrak EX8350/8300/16350/16300 */
1352 { 0x105a, 0x4301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1373 { 0x105a, 0xc350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1353 { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1374 st_shasta }, /* SuperTrak EX12350 */
1354 { 0x105a, 0x8301, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1375 { 0x105a, 0x4302, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1355 { 0x105a, 0x8302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_shasta }, 1376 st_shasta }, /* SuperTrak EX4350 */
1356 { 0x1725, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc }, 1377 { 0x105a, 0xe350, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1357 { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_yosemite }, 1378 st_shasta }, /* SuperTrak EX24350 */
1379
1380 /* st_vsc */
1381 { 0x105a, 0x7250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, st_vsc },
1382
1383 /* st_yosemite */
1384 { 0x105a, 0x8650, PCI_ANY_ID, 0x4600, 0, 0,
1385 st_yosemite }, /* SuperTrak EX4650 */
1386 { 0x105a, 0x8650, PCI_ANY_ID, 0x4610, 0, 0,
1387 st_yosemite }, /* SuperTrak EX4650o */
1388 { 0x105a, 0x8650, PCI_ANY_ID, 0x8600, 0, 0,
1389 st_yosemite }, /* SuperTrak EX8650EL */
1390 { 0x105a, 0x8650, PCI_ANY_ID, 0x8601, 0, 0,
1391 st_yosemite }, /* SuperTrak EX8650 */
1392 { 0x105a, 0x8650, PCI_ANY_ID, 0x8602, 0, 0,
1393 st_yosemite }, /* SuperTrak EX8654 */
1394 { 0x105a, 0x8650, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1395 st_yosemite }, /* generic st_yosemite */
1358 { } /* terminate list */ 1396 { } /* terminate list */
1359}; 1397};
1360MODULE_DEVICE_TABLE(pci, stex_pci_tbl); 1398MODULE_DEVICE_TABLE(pci, stex_pci_tbl);
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index 646e840266e2..76a069b7ac0b 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -8,20 +8,20 @@
8 * drew@colorado.edu 8 * drew@colorado.edu
9 * +1 (303) 440-4894 9 * +1 (303) 440-4894
10 * 10 *
11 * DISTRIBUTION RELEASE 3. 11 * DISTRIBUTION RELEASE 3.
12 * 12 *
13 * For more information, please consult 13 * For more information, please consult
14 * 14 *
15 * Trantor Systems, Ltd. 15 * Trantor Systems, Ltd.
16 * T128/T128F/T228 SCSI Host Adapter 16 * T128/T128F/T228 SCSI Host Adapter
17 * Hardware Specifications 17 * Hardware Specifications
18 * 18 *
19 * Trantor Systems, Ltd. 19 * Trantor Systems, Ltd.
20 * 5415 Randall Place 20 * 5415 Randall Place
21 * Fremont, CA 94538 21 * Fremont, CA 94538
22 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910 22 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
23 * 23 *
24 * and 24 * and
25 * 25 *
26 * NCR 5380 Family 26 * NCR 5380 Family
27 * SCSI Protocol Controller 27 * SCSI Protocol Controller
@@ -48,15 +48,15 @@
48#define TDEBUG_TRANSFER 0x2 48#define TDEBUG_TRANSFER 0x2
49 49
50/* 50/*
51 * The trantor boards are memory mapped. They use an NCR5380 or 51 * The trantor boards are memory mapped. They use an NCR5380 or
52 * equivalent (my sample board had part second sourced from ZILOG). 52 * equivalent (my sample board had part second sourced from ZILOG).
53 * NCR's recommended "Pseudo-DMA" architecture is used, where 53 * NCR's recommended "Pseudo-DMA" architecture is used, where
54 * a PAL drives the DMA signals on the 5380 allowing fast, blind 54 * a PAL drives the DMA signals on the 5380 allowing fast, blind
55 * transfers with proper handshaking. 55 * transfers with proper handshaking.
56 */ 56 */
57 57
58/* 58/*
59 * Note : a boot switch is provided for the purpose of informing the 59 * Note : a boot switch is provided for the purpose of informing the
60 * firmware to boot or not boot from attached SCSI devices. So, I imagine 60 * firmware to boot or not boot from attached SCSI devices. So, I imagine
61 * there are fewer people who've yanked the ROM like they do on the Seagate 61 * there are fewer people who've yanked the ROM like they do on the Seagate
62 * to make bootup faster, and I'll probably use this for autodetection. 62 * to make bootup faster, and I'll probably use this for autodetection.
@@ -92,19 +92,20 @@
92#define T_DATA_REG_OFFSET 0x1e00 /* rw 512 bytes long */ 92#define T_DATA_REG_OFFSET 0x1e00 /* rw 512 bytes long */
93 93
94#ifndef ASM 94#ifndef ASM
95static int t128_abort(Scsi_Cmnd *); 95static int t128_abort(struct scsi_cmnd *);
96static int t128_biosparam(struct scsi_device *, struct block_device *, 96static int t128_biosparam(struct scsi_device *, struct block_device *,
97 sector_t, int*); 97 sector_t, int*);
98static int t128_detect(struct scsi_host_template *); 98static int t128_detect(struct scsi_host_template *);
99static int t128_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 99static int t128_queue_command(struct scsi_cmnd *,
100static int t128_bus_reset(Scsi_Cmnd *); 100 void (*done)(struct scsi_cmnd *));
101static int t128_bus_reset(struct scsi_cmnd *);
101 102
102#ifndef CMD_PER_LUN 103#ifndef CMD_PER_LUN
103#define CMD_PER_LUN 2 104#define CMD_PER_LUN 2
104#endif 105#endif
105 106
106#ifndef CAN_QUEUE 107#ifndef CAN_QUEUE
107#define CAN_QUEUE 32 108#define CAN_QUEUE 32
108#endif 109#endif
109 110
110#ifndef HOSTS_C 111#ifndef HOSTS_C
@@ -120,7 +121,7 @@ static int t128_bus_reset(Scsi_Cmnd *);
120 121
121#define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20)) 122#define T128_address(reg) (base + T_5380_OFFSET + ((reg) * 0x20))
122 123
123#if !(TDEBUG & TDEBUG_TRANSFER) 124#if !(TDEBUG & TDEBUG_TRANSFER)
124#define NCR5380_read(reg) readb(T128_address(reg)) 125#define NCR5380_read(reg) readb(T128_address(reg))
125#define NCR5380_write(reg, value) writeb((value),(T128_address(reg))) 126#define NCR5380_write(reg, value) writeb((value),(T128_address(reg)))
126#else 127#else
@@ -129,7 +130,7 @@ static int t128_bus_reset(Scsi_Cmnd *);
129 , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg))) 130 , instance->hostno, (reg), T128_address(reg))), readb(T128_address(reg)))
130 131
131#define NCR5380_write(reg, value) { \ 132#define NCR5380_write(reg, value) { \
132 printk("scsi%d : write %02x to register %d at address %08x\n", \ 133 printk("scsi%d : write %02x to register %d at address %08x\n", \
133 instance->hostno, (value), (reg), T128_address(reg)); \ 134 instance->hostno, (value), (reg), T128_address(reg)); \
134 writeb((value), (T128_address(reg))); \ 135 writeb((value), (T128_address(reg))); \
135} 136}
@@ -142,10 +143,10 @@ static int t128_bus_reset(Scsi_Cmnd *);
142#define NCR5380_bus_reset t128_bus_reset 143#define NCR5380_bus_reset t128_bus_reset
143#define NCR5380_proc_info t128_proc_info 144#define NCR5380_proc_info t128_proc_info
144 145
145/* 15 14 12 10 7 5 3 146/* 15 14 12 10 7 5 3
146 1101 0100 1010 1000 */ 147 1101 0100 1010 1000 */
147 148
148#define T128_IRQS 0xc4a8 149#define T128_IRQS 0xc4a8
149 150
150#endif /* else def HOSTS_C */ 151#endif /* else def HOSTS_C */
151#endif /* ndef ASM */ 152#endif /* ndef ASM */
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index b691d3e14754..787a8f134677 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -282,7 +282,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
282} 282}
283 283
284/* Setup any dynamic params in the uart desc */ 284/* Setup any dynamic params in the uart desc */
285int cpm_uart_init_portdesc(void) 285int __init cpm_uart_init_portdesc(void)
286{ 286{
287#if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) 287#if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2)
288 u32 addr; 288 u32 addr;
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index aee1b31f1a1c..3db206d29b33 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -60,7 +60,8 @@ struct timer_list mcfrs_timer_struct;
60#if defined(CONFIG_HW_FEITH) 60#if defined(CONFIG_HW_FEITH)
61#define CONSOLE_BAUD_RATE 38400 61#define CONSOLE_BAUD_RATE 38400
62#define DEFAULT_CBAUD B38400 62#define DEFAULT_CBAUD B38400
63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || defined(CONFIG_M5329EVB) 63#elif defined(CONFIG_MOD5272) || defined(CONFIG_M5208EVB) || \
64 defined(CONFIG_M5329EVB) || defined(CONFIG_GILBARCO)
64#define CONSOLE_BAUD_RATE 115200 65#define CONSOLE_BAUD_RATE 115200
65#define DEFAULT_CBAUD B115200 66#define DEFAULT_CBAUD B115200
66#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \ 67#elif defined(CONFIG_ARNEWSH) || defined(CONFIG_FREESCALE) || \
@@ -109,12 +110,30 @@ static struct mcf_serial mcfrs_table[] = {
109 .irq = IRQBASE, 110 .irq = IRQBASE,
110 .flags = ASYNC_BOOT_AUTOCONF, 111 .flags = ASYNC_BOOT_AUTOCONF,
111 }, 112 },
113#ifdef MCFUART_BASE2
112 { /* ttyS1 */ 114 { /* ttyS1 */
113 .magic = 0, 115 .magic = 0,
114 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2), 116 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE2),
115 .irq = IRQBASE+1, 117 .irq = IRQBASE+1,
116 .flags = ASYNC_BOOT_AUTOCONF, 118 .flags = ASYNC_BOOT_AUTOCONF,
117 }, 119 },
120#endif
121#ifdef MCFUART_BASE3
122 { /* ttyS2 */
123 .magic = 0,
124 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE3),
125 .irq = IRQBASE+2,
126 .flags = ASYNC_BOOT_AUTOCONF,
127 },
128#endif
129#ifdef MCFUART_BASE4
130 { /* ttyS3 */
131 .magic = 0,
132 .addr = (volatile unsigned char *) (MCF_MBAR+MCFUART_BASE4),
133 .irq = IRQBASE+3,
134 .flags = ASYNC_BOOT_AUTOCONF,
135 },
136#endif
118}; 137};
119 138
120 139
@@ -1516,6 +1535,22 @@ static void mcfrs_irqinit(struct mcf_serial *info)
1516 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 + 1535 imrp = (volatile unsigned long *) (MCF_MBAR + MCFICM_INTC0 +
1517 MCFINTC_IMRL); 1536 MCFINTC_IMRL);
1518 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1); 1537 *imrp &= ~((1 << (info->irq - MCFINT_VECBASE)) | 1);
1538#if defined(CONFIG_M527x)
1539 {
1540 /*
1541 * External Pin Mask Setting & Enable External Pin for Interface
1542 * mrcbis@aliceposta.it
1543 */
1544 unsigned short *serpin_enable_mask;
1545 serpin_enable_mask = (MCF_IPSBAR + MCF_GPIO_PAR_UART);
1546 if (info->line == 0)
1547 *serpin_enable_mask |= UART0_ENABLE_MASK;
1548 else if (info->line == 1)
1549 *serpin_enable_mask |= UART1_ENABLE_MASK;
1550 else if (info->line == 2)
1551 *serpin_enable_mask |= UART2_ENABLE_MASK;
1552 }
1553#endif
1519#elif defined(CONFIG_M520x) 1554#elif defined(CONFIG_M520x)
1520 volatile unsigned char *icrp, *uartp; 1555 volatile unsigned char *icrp, *uartp;
1521 volatile unsigned long *imrp; 1556 volatile unsigned long *imrp;
@@ -1713,7 +1748,7 @@ mcfrs_init(void)
1713 /* Initialize the tty_driver structure */ 1748 /* Initialize the tty_driver structure */
1714 mcfrs_serial_driver->owner = THIS_MODULE; 1749 mcfrs_serial_driver->owner = THIS_MODULE;
1715 mcfrs_serial_driver->name = "ttyS"; 1750 mcfrs_serial_driver->name = "ttyS";
1716 mcfrs_serial_driver->driver_name = "serial"; 1751 mcfrs_serial_driver->driver_name = "mcfserial";
1717 mcfrs_serial_driver->major = TTY_MAJOR; 1752 mcfrs_serial_driver->major = TTY_MAJOR;
1718 mcfrs_serial_driver->minor_start = 64; 1753 mcfrs_serial_driver->minor_start = 64;
1719 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; 1754 mcfrs_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
@@ -1797,10 +1832,23 @@ void mcfrs_init_console(void)
1797 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8; 1832 uartp[MCFUART_UMR] = MCFUART_MR1_PARITYNONE | MCFUART_MR1_CS8;
1798 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1; 1833 uartp[MCFUART_UMR] = MCFUART_MR2_STOP1;
1799 1834
1835#ifdef CONFIG_M5272
1836{
1837 /*
1838 * For the MCF5272, also compute the baudrate fraction.
1839 */
1840 int fraction = MCF_BUSCLK - (clk * 32 * mcfrs_console_baud);
1841 fraction *= 16;
1842 fraction /= (32 * mcfrs_console_baud);
1843 uartp[MCFUART_UFPD] = (fraction & 0xf); /* set fraction */
1844 clk = (MCF_BUSCLK / mcfrs_console_baud) / 32;
1845}
1846#else
1800 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */ 1847 clk = ((MCF_BUSCLK / mcfrs_console_baud) + 16) / 32; /* set baud */
1848#endif
1849
1801 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */ 1850 uartp[MCFUART_UBG1] = (clk & 0xff00) >> 8; /* set msb baud */
1802 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */ 1851 uartp[MCFUART_UBG2] = (clk & 0xff); /* set lsb baud */
1803
1804 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER; 1852 uartp[MCFUART_UCSR] = MCFUART_UCSR_RXCLKTIMER | MCFUART_UCSR_TXCLKTIMER;
1805 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE; 1853 uartp[MCFUART_UCR] = MCFUART_UCR_RXENABLE | MCFUART_UCR_TXENABLE;
1806 1854
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 4f80c5b4a753..6dd579ed9777 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/serial/mpc52xx_uart.c
3 *
4 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs. 2 * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs.
5 * 3 *
6 * FIXME According to the usermanual the status bits in the status register 4 * FIXME According to the usermanual the status bits in the status register
@@ -14,18 +12,20 @@
14 * 12 *
15 * 13 *
16 * Maintainer : Sylvain Munaut <tnt@246tNt.com> 14 * Maintainer : Sylvain Munaut <tnt@246tNt.com>
17 * 15 *
18 * Some of the code has been inspired/copied from the 2.4 code written 16 * Some of the code has been inspired/copied from the 2.4 code written
19 * by Dale Farnsworth <dfarnsworth@mvista.com>. 17 * by Dale Farnsworth <dfarnsworth@mvista.com>.
20 * 18 *
21 * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com> 19 * Copyright (C) 2006 Secret Lab Technologies Ltd.
20 * Grant Likely <grant.likely@secretlab.ca>
21 * Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com>
22 * Copyright (C) 2003 MontaVista, Software, Inc. 22 * Copyright (C) 2003 MontaVista, Software, Inc.
23 * 23 *
24 * This file is licensed under the terms of the GNU General Public License 24 * This file is licensed under the terms of the GNU General Public License
25 * version 2. This program is licensed "as is" without any warranty of any 25 * version 2. This program is licensed "as is" without any warranty of any
26 * kind, whether express or implied. 26 * kind, whether express or implied.
27 */ 27 */
28 28
29/* Platform device Usage : 29/* Platform device Usage :
30 * 30 *
31 * Since PSCs can have multiple function, the correct driver for each one 31 * Since PSCs can have multiple function, the correct driver for each one
@@ -44,7 +44,24 @@
44 * will be mapped to. 44 * will be mapped to.
45 */ 45 */
46 46
47#include <linux/platform_device.h> 47/* OF Platform device Usage :
48 *
49 * This driver is only used for PSCs configured in uart mode. The device
50 * tree will have a node for each PSC in uart mode w/ device_type = "serial"
51 * and "mpc52xx-psc-uart" in the compatible string
52 *
53 * By default, PSC devices are enumerated in the order they are found. However
54 * a particular PSC number can be forces by adding 'device_no = <port#>'
55 * to the device node.
56 *
57 * The driver init all necessary registers to place the PSC in uart mode without
58 * DCD. However, the pin multiplexing aren't changed and should be set either
59 * by the bootloader or in the platform init code.
60 */
61
62#undef DEBUG
63
64#include <linux/device.h>
48#include <linux/module.h> 65#include <linux/module.h>
49#include <linux/tty.h> 66#include <linux/tty.h>
50#include <linux/serial.h> 67#include <linux/serial.h>
@@ -54,6 +71,12 @@
54#include <asm/delay.h> 71#include <asm/delay.h>
55#include <asm/io.h> 72#include <asm/io.h>
56 73
74#if defined(CONFIG_PPC_MERGE)
75#include <asm/of_platform.h>
76#else
77#include <linux/platform_device.h>
78#endif
79
57#include <asm/mpc52xx.h> 80#include <asm/mpc52xx.h>
58#include <asm/mpc52xx_psc.h> 81#include <asm/mpc52xx_psc.h>
59 82
@@ -80,6 +103,12 @@ static struct uart_port mpc52xx_uart_ports[MPC52xx_PSC_MAXNUM];
80 * it's cleared, then a memset(...,0,...) should be added to 103 * it's cleared, then a memset(...,0,...) should be added to
81 * the console_init 104 * the console_init
82 */ 105 */
106#if defined(CONFIG_PPC_MERGE)
107/* lookup table for matching device nodes to index numbers */
108static struct device_node *mpc52xx_uart_nodes[MPC52xx_PSC_MAXNUM];
109
110static void mpc52xx_uart_of_enumerate(void);
111#endif
83 112
84#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) 113#define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase))
85 114
@@ -96,32 +125,40 @@ static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id);
96#define uart_console(port) (0) 125#define uart_console(port) (0)
97#endif 126#endif
98 127
128#if defined(CONFIG_PPC_MERGE)
129static struct of_device_id mpc52xx_uart_of_match[] = {
130 { .type = "serial", .compatible = "mpc52xx-psc-uart", },
131 { .type = "serial", .compatible = "mpc5200-psc", }, /* Efika only! */
132 {},
133};
134#endif
135
99 136
100/* ======================================================================== */ 137/* ======================================================================== */
101/* UART operations */ 138/* UART operations */
102/* ======================================================================== */ 139/* ======================================================================== */
103 140
104static unsigned int 141static unsigned int
105mpc52xx_uart_tx_empty(struct uart_port *port) 142mpc52xx_uart_tx_empty(struct uart_port *port)
106{ 143{
107 int status = in_be16(&PSC(port)->mpc52xx_psc_status); 144 int status = in_be16(&PSC(port)->mpc52xx_psc_status);
108 return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0; 145 return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0;
109} 146}
110 147
111static void 148static void
112mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) 149mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
113{ 150{
114 /* Not implemented */ 151 /* Not implemented */
115} 152}
116 153
117static unsigned int 154static unsigned int
118mpc52xx_uart_get_mctrl(struct uart_port *port) 155mpc52xx_uart_get_mctrl(struct uart_port *port)
119{ 156{
120 /* Not implemented */ 157 /* Not implemented */
121 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; 158 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
122} 159}
123 160
124static void 161static void
125mpc52xx_uart_stop_tx(struct uart_port *port) 162mpc52xx_uart_stop_tx(struct uart_port *port)
126{ 163{
127 /* port->lock taken by caller */ 164 /* port->lock taken by caller */
@@ -129,7 +166,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port)
129 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 166 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
130} 167}
131 168
132static void 169static void
133mpc52xx_uart_start_tx(struct uart_port *port) 170mpc52xx_uart_start_tx(struct uart_port *port)
134{ 171{
135 /* port->lock taken by caller */ 172 /* port->lock taken by caller */
@@ -137,12 +174,12 @@ mpc52xx_uart_start_tx(struct uart_port *port)
137 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 174 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
138} 175}
139 176
140static void 177static void
141mpc52xx_uart_send_xchar(struct uart_port *port, char ch) 178mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
142{ 179{
143 unsigned long flags; 180 unsigned long flags;
144 spin_lock_irqsave(&port->lock, flags); 181 spin_lock_irqsave(&port->lock, flags);
145 182
146 port->x_char = ch; 183 port->x_char = ch;
147 if (ch) { 184 if (ch) {
148 /* Make sure tx interrupts are on */ 185 /* Make sure tx interrupts are on */
@@ -150,7 +187,7 @@ mpc52xx_uart_send_xchar(struct uart_port *port, char ch)
150 port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; 187 port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY;
151 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); 188 out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask);
152 } 189 }
153 190
154 spin_unlock_irqrestore(&port->lock, flags); 191 spin_unlock_irqrestore(&port->lock, flags);
155} 192}
156 193
@@ -178,7 +215,7 @@ mpc52xx_uart_break_ctl(struct uart_port *port, int ctl)
178 out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); 215 out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK);
179 else 216 else
180 out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); 217 out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK);
181 218
182 spin_unlock_irqrestore(&port->lock, flags); 219 spin_unlock_irqrestore(&port->lock, flags);
183} 220}
184 221
@@ -197,11 +234,11 @@ mpc52xx_uart_startup(struct uart_port *port)
197 /* Reset/activate the port, clear and enable interrupts */ 234 /* Reset/activate the port, clear and enable interrupts */
198 out_8(&psc->command,MPC52xx_PSC_RST_RX); 235 out_8(&psc->command,MPC52xx_PSC_RST_RX);
199 out_8(&psc->command,MPC52xx_PSC_RST_TX); 236 out_8(&psc->command,MPC52xx_PSC_RST_TX);
200 237
201 out_be32(&psc->sicr,0); /* UART mode DCD ignored */ 238 out_be32(&psc->sicr,0); /* UART mode DCD ignored */
202 239
203 out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ 240 out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */
204 241
205 out_8(&psc->rfcntl, 0x00); 242 out_8(&psc->rfcntl, 0x00);
206 out_be16(&psc->rfalarm, 0x1ff); 243 out_be16(&psc->rfalarm, 0x1ff);
207 out_8(&psc->tfcntl, 0x07); 244 out_8(&psc->tfcntl, 0x07);
@@ -209,10 +246,10 @@ mpc52xx_uart_startup(struct uart_port *port)
209 246
210 port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; 247 port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY;
211 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); 248 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
212 249
213 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); 250 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
214 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); 251 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
215 252
216 return 0; 253 return 0;
217} 254}
218 255
@@ -220,19 +257,19 @@ static void
220mpc52xx_uart_shutdown(struct uart_port *port) 257mpc52xx_uart_shutdown(struct uart_port *port)
221{ 258{
222 struct mpc52xx_psc __iomem *psc = PSC(port); 259 struct mpc52xx_psc __iomem *psc = PSC(port);
223 260
224 /* Shut down the port, interrupt and all */ 261 /* Shut down the port, interrupt and all */
225 out_8(&psc->command,MPC52xx_PSC_RST_RX); 262 out_8(&psc->command,MPC52xx_PSC_RST_RX);
226 out_8(&psc->command,MPC52xx_PSC_RST_TX); 263 out_8(&psc->command,MPC52xx_PSC_RST_TX);
227 264
228 port->read_status_mask = 0; 265 port->read_status_mask = 0;
229 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); 266 out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask);
230 267
231 /* Release interrupt */ 268 /* Release interrupt */
232 free_irq(port->irq, port); 269 free_irq(port->irq, port);
233} 270}
234 271
235static void 272static void
236mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, 273mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
237 struct termios *old) 274 struct termios *old)
238{ 275{
@@ -241,10 +278,10 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
241 unsigned char mr1, mr2; 278 unsigned char mr1, mr2;
242 unsigned short ctr; 279 unsigned short ctr;
243 unsigned int j, baud, quot; 280 unsigned int j, baud, quot;
244 281
245 /* Prepare what we're gonna write */ 282 /* Prepare what we're gonna write */
246 mr1 = 0; 283 mr1 = 0;
247 284
248 switch (new->c_cflag & CSIZE) { 285 switch (new->c_cflag & CSIZE) {
249 case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; 286 case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS;
250 break; 287 break;
@@ -261,8 +298,8 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
261 MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN; 298 MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN;
262 } else 299 } else
263 mr1 |= MPC52xx_PSC_MODE_PARNONE; 300 mr1 |= MPC52xx_PSC_MODE_PARNONE;
264 301
265 302
266 mr2 = 0; 303 mr2 = 0;
267 304
268 if (new->c_cflag & CSTOPB) 305 if (new->c_cflag & CSTOPB)
@@ -276,7 +313,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
276 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); 313 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16);
277 quot = uart_get_divisor(port, baud); 314 quot = uart_get_divisor(port, baud);
278 ctr = quot & 0xffff; 315 ctr = quot & 0xffff;
279 316
280 /* Get the lock */ 317 /* Get the lock */
281 spin_lock_irqsave(&port->lock, flags); 318 spin_lock_irqsave(&port->lock, flags);
282 319
@@ -290,14 +327,14 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
290 * boot for the console, all stuff is not yet ready to receive at that 327 * boot for the console, all stuff is not yet ready to receive at that
291 * time and that just makes the kernel oops */ 328 * time and that just makes the kernel oops */
292 /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */ 329 /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */
293 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 330 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) &&
294 --j) 331 --j)
295 udelay(1); 332 udelay(1);
296 333
297 if (!j) 334 if (!j)
298 printk( KERN_ERR "mpc52xx_uart.c: " 335 printk( KERN_ERR "mpc52xx_uart.c: "
299 "Unable to flush RX & TX fifos in-time in set_termios." 336 "Unable to flush RX & TX fifos in-time in set_termios."
300 "Some chars may have been lost.\n" ); 337 "Some chars may have been lost.\n" );
301 338
302 /* Reset the TX & RX */ 339 /* Reset the TX & RX */
303 out_8(&psc->command,MPC52xx_PSC_RST_RX); 340 out_8(&psc->command,MPC52xx_PSC_RST_RX);
@@ -309,7 +346,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new,
309 out_8(&psc->mode,mr2); 346 out_8(&psc->mode,mr2);
310 out_8(&psc->ctur,ctr >> 8); 347 out_8(&psc->ctur,ctr >> 8);
311 out_8(&psc->ctlr,ctr & 0xff); 348 out_8(&psc->ctlr,ctr & 0xff);
312 349
313 /* Reenable TX & RX */ 350 /* Reenable TX & RX */
314 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); 351 out_8(&psc->command,MPC52xx_PSC_TX_ENABLE);
315 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); 352 out_8(&psc->command,MPC52xx_PSC_RX_ENABLE);
@@ -332,7 +369,7 @@ mpc52xx_uart_release_port(struct uart_port *port)
332 port->membase = NULL; 369 port->membase = NULL;
333 } 370 }
334 371
335 release_mem_region(port->mapbase, MPC52xx_PSC_SIZE); 372 release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc));
336} 373}
337 374
338static int 375static int
@@ -341,12 +378,13 @@ mpc52xx_uart_request_port(struct uart_port *port)
341 int err; 378 int err;
342 379
343 if (port->flags & UPF_IOREMAP) /* Need to remap ? */ 380 if (port->flags & UPF_IOREMAP) /* Need to remap ? */
344 port->membase = ioremap(port->mapbase, MPC52xx_PSC_SIZE); 381 port->membase = ioremap(port->mapbase,
382 sizeof(struct mpc52xx_psc));
345 383
346 if (!port->membase) 384 if (!port->membase)
347 return -EINVAL; 385 return -EINVAL;
348 386
349 err = request_mem_region(port->mapbase, MPC52xx_PSC_SIZE, 387 err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc),
350 "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY; 388 "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY;
351 389
352 if (err && (port->flags & UPF_IOREMAP)) { 390 if (err && (port->flags & UPF_IOREMAP)) {
@@ -373,7 +411,7 @@ mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser)
373 411
374 if ( (ser->irq != port->irq) || 412 if ( (ser->irq != port->irq) ||
375 (ser->io_type != SERIAL_IO_MEM) || 413 (ser->io_type != SERIAL_IO_MEM) ||
376 (ser->baud_base != port->uartclk) || 414 (ser->baud_base != port->uartclk) ||
377 (ser->iomem_base != (void*)port->mapbase) || 415 (ser->iomem_base != (void*)port->mapbase) ||
378 (ser->hub6 != 0 ) ) 416 (ser->hub6 != 0 ) )
379 return -EINVAL; 417 return -EINVAL;
@@ -404,11 +442,11 @@ static struct uart_ops mpc52xx_uart_ops = {
404 .verify_port = mpc52xx_uart_verify_port 442 .verify_port = mpc52xx_uart_verify_port
405}; 443};
406 444
407 445
408/* ======================================================================== */ 446/* ======================================================================== */
409/* Interrupt handling */ 447/* Interrupt handling */
410/* ======================================================================== */ 448/* ======================================================================== */
411 449
412static inline int 450static inline int
413mpc52xx_uart_int_rx_chars(struct uart_port *port) 451mpc52xx_uart_int_rx_chars(struct uart_port *port)
414{ 452{
@@ -435,11 +473,11 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
435 473
436 flag = TTY_NORMAL; 474 flag = TTY_NORMAL;
437 port->icount.rx++; 475 port->icount.rx++;
438 476
439 if ( status & (MPC52xx_PSC_SR_PE | 477 if ( status & (MPC52xx_PSC_SR_PE |
440 MPC52xx_PSC_SR_FE | 478 MPC52xx_PSC_SR_FE |
441 MPC52xx_PSC_SR_RB) ) { 479 MPC52xx_PSC_SR_RB) ) {
442 480
443 if (status & MPC52xx_PSC_SR_RB) { 481 if (status & MPC52xx_PSC_SR_RB) {
444 flag = TTY_BREAK; 482 flag = TTY_BREAK;
445 uart_handle_break(port); 483 uart_handle_break(port);
@@ -464,7 +502,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
464 } 502 }
465 503
466 tty_flip_buffer_push(tty); 504 tty_flip_buffer_push(tty);
467 505
468 return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY; 506 return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY;
469} 507}
470 508
@@ -509,25 +547,25 @@ mpc52xx_uart_int_tx_chars(struct uart_port *port)
509 return 1; 547 return 1;
510} 548}
511 549
512static irqreturn_t 550static irqreturn_t
513mpc52xx_uart_int(int irq, void *dev_id) 551mpc52xx_uart_int(int irq, void *dev_id)
514{ 552{
515 struct uart_port *port = dev_id; 553 struct uart_port *port = dev_id;
516 unsigned long pass = ISR_PASS_LIMIT; 554 unsigned long pass = ISR_PASS_LIMIT;
517 unsigned int keepgoing; 555 unsigned int keepgoing;
518 unsigned short status; 556 unsigned short status;
519 557
520 spin_lock(&port->lock); 558 spin_lock(&port->lock);
521 559
522 /* While we have stuff to do, we continue */ 560 /* While we have stuff to do, we continue */
523 do { 561 do {
524 /* If we don't find anything to do, we stop */ 562 /* If we don't find anything to do, we stop */
525 keepgoing = 0; 563 keepgoing = 0;
526 564
527 /* Read status */ 565 /* Read status */
528 status = in_be16(&PSC(port)->mpc52xx_psc_isr); 566 status = in_be16(&PSC(port)->mpc52xx_psc_isr);
529 status &= port->read_status_mask; 567 status &= port->read_status_mask;
530 568
531 /* Do we need to receive chars ? */ 569 /* Do we need to receive chars ? */
532 /* For this RX interrupts must be on and some chars waiting */ 570 /* For this RX interrupts must be on and some chars waiting */
533 if ( status & MPC52xx_PSC_IMR_RXRDY ) 571 if ( status & MPC52xx_PSC_IMR_RXRDY )
@@ -537,15 +575,15 @@ mpc52xx_uart_int(int irq, void *dev_id)
537 /* For this, TX must be ready and TX interrupt enabled */ 575 /* For this, TX must be ready and TX interrupt enabled */
538 if ( status & MPC52xx_PSC_IMR_TXRDY ) 576 if ( status & MPC52xx_PSC_IMR_TXRDY )
539 keepgoing |= mpc52xx_uart_int_tx_chars(port); 577 keepgoing |= mpc52xx_uart_int_tx_chars(port);
540 578
541 /* Limit number of iteration */ 579 /* Limit number of iteration */
542 if ( !(--pass) ) 580 if ( !(--pass) )
543 keepgoing = 0; 581 keepgoing = 0;
544 582
545 } while (keepgoing); 583 } while (keepgoing);
546 584
547 spin_unlock(&port->lock); 585 spin_unlock(&port->lock);
548 586
549 return IRQ_HANDLED; 587 return IRQ_HANDLED;
550} 588}
551 589
@@ -563,13 +601,18 @@ mpc52xx_console_get_options(struct uart_port *port,
563 struct mpc52xx_psc __iomem *psc = PSC(port); 601 struct mpc52xx_psc __iomem *psc = PSC(port);
564 unsigned char mr1; 602 unsigned char mr1;
565 603
604 pr_debug("mpc52xx_console_get_options(port=%p)\n", port);
605
566 /* Read the mode registers */ 606 /* Read the mode registers */
567 out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); 607 out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1);
568 mr1 = in_8(&psc->mode); 608 mr1 = in_8(&psc->mode);
569 609
570 /* CT{U,L}R are write-only ! */ 610 /* CT{U,L}R are write-only ! */
571 *baud = __res.bi_baudrate ? 611 *baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;
572 __res.bi_baudrate : CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD; 612#if !defined(CONFIG_PPC_MERGE)
613 if (__res.bi_baudrate)
614 *baud = __res.bi_baudrate;
615#endif
573 616
574 /* Parse them */ 617 /* Parse them */
575 switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { 618 switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) {
@@ -579,26 +622,26 @@ mpc52xx_console_get_options(struct uart_port *port,
579 case MPC52xx_PSC_MODE_8_BITS: 622 case MPC52xx_PSC_MODE_8_BITS:
580 default: *bits = 8; 623 default: *bits = 8;
581 } 624 }
582 625
583 if (mr1 & MPC52xx_PSC_MODE_PARNONE) 626 if (mr1 & MPC52xx_PSC_MODE_PARNONE)
584 *parity = 'n'; 627 *parity = 'n';
585 else 628 else
586 *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e'; 629 *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e';
587} 630}
588 631
589static void 632static void
590mpc52xx_console_write(struct console *co, const char *s, unsigned int count) 633mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
591{ 634{
592 struct uart_port *port = &mpc52xx_uart_ports[co->index]; 635 struct uart_port *port = &mpc52xx_uart_ports[co->index];
593 struct mpc52xx_psc __iomem *psc = PSC(port); 636 struct mpc52xx_psc __iomem *psc = PSC(port);
594 unsigned int i, j; 637 unsigned int i, j;
595 638
596 /* Disable interrupts */ 639 /* Disable interrupts */
597 out_be16(&psc->mpc52xx_psc_imr, 0); 640 out_be16(&psc->mpc52xx_psc_imr, 0);
598 641
599 /* Wait the TX buffer to be empty */ 642 /* Wait the TX buffer to be empty */
600 j = 5000000; /* Maximum wait */ 643 j = 5000000; /* Maximum wait */
601 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && 644 while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) &&
602 --j) 645 --j)
603 udelay(1); 646 udelay(1);
604 647
@@ -607,13 +650,13 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
607 /* Line return handling */ 650 /* Line return handling */
608 if (*s == '\n') 651 if (*s == '\n')
609 out_8(&psc->mpc52xx_psc_buffer_8, '\r'); 652 out_8(&psc->mpc52xx_psc_buffer_8, '\r');
610 653
611 /* Send the char */ 654 /* Send the char */
612 out_8(&psc->mpc52xx_psc_buffer_8, *s); 655 out_8(&psc->mpc52xx_psc_buffer_8, *s);
613 656
614 /* Wait the TX buffer to be empty */ 657 /* Wait the TX buffer to be empty */
615 j = 20000; /* Maximum wait */ 658 j = 20000; /* Maximum wait */
616 while (!(in_be16(&psc->mpc52xx_psc_status) & 659 while (!(in_be16(&psc->mpc52xx_psc_status) &
617 MPC52xx_PSC_SR_TXEMP) && --j) 660 MPC52xx_PSC_SR_TXEMP) && --j)
618 udelay(1); 661 udelay(1);
619 } 662 }
@@ -622,6 +665,7 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
622 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); 665 out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask);
623} 666}
624 667
668#if !defined(CONFIG_PPC_MERGE)
625static int __init 669static int __init
626mpc52xx_console_setup(struct console *co, char *options) 670mpc52xx_console_setup(struct console *co, char *options)
627{ 671{
@@ -634,7 +678,7 @@ mpc52xx_console_setup(struct console *co, char *options)
634 678
635 if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM) 679 if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM)
636 return -EINVAL; 680 return -EINVAL;
637 681
638 /* Basic port init. Needed since we use some uart_??? func before 682 /* Basic port init. Needed since we use some uart_??? func before
639 * real init for early access */ 683 * real init for early access */
640 spin_lock_init(&port->lock); 684 spin_lock_init(&port->lock);
@@ -656,6 +700,78 @@ mpc52xx_console_setup(struct console *co, char *options)
656 return uart_set_options(port, co, baud, parity, bits, flow); 700 return uart_set_options(port, co, baud, parity, bits, flow);
657} 701}
658 702
703#else
704
705static int __init
706mpc52xx_console_setup(struct console *co, char *options)
707{
708 struct uart_port *port = &mpc52xx_uart_ports[co->index];
709 struct device_node *np = mpc52xx_uart_nodes[co->index];
710 unsigned int ipb_freq;
711 struct resource res;
712 int ret;
713
714 int baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD;
715 int bits = 8;
716 int parity = 'n';
717 int flow = 'n';
718
719 pr_debug("mpc52xx_console_setup co=%p, co->index=%i, options=%s\n",
720 co, co->index, options);
721
722 if ((co->index < 0) || (co->index > MPC52xx_PSC_MAXNUM)) {
723 pr_debug("PSC%x out of range\n", co->index);
724 return -EINVAL;
725 }
726
727 if (!np) {
728 pr_debug("PSC%x not found in device tree\n", co->index);
729 return -EINVAL;
730 }
731
732 pr_debug("Console on ttyPSC%x is %s\n",
733 co->index, mpc52xx_uart_nodes[co->index]->full_name);
734
735 /* Fetch register locations */
736 if ((ret = of_address_to_resource(np, 0, &res)) != 0) {
737 pr_debug("Could not get resources for PSC%x\n", co->index);
738 return ret;
739 }
740
741 /* Search for bus-frequency property in this node or a parent */
742 if ((ipb_freq = mpc52xx_find_ipb_freq(np)) == 0) {
743 pr_debug("Could not find IPB bus frequency!\n");
744 return -EINVAL;
745 }
746
747 /* Basic port init. Needed since we use some uart_??? func before
748 * real init for early access */
749 spin_lock_init(&port->lock);
750 port->uartclk = ipb_freq / 2;
751 port->ops = &mpc52xx_uart_ops;
752 port->mapbase = res.start;
753 port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc));
754 port->irq = irq_of_parse_and_map(np, 0);
755
756 if (port->membase == NULL)
757 return -EINVAL;
758
759 pr_debug("mpc52xx-psc uart at %lx, mapped to %p, irq=%x, freq=%i\n",
760 port->mapbase, port->membase, port->irq, port->uartclk);
761
762 /* Setup the port parameters accoding to options */
763 if (options)
764 uart_parse_options(options, &baud, &parity, &bits, &flow);
765 else
766 mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow);
767
768 pr_debug("Setting console parameters: %i %i%c1 flow=%c\n",
769 baud, bits, parity, flow);
770
771 return uart_set_options(port, co, baud, parity, bits, flow);
772}
773#endif /* defined(CONFIG_PPC_MERGE) */
774
659 775
660static struct uart_driver mpc52xx_uart_driver; 776static struct uart_driver mpc52xx_uart_driver;
661 777
@@ -669,10 +785,11 @@ static struct console mpc52xx_console = {
669 .data = &mpc52xx_uart_driver, 785 .data = &mpc52xx_uart_driver,
670}; 786};
671 787
672 788
673static int __init 789static int __init
674mpc52xx_console_init(void) 790mpc52xx_console_init(void)
675{ 791{
792 mpc52xx_uart_of_enumerate();
676 register_console(&mpc52xx_console); 793 register_console(&mpc52xx_console);
677 return 0; 794 return 0;
678} 795}
@@ -700,6 +817,7 @@ static struct uart_driver mpc52xx_uart_driver = {
700}; 817};
701 818
702 819
820#if !defined(CONFIG_PPC_MERGE)
703/* ======================================================================== */ 821/* ======================================================================== */
704/* Platform Driver */ 822/* Platform Driver */
705/* ======================================================================== */ 823/* ======================================================================== */
@@ -723,8 +841,6 @@ mpc52xx_uart_probe(struct platform_device *dev)
723 /* Init the port structure */ 841 /* Init the port structure */
724 port = &mpc52xx_uart_ports[idx]; 842 port = &mpc52xx_uart_ports[idx];
725 843
726 memset(port, 0x00, sizeof(struct uart_port));
727
728 spin_lock_init(&port->lock); 844 spin_lock_init(&port->lock);
729 port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */ 845 port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */
730 port->fifosize = 512; 846 port->fifosize = 512;
@@ -733,6 +849,7 @@ mpc52xx_uart_probe(struct platform_device *dev)
733 ( uart_console(port) ? 0 : UPF_IOREMAP ); 849 ( uart_console(port) ? 0 : UPF_IOREMAP );
734 port->line = idx; 850 port->line = idx;
735 port->ops = &mpc52xx_uart_ops; 851 port->ops = &mpc52xx_uart_ops;
852 port->dev = &dev->dev;
736 853
737 /* Search for IRQ and mapbase */ 854 /* Search for IRQ and mapbase */
738 for (i=0 ; i<dev->num_resources ; i++, res++) { 855 for (i=0 ; i<dev->num_resources ; i++, res++) {
@@ -771,7 +888,7 @@ mpc52xx_uart_suspend(struct platform_device *dev, pm_message_t state)
771{ 888{
772 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev); 889 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
773 890
774 if (sport) 891 if (port)
775 uart_suspend_port(&mpc52xx_uart_driver, port); 892 uart_suspend_port(&mpc52xx_uart_driver, port);
776 893
777 return 0; 894 return 0;
@@ -789,6 +906,7 @@ mpc52xx_uart_resume(struct platform_device *dev)
789} 906}
790#endif 907#endif
791 908
909
792static struct platform_driver mpc52xx_uart_platform_driver = { 910static struct platform_driver mpc52xx_uart_platform_driver = {
793 .probe = mpc52xx_uart_probe, 911 .probe = mpc52xx_uart_probe,
794 .remove = mpc52xx_uart_remove, 912 .remove = mpc52xx_uart_remove,
@@ -800,6 +918,184 @@ static struct platform_driver mpc52xx_uart_platform_driver = {
800 .name = "mpc52xx-psc", 918 .name = "mpc52xx-psc",
801 }, 919 },
802}; 920};
921#endif /* !defined(CONFIG_PPC_MERGE) */
922
923
924#if defined(CONFIG_PPC_MERGE)
925/* ======================================================================== */
926/* OF Platform Driver */
927/* ======================================================================== */
928
929static int __devinit
930mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match)
931{
932 int idx = -1;
933 unsigned int ipb_freq;
934 struct uart_port *port = NULL;
935 struct resource res;
936 int ret;
937
938 dev_dbg(&op->dev, "mpc52xx_uart_probe(op=%p, match=%p)\n", op, match);
939
940 /* Check validity & presence */
941 for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++)
942 if (mpc52xx_uart_nodes[idx] == op->node)
943 break;
944 if (idx >= MPC52xx_PSC_MAXNUM)
945 return -EINVAL;
946 pr_debug("Found %s assigned to ttyPSC%x\n",
947 mpc52xx_uart_nodes[idx]->full_name, idx);
948
949 /* Search for bus-frequency property in this node or a parent */
950 if ((ipb_freq = mpc52xx_find_ipb_freq(op->node)) == 0) {
951 dev_dbg(&op->dev, "Could not find IPB bus frequency!\n");
952 return -EINVAL;
953 }
954
955 /* Init the port structure */
956 port = &mpc52xx_uart_ports[idx];
957
958 spin_lock_init(&port->lock);
959 port->uartclk = ipb_freq / 2;
960 port->fifosize = 512;
961 port->iotype = UPIO_MEM;
962 port->flags = UPF_BOOT_AUTOCONF |
963 ( uart_console(port) ? 0 : UPF_IOREMAP );
964 port->line = idx;
965 port->ops = &mpc52xx_uart_ops;
966 port->dev = &op->dev;
967
968 /* Search for IRQ and mapbase */
969 if ((ret = of_address_to_resource(op->node, 0, &res)) != 0)
970 return ret;
971
972 port->mapbase = res.start;
973 port->irq = irq_of_parse_and_map(op->node, 0);
974
975 dev_dbg(&op->dev, "mpc52xx-psc uart at %lx, irq=%x, freq=%i\n",
976 port->mapbase, port->irq, port->uartclk);
977
978 if ((port->irq==NO_IRQ) || !port->mapbase) {
979 printk(KERN_ERR "Could not allocate resources for PSC\n");
980 return -EINVAL;
981 }
982
983 /* Add the port to the uart sub-system */
984 ret = uart_add_one_port(&mpc52xx_uart_driver, port);
985 if (!ret)
986 dev_set_drvdata(&op->dev, (void*)port);
987
988 return ret;
989}
990
991static int
992mpc52xx_uart_of_remove(struct of_device *op)
993{
994 struct uart_port *port = dev_get_drvdata(&op->dev);
995 dev_set_drvdata(&op->dev, NULL);
996
997 if (port)
998 uart_remove_one_port(&mpc52xx_uart_driver, port);
999
1000 return 0;
1001}
1002
1003#ifdef CONFIG_PM
1004static int
1005mpc52xx_uart_of_suspend(struct of_device *op, pm_message_t state)
1006{
1007 struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
1008
1009 if (port)
1010 uart_suspend_port(&mpc52xx_uart_driver, port);
1011
1012 return 0;
1013}
1014
1015static int
1016mpc52xx_uart_of_resume(struct of_device *op)
1017{
1018 struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev);
1019
1020 if (port)
1021 uart_resume_port(&mpc52xx_uart_driver, port);
1022
1023 return 0;
1024}
1025#endif
1026
1027static void
1028mpc52xx_uart_of_assign(struct device_node *np, int idx)
1029{
1030 int free_idx = -1;
1031 int i;
1032
1033 /* Find the first free node */
1034 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
1035 if (mpc52xx_uart_nodes[i] == NULL) {
1036 free_idx = i;
1037 break;
1038 }
1039 }
1040
1041 if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
1042 idx = free_idx;
1043
1044 if (idx < 0)
1045 return; /* No free slot; abort */
1046
1047 /* If the slot is already occupied, then swap slots */
1048 if (mpc52xx_uart_nodes[idx] && (free_idx != -1))
1049 mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx];
1050 mpc52xx_uart_nodes[i] = np;
1051}
1052
1053static void
1054mpc52xx_uart_of_enumerate(void)
1055{
1056 static int enum_done = 0;
1057 struct device_node *np;
1058 const unsigned int *devno;
1059 int i;
1060
1061 if (enum_done)
1062 return;
1063
1064 for_each_node_by_type(np, "serial") {
1065 if (!of_match_node(mpc52xx_uart_of_match, np))
1066 continue;
1067
1068 /* Is a particular device number requested? */
1069 devno = get_property(np, "device_no", NULL);
1070 mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1);
1071 }
1072
1073 enum_done = 1;
1074
1075 for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
1076 if (mpc52xx_uart_nodes[i])
1077 pr_debug("%s assigned to ttyPSC%x\n",
1078 mpc52xx_uart_nodes[i]->full_name, i);
1079 }
1080}
1081
1082MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match);
1083
1084static struct of_platform_driver mpc52xx_uart_of_driver = {
1085 .owner = THIS_MODULE,
1086 .name = "mpc52xx-psc-uart",
1087 .match_table = mpc52xx_uart_of_match,
1088 .probe = mpc52xx_uart_of_probe,
1089 .remove = mpc52xx_uart_of_remove,
1090#ifdef CONFIG_PM
1091 .suspend = mpc52xx_uart_of_suspend,
1092 .resume = mpc52xx_uart_of_resume,
1093#endif
1094 .driver = {
1095 .name = "mpc52xx-psc-uart",
1096 },
1097};
1098#endif /* defined(CONFIG_PPC_MERGE) */
803 1099
804 1100
805/* ======================================================================== */ 1101/* ======================================================================== */
@@ -811,22 +1107,45 @@ mpc52xx_uart_init(void)
811{ 1107{
812 int ret; 1108 int ret;
813 1109
814 printk(KERN_INFO "Serial: MPC52xx PSC driver\n"); 1110 printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n");
815 1111
816 ret = uart_register_driver(&mpc52xx_uart_driver); 1112 if ((ret = uart_register_driver(&mpc52xx_uart_driver)) != 0) {
817 if (ret == 0) { 1113 printk(KERN_ERR "%s: uart_register_driver failed (%i)\n",
818 ret = platform_driver_register(&mpc52xx_uart_platform_driver); 1114 __FILE__, ret);
819 if (ret) 1115 return ret;
820 uart_unregister_driver(&mpc52xx_uart_driver);
821 } 1116 }
822 1117
823 return ret; 1118#if defined(CONFIG_PPC_MERGE)
1119 mpc52xx_uart_of_enumerate();
1120
1121 ret = of_register_platform_driver(&mpc52xx_uart_of_driver);
1122 if (ret) {
1123 printk(KERN_ERR "%s: of_register_platform_driver failed (%i)\n",
1124 __FILE__, ret);
1125 uart_unregister_driver(&mpc52xx_uart_driver);
1126 return ret;
1127 }
1128#else
1129 ret = platform_driver_register(&mpc52xx_uart_platform_driver);
1130 if (ret) {
1131 printk(KERN_ERR "%s: platform_driver_register failed (%i)\n",
1132 __FILE__, ret);
1133 uart_unregister_driver(&mpc52xx_uart_driver);
1134 return ret;
1135 }
1136#endif
1137
1138 return 0;
824} 1139}
825 1140
826static void __exit 1141static void __exit
827mpc52xx_uart_exit(void) 1142mpc52xx_uart_exit(void)
828{ 1143{
1144#if defined(CONFIG_PPC_MERGE)
1145 of_unregister_platform_driver(&mpc52xx_uart_of_driver);
1146#else
829 platform_driver_unregister(&mpc52xx_uart_platform_driver); 1147 platform_driver_unregister(&mpc52xx_uart_platform_driver);
1148#endif
830 uart_unregister_driver(&mpc52xx_uart_driver); 1149 uart_unregister_driver(&mpc52xx_uart_driver);
831} 1150}
832 1151
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 00f9ffd69489..431433f4dd6d 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -723,7 +723,7 @@ static int serial_config(struct pcmcia_device * link)
723 u_char *buf; 723 u_char *buf;
724 cisparse_t *parse; 724 cisparse_t *parse;
725 cistpl_cftable_entry_t *cf; 725 cistpl_cftable_entry_t *cf;
726 int i, last_ret, last_fn; 726 int i;
727 727
728 DEBUG(0, "serial_config(0x%p)\n", link); 728 DEBUG(0, "serial_config(0x%p)\n", link);
729 729
@@ -740,15 +740,6 @@ static int serial_config(struct pcmcia_device * link)
740 tuple->TupleOffset = 0; 740 tuple->TupleOffset = 0;
741 tuple->TupleDataMax = 255; 741 tuple->TupleDataMax = 255;
742 tuple->Attributes = 0; 742 tuple->Attributes = 0;
743 /* Get configuration register information */
744 tuple->DesiredTuple = CISTPL_CONFIG;
745 last_ret = first_tuple(link, tuple, parse);
746 if (last_ret != CS_SUCCESS) {
747 last_fn = ParseTuple;
748 goto cs_failed;
749 }
750 link->conf.ConfigBase = parse->config.base;
751 link->conf.Present = parse->config.rmask[0];
752 743
753 /* Is this a compliant multifunction card? */ 744 /* Is this a compliant multifunction card? */
754 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 745 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
@@ -757,27 +748,25 @@ static int serial_config(struct pcmcia_device * link)
757 748
758 /* Is this a multiport card? */ 749 /* Is this a multiport card? */
759 tuple->DesiredTuple = CISTPL_MANFID; 750 tuple->DesiredTuple = CISTPL_MANFID;
760 if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 751 info->manfid = link->manf_id;
761 info->manfid = parse->manfid.manf; 752 info->prodid = link->card_id;
762 info->prodid = parse->manfid.card; 753
763 754 for (i = 0; i < ARRAY_SIZE(quirks); i++)
764 for (i = 0; i < ARRAY_SIZE(quirks); i++) 755 if ((quirks[i].manfid == ~0 ||
765 if ((quirks[i].manfid == ~0 || 756 quirks[i].manfid == info->manfid) &&
766 quirks[i].manfid == info->manfid) && 757 (quirks[i].prodid == ~0 ||
767 (quirks[i].prodid == ~0 || 758 quirks[i].prodid == info->prodid)) {
768 quirks[i].prodid == info->prodid)) { 759 info->quirk = &quirks[i];
769 info->quirk = &quirks[i]; 760 break;
770 break; 761 }
771 }
772 }
773 762
774 /* Another check for dual-serial cards: look for either serial or 763 /* Another check for dual-serial cards: look for either serial or
775 multifunction cards that ask for appropriate IO port ranges */ 764 multifunction cards that ask for appropriate IO port ranges */
776 tuple->DesiredTuple = CISTPL_FUNCID; 765 tuple->DesiredTuple = CISTPL_FUNCID;
777 if ((info->multi == 0) && 766 if ((info->multi == 0) &&
778 ((first_tuple(link, tuple, parse) != CS_SUCCESS) || 767 (link->has_func_id) &&
779 (parse->funcid.func == CISTPL_FUNCID_MULTI) || 768 ((link->func_id == CISTPL_FUNCID_MULTI) ||
780 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) { 769 (link->func_id == CISTPL_FUNCID_SERIAL))) {
781 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 770 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
782 if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 771 if (first_tuple(link, tuple, parse) == CS_SUCCESS) {
783 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 772 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0))
@@ -814,8 +803,6 @@ static int serial_config(struct pcmcia_device * link)
814 kfree(cfg_mem); 803 kfree(cfg_mem);
815 return 0; 804 return 0;
816 805
817 cs_failed:
818 cs_error(link, last_fn, last_ret);
819 failed: 806 failed:
820 serial_remove(link); 807 serial_remove(link);
821 kfree(cfg_mem); 808 kfree(cfg_mem);
@@ -925,6 +912,30 @@ static struct pcmcia_device_id serial_ids[] = {
925 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), 912 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"),
926 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), 913 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"),
927 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"), 914 PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"),
915 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b),
916 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83),
917 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232 1.00.",0x19ca78af,0x69fb7490),
918 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL232",0x19ca78af,0xb6bc0235),
919 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232",0x63f2e0bd,0xb9e175d3),
920 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c2000.","SERIAL CARD: CF232-5",0x63f2e0bd,0xfce33442),
921 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232",0x3beb8cf2,0x171e7190),
922 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF232-5",0x3beb8cf2,0x20da4262),
923 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF428",0x3beb8cf2,0xea5dd57d),
924 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: CF500",0x3beb8cf2,0xd77255fa),
925 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: IC232",0x3beb8cf2,0x6a709903),
926 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: SL232",0x3beb8cf2,0x18430676),
927 PCMCIA_DEVICE_PROD_ID12("Elan","Serial Port: XL232",0x3beb8cf2,0x6f933767),
928 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
929 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
930 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
931 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
932 PCMCIA_MFC_DEVICE_PROD_ID12(0,"Elan","Serial+Parallel Port: SP230",0x3beb8cf2,0xdb9e58bc),
933 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: CF332",0x3beb8cf2,0x16dc1ba7),
934 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL332",0x3beb8cf2,0x19816c41),
935 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL385",0x3beb8cf2,0x64112029),
936 PCMCIA_MFC_DEVICE_PROD_ID12(1,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
937 PCMCIA_MFC_DEVICE_PROD_ID12(2,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
938 PCMCIA_MFC_DEVICE_PROD_ID12(3,"Elan","Serial Port: SL432",0x3beb8cf2,0x1cce7ac4),
928 /* too generic */ 939 /* too generic */
929 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */ 940 /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */
930 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */ 941 /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index cfcc3caf49d8..3b5f19ec2126 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -775,7 +775,7 @@ static int sci_notifier(struct notifier_block *self,
775 * 775 *
776 * Clean this up later.. 776 * Clean this up later..
777 */ 777 */
778 clk = clk_get("module_clk"); 778 clk = clk_get(NULL, "module_clk");
779 port->uartclk = clk_get_rate(clk) * 16; 779 port->uartclk = clk_get_rate(clk) * 16;
780 clk_put(clk); 780 clk_put(clk);
781 } 781 }
@@ -960,7 +960,7 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
960 default: 960 default:
961 { 961 {
962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 962#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
963 struct clk *clk = clk_get("module_clk"); 963 struct clk *clk = clk_get(NULL, "module_clk");
964 t = SCBRR_VALUE(baud, clk_get_rate(clk)); 964 t = SCBRR_VALUE(baud, clk_get_rate(clk));
965 clk_put(clk); 965 clk_put(clk);
966#else 966#else
@@ -1128,7 +1128,7 @@ static void __init sci_init_ports(void)
1128 * XXX: We should use a proper SCI/SCIF clock 1128 * XXX: We should use a proper SCI/SCIF clock
1129 */ 1129 */
1130 { 1130 {
1131 struct clk *clk = clk_get("module_clk"); 1131 struct clk *clk = clk_get(NULL, "module_clk");
1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16; 1132 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16;
1133 clk_put(clk); 1133 clk_put(clk);
1134 } 1134 }
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index 7ee992146ae9..e4557cc4f74b 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -133,6 +133,20 @@
133# define SCIF_ORER 0x0001 /* Overrun error bit */ 133# define SCIF_ORER 0x0001 /* Overrun error bit */
134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 134# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
135# define SCIF_ONLY 135# define SCIF_ONLY
136#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
137# define SCSPTR0 0xfffe8020 /* 16 bit SCIF */
138# define SCSPTR1 0xfffe8820 /* 16 bit SCIF */
139# define SCSPTR2 0xfffe9020 /* 16 bit SCIF */
140# define SCSPTR3 0xfffe9820 /* 16 bit SCIF */
141# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
142# define SCIF_ONLY
143#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
144# define SCSPTR0 0xf8400020 /* 16 bit SCIF */
145# define SCSPTR1 0xf8410020 /* 16 bit SCIF */
146# define SCSPTR2 0xf8420020 /* 16 bit SCIF */
147# define SCIF_ORER 0x0001 /* overrun error bit */
148# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
149# define SCIF_ONLY
136#else 150#else
137# error CPU subtype not defined 151# error CPU subtype not defined
138#endif 152#endif
@@ -365,6 +379,7 @@ SCIx_FNS(SCxSR, 0x08, 8, 0x10, 8, 0x08, 16, 0x10, 16, 0x04, 8)
365SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8) 379SCIx_FNS(SCxRDR, 0x0a, 8, 0x14, 8, 0x0A, 8, 0x14, 8, 0x05, 8)
366SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16) 380SCIF_FNS(SCFCR, 0x0c, 8, 0x18, 16)
367#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) 381#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
382SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
368SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16) 383SCIF_FNS(SCTFDR, 0x0e, 16, 0x1C, 16)
369SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16) 384SCIF_FNS(SCRFDR, 0x0e, 16, 0x20, 16)
370SCIF_FNS(SCSPTR, 0, 0, 0x24, 16) 385SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
@@ -544,6 +559,28 @@ static inline int sci_rxd_in(struct uart_port *port)
544 if (port->mapbase == 0xffe10000) 559 if (port->mapbase == 0xffe10000)
545 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */ 560 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
546} 561}
562#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
563static inline int sci_rxd_in(struct uart_port *port)
564{
565 if (port->mapbase == 0xfffe8000)
566 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
567 if (port->mapbase == 0xfffe8800)
568 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
569 if (port->mapbase == 0xfffe9000)
570 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
571 if (port->mapbase == 0xfffe9800)
572 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
573}
574#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
575static inline int sci_rxd_in(struct uart_port *port)
576{
577 if (port->mapbase == 0xf8400000)
578 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
579 if (port->mapbase == 0xf8410000)
580 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
581 if (port->mapbase == 0xf8420000)
582 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
583}
547#endif 584#endif
548 585
549/* 586/*
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 72025df5561d..494d9b856488 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -148,7 +148,7 @@ struct chip_data {
148 void (*cs_control)(u32 command); 148 void (*cs_control)(u32 command);
149}; 149};
150 150
151static void pump_messages(void *data); 151static void pump_messages(struct work_struct *work);
152 152
153static int flush(struct driver_data *drv_data) 153static int flush(struct driver_data *drv_data)
154{ 154{
@@ -884,9 +884,10 @@ static void pump_transfers(unsigned long data)
884 } 884 }
885} 885}
886 886
887static void pump_messages(void *data) 887static void pump_messages(struct work_struct *work)
888{ 888{
889 struct driver_data *drv_data = data; 889 struct driver_data *drv_data =
890 container_of(work, struct driver_data, pump_messages);
890 unsigned long flags; 891 unsigned long flags;
891 892
892 /* Lock queue and check for queue work */ 893 /* Lock queue and check for queue work */
@@ -1098,7 +1099,7 @@ static int init_queue(struct driver_data *drv_data)
1098 tasklet_init(&drv_data->pump_transfers, 1099 tasklet_init(&drv_data->pump_transfers,
1099 pump_transfers, (unsigned long)drv_data); 1100 pump_transfers, (unsigned long)drv_data);
1100 1101
1101 INIT_WORK(&drv_data->pump_messages, pump_messages, drv_data); 1102 INIT_WORK(&drv_data->pump_messages, pump_messages);
1102 drv_data->workqueue = create_singlethread_workqueue( 1103 drv_data->workqueue = create_singlethread_workqueue(
1103 drv_data->master->cdev.dev->bus_id); 1104 drv_data->master->cdev.dev->bus_id);
1104 if (drv_data->workqueue == NULL) 1105 if (drv_data->workqueue == NULL)
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index a23862ef72b2..08c1c57c6128 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -265,9 +265,10 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t)
265 * Drivers can provide word-at-a-time i/o primitives, or provide 265 * Drivers can provide word-at-a-time i/o primitives, or provide
266 * transfer-at-a-time ones to leverage dma or fifo hardware. 266 * transfer-at-a-time ones to leverage dma or fifo hardware.
267 */ 267 */
268static void bitbang_work(void *_bitbang) 268static void bitbang_work(struct work_struct *work)
269{ 269{
270 struct spi_bitbang *bitbang = _bitbang; 270 struct spi_bitbang *bitbang =
271 container_of(work, struct spi_bitbang, work);
271 unsigned long flags; 272 unsigned long flags;
272 273
273 spin_lock_irqsave(&bitbang->lock, flags); 274 spin_lock_irqsave(&bitbang->lock, flags);
@@ -456,7 +457,7 @@ int spi_bitbang_start(struct spi_bitbang *bitbang)
456 if (!bitbang->master || !bitbang->chipselect) 457 if (!bitbang->master || !bitbang->chipselect)
457 return -EINVAL; 458 return -EINVAL;
458 459
459 INIT_WORK(&bitbang->work, bitbang_work, bitbang); 460 INIT_WORK(&bitbang->work, bitbang_work);
460 spin_lock_init(&bitbang->lock); 461 spin_lock_init(&bitbang->lock);
461 INIT_LIST_HEAD(&bitbang->queue); 462 INIT_LIST_HEAD(&bitbang->queue);
462 463
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index dda0ca45d904..164a5dcf1f1e 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -69,25 +69,21 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
69 69
70static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) 70static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
71{ 71{
72 tuple_t tuple;
73 u_short buf[128];
74 char *str; 72 char *str;
75 int last_ret, last_fn, i, place; 73 int i, place;
76 DEBUG(0, "ixj_get_serial(0x%p)\n", link); 74 DEBUG(0, "ixj_get_serial(0x%p)\n", link);
77 tuple.TupleData = (cisdata_t *) buf; 75
78 tuple.TupleOffset = 0; 76 str = link->prod_id[0];
79 tuple.TupleDataMax = 80; 77 if (!str)
80 tuple.Attributes = 0; 78 goto cs_failed;
81 tuple.DesiredTuple = CISTPL_VERS_1;
82 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
83 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
84 str = (char *) buf;
85 printk("PCMCIA Version %d.%d\n", str[0], str[1]);
86 str += 2;
87 printk("%s", str); 79 printk("%s", str);
88 str = str + strlen(str) + 1; 80 str = link->prod_id[1];
81 if (!str)
82 goto cs_failed;
89 printk(" %s", str); 83 printk(" %s", str);
90 str = str + strlen(str) + 1; 84 str = link->prod_id[2];
85 if (!str)
86 goto cs_failed;
91 place = 1; 87 place = 1;
92 for (i = strlen(str) - 1; i >= 0; i--) { 88 for (i = strlen(str) - 1; i >= 0; i--) {
93 switch (str[i]) { 89 switch (str[i]) {
@@ -122,7 +118,9 @@ static void ixj_get_serial(struct pcmcia_device * link, IXJ * j)
122 } 118 }
123 place = place * 0x10; 119 place = place * 0x10;
124 } 120 }
125 str = str + strlen(str) + 1; 121 str = link->prod_id[3];
122 if (!str)
123 goto cs_failed;
126 printk(" version %s\n", str); 124 printk(" version %s\n", str);
127 cs_failed: 125 cs_failed:
128 return; 126 return;
@@ -146,13 +144,6 @@ static int ixj_config(struct pcmcia_device * link)
146 tuple.TupleData = (cisdata_t *) buf; 144 tuple.TupleData = (cisdata_t *) buf;
147 tuple.TupleOffset = 0; 145 tuple.TupleOffset = 0;
148 tuple.TupleDataMax = 255; 146 tuple.TupleDataMax = 255;
149 tuple.Attributes = 0;
150 tuple.DesiredTuple = CISTPL_CONFIG;
151 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
152 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
153 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
154 link->conf.ConfigBase = parse.config.base;
155 link->conf.Present = parse.config.rmask[0];
156 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 147 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
157 tuple.Attributes = 0; 148 tuple.Attributes = 0;
158 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 149 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index e6565633ba0f..3dfa3e40e148 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -158,7 +158,7 @@ struct cxacru_data {
158 const struct cxacru_modem_type *modem_type; 158 const struct cxacru_modem_type *modem_type;
159 159
160 int line_status; 160 int line_status;
161 struct work_struct poll_work; 161 struct delayed_work poll_work;
162 162
163 /* contol handles */ 163 /* contol handles */
164 struct mutex cm_serialize; 164 struct mutex cm_serialize;
@@ -347,7 +347,7 @@ static int cxacru_card_status(struct cxacru_data *instance)
347 return 0; 347 return 0;
348} 348}
349 349
350static void cxacru_poll_status(struct cxacru_data *instance); 350static void cxacru_poll_status(struct work_struct *work);
351 351
352static int cxacru_atm_start(struct usbatm_data *usbatm_instance, 352static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
353 struct atm_dev *atm_dev) 353 struct atm_dev *atm_dev)
@@ -376,12 +376,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
376 } 376 }
377 377
378 /* Start status polling */ 378 /* Start status polling */
379 cxacru_poll_status(instance); 379 cxacru_poll_status(&instance->poll_work.work);
380 return 0; 380 return 0;
381} 381}
382 382
383static void cxacru_poll_status(struct cxacru_data *instance) 383static void cxacru_poll_status(struct work_struct *work)
384{ 384{
385 struct cxacru_data *instance =
386 container_of(work, struct cxacru_data, poll_work.work);
385 u32 buf[CXINF_MAX] = {}; 387 u32 buf[CXINF_MAX] = {};
386 struct usbatm_data *usbatm = instance->usbatm; 388 struct usbatm_data *usbatm = instance->usbatm;
387 struct atm_dev *atm_dev = usbatm->atm_dev; 389 struct atm_dev *atm_dev = usbatm->atm_dev;
@@ -720,7 +722,7 @@ static int cxacru_bind(struct usbatm_data *usbatm_instance,
720 722
721 mutex_init(&instance->cm_serialize); 723 mutex_init(&instance->cm_serialize);
722 724
723 INIT_WORK(&instance->poll_work, (void *)cxacru_poll_status, instance); 725 INIT_DELAYED_WORK(&instance->poll_work, cxacru_poll_status);
724 726
725 usbatm_instance->driver_data = instance; 727 usbatm_instance->driver_data = instance;
726 728
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index a823486495c3..8ed6c75adf0f 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -142,7 +142,7 @@ struct speedtch_instance_data {
142 142
143 struct speedtch_params params; /* set in probe, constant afterwards */ 143 struct speedtch_params params; /* set in probe, constant afterwards */
144 144
145 struct work_struct status_checker; 145 struct delayed_work status_checker;
146 146
147 unsigned char last_status; 147 unsigned char last_status;
148 148
@@ -498,8 +498,11 @@ static int speedtch_start_synchro(struct speedtch_instance_data *instance)
498 return ret; 498 return ret;
499} 499}
500 500
501static void speedtch_check_status(struct speedtch_instance_data *instance) 501static void speedtch_check_status(struct work_struct *work)
502{ 502{
503 struct speedtch_instance_data *instance =
504 container_of(work, struct speedtch_instance_data,
505 status_checker.work);
503 struct usbatm_data *usbatm = instance->usbatm; 506 struct usbatm_data *usbatm = instance->usbatm;
504 struct atm_dev *atm_dev = usbatm->atm_dev; 507 struct atm_dev *atm_dev = usbatm->atm_dev;
505 unsigned char *buf = instance->scratch_buffer; 508 unsigned char *buf = instance->scratch_buffer;
@@ -576,7 +579,7 @@ static void speedtch_status_poll(unsigned long data)
576{ 579{
577 struct speedtch_instance_data *instance = (void *)data; 580 struct speedtch_instance_data *instance = (void *)data;
578 581
579 schedule_work(&instance->status_checker); 582 schedule_delayed_work(&instance->status_checker, 0);
580 583
581 /* The following check is racy, but the race is harmless */ 584 /* The following check is racy, but the race is harmless */
582 if (instance->poll_delay < MAX_POLL_DELAY) 585 if (instance->poll_delay < MAX_POLL_DELAY)
@@ -596,7 +599,7 @@ static void speedtch_resubmit_int(unsigned long data)
596 if (int_urb) { 599 if (int_urb) {
597 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 600 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
598 if (!ret) 601 if (!ret)
599 schedule_work(&instance->status_checker); 602 schedule_delayed_work(&instance->status_checker, 0);
600 else { 603 else {
601 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 604 atm_dbg(instance->usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
602 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY)); 605 mod_timer(&instance->resubmit_timer, jiffies + msecs_to_jiffies(RESUBMIT_DELAY));
@@ -640,7 +643,7 @@ static void speedtch_handle_int(struct urb *int_urb)
640 643
641 if ((int_urb = instance->int_urb)) { 644 if ((int_urb = instance->int_urb)) {
642 ret = usb_submit_urb(int_urb, GFP_ATOMIC); 645 ret = usb_submit_urb(int_urb, GFP_ATOMIC);
643 schedule_work(&instance->status_checker); 646 schedule_delayed_work(&instance->status_checker, 0);
644 if (ret < 0) { 647 if (ret < 0) {
645 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret); 648 atm_dbg(usbatm, "%s: usb_submit_urb failed with result %d\n", __func__, ret);
646 goto fail; 649 goto fail;
@@ -855,7 +858,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
855 858
856 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0); 859 usbatm->flags |= (use_isoc ? UDSL_USE_ISOC : 0);
857 860
858 INIT_WORK(&instance->status_checker, (void *)speedtch_check_status, instance); 861 INIT_DELAYED_WORK(&instance->status_checker, speedtch_check_status);
859 862
860 instance->status_checker.timer.function = speedtch_status_poll; 863 instance->status_checker.timer.function = speedtch_status_poll;
861 instance->status_checker.timer.data = (unsigned long)instance; 864 instance->status_checker.timer.data = (unsigned long)instance;
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index c137c041f7a4..f2d196fa1e8b 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -655,9 +655,9 @@ static int request_dsp(struct uea_softc *sc)
655/* 655/*
656 * The uea_load_page() function must be called within a process context 656 * The uea_load_page() function must be called within a process context
657 */ 657 */
658static void uea_load_page(void *xsc) 658static void uea_load_page(struct work_struct *work)
659{ 659{
660 struct uea_softc *sc = xsc; 660 struct uea_softc *sc = container_of(work, struct uea_softc, task);
661 u16 pageno = sc->pageno; 661 u16 pageno = sc->pageno;
662 u16 ovl = sc->ovl; 662 u16 ovl = sc->ovl;
663 struct block_info bi; 663 struct block_info bi;
@@ -1348,7 +1348,7 @@ static int uea_boot(struct uea_softc *sc)
1348 1348
1349 uea_enters(INS_TO_USBDEV(sc)); 1349 uea_enters(INS_TO_USBDEV(sc));
1350 1350
1351 INIT_WORK(&sc->task, uea_load_page, sc); 1351 INIT_WORK(&sc->task, uea_load_page);
1352 init_waitqueue_head(&sc->sync_q); 1352 init_waitqueue_head(&sc->sync_q);
1353 init_waitqueue_head(&sc->cmv_ack_wait); 1353 init_waitqueue_head(&sc->cmv_ack_wait);
1354 1354
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index ec3438dc8ee5..7f1fa956dcdb 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -421,9 +421,9 @@ static void acm_write_bulk(struct urb *urb)
421 schedule_work(&acm->work); 421 schedule_work(&acm->work);
422} 422}
423 423
424static void acm_softint(void *private) 424static void acm_softint(struct work_struct *work)
425{ 425{
426 struct acm *acm = private; 426 struct acm *acm = container_of(work, struct acm, work);
427 dbg("Entering acm_softint."); 427 dbg("Entering acm_softint.");
428 428
429 if (!ACM_READY(acm)) 429 if (!ACM_READY(acm))
@@ -927,7 +927,7 @@ skip_normal_probe:
927 acm->rx_buflimit = num_rx_buf; 927 acm->rx_buflimit = num_rx_buf;
928 acm->urb_task.func = acm_rx_tasklet; 928 acm->urb_task.func = acm_rx_tasklet;
929 acm->urb_task.data = (unsigned long) acm; 929 acm->urb_task.data = (unsigned long) acm;
930 INIT_WORK(&acm->work, acm_softint, acm); 930 INIT_WORK(&acm->work, acm_softint);
931 spin_lock_init(&acm->throttle_lock); 931 spin_lock_init(&acm->throttle_lock);
932 spin_lock_init(&acm->write_lock); 932 spin_lock_init(&acm->write_lock);
933 spin_lock_init(&acm->read_lock); 933 spin_lock_init(&acm->read_lock);
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0ce393eb3c4b..9be41ed1f9a6 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -68,7 +68,7 @@ struct usb_hub {
68 68
69 unsigned has_indicators:1; 69 unsigned has_indicators:1;
70 u8 indicator[USB_MAXCHILDREN]; 70 u8 indicator[USB_MAXCHILDREN];
71 struct work_struct leds; 71 struct delayed_work leds;
72}; 72};
73 73
74 74
@@ -218,9 +218,10 @@ static void set_port_led(
218 218
219#define LED_CYCLE_PERIOD ((2*HZ)/3) 219#define LED_CYCLE_PERIOD ((2*HZ)/3)
220 220
221static void led_work (void *__hub) 221static void led_work (struct work_struct *work)
222{ 222{
223 struct usb_hub *hub = __hub; 223 struct usb_hub *hub =
224 container_of(work, struct usb_hub, leds.work);
224 struct usb_device *hdev = hub->hdev; 225 struct usb_device *hdev = hub->hdev;
225 unsigned i; 226 unsigned i;
226 unsigned changed = 0; 227 unsigned changed = 0;
@@ -405,9 +406,10 @@ hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
405 * talking to TTs must queue control transfers (not just bulk and iso), so 406 * talking to TTs must queue control transfers (not just bulk and iso), so
406 * both can talk to the same hub concurrently. 407 * both can talk to the same hub concurrently.
407 */ 408 */
408static void hub_tt_kevent (void *arg) 409static void hub_tt_kevent (struct work_struct *work)
409{ 410{
410 struct usb_hub *hub = arg; 411 struct usb_hub *hub =
412 container_of(work, struct usb_hub, tt.kevent);
411 unsigned long flags; 413 unsigned long flags;
412 414
413 spin_lock_irqsave (&hub->tt.lock, flags); 415 spin_lock_irqsave (&hub->tt.lock, flags);
@@ -694,7 +696,7 @@ static int hub_configure(struct usb_hub *hub,
694 696
695 spin_lock_init (&hub->tt.lock); 697 spin_lock_init (&hub->tt.lock);
696 INIT_LIST_HEAD (&hub->tt.clear_list); 698 INIT_LIST_HEAD (&hub->tt.clear_list);
697 INIT_WORK (&hub->tt.kevent, hub_tt_kevent, hub); 699 INIT_WORK (&hub->tt.kevent, hub_tt_kevent);
698 switch (hdev->descriptor.bDeviceProtocol) { 700 switch (hdev->descriptor.bDeviceProtocol) {
699 case 0: 701 case 0:
700 break; 702 break;
@@ -938,7 +940,7 @@ descriptor_error:
938 INIT_LIST_HEAD(&hub->event_list); 940 INIT_LIST_HEAD(&hub->event_list);
939 hub->intfdev = &intf->dev; 941 hub->intfdev = &intf->dev;
940 hub->hdev = hdev; 942 hub->hdev = hdev;
941 INIT_WORK(&hub->leds, led_work, hub); 943 INIT_DELAYED_WORK(&hub->leds, led_work);
942 944
943 usb_set_intfdata (intf, hub); 945 usb_set_intfdata (intf, hub);
944 intf->needs_remote_wakeup = 1; 946 intf->needs_remote_wakeup = 1;
@@ -2381,7 +2383,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2381 /* hub LEDs are probably harder to miss than syslog */ 2383 /* hub LEDs are probably harder to miss than syslog */
2382 if (hub->has_indicators) { 2384 if (hub->has_indicators) {
2383 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK; 2385 hub->indicator[port1-1] = INDICATOR_GREEN_BLINK;
2384 schedule_work (&hub->leds); 2386 schedule_delayed_work (&hub->leds, 0);
2385 } 2387 }
2386 } 2388 }
2387 kfree(qual); 2389 kfree(qual);
@@ -2555,7 +2557,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2555 if (hub->has_indicators) { 2557 if (hub->has_indicators) {
2556 hub->indicator[port1-1] = 2558 hub->indicator[port1-1] =
2557 INDICATOR_AMBER_BLINK; 2559 INDICATOR_AMBER_BLINK;
2558 schedule_work (&hub->leds); 2560 schedule_delayed_work (&hub->leds, 0);
2559 } 2561 }
2560 status = -ENOTCONN; /* Don't retry */ 2562 status = -ENOTCONN; /* Don't retry */
2561 goto loop_disable; 2563 goto loop_disable;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 29b0fa9ff9d0..7390b67c609d 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1501,9 +1501,10 @@ struct set_config_request {
1501}; 1501};
1502 1502
1503/* Worker routine for usb_driver_set_configuration() */ 1503/* Worker routine for usb_driver_set_configuration() */
1504static void driver_set_config_work(void *_req) 1504static void driver_set_config_work(struct work_struct *work)
1505{ 1505{
1506 struct set_config_request *req = _req; 1506 struct set_config_request *req =
1507 container_of(work, struct set_config_request, work);
1507 1508
1508 usb_lock_device(req->udev); 1509 usb_lock_device(req->udev);
1509 usb_set_configuration(req->udev, req->config); 1510 usb_set_configuration(req->udev, req->config);
@@ -1541,7 +1542,7 @@ int usb_driver_set_configuration(struct usb_device *udev, int config)
1541 return -ENOMEM; 1542 return -ENOMEM;
1542 req->udev = udev; 1543 req->udev = udev;
1543 req->config = config; 1544 req->config = config;
1544 INIT_WORK(&req->work, driver_set_config_work, req); 1545 INIT_WORK(&req->work, driver_set_config_work);
1545 1546
1546 usb_get_dev(udev); 1547 usb_get_dev(udev);
1547 if (!schedule_work(&req->work)) { 1548 if (!schedule_work(&req->work)) {
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 81cb52564e68..02426d0b9a34 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -203,9 +203,10 @@ static void ksuspend_usb_cleanup(void)
203#ifdef CONFIG_USB_SUSPEND 203#ifdef CONFIG_USB_SUSPEND
204 204
205/* usb_autosuspend_work - callback routine to autosuspend a USB device */ 205/* usb_autosuspend_work - callback routine to autosuspend a USB device */
206static void usb_autosuspend_work(void *_udev) 206static void usb_autosuspend_work(struct work_struct *work)
207{ 207{
208 struct usb_device *udev = _udev; 208 struct usb_device *udev =
209 container_of(work, struct usb_device, autosuspend.work);
209 210
210 usb_pm_lock(udev); 211 usb_pm_lock(udev);
211 udev->auto_pm = 1; 212 udev->auto_pm = 1;
@@ -215,7 +216,7 @@ static void usb_autosuspend_work(void *_udev)
215 216
216#else 217#else
217 218
218static void usb_autosuspend_work(void *_udev) 219static void usb_autosuspend_work(struct work_struct *work)
219{} 220{}
220 221
221#endif /* CONFIG_USB_SUSPEND */ 222#endif /* CONFIG_USB_SUSPEND */
@@ -304,7 +305,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
304 305
305#ifdef CONFIG_PM 306#ifdef CONFIG_PM
306 mutex_init(&dev->pm_mutex); 307 mutex_init(&dev->pm_mutex);
307 INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev); 308 INIT_DELAYED_WORK(&dev->autosuspend, usb_autosuspend_work);
308#endif 309#endif
309 return dev; 310 return dev;
310} 311}
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 3bd1dfe565c1..d15bf22b9a03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1833,9 +1833,9 @@ static void rx_fill (struct eth_dev *dev, gfp_t gfp_flags)
1833 spin_unlock_irqrestore(&dev->req_lock, flags); 1833 spin_unlock_irqrestore(&dev->req_lock, flags);
1834} 1834}
1835 1835
1836static void eth_work (void *_dev) 1836static void eth_work (struct work_struct *work)
1837{ 1837{
1838 struct eth_dev *dev = _dev; 1838 struct eth_dev *dev = container_of(work, struct eth_dev, work);
1839 1839
1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) { 1840 if (test_and_clear_bit (WORK_RX_MEMORY, &dev->todo)) {
1841 if (netif_running (dev->net)) 1841 if (netif_running (dev->net))
@@ -2398,7 +2398,7 @@ autoconf_fail:
2398 dev = netdev_priv(net); 2398 dev = netdev_priv(net);
2399 spin_lock_init (&dev->lock); 2399 spin_lock_init (&dev->lock);
2400 spin_lock_init (&dev->req_lock); 2400 spin_lock_init (&dev->req_lock);
2401 INIT_WORK (&dev->work, eth_work, dev); 2401 INIT_WORK (&dev->work, eth_work);
2402 INIT_LIST_HEAD (&dev->tx_reqs); 2402 INIT_LIST_HEAD (&dev->tx_reqs);
2403 INIT_LIST_HEAD (&dev->rx_reqs); 2403 INIT_LIST_HEAD (&dev->rx_reqs);
2404 2404
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 54f554e0f0ad..ac9f11d19817 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -169,21 +169,14 @@ static int sl811_cs_config(struct pcmcia_device *link)
169 169
170 DBG(0, "sl811_cs_config(0x%p)\n", link); 170 DBG(0, "sl811_cs_config(0x%p)\n", link);
171 171
172 tuple.DesiredTuple = CISTPL_CONFIG;
173 tuple.Attributes = 0;
174 tuple.TupleData = buf;
175 tuple.TupleDataMax = sizeof(buf);
176 tuple.TupleOffset = 0;
177 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
178 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
179 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
180 link->conf.ConfigBase = parse.config.base;
181 link->conf.Present = parse.config.rmask[0];
182
183 /* Look up the current Vcc */ 172 /* Look up the current Vcc */
184 CS_CHECK(GetConfigurationInfo, 173 CS_CHECK(GetConfigurationInfo,
185 pcmcia_get_configuration_info(link, &conf)); 174 pcmcia_get_configuration_info(link, &conf));
186 175
176 tuple.Attributes = 0;
177 tuple.TupleData = buf;
178 tuple.TupleDataMax = sizeof(buf);
179 tuple.TupleOffset = 0;
187 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 180 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
188 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 181 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
189 while (1) { 182 while (1) {
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index ef54e310bfc4..a9d7119e3176 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -163,7 +163,7 @@ struct u132_endp {
163 u16 queue_next; 163 u16 queue_next;
164 struct urb *urb_list[ENDP_QUEUE_SIZE]; 164 struct urb *urb_list[ENDP_QUEUE_SIZE];
165 struct list_head urb_more; 165 struct list_head urb_more;
166 struct work_struct scheduler; 166 struct delayed_work scheduler;
167}; 167};
168struct u132_ring { 168struct u132_ring {
169 unsigned in_use:1; 169 unsigned in_use:1;
@@ -171,7 +171,7 @@ struct u132_ring {
171 u8 number; 171 u8 number;
172 struct u132 *u132; 172 struct u132 *u132;
173 struct u132_endp *curr_endp; 173 struct u132_endp *curr_endp;
174 struct work_struct scheduler; 174 struct delayed_work scheduler;
175}; 175};
176#define OHCI_QUIRK_AMD756 0x01 176#define OHCI_QUIRK_AMD756 0x01
177#define OHCI_QUIRK_SUPERIO 0x02 177#define OHCI_QUIRK_SUPERIO 0x02
@@ -198,7 +198,7 @@ struct u132 {
198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS]; 198 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
199 int flags; 199 int flags;
200 unsigned long next_statechange; 200 unsigned long next_statechange;
201 struct work_struct monitor; 201 struct delayed_work monitor;
202 int num_endpoints; 202 int num_endpoints;
203 struct u132_addr addr[MAX_U132_ADDRS]; 203 struct u132_addr addr[MAX_U132_ADDRS];
204 struct u132_udev udev[MAX_U132_UDEVS]; 204 struct u132_udev udev[MAX_U132_UDEVS];
@@ -310,7 +310,7 @@ static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
310 if (delta > 0) { 310 if (delta > 0) {
311 if (queue_delayed_work(workqueue, &ring->scheduler, delta)) 311 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
312 return; 312 return;
313 } else if (queue_work(workqueue, &ring->scheduler)) 313 } else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
314 return; 314 return;
315 kref_put(&u132->kref, u132_hcd_delete); 315 kref_put(&u132->kref, u132_hcd_delete);
316 return; 316 return;
@@ -389,12 +389,8 @@ static inline void u132_endp_init_kref(struct u132 *u132,
389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp, 389static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
390 unsigned int delta) 390 unsigned int delta)
391{ 391{
392 if (delta > 0) { 392 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
393 if (queue_delayed_work(workqueue, &endp->scheduler, delta)) 393 kref_get(&endp->kref);
394 kref_get(&endp->kref);
395 } else if (queue_work(workqueue, &endp->scheduler))
396 kref_get(&endp->kref);
397 return;
398} 394}
399 395
400static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp) 396static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
@@ -410,24 +406,14 @@ static inline void u132_monitor_put_kref(struct u132 *u132)
410 406
411static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta) 407static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
412{ 408{
413 if (delta > 0) { 409 if (queue_delayed_work(workqueue, &u132->monitor, delta))
414 if (queue_delayed_work(workqueue, &u132->monitor, delta)) { 410 kref_get(&u132->kref);
415 kref_get(&u132->kref);
416 }
417 } else if (queue_work(workqueue, &u132->monitor))
418 kref_get(&u132->kref);
419 return;
420} 411}
421 412
422static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta) 413static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
423{ 414{
424 if (delta > 0) { 415 if (!queue_delayed_work(workqueue, &u132->monitor, delta))
425 if (queue_delayed_work(workqueue, &u132->monitor, delta)) 416 kref_put(&u132->kref, u132_hcd_delete);
426 return;
427 } else if (queue_work(workqueue, &u132->monitor))
428 return;
429 kref_put(&u132->kref, u132_hcd_delete);
430 return;
431} 417}
432 418
433static void u132_monitor_cancel_work(struct u132 *u132) 419static void u132_monitor_cancel_work(struct u132 *u132)
@@ -489,9 +475,9 @@ static int read_roothub_info(struct u132 *u132)
489 return 0; 475 return 0;
490} 476}
491 477
492static void u132_hcd_monitor_work(void *data) 478static void u132_hcd_monitor_work(struct work_struct *work)
493{ 479{
494 struct u132 *u132 = data; 480 struct u132 *u132 = container_of(work, struct u132, monitor.work);
495 if (u132->going > 1) { 481 if (u132->going > 1) {
496 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 482 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
497 , u132->going); 483 , u132->going);
@@ -1315,15 +1301,14 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1315 } 1301 }
1316} 1302}
1317 1303
1318static void u132_hcd_ring_work_scheduler(void *data);
1319static void u132_hcd_endp_work_scheduler(void *data);
1320/* 1304/*
1321* this work function is only executed from the work queue 1305* this work function is only executed from the work queue
1322* 1306*
1323*/ 1307*/
1324static void u132_hcd_ring_work_scheduler(void *data) 1308static void u132_hcd_ring_work_scheduler(struct work_struct *work)
1325{ 1309{
1326 struct u132_ring *ring = data; 1310 struct u132_ring *ring =
1311 container_of(work, struct u132_ring, scheduler.work);
1327 struct u132 *u132 = ring->u132; 1312 struct u132 *u132 = ring->u132;
1328 down(&u132->scheduler_lock); 1313 down(&u132->scheduler_lock);
1329 if (ring->in_use) { 1314 if (ring->in_use) {
@@ -1382,10 +1367,11 @@ static void u132_hcd_ring_work_scheduler(void *data)
1382 } 1367 }
1383} 1368}
1384 1369
1385static void u132_hcd_endp_work_scheduler(void *data) 1370static void u132_hcd_endp_work_scheduler(struct work_struct *work)
1386{ 1371{
1387 struct u132_ring *ring; 1372 struct u132_ring *ring;
1388 struct u132_endp *endp = data; 1373 struct u132_endp *endp =
1374 container_of(work, struct u132_endp, scheduler.work);
1389 struct u132 *u132 = endp->u132; 1375 struct u132 *u132 = endp->u132;
1390 down(&u132->scheduler_lock); 1376 down(&u132->scheduler_lock);
1391 ring = endp->ring; 1377 ring = endp->ring;
@@ -1943,7 +1929,7 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
1943 if (!endp) { 1929 if (!endp) {
1944 return -ENOMEM; 1930 return -ENOMEM;
1945 } 1931 }
1946 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 1932 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
1947 spin_lock_init(&endp->queue_lock.slock); 1933 spin_lock_init(&endp->queue_lock.slock);
1948 INIT_LIST_HEAD(&endp->urb_more); 1934 INIT_LIST_HEAD(&endp->urb_more);
1949 ring = endp->ring = &u132->ring[0]; 1935 ring = endp->ring = &u132->ring[0];
@@ -2032,7 +2018,7 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
2032 if (!endp) { 2018 if (!endp) {
2033 return -ENOMEM; 2019 return -ENOMEM;
2034 } 2020 }
2035 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2021 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2036 spin_lock_init(&endp->queue_lock.slock); 2022 spin_lock_init(&endp->queue_lock.slock);
2037 INIT_LIST_HEAD(&endp->urb_more); 2023 INIT_LIST_HEAD(&endp->urb_more);
2038 endp->dequeueing = 0; 2024 endp->dequeueing = 0;
@@ -2117,7 +2103,7 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
2117 if (!endp) { 2103 if (!endp) {
2118 return -ENOMEM; 2104 return -ENOMEM;
2119 } 2105 }
2120 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp); 2106 INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
2121 spin_lock_init(&endp->queue_lock.slock); 2107 spin_lock_init(&endp->queue_lock.slock);
2122 INIT_LIST_HEAD(&endp->urb_more); 2108 INIT_LIST_HEAD(&endp->urb_more);
2123 ring = endp->ring = &u132->ring[0]; 2109 ring = endp->ring = &u132->ring[0];
@@ -3096,10 +3082,10 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3096 ring->number = rings + 1; 3082 ring->number = rings + 1;
3097 ring->length = 0; 3083 ring->length = 0;
3098 ring->curr_endp = NULL; 3084 ring->curr_endp = NULL;
3099 INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler, 3085 INIT_DELAYED_WORK(&ring->scheduler,
3100 (void *)ring); 3086 u132_hcd_ring_work_scheduler);
3101 } down(&u132->sw_lock); 3087 } down(&u132->sw_lock);
3102 INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132); 3088 INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
3103 while (ports-- > 0) { 3089 while (ports-- > 0) {
3104 struct u132_port *port = &u132->port[ports]; 3090 struct u132_port *port = &u132->port[ports];
3105 port->u132 = u132; 3091 port->u132 = u132;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index a49644b7c58e..4295bab4f1e2 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -969,9 +969,10 @@ static void hid_retry_timeout(unsigned long _hid)
969} 969}
970 970
971/* Workqueue routine to reset the device or clear a halt */ 971/* Workqueue routine to reset the device or clear a halt */
972static void hid_reset(void *_hid) 972static void hid_reset(struct work_struct *work)
973{ 973{
974 struct hid_device *hid = (struct hid_device *) _hid; 974 struct hid_device *hid =
975 container_of(work, struct hid_device, reset_work);
975 int rc_lock, rc = 0; 976 int rc_lock, rc = 0;
976 977
977 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) { 978 if (test_bit(HID_CLEAR_HALT, &hid->iofl)) {
@@ -2043,7 +2044,7 @@ static struct hid_device *usb_hid_configure(struct usb_interface *intf)
2043 2044
2044 init_waitqueue_head(&hid->wait); 2045 init_waitqueue_head(&hid->wait);
2045 2046
2046 INIT_WORK(&hid->reset_work, hid_reset, hid); 2047 INIT_WORK(&hid->reset_work, hid_reset);
2047 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid); 2048 setup_timer(&hid->io_retry, hid_retry_timeout, (unsigned long) hid);
2048 2049
2049 spin_lock_init(&hid->inlock); 2050 spin_lock_init(&hid->inlock);
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index ba30ca6a14aa..02cbb7fff24f 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -76,7 +76,7 @@ struct appledisplay {
76 char *urbdata; /* interrupt URB data buffer */ 76 char *urbdata; /* interrupt URB data buffer */
77 char *msgdata; /* control message data buffer */ 77 char *msgdata; /* control message data buffer */
78 78
79 struct work_struct work; 79 struct delayed_work work;
80 int button_pressed; 80 int button_pressed;
81 spinlock_t lock; 81 spinlock_t lock;
82}; 82};
@@ -117,7 +117,7 @@ static void appledisplay_complete(struct urb *urb)
117 case ACD_BTN_BRIGHT_UP: 117 case ACD_BTN_BRIGHT_UP:
118 case ACD_BTN_BRIGHT_DOWN: 118 case ACD_BTN_BRIGHT_DOWN:
119 pdata->button_pressed = 1; 119 pdata->button_pressed = 1;
120 queue_work(wq, &pdata->work); 120 queue_delayed_work(wq, &pdata->work, 0);
121 break; 121 break;
122 case ACD_BTN_NONE: 122 case ACD_BTN_NONE:
123 default: 123 default:
@@ -184,9 +184,10 @@ static struct backlight_properties appledisplay_bl_data = {
184 .max_brightness = 0xFF 184 .max_brightness = 0xFF
185}; 185};
186 186
187static void appledisplay_work(void *private) 187static void appledisplay_work(struct work_struct *work)
188{ 188{
189 struct appledisplay *pdata = private; 189 struct appledisplay *pdata =
190 container_of(work, struct appledisplay, work.work);
190 int retval; 191 int retval;
191 192
192 up(&pdata->bd->sem); 193 up(&pdata->bd->sem);
@@ -238,7 +239,7 @@ static int appledisplay_probe(struct usb_interface *iface,
238 pdata->udev = udev; 239 pdata->udev = udev;
239 240
240 spin_lock_init(&pdata->lock); 241 spin_lock_init(&pdata->lock);
241 INIT_WORK(&pdata->work, appledisplay_work, pdata); 242 INIT_DELAYED_WORK(&pdata->work, appledisplay_work);
242 243
243 /* Allocate buffer for control messages */ 244 /* Allocate buffer for control messages */
244 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL); 245 pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index cb0ba3107d7f..18b1925032a8 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -156,9 +156,9 @@ struct usb_ftdi {
156 struct usb_device *udev; 156 struct usb_device *udev;
157 struct usb_interface *interface; 157 struct usb_interface *interface;
158 struct usb_class_driver *class; 158 struct usb_class_driver *class;
159 struct work_struct status_work; 159 struct delayed_work status_work;
160 struct work_struct command_work; 160 struct delayed_work command_work;
161 struct work_struct respond_work; 161 struct delayed_work respond_work;
162 struct u132_platform_data platform_data; 162 struct u132_platform_data platform_data;
163 struct resource resources[0]; 163 struct resource resources[0];
164 struct platform_device platform_dev; 164 struct platform_device platform_dev;
@@ -210,23 +210,14 @@ static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
210 210
211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 211static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
212{ 212{
213 if (delta > 0) { 213 if (!queue_delayed_work(status_queue, &ftdi->status_work, delta))
214 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 214 kref_put(&ftdi->kref, ftdi_elan_delete);
215 return;
216 } else if (queue_work(status_queue, &ftdi->status_work))
217 return;
218 kref_put(&ftdi->kref, ftdi_elan_delete);
219 return;
220} 215}
221 216
222static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 217static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
223{ 218{
224 if (delta > 0) { 219 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
225 if (queue_delayed_work(status_queue, &ftdi->status_work, delta)) 220 kref_get(&ftdi->kref);
226 kref_get(&ftdi->kref);
227 } else if (queue_work(status_queue, &ftdi->status_work))
228 kref_get(&ftdi->kref);
229 return;
230} 221}
231 222
232static void ftdi_status_cancel_work(struct usb_ftdi *ftdi) 223static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
@@ -237,25 +228,14 @@ static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
237 228
238static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta) 229static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
239{ 230{
240 if (delta > 0) { 231 if (!queue_delayed_work(command_queue, &ftdi->command_work, delta))
241 if (queue_delayed_work(command_queue, &ftdi->command_work, 232 kref_put(&ftdi->kref, ftdi_elan_delete);
242 delta))
243 return;
244 } else if (queue_work(command_queue, &ftdi->command_work))
245 return;
246 kref_put(&ftdi->kref, ftdi_elan_delete);
247 return;
248} 233}
249 234
250static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 235static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
251{ 236{
252 if (delta > 0) { 237 if (queue_delayed_work(command_queue, &ftdi->command_work, delta))
253 if (queue_delayed_work(command_queue, &ftdi->command_work, 238 kref_get(&ftdi->kref);
254 delta))
255 kref_get(&ftdi->kref);
256 } else if (queue_work(command_queue, &ftdi->command_work))
257 kref_get(&ftdi->kref);
258 return;
259} 239}
260 240
261static void ftdi_command_cancel_work(struct usb_ftdi *ftdi) 241static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
@@ -267,25 +247,14 @@ static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
267static void ftdi_response_requeue_work(struct usb_ftdi *ftdi, 247static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
268 unsigned int delta) 248 unsigned int delta)
269{ 249{
270 if (delta > 0) { 250 if (!queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
271 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 251 kref_put(&ftdi->kref, ftdi_elan_delete);
272 delta))
273 return;
274 } else if (queue_work(respond_queue, &ftdi->respond_work))
275 return;
276 kref_put(&ftdi->kref, ftdi_elan_delete);
277 return;
278} 252}
279 253
280static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta) 254static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
281{ 255{
282 if (delta > 0) { 256 if (queue_delayed_work(respond_queue, &ftdi->respond_work, delta))
283 if (queue_delayed_work(respond_queue, &ftdi->respond_work, 257 kref_get(&ftdi->kref);
284 delta))
285 kref_get(&ftdi->kref);
286 } else if (queue_work(respond_queue, &ftdi->respond_work))
287 kref_get(&ftdi->kref);
288 return;
289} 258}
290 259
291static void ftdi_response_cancel_work(struct usb_ftdi *ftdi) 260static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
@@ -475,9 +444,11 @@ static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi)
475 return; 444 return;
476} 445}
477 446
478static void ftdi_elan_command_work(void *data) 447static void ftdi_elan_command_work(struct work_struct *work)
479{ 448{
480 struct usb_ftdi *ftdi = data; 449 struct usb_ftdi *ftdi =
450 container_of(work, struct usb_ftdi, command_work.work);
451
481 if (ftdi->disconnected > 0) { 452 if (ftdi->disconnected > 0) {
482 ftdi_elan_put_kref(ftdi); 453 ftdi_elan_put_kref(ftdi);
483 return; 454 return;
@@ -500,9 +471,10 @@ static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi)
500 return; 471 return;
501} 472}
502 473
503static void ftdi_elan_respond_work(void *data) 474static void ftdi_elan_respond_work(struct work_struct *work)
504{ 475{
505 struct usb_ftdi *ftdi = data; 476 struct usb_ftdi *ftdi =
477 container_of(work, struct usb_ftdi, respond_work.work);
506 if (ftdi->disconnected > 0) { 478 if (ftdi->disconnected > 0) {
507 ftdi_elan_put_kref(ftdi); 479 ftdi_elan_put_kref(ftdi);
508 return; 480 return;
@@ -534,9 +506,10 @@ static void ftdi_elan_respond_work(void *data)
534* after the FTDI has been synchronized 506* after the FTDI has been synchronized
535* 507*
536*/ 508*/
537static void ftdi_elan_status_work(void *data) 509static void ftdi_elan_status_work(struct work_struct *work)
538{ 510{
539 struct usb_ftdi *ftdi = data; 511 struct usb_ftdi *ftdi =
512 container_of(work, struct usb_ftdi, status_work.work);
540 int work_delay_in_msec = 0; 513 int work_delay_in_msec = 0;
541 if (ftdi->disconnected > 0) { 514 if (ftdi->disconnected > 0) {
542 ftdi_elan_put_kref(ftdi); 515 ftdi_elan_put_kref(ftdi);
@@ -2677,12 +2650,9 @@ static int ftdi_elan_probe(struct usb_interface *interface,
2677 ftdi->class = NULL; 2650 ftdi->class = NULL;
2678 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a" 2651 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a"
2679 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber); 2652 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber);
2680 INIT_WORK(&ftdi->status_work, ftdi_elan_status_work, 2653 INIT_DELAYED_WORK(&ftdi->status_work, ftdi_elan_status_work);
2681 (void *)ftdi); 2654 INIT_DELAYED_WORK(&ftdi->command_work, ftdi_elan_command_work);
2682 INIT_WORK(&ftdi->command_work, ftdi_elan_command_work, 2655 INIT_DELAYED_WORK(&ftdi->respond_work, ftdi_elan_respond_work);
2683 (void *)ftdi);
2684 INIT_WORK(&ftdi->respond_work, ftdi_elan_respond_work,
2685 (void *)ftdi);
2686 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000)); 2656 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000));
2687 return 0; 2657 return 0;
2688 } else { 2658 } else {
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 9110793f81d3..9659c79e187e 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -81,8 +81,8 @@ struct interfacekit {
81 unsigned char *data; 81 unsigned char *data;
82 dma_addr_t data_dma; 82 dma_addr_t data_dma;
83 83
84 struct work_struct do_notify; 84 struct delayed_work do_notify;
85 struct work_struct do_resubmit; 85 struct delayed_work do_resubmit;
86 unsigned long input_events; 86 unsigned long input_events;
87 unsigned long sensor_events; 87 unsigned long sensor_events;
88}; 88};
@@ -374,7 +374,7 @@ static void interfacekit_irq(struct urb *urb)
374 } 374 }
375 375
376 if (kit->input_events || kit->sensor_events) 376 if (kit->input_events || kit->sensor_events)
377 schedule_work(&kit->do_notify); 377 schedule_delayed_work(&kit->do_notify, 0);
378 378
379resubmit: 379resubmit:
380 status = usb_submit_urb(urb, SLAB_ATOMIC); 380 status = usb_submit_urb(urb, SLAB_ATOMIC);
@@ -384,9 +384,10 @@ resubmit:
384 kit->udev->devpath, status); 384 kit->udev->devpath, status);
385} 385}
386 386
387static void do_notify(void *data) 387static void do_notify(struct work_struct *work)
388{ 388{
389 struct interfacekit *kit = data; 389 struct interfacekit *kit =
390 container_of(work, struct interfacekit, do_notify.work);
390 int i; 391 int i;
391 char sysfs_file[8]; 392 char sysfs_file[8];
392 393
@@ -405,9 +406,11 @@ static void do_notify(void *data)
405 } 406 }
406} 407}
407 408
408static void do_resubmit(void *data) 409static void do_resubmit(struct work_struct *work)
409{ 410{
410 set_outputs(data); 411 struct interfacekit *kit =
412 container_of(work, struct interfacekit, do_resubmit.work);
413 set_outputs(kit);
411} 414}
412 415
413#define show_set_output(value) \ 416#define show_set_output(value) \
@@ -575,8 +578,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
575 578
576 kit->udev = usb_get_dev(dev); 579 kit->udev = usb_get_dev(dev);
577 kit->intf = intf; 580 kit->intf = intf;
578 INIT_WORK(&kit->do_notify, do_notify, kit); 581 INIT_DELAYED_WORK(&kit->do_notify, do_notify);
579 INIT_WORK(&kit->do_resubmit, do_resubmit, kit); 582 INIT_DELAYED_WORK(&kit->do_resubmit, do_resubmit);
580 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data, 583 usb_fill_int_urb(kit->irq, kit->udev, pipe, kit->data,
581 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 584 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
582 interfacekit_irq, kit, endpoint->bInterval); 585 interfacekit_irq, kit, endpoint->bInterval);
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index c3469b0a67c2..2bb4fa572bb7 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -41,7 +41,7 @@ struct motorcontrol {
41 unsigned char *data; 41 unsigned char *data;
42 dma_addr_t data_dma; 42 dma_addr_t data_dma;
43 43
44 struct work_struct do_notify; 44 struct delayed_work do_notify;
45 unsigned long input_events; 45 unsigned long input_events;
46 unsigned long speed_events; 46 unsigned long speed_events;
47 unsigned long exceed_events; 47 unsigned long exceed_events;
@@ -148,7 +148,7 @@ static void motorcontrol_irq(struct urb *urb)
148 set_bit(1, &mc->exceed_events); 148 set_bit(1, &mc->exceed_events);
149 149
150 if (mc->input_events || mc->exceed_events || mc->speed_events) 150 if (mc->input_events || mc->exceed_events || mc->speed_events)
151 schedule_work(&mc->do_notify); 151 schedule_delayed_work(&mc->do_notify, 0);
152 152
153resubmit: 153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC); 154 status = usb_submit_urb(urb, SLAB_ATOMIC);
@@ -159,9 +159,10 @@ resubmit:
159 mc->udev->devpath, status); 159 mc->udev->devpath, status);
160} 160}
161 161
162static void do_notify(void *data) 162static void do_notify(struct work_struct *work)
163{ 163{
164 struct motorcontrol *mc = data; 164 struct motorcontrol *mc =
165 container_of(work, struct motorcontrol, do_notify.work);
165 int i; 166 int i;
166 char sysfs_file[8]; 167 char sysfs_file[8];
167 168
@@ -348,7 +349,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
348 mc->udev = usb_get_dev(dev); 349 mc->udev = usb_get_dev(dev);
349 mc->intf = intf; 350 mc->intf = intf;
350 mc->acceleration[0] = mc->acceleration[1] = 10; 351 mc->acceleration[0] = mc->acceleration[1] = 10;
351 INIT_WORK(&mc->do_notify, do_notify, mc); 352 INIT_DELAYED_WORK(&mc->do_notify, do_notify);
352 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data, 353 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
353 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp, 354 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
354 motorcontrol_irq, mc, endpoint->bInterval); 355 motorcontrol_irq, mc, endpoint->bInterval);
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 7c906a43e497..fa78326d0bf0 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -222,7 +222,7 @@ struct kaweth_device
222 int suspend_lowmem_ctrl; 222 int suspend_lowmem_ctrl;
223 int linkstate; 223 int linkstate;
224 int opened; 224 int opened;
225 struct work_struct lowmem_work; 225 struct delayed_work lowmem_work;
226 226
227 struct usb_device *dev; 227 struct usb_device *dev;
228 struct net_device *net; 228 struct net_device *net;
@@ -530,9 +530,10 @@ resubmit:
530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); 530 kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC);
531} 531}
532 532
533static void kaweth_resubmit_tl(void *d) 533static void kaweth_resubmit_tl(struct work_struct *work)
534{ 534{
535 struct kaweth_device *kaweth = (struct kaweth_device *)d; 535 struct kaweth_device *kaweth =
536 container_of(work, struct kaweth_device, lowmem_work.work);
536 537
537 if (IS_BLOCKED(kaweth->status)) 538 if (IS_BLOCKED(kaweth->status))
538 return; 539 return;
@@ -1126,7 +1127,7 @@ err_fw:
1126 1127
1127 /* kaweth is zeroed as part of alloc_netdev */ 1128 /* kaweth is zeroed as part of alloc_netdev */
1128 1129
1129 INIT_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl, (void *)kaweth); 1130 INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl);
1130 1131
1131 SET_MODULE_OWNER(netdev); 1132 SET_MODULE_OWNER(netdev);
1132 1133
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 69eb0db399df..b5690b3834e3 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -1281,9 +1281,9 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1281static struct workqueue_struct *pegasus_workqueue = NULL; 1281static struct workqueue_struct *pegasus_workqueue = NULL;
1282#define CARRIER_CHECK_DELAY (2 * HZ) 1282#define CARRIER_CHECK_DELAY (2 * HZ)
1283 1283
1284static void check_carrier(void *data) 1284static void check_carrier(struct work_struct *work)
1285{ 1285{
1286 pegasus_t *pegasus = data; 1286 pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work);
1287 set_carrier(pegasus->net); 1287 set_carrier(pegasus->net);
1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) { 1288 if (!(pegasus->flags & PEGASUS_UNPLUG)) {
1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, 1289 queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check,
@@ -1319,7 +1319,7 @@ static int pegasus_probe(struct usb_interface *intf,
1319 1319
1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); 1320 tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus);
1321 1321
1322 INIT_WORK(&pegasus->carrier_check, check_carrier, pegasus); 1322 INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier);
1323 1323
1324 pegasus->intf = intf; 1324 pegasus->intf = intf;
1325 pegasus->usb = dev; 1325 pegasus->usb = dev;
diff --git a/drivers/usb/net/pegasus.h b/drivers/usb/net/pegasus.h
index 006438069b66..98f6898cae1f 100644
--- a/drivers/usb/net/pegasus.h
+++ b/drivers/usb/net/pegasus.h
@@ -95,7 +95,7 @@ typedef struct pegasus {
95 int dev_index; 95 int dev_index;
96 int intr_interval; 96 int intr_interval;
97 struct tasklet_struct rx_tl; 97 struct tasklet_struct rx_tl;
98 struct work_struct carrier_check; 98 struct delayed_work carrier_check;
99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb; 99 struct urb *ctrl_urb, *rx_urb, *tx_urb, *intr_urb;
100 struct sk_buff *rx_pool[RX_SKBS]; 100 struct sk_buff *rx_pool[RX_SKBS];
101 struct sk_buff *rx_skb; 101 struct sk_buff *rx_skb;
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 7672e11c94c4..327f97555679 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -782,9 +782,10 @@ static struct ethtool_ops usbnet_ethtool_ops = {
782 * especially now that control transfers can be queued. 782 * especially now that control transfers can be queued.
783 */ 783 */
784static void 784static void
785kevent (void *data) 785kevent (struct work_struct *work)
786{ 786{
787 struct usbnet *dev = data; 787 struct usbnet *dev =
788 container_of(work, struct usbnet, kevent);
788 int status; 789 int status;
789 790
790 /* usb_clear_halt() needs a thread context */ 791 /* usb_clear_halt() needs a thread context */
@@ -1146,7 +1147,7 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
1146 skb_queue_head_init (&dev->done); 1147 skb_queue_head_init (&dev->done);
1147 dev->bh.func = usbnet_bh; 1148 dev->bh.func = usbnet_bh;
1148 dev->bh.data = (unsigned long) dev; 1149 dev->bh.data = (unsigned long) dev;
1149 INIT_WORK (&dev->kevent, kevent, dev); 1150 INIT_WORK (&dev->kevent, kevent);
1150 dev->delay.function = usbnet_bh; 1151 dev->delay.function = usbnet_bh;
1151 dev->delay.data = (unsigned long) dev; 1152 dev->delay.data = (unsigned long) dev;
1152 init_timer (&dev->delay); 1153 init_timer (&dev->delay);
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index b1b5707bc99a..86bcf63b6ba5 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -92,6 +92,7 @@ struct aircable_private {
92 struct circ_buf *rx_buf; /* read buffer */ 92 struct circ_buf *rx_buf; /* read buffer */
93 int rx_flags; /* for throttilng */ 93 int rx_flags; /* for throttilng */
94 struct work_struct rx_work; /* work cue for the receiving line */ 94 struct work_struct rx_work; /* work cue for the receiving line */
95 struct usb_serial_port *port; /* USB port with which associated */
95}; 96};
96 97
97/* Private methods */ 98/* Private methods */
@@ -251,10 +252,11 @@ static void aircable_send(struct usb_serial_port *port)
251 schedule_work(&port->work); 252 schedule_work(&port->work);
252} 253}
253 254
254static void aircable_read(void *params) 255static void aircable_read(struct work_struct *work)
255{ 256{
256 struct usb_serial_port *port = params; 257 struct aircable_private *priv =
257 struct aircable_private *priv = usb_get_serial_port_data(port); 258 container_of(work, struct aircable_private, rx_work);
259 struct usb_serial_port *port = priv->port;
258 struct tty_struct *tty; 260 struct tty_struct *tty;
259 unsigned char *data; 261 unsigned char *data;
260 int count; 262 int count;
@@ -349,7 +351,8 @@ static int aircable_attach (struct usb_serial *serial)
349 } 351 }
350 352
351 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED); 353 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
352 INIT_WORK(&priv->rx_work, aircable_read, port); 354 priv->port = port;
355 INIT_WORK(&priv->rx_work, aircable_read);
353 356
354 usb_set_serial_port_data(serial->port[0], priv); 357 usb_set_serial_port_data(serial->port[0], priv);
355 358
@@ -516,7 +519,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
516 package_length - shift); 519 package_length - shift);
517 } 520 }
518 } 521 }
519 aircable_read(port); 522 aircable_read(&priv->rx_work);
520 } 523 }
521 524
522 /* Schedule the next read _if_ we are still open */ 525 /* Schedule the next read _if_ we are still open */
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 5e3ac281a2f8..83d0e21145b0 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -430,13 +430,14 @@ struct digi_port {
430 int dp_in_close; /* close in progress */ 430 int dp_in_close; /* close in progress */
431 wait_queue_head_t dp_close_wait; /* wait queue for close */ 431 wait_queue_head_t dp_close_wait; /* wait queue for close */
432 struct work_struct dp_wakeup_work; 432 struct work_struct dp_wakeup_work;
433 struct usb_serial_port *dp_port;
433}; 434};
434 435
435 436
436/* Local Function Declarations */ 437/* Local Function Declarations */
437 438
438static void digi_wakeup_write( struct usb_serial_port *port ); 439static void digi_wakeup_write( struct usb_serial_port *port );
439static void digi_wakeup_write_lock(void *); 440static void digi_wakeup_write_lock(struct work_struct *work);
440static int digi_write_oob_command( struct usb_serial_port *port, 441static int digi_write_oob_command( struct usb_serial_port *port,
441 unsigned char *buf, int count, int interruptible ); 442 unsigned char *buf, int count, int interruptible );
442static int digi_write_inb_command( struct usb_serial_port *port, 443static int digi_write_inb_command( struct usb_serial_port *port,
@@ -598,11 +599,12 @@ static inline long cond_wait_interruptible_timeout_irqrestore(
598* on writes. 599* on writes.
599*/ 600*/
600 601
601static void digi_wakeup_write_lock(void *arg) 602static void digi_wakeup_write_lock(struct work_struct *work)
602{ 603{
603 struct usb_serial_port *port = arg; 604 struct digi_port *priv =
605 container_of(work, struct digi_port, dp_wakeup_work);
606 struct usb_serial_port *port = priv->dp_port;
604 unsigned long flags; 607 unsigned long flags;
605 struct digi_port *priv = usb_get_serial_port_data(port);
606 608
607 609
608 spin_lock_irqsave( &priv->dp_port_lock, flags ); 610 spin_lock_irqsave( &priv->dp_port_lock, flags );
@@ -1702,8 +1704,8 @@ dbg( "digi_startup: TOP" );
1702 init_waitqueue_head( &priv->dp_flush_wait ); 1704 init_waitqueue_head( &priv->dp_flush_wait );
1703 priv->dp_in_close = 0; 1705 priv->dp_in_close = 0;
1704 init_waitqueue_head( &priv->dp_close_wait ); 1706 init_waitqueue_head( &priv->dp_close_wait );
1705 INIT_WORK(&priv->dp_wakeup_work, 1707 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1706 digi_wakeup_write_lock, serial->port[i]); 1708 priv->dp_port = serial->port[i];
1707 1709
1708 /* initialize write wait queue for this port */ 1710 /* initialize write wait queue for this port */
1709 init_waitqueue_head( &serial->port[i]->write_wait ); 1711 init_waitqueue_head( &serial->port[i]->write_wait );
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 89ce2775be15..72e4d48f51e9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -559,7 +559,8 @@ struct ftdi_private {
559 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
560 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
561 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
562 struct work_struct rx_work; 562 struct delayed_work rx_work;
563 struct usb_serial_port *port;
563 int rx_processed; 564 int rx_processed;
564 unsigned long rx_bytes; 565 unsigned long rx_bytes;
565 566
@@ -593,7 +594,7 @@ static int ftdi_write_room (struct usb_serial_port *port);
593static int ftdi_chars_in_buffer (struct usb_serial_port *port); 594static int ftdi_chars_in_buffer (struct usb_serial_port *port);
594static void ftdi_write_bulk_callback (struct urb *urb); 595static void ftdi_write_bulk_callback (struct urb *urb);
595static void ftdi_read_bulk_callback (struct urb *urb); 596static void ftdi_read_bulk_callback (struct urb *urb);
596static void ftdi_process_read (void *param); 597static void ftdi_process_read (struct work_struct *work);
597static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old); 598static void ftdi_set_termios (struct usb_serial_port *port, struct termios * old);
598static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file); 599static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file);
599static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear); 600static int ftdi_tiocmset (struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear);
@@ -1201,7 +1202,8 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1201 port->read_urb->transfer_buffer_length = BUFSZ; 1202 port->read_urb->transfer_buffer_length = BUFSZ;
1202 } 1203 }
1203 1204
1204 INIT_WORK(&priv->rx_work, ftdi_process_read, port); 1205 INIT_DELAYED_WORK(&priv->rx_work, ftdi_process_read);
1206 priv->port = port;
1205 1207
1206 /* Free port's existing write urb and transfer buffer. */ 1208 /* Free port's existing write urb and transfer buffer. */
1207 if (port->write_urb) { 1209 if (port->write_urb) {
@@ -1640,17 +1642,18 @@ static void ftdi_read_bulk_callback (struct urb *urb)
1640 priv->rx_bytes += countread; 1642 priv->rx_bytes += countread;
1641 spin_unlock_irqrestore(&priv->rx_lock, flags); 1643 spin_unlock_irqrestore(&priv->rx_lock, flags);
1642 1644
1643 ftdi_process_read(port); 1645 ftdi_process_read(&priv->rx_work.work);
1644 1646
1645} /* ftdi_read_bulk_callback */ 1647} /* ftdi_read_bulk_callback */
1646 1648
1647 1649
1648static void ftdi_process_read (void *param) 1650static void ftdi_process_read (struct work_struct *work)
1649{ /* ftdi_process_read */ 1651{ /* ftdi_process_read */
1650 struct usb_serial_port *port = (struct usb_serial_port*)param; 1652 struct ftdi_private *priv =
1653 container_of(work, struct ftdi_private, rx_work.work);
1654 struct usb_serial_port *port = priv->port;
1651 struct urb *urb; 1655 struct urb *urb;
1652 struct tty_struct *tty; 1656 struct tty_struct *tty;
1653 struct ftdi_private *priv;
1654 char error_flag; 1657 char error_flag;
1655 unsigned char *data; 1658 unsigned char *data;
1656 1659
@@ -2179,7 +2182,7 @@ static void ftdi_unthrottle (struct usb_serial_port *port)
2179 spin_unlock_irqrestore(&priv->rx_lock, flags); 2182 spin_unlock_irqrestore(&priv->rx_lock, flags);
2180 2183
2181 if (actually_throttled) 2184 if (actually_throttled)
2182 schedule_work(&priv->rx_work); 2185 schedule_delayed_work(&priv->rx_work, 0);
2183} 2186}
2184 2187
2185static int __init ftdi_init (void) 2188static int __init ftdi_init (void)
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index 909005107ea2..e09a0bfe6231 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -120,6 +120,8 @@ struct keyspan_pda_private {
120 int tx_throttled; 120 int tx_throttled;
121 struct work_struct wakeup_work; 121 struct work_struct wakeup_work;
122 struct work_struct unthrottle_work; 122 struct work_struct unthrottle_work;
123 struct usb_serial *serial;
124 struct usb_serial_port *port;
123}; 125};
124 126
125 127
@@ -175,9 +177,11 @@ static struct usb_device_id id_table_fake_xircom [] = {
175}; 177};
176#endif 178#endif
177 179
178static void keyspan_pda_wakeup_write( struct usb_serial_port *port ) 180static void keyspan_pda_wakeup_write(struct work_struct *work)
179{ 181{
180 182 struct keyspan_pda_private *priv =
183 container_of(work, struct keyspan_pda_private, wakeup_work);
184 struct usb_serial_port *port = priv->port;
181 struct tty_struct *tty = port->tty; 185 struct tty_struct *tty = port->tty;
182 186
183 /* wake up port processes */ 187 /* wake up port processes */
@@ -187,8 +191,11 @@ static void keyspan_pda_wakeup_write( struct usb_serial_port *port )
187 tty_wakeup(tty); 191 tty_wakeup(tty);
188} 192}
189 193
190static void keyspan_pda_request_unthrottle( struct usb_serial *serial ) 194static void keyspan_pda_request_unthrottle(struct work_struct *work)
191{ 195{
196 struct keyspan_pda_private *priv =
197 container_of(work, struct keyspan_pda_private, unthrottle_work);
198 struct usb_serial *serial = priv->serial;
192 int result; 199 int result;
193 200
194 dbg(" request_unthrottle"); 201 dbg(" request_unthrottle");
@@ -765,11 +772,10 @@ static int keyspan_pda_startup (struct usb_serial *serial)
765 return (1); /* error */ 772 return (1); /* error */
766 usb_set_serial_port_data(serial->port[0], priv); 773 usb_set_serial_port_data(serial->port[0], priv);
767 init_waitqueue_head(&serial->port[0]->write_wait); 774 init_waitqueue_head(&serial->port[0]->write_wait);
768 INIT_WORK(&priv->wakeup_work, (void *)keyspan_pda_wakeup_write, 775 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
769 (void *)(serial->port[0])); 776 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
770 INIT_WORK(&priv->unthrottle_work, 777 priv->serial = serial;
771 (void *)keyspan_pda_request_unthrottle, 778 priv->port = serial->port[0];
772 (void *)(serial));
773 return (0); 779 return (0);
774} 780}
775 781
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index c1257d5292f5..3d5072f14b8d 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -533,9 +533,10 @@ void usb_serial_port_softint(struct usb_serial_port *port)
533 schedule_work(&port->work); 533 schedule_work(&port->work);
534} 534}
535 535
536static void usb_serial_port_work(void *private) 536static void usb_serial_port_work(struct work_struct *work)
537{ 537{
538 struct usb_serial_port *port = private; 538 struct usb_serial_port *port =
539 container_of(work, struct usb_serial_port, work);
539 struct tty_struct *tty; 540 struct tty_struct *tty;
540 541
541 dbg("%s - port %d", __FUNCTION__, port->number); 542 dbg("%s - port %d", __FUNCTION__, port->number);
@@ -799,7 +800,7 @@ int usb_serial_probe(struct usb_interface *interface,
799 port->serial = serial; 800 port->serial = serial;
800 spin_lock_init(&port->lock); 801 spin_lock_init(&port->lock);
801 mutex_init(&port->mutex); 802 mutex_init(&port->mutex);
802 INIT_WORK(&port->work, usb_serial_port_work, port); 803 INIT_WORK(&port->work, usb_serial_port_work);
803 serial->port[i] = port; 804 serial->port[i] = port;
804 } 805 }
805 806
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 4d1cd7aeccd3..154c7d290597 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -227,6 +227,7 @@ struct whiteheat_private {
227 struct list_head rx_urbs_submitted; 227 struct list_head rx_urbs_submitted;
228 struct list_head rx_urb_q; 228 struct list_head rx_urb_q;
229 struct work_struct rx_work; 229 struct work_struct rx_work;
230 struct usb_serial_port *port;
230 struct list_head tx_urbs_free; 231 struct list_head tx_urbs_free;
231 struct list_head tx_urbs_submitted; 232 struct list_head tx_urbs_submitted;
232}; 233};
@@ -241,7 +242,7 @@ static void command_port_read_callback(struct urb *urb);
241static int start_port_read(struct usb_serial_port *port); 242static int start_port_read(struct usb_serial_port *port);
242static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head); 243static struct whiteheat_urb_wrap *urb_to_wrap(struct urb *urb, struct list_head *head);
243static struct list_head *list_first(struct list_head *head); 244static struct list_head *list_first(struct list_head *head);
244static void rx_data_softint(void *private); 245static void rx_data_softint(struct work_struct *work);
245 246
246static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize); 247static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
247static int firm_open(struct usb_serial_port *port); 248static int firm_open(struct usb_serial_port *port);
@@ -424,7 +425,8 @@ static int whiteheat_attach (struct usb_serial *serial)
424 spin_lock_init(&info->lock); 425 spin_lock_init(&info->lock);
425 info->flags = 0; 426 info->flags = 0;
426 info->mcr = 0; 427 info->mcr = 0;
427 INIT_WORK(&info->rx_work, rx_data_softint, port); 428 INIT_WORK(&info->rx_work, rx_data_softint);
429 info->port = port;
428 430
429 INIT_LIST_HEAD(&info->rx_urbs_free); 431 INIT_LIST_HEAD(&info->rx_urbs_free);
430 INIT_LIST_HEAD(&info->rx_urbs_submitted); 432 INIT_LIST_HEAD(&info->rx_urbs_submitted);
@@ -949,7 +951,7 @@ static void whiteheat_unthrottle (struct usb_serial_port *port)
949 spin_unlock_irqrestore(&info->lock, flags); 951 spin_unlock_irqrestore(&info->lock, flags);
950 952
951 if (actually_throttled) 953 if (actually_throttled)
952 rx_data_softint(port); 954 rx_data_softint(&info->rx_work);
953 955
954 return; 956 return;
955} 957}
@@ -1400,10 +1402,11 @@ static struct list_head *list_first(struct list_head *head)
1400} 1402}
1401 1403
1402 1404
1403static void rx_data_softint(void *private) 1405static void rx_data_softint(struct work_struct *work)
1404{ 1406{
1405 struct usb_serial_port *port = (struct usb_serial_port *)private; 1407 struct whiteheat_private *info =
1406 struct whiteheat_private *info = usb_get_serial_port_data(port); 1408 container_of(work, struct whiteheat_private, rx_work);
1409 struct usb_serial_port *port = info->port;
1407 struct tty_struct *tty = port->tty; 1410 struct tty_struct *tty = port->tty;
1408 struct whiteheat_urb_wrap *wrap; 1411 struct whiteheat_urb_wrap *wrap;
1409 struct urb *urb; 1412 struct urb *urb;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 302174b8e477..31f476a64790 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -383,9 +383,9 @@ static void fbcon_update_softback(struct vc_data *vc)
383 softback_top = 0; 383 softback_top = 0;
384} 384}
385 385
386static void fb_flashcursor(void *private) 386static void fb_flashcursor(struct work_struct *work)
387{ 387{
388 struct fb_info *info = private; 388 struct fb_info *info = container_of(work, struct fb_info, queue);
389 struct fbcon_ops *ops = info->fbcon_par; 389 struct fbcon_ops *ops = info->fbcon_par;
390 struct display *p; 390 struct display *p;
391 struct vc_data *vc = NULL; 391 struct vc_data *vc = NULL;
@@ -442,7 +442,7 @@ static void fbcon_add_cursor_timer(struct fb_info *info)
442 if ((!info->queue.func || info->queue.func == fb_flashcursor) && 442 if ((!info->queue.func || info->queue.func == fb_flashcursor) &&
443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) { 443 !(ops->flags & FBCON_FLAGS_CURSOR_TIMER)) {
444 if (!info->queue.func) 444 if (!info->queue.func)
445 INIT_WORK(&info->queue, fb_flashcursor, info); 445 INIT_WORK(&info->queue, fb_flashcursor);
446 446
447 init_timer(&ops->cursor_timer); 447 init_timer(&ops->cursor_timer);
448 ops->cursor_timer.function = cursor_timer_handler; 448 ops->cursor_timer.function = cursor_timer_handler;
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c
index fdb33cd21a27..cb26c6df0583 100644
--- a/drivers/video/platinumfb.c
+++ b/drivers/video/platinumfb.c
@@ -34,6 +34,7 @@
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/pgtable.h> 35#include <asm/pgtable.h>
36#include <asm/of_device.h> 36#include <asm/of_device.h>
37#include <asm/of_platform.h>
37 38
38#include "macmodes.h" 39#include "macmodes.h"
39#include "platinumfb.h" 40#include "platinumfb.h"
@@ -682,14 +683,14 @@ static int __init platinumfb_init(void)
682 return -ENODEV; 683 return -ENODEV;
683 platinumfb_setup(option); 684 platinumfb_setup(option);
684#endif 685#endif
685 of_register_driver(&platinum_driver); 686 of_register_platform_driver(&platinum_driver);
686 687
687 return 0; 688 return 0;
688} 689}
689 690
690static void __exit platinumfb_exit(void) 691static void __exit platinumfb_exit(void)
691{ 692{
692 of_unregister_driver(&platinum_driver); 693 of_unregister_platform_driver(&platinum_driver);
693} 694}
694 695
695MODULE_LICENSE("GPL"); 696MODULE_LICENSE("GPL");
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 8a8ae55a7403..38eb0b69c2d7 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -964,9 +964,10 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
964 * Our LCD controller task (which is called when we blank or unblank) 964 * Our LCD controller task (which is called when we blank or unblank)
965 * via keventd. 965 * via keventd.
966 */ 966 */
967static void pxafb_task(void *dummy) 967static void pxafb_task(struct work_struct *work)
968{ 968{
969 struct pxafb_info *fbi = dummy; 969 struct pxafb_info *fbi =
970 container_of(work, struct pxafb_info, task);
970 u_int state = xchg(&fbi->task_state, -1); 971 u_int state = xchg(&fbi->task_state, -1);
971 972
972 set_ctrlr_state(fbi, state); 973 set_ctrlr_state(fbi, state);
@@ -1159,7 +1160,7 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1159 } 1160 }
1160 1161
1161 init_waitqueue_head(&fbi->ctrlr_wait); 1162 init_waitqueue_head(&fbi->ctrlr_wait);
1162 INIT_WORK(&fbi->task, pxafb_task, fbi); 1163 INIT_WORK(&fbi->task, pxafb_task);
1163 init_MUTEX(&fbi->ctrlr_sem); 1164 init_MUTEX(&fbi->ctrlr_sem);
1164 1165
1165 return fbi; 1166 return fbi;
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index 90a79c784549..944273c3dbff 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -110,8 +110,8 @@ struct v9fs_mux_rpc {
110}; 110};
111 111
112static int v9fs_poll_proc(void *); 112static int v9fs_poll_proc(void *);
113static void v9fs_read_work(void *); 113static void v9fs_read_work(struct work_struct *work);
114static void v9fs_write_work(void *); 114static void v9fs_write_work(struct work_struct *work);
115static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address, 115static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
116 poll_table * p); 116 poll_table * p);
117static u16 v9fs_mux_get_tag(struct v9fs_mux_data *); 117static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
@@ -297,8 +297,8 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
297 m->rbuf = NULL; 297 m->rbuf = NULL;
298 m->wpos = m->wsize = 0; 298 m->wpos = m->wsize = 0;
299 m->wbuf = NULL; 299 m->wbuf = NULL;
300 INIT_WORK(&m->rq, v9fs_read_work, m); 300 INIT_WORK(&m->rq, v9fs_read_work);
301 INIT_WORK(&m->wq, v9fs_write_work, m); 301 INIT_WORK(&m->wq, v9fs_write_work);
302 m->wsched = 0; 302 m->wsched = 0;
303 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr)); 303 memset(&m->poll_waddr, 0, sizeof(m->poll_waddr));
304 m->poll_task = NULL; 304 m->poll_task = NULL;
@@ -458,13 +458,13 @@ static int v9fs_poll_proc(void *a)
458/** 458/**
459 * v9fs_write_work - called when a transport can send some data 459 * v9fs_write_work - called when a transport can send some data
460 */ 460 */
461static void v9fs_write_work(void *a) 461static void v9fs_write_work(struct work_struct *work)
462{ 462{
463 int n, err; 463 int n, err;
464 struct v9fs_mux_data *m; 464 struct v9fs_mux_data *m;
465 struct v9fs_req *req; 465 struct v9fs_req *req;
466 466
467 m = a; 467 m = container_of(work, struct v9fs_mux_data, wq);
468 468
469 if (m->err < 0) { 469 if (m->err < 0) {
470 clear_bit(Wworksched, &m->wsched); 470 clear_bit(Wworksched, &m->wsched);
@@ -564,7 +564,7 @@ static void process_request(struct v9fs_mux_data *m, struct v9fs_req *req)
564/** 564/**
565 * v9fs_read_work - called when there is some data to be read from a transport 565 * v9fs_read_work - called when there is some data to be read from a transport
566 */ 566 */
567static void v9fs_read_work(void *a) 567static void v9fs_read_work(struct work_struct *work)
568{ 568{
569 int n, err; 569 int n, err;
570 struct v9fs_mux_data *m; 570 struct v9fs_mux_data *m;
@@ -572,7 +572,7 @@ static void v9fs_read_work(void *a)
572 struct v9fs_fcall *rcall; 572 struct v9fs_fcall *rcall;
573 char *rbuf; 573 char *rbuf;
574 574
575 m = a; 575 m = container_of(work, struct v9fs_mux_data, rq);
576 576
577 if (m->err < 0) 577 if (m->err < 0)
578 return; 578 return;
diff --git a/fs/aio.c b/fs/aio.c
index 277a5f2d18ad..287a1bc7a182 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -53,13 +53,13 @@ static kmem_cache_t *kioctx_cachep;
53static struct workqueue_struct *aio_wq; 53static struct workqueue_struct *aio_wq;
54 54
55/* Used for rare fput completion. */ 55/* Used for rare fput completion. */
56static void aio_fput_routine(void *); 56static void aio_fput_routine(struct work_struct *);
57static DECLARE_WORK(fput_work, aio_fput_routine, NULL); 57static DECLARE_WORK(fput_work, aio_fput_routine);
58 58
59static DEFINE_SPINLOCK(fput_lock); 59static DEFINE_SPINLOCK(fput_lock);
60static LIST_HEAD(fput_head); 60static LIST_HEAD(fput_head);
61 61
62static void aio_kick_handler(void *); 62static void aio_kick_handler(struct work_struct *);
63static void aio_queue_work(struct kioctx *); 63static void aio_queue_work(struct kioctx *);
64 64
65/* aio_setup 65/* aio_setup
@@ -227,7 +227,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
227 227
228 INIT_LIST_HEAD(&ctx->active_reqs); 228 INIT_LIST_HEAD(&ctx->active_reqs);
229 INIT_LIST_HEAD(&ctx->run_list); 229 INIT_LIST_HEAD(&ctx->run_list);
230 INIT_WORK(&ctx->wq, aio_kick_handler, ctx); 230 INIT_DELAYED_WORK(&ctx->wq, aio_kick_handler);
231 231
232 if (aio_setup_ring(ctx) < 0) 232 if (aio_setup_ring(ctx) < 0)
233 goto out_freectx; 233 goto out_freectx;
@@ -469,7 +469,7 @@ static inline void really_put_req(struct kioctx *ctx, struct kiocb *req)
469 wake_up(&ctx->wait); 469 wake_up(&ctx->wait);
470} 470}
471 471
472static void aio_fput_routine(void *data) 472static void aio_fput_routine(struct work_struct *data)
473{ 473{
474 spin_lock_irq(&fput_lock); 474 spin_lock_irq(&fput_lock);
475 while (likely(!list_empty(&fput_head))) { 475 while (likely(!list_empty(&fput_head))) {
@@ -857,9 +857,9 @@ static inline void aio_run_all_iocbs(struct kioctx *ctx)
857 * space. 857 * space.
858 * Run on aiod's context. 858 * Run on aiod's context.
859 */ 859 */
860static void aio_kick_handler(void *data) 860static void aio_kick_handler(struct work_struct *work)
861{ 861{
862 struct kioctx *ctx = data; 862 struct kioctx *ctx = container_of(work, struct kioctx, wq.work);
863 mm_segment_t oldfs = get_fs(); 863 mm_segment_t oldfs = get_fs();
864 int requeue; 864 int requeue;
865 865
@@ -874,7 +874,7 @@ static void aio_kick_handler(void *data)
874 * we're in a worker thread already, don't use queue_delayed_work, 874 * we're in a worker thread already, don't use queue_delayed_work,
875 */ 875 */
876 if (requeue) 876 if (requeue)
877 queue_work(aio_wq, &ctx->wq); 877 queue_delayed_work(aio_wq, &ctx->wq, 0);
878} 878}
879 879
880 880
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 79b05a1a4365..cc72bb43061d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1582,6 +1582,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1582 1582
1583 sz += thread_status_size; 1583 sz += thread_status_size;
1584 1584
1585#ifdef ELF_CORE_WRITE_EXTRA_NOTES
1586 sz += ELF_CORE_EXTRA_NOTES_SIZE;
1587#endif
1588
1585 fill_elf_note_phdr(&phdr, sz, offset); 1589 fill_elf_note_phdr(&phdr, sz, offset);
1586 offset += sz; 1590 offset += sz;
1587 DUMP_WRITE(&phdr, sizeof(phdr)); 1591 DUMP_WRITE(&phdr, sizeof(phdr));
@@ -1622,6 +1626,10 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
1622 if (!writenote(notes + i, file, &foffset)) 1626 if (!writenote(notes + i, file, &foffset))
1623 goto end_coredump; 1627 goto end_coredump;
1624 1628
1629#ifdef ELF_CORE_WRITE_EXTRA_NOTES
1630 ELF_CORE_WRITE_EXTRA_NOTES;
1631#endif
1632
1625 /* write out the thread status notes section */ 1633 /* write out the thread status notes section */
1626 list_for_each(t, &thread_list) { 1634 list_for_each(t, &thread_list) {
1627 struct elf_thread_status *tmp = 1635 struct elf_thread_status *tmp =
diff --git a/fs/bio.c b/fs/bio.c
index aa4d09bd4e71..50c40ce2cead 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -940,16 +940,16 @@ static void bio_release_pages(struct bio *bio)
940 * run one bio_put() against the BIO. 940 * run one bio_put() against the BIO.
941 */ 941 */
942 942
943static void bio_dirty_fn(void *data); 943static void bio_dirty_fn(struct work_struct *work);
944 944
945static DECLARE_WORK(bio_dirty_work, bio_dirty_fn, NULL); 945static DECLARE_WORK(bio_dirty_work, bio_dirty_fn);
946static DEFINE_SPINLOCK(bio_dirty_lock); 946static DEFINE_SPINLOCK(bio_dirty_lock);
947static struct bio *bio_dirty_list; 947static struct bio *bio_dirty_list;
948 948
949/* 949/*
950 * This runs in process context 950 * This runs in process context
951 */ 951 */
952static void bio_dirty_fn(void *data) 952static void bio_dirty_fn(struct work_struct *work)
953{ 953{
954 unsigned long flags; 954 unsigned long flags;
955 struct bio *bio; 955 struct bio *bio;
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 8a3b6a1a6ad1..c398861f78a5 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -93,8 +93,8 @@ static struct configfs_dirent *configfs_new_dirent(struct configfs_dirent * pare
93 * 93 *
94 * called with parent inode's i_mutex held 94 * called with parent inode's i_mutex held
95 */ 95 */
96int configfs_dirent_exists(struct configfs_dirent *parent_sd, 96static int configfs_dirent_exists(struct configfs_dirent *parent_sd,
97 const unsigned char *new) 97 const unsigned char *new)
98{ 98{
99 struct configfs_dirent * sd; 99 struct configfs_dirent * sd;
100 100
@@ -1176,8 +1176,9 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
1176 return; 1176 return;
1177 } 1177 }
1178 1178
1179 mutex_lock(&configfs_sb->s_root->d_inode->i_mutex); 1179 mutex_lock_nested(&configfs_sb->s_root->d_inode->i_mutex,
1180 mutex_lock(&dentry->d_inode->i_mutex); 1180 I_MUTEX_PARENT);
1181 mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
1181 if (configfs_detach_prep(dentry)) { 1182 if (configfs_detach_prep(dentry)) {
1182 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); 1183 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n");
1183 } 1184 }
diff --git a/fs/file.c b/fs/file.c
index 8e81775c5dc8..3787e82f54c1 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -91,8 +91,10 @@ out:
91 spin_unlock(&fddef->lock); 91 spin_unlock(&fddef->lock);
92} 92}
93 93
94static void free_fdtable_work(struct fdtable_defer *f) 94static void free_fdtable_work(struct work_struct *work)
95{ 95{
96 struct fdtable_defer *f =
97 container_of(work, struct fdtable_defer, wq);
96 struct fdtable *fdt; 98 struct fdtable *fdt;
97 99
98 spin_lock_bh(&f->lock); 100 spin_lock_bh(&f->lock);
@@ -351,7 +353,7 @@ static void __devinit fdtable_defer_list_init(int cpu)
351{ 353{
352 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); 354 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
353 spin_lock_init(&fddef->lock); 355 spin_lock_init(&fddef->lock);
354 INIT_WORK(&fddef->wq, (void (*)(void *))free_fdtable_work, fddef); 356 INIT_WORK(&fddef->wq, free_fdtable_work);
355 init_timer(&fddef->timer); 357 init_timer(&fddef->timer);
356 fddef->timer.data = (unsigned long)fddef; 358 fddef->timer.data = (unsigned long)fddef;
357 fddef->timer.function = fdtable_timer; 359 fddef->timer.function = fdtable_timer;
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 78fe0fae23ff..55f5333dae99 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -35,7 +35,7 @@
35 35
36struct greedy { 36struct greedy {
37 struct gfs2_holder gr_gh; 37 struct gfs2_holder gr_gh;
38 struct work_struct gr_work; 38 struct delayed_work gr_work;
39}; 39};
40 40
41struct gfs2_gl_hash_bucket { 41struct gfs2_gl_hash_bucket {
@@ -1368,9 +1368,9 @@ static void gfs2_glock_prefetch(struct gfs2_glock *gl, unsigned int state,
1368 glops->go_xmote_th(gl, state, flags); 1368 glops->go_xmote_th(gl, state, flags);
1369} 1369}
1370 1370
1371static void greedy_work(void *data) 1371static void greedy_work(struct work_struct *work)
1372{ 1372{
1373 struct greedy *gr = data; 1373 struct greedy *gr = container_of(work, struct greedy, gr_work.work);
1374 struct gfs2_holder *gh = &gr->gr_gh; 1374 struct gfs2_holder *gh = &gr->gr_gh;
1375 struct gfs2_glock *gl = gh->gh_gl; 1375 struct gfs2_glock *gl = gh->gh_gl;
1376 const struct gfs2_glock_operations *glops = gl->gl_ops; 1376 const struct gfs2_glock_operations *glops = gl->gl_ops;
@@ -1422,7 +1422,7 @@ int gfs2_glock_be_greedy(struct gfs2_glock *gl, unsigned int time)
1422 1422
1423 gfs2_holder_init(gl, 0, 0, gh); 1423 gfs2_holder_init(gl, 0, 0, gh);
1424 set_bit(HIF_GREEDY, &gh->gh_iflags); 1424 set_bit(HIF_GREEDY, &gh->gh_iflags);
1425 INIT_WORK(&gr->gr_work, greedy_work, gr); 1425 INIT_DELAYED_WORK(&gr->gr_work, greedy_work);
1426 1426
1427 set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags); 1427 set_bit(GLF_SKIP_WAITERS2, &gl->gl_flags);
1428 schedule_delayed_work(&gr->gr_work, time); 1428 schedule_delayed_work(&gr->gr_work, time);
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 42e3bef270c9..72dad552aa00 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -577,12 +577,12 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
577 server->rcv.ptr = (unsigned char*)&server->rcv.buf; 577 server->rcv.ptr = (unsigned char*)&server->rcv.buf;
578 server->rcv.len = 10; 578 server->rcv.len = 10;
579 server->rcv.state = 0; 579 server->rcv.state = 0;
580 INIT_WORK(&server->rcv.tq, ncp_tcp_rcv_proc, server); 580 INIT_WORK(&server->rcv.tq, ncp_tcp_rcv_proc);
581 INIT_WORK(&server->tx.tq, ncp_tcp_tx_proc, server); 581 INIT_WORK(&server->tx.tq, ncp_tcp_tx_proc);
582 sock->sk->sk_write_space = ncp_tcp_write_space; 582 sock->sk->sk_write_space = ncp_tcp_write_space;
583 } else { 583 } else {
584 INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc, server); 584 INIT_WORK(&server->rcv.tq, ncpdgram_rcv_proc);
585 INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc, server); 585 INIT_WORK(&server->timeout_tq, ncpdgram_timeout_proc);
586 server->timeout_tm.data = (unsigned long)server; 586 server->timeout_tm.data = (unsigned long)server;
587 server->timeout_tm.function = ncpdgram_timeout_call; 587 server->timeout_tm.function = ncpdgram_timeout_call;
588 } 588 }
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 11c2b252ebed..e496d8b65e92 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -350,9 +350,10 @@ static void info_server(struct ncp_server *server, unsigned int id, const void *
350 } 350 }
351} 351}
352 352
353void ncpdgram_rcv_proc(void *s) 353void ncpdgram_rcv_proc(struct work_struct *work)
354{ 354{
355 struct ncp_server *server = s; 355 struct ncp_server *server =
356 container_of(work, struct ncp_server, rcv.tq);
356 struct socket* sock; 357 struct socket* sock;
357 358
358 sock = server->ncp_sock; 359 sock = server->ncp_sock;
@@ -468,9 +469,10 @@ static void __ncpdgram_timeout_proc(struct ncp_server *server)
468 } 469 }
469} 470}
470 471
471void ncpdgram_timeout_proc(void *s) 472void ncpdgram_timeout_proc(struct work_struct *work)
472{ 473{
473 struct ncp_server *server = s; 474 struct ncp_server *server =
475 container_of(work, struct ncp_server, timeout_tq);
474 mutex_lock(&server->rcv.creq_mutex); 476 mutex_lock(&server->rcv.creq_mutex);
475 __ncpdgram_timeout_proc(server); 477 __ncpdgram_timeout_proc(server);
476 mutex_unlock(&server->rcv.creq_mutex); 478 mutex_unlock(&server->rcv.creq_mutex);
@@ -652,18 +654,20 @@ skipdata:;
652 } 654 }
653} 655}
654 656
655void ncp_tcp_rcv_proc(void *s) 657void ncp_tcp_rcv_proc(struct work_struct *work)
656{ 658{
657 struct ncp_server *server = s; 659 struct ncp_server *server =
660 container_of(work, struct ncp_server, rcv.tq);
658 661
659 mutex_lock(&server->rcv.creq_mutex); 662 mutex_lock(&server->rcv.creq_mutex);
660 __ncptcp_rcv_proc(server); 663 __ncptcp_rcv_proc(server);
661 mutex_unlock(&server->rcv.creq_mutex); 664 mutex_unlock(&server->rcv.creq_mutex);
662} 665}
663 666
664void ncp_tcp_tx_proc(void *s) 667void ncp_tcp_tx_proc(struct work_struct *work)
665{ 668{
666 struct ncp_server *server = s; 669 struct ncp_server *server =
670 container_of(work, struct ncp_server, tx.tq);
667 671
668 mutex_lock(&server->rcv.creq_mutex); 672 mutex_lock(&server->rcv.creq_mutex);
669 __ncptcp_try_send(server); 673 __ncptcp_try_send(server);
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 5fea638743e4..23ab145daa2d 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -143,7 +143,7 @@ static struct nfs_client *nfs_alloc_client(const char *hostname,
143 INIT_LIST_HEAD(&clp->cl_state_owners); 143 INIT_LIST_HEAD(&clp->cl_state_owners);
144 INIT_LIST_HEAD(&clp->cl_unused); 144 INIT_LIST_HEAD(&clp->cl_unused);
145 spin_lock_init(&clp->cl_lock); 145 spin_lock_init(&clp->cl_lock);
146 INIT_WORK(&clp->cl_renewd, nfs4_renew_state, clp); 146 INIT_DELAYED_WORK(&clp->cl_renewd, nfs4_renew_state);
147 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client"); 147 rpc_init_wait_queue(&clp->cl_rpcwaitq, "NFS client");
148 clp->cl_boot_time = CURRENT_TIME; 148 clp->cl_boot_time = CURRENT_TIME;
149 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED; 149 clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index ec1114b33d89..371b804e7cc8 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -18,10 +18,10 @@
18 18
19#define NFSDBG_FACILITY NFSDBG_VFS 19#define NFSDBG_FACILITY NFSDBG_VFS
20 20
21static void nfs_expire_automounts(void *list); 21static void nfs_expire_automounts(struct work_struct *work);
22 22
23LIST_HEAD(nfs_automount_list); 23LIST_HEAD(nfs_automount_list);
24static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list); 24static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts);
25int nfs_mountpoint_expiry_timeout = 500 * HZ; 25int nfs_mountpoint_expiry_timeout = 500 * HZ;
26 26
27static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, 27static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
@@ -164,9 +164,9 @@ struct inode_operations nfs_referral_inode_operations = {
164 .follow_link = nfs_follow_mountpoint, 164 .follow_link = nfs_follow_mountpoint,
165}; 165};
166 166
167static void nfs_expire_automounts(void *data) 167static void nfs_expire_automounts(struct work_struct *work)
168{ 168{
169 struct list_head *list = (struct list_head *)data; 169 struct list_head *list = &nfs_automount_list;
170 170
171 mark_mounts_for_expiry(list); 171 mark_mounts_for_expiry(list);
172 if (!list_empty(list)) 172 if (!list_empty(list))
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 6f346677332d..c26cd978c7cc 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -185,7 +185,7 @@ extern const u32 nfs4_fs_locations_bitmap[2];
185extern void nfs4_schedule_state_renewal(struct nfs_client *); 185extern void nfs4_schedule_state_renewal(struct nfs_client *);
186extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); 186extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
187extern void nfs4_kill_renewd(struct nfs_client *); 187extern void nfs4_kill_renewd(struct nfs_client *);
188extern void nfs4_renew_state(void *); 188extern void nfs4_renew_state(struct work_struct *);
189 189
190/* nfs4state.c */ 190/* nfs4state.c */
191struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp); 191struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp);
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 7b6df1852e75..823298561c0a 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -59,9 +59,10 @@
59#define NFSDBG_FACILITY NFSDBG_PROC 59#define NFSDBG_FACILITY NFSDBG_PROC
60 60
61void 61void
62nfs4_renew_state(void *data) 62nfs4_renew_state(struct work_struct *work)
63{ 63{
64 struct nfs_client *clp = (struct nfs_client *)data; 64 struct nfs_client *clp =
65 container_of(work, struct nfs_client, cl_renewd.work);
65 struct rpc_cred *cred; 66 struct rpc_cred *cred;
66 long lease, timeout; 67 long lease, timeout;
67 unsigned long last, now; 68 unsigned long last, now;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 293b6495829f..e431e93ab503 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -1829,9 +1829,8 @@ out:
1829} 1829}
1830 1830
1831static struct workqueue_struct *laundry_wq; 1831static struct workqueue_struct *laundry_wq;
1832static struct work_struct laundromat_work; 1832static void laundromat_main(struct work_struct *);
1833static void laundromat_main(void *); 1833static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main);
1834static DECLARE_WORK(laundromat_work, laundromat_main, NULL);
1835 1834
1836__be32 1835__be32
1837nfsd4_renew(clientid_t *clid) 1836nfsd4_renew(clientid_t *clid)
@@ -1940,7 +1939,7 @@ nfs4_laundromat(void)
1940} 1939}
1941 1940
1942void 1941void
1943laundromat_main(void *not_used) 1942laundromat_main(struct work_struct *not_used)
1944{ 1943{
1945 time_t t; 1944 time_t t;
1946 1945
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index f43bc5f18a35..edc91ca3792a 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -52,14 +52,14 @@ static int ocfs2_extent_contig(struct inode *inode,
52 u64 blkno); 52 u64 blkno);
53 53
54static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, 54static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
55 struct ocfs2_journal_handle *handle, 55 handle_t *handle,
56 struct inode *inode, 56 struct inode *inode,
57 int wanted, 57 int wanted,
58 struct ocfs2_alloc_context *meta_ac, 58 struct ocfs2_alloc_context *meta_ac,
59 struct buffer_head *bhs[]); 59 struct buffer_head *bhs[]);
60 60
61static int ocfs2_add_branch(struct ocfs2_super *osb, 61static int ocfs2_add_branch(struct ocfs2_super *osb,
62 struct ocfs2_journal_handle *handle, 62 handle_t *handle,
63 struct inode *inode, 63 struct inode *inode,
64 struct buffer_head *fe_bh, 64 struct buffer_head *fe_bh,
65 struct buffer_head *eb_bh, 65 struct buffer_head *eb_bh,
@@ -67,14 +67,14 @@ static int ocfs2_add_branch(struct ocfs2_super *osb,
67 struct ocfs2_alloc_context *meta_ac); 67 struct ocfs2_alloc_context *meta_ac);
68 68
69static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 69static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
70 struct ocfs2_journal_handle *handle, 70 handle_t *handle,
71 struct inode *inode, 71 struct inode *inode,
72 struct buffer_head *fe_bh, 72 struct buffer_head *fe_bh,
73 struct ocfs2_alloc_context *meta_ac, 73 struct ocfs2_alloc_context *meta_ac,
74 struct buffer_head **ret_new_eb_bh); 74 struct buffer_head **ret_new_eb_bh);
75 75
76static int ocfs2_do_insert_extent(struct ocfs2_super *osb, 76static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
77 struct ocfs2_journal_handle *handle, 77 handle_t *handle,
78 struct inode *inode, 78 struct inode *inode,
79 struct buffer_head *fe_bh, 79 struct buffer_head *fe_bh,
80 u64 blkno, 80 u64 blkno,
@@ -152,7 +152,7 @@ bail:
152 * l_count for you 152 * l_count for you
153 */ 153 */
154static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, 154static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb,
155 struct ocfs2_journal_handle *handle, 155 handle_t *handle,
156 struct inode *inode, 156 struct inode *inode,
157 int wanted, 157 int wanted,
158 struct ocfs2_alloc_context *meta_ac, 158 struct ocfs2_alloc_context *meta_ac,
@@ -253,7 +253,7 @@ bail:
253 * contain a single record with e_clusters == 0. 253 * contain a single record with e_clusters == 0.
254 */ 254 */
255static int ocfs2_add_branch(struct ocfs2_super *osb, 255static int ocfs2_add_branch(struct ocfs2_super *osb,
256 struct ocfs2_journal_handle *handle, 256 handle_t *handle,
257 struct inode *inode, 257 struct inode *inode,
258 struct buffer_head *fe_bh, 258 struct buffer_head *fe_bh,
259 struct buffer_head *eb_bh, 259 struct buffer_head *eb_bh,
@@ -418,7 +418,7 @@ bail:
418 * after this call. 418 * after this call.
419 */ 419 */
420static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, 420static int ocfs2_shift_tree_depth(struct ocfs2_super *osb,
421 struct ocfs2_journal_handle *handle, 421 handle_t *handle,
422 struct inode *inode, 422 struct inode *inode,
423 struct buffer_head *fe_bh, 423 struct buffer_head *fe_bh,
424 struct ocfs2_alloc_context *meta_ac, 424 struct ocfs2_alloc_context *meta_ac,
@@ -520,7 +520,7 @@ bail:
520 * down. 520 * down.
521 */ 521 */
522static int ocfs2_do_insert_extent(struct ocfs2_super *osb, 522static int ocfs2_do_insert_extent(struct ocfs2_super *osb,
523 struct ocfs2_journal_handle *handle, 523 handle_t *handle,
524 struct inode *inode, 524 struct inode *inode,
525 struct buffer_head *fe_bh, 525 struct buffer_head *fe_bh,
526 u64 start_blk, 526 u64 start_blk,
@@ -809,7 +809,7 @@ bail:
809 809
810/* the caller needs to update fe->i_clusters */ 810/* the caller needs to update fe->i_clusters */
811int ocfs2_insert_extent(struct ocfs2_super *osb, 811int ocfs2_insert_extent(struct ocfs2_super *osb,
812 struct ocfs2_journal_handle *handle, 812 handle_t *handle,
813 struct inode *inode, 813 struct inode *inode,
814 struct buffer_head *fe_bh, 814 struct buffer_head *fe_bh,
815 u64 start_blk, 815 u64 start_blk,
@@ -951,7 +951,7 @@ static int ocfs2_truncate_log_can_coalesce(struct ocfs2_truncate_log *tl,
951} 951}
952 952
953static int ocfs2_truncate_log_append(struct ocfs2_super *osb, 953static int ocfs2_truncate_log_append(struct ocfs2_super *osb,
954 struct ocfs2_journal_handle *handle, 954 handle_t *handle,
955 u64 start_blk, 955 u64 start_blk,
956 unsigned int num_clusters) 956 unsigned int num_clusters)
957{ 957{
@@ -1034,7 +1034,7 @@ bail:
1034} 1034}
1035 1035
1036static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, 1036static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
1037 struct ocfs2_journal_handle *handle, 1037 handle_t *handle,
1038 struct inode *data_alloc_inode, 1038 struct inode *data_alloc_inode,
1039 struct buffer_head *data_alloc_bh) 1039 struct buffer_head *data_alloc_bh)
1040{ 1040{
@@ -1113,7 +1113,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1113{ 1113{
1114 int status; 1114 int status;
1115 unsigned int num_to_flush; 1115 unsigned int num_to_flush;
1116 struct ocfs2_journal_handle *handle = NULL; 1116 handle_t *handle;
1117 struct inode *tl_inode = osb->osb_tl_inode; 1117 struct inode *tl_inode = osb->osb_tl_inode;
1118 struct inode *data_alloc_inode = NULL; 1118 struct inode *data_alloc_inode = NULL;
1119 struct buffer_head *tl_bh = osb->osb_tl_bh; 1119 struct buffer_head *tl_bh = osb->osb_tl_bh;
@@ -1130,7 +1130,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1130 if (!OCFS2_IS_VALID_DINODE(di)) { 1130 if (!OCFS2_IS_VALID_DINODE(di)) {
1131 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); 1131 OCFS2_RO_ON_INVALID_DINODE(osb->sb, di);
1132 status = -EIO; 1132 status = -EIO;
1133 goto bail; 1133 goto out;
1134 } 1134 }
1135 1135
1136 num_to_flush = le16_to_cpu(tl->tl_used); 1136 num_to_flush = le16_to_cpu(tl->tl_used);
@@ -1138,14 +1138,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1138 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); 1138 num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno);
1139 if (!num_to_flush) { 1139 if (!num_to_flush) {
1140 status = 0; 1140 status = 0;
1141 goto bail; 1141 goto out;
1142 }
1143
1144 handle = ocfs2_alloc_handle(osb);
1145 if (!handle) {
1146 status = -ENOMEM;
1147 mlog_errno(status);
1148 goto bail;
1149 } 1142 }
1150 1143
1151 data_alloc_inode = ocfs2_get_system_file_inode(osb, 1144 data_alloc_inode = ocfs2_get_system_file_inode(osb,
@@ -1154,41 +1147,40 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1154 if (!data_alloc_inode) { 1147 if (!data_alloc_inode) {
1155 status = -EINVAL; 1148 status = -EINVAL;
1156 mlog(ML_ERROR, "Could not get bitmap inode!\n"); 1149 mlog(ML_ERROR, "Could not get bitmap inode!\n");
1157 goto bail; 1150 goto out;
1158 } 1151 }
1159 1152
1160 ocfs2_handle_add_inode(handle, data_alloc_inode); 1153 mutex_lock(&data_alloc_inode->i_mutex);
1161 status = ocfs2_meta_lock(data_alloc_inode, handle, &data_alloc_bh, 1); 1154
1155 status = ocfs2_meta_lock(data_alloc_inode, &data_alloc_bh, 1);
1162 if (status < 0) { 1156 if (status < 0) {
1163 mlog_errno(status); 1157 mlog_errno(status);
1164 goto bail; 1158 goto out_mutex;
1165 } 1159 }
1166 1160
1167 handle = ocfs2_start_trans(osb, handle, OCFS2_TRUNCATE_LOG_UPDATE); 1161 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1168 if (IS_ERR(handle)) { 1162 if (IS_ERR(handle)) {
1169 status = PTR_ERR(handle); 1163 status = PTR_ERR(handle);
1170 handle = NULL;
1171 mlog_errno(status); 1164 mlog_errno(status);
1172 goto bail; 1165 goto out_unlock;
1173 } 1166 }
1174 1167
1175 status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode, 1168 status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode,
1176 data_alloc_bh); 1169 data_alloc_bh);
1177 if (status < 0) { 1170 if (status < 0)
1178 mlog_errno(status); 1171 mlog_errno(status);
1179 goto bail;
1180 }
1181 1172
1182bail: 1173 ocfs2_commit_trans(osb, handle);
1183 if (handle)
1184 ocfs2_commit_trans(handle);
1185 1174
1186 if (data_alloc_inode) 1175out_unlock:
1187 iput(data_alloc_inode); 1176 brelse(data_alloc_bh);
1177 ocfs2_meta_unlock(data_alloc_inode, 1);
1188 1178
1189 if (data_alloc_bh) 1179out_mutex:
1190 brelse(data_alloc_bh); 1180 mutex_unlock(&data_alloc_inode->i_mutex);
1181 iput(data_alloc_inode);
1191 1182
1183out:
1192 mlog_exit(status); 1184 mlog_exit(status);
1193 return status; 1185 return status;
1194} 1186}
@@ -1205,10 +1197,12 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb)
1205 return status; 1197 return status;
1206} 1198}
1207 1199
1208static void ocfs2_truncate_log_worker(void *data) 1200static void ocfs2_truncate_log_worker(struct work_struct *work)
1209{ 1201{
1210 int status; 1202 int status;
1211 struct ocfs2_super *osb = data; 1203 struct ocfs2_super *osb =
1204 container_of(work, struct ocfs2_super,
1205 osb_truncate_log_wq.work);
1212 1206
1213 mlog_entry_void(); 1207 mlog_entry_void();
1214 1208
@@ -1347,7 +1341,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1347 int i; 1341 int i;
1348 unsigned int clusters, num_recs, start_cluster; 1342 unsigned int clusters, num_recs, start_cluster;
1349 u64 start_blk; 1343 u64 start_blk;
1350 struct ocfs2_journal_handle *handle; 1344 handle_t *handle;
1351 struct inode *tl_inode = osb->osb_tl_inode; 1345 struct inode *tl_inode = osb->osb_tl_inode;
1352 struct ocfs2_truncate_log *tl; 1346 struct ocfs2_truncate_log *tl;
1353 1347
@@ -1373,8 +1367,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1373 } 1367 }
1374 } 1368 }
1375 1369
1376 handle = ocfs2_start_trans(osb, NULL, 1370 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE);
1377 OCFS2_TRUNCATE_LOG_UPDATE);
1378 if (IS_ERR(handle)) { 1371 if (IS_ERR(handle)) {
1379 status = PTR_ERR(handle); 1372 status = PTR_ERR(handle);
1380 mlog_errno(status); 1373 mlog_errno(status);
@@ -1387,7 +1380,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb,
1387 1380
1388 status = ocfs2_truncate_log_append(osb, handle, 1381 status = ocfs2_truncate_log_append(osb, handle,
1389 start_blk, clusters); 1382 start_blk, clusters);
1390 ocfs2_commit_trans(handle); 1383 ocfs2_commit_trans(osb, handle);
1391 if (status < 0) { 1384 if (status < 0) {
1392 mlog_errno(status); 1385 mlog_errno(status);
1393 goto bail_up; 1386 goto bail_up;
@@ -1441,7 +1434,8 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb)
1441 /* ocfs2_truncate_log_shutdown keys on the existence of 1434 /* ocfs2_truncate_log_shutdown keys on the existence of
1442 * osb->osb_tl_inode so we don't set any of the osb variables 1435 * osb->osb_tl_inode so we don't set any of the osb variables
1443 * until we're sure all is well. */ 1436 * until we're sure all is well. */
1444 INIT_WORK(&osb->osb_truncate_log_wq, ocfs2_truncate_log_worker, osb); 1437 INIT_DELAYED_WORK(&osb->osb_truncate_log_wq,
1438 ocfs2_truncate_log_worker);
1445 osb->osb_tl_bh = tl_bh; 1439 osb->osb_tl_bh = tl_bh;
1446 osb->osb_tl_inode = tl_inode; 1440 osb->osb_tl_inode = tl_inode;
1447 1441
@@ -1543,7 +1537,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
1543 struct inode *inode, 1537 struct inode *inode,
1544 struct buffer_head *fe_bh, 1538 struct buffer_head *fe_bh,
1545 struct buffer_head *old_last_eb_bh, 1539 struct buffer_head *old_last_eb_bh,
1546 struct ocfs2_journal_handle *handle, 1540 handle_t *handle,
1547 struct ocfs2_truncate_context *tc) 1541 struct ocfs2_truncate_context *tc)
1548{ 1542{
1549 int status, i, depth; 1543 int status, i, depth;
@@ -1782,7 +1776,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
1782 struct ocfs2_extent_block *eb; 1776 struct ocfs2_extent_block *eb;
1783 struct ocfs2_extent_list *el; 1777 struct ocfs2_extent_list *el;
1784 struct buffer_head *last_eb_bh; 1778 struct buffer_head *last_eb_bh;
1785 struct ocfs2_journal_handle *handle = NULL; 1779 handle_t *handle = NULL;
1786 struct inode *tl_inode = osb->osb_tl_inode; 1780 struct inode *tl_inode = osb->osb_tl_inode;
1787 1781
1788 mlog_entry_void(); 1782 mlog_entry_void();
@@ -1868,7 +1862,7 @@ start:
1868 1862
1869 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, 1863 credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del,
1870 fe, el); 1864 fe, el);
1871 handle = ocfs2_start_trans(osb, NULL, credits); 1865 handle = ocfs2_start_trans(osb, credits);
1872 if (IS_ERR(handle)) { 1866 if (IS_ERR(handle)) {
1873 status = PTR_ERR(handle); 1867 status = PTR_ERR(handle);
1874 handle = NULL; 1868 handle = NULL;
@@ -1891,7 +1885,7 @@ start:
1891 mutex_unlock(&tl_inode->i_mutex); 1885 mutex_unlock(&tl_inode->i_mutex);
1892 tl_sem = 0; 1886 tl_sem = 0;
1893 1887
1894 ocfs2_commit_trans(handle); 1888 ocfs2_commit_trans(osb, handle);
1895 handle = NULL; 1889 handle = NULL;
1896 1890
1897 BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); 1891 BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters);
@@ -1906,7 +1900,7 @@ bail:
1906 mutex_unlock(&tl_inode->i_mutex); 1900 mutex_unlock(&tl_inode->i_mutex);
1907 1901
1908 if (handle) 1902 if (handle)
1909 ocfs2_commit_trans(handle); 1903 ocfs2_commit_trans(osb, handle);
1910 1904
1911 if (last_eb_bh) 1905 if (last_eb_bh)
1912 brelse(last_eb_bh); 1906 brelse(last_eb_bh);
@@ -2011,10 +2005,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb,
2011 mutex_lock(&ext_alloc_inode->i_mutex); 2005 mutex_lock(&ext_alloc_inode->i_mutex);
2012 (*tc)->tc_ext_alloc_inode = ext_alloc_inode; 2006 (*tc)->tc_ext_alloc_inode = ext_alloc_inode;
2013 2007
2014 status = ocfs2_meta_lock(ext_alloc_inode, 2008 status = ocfs2_meta_lock(ext_alloc_inode, &ext_alloc_bh, 1);
2015 NULL,
2016 &ext_alloc_bh,
2017 1);
2018 if (status < 0) { 2009 if (status < 0) {
2019 mlog_errno(status); 2010 mlog_errno(status);
2020 goto bail; 2011 goto bail;
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h
index 12ba897743f4..0b82e8044325 100644
--- a/fs/ocfs2/alloc.h
+++ b/fs/ocfs2/alloc.h
@@ -28,7 +28,7 @@
28 28
29struct ocfs2_alloc_context; 29struct ocfs2_alloc_context;
30int ocfs2_insert_extent(struct ocfs2_super *osb, 30int ocfs2_insert_extent(struct ocfs2_super *osb,
31 struct ocfs2_journal_handle *handle, 31 handle_t *handle,
32 struct inode *inode, 32 struct inode *inode,
33 struct buffer_head *fe_bh, 33 struct buffer_head *fe_bh,
34 u64 blkno, 34 u64 blkno,
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 3d7c082a8f58..2f7268e81520 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -200,7 +200,7 @@ static int ocfs2_readpage(struct file *file, struct page *page)
200 200
201 mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); 201 mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0));
202 202
203 ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); 203 ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page);
204 if (ret != 0) { 204 if (ret != 0) {
205 if (ret == AOP_TRUNCATED_PAGE) 205 if (ret == AOP_TRUNCATED_PAGE)
206 unlock = 0; 206 unlock = 0;
@@ -305,7 +305,7 @@ static int ocfs2_prepare_write(struct file *file, struct page *page,
305 305
306 mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); 306 mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to);
307 307
308 ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); 308 ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page);
309 if (ret != 0) { 309 if (ret != 0) {
310 mlog_errno(ret); 310 mlog_errno(ret);
311 goto out; 311 goto out;
@@ -355,16 +355,16 @@ static int walk_page_buffers( handle_t *handle,
355 return ret; 355 return ret;
356} 356}
357 357
358struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, 358handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
359 struct page *page, 359 struct page *page,
360 unsigned from, 360 unsigned from,
361 unsigned to) 361 unsigned to)
362{ 362{
363 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 363 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
364 struct ocfs2_journal_handle *handle = NULL; 364 handle_t *handle = NULL;
365 int ret = 0; 365 int ret = 0;
366 366
367 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 367 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
368 if (!handle) { 368 if (!handle) {
369 ret = -ENOMEM; 369 ret = -ENOMEM;
370 mlog_errno(ret); 370 mlog_errno(ret);
@@ -372,7 +372,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode,
372 } 372 }
373 373
374 if (ocfs2_should_order_data(inode)) { 374 if (ocfs2_should_order_data(inode)) {
375 ret = walk_page_buffers(handle->k_handle, 375 ret = walk_page_buffers(handle,
376 page_buffers(page), 376 page_buffers(page),
377 from, to, NULL, 377 from, to, NULL,
378 ocfs2_journal_dirty_data); 378 ocfs2_journal_dirty_data);
@@ -382,7 +382,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode,
382out: 382out:
383 if (ret) { 383 if (ret) {
384 if (handle) 384 if (handle)
385 ocfs2_commit_trans(handle); 385 ocfs2_commit_trans(osb, handle);
386 handle = ERR_PTR(ret); 386 handle = ERR_PTR(ret);
387 } 387 }
388 return handle; 388 return handle;
@@ -394,7 +394,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page,
394 int ret; 394 int ret;
395 struct buffer_head *di_bh = NULL; 395 struct buffer_head *di_bh = NULL;
396 struct inode *inode = page->mapping->host; 396 struct inode *inode = page->mapping->host;
397 struct ocfs2_journal_handle *handle = NULL; 397 handle_t *handle = NULL;
398 struct ocfs2_dinode *di; 398 struct ocfs2_dinode *di;
399 399
400 mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); 400 mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to);
@@ -412,7 +412,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page,
412 * stale inode allocation image (i_size, i_clusters, etc). 412 * stale inode allocation image (i_size, i_clusters, etc).
413 */ 413 */
414 414
415 ret = ocfs2_meta_lock_with_page(inode, NULL, &di_bh, 1, page); 415 ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page);
416 if (ret != 0) { 416 if (ret != 0) {
417 mlog_errno(ret); 417 mlog_errno(ret);
418 goto out; 418 goto out;
@@ -464,7 +464,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page,
464 } 464 }
465 465
466out_commit: 466out_commit:
467 ocfs2_commit_trans(handle); 467 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
468out_unlock_data: 468out_unlock_data:
469 ocfs2_data_unlock(inode, 1); 469 ocfs2_data_unlock(inode, 1);
470out_unlock_meta: 470out_unlock_meta:
@@ -490,7 +490,7 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block)
490 * accessed concurrently from multiple nodes. 490 * accessed concurrently from multiple nodes.
491 */ 491 */
492 if (!INODE_JOURNAL(inode)) { 492 if (!INODE_JOURNAL(inode)) {
493 err = ocfs2_meta_lock(inode, NULL, NULL, 0); 493 err = ocfs2_meta_lock(inode, NULL, 0);
494 if (err) { 494 if (err) {
495 if (err != -ENOENT) 495 if (err != -ENOENT)
496 mlog_errno(err); 496 mlog_errno(err);
diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h
index e88c3f0b8fa9..f446a15eab88 100644
--- a/fs/ocfs2/aops.h
+++ b/fs/ocfs2/aops.h
@@ -25,7 +25,7 @@
25int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page, 25int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page,
26 unsigned from, unsigned to); 26 unsigned from, unsigned to);
27 27
28struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, 28handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
29 struct page *page, 29 struct page *page,
30 unsigned from, 30 unsigned from,
31 unsigned to); 31 unsigned to);
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 305cba3681fe..4cd9a9580456 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -141,7 +141,7 @@ struct o2hb_region {
141 * recognizes a node going up and down in one iteration */ 141 * recognizes a node going up and down in one iteration */
142 u64 hr_generation; 142 u64 hr_generation;
143 143
144 struct work_struct hr_write_timeout_work; 144 struct delayed_work hr_write_timeout_work;
145 unsigned long hr_last_timeout_start; 145 unsigned long hr_last_timeout_start;
146 146
147 /* Used during o2hb_check_slot to hold a copy of the block 147 /* Used during o2hb_check_slot to hold a copy of the block
@@ -156,9 +156,11 @@ struct o2hb_bio_wait_ctxt {
156 int wc_error; 156 int wc_error;
157}; 157};
158 158
159static void o2hb_write_timeout(void *arg) 159static void o2hb_write_timeout(struct work_struct *work)
160{ 160{
161 struct o2hb_region *reg = arg; 161 struct o2hb_region *reg =
162 container_of(work, struct o2hb_region,
163 hr_write_timeout_work.work);
162 164
163 mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u " 165 mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u "
164 "milliseconds\n", reg->hr_dev_name, 166 "milliseconds\n", reg->hr_dev_name,
@@ -1404,7 +1406,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
1404 goto out; 1406 goto out;
1405 } 1407 }
1406 1408
1407 INIT_WORK(&reg->hr_write_timeout_work, o2hb_write_timeout, reg); 1409 INIT_DELAYED_WORK(&reg->hr_write_timeout_work, o2hb_write_timeout);
1408 1410
1409 /* 1411 /*
1410 * A node is considered live after it has beat LIVE_THRESHOLD 1412 * A node is considered live after it has beat LIVE_THRESHOLD
diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c
index 7bba98fbfc15..4705d659fe57 100644
--- a/fs/ocfs2/cluster/quorum.c
+++ b/fs/ocfs2/cluster/quorum.c
@@ -88,7 +88,7 @@ void o2quo_disk_timeout(void)
88 o2quo_fence_self(); 88 o2quo_fence_self();
89} 89}
90 90
91static void o2quo_make_decision(void *arg) 91static void o2quo_make_decision(struct work_struct *work)
92{ 92{
93 int quorum; 93 int quorum;
94 int lowest_hb, lowest_reachable = 0, fence = 0; 94 int lowest_hb, lowest_reachable = 0, fence = 0;
@@ -306,7 +306,7 @@ void o2quo_init(void)
306 struct o2quo_state *qs = &o2quo_state; 306 struct o2quo_state *qs = &o2quo_state;
307 307
308 spin_lock_init(&qs->qs_lock); 308 spin_lock_init(&qs->qs_lock);
309 INIT_WORK(&qs->qs_work, o2quo_make_decision, NULL); 309 INIT_WORK(&qs->qs_work, o2quo_make_decision);
310} 310}
311 311
312void o2quo_exit(void) 312void o2quo_exit(void)
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index b650efa8c8be..9b3209dc0b16 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -140,11 +140,11 @@ static int o2net_sys_err_translations[O2NET_ERR_MAX] =
140 [O2NET_ERR_DIED] = -EHOSTDOWN,}; 140 [O2NET_ERR_DIED] = -EHOSTDOWN,};
141 141
142/* can't quite avoid *all* internal declarations :/ */ 142/* can't quite avoid *all* internal declarations :/ */
143static void o2net_sc_connect_completed(void *arg); 143static void o2net_sc_connect_completed(struct work_struct *work);
144static void o2net_rx_until_empty(void *arg); 144static void o2net_rx_until_empty(struct work_struct *work);
145static void o2net_shutdown_sc(void *arg); 145static void o2net_shutdown_sc(struct work_struct *work);
146static void o2net_listen_data_ready(struct sock *sk, int bytes); 146static void o2net_listen_data_ready(struct sock *sk, int bytes);
147static void o2net_sc_send_keep_req(void *arg); 147static void o2net_sc_send_keep_req(struct work_struct *work);
148static void o2net_idle_timer(unsigned long data); 148static void o2net_idle_timer(unsigned long data);
149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); 149static void o2net_sc_postpone_idle(struct o2net_sock_container *sc);
150 150
@@ -308,10 +308,10 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node)
308 o2nm_node_get(node); 308 o2nm_node_get(node);
309 sc->sc_node = node; 309 sc->sc_node = node;
310 310
311 INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed, sc); 311 INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed);
312 INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty, sc); 312 INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty);
313 INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc, sc); 313 INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc);
314 INIT_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req, sc); 314 INIT_DELAYED_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req);
315 315
316 init_timer(&sc->sc_idle_timeout); 316 init_timer(&sc->sc_idle_timeout);
317 sc->sc_idle_timeout.function = o2net_idle_timer; 317 sc->sc_idle_timeout.function = o2net_idle_timer;
@@ -342,7 +342,7 @@ static void o2net_sc_queue_work(struct o2net_sock_container *sc,
342 sc_put(sc); 342 sc_put(sc);
343} 343}
344static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, 344static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc,
345 struct work_struct *work, 345 struct delayed_work *work,
346 int delay) 346 int delay)
347{ 347{
348 sc_get(sc); 348 sc_get(sc);
@@ -350,7 +350,7 @@ static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc,
350 sc_put(sc); 350 sc_put(sc);
351} 351}
352static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc, 352static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc,
353 struct work_struct *work) 353 struct delayed_work *work)
354{ 354{
355 if (cancel_delayed_work(work)) 355 if (cancel_delayed_work(work))
356 sc_put(sc); 356 sc_put(sc);
@@ -564,9 +564,11 @@ static void o2net_ensure_shutdown(struct o2net_node *nn,
564 * ourselves as state_change couldn't get the nn_lock and call set_nn_state 564 * ourselves as state_change couldn't get the nn_lock and call set_nn_state
565 * itself. 565 * itself.
566 */ 566 */
567static void o2net_shutdown_sc(void *arg) 567static void o2net_shutdown_sc(struct work_struct *work)
568{ 568{
569 struct o2net_sock_container *sc = arg; 569 struct o2net_sock_container *sc =
570 container_of(work, struct o2net_sock_container,
571 sc_shutdown_work);
570 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); 572 struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num);
571 573
572 sclog(sc, "shutting down\n"); 574 sclog(sc, "shutting down\n");
@@ -1201,9 +1203,10 @@ out:
1201/* this work func is triggerd by data ready. it reads until it can read no 1203/* this work func is triggerd by data ready. it reads until it can read no
1202 * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing 1204 * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing
1203 * our work the work struct will be marked and we'll be called again. */ 1205 * our work the work struct will be marked and we'll be called again. */
1204static void o2net_rx_until_empty(void *arg) 1206static void o2net_rx_until_empty(struct work_struct *work)
1205{ 1207{
1206 struct o2net_sock_container *sc = arg; 1208 struct o2net_sock_container *sc =
1209 container_of(work, struct o2net_sock_container, sc_rx_work);
1207 int ret; 1210 int ret;
1208 1211
1209 do { 1212 do {
@@ -1249,9 +1252,11 @@ static int o2net_set_nodelay(struct socket *sock)
1249 1252
1250/* called when a connect completes and after a sock is accepted. the 1253/* called when a connect completes and after a sock is accepted. the
1251 * rx path will see the response and mark the sc valid */ 1254 * rx path will see the response and mark the sc valid */
1252static void o2net_sc_connect_completed(void *arg) 1255static void o2net_sc_connect_completed(struct work_struct *work)
1253{ 1256{
1254 struct o2net_sock_container *sc = arg; 1257 struct o2net_sock_container *sc =
1258 container_of(work, struct o2net_sock_container,
1259 sc_connect_work);
1255 1260
1256 mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", 1261 mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n",
1257 (unsigned long long)O2NET_PROTOCOL_VERSION, 1262 (unsigned long long)O2NET_PROTOCOL_VERSION,
@@ -1262,9 +1267,11 @@ static void o2net_sc_connect_completed(void *arg)
1262} 1267}
1263 1268
1264/* this is called as a work_struct func. */ 1269/* this is called as a work_struct func. */
1265static void o2net_sc_send_keep_req(void *arg) 1270static void o2net_sc_send_keep_req(struct work_struct *work)
1266{ 1271{
1267 struct o2net_sock_container *sc = arg; 1272 struct o2net_sock_container *sc =
1273 container_of(work, struct o2net_sock_container,
1274 sc_keepalive_work.work);
1268 1275
1269 o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); 1276 o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req));
1270 sc_put(sc); 1277 sc_put(sc);
@@ -1314,14 +1321,15 @@ static void o2net_sc_postpone_idle(struct o2net_sock_container *sc)
1314 * having a connect attempt fail, etc. This centralizes the logic which decides 1321 * having a connect attempt fail, etc. This centralizes the logic which decides
1315 * if a connect attempt should be made or if we should give up and all future 1322 * if a connect attempt should be made or if we should give up and all future
1316 * transmit attempts should fail */ 1323 * transmit attempts should fail */
1317static void o2net_start_connect(void *arg) 1324static void o2net_start_connect(struct work_struct *work)
1318{ 1325{
1319 struct o2net_node *nn = arg; 1326 struct o2net_node *nn =
1327 container_of(work, struct o2net_node, nn_connect_work.work);
1320 struct o2net_sock_container *sc = NULL; 1328 struct o2net_sock_container *sc = NULL;
1321 struct o2nm_node *node = NULL, *mynode = NULL; 1329 struct o2nm_node *node = NULL, *mynode = NULL;
1322 struct socket *sock = NULL; 1330 struct socket *sock = NULL;
1323 struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; 1331 struct sockaddr_in myaddr = {0, }, remoteaddr = {0, };
1324 int ret = 0; 1332 int ret = 0, stop;
1325 1333
1326 /* if we're greater we initiate tx, otherwise we accept */ 1334 /* if we're greater we initiate tx, otherwise we accept */
1327 if (o2nm_this_node() <= o2net_num_from_nn(nn)) 1335 if (o2nm_this_node() <= o2net_num_from_nn(nn))
@@ -1342,10 +1350,9 @@ static void o2net_start_connect(void *arg)
1342 1350
1343 spin_lock(&nn->nn_lock); 1351 spin_lock(&nn->nn_lock);
1344 /* see if we already have one pending or have given up */ 1352 /* see if we already have one pending or have given up */
1345 if (nn->nn_sc || nn->nn_persistent_error) 1353 stop = (nn->nn_sc || nn->nn_persistent_error);
1346 arg = NULL;
1347 spin_unlock(&nn->nn_lock); 1354 spin_unlock(&nn->nn_lock);
1348 if (arg == NULL) /* *shrug*, needed some indicator */ 1355 if (stop)
1349 goto out; 1356 goto out;
1350 1357
1351 nn->nn_last_connect_attempt = jiffies; 1358 nn->nn_last_connect_attempt = jiffies;
@@ -1421,9 +1428,10 @@ out:
1421 return; 1428 return;
1422} 1429}
1423 1430
1424static void o2net_connect_expired(void *arg) 1431static void o2net_connect_expired(struct work_struct *work)
1425{ 1432{
1426 struct o2net_node *nn = arg; 1433 struct o2net_node *nn =
1434 container_of(work, struct o2net_node, nn_connect_expired.work);
1427 1435
1428 spin_lock(&nn->nn_lock); 1436 spin_lock(&nn->nn_lock);
1429 if (!nn->nn_sc_valid) { 1437 if (!nn->nn_sc_valid) {
@@ -1436,9 +1444,10 @@ static void o2net_connect_expired(void *arg)
1436 spin_unlock(&nn->nn_lock); 1444 spin_unlock(&nn->nn_lock);
1437} 1445}
1438 1446
1439static void o2net_still_up(void *arg) 1447static void o2net_still_up(struct work_struct *work)
1440{ 1448{
1441 struct o2net_node *nn = arg; 1449 struct o2net_node *nn =
1450 container_of(work, struct o2net_node, nn_still_up.work);
1442 1451
1443 o2quo_hb_still_up(o2net_num_from_nn(nn)); 1452 o2quo_hb_still_up(o2net_num_from_nn(nn));
1444} 1453}
@@ -1644,9 +1653,9 @@ out:
1644 return ret; 1653 return ret;
1645} 1654}
1646 1655
1647static void o2net_accept_many(void *arg) 1656static void o2net_accept_many(struct work_struct *work)
1648{ 1657{
1649 struct socket *sock = arg; 1658 struct socket *sock = o2net_listen_sock;
1650 while (o2net_accept_one(sock) == 0) 1659 while (o2net_accept_one(sock) == 0)
1651 cond_resched(); 1660 cond_resched();
1652} 1661}
@@ -1700,7 +1709,7 @@ static int o2net_open_listening_sock(__be16 port)
1700 write_unlock_bh(&sock->sk->sk_callback_lock); 1709 write_unlock_bh(&sock->sk->sk_callback_lock);
1701 1710
1702 o2net_listen_sock = sock; 1711 o2net_listen_sock = sock;
1703 INIT_WORK(&o2net_listen_work, o2net_accept_many, sock); 1712 INIT_WORK(&o2net_listen_work, o2net_accept_many);
1704 1713
1705 sock->sk->sk_reuse = 1; 1714 sock->sk->sk_reuse = 1;
1706 ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); 1715 ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
@@ -1819,9 +1828,10 @@ int o2net_init(void)
1819 struct o2net_node *nn = o2net_nn_from_num(i); 1828 struct o2net_node *nn = o2net_nn_from_num(i);
1820 1829
1821 spin_lock_init(&nn->nn_lock); 1830 spin_lock_init(&nn->nn_lock);
1822 INIT_WORK(&nn->nn_connect_work, o2net_start_connect, nn); 1831 INIT_DELAYED_WORK(&nn->nn_connect_work, o2net_start_connect);
1823 INIT_WORK(&nn->nn_connect_expired, o2net_connect_expired, nn); 1832 INIT_DELAYED_WORK(&nn->nn_connect_expired,
1824 INIT_WORK(&nn->nn_still_up, o2net_still_up, nn); 1833 o2net_connect_expired);
1834 INIT_DELAYED_WORK(&nn->nn_still_up, o2net_still_up);
1825 /* until we see hb from a node we'll return einval */ 1835 /* until we see hb from a node we'll return einval */
1826 nn->nn_persistent_error = -ENOTCONN; 1836 nn->nn_persistent_error = -ENOTCONN;
1827 init_waitqueue_head(&nn->nn_sc_wq); 1837 init_waitqueue_head(&nn->nn_sc_wq);
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h
index 4b46aac7d243..daebbd3a2c8c 100644
--- a/fs/ocfs2/cluster/tcp_internal.h
+++ b/fs/ocfs2/cluster/tcp_internal.h
@@ -86,18 +86,18 @@ struct o2net_node {
86 * connect attempt fails and so can be self-arming. shutdown is 86 * connect attempt fails and so can be self-arming. shutdown is
87 * careful to first mark the nn such that no connects will be attempted 87 * careful to first mark the nn such that no connects will be attempted
88 * before canceling delayed connect work and flushing the queue. */ 88 * before canceling delayed connect work and flushing the queue. */
89 struct work_struct nn_connect_work; 89 struct delayed_work nn_connect_work;
90 unsigned long nn_last_connect_attempt; 90 unsigned long nn_last_connect_attempt;
91 91
92 /* this is queued as nodes come up and is canceled when a connection is 92 /* this is queued as nodes come up and is canceled when a connection is
93 * established. this expiring gives up on the node and errors out 93 * established. this expiring gives up on the node and errors out
94 * transmits */ 94 * transmits */
95 struct work_struct nn_connect_expired; 95 struct delayed_work nn_connect_expired;
96 96
97 /* after we give up on a socket we wait a while before deciding 97 /* after we give up on a socket we wait a while before deciding
98 * that it is still heartbeating and that we should do some 98 * that it is still heartbeating and that we should do some
99 * quorum work */ 99 * quorum work */
100 struct work_struct nn_still_up; 100 struct delayed_work nn_still_up;
101}; 101};
102 102
103struct o2net_sock_container { 103struct o2net_sock_container {
@@ -129,7 +129,7 @@ struct o2net_sock_container {
129 struct work_struct sc_shutdown_work; 129 struct work_struct sc_shutdown_work;
130 130
131 struct timer_list sc_idle_timeout; 131 struct timer_list sc_idle_timeout;
132 struct work_struct sc_keepalive_work; 132 struct delayed_work sc_keepalive_work;
133 133
134 unsigned sc_handshake_ok:1; 134 unsigned sc_handshake_ok:1;
135 135
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 04e01915b86e..baad2aa27c14 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -82,6 +82,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
82 struct inode *inode = filp->f_dentry->d_inode; 82 struct inode *inode = filp->f_dentry->d_inode;
83 struct super_block * sb = inode->i_sb; 83 struct super_block * sb = inode->i_sb;
84 unsigned int ra_sectors = 16; 84 unsigned int ra_sectors = 16;
85 int lock_level = 0;
85 86
86 mlog_entry("dirino=%llu\n", 87 mlog_entry("dirino=%llu\n",
87 (unsigned long long)OCFS2_I(inode)->ip_blkno); 88 (unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -89,7 +90,15 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir)
89 stored = 0; 90 stored = 0;
90 bh = NULL; 91 bh = NULL;
91 92
92 error = ocfs2_meta_lock(inode, NULL, NULL, 0); 93 error = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
94 if (lock_level && error >= 0) {
95 /* We release EX lock which used to update atime
96 * and get PR lock again to reduce contention
97 * on commonly accessed directories. */
98 ocfs2_meta_unlock(inode, 1);
99 lock_level = 0;
100 error = ocfs2_meta_lock(inode, NULL, 0);
101 }
93 if (error < 0) { 102 if (error < 0) {
94 if (error != -ENOENT) 103 if (error != -ENOENT)
95 mlog_errno(error); 104 mlog_errno(error);
@@ -198,7 +207,7 @@ revalidate:
198 207
199 stored = 0; 208 stored = 0;
200bail: 209bail:
201 ocfs2_meta_unlock(inode, 0); 210 ocfs2_meta_unlock(inode, lock_level);
202 211
203bail_nolock: 212bail_nolock:
204 mlog_exit(stored); 213 mlog_exit(stored);
@@ -340,7 +349,7 @@ int ocfs2_empty_dir(struct inode *inode)
340 349
341/* returns a bh of the 1st new block in the allocation. */ 350/* returns a bh of the 1st new block in the allocation. */
342int ocfs2_do_extend_dir(struct super_block *sb, 351int ocfs2_do_extend_dir(struct super_block *sb,
343 struct ocfs2_journal_handle *handle, 352 handle_t *handle,
344 struct inode *dir, 353 struct inode *dir,
345 struct buffer_head *parent_fe_bh, 354 struct buffer_head *parent_fe_bh,
346 struct ocfs2_alloc_context *data_ac, 355 struct ocfs2_alloc_context *data_ac,
@@ -398,7 +407,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
398 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; 407 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
399 struct ocfs2_alloc_context *data_ac = NULL; 408 struct ocfs2_alloc_context *data_ac = NULL;
400 struct ocfs2_alloc_context *meta_ac = NULL; 409 struct ocfs2_alloc_context *meta_ac = NULL;
401 struct ocfs2_journal_handle *handle = NULL; 410 handle_t *handle = NULL;
402 struct buffer_head *new_bh = NULL; 411 struct buffer_head *new_bh = NULL;
403 struct ocfs2_dir_entry * de; 412 struct ocfs2_dir_entry * de;
404 struct super_block *sb = osb->sb; 413 struct super_block *sb = osb->sb;
@@ -409,13 +418,6 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
409 mlog(0, "extending dir %llu (i_size = %lld)\n", 418 mlog(0, "extending dir %llu (i_size = %lld)\n",
410 (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size); 419 (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size);
411 420
412 handle = ocfs2_alloc_handle(osb);
413 if (handle == NULL) {
414 status = -ENOMEM;
415 mlog_errno(status);
416 goto bail;
417 }
418
419 /* dir->i_size is always block aligned. */ 421 /* dir->i_size is always block aligned. */
420 spin_lock(&OCFS2_I(dir)->ip_lock); 422 spin_lock(&OCFS2_I(dir)->ip_lock);
421 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { 423 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
@@ -428,8 +430,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
428 } 430 }
429 431
430 if (!num_free_extents) { 432 if (!num_free_extents) {
431 status = ocfs2_reserve_new_metadata(osb, handle, 433 status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac);
432 fe, &meta_ac);
433 if (status < 0) { 434 if (status < 0) {
434 if (status != -ENOSPC) 435 if (status != -ENOSPC)
435 mlog_errno(status); 436 mlog_errno(status);
@@ -437,7 +438,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
437 } 438 }
438 } 439 }
439 440
440 status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); 441 status = ocfs2_reserve_clusters(osb, 1, &data_ac);
441 if (status < 0) { 442 if (status < 0) {
442 if (status != -ENOSPC) 443 if (status != -ENOSPC)
443 mlog_errno(status); 444 mlog_errno(status);
@@ -450,7 +451,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
450 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; 451 credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS;
451 } 452 }
452 453
453 handle = ocfs2_start_trans(osb, handle, credits); 454 handle = ocfs2_start_trans(osb, credits);
454 if (IS_ERR(handle)) { 455 if (IS_ERR(handle)) {
455 status = PTR_ERR(handle); 456 status = PTR_ERR(handle);
456 handle = NULL; 457 handle = NULL;
@@ -496,7 +497,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
496 get_bh(*new_de_bh); 497 get_bh(*new_de_bh);
497bail: 498bail:
498 if (handle) 499 if (handle)
499 ocfs2_commit_trans(handle); 500 ocfs2_commit_trans(osb, handle);
500 501
501 if (data_ac) 502 if (data_ac)
502 ocfs2_free_alloc_context(data_ac); 503 ocfs2_free_alloc_context(data_ac);
diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h
index 5f614ec9649c..3f67e146864a 100644
--- a/fs/ocfs2/dir.h
+++ b/fs/ocfs2/dir.h
@@ -45,7 +45,7 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
45 struct buffer_head **ret_de_bh); 45 struct buffer_head **ret_de_bh);
46struct ocfs2_alloc_context; 46struct ocfs2_alloc_context;
47int ocfs2_do_extend_dir(struct super_block *sb, 47int ocfs2_do_extend_dir(struct super_block *sb,
48 struct ocfs2_journal_handle *handle, 48 handle_t *handle,
49 struct inode *dir, 49 struct inode *dir,
50 struct buffer_head *parent_fe_bh, 50 struct buffer_head *parent_fe_bh,
51 struct ocfs2_alloc_context *data_ac, 51 struct ocfs2_alloc_context *data_ac,
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h
index fa968180b072..6b6ff76538c5 100644
--- a/fs/ocfs2/dlm/dlmcommon.h
+++ b/fs/ocfs2/dlm/dlmcommon.h
@@ -153,7 +153,7 @@ static inline struct hlist_head *dlm_lockres_hash(struct dlm_ctxt *dlm, unsigned
153 * called functions that cannot be directly called from the 153 * called functions that cannot be directly called from the
154 * net message handlers for some reason, usually because 154 * net message handlers for some reason, usually because
155 * they need to send net messages of their own. */ 155 * they need to send net messages of their own. */
156void dlm_dispatch_work(void *data); 156void dlm_dispatch_work(struct work_struct *work);
157 157
158struct dlm_lock_resource; 158struct dlm_lock_resource;
159struct dlm_work_item; 159struct dlm_work_item;
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 8d1065f8b3bd..420a375a3949 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -68,7 +68,8 @@ static void **dlm_alloc_pagevec(int pages)
68 goto out_free; 68 goto out_free;
69 69
70 mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n", 70 mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n",
71 pages, DLM_HASH_PAGES, (unsigned long)DLM_BUCKETS_PER_PAGE); 71 pages, (unsigned long)DLM_HASH_PAGES,
72 (unsigned long)DLM_BUCKETS_PER_PAGE);
72 return vec; 73 return vec;
73out_free: 74out_free:
74 dlm_free_pagevec(vec, i); 75 dlm_free_pagevec(vec, i);
@@ -1296,7 +1297,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain,
1296 1297
1297 spin_lock_init(&dlm->work_lock); 1298 spin_lock_init(&dlm->work_lock);
1298 INIT_LIST_HEAD(&dlm->work_list); 1299 INIT_LIST_HEAD(&dlm->work_list);
1299 INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work, dlm); 1300 INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work);
1300 1301
1301 kref_init(&dlm->dlm_refs); 1302 kref_init(&dlm->dlm_refs);
1302 dlm->dlm_state = DLM_CTXT_NEW; 1303 dlm->dlm_state = DLM_CTXT_NEW;
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 9d950d7cea38..fb3e2b0817f1 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -153,9 +153,10 @@ static inline void dlm_reset_recovery(struct dlm_ctxt *dlm)
153} 153}
154 154
155/* Worker function used during recovery. */ 155/* Worker function used during recovery. */
156void dlm_dispatch_work(void *data) 156void dlm_dispatch_work(struct work_struct *work)
157{ 157{
158 struct dlm_ctxt *dlm = (struct dlm_ctxt *)data; 158 struct dlm_ctxt *dlm =
159 container_of(work, struct dlm_ctxt, dispatched_work);
159 LIST_HEAD(tmp_list); 160 LIST_HEAD(tmp_list);
160 struct list_head *iter, *iter2; 161 struct list_head *iter, *iter2;
161 struct dlm_work_item *item; 162 struct dlm_work_item *item;
diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c
index eead48bbfac6..7d2f578b267d 100644
--- a/fs/ocfs2/dlm/userdlm.c
+++ b/fs/ocfs2/dlm/userdlm.c
@@ -171,15 +171,14 @@ static inline void user_dlm_grab_inode_ref(struct user_lock_res *lockres)
171 BUG(); 171 BUG();
172} 172}
173 173
174static void user_dlm_unblock_lock(void *opaque); 174static void user_dlm_unblock_lock(struct work_struct *work);
175 175
176static void __user_dlm_queue_lockres(struct user_lock_res *lockres) 176static void __user_dlm_queue_lockres(struct user_lock_res *lockres)
177{ 177{
178 if (!(lockres->l_flags & USER_LOCK_QUEUED)) { 178 if (!(lockres->l_flags & USER_LOCK_QUEUED)) {
179 user_dlm_grab_inode_ref(lockres); 179 user_dlm_grab_inode_ref(lockres);
180 180
181 INIT_WORK(&lockres->l_work, user_dlm_unblock_lock, 181 INIT_WORK(&lockres->l_work, user_dlm_unblock_lock);
182 lockres);
183 182
184 queue_work(user_dlm_worker, &lockres->l_work); 183 queue_work(user_dlm_worker, &lockres->l_work);
185 lockres->l_flags |= USER_LOCK_QUEUED; 184 lockres->l_flags |= USER_LOCK_QUEUED;
@@ -279,10 +278,11 @@ static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres)
279 iput(inode); 278 iput(inode);
280} 279}
281 280
282static void user_dlm_unblock_lock(void *opaque) 281static void user_dlm_unblock_lock(struct work_struct *work)
283{ 282{
284 int new_level, status; 283 int new_level, status;
285 struct user_lock_res *lockres = (struct user_lock_res *) opaque; 284 struct user_lock_res *lockres =
285 container_of(work, struct user_lock_res, l_work);
286 struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); 286 struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres);
287 287
288 mlog(0, "processing lockres %.*s\n", lockres->l_namelen, 288 mlog(0, "processing lockres %.*s\n", lockres->l_namelen,
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 8801e41afe80..69fba16efbd1 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -49,6 +49,7 @@
49#include "dcache.h" 49#include "dcache.h"
50#include "dlmglue.h" 50#include "dlmglue.h"
51#include "extent_map.h" 51#include "extent_map.h"
52#include "file.h"
52#include "heartbeat.h" 53#include "heartbeat.h"
53#include "inode.h" 54#include "inode.h"
54#include "journal.h" 55#include "journal.h"
@@ -1063,10 +1064,10 @@ static void ocfs2_cluster_unlock(struct ocfs2_super *osb,
1063 mlog_exit_void(); 1064 mlog_exit_void();
1064} 1065}
1065 1066
1066int ocfs2_create_new_lock(struct ocfs2_super *osb, 1067static int ocfs2_create_new_lock(struct ocfs2_super *osb,
1067 struct ocfs2_lock_res *lockres, 1068 struct ocfs2_lock_res *lockres,
1068 int ex, 1069 int ex,
1069 int local) 1070 int local)
1070{ 1071{
1071 int level = ex ? LKM_EXMODE : LKM_PRMODE; 1072 int level = ex ? LKM_EXMODE : LKM_PRMODE;
1072 unsigned long flags; 1073 unsigned long flags;
@@ -1579,7 +1580,6 @@ static int ocfs2_assign_bh(struct inode *inode,
1579 * the result of the lock will be communicated via the callback. 1580 * the result of the lock will be communicated via the callback.
1580 */ 1581 */
1581int ocfs2_meta_lock_full(struct inode *inode, 1582int ocfs2_meta_lock_full(struct inode *inode,
1582 struct ocfs2_journal_handle *handle,
1583 struct buffer_head **ret_bh, 1583 struct buffer_head **ret_bh,
1584 int ex, 1584 int ex,
1585 int arg_flags) 1585 int arg_flags)
@@ -1668,12 +1668,6 @@ int ocfs2_meta_lock_full(struct inode *inode,
1668 } 1668 }
1669 } 1669 }
1670 1670
1671 if (handle) {
1672 status = ocfs2_handle_add_lock(handle, inode);
1673 if (status < 0)
1674 mlog_errno(status);
1675 }
1676
1677bail: 1671bail:
1678 if (status < 0) { 1672 if (status < 0) {
1679 if (ret_bh && (*ret_bh)) { 1673 if (ret_bh && (*ret_bh)) {
@@ -1713,18 +1707,16 @@ bail:
1713 * the lock inversion simply. 1707 * the lock inversion simply.
1714 */ 1708 */
1715int ocfs2_meta_lock_with_page(struct inode *inode, 1709int ocfs2_meta_lock_with_page(struct inode *inode,
1716 struct ocfs2_journal_handle *handle,
1717 struct buffer_head **ret_bh, 1710 struct buffer_head **ret_bh,
1718 int ex, 1711 int ex,
1719 struct page *page) 1712 struct page *page)
1720{ 1713{
1721 int ret; 1714 int ret;
1722 1715
1723 ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, 1716 ret = ocfs2_meta_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK);
1724 OCFS2_LOCK_NONBLOCK);
1725 if (ret == -EAGAIN) { 1717 if (ret == -EAGAIN) {
1726 unlock_page(page); 1718 unlock_page(page);
1727 if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) 1719 if (ocfs2_meta_lock(inode, ret_bh, ex) == 0)
1728 ocfs2_meta_unlock(inode, ex); 1720 ocfs2_meta_unlock(inode, ex);
1729 ret = AOP_TRUNCATED_PAGE; 1721 ret = AOP_TRUNCATED_PAGE;
1730 } 1722 }
@@ -1732,6 +1724,44 @@ int ocfs2_meta_lock_with_page(struct inode *inode,
1732 return ret; 1724 return ret;
1733} 1725}
1734 1726
1727int ocfs2_meta_lock_atime(struct inode *inode,
1728 struct vfsmount *vfsmnt,
1729 int *level)
1730{
1731 int ret;
1732
1733 mlog_entry_void();
1734 ret = ocfs2_meta_lock(inode, NULL, 0);
1735 if (ret < 0) {
1736 mlog_errno(ret);
1737 return ret;
1738 }
1739
1740 /*
1741 * If we should update atime, we will get EX lock,
1742 * otherwise we just get PR lock.
1743 */
1744 if (ocfs2_should_update_atime(inode, vfsmnt)) {
1745 struct buffer_head *bh = NULL;
1746
1747 ocfs2_meta_unlock(inode, 0);
1748 ret = ocfs2_meta_lock(inode, &bh, 1);
1749 if (ret < 0) {
1750 mlog_errno(ret);
1751 return ret;
1752 }
1753 *level = 1;
1754 if (ocfs2_should_update_atime(inode, vfsmnt))
1755 ocfs2_update_inode_atime(inode, bh);
1756 if (bh)
1757 brelse(bh);
1758 } else
1759 *level = 0;
1760
1761 mlog_exit(ret);
1762 return ret;
1763}
1764
1735void ocfs2_meta_unlock(struct inode *inode, 1765void ocfs2_meta_unlock(struct inode *inode,
1736 int ex) 1766 int ex)
1737{ 1767{
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h
index 4a2769387229..c343fca68cf1 100644
--- a/fs/ocfs2/dlmglue.h
+++ b/fs/ocfs2/dlmglue.h
@@ -68,8 +68,6 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl,
68 u64 parent, struct inode *inode); 68 u64 parent, struct inode *inode);
69void ocfs2_lock_res_free(struct ocfs2_lock_res *res); 69void ocfs2_lock_res_free(struct ocfs2_lock_res *res);
70int ocfs2_create_new_inode_locks(struct inode *inode); 70int ocfs2_create_new_inode_locks(struct inode *inode);
71int ocfs2_create_new_lock(struct ocfs2_super *osb,
72 struct ocfs2_lock_res *lockres, int ex, int local);
73int ocfs2_drop_inode_locks(struct inode *inode); 71int ocfs2_drop_inode_locks(struct inode *inode);
74int ocfs2_data_lock_full(struct inode *inode, 72int ocfs2_data_lock_full(struct inode *inode,
75 int write, 73 int write,
@@ -82,19 +80,20 @@ void ocfs2_data_unlock(struct inode *inode,
82 int write); 80 int write);
83int ocfs2_rw_lock(struct inode *inode, int write); 81int ocfs2_rw_lock(struct inode *inode, int write);
84void ocfs2_rw_unlock(struct inode *inode, int write); 82void ocfs2_rw_unlock(struct inode *inode, int write);
83int ocfs2_meta_lock_atime(struct inode *inode,
84 struct vfsmount *vfsmnt,
85 int *level);
85int ocfs2_meta_lock_full(struct inode *inode, 86int ocfs2_meta_lock_full(struct inode *inode,
86 struct ocfs2_journal_handle *handle,
87 struct buffer_head **ret_bh, 87 struct buffer_head **ret_bh,
88 int ex, 88 int ex,
89 int arg_flags); 89 int arg_flags);
90int ocfs2_meta_lock_with_page(struct inode *inode, 90int ocfs2_meta_lock_with_page(struct inode *inode,
91 struct ocfs2_journal_handle *handle,
92 struct buffer_head **ret_bh, 91 struct buffer_head **ret_bh,
93 int ex, 92 int ex,
94 struct page *page); 93 struct page *page);
95/* 99% of the time we don't want to supply any additional flags -- 94/* 99% of the time we don't want to supply any additional flags --
96 * those are for very specific cases only. */ 95 * those are for very specific cases only. */
97#define ocfs2_meta_lock(i, h, b, e) ocfs2_meta_lock_full(i, h, b, e, 0) 96#define ocfs2_meta_lock(i, b, e) ocfs2_meta_lock_full(i, b, e, 0)
98void ocfs2_meta_unlock(struct inode *inode, 97void ocfs2_meta_unlock(struct inode *inode,
99 int ex); 98 int ex);
100int ocfs2_super_lock(struct ocfs2_super *osb, 99int ocfs2_super_lock(struct ocfs2_super *osb,
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index fb91089a60a7..06be6e774cf9 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -100,7 +100,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child)
100 mlog(0, "find parent of directory %llu\n", 100 mlog(0, "find parent of directory %llu\n",
101 (unsigned long long)OCFS2_I(dir)->ip_blkno); 101 (unsigned long long)OCFS2_I(dir)->ip_blkno);
102 102
103 status = ocfs2_meta_lock(dir, NULL, NULL, 0); 103 status = ocfs2_meta_lock(dir, NULL, 0);
104 if (status < 0) { 104 if (status < 0) {
105 if (status != -ENOENT) 105 if (status != -ENOENT)
106 mlog_errno(status); 106 mlog_errno(status);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 1be74c4e7814..8786b3c490aa 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -31,6 +31,8 @@
31#include <linux/pagemap.h> 31#include <linux/pagemap.h>
32#include <linux/uio.h> 32#include <linux/uio.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/pipe_fs_i.h>
35#include <linux/mount.h>
34 36
35#define MLOG_MASK_PREFIX ML_INODE 37#define MLOG_MASK_PREFIX ML_INODE
36#include <cluster/masklog.h> 38#include <cluster/masklog.h>
@@ -134,7 +136,58 @@ bail:
134 return (err < 0) ? -EIO : 0; 136 return (err < 0) ? -EIO : 0;
135} 137}
136 138
137int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, 139int ocfs2_should_update_atime(struct inode *inode,
140 struct vfsmount *vfsmnt)
141{
142 struct timespec now;
143 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
144
145 if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
146 return 0;
147
148 if ((inode->i_flags & S_NOATIME) ||
149 ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode)))
150 return 0;
151
152 if ((vfsmnt->mnt_flags & MNT_NOATIME) ||
153 ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode)))
154 return 0;
155
156 now = CURRENT_TIME;
157 if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum))
158 return 0;
159 else
160 return 1;
161}
162
163int ocfs2_update_inode_atime(struct inode *inode,
164 struct buffer_head *bh)
165{
166 int ret;
167 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
168 handle_t *handle;
169
170 mlog_entry_void();
171
172 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
173 if (handle == NULL) {
174 ret = -ENOMEM;
175 mlog_errno(ret);
176 goto out;
177 }
178
179 inode->i_atime = CURRENT_TIME;
180 ret = ocfs2_mark_inode_dirty(handle, inode, bh);
181 if (ret < 0)
182 mlog_errno(ret);
183
184 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
185out:
186 mlog_exit(ret);
187 return ret;
188}
189
190int ocfs2_set_inode_size(handle_t *handle,
138 struct inode *inode, 191 struct inode *inode,
139 struct buffer_head *fe_bh, 192 struct buffer_head *fe_bh,
140 u64 new_i_size) 193 u64 new_i_size)
@@ -163,10 +216,9 @@ static int ocfs2_simple_size_update(struct inode *inode,
163{ 216{
164 int ret; 217 int ret;
165 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 218 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
166 struct ocfs2_journal_handle *handle = NULL; 219 handle_t *handle = NULL;
167 220
168 handle = ocfs2_start_trans(osb, NULL, 221 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
169 OCFS2_INODE_UPDATE_CREDITS);
170 if (handle == NULL) { 222 if (handle == NULL) {
171 ret = -ENOMEM; 223 ret = -ENOMEM;
172 mlog_errno(ret); 224 mlog_errno(ret);
@@ -178,7 +230,7 @@ static int ocfs2_simple_size_update(struct inode *inode,
178 if (ret < 0) 230 if (ret < 0)
179 mlog_errno(ret); 231 mlog_errno(ret);
180 232
181 ocfs2_commit_trans(handle); 233 ocfs2_commit_trans(osb, handle);
182out: 234out:
183 return ret; 235 return ret;
184} 236}
@@ -189,14 +241,14 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
189 u64 new_i_size) 241 u64 new_i_size)
190{ 242{
191 int status; 243 int status;
192 struct ocfs2_journal_handle *handle; 244 handle_t *handle;
193 245
194 mlog_entry_void(); 246 mlog_entry_void();
195 247
196 /* TODO: This needs to actually orphan the inode in this 248 /* TODO: This needs to actually orphan the inode in this
197 * transaction. */ 249 * transaction. */
198 250
199 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 251 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
200 if (IS_ERR(handle)) { 252 if (IS_ERR(handle)) {
201 status = PTR_ERR(handle); 253 status = PTR_ERR(handle);
202 mlog_errno(status); 254 mlog_errno(status);
@@ -207,7 +259,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb,
207 if (status < 0) 259 if (status < 0)
208 mlog_errno(status); 260 mlog_errno(status);
209 261
210 ocfs2_commit_trans(handle); 262 ocfs2_commit_trans(osb, handle);
211out: 263out:
212 mlog_exit(status); 264 mlog_exit(status);
213 return status; 265 return status;
@@ -328,7 +380,7 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
328 struct inode *inode, 380 struct inode *inode,
329 u32 clusters_to_add, 381 u32 clusters_to_add,
330 struct buffer_head *fe_bh, 382 struct buffer_head *fe_bh,
331 struct ocfs2_journal_handle *handle, 383 handle_t *handle,
332 struct ocfs2_alloc_context *data_ac, 384 struct ocfs2_alloc_context *data_ac,
333 struct ocfs2_alloc_context *meta_ac, 385 struct ocfs2_alloc_context *meta_ac,
334 enum ocfs2_alloc_restarted *reason_ret) 386 enum ocfs2_alloc_restarted *reason_ret)
@@ -433,7 +485,7 @@ static int ocfs2_extend_allocation(struct inode *inode,
433 u32 prev_clusters; 485 u32 prev_clusters;
434 struct buffer_head *bh = NULL; 486 struct buffer_head *bh = NULL;
435 struct ocfs2_dinode *fe = NULL; 487 struct ocfs2_dinode *fe = NULL;
436 struct ocfs2_journal_handle *handle = NULL; 488 handle_t *handle = NULL;
437 struct ocfs2_alloc_context *data_ac = NULL; 489 struct ocfs2_alloc_context *data_ac = NULL;
438 struct ocfs2_alloc_context *meta_ac = NULL; 490 struct ocfs2_alloc_context *meta_ac = NULL;
439 enum ocfs2_alloc_restarted why; 491 enum ocfs2_alloc_restarted why;
@@ -463,13 +515,6 @@ restart_all:
463 (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode), 515 (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode),
464 fe->i_clusters, clusters_to_add); 516 fe->i_clusters, clusters_to_add);
465 517
466 handle = ocfs2_alloc_handle(osb);
467 if (handle == NULL) {
468 status = -ENOMEM;
469 mlog_errno(status);
470 goto leave;
471 }
472
473 num_free_extents = ocfs2_num_free_extents(osb, 518 num_free_extents = ocfs2_num_free_extents(osb,
474 inode, 519 inode,
475 fe); 520 fe);
@@ -480,10 +525,7 @@ restart_all:
480 } 525 }
481 526
482 if (!num_free_extents) { 527 if (!num_free_extents) {
483 status = ocfs2_reserve_new_metadata(osb, 528 status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac);
484 handle,
485 fe,
486 &meta_ac);
487 if (status < 0) { 529 if (status < 0) {
488 if (status != -ENOSPC) 530 if (status != -ENOSPC)
489 mlog_errno(status); 531 mlog_errno(status);
@@ -491,10 +533,7 @@ restart_all:
491 } 533 }
492 } 534 }
493 535
494 status = ocfs2_reserve_clusters(osb, 536 status = ocfs2_reserve_clusters(osb, clusters_to_add, &data_ac);
495 handle,
496 clusters_to_add,
497 &data_ac);
498 if (status < 0) { 537 if (status < 0) {
499 if (status != -ENOSPC) 538 if (status != -ENOSPC)
500 mlog_errno(status); 539 mlog_errno(status);
@@ -509,7 +548,7 @@ restart_all:
509 drop_alloc_sem = 1; 548 drop_alloc_sem = 1;
510 549
511 credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); 550 credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add);
512 handle = ocfs2_start_trans(osb, handle, credits); 551 handle = ocfs2_start_trans(osb, credits);
513 if (IS_ERR(handle)) { 552 if (IS_ERR(handle)) {
514 status = PTR_ERR(handle); 553 status = PTR_ERR(handle);
515 handle = NULL; 554 handle = NULL;
@@ -589,7 +628,7 @@ leave:
589 drop_alloc_sem = 0; 628 drop_alloc_sem = 0;
590 } 629 }
591 if (handle) { 630 if (handle) {
592 ocfs2_commit_trans(handle); 631 ocfs2_commit_trans(osb, handle);
593 handle = NULL; 632 handle = NULL;
594 } 633 }
595 if (data_ac) { 634 if (data_ac) {
@@ -624,7 +663,7 @@ static int ocfs2_write_zero_page(struct inode *inode,
624 struct page *page; 663 struct page *page;
625 unsigned long index; 664 unsigned long index;
626 unsigned int offset; 665 unsigned int offset;
627 struct ocfs2_journal_handle *handle = NULL; 666 handle_t *handle = NULL;
628 int ret; 667 int ret;
629 668
630 offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ 669 offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */
@@ -668,7 +707,7 @@ static int ocfs2_write_zero_page(struct inode *inode,
668 ret = 0; 707 ret = 0;
669 708
670 if (handle) 709 if (handle)
671 ocfs2_commit_trans(handle); 710 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
672out_unlock: 711out_unlock:
673 unlock_page(page); 712 unlock_page(page);
674 page_cache_release(page); 713 page_cache_release(page);
@@ -789,7 +828,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
789 struct super_block *sb = inode->i_sb; 828 struct super_block *sb = inode->i_sb;
790 struct ocfs2_super *osb = OCFS2_SB(sb); 829 struct ocfs2_super *osb = OCFS2_SB(sb);
791 struct buffer_head *bh = NULL; 830 struct buffer_head *bh = NULL;
792 struct ocfs2_journal_handle *handle = NULL; 831 handle_t *handle = NULL;
793 832
794 mlog_entry("(0x%p, '%.*s')\n", dentry, 833 mlog_entry("(0x%p, '%.*s')\n", dentry,
795 dentry->d_name.len, dentry->d_name.name); 834 dentry->d_name.len, dentry->d_name.name);
@@ -825,7 +864,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
825 } 864 }
826 } 865 }
827 866
828 status = ocfs2_meta_lock(inode, NULL, &bh, 1); 867 status = ocfs2_meta_lock(inode, &bh, 1);
829 if (status < 0) { 868 if (status < 0) {
830 if (status != -ENOENT) 869 if (status != -ENOENT)
831 mlog_errno(status); 870 mlog_errno(status);
@@ -845,7 +884,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
845 } 884 }
846 } 885 }
847 886
848 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 887 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
849 if (IS_ERR(handle)) { 888 if (IS_ERR(handle)) {
850 status = PTR_ERR(handle); 889 status = PTR_ERR(handle);
851 mlog_errno(status); 890 mlog_errno(status);
@@ -863,7 +902,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
863 mlog_errno(status); 902 mlog_errno(status);
864 903
865bail_commit: 904bail_commit:
866 ocfs2_commit_trans(handle); 905 ocfs2_commit_trans(osb, handle);
867bail_unlock: 906bail_unlock:
868 ocfs2_meta_unlock(inode, 1); 907 ocfs2_meta_unlock(inode, 1);
869bail_unlock_rw: 908bail_unlock_rw:
@@ -906,19 +945,41 @@ bail:
906 return err; 945 return err;
907} 946}
908 947
948int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
949{
950 int ret;
951
952 mlog_entry_void();
953
954 ret = ocfs2_meta_lock(inode, NULL, 0);
955 if (ret) {
956 mlog_errno(ret);
957 goto out;
958 }
959
960 ret = generic_permission(inode, mask, NULL);
961 if (ret)
962 mlog_errno(ret);
963
964 ocfs2_meta_unlock(inode, 0);
965out:
966 mlog_exit(ret);
967 return ret;
968}
969
909static int ocfs2_write_remove_suid(struct inode *inode) 970static int ocfs2_write_remove_suid(struct inode *inode)
910{ 971{
911 int ret; 972 int ret;
912 struct buffer_head *bh = NULL; 973 struct buffer_head *bh = NULL;
913 struct ocfs2_inode_info *oi = OCFS2_I(inode); 974 struct ocfs2_inode_info *oi = OCFS2_I(inode);
914 struct ocfs2_journal_handle *handle; 975 handle_t *handle;
915 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 976 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
916 struct ocfs2_dinode *di; 977 struct ocfs2_dinode *di;
917 978
918 mlog_entry("(Inode %llu, mode 0%o)\n", 979 mlog_entry("(Inode %llu, mode 0%o)\n",
919 (unsigned long long)oi->ip_blkno, inode->i_mode); 980 (unsigned long long)oi->ip_blkno, inode->i_mode);
920 981
921 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 982 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
922 if (handle == NULL) { 983 if (handle == NULL) {
923 ret = -ENOMEM; 984 ret = -ENOMEM;
924 mlog_errno(ret); 985 mlog_errno(ret);
@@ -951,75 +1012,29 @@ static int ocfs2_write_remove_suid(struct inode *inode)
951out_bh: 1012out_bh:
952 brelse(bh); 1013 brelse(bh);
953out_trans: 1014out_trans:
954 ocfs2_commit_trans(handle); 1015 ocfs2_commit_trans(osb, handle);
955out: 1016out:
956 mlog_exit(ret); 1017 mlog_exit(ret);
957 return ret; 1018 return ret;
958} 1019}
959 1020
960static inline int ocfs2_write_should_remove_suid(struct inode *inode) 1021static int ocfs2_prepare_inode_for_write(struct dentry *dentry,
961{ 1022 loff_t *ppos,
962 mode_t mode = inode->i_mode; 1023 size_t count,
963 1024 int appending)
964 if (!capable(CAP_FSETID)) {
965 if (unlikely(mode & S_ISUID))
966 return 1;
967
968 if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
969 return 1;
970 }
971 return 0;
972}
973
974static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
975 const struct iovec *iov,
976 unsigned long nr_segs,
977 loff_t pos)
978{ 1025{
979 int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; 1026 int ret = 0, meta_level = appending;
1027 struct inode *inode = dentry->d_inode;
980 u32 clusters; 1028 u32 clusters;
981 struct file *filp = iocb->ki_filp;
982 struct inode *inode = filp->f_dentry->d_inode;
983 loff_t newsize, saved_pos; 1029 loff_t newsize, saved_pos;
984 1030
985 mlog_entry("(0x%p, %u, '%.*s')\n", filp,
986 (unsigned int)nr_segs,
987 filp->f_dentry->d_name.len,
988 filp->f_dentry->d_name.name);
989
990 /* happy write of zero bytes */
991 if (iocb->ki_left == 0)
992 return 0;
993
994 if (!inode) {
995 mlog(0, "bad inode\n");
996 return -EIO;
997 }
998
999 mutex_lock(&inode->i_mutex);
1000 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */
1001 if (filp->f_flags & O_DIRECT) {
1002 have_alloc_sem = 1;
1003 down_read(&inode->i_alloc_sem);
1004 }
1005
1006 /* concurrent O_DIRECT writes are allowed */
1007 rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1;
1008 ret = ocfs2_rw_lock(inode, rw_level);
1009 if (ret < 0) {
1010 rw_level = -1;
1011 mlog_errno(ret);
1012 goto out;
1013 }
1014
1015 /* 1031 /*
1016 * We sample i_size under a read level meta lock to see if our write 1032 * We sample i_size under a read level meta lock to see if our write
1017 * is extending the file, if it is we back off and get a write level 1033 * is extending the file, if it is we back off and get a write level
1018 * meta lock. 1034 * meta lock.
1019 */ 1035 */
1020 meta_level = (filp->f_flags & O_APPEND) ? 1 : 0;
1021 for(;;) { 1036 for(;;) {
1022 ret = ocfs2_meta_lock(inode, NULL, NULL, meta_level); 1037 ret = ocfs2_meta_lock(inode, NULL, meta_level);
1023 if (ret < 0) { 1038 if (ret < 0) {
1024 meta_level = -1; 1039 meta_level = -1;
1025 mlog_errno(ret); 1040 mlog_errno(ret);
@@ -1035,7 +1050,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1035 * inode. There's also the dinode i_size state which 1050 * inode. There's also the dinode i_size state which
1036 * can be lost via setattr during extending writes (we 1051 * can be lost via setattr during extending writes (we
1037 * set inode->i_size at the end of a write. */ 1052 * set inode->i_size at the end of a write. */
1038 if (ocfs2_write_should_remove_suid(inode)) { 1053 if (should_remove_suid(dentry)) {
1039 if (meta_level == 0) { 1054 if (meta_level == 0) {
1040 ocfs2_meta_unlock(inode, meta_level); 1055 ocfs2_meta_unlock(inode, meta_level);
1041 meta_level = 1; 1056 meta_level = 1;
@@ -1045,19 +1060,19 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1045 ret = ocfs2_write_remove_suid(inode); 1060 ret = ocfs2_write_remove_suid(inode);
1046 if (ret < 0) { 1061 if (ret < 0) {
1047 mlog_errno(ret); 1062 mlog_errno(ret);
1048 goto out; 1063 goto out_unlock;
1049 } 1064 }
1050 } 1065 }
1051 1066
1052 /* work on a copy of ppos until we're sure that we won't have 1067 /* work on a copy of ppos until we're sure that we won't have
1053 * to recalculate it due to relocking. */ 1068 * to recalculate it due to relocking. */
1054 if (filp->f_flags & O_APPEND) { 1069 if (appending) {
1055 saved_pos = i_size_read(inode); 1070 saved_pos = i_size_read(inode);
1056 mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); 1071 mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos);
1057 } else { 1072 } else {
1058 saved_pos = iocb->ki_pos; 1073 saved_pos = *ppos;
1059 } 1074 }
1060 newsize = iocb->ki_left + saved_pos; 1075 newsize = count + saved_pos;
1061 1076
1062 mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", 1077 mlog(0, "pos=%lld newsize=%lld cursize=%lld\n",
1063 (long long) saved_pos, (long long) newsize, 1078 (long long) saved_pos, (long long) newsize,
@@ -1090,19 +1105,66 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1090 if (!clusters) 1105 if (!clusters)
1091 break; 1106 break;
1092 1107
1093 ret = ocfs2_extend_file(inode, NULL, newsize, iocb->ki_left); 1108 ret = ocfs2_extend_file(inode, NULL, newsize, count);
1094 if (ret < 0) { 1109 if (ret < 0) {
1095 if (ret != -ENOSPC) 1110 if (ret != -ENOSPC)
1096 mlog_errno(ret); 1111 mlog_errno(ret);
1097 goto out; 1112 goto out_unlock;
1098 } 1113 }
1099 break; 1114 break;
1100 } 1115 }
1101 1116
1102 /* ok, we're done with i_size and alloc work */ 1117 if (appending)
1103 iocb->ki_pos = saved_pos; 1118 *ppos = saved_pos;
1119
1120out_unlock:
1104 ocfs2_meta_unlock(inode, meta_level); 1121 ocfs2_meta_unlock(inode, meta_level);
1105 meta_level = -1; 1122
1123out:
1124 return ret;
1125}
1126
1127static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1128 const struct iovec *iov,
1129 unsigned long nr_segs,
1130 loff_t pos)
1131{
1132 int ret, rw_level, have_alloc_sem = 0;
1133 struct file *filp = iocb->ki_filp;
1134 struct inode *inode = filp->f_dentry->d_inode;
1135 int appending = filp->f_flags & O_APPEND ? 1 : 0;
1136
1137 mlog_entry("(0x%p, %u, '%.*s')\n", filp,
1138 (unsigned int)nr_segs,
1139 filp->f_dentry->d_name.len,
1140 filp->f_dentry->d_name.name);
1141
1142 /* happy write of zero bytes */
1143 if (iocb->ki_left == 0)
1144 return 0;
1145
1146 mutex_lock(&inode->i_mutex);
1147 /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */
1148 if (filp->f_flags & O_DIRECT) {
1149 have_alloc_sem = 1;
1150 down_read(&inode->i_alloc_sem);
1151 }
1152
1153 /* concurrent O_DIRECT writes are allowed */
1154 rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1;
1155 ret = ocfs2_rw_lock(inode, rw_level);
1156 if (ret < 0) {
1157 rw_level = -1;
1158 mlog_errno(ret);
1159 goto out;
1160 }
1161
1162 ret = ocfs2_prepare_inode_for_write(filp->f_dentry, &iocb->ki_pos,
1163 iocb->ki_left, appending);
1164 if (ret < 0) {
1165 mlog_errno(ret);
1166 goto out;
1167 }
1106 1168
1107 /* communicate with ocfs2_dio_end_io */ 1169 /* communicate with ocfs2_dio_end_io */
1108 ocfs2_iocb_set_rw_locked(iocb); 1170 ocfs2_iocb_set_rw_locked(iocb);
@@ -1128,8 +1190,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb,
1128 } 1190 }
1129 1191
1130out: 1192out:
1131 if (meta_level != -1)
1132 ocfs2_meta_unlock(inode, meta_level);
1133 if (have_alloc_sem) 1193 if (have_alloc_sem)
1134 up_read(&inode->i_alloc_sem); 1194 up_read(&inode->i_alloc_sem);
1135 if (rw_level != -1) 1195 if (rw_level != -1)
@@ -1140,12 +1200,83 @@ out:
1140 return ret; 1200 return ret;
1141} 1201}
1142 1202
1203static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
1204 struct file *out,
1205 loff_t *ppos,
1206 size_t len,
1207 unsigned int flags)
1208{
1209 int ret;
1210 struct inode *inode = out->f_dentry->d_inode;
1211
1212 mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe,
1213 (unsigned int)len,
1214 out->f_dentry->d_name.len,
1215 out->f_dentry->d_name.name);
1216
1217 inode_double_lock(inode, pipe->inode);
1218
1219 ret = ocfs2_rw_lock(inode, 1);
1220 if (ret < 0) {
1221 mlog_errno(ret);
1222 goto out;
1223 }
1224
1225 ret = ocfs2_prepare_inode_for_write(out->f_dentry, ppos, len, 0);
1226 if (ret < 0) {
1227 mlog_errno(ret);
1228 goto out_unlock;
1229 }
1230
1231 /* ok, we're done with i_size and alloc work */
1232 ret = generic_file_splice_write_nolock(pipe, out, ppos, len, flags);
1233
1234out_unlock:
1235 ocfs2_rw_unlock(inode, 1);
1236out:
1237 inode_double_unlock(inode, pipe->inode);
1238
1239 mlog_exit(ret);
1240 return ret;
1241}
1242
1243static ssize_t ocfs2_file_splice_read(struct file *in,
1244 loff_t *ppos,
1245 struct pipe_inode_info *pipe,
1246 size_t len,
1247 unsigned int flags)
1248{
1249 int ret = 0;
1250 struct inode *inode = in->f_dentry->d_inode;
1251
1252 mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe,
1253 (unsigned int)len,
1254 in->f_dentry->d_name.len,
1255 in->f_dentry->d_name.name);
1256
1257 /*
1258 * See the comment in ocfs2_file_aio_read()
1259 */
1260 ret = ocfs2_meta_lock(inode, NULL, 0);
1261 if (ret < 0) {
1262 mlog_errno(ret);
1263 goto bail;
1264 }
1265 ocfs2_meta_unlock(inode, 0);
1266
1267 ret = generic_file_splice_read(in, ppos, pipe, len, flags);
1268
1269bail:
1270 mlog_exit(ret);
1271 return ret;
1272}
1273
1143static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, 1274static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
1144 const struct iovec *iov, 1275 const struct iovec *iov,
1145 unsigned long nr_segs, 1276 unsigned long nr_segs,
1146 loff_t pos) 1277 loff_t pos)
1147{ 1278{
1148 int ret = 0, rw_level = -1, have_alloc_sem = 0; 1279 int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0;
1149 struct file *filp = iocb->ki_filp; 1280 struct file *filp = iocb->ki_filp;
1150 struct inode *inode = filp->f_dentry->d_inode; 1281 struct inode *inode = filp->f_dentry->d_inode;
1151 1282
@@ -1187,12 +1318,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
1187 * like i_size. This allows the checks down below 1318 * like i_size. This allows the checks down below
1188 * generic_file_aio_read() a chance of actually working. 1319 * generic_file_aio_read() a chance of actually working.
1189 */ 1320 */
1190 ret = ocfs2_meta_lock(inode, NULL, NULL, 0); 1321 ret = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level);
1191 if (ret < 0) { 1322 if (ret < 0) {
1192 mlog_errno(ret); 1323 mlog_errno(ret);
1193 goto bail; 1324 goto bail;
1194 } 1325 }
1195 ocfs2_meta_unlock(inode, 0); 1326 ocfs2_meta_unlock(inode, lock_level);
1196 1327
1197 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); 1328 ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos);
1198 if (ret == -EINVAL) 1329 if (ret == -EINVAL)
@@ -1220,11 +1351,13 @@ bail:
1220struct inode_operations ocfs2_file_iops = { 1351struct inode_operations ocfs2_file_iops = {
1221 .setattr = ocfs2_setattr, 1352 .setattr = ocfs2_setattr,
1222 .getattr = ocfs2_getattr, 1353 .getattr = ocfs2_getattr,
1354 .permission = ocfs2_permission,
1223}; 1355};
1224 1356
1225struct inode_operations ocfs2_special_file_iops = { 1357struct inode_operations ocfs2_special_file_iops = {
1226 .setattr = ocfs2_setattr, 1358 .setattr = ocfs2_setattr,
1227 .getattr = ocfs2_getattr, 1359 .getattr = ocfs2_getattr,
1360 .permission = ocfs2_permission,
1228}; 1361};
1229 1362
1230const struct file_operations ocfs2_fops = { 1363const struct file_operations ocfs2_fops = {
@@ -1238,6 +1371,8 @@ const struct file_operations ocfs2_fops = {
1238 .aio_read = ocfs2_file_aio_read, 1371 .aio_read = ocfs2_file_aio_read,
1239 .aio_write = ocfs2_file_aio_write, 1372 .aio_write = ocfs2_file_aio_write,
1240 .ioctl = ocfs2_ioctl, 1373 .ioctl = ocfs2_ioctl,
1374 .splice_read = ocfs2_file_splice_read,
1375 .splice_write = ocfs2_file_splice_write,
1241}; 1376};
1242 1377
1243const struct file_operations ocfs2_dops = { 1378const struct file_operations ocfs2_dops = {
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index 740c9e7ca599..601a453f18a8 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -41,17 +41,24 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
41 struct inode *inode, 41 struct inode *inode,
42 u32 clusters_to_add, 42 u32 clusters_to_add,
43 struct buffer_head *fe_bh, 43 struct buffer_head *fe_bh,
44 struct ocfs2_journal_handle *handle, 44 handle_t *handle,
45 struct ocfs2_alloc_context *data_ac, 45 struct ocfs2_alloc_context *data_ac,
46 struct ocfs2_alloc_context *meta_ac, 46 struct ocfs2_alloc_context *meta_ac,
47 enum ocfs2_alloc_restarted *reason); 47 enum ocfs2_alloc_restarted *reason);
48int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); 48int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
49int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, 49int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
50 struct kstat *stat); 50 struct kstat *stat);
51int ocfs2_permission(struct inode *inode, int mask,
52 struct nameidata *nd);
51 53
52int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, 54int ocfs2_set_inode_size(handle_t *handle,
53 struct inode *inode, 55 struct inode *inode,
54 struct buffer_head *fe_bh, 56 struct buffer_head *fe_bh,
55 u64 new_i_size); 57 u64 new_i_size);
56 58
59int ocfs2_should_update_atime(struct inode *inode,
60 struct vfsmount *vfsmnt);
61int ocfs2_update_inode_atime(struct inode *inode,
62 struct buffer_head *bh);
63
57#endif /* OCFS2_FILE_H */ 64#endif /* OCFS2_FILE_H */
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 16e8e74dc966..42e361f3054f 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -360,7 +360,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
360 inode); 360 inode);
361 361
362 ocfs2_set_inode_flags(inode); 362 ocfs2_set_inode_flags(inode);
363 inode->i_flags |= S_NOATIME;
364 363
365 status = 0; 364 status = 0;
366bail: 365bail:
@@ -441,7 +440,7 @@ static int ocfs2_read_locked_inode(struct inode *inode,
441 generation, inode); 440 generation, inode);
442 441
443 if (can_lock) { 442 if (can_lock) {
444 status = ocfs2_meta_lock(inode, NULL, NULL, 0); 443 status = ocfs2_meta_lock(inode, NULL, 0);
445 if (status) { 444 if (status) {
446 make_bad_inode(inode); 445 make_bad_inode(inode);
447 mlog_errno(status); 446 mlog_errno(status);
@@ -512,7 +511,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
512 struct buffer_head *fe_bh) 511 struct buffer_head *fe_bh)
513{ 512{
514 int status = 0; 513 int status = 0;
515 struct ocfs2_journal_handle *handle = NULL; 514 handle_t *handle = NULL;
516 struct ocfs2_truncate_context *tc = NULL; 515 struct ocfs2_truncate_context *tc = NULL;
517 struct ocfs2_dinode *fe; 516 struct ocfs2_dinode *fe;
518 517
@@ -524,7 +523,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
524 if (!fe->i_clusters) 523 if (!fe->i_clusters)
525 goto bail; 524 goto bail;
526 525
527 handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS); 526 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
528 if (IS_ERR(handle)) { 527 if (IS_ERR(handle)) {
529 status = PTR_ERR(handle); 528 status = PTR_ERR(handle);
530 handle = NULL; 529 handle = NULL;
@@ -538,7 +537,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
538 goto bail; 537 goto bail;
539 } 538 }
540 539
541 ocfs2_commit_trans(handle); 540 ocfs2_commit_trans(osb, handle);
542 handle = NULL; 541 handle = NULL;
543 542
544 status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); 543 status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc);
@@ -554,7 +553,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
554 } 553 }
555bail: 554bail:
556 if (handle) 555 if (handle)
557 ocfs2_commit_trans(handle); 556 ocfs2_commit_trans(osb, handle);
558 557
559 mlog_exit(status); 558 mlog_exit(status);
560 return status; 559 return status;
@@ -568,7 +567,7 @@ static int ocfs2_remove_inode(struct inode *inode,
568 int status; 567 int status;
569 struct inode *inode_alloc_inode = NULL; 568 struct inode *inode_alloc_inode = NULL;
570 struct buffer_head *inode_alloc_bh = NULL; 569 struct buffer_head *inode_alloc_bh = NULL;
571 struct ocfs2_journal_handle *handle; 570 handle_t *handle;
572 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 571 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
573 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; 572 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
574 573
@@ -582,7 +581,7 @@ static int ocfs2_remove_inode(struct inode *inode,
582 } 581 }
583 582
584 mutex_lock(&inode_alloc_inode->i_mutex); 583 mutex_lock(&inode_alloc_inode->i_mutex);
585 status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); 584 status = ocfs2_meta_lock(inode_alloc_inode, &inode_alloc_bh, 1);
586 if (status < 0) { 585 if (status < 0) {
587 mutex_unlock(&inode_alloc_inode->i_mutex); 586 mutex_unlock(&inode_alloc_inode->i_mutex);
588 587
@@ -590,7 +589,7 @@ static int ocfs2_remove_inode(struct inode *inode,
590 goto bail; 589 goto bail;
591 } 590 }
592 591
593 handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS); 592 handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS);
594 if (IS_ERR(handle)) { 593 if (IS_ERR(handle)) {
595 status = PTR_ERR(handle); 594 status = PTR_ERR(handle);
596 mlog_errno(status); 595 mlog_errno(status);
@@ -629,7 +628,7 @@ static int ocfs2_remove_inode(struct inode *inode,
629 mlog_errno(status); 628 mlog_errno(status);
630 629
631bail_commit: 630bail_commit:
632 ocfs2_commit_trans(handle); 631 ocfs2_commit_trans(osb, handle);
633bail_unlock: 632bail_unlock:
634 ocfs2_meta_unlock(inode_alloc_inode, 1); 633 ocfs2_meta_unlock(inode_alloc_inode, 1);
635 mutex_unlock(&inode_alloc_inode->i_mutex); 634 mutex_unlock(&inode_alloc_inode->i_mutex);
@@ -705,7 +704,7 @@ static int ocfs2_wipe_inode(struct inode *inode,
705 * delete_inode operation. We do this now to avoid races with 704 * delete_inode operation. We do this now to avoid races with
706 * recovery completion on other nodes. */ 705 * recovery completion on other nodes. */
707 mutex_lock(&orphan_dir_inode->i_mutex); 706 mutex_lock(&orphan_dir_inode->i_mutex);
708 status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); 707 status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1);
709 if (status < 0) { 708 if (status < 0) {
710 mutex_unlock(&orphan_dir_inode->i_mutex); 709 mutex_unlock(&orphan_dir_inode->i_mutex);
711 710
@@ -933,7 +932,7 @@ void ocfs2_delete_inode(struct inode *inode)
933 * allocation lock here as it won't be needed - nobody will 932 * allocation lock here as it won't be needed - nobody will
934 * have the file open. 933 * have the file open.
935 */ 934 */
936 status = ocfs2_meta_lock(inode, NULL, &di_bh, 1); 935 status = ocfs2_meta_lock(inode, &di_bh, 1);
937 if (status < 0) { 936 if (status < 0) {
938 if (status != -ENOENT) 937 if (status != -ENOENT)
939 mlog_errno(status); 938 mlog_errno(status);
@@ -1067,12 +1066,6 @@ void ocfs2_clear_inode(struct inode *inode)
1067 mlog_bug_on_msg(oi->ip_open_count, 1066 mlog_bug_on_msg(oi->ip_open_count,
1068 "Clear inode of %llu has open count %d\n", 1067 "Clear inode of %llu has open count %d\n",
1069 (unsigned long long)oi->ip_blkno, oi->ip_open_count); 1068 (unsigned long long)oi->ip_blkno, oi->ip_open_count);
1070 mlog_bug_on_msg(!list_empty(&oi->ip_handle_list),
1071 "Clear inode of %llu has non empty handle list\n",
1072 (unsigned long long)oi->ip_blkno);
1073 mlog_bug_on_msg(oi->ip_handle,
1074 "Clear inode of %llu has non empty handle pointer\n",
1075 (unsigned long long)oi->ip_blkno);
1076 1069
1077 /* Clear all other flags. */ 1070 /* Clear all other flags. */
1078 oi->ip_flags = OCFS2_INODE_CACHE_INLINE; 1071 oi->ip_flags = OCFS2_INODE_CACHE_INLINE;
@@ -1186,7 +1179,7 @@ int ocfs2_inode_revalidate(struct dentry *dentry)
1186 1179
1187 /* Let ocfs2_meta_lock do the work of updating our struct 1180 /* Let ocfs2_meta_lock do the work of updating our struct
1188 * inode for us. */ 1181 * inode for us. */
1189 status = ocfs2_meta_lock(inode, NULL, NULL, 0); 1182 status = ocfs2_meta_lock(inode, NULL, 0);
1190 if (status < 0) { 1183 if (status < 0) {
1191 if (status != -ENOENT) 1184 if (status != -ENOENT)
1192 mlog_errno(status); 1185 mlog_errno(status);
@@ -1204,7 +1197,7 @@ bail:
1204 * struct inode. 1197 * struct inode.
1205 * Only takes ip_lock. 1198 * Only takes ip_lock.
1206 */ 1199 */
1207int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, 1200int ocfs2_mark_inode_dirty(handle_t *handle,
1208 struct inode *inode, 1201 struct inode *inode,
1209 struct buffer_head *bh) 1202 struct buffer_head *bh)
1210{ 1203{
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 9957810fdf85..46a378fbc40b 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -48,13 +48,6 @@ struct ocfs2_inode_info
48 48
49 struct mutex ip_io_mutex; 49 struct mutex ip_io_mutex;
50 50
51 /* Used by the journalling code to attach an inode to a
52 * handle. These are protected by ip_io_mutex in order to lock
53 * out other I/O to the inode until we either commit or
54 * abort. */
55 struct list_head ip_handle_list;
56 struct ocfs2_journal_handle *ip_handle;
57
58 u32 ip_flags; /* see below */ 51 u32 ip_flags; /* see below */
59 u32 ip_attr; /* inode attributes */ 52 u32 ip_attr; /* inode attributes */
60 53
@@ -143,7 +136,7 @@ ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf,
143void ocfs2_sync_blockdev(struct super_block *sb); 136void ocfs2_sync_blockdev(struct super_block *sb);
144void ocfs2_refresh_inode(struct inode *inode, 137void ocfs2_refresh_inode(struct inode *inode,
145 struct ocfs2_dinode *fe); 138 struct ocfs2_dinode *fe);
146int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, 139int ocfs2_mark_inode_dirty(handle_t *handle,
147 struct inode *inode, 140 struct inode *inode,
148 struct buffer_head *bh); 141 struct buffer_head *bh);
149int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb); 142int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb);
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index 3663cef80689..4768be5f3086 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -26,7 +26,7 @@ static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags)
26{ 26{
27 int status; 27 int status;
28 28
29 status = ocfs2_meta_lock(inode, NULL, NULL, 0); 29 status = ocfs2_meta_lock(inode, NULL, 0);
30 if (status < 0) { 30 if (status < 0) {
31 mlog_errno(status); 31 mlog_errno(status);
32 return status; 32 return status;
@@ -43,14 +43,14 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
43{ 43{
44 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode); 44 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
45 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 45 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
46 struct ocfs2_journal_handle *handle = NULL; 46 handle_t *handle = NULL;
47 struct buffer_head *bh = NULL; 47 struct buffer_head *bh = NULL;
48 unsigned oldflags; 48 unsigned oldflags;
49 int status; 49 int status;
50 50
51 mutex_lock(&inode->i_mutex); 51 mutex_lock(&inode->i_mutex);
52 52
53 status = ocfs2_meta_lock(inode, NULL, &bh, 1); 53 status = ocfs2_meta_lock(inode, &bh, 1);
54 if (status < 0) { 54 if (status < 0) {
55 mlog_errno(status); 55 mlog_errno(status);
56 goto bail; 56 goto bail;
@@ -67,7 +67,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
67 if (!S_ISDIR(inode->i_mode)) 67 if (!S_ISDIR(inode->i_mode))
68 flags &= ~OCFS2_DIRSYNC_FL; 68 flags &= ~OCFS2_DIRSYNC_FL;
69 69
70 handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); 70 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
71 if (IS_ERR(handle)) { 71 if (IS_ERR(handle)) {
72 status = PTR_ERR(handle); 72 status = PTR_ERR(handle);
73 mlog_errno(status); 73 mlog_errno(status);
@@ -96,7 +96,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
96 if (status < 0) 96 if (status < 0)
97 mlog_errno(status); 97 mlog_errno(status);
98 98
99 ocfs2_commit_trans(handle); 99 ocfs2_commit_trans(osb, handle);
100bail_unlock: 100bail_unlock:
101 ocfs2_meta_unlock(inode, 1); 101 ocfs2_meta_unlock(inode, 1);
102bail: 102bail:
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index fd9734def551..1d7f4ab1e5ed 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -57,9 +57,6 @@ static int ocfs2_recover_node(struct ocfs2_super *osb,
57static int __ocfs2_recovery_thread(void *arg); 57static int __ocfs2_recovery_thread(void *arg);
58static int ocfs2_commit_cache(struct ocfs2_super *osb); 58static int ocfs2_commit_cache(struct ocfs2_super *osb);
59static int ocfs2_wait_on_mount(struct ocfs2_super *osb); 59static int ocfs2_wait_on_mount(struct ocfs2_super *osb);
60static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
61 struct ocfs2_journal_handle *handle);
62static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle);
63static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, 60static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
64 int dirty); 61 int dirty);
65static int ocfs2_trylock_journal(struct ocfs2_super *osb, 62static int ocfs2_trylock_journal(struct ocfs2_super *osb,
@@ -113,46 +110,18 @@ finally:
113 return status; 110 return status;
114} 111}
115 112
116struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb)
117{
118 struct ocfs2_journal_handle *retval = NULL;
119
120 retval = kcalloc(1, sizeof(*retval), GFP_NOFS);
121 if (!retval) {
122 mlog(ML_ERROR, "Failed to allocate memory for journal "
123 "handle!\n");
124 return NULL;
125 }
126
127 retval->max_buffs = 0;
128 retval->num_locks = 0;
129 retval->k_handle = NULL;
130
131 INIT_LIST_HEAD(&retval->locks);
132 INIT_LIST_HEAD(&retval->inode_list);
133 retval->journal = osb->journal;
134
135 return retval;
136}
137
138/* pass it NULL and it will allocate a new handle object for you. If 113/* pass it NULL and it will allocate a new handle object for you. If
139 * you pass it a handle however, it may still return error, in which 114 * you pass it a handle however, it may still return error, in which
140 * case it has free'd the passed handle for you. */ 115 * case it has free'd the passed handle for you. */
141struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, 116handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
142 struct ocfs2_journal_handle *handle,
143 int max_buffs)
144{ 117{
145 int ret;
146 journal_t *journal = osb->journal->j_journal; 118 journal_t *journal = osb->journal->j_journal;
147 119 handle_t *handle;
148 mlog_entry("(max_buffs = %d)\n", max_buffs);
149 120
150 BUG_ON(!osb || !osb->journal->j_journal); 121 BUG_ON(!osb || !osb->journal->j_journal);
151 122
152 if (ocfs2_is_hard_readonly(osb)) { 123 if (ocfs2_is_hard_readonly(osb))
153 ret = -EROFS; 124 return ERR_PTR(-EROFS);
154 goto done_free;
155 }
156 125
157 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); 126 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
158 BUG_ON(max_buffs <= 0); 127 BUG_ON(max_buffs <= 0);
@@ -163,154 +132,39 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
163 BUG(); 132 BUG();
164 } 133 }
165 134
166 if (!handle)
167 handle = ocfs2_alloc_handle(osb);
168 if (!handle) {
169 ret = -ENOMEM;
170 mlog(ML_ERROR, "Failed to allocate memory for journal "
171 "handle!\n");
172 goto done_free;
173 }
174
175 handle->max_buffs = max_buffs;
176
177 down_read(&osb->journal->j_trans_barrier); 135 down_read(&osb->journal->j_trans_barrier);
178 136
179 /* actually start the transaction now */ 137 handle = journal_start(journal, max_buffs);
180 handle->k_handle = journal_start(journal, max_buffs); 138 if (IS_ERR(handle)) {
181 if (IS_ERR(handle->k_handle)) {
182 up_read(&osb->journal->j_trans_barrier); 139 up_read(&osb->journal->j_trans_barrier);
183 140
184 ret = PTR_ERR(handle->k_handle); 141 mlog_errno(PTR_ERR(handle));
185 handle->k_handle = NULL;
186 mlog_errno(ret);
187 142
188 if (is_journal_aborted(journal)) { 143 if (is_journal_aborted(journal)) {
189 ocfs2_abort(osb->sb, "Detected aborted journal"); 144 ocfs2_abort(osb->sb, "Detected aborted journal");
190 ret = -EROFS; 145 handle = ERR_PTR(-EROFS);
191 } 146 }
192 goto done_free; 147 } else
193 } 148 atomic_inc(&(osb->journal->j_num_trans));
194
195 atomic_inc(&(osb->journal->j_num_trans));
196 handle->flags |= OCFS2_HANDLE_STARTED;
197 149
198 mlog_exit_ptr(handle);
199 return handle; 150 return handle;
200
201done_free:
202 if (handle)
203 ocfs2_commit_unstarted_handle(handle); /* will kfree handle */
204
205 mlog_exit(ret);
206 return ERR_PTR(ret);
207}
208
209void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle,
210 struct inode *inode)
211{
212 BUG_ON(!handle);
213 BUG_ON(!inode);
214
215 atomic_inc(&inode->i_count);
216
217 /* we're obviously changing it... */
218 mutex_lock(&inode->i_mutex);
219
220 /* sanity check */
221 BUG_ON(OCFS2_I(inode)->ip_handle);
222 BUG_ON(!list_empty(&OCFS2_I(inode)->ip_handle_list));
223
224 OCFS2_I(inode)->ip_handle = handle;
225 list_move_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list));
226}
227
228static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle)
229{
230 struct list_head *p, *n;
231 struct inode *inode;
232 struct ocfs2_inode_info *oi;
233
234 list_for_each_safe(p, n, &handle->inode_list) {
235 oi = list_entry(p, struct ocfs2_inode_info,
236 ip_handle_list);
237 inode = &oi->vfs_inode;
238
239 OCFS2_I(inode)->ip_handle = NULL;
240 list_del_init(&OCFS2_I(inode)->ip_handle_list);
241
242 mutex_unlock(&inode->i_mutex);
243 iput(inode);
244 }
245}
246
247/* This is trivial so we do it out of the main commit
248 * paths. Beware, it can be called from start_trans too! */
249static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle)
250{
251 mlog_entry_void();
252
253 BUG_ON(handle->flags & OCFS2_HANDLE_STARTED);
254
255 ocfs2_handle_unlock_inodes(handle);
256 /* You are allowed to add journal locks before the transaction
257 * has started. */
258 ocfs2_handle_cleanup_locks(handle->journal, handle);
259
260 kfree(handle);
261
262 mlog_exit_void();
263} 151}
264 152
265void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) 153int ocfs2_commit_trans(struct ocfs2_super *osb,
154 handle_t *handle)
266{ 155{
267 handle_t *jbd_handle; 156 int ret;
268 int retval; 157 struct ocfs2_journal *journal = osb->journal;
269 struct ocfs2_journal *journal = handle->journal;
270
271 mlog_entry_void();
272 158
273 BUG_ON(!handle); 159 BUG_ON(!handle);
274 160
275 if (!(handle->flags & OCFS2_HANDLE_STARTED)) { 161 ret = journal_stop(handle);
276 ocfs2_commit_unstarted_handle(handle); 162 if (ret < 0)
277 mlog_exit_void(); 163 mlog_errno(ret);
278 return;
279 }
280
281 /* release inode semaphores we took during this transaction */
282 ocfs2_handle_unlock_inodes(handle);
283
284 /* ocfs2_extend_trans may have had to call journal_restart
285 * which will always commit the transaction, but may return
286 * error for any number of reasons. If this is the case, we
287 * clear k_handle as it's not valid any more. */
288 if (handle->k_handle) {
289 jbd_handle = handle->k_handle;
290
291 if (handle->flags & OCFS2_HANDLE_SYNC)
292 jbd_handle->h_sync = 1;
293 else
294 jbd_handle->h_sync = 0;
295
296 /* actually stop the transaction. if we've set h_sync,
297 * it'll have been committed when we return */
298 retval = journal_stop(jbd_handle);
299 if (retval < 0) {
300 mlog_errno(retval);
301 mlog(ML_ERROR, "Could not commit transaction\n");
302 BUG();
303 }
304
305 handle->k_handle = NULL; /* it's been free'd in journal_stop */
306 }
307
308 ocfs2_handle_cleanup_locks(journal, handle);
309 164
310 up_read(&journal->j_trans_barrier); 165 up_read(&journal->j_trans_barrier);
311 166
312 kfree(handle); 167 return ret;
313 mlog_exit_void();
314} 168}
315 169
316/* 170/*
@@ -326,20 +180,18 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle)
326 * good because transaction ids haven't yet been recorded on the 180 * good because transaction ids haven't yet been recorded on the
327 * cluster locks associated with this handle. 181 * cluster locks associated with this handle.
328 */ 182 */
329int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, 183int ocfs2_extend_trans(handle_t *handle, int nblocks)
330 int nblocks)
331{ 184{
332 int status; 185 int status;
333 186
334 BUG_ON(!handle); 187 BUG_ON(!handle);
335 BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED));
336 BUG_ON(!nblocks); 188 BUG_ON(!nblocks);
337 189
338 mlog_entry_void(); 190 mlog_entry_void();
339 191
340 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); 192 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks);
341 193
342 status = journal_extend(handle->k_handle, nblocks); 194 status = journal_extend(handle, nblocks);
343 if (status < 0) { 195 if (status < 0) {
344 mlog_errno(status); 196 mlog_errno(status);
345 goto bail; 197 goto bail;
@@ -347,15 +199,12 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle,
347 199
348 if (status > 0) { 200 if (status > 0) {
349 mlog(0, "journal_extend failed, trying journal_restart\n"); 201 mlog(0, "journal_extend failed, trying journal_restart\n");
350 status = journal_restart(handle->k_handle, nblocks); 202 status = journal_restart(handle, nblocks);
351 if (status < 0) { 203 if (status < 0) {
352 handle->k_handle = NULL;
353 mlog_errno(status); 204 mlog_errno(status);
354 goto bail; 205 goto bail;
355 } 206 }
356 handle->max_buffs = nblocks; 207 }
357 } else
358 handle->max_buffs += nblocks;
359 208
360 status = 0; 209 status = 0;
361bail: 210bail:
@@ -364,7 +213,7 @@ bail:
364 return status; 213 return status;
365} 214}
366 215
367int ocfs2_journal_access(struct ocfs2_journal_handle *handle, 216int ocfs2_journal_access(handle_t *handle,
368 struct inode *inode, 217 struct inode *inode,
369 struct buffer_head *bh, 218 struct buffer_head *bh,
370 int type) 219 int type)
@@ -374,7 +223,6 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
374 BUG_ON(!inode); 223 BUG_ON(!inode);
375 BUG_ON(!handle); 224 BUG_ON(!handle);
376 BUG_ON(!bh); 225 BUG_ON(!bh);
377 BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED));
378 226
379 mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", 227 mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n",
380 (unsigned long long)bh->b_blocknr, type, 228 (unsigned long long)bh->b_blocknr, type,
@@ -403,11 +251,11 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
403 switch (type) { 251 switch (type) {
404 case OCFS2_JOURNAL_ACCESS_CREATE: 252 case OCFS2_JOURNAL_ACCESS_CREATE:
405 case OCFS2_JOURNAL_ACCESS_WRITE: 253 case OCFS2_JOURNAL_ACCESS_WRITE:
406 status = journal_get_write_access(handle->k_handle, bh); 254 status = journal_get_write_access(handle, bh);
407 break; 255 break;
408 256
409 case OCFS2_JOURNAL_ACCESS_UNDO: 257 case OCFS2_JOURNAL_ACCESS_UNDO:
410 status = journal_get_undo_access(handle->k_handle, bh); 258 status = journal_get_undo_access(handle, bh);
411 break; 259 break;
412 260
413 default: 261 default:
@@ -424,17 +272,15 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
424 return status; 272 return status;
425} 273}
426 274
427int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, 275int ocfs2_journal_dirty(handle_t *handle,
428 struct buffer_head *bh) 276 struct buffer_head *bh)
429{ 277{
430 int status; 278 int status;
431 279
432 BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED));
433
434 mlog_entry("(bh->b_blocknr=%llu)\n", 280 mlog_entry("(bh->b_blocknr=%llu)\n",
435 (unsigned long long)bh->b_blocknr); 281 (unsigned long long)bh->b_blocknr);
436 282
437 status = journal_dirty_metadata(handle->k_handle, bh); 283 status = journal_dirty_metadata(handle, bh);
438 if (status < 0) 284 if (status < 0)
439 mlog(ML_ERROR, "Could not dirty metadata buffer. " 285 mlog(ML_ERROR, "Could not dirty metadata buffer. "
440 "(bh->b_blocknr=%llu)\n", 286 "(bh->b_blocknr=%llu)\n",
@@ -456,59 +302,6 @@ int ocfs2_journal_dirty_data(handle_t *handle,
456 return err; 302 return err;
457} 303}
458 304
459/* We always assume you're adding a metadata lock at level 'ex' */
460int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
461 struct inode *inode)
462{
463 int status;
464 struct ocfs2_journal_lock *lock;
465
466 BUG_ON(!inode);
467
468 lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS);
469 if (!lock) {
470 status = -ENOMEM;
471 mlog_errno(-ENOMEM);
472 goto bail;
473 }
474
475 if (!igrab(inode))
476 BUG();
477 lock->jl_inode = inode;
478
479 list_add_tail(&(lock->jl_lock_list), &(handle->locks));
480 handle->num_locks++;
481
482 status = 0;
483bail:
484 mlog_exit(status);
485 return status;
486}
487
488static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal,
489 struct ocfs2_journal_handle *handle)
490{
491 struct list_head *p, *n;
492 struct ocfs2_journal_lock *lock;
493 struct inode *inode;
494
495 list_for_each_safe(p, n, &(handle->locks)) {
496 lock = list_entry(p, struct ocfs2_journal_lock,
497 jl_lock_list);
498 list_del(&lock->jl_lock_list);
499 handle->num_locks--;
500
501 inode = lock->jl_inode;
502 ocfs2_meta_unlock(inode, 1);
503 if (atomic_read(&inode->i_count) == 1)
504 mlog(ML_ERROR,
505 "Inode %llu, I'm doing a last iput for!",
506 (unsigned long long)OCFS2_I(inode)->ip_blkno);
507 iput(inode);
508 kmem_cache_free(ocfs2_lock_cache, lock);
509 }
510}
511
512#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) 305#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5)
513 306
514void ocfs2_set_journal_params(struct ocfs2_super *osb) 307void ocfs2_set_journal_params(struct ocfs2_super *osb)
@@ -562,8 +355,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
562 /* Skip recovery waits here - journal inode metadata never 355 /* Skip recovery waits here - journal inode metadata never
563 * changes in a live cluster so it can be considered an 356 * changes in a live cluster so it can be considered an
564 * exception to the rule. */ 357 * exception to the rule. */
565 status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, 358 status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY);
566 OCFS2_META_LOCK_RECOVERY);
567 if (status < 0) { 359 if (status < 0) {
568 if (status != -ERESTARTSYS) 360 if (status != -ERESTARTSYS)
569 mlog(ML_ERROR, "Could not get lock on journal!\n"); 361 mlog(ML_ERROR, "Could not get lock on journal!\n");
@@ -911,11 +703,12 @@ struct ocfs2_la_recovery_item {
911 * NOTE: This function can and will sleep on recovery of other nodes 703 * NOTE: This function can and will sleep on recovery of other nodes
912 * during cluster locking, just like any other ocfs2 process. 704 * during cluster locking, just like any other ocfs2 process.
913 */ 705 */
914void ocfs2_complete_recovery(void *data) 706void ocfs2_complete_recovery(struct work_struct *work)
915{ 707{
916 int ret; 708 int ret;
917 struct ocfs2_super *osb = data; 709 struct ocfs2_journal *journal =
918 struct ocfs2_journal *journal = osb->journal; 710 container_of(work, struct ocfs2_journal, j_recovery_work);
711 struct ocfs2_super *osb = journal->j_osb;
919 struct ocfs2_dinode *la_dinode, *tl_dinode; 712 struct ocfs2_dinode *la_dinode, *tl_dinode;
920 struct ocfs2_la_recovery_item *item; 713 struct ocfs2_la_recovery_item *item;
921 struct list_head *p, *n; 714 struct list_head *p, *n;
@@ -1160,8 +953,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1160 } 953 }
1161 SET_INODE_JOURNAL(inode); 954 SET_INODE_JOURNAL(inode);
1162 955
1163 status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, 956 status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY);
1164 OCFS2_META_LOCK_RECOVERY);
1165 if (status < 0) { 957 if (status < 0) {
1166 mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); 958 mlog(0, "status returned from ocfs2_meta_lock=%d\n", status);
1167 if (status != -ERESTARTSYS) 959 if (status != -ERESTARTSYS)
@@ -1350,7 +1142,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
1350 SET_INODE_JOURNAL(inode); 1142 SET_INODE_JOURNAL(inode);
1351 1143
1352 flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; 1144 flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE;
1353 status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags); 1145 status = ocfs2_meta_lock_full(inode, NULL, 1, flags);
1354 if (status < 0) { 1146 if (status < 0) {
1355 if (status != -EAGAIN) 1147 if (status != -EAGAIN)
1356 mlog_errno(status); 1148 mlog_errno(status);
@@ -1433,7 +1225,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
1433 } 1225 }
1434 1226
1435 mutex_lock(&orphan_dir_inode->i_mutex); 1227 mutex_lock(&orphan_dir_inode->i_mutex);
1436 status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); 1228 status = ocfs2_meta_lock(orphan_dir_inode, NULL, 0);
1437 if (status < 0) { 1229 if (status < 0) {
1438 mlog_errno(status); 1230 mlog_errno(status);
1439 goto out; 1231 goto out;
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 2f3a6acdac45..899112ad8136 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -37,7 +37,6 @@ enum ocfs2_journal_state {
37 37
38struct ocfs2_super; 38struct ocfs2_super;
39struct ocfs2_dinode; 39struct ocfs2_dinode;
40struct ocfs2_journal_handle;
41 40
42struct ocfs2_journal { 41struct ocfs2_journal {
43 enum ocfs2_journal_state j_state; /* Journals current state */ 42 enum ocfs2_journal_state j_state; /* Journals current state */
@@ -133,46 +132,8 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
133 spin_unlock(&trans_inc_lock); 132 spin_unlock(&trans_inc_lock);
134} 133}
135 134
136extern kmem_cache_t *ocfs2_lock_cache;
137
138struct ocfs2_journal_lock {
139 struct inode *jl_inode;
140 struct list_head jl_lock_list;
141};
142
143struct ocfs2_journal_handle {
144 handle_t *k_handle; /* kernel handle. */
145 struct ocfs2_journal *journal;
146 u32 flags; /* see flags below. */
147 int max_buffs; /* Buffs reserved by this handle */
148
149 /* The following two fields are for ocfs2_handle_add_lock */
150 int num_locks;
151 struct list_head locks; /* A bunch of locks to
152 * release on commit. This
153 * should be a list_head */
154
155 struct list_head inode_list;
156};
157
158#define OCFS2_HANDLE_STARTED 1
159/* should we sync-commit this handle? */
160#define OCFS2_HANDLE_SYNC 2
161static inline int ocfs2_handle_started(struct ocfs2_journal_handle *handle)
162{
163 return handle->flags & OCFS2_HANDLE_STARTED;
164}
165
166static inline void ocfs2_handle_set_sync(struct ocfs2_journal_handle *handle, int sync)
167{
168 if (sync)
169 handle->flags |= OCFS2_HANDLE_SYNC;
170 else
171 handle->flags &= ~OCFS2_HANDLE_SYNC;
172}
173
174/* Exported only for the journal struct init code in super.c. Do not call. */ 135/* Exported only for the journal struct init code in super.c. Do not call. */
175void ocfs2_complete_recovery(void *data); 136void ocfs2_complete_recovery(struct work_struct *work);
176 137
177/* 138/*
178 * Journal Control: 139 * Journal Control:
@@ -231,15 +192,14 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
231 * Transaction Handling: 192 * Transaction Handling:
232 * Manage the lifetime of a transaction handle. 193 * Manage the lifetime of a transaction handle.
233 * 194 *
234 * ocfs2_alloc_handle - Only allocate a handle so we can start putting
235 * cluster locks on it. To actually change blocks,
236 * call ocfs2_start_trans with the handle returned
237 * from this function. You may call ocfs2_commit_trans
238 * at any time in the lifetime of a handle.
239 * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of 195 * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of
240 * the number of blocks that will be changed during 196 * the number of blocks that will be changed during
241 * this handle. 197 * this handle.
242 * ocfs2_commit_trans - Complete a handle. 198 * ocfs2_commit_trans - Complete a handle. It might return -EIO if
199 * the journal was aborted. The majority of paths don't
200 * check the return value as an error there comes too
201 * late to do anything (and will be picked up in a
202 * later transaction).
243 * ocfs2_extend_trans - Extend a handle by nblocks credits. This may 203 * ocfs2_extend_trans - Extend a handle by nblocks credits. This may
244 * commit the handle to disk in the process, but will 204 * commit the handle to disk in the process, but will
245 * not release any locks taken during the transaction. 205 * not release any locks taken during the transaction.
@@ -249,24 +209,16 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
249 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. 209 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data.
250 * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before 210 * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before
251 * the current handle commits. 211 * the current handle commits.
252 * ocfs2_handle_add_lock - Sometimes we need to delay lock release
253 * until after a transaction has been completed. Use
254 * ocfs2_handle_add_lock to indicate that a lock needs
255 * to be released at the end of that handle. Locks
256 * will be released in the order that they are added.
257 * ocfs2_handle_add_inode - Add a locked inode to a transaction.
258 */ 212 */
259 213
260/* You must always start_trans with a number of buffs > 0, but it's 214/* You must always start_trans with a number of buffs > 0, but it's
261 * perfectly legal to go through an entire transaction without having 215 * perfectly legal to go through an entire transaction without having
262 * dirtied any buffers. */ 216 * dirtied any buffers. */
263struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb); 217handle_t *ocfs2_start_trans(struct ocfs2_super *osb,
264struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb,
265 struct ocfs2_journal_handle *handle,
266 int max_buffs); 218 int max_buffs);
267void ocfs2_commit_trans(struct ocfs2_journal_handle *handle); 219int ocfs2_commit_trans(struct ocfs2_super *osb,
268int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, 220 handle_t *handle);
269 int nblocks); 221int ocfs2_extend_trans(handle_t *handle, int nblocks);
270 222
271/* 223/*
272 * Create access is for when we get a newly created buffer and we're 224 * Create access is for when we get a newly created buffer and we're
@@ -283,7 +235,7 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle,
283#define OCFS2_JOURNAL_ACCESS_WRITE 1 235#define OCFS2_JOURNAL_ACCESS_WRITE 1
284#define OCFS2_JOURNAL_ACCESS_UNDO 2 236#define OCFS2_JOURNAL_ACCESS_UNDO 2
285 237
286int ocfs2_journal_access(struct ocfs2_journal_handle *handle, 238int ocfs2_journal_access(handle_t *handle,
287 struct inode *inode, 239 struct inode *inode,
288 struct buffer_head *bh, 240 struct buffer_head *bh,
289 int type); 241 int type);
@@ -306,18 +258,10 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle,
306 * <modify the bh> 258 * <modify the bh>
307 * ocfs2_journal_dirty(handle, bh); 259 * ocfs2_journal_dirty(handle, bh);
308 */ 260 */
309int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, 261int ocfs2_journal_dirty(handle_t *handle,
310 struct buffer_head *bh); 262 struct buffer_head *bh);
311int ocfs2_journal_dirty_data(handle_t *handle, 263int ocfs2_journal_dirty_data(handle_t *handle,
312 struct buffer_head *bh); 264 struct buffer_head *bh);
313int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle,
314 struct inode *inode);
315/*
316 * Use this to protect from other processes reading buffer state while
317 * it's in flight.
318 */
319void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle,
320 struct inode *inode);
321 265
322/* 266/*
323 * Credit Macros: 267 * Credit Macros:
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 1f17a4d08287..698d79a74ef8 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -58,19 +58,18 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
58static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc); 58static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc);
59 59
60static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, 60static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
61 struct ocfs2_journal_handle *handle, 61 handle_t *handle,
62 struct ocfs2_dinode *alloc, 62 struct ocfs2_dinode *alloc,
63 struct inode *main_bm_inode, 63 struct inode *main_bm_inode,
64 struct buffer_head *main_bm_bh); 64 struct buffer_head *main_bm_bh);
65 65
66static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, 66static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
67 struct ocfs2_journal_handle *handle,
68 struct ocfs2_alloc_context **ac, 67 struct ocfs2_alloc_context **ac,
69 struct inode **bitmap_inode, 68 struct inode **bitmap_inode,
70 struct buffer_head **bitmap_bh); 69 struct buffer_head **bitmap_bh);
71 70
72static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, 71static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
73 struct ocfs2_journal_handle *handle, 72 handle_t *handle,
74 struct ocfs2_alloc_context *ac); 73 struct ocfs2_alloc_context *ac);
75 74
76static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, 75static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
@@ -196,7 +195,7 @@ bail:
196void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) 195void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
197{ 196{
198 int status; 197 int status;
199 struct ocfs2_journal_handle *handle = NULL; 198 handle_t *handle;
200 struct inode *local_alloc_inode = NULL; 199 struct inode *local_alloc_inode = NULL;
201 struct buffer_head *bh = NULL; 200 struct buffer_head *bh = NULL;
202 struct buffer_head *main_bm_bh = NULL; 201 struct buffer_head *main_bm_bh = NULL;
@@ -207,7 +206,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
207 mlog_entry_void(); 206 mlog_entry_void();
208 207
209 if (osb->local_alloc_state == OCFS2_LA_UNUSED) 208 if (osb->local_alloc_state == OCFS2_LA_UNUSED)
210 goto bail; 209 goto out;
211 210
212 local_alloc_inode = 211 local_alloc_inode =
213 ocfs2_get_system_file_inode(osb, 212 ocfs2_get_system_file_inode(osb,
@@ -216,40 +215,34 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
216 if (!local_alloc_inode) { 215 if (!local_alloc_inode) {
217 status = -ENOENT; 216 status = -ENOENT;
218 mlog_errno(status); 217 mlog_errno(status);
219 goto bail; 218 goto out;
220 } 219 }
221 220
222 osb->local_alloc_state = OCFS2_LA_DISABLED; 221 osb->local_alloc_state = OCFS2_LA_DISABLED;
223 222
224 handle = ocfs2_alloc_handle(osb);
225 if (!handle) {
226 status = -ENOMEM;
227 mlog_errno(status);
228 goto bail;
229 }
230
231 main_bm_inode = ocfs2_get_system_file_inode(osb, 223 main_bm_inode = ocfs2_get_system_file_inode(osb,
232 GLOBAL_BITMAP_SYSTEM_INODE, 224 GLOBAL_BITMAP_SYSTEM_INODE,
233 OCFS2_INVALID_SLOT); 225 OCFS2_INVALID_SLOT);
234 if (!main_bm_inode) { 226 if (!main_bm_inode) {
235 status = -EINVAL; 227 status = -EINVAL;
236 mlog_errno(status); 228 mlog_errno(status);
237 goto bail; 229 goto out;
238 } 230 }
239 231
240 ocfs2_handle_add_inode(handle, main_bm_inode); 232 mutex_lock(&main_bm_inode->i_mutex);
241 status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); 233
234 status = ocfs2_meta_lock(main_bm_inode, &main_bm_bh, 1);
242 if (status < 0) { 235 if (status < 0) {
243 mlog_errno(status); 236 mlog_errno(status);
244 goto bail; 237 goto out_mutex;
245 } 238 }
246 239
247 /* WINDOW_MOVE_CREDITS is a bit heavy... */ 240 /* WINDOW_MOVE_CREDITS is a bit heavy... */
248 handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); 241 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
249 if (IS_ERR(handle)) { 242 if (IS_ERR(handle)) {
250 mlog_errno(PTR_ERR(handle)); 243 mlog_errno(PTR_ERR(handle));
251 handle = NULL; 244 handle = NULL;
252 goto bail; 245 goto out_unlock;
253 } 246 }
254 247
255 bh = osb->local_alloc_bh; 248 bh = osb->local_alloc_bh;
@@ -258,7 +251,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
258 alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); 251 alloc_copy = kmalloc(bh->b_size, GFP_KERNEL);
259 if (!alloc_copy) { 252 if (!alloc_copy) {
260 status = -ENOMEM; 253 status = -ENOMEM;
261 goto bail; 254 goto out_commit;
262 } 255 }
263 memcpy(alloc_copy, alloc, bh->b_size); 256 memcpy(alloc_copy, alloc, bh->b_size);
264 257
@@ -266,7 +259,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
266 OCFS2_JOURNAL_ACCESS_WRITE); 259 OCFS2_JOURNAL_ACCESS_WRITE);
267 if (status < 0) { 260 if (status < 0) {
268 mlog_errno(status); 261 mlog_errno(status);
269 goto bail; 262 goto out_commit;
270 } 263 }
271 264
272 ocfs2_clear_local_alloc(alloc); 265 ocfs2_clear_local_alloc(alloc);
@@ -274,7 +267,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
274 status = ocfs2_journal_dirty(handle, bh); 267 status = ocfs2_journal_dirty(handle, bh);
275 if (status < 0) { 268 if (status < 0) {
276 mlog_errno(status); 269 mlog_errno(status);
277 goto bail; 270 goto out_commit;
278 } 271 }
279 272
280 brelse(bh); 273 brelse(bh);
@@ -286,16 +279,20 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
286 if (status < 0) 279 if (status < 0)
287 mlog_errno(status); 280 mlog_errno(status);
288 281
289bail: 282out_commit:
290 if (handle) 283 ocfs2_commit_trans(osb, handle);
291 ocfs2_commit_trans(handle);
292 284
285out_unlock:
293 if (main_bm_bh) 286 if (main_bm_bh)
294 brelse(main_bm_bh); 287 brelse(main_bm_bh);
295 288
296 if (main_bm_inode) 289 ocfs2_meta_unlock(main_bm_inode, 1);
297 iput(main_bm_inode);
298 290
291out_mutex:
292 mutex_unlock(&main_bm_inode->i_mutex);
293 iput(main_bm_inode);
294
295out:
299 if (local_alloc_inode) 296 if (local_alloc_inode)
300 iput(local_alloc_inode); 297 iput(local_alloc_inode);
301 298
@@ -385,61 +382,59 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb,
385 struct ocfs2_dinode *alloc) 382 struct ocfs2_dinode *alloc)
386{ 383{
387 int status; 384 int status;
388 struct ocfs2_journal_handle *handle = NULL; 385 handle_t *handle;
389 struct buffer_head *main_bm_bh = NULL; 386 struct buffer_head *main_bm_bh = NULL;
390 struct inode *main_bm_inode = NULL; 387 struct inode *main_bm_inode;
391 388
392 mlog_entry_void(); 389 mlog_entry_void();
393 390
394 handle = ocfs2_alloc_handle(osb);
395 if (!handle) {
396 status = -ENOMEM;
397 mlog_errno(status);
398 goto bail;
399 }
400
401 main_bm_inode = ocfs2_get_system_file_inode(osb, 391 main_bm_inode = ocfs2_get_system_file_inode(osb,
402 GLOBAL_BITMAP_SYSTEM_INODE, 392 GLOBAL_BITMAP_SYSTEM_INODE,
403 OCFS2_INVALID_SLOT); 393 OCFS2_INVALID_SLOT);
404 if (!main_bm_inode) { 394 if (!main_bm_inode) {
405 status = -EINVAL; 395 status = -EINVAL;
406 mlog_errno(status); 396 mlog_errno(status);
407 goto bail; 397 goto out;
408 } 398 }
409 399
410 ocfs2_handle_add_inode(handle, main_bm_inode); 400 mutex_lock(&main_bm_inode->i_mutex);
411 status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); 401
402 status = ocfs2_meta_lock(main_bm_inode, &main_bm_bh, 1);
412 if (status < 0) { 403 if (status < 0) {
413 mlog_errno(status); 404 mlog_errno(status);
414 goto bail; 405 goto out_mutex;
415 } 406 }
416 407
417 handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); 408 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
418 if (IS_ERR(handle)) { 409 if (IS_ERR(handle)) {
419 status = PTR_ERR(handle); 410 status = PTR_ERR(handle);
420 handle = NULL; 411 handle = NULL;
421 mlog_errno(status); 412 mlog_errno(status);
422 goto bail; 413 goto out_unlock;
423 } 414 }
424 415
425 /* we want the bitmap change to be recorded on disk asap */ 416 /* we want the bitmap change to be recorded on disk asap */
426 ocfs2_handle_set_sync(handle, 1); 417 handle->h_sync = 1;
427 418
428 status = ocfs2_sync_local_to_main(osb, handle, alloc, 419 status = ocfs2_sync_local_to_main(osb, handle, alloc,
429 main_bm_inode, main_bm_bh); 420 main_bm_inode, main_bm_bh);
430 if (status < 0) 421 if (status < 0)
431 mlog_errno(status); 422 mlog_errno(status);
432 423
433bail: 424 ocfs2_commit_trans(osb, handle);
434 if (handle) 425
435 ocfs2_commit_trans(handle); 426out_unlock:
427 ocfs2_meta_unlock(main_bm_inode, 1);
428
429out_mutex:
430 mutex_unlock(&main_bm_inode->i_mutex);
436 431
437 if (main_bm_bh) 432 if (main_bm_bh)
438 brelse(main_bm_bh); 433 brelse(main_bm_bh);
439 434
440 if (main_bm_inode) 435 iput(main_bm_inode);
441 iput(main_bm_inode);
442 436
437out:
443 mlog_exit(status); 438 mlog_exit(status);
444 return status; 439 return status;
445} 440}
@@ -452,7 +447,6 @@ bail:
452 * our own in order to shift windows. 447 * our own in order to shift windows.
453 */ 448 */
454int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, 449int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
455 struct ocfs2_journal_handle *passed_handle,
456 u32 bits_wanted, 450 u32 bits_wanted,
457 struct ocfs2_alloc_context *ac) 451 struct ocfs2_alloc_context *ac)
458{ 452{
@@ -463,9 +457,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
463 457
464 mlog_entry_void(); 458 mlog_entry_void();
465 459
466 BUG_ON(!passed_handle);
467 BUG_ON(!ac); 460 BUG_ON(!ac);
468 BUG_ON(passed_handle->flags & OCFS2_HANDLE_STARTED);
469 461
470 local_alloc_inode = 462 local_alloc_inode =
471 ocfs2_get_system_file_inode(osb, 463 ocfs2_get_system_file_inode(osb,
@@ -476,7 +468,11 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
476 mlog_errno(status); 468 mlog_errno(status);
477 goto bail; 469 goto bail;
478 } 470 }
479 ocfs2_handle_add_inode(passed_handle, local_alloc_inode); 471
472 mutex_lock(&local_alloc_inode->i_mutex);
473
474 ac->ac_inode = local_alloc_inode;
475 ac->ac_which = OCFS2_AC_USE_LOCAL;
480 476
481 if (osb->local_alloc_state != OCFS2_LA_ENABLED) { 477 if (osb->local_alloc_state != OCFS2_LA_ENABLED) {
482 status = -ENOSPC; 478 status = -ENOSPC;
@@ -515,21 +511,17 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
515 } 511 }
516 } 512 }
517 513
518 ac->ac_inode = igrab(local_alloc_inode);
519 get_bh(osb->local_alloc_bh); 514 get_bh(osb->local_alloc_bh);
520 ac->ac_bh = osb->local_alloc_bh; 515 ac->ac_bh = osb->local_alloc_bh;
521 ac->ac_which = OCFS2_AC_USE_LOCAL;
522 status = 0; 516 status = 0;
523bail: 517bail:
524 if (local_alloc_inode)
525 iput(local_alloc_inode);
526 518
527 mlog_exit(status); 519 mlog_exit(status);
528 return status; 520 return status;
529} 521}
530 522
531int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 523int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
532 struct ocfs2_journal_handle *handle, 524 handle_t *handle,
533 struct ocfs2_alloc_context *ac, 525 struct ocfs2_alloc_context *ac,
534 u32 min_bits, 526 u32 min_bits,
535 u32 *bit_off, 527 u32 *bit_off,
@@ -707,7 +699,7 @@ static void ocfs2_verify_zero_bits(unsigned long *bitmap,
707 * passed is used for caching. 699 * passed is used for caching.
708 */ 700 */
709static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, 701static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
710 struct ocfs2_journal_handle *handle, 702 handle_t *handle,
711 struct ocfs2_dinode *alloc, 703 struct ocfs2_dinode *alloc,
712 struct inode *main_bm_inode, 704 struct inode *main_bm_inode,
713 struct buffer_head *main_bm_bh) 705 struct buffer_head *main_bm_bh)
@@ -778,7 +770,6 @@ bail:
778} 770}
779 771
780static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, 772static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
781 struct ocfs2_journal_handle *handle,
782 struct ocfs2_alloc_context **ac, 773 struct ocfs2_alloc_context **ac,
783 struct inode **bitmap_inode, 774 struct inode **bitmap_inode,
784 struct buffer_head **bitmap_bh) 775 struct buffer_head **bitmap_bh)
@@ -792,7 +783,6 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
792 goto bail; 783 goto bail;
793 } 784 }
794 785
795 (*ac)->ac_handle = handle;
796 (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); 786 (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb);
797 787
798 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); 788 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
@@ -821,7 +811,7 @@ bail:
821 * pass it the bitmap lock in lock_bh if you have it. 811 * pass it the bitmap lock in lock_bh if you have it.
822 */ 812 */
823static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, 813static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
824 struct ocfs2_journal_handle *handle, 814 handle_t *handle,
825 struct ocfs2_alloc_context *ac) 815 struct ocfs2_alloc_context *ac)
826{ 816{
827 int status = 0; 817 int status = 0;
@@ -888,23 +878,15 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
888 int status = 0; 878 int status = 0;
889 struct buffer_head *main_bm_bh = NULL; 879 struct buffer_head *main_bm_bh = NULL;
890 struct inode *main_bm_inode = NULL; 880 struct inode *main_bm_inode = NULL;
891 struct ocfs2_journal_handle *handle = NULL; 881 handle_t *handle = NULL;
892 struct ocfs2_dinode *alloc; 882 struct ocfs2_dinode *alloc;
893 struct ocfs2_dinode *alloc_copy = NULL; 883 struct ocfs2_dinode *alloc_copy = NULL;
894 struct ocfs2_alloc_context *ac = NULL; 884 struct ocfs2_alloc_context *ac = NULL;
895 885
896 mlog_entry_void(); 886 mlog_entry_void();
897 887
898 handle = ocfs2_alloc_handle(osb);
899 if (!handle) {
900 status = -ENOMEM;
901 mlog_errno(status);
902 goto bail;
903 }
904
905 /* This will lock the main bitmap for us. */ 888 /* This will lock the main bitmap for us. */
906 status = ocfs2_local_alloc_reserve_for_window(osb, 889 status = ocfs2_local_alloc_reserve_for_window(osb,
907 handle,
908 &ac, 890 &ac,
909 &main_bm_inode, 891 &main_bm_inode,
910 &main_bm_bh); 892 &main_bm_bh);
@@ -914,7 +896,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
914 goto bail; 896 goto bail;
915 } 897 }
916 898
917 handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); 899 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS);
918 if (IS_ERR(handle)) { 900 if (IS_ERR(handle)) {
919 status = PTR_ERR(handle); 901 status = PTR_ERR(handle);
920 handle = NULL; 902 handle = NULL;
@@ -972,7 +954,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
972 status = 0; 954 status = 0;
973bail: 955bail:
974 if (handle) 956 if (handle)
975 ocfs2_commit_trans(handle); 957 ocfs2_commit_trans(osb, handle);
976 958
977 if (main_bm_bh) 959 if (main_bm_bh)
978 brelse(main_bm_bh); 960 brelse(main_bm_bh);
diff --git a/fs/ocfs2/localalloc.h b/fs/ocfs2/localalloc.h
index 30f88ce14e46..385a10152f9c 100644
--- a/fs/ocfs2/localalloc.h
+++ b/fs/ocfs2/localalloc.h
@@ -42,12 +42,11 @@ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb,
42 42
43struct ocfs2_alloc_context; 43struct ocfs2_alloc_context;
44int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, 44int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
45 struct ocfs2_journal_handle *passed_handle,
46 u32 bits_wanted, 45 u32 bits_wanted,
47 struct ocfs2_alloc_context *ac); 46 struct ocfs2_alloc_context *ac);
48 47
49int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 48int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
50 struct ocfs2_journal_handle *handle, 49 handle_t *handle,
51 struct ocfs2_alloc_context *ac, 50 struct ocfs2_alloc_context *ac,
52 u32 min_bits, 51 u32 min_bits,
53 u32 *bit_off, 52 u32 *bit_off,
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index 83934e33e5b0..69f85ae392dc 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -82,6 +82,8 @@ static struct vm_operations_struct ocfs2_file_vm_ops = {
82 82
83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) 83int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
84{ 84{
85 int ret = 0, lock_level = 0;
86
85 /* We don't want to support shared writable mappings yet. */ 87 /* We don't want to support shared writable mappings yet. */
86 if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) 88 if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE))
87 && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { 89 && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) {
@@ -91,7 +93,14 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma)
91 return -EINVAL; 93 return -EINVAL;
92 } 94 }
93 95
94 file_accessed(file); 96 ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode,
97 file->f_vfsmnt, &lock_level);
98 if (ret < 0) {
99 mlog_errno(ret);
100 goto out;
101 }
102 ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level);
103out:
95 vma->vm_ops = &ocfs2_file_vm_ops; 104 vma->vm_ops = &ocfs2_file_vm_ops;
96 return 0; 105 return 0;
97} 106}
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index a57b751d4f40..21db45ddf144 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -75,12 +75,12 @@ static int inline ocfs2_search_dirblock(struct buffer_head *bh,
75 unsigned long offset, 75 unsigned long offset,
76 struct ocfs2_dir_entry **res_dir); 76 struct ocfs2_dir_entry **res_dir);
77 77
78static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, 78static int ocfs2_delete_entry(handle_t *handle,
79 struct inode *dir, 79 struct inode *dir,
80 struct ocfs2_dir_entry *de_del, 80 struct ocfs2_dir_entry *de_del,
81 struct buffer_head *bh); 81 struct buffer_head *bh);
82 82
83static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, 83static int __ocfs2_add_entry(handle_t *handle,
84 struct inode *dir, 84 struct inode *dir,
85 const char *name, int namelen, 85 const char *name, int namelen,
86 struct inode *inode, u64 blkno, 86 struct inode *inode, u64 blkno,
@@ -93,43 +93,37 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
93 dev_t dev, 93 dev_t dev,
94 struct buffer_head **new_fe_bh, 94 struct buffer_head **new_fe_bh,
95 struct buffer_head *parent_fe_bh, 95 struct buffer_head *parent_fe_bh,
96 struct ocfs2_journal_handle *handle, 96 handle_t *handle,
97 struct inode **ret_inode, 97 struct inode **ret_inode,
98 struct ocfs2_alloc_context *inode_ac); 98 struct ocfs2_alloc_context *inode_ac);
99 99
100static int ocfs2_fill_new_dir(struct ocfs2_super *osb, 100static int ocfs2_fill_new_dir(struct ocfs2_super *osb,
101 struct ocfs2_journal_handle *handle, 101 handle_t *handle,
102 struct inode *parent, 102 struct inode *parent,
103 struct inode *inode, 103 struct inode *inode,
104 struct buffer_head *fe_bh, 104 struct buffer_head *fe_bh,
105 struct ocfs2_alloc_context *data_ac); 105 struct ocfs2_alloc_context *data_ac);
106 106
107static int ocfs2_double_lock(struct ocfs2_super *osb,
108 struct ocfs2_journal_handle *handle,
109 struct buffer_head **bh1,
110 struct inode *inode1,
111 struct buffer_head **bh2,
112 struct inode *inode2);
113
114static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, 107static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
115 struct ocfs2_journal_handle *handle, 108 struct inode **ret_orphan_dir,
116 struct inode *inode, 109 struct inode *inode,
117 char *name, 110 char *name,
118 struct buffer_head **de_bh); 111 struct buffer_head **de_bh);
119 112
120static int ocfs2_orphan_add(struct ocfs2_super *osb, 113static int ocfs2_orphan_add(struct ocfs2_super *osb,
121 struct ocfs2_journal_handle *handle, 114 handle_t *handle,
122 struct inode *inode, 115 struct inode *inode,
123 struct ocfs2_dinode *fe, 116 struct ocfs2_dinode *fe,
124 char *name, 117 char *name,
125 struct buffer_head *de_bh); 118 struct buffer_head *de_bh,
119 struct inode *orphan_dir_inode);
126 120
127static int ocfs2_create_symlink_data(struct ocfs2_super *osb, 121static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
128 struct ocfs2_journal_handle *handle, 122 handle_t *handle,
129 struct inode *inode, 123 struct inode *inode,
130 const char *symname); 124 const char *symname);
131 125
132static inline int ocfs2_add_entry(struct ocfs2_journal_handle *handle, 126static inline int ocfs2_add_entry(handle_t *handle,
133 struct dentry *dentry, 127 struct dentry *dentry,
134 struct inode *inode, u64 blkno, 128 struct inode *inode, u64 blkno,
135 struct buffer_head *parent_fe_bh, 129 struct buffer_head *parent_fe_bh,
@@ -165,7 +159,7 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry,
165 mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len, 159 mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len,
166 dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno); 160 dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno);
167 161
168 status = ocfs2_meta_lock(dir, NULL, NULL, 0); 162 status = ocfs2_meta_lock(dir, NULL, 0);
169 if (status < 0) { 163 if (status < 0) {
170 if (status != -ENOENT) 164 if (status != -ENOENT)
171 mlog_errno(status); 165 mlog_errno(status);
@@ -242,7 +236,7 @@ bail:
242} 236}
243 237
244static int ocfs2_fill_new_dir(struct ocfs2_super *osb, 238static int ocfs2_fill_new_dir(struct ocfs2_super *osb,
245 struct ocfs2_journal_handle *handle, 239 handle_t *handle,
246 struct inode *parent, 240 struct inode *parent,
247 struct inode *inode, 241 struct inode *inode,
248 struct buffer_head *fe_bh, 242 struct buffer_head *fe_bh,
@@ -317,7 +311,7 @@ static int ocfs2_mknod(struct inode *dir,
317{ 311{
318 int status = 0; 312 int status = 0;
319 struct buffer_head *parent_fe_bh = NULL; 313 struct buffer_head *parent_fe_bh = NULL;
320 struct ocfs2_journal_handle *handle = NULL; 314 handle_t *handle = NULL;
321 struct ocfs2_super *osb; 315 struct ocfs2_super *osb;
322 struct ocfs2_dinode *dirfe; 316 struct ocfs2_dinode *dirfe;
323 struct buffer_head *new_fe_bh = NULL; 317 struct buffer_head *new_fe_bh = NULL;
@@ -333,18 +327,11 @@ static int ocfs2_mknod(struct inode *dir,
333 /* get our super block */ 327 /* get our super block */
334 osb = OCFS2_SB(dir->i_sb); 328 osb = OCFS2_SB(dir->i_sb);
335 329
336 handle = ocfs2_alloc_handle(osb); 330 status = ocfs2_meta_lock(dir, &parent_fe_bh, 1);
337 if (handle == NULL) {
338 status = -ENOMEM;
339 mlog_errno(status);
340 goto leave;
341 }
342
343 status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1);
344 if (status < 0) { 331 if (status < 0) {
345 if (status != -ENOENT) 332 if (status != -ENOENT)
346 mlog_errno(status); 333 mlog_errno(status);
347 goto leave; 334 return status;
348 } 335 }
349 336
350 if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) { 337 if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) {
@@ -374,7 +361,7 @@ static int ocfs2_mknod(struct inode *dir,
374 } 361 }
375 362
376 /* reserve an inode spot */ 363 /* reserve an inode spot */
377 status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); 364 status = ocfs2_reserve_new_inode(osb, &inode_ac);
378 if (status < 0) { 365 if (status < 0) {
379 if (status != -ENOSPC) 366 if (status != -ENOSPC)
380 mlog_errno(status); 367 mlog_errno(status);
@@ -384,7 +371,7 @@ static int ocfs2_mknod(struct inode *dir,
384 /* are we making a directory? If so, reserve a cluster for his 371 /* are we making a directory? If so, reserve a cluster for his
385 * 1st extent. */ 372 * 1st extent. */
386 if (S_ISDIR(mode)) { 373 if (S_ISDIR(mode)) {
387 status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); 374 status = ocfs2_reserve_clusters(osb, 1, &data_ac);
388 if (status < 0) { 375 if (status < 0) {
389 if (status != -ENOSPC) 376 if (status != -ENOSPC)
390 mlog_errno(status); 377 mlog_errno(status);
@@ -392,7 +379,7 @@ static int ocfs2_mknod(struct inode *dir,
392 } 379 }
393 } 380 }
394 381
395 handle = ocfs2_start_trans(osb, handle, OCFS2_MKNOD_CREDITS); 382 handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS);
396 if (IS_ERR(handle)) { 383 if (IS_ERR(handle)) {
397 status = PTR_ERR(handle); 384 status = PTR_ERR(handle);
398 handle = NULL; 385 handle = NULL;
@@ -453,7 +440,9 @@ static int ocfs2_mknod(struct inode *dir,
453 status = 0; 440 status = 0;
454leave: 441leave:
455 if (handle) 442 if (handle)
456 ocfs2_commit_trans(handle); 443 ocfs2_commit_trans(osb, handle);
444
445 ocfs2_meta_unlock(dir, 1);
457 446
458 if (status == -ENOSPC) 447 if (status == -ENOSPC)
459 mlog(0, "Disk is full\n"); 448 mlog(0, "Disk is full\n");
@@ -487,7 +476,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
487 dev_t dev, 476 dev_t dev,
488 struct buffer_head **new_fe_bh, 477 struct buffer_head **new_fe_bh,
489 struct buffer_head *parent_fe_bh, 478 struct buffer_head *parent_fe_bh,
490 struct ocfs2_journal_handle *handle, 479 handle_t *handle,
491 struct inode **ret_inode, 480 struct inode **ret_inode,
492 struct ocfs2_alloc_context *inode_ac) 481 struct ocfs2_alloc_context *inode_ac)
493{ 482{
@@ -653,7 +642,7 @@ static int ocfs2_link(struct dentry *old_dentry,
653 struct inode *dir, 642 struct inode *dir,
654 struct dentry *dentry) 643 struct dentry *dentry)
655{ 644{
656 struct ocfs2_journal_handle *handle = NULL; 645 handle_t *handle;
657 struct inode *inode = old_dentry->d_inode; 646 struct inode *inode = old_dentry->d_inode;
658 int err; 647 int err;
659 struct buffer_head *fe_bh = NULL; 648 struct buffer_head *fe_bh = NULL;
@@ -666,68 +655,60 @@ static int ocfs2_link(struct dentry *old_dentry,
666 old_dentry->d_name.len, old_dentry->d_name.name, 655 old_dentry->d_name.len, old_dentry->d_name.name,
667 dentry->d_name.len, dentry->d_name.name); 656 dentry->d_name.len, dentry->d_name.name);
668 657
669 if (S_ISDIR(inode->i_mode)) { 658 if (S_ISDIR(inode->i_mode))
670 err = -EPERM; 659 return -EPERM;
671 goto bail;
672 }
673
674 handle = ocfs2_alloc_handle(osb);
675 if (handle == NULL) {
676 err = -ENOMEM;
677 goto bail;
678 }
679 660
680 err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); 661 err = ocfs2_meta_lock(dir, &parent_fe_bh, 1);
681 if (err < 0) { 662 if (err < 0) {
682 if (err != -ENOENT) 663 if (err != -ENOENT)
683 mlog_errno(err); 664 mlog_errno(err);
684 goto bail; 665 return err;
685 } 666 }
686 667
687 if (!dir->i_nlink) { 668 if (!dir->i_nlink) {
688 err = -ENOENT; 669 err = -ENOENT;
689 goto bail; 670 goto out;
690 } 671 }
691 672
692 err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, 673 err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name,
693 dentry->d_name.len); 674 dentry->d_name.len);
694 if (err) 675 if (err)
695 goto bail; 676 goto out;
696 677
697 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, 678 err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh,
698 dentry->d_name.name, 679 dentry->d_name.name,
699 dentry->d_name.len, &de_bh); 680 dentry->d_name.len, &de_bh);
700 if (err < 0) { 681 if (err < 0) {
701 mlog_errno(err); 682 mlog_errno(err);
702 goto bail; 683 goto out;
703 } 684 }
704 685
705 err = ocfs2_meta_lock(inode, handle, &fe_bh, 1); 686 err = ocfs2_meta_lock(inode, &fe_bh, 1);
706 if (err < 0) { 687 if (err < 0) {
707 if (err != -ENOENT) 688 if (err != -ENOENT)
708 mlog_errno(err); 689 mlog_errno(err);
709 goto bail; 690 goto out;
710 } 691 }
711 692
712 fe = (struct ocfs2_dinode *) fe_bh->b_data; 693 fe = (struct ocfs2_dinode *) fe_bh->b_data;
713 if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { 694 if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) {
714 err = -EMLINK; 695 err = -EMLINK;
715 goto bail; 696 goto out_unlock_inode;
716 } 697 }
717 698
718 handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS); 699 handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS);
719 if (IS_ERR(handle)) { 700 if (IS_ERR(handle)) {
720 err = PTR_ERR(handle); 701 err = PTR_ERR(handle);
721 handle = NULL; 702 handle = NULL;
722 mlog_errno(err); 703 mlog_errno(err);
723 goto bail; 704 goto out_unlock_inode;
724 } 705 }
725 706
726 err = ocfs2_journal_access(handle, inode, fe_bh, 707 err = ocfs2_journal_access(handle, inode, fe_bh,
727 OCFS2_JOURNAL_ACCESS_WRITE); 708 OCFS2_JOURNAL_ACCESS_WRITE);
728 if (err < 0) { 709 if (err < 0) {
729 mlog_errno(err); 710 mlog_errno(err);
730 goto bail; 711 goto out_commit;
731 } 712 }
732 713
733 inc_nlink(inode); 714 inc_nlink(inode);
@@ -741,7 +722,7 @@ static int ocfs2_link(struct dentry *old_dentry,
741 le16_add_cpu(&fe->i_links_count, -1); 722 le16_add_cpu(&fe->i_links_count, -1);
742 drop_nlink(inode); 723 drop_nlink(inode);
743 mlog_errno(err); 724 mlog_errno(err);
744 goto bail; 725 goto out_commit;
745 } 726 }
746 727
747 err = ocfs2_add_entry(handle, dentry, inode, 728 err = ocfs2_add_entry(handle, dentry, inode,
@@ -751,21 +732,27 @@ static int ocfs2_link(struct dentry *old_dentry,
751 le16_add_cpu(&fe->i_links_count, -1); 732 le16_add_cpu(&fe->i_links_count, -1);
752 drop_nlink(inode); 733 drop_nlink(inode);
753 mlog_errno(err); 734 mlog_errno(err);
754 goto bail; 735 goto out_commit;
755 } 736 }
756 737
757 err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); 738 err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno);
758 if (err) { 739 if (err) {
759 mlog_errno(err); 740 mlog_errno(err);
760 goto bail; 741 goto out_commit;
761 } 742 }
762 743
763 atomic_inc(&inode->i_count); 744 atomic_inc(&inode->i_count);
764 dentry->d_op = &ocfs2_dentry_ops; 745 dentry->d_op = &ocfs2_dentry_ops;
765 d_instantiate(dentry, inode); 746 d_instantiate(dentry, inode);
766bail: 747
767 if (handle) 748out_commit:
768 ocfs2_commit_trans(handle); 749 ocfs2_commit_trans(osb, handle);
750out_unlock_inode:
751 ocfs2_meta_unlock(inode, 1);
752
753out:
754 ocfs2_meta_unlock(dir, 1);
755
769 if (de_bh) 756 if (de_bh)
770 brelse(de_bh); 757 brelse(de_bh);
771 if (fe_bh) 758 if (fe_bh)
@@ -812,13 +799,15 @@ static int ocfs2_unlink(struct inode *dir,
812 struct dentry *dentry) 799 struct dentry *dentry)
813{ 800{
814 int status; 801 int status;
802 int child_locked = 0;
815 struct inode *inode = dentry->d_inode; 803 struct inode *inode = dentry->d_inode;
804 struct inode *orphan_dir = NULL;
816 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); 805 struct ocfs2_super *osb = OCFS2_SB(dir->i_sb);
817 u64 blkno; 806 u64 blkno;
818 struct ocfs2_dinode *fe = NULL; 807 struct ocfs2_dinode *fe = NULL;
819 struct buffer_head *fe_bh = NULL; 808 struct buffer_head *fe_bh = NULL;
820 struct buffer_head *parent_node_bh = NULL; 809 struct buffer_head *parent_node_bh = NULL;
821 struct ocfs2_journal_handle *handle = NULL; 810 handle_t *handle = NULL;
822 struct ocfs2_dir_entry *dirent = NULL; 811 struct ocfs2_dir_entry *dirent = NULL;
823 struct buffer_head *dirent_bh = NULL; 812 struct buffer_head *dirent_bh = NULL;
824 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; 813 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
@@ -833,22 +822,14 @@ static int ocfs2_unlink(struct inode *dir,
833 822
834 if (inode == osb->root_inode) { 823 if (inode == osb->root_inode) {
835 mlog(0, "Cannot delete the root directory\n"); 824 mlog(0, "Cannot delete the root directory\n");
836 status = -EPERM; 825 return -EPERM;
837 goto leave;
838 } 826 }
839 827
840 handle = ocfs2_alloc_handle(osb); 828 status = ocfs2_meta_lock(dir, &parent_node_bh, 1);
841 if (handle == NULL) {
842 status = -ENOMEM;
843 mlog_errno(status);
844 goto leave;
845 }
846
847 status = ocfs2_meta_lock(dir, handle, &parent_node_bh, 1);
848 if (status < 0) { 829 if (status < 0) {
849 if (status != -ENOENT) 830 if (status != -ENOENT)
850 mlog_errno(status); 831 mlog_errno(status);
851 goto leave; 832 return status;
852 } 833 }
853 834
854 status = ocfs2_find_files_on_disk(dentry->d_name.name, 835 status = ocfs2_find_files_on_disk(dentry->d_name.name,
@@ -869,12 +850,13 @@ static int ocfs2_unlink(struct inode *dir,
869 goto leave; 850 goto leave;
870 } 851 }
871 852
872 status = ocfs2_meta_lock(inode, handle, &fe_bh, 1); 853 status = ocfs2_meta_lock(inode, &fe_bh, 1);
873 if (status < 0) { 854 if (status < 0) {
874 if (status != -ENOENT) 855 if (status != -ENOENT)
875 mlog_errno(status); 856 mlog_errno(status);
876 goto leave; 857 goto leave;
877 } 858 }
859 child_locked = 1;
878 860
879 if (S_ISDIR(inode->i_mode)) { 861 if (S_ISDIR(inode->i_mode)) {
880 if (!ocfs2_empty_dir(inode)) { 862 if (!ocfs2_empty_dir(inode)) {
@@ -895,7 +877,7 @@ static int ocfs2_unlink(struct inode *dir,
895 } 877 }
896 878
897 if (inode_is_unlinkable(inode)) { 879 if (inode_is_unlinkable(inode)) {
898 status = ocfs2_prepare_orphan_dir(osb, handle, inode, 880 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode,
899 orphan_name, 881 orphan_name,
900 &orphan_entry_bh); 882 &orphan_entry_bh);
901 if (status < 0) { 883 if (status < 0) {
@@ -904,7 +886,7 @@ static int ocfs2_unlink(struct inode *dir,
904 } 886 }
905 } 887 }
906 888
907 handle = ocfs2_start_trans(osb, handle, OCFS2_UNLINK_CREDITS); 889 handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS);
908 if (IS_ERR(handle)) { 890 if (IS_ERR(handle)) {
909 status = PTR_ERR(handle); 891 status = PTR_ERR(handle);
910 handle = NULL; 892 handle = NULL;
@@ -923,7 +905,7 @@ static int ocfs2_unlink(struct inode *dir,
923 905
924 if (inode_is_unlinkable(inode)) { 906 if (inode_is_unlinkable(inode)) {
925 status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, 907 status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name,
926 orphan_entry_bh); 908 orphan_entry_bh, orphan_dir);
927 if (status < 0) { 909 if (status < 0) {
928 mlog_errno(status); 910 mlog_errno(status);
929 goto leave; 911 goto leave;
@@ -960,7 +942,19 @@ static int ocfs2_unlink(struct inode *dir,
960 942
961leave: 943leave:
962 if (handle) 944 if (handle)
963 ocfs2_commit_trans(handle); 945 ocfs2_commit_trans(osb, handle);
946
947 if (child_locked)
948 ocfs2_meta_unlock(inode, 1);
949
950 ocfs2_meta_unlock(dir, 1);
951
952 if (orphan_dir) {
953 /* This was locked for us in ocfs2_prepare_orphan_dir() */
954 ocfs2_meta_unlock(orphan_dir, 1);
955 mutex_unlock(&orphan_dir->i_mutex);
956 iput(orphan_dir);
957 }
964 958
965 if (fe_bh) 959 if (fe_bh)
966 brelse(fe_bh); 960 brelse(fe_bh);
@@ -984,7 +978,6 @@ leave:
984 * if they have the same id, then the 1st one is the only one locked. 978 * if they have the same id, then the 1st one is the only one locked.
985 */ 979 */
986static int ocfs2_double_lock(struct ocfs2_super *osb, 980static int ocfs2_double_lock(struct ocfs2_super *osb,
987 struct ocfs2_journal_handle *handle,
988 struct buffer_head **bh1, 981 struct buffer_head **bh1,
989 struct inode *inode1, 982 struct inode *inode1,
990 struct buffer_head **bh2, 983 struct buffer_head **bh2,
@@ -1000,8 +993,6 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
1000 (unsigned long long)oi1->ip_blkno, 993 (unsigned long long)oi1->ip_blkno,
1001 (unsigned long long)oi2->ip_blkno); 994 (unsigned long long)oi2->ip_blkno);
1002 995
1003 BUG_ON(!handle);
1004
1005 if (*bh1) 996 if (*bh1)
1006 *bh1 = NULL; 997 *bh1 = NULL;
1007 if (*bh2) 998 if (*bh2)
@@ -1021,25 +1012,41 @@ static int ocfs2_double_lock(struct ocfs2_super *osb,
1021 inode1 = tmpinode; 1012 inode1 = tmpinode;
1022 } 1013 }
1023 /* lock id2 */ 1014 /* lock id2 */
1024 status = ocfs2_meta_lock(inode2, handle, bh2, 1); 1015 status = ocfs2_meta_lock(inode2, bh2, 1);
1025 if (status < 0) { 1016 if (status < 0) {
1026 if (status != -ENOENT) 1017 if (status != -ENOENT)
1027 mlog_errno(status); 1018 mlog_errno(status);
1028 goto bail; 1019 goto bail;
1029 } 1020 }
1030 } 1021 }
1022
1031 /* lock id1 */ 1023 /* lock id1 */
1032 status = ocfs2_meta_lock(inode1, handle, bh1, 1); 1024 status = ocfs2_meta_lock(inode1, bh1, 1);
1033 if (status < 0) { 1025 if (status < 0) {
1026 /*
1027 * An error return must mean that no cluster locks
1028 * were held on function exit.
1029 */
1030 if (oi1->ip_blkno != oi2->ip_blkno)
1031 ocfs2_meta_unlock(inode2, 1);
1032
1034 if (status != -ENOENT) 1033 if (status != -ENOENT)
1035 mlog_errno(status); 1034 mlog_errno(status);
1036 goto bail;
1037 } 1035 }
1036
1038bail: 1037bail:
1039 mlog_exit(status); 1038 mlog_exit(status);
1040 return status; 1039 return status;
1041} 1040}
1042 1041
1042static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
1043{
1044 ocfs2_meta_unlock(inode1, 1);
1045
1046 if (inode1 != inode2)
1047 ocfs2_meta_unlock(inode2, 1);
1048}
1049
1043#define PARENT_INO(buffer) \ 1050#define PARENT_INO(buffer) \
1044 ((struct ocfs2_dir_entry *) \ 1051 ((struct ocfs2_dir_entry *) \
1045 ((char *)buffer + \ 1052 ((char *)buffer + \
@@ -1050,9 +1057,11 @@ static int ocfs2_rename(struct inode *old_dir,
1050 struct inode *new_dir, 1057 struct inode *new_dir,
1051 struct dentry *new_dentry) 1058 struct dentry *new_dentry)
1052{ 1059{
1053 int status = 0, rename_lock = 0; 1060 int status = 0, rename_lock = 0, parents_locked = 0;
1061 int old_child_locked = 0, new_child_locked = 0;
1054 struct inode *old_inode = old_dentry->d_inode; 1062 struct inode *old_inode = old_dentry->d_inode;
1055 struct inode *new_inode = new_dentry->d_inode; 1063 struct inode *new_inode = new_dentry->d_inode;
1064 struct inode *orphan_dir = NULL;
1056 struct ocfs2_dinode *newfe = NULL; 1065 struct ocfs2_dinode *newfe = NULL;
1057 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; 1066 char orphan_name[OCFS2_ORPHAN_NAMELEN + 1];
1058 struct buffer_head *orphan_entry_bh = NULL; 1067 struct buffer_head *orphan_entry_bh = NULL;
@@ -1060,7 +1069,7 @@ static int ocfs2_rename(struct inode *old_dir,
1060 struct buffer_head *insert_entry_bh = NULL; 1069 struct buffer_head *insert_entry_bh = NULL;
1061 struct ocfs2_super *osb = NULL; 1070 struct ocfs2_super *osb = NULL;
1062 u64 newfe_blkno; 1071 u64 newfe_blkno;
1063 struct ocfs2_journal_handle *handle = NULL; 1072 handle_t *handle = NULL;
1064 struct buffer_head *old_dir_bh = NULL; 1073 struct buffer_head *old_dir_bh = NULL;
1065 struct buffer_head *new_dir_bh = NULL; 1074 struct buffer_head *new_dir_bh = NULL;
1066 struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry 1075 struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry
@@ -1105,21 +1114,14 @@ static int ocfs2_rename(struct inode *old_dir,
1105 rename_lock = 1; 1114 rename_lock = 1;
1106 } 1115 }
1107 1116
1108 handle = ocfs2_alloc_handle(osb);
1109 if (handle == NULL) {
1110 status = -ENOMEM;
1111 mlog_errno(status);
1112 goto bail;
1113 }
1114
1115 /* if old and new are the same, this'll just do one lock. */ 1117 /* if old and new are the same, this'll just do one lock. */
1116 status = ocfs2_double_lock(osb, handle, 1118 status = ocfs2_double_lock(osb, &old_dir_bh, old_dir,
1117 &old_dir_bh, old_dir, 1119 &new_dir_bh, new_dir);
1118 &new_dir_bh, new_dir);
1119 if (status < 0) { 1120 if (status < 0) {
1120 mlog_errno(status); 1121 mlog_errno(status);
1121 goto bail; 1122 goto bail;
1122 } 1123 }
1124 parents_locked = 1;
1123 1125
1124 /* make sure both dirs have bhs 1126 /* make sure both dirs have bhs
1125 * get an extra ref on old_dir_bh if old==new */ 1127 * get an extra ref on old_dir_bh if old==new */
@@ -1140,12 +1142,13 @@ static int ocfs2_rename(struct inode *old_dir,
1140 * the vote thread on other nodes won't have to concurrently 1142 * the vote thread on other nodes won't have to concurrently
1141 * downconvert the inode and the dentry locks. 1143 * downconvert the inode and the dentry locks.
1142 */ 1144 */
1143 status = ocfs2_meta_lock(old_inode, handle, NULL, 1); 1145 status = ocfs2_meta_lock(old_inode, NULL, 1);
1144 if (status < 0) { 1146 if (status < 0) {
1145 if (status != -ENOENT) 1147 if (status != -ENOENT)
1146 mlog_errno(status); 1148 mlog_errno(status);
1147 goto bail; 1149 goto bail;
1148 } 1150 }
1151 old_child_locked = 1;
1149 1152
1150 status = ocfs2_remote_dentry_delete(old_dentry); 1153 status = ocfs2_remote_dentry_delete(old_dentry);
1151 if (status < 0) { 1154 if (status < 0) {
@@ -1231,12 +1234,13 @@ static int ocfs2_rename(struct inode *old_dir,
1231 goto bail; 1234 goto bail;
1232 } 1235 }
1233 1236
1234 status = ocfs2_meta_lock(new_inode, handle, &newfe_bh, 1); 1237 status = ocfs2_meta_lock(new_inode, &newfe_bh, 1);
1235 if (status < 0) { 1238 if (status < 0) {
1236 if (status != -ENOENT) 1239 if (status != -ENOENT)
1237 mlog_errno(status); 1240 mlog_errno(status);
1238 goto bail; 1241 goto bail;
1239 } 1242 }
1243 new_child_locked = 1;
1240 1244
1241 status = ocfs2_remote_dentry_delete(new_dentry); 1245 status = ocfs2_remote_dentry_delete(new_dentry);
1242 if (status < 0) { 1246 if (status < 0) {
@@ -1252,7 +1256,7 @@ static int ocfs2_rename(struct inode *old_dir,
1252 (unsigned long long)newfe_bh->b_blocknr : 0ULL); 1256 (unsigned long long)newfe_bh->b_blocknr : 0ULL);
1253 1257
1254 if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { 1258 if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) {
1255 status = ocfs2_prepare_orphan_dir(osb, handle, 1259 status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
1256 new_inode, 1260 new_inode,
1257 orphan_name, 1261 orphan_name,
1258 &orphan_entry_bh); 1262 &orphan_entry_bh);
@@ -1280,7 +1284,7 @@ static int ocfs2_rename(struct inode *old_dir,
1280 } 1284 }
1281 } 1285 }
1282 1286
1283 handle = ocfs2_start_trans(osb, handle, OCFS2_RENAME_CREDITS); 1287 handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS);
1284 if (IS_ERR(handle)) { 1288 if (IS_ERR(handle)) {
1285 status = PTR_ERR(handle); 1289 status = PTR_ERR(handle);
1286 handle = NULL; 1290 handle = NULL;
@@ -1307,7 +1311,7 @@ static int ocfs2_rename(struct inode *old_dir,
1307 (newfe->i_links_count == cpu_to_le16(1))){ 1311 (newfe->i_links_count == cpu_to_le16(1))){
1308 status = ocfs2_orphan_add(osb, handle, new_inode, 1312 status = ocfs2_orphan_add(osb, handle, new_inode,
1309 newfe, orphan_name, 1313 newfe, orphan_name,
1310 orphan_entry_bh); 1314 orphan_entry_bh, orphan_dir);
1311 if (status < 0) { 1315 if (status < 0) {
1312 mlog_errno(status); 1316 mlog_errno(status);
1313 goto bail; 1317 goto bail;
@@ -1424,7 +1428,23 @@ bail:
1424 ocfs2_rename_unlock(osb); 1428 ocfs2_rename_unlock(osb);
1425 1429
1426 if (handle) 1430 if (handle)
1427 ocfs2_commit_trans(handle); 1431 ocfs2_commit_trans(osb, handle);
1432
1433 if (parents_locked)
1434 ocfs2_double_unlock(old_dir, new_dir);
1435
1436 if (old_child_locked)
1437 ocfs2_meta_unlock(old_inode, 1);
1438
1439 if (new_child_locked)
1440 ocfs2_meta_unlock(new_inode, 1);
1441
1442 if (orphan_dir) {
1443 /* This was locked for us in ocfs2_prepare_orphan_dir() */
1444 ocfs2_meta_unlock(orphan_dir, 1);
1445 mutex_unlock(&orphan_dir->i_mutex);
1446 iput(orphan_dir);
1447 }
1428 1448
1429 if (new_inode) 1449 if (new_inode)
1430 sync_mapping_buffers(old_inode->i_mapping); 1450 sync_mapping_buffers(old_inode->i_mapping);
@@ -1458,7 +1478,7 @@ bail:
1458 * data, including the null terminator. 1478 * data, including the null terminator.
1459 */ 1479 */
1460static int ocfs2_create_symlink_data(struct ocfs2_super *osb, 1480static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
1461 struct ocfs2_journal_handle *handle, 1481 handle_t *handle,
1462 struct inode *inode, 1482 struct inode *inode,
1463 const char *symname) 1483 const char *symname)
1464{ 1484{
@@ -1573,7 +1593,7 @@ static int ocfs2_symlink(struct inode *dir,
1573 struct buffer_head *parent_fe_bh = NULL; 1593 struct buffer_head *parent_fe_bh = NULL;
1574 struct ocfs2_dinode *fe = NULL; 1594 struct ocfs2_dinode *fe = NULL;
1575 struct ocfs2_dinode *dirfe; 1595 struct ocfs2_dinode *dirfe;
1576 struct ocfs2_journal_handle *handle = NULL; 1596 handle_t *handle = NULL;
1577 struct ocfs2_alloc_context *inode_ac = NULL; 1597 struct ocfs2_alloc_context *inode_ac = NULL;
1578 struct ocfs2_alloc_context *data_ac = NULL; 1598 struct ocfs2_alloc_context *data_ac = NULL;
1579 1599
@@ -1587,19 +1607,12 @@ static int ocfs2_symlink(struct inode *dir,
1587 1607
1588 credits = ocfs2_calc_symlink_credits(sb); 1608 credits = ocfs2_calc_symlink_credits(sb);
1589 1609
1590 handle = ocfs2_alloc_handle(osb);
1591 if (handle == NULL) {
1592 status = -ENOMEM;
1593 mlog_errno(status);
1594 goto bail;
1595 }
1596
1597 /* lock the parent directory */ 1610 /* lock the parent directory */
1598 status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); 1611 status = ocfs2_meta_lock(dir, &parent_fe_bh, 1);
1599 if (status < 0) { 1612 if (status < 0) {
1600 if (status != -ENOENT) 1613 if (status != -ENOENT)
1601 mlog_errno(status); 1614 mlog_errno(status);
1602 goto bail; 1615 return status;
1603 } 1616 }
1604 1617
1605 dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; 1618 dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data;
@@ -1622,7 +1635,7 @@ static int ocfs2_symlink(struct inode *dir,
1622 goto bail; 1635 goto bail;
1623 } 1636 }
1624 1637
1625 status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); 1638 status = ocfs2_reserve_new_inode(osb, &inode_ac);
1626 if (status < 0) { 1639 if (status < 0) {
1627 if (status != -ENOSPC) 1640 if (status != -ENOSPC)
1628 mlog_errno(status); 1641 mlog_errno(status);
@@ -1631,7 +1644,7 @@ static int ocfs2_symlink(struct inode *dir,
1631 1644
1632 /* don't reserve bitmap space for fast symlinks. */ 1645 /* don't reserve bitmap space for fast symlinks. */
1633 if (l > ocfs2_fast_symlink_chars(sb)) { 1646 if (l > ocfs2_fast_symlink_chars(sb)) {
1634 status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); 1647 status = ocfs2_reserve_clusters(osb, 1, &data_ac);
1635 if (status < 0) { 1648 if (status < 0) {
1636 if (status != -ENOSPC) 1649 if (status != -ENOSPC)
1637 mlog_errno(status); 1650 mlog_errno(status);
@@ -1639,7 +1652,7 @@ static int ocfs2_symlink(struct inode *dir,
1639 } 1652 }
1640 } 1653 }
1641 1654
1642 handle = ocfs2_start_trans(osb, handle, credits); 1655 handle = ocfs2_start_trans(osb, credits);
1643 if (IS_ERR(handle)) { 1656 if (IS_ERR(handle)) {
1644 status = PTR_ERR(handle); 1657 status = PTR_ERR(handle);
1645 handle = NULL; 1658 handle = NULL;
@@ -1717,7 +1730,10 @@ static int ocfs2_symlink(struct inode *dir,
1717 d_instantiate(dentry, inode); 1730 d_instantiate(dentry, inode);
1718bail: 1731bail:
1719 if (handle) 1732 if (handle)
1720 ocfs2_commit_trans(handle); 1733 ocfs2_commit_trans(osb, handle);
1734
1735 ocfs2_meta_unlock(dir, 1);
1736
1721 if (new_fe_bh) 1737 if (new_fe_bh)
1722 brelse(new_fe_bh); 1738 brelse(new_fe_bh);
1723 if (parent_fe_bh) 1739 if (parent_fe_bh)
@@ -1768,7 +1784,7 @@ int ocfs2_check_dir_entry(struct inode * dir,
1768 * If you pass me insert_bh, I'll skip the search of the other dir 1784 * If you pass me insert_bh, I'll skip the search of the other dir
1769 * blocks and put the record in there. 1785 * blocks and put the record in there.
1770 */ 1786 */
1771static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, 1787static int __ocfs2_add_entry(handle_t *handle,
1772 struct inode *dir, 1788 struct inode *dir,
1773 const char *name, int namelen, 1789 const char *name, int namelen,
1774 struct inode *inode, u64 blkno, 1790 struct inode *inode, u64 blkno,
@@ -1854,7 +1870,7 @@ bail:
1854 * ocfs2_delete_entry deletes a directory entry by merging it with the 1870 * ocfs2_delete_entry deletes a directory entry by merging it with the
1855 * previous entry 1871 * previous entry
1856 */ 1872 */
1857static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, 1873static int ocfs2_delete_entry(handle_t *handle,
1858 struct inode *dir, 1874 struct inode *dir,
1859 struct ocfs2_dir_entry *de_del, 1875 struct ocfs2_dir_entry *de_del,
1860 struct buffer_head *bh) 1876 struct buffer_head *bh)
@@ -2085,19 +2101,19 @@ bail:
2085} 2101}
2086 2102
2087static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, 2103static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
2088 struct ocfs2_journal_handle *handle, 2104 struct inode **ret_orphan_dir,
2089 struct inode *inode, 2105 struct inode *inode,
2090 char *name, 2106 char *name,
2091 struct buffer_head **de_bh) 2107 struct buffer_head **de_bh)
2092{ 2108{
2093 struct inode *orphan_dir_inode = NULL; 2109 struct inode *orphan_dir_inode;
2094 struct buffer_head *orphan_dir_bh = NULL; 2110 struct buffer_head *orphan_dir_bh = NULL;
2095 int status = 0; 2111 int status = 0;
2096 2112
2097 status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); 2113 status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name);
2098 if (status < 0) { 2114 if (status < 0) {
2099 mlog_errno(status); 2115 mlog_errno(status);
2100 goto leave; 2116 return status;
2101 } 2117 }
2102 2118
2103 orphan_dir_inode = ocfs2_get_system_file_inode(osb, 2119 orphan_dir_inode = ocfs2_get_system_file_inode(osb,
@@ -2106,11 +2122,12 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
2106 if (!orphan_dir_inode) { 2122 if (!orphan_dir_inode) {
2107 status = -ENOENT; 2123 status = -ENOENT;
2108 mlog_errno(status); 2124 mlog_errno(status);
2109 goto leave; 2125 return status;
2110 } 2126 }
2111 2127
2112 ocfs2_handle_add_inode(handle, orphan_dir_inode); 2128 mutex_lock(&orphan_dir_inode->i_mutex);
2113 status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1); 2129
2130 status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1);
2114 if (status < 0) { 2131 if (status < 0) {
2115 mlog_errno(status); 2132 mlog_errno(status);
2116 goto leave; 2133 goto leave;
@@ -2120,13 +2137,19 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb,
2120 orphan_dir_bh, name, 2137 orphan_dir_bh, name,
2121 OCFS2_ORPHAN_NAMELEN, de_bh); 2138 OCFS2_ORPHAN_NAMELEN, de_bh);
2122 if (status < 0) { 2139 if (status < 0) {
2140 ocfs2_meta_unlock(orphan_dir_inode, 1);
2141
2123 mlog_errno(status); 2142 mlog_errno(status);
2124 goto leave; 2143 goto leave;
2125 } 2144 }
2126 2145
2146 *ret_orphan_dir = orphan_dir_inode;
2147
2127leave: 2148leave:
2128 if (orphan_dir_inode) 2149 if (status) {
2150 mutex_unlock(&orphan_dir_inode->i_mutex);
2129 iput(orphan_dir_inode); 2151 iput(orphan_dir_inode);
2152 }
2130 2153
2131 if (orphan_dir_bh) 2154 if (orphan_dir_bh)
2132 brelse(orphan_dir_bh); 2155 brelse(orphan_dir_bh);
@@ -2136,28 +2159,19 @@ leave:
2136} 2159}
2137 2160
2138static int ocfs2_orphan_add(struct ocfs2_super *osb, 2161static int ocfs2_orphan_add(struct ocfs2_super *osb,
2139 struct ocfs2_journal_handle *handle, 2162 handle_t *handle,
2140 struct inode *inode, 2163 struct inode *inode,
2141 struct ocfs2_dinode *fe, 2164 struct ocfs2_dinode *fe,
2142 char *name, 2165 char *name,
2143 struct buffer_head *de_bh) 2166 struct buffer_head *de_bh,
2167 struct inode *orphan_dir_inode)
2144{ 2168{
2145 struct inode *orphan_dir_inode = NULL;
2146 struct buffer_head *orphan_dir_bh = NULL; 2169 struct buffer_head *orphan_dir_bh = NULL;
2147 int status = 0; 2170 int status = 0;
2148 struct ocfs2_dinode *orphan_fe; 2171 struct ocfs2_dinode *orphan_fe;
2149 2172
2150 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); 2173 mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino);
2151 2174
2152 orphan_dir_inode = ocfs2_get_system_file_inode(osb,
2153 ORPHAN_DIR_SYSTEM_INODE,
2154 osb->slot_num);
2155 if (!orphan_dir_inode) {
2156 status = -ENOENT;
2157 mlog_errno(status);
2158 goto leave;
2159 }
2160
2161 status = ocfs2_read_block(osb, 2175 status = ocfs2_read_block(osb,
2162 OCFS2_I(orphan_dir_inode)->ip_blkno, 2176 OCFS2_I(orphan_dir_inode)->ip_blkno,
2163 &orphan_dir_bh, OCFS2_BH_CACHED, 2177 &orphan_dir_bh, OCFS2_BH_CACHED,
@@ -2209,9 +2223,6 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb,
2209 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); 2223 (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num);
2210 2224
2211leave: 2225leave:
2212 if (orphan_dir_inode)
2213 iput(orphan_dir_inode);
2214
2215 if (orphan_dir_bh) 2226 if (orphan_dir_bh)
2216 brelse(orphan_dir_bh); 2227 brelse(orphan_dir_bh);
2217 2228
@@ -2221,7 +2232,7 @@ leave:
2221 2232
2222/* unlike orphan_add, we expect the orphan dir to already be locked here. */ 2233/* unlike orphan_add, we expect the orphan dir to already be locked here. */
2223int ocfs2_orphan_del(struct ocfs2_super *osb, 2234int ocfs2_orphan_del(struct ocfs2_super *osb,
2224 struct ocfs2_journal_handle *handle, 2235 handle_t *handle,
2225 struct inode *orphan_dir_inode, 2236 struct inode *orphan_dir_inode,
2226 struct inode *inode, 2237 struct inode *inode,
2227 struct buffer_head *orphan_dir_bh) 2238 struct buffer_head *orphan_dir_bh)
@@ -2300,4 +2311,5 @@ struct inode_operations ocfs2_dir_iops = {
2300 .rename = ocfs2_rename, 2311 .rename = ocfs2_rename,
2301 .setattr = ocfs2_setattr, 2312 .setattr = ocfs2_setattr,
2302 .getattr = ocfs2_getattr, 2313 .getattr = ocfs2_getattr,
2314 .permission = ocfs2_permission,
2303}; 2315};
diff --git a/fs/ocfs2/namei.h b/fs/ocfs2/namei.h
index deaaa97dbf0b..8425944fcccd 100644
--- a/fs/ocfs2/namei.h
+++ b/fs/ocfs2/namei.h
@@ -39,7 +39,7 @@ struct buffer_head *ocfs2_find_entry(const char *name,
39 struct inode *dir, 39 struct inode *dir,
40 struct ocfs2_dir_entry **res_dir); 40 struct ocfs2_dir_entry **res_dir);
41int ocfs2_orphan_del(struct ocfs2_super *osb, 41int ocfs2_orphan_del(struct ocfs2_super *osb,
42 struct ocfs2_journal_handle *handle, 42 handle_t *handle,
43 struct inode *orphan_dir_inode, 43 struct inode *orphan_dir_inode,
44 struct inode *inode, 44 struct inode *inode,
45 struct buffer_head *orphan_dir_bh); 45 struct buffer_head *orphan_dir_bh);
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 0462a7f4e21b..b767fd7da6eb 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -34,6 +34,7 @@
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/kref.h> 35#include <linux/kref.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/jbd.h>
37 38
38#include "cluster/nodemanager.h" 39#include "cluster/nodemanager.h"
39#include "cluster/heartbeat.h" 40#include "cluster/heartbeat.h"
@@ -179,9 +180,9 @@ enum ocfs2_mount_options
179#define OCFS2_OSB_SOFT_RO 0x0001 180#define OCFS2_OSB_SOFT_RO 0x0001
180#define OCFS2_OSB_HARD_RO 0x0002 181#define OCFS2_OSB_HARD_RO 0x0002
181#define OCFS2_OSB_ERROR_FS 0x0004 182#define OCFS2_OSB_ERROR_FS 0x0004
183#define OCFS2_DEFAULT_ATIME_QUANTUM 60
182 184
183struct ocfs2_journal; 185struct ocfs2_journal;
184struct ocfs2_journal_handle;
185struct ocfs2_super 186struct ocfs2_super
186{ 187{
187 struct task_struct *commit_task; 188 struct task_struct *commit_task;
@@ -218,6 +219,7 @@ struct ocfs2_super
218 unsigned long osb_flags; 219 unsigned long osb_flags;
219 220
220 unsigned long s_mount_opt; 221 unsigned long s_mount_opt;
222 unsigned int s_atime_quantum;
221 223
222 u16 max_slots; 224 u16 max_slots;
223 s16 node_num; 225 s16 node_num;
@@ -283,7 +285,7 @@ struct ocfs2_super
283 /* Truncate log info */ 285 /* Truncate log info */
284 struct inode *osb_tl_inode; 286 struct inode *osb_tl_inode;
285 struct buffer_head *osb_tl_bh; 287 struct buffer_head *osb_tl_bh;
286 struct work_struct osb_truncate_log_wq; 288 struct delayed_work osb_truncate_log_wq;
287 289
288 struct ocfs2_node_map osb_recovering_orphan_dirs; 290 struct ocfs2_node_map osb_recovering_orphan_dirs;
289 unsigned int *osb_orphan_wipes; 291 unsigned int *osb_orphan_wipes;
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 9d91e66f51a9..000d71cca6c5 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -49,7 +49,7 @@
49static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); 49static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
50static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); 50static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
51static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); 51static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
52static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, 52static int ocfs2_block_group_fill(handle_t *handle,
53 struct inode *alloc_inode, 53 struct inode *alloc_inode,
54 struct buffer_head *bg_bh, 54 struct buffer_head *bg_bh,
55 u64 group_blkno, 55 u64 group_blkno,
@@ -59,9 +59,6 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
59 struct inode *alloc_inode, 59 struct inode *alloc_inode,
60 struct buffer_head *bh); 60 struct buffer_head *bh);
61 61
62static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
63 struct ocfs2_alloc_context *ac);
64
65static int ocfs2_cluster_group_search(struct inode *inode, 62static int ocfs2_cluster_group_search(struct inode *inode,
66 struct buffer_head *group_bh, 63 struct buffer_head *group_bh,
67 u32 bits_wanted, u32 min_bits, 64 u32 bits_wanted, u32 min_bits,
@@ -72,6 +69,7 @@ static int ocfs2_block_group_search(struct inode *inode,
72 u16 *bit_off, u16 *bits_found); 69 u16 *bit_off, u16 *bits_found);
73static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, 70static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
74 struct ocfs2_alloc_context *ac, 71 struct ocfs2_alloc_context *ac,
72 handle_t *handle,
75 u32 bits_wanted, 73 u32 bits_wanted,
76 u32 min_bits, 74 u32 min_bits,
77 u16 *bit_off, 75 u16 *bit_off,
@@ -79,20 +77,20 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
79 u64 *bg_blkno); 77 u64 *bg_blkno);
80static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, 78static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
81 int nr); 79 int nr);
82static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, 80static inline int ocfs2_block_group_set_bits(handle_t *handle,
83 struct inode *alloc_inode, 81 struct inode *alloc_inode,
84 struct ocfs2_group_desc *bg, 82 struct ocfs2_group_desc *bg,
85 struct buffer_head *group_bh, 83 struct buffer_head *group_bh,
86 unsigned int bit_off, 84 unsigned int bit_off,
87 unsigned int num_bits); 85 unsigned int num_bits);
88static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, 86static inline int ocfs2_block_group_clear_bits(handle_t *handle,
89 struct inode *alloc_inode, 87 struct inode *alloc_inode,
90 struct ocfs2_group_desc *bg, 88 struct ocfs2_group_desc *bg,
91 struct buffer_head *group_bh, 89 struct buffer_head *group_bh,
92 unsigned int bit_off, 90 unsigned int bit_off,
93 unsigned int num_bits); 91 unsigned int num_bits);
94 92
95static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, 93static int ocfs2_relink_block_group(handle_t *handle,
96 struct inode *alloc_inode, 94 struct inode *alloc_inode,
97 struct buffer_head *fe_bh, 95 struct buffer_head *fe_bh,
98 struct buffer_head *bg_bh, 96 struct buffer_head *bg_bh,
@@ -100,7 +98,7 @@ static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle,
100 u16 chain); 98 u16 chain);
101static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, 99static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
102 u32 wanted); 100 u32 wanted);
103static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, 101static int ocfs2_free_suballoc_bits(handle_t *handle,
104 struct inode *alloc_inode, 102 struct inode *alloc_inode,
105 struct buffer_head *alloc_bh, 103 struct buffer_head *alloc_bh,
106 unsigned int start_bit, 104 unsigned int start_bit,
@@ -120,8 +118,16 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
120 118
121void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) 119void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
122{ 120{
123 if (ac->ac_inode) 121 struct inode *inode = ac->ac_inode;
124 iput(ac->ac_inode); 122
123 if (inode) {
124 if (ac->ac_which != OCFS2_AC_USE_LOCAL)
125 ocfs2_meta_unlock(inode, 1);
126
127 mutex_unlock(&inode->i_mutex);
128
129 iput(inode);
130 }
125 if (ac->ac_bh) 131 if (ac->ac_bh)
126 brelse(ac->ac_bh); 132 brelse(ac->ac_bh);
127 kfree(ac); 133 kfree(ac);
@@ -190,7 +196,7 @@ static int ocfs2_check_group_descriptor(struct super_block *sb,
190 return 0; 196 return 0;
191} 197}
192 198
193static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, 199static int ocfs2_block_group_fill(handle_t *handle,
194 struct inode *alloc_inode, 200 struct inode *alloc_inode,
195 struct buffer_head *bg_bh, 201 struct buffer_head *bg_bh,
196 u64 group_blkno, 202 u64 group_blkno,
@@ -273,7 +279,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
273 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; 279 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
274 struct ocfs2_chain_list *cl; 280 struct ocfs2_chain_list *cl;
275 struct ocfs2_alloc_context *ac = NULL; 281 struct ocfs2_alloc_context *ac = NULL;
276 struct ocfs2_journal_handle *handle = NULL; 282 handle_t *handle = NULL;
277 u32 bit_off, num_bits; 283 u32 bit_off, num_bits;
278 u16 alloc_rec; 284 u16 alloc_rec;
279 u64 bg_blkno; 285 u64 bg_blkno;
@@ -284,16 +290,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
284 290
285 mlog_entry_void(); 291 mlog_entry_void();
286 292
287 handle = ocfs2_alloc_handle(osb);
288 if (!handle) {
289 status = -ENOMEM;
290 mlog_errno(status);
291 goto bail;
292 }
293
294 cl = &fe->id2.i_chain; 293 cl = &fe->id2.i_chain;
295 status = ocfs2_reserve_clusters(osb, 294 status = ocfs2_reserve_clusters(osb,
296 handle,
297 le16_to_cpu(cl->cl_cpg), 295 le16_to_cpu(cl->cl_cpg),
298 &ac); 296 &ac);
299 if (status < 0) { 297 if (status < 0) {
@@ -304,7 +302,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
304 302
305 credits = ocfs2_calc_group_alloc_credits(osb->sb, 303 credits = ocfs2_calc_group_alloc_credits(osb->sb,
306 le16_to_cpu(cl->cl_cpg)); 304 le16_to_cpu(cl->cl_cpg));
307 handle = ocfs2_start_trans(osb, handle, credits); 305 handle = ocfs2_start_trans(osb, credits);
308 if (IS_ERR(handle)) { 306 if (IS_ERR(handle)) {
309 status = PTR_ERR(handle); 307 status = PTR_ERR(handle);
310 handle = NULL; 308 handle = NULL;
@@ -389,7 +387,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
389 status = 0; 387 status = 0;
390bail: 388bail:
391 if (handle) 389 if (handle)
392 ocfs2_commit_trans(handle); 390 ocfs2_commit_trans(osb, handle);
393 391
394 if (ac) 392 if (ac)
395 ocfs2_free_alloc_context(ac); 393 ocfs2_free_alloc_context(ac);
@@ -402,27 +400,38 @@ bail:
402} 400}
403 401
404static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, 402static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
405 struct ocfs2_alloc_context *ac) 403 struct ocfs2_alloc_context *ac,
404 int type,
405 u32 slot)
406{ 406{
407 int status; 407 int status;
408 u32 bits_wanted = ac->ac_bits_wanted; 408 u32 bits_wanted = ac->ac_bits_wanted;
409 struct inode *alloc_inode = ac->ac_inode; 409 struct inode *alloc_inode;
410 struct buffer_head *bh = NULL; 410 struct buffer_head *bh = NULL;
411 struct ocfs2_journal_handle *handle = ac->ac_handle;
412 struct ocfs2_dinode *fe; 411 struct ocfs2_dinode *fe;
413 u32 free_bits; 412 u32 free_bits;
414 413
415 mlog_entry_void(); 414 mlog_entry_void();
416 415
417 BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); 416 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
417 if (!alloc_inode) {
418 mlog_errno(-EINVAL);
419 return -EINVAL;
420 }
418 421
419 ocfs2_handle_add_inode(handle, alloc_inode); 422 mutex_lock(&alloc_inode->i_mutex);
420 status = ocfs2_meta_lock(alloc_inode, handle, &bh, 1); 423
424 status = ocfs2_meta_lock(alloc_inode, &bh, 1);
421 if (status < 0) { 425 if (status < 0) {
426 mutex_unlock(&alloc_inode->i_mutex);
427 iput(alloc_inode);
428
422 mlog_errno(status); 429 mlog_errno(status);
423 goto bail; 430 return status;
424 } 431 }
425 432
433 ac->ac_inode = alloc_inode;
434
426 fe = (struct ocfs2_dinode *) bh->b_data; 435 fe = (struct ocfs2_dinode *) bh->b_data;
427 if (!OCFS2_IS_VALID_DINODE(fe)) { 436 if (!OCFS2_IS_VALID_DINODE(fe)) {
428 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); 437 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
@@ -473,12 +482,11 @@ bail:
473} 482}
474 483
475int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, 484int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
476 struct ocfs2_journal_handle *handle,
477 struct ocfs2_dinode *fe, 485 struct ocfs2_dinode *fe,
478 struct ocfs2_alloc_context **ac) 486 struct ocfs2_alloc_context **ac)
479{ 487{
480 int status; 488 int status;
481 struct inode *alloc_inode = NULL; 489 u32 slot;
482 490
483 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 491 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
484 if (!(*ac)) { 492 if (!(*ac)) {
@@ -488,28 +496,18 @@ int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
488 } 496 }
489 497
490 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe); 498 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
491 (*ac)->ac_handle = handle;
492 (*ac)->ac_which = OCFS2_AC_USE_META; 499 (*ac)->ac_which = OCFS2_AC_USE_META;
493 500
494#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS 501#ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS
495 alloc_inode = ocfs2_get_system_file_inode(osb, 502 slot = 0;
496 EXTENT_ALLOC_SYSTEM_INODE,
497 0);
498#else 503#else
499 alloc_inode = ocfs2_get_system_file_inode(osb, 504 slot = osb->slot_num;
500 EXTENT_ALLOC_SYSTEM_INODE,
501 osb->slot_num);
502#endif 505#endif
503 if (!alloc_inode) {
504 status = -ENOMEM;
505 mlog_errno(status);
506 goto bail;
507 }
508 506
509 (*ac)->ac_inode = igrab(alloc_inode);
510 (*ac)->ac_group_search = ocfs2_block_group_search; 507 (*ac)->ac_group_search = ocfs2_block_group_search;
511 508
512 status = ocfs2_reserve_suballoc_bits(osb, (*ac)); 509 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
510 EXTENT_ALLOC_SYSTEM_INODE, slot);
513 if (status < 0) { 511 if (status < 0) {
514 if (status != -ENOSPC) 512 if (status != -ENOSPC)
515 mlog_errno(status); 513 mlog_errno(status);
@@ -523,19 +521,14 @@ bail:
523 *ac = NULL; 521 *ac = NULL;
524 } 522 }
525 523
526 if (alloc_inode)
527 iput(alloc_inode);
528
529 mlog_exit(status); 524 mlog_exit(status);
530 return status; 525 return status;
531} 526}
532 527
533int ocfs2_reserve_new_inode(struct ocfs2_super *osb, 528int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
534 struct ocfs2_journal_handle *handle,
535 struct ocfs2_alloc_context **ac) 529 struct ocfs2_alloc_context **ac)
536{ 530{
537 int status; 531 int status;
538 struct inode *alloc_inode = NULL;
539 532
540 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 533 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
541 if (!(*ac)) { 534 if (!(*ac)) {
@@ -545,22 +538,13 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
545 } 538 }
546 539
547 (*ac)->ac_bits_wanted = 1; 540 (*ac)->ac_bits_wanted = 1;
548 (*ac)->ac_handle = handle;
549 (*ac)->ac_which = OCFS2_AC_USE_INODE; 541 (*ac)->ac_which = OCFS2_AC_USE_INODE;
550 542
551 alloc_inode = ocfs2_get_system_file_inode(osb,
552 INODE_ALLOC_SYSTEM_INODE,
553 osb->slot_num);
554 if (!alloc_inode) {
555 status = -ENOMEM;
556 mlog_errno(status);
557 goto bail;
558 }
559
560 (*ac)->ac_inode = igrab(alloc_inode);
561 (*ac)->ac_group_search = ocfs2_block_group_search; 543 (*ac)->ac_group_search = ocfs2_block_group_search;
562 544
563 status = ocfs2_reserve_suballoc_bits(osb, *ac); 545 status = ocfs2_reserve_suballoc_bits(osb, *ac,
546 INODE_ALLOC_SYSTEM_INODE,
547 osb->slot_num);
564 if (status < 0) { 548 if (status < 0) {
565 if (status != -ENOSPC) 549 if (status != -ENOSPC)
566 mlog_errno(status); 550 mlog_errno(status);
@@ -574,9 +558,6 @@ bail:
574 *ac = NULL; 558 *ac = NULL;
575 } 559 }
576 560
577 if (alloc_inode)
578 iput(alloc_inode);
579
580 mlog_exit(status); 561 mlog_exit(status);
581 return status; 562 return status;
582} 563}
@@ -588,20 +569,17 @@ int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
588{ 569{
589 int status; 570 int status;
590 571
591 ac->ac_inode = ocfs2_get_system_file_inode(osb,
592 GLOBAL_BITMAP_SYSTEM_INODE,
593 OCFS2_INVALID_SLOT);
594 if (!ac->ac_inode) {
595 status = -EINVAL;
596 mlog(ML_ERROR, "Could not get bitmap inode!\n");
597 goto bail;
598 }
599 ac->ac_which = OCFS2_AC_USE_MAIN; 572 ac->ac_which = OCFS2_AC_USE_MAIN;
600 ac->ac_group_search = ocfs2_cluster_group_search; 573 ac->ac_group_search = ocfs2_cluster_group_search;
601 574
602 status = ocfs2_reserve_suballoc_bits(osb, ac); 575 status = ocfs2_reserve_suballoc_bits(osb, ac,
603 if (status < 0 && status != -ENOSPC) 576 GLOBAL_BITMAP_SYSTEM_INODE,
577 OCFS2_INVALID_SLOT);
578 if (status < 0 && status != -ENOSPC) {
604 mlog_errno(status); 579 mlog_errno(status);
580 goto bail;
581 }
582
605bail: 583bail:
606 return status; 584 return status;
607} 585}
@@ -610,7 +588,6 @@ bail:
610 * use so we figure it out for them, but unfortunately this clutters 588 * use so we figure it out for them, but unfortunately this clutters
611 * things a bit. */ 589 * things a bit. */
612int ocfs2_reserve_clusters(struct ocfs2_super *osb, 590int ocfs2_reserve_clusters(struct ocfs2_super *osb,
613 struct ocfs2_journal_handle *handle,
614 u32 bits_wanted, 591 u32 bits_wanted,
615 struct ocfs2_alloc_context **ac) 592 struct ocfs2_alloc_context **ac)
616{ 593{
@@ -618,8 +595,6 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
618 595
619 mlog_entry_void(); 596 mlog_entry_void();
620 597
621 BUG_ON(!handle);
622
623 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); 598 *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
624 if (!(*ac)) { 599 if (!(*ac)) {
625 status = -ENOMEM; 600 status = -ENOMEM;
@@ -628,12 +603,10 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb,
628 } 603 }
629 604
630 (*ac)->ac_bits_wanted = bits_wanted; 605 (*ac)->ac_bits_wanted = bits_wanted;
631 (*ac)->ac_handle = handle;
632 606
633 status = -ENOSPC; 607 status = -ENOSPC;
634 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { 608 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) {
635 status = ocfs2_reserve_local_alloc_bits(osb, 609 status = ocfs2_reserve_local_alloc_bits(osb,
636 handle,
637 bits_wanted, 610 bits_wanted,
638 *ac); 611 *ac);
639 if ((status < 0) && (status != -ENOSPC)) { 612 if ((status < 0) && (status != -ENOSPC)) {
@@ -774,7 +747,7 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
774 return status; 747 return status;
775} 748}
776 749
777static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, 750static inline int ocfs2_block_group_set_bits(handle_t *handle,
778 struct inode *alloc_inode, 751 struct inode *alloc_inode,
779 struct ocfs2_group_desc *bg, 752 struct ocfs2_group_desc *bg,
780 struct buffer_head *group_bh, 753 struct buffer_head *group_bh,
@@ -845,7 +818,7 @@ static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl)
845 return best; 818 return best;
846} 819}
847 820
848static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, 821static int ocfs2_relink_block_group(handle_t *handle,
849 struct inode *alloc_inode, 822 struct inode *alloc_inode,
850 struct buffer_head *fe_bh, 823 struct buffer_head *fe_bh,
851 struct buffer_head *bg_bh, 824 struct buffer_head *bg_bh,
@@ -1025,7 +998,7 @@ static int ocfs2_block_group_search(struct inode *inode,
1025} 998}
1026 999
1027static int ocfs2_alloc_dinode_update_counts(struct inode *inode, 1000static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1028 struct ocfs2_journal_handle *handle, 1001 handle_t *handle,
1029 struct buffer_head *di_bh, 1002 struct buffer_head *di_bh,
1030 u32 num_bits, 1003 u32 num_bits,
1031 u16 chain) 1004 u16 chain)
@@ -1055,6 +1028,7 @@ out:
1055} 1028}
1056 1029
1057static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, 1030static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1031 handle_t *handle,
1058 u32 bits_wanted, 1032 u32 bits_wanted,
1059 u32 min_bits, 1033 u32 min_bits,
1060 u16 *bit_off, 1034 u16 *bit_off,
@@ -1067,7 +1041,6 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1067 struct buffer_head *group_bh = NULL; 1041 struct buffer_head *group_bh = NULL;
1068 struct ocfs2_group_desc *gd; 1042 struct ocfs2_group_desc *gd;
1069 struct inode *alloc_inode = ac->ac_inode; 1043 struct inode *alloc_inode = ac->ac_inode;
1070 struct ocfs2_journal_handle *handle = ac->ac_handle;
1071 1044
1072 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno, 1045 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno,
1073 &group_bh, OCFS2_BH_CACHED, alloc_inode); 1046 &group_bh, OCFS2_BH_CACHED, alloc_inode);
@@ -1115,6 +1088,7 @@ out:
1115} 1088}
1116 1089
1117static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, 1090static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1091 handle_t *handle,
1118 u32 bits_wanted, 1092 u32 bits_wanted,
1119 u32 min_bits, 1093 u32 min_bits,
1120 u16 *bit_off, 1094 u16 *bit_off,
@@ -1126,7 +1100,6 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1126 u16 chain, tmp_bits; 1100 u16 chain, tmp_bits;
1127 u32 tmp_used; 1101 u32 tmp_used;
1128 u64 next_group; 1102 u64 next_group;
1129 struct ocfs2_journal_handle *handle = ac->ac_handle;
1130 struct inode *alloc_inode = ac->ac_inode; 1103 struct inode *alloc_inode = ac->ac_inode;
1131 struct buffer_head *group_bh = NULL; 1104 struct buffer_head *group_bh = NULL;
1132 struct buffer_head *prev_group_bh = NULL; 1105 struct buffer_head *prev_group_bh = NULL;
@@ -1272,6 +1245,7 @@ bail:
1272/* will give out up to bits_wanted contiguous bits. */ 1245/* will give out up to bits_wanted contiguous bits. */
1273static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, 1246static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1274 struct ocfs2_alloc_context *ac, 1247 struct ocfs2_alloc_context *ac,
1248 handle_t *handle,
1275 u32 bits_wanted, 1249 u32 bits_wanted,
1276 u32 min_bits, 1250 u32 min_bits,
1277 u16 *bit_off, 1251 u16 *bit_off,
@@ -1313,8 +1287,8 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1313 * by jumping straight to the most recently used 1287 * by jumping straight to the most recently used
1314 * allocation group. This helps us mantain some 1288 * allocation group. This helps us mantain some
1315 * contiguousness across allocations. */ 1289 * contiguousness across allocations. */
1316 status = ocfs2_search_one_group(ac, bits_wanted, min_bits, 1290 status = ocfs2_search_one_group(ac, handle, bits_wanted,
1317 bit_off, num_bits, 1291 min_bits, bit_off, num_bits,
1318 hint_blkno, &bits_left); 1292 hint_blkno, &bits_left);
1319 if (!status) { 1293 if (!status) {
1320 /* Be careful to update *bg_blkno here as the 1294 /* Be careful to update *bg_blkno here as the
@@ -1336,7 +1310,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1336 ac->ac_chain = victim; 1310 ac->ac_chain = victim;
1337 ac->ac_allow_chain_relink = 1; 1311 ac->ac_allow_chain_relink = 1;
1338 1312
1339 status = ocfs2_search_chain(ac, bits_wanted, min_bits, bit_off, 1313 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, bit_off,
1340 num_bits, bg_blkno, &bits_left); 1314 num_bits, bg_blkno, &bits_left);
1341 if (!status) 1315 if (!status)
1342 goto set_hint; 1316 goto set_hint;
@@ -1360,7 +1334,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1360 continue; 1334 continue;
1361 1335
1362 ac->ac_chain = i; 1336 ac->ac_chain = i;
1363 status = ocfs2_search_chain(ac, bits_wanted, min_bits, 1337 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1364 bit_off, num_bits, bg_blkno, 1338 bit_off, num_bits, bg_blkno,
1365 &bits_left); 1339 &bits_left);
1366 if (!status) 1340 if (!status)
@@ -1388,7 +1362,7 @@ bail:
1388} 1362}
1389 1363
1390int ocfs2_claim_metadata(struct ocfs2_super *osb, 1364int ocfs2_claim_metadata(struct ocfs2_super *osb,
1391 struct ocfs2_journal_handle *handle, 1365 handle_t *handle,
1392 struct ocfs2_alloc_context *ac, 1366 struct ocfs2_alloc_context *ac,
1393 u32 bits_wanted, 1367 u32 bits_wanted,
1394 u16 *suballoc_bit_start, 1368 u16 *suballoc_bit_start,
@@ -1401,10 +1375,10 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb,
1401 BUG_ON(!ac); 1375 BUG_ON(!ac);
1402 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); 1376 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted));
1403 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); 1377 BUG_ON(ac->ac_which != OCFS2_AC_USE_META);
1404 BUG_ON(ac->ac_handle != handle);
1405 1378
1406 status = ocfs2_claim_suballoc_bits(osb, 1379 status = ocfs2_claim_suballoc_bits(osb,
1407 ac, 1380 ac,
1381 handle,
1408 bits_wanted, 1382 bits_wanted,
1409 1, 1383 1,
1410 suballoc_bit_start, 1384 suballoc_bit_start,
@@ -1425,7 +1399,7 @@ bail:
1425} 1399}
1426 1400
1427int ocfs2_claim_new_inode(struct ocfs2_super *osb, 1401int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1428 struct ocfs2_journal_handle *handle, 1402 handle_t *handle,
1429 struct ocfs2_alloc_context *ac, 1403 struct ocfs2_alloc_context *ac,
1430 u16 *suballoc_bit, 1404 u16 *suballoc_bit,
1431 u64 *fe_blkno) 1405 u64 *fe_blkno)
@@ -1440,10 +1414,10 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1440 BUG_ON(ac->ac_bits_given != 0); 1414 BUG_ON(ac->ac_bits_given != 0);
1441 BUG_ON(ac->ac_bits_wanted != 1); 1415 BUG_ON(ac->ac_bits_wanted != 1);
1442 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); 1416 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);
1443 BUG_ON(ac->ac_handle != handle);
1444 1417
1445 status = ocfs2_claim_suballoc_bits(osb, 1418 status = ocfs2_claim_suballoc_bits(osb,
1446 ac, 1419 ac,
1420 handle,
1447 1, 1421 1,
1448 1, 1422 1,
1449 suballoc_bit, 1423 suballoc_bit,
@@ -1528,7 +1502,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1528 * of any size. 1502 * of any size.
1529 */ 1503 */
1530int ocfs2_claim_clusters(struct ocfs2_super *osb, 1504int ocfs2_claim_clusters(struct ocfs2_super *osb,
1531 struct ocfs2_journal_handle *handle, 1505 handle_t *handle,
1532 struct ocfs2_alloc_context *ac, 1506 struct ocfs2_alloc_context *ac,
1533 u32 min_clusters, 1507 u32 min_clusters,
1534 u32 *cluster_start, 1508 u32 *cluster_start,
@@ -1546,7 +1520,6 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
1546 1520
1547 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL 1521 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
1548 && ac->ac_which != OCFS2_AC_USE_MAIN); 1522 && ac->ac_which != OCFS2_AC_USE_MAIN);
1549 BUG_ON(ac->ac_handle != handle);
1550 1523
1551 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { 1524 if (ac->ac_which == OCFS2_AC_USE_LOCAL) {
1552 status = ocfs2_claim_local_alloc_bits(osb, 1525 status = ocfs2_claim_local_alloc_bits(osb,
@@ -1572,6 +1545,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
1572 1545
1573 status = ocfs2_claim_suballoc_bits(osb, 1546 status = ocfs2_claim_suballoc_bits(osb,
1574 ac, 1547 ac,
1548 handle,
1575 bits_wanted, 1549 bits_wanted,
1576 min_clusters, 1550 min_clusters,
1577 &bg_bit_off, 1551 &bg_bit_off,
@@ -1598,7 +1572,7 @@ bail:
1598 return status; 1572 return status;
1599} 1573}
1600 1574
1601static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, 1575static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1602 struct inode *alloc_inode, 1576 struct inode *alloc_inode,
1603 struct ocfs2_group_desc *bg, 1577 struct ocfs2_group_desc *bg,
1604 struct buffer_head *group_bh, 1578 struct buffer_head *group_bh,
@@ -1653,7 +1627,7 @@ bail:
1653/* 1627/*
1654 * expects the suballoc inode to already be locked. 1628 * expects the suballoc inode to already be locked.
1655 */ 1629 */
1656static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, 1630static int ocfs2_free_suballoc_bits(handle_t *handle,
1657 struct inode *alloc_inode, 1631 struct inode *alloc_inode,
1658 struct buffer_head *alloc_bh, 1632 struct buffer_head *alloc_bh,
1659 unsigned int start_bit, 1633 unsigned int start_bit,
@@ -1737,7 +1711,7 @@ static inline u64 ocfs2_which_suballoc_group(u64 block, unsigned int bit)
1737 return group; 1711 return group;
1738} 1712}
1739 1713
1740int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, 1714int ocfs2_free_dinode(handle_t *handle,
1741 struct inode *inode_alloc_inode, 1715 struct inode *inode_alloc_inode,
1742 struct buffer_head *inode_alloc_bh, 1716 struct buffer_head *inode_alloc_bh,
1743 struct ocfs2_dinode *di) 1717 struct ocfs2_dinode *di)
@@ -1750,7 +1724,7 @@ int ocfs2_free_dinode(struct ocfs2_journal_handle *handle,
1750 inode_alloc_bh, bit, bg_blkno, 1); 1724 inode_alloc_bh, bit, bg_blkno, 1);
1751} 1725}
1752 1726
1753int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, 1727int ocfs2_free_extent_block(handle_t *handle,
1754 struct inode *eb_alloc_inode, 1728 struct inode *eb_alloc_inode,
1755 struct buffer_head *eb_alloc_bh, 1729 struct buffer_head *eb_alloc_bh,
1756 struct ocfs2_extent_block *eb) 1730 struct ocfs2_extent_block *eb)
@@ -1763,7 +1737,7 @@ int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle,
1763 bit, bg_blkno, 1); 1737 bit, bg_blkno, 1);
1764} 1738}
1765 1739
1766int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, 1740int ocfs2_free_clusters(handle_t *handle,
1767 struct inode *bitmap_inode, 1741 struct inode *bitmap_inode,
1768 struct buffer_head *bitmap_bh, 1742 struct buffer_head *bitmap_bh,
1769 u64 start_blk, 1743 u64 start_blk,
diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h
index c787838d1052..1a3c94cb9250 100644
--- a/fs/ocfs2/suballoc.h
+++ b/fs/ocfs2/suballoc.h
@@ -43,7 +43,6 @@ struct ocfs2_alloc_context {
43#define OCFS2_AC_USE_INODE 3 43#define OCFS2_AC_USE_INODE 3
44#define OCFS2_AC_USE_META 4 44#define OCFS2_AC_USE_META 4
45 u32 ac_which; 45 u32 ac_which;
46 struct ocfs2_journal_handle *ac_handle;
47 46
48 /* these are used by the chain search */ 47 /* these are used by the chain search */
49 u16 ac_chain; 48 u16 ac_chain;
@@ -60,45 +59,42 @@ static inline int ocfs2_alloc_context_bits_left(struct ocfs2_alloc_context *ac)
60} 59}
61 60
62int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, 61int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
63 struct ocfs2_journal_handle *handle,
64 struct ocfs2_dinode *fe, 62 struct ocfs2_dinode *fe,
65 struct ocfs2_alloc_context **ac); 63 struct ocfs2_alloc_context **ac);
66int ocfs2_reserve_new_inode(struct ocfs2_super *osb, 64int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
67 struct ocfs2_journal_handle *handle,
68 struct ocfs2_alloc_context **ac); 65 struct ocfs2_alloc_context **ac);
69int ocfs2_reserve_clusters(struct ocfs2_super *osb, 66int ocfs2_reserve_clusters(struct ocfs2_super *osb,
70 struct ocfs2_journal_handle *handle,
71 u32 bits_wanted, 67 u32 bits_wanted,
72 struct ocfs2_alloc_context **ac); 68 struct ocfs2_alloc_context **ac);
73 69
74int ocfs2_claim_metadata(struct ocfs2_super *osb, 70int ocfs2_claim_metadata(struct ocfs2_super *osb,
75 struct ocfs2_journal_handle *handle, 71 handle_t *handle,
76 struct ocfs2_alloc_context *ac, 72 struct ocfs2_alloc_context *ac,
77 u32 bits_wanted, 73 u32 bits_wanted,
78 u16 *suballoc_bit_start, 74 u16 *suballoc_bit_start,
79 u32 *num_bits, 75 u32 *num_bits,
80 u64 *blkno_start); 76 u64 *blkno_start);
81int ocfs2_claim_new_inode(struct ocfs2_super *osb, 77int ocfs2_claim_new_inode(struct ocfs2_super *osb,
82 struct ocfs2_journal_handle *handle, 78 handle_t *handle,
83 struct ocfs2_alloc_context *ac, 79 struct ocfs2_alloc_context *ac,
84 u16 *suballoc_bit, 80 u16 *suballoc_bit,
85 u64 *fe_blkno); 81 u64 *fe_blkno);
86int ocfs2_claim_clusters(struct ocfs2_super *osb, 82int ocfs2_claim_clusters(struct ocfs2_super *osb,
87 struct ocfs2_journal_handle *handle, 83 handle_t *handle,
88 struct ocfs2_alloc_context *ac, 84 struct ocfs2_alloc_context *ac,
89 u32 min_clusters, 85 u32 min_clusters,
90 u32 *cluster_start, 86 u32 *cluster_start,
91 u32 *num_clusters); 87 u32 *num_clusters);
92 88
93int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, 89int ocfs2_free_dinode(handle_t *handle,
94 struct inode *inode_alloc_inode, 90 struct inode *inode_alloc_inode,
95 struct buffer_head *inode_alloc_bh, 91 struct buffer_head *inode_alloc_bh,
96 struct ocfs2_dinode *di); 92 struct ocfs2_dinode *di);
97int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, 93int ocfs2_free_extent_block(handle_t *handle,
98 struct inode *eb_alloc_inode, 94 struct inode *eb_alloc_inode,
99 struct buffer_head *eb_alloc_bh, 95 struct buffer_head *eb_alloc_bh,
100 struct ocfs2_extent_block *eb); 96 struct ocfs2_extent_block *eb);
101int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, 97int ocfs2_free_clusters(handle_t *handle,
102 struct inode *bitmap_inode, 98 struct inode *bitmap_inode,
103 struct buffer_head *bitmap_bh, 99 struct buffer_head *bitmap_bh,
104 u64 start_blk, 100 u64 start_blk,
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 76b46ebbb10c..d9b4214a12da 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -70,8 +70,6 @@
70 70
71static kmem_cache_t *ocfs2_inode_cachep = NULL; 71static kmem_cache_t *ocfs2_inode_cachep = NULL;
72 72
73kmem_cache_t *ocfs2_lock_cache = NULL;
74
75/* OCFS2 needs to schedule several differnt types of work which 73/* OCFS2 needs to schedule several differnt types of work which
76 * require cluster locking, disk I/O, recovery waits, etc. Since these 74 * require cluster locking, disk I/O, recovery waits, etc. Since these
77 * types of work tend to be heavy we avoid using the kernel events 75 * types of work tend to be heavy we avoid using the kernel events
@@ -141,6 +139,7 @@ enum {
141 Opt_hb_local, 139 Opt_hb_local,
142 Opt_data_ordered, 140 Opt_data_ordered,
143 Opt_data_writeback, 141 Opt_data_writeback,
142 Opt_atime_quantum,
144 Opt_err, 143 Opt_err,
145}; 144};
146 145
@@ -154,6 +153,7 @@ static match_table_t tokens = {
154 {Opt_hb_local, OCFS2_HB_LOCAL}, 153 {Opt_hb_local, OCFS2_HB_LOCAL},
155 {Opt_data_ordered, "data=ordered"}, 154 {Opt_data_ordered, "data=ordered"},
156 {Opt_data_writeback, "data=writeback"}, 155 {Opt_data_writeback, "data=writeback"},
156 {Opt_atime_quantum, "atime_quantum=%u"},
157 {Opt_err, NULL} 157 {Opt_err, NULL}
158}; 158};
159 159
@@ -707,6 +707,7 @@ static int ocfs2_parse_options(struct super_block *sb,
707 while ((p = strsep(&options, ",")) != NULL) { 707 while ((p = strsep(&options, ",")) != NULL) {
708 int token, option; 708 int token, option;
709 substring_t args[MAX_OPT_ARGS]; 709 substring_t args[MAX_OPT_ARGS];
710 struct ocfs2_super * osb = OCFS2_SB(sb);
710 711
711 if (!*p) 712 if (!*p)
712 continue; 713 continue;
@@ -747,6 +748,16 @@ static int ocfs2_parse_options(struct super_block *sb,
747 case Opt_data_writeback: 748 case Opt_data_writeback:
748 *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; 749 *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK;
749 break; 750 break;
751 case Opt_atime_quantum:
752 if (match_int(&args[0], &option)) {
753 status = 0;
754 goto bail;
755 }
756 if (option >= 0)
757 osb->s_atime_quantum = option;
758 else
759 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
760 break;
750 default: 761 default:
751 mlog(ML_ERROR, 762 mlog(ML_ERROR,
752 "Unrecognized mount option \"%s\" " 763 "Unrecognized mount option \"%s\" "
@@ -867,7 +878,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
867 goto bail; 878 goto bail;
868 } 879 }
869 880
870 status = ocfs2_meta_lock(inode, NULL, &bh, 0); 881 status = ocfs2_meta_lock(inode, &bh, 0);
871 if (status < 0) { 882 if (status < 0) {
872 mlog_errno(status); 883 mlog_errno(status);
873 goto bail; 884 goto bail;
@@ -914,9 +925,7 @@ static void ocfs2_inode_init_once(void *data,
914 oi->ip_open_count = 0; 925 oi->ip_open_count = 0;
915 spin_lock_init(&oi->ip_lock); 926 spin_lock_init(&oi->ip_lock);
916 ocfs2_extent_map_init(&oi->vfs_inode); 927 ocfs2_extent_map_init(&oi->vfs_inode);
917 INIT_LIST_HEAD(&oi->ip_handle_list);
918 INIT_LIST_HEAD(&oi->ip_io_markers); 928 INIT_LIST_HEAD(&oi->ip_io_markers);
919 oi->ip_handle = NULL;
920 oi->ip_created_trans = 0; 929 oi->ip_created_trans = 0;
921 oi->ip_last_trans = 0; 930 oi->ip_last_trans = 0;
922 oi->ip_dir_start_lookup = 0; 931 oi->ip_dir_start_lookup = 0;
@@ -948,14 +957,6 @@ static int ocfs2_initialize_mem_caches(void)
948 if (!ocfs2_inode_cachep) 957 if (!ocfs2_inode_cachep)
949 return -ENOMEM; 958 return -ENOMEM;
950 959
951 ocfs2_lock_cache = kmem_cache_create("ocfs2_lock",
952 sizeof(struct ocfs2_journal_lock),
953 0,
954 SLAB_HWCACHE_ALIGN,
955 NULL, NULL);
956 if (!ocfs2_lock_cache)
957 return -ENOMEM;
958
959 return 0; 960 return 0;
960} 961}
961 962
@@ -963,11 +964,8 @@ static void ocfs2_free_mem_caches(void)
963{ 964{
964 if (ocfs2_inode_cachep) 965 if (ocfs2_inode_cachep)
965 kmem_cache_destroy(ocfs2_inode_cachep); 966 kmem_cache_destroy(ocfs2_inode_cachep);
966 if (ocfs2_lock_cache)
967 kmem_cache_destroy(ocfs2_lock_cache);
968 967
969 ocfs2_inode_cachep = NULL; 968 ocfs2_inode_cachep = NULL;
970 ocfs2_lock_cache = NULL;
971} 969}
972 970
973static int ocfs2_get_sector(struct super_block *sb, 971static int ocfs2_get_sector(struct super_block *sb,
@@ -1280,6 +1278,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1280 init_waitqueue_head(&osb->checkpoint_event); 1278 init_waitqueue_head(&osb->checkpoint_event);
1281 atomic_set(&osb->needs_checkpoint, 0); 1279 atomic_set(&osb->needs_checkpoint, 0);
1282 1280
1281 osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM;
1282
1283 osb->node_num = O2NM_INVALID_NODE_NUM; 1283 osb->node_num = O2NM_INVALID_NODE_NUM;
1284 osb->slot_num = OCFS2_INVALID_SLOT; 1284 osb->slot_num = OCFS2_INVALID_SLOT;
1285 1285
@@ -1365,7 +1365,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
1365 spin_lock_init(&journal->j_lock); 1365 spin_lock_init(&journal->j_lock);
1366 journal->j_trans_id = (unsigned long) 1; 1366 journal->j_trans_id = (unsigned long) 1;
1367 INIT_LIST_HEAD(&journal->j_la_cleanups); 1367 INIT_LIST_HEAD(&journal->j_la_cleanups);
1368 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery, osb); 1368 INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery);
1369 journal->j_state = OCFS2_JOURNAL_FREE; 1369 journal->j_state = OCFS2_JOURNAL_FREE;
1370 1370
1371 /* get some pseudo constants for clustersize bits */ 1371 /* get some pseudo constants for clustersize bits */
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c
index c0f68aa6c175..957d6878b03e 100644
--- a/fs/ocfs2/symlink.c
+++ b/fs/ocfs2/symlink.c
@@ -126,6 +126,10 @@ static int ocfs2_readlink(struct dentry *dentry,
126 goto out; 126 goto out;
127 } 127 }
128 128
129 /*
130 * Without vfsmount we can't update atime now,
131 * but we will update atime here ultimately.
132 */
129 ret = vfs_readlink(dentry, buffer, buflen, link); 133 ret = vfs_readlink(dentry, buffer, buflen, link);
130 134
131 brelse(bh); 135 brelse(bh);
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index ac93174c9639..7280a23ef344 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -104,7 +104,7 @@ static int release_journal_dev(struct super_block *super,
104 struct reiserfs_journal *journal); 104 struct reiserfs_journal *journal);
105static int dirty_one_transaction(struct super_block *s, 105static int dirty_one_transaction(struct super_block *s,
106 struct reiserfs_journal_list *jl); 106 struct reiserfs_journal_list *jl);
107static void flush_async_commits(void *p); 107static void flush_async_commits(struct work_struct *work);
108static void queue_log_writer(struct super_block *s); 108static void queue_log_writer(struct super_block *s);
109 109
110/* values for join in do_journal_begin_r */ 110/* values for join in do_journal_begin_r */
@@ -2836,7 +2836,8 @@ int journal_init(struct super_block *p_s_sb, const char *j_dev_name,
2836 if (reiserfs_mounted_fs_count <= 1) 2836 if (reiserfs_mounted_fs_count <= 1)
2837 commit_wq = create_workqueue("reiserfs"); 2837 commit_wq = create_workqueue("reiserfs");
2838 2838
2839 INIT_WORK(&journal->j_work, flush_async_commits, p_s_sb); 2839 INIT_DELAYED_WORK(&journal->j_work, flush_async_commits);
2840 journal->j_work_sb = p_s_sb;
2840 return 0; 2841 return 0;
2841 free_and_return: 2842 free_and_return:
2842 free_journal_ram(p_s_sb); 2843 free_journal_ram(p_s_sb);
@@ -3447,10 +3448,11 @@ int journal_end_sync(struct reiserfs_transaction_handle *th,
3447/* 3448/*
3448** writeback the pending async commits to disk 3449** writeback the pending async commits to disk
3449*/ 3450*/
3450static void flush_async_commits(void *p) 3451static void flush_async_commits(struct work_struct *work)
3451{ 3452{
3452 struct super_block *p_s_sb = p; 3453 struct reiserfs_journal *journal =
3453 struct reiserfs_journal *journal = SB_JOURNAL(p_s_sb); 3454 container_of(work, struct reiserfs_journal, j_work.work);
3455 struct super_block *p_s_sb = journal->j_work_sb;
3454 struct reiserfs_journal_list *jl; 3456 struct reiserfs_journal_list *jl;
3455 struct list_head *entry; 3457 struct list_head *entry;
3456 3458
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 09360cf1e1f2..8e6b56fc1cad 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -149,9 +149,10 @@ xfs_destroy_ioend(
149 */ 149 */
150STATIC void 150STATIC void
151xfs_end_bio_delalloc( 151xfs_end_bio_delalloc(
152 void *data) 152 struct work_struct *work)
153{ 153{
154 xfs_ioend_t *ioend = data; 154 xfs_ioend_t *ioend =
155 container_of(work, xfs_ioend_t, io_work);
155 156
156 xfs_destroy_ioend(ioend); 157 xfs_destroy_ioend(ioend);
157} 158}
@@ -161,9 +162,10 @@ xfs_end_bio_delalloc(
161 */ 162 */
162STATIC void 163STATIC void
163xfs_end_bio_written( 164xfs_end_bio_written(
164 void *data) 165 struct work_struct *work)
165{ 166{
166 xfs_ioend_t *ioend = data; 167 xfs_ioend_t *ioend =
168 container_of(work, xfs_ioend_t, io_work);
167 169
168 xfs_destroy_ioend(ioend); 170 xfs_destroy_ioend(ioend);
169} 171}
@@ -176,9 +178,10 @@ xfs_end_bio_written(
176 */ 178 */
177STATIC void 179STATIC void
178xfs_end_bio_unwritten( 180xfs_end_bio_unwritten(
179 void *data) 181 struct work_struct *work)
180{ 182{
181 xfs_ioend_t *ioend = data; 183 xfs_ioend_t *ioend =
184 container_of(work, xfs_ioend_t, io_work);
182 bhv_vnode_t *vp = ioend->io_vnode; 185 bhv_vnode_t *vp = ioend->io_vnode;
183 xfs_off_t offset = ioend->io_offset; 186 xfs_off_t offset = ioend->io_offset;
184 size_t size = ioend->io_size; 187 size_t size = ioend->io_size;
@@ -220,11 +223,11 @@ xfs_alloc_ioend(
220 ioend->io_size = 0; 223 ioend->io_size = 0;
221 224
222 if (type == IOMAP_UNWRITTEN) 225 if (type == IOMAP_UNWRITTEN)
223 INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten, ioend); 226 INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten);
224 else if (type == IOMAP_DELAY) 227 else if (type == IOMAP_DELAY)
225 INIT_WORK(&ioend->io_work, xfs_end_bio_delalloc, ioend); 228 INIT_WORK(&ioend->io_work, xfs_end_bio_delalloc);
226 else 229 else
227 INIT_WORK(&ioend->io_work, xfs_end_bio_written, ioend); 230 INIT_WORK(&ioend->io_work, xfs_end_bio_written);
228 231
229 return ioend; 232 return ioend;
230} 233}
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d3382843698e..eef4a0ba11e9 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -994,9 +994,10 @@ xfs_buf_wait_unpin(
994 994
995STATIC void 995STATIC void
996xfs_buf_iodone_work( 996xfs_buf_iodone_work(
997 void *v) 997 struct work_struct *work)
998{ 998{
999 xfs_buf_t *bp = (xfs_buf_t *)v; 999 xfs_buf_t *bp =
1000 container_of(work, xfs_buf_t, b_iodone_work);
1000 1001
1001 if (bp->b_iodone) 1002 if (bp->b_iodone)
1002 (*(bp->b_iodone))(bp); 1003 (*(bp->b_iodone))(bp);
@@ -1017,10 +1018,10 @@ xfs_buf_ioend(
1017 1018
1018 if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) { 1019 if ((bp->b_iodone) || (bp->b_flags & XBF_ASYNC)) {
1019 if (schedule) { 1020 if (schedule) {
1020 INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work, bp); 1021 INIT_WORK(&bp->b_iodone_work, xfs_buf_iodone_work);
1021 queue_work(xfslogd_workqueue, &bp->b_iodone_work); 1022 queue_work(xfslogd_workqueue, &bp->b_iodone_work);
1022 } else { 1023 } else {
1023 xfs_buf_iodone_work(bp); 1024 xfs_buf_iodone_work(&bp->b_iodone_work);
1024 } 1025 }
1025 } else { 1026 } else {
1026 up(&bp->b_iodonesema); 1027 up(&bp->b_iodonesema);
diff --git a/include/asm-arm/arch-omap/irda.h b/include/asm-arm/arch-omap/irda.h
index 805ae3575e44..345a649ec838 100644
--- a/include/asm-arm/arch-omap/irda.h
+++ b/include/asm-arm/arch-omap/irda.h
@@ -24,7 +24,7 @@ struct omap_irda_config {
24 /* Very specific to the needs of some platforms (h3,h4) 24 /* Very specific to the needs of some platforms (h3,h4)
25 * having calls which can sleep in irda_set_speed. 25 * having calls which can sleep in irda_set_speed.
26 */ 26 */
27 struct work_struct gpio_expa; 27 struct delayed_work gpio_expa;
28 int rx_channel; 28 int rx_channel;
29 int tx_channel; 29 int tx_channel;
30 unsigned long dest_start; 30 unsigned long dest_start;
diff --git a/include/asm-avr32/types.h b/include/asm-avr32/types.h
index 3f47db9675af..2bff153a32ed 100644
--- a/include/asm-avr32/types.h
+++ b/include/asm-avr32/types.h
@@ -57,11 +57,6 @@ typedef unsigned long long u64;
57 57
58typedef u32 dma_addr_t; 58typedef u32 dma_addr_t;
59 59
60#ifdef CONFIG_LBD
61typedef u64 sector_t;
62#define HAVE_SECTOR_T
63#endif
64
65#endif /* __ASSEMBLY__ */ 60#endif /* __ASSEMBLY__ */
66 61
67#endif /* __KERNEL__ */ 62#endif /* __KERNEL__ */
diff --git a/include/asm-h8300/types.h b/include/asm-h8300/types.h
index da2402b86540..2a8b1b2be782 100644
--- a/include/asm-h8300/types.h
+++ b/include/asm-h8300/types.h
@@ -55,12 +55,6 @@ typedef unsigned long long u64;
55 55
56typedef u32 dma_addr_t; 56typedef u32 dma_addr_t;
57 57
58#define HAVE_SECTOR_T
59typedef u64 sector_t;
60
61#define HAVE_BLKCNT_T
62typedef u64 blkcnt_t;
63
64#endif /* __KERNEL__ */ 58#endif /* __KERNEL__ */
65 59
66#endif /* __ASSEMBLY__ */ 60#endif /* __ASSEMBLY__ */
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index 51a166242522..a6c024e2506f 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -14,7 +14,7 @@
14 * on us. We need to use _exactly_ the address the user gave us, 14 * on us. We need to use _exactly_ the address the user gave us,
15 * not some alias that contains the same information. 15 * not some alias that contains the same information.
16 */ 16 */
17typedef struct { volatile int counter; } atomic_t; 17typedef struct { int counter; } atomic_t;
18 18
19#define ATOMIC_INIT(i) { (i) } 19#define ATOMIC_INIT(i) { (i) }
20 20
diff --git a/include/asm-i386/spinlock_types.h b/include/asm-i386/spinlock_types.h
index 59efe849f351..4da9345c1500 100644
--- a/include/asm-i386/spinlock_types.h
+++ b/include/asm-i386/spinlock_types.h
@@ -6,13 +6,13 @@
6#endif 6#endif
7 7
8typedef struct { 8typedef struct {
9 volatile unsigned int slock; 9 unsigned int slock;
10} raw_spinlock_t; 10} raw_spinlock_t;
11 11
12#define __RAW_SPIN_LOCK_UNLOCKED { 1 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
13 13
14typedef struct { 14typedef struct {
15 volatile unsigned int lock; 15 unsigned int lock;
16} raw_rwlock_t; 16} raw_rwlock_t;
17 17
18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } 18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
diff --git a/include/asm-i386/types.h b/include/asm-i386/types.h
index 4b4b295ccdb9..ad0a55bd782f 100644
--- a/include/asm-i386/types.h
+++ b/include/asm-i386/types.h
@@ -57,16 +57,6 @@ typedef u32 dma_addr_t;
57#endif 57#endif
58typedef u64 dma64_addr_t; 58typedef u64 dma64_addr_t;
59 59
60#ifdef CONFIG_LBD
61typedef u64 sector_t;
62#define HAVE_SECTOR_T
63#endif
64
65#ifdef CONFIG_LSF
66typedef u64 blkcnt_t;
67#define HAVE_BLKCNT_T
68#endif
69
70#endif /* __ASSEMBLY__ */ 60#endif /* __ASSEMBLY__ */
71 61
72#endif /* __KERNEL__ */ 62#endif /* __KERNEL__ */
diff --git a/include/asm-m68knommu/irq.h b/include/asm-m68knommu/irq.h
index 45e7a2fd1689..7b8f874f8429 100644
--- a/include/asm-m68knommu/irq.h
+++ b/include/asm-m68knommu/irq.h
@@ -86,5 +86,6 @@ extern void (*mach_disable_irq)(unsigned int);
86#define enable_irq(x) do { } while (0) 86#define enable_irq(x) do { } while (0)
87#define disable_irq(x) do { } while (0) 87#define disable_irq(x) do { } while (0)
88#define disable_irq_nosync(x) disable_irq(x) 88#define disable_irq_nosync(x) disable_irq(x)
89#define irq_canonicalize(irq) (irq)
89 90
90#endif /* _M68K_IRQ_H_ */ 91#endif /* _M68K_IRQ_H_ */
diff --git a/include/asm-m68knommu/rtc.h b/include/asm-m68knommu/rtc.h
new file mode 100644
index 000000000000..eaf18ec83c8e
--- /dev/null
+++ b/include/asm-m68knommu/rtc.h
@@ -0,0 +1 @@
#include <asm-m68k/rtc.h>
diff --git a/include/asm-m68knommu/ucontext.h b/include/asm-m68knommu/ucontext.h
index 5d570cedbb02..713a27f901cd 100644
--- a/include/asm-m68knommu/ucontext.h
+++ b/include/asm-m68knommu/ucontext.h
@@ -5,21 +5,17 @@ typedef int greg_t;
5#define NGREG 18 5#define NGREG 18
6typedef greg_t gregset_t[NGREG]; 6typedef greg_t gregset_t[NGREG];
7 7
8#ifdef CONFIG_FPU
9typedef struct fpregset { 8typedef struct fpregset {
10 int f_pcr; 9 int f_pcr;
11 int f_psr; 10 int f_psr;
12 int f_fpiaddr; 11 int f_fpiaddr;
13 int f_fpregs[8][3]; 12 int f_fpregs[8][3];
14} fpregset_t; 13} fpregset_t;
15#endif
16 14
17struct mcontext { 15struct mcontext {
18 int version; 16 int version;
19 gregset_t gregs; 17 gregset_t gregs;
20#ifdef CONFIG_FPU
21 fpregset_t fpregs; 18 fpregset_t fpregs;
22#endif
23}; 19};
24 20
25#define MCONTEXT_VERSION 2 21#define MCONTEXT_VERSION 2
@@ -29,9 +25,7 @@ struct ucontext {
29 struct ucontext *uc_link; 25 struct ucontext *uc_link;
30 stack_t uc_stack; 26 stack_t uc_stack;
31 struct mcontext uc_mcontext; 27 struct mcontext uc_mcontext;
32#ifdef CONFIG_FPU
33 unsigned long uc_filler[80]; 28 unsigned long uc_filler[80];
34#endif
35 sigset_t uc_sigmask; /* mask last for extensibility */ 29 sigset_t uc_sigmask; /* mask last for extensibility */
36}; 30};
37 31
diff --git a/include/asm-mips/atomic.h b/include/asm-mips/atomic.h
index 7978d8e11647..c1a2409bb52a 100644
--- a/include/asm-mips/atomic.h
+++ b/include/asm-mips/atomic.h
@@ -15,6 +15,7 @@
15#define _ASM_ATOMIC_H 15#define _ASM_ATOMIC_H
16 16
17#include <linux/irqflags.h> 17#include <linux/irqflags.h>
18#include <asm/barrier.h>
18#include <asm/cpu-features.h> 19#include <asm/cpu-features.h>
19#include <asm/war.h> 20#include <asm/war.h>
20 21
@@ -130,6 +131,8 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
130{ 131{
131 unsigned long result; 132 unsigned long result;
132 133
134 smp_mb();
135
133 if (cpu_has_llsc && R10000_LLSC_WAR) { 136 if (cpu_has_llsc && R10000_LLSC_WAR) {
134 unsigned long temp; 137 unsigned long temp;
135 138
@@ -140,7 +143,6 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
140 " sc %0, %2 \n" 143 " sc %0, %2 \n"
141 " beqzl %0, 1b \n" 144 " beqzl %0, 1b \n"
142 " addu %0, %1, %3 \n" 145 " addu %0, %1, %3 \n"
143 " sync \n"
144 " .set mips0 \n" 146 " .set mips0 \n"
145 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 147 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
146 : "Ir" (i), "m" (v->counter) 148 : "Ir" (i), "m" (v->counter)
@@ -155,7 +157,6 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
155 " sc %0, %2 \n" 157 " sc %0, %2 \n"
156 " beqz %0, 1b \n" 158 " beqz %0, 1b \n"
157 " addu %0, %1, %3 \n" 159 " addu %0, %1, %3 \n"
158 " sync \n"
159 " .set mips0 \n" 160 " .set mips0 \n"
160 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 161 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
161 : "Ir" (i), "m" (v->counter) 162 : "Ir" (i), "m" (v->counter)
@@ -170,6 +171,8 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
170 local_irq_restore(flags); 171 local_irq_restore(flags);
171 } 172 }
172 173
174 smp_mb();
175
173 return result; 176 return result;
174} 177}
175 178
@@ -177,6 +180,8 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
177{ 180{
178 unsigned long result; 181 unsigned long result;
179 182
183 smp_mb();
184
180 if (cpu_has_llsc && R10000_LLSC_WAR) { 185 if (cpu_has_llsc && R10000_LLSC_WAR) {
181 unsigned long temp; 186 unsigned long temp;
182 187
@@ -187,7 +192,6 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
187 " sc %0, %2 \n" 192 " sc %0, %2 \n"
188 " beqzl %0, 1b \n" 193 " beqzl %0, 1b \n"
189 " subu %0, %1, %3 \n" 194 " subu %0, %1, %3 \n"
190 " sync \n"
191 " .set mips0 \n" 195 " .set mips0 \n"
192 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 196 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
193 : "Ir" (i), "m" (v->counter) 197 : "Ir" (i), "m" (v->counter)
@@ -202,7 +206,6 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
202 " sc %0, %2 \n" 206 " sc %0, %2 \n"
203 " beqz %0, 1b \n" 207 " beqz %0, 1b \n"
204 " subu %0, %1, %3 \n" 208 " subu %0, %1, %3 \n"
205 " sync \n"
206 " .set mips0 \n" 209 " .set mips0 \n"
207 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 210 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
208 : "Ir" (i), "m" (v->counter) 211 : "Ir" (i), "m" (v->counter)
@@ -217,6 +220,8 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
217 local_irq_restore(flags); 220 local_irq_restore(flags);
218 } 221 }
219 222
223 smp_mb();
224
220 return result; 225 return result;
221} 226}
222 227
@@ -232,6 +237,8 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
232{ 237{
233 unsigned long result; 238 unsigned long result;
234 239
240 smp_mb();
241
235 if (cpu_has_llsc && R10000_LLSC_WAR) { 242 if (cpu_has_llsc && R10000_LLSC_WAR) {
236 unsigned long temp; 243 unsigned long temp;
237 244
@@ -245,7 +252,6 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
245 " beqzl %0, 1b \n" 252 " beqzl %0, 1b \n"
246 " subu %0, %1, %3 \n" 253 " subu %0, %1, %3 \n"
247 " .set reorder \n" 254 " .set reorder \n"
248 " sync \n"
249 "1: \n" 255 "1: \n"
250 " .set mips0 \n" 256 " .set mips0 \n"
251 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 257 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
@@ -264,7 +270,6 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
264 " beqz %0, 1b \n" 270 " beqz %0, 1b \n"
265 " subu %0, %1, %3 \n" 271 " subu %0, %1, %3 \n"
266 " .set reorder \n" 272 " .set reorder \n"
267 " sync \n"
268 "1: \n" 273 "1: \n"
269 " .set mips0 \n" 274 " .set mips0 \n"
270 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 275 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
@@ -281,6 +286,8 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
281 local_irq_restore(flags); 286 local_irq_restore(flags);
282 } 287 }
283 288
289 smp_mb();
290
284 return result; 291 return result;
285} 292}
286 293
@@ -375,7 +382,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
375 382
376#ifdef CONFIG_64BIT 383#ifdef CONFIG_64BIT
377 384
378typedef struct { volatile __s64 counter; } atomic64_t; 385typedef struct { volatile long counter; } atomic64_t;
379 386
380#define ATOMIC64_INIT(i) { (i) } 387#define ATOMIC64_INIT(i) { (i) }
381 388
@@ -484,6 +491,8 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
484{ 491{
485 unsigned long result; 492 unsigned long result;
486 493
494 smp_mb();
495
487 if (cpu_has_llsc && R10000_LLSC_WAR) { 496 if (cpu_has_llsc && R10000_LLSC_WAR) {
488 unsigned long temp; 497 unsigned long temp;
489 498
@@ -494,7 +503,6 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
494 " scd %0, %2 \n" 503 " scd %0, %2 \n"
495 " beqzl %0, 1b \n" 504 " beqzl %0, 1b \n"
496 " addu %0, %1, %3 \n" 505 " addu %0, %1, %3 \n"
497 " sync \n"
498 " .set mips0 \n" 506 " .set mips0 \n"
499 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 507 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
500 : "Ir" (i), "m" (v->counter) 508 : "Ir" (i), "m" (v->counter)
@@ -509,7 +517,6 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
509 " scd %0, %2 \n" 517 " scd %0, %2 \n"
510 " beqz %0, 1b \n" 518 " beqz %0, 1b \n"
511 " addu %0, %1, %3 \n" 519 " addu %0, %1, %3 \n"
512 " sync \n"
513 " .set mips0 \n" 520 " .set mips0 \n"
514 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 521 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
515 : "Ir" (i), "m" (v->counter) 522 : "Ir" (i), "m" (v->counter)
@@ -524,6 +531,8 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
524 local_irq_restore(flags); 531 local_irq_restore(flags);
525 } 532 }
526 533
534 smp_mb();
535
527 return result; 536 return result;
528} 537}
529 538
@@ -531,6 +540,8 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
531{ 540{
532 unsigned long result; 541 unsigned long result;
533 542
543 smp_mb();
544
534 if (cpu_has_llsc && R10000_LLSC_WAR) { 545 if (cpu_has_llsc && R10000_LLSC_WAR) {
535 unsigned long temp; 546 unsigned long temp;
536 547
@@ -541,7 +552,6 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
541 " scd %0, %2 \n" 552 " scd %0, %2 \n"
542 " beqzl %0, 1b \n" 553 " beqzl %0, 1b \n"
543 " subu %0, %1, %3 \n" 554 " subu %0, %1, %3 \n"
544 " sync \n"
545 " .set mips0 \n" 555 " .set mips0 \n"
546 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 556 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
547 : "Ir" (i), "m" (v->counter) 557 : "Ir" (i), "m" (v->counter)
@@ -556,7 +566,6 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
556 " scd %0, %2 \n" 566 " scd %0, %2 \n"
557 " beqz %0, 1b \n" 567 " beqz %0, 1b \n"
558 " subu %0, %1, %3 \n" 568 " subu %0, %1, %3 \n"
559 " sync \n"
560 " .set mips0 \n" 569 " .set mips0 \n"
561 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 570 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
562 : "Ir" (i), "m" (v->counter) 571 : "Ir" (i), "m" (v->counter)
@@ -571,6 +580,8 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
571 local_irq_restore(flags); 580 local_irq_restore(flags);
572 } 581 }
573 582
583 smp_mb();
584
574 return result; 585 return result;
575} 586}
576 587
@@ -586,6 +597,8 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
586{ 597{
587 unsigned long result; 598 unsigned long result;
588 599
600 smp_mb();
601
589 if (cpu_has_llsc && R10000_LLSC_WAR) { 602 if (cpu_has_llsc && R10000_LLSC_WAR) {
590 unsigned long temp; 603 unsigned long temp;
591 604
@@ -599,7 +612,6 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
599 " beqzl %0, 1b \n" 612 " beqzl %0, 1b \n"
600 " dsubu %0, %1, %3 \n" 613 " dsubu %0, %1, %3 \n"
601 " .set reorder \n" 614 " .set reorder \n"
602 " sync \n"
603 "1: \n" 615 "1: \n"
604 " .set mips0 \n" 616 " .set mips0 \n"
605 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 617 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
@@ -618,7 +630,6 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
618 " beqz %0, 1b \n" 630 " beqz %0, 1b \n"
619 " dsubu %0, %1, %3 \n" 631 " dsubu %0, %1, %3 \n"
620 " .set reorder \n" 632 " .set reorder \n"
621 " sync \n"
622 "1: \n" 633 "1: \n"
623 " .set mips0 \n" 634 " .set mips0 \n"
624 : "=&r" (result), "=&r" (temp), "=m" (v->counter) 635 : "=&r" (result), "=&r" (temp), "=m" (v->counter)
@@ -635,6 +646,8 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
635 local_irq_restore(flags); 646 local_irq_restore(flags);
636 } 647 }
637 648
649 smp_mb();
650
638 return result; 651 return result;
639} 652}
640 653
diff --git a/include/asm-mips/barrier.h b/include/asm-mips/barrier.h
new file mode 100644
index 000000000000..ed82631b0017
--- /dev/null
+++ b/include/asm-mips/barrier.h
@@ -0,0 +1,132 @@
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) 2006 by Ralf Baechle (ralf@linux-mips.org)
7 */
8#ifndef __ASM_BARRIER_H
9#define __ASM_BARRIER_H
10
11/*
12 * read_barrier_depends - Flush all pending reads that subsequents reads
13 * depend on.
14 *
15 * No data-dependent reads from memory-like regions are ever reordered
16 * over this barrier. All reads preceding this primitive are guaranteed
17 * to access memory (but not necessarily other CPUs' caches) before any
18 * reads following this primitive that depend on the data return by
19 * any of the preceding reads. This primitive is much lighter weight than
20 * rmb() on most CPUs, and is never heavier weight than is
21 * rmb().
22 *
23 * These ordering constraints are respected by both the local CPU
24 * and the compiler.
25 *
26 * Ordering is not guaranteed by anything other than these primitives,
27 * not even by data dependencies. See the documentation for
28 * memory_barrier() for examples and URLs to more information.
29 *
30 * For example, the following code would force ordering (the initial
31 * value of "a" is zero, "b" is one, and "p" is "&a"):
32 *
33 * <programlisting>
34 * CPU 0 CPU 1
35 *
36 * b = 2;
37 * memory_barrier();
38 * p = &b; q = p;
39 * read_barrier_depends();
40 * d = *q;
41 * </programlisting>
42 *
43 * because the read of "*q" depends on the read of "p" and these
44 * two reads are separated by a read_barrier_depends(). However,
45 * the following code, with the same initial values for "a" and "b":
46 *
47 * <programlisting>
48 * CPU 0 CPU 1
49 *
50 * a = 2;
51 * memory_barrier();
52 * b = 3; y = b;
53 * read_barrier_depends();
54 * x = a;
55 * </programlisting>
56 *
57 * does not enforce ordering, since there is no data dependency between
58 * the read of "a" and the read of "b". Therefore, on some CPUs, such
59 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
60 * in cases like this where there are no data dependencies.
61 */
62
63#define read_barrier_depends() do { } while(0)
64#define smp_read_barrier_depends() do { } while(0)
65
66#ifdef CONFIG_CPU_HAS_SYNC
67#define __sync() \
68 __asm__ __volatile__( \
69 ".set push\n\t" \
70 ".set noreorder\n\t" \
71 ".set mips2\n\t" \
72 "sync\n\t" \
73 ".set pop" \
74 : /* no output */ \
75 : /* no input */ \
76 : "memory")
77#else
78#define __sync() do { } while(0)
79#endif
80
81#define __fast_iob() \
82 __asm__ __volatile__( \
83 ".set push\n\t" \
84 ".set noreorder\n\t" \
85 "lw $0,%0\n\t" \
86 "nop\n\t" \
87 ".set pop" \
88 : /* no output */ \
89 : "m" (*(int *)CKSEG1) \
90 : "memory")
91
92#define fast_wmb() __sync()
93#define fast_rmb() __sync()
94#define fast_mb() __sync()
95#define fast_iob() \
96 do { \
97 __sync(); \
98 __fast_iob(); \
99 } while (0)
100
101#ifdef CONFIG_CPU_HAS_WB
102
103#include <asm/wbflush.h>
104
105#define wmb() fast_wmb()
106#define rmb() fast_rmb()
107#define mb() wbflush()
108#define iob() wbflush()
109
110#else /* !CONFIG_CPU_HAS_WB */
111
112#define wmb() fast_wmb()
113#define rmb() fast_rmb()
114#define mb() fast_mb()
115#define iob() fast_iob()
116
117#endif /* !CONFIG_CPU_HAS_WB */
118
119#if defined(CONFIG_WEAK_ORDERING) && defined(CONFIG_SMP)
120#define __WEAK_ORDERING_MB " sync \n"
121#else
122#define __WEAK_ORDERING_MB " \n"
123#endif
124
125#define smp_mb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
126#define smp_rmb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
127#define smp_wmb() __asm__ __volatile__(__WEAK_ORDERING_MB : : :"memory")
128
129#define set_mb(var, value) \
130 do { var = value; smp_mb(); } while (0)
131
132#endif /* __ASM_BARRIER_H */
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index b9007411b60f..06445de1324b 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 1994 - 1997, 1999, 2000 Ralf Baechle (ralf@gnu.org) 6 * Copyright (c) 1994 - 1997, 1999, 2000, 06 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc. 7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc.
8 */ 8 */
9#ifndef _ASM_BITOPS_H 9#ifndef _ASM_BITOPS_H
@@ -12,6 +12,7 @@
12#include <linux/compiler.h> 12#include <linux/compiler.h>
13#include <linux/irqflags.h> 13#include <linux/irqflags.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <asm/barrier.h>
15#include <asm/bug.h> 16#include <asm/bug.h>
16#include <asm/byteorder.h> /* sigh ... */ 17#include <asm/byteorder.h> /* sigh ... */
17#include <asm/cpu-features.h> 18#include <asm/cpu-features.h>
@@ -204,9 +205,6 @@ static inline int test_and_set_bit(unsigned long nr,
204 " " __SC "%2, %1 \n" 205 " " __SC "%2, %1 \n"
205 " beqzl %2, 1b \n" 206 " beqzl %2, 1b \n"
206 " and %2, %0, %3 \n" 207 " and %2, %0, %3 \n"
207#ifdef CONFIG_SMP
208 " sync \n"
209#endif
210 " .set mips0 \n" 208 " .set mips0 \n"
211 : "=&r" (temp), "=m" (*m), "=&r" (res) 209 : "=&r" (temp), "=m" (*m), "=&r" (res)
212 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 210 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -226,9 +224,6 @@ static inline int test_and_set_bit(unsigned long nr,
226 " " __SC "%2, %1 \n" 224 " " __SC "%2, %1 \n"
227 " beqz %2, 1b \n" 225 " beqz %2, 1b \n"
228 " and %2, %0, %3 \n" 226 " and %2, %0, %3 \n"
229#ifdef CONFIG_SMP
230 " sync \n"
231#endif
232 " .set pop \n" 227 " .set pop \n"
233 : "=&r" (temp), "=m" (*m), "=&r" (res) 228 : "=&r" (temp), "=m" (*m), "=&r" (res)
234 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 229 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -250,6 +245,8 @@ static inline int test_and_set_bit(unsigned long nr,
250 245
251 return retval; 246 return retval;
252 } 247 }
248
249 smp_mb();
253} 250}
254 251
255/* 252/*
@@ -275,9 +272,6 @@ static inline int test_and_clear_bit(unsigned long nr,
275 " " __SC "%2, %1 \n" 272 " " __SC "%2, %1 \n"
276 " beqzl %2, 1b \n" 273 " beqzl %2, 1b \n"
277 " and %2, %0, %3 \n" 274 " and %2, %0, %3 \n"
278#ifdef CONFIG_SMP
279 " sync \n"
280#endif
281 " .set mips0 \n" 275 " .set mips0 \n"
282 : "=&r" (temp), "=m" (*m), "=&r" (res) 276 : "=&r" (temp), "=m" (*m), "=&r" (res)
283 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 277 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -298,9 +292,6 @@ static inline int test_and_clear_bit(unsigned long nr,
298 " " __SC "%2, %1 \n" 292 " " __SC "%2, %1 \n"
299 " beqz %2, 1b \n" 293 " beqz %2, 1b \n"
300 " and %2, %0, %3 \n" 294 " and %2, %0, %3 \n"
301#ifdef CONFIG_SMP
302 " sync \n"
303#endif
304 " .set pop \n" 295 " .set pop \n"
305 : "=&r" (temp), "=m" (*m), "=&r" (res) 296 : "=&r" (temp), "=m" (*m), "=&r" (res)
306 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 297 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -322,6 +313,8 @@ static inline int test_and_clear_bit(unsigned long nr,
322 313
323 return retval; 314 return retval;
324 } 315 }
316
317 smp_mb();
325} 318}
326 319
327/* 320/*
@@ -346,9 +339,6 @@ static inline int test_and_change_bit(unsigned long nr,
346 " " __SC "%2, %1 \n" 339 " " __SC "%2, %1 \n"
347 " beqzl %2, 1b \n" 340 " beqzl %2, 1b \n"
348 " and %2, %0, %3 \n" 341 " and %2, %0, %3 \n"
349#ifdef CONFIG_SMP
350 " sync \n"
351#endif
352 " .set mips0 \n" 342 " .set mips0 \n"
353 : "=&r" (temp), "=m" (*m), "=&r" (res) 343 : "=&r" (temp), "=m" (*m), "=&r" (res)
354 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 344 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -368,9 +358,6 @@ static inline int test_and_change_bit(unsigned long nr,
368 " " __SC "\t%2, %1 \n" 358 " " __SC "\t%2, %1 \n"
369 " beqz %2, 1b \n" 359 " beqz %2, 1b \n"
370 " and %2, %0, %3 \n" 360 " and %2, %0, %3 \n"
371#ifdef CONFIG_SMP
372 " sync \n"
373#endif
374 " .set pop \n" 361 " .set pop \n"
375 : "=&r" (temp), "=m" (*m), "=&r" (res) 362 : "=&r" (temp), "=m" (*m), "=&r" (res)
376 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m) 363 : "r" (1UL << (nr & SZLONG_MASK)), "m" (*m)
@@ -391,6 +378,8 @@ static inline int test_and_change_bit(unsigned long nr,
391 378
392 return retval; 379 return retval;
393 } 380 }
381
382 smp_mb();
394} 383}
395 384
396#include <asm-generic/bitops/non-atomic.h> 385#include <asm-generic/bitops/non-atomic.h>
diff --git a/include/asm-mips/compat.h b/include/asm-mips/compat.h
index 900f472fdd2b..55a0152feb08 100644
--- a/include/asm-mips/compat.h
+++ b/include/asm-mips/compat.h
@@ -32,6 +32,7 @@ typedef struct {
32 s32 val[2]; 32 s32 val[2];
33} compat_fsid_t; 33} compat_fsid_t;
34typedef s32 compat_timer_t; 34typedef s32 compat_timer_t;
35typedef s32 compat_key_t;
35 36
36typedef s32 compat_int_t; 37typedef s32 compat_int_t;
37typedef s32 compat_long_t; 38typedef s32 compat_long_t;
@@ -146,4 +147,71 @@ static inline void __user *compat_alloc_user_space(long len)
146 return (void __user *) (regs->regs[29] - len); 147 return (void __user *) (regs->regs[29] - len);
147} 148}
148 149
150struct compat_ipc64_perm {
151 compat_key_t key;
152 __compat_uid32_t uid;
153 __compat_gid32_t gid;
154 __compat_uid32_t cuid;
155 __compat_gid32_t cgid;
156 compat_mode_t mode;
157 unsigned short seq;
158 unsigned short __pad2;
159 compat_ulong_t __unused1;
160 compat_ulong_t __unused2;
161};
162
163struct compat_semid64_ds {
164 struct compat_ipc64_perm sem_perm;
165 compat_time_t sem_otime;
166 compat_time_t sem_ctime;
167 compat_ulong_t sem_nsems;
168 compat_ulong_t __unused1;
169 compat_ulong_t __unused2;
170};
171
172struct compat_msqid64_ds {
173 struct compat_ipc64_perm msg_perm;
174#ifndef CONFIG_CPU_LITTLE_ENDIAN
175 compat_ulong_t __unused1;
176#endif
177 compat_time_t msg_stime;
178#ifdef CONFIG_CPU_LITTLE_ENDIAN
179 compat_ulong_t __unused1;
180#endif
181#ifndef CONFIG_CPU_LITTLE_ENDIAN
182 compat_ulong_t __unused2;
183#endif
184 compat_time_t msg_rtime;
185#ifdef CONFIG_CPU_LITTLE_ENDIAN
186 compat_ulong_t __unused2;
187#endif
188#ifndef CONFIG_CPU_LITTLE_ENDIAN
189 compat_ulong_t __unused3;
190#endif
191 compat_time_t msg_ctime;
192#ifdef CONFIG_CPU_LITTLE_ENDIAN
193 compat_ulong_t __unused3;
194#endif
195 compat_ulong_t msg_cbytes;
196 compat_ulong_t msg_qnum;
197 compat_ulong_t msg_qbytes;
198 compat_pid_t msg_lspid;
199 compat_pid_t msg_lrpid;
200 compat_ulong_t __unused4;
201 compat_ulong_t __unused5;
202};
203
204struct compat_shmid64_ds {
205 struct compat_ipc64_perm shm_perm;
206 compat_size_t shm_segsz;
207 compat_time_t shm_atime;
208 compat_time_t shm_dtime;
209 compat_time_t shm_ctime;
210 compat_pid_t shm_cpid;
211 compat_pid_t shm_lpid;
212 compat_ulong_t shm_nattch;
213 compat_ulong_t __unused1;
214 compat_ulong_t __unused2;
215};
216
149#endif /* _ASM_COMPAT_H */ 217#endif /* _ASM_COMPAT_H */
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index ed023eae0674..927a216bd530 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -1,19 +1,21 @@
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) 2006 Ralf Baechle (ralf@linux-mips.org)
7 */
1#ifndef _ASM_FUTEX_H 8#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H 9#define _ASM_FUTEX_H
3 10
4#ifdef __KERNEL__ 11#ifdef __KERNEL__
5 12
6#include <linux/futex.h> 13#include <linux/futex.h>
14#include <asm/barrier.h>
7#include <asm/errno.h> 15#include <asm/errno.h>
8#include <asm/uaccess.h> 16#include <asm/uaccess.h>
9#include <asm/war.h> 17#include <asm/war.h>
10 18
11#ifdef CONFIG_SMP
12#define __FUTEX_SMP_SYNC " sync \n"
13#else
14#define __FUTEX_SMP_SYNC
15#endif
16
17#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
18{ \ 20{ \
19 if (cpu_has_llsc && R10000_LLSC_WAR) { \ 21 if (cpu_has_llsc && R10000_LLSC_WAR) { \
@@ -27,7 +29,7 @@
27 " .set mips3 \n" \ 29 " .set mips3 \n" \
28 "2: sc $1, %2 \n" \ 30 "2: sc $1, %2 \n" \
29 " beqzl $1, 1b \n" \ 31 " beqzl $1, 1b \n" \
30 __FUTEX_SMP_SYNC \ 32 __WEAK_ORDERING_MB \
31 "3: \n" \ 33 "3: \n" \
32 " .set pop \n" \ 34 " .set pop \n" \
33 " .set mips0 \n" \ 35 " .set mips0 \n" \
@@ -53,7 +55,7 @@
53 " .set mips3 \n" \ 55 " .set mips3 \n" \
54 "2: sc $1, %2 \n" \ 56 "2: sc $1, %2 \n" \
55 " beqz $1, 1b \n" \ 57 " beqz $1, 1b \n" \
56 __FUTEX_SMP_SYNC \ 58 __WEAK_ORDERING_MB \
57 "3: \n" \ 59 "3: \n" \
58 " .set pop \n" \ 60 " .set pop \n" \
59 " .set mips0 \n" \ 61 " .set mips0 \n" \
@@ -150,7 +152,7 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
150 " .set mips3 \n" 152 " .set mips3 \n"
151 "2: sc $1, %1 \n" 153 "2: sc $1, %1 \n"
152 " beqzl $1, 1b \n" 154 " beqzl $1, 1b \n"
153 __FUTEX_SMP_SYNC 155 __WEAK_ORDERING_MB
154 "3: \n" 156 "3: \n"
155 " .set pop \n" 157 " .set pop \n"
156 " .section .fixup,\"ax\" \n" 158 " .section .fixup,\"ax\" \n"
@@ -177,7 +179,7 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
177 " .set mips3 \n" 179 " .set mips3 \n"
178 "2: sc $1, %1 \n" 180 "2: sc $1, %1 \n"
179 " beqz $1, 1b \n" 181 " beqz $1, 1b \n"
180 __FUTEX_SMP_SYNC 182 __WEAK_ORDERING_MB
181 "3: \n" 183 "3: \n"
182 " .set pop \n" 184 " .set pop \n"
183 " .section .fixup,\"ax\" \n" 185 " .section .fixup,\"ax\" \n"
diff --git a/include/asm-mips/i8259.h b/include/asm-mips/i8259.h
index 0214abe3f0af..4df8d8b118c0 100644
--- a/include/asm-mips/i8259.h
+++ b/include/asm-mips/i8259.h
@@ -19,10 +19,31 @@
19 19
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22/* i8259A PIC registers */
23#define PIC_MASTER_CMD 0x20
24#define PIC_MASTER_IMR 0x21
25#define PIC_MASTER_ISR PIC_MASTER_CMD
26#define PIC_MASTER_POLL PIC_MASTER_ISR
27#define PIC_MASTER_OCW3 PIC_MASTER_ISR
28#define PIC_SLAVE_CMD 0xa0
29#define PIC_SLAVE_IMR 0xa1
30
31/* i8259A PIC related value */
32#define PIC_CASCADE_IR 2
33#define MASTER_ICW4_DEFAULT 0x01
34#define SLAVE_ICW4_DEFAULT 0x01
35#define PIC_ICW4_AEOI 2
36
22extern spinlock_t i8259A_lock; 37extern spinlock_t i8259A_lock;
23 38
39extern void init_8259A(int auto_eoi);
40extern void enable_8259A_irq(unsigned int irq);
41extern void disable_8259A_irq(unsigned int irq);
42
24extern void init_i8259_irqs(void); 43extern void init_i8259_irqs(void);
25 44
45#define I8259A_IRQ_BASE 0
46
26/* 47/*
27 * Do the traditional i8259 interrupt polling thing. This is for the few 48 * Do the traditional i8259 interrupt polling thing. This is for the few
28 * cases where no better interrupt acknowledge method is available and we 49 * cases where no better interrupt acknowledge method is available and we
@@ -35,15 +56,15 @@ static inline int i8259_irq(void)
35 spin_lock(&i8259A_lock); 56 spin_lock(&i8259A_lock);
36 57
37 /* Perform an interrupt acknowledge cycle on controller 1. */ 58 /* Perform an interrupt acknowledge cycle on controller 1. */
38 outb(0x0C, 0x20); /* prepare for poll */ 59 outb(0x0C, PIC_MASTER_CMD); /* prepare for poll */
39 irq = inb(0x20) & 7; 60 irq = inb(PIC_MASTER_CMD) & 7;
40 if (irq == 2) { 61 if (irq == PIC_CASCADE_IR) {
41 /* 62 /*
42 * Interrupt is cascaded so perform interrupt 63 * Interrupt is cascaded so perform interrupt
43 * acknowledge on controller 2. 64 * acknowledge on controller 2.
44 */ 65 */
45 outb(0x0C, 0xA0); /* prepare for poll */ 66 outb(0x0C, PIC_SLAVE_CMD); /* prepare for poll */
46 irq = (inb(0xA0) & 7) + 8; 67 irq = (inb(PIC_SLAVE_CMD) & 7) + 8;
47 } 68 }
48 69
49 if (unlikely(irq == 7)) { 70 if (unlikely(irq == 7)) {
@@ -54,14 +75,14 @@ static inline int i8259_irq(void)
54 * significant bit is not set then there is no valid 75 * significant bit is not set then there is no valid
55 * interrupt. 76 * interrupt.
56 */ 77 */
57 outb(0x0B, 0x20); /* ISR register */ 78 outb(0x0B, PIC_MASTER_ISR); /* ISR register */
58 if(~inb(0x20) & 0x80) 79 if(~inb(PIC_MASTER_ISR) & 0x80)
59 irq = -1; 80 irq = -1;
60 } 81 }
61 82
62 spin_unlock(&i8259A_lock); 83 spin_unlock(&i8259A_lock);
63 84
64 return irq; 85 return likely(irq >= 0) ? irq + I8259A_IRQ_BASE : irq;
65} 86}
66 87
67#endif /* _ASM_I8259_H */ 88#endif /* _ASM_I8259_H */
diff --git a/include/asm-mips/pgtable-32.h b/include/asm-mips/pgtable-32.h
index d20f2e9b28be..2fbd47eba32d 100644
--- a/include/asm-mips/pgtable-32.h
+++ b/include/asm-mips/pgtable-32.h
@@ -156,9 +156,9 @@ pfn_pte(unsigned long pfn, pgprot_t prot)
156#define __pte_offset(address) \ 156#define __pte_offset(address) \
157 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 157 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
158#define pte_offset(dir, address) \ 158#define pte_offset(dir, address) \
159 ((pte_t *) (pmd_page_vaddr(*dir)) + __pte_offset(address)) 159 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
160#define pte_offset_kernel(dir, address) \ 160#define pte_offset_kernel(dir, address) \
161 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 161 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
162 162
163#define pte_offset_map(dir, address) \ 163#define pte_offset_map(dir, address) \
164 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 164 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index b9b1e86493ee..a5b18710b6a4 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -212,9 +212,9 @@ static inline pmd_t *pmd_offset(pud_t * pud, unsigned long address)
212#define __pte_offset(address) \ 212#define __pte_offset(address) \
213 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 213 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
214#define pte_offset(dir, address) \ 214#define pte_offset(dir, address) \
215 ((pte_t *) (pmd_page_vaddr(*dir)) + __pte_offset(address)) 215 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
216#define pte_offset_kernel(dir, address) \ 216#define pte_offset_kernel(dir, address) \
217 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address)) 217 ((pte_t *) pmd_page_vaddr(*(dir)) + __pte_offset(address))
218#define pte_offset_map(dir, address) \ 218#define pte_offset_map(dir, address) \
219 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address)) 219 ((pte_t *)page_address(pmd_page(*(dir))) + __pte_offset(address))
220#define pte_offset_map_nested(dir, address) \ 220#define pte_offset_map_nested(dir, address) \
diff --git a/include/asm-mips/sn/klconfig.h b/include/asm-mips/sn/klconfig.h
index b63cd0655b3d..15d70ca56187 100644
--- a/include/asm-mips/sn/klconfig.h
+++ b/include/asm-mips/sn/klconfig.h
@@ -176,7 +176,7 @@ typedef struct kl_config_hdr {
176/* --- New Macros for the changed kl_config_hdr_t structure --- */ 176/* --- New Macros for the changed kl_config_hdr_t structure --- */
177 177
178#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\ 178#define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\
179 (unsigned long)_k + (_k->ch_malloc_hdr_off))) 179 ((unsigned long)_k + (_k->ch_malloc_hdr_off)))
180 180
181#define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n)) 181#define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
182 182
diff --git a/include/asm-mips/spinlock.h b/include/asm-mips/spinlock.h
index c8d5587467bb..fc3217fc1118 100644
--- a/include/asm-mips/spinlock.h
+++ b/include/asm-mips/spinlock.h
@@ -3,12 +3,13 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1999, 2000 by Ralf Baechle 6 * Copyright (C) 1999, 2000, 06 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 */ 8 */
9#ifndef _ASM_SPINLOCK_H 9#ifndef _ASM_SPINLOCK_H
10#define _ASM_SPINLOCK_H 10#define _ASM_SPINLOCK_H
11 11
12#include <asm/barrier.h>
12#include <asm/war.h> 13#include <asm/war.h>
13 14
14/* 15/*
@@ -40,7 +41,6 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
40 " sc %1, %0 \n" 41 " sc %1, %0 \n"
41 " beqzl %1, 1b \n" 42 " beqzl %1, 1b \n"
42 " nop \n" 43 " nop \n"
43 " sync \n"
44 " .set reorder \n" 44 " .set reorder \n"
45 : "=m" (lock->lock), "=&r" (tmp) 45 : "=m" (lock->lock), "=&r" (tmp)
46 : "m" (lock->lock) 46 : "m" (lock->lock)
@@ -53,19 +53,22 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
53 " li %1, 1 \n" 53 " li %1, 1 \n"
54 " sc %1, %0 \n" 54 " sc %1, %0 \n"
55 " beqz %1, 1b \n" 55 " beqz %1, 1b \n"
56 " sync \n" 56 " nop \n"
57 " .set reorder \n" 57 " .set reorder \n"
58 : "=m" (lock->lock), "=&r" (tmp) 58 : "=m" (lock->lock), "=&r" (tmp)
59 : "m" (lock->lock) 59 : "m" (lock->lock)
60 : "memory"); 60 : "memory");
61 } 61 }
62
63 smp_mb();
62} 64}
63 65
64static inline void __raw_spin_unlock(raw_spinlock_t *lock) 66static inline void __raw_spin_unlock(raw_spinlock_t *lock)
65{ 67{
68 smp_mb();
69
66 __asm__ __volatile__( 70 __asm__ __volatile__(
67 " .set noreorder # __raw_spin_unlock \n" 71 " .set noreorder # __raw_spin_unlock \n"
68 " sync \n"
69 " sw $0, %0 \n" 72 " sw $0, %0 \n"
70 " .set\treorder \n" 73 " .set\treorder \n"
71 : "=m" (lock->lock) 74 : "=m" (lock->lock)
@@ -86,7 +89,6 @@ static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
86 " beqzl %2, 1b \n" 89 " beqzl %2, 1b \n"
87 " nop \n" 90 " nop \n"
88 " andi %2, %0, 1 \n" 91 " andi %2, %0, 1 \n"
89 " sync \n"
90 " .set reorder" 92 " .set reorder"
91 : "=&r" (temp), "=m" (lock->lock), "=&r" (res) 93 : "=&r" (temp), "=m" (lock->lock), "=&r" (res)
92 : "m" (lock->lock) 94 : "m" (lock->lock)
@@ -99,13 +101,14 @@ static inline unsigned int __raw_spin_trylock(raw_spinlock_t *lock)
99 " sc %2, %1 \n" 101 " sc %2, %1 \n"
100 " beqz %2, 1b \n" 102 " beqz %2, 1b \n"
101 " andi %2, %0, 1 \n" 103 " andi %2, %0, 1 \n"
102 " sync \n"
103 " .set reorder" 104 " .set reorder"
104 : "=&r" (temp), "=m" (lock->lock), "=&r" (res) 105 : "=&r" (temp), "=m" (lock->lock), "=&r" (res)
105 : "m" (lock->lock) 106 : "m" (lock->lock)
106 : "memory"); 107 : "memory");
107 } 108 }
108 109
110 smp_mb();
111
109 return res == 0; 112 return res == 0;
110} 113}
111 114
@@ -143,7 +146,6 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
143 " sc %1, %0 \n" 146 " sc %1, %0 \n"
144 " beqzl %1, 1b \n" 147 " beqzl %1, 1b \n"
145 " nop \n" 148 " nop \n"
146 " sync \n"
147 " .set reorder \n" 149 " .set reorder \n"
148 : "=m" (rw->lock), "=&r" (tmp) 150 : "=m" (rw->lock), "=&r" (tmp)
149 : "m" (rw->lock) 151 : "m" (rw->lock)
@@ -156,12 +158,14 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)
156 " addu %1, 1 \n" 158 " addu %1, 1 \n"
157 " sc %1, %0 \n" 159 " sc %1, %0 \n"
158 " beqz %1, 1b \n" 160 " beqz %1, 1b \n"
159 " sync \n" 161 " nop \n"
160 " .set reorder \n" 162 " .set reorder \n"
161 : "=m" (rw->lock), "=&r" (tmp) 163 : "=m" (rw->lock), "=&r" (tmp)
162 : "m" (rw->lock) 164 : "m" (rw->lock)
163 : "memory"); 165 : "memory");
164 } 166 }
167
168 smp_mb();
165} 169}
166 170
167/* Note the use of sub, not subu which will make the kernel die with an 171/* Note the use of sub, not subu which will make the kernel die with an
@@ -171,13 +175,14 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
171{ 175{
172 unsigned int tmp; 176 unsigned int tmp;
173 177
178 smp_mb();
179
174 if (R10000_LLSC_WAR) { 180 if (R10000_LLSC_WAR) {
175 __asm__ __volatile__( 181 __asm__ __volatile__(
176 "1: ll %1, %2 # __raw_read_unlock \n" 182 "1: ll %1, %2 # __raw_read_unlock \n"
177 " sub %1, 1 \n" 183 " sub %1, 1 \n"
178 " sc %1, %0 \n" 184 " sc %1, %0 \n"
179 " beqzl %1, 1b \n" 185 " beqzl %1, 1b \n"
180 " sync \n"
181 : "=m" (rw->lock), "=&r" (tmp) 186 : "=m" (rw->lock), "=&r" (tmp)
182 : "m" (rw->lock) 187 : "m" (rw->lock)
183 : "memory"); 188 : "memory");
@@ -188,7 +193,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw)
188 " sub %1, 1 \n" 193 " sub %1, 1 \n"
189 " sc %1, %0 \n" 194 " sc %1, %0 \n"
190 " beqz %1, 1b \n" 195 " beqz %1, 1b \n"
191 " sync \n" 196 " nop \n"
192 " .set reorder \n" 197 " .set reorder \n"
193 : "=m" (rw->lock), "=&r" (tmp) 198 : "=m" (rw->lock), "=&r" (tmp)
194 : "m" (rw->lock) 199 : "m" (rw->lock)
@@ -208,7 +213,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
208 " lui %1, 0x8000 \n" 213 " lui %1, 0x8000 \n"
209 " sc %1, %0 \n" 214 " sc %1, %0 \n"
210 " beqzl %1, 1b \n" 215 " beqzl %1, 1b \n"
211 " sync \n" 216 " nop \n"
212 " .set reorder \n" 217 " .set reorder \n"
213 : "=m" (rw->lock), "=&r" (tmp) 218 : "=m" (rw->lock), "=&r" (tmp)
214 : "m" (rw->lock) 219 : "m" (rw->lock)
@@ -221,18 +226,22 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)
221 " lui %1, 0x8000 \n" 226 " lui %1, 0x8000 \n"
222 " sc %1, %0 \n" 227 " sc %1, %0 \n"
223 " beqz %1, 1b \n" 228 " beqz %1, 1b \n"
224 " sync \n" 229 " nop \n"
225 " .set reorder \n" 230 " .set reorder \n"
226 : "=m" (rw->lock), "=&r" (tmp) 231 : "=m" (rw->lock), "=&r" (tmp)
227 : "m" (rw->lock) 232 : "m" (rw->lock)
228 : "memory"); 233 : "memory");
229 } 234 }
235
236 smp_mb();
230} 237}
231 238
232static inline void __raw_write_unlock(raw_rwlock_t *rw) 239static inline void __raw_write_unlock(raw_rwlock_t *rw)
233{ 240{
241 smp_mb();
242
234 __asm__ __volatile__( 243 __asm__ __volatile__(
235 " sync # __raw_write_unlock \n" 244 " # __raw_write_unlock \n"
236 " sw $0, %0 \n" 245 " sw $0, %0 \n"
237 : "=m" (rw->lock) 246 : "=m" (rw->lock)
238 : "m" (rw->lock) 247 : "m" (rw->lock)
@@ -252,11 +261,10 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
252 " bnez %1, 2f \n" 261 " bnez %1, 2f \n"
253 " addu %1, 1 \n" 262 " addu %1, 1 \n"
254 " sc %1, %0 \n" 263 " sc %1, %0 \n"
255 " beqzl %1, 1b \n"
256 " .set reorder \n" 264 " .set reorder \n"
257#ifdef CONFIG_SMP 265 " beqzl %1, 1b \n"
258 " sync \n" 266 " nop \n"
259#endif 267 __WEAK_ORDERING_MB
260 " li %2, 1 \n" 268 " li %2, 1 \n"
261 "2: \n" 269 "2: \n"
262 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret) 270 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
@@ -271,10 +279,9 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)
271 " addu %1, 1 \n" 279 " addu %1, 1 \n"
272 " sc %1, %0 \n" 280 " sc %1, %0 \n"
273 " beqz %1, 1b \n" 281 " beqz %1, 1b \n"
282 " nop \n"
274 " .set reorder \n" 283 " .set reorder \n"
275#ifdef CONFIG_SMP 284 __WEAK_ORDERING_MB
276 " sync \n"
277#endif
278 " li %2, 1 \n" 285 " li %2, 1 \n"
279 "2: \n" 286 "2: \n"
280 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret) 287 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
@@ -299,7 +306,8 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
299 " lui %1, 0x8000 \n" 306 " lui %1, 0x8000 \n"
300 " sc %1, %0 \n" 307 " sc %1, %0 \n"
301 " beqzl %1, 1b \n" 308 " beqzl %1, 1b \n"
302 " sync \n" 309 " nop \n"
310 __WEAK_ORDERING_MB
303 " li %2, 1 \n" 311 " li %2, 1 \n"
304 " .set reorder \n" 312 " .set reorder \n"
305 "2: \n" 313 "2: \n"
@@ -315,7 +323,8 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
315 " lui %1, 0x8000 \n" 323 " lui %1, 0x8000 \n"
316 " sc %1, %0 \n" 324 " sc %1, %0 \n"
317 " beqz %1, 1b \n" 325 " beqz %1, 1b \n"
318 " sync \n" 326 " nop \n"
327 __WEAK_ORDERING_MB
319 " li %2, 1 \n" 328 " li %2, 1 \n"
320 " .set reorder \n" 329 " .set reorder \n"
321 "2: \n" 330 "2: \n"
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h
index 3056feed5a36..9428057a50cf 100644
--- a/include/asm-mips/system.h
+++ b/include/asm-mips/system.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle 6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003, 06 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine 7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics 8 * Copyright (C) 1999 Silicon Graphics
9 * Kevin D. Kissell, kevink@mips.org and Carsten Langgaard, carstenl@mips.com 9 * Kevin D. Kissell, kevink@mips.org and Carsten Langgaard, carstenl@mips.com
@@ -16,132 +16,12 @@
16#include <linux/irqflags.h> 16#include <linux/irqflags.h>
17 17
18#include <asm/addrspace.h> 18#include <asm/addrspace.h>
19#include <asm/barrier.h>
19#include <asm/cpu-features.h> 20#include <asm/cpu-features.h>
20#include <asm/dsp.h> 21#include <asm/dsp.h>
21#include <asm/ptrace.h> 22#include <asm/ptrace.h>
22#include <asm/war.h> 23#include <asm/war.h>
23 24
24/*
25 * read_barrier_depends - Flush all pending reads that subsequents reads
26 * depend on.
27 *
28 * No data-dependent reads from memory-like regions are ever reordered
29 * over this barrier. All reads preceding this primitive are guaranteed
30 * to access memory (but not necessarily other CPUs' caches) before any
31 * reads following this primitive that depend on the data return by
32 * any of the preceding reads. This primitive is much lighter weight than
33 * rmb() on most CPUs, and is never heavier weight than is
34 * rmb().
35 *
36 * These ordering constraints are respected by both the local CPU
37 * and the compiler.
38 *
39 * Ordering is not guaranteed by anything other than these primitives,
40 * not even by data dependencies. See the documentation for
41 * memory_barrier() for examples and URLs to more information.
42 *
43 * For example, the following code would force ordering (the initial
44 * value of "a" is zero, "b" is one, and "p" is "&a"):
45 *
46 * <programlisting>
47 * CPU 0 CPU 1
48 *
49 * b = 2;
50 * memory_barrier();
51 * p = &b; q = p;
52 * read_barrier_depends();
53 * d = *q;
54 * </programlisting>
55 *
56 * because the read of "*q" depends on the read of "p" and these
57 * two reads are separated by a read_barrier_depends(). However,
58 * the following code, with the same initial values for "a" and "b":
59 *
60 * <programlisting>
61 * CPU 0 CPU 1
62 *
63 * a = 2;
64 * memory_barrier();
65 * b = 3; y = b;
66 * read_barrier_depends();
67 * x = a;
68 * </programlisting>
69 *
70 * does not enforce ordering, since there is no data dependency between
71 * the read of "a" and the read of "b". Therefore, on some CPUs, such
72 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
73 * in cases like this where there are no data dependencies.
74 */
75
76#define read_barrier_depends() do { } while(0)
77
78#ifdef CONFIG_CPU_HAS_SYNC
79#define __sync() \
80 __asm__ __volatile__( \
81 ".set push\n\t" \
82 ".set noreorder\n\t" \
83 ".set mips2\n\t" \
84 "sync\n\t" \
85 ".set pop" \
86 : /* no output */ \
87 : /* no input */ \
88 : "memory")
89#else
90#define __sync() do { } while(0)
91#endif
92
93#define __fast_iob() \
94 __asm__ __volatile__( \
95 ".set push\n\t" \
96 ".set noreorder\n\t" \
97 "lw $0,%0\n\t" \
98 "nop\n\t" \
99 ".set pop" \
100 : /* no output */ \
101 : "m" (*(int *)CKSEG1) \
102 : "memory")
103
104#define fast_wmb() __sync()
105#define fast_rmb() __sync()
106#define fast_mb() __sync()
107#define fast_iob() \
108 do { \
109 __sync(); \
110 __fast_iob(); \
111 } while (0)
112
113#ifdef CONFIG_CPU_HAS_WB
114
115#include <asm/wbflush.h>
116
117#define wmb() fast_wmb()
118#define rmb() fast_rmb()
119#define mb() wbflush()
120#define iob() wbflush()
121
122#else /* !CONFIG_CPU_HAS_WB */
123
124#define wmb() fast_wmb()
125#define rmb() fast_rmb()
126#define mb() fast_mb()
127#define iob() fast_iob()
128
129#endif /* !CONFIG_CPU_HAS_WB */
130
131#ifdef CONFIG_SMP
132#define smp_mb() mb()
133#define smp_rmb() rmb()
134#define smp_wmb() wmb()
135#define smp_read_barrier_depends() read_barrier_depends()
136#else
137#define smp_mb() barrier()
138#define smp_rmb() barrier()
139#define smp_wmb() barrier()
140#define smp_read_barrier_depends() do { } while(0)
141#endif
142
143#define set_mb(var, value) \
144do { var = value; mb(); } while (0)
145 25
146/* 26/*
147 * switch_to(n) should switch tasks to task nr n, first 27 * switch_to(n) should switch tasks to task nr n, first
@@ -217,9 +97,6 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
217 " .set mips3 \n" 97 " .set mips3 \n"
218 " sc %2, %1 \n" 98 " sc %2, %1 \n"
219 " beqzl %2, 1b \n" 99 " beqzl %2, 1b \n"
220#ifdef CONFIG_SMP
221 " sync \n"
222#endif
223 " .set mips0 \n" 100 " .set mips0 \n"
224 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 101 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
225 : "R" (*m), "Jr" (val) 102 : "R" (*m), "Jr" (val)
@@ -235,9 +112,6 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
235 " .set mips3 \n" 112 " .set mips3 \n"
236 " sc %2, %1 \n" 113 " sc %2, %1 \n"
237 " beqz %2, 1b \n" 114 " beqz %2, 1b \n"
238#ifdef CONFIG_SMP
239 " sync \n"
240#endif
241 " .set mips0 \n" 115 " .set mips0 \n"
242 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 116 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
243 : "R" (*m), "Jr" (val) 117 : "R" (*m), "Jr" (val)
@@ -251,6 +125,8 @@ static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
251 local_irq_restore(flags); /* implies memory barrier */ 125 local_irq_restore(flags); /* implies memory barrier */
252 } 126 }
253 127
128 smp_mb();
129
254 return retval; 130 return retval;
255} 131}
256 132
@@ -268,9 +144,6 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
268 " move %2, %z4 \n" 144 " move %2, %z4 \n"
269 " scd %2, %1 \n" 145 " scd %2, %1 \n"
270 " beqzl %2, 1b \n" 146 " beqzl %2, 1b \n"
271#ifdef CONFIG_SMP
272 " sync \n"
273#endif
274 " .set mips0 \n" 147 " .set mips0 \n"
275 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 148 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
276 : "R" (*m), "Jr" (val) 149 : "R" (*m), "Jr" (val)
@@ -284,9 +157,6 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
284 " move %2, %z4 \n" 157 " move %2, %z4 \n"
285 " scd %2, %1 \n" 158 " scd %2, %1 \n"
286 " beqz %2, 1b \n" 159 " beqz %2, 1b \n"
287#ifdef CONFIG_SMP
288 " sync \n"
289#endif
290 " .set mips0 \n" 160 " .set mips0 \n"
291 : "=&r" (retval), "=m" (*m), "=&r" (dummy) 161 : "=&r" (retval), "=m" (*m), "=&r" (dummy)
292 : "R" (*m), "Jr" (val) 162 : "R" (*m), "Jr" (val)
@@ -300,6 +170,8 @@ static inline __u64 __xchg_u64(volatile __u64 * m, __u64 val)
300 local_irq_restore(flags); /* implies memory barrier */ 170 local_irq_restore(flags); /* implies memory barrier */
301 } 171 }
302 172
173 smp_mb();
174
303 return retval; 175 return retval;
304} 176}
305#else 177#else
@@ -345,9 +217,6 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
345 " .set mips3 \n" 217 " .set mips3 \n"
346 " sc $1, %1 \n" 218 " sc $1, %1 \n"
347 " beqzl $1, 1b \n" 219 " beqzl $1, 1b \n"
348#ifdef CONFIG_SMP
349 " sync \n"
350#endif
351 "2: \n" 220 "2: \n"
352 " .set pop \n" 221 " .set pop \n"
353 : "=&r" (retval), "=R" (*m) 222 : "=&r" (retval), "=R" (*m)
@@ -365,9 +234,6 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
365 " .set mips3 \n" 234 " .set mips3 \n"
366 " sc $1, %1 \n" 235 " sc $1, %1 \n"
367 " beqz $1, 1b \n" 236 " beqz $1, 1b \n"
368#ifdef CONFIG_SMP
369 " sync \n"
370#endif
371 "2: \n" 237 "2: \n"
372 " .set pop \n" 238 " .set pop \n"
373 : "=&r" (retval), "=R" (*m) 239 : "=&r" (retval), "=R" (*m)
@@ -383,6 +249,8 @@ static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
383 local_irq_restore(flags); /* implies memory barrier */ 249 local_irq_restore(flags); /* implies memory barrier */
384 } 250 }
385 251
252 smp_mb();
253
386 return retval; 254 return retval;
387} 255}
388 256
@@ -402,9 +270,6 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
402 " move $1, %z4 \n" 270 " move $1, %z4 \n"
403 " scd $1, %1 \n" 271 " scd $1, %1 \n"
404 " beqzl $1, 1b \n" 272 " beqzl $1, 1b \n"
405#ifdef CONFIG_SMP
406 " sync \n"
407#endif
408 "2: \n" 273 "2: \n"
409 " .set pop \n" 274 " .set pop \n"
410 : "=&r" (retval), "=R" (*m) 275 : "=&r" (retval), "=R" (*m)
@@ -420,9 +285,6 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
420 " move $1, %z4 \n" 285 " move $1, %z4 \n"
421 " scd $1, %1 \n" 286 " scd $1, %1 \n"
422 " beqz $1, 1b \n" 287 " beqz $1, 1b \n"
423#ifdef CONFIG_SMP
424 " sync \n"
425#endif
426 "2: \n" 288 "2: \n"
427 " .set pop \n" 289 " .set pop \n"
428 : "=&r" (retval), "=R" (*m) 290 : "=&r" (retval), "=R" (*m)
@@ -438,6 +300,8 @@ static inline unsigned long __cmpxchg_u64(volatile int * m, unsigned long old,
438 local_irq_restore(flags); /* implies memory barrier */ 300 local_irq_restore(flags); /* implies memory barrier */
439 } 301 }
440 302
303 smp_mb();
304
441 return retval; 305 return retval;
442} 306}
443#else 307#else
diff --git a/include/asm-mips/types.h b/include/asm-mips/types.h
index 2b52e180c6f2..63a13c5bd832 100644
--- a/include/asm-mips/types.h
+++ b/include/asm-mips/types.h
@@ -93,16 +93,6 @@ typedef unsigned long long phys_t;
93typedef unsigned long phys_t; 93typedef unsigned long phys_t;
94#endif 94#endif
95 95
96#ifdef CONFIG_LBD
97typedef u64 sector_t;
98#define HAVE_SECTOR_T
99#endif
100
101#ifdef CONFIG_LSF
102typedef u64 blkcnt_t;
103#define HAVE_BLKCNT_T
104#endif
105
106#endif /* __ASSEMBLY__ */ 96#endif /* __ASSEMBLY__ */
107 97
108#endif /* __KERNEL__ */ 98#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/Kbuild b/include/asm-powerpc/Kbuild
index 9827849953a3..1e637381c118 100644
--- a/include/asm-powerpc/Kbuild
+++ b/include/asm-powerpc/Kbuild
@@ -17,6 +17,7 @@ header-y += ipc.h
17header-y += poll.h 17header-y += poll.h
18header-y += shmparam.h 18header-y += shmparam.h
19header-y += sockios.h 19header-y += sockios.h
20header-y += spu_info.h
20header-y += ucontext.h 21header-y += ucontext.h
21header-y += ioctl.h 22header-y += ioctl.h
22header-y += linkage.h 23header-y += linkage.h
diff --git a/include/asm-powerpc/cell-pmu.h b/include/asm-powerpc/cell-pmu.h
new file mode 100644
index 000000000000..e8c2ebd3ddda
--- /dev/null
+++ b/include/asm-powerpc/cell-pmu.h
@@ -0,0 +1,113 @@
1/*
2 * Cell Broadband Engine Performance Monitor
3 *
4 * (C) Copyright IBM Corporation 2006
5 *
6 * Author:
7 * David Erb (djerb@us.ibm.com)
8 * Kevin Corry (kevcorry@us.ibm.com)
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, or (at your option)
13 * 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#ifndef __ASM_CELL_PMU_H__
26#define __ASM_CELL_PMU_H__
27
28/* The Cell PMU has four hardware performance counters, which can be
29 * configured as four 32-bit counters or eight 16-bit counters.
30 */
31#define NR_PHYS_CTRS 4
32#define NR_CTRS (NR_PHYS_CTRS * 2)
33
34/* Macros for the pm_control register. */
35#define CBE_PM_16BIT_CTR(ctr) (1 << (24 - ((ctr) & (NR_PHYS_CTRS - 1))))
36#define CBE_PM_ENABLE_PERF_MON 0x80000000
37#define CBE_PM_STOP_AT_MAX 0x40000000
38#define CBE_PM_TRACE_MODE_GET(pm_control) (((pm_control) >> 28) & 0x3)
39#define CBE_PM_TRACE_MODE_SET(mode) (((mode) & 0x3) << 28)
40#define CBE_PM_COUNT_MODE_SET(count) (((count) & 0x3) << 18)
41#define CBE_PM_FREEZE_ALL_CTRS 0x00100000
42#define CBE_PM_ENABLE_EXT_TRACE 0x00008000
43
44/* Macros for the trace_address register. */
45#define CBE_PM_TRACE_BUF_FULL 0x00000800
46#define CBE_PM_TRACE_BUF_EMPTY 0x00000400
47#define CBE_PM_TRACE_BUF_DATA_COUNT(ta) ((ta) & 0x3ff)
48#define CBE_PM_TRACE_BUF_MAX_COUNT 0x400
49
50/* Macros for the pm07_control registers. */
51#define CBE_PM_CTR_INPUT_MUX(pm07_control) (((pm07_control) >> 26) & 0x3f)
52#define CBE_PM_CTR_INPUT_CONTROL 0x02000000
53#define CBE_PM_CTR_POLARITY 0x01000000
54#define CBE_PM_CTR_COUNT_CYCLES 0x00800000
55#define CBE_PM_CTR_ENABLE 0x00400000
56
57/* Macros for the pm_status register. */
58#define CBE_PM_CTR_OVERFLOW_INTR(ctr) (1 << (31 - ((ctr) & 7)))
59
60enum pm_reg_name {
61 group_control,
62 debug_bus_control,
63 trace_address,
64 ext_tr_timer,
65 pm_status,
66 pm_control,
67 pm_interval,
68 pm_start_stop,
69};
70
71/* Routines for reading/writing the PMU registers. */
72extern u32 cbe_read_phys_ctr(u32 cpu, u32 phys_ctr);
73extern void cbe_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
74extern u32 cbe_read_ctr(u32 cpu, u32 ctr);
75extern void cbe_write_ctr(u32 cpu, u32 ctr, u32 val);
76
77extern u32 cbe_read_pm07_control(u32 cpu, u32 ctr);
78extern void cbe_write_pm07_control(u32 cpu, u32 ctr, u32 val);
79extern u32 cbe_read_pm(u32 cpu, enum pm_reg_name reg);
80extern void cbe_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
81
82extern u32 cbe_get_ctr_size(u32 cpu, u32 phys_ctr);
83extern void cbe_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
84
85extern void cbe_enable_pm(u32 cpu);
86extern void cbe_disable_pm(u32 cpu);
87
88extern void cbe_read_trace_buffer(u32 cpu, u64 *buf);
89
90extern void cbe_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
91extern void cbe_disable_pm_interrupts(u32 cpu);
92extern u32 cbe_query_pm_interrupts(u32 cpu);
93extern u32 cbe_clear_pm_interrupts(u32 cpu);
94extern void cbe_sync_irq(int node);
95
96/* Utility functions, macros */
97extern u32 cbe_get_hw_thread_id(int cpu);
98
99#define cbe_cpu_to_node(cpu) ((cpu) >> 1)
100
101#define CBE_COUNT_SUPERVISOR_MODE 0
102#define CBE_COUNT_HYPERVISOR_MODE 1
103#define CBE_COUNT_PROBLEM_MODE 2
104#define CBE_COUNT_ALL_MODES 3
105
106/* Macros for the pm07_control registers. */
107#define PM07_CTR_INPUT_MUX(x) (((x) & 0x3F) << 26)
108#define PM07_CTR_INPUT_CONTROL(x) (((x) & 1) << 25)
109#define PM07_CTR_POLARITY(x) (((x) & 1) << 24)
110#define PM07_CTR_COUNT_CYCLES(x) (((x) & 1) << 23)
111#define PM07_CTR_ENABLE(x) (((x) & 1) << 22)
112
113#endif /* __ASM_CELL_PMU_H__ */
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index a9a40149a7c0..6fe5c9d4ca3b 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -24,6 +24,8 @@
24#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 24#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
25#define PPC_FEATURE_ARCH_2_05 0x00001000 25#define PPC_FEATURE_ARCH_2_05 0x00001000
26#define PPC_FEATURE_PA6T 0x00000800 26#define PPC_FEATURE_PA6T 0x00000800
27#define PPC_FEATURE_HAS_DFP 0x00000400
28#define PPC_FEATURE_POWER6_EXT 0x00000200
27 29
28#define PPC_FEATURE_TRUE_LE 0x00000002 30#define PPC_FEATURE_TRUE_LE 0x00000002
29#define PPC_FEATURE_PPC_LE 0x00000001 31#define PPC_FEATURE_PPC_LE 0x00000001
@@ -45,6 +47,7 @@ enum powerpc_oprofile_type {
45 PPC_OPROFILE_POWER4 = 2, 47 PPC_OPROFILE_POWER4 = 2,
46 PPC_OPROFILE_G4 = 3, 48 PPC_OPROFILE_G4 = 3,
47 PPC_OPROFILE_BOOKE = 4, 49 PPC_OPROFILE_BOOKE = 4,
50 PPC_OPROFILE_CELL = 5,
48}; 51};
49 52
50struct cpu_spec { 53struct cpu_spec {
@@ -91,7 +94,7 @@ extern struct cpu_spec *cur_cpu_spec;
91 94
92extern unsigned int __start___ftr_fixup, __stop___ftr_fixup; 95extern unsigned int __start___ftr_fixup, __stop___ftr_fixup;
93 96
94extern struct cpu_spec *identify_cpu(unsigned long offset); 97extern struct cpu_spec *identify_cpu(unsigned long offset, unsigned int pvr);
95extern void do_feature_fixups(unsigned long value, void *fixup_start, 98extern void do_feature_fixups(unsigned long value, void *fixup_start,
96 void *fixup_end); 99 void *fixup_end);
97 100
@@ -148,19 +151,13 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
148#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000) 151#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000)
149#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000) 152#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000)
150#define CPU_FTR_CELL_TB_BUG LONG_ASM_CONST(0x0000800000000000) 153#define CPU_FTR_CELL_TB_BUG LONG_ASM_CONST(0x0000800000000000)
154#define CPU_FTR_SPURR LONG_ASM_CONST(0x0001000000000000)
151 155
152#ifndef __ASSEMBLY__ 156#ifndef __ASSEMBLY__
153 157
154#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \ 158#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_SLB | \
155 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \ 159 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \
156 CPU_FTR_NODSISRALIGN) 160 CPU_FTR_NODSISRALIGN | CPU_FTR_16M_PAGE)
157
158/* iSeries doesn't support large pages */
159#ifdef CONFIG_PPC_ISERIES
160#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE)
161#else
162#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE | CPU_FTR_16M_PAGE)
163#endif /* CONFIG_PPC_ISERIES */
164 161
165/* We only set the altivec features if the kernel was compiled with altivec 162/* We only set the altivec features if the kernel was compiled with altivec
166 * support 163 * support
@@ -311,7 +308,8 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
311#define CPU_FTRS_E500_2 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 308#define CPU_FTRS_E500_2 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
312 CPU_FTR_BIG_PHYS | CPU_FTR_NODSISRALIGN) 309 CPU_FTR_BIG_PHYS | CPU_FTR_NODSISRALIGN)
313#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN) 310#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN)
314#ifdef __powerpc64__ 311
312/* 64-bit CPUs */
315#define CPU_FTRS_POWER3 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 313#define CPU_FTRS_POWER3 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
316 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | CPU_FTR_PPC_LE) 314 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | CPU_FTR_PPC_LE)
317#define CPU_FTRS_RS64 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 315#define CPU_FTRS_RS64 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
@@ -332,7 +330,13 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
332 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 330 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
333 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 331 CPU_FTR_MMCRA | CPU_FTR_SMT | \
334 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 332 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
335 CPU_FTR_PURR | CPU_FTR_CI_LARGE_PAGE | CPU_FTR_REAL_LE) 333 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE)
334#define CPU_FTRS_POWER6X (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
335 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
336 CPU_FTR_MMCRA | CPU_FTR_SMT | \
337 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
338 CPU_FTR_PURR | CPU_FTR_CI_LARGE_PAGE | \
339 CPU_FTR_SPURR | CPU_FTR_REAL_LE)
336#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 340#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
337 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 341 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
338 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 342 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
@@ -343,7 +347,6 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
343 CPU_FTR_PURR | CPU_FTR_REAL_LE) 347 CPU_FTR_PURR | CPU_FTR_REAL_LE)
344#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 348#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
345 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2) 349 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2)
346#endif
347 350
348#ifdef __powerpc64__ 351#ifdef __powerpc64__
349#define CPU_FTRS_POSSIBLE \ 352#define CPU_FTRS_POSSIBLE \
diff --git a/include/asm-powerpc/dbdma.h b/include/asm-powerpc/dbdma.h
index 8973565f95d3..e23f07e73cb3 100644
--- a/include/asm-powerpc/dbdma.h
+++ b/include/asm-powerpc/dbdma.h
@@ -95,7 +95,13 @@ struct dbdma_cmd {
95#define DBDMA_DO_STOP(regs) do { \ 95#define DBDMA_DO_STOP(regs) do { \
96 out_le32(&((regs)->control), (RUN|FLUSH)<<16); \ 96 out_le32(&((regs)->control), (RUN|FLUSH)<<16); \
97 while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \ 97 while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \
98 ; \ 98 ; \
99} while(0)
100
101#define DBDMA_DO_RESET(regs) do { \
102 out_le32(&((regs)->control), (ACTIVE|DEAD|WAKE|FLUSH|PAUSE|RUN)<<16);\
103 while(in_le32(&((regs)->status)) & (RUN)) \
104 ; \
99} while(0) 105} while(0)
100 106
101#endif /* _ASM_DBDMA_H_ */ 107#endif /* _ASM_DBDMA_H_ */
diff --git a/include/asm-powerpc/dcr-mmio.h b/include/asm-powerpc/dcr-mmio.h
new file mode 100644
index 000000000000..5dbfca8dde36
--- /dev/null
+++ b/include/asm-powerpc/dcr-mmio.h
@@ -0,0 +1,51 @@
1/*
2 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef _ASM_POWERPC_DCR_MMIO_H
21#define _ASM_POWERPC_DCR_MMIO_H
22#ifdef __KERNEL__
23
24#include <asm/io.h>
25
26typedef struct { void __iomem *token; unsigned int stride; } dcr_host_t;
27
28#define DCR_MAP_OK(host) ((host).token != NULL)
29
30extern dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n,
31 unsigned int dcr_c);
32extern void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c);
33
34static inline u32 dcr_read(dcr_host_t host, unsigned int dcr_n)
35{
36 return in_be32(host.token + dcr_n * host.stride);
37}
38
39static inline void dcr_write(dcr_host_t host, unsigned int dcr_n, u32 value)
40{
41 out_be32(host.token + dcr_n * host.stride, value);
42}
43
44extern u64 of_translate_dcr_address(struct device_node *dev,
45 unsigned int dcr_n,
46 unsigned int *stride);
47
48#endif /* __KERNEL__ */
49#endif /* _ASM_POWERPC_DCR_MMIO_H */
50
51
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
new file mode 100644
index 000000000000..fd4a5f5e33d1
--- /dev/null
+++ b/include/asm-powerpc/dcr-native.h
@@ -0,0 +1,39 @@
1/*
2 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef _ASM_POWERPC_DCR_NATIVE_H
21#define _ASM_POWERPC_DCR_NATIVE_H
22#ifdef __KERNEL__
23
24#include <asm/reg.h>
25
26typedef struct {} dcr_host_t;
27
28#define DCR_MAP_OK(host) (1)
29
30#define dcr_map(dev, dcr_n, dcr_c) {}
31#define dcr_unmap(host, dcr_n, dcr_c) {}
32#define dcr_read(host, dcr_n) mfdcr(dcr_n)
33#define dcr_write(host, dcr_n, value) mtdcr(dcr_n, value)
34
35
36#endif /* __KERNEL__ */
37#endif /* _ASM_POWERPC_DCR_NATIVE_H */
38
39
diff --git a/include/asm-powerpc/dcr.h b/include/asm-powerpc/dcr.h
new file mode 100644
index 000000000000..473f2c7fd892
--- /dev/null
+++ b/include/asm-powerpc/dcr.h
@@ -0,0 +1,42 @@
1/*
2 * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 * the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef _ASM_POWERPC_DCR_H
21#define _ASM_POWERPC_DCR_H
22#ifdef __KERNEL__
23
24#ifdef CONFIG_PPC_DCR_NATIVE
25#include <asm/dcr-native.h>
26#else
27#include <asm/dcr-mmio.h>
28#endif
29
30/*
31 * On CONFIG_PPC_MERGE, we have additional helpers to read the DCR
32 * base from the device-tree
33 */
34#ifdef CONFIG_PPC_MERGE
35extern unsigned int dcr_resource_start(struct device_node *np,
36 unsigned int index);
37extern unsigned int dcr_resource_len(struct device_node *np,
38 unsigned int index);
39#endif /* CONFIG_PPC_MERGE */
40
41#endif /* __KERNEL__ */
42#endif /* _ASM_POWERPC_DCR_H */
diff --git a/include/asm-powerpc/device.h b/include/asm-powerpc/device.h
index d8f9872b0e2d..228ab2a315b9 100644
--- a/include/asm-powerpc/device.h
+++ b/include/asm-powerpc/device.h
@@ -3,5 +3,22 @@
3 * 3 *
4 * This file is released under the GPLv2 4 * This file is released under the GPLv2
5 */ 5 */
6#include <asm-generic/device.h> 6#ifndef _ASM_POWERPC_DEVICE_H
7#define _ASM_POWERPC_DEVICE_H
7 8
9struct dma_mapping_ops;
10struct device_node;
11
12struct dev_archdata {
13 /* Optional pointer to an OF device node */
14 struct device_node *of_node;
15
16 /* DMA operations on that device */
17 struct dma_mapping_ops *dma_ops;
18 void *dma_data;
19
20 /* NUMA node if applicable */
21 int numa_node;
22};
23
24#endif /* _ASM_POWERPC_DEVICE_H */
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index 2ab9baf78bb4..7e38b5fddada 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -44,26 +44,150 @@ extern void __dma_sync_page(struct page *page, unsigned long offset,
44#endif /* ! CONFIG_NOT_COHERENT_CACHE */ 44#endif /* ! CONFIG_NOT_COHERENT_CACHE */
45 45
46#ifdef CONFIG_PPC64 46#ifdef CONFIG_PPC64
47/*
48 * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
49 */
50struct dma_mapping_ops {
51 void * (*alloc_coherent)(struct device *dev, size_t size,
52 dma_addr_t *dma_handle, gfp_t flag);
53 void (*free_coherent)(struct device *dev, size_t size,
54 void *vaddr, dma_addr_t dma_handle);
55 dma_addr_t (*map_single)(struct device *dev, void *ptr,
56 size_t size, enum dma_data_direction direction);
57 void (*unmap_single)(struct device *dev, dma_addr_t dma_addr,
58 size_t size, enum dma_data_direction direction);
59 int (*map_sg)(struct device *dev, struct scatterlist *sg,
60 int nents, enum dma_data_direction direction);
61 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
62 int nents, enum dma_data_direction direction);
63 int (*dma_supported)(struct device *dev, u64 mask);
64 int (*dac_dma_supported)(struct device *dev, u64 mask);
65 int (*set_dma_mask)(struct device *dev, u64 dma_mask);
66};
67
68static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
69{
70 /* We don't handle the NULL dev case for ISA for now. We could
71 * do it via an out of line call but it is not needed for now. The
72 * only ISA DMA device we support is the floppy and we have a hack
73 * in the floppy driver directly to get a device for us.
74 */
75 if (unlikely(dev == NULL || dev->archdata.dma_ops == NULL))
76 return NULL;
77 return dev->archdata.dma_ops;
78}
47 79
48extern int dma_supported(struct device *dev, u64 mask); 80static inline int dma_supported(struct device *dev, u64 mask)
49extern int dma_set_mask(struct device *dev, u64 dma_mask); 81{
50extern void *dma_alloc_coherent(struct device *dev, size_t size, 82 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
51 dma_addr_t *dma_handle, gfp_t flag); 83
52extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr, 84 if (unlikely(dma_ops == NULL))
53 dma_addr_t dma_handle); 85 return 0;
54extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, 86 if (dma_ops->dma_supported == NULL)
55 size_t size, enum dma_data_direction direction); 87 return 1;
56extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, 88 return dma_ops->dma_supported(dev, mask);
57 size_t size, enum dma_data_direction direction); 89}
58extern dma_addr_t dma_map_page(struct device *dev, struct page *page, 90
59 unsigned long offset, size_t size, 91static inline int dma_set_mask(struct device *dev, u64 dma_mask)
60 enum dma_data_direction direction); 92{
61extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address, 93 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
62 size_t size, enum dma_data_direction direction); 94
63extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, 95 if (unlikely(dma_ops == NULL))
64 enum dma_data_direction direction); 96 return -EIO;
65extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg, 97 if (dma_ops->set_dma_mask != NULL)
66 int nhwentries, enum dma_data_direction direction); 98 return dma_ops->set_dma_mask(dev, dma_mask);
99 if (!dev->dma_mask || !dma_supported(dev, *dev->dma_mask))
100 return -EIO;
101 *dev->dma_mask = dma_mask;
102 return 0;
103}
104
105static inline void *dma_alloc_coherent(struct device *dev, size_t size,
106 dma_addr_t *dma_handle, gfp_t flag)
107{
108 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
109
110 BUG_ON(!dma_ops);
111 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
112}
113
114static inline void dma_free_coherent(struct device *dev, size_t size,
115 void *cpu_addr, dma_addr_t dma_handle)
116{
117 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
118
119 BUG_ON(!dma_ops);
120 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
121}
122
123static inline dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
124 size_t size,
125 enum dma_data_direction direction)
126{
127 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
128
129 BUG_ON(!dma_ops);
130 return dma_ops->map_single(dev, cpu_addr, size, direction);
131}
132
133static inline void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
134 size_t size,
135 enum dma_data_direction direction)
136{
137 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
138
139 BUG_ON(!dma_ops);
140 dma_ops->unmap_single(dev, dma_addr, size, direction);
141}
142
143static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
144 unsigned long offset, size_t size,
145 enum dma_data_direction direction)
146{
147 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
148
149 BUG_ON(!dma_ops);
150 return dma_ops->map_single(dev, page_address(page) + offset, size,
151 direction);
152}
153
154static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
155 size_t size,
156 enum dma_data_direction direction)
157{
158 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
159
160 BUG_ON(!dma_ops);
161 dma_ops->unmap_single(dev, dma_address, size, direction);
162}
163
164static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
165 int nents, enum dma_data_direction direction)
166{
167 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
168
169 BUG_ON(!dma_ops);
170 return dma_ops->map_sg(dev, sg, nents, direction);
171}
172
173static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
174 int nhwentries,
175 enum dma_data_direction direction)
176{
177 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
178
179 BUG_ON(!dma_ops);
180 dma_ops->unmap_sg(dev, sg, nhwentries, direction);
181}
182
183
184/*
185 * Available generic sets of operations
186 */
187extern struct dma_mapping_ops dma_iommu_ops;
188extern struct dma_mapping_ops dma_direct_ops;
189
190extern unsigned long dma_direct_offset;
67 191
68#else /* CONFIG_PPC64 */ 192#else /* CONFIG_PPC64 */
69 193
@@ -261,25 +385,5 @@ static inline void dma_cache_sync(void *vaddr, size_t size,
261 __dma_sync(vaddr, size, (int)direction); 385 __dma_sync(vaddr, size, (int)direction);
262} 386}
263 387
264/*
265 * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
266 */
267struct dma_mapping_ops {
268 void * (*alloc_coherent)(struct device *dev, size_t size,
269 dma_addr_t *dma_handle, gfp_t flag);
270 void (*free_coherent)(struct device *dev, size_t size,
271 void *vaddr, dma_addr_t dma_handle);
272 dma_addr_t (*map_single)(struct device *dev, void *ptr,
273 size_t size, enum dma_data_direction direction);
274 void (*unmap_single)(struct device *dev, dma_addr_t dma_addr,
275 size_t size, enum dma_data_direction direction);
276 int (*map_sg)(struct device *dev, struct scatterlist *sg,
277 int nents, enum dma_data_direction direction);
278 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
279 int nents, enum dma_data_direction direction);
280 int (*dma_supported)(struct device *dev, u64 mask);
281 int (*dac_dma_supported)(struct device *dev, u64 mask);
282};
283
284#endif /* __KERNEL__ */ 388#endif /* __KERNEL__ */
285#endif /* _ASM_DMA_MAPPING_H */ 389#endif /* _ASM_DMA_MAPPING_H */
diff --git a/include/asm-powerpc/eeh.h b/include/asm-powerpc/eeh.h
index 6a784396660b..b886bec67016 100644
--- a/include/asm-powerpc/eeh.h
+++ b/include/asm-powerpc/eeh.h
@@ -120,10 +120,6 @@ static inline u8 eeh_readb(const volatile void __iomem *addr)
120 return eeh_check_failure(addr, val); 120 return eeh_check_failure(addr, val);
121 return val; 121 return val;
122} 122}
123static inline void eeh_writeb(u8 val, volatile void __iomem *addr)
124{
125 out_8(addr, val);
126}
127 123
128static inline u16 eeh_readw(const volatile void __iomem *addr) 124static inline u16 eeh_readw(const volatile void __iomem *addr)
129{ 125{
@@ -132,21 +128,6 @@ static inline u16 eeh_readw(const volatile void __iomem *addr)
132 return eeh_check_failure(addr, val); 128 return eeh_check_failure(addr, val);
133 return val; 129 return val;
134} 130}
135static inline void eeh_writew(u16 val, volatile void __iomem *addr)
136{
137 out_le16(addr, val);
138}
139static inline u16 eeh_raw_readw(const volatile void __iomem *addr)
140{
141 u16 val = in_be16(addr);
142 if (EEH_POSSIBLE_ERROR(val, u16))
143 return eeh_check_failure(addr, val);
144 return val;
145}
146static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) {
147 volatile u16 __iomem *vaddr = (volatile u16 __iomem *) addr;
148 out_be16(vaddr, val);
149}
150 131
151static inline u32 eeh_readl(const volatile void __iomem *addr) 132static inline u32 eeh_readl(const volatile void __iomem *addr)
152{ 133{
@@ -155,205 +136,75 @@ static inline u32 eeh_readl(const volatile void __iomem *addr)
155 return eeh_check_failure(addr, val); 136 return eeh_check_failure(addr, val);
156 return val; 137 return val;
157} 138}
158static inline void eeh_writel(u32 val, volatile void __iomem *addr) 139
159{ 140static inline u64 eeh_readq(const volatile void __iomem *addr)
160 out_le32(addr, val);
161}
162static inline u32 eeh_raw_readl(const volatile void __iomem *addr)
163{ 141{
164 u32 val = in_be32(addr); 142 u64 val = in_le64(addr);
165 if (EEH_POSSIBLE_ERROR(val, u32)) 143 if (EEH_POSSIBLE_ERROR(val, u64))
166 return eeh_check_failure(addr, val); 144 return eeh_check_failure(addr, val);
167 return val; 145 return val;
168} 146}
169static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr)
170{
171 out_be32(addr, val);
172}
173 147
174static inline u64 eeh_readq(const volatile void __iomem *addr) 148static inline u16 eeh_readw_be(const volatile void __iomem *addr)
175{ 149{
176 u64 val = in_le64(addr); 150 u16 val = in_be16(addr);
177 if (EEH_POSSIBLE_ERROR(val, u64)) 151 if (EEH_POSSIBLE_ERROR(val, u16))
178 return eeh_check_failure(addr, val); 152 return eeh_check_failure(addr, val);
179 return val; 153 return val;
180} 154}
181static inline void eeh_writeq(u64 val, volatile void __iomem *addr) 155
156static inline u32 eeh_readl_be(const volatile void __iomem *addr)
182{ 157{
183 out_le64(addr, val); 158 u32 val = in_be32(addr);
159 if (EEH_POSSIBLE_ERROR(val, u32))
160 return eeh_check_failure(addr, val);
161 return val;
184} 162}
185static inline u64 eeh_raw_readq(const volatile void __iomem *addr) 163
164static inline u64 eeh_readq_be(const volatile void __iomem *addr)
186{ 165{
187 u64 val = in_be64(addr); 166 u64 val = in_be64(addr);
188 if (EEH_POSSIBLE_ERROR(val, u64)) 167 if (EEH_POSSIBLE_ERROR(val, u64))
189 return eeh_check_failure(addr, val); 168 return eeh_check_failure(addr, val);
190 return val; 169 return val;
191} 170}
192static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr)
193{
194 out_be64(addr, val);
195}
196
197#define EEH_CHECK_ALIGN(v,a) \
198 ((((unsigned long)(v)) & ((a) - 1)) == 0)
199 171
200static inline void eeh_memset_io(volatile void __iomem *addr, int c, 172static inline void eeh_memcpy_fromio(void *dest, const
201 unsigned long n) 173 volatile void __iomem *src,
202{
203 void *p = (void __force *)addr;
204 u32 lc = c;
205 lc |= lc << 8;
206 lc |= lc << 16;
207
208 __asm__ __volatile__ ("sync" : : : "memory");
209 while(n && !EEH_CHECK_ALIGN(p, 4)) {
210 *((volatile u8 *)p) = c;
211 p++;
212 n--;
213 }
214 while(n >= 4) {
215 *((volatile u32 *)p) = lc;
216 p += 4;
217 n -= 4;
218 }
219 while(n) {
220 *((volatile u8 *)p) = c;
221 p++;
222 n--;
223 }
224 __asm__ __volatile__ ("sync" : : : "memory");
225}
226static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src,
227 unsigned long n) 174 unsigned long n)
228{ 175{
229 void *vsrc = (void __force *) src; 176 _memcpy_fromio(dest, src, n);
230 void *destsave = dest;
231 unsigned long nsave = n;
232
233 __asm__ __volatile__ ("sync" : : : "memory");
234 while(n && (!EEH_CHECK_ALIGN(vsrc, 4) || !EEH_CHECK_ALIGN(dest, 4))) {
235 *((u8 *)dest) = *((volatile u8 *)vsrc);
236 __asm__ __volatile__ ("eieio" : : : "memory");
237 vsrc++;
238 dest++;
239 n--;
240 }
241 while(n > 4) {
242 *((u32 *)dest) = *((volatile u32 *)vsrc);
243 __asm__ __volatile__ ("eieio" : : : "memory");
244 vsrc += 4;
245 dest += 4;
246 n -= 4;
247 }
248 while(n) {
249 *((u8 *)dest) = *((volatile u8 *)vsrc);
250 __asm__ __volatile__ ("eieio" : : : "memory");
251 vsrc++;
252 dest++;
253 n--;
254 }
255 __asm__ __volatile__ ("sync" : : : "memory");
256 177
257 /* Look for ffff's here at dest[n]. Assume that at least 4 bytes 178 /* Look for ffff's here at dest[n]. Assume that at least 4 bytes
258 * were copied. Check all four bytes. 179 * were copied. Check all four bytes.
259 */ 180 */
260 if ((nsave >= 4) && 181 if (n >= 4 && EEH_POSSIBLE_ERROR(*((u32 *)(dest + n - 4)), u32))
261 (EEH_POSSIBLE_ERROR((*((u32 *) destsave+nsave-4)), u32))) { 182 eeh_check_failure(src, *((u32 *)(dest + n - 4)));
262 eeh_check_failure(src, (*((u32 *) destsave+nsave-4)));
263 }
264}
265
266static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
267 unsigned long n)
268{
269 void *vdest = (void __force *) dest;
270
271 __asm__ __volatile__ ("sync" : : : "memory");
272 while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) {
273 *((volatile u8 *)vdest) = *((u8 *)src);
274 src++;
275 vdest++;
276 n--;
277 }
278 while(n > 4) {
279 *((volatile u32 *)vdest) = *((volatile u32 *)src);
280 src += 4;
281 vdest += 4;
282 n-=4;
283 }
284 while(n) {
285 *((volatile u8 *)vdest) = *((u8 *)src);
286 src++;
287 vdest++;
288 n--;
289 }
290 __asm__ __volatile__ ("sync" : : : "memory");
291}
292
293#undef EEH_CHECK_ALIGN
294
295static inline u8 eeh_inb(unsigned long port)
296{
297 u8 val;
298 val = in_8((u8 __iomem *)(port+pci_io_base));
299 if (EEH_POSSIBLE_ERROR(val, u8))
300 return eeh_check_failure((void __iomem *)(port), val);
301 return val;
302}
303
304static inline void eeh_outb(u8 val, unsigned long port)
305{
306 out_8((u8 __iomem *)(port+pci_io_base), val);
307}
308
309static inline u16 eeh_inw(unsigned long port)
310{
311 u16 val;
312 val = in_le16((u16 __iomem *)(port+pci_io_base));
313 if (EEH_POSSIBLE_ERROR(val, u16))
314 return eeh_check_failure((void __iomem *)(port), val);
315 return val;
316}
317
318static inline void eeh_outw(u16 val, unsigned long port)
319{
320 out_le16((u16 __iomem *)(port+pci_io_base), val);
321}
322
323static inline u32 eeh_inl(unsigned long port)
324{
325 u32 val;
326 val = in_le32((u32 __iomem *)(port+pci_io_base));
327 if (EEH_POSSIBLE_ERROR(val, u32))
328 return eeh_check_failure((void __iomem *)(port), val);
329 return val;
330}
331
332static inline void eeh_outl(u32 val, unsigned long port)
333{
334 out_le32((u32 __iomem *)(port+pci_io_base), val);
335} 183}
336 184
337/* in-string eeh macros */ 185/* in-string eeh macros */
338static inline void eeh_insb(unsigned long port, void * buf, int ns) 186static inline void eeh_readsb(const volatile void __iomem *addr, void * buf,
187 int ns)
339{ 188{
340 _insb((u8 __iomem *)(port+pci_io_base), buf, ns); 189 _insb(addr, buf, ns);
341 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8)) 190 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8))
342 eeh_check_failure((void __iomem *)(port), *(u8*)buf); 191 eeh_check_failure(addr, *(u8*)buf);
343} 192}
344 193
345static inline void eeh_insw_ns(unsigned long port, void * buf, int ns) 194static inline void eeh_readsw(const volatile void __iomem *addr, void * buf,
195 int ns)
346{ 196{
347 _insw_ns((u16 __iomem *)(port+pci_io_base), buf, ns); 197 _insw(addr, buf, ns);
348 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16)) 198 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16))
349 eeh_check_failure((void __iomem *)(port), *(u16*)buf); 199 eeh_check_failure(addr, *(u16*)buf);
350} 200}
351 201
352static inline void eeh_insl_ns(unsigned long port, void * buf, int nl) 202static inline void eeh_readsl(const volatile void __iomem *addr, void * buf,
203 int nl)
353{ 204{
354 _insl_ns((u32 __iomem *)(port+pci_io_base), buf, nl); 205 _insl(addr, buf, nl);
355 if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32)) 206 if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32))
356 eeh_check_failure((void __iomem *)(port), *(u32*)buf); 207 eeh_check_failure(addr, *(u32*)buf);
357} 208}
358 209
359#endif /* __KERNEL__ */ 210#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index 9a83a987d396..b5436642a109 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -411,4 +411,17 @@ do { \
411/* Keep this the last entry. */ 411/* Keep this the last entry. */
412#define R_PPC64_NUM 107 412#define R_PPC64_NUM 107
413 413
414#ifdef CONFIG_SPU_BASE
415/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
416#define NT_SPU 1
417
418extern int arch_notes_size(void);
419extern void arch_write_notes(struct file *file);
420
421#define ELF_CORE_EXTRA_NOTES_SIZE arch_notes_size()
422#define ELF_CORE_WRITE_EXTRA_NOTES arch_write_notes(file)
423
424#define ARCH_HAVE_EXTRA_ELF_NOTES
425#endif /* CONFIG_PPC_CELL */
426
414#endif /* _ASM_POWERPC_ELF_H */ 427#endif /* _ASM_POWERPC_ELF_H */
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
index fdf9aff71150..98f7b62422c9 100644
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -42,6 +42,7 @@
42#define FW_FEATURE_SPLPAR ASM_CONST(0x0000000000100000) 42#define FW_FEATURE_SPLPAR ASM_CONST(0x0000000000100000)
43#define FW_FEATURE_ISERIES ASM_CONST(0x0000000000200000) 43#define FW_FEATURE_ISERIES ASM_CONST(0x0000000000200000)
44#define FW_FEATURE_LPAR ASM_CONST(0x0000000000400000) 44#define FW_FEATURE_LPAR ASM_CONST(0x0000000000400000)
45#define FW_FEATURE_PS3_LV1 ASM_CONST(0x0000000000800000)
45 46
46#ifndef __ASSEMBLY__ 47#ifndef __ASSEMBLY__
47 48
@@ -58,6 +59,10 @@ enum {
58 FW_FEATURE_PSERIES_ALWAYS = 0, 59 FW_FEATURE_PSERIES_ALWAYS = 0,
59 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR, 60 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
60 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR, 61 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
62 FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
63 FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
64 FW_FEATURE_NATIVE_POSSIBLE = 0,
65 FW_FEATURE_NATIVE_ALWAYS = 0,
61 FW_FEATURE_POSSIBLE = 66 FW_FEATURE_POSSIBLE =
62#ifdef CONFIG_PPC_PSERIES 67#ifdef CONFIG_PPC_PSERIES
63 FW_FEATURE_PSERIES_POSSIBLE | 68 FW_FEATURE_PSERIES_POSSIBLE |
@@ -65,6 +70,12 @@ enum {
65#ifdef CONFIG_PPC_ISERIES 70#ifdef CONFIG_PPC_ISERIES
66 FW_FEATURE_ISERIES_POSSIBLE | 71 FW_FEATURE_ISERIES_POSSIBLE |
67#endif 72#endif
73#ifdef CONFIG_PPC_PS3
74 FW_FEATURE_PS3_POSSIBLE |
75#endif
76#ifdef CONFIG_PPC_NATIVE
77 FW_FEATURE_NATIVE_ALWAYS |
78#endif
68 0, 79 0,
69 FW_FEATURE_ALWAYS = 80 FW_FEATURE_ALWAYS =
70#ifdef CONFIG_PPC_PSERIES 81#ifdef CONFIG_PPC_PSERIES
@@ -73,6 +84,12 @@ enum {
73#ifdef CONFIG_PPC_ISERIES 84#ifdef CONFIG_PPC_ISERIES
74 FW_FEATURE_ISERIES_ALWAYS & 85 FW_FEATURE_ISERIES_ALWAYS &
75#endif 86#endif
87#ifdef CONFIG_PPC_PS3
88 FW_FEATURE_PS3_ALWAYS &
89#endif
90#ifdef CONFIG_PPC_NATIVE
91 FW_FEATURE_NATIVE_ALWAYS &
92#endif
76 FW_FEATURE_POSSIBLE, 93 FW_FEATURE_POSSIBLE,
77 94
78#else /* CONFIG_PPC64 */ 95#else /* CONFIG_PPC64 */
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
index d40359204aba..d604863d72fb 100644
--- a/include/asm-powerpc/hw_irq.h
+++ b/include/asm-powerpc/hw_irq.h
@@ -7,16 +7,40 @@
7#ifdef __KERNEL__ 7#ifdef __KERNEL__
8 8
9#include <linux/errno.h> 9#include <linux/errno.h>
10#include <linux/compiler.h>
10#include <asm/ptrace.h> 11#include <asm/ptrace.h>
11#include <asm/processor.h> 12#include <asm/processor.h>
12 13
13extern void timer_interrupt(struct pt_regs *); 14extern void timer_interrupt(struct pt_regs *);
14 15
15#ifdef CONFIG_PPC_ISERIES 16#ifdef CONFIG_PPC64
17#include <asm/paca.h>
18
19static inline unsigned long local_get_flags(void)
20{
21 unsigned long flags;
22
23 __asm__ __volatile__("lbz %0,%1(13)"
24 : "=r" (flags)
25 : "i" (offsetof(struct paca_struct, soft_enabled)));
26
27 return flags;
28}
29
30static inline unsigned long local_irq_disable(void)
31{
32 unsigned long flags, zero;
33
34 __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)"
35 : "=r" (flags), "=&r" (zero)
36 : "i" (offsetof(struct paca_struct, soft_enabled))
37 : "memory");
38
39 return flags;
40}
16 41
17extern unsigned long local_get_flags(void);
18extern unsigned long local_irq_disable(void);
19extern void local_irq_restore(unsigned long); 42extern void local_irq_restore(unsigned long);
43extern void iseries_handle_interrupts(void);
20 44
21#define local_irq_enable() local_irq_restore(1) 45#define local_irq_enable() local_irq_restore(1)
22#define local_save_flags(flags) ((flags) = local_get_flags()) 46#define local_save_flags(flags) ((flags) = local_get_flags())
@@ -24,17 +48,14 @@ extern void local_irq_restore(unsigned long);
24 48
25#define irqs_disabled() (local_get_flags() == 0) 49#define irqs_disabled() (local_get_flags() == 0)
26 50
51#define hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
52#define hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
53
27#else 54#else
28 55
29#if defined(CONFIG_BOOKE) 56#if defined(CONFIG_BOOKE)
30#define SET_MSR_EE(x) mtmsr(x) 57#define SET_MSR_EE(x) mtmsr(x)
31#define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") 58#define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
32#elif defined(__powerpc64__)
33#define SET_MSR_EE(x) __mtmsrd(x, 1)
34#define local_irq_restore(flags) do { \
35 __asm__ __volatile__("": : :"memory"); \
36 __mtmsrd((flags), 1); \
37} while(0)
38#else 59#else
39#define SET_MSR_EE(x) mtmsr(x) 60#define SET_MSR_EE(x) mtmsr(x)
40#define local_irq_restore(flags) mtmsr(flags) 61#define local_irq_restore(flags) mtmsr(flags)
@@ -81,7 +102,10 @@ static inline void local_irq_save_ptr(unsigned long *flags)
81#define local_irq_save(flags) local_irq_save_ptr(&flags) 102#define local_irq_save(flags) local_irq_save_ptr(&flags)
82#define irqs_disabled() ((mfmsr() & MSR_EE) == 0) 103#define irqs_disabled() ((mfmsr() & MSR_EE) == 0)
83 104
84#endif /* CONFIG_PPC_ISERIES */ 105#define hard_irq_enable() local_irq_enable()
106#define hard_irq_disable() local_irq_disable()
107
108#endif /* CONFIG_PPC64 */
85 109
86#define mask_irq(irq) \ 110#define mask_irq(irq) \
87 ({ \ 111 ({ \
diff --git a/include/asm-powerpc/ibmebus.h b/include/asm-powerpc/ibmebus.h
index 3493429b70f5..66112114b8c5 100644
--- a/include/asm-powerpc/ibmebus.h
+++ b/include/asm-powerpc/ibmebus.h
@@ -44,7 +44,6 @@
44#include <linux/mod_devicetable.h> 44#include <linux/mod_devicetable.h>
45#include <asm/of_device.h> 45#include <asm/of_device.h>
46 46
47extern struct dma_mapping_ops ibmebus_dma_ops;
48extern struct bus_type ibmebus_bus_type; 47extern struct bus_type ibmebus_bus_type;
49 48
50struct ibmebus_dev { 49struct ibmebus_dev {
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
index c8390f9485de..0f66f0f82c32 100644
--- a/include/asm-powerpc/ide.h
+++ b/include/asm-powerpc/ide.h
@@ -22,10 +22,10 @@
22#endif 22#endif
23#endif 23#endif
24 24
25#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c)) 25#define __ide_mm_insw(p, a, c) readsw((void __iomem *)(p), (a), (c))
26#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c)) 26#define __ide_mm_insl(p, a, c) readsl((void __iomem *)(p), (a), (c))
27#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c)) 27#define __ide_mm_outsw(p, a, c) writesw((void __iomem *)(p), (a), (c))
28#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c)) 28#define __ide_mm_outsl(p, a, c) writesl((void __iomem *)(p), (a), (c))
29 29
30#ifndef __powerpc64__ 30#ifndef __powerpc64__
31#include <linux/hdreg.h> 31#include <linux/hdreg.h>
diff --git a/include/asm-powerpc/immap_qe.h b/include/asm-powerpc/immap_qe.h
index ce12f85fff9b..9fdd0491f6a3 100644
--- a/include/asm-powerpc/immap_qe.h
+++ b/include/asm-powerpc/immap_qe.h
@@ -136,22 +136,7 @@ struct qe_timers {
136 136
137/* BRG */ 137/* BRG */
138struct qe_brg { 138struct qe_brg {
139 __be32 brgc1; /* BRG1 configuration register */ 139 __be32 brgc[16]; /* BRG configuration registers */
140 __be32 brgc2; /* BRG2 configuration register */
141 __be32 brgc3; /* BRG3 configuration register */
142 __be32 brgc4; /* BRG4 configuration register */
143 __be32 brgc5; /* BRG5 configuration register */
144 __be32 brgc6; /* BRG6 configuration register */
145 __be32 brgc7; /* BRG7 configuration register */
146 __be32 brgc8; /* BRG8 configuration register */
147 __be32 brgc9; /* BRG9 configuration register */
148 __be32 brgc10; /* BRG10 configuration register */
149 __be32 brgc11; /* BRG11 configuration register */
150 __be32 brgc12; /* BRG12 configuration register */
151 __be32 brgc13; /* BRG13 configuration register */
152 __be32 brgc14; /* BRG14 configuration register */
153 __be32 brgc15; /* BRG15 configuration register */
154 __be32 brgc16; /* BRG16 configuration register */
155 u8 res0[0x40]; 140 u8 res0[0x40];
156} __attribute__ ((packed)); 141} __attribute__ ((packed));
157 142
diff --git a/include/asm-powerpc/io-defs.h b/include/asm-powerpc/io-defs.h
new file mode 100644
index 000000000000..03691ab69217
--- /dev/null
+++ b/include/asm-powerpc/io-defs.h
@@ -0,0 +1,59 @@
1/* This file is meant to be include multiple times by other headers */
2
3DEF_PCI_AC_RET(readb, u8, (const PCI_IO_ADDR addr), (addr))
4DEF_PCI_AC_RET(readw, u16, (const PCI_IO_ADDR addr), (addr))
5DEF_PCI_AC_RET(readl, u32, (const PCI_IO_ADDR addr), (addr))
6DEF_PCI_AC_RET(readw_be, u16, (const PCI_IO_ADDR addr), (addr))
7DEF_PCI_AC_RET(readl_be, u32, (const PCI_IO_ADDR addr), (addr))
8DEF_PCI_AC_NORET(writeb, (u8 val, PCI_IO_ADDR addr), (val, addr))
9DEF_PCI_AC_NORET(writew, (u16 val, PCI_IO_ADDR addr), (val, addr))
10DEF_PCI_AC_NORET(writel, (u32 val, PCI_IO_ADDR addr), (val, addr))
11DEF_PCI_AC_NORET(writew_be, (u16 val, PCI_IO_ADDR addr), (val, addr))
12DEF_PCI_AC_NORET(writel_be, (u32 val, PCI_IO_ADDR addr), (val, addr))
13
14#ifdef __powerpc64__
15DEF_PCI_AC_RET(readq, u64, (const PCI_IO_ADDR addr), (addr))
16DEF_PCI_AC_RET(readq_be, u64, (const PCI_IO_ADDR addr), (addr))
17DEF_PCI_AC_NORET(writeq, (u64 val, PCI_IO_ADDR addr), (val, addr))
18DEF_PCI_AC_NORET(writeq_be, (u64 val, PCI_IO_ADDR addr), (val, addr))
19#endif /* __powerpc64__ */
20
21DEF_PCI_AC_RET(inb, u8, (unsigned long port), (port))
22DEF_PCI_AC_RET(inw, u16, (unsigned long port), (port))
23DEF_PCI_AC_RET(inl, u32, (unsigned long port), (port))
24DEF_PCI_AC_NORET(outb, (u8 val, unsigned long port), (val, port))
25DEF_PCI_AC_NORET(outw, (u16 val, unsigned long port), (val, port))
26DEF_PCI_AC_NORET(outl, (u32 val, unsigned long port), (val, port))
27
28DEF_PCI_AC_NORET(readsb, (const PCI_IO_ADDR a, void *b, unsigned long c), \
29 (a, b, c))
30DEF_PCI_AC_NORET(readsw, (const PCI_IO_ADDR a, void *b, unsigned long c), \
31 (a, b, c))
32DEF_PCI_AC_NORET(readsl, (const PCI_IO_ADDR a, void *b, unsigned long c), \
33 (a, b, c))
34DEF_PCI_AC_NORET(writesb, (PCI_IO_ADDR a, const void *b, unsigned long c), \
35 (a, b, c))
36DEF_PCI_AC_NORET(writesw, (PCI_IO_ADDR a, const void *b, unsigned long c), \
37 (a, b, c))
38DEF_PCI_AC_NORET(writesl, (PCI_IO_ADDR a, const void *b, unsigned long c), \
39 (a, b, c))
40
41DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), \
42 (p, b, c))
43DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), \
44 (p, b, c))
45DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), \
46 (p, b, c))
47DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), \
48 (p, b, c))
49DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), \
50 (p, b, c))
51DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), \
52 (p, b, c))
53
54DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n), \
55 (a, c, n))
56DEF_PCI_AC_NORET(memcpy_fromio,(void *d,const PCI_IO_ADDR s,unsigned long n), \
57 (d, s, n))
58DEF_PCI_AC_NORET(memcpy_toio,(PCI_IO_ADDR d,const void *s,unsigned long n), \
59 (d, s, n))
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index c2c5f14b5f5f..1cd532379c30 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -13,154 +13,530 @@
13extern int check_legacy_ioport(unsigned long base_port); 13extern int check_legacy_ioport(unsigned long base_port);
14#define PNPBIOS_BASE 0xf000 /* only relevant for PReP */ 14#define PNPBIOS_BASE 0xf000 /* only relevant for PReP */
15 15
16#ifndef CONFIG_PPC64
17#include <asm-ppc/io.h>
18#else
19
20#include <linux/compiler.h> 16#include <linux/compiler.h>
21#include <asm/page.h> 17#include <asm/page.h>
22#include <asm/byteorder.h> 18#include <asm/byteorder.h>
23#include <asm/paca.h>
24#include <asm/synch.h> 19#include <asm/synch.h>
25#include <asm/delay.h> 20#include <asm/delay.h>
21#include <asm/mmu.h>
26 22
27#include <asm-generic/iomap.h> 23#include <asm-generic/iomap.h>
28 24
25#ifdef CONFIG_PPC64
26#include <asm/paca.h>
27#endif
28
29#define SIO_CONFIG_RA 0x398 29#define SIO_CONFIG_RA 0x398
30#define SIO_CONFIG_RD 0x399 30#define SIO_CONFIG_RD 0x399
31 31
32#define SLOW_DOWN_IO 32#define SLOW_DOWN_IO
33 33
34/* 32 bits uses slightly different variables for the various IO
35 * bases. Most of this file only uses _IO_BASE though which we
36 * define properly based on the platform
37 */
38#ifndef CONFIG_PCI
39#define _IO_BASE 0
40#define _ISA_MEM_BASE 0
41#define PCI_DRAM_OFFSET 0
42#elif defined(CONFIG_PPC32)
43#define _IO_BASE isa_io_base
44#define _ISA_MEM_BASE isa_mem_base
45#define PCI_DRAM_OFFSET pci_dram_offset
46#else
47#define _IO_BASE pci_io_base
48#define _ISA_MEM_BASE 0
49#define PCI_DRAM_OFFSET 0
50#endif
51
34extern unsigned long isa_io_base; 52extern unsigned long isa_io_base;
53extern unsigned long isa_mem_base;
35extern unsigned long pci_io_base; 54extern unsigned long pci_io_base;
55extern unsigned long pci_dram_offset;
56
57#if defined(CONFIG_PPC32) && defined(CONFIG_PPC_INDIRECT_IO)
58#error CONFIG_PPC_INDIRECT_IO is not yet supported on 32 bits
59#endif
60
61/*
62 *
63 * Low level MMIO accessors
64 *
65 * This provides the non-bus specific accessors to MMIO. Those are PowerPC
66 * specific and thus shouldn't be used in generic code. The accessors
67 * provided here are:
68 *
69 * in_8, in_le16, in_be16, in_le32, in_be32, in_le64, in_be64
70 * out_8, out_le16, out_be16, out_le32, out_be32, out_le64, out_be64
71 * _insb, _insw_ns, _insl_ns, _outsb, _outsw_ns, _outsl_ns
72 *
73 * Those operate directly on a kernel virtual address. Note that the prototype
74 * for the out_* accessors has the arguments in opposite order from the usual
75 * linux PCI accessors. Unlike those, they take the address first and the value
76 * next.
77 *
78 * Note: I might drop the _ns suffix on the stream operations soon as it is
79 * simply normal for stream operations to not swap in the first place.
80 *
81 */
82
83#ifdef CONFIG_PPC64
84#define IO_SET_SYNC_FLAG() do { get_paca()->io_sync = 1; } while(0)
85#else
86#define IO_SET_SYNC_FLAG()
87#endif
88
89#define DEF_MMIO_IN(name, type, insn) \
90static inline type name(const volatile type __iomem *addr) \
91{ \
92 type ret; \
93 __asm__ __volatile__("sync;" insn ";twi 0,%0,0;isync" \
94 : "=r" (ret) : "r" (addr), "m" (*addr)); \
95 return ret; \
96}
97
98#define DEF_MMIO_OUT(name, type, insn) \
99static inline void name(volatile type __iomem *addr, type val) \
100{ \
101 __asm__ __volatile__("sync;" insn \
102 : "=m" (*addr) : "r" (val), "r" (addr)); \
103 IO_SET_SYNC_FLAG(); \
104}
105
106
107#define DEF_MMIO_IN_BE(name, size, insn) \
108 DEF_MMIO_IN(name, u##size, __stringify(insn)"%U2%X2 %0,%2")
109#define DEF_MMIO_IN_LE(name, size, insn) \
110 DEF_MMIO_IN(name, u##size, __stringify(insn)" %0,0,%1")
111
112#define DEF_MMIO_OUT_BE(name, size, insn) \
113 DEF_MMIO_OUT(name, u##size, __stringify(insn)"%U0%X0 %1,%0")
114#define DEF_MMIO_OUT_LE(name, size, insn) \
115 DEF_MMIO_OUT(name, u##size, __stringify(insn)" %1,0,%2")
116
117DEF_MMIO_IN_BE(in_8, 8, lbz);
118DEF_MMIO_IN_BE(in_be16, 16, lhz);
119DEF_MMIO_IN_BE(in_be32, 32, lwz);
120DEF_MMIO_IN_LE(in_le16, 16, lhbrx);
121DEF_MMIO_IN_LE(in_le32, 32, lwbrx);
122
123DEF_MMIO_OUT_BE(out_8, 8, stb);
124DEF_MMIO_OUT_BE(out_be16, 16, sth);
125DEF_MMIO_OUT_BE(out_be32, 32, stw);
126DEF_MMIO_OUT_LE(out_le16, 16, sthbrx);
127DEF_MMIO_OUT_LE(out_le32, 32, stwbrx);
128
129#ifdef __powerpc64__
130DEF_MMIO_OUT_BE(out_be64, 64, std);
131DEF_MMIO_IN_BE(in_be64, 64, ld);
132
133/* There is no asm instructions for 64 bits reverse loads and stores */
134static inline u64 in_le64(const volatile u64 __iomem *addr)
135{
136 return le64_to_cpu(in_be64(addr));
137}
138
139static inline void out_le64(volatile u64 __iomem *addr, u64 val)
140{
141 out_be64(addr, cpu_to_le64(val));
142}
143#endif /* __powerpc64__ */
144
145/*
146 * Low level IO stream instructions are defined out of line for now
147 */
148extern void _insb(const volatile u8 __iomem *addr, void *buf, long count);
149extern void _outsb(volatile u8 __iomem *addr,const void *buf,long count);
150extern void _insw_ns(const volatile u16 __iomem *addr, void *buf, long count);
151extern void _outsw_ns(volatile u16 __iomem *addr, const void *buf, long count);
152extern void _insl_ns(const volatile u32 __iomem *addr, void *buf, long count);
153extern void _outsl_ns(volatile u32 __iomem *addr, const void *buf, long count);
154
155/* The _ns naming is historical and will be removed. For now, just #define
156 * the non _ns equivalent names
157 */
158#define _insw _insw_ns
159#define _insl _insl_ns
160#define _outsw _outsw_ns
161#define _outsl _outsl_ns
162
163
164/*
165 * memset_io, memcpy_toio, memcpy_fromio base implementations are out of line
166 */
167
168extern void _memset_io(volatile void __iomem *addr, int c, unsigned long n);
169extern void _memcpy_fromio(void *dest, const volatile void __iomem *src,
170 unsigned long n);
171extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
172 unsigned long n);
173
174/*
175 *
176 * PCI and standard ISA accessors
177 *
178 * Those are globally defined linux accessors for devices on PCI or ISA
179 * busses. They follow the Linux defined semantics. The current implementation
180 * for PowerPC is as close as possible to the x86 version of these, and thus
181 * provides fairly heavy weight barriers for the non-raw versions
182 *
183 * In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_IO
184 * allowing the platform to provide its own implementation of some or all
185 * of the accessors.
186 */
187
188/*
189 * Include the EEH definitions when EEH is enabled only so they don't get
190 * in the way when building for 32 bits
191 */
192#ifdef CONFIG_EEH
193#include <asm/eeh.h>
194#endif
195
196/* Shortcut to the MMIO argument pointer */
197#define PCI_IO_ADDR volatile void __iomem *
198
199/* Indirect IO address tokens:
200 *
201 * When CONFIG_PPC_INDIRECT_IO is set, the platform can provide hooks
202 * on all IOs. (Note that this is all 64 bits only for now)
203 *
204 * To help platforms who may need to differenciate MMIO addresses in
205 * their hooks, a bitfield is reserved for use by the platform near the
206 * top of MMIO addresses (not PIO, those have to cope the hard way).
207 *
208 * This bit field is 12 bits and is at the top of the IO virtual
209 * addresses PCI_IO_INDIRECT_TOKEN_MASK.
210 *
211 * The kernel virtual space is thus:
212 *
213 * 0xD000000000000000 : vmalloc
214 * 0xD000080000000000 : PCI PHB IO space
215 * 0xD000080080000000 : ioremap
216 * 0xD0000fffffffffff : end of ioremap region
217 *
218 * Since the top 4 bits are reserved as the region ID, we use thus
219 * the next 12 bits and keep 4 bits available for the future if the
220 * virtual address space is ever to be extended.
221 *
222 * The direct IO mapping operations will then mask off those bits
223 * before doing the actual access, though that only happen when
224 * CONFIG_PPC_INDIRECT_IO is set, thus be careful when you use that
225 * mechanism
226 */
227
228#ifdef CONFIG_PPC_INDIRECT_IO
229#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul
230#define PCI_IO_IND_TOKEN_SHIFT 48
231#define PCI_FIX_ADDR(addr) \
232 ((PCI_IO_ADDR)(((unsigned long)(addr)) & ~PCI_IO_IND_TOKEN_MASK))
233#define PCI_GET_ADDR_TOKEN(addr) \
234 (((unsigned long)(addr) & PCI_IO_IND_TOKEN_MASK) >> \
235 PCI_IO_IND_TOKEN_SHIFT)
236#define PCI_SET_ADDR_TOKEN(addr, token) \
237do { \
238 unsigned long __a = (unsigned long)(addr); \
239 __a &= ~PCI_IO_IND_TOKEN_MASK; \
240 __a |= ((unsigned long)(token)) << PCI_IO_IND_TOKEN_SHIFT; \
241 (addr) = (void __iomem *)__a; \
242} while(0)
243#else
244#define PCI_FIX_ADDR(addr) (addr)
245#endif
36 246
37#ifdef CONFIG_PPC_ISERIES 247
38 248/*
39extern int in_8(const volatile unsigned char __iomem *addr); 249 * Non ordered and non-swapping "raw" accessors
40extern void out_8(volatile unsigned char __iomem *addr, int val); 250 */
41extern int in_le16(const volatile unsigned short __iomem *addr);
42extern int in_be16(const volatile unsigned short __iomem *addr);
43extern void out_le16(volatile unsigned short __iomem *addr, int val);
44extern void out_be16(volatile unsigned short __iomem *addr, int val);
45extern unsigned in_le32(const volatile unsigned __iomem *addr);
46extern unsigned in_be32(const volatile unsigned __iomem *addr);
47extern void out_le32(volatile unsigned __iomem *addr, int val);
48extern void out_be32(volatile unsigned __iomem *addr, int val);
49extern unsigned long in_le64(const volatile unsigned long __iomem *addr);
50extern unsigned long in_be64(const volatile unsigned long __iomem *addr);
51extern void out_le64(volatile unsigned long __iomem *addr, unsigned long val);
52extern void out_be64(volatile unsigned long __iomem *addr, unsigned long val);
53
54extern unsigned char __raw_readb(const volatile void __iomem *addr);
55extern unsigned short __raw_readw(const volatile void __iomem *addr);
56extern unsigned int __raw_readl(const volatile void __iomem *addr);
57extern unsigned long __raw_readq(const volatile void __iomem *addr);
58extern void __raw_writeb(unsigned char v, volatile void __iomem *addr);
59extern void __raw_writew(unsigned short v, volatile void __iomem *addr);
60extern void __raw_writel(unsigned int v, volatile void __iomem *addr);
61extern void __raw_writeq(unsigned long v, volatile void __iomem *addr);
62
63extern void memset_io(volatile void __iomem *addr, int c, unsigned long n);
64extern void memcpy_fromio(void *dest, const volatile void __iomem *src,
65 unsigned long n);
66extern void memcpy_toio(volatile void __iomem *dest, const void *src,
67 unsigned long n);
68
69#else /* CONFIG_PPC_ISERIES */
70
71#define in_8(addr) __in_8((addr))
72#define out_8(addr, val) __out_8((addr), (val))
73#define in_le16(addr) __in_le16((addr))
74#define in_be16(addr) __in_be16((addr))
75#define out_le16(addr, val) __out_le16((addr), (val))
76#define out_be16(addr, val) __out_be16((addr), (val))
77#define in_le32(addr) __in_le32((addr))
78#define in_be32(addr) __in_be32((addr))
79#define out_le32(addr, val) __out_le32((addr), (val))
80#define out_be32(addr, val) __out_be32((addr), (val))
81#define in_le64(addr) __in_le64((addr))
82#define in_be64(addr) __in_be64((addr))
83#define out_le64(addr, val) __out_le64((addr), (val))
84#define out_be64(addr, val) __out_be64((addr), (val))
85 251
86static inline unsigned char __raw_readb(const volatile void __iomem *addr) 252static inline unsigned char __raw_readb(const volatile void __iomem *addr)
87{ 253{
88 return *(volatile unsigned char __force *)addr; 254 return *(volatile unsigned char __force *)PCI_FIX_ADDR(addr);
89} 255}
90static inline unsigned short __raw_readw(const volatile void __iomem *addr) 256static inline unsigned short __raw_readw(const volatile void __iomem *addr)
91{ 257{
92 return *(volatile unsigned short __force *)addr; 258 return *(volatile unsigned short __force *)PCI_FIX_ADDR(addr);
93} 259}
94static inline unsigned int __raw_readl(const volatile void __iomem *addr) 260static inline unsigned int __raw_readl(const volatile void __iomem *addr)
95{ 261{
96 return *(volatile unsigned int __force *)addr; 262 return *(volatile unsigned int __force *)PCI_FIX_ADDR(addr);
97}
98static inline unsigned long __raw_readq(const volatile void __iomem *addr)
99{
100 return *(volatile unsigned long __force *)addr;
101} 263}
102static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr) 264static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
103{ 265{
104 *(volatile unsigned char __force *)addr = v; 266 *(volatile unsigned char __force *)PCI_FIX_ADDR(addr) = v;
105} 267}
106static inline void __raw_writew(unsigned short v, volatile void __iomem *addr) 268static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
107{ 269{
108 *(volatile unsigned short __force *)addr = v; 270 *(volatile unsigned short __force *)PCI_FIX_ADDR(addr) = v;
109} 271}
110static inline void __raw_writel(unsigned int v, volatile void __iomem *addr) 272static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
111{ 273{
112 *(volatile unsigned int __force *)addr = v; 274 *(volatile unsigned int __force *)PCI_FIX_ADDR(addr) = v;
275}
276
277#ifdef __powerpc64__
278static inline unsigned long __raw_readq(const volatile void __iomem *addr)
279{
280 return *(volatile unsigned long __force *)PCI_FIX_ADDR(addr);
113} 281}
114static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr) 282static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
115{ 283{
116 *(volatile unsigned long __force *)addr = v; 284 *(volatile unsigned long __force *)PCI_FIX_ADDR(addr) = v;
285}
286#endif /* __powerpc64__ */
287
288/*
289 *
290 * PCI PIO and MMIO accessors.
291 *
292 *
293 * On 32 bits, PIO operations have a recovery mechanism in case they trigger
294 * machine checks (which they occasionally do when probing non existing
295 * IO ports on some platforms, like PowerMac and 8xx).
296 * I always found it to be of dubious reliability and I am tempted to get
297 * rid of it one of these days. So if you think it's important to keep it,
298 * please voice up asap. We never had it for 64 bits and I do not intend
299 * to port it over
300 */
301
302#ifdef CONFIG_PPC32
303
304#define __do_in_asm(name, op) \
305static inline unsigned int name(unsigned int port) \
306{ \
307 unsigned int x; \
308 __asm__ __volatile__( \
309 "sync\n" \
310 "0:" op " %0,0,%1\n" \
311 "1: twi 0,%0,0\n" \
312 "2: isync\n" \
313 "3: nop\n" \
314 "4:\n" \
315 ".section .fixup,\"ax\"\n" \
316 "5: li %0,-1\n" \
317 " b 4b\n" \
318 ".previous\n" \
319 ".section __ex_table,\"a\"\n" \
320 " .align 2\n" \
321 " .long 0b,5b\n" \
322 " .long 1b,5b\n" \
323 " .long 2b,5b\n" \
324 " .long 3b,5b\n" \
325 ".previous" \
326 : "=&r" (x) \
327 : "r" (port + _IO_BASE)); \
328 return x; \
329}
330
331#define __do_out_asm(name, op) \
332static inline void name(unsigned int val, unsigned int port) \
333{ \
334 __asm__ __volatile__( \
335 "sync\n" \
336 "0:" op " %0,0,%1\n" \
337 "1: sync\n" \
338 "2:\n" \
339 ".section __ex_table,\"a\"\n" \
340 " .align 2\n" \
341 " .long 0b,2b\n" \
342 " .long 1b,2b\n" \
343 ".previous" \
344 : : "r" (val), "r" (port + _IO_BASE)); \
345}
346
347__do_in_asm(_rec_inb, "lbzx")
348__do_in_asm(_rec_inw, "lhbrx")
349__do_in_asm(_rec_inl, "lwbrx")
350__do_out_asm(_rec_outb, "stbx")
351__do_out_asm(_rec_outw, "sthbrx")
352__do_out_asm(_rec_outl, "stwbrx")
353
354#endif /* CONFIG_PPC32 */
355
356/* The "__do_*" operations below provide the actual "base" implementation
357 * for each of the defined acccessor. Some of them use the out_* functions
358 * directly, some of them still use EEH, though we might change that in the
359 * future. Those macros below provide the necessary argument swapping and
360 * handling of the IO base for PIO.
361 *
362 * They are themselves used by the macros that define the actual accessors
363 * and can be used by the hooks if any.
364 *
365 * Note that PIO operations are always defined in terms of their corresonding
366 * MMIO operations. That allows platforms like iSeries who want to modify the
367 * behaviour of both to only hook on the MMIO version and get both. It's also
368 * possible to hook directly at the toplevel PIO operation if they have to
369 * be handled differently
370 */
371#define __do_writeb(val, addr) out_8(PCI_FIX_ADDR(addr), val)
372#define __do_writew(val, addr) out_le16(PCI_FIX_ADDR(addr), val)
373#define __do_writel(val, addr) out_le32(PCI_FIX_ADDR(addr), val)
374#define __do_writeq(val, addr) out_le64(PCI_FIX_ADDR(addr), val)
375#define __do_writew_be(val, addr) out_be16(PCI_FIX_ADDR(addr), val)
376#define __do_writel_be(val, addr) out_be32(PCI_FIX_ADDR(addr), val)
377#define __do_writeq_be(val, addr) out_be64(PCI_FIX_ADDR(addr), val)
378
379#ifdef CONFIG_EEH
380#define __do_readb(addr) eeh_readb(PCI_FIX_ADDR(addr))
381#define __do_readw(addr) eeh_readw(PCI_FIX_ADDR(addr))
382#define __do_readl(addr) eeh_readl(PCI_FIX_ADDR(addr))
383#define __do_readq(addr) eeh_readq(PCI_FIX_ADDR(addr))
384#define __do_readw_be(addr) eeh_readw_be(PCI_FIX_ADDR(addr))
385#define __do_readl_be(addr) eeh_readl_be(PCI_FIX_ADDR(addr))
386#define __do_readq_be(addr) eeh_readq_be(PCI_FIX_ADDR(addr))
387#else /* CONFIG_EEH */
388#define __do_readb(addr) in_8(PCI_FIX_ADDR(addr))
389#define __do_readw(addr) in_le16(PCI_FIX_ADDR(addr))
390#define __do_readl(addr) in_le32(PCI_FIX_ADDR(addr))
391#define __do_readq(addr) in_le64(PCI_FIX_ADDR(addr))
392#define __do_readw_be(addr) in_be16(PCI_FIX_ADDR(addr))
393#define __do_readl_be(addr) in_be32(PCI_FIX_ADDR(addr))
394#define __do_readq_be(addr) in_be64(PCI_FIX_ADDR(addr))
395#endif /* !defined(CONFIG_EEH) */
396
397#ifdef CONFIG_PPC32
398#define __do_outb(val, port) _rec_outb(val, port)
399#define __do_outw(val, port) _rec_outw(val, port)
400#define __do_outl(val, port) _rec_outl(val, port)
401#define __do_inb(port) _rec_inb(port)
402#define __do_inw(port) _rec_inw(port)
403#define __do_inl(port) _rec_inl(port)
404#else /* CONFIG_PPC32 */
405#define __do_outb(val, port) writeb(val,(PCI_IO_ADDR)_IO_BASE+port);
406#define __do_outw(val, port) writew(val,(PCI_IO_ADDR)_IO_BASE+port);
407#define __do_outl(val, port) writel(val,(PCI_IO_ADDR)_IO_BASE+port);
408#define __do_inb(port) readb((PCI_IO_ADDR)_IO_BASE + port);
409#define __do_inw(port) readw((PCI_IO_ADDR)_IO_BASE + port);
410#define __do_inl(port) readl((PCI_IO_ADDR)_IO_BASE + port);
411#endif /* !CONFIG_PPC32 */
412
413#ifdef CONFIG_EEH
414#define __do_readsb(a, b, n) eeh_readsb(PCI_FIX_ADDR(a), (b), (n))
415#define __do_readsw(a, b, n) eeh_readsw(PCI_FIX_ADDR(a), (b), (n))
416#define __do_readsl(a, b, n) eeh_readsl(PCI_FIX_ADDR(a), (b), (n))
417#else /* CONFIG_EEH */
418#define __do_readsb(a, b, n) _insb(PCI_FIX_ADDR(a), (b), (n))
419#define __do_readsw(a, b, n) _insw(PCI_FIX_ADDR(a), (b), (n))
420#define __do_readsl(a, b, n) _insl(PCI_FIX_ADDR(a), (b), (n))
421#endif /* !CONFIG_EEH */
422#define __do_writesb(a, b, n) _outsb(PCI_FIX_ADDR(a),(b),(n))
423#define __do_writesw(a, b, n) _outsw(PCI_FIX_ADDR(a),(b),(n))
424#define __do_writesl(a, b, n) _outsl(PCI_FIX_ADDR(a),(b),(n))
425
426#define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
427#define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
428#define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
429#define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
430#define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
431#define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
432
433#define __do_memset_io(addr, c, n) \
434 _memset_io(PCI_FIX_ADDR(addr), c, n)
435#define __do_memcpy_toio(dst, src, n) \
436 _memcpy_toio(PCI_FIX_ADDR(dst), src, n)
437
438#ifdef CONFIG_EEH
439#define __do_memcpy_fromio(dst, src, n) \
440 eeh_memcpy_fromio(dst, PCI_FIX_ADDR(src), n)
441#else /* CONFIG_EEH */
442#define __do_memcpy_fromio(dst, src, n) \
443 _memcpy_fromio(dst,PCI_FIX_ADDR(src),n)
444#endif /* !CONFIG_EEH */
445
446#ifdef CONFIG_PPC_INDIRECT_IO
447#define DEF_PCI_HOOK(x) x
448#else
449#define DEF_PCI_HOOK(x) NULL
450#endif
451
452/* Structure containing all the hooks */
453extern struct ppc_pci_io {
454
455#define DEF_PCI_AC_RET(name, ret, at, al) ret (*name) at;
456#define DEF_PCI_AC_NORET(name, at, al) void (*name) at;
457
458#include <asm/io-defs.h>
459
460#undef DEF_PCI_AC_RET
461#undef DEF_PCI_AC_NORET
462
463} ppc_pci_io;
464
465/* The inline wrappers */
466#define DEF_PCI_AC_RET(name, ret, at, al) \
467static inline ret name at \
468{ \
469 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
470 return ppc_pci_io.name al; \
471 return __do_##name al; \
472}
473
474#define DEF_PCI_AC_NORET(name, at, al) \
475static inline void name at \
476{ \
477 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \
478 ppc_pci_io.name al; \
479 else \
480 __do_##name al; \
117} 481}
118#define memset_io(a,b,c) eeh_memset_io((a),(b),(c))
119#define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c))
120#define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c))
121 482
122#endif /* CONFIG_PPC_ISERIES */ 483#include <asm/io-defs.h>
484
485#undef DEF_PCI_AC_RET
486#undef DEF_PCI_AC_NORET
487
488/* Some drivers check for the presence of readq & writeq with
489 * a #ifdef, so we make them happy here.
490 */
491#ifdef __powerpc64__
492#define readq readq
493#define writeq writeq
494#endif
495
496#ifdef CONFIG_NOT_COHERENT_CACHE
497
498#define dma_cache_inv(_start,_size) \
499 invalidate_dcache_range(_start, (_start + _size))
500#define dma_cache_wback(_start,_size) \
501 clean_dcache_range(_start, (_start + _size))
502#define dma_cache_wback_inv(_start,_size) \
503 flush_dcache_range(_start, (_start + _size))
504
505#else /* CONFIG_NOT_COHERENT_CACHE */
506
507#define dma_cache_inv(_start,_size) do { } while (0)
508#define dma_cache_wback(_start,_size) do { } while (0)
509#define dma_cache_wback_inv(_start,_size) do { } while (0)
510
511#endif /* !CONFIG_NOT_COHERENT_CACHE */
123 512
124/* 513/*
125 * The insw/outsw/insl/outsl macros don't do byte-swapping. 514 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
126 * They are only used in practice for transferring buffers which 515 * access
127 * are arrays of bytes, and byte-swapping is not appropriate in 516 */
128 * that case. - paulus */ 517#define xlate_dev_mem_ptr(p) __va(p)
129#define insb(port, buf, ns) eeh_insb((port), (buf), (ns)) 518
130#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) 519/*
131#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) 520 * Convert a virtual cached pointer to an uncached pointer
132 521 */
133#define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 522#define xlate_dev_kmem_ptr(p) p
134#define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
135#define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
136
137#define readb(addr) eeh_readb(addr)
138#define readw(addr) eeh_readw(addr)
139#define readl(addr) eeh_readl(addr)
140#define readq(addr) eeh_readq(addr)
141#define writeb(data, addr) eeh_writeb((data), (addr))
142#define writew(data, addr) eeh_writew((data), (addr))
143#define writel(data, addr) eeh_writel((data), (addr))
144#define writeq(data, addr) eeh_writeq((data), (addr))
145#define inb(port) eeh_inb((unsigned long)port)
146#define outb(val, port) eeh_outb(val, (unsigned long)port)
147#define inw(port) eeh_inw((unsigned long)port)
148#define outw(val, port) eeh_outw(val, (unsigned long)port)
149#define inl(port) eeh_inl((unsigned long)port)
150#define outl(val, port) eeh_outl(val, (unsigned long)port)
151 523
524/*
525 * We don't do relaxed operations yet, at least not with this semantic
526 */
152#define readb_relaxed(addr) readb(addr) 527#define readb_relaxed(addr) readb(addr)
153#define readw_relaxed(addr) readw(addr) 528#define readw_relaxed(addr) readw(addr)
154#define readl_relaxed(addr) readl(addr) 529#define readl_relaxed(addr) readl(addr)
155#define readq_relaxed(addr) readq(addr) 530#define readq_relaxed(addr) readq(addr)
156 531
157extern void _insb(volatile u8 __iomem *port, void *buf, long count); 532#ifdef CONFIG_PPC32
158extern void _outsb(volatile u8 __iomem *port, const void *buf, long count); 533#define mmiowb()
159extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count); 534#else
160extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count); 535/*
161extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count); 536 * Enforce synchronisation of stores vs. spin_unlock
162extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count); 537 * (this does it explicitely, though our implementation of spin_unlock
163 538 * does it implicitely too)
539 */
164static inline void mmiowb(void) 540static inline void mmiowb(void)
165{ 541{
166 unsigned long tmp; 542 unsigned long tmp;
@@ -169,6 +545,24 @@ static inline void mmiowb(void)
169 : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync)) 545 : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync))
170 : "memory"); 546 : "memory");
171} 547}
548#endif /* !CONFIG_PPC32 */
549
550static inline void iosync(void)
551{
552 __asm__ __volatile__ ("sync" : : : "memory");
553}
554
555/* Enforce in-order execution of data I/O.
556 * No distinction between read/write on PPC; use eieio for all three.
557 * Those are fairly week though. They don't provide a barrier between
558 * MMIO and cacheable storage nor do they provide a barrier vs. locks,
559 * they only provide barriers between 2 __raw MMIO operations and
560 * possibly break write combining.
561 */
562#define iobarrier_rw() eieio()
563#define iobarrier_r() eieio()
564#define iobarrier_w() eieio()
565
172 566
173/* 567/*
174 * output pause versions need a delay at least for the 568 * output pause versions need a delay at least for the
@@ -185,11 +579,6 @@ static inline void mmiowb(void)
185#define IO_SPACE_LIMIT ~(0UL) 579#define IO_SPACE_LIMIT ~(0UL)
186 580
187 581
188extern int __ioremap_explicit(unsigned long p_addr, unsigned long v_addr,
189 unsigned long size, unsigned long flags);
190extern void __iomem *__ioremap(unsigned long address, unsigned long size,
191 unsigned long flags);
192
193/** 582/**
194 * ioremap - map bus memory into CPU space 583 * ioremap - map bus memory into CPU space
195 * @address: bus address of the memory 584 * @address: bus address of the memory
@@ -200,14 +589,77 @@ extern void __iomem *__ioremap(unsigned long address, unsigned long size,
200 * writew/writel functions and the other mmio helpers. The returned 589 * writew/writel functions and the other mmio helpers. The returned
201 * address is not guaranteed to be usable directly as a virtual 590 * address is not guaranteed to be usable directly as a virtual
202 * address. 591 * address.
592 *
593 * We provide a few variations of it:
594 *
595 * * ioremap is the standard one and provides non-cacheable guarded mappings
596 * and can be hooked by the platform via ppc_md
597 *
598 * * ioremap_flags allows to specify the page flags as an argument and can
599 * also be hooked by the platform via ppc_md
600 *
601 * * ioremap_nocache is identical to ioremap
602 *
603 * * iounmap undoes such a mapping and can be hooked
604 *
605 * * __ioremap_explicit (and the pending __iounmap_explicit) are low level
606 * functions to create hand-made mappings for use only by the PCI code
607 * and cannot currently be hooked.
608 *
609 * * __ioremap is the low level implementation used by ioremap and
610 * ioremap_flags and cannot be hooked (but can be used by a hook on one
611 * of the previous ones)
612 *
613 * * __iounmap, is the low level implementation used by iounmap and cannot
614 * be hooked (but can be used by a hook on iounmap)
615 *
203 */ 616 */
204extern void __iomem *ioremap(unsigned long address, unsigned long size); 617extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
205 618extern void __iomem *ioremap_flags(phys_addr_t address, unsigned long size,
619 unsigned long flags);
206#define ioremap_nocache(addr, size) ioremap((addr), (size)) 620#define ioremap_nocache(addr, size) ioremap((addr), (size))
207extern int iounmap_explicit(volatile void __iomem *addr, unsigned long size);
208extern void iounmap(volatile void __iomem *addr); 621extern void iounmap(volatile void __iomem *addr);
622
623extern void __iomem *__ioremap(phys_addr_t, unsigned long size,
624 unsigned long flags);
625extern void __iounmap(volatile void __iomem *addr);
626
627extern int __ioremap_explicit(phys_addr_t p_addr, unsigned long v_addr,
628 unsigned long size, unsigned long flags);
629extern int __iounmap_explicit(volatile void __iomem *start,
630 unsigned long size);
631
209extern void __iomem * reserve_phb_iospace(unsigned long size); 632extern void __iomem * reserve_phb_iospace(unsigned long size);
210 633
634/* Those are more 32 bits only functions */
635extern unsigned long iopa(unsigned long addr);
636extern unsigned long mm_ptov(unsigned long addr) __attribute_const__;
637extern void io_block_mapping(unsigned long virt, phys_addr_t phys,
638 unsigned int size, int flags);
639
640
641/*
642 * When CONFIG_PPC_INDIRECT_IO is set, we use the generic iomap implementation
643 * which needs some additional definitions here. They basically allow PIO
644 * space overall to be 1GB. This will work as long as we never try to use
645 * iomap to map MMIO below 1GB which should be fine on ppc64
646 */
647#define HAVE_ARCH_PIO_SIZE 1
648#define PIO_OFFSET 0x00000000UL
649#define PIO_MASK 0x3fffffffUL
650#define PIO_RESERVED 0x40000000UL
651
652#define mmio_read16be(addr) readw_be(addr)
653#define mmio_read32be(addr) readl_be(addr)
654#define mmio_write16be(val, addr) writew_be(val, addr)
655#define mmio_write32be(val, addr) writel_be(val, addr)
656#define mmio_insb(addr, dst, count) readsb(addr, dst, count)
657#define mmio_insw(addr, dst, count) readsw(addr, dst, count)
658#define mmio_insl(addr, dst, count) readsl(addr, dst, count)
659#define mmio_outsb(addr, src, count) writesb(addr, src, count)
660#define mmio_outsw(addr, src, count) writesw(addr, src, count)
661#define mmio_outsl(addr, src, count) writesl(addr, src, count)
662
211/** 663/**
212 * virt_to_phys - map virtual addresses to physical 664 * virt_to_phys - map virtual addresses to physical
213 * @address: address to remap 665 * @address: address to remap
@@ -254,178 +706,33 @@ static inline void * phys_to_virt(unsigned long address)
254 */ 706 */
255#define BIO_VMERGE_BOUNDARY 0 707#define BIO_VMERGE_BOUNDARY 0
256 708
257static inline void iosync(void)
258{
259 __asm__ __volatile__ ("sync" : : : "memory");
260}
261
262/* Enforce in-order execution of data I/O.
263 * No distinction between read/write on PPC; use eieio for all three.
264 */
265#define iobarrier_rw() eieio()
266#define iobarrier_r() eieio()
267#define iobarrier_w() eieio()
268
269/* 709/*
270 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier. 710 * 32 bits still uses virt_to_bus() for it's implementation of DMA
271 * These routines do not perform EEH-related I/O address translation, 711 * mappings se we have to keep it defined here. We also have some old
272 * and should not be used directly by device drivers. Use inb/readb 712 * drivers (shame shame shame) that use bus_to_virt() and haven't been
273 * instead. 713 * fixed yet so I need to define it here.
274 */ 714 */
275static inline int __in_8(const volatile unsigned char __iomem *addr) 715#ifdef CONFIG_PPC32
276{
277 int ret;
278 716
279 __asm__ __volatile__("sync; lbz%U1%X1 %0,%1; twi 0,%0,0; isync" 717static inline unsigned long virt_to_bus(volatile void * address)
280 : "=r" (ret) : "m" (*addr));
281 return ret;
282}
283
284static inline void __out_8(volatile unsigned char __iomem *addr, int val)
285{
286 __asm__ __volatile__("sync; stb%U0%X0 %1,%0"
287 : "=m" (*addr) : "r" (val));
288 get_paca()->io_sync = 1;
289}
290
291static inline int __in_le16(const volatile unsigned short __iomem *addr)
292{ 718{
293 int ret; 719 if (address == NULL)
294 720 return 0;
295 __asm__ __volatile__("sync; lhbrx %0,0,%1; twi 0,%0,0; isync" 721 return __pa(address) + PCI_DRAM_OFFSET;
296 : "=r" (ret) : "r" (addr), "m" (*addr));
297 return ret;
298} 722}
299 723
300static inline int __in_be16(const volatile unsigned short __iomem *addr) 724static inline void * bus_to_virt(unsigned long address)
301{ 725{
302 int ret; 726 if (address == 0)
303 727 return NULL;
304 __asm__ __volatile__("sync; lhz%U1%X1 %0,%1; twi 0,%0,0; isync" 728 return __va(address - PCI_DRAM_OFFSET);
305 : "=r" (ret) : "m" (*addr));
306 return ret;
307} 729}
308 730
309static inline void __out_le16(volatile unsigned short __iomem *addr, int val) 731#define page_to_bus(page) (page_to_phys(page) + PCI_DRAM_OFFSET)
310{
311 __asm__ __volatile__("sync; sthbrx %1,0,%2"
312 : "=m" (*addr) : "r" (val), "r" (addr));
313 get_paca()->io_sync = 1;
314}
315
316static inline void __out_be16(volatile unsigned short __iomem *addr, int val)
317{
318 __asm__ __volatile__("sync; sth%U0%X0 %1,%0"
319 : "=m" (*addr) : "r" (val));
320 get_paca()->io_sync = 1;
321}
322
323static inline unsigned __in_le32(const volatile unsigned __iomem *addr)
324{
325 unsigned ret;
326
327 __asm__ __volatile__("sync; lwbrx %0,0,%1; twi 0,%0,0; isync"
328 : "=r" (ret) : "r" (addr), "m" (*addr));
329 return ret;
330}
331 732
332static inline unsigned __in_be32(const volatile unsigned __iomem *addr) 733#endif /* CONFIG_PPC32 */
333{
334 unsigned ret;
335
336 __asm__ __volatile__("sync; lwz%U1%X1 %0,%1; twi 0,%0,0; isync"
337 : "=r" (ret) : "m" (*addr));
338 return ret;
339}
340
341static inline void __out_le32(volatile unsigned __iomem *addr, int val)
342{
343 __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr)
344 : "r" (val), "r" (addr));
345 get_paca()->io_sync = 1;
346}
347
348static inline void __out_be32(volatile unsigned __iomem *addr, int val)
349{
350 __asm__ __volatile__("sync; stw%U0%X0 %1,%0"
351 : "=m" (*addr) : "r" (val));
352 get_paca()->io_sync = 1;
353}
354
355static inline unsigned long __in_le64(const volatile unsigned long __iomem *addr)
356{
357 unsigned long tmp, ret;
358
359 __asm__ __volatile__(
360 "sync\n"
361 "ld %1,0(%2)\n"
362 "twi 0,%1,0\n"
363 "isync\n"
364 "rldimi %0,%1,5*8,1*8\n"
365 "rldimi %0,%1,3*8,2*8\n"
366 "rldimi %0,%1,1*8,3*8\n"
367 "rldimi %0,%1,7*8,4*8\n"
368 "rldicl %1,%1,32,0\n"
369 "rlwimi %0,%1,8,8,31\n"
370 "rlwimi %0,%1,24,16,23\n"
371 : "=r" (ret) , "=r" (tmp) : "b" (addr) , "m" (*addr));
372 return ret;
373}
374
375static inline unsigned long __in_be64(const volatile unsigned long __iomem *addr)
376{
377 unsigned long ret;
378 734
379 __asm__ __volatile__("sync; ld%U1%X1 %0,%1; twi 0,%0,0; isync"
380 : "=r" (ret) : "m" (*addr));
381 return ret;
382}
383
384static inline void __out_le64(volatile unsigned long __iomem *addr, unsigned long val)
385{
386 unsigned long tmp;
387
388 __asm__ __volatile__(
389 "rldimi %0,%1,5*8,1*8\n"
390 "rldimi %0,%1,3*8,2*8\n"
391 "rldimi %0,%1,1*8,3*8\n"
392 "rldimi %0,%1,7*8,4*8\n"
393 "rldicl %1,%1,32,0\n"
394 "rlwimi %0,%1,8,8,31\n"
395 "rlwimi %0,%1,24,16,23\n"
396 "sync\n"
397 "std %0,0(%3)"
398 : "=&r" (tmp) , "=&r" (val) : "1" (val) , "b" (addr) , "m" (*addr));
399 get_paca()->io_sync = 1;
400}
401
402static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned long val)
403{
404 __asm__ __volatile__("sync; std%U0%X0 %1,%0" : "=m" (*addr) : "r" (val));
405 get_paca()->io_sync = 1;
406}
407
408#include <asm/eeh.h>
409
410/* Nothing to do */
411
412#define dma_cache_inv(_start,_size) do { } while (0)
413#define dma_cache_wback(_start,_size) do { } while (0)
414#define dma_cache_wback_inv(_start,_size) do { } while (0)
415
416
417/*
418 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
419 * access
420 */
421#define xlate_dev_mem_ptr(p) __va(p)
422
423/*
424 * Convert a virtual cached pointer to an uncached pointer
425 */
426#define xlate_dev_kmem_ptr(p) p
427 735
428#endif /* __KERNEL__ */ 736#endif /* __KERNEL__ */
429 737
430#endif /* CONFIG_PPC64 */
431#endif /* _ASM_POWERPC_IO_H */ 738#endif /* _ASM_POWERPC_IO_H */
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index 39fad685ffab..f85dbd305558 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -34,7 +34,9 @@
34#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1)) 34#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1))
35#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE) 35#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE)
36 36
37#ifndef __ASSEMBLY__ 37/* Boot time flags */
38extern int iommu_is_off;
39extern int iommu_force_on;
38 40
39/* Pure 2^n version of get_order */ 41/* Pure 2^n version of get_order */
40static __inline__ __attribute_const__ int get_iommu_order(unsigned long size) 42static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
@@ -42,8 +44,6 @@ static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
42 return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT) + 1; 44 return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT) + 1;
43} 45}
44 46
45#endif /* __ASSEMBLY__ */
46
47 47
48/* 48/*
49 * IOMAP_MAX_ORDER defines the largest contiguous block 49 * IOMAP_MAX_ORDER defines the largest contiguous block
@@ -70,39 +70,31 @@ struct iommu_table {
70struct scatterlist; 70struct scatterlist;
71struct device_node; 71struct device_node;
72 72
73#ifdef CONFIG_PPC_MULTIPLATFORM
74
75/* Walks all buses and creates iommu tables */
76extern void iommu_setup_pSeries(void);
77extern void iommu_setup_dart(void);
78
79/* Frees table for an individual device node */ 73/* Frees table for an individual device node */
80extern void iommu_free_table(struct device_node *dn); 74extern void iommu_free_table(struct device_node *dn);
81 75
82#endif /* CONFIG_PPC_MULTIPLATFORM */
83
84/* Initializes an iommu_table based in values set in the passed-in 76/* Initializes an iommu_table based in values set in the passed-in
85 * structure 77 * structure
86 */ 78 */
87extern struct iommu_table *iommu_init_table(struct iommu_table * tbl, 79extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
88 int nid); 80 int nid);
89 81
90extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, 82extern int iommu_map_sg(struct iommu_table *tbl, struct scatterlist *sglist,
91 struct scatterlist *sglist, int nelems, unsigned long mask, 83 int nelems, unsigned long mask,
92 enum dma_data_direction direction); 84 enum dma_data_direction direction);
93extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist, 85extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
94 int nelems, enum dma_data_direction direction); 86 int nelems, enum dma_data_direction direction);
95 87
96extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size, 88extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
97 dma_addr_t *dma_handle, unsigned long mask, 89 dma_addr_t *dma_handle, unsigned long mask,
98 gfp_t flag, int node); 90 gfp_t flag, int node);
99extern void iommu_free_coherent(struct iommu_table *tbl, size_t size, 91extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
100 void *vaddr, dma_addr_t dma_handle); 92 void *vaddr, dma_addr_t dma_handle);
101extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr, 93extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
102 size_t size, unsigned long mask, 94 size_t size, unsigned long mask,
103 enum dma_data_direction direction); 95 enum dma_data_direction direction);
104extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, 96extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
105 size_t size, enum dma_data_direction direction); 97 size_t size, enum dma_data_direction direction);
106 98
107extern void iommu_init_early_pSeries(void); 99extern void iommu_init_early_pSeries(void);
108extern void iommu_init_early_iSeries(void); 100extern void iommu_init_early_iSeries(void);
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index f960f5346f40..46476e9a494a 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -135,6 +135,10 @@ struct irq_map_entry {
135 135
136extern struct irq_map_entry irq_map[NR_IRQS]; 136extern struct irq_map_entry irq_map[NR_IRQS];
137 137
138static inline irq_hw_number_t virq_to_hw(unsigned int virq)
139{
140 return irq_map[virq].hwirq;
141}
138 142
139/** 143/**
140 * irq_alloc_host - Allocate a new irq_host data structure 144 * irq_alloc_host - Allocate a new irq_host data structure
diff --git a/include/asm-powerpc/iseries/iommu.h b/include/asm-powerpc/iseries/iommu.h
index 0edbfe10cb37..6e323a13ac30 100644
--- a/include/asm-powerpc/iseries/iommu.h
+++ b/include/asm-powerpc/iseries/iommu.h
@@ -21,11 +21,13 @@
21 * Boston, MA 02111-1307 USA 21 * Boston, MA 02111-1307 USA
22 */ 22 */
23 23
24struct pci_dev;
24struct device_node; 25struct device_node;
25struct iommu_table; 26struct iommu_table;
26 27
27/* Creates table for an individual device node */ 28/* Creates table for an individual device node */
28extern void iommu_devnode_init_iSeries(struct device_node *dn); 29extern void iommu_devnode_init_iSeries(struct pci_dev *pdev,
30 struct device_node *dn);
29 31
30/* Get table parameters from HV */ 32/* Get table parameters from HV */
31extern void iommu_table_getparms_iSeries(unsigned long busno, 33extern void iommu_table_getparms_iSeries(unsigned long busno,
diff --git a/include/asm-powerpc/lv1call.h b/include/asm-powerpc/lv1call.h
new file mode 100644
index 000000000000..f733beeea63a
--- /dev/null
+++ b/include/asm-powerpc/lv1call.h
@@ -0,0 +1,345 @@
1/*
2 * PS3 hvcall interface.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
6 * Copyright 2003, 2004 (c) MontaVista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#if !defined(_ASM_POWERPC_LV1CALL_H)
23#define _ASM_POWERPC_LV1CALL_H
24
25#if !defined(__ASSEMBLY__)
26
27#include <linux/types.h>
28
29/* lv1 call declaration macros */
30
31#define LV1_1_IN_ARG_DECL u64 in_1
32#define LV1_2_IN_ARG_DECL LV1_1_IN_ARG_DECL, u64 in_2
33#define LV1_3_IN_ARG_DECL LV1_2_IN_ARG_DECL, u64 in_3
34#define LV1_4_IN_ARG_DECL LV1_3_IN_ARG_DECL, u64 in_4
35#define LV1_5_IN_ARG_DECL LV1_4_IN_ARG_DECL, u64 in_5
36#define LV1_6_IN_ARG_DECL LV1_5_IN_ARG_DECL, u64 in_6
37#define LV1_7_IN_ARG_DECL LV1_6_IN_ARG_DECL, u64 in_7
38#define LV1_8_IN_ARG_DECL LV1_7_IN_ARG_DECL, u64 in_8
39#define LV1_1_OUT_ARG_DECL u64 *out_1
40#define LV1_2_OUT_ARG_DECL LV1_1_OUT_ARG_DECL, u64 *out_2
41#define LV1_3_OUT_ARG_DECL LV1_2_OUT_ARG_DECL, u64 *out_3
42#define LV1_4_OUT_ARG_DECL LV1_3_OUT_ARG_DECL, u64 *out_4
43#define LV1_5_OUT_ARG_DECL LV1_4_OUT_ARG_DECL, u64 *out_5
44#define LV1_6_OUT_ARG_DECL LV1_5_OUT_ARG_DECL, u64 *out_6
45#define LV1_7_OUT_ARG_DECL LV1_6_OUT_ARG_DECL, u64 *out_7
46
47#define LV1_0_IN_0_OUT_ARG_DECL void
48#define LV1_1_IN_0_OUT_ARG_DECL LV1_1_IN_ARG_DECL
49#define LV1_2_IN_0_OUT_ARG_DECL LV1_2_IN_ARG_DECL
50#define LV1_3_IN_0_OUT_ARG_DECL LV1_3_IN_ARG_DECL
51#define LV1_4_IN_0_OUT_ARG_DECL LV1_4_IN_ARG_DECL
52#define LV1_5_IN_0_OUT_ARG_DECL LV1_5_IN_ARG_DECL
53#define LV1_6_IN_0_OUT_ARG_DECL LV1_6_IN_ARG_DECL
54#define LV1_7_IN_0_OUT_ARG_DECL LV1_7_IN_ARG_DECL
55
56#define LV1_0_IN_1_OUT_ARG_DECL LV1_1_OUT_ARG_DECL
57#define LV1_1_IN_1_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
58#define LV1_2_IN_1_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
59#define LV1_3_IN_1_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
60#define LV1_4_IN_1_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
61#define LV1_5_IN_1_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
62#define LV1_6_IN_1_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
63#define LV1_7_IN_1_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
64#define LV1_8_IN_1_OUT_ARG_DECL LV1_8_IN_ARG_DECL, LV1_1_OUT_ARG_DECL
65
66#define LV1_0_IN_2_OUT_ARG_DECL LV1_2_OUT_ARG_DECL
67#define LV1_1_IN_2_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
68#define LV1_2_IN_2_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
69#define LV1_3_IN_2_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
70#define LV1_4_IN_2_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
71#define LV1_5_IN_2_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
72#define LV1_6_IN_2_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
73#define LV1_7_IN_2_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_2_OUT_ARG_DECL
74
75#define LV1_0_IN_3_OUT_ARG_DECL LV1_3_OUT_ARG_DECL
76#define LV1_1_IN_3_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
77#define LV1_2_IN_3_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
78#define LV1_3_IN_3_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
79#define LV1_4_IN_3_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
80#define LV1_5_IN_3_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
81#define LV1_6_IN_3_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
82#define LV1_7_IN_3_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_3_OUT_ARG_DECL
83
84#define LV1_0_IN_4_OUT_ARG_DECL LV1_4_OUT_ARG_DECL
85#define LV1_1_IN_4_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
86#define LV1_2_IN_4_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
87#define LV1_3_IN_4_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
88#define LV1_4_IN_4_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
89#define LV1_5_IN_4_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
90#define LV1_6_IN_4_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
91#define LV1_7_IN_4_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_4_OUT_ARG_DECL
92
93#define LV1_0_IN_5_OUT_ARG_DECL LV1_5_OUT_ARG_DECL
94#define LV1_1_IN_5_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
95#define LV1_2_IN_5_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
96#define LV1_3_IN_5_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
97#define LV1_4_IN_5_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
98#define LV1_5_IN_5_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
99#define LV1_6_IN_5_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
100#define LV1_7_IN_5_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_5_OUT_ARG_DECL
101
102#define LV1_0_IN_6_OUT_ARG_DECL LV1_6_OUT_ARG_DECL
103#define LV1_1_IN_6_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
104#define LV1_2_IN_6_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
105#define LV1_3_IN_6_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
106#define LV1_4_IN_6_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
107#define LV1_5_IN_6_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
108#define LV1_6_IN_6_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
109#define LV1_7_IN_6_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_6_OUT_ARG_DECL
110
111#define LV1_0_IN_7_OUT_ARG_DECL LV1_7_OUT_ARG_DECL
112#define LV1_1_IN_7_OUT_ARG_DECL LV1_1_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
113#define LV1_2_IN_7_OUT_ARG_DECL LV1_2_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
114#define LV1_3_IN_7_OUT_ARG_DECL LV1_3_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
115#define LV1_4_IN_7_OUT_ARG_DECL LV1_4_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
116#define LV1_5_IN_7_OUT_ARG_DECL LV1_5_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
117#define LV1_6_IN_7_OUT_ARG_DECL LV1_6_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
118#define LV1_7_IN_7_OUT_ARG_DECL LV1_7_IN_ARG_DECL, LV1_7_OUT_ARG_DECL
119
120#define LV1_1_IN_ARGS in_1
121#define LV1_2_IN_ARGS LV1_1_IN_ARGS, in_2
122#define LV1_3_IN_ARGS LV1_2_IN_ARGS, in_3
123#define LV1_4_IN_ARGS LV1_3_IN_ARGS, in_4
124#define LV1_5_IN_ARGS LV1_4_IN_ARGS, in_5
125#define LV1_6_IN_ARGS LV1_5_IN_ARGS, in_6
126#define LV1_7_IN_ARGS LV1_6_IN_ARGS, in_7
127#define LV1_8_IN_ARGS LV1_7_IN_ARGS, in_8
128
129#define LV1_1_OUT_ARGS out_1
130#define LV1_2_OUT_ARGS LV1_1_OUT_ARGS, out_2
131#define LV1_3_OUT_ARGS LV1_2_OUT_ARGS, out_3
132#define LV1_4_OUT_ARGS LV1_3_OUT_ARGS, out_4
133#define LV1_5_OUT_ARGS LV1_4_OUT_ARGS, out_5
134#define LV1_6_OUT_ARGS LV1_5_OUT_ARGS, out_6
135#define LV1_7_OUT_ARGS LV1_6_OUT_ARGS, out_7
136
137#define LV1_0_IN_0_OUT_ARGS
138#define LV1_1_IN_0_OUT_ARGS LV1_1_IN_ARGS
139#define LV1_2_IN_0_OUT_ARGS LV1_2_IN_ARGS
140#define LV1_3_IN_0_OUT_ARGS LV1_3_IN_ARGS
141#define LV1_4_IN_0_OUT_ARGS LV1_4_IN_ARGS
142#define LV1_5_IN_0_OUT_ARGS LV1_5_IN_ARGS
143#define LV1_6_IN_0_OUT_ARGS LV1_6_IN_ARGS
144#define LV1_7_IN_0_OUT_ARGS LV1_7_IN_ARGS
145
146#define LV1_0_IN_1_OUT_ARGS LV1_1_OUT_ARGS
147#define LV1_1_IN_1_OUT_ARGS LV1_1_IN_ARGS, LV1_1_OUT_ARGS
148#define LV1_2_IN_1_OUT_ARGS LV1_2_IN_ARGS, LV1_1_OUT_ARGS
149#define LV1_3_IN_1_OUT_ARGS LV1_3_IN_ARGS, LV1_1_OUT_ARGS
150#define LV1_4_IN_1_OUT_ARGS LV1_4_IN_ARGS, LV1_1_OUT_ARGS
151#define LV1_5_IN_1_OUT_ARGS LV1_5_IN_ARGS, LV1_1_OUT_ARGS
152#define LV1_6_IN_1_OUT_ARGS LV1_6_IN_ARGS, LV1_1_OUT_ARGS
153#define LV1_7_IN_1_OUT_ARGS LV1_7_IN_ARGS, LV1_1_OUT_ARGS
154#define LV1_8_IN_1_OUT_ARGS LV1_8_IN_ARGS, LV1_1_OUT_ARGS
155
156#define LV1_0_IN_2_OUT_ARGS LV1_2_OUT_ARGS
157#define LV1_1_IN_2_OUT_ARGS LV1_1_IN_ARGS, LV1_2_OUT_ARGS
158#define LV1_2_IN_2_OUT_ARGS LV1_2_IN_ARGS, LV1_2_OUT_ARGS
159#define LV1_3_IN_2_OUT_ARGS LV1_3_IN_ARGS, LV1_2_OUT_ARGS
160#define LV1_4_IN_2_OUT_ARGS LV1_4_IN_ARGS, LV1_2_OUT_ARGS
161#define LV1_5_IN_2_OUT_ARGS LV1_5_IN_ARGS, LV1_2_OUT_ARGS
162#define LV1_6_IN_2_OUT_ARGS LV1_6_IN_ARGS, LV1_2_OUT_ARGS
163#define LV1_7_IN_2_OUT_ARGS LV1_7_IN_ARGS, LV1_2_OUT_ARGS
164
165#define LV1_0_IN_3_OUT_ARGS LV1_3_OUT_ARGS
166#define LV1_1_IN_3_OUT_ARGS LV1_1_IN_ARGS, LV1_3_OUT_ARGS
167#define LV1_2_IN_3_OUT_ARGS LV1_2_IN_ARGS, LV1_3_OUT_ARGS
168#define LV1_3_IN_3_OUT_ARGS LV1_3_IN_ARGS, LV1_3_OUT_ARGS
169#define LV1_4_IN_3_OUT_ARGS LV1_4_IN_ARGS, LV1_3_OUT_ARGS
170#define LV1_5_IN_3_OUT_ARGS LV1_5_IN_ARGS, LV1_3_OUT_ARGS
171#define LV1_6_IN_3_OUT_ARGS LV1_6_IN_ARGS, LV1_3_OUT_ARGS
172#define LV1_7_IN_3_OUT_ARGS LV1_7_IN_ARGS, LV1_3_OUT_ARGS
173
174#define LV1_0_IN_4_OUT_ARGS LV1_4_OUT_ARGS
175#define LV1_1_IN_4_OUT_ARGS LV1_1_IN_ARGS, LV1_4_OUT_ARGS
176#define LV1_2_IN_4_OUT_ARGS LV1_2_IN_ARGS, LV1_4_OUT_ARGS
177#define LV1_3_IN_4_OUT_ARGS LV1_3_IN_ARGS, LV1_4_OUT_ARGS
178#define LV1_4_IN_4_OUT_ARGS LV1_4_IN_ARGS, LV1_4_OUT_ARGS
179#define LV1_5_IN_4_OUT_ARGS LV1_5_IN_ARGS, LV1_4_OUT_ARGS
180#define LV1_6_IN_4_OUT_ARGS LV1_6_IN_ARGS, LV1_4_OUT_ARGS
181#define LV1_7_IN_4_OUT_ARGS LV1_7_IN_ARGS, LV1_4_OUT_ARGS
182
183#define LV1_0_IN_5_OUT_ARGS LV1_5_OUT_ARGS
184#define LV1_1_IN_5_OUT_ARGS LV1_1_IN_ARGS, LV1_5_OUT_ARGS
185#define LV1_2_IN_5_OUT_ARGS LV1_2_IN_ARGS, LV1_5_OUT_ARGS
186#define LV1_3_IN_5_OUT_ARGS LV1_3_IN_ARGS, LV1_5_OUT_ARGS
187#define LV1_4_IN_5_OUT_ARGS LV1_4_IN_ARGS, LV1_5_OUT_ARGS
188#define LV1_5_IN_5_OUT_ARGS LV1_5_IN_ARGS, LV1_5_OUT_ARGS
189#define LV1_6_IN_5_OUT_ARGS LV1_6_IN_ARGS, LV1_5_OUT_ARGS
190#define LV1_7_IN_5_OUT_ARGS LV1_7_IN_ARGS, LV1_5_OUT_ARGS
191
192#define LV1_0_IN_6_OUT_ARGS LV1_6_OUT_ARGS
193#define LV1_1_IN_6_OUT_ARGS LV1_1_IN_ARGS, LV1_6_OUT_ARGS
194#define LV1_2_IN_6_OUT_ARGS LV1_2_IN_ARGS, LV1_6_OUT_ARGS
195#define LV1_3_IN_6_OUT_ARGS LV1_3_IN_ARGS, LV1_6_OUT_ARGS
196#define LV1_4_IN_6_OUT_ARGS LV1_4_IN_ARGS, LV1_6_OUT_ARGS
197#define LV1_5_IN_6_OUT_ARGS LV1_5_IN_ARGS, LV1_6_OUT_ARGS
198#define LV1_6_IN_6_OUT_ARGS LV1_6_IN_ARGS, LV1_6_OUT_ARGS
199#define LV1_7_IN_6_OUT_ARGS LV1_7_IN_ARGS, LV1_6_OUT_ARGS
200
201#define LV1_0_IN_7_OUT_ARGS LV1_7_OUT_ARGS
202#define LV1_1_IN_7_OUT_ARGS LV1_1_IN_ARGS, LV1_7_OUT_ARGS
203#define LV1_2_IN_7_OUT_ARGS LV1_2_IN_ARGS, LV1_7_OUT_ARGS
204#define LV1_3_IN_7_OUT_ARGS LV1_3_IN_ARGS, LV1_7_OUT_ARGS
205#define LV1_4_IN_7_OUT_ARGS LV1_4_IN_ARGS, LV1_7_OUT_ARGS
206#define LV1_5_IN_7_OUT_ARGS LV1_5_IN_ARGS, LV1_7_OUT_ARGS
207#define LV1_6_IN_7_OUT_ARGS LV1_6_IN_ARGS, LV1_7_OUT_ARGS
208#define LV1_7_IN_7_OUT_ARGS LV1_7_IN_ARGS, LV1_7_OUT_ARGS
209
210/*
211 * This LV1_CALL() macro is for use by callers. It expands into an
212 * inline call wrapper and an underscored HV call declaration. The
213 * wrapper can be used to instrument the lv1 call interface. The
214 * file lv1call.S defines its own LV1_CALL() macro to expand into
215 * the actual underscored call definition.
216 */
217
218#if !defined(LV1_CALL)
219#define LV1_CALL(name, in, out, num) \
220 extern s64 _lv1_##name(LV1_##in##_IN_##out##_OUT_ARG_DECL); \
221 static inline int lv1_##name(LV1_##in##_IN_##out##_OUT_ARG_DECL) \
222 {return _lv1_##name(LV1_##in##_IN_##out##_OUT_ARGS);}
223#endif
224
225#endif /* !defined(__ASSEMBLY__) */
226
227/* lv1 call table */
228
229LV1_CALL(allocate_memory, 4, 2, 0 )
230LV1_CALL(write_htab_entry, 4, 0, 1 )
231LV1_CALL(construct_virtual_address_space, 3, 2, 2 )
232LV1_CALL(invalidate_htab_entries, 5, 0, 3 )
233LV1_CALL(get_virtual_address_space_id_of_ppe, 1, 1, 4 )
234LV1_CALL(query_logical_partition_address_region_info, 1, 5, 6 )
235LV1_CALL(select_virtual_address_space, 1, 0, 7 )
236LV1_CALL(pause, 1, 0, 9 )
237LV1_CALL(destruct_virtual_address_space, 1, 0, 10 )
238LV1_CALL(configure_irq_state_bitmap, 3, 0, 11 )
239LV1_CALL(connect_irq_plug_ext, 5, 0, 12 )
240LV1_CALL(release_memory, 1, 0, 13 )
241LV1_CALL(disconnect_irq_plug_ext, 3, 0, 17 )
242LV1_CALL(construct_event_receive_port, 0, 1, 18 )
243LV1_CALL(destruct_event_receive_port, 1, 0, 19 )
244LV1_CALL(send_event_locally, 1, 0, 24 )
245LV1_CALL(end_of_interrupt, 1, 0, 27 )
246LV1_CALL(connect_irq_plug, 2, 0, 28 )
247LV1_CALL(disconnect_irq_plug, 1, 0, 29 )
248LV1_CALL(end_of_interrupt_ext, 3, 0, 30 )
249LV1_CALL(did_update_interrupt_mask, 2, 0, 31 )
250LV1_CALL(shutdown_logical_partition, 1, 0, 44 )
251LV1_CALL(destruct_logical_spe, 1, 0, 54 )
252LV1_CALL(construct_logical_spe, 7, 6, 57 )
253LV1_CALL(set_spe_interrupt_mask, 3, 0, 61 )
254LV1_CALL(set_spe_transition_notifier, 3, 0, 64 )
255LV1_CALL(disable_logical_spe, 2, 0, 65 )
256LV1_CALL(clear_spe_interrupt_status, 4, 0, 66 )
257LV1_CALL(get_spe_interrupt_status, 2, 1, 67 )
258LV1_CALL(get_logical_ppe_id, 0, 1, 69 )
259LV1_CALL(set_interrupt_mask, 5, 0, 73 )
260LV1_CALL(get_logical_partition_id, 0, 1, 74 )
261LV1_CALL(configure_execution_time_variable, 1, 0, 77 )
262LV1_CALL(get_spe_irq_outlet, 2, 1, 78 )
263LV1_CALL(set_spe_privilege_state_area_1_register, 3, 0, 79 )
264LV1_CALL(create_repository_node, 6, 0, 90 )
265LV1_CALL(get_repository_node_value, 5, 2, 91 )
266LV1_CALL(modify_repository_node_value, 6, 0, 92 )
267LV1_CALL(remove_repository_node, 4, 0, 93 )
268LV1_CALL(read_htab_entries, 2, 5, 95 )
269LV1_CALL(set_dabr, 2, 0, 96 )
270LV1_CALL(get_total_execution_time, 2, 1, 103 )
271LV1_CALL(construct_io_irq_outlet, 1, 1, 120 )
272LV1_CALL(destruct_io_irq_outlet, 1, 0, 121 )
273LV1_CALL(map_htab, 1, 1, 122 )
274LV1_CALL(unmap_htab, 1, 0, 123 )
275LV1_CALL(get_version_info, 0, 1, 127 )
276LV1_CALL(insert_htab_entry, 6, 3, 158 )
277LV1_CALL(read_virtual_uart, 3, 1, 162 )
278LV1_CALL(write_virtual_uart, 3, 1, 163 )
279LV1_CALL(set_virtual_uart_param, 3, 0, 164 )
280LV1_CALL(get_virtual_uart_param, 2, 1, 165 )
281LV1_CALL(configure_virtual_uart_irq, 1, 1, 166 )
282LV1_CALL(open_device, 3, 0, 170 )
283LV1_CALL(close_device, 2, 0, 171 )
284LV1_CALL(map_device_mmio_region, 5, 1, 172 )
285LV1_CALL(unmap_device_mmio_region, 3, 0, 173 )
286LV1_CALL(allocate_device_dma_region, 5, 1, 174 )
287LV1_CALL(free_device_dma_region, 3, 0, 175 )
288LV1_CALL(map_device_dma_region, 6, 0, 176 )
289LV1_CALL(unmap_device_dma_region, 4, 0, 177 )
290LV1_CALL(net_add_multicast_address, 4, 0, 185 )
291LV1_CALL(net_remove_multicast_address, 4, 0, 186 )
292LV1_CALL(net_start_tx_dma, 4, 0, 187 )
293LV1_CALL(net_stop_tx_dma, 3, 0, 188 )
294LV1_CALL(net_start_rx_dma, 4, 0, 189 )
295LV1_CALL(net_stop_rx_dma, 3, 0, 190 )
296LV1_CALL(net_set_interrupt_status_indicator, 4, 0, 191 )
297LV1_CALL(net_set_interrupt_mask, 4, 0, 193 )
298LV1_CALL(net_control, 6, 2, 194 )
299LV1_CALL(connect_interrupt_event_receive_port, 4, 0, 197 )
300LV1_CALL(disconnect_interrupt_event_receive_port, 4, 0, 198 )
301LV1_CALL(get_spe_all_interrupt_statuses, 1, 1, 199 )
302LV1_CALL(deconfigure_virtual_uart_irq, 0, 0, 202 )
303LV1_CALL(enable_logical_spe, 2, 0, 207 )
304LV1_CALL(gpu_open, 1, 0, 210 )
305LV1_CALL(gpu_close, 0, 0, 211 )
306LV1_CALL(gpu_device_map, 1, 2, 212 )
307LV1_CALL(gpu_device_unmap, 1, 0, 213 )
308LV1_CALL(gpu_memory_allocate, 5, 2, 214 )
309LV1_CALL(gpu_memory_free, 1, 0, 216 )
310LV1_CALL(gpu_context_allocate, 2, 5, 217 )
311LV1_CALL(gpu_context_free, 1, 0, 218 )
312LV1_CALL(gpu_context_iomap, 5, 0, 221 )
313LV1_CALL(gpu_context_attribute, 6, 0, 225 )
314LV1_CALL(gpu_context_intr, 1, 1, 227 )
315LV1_CALL(gpu_attribute, 5, 0, 228 )
316LV1_CALL(get_rtc, 0, 2, 232 )
317LV1_CALL(set_ppe_periodic_tracer_frequency, 1, 0, 240 )
318LV1_CALL(start_ppe_periodic_tracer, 5, 0, 241 )
319LV1_CALL(stop_ppe_periodic_tracer, 1, 1, 242 )
320LV1_CALL(storage_read, 6, 1, 245 )
321LV1_CALL(storage_write, 6, 1, 246 )
322LV1_CALL(storage_send_device_command, 6, 1, 248 )
323LV1_CALL(storage_get_async_status, 1, 2, 249 )
324LV1_CALL(storage_check_async_status, 2, 1, 254 )
325LV1_CALL(panic, 1, 0, 255 )
326LV1_CALL(construct_lpm, 6, 3, 140 )
327LV1_CALL(destruct_lpm, 1, 0, 141 )
328LV1_CALL(start_lpm, 1, 0, 142 )
329LV1_CALL(stop_lpm, 1, 1, 143 )
330LV1_CALL(copy_lpm_trace_buffer, 3, 1, 144 )
331LV1_CALL(add_lpm_event_bookmark, 5, 0, 145 )
332LV1_CALL(delete_lpm_event_bookmark, 3, 0, 146 )
333LV1_CALL(set_lpm_interrupt_mask, 3, 1, 147 )
334LV1_CALL(get_lpm_interrupt_status, 1, 1, 148 )
335LV1_CALL(set_lpm_general_control, 5, 2, 149 )
336LV1_CALL(set_lpm_interval, 3, 1, 150 )
337LV1_CALL(set_lpm_trigger_control, 3, 1, 151 )
338LV1_CALL(set_lpm_counter_control, 4, 1, 152 )
339LV1_CALL(set_lpm_group_control, 3, 1, 153 )
340LV1_CALL(set_lpm_debug_bus_control, 3, 1, 154 )
341LV1_CALL(set_lpm_counter, 5, 2, 155 )
342LV1_CALL(set_lpm_signal, 7, 0, 156 )
343LV1_CALL(set_lpm_spr_trigger, 2, 0, 157 )
344
345#endif
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index dac90dc341cb..1b04e5723548 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -26,6 +26,7 @@ struct device_node;
26struct iommu_table; 26struct iommu_table;
27struct rtc_time; 27struct rtc_time;
28struct file; 28struct file;
29struct pci_controller;
29#ifdef CONFIG_KEXEC 30#ifdef CONFIG_KEXEC
30struct kimage; 31struct kimage;
31#endif 32#endif
@@ -84,9 +85,12 @@ struct machdep_calls {
84 unsigned long (*tce_get)(struct iommu_table *tbl, 85 unsigned long (*tce_get)(struct iommu_table *tbl,
85 long index); 86 long index);
86 void (*tce_flush)(struct iommu_table *tbl); 87 void (*tce_flush)(struct iommu_table *tbl);
87 void (*iommu_dev_setup)(struct pci_dev *dev); 88 void (*pci_dma_dev_setup)(struct pci_dev *dev);
88 void (*iommu_bus_setup)(struct pci_bus *bus); 89 void (*pci_dma_bus_setup)(struct pci_bus *bus);
89 void (*irq_bus_setup)(struct pci_bus *bus); 90
91 void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
92 unsigned long flags);
93 void (*iounmap)(volatile void __iomem *token);
90#endif /* CONFIG_PPC64 */ 94#endif /* CONFIG_PPC64 */
91 95
92 int (*probe)(void); 96 int (*probe)(void);
@@ -106,6 +110,10 @@ struct machdep_calls {
106 /* Called after scanning the bus, before allocating resources */ 110 /* Called after scanning the bus, before allocating resources */
107 void (*pcibios_fixup)(void); 111 void (*pcibios_fixup)(void);
108 int (*pci_probe_mode)(struct pci_bus *); 112 int (*pci_probe_mode)(struct pci_bus *);
113 void (*pci_irq_fixup)(struct pci_dev *dev);
114
115 /* To setup PHBs when using automatic OF platform driver for PCI */
116 int (*pci_setup_phb)(struct pci_controller *host);
109 117
110 void (*restart)(char *cmd); 118 void (*restart)(char *cmd);
111 void (*power_off)(void); 119 void (*power_off)(void);
@@ -199,10 +207,6 @@ struct machdep_calls {
199 * Returns 0 to allow assignment/enabling of the device. */ 207 * Returns 0 to allow assignment/enabling of the device. */
200 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial); 208 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
201 209
202 /* For interrupt routing */
203 unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *);
204 int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char);
205
206 /* Called in indirect_* to avoid touching devices */ 210 /* Called in indirect_* to avoid touching devices */
207 int (*pci_exclude_device)(unsigned char, unsigned char); 211 int (*pci_exclude_device)(unsigned char, unsigned char);
208 212
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
index c3fc7a28e3cd..41c8c9c5a254 100644
--- a/include/asm-powerpc/mmu.h
+++ b/include/asm-powerpc/mmu.h
@@ -248,21 +248,6 @@ extern void hpte_init_native(void);
248extern void hpte_init_lpar(void); 248extern void hpte_init_lpar(void);
249extern void hpte_init_iSeries(void); 249extern void hpte_init_iSeries(void);
250 250
251extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
252 unsigned long va, unsigned long prpn,
253 unsigned long rflags,
254 unsigned long vflags, int psize);
255
256extern long native_hpte_insert(unsigned long hpte_group,
257 unsigned long va, unsigned long prpn,
258 unsigned long rflags,
259 unsigned long vflags, int psize);
260
261extern long iSeries_hpte_insert(unsigned long hpte_group,
262 unsigned long va, unsigned long prpn,
263 unsigned long rflags,
264 unsigned long vflags, int psize);
265
266extern void stabs_alloc(void); 251extern void stabs_alloc(void);
267extern void slb_initialize(void); 252extern void slb_initialize(void);
268extern void slb_flush_and_rebolt(void); 253extern void slb_flush_and_rebolt(void);
diff --git a/include/asm-powerpc/mpc52xx.h b/include/asm-powerpc/mpc52xx.h
new file mode 100644
index 000000000000..4a28a850998c
--- /dev/null
+++ b/include/asm-powerpc/mpc52xx.h
@@ -0,0 +1,254 @@
1/*
2 * Prototypes, etc. for the Freescale MPC52xx embedded cpu chips
3 * May need to be cleaned as the port goes on ...
4 *
5 * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com>
6 * Copyright (C) 2003 MontaVista, Software, Inc.
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12
13#ifndef __ASM_POWERPC_MPC52xx_H__
14#define __ASM_POWERPC_MPC52xx_H__
15
16#ifndef __ASSEMBLY__
17#include <asm/types.h>
18#include <asm/prom.h>
19#endif /* __ASSEMBLY__ */
20
21
22/* ======================================================================== */
23/* Structures mapping of some unit register set */
24/* ======================================================================== */
25
26#ifndef __ASSEMBLY__
27
28/* Memory Mapping Control */
29struct mpc52xx_mmap_ctl {
30 u32 mbar; /* MMAP_CTRL + 0x00 */
31
32 u32 cs0_start; /* MMAP_CTRL + 0x04 */
33 u32 cs0_stop; /* MMAP_CTRL + 0x08 */
34 u32 cs1_start; /* MMAP_CTRL + 0x0c */
35 u32 cs1_stop; /* MMAP_CTRL + 0x10 */
36 u32 cs2_start; /* MMAP_CTRL + 0x14 */
37 u32 cs2_stop; /* MMAP_CTRL + 0x18 */
38 u32 cs3_start; /* MMAP_CTRL + 0x1c */
39 u32 cs3_stop; /* MMAP_CTRL + 0x20 */
40 u32 cs4_start; /* MMAP_CTRL + 0x24 */
41 u32 cs4_stop; /* MMAP_CTRL + 0x28 */
42 u32 cs5_start; /* MMAP_CTRL + 0x2c */
43 u32 cs5_stop; /* MMAP_CTRL + 0x30 */
44
45 u32 sdram0; /* MMAP_CTRL + 0x34 */
46 u32 sdram1; /* MMAP_CTRL + 0X38 */
47
48 u32 reserved[4]; /* MMAP_CTRL + 0x3c .. 0x48 */
49
50 u32 boot_start; /* MMAP_CTRL + 0x4c */
51 u32 boot_stop; /* MMAP_CTRL + 0x50 */
52
53 u32 ipbi_ws_ctrl; /* MMAP_CTRL + 0x54 */
54
55 u32 cs6_start; /* MMAP_CTRL + 0x58 */
56 u32 cs6_stop; /* MMAP_CTRL + 0x5c */
57 u32 cs7_start; /* MMAP_CTRL + 0x60 */
58 u32 cs7_stop; /* MMAP_CTRL + 0x64 */
59};
60
61/* SDRAM control */
62struct mpc52xx_sdram {
63 u32 mode; /* SDRAM + 0x00 */
64 u32 ctrl; /* SDRAM + 0x04 */
65 u32 config1; /* SDRAM + 0x08 */
66 u32 config2; /* SDRAM + 0x0c */
67};
68
69/* SDMA */
70struct mpc52xx_sdma {
71 u32 taskBar; /* SDMA + 0x00 */
72 u32 currentPointer; /* SDMA + 0x04 */
73 u32 endPointer; /* SDMA + 0x08 */
74 u32 variablePointer; /* SDMA + 0x0c */
75
76 u8 IntVect1; /* SDMA + 0x10 */
77 u8 IntVect2; /* SDMA + 0x11 */
78 u16 PtdCntrl; /* SDMA + 0x12 */
79
80 u32 IntPend; /* SDMA + 0x14 */
81 u32 IntMask; /* SDMA + 0x18 */
82
83 u16 tcr[16]; /* SDMA + 0x1c .. 0x3a */
84
85 u8 ipr[32]; /* SDMA + 0x3c .. 0x5b */
86
87 u32 cReqSelect; /* SDMA + 0x5c */
88 u32 task_size0; /* SDMA + 0x60 */
89 u32 task_size1; /* SDMA + 0x64 */
90 u32 MDEDebug; /* SDMA + 0x68 */
91 u32 ADSDebug; /* SDMA + 0x6c */
92 u32 Value1; /* SDMA + 0x70 */
93 u32 Value2; /* SDMA + 0x74 */
94 u32 Control; /* SDMA + 0x78 */
95 u32 Status; /* SDMA + 0x7c */
96 u32 PTDDebug; /* SDMA + 0x80 */
97};
98
99/* GPT */
100struct mpc52xx_gpt {
101 u32 mode; /* GPTx + 0x00 */
102 u32 count; /* GPTx + 0x04 */
103 u32 pwm; /* GPTx + 0x08 */
104 u32 status; /* GPTx + 0X0c */
105};
106
107/* GPIO */
108struct mpc52xx_gpio {
109 u32 port_config; /* GPIO + 0x00 */
110 u32 simple_gpioe; /* GPIO + 0x04 */
111 u32 simple_ode; /* GPIO + 0x08 */
112 u32 simple_ddr; /* GPIO + 0x0c */
113 u32 simple_dvo; /* GPIO + 0x10 */
114 u32 simple_ival; /* GPIO + 0x14 */
115 u8 outo_gpioe; /* GPIO + 0x18 */
116 u8 reserved1[3]; /* GPIO + 0x19 */
117 u8 outo_dvo; /* GPIO + 0x1c */
118 u8 reserved2[3]; /* GPIO + 0x1d */
119 u8 sint_gpioe; /* GPIO + 0x20 */
120 u8 reserved3[3]; /* GPIO + 0x21 */
121 u8 sint_ode; /* GPIO + 0x24 */
122 u8 reserved4[3]; /* GPIO + 0x25 */
123 u8 sint_ddr; /* GPIO + 0x28 */
124 u8 reserved5[3]; /* GPIO + 0x29 */
125 u8 sint_dvo; /* GPIO + 0x2c */
126 u8 reserved6[3]; /* GPIO + 0x2d */
127 u8 sint_inten; /* GPIO + 0x30 */
128 u8 reserved7[3]; /* GPIO + 0x31 */
129 u16 sint_itype; /* GPIO + 0x34 */
130 u16 reserved8; /* GPIO + 0x36 */
131 u8 gpio_control; /* GPIO + 0x38 */
132 u8 reserved9[3]; /* GPIO + 0x39 */
133 u8 sint_istat; /* GPIO + 0x3c */
134 u8 sint_ival; /* GPIO + 0x3d */
135 u8 bus_errs; /* GPIO + 0x3e */
136 u8 reserved10; /* GPIO + 0x3f */
137};
138
139#define MPC52xx_GPIO_PSC_CONFIG_UART_WITHOUT_CD 4
140#define MPC52xx_GPIO_PSC_CONFIG_UART_WITH_CD 5
141#define MPC52xx_GPIO_PCI_DIS (1<<15)
142
143/* GPIO with WakeUp*/
144struct mpc52xx_gpio_wkup {
145 u8 wkup_gpioe; /* GPIO_WKUP + 0x00 */
146 u8 reserved1[3]; /* GPIO_WKUP + 0x03 */
147 u8 wkup_ode; /* GPIO_WKUP + 0x04 */
148 u8 reserved2[3]; /* GPIO_WKUP + 0x05 */
149 u8 wkup_ddr; /* GPIO_WKUP + 0x08 */
150 u8 reserved3[3]; /* GPIO_WKUP + 0x09 */
151 u8 wkup_dvo; /* GPIO_WKUP + 0x0C */
152 u8 reserved4[3]; /* GPIO_WKUP + 0x0D */
153 u8 wkup_inten; /* GPIO_WKUP + 0x10 */
154 u8 reserved5[3]; /* GPIO_WKUP + 0x11 */
155 u8 wkup_iinten; /* GPIO_WKUP + 0x14 */
156 u8 reserved6[3]; /* GPIO_WKUP + 0x15 */
157 u16 wkup_itype; /* GPIO_WKUP + 0x18 */
158 u8 reserved7[2]; /* GPIO_WKUP + 0x1A */
159 u8 wkup_maste; /* GPIO_WKUP + 0x1C */
160 u8 reserved8[3]; /* GPIO_WKUP + 0x1D */
161 u8 wkup_ival; /* GPIO_WKUP + 0x20 */
162 u8 reserved9[3]; /* GPIO_WKUP + 0x21 */
163 u8 wkup_istat; /* GPIO_WKUP + 0x24 */
164 u8 reserved10[3]; /* GPIO_WKUP + 0x25 */
165};
166
167/* XLB Bus control */
168struct mpc52xx_xlb {
169 u8 reserved[0x40];
170 u32 config; /* XLB + 0x40 */
171 u32 version; /* XLB + 0x44 */
172 u32 status; /* XLB + 0x48 */
173 u32 int_enable; /* XLB + 0x4c */
174 u32 addr_capture; /* XLB + 0x50 */
175 u32 bus_sig_capture; /* XLB + 0x54 */
176 u32 addr_timeout; /* XLB + 0x58 */
177 u32 data_timeout; /* XLB + 0x5c */
178 u32 bus_act_timeout; /* XLB + 0x60 */
179 u32 master_pri_enable; /* XLB + 0x64 */
180 u32 master_priority; /* XLB + 0x68 */
181 u32 base_address; /* XLB + 0x6c */
182 u32 snoop_window; /* XLB + 0x70 */
183};
184
185#define MPC52xx_XLB_CFG_PLDIS (1 << 31)
186#define MPC52xx_XLB_CFG_SNOOP (1 << 15)
187
188/* Clock Distribution control */
189struct mpc52xx_cdm {
190 u32 jtag_id; /* CDM + 0x00 reg0 read only */
191 u32 rstcfg; /* CDM + 0x04 reg1 read only */
192 u32 breadcrumb; /* CDM + 0x08 reg2 */
193
194 u8 mem_clk_sel; /* CDM + 0x0c reg3 byte0 */
195 u8 xlb_clk_sel; /* CDM + 0x0d reg3 byte1 read only */
196 u8 ipb_clk_sel; /* CDM + 0x0e reg3 byte2 */
197 u8 pci_clk_sel; /* CDM + 0x0f reg3 byte3 */
198
199 u8 ext_48mhz_en; /* CDM + 0x10 reg4 byte0 */
200 u8 fd_enable; /* CDM + 0x11 reg4 byte1 */
201 u16 fd_counters; /* CDM + 0x12 reg4 byte2,3 */
202
203 u32 clk_enables; /* CDM + 0x14 reg5 */
204
205 u8 osc_disable; /* CDM + 0x18 reg6 byte0 */
206 u8 reserved0[3]; /* CDM + 0x19 reg6 byte1,2,3 */
207
208 u8 ccs_sleep_enable; /* CDM + 0x1c reg7 byte0 */
209 u8 osc_sleep_enable; /* CDM + 0x1d reg7 byte1 */
210 u8 reserved1; /* CDM + 0x1e reg7 byte2 */
211 u8 ccs_qreq_test; /* CDM + 0x1f reg7 byte3 */
212
213 u8 soft_reset; /* CDM + 0x20 u8 byte0 */
214 u8 no_ckstp; /* CDM + 0x21 u8 byte0 */
215 u8 reserved2[2]; /* CDM + 0x22 u8 byte1,2,3 */
216
217 u8 pll_lock; /* CDM + 0x24 reg9 byte0 */
218 u8 pll_looselock; /* CDM + 0x25 reg9 byte1 */
219 u8 pll_sm_lockwin; /* CDM + 0x26 reg9 byte2 */
220 u8 reserved3; /* CDM + 0x27 reg9 byte3 */
221
222 u16 reserved4; /* CDM + 0x28 reg10 byte0,1 */
223 u16 mclken_div_psc1; /* CDM + 0x2a reg10 byte2,3 */
224
225 u16 reserved5; /* CDM + 0x2c reg11 byte0,1 */
226 u16 mclken_div_psc2; /* CDM + 0x2e reg11 byte2,3 */
227
228 u16 reserved6; /* CDM + 0x30 reg12 byte0,1 */
229 u16 mclken_div_psc3; /* CDM + 0x32 reg12 byte2,3 */
230
231 u16 reserved7; /* CDM + 0x34 reg13 byte0,1 */
232 u16 mclken_div_psc6; /* CDM + 0x36 reg13 byte2,3 */
233};
234
235#endif /* __ASSEMBLY__ */
236
237
238/* ========================================================================= */
239/* Prototypes for MPC52xx sysdev */
240/* ========================================================================= */
241
242#ifndef __ASSEMBLY__
243
244extern void __iomem * mpc52xx_find_and_map(const char *);
245extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node);
246extern void mpc52xx_setup_cpu(void);
247
248extern void mpc52xx_init_irq(void);
249extern unsigned int mpc52xx_get_irq(void);
250
251#endif /* __ASSEMBLY__ */
252
253#endif /* __ASM_POWERPC_MPC52xx_H__ */
254
diff --git a/include/asm-powerpc/mpc85xx.h b/include/asm-powerpc/mpc85xx.h
index ccdb8a21138f..54142997a584 100644
--- a/include/asm-powerpc/mpc85xx.h
+++ b/include/asm-powerpc/mpc85xx.h
@@ -31,14 +31,6 @@
31#include <platforms/85xx/mpc85xx_cds.h> 31#include <platforms/85xx/mpc85xx_cds.h>
32#endif 32#endif
33 33
34#define _IO_BASE isa_io_base
35#define _ISA_MEM_BASE isa_mem_base
36#ifdef CONFIG_PCI
37#define PCI_DRAM_OFFSET pci_dram_offset
38#else
39#define PCI_DRAM_OFFSET 0
40#endif
41
42/* Let modules/drivers get at CCSRBAR */ 34/* Let modules/drivers get at CCSRBAR */
43extern phys_addr_t get_ccsrbar(void); 35extern phys_addr_t get_ccsrbar(void);
44 36
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index ef0a5458d2b2..b71e7b32a555 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -3,6 +3,7 @@
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/irq.h> 5#include <linux/irq.h>
6#include <asm/dcr.h>
6 7
7/* 8/*
8 * Global registers 9 * Global registers
@@ -225,6 +226,23 @@ struct mpic_irq_fixup
225#endif /* CONFIG_MPIC_BROKEN_U3 */ 226#endif /* CONFIG_MPIC_BROKEN_U3 */
226 227
227 228
229enum mpic_reg_type {
230 mpic_access_mmio_le,
231 mpic_access_mmio_be,
232#ifdef CONFIG_PPC_DCR
233 mpic_access_dcr
234#endif
235};
236
237struct mpic_reg_bank {
238 u32 __iomem *base;
239#ifdef CONFIG_PPC_DCR
240 dcr_host_t dhost;
241 unsigned int dbase;
242 unsigned int doff;
243#endif /* CONFIG_PPC_DCR */
244};
245
228/* The instance data of a given MPIC */ 246/* The instance data of a given MPIC */
229struct mpic 247struct mpic
230{ 248{
@@ -264,11 +282,18 @@ struct mpic
264 spinlock_t fixup_lock; 282 spinlock_t fixup_lock;
265#endif 283#endif
266 284
285 /* Register access method */
286 enum mpic_reg_type reg_type;
287
267 /* The various ioremap'ed bases */ 288 /* The various ioremap'ed bases */
268 volatile u32 __iomem *gregs; 289 struct mpic_reg_bank gregs;
269 volatile u32 __iomem *tmregs; 290 struct mpic_reg_bank tmregs;
270 volatile u32 __iomem *cpuregs[MPIC_MAX_CPUS]; 291 struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS];
271 volatile u32 __iomem *isus[MPIC_MAX_ISU]; 292 struct mpic_reg_bank isus[MPIC_MAX_ISU];
293
294#ifdef CONFIG_PPC_DCR
295 unsigned int dcr_base;
296#endif
272 297
273#ifdef CONFIG_MPIC_WEIRD 298#ifdef CONFIG_MPIC_WEIRD
274 /* Pointer to HW info array */ 299 /* Pointer to HW info array */
@@ -305,6 +330,8 @@ struct mpic
305#define MPIC_SPV_EOI 0x00000020 330#define MPIC_SPV_EOI 0x00000020
306/* No passthrough disable */ 331/* No passthrough disable */
307#define MPIC_NO_PTHROU_DIS 0x00000040 332#define MPIC_NO_PTHROU_DIS 0x00000040
333/* DCR based MPIC */
334#define MPIC_USES_DCR 0x00000080
308 335
309/* MPIC HW modification ID */ 336/* MPIC HW modification ID */
310#define MPIC_REGSET_MASK 0xf0000000 337#define MPIC_REGSET_MASK 0xf0000000
@@ -337,7 +364,7 @@ struct mpic
337 * that is senses[0] correspond to linux irq "irq_offset". 364 * that is senses[0] correspond to linux irq "irq_offset".
338 */ 365 */
339extern struct mpic *mpic_alloc(struct device_node *node, 366extern struct mpic *mpic_alloc(struct device_node *node,
340 unsigned long phys_addr, 367 phys_addr_t phys_addr,
341 unsigned int flags, 368 unsigned int flags,
342 unsigned int isu_size, 369 unsigned int isu_size,
343 unsigned int irq_count, 370 unsigned int irq_count,
@@ -350,7 +377,7 @@ extern struct mpic *mpic_alloc(struct device_node *node,
350 * @phys_addr: physical address of the ISU 377 * @phys_addr: physical address of the ISU
351 */ 378 */
352extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, 379extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
353 unsigned long phys_addr); 380 phys_addr_t phys_addr);
354 381
355/* Set default sense codes 382/* Set default sense codes
356 * 383 *
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h
index c5c0b0b3cd52..a889b2005bf5 100644
--- a/include/asm-powerpc/of_device.h
+++ b/include/asm-powerpc/of_device.h
@@ -6,12 +6,6 @@
6#include <linux/mod_devicetable.h> 6#include <linux/mod_devicetable.h>
7#include <asm/prom.h> 7#include <asm/prom.h>
8 8
9/*
10 * The of_platform_bus_type is a bus type used by drivers that do not
11 * attach to a macio or similar bus but still use OF probing
12 * mechanism
13 */
14extern struct bus_type of_platform_bus_type;
15 9
16/* 10/*
17 * The of_device is a kind of "base class" that is a superset of 11 * The of_device is a kind of "base class" that is a superset of
@@ -20,46 +14,22 @@ extern struct bus_type of_platform_bus_type;
20 */ 14 */
21struct of_device 15struct of_device
22{ 16{
23 struct device_node *node; /* OF device node */ 17 struct device_node *node; /* to be obsoleted */
24 u64 dma_mask; /* DMA mask */ 18 u64 dma_mask; /* DMA mask */
25 struct device dev; /* Generic device interface */ 19 struct device dev; /* Generic device interface */
26}; 20};
27#define to_of_device(d) container_of(d, struct of_device, dev) 21#define to_of_device(d) container_of(d, struct of_device, dev)
28 22
23extern const struct of_device_id *of_match_node(
24 const struct of_device_id *matches, const struct device_node *node);
29extern const struct of_device_id *of_match_device( 25extern const struct of_device_id *of_match_device(
30 const struct of_device_id *matches, const struct of_device *dev); 26 const struct of_device_id *matches, const struct of_device *dev);
31 27
32extern struct of_device *of_dev_get(struct of_device *dev); 28extern struct of_device *of_dev_get(struct of_device *dev);
33extern void of_dev_put(struct of_device *dev); 29extern void of_dev_put(struct of_device *dev);
34 30
35/*
36 * An of_platform_driver driver is attached to a basic of_device on
37 * the "platform bus" (of_platform_bus_type)
38 */
39struct of_platform_driver
40{
41 char *name;
42 struct of_device_id *match_table;
43 struct module *owner;
44
45 int (*probe)(struct of_device* dev, const struct of_device_id *match);
46 int (*remove)(struct of_device* dev);
47
48 int (*suspend)(struct of_device* dev, pm_message_t state);
49 int (*resume)(struct of_device* dev);
50 int (*shutdown)(struct of_device* dev);
51
52 struct device_driver driver;
53};
54#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
55
56extern int of_register_driver(struct of_platform_driver *drv);
57extern void of_unregister_driver(struct of_platform_driver *drv);
58extern int of_device_register(struct of_device *ofdev); 31extern int of_device_register(struct of_device *ofdev);
59extern void of_device_unregister(struct of_device *ofdev); 32extern void of_device_unregister(struct of_device *ofdev);
60extern struct of_device *of_platform_device_create(struct device_node *np,
61 const char *bus_id,
62 struct device *parent);
63extern void of_release_dev(struct device *dev); 33extern void of_release_dev(struct device *dev);
64 34
65#endif /* __KERNEL__ */ 35#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/of_platform.h b/include/asm-powerpc/of_platform.h
new file mode 100644
index 000000000000..217eafb167e9
--- /dev/null
+++ b/include/asm-powerpc/of_platform.h
@@ -0,0 +1,60 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
3 * <benh@kernel.crashing.org>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 *
10 */
11
12#include <asm/of_device.h>
13
14/*
15 * The of_platform_bus_type is a bus type used by drivers that do not
16 * attach to a macio or similar bus but still use OF probing
17 * mechanism
18 */
19extern struct bus_type of_platform_bus_type;
20
21/*
22 * An of_platform_driver driver is attached to a basic of_device on
23 * the "platform bus" (of_platform_bus_type)
24 */
25struct of_platform_driver
26{
27 char *name;
28 struct of_device_id *match_table;
29 struct module *owner;
30
31 int (*probe)(struct of_device* dev,
32 const struct of_device_id *match);
33 int (*remove)(struct of_device* dev);
34
35 int (*suspend)(struct of_device* dev, pm_message_t state);
36 int (*resume)(struct of_device* dev);
37 int (*shutdown)(struct of_device* dev);
38
39 struct device_driver driver;
40};
41#define to_of_platform_driver(drv) \
42 container_of(drv,struct of_platform_driver, driver)
43
44/* Platform drivers register/unregister */
45extern int of_register_platform_driver(struct of_platform_driver *drv);
46extern void of_unregister_platform_driver(struct of_platform_driver *drv);
47
48/* Platform devices and busses creation */
49extern struct of_device *of_platform_device_create(struct device_node *np,
50 const char *bus_id,
51 struct device *parent);
52/* pseudo "matches" value to not do deep probe */
53#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
54
55extern int of_platform_bus_probe(struct device_node *root,
56 struct of_device_id *matches,
57 struct device *parent);
58
59extern struct of_device *of_find_device_by_node(struct device_node *np);
60extern struct of_device *of_find_device_by_phandle(phandle ph);
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
index 07a10e590c1d..71043bf3641f 100644
--- a/include/asm-powerpc/oprofile_impl.h
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -44,7 +44,9 @@ struct op_powerpc_model {
44 int num_counters); 44 int num_counters);
45 void (*cpu_setup) (struct op_counter_config *); 45 void (*cpu_setup) (struct op_counter_config *);
46 void (*start) (struct op_counter_config *); 46 void (*start) (struct op_counter_config *);
47 void (*global_start) (struct op_counter_config *);
47 void (*stop) (void); 48 void (*stop) (void);
49 void (*global_stop) (void);
48 void (*handle_interrupt) (struct pt_regs *, 50 void (*handle_interrupt) (struct pt_regs *,
49 struct op_counter_config *); 51 struct op_counter_config *);
50 int num_counters; 52 int num_counters;
@@ -54,6 +56,7 @@ extern struct op_powerpc_model op_model_fsl_booke;
54extern struct op_powerpc_model op_model_rs64; 56extern struct op_powerpc_model op_model_rs64;
55extern struct op_powerpc_model op_model_power4; 57extern struct op_powerpc_model op_model_power4;
56extern struct op_powerpc_model op_model_7450; 58extern struct op_powerpc_model op_model_7450;
59extern struct op_powerpc_model op_model_cell;
57 60
58#ifndef CONFIG_FSL_BOOKE 61#ifndef CONFIG_FSL_BOOKE
59 62
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index 0a4e5c93e8e6..0d3adc09c847 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -93,7 +93,8 @@ struct paca_struct {
93 u64 stab_rr; /* stab/slb round-robin counter */ 93 u64 stab_rr; /* stab/slb round-robin counter */
94 u64 saved_r1; /* r1 save for RTAS calls */ 94 u64 saved_r1; /* r1 save for RTAS calls */
95 u64 saved_msr; /* MSR saved here by enter_rtas */ 95 u64 saved_msr; /* MSR saved here by enter_rtas */
96 u8 proc_enabled; /* irq soft-enable flag */ 96 u8 soft_enabled; /* irq soft-enable flag */
97 u8 hard_enabled; /* set if irqs are enabled in MSR */
97 u8 io_sync; /* writel() needs spin_unlock sync */ 98 u8 io_sync; /* writel() needs spin_unlock sync */
98 99
99 /* Stuff for accurate time accounting */ 100 /* Stuff for accurate time accounting */
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
index 86ee46b09b8a..7bb7f9009806 100644
--- a/include/asm-powerpc/pci-bridge.h
+++ b/include/asm-powerpc/pci-bridge.h
@@ -25,6 +25,7 @@ struct pci_controller {
25 int node; 25 int node;
26 void *arch_data; 26 void *arch_data;
27 struct list_head list_node; 27 struct list_head list_node;
28 struct device *parent;
28 29
29 int first_busno; 30 int first_busno;
30 int last_busno; 31 int last_busno;
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
index 721c97f09b20..16f13319c769 100644
--- a/include/asm-powerpc/pci.h
+++ b/include/asm-powerpc/pci.h
@@ -70,15 +70,15 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
70 */ 70 */
71#define PCI_DISABLE_MWI 71#define PCI_DISABLE_MWI
72 72
73extern struct dma_mapping_ops pci_dma_ops; 73extern struct dma_mapping_ops *pci_dma_ops;
74 74
75/* For DAC DMA, we currently don't support it by default, but 75/* For DAC DMA, we currently don't support it by default, but
76 * we let 64-bit platforms override this. 76 * we let 64-bit platforms override this.
77 */ 77 */
78static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask) 78static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask)
79{ 79{
80 if (pci_dma_ops.dac_dma_supported) 80 if (pci_dma_ops && pci_dma_ops->dac_dma_supported)
81 return pci_dma_ops.dac_dma_supported(&hwdev->dev, mask); 81 return pci_dma_ops->dac_dma_supported(&hwdev->dev, mask);
82 return 0; 82 return 0;
83} 83}
84 84
@@ -210,6 +210,8 @@ extern int remap_bus_range(struct pci_bus *bus);
210extern void pcibios_fixup_device_resources(struct pci_dev *dev, 210extern void pcibios_fixup_device_resources(struct pci_dev *dev,
211 struct pci_bus *bus); 211 struct pci_bus *bus);
212 212
213extern void pcibios_setup_new_device(struct pci_dev *dev);
214
213extern void pcibios_claim_one_bus(struct pci_bus *b); 215extern void pcibios_claim_one_bus(struct pci_bus *b);
214 216
215extern struct pci_controller *init_phb_dynamic(struct device_node *dn); 217extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
@@ -232,12 +234,10 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file,
232 unsigned long size, 234 unsigned long size,
233 pgprot_t prot); 235 pgprot_t prot);
234 236
235#if defined(CONFIG_PPC_MULTIPLATFORM) || defined(CONFIG_PPC32)
236#define HAVE_ARCH_PCI_RESOURCE_TO_USER 237#define HAVE_ARCH_PCI_RESOURCE_TO_USER
237extern void pci_resource_to_user(const struct pci_dev *dev, int bar, 238extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
238 const struct resource *rsrc, 239 const struct resource *rsrc,
239 resource_size_t *start, resource_size_t *end); 240 resource_size_t *start, resource_size_t *end);
240#endif /* CONFIG_PPC_MULTIPLATFORM || CONFIG_PPC32 */
241 241
242#endif /* __KERNEL__ */ 242#endif /* __KERNEL__ */
243#endif /* __ASM_POWERPC_PCI_H */ 243#endif /* __ASM_POWERPC_PCI_H */
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h
index 1115756c79f9..ab6eddb518c7 100644
--- a/include/asm-powerpc/ppc-pci.h
+++ b/include/asm-powerpc/ppc-pci.h
@@ -36,18 +36,17 @@ typedef void *(*traverse_func)(struct device_node *me, void *data);
36void *traverse_pci_devices(struct device_node *start, traverse_func pre, 36void *traverse_pci_devices(struct device_node *start, traverse_func pre,
37 void *data); 37 void *data);
38 38
39void pci_devs_phb_init(void); 39extern void pci_devs_phb_init(void);
40void pci_devs_phb_init_dynamic(struct pci_controller *phb); 40extern void pci_devs_phb_init_dynamic(struct pci_controller *phb);
41int setup_phb(struct device_node *dev, struct pci_controller *phb); 41extern void scan_phb(struct pci_controller *hose);
42void __devinit scan_phb(struct pci_controller *hose);
43 42
44/* From rtas_pci.h */ 43/* From rtas_pci.h */
45void init_pci_config_tokens (void); 44extern void init_pci_config_tokens (void);
46unsigned long get_phb_buid (struct device_node *); 45extern unsigned long get_phb_buid (struct device_node *);
46extern int rtas_setup_phb(struct pci_controller *phb);
47 47
48/* From pSeries_pci.h */ 48/* From pSeries_pci.h */
49extern void pSeries_final_fixup(void); 49extern void pSeries_final_fixup(void);
50extern void pSeries_irq_bus_setup(struct pci_bus *bus);
51 50
52extern unsigned long pci_probe_only; 51extern unsigned long pci_probe_only;
53 52
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index 6cb6fb19e57f..a26c32ee5527 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -53,10 +53,6 @@ extern unsigned char ucBoardRevMaj, ucBoardRevMin;
53 53
54#endif /* CONFIG_PPC_PREP */ 54#endif /* CONFIG_PPC_PREP */
55 55
56#ifndef CONFIG_PPC_MULTIPLATFORM
57#define _machine 0
58#endif /* CONFIG_PPC_MULTIPLATFORM */
59
60#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */ 56#endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
61 57
62/* 58/*
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index ec11d44eaeb5..0afee17f33b4 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/platform_device.h>
20#include <asm/atomic.h> 21#include <asm/atomic.h>
21 22
22/* Definitions used by the flattened device tree */ 23/* Definitions used by the flattened device tree */
@@ -333,6 +334,20 @@ extern int of_irq_map_one(struct device_node *device, int index,
333struct pci_dev; 334struct pci_dev;
334extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq); 335extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
335 336
337static inline int of_irq_to_resource(struct device_node *dev, int index, struct resource *r)
338{
339 int irq = irq_of_parse_and_map(dev, index);
340
341 /* Only dereference the resource if both the
342 * resource and the irq are valid. */
343 if (r && irq != NO_IRQ) {
344 r->start = r->end = irq;
345 r->flags = IORESOURCE_IRQ;
346 }
347
348 return irq;
349}
350
336 351
337#endif /* __KERNEL__ */ 352#endif /* __KERNEL__ */
338#endif /* _POWERPC_PROM_H */ 353#endif /* _POWERPC_PROM_H */
diff --git a/include/asm-powerpc/ps3.h b/include/asm-powerpc/ps3.h
new file mode 100644
index 000000000000..52a69ed0d90a
--- /dev/null
+++ b/include/asm-powerpc/ps3.h
@@ -0,0 +1,462 @@
1/*
2 * PS3 platform declarations.
3 *
4 * Copyright (C) 2006 Sony Computer Entertainment Inc.
5 * Copyright 2006 Sony Corp.
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; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#if !defined(_ASM_POWERPC_PS3_H)
22#define _ASM_POWERPC_PS3_H
23
24#include <linux/compiler.h> /* for __deprecated */
25#include <linux/init.h>
26#include <linux/types.h>
27#include <linux/device.h>
28
29/**
30 * struct ps3_device_id - HV bus device identifier from the system repository
31 * @bus_id: HV bus id, {1..} (zero invalid)
32 * @dev_id: HV device id, {0..}
33 */
34
35struct ps3_device_id {
36 unsigned int bus_id;
37 unsigned int dev_id;
38};
39
40
41/* dma routines */
42
43enum ps3_dma_page_size {
44 PS3_DMA_4K = 12U,
45 PS3_DMA_64K = 16U,
46 PS3_DMA_1M = 20U,
47 PS3_DMA_16M = 24U,
48};
49
50enum ps3_dma_region_type {
51 PS3_DMA_OTHER = 0,
52 PS3_DMA_INTERNAL = 2,
53};
54
55/**
56 * struct ps3_dma_region - A per device dma state variables structure
57 * @did: The HV device id.
58 * @page_size: The ioc pagesize.
59 * @region_type: The HV region type.
60 * @bus_addr: The 'translated' bus address of the region.
61 * @len: The length in bytes of the region.
62 * @chunk_list: Opaque variable used by the ioc page manager.
63 */
64
65struct ps3_dma_region {
66 struct ps3_device_id did;
67 enum ps3_dma_page_size page_size;
68 enum ps3_dma_region_type region_type;
69 unsigned long bus_addr;
70 unsigned long len;
71 struct {
72 spinlock_t lock;
73 struct list_head head;
74 } chunk_list;
75};
76
77/**
78 * struct ps3_dma_region_init - Helper to initialize structure variables
79 *
80 * Helper to properly initialize variables prior to calling
81 * ps3_system_bus_device_register.
82 */
83
84static inline void ps3_dma_region_init(struct ps3_dma_region *r,
85 const struct ps3_device_id* did, enum ps3_dma_page_size page_size,
86 enum ps3_dma_region_type region_type)
87{
88 r->did = *did;
89 r->page_size = page_size;
90 r->region_type = region_type;
91}
92int ps3_dma_region_create(struct ps3_dma_region *r);
93int ps3_dma_region_free(struct ps3_dma_region *r);
94int ps3_dma_map(struct ps3_dma_region *r, unsigned long virt_addr,
95 unsigned long len, unsigned long *bus_addr);
96int ps3_dma_unmap(struct ps3_dma_region *r, unsigned long bus_addr,
97 unsigned long len);
98
99/* mmio routines */
100
101enum ps3_mmio_page_size {
102 PS3_MMIO_4K = 12U,
103 PS3_MMIO_64K = 16U
104};
105
106/**
107 * struct ps3_mmio_region - a per device mmio state variables structure
108 *
109 * Current systems can be supported with a single region per device.
110 */
111
112struct ps3_mmio_region {
113 struct ps3_device_id did;
114 unsigned long bus_addr;
115 unsigned long len;
116 enum ps3_mmio_page_size page_size;
117 unsigned long lpar_addr;
118};
119
120/**
121 * struct ps3_mmio_region_init - Helper to initialize structure variables
122 *
123 * Helper to properly initialize variables prior to calling
124 * ps3_system_bus_device_register.
125 */
126
127static inline void ps3_mmio_region_init(struct ps3_mmio_region *r,
128 const struct ps3_device_id* did, unsigned long bus_addr,
129 unsigned long len, enum ps3_mmio_page_size page_size)
130{
131 r->did = *did;
132 r->bus_addr = bus_addr;
133 r->len = len;
134 r->page_size = page_size;
135}
136int ps3_mmio_region_create(struct ps3_mmio_region *r);
137int ps3_free_mmio_region(struct ps3_mmio_region *r);
138unsigned long ps3_mm_phys_to_lpar(unsigned long phys_addr);
139
140/* inrerrupt routines */
141
142int ps3_alloc_io_irq(unsigned int interrupt_id, unsigned int *virq);
143int ps3_free_io_irq(unsigned int virq);
144int ps3_alloc_event_irq(unsigned int *virq);
145int ps3_free_event_irq(unsigned int virq);
146int ps3_send_event_locally(unsigned int virq);
147int ps3_connect_event_irq(const struct ps3_device_id *did,
148 unsigned int interrupt_id, unsigned int *virq);
149int ps3_disconnect_event_irq(const struct ps3_device_id *did,
150 unsigned int interrupt_id, unsigned int virq);
151int ps3_alloc_vuart_irq(void* virt_addr_bmp, unsigned int *virq);
152int ps3_free_vuart_irq(unsigned int virq);
153int ps3_alloc_spe_irq(unsigned long spe_id, unsigned int class,
154 unsigned int *virq);
155int ps3_free_spe_irq(unsigned int virq);
156
157/* lv1 result codes */
158
159enum lv1_result {
160 LV1_SUCCESS = 0,
161 /* not used -1 */
162 LV1_RESOURCE_SHORTAGE = -2,
163 LV1_NO_PRIVILEGE = -3,
164 LV1_DENIED_BY_POLICY = -4,
165 LV1_ACCESS_VIOLATION = -5,
166 LV1_NO_ENTRY = -6,
167 LV1_DUPLICATE_ENTRY = -7,
168 LV1_TYPE_MISMATCH = -8,
169 LV1_BUSY = -9,
170 LV1_EMPTY = -10,
171 LV1_WRONG_STATE = -11,
172 /* not used -12 */
173 LV1_NO_MATCH = -13,
174 LV1_ALREADY_CONNECTED = -14,
175 LV1_UNSUPPORTED_PARAMETER_VALUE = -15,
176 LV1_CONDITION_NOT_SATISFIED = -16,
177 LV1_ILLEGAL_PARAMETER_VALUE = -17,
178 LV1_BAD_OPTION = -18,
179 LV1_IMPLEMENTATION_LIMITATION = -19,
180 LV1_NOT_IMPLEMENTED = -20,
181 LV1_INVALID_CLASS_ID = -21,
182 LV1_CONSTRAINT_NOT_SATISFIED = -22,
183 LV1_ALIGNMENT_ERROR = -23,
184 LV1_INTERNAL_ERROR = -32768,
185};
186
187static inline const char* ps3_result(int result)
188{
189#if defined(DEBUG)
190 switch (result) {
191 case LV1_SUCCESS:
192 return "LV1_SUCCESS (0)";
193 case -1:
194 return "** unknown result ** (-1)";
195 case LV1_RESOURCE_SHORTAGE:
196 return "LV1_RESOURCE_SHORTAGE (-2)";
197 case LV1_NO_PRIVILEGE:
198 return "LV1_NO_PRIVILEGE (-3)";
199 case LV1_DENIED_BY_POLICY:
200 return "LV1_DENIED_BY_POLICY (-4)";
201 case LV1_ACCESS_VIOLATION:
202 return "LV1_ACCESS_VIOLATION (-5)";
203 case LV1_NO_ENTRY:
204 return "LV1_NO_ENTRY (-6)";
205 case LV1_DUPLICATE_ENTRY:
206 return "LV1_DUPLICATE_ENTRY (-7)";
207 case LV1_TYPE_MISMATCH:
208 return "LV1_TYPE_MISMATCH (-8)";
209 case LV1_BUSY:
210 return "LV1_BUSY (-9)";
211 case LV1_EMPTY:
212 return "LV1_EMPTY (-10)";
213 case LV1_WRONG_STATE:
214 return "LV1_WRONG_STATE (-11)";
215 case -12:
216 return "** unknown result ** (-12)";
217 case LV1_NO_MATCH:
218 return "LV1_NO_MATCH (-13)";
219 case LV1_ALREADY_CONNECTED:
220 return "LV1_ALREADY_CONNECTED (-14)";
221 case LV1_UNSUPPORTED_PARAMETER_VALUE:
222 return "LV1_UNSUPPORTED_PARAMETER_VALUE (-15)";
223 case LV1_CONDITION_NOT_SATISFIED:
224 return "LV1_CONDITION_NOT_SATISFIED (-16)";
225 case LV1_ILLEGAL_PARAMETER_VALUE:
226 return "LV1_ILLEGAL_PARAMETER_VALUE (-17)";
227 case LV1_BAD_OPTION:
228 return "LV1_BAD_OPTION (-18)";
229 case LV1_IMPLEMENTATION_LIMITATION:
230 return "LV1_IMPLEMENTATION_LIMITATION (-19)";
231 case LV1_NOT_IMPLEMENTED:
232 return "LV1_NOT_IMPLEMENTED (-20)";
233 case LV1_INVALID_CLASS_ID:
234 return "LV1_INVALID_CLASS_ID (-21)";
235 case LV1_CONSTRAINT_NOT_SATISFIED:
236 return "LV1_CONSTRAINT_NOT_SATISFIED (-22)";
237 case LV1_ALIGNMENT_ERROR:
238 return "LV1_ALIGNMENT_ERROR (-23)";
239 case LV1_INTERNAL_ERROR:
240 return "LV1_INTERNAL_ERROR (-32768)";
241 default:
242 BUG();
243 return "** unknown result **";
244 };
245#else
246 return "";
247#endif
248}
249
250/* repository bus info */
251
252enum ps3_bus_type {
253 PS3_BUS_TYPE_SB = 4,
254 PS3_BUS_TYPE_STORAGE = 5,
255};
256
257enum ps3_dev_type {
258 PS3_DEV_TYPE_SB_GELIC = 3,
259 PS3_DEV_TYPE_SB_USB = 4,
260 PS3_DEV_TYPE_SB_GPIO = 6,
261};
262
263int ps3_repository_read_bus_str(unsigned int bus_index, const char *bus_str,
264 u64 *value);
265int ps3_repository_read_bus_id(unsigned int bus_index, unsigned int *bus_id);
266int ps3_repository_read_bus_type(unsigned int bus_index,
267 enum ps3_bus_type *bus_type);
268int ps3_repository_read_bus_num_dev(unsigned int bus_index,
269 unsigned int *num_dev);
270
271/* repository bus device info */
272
273enum ps3_interrupt_type {
274 PS3_INTERRUPT_TYPE_EVENT_PORT = 2,
275 PS3_INTERRUPT_TYPE_SB_OHCI = 3,
276 PS3_INTERRUPT_TYPE_SB_EHCI = 4,
277 PS3_INTERRUPT_TYPE_OTHER = 5,
278};
279
280enum ps3_region_type {
281 PS3_REGION_TYPE_SB_OHCI = 3,
282 PS3_REGION_TYPE_SB_EHCI = 4,
283 PS3_REGION_TYPE_SB_GPIO = 5,
284};
285
286int ps3_repository_read_dev_str(unsigned int bus_index,
287 unsigned int dev_index, const char *dev_str, u64 *value);
288int ps3_repository_read_dev_id(unsigned int bus_index, unsigned int dev_index,
289 unsigned int *dev_id);
290int ps3_repository_read_dev_type(unsigned int bus_index,
291 unsigned int dev_index, enum ps3_dev_type *dev_type);
292int ps3_repository_read_dev_intr(unsigned int bus_index,
293 unsigned int dev_index, unsigned int intr_index,
294 enum ps3_interrupt_type *intr_type, unsigned int *interrupt_id);
295int ps3_repository_read_dev_reg_type(unsigned int bus_index,
296 unsigned int dev_index, unsigned int reg_index,
297 enum ps3_region_type *reg_type);
298int ps3_repository_read_dev_reg_addr(unsigned int bus_index,
299 unsigned int dev_index, unsigned int reg_index, u64 *bus_addr,
300 u64 *len);
301int ps3_repository_read_dev_reg(unsigned int bus_index,
302 unsigned int dev_index, unsigned int reg_index,
303 enum ps3_region_type *reg_type, u64 *bus_addr, u64 *len);
304
305/* repository bus enumerators */
306
307struct ps3_repository_device {
308 unsigned int bus_index;
309 unsigned int dev_index;
310 struct ps3_device_id did;
311};
312
313int ps3_repository_find_device(enum ps3_bus_type bus_type,
314 enum ps3_dev_type dev_type,
315 const struct ps3_repository_device *start_dev,
316 struct ps3_repository_device *dev);
317static inline int ps3_repository_find_first_device(
318 enum ps3_bus_type bus_type, enum ps3_dev_type dev_type,
319 struct ps3_repository_device *dev)
320{
321 return ps3_repository_find_device(bus_type, dev_type, NULL, dev);
322}
323int ps3_repository_find_interrupt(const struct ps3_repository_device *dev,
324 enum ps3_interrupt_type intr_type, unsigned int *interrupt_id);
325int ps3_repository_find_region(const struct ps3_repository_device *dev,
326 enum ps3_region_type reg_type, u64 *bus_addr, u64 *len);
327
328/* repository block device info */
329
330int ps3_repository_read_dev_port(unsigned int bus_index,
331 unsigned int dev_index, u64 *port);
332int ps3_repository_read_dev_blk_size(unsigned int bus_index,
333 unsigned int dev_index, u64 *blk_size);
334int ps3_repository_read_dev_num_blocks(unsigned int bus_index,
335 unsigned int dev_index, u64 *num_blocks);
336int ps3_repository_read_dev_num_regions(unsigned int bus_index,
337 unsigned int dev_index, unsigned int *num_regions);
338int ps3_repository_read_dev_region_id(unsigned int bus_index,
339 unsigned int dev_index, unsigned int region_index,
340 unsigned int *region_id);
341int ps3_repository_read_dev_region_size(unsigned int bus_index,
342 unsigned int dev_index, unsigned int region_index, u64 *region_size);
343int ps3_repository_read_dev_region_start(unsigned int bus_index,
344 unsigned int dev_index, unsigned int region_index, u64 *region_start);
345
346/* repository pu and memory info */
347
348int ps3_repository_read_num_pu(unsigned int *num_pu);
349int ps3_repository_read_ppe_id(unsigned int *pu_index, unsigned int *ppe_id);
350int ps3_repository_read_rm_base(unsigned int ppe_id, u64 *rm_base);
351int ps3_repository_read_rm_size(unsigned int ppe_id, u64 *rm_size);
352int ps3_repository_read_region_total(u64 *region_total);
353int ps3_repository_read_mm_info(u64 *rm_base, u64 *rm_size,
354 u64 *region_total);
355
356/* repository pme info */
357
358int ps3_repository_read_num_be(unsigned int *num_be);
359int ps3_repository_read_be_node_id(unsigned int be_index, u64 *node_id);
360int ps3_repository_read_tb_freq(u64 node_id, u64 *tb_freq);
361int ps3_repository_read_be_tb_freq(unsigned int be_index, u64 *tb_freq);
362
363/* repository 'Other OS' area */
364
365int ps3_repository_read_boot_dat_addr(u64 *lpar_addr);
366int ps3_repository_read_boot_dat_size(unsigned int *size);
367int ps3_repository_read_boot_dat_info(u64 *lpar_addr, unsigned int *size);
368
369/* repository spu info */
370
371/**
372 * enum spu_resource_type - Type of spu resource.
373 * @spu_resource_type_shared: Logical spu is shared with other partions.
374 * @spu_resource_type_exclusive: Logical spu is not shared with other partions.
375 *
376 * Returned by ps3_repository_read_spu_resource_id().
377 */
378
379enum ps3_spu_resource_type {
380 PS3_SPU_RESOURCE_TYPE_SHARED = 0,
381 PS3_SPU_RESOURCE_TYPE_EXCLUSIVE = 0x8000000000000000UL,
382};
383
384int ps3_repository_read_num_spu_reserved(unsigned int *num_spu_reserved);
385int ps3_repository_read_num_spu_resource_id(unsigned int *num_resource_id);
386int ps3_repository_read_spu_resource_id(unsigned int res_index,
387 enum ps3_spu_resource_type* resource_type, unsigned int *resource_id);
388
389
390/* system bus routines */
391
392enum ps3_match_id {
393 PS3_MATCH_ID_EHCI = 1,
394 PS3_MATCH_ID_OHCI,
395 PS3_MATCH_ID_GELIC,
396 PS3_MATCH_ID_AV_SETTINGS,
397 PS3_MATCH_ID_SYSTEM_MANAGER,
398};
399
400/**
401 * struct ps3_system_bus_device - a device on the system bus
402 */
403
404struct ps3_system_bus_device {
405 enum ps3_match_id match_id;
406 struct ps3_device_id did;
407 unsigned int interrupt_id;
408/* struct iommu_table *iommu_table; -- waiting for Ben's cleanups */
409 struct ps3_dma_region *d_region;
410 struct ps3_mmio_region *m_region;
411 struct device core;
412};
413
414/**
415 * struct ps3_system_bus_driver - a driver for a device on the system bus
416 */
417
418struct ps3_system_bus_driver {
419 enum ps3_match_id match_id;
420 struct device_driver core;
421 int (*probe)(struct ps3_system_bus_device *);
422 int (*remove)(struct ps3_system_bus_device *);
423/* int (*suspend)(struct ps3_system_bus_device *, pm_message_t); */
424/* int (*resume)(struct ps3_system_bus_device *); */
425};
426
427int ps3_system_bus_device_register(struct ps3_system_bus_device *dev);
428int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv);
429void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv);
430static inline struct ps3_system_bus_driver *to_ps3_system_bus_driver(
431 struct device_driver *_drv)
432{
433 return container_of(_drv, struct ps3_system_bus_driver, core);
434}
435static inline struct ps3_system_bus_device *to_ps3_system_bus_device(
436 struct device *_dev)
437{
438 return container_of(_dev, struct ps3_system_bus_device, core);
439}
440
441/**
442 * ps3_system_bus_set_drvdata -
443 * @dev: device structure
444 * @data: Data to set
445 */
446
447static inline void ps3_system_bus_set_driver_data(
448 struct ps3_system_bus_device *dev, void *data)
449{
450 dev->core.driver_data = data;
451}
452static inline void *ps3_system_bus_get_driver_data(
453 struct ps3_system_bus_device *dev)
454{
455 return dev->core.driver_data;
456}
457
458/* These two need global scope for get_dma_ops(). */
459
460extern struct bus_type ps3_system_bus_type;
461
462#endif
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
index d34f9e1f242c..5a0c136c0416 100644
--- a/include/asm-powerpc/rtas.h
+++ b/include/asm-powerpc/rtas.h
@@ -54,8 +54,6 @@ struct rtas_args {
54 rtas_arg_t *rets; /* Pointer to return values in args[]. */ 54 rtas_arg_t *rets; /* Pointer to return values in args[]. */
55}; 55};
56 56
57extern struct rtas_args rtas_stop_self_args;
58
59struct rtas_t { 57struct rtas_t {
60 unsigned long entry; /* physical address pointer */ 58 unsigned long entry; /* physical address pointer */
61 unsigned long base; /* physical address pointer */ 59 unsigned long base; /* physical address pointer */
diff --git a/include/asm-powerpc/sparsemem.h b/include/asm-powerpc/sparsemem.h
index 38b1ea3b58fd..48ad807a0b8a 100644
--- a/include/asm-powerpc/sparsemem.h
+++ b/include/asm-powerpc/sparsemem.h
@@ -9,8 +9,14 @@
9 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space 9 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
10 */ 10 */
11#define SECTION_SIZE_BITS 24 11#define SECTION_SIZE_BITS 24
12
13#if defined(CONFIG_PS3_USE_LPAR_ADDR)
14#define MAX_PHYSADDR_BITS 47
15#define MAX_PHYSMEM_BITS 47
16#else
12#define MAX_PHYSADDR_BITS 44 17#define MAX_PHYSADDR_BITS 44
13#define MAX_PHYSMEM_BITS 44 18#define MAX_PHYSMEM_BITS 44
19#endif
14 20
15#ifdef CONFIG_MEMORY_HOTPLUG 21#ifdef CONFIG_MEMORY_HOTPLUG
16extern void create_section_mapping(unsigned long start, unsigned long end); 22extern void create_section_mapping(unsigned long start, unsigned long end);
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index e73ea00efd8b..fdad4267b447 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -111,14 +111,12 @@ struct spu {
111 u8 *local_store; 111 u8 *local_store;
112 unsigned long problem_phys; 112 unsigned long problem_phys;
113 struct spu_problem __iomem *problem; 113 struct spu_problem __iomem *problem;
114 struct spu_priv1 __iomem *priv1;
115 struct spu_priv2 __iomem *priv2; 114 struct spu_priv2 __iomem *priv2;
116 struct list_head list; 115 struct list_head list;
117 struct list_head sched_list; 116 struct list_head sched_list;
117 struct list_head full_list;
118 int number; 118 int number;
119 int nid;
120 unsigned int irqs[3]; 119 unsigned int irqs[3];
121 u32 isrc;
122 u32 node; 120 u32 node;
123 u64 flags; 121 u64 flags;
124 u64 dar; 122 u64 dar;
@@ -144,6 +142,7 @@ struct spu {
144 char irq_c1[8]; 142 char irq_c1[8];
145 char irq_c2[8]; 143 char irq_c2[8];
146 144
145 void* pdata; /* platform private data */
147 struct sys_device sysdev; 146 struct sys_device sysdev;
148}; 147};
149 148
@@ -170,6 +169,13 @@ extern struct spufs_calls {
170 struct module *owner; 169 struct module *owner;
171} spufs_calls; 170} spufs_calls;
172 171
172/* coredump calls implemented in spufs */
173struct spu_coredump_calls {
174 asmlinkage int (*arch_notes_size)(void);
175 asmlinkage void (*arch_write_notes)(struct file *file);
176 struct module *owner;
177};
178
173/* return status from spu_run, same as in libspe */ 179/* return status from spu_run, same as in libspe */
174#define SPE_EVENT_DMA_ALIGNMENT 0x0008 /*A DMA alignment error */ 180#define SPE_EVENT_DMA_ALIGNMENT 0x0008 /*A DMA alignment error */
175#define SPE_EVENT_SPE_ERROR 0x0010 /*An illegal instruction error*/ 181#define SPE_EVENT_SPE_ERROR 0x0010 /*An illegal instruction error*/
@@ -182,8 +188,10 @@ extern struct spufs_calls {
182 */ 188 */
183#define SPU_CREATE_EVENTS_ENABLED 0x0001 189#define SPU_CREATE_EVENTS_ENABLED 0x0001
184#define SPU_CREATE_GANG 0x0002 190#define SPU_CREATE_GANG 0x0002
191#define SPU_CREATE_NOSCHED 0x0004
192#define SPU_CREATE_ISOLATE 0x0008
185 193
186#define SPU_CREATE_FLAG_ALL 0x0003 /* mask of all valid flags */ 194#define SPU_CREATE_FLAG_ALL 0x000f /* mask of all valid flags */
187 195
188 196
189#ifdef CONFIG_SPU_FS_MODULE 197#ifdef CONFIG_SPU_FS_MODULE
@@ -199,6 +207,15 @@ static inline void unregister_spu_syscalls(struct spufs_calls *calls)
199} 207}
200#endif /* MODULE */ 208#endif /* MODULE */
201 209
210int register_arch_coredump_calls(struct spu_coredump_calls *calls);
211void unregister_arch_coredump_calls(struct spu_coredump_calls *calls);
212
213int spu_add_sysdev_attr(struct sysdev_attribute *attr);
214void spu_remove_sysdev_attr(struct sysdev_attribute *attr);
215
216int spu_add_sysdev_attr_group(struct attribute_group *attrs);
217void spu_remove_sysdev_attr_group(struct attribute_group *attrs);
218
202 219
203/* 220/*
204 * Notifier blocks: 221 * Notifier blocks:
@@ -277,6 +294,7 @@ struct spu_problem {
277 u32 spu_runcntl_RW; /* 0x401c */ 294 u32 spu_runcntl_RW; /* 0x401c */
278#define SPU_RUNCNTL_STOP 0L 295#define SPU_RUNCNTL_STOP 0L
279#define SPU_RUNCNTL_RUNNABLE 1L 296#define SPU_RUNCNTL_RUNNABLE 1L
297#define SPU_RUNCNTL_ISOLATE 2L
280 u8 pad_0x4020_0x4024[0x4]; /* 0x4020 */ 298 u8 pad_0x4020_0x4024[0x4]; /* 0x4020 */
281 u32 spu_status_R; /* 0x4024 */ 299 u32 spu_status_R; /* 0x4024 */
282#define SPU_STOP_STATUS_SHIFT 16 300#define SPU_STOP_STATUS_SHIFT 16
@@ -289,8 +307,8 @@ struct spu_problem {
289#define SPU_STATUS_INVALID_INSTR 0x20 307#define SPU_STATUS_INVALID_INSTR 0x20
290#define SPU_STATUS_INVALID_CH 0x40 308#define SPU_STATUS_INVALID_CH 0x40
291#define SPU_STATUS_ISOLATED_STATE 0x80 309#define SPU_STATUS_ISOLATED_STATE 0x80
292#define SPU_STATUS_ISOLATED_LOAD_STAUTUS 0x200 310#define SPU_STATUS_ISOLATED_LOAD_STATUS 0x200
293#define SPU_STATUS_ISOLATED_EXIT_STAUTUS 0x400 311#define SPU_STATUS_ISOLATED_EXIT_STATUS 0x400
294 u8 pad_0x4028_0x402c[0x4]; /* 0x4028 */ 312 u8 pad_0x4028_0x402c[0x4]; /* 0x4028 */
295 u32 spu_spe_R; /* 0x402c */ 313 u32 spu_spe_R; /* 0x402c */
296 u8 pad_0x4030_0x4034[0x4]; /* 0x4030 */ 314 u8 pad_0x4030_0x4034[0x4]; /* 0x4030 */
diff --git a/include/asm-powerpc/spu_csa.h b/include/asm-powerpc/spu_csa.h
index 964c2d38ccb7..bdbf906a767f 100644
--- a/include/asm-powerpc/spu_csa.h
+++ b/include/asm-powerpc/spu_csa.h
@@ -151,7 +151,6 @@ struct spu_priv1_collapsed {
151 u64 mfc_fir_chkstp_enable_RW; 151 u64 mfc_fir_chkstp_enable_RW;
152 u64 smf_sbi_signal_sel; 152 u64 smf_sbi_signal_sel;
153 u64 smf_ato_signal_sel; 153 u64 smf_ato_signal_sel;
154 u64 mfc_sdr_RW;
155 u64 tlb_index_hint_RO; 154 u64 tlb_index_hint_RO;
156 u64 tlb_index_W; 155 u64 tlb_index_W;
157 u64 tlb_vpn_RW; 156 u64 tlb_vpn_RW;
diff --git a/include/asm-powerpc/spu_info.h b/include/asm-powerpc/spu_info.h
new file mode 100644
index 000000000000..3545efbf9891
--- /dev/null
+++ b/include/asm-powerpc/spu_info.h
@@ -0,0 +1,54 @@
1/*
2 * SPU info structures
3 *
4 * (C) Copyright 2006 IBM Corp.
5 *
6 * Author: Dwayne Grant McConnell <decimal@us.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
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#ifndef _SPU_INFO_H
24#define _SPU_INFO_H
25
26#ifdef __KERNEL__
27#include <asm/spu.h>
28#include <linux/types.h>
29#else
30struct mfc_cq_sr {
31 __u64 mfc_cq_data0_RW;
32 __u64 mfc_cq_data1_RW;
33 __u64 mfc_cq_data2_RW;
34 __u64 mfc_cq_data3_RW;
35};
36#endif /* __KERNEL__ */
37
38struct spu_dma_info {
39 __u64 dma_info_type;
40 __u64 dma_info_mask;
41 __u64 dma_info_status;
42 __u64 dma_info_stall_and_notify;
43 __u64 dma_info_atomic_command_status;
44 struct mfc_cq_sr dma_info_command_data[16];
45};
46
47struct spu_proxydma_info {
48 __u64 proxydma_info_type;
49 __u64 proxydma_info_mask;
50 __u64 proxydma_info_status;
51 struct mfc_cq_sr proxydma_info_command_data[8];
52};
53
54#endif
diff --git a/include/asm-powerpc/spu_priv1.h b/include/asm-powerpc/spu_priv1.h
index 300c458b6d06..69dcb0c53884 100644
--- a/include/asm-powerpc/spu_priv1.h
+++ b/include/asm-powerpc/spu_priv1.h
@@ -21,12 +21,13 @@
21#define _SPU_PRIV1_H 21#define _SPU_PRIV1_H
22#if defined(__KERNEL__) 22#if defined(__KERNEL__)
23 23
24#include <linux/types.h>
25
24struct spu; 26struct spu;
25 27
26/* access to priv1 registers */ 28/* access to priv1 registers */
27 29
28struct spu_priv1_ops 30struct spu_priv1_ops {
29{
30 void (*int_mask_and) (struct spu *spu, int class, u64 mask); 31 void (*int_mask_and) (struct spu *spu, int class, u64 mask);
31 void (*int_mask_or) (struct spu *spu, int class, u64 mask); 32 void (*int_mask_or) (struct spu *spu, int class, u64 mask);
32 void (*int_mask_set) (struct spu *spu, int class, u64 mask); 33 void (*int_mask_set) (struct spu *spu, int class, u64 mask);
@@ -37,7 +38,7 @@ struct spu_priv1_ops
37 u64 (*mfc_dar_get) (struct spu *spu); 38 u64 (*mfc_dar_get) (struct spu *spu);
38 u64 (*mfc_dsisr_get) (struct spu *spu); 39 u64 (*mfc_dsisr_get) (struct spu *spu);
39 void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr); 40 void (*mfc_dsisr_set) (struct spu *spu, u64 dsisr);
40 void (*mfc_sdr_set) (struct spu *spu, u64 sdr); 41 void (*mfc_sdr_setup) (struct spu *spu);
41 void (*mfc_sr1_set) (struct spu *spu, u64 sr1); 42 void (*mfc_sr1_set) (struct spu *spu, u64 sr1);
42 u64 (*mfc_sr1_get) (struct spu *spu); 43 u64 (*mfc_sr1_get) (struct spu *spu);
43 void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id); 44 void (*mfc_tclass_id_set) (struct spu *spu, u64 tclass_id);
@@ -112,9 +113,9 @@ spu_mfc_dsisr_set (struct spu *spu, u64 dsisr)
112} 113}
113 114
114static inline void 115static inline void
115spu_mfc_sdr_set (struct spu *spu, u64 sdr) 116spu_mfc_sdr_setup (struct spu *spu)
116{ 117{
117 spu_priv1_ops->mfc_sdr_set(spu, sdr); 118 spu_priv1_ops->mfc_sdr_setup(spu);
118} 119}
119 120
120static inline void 121static inline void
@@ -171,12 +172,41 @@ spu_resource_allocation_enable_get (struct spu *spu)
171 return spu_priv1_ops->resource_allocation_enable_get(spu); 172 return spu_priv1_ops->resource_allocation_enable_get(spu);
172} 173}
173 174
174/* The declarations folowing are put here for convenience 175/* spu management abstraction */
175 * and only intended to be used by the platform setup code 176
176 * for initializing spu_priv1_ops. 177struct spu_management_ops {
178 int (*enumerate_spus)(int (*fn)(void *data));
179 int (*create_spu)(struct spu *spu, void *data);
180 int (*destroy_spu)(struct spu *spu);
181};
182
183extern const struct spu_management_ops* spu_management_ops;
184
185static inline int
186spu_enumerate_spus (int (*fn)(void *data))
187{
188 return spu_management_ops->enumerate_spus(fn);
189}
190
191static inline int
192spu_create_spu (struct spu *spu, void *data)
193{
194 return spu_management_ops->create_spu(spu, data);
195}
196
197static inline int
198spu_destroy_spu (struct spu *spu)
199{
200 return spu_management_ops->destroy_spu(spu);
201}
202
203/*
204 * The declarations folowing are put here for convenience
205 * and only intended to be used by the platform setup code.
177 */ 206 */
178 207
179extern const struct spu_priv1_ops spu_priv1_mmio_ops; 208extern const struct spu_priv1_ops spu_priv1_mmio_ops;
209extern const struct spu_management_ops spu_management_of_ops;
180 210
181#endif /* __KERNEL__ */ 211#endif /* __KERNEL__ */
182#endif 212#endif
diff --git a/include/asm-powerpc/todc.h b/include/asm-powerpc/todc.h
deleted file mode 100644
index 60a8c39b8c11..000000000000
--- a/include/asm-powerpc/todc.h
+++ /dev/null
@@ -1,487 +0,0 @@
1/*
2 * Definitions for the M48Txx and mc146818 series of Time of day/Real Time
3 * Clock chips.
4 *
5 * Author: Mark A. Greer <mgreer@mvista.com>
6 *
7 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
11 */
12
13/*
14 * Support for the M48T37/M48T59/.../mc146818 Real Time Clock chips.
15 * Purpose is to make one generic file that handles all of these chips instead
16 * of every platform implementing the same code over & over again.
17 */
18
19#ifndef __PPC_KERNEL_TODC_H
20#define __PPC_KERNEL_TODC_H
21
22typedef struct {
23 uint rtc_type; /* your particular chip */
24
25 /*
26 * Following are the addresses of the AS0, AS1, and DATA registers
27 * of these chips. Note that these are board-specific.
28 */
29 unsigned int nvram_as0;
30 unsigned int nvram_as1;
31 unsigned int nvram_data;
32
33 /*
34 * Define bits to stop external set of regs from changing so
35 * the chip can be read/written reliably.
36 */
37 unsigned char enable_read;
38 unsigned char enable_write;
39
40 /*
41 * Following is the number of AS0 address bits. This is normally
42 * 8 but some bad hardware routes address lines incorrectly.
43 */
44 int as0_bits;
45
46 int nvram_size; /* Size of NVRAM on chip */
47 int sw_flags; /* Software control flags */
48
49 /* Following are the register offsets for the particular chip */
50 int year;
51 int month;
52 int day_of_month;
53 int day_of_week;
54 int hours;
55 int minutes;
56 int seconds;
57 int control_b;
58 int control_a;
59 int watchdog;
60 int interrupts;
61 int alarm_date;
62 int alarm_hour;
63 int alarm_minutes;
64 int alarm_seconds;
65 int century;
66 int flags;
67
68 /*
69 * Some RTC chips have their NVRAM buried behind a addr/data pair of
70 * regs on the first level/clock registers. The following fields
71 * are the addresses for those addr/data regs.
72 */
73 int nvram_addr_reg;
74 int nvram_data_reg;
75} todc_info_t;
76
77/*
78 * Define the types of TODC/RTC variants that are supported in
79 * arch/ppc/kernel/todc_time.c
80 * Make a new one of these for any chip somehow differs from what's already
81 * defined. That way, if you ever need to put in code to touch those
82 * bits/registers in todc_time.c, you can put it inside an
83 * 'if (todc_info->rtc_type == TODC_TYPE_XXX)' so you won't break
84 * anyone else.
85 */
86#define TODC_TYPE_MK48T35 1
87#define TODC_TYPE_MK48T37 2
88#define TODC_TYPE_MK48T59 3
89#define TODC_TYPE_DS1693 4 /* Dallas DS1693 RTC */
90#define TODC_TYPE_DS1743 5 /* Dallas DS1743 RTC */
91#define TODC_TYPE_DS1746 6 /* Dallas DS1746 RTC */
92#define TODC_TYPE_DS1747 7 /* Dallas DS1747 RTC */
93#define TODC_TYPE_DS1501 8 /* Dallas DS1501 RTC */
94#define TODC_TYPE_DS1643 9 /* Dallas DS1643 RTC */
95#define TODC_TYPE_PC97307 10 /* PC97307 internal RTC */
96#define TODC_TYPE_DS1557 11 /* Dallas DS1557 RTC */
97#define TODC_TYPE_DS17285 12 /* Dallas DS17285 RTC */
98#define TODC_TYPE_DS1553 13 /* Dallas DS1553 RTC */
99#define TODC_TYPE_MC146818 100 /* Leave room for m48txx's */
100
101/*
102 * Bit to clear/set to enable reads/writes to the chip
103 */
104#define TODC_MK48TXX_CNTL_A_R 0x40
105#define TODC_MK48TXX_CNTL_A_W 0x80
106#define TODC_MK48TXX_DAY_CB 0x80
107
108#define TODC_DS1501_CNTL_B_TE 0x80
109
110/*
111 * Define flag bits used by todc routines.
112 */
113#define TODC_FLAG_2_LEVEL_NVRAM 0x00000001
114
115/*
116 * Define the values for the various RTC's that should to into the todc_info
117 * table.
118 * Note: The XXX_NVRAM_SIZE, XXX_NVRAM_ADDR_REG, and XXX_NVRAM_DATA_REG only
119 * matter if XXX_SW_FLAGS has TODC_FLAG_2_LEVEL_NVRAM set.
120 */
121#define TODC_TYPE_MK48T35_NVRAM_SIZE 0x7ff8
122#define TODC_TYPE_MK48T35_SW_FLAGS 0
123#define TODC_TYPE_MK48T35_YEAR 0x7fff
124#define TODC_TYPE_MK48T35_MONTH 0x7ffe
125#define TODC_TYPE_MK48T35_DOM 0x7ffd /* Day of Month */
126#define TODC_TYPE_MK48T35_DOW 0x7ffc /* Day of Week */
127#define TODC_TYPE_MK48T35_HOURS 0x7ffb
128#define TODC_TYPE_MK48T35_MINUTES 0x7ffa
129#define TODC_TYPE_MK48T35_SECONDS 0x7ff9
130#define TODC_TYPE_MK48T35_CNTL_B 0x7ff9
131#define TODC_TYPE_MK48T35_CNTL_A 0x7ff8
132#define TODC_TYPE_MK48T35_WATCHDOG 0x0000
133#define TODC_TYPE_MK48T35_INTERRUPTS 0x0000
134#define TODC_TYPE_MK48T35_ALARM_DATE 0x0000
135#define TODC_TYPE_MK48T35_ALARM_HOUR 0x0000
136#define TODC_TYPE_MK48T35_ALARM_MINUTES 0x0000
137#define TODC_TYPE_MK48T35_ALARM_SECONDS 0x0000
138#define TODC_TYPE_MK48T35_CENTURY 0x0000
139#define TODC_TYPE_MK48T35_FLAGS 0x0000
140#define TODC_TYPE_MK48T35_NVRAM_ADDR_REG 0
141#define TODC_TYPE_MK48T35_NVRAM_DATA_REG 0
142
143#define TODC_TYPE_MK48T37_NVRAM_SIZE 0x7ff0
144#define TODC_TYPE_MK48T37_SW_FLAGS 0
145#define TODC_TYPE_MK48T37_YEAR 0x7fff
146#define TODC_TYPE_MK48T37_MONTH 0x7ffe
147#define TODC_TYPE_MK48T37_DOM 0x7ffd /* Day of Month */
148#define TODC_TYPE_MK48T37_DOW 0x7ffc /* Day of Week */
149#define TODC_TYPE_MK48T37_HOURS 0x7ffb
150#define TODC_TYPE_MK48T37_MINUTES 0x7ffa
151#define TODC_TYPE_MK48T37_SECONDS 0x7ff9
152#define TODC_TYPE_MK48T37_CNTL_B 0x7ff9
153#define TODC_TYPE_MK48T37_CNTL_A 0x7ff8
154#define TODC_TYPE_MK48T37_WATCHDOG 0x7ff7
155#define TODC_TYPE_MK48T37_INTERRUPTS 0x7ff6
156#define TODC_TYPE_MK48T37_ALARM_DATE 0x7ff5
157#define TODC_TYPE_MK48T37_ALARM_HOUR 0x7ff4
158#define TODC_TYPE_MK48T37_ALARM_MINUTES 0x7ff3
159#define TODC_TYPE_MK48T37_ALARM_SECONDS 0x7ff2
160#define TODC_TYPE_MK48T37_CENTURY 0x7ff1
161#define TODC_TYPE_MK48T37_FLAGS 0x7ff0
162#define TODC_TYPE_MK48T37_NVRAM_ADDR_REG 0
163#define TODC_TYPE_MK48T37_NVRAM_DATA_REG 0
164
165#define TODC_TYPE_MK48T59_NVRAM_SIZE 0x1ff0
166#define TODC_TYPE_MK48T59_SW_FLAGS 0
167#define TODC_TYPE_MK48T59_YEAR 0x1fff
168#define TODC_TYPE_MK48T59_MONTH 0x1ffe
169#define TODC_TYPE_MK48T59_DOM 0x1ffd /* Day of Month */
170#define TODC_TYPE_MK48T59_DOW 0x1ffc /* Day of Week */
171#define TODC_TYPE_MK48T59_HOURS 0x1ffb
172#define TODC_TYPE_MK48T59_MINUTES 0x1ffa
173#define TODC_TYPE_MK48T59_SECONDS 0x1ff9
174#define TODC_TYPE_MK48T59_CNTL_B 0x1ff9
175#define TODC_TYPE_MK48T59_CNTL_A 0x1ff8
176#define TODC_TYPE_MK48T59_WATCHDOG 0x1fff
177#define TODC_TYPE_MK48T59_INTERRUPTS 0x1fff
178#define TODC_TYPE_MK48T59_ALARM_DATE 0x1fff
179#define TODC_TYPE_MK48T59_ALARM_HOUR 0x1fff
180#define TODC_TYPE_MK48T59_ALARM_MINUTES 0x1fff
181#define TODC_TYPE_MK48T59_ALARM_SECONDS 0x1fff
182#define TODC_TYPE_MK48T59_CENTURY 0x1fff
183#define TODC_TYPE_MK48T59_FLAGS 0x1fff
184#define TODC_TYPE_MK48T59_NVRAM_ADDR_REG 0
185#define TODC_TYPE_MK48T59_NVRAM_DATA_REG 0
186
187#define TODC_TYPE_DS1501_NVRAM_SIZE 0x100
188#define TODC_TYPE_DS1501_SW_FLAGS TODC_FLAG_2_LEVEL_NVRAM
189#define TODC_TYPE_DS1501_YEAR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x06)
190#define TODC_TYPE_DS1501_MONTH (TODC_TYPE_DS1501_NVRAM_SIZE + 0x05)
191#define TODC_TYPE_DS1501_DOM (TODC_TYPE_DS1501_NVRAM_SIZE + 0x04)
192#define TODC_TYPE_DS1501_DOW (TODC_TYPE_DS1501_NVRAM_SIZE + 0x03)
193#define TODC_TYPE_DS1501_HOURS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x02)
194#define TODC_TYPE_DS1501_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x01)
195#define TODC_TYPE_DS1501_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x00)
196#define TODC_TYPE_DS1501_CNTL_B (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
197#define TODC_TYPE_DS1501_CNTL_A (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0f)
198#define TODC_TYPE_DS1501_WATCHDOG (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
199#define TODC_TYPE_DS1501_INTERRUPTS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
200#define TODC_TYPE_DS1501_ALARM_DATE (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0b)
201#define TODC_TYPE_DS1501_ALARM_HOUR (TODC_TYPE_DS1501_NVRAM_SIZE + 0x0a)
202#define TODC_TYPE_DS1501_ALARM_MINUTES (TODC_TYPE_DS1501_NVRAM_SIZE + 0x09)
203#define TODC_TYPE_DS1501_ALARM_SECONDS (TODC_TYPE_DS1501_NVRAM_SIZE + 0x08)
204#define TODC_TYPE_DS1501_CENTURY (TODC_TYPE_DS1501_NVRAM_SIZE + 0x07)
205#define TODC_TYPE_DS1501_FLAGS (TODC_TYPE_DS1501_NVRAM_SIZE + 0xff)
206#define TODC_TYPE_DS1501_NVRAM_ADDR_REG 0x10
207#define TODC_TYPE_DS1501_NVRAM_DATA_REG 0x13
208
209#define TODC_TYPE_DS1553_NVRAM_SIZE 0x1ff0
210#define TODC_TYPE_DS1553_SW_FLAGS 0
211#define TODC_TYPE_DS1553_YEAR 0x1fff
212#define TODC_TYPE_DS1553_MONTH 0x1ffe
213#define TODC_TYPE_DS1553_DOM 0x1ffd /* Day of Month */
214#define TODC_TYPE_DS1553_DOW 0x1ffc /* Day of Week */
215#define TODC_TYPE_DS1553_HOURS 0x1ffb
216#define TODC_TYPE_DS1553_MINUTES 0x1ffa
217#define TODC_TYPE_DS1553_SECONDS 0x1ff9
218#define TODC_TYPE_DS1553_CNTL_B 0x1ff9
219#define TODC_TYPE_DS1553_CNTL_A 0x1ff8 /* control_a R/W regs */
220#define TODC_TYPE_DS1553_WATCHDOG 0x1ff7
221#define TODC_TYPE_DS1553_INTERRUPTS 0x1ff6
222#define TODC_TYPE_DS1553_ALARM_DATE 0x1ff5
223#define TODC_TYPE_DS1553_ALARM_HOUR 0x1ff4
224#define TODC_TYPE_DS1553_ALARM_MINUTES 0x1ff3
225#define TODC_TYPE_DS1553_ALARM_SECONDS 0x1ff2
226#define TODC_TYPE_DS1553_CENTURY 0x1ff8
227#define TODC_TYPE_DS1553_FLAGS 0x1ff0
228#define TODC_TYPE_DS1553_NVRAM_ADDR_REG 0
229#define TODC_TYPE_DS1553_NVRAM_DATA_REG 0
230
231#define TODC_TYPE_DS1557_NVRAM_SIZE 0x7fff0
232#define TODC_TYPE_DS1557_SW_FLAGS 0
233#define TODC_TYPE_DS1557_YEAR 0x7ffff
234#define TODC_TYPE_DS1557_MONTH 0x7fffe
235#define TODC_TYPE_DS1557_DOM 0x7fffd /* Day of Month */
236#define TODC_TYPE_DS1557_DOW 0x7fffc /* Day of Week */
237#define TODC_TYPE_DS1557_HOURS 0x7fffb
238#define TODC_TYPE_DS1557_MINUTES 0x7fffa
239#define TODC_TYPE_DS1557_SECONDS 0x7fff9
240#define TODC_TYPE_DS1557_CNTL_B 0x7fff9
241#define TODC_TYPE_DS1557_CNTL_A 0x7fff8 /* control_a R/W regs */
242#define TODC_TYPE_DS1557_WATCHDOG 0x7fff7
243#define TODC_TYPE_DS1557_INTERRUPTS 0x7fff6
244#define TODC_TYPE_DS1557_ALARM_DATE 0x7fff5
245#define TODC_TYPE_DS1557_ALARM_HOUR 0x7fff4
246#define TODC_TYPE_DS1557_ALARM_MINUTES 0x7fff3
247#define TODC_TYPE_DS1557_ALARM_SECONDS 0x7fff2
248#define TODC_TYPE_DS1557_CENTURY 0x7fff8
249#define TODC_TYPE_DS1557_FLAGS 0x7fff0
250#define TODC_TYPE_DS1557_NVRAM_ADDR_REG 0
251#define TODC_TYPE_DS1557_NVRAM_DATA_REG 0
252
253#define TODC_TYPE_DS1643_NVRAM_SIZE 0x1ff8
254#define TODC_TYPE_DS1643_SW_FLAGS 0
255#define TODC_TYPE_DS1643_YEAR 0x1fff
256#define TODC_TYPE_DS1643_MONTH 0x1ffe
257#define TODC_TYPE_DS1643_DOM 0x1ffd /* Day of Month */
258#define TODC_TYPE_DS1643_DOW 0x1ffc /* Day of Week */
259#define TODC_TYPE_DS1643_HOURS 0x1ffb
260#define TODC_TYPE_DS1643_MINUTES 0x1ffa
261#define TODC_TYPE_DS1643_SECONDS 0x1ff9
262#define TODC_TYPE_DS1643_CNTL_B 0x1ff9
263#define TODC_TYPE_DS1643_CNTL_A 0x1ff8 /* control_a R/W regs */
264#define TODC_TYPE_DS1643_WATCHDOG 0x1fff
265#define TODC_TYPE_DS1643_INTERRUPTS 0x1fff
266#define TODC_TYPE_DS1643_ALARM_DATE 0x1fff
267#define TODC_TYPE_DS1643_ALARM_HOUR 0x1fff
268#define TODC_TYPE_DS1643_ALARM_MINUTES 0x1fff
269#define TODC_TYPE_DS1643_ALARM_SECONDS 0x1fff
270#define TODC_TYPE_DS1643_CENTURY 0x1ff8
271#define TODC_TYPE_DS1643_FLAGS 0x1fff
272#define TODC_TYPE_DS1643_NVRAM_ADDR_REG 0
273#define TODC_TYPE_DS1643_NVRAM_DATA_REG 0
274
275#define TODC_TYPE_DS1693_NVRAM_SIZE 0 /* Not handled yet */
276#define TODC_TYPE_DS1693_SW_FLAGS 0
277#define TODC_TYPE_DS1693_YEAR 0x09
278#define TODC_TYPE_DS1693_MONTH 0x08
279#define TODC_TYPE_DS1693_DOM 0x07 /* Day of Month */
280#define TODC_TYPE_DS1693_DOW 0x06 /* Day of Week */
281#define TODC_TYPE_DS1693_HOURS 0x04
282#define TODC_TYPE_DS1693_MINUTES 0x02
283#define TODC_TYPE_DS1693_SECONDS 0x00
284#define TODC_TYPE_DS1693_CNTL_B 0x0b
285#define TODC_TYPE_DS1693_CNTL_A 0x0a
286#define TODC_TYPE_DS1693_WATCHDOG 0xff
287#define TODC_TYPE_DS1693_INTERRUPTS 0xff
288#define TODC_TYPE_DS1693_ALARM_DATE 0x49
289#define TODC_TYPE_DS1693_ALARM_HOUR 0x05
290#define TODC_TYPE_DS1693_ALARM_MINUTES 0x03
291#define TODC_TYPE_DS1693_ALARM_SECONDS 0x01
292#define TODC_TYPE_DS1693_CENTURY 0x48
293#define TODC_TYPE_DS1693_FLAGS 0xff
294#define TODC_TYPE_DS1693_NVRAM_ADDR_REG 0
295#define TODC_TYPE_DS1693_NVRAM_DATA_REG 0
296
297#define TODC_TYPE_DS1743_NVRAM_SIZE 0x1ff8
298#define TODC_TYPE_DS1743_SW_FLAGS 0
299#define TODC_TYPE_DS1743_YEAR 0x1fff
300#define TODC_TYPE_DS1743_MONTH 0x1ffe
301#define TODC_TYPE_DS1743_DOM 0x1ffd /* Day of Month */
302#define TODC_TYPE_DS1743_DOW 0x1ffc /* Day of Week */
303#define TODC_TYPE_DS1743_HOURS 0x1ffb
304#define TODC_TYPE_DS1743_MINUTES 0x1ffa
305#define TODC_TYPE_DS1743_SECONDS 0x1ff9
306#define TODC_TYPE_DS1743_CNTL_B 0x1ff9
307#define TODC_TYPE_DS1743_CNTL_A 0x1ff8 /* control_a R/W regs */
308#define TODC_TYPE_DS1743_WATCHDOG 0x1fff
309#define TODC_TYPE_DS1743_INTERRUPTS 0x1fff
310#define TODC_TYPE_DS1743_ALARM_DATE 0x1fff
311#define TODC_TYPE_DS1743_ALARM_HOUR 0x1fff
312#define TODC_TYPE_DS1743_ALARM_MINUTES 0x1fff
313#define TODC_TYPE_DS1743_ALARM_SECONDS 0x1fff
314#define TODC_TYPE_DS1743_CENTURY 0x1ff8
315#define TODC_TYPE_DS1743_FLAGS 0x1fff
316#define TODC_TYPE_DS1743_NVRAM_ADDR_REG 0
317#define TODC_TYPE_DS1743_NVRAM_DATA_REG 0
318
319#define TODC_TYPE_DS1746_NVRAM_SIZE 0x1fff8
320#define TODC_TYPE_DS1746_SW_FLAGS 0
321#define TODC_TYPE_DS1746_YEAR 0x1ffff
322#define TODC_TYPE_DS1746_MONTH 0x1fffe
323#define TODC_TYPE_DS1746_DOM 0x1fffd /* Day of Month */
324#define TODC_TYPE_DS1746_DOW 0x1fffc /* Day of Week */
325#define TODC_TYPE_DS1746_HOURS 0x1fffb
326#define TODC_TYPE_DS1746_MINUTES 0x1fffa
327#define TODC_TYPE_DS1746_SECONDS 0x1fff9
328#define TODC_TYPE_DS1746_CNTL_B 0x1fff9
329#define TODC_TYPE_DS1746_CNTL_A 0x1fff8 /* control_a R/W regs */
330#define TODC_TYPE_DS1746_WATCHDOG 0x00000
331#define TODC_TYPE_DS1746_INTERRUPTS 0x00000
332#define TODC_TYPE_DS1746_ALARM_DATE 0x00000
333#define TODC_TYPE_DS1746_ALARM_HOUR 0x00000
334#define TODC_TYPE_DS1746_ALARM_MINUTES 0x00000
335#define TODC_TYPE_DS1746_ALARM_SECONDS 0x00000
336#define TODC_TYPE_DS1746_CENTURY 0x00000
337#define TODC_TYPE_DS1746_FLAGS 0x00000
338#define TODC_TYPE_DS1746_NVRAM_ADDR_REG 0
339#define TODC_TYPE_DS1746_NVRAM_DATA_REG 0
340
341#define TODC_TYPE_DS1747_NVRAM_SIZE 0x7fff8
342#define TODC_TYPE_DS1747_SW_FLAGS 0
343#define TODC_TYPE_DS1747_YEAR 0x7ffff
344#define TODC_TYPE_DS1747_MONTH 0x7fffe
345#define TODC_TYPE_DS1747_DOM 0x7fffd /* Day of Month */
346#define TODC_TYPE_DS1747_DOW 0x7fffc /* Day of Week */
347#define TODC_TYPE_DS1747_HOURS 0x7fffb
348#define TODC_TYPE_DS1747_MINUTES 0x7fffa
349#define TODC_TYPE_DS1747_SECONDS 0x7fff9
350#define TODC_TYPE_DS1747_CNTL_B 0x7fff9
351#define TODC_TYPE_DS1747_CNTL_A 0x7fff8 /* control_a R/W regs */
352#define TODC_TYPE_DS1747_WATCHDOG 0x00000
353#define TODC_TYPE_DS1747_INTERRUPTS 0x00000
354#define TODC_TYPE_DS1747_ALARM_DATE 0x00000
355#define TODC_TYPE_DS1747_ALARM_HOUR 0x00000
356#define TODC_TYPE_DS1747_ALARM_MINUTES 0x00000
357#define TODC_TYPE_DS1747_ALARM_SECONDS 0x00000
358#define TODC_TYPE_DS1747_CENTURY 0x00000
359#define TODC_TYPE_DS1747_FLAGS 0x00000
360#define TODC_TYPE_DS1747_NVRAM_ADDR_REG 0
361#define TODC_TYPE_DS1747_NVRAM_DATA_REG 0
362
363#define TODC_TYPE_DS17285_NVRAM_SIZE (0x1000-0x80) /* 4Kx8 NVRAM (minus RTC regs) */
364#define TODC_TYPE_DS17285_SW_FLAGS TODC_FLAG_2_LEVEL_NVRAM
365#define TODC_TYPE_DS17285_SECONDS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x00)
366#define TODC_TYPE_DS17285_ALARM_SECONDS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x01)
367#define TODC_TYPE_DS17285_MINUTES (TODC_TYPE_DS17285_NVRAM_SIZE + 0x02)
368#define TODC_TYPE_DS17285_ALARM_MINUTES (TODC_TYPE_DS17285_NVRAM_SIZE + 0x03)
369#define TODC_TYPE_DS17285_HOURS (TODC_TYPE_DS17285_NVRAM_SIZE + 0x04)
370#define TODC_TYPE_DS17285_ALARM_HOUR (TODC_TYPE_DS17285_NVRAM_SIZE + 0x05)
371#define TODC_TYPE_DS17285_DOW (TODC_TYPE_DS17285_NVRAM_SIZE + 0x06)
372#define TODC_TYPE_DS17285_DOM (TODC_TYPE_DS17285_NVRAM_SIZE + 0x07)
373#define TODC_TYPE_DS17285_MONTH (TODC_TYPE_DS17285_NVRAM_SIZE + 0x08)
374#define TODC_TYPE_DS17285_YEAR (TODC_TYPE_DS17285_NVRAM_SIZE + 0x09)
375#define TODC_TYPE_DS17285_CNTL_A (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0A)
376#define TODC_TYPE_DS17285_CNTL_B (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0B)
377#define TODC_TYPE_DS17285_CNTL_C (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0C)
378#define TODC_TYPE_DS17285_CNTL_D (TODC_TYPE_DS17285_NVRAM_SIZE + 0x0D)
379#define TODC_TYPE_DS17285_WATCHDOG 0
380#define TODC_TYPE_DS17285_INTERRUPTS 0
381#define TODC_TYPE_DS17285_ALARM_DATE 0
382#define TODC_TYPE_DS17285_CENTURY 0
383#define TODC_TYPE_DS17285_FLAGS 0
384#define TODC_TYPE_DS17285_NVRAM_ADDR_REG 0x50
385#define TODC_TYPE_DS17285_NVRAM_DATA_REG 0x53
386
387#define TODC_TYPE_MC146818_NVRAM_SIZE 0 /* XXXX */
388#define TODC_TYPE_MC146818_SW_FLAGS 0
389#define TODC_TYPE_MC146818_YEAR 0x09
390#define TODC_TYPE_MC146818_MONTH 0x08
391#define TODC_TYPE_MC146818_DOM 0x07 /* Day of Month */
392#define TODC_TYPE_MC146818_DOW 0x06 /* Day of Week */
393#define TODC_TYPE_MC146818_HOURS 0x04
394#define TODC_TYPE_MC146818_MINUTES 0x02
395#define TODC_TYPE_MC146818_SECONDS 0x00
396#define TODC_TYPE_MC146818_CNTL_B 0x0a
397#define TODC_TYPE_MC146818_CNTL_A 0x0b /* control_a R/W regs */
398#define TODC_TYPE_MC146818_WATCHDOG 0
399#define TODC_TYPE_MC146818_INTERRUPTS 0x0c
400#define TODC_TYPE_MC146818_ALARM_DATE 0xff
401#define TODC_TYPE_MC146818_ALARM_HOUR 0x05
402#define TODC_TYPE_MC146818_ALARM_MINUTES 0x03
403#define TODC_TYPE_MC146818_ALARM_SECONDS 0x01
404#define TODC_TYPE_MC146818_CENTURY 0xff
405#define TODC_TYPE_MC146818_FLAGS 0xff
406#define TODC_TYPE_MC146818_NVRAM_ADDR_REG 0
407#define TODC_TYPE_MC146818_NVRAM_DATA_REG 0
408
409#define TODC_TYPE_PC97307_NVRAM_SIZE 0 /* No NVRAM? */
410#define TODC_TYPE_PC97307_SW_FLAGS 0
411#define TODC_TYPE_PC97307_YEAR 0x09
412#define TODC_TYPE_PC97307_MONTH 0x08
413#define TODC_TYPE_PC97307_DOM 0x07 /* Day of Month */
414#define TODC_TYPE_PC97307_DOW 0x06 /* Day of Week */
415#define TODC_TYPE_PC97307_HOURS 0x04
416#define TODC_TYPE_PC97307_MINUTES 0x02
417#define TODC_TYPE_PC97307_SECONDS 0x00
418#define TODC_TYPE_PC97307_CNTL_B 0x0a
419#define TODC_TYPE_PC97307_CNTL_A 0x0b /* control_a R/W regs */
420#define TODC_TYPE_PC97307_WATCHDOG 0x0c
421#define TODC_TYPE_PC97307_INTERRUPTS 0x0d
422#define TODC_TYPE_PC97307_ALARM_DATE 0xff
423#define TODC_TYPE_PC97307_ALARM_HOUR 0x05
424#define TODC_TYPE_PC97307_ALARM_MINUTES 0x03
425#define TODC_TYPE_PC97307_ALARM_SECONDS 0x01
426#define TODC_TYPE_PC97307_CENTURY 0xff
427#define TODC_TYPE_PC97307_FLAGS 0xff
428#define TODC_TYPE_PC97307_NVRAM_ADDR_REG 0
429#define TODC_TYPE_PC97307_NVRAM_DATA_REG 0
430
431/*
432 * Define macros to allocate and init the todc_info_t table that will
433 * be used by the todc_time.c routines.
434 */
435#define TODC_ALLOC() \
436 static todc_info_t todc_info_alloc; \
437 todc_info_t *todc_info = &todc_info_alloc;
438
439#define TODC_INIT(clock_type, as0, as1, data, bits) { \
440 todc_info->rtc_type = clock_type; \
441 \
442 todc_info->nvram_as0 = (unsigned int)(as0); \
443 todc_info->nvram_as1 = (unsigned int)(as1); \
444 todc_info->nvram_data = (unsigned int)(data); \
445 \
446 todc_info->as0_bits = (bits); \
447 \
448 todc_info->nvram_size = clock_type ##_NVRAM_SIZE; \
449 todc_info->sw_flags = clock_type ##_SW_FLAGS; \
450 \
451 todc_info->year = clock_type ##_YEAR; \
452 todc_info->month = clock_type ##_MONTH; \
453 todc_info->day_of_month = clock_type ##_DOM; \
454 todc_info->day_of_week = clock_type ##_DOW; \
455 todc_info->hours = clock_type ##_HOURS; \
456 todc_info->minutes = clock_type ##_MINUTES; \
457 todc_info->seconds = clock_type ##_SECONDS; \
458 todc_info->control_b = clock_type ##_CNTL_B; \
459 todc_info->control_a = clock_type ##_CNTL_A; \
460 todc_info->watchdog = clock_type ##_WATCHDOG; \
461 todc_info->interrupts = clock_type ##_INTERRUPTS; \
462 todc_info->alarm_date = clock_type ##_ALARM_DATE; \
463 todc_info->alarm_hour = clock_type ##_ALARM_HOUR; \
464 todc_info->alarm_minutes = clock_type ##_ALARM_MINUTES; \
465 todc_info->alarm_seconds = clock_type ##_ALARM_SECONDS; \
466 todc_info->century = clock_type ##_CENTURY; \
467 todc_info->flags = clock_type ##_FLAGS; \
468 \
469 todc_info->nvram_addr_reg = clock_type ##_NVRAM_ADDR_REG; \
470 todc_info->nvram_data_reg = clock_type ##_NVRAM_DATA_REG; \
471}
472
473extern todc_info_t *todc_info;
474
475unsigned char todc_direct_read_val(int addr);
476void todc_direct_write_val(int addr, unsigned char val);
477unsigned char todc_m48txx_read_val(int addr);
478void todc_m48txx_write_val(int addr, unsigned char val);
479unsigned char todc_mc146818_read_val(int addr);
480void todc_mc146818_write_val(int addr, unsigned char val);
481
482long todc_time_init(void);
483void todc_get_rtc_time(struct rtc_time *);
484int todc_set_rtc_time(struct rtc_time *);
485void todc_calibrate_decr(void);
486
487#endif /* __PPC_KERNEL_TODC_H */
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index 9fe7894ee035..50c014007de7 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -32,7 +32,14 @@ static inline int node_to_first_cpu(int node)
32int of_node_to_nid(struct device_node *device); 32int of_node_to_nid(struct device_node *device);
33 33
34struct pci_bus; 34struct pci_bus;
35#ifdef CONFIG_PCI
35extern int pcibus_to_node(struct pci_bus *bus); 36extern int pcibus_to_node(struct pci_bus *bus);
37#else
38static inline int pcibus_to_node(struct pci_bus *bus)
39{
40 return -1;
41}
42#endif
36 43
37#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \ 44#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
38 CPU_MASK_ALL : \ 45 CPU_MASK_ALL : \
diff --git a/include/asm-powerpc/tsi108.h b/include/asm-powerpc/tsi108.h
index 2c702d35a7cf..4e95d153be84 100644
--- a/include/asm-powerpc/tsi108.h
+++ b/include/asm-powerpc/tsi108.h
@@ -98,12 +98,12 @@ typedef struct {
98extern u32 get_vir_csrbase(void); 98extern u32 get_vir_csrbase(void);
99extern u32 tsi108_csr_vir_base; 99extern u32 tsi108_csr_vir_base;
100 100
101extern inline u32 tsi108_read_reg(u32 reg_offset) 101static inline u32 tsi108_read_reg(u32 reg_offset)
102{ 102{
103 return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset)); 103 return in_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset));
104} 104}
105 105
106extern inline void tsi108_write_reg(u32 reg_offset, u32 val) 106static inline void tsi108_write_reg(u32 reg_offset, u32 val)
107{ 107{
108 out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val); 108 out_be32((volatile u32 *)(tsi108_csr_vir_base + reg_offset), val);
109} 109}
diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h
index d6fb56b80453..3b363757a2bb 100644
--- a/include/asm-powerpc/types.h
+++ b/include/asm-powerpc/types.h
@@ -97,16 +97,6 @@ typedef struct {
97 unsigned long env; 97 unsigned long env;
98} func_descr_t; 98} func_descr_t;
99 99
100#ifdef CONFIG_LBD
101typedef u64 sector_t;
102#define HAVE_SECTOR_T
103#endif
104
105#ifdef CONFIG_LSF
106typedef u64 blkcnt_t;
107#define HAVE_BLKCNT_T
108#endif
109
110#endif /* __ASSEMBLY__ */ 100#endif /* __ASSEMBLY__ */
111 101
112#endif /* __KERNEL__ */ 102#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/uaccess.h b/include/asm-powerpc/uaccess.h
index d83fc29c2bbf..adbf16b8cfbb 100644
--- a/include/asm-powerpc/uaccess.h
+++ b/include/asm-powerpc/uaccess.h
@@ -304,7 +304,7 @@ extern unsigned long __copy_tofrom_user(void __user *to,
304 304
305#ifndef __powerpc64__ 305#ifndef __powerpc64__
306 306
307extern inline unsigned long copy_from_user(void *to, 307static inline unsigned long copy_from_user(void *to,
308 const void __user *from, unsigned long n) 308 const void __user *from, unsigned long n)
309{ 309{
310 unsigned long over; 310 unsigned long over;
@@ -319,7 +319,7 @@ extern inline unsigned long copy_from_user(void *to,
319 return n; 319 return n;
320} 320}
321 321
322extern inline unsigned long copy_to_user(void __user *to, 322static inline unsigned long copy_to_user(void __user *to,
323 const void *from, unsigned long n) 323 const void *from, unsigned long n)
324{ 324{
325 unsigned long over; 325 unsigned long over;
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 0e4ea37f6466..04b6c17cc59b 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -446,7 +446,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6
446#include <linux/types.h> 446#include <linux/types.h>
447#include <linux/compiler.h> 447#include <linux/compiler.h>
448#include <linux/linkage.h> 448#include <linux/linkage.h>
449#include <asm/syscalls.h>
450 449
451#define __ARCH_WANT_IPC_PARSE_VERSION 450#define __ARCH_WANT_IPC_PARSE_VERSION
452#define __ARCH_WANT_OLD_READDIR 451#define __ARCH_WANT_OLD_READDIR
@@ -481,16 +480,9 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6
481 480
482/* 481/*
483 * "Conditional" syscalls 482 * "Conditional" syscalls
484 *
485 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
486 * but it doesn't work on all toolchains, so we just do it by hand
487 */ 483 */
488#ifdef CONFIG_PPC32 484#define cond_syscall(x) \
489#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") 485 asmlinkage long x (void) __attribute__((weak,alias("sys_ni_syscall")))
490#else
491#define cond_syscall(x) asm(".weak\t." #x "\n\t.set\t." #x ",.sys_ni_syscall")
492#endif
493
494 486
495#endif /* __ASSEMBLY__ */ 487#endif /* __ASSEMBLY__ */
496#endif /* __KERNEL__ */ 488#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/vio.h b/include/asm-powerpc/vio.h
index 4b51d42e1419..0117b544ecbc 100644
--- a/include/asm-powerpc/vio.h
+++ b/include/asm-powerpc/vio.h
@@ -45,7 +45,6 @@ struct iommu_table;
45 * The vio_dev structure is used to describe virtual I/O devices. 45 * The vio_dev structure is used to describe virtual I/O devices.
46 */ 46 */
47struct vio_dev { 47struct vio_dev {
48 struct iommu_table *iommu_table; /* vio_map_* uses this */
49 const char *name; 48 const char *name;
50 const char *type; 49 const char *type;
51 uint32_t unit_address; 50 uint32_t unit_address;
diff --git a/include/asm-powerpc/xmon.h b/include/asm-powerpc/xmon.h
index f1d337ed68d5..88320a05f0a8 100644
--- a/include/asm-powerpc/xmon.h
+++ b/include/asm-powerpc/xmon.h
@@ -14,8 +14,10 @@
14 14
15#ifdef CONFIG_XMON 15#ifdef CONFIG_XMON
16extern void xmon_setup(void); 16extern void xmon_setup(void);
17extern void xmon_register_spus(struct list_head *list);
17#else 18#else
18static inline void xmon_setup(void) { }; 19static inline void xmon_setup(void) { };
20static inline void xmon_register_spus(struct list_head *list) { };
19#endif 21#endif
20 22
21#endif /* __KERNEL __ */ 23#endif /* __KERNEL __ */
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index a4c411b753ef..ccf1a9bb2e43 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -26,17 +26,11 @@
26 26
27#if defined(CONFIG_4xx) 27#if defined(CONFIG_4xx)
28#include <asm/ibm4xx.h> 28#include <asm/ibm4xx.h>
29#elif defined(CONFIG_PPC_MPC52xx)
30#include <asm/mpc52xx.h>
31#elif defined(CONFIG_8xx) 29#elif defined(CONFIG_8xx)
32#include <asm/mpc8xx.h> 30#include <asm/mpc8xx.h>
33#elif defined(CONFIG_8260) 31#elif defined(CONFIG_8260)
34#include <asm/mpc8260.h> 32#include <asm/mpc8260.h>
35#elif defined(CONFIG_83xx) 33#elif defined(CONFIG_APUS) || !defined(CONFIG_PCI)
36#include <asm/mpc83xx.h>
37#elif defined(CONFIG_85xx)
38#include <asm/mpc85xx.h>
39#elif defined(CONFIG_APUS)
40#define _IO_BASE 0 34#define _IO_BASE 0
41#define _ISA_MEM_BASE 0 35#define _ISA_MEM_BASE 0
42#define PCI_DRAM_OFFSET 0 36#define PCI_DRAM_OFFSET 0
@@ -237,6 +231,14 @@ static inline void __raw_writel(__u32 b, volatile void __iomem *addr)
237#define insl(port, buf, nl) _insl_ns((port)+___IO_BASE, (buf), (nl)) 231#define insl(port, buf, nl) _insl_ns((port)+___IO_BASE, (buf), (nl))
238#define outsl(port, buf, nl) _outsl_ns((port)+___IO_BASE, (buf), (nl)) 232#define outsl(port, buf, nl) _outsl_ns((port)+___IO_BASE, (buf), (nl))
239 233
234#define readsb(a, b, n) _insb((a), (b), (n))
235#define readsw(a, b, n) _insw_ns((a), (b), (n))
236#define readsl(a, b, n) _insl_ns((a), (b), (n))
237#define writesb(a, b, n) _outsb((a),(b),(n))
238#define writesw(a, b, n) _outsw_ns((a),(b),(n))
239#define writesl(a, b, n) _outsl_ns((a),(b),(n))
240
241
240/* 242/*
241 * On powermacs and 8xx we will get a machine check exception 243 * On powermacs and 8xx we will get a machine check exception
242 * if we try to read data from a non-existent I/O port. Because 244 * if we try to read data from a non-existent I/O port. Because
@@ -327,12 +329,12 @@ __do_out_asm(outl, "stwbrx")
327#define inl_p(port) inl((port)) 329#define inl_p(port) inl((port))
328#define outl_p(val, port) outl((val), (port)) 330#define outl_p(val, port) outl((val), (port))
329 331
330extern void _insb(volatile u8 __iomem *port, void *buf, long count); 332extern void _insb(const volatile u8 __iomem *addr, void *buf, long count);
331extern void _outsb(volatile u8 __iomem *port, const void *buf, long count); 333extern void _outsb(volatile u8 __iomem *addr,const void *buf,long count);
332extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count); 334extern void _insw_ns(const volatile u16 __iomem *addr, void *buf, long count);
333extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count); 335extern void _outsw_ns(volatile u16 __iomem *addr, const void *buf, long count);
334extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count); 336extern void _insl_ns(const volatile u32 __iomem *addr, void *buf, long count);
335extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count); 337extern void _outsl_ns(volatile u32 __iomem *addr, const void *buf, long count);
336 338
337 339
338#define IO_SPACE_LIMIT ~0 340#define IO_SPACE_LIMIT ~0
diff --git a/include/asm-ppc/m48t35.h b/include/asm-ppc/m48t35.h
index f3c5e5dfa986..a5277ea4b194 100644
--- a/include/asm-ppc/m48t35.h
+++ b/include/asm-ppc/m48t35.h
@@ -39,7 +39,7 @@
39#define M48T35_RTC_WATCHDOG_RB 0x03 39#define M48T35_RTC_WATCHDOG_RB 0x03
40#define M48T35_RTC_WATCHDOG_BMB 0x7c 40#define M48T35_RTC_WATCHDOG_BMB 0x7c
41#define M48T35_RTC_WATCHDOG_WDS 0x80 41#define M48T35_RTC_WATCHDOG_WDS 0x80
42#define M48T35_RTC_WATCHDOG_ALL (M48T35_RTC_WATCHDOG_RB|M48T35_RTC_WATCHDOG_BMB|M48T35_RTC_W 42#define M48T35_RTC_WATCHDOG_ALL (M48T35_RTC_WATCHDOG_RB|M48T35_RTC_WATCHDOG_BMB|M48T35_RTC_W)
43 43
44#define M48T35_RTC_CONTROL_WRITE 0x80 44#define M48T35_RTC_CONTROL_WRITE 0x80
45#define M48T35_RTC_CONTROL_READ 0x40 45#define M48T35_RTC_CONTROL_READ 0x40
diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h
index 64c8874618dc..d9d21aa68ba3 100644
--- a/include/asm-ppc/mpc52xx.h
+++ b/include/asm-ppc/mpc52xx.h
@@ -29,17 +29,6 @@ struct pt_regs;
29#endif /* __ASSEMBLY__ */ 29#endif /* __ASSEMBLY__ */
30 30
31 31
32#ifdef CONFIG_PCI
33#define _IO_BASE isa_io_base
34#define _ISA_MEM_BASE isa_mem_base
35#define PCI_DRAM_OFFSET pci_dram_offset
36#else
37#define _IO_BASE 0
38#define _ISA_MEM_BASE 0
39#define PCI_DRAM_OFFSET 0
40#endif
41
42
43/* ======================================================================== */ 32/* ======================================================================== */
44/* PPC Sys devices definition */ 33/* PPC Sys devices definition */
45/* ======================================================================== */ 34/* ======================================================================== */
diff --git a/include/asm-ppc/mpc83xx.h b/include/asm-ppc/mpc83xx.h
index 02ed2c325714..c3061972309b 100644
--- a/include/asm-ppc/mpc83xx.h
+++ b/include/asm-ppc/mpc83xx.h
@@ -25,14 +25,6 @@
25#include <platforms/83xx/mpc834x_sys.h> 25#include <platforms/83xx/mpc834x_sys.h>
26#endif 26#endif
27 27
28#define _IO_BASE isa_io_base
29#define _ISA_MEM_BASE isa_mem_base
30#ifdef CONFIG_PCI
31#define PCI_DRAM_OFFSET pci_dram_offset
32#else
33#define PCI_DRAM_OFFSET 0
34#endif
35
36/* 28/*
37 * The "residual" board information structure the boot loader passes 29 * The "residual" board information structure the boot loader passes
38 * into the kernel. 30 * into the kernel.
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
index 9b4851199c76..d7e4a79d77fb 100644
--- a/include/asm-ppc/mpc85xx.h
+++ b/include/asm-ppc/mpc85xx.h
@@ -44,14 +44,6 @@
44#include <platforms/85xx/tqm85xx.h> 44#include <platforms/85xx/tqm85xx.h>
45#endif 45#endif
46 46
47#define _IO_BASE isa_io_base
48#define _ISA_MEM_BASE isa_mem_base
49#ifdef CONFIG_PCI
50#define PCI_DRAM_OFFSET pci_dram_offset
51#else
52#define PCI_DRAM_OFFSET 0
53#endif
54
55/* 47/*
56 * The "residual" board information structure the boot loader passes 48 * The "residual" board information structure the boot loader passes
57 * into the kernel. 49 * into the kernel.
diff --git a/include/asm-ppc/pci-bridge.h b/include/asm-ppc/pci-bridge.h
index 9d5230689b31..6c955d0c1ef0 100644
--- a/include/asm-ppc/pci-bridge.h
+++ b/include/asm-ppc/pci-bridge.h
@@ -43,6 +43,7 @@ struct pci_controller {
43 struct pci_controller *next; 43 struct pci_controller *next;
44 struct pci_bus *bus; 44 struct pci_bus *bus;
45 void *arch_data; 45 void *arch_data;
46 struct device *parent;
46 47
47 int first_busno; 48 int first_busno;
48 int last_busno; 49 int last_busno;
diff --git a/include/asm-s390/types.h b/include/asm-s390/types.h
index ae2951cc83ac..fc5d7cf19324 100644
--- a/include/asm-s390/types.h
+++ b/include/asm-s390/types.h
@@ -87,16 +87,6 @@ typedef union {
87 } subreg; 87 } subreg;
88} register_pair; 88} register_pair;
89 89
90#ifdef CONFIG_LBD
91typedef u64 sector_t;
92#define HAVE_SECTOR_T
93#endif
94
95#ifdef CONFIG_LSF
96typedef u64 blkcnt_t;
97#define HAVE_BLKCNT_T
98#endif
99
100#endif /* ! __s390x__ */ 90#endif /* ! __s390x__ */
101#endif /* __ASSEMBLY__ */ 91#endif /* __ASSEMBLY__ */
102#endif /* __KERNEL__ */ 92#endif /* __KERNEL__ */
diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h
index 8bdc1ba56f73..28305c3cbddf 100644
--- a/include/asm-sh/atomic.h
+++ b/include/asm-sh/atomic.h
@@ -28,11 +28,11 @@ static inline void atomic_add(int i, atomic_t *v)
28 unsigned long tmp; 28 unsigned long tmp;
29 29
30 __asm__ __volatile__ ( 30 __asm__ __volatile__ (
31"1: movli.l @%3, %0 ! atomic_add \n" 31"1: movli.l @%2, %0 ! atomic_add \n"
32" add %2, %0 \n" 32" add %1, %0 \n"
33" movco.l %0, @%3 \n" 33" movco.l %0, @%2 \n"
34" bf 1b \n" 34" bf 1b \n"
35 : "=&z" (tmp), "=r" (&v->counter) 35 : "=&z" (tmp)
36 : "r" (i), "r" (&v->counter) 36 : "r" (i), "r" (&v->counter)
37 : "t"); 37 : "t");
38#else 38#else
@@ -50,11 +50,11 @@ static inline void atomic_sub(int i, atomic_t *v)
50 unsigned long tmp; 50 unsigned long tmp;
51 51
52 __asm__ __volatile__ ( 52 __asm__ __volatile__ (
53"1: movli.l @%3, %0 ! atomic_sub \n" 53"1: movli.l @%2, %0 ! atomic_sub \n"
54" sub %2, %0 \n" 54" sub %1, %0 \n"
55" movco.l %0, @%3 \n" 55" movco.l %0, @%2 \n"
56" bf 1b \n" 56" bf 1b \n"
57 : "=&z" (tmp), "=r" (&v->counter) 57 : "=&z" (tmp)
58 : "r" (i), "r" (&v->counter) 58 : "r" (i), "r" (&v->counter)
59 : "t"); 59 : "t");
60#else 60#else
@@ -80,12 +80,12 @@ static inline int atomic_add_return(int i, atomic_t *v)
80 80
81#ifdef CONFIG_CPU_SH4A 81#ifdef CONFIG_CPU_SH4A
82 __asm__ __volatile__ ( 82 __asm__ __volatile__ (
83"1: movli.l @%3, %0 ! atomic_add_return \n" 83"1: movli.l @%2, %0 ! atomic_add_return \n"
84" add %2, %0 \n" 84" add %1, %0 \n"
85" movco.l %0, @%3 \n" 85" movco.l %0, @%2 \n"
86" bf 1b \n" 86" bf 1b \n"
87" synco \n" 87" synco \n"
88 : "=&z" (temp), "=r" (&v->counter) 88 : "=&z" (temp)
89 : "r" (i), "r" (&v->counter) 89 : "r" (i), "r" (&v->counter)
90 : "t"); 90 : "t");
91#else 91#else
@@ -109,12 +109,12 @@ static inline int atomic_sub_return(int i, atomic_t *v)
109 109
110#ifdef CONFIG_CPU_SH4A 110#ifdef CONFIG_CPU_SH4A
111 __asm__ __volatile__ ( 111 __asm__ __volatile__ (
112"1: movli.l @%3, %0 ! atomic_sub_return \n" 112"1: movli.l @%2, %0 ! atomic_sub_return \n"
113" sub %2, %0 \n" 113" sub %1, %0 \n"
114" movco.l %0, @%3 \n" 114" movco.l %0, @%2 \n"
115" bf 1b \n" 115" bf 1b \n"
116" synco \n" 116" synco \n"
117 : "=&z" (temp), "=r" (&v->counter) 117 : "=&z" (temp)
118 : "r" (i), "r" (&v->counter) 118 : "r" (i), "r" (&v->counter)
119 : "t"); 119 : "t");
120#else 120#else
@@ -186,11 +186,11 @@ static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
186 unsigned long tmp; 186 unsigned long tmp;
187 187
188 __asm__ __volatile__ ( 188 __asm__ __volatile__ (
189"1: movli.l @%3, %0 ! atomic_clear_mask \n" 189"1: movli.l @%2, %0 ! atomic_clear_mask \n"
190" and %2, %0 \n" 190" and %1, %0 \n"
191" movco.l %0, @%3 \n" 191" movco.l %0, @%2 \n"
192" bf 1b \n" 192" bf 1b \n"
193 : "=&z" (tmp), "=r" (&v->counter) 193 : "=&z" (tmp)
194 : "r" (~mask), "r" (&v->counter) 194 : "r" (~mask), "r" (&v->counter)
195 : "t"); 195 : "t");
196#else 196#else
@@ -208,11 +208,11 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
208 unsigned long tmp; 208 unsigned long tmp;
209 209
210 __asm__ __volatile__ ( 210 __asm__ __volatile__ (
211"1: movli.l @%3, %0 ! atomic_set_mask \n" 211"1: movli.l @%2, %0 ! atomic_set_mask \n"
212" or %2, %0 \n" 212" or %1, %0 \n"
213" movco.l %0, @%3 \n" 213" movco.l %0, @%2 \n"
214" bf 1b \n" 214" bf 1b \n"
215 : "=&z" (tmp), "=r" (&v->counter) 215 : "=&z" (tmp)
216 : "r" (mask), "r" (&v->counter) 216 : "r" (mask), "r" (&v->counter)
217 : "t"); 217 : "t");
218#else 218#else
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index beeea40f549e..795047da5e17 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -23,16 +23,20 @@ static void __init check_bugs(void)
23 cpu_data->loops_per_jiffy = loops_per_jiffy; 23 cpu_data->loops_per_jiffy = loops_per_jiffy;
24 24
25 switch (cpu_data->type) { 25 switch (cpu_data->type) {
26 case CPU_SH7604: 26 case CPU_SH7604 ... CPU_SH7619:
27 *p++ = '2'; 27 *p++ = '2';
28 break; 28 break;
29 case CPU_SH7206:
30 *p++ = '2';
31 *p++ = 'a';
32 break;
29 case CPU_SH7705 ... CPU_SH7300: 33 case CPU_SH7705 ... CPU_SH7300:
30 *p++ = '3'; 34 *p++ = '3';
31 break; 35 break;
32 case CPU_SH7750 ... CPU_SH4_501: 36 case CPU_SH7750 ... CPU_SH4_501:
33 *p++ = '4'; 37 *p++ = '4';
34 break; 38 break;
35 case CPU_SH7770 ... CPU_SH7781: 39 case CPU_SH7770 ... CPU_SH7785:
36 *p++ = '4'; 40 *p++ = '4';
37 *p++ = 'a'; 41 *p++ = 'a';
38 break; 42 break;
diff --git a/include/asm-sh/clock.h b/include/asm-sh/clock.h
index fdfb75b30f0d..1df92807f8c5 100644
--- a/include/asm-sh/clock.h
+++ b/include/asm-sh/clock.h
@@ -4,6 +4,7 @@
4#include <linux/kref.h> 4#include <linux/kref.h>
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/seq_file.h> 6#include <linux/seq_file.h>
7#include <linux/clk.h>
7 8
8struct clk; 9struct clk;
9 10
@@ -18,7 +19,7 @@ struct clk_ops {
18struct clk { 19struct clk {
19 struct list_head node; 20 struct list_head node;
20 const char *name; 21 const char *name;
21 22 int id;
22 struct module *owner; 23 struct module *owner;
23 24
24 struct clk *parent; 25 struct clk *parent;
@@ -40,22 +41,13 @@ void arch_init_clk_ops(struct clk_ops **, int type);
40int clk_init(void); 41int clk_init(void);
41 42
42int __clk_enable(struct clk *); 43int __clk_enable(struct clk *);
43int clk_enable(struct clk *);
44
45void __clk_disable(struct clk *); 44void __clk_disable(struct clk *);
46void clk_disable(struct clk *);
47 45
48int clk_set_rate(struct clk *, unsigned long rate);
49unsigned long clk_get_rate(struct clk *);
50void clk_recalc_rate(struct clk *); 46void clk_recalc_rate(struct clk *);
51 47
52struct clk *clk_get(const char *id);
53void clk_put(struct clk *);
54
55int clk_register(struct clk *); 48int clk_register(struct clk *);
56void clk_unregister(struct clk *); 49void clk_unregister(struct clk *);
57 50
58int show_clocks(struct seq_file *m); 51int show_clocks(struct seq_file *m);
59 52
60#endif /* __ASM_SH_CLOCK_H */ 53#endif /* __ASM_SH_CLOCK_H */
61
diff --git a/include/asm-sh/cpu-sh2/cache.h b/include/asm-sh/cpu-sh2/cache.h
index cd96402e8562..20b9796842dc 100644
--- a/include/asm-sh/cpu-sh2/cache.h
+++ b/include/asm-sh/cpu-sh2/cache.h
@@ -12,6 +12,7 @@
12 12
13#define L1_CACHE_SHIFT 4 13#define L1_CACHE_SHIFT 4
14 14
15#if defined(CONFIG_CPU_SUBTYPE_SH7604)
15#define CCR 0xfffffe92 /* Address of Cache Control Register */ 16#define CCR 0xfffffe92 /* Address of Cache Control Register */
16 17
17#define CCR_CACHE_CE 0x01 /* Cache enable */ 18#define CCR_CACHE_CE 0x01 /* Cache enable */
@@ -27,5 +28,26 @@
27#define CCR_CACHE_ORA CCR_CACHE_TW 28#define CCR_CACHE_ORA CCR_CACHE_TW
28#define CCR_CACHE_WT 0x00 /* SH-2 is _always_ write-through */ 29#define CCR_CACHE_WT 0x00 /* SH-2 is _always_ write-through */
29 30
31#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
32#define CCR1 0xffffffec
33#define CCR CCR1
34
35#define CCR_CACHE_CE 0x01 /* Cache enable */
36#define CCR_CACHE_WT 0x06 /* CCR[bit1=1,bit2=1] */
37 /* 0x00000000-0x7fffffff: Write-through */
38 /* 0x80000000-0x9fffffff: Write-back */
39 /* 0xc0000000-0xdfffffff: Write-through */
40#define CCR_CACHE_CB 0x00 /* CCR[bit1=0,bit2=0] */
41 /* 0x00000000-0x7fffffff: Write-back */
42 /* 0x80000000-0x9fffffff: Write-through */
43 /* 0xc0000000-0xdfffffff: Write-back */
44#define CCR_CACHE_CF 0x08 /* Cache invalidate */
45
46#define CACHE_OC_ADDRESS_ARRAY 0xf0000000
47#define CACHE_OC_DATA_ARRAY 0xf1000000
48
49#define CCR_CACHE_ENABLE CCR_CACHE_CE
50#define CCR_CACHE_INVALIDATE CCR_CACHE_CF
51#endif
30#endif /* __ASM_CPU_SH2_CACHE_H */ 52#endif /* __ASM_CPU_SH2_CACHE_H */
31 53
diff --git a/include/asm-sh/cpu-sh2/freq.h b/include/asm-sh/cpu-sh2/freq.h
new file mode 100644
index 000000000000..31de475da70b
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/freq.h
@@ -0,0 +1,18 @@
1/*
2 * include/asm-sh/cpu-sh2/freq.h
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2_FREQ_H
11#define __ASM_CPU_SH2_FREQ_H
12
13#if defined(CONFIG_CPU_SUBTYPE_SH7619)
14#define FREQCR 0xf815ff80
15#endif
16
17#endif /* __ASM_CPU_SH2_FREQ_H */
18
diff --git a/include/asm-sh/cpu-sh2/mmu_context.h b/include/asm-sh/cpu-sh2/mmu_context.h
new file mode 100644
index 000000000000..beeb299e01ec
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/mmu_context.h
@@ -0,0 +1,16 @@
1/*
2 * include/asm-sh/cpu-sh2/mmu_context.h
3 *
4 * Copyright (C) 2003 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2_MMU_CONTEXT_H
11#define __ASM_CPU_SH2_MMU_CONTEXT_H
12
13/* No MMU */
14
15#endif /* __ASM_CPU_SH2_MMU_CONTEXT_H */
16
diff --git a/include/asm-sh/cpu-sh2/timer.h b/include/asm-sh/cpu-sh2/timer.h
new file mode 100644
index 000000000000..a39c241e8195
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/timer.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_CPU_SH2_TIMER_H
2#define __ASM_CPU_SH2_TIMER_H
3
4/* Nothing needed yet */
5
6#endif /* __ASM_CPU_SH2_TIMER_H */
diff --git a/include/asm-sh/cpu-sh2a/addrspace.h b/include/asm-sh/cpu-sh2a/addrspace.h
new file mode 100644
index 000000000000..3d2e9aa21522
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/addrspace.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/addrspace.h>
diff --git a/include/asm-sh/cpu-sh2a/cache.h b/include/asm-sh/cpu-sh2a/cache.h
new file mode 100644
index 000000000000..3e4b9e480982
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/cache.h
@@ -0,0 +1,39 @@
1/*
2 * include/asm-sh/cpu-sh2a/cache.h
3 *
4 * Copyright (C) 2004 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2A_CACHE_H
11#define __ASM_CPU_SH2A_CACHE_H
12
13#define L1_CACHE_SHIFT 4
14
15#define CCR1 0xfffc1000
16#define CCR2 0xfffc1004
17
18/* CCR1 behaves more like the traditional CCR */
19#define CCR CCR1
20
21/*
22 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not
23 * listed here are reserved.
24 */
25#define CCR_CACHE_CB 0x0000 /* Hack */
26#define CCR_CACHE_OCE 0x0001
27#define CCR_CACHE_WT 0x0002
28#define CCR_CACHE_OCI 0x0008 /* OCF */
29#define CCR_CACHE_ICE 0x0100
30#define CCR_CACHE_ICI 0x0800 /* ICF */
31
32#define CACHE_IC_ADDRESS_ARRAY 0xf0000000
33#define CACHE_OC_ADDRESS_ARRAY 0xf0800000
34
35#define CCR_CACHE_ENABLE (CCR_CACHE_OCE | CCR_CACHE_ICE)
36#define CCR_CACHE_INVALIDATE (CCR_CACHE_OCI | CCR_CACHE_ICI)
37
38#endif /* __ASM_CPU_SH2A_CACHE_H */
39
diff --git a/include/asm-sh/cpu-sh2a/cacheflush.h b/include/asm-sh/cpu-sh2a/cacheflush.h
new file mode 100644
index 000000000000..fa3186c73350
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/cacheflush.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/cacheflush.h>
diff --git a/include/asm-sh/cpu-sh2a/dma.h b/include/asm-sh/cpu-sh2a/dma.h
new file mode 100644
index 000000000000..0d5ad85c1de8
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/dma.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/dma.h>
diff --git a/include/asm-sh/cpu-sh2a/freq.h b/include/asm-sh/cpu-sh2a/freq.h
new file mode 100644
index 000000000000..e518fff6d10f
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/freq.h
@@ -0,0 +1,18 @@
1/*
2 * include/asm-sh/cpu-sh2a/freq.h
3 *
4 * Copyright (C) 2006 Yoshinori Sato
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#ifndef __ASM_CPU_SH2A_FREQ_H
11#define __ASM_CPU_SH2A_FREQ_H
12
13#if defined(CONFIG_CPU_SUBTYPE_SH7206)
14#define FREQCR 0xfffe0010
15#endif
16
17#endif /* __ASM_CPU_SH2A_FREQ_H */
18
diff --git a/include/asm-sh/cpu-sh2a/mmu_context.h b/include/asm-sh/cpu-sh2a/mmu_context.h
new file mode 100644
index 000000000000..cd2387f7db9e
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/mmu_context.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/mmu_context.h>
diff --git a/include/asm-sh/cpu-sh2a/timer.h b/include/asm-sh/cpu-sh2a/timer.h
new file mode 100644
index 000000000000..fee504adf11e
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/timer.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/timer.h>
diff --git a/include/asm-sh/cpu-sh2a/ubc.h b/include/asm-sh/cpu-sh2a/ubc.h
new file mode 100644
index 000000000000..cf28062b96a2
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/ubc.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/ubc.h>
diff --git a/include/asm-sh/cpu-sh2a/watchdog.h b/include/asm-sh/cpu-sh2a/watchdog.h
new file mode 100644
index 000000000000..c1b3e2488478
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/watchdog.h
@@ -0,0 +1 @@
#include <asm/cpu-sh2/watchdog.h>
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index d9daa028689f..faf3051cd429 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -14,9 +14,7 @@
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/wait.h> 15#include <linux/wait.h>
16#include <linux/sysdev.h> 16#include <linux/sysdev.h>
17#include <linux/device.h>
18#include <asm/cpu/dma.h> 17#include <asm/cpu/dma.h>
19#include <asm/semaphore.h>
20 18
21/* The maximum address that we can perform a DMA transfer to on this platform */ 19/* The maximum address that we can perform a DMA transfer to on this platform */
22/* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any 20/* Don't define MAX_DMA_ADDRESS; it's useless on the SuperH and any
@@ -46,16 +44,21 @@
46 * DMAC (dma_info) flags 44 * DMAC (dma_info) flags
47 */ 45 */
48enum { 46enum {
49 DMAC_CHANNELS_CONFIGURED = 0x00, 47 DMAC_CHANNELS_CONFIGURED = 0x01,
50 DMAC_CHANNELS_TEI_CAPABLE = 0x01, 48 DMAC_CHANNELS_TEI_CAPABLE = 0x02, /* Transfer end interrupt */
51}; 49};
52 50
53/* 51/*
54 * DMA channel capabilities / flags 52 * DMA channel capabilities / flags
55 */ 53 */
56enum { 54enum {
57 DMA_TEI_CAPABLE = 0x01, 55 DMA_CONFIGURED = 0x01,
58 DMA_CONFIGURED = 0x02, 56
57 /*
58 * Transfer end interrupt, inherited from DMAC.
59 * wait_queue used in dma_wait_for_completion.
60 */
61 DMA_TEI_CAPABLE = 0x02,
59}; 62};
60 63
61extern spinlock_t dma_spin_lock; 64extern spinlock_t dma_spin_lock;
@@ -68,28 +71,31 @@ struct dma_ops {
68 71
69 int (*get_residue)(struct dma_channel *chan); 72 int (*get_residue)(struct dma_channel *chan);
70 int (*xfer)(struct dma_channel *chan); 73 int (*xfer)(struct dma_channel *chan);
71 void (*configure)(struct dma_channel *chan, unsigned long flags); 74 int (*configure)(struct dma_channel *chan, unsigned long flags);
75 int (*extend)(struct dma_channel *chan, unsigned long op, void *param);
72}; 76};
73 77
74struct dma_channel { 78struct dma_channel {
75 char dev_id[16]; 79 char dev_id[16]; /* unique name per DMAC of channel */
76 80
77 unsigned int chan; /* Physical channel number */ 81 unsigned int chan; /* DMAC channel number */
78 unsigned int vchan; /* Virtual channel number */ 82 unsigned int vchan; /* Virtual channel number */
83
79 unsigned int mode; 84 unsigned int mode;
80 unsigned int count; 85 unsigned int count;
81 86
82 unsigned long sar; 87 unsigned long sar;
83 unsigned long dar; 88 unsigned long dar;
84 89
90 const char **caps;
91
85 unsigned long flags; 92 unsigned long flags;
86 atomic_t busy; 93 atomic_t busy;
87 94
88 struct semaphore sem;
89 wait_queue_head_t wait_queue; 95 wait_queue_head_t wait_queue;
90 96
91 struct sys_device dev; 97 struct sys_device dev;
92 char *name; 98 void *priv_data;
93}; 99};
94 100
95struct dma_info { 101struct dma_info {
@@ -103,6 +109,12 @@ struct dma_info {
103 struct dma_channel *channels; 109 struct dma_channel *channels;
104 110
105 struct list_head list; 111 struct list_head list;
112 int first_channel_nr;
113};
114
115struct dma_chan_caps {
116 int ch_num;
117 const char **caplist;
106}; 118};
107 119
108#define to_dma_channel(channel) container_of(channel, struct dma_channel, dev) 120#define to_dma_channel(channel) container_of(channel, struct dma_channel, dev)
@@ -121,6 +133,8 @@ extern int dma_xfer(unsigned int chan, unsigned long from,
121#define dma_read_page(chan, from, to) \ 133#define dma_read_page(chan, from, to) \
122 dma_read(chan, from, to, PAGE_SIZE) 134 dma_read(chan, from, to, PAGE_SIZE)
123 135
136extern int request_dma_bycap(const char **dmac, const char **caps,
137 const char *dev_id);
124extern int request_dma(unsigned int chan, const char *dev_id); 138extern int request_dma(unsigned int chan, const char *dev_id);
125extern void free_dma(unsigned int chan); 139extern void free_dma(unsigned int chan);
126extern int get_dma_residue(unsigned int chan); 140extern int get_dma_residue(unsigned int chan);
@@ -131,6 +145,10 @@ extern void dma_configure_channel(unsigned int chan, unsigned long flags);
131 145
132extern int register_dmac(struct dma_info *info); 146extern int register_dmac(struct dma_info *info);
133extern void unregister_dmac(struct dma_info *info); 147extern void unregister_dmac(struct dma_info *info);
148extern struct dma_info *get_dma_info_by_name(const char *dmac_name);
149
150extern int dma_extend(unsigned int chan, unsigned long op, void *param);
151extern int register_chan_caps(const char *dmac, struct dma_chan_caps *capslist);
134 152
135#ifdef CONFIG_SYSFS 153#ifdef CONFIG_SYSFS
136/* arch/sh/drivers/dma/dma-sysfs.c */ 154/* arch/sh/drivers/dma/dma-sysfs.c */
diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h
index fc050fd7645e..43ca244564b1 100644
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -74,7 +74,7 @@ typedef struct user_fpu_struct elf_fpregset_t;
74#define ELF_ARCH EM_SH 74#define ELF_ARCH EM_SH
75 75
76#define USE_ELF_CORE_DUMP 76#define USE_ELF_CORE_DUMP
77#define ELF_EXEC_PAGESIZE 4096 77#define ELF_EXEC_PAGESIZE PAGE_SIZE
78 78
79/* This is the location that an ET_DYN program is loaded if exec'ed. Typical 79/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
80 use of this is to invoke "./ld.so someprog" to test out a new version of 80 use of this is to invoke "./ld.so someprog" to test out a new version of
diff --git a/include/asm-sh/entry-macros.S b/include/asm-sh/entry-macros.S
new file mode 100644
index 000000000000..500030eae7aa
--- /dev/null
+++ b/include/asm-sh/entry-macros.S
@@ -0,0 +1,33 @@
1! entry.S macro define
2
3 .macro cli
4 stc sr, r0
5 or #0xf0, r0
6 ldc r0, sr
7 .endm
8
9 .macro sti
10 mov #0xf0, r11
11 extu.b r11, r11
12 not r11, r11
13 stc sr, r10
14 and r11, r10
15#ifdef CONFIG_HAS_SR_RB
16 stc k_g_imask, r11
17 or r11, r10
18#endif
19 ldc r10, sr
20 .endm
21
22 .macro get_current_thread_info, ti, tmp
23#ifdef CONFIG_HAS_SR_RB
24 stc r7_bank, \ti
25#else
26 mov #((THREAD_SIZE - 1) >> 10) ^ 0xff, \tmp
27 shll8 \tmp
28 shll2 \tmp
29 mov r15, \ti
30 and \tmp, \ti
31#endif
32 .endm
33
diff --git a/include/asm-sh/irq-sh73180.h b/include/asm-sh/irq-sh73180.h
deleted file mode 100644
index b28af9a69d72..000000000000
--- a/include/asm-sh/irq-sh73180.h
+++ /dev/null
@@ -1,314 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH73180_H
2#define __ASM_SH_IRQ_SH73180_H
3
4/*
5 * linux/include/asm-sh/irq-sh73180.h
6 *
7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
8 */
9
10#undef INTC_IPRA
11#undef INTC_IPRB
12#undef INTC_IPRC
13#undef INTC_IPRD
14
15#undef DMTE0_IRQ
16#undef DMTE1_IRQ
17#undef DMTE2_IRQ
18#undef DMTE3_IRQ
19#undef DMTE4_IRQ
20#undef DMTE5_IRQ
21#undef DMTE6_IRQ
22#undef DMTE7_IRQ
23#undef DMAE_IRQ
24#undef DMA_IPR_ADDR
25#undef DMA_IPR_POS
26#undef DMA_PRIORITY
27
28#undef INTC_IMCR0
29#undef INTC_IMCR1
30#undef INTC_IMCR2
31#undef INTC_IMCR3
32#undef INTC_IMCR4
33#undef INTC_IMCR5
34#undef INTC_IMCR6
35#undef INTC_IMCR7
36#undef INTC_IMCR8
37#undef INTC_IMCR9
38#undef INTC_IMCR10
39
40
41#define INTC_IPRA 0xA4080000UL
42#define INTC_IPRB 0xA4080004UL
43#define INTC_IPRC 0xA4080008UL
44#define INTC_IPRD 0xA408000CUL
45#define INTC_IPRE 0xA4080010UL
46#define INTC_IPRF 0xA4080014UL
47#define INTC_IPRG 0xA4080018UL
48#define INTC_IPRH 0xA408001CUL
49#define INTC_IPRI 0xA4080020UL
50#define INTC_IPRJ 0xA4080024UL
51#define INTC_IPRK 0xA4080028UL
52
53#define INTC_IMR0 0xA4080080UL
54#define INTC_IMR1 0xA4080084UL
55#define INTC_IMR2 0xA4080088UL
56#define INTC_IMR3 0xA408008CUL
57#define INTC_IMR4 0xA4080090UL
58#define INTC_IMR5 0xA4080094UL
59#define INTC_IMR6 0xA4080098UL
60#define INTC_IMR7 0xA408009CUL
61#define INTC_IMR8 0xA40800A0UL
62#define INTC_IMR9 0xA40800A4UL
63#define INTC_IMR10 0xA40800A8UL
64#define INTC_IMR11 0xA40800ACUL
65
66#define INTC_IMCR0 0xA40800C0UL
67#define INTC_IMCR1 0xA40800C4UL
68#define INTC_IMCR2 0xA40800C8UL
69#define INTC_IMCR3 0xA40800CCUL
70#define INTC_IMCR4 0xA40800D0UL
71#define INTC_IMCR5 0xA40800D4UL
72#define INTC_IMCR6 0xA40800D8UL
73#define INTC_IMCR7 0xA40800DCUL
74#define INTC_IMCR8 0xA40800E0UL
75#define INTC_IMCR9 0xA40800E4UL
76#define INTC_IMCR10 0xA40800E8UL
77#define INTC_IMCR11 0xA40800ECUL
78
79#define INTC_ICR0 0xA4140000UL
80#define INTC_ICR1 0xA414001CUL
81
82#define INTMSK0 0xa4140044
83#define INTMSKCLR0 0xa4140064
84#define INTC_INTPRI0 0xa4140010
85
86/*
87 NOTE:
88
89 *_IRQ = (INTEVT2 - 0x200)/0x20
90*/
91
92/* TMU0 */
93#define TMU0_IRQ 16
94#define TMU0_IPR_ADDR INTC_IPRA
95#define TMU0_IPR_POS 3
96#define TMU0_PRIORITY 2
97
98#define TIMER_IRQ 16
99#define TIMER_IPR_ADDR INTC_IPRA
100#define TIMER_IPR_POS 3
101#define TIMER_PRIORITY 2
102
103/* TMU1 */
104#define TMU1_IRQ 17
105#define TMU1_IPR_ADDR INTC_IPRA
106#define TMU1_IPR_POS 2
107#define TMU1_PRIORITY 2
108
109/* TMU2 */
110#define TMU2_IRQ 18
111#define TMU2_IPR_ADDR INTC_IPRA
112#define TMU2_IPR_POS 1
113#define TMU2_PRIORITY 2
114
115/* LCDC */
116#define LCDC_IRQ 28
117#define LCDC_IPR_ADDR INTC_IPRB
118#define LCDC_IPR_POS 2
119#define LCDC_PRIORITY 2
120
121/* VIO (Video I/O) */
122#define CEU_IRQ 52
123#define BEU_IRQ 53
124#define VEU_IRQ 54
125#define VOU_IRQ 55
126#define VIO_IPR_ADDR INTC_IPRE
127#define VIO_IPR_POS 2
128#define VIO_PRIORITY 2
129
130/* MFI (Multi Functional Interface) */
131#define MFI_IRQ 56
132#define MFI_IPR_ADDR INTC_IPRE
133#define MFI_IPR_POS 1
134#define MFI_PRIORITY 2
135
136/* VPU (Video Processing Unit) */
137#define VPU_IRQ 60
138#define VPU_IPR_ADDR INTC_IPRE
139#define VPU_IPR_POS 0
140#define VPU_PRIORITY 2
141
142/* 3DG */
143#define TDG_IRQ 63
144#define TDG_IPR_ADDR INTC_IPRJ
145#define TDG_IPR_POS 2
146#define TDG_PRIORITY 2
147
148/* DMAC(1) */
149#define DMTE0_IRQ 48
150#define DMTE1_IRQ 49
151#define DMTE2_IRQ 50
152#define DMTE3_IRQ 51
153#define DMA1_IPR_ADDR INTC_IPRE
154#define DMA1_IPR_POS 3
155#define DMA1_PRIORITY 7
156
157/* DMAC(2) */
158#define DMTE4_IRQ 76
159#define DMTE5_IRQ 77
160#define DMA2_IPR_ADDR INTC_IPRF
161#define DMA2_IPR_POS 2
162#define DMA2_PRIORITY 7
163
164/* SCIF0 */
165#define SCIF_ERI_IRQ 80
166#define SCIF_RXI_IRQ 81
167#define SCIF_BRI_IRQ 82
168#define SCIF_TXI_IRQ 83
169#define SCIF_IPR_ADDR INTC_IPRG
170#define SCIF_IPR_POS 3
171#define SCIF_PRIORITY 3
172
173/* SIOF0 */
174#define SIOF0_IRQ 84
175#define SIOF0_IPR_ADDR INTC_IPRH
176#define SIOF0_IPR_POS 3
177#define SIOF0_PRIORITY 3
178
179/* FLCTL (Flash Memory Controller) */
180#define FLSTE_IRQ 92
181#define FLTEND_IRQ 93
182#define FLTRQ0_IRQ 94
183#define FLTRQ1_IRQ 95
184#define FLCTL_IPR_ADDR INTC_IPRH
185#define FLCTL_IPR_POS 1
186#define FLCTL_PRIORITY 3
187
188/* IIC(0) (IIC Bus Interface) */
189#define IIC0_ALI_IRQ 96
190#define IIC0_TACKI_IRQ 97
191#define IIC0_WAITI_IRQ 98
192#define IIC0_DTEI_IRQ 99
193#define IIC0_IPR_ADDR INTC_IPRH
194#define IIC0_IPR_POS 0
195#define IIC0_PRIORITY 3
196
197/* IIC(1) (IIC Bus Interface) */
198#define IIC1_ALI_IRQ 44
199#define IIC1_TACKI_IRQ 45
200#define IIC1_WAITI_IRQ 46
201#define IIC1_DTEI_IRQ 47
202#define IIC1_IPR_ADDR INTC_IPRG
203#define IIC1_IPR_POS 0
204#define IIC1_PRIORITY 3
205
206/* SIO0 */
207#define SIO0_IRQ 88
208#define SIO0_IPR_ADDR INTC_IPRI
209#define SIO0_IPR_POS 3
210#define SIO0_PRIORITY 3
211
212/* SDHI */
213#define SDHI_SDHII0_IRQ 100
214#define SDHI_SDHII1_IRQ 101
215#define SDHI_SDHII2_IRQ 102
216#define SDHI_SDHII3_IRQ 103
217#define SDHI_IPR_ADDR INTC_IPRK
218#define SDHI_IPR_POS 0
219#define SDHI_PRIORITY 3
220
221/* SIU (Sound Interface Unit) */
222#define SIU_IRQ 108
223#define SIU_IPR_ADDR INTC_IPRJ
224#define SIU_IPR_POS 1
225#define SIU_PRIORITY 3
226
227#define PORT_PACR 0xA4050100UL
228#define PORT_PBCR 0xA4050102UL
229#define PORT_PCCR 0xA4050104UL
230#define PORT_PDCR 0xA4050106UL
231#define PORT_PECR 0xA4050108UL
232#define PORT_PFCR 0xA405010AUL
233#define PORT_PGCR 0xA405010CUL
234#define PORT_PHCR 0xA405010EUL
235#define PORT_PJCR 0xA4050110UL
236#define PORT_PKCR 0xA4050112UL
237#define PORT_PLCR 0xA4050114UL
238#define PORT_SCPCR 0xA4050116UL
239#define PORT_PMCR 0xA4050118UL
240#define PORT_PNCR 0xA405011AUL
241#define PORT_PQCR 0xA405011CUL
242#define PORT_PRCR 0xA405011EUL
243#define PORT_PTCR 0xA405014CUL
244#define PORT_PUCR 0xA405014EUL
245#define PORT_PVCR 0xA4050150UL
246
247#define PORT_PSELA 0xA4050140UL
248#define PORT_PSELB 0xA4050142UL
249#define PORT_PSELC 0xA4050144UL
250#define PORT_PSELE 0xA4050158UL
251
252#define PORT_HIZCRA 0xA4050146UL
253#define PORT_HIZCRB 0xA4050148UL
254#define PORT_DRVCR 0xA405014AUL
255
256#define PORT_PADR 0xA4050120UL
257#define PORT_PBDR 0xA4050122UL
258#define PORT_PCDR 0xA4050124UL
259#define PORT_PDDR 0xA4050126UL
260#define PORT_PEDR 0xA4050128UL
261#define PORT_PFDR 0xA405012AUL
262#define PORT_PGDR 0xA405012CUL
263#define PORT_PHDR 0xA405012EUL
264#define PORT_PJDR 0xA4050130UL
265#define PORT_PKDR 0xA4050132UL
266#define PORT_PLDR 0xA4050134UL
267#define PORT_SCPDR 0xA4050136UL
268#define PORT_PMDR 0xA4050138UL
269#define PORT_PNDR 0xA405013AUL
270#define PORT_PQDR 0xA405013CUL
271#define PORT_PRDR 0xA405013EUL
272#define PORT_PTDR 0xA405016CUL
273#define PORT_PUDR 0xA405016EUL
274#define PORT_PVDR 0xA4050170UL
275
276#define IRQ0_IRQ 32
277#define IRQ1_IRQ 33
278#define IRQ2_IRQ 34
279#define IRQ3_IRQ 35
280#define IRQ4_IRQ 36
281#define IRQ5_IRQ 37
282#define IRQ6_IRQ 38
283#define IRQ7_IRQ 39
284
285#define INTPRI00 0xA4140010UL
286
287#define IRQ0_IPR_ADDR INTPRI00
288#define IRQ1_IPR_ADDR INTPRI00
289#define IRQ2_IPR_ADDR INTPRI00
290#define IRQ3_IPR_ADDR INTPRI00
291#define IRQ4_IPR_ADDR INTPRI00
292#define IRQ5_IPR_ADDR INTPRI00
293#define IRQ6_IPR_ADDR INTPRI00
294#define IRQ7_IPR_ADDR INTPRI00
295
296#define IRQ0_IPR_POS 7
297#define IRQ1_IPR_POS 6
298#define IRQ2_IPR_POS 5
299#define IRQ3_IPR_POS 4
300#define IRQ4_IPR_POS 3
301#define IRQ5_IPR_POS 2
302#define IRQ6_IPR_POS 1
303#define IRQ7_IPR_POS 0
304
305#define IRQ0_PRIORITY 1
306#define IRQ1_PRIORITY 1
307#define IRQ2_PRIORITY 1
308#define IRQ3_PRIORITY 1
309#define IRQ4_PRIORITY 1
310#define IRQ5_PRIORITY 1
311#define IRQ6_PRIORITY 1
312#define IRQ7_PRIORITY 1
313
314#endif /* __ASM_SH_IRQ_SH73180_H */
diff --git a/include/asm-sh/irq-sh7343.h b/include/asm-sh/irq-sh7343.h
deleted file mode 100644
index 5d15419b53b0..000000000000
--- a/include/asm-sh/irq-sh7343.h
+++ /dev/null
@@ -1,317 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH7343_H
2#define __ASM_SH_IRQ_SH7343_H
3
4/*
5 * linux/include/asm-sh/irq-sh7343.h
6 *
7 * Copyright (C) 2006 Kenati Technologies Inc.
8 * Andre Mccurdy <andre@kenati.com>
9 * Ranjit Deshpande <ranjit@kenati.com>
10 */
11
12#undef INTC_IPRA
13#undef INTC_IPRB
14#undef INTC_IPRC
15#undef INTC_IPRD
16
17#undef DMTE0_IRQ
18#undef DMTE1_IRQ
19#undef DMTE2_IRQ
20#undef DMTE3_IRQ
21#undef DMTE4_IRQ
22#undef DMTE5_IRQ
23#undef DMTE6_IRQ
24#undef DMTE7_IRQ
25#undef DMAE_IRQ
26#undef DMA_IPR_ADDR
27#undef DMA_IPR_POS
28#undef DMA_PRIORITY
29
30#undef INTC_IMCR0
31#undef INTC_IMCR1
32#undef INTC_IMCR2
33#undef INTC_IMCR3
34#undef INTC_IMCR4
35#undef INTC_IMCR5
36#undef INTC_IMCR6
37#undef INTC_IMCR7
38#undef INTC_IMCR8
39#undef INTC_IMCR9
40#undef INTC_IMCR10
41
42
43#define INTC_IPRA 0xA4080000UL
44#define INTC_IPRB 0xA4080004UL
45#define INTC_IPRC 0xA4080008UL
46#define INTC_IPRD 0xA408000CUL
47#define INTC_IPRE 0xA4080010UL
48#define INTC_IPRF 0xA4080014UL
49#define INTC_IPRG 0xA4080018UL
50#define INTC_IPRH 0xA408001CUL
51#define INTC_IPRI 0xA4080020UL
52#define INTC_IPRJ 0xA4080024UL
53#define INTC_IPRK 0xA4080028UL
54#define INTC_IPRL 0xA408002CUL
55
56#define INTC_IMR0 0xA4080080UL
57#define INTC_IMR1 0xA4080084UL
58#define INTC_IMR2 0xA4080088UL
59#define INTC_IMR3 0xA408008CUL
60#define INTC_IMR4 0xA4080090UL
61#define INTC_IMR5 0xA4080094UL
62#define INTC_IMR6 0xA4080098UL
63#define INTC_IMR7 0xA408009CUL
64#define INTC_IMR8 0xA40800A0UL
65#define INTC_IMR9 0xA40800A4UL
66#define INTC_IMR10 0xA40800A8UL
67#define INTC_IMR11 0xA40800ACUL
68
69#define INTC_IMCR0 0xA40800C0UL
70#define INTC_IMCR1 0xA40800C4UL
71#define INTC_IMCR2 0xA40800C8UL
72#define INTC_IMCR3 0xA40800CCUL
73#define INTC_IMCR4 0xA40800D0UL
74#define INTC_IMCR5 0xA40800D4UL
75#define INTC_IMCR6 0xA40800D8UL
76#define INTC_IMCR7 0xA40800DCUL
77#define INTC_IMCR8 0xA40800E0UL
78#define INTC_IMCR9 0xA40800E4UL
79#define INTC_IMCR10 0xA40800E8UL
80#define INTC_IMCR11 0xA40800ECUL
81
82#define INTC_ICR0 0xA4140000UL
83#define INTC_ICR1 0xA414001CUL
84
85#define INTMSK0 0xa4140044
86#define INTMSKCLR0 0xa4140064
87#define INTC_INTPRI0 0xa4140010
88
89/*
90 NOTE:
91
92 *_IRQ = (INTEVT2 - 0x200)/0x20
93*/
94
95/* TMU0 */
96#define TMU0_IRQ 16
97#define TMU0_IPR_ADDR INTC_IPRA
98#define TMU0_IPR_POS 3
99#define TMU0_PRIORITY 2
100
101#define TIMER_IRQ 16
102#define TIMER_IPR_ADDR INTC_IPRA
103#define TIMER_IPR_POS 3
104#define TIMER_PRIORITY 2
105
106/* TMU1 */
107#define TMU1_IRQ 17
108#define TMU1_IPR_ADDR INTC_IPRA
109#define TMU1_IPR_POS 2
110#define TMU1_PRIORITY 2
111
112/* TMU2 */
113#define TMU2_IRQ 18
114#define TMU2_IPR_ADDR INTC_IPRA
115#define TMU2_IPR_POS 1
116#define TMU2_PRIORITY 2
117
118/* LCDC */
119#define LCDC_IRQ 28
120#define LCDC_IPR_ADDR INTC_IPRB
121#define LCDC_IPR_POS 2
122#define LCDC_PRIORITY 2
123
124/* VIO (Video I/O) */
125#define CEU_IRQ 52
126#define BEU_IRQ 53
127#define VEU_IRQ 54
128#define VOU_IRQ 55
129#define VIO_IPR_ADDR INTC_IPRE
130#define VIO_IPR_POS 2
131#define VIO_PRIORITY 2
132
133/* MFI (Multi Functional Interface) */
134#define MFI_IRQ 56
135#define MFI_IPR_ADDR INTC_IPRE
136#define MFI_IPR_POS 1
137#define MFI_PRIORITY 2
138
139/* VPU (Video Processing Unit) */
140#define VPU_IRQ 60
141#define VPU_IPR_ADDR INTC_IPRE
142#define VPU_IPR_POS 0
143#define VPU_PRIORITY 2
144
145/* 3DG */
146#define TDG_IRQ 63
147#define TDG_IPR_ADDR INTC_IPRJ
148#define TDG_IPR_POS 2
149#define TDG_PRIORITY 2
150
151/* DMAC(1) */
152#define DMTE0_IRQ 48
153#define DMTE1_IRQ 49
154#define DMTE2_IRQ 50
155#define DMTE3_IRQ 51
156#define DMA1_IPR_ADDR INTC_IPRE
157#define DMA1_IPR_POS 3
158#define DMA1_PRIORITY 7
159
160/* DMAC(2) */
161#define DMTE4_IRQ 76
162#define DMTE5_IRQ 77
163#define DMA2_IPR_ADDR INTC_IPRF
164#define DMA2_IPR_POS 2
165#define DMA2_PRIORITY 7
166
167/* SCIF0 */
168#define SCIF_ERI_IRQ 80
169#define SCIF_RXI_IRQ 81
170#define SCIF_BRI_IRQ 82
171#define SCIF_TXI_IRQ 83
172#define SCIF_IPR_ADDR INTC_IPRG
173#define SCIF_IPR_POS 3
174#define SCIF_PRIORITY 3
175
176/* SIOF0 */
177#define SIOF0_IRQ 84
178#define SIOF0_IPR_ADDR INTC_IPRH
179#define SIOF0_IPR_POS 3
180#define SIOF0_PRIORITY 3
181
182/* FLCTL (Flash Memory Controller) */
183#define FLSTE_IRQ 92
184#define FLTEND_IRQ 93
185#define FLTRQ0_IRQ 94
186#define FLTRQ1_IRQ 95
187#define FLCTL_IPR_ADDR INTC_IPRH
188#define FLCTL_IPR_POS 1
189#define FLCTL_PRIORITY 3
190
191/* IIC(0) (IIC Bus Interface) */
192#define IIC0_ALI_IRQ 96
193#define IIC0_TACKI_IRQ 97
194#define IIC0_WAITI_IRQ 98
195#define IIC0_DTEI_IRQ 99
196#define IIC0_IPR_ADDR INTC_IPRH
197#define IIC0_IPR_POS 0
198#define IIC0_PRIORITY 3
199
200/* IIC(1) (IIC Bus Interface) */
201#define IIC1_ALI_IRQ 44
202#define IIC1_TACKI_IRQ 45
203#define IIC1_WAITI_IRQ 46
204#define IIC1_DTEI_IRQ 47
205#define IIC1_IPR_ADDR INTC_IPRI
206#define IIC1_IPR_POS 0
207#define IIC1_PRIORITY 3
208
209/* SIO0 */
210#define SIO0_IRQ 88
211#define SIO0_IPR_ADDR INTC_IPRI
212#define SIO0_IPR_POS 3
213#define SIO0_PRIORITY 3
214
215/* SDHI */
216#define SDHI_SDHII0_IRQ 100
217#define SDHI_SDHII1_IRQ 101
218#define SDHI_SDHII2_IRQ 102
219#define SDHI_SDHII3_IRQ 103
220#define SDHI_IPR_ADDR INTC_IPRK
221#define SDHI_IPR_POS 0
222#define SDHI_PRIORITY 3
223
224/* SIU (Sound Interface Unit) */
225#define SIU_IRQ 108
226#define SIU_IPR_ADDR INTC_IPRJ
227#define SIU_IPR_POS 1
228#define SIU_PRIORITY 3
229
230#define PORT_PACR 0xA4050100UL
231#define PORT_PBCR 0xA4050102UL
232#define PORT_PCCR 0xA4050104UL
233#define PORT_PDCR 0xA4050106UL
234#define PORT_PECR 0xA4050108UL
235#define PORT_PFCR 0xA405010AUL
236#define PORT_PGCR 0xA405010CUL
237#define PORT_PHCR 0xA405010EUL
238#define PORT_PJCR 0xA4050110UL
239#define PORT_PKCR 0xA4050112UL
240#define PORT_PLCR 0xA4050114UL
241#define PORT_SCPCR 0xA4050116UL
242#define PORT_PMCR 0xA4050118UL
243#define PORT_PNCR 0xA405011AUL
244#define PORT_PQCR 0xA405011CUL
245#define PORT_PRCR 0xA405011EUL
246#define PORT_PTCR 0xA405014CUL
247#define PORT_PUCR 0xA405014EUL
248#define PORT_PVCR 0xA4050150UL
249
250#define PORT_PSELA 0xA4050140UL
251#define PORT_PSELB 0xA4050142UL
252#define PORT_PSELC 0xA4050144UL
253#define PORT_PSELE 0xA4050158UL
254
255#define PORT_HIZCRA 0xA4050146UL
256#define PORT_HIZCRB 0xA4050148UL
257#define PORT_DRVCR 0xA405014AUL
258
259#define PORT_PADR 0xA4050120UL
260#define PORT_PBDR 0xA4050122UL
261#define PORT_PCDR 0xA4050124UL
262#define PORT_PDDR 0xA4050126UL
263#define PORT_PEDR 0xA4050128UL
264#define PORT_PFDR 0xA405012AUL
265#define PORT_PGDR 0xA405012CUL
266#define PORT_PHDR 0xA405012EUL
267#define PORT_PJDR 0xA4050130UL
268#define PORT_PKDR 0xA4050132UL
269#define PORT_PLDR 0xA4050134UL
270#define PORT_SCPDR 0xA4050136UL
271#define PORT_PMDR 0xA4050138UL
272#define PORT_PNDR 0xA405013AUL
273#define PORT_PQDR 0xA405013CUL
274#define PORT_PRDR 0xA405013EUL
275#define PORT_PTDR 0xA405016CUL
276#define PORT_PUDR 0xA405016EUL
277#define PORT_PVDR 0xA4050170UL
278
279#define IRQ0_IRQ 32
280#define IRQ1_IRQ 33
281#define IRQ2_IRQ 34
282#define IRQ3_IRQ 35
283#define IRQ4_IRQ 36
284#define IRQ5_IRQ 37
285#define IRQ6_IRQ 38
286#define IRQ7_IRQ 39
287
288#define INTPRI00 0xA4140010UL
289
290#define IRQ0_IPR_ADDR INTPRI00
291#define IRQ1_IPR_ADDR INTPRI00
292#define IRQ2_IPR_ADDR INTPRI00
293#define IRQ3_IPR_ADDR INTPRI00
294#define IRQ4_IPR_ADDR INTPRI00
295#define IRQ5_IPR_ADDR INTPRI00
296#define IRQ6_IPR_ADDR INTPRI00
297#define IRQ7_IPR_ADDR INTPRI00
298
299#define IRQ0_IPR_POS 7
300#define IRQ1_IPR_POS 6
301#define IRQ2_IPR_POS 5
302#define IRQ3_IPR_POS 4
303#define IRQ4_IPR_POS 3
304#define IRQ5_IPR_POS 2
305#define IRQ6_IPR_POS 1
306#define IRQ7_IPR_POS 0
307
308#define IRQ0_PRIORITY 1
309#define IRQ1_PRIORITY 1
310#define IRQ2_PRIORITY 1
311#define IRQ3_PRIORITY 1
312#define IRQ4_PRIORITY 1
313#define IRQ5_PRIORITY 1
314#define IRQ6_PRIORITY 1
315#define IRQ7_PRIORITY 1
316
317#endif /* __ASM_SH_IRQ_SH7343_H */
diff --git a/include/asm-sh/irq-sh7780.h b/include/asm-sh/irq-sh7780.h
deleted file mode 100644
index 19912ae6a7f7..000000000000
--- a/include/asm-sh/irq-sh7780.h
+++ /dev/null
@@ -1,311 +0,0 @@
1#ifndef __ASM_SH_IRQ_SH7780_H
2#define __ASM_SH_IRQ_SH7780_H
3
4/*
5 * linux/include/asm-sh/irq-sh7780.h
6 *
7 * Copyright (C) 2004 Takashi SHUDO <shudo@hitachi-ul.co.jp>
8 */
9#define INTC_BASE 0xffd00000
10#define INTC_ICR0 (INTC_BASE+0x0)
11#define INTC_ICR1 (INTC_BASE+0x1c)
12#define INTC_INTPRI (INTC_BASE+0x10)
13#define INTC_INTREQ (INTC_BASE+0x24)
14#define INTC_INTMSK0 (INTC_BASE+0x44)
15#define INTC_INTMSK1 (INTC_BASE+0x48)
16#define INTC_INTMSK2 (INTC_BASE+0x40080)
17#define INTC_INTMSKCLR0 (INTC_BASE+0x64)
18#define INTC_INTMSKCLR1 (INTC_BASE+0x68)
19#define INTC_INTMSKCLR2 (INTC_BASE+0x40084)
20#define INTC_NMIFCR (INTC_BASE+0xc0)
21#define INTC_USERIMASK (INTC_BASE+0x30000)
22
23#define INTC_INT2PRI0 (INTC_BASE+0x40000)
24#define INTC_INT2PRI1 (INTC_BASE+0x40004)
25#define INTC_INT2PRI2 (INTC_BASE+0x40008)
26#define INTC_INT2PRI3 (INTC_BASE+0x4000c)
27#define INTC_INT2PRI4 (INTC_BASE+0x40010)
28#define INTC_INT2PRI5 (INTC_BASE+0x40014)
29#define INTC_INT2PRI6 (INTC_BASE+0x40018)
30#define INTC_INT2PRI7 (INTC_BASE+0x4001c)
31#define INTC_INT2A0 (INTC_BASE+0x40030)
32#define INTC_INT2A1 (INTC_BASE+0x40034)
33#define INTC_INT2MSKR (INTC_BASE+0x40038)
34#define INTC_INT2MSKCR (INTC_BASE+0x4003c)
35#define INTC_INT2B0 (INTC_BASE+0x40040)
36#define INTC_INT2B1 (INTC_BASE+0x40044)
37#define INTC_INT2B2 (INTC_BASE+0x40048)
38#define INTC_INT2B3 (INTC_BASE+0x4004c)
39#define INTC_INT2B4 (INTC_BASE+0x40050)
40#define INTC_INT2B5 (INTC_BASE+0x40054)
41#define INTC_INT2B6 (INTC_BASE+0x40058)
42#define INTC_INT2B7 (INTC_BASE+0x4005c)
43#define INTC_INT2GPIC (INTC_BASE+0x40090)
44/*
45 NOTE:
46 *_IRQ = (INTEVT2 - 0x200)/0x20
47*/
48/* IRQ 0-7 line external int*/
49#define IRQ0_IRQ 2
50#define IRQ0_IPR_ADDR INTC_INTPRI
51#define IRQ0_IPR_POS 7
52#define IRQ0_PRIORITY 2
53
54#define IRQ1_IRQ 4
55#define IRQ1_IPR_ADDR INTC_INTPRI
56#define IRQ1_IPR_POS 6
57#define IRQ1_PRIORITY 2
58
59#define IRQ2_IRQ 6
60#define IRQ2_IPR_ADDR INTC_INTPRI
61#define IRQ2_IPR_POS 5
62#define IRQ2_PRIORITY 2
63
64#define IRQ3_IRQ 8
65#define IRQ3_IPR_ADDR INTC_INTPRI
66#define IRQ3_IPR_POS 4
67#define IRQ3_PRIORITY 2
68
69#define IRQ4_IRQ 10
70#define IRQ4_IPR_ADDR INTC_INTPRI
71#define IRQ4_IPR_POS 3
72#define IRQ4_PRIORITY 2
73
74#define IRQ5_IRQ 12
75#define IRQ5_IPR_ADDR INTC_INTPRI
76#define IRQ5_IPR_POS 2
77#define IRQ5_PRIORITY 2
78
79#define IRQ6_IRQ 14
80#define IRQ6_IPR_ADDR INTC_INTPRI
81#define IRQ6_IPR_POS 1
82#define IRQ6_PRIORITY 2
83
84#define IRQ7_IRQ 0
85#define IRQ7_IPR_ADDR INTC_INTPRI
86#define IRQ7_IPR_POS 0
87#define IRQ7_PRIORITY 2
88
89/* TMU */
90/* ch0 */
91#define TMU_IRQ 28
92#define TMU_IPR_ADDR INTC_INT2PRI0
93#define TMU_IPR_POS 3
94#define TMU_PRIORITY 2
95
96#define TIMER_IRQ 28
97#define TIMER_IPR_ADDR INTC_INT2PRI0
98#define TIMER_IPR_POS 3
99#define TIMER_PRIORITY 2
100
101/* ch 1*/
102#define TMU_CH1_IRQ 29
103#define TMU_CH1_IPR_ADDR INTC_INT2PRI0
104#define TMU_CH1_IPR_POS 2
105#define TMU_CH1_PRIORITY 2
106
107#define TIMER1_IRQ 29
108#define TIMER1_IPR_ADDR INTC_INT2PRI0
109#define TIMER1_IPR_POS 2
110#define TIMER1_PRIORITY 2
111
112/* ch 2*/
113#define TMU_CH2_IRQ 30
114#define TMU_CH2_IPR_ADDR INTC_INT2PRI0
115#define TMU_CH2_IPR_POS 1
116#define TMU_CH2_PRIORITY 2
117/* ch 2 Input capture */
118#define TMU_CH2IC_IRQ 31
119#define TMU_CH2IC_IPR_ADDR INTC_INT2PRI0
120#define TMU_CH2IC_IPR_POS 0
121#define TMU_CH2IC_PRIORITY 2
122/* ch 3 */
123#define TMU_CH3_IRQ 96
124#define TMU_CH3_IPR_ADDR INTC_INT2PRI1
125#define TMU_CH3_IPR_POS 3
126#define TMU_CH3_PRIORITY 2
127/* ch 4 */
128#define TMU_CH4_IRQ 97
129#define TMU_CH4_IPR_ADDR INTC_INT2PRI1
130#define TMU_CH4_IPR_POS 2
131#define TMU_CH4_PRIORITY 2
132/* ch 5*/
133#define TMU_CH5_IRQ 98
134#define TMU_CH5_IPR_ADDR INTC_INT2PRI1
135#define TMU_CH5_IPR_POS 1
136#define TMU_CH5_PRIORITY 2
137
138/* SCIF0 */
139#define SCIF0_ERI_IRQ 40
140#define SCIF0_RXI_IRQ 41
141#define SCIF0_BRI_IRQ 42
142#define SCIF0_TXI_IRQ 43
143#define SCIF0_IPR_ADDR INTC_INT2PRI2
144#define SCIF0_IPR_POS 3
145#define SCIF0_PRIORITY 3
146
147/* SCIF1 */
148#define SCIF1_ERI_IRQ 76
149#define SCIF1_RXI_IRQ 77
150#define SCIF1_BRI_IRQ 78
151#define SCIF1_TXI_IRQ 79
152#define SCIF1_IPR_ADDR INTC_INT2PRI2
153#define SCIF1_IPR_POS 2
154#define SCIF1_PRIORITY 3
155
156#define WDT_IRQ 27
157#define WDT_IPR_ADDR INTC_INT2PRI2
158#define WDT_IPR_POS 1
159#define WDT_PRIORITY 2
160
161/* DMAC(0) */
162#define DMINT0_IRQ 34
163#define DMINT1_IRQ 35
164#define DMINT2_IRQ 36
165#define DMINT3_IRQ 37
166#define DMINT4_IRQ 44
167#define DMINT5_IRQ 45
168#define DMINT6_IRQ 46
169#define DMINT7_IRQ 47
170#define DMAE_IRQ 38
171#define DMA0_IPR_ADDR INTC_INT2PRI3
172#define DMA0_IPR_POS 2
173#define DMA0_PRIORITY 7
174
175/* DMAC(1) */
176#define DMINT8_IRQ 92
177#define DMINT9_IRQ 93
178#define DMINT10_IRQ 94
179#define DMINT11_IRQ 95
180#define DMA1_IPR_ADDR INTC_INT2PRI3
181#define DMA1_IPR_POS 1
182#define DMA1_PRIORITY 7
183
184#define DMTE0_IRQ DMINT0_IRQ
185#define DMTE4_IRQ DMINT4_IRQ
186#define DMA_IPR_ADDR DMA0_IPR_ADDR
187#define DMA_IPR_POS DMA0_IPR_POS
188#define DMA_PRIORITY DMA0_PRIORITY
189
190/* CMT */
191#define CMT_IRQ 56
192#define CMT_IPR_ADDR INTC_INT2PRI4
193#define CMT_IPR_POS 3
194#define CMT_PRIORITY 0
195
196/* HAC */
197#define HAC_IRQ 60
198#define HAC_IPR_ADDR INTC_INT2PRI4
199#define HAC_IPR_POS 2
200#define CMT_PRIORITY 0
201
202/* PCIC(0) */
203#define PCIC0_IRQ 64
204#define PCIC0_IPR_ADDR INTC_INT2PRI4
205#define PCIC0_IPR_POS 1
206#define PCIC0_PRIORITY 2
207
208/* PCIC(1) */
209#define PCIC1_IRQ 65
210#define PCIC1_IPR_ADDR INTC_INT2PRI4
211#define PCIC1_IPR_POS 0
212#define PCIC1_PRIORITY 2
213
214/* PCIC(2) */
215#define PCIC2_IRQ 66
216#define PCIC2_IPR_ADDR INTC_INT2PRI5
217#define PCIC2_IPR_POS 3
218#define PCIC2_PRIORITY 2
219
220/* PCIC(3) */
221#define PCIC3_IRQ 67
222#define PCIC3_IPR_ADDR INTC_INT2PRI5
223#define PCIC3_IPR_POS 2
224#define PCIC3_PRIORITY 2
225
226/* PCIC(4) */
227#define PCIC4_IRQ 68
228#define PCIC4_IPR_ADDR INTC_INT2PRI5
229#define PCIC4_IPR_POS 1
230#define PCIC4_PRIORITY 2
231
232/* PCIC(5) */
233#define PCICERR_IRQ 69
234#define PCICPWD3_IRQ 70
235#define PCICPWD2_IRQ 71
236#define PCICPWD1_IRQ 72
237#define PCICPWD0_IRQ 73
238#define PCIC5_IPR_ADDR INTC_INT2PRI5
239#define PCIC5_IPR_POS 0
240#define PCIC5_PRIORITY 2
241
242/* SIOF */
243#define SIOF_IRQ 80
244#define SIOF_IPR_ADDR INTC_INT2PRI6
245#define SIOF_IPR_POS 3
246#define SIOF_PRIORITY 3
247
248/* HSPI */
249#define HSPI_IRQ 84
250#define HSPI_IPR_ADDR INTC_INT2PRI6
251#define HSPI_IPR_POS 2
252#define HSPI_PRIORITY 3
253
254/* MMCIF */
255#define MMCIF_FSTAT_IRQ 88
256#define MMCIF_TRAN_IRQ 89
257#define MMCIF_ERR_IRQ 90
258#define MMCIF_FRDY_IRQ 91
259#define MMCIF_IPR_ADDR INTC_INT2PRI6
260#define MMCIF_IPR_POS 1
261#define HSPI_PRIORITY 3
262
263/* SSI */
264#define SSI_IRQ 100
265#define SSI_IPR_ADDR INTC_INT2PRI6
266#define SSI_IPR_POS 0
267#define SSI_PRIORITY 3
268
269/* FLCTL */
270#define FLCTL_FLSTE_IRQ 104
271#define FLCTL_FLTEND_IRQ 105
272#define FLCTL_FLTRQ0_IRQ 106
273#define FLCTL_FLTRQ1_IRQ 107
274#define FLCTL_IPR_ADDR INTC_INT2PRI7
275#define FLCTL_IPR_POS 3
276#define FLCTL_PRIORITY 3
277
278/* GPIO */
279#define GPIO0_IRQ 108
280#define GPIO1_IRQ 109
281#define GPIO2_IRQ 110
282#define GPIO3_IRQ 111
283#define GPIO_IPR_ADDR INTC_INT2PRI7
284#define GPIO_IPR_POS 2
285#define GPIO_PRIORITY 3
286
287#define INTC_TMU0_MSK 0
288#define INTC_TMU3_MSK 1
289#define INTC_RTC_MSK 2
290#define INTC_SCIF0_MSK 3
291#define INTC_SCIF1_MSK 4
292#define INTC_WDT_MSK 5
293#define INTC_HUID_MSK 7
294#define INTC_DMAC0_MSK 8
295#define INTC_DMAC1_MSK 9
296#define INTC_CMT_MSK 12
297#define INTC_HAC_MSK 13
298#define INTC_PCIC0_MSK 14
299#define INTC_PCIC1_MSK 15
300#define INTC_PCIC2_MSK 16
301#define INTC_PCIC3_MSK 17
302#define INTC_PCIC4_MSK 18
303#define INTC_PCIC5_MSK 19
304#define INTC_SIOF_MSK 20
305#define INTC_HSPI_MSK 21
306#define INTC_MMCIF_MSK 22
307#define INTC_SSI_MSK 23
308#define INTC_FLCTL_MSK 24
309#define INTC_GPIO_MSK 25
310
311#endif /* __ASM_SH_IRQ_SH7780_H */
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 6cd3e9e2a76a..fd576088e47e 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -1,233 +1,9 @@
1#ifndef __ASM_SH_IRQ_H 1#ifndef __ASM_SH_IRQ_H
2#define __ASM_SH_IRQ_H 2#define __ASM_SH_IRQ_H
3 3
4/*
5 *
6 * linux/include/asm-sh/irq.h
7 *
8 * Copyright (C) 1999 Niibe Yutaka & Takeshi Yaegashi
9 * Copyright (C) 2000 Kazumoto Kojima
10 * Copyright (C) 2003 Paul Mundt
11 *
12 */
13
14#include <asm/machvec.h> 4#include <asm/machvec.h>
15#include <asm/ptrace.h> /* for pt_regs */ 5#include <asm/ptrace.h> /* for pt_regs */
16 6
17#ifndef CONFIG_CPU_SUBTYPE_SH7780
18
19#define INTC_DMAC0_MSK 0
20
21#if defined(CONFIG_CPU_SH3)
22#define INTC_IPRA 0xfffffee2UL
23#define INTC_IPRB 0xfffffee4UL
24#elif defined(CONFIG_CPU_SH4)
25#define INTC_IPRA 0xffd00004UL
26#define INTC_IPRB 0xffd00008UL
27#define INTC_IPRC 0xffd0000cUL
28#define INTC_IPRD 0xffd00010UL
29#endif
30
31#define TIMER_IRQ 16
32#define TIMER_IPR_ADDR INTC_IPRA
33#define TIMER_IPR_POS 3
34#define TIMER_PRIORITY 2
35
36#define TIMER1_IRQ 17
37#define TIMER1_IPR_ADDR INTC_IPRA
38#define TIMER1_IPR_POS 2
39#define TIMER1_PRIORITY 4
40
41#define RTC_IRQ 22
42#define RTC_IPR_ADDR INTC_IPRA
43#define RTC_IPR_POS 0
44#define RTC_PRIORITY TIMER_PRIORITY
45
46#if defined(CONFIG_CPU_SH3)
47#define DMTE0_IRQ 48
48#define DMTE1_IRQ 49
49#define DMTE2_IRQ 50
50#define DMTE3_IRQ 51
51#define DMA_IPR_ADDR INTC_IPRE
52#define DMA_IPR_POS 3
53#define DMA_PRIORITY 7
54#if defined(CONFIG_CPU_SUBTYPE_SH7300)
55/* TMU2 */
56#define TIMER2_IRQ 18
57#define TIMER2_IPR_ADDR INTC_IPRA
58#define TIMER2_IPR_POS 1
59#define TIMER2_PRIORITY 2
60
61/* WDT */
62#define WDT_IRQ 27
63#define WDT_IPR_ADDR INTC_IPRB
64#define WDT_IPR_POS 3
65#define WDT_PRIORITY 2
66
67/* SIM (SIM Card Module) */
68#define SIM_ERI_IRQ 23
69#define SIM_RXI_IRQ 24
70#define SIM_TXI_IRQ 25
71#define SIM_TEND_IRQ 26
72#define SIM_IPR_ADDR INTC_IPRB
73#define SIM_IPR_POS 1
74#define SIM_PRIORITY 2
75
76/* VIO (Video I/O) */
77#define VIO_IRQ 52
78#define VIO_IPR_ADDR INTC_IPRE
79#define VIO_IPR_POS 2
80#define VIO_PRIORITY 2
81
82/* MFI (Multi Functional Interface) */
83#define MFI_IRQ 56
84#define MFI_IPR_ADDR INTC_IPRE
85#define MFI_IPR_POS 1
86#define MFI_PRIORITY 2
87
88/* VPU (Video Processing Unit) */
89#define VPU_IRQ 60
90#define VPU_IPR_ADDR INTC_IPRE
91#define VPU_IPR_POS 0
92#define VPU_PRIORITY 2
93
94/* KEY (Key Scan Interface) */
95#define KEY_IRQ 79
96#define KEY_IPR_ADDR INTC_IPRF
97#define KEY_IPR_POS 3
98#define KEY_PRIORITY 2
99
100/* CMT (Compare Match Timer) */
101#define CMT_IRQ 104
102#define CMT_IPR_ADDR INTC_IPRF
103#define CMT_IPR_POS 0
104#define CMT_PRIORITY 2
105
106/* DMAC(1) */
107#define DMTE0_IRQ 48
108#define DMTE1_IRQ 49
109#define DMTE2_IRQ 50
110#define DMTE3_IRQ 51
111#define DMA1_IPR_ADDR INTC_IPRE
112#define DMA1_IPR_POS 3
113#define DMA1_PRIORITY 7
114
115/* DMAC(2) */
116#define DMTE4_IRQ 76
117#define DMTE5_IRQ 77
118#define DMA2_IPR_ADDR INTC_IPRF
119#define DMA2_IPR_POS 2
120#define DMA2_PRIORITY 7
121
122/* SIOF0 */
123#define SIOF0_IRQ 84
124#define SIOF0_IPR_ADDR INTC_IPRH
125#define SIOF0_IPR_POS 3
126#define SIOF0_PRIORITY 3
127
128/* FLCTL (Flash Memory Controller) */
129#define FLSTE_IRQ 92
130#define FLTEND_IRQ 93
131#define FLTRQ0_IRQ 94
132#define FLTRQ1_IRQ 95
133#define FLCTL_IPR_ADDR INTC_IPRH
134#define FLCTL_IPR_POS 1
135#define FLCTL_PRIORITY 3
136
137/* IIC (IIC Bus Interface) */
138#define IIC_ALI_IRQ 96
139#define IIC_TACKI_IRQ 97
140#define IIC_WAITI_IRQ 98
141#define IIC_DTEI_IRQ 99
142#define IIC_IPR_ADDR INTC_IPRH
143#define IIC_IPR_POS 0
144#define IIC_PRIORITY 3
145
146/* SIO0 */
147#define SIO0_IRQ 88
148#define SIO0_IPR_ADDR INTC_IPRI
149#define SIO0_IPR_POS 3
150#define SIO0_PRIORITY 3
151
152/* SIU (Sound Interface Unit) */
153#define SIU_IRQ 108
154#define SIU_IPR_ADDR INTC_IPRJ
155#define SIU_IPR_POS 1
156#define SIU_PRIORITY 3
157
158#endif
159#elif defined(CONFIG_CPU_SH4)
160#define DMTE0_IRQ 34
161#define DMTE1_IRQ 35
162#define DMTE2_IRQ 36
163#define DMTE3_IRQ 37
164#define DMTE4_IRQ 44 /* 7751R only */
165#define DMTE5_IRQ 45 /* 7751R only */
166#define DMTE6_IRQ 46 /* 7751R only */
167#define DMTE7_IRQ 47 /* 7751R only */
168#define DMAE_IRQ 38
169#define DMA_IPR_ADDR INTC_IPRC
170#define DMA_IPR_POS 2
171#define DMA_PRIORITY 7
172#endif
173
174#if defined (CONFIG_CPU_SUBTYPE_SH7707) || defined (CONFIG_CPU_SUBTYPE_SH7708) || \
175 defined (CONFIG_CPU_SUBTYPE_SH7709) || defined (CONFIG_CPU_SUBTYPE_SH7750) || \
176 defined (CONFIG_CPU_SUBTYPE_SH7751) || defined (CONFIG_CPU_SUBTYPE_SH7706)
177#define SCI_ERI_IRQ 23
178#define SCI_RXI_IRQ 24
179#define SCI_TXI_IRQ 25
180#define SCI_IPR_ADDR INTC_IPRB
181#define SCI_IPR_POS 1
182#define SCI_PRIORITY 3
183#endif
184
185#if defined(CONFIG_CPU_SUBTYPE_SH7300)
186#define SCIF0_IRQ 80
187#define SCIF0_IPR_ADDR INTC_IPRG
188#define SCIF0_IPR_POS 3
189#define SCIF0_PRIORITY 3
190#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
191 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
192 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
193 defined(CONFIG_CPU_SUBTYPE_SH7709)
194#define SCIF_ERI_IRQ 56
195#define SCIF_RXI_IRQ 57
196#define SCIF_BRI_IRQ 58
197#define SCIF_TXI_IRQ 59
198#define SCIF_IPR_ADDR INTC_IPRE
199#define SCIF_IPR_POS 1
200#define SCIF_PRIORITY 3
201
202#define IRDA_ERI_IRQ 52
203#define IRDA_RXI_IRQ 53
204#define IRDA_BRI_IRQ 54
205#define IRDA_TXI_IRQ 55
206#define IRDA_IPR_ADDR INTC_IPRE
207#define IRDA_IPR_POS 2
208#define IRDA_PRIORITY 3
209#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
210 defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
211#define SCIF_ERI_IRQ 40
212#define SCIF_RXI_IRQ 41
213#define SCIF_BRI_IRQ 42
214#define SCIF_TXI_IRQ 43
215#define SCIF_IPR_ADDR INTC_IPRC
216#define SCIF_IPR_POS 1
217#define SCIF_PRIORITY 3
218#if defined(CONFIG_CPU_SUBTYPE_ST40STB1)
219#define SCIF1_ERI_IRQ 23
220#define SCIF1_RXI_IRQ 24
221#define SCIF1_BRI_IRQ 25
222#define SCIF1_TXI_IRQ 26
223#define SCIF1_IPR_ADDR INTC_IPRB
224#define SCIF1_IPR_POS 1
225#define SCIF1_PRIORITY 3
226#endif /* ST40STB1 */
227
228#endif /* 775x / SH4-202 / ST40STB1 */
229#endif /* 7780 */
230
231/* NR_IRQS is made from three components: 7/* NR_IRQS is made from three components:
232 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules 8 * 1. ONCHIP_NR_IRQS - number of IRLS + on-chip peripherial modules
233 * 2. PINT_NR_IRQS - number of PINT interrupts 9 * 2. PINT_NR_IRQS - number of PINT interrupts
@@ -265,6 +41,10 @@
265# define ONCHIP_NR_IRQS 109 41# define ONCHIP_NR_IRQS 109
266#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 42#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
267# define ONCHIP_NR_IRQS 111 43# define ONCHIP_NR_IRQS 111
44#elif defined(CONFIG_CPU_SUBTYPE_SH7206)
45# define ONCHIP_NR_IRQS 256
46#elif defined(CONFIG_CPU_SUBTYPE_SH7619)
47# define ONCHIP_NR_IRQS 128
268#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */ 48#elif defined(CONFIG_SH_UNKNOWN) /* Most be last */
269# define ONCHIP_NR_IRQS 144 49# define ONCHIP_NR_IRQS 144
270#endif 50#endif
@@ -312,9 +92,11 @@
312/* NR_IRQS. 1+2+3 */ 92/* NR_IRQS. 1+2+3 */
313#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS) 93#define NR_IRQS (ONCHIP_NR_IRQS + PINT_NR_IRQS + OFFCHIP_NR_IRQS)
314 94
315extern void disable_irq(unsigned int); 95/*
316extern void disable_irq_nosync(unsigned int); 96 * Convert back and forth between INTEVT and IRQ values.
317extern void enable_irq(unsigned int); 97 */
98#define evt2irq(evt) (((evt) >> 5) - 16)
99#define irq2evt(irq) (((irq) + 16) << 5)
318 100
319/* 101/*
320 * Simple Mask Register Support 102 * Simple Mask Register Support
@@ -327,362 +109,36 @@ extern unsigned short *irq_mask_register;
327 */ 109 */
328void init_IRQ_pint(void); 110void init_IRQ_pint(void);
329 111
112/*
113 * The shift value is now the number of bits to shift, not the number of
114 * bits/4. This is to make it easier to read the value directly from the
115 * datasheets. The IPR address, addr, will be set from ipr_idx via the
116 * map_ipridx_to_addr function.
117 */
330struct ipr_data { 118struct ipr_data {
331 unsigned int irq; 119 unsigned int irq;
332 unsigned int addr; /* Address of Interrupt Priority Register */ 120 int ipr_idx; /* Index for the IPR registered */
333 int shift; /* Shifts of the 16-bit data */ 121 int shift; /* Number of bits to shift the data */
334 int priority; /* The priority */ 122 int priority; /* The priority */
123 unsigned int addr; /* Address of Interrupt Priority Register */
335}; 124};
336 125
337/* 126/*
338 * Function for "on chip support modules". 127 * Given an IPR IDX, map the value to an IPR register address.
339 */ 128 */
340extern void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs); 129unsigned int map_ipridx_to_addr(int idx);
341extern void make_imask_irq(unsigned int irq);
342
343#if defined(CONFIG_CPU_SUBTYPE_SH7300)
344#undef INTC_IPRA
345#undef INTC_IPRB
346#define INTC_IPRA 0xA414FEE2UL
347#define INTC_IPRB 0xA414FEE4UL
348#define INTC_IPRC 0xA4140016UL
349#define INTC_IPRD 0xA4140018UL
350#define INTC_IPRE 0xA414001AUL
351#define INTC_IPRF 0xA4080000UL
352#define INTC_IPRG 0xA4080002UL
353#define INTC_IPRH 0xA4080004UL
354#define INTC_IPRI 0xA4080006UL
355#define INTC_IPRJ 0xA4080008UL
356
357#define INTC_IMR0 0xA4080040UL
358#define INTC_IMR1 0xA4080042UL
359#define INTC_IMR2 0xA4080044UL
360#define INTC_IMR3 0xA4080046UL
361#define INTC_IMR4 0xA4080048UL
362#define INTC_IMR5 0xA408004AUL
363#define INTC_IMR6 0xA408004CUL
364#define INTC_IMR7 0xA408004EUL
365#define INTC_IMR8 0xA4080050UL
366#define INTC_IMR9 0xA4080052UL
367#define INTC_IMR10 0xA4080054UL
368
369#define INTC_IMCR0 0xA4080060UL
370#define INTC_IMCR1 0xA4080062UL
371#define INTC_IMCR2 0xA4080064UL
372#define INTC_IMCR3 0xA4080066UL
373#define INTC_IMCR4 0xA4080068UL
374#define INTC_IMCR5 0xA408006AUL
375#define INTC_IMCR6 0xA408006CUL
376#define INTC_IMCR7 0xA408006EUL
377#define INTC_IMCR8 0xA4080070UL
378#define INTC_IMCR9 0xA4080072UL
379#define INTC_IMCR10 0xA4080074UL
380
381#define INTC_ICR0 0xA414FEE0UL
382#define INTC_ICR1 0xA4140010UL
383
384#define INTC_IRR0 0xA4140004UL
385
386#define PORT_PACR 0xA4050100UL
387#define PORT_PBCR 0xA4050102UL
388#define PORT_PCCR 0xA4050104UL
389#define PORT_PDCR 0xA4050106UL
390#define PORT_PECR 0xA4050108UL
391#define PORT_PFCR 0xA405010AUL
392#define PORT_PGCR 0xA405010CUL
393#define PORT_PHCR 0xA405010EUL
394#define PORT_PJCR 0xA4050110UL
395#define PORT_PKCR 0xA4050112UL
396#define PORT_PLCR 0xA4050114UL
397#define PORT_SCPCR 0xA4050116UL
398#define PORT_PMCR 0xA4050118UL
399#define PORT_PNCR 0xA405011AUL
400#define PORT_PQCR 0xA405011CUL
401
402#define PORT_PSELA 0xA4050140UL
403#define PORT_PSELB 0xA4050142UL
404#define PORT_PSELC 0xA4050144UL
405
406#define PORT_HIZCRA 0xA4050146UL
407#define PORT_HIZCRB 0xA4050148UL
408#define PORT_DRVCR 0xA4050150UL
409
410#define PORT_PADR 0xA4050120UL
411#define PORT_PBDR 0xA4050122UL
412#define PORT_PCDR 0xA4050124UL
413#define PORT_PDDR 0xA4050126UL
414#define PORT_PEDR 0xA4050128UL
415#define PORT_PFDR 0xA405012AUL
416#define PORT_PGDR 0xA405012CUL
417#define PORT_PHDR 0xA405012EUL
418#define PORT_PJDR 0xA4050130UL
419#define PORT_PKDR 0xA4050132UL
420#define PORT_PLDR 0xA4050134UL
421#define PORT_SCPDR 0xA4050136UL
422#define PORT_PMDR 0xA4050138UL
423#define PORT_PNDR 0xA405013AUL
424#define PORT_PQDR 0xA405013CUL
425
426#define IRQ0_IRQ 32
427#define IRQ1_IRQ 33
428#define IRQ2_IRQ 34
429#define IRQ3_IRQ 35
430#define IRQ4_IRQ 36
431#define IRQ5_IRQ 37
432
433#define IRQ0_IPR_ADDR INTC_IPRC
434#define IRQ1_IPR_ADDR INTC_IPRC
435#define IRQ2_IPR_ADDR INTC_IPRC
436#define IRQ3_IPR_ADDR INTC_IPRC
437#define IRQ4_IPR_ADDR INTC_IPRD
438#define IRQ5_IPR_ADDR INTC_IPRD
439
440#define IRQ0_IPR_POS 0
441#define IRQ1_IPR_POS 1
442#define IRQ2_IPR_POS 2
443#define IRQ3_IPR_POS 3
444#define IRQ4_IPR_POS 0
445#define IRQ5_IPR_POS 1
446 130
447#define IRQ0_PRIORITY 1 131/*
448#define IRQ1_PRIORITY 1 132 * Enable individual interrupt mode for external IPR IRQs.
449#define IRQ2_PRIORITY 1 133 */
450#define IRQ3_PRIORITY 1 134void ipr_irq_enable_irlm(void);
451#define IRQ4_PRIORITY 1
452#define IRQ5_PRIORITY 1
453
454extern int ipr_irq_demux(int irq);
455#define __irq_demux(irq) ipr_irq_demux(irq)
456
457#elif defined(CONFIG_CPU_SUBTYPE_SH7604)
458#define INTC_IPRA 0xfffffee2UL
459#define INTC_IPRB 0xfffffe60UL
460
461#define INTC_VCRA 0xfffffe62UL
462#define INTC_VCRB 0xfffffe64UL
463#define INTC_VCRC 0xfffffe66UL
464#define INTC_VCRD 0xfffffe68UL
465
466#define INTC_VCRWDT 0xfffffee4UL
467#define INTC_VCRDIV 0xffffff0cUL
468#define INTC_VCRDMA0 0xffffffa0UL
469#define INTC_VCRDMA1 0xffffffa8UL
470
471#define INTC_ICR 0xfffffee0UL
472#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
473 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
474 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
475 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
476 defined(CONFIG_CPU_SUBTYPE_SH7710)
477#define INTC_IRR0 0xa4000004UL
478#define INTC_IRR1 0xa4000006UL
479#define INTC_IRR2 0xa4000008UL
480
481#define INTC_ICR0 0xfffffee0UL
482#define INTC_ICR1 0xa4000010UL
483#define INTC_ICR2 0xa4000012UL
484#define INTC_INTER 0xa4000014UL
485
486#define INTC_IPRC 0xa4000016UL
487#define INTC_IPRD 0xa4000018UL
488#define INTC_IPRE 0xa400001aUL
489#if defined(CONFIG_CPU_SUBTYPE_SH7707)
490#define INTC_IPRF 0xa400001cUL
491#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
492#define INTC_IPRF 0xa4080000UL
493#define INTC_IPRG 0xa4080002UL
494#define INTC_IPRH 0xa4080004UL
495#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
496/* Interrupt Controller Registers */
497#undef INTC_IPRA
498#undef INTC_IPRB
499#define INTC_IPRA 0xA414FEE2UL
500#define INTC_IPRB 0xA414FEE4UL
501#define INTC_IPRF 0xA4080000UL
502#define INTC_IPRG 0xA4080002UL
503#define INTC_IPRH 0xA4080004UL
504#define INTC_IPRI 0xA4080006UL
505
506#undef INTC_ICR0
507#undef INTC_ICR1
508#define INTC_ICR0 0xA414FEE0UL
509#define INTC_ICR1 0xA4140010UL
510
511#define INTC_IRR0 0xa4000004UL
512#define INTC_IRR1 0xa4000006UL
513#define INTC_IRR2 0xa4000008UL
514#define INTC_IRR3 0xa400000AUL
515#define INTC_IRR4 0xa400000CUL
516#define INTC_IRR5 0xa4080020UL
517#define INTC_IRR7 0xa4080024UL
518#define INTC_IRR8 0xa4080026UL
519
520/* Interrupt numbers */
521#define TIMER2_IRQ 18
522#define TIMER2_IPR_ADDR INTC_IPRA
523#define TIMER2_IPR_POS 1
524#define TIMER2_PRIORITY 2
525
526/* WDT */
527#define WDT_IRQ 27
528#define WDT_IPR_ADDR INTC_IPRB
529#define WDT_IPR_POS 3
530#define WDT_PRIORITY 2
531
532#define SCIF0_ERI_IRQ 52
533#define SCIF0_RXI_IRQ 53
534#define SCIF0_BRI_IRQ 54
535#define SCIF0_TXI_IRQ 55
536#define SCIF0_IPR_ADDR INTC_IPRE
537#define SCIF0_IPR_POS 2
538#define SCIF0_PRIORITY 3
539
540#define DMTE4_IRQ 76
541#define DMTE5_IRQ 77
542#define DMA2_IPR_ADDR INTC_IPRF
543#define DMA2_IPR_POS 2
544#define DMA2_PRIORITY 7
545
546#define IPSEC_IRQ 79
547#define IPSEC_IPR_ADDR INTC_IPRF
548#define IPSEC_IPR_POS 3
549#define IPSEC_PRIORITY 3
550
551/* EDMAC */
552#define EDMAC0_IRQ 80
553#define EDMAC0_IPR_ADDR INTC_IPRG
554#define EDMAC0_IPR_POS 3
555#define EDMAC0_PRIORITY 3
556
557#define EDMAC1_IRQ 81
558#define EDMAC1_IPR_ADDR INTC_IPRG
559#define EDMAC1_IPR_POS 2
560#define EDMAC1_PRIORITY 3
561
562#define EDMAC2_IRQ 82
563#define EDMAC2_IPR_ADDR INTC_IPRG
564#define EDMAC2_IPR_POS 1
565#define EDMAC2_PRIORITY 3
566
567/* SIOF */
568#define SIOF0_ERI_IRQ 96
569#define SIOF0_TXI_IRQ 97
570#define SIOF0_RXI_IRQ 98
571#define SIOF0_CCI_IRQ 99
572#define SIOF0_IPR_ADDR INTC_IPRH
573#define SIOF0_IPR_POS 0
574#define SIOF0_PRIORITY 7
575
576#define SIOF1_ERI_IRQ 100
577#define SIOF1_TXI_IRQ 101
578#define SIOF1_RXI_IRQ 102
579#define SIOF1_CCI_IRQ 103
580#define SIOF1_IPR_ADDR INTC_IPRI
581#define SIOF1_IPR_POS 1
582#define SIOF1_PRIORITY 7
583#endif /* CONFIG_CPU_SUBTYPE_SH7710 */
584
585#if defined(CONFIG_CPU_SUBTYPE_SH7710)
586#define PORT_PACR 0xa4050100UL
587#define PORT_PBCR 0xa4050102UL
588#define PORT_PCCR 0xa4050104UL
589#define PORT_PETCR 0xa4050106UL
590#define PORT_PADR 0xa4050120UL
591#define PORT_PBDR 0xa4050122UL
592#define PORT_PCDR 0xa4050124UL
593#else
594#define PORT_PACR 0xa4000100UL
595#define PORT_PBCR 0xa4000102UL
596#define PORT_PCCR 0xa4000104UL
597#define PORT_PFCR 0xa400010aUL
598#define PORT_PADR 0xa4000120UL
599#define PORT_PBDR 0xa4000122UL
600#define PORT_PCDR 0xa4000124UL
601#define PORT_PFDR 0xa400012aUL
602#endif
603
604#define IRQ0_IRQ 32
605#define IRQ1_IRQ 33
606#define IRQ2_IRQ 34
607#define IRQ3_IRQ 35
608#define IRQ4_IRQ 36
609#define IRQ5_IRQ 37
610
611#define IRQ0_IPR_ADDR INTC_IPRC
612#define IRQ1_IPR_ADDR INTC_IPRC
613#define IRQ2_IPR_ADDR INTC_IPRC
614#define IRQ3_IPR_ADDR INTC_IPRC
615#define IRQ4_IPR_ADDR INTC_IPRD
616#define IRQ5_IPR_ADDR INTC_IPRD
617
618#define IRQ0_IPR_POS 0
619#define IRQ1_IPR_POS 1
620#define IRQ2_IPR_POS 2
621#define IRQ3_IPR_POS 3
622#define IRQ4_IPR_POS 0
623#define IRQ5_IPR_POS 1
624
625#define IRQ0_PRIORITY 1
626#define IRQ1_PRIORITY 1
627#define IRQ2_PRIORITY 1
628#define IRQ3_PRIORITY 1
629#define IRQ4_PRIORITY 1
630#define IRQ5_PRIORITY 1
631
632#define PINT0_IRQ 40
633#define PINT8_IRQ 41
634
635#define PINT0_IPR_ADDR INTC_IPRD
636#define PINT8_IPR_ADDR INTC_IPRD
637
638#define PINT0_IPR_POS 3
639#define PINT8_IPR_POS 2
640#define PINT0_PRIORITY 2
641#define PINT8_PRIORITY 2
642
643extern int ipr_irq_demux(int irq);
644#define __irq_demux(irq) ipr_irq_demux(irq)
645#endif /* CONFIG_CPU_SUBTYPE_SH7707 || CONFIG_CPU_SUBTYPE_SH7709 */
646
647#if defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751) || \
648 defined(CONFIG_CPU_SUBTYPE_ST40STB1) || defined(CONFIG_CPU_SUBTYPE_SH4_202)
649#define INTC_ICR 0xffd00000
650#define INTC_ICR_NMIL (1<<15)
651#define INTC_ICR_MAI (1<<14)
652#define INTC_ICR_NMIB (1<<9)
653#define INTC_ICR_NMIE (1<<8)
654#define INTC_ICR_IRLM (1<<7)
655#endif
656
657#ifdef CONFIG_CPU_SUBTYPE_SH7780
658#include <asm/irq-sh7780.h>
659#endif
660
661/* SH with INTC2-style interrupts */
662#ifdef CONFIG_CPU_HAS_INTC2_IRQ
663#if defined(CONFIG_CPU_SUBTYPE_ST40STB1)
664#define INTC2_BASE 0xfe080000
665#define INTC2_FIRST_IRQ 64
666#define INTC2_INTREQ_OFFSET 0x20
667#define INTC2_INTMSK_OFFSET 0x40
668#define INTC2_INTMSKCLR_OFFSET 0x60
669#define NR_INTC2_IRQS 25
670#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
671#define INTC2_BASE 0xfe080000
672#define INTC2_FIRST_IRQ 48 /* INTEVT 0x800 */
673#define INTC2_INTREQ_OFFSET 0x20
674#define INTC2_INTMSK_OFFSET 0x40
675#define INTC2_INTMSKCLR_OFFSET 0x60
676#define NR_INTC2_IRQS 64
677#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
678#define INTC2_BASE 0xffd40000
679#define INTC2_FIRST_IRQ 21
680#define INTC2_INTMSK_OFFSET (0x38)
681#define INTC2_INTMSKCLR_OFFSET (0x3c)
682#define NR_INTC2_IRQS 60
683#endif
684 135
685#define INTC2_INTPRI_OFFSET 0x00 136/*
137 * Function for "on chip support modules".
138 */
139void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
140void make_imask_irq(unsigned int irq);
141void init_IRQ_ipr(void);
686 142
687struct intc2_data { 143struct intc2_data {
688 unsigned short irq; 144 unsigned short irq;
@@ -693,20 +149,14 @@ struct intc2_data {
693 149
694void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs); 150void make_intc2_irq(struct intc2_data *, unsigned int nr_irqs);
695void init_IRQ_intc2(void); 151void init_IRQ_intc2(void);
696#endif
697
698extern int shmse_irq_demux(int irq);
699 152
700static inline int generic_irq_demux(int irq) 153static inline int generic_irq_demux(int irq)
701{ 154{
702 return irq; 155 return irq;
703} 156}
704 157
705#ifndef __irq_demux
706#define __irq_demux(irq) (irq)
707#endif
708#define irq_canonicalize(irq) (irq) 158#define irq_canonicalize(irq) (irq)
709#define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq)) 159#define irq_demux(irq) sh_mv.mv_irq_demux(irq)
710 160
711#ifdef CONFIG_4KSTACKS 161#ifdef CONFIG_4KSTACKS
712extern void irq_ctx_init(int cpu); 162extern void irq_ctx_init(int cpu);
@@ -717,12 +167,4 @@ extern void irq_ctx_exit(int cpu);
717# define irq_ctx_exit(cpu) do { } while (0) 167# define irq_ctx_exit(cpu) do { } while (0)
718#endif 168#endif
719 169
720#if defined(CONFIG_CPU_SUBTYPE_SH73180)
721#include <asm/irq-sh73180.h>
722#endif
723
724#if defined(CONFIG_CPU_SUBTYPE_SH7343)
725#include <asm/irq-sh7343.h>
726#endif
727
728#endif /* __ASM_SH_IRQ_H */ 170#endif /* __ASM_SH_IRQ_H */
diff --git a/include/asm-sh/irqflags.h b/include/asm-sh/irqflags.h
new file mode 100644
index 000000000000..9dedc1b693e3
--- /dev/null
+++ b/include/asm-sh/irqflags.h
@@ -0,0 +1,123 @@
1#ifndef __ASM_SH_IRQFLAGS_H
2#define __ASM_SH_IRQFLAGS_H
3
4static inline void raw_local_irq_enable(void)
5{
6 unsigned long __dummy0, __dummy1;
7
8 __asm__ __volatile__ (
9 "stc sr, %0\n\t"
10 "and %1, %0\n\t"
11#ifdef CONFIG_CPU_HAS_SR_RB
12 "stc r6_bank, %1\n\t"
13 "or %1, %0\n\t"
14#endif
15 "ldc %0, sr\n\t"
16 : "=&r" (__dummy0), "=r" (__dummy1)
17 : "1" (~0x000000f0)
18 : "memory"
19 );
20}
21
22static inline void raw_local_irq_disable(void)
23{
24 unsigned long flags;
25
26 __asm__ __volatile__ (
27 "stc sr, %0\n\t"
28 "or #0xf0, %0\n\t"
29 "ldc %0, sr\n\t"
30 : "=&z" (flags)
31 : /* no inputs */
32 : "memory"
33 );
34}
35
36static inline void set_bl_bit(void)
37{
38 unsigned long __dummy0, __dummy1;
39
40 __asm__ __volatile__ (
41 "stc sr, %0\n\t"
42 "or %2, %0\n\t"
43 "and %3, %0\n\t"
44 "ldc %0, sr\n\t"
45 : "=&r" (__dummy0), "=r" (__dummy1)
46 : "r" (0x10000000), "r" (0xffffff0f)
47 : "memory"
48 );
49}
50
51static inline void clear_bl_bit(void)
52{
53 unsigned long __dummy0, __dummy1;
54
55 __asm__ __volatile__ (
56 "stc sr, %0\n\t"
57 "and %2, %0\n\t"
58 "ldc %0, sr\n\t"
59 : "=&r" (__dummy0), "=r" (__dummy1)
60 : "1" (~0x10000000)
61 : "memory"
62 );
63}
64
65static inline unsigned long __raw_local_save_flags(void)
66{
67 unsigned long flags;
68
69 __asm__ __volatile__ (
70 "stc sr, %0\n\t"
71 "and #0xf0, %0\n\t"
72 : "=&z" (flags)
73 : /* no inputs */
74 : "memory"
75 );
76
77 return flags;
78}
79
80#define raw_local_save_flags(flags) \
81 do { (flags) = __raw_local_save_flags(); } while (0)
82
83static inline int raw_irqs_disabled_flags(unsigned long flags)
84{
85 return (flags != 0);
86}
87
88static inline int raw_irqs_disabled(void)
89{
90 unsigned long flags = __raw_local_save_flags();
91
92 return raw_irqs_disabled_flags(flags);
93}
94
95static inline unsigned long __raw_local_irq_save(void)
96{
97 unsigned long flags, __dummy;
98
99 __asm__ __volatile__ (
100 "stc sr, %1\n\t"
101 "mov %1, %0\n\t"
102 "or #0xf0, %0\n\t"
103 "ldc %0, sr\n\t"
104 "mov %1, %0\n\t"
105 "and #0xf0, %0\n\t"
106 : "=&z" (flags), "=&r" (__dummy)
107 : /* no inputs */
108 : "memory"
109 );
110
111 return flags;
112}
113
114#define raw_local_irq_save(flags) \
115 do { (flags) = __raw_local_irq_save(); } while (0)
116
117static inline void raw_local_irq_restore(unsigned long flags)
118{
119 if ((flags & 0xf0) != 0xf0)
120 raw_local_irq_enable();
121}
122
123#endif /* __ASM_SH_IRQFLAGS_H */
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index c7088efe579a..46f04e23bd45 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -10,7 +10,6 @@
10 10
11#include <asm/cpu/mmu_context.h> 11#include <asm/cpu/mmu_context.h>
12#include <asm/tlbflush.h> 12#include <asm/tlbflush.h>
13#include <asm/pgalloc.h>
14#include <asm/uaccess.h> 13#include <asm/uaccess.h>
15#include <asm/io.h> 14#include <asm/io.h>
16 15
@@ -42,10 +41,8 @@ extern unsigned long mmu_context_cache;
42/* 41/*
43 * Get MMU context if needed. 42 * Get MMU context if needed.
44 */ 43 */
45static __inline__ void 44static inline void get_mmu_context(struct mm_struct *mm)
46get_mmu_context(struct mm_struct *mm)
47{ 45{
48 extern void flush_tlb_all(void);
49 unsigned long mc = mmu_context_cache; 46 unsigned long mc = mmu_context_cache;
50 47
51 /* Check if we have old version of context. */ 48 /* Check if we have old version of context. */
@@ -61,6 +58,7 @@ get_mmu_context(struct mm_struct *mm)
61 * Flush all TLB and start new cycle. 58 * Flush all TLB and start new cycle.
62 */ 59 */
63 flush_tlb_all(); 60 flush_tlb_all();
61
64 /* 62 /*
65 * Fix version; Note that we avoid version #0 63 * Fix version; Note that we avoid version #0
66 * to distingush NO_CONTEXT. 64 * to distingush NO_CONTEXT.
@@ -75,11 +73,10 @@ get_mmu_context(struct mm_struct *mm)
75 * Initialize the context related info for a new mm_struct 73 * Initialize the context related info for a new mm_struct
76 * instance. 74 * instance.
77 */ 75 */
78static __inline__ int init_new_context(struct task_struct *tsk, 76static inline int init_new_context(struct task_struct *tsk,
79 struct mm_struct *mm) 77 struct mm_struct *mm)
80{ 78{
81 mm->context.id = NO_CONTEXT; 79 mm->context.id = NO_CONTEXT;
82
83 return 0; 80 return 0;
84} 81}
85 82
@@ -87,12 +84,12 @@ static __inline__ int init_new_context(struct task_struct *tsk,
87 * Destroy context related info for an mm_struct that is about 84 * Destroy context related info for an mm_struct that is about
88 * to be put to rest. 85 * to be put to rest.
89 */ 86 */
90static __inline__ void destroy_context(struct mm_struct *mm) 87static inline void destroy_context(struct mm_struct *mm)
91{ 88{
92 /* Do nothing */ 89 /* Do nothing */
93} 90}
94 91
95static __inline__ void set_asid(unsigned long asid) 92static inline void set_asid(unsigned long asid)
96{ 93{
97 unsigned long __dummy; 94 unsigned long __dummy;
98 95
@@ -105,7 +102,7 @@ static __inline__ void set_asid(unsigned long asid)
105 "r" (0xffffff00)); 102 "r" (0xffffff00));
106} 103}
107 104
108static __inline__ unsigned long get_asid(void) 105static inline unsigned long get_asid(void)
109{ 106{
110 unsigned long asid; 107 unsigned long asid;
111 108
@@ -120,24 +117,29 @@ static __inline__ unsigned long get_asid(void)
120 * After we have set current->mm to a new value, this activates 117 * After we have set current->mm to a new value, this activates
121 * the context for the new mm so we see the new mappings. 118 * the context for the new mm so we see the new mappings.
122 */ 119 */
123static __inline__ void activate_context(struct mm_struct *mm) 120static inline void activate_context(struct mm_struct *mm)
124{ 121{
125 get_mmu_context(mm); 122 get_mmu_context(mm);
126 set_asid(mm->context.id & MMU_CONTEXT_ASID_MASK); 123 set_asid(mm->context.id & MMU_CONTEXT_ASID_MASK);
127} 124}
128 125
129/* MMU_TTB can be used for optimizing the fault handling. 126/* MMU_TTB is used for optimizing the fault handling. */
130 (Currently not used) */ 127static inline void set_TTB(pgd_t *pgd)
131static __inline__ void switch_mm(struct mm_struct *prev,
132 struct mm_struct *next,
133 struct task_struct *tsk)
134{ 128{
135 if (likely(prev != next)) { 129 ctrl_outl((unsigned long)pgd, MMU_TTB);
136 unsigned long __pgdir = (unsigned long)next->pgd; 130}
137 131
138 __asm__ __volatile__("mov.l %0, %1" 132static inline pgd_t *get_TTB(void)
139 : /* no output */ 133{
140 : "r" (__pgdir), "m" (__m(MMU_TTB))); 134 return (pgd_t *)ctrl_inl(MMU_TTB);
135}
136
137static inline void switch_mm(struct mm_struct *prev,
138 struct mm_struct *next,
139 struct task_struct *tsk)
140{
141 if (likely(prev != next)) {
142 set_TTB(next->pgd);
141 activate_context(next); 143 activate_context(next);
142 } 144 }
143} 145}
@@ -147,7 +149,7 @@ static __inline__ void switch_mm(struct mm_struct *prev,
147#define activate_mm(prev, next) \ 149#define activate_mm(prev, next) \
148 switch_mm((prev),(next),NULL) 150 switch_mm((prev),(next),NULL)
149 151
150static __inline__ void 152static inline void
151enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) 153enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
152{ 154{
153} 155}
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index ca8b26d90475..380fd62dd05a 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -13,9 +13,16 @@
13 [ P4 control ] 0xE0000000 13 [ P4 control ] 0xE0000000
14 */ 14 */
15 15
16
17/* PAGE_SHIFT determines the page size */ 16/* PAGE_SHIFT determines the page size */
18#define PAGE_SHIFT 12 17#if defined(CONFIG_PAGE_SIZE_4KB)
18# define PAGE_SHIFT 12
19#elif defined(CONFIG_PAGE_SIZE_8KB)
20# define PAGE_SHIFT 13
21#elif defined(CONFIG_PAGE_SIZE_64KB)
22# define PAGE_SHIFT 16
23#else
24# error "Bogus kernel page size?"
25#endif
19 26
20#ifdef __ASSEMBLY__ 27#ifdef __ASSEMBLY__
21#define PAGE_SIZE (1 << PAGE_SHIFT) 28#define PAGE_SIZE (1 << PAGE_SHIFT)
@@ -28,8 +35,14 @@
28 35
29#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 36#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
30#define HPAGE_SHIFT 16 37#define HPAGE_SHIFT 16
38#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
39#define HPAGE_SHIFT 18
31#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) 40#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
32#define HPAGE_SHIFT 20 41#define HPAGE_SHIFT 20
42#elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
43#define HPAGE_SHIFT 22
44#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
45#define HPAGE_SHIFT 26
33#endif 46#endif
34 47
35#ifdef CONFIG_HUGETLB_PAGE 48#ifdef CONFIG_HUGETLB_PAGE
@@ -69,15 +82,25 @@ extern void __copy_user_page(void *to, void *from, void *orig_to);
69/* 82/*
70 * These are used to make use of C type-checking.. 83 * These are used to make use of C type-checking..
71 */ 84 */
72typedef struct { unsigned long pte; } pte_t; 85#ifdef CONFIG_X2TLB
73typedef struct { unsigned long pgd; } pgd_t; 86typedef struct { unsigned long pte_low, pte_high; } pte_t;
87typedef struct { unsigned long long pgprot; } pgprot_t;
88#define pte_val(x) \
89 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
90#define __pte(x) \
91 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
92#else
93typedef struct { unsigned long pte_low; } pte_t;
74typedef struct { unsigned long pgprot; } pgprot_t; 94typedef struct { unsigned long pgprot; } pgprot_t;
95#define pte_val(x) ((x).pte_low)
96#define __pte(x) ((pte_t) { (x) } )
97#endif
98
99typedef struct { unsigned long pgd; } pgd_t;
75 100
76#define pte_val(x) ((x).pte)
77#define pgd_val(x) ((x).pgd) 101#define pgd_val(x) ((x).pgd)
78#define pgprot_val(x) ((x).pgprot) 102#define pgprot_val(x) ((x).pgprot)
79 103
80#define __pte(x) ((pte_t) { (x) } )
81#define __pgd(x) ((pgd_t) { (x) } ) 104#define __pgd(x) ((pgd_t) { (x) } )
82#define __pgprot(x) ((pgprot_t) { (x) } ) 105#define __pgprot(x) ((pgprot_t) { (x) } )
83 106
diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h
index e841465ab4d2..888e4529e6fe 100644
--- a/include/asm-sh/pgalloc.h
+++ b/include/asm-sh/pgalloc.h
@@ -1,13 +1,16 @@
1#ifndef __ASM_SH_PGALLOC_H 1#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H 2#define __ASM_SH_PGALLOC_H
3 3
4#define pmd_populate_kernel(mm, pmd, pte) \ 4static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
5 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) 5 pte_t *pte)
6{
7 set_pmd(pmd, __pmd((unsigned long)pte));
8}
6 9
7static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, 10static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
8 struct page *pte) 11 struct page *pte)
9{ 12{
10 set_pmd(pmd, __pmd(_PAGE_TABLE + page_to_phys(pte))); 13 set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
11} 14}
12 15
13/* 16/*
@@ -15,7 +18,16 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
15 */ 18 */
16static inline pgd_t *pgd_alloc(struct mm_struct *mm) 19static inline pgd_t *pgd_alloc(struct mm_struct *mm)
17{ 20{
18 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO); 21 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT);
22
23 if (pgd) {
24 memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
25 memcpy(pgd + USER_PTRS_PER_PGD,
26 swapper_pg_dir + USER_PTRS_PER_PGD,
27 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
28 }
29
30 return pgd;
19} 31}
20 32
21static inline void pgd_free(pgd_t *pgd) 33static inline void pgd_free(pgd_t *pgd)
diff --git a/include/asm-sh/pgtable-2level.h b/include/asm-sh/pgtable-2level.h
deleted file mode 100644
index b525db6f61c6..000000000000
--- a/include/asm-sh/pgtable-2level.h
+++ /dev/null
@@ -1,70 +0,0 @@
1#ifndef __ASM_SH_PGTABLE_2LEVEL_H
2#define __ASM_SH_PGTABLE_2LEVEL_H
3
4/*
5 * traditional two-level paging structure:
6 */
7
8#define PGDIR_SHIFT 22
9#define PTRS_PER_PGD 1024
10
11/*
12 * this is two-level, so we don't really have any
13 * PMD directory physically.
14 */
15#define PMD_SHIFT 22
16#define PTRS_PER_PMD 1
17
18#define PTRS_PER_PTE 1024
19
20#ifndef __ASSEMBLY__
21#define pte_ERROR(e) \
22 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
23#define pmd_ERROR(e) \
24 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
25#define pgd_ERROR(e) \
26 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
27
28/*
29 * The "pgd_xxx()" functions here are trivial for a folded two-level
30 * setup: the pgd is never bad, and a pmd always exists (as it's folded
31 * into the pgd entry)
32 */
33static inline int pgd_none(pgd_t pgd) { return 0; }
34static inline int pgd_bad(pgd_t pgd) { return 0; }
35static inline int pgd_present(pgd_t pgd) { return 1; }
36static inline void pgd_clear (pgd_t * pgdp) { }
37
38/*
39 * Certain architectures need to do special things when PTEs
40 * within a page table are directly modified. Thus, the following
41 * hook is made available.
42 */
43#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
44#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
45
46/*
47 * (pmds are folded into pgds so this doesn't get actually called,
48 * but the define is needed for a generic inline function.)
49 */
50#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
51#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
52
53#define pgd_page_vaddr(pgd) \
54((unsigned long) __va(pgd_val(pgd) & PAGE_MASK))
55
56#define pgd_page(pgd) \
57 (phys_to_page(pgd_val(pgd)))
58
59static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
60{
61 return (pmd_t *) dir;
62}
63
64#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
65#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
66#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
67
68#endif /* !__ASSEMBLY__ */
69
70#endif /* __ASM_SH_PGTABLE_2LEVEL_H */
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index 2c8682ad1012..c84901dbd8e5 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -15,15 +15,10 @@
15#include <asm-generic/pgtable-nopmd.h> 15#include <asm-generic/pgtable-nopmd.h>
16#include <asm/page.h> 16#include <asm/page.h>
17 17
18#define PTRS_PER_PGD 1024
19
20#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
21#include <asm/addrspace.h> 19#include <asm/addrspace.h>
22#include <asm/fixmap.h> 20#include <asm/fixmap.h>
23 21
24extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
25extern void paging_init(void);
26
27/* 22/*
28 * ZERO_PAGE is a global shared page that is always zero: used 23 * ZERO_PAGE is a global shared page that is always zero: used
29 * for zero-mapped memory areas etc.. 24 * for zero-mapped memory areas etc..
@@ -33,15 +28,28 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
33 28
34#endif /* !__ASSEMBLY__ */ 29#endif /* !__ASSEMBLY__ */
35 30
36/* traditional two-level paging structure */ 31/*
37#define PGDIR_SHIFT 22 32 * traditional two-level paging structure
38#define PTRS_PER_PMD 1 33 */
39#define PTRS_PER_PTE 1024 34/* PTE bits */
40#define PMD_SIZE (1UL << PMD_SHIFT) 35#ifdef CONFIG_X2TLB
41#define PMD_MASK (~(PMD_SIZE-1)) 36# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
42#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 37#else
38# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
39#endif
40#define PTE_SHIFT PAGE_SHIFT
41#define PTE_BITS (PTE_SHIFT - PTE_MAGNITUDE)
42
43/* PGD bits */
44#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
45#define PGDIR_BITS (32 - PGDIR_SHIFT)
46#define PGDIR_SIZE (1 << PGDIR_SHIFT)
43#define PGDIR_MASK (~(PGDIR_SIZE-1)) 47#define PGDIR_MASK (~(PGDIR_SIZE-1))
44 48
49/* Entries per level */
50#define PTRS_PER_PTE (PAGE_SIZE / 4)
51#define PTRS_PER_PGD (PAGE_SIZE / 4)
52
45#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 53#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
46#define FIRST_USER_ADDRESS 0 54#define FIRST_USER_ADDRESS 0
47 55
@@ -49,7 +57,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
49 57
50/* 58/*
51 * First 1MB map is used by fixed purpose. 59 * First 1MB map is used by fixed purpose.
52 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) 60 * Currently only 4-entry (16kB) is used (see arch/sh/mm/cache.c)
53 */ 61 */
54#define VMALLOC_START (P3SEG+0x00100000) 62#define VMALLOC_START (P3SEG+0x00100000)
55#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 63#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
@@ -57,7 +65,8 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
57/* 65/*
58 * Linux PTEL encoding. 66 * Linux PTEL encoding.
59 * 67 *
60 * Hardware and software bit definitions for the PTEL value: 68 * Hardware and software bit definitions for the PTEL value (see below for
69 * notes on SH-X2 MMUs and 64-bit PTEs):
61 * 70 *
62 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4). 71 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4).
63 * 72 *
@@ -76,20 +85,57 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
76 * 85 *
77 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future 86 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future
78 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS. 87 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS.
88 *
89 * XXX: Leave the _PAGE_FILE and _PAGE_WT overhaul for a rainy day.
90 *
91 * SH-X2 MMUs and extended PTEs
92 *
93 * SH-X2 supports an extended mode TLB with split data arrays due to the
94 * number of bits needed for PR and SZ (now EPR and ESZ) encodings. The PR and
95 * SZ bit placeholders still exist in data array 1, but are implemented as
96 * reserved bits, with the real logic existing in data array 2.
97 *
98 * The downside to this is that we can no longer fit everything in to a 32-bit
99 * PTE encoding, so a 64-bit pte_t is necessary for these parts. On the plus
100 * side, this gives us quite a few spare bits to play with for future usage.
79 */ 101 */
102/* Legacy and compat mode bits */
80#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */ 103#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */
81#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */ 104#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */
82#define _PAGE_DIRTY 0x004 /* D-bit : page changed */ 105#define _PAGE_DIRTY 0x004 /* D-bit : page changed */
83#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */ 106#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */
84#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */ 107#ifndef CONFIG_X2TLB
85#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */ 108# define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */
86#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */ 109# define _PAGE_RW 0x020 /* PR0-bit : write access allowed */
87#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ 110# define _PAGE_USER 0x040 /* PR1-bit : user space access allowed*/
111# define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
112#endif
88#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ 113#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
89#define _PAGE_PROTNONE 0x200 /* software: if not present */ 114#define _PAGE_PROTNONE 0x200 /* software: if not present */
90#define _PAGE_ACCESSED 0x400 /* software: page referenced */ 115#define _PAGE_ACCESSED 0x400 /* software: page referenced */
91#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ 116#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
92 117
118/* Extended mode bits */
119#define _PAGE_EXT_ESZ0 0x0010 /* ESZ0-bit: Size of page */
120#define _PAGE_EXT_ESZ1 0x0020 /* ESZ1-bit: Size of page */
121#define _PAGE_EXT_ESZ2 0x0040 /* ESZ2-bit: Size of page */
122#define _PAGE_EXT_ESZ3 0x0080 /* ESZ3-bit: Size of page */
123
124#define _PAGE_EXT_USER_EXEC 0x0100 /* EPR0-bit: User space executable */
125#define _PAGE_EXT_USER_WRITE 0x0200 /* EPR1-bit: User space writable */
126#define _PAGE_EXT_USER_READ 0x0400 /* EPR2-bit: User space readable */
127
128#define _PAGE_EXT_KERN_EXEC 0x0800 /* EPR3-bit: Kernel space executable */
129#define _PAGE_EXT_KERN_WRITE 0x1000 /* EPR4-bit: Kernel space writable */
130#define _PAGE_EXT_KERN_READ 0x2000 /* EPR5-bit: Kernel space readable */
131
132/* Wrapper for extended mode pgprot twiddling */
133#ifdef CONFIG_X2TLB
134# define _PAGE_EXT(x) ((unsigned long long)(x) << 32)
135#else
136# define _PAGE_EXT(x) (0)
137#endif
138
93/* software: moves to PTEA.TC (Timing Control) */ 139/* software: moves to PTEA.TC (Timing Control) */
94#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ 140#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */
95#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */ 141#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */
@@ -114,37 +160,160 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
114 160
115#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 161#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS))
116 162
117/* Hardware flags: SZ0=1 (4k-byte) */ 163/* Hardware flags, page size encoding */
118#define _PAGE_FLAGS_HARD _PAGE_SZ0 164#if defined(CONFIG_X2TLB)
165# if defined(CONFIG_PAGE_SIZE_4KB)
166# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0)
167# elif defined(CONFIG_PAGE_SIZE_8KB)
168# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ1)
169# elif defined(CONFIG_PAGE_SIZE_64KB)
170# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ2)
171# endif
172#else
173# if defined(CONFIG_PAGE_SIZE_4KB)
174# define _PAGE_FLAGS_HARD _PAGE_SZ0
175# elif defined(CONFIG_PAGE_SIZE_64KB)
176# define _PAGE_FLAGS_HARD _PAGE_SZ1
177# endif
178#endif
119 179
120#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 180#if defined(CONFIG_X2TLB)
121#define _PAGE_SZHUGE (_PAGE_SZ1) 181# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
122#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB) 182# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2)
123#define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) 183# elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
184# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ2)
185# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
186# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ1 | _PAGE_EXT_ESZ2)
187# elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
188# define _PAGE_SZHUGE (_PAGE_EXT_ESZ3)
189# elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
190# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2 | _PAGE_EXT_ESZ3)
191# endif
192#else
193# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
194# define _PAGE_SZHUGE (_PAGE_SZ1)
195# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
196# define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1)
197# endif
198#endif
199
200/*
201 * Stub out _PAGE_SZHUGE if we don't have a good definition for it,
202 * to make pte_mkhuge() happy.
203 */
204#ifndef _PAGE_SZHUGE
205# define _PAGE_SZHUGE (_PAGE_FLAGS_HARD)
124#endif 206#endif
125 207
126#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) 208#define _PAGE_CHG_MASK \
127#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 209 (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
128#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
129 210
130#ifndef __ASSEMBLY__ 211#ifndef __ASSEMBLY__
131 212
132#ifdef CONFIG_MMU 213#if defined(CONFIG_X2TLB) /* SH-X2 TLB */
133#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 214#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
134#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 215 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
135#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 216
136#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 217#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
137#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 218 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
219 _PAGE_EXT(_PAGE_EXT_USER_READ | \
220 _PAGE_EXT_USER_WRITE))
221
222#define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
223 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
224 _PAGE_EXT(_PAGE_EXT_USER_EXEC | \
225 _PAGE_EXT_USER_READ))
226
227#define PAGE_COPY PAGE_EXECREAD
228
229#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
230 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
231 _PAGE_EXT(_PAGE_EXT_USER_READ))
232
233#define PAGE_WRITEONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
234 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
235 _PAGE_EXT(_PAGE_EXT_USER_WRITE))
236
237#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
238 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
239 _PAGE_EXT(_PAGE_EXT_USER_WRITE | \
240 _PAGE_EXT_USER_READ | \
241 _PAGE_EXT_USER_EXEC))
242
243#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
244 _PAGE_DIRTY | _PAGE_ACCESSED | \
245 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
246 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
247 _PAGE_EXT_KERN_WRITE | \
248 _PAGE_EXT_KERN_EXEC))
249
138#define PAGE_KERNEL_NOCACHE \ 250#define PAGE_KERNEL_NOCACHE \
139 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 251 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
140#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 252 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
253 _PAGE_FLAGS_HARD | \
254 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
255 _PAGE_EXT_KERN_WRITE | \
256 _PAGE_EXT_KERN_EXEC))
257
258#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
259 _PAGE_DIRTY | _PAGE_ACCESSED | \
260 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
261 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
262 _PAGE_EXT_KERN_EXEC))
263
264#define PAGE_KERNEL_PCC(slot, type) \
265 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
266 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
267 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
268 _PAGE_EXT_KERN_WRITE | \
269 _PAGE_EXT_KERN_EXEC) \
270 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
271 (type))
272
273#elif defined(CONFIG_MMU) /* SH-X TLB */
274#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
275 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
276
277#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
278 _PAGE_CACHABLE | _PAGE_ACCESSED | \
279 _PAGE_FLAGS_HARD)
280
281#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
282 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
283
284#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
285 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
286
287#define PAGE_EXECREAD PAGE_READONLY
288#define PAGE_RWX PAGE_SHARED
289#define PAGE_WRITEONLY PAGE_SHARED
290
291#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | \
292 _PAGE_DIRTY | _PAGE_ACCESSED | \
293 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
294
295#define PAGE_KERNEL_NOCACHE \
296 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
297 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
298 _PAGE_FLAGS_HARD)
299
300#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
301 _PAGE_DIRTY | _PAGE_ACCESSED | \
302 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
303
141#define PAGE_KERNEL_PCC(slot, type) \ 304#define PAGE_KERNEL_PCC(slot, type) \
142 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_FLAGS_HARD | (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | (type)) 305 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
306 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
307 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
308 (type))
143#else /* no mmu */ 309#else /* no mmu */
144#define PAGE_NONE __pgprot(0) 310#define PAGE_NONE __pgprot(0)
145#define PAGE_SHARED __pgprot(0) 311#define PAGE_SHARED __pgprot(0)
146#define PAGE_COPY __pgprot(0) 312#define PAGE_COPY __pgprot(0)
313#define PAGE_EXECREAD __pgprot(0)
314#define PAGE_RWX __pgprot(0)
147#define PAGE_READONLY __pgprot(0) 315#define PAGE_READONLY __pgprot(0)
316#define PAGE_WRITEONLY __pgprot(0)
148#define PAGE_KERNEL __pgprot(0) 317#define PAGE_KERNEL __pgprot(0)
149#define PAGE_KERNEL_NOCACHE __pgprot(0) 318#define PAGE_KERNEL_NOCACHE __pgprot(0)
150#define PAGE_KERNEL_RO __pgprot(0) 319#define PAGE_KERNEL_RO __pgprot(0)
@@ -154,27 +323,32 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
154#endif /* __ASSEMBLY__ */ 323#endif /* __ASSEMBLY__ */
155 324
156/* 325/*
157 * As i386 and MIPS, SuperH can't do page protection for execute, and 326 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
158 * considers that the same as a read. Also, write permissions imply 327 * protection for execute, and considers it the same as a read. Also, write
159 * read permissions. This is the closest we can get.. 328 * permission implies read permission. This is the closest we can get..
329 *
330 * SH-X2 (SH7785) and later parts take this to the opposite end of the extreme,
331 * not only supporting separate execute, read, and write bits, but having
332 * completely separate permission bits for user and kernel space.
160 */ 333 */
334 /*xwr*/
161#define __P000 PAGE_NONE 335#define __P000 PAGE_NONE
162#define __P001 PAGE_READONLY 336#define __P001 PAGE_READONLY
163#define __P010 PAGE_COPY 337#define __P010 PAGE_COPY
164#define __P011 PAGE_COPY 338#define __P011 PAGE_COPY
165#define __P100 PAGE_READONLY 339#define __P100 PAGE_EXECREAD
166#define __P101 PAGE_READONLY 340#define __P101 PAGE_EXECREAD
167#define __P110 PAGE_COPY 341#define __P110 PAGE_COPY
168#define __P111 PAGE_COPY 342#define __P111 PAGE_COPY
169 343
170#define __S000 PAGE_NONE 344#define __S000 PAGE_NONE
171#define __S001 PAGE_READONLY 345#define __S001 PAGE_READONLY
172#define __S010 PAGE_SHARED 346#define __S010 PAGE_WRITEONLY
173#define __S011 PAGE_SHARED 347#define __S011 PAGE_SHARED
174#define __S100 PAGE_READONLY 348#define __S100 PAGE_EXECREAD
175#define __S101 PAGE_READONLY 349#define __S101 PAGE_EXECREAD
176#define __S110 PAGE_SHARED 350#define __S110 PAGE_RWX
177#define __S111 PAGE_SHARED 351#define __S111 PAGE_RWX
178 352
179#ifndef __ASSEMBLY__ 353#ifndef __ASSEMBLY__
180 354
@@ -183,7 +357,17 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
183 * within a page table are directly modified. Thus, the following 357 * within a page table are directly modified. Thus, the following
184 * hook is made available. 358 * hook is made available.
185 */ 359 */
360#ifdef CONFIG_X2TLB
361static inline void set_pte(pte_t *ptep, pte_t pte)
362{
363 ptep->pte_high = pte.pte_high;
364 smp_wmb();
365 ptep->pte_low = pte.pte_low;
366}
367#else
186#define set_pte(pteptr, pteval) (*(pteptr) = pteval) 368#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
369#endif
370
187#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 371#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
188 372
189/* 373/*
@@ -192,18 +376,18 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
192 */ 376 */
193#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) 377#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
194 378
195#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT))) 379#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
196#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 380#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
197#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 381#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
198 382
199#define pte_none(x) (!pte_val(x)) 383#define pte_none(x) (!pte_val(x))
200#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 384#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
201#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 385#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
202 386
203#define pmd_none(x) (!pmd_val(x)) 387#define pmd_none(x) (!pmd_val(x))
204#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 388#define pmd_present(x) (pmd_val(x))
205#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) 389#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
206#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 390#define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK)
207 391
208#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 392#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
209#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) 393#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK)
@@ -212,28 +396,52 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
212 * The following only work if pte_present() is true. 396 * The following only work if pte_present() is true.
213 * Undefined behaviour if not.. 397 * Undefined behaviour if not..
214 */ 398 */
215static inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 399#define pte_not_present(pte) (!(pte_val(pte) & _PAGE_PRESENT))
216static inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 400#define pte_dirty(pte) (pte_val(pte) & _PAGE_DIRTY)
217static inline int pte_dirty(pte_t pte){ return pte_val(pte) & _PAGE_DIRTY; } 401#define pte_young(pte) (pte_val(pte) & _PAGE_ACCESSED)
218static inline int pte_young(pte_t pte){ return pte_val(pte) & _PAGE_ACCESSED; } 402#define pte_file(pte) (pte_val(pte) & _PAGE_FILE)
219static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 403
220static inline int pte_write(pte_t pte){ return pte_val(pte) & _PAGE_RW; } 404#ifdef CONFIG_X2TLB
221static inline int pte_not_present(pte_t pte){ return !(pte_val(pte) & _PAGE_PRESENT); } 405#define pte_read(pte) ((pte).pte_high & _PAGE_EXT_USER_READ)
222 406#define pte_exec(pte) ((pte).pte_high & _PAGE_EXT_USER_EXEC)
223static inline pte_t pte_rdprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 407#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE)
224static inline pte_t pte_exprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_USER)); return pte; } 408#else
225static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; } 409#define pte_read(pte) (pte_val(pte) & _PAGE_USER)
226static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; } 410#define pte_exec(pte) (pte_val(pte) & _PAGE_USER)
227static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; } 411#define pte_write(pte) (pte_val(pte) & _PAGE_RW)
228static inline pte_t pte_mkread(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
229static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
230static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
231static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
232static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
233#ifdef CONFIG_HUGETLB_PAGE
234static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_SZHUGE)); return pte; }
235#endif 412#endif
236 413
414#define PTE_BIT_FUNC(h,fn,op) \
415static inline pte_t pte_##fn(pte_t pte) { pte.pte_##h op; return pte; }
416
417#ifdef CONFIG_X2TLB
418/*
419 * We cheat a bit in the SH-X2 TLB case. As the permission bits are
420 * individually toggled (and user permissions are entirely decoupled from
421 * kernel permissions), we attempt to couple them a bit more sanely here.
422 */
423PTE_BIT_FUNC(high, rdprotect, &= ~_PAGE_EXT_USER_READ);
424PTE_BIT_FUNC(high, mkread, |= _PAGE_EXT_USER_READ | _PAGE_EXT_KERN_READ);
425PTE_BIT_FUNC(high, wrprotect, &= ~_PAGE_EXT_USER_WRITE);
426PTE_BIT_FUNC(high, mkwrite, |= _PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE);
427PTE_BIT_FUNC(high, exprotect, &= ~_PAGE_EXT_USER_EXEC);
428PTE_BIT_FUNC(high, mkexec, |= _PAGE_EXT_USER_EXEC | _PAGE_EXT_KERN_EXEC);
429PTE_BIT_FUNC(high, mkhuge, |= _PAGE_SZHUGE);
430#else
431PTE_BIT_FUNC(low, rdprotect, &= ~_PAGE_USER);
432PTE_BIT_FUNC(low, mkread, |= _PAGE_USER);
433PTE_BIT_FUNC(low, wrprotect, &= ~_PAGE_RW);
434PTE_BIT_FUNC(low, mkwrite, |= _PAGE_RW);
435PTE_BIT_FUNC(low, exprotect, &= ~_PAGE_USER);
436PTE_BIT_FUNC(low, mkexec, |= _PAGE_USER);
437PTE_BIT_FUNC(low, mkhuge, |= _PAGE_SZHUGE);
438#endif
439
440PTE_BIT_FUNC(low, mkclean, &= ~_PAGE_DIRTY);
441PTE_BIT_FUNC(low, mkdirty, |= _PAGE_DIRTY);
442PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
443PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
444
237/* 445/*
238 * Macro and implementation to make a page protection as uncachable. 446 * Macro and implementation to make a page protection as uncachable.
239 */ 447 */
@@ -258,13 +466,14 @@ static inline pgprot_t pgprot_noncached(pgprot_t _prot)
258#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 466#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
259 467
260static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 468static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
261{ set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot))); return pte; } 469{
262 470 set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) |
263#define pmd_page_vaddr(pmd) \ 471 pgprot_val(newprot)));
264((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 472 return pte;
473}
265 474
266#define pmd_page(pmd) \ 475#define pmd_page_vaddr(pmd) pmd_val(pmd)
267 (phys_to_page(pmd_val(pmd))) 476#define pmd_page(pmd) (virt_to_page(pmd_val(pmd)))
268 477
269/* to find an entry in a page-table-directory. */ 478/* to find an entry in a page-table-directory. */
270#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 479#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
@@ -283,8 +492,15 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
283#define pte_unmap(pte) do { } while (0) 492#define pte_unmap(pte) do { } while (0)
284#define pte_unmap_nested(pte) do { } while (0) 493#define pte_unmap_nested(pte) do { } while (0)
285 494
495#ifdef CONFIG_X2TLB
496#define pte_ERROR(e) \
497 printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \
498 &(e), (e).pte_high, (e).pte_low)
499#else
286#define pte_ERROR(e) \ 500#define pte_ERROR(e) \
287 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) 501 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
502#endif
503
288#define pgd_ERROR(e) \ 504#define pgd_ERROR(e) \
289 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) 505 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
290 506
@@ -337,6 +553,9 @@ extern unsigned int kobjsize(const void *objp);
337extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 553extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
338#endif 554#endif
339 555
556extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
557extern void paging_init(void);
558
340#include <asm-generic/pgtable.h> 559#include <asm-generic/pgtable.h>
341 560
342#endif /* !__ASSEMBLY__ */ 561#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index 45bb74e35d32..6f1dd7ca1b1d 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -36,7 +36,10 @@
36 */ 36 */
37enum cpu_type { 37enum cpu_type {
38 /* SH-2 types */ 38 /* SH-2 types */
39 CPU_SH7604, 39 CPU_SH7604, CPU_SH7619,
40
41 /* SH-2A types */
42 CPU_SH7206,
40 43
41 /* SH-3 types */ 44 /* SH-3 types */
42 CPU_SH7705, CPU_SH7706, CPU_SH7707, 45 CPU_SH7705, CPU_SH7706, CPU_SH7707,
@@ -47,7 +50,10 @@ enum cpu_type {
47 /* SH-4 types */ 50 /* SH-4 types */
48 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 51 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
49 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501, 52 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
53
54 /* SH-4A types */
50 CPU_SH73180, CPU_SH7343, CPU_SH7770, CPU_SH7780, CPU_SH7781, 55 CPU_SH73180, CPU_SH7343, CPU_SH7770, CPU_SH7780, CPU_SH7781,
56 CPU_SH7785,
51 57
52 /* Unknown subtype */ 58 /* Unknown subtype */
53 CPU_SH_NONE 59 CPU_SH_NONE
@@ -130,12 +136,11 @@ union sh_fpu_union {
130}; 136};
131 137
132struct thread_struct { 138struct thread_struct {
139 /* Saved registers when thread is descheduled */
133 unsigned long sp; 140 unsigned long sp;
134 unsigned long pc; 141 unsigned long pc;
135 142
136 unsigned long trap_no, error_code; 143 /* Hardware debugging registers */
137 unsigned long address;
138 /* Hardware debugging registers may come here */
139 unsigned long ubc_pc; 144 unsigned long ubc_pc;
140 145
141 /* floating point info */ 146 /* floating point info */
@@ -150,12 +155,7 @@ typedef struct {
150extern int ubc_usercnt; 155extern int ubc_usercnt;
151 156
152#define INIT_THREAD { \ 157#define INIT_THREAD { \
153 sizeof(init_stack) + (long) &init_stack, /* sp */ \ 158 .sp = sizeof(init_stack) + (long) &init_stack, \
154 0, /* pc */ \
155 0, 0, \
156 0, \
157 0, \
158 {{{0,}},} /* fpu state */ \
159} 159}
160 160
161/* 161/*
@@ -259,8 +259,8 @@ void show_trace(struct task_struct *tsk, unsigned long *sp,
259 struct pt_regs *regs); 259 struct pt_regs *regs);
260extern unsigned long get_wchan(struct task_struct *p); 260extern unsigned long get_wchan(struct task_struct *p);
261 261
262#define KSTK_EIP(tsk) ((tsk)->thread.pc) 262#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
263#define KSTK_ESP(tsk) ((tsk)->thread.sp) 263#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
264 264
265#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory") 265#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
266#define cpu_relax() barrier() 266#define cpu_relax() barrier()
diff --git a/include/asm-sh/push-switch.h b/include/asm-sh/push-switch.h
new file mode 100644
index 000000000000..dfc6bad567f0
--- /dev/null
+++ b/include/asm-sh/push-switch.h
@@ -0,0 +1,28 @@
1#ifndef __ASM_SH_PUSH_SWITCH_H
2#define __ASM_SH_PUSH_SWITCH_H
3
4#include <linux/timer.h>
5#include <linux/interrupt.h>
6#include <linux/workqueue.h>
7
8struct push_switch {
9 /* switch state */
10 unsigned int state:1;
11 /* debounce timer */
12 struct timer_list debounce;
13 /* workqueue */
14 struct work_struct work;
15};
16
17struct push_switch_platform_info {
18 /* IRQ handler */
19 irqreturn_t (*irq_handler)(int irq, void *data);
20 /* Special IRQ flags */
21 unsigned int irq_flags;
22 /* Bit location of switch */
23 unsigned int bit;
24 /* Symbolic switch name */
25 const char *name;
26};
27
28#endif /* __ASM_SH_PUSH_SWITCH_H */
diff --git a/include/asm-sh/rwsem.h b/include/asm-sh/rwsem.h
index 9d2aea5e8488..4931ba817d73 100644
--- a/include/asm-sh/rwsem.h
+++ b/include/asm-sh/rwsem.h
@@ -25,11 +25,21 @@ struct rw_semaphore {
25#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 25#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
26 spinlock_t wait_lock; 26 spinlock_t wait_lock;
27 struct list_head wait_list; 27 struct list_head wait_list;
28#ifdef CONFIG_DEBUG_LOCK_ALLOC
29 struct lockdep_map dep_map;
30#endif
28}; 31};
29 32
33#ifdef CONFIG_DEBUG_LOCK_ALLOC
34# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
35#else
36# define __RWSEM_DEP_MAP_INIT(lockname)
37#endif
38
30#define __RWSEM_INITIALIZER(name) \ 39#define __RWSEM_INITIALIZER(name) \
31 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \ 40 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \
32 LIST_HEAD_INIT((name).wait_list) } 41 LIST_HEAD_INIT((name).wait_list) \
42 __RWSEM_DEP_MAP_INIT(name) }
33 43
34#define DECLARE_RWSEM(name) \ 44#define DECLARE_RWSEM(name) \
35 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 45 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
@@ -39,6 +49,16 @@ extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
39extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem); 49extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
40extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem); 50extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
41 51
52extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
53 struct lock_class_key *key);
54
55#define init_rwsem(sem) \
56do { \
57 static struct lock_class_key __key; \
58 \
59 __init_rwsem((sem), #sem, &__key); \
60} while (0)
61
42static inline void init_rwsem(struct rw_semaphore *sem) 62static inline void init_rwsem(struct rw_semaphore *sem)
43{ 63{
44 sem->count = RWSEM_UNLOCKED_VALUE; 64 sem->count = RWSEM_UNLOCKED_VALUE;
@@ -141,6 +161,11 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
141 rwsem_downgrade_wake(sem); 161 rwsem_downgrade_wake(sem);
142} 162}
143 163
164static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
165{
166 __down_write(sem);
167}
168
144/* 169/*
145 * implement exchange and add functionality 170 * implement exchange and add functionality
146 */ 171 */
diff --git a/include/asm-sh/se7206.h b/include/asm-sh/se7206.h
new file mode 100644
index 000000000000..698eb80389ab
--- /dev/null
+++ b/include/asm-sh/se7206.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_SH_SE7206_H
2#define __ASM_SH_SE7206_H
3
4#define PA_SMSC 0x30000000
5#define PA_MRSHPC 0x34000000
6#define PA_LED 0x31400000
7
8void init_se7206_IRQ(void);
9
10#define __IO_PREFIX se7206
11#include <asm/io_generic.h>
12
13#endif /* __ASM_SH_SE7206_H */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 3340126f4e0f..b1e42e7f998b 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 2002 Paul Mundt 6 * Copyright (C) 2002 Paul Mundt
7 */ 7 */
8 8
9#include <linux/irqflags.h>
9#include <asm/types.h> 10#include <asm/types.h>
10 11
11/* 12/*
@@ -131,103 +132,6 @@ static inline unsigned long tas(volatile int *m)
131 132
132#define set_mb(var, value) do { xchg(&var, value); } while (0) 133#define set_mb(var, value) do { xchg(&var, value); } while (0)
133 134
134/* Interrupt Control */
135#ifdef CONFIG_CPU_HAS_SR_RB
136static inline void local_irq_enable(void)
137{
138 unsigned long __dummy0, __dummy1;
139
140 __asm__ __volatile__("stc sr, %0\n\t"
141 "and %1, %0\n\t"
142 "stc r6_bank, %1\n\t"
143 "or %1, %0\n\t"
144 "ldc %0, sr"
145 : "=&r" (__dummy0), "=r" (__dummy1)
146 : "1" (~0x000000f0)
147 : "memory");
148}
149#else
150static inline void local_irq_enable(void)
151{
152 unsigned long __dummy0, __dummy1;
153
154 __asm__ __volatile__ (
155 "stc sr, %0\n\t"
156 "and %1, %0\n\t"
157 "ldc %0, sr\n\t"
158 : "=&r" (__dummy0), "=r" (__dummy1)
159 : "1" (~0x000000f0)
160 : "memory");
161}
162#endif
163
164static inline void local_irq_disable(void)
165{
166 unsigned long __dummy;
167 __asm__ __volatile__("stc sr, %0\n\t"
168 "or #0xf0, %0\n\t"
169 "ldc %0, sr"
170 : "=&z" (__dummy)
171 : /* no inputs */
172 : "memory");
173}
174
175static inline void set_bl_bit(void)
176{
177 unsigned long __dummy0, __dummy1;
178
179 __asm__ __volatile__ ("stc sr, %0\n\t"
180 "or %2, %0\n\t"
181 "and %3, %0\n\t"
182 "ldc %0, sr"
183 : "=&r" (__dummy0), "=r" (__dummy1)
184 : "r" (0x10000000), "r" (0xffffff0f)
185 : "memory");
186}
187
188static inline void clear_bl_bit(void)
189{
190 unsigned long __dummy0, __dummy1;
191
192 __asm__ __volatile__ ("stc sr, %0\n\t"
193 "and %2, %0\n\t"
194 "ldc %0, sr"
195 : "=&r" (__dummy0), "=r" (__dummy1)
196 : "1" (~0x10000000)
197 : "memory");
198}
199
200#define local_save_flags(x) \
201 __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" )
202
203#define irqs_disabled() \
204({ \
205 unsigned long flags; \
206 local_save_flags(flags); \
207 (flags != 0); \
208})
209
210static inline unsigned long local_irq_save(void)
211{
212 unsigned long flags, __dummy;
213
214 __asm__ __volatile__("stc sr, %1\n\t"
215 "mov %1, %0\n\t"
216 "or #0xf0, %0\n\t"
217 "ldc %0, sr\n\t"
218 "mov %1, %0\n\t"
219 "and #0xf0, %0"
220 : "=&z" (flags), "=&r" (__dummy)
221 :/**/
222 : "memory" );
223 return flags;
224}
225
226#define local_irq_restore(x) do { \
227 if ((x & 0x000000f0) != 0x000000f0) \
228 local_irq_enable(); \
229} while (0)
230
231/* 135/*
232 * Jump to P2 area. 136 * Jump to P2 area.
233 * When handling TLB or caches, we need to do it from P2 area. 137 * When handling TLB or caches, we need to do it from P2 area.
@@ -264,9 +168,6 @@ do { \
264 : "=&r" (__dummy)); \ 168 : "=&r" (__dummy)); \
265} while (0) 169} while (0)
266 170
267/* For spinlocks etc */
268#define local_irq_save(x) x = local_irq_save()
269
270static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) 171static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
271{ 172{
272 unsigned long flags, retval; 173 unsigned long flags, retval;
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 3ebc3f9039eb..0c01dc550819 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -90,13 +90,7 @@ static inline struct thread_info *current_thread_info(void)
90#endif 90#endif
91#define free_thread_info(ti) kfree(ti) 91#define free_thread_info(ti) kfree(ti)
92 92
93#else /* !__ASSEMBLY__ */ 93#endif /* __ASSEMBLY__ */
94
95/* how to get the thread information struct from ASM */
96#define GET_THREAD_INFO(reg) \
97 stc r7_bank, reg
98
99#endif
100 94
101/* 95/*
102 * thread information flags 96 * thread information flags
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h
index 5df842bcf7b6..17b5e76a4c31 100644
--- a/include/asm-sh/timer.h
+++ b/include/asm-sh/timer.h
@@ -18,11 +18,32 @@ struct sys_timer {
18 18
19 struct sys_device dev; 19 struct sys_device dev;
20 struct sys_timer_ops *ops; 20 struct sys_timer_ops *ops;
21
22#ifdef CONFIG_NO_IDLE_HZ
23 struct dyn_tick_timer *dyn_tick;
24#endif
21}; 25};
22 26
27#ifdef CONFIG_NO_IDLE_HZ
28#define DYN_TICK_ENABLED (1 << 1)
29
30struct dyn_tick_timer {
31 spinlock_t lock;
32 unsigned int state; /* Current state */
33 int (*enable)(void); /* Enables dynamic tick */
34 int (*disable)(void); /* Disables dynamic tick */
35 void (*reprogram)(unsigned long); /* Reprograms the timer */
36 int (*handler)(int, void *);
37};
38
39void timer_dyn_reprogram(void);
40#else
41#define timer_dyn_reprogram() do { } while (0)
42#endif
43
23#define TICK_SIZE (tick_nsec / 1000) 44#define TICK_SIZE (tick_nsec / 1000)
24 45
25extern struct sys_timer tmu_timer; 46extern struct sys_timer tmu_timer, cmt_timer, mtu2_timer;
26extern struct sys_timer *sys_timer; 47extern struct sys_timer *sys_timer;
27 48
28#ifndef CONFIG_GENERIC_TIME 49#ifndef CONFIG_GENERIC_TIME
diff --git a/include/asm-sh/titan.h b/include/asm-sh/titan.h
index 270a4f4bc8a9..03f3583c8918 100644
--- a/include/asm-sh/titan.h
+++ b/include/asm-sh/titan.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * Platform defintions for Titan 2 * Platform defintions for Titan
3 */ 3 */
4 4#ifndef _ASM_SH_TITAN_H
5#ifndef _ASM_SH_TITAN_TITAN_H 5#define _ASM_SH_TITAN_H
6#define _ASM_SH_TITAN_TITAN_H
7 6
8#define __IO_PREFIX titan 7#define __IO_PREFIX titan
9#include <asm/io_generic.h> 8#include <asm/io_generic.h>
@@ -15,29 +14,4 @@
15#define TITAN_IRQ_MPCIB 11 /* mPCI B */ 14#define TITAN_IRQ_MPCIB 11 /* mPCI B */
16#define TITAN_IRQ_USB 11 /* USB */ 15#define TITAN_IRQ_USB 11 /* USB */
17 16
18/* 17#endif /* __ASM_SH_TITAN_H */
19 * The external interrupt lines, these take up ints 0 - 15 inclusive
20 * depending on the priority for the interrupt. In fact the priority
21 * is the interrupt :-)
22 */
23#define IRL0_IRQ 0
24#define IRL0_IPR_ADDR INTC_IPRD
25#define IRL0_IPR_POS 3
26#define IRL0_PRIORITY 8
27
28#define IRL1_IRQ 1
29#define IRL1_IPR_ADDR INTC_IPRD
30#define IRL1_IPR_POS 2
31#define IRL1_PRIORITY 8
32
33#define IRL2_IRQ 2
34#define IRL2_IPR_ADDR INTC_IPRD
35#define IRL2_IPR_POS 1
36#define IRL2_PRIORITY 8
37
38#define IRL3_IRQ 3
39#define IRL3_IPR_ADDR INTC_IPRD
40#define IRL3_IPR_POS 0
41#define IRL3_PRIORITY 8
42
43#endif
diff --git a/include/asm-sh/types.h b/include/asm-sh/types.h
index 3c09dd4ca31c..fd00dbb82f84 100644
--- a/include/asm-sh/types.h
+++ b/include/asm-sh/types.h
@@ -52,16 +52,6 @@ typedef unsigned long long u64;
52 52
53typedef u32 dma_addr_t; 53typedef u32 dma_addr_t;
54 54
55#ifdef CONFIG_LBD
56typedef u64 sector_t;
57#define HAVE_SECTOR_T
58#endif
59
60#ifdef CONFIG_LSF
61typedef u64 blkcnt_t;
62#define HAVE_BLKCNT_T
63#endif
64
65#endif /* __ASSEMBLY__ */ 55#endif /* __ASSEMBLY__ */
66 56
67#endif /* __KERNEL__ */ 57#endif /* __KERNEL__ */
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 1c2abde122cd..0cae1d248761 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -349,12 +349,30 @@ do { \
349 return (type) (res); \ 349 return (type) (res); \
350} while (0) 350} while (0)
351 351
352#if defined(__sh2__) || defined(__SH2E__) || defined(__SH2A__)
353#define SYSCALL_ARG0 "trapa #0x20"
354#define SYSCALL_ARG1 "trapa #0x21"
355#define SYSCALL_ARG2 "trapa #0x22"
356#define SYSCALL_ARG3 "trapa #0x23"
357#define SYSCALL_ARG4 "trapa #0x24"
358#define SYSCALL_ARG5 "trapa #0x25"
359#define SYSCALL_ARG6 "trapa #0x26"
360#else
361#define SYSCALL_ARG0 "trapa #0x10"
362#define SYSCALL_ARG1 "trapa #0x11"
363#define SYSCALL_ARG2 "trapa #0x12"
364#define SYSCALL_ARG3 "trapa #0x13"
365#define SYSCALL_ARG4 "trapa #0x14"
366#define SYSCALL_ARG5 "trapa #0x15"
367#define SYSCALL_ARG6 "trapa #0x16"
368#endif
369
352/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */ 370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
353#define _syscall0(type,name) \ 371#define _syscall0(type,name) \
354type name(void) \ 372type name(void) \
355{ \ 373{ \
356register long __sc0 __asm__ ("r3") = __NR_##name; \ 374register long __sc0 __asm__ ("r3") = __NR_##name; \
357__asm__ __volatile__ ("trapa #0x10" \ 375__asm__ __volatile__ (SYSCALL_ARG0 \
358 : "=z" (__sc0) \ 376 : "=z" (__sc0) \
359 : "0" (__sc0) \ 377 : "0" (__sc0) \
360 : "memory" ); \ 378 : "memory" ); \
@@ -366,7 +384,7 @@ type name(type1 arg1) \
366{ \ 384{ \
367register long __sc0 __asm__ ("r3") = __NR_##name; \ 385register long __sc0 __asm__ ("r3") = __NR_##name; \
368register long __sc4 __asm__ ("r4") = (long) arg1; \ 386register long __sc4 __asm__ ("r4") = (long) arg1; \
369__asm__ __volatile__ ("trapa #0x11" \ 387__asm__ __volatile__ (SYSCALL_ARG1 \
370 : "=z" (__sc0) \ 388 : "=z" (__sc0) \
371 : "0" (__sc0), "r" (__sc4) \ 389 : "0" (__sc0), "r" (__sc4) \
372 : "memory"); \ 390 : "memory"); \
@@ -379,7 +397,7 @@ type name(type1 arg1,type2 arg2) \
379register long __sc0 __asm__ ("r3") = __NR_##name; \ 397register long __sc0 __asm__ ("r3") = __NR_##name; \
380register long __sc4 __asm__ ("r4") = (long) arg1; \ 398register long __sc4 __asm__ ("r4") = (long) arg1; \
381register long __sc5 __asm__ ("r5") = (long) arg2; \ 399register long __sc5 __asm__ ("r5") = (long) arg2; \
382__asm__ __volatile__ ("trapa #0x12" \ 400__asm__ __volatile__ (SYSCALL_ARG2 \
383 : "=z" (__sc0) \ 401 : "=z" (__sc0) \
384 : "0" (__sc0), "r" (__sc4), "r" (__sc5) \ 402 : "0" (__sc0), "r" (__sc4), "r" (__sc5) \
385 : "memory"); \ 403 : "memory"); \
@@ -393,7 +411,7 @@ register long __sc0 __asm__ ("r3") = __NR_##name; \
393register long __sc4 __asm__ ("r4") = (long) arg1; \ 411register long __sc4 __asm__ ("r4") = (long) arg1; \
394register long __sc5 __asm__ ("r5") = (long) arg2; \ 412register long __sc5 __asm__ ("r5") = (long) arg2; \
395register long __sc6 __asm__ ("r6") = (long) arg3; \ 413register long __sc6 __asm__ ("r6") = (long) arg3; \
396__asm__ __volatile__ ("trapa #0x13" \ 414__asm__ __volatile__ (SYSCALL_ARG3 \
397 : "=z" (__sc0) \ 415 : "=z" (__sc0) \
398 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \ 416 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
399 : "memory"); \ 417 : "memory"); \
@@ -408,7 +426,7 @@ register long __sc4 __asm__ ("r4") = (long) arg1; \
408register long __sc5 __asm__ ("r5") = (long) arg2; \ 426register long __sc5 __asm__ ("r5") = (long) arg2; \
409register long __sc6 __asm__ ("r6") = (long) arg3; \ 427register long __sc6 __asm__ ("r6") = (long) arg3; \
410register long __sc7 __asm__ ("r7") = (long) arg4; \ 428register long __sc7 __asm__ ("r7") = (long) arg4; \
411__asm__ __volatile__ ("trapa #0x14" \ 429__asm__ __volatile__ (SYSCALL_ARG4 \
412 : "=z" (__sc0) \ 430 : "=z" (__sc0) \
413 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \ 431 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \
414 "r" (__sc7) \ 432 "r" (__sc7) \
@@ -425,7 +443,7 @@ register long __sc5 __asm__ ("r5") = (long) arg2; \
425register long __sc6 __asm__ ("r6") = (long) arg3; \ 443register long __sc6 __asm__ ("r6") = (long) arg3; \
426register long __sc7 __asm__ ("r7") = (long) arg4; \ 444register long __sc7 __asm__ ("r7") = (long) arg4; \
427register long __sc0 __asm__ ("r0") = (long) arg5; \ 445register long __sc0 __asm__ ("r0") = (long) arg5; \
428__asm__ __volatile__ ("trapa #0x15" \ 446__asm__ __volatile__ (SYSCALL_ARG5 \
429 : "=z" (__sc0) \ 447 : "=z" (__sc0) \
430 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \ 448 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
431 "r" (__sc3) \ 449 "r" (__sc3) \
@@ -443,7 +461,7 @@ register long __sc6 __asm__ ("r6") = (long) arg3; \
443register long __sc7 __asm__ ("r7") = (long) arg4; \ 461register long __sc7 __asm__ ("r7") = (long) arg4; \
444register long __sc0 __asm__ ("r0") = (long) arg5; \ 462register long __sc0 __asm__ ("r0") = (long) arg5; \
445register long __sc1 __asm__ ("r1") = (long) arg6; \ 463register long __sc1 __asm__ ("r1") = (long) arg6; \
446__asm__ __volatile__ ("trapa #0x16" \ 464__asm__ __volatile__ (SYSCALL_ARG6 \
447 : "=z" (__sc0) \ 465 : "=z" (__sc0) \
448 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \ 466 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
449 "r" (__sc3), "r" (__sc1) \ 467 "r" (__sc3), "r" (__sc1) \
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 007e88d6d43f..93849f7abc24 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -21,7 +21,7 @@
21 * on us. We need to use _exactly_ the address the user gave us, 21 * on us. We need to use _exactly_ the address the user gave us,
22 * not some alias that contains the same information. 22 * not some alias that contains the same information.
23 */ 23 */
24typedef struct { volatile int counter; } atomic_t; 24typedef struct { int counter; } atomic_t;
25 25
26#define ATOMIC_INIT(i) { (i) } 26#define ATOMIC_INIT(i) { (i) }
27 27
diff --git a/include/asm-x86_64/spinlock_types.h b/include/asm-x86_64/spinlock_types.h
index 59efe849f351..4da9345c1500 100644
--- a/include/asm-x86_64/spinlock_types.h
+++ b/include/asm-x86_64/spinlock_types.h
@@ -6,13 +6,13 @@
6#endif 6#endif
7 7
8typedef struct { 8typedef struct {
9 volatile unsigned int slock; 9 unsigned int slock;
10} raw_spinlock_t; 10} raw_spinlock_t;
11 11
12#define __RAW_SPIN_LOCK_UNLOCKED { 1 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
13 13
14typedef struct { 14typedef struct {
15 volatile unsigned int lock; 15 unsigned int lock;
16} raw_rwlock_t; 16} raw_rwlock_t;
17 17
18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS } 18#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
diff --git a/include/asm-x86_64/types.h b/include/asm-x86_64/types.h
index c86c2e6793e2..2d4491aae281 100644
--- a/include/asm-x86_64/types.h
+++ b/include/asm-x86_64/types.h
@@ -48,9 +48,6 @@ typedef unsigned long long u64;
48typedef u64 dma64_addr_t; 48typedef u64 dma64_addr_t;
49typedef u64 dma_addr_t; 49typedef u64 dma_addr_t;
50 50
51typedef u64 sector_t;
52#define HAVE_SECTOR_T
53
54#endif /* __ASSEMBLY__ */ 51#endif /* __ASSEMBLY__ */
55 52
56#endif /* __KERNEL__ */ 53#endif /* __KERNEL__ */
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 0d71c0041f13..9e350fd44d77 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -194,7 +194,7 @@ struct kioctx {
194 194
195 struct aio_ring_info ring_info; 195 struct aio_ring_info ring_info;
196 196
197 struct work_struct wq; 197 struct delayed_work wq;
198}; 198};
199 199
200/* prototypes */ 200/* prototypes */
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 4c02119c6ab9..3ea1cd58de97 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -133,7 +133,7 @@ struct cn_callback_data {
133struct cn_callback_entry { 133struct cn_callback_entry {
134 struct list_head callback_entry; 134 struct list_head callback_entry;
135 struct cn_callback *cb; 135 struct cn_callback *cb;
136 struct work_struct work; 136 struct delayed_work work;
137 struct cn_queue_dev *pdev; 137 struct cn_queue_dev *pdev;
138 138
139 struct cn_callback_id id; 139 struct cn_callback_id id;
@@ -170,7 +170,7 @@ void cn_queue_free_dev(struct cn_queue_dev *dev);
170 170
171int cn_cb_equal(struct cb_id *, struct cb_id *); 171int cn_cb_equal(struct cb_id *, struct cb_id *);
172 172
173void cn_queue_wrapper(void *data); 173void cn_queue_wrapper(struct work_struct *work);
174 174
175extern int cn_already_initialized; 175extern int cn_already_initialized;
176 176
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 3fef7d67aedc..f02d71bf6894 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -33,6 +33,14 @@ struct cpu {
33 33
34extern int register_cpu(struct cpu *cpu, int num); 34extern int register_cpu(struct cpu *cpu, int num);
35extern struct sys_device *get_cpu_sysdev(unsigned cpu); 35extern struct sys_device *get_cpu_sysdev(unsigned cpu);
36
37extern int cpu_add_sysdev_attr(struct sysdev_attribute *attr);
38extern void cpu_remove_sysdev_attr(struct sysdev_attribute *attr);
39
40extern int cpu_add_sysdev_attr_group(struct attribute_group *attrs);
41extern void cpu_remove_sysdev_attr_group(struct attribute_group *attrs);
42
43
36#ifdef CONFIG_HOTPLUG_CPU 44#ifdef CONFIG_HOTPLUG_CPU
37extern void unregister_cpu(struct cpu *cpu); 45extern void unregister_cpu(struct cpu *cpu);
38#endif 46#endif
diff --git a/include/linux/elf.h b/include/linux/elf.h
index b70d1d2c8d28..743d5c8e6d36 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -368,5 +368,12 @@ extern Elf64_Dyn _DYNAMIC [];
368 368
369#endif 369#endif
370 370
371#ifndef ARCH_HAVE_EXTRA_ELF_NOTES
372static inline int arch_notes_size(void) { return 0; }
373static inline void arch_write_notes(struct file *file) { }
374
375#define ELF_CORE_EXTRA_NOTES_SIZE arch_notes_size()
376#define ELF_CORE_WRITE_EXTRA_NOTES arch_write_notes(file)
377#endif /* ARCH_HAVE_EXTRA_ELF_NOTES */
371 378
372#endif /* _LINUX_ELF_H */ 379#endif /* _LINUX_ELF_H */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index c115e9e840b4..1fb02e17f6f6 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -461,7 +461,7 @@ struct i2o_driver {
461 int (*reply) (struct i2o_controller *, u32, struct i2o_message *); 461 int (*reply) (struct i2o_controller *, u32, struct i2o_message *);
462 462
463 /* Event handler */ 463 /* Event handler */
464 void (*event) (struct i2o_event *); 464 work_func_t event;
465 465
466 struct workqueue_struct *event_queue; /* Event queue */ 466 struct workqueue_struct *event_queue; /* Event queue */
467 467
diff --git a/include/linux/kbd_kern.h b/include/linux/kbd_kern.h
index efe0ee4cc80b..06c58c423fe1 100644
--- a/include/linux/kbd_kern.h
+++ b/include/linux/kbd_kern.h
@@ -158,7 +158,7 @@ static inline void con_schedule_flip(struct tty_struct *t)
158 if (t->buf.tail != NULL) 158 if (t->buf.tail != NULL)
159 t->buf.tail->commit = t->buf.tail->used; 159 t->buf.tail->commit = t->buf.tail->used;
160 spin_unlock_irqrestore(&t->buf.lock, flags); 160 spin_unlock_irqrestore(&t->buf.lock, flags);
161 schedule_work(&t->buf.work); 161 schedule_delayed_work(&t->buf.work, 0);
162} 162}
163 163
164#endif 164#endif
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 202283b5df96..ab2754830322 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -575,8 +575,9 @@ struct ata_port {
575 struct ata_host *host; 575 struct ata_host *host;
576 struct device *dev; 576 struct device *dev;
577 577
578 struct work_struct port_task; 578 void *port_task_data;
579 struct work_struct hotplug_task; 579 struct delayed_work port_task;
580 struct delayed_work hotplug_task;
580 struct work_struct scsi_rescan_task; 581 struct work_struct scsi_rescan_task;
581 582
582 unsigned int hsm_task_state; 583 unsigned int hsm_task_state;
@@ -755,7 +756,7 @@ extern void ata_host_resume(struct ata_host *host);
755extern int ata_ratelimit(void); 756extern int ata_ratelimit(void);
756extern int ata_busy_sleep(struct ata_port *ap, 757extern int ata_busy_sleep(struct ata_port *ap,
757 unsigned long timeout_pat, unsigned long timeout); 758 unsigned long timeout_pat, unsigned long timeout);
758extern void ata_port_queue_task(struct ata_port *ap, void (*fn)(void *), 759extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
759 void *data, unsigned long delay); 760 void *data, unsigned long delay);
760extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 761extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
761 unsigned long interval_msec, 762 unsigned long interval_msec,
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 528e7d3fecb1..c15ae1986b98 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -110,7 +110,7 @@ struct mmc_host {
110 struct mmc_card *card_busy; /* the MMC card claiming host */ 110 struct mmc_card *card_busy; /* the MMC card claiming host */
111 struct mmc_card *card_selected; /* the selected MMC card */ 111 struct mmc_card *card_selected; /* the selected MMC card */
112 112
113 struct work_struct detect; 113 struct delayed_work detect;
114 114
115 unsigned long private[0] ____cacheline_aligned; 115 unsigned long private[0] ____cacheline_aligned;
116}; 116};
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index b089d9506283..a503052138bd 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -127,10 +127,10 @@ struct ncp_server {
127 } unexpected_packet; 127 } unexpected_packet;
128}; 128};
129 129
130extern void ncp_tcp_rcv_proc(void *server); 130extern void ncp_tcp_rcv_proc(struct work_struct *work);
131extern void ncp_tcp_tx_proc(void *server); 131extern void ncp_tcp_tx_proc(struct work_struct *work);
132extern void ncpdgram_rcv_proc(void *server); 132extern void ncpdgram_rcv_proc(struct work_struct *work);
133extern void ncpdgram_timeout_proc(void *server); 133extern void ncpdgram_timeout_proc(struct work_struct *work);
134extern void ncpdgram_timeout_call(unsigned long server); 134extern void ncpdgram_timeout_call(unsigned long server);
135extern void ncp_tcp_data_ready(struct sock* sk, int len); 135extern void ncp_tcp_data_ready(struct sock* sk, int len);
136extern void ncp_tcp_write_space(struct sock* sk); 136extern void ncp_tcp_write_space(struct sock* sk);
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 2cc9867b1626..29930b71a9aa 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -32,7 +32,7 @@ struct netpoll_info {
32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */ 32 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
33 struct sk_buff_head arp_tx; /* list of arp requests to reply to */ 33 struct sk_buff_head arp_tx; /* list of arp requests to reply to */
34 struct sk_buff_head txq; 34 struct sk_buff_head txq;
35 struct work_struct tx_work; 35 struct delayed_work tx_work;
36}; 36};
37 37
38void netpoll_poll(struct netpoll *np); 38void netpoll_poll(struct netpoll *np);
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 7ccfc7ef0a83..95796e6924f1 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -51,7 +51,7 @@ struct nfs_client {
51 51
52 unsigned long cl_lease_time; 52 unsigned long cl_lease_time;
53 unsigned long cl_last_renewal; 53 unsigned long cl_last_renewal;
54 struct work_struct cl_renewd; 54 struct delayed_work cl_renewd;
55 55
56 struct rpc_wait_queue cl_rpcwaitq; 56 struct rpc_wait_queue cl_rpcwaitq;
57 57
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index 62a7169aed8b..3a28742d86f9 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -249,7 +249,8 @@ struct reiserfs_journal {
249 int j_errno; 249 int j_errno;
250 250
251 /* when flushing ordered buffers, throttle new ordered writers */ 251 /* when flushing ordered buffers, throttle new ordered writers */
252 struct work_struct j_work; 252 struct delayed_work j_work;
253 struct super_block *j_work_sb;
253 atomic_t j_async_throttle; 254 atomic_t j_async_throttle;
254}; 255};
255 256
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 24accb483849..0e3d91b76996 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -38,7 +38,7 @@ struct rchan_buf
38 size_t subbufs_consumed; /* count of sub-buffers consumed */ 38 size_t subbufs_consumed; /* count of sub-buffers consumed */
39 struct rchan *chan; /* associated channel */ 39 struct rchan *chan; /* associated channel */
40 wait_queue_head_t read_wait; /* reader wait queue */ 40 wait_queue_head_t read_wait; /* reader wait queue */
41 struct work_struct wake_readers; /* reader wake-up work struct */ 41 struct delayed_work wake_readers; /* reader wake-up work struct */
42 struct dentry *dentry; /* channel file dentry */ 42 struct dentry *dentry; /* channel file dentry */
43 struct kref kref; /* channel buffer refcount */ 43 struct kref kref; /* channel buffer refcount */
44 struct page **page_array; /* array of current buffer pages */ 44 struct page **page_array; /* array of current buffer pages */
diff --git a/include/linux/sunrpc/rpc_pipe_fs.h b/include/linux/sunrpc/rpc_pipe_fs.h
index a2eb9b4a9de3..4a68125b6de6 100644
--- a/include/linux/sunrpc/rpc_pipe_fs.h
+++ b/include/linux/sunrpc/rpc_pipe_fs.h
@@ -30,7 +30,7 @@ struct rpc_inode {
30#define RPC_PIPE_WAIT_FOR_OPEN 1 30#define RPC_PIPE_WAIT_FOR_OPEN 1
31 int flags; 31 int flags;
32 struct rpc_pipe_ops *ops; 32 struct rpc_pipe_ops *ops;
33 struct work_struct queue_timeout; 33 struct delayed_work queue_timeout;
34}; 34};
35 35
36static inline struct rpc_inode * 36static inline struct rpc_inode *
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 60394fbc4c70..3e04c1512fc4 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -177,7 +177,7 @@ struct rpc_xprt {
177 unsigned long connect_timeout, 177 unsigned long connect_timeout,
178 bind_timeout, 178 bind_timeout,
179 reestablish_timeout; 179 reestablish_timeout;
180 struct work_struct connect_worker; 180 struct delayed_work connect_worker;
181 unsigned short port; 181 unsigned short port;
182 182
183 /* 183 /*
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 65321f911c1e..f717f0898238 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -53,7 +53,7 @@ struct tty_buffer {
53}; 53};
54 54
55struct tty_bufhead { 55struct tty_bufhead {
56 struct work_struct work; 56 struct delayed_work work;
57 struct semaphore pty_sem; 57 struct semaphore pty_sem;
58 spinlock_t lock; 58 spinlock_t lock;
59 struct tty_buffer *head; /* Queue head */ 59 struct tty_buffer *head; /* Queue head */
diff --git a/include/linux/types.h b/include/linux/types.h
index 745c409ebbb5..0351bf2fac85 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -136,15 +136,19 @@ typedef __s64 int64_t;
136 * 136 *
137 * Linux always considers sectors to be 512 bytes long independently 137 * Linux always considers sectors to be 512 bytes long independently
138 * of the devices real block size. 138 * of the devices real block size.
139 *
140 * If required, asm/types.h can override it and define
141 * HAVE_SECTOR_T
142 */ 139 */
143#ifndef HAVE_SECTOR_T 140#ifdef CONFIG_LBD
141typedef u64 sector_t;
142#else
144typedef unsigned long sector_t; 143typedef unsigned long sector_t;
145#endif 144#endif
146 145
147#ifndef HAVE_BLKCNT_T 146/*
147 * The type of the inode's block count.
148 */
149#ifdef CONFIG_LSF
150typedef u64 blkcnt_t;
151#else
148typedef unsigned long blkcnt_t; 152typedef unsigned long blkcnt_t;
149#endif 153#endif
150 154
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 0cd73edeef13..aab5b1b72021 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -388,7 +388,7 @@ struct usb_device {
388 388
389 int pm_usage_cnt; /* usage counter for autosuspend */ 389 int pm_usage_cnt; /* usage counter for autosuspend */
390#ifdef CONFIG_PM 390#ifdef CONFIG_PM
391 struct work_struct autosuspend; /* for delayed autosuspends */ 391 struct delayed_work autosuspend; /* for delayed autosuspends */
392 struct mutex pm_mutex; /* protects PM operations */ 392 struct mutex pm_mutex; /* protects PM operations */
393 393
394 unsigned auto_pm:1; /* autosuspend/resume in progress */ 394 unsigned auto_pm:1; /* autosuspend/resume in progress */
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 9bca3539a1e5..4a3ea83c6d16 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -11,12 +11,23 @@
11 11
12struct workqueue_struct; 12struct workqueue_struct;
13 13
14struct work_struct;
15typedef void (*work_func_t)(struct work_struct *work);
16
14struct work_struct { 17struct work_struct {
15 unsigned long pending; 18 /* the first word is the work queue pointer and the flags rolled into
19 * one */
20 unsigned long management;
21#define WORK_STRUCT_PENDING 0 /* T if work item pending execution */
22#define WORK_STRUCT_NOAUTOREL 1 /* F if work item automatically released on exec */
23#define WORK_STRUCT_FLAG_MASK (3UL)
24#define WORK_STRUCT_WQ_DATA_MASK (~WORK_STRUCT_FLAG_MASK)
16 struct list_head entry; 25 struct list_head entry;
17 void (*func)(void *); 26 work_func_t func;
18 void *data; 27};
19 void *wq_data; 28
29struct delayed_work {
30 struct work_struct work;
20 struct timer_list timer; 31 struct timer_list timer;
21}; 32};
22 33
@@ -24,36 +35,117 @@ struct execute_work {
24 struct work_struct work; 35 struct work_struct work;
25}; 36};
26 37
27#define __WORK_INITIALIZER(n, f, d) { \ 38#define __WORK_INITIALIZER(n, f) { \
39 .management = 0, \
40 .entry = { &(n).entry, &(n).entry }, \
41 .func = (f), \
42 }
43
44#define __WORK_INITIALIZER_NAR(n, f) { \
45 .management = (1 << WORK_STRUCT_NOAUTOREL), \
28 .entry = { &(n).entry, &(n).entry }, \ 46 .entry = { &(n).entry, &(n).entry }, \
29 .func = (f), \ 47 .func = (f), \
30 .data = (d), \ 48 }
49
50#define __DELAYED_WORK_INITIALIZER(n, f) { \
51 .work = __WORK_INITIALIZER((n).work, (f)), \
52 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
53 }
54
55#define __DELAYED_WORK_INITIALIZER_NAR(n, f) { \
56 .work = __WORK_INITIALIZER_NAR((n).work, (f)), \
31 .timer = TIMER_INITIALIZER(NULL, 0, 0), \ 57 .timer = TIMER_INITIALIZER(NULL, 0, 0), \
32 } 58 }
33 59
34#define DECLARE_WORK(n, f, d) \ 60#define DECLARE_WORK(n, f) \
35 struct work_struct n = __WORK_INITIALIZER(n, f, d) 61 struct work_struct n = __WORK_INITIALIZER(n, f)
62
63#define DECLARE_WORK_NAR(n, f) \
64 struct work_struct n = __WORK_INITIALIZER_NAR(n, f)
65
66#define DECLARE_DELAYED_WORK(n, f) \
67 struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f)
68
69#define DECLARE_DELAYED_WORK_NAR(n, f) \
70 struct dwork_struct n = __DELAYED_WORK_INITIALIZER_NAR(n, f)
36 71
37/* 72/*
38 * initialize a work-struct's func and data pointers: 73 * initialize a work item's function pointer
39 */ 74 */
40#define PREPARE_WORK(_work, _func, _data) \ 75#define PREPARE_WORK(_work, _func) \
41 do { \ 76 do { \
42 (_work)->func = _func; \ 77 (_work)->func = (_func); \
43 (_work)->data = _data; \
44 } while (0) 78 } while (0)
45 79
80#define PREPARE_DELAYED_WORK(_work, _func) \
81 PREPARE_WORK(&(_work)->work, (_func))
82
46/* 83/*
47 * initialize all of a work-struct: 84 * initialize all of a work item in one go
48 */ 85 */
49#define INIT_WORK(_work, _func, _data) \ 86#define INIT_WORK(_work, _func) \
50 do { \ 87 do { \
88 (_work)->management = 0; \
51 INIT_LIST_HEAD(&(_work)->entry); \ 89 INIT_LIST_HEAD(&(_work)->entry); \
52 (_work)->pending = 0; \ 90 PREPARE_WORK((_work), (_func)); \
53 PREPARE_WORK((_work), (_func), (_data)); \ 91 } while (0)
92
93#define INIT_WORK_NAR(_work, _func) \
94 do { \
95 (_work)->management = (1 << WORK_STRUCT_NOAUTOREL); \
96 INIT_LIST_HEAD(&(_work)->entry); \
97 PREPARE_WORK((_work), (_func)); \
98 } while (0)
99
100#define INIT_DELAYED_WORK(_work, _func) \
101 do { \
102 INIT_WORK(&(_work)->work, (_func)); \
103 init_timer(&(_work)->timer); \
104 } while (0)
105
106#define INIT_DELAYED_WORK_NAR(_work, _func) \
107 do { \
108 INIT_WORK_NAR(&(_work)->work, (_func)); \
54 init_timer(&(_work)->timer); \ 109 init_timer(&(_work)->timer); \
55 } while (0) 110 } while (0)
56 111
112/**
113 * work_pending - Find out whether a work item is currently pending
114 * @work: The work item in question
115 */
116#define work_pending(work) \
117 test_bit(WORK_STRUCT_PENDING, &(work)->management)
118
119/**
120 * delayed_work_pending - Find out whether a delayable work item is currently
121 * pending
122 * @work: The work item in question
123 */
124#define delayed_work_pending(work) \
125 test_bit(WORK_STRUCT_PENDING, &(work)->work.management)
126
127/**
128 * work_release - Release a work item under execution
129 * @work: The work item to release
130 *
131 * This is used to release a work item that has been initialised with automatic
132 * release mode disabled (WORK_STRUCT_NOAUTOREL is set). This gives the work
133 * function the opportunity to grab auxiliary data from the container of the
134 * work_struct before clearing the pending bit as the work_struct may be
135 * subject to deallocation the moment the pending bit is cleared.
136 *
137 * In such a case, this should be called in the work function after it has
138 * fetched any data it may require from the containter of the work_struct.
139 * After this function has been called, the work_struct may be scheduled for
140 * further execution or it may be deallocated unless other precautions are
141 * taken.
142 *
143 * This should also be used to release a delayed work item.
144 */
145#define work_release(work) \
146 clear_bit(WORK_STRUCT_PENDING, &(work)->management)
147
148
57extern struct workqueue_struct *__create_workqueue(const char *name, 149extern struct workqueue_struct *__create_workqueue(const char *name,
58 int singlethread); 150 int singlethread);
59#define create_workqueue(name) __create_workqueue((name), 0) 151#define create_workqueue(name) __create_workqueue((name), 0)
@@ -62,39 +154,38 @@ extern struct workqueue_struct *__create_workqueue(const char *name,
62extern void destroy_workqueue(struct workqueue_struct *wq); 154extern void destroy_workqueue(struct workqueue_struct *wq);
63 155
64extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); 156extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work));
65extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay)); 157extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay));
66extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 158extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
67 struct work_struct *work, unsigned long delay); 159 struct delayed_work *work, unsigned long delay);
68extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq)); 160extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
69 161
70extern int FASTCALL(schedule_work(struct work_struct *work)); 162extern int FASTCALL(schedule_work(struct work_struct *work));
71extern int FASTCALL(schedule_delayed_work(struct work_struct *work, unsigned long delay)); 163extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
72 164
73extern int schedule_delayed_work_on(int cpu, struct work_struct *work, unsigned long delay); 165extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
74extern int schedule_on_each_cpu(void (*func)(void *info), void *info); 166extern int schedule_on_each_cpu(work_func_t func);
75extern void flush_scheduled_work(void); 167extern void flush_scheduled_work(void);
76extern int current_is_keventd(void); 168extern int current_is_keventd(void);
77extern int keventd_up(void); 169extern int keventd_up(void);
78 170
79extern void init_workqueues(void); 171extern void init_workqueues(void);
80void cancel_rearming_delayed_work(struct work_struct *work); 172void cancel_rearming_delayed_work(struct delayed_work *work);
81void cancel_rearming_delayed_workqueue(struct workqueue_struct *, 173void cancel_rearming_delayed_workqueue(struct workqueue_struct *,
82 struct work_struct *); 174 struct delayed_work *);
83int execute_in_process_context(void (*fn)(void *), void *, 175int execute_in_process_context(work_func_t fn, struct execute_work *);
84 struct execute_work *);
85 176
86/* 177/*
87 * Kill off a pending schedule_delayed_work(). Note that the work callback 178 * Kill off a pending schedule_delayed_work(). Note that the work callback
88 * function may still be running on return from cancel_delayed_work(). Run 179 * function may still be running on return from cancel_delayed_work(). Run
89 * flush_scheduled_work() to wait on it. 180 * flush_scheduled_work() to wait on it.
90 */ 181 */
91static inline int cancel_delayed_work(struct work_struct *work) 182static inline int cancel_delayed_work(struct delayed_work *work)
92{ 183{
93 int ret; 184 int ret;
94 185
95 ret = del_timer_sync(&work->timer); 186 ret = del_timer_sync(&work->timer);
96 if (ret) 187 if (ret)
97 clear_bit(0, &work->pending); 188 clear_bit(WORK_STRUCT_PENDING, &work->work.management);
98 return ret; 189 return ret;
99} 190}
100 191
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 617b672b1132..89119277553d 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -108,8 +108,8 @@ struct ieee80211softmac_assoc_info {
108 /* Scan retries remaining */ 108 /* Scan retries remaining */
109 int scan_retry; 109 int scan_retry;
110 110
111 struct work_struct work; 111 struct delayed_work work;
112 struct work_struct timeout; 112 struct delayed_work timeout;
113}; 113};
114 114
115struct ieee80211softmac_bss_info { 115struct ieee80211softmac_bss_info {
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 5f48748fe017..f7be1ac73601 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -84,7 +84,7 @@ struct inet_timewait_death_row {
84}; 84};
85 85
86extern void inet_twdr_hangman(unsigned long data); 86extern void inet_twdr_hangman(unsigned long data);
87extern void inet_twdr_twkill_work(void *data); 87extern void inet_twdr_twkill_work(struct work_struct *work);
88extern void inet_twdr_twcal_tick(unsigned long data); 88extern void inet_twdr_twcal_tick(unsigned long data);
89 89
90#if (BITS_PER_LONG == 64) 90#if (BITS_PER_LONG == 64)
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index f8cbe40f52c0..c089f93ba591 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1030,7 +1030,7 @@ void sctp_inq_init(struct sctp_inq *);
1030void sctp_inq_free(struct sctp_inq *); 1030void sctp_inq_free(struct sctp_inq *);
1031void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet); 1031void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);
1032struct sctp_chunk *sctp_inq_pop(struct sctp_inq *); 1032struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);
1033void sctp_inq_set_th_handler(struct sctp_inq *, void (*)(void *), void *); 1033void sctp_inq_set_th_handler(struct sctp_inq *, work_func_t);
1034 1034
1035/* This is the structure we use to hold outbound chunks. You push 1035/* This is the structure we use to hold outbound chunks. You push
1036 * chunks in and they automatically pop out the other end as bundled 1036 * chunks in and they automatically pop out the other end as bundled
diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h
index ede639812f8a..623a0fc0dae1 100644
--- a/include/pcmcia/ss.h
+++ b/include/pcmcia/ss.h
@@ -262,9 +262,10 @@ struct pcmcia_socket {
262 u8 present:1, /* PCMCIA card is present in socket */ 262 u8 present:1, /* PCMCIA card is present in socket */
263 busy:1, /* "master" ioctl is used */ 263 busy:1, /* "master" ioctl is used */
264 dead:1, /* pcmcia module is being unloaded */ 264 dead:1, /* pcmcia module is being unloaded */
265 device_add_pending:1, /* a pseudo-multifunction-device 265 device_add_pending:1, /* a multifunction-device
266 * add event is pending */ 266 * add event is pending */
267 reserved:4; 267 mfc_pfc:1, /* the pending event adds a mfc (1) or pfc (0) */
268 reserved:3;
268 } pcmcia_state; 269 } pcmcia_state;
269 270
270 struct work_struct device_add; /* for adding further pseudo-multifunction 271 struct work_struct device_add; /* for adding further pseudo-multifunction
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 1d77b63c5ea4..9233ed5de664 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -201,9 +201,14 @@ struct domain_device {
201 void *lldd_dev; 201 void *lldd_dev;
202}; 202};
203 203
204struct sas_discovery_event {
205 struct work_struct work;
206 struct asd_sas_port *port;
207};
208
204struct sas_discovery { 209struct sas_discovery {
205 spinlock_t disc_event_lock; 210 spinlock_t disc_event_lock;
206 struct work_struct disc_work[DISC_NUM_EVENTS]; 211 struct sas_discovery_event disc_work[DISC_NUM_EVENTS];
207 unsigned long pending; 212 unsigned long pending;
208 u8 fanout_sas_addr[8]; 213 u8 fanout_sas_addr[8];
209 u8 eeds_a[8]; 214 u8 eeds_a[8];
@@ -249,14 +254,19 @@ struct asd_sas_port {
249 void *lldd_port; /* not touched by the sas class code */ 254 void *lldd_port; /* not touched by the sas class code */
250}; 255};
251 256
257struct asd_sas_event {
258 struct work_struct work;
259 struct asd_sas_phy *phy;
260};
261
252/* The phy pretty much is controlled by the LLDD. 262/* The phy pretty much is controlled by the LLDD.
253 * The class only reads those fields. 263 * The class only reads those fields.
254 */ 264 */
255struct asd_sas_phy { 265struct asd_sas_phy {
256/* private: */ 266/* private: */
257 /* protected by ha->event_lock */ 267 /* protected by ha->event_lock */
258 struct work_struct port_events[PORT_NUM_EVENTS]; 268 struct asd_sas_event port_events[PORT_NUM_EVENTS];
259 struct work_struct phy_events[PHY_NUM_EVENTS]; 269 struct asd_sas_event phy_events[PHY_NUM_EVENTS];
260 270
261 unsigned long port_events_pending; 271 unsigned long port_events_pending;
262 unsigned long phy_events_pending; 272 unsigned long phy_events_pending;
@@ -308,10 +318,15 @@ struct scsi_core {
308 int queue_thread_kill; 318 int queue_thread_kill;
309}; 319};
310 320
321struct sas_ha_event {
322 struct work_struct work;
323 struct sas_ha_struct *ha;
324};
325
311struct sas_ha_struct { 326struct sas_ha_struct {
312/* private: */ 327/* private: */
313 spinlock_t event_lock; 328 spinlock_t event_lock;
314 struct work_struct ha_events[HA_NUM_EVENTS]; 329 struct sas_ha_event ha_events[HA_NUM_EVENTS];
315 unsigned long pending; 330 unsigned long pending;
316 331
317 struct scsi_core core; 332 struct scsi_core core;
@@ -339,6 +354,8 @@ struct sas_ha_struct {
339 void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event); 354 void (*notify_phy_event)(struct asd_sas_phy *, enum phy_event);
340 355
341 void *lldd_ha; /* not touched by sas class code */ 356 void *lldd_ha; /* not touched by sas class code */
357
358 struct list_head eh_done_q;
342}; 359};
343 360
344#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata) 361#define SHOST_TO_SAS_HA(_shost) (*(struct sas_ha_struct **)(_shost)->hostdata)
@@ -527,13 +544,16 @@ struct sas_task {
527 544
528 void *lldd_task; /* for use by LLDDs */ 545 void *lldd_task; /* for use by LLDDs */
529 void *uldd_task; 546 void *uldd_task;
547
548 struct work_struct abort_work;
530}; 549};
531 550
532 551
533 552
534#define SAS_TASK_STATE_PENDING 1 553#define SAS_TASK_STATE_PENDING 1
535#define SAS_TASK_STATE_DONE 2 554#define SAS_TASK_STATE_DONE 2
536#define SAS_TASK_STATE_ABORTED 4 555#define SAS_TASK_STATE_ABORTED 4
556#define SAS_TASK_INITIATOR_ABORTED 8
537 557
538static inline struct sas_task *sas_alloc_task(gfp_t flags) 558static inline struct sas_task *sas_alloc_task(gfp_t flags)
539{ 559{
@@ -593,6 +613,7 @@ struct sas_domain_function_template {
593extern int sas_register_ha(struct sas_ha_struct *); 613extern int sas_register_ha(struct sas_ha_struct *);
594extern int sas_unregister_ha(struct sas_ha_struct *); 614extern int sas_unregister_ha(struct sas_ha_struct *);
595 615
616int sas_phy_reset(struct sas_phy *phy, int hard_reset);
596extern int sas_queuecommand(struct scsi_cmnd *, 617extern int sas_queuecommand(struct scsi_cmnd *,
597 void (*scsi_done)(struct scsi_cmnd *)); 618 void (*scsi_done)(struct scsi_cmnd *));
598extern int sas_target_alloc(struct scsi_target *); 619extern int sas_target_alloc(struct scsi_target *);
@@ -625,4 +646,6 @@ void sas_unregister_dev(struct domain_device *);
625 646
626void sas_init_dev(struct domain_device *); 647void sas_init_dev(struct domain_device *);
627 648
649void sas_task_abort(struct work_struct *);
650
628#endif /* _SASLIB_H_ */ 651#endif /* _SASLIB_H_ */
diff --git a/include/scsi/libsrp.h b/include/scsi/libsrp.h
new file mode 100644
index 000000000000..d143171896ae
--- /dev/null
+++ b/include/scsi/libsrp.h
@@ -0,0 +1,77 @@
1#ifndef __LIBSRP_H__
2#define __LIBSRP_H__
3
4#include <linux/list.h>
5#include <scsi/scsi_cmnd.h>
6#include <scsi/scsi_host.h>
7#include <scsi/srp.h>
8
9enum iue_flags {
10 V_DIOVER,
11 V_WRITE,
12 V_LINKED,
13 V_FLYING,
14};
15
16struct srp_buf {
17 dma_addr_t dma;
18 void *buf;
19};
20
21struct srp_queue {
22 void *pool;
23 void *items;
24 struct kfifo *queue;
25 spinlock_t lock;
26};
27
28struct srp_target {
29 struct Scsi_Host *shost;
30 struct device *dev;
31
32 spinlock_t lock;
33 struct list_head cmd_queue;
34
35 size_t srp_iu_size;
36 struct srp_queue iu_queue;
37 size_t rx_ring_size;
38 struct srp_buf **rx_ring;
39
40 void *ldata;
41};
42
43struct iu_entry {
44 struct srp_target *target;
45
46 struct list_head ilist;
47 dma_addr_t remote_token;
48 unsigned long flags;
49
50 struct srp_buf *sbuf;
51};
52
53typedef int (srp_rdma_t)(struct scsi_cmnd *, struct scatterlist *, int,
54 struct srp_direct_buf *, int,
55 enum dma_data_direction, unsigned int);
56extern int srp_target_alloc(struct srp_target *, struct device *, size_t, size_t);
57extern void srp_target_free(struct srp_target *);
58
59extern struct iu_entry *srp_iu_get(struct srp_target *);
60extern void srp_iu_put(struct iu_entry *);
61
62extern int srp_cmd_queue(struct Scsi_Host *, struct srp_cmd *, void *, u64);
63extern int srp_transfer_data(struct scsi_cmnd *, struct srp_cmd *,
64 srp_rdma_t, int, int);
65
66
67static inline struct srp_target *host_to_srp_target(struct Scsi_Host *host)
68{
69 return (struct srp_target *) host->hostdata;
70}
71
72static inline int srp_cmd_direction(struct srp_cmd *cmd)
73{
74 return (cmd->buf_fmt >> 4) ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
75}
76
77#endif
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index be117f812deb..d6948d0e8cdb 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -8,6 +8,7 @@
8 8
9struct request; 9struct request;
10struct scatterlist; 10struct scatterlist;
11struct Scsi_Host;
11struct scsi_device; 12struct scsi_device;
12 13
13 14
@@ -72,6 +73,9 @@ struct scsi_cmnd {
72 unsigned short use_sg; /* Number of pieces of scatter-gather */ 73 unsigned short use_sg; /* Number of pieces of scatter-gather */
73 unsigned short sglist_len; /* size of malloc'd scatter-gather list */ 74 unsigned short sglist_len; /* size of malloc'd scatter-gather list */
74 75
76 /* offset in cmd we are at (for multi-transfer tgt cmds) */
77 unsigned offset;
78
75 unsigned underflow; /* Return error if less than 79 unsigned underflow; /* Return error if less than
76 this amount is transferred */ 80 this amount is transferred */
77 81
@@ -119,7 +123,10 @@ struct scsi_cmnd {
119}; 123};
120 124
121extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t); 125extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
126extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
122extern void scsi_put_command(struct scsi_cmnd *); 127extern void scsi_put_command(struct scsi_cmnd *);
128extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
129 struct device *);
123extern void scsi_io_completion(struct scsi_cmnd *, unsigned int); 130extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
124extern void scsi_finish_command(struct scsi_cmnd *cmd); 131extern void scsi_finish_command(struct scsi_cmnd *cmd);
125extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd); 132extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
@@ -128,4 +135,7 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
128 size_t *offset, size_t *len); 135 size_t *offset, size_t *len);
129extern void scsi_kunmap_atomic_sg(void *virt); 136extern void scsi_kunmap_atomic_sg(void *virt);
130 137
138extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
139extern void scsi_free_sgtable(struct scatterlist *, int);
140
131#endif /* _SCSI_SCSI_CMND_H */ 141#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index b401c82036be..ebf31b16dc49 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -223,13 +223,13 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
223 struct scsi_device *); 223 struct scsi_device *);
224 224
225/** 225/**
226 * shost_for_each_device - iterate over all devices of a host 226 * shost_for_each_device - iterate over all devices of a host
227 * @sdev: iterator 227 * @sdev: the &struct scsi_device to use as a cursor
228 * @host: host whiches devices we want to iterate over 228 * @shost: the &struct scsi_host to iterate over
229 * 229 *
230 * This traverses over each devices of @shost. The devices have 230 * Iterator that returns each device attached to @shost. This loop
231 * a reference that must be released by scsi_host_put when breaking 231 * takes a reference on each device and releases it at the end. If
232 * out of the loop. 232 * you break out of the loop, you must call scsi_device_put(sdev).
233 */ 233 */
234#define shost_for_each_device(sdev, shost) \ 234#define shost_for_each_device(sdev, shost) \
235 for ((sdev) = __scsi_iterate_devices((shost), NULL); \ 235 for ((sdev) = __scsi_iterate_devices((shost), NULL); \
@@ -237,17 +237,17 @@ extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
237 (sdev) = __scsi_iterate_devices((shost), (sdev))) 237 (sdev) = __scsi_iterate_devices((shost), (sdev)))
238 238
239/** 239/**
240 * __shost_for_each_device - iterate over all devices of a host (UNLOCKED) 240 * __shost_for_each_device - iterate over all devices of a host (UNLOCKED)
241 * @sdev: iterator 241 * @sdev: the &struct scsi_device to use as a cursor
242 * @host: host whiches devices we want to iterate over 242 * @shost: the &struct scsi_host to iterate over
243 * 243 *
244 * This traverses over each devices of @shost. It does _not_ take a 244 * Iterator that returns each device attached to @shost. It does _not_
245 * reference on the scsi_device, thus it the whole loop must be protected 245 * take a reference on the scsi_device, so the whole loop must be
246 * by shost->host_lock. 246 * protected by shost->host_lock.
247 * 247 *
248 * Note: The only reason why drivers would want to use this is because 248 * Note: The only reason to use this is because you need to access the
249 * they're need to access the device list in irq context. Otherwise you 249 * device list in interrupt context. Otherwise you really want to use
250 * really want to use shost_for_each_device instead. 250 * shost_for_each_device instead.
251 */ 251 */
252#define __shost_for_each_device(sdev, shost) \ 252#define __shost_for_each_device(sdev, shost) \
253 list_for_each_entry((sdev), &((shost)->__devices), siblings) 253 list_for_each_entry((sdev), &((shost)->__devices), siblings)
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 39c6f8cc20c3..7f1f411d07af 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -7,6 +7,7 @@
7#include <linux/workqueue.h> 7#include <linux/workqueue.h>
8#include <linux/mutex.h> 8#include <linux/mutex.h>
9 9
10struct request_queue;
10struct block_device; 11struct block_device;
11struct completion; 12struct completion;
12struct module; 13struct module;
@@ -124,6 +125,39 @@ struct scsi_host_template {
124 void (*done)(struct scsi_cmnd *)); 125 void (*done)(struct scsi_cmnd *));
125 126
126 /* 127 /*
128 * The transfer functions are used to queue a scsi command to
129 * the LLD. When the driver is finished processing the command
130 * the done callback is invoked.
131 *
132 * return values: see queuecommand
133 *
134 * If the LLD accepts the cmd, it should set the result to an
135 * appropriate value when completed before calling the done function.
136 *
137 * STATUS: REQUIRED FOR TARGET DRIVERS
138 */
139 /* TODO: rename */
140 int (* transfer_response)(struct scsi_cmnd *,
141 void (*done)(struct scsi_cmnd *));
142 /*
143 * This is called to inform the LLD to transfer cmd->request_bufflen
144 * bytes of the cmd at cmd->offset in the cmd. The cmd->use_sg
145 * speciefies the number of scatterlist entried in the command
146 * and cmd->request_buffer contains the scatterlist.
147 *
148 * If the command cannot be processed in one transfer_data call
149 * becuase a scatterlist within the LLD's limits cannot be
150 * created then transfer_data will be called multiple times.
151 * It is initially called from process context, and later
152 * calls are from the interrup context.
153 */
154 int (* transfer_data)(struct scsi_cmnd *,
155 void (*done)(struct scsi_cmnd *));
156
157 /* Used as callback for the completion of task management request. */
158 int (* tsk_mgmt_response)(u64 mid, int result);
159
160 /*
127 * This is an error handling strategy routine. You don't need to 161 * This is an error handling strategy routine. You don't need to
128 * define one of these if you don't want to - there is a default 162 * define one of these if you don't want to - there is a default
129 * routine that is present that should work in most cases. For those 163 * routine that is present that should work in most cases. For those
@@ -241,6 +275,24 @@ struct scsi_host_template {
241 void (* target_destroy)(struct scsi_target *); 275 void (* target_destroy)(struct scsi_target *);
242 276
243 /* 277 /*
278 * If a host has the ability to discover targets on its own instead
279 * of scanning the entire bus, it can fill in this function and
280 * call scsi_scan_host(). This function will be called periodically
281 * until it returns 1 with the scsi_host and the elapsed time of
282 * the scan in jiffies.
283 *
284 * Status: OPTIONAL
285 */
286 int (* scan_finished)(struct Scsi_Host *, unsigned long);
287
288 /*
289 * If the host wants to be called before the scan starts, but
290 * after the midlayer has set up ready for the scan, it can fill
291 * in this function.
292 */
293 void (* scan_start)(struct Scsi_Host *);
294
295 /*
244 * fill in this function to allow the queue depth of this host 296 * fill in this function to allow the queue depth of this host
245 * to be changeable (on a per device basis). returns either 297 * to be changeable (on a per device basis). returns either
246 * the current queue depth setting (may be different from what 298 * the current queue depth setting (may be different from what
@@ -552,6 +604,9 @@ struct Scsi_Host {
552 /* task mgmt function in progress */ 604 /* task mgmt function in progress */
553 unsigned tmf_in_progress:1; 605 unsigned tmf_in_progress:1;
554 606
607 /* Asynchronous scan in progress */
608 unsigned async_scan:1;
609
555 /* 610 /*
556 * Optional work queue to be utilized by the transport 611 * Optional work queue to be utilized by the transport
557 */ 612 */
@@ -568,6 +623,12 @@ struct Scsi_Host {
568 */ 623 */
569 unsigned int max_host_blocked; 624 unsigned int max_host_blocked;
570 625
626 /*
627 * q used for scsi_tgt msgs, async events or any other requests that
628 * need to be processed in userspace
629 */
630 struct request_queue *uspace_req_q;
631
571 /* legacy crap */ 632 /* legacy crap */
572 unsigned long base; 633 unsigned long base;
573 unsigned long io_port; 634 unsigned long io_port;
@@ -648,11 +709,6 @@ extern const char *scsi_host_state_name(enum scsi_host_state);
648 709
649extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *); 710extern u64 scsi_calculate_bounce_limit(struct Scsi_Host *);
650 711
651static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
652{
653 shost->host_lock = lock;
654}
655
656static inline struct device *scsi_get_device(struct Scsi_Host *shost) 712static inline struct device *scsi_get_device(struct Scsi_Host *shost)
657{ 713{
658 return shost->shost_gendev.parent; 714 return shost->shost_gendev.parent;
@@ -671,6 +727,9 @@ extern void scsi_unblock_requests(struct Scsi_Host *);
671extern void scsi_block_requests(struct Scsi_Host *); 727extern void scsi_block_requests(struct Scsi_Host *);
672 728
673struct class_container; 729struct class_container;
730
731extern struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,
732 void (*) (struct request_queue *));
674/* 733/*
675 * These two functions are used to allocate and free a pseudo device 734 * These two functions are used to allocate and free a pseudo device
676 * which will connect to the host adapter itself rather than any 735 * which will connect to the host adapter itself rather than any
diff --git a/include/scsi/scsi_tgt.h b/include/scsi/scsi_tgt.h
new file mode 100644
index 000000000000..4f4427937af2
--- /dev/null
+++ b/include/scsi/scsi_tgt.h
@@ -0,0 +1,19 @@
1/*
2 * SCSI target definitions
3 */
4
5#include <linux/dma-mapping.h>
6
7struct Scsi_Host;
8struct scsi_cmnd;
9struct scsi_lun;
10
11extern struct Scsi_Host *scsi_tgt_cmd_to_host(struct scsi_cmnd *);
12extern int scsi_tgt_alloc_queue(struct Scsi_Host *);
13extern void scsi_tgt_free_queue(struct Scsi_Host *);
14extern int scsi_tgt_queue_command(struct scsi_cmnd *, struct scsi_lun *, u64);
15extern int scsi_tgt_tsk_mgmt_request(struct Scsi_Host *, int, u64, struct scsi_lun *,
16 void *);
17extern struct scsi_cmnd *scsi_host_get_command(struct Scsi_Host *,
18 enum dma_data_direction, gfp_t);
19extern void scsi_host_put_command(struct Scsi_Host *, struct scsi_cmnd *);
diff --git a/include/scsi/scsi_tgt_if.h b/include/scsi/scsi_tgt_if.h
new file mode 100644
index 000000000000..46d5e70d7215
--- /dev/null
+++ b/include/scsi/scsi_tgt_if.h
@@ -0,0 +1,90 @@
1/*
2 * SCSI target kernel/user interface
3 *
4 * Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
5 * Copyright (C) 2005 Mike Christie <michaelc@cs.wisc.edu>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 */
22#ifndef __SCSI_TARGET_IF_H
23#define __SCSI_TARGET_IF_H
24
25/* user -> kernel */
26#define TGT_UEVENT_CMD_RSP 0x0001
27#define TGT_UEVENT_TSK_MGMT_RSP 0x0002
28
29/* kernel -> user */
30#define TGT_KEVENT_CMD_REQ 0x1001
31#define TGT_KEVENT_CMD_DONE 0x1002
32#define TGT_KEVENT_TSK_MGMT_REQ 0x1003
33
34struct tgt_event_hdr {
35 uint16_t version;
36 uint16_t status;
37 uint16_t type;
38 uint16_t len;
39} __attribute__ ((aligned (sizeof(uint64_t))));
40
41struct tgt_event {
42 struct tgt_event_hdr hdr;
43
44 union {
45 /* user-> kernel */
46 struct {
47 int host_no;
48 uint32_t len;
49 int result;
50 aligned_u64 uaddr;
51 uint8_t rw;
52 aligned_u64 tag;
53 } cmd_rsp;
54 struct {
55 int host_no;
56 aligned_u64 mid;
57 int result;
58 } tsk_mgmt_rsp;
59
60
61 /* kernel -> user */
62 struct {
63 int host_no;
64 uint32_t data_len;
65 uint8_t scb[16];
66 uint8_t lun[8];
67 int attribute;
68 aligned_u64 tag;
69 } cmd_req;
70 struct {
71 int host_no;
72 aligned_u64 tag;
73 int result;
74 } cmd_done;
75 struct {
76 int host_no;
77 int function;
78 aligned_u64 tag;
79 uint8_t lun[8];
80 aligned_u64 mid;
81 } tsk_mgmt_req;
82 } p;
83} __attribute__ ((aligned (sizeof(uint64_t))));
84
85#define TGT_RING_SIZE (1UL << 16)
86#define TGT_RING_PAGES (TGT_RING_SIZE >> PAGE_SHIFT)
87#define TGT_EVENT_PER_PAGE (PAGE_SIZE / sizeof(struct tgt_event))
88#define TGT_MAX_EVENTS (TGT_EVENT_PER_PAGE * TGT_RING_PAGES)
89
90#endif
diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
index fd352323378b..798f7c7ee426 100644
--- a/include/scsi/scsi_transport_fc.h
+++ b/include/scsi/scsi_transport_fc.h
@@ -206,9 +206,9 @@ struct fc_rport { /* aka fc_starget_attrs */
206 u8 flags; 206 u8 flags;
207 struct list_head peers; 207 struct list_head peers;
208 struct device dev; 208 struct device dev;
209 struct work_struct dev_loss_work; 209 struct delayed_work dev_loss_work;
210 struct work_struct scan_work; 210 struct work_struct scan_work;
211 struct work_struct fail_io_work; 211 struct delayed_work fail_io_work;
212 struct work_struct stgt_delete_work; 212 struct work_struct stgt_delete_work;
213 struct work_struct rport_delete_work; 213 struct work_struct rport_delete_work;
214} __attribute__((aligned(sizeof(unsigned long)))); 214} __attribute__((aligned(sizeof(unsigned long))));
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 4b95c89c95c9..d5c218ddc527 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -176,7 +176,7 @@ struct iscsi_cls_session {
176 176
177 /* recovery fields */ 177 /* recovery fields */
178 int recovery_tmo; 178 int recovery_tmo;
179 struct work_struct recovery_work; 179 struct delayed_work recovery_work;
180 180
181 int target_id; 181 int target_id;
182 182
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 53024377f3b8..59633a82de47 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -73,6 +73,8 @@ struct sas_phy {
73 73
74 /* for the list of phys belonging to a port */ 74 /* for the list of phys belonging to a port */
75 struct list_head port_siblings; 75 struct list_head port_siblings;
76
77 struct work_struct reset_work;
76}; 78};
77 79
78#define dev_to_phy(d) \ 80#define dev_to_phy(d) \
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 4c43521cc493..33720397a904 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -511,7 +511,7 @@ struct snd_ac97 {
511#ifdef CONFIG_SND_AC97_POWER_SAVE 511#ifdef CONFIG_SND_AC97_POWER_SAVE
512 unsigned int power_up; /* power states */ 512 unsigned int power_up; /* power states */
513 struct workqueue_struct *power_workq; 513 struct workqueue_struct *power_workq;
514 struct work_struct power_work; 514 struct delayed_work power_work;
515#endif 515#endif
516 struct device dev; 516 struct device dev;
517}; 517};
diff --git a/include/sound/ak4114.h b/include/sound/ak4114.h
index 11702aa0bea9..2ee061625fd0 100644
--- a/include/sound/ak4114.h
+++ b/include/sound/ak4114.h
@@ -182,7 +182,7 @@ struct ak4114 {
182 unsigned char rcs0; 182 unsigned char rcs0;
183 unsigned char rcs1; 183 unsigned char rcs1;
184 struct workqueue_struct *workqueue; 184 struct workqueue_struct *workqueue;
185 struct work_struct work; 185 struct delayed_work work;
186 void *change_callback_private; 186 void *change_callback_private;
187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1); 187 void (*change_callback)(struct ak4114 *ak4114, unsigned char c0, unsigned char c1);
188}; 188};
diff --git a/ipc/util.c b/ipc/util.c
index cd8bb14a431f..a9b7a227b8d4 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -514,6 +514,11 @@ void ipc_rcu_getref(void *ptr)
514 container_of(ptr, struct ipc_rcu_hdr, data)->refcount++; 514 container_of(ptr, struct ipc_rcu_hdr, data)->refcount++;
515} 515}
516 516
517static void ipc_do_vfree(struct work_struct *work)
518{
519 vfree(container_of(work, struct ipc_rcu_sched, work));
520}
521
517/** 522/**
518 * ipc_schedule_free - free ipc + rcu space 523 * ipc_schedule_free - free ipc + rcu space
519 * @head: RCU callback structure for queued work 524 * @head: RCU callback structure for queued work
@@ -528,7 +533,7 @@ static void ipc_schedule_free(struct rcu_head *head)
528 struct ipc_rcu_sched *sched = 533 struct ipc_rcu_sched *sched =
529 container_of(&(grace->data[0]), struct ipc_rcu_sched, data[0]); 534 container_of(&(grace->data[0]), struct ipc_rcu_sched, data[0]);
530 535
531 INIT_WORK(&sched->work, vfree, sched); 536 INIT_WORK(&sched->work, ipc_do_vfree);
532 schedule_work(&sched->work); 537 schedule_work(&sched->work);
533} 538}
534 539
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 2b76dee28496..8d2bea09a4ec 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -114,6 +114,7 @@ EXPORT_SYMBOL(request_module);
114#endif /* CONFIG_KMOD */ 114#endif /* CONFIG_KMOD */
115 115
116struct subprocess_info { 116struct subprocess_info {
117 struct work_struct work;
117 struct completion *complete; 118 struct completion *complete;
118 char *path; 119 char *path;
119 char **argv; 120 char **argv;
@@ -221,9 +222,10 @@ static int wait_for_helper(void *data)
221} 222}
222 223
223/* This is run by khelper thread */ 224/* This is run by khelper thread */
224static void __call_usermodehelper(void *data) 225static void __call_usermodehelper(struct work_struct *work)
225{ 226{
226 struct subprocess_info *sub_info = data; 227 struct subprocess_info *sub_info =
228 container_of(work, struct subprocess_info, work);
227 pid_t pid; 229 pid_t pid;
228 int wait = sub_info->wait; 230 int wait = sub_info->wait;
229 231
@@ -264,6 +266,8 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
264{ 266{
265 DECLARE_COMPLETION_ONSTACK(done); 267 DECLARE_COMPLETION_ONSTACK(done);
266 struct subprocess_info sub_info = { 268 struct subprocess_info sub_info = {
269 .work = __WORK_INITIALIZER(sub_info.work,
270 __call_usermodehelper),
267 .complete = &done, 271 .complete = &done,
268 .path = path, 272 .path = path,
269 .argv = argv, 273 .argv = argv,
@@ -272,7 +276,6 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
272 .wait = wait, 276 .wait = wait,
273 .retval = 0, 277 .retval = 0,
274 }; 278 };
275 DECLARE_WORK(work, __call_usermodehelper, &sub_info);
276 279
277 if (!khelper_wq) 280 if (!khelper_wq)
278 return -EBUSY; 281 return -EBUSY;
@@ -280,7 +283,7 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp,
280 if (path[0] == '\0') 283 if (path[0] == '\0')
281 return 0; 284 return 0;
282 285
283 queue_work(khelper_wq, &work); 286 queue_work(khelper_wq, &sub_info.work);
284 wait_for_completion(&done); 287 wait_for_completion(&done);
285 return sub_info.retval; 288 return sub_info.retval;
286} 289}
@@ -291,6 +294,8 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
291{ 294{
292 DECLARE_COMPLETION(done); 295 DECLARE_COMPLETION(done);
293 struct subprocess_info sub_info = { 296 struct subprocess_info sub_info = {
297 .work = __WORK_INITIALIZER(sub_info.work,
298 __call_usermodehelper),
294 .complete = &done, 299 .complete = &done,
295 .path = path, 300 .path = path,
296 .argv = argv, 301 .argv = argv,
@@ -298,7 +303,6 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
298 .retval = 0, 303 .retval = 0,
299 }; 304 };
300 struct file *f; 305 struct file *f;
301 DECLARE_WORK(work, __call_usermodehelper, &sub_info);
302 306
303 if (!khelper_wq) 307 if (!khelper_wq)
304 return -EBUSY; 308 return -EBUSY;
@@ -318,7 +322,7 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp,
318 } 322 }
319 sub_info.stdin = f; 323 sub_info.stdin = f;
320 324
321 queue_work(khelper_wq, &work); 325 queue_work(khelper_wq, &sub_info.work);
322 wait_for_completion(&done); 326 wait_for_completion(&done);
323 return sub_info.retval; 327 return sub_info.retval;
324} 328}
diff --git a/kernel/kthread.c b/kernel/kthread.c
index 4f9c60ef95e8..1db8c72d0d38 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -31,6 +31,8 @@ struct kthread_create_info
31 /* Result passed back to kthread_create() from keventd. */ 31 /* Result passed back to kthread_create() from keventd. */
32 struct task_struct *result; 32 struct task_struct *result;
33 struct completion done; 33 struct completion done;
34
35 struct work_struct work;
34}; 36};
35 37
36struct kthread_stop_info 38struct kthread_stop_info
@@ -111,9 +113,10 @@ static int kthread(void *_create)
111} 113}
112 114
113/* We are keventd: create a thread. */ 115/* We are keventd: create a thread. */
114static void keventd_create_kthread(void *_create) 116static void keventd_create_kthread(struct work_struct *work)
115{ 117{
116 struct kthread_create_info *create = _create; 118 struct kthread_create_info *create =
119 container_of(work, struct kthread_create_info, work);
117 int pid; 120 int pid;
118 121
119 /* We want our own signal handler (we take no signals by default). */ 122 /* We want our own signal handler (we take no signals by default). */
@@ -154,20 +157,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
154 ...) 157 ...)
155{ 158{
156 struct kthread_create_info create; 159 struct kthread_create_info create;
157 DECLARE_WORK(work, keventd_create_kthread, &create);
158 160
159 create.threadfn = threadfn; 161 create.threadfn = threadfn;
160 create.data = data; 162 create.data = data;
161 init_completion(&create.started); 163 init_completion(&create.started);
162 init_completion(&create.done); 164 init_completion(&create.done);
165 INIT_WORK(&create.work, keventd_create_kthread);
163 166
164 /* 167 /*
165 * The workqueue needs to start up first: 168 * The workqueue needs to start up first:
166 */ 169 */
167 if (!helper_wq) 170 if (!helper_wq)
168 work.func(work.data); 171 create.work.func(&create.work);
169 else { 172 else {
170 queue_work(helper_wq, &work); 173 queue_work(helper_wq, &create.work);
171 wait_for_completion(&create.done); 174 wait_for_completion(&create.done);
172 } 175 }
173 if (!IS_ERR(create.result)) { 176 if (!IS_ERR(create.result)) {
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c
index f1f900ac3164..678ec736076b 100644
--- a/kernel/power/poweroff.c
+++ b/kernel/power/poweroff.c
@@ -16,12 +16,12 @@
16 * callback we use. 16 * callback we use.
17 */ 17 */
18 18
19static void do_poweroff(void *dummy) 19static void do_poweroff(struct work_struct *dummy)
20{ 20{
21 kernel_power_off(); 21 kernel_power_off();
22} 22}
23 23
24static DECLARE_WORK(poweroff_work, do_poweroff, NULL); 24static DECLARE_WORK(poweroff_work, do_poweroff);
25 25
26static void handle_poweroff(int key, struct tty_struct *tty) 26static void handle_poweroff(int key, struct tty_struct *tty)
27{ 27{
diff --git a/kernel/relay.c b/kernel/relay.c
index f04bbdb56ac2..2b92e8ece85b 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -308,9 +308,10 @@ static struct rchan_callbacks default_channel_callbacks = {
308 * reason waking is deferred is that calling directly from write 308 * reason waking is deferred is that calling directly from write
309 * causes problems if you're writing from say the scheduler. 309 * causes problems if you're writing from say the scheduler.
310 */ 310 */
311static void wakeup_readers(void *private) 311static void wakeup_readers(struct work_struct *work)
312{ 312{
313 struct rchan_buf *buf = private; 313 struct rchan_buf *buf =
314 container_of(work, struct rchan_buf, wake_readers.work);
314 wake_up_interruptible(&buf->read_wait); 315 wake_up_interruptible(&buf->read_wait);
315} 316}
316 317
@@ -328,7 +329,7 @@ static inline void __relay_reset(struct rchan_buf *buf, unsigned int init)
328 if (init) { 329 if (init) {
329 init_waitqueue_head(&buf->read_wait); 330 init_waitqueue_head(&buf->read_wait);
330 kref_init(&buf->kref); 331 kref_init(&buf->kref);
331 INIT_WORK(&buf->wake_readers, NULL, NULL); 332 INIT_DELAYED_WORK(&buf->wake_readers, NULL);
332 } else { 333 } else {
333 cancel_delayed_work(&buf->wake_readers); 334 cancel_delayed_work(&buf->wake_readers);
334 flush_scheduled_work(); 335 flush_scheduled_work();
@@ -549,7 +550,8 @@ size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
549 buf->padding[old_subbuf]; 550 buf->padding[old_subbuf];
550 smp_mb(); 551 smp_mb();
551 if (waitqueue_active(&buf->read_wait)) { 552 if (waitqueue_active(&buf->read_wait)) {
552 PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf); 553 PREPARE_DELAYED_WORK(&buf->wake_readers,
554 wakeup_readers);
553 schedule_delayed_work(&buf->wake_readers, 1); 555 schedule_delayed_work(&buf->wake_readers, 1);
554 } 556 }
555 } 557 }
diff --git a/kernel/sys.c b/kernel/sys.c
index 98489d82801b..c87b461de38d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -880,7 +880,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
880 return 0; 880 return 0;
881} 881}
882 882
883static void deferred_cad(void *dummy) 883static void deferred_cad(struct work_struct *dummy)
884{ 884{
885 kernel_restart(NULL); 885 kernel_restart(NULL);
886} 886}
@@ -892,7 +892,7 @@ static void deferred_cad(void *dummy)
892 */ 892 */
893void ctrl_alt_del(void) 893void ctrl_alt_del(void)
894{ 894{
895 static DECLARE_WORK(cad_work, deferred_cad, NULL); 895 static DECLARE_WORK(cad_work, deferred_cad);
896 896
897 if (C_A_D) 897 if (C_A_D)
898 schedule_work(&cad_work); 898 schedule_work(&cad_work);
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 17c2f03d2c27..8d1e7cb8a51a 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -80,6 +80,29 @@ static inline int is_single_threaded(struct workqueue_struct *wq)
80 return list_empty(&wq->list); 80 return list_empty(&wq->list);
81} 81}
82 82
83static inline void set_wq_data(struct work_struct *work, void *wq)
84{
85 unsigned long new, old, res;
86
87 /* assume the pending flag is already set and that the task has already
88 * been queued on this workqueue */
89 new = (unsigned long) wq | (1UL << WORK_STRUCT_PENDING);
90 res = work->management;
91 if (res != new) {
92 do {
93 old = res;
94 new = (unsigned long) wq;
95 new |= (old & WORK_STRUCT_FLAG_MASK);
96 res = cmpxchg(&work->management, old, new);
97 } while (res != old);
98 }
99}
100
101static inline void *get_wq_data(struct work_struct *work)
102{
103 return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK);
104}
105
83/* Preempt must be disabled. */ 106/* Preempt must be disabled. */
84static void __queue_work(struct cpu_workqueue_struct *cwq, 107static void __queue_work(struct cpu_workqueue_struct *cwq,
85 struct work_struct *work) 108 struct work_struct *work)
@@ -87,7 +110,7 @@ static void __queue_work(struct cpu_workqueue_struct *cwq,
87 unsigned long flags; 110 unsigned long flags;
88 111
89 spin_lock_irqsave(&cwq->lock, flags); 112 spin_lock_irqsave(&cwq->lock, flags);
90 work->wq_data = cwq; 113 set_wq_data(work, cwq);
91 list_add_tail(&work->entry, &cwq->worklist); 114 list_add_tail(&work->entry, &cwq->worklist);
92 cwq->insert_sequence++; 115 cwq->insert_sequence++;
93 wake_up(&cwq->more_work); 116 wake_up(&cwq->more_work);
@@ -108,7 +131,7 @@ int fastcall queue_work(struct workqueue_struct *wq, struct work_struct *work)
108{ 131{
109 int ret = 0, cpu = get_cpu(); 132 int ret = 0, cpu = get_cpu();
110 133
111 if (!test_and_set_bit(0, &work->pending)) { 134 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
112 if (unlikely(is_single_threaded(wq))) 135 if (unlikely(is_single_threaded(wq)))
113 cpu = singlethread_cpu; 136 cpu = singlethread_cpu;
114 BUG_ON(!list_empty(&work->entry)); 137 BUG_ON(!list_empty(&work->entry));
@@ -122,38 +145,42 @@ EXPORT_SYMBOL_GPL(queue_work);
122 145
123static void delayed_work_timer_fn(unsigned long __data) 146static void delayed_work_timer_fn(unsigned long __data)
124{ 147{
125 struct work_struct *work = (struct work_struct *)__data; 148 struct delayed_work *dwork = (struct delayed_work *)__data;
126 struct workqueue_struct *wq = work->wq_data; 149 struct workqueue_struct *wq = get_wq_data(&dwork->work);
127 int cpu = smp_processor_id(); 150 int cpu = smp_processor_id();
128 151
129 if (unlikely(is_single_threaded(wq))) 152 if (unlikely(is_single_threaded(wq)))
130 cpu = singlethread_cpu; 153 cpu = singlethread_cpu;
131 154
132 __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), work); 155 __queue_work(per_cpu_ptr(wq->cpu_wq, cpu), &dwork->work);
133} 156}
134 157
135/** 158/**
136 * queue_delayed_work - queue work on a workqueue after delay 159 * queue_delayed_work - queue work on a workqueue after delay
137 * @wq: workqueue to use 160 * @wq: workqueue to use
138 * @work: work to queue 161 * @work: delayable work to queue
139 * @delay: number of jiffies to wait before queueing 162 * @delay: number of jiffies to wait before queueing
140 * 163 *
141 * Returns 0 if @work was already on a queue, non-zero otherwise. 164 * Returns 0 if @work was already on a queue, non-zero otherwise.
142 */ 165 */
143int fastcall queue_delayed_work(struct workqueue_struct *wq, 166int fastcall queue_delayed_work(struct workqueue_struct *wq,
144 struct work_struct *work, unsigned long delay) 167 struct delayed_work *dwork, unsigned long delay)
145{ 168{
146 int ret = 0; 169 int ret = 0;
147 struct timer_list *timer = &work->timer; 170 struct timer_list *timer = &dwork->timer;
171 struct work_struct *work = &dwork->work;
172
173 if (delay == 0)
174 return queue_work(wq, work);
148 175
149 if (!test_and_set_bit(0, &work->pending)) { 176 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
150 BUG_ON(timer_pending(timer)); 177 BUG_ON(timer_pending(timer));
151 BUG_ON(!list_empty(&work->entry)); 178 BUG_ON(!list_empty(&work->entry));
152 179
153 /* This stores wq for the moment, for the timer_fn */ 180 /* This stores wq for the moment, for the timer_fn */
154 work->wq_data = wq; 181 set_wq_data(work, wq);
155 timer->expires = jiffies + delay; 182 timer->expires = jiffies + delay;
156 timer->data = (unsigned long)work; 183 timer->data = (unsigned long)dwork;
157 timer->function = delayed_work_timer_fn; 184 timer->function = delayed_work_timer_fn;
158 add_timer(timer); 185 add_timer(timer);
159 ret = 1; 186 ret = 1;
@@ -172,19 +199,20 @@ EXPORT_SYMBOL_GPL(queue_delayed_work);
172 * Returns 0 if @work was already on a queue, non-zero otherwise. 199 * Returns 0 if @work was already on a queue, non-zero otherwise.
173 */ 200 */
174int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, 201int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
175 struct work_struct *work, unsigned long delay) 202 struct delayed_work *dwork, unsigned long delay)
176{ 203{
177 int ret = 0; 204 int ret = 0;
178 struct timer_list *timer = &work->timer; 205 struct timer_list *timer = &dwork->timer;
206 struct work_struct *work = &dwork->work;
179 207
180 if (!test_and_set_bit(0, &work->pending)) { 208 if (!test_and_set_bit(WORK_STRUCT_PENDING, &work->management)) {
181 BUG_ON(timer_pending(timer)); 209 BUG_ON(timer_pending(timer));
182 BUG_ON(!list_empty(&work->entry)); 210 BUG_ON(!list_empty(&work->entry));
183 211
184 /* This stores wq for the moment, for the timer_fn */ 212 /* This stores wq for the moment, for the timer_fn */
185 work->wq_data = wq; 213 set_wq_data(work, wq);
186 timer->expires = jiffies + delay; 214 timer->expires = jiffies + delay;
187 timer->data = (unsigned long)work; 215 timer->data = (unsigned long)dwork;
188 timer->function = delayed_work_timer_fn; 216 timer->function = delayed_work_timer_fn;
189 add_timer_on(timer, cpu); 217 add_timer_on(timer, cpu);
190 ret = 1; 218 ret = 1;
@@ -212,15 +240,15 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
212 while (!list_empty(&cwq->worklist)) { 240 while (!list_empty(&cwq->worklist)) {
213 struct work_struct *work = list_entry(cwq->worklist.next, 241 struct work_struct *work = list_entry(cwq->worklist.next,
214 struct work_struct, entry); 242 struct work_struct, entry);
215 void (*f) (void *) = work->func; 243 work_func_t f = work->func;
216 void *data = work->data;
217 244
218 list_del_init(cwq->worklist.next); 245 list_del_init(cwq->worklist.next);
219 spin_unlock_irqrestore(&cwq->lock, flags); 246 spin_unlock_irqrestore(&cwq->lock, flags);
220 247
221 BUG_ON(work->wq_data != cwq); 248 BUG_ON(get_wq_data(work) != cwq);
222 clear_bit(0, &work->pending); 249 if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management))
223 f(data); 250 work_release(work);
251 f(work);
224 252
225 spin_lock_irqsave(&cwq->lock, flags); 253 spin_lock_irqsave(&cwq->lock, flags);
226 cwq->remove_sequence++; 254 cwq->remove_sequence++;
@@ -468,38 +496,37 @@ EXPORT_SYMBOL(schedule_work);
468 496
469/** 497/**
470 * schedule_delayed_work - put work task in global workqueue after delay 498 * schedule_delayed_work - put work task in global workqueue after delay
471 * @work: job to be done 499 * @dwork: job to be done
472 * @delay: number of jiffies to wait 500 * @delay: number of jiffies to wait or 0 for immediate execution
473 * 501 *
474 * After waiting for a given time this puts a job in the kernel-global 502 * After waiting for a given time this puts a job in the kernel-global
475 * workqueue. 503 * workqueue.
476 */ 504 */
477int fastcall schedule_delayed_work(struct work_struct *work, unsigned long delay) 505int fastcall schedule_delayed_work(struct delayed_work *dwork, unsigned long delay)
478{ 506{
479 return queue_delayed_work(keventd_wq, work, delay); 507 return queue_delayed_work(keventd_wq, dwork, delay);
480} 508}
481EXPORT_SYMBOL(schedule_delayed_work); 509EXPORT_SYMBOL(schedule_delayed_work);
482 510
483/** 511/**
484 * schedule_delayed_work_on - queue work in global workqueue on CPU after delay 512 * schedule_delayed_work_on - queue work in global workqueue on CPU after delay
485 * @cpu: cpu to use 513 * @cpu: cpu to use
486 * @work: job to be done 514 * @dwork: job to be done
487 * @delay: number of jiffies to wait 515 * @delay: number of jiffies to wait
488 * 516 *
489 * After waiting for a given time this puts a job in the kernel-global 517 * After waiting for a given time this puts a job in the kernel-global
490 * workqueue on the specified CPU. 518 * workqueue on the specified CPU.
491 */ 519 */
492int schedule_delayed_work_on(int cpu, 520int schedule_delayed_work_on(int cpu,
493 struct work_struct *work, unsigned long delay) 521 struct delayed_work *dwork, unsigned long delay)
494{ 522{
495 return queue_delayed_work_on(cpu, keventd_wq, work, delay); 523 return queue_delayed_work_on(cpu, keventd_wq, dwork, delay);
496} 524}
497EXPORT_SYMBOL(schedule_delayed_work_on); 525EXPORT_SYMBOL(schedule_delayed_work_on);
498 526
499/** 527/**
500 * schedule_on_each_cpu - call a function on each online CPU from keventd 528 * schedule_on_each_cpu - call a function on each online CPU from keventd
501 * @func: the function to call 529 * @func: the function to call
502 * @info: a pointer to pass to func()
503 * 530 *
504 * Returns zero on success. 531 * Returns zero on success.
505 * Returns -ve errno on failure. 532 * Returns -ve errno on failure.
@@ -508,7 +535,7 @@ EXPORT_SYMBOL(schedule_delayed_work_on);
508 * 535 *
509 * schedule_on_each_cpu() is very slow. 536 * schedule_on_each_cpu() is very slow.
510 */ 537 */
511int schedule_on_each_cpu(void (*func)(void *info), void *info) 538int schedule_on_each_cpu(work_func_t func)
512{ 539{
513 int cpu; 540 int cpu;
514 struct work_struct *works; 541 struct work_struct *works;
@@ -519,7 +546,7 @@ int schedule_on_each_cpu(void (*func)(void *info), void *info)
519 546
520 mutex_lock(&workqueue_mutex); 547 mutex_lock(&workqueue_mutex);
521 for_each_online_cpu(cpu) { 548 for_each_online_cpu(cpu) {
522 INIT_WORK(per_cpu_ptr(works, cpu), func, info); 549 INIT_WORK(per_cpu_ptr(works, cpu), func);
523 __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), 550 __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu),
524 per_cpu_ptr(works, cpu)); 551 per_cpu_ptr(works, cpu));
525 } 552 }
@@ -539,12 +566,12 @@ EXPORT_SYMBOL(flush_scheduled_work);
539 * cancel_rearming_delayed_workqueue - reliably kill off a delayed 566 * cancel_rearming_delayed_workqueue - reliably kill off a delayed
540 * work whose handler rearms the delayed work. 567 * work whose handler rearms the delayed work.
541 * @wq: the controlling workqueue structure 568 * @wq: the controlling workqueue structure
542 * @work: the delayed work struct 569 * @dwork: the delayed work struct
543 */ 570 */
544void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq, 571void cancel_rearming_delayed_workqueue(struct workqueue_struct *wq,
545 struct work_struct *work) 572 struct delayed_work *dwork)
546{ 573{
547 while (!cancel_delayed_work(work)) 574 while (!cancel_delayed_work(dwork))
548 flush_workqueue(wq); 575 flush_workqueue(wq);
549} 576}
550EXPORT_SYMBOL(cancel_rearming_delayed_workqueue); 577EXPORT_SYMBOL(cancel_rearming_delayed_workqueue);
@@ -552,18 +579,17 @@ EXPORT_SYMBOL(cancel_rearming_delayed_workqueue);
552/** 579/**
553 * cancel_rearming_delayed_work - reliably kill off a delayed keventd 580 * cancel_rearming_delayed_work - reliably kill off a delayed keventd
554 * work whose handler rearms the delayed work. 581 * work whose handler rearms the delayed work.
555 * @work: the delayed work struct 582 * @dwork: the delayed work struct
556 */ 583 */
557void cancel_rearming_delayed_work(struct work_struct *work) 584void cancel_rearming_delayed_work(struct delayed_work *dwork)
558{ 585{
559 cancel_rearming_delayed_workqueue(keventd_wq, work); 586 cancel_rearming_delayed_workqueue(keventd_wq, dwork);
560} 587}
561EXPORT_SYMBOL(cancel_rearming_delayed_work); 588EXPORT_SYMBOL(cancel_rearming_delayed_work);
562 589
563/** 590/**
564 * execute_in_process_context - reliably execute the routine with user context 591 * execute_in_process_context - reliably execute the routine with user context
565 * @fn: the function to execute 592 * @fn: the function to execute
566 * @data: data to pass to the function
567 * @ew: guaranteed storage for the execute work structure (must 593 * @ew: guaranteed storage for the execute work structure (must
568 * be available when the work executes) 594 * be available when the work executes)
569 * 595 *
@@ -573,15 +599,14 @@ EXPORT_SYMBOL(cancel_rearming_delayed_work);
573 * Returns: 0 - function was executed 599 * Returns: 0 - function was executed
574 * 1 - function was scheduled for execution 600 * 1 - function was scheduled for execution
575 */ 601 */
576int execute_in_process_context(void (*fn)(void *data), void *data, 602int execute_in_process_context(work_func_t fn, struct execute_work *ew)
577 struct execute_work *ew)
578{ 603{
579 if (!in_interrupt()) { 604 if (!in_interrupt()) {
580 fn(data); 605 fn(&ew->work);
581 return 0; 606 return 0;
582 } 607 }
583 608
584 INIT_WORK(&ew->work, fn, data); 609 INIT_WORK(&ew->work, fn);
585 schedule_work(&ew->work); 610 schedule_work(&ew->work);
586 611
587 return 1; 612 return 1;
diff --git a/lib/iomap.c b/lib/iomap.c
index 55689c5d3379..d6ccdd85df53 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -50,6 +50,16 @@
50 } \ 50 } \
51} while (0) 51} while (0)
52 52
53#ifndef pio_read16be
54#define pio_read16be(port) swab16(inw(port))
55#define pio_read32be(port) swab32(inl(port))
56#endif
57
58#ifndef mmio_read16be
59#define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr))
60#define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr))
61#endif
62
53unsigned int fastcall ioread8(void __iomem *addr) 63unsigned int fastcall ioread8(void __iomem *addr)
54{ 64{
55 IO_COND(addr, return inb(port), return readb(addr)); 65 IO_COND(addr, return inb(port), return readb(addr));
@@ -60,7 +70,7 @@ unsigned int fastcall ioread16(void __iomem *addr)
60} 70}
61unsigned int fastcall ioread16be(void __iomem *addr) 71unsigned int fastcall ioread16be(void __iomem *addr)
62{ 72{
63 IO_COND(addr, return inw(port), return be16_to_cpu(__raw_readw(addr))); 73 IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr));
64} 74}
65unsigned int fastcall ioread32(void __iomem *addr) 75unsigned int fastcall ioread32(void __iomem *addr)
66{ 76{
@@ -68,7 +78,7 @@ unsigned int fastcall ioread32(void __iomem *addr)
68} 78}
69unsigned int fastcall ioread32be(void __iomem *addr) 79unsigned int fastcall ioread32be(void __iomem *addr)
70{ 80{
71 IO_COND(addr, return inl(port), return be32_to_cpu(__raw_readl(addr))); 81 IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr));
72} 82}
73EXPORT_SYMBOL(ioread8); 83EXPORT_SYMBOL(ioread8);
74EXPORT_SYMBOL(ioread16); 84EXPORT_SYMBOL(ioread16);
@@ -76,6 +86,16 @@ EXPORT_SYMBOL(ioread16be);
76EXPORT_SYMBOL(ioread32); 86EXPORT_SYMBOL(ioread32);
77EXPORT_SYMBOL(ioread32be); 87EXPORT_SYMBOL(ioread32be);
78 88
89#ifndef pio_write16be
90#define pio_write16be(val,port) outw(swab16(val),port)
91#define pio_write32be(val,port) outl(swab32(val),port)
92#endif
93
94#ifndef mmio_write16be
95#define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port)
96#define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port)
97#endif
98
79void fastcall iowrite8(u8 val, void __iomem *addr) 99void fastcall iowrite8(u8 val, void __iomem *addr)
80{ 100{
81 IO_COND(addr, outb(val,port), writeb(val, addr)); 101 IO_COND(addr, outb(val,port), writeb(val, addr));
@@ -86,7 +106,7 @@ void fastcall iowrite16(u16 val, void __iomem *addr)
86} 106}
87void fastcall iowrite16be(u16 val, void __iomem *addr) 107void fastcall iowrite16be(u16 val, void __iomem *addr)
88{ 108{
89 IO_COND(addr, outw(val,port), __raw_writew(cpu_to_be16(val), addr)); 109 IO_COND(addr, pio_write16be(val,port), mmio_write16be(val, addr));
90} 110}
91void fastcall iowrite32(u32 val, void __iomem *addr) 111void fastcall iowrite32(u32 val, void __iomem *addr)
92{ 112{
@@ -94,7 +114,7 @@ void fastcall iowrite32(u32 val, void __iomem *addr)
94} 114}
95void fastcall iowrite32be(u32 val, void __iomem *addr) 115void fastcall iowrite32be(u32 val, void __iomem *addr)
96{ 116{
97 IO_COND(addr, outl(val,port), __raw_writel(cpu_to_be32(val), addr)); 117 IO_COND(addr, pio_write32be(val,port), mmio_write32be(val, addr));
98} 118}
99EXPORT_SYMBOL(iowrite8); 119EXPORT_SYMBOL(iowrite8);
100EXPORT_SYMBOL(iowrite16); 120EXPORT_SYMBOL(iowrite16);
@@ -108,6 +128,7 @@ EXPORT_SYMBOL(iowrite32be);
108 * convert to CPU byte order. We write in "IO byte 128 * convert to CPU byte order. We write in "IO byte
109 * order" (we also don't have IO barriers). 129 * order" (we also don't have IO barriers).
110 */ 130 */
131#ifndef mmio_insb
111static inline void mmio_insb(void __iomem *addr, u8 *dst, int count) 132static inline void mmio_insb(void __iomem *addr, u8 *dst, int count)
112{ 133{
113 while (--count >= 0) { 134 while (--count >= 0) {
@@ -132,7 +153,9 @@ static inline void mmio_insl(void __iomem *addr, u32 *dst, int count)
132 dst++; 153 dst++;
133 } 154 }
134} 155}
156#endif
135 157
158#ifndef mmio_outsb
136static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count) 159static inline void mmio_outsb(void __iomem *addr, const u8 *src, int count)
137{ 160{
138 while (--count >= 0) { 161 while (--count >= 0) {
@@ -154,6 +177,7 @@ static inline void mmio_outsl(void __iomem *addr, const u32 *src, int count)
154 src++; 177 src++;
155 } 178 }
156} 179}
180#endif
157 181
158void fastcall ioread8_rep(void __iomem *addr, void *dst, unsigned long count) 182void fastcall ioread8_rep(void __iomem *addr, void *dst, unsigned long count)
159{ 183{
diff --git a/mm/filemap.c b/mm/filemap.c
index 7b84dc814347..13df01c50479 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1893,6 +1893,7 @@ int should_remove_suid(struct dentry *dentry)
1893 1893
1894 return 0; 1894 return 0;
1895} 1895}
1896EXPORT_SYMBOL(should_remove_suid);
1896 1897
1897int __remove_suid(struct dentry *dentry, int kill) 1898int __remove_suid(struct dentry *dentry, int kill)
1898{ 1899{
diff --git a/mm/nommu.c b/mm/nommu.c
index 8bdde9508f3b..6a2a8aada401 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -497,15 +497,17 @@ static int validate_mmap_request(struct file *file,
497 (flags & MAP_TYPE) != MAP_SHARED) 497 (flags & MAP_TYPE) != MAP_SHARED)
498 return -EINVAL; 498 return -EINVAL;
499 499
500 if (PAGE_ALIGN(len) == 0) 500 if (!len)
501 return addr;
502
503 if (len > TASK_SIZE)
504 return -EINVAL; 501 return -EINVAL;
505 502
503 /* Careful about overflows.. */
504 len = PAGE_ALIGN(len);
505 if (!len || len > TASK_SIZE)
506 return -ENOMEM;
507
506 /* offset overflow? */ 508 /* offset overflow? */
507 if ((pgoff + (len >> PAGE_SHIFT)) < pgoff) 509 if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
508 return -EINVAL; 510 return -EOVERFLOW;
509 511
510 if (file) { 512 if (file) {
511 /* validate file mapping requests */ 513 /* validate file mapping requests */
diff --git a/mm/slab.c b/mm/slab.c
index 3c4a7e34eddc..5de81473df34 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -313,7 +313,7 @@ static int drain_freelist(struct kmem_cache *cache,
313static void free_block(struct kmem_cache *cachep, void **objpp, int len, 313static void free_block(struct kmem_cache *cachep, void **objpp, int len,
314 int node); 314 int node);
315static int enable_cpucache(struct kmem_cache *cachep); 315static int enable_cpucache(struct kmem_cache *cachep);
316static void cache_reap(void *unused); 316static void cache_reap(struct work_struct *unused);
317 317
318/* 318/*
319 * This function must be completely optimized away if a constant is passed to 319 * This function must be completely optimized away if a constant is passed to
@@ -753,7 +753,7 @@ int slab_is_available(void)
753 return g_cpucache_up == FULL; 753 return g_cpucache_up == FULL;
754} 754}
755 755
756static DEFINE_PER_CPU(struct work_struct, reap_work); 756static DEFINE_PER_CPU(struct delayed_work, reap_work);
757 757
758static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep) 758static inline struct array_cache *cpu_cache_get(struct kmem_cache *cachep)
759{ 759{
@@ -916,16 +916,16 @@ static void next_reap_node(void)
916 */ 916 */
917static void __devinit start_cpu_timer(int cpu) 917static void __devinit start_cpu_timer(int cpu)
918{ 918{
919 struct work_struct *reap_work = &per_cpu(reap_work, cpu); 919 struct delayed_work *reap_work = &per_cpu(reap_work, cpu);
920 920
921 /* 921 /*
922 * When this gets called from do_initcalls via cpucache_init(), 922 * When this gets called from do_initcalls via cpucache_init(),
923 * init_workqueues() has already run, so keventd will be setup 923 * init_workqueues() has already run, so keventd will be setup
924 * at that time. 924 * at that time.
925 */ 925 */
926 if (keventd_up() && reap_work->func == NULL) { 926 if (keventd_up() && reap_work->work.func == NULL) {
927 init_reap_node(cpu); 927 init_reap_node(cpu);
928 INIT_WORK(reap_work, cache_reap, NULL); 928 INIT_DELAYED_WORK(reap_work, cache_reap);
929 schedule_delayed_work_on(cpu, reap_work, HZ + 3 * cpu); 929 schedule_delayed_work_on(cpu, reap_work, HZ + 3 * cpu);
930 } 930 }
931} 931}
@@ -3815,7 +3815,7 @@ void drain_array(struct kmem_cache *cachep, struct kmem_list3 *l3,
3815 * If we cannot acquire the cache chain mutex then just give up - we'll try 3815 * If we cannot acquire the cache chain mutex then just give up - we'll try
3816 * again on the next iteration. 3816 * again on the next iteration.
3817 */ 3817 */
3818static void cache_reap(void *unused) 3818static void cache_reap(struct work_struct *unused)
3819{ 3819{
3820 struct kmem_cache *searchp; 3820 struct kmem_cache *searchp;
3821 struct kmem_list3 *l3; 3821 struct kmem_list3 *l3;
diff --git a/mm/swap.c b/mm/swap.c
index 2e0e871f542f..d9a3770d8f3c 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -216,7 +216,7 @@ void lru_add_drain(void)
216} 216}
217 217
218#ifdef CONFIG_NUMA 218#ifdef CONFIG_NUMA
219static void lru_add_drain_per_cpu(void *dummy) 219static void lru_add_drain_per_cpu(struct work_struct *dummy)
220{ 220{
221 lru_add_drain(); 221 lru_add_drain();
222} 222}
@@ -226,7 +226,7 @@ static void lru_add_drain_per_cpu(void *dummy)
226 */ 226 */
227int lru_add_drain_all(void) 227int lru_add_drain_all(void)
228{ 228{
229 return schedule_on_each_cpu(lru_add_drain_per_cpu, NULL); 229 return schedule_on_each_cpu(lru_add_drain_per_cpu);
230} 230}
231 231
232#else 232#else
diff --git a/net/atm/lec.c b/net/atm/lec.c
index 5946ec63724f..3fc0abeeaf34 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1454,7 +1454,7 @@ static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
1454 1454
1455#define LEC_ARP_REFRESH_INTERVAL (3*HZ) 1455#define LEC_ARP_REFRESH_INTERVAL (3*HZ)
1456 1456
1457static void lec_arp_check_expire(void *data); 1457static void lec_arp_check_expire(struct work_struct *work);
1458static void lec_arp_expire_arp(unsigned long data); 1458static void lec_arp_expire_arp(unsigned long data);
1459 1459
1460/* 1460/*
@@ -1477,7 +1477,7 @@ static void lec_arp_init(struct lec_priv *priv)
1477 INIT_HLIST_HEAD(&priv->lec_no_forward); 1477 INIT_HLIST_HEAD(&priv->lec_no_forward);
1478 INIT_HLIST_HEAD(&priv->mcast_fwds); 1478 INIT_HLIST_HEAD(&priv->mcast_fwds);
1479 spin_lock_init(&priv->lec_arp_lock); 1479 spin_lock_init(&priv->lec_arp_lock);
1480 INIT_WORK(&priv->lec_arp_work, lec_arp_check_expire, priv); 1480 INIT_DELAYED_WORK(&priv->lec_arp_work, lec_arp_check_expire);
1481 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL); 1481 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
1482} 1482}
1483 1483
@@ -1875,10 +1875,11 @@ static void lec_arp_expire_vcc(unsigned long data)
1875 * to ESI_FORWARD_DIRECT. This causes the flush period to end 1875 * to ESI_FORWARD_DIRECT. This causes the flush period to end
1876 * regardless of the progress of the flush protocol. 1876 * regardless of the progress of the flush protocol.
1877 */ 1877 */
1878static void lec_arp_check_expire(void *data) 1878static void lec_arp_check_expire(struct work_struct *work)
1879{ 1879{
1880 unsigned long flags; 1880 unsigned long flags;
1881 struct lec_priv *priv = data; 1881 struct lec_priv *priv =
1882 container_of(work, struct lec_priv, lec_arp_work.work);
1882 struct hlist_node *node, *next; 1883 struct hlist_node *node, *next;
1883 struct lec_arp_table *entry; 1884 struct lec_arp_table *entry;
1884 unsigned long now; 1885 unsigned long now;
diff --git a/net/atm/lec.h b/net/atm/lec.h
index 24cc95f86741..99136babd535 100644
--- a/net/atm/lec.h
+++ b/net/atm/lec.h
@@ -92,7 +92,7 @@ struct lec_priv {
92 spinlock_t lec_arp_lock; 92 spinlock_t lec_arp_lock;
93 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 93 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */
94 struct atm_vcc *lecd; 94 struct atm_vcc *lecd;
95 struct work_struct lec_arp_work; /* C10 */ 95 struct delayed_work lec_arp_work; /* C10 */
96 unsigned int maximum_unknown_frame_count; 96 unsigned int maximum_unknown_frame_count;
97 /* 97 /*
98 * Within the period of time defined by this variable, the client will send 98 * Within the period of time defined by this variable, the client will send
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 3eeeb7a86e75..d4c935692ccf 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -237,9 +237,9 @@ static void bt_release(struct device *dev)
237 kfree(data); 237 kfree(data);
238} 238}
239 239
240static void add_conn(void *data) 240static void add_conn(struct work_struct *work)
241{ 241{
242 struct hci_conn *conn = data; 242 struct hci_conn *conn = container_of(work, struct hci_conn, work);
243 int i; 243 int i;
244 244
245 if (device_register(&conn->dev) < 0) { 245 if (device_register(&conn->dev) < 0) {
@@ -272,14 +272,14 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
272 272
273 dev_set_drvdata(&conn->dev, conn); 273 dev_set_drvdata(&conn->dev, conn);
274 274
275 INIT_WORK(&conn->work, add_conn, (void *) conn); 275 INIT_WORK(&conn->work, add_conn);
276 276
277 schedule_work(&conn->work); 277 schedule_work(&conn->work);
278} 278}
279 279
280static void del_conn(void *data) 280static void del_conn(struct work_struct *work)
281{ 281{
282 struct hci_conn *conn = data; 282 struct hci_conn *conn = container_of(work, struct hci_conn, work);
283 device_del(&conn->dev); 283 device_del(&conn->dev);
284} 284}
285 285
@@ -287,7 +287,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn)
287{ 287{
288 BT_DBG("conn %p", conn); 288 BT_DBG("conn %p", conn);
289 289
290 INIT_WORK(&conn->work, del_conn, (void *) conn); 290 INIT_WORK(&conn->work, del_conn);
291 291
292 schedule_work(&conn->work); 292 schedule_work(&conn->work);
293} 293}
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index f753c40c11d2..55bb2634c088 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -77,12 +77,16 @@ static int port_cost(struct net_device *dev)
77 * Called from work queue to allow for calling functions that 77 * Called from work queue to allow for calling functions that
78 * might sleep (such as speed check), and to debounce. 78 * might sleep (such as speed check), and to debounce.
79 */ 79 */
80static void port_carrier_check(void *arg) 80static void port_carrier_check(struct work_struct *work)
81{ 81{
82 struct net_device *dev = arg;
83 struct net_bridge_port *p; 82 struct net_bridge_port *p;
83 struct net_device *dev;
84 struct net_bridge *br; 84 struct net_bridge *br;
85 85
86 dev = container_of(work, struct net_bridge_port,
87 carrier_check.work)->dev;
88 work_release(work);
89
86 rtnl_lock(); 90 rtnl_lock();
87 p = dev->br_port; 91 p = dev->br_port;
88 if (!p) 92 if (!p)
@@ -276,7 +280,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br,
276 p->port_no = index; 280 p->port_no = index;
277 br_init_port(p); 281 br_init_port(p);
278 p->state = BR_STATE_DISABLED; 282 p->state = BR_STATE_DISABLED;
279 INIT_WORK(&p->carrier_check, port_carrier_check, dev); 283 INIT_DELAYED_WORK_NAR(&p->carrier_check, port_carrier_check);
280 br_stp_port_timer_init(p); 284 br_stp_port_timer_init(p);
281 285
282 kobject_init(&p->kobj); 286 kobject_init(&p->kobj);
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 74258d86f256..3a534e94c7f3 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -82,7 +82,7 @@ struct net_bridge_port
82 struct timer_list hold_timer; 82 struct timer_list hold_timer;
83 struct timer_list message_age_timer; 83 struct timer_list message_age_timer;
84 struct kobject kobj; 84 struct kobject kobj;
85 struct work_struct carrier_check; 85 struct delayed_work carrier_check;
86 struct rcu_head rcu; 86 struct rcu_head rcu;
87}; 87};
88 88
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 4b36114744c5..549a2ce951b0 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -34,8 +34,8 @@ enum lw_bits {
34static unsigned long linkwatch_flags; 34static unsigned long linkwatch_flags;
35static unsigned long linkwatch_nextevent; 35static unsigned long linkwatch_nextevent;
36 36
37static void linkwatch_event(void *dummy); 37static void linkwatch_event(struct work_struct *dummy);
38static DECLARE_WORK(linkwatch_work, linkwatch_event, NULL); 38static DECLARE_DELAYED_WORK(linkwatch_work, linkwatch_event);
39 39
40static LIST_HEAD(lweventlist); 40static LIST_HEAD(lweventlist);
41static DEFINE_SPINLOCK(lweventlist_lock); 41static DEFINE_SPINLOCK(lweventlist_lock);
@@ -127,7 +127,7 @@ void linkwatch_run_queue(void)
127} 127}
128 128
129 129
130static void linkwatch_event(void *dummy) 130static void linkwatch_event(struct work_struct *dummy)
131{ 131{
132 /* Limit the number of linkwatch events to one 132 /* Limit the number of linkwatch events to one
133 * per second so that a runaway driver does not 133 * per second so that a runaway driver does not
@@ -171,10 +171,9 @@ void linkwatch_fire_event(struct net_device *dev)
171 unsigned long delay = linkwatch_nextevent - jiffies; 171 unsigned long delay = linkwatch_nextevent - jiffies;
172 172
173 /* If we wrap around we'll delay it by at most HZ. */ 173 /* If we wrap around we'll delay it by at most HZ. */
174 if (!delay || delay > HZ) 174 if (delay > HZ)
175 schedule_work(&linkwatch_work); 175 delay = 0;
176 else 176 schedule_delayed_work(&linkwatch_work, delay);
177 schedule_delayed_work(&linkwatch_work, delay);
178 } 177 }
179 } 178 }
180} 179}
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 3c58846fcaa5..b3c559b9ac35 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -50,9 +50,10 @@ static atomic_t trapped;
50static void zap_completion_queue(void); 50static void zap_completion_queue(void);
51static void arp_reply(struct sk_buff *skb); 51static void arp_reply(struct sk_buff *skb);
52 52
53static void queue_process(void *p) 53static void queue_process(struct work_struct *work)
54{ 54{
55 struct netpoll_info *npinfo = p; 55 struct netpoll_info *npinfo =
56 container_of(work, struct netpoll_info, tx_work.work);
56 struct sk_buff *skb; 57 struct sk_buff *skb;
57 58
58 while ((skb = skb_dequeue(&npinfo->txq))) { 59 while ((skb = skb_dequeue(&npinfo->txq))) {
@@ -72,8 +73,6 @@ static void queue_process(void *p)
72 schedule_delayed_work(&npinfo->tx_work, HZ/10); 73 schedule_delayed_work(&npinfo->tx_work, HZ/10);
73 return; 74 return;
74 } 75 }
75
76 netif_tx_unlock_bh(dev);
77 } 76 }
78} 77}
79 78
@@ -263,7 +262,7 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
263 262
264 if (status != NETDEV_TX_OK) { 263 if (status != NETDEV_TX_OK) {
265 skb_queue_tail(&npinfo->txq, skb); 264 skb_queue_tail(&npinfo->txq, skb);
266 schedule_work(&npinfo->tx_work); 265 schedule_delayed_work(&npinfo->tx_work,0);
267 } 266 }
268} 267}
269 268
@@ -628,7 +627,7 @@ int netpoll_setup(struct netpoll *np)
628 spin_lock_init(&npinfo->rx_lock); 627 spin_lock_init(&npinfo->rx_lock);
629 skb_queue_head_init(&npinfo->arp_tx); 628 skb_queue_head_init(&npinfo->arp_tx);
630 skb_queue_head_init(&npinfo->txq); 629 skb_queue_head_init(&npinfo->txq);
631 INIT_WORK(&npinfo->tx_work, queue_process, npinfo); 630 INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
632 631
633 atomic_set(&npinfo->refcnt, 1); 632 atomic_set(&npinfo->refcnt, 1);
634 } else { 633 } else {
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
index 7b52f2a03eef..4c9e26775f72 100644
--- a/net/dccp/minisocks.c
+++ b/net/dccp/minisocks.c
@@ -32,8 +32,7 @@ struct inet_timewait_death_row dccp_death_row = {
32 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0, 32 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0,
33 (unsigned long)&dccp_death_row), 33 (unsigned long)&dccp_death_row),
34 .twkill_work = __WORK_INITIALIZER(dccp_death_row.twkill_work, 34 .twkill_work = __WORK_INITIALIZER(dccp_death_row.twkill_work,
35 inet_twdr_twkill_work, 35 inet_twdr_twkill_work),
36 &dccp_death_row),
37/* Short-time timewait calendar */ 36/* Short-time timewait calendar */
38 37
39 .twcal_hand = -1, 38 .twcal_hand = -1,
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index cf51c87a971d..08386c102954 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -58,9 +58,11 @@ ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211soft
58} 58}
59 59
60void 60void
61ieee80211softmac_assoc_timeout(void *d) 61ieee80211softmac_assoc_timeout(struct work_struct *work)
62{ 62{
63 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 63 struct ieee80211softmac_device *mac =
64 container_of(work, struct ieee80211softmac_device,
65 associnfo.timeout.work);
64 struct ieee80211softmac_network *n; 66 struct ieee80211softmac_network *n;
65 67
66 mutex_lock(&mac->associnfo.mutex); 68 mutex_lock(&mac->associnfo.mutex);
@@ -186,9 +188,11 @@ ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void
186 188
187/* This function is called to handle userspace requests (asynchronously) */ 189/* This function is called to handle userspace requests (asynchronously) */
188void 190void
189ieee80211softmac_assoc_work(void *d) 191ieee80211softmac_assoc_work(struct work_struct *work)
190{ 192{
191 struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d; 193 struct ieee80211softmac_device *mac =
194 container_of(work, struct ieee80211softmac_device,
195 associnfo.work.work);
192 struct ieee80211softmac_network *found = NULL; 196 struct ieee80211softmac_network *found = NULL;
193 struct ieee80211_network *net = NULL, *best = NULL; 197 struct ieee80211_network *net = NULL, *best = NULL;
194 int bssvalid; 198 int bssvalid;
@@ -412,7 +416,7 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
412 network->authenticated = 0; 416 network->authenticated = 0;
413 /* we don't want to do this more than once ... */ 417 /* we don't want to do this more than once ... */
414 network->auth_desynced_once = 1; 418 network->auth_desynced_once = 1;
415 schedule_work(&mac->associnfo.work); 419 schedule_delayed_work(&mac->associnfo.work, 0);
416 break; 420 break;
417 } 421 }
418 default: 422 default:
@@ -446,7 +450,7 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
446 ieee80211softmac_disassoc(mac); 450 ieee80211softmac_disassoc(mac);
447 451
448 /* try to reassociate */ 452 /* try to reassociate */
449 schedule_work(&mac->associnfo.work); 453 schedule_delayed_work(&mac->associnfo.work, 0);
450 454
451 return 0; 455 return 0;
452} 456}
@@ -466,7 +470,7 @@ ieee80211softmac_handle_reassoc_req(struct net_device * dev,
466 dprintkl(KERN_INFO PFX "reassoc request from unknown network\n"); 470 dprintkl(KERN_INFO PFX "reassoc request from unknown network\n");
467 return 0; 471 return 0;
468 } 472 }
469 schedule_work(&mac->associnfo.work); 473 schedule_delayed_work(&mac->associnfo.work, 0);
470 474
471 return 0; 475 return 0;
472} 476}
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 0612015f1c78..6012705aa4f8 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -26,7 +26,7 @@
26 26
27#include "ieee80211softmac_priv.h" 27#include "ieee80211softmac_priv.h"
28 28
29static void ieee80211softmac_auth_queue(void *data); 29static void ieee80211softmac_auth_queue(struct work_struct *work);
30 30
31/* Queues an auth request to the desired AP */ 31/* Queues an auth request to the desired AP */
32int 32int
@@ -54,14 +54,14 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
54 auth->mac = mac; 54 auth->mac = mac;
55 auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT; 55 auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT;
56 auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST; 56 auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST;
57 INIT_WORK(&auth->work, &ieee80211softmac_auth_queue, (void *)auth); 57 INIT_DELAYED_WORK(&auth->work, ieee80211softmac_auth_queue);
58 58
59 /* Lock (for list) */ 59 /* Lock (for list) */
60 spin_lock_irqsave(&mac->lock, flags); 60 spin_lock_irqsave(&mac->lock, flags);
61 61
62 /* add to list */ 62 /* add to list */
63 list_add_tail(&auth->list, &mac->auth_queue); 63 list_add_tail(&auth->list, &mac->auth_queue);
64 schedule_work(&auth->work); 64 schedule_delayed_work(&auth->work, 0);
65 spin_unlock_irqrestore(&mac->lock, flags); 65 spin_unlock_irqrestore(&mac->lock, flags);
66 66
67 return 0; 67 return 0;
@@ -70,14 +70,15 @@ ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
70 70
71/* Sends an auth request to the desired AP and handles timeouts */ 71/* Sends an auth request to the desired AP and handles timeouts */
72static void 72static void
73ieee80211softmac_auth_queue(void *data) 73ieee80211softmac_auth_queue(struct work_struct *work)
74{ 74{
75 struct ieee80211softmac_device *mac; 75 struct ieee80211softmac_device *mac;
76 struct ieee80211softmac_auth_queue_item *auth; 76 struct ieee80211softmac_auth_queue_item *auth;
77 struct ieee80211softmac_network *net; 77 struct ieee80211softmac_network *net;
78 unsigned long flags; 78 unsigned long flags;
79 79
80 auth = (struct ieee80211softmac_auth_queue_item *)data; 80 auth = container_of(work, struct ieee80211softmac_auth_queue_item,
81 work.work);
81 net = auth->net; 82 net = auth->net;
82 mac = auth->mac; 83 mac = auth->mac;
83 84
@@ -118,9 +119,11 @@ ieee80211softmac_auth_queue(void *data)
118 119
119/* Sends a response to an auth challenge (for shared key auth). */ 120/* Sends a response to an auth challenge (for shared key auth). */
120static void 121static void
121ieee80211softmac_auth_challenge_response(void *_aq) 122ieee80211softmac_auth_challenge_response(struct work_struct *work)
122{ 123{
123 struct ieee80211softmac_auth_queue_item *aq = _aq; 124 struct ieee80211softmac_auth_queue_item *aq =
125 container_of(work, struct ieee80211softmac_auth_queue_item,
126 work.work);
124 127
125 /* Send our response */ 128 /* Send our response */
126 ieee80211softmac_send_mgt_frame(aq->mac, aq->net, IEEE80211_STYPE_AUTH, aq->state); 129 ieee80211softmac_send_mgt_frame(aq->mac, aq->net, IEEE80211_STYPE_AUTH, aq->state);
@@ -234,8 +237,8 @@ ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
234 * we have obviously already sent the initial auth 237 * we have obviously already sent the initial auth
235 * request. */ 238 * request. */
236 cancel_delayed_work(&aq->work); 239 cancel_delayed_work(&aq->work);
237 INIT_WORK(&aq->work, &ieee80211softmac_auth_challenge_response, (void *)aq); 240 INIT_DELAYED_WORK(&aq->work, &ieee80211softmac_auth_challenge_response);
238 schedule_work(&aq->work); 241 schedule_delayed_work(&aq->work, 0);
239 spin_unlock_irqrestore(&mac->lock, flags); 242 spin_unlock_irqrestore(&mac->lock, flags);
240 return 0; 243 return 0;
241 case IEEE80211SOFTMAC_AUTH_SHARED_PASS: 244 case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
@@ -398,6 +401,6 @@ ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *de
398 ieee80211softmac_deauth_from_net(mac, net); 401 ieee80211softmac_deauth_from_net(mac, net);
399 402
400 /* let's try to re-associate */ 403 /* let's try to re-associate */
401 schedule_work(&mac->associnfo.work); 404 schedule_delayed_work(&mac->associnfo.work, 0);
402 return 0; 405 return 0;
403} 406}
diff --git a/net/ieee80211/softmac/ieee80211softmac_event.c b/net/ieee80211/softmac/ieee80211softmac_event.c
index f34fa2ef666b..b9015656cfb3 100644
--- a/net/ieee80211/softmac/ieee80211softmac_event.c
+++ b/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -73,10 +73,12 @@ static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
73 73
74 74
75static void 75static void
76ieee80211softmac_notify_callback(void *d) 76ieee80211softmac_notify_callback(struct work_struct *work)
77{ 77{
78 struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d; 78 struct ieee80211softmac_event *pevent =
79 kfree(d); 79 container_of(work, struct ieee80211softmac_event, work.work);
80 struct ieee80211softmac_event event = *pevent;
81 kfree(pevent);
80 82
81 event.fun(event.mac->dev, event.event_type, event.context); 83 event.fun(event.mac->dev, event.event_type, event.context);
82} 84}
@@ -99,7 +101,7 @@ ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
99 return -ENOMEM; 101 return -ENOMEM;
100 102
101 eventptr->event_type = event; 103 eventptr->event_type = event;
102 INIT_WORK(&eventptr->work, ieee80211softmac_notify_callback, eventptr); 104 INIT_DELAYED_WORK(&eventptr->work, ieee80211softmac_notify_callback);
103 eventptr->fun = fun; 105 eventptr->fun = fun;
104 eventptr->context = context; 106 eventptr->context = context;
105 eventptr->mac = mac; 107 eventptr->mac = mac;
@@ -170,7 +172,7 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
170 /* User may have subscribed to ANY event, so 172 /* User may have subscribed to ANY event, so
171 * we tell them which event triggered it. */ 173 * we tell them which event triggered it. */
172 eventptr->event_type = event; 174 eventptr->event_type = event;
173 schedule_work(&eventptr->work); 175 schedule_delayed_work(&eventptr->work, 0);
174 } 176 }
175 } 177 }
176} 178}
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
index 33aff4f4a471..256207b71dc9 100644
--- a/net/ieee80211/softmac/ieee80211softmac_module.c
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -58,8 +58,8 @@ struct net_device *alloc_ieee80211softmac(int sizeof_priv)
58 INIT_LIST_HEAD(&softmac->events); 58 INIT_LIST_HEAD(&softmac->events);
59 59
60 mutex_init(&softmac->associnfo.mutex); 60 mutex_init(&softmac->associnfo.mutex);
61 INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac); 61 INIT_DELAYED_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work);
62 INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac); 62 INIT_DELAYED_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout);
63 softmac->start_scan = ieee80211softmac_start_scan_implementation; 63 softmac->start_scan = ieee80211softmac_start_scan_implementation;
64 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation; 64 softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;
65 softmac->stop_scan = ieee80211softmac_stop_scan_implementation; 65 softmac->stop_scan = ieee80211softmac_stop_scan_implementation;
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h
index 0642e090b8a7..c0dbe070e548 100644
--- a/net/ieee80211/softmac/ieee80211softmac_priv.h
+++ b/net/ieee80211/softmac/ieee80211softmac_priv.h
@@ -78,7 +78,7 @@
78/* private definitions and prototypes */ 78/* private definitions and prototypes */
79 79
80/*** prototypes from _scan.c */ 80/*** prototypes from _scan.c */
81void ieee80211softmac_scan(void *sm); 81void ieee80211softmac_scan(struct work_struct *work);
82/* for internal use if scanning is needed */ 82/* for internal use if scanning is needed */
83int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac); 83int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
84void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac); 84void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
@@ -149,7 +149,7 @@ int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *au
149int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth); 149int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth);
150 150
151/*** prototypes from _assoc.c */ 151/*** prototypes from _assoc.c */
152void ieee80211softmac_assoc_work(void *d); 152void ieee80211softmac_assoc_work(struct work_struct *work);
153int ieee80211softmac_handle_assoc_response(struct net_device * dev, 153int ieee80211softmac_handle_assoc_response(struct net_device * dev,
154 struct ieee80211_assoc_response * resp, 154 struct ieee80211_assoc_response * resp,
155 struct ieee80211_network * network); 155 struct ieee80211_network * network);
@@ -157,7 +157,7 @@ int ieee80211softmac_handle_disassoc(struct net_device * dev,
157 struct ieee80211_disassoc * disassoc); 157 struct ieee80211_disassoc * disassoc);
158int ieee80211softmac_handle_reassoc_req(struct net_device * dev, 158int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
159 struct ieee80211_reassoc_request * reassoc); 159 struct ieee80211_reassoc_request * reassoc);
160void ieee80211softmac_assoc_timeout(void *d); 160void ieee80211softmac_assoc_timeout(struct work_struct *work);
161void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason); 161void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
162void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac); 162void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
163 163
@@ -207,7 +207,7 @@ struct ieee80211softmac_auth_queue_item {
207 struct ieee80211softmac_device *mac; /* SoftMAC device */ 207 struct ieee80211softmac_device *mac; /* SoftMAC device */
208 u8 retry; /* Retry limit */ 208 u8 retry; /* Retry limit */
209 u8 state; /* Auth State */ 209 u8 state; /* Auth State */
210 struct work_struct work; /* Work queue */ 210 struct delayed_work work; /* Work queue */
211}; 211};
212 212
213/* scanning information */ 213/* scanning information */
@@ -219,7 +219,8 @@ struct ieee80211softmac_scaninfo {
219 stop:1; 219 stop:1;
220 u8 skip_flags; 220 u8 skip_flags;
221 struct completion finished; 221 struct completion finished;
222 struct work_struct softmac_scan; 222 struct delayed_work softmac_scan;
223 struct ieee80211softmac_device *mac;
223}; 224};
224 225
225/* private event struct */ 226/* private event struct */
@@ -227,7 +228,7 @@ struct ieee80211softmac_event {
227 struct list_head list; 228 struct list_head list;
228 int event_type; 229 int event_type;
229 void *event_context; 230 void *event_context;
230 struct work_struct work; 231 struct delayed_work work;
231 notify_function_ptr fun; 232 notify_function_ptr fun;
232 void *context; 233 void *context;
233 struct ieee80211softmac_device *mac; 234 struct ieee80211softmac_device *mac;
diff --git a/net/ieee80211/softmac/ieee80211softmac_scan.c b/net/ieee80211/softmac/ieee80211softmac_scan.c
index 5507feab32de..0c85d6c24cdb 100644
--- a/net/ieee80211/softmac/ieee80211softmac_scan.c
+++ b/net/ieee80211/softmac/ieee80211softmac_scan.c
@@ -90,12 +90,14 @@ ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *sm)
90 90
91 91
92/* internal scanning implementation follows */ 92/* internal scanning implementation follows */
93void ieee80211softmac_scan(void *d) 93void ieee80211softmac_scan(struct work_struct *work)
94{ 94{
95 int invalid_channel; 95 int invalid_channel;
96 u8 current_channel_idx; 96 u8 current_channel_idx;
97 struct ieee80211softmac_device *sm = (struct ieee80211softmac_device *)d; 97 struct ieee80211softmac_scaninfo *si =
98 struct ieee80211softmac_scaninfo *si = sm->scaninfo; 98 container_of(work, struct ieee80211softmac_scaninfo,
99 softmac_scan.work);
100 struct ieee80211softmac_device *sm = si->mac;
99 unsigned long flags; 101 unsigned long flags;
100 102
101 while (!(si->stop) && (si->current_channel_idx < si->number_channels)) { 103 while (!(si->stop) && (si->current_channel_idx < si->number_channels)) {
@@ -146,7 +148,8 @@ static inline struct ieee80211softmac_scaninfo *allocate_scaninfo(struct ieee802
146 struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC); 148 struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC);
147 if (unlikely(!info)) 149 if (unlikely(!info))
148 return NULL; 150 return NULL;
149 INIT_WORK(&info->softmac_scan, ieee80211softmac_scan, mac); 151 INIT_DELAYED_WORK(&info->softmac_scan, ieee80211softmac_scan);
152 info->mac = mac;
150 init_completion(&info->finished); 153 init_completion(&info->finished);
151 return info; 154 return info;
152} 155}
@@ -187,7 +190,7 @@ int ieee80211softmac_start_scan_implementation(struct net_device *dev)
187 sm->scaninfo->started = 1; 190 sm->scaninfo->started = 1;
188 sm->scaninfo->stop = 0; 191 sm->scaninfo->stop = 0;
189 INIT_COMPLETION(sm->scaninfo->finished); 192 INIT_COMPLETION(sm->scaninfo->finished);
190 schedule_work(&sm->scaninfo->softmac_scan); 193 schedule_delayed_work(&sm->scaninfo->softmac_scan, 0);
191 spin_unlock_irqrestore(&sm->lock, flags); 194 spin_unlock_irqrestore(&sm->lock, flags);
192 return 0; 195 return 0;
193} 196}
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 23068a830f7d..2ffaebd21c53 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -122,7 +122,7 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
122 122
123 sm->associnfo.associating = 1; 123 sm->associnfo.associating = 1;
124 /* queue lower level code to do work (if necessary) */ 124 /* queue lower level code to do work (if necessary) */
125 schedule_work(&sm->associnfo.work); 125 schedule_delayed_work(&sm->associnfo.work, 0);
126out: 126out:
127 mutex_unlock(&sm->associnfo.mutex); 127 mutex_unlock(&sm->associnfo.mutex);
128 128
@@ -356,7 +356,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
356 /* force reassociation */ 356 /* force reassociation */
357 mac->associnfo.bssvalid = 0; 357 mac->associnfo.bssvalid = 0;
358 if (mac->associnfo.associated) 358 if (mac->associnfo.associated)
359 schedule_work(&mac->associnfo.work); 359 schedule_delayed_work(&mac->associnfo.work, 0);
360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) { 360 } else if (is_zero_ether_addr(data->ap_addr.sa_data)) {
361 /* the bssid we have is no longer fixed */ 361 /* the bssid we have is no longer fixed */
362 mac->associnfo.bssfixed = 0; 362 mac->associnfo.bssfixed = 0;
@@ -373,7 +373,7 @@ ieee80211softmac_wx_set_wap(struct net_device *net_dev,
373 /* tell the other code that this bssid should be used no matter what */ 373 /* tell the other code that this bssid should be used no matter what */
374 mac->associnfo.bssfixed = 1; 374 mac->associnfo.bssfixed = 1;
375 /* queue associate if new bssid or (old one again and not associated) */ 375 /* queue associate if new bssid or (old one again and not associated) */
376 schedule_work(&mac->associnfo.work); 376 schedule_delayed_work(&mac->associnfo.work, 0);
377 } 377 }
378 378
379 out: 379 out:
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index cdd805344c61..8c74f9168b7d 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -197,9 +197,10 @@ EXPORT_SYMBOL_GPL(inet_twdr_hangman);
197 197
198extern void twkill_slots_invalid(void); 198extern void twkill_slots_invalid(void);
199 199
200void inet_twdr_twkill_work(void *data) 200void inet_twdr_twkill_work(struct work_struct *work)
201{ 201{
202 struct inet_timewait_death_row *twdr = data; 202 struct inet_timewait_death_row *twdr =
203 container_of(work, struct inet_timewait_death_row, twkill_work);
203 int i; 204 int i;
204 205
205 if ((INET_TWDR_TWKILL_SLOTS - 1) > (sizeof(twdr->thread_slots) * 8)) 206 if ((INET_TWDR_TWKILL_SLOTS - 1) > (sizeof(twdr->thread_slots) * 8))
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index f261616e4602..9b933381ebbe 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -221,10 +221,10 @@ static void update_defense_level(void)
221 * Timer for checking the defense 221 * Timer for checking the defense
222 */ 222 */
223#define DEFENSE_TIMER_PERIOD 1*HZ 223#define DEFENSE_TIMER_PERIOD 1*HZ
224static void defense_work_handler(void *data); 224static void defense_work_handler(struct work_struct *work);
225static DECLARE_WORK(defense_work, defense_work_handler, NULL); 225static DECLARE_DELAYED_WORK(defense_work, defense_work_handler);
226 226
227static void defense_work_handler(void *data) 227static void defense_work_handler(struct work_struct *work)
228{ 228{
229 update_defense_level(); 229 update_defense_level();
230 if (atomic_read(&ip_vs_dropentry)) 230 if (atomic_read(&ip_vs_dropentry))
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 6dddf59c1fb9..4a3889dd1943 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -45,8 +45,7 @@ struct inet_timewait_death_row tcp_death_row = {
45 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0, 45 .tw_timer = TIMER_INITIALIZER(inet_twdr_hangman, 0,
46 (unsigned long)&tcp_death_row), 46 (unsigned long)&tcp_death_row),
47 .twkill_work = __WORK_INITIALIZER(tcp_death_row.twkill_work, 47 .twkill_work = __WORK_INITIALIZER(tcp_death_row.twkill_work,
48 inet_twdr_twkill_work, 48 inet_twdr_twkill_work),
49 &tcp_death_row),
50/* Short-time timewait calendar */ 49/* Short-time timewait calendar */
51 50
52 .twcal_hand = -1, 51 .twcal_hand = -1,
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index d50a02030ad7..262bda808d96 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -61,7 +61,7 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty);
61static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch); 61static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch);
62static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout); 62static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout);
63static void ircomm_tty_hangup(struct tty_struct *tty); 63static void ircomm_tty_hangup(struct tty_struct *tty);
64static void ircomm_tty_do_softint(void *private_); 64static void ircomm_tty_do_softint(struct work_struct *work);
65static void ircomm_tty_shutdown(struct ircomm_tty_cb *self); 65static void ircomm_tty_shutdown(struct ircomm_tty_cb *self);
66static void ircomm_tty_stop(struct tty_struct *tty); 66static void ircomm_tty_stop(struct tty_struct *tty);
67 67
@@ -389,7 +389,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
389 self->flow = FLOW_STOP; 389 self->flow = FLOW_STOP;
390 390
391 self->line = line; 391 self->line = line;
392 INIT_WORK(&self->tqueue, ircomm_tty_do_softint, self); 392 INIT_WORK(&self->tqueue, ircomm_tty_do_softint);
393 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED; 393 self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED;
394 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED; 394 self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED;
395 self->close_delay = 5*HZ/10; 395 self->close_delay = 5*HZ/10;
@@ -594,15 +594,16 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
594} 594}
595 595
596/* 596/*
597 * Function ircomm_tty_do_softint (private_) 597 * Function ircomm_tty_do_softint (work)
598 * 598 *
599 * We use this routine to give the write wakeup to the user at at a 599 * We use this routine to give the write wakeup to the user at at a
600 * safe time (as fast as possible after write have completed). This 600 * safe time (as fast as possible after write have completed). This
601 * can be compared to the Tx interrupt. 601 * can be compared to the Tx interrupt.
602 */ 602 */
603static void ircomm_tty_do_softint(void *private_) 603static void ircomm_tty_do_softint(struct work_struct *work)
604{ 604{
605 struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) private_; 605 struct ircomm_tty_cb *self =
606 container_of(work, struct ircomm_tty_cb, tqueue);
606 struct tty_struct *tty; 607 struct tty_struct *tty;
607 unsigned long flags; 608 unsigned long flags;
608 struct sk_buff *skb, *ctrl_skb; 609 struct sk_buff *skb, *ctrl_skb;
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 39471d3b31b9..ad0057db0f91 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -61,7 +61,7 @@
61#include <net/sctp/sm.h> 61#include <net/sctp/sm.h>
62 62
63/* Forward declarations for internal functions. */ 63/* Forward declarations for internal functions. */
64static void sctp_assoc_bh_rcv(struct sctp_association *asoc); 64static void sctp_assoc_bh_rcv(struct work_struct *work);
65 65
66 66
67/* 1st Level Abstractions. */ 67/* 1st Level Abstractions. */
@@ -269,9 +269,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
269 269
270 /* Create an input queue. */ 270 /* Create an input queue. */
271 sctp_inq_init(&asoc->base.inqueue); 271 sctp_inq_init(&asoc->base.inqueue);
272 sctp_inq_set_th_handler(&asoc->base.inqueue, 272 sctp_inq_set_th_handler(&asoc->base.inqueue, sctp_assoc_bh_rcv);
273 (void (*)(void *))sctp_assoc_bh_rcv,
274 asoc);
275 273
276 /* Create an output queue. */ 274 /* Create an output queue. */
277 sctp_outq_init(asoc, &asoc->outqueue); 275 sctp_outq_init(asoc, &asoc->outqueue);
@@ -946,8 +944,11 @@ out:
946} 944}
947 945
948/* Do delayed input processing. This is scheduled by sctp_rcv(). */ 946/* Do delayed input processing. This is scheduled by sctp_rcv(). */
949static void sctp_assoc_bh_rcv(struct sctp_association *asoc) 947static void sctp_assoc_bh_rcv(struct work_struct *work)
950{ 948{
949 struct sctp_association *asoc =
950 container_of(work, struct sctp_association,
951 base.inqueue.immediate);
951 struct sctp_endpoint *ep; 952 struct sctp_endpoint *ep;
952 struct sctp_chunk *chunk; 953 struct sctp_chunk *chunk;
953 struct sock *sk; 954 struct sock *sk;
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 33a42e90c32f..129756908da4 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -61,7 +61,7 @@
61#include <net/sctp/sm.h> 61#include <net/sctp/sm.h>
62 62
63/* Forward declarations for internal helpers. */ 63/* Forward declarations for internal helpers. */
64static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep); 64static void sctp_endpoint_bh_rcv(struct work_struct *work);
65 65
66/* 66/*
67 * Initialize the base fields of the endpoint structure. 67 * Initialize the base fields of the endpoint structure.
@@ -89,8 +89,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
89 sctp_inq_init(&ep->base.inqueue); 89 sctp_inq_init(&ep->base.inqueue);
90 90
91 /* Set its top-half handler */ 91 /* Set its top-half handler */
92 sctp_inq_set_th_handler(&ep->base.inqueue, 92 sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv);
93 (void (*)(void *))sctp_endpoint_bh_rcv, ep);
94 93
95 /* Initialize the bind addr area */ 94 /* Initialize the bind addr area */
96 sctp_bind_addr_init(&ep->base.bind_addr, 0); 95 sctp_bind_addr_init(&ep->base.bind_addr, 0);
@@ -318,8 +317,11 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
318/* Do delayed input processing. This is scheduled by sctp_rcv(). 317/* Do delayed input processing. This is scheduled by sctp_rcv().
319 * This may be called on BH or task time. 318 * This may be called on BH or task time.
320 */ 319 */
321static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep) 320static void sctp_endpoint_bh_rcv(struct work_struct *work)
322{ 321{
322 struct sctp_endpoint *ep =
323 container_of(work, struct sctp_endpoint,
324 base.inqueue.immediate);
323 struct sctp_association *asoc; 325 struct sctp_association *asoc;
324 struct sock *sk; 326 struct sock *sk;
325 struct sctp_transport *transport; 327 struct sctp_transport *transport;
diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c
index cf6deed7e849..71b07466e880 100644
--- a/net/sctp/inqueue.c
+++ b/net/sctp/inqueue.c
@@ -54,7 +54,7 @@ void sctp_inq_init(struct sctp_inq *queue)
54 queue->in_progress = NULL; 54 queue->in_progress = NULL;
55 55
56 /* Create a task for delivering data. */ 56 /* Create a task for delivering data. */
57 INIT_WORK(&queue->immediate, NULL, NULL); 57 INIT_WORK(&queue->immediate, NULL);
58 58
59 queue->malloced = 0; 59 queue->malloced = 0;
60} 60}
@@ -97,7 +97,7 @@ void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
97 * on the BH related data structures. 97 * on the BH related data structures.
98 */ 98 */
99 list_add_tail(&chunk->list, &q->in_chunk_list); 99 list_add_tail(&chunk->list, &q->in_chunk_list);
100 q->immediate.func(q->immediate.data); 100 q->immediate.func(&q->immediate);
101} 101}
102 102
103/* Extract a chunk from an SCTP inqueue. 103/* Extract a chunk from an SCTP inqueue.
@@ -205,9 +205,8 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue)
205 * The intent is that this routine will pull stuff out of the 205 * The intent is that this routine will pull stuff out of the
206 * inqueue and process it. 206 * inqueue and process it.
207 */ 207 */
208void sctp_inq_set_th_handler(struct sctp_inq *q, 208void sctp_inq_set_th_handler(struct sctp_inq *q, work_func_t callback)
209 void (*callback)(void *), void *arg)
210{ 209{
211 INIT_WORK(&q->immediate, callback, arg); 210 INIT_WORK(&q->immediate, callback);
212} 211}
213 212
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 00cb388ece03..d96fd466a9a4 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -284,8 +284,8 @@ static struct file_operations cache_file_operations;
284static struct file_operations content_file_operations; 284static struct file_operations content_file_operations;
285static struct file_operations cache_flush_operations; 285static struct file_operations cache_flush_operations;
286 286
287static void do_cache_clean(void *data); 287static void do_cache_clean(struct work_struct *work);
288static DECLARE_WORK(cache_cleaner, do_cache_clean, NULL); 288static DECLARE_DELAYED_WORK(cache_cleaner, do_cache_clean);
289 289
290void cache_register(struct cache_detail *cd) 290void cache_register(struct cache_detail *cd)
291{ 291{
@@ -337,7 +337,7 @@ void cache_register(struct cache_detail *cd)
337 spin_unlock(&cache_list_lock); 337 spin_unlock(&cache_list_lock);
338 338
339 /* start the cleaning process */ 339 /* start the cleaning process */
340 schedule_work(&cache_cleaner); 340 schedule_delayed_work(&cache_cleaner, 0);
341} 341}
342 342
343int cache_unregister(struct cache_detail *cd) 343int cache_unregister(struct cache_detail *cd)
@@ -461,7 +461,7 @@ static int cache_clean(void)
461/* 461/*
462 * We want to regularly clean the cache, so we need to schedule some work ... 462 * We want to regularly clean the cache, so we need to schedule some work ...
463 */ 463 */
464static void do_cache_clean(void *data) 464static void do_cache_clean(struct work_struct *work)
465{ 465{
466 int delay = 5; 466 int delay = 5;
467 if (cache_clean() == -1) 467 if (cache_clean() == -1)
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 9a0b41a97f90..49dba5febbbd 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -54,10 +54,11 @@ static void rpc_purge_list(struct rpc_inode *rpci, struct list_head *head,
54} 54}
55 55
56static void 56static void
57rpc_timeout_upcall_queue(void *data) 57rpc_timeout_upcall_queue(struct work_struct *work)
58{ 58{
59 LIST_HEAD(free_list); 59 LIST_HEAD(free_list);
60 struct rpc_inode *rpci = (struct rpc_inode *)data; 60 struct rpc_inode *rpci =
61 container_of(work, struct rpc_inode, queue_timeout.work);
61 struct inode *inode = &rpci->vfs_inode; 62 struct inode *inode = &rpci->vfs_inode;
62 void (*destroy_msg)(struct rpc_pipe_msg *); 63 void (*destroy_msg)(struct rpc_pipe_msg *);
63 64
@@ -837,7 +838,8 @@ init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
837 INIT_LIST_HEAD(&rpci->pipe); 838 INIT_LIST_HEAD(&rpci->pipe);
838 rpci->pipelen = 0; 839 rpci->pipelen = 0;
839 init_waitqueue_head(&rpci->waitq); 840 init_waitqueue_head(&rpci->waitq);
840 INIT_WORK(&rpci->queue_timeout, rpc_timeout_upcall_queue, rpci); 841 INIT_DELAYED_WORK(&rpci->queue_timeout,
842 rpc_timeout_upcall_queue);
841 rpci->ops = NULL; 843 rpci->ops = NULL;
842 } 844 }
843} 845}
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index a1ab4eed41f4..eff44bcdc95a 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -41,7 +41,7 @@ static mempool_t *rpc_buffer_mempool __read_mostly;
41 41
42static void __rpc_default_timer(struct rpc_task *task); 42static void __rpc_default_timer(struct rpc_task *task);
43static void rpciod_killall(void); 43static void rpciod_killall(void);
44static void rpc_async_schedule(void *); 44static void rpc_async_schedule(struct work_struct *);
45 45
46/* 46/*
47 * RPC tasks sit here while waiting for conditions to improve. 47 * RPC tasks sit here while waiting for conditions to improve.
@@ -305,7 +305,7 @@ static void rpc_make_runnable(struct rpc_task *task)
305 if (RPC_IS_ASYNC(task)) { 305 if (RPC_IS_ASYNC(task)) {
306 int status; 306 int status;
307 307
308 INIT_WORK(&task->u.tk_work, rpc_async_schedule, (void *)task); 308 INIT_WORK(&task->u.tk_work, rpc_async_schedule);
309 status = queue_work(task->tk_workqueue, &task->u.tk_work); 309 status = queue_work(task->tk_workqueue, &task->u.tk_work);
310 if (status < 0) { 310 if (status < 0) {
311 printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status); 311 printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status);
@@ -695,9 +695,9 @@ rpc_execute(struct rpc_task *task)
695 return __rpc_execute(task); 695 return __rpc_execute(task);
696} 696}
697 697
698static void rpc_async_schedule(void *arg) 698static void rpc_async_schedule(struct work_struct *work)
699{ 699{
700 __rpc_execute((struct rpc_task *)arg); 700 __rpc_execute(container_of(work, struct rpc_task, u.tk_work));
701} 701}
702 702
703/** 703/**
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 80857470dc11..4f9a5d9791fb 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -479,9 +479,10 @@ int xprt_adjust_timeout(struct rpc_rqst *req)
479 return status; 479 return status;
480} 480}
481 481
482static void xprt_autoclose(void *args) 482static void xprt_autoclose(struct work_struct *work)
483{ 483{
484 struct rpc_xprt *xprt = (struct rpc_xprt *)args; 484 struct rpc_xprt *xprt =
485 container_of(work, struct rpc_xprt, task_cleanup);
485 486
486 xprt_disconnect(xprt); 487 xprt_disconnect(xprt);
487 xprt->ops->close(xprt); 488 xprt->ops->close(xprt);
@@ -932,7 +933,7 @@ struct rpc_xprt *xprt_create_transport(int proto, struct sockaddr *ap, size_t si
932 933
933 INIT_LIST_HEAD(&xprt->free); 934 INIT_LIST_HEAD(&xprt->free);
934 INIT_LIST_HEAD(&xprt->recv); 935 INIT_LIST_HEAD(&xprt->recv);
935 INIT_WORK(&xprt->task_cleanup, xprt_autoclose, xprt); 936 INIT_WORK(&xprt->task_cleanup, xprt_autoclose);
936 init_timer(&xprt->timer); 937 init_timer(&xprt->timer);
937 xprt->timer.function = xprt_init_autodisconnect; 938 xprt->timer.function = xprt_init_autodisconnect;
938 xprt->timer.data = (unsigned long) xprt; 939 xprt->timer.data = (unsigned long) xprt;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 757fc91ef25d..cfe3c15be948 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1060,13 +1060,14 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
1060 1060
1061/** 1061/**
1062 * xs_udp_connect_worker - set up a UDP socket 1062 * xs_udp_connect_worker - set up a UDP socket
1063 * @args: RPC transport to connect 1063 * @work: RPC transport to connect
1064 * 1064 *
1065 * Invoked by a work queue tasklet. 1065 * Invoked by a work queue tasklet.
1066 */ 1066 */
1067static void xs_udp_connect_worker(void *args) 1067static void xs_udp_connect_worker(struct work_struct *work)
1068{ 1068{
1069 struct rpc_xprt *xprt = (struct rpc_xprt *) args; 1069 struct rpc_xprt *xprt =
1070 container_of(work, struct rpc_xprt, connect_worker.work);
1070 struct socket *sock = xprt->sock; 1071 struct socket *sock = xprt->sock;
1071 int err, status = -EIO; 1072 int err, status = -EIO;
1072 1073
@@ -1144,13 +1145,14 @@ static void xs_tcp_reuse_connection(struct rpc_xprt *xprt)
1144 1145
1145/** 1146/**
1146 * xs_tcp_connect_worker - connect a TCP socket to a remote endpoint 1147 * xs_tcp_connect_worker - connect a TCP socket to a remote endpoint
1147 * @args: RPC transport to connect 1148 * @work: RPC transport to connect
1148 * 1149 *
1149 * Invoked by a work queue tasklet. 1150 * Invoked by a work queue tasklet.
1150 */ 1151 */
1151static void xs_tcp_connect_worker(void *args) 1152static void xs_tcp_connect_worker(struct work_struct *work)
1152{ 1153{
1153 struct rpc_xprt *xprt = (struct rpc_xprt *)args; 1154 struct rpc_xprt *xprt =
1155 container_of(work, struct rpc_xprt, connect_worker.work);
1154 struct socket *sock = xprt->sock; 1156 struct socket *sock = xprt->sock;
1155 int err, status = -EIO; 1157 int err, status = -EIO;
1156 1158
@@ -1262,7 +1264,7 @@ static void xs_connect(struct rpc_task *task)
1262 xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO; 1264 xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO;
1263 } else { 1265 } else {
1264 dprintk("RPC: xs_connect scheduled xprt %p\n", xprt); 1266 dprintk("RPC: xs_connect scheduled xprt %p\n", xprt);
1265 schedule_work(&xprt->connect_worker); 1267 schedule_delayed_work(&xprt->connect_worker, 0);
1266 1268
1267 /* flush_scheduled_work can sleep... */ 1269 /* flush_scheduled_work can sleep... */
1268 if (!RPC_IS_ASYNC(task)) 1270 if (!RPC_IS_ASYNC(task))
@@ -1375,7 +1377,7 @@ int xs_setup_udp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1375 /* XXX: header size can vary due to auth type, IPv6, etc. */ 1377 /* XXX: header size can vary due to auth type, IPv6, etc. */
1376 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3); 1378 xprt->max_payload = (1U << 16) - (MAX_HEADER << 3);
1377 1379
1378 INIT_WORK(&xprt->connect_worker, xs_udp_connect_worker, xprt); 1380 INIT_DELAYED_WORK(&xprt->connect_worker, xs_udp_connect_worker);
1379 xprt->bind_timeout = XS_BIND_TO; 1381 xprt->bind_timeout = XS_BIND_TO;
1380 xprt->connect_timeout = XS_UDP_CONN_TO; 1382 xprt->connect_timeout = XS_UDP_CONN_TO;
1381 xprt->reestablish_timeout = XS_UDP_REEST_TO; 1383 xprt->reestablish_timeout = XS_UDP_REEST_TO;
@@ -1420,7 +1422,7 @@ int xs_setup_tcp(struct rpc_xprt *xprt, struct rpc_timeout *to)
1420 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32); 1422 xprt->tsh_size = sizeof(rpc_fraghdr) / sizeof(u32);
1421 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE; 1423 xprt->max_payload = RPC_MAX_FRAGMENT_SIZE;
1422 1424
1423 INIT_WORK(&xprt->connect_worker, xs_tcp_connect_worker, xprt); 1425 INIT_DELAYED_WORK(&xprt->connect_worker, xs_tcp_connect_worker);
1424 xprt->bind_timeout = XS_BIND_TO; 1426 xprt->bind_timeout = XS_BIND_TO;
1425 xprt->connect_timeout = XS_TCP_CONN_TO; 1427 xprt->connect_timeout = XS_TCP_CONN_TO;
1426 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; 1428 xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 64d3938f74c4..f6c77bd36fdd 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -392,7 +392,7 @@ static void xfrm_policy_gc_kill(struct xfrm_policy *policy)
392 xfrm_pol_put(policy); 392 xfrm_pol_put(policy);
393} 393}
394 394
395static void xfrm_policy_gc_task(void *data) 395static void xfrm_policy_gc_task(struct work_struct *work)
396{ 396{
397 struct xfrm_policy *policy; 397 struct xfrm_policy *policy;
398 struct hlist_node *entry, *tmp; 398 struct hlist_node *entry, *tmp;
@@ -580,7 +580,7 @@ static inline int xfrm_byidx_should_resize(int total)
580 580
581static DEFINE_MUTEX(hash_resize_mutex); 581static DEFINE_MUTEX(hash_resize_mutex);
582 582
583static void xfrm_hash_resize(void *__unused) 583static void xfrm_hash_resize(struct work_struct *__unused)
584{ 584{
585 int dir, total; 585 int dir, total;
586 586
@@ -597,7 +597,7 @@ static void xfrm_hash_resize(void *__unused)
597 mutex_unlock(&hash_resize_mutex); 597 mutex_unlock(&hash_resize_mutex);
598} 598}
599 599
600static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize, NULL); 600static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize);
601 601
602/* Generate new index... KAME seems to generate them ordered by cost 602/* Generate new index... KAME seems to generate them ordered by cost
603 * of an absolute inpredictability of ordering of rules. This will not pass. */ 603 * of an absolute inpredictability of ordering of rules. This will not pass. */
@@ -2116,7 +2116,7 @@ static void __init xfrm_policy_init(void)
2116 panic("XFRM: failed to allocate bydst hash\n"); 2116 panic("XFRM: failed to allocate bydst hash\n");
2117 } 2117 }
2118 2118
2119 INIT_WORK(&xfrm_policy_gc_work, xfrm_policy_gc_task, NULL); 2119 INIT_WORK(&xfrm_policy_gc_work, xfrm_policy_gc_task);
2120 register_netdevice_notifier(&xfrm_dev_notifier); 2120 register_netdevice_notifier(&xfrm_dev_notifier);
2121} 2121}
2122 2122
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 864962bbda90..da54a64ccfa3 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -115,7 +115,7 @@ static unsigned long xfrm_hash_new_size(void)
115 115
116static DEFINE_MUTEX(hash_resize_mutex); 116static DEFINE_MUTEX(hash_resize_mutex);
117 117
118static void xfrm_hash_resize(void *__unused) 118static void xfrm_hash_resize(struct work_struct *__unused)
119{ 119{
120 struct hlist_head *ndst, *nsrc, *nspi, *odst, *osrc, *ospi; 120 struct hlist_head *ndst, *nsrc, *nspi, *odst, *osrc, *ospi;
121 unsigned long nsize, osize; 121 unsigned long nsize, osize;
@@ -168,7 +168,7 @@ out_unlock:
168 mutex_unlock(&hash_resize_mutex); 168 mutex_unlock(&hash_resize_mutex);
169} 169}
170 170
171static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize, NULL); 171static DECLARE_WORK(xfrm_hash_work, xfrm_hash_resize);
172 172
173DECLARE_WAIT_QUEUE_HEAD(km_waitq); 173DECLARE_WAIT_QUEUE_HEAD(km_waitq);
174EXPORT_SYMBOL(km_waitq); 174EXPORT_SYMBOL(km_waitq);
@@ -207,7 +207,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
207 kfree(x); 207 kfree(x);
208} 208}
209 209
210static void xfrm_state_gc_task(void *data) 210static void xfrm_state_gc_task(struct work_struct *data)
211{ 211{
212 struct xfrm_state *x; 212 struct xfrm_state *x;
213 struct hlist_node *entry, *tmp; 213 struct hlist_node *entry, *tmp;
@@ -1568,6 +1568,6 @@ void __init xfrm_state_init(void)
1568 panic("XFRM: Cannot allocate bydst/bysrc/byspi hashes."); 1568 panic("XFRM: Cannot allocate bydst/bysrc/byspi hashes.");
1569 xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1); 1569 xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1);
1570 1570
1571 INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task, NULL); 1571 INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task);
1572} 1572}
1573 1573
diff --git a/security/keys/key.c b/security/keys/key.c
index 80de8c3e9cc3..70eacbe5abde 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -30,8 +30,8 @@ DEFINE_SPINLOCK(key_user_lock);
30static LIST_HEAD(key_types_list); 30static LIST_HEAD(key_types_list);
31static DECLARE_RWSEM(key_types_sem); 31static DECLARE_RWSEM(key_types_sem);
32 32
33static void key_cleanup(void *data); 33static void key_cleanup(struct work_struct *work);
34static DECLARE_WORK(key_cleanup_task, key_cleanup, NULL); 34static DECLARE_WORK(key_cleanup_task, key_cleanup);
35 35
36/* we serialise key instantiation and link */ 36/* we serialise key instantiation and link */
37DECLARE_RWSEM(key_construction_sem); 37DECLARE_RWSEM(key_construction_sem);
@@ -552,7 +552,7 @@ EXPORT_SYMBOL(key_negate_and_link);
552 * do cleaning up in process context so that we don't have to disable 552 * do cleaning up in process context so that we don't have to disable
553 * interrupts all over the place 553 * interrupts all over the place
554 */ 554 */
555static void key_cleanup(void *data) 555static void key_cleanup(struct work_struct *work)
556{ 556{
557 struct rb_node *_n; 557 struct rb_node *_n;
558 struct key *key; 558 struct key *key;
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 74c0319c417e..e73ac1ab7cfd 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -496,7 +496,7 @@ static inline void avc_print_ipv6_addr(struct audit_buffer *ab,
496 audit_log_format(ab, " %s=%d", name2, ntohs(port)); 496 audit_log_format(ab, " %s=%d", name2, ntohs(port));
497} 497}
498 498
499static inline void avc_print_ipv4_addr(struct audit_buffer *ab, u32 addr, 499static inline void avc_print_ipv4_addr(struct audit_buffer *ab, __be32 addr,
500 __be16 port, char *name1, char *name2) 500 __be16 port, char *name1, char *name2)
501{ 501{
502 if (addr) 502 if (addr)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index a29d78d3f44c..78f98fe084eb 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3537,7 +3537,7 @@ static int selinux_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
3537 goto out; 3537 goto out;
3538 3538
3539 /* Handle mapped IPv4 packets arriving via IPv6 sockets */ 3539 /* Handle mapped IPv4 packets arriving via IPv6 sockets */
3540 if (family == PF_INET6 && skb->protocol == ntohs(ETH_P_IP)) 3540 if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP))
3541 family = PF_INET; 3541 family = PF_INET;
3542 3542
3543 AVC_AUDIT_DATA_INIT(&ad, NET); 3543 AVC_AUDIT_DATA_INIT(&ad, NET);
diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
index 960ef18ddc41..6ed10c3d3339 100644
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -54,12 +54,12 @@ struct avc_audit_data {
54 char *netif; 54 char *netif;
55 struct sock *sk; 55 struct sock *sk;
56 u16 family; 56 u16 family;
57 u16 dport; 57 __be16 dport;
58 u16 sport; 58 __be16 sport;
59 union { 59 union {
60 struct { 60 struct {
61 u32 daddr; 61 __be32 daddr;
62 u32 saddr; 62 __be32 saddr;
63 } v4; 63 } v4;
64 struct { 64 struct {
65 struct in6_addr daddr; 65 struct in6_addr daddr;
diff --git a/sound/aoa/aoa-gpio.h b/sound/aoa/aoa-gpio.h
index 3a61f3115573..ee64f5de8966 100644
--- a/sound/aoa/aoa-gpio.h
+++ b/sound/aoa/aoa-gpio.h
@@ -59,10 +59,10 @@ struct gpio_methods {
59}; 59};
60 60
61struct gpio_notification { 61struct gpio_notification {
62 struct delayed_work work;
62 notify_func_t notify; 63 notify_func_t notify;
63 void *data; 64 void *data;
64 void *gpio_private; 65 void *gpio_private;
65 struct work_struct work;
66 struct mutex mutex; 66 struct mutex mutex;
67}; 67};
68 68
diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index 40eb47eccf9a..2b03bc798bcb 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -195,9 +195,10 @@ static void ftr_gpio_all_amps_restore(struct gpio_runtime *rt)
195 ftr_gpio_set_lineout(rt, (s>>2)&1); 195 ftr_gpio_set_lineout(rt, (s>>2)&1);
196} 196}
197 197
198static void ftr_handle_notify(void *data) 198static void ftr_handle_notify(struct work_struct *work)
199{ 199{
200 struct gpio_notification *notif = data; 200 struct gpio_notification *notif =
201 container_of(work, struct gpio_notification, work.work);
201 202
202 mutex_lock(&notif->mutex); 203 mutex_lock(&notif->mutex);
203 if (notif->notify) 204 if (notif->notify)
@@ -253,12 +254,9 @@ static void ftr_gpio_init(struct gpio_runtime *rt)
253 254
254 ftr_gpio_all_amps_off(rt); 255 ftr_gpio_all_amps_off(rt);
255 rt->implementation_private = 0; 256 rt->implementation_private = 0;
256 INIT_WORK(&rt->headphone_notify.work, ftr_handle_notify, 257 INIT_DELAYED_WORK(&rt->headphone_notify.work, ftr_handle_notify);
257 &rt->headphone_notify); 258 INIT_DELAYED_WORK(&rt->line_in_notify.work, ftr_handle_notify);
258 INIT_WORK(&rt->line_in_notify.work, ftr_handle_notify, 259 INIT_DELAYED_WORK(&rt->line_out_notify.work, ftr_handle_notify);
259 &rt->line_in_notify);
260 INIT_WORK(&rt->line_out_notify.work, ftr_handle_notify,
261 &rt->line_out_notify);
262 mutex_init(&rt->headphone_notify.mutex); 260 mutex_init(&rt->headphone_notify.mutex);
263 mutex_init(&rt->line_in_notify.mutex); 261 mutex_init(&rt->line_in_notify.mutex);
264 mutex_init(&rt->line_out_notify.mutex); 262 mutex_init(&rt->line_out_notify.mutex);
@@ -287,7 +285,7 @@ static irqreturn_t ftr_handle_notify_irq(int xx, void *data)
287{ 285{
288 struct gpio_notification *notif = data; 286 struct gpio_notification *notif = data;
289 287
290 schedule_work(&notif->work); 288 schedule_delayed_work(&notif->work, 0);
291 289
292 return IRQ_HANDLED; 290 return IRQ_HANDLED;
293} 291}
diff --git a/sound/aoa/core/snd-aoa-gpio-pmf.c b/sound/aoa/core/snd-aoa-gpio-pmf.c
index 2836c3218391..5ca2220eac7d 100644
--- a/sound/aoa/core/snd-aoa-gpio-pmf.c
+++ b/sound/aoa/core/snd-aoa-gpio-pmf.c
@@ -69,9 +69,10 @@ static void pmf_gpio_all_amps_restore(struct gpio_runtime *rt)
69 pmf_gpio_set_lineout(rt, (s>>2)&1); 69 pmf_gpio_set_lineout(rt, (s>>2)&1);
70} 70}
71 71
72static void pmf_handle_notify(void *data) 72static void pmf_handle_notify(struct work_struct *work)
73{ 73{
74 struct gpio_notification *notif = data; 74 struct gpio_notification *notif =
75 container_of(work, struct gpio_notification, work.work);
75 76
76 mutex_lock(&notif->mutex); 77 mutex_lock(&notif->mutex);
77 if (notif->notify) 78 if (notif->notify)
@@ -83,12 +84,9 @@ static void pmf_gpio_init(struct gpio_runtime *rt)
83{ 84{
84 pmf_gpio_all_amps_off(rt); 85 pmf_gpio_all_amps_off(rt);
85 rt->implementation_private = 0; 86 rt->implementation_private = 0;
86 INIT_WORK(&rt->headphone_notify.work, pmf_handle_notify, 87 INIT_DELAYED_WORK(&rt->headphone_notify.work, pmf_handle_notify);
87 &rt->headphone_notify); 88 INIT_DELAYED_WORK(&rt->line_in_notify.work, pmf_handle_notify);
88 INIT_WORK(&rt->line_in_notify.work, pmf_handle_notify, 89 INIT_DELAYED_WORK(&rt->line_out_notify.work, pmf_handle_notify);
89 &rt->line_in_notify);
90 INIT_WORK(&rt->line_out_notify.work, pmf_handle_notify,
91 &rt->line_out_notify);
92 mutex_init(&rt->headphone_notify.mutex); 90 mutex_init(&rt->headphone_notify.mutex);
93 mutex_init(&rt->line_in_notify.mutex); 91 mutex_init(&rt->line_in_notify.mutex);
94 mutex_init(&rt->line_out_notify.mutex); 92 mutex_init(&rt->line_out_notify.mutex);
@@ -129,7 +127,7 @@ static void pmf_handle_notify_irq(void *data)
129{ 127{
130 struct gpio_notification *notif = data; 128 struct gpio_notification *notif = data;
131 129
132 schedule_work(&notif->work); 130 schedule_delayed_work(&notif->work, 0);
133} 131}
134 132
135static int pmf_set_notify(struct gpio_runtime *rt, 133static int pmf_set_notify(struct gpio_runtime *rt,
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 12ffffc9e814..d2f2c5078e65 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL");
35 35
36#define AK4114_ADDR 0x00 /* fixed address */ 36#define AK4114_ADDR 0x00 /* fixed address */
37 37
38static void ak4114_stats(void *); 38static void ak4114_stats(struct work_struct *work);
39 39
40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val) 40static void reg_write(struct ak4114 *ak4114, unsigned char reg, unsigned char val)
41{ 41{
@@ -158,7 +158,7 @@ void snd_ak4114_reinit(struct ak4114 *chip)
158 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN); 158 reg_write(chip, AK4114_REG_PWRDN, old | AK4114_RST | AK4114_PWN);
159 /* bring up statistics / event queing */ 159 /* bring up statistics / event queing */
160 chip->init = 0; 160 chip->init = 0;
161 INIT_WORK(&chip->work, ak4114_stats, chip); 161 INIT_DELAYED_WORK(&chip->work, ak4114_stats);
162 queue_delayed_work(chip->workqueue, &chip->work, HZ / 10); 162 queue_delayed_work(chip->workqueue, &chip->work, HZ / 10);
163} 163}
164 164
@@ -561,9 +561,9 @@ int snd_ak4114_check_rate_and_errors(struct ak4114 *ak4114, unsigned int flags)
561 return res; 561 return res;
562} 562}
563 563
564static void ak4114_stats(void *data) 564static void ak4114_stats(struct work_struct *work)
565{ 565{
566 struct ak4114 *chip = (struct ak4114 *)data; 566 struct ak4114 *chip = container_of(work, struct ak4114, work.work);
567 567
568 if (chip->init) 568 if (chip->init)
569 return; 569 return;
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 6577b2325357..7abcb10b2754 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1927,9 +1927,10 @@ static int snd_ac97_dev_disconnect(struct snd_device *device)
1927static struct snd_ac97_build_ops null_build_ops; 1927static struct snd_ac97_build_ops null_build_ops;
1928 1928
1929#ifdef CONFIG_SND_AC97_POWER_SAVE 1929#ifdef CONFIG_SND_AC97_POWER_SAVE
1930static void do_update_power(void *data) 1930static void do_update_power(struct work_struct *work)
1931{ 1931{
1932 update_power_regs(data); 1932 update_power_regs(
1933 container_of(work, struct snd_ac97, power_work.work));
1933} 1934}
1934#endif 1935#endif
1935 1936
@@ -1989,7 +1990,7 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template,
1989 mutex_init(&ac97->page_mutex); 1990 mutex_init(&ac97->page_mutex);
1990#ifdef CONFIG_SND_AC97_POWER_SAVE 1991#ifdef CONFIG_SND_AC97_POWER_SAVE
1991 ac97->power_workq = create_workqueue("ac97"); 1992 ac97->power_workq = create_workqueue("ac97");
1992 INIT_WORK(&ac97->power_work, do_update_power, ac97); 1993 INIT_DELAYED_WORK(&ac97->power_work, do_update_power);
1993#endif 1994#endif
1994 1995
1995#ifdef CONFIG_PCI 1996#ifdef CONFIG_PCI
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 9c3d7ac08068..71482c15a852 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -272,10 +272,11 @@ EXPORT_SYMBOL(snd_hda_queue_unsol_event);
272/* 272/*
273 * process queueud unsolicited events 273 * process queueud unsolicited events
274 */ 274 */
275static void process_unsol_events(void *data) 275static void process_unsol_events(struct work_struct *work)
276{ 276{
277 struct hda_bus *bus = data; 277 struct hda_bus_unsolicited *unsol =
278 struct hda_bus_unsolicited *unsol = bus->unsol; 278 container_of(work, struct hda_bus_unsolicited, work);
279 struct hda_bus *bus = unsol->bus;
279 struct hda_codec *codec; 280 struct hda_codec *codec;
280 unsigned int rp, caddr, res; 281 unsigned int rp, caddr, res;
281 282
@@ -314,7 +315,8 @@ static int init_unsol_queue(struct hda_bus *bus)
314 kfree(unsol); 315 kfree(unsol);
315 return -ENOMEM; 316 return -ENOMEM;
316 } 317 }
317 INIT_WORK(&unsol->work, process_unsol_events, bus); 318 INIT_WORK(&unsol->work, process_unsol_events);
319 unsol->bus = bus;
318 bus->unsol = unsol; 320 bus->unsol = unsol;
319 return 0; 321 return 0;
320} 322}
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index f9416c36396e..9ca1baf860bd 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -206,6 +206,7 @@ struct hda_bus_unsolicited {
206 /* workqueue */ 206 /* workqueue */
207 struct workqueue_struct *workq; 207 struct workqueue_struct *workq;
208 struct work_struct work; 208 struct work_struct work;
209 struct hda_bus *bus;
209}; 210};
210 211
211/* 212/*
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index fd3590fcaedb..2d40cc72f236 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -219,35 +219,15 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
219static int pdacf_config(struct pcmcia_device *link) 219static int pdacf_config(struct pcmcia_device *link)
220{ 220{
221 struct snd_pdacf *pdacf = link->priv; 221 struct snd_pdacf *pdacf = link->priv;
222 tuple_t tuple;
223 cisparse_t *parse = NULL;
224 u_short buf[32];
225 int last_fn, last_ret; 222 int last_fn, last_ret;
226 223
227 snd_printdd(KERN_DEBUG "pdacf_config called\n"); 224 snd_printdd(KERN_DEBUG "pdacf_config called\n");
228 parse = kmalloc(sizeof(*parse), GFP_KERNEL);
229 if (! parse) {
230 snd_printk(KERN_ERR "pdacf_config: cannot allocate\n");
231 return -ENOMEM;
232 }
233 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
234 tuple.Attributes = 0;
235 tuple.TupleData = (cisdata_t *)buf;
236 tuple.TupleDataMax = sizeof(buf);
237 tuple.TupleOffset = 0;
238 tuple.DesiredTuple = CISTPL_CONFIG;
239 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
240 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
241 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
242 link->conf.ConfigBase = parse->config.base;
243 link->conf.ConfigIndex = 0x5; 225 link->conf.ConfigIndex = 0x5;
244 226
245 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 227 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
246 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 228 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
247 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 229 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
248 230
249 kfree(parse);
250
251 if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 231 if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
252 goto failed; 232 goto failed;
253 233
@@ -255,7 +235,6 @@ static int pdacf_config(struct pcmcia_device *link)
255 return 0; 235 return 0;
256 236
257cs_failed: 237cs_failed:
258 kfree(parse);
259 cs_error(link, last_fn, last_ret); 238 cs_error(link, last_fn, last_ret);
260failed: 239failed:
261 pcmcia_disable_device(link); 240 pcmcia_disable_device(link);
@@ -299,7 +278,8 @@ static int pdacf_resume(struct pcmcia_device *link)
299 * Module entry points 278 * Module entry points
300 */ 279 */
301static struct pcmcia_device_id snd_pdacf_ids[] = { 280static struct pcmcia_device_id snd_pdacf_ids[] = {
302 PCMCIA_DEVICE_MANF_CARD(0x015d, 0x4c45), 281 /* this is too general PCMCIA_DEVICE_MANF_CARD(0x015d, 0x4c45), */
282 PCMCIA_DEVICE_PROD_ID12("Core Sound","PDAudio-CF",0x396d19d2,0x71717b49),
303 PCMCIA_DEVICE_NULL 283 PCMCIA_DEVICE_NULL
304}; 284};
305MODULE_DEVICE_TABLE(pcmcia, snd_pdacf_ids); 285MODULE_DEVICE_TABLE(pcmcia, snd_pdacf_ids);
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 3089fcca800e..d7df59e9c647 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -217,34 +217,12 @@ static int vxpocket_config(struct pcmcia_device *link)
217{ 217{
218 struct vx_core *chip = link->priv; 218 struct vx_core *chip = link->priv;
219 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; 219 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
220 tuple_t tuple;
221 cisparse_t *parse;
222 u_short buf[32];
223 int last_fn, last_ret; 220 int last_fn, last_ret;
224 221
225 snd_printdd(KERN_DEBUG "vxpocket_config called\n"); 222 snd_printdd(KERN_DEBUG "vxpocket_config called\n");
226 parse = kmalloc(sizeof(*parse), GFP_KERNEL);
227 if (! parse) {
228 snd_printk(KERN_ERR "vx: cannot allocate\n");
229 return -ENOMEM;
230 }
231 tuple.Attributes = 0;
232 tuple.TupleData = (cisdata_t *)buf;
233 tuple.TupleDataMax = sizeof(buf);
234 tuple.TupleOffset = 0;
235 tuple.DesiredTuple = CISTPL_CONFIG;
236 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
237 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
238 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
239 link->conf.ConfigBase = parse->config.base;
240 link->conf.Present = parse->config.rmask[0];
241 223
242 /* redefine hardware record according to the VERSION1 string */ 224 /* redefine hardware record according to the VERSION1 string */
243 tuple.DesiredTuple = CISTPL_VERS_1; 225 if (!strcmp(link->prod_id[1], "VX-POCKET")) {
244 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
245 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
246 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse));
247 if (! strcmp(parse->version_1.str + parse->version_1.ofs[1], "VX-POCKET")) {
248 snd_printdd("VX-pocket is detected\n"); 226 snd_printdd("VX-pocket is detected\n");
249 } else { 227 } else {
250 snd_printdd("VX-pocket 440 is detected\n"); 228 snd_printdd("VX-pocket 440 is detected\n");
@@ -265,14 +243,12 @@ static int vxpocket_config(struct pcmcia_device *link)
265 goto failed; 243 goto failed;
266 244
267 link->dev_node = &vxp->node; 245 link->dev_node = &vxp->node;
268 kfree(parse);
269 return 0; 246 return 0;
270 247
271cs_failed: 248cs_failed:
272 cs_error(link, last_fn, last_ret); 249 cs_error(link, last_fn, last_ret);
273failed: 250failed:
274 pcmcia_disable_device(link); 251 pcmcia_disable_device(link);
275 kfree(parse);
276 return -ENODEV; 252 return -ENODEV;
277} 253}
278 254
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 2fbe1d183fce..8f074c7936e6 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -942,10 +942,11 @@ static void check_mute(struct snd_pmac *chip, struct pmac_gpio *gp, int val, int
942} 942}
943 943
944static struct work_struct device_change; 944static struct work_struct device_change;
945static struct snd_pmac *device_change_chip;
945 946
946static void device_change_handler(void *self) 947static void device_change_handler(struct work_struct *work)
947{ 948{
948 struct snd_pmac *chip = self; 949 struct snd_pmac *chip = device_change_chip;
949 struct pmac_tumbler *mix; 950 struct pmac_tumbler *mix;
950 int headphone, lineout; 951 int headphone, lineout;
951 952
@@ -1417,7 +1418,8 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1417 chip->resume = tumbler_resume; 1418 chip->resume = tumbler_resume;
1418#endif 1419#endif
1419 1420
1420 INIT_WORK(&device_change, device_change_handler, (void *)chip); 1421 INIT_WORK(&device_change, device_change_handler);
1422 device_change_chip = chip;
1421 1423
1422#ifdef PMAC_SUPPORT_AUTOMUTE 1424#ifdef PMAC_SUPPORT_AUTOMUTE
1423 if ((mix->headphone_irq >=0 || mix->lineout_irq >= 0) 1425 if ((mix->headphone_irq >=0 || mix->lineout_irq >= 0)