aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.mailmap1
-rw-r--r--Documentation/ABI/testing/sysfs-class-bdi46
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/debugobjects.tmpl391
-rw-r--r--Documentation/DocBook/rapidio.tmpl1
-rw-r--r--Documentation/braille-console.txt34
-rw-r--r--Documentation/feature-removal-schedule.txt18
-rw-r--r--Documentation/filesystems/proc.txt21
-rw-r--r--Documentation/kernel-parameters.txt7
-rw-r--r--Documentation/powerpc/mpc52xx-device-tree-bindings.txt12
-rw-r--r--MAINTAINERS131
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_npe.c4
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_qmgr.c2
-rw-r--r--arch/arm/mach-pxa/generic.c5
-rw-r--r--arch/arm/mach-pxa/littleton.c3
-rw-r--r--arch/arm/mach-pxa/lubbock.c4
-rw-r--r--arch/arm/mach-pxa/mainstone.c3
-rw-r--r--arch/arm/mach-pxa/zylonite.c6
-rw-r--r--arch/ia64/hp/sim/simserial.c11
-rw-r--r--arch/ia64/kernel/process.c2
-rw-r--r--arch/powerpc/boot/dts/cm5200.dts98
-rw-r--r--arch/powerpc/boot/dts/lite5200.dts132
-rw-r--r--arch/powerpc/boot/dts/lite5200b.dts146
-rw-r--r--arch/powerpc/boot/dts/motionpro.dts118
-rw-r--r--arch/powerpc/boot/dts/pcm030.dts363
-rw-r--r--arch/powerpc/boot/dts/tqm5200.dts80
-rw-r--r--arch/powerpc/configs/52xx/cm5200_defconfig1099
-rw-r--r--arch/powerpc/configs/52xx/lite5200b_defconfig1049
-rw-r--r--arch/powerpc/configs/52xx/motionpro_defconfig1107
-rw-r--r--arch/powerpc/configs/52xx/pcm030_defconfig1115
-rw-r--r--arch/powerpc/configs/52xx/tqm5200_defconfig1214
-rw-r--r--arch/powerpc/kernel/machine_kexec.c12
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c3
-rw-r--r--arch/powerpc/kernel/setup_64.c9
-rw-r--r--arch/powerpc/platforms/52xx/Kconfig6
-rw-r--r--arch/powerpc/platforms/52xx/Makefile2
-rw-r--r--arch/powerpc/platforms/52xx/mpc5200_simple.c1
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_gpio.c465
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c38
-rw-r--r--arch/powerpc/platforms/cell/spufs/.gitignore2
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c166
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c4
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h33
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.c36
-rw-r--r--arch/ppc/kernel/ppc_ksyms.c3
-rw-r--r--arch/s390/Kconfig8
-rw-r--r--arch/s390/defconfig141
-rw-r--r--arch/s390/kernel/Makefile2
-rw-r--r--arch/s390/kernel/early.c125
-rw-r--r--arch/s390/kernel/entry.S14
-rw-r--r--arch/s390/kernel/entry64.S12
-rw-r--r--arch/s390/kernel/head31.S61
-rw-r--r--arch/s390/kernel/head64.S64
-rw-r--r--arch/s390/kernel/process.c18
-rw-r--r--arch/s390/kernel/ptrace.c57
-rw-r--r--arch/s390/kernel/setup.c21
-rw-r--r--arch/s390/kernel/smp.c31
-rw-r--r--arch/s390/kernel/topology.c35
-rw-r--r--arch/s390/kernel/traps.c26
-rw-r--r--arch/s390/kvm/priv.c11
-rw-r--r--arch/s390/lib/Makefile2
-rw-r--r--arch/s390/lib/uaccess_mvcos.c2
-rw-r--r--arch/s390/math-emu/Makefile1
-rw-r--r--arch/s390/mm/Makefile2
-rw-r--r--arch/s390/mm/extmem.c8
-rw-r--r--arch/s390/mm/fault.c3
-rw-r--r--arch/s390/mm/hugetlbpage.c134
-rw-r--r--arch/s390/mm/init.c25
-rw-r--r--arch/s390/mm/vmem.c135
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/defconfig139
-rw-r--r--arch/sparc/kernel/Makefile1
-rw-r--r--arch/sparc/kernel/entry.S125
-rw-r--r--arch/sparc/kernel/head.S9
-rw-r--r--arch/sparc/kernel/kgdb.c164
-rw-r--r--arch/sparc/kernel/sparc-stub.c724
-rw-r--r--arch/sparc/kernel/sun4d_smp.c32
-rw-r--r--arch/sparc/kernel/sun4m_smp.c45
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--arch/sparc64/kernel/Makefile1
-rw-r--r--arch/sparc64/kernel/cherrs.S579
-rw-r--r--arch/sparc64/kernel/entry.S2575
-rw-r--r--arch/sparc64/kernel/fpu_traps.S384
-rw-r--r--arch/sparc64/kernel/getsetcc.S24
-rw-r--r--arch/sparc64/kernel/head.S15
-rw-r--r--arch/sparc64/kernel/helpers.S63
-rw-r--r--arch/sparc64/kernel/hvcalls.S886
-rw-r--r--arch/sparc64/kernel/ivec.S51
-rw-r--r--arch/sparc64/kernel/kgdb.c186
-rw-r--r--arch/sparc64/kernel/misctrap.S97
-rw-r--r--arch/sparc64/kernel/smp.c11
-rw-r--r--arch/sparc64/kernel/spiterrs.S245
-rw-r--r--arch/sparc64/kernel/syscalls.S279
-rw-r--r--arch/sparc64/kernel/ttable.S2
-rw-r--r--arch/sparc64/kernel/utrap.S29
-rw-r--r--arch/sparc64/mm/ultra.S27
-rw-r--r--arch/x86/ia32/ia32_signal.c2
-rw-r--r--arch/x86/kernel/signal_32.c17
-rw-r--r--arch/x86/kernel/signal_64.c16
-rw-r--r--block/genhd.c8
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/accessibility/Kconfig23
-rw-r--r--drivers/accessibility/Makefile1
-rw-r--r--drivers/accessibility/braille/Makefile1
-rw-r--r--drivers/accessibility/braille/braille_console.c397
-rw-r--r--drivers/atm/ambassador.c19
-rw-r--r--drivers/atm/ambassador.h2
-rw-r--r--drivers/base/node.c2
-rw-r--r--drivers/block/brd.c19
-rw-r--r--drivers/bluetooth/hci_ldisc.c13
-rw-r--r--drivers/char/agp/agp.h2
-rw-r--r--drivers/char/amiserial.c30
-rw-r--r--drivers/char/applicom.c4
-rw-r--r--drivers/char/consolemap.c1
-rw-r--r--drivers/char/cyclades.c432
-rw-r--r--drivers/char/drm/drmP.h8
-rw-r--r--drivers/char/drm/drm_sysfs.c2
-rw-r--r--drivers/char/drm/i830_dma.c18
-rw-r--r--drivers/char/drm/i830_drv.h2
-rw-r--r--drivers/char/drm/i830_irq.c8
-rw-r--r--drivers/char/drm/i915_dma.c4
-rw-r--r--drivers/char/drm/i915_drv.h2
-rw-r--r--drivers/char/drm/radeon_cp.c2
-rw-r--r--drivers/char/ds1286.c3
-rw-r--r--drivers/char/epca.c315
-rw-r--r--drivers/char/esp.c611
-rw-r--r--drivers/char/generic_serial.c18
-rw-r--r--drivers/char/hpet.c10
-rw-r--r--drivers/char/hvsi.c52
-rw-r--r--drivers/char/ip2/i2ellis.c194
-rw-r--r--drivers/char/ip2/i2ellis.h58
-rw-r--r--drivers/char/ip2/i2hw.h6
-rw-r--r--drivers/char/ip2/i2lib.c141
-rw-r--r--drivers/char/ip2/i2os.h127
-rw-r--r--drivers/char/ip2/ip2main.c89
-rw-r--r--drivers/char/isicom.c171
-rw-r--r--drivers/char/istallion.c22
-rw-r--r--drivers/char/keyboard.c4
-rw-r--r--drivers/char/mmtimer.c400
-rw-r--r--drivers/char/moxa.c2999
-rw-r--r--drivers/char/moxa.h304
-rw-r--r--drivers/char/mxser.c346
-rw-r--r--drivers/char/mxser.h137
-rw-r--r--drivers/char/n_hdlc.c35
-rw-r--r--drivers/char/n_r3964.c33
-rw-r--r--drivers/char/n_tty.c160
-rw-r--r--drivers/char/nozomi.c17
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c2
-rw-r--r--drivers/char/pcmcia/synclink_cs.c23
-rw-r--r--drivers/char/pty.c32
-rw-r--r--drivers/char/rio/cirrus.h210
-rw-r--r--drivers/char/rio/rio_linux.c10
-rw-r--r--drivers/char/rio/rio_linux.h6
-rw-r--r--drivers/char/rio/riocmd.c19
-rw-r--r--drivers/char/rio/rioctrl.c37
-rw-r--r--drivers/char/rio/riointr.c5
-rw-r--r--drivers/char/rio/rioparam.c70
-rw-r--r--drivers/char/rio/riotty.c25
-rw-r--r--drivers/char/riscom8.c706
-rw-r--r--drivers/char/rocket.c43
-rw-r--r--drivers/char/serial167.c25
-rw-r--r--drivers/char/snsc.c18
-rw-r--r--drivers/char/snsc_event.c6
-rw-r--r--drivers/char/sonypi.c2
-rw-r--r--drivers/char/specialix.c111
-rw-r--r--drivers/char/stallion.c17
-rw-r--r--drivers/char/sx.c35
-rw-r--r--drivers/char/synclink.c31
-rw-r--r--drivers/char/synclink_gt.c80
-rw-r--r--drivers/char/synclinkmp.c41
-rw-r--r--drivers/char/tty_io.c372
-rw-r--r--drivers/char/tty_ioctl.c126
-rw-r--r--drivers/char/viocons.c12
-rw-r--r--drivers/char/vt.c21
-rw-r--r--drivers/char/vt_ioctl.c452
-rw-r--r--drivers/gpio/gpiolib.c4
-rw-r--r--drivers/hwmon/ads7828.c2
-rw-r--r--drivers/input/serio/serport.c2
-rw-r--r--drivers/isdn/capi/capi.c9
-rw-r--r--drivers/isdn/gigaset/ser-gigaset.c15
-rw-r--r--drivers/isdn/i4l/isdn_tty.c30
-rw-r--r--drivers/md/md.c112
-rw-r--r--drivers/md/raid1.c27
-rw-r--r--drivers/md/raid10.c29
-rw-r--r--drivers/md/raid5.c33
-rw-r--r--drivers/media/common/Makefile1
-rw-r--r--drivers/media/video/bt8xx/bttvp.h2
-rw-r--r--drivers/media/video/usbvideo/vicam.c6
-rw-r--r--drivers/mfd/asic3.c6
-rw-r--r--drivers/mfd/sm501.c4
-rw-r--r--drivers/misc/kgdbts.c2
-rw-r--r--drivers/net/3c505.c30
-rw-r--r--drivers/net/3c505.h1
-rw-r--r--drivers/net/3c509.c47
-rw-r--r--drivers/net/3c515.c64
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/Makefile2
-rw-r--r--drivers/net/arm/Kconfig8
-rw-r--r--drivers/net/arm/Makefile1
-rw-r--r--drivers/net/arm/ixp4xx_eth.c1265
-rw-r--r--drivers/net/bfin_mac.c296
-rw-r--r--drivers/net/bfin_mac.h2
-rw-r--r--drivers/net/eepro.c2
-rw-r--r--drivers/net/fec_mpc52xx.c23
-rw-r--r--drivers/net/gianfar.c27
-rw-r--r--drivers/net/gianfar.h1
-rw-r--r--drivers/net/gianfar_mii.c38
-rw-r--r--drivers/net/gianfar_mii.h3
-rw-r--r--drivers/net/hamradio/6pack.c36
-rw-r--r--drivers/net/hamradio/mkiss.c15
-rw-r--r--drivers/net/irda/irtty-sir.c95
-rw-r--r--drivers/net/phy/Kconfig2
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/phy/smsc.c83
-rw-r--r--drivers/net/ppp_async.c9
-rw-r--r--drivers/net/ppp_synctty.c9
-rw-r--r--drivers/net/r8169.c8
-rw-r--r--drivers/net/s2io.c337
-rw-r--r--drivers/net/s2io.h82
-rw-r--r--drivers/net/sfc/Kconfig12
-rw-r--r--drivers/net/sfc/Makefile5
-rw-r--r--drivers/net/sfc/bitfield.h508
-rw-r--r--drivers/net/sfc/boards.c167
-rw-r--r--drivers/net/sfc/boards.h26
-rw-r--r--drivers/net/sfc/efx.c2208
-rw-r--r--drivers/net/sfc/efx.h67
-rw-r--r--drivers/net/sfc/enum.h50
-rw-r--r--drivers/net/sfc/ethtool.c460
-rw-r--r--drivers/net/sfc/ethtool.h27
-rw-r--r--drivers/net/sfc/falcon.c2722
-rw-r--r--drivers/net/sfc/falcon.h130
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h1135
-rw-r--r--drivers/net/sfc/falcon_io.h243
-rw-r--r--drivers/net/sfc/falcon_xmac.c585
-rw-r--r--drivers/net/sfc/gmii.h195
-rw-r--r--drivers/net/sfc/i2c-direct.c381
-rw-r--r--drivers/net/sfc/i2c-direct.h91
-rw-r--r--drivers/net/sfc/mac.h33
-rw-r--r--drivers/net/sfc/mdio_10g.c282
-rw-r--r--drivers/net/sfc/mdio_10g.h232
-rw-r--r--drivers/net/sfc/net_driver.h883
-rw-r--r--drivers/net/sfc/phy.h48
-rw-r--r--drivers/net/sfc/rx.c875
-rw-r--r--drivers/net/sfc/rx.h29
-rw-r--r--drivers/net/sfc/sfe4001.c252
-rw-r--r--drivers/net/sfc/spi.h71
-rw-r--r--drivers/net/sfc/tenxpress.c434
-rw-r--r--drivers/net/sfc/tx.c452
-rw-r--r--drivers/net/sfc/tx.h24
-rw-r--r--drivers/net/sfc/workarounds.h56
-rw-r--r--drivers/net/sfc/xenpack.h62
-rw-r--r--drivers/net/sfc/xfp_phy.c132
-rw-r--r--drivers/net/sis190.c136
-rw-r--r--drivers/net/slip.c13
-rw-r--r--drivers/net/wan/pc300_tty.c24
-rw-r--r--drivers/net/wan/x25_asy.c279
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig12
-rw-r--r--drivers/net/wireless/strip.c66
-rw-r--r--drivers/parport/ieee1284.c4
-rw-r--r--drivers/parport/parport_gsc.c4
-rw-r--r--drivers/parport/parport_pc.c8
-rw-r--r--drivers/s390/char/con3215.c5
-rw-r--r--drivers/s390/char/sclp_config.c17
-rw-r--r--drivers/s390/char/sclp_tty.c4
-rw-r--r--drivers/s390/char/sclp_vt220.c6
-rw-r--r--drivers/s390/char/tty3270.c3
-rw-r--r--drivers/s390/cio/ccwgroup.c103
-rw-r--r--drivers/s390/cio/cio.c9
-rw-r--r--drivers/s390/cio/cio.h3
-rw-r--r--drivers/s390/cio/cmf.c11
-rw-r--r--drivers/s390/cio/css.c10
-rw-r--r--drivers/s390/cio/device.c17
-rw-r--r--drivers/s390/cio/device_fsm.c10
-rw-r--r--drivers/s390/cio/device_ops.c2
-rw-r--r--drivers/s390/cio/qdio.c8
-rw-r--r--drivers/s390/kvm/kvm_virtio.c23
-rw-r--r--drivers/s390/net/cu3088.c20
-rw-r--r--drivers/s390/net/lcs.c3
-rw-r--r--drivers/s390/net/netiucv.c3
-rw-r--r--drivers/s390/net/qeth_core.h50
-rw-r--r--drivers/s390/net/qeth_core_main.c200
-rw-r--r--drivers/s390/net/qeth_l2_main.c30
-rw-r--r--drivers/s390/net/qeth_l3.h3
-rw-r--r--drivers/s390/net/qeth_l3_main.c30
-rw-r--r--drivers/sbus/char/cpwatchdog.c2
-rw-r--r--drivers/sbus/char/uctrl.c4
-rw-r--r--drivers/serial/68328serial.c21
-rw-r--r--drivers/serial/68360serial.c28
-rw-r--r--drivers/serial/8250_early.c2
-rw-r--r--drivers/serial/Kconfig43
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/bfin_5xx.c4
-rw-r--r--drivers/serial/bfin_sport_uart.c614
-rw-r--r--drivers/serial/bfin_sport_uart.h63
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c2
-rw-r--r--drivers/serial/crisv10.c31
-rw-r--r--drivers/serial/ioc3_serial.c36
-rw-r--r--drivers/serial/ioc4_serial.c32
-rw-r--r--drivers/serial/kgdboc.c6
-rw-r--r--drivers/serial/mcfserial.c22
-rw-r--r--drivers/serial/mpc52xx_uart.c2
-rw-r--r--drivers/serial/netx-serial.c1
-rw-r--r--drivers/serial/s3c2410.c6
-rw-r--r--drivers/serial/sa1100.c4
-rw-r--r--drivers/serial/serial_core.c54
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/serial/sn_console.c2
-rw-r--r--drivers/serial/uartlite.c2
-rw-r--r--drivers/serial/ucc_uart.c4
-rw-r--r--drivers/spi/atmel_spi.c29
-rw-r--r--drivers/usb/gadget/serial.c10
-rw-r--r--drivers/usb/serial/digi_acceleport.c3
-rw-r--r--drivers/usb/serial/usb-serial.c129
-rw-r--r--drivers/usb/serial/whiteheat.c4
-rw-r--r--drivers/video/Kconfig5
-rw-r--r--drivers/video/pxafb.c1297
-rw-r--r--drivers/video/pxafb.h70
-rw-r--r--drivers/w1/w1_log.h2
-rw-r--r--fs/Kconfig3
-rw-r--r--fs/adfs/adfs.h2
-rw-r--r--fs/affs/file.c4
-rw-r--r--fs/afs/dir.c4
-rw-r--r--fs/afs/internal.h8
-rw-r--r--fs/aio.c5
-rw-r--r--fs/autofs4/autofs_i.h2
-rw-r--r--fs/bfs/bfs.h2
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/compat.c14
-rw-r--r--fs/compat_ioctl.c4
-rw-r--r--fs/configfs/file.c2
-rw-r--r--fs/configfs/inode.c2
-rw-r--r--fs/configfs/mount.c2
-rw-r--r--fs/configfs/symlink.c4
-rw-r--r--fs/devpts/inode.c43
-rw-r--r--fs/dlm/lockspace.c2
-rw-r--r--fs/eventpoll.c7
-rw-r--r--fs/exec.c17
-rw-r--r--fs/exportfs/expfs.c10
-rw-r--r--fs/fat/cache.c6
-rw-r--r--fs/fat/fatent.c2
-rw-r--r--fs/fat/file.c2
-rw-r--r--fs/fuse/control.c2
-rw-r--r--fs/fuse/dev.c23
-rw-r--r--fs/fuse/dir.c86
-rw-r--r--fs/fuse/file.c631
-rw-r--r--fs/fuse/fuse_i.h52
-rw-r--r--fs/fuse/inode.c90
-rw-r--r--fs/gfs2/locking/dlm/sysfs.c2
-rw-r--r--fs/gfs2/util.h18
-rw-r--r--fs/hfs/btree.c10
-rw-r--r--fs/hfs/mdb.c2
-rw-r--r--fs/hfsplus/btree.c10
-rw-r--r--fs/hfsplus/super.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/isofs/dir.c8
-rw-r--r--fs/isofs/namei.c7
-rw-r--r--fs/jffs2/debug.h8
-rw-r--r--fs/jffs2/xattr.c4
-rw-r--r--fs/lockd/clntproc.c2
-rw-r--r--fs/lockd/svclock.c2
-rw-r--r--fs/msdos/namei.c2
-rw-r--r--fs/namespace.c4
-rw-r--r--fs/nfs/super.c26
-rw-r--r--fs/nfsd/nfs4callback.c4
-rw-r--r--fs/ntfs/debug.h6
-rw-r--r--fs/ocfs2/dlm/dlmfs.c2
-rw-r--r--fs/partitions/ldm.c8
-rw-r--r--fs/proc/array.c6
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/proc/proc_tty.c6
-rw-r--r--fs/quota_v2.c4
-rw-r--r--fs/ramfs/inode.c2
-rw-r--r--fs/reiserfs/journal.c50
-rw-r--r--fs/select.c12
-rw-r--r--fs/smbfs/smb_debug.h6
-rw-r--r--fs/sysfs/file.c2
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysfs/mount.c2
-rw-r--r--fs/sysv/sysv.h8
-rw-r--r--fs/udf/super.c4
-rw-r--r--fs/vfat/namei.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h1
-rw-r--r--fs/xfs/support/debug.h2
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h196
-rw-r--r--include/asm-arm/arch-pxa/pxafb.h71
-rw-r--r--include/asm-arm/arch-pxa/regs-lcd.h171
-rw-r--r--include/asm-generic/bitops.h4
-rw-r--r--include/asm-generic/futex.h5
-rw-r--r--include/asm-generic/memory_model.h2
-rw-r--r--include/asm-generic/page.h2
-rw-r--r--include/asm-generic/rtc.h3
-rw-r--r--include/asm-ia64/futex.h2
-rw-r--r--include/asm-ia64/thread_info.h5
-rw-r--r--include/asm-mips/futex.h2
-rw-r--r--include/asm-parisc/futex.h2
-rw-r--r--include/asm-powerpc/futex.h2
-rw-r--r--include/asm-s390/ccwgroup.h7
-rw-r--r--include/asm-s390/hugetlb.h183
-rw-r--r--include/asm-s390/page.h49
-rw-r--r--include/asm-s390/pgtable.h21
-rw-r--r--include/asm-s390/processor.h9
-rw-r--r--include/asm-s390/ptrace.h2
-rw-r--r--include/asm-s390/qdio.h1
-rw-r--r--include/asm-s390/setup.h39
-rw-r--r--include/asm-s390/smp.h12
-rw-r--r--include/asm-s390/sparsemem.h18
-rw-r--r--include/asm-s390/sysinfo.h5
-rw-r--r--include/asm-s390/system.h18
-rw-r--r--include/asm-s390/thread_info.h2
-rw-r--r--include/asm-s390/tlbflush.h1
-rw-r--r--include/asm-s390/topology.h4
-rw-r--r--include/asm-sh/futex.h2
-rw-r--r--include/asm-sparc/head.h11
-rw-r--r--include/asm-sparc/kgdb.h116
-rw-r--r--include/asm-sparc/smp.h2
-rw-r--r--include/asm-sparc/system.h2
-rw-r--r--include/asm-sparc64/futex.h2
-rw-r--r--include/asm-sparc64/kgdb.h1
-rw-r--r--include/asm-sparc64/pil.h7
-rw-r--r--include/asm-sparc64/system.h5
-rw-r--r--include/asm-sparc64/ttable.h6
-rw-r--r--include/asm-x86/futex.h2
-rw-r--r--include/asm-x86/thread_info_32.h13
-rw-r--r--include/asm-x86/thread_info_64.h13
-rw-r--r--include/linux/agp_backend.h3
-rw-r--r--include/linux/backing-dev.h100
-rw-r--r--include/linux/byteorder/Kbuild6
-rw-r--r--include/linux/byteorder/big_endian.h2
-rw-r--r--include/linux/byteorder/generic.h8
-rw-r--r--include/linux/byteorder/little_endian.h2
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/coda_fs_i.h2
-rw-r--r--include/linux/compiler-gcc.h5
-rw-r--r--include/linux/concap.h3
-rw-r--r--include/linux/configfs.h4
-rw-r--r--include/linux/console.h4
-rw-r--r--include/linux/crc-ccitt.h2
-rw-r--r--include/linux/dcache.h4
-rw-r--r--include/linux/debugobjects.h90
-rw-r--r--include/linux/device-mapper.h3
-rw-r--r--include/linux/devpts_fs.h4
-rw-r--r--include/linux/eventfd.h5
-rw-r--r--include/linux/fsl_devices.h2
-rw-r--r--include/linux/fsnotify.h4
-rw-r--r--include/linux/generic_serial.h2
-rw-r--r--include/linux/hrtimer.h15
-rw-r--r--include/linux/hw_random.h2
-rw-r--r--include/linux/i2o.h3
-rw-r--r--include/linux/if_macvlan.h3
-rw-r--r--include/linux/inet.h2
-rw-r--r--include/linux/isicom.h7
-rw-r--r--include/linux/kernel.h91
-rw-r--r--include/linux/kfifo.h5
-rw-r--r--include/linux/kobj_map.h4
-rw-r--r--include/linux/kobject.h3
-rw-r--r--include/linux/kref.h3
-rw-r--r--include/linux/list.h5
-rw-r--r--include/linux/mmzone.h3
-rw-r--r--include/linux/mount.h2
-rw-r--r--include/linux/ncp_fs_i.h4
-rw-r--r--include/linux/of_device.h2
-rw-r--r--include/linux/pid.h8
-rw-r--r--include/linux/pid_namespace.h2
-rw-r--r--include/linux/pm.h4
-rw-r--r--include/linux/pnp.h4
-rw-r--r--include/linux/poison.h7
-rw-r--r--include/linux/profile.h4
-rw-r--r--include/linux/proportions.h13
-rw-r--r--include/linux/ptrace.h4
-rw-r--r--include/linux/raid/md.h1
-rw-r--r--include/linux/raid/md_k.h4
-rw-r--r--include/linux/rcuclassic.h3
-rw-r--r--include/linux/rcupdate.h3
-rw-r--r--include/linux/rcupreempt.h3
-rw-r--r--include/linux/rcupreempt_trace.h2
-rw-r--r--include/linux/reiserfs_fs_sb.h1
-rw-r--r--include/linux/rio.h3
-rw-r--r--include/linux/rio_drv.h3
-rw-r--r--include/linux/rwsem.h3
-rw-r--r--include/linux/sched.h18
-rw-r--r--include/linux/seq_file.h2
-rw-r--r--include/linux/serial_core.h6
-rw-r--r--include/linux/signal.h2
-rw-r--r--include/linux/slab.h10
-rw-r--r--include/linux/smb_fs_i.h2
-rw-r--r--include/linux/smb_fs_sb.h4
-rw-r--r--include/linux/svga.h3
-rw-r--r--include/linux/textsearch.h4
-rw-r--r--include/linux/thread_info.h27
-rw-r--r--include/linux/timer.h23
-rw-r--r--include/linux/tty.h25
-rw-r--r--include/linux/tty_driver.h106
-rw-r--r--include/linux/writeback.h3
-rw-r--r--include/net/compat.h3
-rw-r--r--include/net/ip_vs.h3
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h10
-rw-r--r--include/net/route.h2
-rw-r--r--init/main.c7
-rw-r--r--kernel/cgroup.c2
-rw-r--r--kernel/compat.c3
-rw-r--r--kernel/cpu.c4
-rw-r--r--kernel/exit.c66
-rw-r--r--kernel/fork.c2
-rw-r--r--kernel/futex.c17
-rw-r--r--kernel/hrtimer.c177
-rw-r--r--kernel/kthread.c2
-rw-r--r--kernel/marker.c2
-rw-r--r--kernel/pid.c41
-rw-r--r--kernel/pid_namespace.c2
-rw-r--r--kernel/posix-timers.c6
-rw-r--r--kernel/printk.c96
-rw-r--r--kernel/ptrace.c13
-rw-r--r--kernel/signal.c646
-rw-r--r--kernel/sys.c79
-rw-r--r--kernel/taskstats.c6
-rw-r--r--kernel/timer.c153
-rw-r--r--kernel/user.c18
-rw-r--r--kernel/workqueue.c2
-rw-r--r--lib/Kconfig.debug31
-rw-r--r--lib/Makefile1
-rw-r--r--lib/debugobjects.c890
-rw-r--r--lib/kobject.c16
-rw-r--r--lib/kobject_uevent.c10
-rw-r--r--lib/percpu_counter.c1
-rw-r--r--lib/proportions.c38
-rw-r--r--mm/backing-dev.c219
-rw-r--r--mm/migrate.c9
-rw-r--r--mm/page-writeback.c77
-rw-r--r--mm/page_alloc.c10
-rw-r--r--mm/readahead.c8
-rw-r--r--mm/shmem.c2
-rw-r--r--mm/slab.c14
-rw-r--r--mm/slub.c3
-rw-r--r--mm/sparse.c19
-rw-r--r--mm/swap_state.c2
-rw-r--r--mm/vmalloc.c2
-rw-r--r--mm/vmscan.c4
-rw-r--r--mm/vmstat.c5
-rw-r--r--net/bridge/br.c2
-rw-r--r--net/bridge/br_if.c5
-rw-r--r--net/compat.c90
-rw-r--r--net/ipv4/icmp.c3
-rw-r--r--net/ipv4/ip_output.c22
-rw-r--r--net/ipv4/ip_sockglue.c9
-rw-r--r--net/ipv4/ipconfig.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_ah.c1
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_esp.c1
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c1
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c1
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c80
-rw-r--r--net/ipv4/netfilter/ip_queue.c5
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c2
-rw-r--r--net/ipv4/route.c38
-rw-r--r--net/ipv4/tcp_cong.c12
-rw-r--r--net/ipv4/tcp_vegas.c10
-rw-r--r--net/ipv4/tcp_veno.c8
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/netfilter/ip6_queue.c5
-rw-r--r--net/irda/ircomm/ircomm_tty.c6
-rw-r--r--net/netfilter/nf_conntrack_core.c4
-rw-r--r--net/netfilter/nfnetlink_queue.c5
-rw-r--r--net/netfilter/x_tables.c2
-rw-r--r--net/netfilter/xt_TCPOPTSTRIP.c2
-rw-r--r--net/sched/sch_sfq.c3
-rw-r--r--scripts/kallsyms.c6
-rw-r--r--security/selinux/hooks.c3
-rw-r--r--security/smack/smack_lsm.c9
572 files changed, 38214 insertions, 12645 deletions
diff --git a/.mailmap b/.mailmap
index ebf9bf84da0a..726084286d33 100644
--- a/.mailmap
+++ b/.mailmap
@@ -88,6 +88,7 @@ Rudolf Marek <R.Marek@sh.cvut.cz>
88Rui Saraiva <rmps@joel.ist.utl.pt> 88Rui Saraiva <rmps@joel.ist.utl.pt>
89Sachin P Sant <ssant@in.ibm.com> 89Sachin P Sant <ssant@in.ibm.com>
90Sam Ravnborg <sam@mars.ravnborg.org> 90Sam Ravnborg <sam@mars.ravnborg.org>
91S.Çağlar Onur <caglar@pardus.org.tr>
91Simon Kelley <simon@thekelleys.org.uk> 92Simon Kelley <simon@thekelleys.org.uk>
92Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr> 93Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr>
93Stephen Hemminger <shemminger@osdl.org> 94Stephen Hemminger <shemminger@osdl.org>
diff --git a/Documentation/ABI/testing/sysfs-class-bdi b/Documentation/ABI/testing/sysfs-class-bdi
new file mode 100644
index 000000000000..5ac1e01bbd48
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-bdi
@@ -0,0 +1,46 @@
1What: /sys/class/bdi/<bdi>/
2Date: January 2008
3Contact: Peter Zijlstra <a.p.zijlstra@chello.nl>
4Description:
5
6Provide a place in sysfs for the backing_dev_info object. This allows
7setting and retrieving various BDI specific variables.
8
9The <bdi> identifier can be either of the following:
10
11MAJOR:MINOR
12
13 Device number for block devices, or value of st_dev on
14 non-block filesystems which provide their own BDI, such as NFS
15 and FUSE.
16
17default
18
19 The default backing dev, used for non-block device backed
20 filesystems which do not provide their own BDI.
21
22Files under /sys/class/bdi/<bdi>/
23---------------------------------
24
25read_ahead_kb (read-write)
26
27 Size of the read-ahead window in kilobytes
28
29min_ratio (read-write)
30
31 Under normal circumstances each device is given a part of the
32 total write-back cache that relates to its current average
33 writeout speed in relation to the other devices.
34
35 The 'min_ratio' parameter allows assigning a minimum
36 percentage of the write-back cache to a particular device.
37 For example, this is useful for providing a minimum QoS.
38
39max_ratio (read-write)
40
41 Allows limiting a particular device to use not more than the
42 given percentage of the write-back cache. This is useful in
43 situations where we want to avoid one device taking all or
44 most of the write-back cache. For example in case of an NFS
45 mount that is prone to get stuck, or a FUSE mount which cannot
46 be trusted to play fair.
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 83966e94cc32..0eb0d027eb32 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -12,7 +12,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
15 mac80211.xml 15 mac80211.xml debugobjects.xml
16 16
17### 17###
18# The build process is as follows (targets): 18# The build process is as follows (targets):
diff --git a/Documentation/DocBook/debugobjects.tmpl b/Documentation/DocBook/debugobjects.tmpl
new file mode 100644
index 000000000000..7f5f218015fe
--- /dev/null
+++ b/Documentation/DocBook/debugobjects.tmpl
@@ -0,0 +1,391 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="debug-objects-guide">
6 <bookinfo>
7 <title>Debug objects life time</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Thomas</firstname>
12 <surname>Gleixner</surname>
13 <affiliation>
14 <address>
15 <email>tglx@linutronix.de</email>
16 </address>
17 </affiliation>
18 </author>
19 </authorgroup>
20
21 <copyright>
22 <year>2008</year>
23 <holder>Thomas Gleixner</holder>
24 </copyright>
25
26 <legalnotice>
27 <para>
28 This documentation is free software; you can redistribute
29 it and/or modify it under the terms of the GNU General Public
30 License version 2 as published by the Free Software Foundation.
31 </para>
32
33 <para>
34 This program is distributed in the hope that it will be
35 useful, but WITHOUT ANY WARRANTY; without even the implied
36 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
37 See the GNU General Public License for more details.
38 </para>
39
40 <para>
41 You should have received a copy of the GNU General Public
42 License along with this program; if not, write to the Free
43 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
44 MA 02111-1307 USA
45 </para>
46
47 <para>
48 For more details see the file COPYING in the source
49 distribution of Linux.
50 </para>
51 </legalnotice>
52 </bookinfo>
53
54<toc></toc>
55
56 <chapter id="intro">
57 <title>Introduction</title>
58 <para>
59 debugobjects is a generic infrastructure to track the life time
60 of kernel objects and validate the operations on those.
61 </para>
62 <para>
63 debugobjects is useful to check for the following error patterns:
64 <itemizedlist>
65 <listitem><para>Activation of uninitialized objects</para></listitem>
66 <listitem><para>Initialization of active objects</para></listitem>
67 <listitem><para>Usage of freed/destroyed objects</para></listitem>
68 </itemizedlist>
69 </para>
70 <para>
71 debugobjects is not changing the data structure of the real
72 object so it can be compiled in with a minimal runtime impact
73 and enabled on demand with a kernel command line option.
74 </para>
75 </chapter>
76
77 <chapter id="howto">
78 <title>Howto use debugobjects</title>
79 <para>
80 A kernel subsystem needs to provide a data structure which
81 describes the object type and add calls into the debug code at
82 appropriate places. The data structure to describe the object
83 type needs at minimum the name of the object type. Optional
84 functions can and should be provided to fixup detected problems
85 so the kernel can continue to work and the debug information can
86 be retrieved from a live system instead of hard core debugging
87 with serial consoles and stack trace transcripts from the
88 monitor.
89 </para>
90 <para>
91 The debug calls provided by debugobjects are:
92 <itemizedlist>
93 <listitem><para>debug_object_init</para></listitem>
94 <listitem><para>debug_object_init_on_stack</para></listitem>
95 <listitem><para>debug_object_activate</para></listitem>
96 <listitem><para>debug_object_deactivate</para></listitem>
97 <listitem><para>debug_object_destroy</para></listitem>
98 <listitem><para>debug_object_free</para></listitem>
99 </itemizedlist>
100 Each of these functions takes the address of the real object and
101 a pointer to the object type specific debug description
102 structure.
103 </para>
104 <para>
105 Each detected error is reported in the statistics and a limited
106 number of errors are printk'ed including a full stack trace.
107 </para>
108 <para>
109 The statistics are available via debugfs/debug_objects/stats.
110 They provide information about the number of warnings and the
111 number of successful fixups along with information about the
112 usage of the internal tracking objects and the state of the
113 internal tracking objects pool.
114 </para>
115 </chapter>
116 <chapter id="debugfunctions">
117 <title>Debug functions</title>
118 <sect1 id="prototypes">
119 <title>Debug object function reference</title>
120!Elib/debugobjects.c
121 </sect1>
122 <sect1 id="debug_object_init">
123 <title>debug_object_init</title>
124 <para>
125 This function is called whenever the initialization function
126 of a real object is called.
127 </para>
128 <para>
129 When the real object is already tracked by debugobjects it is
130 checked, whether the object can be initialized. Initializing
131 is not allowed for active and destroyed objects. When
132 debugobjects detects an error, then it calls the fixup_init
133 function of the object type description structure if provided
134 by the caller. The fixup function can correct the problem
135 before the real initialization of the object happens. E.g. it
136 can deactivate an active object in order to prevent damage to
137 the subsystem.
138 </para>
139 <para>
140 When the real object is not yet tracked by debugobjects,
141 debugobjects allocates a tracker object for the real object
142 and sets the tracker object state to ODEBUG_STATE_INIT. It
143 verifies that the object is not on the callers stack. If it is
144 on the callers stack then a limited number of warnings
145 including a full stack trace is printk'ed. The calling code
146 must use debug_object_init_on_stack() and remove the object
147 before leaving the function which allocated it. See next
148 section.
149 </para>
150 </sect1>
151
152 <sect1 id="debug_object_init_on_stack">
153 <title>debug_object_init_on_stack</title>
154 <para>
155 This function is called whenever the initialization function
156 of a real object which resides on the stack is called.
157 </para>
158 <para>
159 When the real object is already tracked by debugobjects it is
160 checked, whether the object can be initialized. Initializing
161 is not allowed for active and destroyed objects. When
162 debugobjects detects an error, then it calls the fixup_init
163 function of the object type description structure if provided
164 by the caller. The fixup function can correct the problem
165 before the real initialization of the object happens. E.g. it
166 can deactivate an active object in order to prevent damage to
167 the subsystem.
168 </para>
169 <para>
170 When the real object is not yet tracked by debugobjects
171 debugobjects allocates a tracker object for the real object
172 and sets the tracker object state to ODEBUG_STATE_INIT. It
173 verifies that the object is on the callers stack.
174 </para>
175 <para>
176 An object which is on the stack must be removed from the
177 tracker by calling debug_object_free() before the function
178 which allocates the object returns. Otherwise we keep track of
179 stale objects.
180 </para>
181 </sect1>
182
183 <sect1 id="debug_object_activate">
184 <title>debug_object_activate</title>
185 <para>
186 This function is called whenever the activation function of a
187 real object is called.
188 </para>
189 <para>
190 When the real object is already tracked by debugobjects it is
191 checked, whether the object can be activated. Activating is
192 not allowed for active and destroyed objects. When
193 debugobjects detects an error, then it calls the
194 fixup_activate function of the object type description
195 structure if provided by the caller. The fixup function can
196 correct the problem before the real activation of the object
197 happens. E.g. it can deactivate an active object in order to
198 prevent damage to the subsystem.
199 </para>
200 <para>
201 When the real object is not yet tracked by debugobjects then
202 the fixup_activate function is called if available. This is
203 necessary to allow the legitimate activation of statically
204 allocated and initialized objects. The fixup function checks
205 whether the object is valid and calls the debug_objects_init()
206 function to initialize the tracking of this object.
207 </para>
208 <para>
209 When the activation is legitimate, then the state of the
210 associated tracker object is set to ODEBUG_STATE_ACTIVE.
211 </para>
212 </sect1>
213
214 <sect1 id="debug_object_deactivate">
215 <title>debug_object_deactivate</title>
216 <para>
217 This function is called whenever the deactivation function of
218 a real object is called.
219 </para>
220 <para>
221 When the real object is tracked by debugobjects it is checked,
222 whether the object can be deactivated. Deactivating is not
223 allowed for untracked or destroyed objects.
224 </para>
225 <para>
226 When the deactivation is legitimate, then the state of the
227 associated tracker object is set to ODEBUG_STATE_INACTIVE.
228 </para>
229 </sect1>
230
231 <sect1 id="debug_object_destroy">
232 <title>debug_object_destroy</title>
233 <para>
234 This function is called to mark an object destroyed. This is
235 useful to prevent the usage of invalid objects, which are
236 still available in memory: either statically allocated objects
237 or objects which are freed later.
238 </para>
239 <para>
240 When the real object is tracked by debugobjects it is checked,
241 whether the object can be destroyed. Destruction is not
242 allowed for active and destroyed objects. When debugobjects
243 detects an error, then it calls the fixup_destroy function of
244 the object type description structure if provided by the
245 caller. The fixup function can correct the problem before the
246 real destruction of the object happens. E.g. it can deactivate
247 an active object in order to prevent damage to the subsystem.
248 </para>
249 <para>
250 When the destruction is legitimate, then the state of the
251 associated tracker object is set to ODEBUG_STATE_DESTROYED.
252 </para>
253 </sect1>
254
255 <sect1 id="debug_object_free">
256 <title>debug_object_free</title>
257 <para>
258 This function is called before an object is freed.
259 </para>
260 <para>
261 When the real object is tracked by debugobjects it is checked,
262 whether the object can be freed. Free is not allowed for
263 active objects. When debugobjects detects an error, then it
264 calls the fixup_free function of the object type description
265 structure if provided by the caller. The fixup function can
266 correct the problem before the real free of the object
267 happens. E.g. it can deactivate an active object in order to
268 prevent damage to the subsystem.
269 </para>
270 <para>
271 Note that debug_object_free removes the object from the
272 tracker. Later usage of the object is detected by the other
273 debug checks.
274 </para>
275 </sect1>
276 </chapter>
277 <chapter id="fixupfunctions">
278 <title>Fixup functions</title>
279 <sect1 id="debug_obj_descr">
280 <title>Debug object type description structure</title>
281!Iinclude/linux/debugobjects.h
282 </sect1>
283 <sect1 id="fixup_init">
284 <title>fixup_init</title>
285 <para>
286 This function is called from the debug code whenever a problem
287 in debug_object_init is detected. The function takes the
288 address of the object and the state which is currently
289 recorded in the tracker.
290 </para>
291 <para>
292 Called from debug_object_init when the object state is:
293 <itemizedlist>
294 <listitem><para>ODEBUG_STATE_ACTIVE</para></listitem>
295 </itemizedlist>
296 </para>
297 <para>
298 The function returns 1 when the fixup was successful,
299 otherwise 0. The return value is used to update the
300 statistics.
301 </para>
302 <para>
303 Note, that the function needs to call the debug_object_init()
304 function again, after the damage has been repaired in order to
305 keep the state consistent.
306 </para>
307 </sect1>
308
309 <sect1 id="fixup_activate">
310 <title>fixup_activate</title>
311 <para>
312 This function is called from the debug code whenever a problem
313 in debug_object_activate is detected.
314 </para>
315 <para>
316 Called from debug_object_activate when the object state is:
317 <itemizedlist>
318 <listitem><para>ODEBUG_STATE_NOTAVAILABLE</para></listitem>
319 <listitem><para>ODEBUG_STATE_ACTIVE</para></listitem>
320 </itemizedlist>
321 </para>
322 <para>
323 The function returns 1 when the fixup was successful,
324 otherwise 0. The return value is used to update the
325 statistics.
326 </para>
327 <para>
328 Note that the function needs to call the debug_object_activate()
329 function again after the damage has been repaired in order to
330 keep the state consistent.
331 </para>
332 <para>
333 The activation of statically initialized objects is a special
334 case. When debug_object_activate() has no tracked object for
335 this object address then fixup_activate() is called with
336 object state ODEBUG_STATE_NOTAVAILABLE. The fixup function
337 needs to check whether this is a legitimate case of a
338 statically initialized object or not. In case it is it calls
339 debug_object_init() and debug_object_activate() to make the
340 object known to the tracker and marked active. In this case
341 the function should return 0 because this is not a real fixup.
342 </para>
343 </sect1>
344
345 <sect1 id="fixup_destroy">
346 <title>fixup_destroy</title>
347 <para>
348 This function is called from the debug code whenever a problem
349 in debug_object_destroy is detected.
350 </para>
351 <para>
352 Called from debug_object_destroy when the object state is:
353 <itemizedlist>
354 <listitem><para>ODEBUG_STATE_ACTIVE</para></listitem>
355 </itemizedlist>
356 </para>
357 <para>
358 The function returns 1 when the fixup was successful,
359 otherwise 0. The return value is used to update the
360 statistics.
361 </para>
362 </sect1>
363 <sect1 id="fixup_free">
364 <title>fixup_free</title>
365 <para>
366 This function is called from the debug code whenever a problem
367 in debug_object_free is detected. Further it can be called
368 from the debug checks in kfree/vfree, when an active object is
369 detected from the debug_check_no_obj_freed() sanity checks.
370 </para>
371 <para>
372 Called from debug_object_free() or debug_check_no_obj_freed()
373 when the object state is:
374 <itemizedlist>
375 <listitem><para>ODEBUG_STATE_ACTIVE</para></listitem>
376 </itemizedlist>
377 </para>
378 <para>
379 The function returns 1 when the fixup was successful,
380 otherwise 0. The return value is used to update the
381 statistics.
382 </para>
383 </sect1>
384 </chapter>
385 <chapter id="bugs">
386 <title>Known Bugs And Assumptions</title>
387 <para>
388 None (knock on wood).
389 </para>
390 </chapter>
391</book>
diff --git a/Documentation/DocBook/rapidio.tmpl b/Documentation/DocBook/rapidio.tmpl
index b9e143e28c64..54eb26b57372 100644
--- a/Documentation/DocBook/rapidio.tmpl
+++ b/Documentation/DocBook/rapidio.tmpl
@@ -133,7 +133,6 @@
133!Idrivers/rapidio/rio-sysfs.c 133!Idrivers/rapidio/rio-sysfs.c
134 </sect1> 134 </sect1>
135 <sect1 id="PPC32_support"><title>PPC32 support</title> 135 <sect1 id="PPC32_support"><title>PPC32 support</title>
136!Iarch/powerpc/kernel/rio.c
137!Earch/powerpc/sysdev/fsl_rio.c 136!Earch/powerpc/sysdev/fsl_rio.c
138!Iarch/powerpc/sysdev/fsl_rio.c 137!Iarch/powerpc/sysdev/fsl_rio.c
139 </sect1> 138 </sect1>
diff --git a/Documentation/braille-console.txt b/Documentation/braille-console.txt
new file mode 100644
index 000000000000..000b0fbdc105
--- /dev/null
+++ b/Documentation/braille-console.txt
@@ -0,0 +1,34 @@
1 Linux Braille Console
2
3To get early boot messages on a braille device (before userspace screen
4readers can start), you first need to compile the support for the usual serial
5console (see serial-console.txt), and for braille device (in Device Drivers -
6Accessibility).
7
8Then you need to specify a console=brl, option on the kernel command line, the
9format is:
10
11 console=brl,serial_options...
12
13where serial_options... are the same as described in serial-console.txt
14
15So for instance you can use console=brl,ttyS0 if the braille device is connected
16to the first serial port, and console=brl,ttyS0,115200 to override the baud rate
17to 115200, etc.
18
19By default, the braille device will just show the last kernel message (console
20mode). To review previous messages, press the Insert key to switch to the VT
21review mode. In review mode, the arrow keys permit to browse in the VT content,
22page up/down keys go at the top/bottom of the screen, and the home key goes back
23to the cursor, hence providing very basic screen reviewing facility.
24
25Sound feedback can be obtained by adding the braille_console.sound=1 kernel
26parameter.
27
28For simplicity, only one braille console can be enabled, other uses of
29console=brl,... will be discarded. Also note that it does not interfere with
30the console selection mecanism described in serial-console.txt
31
32For now, only the VisioBraille device is supported.
33
34Samuel Thibault <samuel.thibault@ens-lyon.org>
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 599fe55bf297..3c35d452b1a9 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -138,6 +138,24 @@ Who: Kay Sievers <kay.sievers@suse.de>
138 138
139--------------------------- 139---------------------------
140 140
141What: find_task_by_pid
142When: 2.6.26
143Why: With pid namespaces, calling this funciton will return the
144 wrong task when called from inside a namespace.
145
146 The best way to save a task pid and find a task by this
147 pid later, is to find this task's struct pid pointer (or get
148 it directly from the task) and call pid_task() later.
149
150 If someone really needs to get a task by its pid_t, then
151 he most likely needs the find_task_by_vpid() to get the
152 task from the same namespace as the current task is in, but
153 this may be not so in general.
154
155Who: Pavel Emelyanov <xemul@openvz.org>
156
157---------------------------
158
141What: ACPI procfs interface 159What: ACPI procfs interface
142When: July 2008 160When: July 2008
143Why: ACPI sysfs conversion should be finished by January 2008. 161Why: ACPI sysfs conversion should be finished by January 2008.
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 2a99116edc47..dbc3c6a3650f 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -463,11 +463,17 @@ SwapTotal: 0 kB
463SwapFree: 0 kB 463SwapFree: 0 kB
464Dirty: 968 kB 464Dirty: 968 kB
465Writeback: 0 kB 465Writeback: 0 kB
466AnonPages: 861800 kB
466Mapped: 280372 kB 467Mapped: 280372 kB
467Slab: 684068 kB 468Slab: 284364 kB
469SReclaimable: 159856 kB
470SUnreclaim: 124508 kB
471PageTables: 24448 kB
472NFS_Unstable: 0 kB
473Bounce: 0 kB
474WritebackTmp: 0 kB
468CommitLimit: 7669796 kB 475CommitLimit: 7669796 kB
469Committed_AS: 100056 kB 476Committed_AS: 100056 kB
470PageTables: 24448 kB
471VmallocTotal: 112216 kB 477VmallocTotal: 112216 kB
472VmallocUsed: 428 kB 478VmallocUsed: 428 kB
473VmallocChunk: 111088 kB 479VmallocChunk: 111088 kB
@@ -503,8 +509,17 @@ VmallocChunk: 111088 kB
503 on the disk 509 on the disk
504 Dirty: Memory which is waiting to get written back to the disk 510 Dirty: Memory which is waiting to get written back to the disk
505 Writeback: Memory which is actively being written back to the disk 511 Writeback: Memory which is actively being written back to the disk
512 AnonPages: Non-file backed pages mapped into userspace page tables
506 Mapped: files which have been mmaped, such as libraries 513 Mapped: files which have been mmaped, such as libraries
507 Slab: in-kernel data structures cache 514 Slab: in-kernel data structures cache
515SReclaimable: Part of Slab, that might be reclaimed, such as caches
516 SUnreclaim: Part of Slab, that cannot be reclaimed on memory pressure
517 PageTables: amount of memory dedicated to the lowest level of page
518 tables.
519NFS_Unstable: NFS pages sent to the server, but not yet committed to stable
520 storage
521 Bounce: Memory used for block device "bounce buffers"
522WritebackTmp: Memory used by FUSE for temporary writeback buffers
508 CommitLimit: Based on the overcommit ratio ('vm.overcommit_ratio'), 523 CommitLimit: Based on the overcommit ratio ('vm.overcommit_ratio'),
509 this is the total amount of memory currently available to 524 this is the total amount of memory currently available to
510 be allocated on the system. This limit is only adhered to 525 be allocated on the system. This limit is only adhered to
@@ -531,8 +546,6 @@ Committed_AS: The amount of memory presently allocated on the system.
531 above) will not be permitted. This is useful if one needs 546 above) will not be permitted. This is useful if one needs
532 to guarantee that processes will not fail due to lack of 547 to guarantee that processes will not fail due to lack of
533 memory once that memory has been successfully allocated. 548 memory once that memory has been successfully allocated.
534 PageTables: amount of memory dedicated to the lowest level of page
535 tables.
536VmallocTotal: total size of vmalloc memory area 549VmallocTotal: total size of vmalloc memory area
537 VmallocUsed: amount of vmalloc area which is used 550 VmallocUsed: amount of vmalloc area which is used
538VmallocChunk: largest contigious block of vmalloc area which is free 551VmallocChunk: largest contigious block of vmalloc area which is free
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 3ce193f86565..a3c35446e755 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -496,6 +496,11 @@ and is between 256 and 4096 characters. It is defined in the file
496 switching to the matching ttyS device later. The 496 switching to the matching ttyS device later. The
497 options are the same as for ttyS, above. 497 options are the same as for ttyS, above.
498 498
499 If the device connected to the port is not a TTY but a braille
500 device, prepend "brl," before the device type, for instance
501 console=brl,ttyS0
502 For now, only VisioBraille is supported.
503
499 earlycon= [KNL] Output early console device and options. 504 earlycon= [KNL] Output early console device and options.
500 uart[8250],io,<addr>[,options] 505 uart[8250],io,<addr>[,options]
501 uart[8250],mmio,<addr>[,options] 506 uart[8250],mmio,<addr>[,options]
@@ -556,6 +561,8 @@ and is between 256 and 4096 characters. It is defined in the file
556 1 will print _a lot_ more information - normally 561 1 will print _a lot_ more information - normally
557 only useful to kernel developers. 562 only useful to kernel developers.
558 563
564 debug_objects [KNL] Enable object debugging
565
559 decnet.addr= [HW,NET] 566 decnet.addr= [HW,NET]
560 Format: <area>[,<node>] 567 Format: <area>[,<node>]
561 See also Documentation/networking/decnet.txt. 568 See also Documentation/networking/decnet.txt.
diff --git a/Documentation/powerpc/mpc52xx-device-tree-bindings.txt b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt
index 5e03610e186f..cda7a7dffa6d 100644
--- a/Documentation/powerpc/mpc52xx-device-tree-bindings.txt
+++ b/Documentation/powerpc/mpc52xx-device-tree-bindings.txt
@@ -186,6 +186,12 @@ Recommended soc5200 child nodes; populate as needed for your board
186name device_type compatible Description 186name device_type compatible Description
187---- ----------- ---------- ----------- 187---- ----------- ---------- -----------
188gpt@<addr> gpt fsl,mpc5200-gpt General purpose timers 188gpt@<addr> gpt fsl,mpc5200-gpt General purpose timers
189gpt@<addr> gpt fsl,mpc5200-gpt-gpio General purpose
190 timers in GPIO mode
191gpio@<addr> fsl,mpc5200-gpio MPC5200 simple gpio
192 controller
193gpio@<addr> fsl,mpc5200-gpio-wkup MPC5200 wakeup gpio
194 controller
189rtc@<addr> rtc mpc5200-rtc Real time clock 195rtc@<addr> rtc mpc5200-rtc Real time clock
190mscan@<addr> mscan mpc5200-mscan CAN bus controller 196mscan@<addr> mscan mpc5200-mscan CAN bus controller
191pci@<addr> pci mpc5200-pci PCI bridge 197pci@<addr> pci mpc5200-pci PCI bridge
@@ -225,6 +231,12 @@ PSC in i2s mode: The mpc5200 and mpc5200b PSCs are not compatible when in
225i2s mode. An 'mpc5200b-psc-i2s' node cannot include 'mpc5200-psc-i2s' in the 231i2s mode. An 'mpc5200b-psc-i2s' node cannot include 'mpc5200-psc-i2s' in the
226compatible field. 232compatible field.
227 233
2347) GPIO controller nodes
235Each GPIO controller node should have the empty property gpio-controller and
236#gpio-cells set to 2. First cell is the GPIO number which is interpreted
237according to the bit numbers in the GPIO control registers. The second cell
238is for flags which is currently unsused.
239
228IV - Extra Notes 240IV - Extra Notes
229================ 241================
230 242
diff --git a/MAINTAINERS b/MAINTAINERS
index bca09ed77029..f8d6de111479 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1039,7 +1039,7 @@ P: Urs Thuermann
1039M: urs.thuermann@volkswagen.de 1039M: urs.thuermann@volkswagen.de
1040P: Oliver Hartkopp 1040P: Oliver Hartkopp
1041M: oliver.hartkopp@volkswagen.de 1041M: oliver.hartkopp@volkswagen.de
1042L: socketcan-core@lists.berlios.de 1042L: socketcan-core@lists.berlios.de (subscribers-only)
1043W: http://developer.berlios.de/projects/socketcan/ 1043W: http://developer.berlios.de/projects/socketcan/
1044S: Maintained 1044S: Maintained
1045 1045
@@ -2759,7 +2759,7 @@ M: rubini@ipvvis.unipv.it
2759L: linux-kernel@vger.kernel.org 2759L: linux-kernel@vger.kernel.org
2760S: Maintained 2760S: Maintained
2761 2761
2762MOXA SMARTIO/INDUSTIO SERIAL CARD (MXSER 2.0) 2762MOXA SMARTIO/INDUSTIO/INTELLIO SERIAL CARD
2763P: Jiri Slaby 2763P: Jiri Slaby
2764M: jirislaby@gmail.com 2764M: jirislaby@gmail.com
2765L: linux-kernel@vger.kernel.org 2765L: linux-kernel@vger.kernel.org
@@ -3577,6 +3577,13 @@ M: pfg@sgi.com
3577L: linux-ia64@vger.kernel.org 3577L: linux-ia64@vger.kernel.org
3578S: Supported 3578S: Supported
3579 3579
3580SFC NETWORK DRIVER
3581P: Steve Hodgson
3582P: Ben Hutchings
3583P: Robert Stonehouse
3584M: linux-net-drivers@solarflare.com
3585S: Supported
3586
3580SGI VISUAL WORKSTATION 320 AND 540 3587SGI VISUAL WORKSTATION 320 AND 540
3581P: Andrey Panin 3588P: Andrey Panin
3582M: pazke@donpac.ru 3589M: pazke@donpac.ru
@@ -3743,42 +3750,6 @@ M: chrisw@sous-sol.org
3743L: stable@kernel.org 3750L: stable@kernel.org
3744S: Maintained 3751S: Maintained
3745 3752
3746TPM DEVICE DRIVER
3747P: Kylene Hall
3748M: tpmdd-devel@lists.sourceforge.net
3749W: http://tpmdd.sourceforge.net
3750P: Marcel Selhorst
3751M: tpm@selhorst.net
3752W: http://www.prosec.rub.de/tpm/
3753L: tpmdd-devel@lists.sourceforge.net
3754S: Maintained
3755
3756Telecom Clock Driver for MCPL0010
3757P: Mark Gross
3758M: mark.gross@intel.com
3759S: Supported
3760
3761TENSILICA XTENSA PORT (xtensa):
3762P: Chris Zankel
3763M: chris@zankel.net
3764S: Maintained
3765
3766THINKPAD ACPI EXTRAS DRIVER
3767P: Henrique de Moraes Holschuh
3768M: ibm-acpi@hmh.eng.br
3769L: ibm-acpi-devel@lists.sourceforge.net
3770W: http://ibm-acpi.sourceforge.net
3771W: http://thinkwiki.org/wiki/Ibm-acpi
3772T: git repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git
3773S: Maintained
3774
3775UltraSPARC (sparc64):
3776P: David S. Miller
3777M: davem@davemloft.net
3778L: sparclinux@vger.kernel.org
3779T: git kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.git
3780S: Maintained
3781
3782SHARP LH SUPPORT (LH7952X & LH7A40X) 3753SHARP LH SUPPORT (LH7952X & LH7A40X)
3783P: Marc Singer 3754P: Marc Singer
3784M: elf@buici.com 3755M: elf@buici.com
@@ -3875,6 +3846,12 @@ P: Christoph Hellwig
3875M: hch@infradead.org 3846M: hch@infradead.org
3876S: Maintained 3847S: Maintained
3877 3848
3849TASKSTATS STATISTICS INTERFACE
3850P: Shailabh Nagar
3851M: nagar@watson.ibm.com
3852L: linux-kernel@vger.kernel.org
3853S: Maintained
3854
3878TC CLASSIFIER 3855TC CLASSIFIER
3879P: Jamal Hadi Salim 3856P: Jamal Hadi Salim
3880M: hadi@cyberus.ca 3857M: hadi@cyberus.ca
@@ -3897,6 +3874,25 @@ M: andy@greyhouse.net
3897L: netdev@vger.kernel.org 3874L: netdev@vger.kernel.org
3898S: Supported 3875S: Supported
3899 3876
3877Telecom Clock Driver for MCPL0010
3878P: Mark Gross
3879M: mark.gross@intel.com
3880S: Supported
3881
3882TENSILICA XTENSA PORT (xtensa):
3883P: Chris Zankel
3884M: chris@zankel.net
3885S: Maintained
3886
3887THINKPAD ACPI EXTRAS DRIVER
3888P: Henrique de Moraes Holschuh
3889M: ibm-acpi@hmh.eng.br
3890L: ibm-acpi-devel@lists.sourceforge.net
3891W: http://ibm-acpi.sourceforge.net
3892W: http://thinkwiki.org/wiki/Ibm-acpi
3893T: git repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git
3894S: Maintained
3895
3900TI FLASH MEDIA INTERFACE DRIVER 3896TI FLASH MEDIA INTERFACE DRIVER
3901P: Alex Dubov 3897P: Alex Dubov
3902M: oakad@yahoo.com 3898M: oakad@yahoo.com
@@ -3914,12 +3910,6 @@ P: Deepak Saxena
3914M: dsaxena@plexity.net 3910M: dsaxena@plexity.net
3915S: Maintained 3911S: Maintained
3916 3912
3917TASKSTATS STATISTICS INTERFACE
3918P: Shailabh Nagar
3919M: nagar@watson.ibm.com
3920L: linux-kernel@vger.kernel.org
3921S: Maintained
3922
3923TIPC NETWORK LAYER 3913TIPC NETWORK LAYER
3924P: Per Liden 3914P: Per Liden
3925M: per.liden@ericsson.com 3915M: per.liden@ericsson.com
@@ -3953,6 +3943,16 @@ L: tlinux-users@tce.toshiba-dme.co.jp
3953W: http://www.buzzard.org.uk/toshiba/ 3943W: http://www.buzzard.org.uk/toshiba/
3954S: Maintained 3944S: Maintained
3955 3945
3946TPM DEVICE DRIVER
3947P: Kylene Hall
3948M: tpmdd-devel@lists.sourceforge.net
3949W: http://tpmdd.sourceforge.net
3950P: Marcel Selhorst
3951M: tpm@selhorst.net
3952W: http://www.prosec.rub.de/tpm/
3953L: tpmdd-devel@lists.sourceforge.net
3954S: Maintained
3955
3956TRIDENT 4DWAVE/SIS 7018 PCI AUDIO CORE 3956TRIDENT 4DWAVE/SIS 7018 PCI AUDIO CORE
3957P: Muli Ben-Yehuda 3957P: Muli Ben-Yehuda
3958M: mulix@mulix.org 3958M: mulix@mulix.org
@@ -3965,6 +3965,12 @@ M: trivial@kernel.org
3965L: linux-kernel@vger.kernel.org 3965L: linux-kernel@vger.kernel.org
3966S: Maintained 3966S: Maintained
3967 3967
3968TTY LAYER
3969P: Alan Cox
3970M: alan@lxorguk.ukuu.org.uk
3971L: linux-kernel@vger.kernel.org
3972S: Maintained
3973
3968TULIP NETWORK DRIVERS 3974TULIP NETWORK DRIVERS
3969P: Grant Grundler 3975P: Grant Grundler
3970M: grundler@parisc-linux.org 3976M: grundler@parisc-linux.org
@@ -4133,6 +4139,20 @@ L: linux-usb@vger.kernel.org
4133W: http://www.chello.nl/~j.vreeken/se401/ 4139W: http://www.chello.nl/~j.vreeken/se401/
4134S: Maintained 4140S: Maintained
4135 4141
4142USB SERIAL BELKIN F5U103 DRIVER
4143P: William Greathouse
4144M: wgreathouse@smva.com
4145L: linux-usb@vger.kernel.org
4146S: Maintained
4147
4148USB SERIAL CYPRESS M8 DRIVER
4149P: Lonnie Mendez
4150M: dignome@gmail.com
4151L: linux-usb@vger.kernel.org
4152S: Maintained
4153W: http://geocities.com/i0xox0i
4154W: http://firstlight.net/cvs
4155
4136USB SERIAL CYBERJACK DRIVER 4156USB SERIAL CYBERJACK DRIVER
4137P: Matthias Bruestle and Harald Welte 4157P: Matthias Bruestle and Harald Welte
4138M: support@reiner-sct.com 4158M: support@reiner-sct.com
@@ -4152,20 +4172,6 @@ M: gregkh@suse.de
4152L: linux-usb@vger.kernel.org 4172L: linux-usb@vger.kernel.org
4153S: Supported 4173S: Supported
4154 4174
4155USB SERIAL BELKIN F5U103 DRIVER
4156P: William Greathouse
4157M: wgreathouse@smva.com
4158L: linux-usb@vger.kernel.org
4159S: Maintained
4160
4161USB SERIAL CYPRESS M8 DRIVER
4162P: Lonnie Mendez
4163M: dignome@gmail.com
4164L: linux-usb@vger.kernel.org
4165S: Maintained
4166W: http://geocities.com/i0xox0i
4167W: http://firstlight.net/cvs
4168
4169USB SERIAL EMPEG EMPEG-CAR MARK I/II DRIVER 4175USB SERIAL EMPEG EMPEG-CAR MARK I/II DRIVER
4170P: Gary Brubaker 4176P: Gary Brubaker
4171M: xavyer@ix.netcom.com 4177M: xavyer@ix.netcom.com
@@ -4268,7 +4274,7 @@ M: gregkh@suse.de
4268L: linux-kernel@vger.kernel.org 4274L: linux-kernel@vger.kernel.org
4269S: Maintained 4275S: Maintained
4270 4276
4271FAT/VFAT/MSDOS FILESYSTEM: 4277VFAT/FAT/MSDOS FILESYSTEM:
4272P: OGAWA Hirofumi 4278P: OGAWA Hirofumi
4273M: hirofumi@mail.parknet.co.jp 4279M: hirofumi@mail.parknet.co.jp
4274L: linux-kernel@vger.kernel.org 4280L: linux-kernel@vger.kernel.org
@@ -4313,6 +4319,13 @@ M: dushistov@mail.ru
4313L: linux-kernel@vger.kernel.org 4319L: linux-kernel@vger.kernel.org
4314S: Maintained 4320S: Maintained
4315 4321
4322UltraSPARC (sparc64):
4323P: David S. Miller
4324M: davem@davemloft.net
4325L: sparclinux@vger.kernel.org
4326T: git kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.git
4327S: Maintained
4328
4316USB DIAMOND RIO500 DRIVER 4329USB DIAMOND RIO500 DRIVER
4317P: Cesar Miquel 4330P: Cesar Miquel
4318M: miquel@df.uba.ar 4331M: miquel@df.uba.ar
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_npe.c b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
index 83c137ec582c..63a23fa4aab4 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_npe.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_npe.c
@@ -448,7 +448,9 @@ int npe_send_message(struct npe *npe, const void *msg, const char *what)
448 return -ETIMEDOUT; 448 return -ETIMEDOUT;
449 } 449 }
450 450
451#if DEBUG_MSG > 1
451 debug_msg(npe, "Sending a message took %i cycles\n", cycles); 452 debug_msg(npe, "Sending a message took %i cycles\n", cycles);
453#endif
452 return 0; 454 return 0;
453} 455}
454 456
@@ -484,7 +486,9 @@ int npe_recv_message(struct npe *npe, void *msg, const char *what)
484 return -ETIMEDOUT; 486 return -ETIMEDOUT;
485 } 487 }
486 488
489#if DEBUG_MSG > 1
487 debug_msg(npe, "Receiving a message took %i cycles\n", cycles); 490 debug_msg(npe, "Receiving a message took %i cycles\n", cycles);
491#endif
488 return 0; 492 return 0;
489} 493}
490 494
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
index e83301325301..fab94eaecee7 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
@@ -184,6 +184,8 @@ void qmgr_release_queue(unsigned int queue)
184 case 3: mask[0] = 0xFF; break; 184 case 3: mask[0] = 0xFF; break;
185 } 185 }
186 186
187 mask[1] = mask[2] = mask[3] = 0;
188
187 while (addr--) 189 while (addr--)
188 shift_mask(mask); 190 shift_mask(mask);
189 191
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 331f29b2d0cd..44617938f3f1 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -90,11 +90,6 @@ static struct map_desc standard_io_desc[] __initdata = {
90 .pfn = __phys_to_pfn(0x40000000), 90 .pfn = __phys_to_pfn(0x40000000),
91 .length = 0x02000000, 91 .length = 0x02000000,
92 .type = MT_DEVICE 92 .type = MT_DEVICE
93 }, { /* LCD */
94 .virtual = 0xf4000000,
95 .pfn = __phys_to_pfn(0x44000000),
96 .length = 0x00100000,
97 .type = MT_DEVICE
98 }, { /* Mem Ctl */ 93 }, { /* Mem Ctl */
99 .virtual = 0xf6000000, 94 .virtual = 0xf6000000,
100 .pfn = __phys_to_pfn(0x48000000), 95 .pfn = __phys_to_pfn(0x48000000),
diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
index 03396063b561..530654474bb2 100644
--- a/arch/arm/mach-pxa/littleton.c
+++ b/arch/arm/mach-pxa/littleton.c
@@ -301,8 +301,7 @@ static struct pxafb_mode_info tpo_tdo24mtea1_modes[] = {
301static struct pxafb_mach_info littleton_lcd_info = { 301static struct pxafb_mach_info littleton_lcd_info = {
302 .modes = tpo_tdo24mtea1_modes, 302 .modes = tpo_tdo24mtea1_modes,
303 .num_modes = 2, 303 .num_modes = 2,
304 .lccr0 = LCCR0_Act, 304 .lcd_conn = LCD_COLOR_TFT_16BPP,
305 .lccr3 = LCCR3_HSP | LCCR3_VSP,
306 .pxafb_lcd_power = littleton_lcd_power, 305 .pxafb_lcd_power = littleton_lcd_power,
307}; 306};
308 307
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index ca209c443f34..0993f4d1a0bc 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -395,8 +395,8 @@ static struct pxafb_mach_info sharp_lm8v31 = {
395 .num_modes = 1, 395 .num_modes = 1,
396 .cmap_inverse = 0, 396 .cmap_inverse = 0,
397 .cmap_static = 0, 397 .cmap_static = 0,
398 .lccr0 = LCCR0_SDS, 398 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
399 .lccr3 = LCCR3_PCP | LCCR3_Acb(255), 399 LCD_AC_BIAS_FREQ(255);
400}; 400};
401 401
402#define MMC_POLL_RATE msecs_to_jiffies(1000) 402#define MMC_POLL_RATE msecs_to_jiffies(1000)
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 18d47cfa2a18..7399fb34da4e 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -434,8 +434,7 @@ static struct pxafb_mode_info toshiba_ltm035a776c_mode = {
434 434
435static struct pxafb_mach_info mainstone_pxafb_info = { 435static struct pxafb_mach_info mainstone_pxafb_info = {
436 .num_modes = 1, 436 .num_modes = 1,
437 .lccr0 = LCCR0_Act, 437 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
438 .lccr3 = LCCR3_PCP,
439}; 438};
440 439
441static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data) 440static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data)
diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index dbb546216be1..4a0028087ea6 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -97,8 +97,7 @@ static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
97 97
98static struct pxafb_mach_info zylonite_toshiba_lcd_info = { 98static struct pxafb_mach_info zylonite_toshiba_lcd_info = {
99 .num_modes = 1, 99 .num_modes = 1,
100 .lccr0 = LCCR0_Act, 100 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
101 .lccr3 = LCCR3_PCP,
102 .pxafb_backlight_power = zylonite_backlight_power, 101 .pxafb_backlight_power = zylonite_backlight_power,
103}; 102};
104 103
@@ -134,8 +133,7 @@ static struct pxafb_mode_info sharp_ls037_modes[] = {
134static struct pxafb_mach_info zylonite_sharp_lcd_info = { 133static struct pxafb_mach_info zylonite_sharp_lcd_info = {
135 .modes = sharp_ls037_modes, 134 .modes = sharp_ls037_modes,
136 .num_modes = 2, 135 .num_modes = 2,
137 .lccr0 = LCCR0_Act, 136 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
138 .lccr3 = LCCR3_PCP | LCCR3_HSP | LCCR3_VSP,
139 .pxafb_backlight_power = zylonite_backlight_power, 137 .pxafb_backlight_power = zylonite_backlight_power,
140}; 138};
141 139
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index eb0c32a85fd7..23cafc80d2a4 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -210,21 +210,23 @@ static void do_softint(struct work_struct *private_)
210 printk(KERN_ERR "simserial: do_softint called\n"); 210 printk(KERN_ERR "simserial: do_softint called\n");
211} 211}
212 212
213static void rs_put_char(struct tty_struct *tty, unsigned char ch) 213static int rs_put_char(struct tty_struct *tty, unsigned char ch)
214{ 214{
215 struct async_struct *info = (struct async_struct *)tty->driver_data; 215 struct async_struct *info = (struct async_struct *)tty->driver_data;
216 unsigned long flags; 216 unsigned long flags;
217 217
218 if (!tty || !info->xmit.buf) return; 218 if (!tty || !info->xmit.buf)
219 return 0;
219 220
220 local_irq_save(flags); 221 local_irq_save(flags);
221 if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) { 222 if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) {
222 local_irq_restore(flags); 223 local_irq_restore(flags);
223 return; 224 return 0;
224 } 225 }
225 info->xmit.buf[info->xmit.head] = ch; 226 info->xmit.buf[info->xmit.head] = ch;
226 info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1); 227 info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1);
227 local_irq_restore(flags); 228 local_irq_restore(flags);
229 return 1;
228} 230}
229 231
230static void transmit_chars(struct async_struct *info, int *intr_done) 232static void transmit_chars(struct async_struct *info, int *intr_done)
@@ -621,7 +623,8 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
621 * the line discipline to only process XON/XOFF characters. 623 * the line discipline to only process XON/XOFF characters.
622 */ 624 */
623 shutdown(info); 625 shutdown(info);
624 if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty); 626 if (tty->ops->flush_buffer)
627 tty->ops->flush_buffer(tty);
625 if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty); 628 if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty);
626 info->event = 0; 629 info->event = 0;
627 info->tty = NULL; 630 info->tty = NULL;
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index a5ea817cbcbf..58dcfac5ea88 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -183,7 +183,7 @@ do_notify_resume_user (sigset_t *unused, struct sigscratch *scr, long in_syscall
183#endif 183#endif
184 184
185 /* deal with pending signal delivery */ 185 /* deal with pending signal delivery */
186 if (test_thread_flag(TIF_SIGPENDING)||test_thread_flag(TIF_RESTORE_SIGMASK)) 186 if (test_thread_flag(TIF_SIGPENDING))
187 ia64_do_signal(scr, in_syscall); 187 ia64_do_signal(scr, in_syscall);
188 188
189 /* copy user rbs to kernel rbs */ 189 /* copy user rbs to kernel rbs */
diff --git a/arch/powerpc/boot/dts/cm5200.dts b/arch/powerpc/boot/dts/cm5200.dts
index c6ca6319e4f7..2f74cc4e093e 100644
--- a/arch/powerpc/boot/dts/cm5200.dts
+++ b/arch/powerpc/boot/dts/cm5200.dts
@@ -10,11 +10,7 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13/* 13/dts-v1/;
14 * WARNING: Do not depend on this tree layout remaining static just yet.
15 * The MPC5200 device tree conventions are still in flux
16 * Keep an eye on the linuxppc-dev mailing list for more details
17 */
18 14
19/ { 15/ {
20 model = "schindler,cm5200"; 16 model = "schindler,cm5200";
@@ -29,10 +25,10 @@
29 PowerPC,5200@0 { 25 PowerPC,5200@0 {
30 device_type = "cpu"; 26 device_type = "cpu";
31 reg = <0>; 27 reg = <0>;
32 d-cache-line-size = <20>; 28 d-cache-line-size = <32>;
33 i-cache-line-size = <20>; 29 i-cache-line-size = <32>;
34 d-cache-size = <4000>; // L1, 16K 30 d-cache-size = <0x4000>; // L1, 16K
35 i-cache-size = <4000>; // L1, 16K 31 i-cache-size = <0x4000>; // L1, 16K
36 timebase-frequency = <0>; // from bootloader 32 timebase-frequency = <0>; // from bootloader
37 bus-frequency = <0>; // from bootloader 33 bus-frequency = <0>; // from bootloader
38 clock-frequency = <0>; // from bootloader 34 clock-frequency = <0>; // from bootloader
@@ -41,34 +37,34 @@
41 37
42 memory { 38 memory {
43 device_type = "memory"; 39 device_type = "memory";
44 reg = <00000000 04000000>; // 64MB 40 reg = <0x00000000 0x04000000>; // 64MB
45 }; 41 };
46 42
47 soc5200@f0000000 { 43 soc5200@f0000000 {
48 #address-cells = <1>; 44 #address-cells = <1>;
49 #size-cells = <1>; 45 #size-cells = <1>;
50 compatible = "fsl,mpc5200b-immr"; 46 compatible = "fsl,mpc5200b-immr";
51 ranges = <0 f0000000 0000c000>; 47 ranges = <0 0xf0000000 0x0000c000>;
52 reg = <f0000000 00000100>; 48 reg = <0xf0000000 0x00000100>;
53 bus-frequency = <0>; // from bootloader 49 bus-frequency = <0>; // from bootloader
54 system-frequency = <0>; // from bootloader 50 system-frequency = <0>; // from bootloader
55 51
56 cdm@200 { 52 cdm@200 {
57 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm"; 53 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
58 reg = <200 38>; 54 reg = <0x200 0x38>;
59 }; 55 };
60 56
61 mpc5200_pic: pic@500 { 57 mpc5200_pic: interrupt-controller@500 {
62 // 5200 interrupts are encoded into two levels; 58 // 5200 interrupts are encoded into two levels;
63 interrupt-controller; 59 interrupt-controller;
64 #interrupt-cells = <3>; 60 #interrupt-cells = <3>;
65 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic"; 61 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
66 reg = <500 80>; 62 reg = <0x500 0x80>;
67 }; 63 };
68 64
69 timer@600 { // General Purpose Timer 65 timer@600 { // General Purpose Timer
70 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 66 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
71 reg = <600 10>; 67 reg = <0x600 0x10>;
72 interrupts = <1 9 0>; 68 interrupts = <1 9 0>;
73 interrupt-parent = <&mpc5200_pic>; 69 interrupt-parent = <&mpc5200_pic>;
74 fsl,has-wdt; 70 fsl,has-wdt;
@@ -76,108 +72,108 @@
76 72
77 timer@610 { // General Purpose Timer 73 timer@610 { // General Purpose Timer
78 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 74 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
79 reg = <610 10>; 75 reg = <0x610 0x10>;
80 interrupts = <1 a 0>; 76 interrupts = <1 10 0>;
81 interrupt-parent = <&mpc5200_pic>; 77 interrupt-parent = <&mpc5200_pic>;
82 }; 78 };
83 79
84 timer@620 { // General Purpose Timer 80 timer@620 { // General Purpose Timer
85 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 81 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
86 reg = <620 10>; 82 reg = <0x620 0x10>;
87 interrupts = <1 b 0>; 83 interrupts = <1 11 0>;
88 interrupt-parent = <&mpc5200_pic>; 84 interrupt-parent = <&mpc5200_pic>;
89 }; 85 };
90 86
91 timer@630 { // General Purpose Timer 87 timer@630 { // General Purpose Timer
92 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 88 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
93 reg = <630 10>; 89 reg = <0x630 0x10>;
94 interrupts = <1 c 0>; 90 interrupts = <1 12 0>;
95 interrupt-parent = <&mpc5200_pic>; 91 interrupt-parent = <&mpc5200_pic>;
96 }; 92 };
97 93
98 timer@640 { // General Purpose Timer 94 timer@640 { // General Purpose Timer
99 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 95 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
100 reg = <640 10>; 96 reg = <0x640 0x10>;
101 interrupts = <1 d 0>; 97 interrupts = <1 13 0>;
102 interrupt-parent = <&mpc5200_pic>; 98 interrupt-parent = <&mpc5200_pic>;
103 }; 99 };
104 100
105 timer@650 { // General Purpose Timer 101 timer@650 { // General Purpose Timer
106 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 102 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
107 reg = <650 10>; 103 reg = <0x650 0x10>;
108 interrupts = <1 e 0>; 104 interrupts = <1 14 0>;
109 interrupt-parent = <&mpc5200_pic>; 105 interrupt-parent = <&mpc5200_pic>;
110 }; 106 };
111 107
112 timer@660 { // General Purpose Timer 108 timer@660 { // General Purpose Timer
113 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 109 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
114 reg = <660 10>; 110 reg = <0x660 0x10>;
115 interrupts = <1 f 0>; 111 interrupts = <1 15 0>;
116 interrupt-parent = <&mpc5200_pic>; 112 interrupt-parent = <&mpc5200_pic>;
117 }; 113 };
118 114
119 timer@670 { // General Purpose Timer 115 timer@670 { // General Purpose Timer
120 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 116 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
121 reg = <670 10>; 117 reg = <0x670 0x10>;
122 interrupts = <1 10 0>; 118 interrupts = <1 16 0>;
123 interrupt-parent = <&mpc5200_pic>; 119 interrupt-parent = <&mpc5200_pic>;
124 }; 120 };
125 121
126 rtc@800 { // Real time clock 122 rtc@800 { // Real time clock
127 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc"; 123 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
128 reg = <800 100>; 124 reg = <0x800 0x100>;
129 interrupts = <1 5 0 1 6 0>; 125 interrupts = <1 5 0 1 6 0>;
130 interrupt-parent = <&mpc5200_pic>; 126 interrupt-parent = <&mpc5200_pic>;
131 }; 127 };
132 128
133 gpio@b00 { 129 gpio@b00 {
134 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio"; 130 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
135 reg = <b00 40>; 131 reg = <0xb00 0x40>;
136 interrupts = <1 7 0>; 132 interrupts = <1 7 0>;
137 interrupt-parent = <&mpc5200_pic>; 133 interrupt-parent = <&mpc5200_pic>;
138 }; 134 };
139 135
140 gpio@c00 { 136 gpio@c00 {
141 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup"; 137 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
142 reg = <c00 40>; 138 reg = <0xc00 0x40>;
143 interrupts = <1 8 0 0 3 0>; 139 interrupts = <1 8 0 0 3 0>;
144 interrupt-parent = <&mpc5200_pic>; 140 interrupt-parent = <&mpc5200_pic>;
145 }; 141 };
146 142
147 spi@f00 { 143 spi@f00 {
148 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 144 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
149 reg = <f00 20>; 145 reg = <0xf00 0x20>;
150 interrupts = <2 d 0 2 e 0>; 146 interrupts = <2 13 0 2 14 0>;
151 interrupt-parent = <&mpc5200_pic>; 147 interrupt-parent = <&mpc5200_pic>;
152 }; 148 };
153 149
154 usb@1000 { 150 usb@1000 {
155 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be"; 151 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
156 reg = <1000 ff>; 152 reg = <0x1000 0xff>;
157 interrupts = <2 6 0>; 153 interrupts = <2 6 0>;
158 interrupt-parent = <&mpc5200_pic>; 154 interrupt-parent = <&mpc5200_pic>;
159 }; 155 };
160 156
161 dma-controller@1200 { 157 dma-controller@1200 {
162 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm"; 158 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
163 reg = <1200 80>; 159 reg = <0x1200 0x80>;
164 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0 160 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
165 3 4 0 3 5 0 3 6 0 3 7 0 161 3 4 0 3 5 0 3 6 0 3 7 0
166 3 8 0 3 9 0 3 a 0 3 b 0 162 3 8 0 3 9 0 3 10 0 3 11 0
167 3 c 0 3 d 0 3 e 0 3 f 0>; 163 3 12 0 3 13 0 3 14 0 3 15 0>;
168 interrupt-parent = <&mpc5200_pic>; 164 interrupt-parent = <&mpc5200_pic>;
169 }; 165 };
170 166
171 xlb@1f00 { 167 xlb@1f00 {
172 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; 168 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
173 reg = <1f00 100>; 169 reg = <0x1f00 0x100>;
174 }; 170 };
175 171
176 serial@2000 { // PSC1 172 serial@2000 { // PSC1
177 device_type = "serial"; 173 device_type = "serial";
178 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 174 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
179 port-number = <0>; // Logical port assignment 175 port-number = <0>; // Logical port assignment
180 reg = <2000 100>; 176 reg = <0x2000 0x100>;
181 interrupts = <2 1 0>; 177 interrupts = <2 1 0>;
182 interrupt-parent = <&mpc5200_pic>; 178 interrupt-parent = <&mpc5200_pic>;
183 }; 179 };
@@ -186,7 +182,7 @@
186 device_type = "serial"; 182 device_type = "serial";
187 compatible = "fsl,mpc5200-psc-uart"; 183 compatible = "fsl,mpc5200-psc-uart";
188 port-number = <1>; // Logical port assignment 184 port-number = <1>; // Logical port assignment
189 reg = <2200 100>; 185 reg = <0x2200 0x100>;
190 interrupts = <2 2 0>; 186 interrupts = <2 2 0>;
191 interrupt-parent = <&mpc5200_pic>; 187 interrupt-parent = <&mpc5200_pic>;
192 }; 188 };
@@ -195,7 +191,7 @@
195 device_type = "serial"; 191 device_type = "serial";
196 compatible = "fsl,mpc5200-psc-uart"; 192 compatible = "fsl,mpc5200-psc-uart";
197 port-number = <2>; // Logical port assignment 193 port-number = <2>; // Logical port assignment
198 reg = <2400 100>; 194 reg = <0x2400 0x100>;
199 interrupts = <2 3 0>; 195 interrupts = <2 3 0>;
200 interrupt-parent = <&mpc5200_pic>; 196 interrupt-parent = <&mpc5200_pic>;
201 }; 197 };
@@ -204,7 +200,7 @@
204 device_type = "serial"; 200 device_type = "serial";
205 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 201 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
206 port-number = <5>; // Logical port assignment 202 port-number = <5>; // Logical port assignment
207 reg = <2c00 100>; 203 reg = <0x2c00 0x100>;
208 interrupts = <2 4 0>; 204 interrupts = <2 4 0>;
209 interrupt-parent = <&mpc5200_pic>; 205 interrupt-parent = <&mpc5200_pic>;
210 }; 206 };
@@ -212,7 +208,7 @@
212 ethernet@3000 { 208 ethernet@3000 {
213 device_type = "network"; 209 device_type = "network";
214 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec"; 210 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
215 reg = <3000 400>; 211 reg = <0x3000 0x400>;
216 local-mac-address = [ 00 00 00 00 00 00 ]; 212 local-mac-address = [ 00 00 00 00 00 00 ];
217 interrupts = <2 5 0>; 213 interrupts = <2 5 0>;
218 interrupt-parent = <&mpc5200_pic>; 214 interrupt-parent = <&mpc5200_pic>;
@@ -223,7 +219,7 @@
223 #address-cells = <1>; 219 #address-cells = <1>;
224 #size-cells = <0>; 220 #size-cells = <0>;
225 compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio"; 221 compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
226 reg = <3000 400>; // fec range, since we need to setup fec interrupts 222 reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
227 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co. 223 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
228 interrupt-parent = <&mpc5200_pic>; 224 interrupt-parent = <&mpc5200_pic>;
229 225
@@ -237,15 +233,15 @@
237 #address-cells = <1>; 233 #address-cells = <1>;
238 #size-cells = <0>; 234 #size-cells = <0>;
239 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; 235 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
240 reg = <3d40 40>; 236 reg = <0x3d40 0x40>;
241 interrupts = <2 10 0>; 237 interrupts = <2 16 0>;
242 interrupt-parent = <&mpc5200_pic>; 238 interrupt-parent = <&mpc5200_pic>;
243 fsl5200-clocking; 239 fsl5200-clocking;
244 }; 240 };
245 241
246 sram@8000 { 242 sram@8000 {
247 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; 243 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
248 reg = <8000 4000>; 244 reg = <0x8000 0x4000>;
249 }; 245 };
250 }; 246 };
251 247
@@ -254,12 +250,12 @@
254 compatible = "fsl,lpb"; 250 compatible = "fsl,lpb";
255 #address-cells = <2>; 251 #address-cells = <2>;
256 #size-cells = <1>; 252 #size-cells = <1>;
257 ranges = <0 0 fc000000 2000000>; 253 ranges = <0 0 0xfc000000 0x2000000>;
258 254
259 // 16-bit flash device at LocalPlus Bus CS0 255 // 16-bit flash device at LocalPlus Bus CS0
260 flash@0,0 { 256 flash@0,0 {
261 compatible = "cfi-flash"; 257 compatible = "cfi-flash";
262 reg = <0 0 2000000>; 258 reg = <0 0 0x2000000>;
263 bank-width = <2>; 259 bank-width = <2>;
264 device-width = <2>; 260 device-width = <2>;
265 #size-cells = <1>; 261 #size-cells = <1>;
diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
index 09b4e16154d6..2cf9a8768f44 100644
--- a/arch/powerpc/boot/dts/lite5200.dts
+++ b/arch/powerpc/boot/dts/lite5200.dts
@@ -10,6 +10,8 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13/dts-v1/;
14
13/ { 15/ {
14 model = "fsl,lite5200"; 16 model = "fsl,lite5200";
15 compatible = "fsl,lite5200"; 17 compatible = "fsl,lite5200";
@@ -23,10 +25,10 @@
23 PowerPC,5200@0 { 25 PowerPC,5200@0 {
24 device_type = "cpu"; 26 device_type = "cpu";
25 reg = <0>; 27 reg = <0>;
26 d-cache-line-size = <20>; 28 d-cache-line-size = <32>;
27 i-cache-line-size = <20>; 29 i-cache-line-size = <32>;
28 d-cache-size = <4000>; // L1, 16K 30 d-cache-size = <0x4000>; // L1, 16K
29 i-cache-size = <4000>; // L1, 16K 31 i-cache-size = <0x4000>; // L1, 16K
30 timebase-frequency = <0>; // from bootloader 32 timebase-frequency = <0>; // from bootloader
31 bus-frequency = <0>; // from bootloader 33 bus-frequency = <0>; // from bootloader
32 clock-frequency = <0>; // from bootloader 34 clock-frequency = <0>; // from bootloader
@@ -35,21 +37,21 @@
35 37
36 memory { 38 memory {
37 device_type = "memory"; 39 device_type = "memory";
38 reg = <00000000 04000000>; // 64MB 40 reg = <0x00000000 0x04000000>; // 64MB
39 }; 41 };
40 42
41 soc5200@f0000000 { 43 soc5200@f0000000 {
42 #address-cells = <1>; 44 #address-cells = <1>;
43 #size-cells = <1>; 45 #size-cells = <1>;
44 compatible = "fsl,mpc5200-immr"; 46 compatible = "fsl,mpc5200-immr";
45 ranges = <0 f0000000 0000c000>; 47 ranges = <0 0xf0000000 0x0000c000>;
46 reg = <f0000000 00000100>; 48 reg = <0xf0000000 0x00000100>;
47 bus-frequency = <0>; // from bootloader 49 bus-frequency = <0>; // from bootloader
48 system-frequency = <0>; // from bootloader 50 system-frequency = <0>; // from bootloader
49 51
50 cdm@200 { 52 cdm@200 {
51 compatible = "fsl,mpc5200-cdm"; 53 compatible = "fsl,mpc5200-cdm";
52 reg = <200 38>; 54 reg = <0x200 0x38>;
53 }; 55 };
54 56
55 mpc5200_pic: interrupt-controller@500 { 57 mpc5200_pic: interrupt-controller@500 {
@@ -58,13 +60,13 @@
58 #interrupt-cells = <3>; 60 #interrupt-cells = <3>;
59 device_type = "interrupt-controller"; 61 device_type = "interrupt-controller";
60 compatible = "fsl,mpc5200-pic"; 62 compatible = "fsl,mpc5200-pic";
61 reg = <500 80>; 63 reg = <0x500 0x80>;
62 }; 64 };
63 65
64 timer@600 { // General Purpose Timer 66 timer@600 { // General Purpose Timer
65 compatible = "fsl,mpc5200-gpt"; 67 compatible = "fsl,mpc5200-gpt";
66 cell-index = <0>; 68 cell-index = <0>;
67 reg = <600 10>; 69 reg = <0x600 0x10>;
68 interrupts = <1 9 0>; 70 interrupts = <1 9 0>;
69 interrupt-parent = <&mpc5200_pic>; 71 interrupt-parent = <&mpc5200_pic>;
70 fsl,has-wdt; 72 fsl,has-wdt;
@@ -73,63 +75,63 @@
73 timer@610 { // General Purpose Timer 75 timer@610 { // General Purpose Timer
74 compatible = "fsl,mpc5200-gpt"; 76 compatible = "fsl,mpc5200-gpt";
75 cell-index = <1>; 77 cell-index = <1>;
76 reg = <610 10>; 78 reg = <0x610 0x10>;
77 interrupts = <1 a 0>; 79 interrupts = <1 10 0>;
78 interrupt-parent = <&mpc5200_pic>; 80 interrupt-parent = <&mpc5200_pic>;
79 }; 81 };
80 82
81 timer@620 { // General Purpose Timer 83 timer@620 { // General Purpose Timer
82 compatible = "fsl,mpc5200-gpt"; 84 compatible = "fsl,mpc5200-gpt";
83 cell-index = <2>; 85 cell-index = <2>;
84 reg = <620 10>; 86 reg = <0x620 0x10>;
85 interrupts = <1 b 0>; 87 interrupts = <1 11 0>;
86 interrupt-parent = <&mpc5200_pic>; 88 interrupt-parent = <&mpc5200_pic>;
87 }; 89 };
88 90
89 timer@630 { // General Purpose Timer 91 timer@630 { // General Purpose Timer
90 compatible = "fsl,mpc5200-gpt"; 92 compatible = "fsl,mpc5200-gpt";
91 cell-index = <3>; 93 cell-index = <3>;
92 reg = <630 10>; 94 reg = <0x630 0x10>;
93 interrupts = <1 c 0>; 95 interrupts = <1 12 0>;
94 interrupt-parent = <&mpc5200_pic>; 96 interrupt-parent = <&mpc5200_pic>;
95 }; 97 };
96 98
97 timer@640 { // General Purpose Timer 99 timer@640 { // General Purpose Timer
98 compatible = "fsl,mpc5200-gpt"; 100 compatible = "fsl,mpc5200-gpt";
99 cell-index = <4>; 101 cell-index = <4>;
100 reg = <640 10>; 102 reg = <0x640 0x10>;
101 interrupts = <1 d 0>; 103 interrupts = <1 13 0>;
102 interrupt-parent = <&mpc5200_pic>; 104 interrupt-parent = <&mpc5200_pic>;
103 }; 105 };
104 106
105 timer@650 { // General Purpose Timer 107 timer@650 { // General Purpose Timer
106 compatible = "fsl,mpc5200-gpt"; 108 compatible = "fsl,mpc5200-gpt";
107 cell-index = <5>; 109 cell-index = <5>;
108 reg = <650 10>; 110 reg = <0x650 0x10>;
109 interrupts = <1 e 0>; 111 interrupts = <1 14 0>;
110 interrupt-parent = <&mpc5200_pic>; 112 interrupt-parent = <&mpc5200_pic>;
111 }; 113 };
112 114
113 timer@660 { // General Purpose Timer 115 timer@660 { // General Purpose Timer
114 compatible = "fsl,mpc5200-gpt"; 116 compatible = "fsl,mpc5200-gpt";
115 cell-index = <6>; 117 cell-index = <6>;
116 reg = <660 10>; 118 reg = <0x660 0x10>;
117 interrupts = <1 f 0>; 119 interrupts = <1 15 0>;
118 interrupt-parent = <&mpc5200_pic>; 120 interrupt-parent = <&mpc5200_pic>;
119 }; 121 };
120 122
121 timer@670 { // General Purpose Timer 123 timer@670 { // General Purpose Timer
122 compatible = "fsl,mpc5200-gpt"; 124 compatible = "fsl,mpc5200-gpt";
123 cell-index = <7>; 125 cell-index = <7>;
124 reg = <670 10>; 126 reg = <0x670 0x10>;
125 interrupts = <1 10 0>; 127 interrupts = <1 16 0>;
126 interrupt-parent = <&mpc5200_pic>; 128 interrupt-parent = <&mpc5200_pic>;
127 }; 129 };
128 130
129 rtc@800 { // Real time clock 131 rtc@800 { // Real time clock
130 compatible = "fsl,mpc5200-rtc"; 132 compatible = "fsl,mpc5200-rtc";
131 device_type = "rtc"; 133 device_type = "rtc";
132 reg = <800 100>; 134 reg = <0x800 0x100>;
133 interrupts = <1 5 0 1 6 0>; 135 interrupts = <1 5 0 1 6 0>;
134 interrupt-parent = <&mpc5200_pic>; 136 interrupt-parent = <&mpc5200_pic>;
135 }; 137 };
@@ -137,43 +139,43 @@
137 can@900 { 139 can@900 {
138 compatible = "fsl,mpc5200-mscan"; 140 compatible = "fsl,mpc5200-mscan";
139 cell-index = <0>; 141 cell-index = <0>;
140 interrupts = <2 11 0>; 142 interrupts = <2 17 0>;
141 interrupt-parent = <&mpc5200_pic>; 143 interrupt-parent = <&mpc5200_pic>;
142 reg = <900 80>; 144 reg = <0x900 0x80>;
143 }; 145 };
144 146
145 can@980 { 147 can@980 {
146 compatible = "fsl,mpc5200-mscan"; 148 compatible = "fsl,mpc5200-mscan";
147 cell-index = <1>; 149 cell-index = <1>;
148 interrupts = <2 12 0>; 150 interrupts = <2 18 0>;
149 interrupt-parent = <&mpc5200_pic>; 151 interrupt-parent = <&mpc5200_pic>;
150 reg = <980 80>; 152 reg = <0x980 0x80>;
151 }; 153 };
152 154
153 gpio@b00 { 155 gpio@b00 {
154 compatible = "fsl,mpc5200-gpio"; 156 compatible = "fsl,mpc5200-gpio";
155 reg = <b00 40>; 157 reg = <0xb00 0x40>;
156 interrupts = <1 7 0>; 158 interrupts = <1 7 0>;
157 interrupt-parent = <&mpc5200_pic>; 159 interrupt-parent = <&mpc5200_pic>;
158 }; 160 };
159 161
160 gpio@c00 { 162 gpio@c00 {
161 compatible = "fsl,mpc5200-gpio-wkup"; 163 compatible = "fsl,mpc5200-gpio-wkup";
162 reg = <c00 40>; 164 reg = <0xc00 0x40>;
163 interrupts = <1 8 0 0 3 0>; 165 interrupts = <1 8 0 0 3 0>;
164 interrupt-parent = <&mpc5200_pic>; 166 interrupt-parent = <&mpc5200_pic>;
165 }; 167 };
166 168
167 spi@f00 { 169 spi@f00 {
168 compatible = "fsl,mpc5200-spi"; 170 compatible = "fsl,mpc5200-spi";
169 reg = <f00 20>; 171 reg = <0xf00 0x20>;
170 interrupts = <2 d 0 2 e 0>; 172 interrupts = <2 13 0 2 14 0>;
171 interrupt-parent = <&mpc5200_pic>; 173 interrupt-parent = <&mpc5200_pic>;
172 }; 174 };
173 175
174 usb@1000 { 176 usb@1000 {
175 compatible = "fsl,mpc5200-ohci","ohci-be"; 177 compatible = "fsl,mpc5200-ohci","ohci-be";
176 reg = <1000 ff>; 178 reg = <0x1000 0xff>;
177 interrupts = <2 6 0>; 179 interrupts = <2 6 0>;
178 interrupt-parent = <&mpc5200_pic>; 180 interrupt-parent = <&mpc5200_pic>;
179 }; 181 };
@@ -181,17 +183,17 @@
181 dma-controller@1200 { 183 dma-controller@1200 {
182 device_type = "dma-controller"; 184 device_type = "dma-controller";
183 compatible = "fsl,mpc5200-bestcomm"; 185 compatible = "fsl,mpc5200-bestcomm";
184 reg = <1200 80>; 186 reg = <0x1200 0x80>;
185 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0 187 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
186 3 4 0 3 5 0 3 6 0 3 7 0 188 3 4 0 3 5 0 3 6 0 3 7 0
187 3 8 0 3 9 0 3 a 0 3 b 0 189 3 8 0 3 9 0 3 10 0 3 11 0
188 3 c 0 3 d 0 3 e 0 3 f 0>; 190 3 12 0 3 13 0 3 14 0 3 15 0>;
189 interrupt-parent = <&mpc5200_pic>; 191 interrupt-parent = <&mpc5200_pic>;
190 }; 192 };
191 193
192 xlb@1f00 { 194 xlb@1f00 {
193 compatible = "fsl,mpc5200-xlb"; 195 compatible = "fsl,mpc5200-xlb";
194 reg = <1f00 100>; 196 reg = <0x1f00 0x100>;
195 }; 197 };
196 198
197 serial@2000 { // PSC1 199 serial@2000 { // PSC1
@@ -199,7 +201,7 @@
199 compatible = "fsl,mpc5200-psc-uart"; 201 compatible = "fsl,mpc5200-psc-uart";
200 port-number = <0>; // Logical port assignment 202 port-number = <0>; // Logical port assignment
201 cell-index = <0>; 203 cell-index = <0>;
202 reg = <2000 100>; 204 reg = <0x2000 0x100>;
203 interrupts = <2 1 0>; 205 interrupts = <2 1 0>;
204 interrupt-parent = <&mpc5200_pic>; 206 interrupt-parent = <&mpc5200_pic>;
205 }; 207 };
@@ -208,7 +210,7 @@
208 //ac97@2200 { // PSC2 210 //ac97@2200 { // PSC2
209 // compatible = "fsl,mpc5200-psc-ac97"; 211 // compatible = "fsl,mpc5200-psc-ac97";
210 // cell-index = <1>; 212 // cell-index = <1>;
211 // reg = <2200 100>; 213 // reg = <0x2200 0x100>;
212 // interrupts = <2 2 0>; 214 // interrupts = <2 2 0>;
213 // interrupt-parent = <&mpc5200_pic>; 215 // interrupt-parent = <&mpc5200_pic>;
214 //}; 216 //};
@@ -217,7 +219,7 @@
217 //i2s@2400 { // PSC3 219 //i2s@2400 { // PSC3
218 // compatible = "fsl,mpc5200-psc-i2s"; 220 // compatible = "fsl,mpc5200-psc-i2s";
219 // cell-index = <2>; 221 // cell-index = <2>;
220 // reg = <2400 100>; 222 // reg = <0x2400 0x100>;
221 // interrupts = <2 3 0>; 223 // interrupts = <2 3 0>;
222 // interrupt-parent = <&mpc5200_pic>; 224 // interrupt-parent = <&mpc5200_pic>;
223 //}; 225 //};
@@ -227,8 +229,8 @@
227 // device_type = "serial"; 229 // device_type = "serial";
228 // compatible = "fsl,mpc5200-psc-uart"; 230 // compatible = "fsl,mpc5200-psc-uart";
229 // cell-index = <3>; 231 // cell-index = <3>;
230 // reg = <2600 100>; 232 // reg = <0x2600 0x100>;
231 // interrupts = <2 b 0>; 233 // interrupts = <2 11 0>;
232 // interrupt-parent = <&mpc5200_pic>; 234 // interrupt-parent = <&mpc5200_pic>;
233 //}; 235 //};
234 236
@@ -237,8 +239,8 @@
237 // device_type = "serial"; 239 // device_type = "serial";
238 // compatible = "fsl,mpc5200-psc-uart"; 240 // compatible = "fsl,mpc5200-psc-uart";
239 // cell-index = <4>; 241 // cell-index = <4>;
240 // reg = <2800 100>; 242 // reg = <0x2800 0x100>;
241 // interrupts = <2 c 0>; 243 // interrupts = <2 12 0>;
242 // interrupt-parent = <&mpc5200_pic>; 244 // interrupt-parent = <&mpc5200_pic>;
243 //}; 245 //};
244 246
@@ -246,7 +248,7 @@
246 //spi@2c00 { // PSC6 248 //spi@2c00 { // PSC6
247 // compatible = "fsl,mpc5200-psc-spi"; 249 // compatible = "fsl,mpc5200-psc-spi";
248 // cell-index = <5>; 250 // cell-index = <5>;
249 // reg = <2c00 100>; 251 // reg = <0x2c00 0x100>;
250 // interrupts = <2 4 0>; 252 // interrupts = <2 4 0>;
251 // interrupt-parent = <&mpc5200_pic>; 253 // interrupt-parent = <&mpc5200_pic>;
252 //}; 254 //};
@@ -254,7 +256,7 @@
254 ethernet@3000 { 256 ethernet@3000 {
255 device_type = "network"; 257 device_type = "network";
256 compatible = "fsl,mpc5200-fec"; 258 compatible = "fsl,mpc5200-fec";
257 reg = <3000 800>; 259 reg = <0x3000 0x400>;
258 local-mac-address = [ 00 00 00 00 00 00 ]; 260 local-mac-address = [ 00 00 00 00 00 00 ];
259 interrupts = <2 5 0>; 261 interrupts = <2 5 0>;
260 interrupt-parent = <&mpc5200_pic>; 262 interrupt-parent = <&mpc5200_pic>;
@@ -265,11 +267,11 @@
265 #address-cells = <1>; 267 #address-cells = <1>;
266 #size-cells = <0>; 268 #size-cells = <0>;
267 compatible = "fsl,mpc5200-mdio"; 269 compatible = "fsl,mpc5200-mdio";
268 reg = <3000 400>; // fec range, since we need to setup fec interrupts 270 reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
269 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co. 271 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
270 interrupt-parent = <&mpc5200_pic>; 272 interrupt-parent = <&mpc5200_pic>;
271 273
272 phy0:ethernet-phy@1 { 274 phy0: ethernet-phy@1 {
273 device_type = "ethernet-phy"; 275 device_type = "ethernet-phy";
274 reg = <1>; 276 reg = <1>;
275 }; 277 };
@@ -278,7 +280,7 @@
278 ata@3a00 { 280 ata@3a00 {
279 device_type = "ata"; 281 device_type = "ata";
280 compatible = "fsl,mpc5200-ata"; 282 compatible = "fsl,mpc5200-ata";
281 reg = <3a00 100>; 283 reg = <0x3a00 0x100>;
282 interrupts = <2 7 0>; 284 interrupts = <2 7 0>;
283 interrupt-parent = <&mpc5200_pic>; 285 interrupt-parent = <&mpc5200_pic>;
284 }; 286 };
@@ -288,8 +290,8 @@
288 #size-cells = <0>; 290 #size-cells = <0>;
289 compatible = "fsl,mpc5200-i2c","fsl-i2c"; 291 compatible = "fsl,mpc5200-i2c","fsl-i2c";
290 cell-index = <0>; 292 cell-index = <0>;
291 reg = <3d00 40>; 293 reg = <0x3d00 0x40>;
292 interrupts = <2 f 0>; 294 interrupts = <2 15 0>;
293 interrupt-parent = <&mpc5200_pic>; 295 interrupt-parent = <&mpc5200_pic>;
294 fsl5200-clocking; 296 fsl5200-clocking;
295 }; 297 };
@@ -299,14 +301,14 @@
299 #size-cells = <0>; 301 #size-cells = <0>;
300 compatible = "fsl,mpc5200-i2c","fsl-i2c"; 302 compatible = "fsl,mpc5200-i2c","fsl-i2c";
301 cell-index = <1>; 303 cell-index = <1>;
302 reg = <3d40 40>; 304 reg = <0x3d40 0x40>;
303 interrupts = <2 10 0>; 305 interrupts = <2 16 0>;
304 interrupt-parent = <&mpc5200_pic>; 306 interrupt-parent = <&mpc5200_pic>;
305 fsl5200-clocking; 307 fsl5200-clocking;
306 }; 308 };
307 sram@8000 { 309 sram@8000 {
308 compatible = "fsl,mpc5200-sram","sram"; 310 compatible = "fsl,mpc5200-sram","sram";
309 reg = <8000 4000>; 311 reg = <0x8000 0x4000>;
310 }; 312 };
311 }; 313 };
312 314
@@ -316,18 +318,18 @@
316 #address-cells = <3>; 318 #address-cells = <3>;
317 device_type = "pci"; 319 device_type = "pci";
318 compatible = "fsl,mpc5200-pci"; 320 compatible = "fsl,mpc5200-pci";
319 reg = <f0000d00 100>; 321 reg = <0xf0000d00 0x100>;
320 interrupt-map-mask = <f800 0 0 7>; 322 interrupt-map-mask = <0xf800 0 0 7>;
321 interrupt-map = <c000 0 0 1 &mpc5200_pic 0 0 3 323 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3
322 c000 0 0 2 &mpc5200_pic 0 0 3 324 0xc000 0 0 2 &mpc5200_pic 0 0 3
323 c000 0 0 3 &mpc5200_pic 0 0 3 325 0xc000 0 0 3 &mpc5200_pic 0 0 3
324 c000 0 0 4 &mpc5200_pic 0 0 3>; 326 0xc000 0 0 4 &mpc5200_pic 0 0 3>;
325 clock-frequency = <0>; // From boot loader 327 clock-frequency = <0>; // From boot loader
326 interrupts = <2 8 0 2 9 0 2 a 0>; 328 interrupts = <2 8 0 2 9 0 2 10 0>;
327 interrupt-parent = <&mpc5200_pic>; 329 interrupt-parent = <&mpc5200_pic>;
328 bus-range = <0 0>; 330 bus-range = <0 0>;
329 ranges = <42000000 0 80000000 80000000 0 20000000 331 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
330 02000000 0 a0000000 a0000000 0 10000000 332 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
331 01000000 0 00000000 b0000000 0 01000000>; 333 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
332 }; 334 };
333}; 335};
diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
index 2e9bc397ae9a..7bd5b9c399b8 100644
--- a/arch/powerpc/boot/dts/lite5200b.dts
+++ b/arch/powerpc/boot/dts/lite5200b.dts
@@ -10,11 +10,7 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13/* 13/dts-v1/;
14 * WARNING: Do not depend on this tree layout remaining static just yet.
15 * The MPC5200 device tree conventions are still in flux
16 * Keep an eye on the linuxppc-dev mailing list for more details
17 */
18 14
19/ { 15/ {
20 model = "fsl,lite5200b"; 16 model = "fsl,lite5200b";
@@ -29,10 +25,10 @@
29 PowerPC,5200@0 { 25 PowerPC,5200@0 {
30 device_type = "cpu"; 26 device_type = "cpu";
31 reg = <0>; 27 reg = <0>;
32 d-cache-line-size = <20>; 28 d-cache-line-size = <32>;
33 i-cache-line-size = <20>; 29 i-cache-line-size = <32>;
34 d-cache-size = <4000>; // L1, 16K 30 d-cache-size = <0x4000>; // L1, 16K
35 i-cache-size = <4000>; // L1, 16K 31 i-cache-size = <0x4000>; // L1, 16K
36 timebase-frequency = <0>; // from bootloader 32 timebase-frequency = <0>; // from bootloader
37 bus-frequency = <0>; // from bootloader 33 bus-frequency = <0>; // from bootloader
38 clock-frequency = <0>; // from bootloader 34 clock-frequency = <0>; // from bootloader
@@ -41,21 +37,21 @@
41 37
42 memory { 38 memory {
43 device_type = "memory"; 39 device_type = "memory";
44 reg = <00000000 10000000>; // 256MB 40 reg = <0x00000000 0x10000000>; // 256MB
45 }; 41 };
46 42
47 soc5200@f0000000 { 43 soc5200@f0000000 {
48 #address-cells = <1>; 44 #address-cells = <1>;
49 #size-cells = <1>; 45 #size-cells = <1>;
50 compatible = "fsl,mpc5200b-immr"; 46 compatible = "fsl,mpc5200b-immr";
51 ranges = <0 f0000000 0000c000>; 47 ranges = <0 0xf0000000 0x0000c000>;
52 reg = <f0000000 00000100>; 48 reg = <0xf0000000 0x00000100>;
53 bus-frequency = <0>; // from bootloader 49 bus-frequency = <0>; // from bootloader
54 system-frequency = <0>; // from bootloader 50 system-frequency = <0>; // from bootloader
55 51
56 cdm@200 { 52 cdm@200 {
57 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm"; 53 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
58 reg = <200 38>; 54 reg = <0x200 0x38>;
59 }; 55 };
60 56
61 mpc5200_pic: interrupt-controller@500 { 57 mpc5200_pic: interrupt-controller@500 {
@@ -64,13 +60,13 @@
64 #interrupt-cells = <3>; 60 #interrupt-cells = <3>;
65 device_type = "interrupt-controller"; 61 device_type = "interrupt-controller";
66 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic"; 62 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
67 reg = <500 80>; 63 reg = <0x500 0x80>;
68 }; 64 };
69 65
70 timer@600 { // General Purpose Timer 66 timer@600 { // General Purpose Timer
71 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 67 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
72 cell-index = <0>; 68 cell-index = <0>;
73 reg = <600 10>; 69 reg = <0x600 0x10>;
74 interrupts = <1 9 0>; 70 interrupts = <1 9 0>;
75 interrupt-parent = <&mpc5200_pic>; 71 interrupt-parent = <&mpc5200_pic>;
76 fsl,has-wdt; 72 fsl,has-wdt;
@@ -79,63 +75,63 @@
79 timer@610 { // General Purpose Timer 75 timer@610 { // General Purpose Timer
80 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 76 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
81 cell-index = <1>; 77 cell-index = <1>;
82 reg = <610 10>; 78 reg = <0x610 0x10>;
83 interrupts = <1 a 0>; 79 interrupts = <1 10 0>;
84 interrupt-parent = <&mpc5200_pic>; 80 interrupt-parent = <&mpc5200_pic>;
85 }; 81 };
86 82
87 timer@620 { // General Purpose Timer 83 timer@620 { // General Purpose Timer
88 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 84 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
89 cell-index = <2>; 85 cell-index = <2>;
90 reg = <620 10>; 86 reg = <0x620 0x10>;
91 interrupts = <1 b 0>; 87 interrupts = <1 11 0>;
92 interrupt-parent = <&mpc5200_pic>; 88 interrupt-parent = <&mpc5200_pic>;
93 }; 89 };
94 90
95 timer@630 { // General Purpose Timer 91 timer@630 { // General Purpose Timer
96 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 92 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
97 cell-index = <3>; 93 cell-index = <3>;
98 reg = <630 10>; 94 reg = <0x630 0x10>;
99 interrupts = <1 c 0>; 95 interrupts = <1 12 0>;
100 interrupt-parent = <&mpc5200_pic>; 96 interrupt-parent = <&mpc5200_pic>;
101 }; 97 };
102 98
103 timer@640 { // General Purpose Timer 99 timer@640 { // General Purpose Timer
104 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 100 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
105 cell-index = <4>; 101 cell-index = <4>;
106 reg = <640 10>; 102 reg = <0x640 0x10>;
107 interrupts = <1 d 0>; 103 interrupts = <1 13 0>;
108 interrupt-parent = <&mpc5200_pic>; 104 interrupt-parent = <&mpc5200_pic>;
109 }; 105 };
110 106
111 timer@650 { // General Purpose Timer 107 timer@650 { // General Purpose Timer
112 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 108 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
113 cell-index = <5>; 109 cell-index = <5>;
114 reg = <650 10>; 110 reg = <0x650 0x10>;
115 interrupts = <1 e 0>; 111 interrupts = <1 14 0>;
116 interrupt-parent = <&mpc5200_pic>; 112 interrupt-parent = <&mpc5200_pic>;
117 }; 113 };
118 114
119 timer@660 { // General Purpose Timer 115 timer@660 { // General Purpose Timer
120 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 116 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
121 cell-index = <6>; 117 cell-index = <6>;
122 reg = <660 10>; 118 reg = <0x660 0x10>;
123 interrupts = <1 f 0>; 119 interrupts = <1 15 0>;
124 interrupt-parent = <&mpc5200_pic>; 120 interrupt-parent = <&mpc5200_pic>;
125 }; 121 };
126 122
127 timer@670 { // General Purpose Timer 123 timer@670 { // General Purpose Timer
128 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 124 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
129 cell-index = <7>; 125 cell-index = <7>;
130 reg = <670 10>; 126 reg = <0x670 0x10>;
131 interrupts = <1 10 0>; 127 interrupts = <1 16 0>;
132 interrupt-parent = <&mpc5200_pic>; 128 interrupt-parent = <&mpc5200_pic>;
133 }; 129 };
134 130
135 rtc@800 { // Real time clock 131 rtc@800 { // Real time clock
136 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc"; 132 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
137 device_type = "rtc"; 133 device_type = "rtc";
138 reg = <800 100>; 134 reg = <0x800 0x100>;
139 interrupts = <1 5 0 1 6 0>; 135 interrupts = <1 5 0 1 6 0>;
140 interrupt-parent = <&mpc5200_pic>; 136 interrupt-parent = <&mpc5200_pic>;
141 }; 137 };
@@ -143,43 +139,43 @@
143 can@900 { 139 can@900 {
144 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan"; 140 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
145 cell-index = <0>; 141 cell-index = <0>;
146 interrupts = <2 11 0>; 142 interrupts = <2 17 0>;
147 interrupt-parent = <&mpc5200_pic>; 143 interrupt-parent = <&mpc5200_pic>;
148 reg = <900 80>; 144 reg = <0x900 0x80>;
149 }; 145 };
150 146
151 can@980 { 147 can@980 {
152 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan"; 148 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
153 cell-index = <1>; 149 cell-index = <1>;
154 interrupts = <2 12 0>; 150 interrupts = <2 18 0>;
155 interrupt-parent = <&mpc5200_pic>; 151 interrupt-parent = <&mpc5200_pic>;
156 reg = <980 80>; 152 reg = <0x980 0x80>;
157 }; 153 };
158 154
159 gpio@b00 { 155 gpio@b00 {
160 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio"; 156 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
161 reg = <b00 40>; 157 reg = <0xb00 0x40>;
162 interrupts = <1 7 0>; 158 interrupts = <1 7 0>;
163 interrupt-parent = <&mpc5200_pic>; 159 interrupt-parent = <&mpc5200_pic>;
164 }; 160 };
165 161
166 gpio@c00 { 162 gpio@c00 {
167 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup"; 163 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
168 reg = <c00 40>; 164 reg = <0xc00 0x40>;
169 interrupts = <1 8 0 0 3 0>; 165 interrupts = <1 8 0 0 3 0>;
170 interrupt-parent = <&mpc5200_pic>; 166 interrupt-parent = <&mpc5200_pic>;
171 }; 167 };
172 168
173 spi@f00 { 169 spi@f00 {
174 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 170 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
175 reg = <f00 20>; 171 reg = <0xf00 0x20>;
176 interrupts = <2 d 0 2 e 0>; 172 interrupts = <2 13 0 2 14 0>;
177 interrupt-parent = <&mpc5200_pic>; 173 interrupt-parent = <&mpc5200_pic>;
178 }; 174 };
179 175
180 usb@1000 { 176 usb@1000 {
181 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be"; 177 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
182 reg = <1000 ff>; 178 reg = <0x1000 0xff>;
183 interrupts = <2 6 0>; 179 interrupts = <2 6 0>;
184 interrupt-parent = <&mpc5200_pic>; 180 interrupt-parent = <&mpc5200_pic>;
185 }; 181 };
@@ -187,17 +183,17 @@
187 dma-controller@1200 { 183 dma-controller@1200 {
188 device_type = "dma-controller"; 184 device_type = "dma-controller";
189 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm"; 185 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
190 reg = <1200 80>; 186 reg = <0x1200 0x80>;
191 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0 187 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
192 3 4 0 3 5 0 3 6 0 3 7 0 188 3 4 0 3 5 0 3 6 0 3 7 0
193 3 8 0 3 9 0 3 a 0 3 b 0 189 3 8 0 3 9 0 3 10 0 3 11 0
194 3 c 0 3 d 0 3 e 0 3 f 0>; 190 3 12 0 3 13 0 3 14 0 3 15 0>;
195 interrupt-parent = <&mpc5200_pic>; 191 interrupt-parent = <&mpc5200_pic>;
196 }; 192 };
197 193
198 xlb@1f00 { 194 xlb@1f00 {
199 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; 195 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
200 reg = <1f00 100>; 196 reg = <0x1f00 0x100>;
201 }; 197 };
202 198
203 serial@2000 { // PSC1 199 serial@2000 { // PSC1
@@ -205,7 +201,7 @@
205 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 201 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
206 port-number = <0>; // Logical port assignment 202 port-number = <0>; // Logical port assignment
207 cell-index = <0>; 203 cell-index = <0>;
208 reg = <2000 100>; 204 reg = <0x2000 0x100>;
209 interrupts = <2 1 0>; 205 interrupts = <2 1 0>;
210 interrupt-parent = <&mpc5200_pic>; 206 interrupt-parent = <&mpc5200_pic>;
211 }; 207 };
@@ -214,7 +210,7 @@
214 //ac97@2200 { // PSC2 210 //ac97@2200 { // PSC2
215 // compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97"; 211 // compatible = "fsl,mpc5200b-psc-ac97","fsl,mpc5200-psc-ac97";
216 // cell-index = <1>; 212 // cell-index = <1>;
217 // reg = <2200 100>; 213 // reg = <0x2200 0x100>;
218 // interrupts = <2 2 0>; 214 // interrupts = <2 2 0>;
219 // interrupt-parent = <&mpc5200_pic>; 215 // interrupt-parent = <&mpc5200_pic>;
220 //}; 216 //};
@@ -223,7 +219,7 @@
223 //i2s@2400 { // PSC3 219 //i2s@2400 { // PSC3
224 // compatible = "fsl,mpc5200b-psc-i2s"; //not 5200 compatible 220 // compatible = "fsl,mpc5200b-psc-i2s"; //not 5200 compatible
225 // cell-index = <2>; 221 // cell-index = <2>;
226 // reg = <2400 100>; 222 // reg = <0x2400 0x100>;
227 // interrupts = <2 3 0>; 223 // interrupts = <2 3 0>;
228 // interrupt-parent = <&mpc5200_pic>; 224 // interrupt-parent = <&mpc5200_pic>;
229 //}; 225 //};
@@ -233,8 +229,8 @@
233 // device_type = "serial"; 229 // device_type = "serial";
234 // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 230 // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
235 // cell-index = <3>; 231 // cell-index = <3>;
236 // reg = <2600 100>; 232 // reg = <0x2600 0x100>;
237 // interrupts = <2 b 0>; 233 // interrupts = <2 11 0>;
238 // interrupt-parent = <&mpc5200_pic>; 234 // interrupt-parent = <&mpc5200_pic>;
239 //}; 235 //};
240 236
@@ -243,8 +239,8 @@
243 // device_type = "serial"; 239 // device_type = "serial";
244 // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 240 // compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
245 // cell-index = <4>; 241 // cell-index = <4>;
246 // reg = <2800 100>; 242 // reg = <0x2800 0x100>;
247 // interrupts = <2 c 0>; 243 // interrupts = <2 12 0>;
248 // interrupt-parent = <&mpc5200_pic>; 244 // interrupt-parent = <&mpc5200_pic>;
249 //}; 245 //};
250 246
@@ -252,7 +248,7 @@
252 //spi@2c00 { // PSC6 248 //spi@2c00 { // PSC6
253 // compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi"; 249 // compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
254 // cell-index = <5>; 250 // cell-index = <5>;
255 // reg = <2c00 100>; 251 // reg = <0x2c00 0x100>;
256 // interrupts = <2 4 0>; 252 // interrupts = <2 4 0>;
257 // interrupt-parent = <&mpc5200_pic>; 253 // interrupt-parent = <&mpc5200_pic>;
258 //}; 254 //};
@@ -260,7 +256,7 @@
260 ethernet@3000 { 256 ethernet@3000 {
261 device_type = "network"; 257 device_type = "network";
262 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec"; 258 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
263 reg = <3000 400>; 259 reg = <0x3000 0x400>;
264 local-mac-address = [ 00 00 00 00 00 00 ]; 260 local-mac-address = [ 00 00 00 00 00 00 ];
265 interrupts = <2 5 0>; 261 interrupts = <2 5 0>;
266 interrupt-parent = <&mpc5200_pic>; 262 interrupt-parent = <&mpc5200_pic>;
@@ -271,11 +267,11 @@
271 #address-cells = <1>; 267 #address-cells = <1>;
272 #size-cells = <0>; 268 #size-cells = <0>;
273 compatible = "fsl,mpc5200b-mdio", "fsl,mpc5200-mdio"; 269 compatible = "fsl,mpc5200b-mdio", "fsl,mpc5200-mdio";
274 reg = <3000 400>; // fec range, since we need to setup fec interrupts 270 reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
275 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co. 271 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
276 interrupt-parent = <&mpc5200_pic>; 272 interrupt-parent = <&mpc5200_pic>;
277 273
278 phy0:ethernet-phy@0 { 274 phy0: ethernet-phy@0 {
279 device_type = "ethernet-phy"; 275 device_type = "ethernet-phy";
280 reg = <0>; 276 reg = <0>;
281 }; 277 };
@@ -284,7 +280,7 @@
284 ata@3a00 { 280 ata@3a00 {
285 device_type = "ata"; 281 device_type = "ata";
286 compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata"; 282 compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
287 reg = <3a00 100>; 283 reg = <0x3a00 0x100>;
288 interrupts = <2 7 0>; 284 interrupts = <2 7 0>;
289 interrupt-parent = <&mpc5200_pic>; 285 interrupt-parent = <&mpc5200_pic>;
290 }; 286 };
@@ -294,8 +290,8 @@
294 #size-cells = <0>; 290 #size-cells = <0>;
295 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; 291 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
296 cell-index = <0>; 292 cell-index = <0>;
297 reg = <3d00 40>; 293 reg = <0x3d00 0x40>;
298 interrupts = <2 f 0>; 294 interrupts = <2 15 0>;
299 interrupt-parent = <&mpc5200_pic>; 295 interrupt-parent = <&mpc5200_pic>;
300 fsl5200-clocking; 296 fsl5200-clocking;
301 }; 297 };
@@ -305,14 +301,14 @@
305 #size-cells = <0>; 301 #size-cells = <0>;
306 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; 302 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
307 cell-index = <1>; 303 cell-index = <1>;
308 reg = <3d40 40>; 304 reg = <0x3d40 0x40>;
309 interrupts = <2 10 0>; 305 interrupts = <2 16 0>;
310 interrupt-parent = <&mpc5200_pic>; 306 interrupt-parent = <&mpc5200_pic>;
311 fsl5200-clocking; 307 fsl5200-clocking;
312 }; 308 };
313 sram@8000 { 309 sram@8000 {
314 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram","sram"; 310 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram","sram";
315 reg = <8000 4000>; 311 reg = <0x8000 0x4000>;
316 }; 312 };
317 }; 313 };
318 314
@@ -322,23 +318,23 @@
322 #address-cells = <3>; 318 #address-cells = <3>;
323 device_type = "pci"; 319 device_type = "pci";
324 compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci"; 320 compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
325 reg = <f0000d00 100>; 321 reg = <0xf0000d00 0x100>;
326 interrupt-map-mask = <f800 0 0 7>; 322 interrupt-map-mask = <0xf800 0 0 7>;
327 interrupt-map = <c000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot 323 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3 // 1st slot
328 c000 0 0 2 &mpc5200_pic 1 1 3 324 0xc000 0 0 2 &mpc5200_pic 1 1 3
329 c000 0 0 3 &mpc5200_pic 1 2 3 325 0xc000 0 0 3 &mpc5200_pic 1 2 3
330 c000 0 0 4 &mpc5200_pic 1 3 3 326 0xc000 0 0 4 &mpc5200_pic 1 3 3
331 327
332 c800 0 0 1 &mpc5200_pic 1 1 3 // 2nd slot 328 0xc800 0 0 1 &mpc5200_pic 1 1 3 // 2nd slot
333 c800 0 0 2 &mpc5200_pic 1 2 3 329 0xc800 0 0 2 &mpc5200_pic 1 2 3
334 c800 0 0 3 &mpc5200_pic 1 3 3 330 0xc800 0 0 3 &mpc5200_pic 1 3 3
335 c800 0 0 4 &mpc5200_pic 0 0 3>; 331 0xc800 0 0 4 &mpc5200_pic 0 0 3>;
336 clock-frequency = <0>; // From boot loader 332 clock-frequency = <0>; // From boot loader
337 interrupts = <2 8 0 2 9 0 2 a 0>; 333 interrupts = <2 8 0 2 9 0 2 10 0>;
338 interrupt-parent = <&mpc5200_pic>; 334 interrupt-parent = <&mpc5200_pic>;
339 bus-range = <0 0>; 335 bus-range = <0 0>;
340 ranges = <42000000 0 80000000 80000000 0 20000000 336 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x20000000
341 02000000 0 a0000000 a0000000 0 10000000 337 0x02000000 0 0xa0000000 0xa0000000 0 0x10000000
342 01000000 0 00000000 b0000000 0 01000000>; 338 0x01000000 0 0x00000000 0xb0000000 0 0x01000000>;
343 }; 339 };
344}; 340};
diff --git a/arch/powerpc/boot/dts/motionpro.dts b/arch/powerpc/boot/dts/motionpro.dts
index 2b0dde058f8e..9e3c921be164 100644
--- a/arch/powerpc/boot/dts/motionpro.dts
+++ b/arch/powerpc/boot/dts/motionpro.dts
@@ -10,6 +10,8 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13/dts-v1/;
14
13/ { 15/ {
14 model = "promess,motionpro"; 16 model = "promess,motionpro";
15 compatible = "promess,motionpro"; 17 compatible = "promess,motionpro";
@@ -23,10 +25,10 @@
23 PowerPC,5200@0 { 25 PowerPC,5200@0 {
24 device_type = "cpu"; 26 device_type = "cpu";
25 reg = <0>; 27 reg = <0>;
26 d-cache-line-size = <20>; 28 d-cache-line-size = <32>;
27 i-cache-line-size = <20>; 29 i-cache-line-size = <32>;
28 d-cache-size = <4000>; // L1, 16K 30 d-cache-size = <0x4000>; // L1, 16K
29 i-cache-size = <4000>; // L1, 16K 31 i-cache-size = <0x4000>; // L1, 16K
30 timebase-frequency = <0>; // from bootloader 32 timebase-frequency = <0>; // from bootloader
31 bus-frequency = <0>; // from bootloader 33 bus-frequency = <0>; // from bootloader
32 clock-frequency = <0>; // from bootloader 34 clock-frequency = <0>; // from bootloader
@@ -35,21 +37,21 @@
35 37
36 memory { 38 memory {
37 device_type = "memory"; 39 device_type = "memory";
38 reg = <00000000 04000000>; // 64MB 40 reg = <0x00000000 0x04000000>; // 64MB
39 }; 41 };
40 42
41 soc5200@f0000000 { 43 soc5200@f0000000 {
42 #address-cells = <1>; 44 #address-cells = <1>;
43 #size-cells = <1>; 45 #size-cells = <1>;
44 compatible = "fsl,mpc5200b-immr"; 46 compatible = "fsl,mpc5200b-immr";
45 ranges = <0 f0000000 0000c000>; 47 ranges = <0 0xf0000000 0x0000c000>;
46 reg = <f0000000 00000100>; 48 reg = <0xf0000000 0x00000100>;
47 bus-frequency = <0>; // from bootloader 49 bus-frequency = <0>; // from bootloader
48 system-frequency = <0>; // from bootloader 50 system-frequency = <0>; // from bootloader
49 51
50 cdm@200 { 52 cdm@200 {
51 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm"; 53 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
52 reg = <200 38>; 54 reg = <0x200 0x38>;
53 }; 55 };
54 56
55 mpc5200_pic: interrupt-controller@500 { 57 mpc5200_pic: interrupt-controller@500 {
@@ -57,12 +59,12 @@
57 interrupt-controller; 59 interrupt-controller;
58 #interrupt-cells = <3>; 60 #interrupt-cells = <3>;
59 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic"; 61 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
60 reg = <500 80>; 62 reg = <0x500 0x80>;
61 }; 63 };
62 64
63 timer@600 { // General Purpose Timer 65 timer@600 { // General Purpose Timer
64 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 66 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
65 reg = <600 10>; 67 reg = <0x600 0x10>;
66 interrupts = <1 9 0>; 68 interrupts = <1 9 0>;
67 interrupt-parent = <&mpc5200_pic>; 69 interrupt-parent = <&mpc5200_pic>;
68 fsl,has-wdt; 70 fsl,has-wdt;
@@ -70,118 +72,118 @@
70 72
71 timer@610 { // General Purpose Timer 73 timer@610 { // General Purpose Timer
72 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 74 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
73 reg = <610 10>; 75 reg = <0x610 0x10>;
74 interrupts = <1 a 0>; 76 interrupts = <1 10 0>;
75 interrupt-parent = <&mpc5200_pic>; 77 interrupt-parent = <&mpc5200_pic>;
76 }; 78 };
77 79
78 timer@620 { // General Purpose Timer 80 timer@620 { // General Purpose Timer
79 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 81 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
80 reg = <620 10>; 82 reg = <0x620 0x10>;
81 interrupts = <1 b 0>; 83 interrupts = <1 11 0>;
82 interrupt-parent = <&mpc5200_pic>; 84 interrupt-parent = <&mpc5200_pic>;
83 }; 85 };
84 86
85 timer@630 { // General Purpose Timer 87 timer@630 { // General Purpose Timer
86 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 88 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
87 reg = <630 10>; 89 reg = <0x630 0x10>;
88 interrupts = <1 c 0>; 90 interrupts = <1 12 0>;
89 interrupt-parent = <&mpc5200_pic>; 91 interrupt-parent = <&mpc5200_pic>;
90 }; 92 };
91 93
92 timer@640 { // General Purpose Timer 94 timer@640 { // General Purpose Timer
93 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 95 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
94 reg = <640 10>; 96 reg = <0x640 0x10>;
95 interrupts = <1 d 0>; 97 interrupts = <1 13 0>;
96 interrupt-parent = <&mpc5200_pic>; 98 interrupt-parent = <&mpc5200_pic>;
97 }; 99 };
98 100
99 timer@650 { // General Purpose Timer 101 timer@650 { // General Purpose Timer
100 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt"; 102 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
101 reg = <650 10>; 103 reg = <0x650 0x10>;
102 interrupts = <1 e 0>; 104 interrupts = <1 14 0>;
103 interrupt-parent = <&mpc5200_pic>; 105 interrupt-parent = <&mpc5200_pic>;
104 }; 106 };
105 107
106 motionpro-led@660 { // Motion-PRO status LED 108 motionpro-led@660 { // Motion-PRO status LED
107 compatible = "promess,motionpro-led"; 109 compatible = "promess,motionpro-led";
108 label = "motionpro-statusled"; 110 label = "motionpro-statusled";
109 reg = <660 10>; 111 reg = <0x660 0x10>;
110 interrupts = <1 f 0>; 112 interrupts = <1 15 0>;
111 interrupt-parent = <&mpc5200_pic>; 113 interrupt-parent = <&mpc5200_pic>;
112 blink-delay = <64>; // 100 msec 114 blink-delay = <100>; // 100 msec
113 }; 115 };
114 116
115 motionpro-led@670 { // Motion-PRO ready LED 117 motionpro-led@670 { // Motion-PRO ready LED
116 compatible = "promess,motionpro-led"; 118 compatible = "promess,motionpro-led";
117 label = "motionpro-readyled"; 119 label = "motionpro-readyled";
118 reg = <670 10>; 120 reg = <0x670 0x10>;
119 interrupts = <1 10 0>; 121 interrupts = <1 16 0>;
120 interrupt-parent = <&mpc5200_pic>; 122 interrupt-parent = <&mpc5200_pic>;
121 }; 123 };
122 124
123 rtc@800 { // Real time clock 125 rtc@800 { // Real time clock
124 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc"; 126 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
125 reg = <800 100>; 127 reg = <0x800 0x100>;
126 interrupts = <1 5 0 1 6 0>; 128 interrupts = <1 5 0 1 6 0>;
127 interrupt-parent = <&mpc5200_pic>; 129 interrupt-parent = <&mpc5200_pic>;
128 }; 130 };
129 131
130 mscan@980 { 132 can@980 {
131 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan"; 133 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
132 interrupts = <2 12 0>; 134 interrupts = <2 18 0>;
133 interrupt-parent = <&mpc5200_pic>; 135 interrupt-parent = <&mpc5200_pic>;
134 reg = <980 80>; 136 reg = <0x980 0x80>;
135 }; 137 };
136 138
137 gpio@b00 { 139 gpio@b00 {
138 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio"; 140 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
139 reg = <b00 40>; 141 reg = <0xb00 0x40>;
140 interrupts = <1 7 0>; 142 interrupts = <1 7 0>;
141 interrupt-parent = <&mpc5200_pic>; 143 interrupt-parent = <&mpc5200_pic>;
142 }; 144 };
143 145
144 gpio@c00 { 146 gpio@c00 {
145 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup"; 147 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
146 reg = <c00 40>; 148 reg = <0xc00 0x40>;
147 interrupts = <1 8 0 0 3 0>; 149 interrupts = <1 8 0 0 3 0>;
148 interrupt-parent = <&mpc5200_pic>; 150 interrupt-parent = <&mpc5200_pic>;
149 }; 151 };
150 152
151 spi@f00 { 153 spi@f00 {
152 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi"; 154 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
153 reg = <f00 20>; 155 reg = <0xf00 0x20>;
154 interrupts = <2 d 0 2 e 0>; 156 interrupts = <2 13 0 2 14 0>;
155 interrupt-parent = <&mpc5200_pic>; 157 interrupt-parent = <&mpc5200_pic>;
156 }; 158 };
157 159
158 usb@1000 { 160 usb@1000 {
159 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be"; 161 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
160 reg = <1000 ff>; 162 reg = <0x1000 0xff>;
161 interrupts = <2 6 0>; 163 interrupts = <2 6 0>;
162 interrupt-parent = <&mpc5200_pic>; 164 interrupt-parent = <&mpc5200_pic>;
163 }; 165 };
164 166
165 dma-controller@1200 { 167 dma-controller@1200 {
166 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm"; 168 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
167 reg = <1200 80>; 169 reg = <0x1200 0x80>;
168 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0 170 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
169 3 4 0 3 5 0 3 6 0 3 7 0 171 3 4 0 3 5 0 3 6 0 3 7 0
170 3 8 0 3 9 0 3 a 0 3 b 0 172 3 8 0 3 9 0 3 10 0 3 11 0
171 3 c 0 3 d 0 3 e 0 3 f 0>; 173 3 12 0 3 13 0 3 14 0 3 15 0>;
172 interrupt-parent = <&mpc5200_pic>; 174 interrupt-parent = <&mpc5200_pic>;
173 }; 175 };
174 176
175 xlb@1f00 { 177 xlb@1f00 {
176 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb"; 178 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
177 reg = <1f00 100>; 179 reg = <0x1f00 0x100>;
178 }; 180 };
179 181
180 serial@2000 { // PSC1 182 serial@2000 { // PSC1
181 device_type = "serial"; 183 device_type = "serial";
182 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 184 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
183 port-number = <0>; // Logical port assignment 185 port-number = <0>; // Logical port assignment
184 reg = <2000 100>; 186 reg = <0x2000 0x100>;
185 interrupts = <2 1 0>; 187 interrupts = <2 1 0>;
186 interrupt-parent = <&mpc5200_pic>; 188 interrupt-parent = <&mpc5200_pic>;
187 }; 189 };
@@ -190,7 +192,7 @@
190 spi@2200 { // PSC2 192 spi@2200 { // PSC2
191 compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi"; 193 compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi";
192 cell-index = <1>; 194 cell-index = <1>;
193 reg = <2200 100>; 195 reg = <0x2200 0x100>;
194 interrupts = <2 2 0>; 196 interrupts = <2 2 0>;
195 interrupt-parent = <&mpc5200_pic>; 197 interrupt-parent = <&mpc5200_pic>;
196 }; 198 };
@@ -200,15 +202,15 @@
200 device_type = "serial"; 202 device_type = "serial";
201 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; 203 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
202 port-number = <4>; // Logical port assignment 204 port-number = <4>; // Logical port assignment
203 reg = <2800 100>; 205 reg = <0x2800 0x100>;
204 interrupts = <2 c 0>; 206 interrupts = <2 12 0>;
205 interrupt-parent = <&mpc5200_pic>; 207 interrupt-parent = <&mpc5200_pic>;
206 }; 208 };
207 209
208 ethernet@3000 { 210 ethernet@3000 {
209 device_type = "network"; 211 device_type = "network";
210 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec"; 212 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
211 reg = <3000 400>; 213 reg = <0x3000 0x400>;
212 local-mac-address = [ 00 00 00 00 00 00 ]; 214 local-mac-address = [ 00 00 00 00 00 00 ];
213 interrupts = <2 5 0>; 215 interrupts = <2 5 0>;
214 interrupt-parent = <&mpc5200_pic>; 216 interrupt-parent = <&mpc5200_pic>;
@@ -219,7 +221,7 @@
219 #address-cells = <1>; 221 #address-cells = <1>;
220 #size-cells = <0>; 222 #size-cells = <0>;
221 compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio"; 223 compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio";
222 reg = <3000 400>; // fec range, since we need to setup fec interrupts 224 reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
223 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co. 225 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
224 interrupt-parent = <&mpc5200_pic>; 226 interrupt-parent = <&mpc5200_pic>;
225 227
@@ -231,7 +233,7 @@
231 233
232 ata@3a00 { 234 ata@3a00 {
233 compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata"; 235 compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
234 reg = <3a00 100>; 236 reg = <0x3a00 0x100>;
235 interrupts = <2 7 0>; 237 interrupts = <2 7 0>;
236 interrupt-parent = <&mpc5200_pic>; 238 interrupt-parent = <&mpc5200_pic>;
237 }; 239 };
@@ -240,21 +242,21 @@
240 #address-cells = <1>; 242 #address-cells = <1>;
241 #size-cells = <0>; 243 #size-cells = <0>;
242 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c"; 244 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
243 reg = <3d40 40>; 245 reg = <0x3d40 0x40>;
244 interrupts = <2 10 0>; 246 interrupts = <2 16 0>;
245 interrupt-parent = <&mpc5200_pic>; 247 interrupt-parent = <&mpc5200_pic>;
246 fsl5200-clocking; 248 fsl5200-clocking;
247 249
248 rtc@68 { 250 rtc@68 {
249 device_type = "rtc"; 251 device_type = "rtc";
250 compatible = "dallas,ds1339"; 252 compatible = "dallas,ds1339";
251 reg = <68>; 253 reg = <0x68>;
252 }; 254 };
253 }; 255 };
254 256
255 sram@8000 { 257 sram@8000 {
256 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram"; 258 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram";
257 reg = <8000 4000>; 259 reg = <0x8000 0x4000>;
258 }; 260 };
259 }; 261 };
260 262
@@ -262,15 +264,15 @@
262 compatible = "fsl,lpb"; 264 compatible = "fsl,lpb";
263 #address-cells = <2>; 265 #address-cells = <2>;
264 #size-cells = <1>; 266 #size-cells = <1>;
265 ranges = <0 0 ff000000 01000000 267 ranges = <0 0 0xff000000 0x01000000
266 1 0 50000000 00010000 268 1 0 0x50000000 0x00010000
267 2 0 50010000 00010000 269 2 0 0x50010000 0x00010000
268 3 0 50020000 00010000>; 270 3 0 0x50020000 0x00010000>;
269 271
270 // 8-bit DualPort SRAM on LocalPlus Bus CS1 272 // 8-bit DualPort SRAM on LocalPlus Bus CS1
271 kollmorgen@1,0 { 273 kollmorgen@1,0 {
272 compatible = "promess,motionpro-kollmorgen"; 274 compatible = "promess,motionpro-kollmorgen";
273 reg = <1 0 10000>; 275 reg = <1 0 0x10000>;
274 interrupts = <1 1 0>; 276 interrupts = <1 1 0>;
275 interrupt-parent = <&mpc5200_pic>; 277 interrupt-parent = <&mpc5200_pic>;
276 }; 278 };
@@ -278,13 +280,13 @@
278 // 8-bit board CPLD on LocalPlus Bus CS2 280 // 8-bit board CPLD on LocalPlus Bus CS2
279 cpld@2,0 { 281 cpld@2,0 {
280 compatible = "promess,motionpro-cpld"; 282 compatible = "promess,motionpro-cpld";
281 reg = <2 0 10000>; 283 reg = <2 0 0x10000>;
282 }; 284 };
283 285
284 // 8-bit custom Anybus Module on LocalPlus Bus CS3 286 // 8-bit custom Anybus Module on LocalPlus Bus CS3
285 anybus@3,0 { 287 anybus@3,0 {
286 compatible = "promess,motionpro-anybus"; 288 compatible = "promess,motionpro-anybus";
287 reg = <3 0 10000>; 289 reg = <3 0 0x10000>;
288 }; 290 };
289 pro_module_general@3,0 { 291 pro_module_general@3,0 {
290 compatible = "promess,pro_module_general"; 292 compatible = "promess,pro_module_general";
@@ -292,13 +294,13 @@
292 }; 294 };
293 pro_module_dio@3,800 { 295 pro_module_dio@3,800 {
294 compatible = "promess,pro_module_dio"; 296 compatible = "promess,pro_module_dio";
295 reg = <3 800 2>; 297 reg = <3 0x800 2>;
296 }; 298 };
297 299
298 // 16-bit flash device at LocalPlus Bus CS0 300 // 16-bit flash device at LocalPlus Bus CS0
299 flash@0,0 { 301 flash@0,0 {
300 compatible = "cfi-flash"; 302 compatible = "cfi-flash";
301 reg = <0 0 01000000>; 303 reg = <0 0 0x01000000>;
302 bank-width = <2>; 304 bank-width = <2>;
303 device-width = <2>; 305 device-width = <2>;
304 #size-cells = <1>; 306 #size-cells = <1>;
diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts
new file mode 100644
index 000000000000..7c1bb952360c
--- /dev/null
+++ b/arch/powerpc/boot/dts/pcm030.dts
@@ -0,0 +1,363 @@
1/*
2 * phyCORE-MPC5200B-tiny (pcm030) board Device Tree Source
3 *
4 * Copyright 2006 Pengutronix
5 * Sascha Hauer <s.hauer@pengutronix.de>
6 * Copyright 2007 Pengutronix
7 * Juergen Beisert <j.beisert@pengutronix.de>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15/dts-v1/;
16
17/ {
18 model = "phytec,pcm030";
19 compatible = "phytec,pcm030";
20 #address-cells = <1>;
21 #size-cells = <1>;
22
23 cpus {
24 #address-cells = <1>;
25 #size-cells = <0>;
26
27 PowerPC,5200@0 {
28 device_type = "cpu";
29 reg = <0>;
30 d-cache-line-size = <32>;
31 i-cache-line-size = <32>;
32 d-cache-size = <0x4000>; /* L1, 16K */
33 i-cache-size = <0x4000>; /* L1, 16K */
34 timebase-frequency = <0>; /* From Bootloader */
35 bus-frequency = <0>; /* From Bootloader */
36 clock-frequency = <0>; /* From Bootloader */
37 };
38 };
39
40 memory {
41 device_type = "memory";
42 reg = <0x00000000 0x04000000>; /* 64MB */
43 };
44
45 soc5200@f0000000 {
46 #address-cells = <1>;
47 #size-cells = <1>;
48 compatible = "fsl,mpc5200b-immr";
49 ranges = <0x0 0xf0000000 0x0000c000>;
50 bus-frequency = <0>; /* From bootloader */
51 system-frequency = <0>; /* From bootloader */
52
53 cdm@200 {
54 compatible = "fsl,mpc5200b-cdm","fsl,mpc5200-cdm";
55 reg = <0x200 0x38>;
56 };
57
58 mpc5200_pic: interrupt-controller@500 {
59 /* 5200 interrupts are encoded into two levels; */
60 interrupt-controller;
61 #interrupt-cells = <3>;
62 device_type = "interrupt-controller";
63 compatible = "fsl,mpc5200b-pic","fsl,mpc5200-pic";
64 reg = <0x500 0x80>;
65 };
66
67 timer@600 { /* General Purpose Timer */
68 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
69 cell-index = <0>;
70 reg = <0x600 0x10>;
71 interrupts = <0x1 0x9 0x0>;
72 interrupt-parent = <&mpc5200_pic>;
73 fsl,has-wdt;
74 };
75
76 timer@610 { /* General Purpose Timer */
77 compatible = "fsl,mpc5200b-gpt","fsl,mpc5200-gpt";
78 cell-index = <1>;
79 reg = <0x610 0x10>;
80 interrupts = <0x1 0xa 0x0>;
81 interrupt-parent = <&mpc5200_pic>;
82 };
83
84 gpt2: timer@620 { /* General Purpose Timer in GPIO mode */
85 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
86 cell-index = <2>;
87 reg = <0x620 0x10>;
88 interrupts = <0x1 0xb 0x0>;
89 interrupt-parent = <&mpc5200_pic>;
90 gpio-controller;
91 #gpio-cells = <2>;
92 };
93
94 gpt3: timer@630 { /* General Purpose Timer in GPIO mode */
95 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
96 cell-index = <3>;
97 reg = <0x630 0x10>;
98 interrupts = <0x1 0xc 0x0>;
99 interrupt-parent = <&mpc5200_pic>;
100 gpio-controller;
101 #gpio-cells = <2>;
102 };
103
104 gpt4: timer@640 { /* General Purpose Timer in GPIO mode */
105 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
106 cell-index = <4>;
107 reg = <0x640 0x10>;
108 interrupts = <0x1 0xd 0x0>;
109 interrupt-parent = <&mpc5200_pic>;
110 gpio-controller;
111 #gpio-cells = <2>;
112 };
113
114 gpt5: timer@650 { /* General Purpose Timer in GPIO mode */
115 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
116 cell-index = <5>;
117 reg = <0x650 0x10>;
118 interrupts = <0x1 0xe 0x0>;
119 interrupt-parent = <&mpc5200_pic>;
120 gpio-controller;
121 #gpio-cells = <2>;
122 };
123
124 gpt6: timer@660 { /* General Purpose Timer in GPIO mode */
125 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
126 cell-index = <6>;
127 reg = <0x660 0x10>;
128 interrupts = <0x1 0xf 0x0>;
129 interrupt-parent = <&mpc5200_pic>;
130 gpio-controller;
131 #gpio-cells = <2>;
132 };
133
134 gpt7: timer@670 { /* General Purpose Timer in GPIO mode */
135 compatible = "fsl,mpc5200b-gpt-gpio","fsl,mpc5200-gpt-gpio";
136 cell-index = <7>;
137 reg = <0x670 0x10>;
138 interrupts = <0x1 0x10 0x0>;
139 interrupt-parent = <&mpc5200_pic>;
140 gpio-controller;
141 #gpio-cells = <2>;
142 };
143
144 rtc@800 { // Real time clock
145 compatible = "fsl,mpc5200b-rtc","fsl,mpc5200-rtc";
146 device_type = "rtc";
147 reg = <0x800 0x100>;
148 interrupts = <0x1 0x5 0x0 0x1 0x6 0x0>;
149 interrupt-parent = <&mpc5200_pic>;
150 };
151
152 can@900 {
153 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
154 cell-index = <0>;
155 interrupts = <0x2 0x11 0x0>;
156 interrupt-parent = <&mpc5200_pic>;
157 reg = <0x900 0x80>;
158 };
159
160 can@980 {
161 compatible = "fsl,mpc5200b-mscan","fsl,mpc5200-mscan";
162 cell-index = <1>;
163 interrupts = <0x2 0x12 0x0>;
164 interrupt-parent = <&mpc5200_pic>;
165 reg = <0x980 0x80>;
166 };
167
168 gpio_simple: gpio@b00 {
169 compatible = "fsl,mpc5200b-gpio","fsl,mpc5200-gpio";
170 reg = <0xb00 0x40>;
171 interrupts = <0x1 0x7 0x0>;
172 interrupt-parent = <&mpc5200_pic>;
173 gpio-controller;
174 #gpio-cells = <2>;
175 };
176
177 gpio_wkup: gpio-wkup@c00 {
178 compatible = "fsl,mpc5200b-gpio-wkup","fsl,mpc5200-gpio-wkup";
179 reg = <0xc00 0x40>;
180 interrupts = <0x1 0x8 0x0 0x0 0x3 0x0>;
181 interrupt-parent = <&mpc5200_pic>;
182 gpio-controller;
183 #gpio-cells = <2>;
184 };
185
186 spi@f00 {
187 compatible = "fsl,mpc5200b-spi","fsl,mpc5200-spi";
188 reg = <0xf00 0x20>;
189 interrupts = <0x2 0xd 0x0 0x2 0xe 0x0>;
190 interrupt-parent = <&mpc5200_pic>;
191 };
192
193 usb@1000 {
194 compatible = "fsl,mpc5200b-ohci","fsl,mpc5200-ohci","ohci-be";
195 reg = <0x1000 0xff>;
196 interrupts = <0x2 0x6 0x0>;
197 interrupt-parent = <&mpc5200_pic>;
198 };
199
200 dma-controller@1200 {
201 device_type = "dma-controller";
202 compatible = "fsl,mpc5200b-bestcomm","fsl,mpc5200-bestcomm";
203 reg = <0x1200 0x80>;
204 interrupts = <0x3 0x0 0x0 0x3 0x1 0x0 0x3 0x2 0x0 0x3 0x3 0x0
205 0x3 0x4 0x0 0x3 0x5 0x0 0x3 0x6 0x0 0x3 0x7 0x0
206 0x3 0x8 0x0 0x3 0x9 0x0 0x3 0xa 0x0 0x3 0xb 0x0
207 0x3 0xc 0x0 0x3 0xd 0x0 0x3 0xe 0x0 0x3 0xf 0x0>;
208 interrupt-parent = <&mpc5200_pic>;
209 };
210
211 xlb@1f00 {
212 compatible = "fsl,mpc5200b-xlb","fsl,mpc5200-xlb";
213 reg = <0x1f00 0x100>;
214 };
215
216 ac97@2000 { /* PSC1 in ac97 mode */
217 device_type = "sound";
218 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97";
219 cell-index = <0>;
220 reg = <0x2000 0x100>;
221 interrupts = <0x2 0x2 0x0>;
222 interrupt-parent = <&mpc5200_pic>;
223 };
224
225 /* PSC2 port is used by CAN1/2 */
226
227 serial@2400 { /* PSC3 in UART mode */
228 device_type = "serial";
229 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
230 port-number = <0>;
231 cell-index = <2>;
232 reg = <0x2400 0x100>;
233 interrupts = <0x2 0x3 0x0>;
234 interrupt-parent = <&mpc5200_pic>;
235 };
236
237 /* PSC4 is ??? */
238
239 /* PSC5 is ??? */
240
241 serial@2c00 { /* PSC6 in UART mode */
242 device_type = "serial";
243 compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart";
244 port-number = <1>;
245 cell-index = <5>;
246 reg = <0x2c00 0x100>;
247 interrupts = <0x2 0x4 0x0>;
248 interrupt-parent = <&mpc5200_pic>;
249 };
250
251 ethernet@3000 {
252 device_type = "network";
253 compatible = "fsl,mpc5200b-fec","fsl,mpc5200-fec";
254 reg = <0x3000 0x400>;
255 local-mac-address = [00 00 00 00 00 00];
256 interrupts = <0x2 0x5 0x0>;
257 interrupt-parent = <&mpc5200_pic>;
258 phy-handle = <&phy0>;
259 };
260
261 mdio@3000 {
262 #address-cells = <1>;
263 #size-cells = <0>;
264 compatible = "fsl,mpc5200b-mdio", "fsl,mpc5200-mdio";
265 reg = <0x3000 0x400>; /* fec range, since we need to setup fec interrupts */
266 interrupts = <0x2 0x5 0x0>; /* these are for "mii command finished", not link changes & co. */
267 interrupt-parent = <&mpc5200_pic>;
268
269 phy0:ethernet-phy@0 {
270 device_type = "ethernet-phy";
271 reg = <0x0>;
272 };
273 };
274
275 ata@3a00 {
276 device_type = "ata";
277 compatible = "fsl,mpc5200b-ata","fsl,mpc5200-ata";
278 reg = <0x3a00 0x100>;
279 interrupts = <0x2 0x7 0x0>;
280 interrupt-parent = <&mpc5200_pic>;
281 };
282
283 i2c@3d00 {
284 #address-cells = <1>;
285 #size-cells = <0>;
286 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
287 cell-index = <0>;
288 reg = <0x3d00 0x40>;
289 interrupts = <0x2 0xf 0x0>;
290 interrupt-parent = <&mpc5200_pic>;
291 fsl5200-clocking;
292 };
293
294 i2c@3d40 {
295 #address-cells = <1>;
296 #size-cells = <0>;
297 compatible = "fsl,mpc5200b-i2c","fsl,mpc5200-i2c","fsl-i2c";
298 cell-index = <1>;
299 reg = <0x3d40 0x40>;
300 interrupts = <0x2 0x10 0x0>;
301 interrupt-parent = <&mpc5200_pic>;
302 fsl5200-clocking;
303 rtc@51 {
304 device_type = "rtc";
305 compatible = "nxp,pcf8563";
306 reg = <0x51>;
307 };
308 /* FIXME: EEPROM */
309 };
310
311 sram@8000 {
312 compatible = "fsl,mpc5200b-sram","fsl,mpc5200-sram","sram";
313 reg = <0x8000 0x4000>;
314 };
315
316 /* This is only an example device to show the usage of gpios. It maps all available
317 * gpios to the "gpio-provider" device.
318 */
319 gpio {
320 compatible = "gpio-provider";
321
322 /* mpc52xx exp.con patchfield */
323 gpios = <&gpio_wkup 0 0 /* GPIO_WKUP_7 11d jp13-3 */
324 &gpio_wkup 1 0 /* GPIO_WKUP_6 14c */
325 &gpio_wkup 6 0 /* PSC2_4 43c x5-11 */
326 &gpio_simple 2 0 /* IRDA_1 24c x7-6 set GPS_PORT_CONFIG[IRDA] = 0 */
327 &gpio_simple 3 0 /* IRDA_0 x8-5 set GPS_PORT_CONFIG[IRDA] = 0 */
328 &gpt2 0 0 /* timer2 12d x4-4 */
329 &gpt3 0 0 /* timer3 13d x6-4 */
330 &gpt4 0 0 /* timer4 61c x2-16 */
331 &gpt5 0 0 /* timer5 44c x7-11 */
332 &gpt6 0 0 /* timer6 60c x8-15 */
333 &gpt7 0 0 /* timer7 36a x17-9 */
334 >;
335 };
336 };
337
338 pci@f0000d00 {
339 #interrupt-cells = <1>;
340 #size-cells = <2>;
341 #address-cells = <3>;
342 device_type = "pci";
343 compatible = "fsl,mpc5200b-pci","fsl,mpc5200-pci";
344 reg = <0xf0000d00 0x100>;
345 interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
346 interrupt-map = <0xc000 0x0 0x0 0x1 &mpc5200_pic 0x0 0x0 0x3 /* 1st slot */
347 0xc000 0x0 0x0 0x2 &mpc5200_pic 0x1 0x1 0x3
348 0xc000 0x0 0x0 0x3 &mpc5200_pic 0x1 0x2 0x3
349 0xc000 0x0 0x0 0x4 &mpc5200_pic 0x1 0x3 0x3
350
351 0xc800 0x0 0x0 0x1 &mpc5200_pic 0x1 0x1 0x3 /* 2nd slot */
352 0xc800 0x0 0x0 0x2 &mpc5200_pic 0x1 0x2 0x3
353 0xc800 0x0 0x0 0x3 &mpc5200_pic 0x1 0x3 0x3
354 0xc800 0x0 0x0 0x4 &mpc5200_pic 0x0 0x0 0x3>;
355 clock-frequency = <0>; // From boot loader
356 interrupts = <0x2 0x8 0x0 0x2 0x9 0x0 0x2 0xa 0x0>;
357 interrupt-parent = <&mpc5200_pic>;
358 bus-range = <0 0>;
359 ranges = <0x42000000 0x0 0x80000000 0x80000000 0x0 0x20000000
360 0x02000000 0x0 0xa0000000 0xa0000000 0x0 0x10000000
361 0x01000000 0x0 0x00000000 0xb0000000 0x0 0x01000000>;
362 };
363};
diff --git a/arch/powerpc/boot/dts/tqm5200.dts b/arch/powerpc/boot/dts/tqm5200.dts
index 65bcea6a0173..773a68e00058 100644
--- a/arch/powerpc/boot/dts/tqm5200.dts
+++ b/arch/powerpc/boot/dts/tqm5200.dts
@@ -10,6 +10,8 @@
10 * option) any later version. 10 * option) any later version.
11 */ 11 */
12 12
13/dts-v1/;
14
13/ { 15/ {
14 model = "tqc,tqm5200"; 16 model = "tqc,tqm5200";
15 compatible = "tqc,tqm5200"; 17 compatible = "tqc,tqm5200";
@@ -23,10 +25,10 @@
23 PowerPC,5200@0 { 25 PowerPC,5200@0 {
24 device_type = "cpu"; 26 device_type = "cpu";
25 reg = <0>; 27 reg = <0>;
26 d-cache-line-size = <20>; 28 d-cache-line-size = <32>;
27 i-cache-line-size = <20>; 29 i-cache-line-size = <32>;
28 d-cache-size = <4000>; // L1, 16K 30 d-cache-size = <0x4000>; // L1, 16K
29 i-cache-size = <4000>; // L1, 16K 31 i-cache-size = <0x4000>; // L1, 16K
30 timebase-frequency = <0>; // from bootloader 32 timebase-frequency = <0>; // from bootloader
31 bus-frequency = <0>; // from bootloader 33 bus-frequency = <0>; // from bootloader
32 clock-frequency = <0>; // from bootloader 34 clock-frequency = <0>; // from bootloader
@@ -35,21 +37,21 @@
35 37
36 memory { 38 memory {
37 device_type = "memory"; 39 device_type = "memory";
38 reg = <00000000 04000000>; // 64MB 40 reg = <0x00000000 0x04000000>; // 64MB
39 }; 41 };
40 42
41 soc5200@f0000000 { 43 soc5200@f0000000 {
42 #address-cells = <1>; 44 #address-cells = <1>;
43 #size-cells = <1>; 45 #size-cells = <1>;
44 compatible = "fsl,mpc5200-immr"; 46 compatible = "fsl,mpc5200-immr";
45 ranges = <0 f0000000 0000c000>; 47 ranges = <0 0xf0000000 0x0000c000>;
46 reg = <f0000000 00000100>; 48 reg = <0xf0000000 0x00000100>;
47 bus-frequency = <0>; // from bootloader 49 bus-frequency = <0>; // from bootloader
48 system-frequency = <0>; // from bootloader 50 system-frequency = <0>; // from bootloader
49 51
50 cdm@200 { 52 cdm@200 {
51 compatible = "fsl,mpc5200-cdm"; 53 compatible = "fsl,mpc5200-cdm";
52 reg = <200 38>; 54 reg = <0x200 0x38>;
53 }; 55 };
54 56
55 mpc5200_pic: interrupt-controller@500 { 57 mpc5200_pic: interrupt-controller@500 {
@@ -57,12 +59,12 @@
57 interrupt-controller; 59 interrupt-controller;
58 #interrupt-cells = <3>; 60 #interrupt-cells = <3>;
59 compatible = "fsl,mpc5200-pic"; 61 compatible = "fsl,mpc5200-pic";
60 reg = <500 80>; 62 reg = <0x500 0x80>;
61 }; 63 };
62 64
63 timer@600 { // General Purpose Timer 65 timer@600 { // General Purpose Timer
64 compatible = "fsl,mpc5200-gpt"; 66 compatible = "fsl,mpc5200-gpt";
65 reg = <600 10>; 67 reg = <0x600 0x10>;
66 interrupts = <1 9 0>; 68 interrupts = <1 9 0>;
67 interrupt-parent = <&mpc5200_pic>; 69 interrupt-parent = <&mpc5200_pic>;
68 fsl,has-wdt; 70 fsl,has-wdt;
@@ -70,38 +72,38 @@
70 72
71 gpio@b00 { 73 gpio@b00 {
72 compatible = "fsl,mpc5200-gpio"; 74 compatible = "fsl,mpc5200-gpio";
73 reg = <b00 40>; 75 reg = <0xb00 0x40>;
74 interrupts = <1 7 0>; 76 interrupts = <1 7 0>;
75 interrupt-parent = <&mpc5200_pic>; 77 interrupt-parent = <&mpc5200_pic>;
76 }; 78 };
77 79
78 usb@1000 { 80 usb@1000 {
79 compatible = "fsl,mpc5200-ohci","ohci-be"; 81 compatible = "fsl,mpc5200-ohci","ohci-be";
80 reg = <1000 ff>; 82 reg = <0x1000 0xff>;
81 interrupts = <2 6 0>; 83 interrupts = <2 6 0>;
82 interrupt-parent = <&mpc5200_pic>; 84 interrupt-parent = <&mpc5200_pic>;
83 }; 85 };
84 86
85 dma-controller@1200 { 87 dma-controller@1200 {
86 compatible = "fsl,mpc5200-bestcomm"; 88 compatible = "fsl,mpc5200-bestcomm";
87 reg = <1200 80>; 89 reg = <0x1200 0x80>;
88 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0 90 interrupts = <3 0 0 3 1 0 3 2 0 3 3 0
89 3 4 0 3 5 0 3 6 0 3 7 0 91 3 4 0 3 5 0 3 6 0 3 7 0
90 3 8 0 3 9 0 3 a 0 3 b 0 92 3 8 0 3 9 0 3 10 0 3 11 0
91 3 c 0 3 d 0 3 e 0 3 f 0>; 93 3 12 0 3 13 0 3 14 0 3 15 0>;
92 interrupt-parent = <&mpc5200_pic>; 94 interrupt-parent = <&mpc5200_pic>;
93 }; 95 };
94 96
95 xlb@1f00 { 97 xlb@1f00 {
96 compatible = "fsl,mpc5200-xlb"; 98 compatible = "fsl,mpc5200-xlb";
97 reg = <1f00 100>; 99 reg = <0x1f00 0x100>;
98 }; 100 };
99 101
100 serial@2000 { // PSC1 102 serial@2000 { // PSC1
101 device_type = "serial"; 103 device_type = "serial";
102 compatible = "fsl,mpc5200-psc-uart"; 104 compatible = "fsl,mpc5200-psc-uart";
103 port-number = <0>; // Logical port assignment 105 port-number = <0>; // Logical port assignment
104 reg = <2000 100>; 106 reg = <0x2000 0x100>;
105 interrupts = <2 1 0>; 107 interrupts = <2 1 0>;
106 interrupt-parent = <&mpc5200_pic>; 108 interrupt-parent = <&mpc5200_pic>;
107 }; 109 };
@@ -110,7 +112,7 @@
110 device_type = "serial"; 112 device_type = "serial";
111 compatible = "fsl,mpc5200-psc-uart"; 113 compatible = "fsl,mpc5200-psc-uart";
112 port-number = <1>; // Logical port assignment 114 port-number = <1>; // Logical port assignment
113 reg = <2200 100>; 115 reg = <0x2200 0x100>;
114 interrupts = <2 2 0>; 116 interrupts = <2 2 0>;
115 interrupt-parent = <&mpc5200_pic>; 117 interrupt-parent = <&mpc5200_pic>;
116 }; 118 };
@@ -119,7 +121,7 @@
119 device_type = "serial"; 121 device_type = "serial";
120 compatible = "fsl,mpc5200-psc-uart"; 122 compatible = "fsl,mpc5200-psc-uart";
121 port-number = <2>; // Logical port assignment 123 port-number = <2>; // Logical port assignment
122 reg = <2400 100>; 124 reg = <0x2400 0x100>;
123 interrupts = <2 3 0>; 125 interrupts = <2 3 0>;
124 interrupt-parent = <&mpc5200_pic>; 126 interrupt-parent = <&mpc5200_pic>;
125 }; 127 };
@@ -127,7 +129,7 @@
127 ethernet@3000 { 129 ethernet@3000 {
128 device_type = "network"; 130 device_type = "network";
129 compatible = "fsl,mpc5200-fec"; 131 compatible = "fsl,mpc5200-fec";
130 reg = <3000 400>; 132 reg = <0x3000 0x400>;
131 local-mac-address = [ 00 00 00 00 00 00 ]; 133 local-mac-address = [ 00 00 00 00 00 00 ];
132 interrupts = <2 5 0>; 134 interrupts = <2 5 0>;
133 interrupt-parent = <&mpc5200_pic>; 135 interrupt-parent = <&mpc5200_pic>;
@@ -137,8 +139,8 @@
137 mdio@3000 { 139 mdio@3000 {
138 #address-cells = <1>; 140 #address-cells = <1>;
139 #size-cells = <0>; 141 #size-cells = <0>;
140 compatible = "fsl,mpc5200b-mdio","fsl,mpc5200-mdio"; 142 compatible = "fsl,mpc5200-mdio";
141 reg = <3000 400>; // fec range, since we need to setup fec interrupts 143 reg = <0x3000 0x400>; // fec range, since we need to setup fec interrupts
142 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co. 144 interrupts = <2 5 0>; // these are for "mii command finished", not link changes & co.
143 interrupt-parent = <&mpc5200_pic>; 145 interrupt-parent = <&mpc5200_pic>;
144 146
@@ -150,7 +152,7 @@
150 152
151 ata@3a00 { 153 ata@3a00 {
152 compatible = "fsl,mpc5200-ata"; 154 compatible = "fsl,mpc5200-ata";
153 reg = <3a00 100>; 155 reg = <0x3a00 0x100>;
154 interrupts = <2 7 0>; 156 interrupts = <2 7 0>;
155 interrupt-parent = <&mpc5200_pic>; 157 interrupt-parent = <&mpc5200_pic>;
156 }; 158 };
@@ -159,21 +161,21 @@
159 #address-cells = <1>; 161 #address-cells = <1>;
160 #size-cells = <0>; 162 #size-cells = <0>;
161 compatible = "fsl,mpc5200-i2c","fsl-i2c"; 163 compatible = "fsl,mpc5200-i2c","fsl-i2c";
162 reg = <3d40 40>; 164 reg = <0x3d40 0x40>;
163 interrupts = <2 10 0>; 165 interrupts = <2 16 0>;
164 interrupt-parent = <&mpc5200_pic>; 166 interrupt-parent = <&mpc5200_pic>;
165 fsl5200-clocking; 167 fsl5200-clocking;
166 168
167 rtc@68 { 169 rtc@68 {
168 device_type = "rtc"; 170 device_type = "rtc";
169 compatible = "dallas,ds1307"; 171 compatible = "dallas,ds1307";
170 reg = <68>; 172 reg = <0x68>;
171 }; 173 };
172 }; 174 };
173 175
174 sram@8000 { 176 sram@8000 {
175 compatible = "fsl,mpc5200-sram"; 177 compatible = "fsl,mpc5200-sram";
176 reg = <8000 4000>; 178 reg = <0x8000 0x4000>;
177 }; 179 };
178 }; 180 };
179 181
@@ -182,11 +184,11 @@
182 compatible = "fsl,lpb"; 184 compatible = "fsl,lpb";
183 #address-cells = <2>; 185 #address-cells = <2>;
184 #size-cells = <1>; 186 #size-cells = <1>;
185 ranges = <0 0 fc000000 02000000>; 187 ranges = <0 0 0xfc000000 0x02000000>;
186 188
187 flash@0,0 { 189 flash@0,0 {
188 compatible = "cfi-flash"; 190 compatible = "cfi-flash";
189 reg = <0 0 02000000>; 191 reg = <0 0 0x02000000>;
190 bank-width = <4>; 192 bank-width = <4>;
191 device-width = <2>; 193 device-width = <2>;
192 #size-cells = <1>; 194 #size-cells = <1>;
@@ -200,18 +202,18 @@
200 #address-cells = <3>; 202 #address-cells = <3>;
201 device_type = "pci"; 203 device_type = "pci";
202 compatible = "fsl,mpc5200-pci"; 204 compatible = "fsl,mpc5200-pci";
203 reg = <f0000d00 100>; 205 reg = <0xf0000d00 0x100>;
204 interrupt-map-mask = <f800 0 0 7>; 206 interrupt-map-mask = <0xf800 0 0 7>;
205 interrupt-map = <c000 0 0 1 &mpc5200_pic 0 0 3 207 interrupt-map = <0xc000 0 0 1 &mpc5200_pic 0 0 3
206 c000 0 0 2 &mpc5200_pic 0 0 3 208 0xc000 0 0 2 &mpc5200_pic 0 0 3
207 c000 0 0 3 &mpc5200_pic 0 0 3 209 0xc000 0 0 3 &mpc5200_pic 0 0 3
208 c000 0 0 4 &mpc5200_pic 0 0 3>; 210 0xc000 0 0 4 &mpc5200_pic 0 0 3>;
209 clock-frequency = <0>; // From boot loader 211 clock-frequency = <0>; // From boot loader
210 interrupts = <2 8 0 2 9 0 2 a 0>; 212 interrupts = <2 8 0 2 9 0 2 10 0>;
211 interrupt-parent = <&mpc5200_pic>; 213 interrupt-parent = <&mpc5200_pic>;
212 bus-range = <0 0>; 214 bus-range = <0 0>;
213 ranges = <42000000 0 80000000 80000000 0 10000000 215 ranges = <0x42000000 0 0x80000000 0x80000000 0 0x10000000
214 02000000 0 90000000 90000000 0 10000000 216 0x02000000 0 0x90000000 0x90000000 0 0x10000000
215 01000000 0 00000000 a0000000 0 01000000>; 217 0x01000000 0 0x00000000 0xa0000000 0 0x01000000>;
216 }; 218 };
217}; 219};
diff --git a/arch/powerpc/configs/52xx/cm5200_defconfig b/arch/powerpc/configs/52xx/cm5200_defconfig
new file mode 100644
index 000000000000..c10f7395aa1b
--- /dev/null
+++ b/arch/powerpc/configs/52xx/cm5200_defconfig
@@ -0,0 +1,1099 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Tue Apr 29 07:11:37 2008
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11CONFIG_6xx=y
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18# CONFIG_ALTIVEC is not set
19CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_32=y
21# CONFIG_PPC_MM_SLICES is not set
22# CONFIG_SMP is not set
23CONFIG_PPC32=y
24CONFIG_WORD_SIZE=32
25CONFIG_PPC_MERGE=y
26CONFIG_MMU=y
27CONFIG_GENERIC_CMOS_UPDATE=y
28CONFIG_GENERIC_TIME=y
29CONFIG_GENERIC_TIME_VSYSCALL=y
30CONFIG_GENERIC_CLOCKEVENTS=y
31CONFIG_GENERIC_HARDIRQS=y
32# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
33CONFIG_IRQ_PER_CPU=y
34CONFIG_STACKTRACE_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y
43CONFIG_EARLY_PRINTK=y
44CONFIG_GENERIC_NVRAM=y
45CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
46CONFIG_ARCH_MAY_HAVE_PC_FDC=y
47CONFIG_PPC_OF=y
48CONFIG_OF=y
49# CONFIG_PPC_UDBG_16550 is not set
50# CONFIG_GENERIC_TBSYNC is not set
51CONFIG_AUDIT_ARCH=y
52CONFIG_GENERIC_BUG=y
53CONFIG_DEFAULT_UIMAGE=y
54# CONFIG_PPC_DCR_NATIVE is not set
55# CONFIG_PPC_DCR_MMIO is not set
56CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
57
58#
59# General setup
60#
61CONFIG_EXPERIMENTAL=y
62CONFIG_BROKEN_ON_SMP=y
63CONFIG_INIT_ENV_ARG_LIMIT=32
64CONFIG_LOCALVERSION=""
65CONFIG_LOCALVERSION_AUTO=y
66CONFIG_SWAP=y
67CONFIG_SYSVIPC=y
68CONFIG_SYSVIPC_SYSCTL=y
69# CONFIG_POSIX_MQUEUE is not set
70# CONFIG_BSD_PROCESS_ACCT is not set
71# CONFIG_TASKSTATS is not set
72# CONFIG_AUDIT is not set
73# CONFIG_IKCONFIG is not set
74CONFIG_LOG_BUF_SHIFT=14
75# CONFIG_CGROUPS is not set
76CONFIG_GROUP_SCHED=y
77CONFIG_FAIR_GROUP_SCHED=y
78# CONFIG_RT_GROUP_SCHED is not set
79CONFIG_USER_SCHED=y
80# CONFIG_CGROUP_SCHED is not set
81CONFIG_SYSFS_DEPRECATED=y
82CONFIG_SYSFS_DEPRECATED_V2=y
83# CONFIG_RELAY is not set
84# CONFIG_NAMESPACES is not set
85CONFIG_BLK_DEV_INITRD=y
86CONFIG_INITRAMFS_SOURCE=""
87# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
88CONFIG_SYSCTL=y
89CONFIG_EMBEDDED=y
90# CONFIG_SYSCTL_SYSCALL is not set
91# CONFIG_KALLSYMS is not set
92CONFIG_HOTPLUG=y
93CONFIG_PRINTK=y
94CONFIG_BUG=y
95CONFIG_ELF_CORE=y
96CONFIG_COMPAT_BRK=y
97CONFIG_BASE_FULL=y
98CONFIG_FUTEX=y
99CONFIG_ANON_INODES=y
100# CONFIG_EPOLL is not set
101CONFIG_SIGNALFD=y
102CONFIG_TIMERFD=y
103CONFIG_EVENTFD=y
104CONFIG_SHMEM=y
105CONFIG_VM_EVENT_COUNTERS=y
106CONFIG_SLUB_DEBUG=y
107# CONFIG_SLAB is not set
108CONFIG_SLUB=y
109# CONFIG_SLOB is not set
110# CONFIG_PROFILING is not set
111# CONFIG_MARKERS is not set
112CONFIG_HAVE_OPROFILE=y
113CONFIG_HAVE_KPROBES=y
114CONFIG_HAVE_KRETPROBES=y
115CONFIG_PROC_PAGE_MONITOR=y
116CONFIG_SLABINFO=y
117CONFIG_RT_MUTEXES=y
118# CONFIG_TINY_SHMEM is not set
119CONFIG_BASE_SMALL=0
120# CONFIG_MODULES is not set
121CONFIG_BLOCK=y
122# CONFIG_LBD is not set
123# CONFIG_BLK_DEV_IO_TRACE is not set
124# CONFIG_LSF is not set
125# CONFIG_BLK_DEV_BSG is not set
126
127#
128# IO Schedulers
129#
130CONFIG_IOSCHED_NOOP=y
131CONFIG_IOSCHED_AS=y
132CONFIG_IOSCHED_DEADLINE=y
133CONFIG_IOSCHED_CFQ=y
134CONFIG_DEFAULT_AS=y
135# CONFIG_DEFAULT_DEADLINE is not set
136# CONFIG_DEFAULT_CFQ is not set
137# CONFIG_DEFAULT_NOOP is not set
138CONFIG_DEFAULT_IOSCHED="anticipatory"
139CONFIG_CLASSIC_RCU=y
140
141#
142# Platform support
143#
144CONFIG_PPC_MULTIPLATFORM=y
145# CONFIG_PPC_82xx is not set
146# CONFIG_PPC_83xx is not set
147# CONFIG_PPC_86xx is not set
148CONFIG_CLASSIC32=y
149# CONFIG_PPC_CHRP is not set
150# CONFIG_PPC_MPC512x is not set
151# CONFIG_PPC_MPC5121 is not set
152# CONFIG_MPC5121_ADS is not set
153CONFIG_PPC_MPC52xx=y
154CONFIG_PPC_MPC5200_SIMPLE=y
155# CONFIG_PPC_EFIKA is not set
156# CONFIG_PPC_LITE5200 is not set
157# CONFIG_PPC_MPC5200_BUGFIX is not set
158# CONFIG_PPC_MPC5200_GPIO is not set
159# CONFIG_PPC_PMAC is not set
160# CONFIG_PPC_CELL is not set
161# CONFIG_PPC_CELL_NATIVE is not set
162# CONFIG_PQ2ADS is not set
163# CONFIG_EMBEDDED6xx is not set
164# CONFIG_IPIC is not set
165# CONFIG_MPIC is not set
166# CONFIG_MPIC_WEIRD is not set
167# CONFIG_PPC_I8259 is not set
168# CONFIG_PPC_RTAS is not set
169# CONFIG_MMIO_NVRAM is not set
170# CONFIG_PPC_MPC106 is not set
171# CONFIG_PPC_970_NAP is not set
172# CONFIG_PPC_INDIRECT_IO is not set
173# CONFIG_GENERIC_IOMAP is not set
174# CONFIG_CPU_FREQ is not set
175# CONFIG_TAU is not set
176# CONFIG_FSL_ULI1575 is not set
177CONFIG_PPC_BESTCOMM=y
178# CONFIG_PPC_BESTCOMM_ATA is not set
179CONFIG_PPC_BESTCOMM_FEC=y
180# CONFIG_PPC_BESTCOMM_GEN_BD is not set
181
182#
183# Kernel options
184#
185# CONFIG_HIGHMEM is not set
186# CONFIG_TICK_ONESHOT is not set
187# CONFIG_NO_HZ is not set
188# CONFIG_HIGH_RES_TIMERS is not set
189CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
190# CONFIG_HZ_100 is not set
191CONFIG_HZ_250=y
192# CONFIG_HZ_300 is not set
193# CONFIG_HZ_1000 is not set
194CONFIG_HZ=250
195# CONFIG_SCHED_HRTICK is not set
196CONFIG_PREEMPT_NONE=y
197# CONFIG_PREEMPT_VOLUNTARY is not set
198# CONFIG_PREEMPT is not set
199CONFIG_BINFMT_ELF=y
200# CONFIG_BINFMT_MISC is not set
201# CONFIG_IOMMU_HELPER is not set
202CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
203CONFIG_ARCH_HAS_WALK_MEMORY=y
204CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
205# CONFIG_KEXEC is not set
206CONFIG_ARCH_FLATMEM_ENABLE=y
207CONFIG_ARCH_POPULATES_NODE_MAP=y
208CONFIG_SELECT_MEMORY_MODEL=y
209CONFIG_FLATMEM_MANUAL=y
210# CONFIG_DISCONTIGMEM_MANUAL is not set
211# CONFIG_SPARSEMEM_MANUAL is not set
212CONFIG_FLATMEM=y
213CONFIG_FLAT_NODE_MEM_MAP=y
214# CONFIG_SPARSEMEM_STATIC is not set
215# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
216CONFIG_PAGEFLAGS_EXTENDED=y
217CONFIG_SPLIT_PTLOCK_CPUS=4
218# CONFIG_RESOURCES_64BIT is not set
219CONFIG_ZONE_DMA_FLAG=1
220CONFIG_BOUNCE=y
221CONFIG_VIRT_TO_BUS=y
222CONFIG_FORCE_MAX_ZONEORDER=11
223CONFIG_PROC_DEVICETREE=y
224# CONFIG_CMDLINE_BOOL is not set
225CONFIG_PM=y
226# CONFIG_PM_LEGACY is not set
227# CONFIG_PM_DEBUG is not set
228CONFIG_SECCOMP=y
229CONFIG_ISA_DMA_API=y
230
231#
232# Bus options
233#
234CONFIG_ZONE_DMA=y
235CONFIG_GENERIC_ISA_DMA=y
236CONFIG_FSL_SOC=y
237# CONFIG_PCI is not set
238# CONFIG_PCI_DOMAINS is not set
239# CONFIG_PCI_SYSCALL is not set
240# CONFIG_ARCH_SUPPORTS_MSI is not set
241# CONFIG_PCCARD is not set
242# CONFIG_HAS_RAPIDIO is not set
243
244#
245# Advanced setup
246#
247# CONFIG_ADVANCED_OPTIONS is not set
248
249#
250# Default settings for advanced configuration options are used
251#
252CONFIG_LOWMEM_SIZE=0x30000000
253CONFIG_PAGE_OFFSET=0xc0000000
254CONFIG_KERNEL_START=0xc0000000
255CONFIG_PHYSICAL_START=0x00000000
256CONFIG_TASK_SIZE=0xc0000000
257
258#
259# Networking
260#
261CONFIG_NET=y
262
263#
264# Networking options
265#
266CONFIG_PACKET=y
267# CONFIG_PACKET_MMAP is not set
268CONFIG_UNIX=y
269CONFIG_XFRM=y
270CONFIG_XFRM_USER=y
271# CONFIG_XFRM_SUB_POLICY is not set
272# CONFIG_XFRM_MIGRATE is not set
273# CONFIG_XFRM_STATISTICS is not set
274# CONFIG_NET_KEY is not set
275CONFIG_INET=y
276CONFIG_IP_MULTICAST=y
277# CONFIG_IP_ADVANCED_ROUTER is not set
278CONFIG_IP_FIB_HASH=y
279CONFIG_IP_PNP=y
280CONFIG_IP_PNP_DHCP=y
281CONFIG_IP_PNP_BOOTP=y
282# CONFIG_IP_PNP_RARP is not set
283# CONFIG_NET_IPIP is not set
284# CONFIG_NET_IPGRE is not set
285# CONFIG_IP_MROUTE is not set
286# CONFIG_ARPD is not set
287CONFIG_SYN_COOKIES=y
288# CONFIG_INET_AH is not set
289# CONFIG_INET_ESP is not set
290# CONFIG_INET_IPCOMP is not set
291# CONFIG_INET_XFRM_TUNNEL is not set
292# CONFIG_INET_TUNNEL is not set
293CONFIG_INET_XFRM_MODE_TRANSPORT=y
294CONFIG_INET_XFRM_MODE_TUNNEL=y
295CONFIG_INET_XFRM_MODE_BEET=y
296# CONFIG_INET_LRO is not set
297CONFIG_INET_DIAG=y
298CONFIG_INET_TCP_DIAG=y
299# CONFIG_TCP_CONG_ADVANCED is not set
300CONFIG_TCP_CONG_CUBIC=y
301CONFIG_DEFAULT_TCP_CONG="cubic"
302# CONFIG_TCP_MD5SIG is not set
303# CONFIG_IPV6 is not set
304# CONFIG_NETWORK_SECMARK is not set
305# CONFIG_NETFILTER is not set
306# CONFIG_IP_DCCP is not set
307# CONFIG_IP_SCTP is not set
308# CONFIG_TIPC is not set
309# CONFIG_ATM is not set
310# CONFIG_BRIDGE is not set
311# CONFIG_VLAN_8021Q is not set
312# CONFIG_DECNET is not set
313# CONFIG_LLC2 is not set
314# CONFIG_IPX is not set
315# CONFIG_ATALK is not set
316# CONFIG_X25 is not set
317# CONFIG_LAPB is not set
318# CONFIG_ECONET is not set
319# CONFIG_WAN_ROUTER is not set
320# CONFIG_NET_SCHED is not set
321
322#
323# Network testing
324#
325# CONFIG_NET_PKTGEN is not set
326# CONFIG_HAMRADIO is not set
327# CONFIG_CAN is not set
328# CONFIG_IRDA is not set
329# CONFIG_BT is not set
330# CONFIG_AF_RXRPC is not set
331
332#
333# Wireless
334#
335# CONFIG_CFG80211 is not set
336# CONFIG_WIRELESS_EXT is not set
337# CONFIG_MAC80211 is not set
338# CONFIG_IEEE80211 is not set
339# CONFIG_RFKILL is not set
340# CONFIG_NET_9P is not set
341
342#
343# Device Drivers
344#
345
346#
347# Generic Driver Options
348#
349CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
350CONFIG_STANDALONE=y
351CONFIG_PREVENT_FIRMWARE_BUILD=y
352# CONFIG_FW_LOADER is not set
353# CONFIG_DEBUG_DRIVER is not set
354# CONFIG_DEBUG_DEVRES is not set
355# CONFIG_SYS_HYPERVISOR is not set
356# CONFIG_CONNECTOR is not set
357CONFIG_MTD=y
358# CONFIG_MTD_DEBUG is not set
359# CONFIG_MTD_CONCAT is not set
360CONFIG_MTD_PARTITIONS=y
361# CONFIG_MTD_REDBOOT_PARTS is not set
362CONFIG_MTD_CMDLINE_PARTS=y
363# CONFIG_MTD_OF_PARTS is not set
364# CONFIG_MTD_AR7_PARTS is not set
365
366#
367# User Modules And Translation Layers
368#
369CONFIG_MTD_CHAR=y
370CONFIG_MTD_BLKDEVS=y
371CONFIG_MTD_BLOCK=y
372# CONFIG_FTL is not set
373# CONFIG_NFTL is not set
374# CONFIG_INFTL is not set
375# CONFIG_RFD_FTL is not set
376# CONFIG_SSFDC is not set
377# CONFIG_MTD_OOPS is not set
378
379#
380# RAM/ROM/Flash chip drivers
381#
382CONFIG_MTD_CFI=y
383# CONFIG_MTD_JEDECPROBE is not set
384CONFIG_MTD_GEN_PROBE=y
385# CONFIG_MTD_CFI_ADV_OPTIONS is not set
386CONFIG_MTD_MAP_BANK_WIDTH_1=y
387CONFIG_MTD_MAP_BANK_WIDTH_2=y
388CONFIG_MTD_MAP_BANK_WIDTH_4=y
389# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
390# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
391# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
392CONFIG_MTD_CFI_I1=y
393CONFIG_MTD_CFI_I2=y
394# CONFIG_MTD_CFI_I4 is not set
395# CONFIG_MTD_CFI_I8 is not set
396# CONFIG_MTD_CFI_INTELEXT is not set
397CONFIG_MTD_CFI_AMDSTD=y
398# CONFIG_MTD_CFI_STAA is not set
399CONFIG_MTD_CFI_UTIL=y
400# CONFIG_MTD_RAM is not set
401# CONFIG_MTD_ROM is not set
402# CONFIG_MTD_ABSENT is not set
403
404#
405# Mapping drivers for chip access
406#
407# CONFIG_MTD_COMPLEX_MAPPINGS is not set
408# CONFIG_MTD_PHYSMAP is not set
409CONFIG_MTD_PHYSMAP_OF=y
410# CONFIG_MTD_PLATRAM is not set
411
412#
413# Self-contained MTD device drivers
414#
415# CONFIG_MTD_SLRAM is not set
416# CONFIG_MTD_PHRAM is not set
417# CONFIG_MTD_MTDRAM is not set
418# CONFIG_MTD_BLOCK2MTD is not set
419
420#
421# Disk-On-Chip Device Drivers
422#
423# CONFIG_MTD_DOC2000 is not set
424# CONFIG_MTD_DOC2001 is not set
425# CONFIG_MTD_DOC2001PLUS is not set
426# CONFIG_MTD_NAND is not set
427# CONFIG_MTD_ONENAND is not set
428
429#
430# UBI - Unsorted block images
431#
432# CONFIG_MTD_UBI is not set
433CONFIG_OF_DEVICE=y
434CONFIG_OF_I2C=y
435# CONFIG_PARPORT is not set
436CONFIG_BLK_DEV=y
437# CONFIG_BLK_DEV_FD is not set
438# CONFIG_BLK_DEV_COW_COMMON is not set
439CONFIG_BLK_DEV_LOOP=y
440# CONFIG_BLK_DEV_CRYPTOLOOP is not set
441# CONFIG_BLK_DEV_NBD is not set
442# CONFIG_BLK_DEV_UB is not set
443CONFIG_BLK_DEV_RAM=y
444CONFIG_BLK_DEV_RAM_COUNT=16
445CONFIG_BLK_DEV_RAM_SIZE=32768
446# CONFIG_BLK_DEV_XIP is not set
447# CONFIG_CDROM_PKTCDVD is not set
448# CONFIG_ATA_OVER_ETH is not set
449# CONFIG_MISC_DEVICES is not set
450CONFIG_HAVE_IDE=y
451# CONFIG_IDE is not set
452
453#
454# SCSI device support
455#
456# CONFIG_RAID_ATTRS is not set
457CONFIG_SCSI=y
458CONFIG_SCSI_DMA=y
459# CONFIG_SCSI_TGT is not set
460# CONFIG_SCSI_NETLINK is not set
461CONFIG_SCSI_PROC_FS=y
462
463#
464# SCSI support type (disk, tape, CD-ROM)
465#
466CONFIG_BLK_DEV_SD=y
467# CONFIG_CHR_DEV_ST is not set
468# CONFIG_CHR_DEV_OSST is not set
469# CONFIG_BLK_DEV_SR is not set
470CONFIG_CHR_DEV_SG=y
471# CONFIG_CHR_DEV_SCH is not set
472
473#
474# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
475#
476# CONFIG_SCSI_MULTI_LUN is not set
477# CONFIG_SCSI_CONSTANTS is not set
478# CONFIG_SCSI_LOGGING is not set
479# CONFIG_SCSI_SCAN_ASYNC is not set
480
481#
482# SCSI Transports
483#
484# CONFIG_SCSI_SPI_ATTRS is not set
485# CONFIG_SCSI_FC_ATTRS is not set
486# CONFIG_SCSI_ISCSI_ATTRS is not set
487# CONFIG_SCSI_SAS_LIBSAS is not set
488# CONFIG_SCSI_SRP_ATTRS is not set
489# CONFIG_SCSI_LOWLEVEL is not set
490# CONFIG_ATA is not set
491# CONFIG_MD is not set
492# CONFIG_MACINTOSH_DRIVERS is not set
493CONFIG_NETDEVICES=y
494# CONFIG_NETDEVICES_MULTIQUEUE is not set
495# CONFIG_DUMMY is not set
496# CONFIG_BONDING is not set
497# CONFIG_MACVLAN is not set
498# CONFIG_EQUALIZER is not set
499# CONFIG_TUN is not set
500# CONFIG_VETH is not set
501CONFIG_PHYLIB=y
502
503#
504# MII PHY device drivers
505#
506# CONFIG_MARVELL_PHY is not set
507# CONFIG_DAVICOM_PHY is not set
508# CONFIG_QSEMI_PHY is not set
509CONFIG_LXT_PHY=y
510# CONFIG_CICADA_PHY is not set
511# CONFIG_VITESSE_PHY is not set
512# CONFIG_SMSC_PHY is not set
513# CONFIG_BROADCOM_PHY is not set
514# CONFIG_ICPLUS_PHY is not set
515# CONFIG_REALTEK_PHY is not set
516# CONFIG_FIXED_PHY is not set
517# CONFIG_MDIO_BITBANG is not set
518CONFIG_NET_ETHERNET=y
519# CONFIG_MII is not set
520# CONFIG_IBM_NEW_EMAC_ZMII is not set
521# CONFIG_IBM_NEW_EMAC_RGMII is not set
522# CONFIG_IBM_NEW_EMAC_TAH is not set
523# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
524# CONFIG_B44 is not set
525CONFIG_FEC_MPC52xx=y
526CONFIG_FEC_MPC52xx_MDIO=y
527# CONFIG_NETDEV_1000 is not set
528# CONFIG_NETDEV_10000 is not set
529
530#
531# Wireless LAN
532#
533# CONFIG_WLAN_PRE80211 is not set
534# CONFIG_WLAN_80211 is not set
535# CONFIG_IWLWIFI is not set
536# CONFIG_IWLWIFI_LEDS is not set
537
538#
539# USB Network Adapters
540#
541# CONFIG_USB_CATC is not set
542# CONFIG_USB_KAWETH is not set
543# CONFIG_USB_PEGASUS is not set
544# CONFIG_USB_RTL8150 is not set
545# CONFIG_USB_USBNET is not set
546# CONFIG_WAN is not set
547# CONFIG_PPP is not set
548# CONFIG_SLIP is not set
549# CONFIG_NETCONSOLE is not set
550# CONFIG_NETPOLL is not set
551# CONFIG_NET_POLL_CONTROLLER is not set
552# CONFIG_ISDN is not set
553# CONFIG_PHONE is not set
554
555#
556# Input device support
557#
558# CONFIG_INPUT is not set
559
560#
561# Hardware I/O ports
562#
563# CONFIG_SERIO is not set
564# CONFIG_GAMEPORT is not set
565
566#
567# Character devices
568#
569# CONFIG_VT is not set
570# CONFIG_SERIAL_NONSTANDARD is not set
571
572#
573# Serial drivers
574#
575# CONFIG_SERIAL_8250 is not set
576
577#
578# Non-8250 serial port support
579#
580# CONFIG_SERIAL_UARTLITE is not set
581CONFIG_SERIAL_CORE=y
582CONFIG_SERIAL_CORE_CONSOLE=y
583CONFIG_SERIAL_MPC52xx=y
584CONFIG_SERIAL_MPC52xx_CONSOLE=y
585CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=57600
586CONFIG_UNIX98_PTYS=y
587CONFIG_LEGACY_PTYS=y
588CONFIG_LEGACY_PTY_COUNT=256
589# CONFIG_IPMI_HANDLER is not set
590# CONFIG_HW_RANDOM is not set
591# CONFIG_NVRAM is not set
592# CONFIG_GEN_RTC is not set
593# CONFIG_R3964 is not set
594# CONFIG_RAW_DRIVER is not set
595# CONFIG_TCG_TPM is not set
596CONFIG_I2C=y
597CONFIG_I2C_BOARDINFO=y
598CONFIG_I2C_CHARDEV=y
599
600#
601# I2C Hardware Bus support
602#
603CONFIG_I2C_MPC=y
604# CONFIG_I2C_OCORES is not set
605# CONFIG_I2C_PARPORT_LIGHT is not set
606# CONFIG_I2C_SIMTEC is not set
607# CONFIG_I2C_TAOS_EVM is not set
608# CONFIG_I2C_TINY_USB is not set
609# CONFIG_I2C_PCA_PLATFORM is not set
610
611#
612# Miscellaneous I2C Chip support
613#
614# CONFIG_DS1682 is not set
615# CONFIG_SENSORS_EEPROM is not set
616# CONFIG_SENSORS_PCF8574 is not set
617# CONFIG_PCF8575 is not set
618# CONFIG_SENSORS_PCF8591 is not set
619# CONFIG_SENSORS_MAX6875 is not set
620# CONFIG_SENSORS_TSL2550 is not set
621# CONFIG_I2C_DEBUG_CORE is not set
622# CONFIG_I2C_DEBUG_ALGO is not set
623# CONFIG_I2C_DEBUG_BUS is not set
624# CONFIG_I2C_DEBUG_CHIP is not set
625# CONFIG_SPI is not set
626# CONFIG_W1 is not set
627# CONFIG_POWER_SUPPLY is not set
628# CONFIG_HWMON is not set
629# CONFIG_THERMAL is not set
630CONFIG_WATCHDOG=y
631# CONFIG_WATCHDOG_NOWAYOUT is not set
632
633#
634# Watchdog Device Drivers
635#
636# CONFIG_SOFT_WATCHDOG is not set
637# CONFIG_MPC5200_WDT is not set
638
639#
640# USB-based Watchdog Cards
641#
642# CONFIG_USBPCWATCHDOG is not set
643
644#
645# Sonics Silicon Backplane
646#
647CONFIG_SSB_POSSIBLE=y
648# CONFIG_SSB is not set
649
650#
651# Multifunction device drivers
652#
653# CONFIG_MFD_SM501 is not set
654# CONFIG_HTC_PASIC3 is not set
655
656#
657# Multimedia devices
658#
659# CONFIG_VIDEO_DEV is not set
660# CONFIG_DVB_CORE is not set
661# CONFIG_DAB is not set
662
663#
664# Graphics support
665#
666# CONFIG_VGASTATE is not set
667# CONFIG_VIDEO_OUTPUT_CONTROL is not set
668# CONFIG_FB is not set
669# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
670
671#
672# Display device support
673#
674# CONFIG_DISPLAY_SUPPORT is not set
675
676#
677# Sound
678#
679# CONFIG_SOUND is not set
680CONFIG_USB_SUPPORT=y
681CONFIG_USB_ARCH_HAS_HCD=y
682CONFIG_USB_ARCH_HAS_OHCI=y
683# CONFIG_USB_ARCH_HAS_EHCI is not set
684CONFIG_USB=y
685# CONFIG_USB_DEBUG is not set
686# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
687
688#
689# Miscellaneous USB options
690#
691CONFIG_USB_DEVICEFS=y
692# CONFIG_USB_DEVICE_CLASS is not set
693# CONFIG_USB_DYNAMIC_MINORS is not set
694# CONFIG_USB_SUSPEND is not set
695# CONFIG_USB_OTG is not set
696# CONFIG_USB_OTG_WHITELIST is not set
697# CONFIG_USB_OTG_BLACKLIST_HUB is not set
698
699#
700# USB Host Controller Drivers
701#
702# CONFIG_USB_ISP116X_HCD is not set
703CONFIG_USB_OHCI_HCD=y
704CONFIG_USB_OHCI_HCD_PPC_SOC=y
705CONFIG_USB_OHCI_HCD_PPC_OF=y
706CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
707# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
708CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
709CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
710# CONFIG_USB_OHCI_LITTLE_ENDIAN is not set
711# CONFIG_USB_SL811_HCD is not set
712# CONFIG_USB_R8A66597_HCD is not set
713
714#
715# USB Device Class drivers
716#
717# CONFIG_USB_ACM is not set
718# CONFIG_USB_PRINTER is not set
719
720#
721# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
722#
723
724#
725# may also be needed; see USB_STORAGE Help for more information
726#
727CONFIG_USB_STORAGE=y
728# CONFIG_USB_STORAGE_DEBUG is not set
729# CONFIG_USB_STORAGE_DATAFAB is not set
730# CONFIG_USB_STORAGE_FREECOM is not set
731# CONFIG_USB_STORAGE_ISD200 is not set
732# CONFIG_USB_STORAGE_DPCM is not set
733# CONFIG_USB_STORAGE_USBAT is not set
734# CONFIG_USB_STORAGE_SDDR09 is not set
735# CONFIG_USB_STORAGE_SDDR55 is not set
736# CONFIG_USB_STORAGE_JUMPSHOT is not set
737# CONFIG_USB_STORAGE_ALAUDA is not set
738# CONFIG_USB_STORAGE_KARMA is not set
739# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
740# CONFIG_USB_LIBUSUAL is not set
741
742#
743# USB Imaging devices
744#
745# CONFIG_USB_MDC800 is not set
746# CONFIG_USB_MICROTEK is not set
747# CONFIG_USB_MON is not set
748
749#
750# USB port drivers
751#
752# CONFIG_USB_SERIAL is not set
753
754#
755# USB Miscellaneous drivers
756#
757# CONFIG_USB_EMI62 is not set
758# CONFIG_USB_EMI26 is not set
759# CONFIG_USB_ADUTUX is not set
760# CONFIG_USB_AUERSWALD is not set
761# CONFIG_USB_RIO500 is not set
762# CONFIG_USB_LEGOTOWER is not set
763# CONFIG_USB_LCD is not set
764# CONFIG_USB_BERRY_CHARGE is not set
765# CONFIG_USB_LED is not set
766# CONFIG_USB_CYPRESS_CY7C63 is not set
767# CONFIG_USB_CYTHERM is not set
768# CONFIG_USB_PHIDGET is not set
769# CONFIG_USB_IDMOUSE is not set
770# CONFIG_USB_FTDI_ELAN is not set
771# CONFIG_USB_APPLEDISPLAY is not set
772# CONFIG_USB_LD is not set
773# CONFIG_USB_TRANCEVIBRATOR is not set
774# CONFIG_USB_IOWARRIOR is not set
775# CONFIG_USB_TEST is not set
776# CONFIG_USB_GADGET is not set
777# CONFIG_MMC is not set
778# CONFIG_MEMSTICK is not set
779# CONFIG_NEW_LEDS is not set
780# CONFIG_EDAC is not set
781# CONFIG_RTC_CLASS is not set
782# CONFIG_DMADEVICES is not set
783# CONFIG_UIO is not set
784
785#
786# File systems
787#
788CONFIG_EXT2_FS=y
789# CONFIG_EXT2_FS_XATTR is not set
790# CONFIG_EXT2_FS_XIP is not set
791CONFIG_EXT3_FS=y
792CONFIG_EXT3_FS_XATTR=y
793# CONFIG_EXT3_FS_POSIX_ACL is not set
794# CONFIG_EXT3_FS_SECURITY is not set
795# CONFIG_EXT4DEV_FS is not set
796CONFIG_JBD=y
797CONFIG_FS_MBCACHE=y
798# CONFIG_REISERFS_FS is not set
799# CONFIG_JFS_FS is not set
800# CONFIG_FS_POSIX_ACL is not set
801# CONFIG_XFS_FS is not set
802# CONFIG_OCFS2_FS is not set
803CONFIG_DNOTIFY=y
804CONFIG_INOTIFY=y
805CONFIG_INOTIFY_USER=y
806# CONFIG_QUOTA is not set
807# CONFIG_AUTOFS_FS is not set
808# CONFIG_AUTOFS4_FS is not set
809# CONFIG_FUSE_FS is not set
810
811#
812# CD-ROM/DVD Filesystems
813#
814# CONFIG_ISO9660_FS is not set
815# CONFIG_UDF_FS is not set
816
817#
818# DOS/FAT/NT Filesystems
819#
820CONFIG_FAT_FS=y
821CONFIG_MSDOS_FS=y
822CONFIG_VFAT_FS=y
823CONFIG_FAT_DEFAULT_CODEPAGE=437
824CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
825# CONFIG_NTFS_FS is not set
826
827#
828# Pseudo filesystems
829#
830CONFIG_PROC_FS=y
831CONFIG_PROC_KCORE=y
832CONFIG_PROC_SYSCTL=y
833CONFIG_SYSFS=y
834CONFIG_TMPFS=y
835# CONFIG_TMPFS_POSIX_ACL is not set
836# CONFIG_HUGETLB_PAGE is not set
837# CONFIG_CONFIGFS_FS is not set
838
839#
840# Miscellaneous filesystems
841#
842# CONFIG_ADFS_FS is not set
843# CONFIG_AFFS_FS is not set
844# CONFIG_HFS_FS is not set
845# CONFIG_HFSPLUS_FS is not set
846# CONFIG_BEFS_FS is not set
847# CONFIG_BFS_FS is not set
848# CONFIG_EFS_FS is not set
849CONFIG_JFFS2_FS=y
850CONFIG_JFFS2_FS_DEBUG=0
851CONFIG_JFFS2_FS_WRITEBUFFER=y
852# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
853# CONFIG_JFFS2_SUMMARY is not set
854# CONFIG_JFFS2_FS_XATTR is not set
855# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
856CONFIG_JFFS2_ZLIB=y
857# CONFIG_JFFS2_LZO is not set
858CONFIG_JFFS2_RTIME=y
859# CONFIG_JFFS2_RUBIN is not set
860CONFIG_CRAMFS=y
861# CONFIG_VXFS_FS is not set
862# CONFIG_MINIX_FS is not set
863# CONFIG_HPFS_FS is not set
864# CONFIG_QNX4FS_FS is not set
865# CONFIG_ROMFS_FS is not set
866# CONFIG_SYSV_FS is not set
867# CONFIG_UFS_FS is not set
868CONFIG_NETWORK_FILESYSTEMS=y
869CONFIG_NFS_FS=y
870CONFIG_NFS_V3=y
871# CONFIG_NFS_V3_ACL is not set
872CONFIG_NFS_V4=y
873# CONFIG_NFSD is not set
874CONFIG_ROOT_NFS=y
875CONFIG_LOCKD=y
876CONFIG_LOCKD_V4=y
877CONFIG_NFS_COMMON=y
878CONFIG_SUNRPC=y
879CONFIG_SUNRPC_GSS=y
880# CONFIG_SUNRPC_BIND34 is not set
881CONFIG_RPCSEC_GSS_KRB5=y
882# CONFIG_RPCSEC_GSS_SPKM3 is not set
883# CONFIG_SMB_FS is not set
884# CONFIG_CIFS is not set
885# CONFIG_NCP_FS is not set
886# CONFIG_CODA_FS is not set
887# CONFIG_AFS_FS is not set
888
889#
890# Partition Types
891#
892CONFIG_PARTITION_ADVANCED=y
893# CONFIG_ACORN_PARTITION is not set
894# CONFIG_OSF_PARTITION is not set
895# CONFIG_AMIGA_PARTITION is not set
896# CONFIG_ATARI_PARTITION is not set
897# CONFIG_MAC_PARTITION is not set
898CONFIG_MSDOS_PARTITION=y
899# CONFIG_BSD_DISKLABEL is not set
900# CONFIG_MINIX_SUBPARTITION is not set
901# CONFIG_SOLARIS_X86_PARTITION is not set
902# CONFIG_UNIXWARE_DISKLABEL is not set
903# CONFIG_LDM_PARTITION is not set
904# CONFIG_SGI_PARTITION is not set
905# CONFIG_ULTRIX_PARTITION is not set
906# CONFIG_SUN_PARTITION is not set
907# CONFIG_KARMA_PARTITION is not set
908# CONFIG_EFI_PARTITION is not set
909# CONFIG_SYSV68_PARTITION is not set
910CONFIG_NLS=y
911CONFIG_NLS_DEFAULT="iso8859-1"
912CONFIG_NLS_CODEPAGE_437=y
913# CONFIG_NLS_CODEPAGE_737 is not set
914# CONFIG_NLS_CODEPAGE_775 is not set
915# CONFIG_NLS_CODEPAGE_850 is not set
916# CONFIG_NLS_CODEPAGE_852 is not set
917# CONFIG_NLS_CODEPAGE_855 is not set
918# CONFIG_NLS_CODEPAGE_857 is not set
919# CONFIG_NLS_CODEPAGE_860 is not set
920# CONFIG_NLS_CODEPAGE_861 is not set
921# CONFIG_NLS_CODEPAGE_862 is not set
922# CONFIG_NLS_CODEPAGE_863 is not set
923# CONFIG_NLS_CODEPAGE_864 is not set
924# CONFIG_NLS_CODEPAGE_865 is not set
925# CONFIG_NLS_CODEPAGE_866 is not set
926# CONFIG_NLS_CODEPAGE_869 is not set
927# CONFIG_NLS_CODEPAGE_936 is not set
928# CONFIG_NLS_CODEPAGE_950 is not set
929# CONFIG_NLS_CODEPAGE_932 is not set
930# CONFIG_NLS_CODEPAGE_949 is not set
931# CONFIG_NLS_CODEPAGE_874 is not set
932# CONFIG_NLS_ISO8859_8 is not set
933# CONFIG_NLS_CODEPAGE_1250 is not set
934# CONFIG_NLS_CODEPAGE_1251 is not set
935# CONFIG_NLS_ASCII is not set
936CONFIG_NLS_ISO8859_1=y
937# CONFIG_NLS_ISO8859_2 is not set
938# CONFIG_NLS_ISO8859_3 is not set
939# CONFIG_NLS_ISO8859_4 is not set
940# CONFIG_NLS_ISO8859_5 is not set
941# CONFIG_NLS_ISO8859_6 is not set
942# CONFIG_NLS_ISO8859_7 is not set
943# CONFIG_NLS_ISO8859_9 is not set
944# CONFIG_NLS_ISO8859_13 is not set
945# CONFIG_NLS_ISO8859_14 is not set
946# CONFIG_NLS_ISO8859_15 is not set
947# CONFIG_NLS_KOI8_R is not set
948# CONFIG_NLS_KOI8_U is not set
949# CONFIG_NLS_UTF8 is not set
950# CONFIG_DLM is not set
951
952#
953# Library routines
954#
955CONFIG_BITREVERSE=y
956# CONFIG_GENERIC_FIND_FIRST_BIT is not set
957# CONFIG_CRC_CCITT is not set
958# CONFIG_CRC16 is not set
959# CONFIG_CRC_ITU_T is not set
960CONFIG_CRC32=y
961# CONFIG_CRC7 is not set
962# CONFIG_LIBCRC32C is not set
963CONFIG_ZLIB_INFLATE=y
964CONFIG_ZLIB_DEFLATE=y
965CONFIG_PLIST=y
966CONFIG_HAS_IOMEM=y
967CONFIG_HAS_IOPORT=y
968CONFIG_HAS_DMA=y
969CONFIG_HAVE_LMB=y
970
971#
972# Kernel hacking
973#
974CONFIG_PRINTK_TIME=y
975CONFIG_ENABLE_WARN_DEPRECATED=y
976CONFIG_ENABLE_MUST_CHECK=y
977CONFIG_FRAME_WARN=1024
978# CONFIG_MAGIC_SYSRQ is not set
979# CONFIG_UNUSED_SYMBOLS is not set
980# CONFIG_DEBUG_FS is not set
981# CONFIG_HEADERS_CHECK is not set
982CONFIG_DEBUG_KERNEL=y
983# CONFIG_DEBUG_SHIRQ is not set
984CONFIG_DETECT_SOFTLOCKUP=y
985CONFIG_SCHED_DEBUG=y
986# CONFIG_SCHEDSTATS is not set
987# CONFIG_TIMER_STATS is not set
988# CONFIG_SLUB_DEBUG_ON is not set
989# CONFIG_SLUB_STATS is not set
990# CONFIG_DEBUG_RT_MUTEXES is not set
991# CONFIG_RT_MUTEX_TESTER is not set
992# CONFIG_DEBUG_SPINLOCK is not set
993# CONFIG_DEBUG_MUTEXES is not set
994# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
995# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
996# CONFIG_DEBUG_KOBJECT is not set
997# CONFIG_DEBUG_BUGVERBOSE is not set
998# CONFIG_DEBUG_INFO is not set
999# CONFIG_DEBUG_VM is not set
1000# CONFIG_DEBUG_WRITECOUNT is not set
1001# CONFIG_DEBUG_LIST is not set
1002# CONFIG_DEBUG_SG is not set
1003# CONFIG_BOOT_PRINTK_DELAY is not set
1004# CONFIG_BACKTRACE_SELF_TEST is not set
1005# CONFIG_FAULT_INJECTION is not set
1006# CONFIG_SAMPLES is not set
1007# CONFIG_DEBUG_STACKOVERFLOW is not set
1008# CONFIG_DEBUG_STACK_USAGE is not set
1009# CONFIG_DEBUG_PAGEALLOC is not set
1010# CONFIG_DEBUGGER is not set
1011# CONFIG_IRQSTACKS is not set
1012# CONFIG_BDI_SWITCH is not set
1013# CONFIG_BOOTX_TEXT is not set
1014# CONFIG_PPC_EARLY_DEBUG is not set
1015
1016#
1017# Security options
1018#
1019# CONFIG_KEYS is not set
1020# CONFIG_SECURITY is not set
1021# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1022CONFIG_CRYPTO=y
1023
1024#
1025# Crypto core or helper
1026#
1027CONFIG_CRYPTO_ALGAPI=y
1028CONFIG_CRYPTO_BLKCIPHER=y
1029CONFIG_CRYPTO_MANAGER=y
1030# CONFIG_CRYPTO_GF128MUL is not set
1031# CONFIG_CRYPTO_NULL is not set
1032# CONFIG_CRYPTO_CRYPTD is not set
1033# CONFIG_CRYPTO_AUTHENC is not set
1034
1035#
1036# Authenticated Encryption with Associated Data
1037#
1038# CONFIG_CRYPTO_CCM is not set
1039# CONFIG_CRYPTO_GCM is not set
1040# CONFIG_CRYPTO_SEQIV is not set
1041
1042#
1043# Block modes
1044#
1045CONFIG_CRYPTO_CBC=y
1046# CONFIG_CRYPTO_CTR is not set
1047# CONFIG_CRYPTO_CTS is not set
1048CONFIG_CRYPTO_ECB=y
1049# CONFIG_CRYPTO_LRW is not set
1050CONFIG_CRYPTO_PCBC=y
1051# CONFIG_CRYPTO_XTS is not set
1052
1053#
1054# Hash modes
1055#
1056# CONFIG_CRYPTO_HMAC is not set
1057# CONFIG_CRYPTO_XCBC is not set
1058
1059#
1060# Digest
1061#
1062# CONFIG_CRYPTO_CRC32C is not set
1063# CONFIG_CRYPTO_MD4 is not set
1064CONFIG_CRYPTO_MD5=y
1065# CONFIG_CRYPTO_MICHAEL_MIC is not set
1066# CONFIG_CRYPTO_SHA1 is not set
1067# CONFIG_CRYPTO_SHA256 is not set
1068# CONFIG_CRYPTO_SHA512 is not set
1069# CONFIG_CRYPTO_TGR192 is not set
1070# CONFIG_CRYPTO_WP512 is not set
1071
1072#
1073# Ciphers
1074#
1075# CONFIG_CRYPTO_AES is not set
1076# CONFIG_CRYPTO_ANUBIS is not set
1077# CONFIG_CRYPTO_ARC4 is not set
1078# CONFIG_CRYPTO_BLOWFISH is not set
1079# CONFIG_CRYPTO_CAMELLIA is not set
1080# CONFIG_CRYPTO_CAST5 is not set
1081# CONFIG_CRYPTO_CAST6 is not set
1082CONFIG_CRYPTO_DES=y
1083# CONFIG_CRYPTO_FCRYPT is not set
1084# CONFIG_CRYPTO_KHAZAD is not set
1085# CONFIG_CRYPTO_SALSA20 is not set
1086# CONFIG_CRYPTO_SEED is not set
1087# CONFIG_CRYPTO_SERPENT is not set
1088# CONFIG_CRYPTO_TEA is not set
1089# CONFIG_CRYPTO_TWOFISH is not set
1090
1091#
1092# Compression
1093#
1094# CONFIG_CRYPTO_DEFLATE is not set
1095# CONFIG_CRYPTO_LZO is not set
1096CONFIG_CRYPTO_HW=y
1097CONFIG_PPC_CLOCK=y
1098CONFIG_PPC_LIB_RHEAP=y
1099# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/configs/52xx/lite5200b_defconfig b/arch/powerpc/configs/52xx/lite5200b_defconfig
new file mode 100644
index 000000000000..1a8a250fa11b
--- /dev/null
+++ b/arch/powerpc/configs/52xx/lite5200b_defconfig
@@ -0,0 +1,1049 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Tue Apr 29 07:12:56 2008
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11CONFIG_6xx=y
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18# CONFIG_ALTIVEC is not set
19CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_32=y
21# CONFIG_PPC_MM_SLICES is not set
22# CONFIG_SMP is not set
23CONFIG_PPC32=y
24CONFIG_WORD_SIZE=32
25CONFIG_PPC_MERGE=y
26CONFIG_MMU=y
27CONFIG_GENERIC_CMOS_UPDATE=y
28CONFIG_GENERIC_TIME=y
29CONFIG_GENERIC_TIME_VSYSCALL=y
30CONFIG_GENERIC_CLOCKEVENTS=y
31CONFIG_GENERIC_HARDIRQS=y
32# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
33CONFIG_IRQ_PER_CPU=y
34CONFIG_STACKTRACE_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y
43CONFIG_EARLY_PRINTK=y
44CONFIG_GENERIC_NVRAM=y
45CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
46CONFIG_ARCH_MAY_HAVE_PC_FDC=y
47CONFIG_PPC_OF=y
48CONFIG_OF=y
49# CONFIG_PPC_UDBG_16550 is not set
50# CONFIG_GENERIC_TBSYNC is not set
51CONFIG_AUDIT_ARCH=y
52CONFIG_GENERIC_BUG=y
53CONFIG_DEFAULT_UIMAGE=y
54CONFIG_ARCH_SUSPEND_POSSIBLE=y
55# CONFIG_PPC_DCR_NATIVE is not set
56# CONFIG_PPC_DCR_MMIO is not set
57CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
58
59#
60# General setup
61#
62CONFIG_EXPERIMENTAL=y
63CONFIG_BROKEN_ON_SMP=y
64CONFIG_INIT_ENV_ARG_LIMIT=32
65CONFIG_LOCALVERSION=""
66CONFIG_LOCALVERSION_AUTO=y
67CONFIG_SWAP=y
68CONFIG_SYSVIPC=y
69CONFIG_SYSVIPC_SYSCTL=y
70# CONFIG_POSIX_MQUEUE is not set
71# CONFIG_BSD_PROCESS_ACCT is not set
72# CONFIG_TASKSTATS is not set
73# CONFIG_AUDIT is not set
74# CONFIG_IKCONFIG is not set
75CONFIG_LOG_BUF_SHIFT=14
76# CONFIG_CGROUPS is not set
77CONFIG_GROUP_SCHED=y
78# CONFIG_FAIR_GROUP_SCHED is not set
79# CONFIG_RT_GROUP_SCHED is not set
80CONFIG_USER_SCHED=y
81# CONFIG_CGROUP_SCHED is not set
82CONFIG_SYSFS_DEPRECATED=y
83CONFIG_SYSFS_DEPRECATED_V2=y
84# CONFIG_RELAY is not set
85# CONFIG_NAMESPACES is not set
86CONFIG_BLK_DEV_INITRD=y
87CONFIG_INITRAMFS_SOURCE=""
88# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
89CONFIG_SYSCTL=y
90CONFIG_EMBEDDED=y
91# CONFIG_SYSCTL_SYSCALL is not set
92# CONFIG_KALLSYMS is not set
93CONFIG_HOTPLUG=y
94CONFIG_PRINTK=y
95CONFIG_BUG=y
96CONFIG_ELF_CORE=y
97CONFIG_COMPAT_BRK=y
98CONFIG_BASE_FULL=y
99CONFIG_FUTEX=y
100CONFIG_ANON_INODES=y
101# CONFIG_EPOLL is not set
102CONFIG_SIGNALFD=y
103CONFIG_TIMERFD=y
104CONFIG_EVENTFD=y
105CONFIG_SHMEM=y
106CONFIG_VM_EVENT_COUNTERS=y
107CONFIG_SLUB_DEBUG=y
108# CONFIG_SLAB is not set
109CONFIG_SLUB=y
110# CONFIG_SLOB is not set
111# CONFIG_PROFILING is not set
112# CONFIG_MARKERS is not set
113CONFIG_HAVE_OPROFILE=y
114CONFIG_HAVE_KPROBES=y
115CONFIG_HAVE_KRETPROBES=y
116CONFIG_PROC_PAGE_MONITOR=y
117CONFIG_SLABINFO=y
118CONFIG_RT_MUTEXES=y
119# CONFIG_TINY_SHMEM is not set
120CONFIG_BASE_SMALL=0
121CONFIG_MODULES=y
122CONFIG_MODULE_UNLOAD=y
123# CONFIG_MODULE_FORCE_UNLOAD is not set
124# CONFIG_MODVERSIONS is not set
125# CONFIG_MODULE_SRCVERSION_ALL is not set
126# CONFIG_KMOD is not set
127CONFIG_BLOCK=y
128# CONFIG_LBD is not set
129# CONFIG_BLK_DEV_IO_TRACE is not set
130# CONFIG_LSF is not set
131# CONFIG_BLK_DEV_BSG is not set
132
133#
134# IO Schedulers
135#
136CONFIG_IOSCHED_NOOP=y
137CONFIG_IOSCHED_AS=y
138CONFIG_IOSCHED_DEADLINE=y
139CONFIG_IOSCHED_CFQ=y
140CONFIG_DEFAULT_AS=y
141# CONFIG_DEFAULT_DEADLINE is not set
142# CONFIG_DEFAULT_CFQ is not set
143# CONFIG_DEFAULT_NOOP is not set
144CONFIG_DEFAULT_IOSCHED="anticipatory"
145CONFIG_CLASSIC_RCU=y
146
147#
148# Platform support
149#
150CONFIG_PPC_MULTIPLATFORM=y
151# CONFIG_PPC_82xx is not set
152# CONFIG_PPC_83xx is not set
153# CONFIG_PPC_86xx is not set
154CONFIG_CLASSIC32=y
155# CONFIG_PPC_CHRP is not set
156# CONFIG_PPC_MPC512x is not set
157# CONFIG_PPC_MPC5121 is not set
158# CONFIG_MPC5121_ADS is not set
159CONFIG_PPC_MPC52xx=y
160CONFIG_PPC_MPC5200_SIMPLE=y
161# CONFIG_PPC_EFIKA is not set
162CONFIG_PPC_LITE5200=y
163# CONFIG_PPC_MPC5200_BUGFIX is not set
164# CONFIG_PPC_MPC5200_GPIO is not set
165# CONFIG_PPC_PMAC is not set
166# CONFIG_PPC_CELL is not set
167# CONFIG_PPC_CELL_NATIVE is not set
168# CONFIG_PQ2ADS is not set
169# CONFIG_EMBEDDED6xx is not set
170# CONFIG_IPIC is not set
171# CONFIG_MPIC is not set
172# CONFIG_MPIC_WEIRD is not set
173# CONFIG_PPC_I8259 is not set
174# CONFIG_PPC_RTAS is not set
175# CONFIG_MMIO_NVRAM is not set
176# CONFIG_PPC_MPC106 is not set
177# CONFIG_PPC_970_NAP is not set
178# CONFIG_PPC_INDIRECT_IO is not set
179# CONFIG_GENERIC_IOMAP is not set
180# CONFIG_CPU_FREQ is not set
181# CONFIG_TAU is not set
182# CONFIG_FSL_ULI1575 is not set
183CONFIG_PPC_BESTCOMM=y
184CONFIG_PPC_BESTCOMM_ATA=y
185CONFIG_PPC_BESTCOMM_FEC=y
186CONFIG_PPC_BESTCOMM_GEN_BD=y
187
188#
189# Kernel options
190#
191# CONFIG_HIGHMEM is not set
192CONFIG_TICK_ONESHOT=y
193CONFIG_NO_HZ=y
194CONFIG_HIGH_RES_TIMERS=y
195CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
196# CONFIG_HZ_100 is not set
197CONFIG_HZ_250=y
198# CONFIG_HZ_300 is not set
199# CONFIG_HZ_1000 is not set
200CONFIG_HZ=250
201# CONFIG_SCHED_HRTICK is not set
202CONFIG_PREEMPT_NONE=y
203# CONFIG_PREEMPT_VOLUNTARY is not set
204# CONFIG_PREEMPT is not set
205CONFIG_BINFMT_ELF=y
206# CONFIG_BINFMT_MISC is not set
207# CONFIG_IOMMU_HELPER is not set
208CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
209CONFIG_ARCH_HAS_WALK_MEMORY=y
210CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
211# CONFIG_KEXEC is not set
212CONFIG_ARCH_FLATMEM_ENABLE=y
213CONFIG_ARCH_POPULATES_NODE_MAP=y
214CONFIG_SELECT_MEMORY_MODEL=y
215CONFIG_FLATMEM_MANUAL=y
216# CONFIG_DISCONTIGMEM_MANUAL is not set
217# CONFIG_SPARSEMEM_MANUAL is not set
218CONFIG_FLATMEM=y
219CONFIG_FLAT_NODE_MEM_MAP=y
220# CONFIG_SPARSEMEM_STATIC is not set
221# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
222CONFIG_PAGEFLAGS_EXTENDED=y
223CONFIG_SPLIT_PTLOCK_CPUS=4
224# CONFIG_RESOURCES_64BIT is not set
225CONFIG_ZONE_DMA_FLAG=1
226CONFIG_BOUNCE=y
227CONFIG_VIRT_TO_BUS=y
228CONFIG_FORCE_MAX_ZONEORDER=11
229CONFIG_PROC_DEVICETREE=y
230# CONFIG_CMDLINE_BOOL is not set
231CONFIG_PM=y
232# CONFIG_PM_LEGACY is not set
233# CONFIG_PM_DEBUG is not set
234CONFIG_PM_SLEEP=y
235CONFIG_SUSPEND=y
236CONFIG_SUSPEND_FREEZER=y
237CONFIG_SECCOMP=y
238CONFIG_ISA_DMA_API=y
239
240#
241# Bus options
242#
243CONFIG_ZONE_DMA=y
244CONFIG_GENERIC_ISA_DMA=y
245# CONFIG_PPC_INDIRECT_PCI is not set
246CONFIG_FSL_SOC=y
247CONFIG_PCI=y
248CONFIG_PCI_DOMAINS=y
249CONFIG_PCI_SYSCALL=y
250# CONFIG_PCIEPORTBUS is not set
251CONFIG_ARCH_SUPPORTS_MSI=y
252# CONFIG_PCI_MSI is not set
253CONFIG_PCI_LEGACY=y
254# CONFIG_PCI_DEBUG is not set
255# CONFIG_PCCARD is not set
256# CONFIG_HOTPLUG_PCI is not set
257# CONFIG_HAS_RAPIDIO is not set
258
259#
260# Advanced setup
261#
262# CONFIG_ADVANCED_OPTIONS is not set
263
264#
265# Default settings for advanced configuration options are used
266#
267CONFIG_LOWMEM_SIZE=0x30000000
268CONFIG_PAGE_OFFSET=0xc0000000
269CONFIG_KERNEL_START=0xc0000000
270CONFIG_PHYSICAL_START=0x00000000
271CONFIG_TASK_SIZE=0xc0000000
272
273#
274# Networking
275#
276CONFIG_NET=y
277
278#
279# Networking options
280#
281CONFIG_PACKET=y
282# CONFIG_PACKET_MMAP is not set
283CONFIG_UNIX=y
284CONFIG_XFRM=y
285CONFIG_XFRM_USER=m
286# CONFIG_XFRM_SUB_POLICY is not set
287# CONFIG_XFRM_MIGRATE is not set
288# CONFIG_XFRM_STATISTICS is not set
289# CONFIG_NET_KEY is not set
290CONFIG_INET=y
291CONFIG_IP_MULTICAST=y
292# CONFIG_IP_ADVANCED_ROUTER is not set
293CONFIG_IP_FIB_HASH=y
294CONFIG_IP_PNP=y
295CONFIG_IP_PNP_DHCP=y
296CONFIG_IP_PNP_BOOTP=y
297# CONFIG_IP_PNP_RARP is not set
298# CONFIG_NET_IPIP is not set
299# CONFIG_NET_IPGRE is not set
300# CONFIG_IP_MROUTE is not set
301# CONFIG_ARPD is not set
302CONFIG_SYN_COOKIES=y
303# CONFIG_INET_AH is not set
304# CONFIG_INET_ESP is not set
305# CONFIG_INET_IPCOMP is not set
306# CONFIG_INET_XFRM_TUNNEL is not set
307# CONFIG_INET_TUNNEL is not set
308CONFIG_INET_XFRM_MODE_TRANSPORT=y
309CONFIG_INET_XFRM_MODE_TUNNEL=y
310CONFIG_INET_XFRM_MODE_BEET=y
311# CONFIG_INET_LRO is not set
312CONFIG_INET_DIAG=y
313CONFIG_INET_TCP_DIAG=y
314# CONFIG_TCP_CONG_ADVANCED is not set
315CONFIG_TCP_CONG_CUBIC=y
316CONFIG_DEFAULT_TCP_CONG="cubic"
317# CONFIG_TCP_MD5SIG is not set
318# CONFIG_IPV6 is not set
319# CONFIG_NETWORK_SECMARK is not set
320# CONFIG_NETFILTER is not set
321# CONFIG_IP_DCCP is not set
322# CONFIG_IP_SCTP is not set
323# CONFIG_TIPC is not set
324# CONFIG_ATM is not set
325# CONFIG_BRIDGE is not set
326# CONFIG_VLAN_8021Q is not set
327# CONFIG_DECNET is not set
328# CONFIG_LLC2 is not set
329# CONFIG_IPX is not set
330# CONFIG_ATALK is not set
331# CONFIG_X25 is not set
332# CONFIG_LAPB is not set
333# CONFIG_ECONET is not set
334# CONFIG_WAN_ROUTER is not set
335# CONFIG_NET_SCHED is not set
336
337#
338# Network testing
339#
340# CONFIG_NET_PKTGEN is not set
341# CONFIG_HAMRADIO is not set
342# CONFIG_CAN is not set
343# CONFIG_IRDA is not set
344# CONFIG_BT is not set
345# CONFIG_AF_RXRPC is not set
346
347#
348# Wireless
349#
350# CONFIG_CFG80211 is not set
351# CONFIG_WIRELESS_EXT is not set
352# CONFIG_MAC80211 is not set
353# CONFIG_IEEE80211 is not set
354# CONFIG_RFKILL is not set
355# CONFIG_NET_9P is not set
356
357#
358# Device Drivers
359#
360
361#
362# Generic Driver Options
363#
364CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
365CONFIG_STANDALONE=y
366CONFIG_PREVENT_FIRMWARE_BUILD=y
367# CONFIG_FW_LOADER is not set
368# CONFIG_DEBUG_DRIVER is not set
369# CONFIG_DEBUG_DEVRES is not set
370# CONFIG_SYS_HYPERVISOR is not set
371# CONFIG_CONNECTOR is not set
372# CONFIG_MTD is not set
373CONFIG_OF_DEVICE=y
374CONFIG_OF_I2C=y
375# CONFIG_PARPORT is not set
376CONFIG_BLK_DEV=y
377# CONFIG_BLK_DEV_FD is not set
378# CONFIG_BLK_CPQ_DA is not set
379# CONFIG_BLK_CPQ_CISS_DA is not set
380# CONFIG_BLK_DEV_DAC960 is not set
381# CONFIG_BLK_DEV_UMEM is not set
382# CONFIG_BLK_DEV_COW_COMMON is not set
383CONFIG_BLK_DEV_LOOP=y
384# CONFIG_BLK_DEV_CRYPTOLOOP is not set
385# CONFIG_BLK_DEV_NBD is not set
386# CONFIG_BLK_DEV_SX8 is not set
387CONFIG_BLK_DEV_RAM=y
388CONFIG_BLK_DEV_RAM_COUNT=16
389CONFIG_BLK_DEV_RAM_SIZE=32768
390# CONFIG_BLK_DEV_XIP is not set
391# CONFIG_CDROM_PKTCDVD is not set
392# CONFIG_ATA_OVER_ETH is not set
393CONFIG_MISC_DEVICES=y
394# CONFIG_PHANTOM is not set
395# CONFIG_EEPROM_93CX6 is not set
396# CONFIG_SGI_IOC4 is not set
397# CONFIG_TIFM_CORE is not set
398# CONFIG_ENCLOSURE_SERVICES is not set
399CONFIG_HAVE_IDE=y
400# CONFIG_IDE is not set
401
402#
403# SCSI device support
404#
405# CONFIG_RAID_ATTRS is not set
406CONFIG_SCSI=y
407CONFIG_SCSI_DMA=y
408# CONFIG_SCSI_TGT is not set
409# CONFIG_SCSI_NETLINK is not set
410# CONFIG_SCSI_PROC_FS is not set
411
412#
413# SCSI support type (disk, tape, CD-ROM)
414#
415# CONFIG_BLK_DEV_SD is not set
416# CONFIG_CHR_DEV_ST is not set
417# CONFIG_CHR_DEV_OSST is not set
418# CONFIG_BLK_DEV_SR is not set
419# CONFIG_CHR_DEV_SG is not set
420# CONFIG_CHR_DEV_SCH is not set
421
422#
423# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
424#
425# CONFIG_SCSI_MULTI_LUN is not set
426# CONFIG_SCSI_CONSTANTS is not set
427# CONFIG_SCSI_LOGGING is not set
428# CONFIG_SCSI_SCAN_ASYNC is not set
429CONFIG_SCSI_WAIT_SCAN=m
430
431#
432# SCSI Transports
433#
434# CONFIG_SCSI_SPI_ATTRS is not set
435# CONFIG_SCSI_FC_ATTRS is not set
436# CONFIG_SCSI_ISCSI_ATTRS is not set
437# CONFIG_SCSI_SAS_LIBSAS is not set
438# CONFIG_SCSI_SRP_ATTRS is not set
439CONFIG_SCSI_LOWLEVEL=y
440# CONFIG_ISCSI_TCP is not set
441# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
442# CONFIG_SCSI_3W_9XXX is not set
443# CONFIG_SCSI_ACARD is not set
444# CONFIG_SCSI_AACRAID is not set
445# CONFIG_SCSI_AIC7XXX is not set
446# CONFIG_SCSI_AIC7XXX_OLD is not set
447# CONFIG_SCSI_AIC79XX is not set
448# CONFIG_SCSI_AIC94XX is not set
449# CONFIG_SCSI_DPT_I2O is not set
450# CONFIG_SCSI_ADVANSYS is not set
451# CONFIG_SCSI_ARCMSR is not set
452# CONFIG_MEGARAID_NEWGEN is not set
453# CONFIG_MEGARAID_LEGACY is not set
454# CONFIG_MEGARAID_SAS is not set
455# CONFIG_SCSI_HPTIOP is not set
456# CONFIG_SCSI_BUSLOGIC is not set
457# CONFIG_SCSI_DMX3191D is not set
458# CONFIG_SCSI_EATA is not set
459# CONFIG_SCSI_FUTURE_DOMAIN is not set
460# CONFIG_SCSI_GDTH is not set
461# CONFIG_SCSI_IPS is not set
462# CONFIG_SCSI_INITIO is not set
463# CONFIG_SCSI_INIA100 is not set
464# CONFIG_SCSI_MVSAS is not set
465# CONFIG_SCSI_STEX is not set
466# CONFIG_SCSI_SYM53C8XX_2 is not set
467# CONFIG_SCSI_IPR is not set
468# CONFIG_SCSI_QLOGIC_1280 is not set
469# CONFIG_SCSI_QLA_FC is not set
470# CONFIG_SCSI_QLA_ISCSI is not set
471# CONFIG_SCSI_LPFC is not set
472# CONFIG_SCSI_DC395x is not set
473# CONFIG_SCSI_DC390T is not set
474# CONFIG_SCSI_NSP32 is not set
475# CONFIG_SCSI_DEBUG is not set
476# CONFIG_SCSI_SRP is not set
477CONFIG_ATA=y
478# CONFIG_ATA_NONSTANDARD is not set
479CONFIG_SATA_PMP=y
480# CONFIG_SATA_AHCI is not set
481# CONFIG_SATA_SIL24 is not set
482# CONFIG_SATA_FSL is not set
483CONFIG_ATA_SFF=y
484# CONFIG_SATA_SVW is not set
485# CONFIG_ATA_PIIX is not set
486# CONFIG_SATA_MV is not set
487# CONFIG_SATA_NV is not set
488# CONFIG_PDC_ADMA is not set
489# CONFIG_SATA_QSTOR is not set
490# CONFIG_SATA_PROMISE is not set
491# CONFIG_SATA_SX4 is not set
492# CONFIG_SATA_SIL is not set
493# CONFIG_SATA_SIS is not set
494# CONFIG_SATA_ULI is not set
495# CONFIG_SATA_VIA is not set
496# CONFIG_SATA_VITESSE is not set
497# CONFIG_SATA_INIC162X is not set
498# CONFIG_PATA_ALI is not set
499# CONFIG_PATA_AMD is not set
500# CONFIG_PATA_ARTOP is not set
501# CONFIG_PATA_ATIIXP is not set
502# CONFIG_PATA_CMD640_PCI is not set
503# CONFIG_PATA_CMD64X is not set
504# CONFIG_PATA_CS5520 is not set
505# CONFIG_PATA_CS5530 is not set
506# CONFIG_PATA_CYPRESS is not set
507# CONFIG_PATA_EFAR is not set
508# CONFIG_ATA_GENERIC is not set
509# CONFIG_PATA_HPT366 is not set
510# CONFIG_PATA_HPT37X is not set
511# CONFIG_PATA_HPT3X2N is not set
512# CONFIG_PATA_HPT3X3 is not set
513# CONFIG_PATA_IT821X is not set
514# CONFIG_PATA_IT8213 is not set
515# CONFIG_PATA_JMICRON is not set
516# CONFIG_PATA_TRIFLEX is not set
517# CONFIG_PATA_MARVELL is not set
518CONFIG_PATA_MPC52xx=y
519# CONFIG_PATA_MPIIX is not set
520# CONFIG_PATA_OLDPIIX is not set
521# CONFIG_PATA_NETCELL is not set
522# CONFIG_PATA_NINJA32 is not set
523# CONFIG_PATA_NS87410 is not set
524# CONFIG_PATA_NS87415 is not set
525# CONFIG_PATA_OPTI is not set
526# CONFIG_PATA_OPTIDMA is not set
527# CONFIG_PATA_PDC_OLD is not set
528# CONFIG_PATA_RADISYS is not set
529# CONFIG_PATA_RZ1000 is not set
530# CONFIG_PATA_SC1200 is not set
531# CONFIG_PATA_SERVERWORKS is not set
532# CONFIG_PATA_PDC2027X is not set
533# CONFIG_PATA_SIL680 is not set
534# CONFIG_PATA_SIS is not set
535# CONFIG_PATA_VIA is not set
536# CONFIG_PATA_WINBOND is not set
537# CONFIG_PATA_PLATFORM is not set
538# CONFIG_MD is not set
539# CONFIG_FUSION is not set
540
541#
542# IEEE 1394 (FireWire) support
543#
544# CONFIG_FIREWIRE is not set
545# CONFIG_IEEE1394 is not set
546# CONFIG_I2O is not set
547# CONFIG_MACINTOSH_DRIVERS is not set
548CONFIG_NETDEVICES=y
549# CONFIG_NETDEVICES_MULTIQUEUE is not set
550# CONFIG_DUMMY is not set
551# CONFIG_BONDING is not set
552# CONFIG_MACVLAN is not set
553# CONFIG_EQUALIZER is not set
554# CONFIG_TUN is not set
555# CONFIG_VETH is not set
556# CONFIG_ARCNET is not set
557CONFIG_PHYLIB=y
558
559#
560# MII PHY device drivers
561#
562# CONFIG_MARVELL_PHY is not set
563# CONFIG_DAVICOM_PHY is not set
564# CONFIG_QSEMI_PHY is not set
565CONFIG_LXT_PHY=y
566# CONFIG_CICADA_PHY is not set
567# CONFIG_VITESSE_PHY is not set
568# CONFIG_SMSC_PHY is not set
569# CONFIG_BROADCOM_PHY is not set
570# CONFIG_ICPLUS_PHY is not set
571# CONFIG_REALTEK_PHY is not set
572# CONFIG_FIXED_PHY is not set
573# CONFIG_MDIO_BITBANG is not set
574CONFIG_NET_ETHERNET=y
575# CONFIG_MII is not set
576# CONFIG_HAPPYMEAL is not set
577# CONFIG_SUNGEM is not set
578# CONFIG_CASSINI is not set
579# CONFIG_NET_VENDOR_3COM is not set
580# CONFIG_NET_TULIP is not set
581# CONFIG_HP100 is not set
582# CONFIG_IBM_NEW_EMAC_ZMII is not set
583# CONFIG_IBM_NEW_EMAC_RGMII is not set
584# CONFIG_IBM_NEW_EMAC_TAH is not set
585# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
586# CONFIG_NET_PCI is not set
587# CONFIG_B44 is not set
588CONFIG_FEC_MPC52xx=y
589CONFIG_FEC_MPC52xx_MDIO=y
590CONFIG_NETDEV_1000=y
591# CONFIG_ACENIC is not set
592# CONFIG_DL2K is not set
593# CONFIG_E1000 is not set
594# CONFIG_E1000E is not set
595# CONFIG_E1000E_ENABLED is not set
596# CONFIG_IP1000 is not set
597# CONFIG_IGB is not set
598# CONFIG_NS83820 is not set
599# CONFIG_HAMACHI is not set
600# CONFIG_YELLOWFIN is not set
601# CONFIG_R8169 is not set
602# CONFIG_SIS190 is not set
603# CONFIG_SKGE is not set
604# CONFIG_SKY2 is not set
605# CONFIG_VIA_VELOCITY is not set
606# CONFIG_TIGON3 is not set
607# CONFIG_BNX2 is not set
608# CONFIG_GIANFAR is not set
609# CONFIG_MV643XX_ETH is not set
610# CONFIG_QLA3XXX is not set
611# CONFIG_ATL1 is not set
612CONFIG_NETDEV_10000=y
613# CONFIG_CHELSIO_T1 is not set
614# CONFIG_CHELSIO_T3 is not set
615# CONFIG_IXGBE is not set
616# CONFIG_IXGB is not set
617# CONFIG_S2IO is not set
618# CONFIG_MYRI10GE is not set
619# CONFIG_NETXEN_NIC is not set
620# CONFIG_NIU is not set
621# CONFIG_MLX4_CORE is not set
622# CONFIG_TEHUTI is not set
623# CONFIG_BNX2X is not set
624# CONFIG_TR is not set
625
626#
627# Wireless LAN
628#
629# CONFIG_WLAN_PRE80211 is not set
630# CONFIG_WLAN_80211 is not set
631# CONFIG_IWLWIFI is not set
632# CONFIG_IWLWIFI_LEDS is not set
633# CONFIG_WAN is not set
634# CONFIG_FDDI is not set
635# CONFIG_HIPPI is not set
636# CONFIG_PPP is not set
637# CONFIG_SLIP is not set
638# CONFIG_NET_FC is not set
639# CONFIG_NETCONSOLE is not set
640# CONFIG_NETPOLL is not set
641# CONFIG_NET_POLL_CONTROLLER is not set
642# CONFIG_ISDN is not set
643# CONFIG_PHONE is not set
644
645#
646# Input device support
647#
648# CONFIG_INPUT is not set
649
650#
651# Hardware I/O ports
652#
653# CONFIG_SERIO is not set
654# CONFIG_GAMEPORT is not set
655
656#
657# Character devices
658#
659# CONFIG_VT is not set
660# CONFIG_SERIAL_NONSTANDARD is not set
661# CONFIG_NOZOMI is not set
662
663#
664# Serial drivers
665#
666# CONFIG_SERIAL_8250 is not set
667
668#
669# Non-8250 serial port support
670#
671# CONFIG_SERIAL_UARTLITE is not set
672CONFIG_SERIAL_CORE=y
673CONFIG_SERIAL_CORE_CONSOLE=y
674CONFIG_SERIAL_MPC52xx=y
675CONFIG_SERIAL_MPC52xx_CONSOLE=y
676CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=115200
677# CONFIG_SERIAL_JSM is not set
678CONFIG_UNIX98_PTYS=y
679CONFIG_LEGACY_PTYS=y
680CONFIG_LEGACY_PTY_COUNT=256
681# CONFIG_IPMI_HANDLER is not set
682# CONFIG_HW_RANDOM is not set
683# CONFIG_NVRAM is not set
684CONFIG_GEN_RTC=y
685# CONFIG_GEN_RTC_X is not set
686# CONFIG_R3964 is not set
687# CONFIG_APPLICOM is not set
688# CONFIG_RAW_DRIVER is not set
689# CONFIG_TCG_TPM is not set
690CONFIG_DEVPORT=y
691CONFIG_I2C=y
692CONFIG_I2C_BOARDINFO=y
693CONFIG_I2C_CHARDEV=y
694
695#
696# I2C Hardware Bus support
697#
698# CONFIG_I2C_ALI1535 is not set
699# CONFIG_I2C_ALI1563 is not set
700# CONFIG_I2C_ALI15X3 is not set
701# CONFIG_I2C_AMD756 is not set
702# CONFIG_I2C_AMD8111 is not set
703# CONFIG_I2C_I801 is not set
704# CONFIG_I2C_I810 is not set
705# CONFIG_I2C_PIIX4 is not set
706CONFIG_I2C_MPC=y
707# CONFIG_I2C_NFORCE2 is not set
708# CONFIG_I2C_OCORES is not set
709# CONFIG_I2C_PARPORT_LIGHT is not set
710# CONFIG_I2C_PROSAVAGE is not set
711# CONFIG_I2C_SAVAGE4 is not set
712# CONFIG_I2C_SIMTEC is not set
713# CONFIG_I2C_SIS5595 is not set
714# CONFIG_I2C_SIS630 is not set
715# CONFIG_I2C_SIS96X is not set
716# CONFIG_I2C_TAOS_EVM is not set
717# CONFIG_I2C_STUB is not set
718# CONFIG_I2C_VIA is not set
719# CONFIG_I2C_VIAPRO is not set
720# CONFIG_I2C_VOODOO3 is not set
721# CONFIG_I2C_PCA_PLATFORM is not set
722
723#
724# Miscellaneous I2C Chip support
725#
726# CONFIG_DS1682 is not set
727# CONFIG_SENSORS_EEPROM is not set
728# CONFIG_SENSORS_PCF8574 is not set
729# CONFIG_PCF8575 is not set
730# CONFIG_SENSORS_PCF8591 is not set
731# CONFIG_SENSORS_MAX6875 is not set
732# CONFIG_SENSORS_TSL2550 is not set
733# CONFIG_I2C_DEBUG_CORE is not set
734# CONFIG_I2C_DEBUG_ALGO is not set
735# CONFIG_I2C_DEBUG_BUS is not set
736# CONFIG_I2C_DEBUG_CHIP is not set
737# CONFIG_SPI is not set
738# CONFIG_W1 is not set
739# CONFIG_POWER_SUPPLY is not set
740# CONFIG_HWMON is not set
741# CONFIG_THERMAL is not set
742# CONFIG_WATCHDOG is not set
743
744#
745# Sonics Silicon Backplane
746#
747CONFIG_SSB_POSSIBLE=y
748# CONFIG_SSB is not set
749
750#
751# Multifunction device drivers
752#
753# CONFIG_MFD_SM501 is not set
754# CONFIG_HTC_PASIC3 is not set
755
756#
757# Multimedia devices
758#
759# CONFIG_VIDEO_DEV is not set
760# CONFIG_DVB_CORE is not set
761# CONFIG_DAB is not set
762
763#
764# Graphics support
765#
766# CONFIG_AGP is not set
767# CONFIG_DRM is not set
768# CONFIG_VGASTATE is not set
769CONFIG_VIDEO_OUTPUT_CONTROL=m
770# CONFIG_FB is not set
771# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
772
773#
774# Display device support
775#
776# CONFIG_DISPLAY_SUPPORT is not set
777
778#
779# Sound
780#
781# CONFIG_SOUND is not set
782CONFIG_USB_SUPPORT=y
783CONFIG_USB_ARCH_HAS_HCD=y
784CONFIG_USB_ARCH_HAS_OHCI=y
785CONFIG_USB_ARCH_HAS_EHCI=y
786# CONFIG_USB is not set
787# CONFIG_USB_OTG_WHITELIST is not set
788# CONFIG_USB_OTG_BLACKLIST_HUB is not set
789
790#
791# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
792#
793# CONFIG_USB_GADGET is not set
794# CONFIG_MMC is not set
795# CONFIG_MEMSTICK is not set
796# CONFIG_NEW_LEDS is not set
797# CONFIG_INFINIBAND is not set
798# CONFIG_EDAC is not set
799# CONFIG_RTC_CLASS is not set
800# CONFIG_DMADEVICES is not set
801# CONFIG_UIO is not set
802
803#
804# File systems
805#
806CONFIG_EXT2_FS=y
807# CONFIG_EXT2_FS_XATTR is not set
808# CONFIG_EXT2_FS_XIP is not set
809CONFIG_EXT3_FS=y
810CONFIG_EXT3_FS_XATTR=y
811# CONFIG_EXT3_FS_POSIX_ACL is not set
812# CONFIG_EXT3_FS_SECURITY is not set
813# CONFIG_EXT4DEV_FS is not set
814CONFIG_JBD=y
815CONFIG_FS_MBCACHE=y
816# CONFIG_REISERFS_FS is not set
817# CONFIG_JFS_FS is not set
818# CONFIG_FS_POSIX_ACL is not set
819# CONFIG_XFS_FS is not set
820# CONFIG_OCFS2_FS is not set
821CONFIG_DNOTIFY=y
822CONFIG_INOTIFY=y
823CONFIG_INOTIFY_USER=y
824# CONFIG_QUOTA is not set
825# CONFIG_AUTOFS_FS is not set
826# CONFIG_AUTOFS4_FS is not set
827# CONFIG_FUSE_FS is not set
828
829#
830# CD-ROM/DVD Filesystems
831#
832# CONFIG_ISO9660_FS is not set
833# CONFIG_UDF_FS is not set
834
835#
836# DOS/FAT/NT Filesystems
837#
838# CONFIG_MSDOS_FS is not set
839# CONFIG_VFAT_FS is not set
840# CONFIG_NTFS_FS is not set
841
842#
843# Pseudo filesystems
844#
845CONFIG_PROC_FS=y
846CONFIG_PROC_KCORE=y
847CONFIG_PROC_SYSCTL=y
848CONFIG_SYSFS=y
849CONFIG_TMPFS=y
850# CONFIG_TMPFS_POSIX_ACL is not set
851# CONFIG_HUGETLB_PAGE is not set
852# CONFIG_CONFIGFS_FS is not set
853
854#
855# Miscellaneous filesystems
856#
857# CONFIG_ADFS_FS is not set
858# CONFIG_AFFS_FS is not set
859# CONFIG_HFS_FS is not set
860# CONFIG_HFSPLUS_FS is not set
861# CONFIG_BEFS_FS is not set
862# CONFIG_BFS_FS is not set
863# CONFIG_EFS_FS is not set
864# CONFIG_CRAMFS is not set
865# CONFIG_VXFS_FS is not set
866# CONFIG_MINIX_FS is not set
867# CONFIG_HPFS_FS is not set
868# CONFIG_QNX4FS_FS is not set
869# CONFIG_ROMFS_FS is not set
870# CONFIG_SYSV_FS is not set
871# CONFIG_UFS_FS is not set
872CONFIG_NETWORK_FILESYSTEMS=y
873CONFIG_NFS_FS=y
874CONFIG_NFS_V3=y
875# CONFIG_NFS_V3_ACL is not set
876CONFIG_NFS_V4=y
877# CONFIG_NFSD is not set
878CONFIG_ROOT_NFS=y
879CONFIG_LOCKD=y
880CONFIG_LOCKD_V4=y
881CONFIG_NFS_COMMON=y
882CONFIG_SUNRPC=y
883CONFIG_SUNRPC_GSS=y
884# CONFIG_SUNRPC_BIND34 is not set
885CONFIG_RPCSEC_GSS_KRB5=y
886# CONFIG_RPCSEC_GSS_SPKM3 is not set
887# CONFIG_SMB_FS is not set
888# CONFIG_CIFS is not set
889# CONFIG_NCP_FS is not set
890# CONFIG_CODA_FS is not set
891# CONFIG_AFS_FS is not set
892
893#
894# Partition Types
895#
896# CONFIG_PARTITION_ADVANCED is not set
897CONFIG_MSDOS_PARTITION=y
898# CONFIG_NLS is not set
899# CONFIG_DLM is not set
900
901#
902# Library routines
903#
904CONFIG_BITREVERSE=y
905# CONFIG_GENERIC_FIND_FIRST_BIT is not set
906# CONFIG_CRC_CCITT is not set
907# CONFIG_CRC16 is not set
908# CONFIG_CRC_ITU_T is not set
909CONFIG_CRC32=y
910# CONFIG_CRC7 is not set
911# CONFIG_LIBCRC32C is not set
912CONFIG_PLIST=y
913CONFIG_HAS_IOMEM=y
914CONFIG_HAS_IOPORT=y
915CONFIG_HAS_DMA=y
916CONFIG_HAVE_LMB=y
917
918#
919# Kernel hacking
920#
921CONFIG_PRINTK_TIME=y
922CONFIG_ENABLE_WARN_DEPRECATED=y
923CONFIG_ENABLE_MUST_CHECK=y
924CONFIG_FRAME_WARN=1024
925# CONFIG_MAGIC_SYSRQ is not set
926# CONFIG_UNUSED_SYMBOLS is not set
927# CONFIG_DEBUG_FS is not set
928# CONFIG_HEADERS_CHECK is not set
929CONFIG_DEBUG_KERNEL=y
930# CONFIG_DEBUG_SHIRQ is not set
931CONFIG_DETECT_SOFTLOCKUP=y
932CONFIG_SCHED_DEBUG=y
933# CONFIG_SCHEDSTATS is not set
934# CONFIG_TIMER_STATS is not set
935# CONFIG_SLUB_DEBUG_ON is not set
936# CONFIG_SLUB_STATS is not set
937# CONFIG_DEBUG_RT_MUTEXES is not set
938# CONFIG_RT_MUTEX_TESTER is not set
939# CONFIG_DEBUG_SPINLOCK is not set
940# CONFIG_DEBUG_MUTEXES is not set
941# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
942# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
943# CONFIG_DEBUG_KOBJECT is not set
944# CONFIG_DEBUG_BUGVERBOSE is not set
945CONFIG_DEBUG_INFO=y
946# CONFIG_DEBUG_VM is not set
947# CONFIG_DEBUG_WRITECOUNT is not set
948# CONFIG_DEBUG_LIST is not set
949# CONFIG_DEBUG_SG is not set
950# CONFIG_BOOT_PRINTK_DELAY is not set
951# CONFIG_RCU_TORTURE_TEST is not set
952# CONFIG_BACKTRACE_SELF_TEST is not set
953# CONFIG_FAULT_INJECTION is not set
954# CONFIG_SAMPLES is not set
955# CONFIG_DEBUG_STACKOVERFLOW is not set
956# CONFIG_DEBUG_STACK_USAGE is not set
957# CONFIG_DEBUG_PAGEALLOC is not set
958# CONFIG_DEBUGGER is not set
959# CONFIG_IRQSTACKS is not set
960# CONFIG_BDI_SWITCH is not set
961# CONFIG_BOOTX_TEXT is not set
962# CONFIG_PPC_EARLY_DEBUG is not set
963
964#
965# Security options
966#
967# CONFIG_KEYS is not set
968# CONFIG_SECURITY is not set
969# CONFIG_SECURITY_FILE_CAPABILITIES is not set
970CONFIG_CRYPTO=y
971
972#
973# Crypto core or helper
974#
975CONFIG_CRYPTO_ALGAPI=y
976CONFIG_CRYPTO_BLKCIPHER=y
977CONFIG_CRYPTO_MANAGER=y
978# CONFIG_CRYPTO_GF128MUL is not set
979# CONFIG_CRYPTO_NULL is not set
980# CONFIG_CRYPTO_CRYPTD is not set
981# CONFIG_CRYPTO_AUTHENC is not set
982# CONFIG_CRYPTO_TEST is not set
983
984#
985# Authenticated Encryption with Associated Data
986#
987# CONFIG_CRYPTO_CCM is not set
988# CONFIG_CRYPTO_GCM is not set
989# CONFIG_CRYPTO_SEQIV is not set
990
991#
992# Block modes
993#
994CONFIG_CRYPTO_CBC=y
995# CONFIG_CRYPTO_CTR is not set
996# CONFIG_CRYPTO_CTS is not set
997# CONFIG_CRYPTO_ECB is not set
998# CONFIG_CRYPTO_LRW is not set
999# CONFIG_CRYPTO_PCBC is not set
1000# CONFIG_CRYPTO_XTS is not set
1001
1002#
1003# Hash modes
1004#
1005# CONFIG_CRYPTO_HMAC is not set
1006# CONFIG_CRYPTO_XCBC is not set
1007
1008#
1009# Digest
1010#
1011# CONFIG_CRYPTO_CRC32C is not set
1012# CONFIG_CRYPTO_MD4 is not set
1013CONFIG_CRYPTO_MD5=y
1014# CONFIG_CRYPTO_MICHAEL_MIC is not set
1015# CONFIG_CRYPTO_SHA1 is not set
1016# CONFIG_CRYPTO_SHA256 is not set
1017# CONFIG_CRYPTO_SHA512 is not set
1018# CONFIG_CRYPTO_TGR192 is not set
1019# CONFIG_CRYPTO_WP512 is not set
1020
1021#
1022# Ciphers
1023#
1024# CONFIG_CRYPTO_AES is not set
1025# CONFIG_CRYPTO_ANUBIS is not set
1026# CONFIG_CRYPTO_ARC4 is not set
1027# CONFIG_CRYPTO_BLOWFISH is not set
1028# CONFIG_CRYPTO_CAMELLIA is not set
1029# CONFIG_CRYPTO_CAST5 is not set
1030# CONFIG_CRYPTO_CAST6 is not set
1031CONFIG_CRYPTO_DES=y
1032# CONFIG_CRYPTO_FCRYPT is not set
1033# CONFIG_CRYPTO_KHAZAD is not set
1034# CONFIG_CRYPTO_SALSA20 is not set
1035# CONFIG_CRYPTO_SEED is not set
1036# CONFIG_CRYPTO_SERPENT is not set
1037# CONFIG_CRYPTO_TEA is not set
1038# CONFIG_CRYPTO_TWOFISH is not set
1039
1040#
1041# Compression
1042#
1043# CONFIG_CRYPTO_DEFLATE is not set
1044# CONFIG_CRYPTO_LZO is not set
1045CONFIG_CRYPTO_HW=y
1046# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1047CONFIG_PPC_CLOCK=y
1048CONFIG_PPC_LIB_RHEAP=y
1049# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/configs/52xx/motionpro_defconfig b/arch/powerpc/configs/52xx/motionpro_defconfig
new file mode 100644
index 000000000000..8c7ba7c6ba49
--- /dev/null
+++ b/arch/powerpc/configs/52xx/motionpro_defconfig
@@ -0,0 +1,1107 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Tue Apr 29 07:12:22 2008
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11CONFIG_6xx=y
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18# CONFIG_ALTIVEC is not set
19CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_32=y
21# CONFIG_PPC_MM_SLICES is not set
22# CONFIG_SMP is not set
23CONFIG_PPC32=y
24CONFIG_WORD_SIZE=32
25CONFIG_PPC_MERGE=y
26CONFIG_MMU=y
27CONFIG_GENERIC_CMOS_UPDATE=y
28CONFIG_GENERIC_TIME=y
29CONFIG_GENERIC_TIME_VSYSCALL=y
30CONFIG_GENERIC_CLOCKEVENTS=y
31CONFIG_GENERIC_HARDIRQS=y
32# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
33CONFIG_IRQ_PER_CPU=y
34CONFIG_STACKTRACE_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y
43CONFIG_EARLY_PRINTK=y
44CONFIG_GENERIC_NVRAM=y
45CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
46CONFIG_ARCH_MAY_HAVE_PC_FDC=y
47CONFIG_PPC_OF=y
48CONFIG_OF=y
49# CONFIG_PPC_UDBG_16550 is not set
50# CONFIG_GENERIC_TBSYNC is not set
51CONFIG_AUDIT_ARCH=y
52CONFIG_GENERIC_BUG=y
53CONFIG_DEFAULT_UIMAGE=y
54# CONFIG_PPC_DCR_NATIVE is not set
55# CONFIG_PPC_DCR_MMIO is not set
56CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
57
58#
59# General setup
60#
61CONFIG_EXPERIMENTAL=y
62CONFIG_BROKEN_ON_SMP=y
63CONFIG_INIT_ENV_ARG_LIMIT=32
64CONFIG_LOCALVERSION=""
65CONFIG_LOCALVERSION_AUTO=y
66CONFIG_SWAP=y
67CONFIG_SYSVIPC=y
68CONFIG_SYSVIPC_SYSCTL=y
69# CONFIG_POSIX_MQUEUE is not set
70# CONFIG_BSD_PROCESS_ACCT is not set
71# CONFIG_TASKSTATS is not set
72# CONFIG_AUDIT is not set
73# CONFIG_IKCONFIG is not set
74CONFIG_LOG_BUF_SHIFT=14
75# CONFIG_CGROUPS is not set
76CONFIG_GROUP_SCHED=y
77CONFIG_FAIR_GROUP_SCHED=y
78# CONFIG_RT_GROUP_SCHED is not set
79CONFIG_USER_SCHED=y
80# CONFIG_CGROUP_SCHED is not set
81CONFIG_SYSFS_DEPRECATED=y
82CONFIG_SYSFS_DEPRECATED_V2=y
83# CONFIG_RELAY is not set
84# CONFIG_NAMESPACES is not set
85CONFIG_BLK_DEV_INITRD=y
86CONFIG_INITRAMFS_SOURCE=""
87# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
88CONFIG_SYSCTL=y
89CONFIG_EMBEDDED=y
90# CONFIG_SYSCTL_SYSCALL is not set
91# CONFIG_KALLSYMS is not set
92CONFIG_HOTPLUG=y
93CONFIG_PRINTK=y
94CONFIG_BUG=y
95CONFIG_ELF_CORE=y
96CONFIG_COMPAT_BRK=y
97CONFIG_BASE_FULL=y
98CONFIG_FUTEX=y
99CONFIG_ANON_INODES=y
100# CONFIG_EPOLL is not set
101CONFIG_SIGNALFD=y
102CONFIG_TIMERFD=y
103CONFIG_EVENTFD=y
104CONFIG_SHMEM=y
105CONFIG_VM_EVENT_COUNTERS=y
106CONFIG_SLUB_DEBUG=y
107# CONFIG_SLAB is not set
108CONFIG_SLUB=y
109# CONFIG_SLOB is not set
110# CONFIG_PROFILING is not set
111# CONFIG_MARKERS is not set
112CONFIG_HAVE_OPROFILE=y
113CONFIG_HAVE_KPROBES=y
114CONFIG_HAVE_KRETPROBES=y
115CONFIG_PROC_PAGE_MONITOR=y
116CONFIG_SLABINFO=y
117CONFIG_RT_MUTEXES=y
118# CONFIG_TINY_SHMEM is not set
119CONFIG_BASE_SMALL=0
120# CONFIG_MODULES is not set
121CONFIG_BLOCK=y
122# CONFIG_LBD is not set
123# CONFIG_BLK_DEV_IO_TRACE is not set
124# CONFIG_LSF is not set
125# CONFIG_BLK_DEV_BSG is not set
126
127#
128# IO Schedulers
129#
130CONFIG_IOSCHED_NOOP=y
131CONFIG_IOSCHED_AS=y
132CONFIG_IOSCHED_DEADLINE=y
133CONFIG_IOSCHED_CFQ=y
134CONFIG_DEFAULT_AS=y
135# CONFIG_DEFAULT_DEADLINE is not set
136# CONFIG_DEFAULT_CFQ is not set
137# CONFIG_DEFAULT_NOOP is not set
138CONFIG_DEFAULT_IOSCHED="anticipatory"
139CONFIG_CLASSIC_RCU=y
140
141#
142# Platform support
143#
144CONFIG_PPC_MULTIPLATFORM=y
145# CONFIG_PPC_82xx is not set
146# CONFIG_PPC_83xx is not set
147# CONFIG_PPC_86xx is not set
148CONFIG_CLASSIC32=y
149# CONFIG_PPC_CHRP is not set
150# CONFIG_PPC_MPC512x is not set
151# CONFIG_PPC_MPC5121 is not set
152# CONFIG_MPC5121_ADS is not set
153CONFIG_PPC_MPC52xx=y
154CONFIG_PPC_MPC5200_SIMPLE=y
155# CONFIG_PPC_EFIKA is not set
156# CONFIG_PPC_LITE5200 is not set
157# CONFIG_PPC_MPC5200_BUGFIX is not set
158# CONFIG_PPC_MPC5200_GPIO is not set
159# CONFIG_PPC_PMAC is not set
160# CONFIG_PPC_CELL is not set
161# CONFIG_PPC_CELL_NATIVE is not set
162# CONFIG_PQ2ADS is not set
163# CONFIG_EMBEDDED6xx is not set
164# CONFIG_IPIC is not set
165# CONFIG_MPIC is not set
166# CONFIG_MPIC_WEIRD is not set
167# CONFIG_PPC_I8259 is not set
168# CONFIG_PPC_RTAS is not set
169# CONFIG_MMIO_NVRAM is not set
170# CONFIG_PPC_MPC106 is not set
171# CONFIG_PPC_970_NAP is not set
172# CONFIG_PPC_INDIRECT_IO is not set
173# CONFIG_GENERIC_IOMAP is not set
174# CONFIG_CPU_FREQ is not set
175# CONFIG_TAU is not set
176# CONFIG_FSL_ULI1575 is not set
177CONFIG_PPC_BESTCOMM=y
178# CONFIG_PPC_BESTCOMM_ATA is not set
179CONFIG_PPC_BESTCOMM_FEC=y
180# CONFIG_PPC_BESTCOMM_GEN_BD is not set
181
182#
183# Kernel options
184#
185# CONFIG_HIGHMEM is not set
186# CONFIG_TICK_ONESHOT is not set
187# CONFIG_NO_HZ is not set
188# CONFIG_HIGH_RES_TIMERS is not set
189CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
190# CONFIG_HZ_100 is not set
191CONFIG_HZ_250=y
192# CONFIG_HZ_300 is not set
193# CONFIG_HZ_1000 is not set
194CONFIG_HZ=250
195# CONFIG_SCHED_HRTICK is not set
196CONFIG_PREEMPT_NONE=y
197# CONFIG_PREEMPT_VOLUNTARY is not set
198# CONFIG_PREEMPT is not set
199CONFIG_BINFMT_ELF=y
200# CONFIG_BINFMT_MISC is not set
201# CONFIG_IOMMU_HELPER is not set
202CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
203CONFIG_ARCH_HAS_WALK_MEMORY=y
204CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
205# CONFIG_KEXEC is not set
206CONFIG_ARCH_FLATMEM_ENABLE=y
207CONFIG_ARCH_POPULATES_NODE_MAP=y
208CONFIG_SELECT_MEMORY_MODEL=y
209CONFIG_FLATMEM_MANUAL=y
210# CONFIG_DISCONTIGMEM_MANUAL is not set
211# CONFIG_SPARSEMEM_MANUAL is not set
212CONFIG_FLATMEM=y
213CONFIG_FLAT_NODE_MEM_MAP=y
214# CONFIG_SPARSEMEM_STATIC is not set
215# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
216CONFIG_PAGEFLAGS_EXTENDED=y
217CONFIG_SPLIT_PTLOCK_CPUS=4
218# CONFIG_RESOURCES_64BIT is not set
219CONFIG_ZONE_DMA_FLAG=1
220CONFIG_BOUNCE=y
221CONFIG_VIRT_TO_BUS=y
222CONFIG_FORCE_MAX_ZONEORDER=11
223CONFIG_PROC_DEVICETREE=y
224# CONFIG_CMDLINE_BOOL is not set
225CONFIG_PM=y
226# CONFIG_PM_LEGACY is not set
227# CONFIG_PM_DEBUG is not set
228CONFIG_SECCOMP=y
229CONFIG_ISA_DMA_API=y
230
231#
232# Bus options
233#
234CONFIG_ZONE_DMA=y
235CONFIG_GENERIC_ISA_DMA=y
236CONFIG_FSL_SOC=y
237# CONFIG_PCI is not set
238# CONFIG_PCI_DOMAINS is not set
239# CONFIG_PCI_SYSCALL is not set
240# CONFIG_ARCH_SUPPORTS_MSI is not set
241# CONFIG_PCCARD is not set
242# CONFIG_HAS_RAPIDIO is not set
243
244#
245# Advanced setup
246#
247# CONFIG_ADVANCED_OPTIONS is not set
248
249#
250# Default settings for advanced configuration options are used
251#
252CONFIG_LOWMEM_SIZE=0x30000000
253CONFIG_PAGE_OFFSET=0xc0000000
254CONFIG_KERNEL_START=0xc0000000
255CONFIG_PHYSICAL_START=0x00000000
256CONFIG_TASK_SIZE=0xc0000000
257
258#
259# Networking
260#
261CONFIG_NET=y
262
263#
264# Networking options
265#
266CONFIG_PACKET=y
267# CONFIG_PACKET_MMAP is not set
268CONFIG_UNIX=y
269CONFIG_XFRM=y
270CONFIG_XFRM_USER=y
271# CONFIG_XFRM_SUB_POLICY is not set
272# CONFIG_XFRM_MIGRATE is not set
273# CONFIG_XFRM_STATISTICS is not set
274# CONFIG_NET_KEY is not set
275CONFIG_INET=y
276CONFIG_IP_MULTICAST=y
277# CONFIG_IP_ADVANCED_ROUTER is not set
278CONFIG_IP_FIB_HASH=y
279CONFIG_IP_PNP=y
280CONFIG_IP_PNP_DHCP=y
281CONFIG_IP_PNP_BOOTP=y
282# CONFIG_IP_PNP_RARP is not set
283# CONFIG_NET_IPIP is not set
284# CONFIG_NET_IPGRE is not set
285# CONFIG_IP_MROUTE is not set
286# CONFIG_ARPD is not set
287CONFIG_SYN_COOKIES=y
288# CONFIG_INET_AH is not set
289# CONFIG_INET_ESP is not set
290# CONFIG_INET_IPCOMP is not set
291# CONFIG_INET_XFRM_TUNNEL is not set
292# CONFIG_INET_TUNNEL is not set
293CONFIG_INET_XFRM_MODE_TRANSPORT=y
294CONFIG_INET_XFRM_MODE_TUNNEL=y
295CONFIG_INET_XFRM_MODE_BEET=y
296# CONFIG_INET_LRO is not set
297CONFIG_INET_DIAG=y
298CONFIG_INET_TCP_DIAG=y
299# CONFIG_TCP_CONG_ADVANCED is not set
300CONFIG_TCP_CONG_CUBIC=y
301CONFIG_DEFAULT_TCP_CONG="cubic"
302# CONFIG_TCP_MD5SIG is not set
303# CONFIG_IPV6 is not set
304# CONFIG_NETWORK_SECMARK is not set
305# CONFIG_NETFILTER is not set
306# CONFIG_IP_DCCP is not set
307# CONFIG_IP_SCTP is not set
308# CONFIG_TIPC is not set
309# CONFIG_ATM is not set
310# CONFIG_BRIDGE is not set
311# CONFIG_VLAN_8021Q is not set
312# CONFIG_DECNET is not set
313# CONFIG_LLC2 is not set
314# CONFIG_IPX is not set
315# CONFIG_ATALK is not set
316# CONFIG_X25 is not set
317# CONFIG_LAPB is not set
318# CONFIG_ECONET is not set
319# CONFIG_WAN_ROUTER is not set
320# CONFIG_NET_SCHED is not set
321
322#
323# Network testing
324#
325# CONFIG_NET_PKTGEN is not set
326# CONFIG_HAMRADIO is not set
327# CONFIG_CAN is not set
328# CONFIG_IRDA is not set
329# CONFIG_BT is not set
330# CONFIG_AF_RXRPC is not set
331
332#
333# Wireless
334#
335# CONFIG_CFG80211 is not set
336# CONFIG_WIRELESS_EXT is not set
337# CONFIG_MAC80211 is not set
338# CONFIG_IEEE80211 is not set
339# CONFIG_RFKILL is not set
340# CONFIG_NET_9P is not set
341
342#
343# Device Drivers
344#
345
346#
347# Generic Driver Options
348#
349CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
350CONFIG_STANDALONE=y
351CONFIG_PREVENT_FIRMWARE_BUILD=y
352# CONFIG_FW_LOADER is not set
353# CONFIG_DEBUG_DRIVER is not set
354# CONFIG_DEBUG_DEVRES is not set
355# CONFIG_SYS_HYPERVISOR is not set
356# CONFIG_CONNECTOR is not set
357CONFIG_MTD=y
358# CONFIG_MTD_DEBUG is not set
359CONFIG_MTD_CONCAT=y
360CONFIG_MTD_PARTITIONS=y
361# CONFIG_MTD_REDBOOT_PARTS is not set
362CONFIG_MTD_CMDLINE_PARTS=y
363# CONFIG_MTD_OF_PARTS is not set
364# CONFIG_MTD_AR7_PARTS is not set
365
366#
367# User Modules And Translation Layers
368#
369CONFIG_MTD_CHAR=y
370CONFIG_MTD_BLKDEVS=y
371CONFIG_MTD_BLOCK=y
372# CONFIG_FTL is not set
373# CONFIG_NFTL is not set
374# CONFIG_INFTL is not set
375# CONFIG_RFD_FTL is not set
376# CONFIG_SSFDC is not set
377# CONFIG_MTD_OOPS is not set
378
379#
380# RAM/ROM/Flash chip drivers
381#
382CONFIG_MTD_CFI=y
383# CONFIG_MTD_JEDECPROBE is not set
384CONFIG_MTD_GEN_PROBE=y
385# CONFIG_MTD_CFI_ADV_OPTIONS is not set
386CONFIG_MTD_MAP_BANK_WIDTH_1=y
387CONFIG_MTD_MAP_BANK_WIDTH_2=y
388CONFIG_MTD_MAP_BANK_WIDTH_4=y
389# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
390# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
391# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
392CONFIG_MTD_CFI_I1=y
393CONFIG_MTD_CFI_I2=y
394# CONFIG_MTD_CFI_I4 is not set
395# CONFIG_MTD_CFI_I8 is not set
396# CONFIG_MTD_CFI_INTELEXT is not set
397CONFIG_MTD_CFI_AMDSTD=y
398# CONFIG_MTD_CFI_STAA is not set
399CONFIG_MTD_CFI_UTIL=y
400# CONFIG_MTD_RAM is not set
401CONFIG_MTD_ROM=y
402# CONFIG_MTD_ABSENT is not set
403
404#
405# Mapping drivers for chip access
406#
407# CONFIG_MTD_COMPLEX_MAPPINGS is not set
408# CONFIG_MTD_PHYSMAP is not set
409# CONFIG_MTD_PHYSMAP_OF is not set
410# CONFIG_MTD_PLATRAM is not set
411
412#
413# Self-contained MTD device drivers
414#
415# CONFIG_MTD_SLRAM is not set
416# CONFIG_MTD_PHRAM is not set
417# CONFIG_MTD_MTDRAM is not set
418# CONFIG_MTD_BLOCK2MTD is not set
419
420#
421# Disk-On-Chip Device Drivers
422#
423# CONFIG_MTD_DOC2000 is not set
424# CONFIG_MTD_DOC2001 is not set
425# CONFIG_MTD_DOC2001PLUS is not set
426# CONFIG_MTD_NAND is not set
427# CONFIG_MTD_ONENAND is not set
428
429#
430# UBI - Unsorted block images
431#
432# CONFIG_MTD_UBI is not set
433CONFIG_OF_DEVICE=y
434CONFIG_OF_I2C=y
435# CONFIG_PARPORT is not set
436CONFIG_BLK_DEV=y
437# CONFIG_BLK_DEV_FD is not set
438# CONFIG_BLK_DEV_COW_COMMON is not set
439CONFIG_BLK_DEV_LOOP=y
440# CONFIG_BLK_DEV_CRYPTOLOOP is not set
441# CONFIG_BLK_DEV_NBD is not set
442CONFIG_BLK_DEV_RAM=y
443CONFIG_BLK_DEV_RAM_COUNT=16
444CONFIG_BLK_DEV_RAM_SIZE=32768
445# CONFIG_BLK_DEV_XIP is not set
446# CONFIG_CDROM_PKTCDVD is not set
447# CONFIG_ATA_OVER_ETH is not set
448CONFIG_MISC_DEVICES=y
449# CONFIG_EEPROM_93CX6 is not set
450# CONFIG_ENCLOSURE_SERVICES is not set
451CONFIG_HAVE_IDE=y
452# CONFIG_IDE is not set
453
454#
455# SCSI device support
456#
457# CONFIG_RAID_ATTRS is not set
458CONFIG_SCSI=y
459CONFIG_SCSI_DMA=y
460CONFIG_SCSI_TGT=y
461# CONFIG_SCSI_NETLINK is not set
462CONFIG_SCSI_PROC_FS=y
463
464#
465# SCSI support type (disk, tape, CD-ROM)
466#
467CONFIG_BLK_DEV_SD=y
468# CONFIG_CHR_DEV_ST is not set
469# CONFIG_CHR_DEV_OSST is not set
470# CONFIG_BLK_DEV_SR is not set
471CONFIG_CHR_DEV_SG=y
472# CONFIG_CHR_DEV_SCH is not set
473
474#
475# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
476#
477# CONFIG_SCSI_MULTI_LUN is not set
478# CONFIG_SCSI_CONSTANTS is not set
479# CONFIG_SCSI_LOGGING is not set
480# CONFIG_SCSI_SCAN_ASYNC is not set
481
482#
483# SCSI Transports
484#
485# CONFIG_SCSI_SPI_ATTRS is not set
486# CONFIG_SCSI_FC_ATTRS is not set
487# CONFIG_SCSI_ISCSI_ATTRS is not set
488# CONFIG_SCSI_SAS_LIBSAS is not set
489# CONFIG_SCSI_SRP_ATTRS is not set
490CONFIG_SCSI_LOWLEVEL=y
491# CONFIG_ISCSI_TCP is not set
492# CONFIG_SCSI_DEBUG is not set
493CONFIG_ATA=y
494# CONFIG_ATA_NONSTANDARD is not set
495CONFIG_SATA_PMP=y
496# CONFIG_SATA_FSL is not set
497CONFIG_ATA_SFF=y
498# CONFIG_SATA_MV is not set
499CONFIG_PATA_MPC52xx=y
500# CONFIG_PATA_PLATFORM is not set
501# CONFIG_MD is not set
502# CONFIG_MACINTOSH_DRIVERS is not set
503CONFIG_NETDEVICES=y
504# CONFIG_NETDEVICES_MULTIQUEUE is not set
505# CONFIG_DUMMY is not set
506# CONFIG_BONDING is not set
507# CONFIG_MACVLAN is not set
508# CONFIG_EQUALIZER is not set
509# CONFIG_TUN is not set
510# CONFIG_VETH is not set
511CONFIG_PHYLIB=y
512
513#
514# MII PHY device drivers
515#
516CONFIG_MARVELL_PHY=y
517CONFIG_DAVICOM_PHY=y
518CONFIG_QSEMI_PHY=y
519CONFIG_LXT_PHY=y
520CONFIG_CICADA_PHY=y
521CONFIG_VITESSE_PHY=y
522CONFIG_SMSC_PHY=y
523CONFIG_BROADCOM_PHY=y
524CONFIG_ICPLUS_PHY=y
525# CONFIG_REALTEK_PHY is not set
526# CONFIG_FIXED_PHY is not set
527CONFIG_MDIO_BITBANG=y
528CONFIG_NET_ETHERNET=y
529CONFIG_MII=y
530# CONFIG_IBM_NEW_EMAC_ZMII is not set
531# CONFIG_IBM_NEW_EMAC_RGMII is not set
532# CONFIG_IBM_NEW_EMAC_TAH is not set
533# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
534# CONFIG_B44 is not set
535CONFIG_FEC_MPC52xx=y
536CONFIG_FEC_MPC52xx_MDIO=y
537# CONFIG_NETDEV_1000 is not set
538# CONFIG_NETDEV_10000 is not set
539
540#
541# Wireless LAN
542#
543# CONFIG_WLAN_PRE80211 is not set
544# CONFIG_WLAN_80211 is not set
545# CONFIG_IWLWIFI is not set
546# CONFIG_IWLWIFI_LEDS is not set
547# CONFIG_WAN is not set
548# CONFIG_PPP is not set
549# CONFIG_SLIP is not set
550# CONFIG_NETCONSOLE is not set
551# CONFIG_NETPOLL is not set
552# CONFIG_NET_POLL_CONTROLLER is not set
553# CONFIG_ISDN is not set
554# CONFIG_PHONE is not set
555
556#
557# Input device support
558#
559# CONFIG_INPUT is not set
560
561#
562# Hardware I/O ports
563#
564# CONFIG_SERIO is not set
565# CONFIG_GAMEPORT is not set
566
567#
568# Character devices
569#
570# CONFIG_VT is not set
571# CONFIG_SERIAL_NONSTANDARD is not set
572
573#
574# Serial drivers
575#
576# CONFIG_SERIAL_8250 is not set
577
578#
579# Non-8250 serial port support
580#
581# CONFIG_SERIAL_UARTLITE is not set
582CONFIG_SERIAL_CORE=y
583CONFIG_SERIAL_CORE_CONSOLE=y
584CONFIG_SERIAL_MPC52xx=y
585CONFIG_SERIAL_MPC52xx_CONSOLE=y
586CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=115200
587CONFIG_UNIX98_PTYS=y
588CONFIG_LEGACY_PTYS=y
589CONFIG_LEGACY_PTY_COUNT=256
590# CONFIG_IPMI_HANDLER is not set
591# CONFIG_HW_RANDOM is not set
592# CONFIG_NVRAM is not set
593# CONFIG_R3964 is not set
594# CONFIG_RAW_DRIVER is not set
595# CONFIG_TCG_TPM is not set
596CONFIG_I2C=y
597CONFIG_I2C_BOARDINFO=y
598CONFIG_I2C_CHARDEV=y
599
600#
601# I2C Hardware Bus support
602#
603CONFIG_I2C_MPC=y
604# CONFIG_I2C_OCORES is not set
605# CONFIG_I2C_PARPORT_LIGHT is not set
606# CONFIG_I2C_SIMTEC is not set
607# CONFIG_I2C_TAOS_EVM is not set
608# CONFIG_I2C_PCA_PLATFORM is not set
609
610#
611# Miscellaneous I2C Chip support
612#
613# CONFIG_DS1682 is not set
614CONFIG_SENSORS_EEPROM=y
615# CONFIG_SENSORS_PCF8574 is not set
616# CONFIG_PCF8575 is not set
617# CONFIG_SENSORS_PCF8591 is not set
618# CONFIG_SENSORS_MAX6875 is not set
619# CONFIG_SENSORS_TSL2550 is not set
620# CONFIG_I2C_DEBUG_CORE is not set
621# CONFIG_I2C_DEBUG_ALGO is not set
622# CONFIG_I2C_DEBUG_BUS is not set
623# CONFIG_I2C_DEBUG_CHIP is not set
624# CONFIG_SPI is not set
625# CONFIG_W1 is not set
626# CONFIG_POWER_SUPPLY is not set
627CONFIG_HWMON=y
628# CONFIG_HWMON_VID is not set
629# CONFIG_SENSORS_AD7418 is not set
630# CONFIG_SENSORS_ADM1021 is not set
631# CONFIG_SENSORS_ADM1025 is not set
632# CONFIG_SENSORS_ADM1026 is not set
633# CONFIG_SENSORS_ADM1029 is not set
634# CONFIG_SENSORS_ADM1031 is not set
635# CONFIG_SENSORS_ADM9240 is not set
636# CONFIG_SENSORS_ADT7470 is not set
637# CONFIG_SENSORS_ADT7473 is not set
638# CONFIG_SENSORS_ATXP1 is not set
639# CONFIG_SENSORS_DS1621 is not set
640# CONFIG_SENSORS_F71805F is not set
641# CONFIG_SENSORS_F71882FG is not set
642# CONFIG_SENSORS_F75375S is not set
643# CONFIG_SENSORS_GL518SM is not set
644# CONFIG_SENSORS_GL520SM is not set
645# CONFIG_SENSORS_IT87 is not set
646# CONFIG_SENSORS_LM63 is not set
647# CONFIG_SENSORS_LM75 is not set
648# CONFIG_SENSORS_LM77 is not set
649# CONFIG_SENSORS_LM78 is not set
650# CONFIG_SENSORS_LM80 is not set
651# CONFIG_SENSORS_LM83 is not set
652# CONFIG_SENSORS_LM85 is not set
653# CONFIG_SENSORS_LM87 is not set
654# CONFIG_SENSORS_LM90 is not set
655# CONFIG_SENSORS_LM92 is not set
656# CONFIG_SENSORS_LM93 is not set
657# CONFIG_SENSORS_MAX1619 is not set
658# CONFIG_SENSORS_MAX6650 is not set
659# CONFIG_SENSORS_PC87360 is not set
660# CONFIG_SENSORS_PC87427 is not set
661# CONFIG_SENSORS_DME1737 is not set
662# CONFIG_SENSORS_SMSC47M1 is not set
663# CONFIG_SENSORS_SMSC47M192 is not set
664# CONFIG_SENSORS_SMSC47B397 is not set
665# CONFIG_SENSORS_ADS7828 is not set
666# CONFIG_SENSORS_THMC50 is not set
667# CONFIG_SENSORS_VT1211 is not set
668# CONFIG_SENSORS_W83781D is not set
669# CONFIG_SENSORS_W83791D is not set
670# CONFIG_SENSORS_W83792D is not set
671# CONFIG_SENSORS_W83793 is not set
672# CONFIG_SENSORS_W83L785TS is not set
673# CONFIG_SENSORS_W83L786NG is not set
674# CONFIG_SENSORS_W83627HF is not set
675# CONFIG_SENSORS_W83627EHF is not set
676# CONFIG_HWMON_DEBUG_CHIP is not set
677# CONFIG_THERMAL is not set
678CONFIG_WATCHDOG=y
679# CONFIG_WATCHDOG_NOWAYOUT is not set
680
681#
682# Watchdog Device Drivers
683#
684# CONFIG_SOFT_WATCHDOG is not set
685# CONFIG_MPC5200_WDT is not set
686
687#
688# Sonics Silicon Backplane
689#
690CONFIG_SSB_POSSIBLE=y
691# CONFIG_SSB is not set
692
693#
694# Multifunction device drivers
695#
696# CONFIG_MFD_SM501 is not set
697# CONFIG_HTC_PASIC3 is not set
698
699#
700# Multimedia devices
701#
702# CONFIG_VIDEO_DEV is not set
703# CONFIG_DVB_CORE is not set
704CONFIG_DAB=y
705
706#
707# Graphics support
708#
709# CONFIG_VGASTATE is not set
710# CONFIG_VIDEO_OUTPUT_CONTROL is not set
711# CONFIG_FB is not set
712# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
713
714#
715# Display device support
716#
717# CONFIG_DISPLAY_SUPPORT is not set
718
719#
720# Sound
721#
722# CONFIG_SOUND is not set
723# CONFIG_USB_SUPPORT is not set
724# CONFIG_MMC is not set
725# CONFIG_MEMSTICK is not set
726CONFIG_NEW_LEDS=y
727CONFIG_LEDS_CLASS=y
728
729#
730# LED drivers
731#
732
733#
734# LED Triggers
735#
736CONFIG_LEDS_TRIGGERS=y
737CONFIG_LEDS_TRIGGER_TIMER=y
738# CONFIG_LEDS_TRIGGER_HEARTBEAT is not set
739# CONFIG_LEDS_TRIGGER_DEFAULT_ON is not set
740# CONFIG_EDAC is not set
741CONFIG_RTC_LIB=y
742CONFIG_RTC_CLASS=y
743CONFIG_RTC_HCTOSYS=y
744CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
745# CONFIG_RTC_DEBUG is not set
746
747#
748# RTC interfaces
749#
750CONFIG_RTC_INTF_SYSFS=y
751CONFIG_RTC_INTF_PROC=y
752CONFIG_RTC_INTF_DEV=y
753# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
754# CONFIG_RTC_DRV_TEST is not set
755
756#
757# I2C RTC drivers
758#
759CONFIG_RTC_DRV_DS1307=y
760# CONFIG_RTC_DRV_DS1374 is not set
761# CONFIG_RTC_DRV_DS1672 is not set
762# CONFIG_RTC_DRV_MAX6900 is not set
763# CONFIG_RTC_DRV_RS5C372 is not set
764# CONFIG_RTC_DRV_ISL1208 is not set
765# CONFIG_RTC_DRV_X1205 is not set
766# CONFIG_RTC_DRV_PCF8563 is not set
767# CONFIG_RTC_DRV_PCF8583 is not set
768# CONFIG_RTC_DRV_M41T80 is not set
769# CONFIG_RTC_DRV_S35390A is not set
770
771#
772# SPI RTC drivers
773#
774
775#
776# Platform RTC drivers
777#
778# CONFIG_RTC_DRV_CMOS is not set
779# CONFIG_RTC_DRV_DS1511 is not set
780# CONFIG_RTC_DRV_DS1553 is not set
781# CONFIG_RTC_DRV_DS1742 is not set
782# CONFIG_RTC_DRV_STK17TA8 is not set
783# CONFIG_RTC_DRV_M48T86 is not set
784# CONFIG_RTC_DRV_M48T59 is not set
785# CONFIG_RTC_DRV_V3020 is not set
786
787#
788# on-CPU RTC drivers
789#
790# CONFIG_DMADEVICES is not set
791# CONFIG_UIO is not set
792
793#
794# File systems
795#
796CONFIG_EXT2_FS=y
797# CONFIG_EXT2_FS_XATTR is not set
798# CONFIG_EXT2_FS_XIP is not set
799CONFIG_EXT3_FS=y
800CONFIG_EXT3_FS_XATTR=y
801# CONFIG_EXT3_FS_POSIX_ACL is not set
802# CONFIG_EXT3_FS_SECURITY is not set
803# CONFIG_EXT4DEV_FS is not set
804CONFIG_JBD=y
805CONFIG_FS_MBCACHE=y
806# CONFIG_REISERFS_FS is not set
807# CONFIG_JFS_FS is not set
808# CONFIG_FS_POSIX_ACL is not set
809# CONFIG_XFS_FS is not set
810# CONFIG_OCFS2_FS is not set
811CONFIG_DNOTIFY=y
812CONFIG_INOTIFY=y
813CONFIG_INOTIFY_USER=y
814# CONFIG_QUOTA is not set
815# CONFIG_AUTOFS_FS is not set
816# CONFIG_AUTOFS4_FS is not set
817# CONFIG_FUSE_FS is not set
818
819#
820# CD-ROM/DVD Filesystems
821#
822# CONFIG_ISO9660_FS is not set
823# CONFIG_UDF_FS is not set
824
825#
826# DOS/FAT/NT Filesystems
827#
828CONFIG_FAT_FS=y
829CONFIG_MSDOS_FS=y
830CONFIG_VFAT_FS=y
831CONFIG_FAT_DEFAULT_CODEPAGE=437
832CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
833# CONFIG_NTFS_FS is not set
834
835#
836# Pseudo filesystems
837#
838CONFIG_PROC_FS=y
839CONFIG_PROC_KCORE=y
840CONFIG_PROC_SYSCTL=y
841CONFIG_SYSFS=y
842CONFIG_TMPFS=y
843# CONFIG_TMPFS_POSIX_ACL is not set
844# CONFIG_HUGETLB_PAGE is not set
845# CONFIG_CONFIGFS_FS is not set
846
847#
848# Miscellaneous filesystems
849#
850# CONFIG_ADFS_FS is not set
851# CONFIG_AFFS_FS is not set
852# CONFIG_HFS_FS is not set
853# CONFIG_HFSPLUS_FS is not set
854# CONFIG_BEFS_FS is not set
855# CONFIG_BFS_FS is not set
856# CONFIG_EFS_FS is not set
857CONFIG_JFFS2_FS=y
858CONFIG_JFFS2_FS_DEBUG=0
859CONFIG_JFFS2_FS_WRITEBUFFER=y
860# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
861# CONFIG_JFFS2_SUMMARY is not set
862# CONFIG_JFFS2_FS_XATTR is not set
863# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
864CONFIG_JFFS2_ZLIB=y
865# CONFIG_JFFS2_LZO is not set
866CONFIG_JFFS2_RTIME=y
867# CONFIG_JFFS2_RUBIN is not set
868CONFIG_CRAMFS=y
869# CONFIG_VXFS_FS is not set
870# CONFIG_MINIX_FS is not set
871# CONFIG_HPFS_FS is not set
872# CONFIG_QNX4FS_FS is not set
873# CONFIG_ROMFS_FS is not set
874# CONFIG_SYSV_FS is not set
875# CONFIG_UFS_FS is not set
876CONFIG_NETWORK_FILESYSTEMS=y
877CONFIG_NFS_FS=y
878CONFIG_NFS_V3=y
879# CONFIG_NFS_V3_ACL is not set
880CONFIG_NFS_V4=y
881# CONFIG_NFSD is not set
882CONFIG_ROOT_NFS=y
883CONFIG_LOCKD=y
884CONFIG_LOCKD_V4=y
885CONFIG_NFS_COMMON=y
886CONFIG_SUNRPC=y
887CONFIG_SUNRPC_GSS=y
888# CONFIG_SUNRPC_BIND34 is not set
889CONFIG_RPCSEC_GSS_KRB5=y
890# CONFIG_RPCSEC_GSS_SPKM3 is not set
891# CONFIG_SMB_FS is not set
892# CONFIG_CIFS is not set
893# CONFIG_NCP_FS is not set
894# CONFIG_CODA_FS is not set
895# CONFIG_AFS_FS is not set
896
897#
898# Partition Types
899#
900CONFIG_PARTITION_ADVANCED=y
901# CONFIG_ACORN_PARTITION is not set
902# CONFIG_OSF_PARTITION is not set
903# CONFIG_AMIGA_PARTITION is not set
904# CONFIG_ATARI_PARTITION is not set
905# CONFIG_MAC_PARTITION is not set
906CONFIG_MSDOS_PARTITION=y
907# CONFIG_BSD_DISKLABEL is not set
908# CONFIG_MINIX_SUBPARTITION is not set
909# CONFIG_SOLARIS_X86_PARTITION is not set
910# CONFIG_UNIXWARE_DISKLABEL is not set
911# CONFIG_LDM_PARTITION is not set
912# CONFIG_SGI_PARTITION is not set
913# CONFIG_ULTRIX_PARTITION is not set
914# CONFIG_SUN_PARTITION is not set
915# CONFIG_KARMA_PARTITION is not set
916# CONFIG_EFI_PARTITION is not set
917# CONFIG_SYSV68_PARTITION is not set
918CONFIG_NLS=y
919CONFIG_NLS_DEFAULT="iso8859-1"
920CONFIG_NLS_CODEPAGE_437=y
921# CONFIG_NLS_CODEPAGE_737 is not set
922# CONFIG_NLS_CODEPAGE_775 is not set
923# CONFIG_NLS_CODEPAGE_850 is not set
924# CONFIG_NLS_CODEPAGE_852 is not set
925# CONFIG_NLS_CODEPAGE_855 is not set
926# CONFIG_NLS_CODEPAGE_857 is not set
927# CONFIG_NLS_CODEPAGE_860 is not set
928# CONFIG_NLS_CODEPAGE_861 is not set
929# CONFIG_NLS_CODEPAGE_862 is not set
930# CONFIG_NLS_CODEPAGE_863 is not set
931# CONFIG_NLS_CODEPAGE_864 is not set
932# CONFIG_NLS_CODEPAGE_865 is not set
933# CONFIG_NLS_CODEPAGE_866 is not set
934# CONFIG_NLS_CODEPAGE_869 is not set
935# CONFIG_NLS_CODEPAGE_936 is not set
936# CONFIG_NLS_CODEPAGE_950 is not set
937# CONFIG_NLS_CODEPAGE_932 is not set
938# CONFIG_NLS_CODEPAGE_949 is not set
939# CONFIG_NLS_CODEPAGE_874 is not set
940# CONFIG_NLS_ISO8859_8 is not set
941# CONFIG_NLS_CODEPAGE_1250 is not set
942# CONFIG_NLS_CODEPAGE_1251 is not set
943# CONFIG_NLS_ASCII is not set
944CONFIG_NLS_ISO8859_1=y
945# CONFIG_NLS_ISO8859_2 is not set
946# CONFIG_NLS_ISO8859_3 is not set
947# CONFIG_NLS_ISO8859_4 is not set
948# CONFIG_NLS_ISO8859_5 is not set
949# CONFIG_NLS_ISO8859_6 is not set
950# CONFIG_NLS_ISO8859_7 is not set
951# CONFIG_NLS_ISO8859_9 is not set
952# CONFIG_NLS_ISO8859_13 is not set
953# CONFIG_NLS_ISO8859_14 is not set
954# CONFIG_NLS_ISO8859_15 is not set
955# CONFIG_NLS_KOI8_R is not set
956# CONFIG_NLS_KOI8_U is not set
957# CONFIG_NLS_UTF8 is not set
958# CONFIG_DLM is not set
959
960#
961# Library routines
962#
963CONFIG_BITREVERSE=y
964# CONFIG_GENERIC_FIND_FIRST_BIT is not set
965# CONFIG_CRC_CCITT is not set
966# CONFIG_CRC16 is not set
967# CONFIG_CRC_ITU_T is not set
968CONFIG_CRC32=y
969# CONFIG_CRC7 is not set
970# CONFIG_LIBCRC32C is not set
971CONFIG_ZLIB_INFLATE=y
972CONFIG_ZLIB_DEFLATE=y
973CONFIG_PLIST=y
974CONFIG_HAS_IOMEM=y
975CONFIG_HAS_IOPORT=y
976CONFIG_HAS_DMA=y
977CONFIG_HAVE_LMB=y
978
979#
980# Kernel hacking
981#
982CONFIG_PRINTK_TIME=y
983CONFIG_ENABLE_WARN_DEPRECATED=y
984CONFIG_ENABLE_MUST_CHECK=y
985CONFIG_FRAME_WARN=1024
986# CONFIG_MAGIC_SYSRQ is not set
987# CONFIG_UNUSED_SYMBOLS is not set
988# CONFIG_DEBUG_FS is not set
989# CONFIG_HEADERS_CHECK is not set
990CONFIG_DEBUG_KERNEL=y
991# CONFIG_DEBUG_SHIRQ is not set
992CONFIG_DETECT_SOFTLOCKUP=y
993CONFIG_SCHED_DEBUG=y
994# CONFIG_SCHEDSTATS is not set
995# CONFIG_TIMER_STATS is not set
996# CONFIG_SLUB_DEBUG_ON is not set
997# CONFIG_SLUB_STATS is not set
998# CONFIG_DEBUG_RT_MUTEXES is not set
999# CONFIG_RT_MUTEX_TESTER is not set
1000# CONFIG_DEBUG_SPINLOCK is not set
1001# CONFIG_DEBUG_MUTEXES is not set
1002# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1003# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1004# CONFIG_DEBUG_KOBJECT is not set
1005# CONFIG_DEBUG_BUGVERBOSE is not set
1006CONFIG_DEBUG_INFO=y
1007# CONFIG_DEBUG_VM is not set
1008# CONFIG_DEBUG_WRITECOUNT is not set
1009# CONFIG_DEBUG_LIST is not set
1010# CONFIG_DEBUG_SG is not set
1011# CONFIG_BOOT_PRINTK_DELAY is not set
1012# CONFIG_BACKTRACE_SELF_TEST is not set
1013# CONFIG_FAULT_INJECTION is not set
1014# CONFIG_SAMPLES is not set
1015# CONFIG_DEBUG_STACKOVERFLOW is not set
1016# CONFIG_DEBUG_STACK_USAGE is not set
1017# CONFIG_DEBUG_PAGEALLOC is not set
1018# CONFIG_DEBUGGER is not set
1019# CONFIG_IRQSTACKS is not set
1020# CONFIG_BDI_SWITCH is not set
1021# CONFIG_BOOTX_TEXT is not set
1022# CONFIG_PPC_EARLY_DEBUG is not set
1023
1024#
1025# Security options
1026#
1027# CONFIG_KEYS is not set
1028# CONFIG_SECURITY is not set
1029# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1030CONFIG_CRYPTO=y
1031
1032#
1033# Crypto core or helper
1034#
1035CONFIG_CRYPTO_ALGAPI=y
1036CONFIG_CRYPTO_BLKCIPHER=y
1037CONFIG_CRYPTO_MANAGER=y
1038# CONFIG_CRYPTO_GF128MUL is not set
1039# CONFIG_CRYPTO_NULL is not set
1040# CONFIG_CRYPTO_CRYPTD is not set
1041# CONFIG_CRYPTO_AUTHENC is not set
1042
1043#
1044# Authenticated Encryption with Associated Data
1045#
1046# CONFIG_CRYPTO_CCM is not set
1047# CONFIG_CRYPTO_GCM is not set
1048# CONFIG_CRYPTO_SEQIV is not set
1049
1050#
1051# Block modes
1052#
1053CONFIG_CRYPTO_CBC=y
1054# CONFIG_CRYPTO_CTR is not set
1055# CONFIG_CRYPTO_CTS is not set
1056CONFIG_CRYPTO_ECB=y
1057# CONFIG_CRYPTO_LRW is not set
1058CONFIG_CRYPTO_PCBC=y
1059# CONFIG_CRYPTO_XTS is not set
1060
1061#
1062# Hash modes
1063#
1064# CONFIG_CRYPTO_HMAC is not set
1065# CONFIG_CRYPTO_XCBC is not set
1066
1067#
1068# Digest
1069#
1070# CONFIG_CRYPTO_CRC32C is not set
1071# CONFIG_CRYPTO_MD4 is not set
1072CONFIG_CRYPTO_MD5=y
1073# CONFIG_CRYPTO_MICHAEL_MIC is not set
1074# CONFIG_CRYPTO_SHA1 is not set
1075# CONFIG_CRYPTO_SHA256 is not set
1076# CONFIG_CRYPTO_SHA512 is not set
1077# CONFIG_CRYPTO_TGR192 is not set
1078# CONFIG_CRYPTO_WP512 is not set
1079
1080#
1081# Ciphers
1082#
1083# CONFIG_CRYPTO_AES is not set
1084# CONFIG_CRYPTO_ANUBIS is not set
1085# CONFIG_CRYPTO_ARC4 is not set
1086# CONFIG_CRYPTO_BLOWFISH is not set
1087# CONFIG_CRYPTO_CAMELLIA is not set
1088# CONFIG_CRYPTO_CAST5 is not set
1089# CONFIG_CRYPTO_CAST6 is not set
1090CONFIG_CRYPTO_DES=y
1091# CONFIG_CRYPTO_FCRYPT is not set
1092# CONFIG_CRYPTO_KHAZAD is not set
1093# CONFIG_CRYPTO_SALSA20 is not set
1094# CONFIG_CRYPTO_SEED is not set
1095# CONFIG_CRYPTO_SERPENT is not set
1096# CONFIG_CRYPTO_TEA is not set
1097# CONFIG_CRYPTO_TWOFISH is not set
1098
1099#
1100# Compression
1101#
1102# CONFIG_CRYPTO_DEFLATE is not set
1103# CONFIG_CRYPTO_LZO is not set
1104CONFIG_CRYPTO_HW=y
1105CONFIG_PPC_CLOCK=y
1106CONFIG_PPC_LIB_RHEAP=y
1107# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/configs/52xx/pcm030_defconfig b/arch/powerpc/configs/52xx/pcm030_defconfig
new file mode 100644
index 000000000000..9c0caa488b2e
--- /dev/null
+++ b/arch/powerpc/configs/52xx/pcm030_defconfig
@@ -0,0 +1,1115 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Tue Apr 29 07:13:19 2008
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11CONFIG_6xx=y
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18# CONFIG_ALTIVEC is not set
19CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_32=y
21# CONFIG_PPC_MM_SLICES is not set
22# CONFIG_SMP is not set
23CONFIG_PPC32=y
24CONFIG_WORD_SIZE=32
25CONFIG_PPC_MERGE=y
26CONFIG_MMU=y
27CONFIG_GENERIC_CMOS_UPDATE=y
28CONFIG_GENERIC_TIME=y
29CONFIG_GENERIC_TIME_VSYSCALL=y
30CONFIG_GENERIC_CLOCKEVENTS=y
31CONFIG_GENERIC_HARDIRQS=y
32# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
33CONFIG_IRQ_PER_CPU=y
34CONFIG_STACKTRACE_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y
43CONFIG_EARLY_PRINTK=y
44CONFIG_GENERIC_NVRAM=y
45CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
46CONFIG_ARCH_MAY_HAVE_PC_FDC=y
47CONFIG_PPC_OF=y
48CONFIG_OF=y
49# CONFIG_PPC_UDBG_16550 is not set
50# CONFIG_GENERIC_TBSYNC is not set
51CONFIG_AUDIT_ARCH=y
52CONFIG_GENERIC_BUG=y
53CONFIG_DEFAULT_UIMAGE=y
54# CONFIG_PPC_DCR_NATIVE is not set
55# CONFIG_PPC_DCR_MMIO is not set
56CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
57
58#
59# General setup
60#
61CONFIG_EXPERIMENTAL=y
62CONFIG_BROKEN_ON_SMP=y
63CONFIG_LOCK_KERNEL=y
64CONFIG_INIT_ENV_ARG_LIMIT=32
65CONFIG_LOCALVERSION="trunk"
66# CONFIG_LOCALVERSION_AUTO is not set
67# CONFIG_SWAP is not set
68CONFIG_SYSVIPC=y
69CONFIG_SYSVIPC_SYSCTL=y
70CONFIG_POSIX_MQUEUE=y
71# CONFIG_BSD_PROCESS_ACCT is not set
72# CONFIG_TASKSTATS is not set
73# CONFIG_AUDIT is not set
74CONFIG_IKCONFIG=y
75CONFIG_IKCONFIG_PROC=y
76CONFIG_LOG_BUF_SHIFT=14
77# CONFIG_CGROUPS is not set
78CONFIG_GROUP_SCHED=y
79CONFIG_FAIR_GROUP_SCHED=y
80# CONFIG_RT_GROUP_SCHED is not set
81CONFIG_USER_SCHED=y
82# CONFIG_CGROUP_SCHED is not set
83CONFIG_SYSFS_DEPRECATED=y
84CONFIG_SYSFS_DEPRECATED_V2=y
85# CONFIG_RELAY is not set
86# CONFIG_NAMESPACES is not set
87# CONFIG_BLK_DEV_INITRD is not set
88# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
89CONFIG_SYSCTL=y
90CONFIG_EMBEDDED=y
91# CONFIG_SYSCTL_SYSCALL is not set
92CONFIG_KALLSYMS=y
93# CONFIG_KALLSYMS_EXTRA_PASS is not set
94CONFIG_HOTPLUG=y
95CONFIG_PRINTK=y
96CONFIG_BUG=y
97CONFIG_ELF_CORE=y
98CONFIG_COMPAT_BRK=y
99CONFIG_BASE_FULL=y
100CONFIG_FUTEX=y
101CONFIG_ANON_INODES=y
102CONFIG_EPOLL=y
103CONFIG_SIGNALFD=y
104CONFIG_TIMERFD=y
105CONFIG_EVENTFD=y
106CONFIG_SHMEM=y
107# CONFIG_VM_EVENT_COUNTERS is not set
108CONFIG_SLAB=y
109# CONFIG_SLUB is not set
110# CONFIG_SLOB is not set
111# CONFIG_PROFILING is not set
112# CONFIG_MARKERS is not set
113CONFIG_HAVE_OPROFILE=y
114# CONFIG_KPROBES is not set
115CONFIG_HAVE_KPROBES=y
116CONFIG_HAVE_KRETPROBES=y
117CONFIG_PROC_PAGE_MONITOR=y
118CONFIG_SLABINFO=y
119CONFIG_RT_MUTEXES=y
120# CONFIG_TINY_SHMEM is not set
121CONFIG_BASE_SMALL=0
122CONFIG_MODULES=y
123CONFIG_MODULE_UNLOAD=y
124# CONFIG_MODULE_FORCE_UNLOAD is not set
125# CONFIG_MODVERSIONS is not set
126# CONFIG_MODULE_SRCVERSION_ALL is not set
127# CONFIG_KMOD is not set
128CONFIG_BLOCK=y
129# CONFIG_LBD is not set
130# CONFIG_BLK_DEV_IO_TRACE is not set
131# CONFIG_LSF is not set
132# CONFIG_BLK_DEV_BSG is not set
133
134#
135# IO Schedulers
136#
137CONFIG_IOSCHED_NOOP=y
138# CONFIG_IOSCHED_AS is not set
139# CONFIG_IOSCHED_DEADLINE is not set
140# CONFIG_IOSCHED_CFQ is not set
141# CONFIG_DEFAULT_AS is not set
142# CONFIG_DEFAULT_DEADLINE is not set
143# CONFIG_DEFAULT_CFQ is not set
144CONFIG_DEFAULT_NOOP=y
145CONFIG_DEFAULT_IOSCHED="noop"
146CONFIG_CLASSIC_RCU=y
147
148#
149# Platform support
150#
151CONFIG_PPC_MULTIPLATFORM=y
152# CONFIG_PPC_82xx is not set
153# CONFIG_PPC_83xx is not set
154# CONFIG_PPC_86xx is not set
155CONFIG_CLASSIC32=y
156# CONFIG_PPC_CHRP is not set
157# CONFIG_PPC_MPC512x is not set
158# CONFIG_PPC_MPC5121 is not set
159# CONFIG_MPC5121_ADS is not set
160CONFIG_PPC_MPC52xx=y
161CONFIG_PPC_MPC5200_SIMPLE=y
162# CONFIG_PPC_EFIKA is not set
163# CONFIG_PPC_LITE5200 is not set
164# CONFIG_PPC_MPC5200_BUGFIX is not set
165# CONFIG_PPC_MPC5200_GPIO is not set
166# CONFIG_PPC_PMAC is not set
167# CONFIG_PPC_CELL is not set
168# CONFIG_PPC_CELL_NATIVE is not set
169# CONFIG_PQ2ADS is not set
170# CONFIG_EMBEDDED6xx is not set
171# CONFIG_IPIC is not set
172# CONFIG_MPIC is not set
173# CONFIG_MPIC_WEIRD is not set
174# CONFIG_PPC_I8259 is not set
175# CONFIG_PPC_RTAS is not set
176# CONFIG_MMIO_NVRAM is not set
177# CONFIG_PPC_MPC106 is not set
178# CONFIG_PPC_970_NAP is not set
179# CONFIG_PPC_INDIRECT_IO is not set
180# CONFIG_GENERIC_IOMAP is not set
181# CONFIG_CPU_FREQ is not set
182# CONFIG_TAU is not set
183# CONFIG_FSL_ULI1575 is not set
184CONFIG_PPC_BESTCOMM=y
185CONFIG_PPC_BESTCOMM_ATA=y
186CONFIG_PPC_BESTCOMM_FEC=y
187CONFIG_PPC_BESTCOMM_GEN_BD=y
188
189#
190# Kernel options
191#
192# CONFIG_HIGHMEM is not set
193CONFIG_TICK_ONESHOT=y
194CONFIG_NO_HZ=y
195CONFIG_HIGH_RES_TIMERS=y
196CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
197CONFIG_HZ_100=y
198# CONFIG_HZ_250 is not set
199# CONFIG_HZ_300 is not set
200# CONFIG_HZ_1000 is not set
201CONFIG_HZ=100
202# CONFIG_SCHED_HRTICK is not set
203# CONFIG_PREEMPT_NONE is not set
204# CONFIG_PREEMPT_VOLUNTARY is not set
205CONFIG_PREEMPT=y
206# CONFIG_PREEMPT_RCU is not set
207CONFIG_BINFMT_ELF=y
208# CONFIG_BINFMT_MISC is not set
209# CONFIG_IOMMU_HELPER is not set
210CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
211CONFIG_ARCH_HAS_WALK_MEMORY=y
212CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
213# CONFIG_KEXEC is not set
214CONFIG_ARCH_FLATMEM_ENABLE=y
215CONFIG_ARCH_POPULATES_NODE_MAP=y
216CONFIG_SELECT_MEMORY_MODEL=y
217CONFIG_FLATMEM_MANUAL=y
218# CONFIG_DISCONTIGMEM_MANUAL is not set
219# CONFIG_SPARSEMEM_MANUAL is not set
220CONFIG_FLATMEM=y
221CONFIG_FLAT_NODE_MEM_MAP=y
222# CONFIG_SPARSEMEM_STATIC is not set
223# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
224CONFIG_PAGEFLAGS_EXTENDED=y
225CONFIG_SPLIT_PTLOCK_CPUS=4
226# CONFIG_RESOURCES_64BIT is not set
227CONFIG_ZONE_DMA_FLAG=1
228CONFIG_BOUNCE=y
229CONFIG_VIRT_TO_BUS=y
230CONFIG_FORCE_MAX_ZONEORDER=11
231CONFIG_PROC_DEVICETREE=y
232# CONFIG_CMDLINE_BOOL is not set
233# CONFIG_PM is not set
234# CONFIG_SECCOMP is not set
235CONFIG_ISA_DMA_API=y
236
237#
238# Bus options
239#
240CONFIG_ZONE_DMA=y
241CONFIG_GENERIC_ISA_DMA=y
242# CONFIG_PPC_INDIRECT_PCI is not set
243CONFIG_FSL_SOC=y
244CONFIG_PCI=y
245CONFIG_PCI_DOMAINS=y
246CONFIG_PCI_SYSCALL=y
247# CONFIG_PCIEPORTBUS is not set
248CONFIG_ARCH_SUPPORTS_MSI=y
249# CONFIG_PCI_MSI is not set
250CONFIG_PCI_LEGACY=y
251# CONFIG_PCCARD is not set
252# CONFIG_HOTPLUG_PCI is not set
253# CONFIG_HAS_RAPIDIO is not set
254
255#
256# Advanced setup
257#
258# CONFIG_ADVANCED_OPTIONS is not set
259
260#
261# Default settings for advanced configuration options are used
262#
263CONFIG_LOWMEM_SIZE=0x30000000
264CONFIG_PAGE_OFFSET=0xc0000000
265CONFIG_KERNEL_START=0xc0000000
266CONFIG_PHYSICAL_START=0x00000000
267CONFIG_TASK_SIZE=0xc0000000
268
269#
270# Networking
271#
272CONFIG_NET=y
273
274#
275# Networking options
276#
277CONFIG_PACKET=y
278# CONFIG_PACKET_MMAP is not set
279CONFIG_UNIX=y
280# CONFIG_NET_KEY is not set
281CONFIG_INET=y
282CONFIG_IP_MULTICAST=y
283# CONFIG_IP_ADVANCED_ROUTER is not set
284CONFIG_IP_FIB_HASH=y
285CONFIG_IP_PNP=y
286CONFIG_IP_PNP_DHCP=y
287CONFIG_IP_PNP_BOOTP=y
288# CONFIG_IP_PNP_RARP is not set
289# CONFIG_NET_IPIP is not set
290# CONFIG_NET_IPGRE is not set
291# CONFIG_IP_MROUTE is not set
292# CONFIG_ARPD is not set
293# CONFIG_SYN_COOKIES is not set
294# CONFIG_INET_AH is not set
295# CONFIG_INET_ESP is not set
296# CONFIG_INET_IPCOMP is not set
297# CONFIG_INET_XFRM_TUNNEL is not set
298# CONFIG_INET_TUNNEL is not set
299# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
300# CONFIG_INET_XFRM_MODE_TUNNEL is not set
301# CONFIG_INET_XFRM_MODE_BEET is not set
302# CONFIG_INET_LRO is not set
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_TCP_MD5SIG is not set
308# CONFIG_IPV6 is not set
309# CONFIG_NETWORK_SECMARK is not set
310# CONFIG_NETFILTER is not set
311# CONFIG_IP_DCCP is not set
312# CONFIG_IP_SCTP is not set
313# CONFIG_TIPC is not set
314# CONFIG_ATM is not set
315# CONFIG_BRIDGE is not set
316# CONFIG_VLAN_8021Q is not set
317# CONFIG_DECNET is not set
318# CONFIG_LLC2 is not set
319# CONFIG_IPX is not set
320# CONFIG_ATALK is not set
321# CONFIG_X25 is not set
322# CONFIG_LAPB is not set
323# CONFIG_ECONET is not set
324# CONFIG_WAN_ROUTER is not set
325# CONFIG_NET_SCHED is not set
326
327#
328# Network testing
329#
330# CONFIG_NET_PKTGEN is not set
331# CONFIG_HAMRADIO is not set
332# CONFIG_CAN is not set
333# CONFIG_IRDA is not set
334# CONFIG_BT is not set
335# CONFIG_AF_RXRPC is not set
336
337#
338# Wireless
339#
340# CONFIG_CFG80211 is not set
341# CONFIG_WIRELESS_EXT is not set
342# CONFIG_MAC80211 is not set
343# CONFIG_IEEE80211 is not set
344# CONFIG_RFKILL is not set
345# CONFIG_NET_9P is not set
346
347#
348# Device Drivers
349#
350
351#
352# Generic Driver Options
353#
354CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
355CONFIG_STANDALONE=y
356CONFIG_PREVENT_FIRMWARE_BUILD=y
357# CONFIG_FW_LOADER is not set
358# CONFIG_SYS_HYPERVISOR is not set
359# CONFIG_CONNECTOR is not set
360CONFIG_MTD=y
361# CONFIG_MTD_DEBUG is not set
362# CONFIG_MTD_CONCAT is not set
363CONFIG_MTD_PARTITIONS=y
364# CONFIG_MTD_REDBOOT_PARTS is not set
365CONFIG_MTD_CMDLINE_PARTS=y
366# CONFIG_MTD_OF_PARTS is not set
367# CONFIG_MTD_AR7_PARTS is not set
368
369#
370# User Modules And Translation Layers
371#
372CONFIG_MTD_CHAR=y
373CONFIG_MTD_BLKDEVS=y
374CONFIG_MTD_BLOCK=y
375# CONFIG_FTL is not set
376# CONFIG_NFTL is not set
377# CONFIG_INFTL is not set
378# CONFIG_RFD_FTL is not set
379# CONFIG_SSFDC is not set
380# CONFIG_MTD_OOPS is not set
381
382#
383# RAM/ROM/Flash chip drivers
384#
385CONFIG_MTD_CFI=y
386# CONFIG_MTD_JEDECPROBE is not set
387CONFIG_MTD_GEN_PROBE=y
388# CONFIG_MTD_CFI_ADV_OPTIONS is not set
389CONFIG_MTD_MAP_BANK_WIDTH_1=y
390CONFIG_MTD_MAP_BANK_WIDTH_2=y
391CONFIG_MTD_MAP_BANK_WIDTH_4=y
392# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
393# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
394# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
395CONFIG_MTD_CFI_I1=y
396CONFIG_MTD_CFI_I2=y
397# CONFIG_MTD_CFI_I4 is not set
398# CONFIG_MTD_CFI_I8 is not set
399CONFIG_MTD_CFI_INTELEXT=y
400# CONFIG_MTD_CFI_AMDSTD is not set
401# CONFIG_MTD_CFI_STAA is not set
402CONFIG_MTD_CFI_UTIL=y
403# CONFIG_MTD_RAM is not set
404# CONFIG_MTD_ROM is not set
405# CONFIG_MTD_ABSENT is not set
406
407#
408# Mapping drivers for chip access
409#
410# CONFIG_MTD_COMPLEX_MAPPINGS is not set
411CONFIG_MTD_PHYSMAP=y
412CONFIG_MTD_PHYSMAP_START=0x0
413CONFIG_MTD_PHYSMAP_LEN=0x0
414CONFIG_MTD_PHYSMAP_BANKWIDTH=1
415# CONFIG_MTD_PHYSMAP_OF is not set
416# CONFIG_MTD_INTEL_VR_NOR is not set
417# CONFIG_MTD_PLATRAM is not set
418
419#
420# Self-contained MTD device drivers
421#
422# CONFIG_MTD_PMC551 is not set
423# CONFIG_MTD_SLRAM is not set
424# CONFIG_MTD_PHRAM is not set
425# CONFIG_MTD_MTDRAM is not set
426# CONFIG_MTD_BLOCK2MTD is not set
427
428#
429# Disk-On-Chip Device Drivers
430#
431# CONFIG_MTD_DOC2000 is not set
432# CONFIG_MTD_DOC2001 is not set
433# CONFIG_MTD_DOC2001PLUS is not set
434# CONFIG_MTD_NAND is not set
435# CONFIG_MTD_ONENAND is not set
436
437#
438# UBI - Unsorted block images
439#
440# CONFIG_MTD_UBI is not set
441CONFIG_OF_DEVICE=y
442CONFIG_OF_I2C=y
443# CONFIG_PARPORT is not set
444# CONFIG_BLK_DEV is not set
445# CONFIG_MISC_DEVICES is not set
446CONFIG_HAVE_IDE=y
447# CONFIG_IDE is not set
448
449#
450# SCSI device support
451#
452# CONFIG_RAID_ATTRS is not set
453CONFIG_SCSI=m
454CONFIG_SCSI_DMA=y
455# CONFIG_SCSI_TGT is not set
456# CONFIG_SCSI_NETLINK is not set
457# CONFIG_SCSI_PROC_FS is not set
458
459#
460# SCSI support type (disk, tape, CD-ROM)
461#
462CONFIG_BLK_DEV_SD=m
463# CONFIG_CHR_DEV_ST is not set
464# CONFIG_CHR_DEV_OSST is not set
465# CONFIG_BLK_DEV_SR is not set
466# CONFIG_CHR_DEV_SG is not set
467# CONFIG_CHR_DEV_SCH is not set
468
469#
470# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
471#
472# CONFIG_SCSI_MULTI_LUN is not set
473# CONFIG_SCSI_CONSTANTS is not set
474# CONFIG_SCSI_LOGGING is not set
475# CONFIG_SCSI_SCAN_ASYNC is not set
476CONFIG_SCSI_WAIT_SCAN=m
477
478#
479# SCSI Transports
480#
481# CONFIG_SCSI_SPI_ATTRS is not set
482# CONFIG_SCSI_FC_ATTRS is not set
483# CONFIG_SCSI_ISCSI_ATTRS is not set
484# CONFIG_SCSI_SAS_LIBSAS is not set
485# CONFIG_SCSI_SRP_ATTRS is not set
486# CONFIG_SCSI_LOWLEVEL is not set
487CONFIG_ATA=m
488# CONFIG_ATA_NONSTANDARD is not set
489CONFIG_SATA_PMP=y
490# CONFIG_SATA_AHCI is not set
491# CONFIG_SATA_SIL24 is not set
492# CONFIG_SATA_FSL is not set
493CONFIG_ATA_SFF=y
494# CONFIG_SATA_SVW is not set
495# CONFIG_ATA_PIIX is not set
496# CONFIG_SATA_MV is not set
497# CONFIG_SATA_NV is not set
498# CONFIG_PDC_ADMA is not set
499# CONFIG_SATA_QSTOR is not set
500# CONFIG_SATA_PROMISE is not set
501# CONFIG_SATA_SX4 is not set
502# CONFIG_SATA_SIL is not set
503# CONFIG_SATA_SIS is not set
504# CONFIG_SATA_ULI is not set
505# CONFIG_SATA_VIA is not set
506# CONFIG_SATA_VITESSE is not set
507# CONFIG_SATA_INIC162X is not set
508# CONFIG_PATA_ALI is not set
509# CONFIG_PATA_AMD is not set
510# CONFIG_PATA_ARTOP is not set
511# CONFIG_PATA_ATIIXP is not set
512# CONFIG_PATA_CMD640_PCI is not set
513# CONFIG_PATA_CMD64X is not set
514# CONFIG_PATA_CS5520 is not set
515# CONFIG_PATA_CS5530 is not set
516# CONFIG_PATA_CYPRESS is not set
517# CONFIG_PATA_EFAR is not set
518# CONFIG_ATA_GENERIC is not set
519# CONFIG_PATA_HPT366 is not set
520# CONFIG_PATA_HPT37X is not set
521# CONFIG_PATA_HPT3X2N is not set
522# CONFIG_PATA_HPT3X3 is not set
523# CONFIG_PATA_IT821X is not set
524# CONFIG_PATA_IT8213 is not set
525# CONFIG_PATA_JMICRON is not set
526# CONFIG_PATA_TRIFLEX is not set
527# CONFIG_PATA_MARVELL is not set
528CONFIG_PATA_MPC52xx=m
529# CONFIG_PATA_MPIIX is not set
530# CONFIG_PATA_OLDPIIX is not set
531# CONFIG_PATA_NETCELL is not set
532# CONFIG_PATA_NINJA32 is not set
533# CONFIG_PATA_NS87410 is not set
534# CONFIG_PATA_NS87415 is not set
535# CONFIG_PATA_OPTI is not set
536# CONFIG_PATA_OPTIDMA is not set
537# CONFIG_PATA_PDC_OLD is not set
538# CONFIG_PATA_RADISYS is not set
539# CONFIG_PATA_RZ1000 is not set
540# CONFIG_PATA_SC1200 is not set
541# CONFIG_PATA_SERVERWORKS is not set
542# CONFIG_PATA_PDC2027X is not set
543# CONFIG_PATA_SIL680 is not set
544# CONFIG_PATA_SIS is not set
545# CONFIG_PATA_VIA is not set
546# CONFIG_PATA_WINBOND is not set
547# CONFIG_PATA_PLATFORM is not set
548# CONFIG_MD is not set
549# CONFIG_FUSION is not set
550
551#
552# IEEE 1394 (FireWire) support
553#
554# CONFIG_FIREWIRE is not set
555# CONFIG_IEEE1394 is not set
556# CONFIG_I2O is not set
557# CONFIG_MACINTOSH_DRIVERS is not set
558CONFIG_NETDEVICES=y
559# CONFIG_NETDEVICES_MULTIQUEUE is not set
560# CONFIG_DUMMY is not set
561# CONFIG_BONDING is not set
562# CONFIG_MACVLAN is not set
563# CONFIG_EQUALIZER is not set
564# CONFIG_TUN is not set
565# CONFIG_VETH is not set
566# CONFIG_ARCNET is not set
567CONFIG_PHYLIB=y
568
569#
570# MII PHY device drivers
571#
572# CONFIG_MARVELL_PHY is not set
573# CONFIG_DAVICOM_PHY is not set
574# CONFIG_QSEMI_PHY is not set
575# CONFIG_LXT_PHY is not set
576# CONFIG_CICADA_PHY is not set
577# CONFIG_VITESSE_PHY is not set
578# CONFIG_SMSC_PHY is not set
579# CONFIG_BROADCOM_PHY is not set
580# CONFIG_ICPLUS_PHY is not set
581# CONFIG_REALTEK_PHY is not set
582# CONFIG_FIXED_PHY is not set
583# CONFIG_MDIO_BITBANG is not set
584CONFIG_NET_ETHERNET=y
585CONFIG_MII=y
586# CONFIG_HAPPYMEAL is not set
587# CONFIG_SUNGEM is not set
588# CONFIG_CASSINI is not set
589# CONFIG_NET_VENDOR_3COM is not set
590# CONFIG_NET_TULIP is not set
591# CONFIG_HP100 is not set
592# CONFIG_IBM_NEW_EMAC_ZMII is not set
593# CONFIG_IBM_NEW_EMAC_RGMII is not set
594# CONFIG_IBM_NEW_EMAC_TAH is not set
595# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
596# CONFIG_NET_PCI is not set
597# CONFIG_B44 is not set
598CONFIG_FEC_MPC52xx=y
599CONFIG_FEC_MPC52xx_MDIO=y
600# CONFIG_NETDEV_1000 is not set
601# CONFIG_NETDEV_10000 is not set
602# CONFIG_TR is not set
603
604#
605# Wireless LAN
606#
607# CONFIG_WLAN_PRE80211 is not set
608# CONFIG_WLAN_80211 is not set
609# CONFIG_IWLWIFI is not set
610# CONFIG_IWLWIFI_LEDS is not set
611
612#
613# USB Network Adapters
614#
615# CONFIG_USB_CATC is not set
616# CONFIG_USB_KAWETH is not set
617# CONFIG_USB_PEGASUS is not set
618# CONFIG_USB_RTL8150 is not set
619# CONFIG_USB_USBNET is not set
620# CONFIG_WAN is not set
621# CONFIG_FDDI is not set
622# CONFIG_HIPPI is not set
623# CONFIG_PPP is not set
624# CONFIG_SLIP is not set
625# CONFIG_NET_FC is not set
626# CONFIG_NETCONSOLE is not set
627# CONFIG_NETPOLL is not set
628# CONFIG_NET_POLL_CONTROLLER is not set
629# CONFIG_ISDN is not set
630# CONFIG_PHONE is not set
631
632#
633# Input device support
634#
635# CONFIG_INPUT is not set
636
637#
638# Hardware I/O ports
639#
640# CONFIG_SERIO is not set
641# CONFIG_GAMEPORT is not set
642
643#
644# Character devices
645#
646# CONFIG_VT is not set
647# CONFIG_SERIAL_NONSTANDARD is not set
648# CONFIG_NOZOMI is not set
649
650#
651# Serial drivers
652#
653# CONFIG_SERIAL_8250 is not set
654
655#
656# Non-8250 serial port support
657#
658# CONFIG_SERIAL_UARTLITE is not set
659CONFIG_SERIAL_CORE=y
660CONFIG_SERIAL_CORE_CONSOLE=y
661CONFIG_SERIAL_MPC52xx=y
662CONFIG_SERIAL_MPC52xx_CONSOLE=y
663CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=9600
664# CONFIG_SERIAL_JSM is not set
665CONFIG_UNIX98_PTYS=y
666# CONFIG_LEGACY_PTYS is not set
667# CONFIG_IPMI_HANDLER is not set
668CONFIG_HW_RANDOM=y
669# CONFIG_NVRAM is not set
670# CONFIG_R3964 is not set
671# CONFIG_APPLICOM is not set
672# CONFIG_RAW_DRIVER is not set
673# CONFIG_TCG_TPM is not set
674CONFIG_DEVPORT=y
675CONFIG_I2C=y
676CONFIG_I2C_BOARDINFO=y
677CONFIG_I2C_CHARDEV=y
678
679#
680# I2C Hardware Bus support
681#
682# CONFIG_I2C_ALI1535 is not set
683# CONFIG_I2C_ALI1563 is not set
684# CONFIG_I2C_ALI15X3 is not set
685# CONFIG_I2C_AMD756 is not set
686# CONFIG_I2C_AMD8111 is not set
687# CONFIG_I2C_I801 is not set
688# CONFIG_I2C_I810 is not set
689# CONFIG_I2C_PIIX4 is not set
690CONFIG_I2C_MPC=y
691# CONFIG_I2C_NFORCE2 is not set
692# CONFIG_I2C_OCORES is not set
693# CONFIG_I2C_PARPORT_LIGHT is not set
694# CONFIG_I2C_PROSAVAGE is not set
695# CONFIG_I2C_SAVAGE4 is not set
696# CONFIG_I2C_SIMTEC is not set
697# CONFIG_I2C_SIS5595 is not set
698# CONFIG_I2C_SIS630 is not set
699# CONFIG_I2C_SIS96X is not set
700# CONFIG_I2C_TAOS_EVM is not set
701# CONFIG_I2C_STUB is not set
702# CONFIG_I2C_TINY_USB is not set
703# CONFIG_I2C_VIA is not set
704# CONFIG_I2C_VIAPRO is not set
705# CONFIG_I2C_VOODOO3 is not set
706# CONFIG_I2C_PCA_PLATFORM is not set
707
708#
709# Miscellaneous I2C Chip support
710#
711# CONFIG_DS1682 is not set
712CONFIG_SENSORS_EEPROM=m
713# CONFIG_SENSORS_PCF8574 is not set
714# CONFIG_PCF8575 is not set
715# CONFIG_SENSORS_PCF8591 is not set
716# CONFIG_SENSORS_MAX6875 is not set
717# CONFIG_SENSORS_TSL2550 is not set
718# CONFIG_I2C_DEBUG_CORE is not set
719# CONFIG_I2C_DEBUG_ALGO is not set
720# CONFIG_I2C_DEBUG_BUS is not set
721# CONFIG_I2C_DEBUG_CHIP is not set
722# CONFIG_SPI is not set
723# CONFIG_W1 is not set
724# CONFIG_POWER_SUPPLY is not set
725# CONFIG_HWMON is not set
726# CONFIG_THERMAL is not set
727# CONFIG_WATCHDOG is not set
728
729#
730# Sonics Silicon Backplane
731#
732CONFIG_SSB_POSSIBLE=y
733# CONFIG_SSB is not set
734
735#
736# Multifunction device drivers
737#
738# CONFIG_MFD_SM501 is not set
739# CONFIG_HTC_PASIC3 is not set
740
741#
742# Multimedia devices
743#
744# CONFIG_VIDEO_DEV is not set
745# CONFIG_DVB_CORE is not set
746# CONFIG_DAB is not set
747
748#
749# Graphics support
750#
751# CONFIG_AGP is not set
752# CONFIG_DRM is not set
753# CONFIG_VGASTATE is not set
754# CONFIG_VIDEO_OUTPUT_CONTROL is not set
755# CONFIG_FB is not set
756# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
757
758#
759# Display device support
760#
761# CONFIG_DISPLAY_SUPPORT is not set
762
763#
764# Sound
765#
766# CONFIG_SOUND is not set
767CONFIG_USB_SUPPORT=y
768CONFIG_USB_ARCH_HAS_HCD=y
769CONFIG_USB_ARCH_HAS_OHCI=y
770CONFIG_USB_ARCH_HAS_EHCI=y
771CONFIG_USB=y
772# CONFIG_USB_DEBUG is not set
773# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
774
775#
776# Miscellaneous USB options
777#
778CONFIG_USB_DEVICEFS=y
779# CONFIG_USB_DEVICE_CLASS is not set
780# CONFIG_USB_DYNAMIC_MINORS is not set
781# CONFIG_USB_OTG is not set
782# CONFIG_USB_OTG_WHITELIST is not set
783# CONFIG_USB_OTG_BLACKLIST_HUB is not set
784
785#
786# USB Host Controller Drivers
787#
788# CONFIG_USB_EHCI_HCD is not set
789# CONFIG_USB_ISP116X_HCD is not set
790CONFIG_USB_OHCI_HCD=m
791# CONFIG_USB_OHCI_HCD_PPC_SOC is not set
792CONFIG_USB_OHCI_HCD_PPC_OF=y
793CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
794# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
795# CONFIG_USB_OHCI_HCD_PCI is not set
796CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
797CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
798# CONFIG_USB_OHCI_LITTLE_ENDIAN is not set
799# CONFIG_USB_UHCI_HCD is not set
800# CONFIG_USB_SL811_HCD is not set
801# CONFIG_USB_R8A66597_HCD is not set
802
803#
804# USB Device Class drivers
805#
806# CONFIG_USB_ACM is not set
807# CONFIG_USB_PRINTER is not set
808
809#
810# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
811#
812
813#
814# may also be needed; see USB_STORAGE Help for more information
815#
816CONFIG_USB_STORAGE=m
817# CONFIG_USB_STORAGE_DEBUG is not set
818# CONFIG_USB_STORAGE_DATAFAB is not set
819# CONFIG_USB_STORAGE_FREECOM is not set
820# CONFIG_USB_STORAGE_ISD200 is not set
821# CONFIG_USB_STORAGE_DPCM is not set
822# CONFIG_USB_STORAGE_USBAT is not set
823# CONFIG_USB_STORAGE_SDDR09 is not set
824# CONFIG_USB_STORAGE_SDDR55 is not set
825# CONFIG_USB_STORAGE_JUMPSHOT is not set
826# CONFIG_USB_STORAGE_ALAUDA is not set
827# CONFIG_USB_STORAGE_KARMA is not set
828# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
829# CONFIG_USB_LIBUSUAL is not set
830
831#
832# USB Imaging devices
833#
834# CONFIG_USB_MDC800 is not set
835# CONFIG_USB_MICROTEK is not set
836# CONFIG_USB_MON is not set
837
838#
839# USB port drivers
840#
841# CONFIG_USB_SERIAL is not set
842
843#
844# USB Miscellaneous drivers
845#
846# CONFIG_USB_EMI62 is not set
847# CONFIG_USB_EMI26 is not set
848# CONFIG_USB_ADUTUX is not set
849# CONFIG_USB_AUERSWALD is not set
850# CONFIG_USB_RIO500 is not set
851# CONFIG_USB_LEGOTOWER is not set
852# CONFIG_USB_LCD is not set
853# CONFIG_USB_BERRY_CHARGE is not set
854# CONFIG_USB_LED is not set
855# CONFIG_USB_CYPRESS_CY7C63 is not set
856# CONFIG_USB_CYTHERM is not set
857# CONFIG_USB_PHIDGET is not set
858# CONFIG_USB_IDMOUSE is not set
859# CONFIG_USB_FTDI_ELAN is not set
860# CONFIG_USB_APPLEDISPLAY is not set
861# CONFIG_USB_LD is not set
862# CONFIG_USB_TRANCEVIBRATOR is not set
863# CONFIG_USB_IOWARRIOR is not set
864# CONFIG_USB_TEST is not set
865# CONFIG_USB_GADGET is not set
866# CONFIG_MMC is not set
867# CONFIG_MEMSTICK is not set
868# CONFIG_NEW_LEDS is not set
869# CONFIG_INFINIBAND is not set
870# CONFIG_EDAC is not set
871CONFIG_RTC_LIB=m
872CONFIG_RTC_CLASS=m
873
874#
875# RTC interfaces
876#
877CONFIG_RTC_INTF_SYSFS=y
878CONFIG_RTC_INTF_PROC=y
879CONFIG_RTC_INTF_DEV=y
880# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
881# CONFIG_RTC_DRV_TEST is not set
882
883#
884# I2C RTC drivers
885#
886# CONFIG_RTC_DRV_DS1307 is not set
887# CONFIG_RTC_DRV_DS1374 is not set
888# CONFIG_RTC_DRV_DS1672 is not set
889# CONFIG_RTC_DRV_MAX6900 is not set
890# CONFIG_RTC_DRV_RS5C372 is not set
891# CONFIG_RTC_DRV_ISL1208 is not set
892# CONFIG_RTC_DRV_X1205 is not set
893CONFIG_RTC_DRV_PCF8563=m
894# CONFIG_RTC_DRV_PCF8583 is not set
895# CONFIG_RTC_DRV_M41T80 is not set
896# CONFIG_RTC_DRV_S35390A is not set
897
898#
899# SPI RTC drivers
900#
901
902#
903# Platform RTC drivers
904#
905# CONFIG_RTC_DRV_CMOS is not set
906# CONFIG_RTC_DRV_DS1511 is not set
907# CONFIG_RTC_DRV_DS1553 is not set
908# CONFIG_RTC_DRV_DS1742 is not set
909# CONFIG_RTC_DRV_STK17TA8 is not set
910# CONFIG_RTC_DRV_M48T86 is not set
911# CONFIG_RTC_DRV_M48T59 is not set
912# CONFIG_RTC_DRV_V3020 is not set
913
914#
915# on-CPU RTC drivers
916#
917# CONFIG_DMADEVICES is not set
918# CONFIG_UIO is not set
919
920#
921# File systems
922#
923CONFIG_EXT2_FS=m
924# CONFIG_EXT2_FS_XATTR is not set
925# CONFIG_EXT2_FS_XIP is not set
926CONFIG_EXT3_FS=m
927CONFIG_EXT3_FS_XATTR=y
928# CONFIG_EXT3_FS_POSIX_ACL is not set
929# CONFIG_EXT3_FS_SECURITY is not set
930# CONFIG_EXT4DEV_FS is not set
931CONFIG_JBD=m
932CONFIG_FS_MBCACHE=m
933# CONFIG_REISERFS_FS is not set
934# CONFIG_JFS_FS is not set
935# CONFIG_FS_POSIX_ACL is not set
936# CONFIG_XFS_FS is not set
937# CONFIG_OCFS2_FS is not set
938# CONFIG_DNOTIFY is not set
939# CONFIG_INOTIFY is not set
940# CONFIG_QUOTA is not set
941# CONFIG_AUTOFS_FS is not set
942# CONFIG_AUTOFS4_FS is not set
943# CONFIG_FUSE_FS is not set
944
945#
946# CD-ROM/DVD Filesystems
947#
948# CONFIG_ISO9660_FS is not set
949# CONFIG_UDF_FS is not set
950
951#
952# DOS/FAT/NT Filesystems
953#
954CONFIG_FAT_FS=m
955# CONFIG_MSDOS_FS is not set
956CONFIG_VFAT_FS=m
957CONFIG_FAT_DEFAULT_CODEPAGE=850
958CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
959# CONFIG_NTFS_FS is not set
960
961#
962# Pseudo filesystems
963#
964CONFIG_PROC_FS=y
965# CONFIG_PROC_KCORE is not set
966CONFIG_PROC_SYSCTL=y
967CONFIG_SYSFS=y
968CONFIG_TMPFS=y
969# CONFIG_TMPFS_POSIX_ACL is not set
970# CONFIG_HUGETLB_PAGE is not set
971# CONFIG_CONFIGFS_FS is not set
972
973#
974# Miscellaneous filesystems
975#
976# CONFIG_ADFS_FS is not set
977# CONFIG_AFFS_FS is not set
978# CONFIG_HFS_FS is not set
979# CONFIG_HFSPLUS_FS is not set
980# CONFIG_BEFS_FS is not set
981# CONFIG_BFS_FS is not set
982# CONFIG_EFS_FS is not set
983CONFIG_JFFS2_FS=y
984CONFIG_JFFS2_FS_DEBUG=0
985CONFIG_JFFS2_FS_WRITEBUFFER=y
986# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
987# CONFIG_JFFS2_SUMMARY is not set
988# CONFIG_JFFS2_FS_XATTR is not set
989# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
990CONFIG_JFFS2_ZLIB=y
991# CONFIG_JFFS2_LZO is not set
992CONFIG_JFFS2_RTIME=y
993# CONFIG_JFFS2_RUBIN is not set
994# CONFIG_CRAMFS is not set
995# CONFIG_VXFS_FS is not set
996# CONFIG_MINIX_FS is not set
997# CONFIG_HPFS_FS is not set
998# CONFIG_QNX4FS_FS is not set
999# CONFIG_ROMFS_FS is not set
1000# CONFIG_SYSV_FS is not set
1001# CONFIG_UFS_FS is not set
1002CONFIG_NETWORK_FILESYSTEMS=y
1003CONFIG_NFS_FS=y
1004CONFIG_NFS_V3=y
1005# CONFIG_NFS_V3_ACL is not set
1006# CONFIG_NFS_V4 is not set
1007# CONFIG_NFSD is not set
1008CONFIG_ROOT_NFS=y
1009CONFIG_LOCKD=y
1010CONFIG_LOCKD_V4=y
1011CONFIG_NFS_COMMON=y
1012CONFIG_SUNRPC=y
1013# CONFIG_SUNRPC_BIND34 is not set
1014# CONFIG_RPCSEC_GSS_KRB5 is not set
1015# CONFIG_RPCSEC_GSS_SPKM3 is not set
1016# CONFIG_SMB_FS is not set
1017# CONFIG_CIFS is not set
1018# CONFIG_NCP_FS is not set
1019# CONFIG_CODA_FS is not set
1020# CONFIG_AFS_FS is not set
1021
1022#
1023# Partition Types
1024#
1025# CONFIG_PARTITION_ADVANCED is not set
1026CONFIG_MSDOS_PARTITION=y
1027CONFIG_NLS=y
1028CONFIG_NLS_DEFAULT="iso8859-1"
1029# CONFIG_NLS_CODEPAGE_437 is not set
1030# CONFIG_NLS_CODEPAGE_737 is not set
1031# CONFIG_NLS_CODEPAGE_775 is not set
1032CONFIG_NLS_CODEPAGE_850=y
1033# CONFIG_NLS_CODEPAGE_852 is not set
1034# CONFIG_NLS_CODEPAGE_855 is not set
1035# CONFIG_NLS_CODEPAGE_857 is not set
1036# CONFIG_NLS_CODEPAGE_860 is not set
1037# CONFIG_NLS_CODEPAGE_861 is not set
1038# CONFIG_NLS_CODEPAGE_862 is not set
1039# CONFIG_NLS_CODEPAGE_863 is not set
1040# CONFIG_NLS_CODEPAGE_864 is not set
1041# CONFIG_NLS_CODEPAGE_865 is not set
1042# CONFIG_NLS_CODEPAGE_866 is not set
1043# CONFIG_NLS_CODEPAGE_869 is not set
1044# CONFIG_NLS_CODEPAGE_936 is not set
1045# CONFIG_NLS_CODEPAGE_950 is not set
1046# CONFIG_NLS_CODEPAGE_932 is not set
1047# CONFIG_NLS_CODEPAGE_949 is not set
1048# CONFIG_NLS_CODEPAGE_874 is not set
1049# CONFIG_NLS_ISO8859_8 is not set
1050# CONFIG_NLS_CODEPAGE_1250 is not set
1051# CONFIG_NLS_CODEPAGE_1251 is not set
1052# CONFIG_NLS_ASCII is not set
1053CONFIG_NLS_ISO8859_1=y
1054# CONFIG_NLS_ISO8859_2 is not set
1055# CONFIG_NLS_ISO8859_3 is not set
1056# CONFIG_NLS_ISO8859_4 is not set
1057# CONFIG_NLS_ISO8859_5 is not set
1058# CONFIG_NLS_ISO8859_6 is not set
1059# CONFIG_NLS_ISO8859_7 is not set
1060# CONFIG_NLS_ISO8859_9 is not set
1061# CONFIG_NLS_ISO8859_13 is not set
1062# CONFIG_NLS_ISO8859_14 is not set
1063# CONFIG_NLS_ISO8859_15 is not set
1064# CONFIG_NLS_KOI8_R is not set
1065# CONFIG_NLS_KOI8_U is not set
1066# CONFIG_NLS_UTF8 is not set
1067# CONFIG_DLM is not set
1068
1069#
1070# Library routines
1071#
1072CONFIG_BITREVERSE=y
1073# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1074# CONFIG_CRC_CCITT is not set
1075# CONFIG_CRC16 is not set
1076# CONFIG_CRC_ITU_T is not set
1077CONFIG_CRC32=y
1078# CONFIG_CRC7 is not set
1079# CONFIG_LIBCRC32C is not set
1080CONFIG_ZLIB_INFLATE=y
1081CONFIG_ZLIB_DEFLATE=y
1082CONFIG_PLIST=y
1083CONFIG_HAS_IOMEM=y
1084CONFIG_HAS_IOPORT=y
1085CONFIG_HAS_DMA=y
1086CONFIG_HAVE_LMB=y
1087
1088#
1089# Kernel hacking
1090#
1091# CONFIG_PRINTK_TIME is not set
1092CONFIG_ENABLE_WARN_DEPRECATED=y
1093CONFIG_ENABLE_MUST_CHECK=y
1094CONFIG_FRAME_WARN=1024
1095# CONFIG_MAGIC_SYSRQ is not set
1096# CONFIG_UNUSED_SYMBOLS is not set
1097# CONFIG_DEBUG_FS is not set
1098# CONFIG_HEADERS_CHECK is not set
1099# CONFIG_DEBUG_KERNEL is not set
1100# CONFIG_DEBUG_BUGVERBOSE is not set
1101# CONFIG_SAMPLES is not set
1102# CONFIG_IRQSTACKS is not set
1103# CONFIG_BOOTX_TEXT is not set
1104# CONFIG_PPC_EARLY_DEBUG is not set
1105
1106#
1107# Security options
1108#
1109# CONFIG_KEYS is not set
1110# CONFIG_SECURITY is not set
1111# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1112# CONFIG_CRYPTO is not set
1113CONFIG_PPC_CLOCK=y
1114CONFIG_PPC_LIB_RHEAP=y
1115# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/configs/52xx/tqm5200_defconfig b/arch/powerpc/configs/52xx/tqm5200_defconfig
new file mode 100644
index 000000000000..7672bfba3566
--- /dev/null
+++ b/arch/powerpc/configs/52xx/tqm5200_defconfig
@@ -0,0 +1,1214 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25
4# Tue Apr 29 07:12:39 2008
5#
6# CONFIG_PPC64 is not set
7
8#
9# Processor support
10#
11CONFIG_6xx=y
12# CONFIG_PPC_85xx is not set
13# CONFIG_PPC_8xx is not set
14# CONFIG_40x is not set
15# CONFIG_44x is not set
16# CONFIG_E200 is not set
17CONFIG_PPC_FPU=y
18# CONFIG_ALTIVEC is not set
19CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_32=y
21# CONFIG_PPC_MM_SLICES is not set
22# CONFIG_SMP is not set
23CONFIG_PPC32=y
24CONFIG_WORD_SIZE=32
25CONFIG_PPC_MERGE=y
26CONFIG_MMU=y
27CONFIG_GENERIC_CMOS_UPDATE=y
28CONFIG_GENERIC_TIME=y
29CONFIG_GENERIC_TIME_VSYSCALL=y
30CONFIG_GENERIC_CLOCKEVENTS=y
31CONFIG_GENERIC_HARDIRQS=y
32# CONFIG_HAVE_SETUP_PER_CPU_AREA is not set
33CONFIG_IRQ_PER_CPU=y
34CONFIG_STACKTRACE_SUPPORT=y
35CONFIG_LOCKDEP_SUPPORT=y
36CONFIG_RWSEM_XCHGADD_ALGORITHM=y
37CONFIG_ARCH_HAS_ILOG2_U32=y
38CONFIG_GENERIC_HWEIGHT=y
39CONFIG_GENERIC_CALIBRATE_DELAY=y
40CONFIG_GENERIC_FIND_NEXT_BIT=y
41# CONFIG_ARCH_NO_VIRT_TO_BUS is not set
42CONFIG_PPC=y
43CONFIG_EARLY_PRINTK=y
44CONFIG_GENERIC_NVRAM=y
45CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
46CONFIG_ARCH_MAY_HAVE_PC_FDC=y
47CONFIG_PPC_OF=y
48CONFIG_OF=y
49# CONFIG_PPC_UDBG_16550 is not set
50# CONFIG_GENERIC_TBSYNC is not set
51CONFIG_AUDIT_ARCH=y
52CONFIG_GENERIC_BUG=y
53CONFIG_DEFAULT_UIMAGE=y
54# CONFIG_PPC_DCR_NATIVE is not set
55# CONFIG_PPC_DCR_MMIO is not set
56CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
57
58#
59# General setup
60#
61CONFIG_EXPERIMENTAL=y
62CONFIG_BROKEN_ON_SMP=y
63CONFIG_INIT_ENV_ARG_LIMIT=32
64CONFIG_LOCALVERSION=""
65CONFIG_LOCALVERSION_AUTO=y
66CONFIG_SWAP=y
67CONFIG_SYSVIPC=y
68CONFIG_SYSVIPC_SYSCTL=y
69# CONFIG_POSIX_MQUEUE is not set
70# CONFIG_BSD_PROCESS_ACCT is not set
71# CONFIG_TASKSTATS is not set
72# CONFIG_AUDIT is not set
73# CONFIG_IKCONFIG is not set
74CONFIG_LOG_BUF_SHIFT=14
75# CONFIG_CGROUPS is not set
76CONFIG_GROUP_SCHED=y
77CONFIG_FAIR_GROUP_SCHED=y
78# CONFIG_RT_GROUP_SCHED is not set
79CONFIG_USER_SCHED=y
80# CONFIG_CGROUP_SCHED is not set
81CONFIG_SYSFS_DEPRECATED=y
82CONFIG_SYSFS_DEPRECATED_V2=y
83# CONFIG_RELAY is not set
84# CONFIG_NAMESPACES is not set
85CONFIG_BLK_DEV_INITRD=y
86CONFIG_INITRAMFS_SOURCE=""
87# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
88CONFIG_SYSCTL=y
89CONFIG_EMBEDDED=y
90# CONFIG_SYSCTL_SYSCALL is not set
91# CONFIG_KALLSYMS is not set
92CONFIG_HOTPLUG=y
93CONFIG_PRINTK=y
94CONFIG_BUG=y
95CONFIG_ELF_CORE=y
96CONFIG_COMPAT_BRK=y
97CONFIG_BASE_FULL=y
98CONFIG_FUTEX=y
99CONFIG_ANON_INODES=y
100# CONFIG_EPOLL is not set
101CONFIG_SIGNALFD=y
102CONFIG_TIMERFD=y
103CONFIG_EVENTFD=y
104CONFIG_SHMEM=y
105CONFIG_VM_EVENT_COUNTERS=y
106CONFIG_SLUB_DEBUG=y
107# CONFIG_SLAB is not set
108CONFIG_SLUB=y
109# CONFIG_SLOB is not set
110# CONFIG_PROFILING is not set
111# CONFIG_MARKERS is not set
112CONFIG_HAVE_OPROFILE=y
113CONFIG_HAVE_KPROBES=y
114CONFIG_HAVE_KRETPROBES=y
115CONFIG_PROC_PAGE_MONITOR=y
116CONFIG_SLABINFO=y
117CONFIG_RT_MUTEXES=y
118# CONFIG_TINY_SHMEM is not set
119CONFIG_BASE_SMALL=0
120CONFIG_MODULES=y
121CONFIG_MODULE_UNLOAD=y
122# CONFIG_MODULE_FORCE_UNLOAD is not set
123CONFIG_MODVERSIONS=y
124# CONFIG_MODULE_SRCVERSION_ALL is not set
125CONFIG_KMOD=y
126CONFIG_BLOCK=y
127# CONFIG_LBD is not set
128# CONFIG_BLK_DEV_IO_TRACE is not set
129# CONFIG_LSF is not set
130# CONFIG_BLK_DEV_BSG is not set
131
132#
133# IO Schedulers
134#
135CONFIG_IOSCHED_NOOP=y
136CONFIG_IOSCHED_AS=y
137CONFIG_IOSCHED_DEADLINE=y
138CONFIG_IOSCHED_CFQ=y
139CONFIG_DEFAULT_AS=y
140# CONFIG_DEFAULT_DEADLINE is not set
141# CONFIG_DEFAULT_CFQ is not set
142# CONFIG_DEFAULT_NOOP is not set
143CONFIG_DEFAULT_IOSCHED="anticipatory"
144CONFIG_CLASSIC_RCU=y
145
146#
147# Platform support
148#
149CONFIG_PPC_MULTIPLATFORM=y
150# CONFIG_PPC_82xx is not set
151# CONFIG_PPC_83xx is not set
152# CONFIG_PPC_86xx is not set
153CONFIG_CLASSIC32=y
154# CONFIG_PPC_CHRP is not set
155# CONFIG_PPC_MPC512x is not set
156# CONFIG_PPC_MPC5121 is not set
157# CONFIG_MPC5121_ADS is not set
158CONFIG_PPC_MPC52xx=y
159CONFIG_PPC_MPC5200_SIMPLE=y
160# CONFIG_PPC_EFIKA is not set
161# CONFIG_PPC_LITE5200 is not set
162CONFIG_PPC_MPC5200_BUGFIX=y
163# CONFIG_PPC_MPC5200_GPIO is not set
164# CONFIG_PPC_PMAC is not set
165# CONFIG_PPC_CELL is not set
166# CONFIG_PPC_CELL_NATIVE is not set
167# CONFIG_PQ2ADS is not set
168# CONFIG_EMBEDDED6xx is not set
169# CONFIG_IPIC is not set
170# CONFIG_MPIC is not set
171# CONFIG_MPIC_WEIRD is not set
172# CONFIG_PPC_I8259 is not set
173# CONFIG_PPC_RTAS is not set
174# CONFIG_MMIO_NVRAM is not set
175# CONFIG_PPC_MPC106 is not set
176# CONFIG_PPC_970_NAP is not set
177# CONFIG_PPC_INDIRECT_IO is not set
178# CONFIG_GENERIC_IOMAP is not set
179# CONFIG_CPU_FREQ is not set
180# CONFIG_TAU is not set
181# CONFIG_FSL_ULI1575 is not set
182CONFIG_PPC_BESTCOMM=y
183# CONFIG_PPC_BESTCOMM_ATA is not set
184CONFIG_PPC_BESTCOMM_FEC=y
185# CONFIG_PPC_BESTCOMM_GEN_BD is not set
186
187#
188# Kernel options
189#
190# CONFIG_HIGHMEM is not set
191# CONFIG_TICK_ONESHOT is not set
192# CONFIG_NO_HZ is not set
193# CONFIG_HIGH_RES_TIMERS is not set
194CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
195# CONFIG_HZ_100 is not set
196CONFIG_HZ_250=y
197# CONFIG_HZ_300 is not set
198# CONFIG_HZ_1000 is not set
199CONFIG_HZ=250
200# CONFIG_SCHED_HRTICK is not set
201CONFIG_PREEMPT_NONE=y
202# CONFIG_PREEMPT_VOLUNTARY is not set
203# CONFIG_PREEMPT is not set
204CONFIG_BINFMT_ELF=y
205# CONFIG_BINFMT_MISC is not set
206# CONFIG_IOMMU_HELPER is not set
207CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
208CONFIG_ARCH_HAS_WALK_MEMORY=y
209CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
210# CONFIG_KEXEC is not set
211CONFIG_ARCH_FLATMEM_ENABLE=y
212CONFIG_ARCH_POPULATES_NODE_MAP=y
213CONFIG_SELECT_MEMORY_MODEL=y
214CONFIG_FLATMEM_MANUAL=y
215# CONFIG_DISCONTIGMEM_MANUAL is not set
216# CONFIG_SPARSEMEM_MANUAL is not set
217CONFIG_FLATMEM=y
218CONFIG_FLAT_NODE_MEM_MAP=y
219# CONFIG_SPARSEMEM_STATIC is not set
220# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
221CONFIG_PAGEFLAGS_EXTENDED=y
222CONFIG_SPLIT_PTLOCK_CPUS=4
223# CONFIG_RESOURCES_64BIT is not set
224CONFIG_ZONE_DMA_FLAG=1
225CONFIG_BOUNCE=y
226CONFIG_VIRT_TO_BUS=y
227CONFIG_FORCE_MAX_ZONEORDER=11
228CONFIG_PROC_DEVICETREE=y
229# CONFIG_CMDLINE_BOOL is not set
230CONFIG_PM=y
231# CONFIG_PM_LEGACY is not set
232# CONFIG_PM_DEBUG is not set
233CONFIG_SECCOMP=y
234CONFIG_ISA_DMA_API=y
235
236#
237# Bus options
238#
239CONFIG_ZONE_DMA=y
240CONFIG_GENERIC_ISA_DMA=y
241CONFIG_FSL_SOC=y
242# CONFIG_PCI is not set
243# CONFIG_PCI_DOMAINS is not set
244# CONFIG_PCI_SYSCALL is not set
245# CONFIG_ARCH_SUPPORTS_MSI is not set
246# CONFIG_PCCARD is not set
247# CONFIG_HAS_RAPIDIO is not set
248
249#
250# Advanced setup
251#
252# CONFIG_ADVANCED_OPTIONS is not set
253
254#
255# Default settings for advanced configuration options are used
256#
257CONFIG_LOWMEM_SIZE=0x30000000
258CONFIG_PAGE_OFFSET=0xc0000000
259CONFIG_KERNEL_START=0xc0000000
260CONFIG_PHYSICAL_START=0x00000000
261CONFIG_TASK_SIZE=0xc0000000
262
263#
264# Networking
265#
266CONFIG_NET=y
267
268#
269# Networking options
270#
271CONFIG_PACKET=y
272# CONFIG_PACKET_MMAP is not set
273CONFIG_UNIX=y
274CONFIG_XFRM=y
275CONFIG_XFRM_USER=y
276# CONFIG_XFRM_SUB_POLICY is not set
277# CONFIG_XFRM_MIGRATE is not set
278# CONFIG_XFRM_STATISTICS is not set
279# CONFIG_NET_KEY is not set
280CONFIG_INET=y
281CONFIG_IP_MULTICAST=y
282# CONFIG_IP_ADVANCED_ROUTER is not set
283CONFIG_IP_FIB_HASH=y
284CONFIG_IP_PNP=y
285CONFIG_IP_PNP_DHCP=y
286CONFIG_IP_PNP_BOOTP=y
287# CONFIG_IP_PNP_RARP is not set
288# CONFIG_NET_IPIP is not set
289# CONFIG_NET_IPGRE is not set
290# CONFIG_IP_MROUTE is not set
291# CONFIG_ARPD is not set
292CONFIG_SYN_COOKIES=y
293# CONFIG_INET_AH is not set
294# CONFIG_INET_ESP is not set
295# CONFIG_INET_IPCOMP is not set
296# CONFIG_INET_XFRM_TUNNEL is not set
297# CONFIG_INET_TUNNEL is not set
298CONFIG_INET_XFRM_MODE_TRANSPORT=y
299CONFIG_INET_XFRM_MODE_TUNNEL=y
300CONFIG_INET_XFRM_MODE_BEET=y
301# CONFIG_INET_LRO is not set
302CONFIG_INET_DIAG=y
303CONFIG_INET_TCP_DIAG=y
304# CONFIG_TCP_CONG_ADVANCED is not set
305CONFIG_TCP_CONG_CUBIC=y
306CONFIG_DEFAULT_TCP_CONG="cubic"
307# CONFIG_TCP_MD5SIG is not set
308# CONFIG_IPV6 is not set
309# CONFIG_NETWORK_SECMARK is not set
310# CONFIG_NETFILTER is not set
311# CONFIG_IP_DCCP is not set
312# CONFIG_IP_SCTP is not set
313# CONFIG_TIPC is not set
314# CONFIG_ATM is not set
315# CONFIG_BRIDGE is not set
316# CONFIG_VLAN_8021Q is not set
317# CONFIG_DECNET is not set
318# CONFIG_LLC2 is not set
319# CONFIG_IPX is not set
320# CONFIG_ATALK is not set
321# CONFIG_X25 is not set
322# CONFIG_LAPB is not set
323# CONFIG_ECONET is not set
324# CONFIG_WAN_ROUTER is not set
325# CONFIG_NET_SCHED is not set
326
327#
328# Network testing
329#
330# CONFIG_NET_PKTGEN is not set
331# CONFIG_HAMRADIO is not set
332# CONFIG_CAN is not set
333# CONFIG_IRDA is not set
334# CONFIG_BT is not set
335# CONFIG_AF_RXRPC is not set
336
337#
338# Wireless
339#
340# CONFIG_CFG80211 is not set
341# CONFIG_WIRELESS_EXT is not set
342# CONFIG_MAC80211 is not set
343# CONFIG_IEEE80211 is not set
344# CONFIG_RFKILL is not set
345# CONFIG_NET_9P is not set
346
347#
348# Device Drivers
349#
350
351#
352# Generic Driver Options
353#
354CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
355CONFIG_STANDALONE=y
356CONFIG_PREVENT_FIRMWARE_BUILD=y
357# CONFIG_FW_LOADER is not set
358# CONFIG_DEBUG_DRIVER is not set
359# CONFIG_DEBUG_DEVRES is not set
360# CONFIG_SYS_HYPERVISOR is not set
361# CONFIG_CONNECTOR is not set
362CONFIG_MTD=y
363# CONFIG_MTD_DEBUG is not set
364CONFIG_MTD_CONCAT=y
365CONFIG_MTD_PARTITIONS=y
366# CONFIG_MTD_REDBOOT_PARTS is not set
367CONFIG_MTD_CMDLINE_PARTS=y
368# CONFIG_MTD_OF_PARTS is not set
369# CONFIG_MTD_AR7_PARTS is not set
370
371#
372# User Modules And Translation Layers
373#
374CONFIG_MTD_CHAR=y
375CONFIG_MTD_BLKDEVS=y
376CONFIG_MTD_BLOCK=y
377# CONFIG_FTL is not set
378# CONFIG_NFTL is not set
379# CONFIG_INFTL is not set
380# CONFIG_RFD_FTL is not set
381# CONFIG_SSFDC is not set
382# CONFIG_MTD_OOPS is not set
383
384#
385# RAM/ROM/Flash chip drivers
386#
387CONFIG_MTD_CFI=y
388# CONFIG_MTD_JEDECPROBE is not set
389CONFIG_MTD_GEN_PROBE=y
390# CONFIG_MTD_CFI_ADV_OPTIONS is not set
391CONFIG_MTD_MAP_BANK_WIDTH_1=y
392CONFIG_MTD_MAP_BANK_WIDTH_2=y
393CONFIG_MTD_MAP_BANK_WIDTH_4=y
394# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
395# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
396# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
397CONFIG_MTD_CFI_I1=y
398CONFIG_MTD_CFI_I2=y
399# CONFIG_MTD_CFI_I4 is not set
400# CONFIG_MTD_CFI_I8 is not set
401# CONFIG_MTD_CFI_INTELEXT is not set
402CONFIG_MTD_CFI_AMDSTD=y
403# CONFIG_MTD_CFI_STAA is not set
404CONFIG_MTD_CFI_UTIL=y
405# CONFIG_MTD_RAM is not set
406CONFIG_MTD_ROM=y
407# CONFIG_MTD_ABSENT is not set
408
409#
410# Mapping drivers for chip access
411#
412# CONFIG_MTD_COMPLEX_MAPPINGS is not set
413# CONFIG_MTD_PHYSMAP is not set
414CONFIG_MTD_PHYSMAP_OF=y
415# CONFIG_MTD_PLATRAM is not set
416
417#
418# Self-contained MTD device drivers
419#
420# CONFIG_MTD_SLRAM is not set
421# CONFIG_MTD_PHRAM is not set
422# CONFIG_MTD_MTDRAM is not set
423# CONFIG_MTD_BLOCK2MTD is not set
424
425#
426# Disk-On-Chip Device Drivers
427#
428# CONFIG_MTD_DOC2000 is not set
429# CONFIG_MTD_DOC2001 is not set
430# CONFIG_MTD_DOC2001PLUS is not set
431# CONFIG_MTD_NAND is not set
432# CONFIG_MTD_ONENAND is not set
433
434#
435# UBI - Unsorted block images
436#
437# CONFIG_MTD_UBI is not set
438CONFIG_OF_DEVICE=y
439CONFIG_OF_I2C=y
440# CONFIG_PARPORT is not set
441CONFIG_BLK_DEV=y
442# CONFIG_BLK_DEV_FD is not set
443# CONFIG_BLK_DEV_COW_COMMON is not set
444CONFIG_BLK_DEV_LOOP=y
445# CONFIG_BLK_DEV_CRYPTOLOOP is not set
446# CONFIG_BLK_DEV_NBD is not set
447# CONFIG_BLK_DEV_UB is not set
448CONFIG_BLK_DEV_RAM=y
449CONFIG_BLK_DEV_RAM_COUNT=16
450CONFIG_BLK_DEV_RAM_SIZE=32768
451# CONFIG_BLK_DEV_XIP is not set
452# CONFIG_CDROM_PKTCDVD is not set
453# CONFIG_ATA_OVER_ETH is not set
454# CONFIG_MISC_DEVICES is not set
455CONFIG_HAVE_IDE=y
456# CONFIG_IDE is not set
457
458#
459# SCSI device support
460#
461# CONFIG_RAID_ATTRS is not set
462CONFIG_SCSI=y
463CONFIG_SCSI_DMA=y
464# CONFIG_SCSI_TGT is not set
465# CONFIG_SCSI_NETLINK is not set
466CONFIG_SCSI_PROC_FS=y
467
468#
469# SCSI support type (disk, tape, CD-ROM)
470#
471CONFIG_BLK_DEV_SD=y
472# CONFIG_CHR_DEV_ST is not set
473# CONFIG_CHR_DEV_OSST is not set
474# CONFIG_BLK_DEV_SR is not set
475CONFIG_CHR_DEV_SG=y
476# CONFIG_CHR_DEV_SCH is not set
477
478#
479# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
480#
481# CONFIG_SCSI_MULTI_LUN is not set
482# CONFIG_SCSI_CONSTANTS is not set
483# CONFIG_SCSI_LOGGING is not set
484# CONFIG_SCSI_SCAN_ASYNC is not set
485CONFIG_SCSI_WAIT_SCAN=m
486
487#
488# SCSI Transports
489#
490# CONFIG_SCSI_SPI_ATTRS is not set
491# CONFIG_SCSI_FC_ATTRS is not set
492# CONFIG_SCSI_ISCSI_ATTRS is not set
493# CONFIG_SCSI_SAS_LIBSAS is not set
494# CONFIG_SCSI_SRP_ATTRS is not set
495CONFIG_SCSI_LOWLEVEL=y
496# CONFIG_ISCSI_TCP is not set
497# CONFIG_SCSI_DEBUG is not set
498CONFIG_ATA=y
499# CONFIG_ATA_NONSTANDARD is not set
500CONFIG_SATA_PMP=y
501# CONFIG_SATA_FSL is not set
502CONFIG_ATA_SFF=y
503# CONFIG_SATA_MV is not set
504CONFIG_PATA_MPC52xx=y
505CONFIG_PATA_PLATFORM=y
506# CONFIG_PATA_OF_PLATFORM is not set
507# CONFIG_MD is not set
508# CONFIG_MACINTOSH_DRIVERS is not set
509CONFIG_NETDEVICES=y
510# CONFIG_NETDEVICES_MULTIQUEUE is not set
511# CONFIG_DUMMY is not set
512# CONFIG_BONDING is not set
513# CONFIG_MACVLAN is not set
514# CONFIG_EQUALIZER is not set
515# CONFIG_TUN is not set
516# CONFIG_VETH is not set
517CONFIG_PHYLIB=y
518
519#
520# MII PHY device drivers
521#
522# CONFIG_MARVELL_PHY is not set
523# CONFIG_DAVICOM_PHY is not set
524# CONFIG_QSEMI_PHY is not set
525CONFIG_LXT_PHY=y
526# CONFIG_CICADA_PHY is not set
527# CONFIG_VITESSE_PHY is not set
528# CONFIG_SMSC_PHY is not set
529# CONFIG_BROADCOM_PHY is not set
530# CONFIG_ICPLUS_PHY is not set
531# CONFIG_REALTEK_PHY is not set
532# CONFIG_FIXED_PHY is not set
533# CONFIG_MDIO_BITBANG is not set
534CONFIG_NET_ETHERNET=y
535# CONFIG_MII is not set
536# CONFIG_IBM_NEW_EMAC_ZMII is not set
537# CONFIG_IBM_NEW_EMAC_RGMII is not set
538# CONFIG_IBM_NEW_EMAC_TAH is not set
539# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
540# CONFIG_B44 is not set
541CONFIG_FEC_MPC52xx=y
542CONFIG_FEC_MPC52xx_MDIO=y
543# CONFIG_NETDEV_1000 is not set
544# CONFIG_NETDEV_10000 is not set
545
546#
547# Wireless LAN
548#
549# CONFIG_WLAN_PRE80211 is not set
550# CONFIG_WLAN_80211 is not set
551# CONFIG_IWLWIFI is not set
552# CONFIG_IWLWIFI_LEDS is not set
553
554#
555# USB Network Adapters
556#
557# CONFIG_USB_CATC is not set
558# CONFIG_USB_KAWETH is not set
559# CONFIG_USB_PEGASUS is not set
560# CONFIG_USB_RTL8150 is not set
561# CONFIG_USB_USBNET is not set
562# CONFIG_WAN is not set
563# CONFIG_PPP is not set
564# CONFIG_SLIP is not set
565# CONFIG_NETCONSOLE is not set
566# CONFIG_NETPOLL is not set
567# CONFIG_NET_POLL_CONTROLLER is not set
568# CONFIG_ISDN is not set
569# CONFIG_PHONE is not set
570
571#
572# Input device support
573#
574# CONFIG_INPUT is not set
575
576#
577# Hardware I/O ports
578#
579# CONFIG_SERIO is not set
580# CONFIG_GAMEPORT is not set
581
582#
583# Character devices
584#
585# CONFIG_VT is not set
586# CONFIG_SERIAL_NONSTANDARD is not set
587
588#
589# Serial drivers
590#
591# CONFIG_SERIAL_8250 is not set
592
593#
594# Non-8250 serial port support
595#
596# CONFIG_SERIAL_UARTLITE is not set
597CONFIG_SERIAL_CORE=y
598CONFIG_SERIAL_CORE_CONSOLE=y
599CONFIG_SERIAL_MPC52xx=y
600CONFIG_SERIAL_MPC52xx_CONSOLE=y
601CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD=115200
602CONFIG_UNIX98_PTYS=y
603CONFIG_LEGACY_PTYS=y
604CONFIG_LEGACY_PTY_COUNT=256
605# CONFIG_IPMI_HANDLER is not set
606# CONFIG_HW_RANDOM is not set
607# CONFIG_NVRAM is not set
608# CONFIG_R3964 is not set
609# CONFIG_RAW_DRIVER is not set
610# CONFIG_TCG_TPM is not set
611CONFIG_I2C=y
612CONFIG_I2C_BOARDINFO=y
613CONFIG_I2C_CHARDEV=y
614
615#
616# I2C Hardware Bus support
617#
618CONFIG_I2C_MPC=y
619# CONFIG_I2C_OCORES is not set
620# CONFIG_I2C_PARPORT_LIGHT is not set
621# CONFIG_I2C_SIMTEC is not set
622# CONFIG_I2C_TAOS_EVM is not set
623# CONFIG_I2C_STUB is not set
624# CONFIG_I2C_TINY_USB is not set
625# CONFIG_I2C_PCA_PLATFORM is not set
626
627#
628# Miscellaneous I2C Chip support
629#
630# CONFIG_DS1682 is not set
631# CONFIG_SENSORS_EEPROM is not set
632# CONFIG_SENSORS_PCF8574 is not set
633# CONFIG_PCF8575 is not set
634# CONFIG_SENSORS_PCF8591 is not set
635# CONFIG_SENSORS_MAX6875 is not set
636# CONFIG_SENSORS_TSL2550 is not set
637# CONFIG_I2C_DEBUG_CORE is not set
638# CONFIG_I2C_DEBUG_ALGO is not set
639# CONFIG_I2C_DEBUG_BUS is not set
640# CONFIG_I2C_DEBUG_CHIP is not set
641# CONFIG_SPI is not set
642# CONFIG_W1 is not set
643# CONFIG_POWER_SUPPLY is not set
644CONFIG_HWMON=y
645# CONFIG_HWMON_VID is not set
646# CONFIG_SENSORS_AD7418 is not set
647# CONFIG_SENSORS_ADM1021 is not set
648# CONFIG_SENSORS_ADM1025 is not set
649# CONFIG_SENSORS_ADM1026 is not set
650# CONFIG_SENSORS_ADM1029 is not set
651# CONFIG_SENSORS_ADM1031 is not set
652# CONFIG_SENSORS_ADM9240 is not set
653# CONFIG_SENSORS_ADT7470 is not set
654# CONFIG_SENSORS_ADT7473 is not set
655# CONFIG_SENSORS_ATXP1 is not set
656# CONFIG_SENSORS_DS1621 is not set
657# CONFIG_SENSORS_F71805F is not set
658# CONFIG_SENSORS_F71882FG is not set
659# CONFIG_SENSORS_F75375S is not set
660# CONFIG_SENSORS_GL518SM is not set
661# CONFIG_SENSORS_GL520SM is not set
662# CONFIG_SENSORS_IT87 is not set
663# CONFIG_SENSORS_LM63 is not set
664# CONFIG_SENSORS_LM75 is not set
665# CONFIG_SENSORS_LM77 is not set
666# CONFIG_SENSORS_LM78 is not set
667# CONFIG_SENSORS_LM80 is not set
668# CONFIG_SENSORS_LM83 is not set
669# CONFIG_SENSORS_LM85 is not set
670# CONFIG_SENSORS_LM87 is not set
671# CONFIG_SENSORS_LM90 is not set
672# CONFIG_SENSORS_LM92 is not set
673# CONFIG_SENSORS_LM93 is not set
674# CONFIG_SENSORS_MAX1619 is not set
675# CONFIG_SENSORS_MAX6650 is not set
676# CONFIG_SENSORS_PC87360 is not set
677# CONFIG_SENSORS_PC87427 is not set
678# CONFIG_SENSORS_DME1737 is not set
679# CONFIG_SENSORS_SMSC47M1 is not set
680# CONFIG_SENSORS_SMSC47M192 is not set
681# CONFIG_SENSORS_SMSC47B397 is not set
682# CONFIG_SENSORS_ADS7828 is not set
683# CONFIG_SENSORS_THMC50 is not set
684# CONFIG_SENSORS_VT1211 is not set
685# CONFIG_SENSORS_W83781D is not set
686# CONFIG_SENSORS_W83791D is not set
687# CONFIG_SENSORS_W83792D is not set
688# CONFIG_SENSORS_W83793 is not set
689# CONFIG_SENSORS_W83L785TS is not set
690# CONFIG_SENSORS_W83L786NG is not set
691# CONFIG_SENSORS_W83627HF is not set
692# CONFIG_SENSORS_W83627EHF is not set
693# CONFIG_HWMON_DEBUG_CHIP is not set
694# CONFIG_THERMAL is not set
695CONFIG_WATCHDOG=y
696# CONFIG_WATCHDOG_NOWAYOUT is not set
697
698#
699# Watchdog Device Drivers
700#
701# CONFIG_SOFT_WATCHDOG is not set
702# CONFIG_MPC5200_WDT is not set
703
704#
705# USB-based Watchdog Cards
706#
707# CONFIG_USBPCWATCHDOG is not set
708
709#
710# Sonics Silicon Backplane
711#
712CONFIG_SSB_POSSIBLE=y
713# CONFIG_SSB is not set
714
715#
716# Multifunction device drivers
717#
718# CONFIG_MFD_SM501 is not set
719# CONFIG_HTC_PASIC3 is not set
720
721#
722# Multimedia devices
723#
724# CONFIG_VIDEO_DEV is not set
725# CONFIG_DVB_CORE is not set
726# CONFIG_DAB is not set
727
728#
729# Graphics support
730#
731# CONFIG_VGASTATE is not set
732# CONFIG_VIDEO_OUTPUT_CONTROL is not set
733# CONFIG_FB is not set
734# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
735
736#
737# Display device support
738#
739# CONFIG_DISPLAY_SUPPORT is not set
740
741#
742# Sound
743#
744# CONFIG_SOUND is not set
745CONFIG_USB_SUPPORT=y
746CONFIG_USB_ARCH_HAS_HCD=y
747CONFIG_USB_ARCH_HAS_OHCI=y
748# CONFIG_USB_ARCH_HAS_EHCI is not set
749CONFIG_USB=y
750# CONFIG_USB_DEBUG is not set
751# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set
752
753#
754# Miscellaneous USB options
755#
756CONFIG_USB_DEVICEFS=y
757# CONFIG_USB_DEVICE_CLASS is not set
758# CONFIG_USB_DYNAMIC_MINORS is not set
759# CONFIG_USB_SUSPEND is not set
760# CONFIG_USB_OTG is not set
761# CONFIG_USB_OTG_WHITELIST is not set
762# CONFIG_USB_OTG_BLACKLIST_HUB is not set
763
764#
765# USB Host Controller Drivers
766#
767# CONFIG_USB_ISP116X_HCD is not set
768CONFIG_USB_OHCI_HCD=y
769CONFIG_USB_OHCI_HCD_PPC_SOC=y
770CONFIG_USB_OHCI_HCD_PPC_OF=y
771CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
772# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
773CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
774CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
775# CONFIG_USB_OHCI_LITTLE_ENDIAN is not set
776# CONFIG_USB_SL811_HCD is not set
777# CONFIG_USB_R8A66597_HCD is not set
778
779#
780# USB Device Class drivers
781#
782# CONFIG_USB_ACM is not set
783# CONFIG_USB_PRINTER is not set
784
785#
786# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
787#
788
789#
790# may also be needed; see USB_STORAGE Help for more information
791#
792CONFIG_USB_STORAGE=y
793# CONFIG_USB_STORAGE_DEBUG is not set
794# CONFIG_USB_STORAGE_DATAFAB is not set
795# CONFIG_USB_STORAGE_FREECOM is not set
796# CONFIG_USB_STORAGE_ISD200 is not set
797# CONFIG_USB_STORAGE_DPCM is not set
798# CONFIG_USB_STORAGE_USBAT is not set
799# CONFIG_USB_STORAGE_SDDR09 is not set
800# CONFIG_USB_STORAGE_SDDR55 is not set
801# CONFIG_USB_STORAGE_JUMPSHOT is not set
802# CONFIG_USB_STORAGE_ALAUDA is not set
803# CONFIG_USB_STORAGE_KARMA is not set
804# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set
805# CONFIG_USB_LIBUSUAL is not set
806
807#
808# USB Imaging devices
809#
810# CONFIG_USB_MDC800 is not set
811# CONFIG_USB_MICROTEK is not set
812CONFIG_USB_MON=y
813
814#
815# USB port drivers
816#
817# CONFIG_USB_SERIAL is not set
818
819#
820# USB Miscellaneous drivers
821#
822# CONFIG_USB_EMI62 is not set
823# CONFIG_USB_EMI26 is not set
824# CONFIG_USB_ADUTUX is not set
825# CONFIG_USB_AUERSWALD is not set
826# CONFIG_USB_RIO500 is not set
827# CONFIG_USB_LEGOTOWER is not set
828# CONFIG_USB_LCD is not set
829# CONFIG_USB_BERRY_CHARGE is not set
830# CONFIG_USB_LED is not set
831# CONFIG_USB_CYPRESS_CY7C63 is not set
832# CONFIG_USB_CYTHERM is not set
833# CONFIG_USB_PHIDGET is not set
834# CONFIG_USB_IDMOUSE is not set
835# CONFIG_USB_FTDI_ELAN is not set
836# CONFIG_USB_APPLEDISPLAY is not set
837# CONFIG_USB_LD is not set
838# CONFIG_USB_TRANCEVIBRATOR is not set
839# CONFIG_USB_IOWARRIOR is not set
840# CONFIG_USB_TEST is not set
841# CONFIG_USB_GADGET is not set
842# CONFIG_MMC is not set
843# CONFIG_MEMSTICK is not set
844# CONFIG_NEW_LEDS is not set
845# CONFIG_EDAC is not set
846CONFIG_RTC_LIB=y
847CONFIG_RTC_CLASS=y
848CONFIG_RTC_HCTOSYS=y
849CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
850# CONFIG_RTC_DEBUG is not set
851
852#
853# RTC interfaces
854#
855CONFIG_RTC_INTF_SYSFS=y
856CONFIG_RTC_INTF_PROC=y
857CONFIG_RTC_INTF_DEV=y
858# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
859# CONFIG_RTC_DRV_TEST is not set
860
861#
862# I2C RTC drivers
863#
864CONFIG_RTC_DRV_DS1307=y
865# CONFIG_RTC_DRV_DS1374 is not set
866# CONFIG_RTC_DRV_DS1672 is not set
867# CONFIG_RTC_DRV_MAX6900 is not set
868# CONFIG_RTC_DRV_RS5C372 is not set
869# CONFIG_RTC_DRV_ISL1208 is not set
870# CONFIG_RTC_DRV_X1205 is not set
871# CONFIG_RTC_DRV_PCF8563 is not set
872# CONFIG_RTC_DRV_PCF8583 is not set
873# CONFIG_RTC_DRV_M41T80 is not set
874# CONFIG_RTC_DRV_S35390A is not set
875
876#
877# SPI RTC drivers
878#
879
880#
881# Platform RTC drivers
882#
883# CONFIG_RTC_DRV_CMOS is not set
884# CONFIG_RTC_DRV_DS1511 is not set
885# CONFIG_RTC_DRV_DS1553 is not set
886# CONFIG_RTC_DRV_DS1742 is not set
887# CONFIG_RTC_DRV_STK17TA8 is not set
888# CONFIG_RTC_DRV_M48T86 is not set
889# CONFIG_RTC_DRV_M48T59 is not set
890# CONFIG_RTC_DRV_V3020 is not set
891
892#
893# on-CPU RTC drivers
894#
895# CONFIG_DMADEVICES is not set
896# CONFIG_UIO is not set
897
898#
899# File systems
900#
901CONFIG_EXT2_FS=y
902# CONFIG_EXT2_FS_XATTR is not set
903# CONFIG_EXT2_FS_XIP is not set
904CONFIG_EXT3_FS=y
905CONFIG_EXT3_FS_XATTR=y
906# CONFIG_EXT3_FS_POSIX_ACL is not set
907# CONFIG_EXT3_FS_SECURITY is not set
908# CONFIG_EXT4DEV_FS is not set
909CONFIG_JBD=y
910CONFIG_FS_MBCACHE=y
911# CONFIG_REISERFS_FS is not set
912# CONFIG_JFS_FS is not set
913# CONFIG_FS_POSIX_ACL is not set
914# CONFIG_XFS_FS is not set
915# CONFIG_OCFS2_FS is not set
916CONFIG_DNOTIFY=y
917CONFIG_INOTIFY=y
918CONFIG_INOTIFY_USER=y
919# CONFIG_QUOTA is not set
920# CONFIG_AUTOFS_FS is not set
921# CONFIG_AUTOFS4_FS is not set
922# CONFIG_FUSE_FS is not set
923
924#
925# CD-ROM/DVD Filesystems
926#
927# CONFIG_ISO9660_FS is not set
928# CONFIG_UDF_FS is not set
929
930#
931# DOS/FAT/NT Filesystems
932#
933CONFIG_FAT_FS=y
934CONFIG_MSDOS_FS=y
935CONFIG_VFAT_FS=y
936CONFIG_FAT_DEFAULT_CODEPAGE=437
937CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
938# CONFIG_NTFS_FS is not set
939
940#
941# Pseudo filesystems
942#
943CONFIG_PROC_FS=y
944CONFIG_PROC_KCORE=y
945CONFIG_PROC_SYSCTL=y
946CONFIG_SYSFS=y
947CONFIG_TMPFS=y
948# CONFIG_TMPFS_POSIX_ACL is not set
949# CONFIG_HUGETLB_PAGE is not set
950# CONFIG_CONFIGFS_FS is not set
951
952#
953# Miscellaneous filesystems
954#
955# CONFIG_ADFS_FS is not set
956# CONFIG_AFFS_FS is not set
957# CONFIG_HFS_FS is not set
958# CONFIG_HFSPLUS_FS is not set
959# CONFIG_BEFS_FS is not set
960# CONFIG_BFS_FS is not set
961# CONFIG_EFS_FS is not set
962CONFIG_JFFS2_FS=y
963CONFIG_JFFS2_FS_DEBUG=0
964CONFIG_JFFS2_FS_WRITEBUFFER=y
965# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
966# CONFIG_JFFS2_SUMMARY is not set
967# CONFIG_JFFS2_FS_XATTR is not set
968# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
969CONFIG_JFFS2_ZLIB=y
970# CONFIG_JFFS2_LZO is not set
971CONFIG_JFFS2_RTIME=y
972# CONFIG_JFFS2_RUBIN is not set
973CONFIG_CRAMFS=y
974# CONFIG_VXFS_FS is not set
975# CONFIG_MINIX_FS is not set
976# CONFIG_HPFS_FS is not set
977# CONFIG_QNX4FS_FS is not set
978# CONFIG_ROMFS_FS is not set
979# CONFIG_SYSV_FS is not set
980# CONFIG_UFS_FS is not set
981CONFIG_NETWORK_FILESYSTEMS=y
982CONFIG_NFS_FS=y
983CONFIG_NFS_V3=y
984# CONFIG_NFS_V3_ACL is not set
985CONFIG_NFS_V4=y
986# CONFIG_NFSD is not set
987CONFIG_ROOT_NFS=y
988CONFIG_LOCKD=y
989CONFIG_LOCKD_V4=y
990CONFIG_NFS_COMMON=y
991CONFIG_SUNRPC=y
992CONFIG_SUNRPC_GSS=y
993# CONFIG_SUNRPC_BIND34 is not set
994CONFIG_RPCSEC_GSS_KRB5=y
995# CONFIG_RPCSEC_GSS_SPKM3 is not set
996# CONFIG_SMB_FS is not set
997# CONFIG_CIFS is not set
998# CONFIG_NCP_FS is not set
999# CONFIG_CODA_FS is not set
1000# CONFIG_AFS_FS is not set
1001
1002#
1003# Partition Types
1004#
1005CONFIG_PARTITION_ADVANCED=y
1006# CONFIG_ACORN_PARTITION is not set
1007# CONFIG_OSF_PARTITION is not set
1008# CONFIG_AMIGA_PARTITION is not set
1009# CONFIG_ATARI_PARTITION is not set
1010# CONFIG_MAC_PARTITION is not set
1011CONFIG_MSDOS_PARTITION=y
1012# CONFIG_BSD_DISKLABEL is not set
1013# CONFIG_MINIX_SUBPARTITION is not set
1014# CONFIG_SOLARIS_X86_PARTITION is not set
1015# CONFIG_UNIXWARE_DISKLABEL is not set
1016# CONFIG_LDM_PARTITION is not set
1017# CONFIG_SGI_PARTITION is not set
1018# CONFIG_ULTRIX_PARTITION is not set
1019# CONFIG_SUN_PARTITION is not set
1020# CONFIG_KARMA_PARTITION is not set
1021# CONFIG_EFI_PARTITION is not set
1022# CONFIG_SYSV68_PARTITION is not set
1023CONFIG_NLS=y
1024CONFIG_NLS_DEFAULT="iso8859-1"
1025CONFIG_NLS_CODEPAGE_437=y
1026# CONFIG_NLS_CODEPAGE_737 is not set
1027# CONFIG_NLS_CODEPAGE_775 is not set
1028# CONFIG_NLS_CODEPAGE_850 is not set
1029# CONFIG_NLS_CODEPAGE_852 is not set
1030# CONFIG_NLS_CODEPAGE_855 is not set
1031# CONFIG_NLS_CODEPAGE_857 is not set
1032# CONFIG_NLS_CODEPAGE_860 is not set
1033# CONFIG_NLS_CODEPAGE_861 is not set
1034# CONFIG_NLS_CODEPAGE_862 is not set
1035# CONFIG_NLS_CODEPAGE_863 is not set
1036# CONFIG_NLS_CODEPAGE_864 is not set
1037# CONFIG_NLS_CODEPAGE_865 is not set
1038# CONFIG_NLS_CODEPAGE_866 is not set
1039# CONFIG_NLS_CODEPAGE_869 is not set
1040# CONFIG_NLS_CODEPAGE_936 is not set
1041# CONFIG_NLS_CODEPAGE_950 is not set
1042# CONFIG_NLS_CODEPAGE_932 is not set
1043# CONFIG_NLS_CODEPAGE_949 is not set
1044# CONFIG_NLS_CODEPAGE_874 is not set
1045# CONFIG_NLS_ISO8859_8 is not set
1046# CONFIG_NLS_CODEPAGE_1250 is not set
1047# CONFIG_NLS_CODEPAGE_1251 is not set
1048# CONFIG_NLS_ASCII is not set
1049CONFIG_NLS_ISO8859_1=y
1050# CONFIG_NLS_ISO8859_2 is not set
1051# CONFIG_NLS_ISO8859_3 is not set
1052# CONFIG_NLS_ISO8859_4 is not set
1053# CONFIG_NLS_ISO8859_5 is not set
1054# CONFIG_NLS_ISO8859_6 is not set
1055# CONFIG_NLS_ISO8859_7 is not set
1056# CONFIG_NLS_ISO8859_9 is not set
1057# CONFIG_NLS_ISO8859_13 is not set
1058# CONFIG_NLS_ISO8859_14 is not set
1059# CONFIG_NLS_ISO8859_15 is not set
1060# CONFIG_NLS_KOI8_R is not set
1061# CONFIG_NLS_KOI8_U is not set
1062# CONFIG_NLS_UTF8 is not set
1063# CONFIG_DLM is not set
1064
1065#
1066# Library routines
1067#
1068CONFIG_BITREVERSE=y
1069# CONFIG_GENERIC_FIND_FIRST_BIT is not set
1070# CONFIG_CRC_CCITT is not set
1071# CONFIG_CRC16 is not set
1072# CONFIG_CRC_ITU_T is not set
1073CONFIG_CRC32=y
1074# CONFIG_CRC7 is not set
1075# CONFIG_LIBCRC32C is not set
1076CONFIG_ZLIB_INFLATE=y
1077CONFIG_ZLIB_DEFLATE=y
1078CONFIG_PLIST=y
1079CONFIG_HAS_IOMEM=y
1080CONFIG_HAS_IOPORT=y
1081CONFIG_HAS_DMA=y
1082CONFIG_HAVE_LMB=y
1083
1084#
1085# Kernel hacking
1086#
1087CONFIG_PRINTK_TIME=y
1088CONFIG_ENABLE_WARN_DEPRECATED=y
1089CONFIG_ENABLE_MUST_CHECK=y
1090CONFIG_FRAME_WARN=1024
1091# CONFIG_MAGIC_SYSRQ is not set
1092# CONFIG_UNUSED_SYMBOLS is not set
1093# CONFIG_DEBUG_FS is not set
1094# CONFIG_HEADERS_CHECK is not set
1095CONFIG_DEBUG_KERNEL=y
1096# CONFIG_DEBUG_SHIRQ is not set
1097CONFIG_DETECT_SOFTLOCKUP=y
1098CONFIG_SCHED_DEBUG=y
1099# CONFIG_SCHEDSTATS is not set
1100# CONFIG_TIMER_STATS is not set
1101# CONFIG_SLUB_DEBUG_ON is not set
1102# CONFIG_SLUB_STATS is not set
1103# CONFIG_DEBUG_RT_MUTEXES is not set
1104# CONFIG_RT_MUTEX_TESTER is not set
1105# CONFIG_DEBUG_SPINLOCK is not set
1106# CONFIG_DEBUG_MUTEXES is not set
1107# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1108# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1109# CONFIG_DEBUG_KOBJECT is not set
1110# CONFIG_DEBUG_BUGVERBOSE is not set
1111CONFIG_DEBUG_INFO=y
1112# CONFIG_DEBUG_VM is not set
1113# CONFIG_DEBUG_WRITECOUNT is not set
1114# CONFIG_DEBUG_LIST is not set
1115# CONFIG_DEBUG_SG is not set
1116# CONFIG_BOOT_PRINTK_DELAY is not set
1117# CONFIG_RCU_TORTURE_TEST is not set
1118# CONFIG_BACKTRACE_SELF_TEST is not set
1119# CONFIG_FAULT_INJECTION is not set
1120# CONFIG_SAMPLES is not set
1121# CONFIG_DEBUG_STACKOVERFLOW is not set
1122# CONFIG_DEBUG_STACK_USAGE is not set
1123# CONFIG_DEBUG_PAGEALLOC is not set
1124# CONFIG_DEBUGGER is not set
1125# CONFIG_IRQSTACKS is not set
1126# CONFIG_BDI_SWITCH is not set
1127# CONFIG_BOOTX_TEXT is not set
1128# CONFIG_PPC_EARLY_DEBUG is not set
1129
1130#
1131# Security options
1132#
1133# CONFIG_KEYS is not set
1134# CONFIG_SECURITY is not set
1135# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1136CONFIG_CRYPTO=y
1137
1138#
1139# Crypto core or helper
1140#
1141CONFIG_CRYPTO_ALGAPI=y
1142CONFIG_CRYPTO_BLKCIPHER=y
1143CONFIG_CRYPTO_MANAGER=y
1144# CONFIG_CRYPTO_GF128MUL is not set
1145# CONFIG_CRYPTO_NULL is not set
1146# CONFIG_CRYPTO_CRYPTD is not set
1147# CONFIG_CRYPTO_AUTHENC is not set
1148# CONFIG_CRYPTO_TEST is not set
1149
1150#
1151# Authenticated Encryption with Associated Data
1152#
1153# CONFIG_CRYPTO_CCM is not set
1154# CONFIG_CRYPTO_GCM is not set
1155# CONFIG_CRYPTO_SEQIV is not set
1156
1157#
1158# Block modes
1159#
1160CONFIG_CRYPTO_CBC=y
1161# CONFIG_CRYPTO_CTR is not set
1162# CONFIG_CRYPTO_CTS is not set
1163CONFIG_CRYPTO_ECB=y
1164# CONFIG_CRYPTO_LRW is not set
1165CONFIG_CRYPTO_PCBC=y
1166# CONFIG_CRYPTO_XTS is not set
1167
1168#
1169# Hash modes
1170#
1171# CONFIG_CRYPTO_HMAC is not set
1172# CONFIG_CRYPTO_XCBC is not set
1173
1174#
1175# Digest
1176#
1177# CONFIG_CRYPTO_CRC32C is not set
1178# CONFIG_CRYPTO_MD4 is not set
1179CONFIG_CRYPTO_MD5=y
1180# CONFIG_CRYPTO_MICHAEL_MIC is not set
1181# CONFIG_CRYPTO_SHA1 is not set
1182# CONFIG_CRYPTO_SHA256 is not set
1183# CONFIG_CRYPTO_SHA512 is not set
1184# CONFIG_CRYPTO_TGR192 is not set
1185# CONFIG_CRYPTO_WP512 is not set
1186
1187#
1188# Ciphers
1189#
1190# CONFIG_CRYPTO_AES is not set
1191# CONFIG_CRYPTO_ANUBIS is not set
1192# CONFIG_CRYPTO_ARC4 is not set
1193# CONFIG_CRYPTO_BLOWFISH is not set
1194# CONFIG_CRYPTO_CAMELLIA is not set
1195# CONFIG_CRYPTO_CAST5 is not set
1196# CONFIG_CRYPTO_CAST6 is not set
1197CONFIG_CRYPTO_DES=y
1198# CONFIG_CRYPTO_FCRYPT is not set
1199# CONFIG_CRYPTO_KHAZAD is not set
1200# CONFIG_CRYPTO_SALSA20 is not set
1201# CONFIG_CRYPTO_SEED is not set
1202# CONFIG_CRYPTO_SERPENT is not set
1203# CONFIG_CRYPTO_TEA is not set
1204# CONFIG_CRYPTO_TWOFISH is not set
1205
1206#
1207# Compression
1208#
1209# CONFIG_CRYPTO_DEFLATE is not set
1210# CONFIG_CRYPTO_LZO is not set
1211CONFIG_CRYPTO_HW=y
1212CONFIG_PPC_CLOCK=y
1213CONFIG_PPC_LIB_RHEAP=y
1214# CONFIG_VIRTUALIZATION is not set
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 2d202f274e73..29a0e039d436 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -74,20 +74,20 @@ void __init reserve_crashkernel(void)
74 ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(), 74 ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(),
75 &crash_size, &crash_base); 75 &crash_size, &crash_base);
76 if (ret == 0 && crash_size > 0) { 76 if (ret == 0 && crash_size > 0) {
77 if (crash_base == 0)
78 crash_base = KDUMP_KERNELBASE;
79 crashk_res.start = crash_base; 77 crashk_res.start = crash_base;
80 } else { 78 crashk_res.end = crash_base + crash_size - 1;
81 /* handle the device tree */
82 crash_size = crashk_res.end - crashk_res.start + 1;
83 } 79 }
84 80
85 if (crash_size == 0) 81 if (crashk_res.end == crashk_res.start) {
82 crashk_res.start = crashk_res.end = 0;
86 return; 83 return;
84 }
87 85
88 /* We might have got these values via the command line or the 86 /* We might have got these values via the command line or the
89 * device tree, either way sanitise them now. */ 87 * device tree, either way sanitise them now. */
90 88
89 crash_size = crashk_res.end - crashk_res.start + 1;
90
91 if (crashk_res.start != KDUMP_KERNELBASE) 91 if (crashk_res.start != KDUMP_KERNELBASE)
92 printk("Crash kernel location must be 0x%x\n", 92 printk("Crash kernel location must be 0x%x\n",
93 KDUMP_KERNELBASE); 93 KDUMP_KERNELBASE);
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 09fcb50c45ae..cf6b5a7d8b3f 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -133,9 +133,6 @@ EXPORT_SYMBOL(adb_try_handler_change);
133EXPORT_SYMBOL(cuda_request); 133EXPORT_SYMBOL(cuda_request);
134EXPORT_SYMBOL(cuda_poll); 134EXPORT_SYMBOL(cuda_poll);
135#endif /* CONFIG_ADB_CUDA */ 135#endif /* CONFIG_ADB_CUDA */
136#ifdef CONFIG_VT
137EXPORT_SYMBOL(kd_mksound);
138#endif
139EXPORT_SYMBOL(to_tm); 136EXPORT_SYMBOL(to_tm);
140 137
141#ifdef CONFIG_PPC32 138#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index dff6308d1b5e..25e3fd8606ab 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -487,9 +487,12 @@ static void __init emergency_stack_init(void)
487 */ 487 */
488 limit = min(0x10000000UL, lmb.rmo_size); 488 limit = min(0x10000000UL, lmb.rmo_size);
489 489
490 for_each_possible_cpu(i) 490 for_each_possible_cpu(i) {
491 paca[i].emergency_sp = 491 unsigned long sp;
492 __va(lmb_alloc_base(HW_PAGE_SIZE, 128, limit)) + HW_PAGE_SIZE; 492 sp = lmb_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
493 sp += THREAD_SIZE;
494 paca[i].emergency_sp = __va(sp);
495 }
493} 496}
494 497
495/* 498/*
diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
index cf945d55c276..acd2fc8cf492 100644
--- a/arch/powerpc/platforms/52xx/Kconfig
+++ b/arch/powerpc/platforms/52xx/Kconfig
@@ -44,3 +44,9 @@ config PPC_MPC5200_BUGFIX
44 44
45 It is safe to say 'Y' here 45 It is safe to say 'Y' here
46 46
47config PPC_MPC5200_GPIO
48 bool "MPC5200 GPIO support"
49 depends on PPC_MPC52xx
50 select HAVE_GPIO_LIB
51 help
52 Enable gpiolib support for mpc5200 based boards
diff --git a/arch/powerpc/platforms/52xx/Makefile b/arch/powerpc/platforms/52xx/Makefile
index fe1b81bb5224..daf0e1568d6d 100644
--- a/arch/powerpc/platforms/52xx/Makefile
+++ b/arch/powerpc/platforms/52xx/Makefile
@@ -14,3 +14,5 @@ obj-$(CONFIG_PM) += mpc52xx_sleep.o mpc52xx_pm.o
14ifeq ($(CONFIG_PPC_LITE5200),y) 14ifeq ($(CONFIG_PPC_LITE5200),y)
15 obj-$(CONFIG_PM) += lite5200_sleep.o lite5200_pm.o 15 obj-$(CONFIG_PM) += lite5200_sleep.o lite5200_pm.o
16endif 16endif
17
18obj-$(CONFIG_PPC_MPC5200_GPIO) += mpc52xx_gpio.o \ No newline at end of file
diff --git a/arch/powerpc/platforms/52xx/mpc5200_simple.c b/arch/powerpc/platforms/52xx/mpc5200_simple.c
index c48b82bc2aad..a3bda0b9f1ff 100644
--- a/arch/powerpc/platforms/52xx/mpc5200_simple.c
+++ b/arch/powerpc/platforms/52xx/mpc5200_simple.c
@@ -51,6 +51,7 @@ static void __init mpc5200_simple_setup_arch(void)
51/* list of the supported boards */ 51/* list of the supported boards */
52static char *board[] __initdata = { 52static char *board[] __initdata = {
53 "promess,motionpro", 53 "promess,motionpro",
54 "phytec,pcm030",
54 "schindler,cm5200", 55 "schindler,cm5200",
55 "tqc,tqm5200", 56 "tqc,tqm5200",
56 NULL 57 NULL
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_gpio.c b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
new file mode 100644
index 000000000000..48da5dfe4856
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/mpc52xx_gpio.c
@@ -0,0 +1,465 @@
1/*
2 * MPC52xx gpio driver
3 *
4 * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/of.h>
21#include <linux/kernel.h>
22#include <linux/of_gpio.h>
23#include <linux/io.h>
24#include <linux/of_platform.h>
25
26#include <asm/gpio.h>
27#include <asm/mpc52xx.h>
28#include <sysdev/fsl_soc.h>
29
30static DEFINE_SPINLOCK(gpio_lock);
31
32struct mpc52xx_gpiochip {
33 struct of_mm_gpio_chip mmchip;
34 unsigned int shadow_dvo;
35 unsigned int shadow_gpioe;
36 unsigned int shadow_ddr;
37};
38
39/*
40 * GPIO LIB API implementation for wakeup GPIOs.
41 *
42 * There's a maximum of 8 wakeup GPIOs. Which of these are available
43 * for use depends on your board setup.
44 *
45 * 0 -> GPIO_WKUP_7
46 * 1 -> GPIO_WKUP_6
47 * 2 -> PSC6_1
48 * 3 -> PSC6_0
49 * 4 -> ETH_17
50 * 5 -> PSC3_9
51 * 6 -> PSC2_4
52 * 7 -> PSC1_4
53 *
54 */
55static int mpc52xx_wkup_gpio_get(struct gpio_chip *gc, unsigned int gpio)
56{
57 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
58 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
59 unsigned int ret;
60
61 ret = (in_8(&regs->wkup_ival) >> (7 - gpio)) & 1;
62
63 pr_debug("%s: gpio: %d ret: %d\n", __func__, gpio, ret);
64
65 return ret;
66}
67
68static inline void
69__mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
70{
71 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
72 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
73 struct mpc52xx_gpiochip, mmchip);
74 struct mpc52xx_gpio_wkup __iomem *regs = mm_gc->regs;
75
76 if (val)
77 chip->shadow_dvo |= 1 << (7 - gpio);
78 else
79 chip->shadow_dvo &= ~(1 << (7 - gpio));
80
81 out_8(&regs->wkup_dvo, chip->shadow_dvo);
82}
83
84static void
85mpc52xx_wkup_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
86{
87 unsigned long flags;
88
89 spin_lock_irqsave(&gpio_lock, flags);
90
91 __mpc52xx_wkup_gpio_set(gc, gpio, val);
92
93 spin_unlock_irqrestore(&gpio_lock, flags);
94
95 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
96}
97
98static int mpc52xx_wkup_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
99{
100 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
101 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
102 struct mpc52xx_gpiochip, mmchip);
103 struct mpc52xx_gpio_wkup *regs = mm_gc->regs;
104 unsigned long flags;
105
106 spin_lock_irqsave(&gpio_lock, flags);
107
108 /* set the direction */
109 chip->shadow_ddr &= ~(1 << (7 - gpio));
110 out_8(&regs->wkup_ddr, chip->shadow_ddr);
111
112 /* and enable the pin */
113 chip->shadow_gpioe |= 1 << (7 - gpio);
114 out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
115
116 spin_unlock_irqrestore(&gpio_lock, flags);
117
118 return 0;
119}
120
121static int
122mpc52xx_wkup_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
123{
124 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
125 struct mpc52xx_gpio_wkup *regs = mm_gc->regs;
126 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
127 struct mpc52xx_gpiochip, mmchip);
128 unsigned long flags;
129
130 spin_lock_irqsave(&gpio_lock, flags);
131
132 __mpc52xx_wkup_gpio_set(gc, gpio, val);
133
134 /* Then set direction */
135 chip->shadow_ddr |= 1 << (7 - gpio);
136 out_8(&regs->wkup_ddr, chip->shadow_ddr);
137
138 /* Finally enable the pin */
139 chip->shadow_gpioe |= 1 << (7 - gpio);
140 out_8(&regs->wkup_gpioe, chip->shadow_gpioe);
141
142 spin_unlock_irqrestore(&gpio_lock, flags);
143
144 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
145
146 return 0;
147}
148
149static int __devinit mpc52xx_wkup_gpiochip_probe(struct of_device *ofdev,
150 const struct of_device_id *match)
151{
152 struct mpc52xx_gpiochip *chip;
153 struct mpc52xx_gpio_wkup *regs;
154 struct of_gpio_chip *ofchip;
155 int ret;
156
157 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
158 if (!chip)
159 return -ENOMEM;
160
161 ofchip = &chip->mmchip.of_gc;
162
163 ofchip->gpio_cells = 2;
164 ofchip->gc.ngpio = 8;
165 ofchip->gc.direction_input = mpc52xx_wkup_gpio_dir_in;
166 ofchip->gc.direction_output = mpc52xx_wkup_gpio_dir_out;
167 ofchip->gc.get = mpc52xx_wkup_gpio_get;
168 ofchip->gc.set = mpc52xx_wkup_gpio_set;
169
170 ret = of_mm_gpiochip_add(ofdev->node, &chip->mmchip);
171 if (ret)
172 return ret;
173
174 regs = chip->mmchip.regs;
175 chip->shadow_gpioe = in_8(&regs->wkup_gpioe);
176 chip->shadow_ddr = in_8(&regs->wkup_ddr);
177 chip->shadow_dvo = in_8(&regs->wkup_dvo);
178
179 return 0;
180}
181
182static int mpc52xx_gpiochip_remove(struct of_device *ofdev)
183{
184 return -EBUSY;
185}
186
187static const struct of_device_id mpc52xx_wkup_gpiochip_match[] = {
188 {
189 .compatible = "fsl,mpc5200-gpio-wkup",
190 },
191 {}
192};
193
194static struct of_platform_driver mpc52xx_wkup_gpiochip_driver = {
195 .name = "gpio_wkup",
196 .match_table = mpc52xx_wkup_gpiochip_match,
197 .probe = mpc52xx_wkup_gpiochip_probe,
198 .remove = mpc52xx_gpiochip_remove,
199};
200
201/*
202 * GPIO LIB API implementation for simple GPIOs
203 *
204 * There's a maximum of 32 simple GPIOs. Which of these are available
205 * for use depends on your board setup.
206 * The numbering reflects the bit numbering in the port registers:
207 *
208 * 0..1 > reserved
209 * 2..3 > IRDA
210 * 4..7 > ETHR
211 * 8..11 > reserved
212 * 12..15 > USB
213 * 16..17 > reserved
214 * 18..23 > PSC3
215 * 24..27 > PSC2
216 * 28..31 > PSC1
217 */
218static int mpc52xx_simple_gpio_get(struct gpio_chip *gc, unsigned int gpio)
219{
220 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
221 struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
222 unsigned int ret;
223
224 ret = (in_be32(&regs->simple_ival) >> (31 - gpio)) & 1;
225
226 return ret;
227}
228
229static inline void
230__mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
231{
232 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
233 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
234 struct mpc52xx_gpiochip, mmchip);
235 struct mpc52xx_gpio __iomem *regs = mm_gc->regs;
236
237 if (val)
238 chip->shadow_dvo |= 1 << (31 - gpio);
239 else
240 chip->shadow_dvo &= ~(1 << (31 - gpio));
241 out_be32(&regs->simple_dvo, chip->shadow_dvo);
242}
243
244static void
245mpc52xx_simple_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
246{
247 unsigned long flags;
248
249 spin_lock_irqsave(&gpio_lock, flags);
250
251 __mpc52xx_simple_gpio_set(gc, gpio, val);
252
253 spin_unlock_irqrestore(&gpio_lock, flags);
254
255 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
256}
257
258static int mpc52xx_simple_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
259{
260 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
261 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
262 struct mpc52xx_gpiochip, mmchip);
263 struct mpc52xx_gpio *regs = mm_gc->regs;
264 unsigned long flags;
265
266 spin_lock_irqsave(&gpio_lock, flags);
267
268 /* set the direction */
269 chip->shadow_ddr &= ~(1 << (31 - gpio));
270 out_be32(&regs->simple_ddr, chip->shadow_ddr);
271
272 /* and enable the pin */
273 chip->shadow_gpioe |= 1 << (31 - gpio);
274 out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
275
276 spin_unlock_irqrestore(&gpio_lock, flags);
277
278 return 0;
279}
280
281static int
282mpc52xx_simple_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
283{
284 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
285 struct mpc52xx_gpiochip *chip = container_of(mm_gc,
286 struct mpc52xx_gpiochip, mmchip);
287 struct mpc52xx_gpio *regs = mm_gc->regs;
288 unsigned long flags;
289
290 spin_lock_irqsave(&gpio_lock, flags);
291
292 /* First set initial value */
293 __mpc52xx_simple_gpio_set(gc, gpio, val);
294
295 /* Then set direction */
296 chip->shadow_ddr |= 1 << (31 - gpio);
297 out_be32(&regs->simple_ddr, chip->shadow_ddr);
298
299 /* Finally enable the pin */
300 chip->shadow_gpioe |= 1 << (31 - gpio);
301 out_be32(&regs->simple_gpioe, chip->shadow_gpioe);
302
303 spin_unlock_irqrestore(&gpio_lock, flags);
304
305 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
306
307 return 0;
308}
309
310static int __devinit mpc52xx_simple_gpiochip_probe(struct of_device *ofdev,
311 const struct of_device_id *match)
312{
313 struct mpc52xx_gpiochip *chip;
314 struct of_gpio_chip *ofchip;
315 struct mpc52xx_gpio *regs;
316 int ret;
317
318 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
319 if (!chip)
320 return -ENOMEM;
321
322 ofchip = &chip->mmchip.of_gc;
323
324 ofchip->gpio_cells = 2;
325 ofchip->gc.ngpio = 32;
326 ofchip->gc.direction_input = mpc52xx_simple_gpio_dir_in;
327 ofchip->gc.direction_output = mpc52xx_simple_gpio_dir_out;
328 ofchip->gc.get = mpc52xx_simple_gpio_get;
329 ofchip->gc.set = mpc52xx_simple_gpio_set;
330
331 ret = of_mm_gpiochip_add(ofdev->node, &chip->mmchip);
332 if (ret)
333 return ret;
334
335 regs = chip->mmchip.regs;
336 chip->shadow_gpioe = in_be32(&regs->simple_gpioe);
337 chip->shadow_ddr = in_be32(&regs->simple_ddr);
338 chip->shadow_dvo = in_be32(&regs->simple_dvo);
339
340 return 0;
341}
342
343static const struct of_device_id mpc52xx_simple_gpiochip_match[] = {
344 {
345 .compatible = "fsl,mpc5200-gpio",
346 },
347 {}
348};
349
350static struct of_platform_driver mpc52xx_simple_gpiochip_driver = {
351 .name = "gpio",
352 .match_table = mpc52xx_simple_gpiochip_match,
353 .probe = mpc52xx_simple_gpiochip_probe,
354 .remove = mpc52xx_gpiochip_remove,
355};
356
357/*
358 * GPIO LIB API implementation for gpt GPIOs.
359 *
360 * Each gpt only has a single GPIO.
361 */
362static int mpc52xx_gpt_gpio_get(struct gpio_chip *gc, unsigned int gpio)
363{
364 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
365 struct mpc52xx_gpt __iomem *regs = mm_gc->regs;
366 unsigned int ret;
367
368 return (in_be32(&regs->status) & (1 << (31 - 23))) ? 1 : 0;
369
370 return ret;
371}
372
373static void
374mpc52xx_gpt_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)
375{
376 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
377 struct mpc52xx_gpt __iomem *regs = mm_gc->regs;
378
379 if (val)
380 out_be32(&regs->mode, 0x34);
381 else
382 out_be32(&regs->mode, 0x24);
383
384 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
385}
386
387static int mpc52xx_gpt_gpio_dir_in(struct gpio_chip *gc, unsigned int gpio)
388{
389 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
390 struct mpc52xx_gpt *regs = mm_gc->regs;
391
392 out_be32(&regs->mode, 0x04);
393
394 return 0;
395}
396
397static int
398mpc52xx_gpt_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
399{
400 mpc52xx_gpt_gpio_set(gc, gpio, val);
401 pr_debug("%s: gpio: %d val: %d\n", __func__, gpio, val);
402
403 return 0;
404}
405
406static int __devinit mpc52xx_gpt_gpiochip_probe(struct of_device *ofdev,
407 const struct of_device_id *match)
408{
409 struct of_mm_gpio_chip *mmchip;
410 struct of_gpio_chip *chip;
411
412 mmchip = kzalloc(sizeof(*mmchip), GFP_KERNEL);
413 if (!mmchip)
414 return -ENOMEM;
415
416 chip = &mmchip->of_gc;
417
418 chip->gpio_cells = 2;
419 chip->gc.ngpio = 1;
420 chip->gc.direction_input = mpc52xx_gpt_gpio_dir_in;
421 chip->gc.direction_output = mpc52xx_gpt_gpio_dir_out;
422 chip->gc.get = mpc52xx_gpt_gpio_get;
423 chip->gc.set = mpc52xx_gpt_gpio_set;
424
425 return of_mm_gpiochip_add(ofdev->node, mmchip);
426}
427
428static const struct of_device_id mpc52xx_gpt_gpiochip_match[] = {
429 {
430 .compatible = "fsl,mpc5200-gpt-gpio",
431 },
432 {}
433};
434
435static struct of_platform_driver mpc52xx_gpt_gpiochip_driver = {
436 .name = "gpio_gpt",
437 .match_table = mpc52xx_gpt_gpiochip_match,
438 .probe = mpc52xx_gpt_gpiochip_probe,
439 .remove = mpc52xx_gpiochip_remove,
440};
441
442static int __init mpc52xx_gpio_init(void)
443{
444 if (of_register_platform_driver(&mpc52xx_wkup_gpiochip_driver))
445 printk(KERN_ERR "Unable to register wakeup GPIO driver\n");
446
447 if (of_register_platform_driver(&mpc52xx_simple_gpiochip_driver))
448 printk(KERN_ERR "Unable to register simple GPIO driver\n");
449
450 if (of_register_platform_driver(&mpc52xx_gpt_gpiochip_driver))
451 printk(KERN_ERR "Unable to register gpt GPIO driver\n");
452
453 return 0;
454}
455
456
457/* Make sure we get initialised before anyone else tries to use us */
458subsys_initcall(mpc52xx_gpio_init);
459
460/* No exit call at the moment as we cannot unregister of gpio chips */
461
462MODULE_DESCRIPTION("Freescale MPC52xx gpio driver");
463MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de");
464MODULE_LICENSE("GPL v2");
465
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index d0dead8b9a95..8479394e9ab4 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -18,6 +18,7 @@
18 18
19#undef DEBUG 19#undef DEBUG
20 20
21#include <linux/interrupt.h>
21#include <linux/irq.h> 22#include <linux/irq.h>
22#include <linux/of.h> 23#include <linux/of.h>
23#include <asm/io.h> 24#include <asm/io.h>
@@ -109,11 +110,48 @@ static void mpc52xx_extirq_ack(unsigned int virq)
109 io_be_setbit(&intr->ctrl, 27-l2irq); 110 io_be_setbit(&intr->ctrl, 27-l2irq);
110} 111}
111 112
113static int mpc52xx_extirq_set_type(unsigned int virq, unsigned int flow_type)
114{
115 u32 ctrl_reg, type;
116 int irq;
117 int l2irq;
118
119 irq = irq_map[virq].hwirq;
120 l2irq = (irq & MPC52xx_IRQ_L2_MASK) >> MPC52xx_IRQ_L2_OFFSET;
121
122 pr_debug("%s: irq=%x. l2=%d flow_type=%d\n", __func__, irq, l2irq, flow_type);
123
124 switch (flow_type) {
125 case IRQF_TRIGGER_HIGH:
126 type = 0;
127 break;
128 case IRQF_TRIGGER_RISING:
129 type = 1;
130 break;
131 case IRQF_TRIGGER_FALLING:
132 type = 2;
133 break;
134 case IRQF_TRIGGER_LOW:
135 type = 3;
136 break;
137 default:
138 type = 0;
139 }
140
141 ctrl_reg = in_be32(&intr->ctrl);
142 ctrl_reg &= ~(0x3 << (22 - (l2irq * 2)));
143 ctrl_reg |= (type << (22 - (l2irq * 2)));
144 out_be32(&intr->ctrl, ctrl_reg);
145
146 return 0;
147}
148
112static struct irq_chip mpc52xx_extirq_irqchip = { 149static struct irq_chip mpc52xx_extirq_irqchip = {
113 .typename = " MPC52xx IRQ[0-3] ", 150 .typename = " MPC52xx IRQ[0-3] ",
114 .mask = mpc52xx_extirq_mask, 151 .mask = mpc52xx_extirq_mask,
115 .unmask = mpc52xx_extirq_unmask, 152 .unmask = mpc52xx_extirq_unmask,
116 .ack = mpc52xx_extirq_ack, 153 .ack = mpc52xx_extirq_ack,
154 .set_type = mpc52xx_extirq_set_type,
117}; 155};
118 156
119/* 157/*
diff --git a/arch/powerpc/platforms/cell/spufs/.gitignore b/arch/powerpc/platforms/cell/spufs/.gitignore
new file mode 100644
index 000000000000..a09ee8d84d6c
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spufs/.gitignore
@@ -0,0 +1,2 @@
1spu_save_dump.h
2spu_restore_dump.h
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 0ad83aeb70b1..177735f79317 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -78,6 +78,7 @@ void destroy_spu_context(struct kref *kref)
78{ 78{
79 struct spu_context *ctx; 79 struct spu_context *ctx;
80 ctx = container_of(kref, struct spu_context, kref); 80 ctx = container_of(kref, struct spu_context, kref);
81 spu_context_nospu_trace(destroy_spu_context__enter, ctx);
81 mutex_lock(&ctx->state_mutex); 82 mutex_lock(&ctx->state_mutex);
82 spu_deactivate(ctx); 83 spu_deactivate(ctx);
83 mutex_unlock(&ctx->state_mutex); 84 mutex_unlock(&ctx->state_mutex);
@@ -88,6 +89,7 @@ void destroy_spu_context(struct kref *kref)
88 kref_put(ctx->prof_priv_kref, ctx->prof_priv_release); 89 kref_put(ctx->prof_priv_kref, ctx->prof_priv_release);
89 BUG_ON(!list_empty(&ctx->rq)); 90 BUG_ON(!list_empty(&ctx->rq));
90 atomic_dec(&nr_spu_contexts); 91 atomic_dec(&nr_spu_contexts);
92 kfree(ctx->switch_log);
91 kfree(ctx); 93 kfree(ctx);
92} 94}
93 95
@@ -150,6 +152,8 @@ int spu_acquire_saved(struct spu_context *ctx)
150{ 152{
151 int ret; 153 int ret;
152 154
155 spu_context_nospu_trace(spu_acquire_saved__enter, ctx);
156
153 ret = spu_acquire(ctx); 157 ret = spu_acquire(ctx);
154 if (ret) 158 if (ret)
155 return ret; 159 return ret;
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 08f44d1971ac..80911a373400 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2386,6 +2386,171 @@ static const struct file_operations spufs_stat_fops = {
2386 .release = single_release, 2386 .release = single_release,
2387}; 2387};
2388 2388
2389static inline int spufs_switch_log_used(struct spu_context *ctx)
2390{
2391 return (ctx->switch_log->head - ctx->switch_log->tail) %
2392 SWITCH_LOG_BUFSIZE;
2393}
2394
2395static inline int spufs_switch_log_avail(struct spu_context *ctx)
2396{
2397 return SWITCH_LOG_BUFSIZE - spufs_switch_log_used(ctx);
2398}
2399
2400static int spufs_switch_log_open(struct inode *inode, struct file *file)
2401{
2402 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2403
2404 /*
2405 * We (ab-)use the mapping_lock here because it serves the similar
2406 * purpose for synchronizing open/close elsewhere. Maybe it should
2407 * be renamed eventually.
2408 */
2409 mutex_lock(&ctx->mapping_lock);
2410 if (ctx->switch_log) {
2411 spin_lock(&ctx->switch_log->lock);
2412 ctx->switch_log->head = 0;
2413 ctx->switch_log->tail = 0;
2414 spin_unlock(&ctx->switch_log->lock);
2415 } else {
2416 /*
2417 * We allocate the switch log data structures on first open.
2418 * They will never be free because we assume a context will
2419 * be traced until it goes away.
2420 */
2421 ctx->switch_log = kzalloc(sizeof(struct switch_log) +
2422 SWITCH_LOG_BUFSIZE * sizeof(struct switch_log_entry),
2423 GFP_KERNEL);
2424 if (!ctx->switch_log)
2425 goto out;
2426 spin_lock_init(&ctx->switch_log->lock);
2427 init_waitqueue_head(&ctx->switch_log->wait);
2428 }
2429 mutex_unlock(&ctx->mapping_lock);
2430
2431 return 0;
2432 out:
2433 mutex_unlock(&ctx->mapping_lock);
2434 return -ENOMEM;
2435}
2436
2437static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
2438{
2439 struct switch_log_entry *p;
2440
2441 p = ctx->switch_log->log + ctx->switch_log->tail % SWITCH_LOG_BUFSIZE;
2442
2443 return snprintf(tbuf, n, "%u.%09u %d %u %u %llu\n",
2444 (unsigned int) p->tstamp.tv_sec,
2445 (unsigned int) p->tstamp.tv_nsec,
2446 p->spu_id,
2447 (unsigned int) p->type,
2448 (unsigned int) p->val,
2449 (unsigned long long) p->timebase);
2450}
2451
2452static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
2453 size_t len, loff_t *ppos)
2454{
2455 struct inode *inode = file->f_path.dentry->d_inode;
2456 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2457 int error = 0, cnt = 0;
2458
2459 if (!buf || len < 0)
2460 return -EINVAL;
2461
2462 while (cnt < len) {
2463 char tbuf[128];
2464 int width;
2465
2466 if (file->f_flags & O_NONBLOCK) {
2467 if (spufs_switch_log_used(ctx) <= 0)
2468 return cnt ? cnt : -EAGAIN;
2469 } else {
2470 /* Wait for data in buffer */
2471 error = wait_event_interruptible(ctx->switch_log->wait,
2472 spufs_switch_log_used(ctx) > 0);
2473 if (error)
2474 break;
2475 }
2476
2477 spin_lock(&ctx->switch_log->lock);
2478 if (ctx->switch_log->head == ctx->switch_log->tail) {
2479 /* multiple readers race? */
2480 spin_unlock(&ctx->switch_log->lock);
2481 continue;
2482 }
2483
2484 width = switch_log_sprint(ctx, tbuf, sizeof(tbuf));
2485 if (width < len) {
2486 ctx->switch_log->tail =
2487 (ctx->switch_log->tail + 1) %
2488 SWITCH_LOG_BUFSIZE;
2489 }
2490
2491 spin_unlock(&ctx->switch_log->lock);
2492
2493 /*
2494 * If the record is greater than space available return
2495 * partial buffer (so far)
2496 */
2497 if (width >= len)
2498 break;
2499
2500 error = copy_to_user(buf + cnt, tbuf, width);
2501 if (error)
2502 break;
2503 cnt += width;
2504 }
2505
2506 return cnt == 0 ? error : cnt;
2507}
2508
2509static unsigned int spufs_switch_log_poll(struct file *file, poll_table *wait)
2510{
2511 struct inode *inode = file->f_path.dentry->d_inode;
2512 struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
2513 unsigned int mask = 0;
2514
2515 poll_wait(file, &ctx->switch_log->wait, wait);
2516
2517 if (spufs_switch_log_used(ctx) > 0)
2518 mask |= POLLIN;
2519
2520 return mask;
2521}
2522
2523static const struct file_operations spufs_switch_log_fops = {
2524 .owner = THIS_MODULE,
2525 .open = spufs_switch_log_open,
2526 .read = spufs_switch_log_read,
2527 .poll = spufs_switch_log_poll,
2528};
2529
2530void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
2531 u32 type, u32 val)
2532{
2533 if (!ctx->switch_log)
2534 return;
2535
2536 spin_lock(&ctx->switch_log->lock);
2537 if (spufs_switch_log_avail(ctx) > 1) {
2538 struct switch_log_entry *p;
2539
2540 p = ctx->switch_log->log + ctx->switch_log->head;
2541 ktime_get_ts(&p->tstamp);
2542 p->timebase = get_tb();
2543 p->spu_id = spu ? spu->number : -1;
2544 p->type = type;
2545 p->val = val;
2546
2547 ctx->switch_log->head =
2548 (ctx->switch_log->head + 1) % SWITCH_LOG_BUFSIZE;
2549 }
2550 spin_unlock(&ctx->switch_log->lock);
2551
2552 wake_up(&ctx->switch_log->wait);
2553}
2389 2554
2390struct tree_descr spufs_dir_contents[] = { 2555struct tree_descr spufs_dir_contents[] = {
2391 { "capabilities", &spufs_caps_fops, 0444, }, 2556 { "capabilities", &spufs_caps_fops, 0444, },
@@ -2422,6 +2587,7 @@ struct tree_descr spufs_dir_contents[] = {
2422 { "proxydma_info", &spufs_proxydma_info_fops, 0444, }, 2587 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
2423 { "tid", &spufs_tid_fops, 0444, }, 2588 { "tid", &spufs_tid_fops, 0444, },
2424 { "stat", &spufs_stat_fops, 0444, }, 2589 { "stat", &spufs_stat_fops, 0444, },
2590 { "switch_log", &spufs_switch_log_fops, 0444 },
2425 {}, 2591 {},
2426}; 2592};
2427 2593
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index 96bf7c2b86fc..a9c35b7b719f 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -405,6 +405,8 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
405 ret = spu_run_fini(ctx, npc, &status); 405 ret = spu_run_fini(ctx, npc, &status);
406 spu_yield(ctx); 406 spu_yield(ctx);
407 407
408 spu_switch_log_notify(NULL, ctx, SWITCH_LOG_EXIT, status);
409
408 if ((status & SPU_STATUS_STOPPED_BY_STOP) && 410 if ((status & SPU_STATUS_STOPPED_BY_STOP) &&
409 (((status >> SPU_STOP_STATUS_SHIFT) & 0x3f00) == 0x2100)) 411 (((status >> SPU_STOP_STATUS_SHIFT) & 0x3f00) == 0x2100))
410 ctx->stats.libassist++; 412 ctx->stats.libassist++;
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 45dcd2693502..7298e7db2c83 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -240,6 +240,7 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx)
240 spu->mfc_callback = spufs_mfc_callback; 240 spu->mfc_callback = spufs_mfc_callback;
241 mb(); 241 mb();
242 spu_unmap_mappings(ctx); 242 spu_unmap_mappings(ctx);
243 spu_switch_log_notify(spu, ctx, SWITCH_LOG_START, 0);
243 spu_restore(&ctx->csa, spu); 244 spu_restore(&ctx->csa, spu);
244 spu->timestamp = jiffies; 245 spu->timestamp = jiffies;
245 spu_cpu_affinity_set(spu, raw_smp_processor_id()); 246 spu_cpu_affinity_set(spu, raw_smp_processor_id());
@@ -419,6 +420,7 @@ static void spu_unbind_context(struct spu *spu, struct spu_context *ctx)
419 spu_switch_notify(spu, NULL); 420 spu_switch_notify(spu, NULL);
420 spu_unmap_mappings(ctx); 421 spu_unmap_mappings(ctx);
421 spu_save(&ctx->csa, spu); 422 spu_save(&ctx->csa, spu);
423 spu_switch_log_notify(spu, ctx, SWITCH_LOG_STOP, 0);
422 spu->timestamp = jiffies; 424 spu->timestamp = jiffies;
423 ctx->state = SPU_STATE_SAVED; 425 ctx->state = SPU_STATE_SAVED;
424 spu->ibox_callback = NULL; 426 spu->ibox_callback = NULL;
@@ -591,7 +593,7 @@ static struct spu *find_victim(struct spu_context *ctx)
591 struct spu *spu; 593 struct spu *spu;
592 int node, n; 594 int node, n;
593 595
594 spu_context_nospu_trace(spu_find_vitim__enter, ctx); 596 spu_context_nospu_trace(spu_find_victim__enter, ctx);
595 597
596 /* 598 /*
597 * Look for a possible preemption candidate on the local node first. 599 * Look for a possible preemption candidate on the local node first.
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index cdc515182f82..7312745b7540 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -47,6 +47,30 @@ enum {
47 SPU_SCHED_SPU_RUN, /* context is within spu_run */ 47 SPU_SCHED_SPU_RUN, /* context is within spu_run */
48}; 48};
49 49
50enum {
51 SWITCH_LOG_BUFSIZE = 4096,
52};
53
54enum {
55 SWITCH_LOG_START,
56 SWITCH_LOG_STOP,
57 SWITCH_LOG_EXIT,
58};
59
60struct switch_log {
61 spinlock_t lock;
62 wait_queue_head_t wait;
63 unsigned long head;
64 unsigned long tail;
65 struct switch_log_entry {
66 struct timespec tstamp;
67 s32 spu_id;
68 u32 type;
69 u32 val;
70 u64 timebase;
71 } log[];
72};
73
50struct spu_context { 74struct spu_context {
51 struct spu *spu; /* pointer to a physical SPU */ 75 struct spu *spu; /* pointer to a physical SPU */
52 struct spu_state csa; /* SPU context save area. */ 76 struct spu_state csa; /* SPU context save area. */
@@ -116,6 +140,9 @@ struct spu_context {
116 unsigned long long libassist; 140 unsigned long long libassist;
117 } stats; 141 } stats;
118 142
143 /* context switch log */
144 struct switch_log *switch_log;
145
119 struct list_head aff_list; 146 struct list_head aff_list;
120 int aff_head; 147 int aff_head;
121 int aff_offset; 148 int aff_offset;
@@ -256,6 +283,8 @@ int spu_activate(struct spu_context *ctx, unsigned long flags);
256void spu_deactivate(struct spu_context *ctx); 283void spu_deactivate(struct spu_context *ctx);
257void spu_yield(struct spu_context *ctx); 284void spu_yield(struct spu_context *ctx);
258void spu_switch_notify(struct spu *spu, struct spu_context *ctx); 285void spu_switch_notify(struct spu *spu, struct spu_context *ctx);
286void spu_switch_log_notify(struct spu *spu, struct spu_context *ctx,
287 u32 type, u32 val);
259void spu_set_timeslice(struct spu_context *ctx); 288void spu_set_timeslice(struct spu_context *ctx);
260void spu_update_sched_info(struct spu_context *ctx); 289void spu_update_sched_info(struct spu_context *ctx);
261void __spu_update_sched_info(struct spu_context *ctx); 290void __spu_update_sched_info(struct spu_context *ctx);
@@ -330,8 +359,8 @@ extern void spuctx_switch_state(struct spu_context *ctx,
330 enum spu_utilization_state new_state); 359 enum spu_utilization_state new_state);
331 360
332#define spu_context_trace(name, ctx, spu) \ 361#define spu_context_trace(name, ctx, spu) \
333 trace_mark(name, "%p %p", ctx, spu); 362 trace_mark(name, "ctx %p spu %p", ctx, spu);
334#define spu_context_nospu_trace(name, ctx) \ 363#define spu_context_nospu_trace(name, ctx) \
335 trace_mark(name, "%p", ctx); 364 trace_mark(name, "ctx %p", ctx);
336 365
337#endif 366#endif
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
index aea5286f1245..53202422ba72 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
@@ -171,24 +171,24 @@ static void spu_context_nospu_event(void *probe_private, void *call_data,
171} 171}
172 172
173struct spu_probe spu_probes[] = { 173struct spu_probe spu_probes[] = {
174 { "spu_bind_context__enter", "%p %p", spu_context_event }, 174 { "spu_bind_context__enter", "ctx %p spu %p", spu_context_event },
175 { "spu_unbind_context__enter", "%p %p", spu_context_event }, 175 { "spu_unbind_context__enter", "ctx %p spu %p", spu_context_event },
176 { "spu_get_idle__enter", "%p", spu_context_nospu_event }, 176 { "spu_get_idle__enter", "ctx %p", spu_context_nospu_event },
177 { "spu_get_idle__found", "%p %p", spu_context_event }, 177 { "spu_get_idle__found", "ctx %p spu %p", spu_context_event },
178 { "spu_get_idle__not_found", "%p", spu_context_nospu_event }, 178 { "spu_get_idle__not_found", "ctx %p", spu_context_nospu_event },
179 { "spu_find_victim__enter", "%p", spu_context_nospu_event }, 179 { "spu_find_victim__enter", "ctx %p", spu_context_nospu_event },
180 { "spusched_tick__preempt", "%p %p", spu_context_event }, 180 { "spusched_tick__preempt", "ctx %p spu %p", spu_context_event },
181 { "spusched_tick__newslice", "%p", spu_context_nospu_event }, 181 { "spusched_tick__newslice", "ctx %p", spu_context_nospu_event },
182 { "spu_yield__enter", "%p", spu_context_nospu_event }, 182 { "spu_yield__enter", "ctx %p", spu_context_nospu_event },
183 { "spu_deactivate__enter", "%p", spu_context_nospu_event }, 183 { "spu_deactivate__enter", "ctx %p", spu_context_nospu_event },
184 { "__spu_deactivate__unload", "%p %p", spu_context_event }, 184 { "__spu_deactivate__unload", "ctx %p spu %p", spu_context_event },
185 { "spufs_ps_nopfn__enter", "%p", spu_context_nospu_event }, 185 { "spufs_ps_nopfn__enter", "ctx %p", spu_context_nospu_event },
186 { "spufs_ps_nopfn__sleep", "%p", spu_context_nospu_event }, 186 { "spufs_ps_nopfn__sleep", "ctx %p", spu_context_nospu_event },
187 { "spufs_ps_nopfn__wake", "%p %p", spu_context_event }, 187 { "spufs_ps_nopfn__wake", "ctx %p spu %p", spu_context_event },
188 { "spufs_ps_nopfn__insert", "%p %p", spu_context_event }, 188 { "spufs_ps_nopfn__insert", "ctx %p spu %p", spu_context_event },
189 { "spu_acquire_saved__enter", "%p", spu_context_nospu_event }, 189 { "spu_acquire_saved__enter", "ctx %p", spu_context_nospu_event },
190 { "destroy_spu_context__enter", "%p", spu_context_nospu_event }, 190 { "destroy_spu_context__enter", "ctx %p", spu_context_nospu_event },
191 { "spufs_stop_callback__enter", "%p %p", spu_context_event }, 191 { "spufs_stop_callback__enter", "ctx %p spu %p", spu_context_event },
192}; 192};
193 193
194static int __init sputrace_init(void) 194static int __init sputrace_init(void)
diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
index d9036ef0b658..16ac11ca7ba0 100644
--- a/arch/ppc/kernel/ppc_ksyms.c
+++ b/arch/ppc/kernel/ppc_ksyms.c
@@ -183,9 +183,6 @@ EXPORT_SYMBOL(cuda_poll);
183#if defined(CONFIG_BOOTX_TEXT) 183#if defined(CONFIG_BOOTX_TEXT)
184EXPORT_SYMBOL(btext_update_display); 184EXPORT_SYMBOL(btext_update_display);
185#endif 185#endif
186#ifdef CONFIG_VT
187EXPORT_SYMBOL(kd_mksound);
188#endif
189EXPORT_SYMBOL(to_tm); 186EXPORT_SYMBOL(to_tm);
190 187
191EXPORT_SYMBOL(pm_power_off); 188EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 8f5f02160ffc..29a7940f284f 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -300,6 +300,14 @@ comment "Kernel preemption"
300 300
301source "kernel/Kconfig.preempt" 301source "kernel/Kconfig.preempt"
302 302
303config ARCH_SPARSEMEM_ENABLE
304 def_bool y
305 select SPARSEMEM_VMEMMAP_ENABLE
306 select SPARSEMEM_VMEMMAP
307
308config ARCH_SPARSEMEM_DEFAULT
309 def_bool y
310
303source "mm/Kconfig" 311source "mm/Kconfig"
304 312
305comment "I/O subsystem configuration" 313comment "I/O subsystem configuration"
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index a72f208e62d0..aa341d0ea1e6 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25-rc4 3# Linux kernel version: 2.6.25
4# Wed Mar 5 11:22:59 2008 4# Wed Apr 30 11:07:45 2008
5# 5#
6CONFIG_SCHED_MC=y 6CONFIG_SCHED_MC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -14,10 +14,12 @@ CONFIG_RWSEM_XCHGADD_ALGORITHM=y
14# CONFIG_ARCH_HAS_ILOG2_U64 is not set 14# CONFIG_ARCH_HAS_ILOG2_U64 is not set
15CONFIG_GENERIC_HWEIGHT=y 15CONFIG_GENERIC_HWEIGHT=y
16CONFIG_GENERIC_TIME=y 16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_GENERIC_BUG=y 18CONFIG_GENERIC_BUG=y
18CONFIG_NO_IOMEM=y 19CONFIG_NO_IOMEM=y
19CONFIG_NO_DMA=y 20CONFIG_NO_DMA=y
20CONFIG_GENERIC_LOCKBREAK=y 21CONFIG_GENERIC_LOCKBREAK=y
22CONFIG_PGSTE=y
21CONFIG_S390=y 23CONFIG_S390=y
22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
23 25
@@ -43,6 +45,7 @@ CONFIG_LOG_BUF_SHIFT=17
43CONFIG_CGROUPS=y 45CONFIG_CGROUPS=y
44# CONFIG_CGROUP_DEBUG is not set 46# CONFIG_CGROUP_DEBUG is not set
45CONFIG_CGROUP_NS=y 47CONFIG_CGROUP_NS=y
48# CONFIG_CGROUP_DEVICE is not set
46# CONFIG_CPUSETS is not set 49# CONFIG_CPUSETS is not set
47CONFIG_GROUP_SCHED=y 50CONFIG_GROUP_SCHED=y
48CONFIG_FAIR_GROUP_SCHED=y 51CONFIG_FAIR_GROUP_SCHED=y
@@ -65,6 +68,7 @@ CONFIG_INITRAMFS_SOURCE=""
65CONFIG_SYSCTL=y 68CONFIG_SYSCTL=y
66# CONFIG_EMBEDDED is not set 69# CONFIG_EMBEDDED is not set
67CONFIG_SYSCTL_SYSCALL=y 70CONFIG_SYSCTL_SYSCALL=y
71CONFIG_SYSCTL_SYSCALL_CHECK=y
68CONFIG_KALLSYMS=y 72CONFIG_KALLSYMS=y
69# CONFIG_KALLSYMS_ALL is not set 73# CONFIG_KALLSYMS_ALL is not set
70# CONFIG_KALLSYMS_EXTRA_PASS is not set 74# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -92,6 +96,7 @@ CONFIG_KPROBES=y
92CONFIG_KRETPROBES=y 96CONFIG_KRETPROBES=y
93CONFIG_HAVE_KPROBES=y 97CONFIG_HAVE_KPROBES=y
94CONFIG_HAVE_KRETPROBES=y 98CONFIG_HAVE_KRETPROBES=y
99# CONFIG_HAVE_DMA_ATTRS is not set
95CONFIG_PROC_PAGE_MONITOR=y 100CONFIG_PROC_PAGE_MONITOR=y
96CONFIG_SLABINFO=y 101CONFIG_SLABINFO=y
97CONFIG_RT_MUTEXES=y 102CONFIG_RT_MUTEXES=y
@@ -121,8 +126,8 @@ CONFIG_DEFAULT_DEADLINE=y
121# CONFIG_DEFAULT_CFQ is not set 126# CONFIG_DEFAULT_CFQ is not set
122# CONFIG_DEFAULT_NOOP is not set 127# CONFIG_DEFAULT_NOOP is not set
123CONFIG_DEFAULT_IOSCHED="deadline" 128CONFIG_DEFAULT_IOSCHED="deadline"
129CONFIG_PREEMPT_NOTIFIERS=y
124CONFIG_CLASSIC_RCU=y 130CONFIG_CLASSIC_RCU=y
125# CONFIG_PREEMPT_RCU is not set
126 131
127# 132#
128# Base setup 133# Base setup
@@ -131,6 +136,10 @@ CONFIG_CLASSIC_RCU=y
131# 136#
132# Processor type and features 137# Processor type and features
133# 138#
139CONFIG_TICK_ONESHOT=y
140CONFIG_NO_HZ=y
141CONFIG_HIGH_RES_TIMERS=y
142CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
134CONFIG_64BIT=y 143CONFIG_64BIT=y
135CONFIG_SMP=y 144CONFIG_SMP=y
136CONFIG_NR_CPUS=32 145CONFIG_NR_CPUS=32
@@ -161,15 +170,20 @@ CONFIG_ARCH_POPULATES_NODE_MAP=y
161# CONFIG_PREEMPT_NONE is not set 170# CONFIG_PREEMPT_NONE is not set
162# CONFIG_PREEMPT_VOLUNTARY is not set 171# CONFIG_PREEMPT_VOLUNTARY is not set
163CONFIG_PREEMPT=y 172CONFIG_PREEMPT=y
164# CONFIG_RCU_TRACE is not set 173# CONFIG_PREEMPT_RCU is not set
174CONFIG_ARCH_SPARSEMEM_ENABLE=y
175CONFIG_ARCH_SPARSEMEM_DEFAULT=y
165CONFIG_SELECT_MEMORY_MODEL=y 176CONFIG_SELECT_MEMORY_MODEL=y
166CONFIG_FLATMEM_MANUAL=y 177# CONFIG_FLATMEM_MANUAL is not set
167# CONFIG_DISCONTIGMEM_MANUAL is not set 178# CONFIG_DISCONTIGMEM_MANUAL is not set
168# CONFIG_SPARSEMEM_MANUAL is not set 179CONFIG_SPARSEMEM_MANUAL=y
169CONFIG_FLATMEM=y 180CONFIG_SPARSEMEM=y
170CONFIG_FLAT_NODE_MEM_MAP=y 181CONFIG_HAVE_MEMORY_PRESENT=y
171# CONFIG_SPARSEMEM_STATIC is not set 182# CONFIG_SPARSEMEM_STATIC is not set
172# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set 183CONFIG_SPARSEMEM_EXTREME=y
184CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
185CONFIG_SPARSEMEM_VMEMMAP=y
186CONFIG_PAGEFLAGS_EXTENDED=y
173CONFIG_SPLIT_PTLOCK_CPUS=4 187CONFIG_SPLIT_PTLOCK_CPUS=4
174CONFIG_RESOURCES_64BIT=y 188CONFIG_RESOURCES_64BIT=y
175CONFIG_ZONE_DMA_FLAG=1 189CONFIG_ZONE_DMA_FLAG=1
@@ -205,11 +219,10 @@ CONFIG_HZ_100=y
205# CONFIG_HZ_1000 is not set 219# CONFIG_HZ_1000 is not set
206CONFIG_HZ=100 220CONFIG_HZ=100
207# CONFIG_SCHED_HRTICK is not set 221# CONFIG_SCHED_HRTICK is not set
208CONFIG_NO_IDLE_HZ=y
209CONFIG_NO_IDLE_HZ_INIT=y
210CONFIG_S390_HYPFS_FS=y 222CONFIG_S390_HYPFS_FS=y
211CONFIG_KEXEC=y 223CONFIG_KEXEC=y
212# CONFIG_ZFCPDUMP is not set 224# CONFIG_ZFCPDUMP is not set
225CONFIG_S390_GUEST=y
213 226
214# 227#
215# Networking 228# Networking
@@ -272,8 +285,10 @@ CONFIG_INET6_XFRM_MODE_TUNNEL=y
272CONFIG_INET6_XFRM_MODE_BEET=y 285CONFIG_INET6_XFRM_MODE_BEET=y
273# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 286# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
274CONFIG_IPV6_SIT=y 287CONFIG_IPV6_SIT=y
288CONFIG_IPV6_NDISC_NODETYPE=y
275# CONFIG_IPV6_TUNNEL is not set 289# CONFIG_IPV6_TUNNEL is not set
276# CONFIG_IPV6_MULTIPLE_TABLES is not set 290# CONFIG_IPV6_MULTIPLE_TABLES is not set
291# CONFIG_IPV6_MROUTE is not set
277# CONFIG_NETWORK_SECMARK is not set 292# CONFIG_NETWORK_SECMARK is not set
278CONFIG_NETFILTER=y 293CONFIG_NETFILTER=y
279# CONFIG_NETFILTER_DEBUG is not set 294# CONFIG_NETFILTER_DEBUG is not set
@@ -289,6 +304,7 @@ CONFIG_NF_CONNTRACK=m
289# CONFIG_NF_CT_ACCT is not set 304# CONFIG_NF_CT_ACCT is not set
290# CONFIG_NF_CONNTRACK_MARK is not set 305# CONFIG_NF_CONNTRACK_MARK is not set
291# CONFIG_NF_CONNTRACK_EVENTS is not set 306# CONFIG_NF_CONNTRACK_EVENTS is not set
307# CONFIG_NF_CT_PROTO_DCCP is not set
292# CONFIG_NF_CT_PROTO_SCTP is not set 308# CONFIG_NF_CT_PROTO_SCTP is not set
293# CONFIG_NF_CT_PROTO_UDPLITE is not set 309# CONFIG_NF_CT_PROTO_UDPLITE is not set
294# CONFIG_NF_CONNTRACK_AMANDA is not set 310# CONFIG_NF_CONNTRACK_AMANDA is not set
@@ -439,6 +455,7 @@ CONFIG_DASD_ECKD=y
439CONFIG_DASD_FBA=y 455CONFIG_DASD_FBA=y
440CONFIG_DASD_DIAG=y 456CONFIG_DASD_DIAG=y
441CONFIG_DASD_EER=y 457CONFIG_DASD_EER=y
458CONFIG_VIRTIO_BLK=m
442CONFIG_MISC_DEVICES=y 459CONFIG_MISC_DEVICES=y
443# CONFIG_EEPROM_93CX6 is not set 460# CONFIG_EEPROM_93CX6 is not set
444# CONFIG_ENCLOSURE_SERVICES is not set 461# CONFIG_ENCLOSURE_SERVICES is not set
@@ -533,7 +550,7 @@ CONFIG_NETDEV_10000=y
533# S/390 network device drivers 550# S/390 network device drivers
534# 551#
535CONFIG_LCS=m 552CONFIG_LCS=m
536CONFIG_CTC=m 553CONFIG_CTCM=m
537# CONFIG_NETIUCV is not set 554# CONFIG_NETIUCV is not set
538# CONFIG_SMSGIUCV is not set 555# CONFIG_SMSGIUCV is not set
539# CONFIG_CLAW is not set 556# CONFIG_CLAW is not set
@@ -547,10 +564,12 @@ CONFIG_CCWGROUP=y
547# CONFIG_NETCONSOLE is not set 564# CONFIG_NETCONSOLE is not set
548# CONFIG_NETPOLL is not set 565# CONFIG_NETPOLL is not set
549# CONFIG_NET_POLL_CONTROLLER is not set 566# CONFIG_NET_POLL_CONTROLLER is not set
567CONFIG_VIRTIO_NET=m
550 568
551# 569#
552# Character devices 570# Character devices
553# 571#
572CONFIG_DEVKMEM=y
554CONFIG_UNIX98_PTYS=y 573CONFIG_UNIX98_PTYS=y
555CONFIG_LEGACY_PTYS=y 574CONFIG_LEGACY_PTYS=y
556CONFIG_LEGACY_PTY_COUNT=256 575CONFIG_LEGACY_PTY_COUNT=256
@@ -600,6 +619,7 @@ CONFIG_S390_VMUR=m
600# Sonics Silicon Backplane 619# Sonics Silicon Backplane
601# 620#
602# CONFIG_MEMSTICK is not set 621# CONFIG_MEMSTICK is not set
622# CONFIG_NEW_LEDS is not set
603 623
604# 624#
605# File systems 625# File systems
@@ -652,6 +672,7 @@ CONFIG_PROC_SYSCTL=y
652CONFIG_SYSFS=y 672CONFIG_SYSFS=y
653CONFIG_TMPFS=y 673CONFIG_TMPFS=y
654CONFIG_TMPFS_POSIX_ACL=y 674CONFIG_TMPFS_POSIX_ACL=y
675# CONFIG_HUGETLBFS is not set
655# CONFIG_HUGETLB_PAGE is not set 676# CONFIG_HUGETLB_PAGE is not set
656CONFIG_CONFIGFS_FS=m 677CONFIG_CONFIGFS_FS=m
657 678
@@ -678,12 +699,10 @@ CONFIG_NFS_FS=y
678CONFIG_NFS_V3=y 699CONFIG_NFS_V3=y
679# CONFIG_NFS_V3_ACL is not set 700# CONFIG_NFS_V3_ACL is not set
680# CONFIG_NFS_V4 is not set 701# CONFIG_NFS_V4 is not set
681# CONFIG_NFS_DIRECTIO is not set
682CONFIG_NFSD=y 702CONFIG_NFSD=y
683CONFIG_NFSD_V3=y 703CONFIG_NFSD_V3=y
684# CONFIG_NFSD_V3_ACL is not set 704# CONFIG_NFSD_V3_ACL is not set
685# CONFIG_NFSD_V4 is not set 705# CONFIG_NFSD_V4 is not set
686CONFIG_NFSD_TCP=y
687CONFIG_LOCKD=y 706CONFIG_LOCKD=y
688CONFIG_LOCKD_V4=y 707CONFIG_LOCKD_V4=y
689CONFIG_EXPORTFS=y 708CONFIG_EXPORTFS=y
@@ -731,6 +750,7 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
731# CONFIG_PRINTK_TIME is not set 750# CONFIG_PRINTK_TIME is not set
732CONFIG_ENABLE_WARN_DEPRECATED=y 751CONFIG_ENABLE_WARN_DEPRECATED=y
733CONFIG_ENABLE_MUST_CHECK=y 752CONFIG_ENABLE_MUST_CHECK=y
753CONFIG_FRAME_WARN=2048
734CONFIG_MAGIC_SYSRQ=y 754CONFIG_MAGIC_SYSRQ=y
735# CONFIG_UNUSED_SYMBOLS is not set 755# CONFIG_UNUSED_SYMBOLS is not set
736CONFIG_DEBUG_FS=y 756CONFIG_DEBUG_FS=y
@@ -754,6 +774,7 @@ CONFIG_DEBUG_SPINLOCK_SLEEP=y
754CONFIG_DEBUG_BUGVERBOSE=y 774CONFIG_DEBUG_BUGVERBOSE=y
755# CONFIG_DEBUG_INFO is not set 775# CONFIG_DEBUG_INFO is not set
756# CONFIG_DEBUG_VM is not set 776# CONFIG_DEBUG_VM is not set
777# CONFIG_DEBUG_WRITECOUNT is not set
757# CONFIG_DEBUG_LIST is not set 778# CONFIG_DEBUG_LIST is not set
758# CONFIG_DEBUG_SG is not set 779# CONFIG_DEBUG_SG is not set
759# CONFIG_FRAME_POINTER is not set 780# CONFIG_FRAME_POINTER is not set
@@ -775,58 +796,88 @@ CONFIG_SAMPLES=y
775# CONFIG_SECURITY is not set 796# CONFIG_SECURITY is not set
776# CONFIG_SECURITY_FILE_CAPABILITIES is not set 797# CONFIG_SECURITY_FILE_CAPABILITIES is not set
777CONFIG_CRYPTO=y 798CONFIG_CRYPTO=y
799
800#
801# Crypto core or helper
802#
778CONFIG_CRYPTO_ALGAPI=y 803CONFIG_CRYPTO_ALGAPI=y
779CONFIG_CRYPTO_AEAD=m 804CONFIG_CRYPTO_AEAD=m
780CONFIG_CRYPTO_BLKCIPHER=y 805CONFIG_CRYPTO_BLKCIPHER=y
781CONFIG_CRYPTO_SEQIV=m
782CONFIG_CRYPTO_HASH=m 806CONFIG_CRYPTO_HASH=m
783CONFIG_CRYPTO_MANAGER=y 807CONFIG_CRYPTO_MANAGER=y
808CONFIG_CRYPTO_GF128MUL=m
809# CONFIG_CRYPTO_NULL is not set
810# CONFIG_CRYPTO_CRYPTD is not set
811CONFIG_CRYPTO_AUTHENC=m
812# CONFIG_CRYPTO_TEST is not set
813
814#
815# Authenticated Encryption with Associated Data
816#
817CONFIG_CRYPTO_CCM=m
818CONFIG_CRYPTO_GCM=m
819CONFIG_CRYPTO_SEQIV=m
820
821#
822# Block modes
823#
824CONFIG_CRYPTO_CBC=y
825CONFIG_CRYPTO_CTR=m
826CONFIG_CRYPTO_CTS=m
827CONFIG_CRYPTO_ECB=m
828# CONFIG_CRYPTO_LRW is not set
829CONFIG_CRYPTO_PCBC=m
830# CONFIG_CRYPTO_XTS is not set
831
832#
833# Hash modes
834#
784CONFIG_CRYPTO_HMAC=m 835CONFIG_CRYPTO_HMAC=m
785# CONFIG_CRYPTO_XCBC is not set 836# CONFIG_CRYPTO_XCBC is not set
786# CONFIG_CRYPTO_NULL is not set 837
838#
839# Digest
840#
841# CONFIG_CRYPTO_CRC32C is not set
787# CONFIG_CRYPTO_MD4 is not set 842# CONFIG_CRYPTO_MD4 is not set
788CONFIG_CRYPTO_MD5=m 843CONFIG_CRYPTO_MD5=m
844# CONFIG_CRYPTO_MICHAEL_MIC is not set
789CONFIG_CRYPTO_SHA1=m 845CONFIG_CRYPTO_SHA1=m
790# CONFIG_CRYPTO_SHA256 is not set 846# CONFIG_CRYPTO_SHA256 is not set
791# CONFIG_CRYPTO_SHA512 is not set 847# CONFIG_CRYPTO_SHA512 is not set
792# CONFIG_CRYPTO_WP512 is not set
793# CONFIG_CRYPTO_TGR192 is not set 848# CONFIG_CRYPTO_TGR192 is not set
794CONFIG_CRYPTO_GF128MUL=m 849# CONFIG_CRYPTO_WP512 is not set
795CONFIG_CRYPTO_ECB=m 850
796CONFIG_CRYPTO_CBC=y 851#
797CONFIG_CRYPTO_PCBC=m 852# Ciphers
798# CONFIG_CRYPTO_LRW is not set 853#
799# CONFIG_CRYPTO_XTS is not set
800CONFIG_CRYPTO_CTR=m
801CONFIG_CRYPTO_GCM=m
802CONFIG_CRYPTO_CCM=m
803# CONFIG_CRYPTO_CRYPTD is not set
804# CONFIG_CRYPTO_DES is not set
805CONFIG_CRYPTO_FCRYPT=m
806# CONFIG_CRYPTO_BLOWFISH is not set
807# CONFIG_CRYPTO_TWOFISH is not set
808# CONFIG_CRYPTO_SERPENT is not set
809# CONFIG_CRYPTO_AES is not set 854# CONFIG_CRYPTO_AES is not set
855# CONFIG_CRYPTO_ANUBIS is not set
856# CONFIG_CRYPTO_ARC4 is not set
857# CONFIG_CRYPTO_BLOWFISH is not set
858CONFIG_CRYPTO_CAMELLIA=m
810# CONFIG_CRYPTO_CAST5 is not set 859# CONFIG_CRYPTO_CAST5 is not set
811# CONFIG_CRYPTO_CAST6 is not set 860# CONFIG_CRYPTO_CAST6 is not set
812# CONFIG_CRYPTO_TEA is not set 861# CONFIG_CRYPTO_DES is not set
813# CONFIG_CRYPTO_ARC4 is not set 862CONFIG_CRYPTO_FCRYPT=m
814# CONFIG_CRYPTO_KHAZAD is not set 863# CONFIG_CRYPTO_KHAZAD is not set
815# CONFIG_CRYPTO_ANUBIS is not set
816CONFIG_CRYPTO_SEED=m
817CONFIG_CRYPTO_SALSA20=m 864CONFIG_CRYPTO_SALSA20=m
865CONFIG_CRYPTO_SEED=m
866# CONFIG_CRYPTO_SERPENT is not set
867# CONFIG_CRYPTO_TEA is not set
868# CONFIG_CRYPTO_TWOFISH is not set
869
870#
871# Compression
872#
818# CONFIG_CRYPTO_DEFLATE is not set 873# CONFIG_CRYPTO_DEFLATE is not set
819# CONFIG_CRYPTO_MICHAEL_MIC is not set
820# CONFIG_CRYPTO_CRC32C is not set
821CONFIG_CRYPTO_CAMELLIA=m
822# CONFIG_CRYPTO_TEST is not set
823CONFIG_CRYPTO_AUTHENC=m
824CONFIG_CRYPTO_LZO=m 874CONFIG_CRYPTO_LZO=m
825CONFIG_CRYPTO_HW=y 875CONFIG_CRYPTO_HW=y
826CONFIG_ZCRYPT=m 876CONFIG_ZCRYPT=m
827# CONFIG_ZCRYPT_MONOLITHIC is not set 877# CONFIG_ZCRYPT_MONOLITHIC is not set
828# CONFIG_CRYPTO_SHA1_S390 is not set 878# CONFIG_CRYPTO_SHA1_S390 is not set
829# CONFIG_CRYPTO_SHA256_S390 is not set 879# CONFIG_CRYPTO_SHA256_S390 is not set
880CONFIG_CRYPTO_SHA512_S390=m
830# CONFIG_CRYPTO_DES_S390 is not set 881# CONFIG_CRYPTO_DES_S390 is not set
831# CONFIG_CRYPTO_AES_S390 is not set 882# CONFIG_CRYPTO_AES_S390 is not set
832CONFIG_S390_PRNG=m 883CONFIG_S390_PRNG=m
@@ -835,6 +886,8 @@ CONFIG_S390_PRNG=m
835# Library routines 886# Library routines
836# 887#
837CONFIG_BITREVERSE=m 888CONFIG_BITREVERSE=m
889# CONFIG_GENERIC_FIND_FIRST_BIT is not set
890# CONFIG_GENERIC_FIND_NEXT_BIT is not set
838# CONFIG_CRC_CCITT is not set 891# CONFIG_CRC_CCITT is not set
839# CONFIG_CRC16 is not set 892# CONFIG_CRC16 is not set
840# CONFIG_CRC_ITU_T is not set 893# CONFIG_CRC_ITU_T is not set
@@ -844,3 +897,9 @@ CONFIG_LIBCRC32C=m
844CONFIG_LZO_COMPRESS=m 897CONFIG_LZO_COMPRESS=m
845CONFIG_LZO_DECOMPRESS=m 898CONFIG_LZO_DECOMPRESS=m
846CONFIG_PLIST=y 899CONFIG_PLIST=y
900CONFIG_HAVE_KVM=y
901CONFIG_VIRTUALIZATION=y
902CONFIG_KVM=m
903CONFIG_VIRTIO=y
904CONFIG_VIRTIO_RING=y
905CONFIG_VIRTIO_BALLOON=m
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 77051cd27925..6302f5082588 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -2,8 +2,6 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5EXTRA_AFLAGS := -traditional
6
7# 5#
8# Passing null pointers is ok for smp code, since we access the lowcore here. 6# Passing null pointers is ok for smp code, since we access the lowcore here.
9# 7#
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 68ec4083bf73..d0e09684b9ce 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -139,15 +139,15 @@ static noinline __init void detect_machine_type(void)
139 139
140 /* Running under z/VM ? */ 140 /* Running under z/VM ? */
141 if (cpuinfo->cpu_id.version == 0xff) 141 if (cpuinfo->cpu_id.version == 0xff)
142 machine_flags |= 1; 142 machine_flags |= MACHINE_FLAG_VM;
143 143
144 /* Running on a P/390 ? */ 144 /* Running on a P/390 ? */
145 if (cpuinfo->cpu_id.machine == 0x7490) 145 if (cpuinfo->cpu_id.machine == 0x7490)
146 machine_flags |= 4; 146 machine_flags |= MACHINE_FLAG_P390;
147 147
148 /* Running under KVM ? */ 148 /* Running under KVM ? */
149 if (cpuinfo->cpu_id.version == 0xfe) 149 if (cpuinfo->cpu_id.version == 0xfe)
150 machine_flags |= 64; 150 machine_flags |= MACHINE_FLAG_KVM;
151} 151}
152 152
153#ifdef CONFIG_64BIT 153#ifdef CONFIG_64BIT
@@ -268,6 +268,118 @@ static noinline __init void setup_lowcore_early(void)
268 s390_base_pgm_handler_fn = early_pgm_check_handler; 268 s390_base_pgm_handler_fn = early_pgm_check_handler;
269} 269}
270 270
271static noinline __init void setup_hpage(void)
272{
273#ifndef CONFIG_DEBUG_PAGEALLOC
274 unsigned int facilities;
275
276 facilities = stfl();
277 if (!(facilities & (1UL << 23)) || !(facilities & (1UL << 29)))
278 return;
279 machine_flags |= MACHINE_FLAG_HPAGE;
280 __ctl_set_bit(0, 23);
281#endif
282}
283
284static __init void detect_mvpg(void)
285{
286#ifndef CONFIG_64BIT
287 int rc;
288
289 asm volatile(
290 " la 0,0\n"
291 " mvpg %2,%2\n"
292 "0: la %0,0\n"
293 "1:\n"
294 EX_TABLE(0b,1b)
295 : "=d" (rc) : "0" (-EOPNOTSUPP), "a" (0) : "memory", "cc", "0");
296 if (!rc)
297 machine_flags |= MACHINE_FLAG_MVPG;
298#endif
299}
300
301static __init void detect_ieee(void)
302{
303#ifndef CONFIG_64BIT
304 int rc, tmp;
305
306 asm volatile(
307 " efpc %1,0\n"
308 "0: la %0,0\n"
309 "1:\n"
310 EX_TABLE(0b,1b)
311 : "=d" (rc), "=d" (tmp): "0" (-EOPNOTSUPP) : "cc");
312 if (!rc)
313 machine_flags |= MACHINE_FLAG_IEEE;
314#endif
315}
316
317static __init void detect_csp(void)
318{
319#ifndef CONFIG_64BIT
320 int rc;
321
322 asm volatile(
323 " la 0,0\n"
324 " la 1,0\n"
325 " la 2,4\n"
326 " csp 0,2\n"
327 "0: la %0,0\n"
328 "1:\n"
329 EX_TABLE(0b,1b)
330 : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc", "0", "1", "2");
331 if (!rc)
332 machine_flags |= MACHINE_FLAG_CSP;
333#endif
334}
335
336static __init void detect_diag9c(void)
337{
338 unsigned int cpu_address;
339 int rc;
340
341 cpu_address = stap();
342 asm volatile(
343 " diag %2,0,0x9c\n"
344 "0: la %0,0\n"
345 "1:\n"
346 EX_TABLE(0b,1b)
347 : "=d" (rc) : "0" (-EOPNOTSUPP), "d" (cpu_address) : "cc");
348 if (!rc)
349 machine_flags |= MACHINE_FLAG_DIAG9C;
350}
351
352static __init void detect_diag44(void)
353{
354#ifdef CONFIG_64BIT
355 int rc;
356
357 asm volatile(
358 " diag 0,0,0x44\n"
359 "0: la %0,0\n"
360 "1:\n"
361 EX_TABLE(0b,1b)
362 : "=d" (rc) : "0" (-EOPNOTSUPP) : "cc");
363 if (!rc)
364 machine_flags |= MACHINE_FLAG_DIAG44;
365#endif
366}
367
368static __init void detect_machine_facilities(void)
369{
370#ifdef CONFIG_64BIT
371 unsigned int facilities;
372
373 facilities = stfl();
374 if (facilities & (1 << 28))
375 machine_flags |= MACHINE_FLAG_IDTE;
376 if (facilities & (1 << 23))
377 machine_flags |= MACHINE_FLAG_PFMF;
378 if (facilities & (1 << 4))
379 machine_flags |= MACHINE_FLAG_MVCOS;
380#endif
381}
382
271/* 383/*
272 * Save ipl parameters, clear bss memory, initialize storage keys 384 * Save ipl parameters, clear bss memory, initialize storage keys
273 * and create a kernel NSS at startup if the SAVESYS= parm is defined 385 * and create a kernel NSS at startup if the SAVESYS= parm is defined
@@ -285,6 +397,13 @@ void __init startup_init(void)
285 create_kernel_nss(); 397 create_kernel_nss();
286 sort_main_extable(); 398 sort_main_extable();
287 setup_lowcore_early(); 399 setup_lowcore_early();
400 detect_mvpg();
401 detect_ieee();
402 detect_csp();
403 detect_diag9c();
404 detect_diag44();
405 detect_machine_facilities();
406 setup_hpage();
288 sclp_read_info_early(); 407 sclp_read_info_early();
289 sclp_facilities_detect(); 408 sclp_facilities_detect();
290 memsize = sclp_memory_detect(); 409 memsize = sclp_memory_detect();
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index 6766e37fe8ea..bdbb3bcd78a5 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -49,9 +49,9 @@ SP_ILC = STACK_FRAME_OVERHEAD + __PT_ILC
49SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP 49SP_TRAP = STACK_FRAME_OVERHEAD + __PT_TRAP
50SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE 50SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
51 51
52_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \ 52_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 53 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
54_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \ 54_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
55 _TIF_MCCK_PENDING) 55 _TIF_MCCK_PENDING)
56 56
57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 57STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
@@ -316,7 +316,7 @@ sysc_work:
316 bo BASED(sysc_mcck_pending) 316 bo BASED(sysc_mcck_pending)
317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
318 bo BASED(sysc_reschedule) 318 bo BASED(sysc_reschedule)
319 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK) 319 tm __TI_flags+3(%r9),_TIF_SIGPENDING
320 bnz BASED(sysc_sigpending) 320 bnz BASED(sysc_sigpending)
321 tm __TI_flags+3(%r9),_TIF_RESTART_SVC 321 tm __TI_flags+3(%r9),_TIF_RESTART_SVC
322 bo BASED(sysc_restart) 322 bo BASED(sysc_restart)
@@ -342,7 +342,7 @@ sysc_mcck_pending:
342 br %r1 # TIF bit will be cleared by handler 342 br %r1 # TIF bit will be cleared by handler
343 343
344# 344#
345# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal 345# _TIF_SIGPENDING is set, call do_signal
346# 346#
347sysc_sigpending: 347sysc_sigpending:
348 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP 348 ni __TI_flags+3(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
@@ -657,7 +657,7 @@ io_work:
657 lr %r15,%r1 657 lr %r15,%r1
658# 658#
659# One of the work bits is on. Find out which one. 659# One of the work bits is on. Find out which one.
660# Checked are: _TIF_SIGPENDING, _TIF_RESTORE_SIGMASK, _TIF_NEED_RESCHED 660# Checked are: _TIF_SIGPENDING, _TIF_NEED_RESCHED
661# and _TIF_MCCK_PENDING 661# and _TIF_MCCK_PENDING
662# 662#
663io_work_loop: 663io_work_loop:
@@ -665,7 +665,7 @@ io_work_loop:
665 bo BASED(io_mcck_pending) 665 bo BASED(io_mcck_pending)
666 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 666 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
667 bo BASED(io_reschedule) 667 bo BASED(io_reschedule)
668 tm __TI_flags+3(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK) 668 tm __TI_flags+3(%r9),_TIF_SIGPENDING
669 bnz BASED(io_sigpending) 669 bnz BASED(io_sigpending)
670 b BASED(io_restore) 670 b BASED(io_restore)
671io_work_done: 671io_work_done:
@@ -693,7 +693,7 @@ io_reschedule:
693 b BASED(io_work_loop) 693 b BASED(io_work_loop)
694 694
695# 695#
696# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal 696# _TIF_SIGPENDING is set, call do_signal
697# 697#
698io_sigpending: 698io_sigpending:
699 TRACE_IRQS_ON 699 TRACE_IRQS_ON
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index cd959c0b2e16..5a4a7bcd2bba 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -52,9 +52,9 @@ SP_SIZE = STACK_FRAME_OVERHEAD + __PT_SIZE
52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 52STACK_SHIFT = PAGE_SHIFT + THREAD_ORDER
53STACK_SIZE = 1 << STACK_SHIFT 53STACK_SIZE = 1 << STACK_SHIFT
54 54
55_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \ 55_TIF_WORK_SVC = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP ) 56 _TIF_MCCK_PENDING | _TIF_RESTART_SVC | _TIF_SINGLE_STEP )
57_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | _TIF_NEED_RESCHED | \ 57_TIF_WORK_INT = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
58 _TIF_MCCK_PENDING) 58 _TIF_MCCK_PENDING)
59 59
60#define BASED(name) name-system_call(%r13) 60#define BASED(name) name-system_call(%r13)
@@ -308,7 +308,7 @@ sysc_work:
308 jo sysc_mcck_pending 308 jo sysc_mcck_pending
309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
310 jo sysc_reschedule 310 jo sysc_reschedule
311 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK) 311 tm __TI_flags+7(%r9),_TIF_SIGPENDING
312 jnz sysc_sigpending 312 jnz sysc_sigpending
313 tm __TI_flags+7(%r9),_TIF_RESTART_SVC 313 tm __TI_flags+7(%r9),_TIF_RESTART_SVC
314 jo sysc_restart 314 jo sysc_restart
@@ -332,7 +332,7 @@ sysc_mcck_pending:
332 jg s390_handle_mcck # TIF bit will be cleared by handler 332 jg s390_handle_mcck # TIF bit will be cleared by handler
333 333
334# 334#
335# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal 335# _TIF_SIGPENDING is set, call do_signal
336# 336#
337sysc_sigpending: 337sysc_sigpending:
338 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP 338 ni __TI_flags+7(%r9),255-_TIF_SINGLE_STEP # clear TIF_SINGLE_STEP
@@ -648,7 +648,7 @@ io_work_loop:
648 jo io_mcck_pending 648 jo io_mcck_pending
649 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 649 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
650 jo io_reschedule 650 jo io_reschedule
651 tm __TI_flags+7(%r9),(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK) 651 tm __TI_flags+7(%r9),_TIF_SIGPENDING
652 jnz io_sigpending 652 jnz io_sigpending
653 j io_restore 653 j io_restore
654io_work_done: 654io_work_done:
@@ -674,7 +674,7 @@ io_reschedule:
674 j io_work_loop 674 j io_work_loop
675 675
676# 676#
677# _TIF_SIGPENDING or _TIF_RESTORE_SIGMASK is set, call do_signal 677# _TIF_SIGPENDING or is set, call do_signal
678# 678#
679io_sigpending: 679io_sigpending:
680 TRACE_IRQS_ON 680 TRACE_IRQS_ON
diff --git a/arch/s390/kernel/head31.S b/arch/s390/kernel/head31.S
index dc364c1419af..a816e2de32b9 100644
--- a/arch/s390/kernel/head31.S
+++ b/arch/s390/kernel/head31.S
@@ -57,61 +57,6 @@ startup_continue:
57# 57#
58 l %r14,.Lstartup_init-.LPG1(%r13) 58 l %r14,.Lstartup_init-.LPG1(%r13)
59 basr %r14,%r14 59 basr %r14,%r14
60
61 l %r12,.Lmflags-.LPG1(%r13) # get address of machine_flags
62#
63# find out if we have an IEEE fpu
64#
65 mvc __LC_PGM_NEW_PSW(8),.Lpcfpu-.LPG1(%r13)
66 efpc %r0,0 # test IEEE extract fpc instruction
67 oi 3(%r12),2 # set IEEE fpu flag
68.Lchkfpu:
69
70#
71# find out if we have the CSP instruction
72#
73 mvc __LC_PGM_NEW_PSW(8),.Lpccsp-.LPG1(%r13)
74 la %r0,0
75 lr %r1,%r0
76 la %r2,4
77 csp %r0,%r2 # Test CSP instruction
78 oi 3(%r12),8 # set CSP flag
79.Lchkcsp:
80
81#
82# find out if we have the MVPG instruction
83#
84 mvc __LC_PGM_NEW_PSW(8),.Lpcmvpg-.LPG1(%r13)
85 sr %r0,%r0
86 la %r1,0
87 la %r2,0
88 mvpg %r1,%r2 # Test CSP instruction
89 oi 3(%r12),16 # set MVPG flag
90.Lchkmvpg:
91
92#
93# find out if we have the IDTE instruction
94#
95 mvc __LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
96 .long 0xb2b10000 # store facility list
97 tm 0xc8,0x08 # check bit for clearing-by-ASCE
98 bno .Lchkidte-.LPG1(%r13)
99 lhi %r1,2094
100 lhi %r2,0
101 .long 0xb98e2001
102 oi 3(%r12),0x80 # set IDTE flag
103.Lchkidte:
104
105#
106# find out if the diag 0x9c is available
107#
108 mvc __LC_PGM_NEW_PSW(8),.Lpcdiag9c-.LPG1(%r13)
109 stap __LC_CPUID+4 # store cpu address
110 lh %r1,__LC_CPUID+4
111 diag %r1,0,0x9c # test diag 0x9c
112 oi 2(%r12),1 # set diag9c flag
113.Lchkdiag9c:
114
115 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space, 60 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
116 # virtual and never return ... 61 # virtual and never return ...
117 .align 8 62 .align 8
@@ -132,13 +77,7 @@ startup_continue:
132 .long 0 # cr13: home space segment table 77 .long 0 # cr13: home space segment table
133 .long 0xc0000000 # cr14: machine check handling off 78 .long 0xc0000000 # cr14: machine check handling off
134 .long 0 # cr15: linkage stack operations 79 .long 0 # cr15: linkage stack operations
135.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
136.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
137.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
138.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
139.Lpcdiag9c:.long 0x00080000,0x80000000 + .Lchkdiag9c
140.Lmchunk:.long memory_chunk 80.Lmchunk:.long memory_chunk
141.Lmflags:.long machine_flags
142.Lbss_bgn: .long __bss_start 81.Lbss_bgn: .long __bss_start
143.Lbss_end: .long _end 82.Lbss_end: .long _end
144.Lparmaddr: .long PARMAREA 83.Lparmaddr: .long PARMAREA
diff --git a/arch/s390/kernel/head64.S b/arch/s390/kernel/head64.S
index 79dccd206a6e..1d06961e87b3 100644
--- a/arch/s390/kernel/head64.S
+++ b/arch/s390/kernel/head64.S
@@ -125,73 +125,11 @@ startup_continue:
125# and create a kernel NSS if the SAVESYS= parm is defined 125# and create a kernel NSS if the SAVESYS= parm is defined
126# 126#
127 brasl %r14,startup_init 127 brasl %r14,startup_init
128 # set program check new psw mask
129 mvc __LC_PGM_NEW_PSW(8),.Lpcmsk-.LPG1(%r13)
130 larl %r12,machine_flags
131#
132# find out if we have the MVPG instruction
133#
134 la %r1,0f-.LPG1(%r13) # set program check address
135 stg %r1,__LC_PGM_NEW_PSW+8
136 sgr %r0,%r0
137 lghi %r1,0
138 lghi %r2,0
139 mvpg %r1,%r2 # test MVPG instruction
140 oi 7(%r12),16 # set MVPG flag
1410:
142
143#
144# find out if the diag 0x44 works in 64 bit mode
145#
146 la %r1,0f-.LPG1(%r13) # set program check address
147 stg %r1,__LC_PGM_NEW_PSW+8
148 diag 0,0,0x44 # test diag 0x44
149 oi 7(%r12),32 # set diag44 flag
1500:
151
152#
153# find out if we have the IDTE instruction
154#
155 la %r1,0f-.LPG1(%r13) # set program check address
156 stg %r1,__LC_PGM_NEW_PSW+8
157 .long 0xb2b10000 # store facility list
158 tm 0xc8,0x08 # check bit for clearing-by-ASCE
159 bno 0f-.LPG1(%r13)
160 lhi %r1,2048
161 lhi %r2,0
162 .long 0xb98e2001
163 oi 7(%r12),0x80 # set IDTE flag
1640:
165
166#
167# find out if the diag 0x9c is available
168#
169 la %r1,0f-.LPG1(%r13) # set program check address
170 stg %r1,__LC_PGM_NEW_PSW+8
171 stap __LC_CPUID+4 # store cpu address
172 lh %r1,__LC_CPUID+4
173 diag %r1,0,0x9c # test diag 0x9c
174 oi 6(%r12),1 # set diag9c flag
1750:
176
177#
178# find out if we have the MVCOS instruction
179#
180 la %r1,0f-.LPG1(%r13) # set program check address
181 stg %r1,__LC_PGM_NEW_PSW+8
182 .short 0xc800 # mvcos 0(%r0),0(%r0),%r0
183 .short 0x0000
184 .short 0x0000
1850: tm 0x8f,0x13 # special-operation exception?
186 bno 1f-.LPG1(%r13) # if yes, MVCOS is present
187 oi 6(%r12),2 # set MVCOS flag
1881:
189
190 lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space, 128 lpswe .Lentry-.LPG1(13) # jump to _stext in primary-space,
191 # virtual and never return ... 129 # virtual and never return ...
192 .align 16 130 .align 16
193.Lentry:.quad 0x0000000180000000,_stext 131.Lentry:.quad 0x0000000180000000,_stext
194.Lctl: .quad 0x04b50002 # cr0: various things 132.Lctl: .quad 0x04350002 # cr0: various things
195 .quad 0 # cr1: primary space segment table 133 .quad 0 # cr1: primary space segment table
196 .quad .Lduct # cr2: dispatchable unit control table 134 .quad .Lduct # cr2: dispatchable unit control table
197 .quad 0 # cr3: instruction authorization 135 .quad 0 # cr3: instruction authorization
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index c1aff194141d..7920861109d2 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -180,24 +180,6 @@ void cpu_idle(void)
180 } 180 }
181} 181}
182 182
183void show_regs(struct pt_regs *regs)
184{
185 print_modules();
186 printk("CPU: %d %s %s %.*s\n",
187 task_thread_info(current)->cpu, print_tainted(),
188 init_utsname()->release,
189 (int)strcspn(init_utsname()->version, " "),
190 init_utsname()->version);
191 printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
192 current->comm, current->pid, current,
193 (void *) current->thread.ksp);
194 show_registers(regs);
195 /* Show stack backtrace if pt_regs is from kernel mode */
196 if (!(regs->psw.mask & PSW_MASK_PSTATE))
197 show_trace(NULL, (unsigned long *) regs->gprs[15]);
198 show_last_breaking_event(regs);
199}
200
201extern void kernel_thread_starter(void); 183extern void kernel_thread_starter(void);
202 184
203asm( 185asm(
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 58a064296987..7f4270163744 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -607,38 +607,8 @@ do_ptrace_emu31(struct task_struct *child, long request, long addr, long data)
607} 607}
608#endif 608#endif
609 609
610#define PT32_IEEE_IP 0x13c 610long arch_ptrace(struct task_struct *child, long request, long addr, long data)
611
612static int
613do_ptrace(struct task_struct *child, long request, long addr, long data)
614{ 611{
615 int ret;
616
617 if (request == PTRACE_ATTACH)
618 return ptrace_attach(child);
619
620 /*
621 * Special cases to get/store the ieee instructions pointer.
622 */
623 if (child == current) {
624 if (request == PTRACE_PEEKUSR && addr == PT_IEEE_IP)
625 return peek_user(child, addr, data);
626 if (request == PTRACE_POKEUSR && addr == PT_IEEE_IP)
627 return poke_user(child, addr, data);
628#ifdef CONFIG_COMPAT
629 if (request == PTRACE_PEEKUSR &&
630 addr == PT32_IEEE_IP && test_thread_flag(TIF_31BIT))
631 return peek_user_emu31(child, addr, data);
632 if (request == PTRACE_POKEUSR &&
633 addr == PT32_IEEE_IP && test_thread_flag(TIF_31BIT))
634 return poke_user_emu31(child, addr, data);
635#endif
636 }
637
638 ret = ptrace_check_attach(child, request == PTRACE_KILL);
639 if (ret < 0)
640 return ret;
641
642 switch (request) { 612 switch (request) {
643 case PTRACE_SYSCALL: 613 case PTRACE_SYSCALL:
644 /* continue and stop at next (return from) syscall */ 614 /* continue and stop at next (return from) syscall */
@@ -693,31 +663,6 @@ do_ptrace(struct task_struct *child, long request, long addr, long data)
693 return -EIO; 663 return -EIO;
694} 664}
695 665
696asmlinkage long
697sys_ptrace(long request, long pid, long addr, long data)
698{
699 struct task_struct *child;
700 int ret;
701
702 lock_kernel();
703 if (request == PTRACE_TRACEME) {
704 ret = ptrace_traceme();
705 goto out;
706 }
707
708 child = ptrace_get_task_struct(pid);
709 if (IS_ERR(child)) {
710 ret = PTR_ERR(child);
711 goto out;
712 }
713
714 ret = do_ptrace(child, request, addr, data);
715 put_task_struct(child);
716out:
717 unlock_kernel();
718 return ret;
719}
720
721asmlinkage void 666asmlinkage void
722syscall_trace(struct pt_regs *regs, int entryexit) 667syscall_trace(struct pt_regs *regs, int entryexit)
723{ 668{
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index a9d18aafa5f4..2bc70b6e876a 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL(uaccess);
73unsigned int console_mode = 0; 73unsigned int console_mode = 0;
74unsigned int console_devno = -1; 74unsigned int console_devno = -1;
75unsigned int console_irq = -1; 75unsigned int console_irq = -1;
76unsigned long machine_flags = 0; 76unsigned long machine_flags;
77unsigned long elf_hwcap = 0; 77unsigned long elf_hwcap = 0;
78char elf_platform[ELF_PLATFORM_SIZE]; 78char elf_platform[ELF_PLATFORM_SIZE];
79 79
@@ -683,15 +683,6 @@ setup_memory(void)
683#endif 683#endif
684} 684}
685 685
686static __init unsigned int stfl(void)
687{
688 asm volatile(
689 " .insn s,0xb2b10000,0(0)\n" /* stfl */
690 "0:\n"
691 EX_TABLE(0b,0b));
692 return S390_lowcore.stfl_fac_list;
693}
694
695static int __init __stfle(unsigned long long *list, int doublewords) 686static int __init __stfle(unsigned long long *list, int doublewords)
696{ 687{
697 typedef struct { unsigned long long _[doublewords]; } addrtype; 688 typedef struct { unsigned long long _[doublewords]; } addrtype;
@@ -758,6 +749,9 @@ static void __init setup_hwcaps(void)
758 elf_hwcap |= 1UL << 6; 749 elf_hwcap |= 1UL << 6;
759 } 750 }
760 751
752 if (MACHINE_HAS_HPAGE)
753 elf_hwcap |= 1UL << 7;
754
761 switch (cpuinfo->cpu_id.machine) { 755 switch (cpuinfo->cpu_id.machine) {
762 case 0x9672: 756 case 0x9672:
763#if !defined(CONFIG_64BIT) 757#if !defined(CONFIG_64BIT)
@@ -881,8 +875,9 @@ void __cpuinit print_cpu_info(struct cpuinfo_S390 *cpuinfo)
881 875
882static int show_cpuinfo(struct seq_file *m, void *v) 876static int show_cpuinfo(struct seq_file *m, void *v)
883{ 877{
884 static const char *hwcap_str[7] = { 878 static const char *hwcap_str[8] = {
885 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp" 879 "esan3", "zarch", "stfle", "msa", "ldisp", "eimm", "dfp",
880 "edat"
886 }; 881 };
887 struct cpuinfo_S390 *cpuinfo; 882 struct cpuinfo_S390 *cpuinfo;
888 unsigned long n = (unsigned long) v - 1; 883 unsigned long n = (unsigned long) v - 1;
@@ -897,7 +892,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
897 num_online_cpus(), loops_per_jiffy/(500000/HZ), 892 num_online_cpus(), loops_per_jiffy/(500000/HZ),
898 (loops_per_jiffy/(5000/HZ))%100); 893 (loops_per_jiffy/(5000/HZ))%100);
899 seq_puts(m, "features\t: "); 894 seq_puts(m, "features\t: ");
900 for (i = 0; i < 7; i++) 895 for (i = 0; i < 8; i++)
901 if (hwcap_str[i] && (elf_hwcap & (1UL << i))) 896 if (hwcap_str[i] && (elf_hwcap & (1UL << i)))
902 seq_printf(m, "%s ", hwcap_str[i]); 897 seq_printf(m, "%s ", hwcap_str[i]);
903 seq_puts(m, "\n"); 898 seq_puts(m, "\n");
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 0dfa988c1b26..0aeb290060d9 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -505,7 +505,7 @@ out:
505 return rc; 505 return rc;
506} 506}
507 507
508static int smp_rescan_cpus(void) 508static int __smp_rescan_cpus(void)
509{ 509{
510 cpumask_t avail; 510 cpumask_t avail;
511 511
@@ -570,7 +570,7 @@ out:
570 kfree(info); 570 kfree(info);
571 printk(KERN_INFO "CPUs: %d configured, %d standby\n", c_cpus, s_cpus); 571 printk(KERN_INFO "CPUs: %d configured, %d standby\n", c_cpus, s_cpus);
572 get_online_cpus(); 572 get_online_cpus();
573 smp_rescan_cpus(); 573 __smp_rescan_cpus();
574 put_online_cpus(); 574 put_online_cpus();
575} 575}
576 576
@@ -890,8 +890,8 @@ static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
890 if (val != 0 && val != 1) 890 if (val != 0 && val != 1)
891 return -EINVAL; 891 return -EINVAL;
892 892
893 mutex_lock(&smp_cpu_state_mutex);
894 get_online_cpus(); 893 get_online_cpus();
894 mutex_lock(&smp_cpu_state_mutex);
895 rc = -EBUSY; 895 rc = -EBUSY;
896 if (cpu_online(cpu)) 896 if (cpu_online(cpu))
897 goto out; 897 goto out;
@@ -919,8 +919,8 @@ static ssize_t cpu_configure_store(struct sys_device *dev, const char *buf,
919 break; 919 break;
920 } 920 }
921out: 921out:
922 put_online_cpus();
923 mutex_unlock(&smp_cpu_state_mutex); 922 mutex_unlock(&smp_cpu_state_mutex);
923 put_online_cpus();
924 return rc ? rc : count; 924 return rc ? rc : count;
925} 925}
926static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store); 926static SYSDEV_ATTR(configure, 0644, cpu_configure_show, cpu_configure_store);
@@ -1088,17 +1088,17 @@ out:
1088} 1088}
1089 1089
1090#ifdef CONFIG_HOTPLUG_CPU 1090#ifdef CONFIG_HOTPLUG_CPU
1091static ssize_t __ref rescan_store(struct sys_device *dev, 1091
1092 const char *buf, size_t count) 1092int smp_rescan_cpus(void)
1093{ 1093{
1094 cpumask_t newcpus; 1094 cpumask_t newcpus;
1095 int cpu; 1095 int cpu;
1096 int rc; 1096 int rc;
1097 1097
1098 mutex_lock(&smp_cpu_state_mutex);
1099 get_online_cpus(); 1098 get_online_cpus();
1099 mutex_lock(&smp_cpu_state_mutex);
1100 newcpus = cpu_present_map; 1100 newcpus = cpu_present_map;
1101 rc = smp_rescan_cpus(); 1101 rc = __smp_rescan_cpus();
1102 if (rc) 1102 if (rc)
1103 goto out; 1103 goto out;
1104 cpus_andnot(newcpus, cpu_present_map, newcpus); 1104 cpus_andnot(newcpus, cpu_present_map, newcpus);
@@ -1109,10 +1109,19 @@ static ssize_t __ref rescan_store(struct sys_device *dev,
1109 } 1109 }
1110 rc = 0; 1110 rc = 0;
1111out: 1111out:
1112 put_online_cpus();
1113 mutex_unlock(&smp_cpu_state_mutex); 1112 mutex_unlock(&smp_cpu_state_mutex);
1113 put_online_cpus();
1114 if (!cpus_empty(newcpus)) 1114 if (!cpus_empty(newcpus))
1115 topology_schedule_update(); 1115 topology_schedule_update();
1116 return rc;
1117}
1118
1119static ssize_t __ref rescan_store(struct sys_device *dev, const char *buf,
1120 size_t count)
1121{
1122 int rc;
1123
1124 rc = smp_rescan_cpus();
1116 return rc ? rc : count; 1125 return rc ? rc : count;
1117} 1126}
1118static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store); 1127static SYSDEV_ATTR(rescan, 0200, NULL, rescan_store);
@@ -1139,16 +1148,16 @@ static ssize_t dispatching_store(struct sys_device *dev, const char *buf,
1139 if (val != 0 && val != 1) 1148 if (val != 0 && val != 1)
1140 return -EINVAL; 1149 return -EINVAL;
1141 rc = 0; 1150 rc = 0;
1142 mutex_lock(&smp_cpu_state_mutex);
1143 get_online_cpus(); 1151 get_online_cpus();
1152 mutex_lock(&smp_cpu_state_mutex);
1144 if (cpu_management == val) 1153 if (cpu_management == val)
1145 goto out; 1154 goto out;
1146 rc = topology_set_cpu_management(val); 1155 rc = topology_set_cpu_management(val);
1147 if (!rc) 1156 if (!rc)
1148 cpu_management = val; 1157 cpu_management = val;
1149out: 1158out:
1150 put_online_cpus();
1151 mutex_unlock(&smp_cpu_state_mutex); 1159 mutex_unlock(&smp_cpu_state_mutex);
1160 put_online_cpus();
1152 return rc ? rc : count; 1161 return rc ? rc : count;
1153} 1162}
1154static SYSDEV_ATTR(dispatching, 0644, dispatching_show, dispatching_store); 1163static SYSDEV_ATTR(dispatching, 0644, dispatching_show, dispatching_store);
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 12b39b3d9c38..661a07217057 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -9,6 +9,7 @@
9#include <linux/device.h> 9#include <linux/device.h>
10#include <linux/bootmem.h> 10#include <linux/bootmem.h>
11#include <linux/sched.h> 11#include <linux/sched.h>
12#include <linux/kthread.h>
12#include <linux/workqueue.h> 13#include <linux/workqueue.h>
13#include <linux/cpu.h> 14#include <linux/cpu.h>
14#include <linux/smp.h> 15#include <linux/smp.h>
@@ -66,6 +67,8 @@ static struct timer_list topology_timer;
66static void set_topology_timer(void); 67static void set_topology_timer(void);
67static DECLARE_WORK(topology_work, topology_work_fn); 68static DECLARE_WORK(topology_work, topology_work_fn);
68 69
70cpumask_t cpu_core_map[NR_CPUS];
71
69cpumask_t cpu_coregroup_map(unsigned int cpu) 72cpumask_t cpu_coregroup_map(unsigned int cpu)
70{ 73{
71 struct core_info *core = &core_info; 74 struct core_info *core = &core_info;
@@ -199,6 +202,14 @@ int topology_set_cpu_management(int fc)
199 return rc; 202 return rc;
200} 203}
201 204
205static void update_cpu_core_map(void)
206{
207 int cpu;
208
209 for_each_present_cpu(cpu)
210 cpu_core_map[cpu] = cpu_coregroup_map(cpu);
211}
212
202void arch_update_cpu_topology(void) 213void arch_update_cpu_topology(void)
203{ 214{
204 struct tl_info *info = tl_info; 215 struct tl_info *info = tl_info;
@@ -206,20 +217,33 @@ void arch_update_cpu_topology(void)
206 int cpu; 217 int cpu;
207 218
208 if (!machine_has_topology) { 219 if (!machine_has_topology) {
220 update_cpu_core_map();
209 topology_update_polarization_simple(); 221 topology_update_polarization_simple();
210 return; 222 return;
211 } 223 }
212 stsi(info, 15, 1, 2); 224 stsi(info, 15, 1, 2);
213 tl_to_cores(info); 225 tl_to_cores(info);
226 update_cpu_core_map();
214 for_each_online_cpu(cpu) { 227 for_each_online_cpu(cpu) {
215 sysdev = get_cpu_sysdev(cpu); 228 sysdev = get_cpu_sysdev(cpu);
216 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE); 229 kobject_uevent(&sysdev->kobj, KOBJ_CHANGE);
217 } 230 }
218} 231}
219 232
220static void topology_work_fn(struct work_struct *work) 233static int topology_kthread(void *data)
221{ 234{
222 arch_reinit_sched_domains(); 235 arch_reinit_sched_domains();
236 return 0;
237}
238
239static void topology_work_fn(struct work_struct *work)
240{
241 /* We can't call arch_reinit_sched_domains() from a multi-threaded
242 * workqueue context since it may deadlock in case of cpu hotplug.
243 * So we have to create a kernel thread in order to call
244 * arch_reinit_sched_domains().
245 */
246 kthread_run(topology_kthread, NULL, "topology_update");
223} 247}
224 248
225void topology_schedule_update(void) 249void topology_schedule_update(void)
@@ -251,20 +275,23 @@ static int __init init_topology_update(void)
251{ 275{
252 int rc; 276 int rc;
253 277
278 rc = 0;
254 if (!machine_has_topology) { 279 if (!machine_has_topology) {
255 topology_update_polarization_simple(); 280 topology_update_polarization_simple();
256 return 0; 281 goto out;
257 } 282 }
258 init_timer_deferrable(&topology_timer); 283 init_timer_deferrable(&topology_timer);
259 if (machine_has_topology_irq) { 284 if (machine_has_topology_irq) {
260 rc = register_external_interrupt(0x2005, topology_interrupt); 285 rc = register_external_interrupt(0x2005, topology_interrupt);
261 if (rc) 286 if (rc)
262 return rc; 287 goto out;
263 ctl_set_bit(0, 8); 288 ctl_set_bit(0, 8);
264 } 289 }
265 else 290 else
266 set_topology_timer(); 291 set_topology_timer();
267 return 0; 292out:
293 update_cpu_core_map();
294 return rc;
268} 295}
269__initcall(init_topology_update); 296__initcall(init_topology_update);
270 297
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c
index 57b607b61100..4584d81984c0 100644
--- a/arch/s390/kernel/traps.c
+++ b/arch/s390/kernel/traps.c
@@ -113,7 +113,7 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high)
113 } 113 }
114} 114}
115 115
116void show_trace(struct task_struct *task, unsigned long *stack) 116static void show_trace(struct task_struct *task, unsigned long *stack)
117{ 117{
118 register unsigned long __r15 asm ("15"); 118 register unsigned long __r15 asm ("15");
119 unsigned long sp; 119 unsigned long sp;
@@ -161,14 +161,14 @@ void show_stack(struct task_struct *task, unsigned long *sp)
161 show_trace(task, sp); 161 show_trace(task, sp);
162} 162}
163 163
164#ifdef CONFIG_64BIT 164static void show_last_breaking_event(struct pt_regs *regs)
165void show_last_breaking_event(struct pt_regs *regs)
166{ 165{
166#ifdef CONFIG_64BIT
167 printk("Last Breaking-Event-Address:\n"); 167 printk("Last Breaking-Event-Address:\n");
168 printk(" [<%016lx>] ", regs->args[0] & PSW_ADDR_INSN); 168 printk(" [<%016lx>] ", regs->args[0] & PSW_ADDR_INSN);
169 print_symbol("%s\n", regs->args[0] & PSW_ADDR_INSN); 169 print_symbol("%s\n", regs->args[0] & PSW_ADDR_INSN);
170}
171#endif 170#endif
171}
172 172
173/* 173/*
174 * The architecture-independent dump_stack generator 174 * The architecture-independent dump_stack generator
@@ -223,6 +223,24 @@ void show_registers(struct pt_regs *regs)
223 show_code(regs); 223 show_code(regs);
224} 224}
225 225
226void show_regs(struct pt_regs *regs)
227{
228 print_modules();
229 printk("CPU: %d %s %s %.*s\n",
230 task_thread_info(current)->cpu, print_tainted(),
231 init_utsname()->release,
232 (int)strcspn(init_utsname()->version, " "),
233 init_utsname()->version);
234 printk("Process %s (pid: %d, task: %p, ksp: %p)\n",
235 current->comm, current->pid, current,
236 (void *) current->thread.ksp);
237 show_registers(regs);
238 /* Show stack backtrace if pt_regs is from kernel mode */
239 if (!(regs->psw.mask & PSW_MASK_PSTATE))
240 show_trace(NULL, (unsigned long *) regs->gprs[15]);
241 show_last_breaking_event(regs);
242}
243
226/* This is called from fs/proc/array.c */ 244/* This is called from fs/proc/array.c */
227void task_show_regs(struct seq_file *m, struct task_struct *task) 245void task_show_regs(struct seq_file *m, struct task_struct *task)
228{ 246{
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 1465946325c5..c02286c6a931 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -151,18 +151,9 @@ static int handle_chsc(struct kvm_vcpu *vcpu)
151 return 0; 151 return 0;
152} 152}
153 153
154static unsigned int kvm_stfl(void)
155{
156 asm volatile(
157 " .insn s,0xb2b10000,0(0)\n" /* stfl */
158 "0:\n"
159 EX_TABLE(0b, 0b));
160 return S390_lowcore.stfl_fac_list;
161}
162
163static int handle_stfl(struct kvm_vcpu *vcpu) 154static int handle_stfl(struct kvm_vcpu *vcpu)
164{ 155{
165 unsigned int facility_list = kvm_stfl(); 156 unsigned int facility_list = stfl();
166 int rc; 157 int rc;
167 158
168 vcpu->stat.instruction_stfl++; 159 vcpu->stat.instruction_stfl++;
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
index 52084436ab69..ab6735df2d21 100644
--- a/arch/s390/lib/Makefile
+++ b/arch/s390/lib/Makefile
@@ -2,8 +2,6 @@
2# Makefile for s390-specific library files.. 2# Makefile for s390-specific library files..
3# 3#
4 4
5EXTRA_AFLAGS := -traditional
6
7lib-y += delay.o string.o uaccess_std.o uaccess_pt.o 5lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
8obj-$(CONFIG_32BIT) += div64.o qrnnd.o 6obj-$(CONFIG_32BIT) += div64.o qrnnd.o
9lib-$(CONFIG_64BIT) += uaccess_mvcos.o 7lib-$(CONFIG_64BIT) += uaccess_mvcos.o
diff --git a/arch/s390/lib/uaccess_mvcos.c b/arch/s390/lib/uaccess_mvcos.c
index 6d8772339d76..3f15aaf54855 100644
--- a/arch/s390/lib/uaccess_mvcos.c
+++ b/arch/s390/lib/uaccess_mvcos.c
@@ -162,6 +162,7 @@ static size_t clear_user_mvcos(size_t size, void __user *to)
162 return size; 162 return size;
163} 163}
164 164
165#ifdef CONFIG_S390_SWITCH_AMODE
165static size_t strnlen_user_mvcos(size_t count, const char __user *src) 166static size_t strnlen_user_mvcos(size_t count, const char __user *src)
166{ 167{
167 char buf[256]; 168 char buf[256];
@@ -199,6 +200,7 @@ static size_t strncpy_from_user_mvcos(size_t count, const char __user *src,
199 } while ((len_str == len) && (done < count)); 200 } while ((len_str == len) && (done < count));
200 return done; 201 return done;
201} 202}
203#endif /* CONFIG_S390_SWITCH_AMODE */
202 204
203struct uaccess_ops uaccess_mvcos = { 205struct uaccess_ops uaccess_mvcos = {
204 .copy_from_user = copy_from_user_mvcos_check, 206 .copy_from_user = copy_from_user_mvcos_check,
diff --git a/arch/s390/math-emu/Makefile b/arch/s390/math-emu/Makefile
index 73b3e72efc46..c84890341052 100644
--- a/arch/s390/math-emu/Makefile
+++ b/arch/s390/math-emu/Makefile
@@ -5,4 +5,3 @@
5obj-$(CONFIG_MATHEMU) := math.o 5obj-$(CONFIG_MATHEMU) := math.o
6 6
7EXTRA_CFLAGS := -I$(src) -Iinclude/math-emu -w 7EXTRA_CFLAGS := -I$(src) -Iinclude/math-emu -w
8EXTRA_AFLAGS := -traditional
diff --git a/arch/s390/mm/Makefile b/arch/s390/mm/Makefile
index 66401930f83e..fb988a48a754 100644
--- a/arch/s390/mm/Makefile
+++ b/arch/s390/mm/Makefile
@@ -4,4 +4,4 @@
4 4
5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o 5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o
6obj-$(CONFIG_CMM) += cmm.o 6obj-$(CONFIG_CMM) += cmm.o
7 7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
index ed2af0a3303b..f231f5ec74b6 100644
--- a/arch/s390/mm/extmem.c
+++ b/arch/s390/mm/extmem.c
@@ -287,7 +287,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
287 if (rc < 0) 287 if (rc < 0)
288 goto out_free; 288 goto out_free;
289 289
290 rc = add_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1); 290 rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
291 291
292 if (rc) 292 if (rc)
293 goto out_free; 293 goto out_free;
@@ -351,7 +351,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
351 release_resource(seg->res); 351 release_resource(seg->res);
352 kfree(seg->res); 352 kfree(seg->res);
353 out_shared: 353 out_shared:
354 remove_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1); 354 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
355 out_free: 355 out_free:
356 kfree(seg); 356 kfree(seg);
357 out: 357 out:
@@ -474,7 +474,7 @@ segment_modify_shared (char *name, int do_nonshared)
474 rc = 0; 474 rc = 0;
475 goto out_unlock; 475 goto out_unlock;
476 out_del: 476 out_del:
477 remove_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1); 477 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
478 list_del(&seg->list); 478 list_del(&seg->list);
479 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy); 479 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
480 kfree(seg); 480 kfree(seg);
@@ -508,7 +508,7 @@ segment_unload(char *name)
508 goto out_unlock; 508 goto out_unlock;
509 release_resource(seg->res); 509 release_resource(seg->res);
510 kfree(seg->res); 510 kfree(seg->res);
511 remove_shared_memory(seg->start_addr, seg->end - seg->start_addr + 1); 511 vmem_remove_mapping(seg->start_addr, seg->end - seg->start_addr + 1);
512 list_del(&seg->list); 512 list_del(&seg->list);
513 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy); 513 dcss_diag(DCSS_PURGESEG, seg->dcss_name, &dummy, &dummy);
514 kfree(seg); 514 kfree(seg);
diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index 2650f46001d0..4d537205e83c 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -28,6 +28,7 @@
28#include <linux/hardirq.h> 28#include <linux/hardirq.h>
29#include <linux/kprobes.h> 29#include <linux/kprobes.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/hugetlb.h>
31#include <asm/system.h> 32#include <asm/system.h>
32#include <asm/pgtable.h> 33#include <asm/pgtable.h>
33#include <asm/s390_ext.h> 34#include <asm/s390_ext.h>
@@ -367,6 +368,8 @@ good_area:
367 } 368 }
368 369
369survive: 370survive:
371 if (is_vm_hugetlb_page(vma))
372 address &= HPAGE_MASK;
370 /* 373 /*
371 * If for any reason at all we couldn't handle the fault, 374 * If for any reason at all we couldn't handle the fault,
372 * make sure we exit gracefully rather than endlessly redo 375 * make sure we exit gracefully rather than endlessly redo
diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c
new file mode 100644
index 000000000000..f4b6124fdb75
--- /dev/null
+++ b/arch/s390/mm/hugetlbpage.c
@@ -0,0 +1,134 @@
1/*
2 * IBM System z Huge TLB Page Support for Kernel.
3 *
4 * Copyright 2007 IBM Corp.
5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6 */
7
8#include <linux/mm.h>
9#include <linux/hugetlb.h>
10
11
12void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
13 pte_t *pteptr, pte_t pteval)
14{
15 pmd_t *pmdp = (pmd_t *) pteptr;
16 pte_t shadow_pteval = pteval;
17 unsigned long mask;
18
19 if (!MACHINE_HAS_HPAGE) {
20 pteptr = (pte_t *) pte_page(pteval)[1].index;
21 mask = pte_val(pteval) &
22 (_SEGMENT_ENTRY_INV | _SEGMENT_ENTRY_RO);
23 pte_val(pteval) = (_SEGMENT_ENTRY + __pa(pteptr)) | mask;
24 if (mm->context.noexec) {
25 pteptr += PTRS_PER_PTE;
26 pte_val(shadow_pteval) =
27 (_SEGMENT_ENTRY + __pa(pteptr)) | mask;
28 }
29 }
30
31 pmd_val(*pmdp) = pte_val(pteval);
32 if (mm->context.noexec) {
33 pmdp = get_shadow_table(pmdp);
34 pmd_val(*pmdp) = pte_val(shadow_pteval);
35 }
36}
37
38int arch_prepare_hugepage(struct page *page)
39{
40 unsigned long addr = page_to_phys(page);
41 pte_t pte;
42 pte_t *ptep;
43 int i;
44
45 if (MACHINE_HAS_HPAGE)
46 return 0;
47
48 ptep = (pte_t *) pte_alloc_one(&init_mm, address);
49 if (!ptep)
50 return -ENOMEM;
51
52 pte = mk_pte(page, PAGE_RW);
53 for (i = 0; i < PTRS_PER_PTE; i++) {
54 set_pte_at(&init_mm, addr + i * PAGE_SIZE, ptep + i, pte);
55 pte_val(pte) += PAGE_SIZE;
56 }
57 page[1].index = (unsigned long) ptep;
58 return 0;
59}
60
61void arch_release_hugepage(struct page *page)
62{
63 pte_t *ptep;
64
65 if (MACHINE_HAS_HPAGE)
66 return;
67
68 ptep = (pte_t *) page[1].index;
69 if (!ptep)
70 return;
71 pte_free(&init_mm, ptep);
72 page[1].index = 0;
73}
74
75pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
76{
77 pgd_t *pgdp;
78 pud_t *pudp;
79 pmd_t *pmdp = NULL;
80
81 pgdp = pgd_offset(mm, addr);
82 pudp = pud_alloc(mm, pgdp, addr);
83 if (pudp)
84 pmdp = pmd_alloc(mm, pudp, addr);
85 return (pte_t *) pmdp;
86}
87
88pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
89{
90 pgd_t *pgdp;
91 pud_t *pudp;
92 pmd_t *pmdp = NULL;
93
94 pgdp = pgd_offset(mm, addr);
95 if (pgd_present(*pgdp)) {
96 pudp = pud_offset(pgdp, addr);
97 if (pud_present(*pudp))
98 pmdp = pmd_offset(pudp, addr);
99 }
100 return (pte_t *) pmdp;
101}
102
103int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
104{
105 return 0;
106}
107
108struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
109 int write)
110{
111 return ERR_PTR(-EINVAL);
112}
113
114int pmd_huge(pmd_t pmd)
115{
116 if (!MACHINE_HAS_HPAGE)
117 return 0;
118
119 return !!(pmd_val(pmd) & _SEGMENT_ENTRY_LARGE);
120}
121
122struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
123 pmd_t *pmdp, int write)
124{
125 struct page *page;
126
127 if (!MACHINE_HAS_HPAGE)
128 return NULL;
129
130 page = pmd_page(*pmdp);
131 if (page)
132 page += ((address & ~HPAGE_MASK) >> PAGE_SHIFT);
133 return page;
134}
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 202c952a29b4..fa31de6ae97a 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -77,28 +77,6 @@ void show_mem(void)
77 printk("%lu pages pagetables\n", global_page_state(NR_PAGETABLE)); 77 printk("%lu pages pagetables\n", global_page_state(NR_PAGETABLE));
78} 78}
79 79
80static void __init setup_ro_region(void)
81{
82 pgd_t *pgd;
83 pud_t *pud;
84 pmd_t *pmd;
85 pte_t *pte;
86 pte_t new_pte;
87 unsigned long address, end;
88
89 address = ((unsigned long)&_stext) & PAGE_MASK;
90 end = PFN_ALIGN((unsigned long)&_eshared);
91
92 for (; address < end; address += PAGE_SIZE) {
93 pgd = pgd_offset_k(address);
94 pud = pud_offset(pgd, address);
95 pmd = pmd_offset(pud, address);
96 pte = pte_offset_kernel(pmd, address);
97 new_pte = mk_pte_phys(address, __pgprot(_PAGE_RO));
98 *pte = new_pte;
99 }
100}
101
102/* 80/*
103 * paging_init() sets up the page tables 81 * paging_init() sets up the page tables
104 */ 82 */
@@ -121,7 +99,6 @@ void __init paging_init(void)
121 clear_table((unsigned long *) init_mm.pgd, pgd_type, 99 clear_table((unsigned long *) init_mm.pgd, pgd_type,
122 sizeof(unsigned long)*2048); 100 sizeof(unsigned long)*2048);
123 vmem_map_init(); 101 vmem_map_init();
124 setup_ro_region();
125 102
126 /* enable virtual mapping in kernel mode */ 103 /* enable virtual mapping in kernel mode */
127 __ctl_load(S390_lowcore.kernel_asce, 1, 1); 104 __ctl_load(S390_lowcore.kernel_asce, 1, 1);
@@ -129,6 +106,8 @@ void __init paging_init(void)
129 __ctl_load(S390_lowcore.kernel_asce, 13, 13); 106 __ctl_load(S390_lowcore.kernel_asce, 13, 13);
130 __raw_local_irq_ssm(ssm_mask); 107 __raw_local_irq_ssm(ssm_mask);
131 108
109 sparse_memory_present_with_active_regions(MAX_NUMNODES);
110 sparse_init();
132 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 111 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
133#ifdef CONFIG_ZONE_DMA 112#ifdef CONFIG_ZONE_DMA
134 max_zone_pfns[ZONE_DMA] = PFN_DOWN(MAX_DMA_ADDRESS); 113 max_zone_pfns[ZONE_DMA] = PFN_DOWN(MAX_DMA_ADDRESS);
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index 35d90a4720fd..beccacf907f3 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -10,10 +10,12 @@
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/list.h> 12#include <linux/list.h>
13#include <linux/hugetlb.h>
13#include <asm/pgalloc.h> 14#include <asm/pgalloc.h>
14#include <asm/pgtable.h> 15#include <asm/pgtable.h>
15#include <asm/setup.h> 16#include <asm/setup.h>
16#include <asm/tlbflush.h> 17#include <asm/tlbflush.h>
18#include <asm/sections.h>
17 19
18static DEFINE_MUTEX(vmem_mutex); 20static DEFINE_MUTEX(vmem_mutex);
19 21
@@ -25,43 +27,6 @@ struct memory_segment {
25 27
26static LIST_HEAD(mem_segs); 28static LIST_HEAD(mem_segs);
27 29
28void __meminit memmap_init(unsigned long size, int nid, unsigned long zone,
29 unsigned long start_pfn)
30{
31 struct page *start, *end;
32 struct page *map_start, *map_end;
33 int i;
34
35 start = pfn_to_page(start_pfn);
36 end = start + size;
37
38 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
39 unsigned long cstart, cend;
40
41 cstart = PFN_DOWN(memory_chunk[i].addr);
42 cend = cstart + PFN_DOWN(memory_chunk[i].size);
43
44 map_start = mem_map + cstart;
45 map_end = mem_map + cend;
46
47 if (map_start < start)
48 map_start = start;
49 if (map_end > end)
50 map_end = end;
51
52 map_start -= ((unsigned long) map_start & (PAGE_SIZE - 1))
53 / sizeof(struct page);
54 map_end += ((PFN_ALIGN((unsigned long) map_end)
55 - (unsigned long) map_end)
56 / sizeof(struct page));
57
58 if (map_start < map_end)
59 memmap_init_zone((unsigned long)(map_end - map_start),
60 nid, zone, page_to_pfn(map_start),
61 MEMMAP_EARLY);
62 }
63}
64
65static void __ref *vmem_alloc_pages(unsigned int order) 30static void __ref *vmem_alloc_pages(unsigned int order)
66{ 31{
67 if (slab_is_available()) 32 if (slab_is_available())
@@ -77,8 +42,7 @@ static inline pud_t *vmem_pud_alloc(void)
77 pud = vmem_alloc_pages(2); 42 pud = vmem_alloc_pages(2);
78 if (!pud) 43 if (!pud)
79 return NULL; 44 return NULL;
80 pud_val(*pud) = _REGION3_ENTRY_EMPTY; 45 clear_table((unsigned long *) pud, _REGION3_ENTRY_EMPTY, PAGE_SIZE * 4);
81 memcpy(pud + 1, pud, (PTRS_PER_PUD - 1)*sizeof(pud_t));
82#endif 46#endif
83 return pud; 47 return pud;
84} 48}
@@ -91,7 +55,7 @@ static inline pmd_t *vmem_pmd_alloc(void)
91 pmd = vmem_alloc_pages(2); 55 pmd = vmem_alloc_pages(2);
92 if (!pmd) 56 if (!pmd)
93 return NULL; 57 return NULL;
94 clear_table((unsigned long *) pmd, _SEGMENT_ENTRY_EMPTY, PAGE_SIZE*4); 58 clear_table((unsigned long *) pmd, _SEGMENT_ENTRY_EMPTY, PAGE_SIZE * 4);
95#endif 59#endif
96 return pmd; 60 return pmd;
97} 61}
@@ -114,7 +78,7 @@ static pte_t __init_refok *vmem_pte_alloc(void)
114/* 78/*
115 * Add a physical memory range to the 1:1 mapping. 79 * Add a physical memory range to the 1:1 mapping.
116 */ 80 */
117static int vmem_add_range(unsigned long start, unsigned long size) 81static int vmem_add_mem(unsigned long start, unsigned long size, int ro)
118{ 82{
119 unsigned long address; 83 unsigned long address;
120 pgd_t *pg_dir; 84 pgd_t *pg_dir;
@@ -141,7 +105,19 @@ static int vmem_add_range(unsigned long start, unsigned long size)
141 pud_populate_kernel(&init_mm, pu_dir, pm_dir); 105 pud_populate_kernel(&init_mm, pu_dir, pm_dir);
142 } 106 }
143 107
108 pte = mk_pte_phys(address, __pgprot(ro ? _PAGE_RO : 0));
144 pm_dir = pmd_offset(pu_dir, address); 109 pm_dir = pmd_offset(pu_dir, address);
110
111#ifdef __s390x__
112 if (MACHINE_HAS_HPAGE && !(address & ~HPAGE_MASK) &&
113 (address + HPAGE_SIZE <= start + size) &&
114 (address >= HPAGE_SIZE)) {
115 pte_val(pte) |= _SEGMENT_ENTRY_LARGE;
116 pmd_val(*pm_dir) = pte_val(pte);
117 address += HPAGE_SIZE - PAGE_SIZE;
118 continue;
119 }
120#endif
145 if (pmd_none(*pm_dir)) { 121 if (pmd_none(*pm_dir)) {
146 pt_dir = vmem_pte_alloc(); 122 pt_dir = vmem_pte_alloc();
147 if (!pt_dir) 123 if (!pt_dir)
@@ -150,7 +126,6 @@ static int vmem_add_range(unsigned long start, unsigned long size)
150 } 126 }
151 127
152 pt_dir = pte_offset_kernel(pm_dir, address); 128 pt_dir = pte_offset_kernel(pm_dir, address);
153 pte = pfn_pte(address >> PAGE_SHIFT, PAGE_KERNEL);
154 *pt_dir = pte; 129 *pt_dir = pte;
155 } 130 }
156 ret = 0; 131 ret = 0;
@@ -181,6 +156,13 @@ static void vmem_remove_range(unsigned long start, unsigned long size)
181 pm_dir = pmd_offset(pu_dir, address); 156 pm_dir = pmd_offset(pu_dir, address);
182 if (pmd_none(*pm_dir)) 157 if (pmd_none(*pm_dir))
183 continue; 158 continue;
159
160 if (pmd_huge(*pm_dir)) {
161 pmd_clear_kernel(pm_dir);
162 address += HPAGE_SIZE - PAGE_SIZE;
163 continue;
164 }
165
184 pt_dir = pte_offset_kernel(pm_dir, address); 166 pt_dir = pte_offset_kernel(pm_dir, address);
185 *pt_dir = pte; 167 *pt_dir = pte;
186 } 168 }
@@ -190,10 +172,9 @@ static void vmem_remove_range(unsigned long start, unsigned long size)
190/* 172/*
191 * Add a backed mem_map array to the virtual mem_map array. 173 * Add a backed mem_map array to the virtual mem_map array.
192 */ 174 */
193static int vmem_add_mem_map(unsigned long start, unsigned long size) 175int __meminit vmemmap_populate(struct page *start, unsigned long nr, int node)
194{ 176{
195 unsigned long address, start_addr, end_addr; 177 unsigned long address, start_addr, end_addr;
196 struct page *map_start, *map_end;
197 pgd_t *pg_dir; 178 pgd_t *pg_dir;
198 pud_t *pu_dir; 179 pud_t *pu_dir;
199 pmd_t *pm_dir; 180 pmd_t *pm_dir;
@@ -201,11 +182,8 @@ static int vmem_add_mem_map(unsigned long start, unsigned long size)
201 pte_t pte; 182 pte_t pte;
202 int ret = -ENOMEM; 183 int ret = -ENOMEM;
203 184
204 map_start = VMEM_MAP + PFN_DOWN(start); 185 start_addr = (unsigned long) start;
205 map_end = VMEM_MAP + PFN_DOWN(start + size); 186 end_addr = (unsigned long) (start + nr);
206
207 start_addr = (unsigned long) map_start & PAGE_MASK;
208 end_addr = PFN_ALIGN((unsigned long) map_end);
209 187
210 for (address = start_addr; address < end_addr; address += PAGE_SIZE) { 188 for (address = start_addr; address < end_addr; address += PAGE_SIZE) {
211 pg_dir = pgd_offset_k(address); 189 pg_dir = pgd_offset_k(address);
@@ -249,16 +227,6 @@ out:
249 return ret; 227 return ret;
250} 228}
251 229
252static int vmem_add_mem(unsigned long start, unsigned long size)
253{
254 int ret;
255
256 ret = vmem_add_mem_map(start, size);
257 if (ret)
258 return ret;
259 return vmem_add_range(start, size);
260}
261
262/* 230/*
263 * Add memory segment to the segment list if it doesn't overlap with 231 * Add memory segment to the segment list if it doesn't overlap with
264 * an already present segment. 232 * an already present segment.
@@ -296,7 +264,7 @@ static void __remove_shared_memory(struct memory_segment *seg)
296 vmem_remove_range(seg->start, seg->size); 264 vmem_remove_range(seg->start, seg->size);
297} 265}
298 266
299int remove_shared_memory(unsigned long start, unsigned long size) 267int vmem_remove_mapping(unsigned long start, unsigned long size)
300{ 268{
301 struct memory_segment *seg; 269 struct memory_segment *seg;
302 int ret; 270 int ret;
@@ -320,11 +288,9 @@ out:
320 return ret; 288 return ret;
321} 289}
322 290
323int add_shared_memory(unsigned long start, unsigned long size) 291int vmem_add_mapping(unsigned long start, unsigned long size)
324{ 292{
325 struct memory_segment *seg; 293 struct memory_segment *seg;
326 struct page *page;
327 unsigned long pfn, num_pfn, end_pfn;
328 int ret; 294 int ret;
329 295
330 mutex_lock(&vmem_mutex); 296 mutex_lock(&vmem_mutex);
@@ -339,24 +305,9 @@ int add_shared_memory(unsigned long start, unsigned long size)
339 if (ret) 305 if (ret)
340 goto out_free; 306 goto out_free;
341 307
342 ret = vmem_add_mem(start, size); 308 ret = vmem_add_mem(start, size, 0);
343 if (ret) 309 if (ret)
344 goto out_remove; 310 goto out_remove;
345
346 pfn = PFN_DOWN(start);
347 num_pfn = PFN_DOWN(size);
348 end_pfn = pfn + num_pfn;
349
350 page = pfn_to_page(pfn);
351 memset(page, 0, num_pfn * sizeof(struct page));
352
353 for (; pfn < end_pfn; pfn++) {
354 page = pfn_to_page(pfn);
355 init_page_count(page);
356 reset_page_mapcount(page);
357 SetPageReserved(page);
358 INIT_LIST_HEAD(&page->lru);
359 }
360 goto out; 311 goto out;
361 312
362out_remove: 313out_remove:
@@ -375,14 +326,34 @@ out:
375 */ 326 */
376void __init vmem_map_init(void) 327void __init vmem_map_init(void)
377{ 328{
329 unsigned long ro_start, ro_end;
330 unsigned long start, end;
378 int i; 331 int i;
379 332
380 INIT_LIST_HEAD(&init_mm.context.crst_list); 333 INIT_LIST_HEAD(&init_mm.context.crst_list);
381 INIT_LIST_HEAD(&init_mm.context.pgtable_list); 334 INIT_LIST_HEAD(&init_mm.context.pgtable_list);
382 init_mm.context.noexec = 0; 335 init_mm.context.noexec = 0;
383 NODE_DATA(0)->node_mem_map = VMEM_MAP; 336 ro_start = ((unsigned long)&_stext) & PAGE_MASK;
384 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) 337 ro_end = PFN_ALIGN((unsigned long)&_eshared);
385 vmem_add_mem(memory_chunk[i].addr, memory_chunk[i].size); 338 for (i = 0; i < MEMORY_CHUNKS && memory_chunk[i].size > 0; i++) {
339 start = memory_chunk[i].addr;
340 end = memory_chunk[i].addr + memory_chunk[i].size;
341 if (start >= ro_end || end <= ro_start)
342 vmem_add_mem(start, end - start, 0);
343 else if (start >= ro_start && end <= ro_end)
344 vmem_add_mem(start, end - start, 1);
345 else if (start >= ro_start) {
346 vmem_add_mem(start, ro_end - start, 1);
347 vmem_add_mem(ro_end, end - ro_end, 0);
348 } else if (end < ro_end) {
349 vmem_add_mem(start, ro_start - start, 0);
350 vmem_add_mem(ro_start, end - ro_start, 1);
351 } else {
352 vmem_add_mem(start, ro_start - start, 0);
353 vmem_add_mem(ro_start, ro_end - ro_start, 1);
354 vmem_add_mem(ro_end, end - ro_end, 0);
355 }
356 }
386} 357}
387 358
388/* 359/*
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 49590f8fe98c..d211fdb24584 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -68,6 +68,7 @@ config SPARC
68 default y 68 default y
69 select HAVE_IDE 69 select HAVE_IDE
70 select HAVE_OPROFILE 70 select HAVE_OPROFILE
71 select HAVE_ARCH_KGDB if !SMP
71 72
72# Identify this as a Sparc32 build 73# Identify this as a Sparc32 build
73config SPARC32 74config SPARC32
diff --git a/arch/sparc/defconfig b/arch/sparc/defconfig
index 6a2c57a2fe71..2e3a149ea0e7 100644
--- a/arch/sparc/defconfig
+++ b/arch/sparc/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.25 3# Linux kernel version: 2.6.25
4# Sun Apr 20 01:49:51 2008 4# Tue Apr 29 01:28:58 2008
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_HIGHMEM=y 7CONFIG_HIGHMEM=y
@@ -217,12 +217,7 @@ CONFIG_IPV6_TUNNEL=m
217# CONFIG_NETWORK_SECMARK is not set 217# CONFIG_NETWORK_SECMARK is not set
218# CONFIG_NETFILTER is not set 218# CONFIG_NETFILTER is not set
219# CONFIG_IP_DCCP is not set 219# CONFIG_IP_DCCP is not set
220CONFIG_IP_SCTP=m 220# CONFIG_IP_SCTP is not set
221# CONFIG_SCTP_DBG_MSG is not set
222CONFIG_SCTP_DBG_OBJCNT=y
223# CONFIG_SCTP_HMAC_NONE is not set
224# CONFIG_SCTP_HMAC_SHA1 is not set
225CONFIG_SCTP_HMAC_MD5=y
226# CONFIG_TIPC is not set 221# CONFIG_TIPC is not set
227# CONFIG_ATM is not set 222# CONFIG_ATM is not set
228# CONFIG_BRIDGE is not set 223# CONFIG_BRIDGE is not set
@@ -245,9 +240,7 @@ CONFIG_NET_PKTGEN=m
245# CONFIG_CAN is not set 240# CONFIG_CAN is not set
246# CONFIG_IRDA is not set 241# CONFIG_IRDA is not set
247# CONFIG_BT is not set 242# CONFIG_BT is not set
248CONFIG_AF_RXRPC=m 243# CONFIG_AF_RXRPC is not set
249# CONFIG_AF_RXRPC_DEBUG is not set
250# CONFIG_RXKAD is not set
251 244
252# 245#
253# Wireless 246# Wireless
@@ -390,7 +383,7 @@ CONFIG_DUMMY=m
390# CONFIG_BONDING is not set 383# CONFIG_BONDING is not set
391# CONFIG_MACVLAN is not set 384# CONFIG_MACVLAN is not set
392# CONFIG_EQUALIZER is not set 385# CONFIG_EQUALIZER is not set
393CONFIG_TUN=m 386# CONFIG_TUN is not set
394# CONFIG_VETH is not set 387# CONFIG_VETH is not set
395# CONFIG_ARCNET is not set 388# CONFIG_ARCNET is not set
396# CONFIG_PHYLIB is not set 389# CONFIG_PHYLIB is not set
@@ -544,6 +537,7 @@ CONFIG_SERIAL_SUNSU_CONSOLE=y
544# CONFIG_SERIAL_SUNSAB is not set 537# CONFIG_SERIAL_SUNSAB is not set
545CONFIG_SERIAL_CORE=y 538CONFIG_SERIAL_CORE=y
546CONFIG_SERIAL_CORE_CONSOLE=y 539CONFIG_SERIAL_CORE_CONSOLE=y
540CONFIG_CONSOLE_POLL=y
547# CONFIG_SERIAL_JSM is not set 541# CONFIG_SERIAL_JSM is not set
548CONFIG_UNIX98_PTYS=y 542CONFIG_UNIX98_PTYS=y
549CONFIG_LEGACY_PTYS=y 543CONFIG_LEGACY_PTYS=y
@@ -595,6 +589,7 @@ CONFIG_SSB_POSSIBLE=y
595# Multifunction device drivers 589# Multifunction device drivers
596# 590#
597# CONFIG_MFD_SM501 is not set 591# CONFIG_MFD_SM501 is not set
592# CONFIG_HTC_PASIC3 is not set
598 593
599# 594#
600# Multimedia devices 595# Multimedia devices
@@ -645,10 +640,6 @@ CONFIG_USB_ARCH_HAS_EHCI=y
645# CONFIG_NEW_LEDS is not set 640# CONFIG_NEW_LEDS is not set
646# CONFIG_INFINIBAND is not set 641# CONFIG_INFINIBAND is not set
647# CONFIG_RTC_CLASS is not set 642# CONFIG_RTC_CLASS is not set
648
649#
650# Userspace I/O
651#
652# CONFIG_UIO is not set 643# CONFIG_UIO is not set
653 644
654# 645#
@@ -680,16 +671,12 @@ CONFIG_FS_MBCACHE=y
680# CONFIG_REISERFS_FS is not set 671# CONFIG_REISERFS_FS is not set
681# CONFIG_JFS_FS is not set 672# CONFIG_JFS_FS is not set
682CONFIG_FS_POSIX_ACL=y 673CONFIG_FS_POSIX_ACL=y
683CONFIG_XFS_FS=m 674# CONFIG_XFS_FS is not set
684CONFIG_XFS_QUOTA=y
685CONFIG_XFS_POSIX_ACL=y
686CONFIG_XFS_RT=y
687# CONFIG_OCFS2_FS is not set 675# CONFIG_OCFS2_FS is not set
688CONFIG_DNOTIFY=y 676CONFIG_DNOTIFY=y
689CONFIG_INOTIFY=y 677CONFIG_INOTIFY=y
690CONFIG_INOTIFY_USER=y 678CONFIG_INOTIFY_USER=y
691# CONFIG_QUOTA is not set 679# CONFIG_QUOTA is not set
692CONFIG_QUOTACTL=y
693CONFIG_AUTOFS_FS=m 680CONFIG_AUTOFS_FS=m
694CONFIG_AUTOFS4_FS=m 681CONFIG_AUTOFS4_FS=m
695# CONFIG_FUSE_FS is not set 682# CONFIG_FUSE_FS is not set
@@ -725,11 +712,9 @@ CONFIG_SYSFS=y
725# 712#
726# CONFIG_ADFS_FS is not set 713# CONFIG_ADFS_FS is not set
727# CONFIG_AFFS_FS is not set 714# CONFIG_AFFS_FS is not set
728# CONFIG_ECRYPT_FS is not set
729# CONFIG_HFS_FS is not set 715# CONFIG_HFS_FS is not set
730# CONFIG_HFSPLUS_FS is not set 716# CONFIG_HFSPLUS_FS is not set
731CONFIG_BEFS_FS=m 717# CONFIG_BEFS_FS is not set
732# CONFIG_BEFS_DEBUG is not set
733# CONFIG_BFS_FS is not set 718# CONFIG_BFS_FS is not set
734# CONFIG_EFS_FS is not set 719# CONFIG_EFS_FS is not set
735# CONFIG_CRAMFS is not set 720# CONFIG_CRAMFS is not set
@@ -744,7 +729,6 @@ CONFIG_NETWORK_FILESYSTEMS=y
744CONFIG_NFS_FS=y 729CONFIG_NFS_FS=y
745# CONFIG_NFS_V3 is not set 730# CONFIG_NFS_V3 is not set
746# CONFIG_NFS_V4 is not set 731# CONFIG_NFS_V4 is not set
747# CONFIG_NFS_DIRECTIO is not set
748# CONFIG_NFSD is not set 732# CONFIG_NFSD is not set
749CONFIG_ROOT_NFS=y 733CONFIG_ROOT_NFS=y
750CONFIG_LOCKD=y 734CONFIG_LOCKD=y
@@ -755,16 +739,10 @@ CONFIG_SUNRPC_GSS=m
755CONFIG_RPCSEC_GSS_KRB5=m 739CONFIG_RPCSEC_GSS_KRB5=m
756# CONFIG_RPCSEC_GSS_SPKM3 is not set 740# CONFIG_RPCSEC_GSS_SPKM3 is not set
757# CONFIG_SMB_FS is not set 741# CONFIG_SMB_FS is not set
758CONFIG_CIFS=m 742# CONFIG_CIFS is not set
759# CONFIG_CIFS_STATS is not set
760# CONFIG_CIFS_WEAK_PW_HASH is not set
761# CONFIG_CIFS_XATTR is not set
762# CONFIG_CIFS_DEBUG2 is not set
763# CONFIG_CIFS_EXPERIMENTAL is not set
764# CONFIG_NCP_FS is not set 743# CONFIG_NCP_FS is not set
765# CONFIG_CODA_FS is not set 744# CONFIG_CODA_FS is not set
766CONFIG_AFS_FS=m 745# CONFIG_AFS_FS is not set
767# CONFIG_AFS_DEBUG is not set
768 746
769# 747#
770# Partition Types 748# Partition Types
@@ -821,6 +799,7 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
821# CONFIG_PRINTK_TIME is not set 799# CONFIG_PRINTK_TIME is not set
822# CONFIG_ENABLE_WARN_DEPRECATED is not set 800# CONFIG_ENABLE_WARN_DEPRECATED is not set
823CONFIG_ENABLE_MUST_CHECK=y 801CONFIG_ENABLE_MUST_CHECK=y
802CONFIG_FRAME_WARN=1024
824CONFIG_MAGIC_SYSRQ=y 803CONFIG_MAGIC_SYSRQ=y
825# CONFIG_UNUSED_SYMBOLS is not set 804# CONFIG_UNUSED_SYMBOLS is not set
826# CONFIG_DEBUG_FS is not set 805# CONFIG_DEBUG_FS is not set
@@ -842,70 +821,105 @@ CONFIG_DETECT_SOFTLOCKUP=y
842CONFIG_DEBUG_BUGVERBOSE=y 821CONFIG_DEBUG_BUGVERBOSE=y
843# CONFIG_DEBUG_INFO is not set 822# CONFIG_DEBUG_INFO is not set
844# CONFIG_DEBUG_VM is not set 823# CONFIG_DEBUG_VM is not set
824# CONFIG_DEBUG_WRITECOUNT is not set
845# CONFIG_DEBUG_LIST is not set 825# CONFIG_DEBUG_LIST is not set
846# CONFIG_DEBUG_SG is not set 826# CONFIG_DEBUG_SG is not set
827CONFIG_FRAME_POINTER=y
847# CONFIG_BOOT_PRINTK_DELAY is not set 828# CONFIG_BOOT_PRINTK_DELAY is not set
848# CONFIG_RCU_TORTURE_TEST is not set 829# CONFIG_RCU_TORTURE_TEST is not set
849# CONFIG_BACKTRACE_SELF_TEST is not set 830# CONFIG_BACKTRACE_SELF_TEST is not set
850# CONFIG_FAULT_INJECTION is not set 831# CONFIG_FAULT_INJECTION is not set
851# CONFIG_SAMPLES is not set 832# CONFIG_SAMPLES is not set
833CONFIG_KGDB=y
834CONFIG_HAVE_ARCH_KGDB=y
835CONFIG_KGDB_SERIAL_CONSOLE=y
836CONFIG_KGDB_TESTS=y
837# CONFIG_KGDB_TESTS_ON_BOOT is not set
852# CONFIG_DEBUG_STACK_USAGE is not set 838# CONFIG_DEBUG_STACK_USAGE is not set
853 839
854# 840#
855# Security options 841# Security options
856# 842#
857CONFIG_KEYS=y 843# CONFIG_KEYS is not set
858# CONFIG_KEYS_DEBUG_PROC_KEYS is not set
859# CONFIG_SECURITY is not set 844# CONFIG_SECURITY is not set
860# CONFIG_SECURITY_FILE_CAPABILITIES is not set 845# CONFIG_SECURITY_FILE_CAPABILITIES is not set
861CONFIG_CRYPTO=y 846CONFIG_CRYPTO=y
847
848#
849# Crypto core or helper
850#
862CONFIG_CRYPTO_ALGAPI=y 851CONFIG_CRYPTO_ALGAPI=y
863CONFIG_CRYPTO_AEAD=y 852CONFIG_CRYPTO_AEAD=y
864CONFIG_CRYPTO_BLKCIPHER=y 853CONFIG_CRYPTO_BLKCIPHER=y
865# CONFIG_CRYPTO_SEQIV is not set
866CONFIG_CRYPTO_HASH=y 854CONFIG_CRYPTO_HASH=y
867CONFIG_CRYPTO_MANAGER=y 855CONFIG_CRYPTO_MANAGER=y
856# CONFIG_CRYPTO_GF128MUL is not set
857CONFIG_CRYPTO_NULL=m
858# CONFIG_CRYPTO_CRYPTD is not set
859CONFIG_CRYPTO_AUTHENC=y
860# CONFIG_CRYPTO_TEST is not set
861
862#
863# Authenticated Encryption with Associated Data
864#
865# CONFIG_CRYPTO_CCM is not set
866# CONFIG_CRYPTO_GCM is not set
867# CONFIG_CRYPTO_SEQIV is not set
868
869#
870# Block modes
871#
872CONFIG_CRYPTO_CBC=y
873# CONFIG_CRYPTO_CTR is not set
874# CONFIG_CRYPTO_CTS is not set
875CONFIG_CRYPTO_ECB=m
876# CONFIG_CRYPTO_LRW is not set
877CONFIG_CRYPTO_PCBC=m
878# CONFIG_CRYPTO_XTS is not set
879
880#
881# Hash modes
882#
868CONFIG_CRYPTO_HMAC=y 883CONFIG_CRYPTO_HMAC=y
869# CONFIG_CRYPTO_XCBC is not set 884# CONFIG_CRYPTO_XCBC is not set
870CONFIG_CRYPTO_NULL=m 885
886#
887# Digest
888#
889CONFIG_CRYPTO_CRC32C=m
871CONFIG_CRYPTO_MD4=y 890CONFIG_CRYPTO_MD4=y
872CONFIG_CRYPTO_MD5=y 891CONFIG_CRYPTO_MD5=y
892CONFIG_CRYPTO_MICHAEL_MIC=m
873CONFIG_CRYPTO_SHA1=y 893CONFIG_CRYPTO_SHA1=y
874CONFIG_CRYPTO_SHA256=m 894CONFIG_CRYPTO_SHA256=m
875CONFIG_CRYPTO_SHA512=m 895CONFIG_CRYPTO_SHA512=m
876# CONFIG_CRYPTO_WP512 is not set
877# CONFIG_CRYPTO_TGR192 is not set 896# CONFIG_CRYPTO_TGR192 is not set
878# CONFIG_CRYPTO_GF128MUL is not set 897# CONFIG_CRYPTO_WP512 is not set
879CONFIG_CRYPTO_ECB=m 898
880CONFIG_CRYPTO_CBC=y 899#
881CONFIG_CRYPTO_PCBC=m 900# Ciphers
882# CONFIG_CRYPTO_LRW is not set 901#
883# CONFIG_CRYPTO_XTS is not set
884# CONFIG_CRYPTO_CTR is not set
885# CONFIG_CRYPTO_GCM is not set
886# CONFIG_CRYPTO_CCM is not set
887# CONFIG_CRYPTO_CRYPTD is not set
888CONFIG_CRYPTO_DES=y
889# CONFIG_CRYPTO_FCRYPT is not set
890CONFIG_CRYPTO_BLOWFISH=m
891CONFIG_CRYPTO_TWOFISH=m
892CONFIG_CRYPTO_TWOFISH_COMMON=m
893CONFIG_CRYPTO_SERPENT=m
894CONFIG_CRYPTO_AES=m 902CONFIG_CRYPTO_AES=m
903# CONFIG_CRYPTO_ANUBIS is not set
904CONFIG_CRYPTO_ARC4=m
905CONFIG_CRYPTO_BLOWFISH=m
906# CONFIG_CRYPTO_CAMELLIA is not set
895CONFIG_CRYPTO_CAST5=m 907CONFIG_CRYPTO_CAST5=m
896CONFIG_CRYPTO_CAST6=m 908CONFIG_CRYPTO_CAST6=m
897# CONFIG_CRYPTO_TEA is not set 909CONFIG_CRYPTO_DES=y
898CONFIG_CRYPTO_ARC4=m 910# CONFIG_CRYPTO_FCRYPT is not set
899# CONFIG_CRYPTO_KHAZAD is not set 911# CONFIG_CRYPTO_KHAZAD is not set
900# CONFIG_CRYPTO_ANUBIS is not set
901# CONFIG_CRYPTO_SEED is not set
902# CONFIG_CRYPTO_SALSA20 is not set 912# CONFIG_CRYPTO_SALSA20 is not set
913# CONFIG_CRYPTO_SEED is not set
914CONFIG_CRYPTO_SERPENT=m
915# CONFIG_CRYPTO_TEA is not set
916CONFIG_CRYPTO_TWOFISH=m
917CONFIG_CRYPTO_TWOFISH_COMMON=m
918
919#
920# Compression
921#
903CONFIG_CRYPTO_DEFLATE=y 922CONFIG_CRYPTO_DEFLATE=y
904CONFIG_CRYPTO_MICHAEL_MIC=m
905CONFIG_CRYPTO_CRC32C=m
906# CONFIG_CRYPTO_CAMELLIA is not set
907# CONFIG_CRYPTO_TEST is not set
908CONFIG_CRYPTO_AUTHENC=y
909# CONFIG_CRYPTO_LZO is not set 923# CONFIG_CRYPTO_LZO is not set
910# CONFIG_CRYPTO_HW is not set 924# CONFIG_CRYPTO_HW is not set
911 925
@@ -913,6 +927,7 @@ CONFIG_CRYPTO_AUTHENC=y
913# Library routines 927# Library routines
914# 928#
915CONFIG_BITREVERSE=y 929CONFIG_BITREVERSE=y
930# CONFIG_GENERIC_FIND_FIRST_BIT is not set
916# CONFIG_CRC_CCITT is not set 931# CONFIG_CRC_CCITT is not set
917# CONFIG_CRC16 is not set 932# CONFIG_CRC16 is not set
918# CONFIG_CRC_ITU_T is not set 933# CONFIG_CRC_ITU_T is not set
diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
index 59700aaaae93..6e03a2a7863c 100644
--- a/arch/sparc/kernel/Makefile
+++ b/arch/sparc/kernel/Makefile
@@ -25,3 +25,4 @@ obj-$(CONFIG_PCI) += ebus.o
25obj-$(CONFIG_SUN_PM) += apc.o pmc.o 25obj-$(CONFIG_SUN_PM) += apc.o pmc.o
26obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o 26obj-$(CONFIG_MODULES) += module.o sparc_ksyms.o
27obj-$(CONFIG_SPARC_LED) += led.o 27obj-$(CONFIG_SPARC_LED) += led.o
28obj-$(CONFIG_KGDB) += kgdb.o
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 484c83d23eef..57d1bbdd0bd2 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -12,7 +12,6 @@
12#include <asm/head.h> 12#include <asm/head.h>
13#include <asm/asi.h> 13#include <asm/asi.h>
14#include <asm/smp.h> 14#include <asm/smp.h>
15#include <asm/kgdb.h>
16#include <asm/contregs.h> 15#include <asm/contregs.h>
17#include <asm/ptrace.h> 16#include <asm/ptrace.h>
18#include <asm/asm-offsets.h> 17#include <asm/asm-offsets.h>
@@ -45,91 +44,20 @@
45 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \ 44 _SV; _SV; _SV; _SV; _SV; _SV; _SV; \
46 _RS; _RS; _RS; _RS; _RS; _RS; _RS; 45 _RS; _RS; _RS; _RS; _RS; _RS; _RS;
47 46
48/* First, KGDB low level things. This is a rewrite
49 * of the routines found in the sparc-stub.c asm() statement
50 * from the gdb distribution. This is also dual-purpose
51 * as a software trap for userlevel programs.
52 */
53 .data
54 .align 4
55
56in_trap_handler:
57 .word 0
58
59 .text 47 .text
60 .align 4
61 48
62#if 0 /* kgdb is dropped from 2.5.33 */ 49#ifdef CONFIG_KGDB
63! This function is called when any SPARC trap (except window overflow or 50 .align 4
64! underflow) occurs. It makes sure that the invalid register window is still 51 .globl arch_kgdb_breakpoint
65! available before jumping into C code. It will also restore the world if you 52 .type arch_kgdb_breakpoint,#function
66! return from handle_exception. 53arch_kgdb_breakpoint:
67 54 ta 0x7d
68 .globl trap_low 55 retl
69trap_low: 56 nop
70 rd %wim, %l3 57 .size arch_kgdb_breakpoint,.-arch_kgdb_breakpoint
71 SAVE_ALL
72
73 sethi %hi(in_trap_handler), %l4
74 ld [%lo(in_trap_handler) + %l4], %l5
75 inc %l5
76 st %l5, [%lo(in_trap_handler) + %l4]
77
78 /* Make sure kgdb sees the same state we just saved. */
79 LOAD_PT_GLOBALS(sp)
80 LOAD_PT_INS(sp)
81 ld [%sp + STACKFRAME_SZ + PT_Y], %l4
82 ld [%sp + STACKFRAME_SZ + PT_WIM], %l3
83 ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
84 ld [%sp + STACKFRAME_SZ + PT_PC], %l1
85 ld [%sp + STACKFRAME_SZ + PT_NPC], %l2
86 rd %tbr, %l5 /* Never changes... */
87
88 /* Make kgdb exception frame. */
89 sub %sp,(16+1+6+1+72)*4,%sp ! Make room for input & locals
90 ! + hidden arg + arg spill
91 ! + doubleword alignment
92 ! + registers[72] local var
93 SAVE_KGDB_GLOBALS(sp)
94 SAVE_KGDB_INS(sp)
95 SAVE_KGDB_SREGS(sp, l4, l0, l3, l5, l1, l2)
96
97 /* We are increasing PIL, so two writes. */
98 or %l0, PSR_PIL, %l0
99 wr %l0, 0, %psr
100 WRITE_PAUSE
101 wr %l0, PSR_ET, %psr
102 WRITE_PAUSE
103
104 call handle_exception
105 add %sp, STACKFRAME_SZ, %o0 ! Pass address of registers
106
107 /* Load new kgdb register set. */
108 LOAD_KGDB_GLOBALS(sp)
109 LOAD_KGDB_INS(sp)
110 LOAD_KGDB_SREGS(sp, l4, l0, l3, l5, l1, l2)
111 wr %l4, 0x0, %y
112
113 sethi %hi(in_trap_handler), %l4
114 ld [%lo(in_trap_handler) + %l4], %l5
115 dec %l5
116 st %l5, [%lo(in_trap_handler) + %l4]
117
118 add %sp,(16+1+6+1+72)*4,%sp ! Undo the kgdb trap frame.
119
120 /* Now take what kgdb did and place it into the pt_regs
121 * frame which SparcLinux RESTORE_ALL understands.,
122 */
123 STORE_PT_INS(sp)
124 STORE_PT_GLOBALS(sp)
125 STORE_PT_YREG(sp, g2)
126 STORE_PT_PRIV(sp, l0, l1, l2)
127
128 RESTORE_ALL
129#endif 58#endif
130 59
131#if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE) 60#if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE)
132 .text
133 .align 4 61 .align 4
134 .globl floppy_hardint 62 .globl floppy_hardint
135floppy_hardint: 63floppy_hardint:
@@ -1596,6 +1524,23 @@ breakpoint_trap:
1596 1524
1597 RESTORE_ALL 1525 RESTORE_ALL
1598 1526
1527#ifdef CONFIG_KGDB
1528 .align 4
1529 .globl kgdb_trap_low
1530 .type kgdb_trap_low,#function
1531kgdb_trap_low:
1532 rd %wim,%l3
1533 SAVE_ALL
1534 wr %l0, PSR_ET, %psr
1535 WRITE_PAUSE
1536
1537 call kgdb_trap
1538 add %sp, STACKFRAME_SZ, %o0
1539
1540 RESTORE_ALL
1541 .size kgdb_trap_low,.-kgdb_trap_low
1542#endif
1543
1599 .align 4 1544 .align 4
1600 .globl __handle_exception, flush_patch_exception 1545 .globl __handle_exception, flush_patch_exception
1601__handle_exception: 1546__handle_exception:
@@ -1698,4 +1643,22 @@ pcic_nmi_trap_patch:
1698 1643
1699#endif /* CONFIG_PCI */ 1644#endif /* CONFIG_PCI */
1700 1645
1646 .globl flushw_all
1647flushw_all:
1648 save %sp, -0x40, %sp
1649 save %sp, -0x40, %sp
1650 save %sp, -0x40, %sp
1651 save %sp, -0x40, %sp
1652 save %sp, -0x40, %sp
1653 save %sp, -0x40, %sp
1654 save %sp, -0x40, %sp
1655 restore
1656 restore
1657 restore
1658 restore
1659 restore
1660 restore
1661 ret
1662 restore
1663
1701/* End of entry.S */ 1664/* End of entry.S */
diff --git a/arch/sparc/kernel/head.S b/arch/sparc/kernel/head.S
index b7f1e81c8ff2..8bec05fa5795 100644
--- a/arch/sparc/kernel/head.S
+++ b/arch/sparc/kernel/head.S
@@ -191,7 +191,8 @@ t_bade8:BAD_TRAP(0xe8) BAD_TRAP(0xe9) BAD_TRAP(0xea) BAD_TRAP(0xeb) BAD_TRAP(0xe
191t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1) 191t_baded:BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
192t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6) 192t_badf2:BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
193t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) 193t_badf7:BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
194t_badfc:BAD_TRAP(0xfc) BAD_TRAP(0xfd) 194t_badfc:BAD_TRAP(0xfc)
195t_kgdb: KGDB_TRAP(0xfd)
195dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */ 196dbtrap: BAD_TRAP(0xfe) /* Debugger/PROM breakpoint #1 */
196dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */ 197dbtrap2:BAD_TRAP(0xff) /* Debugger/PROM breakpoint #2 */
197 198
@@ -267,7 +268,7 @@ trapbase_cpu1:
267 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1) 268 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
268 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6) 269 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
269 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) 270 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
270 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff) 271 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
271 272
272trapbase_cpu2: 273trapbase_cpu2:
273 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction) 274 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
@@ -335,7 +336,7 @@ trapbase_cpu2:
335 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1) 336 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
336 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6) 337 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
337 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) 338 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
338 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff) 339 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
339 340
340trapbase_cpu3: 341trapbase_cpu3:
341 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction) 342 BAD_TRAP(0x0) SRMMU_TFAULT TRAP_ENTRY(0x2, bad_instruction)
@@ -403,7 +404,7 @@ trapbase_cpu3:
403 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1) 404 BAD_TRAP(0xed) BAD_TRAP(0xee) BAD_TRAP(0xef) BAD_TRAP(0xf0) BAD_TRAP(0xf1)
404 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6) 405 BAD_TRAP(0xf2) BAD_TRAP(0xf3) BAD_TRAP(0xf4) BAD_TRAP(0xf5) BAD_TRAP(0xf6)
405 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb) 406 BAD_TRAP(0xf7) BAD_TRAP(0xf8) BAD_TRAP(0xf9) BAD_TRAP(0xfa) BAD_TRAP(0xfb)
406 BAD_TRAP(0xfc) BAD_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff) 407 BAD_TRAP(0xfc) KGDB_TRAP(0xfd) BAD_TRAP(0xfe) BAD_TRAP(0xff)
407 408
408#endif 409#endif
409 .align PAGE_SIZE 410 .align PAGE_SIZE
diff --git a/arch/sparc/kernel/kgdb.c b/arch/sparc/kernel/kgdb.c
new file mode 100644
index 000000000000..757805ce02ee
--- /dev/null
+++ b/arch/sparc/kernel/kgdb.c
@@ -0,0 +1,164 @@
1/* kgdb.c: KGDB support for 32-bit sparc.
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/kgdb.h>
7#include <linux/kdebug.h>
8
9#include <asm/kdebug.h>
10#include <asm/ptrace.h>
11#include <asm/irq.h>
12
13extern unsigned long trapbase;
14
15void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
16{
17 struct reg_window *win;
18 int i;
19
20 gdb_regs[GDB_G0] = 0;
21 for (i = 0; i < 15; i++)
22 gdb_regs[GDB_G1 + i] = regs->u_regs[UREG_G1 + i];
23
24 win = (struct reg_window *) regs->u_regs[UREG_FP];
25 for (i = 0; i < 8; i++)
26 gdb_regs[GDB_L0 + i] = win->locals[i];
27 for (i = 0; i < 8; i++)
28 gdb_regs[GDB_I0 + i] = win->ins[i];
29
30 for (i = GDB_F0; i <= GDB_F31; i++)
31 gdb_regs[i] = 0;
32
33 gdb_regs[GDB_Y] = regs->y;
34 gdb_regs[GDB_PSR] = regs->psr;
35 gdb_regs[GDB_WIM] = 0;
36 gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
37 gdb_regs[GDB_PC] = regs->pc;
38 gdb_regs[GDB_NPC] = regs->npc;
39 gdb_regs[GDB_FSR] = 0;
40 gdb_regs[GDB_CSR] = 0;
41}
42
43void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
44{
45 struct thread_info *t = task_thread_info(p);
46 struct reg_window *win;
47 int i;
48
49 for (i = GDB_G0; i < GDB_G6; i++)
50 gdb_regs[i] = 0;
51 gdb_regs[GDB_G6] = (unsigned long) t;
52 gdb_regs[GDB_G7] = 0;
53 for (i = GDB_O0; i < GDB_SP; i++)
54 gdb_regs[i] = 0;
55 gdb_regs[GDB_SP] = t->ksp;
56 gdb_regs[GDB_O7] = 0;
57
58 win = (struct reg_window *) t->ksp;
59 for (i = 0; i < 8; i++)
60 gdb_regs[GDB_L0 + i] = win->locals[i];
61 for (i = 0; i < 8; i++)
62 gdb_regs[GDB_I0 + i] = win->ins[i];
63
64 for (i = GDB_F0; i <= GDB_F31; i++)
65 gdb_regs[i] = 0;
66
67 gdb_regs[GDB_Y] = 0;
68
69 gdb_regs[GDB_PSR] = t->kpsr;
70 gdb_regs[GDB_WIM] = t->kwim;
71 gdb_regs[GDB_TBR] = (unsigned long) &trapbase;
72 gdb_regs[GDB_PC] = t->kpc;
73 gdb_regs[GDB_NPC] = t->kpc + 4;
74 gdb_regs[GDB_FSR] = 0;
75 gdb_regs[GDB_CSR] = 0;
76}
77
78void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
79{
80 struct reg_window *win;
81 int i;
82
83 for (i = 0; i < 15; i++)
84 regs->u_regs[UREG_G1 + i] = gdb_regs[GDB_G1 + i];
85
86 /* If the PSR register is changing, we have to preserve
87 * the CWP field, otherwise window save/restore explodes.
88 */
89 if (regs->psr != gdb_regs[GDB_PSR]) {
90 unsigned long cwp = regs->psr & PSR_CWP;
91
92 regs->psr = (gdb_regs[GDB_PSR] & ~PSR_CWP) | cwp;
93 }
94
95 regs->pc = gdb_regs[GDB_PC];
96 regs->npc = gdb_regs[GDB_NPC];
97 regs->y = gdb_regs[GDB_Y];
98
99 win = (struct reg_window *) regs->u_regs[UREG_FP];
100 for (i = 0; i < 8; i++)
101 win->locals[i] = gdb_regs[GDB_L0 + i];
102 for (i = 0; i < 8; i++)
103 win->ins[i] = gdb_regs[GDB_I0 + i];
104}
105
106int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
107 char *remcomInBuffer, char *remcomOutBuffer,
108 struct pt_regs *linux_regs)
109{
110 unsigned long addr;
111 char *ptr;
112
113 switch (remcomInBuffer[0]) {
114 case 'c':
115 /* try to read optional parameter, pc unchanged if no parm */
116 ptr = &remcomInBuffer[1];
117 if (kgdb_hex2long(&ptr, &addr)) {
118 linux_regs->pc = addr;
119 linux_regs->npc = addr + 4;
120 }
121 /* fallthru */
122
123 case 'D':
124 case 'k':
125 if (linux_regs->pc == (unsigned long) arch_kgdb_breakpoint) {
126 linux_regs->pc = linux_regs->npc;
127 linux_regs->npc += 4;
128 }
129 return 0;
130 }
131 return -1;
132}
133
134extern void do_hw_interrupt(struct pt_regs *regs, unsigned long type);
135
136asmlinkage void kgdb_trap(struct pt_regs *regs)
137{
138 unsigned long flags;
139
140 if (user_mode(regs)) {
141 do_hw_interrupt(regs, 0xfd);
142 return;
143 }
144
145 flushw_all();
146
147 local_irq_save(flags);
148 kgdb_handle_exception(0x172, SIGTRAP, 0, regs);
149 local_irq_restore(flags);
150}
151
152int kgdb_arch_init(void)
153{
154 return 0;
155}
156
157void kgdb_arch_exit(void)
158{
159}
160
161struct kgdb_arch arch_kgdb_ops = {
162 /* Breakpoint instruction: ta 0x7d */
163 .gdb_bpt_instr = { 0x91, 0xd0, 0x20, 0x7d },
164};
diff --git a/arch/sparc/kernel/sparc-stub.c b/arch/sparc/kernel/sparc-stub.c
deleted file mode 100644
index e84f815e6903..000000000000
--- a/arch/sparc/kernel/sparc-stub.c
+++ /dev/null
@@ -1,724 +0,0 @@
1/* $Id: sparc-stub.c,v 1.28 2001/10/30 04:54:21 davem Exp $
2 * sparc-stub.c: KGDB support for the Linux kernel.
3 *
4 * Modifications to run under Linux
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 *
7 * This file originally came from the gdb sources, and the
8 * copyright notices have been retained below.
9 */
10
11/****************************************************************************
12
13 THIS SOFTWARE IS NOT COPYRIGHTED
14
15 HP offers the following for use in the public domain. HP makes no
16 warranty with regard to the software or its performance and the
17 user accepts the software "AS IS" with all faults.
18
19 HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD
20 TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22
23****************************************************************************/
24
25/****************************************************************************
26 * Header: remcom.c,v 1.34 91/03/09 12:29:49 glenne Exp $
27 *
28 * Module name: remcom.c $
29 * Revision: 1.34 $
30 * Date: 91/03/09 12:29:49 $
31 * Contributor: Lake Stevens Instrument Division$
32 *
33 * Description: low level support for gdb debugger. $
34 *
35 * Considerations: only works on target hardware $
36 *
37 * Written by: Glenn Engel $
38 * ModuleState: Experimental $
39 *
40 * NOTES: See Below $
41 *
42 * Modified for SPARC by Stu Grossman, Cygnus Support.
43 *
44 * This code has been extensively tested on the Fujitsu SPARClite demo board.
45 *
46 * To enable debugger support, two things need to happen. One, a
47 * call to set_debug_traps() is necessary in order to allow any breakpoints
48 * or error conditions to be properly intercepted and reported to gdb.
49 * Two, a breakpoint needs to be generated to begin communication. This
50 * is most easily accomplished by a call to breakpoint(). Breakpoint()
51 * simulates a breakpoint by executing a trap #1.
52 *
53 *************
54 *
55 * The following gdb commands are supported:
56 *
57 * command function Return value
58 *
59 * g return the value of the CPU registers hex data or ENN
60 * G set the value of the CPU registers OK or ENN
61 *
62 * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN
63 * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN
64 *
65 * c Resume at current address SNN ( signal NN)
66 * cAA..AA Continue at address AA..AA SNN
67 *
68 * s Step one instruction SNN
69 * sAA..AA Step one instruction from AA..AA SNN
70 *
71 * k kill
72 *
73 * ? What was the last sigval ? SNN (signal NN)
74 *
75 * bBB..BB Set baud rate to BB..BB OK or BNN, then sets
76 * baud rate
77 *
78 * All commands and responses are sent with a packet which includes a
79 * checksum. A packet consists of
80 *
81 * $<packet info>#<checksum>.
82 *
83 * where
84 * <packet info> :: <characters representing the command or response>
85 * <checksum> :: < two hex digits computed as modulo 256 sum of <packetinfo>>
86 *
87 * When a packet is received, it is first acknowledged with either '+' or '-'.
88 * '+' indicates a successful transfer. '-' indicates a failed transfer.
89 *
90 * Example:
91 *
92 * Host: Reply:
93 * $m0,10#2a +$00010203040506070809101112131415#42
94 *
95 ****************************************************************************/
96
97#include <linux/kernel.h>
98#include <linux/string.h>
99#include <linux/mm.h>
100#include <linux/smp.h>
101#include <linux/smp_lock.h>
102
103#include <asm/system.h>
104#include <asm/signal.h>
105#include <asm/oplib.h>
106#include <asm/head.h>
107#include <asm/traps.h>
108#include <asm/vac-ops.h>
109#include <asm/kgdb.h>
110#include <asm/pgalloc.h>
111#include <asm/pgtable.h>
112#include <asm/cacheflush.h>
113
114/*
115 *
116 * external low-level support routines
117 */
118
119extern void putDebugChar(char); /* write a single character */
120extern char getDebugChar(void); /* read and return a single char */
121
122/*
123 * BUFMAX defines the maximum number of characters in inbound/outbound buffers
124 * at least NUMREGBYTES*2 are needed for register packets
125 */
126#define BUFMAX 2048
127
128static int initialized; /* !0 means we've been initialized */
129
130static const char hexchars[]="0123456789abcdef";
131
132#define NUMREGS 72
133
134/* Number of bytes of registers. */
135#define NUMREGBYTES (NUMREGS * 4)
136enum regnames {G0, G1, G2, G3, G4, G5, G6, G7,
137 O0, O1, O2, O3, O4, O5, SP, O7,
138 L0, L1, L2, L3, L4, L5, L6, L7,
139 I0, I1, I2, I3, I4, I5, FP, I7,
140
141 F0, F1, F2, F3, F4, F5, F6, F7,
142 F8, F9, F10, F11, F12, F13, F14, F15,
143 F16, F17, F18, F19, F20, F21, F22, F23,
144 F24, F25, F26, F27, F28, F29, F30, F31,
145 Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR };
146
147
148extern void trap_low(void); /* In arch/sparc/kernel/entry.S */
149
150unsigned long get_sun4cpte(unsigned long addr)
151{
152 unsigned long entry;
153
154 __asm__ __volatile__("\n\tlda [%1] %2, %0\n\t" :
155 "=r" (entry) :
156 "r" (addr), "i" (ASI_PTE));
157 return entry;
158}
159
160unsigned long get_sun4csegmap(unsigned long addr)
161{
162 unsigned long entry;
163
164 __asm__ __volatile__("\n\tlduba [%1] %2, %0\n\t" :
165 "=r" (entry) :
166 "r" (addr), "i" (ASI_SEGMAP));
167 return entry;
168}
169
170#if 0
171/* Have to sort this out. This cannot be done after initialization. */
172static void flush_cache_all_nop(void) {}
173#endif
174
175/* Place where we save old trap entries for restoration */
176struct tt_entry kgdb_savettable[256];
177typedef void (*trapfunc_t)(void);
178
179/* Helper routine for manipulation of kgdb_savettable */
180static inline void copy_ttentry(struct tt_entry *src, struct tt_entry *dest)
181{
182 dest->inst_one = src->inst_one;
183 dest->inst_two = src->inst_two;
184 dest->inst_three = src->inst_three;
185 dest->inst_four = src->inst_four;
186}
187
188/* Initialize the kgdb_savettable so that debugging can commence */
189static void eh_init(void)
190{
191 int i;
192
193 for(i=0; i < 256; i++)
194 copy_ttentry(&sparc_ttable[i], &kgdb_savettable[i]);
195}
196
197/* Install an exception handler for kgdb */
198static void exceptionHandler(int tnum, trapfunc_t trap_entry)
199{
200 unsigned long te_addr = (unsigned long) trap_entry;
201
202 /* Make new vector */
203 sparc_ttable[tnum].inst_one =
204 SPARC_BRANCH((unsigned long) te_addr,
205 (unsigned long) &sparc_ttable[tnum].inst_one);
206 sparc_ttable[tnum].inst_two = SPARC_RD_PSR_L0;
207 sparc_ttable[tnum].inst_three = SPARC_NOP;
208 sparc_ttable[tnum].inst_four = SPARC_NOP;
209}
210
211/* Convert ch from a hex digit to an int */
212static int
213hex(unsigned char ch)
214{
215 if (ch >= 'a' && ch <= 'f')
216 return ch-'a'+10;
217 if (ch >= '0' && ch <= '9')
218 return ch-'0';
219 if (ch >= 'A' && ch <= 'F')
220 return ch-'A'+10;
221 return -1;
222}
223
224/* scan for the sequence $<data>#<checksum> */
225static void
226getpacket(char *buffer)
227{
228 unsigned char checksum;
229 unsigned char xmitcsum;
230 int i;
231 int count;
232 unsigned char ch;
233
234 do {
235 /* wait around for the start character, ignore all other characters */
236 while ((ch = (getDebugChar() & 0x7f)) != '$') ;
237
238 checksum = 0;
239 xmitcsum = -1;
240
241 count = 0;
242
243 /* now, read until a # or end of buffer is found */
244 while (count < BUFMAX) {
245 ch = getDebugChar() & 0x7f;
246 if (ch == '#')
247 break;
248 checksum = checksum + ch;
249 buffer[count] = ch;
250 count = count + 1;
251 }
252
253 if (count >= BUFMAX)
254 continue;
255
256 buffer[count] = 0;
257
258 if (ch == '#') {
259 xmitcsum = hex(getDebugChar() & 0x7f) << 4;
260 xmitcsum |= hex(getDebugChar() & 0x7f);
261 if (checksum != xmitcsum)
262 putDebugChar('-'); /* failed checksum */
263 else {
264 putDebugChar('+'); /* successful transfer */
265 /* if a sequence char is present, reply the ID */
266 if (buffer[2] == ':') {
267 putDebugChar(buffer[0]);
268 putDebugChar(buffer[1]);
269 /* remove sequence chars from buffer */
270 count = strlen(buffer);
271 for (i=3; i <= count; i++)
272 buffer[i-3] = buffer[i];
273 }
274 }
275 }
276 } while (checksum != xmitcsum);
277}
278
279/* send the packet in buffer. */
280
281static void
282putpacket(unsigned char *buffer)
283{
284 unsigned char checksum;
285 int count;
286 unsigned char ch, recv;
287
288 /* $<packet info>#<checksum>. */
289 do {
290 putDebugChar('$');
291 checksum = 0;
292 count = 0;
293
294 while ((ch = buffer[count])) {
295 putDebugChar(ch);
296 checksum += ch;
297 count += 1;
298 }
299
300 putDebugChar('#');
301 putDebugChar(hexchars[checksum >> 4]);
302 putDebugChar(hexchars[checksum & 0xf]);
303 recv = getDebugChar();
304 } while ((recv & 0x7f) != '+');
305}
306
307static char remcomInBuffer[BUFMAX];
308static char remcomOutBuffer[BUFMAX];
309
310/* Convert the memory pointed to by mem into hex, placing result in buf.
311 * Return a pointer to the last char put in buf (null), in case of mem fault,
312 * return 0.
313 */
314
315static unsigned char *
316mem2hex(char *mem, char *buf, int count)
317{
318 unsigned char ch;
319
320 while (count-- > 0) {
321 /* This assembler code is basically: ch = *mem++;
322 * except that we use the SPARC/Linux exception table
323 * mechanism (see how "fixup" works in kernel_mna_trap_fault)
324 * to arrange for a "return 0" upon a memory fault
325 */
326 __asm__(
327 "\n1:\n\t"
328 "ldub [%0], %1\n\t"
329 "inc %0\n\t"
330 ".section .fixup,#alloc,#execinstr\n\t"
331 ".align 4\n"
332 "2:\n\t"
333 "retl\n\t"
334 " mov 0, %%o0\n\t"
335 ".section __ex_table, #alloc\n\t"
336 ".align 4\n\t"
337 ".word 1b, 2b\n\t"
338 ".text\n"
339 : "=r" (mem), "=r" (ch) : "0" (mem));
340 *buf++ = hexchars[ch >> 4];
341 *buf++ = hexchars[ch & 0xf];
342 }
343
344 *buf = 0;
345 return buf;
346}
347
348/* convert the hex array pointed to by buf into binary to be placed in mem
349 * return a pointer to the character AFTER the last byte written.
350*/
351static char *
352hex2mem(char *buf, char *mem, int count)
353{
354 int i;
355 unsigned char ch;
356
357 for (i=0; i<count; i++) {
358
359 ch = hex(*buf++) << 4;
360 ch |= hex(*buf++);
361 /* Assembler code is *mem++ = ch; with return 0 on fault */
362 __asm__(
363 "\n1:\n\t"
364 "stb %1, [%0]\n\t"
365 "inc %0\n\t"
366 ".section .fixup,#alloc,#execinstr\n\t"
367 ".align 4\n"
368 "2:\n\t"
369 "retl\n\t"
370 " mov 0, %%o0\n\t"
371 ".section __ex_table, #alloc\n\t"
372 ".align 4\n\t"
373 ".word 1b, 2b\n\t"
374 ".text\n"
375 : "=r" (mem) : "r" (ch) , "0" (mem));
376 }
377 return mem;
378}
379
380/* This table contains the mapping between SPARC hardware trap types, and
381 signals, which are primarily what GDB understands. It also indicates
382 which hardware traps we need to commandeer when initializing the stub. */
383
384static struct hard_trap_info
385{
386 unsigned char tt; /* Trap type code for SPARC */
387 unsigned char signo; /* Signal that we map this trap into */
388} hard_trap_info[] = {
389 {SP_TRAP_SBPT, SIGTRAP}, /* ta 1 - Linux/KGDB software breakpoint */
390 {0, 0} /* Must be last */
391};
392
393/* Set up exception handlers for tracing and breakpoints */
394
395void
396set_debug_traps(void)
397{
398 struct hard_trap_info *ht;
399 unsigned long flags;
400
401 local_irq_save(flags);
402#if 0
403/* Have to sort this out. This cannot be done after initialization. */
404 BTFIXUPSET_CALL(flush_cache_all, flush_cache_all_nop, BTFIXUPCALL_NOP);
405#endif
406
407 /* Initialize our copy of the Linux Sparc trap table */
408 eh_init();
409
410 for (ht = hard_trap_info; ht->tt && ht->signo; ht++) {
411 /* Only if it doesn't destroy our fault handlers */
412 if((ht->tt != SP_TRAP_TFLT) &&
413 (ht->tt != SP_TRAP_DFLT))
414 exceptionHandler(ht->tt, trap_low);
415 }
416
417 /* In case GDB is started before us, ack any packets (presumably
418 * "$?#xx") sitting there.
419 *
420 * I've found this code causes more problems than it solves,
421 * so that's why it's commented out. GDB seems to work fine
422 * now starting either before or after the kernel -bwb
423 */
424#if 0
425 while((c = getDebugChar()) != '$');
426 while((c = getDebugChar()) != '#');
427 c = getDebugChar(); /* eat first csum byte */
428 c = getDebugChar(); /* eat second csum byte */
429 putDebugChar('+'); /* ack it */
430#endif
431
432 initialized = 1; /* connect! */
433 local_irq_restore(flags);
434}
435
436/* Convert the SPARC hardware trap type code to a unix signal number. */
437
438static int
439computeSignal(int tt)
440{
441 struct hard_trap_info *ht;
442
443 for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
444 if (ht->tt == tt)
445 return ht->signo;
446
447 return SIGHUP; /* default for things we don't know about */
448}
449
450/*
451 * While we find nice hex chars, build an int.
452 * Return number of chars processed.
453 */
454
455static int
456hexToInt(char **ptr, int *intValue)
457{
458 int numChars = 0;
459 int hexValue;
460
461 *intValue = 0;
462
463 while (**ptr) {
464 hexValue = hex(**ptr);
465 if (hexValue < 0)
466 break;
467
468 *intValue = (*intValue << 4) | hexValue;
469 numChars ++;
470
471 (*ptr)++;
472 }
473
474 return (numChars);
475}
476
477/*
478 * This function does all command processing for interfacing to gdb. It
479 * returns 1 if you should skip the instruction at the trap address, 0
480 * otherwise.
481 */
482
483extern void breakinst(void);
484
485void
486handle_exception (unsigned long *registers)
487{
488 int tt; /* Trap type */
489 int sigval;
490 int addr;
491 int length;
492 char *ptr;
493 unsigned long *sp;
494
495 /* First, we must force all of the windows to be spilled out */
496
497 asm("save %sp, -64, %sp\n\t"
498 "save %sp, -64, %sp\n\t"
499 "save %sp, -64, %sp\n\t"
500 "save %sp, -64, %sp\n\t"
501 "save %sp, -64, %sp\n\t"
502 "save %sp, -64, %sp\n\t"
503 "save %sp, -64, %sp\n\t"
504 "save %sp, -64, %sp\n\t"
505 "restore\n\t"
506 "restore\n\t"
507 "restore\n\t"
508 "restore\n\t"
509 "restore\n\t"
510 "restore\n\t"
511 "restore\n\t"
512 "restore\n\t");
513
514 lock_kernel();
515 if (registers[PC] == (unsigned long)breakinst) {
516 /* Skip over breakpoint trap insn */
517 registers[PC] = registers[NPC];
518 registers[NPC] += 4;
519 }
520
521 sp = (unsigned long *)registers[SP];
522
523 tt = (registers[TBR] >> 4) & 0xff;
524
525 /* reply to host that an exception has occurred */
526 sigval = computeSignal(tt);
527 ptr = remcomOutBuffer;
528
529 *ptr++ = 'T';
530 *ptr++ = hexchars[sigval >> 4];
531 *ptr++ = hexchars[sigval & 0xf];
532
533 *ptr++ = hexchars[PC >> 4];
534 *ptr++ = hexchars[PC & 0xf];
535 *ptr++ = ':';
536 ptr = mem2hex((char *)&registers[PC], ptr, 4);
537 *ptr++ = ';';
538
539 *ptr++ = hexchars[FP >> 4];
540 *ptr++ = hexchars[FP & 0xf];
541 *ptr++ = ':';
542 ptr = mem2hex((char *) (sp + 8 + 6), ptr, 4); /* FP */
543 *ptr++ = ';';
544
545 *ptr++ = hexchars[SP >> 4];
546 *ptr++ = hexchars[SP & 0xf];
547 *ptr++ = ':';
548 ptr = mem2hex((char *)&sp, ptr, 4);
549 *ptr++ = ';';
550
551 *ptr++ = hexchars[NPC >> 4];
552 *ptr++ = hexchars[NPC & 0xf];
553 *ptr++ = ':';
554 ptr = mem2hex((char *)&registers[NPC], ptr, 4);
555 *ptr++ = ';';
556
557 *ptr++ = hexchars[O7 >> 4];
558 *ptr++ = hexchars[O7 & 0xf];
559 *ptr++ = ':';
560 ptr = mem2hex((char *)&registers[O7], ptr, 4);
561 *ptr++ = ';';
562
563 *ptr++ = 0;
564
565 putpacket(remcomOutBuffer);
566
567 /* XXX We may want to add some features dealing with poking the
568 * XXX page tables, the real ones on the srmmu, and what is currently
569 * XXX loaded in the sun4/sun4c tlb at this point in time. But this
570 * XXX also required hacking to the gdb sources directly...
571 */
572
573 while (1) {
574 remcomOutBuffer[0] = 0;
575
576 getpacket(remcomInBuffer);
577 switch (remcomInBuffer[0]) {
578 case '?':
579 remcomOutBuffer[0] = 'S';
580 remcomOutBuffer[1] = hexchars[sigval >> 4];
581 remcomOutBuffer[2] = hexchars[sigval & 0xf];
582 remcomOutBuffer[3] = 0;
583 break;
584
585 case 'd':
586 /* toggle debug flag */
587 break;
588
589 case 'g': /* return the value of the CPU registers */
590 {
591 ptr = remcomOutBuffer;
592 /* G & O regs */
593 ptr = mem2hex((char *)registers, ptr, 16 * 4);
594 /* L & I regs */
595 ptr = mem2hex((char *) (sp + 0), ptr, 16 * 4);
596 /* Floating point */
597 memset(ptr, '0', 32 * 8);
598 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
599 mem2hex((char *)&registers[Y], (ptr + 32 * 4 * 2), (8 * 4));
600 }
601 break;
602
603 case 'G': /* set the value of the CPU registers - return OK */
604 {
605 unsigned long *newsp, psr;
606
607 psr = registers[PSR];
608
609 ptr = &remcomInBuffer[1];
610 /* G & O regs */
611 hex2mem(ptr, (char *)registers, 16 * 4);
612 /* L & I regs */
613 hex2mem(ptr + 16 * 4 * 2, (char *) (sp + 0), 16 * 4);
614 /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
615 hex2mem(ptr + 64 * 4 * 2, (char *)&registers[Y], 8 * 4);
616
617 /* See if the stack pointer has moved. If so,
618 * then copy the saved locals and ins to the
619 * new location. This keeps the window
620 * overflow and underflow routines happy.
621 */
622
623 newsp = (unsigned long *)registers[SP];
624 if (sp != newsp)
625 sp = memcpy(newsp, sp, 16 * 4);
626
627 /* Don't allow CWP to be modified. */
628
629 if (psr != registers[PSR])
630 registers[PSR] = (psr & 0x1f) | (registers[PSR] & ~0x1f);
631
632 strcpy(remcomOutBuffer,"OK");
633 }
634 break;
635
636 case 'm': /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */
637 /* Try to read %x,%x. */
638
639 ptr = &remcomInBuffer[1];
640
641 if (hexToInt(&ptr, &addr)
642 && *ptr++ == ','
643 && hexToInt(&ptr, &length)) {
644 if (mem2hex((char *)addr, remcomOutBuffer, length))
645 break;
646
647 strcpy (remcomOutBuffer, "E03");
648 } else {
649 strcpy(remcomOutBuffer,"E01");
650 }
651 break;
652
653 case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
654 /* Try to read '%x,%x:'. */
655
656 ptr = &remcomInBuffer[1];
657
658 if (hexToInt(&ptr, &addr)
659 && *ptr++ == ','
660 && hexToInt(&ptr, &length)
661 && *ptr++ == ':') {
662 if (hex2mem(ptr, (char *)addr, length)) {
663 strcpy(remcomOutBuffer, "OK");
664 } else {
665 strcpy(remcomOutBuffer, "E03");
666 }
667 } else {
668 strcpy(remcomOutBuffer, "E02");
669 }
670 break;
671
672 case 'c': /* cAA..AA Continue at address AA..AA(optional) */
673 /* try to read optional parameter, pc unchanged if no parm */
674
675 ptr = &remcomInBuffer[1];
676 if (hexToInt(&ptr, &addr)) {
677 registers[PC] = addr;
678 registers[NPC] = addr + 4;
679 }
680
681/* Need to flush the instruction cache here, as we may have deposited a
682 * breakpoint, and the icache probably has no way of knowing that a data ref to
683 * some location may have changed something that is in the instruction cache.
684 */
685 flush_cache_all();
686 unlock_kernel();
687 return;
688
689 /* kill the program */
690 case 'k' : /* do nothing */
691 break;
692 case 'r': /* Reset */
693 asm ("call 0\n\t"
694 "nop\n\t");
695 break;
696 } /* switch */
697
698 /* reply to the request */
699 putpacket(remcomOutBuffer);
700 } /* while(1) */
701}
702
703/* This function will generate a breakpoint exception. It is used at the
704 beginning of a program to sync up with a debugger and can be used
705 otherwise as a quick means to stop program execution and "break" into
706 the debugger. */
707
708void
709breakpoint(void)
710{
711 if (!initialized)
712 return;
713
714 /* Again, watch those c-prefixes for ELF kernels */
715#if defined(__svr4__) || defined(__ELF__)
716 asm(".globl breakinst\n"
717 "breakinst:\n\t"
718 "ta 1\n");
719#else
720 asm(".globl _breakinst\n"
721 "_breakinst:\n\t"
722 "ta 1\n");
723#endif
724}
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 0def48158c7d..dfde77ff0848 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -335,37 +335,6 @@ void smp4d_cross_call_irq(void)
335 ccall_info.processors_out[i] = 1; 335 ccall_info.processors_out[i] = 1;
336} 336}
337 337
338static int smp4d_stop_cpu_sender;
339
340static void smp4d_stop_cpu(void)
341{
342 int me = hard_smp4d_processor_id();
343
344 if (me != smp4d_stop_cpu_sender)
345 while(1) barrier();
346}
347
348/* Cross calls, in order to work efficiently and atomically do all
349 * the message passing work themselves, only stopcpu and reschedule
350 * messages come through here.
351 */
352void smp4d_message_pass(int target, int msg, unsigned long data, int wait)
353{
354 int me = hard_smp4d_processor_id();
355
356 SMP_PRINTK(("smp4d_message_pass %d %d %08lx %d\n", target, msg, data, wait));
357 if (msg == MSG_STOP_CPU && target == MSG_ALL_BUT_SELF) {
358 unsigned long flags;
359 static DEFINE_SPINLOCK(stop_cpu_lock);
360 spin_lock_irqsave(&stop_cpu_lock, flags);
361 smp4d_stop_cpu_sender = me;
362 smp4d_cross_call((smpfunc_t)smp4d_stop_cpu, 0, 0, 0, 0, 0);
363 spin_unlock_irqrestore(&stop_cpu_lock, flags);
364 }
365 printk("Yeeee, trying to send SMP msg(%d) to %d on cpu %d\n", msg, target, me);
366 panic("Bogon SMP message pass.");
367}
368
369void smp4d_percpu_timer_interrupt(struct pt_regs *regs) 338void smp4d_percpu_timer_interrupt(struct pt_regs *regs)
370{ 339{
371 struct pt_regs *old_regs; 340 struct pt_regs *old_regs;
@@ -439,7 +408,6 @@ void __init sun4d_init_smp(void)
439 BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id); 408 BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4d_blackbox_id);
440 BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current); 409 BTFIXUPSET_BLACKBOX(load_current, smp4d_blackbox_current);
441 BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM); 410 BTFIXUPSET_CALL(smp_cross_call, smp4d_cross_call, BTFIXUPCALL_NORM);
442 BTFIXUPSET_CALL(smp_message_pass, smp4d_message_pass, BTFIXUPCALL_NORM);
443 BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM); 411 BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4d_processor_id, BTFIXUPCALL_NORM);
444 412
445 for (i = 0; i < NR_CPUS; i++) { 413 for (i = 0; i < NR_CPUS; i++) {
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 0b9407267162..ffb875aacb7e 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -34,8 +34,6 @@
34 34
35#include "irq.h" 35#include "irq.h"
36 36
37#define IRQ_RESCHEDULE 13
38#define IRQ_STOP_CPU 14
39#define IRQ_CROSS_CALL 15 37#define IRQ_CROSS_CALL 15
40 38
41extern ctxd_t *srmmu_ctx_table_phys; 39extern ctxd_t *srmmu_ctx_table_phys;
@@ -232,48 +230,6 @@ void smp4m_irq_rotate(int cpu)
232 set_irq_udt(next); 230 set_irq_udt(next);
233} 231}
234 232
235/* Cross calls, in order to work efficiently and atomically do all
236 * the message passing work themselves, only stopcpu and reschedule
237 * messages come through here.
238 */
239void smp4m_message_pass(int target, int msg, unsigned long data, int wait)
240{
241 static unsigned long smp_cpu_in_msg[NR_CPUS];
242 cpumask_t mask;
243 int me = smp_processor_id();
244 int irq, i;
245
246 if(msg == MSG_RESCHEDULE) {
247 irq = IRQ_RESCHEDULE;
248
249 if(smp_cpu_in_msg[me])
250 return;
251 } else if(msg == MSG_STOP_CPU) {
252 irq = IRQ_STOP_CPU;
253 } else {
254 goto barf;
255 }
256
257 smp_cpu_in_msg[me]++;
258 if(target == MSG_ALL_BUT_SELF || target == MSG_ALL) {
259 mask = cpu_online_map;
260 if(target == MSG_ALL_BUT_SELF)
261 cpu_clear(me, mask);
262 for(i = 0; i < 4; i++) {
263 if (cpu_isset(i, mask))
264 set_cpu_int(i, irq);
265 }
266 } else {
267 set_cpu_int(target, irq);
268 }
269 smp_cpu_in_msg[me]--;
270
271 return;
272barf:
273 printk("Yeeee, trying to send SMP msg(%d) on cpu %d\n", msg, me);
274 panic("Bogon SMP message pass.");
275}
276
277static struct smp_funcall { 233static struct smp_funcall {
278 smpfunc_t func; 234 smpfunc_t func;
279 unsigned long arg1; 235 unsigned long arg1;
@@ -413,6 +369,5 @@ void __init sun4m_init_smp(void)
413 BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4m_blackbox_id); 369 BTFIXUPSET_BLACKBOX(hard_smp_processor_id, smp4m_blackbox_id);
414 BTFIXUPSET_BLACKBOX(load_current, smp4m_blackbox_current); 370 BTFIXUPSET_BLACKBOX(load_current, smp4m_blackbox_current);
415 BTFIXUPSET_CALL(smp_cross_call, smp4m_cross_call, BTFIXUPCALL_NORM); 371 BTFIXUPSET_CALL(smp_cross_call, smp4m_cross_call, BTFIXUPCALL_NORM);
416 BTFIXUPSET_CALL(smp_message_pass, smp4m_message_pass, BTFIXUPCALL_NORM);
417 BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4m_processor_id, BTFIXUPCALL_NORM); 372 BTFIXUPSET_CALL(__hard_smp_processor_id, __smp4m_processor_id, BTFIXUPCALL_NORM);
418} 373}
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index edbe71e3fab9..eb36f3b746b8 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -13,6 +13,7 @@ config SPARC64
13 default y 13 default y
14 select HAVE_IDE 14 select HAVE_IDE
15 select HAVE_LMB 15 select HAVE_LMB
16 select HAVE_ARCH_KGDB
16 17
17config GENERIC_TIME 18config GENERIC_TIME
18 bool 19 bool
diff --git a/arch/sparc64/kernel/Makefile b/arch/sparc64/kernel/Makefile
index 2bd0340b743d..ec4f5ebb1ca6 100644
--- a/arch/sparc64/kernel/Makefile
+++ b/arch/sparc64/kernel/Makefile
@@ -29,3 +29,4 @@ obj-$(CONFIG_SUN_LDOMS) += ldc.o vio.o viohs.o ds.o
29obj-$(CONFIG_AUDIT) += audit.o 29obj-$(CONFIG_AUDIT) += audit.o
30obj-$(CONFIG_AUDIT)$(CONFIG_COMPAT) += compat_audit.o 30obj-$(CONFIG_AUDIT)$(CONFIG_COMPAT) += compat_audit.o
31obj-y += $(obj-yy) 31obj-y += $(obj-yy)
32obj-$(CONFIG_KGDB) += kgdb.o
diff --git a/arch/sparc64/kernel/cherrs.S b/arch/sparc64/kernel/cherrs.S
new file mode 100644
index 000000000000..89afebd7eca0
--- /dev/null
+++ b/arch/sparc64/kernel/cherrs.S
@@ -0,0 +1,579 @@
1 /* These get patched into the trap table at boot time
2 * once we know we have a cheetah processor.
3 */
4 .globl cheetah_fecc_trap_vector
5 .type cheetah_fecc_trap_vector,#function
6cheetah_fecc_trap_vector:
7 membar #Sync
8 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
9 andn %g1, DCU_DC | DCU_IC, %g1
10 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
11 membar #Sync
12 sethi %hi(cheetah_fast_ecc), %g2
13 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
14 mov 0, %g1
15 .size cheetah_fecc_trap_vector,.-cheetah_fecc_trap_vector
16
17 .globl cheetah_fecc_trap_vector_tl1
18 .type cheetah_fecc_trap_vector_tl1,#function
19cheetah_fecc_trap_vector_tl1:
20 membar #Sync
21 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
22 andn %g1, DCU_DC | DCU_IC, %g1
23 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
24 membar #Sync
25 sethi %hi(cheetah_fast_ecc), %g2
26 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
27 mov 1, %g1
28 .size cheetah_fecc_trap_vector_tl1,.-cheetah_fecc_trap_vector_tl1
29
30 .globl cheetah_cee_trap_vector
31 .type cheetah_cee_trap_vector,#function
32cheetah_cee_trap_vector:
33 membar #Sync
34 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
35 andn %g1, DCU_IC, %g1
36 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
37 membar #Sync
38 sethi %hi(cheetah_cee), %g2
39 jmpl %g2 + %lo(cheetah_cee), %g0
40 mov 0, %g1
41 .size cheetah_cee_trap_vector,.-cheetah_cee_trap_vector
42
43 .globl cheetah_cee_trap_vector_tl1
44 .type cheetah_cee_trap_vector_tl1,#function
45cheetah_cee_trap_vector_tl1:
46 membar #Sync
47 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
48 andn %g1, DCU_IC, %g1
49 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
50 membar #Sync
51 sethi %hi(cheetah_cee), %g2
52 jmpl %g2 + %lo(cheetah_cee), %g0
53 mov 1, %g1
54 .size cheetah_cee_trap_vector_tl1,.-cheetah_cee_trap_vector_tl1
55
56 .globl cheetah_deferred_trap_vector
57 .type cheetah_deferred_trap_vector,#function
58cheetah_deferred_trap_vector:
59 membar #Sync
60 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
61 andn %g1, DCU_DC | DCU_IC, %g1;
62 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
63 membar #Sync;
64 sethi %hi(cheetah_deferred_trap), %g2
65 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
66 mov 0, %g1
67 .size cheetah_deferred_trap_vector,.-cheetah_deferred_trap_vector
68
69 .globl cheetah_deferred_trap_vector_tl1
70 .type cheetah_deferred_trap_vector_tl1,#function
71cheetah_deferred_trap_vector_tl1:
72 membar #Sync;
73 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
74 andn %g1, DCU_DC | DCU_IC, %g1;
75 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
76 membar #Sync;
77 sethi %hi(cheetah_deferred_trap), %g2
78 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
79 mov 1, %g1
80 .size cheetah_deferred_trap_vector_tl1,.-cheetah_deferred_trap_vector_tl1
81
82 /* Cheetah+ specific traps. These are for the new I/D cache parity
83 * error traps. The first argument to cheetah_plus_parity_handler
84 * is encoded as follows:
85 *
86 * Bit0: 0=dcache,1=icache
87 * Bit1: 0=recoverable,1=unrecoverable
88 */
89 .globl cheetah_plus_dcpe_trap_vector
90 .type cheetah_plus_dcpe_trap_vector,#function
91cheetah_plus_dcpe_trap_vector:
92 membar #Sync
93 sethi %hi(do_cheetah_plus_data_parity), %g7
94 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
95 nop
96 nop
97 nop
98 nop
99 nop
100 .size cheetah_plus_dcpe_trap_vector,.-cheetah_plus_dcpe_trap_vector
101
102 .type do_cheetah_plus_data_parity,#function
103do_cheetah_plus_data_parity:
104 rdpr %pil, %g2
105 wrpr %g0, 15, %pil
106 ba,pt %xcc, etrap_irq
107 rd %pc, %g7
108#ifdef CONFIG_TRACE_IRQFLAGS
109 call trace_hardirqs_off
110 nop
111#endif
112 mov 0x0, %o0
113 call cheetah_plus_parity_error
114 add %sp, PTREGS_OFF, %o1
115 ba,a,pt %xcc, rtrap_irq
116 .size do_cheetah_plus_data_parity,.-do_cheetah_plus_data_parity
117
118 .globl cheetah_plus_dcpe_trap_vector_tl1
119 .type cheetah_plus_dcpe_trap_vector_tl1,#function
120cheetah_plus_dcpe_trap_vector_tl1:
121 membar #Sync
122 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
123 sethi %hi(do_dcpe_tl1), %g3
124 jmpl %g3 + %lo(do_dcpe_tl1), %g0
125 nop
126 nop
127 nop
128 nop
129 .size cheetah_plus_dcpe_trap_vector_tl1,.-cheetah_plus_dcpe_trap_vector_tl1
130
131 .globl cheetah_plus_icpe_trap_vector
132 .type cheetah_plus_icpe_trap_vector,#function
133cheetah_plus_icpe_trap_vector:
134 membar #Sync
135 sethi %hi(do_cheetah_plus_insn_parity), %g7
136 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
137 nop
138 nop
139 nop
140 nop
141 nop
142 .size cheetah_plus_icpe_trap_vector,.-cheetah_plus_icpe_trap_vector
143
144 .type do_cheetah_plus_insn_parity,#function
145do_cheetah_plus_insn_parity:
146 rdpr %pil, %g2
147 wrpr %g0, 15, %pil
148 ba,pt %xcc, etrap_irq
149 rd %pc, %g7
150#ifdef CONFIG_TRACE_IRQFLAGS
151 call trace_hardirqs_off
152 nop
153#endif
154 mov 0x1, %o0
155 call cheetah_plus_parity_error
156 add %sp, PTREGS_OFF, %o1
157 ba,a,pt %xcc, rtrap_irq
158 .size do_cheetah_plus_insn_parity,.-do_cheetah_plus_insn_parity
159
160 .globl cheetah_plus_icpe_trap_vector_tl1
161 .type cheetah_plus_icpe_trap_vector_tl1,#function
162cheetah_plus_icpe_trap_vector_tl1:
163 membar #Sync
164 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
165 sethi %hi(do_icpe_tl1), %g3
166 jmpl %g3 + %lo(do_icpe_tl1), %g0
167 nop
168 nop
169 nop
170 nop
171 .size cheetah_plus_icpe_trap_vector_tl1,.-cheetah_plus_icpe_trap_vector_tl1
172
173 /* If we take one of these traps when tl >= 1, then we
174 * jump to interrupt globals. If some trap level above us
175 * was also using interrupt globals, we cannot recover.
176 * We may use all interrupt global registers except %g6.
177 */
178 .globl do_dcpe_tl1
179 .type do_dcpe_tl1,#function
180do_dcpe_tl1:
181 rdpr %tl, %g1 ! Save original trap level
182 mov 1, %g2 ! Setup TSTATE checking loop
183 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
1841: wrpr %g2, %tl ! Set trap level to check
185 rdpr %tstate, %g4 ! Read TSTATE for this level
186 andcc %g4, %g3, %g0 ! Interrupt globals in use?
187 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
188 wrpr %g1, %tl ! Restore original trap level
189 add %g2, 1, %g2 ! Next trap level
190 cmp %g2, %g1 ! Hit them all yet?
191 ble,pt %icc, 1b ! Not yet
192 nop
193 wrpr %g1, %tl ! Restore original trap level
194do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
195 sethi %hi(dcache_parity_tl1_occurred), %g2
196 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
197 add %g1, 1, %g1
198 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
199 /* Reset D-cache parity */
200 sethi %hi(1 << 16), %g1 ! D-cache size
201 mov (1 << 5), %g2 ! D-cache line size
202 sub %g1, %g2, %g1 ! Move down 1 cacheline
2031: srl %g1, 14, %g3 ! Compute UTAG
204 membar #Sync
205 stxa %g3, [%g1] ASI_DCACHE_UTAG
206 membar #Sync
207 sub %g2, 8, %g3 ! 64-bit data word within line
2082: membar #Sync
209 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
210 membar #Sync
211 subcc %g3, 8, %g3 ! Next 64-bit data word
212 bge,pt %icc, 2b
213 nop
214 subcc %g1, %g2, %g1 ! Next cacheline
215 bge,pt %icc, 1b
216 nop
217 ba,pt %xcc, dcpe_icpe_tl1_common
218 nop
219
220do_dcpe_tl1_fatal:
221 sethi %hi(1f), %g7
222 ba,pt %xcc, etraptl1
2231: or %g7, %lo(1b), %g7
224 mov 0x2, %o0
225 call cheetah_plus_parity_error
226 add %sp, PTREGS_OFF, %o1
227 ba,pt %xcc, rtrap
228 nop
229 .size do_dcpe_tl1,.-do_dcpe_tl1
230
231 .globl do_icpe_tl1
232 .type do_icpe_tl1,#function
233do_icpe_tl1:
234 rdpr %tl, %g1 ! Save original trap level
235 mov 1, %g2 ! Setup TSTATE checking loop
236 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
2371: wrpr %g2, %tl ! Set trap level to check
238 rdpr %tstate, %g4 ! Read TSTATE for this level
239 andcc %g4, %g3, %g0 ! Interrupt globals in use?
240 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
241 wrpr %g1, %tl ! Restore original trap level
242 add %g2, 1, %g2 ! Next trap level
243 cmp %g2, %g1 ! Hit them all yet?
244 ble,pt %icc, 1b ! Not yet
245 nop
246 wrpr %g1, %tl ! Restore original trap level
247do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
248 sethi %hi(icache_parity_tl1_occurred), %g2
249 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
250 add %g1, 1, %g1
251 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
252 /* Flush I-cache */
253 sethi %hi(1 << 15), %g1 ! I-cache size
254 mov (1 << 5), %g2 ! I-cache line size
255 sub %g1, %g2, %g1
2561: or %g1, (2 << 3), %g3
257 stxa %g0, [%g3] ASI_IC_TAG
258 membar #Sync
259 subcc %g1, %g2, %g1
260 bge,pt %icc, 1b
261 nop
262 ba,pt %xcc, dcpe_icpe_tl1_common
263 nop
264
265do_icpe_tl1_fatal:
266 sethi %hi(1f), %g7
267 ba,pt %xcc, etraptl1
2681: or %g7, %lo(1b), %g7
269 mov 0x3, %o0
270 call cheetah_plus_parity_error
271 add %sp, PTREGS_OFF, %o1
272 ba,pt %xcc, rtrap
273 nop
274 .size do_icpe_tl1,.-do_icpe_tl1
275
276 .type dcpe_icpe_tl1_common,#function
277dcpe_icpe_tl1_common:
278 /* Flush D-cache, re-enable D/I caches in DCU and finally
279 * retry the trapping instruction.
280 */
281 sethi %hi(1 << 16), %g1 ! D-cache size
282 mov (1 << 5), %g2 ! D-cache line size
283 sub %g1, %g2, %g1
2841: stxa %g0, [%g1] ASI_DCACHE_TAG
285 membar #Sync
286 subcc %g1, %g2, %g1
287 bge,pt %icc, 1b
288 nop
289 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
290 or %g1, (DCU_DC | DCU_IC), %g1
291 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
292 membar #Sync
293 retry
294 .size dcpe_icpe_tl1_common,.-dcpe_icpe_tl1_common
295
296 /* Capture I/D/E-cache state into per-cpu error scoreboard.
297 *
298 * %g1: (TL>=0) ? 1 : 0
299 * %g2: scratch
300 * %g3: scratch
301 * %g4: AFSR
302 * %g5: AFAR
303 * %g6: unused, will have current thread ptr after etrap
304 * %g7: scratch
305 */
306 .type __cheetah_log_error,#function
307__cheetah_log_error:
308 /* Put "TL1" software bit into AFSR. */
309 and %g1, 0x1, %g1
310 sllx %g1, 63, %g2
311 or %g4, %g2, %g4
312
313 /* Get log entry pointer for this cpu at this trap level. */
314 BRANCH_IF_JALAPENO(g2,g3,50f)
315 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
316 srlx %g2, 17, %g2
317 ba,pt %xcc, 60f
318 and %g2, 0x3ff, %g2
319
32050: ldxa [%g0] ASI_JBUS_CONFIG, %g2
321 srlx %g2, 17, %g2
322 and %g2, 0x1f, %g2
323
32460: sllx %g2, 9, %g2
325 sethi %hi(cheetah_error_log), %g3
326 ldx [%g3 + %lo(cheetah_error_log)], %g3
327 brz,pn %g3, 80f
328 nop
329
330 add %g3, %g2, %g3
331 sllx %g1, 8, %g1
332 add %g3, %g1, %g1
333
334 /* %g1 holds pointer to the top of the logging scoreboard */
335 ldx [%g1 + 0x0], %g7
336 cmp %g7, -1
337 bne,pn %xcc, 80f
338 nop
339
340 stx %g4, [%g1 + 0x0]
341 stx %g5, [%g1 + 0x8]
342 add %g1, 0x10, %g1
343
344 /* %g1 now points to D-cache logging area */
345 set 0x3ff8, %g2 /* DC_addr mask */
346 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
347 srlx %g5, 12, %g3
348 or %g3, 1, %g3 /* PHYS tag + valid */
349
35010: ldxa [%g2] ASI_DCACHE_TAG, %g7
351 cmp %g3, %g7 /* TAG match? */
352 bne,pt %xcc, 13f
353 nop
354
355 /* Yep, what we want, capture state. */
356 stx %g2, [%g1 + 0x20]
357 stx %g7, [%g1 + 0x28]
358
359 /* A membar Sync is required before and after utag access. */
360 membar #Sync
361 ldxa [%g2] ASI_DCACHE_UTAG, %g7
362 membar #Sync
363 stx %g7, [%g1 + 0x30]
364 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
365 stx %g7, [%g1 + 0x38]
366 clr %g3
367
36812: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
369 stx %g7, [%g1]
370 add %g3, (1 << 5), %g3
371 cmp %g3, (4 << 5)
372 bl,pt %xcc, 12b
373 add %g1, 0x8, %g1
374
375 ba,pt %xcc, 20f
376 add %g1, 0x20, %g1
377
37813: sethi %hi(1 << 14), %g7
379 add %g2, %g7, %g2
380 srlx %g2, 14, %g7
381 cmp %g7, 4
382 bl,pt %xcc, 10b
383 nop
384
385 add %g1, 0x40, %g1
386
387 /* %g1 now points to I-cache logging area */
38820: set 0x1fe0, %g2 /* IC_addr mask */
389 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
390 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
391 srlx %g5, (13 - 8), %g3 /* Make PTAG */
392 andn %g3, 0xff, %g3 /* Mask off undefined bits */
393
39421: ldxa [%g2] ASI_IC_TAG, %g7
395 andn %g7, 0xff, %g7
396 cmp %g3, %g7
397 bne,pt %xcc, 23f
398 nop
399
400 /* Yep, what we want, capture state. */
401 stx %g2, [%g1 + 0x40]
402 stx %g7, [%g1 + 0x48]
403 add %g2, (1 << 3), %g2
404 ldxa [%g2] ASI_IC_TAG, %g7
405 add %g2, (1 << 3), %g2
406 stx %g7, [%g1 + 0x50]
407 ldxa [%g2] ASI_IC_TAG, %g7
408 add %g2, (1 << 3), %g2
409 stx %g7, [%g1 + 0x60]
410 ldxa [%g2] ASI_IC_TAG, %g7
411 stx %g7, [%g1 + 0x68]
412 sub %g2, (3 << 3), %g2
413 ldxa [%g2] ASI_IC_STAG, %g7
414 stx %g7, [%g1 + 0x58]
415 clr %g3
416 srlx %g2, 2, %g2
417
41822: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
419 stx %g7, [%g1]
420 add %g3, (1 << 3), %g3
421 cmp %g3, (8 << 3)
422 bl,pt %xcc, 22b
423 add %g1, 0x8, %g1
424
425 ba,pt %xcc, 30f
426 add %g1, 0x30, %g1
427
42823: sethi %hi(1 << 14), %g7
429 add %g2, %g7, %g2
430 srlx %g2, 14, %g7
431 cmp %g7, 4
432 bl,pt %xcc, 21b
433 nop
434
435 add %g1, 0x70, %g1
436
437 /* %g1 now points to E-cache logging area */
43830: andn %g5, (32 - 1), %g2
439 stx %g2, [%g1 + 0x20]
440 ldxa [%g2] ASI_EC_TAG_DATA, %g7
441 stx %g7, [%g1 + 0x28]
442 ldxa [%g2] ASI_EC_R, %g0
443 clr %g3
444
44531: ldxa [%g3] ASI_EC_DATA, %g7
446 stx %g7, [%g1 + %g3]
447 add %g3, 0x8, %g3
448 cmp %g3, 0x20
449
450 bl,pt %xcc, 31b
451 nop
45280:
453 rdpr %tt, %g2
454 cmp %g2, 0x70
455 be c_fast_ecc
456 cmp %g2, 0x63
457 be c_cee
458 nop
459 ba,pt %xcc, c_deferred
460 .size __cheetah_log_error,.-__cheetah_log_error
461
462 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
463 * in the trap table. That code has done a memory barrier
464 * and has disabled both the I-cache and D-cache in the DCU
465 * control register. The I-cache is disabled so that we may
466 * capture the corrupted cache line, and the D-cache is disabled
467 * because corrupt data may have been placed there and we don't
468 * want to reference it.
469 *
470 * %g1 is one if this trap occurred at %tl >= 1.
471 *
472 * Next, we turn off error reporting so that we don't recurse.
473 */
474 .globl cheetah_fast_ecc
475 .type cheetah_fast_ecc,#function
476cheetah_fast_ecc:
477 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
478 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
479 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
480 membar #Sync
481
482 /* Fetch and clear AFSR/AFAR */
483 ldxa [%g0] ASI_AFSR, %g4
484 ldxa [%g0] ASI_AFAR, %g5
485 stxa %g4, [%g0] ASI_AFSR
486 membar #Sync
487
488 ba,pt %xcc, __cheetah_log_error
489 nop
490 .size cheetah_fast_ecc,.-cheetah_fast_ecc
491
492 .type c_fast_ecc,#function
493c_fast_ecc:
494 rdpr %pil, %g2
495 wrpr %g0, 15, %pil
496 ba,pt %xcc, etrap_irq
497 rd %pc, %g7
498#ifdef CONFIG_TRACE_IRQFLAGS
499 call trace_hardirqs_off
500 nop
501#endif
502 mov %l4, %o1
503 mov %l5, %o2
504 call cheetah_fecc_handler
505 add %sp, PTREGS_OFF, %o0
506 ba,a,pt %xcc, rtrap_irq
507 .size c_fast_ecc,.-c_fast_ecc
508
509 /* Our caller has disabled I-cache and performed membar Sync. */
510 .globl cheetah_cee
511 .type cheetah_cee,#function
512cheetah_cee:
513 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
514 andn %g2, ESTATE_ERROR_CEEN, %g2
515 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
516 membar #Sync
517
518 /* Fetch and clear AFSR/AFAR */
519 ldxa [%g0] ASI_AFSR, %g4
520 ldxa [%g0] ASI_AFAR, %g5
521 stxa %g4, [%g0] ASI_AFSR
522 membar #Sync
523
524 ba,pt %xcc, __cheetah_log_error
525 nop
526 .size cheetah_cee,.-cheetah_cee
527
528 .type c_cee,#function
529c_cee:
530 rdpr %pil, %g2
531 wrpr %g0, 15, %pil
532 ba,pt %xcc, etrap_irq
533 rd %pc, %g7
534#ifdef CONFIG_TRACE_IRQFLAGS
535 call trace_hardirqs_off
536 nop
537#endif
538 mov %l4, %o1
539 mov %l5, %o2
540 call cheetah_cee_handler
541 add %sp, PTREGS_OFF, %o0
542 ba,a,pt %xcc, rtrap_irq
543 .size c_cee,.-c_cee
544
545 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
546 .globl cheetah_deferred_trap
547 .type cheetah_deferred_trap,#function
548cheetah_deferred_trap:
549 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
550 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
551 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
552 membar #Sync
553
554 /* Fetch and clear AFSR/AFAR */
555 ldxa [%g0] ASI_AFSR, %g4
556 ldxa [%g0] ASI_AFAR, %g5
557 stxa %g4, [%g0] ASI_AFSR
558 membar #Sync
559
560 ba,pt %xcc, __cheetah_log_error
561 nop
562 .size cheetah_deferred_trap,.-cheetah_deferred_trap
563
564 .type c_deferred,#function
565c_deferred:
566 rdpr %pil, %g2
567 wrpr %g0, 15, %pil
568 ba,pt %xcc, etrap_irq
569 rd %pc, %g7
570#ifdef CONFIG_TRACE_IRQFLAGS
571 call trace_hardirqs_off
572 nop
573#endif
574 mov %l4, %o1
575 mov %l5, %o2
576 call cheetah_deferred_handler
577 add %sp, PTREGS_OFF, %o0
578 ba,a,pt %xcc, rtrap_irq
579 .size c_deferred,.-c_deferred
diff --git a/arch/sparc64/kernel/entry.S b/arch/sparc64/kernel/entry.S
deleted file mode 100644
index fd06e937ae1e..000000000000
--- a/arch/sparc64/kernel/entry.S
+++ /dev/null
@@ -1,2575 +0,0 @@
1/* $Id: entry.S,v 1.144 2002/02/09 19:49:30 davem Exp $
2 * arch/sparc64/kernel/entry.S: Sparc64 trap low-level entry points.
3 *
4 * Copyright (C) 1995,1997 David S. Miller (davem@caip.rutgers.edu)
5 * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx)
7 * Copyright (C) 1996,98,99 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 */
9
10#include <linux/errno.h>
11
12#include <asm/head.h>
13#include <asm/asi.h>
14#include <asm/smp.h>
15#include <asm/ptrace.h>
16#include <asm/page.h>
17#include <asm/signal.h>
18#include <asm/pgtable.h>
19#include <asm/processor.h>
20#include <asm/visasm.h>
21#include <asm/estate.h>
22#include <asm/auxio.h>
23#include <asm/sfafsr.h>
24#include <asm/pil.h>
25#include <asm/unistd.h>
26
27#define curptr g6
28
29 .text
30 .align 32
31
32 /* This is trivial with the new code... */
33 .globl do_fpdis
34do_fpdis:
35 sethi %hi(TSTATE_PEF), %g4
36 rdpr %tstate, %g5
37 andcc %g5, %g4, %g0
38 be,pt %xcc, 1f
39 nop
40 rd %fprs, %g5
41 andcc %g5, FPRS_FEF, %g0
42 be,pt %xcc, 1f
43 nop
44
45 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
46 sethi %hi(109f), %g7
47 ba,pt %xcc, etrap
48109: or %g7, %lo(109b), %g7
49 add %g0, %g0, %g0
50 ba,a,pt %xcc, rtrap
51
521: TRAP_LOAD_THREAD_REG(%g6, %g1)
53 ldub [%g6 + TI_FPSAVED], %g5
54 wr %g0, FPRS_FEF, %fprs
55 andcc %g5, FPRS_FEF, %g0
56 be,a,pt %icc, 1f
57 clr %g7
58 ldx [%g6 + TI_GSR], %g7
591: andcc %g5, FPRS_DL, %g0
60 bne,pn %icc, 2f
61 fzero %f0
62 andcc %g5, FPRS_DU, %g0
63 bne,pn %icc, 1f
64 fzero %f2
65 faddd %f0, %f2, %f4
66 fmuld %f0, %f2, %f6
67 faddd %f0, %f2, %f8
68 fmuld %f0, %f2, %f10
69 faddd %f0, %f2, %f12
70 fmuld %f0, %f2, %f14
71 faddd %f0, %f2, %f16
72 fmuld %f0, %f2, %f18
73 faddd %f0, %f2, %f20
74 fmuld %f0, %f2, %f22
75 faddd %f0, %f2, %f24
76 fmuld %f0, %f2, %f26
77 faddd %f0, %f2, %f28
78 fmuld %f0, %f2, %f30
79 faddd %f0, %f2, %f32
80 fmuld %f0, %f2, %f34
81 faddd %f0, %f2, %f36
82 fmuld %f0, %f2, %f38
83 faddd %f0, %f2, %f40
84 fmuld %f0, %f2, %f42
85 faddd %f0, %f2, %f44
86 fmuld %f0, %f2, %f46
87 faddd %f0, %f2, %f48
88 fmuld %f0, %f2, %f50
89 faddd %f0, %f2, %f52
90 fmuld %f0, %f2, %f54
91 faddd %f0, %f2, %f56
92 fmuld %f0, %f2, %f58
93 b,pt %xcc, fpdis_exit2
94 faddd %f0, %f2, %f60
951: mov SECONDARY_CONTEXT, %g3
96 add %g6, TI_FPREGS + 0x80, %g1
97 faddd %f0, %f2, %f4
98 fmuld %f0, %f2, %f6
99
100661: ldxa [%g3] ASI_DMMU, %g5
101 .section .sun4v_1insn_patch, "ax"
102 .word 661b
103 ldxa [%g3] ASI_MMU, %g5
104 .previous
105
106 sethi %hi(sparc64_kern_sec_context), %g2
107 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
108
109661: stxa %g2, [%g3] ASI_DMMU
110 .section .sun4v_1insn_patch, "ax"
111 .word 661b
112 stxa %g2, [%g3] ASI_MMU
113 .previous
114
115 membar #Sync
116 add %g6, TI_FPREGS + 0xc0, %g2
117 faddd %f0, %f2, %f8
118 fmuld %f0, %f2, %f10
119 membar #Sync
120 ldda [%g1] ASI_BLK_S, %f32
121 ldda [%g2] ASI_BLK_S, %f48
122 membar #Sync
123 faddd %f0, %f2, %f12
124 fmuld %f0, %f2, %f14
125 faddd %f0, %f2, %f16
126 fmuld %f0, %f2, %f18
127 faddd %f0, %f2, %f20
128 fmuld %f0, %f2, %f22
129 faddd %f0, %f2, %f24
130 fmuld %f0, %f2, %f26
131 faddd %f0, %f2, %f28
132 fmuld %f0, %f2, %f30
133 b,pt %xcc, fpdis_exit
134 nop
1352: andcc %g5, FPRS_DU, %g0
136 bne,pt %icc, 3f
137 fzero %f32
138 mov SECONDARY_CONTEXT, %g3
139 fzero %f34
140
141661: ldxa [%g3] ASI_DMMU, %g5
142 .section .sun4v_1insn_patch, "ax"
143 .word 661b
144 ldxa [%g3] ASI_MMU, %g5
145 .previous
146
147 add %g6, TI_FPREGS, %g1
148 sethi %hi(sparc64_kern_sec_context), %g2
149 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
150
151661: stxa %g2, [%g3] ASI_DMMU
152 .section .sun4v_1insn_patch, "ax"
153 .word 661b
154 stxa %g2, [%g3] ASI_MMU
155 .previous
156
157 membar #Sync
158 add %g6, TI_FPREGS + 0x40, %g2
159 faddd %f32, %f34, %f36
160 fmuld %f32, %f34, %f38
161 membar #Sync
162 ldda [%g1] ASI_BLK_S, %f0
163 ldda [%g2] ASI_BLK_S, %f16
164 membar #Sync
165 faddd %f32, %f34, %f40
166 fmuld %f32, %f34, %f42
167 faddd %f32, %f34, %f44
168 fmuld %f32, %f34, %f46
169 faddd %f32, %f34, %f48
170 fmuld %f32, %f34, %f50
171 faddd %f32, %f34, %f52
172 fmuld %f32, %f34, %f54
173 faddd %f32, %f34, %f56
174 fmuld %f32, %f34, %f58
175 faddd %f32, %f34, %f60
176 fmuld %f32, %f34, %f62
177 ba,pt %xcc, fpdis_exit
178 nop
1793: mov SECONDARY_CONTEXT, %g3
180 add %g6, TI_FPREGS, %g1
181
182661: ldxa [%g3] ASI_DMMU, %g5
183 .section .sun4v_1insn_patch, "ax"
184 .word 661b
185 ldxa [%g3] ASI_MMU, %g5
186 .previous
187
188 sethi %hi(sparc64_kern_sec_context), %g2
189 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
190
191661: stxa %g2, [%g3] ASI_DMMU
192 .section .sun4v_1insn_patch, "ax"
193 .word 661b
194 stxa %g2, [%g3] ASI_MMU
195 .previous
196
197 membar #Sync
198 mov 0x40, %g2
199 membar #Sync
200 ldda [%g1] ASI_BLK_S, %f0
201 ldda [%g1 + %g2] ASI_BLK_S, %f16
202 add %g1, 0x80, %g1
203 ldda [%g1] ASI_BLK_S, %f32
204 ldda [%g1 + %g2] ASI_BLK_S, %f48
205 membar #Sync
206fpdis_exit:
207
208661: stxa %g5, [%g3] ASI_DMMU
209 .section .sun4v_1insn_patch, "ax"
210 .word 661b
211 stxa %g5, [%g3] ASI_MMU
212 .previous
213
214 membar #Sync
215fpdis_exit2:
216 wr %g7, 0, %gsr
217 ldx [%g6 + TI_XFSR], %fsr
218 rdpr %tstate, %g3
219 or %g3, %g4, %g3 ! anal...
220 wrpr %g3, %tstate
221 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
222 retry
223
224 .align 32
225fp_other_bounce:
226 call do_fpother
227 add %sp, PTREGS_OFF, %o0
228 ba,pt %xcc, rtrap
229 nop
230
231 .globl do_fpother_check_fitos
232 .align 32
233do_fpother_check_fitos:
234 TRAP_LOAD_THREAD_REG(%g6, %g1)
235 sethi %hi(fp_other_bounce - 4), %g7
236 or %g7, %lo(fp_other_bounce - 4), %g7
237
238 /* NOTE: Need to preserve %g7 until we fully commit
239 * to the fitos fixup.
240 */
241 stx %fsr, [%g6 + TI_XFSR]
242 rdpr %tstate, %g3
243 andcc %g3, TSTATE_PRIV, %g0
244 bne,pn %xcc, do_fptrap_after_fsr
245 nop
246 ldx [%g6 + TI_XFSR], %g3
247 srlx %g3, 14, %g1
248 and %g1, 7, %g1
249 cmp %g1, 2 ! Unfinished FP-OP
250 bne,pn %xcc, do_fptrap_after_fsr
251 sethi %hi(1 << 23), %g1 ! Inexact
252 andcc %g3, %g1, %g0
253 bne,pn %xcc, do_fptrap_after_fsr
254 rdpr %tpc, %g1
255 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
256#define FITOS_MASK 0xc1f83fe0
257#define FITOS_COMPARE 0x81a01880
258 sethi %hi(FITOS_MASK), %g1
259 or %g1, %lo(FITOS_MASK), %g1
260 and %g3, %g1, %g1
261 sethi %hi(FITOS_COMPARE), %g2
262 or %g2, %lo(FITOS_COMPARE), %g2
263 cmp %g1, %g2
264 bne,pn %xcc, do_fptrap_after_fsr
265 nop
266 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
267 sethi %hi(fitos_table_1), %g1
268 and %g3, 0x1f, %g2
269 or %g1, %lo(fitos_table_1), %g1
270 sllx %g2, 2, %g2
271 jmpl %g1 + %g2, %g0
272 ba,pt %xcc, fitos_emul_continue
273
274fitos_table_1:
275 fitod %f0, %f62
276 fitod %f1, %f62
277 fitod %f2, %f62
278 fitod %f3, %f62
279 fitod %f4, %f62
280 fitod %f5, %f62
281 fitod %f6, %f62
282 fitod %f7, %f62
283 fitod %f8, %f62
284 fitod %f9, %f62
285 fitod %f10, %f62
286 fitod %f11, %f62
287 fitod %f12, %f62
288 fitod %f13, %f62
289 fitod %f14, %f62
290 fitod %f15, %f62
291 fitod %f16, %f62
292 fitod %f17, %f62
293 fitod %f18, %f62
294 fitod %f19, %f62
295 fitod %f20, %f62
296 fitod %f21, %f62
297 fitod %f22, %f62
298 fitod %f23, %f62
299 fitod %f24, %f62
300 fitod %f25, %f62
301 fitod %f26, %f62
302 fitod %f27, %f62
303 fitod %f28, %f62
304 fitod %f29, %f62
305 fitod %f30, %f62
306 fitod %f31, %f62
307
308fitos_emul_continue:
309 sethi %hi(fitos_table_2), %g1
310 srl %g3, 25, %g2
311 or %g1, %lo(fitos_table_2), %g1
312 and %g2, 0x1f, %g2
313 sllx %g2, 2, %g2
314 jmpl %g1 + %g2, %g0
315 ba,pt %xcc, fitos_emul_fini
316
317fitos_table_2:
318 fdtos %f62, %f0
319 fdtos %f62, %f1
320 fdtos %f62, %f2
321 fdtos %f62, %f3
322 fdtos %f62, %f4
323 fdtos %f62, %f5
324 fdtos %f62, %f6
325 fdtos %f62, %f7
326 fdtos %f62, %f8
327 fdtos %f62, %f9
328 fdtos %f62, %f10
329 fdtos %f62, %f11
330 fdtos %f62, %f12
331 fdtos %f62, %f13
332 fdtos %f62, %f14
333 fdtos %f62, %f15
334 fdtos %f62, %f16
335 fdtos %f62, %f17
336 fdtos %f62, %f18
337 fdtos %f62, %f19
338 fdtos %f62, %f20
339 fdtos %f62, %f21
340 fdtos %f62, %f22
341 fdtos %f62, %f23
342 fdtos %f62, %f24
343 fdtos %f62, %f25
344 fdtos %f62, %f26
345 fdtos %f62, %f27
346 fdtos %f62, %f28
347 fdtos %f62, %f29
348 fdtos %f62, %f30
349 fdtos %f62, %f31
350
351fitos_emul_fini:
352 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
353 done
354
355 .globl do_fptrap
356 .align 32
357do_fptrap:
358 TRAP_LOAD_THREAD_REG(%g6, %g1)
359 stx %fsr, [%g6 + TI_XFSR]
360do_fptrap_after_fsr:
361 ldub [%g6 + TI_FPSAVED], %g3
362 rd %fprs, %g1
363 or %g3, %g1, %g3
364 stb %g3, [%g6 + TI_FPSAVED]
365 rd %gsr, %g3
366 stx %g3, [%g6 + TI_GSR]
367 mov SECONDARY_CONTEXT, %g3
368
369661: ldxa [%g3] ASI_DMMU, %g5
370 .section .sun4v_1insn_patch, "ax"
371 .word 661b
372 ldxa [%g3] ASI_MMU, %g5
373 .previous
374
375 sethi %hi(sparc64_kern_sec_context), %g2
376 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
377
378661: stxa %g2, [%g3] ASI_DMMU
379 .section .sun4v_1insn_patch, "ax"
380 .word 661b
381 stxa %g2, [%g3] ASI_MMU
382 .previous
383
384 membar #Sync
385 add %g6, TI_FPREGS, %g2
386 andcc %g1, FPRS_DL, %g0
387 be,pn %icc, 4f
388 mov 0x40, %g3
389 stda %f0, [%g2] ASI_BLK_S
390 stda %f16, [%g2 + %g3] ASI_BLK_S
391 andcc %g1, FPRS_DU, %g0
392 be,pn %icc, 5f
3934: add %g2, 128, %g2
394 stda %f32, [%g2] ASI_BLK_S
395 stda %f48, [%g2 + %g3] ASI_BLK_S
3965: mov SECONDARY_CONTEXT, %g1
397 membar #Sync
398
399661: stxa %g5, [%g1] ASI_DMMU
400 .section .sun4v_1insn_patch, "ax"
401 .word 661b
402 stxa %g5, [%g1] ASI_MMU
403 .previous
404
405 membar #Sync
406 ba,pt %xcc, etrap
407 wr %g0, 0, %fprs
408
409 /* The registers for cross calls will be:
410 *
411 * DATA 0: [low 32-bits] Address of function to call, jmp to this
412 * [high 32-bits] MMU Context Argument 0, place in %g5
413 * DATA 1: Address Argument 1, place in %g1
414 * DATA 2: Address Argument 2, place in %g7
415 *
416 * With this method we can do most of the cross-call tlb/cache
417 * flushing very quickly.
418 */
419 .text
420 .align 32
421 .globl do_ivec
422do_ivec:
423 mov 0x40, %g3
424 ldxa [%g3 + %g0] ASI_INTR_R, %g3
425 sethi %hi(KERNBASE), %g4
426 cmp %g3, %g4
427 bgeu,pn %xcc, do_ivec_xcall
428 srlx %g3, 32, %g5
429 stxa %g0, [%g0] ASI_INTR_RECEIVE
430 membar #Sync
431
432 sethi %hi(ivector_table_pa), %g2
433 ldx [%g2 + %lo(ivector_table_pa)], %g2
434 sllx %g3, 4, %g3
435 add %g2, %g3, %g3
436
437 TRAP_LOAD_IRQ_WORK_PA(%g6, %g1)
438
439 ldx [%g6], %g5
440 stxa %g5, [%g3] ASI_PHYS_USE_EC
441 stx %g3, [%g6]
442 wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
443 retry
444do_ivec_xcall:
445 mov 0x50, %g1
446 ldxa [%g1 + %g0] ASI_INTR_R, %g1
447 srl %g3, 0, %g3
448
449 mov 0x60, %g7
450 ldxa [%g7 + %g0] ASI_INTR_R, %g7
451 stxa %g0, [%g0] ASI_INTR_RECEIVE
452 membar #Sync
453 ba,pt %xcc, 1f
454 nop
455
456 .align 32
4571: jmpl %g3, %g0
458 nop
459
460 .globl getcc, setcc
461getcc:
462 ldx [%o0 + PT_V9_TSTATE], %o1
463 srlx %o1, 32, %o1
464 and %o1, 0xf, %o1
465 retl
466 stx %o1, [%o0 + PT_V9_G1]
467setcc:
468 ldx [%o0 + PT_V9_TSTATE], %o1
469 ldx [%o0 + PT_V9_G1], %o2
470 or %g0, %ulo(TSTATE_ICC), %o3
471 sllx %o3, 32, %o3
472 andn %o1, %o3, %o1
473 sllx %o2, 32, %o2
474 and %o2, %o3, %o2
475 or %o1, %o2, %o1
476 retl
477 stx %o1, [%o0 + PT_V9_TSTATE]
478
479 .globl utrap_trap
480utrap_trap: /* %g3=handler,%g4=level */
481 TRAP_LOAD_THREAD_REG(%g6, %g1)
482 ldx [%g6 + TI_UTRAPS], %g1
483 brnz,pt %g1, invoke_utrap
484 nop
485
486 ba,pt %xcc, etrap
487 rd %pc, %g7
488 mov %l4, %o1
489 call bad_trap
490 add %sp, PTREGS_OFF, %o0
491 ba,pt %xcc, rtrap
492 nop
493
494invoke_utrap:
495 sllx %g3, 3, %g3
496 ldx [%g1 + %g3], %g1
497 save %sp, -128, %sp
498 rdpr %tstate, %l6
499 rdpr %cwp, %l7
500 andn %l6, TSTATE_CWP, %l6
501 wrpr %l6, %l7, %tstate
502 rdpr %tpc, %l6
503 rdpr %tnpc, %l7
504 wrpr %g1, 0, %tnpc
505 done
506
507 /* We need to carefully read the error status, ACK
508 * the errors, prevent recursive traps, and pass the
509 * information on to C code for logging.
510 *
511 * We pass the AFAR in as-is, and we encode the status
512 * information as described in asm-sparc64/sfafsr.h
513 */
514 .globl __spitfire_access_error
515__spitfire_access_error:
516 /* Disable ESTATE error reporting so that we do not
517 * take recursive traps and RED state the processor.
518 */
519 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
520 membar #Sync
521
522 mov UDBE_UE, %g1
523 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
524
525 /* __spitfire_cee_trap branches here with AFSR in %g4 and
526 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the
527 * ESTATE Error Enable register.
528 */
529__spitfire_cee_trap_continue:
530 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
531
532 rdpr %tt, %g3
533 and %g3, 0x1ff, %g3 ! Paranoia
534 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
535 or %g4, %g3, %g4
536 rdpr %tl, %g3
537 cmp %g3, 1
538 mov 1, %g3
539 bleu %xcc, 1f
540 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
541
542 or %g4, %g3, %g4
543
544 /* Read in the UDB error register state, clearing the
545 * sticky error bits as-needed. We only clear them if
546 * the UE bit is set. Likewise, __spitfire_cee_trap
547 * below will only do so if the CE bit is set.
548 *
549 * NOTE: UltraSparc-I/II have high and low UDB error
550 * registers, corresponding to the two UDB units
551 * present on those chips. UltraSparc-IIi only
552 * has a single UDB, called "SDB" in the manual.
553 * For IIi the upper UDB register always reads
554 * as zero so for our purposes things will just
555 * work with the checks below.
556 */
5571: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
558 and %g3, 0x3ff, %g7 ! Paranoia
559 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
560 or %g4, %g7, %g4
561 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
562 be,pn %xcc, 1f
563 nop
564 stxa %g3, [%g0] ASI_UDB_ERROR_W
565 membar #Sync
566
5671: mov 0x18, %g3
568 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
569 and %g3, 0x3ff, %g7 ! Paranoia
570 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
571 or %g4, %g7, %g4
572 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
573 be,pn %xcc, 1f
574 nop
575 mov 0x18, %g7
576 stxa %g3, [%g7] ASI_UDB_ERROR_W
577 membar #Sync
578
5791: /* Ok, now that we've latched the error state,
580 * clear the sticky bits in the AFSR.
581 */
582 stxa %g4, [%g0] ASI_AFSR
583 membar #Sync
584
585 rdpr %tl, %g2
586 cmp %g2, 1
587 rdpr %pil, %g2
588 bleu,pt %xcc, 1f
589 wrpr %g0, 15, %pil
590
591 ba,pt %xcc, etraptl1
592 rd %pc, %g7
593
594 ba,pt %xcc, 2f
595 nop
596
5971: ba,pt %xcc, etrap_irq
598 rd %pc, %g7
599
6002:
601#ifdef CONFIG_TRACE_IRQFLAGS
602 call trace_hardirqs_off
603 nop
604#endif
605 mov %l4, %o1
606 mov %l5, %o2
607 call spitfire_access_error
608 add %sp, PTREGS_OFF, %o0
609 ba,pt %xcc, rtrap
610 nop
611
612 /* This is the trap handler entry point for ECC correctable
613 * errors. They are corrected, but we listen for the trap
614 * so that the event can be logged.
615 *
616 * Disrupting errors are either:
617 * 1) single-bit ECC errors during UDB reads to system
618 * memory
619 * 2) data parity errors during write-back events
620 *
621 * As far as I can make out from the manual, the CEE trap
622 * is only for correctable errors during memory read
623 * accesses by the front-end of the processor.
624 *
625 * The code below is only for trap level 1 CEE events,
626 * as it is the only situation where we can safely record
627 * and log. For trap level >1 we just clear the CE bit
628 * in the AFSR and return.
629 *
630 * This is just like __spiftire_access_error above, but it
631 * specifically handles correctable errors. If an
632 * uncorrectable error is indicated in the AFSR we
633 * will branch directly above to __spitfire_access_error
634 * to handle it instead. Uncorrectable therefore takes
635 * priority over correctable, and the error logging
636 * C code will notice this case by inspecting the
637 * trap type.
638 */
639 .globl __spitfire_cee_trap
640__spitfire_cee_trap:
641 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
642 mov 1, %g3
643 sllx %g3, SFAFSR_UE_SHIFT, %g3
644 andcc %g4, %g3, %g0 ! Check for UE
645 bne,pn %xcc, __spitfire_access_error
646 nop
647
648 /* Ok, in this case we only have a correctable error.
649 * Indicate we only wish to capture that state in register
650 * %g1, and we only disable CE error reporting unlike UE
651 * handling which disables all errors.
652 */
653 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
654 andn %g3, ESTATE_ERR_CE, %g3
655 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
656 membar #Sync
657
658 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
659 ba,pt %xcc, __spitfire_cee_trap_continue
660 mov UDBE_CE, %g1
661
662 .globl __spitfire_data_access_exception
663 .globl __spitfire_data_access_exception_tl1
664__spitfire_data_access_exception_tl1:
665 rdpr %pstate, %g4
666 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
667 mov TLB_SFSR, %g3
668 mov DMMU_SFAR, %g5
669 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
670 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
671 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
672 membar #Sync
673 rdpr %tt, %g3
674 cmp %g3, 0x80 ! first win spill/fill trap
675 blu,pn %xcc, 1f
676 cmp %g3, 0xff ! last win spill/fill trap
677 bgu,pn %xcc, 1f
678 nop
679 ba,pt %xcc, winfix_dax
680 rdpr %tpc, %g3
6811: sethi %hi(109f), %g7
682 ba,pt %xcc, etraptl1
683109: or %g7, %lo(109b), %g7
684 mov %l4, %o1
685 mov %l5, %o2
686 call spitfire_data_access_exception_tl1
687 add %sp, PTREGS_OFF, %o0
688 ba,pt %xcc, rtrap
689 nop
690
691__spitfire_data_access_exception:
692 rdpr %pstate, %g4
693 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
694 mov TLB_SFSR, %g3
695 mov DMMU_SFAR, %g5
696 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
697 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
698 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
699 membar #Sync
700 sethi %hi(109f), %g7
701 ba,pt %xcc, etrap
702109: or %g7, %lo(109b), %g7
703 mov %l4, %o1
704 mov %l5, %o2
705 call spitfire_data_access_exception
706 add %sp, PTREGS_OFF, %o0
707 ba,pt %xcc, rtrap
708 nop
709
710 .globl __spitfire_insn_access_exception
711 .globl __spitfire_insn_access_exception_tl1
712__spitfire_insn_access_exception_tl1:
713 rdpr %pstate, %g4
714 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
715 mov TLB_SFSR, %g3
716 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
717 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
718 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
719 membar #Sync
720 sethi %hi(109f), %g7
721 ba,pt %xcc, etraptl1
722109: or %g7, %lo(109b), %g7
723 mov %l4, %o1
724 mov %l5, %o2
725 call spitfire_insn_access_exception_tl1
726 add %sp, PTREGS_OFF, %o0
727 ba,pt %xcc, rtrap
728 nop
729
730__spitfire_insn_access_exception:
731 rdpr %pstate, %g4
732 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
733 mov TLB_SFSR, %g3
734 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
735 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
736 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
737 membar #Sync
738 sethi %hi(109f), %g7
739 ba,pt %xcc, etrap
740109: or %g7, %lo(109b), %g7
741 mov %l4, %o1
742 mov %l5, %o2
743 call spitfire_insn_access_exception
744 add %sp, PTREGS_OFF, %o0
745 ba,pt %xcc, rtrap
746 nop
747
748 /* These get patched into the trap table at boot time
749 * once we know we have a cheetah processor.
750 */
751 .globl cheetah_fecc_trap_vector, cheetah_fecc_trap_vector_tl1
752cheetah_fecc_trap_vector:
753 membar #Sync
754 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
755 andn %g1, DCU_DC | DCU_IC, %g1
756 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
757 membar #Sync
758 sethi %hi(cheetah_fast_ecc), %g2
759 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
760 mov 0, %g1
761cheetah_fecc_trap_vector_tl1:
762 membar #Sync
763 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
764 andn %g1, DCU_DC | DCU_IC, %g1
765 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
766 membar #Sync
767 sethi %hi(cheetah_fast_ecc), %g2
768 jmpl %g2 + %lo(cheetah_fast_ecc), %g0
769 mov 1, %g1
770 .globl cheetah_cee_trap_vector, cheetah_cee_trap_vector_tl1
771cheetah_cee_trap_vector:
772 membar #Sync
773 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
774 andn %g1, DCU_IC, %g1
775 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
776 membar #Sync
777 sethi %hi(cheetah_cee), %g2
778 jmpl %g2 + %lo(cheetah_cee), %g0
779 mov 0, %g1
780cheetah_cee_trap_vector_tl1:
781 membar #Sync
782 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
783 andn %g1, DCU_IC, %g1
784 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
785 membar #Sync
786 sethi %hi(cheetah_cee), %g2
787 jmpl %g2 + %lo(cheetah_cee), %g0
788 mov 1, %g1
789 .globl cheetah_deferred_trap_vector, cheetah_deferred_trap_vector_tl1
790cheetah_deferred_trap_vector:
791 membar #Sync
792 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
793 andn %g1, DCU_DC | DCU_IC, %g1;
794 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
795 membar #Sync;
796 sethi %hi(cheetah_deferred_trap), %g2
797 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
798 mov 0, %g1
799cheetah_deferred_trap_vector_tl1:
800 membar #Sync;
801 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1;
802 andn %g1, DCU_DC | DCU_IC, %g1;
803 stxa %g1, [%g0] ASI_DCU_CONTROL_REG;
804 membar #Sync;
805 sethi %hi(cheetah_deferred_trap), %g2
806 jmpl %g2 + %lo(cheetah_deferred_trap), %g0
807 mov 1, %g1
808
809 /* Cheetah+ specific traps. These are for the new I/D cache parity
810 * error traps. The first argument to cheetah_plus_parity_handler
811 * is encoded as follows:
812 *
813 * Bit0: 0=dcache,1=icache
814 * Bit1: 0=recoverable,1=unrecoverable
815 */
816 .globl cheetah_plus_dcpe_trap_vector, cheetah_plus_dcpe_trap_vector_tl1
817cheetah_plus_dcpe_trap_vector:
818 membar #Sync
819 sethi %hi(do_cheetah_plus_data_parity), %g7
820 jmpl %g7 + %lo(do_cheetah_plus_data_parity), %g0
821 nop
822 nop
823 nop
824 nop
825 nop
826
827do_cheetah_plus_data_parity:
828 rdpr %pil, %g2
829 wrpr %g0, 15, %pil
830 ba,pt %xcc, etrap_irq
831 rd %pc, %g7
832#ifdef CONFIG_TRACE_IRQFLAGS
833 call trace_hardirqs_off
834 nop
835#endif
836 mov 0x0, %o0
837 call cheetah_plus_parity_error
838 add %sp, PTREGS_OFF, %o1
839 ba,a,pt %xcc, rtrap_irq
840
841cheetah_plus_dcpe_trap_vector_tl1:
842 membar #Sync
843 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
844 sethi %hi(do_dcpe_tl1), %g3
845 jmpl %g3 + %lo(do_dcpe_tl1), %g0
846 nop
847 nop
848 nop
849 nop
850
851 .globl cheetah_plus_icpe_trap_vector, cheetah_plus_icpe_trap_vector_tl1
852cheetah_plus_icpe_trap_vector:
853 membar #Sync
854 sethi %hi(do_cheetah_plus_insn_parity), %g7
855 jmpl %g7 + %lo(do_cheetah_plus_insn_parity), %g0
856 nop
857 nop
858 nop
859 nop
860 nop
861
862do_cheetah_plus_insn_parity:
863 rdpr %pil, %g2
864 wrpr %g0, 15, %pil
865 ba,pt %xcc, etrap_irq
866 rd %pc, %g7
867#ifdef CONFIG_TRACE_IRQFLAGS
868 call trace_hardirqs_off
869 nop
870#endif
871 mov 0x1, %o0
872 call cheetah_plus_parity_error
873 add %sp, PTREGS_OFF, %o1
874 ba,a,pt %xcc, rtrap_irq
875
876cheetah_plus_icpe_trap_vector_tl1:
877 membar #Sync
878 wrpr PSTATE_IG | PSTATE_PEF | PSTATE_PRIV, %pstate
879 sethi %hi(do_icpe_tl1), %g3
880 jmpl %g3 + %lo(do_icpe_tl1), %g0
881 nop
882 nop
883 nop
884 nop
885
886 /* If we take one of these traps when tl >= 1, then we
887 * jump to interrupt globals. If some trap level above us
888 * was also using interrupt globals, we cannot recover.
889 * We may use all interrupt global registers except %g6.
890 */
891 .globl do_dcpe_tl1, do_icpe_tl1
892do_dcpe_tl1:
893 rdpr %tl, %g1 ! Save original trap level
894 mov 1, %g2 ! Setup TSTATE checking loop
895 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
8961: wrpr %g2, %tl ! Set trap level to check
897 rdpr %tstate, %g4 ! Read TSTATE for this level
898 andcc %g4, %g3, %g0 ! Interrupt globals in use?
899 bne,a,pn %xcc, do_dcpe_tl1_fatal ! Yep, irrecoverable
900 wrpr %g1, %tl ! Restore original trap level
901 add %g2, 1, %g2 ! Next trap level
902 cmp %g2, %g1 ! Hit them all yet?
903 ble,pt %icc, 1b ! Not yet
904 nop
905 wrpr %g1, %tl ! Restore original trap level
906do_dcpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
907 sethi %hi(dcache_parity_tl1_occurred), %g2
908 lduw [%g2 + %lo(dcache_parity_tl1_occurred)], %g1
909 add %g1, 1, %g1
910 stw %g1, [%g2 + %lo(dcache_parity_tl1_occurred)]
911 /* Reset D-cache parity */
912 sethi %hi(1 << 16), %g1 ! D-cache size
913 mov (1 << 5), %g2 ! D-cache line size
914 sub %g1, %g2, %g1 ! Move down 1 cacheline
9151: srl %g1, 14, %g3 ! Compute UTAG
916 membar #Sync
917 stxa %g3, [%g1] ASI_DCACHE_UTAG
918 membar #Sync
919 sub %g2, 8, %g3 ! 64-bit data word within line
9202: membar #Sync
921 stxa %g0, [%g1 + %g3] ASI_DCACHE_DATA
922 membar #Sync
923 subcc %g3, 8, %g3 ! Next 64-bit data word
924 bge,pt %icc, 2b
925 nop
926 subcc %g1, %g2, %g1 ! Next cacheline
927 bge,pt %icc, 1b
928 nop
929 ba,pt %xcc, dcpe_icpe_tl1_common
930 nop
931
932do_dcpe_tl1_fatal:
933 sethi %hi(1f), %g7
934 ba,pt %xcc, etraptl1
9351: or %g7, %lo(1b), %g7
936 mov 0x2, %o0
937 call cheetah_plus_parity_error
938 add %sp, PTREGS_OFF, %o1
939 ba,pt %xcc, rtrap
940 nop
941
942do_icpe_tl1:
943 rdpr %tl, %g1 ! Save original trap level
944 mov 1, %g2 ! Setup TSTATE checking loop
945 sethi %hi(TSTATE_IG), %g3 ! TSTATE mask bit
9461: wrpr %g2, %tl ! Set trap level to check
947 rdpr %tstate, %g4 ! Read TSTATE for this level
948 andcc %g4, %g3, %g0 ! Interrupt globals in use?
949 bne,a,pn %xcc, do_icpe_tl1_fatal ! Yep, irrecoverable
950 wrpr %g1, %tl ! Restore original trap level
951 add %g2, 1, %g2 ! Next trap level
952 cmp %g2, %g1 ! Hit them all yet?
953 ble,pt %icc, 1b ! Not yet
954 nop
955 wrpr %g1, %tl ! Restore original trap level
956do_icpe_tl1_nonfatal: /* Ok we may use interrupt globals safely. */
957 sethi %hi(icache_parity_tl1_occurred), %g2
958 lduw [%g2 + %lo(icache_parity_tl1_occurred)], %g1
959 add %g1, 1, %g1
960 stw %g1, [%g2 + %lo(icache_parity_tl1_occurred)]
961 /* Flush I-cache */
962 sethi %hi(1 << 15), %g1 ! I-cache size
963 mov (1 << 5), %g2 ! I-cache line size
964 sub %g1, %g2, %g1
9651: or %g1, (2 << 3), %g3
966 stxa %g0, [%g3] ASI_IC_TAG
967 membar #Sync
968 subcc %g1, %g2, %g1
969 bge,pt %icc, 1b
970 nop
971 ba,pt %xcc, dcpe_icpe_tl1_common
972 nop
973
974do_icpe_tl1_fatal:
975 sethi %hi(1f), %g7
976 ba,pt %xcc, etraptl1
9771: or %g7, %lo(1b), %g7
978 mov 0x3, %o0
979 call cheetah_plus_parity_error
980 add %sp, PTREGS_OFF, %o1
981 ba,pt %xcc, rtrap
982 nop
983
984dcpe_icpe_tl1_common:
985 /* Flush D-cache, re-enable D/I caches in DCU and finally
986 * retry the trapping instruction.
987 */
988 sethi %hi(1 << 16), %g1 ! D-cache size
989 mov (1 << 5), %g2 ! D-cache line size
990 sub %g1, %g2, %g1
9911: stxa %g0, [%g1] ASI_DCACHE_TAG
992 membar #Sync
993 subcc %g1, %g2, %g1
994 bge,pt %icc, 1b
995 nop
996 ldxa [%g0] ASI_DCU_CONTROL_REG, %g1
997 or %g1, (DCU_DC | DCU_IC), %g1
998 stxa %g1, [%g0] ASI_DCU_CONTROL_REG
999 membar #Sync
1000 retry
1001
1002 /* Capture I/D/E-cache state into per-cpu error scoreboard.
1003 *
1004 * %g1: (TL>=0) ? 1 : 0
1005 * %g2: scratch
1006 * %g3: scratch
1007 * %g4: AFSR
1008 * %g5: AFAR
1009 * %g6: unused, will have current thread ptr after etrap
1010 * %g7: scratch
1011 */
1012__cheetah_log_error:
1013 /* Put "TL1" software bit into AFSR. */
1014 and %g1, 0x1, %g1
1015 sllx %g1, 63, %g2
1016 or %g4, %g2, %g4
1017
1018 /* Get log entry pointer for this cpu at this trap level. */
1019 BRANCH_IF_JALAPENO(g2,g3,50f)
1020 ldxa [%g0] ASI_SAFARI_CONFIG, %g2
1021 srlx %g2, 17, %g2
1022 ba,pt %xcc, 60f
1023 and %g2, 0x3ff, %g2
1024
102550: ldxa [%g0] ASI_JBUS_CONFIG, %g2
1026 srlx %g2, 17, %g2
1027 and %g2, 0x1f, %g2
1028
102960: sllx %g2, 9, %g2
1030 sethi %hi(cheetah_error_log), %g3
1031 ldx [%g3 + %lo(cheetah_error_log)], %g3
1032 brz,pn %g3, 80f
1033 nop
1034
1035 add %g3, %g2, %g3
1036 sllx %g1, 8, %g1
1037 add %g3, %g1, %g1
1038
1039 /* %g1 holds pointer to the top of the logging scoreboard */
1040 ldx [%g1 + 0x0], %g7
1041 cmp %g7, -1
1042 bne,pn %xcc, 80f
1043 nop
1044
1045 stx %g4, [%g1 + 0x0]
1046 stx %g5, [%g1 + 0x8]
1047 add %g1, 0x10, %g1
1048
1049 /* %g1 now points to D-cache logging area */
1050 set 0x3ff8, %g2 /* DC_addr mask */
1051 and %g5, %g2, %g2 /* DC_addr bits of AFAR */
1052 srlx %g5, 12, %g3
1053 or %g3, 1, %g3 /* PHYS tag + valid */
1054
105510: ldxa [%g2] ASI_DCACHE_TAG, %g7
1056 cmp %g3, %g7 /* TAG match? */
1057 bne,pt %xcc, 13f
1058 nop
1059
1060 /* Yep, what we want, capture state. */
1061 stx %g2, [%g1 + 0x20]
1062 stx %g7, [%g1 + 0x28]
1063
1064 /* A membar Sync is required before and after utag access. */
1065 membar #Sync
1066 ldxa [%g2] ASI_DCACHE_UTAG, %g7
1067 membar #Sync
1068 stx %g7, [%g1 + 0x30]
1069 ldxa [%g2] ASI_DCACHE_SNOOP_TAG, %g7
1070 stx %g7, [%g1 + 0x38]
1071 clr %g3
1072
107312: ldxa [%g2 + %g3] ASI_DCACHE_DATA, %g7
1074 stx %g7, [%g1]
1075 add %g3, (1 << 5), %g3
1076 cmp %g3, (4 << 5)
1077 bl,pt %xcc, 12b
1078 add %g1, 0x8, %g1
1079
1080 ba,pt %xcc, 20f
1081 add %g1, 0x20, %g1
1082
108313: sethi %hi(1 << 14), %g7
1084 add %g2, %g7, %g2
1085 srlx %g2, 14, %g7
1086 cmp %g7, 4
1087 bl,pt %xcc, 10b
1088 nop
1089
1090 add %g1, 0x40, %g1
1091
1092 /* %g1 now points to I-cache logging area */
109320: set 0x1fe0, %g2 /* IC_addr mask */
1094 and %g5, %g2, %g2 /* IC_addr bits of AFAR */
1095 sllx %g2, 1, %g2 /* IC_addr[13:6]==VA[12:5] */
1096 srlx %g5, (13 - 8), %g3 /* Make PTAG */
1097 andn %g3, 0xff, %g3 /* Mask off undefined bits */
1098
109921: ldxa [%g2] ASI_IC_TAG, %g7
1100 andn %g7, 0xff, %g7
1101 cmp %g3, %g7
1102 bne,pt %xcc, 23f
1103 nop
1104
1105 /* Yep, what we want, capture state. */
1106 stx %g2, [%g1 + 0x40]
1107 stx %g7, [%g1 + 0x48]
1108 add %g2, (1 << 3), %g2
1109 ldxa [%g2] ASI_IC_TAG, %g7
1110 add %g2, (1 << 3), %g2
1111 stx %g7, [%g1 + 0x50]
1112 ldxa [%g2] ASI_IC_TAG, %g7
1113 add %g2, (1 << 3), %g2
1114 stx %g7, [%g1 + 0x60]
1115 ldxa [%g2] ASI_IC_TAG, %g7
1116 stx %g7, [%g1 + 0x68]
1117 sub %g2, (3 << 3), %g2
1118 ldxa [%g2] ASI_IC_STAG, %g7
1119 stx %g7, [%g1 + 0x58]
1120 clr %g3
1121 srlx %g2, 2, %g2
1122
112322: ldxa [%g2 + %g3] ASI_IC_INSTR, %g7
1124 stx %g7, [%g1]
1125 add %g3, (1 << 3), %g3
1126 cmp %g3, (8 << 3)
1127 bl,pt %xcc, 22b
1128 add %g1, 0x8, %g1
1129
1130 ba,pt %xcc, 30f
1131 add %g1, 0x30, %g1
1132
113323: sethi %hi(1 << 14), %g7
1134 add %g2, %g7, %g2
1135 srlx %g2, 14, %g7
1136 cmp %g7, 4
1137 bl,pt %xcc, 21b
1138 nop
1139
1140 add %g1, 0x70, %g1
1141
1142 /* %g1 now points to E-cache logging area */
114330: andn %g5, (32 - 1), %g2
1144 stx %g2, [%g1 + 0x20]
1145 ldxa [%g2] ASI_EC_TAG_DATA, %g7
1146 stx %g7, [%g1 + 0x28]
1147 ldxa [%g2] ASI_EC_R, %g0
1148 clr %g3
1149
115031: ldxa [%g3] ASI_EC_DATA, %g7
1151 stx %g7, [%g1 + %g3]
1152 add %g3, 0x8, %g3
1153 cmp %g3, 0x20
1154
1155 bl,pt %xcc, 31b
1156 nop
115780:
1158 rdpr %tt, %g2
1159 cmp %g2, 0x70
1160 be c_fast_ecc
1161 cmp %g2, 0x63
1162 be c_cee
1163 nop
1164 ba,pt %xcc, c_deferred
1165
1166 /* Cheetah FECC trap handling, we get here from tl{0,1}_fecc
1167 * in the trap table. That code has done a memory barrier
1168 * and has disabled both the I-cache and D-cache in the DCU
1169 * control register. The I-cache is disabled so that we may
1170 * capture the corrupted cache line, and the D-cache is disabled
1171 * because corrupt data may have been placed there and we don't
1172 * want to reference it.
1173 *
1174 * %g1 is one if this trap occurred at %tl >= 1.
1175 *
1176 * Next, we turn off error reporting so that we don't recurse.
1177 */
1178 .globl cheetah_fast_ecc
1179cheetah_fast_ecc:
1180 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1181 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1182 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1183 membar #Sync
1184
1185 /* Fetch and clear AFSR/AFAR */
1186 ldxa [%g0] ASI_AFSR, %g4
1187 ldxa [%g0] ASI_AFAR, %g5
1188 stxa %g4, [%g0] ASI_AFSR
1189 membar #Sync
1190
1191 ba,pt %xcc, __cheetah_log_error
1192 nop
1193
1194c_fast_ecc:
1195 rdpr %pil, %g2
1196 wrpr %g0, 15, %pil
1197 ba,pt %xcc, etrap_irq
1198 rd %pc, %g7
1199#ifdef CONFIG_TRACE_IRQFLAGS
1200 call trace_hardirqs_off
1201 nop
1202#endif
1203 mov %l4, %o1
1204 mov %l5, %o2
1205 call cheetah_fecc_handler
1206 add %sp, PTREGS_OFF, %o0
1207 ba,a,pt %xcc, rtrap_irq
1208
1209 /* Our caller has disabled I-cache and performed membar Sync. */
1210 .globl cheetah_cee
1211cheetah_cee:
1212 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1213 andn %g2, ESTATE_ERROR_CEEN, %g2
1214 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1215 membar #Sync
1216
1217 /* Fetch and clear AFSR/AFAR */
1218 ldxa [%g0] ASI_AFSR, %g4
1219 ldxa [%g0] ASI_AFAR, %g5
1220 stxa %g4, [%g0] ASI_AFSR
1221 membar #Sync
1222
1223 ba,pt %xcc, __cheetah_log_error
1224 nop
1225
1226c_cee:
1227 rdpr %pil, %g2
1228 wrpr %g0, 15, %pil
1229 ba,pt %xcc, etrap_irq
1230 rd %pc, %g7
1231#ifdef CONFIG_TRACE_IRQFLAGS
1232 call trace_hardirqs_off
1233 nop
1234#endif
1235 mov %l4, %o1
1236 mov %l5, %o2
1237 call cheetah_cee_handler
1238 add %sp, PTREGS_OFF, %o0
1239 ba,a,pt %xcc, rtrap_irq
1240
1241 /* Our caller has disabled I-cache+D-cache and performed membar Sync. */
1242 .globl cheetah_deferred_trap
1243cheetah_deferred_trap:
1244 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g2
1245 andn %g2, ESTATE_ERROR_NCEEN | ESTATE_ERROR_CEEN, %g2
1246 stxa %g2, [%g0] ASI_ESTATE_ERROR_EN
1247 membar #Sync
1248
1249 /* Fetch and clear AFSR/AFAR */
1250 ldxa [%g0] ASI_AFSR, %g4
1251 ldxa [%g0] ASI_AFAR, %g5
1252 stxa %g4, [%g0] ASI_AFSR
1253 membar #Sync
1254
1255 ba,pt %xcc, __cheetah_log_error
1256 nop
1257
1258c_deferred:
1259 rdpr %pil, %g2
1260 wrpr %g0, 15, %pil
1261 ba,pt %xcc, etrap_irq
1262 rd %pc, %g7
1263#ifdef CONFIG_TRACE_IRQFLAGS
1264 call trace_hardirqs_off
1265 nop
1266#endif
1267 mov %l4, %o1
1268 mov %l5, %o2
1269 call cheetah_deferred_handler
1270 add %sp, PTREGS_OFF, %o0
1271 ba,a,pt %xcc, rtrap_irq
1272
1273 .globl __do_privact
1274__do_privact:
1275 mov TLB_SFSR, %g3
1276 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1277 membar #Sync
1278 sethi %hi(109f), %g7
1279 ba,pt %xcc, etrap
1280109: or %g7, %lo(109b), %g7
1281 call do_privact
1282 add %sp, PTREGS_OFF, %o0
1283 ba,pt %xcc, rtrap
1284 nop
1285
1286 .globl do_mna
1287do_mna:
1288 rdpr %tl, %g3
1289 cmp %g3, 1
1290
1291 /* Setup %g4/%g5 now as they are used in the
1292 * winfixup code.
1293 */
1294 mov TLB_SFSR, %g3
1295 mov DMMU_SFAR, %g4
1296 ldxa [%g4] ASI_DMMU, %g4
1297 ldxa [%g3] ASI_DMMU, %g5
1298 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
1299 membar #Sync
1300 bgu,pn %icc, winfix_mna
1301 rdpr %tpc, %g3
1302
13031: sethi %hi(109f), %g7
1304 ba,pt %xcc, etrap
1305109: or %g7, %lo(109b), %g7
1306 mov %l4, %o1
1307 mov %l5, %o2
1308 call mem_address_unaligned
1309 add %sp, PTREGS_OFF, %o0
1310 ba,pt %xcc, rtrap
1311 nop
1312
1313 .globl do_lddfmna
1314do_lddfmna:
1315 sethi %hi(109f), %g7
1316 mov TLB_SFSR, %g4
1317 ldxa [%g4] ASI_DMMU, %g5
1318 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1319 membar #Sync
1320 mov DMMU_SFAR, %g4
1321 ldxa [%g4] ASI_DMMU, %g4
1322 ba,pt %xcc, etrap
1323109: or %g7, %lo(109b), %g7
1324 mov %l4, %o1
1325 mov %l5, %o2
1326 call handle_lddfmna
1327 add %sp, PTREGS_OFF, %o0
1328 ba,pt %xcc, rtrap
1329 nop
1330
1331 .globl do_stdfmna
1332do_stdfmna:
1333 sethi %hi(109f), %g7
1334 mov TLB_SFSR, %g4
1335 ldxa [%g4] ASI_DMMU, %g5
1336 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
1337 membar #Sync
1338 mov DMMU_SFAR, %g4
1339 ldxa [%g4] ASI_DMMU, %g4
1340 ba,pt %xcc, etrap
1341109: or %g7, %lo(109b), %g7
1342 mov %l4, %o1
1343 mov %l5, %o2
1344 call handle_stdfmna
1345 add %sp, PTREGS_OFF, %o0
1346 ba,pt %xcc, rtrap
1347 nop
1348
1349 .globl breakpoint_trap
1350breakpoint_trap:
1351 call sparc_breakpoint
1352 add %sp, PTREGS_OFF, %o0
1353 ba,pt %xcc, rtrap
1354 nop
1355
1356 /* SunOS's execv() call only specifies the argv argument, the
1357 * environment settings are the same as the calling processes.
1358 */
1359 .globl sunos_execv
1360sys_execve:
1361 sethi %hi(sparc_execve), %g1
1362 ba,pt %xcc, execve_merge
1363 or %g1, %lo(sparc_execve), %g1
1364#ifdef CONFIG_COMPAT
1365 .globl sys_execve
1366sunos_execv:
1367 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
1368 .globl sys32_execve
1369sys32_execve:
1370 sethi %hi(sparc32_execve), %g1
1371 or %g1, %lo(sparc32_execve), %g1
1372#endif
1373execve_merge:
1374 flushw
1375 jmpl %g1, %g0
1376 add %sp, PTREGS_OFF, %o0
1377
1378 .globl sys_pipe, sys_sigpause, sys_nis_syscall
1379 .globl sys_rt_sigreturn
1380 .globl sys_ptrace
1381 .globl sys_sigaltstack
1382 .align 32
1383sys_pipe: ba,pt %xcc, sparc_pipe
1384 add %sp, PTREGS_OFF, %o0
1385sys_nis_syscall:ba,pt %xcc, c_sys_nis_syscall
1386 add %sp, PTREGS_OFF, %o0
1387sys_memory_ordering:
1388 ba,pt %xcc, sparc_memory_ordering
1389 add %sp, PTREGS_OFF, %o1
1390sys_sigaltstack:ba,pt %xcc, do_sigaltstack
1391 add %i6, STACK_BIAS, %o2
1392#ifdef CONFIG_COMPAT
1393 .globl sys32_sigstack
1394sys32_sigstack: ba,pt %xcc, do_sys32_sigstack
1395 mov %i6, %o2
1396 .globl sys32_sigaltstack
1397sys32_sigaltstack:
1398 ba,pt %xcc, do_sys32_sigaltstack
1399 mov %i6, %o2
1400#endif
1401 .align 32
1402#ifdef CONFIG_COMPAT
1403 .globl sys32_sigreturn
1404sys32_sigreturn:
1405 add %sp, PTREGS_OFF, %o0
1406 call do_sigreturn32
1407 add %o7, 1f-.-4, %o7
1408 nop
1409#endif
1410sys_rt_sigreturn:
1411 add %sp, PTREGS_OFF, %o0
1412 call do_rt_sigreturn
1413 add %o7, 1f-.-4, %o7
1414 nop
1415#ifdef CONFIG_COMPAT
1416 .globl sys32_rt_sigreturn
1417sys32_rt_sigreturn:
1418 add %sp, PTREGS_OFF, %o0
1419 call do_rt_sigreturn32
1420 add %o7, 1f-.-4, %o7
1421 nop
1422#endif
1423 .align 32
14241: ldx [%curptr + TI_FLAGS], %l5
1425 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1426 be,pt %icc, rtrap
1427 nop
1428 add %sp, PTREGS_OFF, %o0
1429 call syscall_trace
1430 mov 1, %o1
1431
1432 ba,pt %xcc, rtrap
1433 nop
1434
1435 /* This is how fork() was meant to be done, 8 instruction entry.
1436 *
1437 * I questioned the following code briefly, let me clear things
1438 * up so you must not reason on it like I did.
1439 *
1440 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
1441 * need it here because the only piece of window state we copy to
1442 * the child is the CWP register. Even if the parent sleeps,
1443 * we are safe because we stuck it into pt_regs of the parent
1444 * so it will not change.
1445 *
1446 * XXX This raises the question, whether we can do the same on
1447 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
1448 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
1449 * XXX fork_kwim in UREG_G1 (global registers are considered
1450 * XXX volatile across a system call in the sparc ABI I think
1451 * XXX if it isn't we can use regs->y instead, anyone who depends
1452 * XXX upon the Y register being preserved across a fork deserves
1453 * XXX to lose).
1454 *
1455 * In fact we should take advantage of that fact for other things
1456 * during system calls...
1457 */
1458 .globl sys_fork, sys_vfork, sys_clone, sparc_exit
1459 .globl ret_from_syscall
1460 .align 32
1461sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
1462 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
1463 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
1464 ba,pt %xcc, sys_clone
1465sys_fork: clr %o1
1466 mov SIGCHLD, %o0
1467sys_clone: flushw
1468 movrz %o1, %fp, %o1
1469 mov 0, %o3
1470 ba,pt %xcc, sparc_do_fork
1471 add %sp, PTREGS_OFF, %o2
1472ret_from_syscall:
1473 /* Clear current_thread_info()->new_child, and
1474 * check performance counter stuff too.
1475 */
1476 stb %g0, [%g6 + TI_NEW_CHILD]
1477 ldx [%g6 + TI_FLAGS], %l0
1478 call schedule_tail
1479 mov %g7, %o0
1480 andcc %l0, _TIF_PERFCTR, %g0
1481 be,pt %icc, 1f
1482 nop
1483 ldx [%g6 + TI_PCR], %o7
1484 wr %g0, %o7, %pcr
1485
1486 /* Blackbird errata workaround. See commentary in
1487 * smp.c:smp_percpu_timer_interrupt() for more
1488 * information.
1489 */
1490 ba,pt %xcc, 99f
1491 nop
1492 .align 64
149399: wr %g0, %g0, %pic
1494 rd %pic, %g0
1495
14961: b,pt %xcc, ret_sys_call
1497 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
1498sparc_exit: rdpr %pstate, %g2
1499 wrpr %g2, PSTATE_IE, %pstate
1500 rdpr %otherwin, %g1
1501 rdpr %cansave, %g3
1502 add %g3, %g1, %g3
1503 wrpr %g3, 0x0, %cansave
1504 wrpr %g0, 0x0, %otherwin
1505 wrpr %g2, 0x0, %pstate
1506 ba,pt %xcc, sys_exit
1507 stb %g0, [%g6 + TI_WSAVED]
1508
1509linux_sparc_ni_syscall:
1510 sethi %hi(sys_ni_syscall), %l7
1511 b,pt %xcc, 4f
1512 or %l7, %lo(sys_ni_syscall), %l7
1513
1514linux_syscall_trace32:
1515 add %sp, PTREGS_OFF, %o0
1516 call syscall_trace
1517 clr %o1
1518 srl %i0, 0, %o0
1519 srl %i4, 0, %o4
1520 srl %i1, 0, %o1
1521 srl %i2, 0, %o2
1522 b,pt %xcc, 2f
1523 srl %i3, 0, %o3
1524
1525linux_syscall_trace:
1526 add %sp, PTREGS_OFF, %o0
1527 call syscall_trace
1528 clr %o1
1529 mov %i0, %o0
1530 mov %i1, %o1
1531 mov %i2, %o2
1532 mov %i3, %o3
1533 b,pt %xcc, 2f
1534 mov %i4, %o4
1535
1536
1537 /* Linux 32-bit system calls enter here... */
1538 .align 32
1539 .globl linux_sparc_syscall32
1540linux_sparc_syscall32:
1541 /* Direct access to user regs, much faster. */
1542 cmp %g1, NR_SYSCALLS ! IEU1 Group
1543 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1544 srl %i0, 0, %o0 ! IEU0
1545 sll %g1, 2, %l4 ! IEU0 Group
1546 srl %i4, 0, %o4 ! IEU1
1547 lduw [%l7 + %l4], %l7 ! Load
1548 srl %i1, 0, %o1 ! IEU0 Group
1549 ldx [%curptr + TI_FLAGS], %l0 ! Load
1550
1551 srl %i5, 0, %o5 ! IEU1
1552 srl %i2, 0, %o2 ! IEU0 Group
1553 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1554 bne,pn %icc, linux_syscall_trace32 ! CTI
1555 mov %i0, %l5 ! IEU1
1556 call %l7 ! CTI Group brk forced
1557 srl %i3, 0, %o3 ! IEU0
1558 ba,a,pt %xcc, 3f
1559
1560 /* Linux native system calls enter here... */
1561 .align 32
1562 .globl linux_sparc_syscall
1563linux_sparc_syscall:
1564 /* Direct access to user regs, much faster. */
1565 cmp %g1, NR_SYSCALLS ! IEU1 Group
1566 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
1567 mov %i0, %o0 ! IEU0
1568 sll %g1, 2, %l4 ! IEU0 Group
1569 mov %i1, %o1 ! IEU1
1570 lduw [%l7 + %l4], %l7 ! Load
15714: mov %i2, %o2 ! IEU0 Group
1572 ldx [%curptr + TI_FLAGS], %l0 ! Load
1573
1574 mov %i3, %o3 ! IEU1
1575 mov %i4, %o4 ! IEU0 Group
1576 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
1577 bne,pn %icc, linux_syscall_trace ! CTI Group
1578 mov %i0, %l5 ! IEU0
15792: call %l7 ! CTI Group brk forced
1580 mov %i5, %o5 ! IEU0
1581 nop
1582
15833: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1584ret_sys_call:
1585 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
1586 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
1587 sra %o0, 0, %o0
1588 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
1589 sllx %g2, 32, %g2
1590
1591 /* Check if force_successful_syscall_return()
1592 * was invoked.
1593 */
1594 ldub [%curptr + TI_SYS_NOERROR], %l2
1595 brnz,a,pn %l2, 80f
1596 stb %g0, [%curptr + TI_SYS_NOERROR]
1597
1598 cmp %o0, -ERESTART_RESTARTBLOCK
1599 bgeu,pn %xcc, 1f
1600 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
160180:
1602 /* System call success, clear Carry condition code. */
1603 andn %g3, %g2, %g3
1604 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1605 bne,pn %icc, linux_syscall_trace2
1606 add %l1, 0x4, %l2 ! npc = npc+4
1607 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1608 ba,pt %xcc, rtrap
1609 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1610
16111:
1612 /* System call failure, set Carry condition code.
1613 * Also, get abs(errno) to return to the process.
1614 */
1615 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
1616 sub %g0, %o0, %o0
1617 or %g3, %g2, %g3
1618 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
1619 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
1620 bne,pn %icc, linux_syscall_trace2
1621 add %l1, 0x4, %l2 ! npc = npc+4
1622 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1623
1624 b,pt %xcc, rtrap
1625 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1626linux_syscall_trace2:
1627 add %sp, PTREGS_OFF, %o0
1628 call syscall_trace
1629 mov 1, %o1
1630 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
1631 ba,pt %xcc, rtrap
1632 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
1633
1634 .align 32
1635 .globl __flushw_user
1636__flushw_user:
1637 rdpr %otherwin, %g1
1638 brz,pn %g1, 2f
1639 clr %g2
16401: save %sp, -128, %sp
1641 rdpr %otherwin, %g1
1642 brnz,pt %g1, 1b
1643 add %g2, 1, %g2
16441: sub %g2, 1, %g2
1645 brnz,pt %g2, 1b
1646 restore %g0, %g0, %g0
16472: retl
1648 nop
1649
1650 /* Flush %fp and %i7 to the stack for all register
1651 * windows active inside of the cpu. This allows
1652 * show_stack_trace() to avoid using an expensive
1653 * 'flushw'.
1654 */
1655 .globl stack_trace_flush
1656 .type stack_trace_flush,#function
1657stack_trace_flush:
1658 rdpr %pstate, %o0
1659 wrpr %o0, PSTATE_IE, %pstate
1660
1661 rdpr %cwp, %g1
1662 rdpr %canrestore, %g2
1663 sub %g1, 1, %g3
1664
16651: brz,pn %g2, 2f
1666 sub %g2, 1, %g2
1667 wrpr %g3, %cwp
1668 stx %fp, [%sp + STACK_BIAS + RW_V9_I6]
1669 stx %i7, [%sp + STACK_BIAS + RW_V9_I7]
1670 ba,pt %xcc, 1b
1671 sub %g3, 1, %g3
1672
16732: wrpr %g1, %cwp
1674 wrpr %o0, %pstate
1675
1676 retl
1677 nop
1678 .size stack_trace_flush,.-stack_trace_flush
1679
1680#ifdef CONFIG_SMP
1681 .globl hard_smp_processor_id
1682hard_smp_processor_id:
1683#endif
1684 .globl real_hard_smp_processor_id
1685real_hard_smp_processor_id:
1686 __GET_CPUID(%o0)
1687 retl
1688 nop
1689
1690 /* %o0: devhandle
1691 * %o1: devino
1692 *
1693 * returns %o0: sysino
1694 */
1695 .globl sun4v_devino_to_sysino
1696 .type sun4v_devino_to_sysino,#function
1697sun4v_devino_to_sysino:
1698 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
1699 ta HV_FAST_TRAP
1700 retl
1701 mov %o1, %o0
1702 .size sun4v_devino_to_sysino, .-sun4v_devino_to_sysino
1703
1704 /* %o0: sysino
1705 *
1706 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1707 */
1708 .globl sun4v_intr_getenabled
1709 .type sun4v_intr_getenabled,#function
1710sun4v_intr_getenabled:
1711 mov HV_FAST_INTR_GETENABLED, %o5
1712 ta HV_FAST_TRAP
1713 retl
1714 mov %o1, %o0
1715 .size sun4v_intr_getenabled, .-sun4v_intr_getenabled
1716
1717 /* %o0: sysino
1718 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
1719 */
1720 .globl sun4v_intr_setenabled
1721 .type sun4v_intr_setenabled,#function
1722sun4v_intr_setenabled:
1723 mov HV_FAST_INTR_SETENABLED, %o5
1724 ta HV_FAST_TRAP
1725 retl
1726 nop
1727 .size sun4v_intr_setenabled, .-sun4v_intr_setenabled
1728
1729 /* %o0: sysino
1730 *
1731 * returns %o0: intr_state (HV_INTR_STATE_*)
1732 */
1733 .globl sun4v_intr_getstate
1734 .type sun4v_intr_getstate,#function
1735sun4v_intr_getstate:
1736 mov HV_FAST_INTR_GETSTATE, %o5
1737 ta HV_FAST_TRAP
1738 retl
1739 mov %o1, %o0
1740 .size sun4v_intr_getstate, .-sun4v_intr_getstate
1741
1742 /* %o0: sysino
1743 * %o1: intr_state (HV_INTR_STATE_*)
1744 */
1745 .globl sun4v_intr_setstate
1746 .type sun4v_intr_setstate,#function
1747sun4v_intr_setstate:
1748 mov HV_FAST_INTR_SETSTATE, %o5
1749 ta HV_FAST_TRAP
1750 retl
1751 nop
1752 .size sun4v_intr_setstate, .-sun4v_intr_setstate
1753
1754 /* %o0: sysino
1755 *
1756 * returns %o0: cpuid
1757 */
1758 .globl sun4v_intr_gettarget
1759 .type sun4v_intr_gettarget,#function
1760sun4v_intr_gettarget:
1761 mov HV_FAST_INTR_GETTARGET, %o5
1762 ta HV_FAST_TRAP
1763 retl
1764 mov %o1, %o0
1765 .size sun4v_intr_gettarget, .-sun4v_intr_gettarget
1766
1767 /* %o0: sysino
1768 * %o1: cpuid
1769 */
1770 .globl sun4v_intr_settarget
1771 .type sun4v_intr_settarget,#function
1772sun4v_intr_settarget:
1773 mov HV_FAST_INTR_SETTARGET, %o5
1774 ta HV_FAST_TRAP
1775 retl
1776 nop
1777 .size sun4v_intr_settarget, .-sun4v_intr_settarget
1778
1779 /* %o0: cpuid
1780 * %o1: pc
1781 * %o2: rtba
1782 * %o3: arg0
1783 *
1784 * returns %o0: status
1785 */
1786 .globl sun4v_cpu_start
1787 .type sun4v_cpu_start,#function
1788sun4v_cpu_start:
1789 mov HV_FAST_CPU_START, %o5
1790 ta HV_FAST_TRAP
1791 retl
1792 nop
1793 .size sun4v_cpu_start, .-sun4v_cpu_start
1794
1795 /* %o0: cpuid
1796 *
1797 * returns %o0: status
1798 */
1799 .globl sun4v_cpu_stop
1800 .type sun4v_cpu_stop,#function
1801sun4v_cpu_stop:
1802 mov HV_FAST_CPU_STOP, %o5
1803 ta HV_FAST_TRAP
1804 retl
1805 nop
1806 .size sun4v_cpu_stop, .-sun4v_cpu_stop
1807
1808 /* returns %o0: status */
1809 .globl sun4v_cpu_yield
1810 .type sun4v_cpu_yield, #function
1811sun4v_cpu_yield:
1812 mov HV_FAST_CPU_YIELD, %o5
1813 ta HV_FAST_TRAP
1814 retl
1815 nop
1816 .size sun4v_cpu_yield, .-sun4v_cpu_yield
1817
1818 /* %o0: type
1819 * %o1: queue paddr
1820 * %o2: num queue entries
1821 *
1822 * returns %o0: status
1823 */
1824 .globl sun4v_cpu_qconf
1825 .type sun4v_cpu_qconf,#function
1826sun4v_cpu_qconf:
1827 mov HV_FAST_CPU_QCONF, %o5
1828 ta HV_FAST_TRAP
1829 retl
1830 nop
1831 .size sun4v_cpu_qconf, .-sun4v_cpu_qconf
1832
1833 /* %o0: num cpus in cpu list
1834 * %o1: cpu list paddr
1835 * %o2: mondo block paddr
1836 *
1837 * returns %o0: status
1838 */
1839 .globl sun4v_cpu_mondo_send
1840 .type sun4v_cpu_mondo_send,#function
1841sun4v_cpu_mondo_send:
1842 mov HV_FAST_CPU_MONDO_SEND, %o5
1843 ta HV_FAST_TRAP
1844 retl
1845 nop
1846 .size sun4v_cpu_mondo_send, .-sun4v_cpu_mondo_send
1847
1848 /* %o0: CPU ID
1849 *
1850 * returns %o0: -status if status non-zero, else
1851 * %o0: cpu state as HV_CPU_STATE_*
1852 */
1853 .globl sun4v_cpu_state
1854 .type sun4v_cpu_state,#function
1855sun4v_cpu_state:
1856 mov HV_FAST_CPU_STATE, %o5
1857 ta HV_FAST_TRAP
1858 brnz,pn %o0, 1f
1859 sub %g0, %o0, %o0
1860 mov %o1, %o0
18611: retl
1862 nop
1863 .size sun4v_cpu_state, .-sun4v_cpu_state
1864
1865 /* %o0: virtual address
1866 * %o1: must be zero
1867 * %o2: TTE
1868 * %o3: HV_MMU_* flags
1869 *
1870 * returns %o0: status
1871 */
1872 .globl sun4v_mmu_map_perm_addr
1873 .type sun4v_mmu_map_perm_addr,#function
1874sun4v_mmu_map_perm_addr:
1875 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
1876 ta HV_FAST_TRAP
1877 retl
1878 nop
1879 .size sun4v_mmu_map_perm_addr, .-sun4v_mmu_map_perm_addr
1880
1881 /* %o0: number of TSB descriptions
1882 * %o1: TSB descriptions real address
1883 *
1884 * returns %o0: status
1885 */
1886 .globl sun4v_mmu_tsb_ctx0
1887 .type sun4v_mmu_tsb_ctx0,#function
1888sun4v_mmu_tsb_ctx0:
1889 mov HV_FAST_MMU_TSB_CTX0, %o5
1890 ta HV_FAST_TRAP
1891 retl
1892 nop
1893 .size sun4v_mmu_tsb_ctx0, .-sun4v_mmu_tsb_ctx0
1894
1895 /* %o0: API group number
1896 * %o1: pointer to unsigned long major number storage
1897 * %o2: pointer to unsigned long minor number storage
1898 *
1899 * returns %o0: status
1900 */
1901 .globl sun4v_get_version
1902 .type sun4v_get_version,#function
1903sun4v_get_version:
1904 mov HV_CORE_GET_VER, %o5
1905 mov %o1, %o3
1906 mov %o2, %o4
1907 ta HV_CORE_TRAP
1908 stx %o1, [%o3]
1909 retl
1910 stx %o2, [%o4]
1911 .size sun4v_get_version, .-sun4v_get_version
1912
1913 /* %o0: API group number
1914 * %o1: desired major number
1915 * %o2: desired minor number
1916 * %o3: pointer to unsigned long actual minor number storage
1917 *
1918 * returns %o0: status
1919 */
1920 .globl sun4v_set_version
1921 .type sun4v_set_version,#function
1922sun4v_set_version:
1923 mov HV_CORE_SET_VER, %o5
1924 mov %o3, %o4
1925 ta HV_CORE_TRAP
1926 retl
1927 stx %o1, [%o4]
1928 .size sun4v_set_version, .-sun4v_set_version
1929
1930 /* %o0: pointer to unsigned long time
1931 *
1932 * returns %o0: status
1933 */
1934 .globl sun4v_tod_get
1935 .type sun4v_tod_get,#function
1936sun4v_tod_get:
1937 mov %o0, %o4
1938 mov HV_FAST_TOD_GET, %o5
1939 ta HV_FAST_TRAP
1940 stx %o1, [%o4]
1941 retl
1942 nop
1943 .size sun4v_tod_get, .-sun4v_tod_get
1944
1945 /* %o0: time
1946 *
1947 * returns %o0: status
1948 */
1949 .globl sun4v_tod_set
1950 .type sun4v_tod_set,#function
1951sun4v_tod_set:
1952 mov HV_FAST_TOD_SET, %o5
1953 ta HV_FAST_TRAP
1954 retl
1955 nop
1956 .size sun4v_tod_set, .-sun4v_tod_set
1957
1958 /* %o0: pointer to unsigned long status
1959 *
1960 * returns %o0: signed character
1961 */
1962 .globl sun4v_con_getchar
1963 .type sun4v_con_getchar,#function
1964sun4v_con_getchar:
1965 mov %o0, %o4
1966 mov HV_FAST_CONS_GETCHAR, %o5
1967 clr %o0
1968 clr %o1
1969 ta HV_FAST_TRAP
1970 stx %o0, [%o4]
1971 retl
1972 sra %o1, 0, %o0
1973 .size sun4v_con_getchar, .-sun4v_con_getchar
1974
1975 /* %o0: signed long character
1976 *
1977 * returns %o0: status
1978 */
1979 .globl sun4v_con_putchar
1980 .type sun4v_con_putchar,#function
1981sun4v_con_putchar:
1982 mov HV_FAST_CONS_PUTCHAR, %o5
1983 ta HV_FAST_TRAP
1984 retl
1985 sra %o0, 0, %o0
1986 .size sun4v_con_putchar, .-sun4v_con_putchar
1987
1988 /* %o0: buffer real address
1989 * %o1: buffer size
1990 * %o2: pointer to unsigned long bytes_read
1991 *
1992 * returns %o0: status
1993 */
1994 .globl sun4v_con_read
1995 .type sun4v_con_read,#function
1996sun4v_con_read:
1997 mov %o2, %o4
1998 mov HV_FAST_CONS_READ, %o5
1999 ta HV_FAST_TRAP
2000 brnz %o0, 1f
2001 cmp %o1, -1 /* break */
2002 be,a,pn %icc, 1f
2003 mov %o1, %o0
2004 cmp %o1, -2 /* hup */
2005 be,a,pn %icc, 1f
2006 mov %o1, %o0
2007 stx %o1, [%o4]
20081: retl
2009 nop
2010 .size sun4v_con_read, .-sun4v_con_read
2011
2012 /* %o0: buffer real address
2013 * %o1: buffer size
2014 * %o2: pointer to unsigned long bytes_written
2015 *
2016 * returns %o0: status
2017 */
2018 .globl sun4v_con_write
2019 .type sun4v_con_write,#function
2020sun4v_con_write:
2021 mov %o2, %o4
2022 mov HV_FAST_CONS_WRITE, %o5
2023 ta HV_FAST_TRAP
2024 stx %o1, [%o4]
2025 retl
2026 nop
2027 .size sun4v_con_write, .-sun4v_con_write
2028
2029 /* %o0: soft state
2030 * %o1: address of description string
2031 *
2032 * returns %o0: status
2033 */
2034 .globl sun4v_mach_set_soft_state
2035 .type sun4v_mach_set_soft_state,#function
2036sun4v_mach_set_soft_state:
2037 mov HV_FAST_MACH_SET_SOFT_STATE, %o5
2038 ta HV_FAST_TRAP
2039 retl
2040 nop
2041 .size sun4v_mach_set_soft_state, .-sun4v_mach_set_soft_state
2042
2043 /* %o0: exit code
2044 *
2045 * Does not return.
2046 */
2047 .globl sun4v_mach_exit
2048 .type sun4v_mach_exit,#function
2049sun4v_mach_exit:
2050 mov HV_FAST_MACH_EXIT, %o5
2051 ta HV_FAST_TRAP
2052 retl
2053 nop
2054 .size sun4v_mach_exit, .-sun4v_mach_exit
2055
2056 /* %o0: buffer real address
2057 * %o1: buffer length
2058 * %o2: pointer to unsigned long real_buf_len
2059 *
2060 * returns %o0: status
2061 */
2062 .globl sun4v_mach_desc
2063 .type sun4v_mach_desc,#function
2064sun4v_mach_desc:
2065 mov %o2, %o4
2066 mov HV_FAST_MACH_DESC, %o5
2067 ta HV_FAST_TRAP
2068 stx %o1, [%o4]
2069 retl
2070 nop
2071 .size sun4v_mach_desc, .-sun4v_mach_desc
2072
2073 /* %o0: new timeout in milliseconds
2074 * %o1: pointer to unsigned long orig_timeout
2075 *
2076 * returns %o0: status
2077 */
2078 .globl sun4v_mach_set_watchdog
2079 .type sun4v_mach_set_watchdog,#function
2080sun4v_mach_set_watchdog:
2081 mov %o1, %o4
2082 mov HV_FAST_MACH_SET_WATCHDOG, %o5
2083 ta HV_FAST_TRAP
2084 stx %o1, [%o4]
2085 retl
2086 nop
2087 .size sun4v_mach_set_watchdog, .-sun4v_mach_set_watchdog
2088
2089 /* No inputs and does not return. */
2090 .globl sun4v_mach_sir
2091 .type sun4v_mach_sir,#function
2092sun4v_mach_sir:
2093 mov %o1, %o4
2094 mov HV_FAST_MACH_SIR, %o5
2095 ta HV_FAST_TRAP
2096 stx %o1, [%o4]
2097 retl
2098 nop
2099 .size sun4v_mach_sir, .-sun4v_mach_sir
2100
2101 /* %o0: channel
2102 * %o1: ra
2103 * %o2: num_entries
2104 *
2105 * returns %o0: status
2106 */
2107 .globl sun4v_ldc_tx_qconf
2108 .type sun4v_ldc_tx_qconf,#function
2109sun4v_ldc_tx_qconf:
2110 mov HV_FAST_LDC_TX_QCONF, %o5
2111 ta HV_FAST_TRAP
2112 retl
2113 nop
2114 .size sun4v_ldc_tx_qconf, .-sun4v_ldc_tx_qconf
2115
2116 /* %o0: channel
2117 * %o1: pointer to unsigned long ra
2118 * %o2: pointer to unsigned long num_entries
2119 *
2120 * returns %o0: status
2121 */
2122 .globl sun4v_ldc_tx_qinfo
2123 .type sun4v_ldc_tx_qinfo,#function
2124sun4v_ldc_tx_qinfo:
2125 mov %o1, %g1
2126 mov %o2, %g2
2127 mov HV_FAST_LDC_TX_QINFO, %o5
2128 ta HV_FAST_TRAP
2129 stx %o1, [%g1]
2130 stx %o2, [%g2]
2131 retl
2132 nop
2133 .size sun4v_ldc_tx_qinfo, .-sun4v_ldc_tx_qinfo
2134
2135 /* %o0: channel
2136 * %o1: pointer to unsigned long head_off
2137 * %o2: pointer to unsigned long tail_off
2138 * %o2: pointer to unsigned long chan_state
2139 *
2140 * returns %o0: status
2141 */
2142 .globl sun4v_ldc_tx_get_state
2143 .type sun4v_ldc_tx_get_state,#function
2144sun4v_ldc_tx_get_state:
2145 mov %o1, %g1
2146 mov %o2, %g2
2147 mov %o3, %g3
2148 mov HV_FAST_LDC_TX_GET_STATE, %o5
2149 ta HV_FAST_TRAP
2150 stx %o1, [%g1]
2151 stx %o2, [%g2]
2152 stx %o3, [%g3]
2153 retl
2154 nop
2155 .size sun4v_ldc_tx_get_state, .-sun4v_ldc_tx_get_state
2156
2157 /* %o0: channel
2158 * %o1: tail_off
2159 *
2160 * returns %o0: status
2161 */
2162 .globl sun4v_ldc_tx_set_qtail
2163 .type sun4v_ldc_tx_set_qtail,#function
2164sun4v_ldc_tx_set_qtail:
2165 mov HV_FAST_LDC_TX_SET_QTAIL, %o5
2166 ta HV_FAST_TRAP
2167 retl
2168 nop
2169 .size sun4v_ldc_tx_set_qtail, .-sun4v_ldc_tx_set_qtail
2170
2171 /* %o0: channel
2172 * %o1: ra
2173 * %o2: num_entries
2174 *
2175 * returns %o0: status
2176 */
2177 .globl sun4v_ldc_rx_qconf
2178 .type sun4v_ldc_rx_qconf,#function
2179sun4v_ldc_rx_qconf:
2180 mov HV_FAST_LDC_RX_QCONF, %o5
2181 ta HV_FAST_TRAP
2182 retl
2183 nop
2184 .size sun4v_ldc_rx_qconf, .-sun4v_ldc_rx_qconf
2185
2186 /* %o0: channel
2187 * %o1: pointer to unsigned long ra
2188 * %o2: pointer to unsigned long num_entries
2189 *
2190 * returns %o0: status
2191 */
2192 .globl sun4v_ldc_rx_qinfo
2193 .type sun4v_ldc_rx_qinfo,#function
2194sun4v_ldc_rx_qinfo:
2195 mov %o1, %g1
2196 mov %o2, %g2
2197 mov HV_FAST_LDC_RX_QINFO, %o5
2198 ta HV_FAST_TRAP
2199 stx %o1, [%g1]
2200 stx %o2, [%g2]
2201 retl
2202 nop
2203 .size sun4v_ldc_rx_qinfo, .-sun4v_ldc_rx_qinfo
2204
2205 /* %o0: channel
2206 * %o1: pointer to unsigned long head_off
2207 * %o2: pointer to unsigned long tail_off
2208 * %o2: pointer to unsigned long chan_state
2209 *
2210 * returns %o0: status
2211 */
2212 .globl sun4v_ldc_rx_get_state
2213 .type sun4v_ldc_rx_get_state,#function
2214sun4v_ldc_rx_get_state:
2215 mov %o1, %g1
2216 mov %o2, %g2
2217 mov %o3, %g3
2218 mov HV_FAST_LDC_RX_GET_STATE, %o5
2219 ta HV_FAST_TRAP
2220 stx %o1, [%g1]
2221 stx %o2, [%g2]
2222 stx %o3, [%g3]
2223 retl
2224 nop
2225 .size sun4v_ldc_rx_get_state, .-sun4v_ldc_rx_get_state
2226
2227 /* %o0: channel
2228 * %o1: head_off
2229 *
2230 * returns %o0: status
2231 */
2232 .globl sun4v_ldc_rx_set_qhead
2233 .type sun4v_ldc_rx_set_qhead,#function
2234sun4v_ldc_rx_set_qhead:
2235 mov HV_FAST_LDC_RX_SET_QHEAD, %o5
2236 ta HV_FAST_TRAP
2237 retl
2238 nop
2239 .size sun4v_ldc_rx_set_qhead, .-sun4v_ldc_rx_set_qhead
2240
2241 /* %o0: channel
2242 * %o1: ra
2243 * %o2: num_entries
2244 *
2245 * returns %o0: status
2246 */
2247 .globl sun4v_ldc_set_map_table
2248 .type sun4v_ldc_set_map_table,#function
2249sun4v_ldc_set_map_table:
2250 mov HV_FAST_LDC_SET_MAP_TABLE, %o5
2251 ta HV_FAST_TRAP
2252 retl
2253 nop
2254 .size sun4v_ldc_set_map_table, .-sun4v_ldc_set_map_table
2255
2256 /* %o0: channel
2257 * %o1: pointer to unsigned long ra
2258 * %o2: pointer to unsigned long num_entries
2259 *
2260 * returns %o0: status
2261 */
2262 .globl sun4v_ldc_get_map_table
2263 .type sun4v_ldc_get_map_table,#function
2264sun4v_ldc_get_map_table:
2265 mov %o1, %g1
2266 mov %o2, %g2
2267 mov HV_FAST_LDC_GET_MAP_TABLE, %o5
2268 ta HV_FAST_TRAP
2269 stx %o1, [%g1]
2270 stx %o2, [%g2]
2271 retl
2272 nop
2273 .size sun4v_ldc_get_map_table, .-sun4v_ldc_get_map_table
2274
2275 /* %o0: channel
2276 * %o1: dir_code
2277 * %o2: tgt_raddr
2278 * %o3: lcl_raddr
2279 * %o4: len
2280 * %o5: pointer to unsigned long actual_len
2281 *
2282 * returns %o0: status
2283 */
2284 .globl sun4v_ldc_copy
2285 .type sun4v_ldc_copy,#function
2286sun4v_ldc_copy:
2287 mov %o5, %g1
2288 mov HV_FAST_LDC_COPY, %o5
2289 ta HV_FAST_TRAP
2290 stx %o1, [%g1]
2291 retl
2292 nop
2293 .size sun4v_ldc_copy, .-sun4v_ldc_copy
2294
2295 /* %o0: channel
2296 * %o1: cookie
2297 * %o2: pointer to unsigned long ra
2298 * %o3: pointer to unsigned long perm
2299 *
2300 * returns %o0: status
2301 */
2302 .globl sun4v_ldc_mapin
2303 .type sun4v_ldc_mapin,#function
2304sun4v_ldc_mapin:
2305 mov %o2, %g1
2306 mov %o3, %g2
2307 mov HV_FAST_LDC_MAPIN, %o5
2308 ta HV_FAST_TRAP
2309 stx %o1, [%g1]
2310 stx %o2, [%g2]
2311 retl
2312 nop
2313 .size sun4v_ldc_mapin, .-sun4v_ldc_mapin
2314
2315 /* %o0: ra
2316 *
2317 * returns %o0: status
2318 */
2319 .globl sun4v_ldc_unmap
2320 .type sun4v_ldc_unmap,#function
2321sun4v_ldc_unmap:
2322 mov HV_FAST_LDC_UNMAP, %o5
2323 ta HV_FAST_TRAP
2324 retl
2325 nop
2326 .size sun4v_ldc_unmap, .-sun4v_ldc_unmap
2327
2328 /* %o0: channel
2329 * %o1: cookie
2330 * %o2: mte_cookie
2331 *
2332 * returns %o0: status
2333 */
2334 .globl sun4v_ldc_revoke
2335 .type sun4v_ldc_revoke,#function
2336sun4v_ldc_revoke:
2337 mov HV_FAST_LDC_REVOKE, %o5
2338 ta HV_FAST_TRAP
2339 retl
2340 nop
2341 .size sun4v_ldc_revoke, .-sun4v_ldc_revoke
2342
2343 /* %o0: device handle
2344 * %o1: device INO
2345 * %o2: pointer to unsigned long cookie
2346 *
2347 * returns %o0: status
2348 */
2349 .globl sun4v_vintr_get_cookie
2350 .type sun4v_vintr_get_cookie,#function
2351sun4v_vintr_get_cookie:
2352 mov %o2, %g1
2353 mov HV_FAST_VINTR_GET_COOKIE, %o5
2354 ta HV_FAST_TRAP
2355 stx %o1, [%g1]
2356 retl
2357 nop
2358 .size sun4v_vintr_get_cookie, .-sun4v_vintr_get_cookie
2359
2360 /* %o0: device handle
2361 * %o1: device INO
2362 * %o2: cookie
2363 *
2364 * returns %o0: status
2365 */
2366 .globl sun4v_vintr_set_cookie
2367 .type sun4v_vintr_set_cookie,#function
2368sun4v_vintr_set_cookie:
2369 mov HV_FAST_VINTR_SET_COOKIE, %o5
2370 ta HV_FAST_TRAP
2371 retl
2372 nop
2373 .size sun4v_vintr_set_cookie, .-sun4v_vintr_set_cookie
2374
2375 /* %o0: device handle
2376 * %o1: device INO
2377 * %o2: pointer to unsigned long valid_state
2378 *
2379 * returns %o0: status
2380 */
2381 .globl sun4v_vintr_get_valid
2382 .type sun4v_vintr_get_valid,#function
2383sun4v_vintr_get_valid:
2384 mov %o2, %g1
2385 mov HV_FAST_VINTR_GET_VALID, %o5
2386 ta HV_FAST_TRAP
2387 stx %o1, [%g1]
2388 retl
2389 nop
2390 .size sun4v_vintr_get_valid, .-sun4v_vintr_get_valid
2391
2392 /* %o0: device handle
2393 * %o1: device INO
2394 * %o2: valid_state
2395 *
2396 * returns %o0: status
2397 */
2398 .globl sun4v_vintr_set_valid
2399 .type sun4v_vintr_set_valid,#function
2400sun4v_vintr_set_valid:
2401 mov HV_FAST_VINTR_SET_VALID, %o5
2402 ta HV_FAST_TRAP
2403 retl
2404 nop
2405 .size sun4v_vintr_set_valid, .-sun4v_vintr_set_valid
2406
2407 /* %o0: device handle
2408 * %o1: device INO
2409 * %o2: pointer to unsigned long state
2410 *
2411 * returns %o0: status
2412 */
2413 .globl sun4v_vintr_get_state
2414 .type sun4v_vintr_get_state,#function
2415sun4v_vintr_get_state:
2416 mov %o2, %g1
2417 mov HV_FAST_VINTR_GET_STATE, %o5
2418 ta HV_FAST_TRAP
2419 stx %o1, [%g1]
2420 retl
2421 nop
2422 .size sun4v_vintr_get_state, .-sun4v_vintr_get_state
2423
2424 /* %o0: device handle
2425 * %o1: device INO
2426 * %o2: state
2427 *
2428 * returns %o0: status
2429 */
2430 .globl sun4v_vintr_set_state
2431 .type sun4v_vintr_set_state,#function
2432sun4v_vintr_set_state:
2433 mov HV_FAST_VINTR_SET_STATE, %o5
2434 ta HV_FAST_TRAP
2435 retl
2436 nop
2437 .size sun4v_vintr_set_state, .-sun4v_vintr_set_state
2438
2439 /* %o0: device handle
2440 * %o1: device INO
2441 * %o2: pointer to unsigned long cpuid
2442 *
2443 * returns %o0: status
2444 */
2445 .globl sun4v_vintr_get_target
2446 .type sun4v_vintr_get_target,#function
2447sun4v_vintr_get_target:
2448 mov %o2, %g1
2449 mov HV_FAST_VINTR_GET_TARGET, %o5
2450 ta HV_FAST_TRAP
2451 stx %o1, [%g1]
2452 retl
2453 nop
2454 .size sun4v_vintr_get_target, .-sun4v_vintr_get_target
2455
2456 /* %o0: device handle
2457 * %o1: device INO
2458 * %o2: cpuid
2459 *
2460 * returns %o0: status
2461 */
2462 .globl sun4v_vintr_set_target
2463 .type sun4v_vintr_set_target,#function
2464sun4v_vintr_set_target:
2465 mov HV_FAST_VINTR_SET_TARGET, %o5
2466 ta HV_FAST_TRAP
2467 retl
2468 nop
2469 .size sun4v_vintr_set_target, .-sun4v_vintr_set_target
2470
2471 /* %o0: NCS sub-function
2472 * %o1: sub-function arg real-address
2473 * %o2: sub-function arg size
2474 *
2475 * returns %o0: status
2476 */
2477 .globl sun4v_ncs_request
2478 .type sun4v_ncs_request,#function
2479sun4v_ncs_request:
2480 mov HV_FAST_NCS_REQUEST, %o5
2481 ta HV_FAST_TRAP
2482 retl
2483 nop
2484 .size sun4v_ncs_request, .-sun4v_ncs_request
2485
2486 .globl sun4v_svc_send
2487 .type sun4v_svc_send,#function
2488sun4v_svc_send:
2489 save %sp, -192, %sp
2490 mov %i0, %o0
2491 mov %i1, %o1
2492 mov %i2, %o2
2493 mov HV_FAST_SVC_SEND, %o5
2494 ta HV_FAST_TRAP
2495 stx %o1, [%i3]
2496 ret
2497 restore
2498 .size sun4v_svc_send, .-sun4v_svc_send
2499
2500 .globl sun4v_svc_recv
2501 .type sun4v_svc_recv,#function
2502sun4v_svc_recv:
2503 save %sp, -192, %sp
2504 mov %i0, %o0
2505 mov %i1, %o1
2506 mov %i2, %o2
2507 mov HV_FAST_SVC_RECV, %o5
2508 ta HV_FAST_TRAP
2509 stx %o1, [%i3]
2510 ret
2511 restore
2512 .size sun4v_svc_recv, .-sun4v_svc_recv
2513
2514 .globl sun4v_svc_getstatus
2515 .type sun4v_svc_getstatus,#function
2516sun4v_svc_getstatus:
2517 mov HV_FAST_SVC_GETSTATUS, %o5
2518 mov %o1, %o4
2519 ta HV_FAST_TRAP
2520 stx %o1, [%o4]
2521 retl
2522 nop
2523 .size sun4v_svc_getstatus, .-sun4v_svc_getstatus
2524
2525 .globl sun4v_svc_setstatus
2526 .type sun4v_svc_setstatus,#function
2527sun4v_svc_setstatus:
2528 mov HV_FAST_SVC_SETSTATUS, %o5
2529 ta HV_FAST_TRAP
2530 retl
2531 nop
2532 .size sun4v_svc_setstatus, .-sun4v_svc_setstatus
2533
2534 .globl sun4v_svc_clrstatus
2535 .type sun4v_svc_clrstatus,#function
2536sun4v_svc_clrstatus:
2537 mov HV_FAST_SVC_CLRSTATUS, %o5
2538 ta HV_FAST_TRAP
2539 retl
2540 nop
2541 .size sun4v_svc_clrstatus, .-sun4v_svc_clrstatus
2542
2543 .globl sun4v_mmustat_conf
2544 .type sun4v_mmustat_conf,#function
2545sun4v_mmustat_conf:
2546 mov %o1, %o4
2547 mov HV_FAST_MMUSTAT_CONF, %o5
2548 ta HV_FAST_TRAP
2549 stx %o1, [%o4]
2550 retl
2551 nop
2552 .size sun4v_mmustat_conf, .-sun4v_mmustat_conf
2553
2554 .globl sun4v_mmustat_info
2555 .type sun4v_mmustat_info,#function
2556sun4v_mmustat_info:
2557 mov %o0, %o4
2558 mov HV_FAST_MMUSTAT_INFO, %o5
2559 ta HV_FAST_TRAP
2560 stx %o1, [%o4]
2561 retl
2562 nop
2563 .size sun4v_mmustat_info, .-sun4v_mmustat_info
2564
2565 .globl sun4v_mmu_demap_all
2566 .type sun4v_mmu_demap_all,#function
2567sun4v_mmu_demap_all:
2568 clr %o0
2569 clr %o1
2570 mov HV_MMU_ALL, %o2
2571 mov HV_FAST_MMU_DEMAP_ALL, %o5
2572 ta HV_FAST_TRAP
2573 retl
2574 nop
2575 .size sun4v_mmu_demap_all, .-sun4v_mmu_demap_all
diff --git a/arch/sparc64/kernel/fpu_traps.S b/arch/sparc64/kernel/fpu_traps.S
new file mode 100644
index 000000000000..a6864826a4bd
--- /dev/null
+++ b/arch/sparc64/kernel/fpu_traps.S
@@ -0,0 +1,384 @@
1 /* This is trivial with the new code... */
2 .globl do_fpdis
3 .type do_fpdis,#function
4do_fpdis:
5 sethi %hi(TSTATE_PEF), %g4
6 rdpr %tstate, %g5
7 andcc %g5, %g4, %g0
8 be,pt %xcc, 1f
9 nop
10 rd %fprs, %g5
11 andcc %g5, FPRS_FEF, %g0
12 be,pt %xcc, 1f
13 nop
14
15 /* Legal state when DCR_IFPOE is set in Cheetah %dcr. */
16 sethi %hi(109f), %g7
17 ba,pt %xcc, etrap
18109: or %g7, %lo(109b), %g7
19 add %g0, %g0, %g0
20 ba,a,pt %xcc, rtrap
21
221: TRAP_LOAD_THREAD_REG(%g6, %g1)
23 ldub [%g6 + TI_FPSAVED], %g5
24 wr %g0, FPRS_FEF, %fprs
25 andcc %g5, FPRS_FEF, %g0
26 be,a,pt %icc, 1f
27 clr %g7
28 ldx [%g6 + TI_GSR], %g7
291: andcc %g5, FPRS_DL, %g0
30 bne,pn %icc, 2f
31 fzero %f0
32 andcc %g5, FPRS_DU, %g0
33 bne,pn %icc, 1f
34 fzero %f2
35 faddd %f0, %f2, %f4
36 fmuld %f0, %f2, %f6
37 faddd %f0, %f2, %f8
38 fmuld %f0, %f2, %f10
39 faddd %f0, %f2, %f12
40 fmuld %f0, %f2, %f14
41 faddd %f0, %f2, %f16
42 fmuld %f0, %f2, %f18
43 faddd %f0, %f2, %f20
44 fmuld %f0, %f2, %f22
45 faddd %f0, %f2, %f24
46 fmuld %f0, %f2, %f26
47 faddd %f0, %f2, %f28
48 fmuld %f0, %f2, %f30
49 faddd %f0, %f2, %f32
50 fmuld %f0, %f2, %f34
51 faddd %f0, %f2, %f36
52 fmuld %f0, %f2, %f38
53 faddd %f0, %f2, %f40
54 fmuld %f0, %f2, %f42
55 faddd %f0, %f2, %f44
56 fmuld %f0, %f2, %f46
57 faddd %f0, %f2, %f48
58 fmuld %f0, %f2, %f50
59 faddd %f0, %f2, %f52
60 fmuld %f0, %f2, %f54
61 faddd %f0, %f2, %f56
62 fmuld %f0, %f2, %f58
63 b,pt %xcc, fpdis_exit2
64 faddd %f0, %f2, %f60
651: mov SECONDARY_CONTEXT, %g3
66 add %g6, TI_FPREGS + 0x80, %g1
67 faddd %f0, %f2, %f4
68 fmuld %f0, %f2, %f6
69
70661: ldxa [%g3] ASI_DMMU, %g5
71 .section .sun4v_1insn_patch, "ax"
72 .word 661b
73 ldxa [%g3] ASI_MMU, %g5
74 .previous
75
76 sethi %hi(sparc64_kern_sec_context), %g2
77 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
78
79661: stxa %g2, [%g3] ASI_DMMU
80 .section .sun4v_1insn_patch, "ax"
81 .word 661b
82 stxa %g2, [%g3] ASI_MMU
83 .previous
84
85 membar #Sync
86 add %g6, TI_FPREGS + 0xc0, %g2
87 faddd %f0, %f2, %f8
88 fmuld %f0, %f2, %f10
89 membar #Sync
90 ldda [%g1] ASI_BLK_S, %f32
91 ldda [%g2] ASI_BLK_S, %f48
92 membar #Sync
93 faddd %f0, %f2, %f12
94 fmuld %f0, %f2, %f14
95 faddd %f0, %f2, %f16
96 fmuld %f0, %f2, %f18
97 faddd %f0, %f2, %f20
98 fmuld %f0, %f2, %f22
99 faddd %f0, %f2, %f24
100 fmuld %f0, %f2, %f26
101 faddd %f0, %f2, %f28
102 fmuld %f0, %f2, %f30
103 b,pt %xcc, fpdis_exit
104 nop
1052: andcc %g5, FPRS_DU, %g0
106 bne,pt %icc, 3f
107 fzero %f32
108 mov SECONDARY_CONTEXT, %g3
109 fzero %f34
110
111661: ldxa [%g3] ASI_DMMU, %g5
112 .section .sun4v_1insn_patch, "ax"
113 .word 661b
114 ldxa [%g3] ASI_MMU, %g5
115 .previous
116
117 add %g6, TI_FPREGS, %g1
118 sethi %hi(sparc64_kern_sec_context), %g2
119 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
120
121661: stxa %g2, [%g3] ASI_DMMU
122 .section .sun4v_1insn_patch, "ax"
123 .word 661b
124 stxa %g2, [%g3] ASI_MMU
125 .previous
126
127 membar #Sync
128 add %g6, TI_FPREGS + 0x40, %g2
129 faddd %f32, %f34, %f36
130 fmuld %f32, %f34, %f38
131 membar #Sync
132 ldda [%g1] ASI_BLK_S, %f0
133 ldda [%g2] ASI_BLK_S, %f16
134 membar #Sync
135 faddd %f32, %f34, %f40
136 fmuld %f32, %f34, %f42
137 faddd %f32, %f34, %f44
138 fmuld %f32, %f34, %f46
139 faddd %f32, %f34, %f48
140 fmuld %f32, %f34, %f50
141 faddd %f32, %f34, %f52
142 fmuld %f32, %f34, %f54
143 faddd %f32, %f34, %f56
144 fmuld %f32, %f34, %f58
145 faddd %f32, %f34, %f60
146 fmuld %f32, %f34, %f62
147 ba,pt %xcc, fpdis_exit
148 nop
1493: mov SECONDARY_CONTEXT, %g3
150 add %g6, TI_FPREGS, %g1
151
152661: ldxa [%g3] ASI_DMMU, %g5
153 .section .sun4v_1insn_patch, "ax"
154 .word 661b
155 ldxa [%g3] ASI_MMU, %g5
156 .previous
157
158 sethi %hi(sparc64_kern_sec_context), %g2
159 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
160
161661: stxa %g2, [%g3] ASI_DMMU
162 .section .sun4v_1insn_patch, "ax"
163 .word 661b
164 stxa %g2, [%g3] ASI_MMU
165 .previous
166
167 membar #Sync
168 mov 0x40, %g2
169 membar #Sync
170 ldda [%g1] ASI_BLK_S, %f0
171 ldda [%g1 + %g2] ASI_BLK_S, %f16
172 add %g1, 0x80, %g1
173 ldda [%g1] ASI_BLK_S, %f32
174 ldda [%g1 + %g2] ASI_BLK_S, %f48
175 membar #Sync
176fpdis_exit:
177
178661: stxa %g5, [%g3] ASI_DMMU
179 .section .sun4v_1insn_patch, "ax"
180 .word 661b
181 stxa %g5, [%g3] ASI_MMU
182 .previous
183
184 membar #Sync
185fpdis_exit2:
186 wr %g7, 0, %gsr
187 ldx [%g6 + TI_XFSR], %fsr
188 rdpr %tstate, %g3
189 or %g3, %g4, %g3 ! anal...
190 wrpr %g3, %tstate
191 wr %g0, FPRS_FEF, %fprs ! clean DU/DL bits
192 retry
193 .size do_fpdis,.-do_fpdis
194
195 .align 32
196 .type fp_other_bounce,#function
197fp_other_bounce:
198 call do_fpother
199 add %sp, PTREGS_OFF, %o0
200 ba,pt %xcc, rtrap
201 nop
202 .size fp_other_bounce,.-fp_other_bounce
203
204 .align 32
205 .globl do_fpother_check_fitos
206 .type do_fpother_check_fitos,#function
207do_fpother_check_fitos:
208 TRAP_LOAD_THREAD_REG(%g6, %g1)
209 sethi %hi(fp_other_bounce - 4), %g7
210 or %g7, %lo(fp_other_bounce - 4), %g7
211
212 /* NOTE: Need to preserve %g7 until we fully commit
213 * to the fitos fixup.
214 */
215 stx %fsr, [%g6 + TI_XFSR]
216 rdpr %tstate, %g3
217 andcc %g3, TSTATE_PRIV, %g0
218 bne,pn %xcc, do_fptrap_after_fsr
219 nop
220 ldx [%g6 + TI_XFSR], %g3
221 srlx %g3, 14, %g1
222 and %g1, 7, %g1
223 cmp %g1, 2 ! Unfinished FP-OP
224 bne,pn %xcc, do_fptrap_after_fsr
225 sethi %hi(1 << 23), %g1 ! Inexact
226 andcc %g3, %g1, %g0
227 bne,pn %xcc, do_fptrap_after_fsr
228 rdpr %tpc, %g1
229 lduwa [%g1] ASI_AIUP, %g3 ! This cannot ever fail
230#define FITOS_MASK 0xc1f83fe0
231#define FITOS_COMPARE 0x81a01880
232 sethi %hi(FITOS_MASK), %g1
233 or %g1, %lo(FITOS_MASK), %g1
234 and %g3, %g1, %g1
235 sethi %hi(FITOS_COMPARE), %g2
236 or %g2, %lo(FITOS_COMPARE), %g2
237 cmp %g1, %g2
238 bne,pn %xcc, do_fptrap_after_fsr
239 nop
240 std %f62, [%g6 + TI_FPREGS + (62 * 4)]
241 sethi %hi(fitos_table_1), %g1
242 and %g3, 0x1f, %g2
243 or %g1, %lo(fitos_table_1), %g1
244 sllx %g2, 2, %g2
245 jmpl %g1 + %g2, %g0
246 ba,pt %xcc, fitos_emul_continue
247
248fitos_table_1:
249 fitod %f0, %f62
250 fitod %f1, %f62
251 fitod %f2, %f62
252 fitod %f3, %f62
253 fitod %f4, %f62
254 fitod %f5, %f62
255 fitod %f6, %f62
256 fitod %f7, %f62
257 fitod %f8, %f62
258 fitod %f9, %f62
259 fitod %f10, %f62
260 fitod %f11, %f62
261 fitod %f12, %f62
262 fitod %f13, %f62
263 fitod %f14, %f62
264 fitod %f15, %f62
265 fitod %f16, %f62
266 fitod %f17, %f62
267 fitod %f18, %f62
268 fitod %f19, %f62
269 fitod %f20, %f62
270 fitod %f21, %f62
271 fitod %f22, %f62
272 fitod %f23, %f62
273 fitod %f24, %f62
274 fitod %f25, %f62
275 fitod %f26, %f62
276 fitod %f27, %f62
277 fitod %f28, %f62
278 fitod %f29, %f62
279 fitod %f30, %f62
280 fitod %f31, %f62
281
282fitos_emul_continue:
283 sethi %hi(fitos_table_2), %g1
284 srl %g3, 25, %g2
285 or %g1, %lo(fitos_table_2), %g1
286 and %g2, 0x1f, %g2
287 sllx %g2, 2, %g2
288 jmpl %g1 + %g2, %g0
289 ba,pt %xcc, fitos_emul_fini
290
291fitos_table_2:
292 fdtos %f62, %f0
293 fdtos %f62, %f1
294 fdtos %f62, %f2
295 fdtos %f62, %f3
296 fdtos %f62, %f4
297 fdtos %f62, %f5
298 fdtos %f62, %f6
299 fdtos %f62, %f7
300 fdtos %f62, %f8
301 fdtos %f62, %f9
302 fdtos %f62, %f10
303 fdtos %f62, %f11
304 fdtos %f62, %f12
305 fdtos %f62, %f13
306 fdtos %f62, %f14
307 fdtos %f62, %f15
308 fdtos %f62, %f16
309 fdtos %f62, %f17
310 fdtos %f62, %f18
311 fdtos %f62, %f19
312 fdtos %f62, %f20
313 fdtos %f62, %f21
314 fdtos %f62, %f22
315 fdtos %f62, %f23
316 fdtos %f62, %f24
317 fdtos %f62, %f25
318 fdtos %f62, %f26
319 fdtos %f62, %f27
320 fdtos %f62, %f28
321 fdtos %f62, %f29
322 fdtos %f62, %f30
323 fdtos %f62, %f31
324
325fitos_emul_fini:
326 ldd [%g6 + TI_FPREGS + (62 * 4)], %f62
327 done
328 .size do_fpother_check_fitos,.-do_fpother_check_fitos
329
330 .align 32
331 .globl do_fptrap
332 .type do_fptrap,#function
333do_fptrap:
334 TRAP_LOAD_THREAD_REG(%g6, %g1)
335 stx %fsr, [%g6 + TI_XFSR]
336do_fptrap_after_fsr:
337 ldub [%g6 + TI_FPSAVED], %g3
338 rd %fprs, %g1
339 or %g3, %g1, %g3
340 stb %g3, [%g6 + TI_FPSAVED]
341 rd %gsr, %g3
342 stx %g3, [%g6 + TI_GSR]
343 mov SECONDARY_CONTEXT, %g3
344
345661: ldxa [%g3] ASI_DMMU, %g5
346 .section .sun4v_1insn_patch, "ax"
347 .word 661b
348 ldxa [%g3] ASI_MMU, %g5
349 .previous
350
351 sethi %hi(sparc64_kern_sec_context), %g2
352 ldx [%g2 + %lo(sparc64_kern_sec_context)], %g2
353
354661: stxa %g2, [%g3] ASI_DMMU
355 .section .sun4v_1insn_patch, "ax"
356 .word 661b
357 stxa %g2, [%g3] ASI_MMU
358 .previous
359
360 membar #Sync
361 add %g6, TI_FPREGS, %g2
362 andcc %g1, FPRS_DL, %g0
363 be,pn %icc, 4f
364 mov 0x40, %g3
365 stda %f0, [%g2] ASI_BLK_S
366 stda %f16, [%g2 + %g3] ASI_BLK_S
367 andcc %g1, FPRS_DU, %g0
368 be,pn %icc, 5f
3694: add %g2, 128, %g2
370 stda %f32, [%g2] ASI_BLK_S
371 stda %f48, [%g2 + %g3] ASI_BLK_S
3725: mov SECONDARY_CONTEXT, %g1
373 membar #Sync
374
375661: stxa %g5, [%g1] ASI_DMMU
376 .section .sun4v_1insn_patch, "ax"
377 .word 661b
378 stxa %g5, [%g1] ASI_MMU
379 .previous
380
381 membar #Sync
382 ba,pt %xcc, etrap
383 wr %g0, 0, %fprs
384 .size do_fptrap,.-do_fptrap
diff --git a/arch/sparc64/kernel/getsetcc.S b/arch/sparc64/kernel/getsetcc.S
new file mode 100644
index 000000000000..a14d272d2061
--- /dev/null
+++ b/arch/sparc64/kernel/getsetcc.S
@@ -0,0 +1,24 @@
1 .globl getcc
2 .type getcc,#function
3getcc:
4 ldx [%o0 + PT_V9_TSTATE], %o1
5 srlx %o1, 32, %o1
6 and %o1, 0xf, %o1
7 retl
8 stx %o1, [%o0 + PT_V9_G1]
9 .size getcc,.-getcc
10
11 .globl setcc
12 .type setcc,#function
13setcc:
14 ldx [%o0 + PT_V9_TSTATE], %o1
15 ldx [%o0 + PT_V9_G1], %o2
16 or %g0, %ulo(TSTATE_ICC), %o3
17 sllx %o3, 32, %o3
18 andn %o1, %o3, %o1
19 sllx %o2, 32, %o2
20 and %o2, %o3, %o2
21 or %o1, %o2, %o1
22 retl
23 stx %o1, [%o0 + PT_V9_TSTATE]
24 .size setcc,.-setcc
diff --git a/arch/sparc64/kernel/head.S b/arch/sparc64/kernel/head.S
index 34f8ff57c56b..c9afef093d51 100644
--- a/arch/sparc64/kernel/head.S
+++ b/arch/sparc64/kernel/head.S
@@ -27,6 +27,10 @@
27#include <asm/ttable.h> 27#include <asm/ttable.h>
28#include <asm/mmu.h> 28#include <asm/mmu.h>
29#include <asm/cpudata.h> 29#include <asm/cpudata.h>
30#include <asm/pil.h>
31#include <asm/estate.h>
32#include <asm/sfafsr.h>
33#include <asm/unistd.h>
30 34
31/* This section from from _start to sparc64_boot_end should fit into 35/* This section from from _start to sparc64_boot_end should fit into
32 * 0x0000000000404000 to 0x0000000000408000. 36 * 0x0000000000404000 to 0x0000000000408000.
@@ -823,7 +827,16 @@ sparc64_boot_end:
823#include "etrap.S" 827#include "etrap.S"
824#include "rtrap.S" 828#include "rtrap.S"
825#include "winfixup.S" 829#include "winfixup.S"
826#include "entry.S" 830#include "fpu_traps.S"
831#include "ivec.S"
832#include "getsetcc.S"
833#include "utrap.S"
834#include "spiterrs.S"
835#include "cherrs.S"
836#include "misctrap.S"
837#include "syscalls.S"
838#include "helpers.S"
839#include "hvcalls.S"
827#include "sun4v_tlb_miss.S" 840#include "sun4v_tlb_miss.S"
828#include "sun4v_ivec.S" 841#include "sun4v_ivec.S"
829#include "ktlb.S" 842#include "ktlb.S"
diff --git a/arch/sparc64/kernel/helpers.S b/arch/sparc64/kernel/helpers.S
new file mode 100644
index 000000000000..314dd0c9fc5b
--- /dev/null
+++ b/arch/sparc64/kernel/helpers.S
@@ -0,0 +1,63 @@
1 .align 32
2 .globl __flushw_user
3 .type __flushw_user,#function
4__flushw_user:
5 rdpr %otherwin, %g1
6 brz,pn %g1, 2f
7 clr %g2
81: save %sp, -128, %sp
9 rdpr %otherwin, %g1
10 brnz,pt %g1, 1b
11 add %g2, 1, %g2
121: sub %g2, 1, %g2
13 brnz,pt %g2, 1b
14 restore %g0, %g0, %g0
152: retl
16 nop
17 .size __flushw_user,.-__flushw_user
18
19 /* Flush %fp and %i7 to the stack for all register
20 * windows active inside of the cpu. This allows
21 * show_stack_trace() to avoid using an expensive
22 * 'flushw'.
23 */
24 .globl stack_trace_flush
25 .type stack_trace_flush,#function
26stack_trace_flush:
27 rdpr %pstate, %o0
28 wrpr %o0, PSTATE_IE, %pstate
29
30 rdpr %cwp, %g1
31 rdpr %canrestore, %g2
32 sub %g1, 1, %g3
33
341: brz,pn %g2, 2f
35 sub %g2, 1, %g2
36 wrpr %g3, %cwp
37 stx %fp, [%sp + STACK_BIAS + RW_V9_I6]
38 stx %i7, [%sp + STACK_BIAS + RW_V9_I7]
39 ba,pt %xcc, 1b
40 sub %g3, 1, %g3
41
422: wrpr %g1, %cwp
43 wrpr %o0, %pstate
44
45 retl
46 nop
47 .size stack_trace_flush,.-stack_trace_flush
48
49#ifdef CONFIG_SMP
50 .globl hard_smp_processor_id
51 .type hard_smp_processor_id,#function
52hard_smp_processor_id:
53#endif
54 .globl real_hard_smp_processor_id
55 .type real_hard_smp_processor_id,#function
56real_hard_smp_processor_id:
57 __GET_CPUID(%o0)
58 retl
59 nop
60#ifdef CONFIG_SMP
61 .size hard_smp_processor_id,.-hard_smp_processor_id
62#endif
63 .size real_hard_smp_processor_id,.-real_hard_smp_processor_id
diff --git a/arch/sparc64/kernel/hvcalls.S b/arch/sparc64/kernel/hvcalls.S
new file mode 100644
index 000000000000..a2810f3ac70f
--- /dev/null
+++ b/arch/sparc64/kernel/hvcalls.S
@@ -0,0 +1,886 @@
1 /* %o0: devhandle
2 * %o1: devino
3 *
4 * returns %o0: sysino
5 */
6 .globl sun4v_devino_to_sysino
7 .type sun4v_devino_to_sysino,#function
8sun4v_devino_to_sysino:
9 mov HV_FAST_INTR_DEVINO2SYSINO, %o5
10 ta HV_FAST_TRAP
11 retl
12 mov %o1, %o0
13 .size sun4v_devino_to_sysino, .-sun4v_devino_to_sysino
14
15 /* %o0: sysino
16 *
17 * returns %o0: intr_enabled (HV_INTR_{DISABLED,ENABLED})
18 */
19 .globl sun4v_intr_getenabled
20 .type sun4v_intr_getenabled,#function
21sun4v_intr_getenabled:
22 mov HV_FAST_INTR_GETENABLED, %o5
23 ta HV_FAST_TRAP
24 retl
25 mov %o1, %o0
26 .size sun4v_intr_getenabled, .-sun4v_intr_getenabled
27
28 /* %o0: sysino
29 * %o1: intr_enabled (HV_INTR_{DISABLED,ENABLED})
30 */
31 .globl sun4v_intr_setenabled
32 .type sun4v_intr_setenabled,#function
33sun4v_intr_setenabled:
34 mov HV_FAST_INTR_SETENABLED, %o5
35 ta HV_FAST_TRAP
36 retl
37 nop
38 .size sun4v_intr_setenabled, .-sun4v_intr_setenabled
39
40 /* %o0: sysino
41 *
42 * returns %o0: intr_state (HV_INTR_STATE_*)
43 */
44 .globl sun4v_intr_getstate
45 .type sun4v_intr_getstate,#function
46sun4v_intr_getstate:
47 mov HV_FAST_INTR_GETSTATE, %o5
48 ta HV_FAST_TRAP
49 retl
50 mov %o1, %o0
51 .size sun4v_intr_getstate, .-sun4v_intr_getstate
52
53 /* %o0: sysino
54 * %o1: intr_state (HV_INTR_STATE_*)
55 */
56 .globl sun4v_intr_setstate
57 .type sun4v_intr_setstate,#function
58sun4v_intr_setstate:
59 mov HV_FAST_INTR_SETSTATE, %o5
60 ta HV_FAST_TRAP
61 retl
62 nop
63 .size sun4v_intr_setstate, .-sun4v_intr_setstate
64
65 /* %o0: sysino
66 *
67 * returns %o0: cpuid
68 */
69 .globl sun4v_intr_gettarget
70 .type sun4v_intr_gettarget,#function
71sun4v_intr_gettarget:
72 mov HV_FAST_INTR_GETTARGET, %o5
73 ta HV_FAST_TRAP
74 retl
75 mov %o1, %o0
76 .size sun4v_intr_gettarget, .-sun4v_intr_gettarget
77
78 /* %o0: sysino
79 * %o1: cpuid
80 */
81 .globl sun4v_intr_settarget
82 .type sun4v_intr_settarget,#function
83sun4v_intr_settarget:
84 mov HV_FAST_INTR_SETTARGET, %o5
85 ta HV_FAST_TRAP
86 retl
87 nop
88 .size sun4v_intr_settarget, .-sun4v_intr_settarget
89
90 /* %o0: cpuid
91 * %o1: pc
92 * %o2: rtba
93 * %o3: arg0
94 *
95 * returns %o0: status
96 */
97 .globl sun4v_cpu_start
98 .type sun4v_cpu_start,#function
99sun4v_cpu_start:
100 mov HV_FAST_CPU_START, %o5
101 ta HV_FAST_TRAP
102 retl
103 nop
104 .size sun4v_cpu_start, .-sun4v_cpu_start
105
106 /* %o0: cpuid
107 *
108 * returns %o0: status
109 */
110 .globl sun4v_cpu_stop
111 .type sun4v_cpu_stop,#function
112sun4v_cpu_stop:
113 mov HV_FAST_CPU_STOP, %o5
114 ta HV_FAST_TRAP
115 retl
116 nop
117 .size sun4v_cpu_stop, .-sun4v_cpu_stop
118
119 /* returns %o0: status */
120 .globl sun4v_cpu_yield
121 .type sun4v_cpu_yield, #function
122sun4v_cpu_yield:
123 mov HV_FAST_CPU_YIELD, %o5
124 ta HV_FAST_TRAP
125 retl
126 nop
127 .size sun4v_cpu_yield, .-sun4v_cpu_yield
128
129 /* %o0: type
130 * %o1: queue paddr
131 * %o2: num queue entries
132 *
133 * returns %o0: status
134 */
135 .globl sun4v_cpu_qconf
136 .type sun4v_cpu_qconf,#function
137sun4v_cpu_qconf:
138 mov HV_FAST_CPU_QCONF, %o5
139 ta HV_FAST_TRAP
140 retl
141 nop
142 .size sun4v_cpu_qconf, .-sun4v_cpu_qconf
143
144 /* %o0: num cpus in cpu list
145 * %o1: cpu list paddr
146 * %o2: mondo block paddr
147 *
148 * returns %o0: status
149 */
150 .globl sun4v_cpu_mondo_send
151 .type sun4v_cpu_mondo_send,#function
152sun4v_cpu_mondo_send:
153 mov HV_FAST_CPU_MONDO_SEND, %o5
154 ta HV_FAST_TRAP
155 retl
156 nop
157 .size sun4v_cpu_mondo_send, .-sun4v_cpu_mondo_send
158
159 /* %o0: CPU ID
160 *
161 * returns %o0: -status if status non-zero, else
162 * %o0: cpu state as HV_CPU_STATE_*
163 */
164 .globl sun4v_cpu_state
165 .type sun4v_cpu_state,#function
166sun4v_cpu_state:
167 mov HV_FAST_CPU_STATE, %o5
168 ta HV_FAST_TRAP
169 brnz,pn %o0, 1f
170 sub %g0, %o0, %o0
171 mov %o1, %o0
1721: retl
173 nop
174 .size sun4v_cpu_state, .-sun4v_cpu_state
175
176 /* %o0: virtual address
177 * %o1: must be zero
178 * %o2: TTE
179 * %o3: HV_MMU_* flags
180 *
181 * returns %o0: status
182 */
183 .globl sun4v_mmu_map_perm_addr
184 .type sun4v_mmu_map_perm_addr,#function
185sun4v_mmu_map_perm_addr:
186 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
187 ta HV_FAST_TRAP
188 retl
189 nop
190 .size sun4v_mmu_map_perm_addr, .-sun4v_mmu_map_perm_addr
191
192 /* %o0: number of TSB descriptions
193 * %o1: TSB descriptions real address
194 *
195 * returns %o0: status
196 */
197 .globl sun4v_mmu_tsb_ctx0
198 .type sun4v_mmu_tsb_ctx0,#function
199sun4v_mmu_tsb_ctx0:
200 mov HV_FAST_MMU_TSB_CTX0, %o5
201 ta HV_FAST_TRAP
202 retl
203 nop
204 .size sun4v_mmu_tsb_ctx0, .-sun4v_mmu_tsb_ctx0
205
206 /* %o0: API group number
207 * %o1: pointer to unsigned long major number storage
208 * %o2: pointer to unsigned long minor number storage
209 *
210 * returns %o0: status
211 */
212 .globl sun4v_get_version
213 .type sun4v_get_version,#function
214sun4v_get_version:
215 mov HV_CORE_GET_VER, %o5
216 mov %o1, %o3
217 mov %o2, %o4
218 ta HV_CORE_TRAP
219 stx %o1, [%o3]
220 retl
221 stx %o2, [%o4]
222 .size sun4v_get_version, .-sun4v_get_version
223
224 /* %o0: API group number
225 * %o1: desired major number
226 * %o2: desired minor number
227 * %o3: pointer to unsigned long actual minor number storage
228 *
229 * returns %o0: status
230 */
231 .globl sun4v_set_version
232 .type sun4v_set_version,#function
233sun4v_set_version:
234 mov HV_CORE_SET_VER, %o5
235 mov %o3, %o4
236 ta HV_CORE_TRAP
237 retl
238 stx %o1, [%o4]
239 .size sun4v_set_version, .-sun4v_set_version
240
241 /* %o0: pointer to unsigned long time
242 *
243 * returns %o0: status
244 */
245 .globl sun4v_tod_get
246 .type sun4v_tod_get,#function
247sun4v_tod_get:
248 mov %o0, %o4
249 mov HV_FAST_TOD_GET, %o5
250 ta HV_FAST_TRAP
251 stx %o1, [%o4]
252 retl
253 nop
254 .size sun4v_tod_get, .-sun4v_tod_get
255
256 /* %o0: time
257 *
258 * returns %o0: status
259 */
260 .globl sun4v_tod_set
261 .type sun4v_tod_set,#function
262sun4v_tod_set:
263 mov HV_FAST_TOD_SET, %o5
264 ta HV_FAST_TRAP
265 retl
266 nop
267 .size sun4v_tod_set, .-sun4v_tod_set
268
269 /* %o0: pointer to unsigned long status
270 *
271 * returns %o0: signed character
272 */
273 .globl sun4v_con_getchar
274 .type sun4v_con_getchar,#function
275sun4v_con_getchar:
276 mov %o0, %o4
277 mov HV_FAST_CONS_GETCHAR, %o5
278 clr %o0
279 clr %o1
280 ta HV_FAST_TRAP
281 stx %o0, [%o4]
282 retl
283 sra %o1, 0, %o0
284 .size sun4v_con_getchar, .-sun4v_con_getchar
285
286 /* %o0: signed long character
287 *
288 * returns %o0: status
289 */
290 .globl sun4v_con_putchar
291 .type sun4v_con_putchar,#function
292sun4v_con_putchar:
293 mov HV_FAST_CONS_PUTCHAR, %o5
294 ta HV_FAST_TRAP
295 retl
296 sra %o0, 0, %o0
297 .size sun4v_con_putchar, .-sun4v_con_putchar
298
299 /* %o0: buffer real address
300 * %o1: buffer size
301 * %o2: pointer to unsigned long bytes_read
302 *
303 * returns %o0: status
304 */
305 .globl sun4v_con_read
306 .type sun4v_con_read,#function
307sun4v_con_read:
308 mov %o2, %o4
309 mov HV_FAST_CONS_READ, %o5
310 ta HV_FAST_TRAP
311 brnz %o0, 1f
312 cmp %o1, -1 /* break */
313 be,a,pn %icc, 1f
314 mov %o1, %o0
315 cmp %o1, -2 /* hup */
316 be,a,pn %icc, 1f
317 mov %o1, %o0
318 stx %o1, [%o4]
3191: retl
320 nop
321 .size sun4v_con_read, .-sun4v_con_read
322
323 /* %o0: buffer real address
324 * %o1: buffer size
325 * %o2: pointer to unsigned long bytes_written
326 *
327 * returns %o0: status
328 */
329 .globl sun4v_con_write
330 .type sun4v_con_write,#function
331sun4v_con_write:
332 mov %o2, %o4
333 mov HV_FAST_CONS_WRITE, %o5
334 ta HV_FAST_TRAP
335 stx %o1, [%o4]
336 retl
337 nop
338 .size sun4v_con_write, .-sun4v_con_write
339
340 /* %o0: soft state
341 * %o1: address of description string
342 *
343 * returns %o0: status
344 */
345 .globl sun4v_mach_set_soft_state
346 .type sun4v_mach_set_soft_state,#function
347sun4v_mach_set_soft_state:
348 mov HV_FAST_MACH_SET_SOFT_STATE, %o5
349 ta HV_FAST_TRAP
350 retl
351 nop
352 .size sun4v_mach_set_soft_state, .-sun4v_mach_set_soft_state
353
354 /* %o0: exit code
355 *
356 * Does not return.
357 */
358 .globl sun4v_mach_exit
359 .type sun4v_mach_exit,#function
360sun4v_mach_exit:
361 mov HV_FAST_MACH_EXIT, %o5
362 ta HV_FAST_TRAP
363 retl
364 nop
365 .size sun4v_mach_exit, .-sun4v_mach_exit
366
367 /* %o0: buffer real address
368 * %o1: buffer length
369 * %o2: pointer to unsigned long real_buf_len
370 *
371 * returns %o0: status
372 */
373 .globl sun4v_mach_desc
374 .type sun4v_mach_desc,#function
375sun4v_mach_desc:
376 mov %o2, %o4
377 mov HV_FAST_MACH_DESC, %o5
378 ta HV_FAST_TRAP
379 stx %o1, [%o4]
380 retl
381 nop
382 .size sun4v_mach_desc, .-sun4v_mach_desc
383
384 /* %o0: new timeout in milliseconds
385 * %o1: pointer to unsigned long orig_timeout
386 *
387 * returns %o0: status
388 */
389 .globl sun4v_mach_set_watchdog
390 .type sun4v_mach_set_watchdog,#function
391sun4v_mach_set_watchdog:
392 mov %o1, %o4
393 mov HV_FAST_MACH_SET_WATCHDOG, %o5
394 ta HV_FAST_TRAP
395 stx %o1, [%o4]
396 retl
397 nop
398 .size sun4v_mach_set_watchdog, .-sun4v_mach_set_watchdog
399
400 /* No inputs and does not return. */
401 .globl sun4v_mach_sir
402 .type sun4v_mach_sir,#function
403sun4v_mach_sir:
404 mov %o1, %o4
405 mov HV_FAST_MACH_SIR, %o5
406 ta HV_FAST_TRAP
407 stx %o1, [%o4]
408 retl
409 nop
410 .size sun4v_mach_sir, .-sun4v_mach_sir
411
412 /* %o0: channel
413 * %o1: ra
414 * %o2: num_entries
415 *
416 * returns %o0: status
417 */
418 .globl sun4v_ldc_tx_qconf
419 .type sun4v_ldc_tx_qconf,#function
420sun4v_ldc_tx_qconf:
421 mov HV_FAST_LDC_TX_QCONF, %o5
422 ta HV_FAST_TRAP
423 retl
424 nop
425 .size sun4v_ldc_tx_qconf, .-sun4v_ldc_tx_qconf
426
427 /* %o0: channel
428 * %o1: pointer to unsigned long ra
429 * %o2: pointer to unsigned long num_entries
430 *
431 * returns %o0: status
432 */
433 .globl sun4v_ldc_tx_qinfo
434 .type sun4v_ldc_tx_qinfo,#function
435sun4v_ldc_tx_qinfo:
436 mov %o1, %g1
437 mov %o2, %g2
438 mov HV_FAST_LDC_TX_QINFO, %o5
439 ta HV_FAST_TRAP
440 stx %o1, [%g1]
441 stx %o2, [%g2]
442 retl
443 nop
444 .size sun4v_ldc_tx_qinfo, .-sun4v_ldc_tx_qinfo
445
446 /* %o0: channel
447 * %o1: pointer to unsigned long head_off
448 * %o2: pointer to unsigned long tail_off
449 * %o2: pointer to unsigned long chan_state
450 *
451 * returns %o0: status
452 */
453 .globl sun4v_ldc_tx_get_state
454 .type sun4v_ldc_tx_get_state,#function
455sun4v_ldc_tx_get_state:
456 mov %o1, %g1
457 mov %o2, %g2
458 mov %o3, %g3
459 mov HV_FAST_LDC_TX_GET_STATE, %o5
460 ta HV_FAST_TRAP
461 stx %o1, [%g1]
462 stx %o2, [%g2]
463 stx %o3, [%g3]
464 retl
465 nop
466 .size sun4v_ldc_tx_get_state, .-sun4v_ldc_tx_get_state
467
468 /* %o0: channel
469 * %o1: tail_off
470 *
471 * returns %o0: status
472 */
473 .globl sun4v_ldc_tx_set_qtail
474 .type sun4v_ldc_tx_set_qtail,#function
475sun4v_ldc_tx_set_qtail:
476 mov HV_FAST_LDC_TX_SET_QTAIL, %o5
477 ta HV_FAST_TRAP
478 retl
479 nop
480 .size sun4v_ldc_tx_set_qtail, .-sun4v_ldc_tx_set_qtail
481
482 /* %o0: channel
483 * %o1: ra
484 * %o2: num_entries
485 *
486 * returns %o0: status
487 */
488 .globl sun4v_ldc_rx_qconf
489 .type sun4v_ldc_rx_qconf,#function
490sun4v_ldc_rx_qconf:
491 mov HV_FAST_LDC_RX_QCONF, %o5
492 ta HV_FAST_TRAP
493 retl
494 nop
495 .size sun4v_ldc_rx_qconf, .-sun4v_ldc_rx_qconf
496
497 /* %o0: channel
498 * %o1: pointer to unsigned long ra
499 * %o2: pointer to unsigned long num_entries
500 *
501 * returns %o0: status
502 */
503 .globl sun4v_ldc_rx_qinfo
504 .type sun4v_ldc_rx_qinfo,#function
505sun4v_ldc_rx_qinfo:
506 mov %o1, %g1
507 mov %o2, %g2
508 mov HV_FAST_LDC_RX_QINFO, %o5
509 ta HV_FAST_TRAP
510 stx %o1, [%g1]
511 stx %o2, [%g2]
512 retl
513 nop
514 .size sun4v_ldc_rx_qinfo, .-sun4v_ldc_rx_qinfo
515
516 /* %o0: channel
517 * %o1: pointer to unsigned long head_off
518 * %o2: pointer to unsigned long tail_off
519 * %o2: pointer to unsigned long chan_state
520 *
521 * returns %o0: status
522 */
523 .globl sun4v_ldc_rx_get_state
524 .type sun4v_ldc_rx_get_state,#function
525sun4v_ldc_rx_get_state:
526 mov %o1, %g1
527 mov %o2, %g2
528 mov %o3, %g3
529 mov HV_FAST_LDC_RX_GET_STATE, %o5
530 ta HV_FAST_TRAP
531 stx %o1, [%g1]
532 stx %o2, [%g2]
533 stx %o3, [%g3]
534 retl
535 nop
536 .size sun4v_ldc_rx_get_state, .-sun4v_ldc_rx_get_state
537
538 /* %o0: channel
539 * %o1: head_off
540 *
541 * returns %o0: status
542 */
543 .globl sun4v_ldc_rx_set_qhead
544 .type sun4v_ldc_rx_set_qhead,#function
545sun4v_ldc_rx_set_qhead:
546 mov HV_FAST_LDC_RX_SET_QHEAD, %o5
547 ta HV_FAST_TRAP
548 retl
549 nop
550 .size sun4v_ldc_rx_set_qhead, .-sun4v_ldc_rx_set_qhead
551
552 /* %o0: channel
553 * %o1: ra
554 * %o2: num_entries
555 *
556 * returns %o0: status
557 */
558 .globl sun4v_ldc_set_map_table
559 .type sun4v_ldc_set_map_table,#function
560sun4v_ldc_set_map_table:
561 mov HV_FAST_LDC_SET_MAP_TABLE, %o5
562 ta HV_FAST_TRAP
563 retl
564 nop
565 .size sun4v_ldc_set_map_table, .-sun4v_ldc_set_map_table
566
567 /* %o0: channel
568 * %o1: pointer to unsigned long ra
569 * %o2: pointer to unsigned long num_entries
570 *
571 * returns %o0: status
572 */
573 .globl sun4v_ldc_get_map_table
574 .type sun4v_ldc_get_map_table,#function
575sun4v_ldc_get_map_table:
576 mov %o1, %g1
577 mov %o2, %g2
578 mov HV_FAST_LDC_GET_MAP_TABLE, %o5
579 ta HV_FAST_TRAP
580 stx %o1, [%g1]
581 stx %o2, [%g2]
582 retl
583 nop
584 .size sun4v_ldc_get_map_table, .-sun4v_ldc_get_map_table
585
586 /* %o0: channel
587 * %o1: dir_code
588 * %o2: tgt_raddr
589 * %o3: lcl_raddr
590 * %o4: len
591 * %o5: pointer to unsigned long actual_len
592 *
593 * returns %o0: status
594 */
595 .globl sun4v_ldc_copy
596 .type sun4v_ldc_copy,#function
597sun4v_ldc_copy:
598 mov %o5, %g1
599 mov HV_FAST_LDC_COPY, %o5
600 ta HV_FAST_TRAP
601 stx %o1, [%g1]
602 retl
603 nop
604 .size sun4v_ldc_copy, .-sun4v_ldc_copy
605
606 /* %o0: channel
607 * %o1: cookie
608 * %o2: pointer to unsigned long ra
609 * %o3: pointer to unsigned long perm
610 *
611 * returns %o0: status
612 */
613 .globl sun4v_ldc_mapin
614 .type sun4v_ldc_mapin,#function
615sun4v_ldc_mapin:
616 mov %o2, %g1
617 mov %o3, %g2
618 mov HV_FAST_LDC_MAPIN, %o5
619 ta HV_FAST_TRAP
620 stx %o1, [%g1]
621 stx %o2, [%g2]
622 retl
623 nop
624 .size sun4v_ldc_mapin, .-sun4v_ldc_mapin
625
626 /* %o0: ra
627 *
628 * returns %o0: status
629 */
630 .globl sun4v_ldc_unmap
631 .type sun4v_ldc_unmap,#function
632sun4v_ldc_unmap:
633 mov HV_FAST_LDC_UNMAP, %o5
634 ta HV_FAST_TRAP
635 retl
636 nop
637 .size sun4v_ldc_unmap, .-sun4v_ldc_unmap
638
639 /* %o0: channel
640 * %o1: cookie
641 * %o2: mte_cookie
642 *
643 * returns %o0: status
644 */
645 .globl sun4v_ldc_revoke
646 .type sun4v_ldc_revoke,#function
647sun4v_ldc_revoke:
648 mov HV_FAST_LDC_REVOKE, %o5
649 ta HV_FAST_TRAP
650 retl
651 nop
652 .size sun4v_ldc_revoke, .-sun4v_ldc_revoke
653
654 /* %o0: device handle
655 * %o1: device INO
656 * %o2: pointer to unsigned long cookie
657 *
658 * returns %o0: status
659 */
660 .globl sun4v_vintr_get_cookie
661 .type sun4v_vintr_get_cookie,#function
662sun4v_vintr_get_cookie:
663 mov %o2, %g1
664 mov HV_FAST_VINTR_GET_COOKIE, %o5
665 ta HV_FAST_TRAP
666 stx %o1, [%g1]
667 retl
668 nop
669 .size sun4v_vintr_get_cookie, .-sun4v_vintr_get_cookie
670
671 /* %o0: device handle
672 * %o1: device INO
673 * %o2: cookie
674 *
675 * returns %o0: status
676 */
677 .globl sun4v_vintr_set_cookie
678 .type sun4v_vintr_set_cookie,#function
679sun4v_vintr_set_cookie:
680 mov HV_FAST_VINTR_SET_COOKIE, %o5
681 ta HV_FAST_TRAP
682 retl
683 nop
684 .size sun4v_vintr_set_cookie, .-sun4v_vintr_set_cookie
685
686 /* %o0: device handle
687 * %o1: device INO
688 * %o2: pointer to unsigned long valid_state
689 *
690 * returns %o0: status
691 */
692 .globl sun4v_vintr_get_valid
693 .type sun4v_vintr_get_valid,#function
694sun4v_vintr_get_valid:
695 mov %o2, %g1
696 mov HV_FAST_VINTR_GET_VALID, %o5
697 ta HV_FAST_TRAP
698 stx %o1, [%g1]
699 retl
700 nop
701 .size sun4v_vintr_get_valid, .-sun4v_vintr_get_valid
702
703 /* %o0: device handle
704 * %o1: device INO
705 * %o2: valid_state
706 *
707 * returns %o0: status
708 */
709 .globl sun4v_vintr_set_valid
710 .type sun4v_vintr_set_valid,#function
711sun4v_vintr_set_valid:
712 mov HV_FAST_VINTR_SET_VALID, %o5
713 ta HV_FAST_TRAP
714 retl
715 nop
716 .size sun4v_vintr_set_valid, .-sun4v_vintr_set_valid
717
718 /* %o0: device handle
719 * %o1: device INO
720 * %o2: pointer to unsigned long state
721 *
722 * returns %o0: status
723 */
724 .globl sun4v_vintr_get_state
725 .type sun4v_vintr_get_state,#function
726sun4v_vintr_get_state:
727 mov %o2, %g1
728 mov HV_FAST_VINTR_GET_STATE, %o5
729 ta HV_FAST_TRAP
730 stx %o1, [%g1]
731 retl
732 nop
733 .size sun4v_vintr_get_state, .-sun4v_vintr_get_state
734
735 /* %o0: device handle
736 * %o1: device INO
737 * %o2: state
738 *
739 * returns %o0: status
740 */
741 .globl sun4v_vintr_set_state
742 .type sun4v_vintr_set_state,#function
743sun4v_vintr_set_state:
744 mov HV_FAST_VINTR_SET_STATE, %o5
745 ta HV_FAST_TRAP
746 retl
747 nop
748 .size sun4v_vintr_set_state, .-sun4v_vintr_set_state
749
750 /* %o0: device handle
751 * %o1: device INO
752 * %o2: pointer to unsigned long cpuid
753 *
754 * returns %o0: status
755 */
756 .globl sun4v_vintr_get_target
757 .type sun4v_vintr_get_target,#function
758sun4v_vintr_get_target:
759 mov %o2, %g1
760 mov HV_FAST_VINTR_GET_TARGET, %o5
761 ta HV_FAST_TRAP
762 stx %o1, [%g1]
763 retl
764 nop
765 .size sun4v_vintr_get_target, .-sun4v_vintr_get_target
766
767 /* %o0: device handle
768 * %o1: device INO
769 * %o2: cpuid
770 *
771 * returns %o0: status
772 */
773 .globl sun4v_vintr_set_target
774 .type sun4v_vintr_set_target,#function
775sun4v_vintr_set_target:
776 mov HV_FAST_VINTR_SET_TARGET, %o5
777 ta HV_FAST_TRAP
778 retl
779 nop
780 .size sun4v_vintr_set_target, .-sun4v_vintr_set_target
781
782 /* %o0: NCS sub-function
783 * %o1: sub-function arg real-address
784 * %o2: sub-function arg size
785 *
786 * returns %o0: status
787 */
788 .globl sun4v_ncs_request
789 .type sun4v_ncs_request,#function
790sun4v_ncs_request:
791 mov HV_FAST_NCS_REQUEST, %o5
792 ta HV_FAST_TRAP
793 retl
794 nop
795 .size sun4v_ncs_request, .-sun4v_ncs_request
796
797 .globl sun4v_svc_send
798 .type sun4v_svc_send,#function
799sun4v_svc_send:
800 save %sp, -192, %sp
801 mov %i0, %o0
802 mov %i1, %o1
803 mov %i2, %o2
804 mov HV_FAST_SVC_SEND, %o5
805 ta HV_FAST_TRAP
806 stx %o1, [%i3]
807 ret
808 restore
809 .size sun4v_svc_send, .-sun4v_svc_send
810
811 .globl sun4v_svc_recv
812 .type sun4v_svc_recv,#function
813sun4v_svc_recv:
814 save %sp, -192, %sp
815 mov %i0, %o0
816 mov %i1, %o1
817 mov %i2, %o2
818 mov HV_FAST_SVC_RECV, %o5
819 ta HV_FAST_TRAP
820 stx %o1, [%i3]
821 ret
822 restore
823 .size sun4v_svc_recv, .-sun4v_svc_recv
824
825 .globl sun4v_svc_getstatus
826 .type sun4v_svc_getstatus,#function
827sun4v_svc_getstatus:
828 mov HV_FAST_SVC_GETSTATUS, %o5
829 mov %o1, %o4
830 ta HV_FAST_TRAP
831 stx %o1, [%o4]
832 retl
833 nop
834 .size sun4v_svc_getstatus, .-sun4v_svc_getstatus
835
836 .globl sun4v_svc_setstatus
837 .type sun4v_svc_setstatus,#function
838sun4v_svc_setstatus:
839 mov HV_FAST_SVC_SETSTATUS, %o5
840 ta HV_FAST_TRAP
841 retl
842 nop
843 .size sun4v_svc_setstatus, .-sun4v_svc_setstatus
844
845 .globl sun4v_svc_clrstatus
846 .type sun4v_svc_clrstatus,#function
847sun4v_svc_clrstatus:
848 mov HV_FAST_SVC_CLRSTATUS, %o5
849 ta HV_FAST_TRAP
850 retl
851 nop
852 .size sun4v_svc_clrstatus, .-sun4v_svc_clrstatus
853
854 .globl sun4v_mmustat_conf
855 .type sun4v_mmustat_conf,#function
856sun4v_mmustat_conf:
857 mov %o1, %o4
858 mov HV_FAST_MMUSTAT_CONF, %o5
859 ta HV_FAST_TRAP
860 stx %o1, [%o4]
861 retl
862 nop
863 .size sun4v_mmustat_conf, .-sun4v_mmustat_conf
864
865 .globl sun4v_mmustat_info
866 .type sun4v_mmustat_info,#function
867sun4v_mmustat_info:
868 mov %o0, %o4
869 mov HV_FAST_MMUSTAT_INFO, %o5
870 ta HV_FAST_TRAP
871 stx %o1, [%o4]
872 retl
873 nop
874 .size sun4v_mmustat_info, .-sun4v_mmustat_info
875
876 .globl sun4v_mmu_demap_all
877 .type sun4v_mmu_demap_all,#function
878sun4v_mmu_demap_all:
879 clr %o0
880 clr %o1
881 mov HV_MMU_ALL, %o2
882 mov HV_FAST_MMU_DEMAP_ALL, %o5
883 ta HV_FAST_TRAP
884 retl
885 nop
886 .size sun4v_mmu_demap_all, .-sun4v_mmu_demap_all
diff --git a/arch/sparc64/kernel/ivec.S b/arch/sparc64/kernel/ivec.S
new file mode 100644
index 000000000000..d29f92ebca5e
--- /dev/null
+++ b/arch/sparc64/kernel/ivec.S
@@ -0,0 +1,51 @@
1 /* The registers for cross calls will be:
2 *
3 * DATA 0: [low 32-bits] Address of function to call, jmp to this
4 * [high 32-bits] MMU Context Argument 0, place in %g5
5 * DATA 1: Address Argument 1, place in %g1
6 * DATA 2: Address Argument 2, place in %g7
7 *
8 * With this method we can do most of the cross-call tlb/cache
9 * flushing very quickly.
10 */
11 .align 32
12 .globl do_ivec
13 .type do_ivec,#function
14do_ivec:
15 mov 0x40, %g3
16 ldxa [%g3 + %g0] ASI_INTR_R, %g3
17 sethi %hi(KERNBASE), %g4
18 cmp %g3, %g4
19 bgeu,pn %xcc, do_ivec_xcall
20 srlx %g3, 32, %g5
21 stxa %g0, [%g0] ASI_INTR_RECEIVE
22 membar #Sync
23
24 sethi %hi(ivector_table_pa), %g2
25 ldx [%g2 + %lo(ivector_table_pa)], %g2
26 sllx %g3, 4, %g3
27 add %g2, %g3, %g3
28
29 TRAP_LOAD_IRQ_WORK_PA(%g6, %g1)
30
31 ldx [%g6], %g5
32 stxa %g5, [%g3] ASI_PHYS_USE_EC
33 stx %g3, [%g6]
34 wr %g0, 1 << PIL_DEVICE_IRQ, %set_softint
35 retry
36do_ivec_xcall:
37 mov 0x50, %g1
38 ldxa [%g1 + %g0] ASI_INTR_R, %g1
39 srl %g3, 0, %g3
40
41 mov 0x60, %g7
42 ldxa [%g7 + %g0] ASI_INTR_R, %g7
43 stxa %g0, [%g0] ASI_INTR_RECEIVE
44 membar #Sync
45 ba,pt %xcc, 1f
46 nop
47
48 .align 32
491: jmpl %g3, %g0
50 nop
51 .size do_ivec,.-do_ivec
diff --git a/arch/sparc64/kernel/kgdb.c b/arch/sparc64/kernel/kgdb.c
new file mode 100644
index 000000000000..fefbe6dc51be
--- /dev/null
+++ b/arch/sparc64/kernel/kgdb.c
@@ -0,0 +1,186 @@
1/* kgdb.c: KGDB support for 64-bit sparc.
2 *
3 * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
4 */
5
6#include <linux/kgdb.h>
7#include <linux/kdebug.h>
8
9#include <asm/kdebug.h>
10#include <asm/ptrace.h>
11#include <asm/irq.h>
12
13void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
14{
15 struct reg_window *win;
16 int i;
17
18 gdb_regs[GDB_G0] = 0;
19 for (i = 0; i < 15; i++)
20 gdb_regs[GDB_G1 + i] = regs->u_regs[UREG_G1 + i];
21
22 win = (struct reg_window *) (regs->u_regs[UREG_FP] + STACK_BIAS);
23 for (i = 0; i < 8; i++)
24 gdb_regs[GDB_L0 + i] = win->locals[i];
25 for (i = 0; i < 8; i++)
26 gdb_regs[GDB_I0 + i] = win->ins[i];
27
28 for (i = GDB_F0; i <= GDB_F62; i++)
29 gdb_regs[i] = 0;
30
31 gdb_regs[GDB_PC] = regs->tpc;
32 gdb_regs[GDB_NPC] = regs->tnpc;
33 gdb_regs[GDB_STATE] = regs->tstate;
34 gdb_regs[GDB_FSR] = 0;
35 gdb_regs[GDB_FPRS] = 0;
36 gdb_regs[GDB_Y] = regs->y;
37}
38
39void sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *p)
40{
41 struct thread_info *t = task_thread_info(p);
42 extern unsigned int switch_to_pc;
43 extern unsigned int ret_from_syscall;
44 struct reg_window *win;
45 unsigned long pc, cwp;
46 int i;
47
48 for (i = GDB_G0; i < GDB_G6; i++)
49 gdb_regs[i] = 0;
50 gdb_regs[GDB_G6] = (unsigned long) t;
51 gdb_regs[GDB_G7] = (unsigned long) p;
52 for (i = GDB_O0; i < GDB_SP; i++)
53 gdb_regs[i] = 0;
54 gdb_regs[GDB_SP] = t->ksp;
55 gdb_regs[GDB_O7] = 0;
56
57 win = (struct reg_window *) (t->ksp + STACK_BIAS);
58 for (i = 0; i < 8; i++)
59 gdb_regs[GDB_L0 + i] = win->locals[i];
60 for (i = 0; i < 8; i++)
61 gdb_regs[GDB_I0 + i] = win->ins[i];
62
63 for (i = GDB_F0; i <= GDB_F62; i++)
64 gdb_regs[i] = 0;
65
66 if (t->new_child)
67 pc = (unsigned long) &ret_from_syscall;
68 else
69 pc = (unsigned long) &switch_to_pc;
70
71 gdb_regs[GDB_PC] = pc;
72 gdb_regs[GDB_NPC] = pc + 4;
73
74 cwp = __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP];
75
76 gdb_regs[GDB_STATE] = (TSTATE_PRIV | TSTATE_IE | cwp);
77 gdb_regs[GDB_FSR] = 0;
78 gdb_regs[GDB_FPRS] = 0;
79 gdb_regs[GDB_Y] = 0;
80}
81
82void gdb_regs_to_pt_regs(unsigned long *gdb_regs, struct pt_regs *regs)
83{
84 struct reg_window *win;
85 int i;
86
87 for (i = 0; i < 15; i++)
88 regs->u_regs[UREG_G1 + i] = gdb_regs[GDB_G1 + i];
89
90 /* If the TSTATE register is changing, we have to preserve
91 * the CWP field, otherwise window save/restore explodes.
92 */
93 if (regs->tstate != gdb_regs[GDB_STATE]) {
94 unsigned long cwp = regs->tstate & TSTATE_CWP;
95
96 regs->tstate = (gdb_regs[GDB_STATE] & ~TSTATE_CWP) | cwp;
97 }
98
99 regs->tpc = gdb_regs[GDB_PC];
100 regs->tnpc = gdb_regs[GDB_NPC];
101 regs->y = gdb_regs[GDB_Y];
102
103 win = (struct reg_window *) (regs->u_regs[UREG_FP] + STACK_BIAS);
104 for (i = 0; i < 8; i++)
105 win->locals[i] = gdb_regs[GDB_L0 + i];
106 for (i = 0; i < 8; i++)
107 win->ins[i] = gdb_regs[GDB_I0 + i];
108}
109
110#ifdef CONFIG_SMP
111void smp_kgdb_capture_client(struct pt_regs *regs)
112{
113 unsigned long flags;
114
115 __asm__ __volatile__("rdpr %%pstate, %0\n\t"
116 "wrpr %0, %1, %%pstate"
117 : "=r" (flags)
118 : "i" (PSTATE_IE));
119
120 flushw_all();
121
122 if (atomic_read(&kgdb_active) != -1)
123 kgdb_nmicallback(raw_smp_processor_id(), regs);
124
125 __asm__ __volatile__("wrpr %0, 0, %%pstate"
126 : : "r" (flags));
127}
128#endif
129
130int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
131 char *remcomInBuffer, char *remcomOutBuffer,
132 struct pt_regs *linux_regs)
133{
134 unsigned long addr;
135 char *ptr;
136
137 switch (remcomInBuffer[0]) {
138 case 'c':
139 /* try to read optional parameter, pc unchanged if no parm */
140 ptr = &remcomInBuffer[1];
141 if (kgdb_hex2long(&ptr, &addr)) {
142 linux_regs->tpc = addr;
143 linux_regs->tnpc = addr + 4;
144 }
145 /* fallthru */
146
147 case 'D':
148 case 'k':
149 if (linux_regs->tpc == (unsigned long) arch_kgdb_breakpoint) {
150 linux_regs->tpc = linux_regs->tnpc;
151 linux_regs->tnpc += 4;
152 }
153 return 0;
154 }
155 return -1;
156}
157
158asmlinkage void kgdb_trap(unsigned long trap_level, struct pt_regs *regs)
159{
160 unsigned long flags;
161
162 if (user_mode(regs)) {
163 bad_trap(regs, trap_level);
164 return;
165 }
166
167 flushw_all();
168
169 local_irq_save(flags);
170 kgdb_handle_exception(0x172, SIGTRAP, 0, regs);
171 local_irq_restore(flags);
172}
173
174int kgdb_arch_init(void)
175{
176 return 0;
177}
178
179void kgdb_arch_exit(void)
180{
181}
182
183struct kgdb_arch arch_kgdb_ops = {
184 /* Breakpoint instruction: ta 0x72 */
185 .gdb_bpt_instr = { 0x91, 0xd0, 0x20, 0x72 },
186};
diff --git a/arch/sparc64/kernel/misctrap.S b/arch/sparc64/kernel/misctrap.S
new file mode 100644
index 000000000000..753b4f031bfb
--- /dev/null
+++ b/arch/sparc64/kernel/misctrap.S
@@ -0,0 +1,97 @@
1#ifdef CONFIG_KGDB
2 .globl arch_kgdb_breakpoint
3 .type arch_kgdb_breakpoint,#function
4arch_kgdb_breakpoint:
5 ta 0x72
6 retl
7 nop
8 .size arch_kgdb_breakpoint,.-arch_kgdb_breakpoint
9#endif
10
11 .type __do_privact,#function
12__do_privact:
13 mov TLB_SFSR, %g3
14 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
15 membar #Sync
16 sethi %hi(109f), %g7
17 ba,pt %xcc, etrap
18109: or %g7, %lo(109b), %g7
19 call do_privact
20 add %sp, PTREGS_OFF, %o0
21 ba,pt %xcc, rtrap
22 nop
23 .size __do_privact,.-__do_privact
24
25 .type do_mna,#function
26do_mna:
27 rdpr %tl, %g3
28 cmp %g3, 1
29
30 /* Setup %g4/%g5 now as they are used in the
31 * winfixup code.
32 */
33 mov TLB_SFSR, %g3
34 mov DMMU_SFAR, %g4
35 ldxa [%g4] ASI_DMMU, %g4
36 ldxa [%g3] ASI_DMMU, %g5
37 stxa %g0, [%g3] ASI_DMMU ! Clear FaultValid bit
38 membar #Sync
39 bgu,pn %icc, winfix_mna
40 rdpr %tpc, %g3
41
421: sethi %hi(109f), %g7
43 ba,pt %xcc, etrap
44109: or %g7, %lo(109b), %g7
45 mov %l4, %o1
46 mov %l5, %o2
47 call mem_address_unaligned
48 add %sp, PTREGS_OFF, %o0
49 ba,pt %xcc, rtrap
50 nop
51 .size do_mna,.-do_mna
52
53 .type do_lddfmna,#function
54do_lddfmna:
55 sethi %hi(109f), %g7
56 mov TLB_SFSR, %g4
57 ldxa [%g4] ASI_DMMU, %g5
58 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
59 membar #Sync
60 mov DMMU_SFAR, %g4
61 ldxa [%g4] ASI_DMMU, %g4
62 ba,pt %xcc, etrap
63109: or %g7, %lo(109b), %g7
64 mov %l4, %o1
65 mov %l5, %o2
66 call handle_lddfmna
67 add %sp, PTREGS_OFF, %o0
68 ba,pt %xcc, rtrap
69 nop
70 .size do_lddfmna,.-do_lddfmna
71
72 .type do_stdfmna,#function
73do_stdfmna:
74 sethi %hi(109f), %g7
75 mov TLB_SFSR, %g4
76 ldxa [%g4] ASI_DMMU, %g5
77 stxa %g0, [%g4] ASI_DMMU ! Clear FaultValid bit
78 membar #Sync
79 mov DMMU_SFAR, %g4
80 ldxa [%g4] ASI_DMMU, %g4
81 ba,pt %xcc, etrap
82109: or %g7, %lo(109b), %g7
83 mov %l4, %o1
84 mov %l5, %o2
85 call handle_stdfmna
86 add %sp, PTREGS_OFF, %o0
87 ba,pt %xcc, rtrap
88 nop
89 .size do_stdfmna,.-do_stdfmna
90
91 .type breakpoint_trap,#function
92breakpoint_trap:
93 call sparc_breakpoint
94 add %sp, PTREGS_OFF, %o0
95 ba,pt %xcc, rtrap
96 nop
97 .size breakpoint_trap,.-breakpoint_trap
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 409dd71f2738..3aba47624df4 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -38,7 +38,6 @@
38#include <asm/pgtable.h> 38#include <asm/pgtable.h>
39#include <asm/oplib.h> 39#include <asm/oplib.h>
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/timer.h>
42#include <asm/starfire.h> 41#include <asm/starfire.h>
43#include <asm/tlb.h> 42#include <asm/tlb.h>
44#include <asm/sections.h> 43#include <asm/sections.h>
@@ -910,6 +909,9 @@ extern unsigned long xcall_flush_tlb_kernel_range;
910extern unsigned long xcall_report_regs; 909extern unsigned long xcall_report_regs;
911extern unsigned long xcall_receive_signal; 910extern unsigned long xcall_receive_signal;
912extern unsigned long xcall_new_mmu_context_version; 911extern unsigned long xcall_new_mmu_context_version;
912#ifdef CONFIG_KGDB
913extern unsigned long xcall_kgdb_capture;
914#endif
913 915
914#ifdef DCACHE_ALIASING_POSSIBLE 916#ifdef DCACHE_ALIASING_POSSIBLE
915extern unsigned long xcall_flush_dcache_page_cheetah; 917extern unsigned long xcall_flush_dcache_page_cheetah;
@@ -1079,6 +1081,13 @@ void smp_new_mmu_context_version(void)
1079 smp_cross_call(&xcall_new_mmu_context_version, 0, 0, 0); 1081 smp_cross_call(&xcall_new_mmu_context_version, 0, 0, 0);
1080} 1082}
1081 1083
1084#ifdef CONFIG_KGDB
1085void kgdb_roundup_cpus(unsigned long flags)
1086{
1087 smp_cross_call(&xcall_kgdb_capture, 0, 0, 0);
1088}
1089#endif
1090
1082void smp_report_regs(void) 1091void smp_report_regs(void)
1083{ 1092{
1084 smp_cross_call(&xcall_report_regs, 0, 0, 0); 1093 smp_cross_call(&xcall_report_regs, 0, 0, 0);
diff --git a/arch/sparc64/kernel/spiterrs.S b/arch/sparc64/kernel/spiterrs.S
new file mode 100644
index 000000000000..ef902c6f8e3c
--- /dev/null
+++ b/arch/sparc64/kernel/spiterrs.S
@@ -0,0 +1,245 @@
1 /* We need to carefully read the error status, ACK the errors,
2 * prevent recursive traps, and pass the information on to C
3 * code for logging.
4 *
5 * We pass the AFAR in as-is, and we encode the status
6 * information as described in asm-sparc64/sfafsr.h
7 */
8 .type __spitfire_access_error,#function
9__spitfire_access_error:
10 /* Disable ESTATE error reporting so that we do not take
11 * recursive traps and RED state the processor.
12 */
13 stxa %g0, [%g0] ASI_ESTATE_ERROR_EN
14 membar #Sync
15
16 mov UDBE_UE, %g1
17 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
18
19 /* __spitfire_cee_trap branches here with AFSR in %g4 and
20 * UDBE_CE in %g1. It only clears ESTATE_ERR_CE in the ESTATE
21 * Error Enable register.
22 */
23__spitfire_cee_trap_continue:
24 ldxa [%g0] ASI_AFAR, %g5 ! Get AFAR
25
26 rdpr %tt, %g3
27 and %g3, 0x1ff, %g3 ! Paranoia
28 sllx %g3, SFSTAT_TRAP_TYPE_SHIFT, %g3
29 or %g4, %g3, %g4
30 rdpr %tl, %g3
31 cmp %g3, 1
32 mov 1, %g3
33 bleu %xcc, 1f
34 sllx %g3, SFSTAT_TL_GT_ONE_SHIFT, %g3
35
36 or %g4, %g3, %g4
37
38 /* Read in the UDB error register state, clearing the sticky
39 * error bits as-needed. We only clear them if the UE bit is
40 * set. Likewise, __spitfire_cee_trap below will only do so
41 * if the CE bit is set.
42 *
43 * NOTE: UltraSparc-I/II have high and low UDB error
44 * registers, corresponding to the two UDB units
45 * present on those chips. UltraSparc-IIi only
46 * has a single UDB, called "SDB" in the manual.
47 * For IIi the upper UDB register always reads
48 * as zero so for our purposes things will just
49 * work with the checks below.
50 */
511: ldxa [%g0] ASI_UDBH_ERROR_R, %g3
52 and %g3, 0x3ff, %g7 ! Paranoia
53 sllx %g7, SFSTAT_UDBH_SHIFT, %g7
54 or %g4, %g7, %g4
55 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
56 be,pn %xcc, 1f
57 nop
58 stxa %g3, [%g0] ASI_UDB_ERROR_W
59 membar #Sync
60
611: mov 0x18, %g3
62 ldxa [%g3] ASI_UDBL_ERROR_R, %g3
63 and %g3, 0x3ff, %g7 ! Paranoia
64 sllx %g7, SFSTAT_UDBL_SHIFT, %g7
65 or %g4, %g7, %g4
66 andcc %g3, %g1, %g3 ! UDBE_UE or UDBE_CE
67 be,pn %xcc, 1f
68 nop
69 mov 0x18, %g7
70 stxa %g3, [%g7] ASI_UDB_ERROR_W
71 membar #Sync
72
731: /* Ok, now that we've latched the error state, clear the
74 * sticky bits in the AFSR.
75 */
76 stxa %g4, [%g0] ASI_AFSR
77 membar #Sync
78
79 rdpr %tl, %g2
80 cmp %g2, 1
81 rdpr %pil, %g2
82 bleu,pt %xcc, 1f
83 wrpr %g0, 15, %pil
84
85 ba,pt %xcc, etraptl1
86 rd %pc, %g7
87
88 ba,pt %xcc, 2f
89 nop
90
911: ba,pt %xcc, etrap_irq
92 rd %pc, %g7
93
942:
95#ifdef CONFIG_TRACE_IRQFLAGS
96 call trace_hardirqs_off
97 nop
98#endif
99 mov %l4, %o1
100 mov %l5, %o2
101 call spitfire_access_error
102 add %sp, PTREGS_OFF, %o0
103 ba,pt %xcc, rtrap
104 nop
105 .size __spitfire_access_error,.-__spitfire_access_error
106
107 /* This is the trap handler entry point for ECC correctable
108 * errors. They are corrected, but we listen for the trap so
109 * that the event can be logged.
110 *
111 * Disrupting errors are either:
112 * 1) single-bit ECC errors during UDB reads to system
113 * memory
114 * 2) data parity errors during write-back events
115 *
116 * As far as I can make out from the manual, the CEE trap is
117 * only for correctable errors during memory read accesses by
118 * the front-end of the processor.
119 *
120 * The code below is only for trap level 1 CEE events, as it
121 * is the only situation where we can safely record and log.
122 * For trap level >1 we just clear the CE bit in the AFSR and
123 * return.
124 *
125 * This is just like __spiftire_access_error above, but it
126 * specifically handles correctable errors. If an
127 * uncorrectable error is indicated in the AFSR we will branch
128 * directly above to __spitfire_access_error to handle it
129 * instead. Uncorrectable therefore takes priority over
130 * correctable, and the error logging C code will notice this
131 * case by inspecting the trap type.
132 */
133 .type __spitfire_cee_trap,#function
134__spitfire_cee_trap:
135 ldxa [%g0] ASI_AFSR, %g4 ! Get AFSR
136 mov 1, %g3
137 sllx %g3, SFAFSR_UE_SHIFT, %g3
138 andcc %g4, %g3, %g0 ! Check for UE
139 bne,pn %xcc, __spitfire_access_error
140 nop
141
142 /* Ok, in this case we only have a correctable error.
143 * Indicate we only wish to capture that state in register
144 * %g1, and we only disable CE error reporting unlike UE
145 * handling which disables all errors.
146 */
147 ldxa [%g0] ASI_ESTATE_ERROR_EN, %g3
148 andn %g3, ESTATE_ERR_CE, %g3
149 stxa %g3, [%g0] ASI_ESTATE_ERROR_EN
150 membar #Sync
151
152 /* Preserve AFSR in %g4, indicate UDB state to capture in %g1 */
153 ba,pt %xcc, __spitfire_cee_trap_continue
154 mov UDBE_CE, %g1
155 .size __spitfire_cee_trap,.-__spitfire_cee_trap
156
157 .type __spitfire_data_access_exception_tl1,#function
158__spitfire_data_access_exception_tl1:
159 rdpr %pstate, %g4
160 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
161 mov TLB_SFSR, %g3
162 mov DMMU_SFAR, %g5
163 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
164 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
165 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
166 membar #Sync
167 rdpr %tt, %g3
168 cmp %g3, 0x80 ! first win spill/fill trap
169 blu,pn %xcc, 1f
170 cmp %g3, 0xff ! last win spill/fill trap
171 bgu,pn %xcc, 1f
172 nop
173 ba,pt %xcc, winfix_dax
174 rdpr %tpc, %g3
1751: sethi %hi(109f), %g7
176 ba,pt %xcc, etraptl1
177109: or %g7, %lo(109b), %g7
178 mov %l4, %o1
179 mov %l5, %o2
180 call spitfire_data_access_exception_tl1
181 add %sp, PTREGS_OFF, %o0
182 ba,pt %xcc, rtrap
183 nop
184 .size __spitfire_data_access_exception_tl1,.-__spitfire_data_access_exception_tl1
185
186 .type __spitfire_data_access_exception,#function
187__spitfire_data_access_exception:
188 rdpr %pstate, %g4
189 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
190 mov TLB_SFSR, %g3
191 mov DMMU_SFAR, %g5
192 ldxa [%g3] ASI_DMMU, %g4 ! Get SFSR
193 ldxa [%g5] ASI_DMMU, %g5 ! Get SFAR
194 stxa %g0, [%g3] ASI_DMMU ! Clear SFSR.FaultValid bit
195 membar #Sync
196 sethi %hi(109f), %g7
197 ba,pt %xcc, etrap
198109: or %g7, %lo(109b), %g7
199 mov %l4, %o1
200 mov %l5, %o2
201 call spitfire_data_access_exception
202 add %sp, PTREGS_OFF, %o0
203 ba,pt %xcc, rtrap
204 nop
205 .size __spitfire_data_access_exception,.-__spitfire_data_access_exception
206
207 .type __spitfire_insn_access_exception_tl1,#function
208__spitfire_insn_access_exception_tl1:
209 rdpr %pstate, %g4
210 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
211 mov TLB_SFSR, %g3
212 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
213 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
214 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
215 membar #Sync
216 sethi %hi(109f), %g7
217 ba,pt %xcc, etraptl1
218109: or %g7, %lo(109b), %g7
219 mov %l4, %o1
220 mov %l5, %o2
221 call spitfire_insn_access_exception_tl1
222 add %sp, PTREGS_OFF, %o0
223 ba,pt %xcc, rtrap
224 nop
225 .size __spitfire_insn_access_exception_tl1,.-__spitfire_insn_access_exception_tl1
226
227 .type __spitfire_insn_access_exception,#function
228__spitfire_insn_access_exception:
229 rdpr %pstate, %g4
230 wrpr %g4, PSTATE_MG|PSTATE_AG, %pstate
231 mov TLB_SFSR, %g3
232 ldxa [%g3] ASI_IMMU, %g4 ! Get SFSR
233 rdpr %tpc, %g5 ! IMMU has no SFAR, use TPC
234 stxa %g0, [%g3] ASI_IMMU ! Clear FaultValid bit
235 membar #Sync
236 sethi %hi(109f), %g7
237 ba,pt %xcc, etrap
238109: or %g7, %lo(109b), %g7
239 mov %l4, %o1
240 mov %l5, %o2
241 call spitfire_insn_access_exception
242 add %sp, PTREGS_OFF, %o0
243 ba,pt %xcc, rtrap
244 nop
245 .size __spitfire_insn_access_exception,.-__spitfire_insn_access_exception
diff --git a/arch/sparc64/kernel/syscalls.S b/arch/sparc64/kernel/syscalls.S
new file mode 100644
index 000000000000..db19ed67acf6
--- /dev/null
+++ b/arch/sparc64/kernel/syscalls.S
@@ -0,0 +1,279 @@
1 /* SunOS's execv() call only specifies the argv argument, the
2 * environment settings are the same as the calling processes.
3 */
4sys_execve:
5 sethi %hi(sparc_execve), %g1
6 ba,pt %xcc, execve_merge
7 or %g1, %lo(sparc_execve), %g1
8
9#ifdef CONFIG_COMPAT
10sunos_execv:
11 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2]
12sys32_execve:
13 sethi %hi(sparc32_execve), %g1
14 or %g1, %lo(sparc32_execve), %g1
15#endif
16
17execve_merge:
18 flushw
19 jmpl %g1, %g0
20 add %sp, PTREGS_OFF, %o0
21
22 .align 32
23sys_pipe:
24 ba,pt %xcc, sparc_pipe
25 add %sp, PTREGS_OFF, %o0
26sys_nis_syscall:
27 ba,pt %xcc, c_sys_nis_syscall
28 add %sp, PTREGS_OFF, %o0
29sys_memory_ordering:
30 ba,pt %xcc, sparc_memory_ordering
31 add %sp, PTREGS_OFF, %o1
32sys_sigaltstack:
33 ba,pt %xcc, do_sigaltstack
34 add %i6, STACK_BIAS, %o2
35#ifdef CONFIG_COMPAT
36sys32_sigstack:
37 ba,pt %xcc, do_sys32_sigstack
38 mov %i6, %o2
39sys32_sigaltstack:
40 ba,pt %xcc, do_sys32_sigaltstack
41 mov %i6, %o2
42#endif
43 .align 32
44#ifdef CONFIG_COMPAT
45sys32_sigreturn:
46 add %sp, PTREGS_OFF, %o0
47 call do_sigreturn32
48 add %o7, 1f-.-4, %o7
49 nop
50#endif
51sys_rt_sigreturn:
52 add %sp, PTREGS_OFF, %o0
53 call do_rt_sigreturn
54 add %o7, 1f-.-4, %o7
55 nop
56#ifdef CONFIG_COMPAT
57sys32_rt_sigreturn:
58 add %sp, PTREGS_OFF, %o0
59 call do_rt_sigreturn32
60 add %o7, 1f-.-4, %o7
61 nop
62#endif
63 .align 32
641: ldx [%g6 + TI_FLAGS], %l5
65 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
66 be,pt %icc, rtrap
67 nop
68 add %sp, PTREGS_OFF, %o0
69 call syscall_trace
70 mov 1, %o1
71 ba,pt %xcc, rtrap
72 nop
73
74 /* This is how fork() was meant to be done, 8 instruction entry.
75 *
76 * I questioned the following code briefly, let me clear things
77 * up so you must not reason on it like I did.
78 *
79 * Know the fork_kpsr etc. we use in the sparc32 port? We don't
80 * need it here because the only piece of window state we copy to
81 * the child is the CWP register. Even if the parent sleeps,
82 * we are safe because we stuck it into pt_regs of the parent
83 * so it will not change.
84 *
85 * XXX This raises the question, whether we can do the same on
86 * XXX sparc32 to get rid of fork_kpsr _and_ fork_kwim. The
87 * XXX answer is yes. We stick fork_kpsr in UREG_G0 and
88 * XXX fork_kwim in UREG_G1 (global registers are considered
89 * XXX volatile across a system call in the sparc ABI I think
90 * XXX if it isn't we can use regs->y instead, anyone who depends
91 * XXX upon the Y register being preserved across a fork deserves
92 * XXX to lose).
93 *
94 * In fact we should take advantage of that fact for other things
95 * during system calls...
96 */
97 .align 32
98sys_vfork: /* Under Linux, vfork and fork are just special cases of clone. */
99 sethi %hi(0x4000 | 0x0100 | SIGCHLD), %o0
100 or %o0, %lo(0x4000 | 0x0100 | SIGCHLD), %o0
101 ba,pt %xcc, sys_clone
102sys_fork:
103 clr %o1
104 mov SIGCHLD, %o0
105sys_clone:
106 flushw
107 movrz %o1, %fp, %o1
108 mov 0, %o3
109 ba,pt %xcc, sparc_do_fork
110 add %sp, PTREGS_OFF, %o2
111
112 .globl ret_from_syscall
113ret_from_syscall:
114 /* Clear current_thread_info()->new_child, and
115 * check performance counter stuff too.
116 */
117 stb %g0, [%g6 + TI_NEW_CHILD]
118 ldx [%g6 + TI_FLAGS], %l0
119 call schedule_tail
120 mov %g7, %o0
121 andcc %l0, _TIF_PERFCTR, %g0
122 be,pt %icc, 1f
123 nop
124 ldx [%g6 + TI_PCR], %o7
125 wr %g0, %o7, %pcr
126
127 /* Blackbird errata workaround. See commentary in
128 * smp.c:smp_percpu_timer_interrupt() for more
129 * information.
130 */
131 ba,pt %xcc, 99f
132 nop
133
134 .align 64
13599: wr %g0, %g0, %pic
136 rd %pic, %g0
137
1381: ba,pt %xcc, ret_sys_call
139 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
140
141 .globl sparc_exit
142 .type sparc_exit,#function
143sparc_exit:
144 rdpr %pstate, %g2
145 wrpr %g2, PSTATE_IE, %pstate
146 rdpr %otherwin, %g1
147 rdpr %cansave, %g3
148 add %g3, %g1, %g3
149 wrpr %g3, 0x0, %cansave
150 wrpr %g0, 0x0, %otherwin
151 wrpr %g2, 0x0, %pstate
152 ba,pt %xcc, sys_exit
153 stb %g0, [%g6 + TI_WSAVED]
154 .size sparc_exit,.-sparc_exit
155
156linux_sparc_ni_syscall:
157 sethi %hi(sys_ni_syscall), %l7
158 ba,pt %xcc, 4f
159 or %l7, %lo(sys_ni_syscall), %l7
160
161linux_syscall_trace32:
162 add %sp, PTREGS_OFF, %o0
163 call syscall_trace
164 clr %o1
165 srl %i0, 0, %o0
166 srl %i4, 0, %o4
167 srl %i1, 0, %o1
168 srl %i2, 0, %o2
169 ba,pt %xcc, 2f
170 srl %i3, 0, %o3
171
172linux_syscall_trace:
173 add %sp, PTREGS_OFF, %o0
174 call syscall_trace
175 clr %o1
176 mov %i0, %o0
177 mov %i1, %o1
178 mov %i2, %o2
179 mov %i3, %o3
180 b,pt %xcc, 2f
181 mov %i4, %o4
182
183
184 /* Linux 32-bit system calls enter here... */
185 .align 32
186 .globl linux_sparc_syscall32
187linux_sparc_syscall32:
188 /* Direct access to user regs, much faster. */
189 cmp %g1, NR_SYSCALLS ! IEU1 Group
190 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
191 srl %i0, 0, %o0 ! IEU0
192 sll %g1, 2, %l4 ! IEU0 Group
193 srl %i4, 0, %o4 ! IEU1
194 lduw [%l7 + %l4], %l7 ! Load
195 srl %i1, 0, %o1 ! IEU0 Group
196 ldx [%g6 + TI_FLAGS], %l0 ! Load
197
198 srl %i5, 0, %o5 ! IEU1
199 srl %i2, 0, %o2 ! IEU0 Group
200 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
201 bne,pn %icc, linux_syscall_trace32 ! CTI
202 mov %i0, %l5 ! IEU1
203 call %l7 ! CTI Group brk forced
204 srl %i3, 0, %o3 ! IEU0
205 ba,a,pt %xcc, 3f
206
207 /* Linux native system calls enter here... */
208 .align 32
209 .globl linux_sparc_syscall
210linux_sparc_syscall:
211 /* Direct access to user regs, much faster. */
212 cmp %g1, NR_SYSCALLS ! IEU1 Group
213 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
214 mov %i0, %o0 ! IEU0
215 sll %g1, 2, %l4 ! IEU0 Group
216 mov %i1, %o1 ! IEU1
217 lduw [%l7 + %l4], %l7 ! Load
2184: mov %i2, %o2 ! IEU0 Group
219 ldx [%g6 + TI_FLAGS], %l0 ! Load
220
221 mov %i3, %o3 ! IEU1
222 mov %i4, %o4 ! IEU0 Group
223 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
224 bne,pn %icc, linux_syscall_trace ! CTI Group
225 mov %i0, %l5 ! IEU0
2262: call %l7 ! CTI Group brk forced
227 mov %i5, %o5 ! IEU0
228 nop
229
2303: stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
231ret_sys_call:
232 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %g3
233 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
234 sra %o0, 0, %o0
235 mov %ulo(TSTATE_XCARRY | TSTATE_ICARRY), %g2
236 sllx %g2, 32, %g2
237
238 /* Check if force_successful_syscall_return()
239 * was invoked.
240 */
241 ldub [%g6 + TI_SYS_NOERROR], %l2
242 brnz,a,pn %l2, 80f
243 stb %g0, [%g6 + TI_SYS_NOERROR]
244
245 cmp %o0, -ERESTART_RESTARTBLOCK
246 bgeu,pn %xcc, 1f
247 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
24880:
249 /* System call success, clear Carry condition code. */
250 andn %g3, %g2, %g3
251 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
252 bne,pn %icc, linux_syscall_trace2
253 add %l1, 0x4, %l2 ! npc = npc+4
254 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
255 ba,pt %xcc, rtrap
256 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
257
2581:
259 /* System call failure, set Carry condition code.
260 * Also, get abs(errno) to return to the process.
261 */
262 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6
263 sub %g0, %o0, %o0
264 or %g3, %g2, %g3
265 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]
266 stx %g3, [%sp + PTREGS_OFF + PT_V9_TSTATE]
267 bne,pn %icc, linux_syscall_trace2
268 add %l1, 0x4, %l2 ! npc = npc+4
269 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
270
271 b,pt %xcc, rtrap
272 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
273linux_syscall_trace2:
274 add %sp, PTREGS_OFF, %o0
275 call syscall_trace
276 mov 1, %o1
277 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
278 ba,pt %xcc, rtrap
279 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
diff --git a/arch/sparc64/kernel/ttable.S b/arch/sparc64/kernel/ttable.S
index b0de4c00b11a..450053af039e 100644
--- a/arch/sparc64/kernel/ttable.S
+++ b/arch/sparc64/kernel/ttable.S
@@ -153,7 +153,7 @@ tl0_resv164: BTRAP(0x164) BTRAP(0x165) BTRAP(0x166) BTRAP(0x167) BTRAP(0x168)
153tl0_resv169: BTRAP(0x169) BTRAP(0x16a) BTRAP(0x16b) BTRAP(0x16c) 153tl0_resv169: BTRAP(0x169) BTRAP(0x16a) BTRAP(0x16b) BTRAP(0x16c)
154tl0_linux64: LINUX_64BIT_SYSCALL_TRAP 154tl0_linux64: LINUX_64BIT_SYSCALL_TRAP
155tl0_gsctx: TRAP(sparc64_get_context) TRAP(sparc64_set_context) 155tl0_gsctx: TRAP(sparc64_get_context) TRAP(sparc64_set_context)
156tl0_resv170: KPROBES_TRAP(0x170) KPROBES_TRAP(0x171) BTRAP(0x172) 156tl0_resv170: KPROBES_TRAP(0x170) KPROBES_TRAP(0x171) KGDB_TRAP(0x172)
157tl0_resv173: BTRAP(0x173) BTRAP(0x174) BTRAP(0x175) BTRAP(0x176) BTRAP(0x177) 157tl0_resv173: BTRAP(0x173) BTRAP(0x174) BTRAP(0x175) BTRAP(0x176) BTRAP(0x177)
158tl0_resv178: BTRAP(0x178) BTRAP(0x179) BTRAP(0x17a) BTRAP(0x17b) BTRAP(0x17c) 158tl0_resv178: BTRAP(0x178) BTRAP(0x179) BTRAP(0x17a) BTRAP(0x17b) BTRAP(0x17c)
159tl0_resv17d: BTRAP(0x17d) BTRAP(0x17e) BTRAP(0x17f) 159tl0_resv17d: BTRAP(0x17d) BTRAP(0x17e) BTRAP(0x17f)
diff --git a/arch/sparc64/kernel/utrap.S b/arch/sparc64/kernel/utrap.S
new file mode 100644
index 000000000000..b7f0f3f3a909
--- /dev/null
+++ b/arch/sparc64/kernel/utrap.S
@@ -0,0 +1,29 @@
1 .globl utrap_trap
2 .type utrap_trap,#function
3utrap_trap: /* %g3=handler,%g4=level */
4 TRAP_LOAD_THREAD_REG(%g6, %g1)
5 ldx [%g6 + TI_UTRAPS], %g1
6 brnz,pt %g1, invoke_utrap
7 nop
8
9 ba,pt %xcc, etrap
10 rd %pc, %g7
11 mov %l4, %o1
12 call bad_trap
13 add %sp, PTREGS_OFF, %o0
14 ba,pt %xcc, rtrap
15 nop
16
17invoke_utrap:
18 sllx %g3, 3, %g3
19 ldx [%g1 + %g3], %g1
20 save %sp, -128, %sp
21 rdpr %tstate, %l6
22 rdpr %cwp, %l7
23 andn %l6, TSTATE_CWP, %l6
24 wrpr %l6, %l7, %tstate
25 rdpr %tpc, %l6
26 rdpr %tnpc, %l7
27 wrpr %g1, 0, %tnpc
28 done
29 .size utrap_trap,.-utrap_trap
diff --git a/arch/sparc64/mm/ultra.S b/arch/sparc64/mm/ultra.S
index e686a67561af..796e005dad8b 100644
--- a/arch/sparc64/mm/ultra.S
+++ b/arch/sparc64/mm/ultra.S
@@ -676,6 +676,33 @@ xcall_new_mmu_context_version:
676 wr %g0, (1 << PIL_SMP_CTX_NEW_VERSION), %set_softint 676 wr %g0, (1 << PIL_SMP_CTX_NEW_VERSION), %set_softint
677 retry 677 retry
678 678
679#ifdef CONFIG_KGDB
680 .globl xcall_kgdb_capture
681xcall_kgdb_capture:
682661: rdpr %pstate, %g2
683 wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate
684 .section .sun4v_2insn_patch, "ax"
685 .word 661b
686 nop
687 nop
688 .previous
689
690 rdpr %pil, %g2
691 wrpr %g0, 15, %pil
692 sethi %hi(109f), %g7
693 ba,pt %xcc, etrap_irq
694109: or %g7, %lo(109b), %g7
695#ifdef CONFIG_TRACE_IRQFLAGS
696 call trace_hardirqs_off
697 nop
698#endif
699 call smp_kgdb_capture_client
700 add %sp, PTREGS_OFF, %o0
701 /* Has to be a non-v9 branch due to the large distance. */
702 ba rtrap_xcall
703 ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
704#endif
705
679#endif /* CONFIG_SMP */ 706#endif /* CONFIG_SMP */
680 707
681 708
diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
index bbed3a26ce55..cb3856a18c85 100644
--- a/arch/x86/ia32/ia32_signal.c
+++ b/arch/x86/ia32/ia32_signal.c
@@ -128,7 +128,7 @@ asmlinkage long sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
128 128
129 current->state = TASK_INTERRUPTIBLE; 129 current->state = TASK_INTERRUPTIBLE;
130 schedule(); 130 schedule();
131 set_thread_flag(TIF_RESTORE_SIGMASK); 131 set_restore_sigmask();
132 return -ERESTARTNOHAND; 132 return -ERESTARTNOHAND;
133} 133}
134 134
diff --git a/arch/x86/kernel/signal_32.c b/arch/x86/kernel/signal_32.c
index 8e05e7f7bd40..d92373630963 100644
--- a/arch/x86/kernel/signal_32.c
+++ b/arch/x86/kernel/signal_32.c
@@ -57,7 +57,7 @@ sys_sigsuspend(int history0, int history1, old_sigset_t mask)
57 57
58 current->state = TASK_INTERRUPTIBLE; 58 current->state = TASK_INTERRUPTIBLE;
59 schedule(); 59 schedule();
60 set_thread_flag(TIF_RESTORE_SIGMASK); 60 set_restore_sigmask();
61 61
62 return -ERESTARTNOHAND; 62 return -ERESTARTNOHAND;
63} 63}
@@ -593,7 +593,7 @@ static void do_signal(struct pt_regs *regs)
593 if (!user_mode(regs)) 593 if (!user_mode(regs))
594 return; 594 return;
595 595
596 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 596 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
597 oldset = &current->saved_sigmask; 597 oldset = &current->saved_sigmask;
598 else 598 else
599 oldset = &current->blocked; 599 oldset = &current->blocked;
@@ -612,13 +612,12 @@ static void do_signal(struct pt_regs *regs)
612 /* Whee! Actually deliver the signal. */ 612 /* Whee! Actually deliver the signal. */
613 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 613 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
614 /* 614 /*
615 * a signal was successfully delivered; the saved 615 * A signal was successfully delivered; the saved
616 * sigmask will have been stored in the signal frame, 616 * sigmask will have been stored in the signal frame,
617 * and will be restored by sigreturn, so we can simply 617 * and will be restored by sigreturn, so we can simply
618 * clear the TIF_RESTORE_SIGMASK flag 618 * clear the TS_RESTORE_SIGMASK flag.
619 */ 619 */
620 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 620 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
621 clear_thread_flag(TIF_RESTORE_SIGMASK);
622 } 621 }
623 return; 622 return;
624 } 623 }
@@ -645,8 +644,8 @@ static void do_signal(struct pt_regs *regs)
645 * If there's no signal to deliver, we just put the saved sigmask 644 * If there's no signal to deliver, we just put the saved sigmask
646 * back. 645 * back.
647 */ 646 */
648 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 647 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
649 clear_thread_flag(TIF_RESTORE_SIGMASK); 648 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
650 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 649 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
651 } 650 }
652} 651}
@@ -665,7 +664,7 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
665 } 664 }
666 665
667 /* deal with pending signal delivery */ 666 /* deal with pending signal delivery */
668 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 667 if (thread_info_flags & _TIF_SIGPENDING)
669 do_signal(regs); 668 do_signal(regs);
670 669
671 if (thread_info_flags & _TIF_HRTICK_RESCHED) 670 if (thread_info_flags & _TIF_HRTICK_RESCHED)
diff --git a/arch/x86/kernel/signal_64.c b/arch/x86/kernel/signal_64.c
index ccb2a4560c2d..e53b267662e7 100644
--- a/arch/x86/kernel/signal_64.c
+++ b/arch/x86/kernel/signal_64.c
@@ -427,7 +427,7 @@ static void do_signal(struct pt_regs *regs)
427 if (!user_mode(regs)) 427 if (!user_mode(regs))
428 return; 428 return;
429 429
430 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 430 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
431 oldset = &current->saved_sigmask; 431 oldset = &current->saved_sigmask;
432 else 432 else
433 oldset = &current->blocked; 433 oldset = &current->blocked;
@@ -444,11 +444,13 @@ static void do_signal(struct pt_regs *regs)
444 444
445 /* Whee! Actually deliver the signal. */ 445 /* Whee! Actually deliver the signal. */
446 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) { 446 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
447 /* a signal was successfully delivered; the saved 447 /*
448 * A signal was successfully delivered; the saved
448 * sigmask will have been stored in the signal frame, 449 * sigmask will have been stored in the signal frame,
449 * and will be restored by sigreturn, so we can simply 450 * and will be restored by sigreturn, so we can simply
450 * clear the TIF_RESTORE_SIGMASK flag */ 451 * clear the TS_RESTORE_SIGMASK flag.
451 clear_thread_flag(TIF_RESTORE_SIGMASK); 452 */
453 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
452 } 454 }
453 return; 455 return;
454 } 456 }
@@ -476,8 +478,8 @@ static void do_signal(struct pt_regs *regs)
476 * If there's no signal to deliver, we just put the saved sigmask 478 * If there's no signal to deliver, we just put the saved sigmask
477 * back. 479 * back.
478 */ 480 */
479 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 481 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
480 clear_thread_flag(TIF_RESTORE_SIGMASK); 482 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
481 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 483 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
482 } 484 }
483} 485}
@@ -498,7 +500,7 @@ void do_notify_resume(struct pt_regs *regs, void *unused,
498#endif /* CONFIG_X86_MCE */ 500#endif /* CONFIG_X86_MCE */
499 501
500 /* deal with pending signal delivery */ 502 /* deal with pending signal delivery */
501 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 503 if (thread_info_flags & _TIF_SIGPENDING)
502 do_signal(regs); 504 do_signal(regs);
503 505
504 if (thread_info_flags & _TIF_HRTICK_RESCHED) 506 if (thread_info_flags & _TIF_HRTICK_RESCHED)
diff --git a/block/genhd.c b/block/genhd.c
index 00da5219ee37..fda9c7a63c29 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -182,11 +182,17 @@ static int exact_lock(dev_t devt, void *data)
182 */ 182 */
183void add_disk(struct gendisk *disk) 183void add_disk(struct gendisk *disk)
184{ 184{
185 struct backing_dev_info *bdi;
186
185 disk->flags |= GENHD_FL_UP; 187 disk->flags |= GENHD_FL_UP;
186 blk_register_region(MKDEV(disk->major, disk->first_minor), 188 blk_register_region(MKDEV(disk->major, disk->first_minor),
187 disk->minors, NULL, exact_match, exact_lock, disk); 189 disk->minors, NULL, exact_match, exact_lock, disk);
188 register_disk(disk); 190 register_disk(disk);
189 blk_register_queue(disk); 191 blk_register_queue(disk);
192
193 bdi = &disk->queue->backing_dev_info;
194 bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor));
195 sysfs_create_link(&disk->dev.kobj, &bdi->dev->kobj, "bdi");
190} 196}
191 197
192EXPORT_SYMBOL(add_disk); 198EXPORT_SYMBOL(add_disk);
@@ -194,6 +200,8 @@ EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */
194 200
195void unlink_gendisk(struct gendisk *disk) 201void unlink_gendisk(struct gendisk *disk)
196{ 202{
203 sysfs_remove_link(&disk->dev.kobj, "bdi");
204 bdi_unregister(&disk->queue->backing_dev_info);
197 blk_unregister_queue(disk); 205 blk_unregister_queue(disk);
198 blk_unregister_region(MKDEV(disk->major, disk->first_minor), 206 blk_unregister_region(MKDEV(disk->major, disk->first_minor),
199 disk->minors); 207 disk->minors);
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 80f0ec91e2cf..59f33fa6af3e 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -84,6 +84,8 @@ source "drivers/memstick/Kconfig"
84 84
85source "drivers/leds/Kconfig" 85source "drivers/leds/Kconfig"
86 86
87source "drivers/accessibility/Kconfig"
88
87source "drivers/infiniband/Kconfig" 89source "drivers/infiniband/Kconfig"
88 90
89source "drivers/edac/Kconfig" 91source "drivers/edac/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index e5e394a7e6c0..f65deda72d61 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -70,6 +70,7 @@ obj-$(CONFIG_WATCHDOG) += watchdog/
70obj-$(CONFIG_PHONE) += telephony/ 70obj-$(CONFIG_PHONE) += telephony/
71obj-$(CONFIG_MD) += md/ 71obj-$(CONFIG_MD) += md/
72obj-$(CONFIG_BT) += bluetooth/ 72obj-$(CONFIG_BT) += bluetooth/
73obj-$(CONFIG_ACCESSIBILITY) += accessibility/
73obj-$(CONFIG_ISDN) += isdn/ 74obj-$(CONFIG_ISDN) += isdn/
74obj-$(CONFIG_EDAC) += edac/ 75obj-$(CONFIG_EDAC) += edac/
75obj-$(CONFIG_MCA) += mca/ 76obj-$(CONFIG_MCA) += mca/
diff --git a/drivers/accessibility/Kconfig b/drivers/accessibility/Kconfig
new file mode 100644
index 000000000000..1264c4b98094
--- /dev/null
+++ b/drivers/accessibility/Kconfig
@@ -0,0 +1,23 @@
1menuconfig ACCESSIBILITY
2 bool "Accessibility support"
3 ---help---
4 Enable a submenu where accessibility items may be enabled.
5
6 If unsure, say N.
7
8if ACCESSIBILITY
9config A11Y_BRAILLE_CONSOLE
10 bool "Console on braille device"
11 depends on VT
12 depends on SERIAL_CORE_CONSOLE
13 ---help---
14 Enables console output on a braille device connected to a 8250
15 serial port. For now only the VisioBraille device is supported.
16
17 To actually enable it, you need to pass option
18 console=brl,ttyS0
19 to the kernel. Options are the same as for serial console.
20
21 If unsure, say N.
22
23endif # ACCESSIBILITY
diff --git a/drivers/accessibility/Makefile b/drivers/accessibility/Makefile
new file mode 100644
index 000000000000..72b01a46546f
--- /dev/null
+++ b/drivers/accessibility/Makefile
@@ -0,0 +1 @@
obj-y += braille/
diff --git a/drivers/accessibility/braille/Makefile b/drivers/accessibility/braille/Makefile
new file mode 100644
index 000000000000..2e9f16c91347
--- /dev/null
+++ b/drivers/accessibility/braille/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille_console.o
diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c
new file mode 100644
index 000000000000..0a5f6b2114c5
--- /dev/null
+++ b/drivers/accessibility/braille/braille_console.c
@@ -0,0 +1,397 @@
1/*
2 * Minimalistic braille device kernel support.
3 *
4 * By default, shows console messages on the braille device.
5 * Pressing Insert switches to VC browsing.
6 *
7 * Copyright (C) Samuel Thibault <samuel.thibault@ens-lyon.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 the program ; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/autoconf.h>
25#include <linux/kernel.h>
26#include <linux/module.h>
27#include <linux/moduleparam.h>
28#include <linux/console.h>
29#include <linux/notifier.h>
30
31#include <linux/selection.h>
32#include <linux/vt_kern.h>
33#include <linux/consolemap.h>
34
35#include <linux/keyboard.h>
36#include <linux/kbd_kern.h>
37#include <linux/input.h>
38
39MODULE_AUTHOR("samuel.thibault@ens-lyon.org");
40MODULE_DESCRIPTION("braille device");
41MODULE_LICENSE("GPL");
42
43/*
44 * Braille device support part.
45 */
46
47/* Emit various sounds */
48static int sound;
49module_param(sound, bool, 0);
50MODULE_PARM_DESC(sound, "emit sounds");
51
52static void beep(unsigned int freq)
53{
54 if (sound)
55 kd_mksound(freq, HZ/10);
56}
57
58/* mini console */
59#define WIDTH 40
60#define BRAILLE_KEY KEY_INSERT
61static u16 console_buf[WIDTH];
62static int console_cursor;
63
64/* mini view of VC */
65static int vc_x, vc_y, lastvc_x, lastvc_y;
66
67/* show console ? (or show VC) */
68static int console_show = 1;
69/* pending newline ? */
70static int console_newline = 1;
71static int lastVC = -1;
72
73static struct console *braille_co;
74
75/* Very VisioBraille-specific */
76static void braille_write(u16 *buf)
77{
78 static u16 lastwrite[WIDTH];
79 unsigned char data[1 + 1 + 2*WIDTH + 2 + 1], csum = 0, *c;
80 u16 out;
81 int i;
82
83 if (!braille_co)
84 return;
85
86 if (!memcmp(lastwrite, buf, WIDTH * sizeof(*buf)))
87 return;
88 memcpy(lastwrite, buf, WIDTH * sizeof(*buf));
89
90#define SOH 1
91#define STX 2
92#define ETX 2
93#define EOT 4
94#define ENQ 5
95 data[0] = STX;
96 data[1] = '>';
97 csum ^= '>';
98 c = &data[2];
99 for (i = 0; i < WIDTH; i++) {
100 out = buf[i];
101 if (out >= 0x100)
102 out = '?';
103 else if (out == 0x00)
104 out = ' ';
105 csum ^= out;
106 if (out <= 0x05) {
107 *c++ = SOH;
108 out |= 0x40;
109 }
110 *c++ = out;
111 }
112
113 if (csum <= 0x05) {
114 *c++ = SOH;
115 csum |= 0x40;
116 }
117 *c++ = csum;
118 *c++ = ETX;
119
120 braille_co->write(braille_co, data, c - data);
121}
122
123/* Follow the VC cursor*/
124static void vc_follow_cursor(struct vc_data *vc)
125{
126 vc_x = vc->vc_x - (vc->vc_x % WIDTH);
127 vc_y = vc->vc_y;
128 lastvc_x = vc->vc_x;
129 lastvc_y = vc->vc_y;
130}
131
132/* Maybe the VC cursor moved, if so follow it */
133static void vc_maybe_cursor_moved(struct vc_data *vc)
134{
135 if (vc->vc_x != lastvc_x || vc->vc_y != lastvc_y)
136 vc_follow_cursor(vc);
137}
138
139/* Show portion of VC at vc_x, vc_y */
140static void vc_refresh(struct vc_data *vc)
141{
142 u16 buf[WIDTH];
143 int i;
144
145 for (i = 0; i < WIDTH; i++) {
146 u16 glyph = screen_glyph(vc,
147 2 * (vc_x + i) + vc_y * vc->vc_size_row);
148 buf[i] = inverse_translate(vc, glyph, 1);
149 }
150 braille_write(buf);
151}
152
153/*
154 * Link to keyboard
155 */
156
157static int keyboard_notifier_call(struct notifier_block *blk,
158 unsigned long code, void *_param)
159{
160 struct keyboard_notifier_param *param = _param;
161 struct vc_data *vc = param->vc;
162 int ret = NOTIFY_OK;
163
164 if (!param->down)
165 return ret;
166
167 switch (code) {
168 case KBD_KEYCODE:
169 if (console_show) {
170 if (param->value == BRAILLE_KEY) {
171 console_show = 0;
172 beep(880);
173 vc_maybe_cursor_moved(vc);
174 vc_refresh(vc);
175 ret = NOTIFY_STOP;
176 }
177 } else {
178 ret = NOTIFY_STOP;
179 switch (param->value) {
180 case KEY_INSERT:
181 beep(440);
182 console_show = 1;
183 lastVC = -1;
184 braille_write(console_buf);
185 break;
186 case KEY_LEFT:
187 if (vc_x > 0) {
188 vc_x -= WIDTH;
189 if (vc_x < 0)
190 vc_x = 0;
191 } else if (vc_y >= 1) {
192 beep(880);
193 vc_y--;
194 vc_x = vc->vc_cols-WIDTH;
195 } else
196 beep(220);
197 break;
198 case KEY_RIGHT:
199 if (vc_x + WIDTH < vc->vc_cols) {
200 vc_x += WIDTH;
201 } else if (vc_y + 1 < vc->vc_rows) {
202 beep(880);
203 vc_y++;
204 vc_x = 0;
205 } else
206 beep(220);
207 break;
208 case KEY_DOWN:
209 if (vc_y + 1 < vc->vc_rows)
210 vc_y++;
211 else
212 beep(220);
213 break;
214 case KEY_UP:
215 if (vc_y >= 1)
216 vc_y--;
217 else
218 beep(220);
219 break;
220 case KEY_HOME:
221 vc_follow_cursor(vc);
222 break;
223 case KEY_PAGEUP:
224 vc_x = 0;
225 vc_y = 0;
226 break;
227 case KEY_PAGEDOWN:
228 vc_x = 0;
229 vc_y = vc->vc_rows-1;
230 break;
231 default:
232 ret = NOTIFY_OK;
233 break;
234 }
235 if (ret == NOTIFY_STOP)
236 vc_refresh(vc);
237 }
238 break;
239 case KBD_POST_KEYSYM:
240 {
241 unsigned char type = KTYP(param->value) - 0xf0;
242 if (type == KT_SPEC) {
243 unsigned char val = KVAL(param->value);
244 int on_off = -1;
245
246 switch (val) {
247 case KVAL(K_CAPS):
248 on_off = vc_kbd_led(kbd_table + fg_console,
249 VC_CAPSLOCK);
250 break;
251 case KVAL(K_NUM):
252 on_off = vc_kbd_led(kbd_table + fg_console,
253 VC_NUMLOCK);
254 break;
255 case KVAL(K_HOLD):
256 on_off = vc_kbd_led(kbd_table + fg_console,
257 VC_SCROLLOCK);
258 break;
259 }
260 if (on_off == 1)
261 beep(880);
262 else if (on_off == 0)
263 beep(440);
264 }
265 }
266 case KBD_UNBOUND_KEYCODE:
267 case KBD_UNICODE:
268 case KBD_KEYSYM:
269 /* Unused */
270 break;
271 }
272 return ret;
273}
274
275static struct notifier_block keyboard_notifier_block = {
276 .notifier_call = keyboard_notifier_call,
277};
278
279static int vt_notifier_call(struct notifier_block *blk,
280 unsigned long code, void *_param)
281{
282 struct vt_notifier_param *param = _param;
283 struct vc_data *vc = param->vc;
284 switch (code) {
285 case VT_ALLOCATE:
286 break;
287 case VT_DEALLOCATE:
288 break;
289 case VT_WRITE:
290 {
291 unsigned char c = param->c;
292 if (vc->vc_num != fg_console)
293 break;
294 switch (c) {
295 case '\b':
296 case 127:
297 if (console_cursor > 0) {
298 console_cursor--;
299 console_buf[console_cursor] = ' ';
300 }
301 break;
302 case '\n':
303 case '\v':
304 case '\f':
305 case '\r':
306 console_newline = 1;
307 break;
308 case '\t':
309 c = ' ';
310 /* Fallthrough */
311 default:
312 if (c < 32)
313 /* Ignore other control sequences */
314 break;
315 if (console_newline) {
316 memset(console_buf, 0, sizeof(console_buf));
317 console_cursor = 0;
318 console_newline = 0;
319 }
320 if (console_cursor == WIDTH)
321 memmove(console_buf, &console_buf[1],
322 (WIDTH-1) * sizeof(*console_buf));
323 else
324 console_cursor++;
325 console_buf[console_cursor-1] = c;
326 break;
327 }
328 if (console_show)
329 braille_write(console_buf);
330 else {
331 vc_maybe_cursor_moved(vc);
332 vc_refresh(vc);
333 }
334 break;
335 }
336 case VT_UPDATE:
337 /* Maybe a VT switch, flush */
338 if (console_show) {
339 if (vc->vc_num != lastVC) {
340 lastVC = vc->vc_num;
341 memset(console_buf, 0, sizeof(console_buf));
342 console_cursor = 0;
343 braille_write(console_buf);
344 }
345 } else {
346 vc_maybe_cursor_moved(vc);
347 vc_refresh(vc);
348 }
349 break;
350 }
351 return NOTIFY_OK;
352}
353
354static struct notifier_block vt_notifier_block = {
355 .notifier_call = vt_notifier_call,
356};
357
358/*
359 * Called from printk.c when console=brl is given
360 */
361
362int braille_register_console(struct console *console, int index,
363 char *console_options, char *braille_options)
364{
365 int ret;
366 if (!console_options)
367 /* Only support VisioBraille for now */
368 console_options = "57600o8";
369 if (braille_co)
370 return -ENODEV;
371 if (console->setup) {
372 ret = console->setup(console, console_options);
373 if (ret != 0)
374 return ret;
375 }
376 console->flags |= CON_ENABLED;
377 console->index = index;
378 braille_co = console;
379 return 0;
380}
381
382int braille_unregister_console(struct console *console)
383{
384 if (braille_co != console)
385 return -EINVAL;
386 braille_co = NULL;
387 return 0;
388}
389
390static int __init braille_init(void)
391{
392 register_keyboard_notifier(&keyboard_notifier_block);
393 register_vt_notifier(&vt_notifier_block);
394 return 0;
395}
396
397console_initcall(braille_init);
diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index 5aa12b011a9a..6adb72a2f876 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -33,6 +33,7 @@
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/poison.h> 34#include <linux/poison.h>
35#include <linux/bitrev.h> 35#include <linux/bitrev.h>
36#include <linux/mutex.h>
36 37
37#include <asm/atomic.h> 38#include <asm/atomic.h>
38#include <asm/io.h> 39#include <asm/io.h>
@@ -1177,7 +1178,7 @@ static int amb_open (struct atm_vcc * atm_vcc)
1177 1178
1178 vcc->tx_frame_bits = tx_frame_bits; 1179 vcc->tx_frame_bits = tx_frame_bits;
1179 1180
1180 down (&dev->vcc_sf); 1181 mutex_lock(&dev->vcc_sf);
1181 if (dev->rxer[vci]) { 1182 if (dev->rxer[vci]) {
1182 // RXer on the channel already, just modify rate... 1183 // RXer on the channel already, just modify rate...
1183 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE); 1184 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE);
@@ -1203,7 +1204,7 @@ static int amb_open (struct atm_vcc * atm_vcc)
1203 schedule(); 1204 schedule();
1204 } 1205 }
1205 dev->txer[vci].tx_present = 1; 1206 dev->txer[vci].tx_present = 1;
1206 up (&dev->vcc_sf); 1207 mutex_unlock(&dev->vcc_sf);
1207 } 1208 }
1208 1209
1209 if (rxtp->traffic_class != ATM_NONE) { 1210 if (rxtp->traffic_class != ATM_NONE) {
@@ -1211,7 +1212,7 @@ static int amb_open (struct atm_vcc * atm_vcc)
1211 1212
1212 vcc->rx_info.pool = pool; 1213 vcc->rx_info.pool = pool;
1213 1214
1214 down (&dev->vcc_sf); 1215 mutex_lock(&dev->vcc_sf);
1215 /* grow RX buffer pool */ 1216 /* grow RX buffer pool */
1216 if (!dev->rxq[pool].buffers_wanted) 1217 if (!dev->rxq[pool].buffers_wanted)
1217 dev->rxq[pool].buffers_wanted = rx_lats; 1218 dev->rxq[pool].buffers_wanted = rx_lats;
@@ -1237,7 +1238,7 @@ static int amb_open (struct atm_vcc * atm_vcc)
1237 schedule(); 1238 schedule();
1238 // this link allows RX frames through 1239 // this link allows RX frames through
1239 dev->rxer[vci] = atm_vcc; 1240 dev->rxer[vci] = atm_vcc;
1240 up (&dev->vcc_sf); 1241 mutex_unlock(&dev->vcc_sf);
1241 } 1242 }
1242 1243
1243 // indicate readiness 1244 // indicate readiness
@@ -1262,7 +1263,7 @@ static void amb_close (struct atm_vcc * atm_vcc) {
1262 if (atm_vcc->qos.txtp.traffic_class != ATM_NONE) { 1263 if (atm_vcc->qos.txtp.traffic_class != ATM_NONE) {
1263 command cmd; 1264 command cmd;
1264 1265
1265 down (&dev->vcc_sf); 1266 mutex_lock(&dev->vcc_sf);
1266 if (dev->rxer[vci]) { 1267 if (dev->rxer[vci]) {
1267 // RXer still on the channel, just modify rate... XXX not really needed 1268 // RXer still on the channel, just modify rate... XXX not really needed
1268 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE); 1269 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_RATE);
@@ -1277,7 +1278,7 @@ static void amb_close (struct atm_vcc * atm_vcc) {
1277 dev->txer[vci].tx_present = 0; 1278 dev->txer[vci].tx_present = 0;
1278 while (command_do (dev, &cmd)) 1279 while (command_do (dev, &cmd))
1279 schedule(); 1280 schedule();
1280 up (&dev->vcc_sf); 1281 mutex_unlock(&dev->vcc_sf);
1281 } 1282 }
1282 1283
1283 // disable RXing 1284 // disable RXing
@@ -1287,7 +1288,7 @@ static void amb_close (struct atm_vcc * atm_vcc) {
1287 // this is (the?) one reason why we need the amb_vcc struct 1288 // this is (the?) one reason why we need the amb_vcc struct
1288 unsigned char pool = vcc->rx_info.pool; 1289 unsigned char pool = vcc->rx_info.pool;
1289 1290
1290 down (&dev->vcc_sf); 1291 mutex_lock(&dev->vcc_sf);
1291 if (dev->txer[vci].tx_present) { 1292 if (dev->txer[vci].tx_present) {
1292 // TXer still on the channel, just go to pool zero XXX not really needed 1293 // TXer still on the channel, just go to pool zero XXX not really needed
1293 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_FLAGS); 1294 cmd.request = cpu_to_be32 (SRB_MODIFY_VC_FLAGS);
@@ -1314,7 +1315,7 @@ static void amb_close (struct atm_vcc * atm_vcc) {
1314 dev->rxq[pool].buffers_wanted = 0; 1315 dev->rxq[pool].buffers_wanted = 0;
1315 drain_rx_pool (dev, pool); 1316 drain_rx_pool (dev, pool);
1316 } 1317 }
1317 up (&dev->vcc_sf); 1318 mutex_unlock(&dev->vcc_sf);
1318 } 1319 }
1319 1320
1320 // free our structure 1321 // free our structure
@@ -2188,7 +2189,7 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
2188 2189
2189 // semaphore for txer/rxer modifications - we cannot use a 2190 // semaphore for txer/rxer modifications - we cannot use a
2190 // spinlock as the critical region needs to switch processes 2191 // spinlock as the critical region needs to switch processes
2191 init_MUTEX (&dev->vcc_sf); 2192 mutex_init(&dev->vcc_sf);
2192 // queue manipulation spinlocks; we want atomic reads and 2193 // queue manipulation spinlocks; we want atomic reads and
2193 // writes to the queue descriptors (handles IRQ and SMP) 2194 // writes to the queue descriptors (handles IRQ and SMP)
2194 // consider replacing "int pending" -> "atomic_t available" 2195 // consider replacing "int pending" -> "atomic_t available"
diff --git a/drivers/atm/ambassador.h b/drivers/atm/ambassador.h
index ff2a303cbe00..df55fa8387dc 100644
--- a/drivers/atm/ambassador.h
+++ b/drivers/atm/ambassador.h
@@ -638,7 +638,7 @@ struct amb_dev {
638 amb_txq txq; 638 amb_txq txq;
639 amb_rxq rxq[NUM_RX_POOLS]; 639 amb_rxq rxq[NUM_RX_POOLS];
640 640
641 struct semaphore vcc_sf; 641 struct mutex vcc_sf;
642 amb_tx_info txer[NUM_VCS]; 642 amb_tx_info txer[NUM_VCS];
643 struct atm_vcc * rxer[NUM_VCS]; 643 struct atm_vcc * rxer[NUM_VCS];
644 unsigned int tx_avail; 644 unsigned int tx_avail;
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 12fde2d03d69..39f3d1b3a213 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -77,6 +77,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
77 "Node %d PageTables: %8lu kB\n" 77 "Node %d PageTables: %8lu kB\n"
78 "Node %d NFS_Unstable: %8lu kB\n" 78 "Node %d NFS_Unstable: %8lu kB\n"
79 "Node %d Bounce: %8lu kB\n" 79 "Node %d Bounce: %8lu kB\n"
80 "Node %d WritebackTmp: %8lu kB\n"
80 "Node %d Slab: %8lu kB\n" 81 "Node %d Slab: %8lu kB\n"
81 "Node %d SReclaimable: %8lu kB\n" 82 "Node %d SReclaimable: %8lu kB\n"
82 "Node %d SUnreclaim: %8lu kB\n", 83 "Node %d SUnreclaim: %8lu kB\n",
@@ -99,6 +100,7 @@ static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
99 nid, K(node_page_state(nid, NR_PAGETABLE)), 100 nid, K(node_page_state(nid, NR_PAGETABLE)),
100 nid, K(node_page_state(nid, NR_UNSTABLE_NFS)), 101 nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
101 nid, K(node_page_state(nid, NR_BOUNCE)), 102 nid, K(node_page_state(nid, NR_BOUNCE)),
103 nid, K(node_page_state(nid, NR_WRITEBACK_TEMP)),
102 nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE) + 104 nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE) +
103 node_page_state(nid, NR_SLAB_UNRECLAIMABLE)), 105 node_page_state(nid, NR_SLAB_UNRECLAIMABLE)),
104 nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE)), 106 nid, K(node_page_state(nid, NR_SLAB_RECLAIMABLE)),
diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index e8e38faeafd8..a196ef7f147f 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -387,10 +387,14 @@ static struct block_device_operations brd_fops = {
387 */ 387 */
388static int rd_nr; 388static int rd_nr;
389int rd_size = CONFIG_BLK_DEV_RAM_SIZE; 389int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
390static int max_part;
391static int part_shift;
390module_param(rd_nr, int, 0); 392module_param(rd_nr, int, 0);
391MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices"); 393MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
392module_param(rd_size, int, 0); 394module_param(rd_size, int, 0);
393MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes."); 395MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
396module_param(max_part, int, 0);
397MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
394MODULE_LICENSE("GPL"); 398MODULE_LICENSE("GPL");
395MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR); 399MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
396 400
@@ -435,11 +439,11 @@ static struct brd_device *brd_alloc(int i)
435 blk_queue_max_sectors(brd->brd_queue, 1024); 439 blk_queue_max_sectors(brd->brd_queue, 1024);
436 blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY); 440 blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
437 441
438 disk = brd->brd_disk = alloc_disk(1); 442 disk = brd->brd_disk = alloc_disk(1 << part_shift);
439 if (!disk) 443 if (!disk)
440 goto out_free_queue; 444 goto out_free_queue;
441 disk->major = RAMDISK_MAJOR; 445 disk->major = RAMDISK_MAJOR;
442 disk->first_minor = i; 446 disk->first_minor = i << part_shift;
443 disk->fops = &brd_fops; 447 disk->fops = &brd_fops;
444 disk->private_data = brd; 448 disk->private_data = brd;
445 disk->queue = brd->brd_queue; 449 disk->queue = brd->brd_queue;
@@ -523,7 +527,12 @@ static int __init brd_init(void)
523 * themselves and have kernel automatically instantiate actual 527 * themselves and have kernel automatically instantiate actual
524 * device on-demand. 528 * device on-demand.
525 */ 529 */
526 if (rd_nr > 1UL << MINORBITS) 530
531 part_shift = 0;
532 if (max_part > 0)
533 part_shift = fls(max_part);
534
535 if (rd_nr > 1UL << (MINORBITS - part_shift))
527 return -EINVAL; 536 return -EINVAL;
528 537
529 if (rd_nr) { 538 if (rd_nr) {
@@ -531,7 +540,7 @@ static int __init brd_init(void)
531 range = rd_nr; 540 range = rd_nr;
532 } else { 541 } else {
533 nr = CONFIG_BLK_DEV_RAM_COUNT; 542 nr = CONFIG_BLK_DEV_RAM_COUNT;
534 range = 1UL << MINORBITS; 543 range = 1UL << (MINORBITS - part_shift);
535 } 544 }
536 545
537 if (register_blkdev(RAMDISK_MAJOR, "ramdisk")) 546 if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
@@ -570,7 +579,7 @@ static void __exit brd_exit(void)
570 unsigned long range; 579 unsigned long range;
571 struct brd_device *brd, *next; 580 struct brd_device *brd, *next;
572 581
573 range = rd_nr ? rd_nr : 1UL << MINORBITS; 582 range = rd_nr ? rd_nr : 1UL << (MINORBITS - part_shift);
574 583
575 list_for_each_entry_safe(brd, next, &brd_devices, brd_list) 584 list_for_each_entry_safe(brd, next, &brd_devices, brd_list)
576 brd_del_one(brd); 585 brd_del_one(brd);
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 7e31d5f1bc8a..e5cd856a2fea 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -143,7 +143,7 @@ restart:
143 int len; 143 int len;
144 144
145 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 145 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
146 len = tty->driver->write(tty, skb->data, skb->len); 146 len = tty->ops->write(tty, skb->data, skb->len);
147 hdev->stat.byte_tx += len; 147 hdev->stat.byte_tx += len;
148 148
149 skb_pull(skb, len); 149 skb_pull(skb, len);
@@ -190,8 +190,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
190 190
191 /* Flush any pending characters in the driver and discipline. */ 191 /* Flush any pending characters in the driver and discipline. */
192 tty_ldisc_flush(tty); 192 tty_ldisc_flush(tty);
193 if (tty->driver && tty->driver->flush_buffer) 193 tty_driver_flush_buffer(tty);
194 tty->driver->flush_buffer(tty);
195 194
196 if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) 195 if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
197 hu->proto->flush(hu); 196 hu->proto->flush(hu);
@@ -285,9 +284,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
285 284
286 if (tty->ldisc.flush_buffer) 285 if (tty->ldisc.flush_buffer)
287 tty->ldisc.flush_buffer(tty); 286 tty->ldisc.flush_buffer(tty);
288 287 tty_driver_flush_buffer(tty);
289 if (tty->driver && tty->driver->flush_buffer)
290 tty->driver->flush_buffer(tty);
291 288
292 return 0; 289 return 0;
293} 290}
@@ -373,9 +370,7 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *f
373 hu->hdev->stat.byte_rx += count; 370 hu->hdev->stat.byte_rx += count;
374 spin_unlock(&hu->rx_lock); 371 spin_unlock(&hu->rx_lock);
375 372
376 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && 373 tty_unthrottle(tty);
377 tty->driver->unthrottle)
378 tty->driver->unthrottle(tty);
379} 374}
380 375
381static int hci_uart_register_dev(struct hci_uart *hu) 376static int hci_uart_register_dev(struct hci_uart *hu)
diff --git a/drivers/char/agp/agp.h b/drivers/char/agp/agp.h
index c69f79598e47..99e6a406efb4 100644
--- a/drivers/char/agp/agp.h
+++ b/drivers/char/agp/agp.h
@@ -35,7 +35,7 @@
35 35
36//#define AGP_DEBUG 1 36//#define AGP_DEBUG 1
37#ifdef AGP_DEBUG 37#ifdef AGP_DEBUG
38#define DBG(x,y...) printk (KERN_DEBUG PFX "%s: " x "\n", __FUNCTION__ , ## y) 38#define DBG(x,y...) printk (KERN_DEBUG PFX "%s: " x "\n", __func__ , ## y)
39#else 39#else
40#define DBG(x,y...) do { } while (0) 40#define DBG(x,y...) do { } while (0)
41#endif 41#endif
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 3d468f502d2d..37457e5a4f2b 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -832,33 +832,34 @@ static void change_speed(struct async_struct *info,
832 local_irq_restore(flags); 832 local_irq_restore(flags);
833} 833}
834 834
835static void rs_put_char(struct tty_struct *tty, unsigned char ch) 835static int rs_put_char(struct tty_struct *tty, unsigned char ch)
836{ 836{
837 struct async_struct *info; 837 struct async_struct *info;
838 unsigned long flags; 838 unsigned long flags;
839 839
840 if (!tty) 840 if (!tty)
841 return; 841 return 0;
842 842
843 info = tty->driver_data; 843 info = tty->driver_data;
844 844
845 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 845 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
846 return; 846 return 0;
847 847
848 if (!info->xmit.buf) 848 if (!info->xmit.buf)
849 return; 849 return 0;
850 850
851 local_irq_save(flags); 851 local_irq_save(flags);
852 if (CIRC_SPACE(info->xmit.head, 852 if (CIRC_SPACE(info->xmit.head,
853 info->xmit.tail, 853 info->xmit.tail,
854 SERIAL_XMIT_SIZE) == 0) { 854 SERIAL_XMIT_SIZE) == 0) {
855 local_irq_restore(flags); 855 local_irq_restore(flags);
856 return; 856 return 0;
857 } 857 }
858 858
859 info->xmit.buf[info->xmit.head++] = ch; 859 info->xmit.buf[info->xmit.head++] = ch;
860 info->xmit.head &= SERIAL_XMIT_SIZE-1; 860 info->xmit.head &= SERIAL_XMIT_SIZE-1;
861 local_irq_restore(flags); 861 local_irq_restore(flags);
862 return 1;
862} 863}
863 864
864static void rs_flush_chars(struct tty_struct *tty) 865static void rs_flush_chars(struct tty_struct *tty)
@@ -1074,6 +1075,7 @@ static int get_serial_info(struct async_struct * info,
1074 if (!retinfo) 1075 if (!retinfo)
1075 return -EFAULT; 1076 return -EFAULT;
1076 memset(&tmp, 0, sizeof(tmp)); 1077 memset(&tmp, 0, sizeof(tmp));
1078 lock_kernel();
1077 tmp.type = state->type; 1079 tmp.type = state->type;
1078 tmp.line = state->line; 1080 tmp.line = state->line;
1079 tmp.port = state->port; 1081 tmp.port = state->port;
@@ -1084,6 +1086,7 @@ static int get_serial_info(struct async_struct * info,
1084 tmp.close_delay = state->close_delay; 1086 tmp.close_delay = state->close_delay;
1085 tmp.closing_wait = state->closing_wait; 1087 tmp.closing_wait = state->closing_wait;
1086 tmp.custom_divisor = state->custom_divisor; 1088 tmp.custom_divisor = state->custom_divisor;
1089 unlock_kernel();
1087 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1090 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
1088 return -EFAULT; 1091 return -EFAULT;
1089 return 0; 1092 return 0;
@@ -1099,13 +1102,17 @@ static int set_serial_info(struct async_struct * info,
1099 1102
1100 if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1103 if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
1101 return -EFAULT; 1104 return -EFAULT;
1105
1106 lock_kernel();
1102 state = info->state; 1107 state = info->state;
1103 old_state = *state; 1108 old_state = *state;
1104 1109
1105 change_irq = new_serial.irq != state->irq; 1110 change_irq = new_serial.irq != state->irq;
1106 change_port = (new_serial.port != state->port); 1111 change_port = (new_serial.port != state->port);
1107 if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) 1112 if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) {
1113 unlock_kernel();
1108 return -EINVAL; 1114 return -EINVAL;
1115 }
1109 1116
1110 if (!serial_isroot()) { 1117 if (!serial_isroot()) {
1111 if ((new_serial.baud_base != state->baud_base) || 1118 if ((new_serial.baud_base != state->baud_base) ||
@@ -1122,8 +1129,10 @@ static int set_serial_info(struct async_struct * info,
1122 goto check_and_exit; 1129 goto check_and_exit;
1123 } 1130 }
1124 1131
1125 if (new_serial.baud_base < 9600) 1132 if (new_serial.baud_base < 9600) {
1133 unlock_kernel();
1126 return -EINVAL; 1134 return -EINVAL;
1135 }
1127 1136
1128 /* 1137 /*
1129 * OK, past this point, all the error checking has been done. 1138 * OK, past this point, all the error checking has been done.
@@ -1157,6 +1166,7 @@ check_and_exit:
1157 } 1166 }
1158 } else 1167 } else
1159 retval = startup(info); 1168 retval = startup(info);
1169 unlock_kernel();
1160 return retval; 1170 return retval;
1161} 1171}
1162 1172
@@ -1496,8 +1506,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1496 rs_wait_until_sent(tty, info->timeout); 1506 rs_wait_until_sent(tty, info->timeout);
1497 } 1507 }
1498 shutdown(info); 1508 shutdown(info);
1499 if (tty->driver->flush_buffer) 1509 rs_flush_buffer(tty);
1500 tty->driver->flush_buffer(tty);
1501 1510
1502 tty_ldisc_flush(tty); 1511 tty_ldisc_flush(tty);
1503 tty->closing = 0; 1512 tty->closing = 0;
@@ -1530,6 +1539,8 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1530 return; /* Just in case.... */ 1539 return; /* Just in case.... */
1531 1540
1532 orig_jiffies = jiffies; 1541 orig_jiffies = jiffies;
1542
1543 lock_kernel();
1533 /* 1544 /*
1534 * Set the check interval to be 1/5 of the estimated time to 1545 * Set the check interval to be 1/5 of the estimated time to
1535 * send a single character, and make it at least 1. The check 1546 * send a single character, and make it at least 1. The check
@@ -1570,6 +1581,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1570 break; 1581 break;
1571 } 1582 }
1572 __set_current_state(TASK_RUNNING); 1583 __set_current_state(TASK_RUNNING);
1584 unlock_kernel();
1573#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1585#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1574 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 1586 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
1575#endif 1587#endif
diff --git a/drivers/char/applicom.c b/drivers/char/applicom.c
index a7c4990b5b6b..31d08b641f5b 100644
--- a/drivers/char/applicom.c
+++ b/drivers/char/applicom.c
@@ -199,7 +199,7 @@ static int __init applicom_init(void)
199 if (pci_enable_device(dev)) 199 if (pci_enable_device(dev))
200 return -EIO; 200 return -EIO;
201 201
202 RamIO = ioremap(pci_resource_start(dev, 0), LEN_RAM_IO); 202 RamIO = ioremap_nocache(pci_resource_start(dev, 0), LEN_RAM_IO);
203 203
204 if (!RamIO) { 204 if (!RamIO) {
205 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory " 205 printk(KERN_INFO "ac.o: Failed to ioremap PCI memory "
@@ -254,7 +254,7 @@ static int __init applicom_init(void)
254 /* Now try the specified ISA cards */ 254 /* Now try the specified ISA cards */
255 255
256 for (i = 0; i < MAX_ISA_BOARD; i++) { 256 for (i = 0; i < MAX_ISA_BOARD; i++) {
257 RamIO = ioremap(mem + (LEN_RAM_IO * i), LEN_RAM_IO); 257 RamIO = ioremap_nocache(mem + (LEN_RAM_IO * i), LEN_RAM_IO);
258 258
259 if (!RamIO) { 259 if (!RamIO) {
260 printk(KERN_INFO "ac.o: Failed to ioremap the ISA card's memory space (slot #%d)\n", i + 1); 260 printk(KERN_INFO "ac.o: Failed to ioremap the ISA card's memory space (slot #%d)\n", i + 1);
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c
index 6b104e45a322..4246b8e36cb3 100644
--- a/drivers/char/consolemap.c
+++ b/drivers/char/consolemap.c
@@ -277,6 +277,7 @@ u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode)
277 return p->inverse_translations[m][glyph]; 277 return p->inverse_translations[m][glyph];
278 } 278 }
279} 279}
280EXPORT_SYMBOL_GPL(inverse_translate);
280 281
281static void update_user_maps(void) 282static void update_user_maps(void)
282{ 283{
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index e4f579c3e245..ef73e72daedc 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -21,7 +21,6 @@
21 * 21 *
22 * This version supports shared IRQ's (only for PCI boards). 22 * This version supports shared IRQ's (only for PCI boards).
23 * 23 *
24 * $Log: cyclades.c,v $
25 * Prevent users from opening non-existing Z ports. 24 * Prevent users from opening non-existing Z ports.
26 * 25 *
27 * Revision 2.3.2.8 2000/07/06 18:14:16 ivan 26 * Revision 2.3.2.8 2000/07/06 18:14:16 ivan
@@ -62,7 +61,7 @@
62 * Driver now makes sure that the constant SERIAL_XMIT_SIZE is defined; 61 * Driver now makes sure that the constant SERIAL_XMIT_SIZE is defined;
63 * 62 *
64 * Revision 2.3.2.2 1999/10/01 11:27:43 ivan 63 * Revision 2.3.2.2 1999/10/01 11:27:43 ivan
65 * Fixed bug in cyz_poll that would make all ports but port 0 64 * Fixed bug in cyz_poll that would make all ports but port 0
66 * unable to transmit/receive data (Cyclades-Z only); 65 * unable to transmit/receive data (Cyclades-Z only);
67 * Implemented logic to prevent the RX buffer from being stuck with data 66 * Implemented logic to prevent the RX buffer from being stuck with data
68 * due to a driver / firmware race condition in interrupt op mode 67 * due to a driver / firmware race condition in interrupt op mode
@@ -83,25 +82,25 @@
83 * Revision 2.3.1.1 1999/07/15 16:45:53 ivan 82 * Revision 2.3.1.1 1999/07/15 16:45:53 ivan
84 * Removed CY_PROC conditional compilation; 83 * Removed CY_PROC conditional compilation;
85 * Implemented SMP-awareness for the driver; 84 * Implemented SMP-awareness for the driver;
86 * Implemented a new ISA IRQ autoprobe that uses the irq_probe_[on|off] 85 * Implemented a new ISA IRQ autoprobe that uses the irq_probe_[on|off]
87 * functions; 86 * functions;
88 * The driver now accepts memory addresses (maddr=0xMMMMM) and IRQs 87 * The driver now accepts memory addresses (maddr=0xMMMMM) and IRQs
89 * (irq=NN) as parameters (only for ISA boards); 88 * (irq=NN) as parameters (only for ISA boards);
90 * Fixed bug in set_line_char that would prevent the Cyclades-Z 89 * Fixed bug in set_line_char that would prevent the Cyclades-Z
91 * ports from being configured at speeds above 115.2Kbps; 90 * ports from being configured at speeds above 115.2Kbps;
92 * Fixed bug in cy_set_termios that would prevent XON/XOFF flow control 91 * Fixed bug in cy_set_termios that would prevent XON/XOFF flow control
93 * switching from working properly; 92 * switching from working properly;
94 * The driver now only prints IRQ info for the Cyclades-Z if it's 93 * The driver now only prints IRQ info for the Cyclades-Z if it's
95 * configured to work in interrupt mode; 94 * configured to work in interrupt mode;
96 * 95 *
97 * Revision 2.2.2.3 1999/06/28 11:13:29 ivan 96 * Revision 2.2.2.3 1999/06/28 11:13:29 ivan
98 * Added support for interrupt mode operation for the Z cards; 97 * Added support for interrupt mode operation for the Z cards;
99 * Removed the driver inactivity control for the Z; 98 * Removed the driver inactivity control for the Z;
100 * Added a missing MOD_DEC_USE_COUNT in the cy_open function for when 99 * Added a missing MOD_DEC_USE_COUNT in the cy_open function for when
101 * the Z firmware is not loaded yet; 100 * the Z firmware is not loaded yet;
102 * Replaced the "manual" Z Tx flush buffer by a call to a FW command of 101 * Replaced the "manual" Z Tx flush buffer by a call to a FW command of
103 * same functionality; 102 * same functionality;
104 * Implemented workaround for IRQ setting loss on the PCI configuration 103 * Implemented workaround for IRQ setting loss on the PCI configuration
105 * registers after a PCI bridge EEPROM reload (affects PLX9060 only); 104 * registers after a PCI bridge EEPROM reload (affects PLX9060 only);
106 * 105 *
107 * Revision 2.2.2.2 1999/05/14 17:18:15 ivan 106 * Revision 2.2.2.2 1999/05/14 17:18:15 ivan
@@ -112,22 +111,22 @@
112 * BREAK implementation changed in order to make use of the 'break_ctl' 111 * BREAK implementation changed in order to make use of the 'break_ctl'
113 * TTY facility; 112 * TTY facility;
114 * Fixed typo in TTY structure field 'driver_name'; 113 * Fixed typo in TTY structure field 'driver_name';
115 * Included a PCI bridge reset and EEPROM reload in the board 114 * Included a PCI bridge reset and EEPROM reload in the board
116 * initialization code (for both Y and Z series). 115 * initialization code (for both Y and Z series).
117 * 116 *
118 * Revision 2.2.2.1 1999/04/08 16:17:43 ivan 117 * Revision 2.2.2.1 1999/04/08 16:17:43 ivan
119 * Fixed a bug in cy_wait_until_sent that was preventing the port to be 118 * Fixed a bug in cy_wait_until_sent that was preventing the port to be
120 * closed properly after a SIGINT; 119 * closed properly after a SIGINT;
121 * Module usage counter scheme revisited; 120 * Module usage counter scheme revisited;
122 * Added support to the upcoming Y PCI boards (i.e., support to additional 121 * Added support to the upcoming Y PCI boards (i.e., support to additional
123 * PCI Device ID's). 122 * PCI Device ID's).
124 * 123 *
125 * Revision 2.2.1.10 1999/01/20 16:14:29 ivan 124 * Revision 2.2.1.10 1999/01/20 16:14:29 ivan
126 * Removed all unnecessary page-alignement operations in ioremap calls 125 * Removed all unnecessary page-alignement operations in ioremap calls
127 * (ioremap is currently safe for these operations). 126 * (ioremap is currently safe for these operations).
128 * 127 *
129 * Revision 2.2.1.9 1998/12/30 18:18:30 ivan 128 * Revision 2.2.1.9 1998/12/30 18:18:30 ivan
130 * Changed access to PLX PCI bridge registers from I/O to MMIO, in 129 * Changed access to PLX PCI bridge registers from I/O to MMIO, in
131 * order to make PLX9050-based boards work with certain motherboards. 130 * order to make PLX9050-based boards work with certain motherboards.
132 * 131 *
133 * Revision 2.2.1.8 1998/11/13 12:46:20 ivan 132 * Revision 2.2.1.8 1998/11/13 12:46:20 ivan
@@ -148,7 +147,7 @@
148 * Fixed Cyclom-4Yo hardware detection bug. 147 * Fixed Cyclom-4Yo hardware detection bug.
149 * 148 *
150 * Revision 2.2.1.4 1998/08/04 11:02:50 ivan 149 * Revision 2.2.1.4 1998/08/04 11:02:50 ivan
151 * /proc/cyclades implementation with great collaboration of 150 * /proc/cyclades implementation with great collaboration of
152 * Marc Lewis <marc@blarg.net>; 151 * Marc Lewis <marc@blarg.net>;
153 * cyy_interrupt was changed to avoid occurrence of kernel oopses 152 * cyy_interrupt was changed to avoid occurrence of kernel oopses
154 * during PPP operation. 153 * during PPP operation.
@@ -157,7 +156,7 @@
157 * General code review in order to comply with 2.1 kernel standards; 156 * General code review in order to comply with 2.1 kernel standards;
158 * data loss prevention for slow devices revisited (cy_wait_until_sent 157 * data loss prevention for slow devices revisited (cy_wait_until_sent
159 * was created); 158 * was created);
160 * removed conditional compilation for new/old PCI structure support 159 * removed conditional compilation for new/old PCI structure support
161 * (now the driver only supports the new PCI structure). 160 * (now the driver only supports the new PCI structure).
162 * 161 *
163 * Revision 2.2.1.1 1998/03/19 16:43:12 ivan 162 * Revision 2.2.1.1 1998/03/19 16:43:12 ivan
@@ -168,7 +167,7 @@
168 * cleaned up the data loss fix; 167 * cleaned up the data loss fix;
169 * fixed XON/XOFF handling once more (Cyclades-Z); 168 * fixed XON/XOFF handling once more (Cyclades-Z);
170 * general review of the driver routines; 169 * general review of the driver routines;
171 * introduction of a mechanism to prevent data loss with slow 170 * introduction of a mechanism to prevent data loss with slow
172 * printers, by forcing a delay before closing the port. 171 * printers, by forcing a delay before closing the port.
173 * 172 *
174 * Revision 2.1.1.2 1998/02/17 16:50:00 ivan 173 * Revision 2.1.1.2 1998/02/17 16:50:00 ivan
@@ -182,12 +181,12 @@
182 * Code review for the module cleanup routine; 181 * Code review for the module cleanup routine;
183 * fixed RTS and DTR status report for new CD1400's in get_modem_info; 182 * fixed RTS and DTR status report for new CD1400's in get_modem_info;
184 * includes anonymous changes regarding signal_pending. 183 * includes anonymous changes regarding signal_pending.
185 * 184 *
186 * Revision 2.1 1997/11/01 17:42:41 ivan 185 * Revision 2.1 1997/11/01 17:42:41 ivan
187 * Changes in the driver to support Alpha systems (except 8Zo V_1); 186 * Changes in the driver to support Alpha systems (except 8Zo V_1);
188 * BREAK fix for the Cyclades-Z boards; 187 * BREAK fix for the Cyclades-Z boards;
189 * driver inactivity control by FW implemented; 188 * driver inactivity control by FW implemented;
190 * introduction of flag that allows driver to take advantage of 189 * introduction of flag that allows driver to take advantage of
191 * a special CD1400 feature related to HW flow control; 190 * a special CD1400 feature related to HW flow control;
192 * added support for the CD1400 rev. J (Cyclom-Y boards); 191 * added support for the CD1400 rev. J (Cyclom-Y boards);
193 * introduction of ioctls to: 192 * introduction of ioctls to:
@@ -196,17 +195,17 @@
196 * - adjust the polling interval (Cyclades-Z); 195 * - adjust the polling interval (Cyclades-Z);
197 * 196 *
198 * Revision 1.36.4.33 1997/06/27 19:00:00 ivan 197 * Revision 1.36.4.33 1997/06/27 19:00:00 ivan
199 * Fixes related to kernel version conditional 198 * Fixes related to kernel version conditional
200 * compilation. 199 * compilation.
201 * 200 *
202 * Revision 1.36.4.32 1997/06/14 19:30:00 ivan 201 * Revision 1.36.4.32 1997/06/14 19:30:00 ivan
203 * Compatibility issues between kernels 2.0.x and 202 * Compatibility issues between kernels 2.0.x and
204 * 2.1.x (mainly related to clear_bit function). 203 * 2.1.x (mainly related to clear_bit function).
205 * 204 *
206 * Revision 1.36.4.31 1997/06/03 15:30:00 ivan 205 * Revision 1.36.4.31 1997/06/03 15:30:00 ivan
207 * Changes to define the memory window according to the 206 * Changes to define the memory window according to the
208 * board type. 207 * board type.
209 * 208 *
210 * Revision 1.36.4.30 1997/05/16 15:30:00 daniel 209 * Revision 1.36.4.30 1997/05/16 15:30:00 daniel
211 * Changes to support new cycladesZ boards. 210 * Changes to support new cycladesZ boards.
212 * 211 *
@@ -624,7 +623,7 @@
624#undef CY_PCI_DEBUG 623#undef CY_PCI_DEBUG
625 624
626/* 625/*
627 * Include section 626 * Include section
628 */ 627 */
629#include <linux/module.h> 628#include <linux/module.h>
630#include <linux/errno.h> 629#include <linux/errno.h>
@@ -649,9 +648,9 @@
649#include <linux/firmware.h> 648#include <linux/firmware.h>
650 649
651#include <asm/system.h> 650#include <asm/system.h>
652#include <asm/io.h> 651#include <linux/io.h>
653#include <asm/irq.h> 652#include <asm/irq.h>
654#include <asm/uaccess.h> 653#include <linux/uaccess.h>
655 654
656#include <linux/kernel.h> 655#include <linux/kernel.h>
657#include <linux/pci.h> 656#include <linux/pci.h>
@@ -668,10 +667,10 @@ static void cy_send_xchar(struct tty_struct *tty, char ch);
668 ((readl(&((struct RUNTIME_9060 __iomem *) \ 667 ((readl(&((struct RUNTIME_9060 __iomem *) \
669 ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) 668 ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
670 669
671#define ISZLOADED(card) (((ZO_V1==readl(&((struct RUNTIME_9060 __iomem *) \ 670#define ISZLOADED(card) (((ZO_V1 == readl(&((struct RUNTIME_9060 __iomem *) \
672 ((card).ctl_addr))->mail_box_0)) || \ 671 ((card).ctl_addr))->mail_box_0)) || \
673 Z_FPGA_CHECK(card)) && \ 672 Z_FPGA_CHECK(card)) && \
674 (ZFIRM_ID==readl(&((struct FIRM_ID __iomem *) \ 673 (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \
675 ((card).base_addr+ID_ADDRESS))->signature))) 674 ((card).base_addr+ID_ADDRESS))->signature)))
676 675
677#ifndef SERIAL_XMIT_SIZE 676#ifndef SERIAL_XMIT_SIZE
@@ -809,12 +808,12 @@ static char baud_cor3[] = { /* receive threshold */
809 808
810/* 809/*
811 * The Cyclades driver implements HW flow control as any serial driver. 810 * The Cyclades driver implements HW flow control as any serial driver.
812 * The cyclades_port structure member rflow and the vector rflow_thr 811 * The cyclades_port structure member rflow and the vector rflow_thr
813 * allows us to take advantage of a special feature in the CD1400 to avoid 812 * allows us to take advantage of a special feature in the CD1400 to avoid
814 * data loss even when the system interrupt latency is too high. These flags 813 * data loss even when the system interrupt latency is too high. These flags
815 * are to be used only with very special applications. Setting these flags 814 * are to be used only with very special applications. Setting these flags
816 * requires the use of a special cable (DTR and RTS reversed). In the new 815 * requires the use of a special cable (DTR and RTS reversed). In the new
817 * CD1400-based boards (rev. 6.00 or later), there is no need for special 816 * CD1400-based boards (rev. 6.00 or later), there is no need for special
818 * cables. 817 * cables.
819 */ 818 */
820 819
@@ -841,14 +840,22 @@ static int cy_chip_offset[] = { 0x0000,
841 840
842#ifdef CONFIG_PCI 841#ifdef CONFIG_PCI
843static struct pci_device_id cy_pci_dev_id[] __devinitdata = { 842static struct pci_device_id cy_pci_dev_id[] __devinitdata = {
844 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) }, /* PCI < 1Mb */ 843 /* PCI < 1Mb */
845 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Hi) }, /* PCI > 1Mb */ 844 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Lo) },
846 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Lo) }, /* 4Y PCI < 1Mb */ 845 /* PCI > 1Mb */
847 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Hi) }, /* 4Y PCI > 1Mb */ 846 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Y_Hi) },
848 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Lo) }, /* 8Y PCI < 1Mb */ 847 /* 4Y PCI < 1Mb */
849 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Hi) }, /* 8Y PCI > 1Mb */ 848 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Lo) },
850 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Lo) }, /* Z PCI < 1Mb */ 849 /* 4Y PCI > 1Mb */
851 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Hi) }, /* Z PCI > 1Mb */ 850 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_4Y_Hi) },
851 /* 8Y PCI < 1Mb */
852 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Lo) },
853 /* 8Y PCI > 1Mb */
854 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_8Y_Hi) },
855 /* Z PCI < 1Mb */
856 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Lo) },
857 /* Z PCI > 1Mb */
858 { PCI_DEVICE(PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_CYCLOM_Z_Hi) },
852 { } /* end of table */ 859 { } /* end of table */
853}; 860};
854MODULE_DEVICE_TABLE(pci, cy_pci_dev_id); 861MODULE_DEVICE_TABLE(pci, cy_pci_dev_id);
@@ -905,15 +912,14 @@ static inline int serial_paranoia_check(struct cyclades_port *info,
905 912
906 This function is only called from inside spinlock-protected code. 913 This function is only called from inside spinlock-protected code.
907 */ 914 */
908static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index) 915static int cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index)
909{ 916{
910 unsigned int i; 917 unsigned int i;
911 918
912 /* Check to see that the previous command has completed */ 919 /* Check to see that the previous command has completed */
913 for (i = 0; i < 100; i++) { 920 for (i = 0; i < 100; i++) {
914 if (readb(base_addr + (CyCCR << index)) == 0) { 921 if (readb(base_addr + (CyCCR << index)) == 0)
915 break; 922 break;
916 }
917 udelay(10L); 923 udelay(10L);
918 } 924 }
919 /* if the CCR never cleared, the previous command 925 /* if the CCR never cleared, the previous command
@@ -929,7 +935,7 @@ static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index)
929 935
930#ifdef CONFIG_ISA 936#ifdef CONFIG_ISA
931/* ISA interrupt detection code */ 937/* ISA interrupt detection code */
932static unsigned detect_isa_irq(void __iomem * address) 938static unsigned detect_isa_irq(void __iomem *address)
933{ 939{
934 int irq; 940 int irq;
935 unsigned long irqs, flags; 941 unsigned long irqs, flags;
@@ -1038,7 +1044,7 @@ static void cyy_chip_rx(struct cyclades_card *cinfo, int chip,
1038 if (info->flags & ASYNC_SAK) 1044 if (info->flags & ASYNC_SAK)
1039 do_SAK(tty); 1045 do_SAK(tty);
1040 } else if (data & CyFRAME) { 1046 } else if (data & CyFRAME) {
1041 tty_insert_flip_char( tty, 1047 tty_insert_flip_char(tty,
1042 readb(base_addr + (CyRDSR << 1048 readb(base_addr + (CyRDSR <<
1043 index)), TTY_FRAME); 1049 index)), TTY_FRAME);
1044 info->icount.rx++; 1050 info->icount.rx++;
@@ -1320,7 +1326,8 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1320 1326
1321 if (unlikely(cinfo == NULL)) { 1327 if (unlikely(cinfo == NULL)) {
1322#ifdef CY_DEBUG_INTERRUPTS 1328#ifdef CY_DEBUG_INTERRUPTS
1323 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",irq); 1329 printk(KERN_DEBUG "cyy_interrupt: spurious interrupt %d\n",
1330 irq);
1324#endif 1331#endif
1325 return IRQ_NONE; /* spurious interrupt */ 1332 return IRQ_NONE; /* spurious interrupt */
1326 } 1333 }
@@ -1375,12 +1382,12 @@ static irqreturn_t cyy_interrupt(int irq, void *dev_id)
1375 1382
1376/***********************************************************/ 1383/***********************************************************/
1377/********* End of block of Cyclom-Y specific code **********/ 1384/********* End of block of Cyclom-Y specific code **********/
1378/******** Start of block of Cyclades-Z specific code *********/ 1385/******** Start of block of Cyclades-Z specific code *******/
1379/***********************************************************/ 1386/***********************************************************/
1380 1387
1381static int 1388static int
1382cyz_fetch_msg(struct cyclades_card *cinfo, 1389cyz_fetch_msg(struct cyclades_card *cinfo,
1383 __u32 * channel, __u8 * cmd, __u32 * param) 1390 __u32 *channel, __u8 *cmd, __u32 *param)
1384{ 1391{
1385 struct FIRM_ID __iomem *firm_id; 1392 struct FIRM_ID __iomem *firm_id;
1386 struct ZFW_CTRL __iomem *zfw_ctrl; 1393 struct ZFW_CTRL __iomem *zfw_ctrl;
@@ -1388,9 +1395,8 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
1388 unsigned long loc_doorbell; 1395 unsigned long loc_doorbell;
1389 1396
1390 firm_id = cinfo->base_addr + ID_ADDRESS; 1397 firm_id = cinfo->base_addr + ID_ADDRESS;
1391 if (!ISZLOADED(*cinfo)) { 1398 if (!ISZLOADED(*cinfo))
1392 return -1; 1399 return -1;
1393 }
1394 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1400 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1395 board_ctrl = &zfw_ctrl->board_ctrl; 1401 board_ctrl = &zfw_ctrl->board_ctrl;
1396 1402
@@ -1418,9 +1424,9 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1418 unsigned int index; 1424 unsigned int index;
1419 1425
1420 firm_id = cinfo->base_addr + ID_ADDRESS; 1426 firm_id = cinfo->base_addr + ID_ADDRESS;
1421 if (!ISZLOADED(*cinfo)) { 1427 if (!ISZLOADED(*cinfo))
1422 return -1; 1428 return -1;
1423 } 1429
1424 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1430 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1425 board_ctrl = &zfw_ctrl->board_ctrl; 1431 board_ctrl = &zfw_ctrl->board_ctrl;
1426 1432
@@ -1428,9 +1434,8 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1428 pci_doorbell = 1434 pci_doorbell =
1429 &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell; 1435 &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
1430 while ((readl(pci_doorbell) & 0xff) != 0) { 1436 while ((readl(pci_doorbell) & 0xff) != 0) {
1431 if (index++ == 1000) { 1437 if (index++ == 1000)
1432 return (int)(readl(pci_doorbell) & 0xff); 1438 return (int)(readl(pci_doorbell) & 0xff);
1433 }
1434 udelay(50L); 1439 udelay(50L);
1435 } 1440 }
1436 cy_writel(&board_ctrl->hcmd_channel, channel); 1441 cy_writel(&board_ctrl->hcmd_channel, channel);
@@ -1504,7 +1509,8 @@ static void cyz_handle_rx(struct cyclades_port *info,
1504 while (len--) { 1509 while (len--) {
1505 data = readb(cinfo->base_addr + rx_bufaddr + 1510 data = readb(cinfo->base_addr + rx_bufaddr +
1506 new_rx_get); 1511 new_rx_get);
1507 new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1); 1512 new_rx_get = (new_rx_get + 1) &
1513 (rx_bufsize - 1);
1508 tty_insert_flip_char(tty, data, TTY_NORMAL); 1514 tty_insert_flip_char(tty, data, TTY_NORMAL);
1509 info->idle_stats.recv_bytes++; 1515 info->idle_stats.recv_bytes++;
1510 info->icount.rx++; 1516 info->icount.rx++;
@@ -1636,7 +1642,8 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1636 special_count = 0; 1642 special_count = 0;
1637 delta_count = 0; 1643 delta_count = 0;
1638 info = &cinfo->ports[channel]; 1644 info = &cinfo->ports[channel];
1639 if ((tty = info->tty) == NULL) 1645 tty = info->tty;
1646 if (tty == NULL)
1640 continue; 1647 continue;
1641 1648
1642 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); 1649 ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]);
@@ -1732,7 +1739,8 @@ static irqreturn_t cyz_interrupt(int irq, void *dev_id)
1732 1739
1733 if (unlikely(cinfo == NULL)) { 1740 if (unlikely(cinfo == NULL)) {
1734#ifdef CY_DEBUG_INTERRUPTS 1741#ifdef CY_DEBUG_INTERRUPTS
1735 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",irq); 1742 printk(KERN_DEBUG "cyz_interrupt: spurious interrupt %d\n",
1743 irq);
1736#endif 1744#endif
1737 return IRQ_NONE; /* spurious interrupt */ 1745 return IRQ_NONE; /* spurious interrupt */
1738 } 1746 }
@@ -1851,9 +1859,8 @@ static int startup(struct cyclades_port *info)
1851 } 1859 }
1852 1860
1853 if (!info->type) { 1861 if (!info->type) {
1854 if (info->tty) { 1862 if (info->tty)
1855 set_bit(TTY_IO_ERROR, &info->tty->flags); 1863 set_bit(TTY_IO_ERROR, &info->tty->flags);
1856 }
1857 free_page(page); 1864 free_page(page);
1858 goto errout; 1865 goto errout;
1859 } 1866 }
@@ -1904,9 +1911,8 @@ static int startup(struct cyclades_port *info)
1904 readb(base_addr + (CySRER << index)) | CyRxData); 1911 readb(base_addr + (CySRER << index)) | CyRxData);
1905 info->flags |= ASYNC_INITIALIZED; 1912 info->flags |= ASYNC_INITIALIZED;
1906 1913
1907 if (info->tty) { 1914 if (info->tty)
1908 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1915 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1909 }
1910 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 1916 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1911 info->breakon = info->breakoff = 0; 1917 info->breakon = info->breakoff = 0;
1912 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); 1918 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -1925,9 +1931,8 @@ static int startup(struct cyclades_port *info)
1925 base_addr = card->base_addr; 1931 base_addr = card->base_addr;
1926 1932
1927 firm_id = base_addr + ID_ADDRESS; 1933 firm_id = base_addr + ID_ADDRESS;
1928 if (!ISZLOADED(*card)) { 1934 if (!ISZLOADED(*card))
1929 return -ENODEV; 1935 return -ENODEV;
1930 }
1931 1936
1932 zfw_ctrl = card->base_addr + 1937 zfw_ctrl = card->base_addr +
1933 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1938 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -1990,9 +1995,8 @@ static int startup(struct cyclades_port *info)
1990 /* enable send, recv, modem !!! */ 1995 /* enable send, recv, modem !!! */
1991 1996
1992 info->flags |= ASYNC_INITIALIZED; 1997 info->flags |= ASYNC_INITIALIZED;
1993 if (info->tty) { 1998 if (info->tty)
1994 clear_bit(TTY_IO_ERROR, &info->tty->flags); 1999 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1995 }
1996 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 2000 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1997 info->breakon = info->breakoff = 0; 2001 info->breakon = info->breakoff = 0;
1998 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); 2002 memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
@@ -2061,9 +2065,8 @@ static void shutdown(struct cyclades_port *info)
2061 void __iomem *base_addr; 2065 void __iomem *base_addr;
2062 int chip, channel, index; 2066 int chip, channel, index;
2063 2067
2064 if (!(info->flags & ASYNC_INITIALIZED)) { 2068 if (!(info->flags & ASYNC_INITIALIZED))
2065 return; 2069 return;
2066 }
2067 2070
2068 card = info->card; 2071 card = info->card;
2069 channel = info->line - card->first_line; 2072 channel = info->line - card->first_line;
@@ -2105,9 +2108,8 @@ static void shutdown(struct cyclades_port *info)
2105 /* it may be appropriate to clear _XMIT at 2108 /* it may be appropriate to clear _XMIT at
2106 some later date (after testing)!!! */ 2109 some later date (after testing)!!! */
2107 2110
2108 if (info->tty) { 2111 if (info->tty)
2109 set_bit(TTY_IO_ERROR, &info->tty->flags); 2112 set_bit(TTY_IO_ERROR, &info->tty->flags);
2110 }
2111 info->flags &= ~ASYNC_INITIALIZED; 2113 info->flags &= ~ASYNC_INITIALIZED;
2112 spin_unlock_irqrestore(&card->card_lock, flags); 2114 spin_unlock_irqrestore(&card->card_lock, flags);
2113 } else { 2115 } else {
@@ -2124,9 +2126,8 @@ static void shutdown(struct cyclades_port *info)
2124#endif 2126#endif
2125 2127
2126 firm_id = base_addr + ID_ADDRESS; 2128 firm_id = base_addr + ID_ADDRESS;
2127 if (!ISZLOADED(*card)) { 2129 if (!ISZLOADED(*card))
2128 return; 2130 return;
2129 }
2130 2131
2131 zfw_ctrl = card->base_addr + 2132 zfw_ctrl = card->base_addr +
2132 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 2133 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -2157,9 +2158,8 @@ static void shutdown(struct cyclades_port *info)
2157#endif 2158#endif
2158 } 2159 }
2159 2160
2160 if (info->tty) { 2161 if (info->tty)
2161 set_bit(TTY_IO_ERROR, &info->tty->flags); 2162 set_bit(TTY_IO_ERROR, &info->tty->flags);
2162 }
2163 info->flags &= ~ASYNC_INITIALIZED; 2163 info->flags &= ~ASYNC_INITIALIZED;
2164 2164
2165 spin_unlock_irqrestore(&card->card_lock, flags); 2165 spin_unlock_irqrestore(&card->card_lock, flags);
@@ -2204,7 +2204,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2204 * If non-blocking mode is set, then make the check up front 2204 * If non-blocking mode is set, then make the check up front
2205 * and then exit. 2205 * and then exit.
2206 */ 2206 */
2207 if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { 2207 if ((filp->f_flags & O_NONBLOCK) ||
2208 (tty->flags & (1 << TTY_IO_ERROR))) {
2208 info->flags |= ASYNC_NORMAL_ACTIVE; 2209 info->flags |= ASYNC_NORMAL_ACTIVE;
2209 return 0; 2210 return 0;
2210 } 2211 }
@@ -2301,7 +2302,8 @@ block_til_ready(struct tty_struct *tty, struct file *filp,
2301 return -EINVAL; 2302 return -EINVAL;
2302 } 2303 }
2303 2304
2304 zfw_ctrl = base_addr + (readl(&firm_id->zfwctrl_addr)& 0xfffff); 2305 zfw_ctrl = base_addr + (readl(&firm_id->zfwctrl_addr)
2306 & 0xfffff);
2305 board_ctrl = &zfw_ctrl->board_ctrl; 2307 board_ctrl = &zfw_ctrl->board_ctrl;
2306 ch_ctrl = zfw_ctrl->ch_ctrl; 2308 ch_ctrl = zfw_ctrl->ch_ctrl;
2307 2309
@@ -2378,9 +2380,9 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2378 int retval; 2380 int retval;
2379 2381
2380 line = tty->index; 2382 line = tty->index;
2381 if ((tty->index < 0) || (NR_PORTS <= line)) { 2383 if (tty->index < 0 || NR_PORTS <= line)
2382 return -ENODEV; 2384 return -ENODEV;
2383 } 2385
2384 for (i = 0; i < NR_CARDS; i++) 2386 for (i = 0; i < NR_CARDS; i++)
2385 if (line < cy_card[i].first_line + cy_card[i].nports && 2387 if (line < cy_card[i].first_line + cy_card[i].nports &&
2386 line >= cy_card[i].first_line) 2388 line >= cy_card[i].first_line)
@@ -2388,9 +2390,8 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2388 if (i >= NR_CARDS) 2390 if (i >= NR_CARDS)
2389 return -ENODEV; 2391 return -ENODEV;
2390 info = &cy_card[i].ports[line - cy_card[i].first_line]; 2392 info = &cy_card[i].ports[line - cy_card[i].first_line];
2391 if (info->line < 0) { 2393 if (info->line < 0)
2392 return -ENODEV; 2394 return -ENODEV;
2393 }
2394 2395
2395 /* If the card's firmware hasn't been loaded, 2396 /* If the card's firmware hasn't been loaded,
2396 treat it as absent from the system. This 2397 treat it as absent from the system. This
@@ -2456,9 +2457,9 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2456#endif 2457#endif
2457 tty->driver_data = info; 2458 tty->driver_data = info;
2458 info->tty = tty; 2459 info->tty = tty;
2459 if (serial_paranoia_check(info, tty->name, "cy_open")) { 2460 if (serial_paranoia_check(info, tty->name, "cy_open"))
2460 return -ENODEV; 2461 return -ENODEV;
2461 } 2462
2462#ifdef CY_DEBUG_OPEN 2463#ifdef CY_DEBUG_OPEN
2463 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line, 2464 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
2464 info->count); 2465 info->count);
@@ -2482,9 +2483,8 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2482 * Start up serial port 2483 * Start up serial port
2483 */ 2484 */
2484 retval = startup(info); 2485 retval = startup(info);
2485 if (retval) { 2486 if (retval)
2486 return retval; 2487 return retval;
2487 }
2488 2488
2489 retval = block_til_ready(tty, filp, info); 2489 retval = block_til_ready(tty, filp, info);
2490 if (retval) { 2490 if (retval) {
@@ -2522,6 +2522,7 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
2522 return; /* Just in case.... */ 2522 return; /* Just in case.... */
2523 2523
2524 orig_jiffies = jiffies; 2524 orig_jiffies = jiffies;
2525 lock_kernel();
2525 /* 2526 /*
2526 * Set the check interval to be 1/5 of the estimated time to 2527 * Set the check interval to be 1/5 of the estimated time to
2527 * send a single character, and make it at least 1. The check 2528 * send a single character, and make it at least 1. The check
@@ -2573,11 +2574,47 @@ static void cy_wait_until_sent(struct tty_struct *tty, int timeout)
2573 } 2574 }
2574 /* Run one more char cycle */ 2575 /* Run one more char cycle */
2575 msleep_interruptible(jiffies_to_msecs(char_time * 5)); 2576 msleep_interruptible(jiffies_to_msecs(char_time * 5));
2577 unlock_kernel();
2576#ifdef CY_DEBUG_WAIT_UNTIL_SENT 2578#ifdef CY_DEBUG_WAIT_UNTIL_SENT
2577 printk(KERN_DEBUG "Clean (jiff=%lu)...done\n", jiffies); 2579 printk(KERN_DEBUG "Clean (jiff=%lu)...done\n", jiffies);
2578#endif 2580#endif
2579} 2581}
2580 2582
2583static void cy_flush_buffer(struct tty_struct *tty)
2584{
2585 struct cyclades_port *info = tty->driver_data;
2586 struct cyclades_card *card;
2587 int channel, retval;
2588 unsigned long flags;
2589
2590#ifdef CY_DEBUG_IO
2591 printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line);
2592#endif
2593
2594 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
2595 return;
2596
2597 card = info->card;
2598 channel = info->line - card->first_line;
2599
2600 spin_lock_irqsave(&card->card_lock, flags);
2601 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
2602 spin_unlock_irqrestore(&card->card_lock, flags);
2603
2604 if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
2605 buffers as well */
2606 spin_lock_irqsave(&card->card_lock, flags);
2607 retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
2608 if (retval != 0) {
2609 printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d "
2610 "was %x\n", info->line, retval);
2611 }
2612 spin_unlock_irqrestore(&card->card_lock, flags);
2613 }
2614 tty_wakeup(tty);
2615} /* cy_flush_buffer */
2616
2617
2581/* 2618/*
2582 * This routine is called when a particular tty device is closed. 2619 * This routine is called when a particular tty device is closed.
2583 */ 2620 */
@@ -2591,9 +2628,8 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2591 printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line); 2628 printk(KERN_DEBUG "cyc:cy_close ttyC%d\n", info->line);
2592#endif 2629#endif
2593 2630
2594 if (!info || serial_paranoia_check(info, tty->name, "cy_close")) { 2631 if (!info || serial_paranoia_check(info, tty->name, "cy_close"))
2595 return; 2632 return;
2596 }
2597 2633
2598 card = info->card; 2634 card = info->card;
2599 2635
@@ -2641,9 +2677,9 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2641 */ 2677 */
2642 tty->closing = 1; 2678 tty->closing = 1;
2643 spin_unlock_irqrestore(&card->card_lock, flags); 2679 spin_unlock_irqrestore(&card->card_lock, flags);
2644 if (info->closing_wait != CY_CLOSING_WAIT_NONE) { 2680 if (info->closing_wait != CY_CLOSING_WAIT_NONE)
2645 tty_wait_until_sent(tty, info->closing_wait); 2681 tty_wait_until_sent(tty, info->closing_wait);
2646 } 2682
2647 spin_lock_irqsave(&card->card_lock, flags); 2683 spin_lock_irqsave(&card->card_lock, flags);
2648 2684
2649 if (!IS_CYC_Z(*card)) { 2685 if (!IS_CYC_Z(*card)) {
@@ -2657,15 +2693,16 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2657 cy_writeb(base_addr + (CySRER << index), 2693 cy_writeb(base_addr + (CySRER << index),
2658 readb(base_addr + (CySRER << index)) & ~CyRxData); 2694 readb(base_addr + (CySRER << index)) & ~CyRxData);
2659 if (info->flags & ASYNC_INITIALIZED) { 2695 if (info->flags & ASYNC_INITIALIZED) {
2660 /* Waiting for on-board buffers to be empty before closing 2696 /* Waiting for on-board buffers to be empty before
2661 the port */ 2697 closing the port */
2662 spin_unlock_irqrestore(&card->card_lock, flags); 2698 spin_unlock_irqrestore(&card->card_lock, flags);
2663 cy_wait_until_sent(tty, info->timeout); 2699 cy_wait_until_sent(tty, info->timeout);
2664 spin_lock_irqsave(&card->card_lock, flags); 2700 spin_lock_irqsave(&card->card_lock, flags);
2665 } 2701 }
2666 } else { 2702 } else {
2667#ifdef Z_WAKE 2703#ifdef Z_WAKE
2668 /* Waiting for on-board buffers to be empty before closing the port */ 2704 /* Waiting for on-board buffers to be empty before closing
2705 the port */
2669 void __iomem *base_addr = card->base_addr; 2706 void __iomem *base_addr = card->base_addr;
2670 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; 2707 struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS;
2671 struct ZFW_CTRL __iomem *zfw_ctrl = 2708 struct ZFW_CTRL __iomem *zfw_ctrl =
@@ -2689,8 +2726,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
2689 2726
2690 spin_unlock_irqrestore(&card->card_lock, flags); 2727 spin_unlock_irqrestore(&card->card_lock, flags);
2691 shutdown(info); 2728 shutdown(info);
2692 if (tty->driver->flush_buffer) 2729 cy_flush_buffer(tty);
2693 tty->driver->flush_buffer(tty);
2694 tty_ldisc_flush(tty); 2730 tty_ldisc_flush(tty);
2695 spin_lock_irqsave(&card->card_lock, flags); 2731 spin_lock_irqsave(&card->card_lock, flags);
2696 2732
@@ -2738,17 +2774,16 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2738 printk(KERN_DEBUG "cyc:cy_write ttyC%d\n", info->line); 2774 printk(KERN_DEBUG "cyc:cy_write ttyC%d\n", info->line);
2739#endif 2775#endif
2740 2776
2741 if (serial_paranoia_check(info, tty->name, "cy_write")) { 2777 if (serial_paranoia_check(info, tty->name, "cy_write"))
2742 return 0; 2778 return 0;
2743 }
2744 2779
2745 if (!info->xmit_buf) 2780 if (!info->xmit_buf)
2746 return 0; 2781 return 0;
2747 2782
2748 spin_lock_irqsave(&info->card->card_lock, flags); 2783 spin_lock_irqsave(&info->card->card_lock, flags);
2749 while (1) { 2784 while (1) {
2750 c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1), 2785 c = min(count, (int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1));
2751 (int)(SERIAL_XMIT_SIZE - info->xmit_head))); 2786 c = min(c, (int)(SERIAL_XMIT_SIZE - info->xmit_head));
2752 2787
2753 if (c <= 0) 2788 if (c <= 0)
2754 break; 2789 break;
@@ -2766,9 +2801,9 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2766 info->idle_stats.xmit_bytes += ret; 2801 info->idle_stats.xmit_bytes += ret;
2767 info->idle_stats.xmit_idle = jiffies; 2802 info->idle_stats.xmit_idle = jiffies;
2768 2803
2769 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { 2804 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped)
2770 start_xmit(info); 2805 start_xmit(info);
2771 } 2806
2772 return ret; 2807 return ret;
2773} /* cy_write */ 2808} /* cy_write */
2774 2809
@@ -2779,7 +2814,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count)
2779 * done stuffing characters into the driver. If there is no room 2814 * done stuffing characters into the driver. If there is no room
2780 * in the queue, the character is ignored. 2815 * in the queue, the character is ignored.
2781 */ 2816 */
2782static void cy_put_char(struct tty_struct *tty, unsigned char ch) 2817static int cy_put_char(struct tty_struct *tty, unsigned char ch)
2783{ 2818{
2784 struct cyclades_port *info = tty->driver_data; 2819 struct cyclades_port *info = tty->driver_data;
2785 unsigned long flags; 2820 unsigned long flags;
@@ -2789,15 +2824,15 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
2789#endif 2824#endif
2790 2825
2791 if (serial_paranoia_check(info, tty->name, "cy_put_char")) 2826 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
2792 return; 2827 return 0;
2793 2828
2794 if (!info->xmit_buf) 2829 if (!info->xmit_buf)
2795 return; 2830 return 0;
2796 2831
2797 spin_lock_irqsave(&info->card->card_lock, flags); 2832 spin_lock_irqsave(&info->card->card_lock, flags);
2798 if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) { 2833 if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) {
2799 spin_unlock_irqrestore(&info->card->card_lock, flags); 2834 spin_unlock_irqrestore(&info->card->card_lock, flags);
2800 return; 2835 return 0;
2801 } 2836 }
2802 2837
2803 info->xmit_buf[info->xmit_head++] = ch; 2838 info->xmit_buf[info->xmit_head++] = ch;
@@ -2806,11 +2841,12 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
2806 info->idle_stats.xmit_bytes++; 2841 info->idle_stats.xmit_bytes++;
2807 info->idle_stats.xmit_idle = jiffies; 2842 info->idle_stats.xmit_idle = jiffies;
2808 spin_unlock_irqrestore(&info->card->card_lock, flags); 2843 spin_unlock_irqrestore(&info->card->card_lock, flags);
2844 return 1;
2809} /* cy_put_char */ 2845} /* cy_put_char */
2810 2846
2811/* 2847/*
2812 * This routine is called by the kernel after it has written a 2848 * This routine is called by the kernel after it has written a
2813 * series of characters to the tty device using put_char(). 2849 * series of characters to the tty device using put_char().
2814 */ 2850 */
2815static void cy_flush_chars(struct tty_struct *tty) 2851static void cy_flush_chars(struct tty_struct *tty)
2816{ 2852{
@@ -2882,6 +2918,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
2882 int char_count; 2918 int char_count;
2883 __u32 tx_put, tx_get, tx_bufsize; 2919 __u32 tx_put, tx_get, tx_bufsize;
2884 2920
2921 lock_kernel();
2885 firm_id = card->base_addr + ID_ADDRESS; 2922 firm_id = card->base_addr + ID_ADDRESS;
2886 zfw_ctrl = card->base_addr + 2923 zfw_ctrl = card->base_addr +
2887 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 2924 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -2899,6 +2936,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty)
2899 printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n", 2936 printk(KERN_DEBUG "cyc:cy_chars_in_buffer ttyC%d %d\n",
2900 info->line, info->xmit_cnt + char_count); 2937 info->line, info->xmit_cnt + char_count);
2901#endif 2938#endif
2939 unlock_kernel();
2902 return info->xmit_cnt + char_count; 2940 return info->xmit_cnt + char_count;
2903 } 2941 }
2904#endif /* Z_EXT_CHARS_IN_BUFFER */ 2942#endif /* Z_EXT_CHARS_IN_BUFFER */
@@ -2950,12 +2988,12 @@ static void set_line_char(struct cyclades_port *info)
2950 int baud, baud_rate = 0; 2988 int baud, baud_rate = 0;
2951 int i; 2989 int i;
2952 2990
2953 if (!info->tty || !info->tty->termios) { 2991 if (!info->tty || !info->tty->termios)
2954 return; 2992 return;
2955 } 2993
2956 if (info->line == -1) { 2994 if (info->line == -1)
2957 return; 2995 return;
2958 } 2996
2959 cflag = info->tty->termios->c_cflag; 2997 cflag = info->tty->termios->c_cflag;
2960 iflag = info->tty->termios->c_iflag; 2998 iflag = info->tty->termios->c_iflag;
2961 2999
@@ -2994,13 +3032,11 @@ static void set_line_char(struct cyclades_port *info)
2994 } 3032 }
2995 /* find the baud index */ 3033 /* find the baud index */
2996 for (i = 0; i < 20; i++) { 3034 for (i = 0; i < 20; i++) {
2997 if (baud == baud_table[i]) { 3035 if (baud == baud_table[i])
2998 break; 3036 break;
2999 }
3000 } 3037 }
3001 if (i == 20) { 3038 if (i == 20)
3002 i = 19; /* CD1400_MAX_SPEED */ 3039 i = 19; /* CD1400_MAX_SPEED */
3003 }
3004 3040
3005 if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == 3041 if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) ==
3006 ASYNC_SPD_CUST) { 3042 ASYNC_SPD_CUST) {
@@ -3059,18 +3095,16 @@ static void set_line_char(struct cyclades_port *info)
3059 info->cor1 = Cy_8_BITS; 3095 info->cor1 = Cy_8_BITS;
3060 break; 3096 break;
3061 } 3097 }
3062 if (cflag & CSTOPB) { 3098 if (cflag & CSTOPB)
3063 info->cor1 |= Cy_2_STOP; 3099 info->cor1 |= Cy_2_STOP;
3064 } 3100
3065 if (cflag & PARENB) { 3101 if (cflag & PARENB) {
3066 if (cflag & PARODD) { 3102 if (cflag & PARODD)
3067 info->cor1 |= CyPARITY_O; 3103 info->cor1 |= CyPARITY_O;
3068 } else { 3104 else
3069 info->cor1 |= CyPARITY_E; 3105 info->cor1 |= CyPARITY_E;
3070 } 3106 } else
3071 } else {
3072 info->cor1 |= CyPARITY_NONE; 3107 info->cor1 |= CyPARITY_NONE;
3073 }
3074 3108
3075 /* CTS flow control flag */ 3109 /* CTS flow control flag */
3076 if (cflag & CRTSCTS) { 3110 if (cflag & CRTSCTS) {
@@ -3123,7 +3157,8 @@ static void set_line_char(struct cyclades_port *info)
3123 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch | 3157 cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch |
3124 CyCOR3ch, index); 3158 CyCOR3ch, index);
3125 3159
3126 cy_writeb(base_addr + (CyCAR << index), (u_char) channel); /* !!! Is this needed? */ 3160 /* !!! Is this needed? */
3161 cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
3127 cy_writeb(base_addr + (CyRTPR << index), 3162 cy_writeb(base_addr + (CyRTPR << index),
3128 (info->default_timeout ? info->default_timeout : 0x02)); 3163 (info->default_timeout ? info->default_timeout : 0x02));
3129 /* 10ms rx timeout */ 3164 /* 10ms rx timeout */
@@ -3191,9 +3226,8 @@ static void set_line_char(struct cyclades_port *info)
3191#endif 3226#endif
3192 } 3227 }
3193 3228
3194 if (info->tty) { 3229 if (info->tty)
3195 clear_bit(TTY_IO_ERROR, &info->tty->flags); 3230 clear_bit(TTY_IO_ERROR, &info->tty->flags);
3196 }
3197 spin_unlock_irqrestore(&card->card_lock, flags); 3231 spin_unlock_irqrestore(&card->card_lock, flags);
3198 3232
3199 } else { 3233 } else {
@@ -3206,9 +3240,8 @@ static void set_line_char(struct cyclades_port *info)
3206 int retval; 3240 int retval;
3207 3241
3208 firm_id = card->base_addr + ID_ADDRESS; 3242 firm_id = card->base_addr + ID_ADDRESS;
3209 if (!ISZLOADED(*card)) { 3243 if (!ISZLOADED(*card))
3210 return; 3244 return;
3211 }
3212 3245
3213 zfw_ctrl = card->base_addr + 3246 zfw_ctrl = card->base_addr +
3214 (readl(&firm_id->zfwctrl_addr) & 0xfffff); 3247 (readl(&firm_id->zfwctrl_addr) & 0xfffff);
@@ -3268,14 +3301,12 @@ static void set_line_char(struct cyclades_port *info)
3268 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); 3301 readl(&ch_ctrl->comm_data_l) | C_DL_1STOP);
3269 } 3302 }
3270 if (cflag & PARENB) { 3303 if (cflag & PARENB) {
3271 if (cflag & PARODD) { 3304 if (cflag & PARODD)
3272 cy_writel(&ch_ctrl->comm_parity, C_PR_ODD); 3305 cy_writel(&ch_ctrl->comm_parity, C_PR_ODD);
3273 } else { 3306 else
3274 cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN); 3307 cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN);
3275 } 3308 } else
3276 } else {
3277 cy_writel(&ch_ctrl->comm_parity, C_PR_NONE); 3309 cy_writel(&ch_ctrl->comm_parity, C_PR_NONE);
3278 }
3279 3310
3280 /* CTS flow control flag */ 3311 /* CTS flow control flag */
3281 if (cflag & CRTSCTS) { 3312 if (cflag & CRTSCTS) {
@@ -3305,11 +3336,10 @@ static void set_line_char(struct cyclades_port *info)
3305 } 3336 }
3306 3337
3307 /* CD sensitivity */ 3338 /* CD sensitivity */
3308 if (cflag & CLOCAL) { 3339 if (cflag & CLOCAL)
3309 info->flags &= ~ASYNC_CHECK_CD; 3340 info->flags &= ~ASYNC_CHECK_CD;
3310 } else { 3341 else
3311 info->flags |= ASYNC_CHECK_CD; 3342 info->flags |= ASYNC_CHECK_CD;
3312 }
3313 3343
3314 if (baud == 0) { /* baud rate is zero, turn off line */ 3344 if (baud == 0) { /* baud rate is zero, turn off line */
3315 cy_writel(&ch_ctrl->rs_control, 3345 cy_writel(&ch_ctrl->rs_control,
@@ -3325,21 +3355,20 @@ static void set_line_char(struct cyclades_port *info)
3325#endif 3355#endif
3326 } 3356 }
3327 3357
3328 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM,0L); 3358 retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM, 0L);
3329 if (retval != 0) { 3359 if (retval != 0) {
3330 printk(KERN_ERR "cyc:set_line_char(2) retval on ttyC%d " 3360 printk(KERN_ERR "cyc:set_line_char(2) retval on ttyC%d "
3331 "was %x\n", info->line, retval); 3361 "was %x\n", info->line, retval);
3332 } 3362 }
3333 3363
3334 if (info->tty) { 3364 if (info->tty)
3335 clear_bit(TTY_IO_ERROR, &info->tty->flags); 3365 clear_bit(TTY_IO_ERROR, &info->tty->flags);
3336 }
3337 } 3366 }
3338} /* set_line_char */ 3367} /* set_line_char */
3339 3368
3340static int 3369static int
3341get_serial_info(struct cyclades_port *info, 3370get_serial_info(struct cyclades_port *info,
3342 struct serial_struct __user * retinfo) 3371 struct serial_struct __user *retinfo)
3343{ 3372{
3344 struct serial_struct tmp; 3373 struct serial_struct tmp;
3345 struct cyclades_card *cinfo = info->card; 3374 struct cyclades_card *cinfo = info->card;
@@ -3363,7 +3392,7 @@ get_serial_info(struct cyclades_port *info,
3363 3392
3364static int 3393static int
3365set_serial_info(struct cyclades_port *info, 3394set_serial_info(struct cyclades_port *info,
3366 struct serial_struct __user * new_info) 3395 struct serial_struct __user *new_info)
3367{ 3396{
3368 struct serial_struct new_serial; 3397 struct serial_struct new_serial;
3369 struct cyclades_port old_info; 3398 struct cyclades_port old_info;
@@ -3417,7 +3446,7 @@ check_and_exit:
3417 * transmit holding register is empty. This functionality 3446 * transmit holding register is empty. This functionality
3418 * allows an RS485 driver to be written in user space. 3447 * allows an RS485 driver to be written in user space.
3419 */ 3448 */
3420static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value) 3449static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value)
3421{ 3450{
3422 struct cyclades_card *card; 3451 struct cyclades_card *card;
3423 int chip, channel, index; 3452 int chip, channel, index;
@@ -3461,9 +3490,11 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
3461 struct BOARD_CTRL __iomem *board_ctrl; 3490 struct BOARD_CTRL __iomem *board_ctrl;
3462 struct CH_CTRL __iomem *ch_ctrl; 3491 struct CH_CTRL __iomem *ch_ctrl;
3463 3492
3464 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 3493 if (serial_paranoia_check(info, tty->name, __func__))
3465 return -ENODEV; 3494 return -ENODEV;
3466 3495
3496 lock_kernel();
3497
3467 card = info->card; 3498 card = info->card;
3468 channel = info->line - card->first_line; 3499 channel = info->line - card->first_line;
3469 if (!IS_CYC_Z(*card)) { 3500 if (!IS_CYC_Z(*card)) {
@@ -3506,10 +3537,12 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
3506 ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0); 3537 ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0);
3507 } else { 3538 } else {
3508 result = 0; 3539 result = 0;
3540 unlock_kernel();
3509 return -ENODEV; 3541 return -ENODEV;
3510 } 3542 }
3511 3543
3512 } 3544 }
3545 unlock_kernel();
3513 return result; 3546 return result;
3514} /* cy_tiomget */ 3547} /* cy_tiomget */
3515 3548
@@ -3528,7 +3561,7 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
3528 struct CH_CTRL __iomem *ch_ctrl; 3561 struct CH_CTRL __iomem *ch_ctrl;
3529 int retval; 3562 int retval;
3530 3563
3531 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 3564 if (serial_paranoia_check(info, tty->name, __func__))
3532 return -ENODEV; 3565 return -ENODEV;
3533 3566
3534 card = info->card; 3567 card = info->card;
@@ -3727,8 +3760,8 @@ static void cy_break(struct tty_struct *tty, int break_state)
3727 spin_unlock_irqrestore(&card->card_lock, flags); 3760 spin_unlock_irqrestore(&card->card_lock, flags);
3728} /* cy_break */ 3761} /* cy_break */
3729 3762
3730static int 3763static int get_mon_info(struct cyclades_port *info,
3731get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon) 3764 struct cyclades_monitor __user *mon)
3732{ 3765{
3733 3766
3734 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) 3767 if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
@@ -3767,8 +3800,8 @@ static int set_threshold(struct cyclades_port *info, unsigned long value)
3767 return 0; 3800 return 0;
3768} /* set_threshold */ 3801} /* set_threshold */
3769 3802
3770static int 3803static int get_threshold(struct cyclades_port *info,
3771get_threshold(struct cyclades_port *info, unsigned long __user * value) 3804 unsigned long __user *value)
3772{ 3805{
3773 struct cyclades_card *card; 3806 struct cyclades_card *card;
3774 void __iomem *base_addr; 3807 void __iomem *base_addr;
@@ -3789,15 +3822,15 @@ get_threshold(struct cyclades_port *info, unsigned long __user * value)
3789 return 0; 3822 return 0;
3790} /* get_threshold */ 3823} /* get_threshold */
3791 3824
3792static int 3825static int set_default_threshold(struct cyclades_port *info,
3793set_default_threshold(struct cyclades_port *info, unsigned long value) 3826 unsigned long value)
3794{ 3827{
3795 info->default_threshold = value & 0x0f; 3828 info->default_threshold = value & 0x0f;
3796 return 0; 3829 return 0;
3797} /* set_default_threshold */ 3830} /* set_default_threshold */
3798 3831
3799static int 3832static int get_default_threshold(struct cyclades_port *info,
3800get_default_threshold(struct cyclades_port *info, unsigned long __user * value) 3833 unsigned long __user *value)
3801{ 3834{
3802 return put_user(info->default_threshold, value); 3835 return put_user(info->default_threshold, value);
3803} /* get_default_threshold */ 3836} /* get_default_threshold */
@@ -3824,7 +3857,8 @@ static int set_timeout(struct cyclades_port *info, unsigned long value)
3824 return 0; 3857 return 0;
3825} /* set_timeout */ 3858} /* set_timeout */
3826 3859
3827static int get_timeout(struct cyclades_port *info, unsigned long __user * value) 3860static int get_timeout(struct cyclades_port *info,
3861 unsigned long __user *value)
3828{ 3862{
3829 struct cyclades_card *card; 3863 struct cyclades_card *card;
3830 void __iomem *base_addr; 3864 void __iomem *base_addr;
@@ -3851,8 +3885,8 @@ static int set_default_timeout(struct cyclades_port *info, unsigned long value)
3851 return 0; 3885 return 0;
3852} /* set_default_timeout */ 3886} /* set_default_timeout */
3853 3887
3854static int 3888static int get_default_timeout(struct cyclades_port *info,
3855get_default_timeout(struct cyclades_port *info, unsigned long __user * value) 3889 unsigned long __user *value)
3856{ 3890{
3857 return put_user(info->default_timeout, value); 3891 return put_user(info->default_timeout, value);
3858} /* get_default_timeout */ 3892} /* get_default_timeout */
@@ -3880,6 +3914,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
3880 printk(KERN_DEBUG "cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", 3914 printk(KERN_DEBUG "cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n",
3881 info->line, cmd, arg); 3915 info->line, cmd, arg);
3882#endif 3916#endif
3917 lock_kernel();
3883 3918
3884 switch (cmd) { 3919 switch (cmd) {
3885 case CYGETMON: 3920 case CYGETMON:
@@ -3936,7 +3971,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
3936 break; 3971 break;
3937#endif /* CONFIG_CYZ_INTR */ 3972#endif /* CONFIG_CYZ_INTR */
3938 case CYSETWAIT: 3973 case CYSETWAIT:
3939 info->closing_wait = (unsigned short)arg *HZ / 100; 3974 info->closing_wait = (unsigned short)arg * HZ / 100;
3940 ret_val = 0; 3975 ret_val = 0;
3941 break; 3976 break;
3942 case CYGETWAIT: 3977 case CYGETWAIT:
@@ -3988,47 +4023,47 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
3988 p_cuser = argp; 4023 p_cuser = argp;
3989 ret_val = put_user(cnow.cts, &p_cuser->cts); 4024 ret_val = put_user(cnow.cts, &p_cuser->cts);
3990 if (ret_val) 4025 if (ret_val)
3991 return ret_val; 4026 break;
3992 ret_val = put_user(cnow.dsr, &p_cuser->dsr); 4027 ret_val = put_user(cnow.dsr, &p_cuser->dsr);
3993 if (ret_val) 4028 if (ret_val)
3994 return ret_val; 4029 break;
3995 ret_val = put_user(cnow.rng, &p_cuser->rng); 4030 ret_val = put_user(cnow.rng, &p_cuser->rng);
3996 if (ret_val) 4031 if (ret_val)
3997 return ret_val; 4032 break;
3998 ret_val = put_user(cnow.dcd, &p_cuser->dcd); 4033 ret_val = put_user(cnow.dcd, &p_cuser->dcd);
3999 if (ret_val) 4034 if (ret_val)
4000 return ret_val; 4035 break;
4001 ret_val = put_user(cnow.rx, &p_cuser->rx); 4036 ret_val = put_user(cnow.rx, &p_cuser->rx);
4002 if (ret_val) 4037 if (ret_val)
4003 return ret_val; 4038 break;
4004 ret_val = put_user(cnow.tx, &p_cuser->tx); 4039 ret_val = put_user(cnow.tx, &p_cuser->tx);
4005 if (ret_val) 4040 if (ret_val)
4006 return ret_val; 4041 break;
4007 ret_val = put_user(cnow.frame, &p_cuser->frame); 4042 ret_val = put_user(cnow.frame, &p_cuser->frame);
4008 if (ret_val) 4043 if (ret_val)
4009 return ret_val; 4044 break;
4010 ret_val = put_user(cnow.overrun, &p_cuser->overrun); 4045 ret_val = put_user(cnow.overrun, &p_cuser->overrun);
4011 if (ret_val) 4046 if (ret_val)
4012 return ret_val; 4047 break;
4013 ret_val = put_user(cnow.parity, &p_cuser->parity); 4048 ret_val = put_user(cnow.parity, &p_cuser->parity);
4014 if (ret_val) 4049 if (ret_val)
4015 return ret_val; 4050 break;
4016 ret_val = put_user(cnow.brk, &p_cuser->brk); 4051 ret_val = put_user(cnow.brk, &p_cuser->brk);
4017 if (ret_val) 4052 if (ret_val)
4018 return ret_val; 4053 break;
4019 ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun); 4054 ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
4020 if (ret_val) 4055 if (ret_val)
4021 return ret_val; 4056 break;
4022 ret_val = 0; 4057 ret_val = 0;
4023 break; 4058 break;
4024 default: 4059 default:
4025 ret_val = -ENOIOCTLCMD; 4060 ret_val = -ENOIOCTLCMD;
4026 } 4061 }
4062 unlock_kernel();
4027 4063
4028#ifdef CY_DEBUG_OTHER 4064#ifdef CY_DEBUG_OTHER
4029 printk(KERN_DEBUG "cyc:cy_ioctl done\n"); 4065 printk(KERN_DEBUG "cyc:cy_ioctl done\n");
4030#endif 4066#endif
4031
4032 return ret_val; 4067 return ret_val;
4033} /* cy_ioctl */ 4068} /* cy_ioctl */
4034 4069
@@ -4113,9 +4148,8 @@ static void cy_throttle(struct tty_struct *tty)
4113 tty->ldisc.chars_in_buffer(tty), info->line); 4148 tty->ldisc.chars_in_buffer(tty), info->line);
4114#endif 4149#endif
4115 4150
4116 if (serial_paranoia_check(info, tty->name, "cy_throttle")) { 4151 if (serial_paranoia_check(info, tty->name, "cy_throttle"))
4117 return; 4152 return;
4118 }
4119 4153
4120 card = info->card; 4154 card = info->card;
4121 4155
@@ -4169,12 +4203,11 @@ static void cy_unthrottle(struct tty_struct *tty)
4169 char buf[64]; 4203 char buf[64];
4170 4204
4171 printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n", 4205 printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n",
4172 tty_name(tty, buf), tty->ldisc.chars_in_buffer(tty),info->line); 4206 tty_name(tty, buf), tty_chars_in_buffer(tty), info->line);
4173#endif 4207#endif
4174 4208
4175 if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) { 4209 if (serial_paranoia_check(info, tty->name, "cy_unthrottle"))
4176 return; 4210 return;
4177 }
4178 4211
4179 if (I_IXOFF(tty)) { 4212 if (I_IXOFF(tty)) {
4180 if (info->x_char) 4213 if (info->x_char)
@@ -4269,47 +4302,14 @@ static void cy_start(struct tty_struct *tty)
4269 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); 4302 base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index);
4270 4303
4271 spin_lock_irqsave(&cinfo->card_lock, flags); 4304 spin_lock_irqsave(&cinfo->card_lock, flags);
4272 cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */ 4305 cy_writeb(base_addr + (CyCAR << index),
4306 (u_char) (channel & 0x0003)); /* index channel */
4273 cy_writeb(base_addr + (CySRER << index), 4307 cy_writeb(base_addr + (CySRER << index),
4274 readb(base_addr + (CySRER << index)) | CyTxRdy); 4308 readb(base_addr + (CySRER << index)) | CyTxRdy);
4275 spin_unlock_irqrestore(&cinfo->card_lock, flags); 4309 spin_unlock_irqrestore(&cinfo->card_lock, flags);
4276 } 4310 }
4277} /* cy_start */ 4311} /* cy_start */
4278 4312
4279static void cy_flush_buffer(struct tty_struct *tty)
4280{
4281 struct cyclades_port *info = tty->driver_data;
4282 struct cyclades_card *card;
4283 int channel, retval;
4284 unsigned long flags;
4285
4286#ifdef CY_DEBUG_IO
4287 printk(KERN_DEBUG "cyc:cy_flush_buffer ttyC%d\n", info->line);
4288#endif
4289
4290 if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
4291 return;
4292
4293 card = info->card;
4294 channel = info->line - card->first_line;
4295
4296 spin_lock_irqsave(&card->card_lock, flags);
4297 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
4298 spin_unlock_irqrestore(&card->card_lock, flags);
4299
4300 if (IS_CYC_Z(*card)) { /* If it is a Z card, flush the on-board
4301 buffers as well */
4302 spin_lock_irqsave(&card->card_lock, flags);
4303 retval = cyz_issue_cmd(card, channel, C_CM_FLUSH_TX, 0L);
4304 if (retval != 0) {
4305 printk(KERN_ERR "cyc: flush_buffer retval on ttyC%d "
4306 "was %x\n", info->line, retval);
4307 }
4308 spin_unlock_irqrestore(&card->card_lock, flags);
4309 }
4310 tty_wakeup(tty);
4311} /* cy_flush_buffer */
4312
4313/* 4313/*
4314 * cy_hangup() --- called by tty_hangup() when a hangup is signaled. 4314 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
4315 */ 4315 */
@@ -4406,10 +4406,11 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
4406 info->cor3 = 0x08; /* _very_ small rcv threshold */ 4406 info->cor3 = 0x08; /* _very_ small rcv threshold */
4407 4407
4408 chip_number = (port - cinfo->first_line) / 4; 4408 chip_number = (port - cinfo->first_line) / 4;
4409 if ((info->chip_rev = readb(cinfo->base_addr + 4409 info->chip_rev = readb(cinfo->base_addr +
4410 (cy_chip_offset[chip_number] << 4410 (cy_chip_offset[chip_number] << index) +
4411 index) + (CyGFRCR << index))) >= 4411 (CyGFRCR << index));
4412 CD1400_REV_J) { 4412
4413 if (info->chip_rev >= CD1400_REV_J) {
4413 /* It is a CD1400 rev. J or later */ 4414 /* It is a CD1400 rev. J or later */
4414 info->tbpr = baud_bpr_60[13]; /* Tx BPR */ 4415 info->tbpr = baud_bpr_60[13]; /* Tx BPR */
4415 info->tco = baud_co_60[13]; /* Tx CO */ 4416 info->tco = baud_co_60[13]; /* Tx CO */
@@ -4454,7 +4455,8 @@ static unsigned short __devinit cyy_init_card(void __iomem *true_base_addr,
4454 /* Cy_ClrIntr is 0x1800 */ 4455 /* Cy_ClrIntr is 0x1800 */
4455 udelay(500L); 4456 udelay(500L);
4456 4457
4457 for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD; chip_number++) { 4458 for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD;
4459 chip_number++) {
4458 base_addr = 4460 base_addr =
4459 true_base_addr + (cy_chip_offset[chip_number] << index); 4461 true_base_addr + (cy_chip_offset[chip_number] << index);
4460 mdelay(1); 4462 mdelay(1);
@@ -4555,12 +4557,11 @@ static int __init cy_detect_isa(void)
4555 /* scan the address table probing for Cyclom-Y/ISA boards */ 4557 /* scan the address table probing for Cyclom-Y/ISA boards */
4556 for (i = 0; i < NR_ISA_ADDRS; i++) { 4558 for (i = 0; i < NR_ISA_ADDRS; i++) {
4557 unsigned int isa_address = cy_isa_addresses[i]; 4559 unsigned int isa_address = cy_isa_addresses[i];
4558 if (isa_address == 0x0000) { 4560 if (isa_address == 0x0000)
4559 return nboard; 4561 return nboard;
4560 }
4561 4562
4562 /* probe for CD1400... */ 4563 /* probe for CD1400... */
4563 cy_isa_address = ioremap(isa_address, CyISA_Ywin); 4564 cy_isa_address = ioremap_nocache(isa_address, CyISA_Ywin);
4564 if (cy_isa_address == NULL) { 4565 if (cy_isa_address == NULL) {
4565 printk(KERN_ERR "Cyclom-Y/ISA: can't remap base " 4566 printk(KERN_ERR "Cyclom-Y/ISA: can't remap base "
4566 "address\n"); 4567 "address\n");
@@ -4847,12 +4848,10 @@ static int __devinit cyz_load_fw(struct pci_dev *pdev, void __iomem *base_addr,
4847 if (mailbox != 0) { 4848 if (mailbox != 0) {
4848 /* set window to last 512K of RAM */ 4849 /* set window to last 512K of RAM */
4849 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM + RAM_SIZE); 4850 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM + RAM_SIZE);
4850 //sleep(1);
4851 for (tmp = base_addr; tmp < base_addr + RAM_SIZE; tmp++) 4851 for (tmp = base_addr; tmp < base_addr + RAM_SIZE; tmp++)
4852 cy_writeb(tmp, 255); 4852 cy_writeb(tmp, 255);
4853 /* set window to beginning of RAM */ 4853 /* set window to beginning of RAM */
4854 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM); 4854 cy_writel(&ctl_addr->loc_addr_base, WIN_RAM);
4855 //sleep(1);
4856 } 4855 }
4857 4856
4858 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, base_addr, NULL); 4857 retval = __cyz_load_fw(fw, "Cyclom-Z", mailbox, base_addr, NULL);
@@ -5382,7 +5381,8 @@ static void __exit cy_cleanup_module(void)
5382 del_timer_sync(&cyz_timerlist); 5381 del_timer_sync(&cyz_timerlist);
5383#endif /* CONFIG_CYZ_INTR */ 5382#endif /* CONFIG_CYZ_INTR */
5384 5383
5385 if ((e1 = tty_unregister_driver(cy_serial_driver))) 5384 e1 = tty_unregister_driver(cy_serial_driver);
5385 if (e1)
5386 printk(KERN_ERR "failed to unregister Cyclades serial " 5386 printk(KERN_ERR "failed to unregister Cyclades serial "
5387 "driver(%d)\n", e1); 5387 "driver(%d)\n", e1);
5388 5388
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index ecee3547a13f..213b3ca3468e 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -160,7 +160,7 @@ struct drm_device;
160 * \param arg arguments 160 * \param arg arguments
161 */ 161 */
162#define DRM_ERROR(fmt, arg...) \ 162#define DRM_ERROR(fmt, arg...) \
163 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg) 163 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __func__ , ##arg)
164 164
165/** 165/**
166 * Memory error output. 166 * Memory error output.
@@ -170,7 +170,7 @@ struct drm_device;
170 * \param arg arguments 170 * \param arg arguments
171 */ 171 */
172#define DRM_MEM_ERROR(area, fmt, arg...) \ 172#define DRM_MEM_ERROR(area, fmt, arg...) \
173 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \ 173 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __func__, \
174 drm_mem_stats[area].name , ##arg) 174 drm_mem_stats[area].name , ##arg)
175 175
176#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg) 176#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
@@ -187,7 +187,7 @@ struct drm_device;
187 if ( drm_debug ) \ 187 if ( drm_debug ) \
188 printk(KERN_DEBUG \ 188 printk(KERN_DEBUG \
189 "[" DRM_NAME ":%s] " fmt , \ 189 "[" DRM_NAME ":%s] " fmt , \
190 __FUNCTION__ , ##arg); \ 190 __func__ , ##arg); \
191 } while (0) 191 } while (0)
192#else 192#else
193#define DRM_DEBUG(fmt, arg...) do { } while (0) 193#define DRM_DEBUG(fmt, arg...) do { } while (0)
@@ -238,7 +238,7 @@ do { \
238 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ 238 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
239 dev->lock.file_priv != file_priv ) { \ 239 dev->lock.file_priv != file_priv ) { \
240 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\ 240 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
241 __FUNCTION__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\ 241 __func__, _DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ),\
242 dev->lock.file_priv, file_priv ); \ 242 dev->lock.file_priv, file_priv ); \
243 return -EINVAL; \ 243 return -EINVAL; \
244 } \ 244 } \
diff --git a/drivers/char/drm/drm_sysfs.c b/drivers/char/drm/drm_sysfs.c
index 7a1d9a782ddb..9a32169e88fb 100644
--- a/drivers/char/drm/drm_sysfs.c
+++ b/drivers/char/drm/drm_sysfs.c
@@ -34,7 +34,7 @@ static int drm_sysfs_suspend(struct device *dev, pm_message_t state)
34 struct drm_minor *drm_minor = to_drm_minor(dev); 34 struct drm_minor *drm_minor = to_drm_minor(dev);
35 struct drm_device *drm_dev = drm_minor->dev; 35 struct drm_device *drm_dev = drm_minor->dev;
36 36
37 printk(KERN_ERR "%s\n", __FUNCTION__); 37 printk(KERN_ERR "%s\n", __func__);
38 38
39 if (drm_dev->driver->suspend) 39 if (drm_dev->driver->suspend)
40 return drm_dev->driver->suspend(drm_dev, state); 40 return drm_dev->driver->suspend(drm_dev, state);
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index 60c9376be486..a86ab30b4620 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -692,7 +692,7 @@ static void i830EmitState(struct drm_device * dev)
692 drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv; 692 drm_i830_sarea_t *sarea_priv = dev_priv->sarea_priv;
693 unsigned int dirty = sarea_priv->dirty; 693 unsigned int dirty = sarea_priv->dirty;
694 694
695 DRM_DEBUG("%s %x\n", __FUNCTION__, dirty); 695 DRM_DEBUG("%s %x\n", __func__, dirty);
696 696
697 if (dirty & I830_UPLOAD_BUFFERS) { 697 if (dirty & I830_UPLOAD_BUFFERS) {
698 i830EmitDestVerified(dev, sarea_priv->BufferState); 698 i830EmitDestVerified(dev, sarea_priv->BufferState);
@@ -1043,7 +1043,7 @@ static void i830_dma_dispatch_flip(struct drm_device * dev)
1043 RING_LOCALS; 1043 RING_LOCALS;
1044 1044
1045 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n", 1045 DRM_DEBUG("%s: page=%d pfCurrentPage=%d\n",
1046 __FUNCTION__, 1046 __func__,
1047 dev_priv->current_page, 1047 dev_priv->current_page,
1048 dev_priv->sarea_priv->pf_current_page); 1048 dev_priv->sarea_priv->pf_current_page);
1049 1049
@@ -1206,7 +1206,7 @@ static void i830_dma_quiescent(struct drm_device * dev)
1206 OUT_RING(0); 1206 OUT_RING(0);
1207 ADVANCE_LP_RING(); 1207 ADVANCE_LP_RING();
1208 1208
1209 i830_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); 1209 i830_wait_ring(dev, dev_priv->ring.Size - 8, __func__);
1210} 1210}
1211 1211
1212static int i830_flush_queue(struct drm_device * dev) 1212static int i830_flush_queue(struct drm_device * dev)
@@ -1223,7 +1223,7 @@ static int i830_flush_queue(struct drm_device * dev)
1223 OUT_RING(0); 1223 OUT_RING(0);
1224 ADVANCE_LP_RING(); 1224 ADVANCE_LP_RING();
1225 1225
1226 i830_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); 1226 i830_wait_ring(dev, dev_priv->ring.Size - 8, __func__);
1227 1227
1228 for (i = 0; i < dma->buf_count; i++) { 1228 for (i = 0; i < dma->buf_count; i++) {
1229 struct drm_buf *buf = dma->buflist[i]; 1229 struct drm_buf *buf = dma->buflist[i];
@@ -1344,7 +1344,7 @@ static void i830_do_init_pageflip(struct drm_device * dev)
1344{ 1344{
1345 drm_i830_private_t *dev_priv = dev->dev_private; 1345 drm_i830_private_t *dev_priv = dev->dev_private;
1346 1346
1347 DRM_DEBUG("%s\n", __FUNCTION__); 1347 DRM_DEBUG("%s\n", __func__);
1348 dev_priv->page_flipping = 1; 1348 dev_priv->page_flipping = 1;
1349 dev_priv->current_page = 0; 1349 dev_priv->current_page = 0;
1350 dev_priv->sarea_priv->pf_current_page = dev_priv->current_page; 1350 dev_priv->sarea_priv->pf_current_page = dev_priv->current_page;
@@ -1354,7 +1354,7 @@ static int i830_do_cleanup_pageflip(struct drm_device * dev)
1354{ 1354{
1355 drm_i830_private_t *dev_priv = dev->dev_private; 1355 drm_i830_private_t *dev_priv = dev->dev_private;
1356 1356
1357 DRM_DEBUG("%s\n", __FUNCTION__); 1357 DRM_DEBUG("%s\n", __func__);
1358 if (dev_priv->current_page != 0) 1358 if (dev_priv->current_page != 0)
1359 i830_dma_dispatch_flip(dev); 1359 i830_dma_dispatch_flip(dev);
1360 1360
@@ -1367,7 +1367,7 @@ static int i830_flip_bufs(struct drm_device *dev, void *data,
1367{ 1367{
1368 drm_i830_private_t *dev_priv = dev->dev_private; 1368 drm_i830_private_t *dev_priv = dev->dev_private;
1369 1369
1370 DRM_DEBUG("%s\n", __FUNCTION__); 1370 DRM_DEBUG("%s\n", __func__);
1371 1371
1372 LOCK_TEST_WITH_RETURN(dev, file_priv); 1372 LOCK_TEST_WITH_RETURN(dev, file_priv);
1373 1373
@@ -1437,7 +1437,7 @@ static int i830_getparam(struct drm_device *dev, void *data,
1437 int value; 1437 int value;
1438 1438
1439 if (!dev_priv) { 1439 if (!dev_priv) {
1440 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1440 DRM_ERROR("%s called with no initialization\n", __func__);
1441 return -EINVAL; 1441 return -EINVAL;
1442 } 1442 }
1443 1443
@@ -1464,7 +1464,7 @@ static int i830_setparam(struct drm_device *dev, void *data,
1464 drm_i830_setparam_t *param = data; 1464 drm_i830_setparam_t *param = data;
1465 1465
1466 if (!dev_priv) { 1466 if (!dev_priv) {
1467 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 1467 DRM_ERROR("%s called with no initialization\n", __func__);
1468 return -EINVAL; 1468 return -EINVAL;
1469 } 1469 }
1470 1470
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index 4caba8c54455..b5bf8cc0fdaa 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -158,7 +158,7 @@ extern int i830_driver_device_is_agp(struct drm_device * dev);
158 if (I830_VERBOSE) \ 158 if (I830_VERBOSE) \
159 printk("BEGIN_LP_RING(%d)\n", (n)); \ 159 printk("BEGIN_LP_RING(%d)\n", (n)); \
160 if (dev_priv->ring.space < n*4) \ 160 if (dev_priv->ring.space < n*4) \
161 i830_wait_ring(dev, n*4, __FUNCTION__); \ 161 i830_wait_ring(dev, n*4, __func__); \
162 outcount = 0; \ 162 outcount = 0; \
163 outring = dev_priv->ring.tail; \ 163 outring = dev_priv->ring.tail; \
164 ringmask = dev_priv->ring.tail_mask; \ 164 ringmask = dev_priv->ring.tail_mask; \
diff --git a/drivers/char/drm/i830_irq.c b/drivers/char/drm/i830_irq.c
index a33db5f0967f..91ec2bb497e9 100644
--- a/drivers/char/drm/i830_irq.c
+++ b/drivers/char/drm/i830_irq.c
@@ -58,7 +58,7 @@ static int i830_emit_irq(struct drm_device * dev)
58 drm_i830_private_t *dev_priv = dev->dev_private; 58 drm_i830_private_t *dev_priv = dev->dev_private;
59 RING_LOCALS; 59 RING_LOCALS;
60 60
61 DRM_DEBUG("%s\n", __FUNCTION__); 61 DRM_DEBUG("%s\n", __func__);
62 62
63 atomic_inc(&dev_priv->irq_emitted); 63 atomic_inc(&dev_priv->irq_emitted);
64 64
@@ -77,7 +77,7 @@ static int i830_wait_irq(struct drm_device * dev, int irq_nr)
77 unsigned long end = jiffies + HZ * 3; 77 unsigned long end = jiffies + HZ * 3;
78 int ret = 0; 78 int ret = 0;
79 79
80 DRM_DEBUG("%s\n", __FUNCTION__); 80 DRM_DEBUG("%s\n", __func__);
81 81
82 if (atomic_read(&dev_priv->irq_received) >= irq_nr) 82 if (atomic_read(&dev_priv->irq_received) >= irq_nr)
83 return 0; 83 return 0;
@@ -124,7 +124,7 @@ int i830_irq_emit(struct drm_device *dev, void *data,
124 LOCK_TEST_WITH_RETURN(dev, file_priv); 124 LOCK_TEST_WITH_RETURN(dev, file_priv);
125 125
126 if (!dev_priv) { 126 if (!dev_priv) {
127 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 127 DRM_ERROR("%s called with no initialization\n", __func__);
128 return -EINVAL; 128 return -EINVAL;
129 } 129 }
130 130
@@ -147,7 +147,7 @@ int i830_irq_wait(struct drm_device *dev, void *data,
147 drm_i830_irq_wait_t *irqwait = data; 147 drm_i830_irq_wait_t *irqwait = data;
148 148
149 if (!dev_priv) { 149 if (!dev_priv) {
150 DRM_ERROR("%s called with no initialization\n", __FUNCTION__); 150 DRM_ERROR("%s called with no initialization\n", __func__);
151 return -EINVAL; 151 return -EINVAL;
152 } 152 }
153 153
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index ef7bf143a80c..f47e46e3529f 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -194,7 +194,7 @@ static int i915_dma_resume(struct drm_device * dev)
194{ 194{
195 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 195 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
196 196
197 DRM_DEBUG("%s\n", __FUNCTION__); 197 DRM_DEBUG("%s\n", __func__);
198 198
199 if (!dev_priv->sarea) { 199 if (!dev_priv->sarea) {
200 DRM_ERROR("can not find sarea!\n"); 200 DRM_ERROR("can not find sarea!\n");
@@ -609,7 +609,7 @@ static int i915_quiescent(struct drm_device * dev)
609 drm_i915_private_t *dev_priv = dev->dev_private; 609 drm_i915_private_t *dev_priv = dev->dev_private;
610 610
611 i915_kernel_lost_context(dev); 611 i915_kernel_lost_context(dev);
612 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __FUNCTION__); 612 return i915_wait_ring(dev, dev_priv->ring.Size - 8, __func__);
613} 613}
614 614
615static int i915_flush_ioctl(struct drm_device *dev, void *data, 615static int i915_flush_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index c614d78b3dfd..db7001f22561 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -272,7 +272,7 @@ extern void i915_mem_release(struct drm_device * dev,
272 if (I915_VERBOSE) \ 272 if (I915_VERBOSE) \
273 DRM_DEBUG("BEGIN_LP_RING(%d)\n", (n)); \ 273 DRM_DEBUG("BEGIN_LP_RING(%d)\n", (n)); \
274 if (dev_priv->ring.space < (n)*4) \ 274 if (dev_priv->ring.space < (n)*4) \
275 i915_wait_ring(dev, (n)*4, __FUNCTION__); \ 275 i915_wait_ring(dev, (n)*4, __func__); \
276 outcount = 0; \ 276 outcount = 0; \
277 outring = dev_priv->ring.tail; \ 277 outring = dev_priv->ring.tail; \
278 ringmask = dev_priv->ring.tail_mask; \ 278 ringmask = dev_priv->ring.tail_mask; \
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 9072e4a1894e..f6f6c92bf771 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -894,7 +894,7 @@ static u32 RADEON_READ_IGPGART(drm_radeon_private_t *dev_priv, int addr)
894#if RADEON_FIFO_DEBUG 894#if RADEON_FIFO_DEBUG
895static void radeon_status(drm_radeon_private_t * dev_priv) 895static void radeon_status(drm_radeon_private_t * dev_priv)
896{ 896{
897 printk("%s:\n", __FUNCTION__); 897 printk("%s:\n", __func__);
898 printk("RBBM_STATUS = 0x%08x\n", 898 printk("RBBM_STATUS = 0x%08x\n",
899 (unsigned int)RADEON_READ(RADEON_RBBM_STATUS)); 899 (unsigned int)RADEON_READ(RADEON_RBBM_STATUS));
900 printk("CP_RB_RTPR = 0x%08x\n", 900 printk("CP_RB_RTPR = 0x%08x\n",
diff --git a/drivers/char/ds1286.c b/drivers/char/ds1286.c
index 59146e3365ba..ea35ab2c9909 100644
--- a/drivers/char/ds1286.c
+++ b/drivers/char/ds1286.c
@@ -39,6 +39,7 @@
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/bcd.h> 40#include <linux/bcd.h>
41#include <linux/proc_fs.h> 41#include <linux/proc_fs.h>
42#include <linux/jiffies.h>
42 43
43#include <asm/uaccess.h> 44#include <asm/uaccess.h>
44#include <asm/system.h> 45#include <asm/system.h>
@@ -451,7 +452,7 @@ static void ds1286_get_time(struct rtc_time *rtc_tm)
451 */ 452 */
452 453
453 if (ds1286_is_updating() != 0) 454 if (ds1286_is_updating() != 0)
454 while (jiffies - uip_watchdog < 2*HZ/100) 455 while (time_before(jiffies, uip_watchdog + 2*HZ/100))
455 barrier(); 456 barrier();
456 457
457 /* 458 /*
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index ffd747c5dff0..60a4df7dac12 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -38,8 +38,8 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <asm/uaccess.h> 41#include <linux/uaccess.h>
42#include <asm/io.h> 42#include <linux/io.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/pci.h> 44#include <linux/pci.h>
45#include "digiPCI.h" 45#include "digiPCI.h"
@@ -73,7 +73,8 @@ static int invalid_lilo_config;
73 */ 73 */
74static DEFINE_SPINLOCK(epca_lock); 74static DEFINE_SPINLOCK(epca_lock);
75 75
76/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted to 7 below. */ 76/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted
77 to 7 below. */
77static struct board_info boards[MAXBOARDS]; 78static struct board_info boards[MAXBOARDS];
78 79
79static struct tty_driver *pc_driver; 80static struct tty_driver *pc_driver;
@@ -157,13 +158,12 @@ static void epca_error(int, char *);
157static void pc_close(struct tty_struct *, struct file *); 158static void pc_close(struct tty_struct *, struct file *);
158static void shutdown(struct channel *); 159static void shutdown(struct channel *);
159static void pc_hangup(struct tty_struct *); 160static void pc_hangup(struct tty_struct *);
160static void pc_put_char(struct tty_struct *, unsigned char);
161static int pc_write_room(struct tty_struct *); 161static int pc_write_room(struct tty_struct *);
162static int pc_chars_in_buffer(struct tty_struct *); 162static int pc_chars_in_buffer(struct tty_struct *);
163static void pc_flush_buffer(struct tty_struct *); 163static void pc_flush_buffer(struct tty_struct *);
164static void pc_flush_chars(struct tty_struct *); 164static void pc_flush_chars(struct tty_struct *);
165static int block_til_ready(struct tty_struct *, struct file *, 165static int block_til_ready(struct tty_struct *, struct file *,
166 struct channel *); 166 struct channel *);
167static int pc_open(struct tty_struct *, struct file *); 167static int pc_open(struct tty_struct *, struct file *);
168static void post_fep_init(unsigned int crd); 168static void post_fep_init(unsigned int crd);
169static void epcapoll(unsigned long); 169static void epcapoll(unsigned long);
@@ -175,18 +175,18 @@ static unsigned termios2digi_c(struct channel *ch, unsigned);
175static void epcaparam(struct tty_struct *, struct channel *); 175static void epcaparam(struct tty_struct *, struct channel *);
176static void receive_data(struct channel *); 176static void receive_data(struct channel *);
177static int pc_ioctl(struct tty_struct *, struct file *, 177static int pc_ioctl(struct tty_struct *, struct file *,
178 unsigned int, unsigned long); 178 unsigned int, unsigned long);
179static int info_ioctl(struct tty_struct *, struct file *, 179static int info_ioctl(struct tty_struct *, struct file *,
180 unsigned int, unsigned long); 180 unsigned int, unsigned long);
181static void pc_set_termios(struct tty_struct *, struct ktermios *); 181static void pc_set_termios(struct tty_struct *, struct ktermios *);
182static void do_softint(struct work_struct *work); 182static void do_softint(struct work_struct *work);
183static void pc_stop(struct tty_struct *); 183static void pc_stop(struct tty_struct *);
184static void pc_start(struct tty_struct *); 184static void pc_start(struct tty_struct *);
185static void pc_throttle(struct tty_struct * tty); 185static void pc_throttle(struct tty_struct *tty);
186static void pc_unthrottle(struct tty_struct *tty); 186static void pc_unthrottle(struct tty_struct *tty);
187static void digi_send_break(struct channel *ch, int msec); 187static void digi_send_break(struct channel *ch, int msec);
188static void setup_empty_event(struct tty_struct *tty, struct channel *ch); 188static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
189void epca_setup(char *, int *); 189static void epca_setup(char *, int *);
190 190
191static int pc_write(struct tty_struct *, const unsigned char *, int); 191static int pc_write(struct tty_struct *, const unsigned char *, int);
192static int pc_init(void); 192static int pc_init(void);
@@ -243,7 +243,7 @@ static void assertmemoff(struct channel *ch)
243/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */ 243/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */
244static void pcxem_memwinon(struct board_info *b, unsigned int win) 244static void pcxem_memwinon(struct board_info *b, unsigned int win)
245{ 245{
246 outb_p(FEPWIN|win, b->port + 1); 246 outb_p(FEPWIN | win, b->port + 1);
247} 247}
248 248
249static void pcxem_memwinoff(struct board_info *b, unsigned int win) 249static void pcxem_memwinoff(struct board_info *b, unsigned int win)
@@ -253,7 +253,7 @@ static void pcxem_memwinoff(struct board_info *b, unsigned int win)
253 253
254static void pcxem_globalwinon(struct channel *ch) 254static void pcxem_globalwinon(struct channel *ch)
255{ 255{
256 outb_p( FEPWIN, (int)ch->board->port + 1); 256 outb_p(FEPWIN, (int)ch->board->port + 1);
257} 257}
258 258
259static void pcxem_rxwinon(struct channel *ch) 259static void pcxem_rxwinon(struct channel *ch)
@@ -394,7 +394,7 @@ static struct channel *verifyChannel(struct tty_struct *tty)
394 */ 394 */
395 if (tty) { 395 if (tty) {
396 struct channel *ch = (struct channel *)tty->driver_data; 396 struct channel *ch = (struct channel *)tty->driver_data;
397 if ((ch >= &digi_channels[0]) && (ch < &digi_channels[nbdevs])) { 397 if (ch >= &digi_channels[0] && ch < &digi_channels[nbdevs]) {
398 if (ch->magic == EPCA_MAGIC) 398 if (ch->magic == EPCA_MAGIC)
399 return ch; 399 return ch;
400 } 400 }
@@ -414,7 +414,7 @@ static void pc_sched_event(struct channel *ch, int event)
414 414
415static void epca_error(int line, char *msg) 415static void epca_error(int line, char *msg)
416{ 416{
417 printk(KERN_ERR "epca_error (Digi): line = %d %s\n",line,msg); 417 printk(KERN_ERR "epca_error (Digi): line = %d %s\n", line, msg);
418} 418}
419 419
420static void pc_close(struct tty_struct *tty, struct file *filp) 420static void pc_close(struct tty_struct *tty, struct file *filp)
@@ -425,7 +425,8 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
425 * verifyChannel returns the channel from the tty struct if it is 425 * verifyChannel returns the channel from the tty struct if it is
426 * valid. This serves as a sanity check. 426 * valid. This serves as a sanity check.
427 */ 427 */
428 if ((ch = verifyChannel(tty)) != NULL) { 428 ch = verifyChannel(tty);
429 if (ch != NULL) {
429 spin_lock_irqsave(&epca_lock, flags); 430 spin_lock_irqsave(&epca_lock, flags);
430 if (tty_hung_up_p(filp)) { 431 if (tty_hung_up_p(filp)) {
431 spin_unlock_irqrestore(&epca_lock, flags); 432 spin_unlock_irqrestore(&epca_lock, flags);
@@ -440,7 +441,6 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
440 spin_unlock_irqrestore(&epca_lock, flags); 441 spin_unlock_irqrestore(&epca_lock, flags);
441 return; 442 return;
442 } 443 }
443
444 /* Port open only once go ahead with shutdown & reset */ 444 /* Port open only once go ahead with shutdown & reset */
445 BUG_ON(ch->count < 0); 445 BUG_ON(ch->count < 0);
446 446
@@ -455,12 +455,13 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
455 spin_unlock_irqrestore(&epca_lock, flags); 455 spin_unlock_irqrestore(&epca_lock, flags);
456 456
457 if (ch->asyncflags & ASYNC_INITIALIZED) { 457 if (ch->asyncflags & ASYNC_INITIALIZED) {
458 /* Setup an event to indicate when the transmit buffer empties */ 458 /* Setup an event to indicate when the
459 transmit buffer empties */
459 setup_empty_event(tty, ch); 460 setup_empty_event(tty, ch);
460 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 461 /* 30 seconds timeout */
462 tty_wait_until_sent(tty, 3000);
461 } 463 }
462 if (tty->driver->flush_buffer) 464 pc_flush_buffer(tty);
463 tty->driver->flush_buffer(tty);
464 465
465 tty_ldisc_flush(tty); 466 tty_ldisc_flush(tty);
466 shutdown(ch); 467 shutdown(ch);
@@ -477,7 +478,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
477 wake_up_interruptible(&ch->open_wait); 478 wake_up_interruptible(&ch->open_wait);
478 } 479 }
479 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | 480 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED |
480 ASYNC_CLOSING); 481 ASYNC_CLOSING);
481 wake_up_interruptible(&ch->close_wait); 482 wake_up_interruptible(&ch->close_wait);
482 } 483 }
483} 484}
@@ -524,16 +525,15 @@ static void shutdown(struct channel *ch)
524static void pc_hangup(struct tty_struct *tty) 525static void pc_hangup(struct tty_struct *tty)
525{ 526{
526 struct channel *ch; 527 struct channel *ch;
527
528 /* 528 /*
529 * verifyChannel returns the channel from the tty struct if it is 529 * verifyChannel returns the channel from the tty struct if it is
530 * valid. This serves as a sanity check. 530 * valid. This serves as a sanity check.
531 */ 531 */
532 if ((ch = verifyChannel(tty)) != NULL) { 532 ch = verifyChannel(tty);
533 if (ch != NULL) {
533 unsigned long flags; 534 unsigned long flags;
534 535
535 if (tty->driver->flush_buffer) 536 pc_flush_buffer(tty);
536 tty->driver->flush_buffer(tty);
537 tty_ldisc_flush(tty); 537 tty_ldisc_flush(tty);
538 shutdown(ch); 538 shutdown(ch);
539 539
@@ -548,7 +548,7 @@ static void pc_hangup(struct tty_struct *tty)
548} 548}
549 549
550static int pc_write(struct tty_struct *tty, 550static int pc_write(struct tty_struct *tty,
551 const unsigned char *buf, int bytesAvailable) 551 const unsigned char *buf, int bytesAvailable)
552{ 552{
553 unsigned int head, tail; 553 unsigned int head, tail;
554 int dataLen; 554 int dataLen;
@@ -572,7 +572,8 @@ static int pc_write(struct tty_struct *tty,
572 * verifyChannel returns the channel from the tty struct if it is 572 * verifyChannel returns the channel from the tty struct if it is
573 * valid. This serves as a sanity check. 573 * valid. This serves as a sanity check.
574 */ 574 */
575 if ((ch = verifyChannel(tty)) == NULL) 575 ch = verifyChannel(tty);
576 if (ch == NULL)
576 return 0; 577 return 0;
577 578
578 /* Make a pointer to the channel data structure found on the board. */ 579 /* Make a pointer to the channel data structure found on the board. */
@@ -645,26 +646,19 @@ static int pc_write(struct tty_struct *tty,
645 return amountCopied; 646 return amountCopied;
646} 647}
647 648
648static void pc_put_char(struct tty_struct *tty, unsigned char c)
649{
650 pc_write(tty, &c, 1);
651}
652
653static int pc_write_room(struct tty_struct *tty) 649static int pc_write_room(struct tty_struct *tty)
654{ 650{
655 int remain; 651 int remain = 0;
656 struct channel *ch; 652 struct channel *ch;
657 unsigned long flags; 653 unsigned long flags;
658 unsigned int head, tail; 654 unsigned int head, tail;
659 struct board_chan __iomem *bc; 655 struct board_chan __iomem *bc;
660
661 remain = 0;
662
663 /* 656 /*
664 * verifyChannel returns the channel from the tty struct if it is 657 * verifyChannel returns the channel from the tty struct if it is
665 * valid. This serves as a sanity check. 658 * valid. This serves as a sanity check.
666 */ 659 */
667 if ((ch = verifyChannel(tty)) != NULL) { 660 ch = verifyChannel(tty);
661 if (ch != NULL) {
668 spin_lock_irqsave(&epca_lock, flags); 662 spin_lock_irqsave(&epca_lock, flags);
669 globalwinon(ch); 663 globalwinon(ch);
670 664
@@ -676,8 +670,8 @@ static int pc_write_room(struct tty_struct *tty)
676 tail = readw(&bc->tout); 670 tail = readw(&bc->tout);
677 /* Wrap tail if necessary */ 671 /* Wrap tail if necessary */
678 tail &= (ch->txbufsize - 1); 672 tail &= (ch->txbufsize - 1);
679 673 remain = tail - head - 1;
680 if ((remain = tail - head - 1) < 0 ) 674 if (remain < 0)
681 remain += ch->txbufsize; 675 remain += ch->txbufsize;
682 676
683 if (remain && (ch->statusflags & LOWWAIT) == 0) { 677 if (remain && (ch->statusflags & LOWWAIT) == 0) {
@@ -699,12 +693,12 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
699 unsigned long flags; 693 unsigned long flags;
700 struct channel *ch; 694 struct channel *ch;
701 struct board_chan __iomem *bc; 695 struct board_chan __iomem *bc;
702
703 /* 696 /*
704 * verifyChannel returns the channel from the tty struct if it is 697 * verifyChannel returns the channel from the tty struct if it is
705 * valid. This serves as a sanity check. 698 * valid. This serves as a sanity check.
706 */ 699 */
707 if ((ch = verifyChannel(tty)) == NULL) 700 ch = verifyChannel(tty);
701 if (ch == NULL)
708 return 0; 702 return 0;
709 703
710 spin_lock_irqsave(&epca_lock, flags); 704 spin_lock_irqsave(&epca_lock, flags);
@@ -715,7 +709,8 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
715 head = readw(&bc->tin); 709 head = readw(&bc->tin);
716 ctail = readw(&ch->mailbox->cout); 710 ctail = readw(&ch->mailbox->cout);
717 711
718 if (tail == head && readw(&ch->mailbox->cin) == ctail && readb(&bc->tbusy) == 0) 712 if (tail == head && readw(&ch->mailbox->cin) == ctail &&
713 readb(&bc->tbusy) == 0)
719 chars = 0; 714 chars = 0;
720 else { /* Begin if some space on the card has been used */ 715 else { /* Begin if some space on the card has been used */
721 head = readw(&bc->tin) & (ch->txbufsize - 1); 716 head = readw(&bc->tin) & (ch->txbufsize - 1);
@@ -725,7 +720,8 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
725 * pc_write_room here we are finding the amount of bytes in the 720 * pc_write_room here we are finding the amount of bytes in the
726 * buffer filled. Not the amount of bytes empty. 721 * buffer filled. Not the amount of bytes empty.
727 */ 722 */
728 if ((remain = tail - head - 1) < 0 ) 723 remain = tail - head - 1;
724 if (remain < 0)
729 remain += ch->txbufsize; 725 remain += ch->txbufsize;
730 chars = (int)(ch->txbufsize - remain); 726 chars = (int)(ch->txbufsize - remain);
731 /* 727 /*
@@ -736,7 +732,7 @@ static int pc_chars_in_buffer(struct tty_struct *tty)
736 * transmit buffer empties. 732 * transmit buffer empties.
737 */ 733 */
738 if (!(ch->statusflags & EMPTYWAIT)) 734 if (!(ch->statusflags & EMPTYWAIT))
739 setup_empty_event(tty,ch); 735 setup_empty_event(tty, ch);
740 } /* End if some space on the card has been used */ 736 } /* End if some space on the card has been used */
741 memoff(ch); 737 memoff(ch);
742 spin_unlock_irqrestore(&epca_lock, flags); 738 spin_unlock_irqrestore(&epca_lock, flags);
@@ -754,7 +750,8 @@ static void pc_flush_buffer(struct tty_struct *tty)
754 * verifyChannel returns the channel from the tty struct if it is 750 * verifyChannel returns the channel from the tty struct if it is
755 * valid. This serves as a sanity check. 751 * valid. This serves as a sanity check.
756 */ 752 */
757 if ((ch = verifyChannel(tty)) == NULL) 753 ch = verifyChannel(tty);
754 if (ch == NULL)
758 return; 755 return;
759 756
760 spin_lock_irqsave(&epca_lock, flags); 757 spin_lock_irqsave(&epca_lock, flags);
@@ -775,23 +772,25 @@ static void pc_flush_chars(struct tty_struct *tty)
775 * verifyChannel returns the channel from the tty struct if it is 772 * verifyChannel returns the channel from the tty struct if it is
776 * valid. This serves as a sanity check. 773 * valid. This serves as a sanity check.
777 */ 774 */
778 if ((ch = verifyChannel(tty)) != NULL) { 775 ch = verifyChannel(tty);
776 if (ch != NULL) {
779 unsigned long flags; 777 unsigned long flags;
780 spin_lock_irqsave(&epca_lock, flags); 778 spin_lock_irqsave(&epca_lock, flags);
781 /* 779 /*
782 * If not already set and the transmitter is busy setup an 780 * If not already set and the transmitter is busy setup an
783 * event to indicate when the transmit empties. 781 * event to indicate when the transmit empties.
784 */ 782 */
785 if ((ch->statusflags & TXBUSY) && !(ch->statusflags & EMPTYWAIT)) 783 if ((ch->statusflags & TXBUSY) &&
786 setup_empty_event(tty,ch); 784 !(ch->statusflags & EMPTYWAIT))
785 setup_empty_event(tty, ch);
787 spin_unlock_irqrestore(&epca_lock, flags); 786 spin_unlock_irqrestore(&epca_lock, flags);
788 } 787 }
789} 788}
790 789
791static int block_til_ready(struct tty_struct *tty, 790static int block_til_ready(struct tty_struct *tty,
792 struct file *filp, struct channel *ch) 791 struct file *filp, struct channel *ch)
793{ 792{
794 DECLARE_WAITQUEUE(wait,current); 793 DECLARE_WAITQUEUE(wait, current);
795 int retval, do_clocal = 0; 794 int retval, do_clocal = 0;
796 unsigned long flags; 795 unsigned long flags;
797 796
@@ -839,8 +838,7 @@ static int block_til_ready(struct tty_struct *tty,
839 while (1) { 838 while (1) {
840 set_current_state(TASK_INTERRUPTIBLE); 839 set_current_state(TASK_INTERRUPTIBLE);
841 if (tty_hung_up_p(filp) || 840 if (tty_hung_up_p(filp) ||
842 !(ch->asyncflags & ASYNC_INITIALIZED)) 841 !(ch->asyncflags & ASYNC_INITIALIZED)) {
843 {
844 if (ch->asyncflags & ASYNC_HUP_NOTIFY) 842 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
845 retval = -EAGAIN; 843 retval = -EAGAIN;
846 else 844 else
@@ -880,7 +878,7 @@ static int block_til_ready(struct tty_struct *tty,
880 return 0; 878 return 0;
881} 879}
882 880
883static int pc_open(struct tty_struct *tty, struct file * filp) 881static int pc_open(struct tty_struct *tty, struct file *filp)
884{ 882{
885 struct channel *ch; 883 struct channel *ch;
886 unsigned long flags; 884 unsigned long flags;
@@ -923,7 +921,8 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
923 return(-ENODEV); 921 return(-ENODEV);
924 } 922 }
925 923
926 if ((bc = ch->brdchan) == 0) { 924 bc = ch->brdchan;
925 if (bc == NULL) {
927 tty->driver_data = NULL; 926 tty->driver_data = NULL;
928 return -ENODEV; 927 return -ENODEV;
929 } 928 }
@@ -964,7 +963,7 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
964 * The below routine generally sets up parity, baud, flow control 963 * The below routine generally sets up parity, baud, flow control
965 * issues, etc.... It effect both control flags and input flags. 964 * issues, etc.... It effect both control flags and input flags.
966 */ 965 */
967 epcaparam(tty,ch); 966 epcaparam(tty, ch);
968 ch->asyncflags |= ASYNC_INITIALIZED; 967 ch->asyncflags |= ASYNC_INITIALIZED;
969 memoff(ch); 968 memoff(ch);
970 spin_unlock_irqrestore(&epca_lock, flags); 969 spin_unlock_irqrestore(&epca_lock, flags);
@@ -1002,8 +1001,8 @@ static void __exit epca_module_exit(void)
1002 1001
1003 del_timer_sync(&epca_timer); 1002 del_timer_sync(&epca_timer);
1004 1003
1005 if (tty_unregister_driver(pc_driver) || tty_unregister_driver(pc_info)) 1004 if (tty_unregister_driver(pc_driver) ||
1006 { 1005 tty_unregister_driver(pc_info)) {
1007 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n"); 1006 printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n");
1008 return; 1007 return;
1009 } 1008 }
@@ -1034,7 +1033,6 @@ static const struct tty_operations pc_ops = {
1034 .flush_buffer = pc_flush_buffer, 1033 .flush_buffer = pc_flush_buffer,
1035 .chars_in_buffer = pc_chars_in_buffer, 1034 .chars_in_buffer = pc_chars_in_buffer,
1036 .flush_chars = pc_flush_chars, 1035 .flush_chars = pc_flush_chars,
1037 .put_char = pc_put_char,
1038 .ioctl = pc_ioctl, 1036 .ioctl = pc_ioctl,
1039 .set_termios = pc_set_termios, 1037 .set_termios = pc_set_termios,
1040 .stop = pc_stop, 1038 .stop = pc_stop,
@@ -1044,7 +1042,7 @@ static const struct tty_operations pc_ops = {
1044 .hangup = pc_hangup, 1042 .hangup = pc_hangup,
1045}; 1043};
1046 1044
1047static int info_open(struct tty_struct *tty, struct file * filp) 1045static int info_open(struct tty_struct *tty, struct file *filp)
1048{ 1046{
1049 return 0; 1047 return 0;
1050} 1048}
@@ -1099,7 +1097,7 @@ static int __init pc_init(void)
1099 * Set up interrupt, we will worry about memory allocation in 1097 * Set up interrupt, we will worry about memory allocation in
1100 * post_fep_init. 1098 * post_fep_init.
1101 */ 1099 */
1102 printk(KERN_INFO "DIGI epca driver version %s loaded.\n",VERSION); 1100 printk(KERN_INFO "DIGI epca driver version %s loaded.\n", VERSION);
1103 1101
1104 /* 1102 /*
1105 * NOTE : This code assumes that the number of ports found in the 1103 * NOTE : This code assumes that the number of ports found in the
@@ -1252,7 +1250,7 @@ static int __init pc_init(void)
1252 if ((board_id & 0x30) == 0x30) 1250 if ((board_id & 0x30) == 0x30)
1253 bd->memory_seg = 0x8000; 1251 bd->memory_seg = 0x8000;
1254 } else 1252 } else
1255 printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n",(int)bd->port); 1253 printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n", (int)bd->port);
1256 break; 1254 break;
1257 } 1255 }
1258 } 1256 }
@@ -1326,12 +1324,12 @@ static void post_fep_init(unsigned int crd)
1326 */ 1324 */
1327 /* PCI cards are already remapped at this point ISA are not */ 1325 /* PCI cards are already remapped at this point ISA are not */
1328 bd->numports = readw(bd->re_map_membase + XEMPORTS); 1326 bd->numports = readw(bd->re_map_membase + XEMPORTS);
1329 epcaassert(bd->numports <= 64,"PCI returned a invalid number of ports"); 1327 epcaassert(bd->numports <= 64, "PCI returned a invalid number of ports");
1330 nbdevs += (bd->numports); 1328 nbdevs += (bd->numports);
1331 } else { 1329 } else {
1332 /* Fix up the mappings for ISA/EISA etc */ 1330 /* Fix up the mappings for ISA/EISA etc */
1333 /* FIXME: 64K - can we be smarter ? */ 1331 /* FIXME: 64K - can we be smarter ? */
1334 bd->re_map_membase = ioremap(bd->membase, 0x10000); 1332 bd->re_map_membase = ioremap_nocache(bd->membase, 0x10000);
1335 } 1333 }
1336 1334
1337 if (crd != 0) 1335 if (crd != 0)
@@ -1362,7 +1360,8 @@ static void post_fep_init(unsigned int crd)
1362 * XEPORTS (address 0xc22) points at the number of channels the card 1360 * XEPORTS (address 0xc22) points at the number of channels the card
1363 * supports. (For 64XE, XI, XEM, and XR use 0xc02) 1361 * supports. (For 64XE, XI, XEM, and XR use 0xc02)
1364 */ 1362 */
1365 if ((bd->type == PCXEVE || bd->type == PCXE) && (readw(memaddr + XEPORTS) < 3)) 1363 if ((bd->type == PCXEVE || bd->type == PCXE) &&
1364 (readw(memaddr + XEPORTS) < 3))
1366 shrinkmem = 1; 1365 shrinkmem = 1;
1367 if (bd->type < PCIXEM) 1366 if (bd->type < PCIXEM)
1368 if (!request_region((int)bd->port, 4, board_desc[bd->type])) 1367 if (!request_region((int)bd->port, 4, board_desc[bd->type]))
@@ -1461,10 +1460,12 @@ static void post_fep_init(unsigned int crd)
1461 1460
1462 case PCXEVE: 1461 case PCXEVE:
1463 case PCXE: 1462 case PCXE:
1464 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4) & 0x1fff); 1463 ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4)
1464 & 0x1fff);
1465 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9); 1465 ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9);
1466 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4) & 0x1fff); 1466 ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4)
1467 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >>9 ); 1467 & 0x1fff);
1468 ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >> 9);
1468 break; 1469 break;
1469 1470
1470 case PCXI: 1471 case PCXI:
@@ -1518,8 +1519,9 @@ static void post_fep_init(unsigned int crd)
1518 } 1519 }
1519 1520
1520 printk(KERN_INFO 1521 printk(KERN_INFO
1521 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n", 1522 "Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n",
1522 VERSION, board_desc[bd->type], (long)bd->port, (long)bd->membase, bd->numports); 1523 VERSION, board_desc[bd->type], (long)bd->port,
1524 (long)bd->membase, bd->numports);
1523 memwinoff(bd, 0); 1525 memwinoff(bd, 0);
1524} 1526}
1525 1527
@@ -1527,7 +1529,7 @@ static void epcapoll(unsigned long ignored)
1527{ 1529{
1528 unsigned long flags; 1530 unsigned long flags;
1529 int crd; 1531 int crd;
1530 volatile unsigned int head, tail; 1532 unsigned int head, tail;
1531 struct channel *ch; 1533 struct channel *ch;
1532 struct board_info *bd; 1534 struct board_info *bd;
1533 1535
@@ -1593,7 +1595,9 @@ static void doevent(int crd)
1593 chan0 = card_ptr[crd]; 1595 chan0 = card_ptr[crd];
1594 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range"); 1596 epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range");
1595 assertgwinon(chan0); 1597 assertgwinon(chan0);
1596 while ((tail = readw(&chan0->mailbox->eout)) != (head = readw(&chan0->mailbox->ein))) { /* Begin while something in event queue */ 1598 while ((tail = readw(&chan0->mailbox->eout)) !=
1599 (head = readw(&chan0->mailbox->ein))) {
1600 /* Begin while something in event queue */
1597 assertgwinon(chan0); 1601 assertgwinon(chan0);
1598 eventbuf = bd->re_map_membase + tail + ISTART; 1602 eventbuf = bd->re_map_membase + tail + ISTART;
1599 /* Get the channel the event occurred on */ 1603 /* Get the channel the event occurred on */
@@ -1617,7 +1621,8 @@ static void doevent(int crd)
1617 goto next; 1621 goto next;
1618 } 1622 }
1619 1623
1620 if ((bc = ch->brdchan) == NULL) 1624 bc = ch->brdchan;
1625 if (bc == NULL)
1621 goto next; 1626 goto next;
1622 1627
1623 if (event & DATA_IND) { /* Begin DATA_IND */ 1628 if (event & DATA_IND) { /* Begin DATA_IND */
@@ -1629,10 +1634,11 @@ static void doevent(int crd)
1629 /* A modem signal change has been indicated */ 1634 /* A modem signal change has been indicated */
1630 ch->imodem = mstat; 1635 ch->imodem = mstat;
1631 if (ch->asyncflags & ASYNC_CHECK_CD) { 1636 if (ch->asyncflags & ASYNC_CHECK_CD) {
1632 if (mstat & ch->dcd) /* We are now receiving dcd */ 1637 /* We are now receiving dcd */
1638 if (mstat & ch->dcd)
1633 wake_up_interruptible(&ch->open_wait); 1639 wake_up_interruptible(&ch->open_wait);
1634 else 1640 else /* No dcd; hangup */
1635 pc_sched_event(ch, EPCA_EVENT_HANGUP); /* No dcd; hangup */ 1641 pc_sched_event(ch, EPCA_EVENT_HANGUP);
1636 } 1642 }
1637 } 1643 }
1638 tty = ch->tty; 1644 tty = ch->tty;
@@ -1647,7 +1653,8 @@ static void doevent(int crd)
1647 tty_wakeup(tty); 1653 tty_wakeup(tty);
1648 } 1654 }
1649 } else if (event & EMPTYTX_IND) { 1655 } else if (event & EMPTYTX_IND) {
1650 /* This event is generated by setup_empty_event */ 1656 /* This event is generated by
1657 setup_empty_event */
1651 ch->statusflags &= ~TXBUSY; 1658 ch->statusflags &= ~TXBUSY;
1652 if (ch->statusflags & EMPTYWAIT) { 1659 if (ch->statusflags & EMPTYWAIT) {
1653 ch->statusflags &= ~EMPTYWAIT; 1660 ch->statusflags &= ~EMPTYWAIT;
@@ -1655,7 +1662,7 @@ static void doevent(int crd)
1655 } 1662 }
1656 } 1663 }
1657 } 1664 }
1658 next: 1665next:
1659 globalwinon(ch); 1666 globalwinon(ch);
1660 BUG_ON(!bc); 1667 BUG_ON(!bc);
1661 writew(1, &bc->idata); 1668 writew(1, &bc->idata);
@@ -1665,7 +1672,7 @@ static void doevent(int crd)
1665} 1672}
1666 1673
1667static void fepcmd(struct channel *ch, int cmd, int word_or_byte, 1674static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1668 int byte2, int ncmds, int bytecmd) 1675 int byte2, int ncmds, int bytecmd)
1669{ 1676{
1670 unchar __iomem *memaddr; 1677 unchar __iomem *memaddr;
1671 unsigned int head, cmdTail, cmdStart, cmdMax; 1678 unsigned int head, cmdTail, cmdStart, cmdMax;
@@ -1690,8 +1697,10 @@ static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
1690 memaddr = ch->board->re_map_membase; 1697 memaddr = ch->board->re_map_membase;
1691 1698
1692 if (head >= (cmdMax - cmdStart) || (head & 03)) { 1699 if (head >= (cmdMax - cmdStart) || (head & 03)) {
1693 printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n", __LINE__, cmd, head); 1700 printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n",
1694 printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n", __LINE__, cmdMax, cmdStart); 1701 __LINE__, cmd, head);
1702 printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n",
1703 __LINE__, cmdMax, cmdStart);
1695 return; 1704 return;
1696 } 1705 }
1697 if (bytecmd) { 1706 if (bytecmd) {
@@ -1770,7 +1779,7 @@ static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
1770static unsigned termios2digi_i(struct channel *ch, unsigned iflag) 1779static unsigned termios2digi_i(struct channel *ch, unsigned iflag)
1771{ 1780{
1772 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | 1781 unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK |
1773 INPCK | ISTRIP|IXON|IXANY|IXOFF); 1782 INPCK | ISTRIP | IXON | IXANY | IXOFF);
1774 if (ch->digiext.digi_flags & DIGI_AIXON) 1783 if (ch->digiext.digi_flags & DIGI_AIXON)
1775 res |= IAIXON; 1784 res |= IAIXON;
1776 return res; 1785 return res;
@@ -1838,7 +1847,7 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
1838 unsigned mval, hflow, cflag, iflag; 1847 unsigned mval, hflow, cflag, iflag;
1839 1848
1840 bc = ch->brdchan; 1849 bc = ch->brdchan;
1841 epcaassert(bc !=0, "bc out of range"); 1850 epcaassert(bc != NULL, "bc out of range");
1842 1851
1843 assertgwinon(ch); 1852 assertgwinon(ch);
1844 ts = tty->termios; 1853 ts = tty->termios;
@@ -1884,8 +1893,10 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
1884 * Command sets channels iflag structure on the board. Such 1893 * Command sets channels iflag structure on the board. Such
1885 * things as input soft flow control, handling of parity 1894 * things as input soft flow control, handling of parity
1886 * errors, and break handling are all set here. 1895 * errors, and break handling are all set here.
1896 *
1897 * break handling, parity handling, input stripping,
1898 * flow control chars
1887 */ 1899 */
1888 /* break handling, parity handling, input stripping, flow control chars */
1889 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0); 1900 fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0);
1890 } 1901 }
1891 /* 1902 /*
@@ -1981,7 +1992,7 @@ static void receive_data(struct channel *ch)
1981 return; 1992 return;
1982 1993
1983 /* If CREAD bit is off or device not open, set TX tail to head */ 1994 /* If CREAD bit is off or device not open, set TX tail to head */
1984 if (!tty || !ts || !(ts->c_cflag & CREAD)) { 1995 if (!tty || !ts || !(ts->c_cflag & CREAD)) {
1985 writew(head, &bc->rout); 1996 writew(head, &bc->rout);
1986 return; 1997 return;
1987 } 1998 }
@@ -1991,18 +2002,21 @@ static void receive_data(struct channel *ch)
1991 2002
1992 if (readb(&bc->orun)) { 2003 if (readb(&bc->orun)) {
1993 writeb(0, &bc->orun); 2004 writeb(0, &bc->orun);
1994 printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",tty->name); 2005 printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",
2006 tty->name);
1995 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 2007 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
1996 } 2008 }
1997 rxwinon(ch); 2009 rxwinon(ch);
1998 while (bytesAvailable > 0) { /* Begin while there is data on the card */ 2010 while (bytesAvailable > 0) {
2011 /* Begin while there is data on the card */
1999 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail; 2012 wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;
2000 /* 2013 /*
2001 * Even if head has wrapped around only report the amount of 2014 * Even if head has wrapped around only report the amount of
2002 * data to be equal to the size - tail. Remember memcpy can't 2015 * data to be equal to the size - tail. Remember memcpy can't
2003 * automaticly wrap around the receive buffer. 2016 * automaticly wrap around the receive buffer.
2004 */ 2017 */
2005 dataToRead = (wrapgap < bytesAvailable) ? wrapgap : bytesAvailable; 2018 dataToRead = (wrapgap < bytesAvailable) ? wrapgap
2019 : bytesAvailable;
2006 /* Make sure we don't overflow the buffer */ 2020 /* Make sure we don't overflow the buffer */
2007 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead); 2021 dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead);
2008 if (dataToRead == 0) 2022 if (dataToRead == 0)
@@ -2153,14 +2167,14 @@ static int pc_tiocmset(struct tty_struct *tty, struct file *file,
2153 * The below routine generally sets up parity, baud, flow control 2167 * The below routine generally sets up parity, baud, flow control
2154 * issues, etc.... It effect both control flags and input flags. 2168 * issues, etc.... It effect both control flags and input flags.
2155 */ 2169 */
2156 epcaparam(tty,ch); 2170 epcaparam(tty, ch);
2157 memoff(ch); 2171 memoff(ch);
2158 spin_unlock_irqrestore(&epca_lock, flags); 2172 spin_unlock_irqrestore(&epca_lock, flags);
2159 return 0; 2173 return 0;
2160} 2174}
2161 2175
2162static int pc_ioctl(struct tty_struct *tty, struct file * file, 2176static int pc_ioctl(struct tty_struct *tty, struct file *file,
2163 unsigned int cmd, unsigned long arg) 2177 unsigned int cmd, unsigned long arg)
2164{ 2178{
2165 digiflow_t dflow; 2179 digiflow_t dflow;
2166 int retval; 2180 int retval;
@@ -2175,7 +2189,6 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2175 bc = ch->brdchan; 2189 bc = ch->brdchan;
2176 else 2190 else
2177 return -EINVAL; 2191 return -EINVAL;
2178
2179 /* 2192 /*
2180 * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in 2193 * For POSIX compliance we need to add more ioctls. See tty_ioctl.c in
2181 * /usr/src/linux/drivers/char for a good example. In particular think 2194 * /usr/src/linux/drivers/char for a good example. In particular think
@@ -2186,9 +2199,10 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2186 retval = tty_check_change(tty); 2199 retval = tty_check_change(tty);
2187 if (retval) 2200 if (retval)
2188 return retval; 2201 return retval;
2189 /* Setup an event to indicate when the transmit buffer empties */ 2202 /* Setup an event to indicate when the transmit
2203 buffer empties */
2190 spin_lock_irqsave(&epca_lock, flags); 2204 spin_lock_irqsave(&epca_lock, flags);
2191 setup_empty_event(tty,ch); 2205 setup_empty_event(tty, ch);
2192 spin_unlock_irqrestore(&epca_lock, flags); 2206 spin_unlock_irqrestore(&epca_lock, flags);
2193 tty_wait_until_sent(tty, 0); 2207 tty_wait_until_sent(tty, 0);
2194 if (!arg) 2208 if (!arg)
@@ -2198,29 +2212,14 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2198 retval = tty_check_change(tty); 2212 retval = tty_check_change(tty);
2199 if (retval) 2213 if (retval)
2200 return retval; 2214 return retval;
2201 2215 /* Setup an event to indicate when the transmit buffer
2202 /* Setup an event to indicate when the transmit buffer empties */ 2216 empties */
2203 spin_lock_irqsave(&epca_lock, flags); 2217 spin_lock_irqsave(&epca_lock, flags);
2204 setup_empty_event(tty,ch); 2218 setup_empty_event(tty, ch);
2205 spin_unlock_irqrestore(&epca_lock, flags); 2219 spin_unlock_irqrestore(&epca_lock, flags);
2206 tty_wait_until_sent(tty, 0); 2220 tty_wait_until_sent(tty, 0);
2207 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4); 2221 digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
2208 return 0; 2222 return 0;
2209 case TIOCGSOFTCAR:
2210 if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg))
2211 return -EFAULT;
2212 return 0;
2213 case TIOCSSOFTCAR:
2214 {
2215 unsigned int value;
2216
2217 if (get_user(value, (unsigned __user *)argp))
2218 return -EFAULT;
2219 tty->termios->c_cflag =
2220 ((tty->termios->c_cflag & ~CLOCAL) |
2221 (value ? CLOCAL : 0));
2222 return 0;
2223 }
2224 case TIOCMODG: 2223 case TIOCMODG:
2225 mflag = pc_tiocmget(tty, file); 2224 mflag = pc_tiocmget(tty, file);
2226 if (put_user(mflag, (unsigned long __user *)argp)) 2225 if (put_user(mflag, (unsigned long __user *)argp))
@@ -2253,10 +2252,12 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2253 break; 2252 break;
2254 case DIGI_SETAW: 2253 case DIGI_SETAW:
2255 case DIGI_SETAF: 2254 case DIGI_SETAF:
2255 lock_kernel();
2256 if (cmd == DIGI_SETAW) { 2256 if (cmd == DIGI_SETAW) {
2257 /* Setup an event to indicate when the transmit buffer empties */ 2257 /* Setup an event to indicate when the transmit
2258 buffer empties */
2258 spin_lock_irqsave(&epca_lock, flags); 2259 spin_lock_irqsave(&epca_lock, flags);
2259 setup_empty_event(tty,ch); 2260 setup_empty_event(tty, ch);
2260 spin_unlock_irqrestore(&epca_lock, flags); 2261 spin_unlock_irqrestore(&epca_lock, flags);
2261 tty_wait_until_sent(tty, 0); 2262 tty_wait_until_sent(tty, 0);
2262 } else { 2263 } else {
@@ -2264,6 +2265,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2264 if (tty->ldisc.flush_buffer) 2265 if (tty->ldisc.flush_buffer)
2265 tty->ldisc.flush_buffer(tty); 2266 tty->ldisc.flush_buffer(tty);
2266 } 2267 }
2268 unlock_kernel();
2267 /* Fall Thru */ 2269 /* Fall Thru */
2268 case DIGI_SETA: 2270 case DIGI_SETA:
2269 if (copy_from_user(&ch->digiext, argp, sizeof(digi_t))) 2271 if (copy_from_user(&ch->digiext, argp, sizeof(digi_t)))
@@ -2285,7 +2287,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2285 * control issues, etc.... It effect both control flags and 2287 * control issues, etc.... It effect both control flags and
2286 * input flags. 2288 * input flags.
2287 */ 2289 */
2288 epcaparam(tty,ch); 2290 epcaparam(tty, ch);
2289 memoff(ch); 2291 memoff(ch);
2290 spin_unlock_irqrestore(&epca_lock, flags); 2292 spin_unlock_irqrestore(&epca_lock, flags);
2291 break; 2293 break;
@@ -2321,18 +2323,21 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
2321 if (copy_from_user(&dflow, argp, sizeof(dflow))) 2323 if (copy_from_user(&dflow, argp, sizeof(dflow)))
2322 return -EFAULT; 2324 return -EFAULT;
2323 2325
2324 if (dflow.startc != startc || dflow.stopc != stopc) { /* Begin if setflow toggled */ 2326 if (dflow.startc != startc || dflow.stopc != stopc) {
2327 /* Begin if setflow toggled */
2325 spin_lock_irqsave(&epca_lock, flags); 2328 spin_lock_irqsave(&epca_lock, flags);
2326 globalwinon(ch); 2329 globalwinon(ch);
2327 2330
2328 if (cmd == DIGI_SETFLOW) { 2331 if (cmd == DIGI_SETFLOW) {
2329 ch->fepstartc = ch->startc = dflow.startc; 2332 ch->fepstartc = ch->startc = dflow.startc;
2330 ch->fepstopc = ch->stopc = dflow.stopc; 2333 ch->fepstopc = ch->stopc = dflow.stopc;
2331 fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1); 2334 fepcmd(ch, SONOFFC, ch->fepstartc,
2335 ch->fepstopc, 0, 1);
2332 } else { 2336 } else {
2333 ch->fepstartca = ch->startca = dflow.startc; 2337 ch->fepstartca = ch->startca = dflow.startc;
2334 ch->fepstopca = ch->stopca = dflow.stopc; 2338 ch->fepstopca = ch->stopca = dflow.stopc;
2335 fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1); 2339 fepcmd(ch, SAUXONOFFC, ch->fepstartca,
2340 ch->fepstopca, 0, 1);
2336 } 2341 }
2337 2342
2338 if (ch->statusflags & TXSTOPPED) 2343 if (ch->statusflags & TXSTOPPED)
@@ -2356,7 +2361,9 @@ static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
2356 * verifyChannel returns the channel from the tty struct if it is 2361 * verifyChannel returns the channel from the tty struct if it is
2357 * valid. This serves as a sanity check. 2362 * valid. This serves as a sanity check.
2358 */ 2363 */
2359 if ((ch = verifyChannel(tty)) != NULL) { /* Begin if channel valid */ 2364 ch = verifyChannel(tty);
2365
2366 if (ch != NULL) { /* Begin if channel valid */
2360 spin_lock_irqsave(&epca_lock, flags); 2367 spin_lock_irqsave(&epca_lock, flags);
2361 globalwinon(ch); 2368 globalwinon(ch);
2362 epcaparam(tty, ch); 2369 epcaparam(tty, ch);
@@ -2383,7 +2390,7 @@ static void do_softint(struct work_struct *work)
2383 2390
2384 if (tty && tty->driver_data) { 2391 if (tty && tty->driver_data) {
2385 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { 2392 if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
2386 tty_hangup(tty); /* FIXME: module removal race here - AKPM */ 2393 tty_hangup(tty);
2387 wake_up_interruptible(&ch->open_wait); 2394 wake_up_interruptible(&ch->open_wait);
2388 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; 2395 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
2389 } 2396 }
@@ -2403,9 +2410,11 @@ static void pc_stop(struct tty_struct *tty)
2403 * verifyChannel returns the channel from the tty struct if it is 2410 * verifyChannel returns the channel from the tty struct if it is
2404 * valid. This serves as a sanity check. 2411 * valid. This serves as a sanity check.
2405 */ 2412 */
2406 if ((ch = verifyChannel(tty)) != NULL) { 2413 ch = verifyChannel(tty);
2414 if (ch != NULL) {
2407 spin_lock_irqsave(&epca_lock, flags); 2415 spin_lock_irqsave(&epca_lock, flags);
2408 if ((ch->statusflags & TXSTOPPED) == 0) { /* Begin if transmit stop requested */ 2416 if ((ch->statusflags & TXSTOPPED) == 0) {
2417 /* Begin if transmit stop requested */
2409 globalwinon(ch); 2418 globalwinon(ch);
2410 /* STOP transmitting now !! */ 2419 /* STOP transmitting now !! */
2411 fepcmd(ch, PAUSETX, 0, 0, 0, 0); 2420 fepcmd(ch, PAUSETX, 0, 0, 0, 0);
@@ -2423,11 +2432,14 @@ static void pc_start(struct tty_struct *tty)
2423 * verifyChannel returns the channel from the tty struct if it is 2432 * verifyChannel returns the channel from the tty struct if it is
2424 * valid. This serves as a sanity check. 2433 * valid. This serves as a sanity check.
2425 */ 2434 */
2426 if ((ch = verifyChannel(tty)) != NULL) { 2435 ch = verifyChannel(tty);
2436 if (ch != NULL) {
2427 unsigned long flags; 2437 unsigned long flags;
2428 spin_lock_irqsave(&epca_lock, flags); 2438 spin_lock_irqsave(&epca_lock, flags);
2429 /* Just in case output was resumed because of a change in Digi-flow */ 2439 /* Just in case output was resumed because of a change
2430 if (ch->statusflags & TXSTOPPED) { /* Begin transmit resume requested */ 2440 in Digi-flow */
2441 if (ch->statusflags & TXSTOPPED) {
2442 /* Begin transmit resume requested */
2431 struct board_chan __iomem *bc; 2443 struct board_chan __iomem *bc;
2432 globalwinon(ch); 2444 globalwinon(ch);
2433 bc = ch->brdchan; 2445 bc = ch->brdchan;
@@ -2457,7 +2469,8 @@ static void pc_throttle(struct tty_struct *tty)
2457 * verifyChannel returns the channel from the tty struct if it is 2469 * verifyChannel returns the channel from the tty struct if it is
2458 * valid. This serves as a sanity check. 2470 * valid. This serves as a sanity check.
2459 */ 2471 */
2460 if ((ch = verifyChannel(tty)) != NULL) { 2472 ch = verifyChannel(tty);
2473 if (ch != NULL) {
2461 spin_lock_irqsave(&epca_lock, flags); 2474 spin_lock_irqsave(&epca_lock, flags);
2462 if ((ch->statusflags & RXSTOPPED) == 0) { 2475 if ((ch->statusflags & RXSTOPPED) == 0) {
2463 globalwinon(ch); 2476 globalwinon(ch);
@@ -2477,8 +2490,10 @@ static void pc_unthrottle(struct tty_struct *tty)
2477 * verifyChannel returns the channel from the tty struct if it is 2490 * verifyChannel returns the channel from the tty struct if it is
2478 * valid. This serves as a sanity check. 2491 * valid. This serves as a sanity check.
2479 */ 2492 */
2480 if ((ch = verifyChannel(tty)) != NULL) { 2493 ch = verifyChannel(tty);
2481 /* Just in case output was resumed because of a change in Digi-flow */ 2494 if (ch != NULL) {
2495 /* Just in case output was resumed because of a change
2496 in Digi-flow */
2482 spin_lock_irqsave(&epca_lock, flags); 2497 spin_lock_irqsave(&epca_lock, flags);
2483 if (ch->statusflags & RXSTOPPED) { 2498 if (ch->statusflags & RXSTOPPED) {
2484 globalwinon(ch); 2499 globalwinon(ch);
@@ -2490,7 +2505,7 @@ static void pc_unthrottle(struct tty_struct *tty)
2490 } 2505 }
2491} 2506}
2492 2507
2493void digi_send_break(struct channel *ch, int msec) 2508static void digi_send_break(struct channel *ch, int msec)
2494{ 2509{
2495 unsigned long flags; 2510 unsigned long flags;
2496 2511
@@ -2523,7 +2538,7 @@ static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
2523 memoff(ch); 2538 memoff(ch);
2524} 2539}
2525 2540
2526void epca_setup(char *str, int *ints) 2541static void epca_setup(char *str, int *ints)
2527{ 2542{
2528 struct board_info board; 2543 struct board_info board;
2529 int index, loop, last; 2544 int index, loop, last;
@@ -2552,14 +2567,16 @@ void epca_setup(char *str, int *ints)
2552 * instructing the driver to ignore epcaconfig.) For 2567 * instructing the driver to ignore epcaconfig.) For
2553 * this reason we check for 2. 2568 * this reason we check for 2.
2554 */ 2569 */
2555 if (board.status == 2) { /* Begin ignore epcaconfig as well as lilo cmd line */ 2570 if (board.status == 2) {
2571 /* Begin ignore epcaconfig as well as lilo cmd line */
2556 nbdevs = 0; 2572 nbdevs = 0;
2557 num_cards = 0; 2573 num_cards = 0;
2558 return; 2574 return;
2559 } /* End ignore epcaconfig as well as lilo cmd line */ 2575 } /* End ignore epcaconfig as well as lilo cmd line */
2560 2576
2561 if (board.status > 2) { 2577 if (board.status > 2) {
2562 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n", board.status); 2578 printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n",
2579 board.status);
2563 invalid_lilo_config = 1; 2580 invalid_lilo_config = 1;
2564 setup_error_code |= INVALID_BOARD_STATUS; 2581 setup_error_code |= INVALID_BOARD_STATUS;
2565 return; 2582 return;
@@ -2613,7 +2630,8 @@ void epca_setup(char *str, int *ints)
2613 case 6: 2630 case 6:
2614 board.membase = ints[index]; 2631 board.membase = ints[index];
2615 if (ints[index] <= 0) { 2632 if (ints[index] <= 0) {
2616 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",(unsigned int)board.membase); 2633 printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",
2634 (unsigned int)board.membase);
2617 invalid_lilo_config = 1; 2635 invalid_lilo_config = 1;
2618 setup_error_code |= INVALID_MEM_BASE; 2636 setup_error_code |= INVALID_MEM_BASE;
2619 return; 2637 return;
@@ -2744,7 +2762,7 @@ void epca_setup(char *str, int *ints)
2744 t2++; 2762 t2++;
2745 2763
2746 if (*t2) { 2764 if (*t2) {
2747 printk(KERN_ERR "epca_setup: Invalid memory base %s\n",str); 2765 printk(KERN_ERR "epca_setup: Invalid memory base %s\n", str);
2748 invalid_lilo_config = 1; 2766 invalid_lilo_config = 1;
2749 setup_error_code |= INVALID_MEM_BASE; 2767 setup_error_code |= INVALID_MEM_BASE;
2750 return; 2768 return;
@@ -2766,7 +2784,7 @@ void epca_setup(char *str, int *ints)
2766 2784
2767 /* I should REALLY validate the stuff here */ 2785 /* I should REALLY validate the stuff here */
2768 /* Copies our local copy of board into boards */ 2786 /* Copies our local copy of board into boards */
2769 memcpy((void *)&boards[num_cards],(void *)&board, sizeof(board)); 2787 memcpy((void *)&boards[num_cards], (void *)&board, sizeof(board));
2770 /* Does this get called once per lilo arg are what ? */ 2788 /* Does this get called once per lilo arg are what ? */
2771 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n", 2789 printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n",
2772 num_cards, board_desc[board.type], 2790 num_cards, board_desc[board.type],
@@ -2807,9 +2825,9 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2807 if (board_idx >= MAXBOARDS) 2825 if (board_idx >= MAXBOARDS)
2808 goto err_out; 2826 goto err_out;
2809 2827
2810 addr = pci_resource_start (pdev, epca_info_tbl[info_idx].bar_idx); 2828 addr = pci_resource_start(pdev, epca_info_tbl[info_idx].bar_idx);
2811 if (!addr) { 2829 if (!addr) {
2812 printk (KERN_ERR PFX "PCI region #%d not available (size 0)\n", 2830 printk(KERN_ERR PFX "PCI region #%d not available (size 0)\n",
2813 epca_info_tbl[info_idx].bar_idx); 2831 epca_info_tbl[info_idx].bar_idx);
2814 goto err_out; 2832 goto err_out;
2815 } 2833 }
@@ -2820,28 +2838,29 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2820 boards[board_idx].port = addr + PCI_IO_OFFSET; 2838 boards[board_idx].port = addr + PCI_IO_OFFSET;
2821 boards[board_idx].membase = addr; 2839 boards[board_idx].membase = addr;
2822 2840
2823 if (!request_mem_region (addr + PCI_IO_OFFSET, 0x200000, "epca")) { 2841 if (!request_mem_region(addr + PCI_IO_OFFSET, 0x200000, "epca")) {
2824 printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", 2842 printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
2825 0x200000, addr + PCI_IO_OFFSET); 2843 0x200000, addr + PCI_IO_OFFSET);
2826 goto err_out; 2844 goto err_out;
2827 } 2845 }
2828 2846
2829 boards[board_idx].re_map_port = ioremap(addr + PCI_IO_OFFSET, 0x200000); 2847 boards[board_idx].re_map_port = ioremap_nocache(addr + PCI_IO_OFFSET,
2848 0x200000);
2830 if (!boards[board_idx].re_map_port) { 2849 if (!boards[board_idx].re_map_port) {
2831 printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", 2850 printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
2832 0x200000, addr + PCI_IO_OFFSET); 2851 0x200000, addr + PCI_IO_OFFSET);
2833 goto err_out_free_pciio; 2852 goto err_out_free_pciio;
2834 } 2853 }
2835 2854
2836 if (!request_mem_region (addr, 0x200000, "epca")) { 2855 if (!request_mem_region(addr, 0x200000, "epca")) {
2837 printk (KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n", 2856 printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
2838 0x200000, addr); 2857 0x200000, addr);
2839 goto err_out_free_iounmap; 2858 goto err_out_free_iounmap;
2840 } 2859 }
2841 2860
2842 boards[board_idx].re_map_membase = ioremap(addr, 0x200000); 2861 boards[board_idx].re_map_membase = ioremap_nocache(addr, 0x200000);
2843 if (!boards[board_idx].re_map_membase) { 2862 if (!boards[board_idx].re_map_membase) {
2844 printk (KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n", 2863 printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
2845 0x200000, addr + PCI_IO_OFFSET); 2864 0x200000, addr + PCI_IO_OFFSET);
2846 goto err_out_free_memregion; 2865 goto err_out_free_memregion;
2847 } 2866 }
@@ -2858,11 +2877,11 @@ static int __devinit epca_init_one(struct pci_dev *pdev,
2858 return 0; 2877 return 0;
2859 2878
2860err_out_free_memregion: 2879err_out_free_memregion:
2861 release_mem_region (addr, 0x200000); 2880 release_mem_region(addr, 0x200000);
2862err_out_free_iounmap: 2881err_out_free_iounmap:
2863 iounmap (boards[board_idx].re_map_port); 2882 iounmap(boards[board_idx].re_map_port);
2864err_out_free_pciio: 2883err_out_free_pciio:
2865 release_mem_region (addr + PCI_IO_OFFSET, 0x200000); 2884 release_mem_region(addr + PCI_IO_OFFSET, 0x200000);
2866err_out: 2885err_out:
2867 return -ENODEV; 2886 return -ENODEV;
2868} 2887}
@@ -2878,9 +2897,9 @@ static struct pci_device_id epca_pci_tbl[] = {
2878 2897
2879MODULE_DEVICE_TABLE(pci, epca_pci_tbl); 2898MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
2880 2899
2881int __init init_PCI (void) 2900static int __init init_PCI(void)
2882{ 2901{
2883 memset (&epca_driver, 0, sizeof (epca_driver)); 2902 memset(&epca_driver, 0, sizeof(epca_driver));
2884 epca_driver.name = "epca"; 2903 epca_driver.name = "epca";
2885 epca_driver.id_table = epca_pci_tbl; 2904 epca_driver.id_table = epca_pci_tbl;
2886 epca_driver.probe = epca_init_one; 2905 epca_driver.probe = epca_init_one;
diff --git a/drivers/char/esp.c b/drivers/char/esp.c
index f3fe62067344..84840ba13ff0 100644
--- a/drivers/char/esp.c
+++ b/drivers/char/esp.c
@@ -8,7 +8,7 @@
8 * Extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92. Now 8 * Extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92. Now
9 * much more extensible to support other serial cards based on the 9 * much more extensible to support other serial cards based on the
10 * 16450/16550A UART's. Added support for the AST FourPort and the 10 * 16450/16550A UART's. Added support for the AST FourPort and the
11 * Accent Async board. 11 * Accent Async board.
12 * 12 *
13 * set_serial_info fixed to set the flags, custom divisor, and uart 13 * set_serial_info fixed to set the flags, custom divisor, and uart
14 * type fields. Fix suggested by Michael K. Johnson 12/12/92. 14 * type fields. Fix suggested by Michael K. Johnson 12/12/92.
@@ -61,11 +61,11 @@
61#include <linux/bitops.h> 61#include <linux/bitops.h>
62 62
63#include <asm/system.h> 63#include <asm/system.h>
64#include <asm/io.h> 64#include <linux/io.h>
65 65
66#include <asm/dma.h> 66#include <asm/dma.h>
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <asm/uaccess.h> 68#include <linux/uaccess.h>
69 69
70#include <linux/hayesesp.h> 70#include <linux/hayesesp.h>
71 71
@@ -127,8 +127,10 @@ static struct tty_driver *esp_driver;
127#undef SERIAL_DEBUG_FLOW 127#undef SERIAL_DEBUG_FLOW
128 128
129#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 129#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
130#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 130#define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
131 tty->name, (info->flags), serial_driver.refcount,info->count,tty->count,s) 131 tty->name, info->flags, \
132 serial_driver.refcount, \
133 info->count, tty->count, s)
132#else 134#else
133#define DBG_CNT(s) 135#define DBG_CNT(s)
134#endif 136#endif
@@ -189,7 +191,7 @@ static inline void serial_out(struct esp_struct *info, int offset,
189 */ 191 */
190static void rs_stop(struct tty_struct *tty) 192static void rs_stop(struct tty_struct *tty)
191{ 193{
192 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 194 struct esp_struct *info = tty->driver_data;
193 unsigned long flags; 195 unsigned long flags;
194 196
195 if (serial_paranoia_check(info, tty->name, "rs_stop")) 197 if (serial_paranoia_check(info, tty->name, "rs_stop"))
@@ -206,12 +208,12 @@ static void rs_stop(struct tty_struct *tty)
206 208
207static void rs_start(struct tty_struct *tty) 209static void rs_start(struct tty_struct *tty)
208{ 210{
209 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 211 struct esp_struct *info = tty->driver_data;
210 unsigned long flags; 212 unsigned long flags;
211 213
212 if (serial_paranoia_check(info, tty->name, "rs_start")) 214 if (serial_paranoia_check(info, tty->name, "rs_start"))
213 return; 215 return;
214 216
215 spin_lock_irqsave(&info->lock, flags); 217 spin_lock_irqsave(&info->lock, flags);
216 if (info->xmit_cnt && info->xmit_buf && !(info->IER & UART_IER_THRI)) { 218 if (info->xmit_cnt && info->xmit_buf && !(info->IER & UART_IER_THRI)) {
217 info->IER |= UART_IER_THRI; 219 info->IER |= UART_IER_THRI;
@@ -233,7 +235,7 @@ static void rs_start(struct tty_struct *tty)
233 * rs_interrupt() should try to keep the interrupt handler as fast as 235 * rs_interrupt() should try to keep the interrupt handler as fast as
234 * possible. After you are done making modifications, it is not a bad 236 * possible. After you are done making modifications, it is not a bad
235 * idea to do: 237 * idea to do:
236 * 238 *
237 * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c 239 * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
238 * 240 *
239 * and look at the resulting assemble code in serial.s. 241 * and look at the resulting assemble code in serial.s.
@@ -290,7 +292,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
290 } 292 }
291 293
292 status_mask = (info->read_status_mask >> 2) & 0x07; 294 status_mask = (info->read_status_mask >> 2) & 0x07;
293 295
294 for (i = 0; i < num_bytes - 1; i += 2) { 296 for (i = 0; i < num_bytes - 1; i += 2) {
295 *((unsigned short *)(pio_buf->data + i)) = 297 *((unsigned short *)(pio_buf->data + i)) =
296 inw(info->port + UART_ESI_RX); 298 inw(info->port + UART_ESI_RX);
@@ -325,8 +327,7 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
325 flag = TTY_BREAK; 327 flag = TTY_BREAK;
326 if (info->flags & ASYNC_SAK) 328 if (info->flags & ASYNC_SAK)
327 do_SAK(tty); 329 do_SAK(tty);
328 } 330 } else if (err_buf->data[i] & 0x02)
329 else if (err_buf->data[i] & 0x02)
330 flag = TTY_FRAME; 331 flag = TTY_FRAME;
331 else if (err_buf->data[i] & 0x01) 332 else if (err_buf->data[i] & 0x01)
332 flag = TTY_PARITY; 333 flag = TTY_PARITY;
@@ -341,23 +342,29 @@ static inline void receive_chars_pio(struct esp_struct *info, int num_bytes)
341 release_pio_buffer(err_buf); 342 release_pio_buffer(err_buf);
342} 343}
343 344
344static inline void receive_chars_dma(struct esp_struct *info, int num_bytes) 345static void program_isa_dma(int dma, int dir, unsigned long addr, int len)
345{ 346{
346 unsigned long flags; 347 unsigned long flags;
348
349 flags = claim_dma_lock();
350 disable_dma(dma);
351 clear_dma_ff(dma);
352 set_dma_mode(dma, dir);
353 set_dma_addr(dma, addr);
354 set_dma_count(dma, len);
355 enable_dma(dma);
356 release_dma_lock(flags);
357}
358
359static void receive_chars_dma(struct esp_struct *info, int num_bytes)
360{
347 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; 361 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT;
348 dma_bytes = num_bytes; 362 dma_bytes = num_bytes;
349 info->stat_flags |= ESP_STAT_DMA_RX; 363 info->stat_flags |= ESP_STAT_DMA_RX;
350 364
351 flags=claim_dma_lock(); 365 program_isa_dma(dma, DMA_MODE_READ, isa_virt_to_bus(dma_buffer),
352 disable_dma(dma); 366 dma_bytes);
353 clear_dma_ff(dma); 367 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX);
354 set_dma_mode(dma, DMA_MODE_READ);
355 set_dma_addr(dma, isa_virt_to_bus(dma_buffer));
356 set_dma_count(dma, dma_bytes);
357 enable_dma(dma);
358 release_dma_lock(flags);
359
360 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX);
361} 368}
362 369
363static inline void receive_chars_dma_done(struct esp_struct *info, 370static inline void receive_chars_dma_done(struct esp_struct *info,
@@ -366,22 +373,22 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
366 struct tty_struct *tty = info->tty; 373 struct tty_struct *tty = info->tty;
367 int num_bytes; 374 int num_bytes;
368 unsigned long flags; 375 unsigned long flags;
369 376
370 flags=claim_dma_lock(); 377 flags = claim_dma_lock();
371 disable_dma(dma); 378 disable_dma(dma);
372 clear_dma_ff(dma); 379 clear_dma_ff(dma);
373 380
374 info->stat_flags &= ~ESP_STAT_DMA_RX; 381 info->stat_flags &= ~ESP_STAT_DMA_RX;
375 num_bytes = dma_bytes - get_dma_residue(dma); 382 num_bytes = dma_bytes - get_dma_residue(dma);
376 release_dma_lock(flags); 383 release_dma_lock(flags);
377 384
378 info->icount.rx += num_bytes; 385 info->icount.rx += num_bytes;
379 386
380 if (num_bytes > 0) { 387 if (num_bytes > 0) {
381 tty_insert_flip_string(tty, dma_buffer, num_bytes - 1); 388 tty_insert_flip_string(tty, dma_buffer, num_bytes - 1);
382 389
383 status &= (0x1c & info->read_status_mask); 390 status &= (0x1c & info->read_status_mask);
384 391
385 /* Is the status significant or do we throw the last byte ? */ 392 /* Is the status significant or do we throw the last byte ? */
386 if (!(status & info->ignore_status_mask)) { 393 if (!(status & info->ignore_status_mask)) {
387 int statflag = 0; 394 int statflag = 0;
@@ -393,13 +400,13 @@ static inline void receive_chars_dma_done(struct esp_struct *info,
393 do_SAK(tty); 400 do_SAK(tty);
394 } else if (status & 0x08) { 401 } else if (status & 0x08) {
395 statflag = TTY_FRAME; 402 statflag = TTY_FRAME;
396 (info->icount.frame)++; 403 info->icount.frame++;
397 } 404 } else if (status & 0x04) {
398 else if (status & 0x04) {
399 statflag = TTY_PARITY; 405 statflag = TTY_PARITY;
400 (info->icount.parity)++; 406 info->icount.parity++;
401 } 407 }
402 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); 408 tty_insert_flip_char(tty, dma_buffer[num_bytes - 1],
409 statflag);
403 } 410 }
404 tty_schedule_flip(tty); 411 tty_schedule_flip(tty);
405 } 412 }
@@ -484,8 +491,6 @@ static inline void transmit_chars_pio(struct esp_struct *info,
484/* Caller must hold info->lock */ 491/* Caller must hold info->lock */
485static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) 492static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes)
486{ 493{
487 unsigned long flags;
488
489 dma_bytes = num_bytes; 494 dma_bytes = num_bytes;
490 495
491 if (info->xmit_tail + dma_bytes <= ESP_XMIT_SIZE) { 496 if (info->xmit_tail + dma_bytes <= ESP_XMIT_SIZE) {
@@ -517,26 +522,18 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes)
517 } 522 }
518 523
519 info->stat_flags |= ESP_STAT_DMA_TX; 524 info->stat_flags |= ESP_STAT_DMA_TX;
520 525
521 flags=claim_dma_lock(); 526 program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer),
522 disable_dma(dma); 527 dma_bytes);
523 clear_dma_ff(dma); 528 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX);
524 set_dma_mode(dma, DMA_MODE_WRITE);
525 set_dma_addr(dma, isa_virt_to_bus(dma_buffer));
526 set_dma_count(dma, dma_bytes);
527 enable_dma(dma);
528 release_dma_lock(flags);
529
530 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX);
531} 529}
532 530
533static inline void transmit_chars_dma_done(struct esp_struct *info) 531static inline void transmit_chars_dma_done(struct esp_struct *info)
534{ 532{
535 int num_bytes; 533 int num_bytes;
536 unsigned long flags; 534 unsigned long flags;
537
538 535
539 flags=claim_dma_lock(); 536 flags = claim_dma_lock();
540 disable_dma(dma); 537 disable_dma(dma);
541 clear_dma_ff(dma); 538 clear_dma_ff(dma);
542 539
@@ -547,27 +544,21 @@ static inline void transmit_chars_dma_done(struct esp_struct *info)
547 if (dma_bytes != num_bytes) { 544 if (dma_bytes != num_bytes) {
548 dma_bytes -= num_bytes; 545 dma_bytes -= num_bytes;
549 memmove(dma_buffer, dma_buffer + num_bytes, dma_bytes); 546 memmove(dma_buffer, dma_buffer + num_bytes, dma_bytes);
550 547
551 flags=claim_dma_lock(); 548 program_isa_dma(dma, DMA_MODE_WRITE,
552 disable_dma(dma); 549 isa_virt_to_bus(dma_buffer), dma_bytes);
553 clear_dma_ff(dma); 550
554 set_dma_mode(dma, DMA_MODE_WRITE); 551 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX);
555 set_dma_addr(dma, isa_virt_to_bus(dma_buffer));
556 set_dma_count(dma, dma_bytes);
557 enable_dma(dma);
558 release_dma_lock(flags);
559
560 serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX);
561 } else { 552 } else {
562 dma_bytes = 0; 553 dma_bytes = 0;
563 info->stat_flags &= ~ESP_STAT_DMA_TX; 554 info->stat_flags &= ~ESP_STAT_DMA_TX;
564 } 555 }
565} 556}
566 557
567static inline void check_modem_status(struct esp_struct *info) 558static void check_modem_status(struct esp_struct *info)
568{ 559{
569 int status; 560 int status;
570 561
571 serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT); 562 serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT);
572 status = serial_in(info, UART_ESI_STAT2); 563 status = serial_in(info, UART_ESI_STAT2);
573 564
@@ -588,7 +579,7 @@ static inline void check_modem_status(struct esp_struct *info)
588#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) 579#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
589 printk("ttys%d CD now %s...", info->line, 580 printk("ttys%d CD now %s...", info->line,
590 (status & UART_MSR_DCD) ? "on" : "off"); 581 (status & UART_MSR_DCD) ? "on" : "off");
591#endif 582#endif
592 if (status & UART_MSR_DCD) 583 if (status & UART_MSR_DCD)
593 wake_up_interruptible(&info->open_wait); 584 wake_up_interruptible(&info->open_wait);
594 else { 585 else {
@@ -605,7 +596,7 @@ static inline void check_modem_status(struct esp_struct *info)
605 */ 596 */
606static irqreturn_t rs_interrupt_single(int irq, void *dev_id) 597static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
607{ 598{
608 struct esp_struct * info; 599 struct esp_struct *info;
609 unsigned err_status; 600 unsigned err_status;
610 unsigned int scratch; 601 unsigned int scratch;
611 602
@@ -617,7 +608,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
617 scratch = serial_in(info, UART_ESI_SID); 608 scratch = serial_in(info, UART_ESI_SID);
618 609
619 spin_lock(&info->lock); 610 spin_lock(&info->lock);
620 611
621 if (!info->tty) { 612 if (!info->tty) {
622 spin_unlock(&info->lock); 613 spin_unlock(&info->lock);
623 return IRQ_NONE; 614 return IRQ_NONE;
@@ -637,7 +628,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
637 if (err_status & 0x80) /* Start break */ 628 if (err_status & 0x80) /* Start break */
638 wake_up_interruptible(&info->break_wait); 629 wake_up_interruptible(&info->break_wait);
639 } 630 }
640 631
641 if ((scratch & 0x88) || /* DMA completed or timed out */ 632 if ((scratch & 0x88) || /* DMA completed or timed out */
642 (err_status & 0x1c) /* receive error */) { 633 (err_status & 0x1c) /* receive error */) {
643 if (info->stat_flags & ESP_STAT_DMA_RX) 634 if (info->stat_flags & ESP_STAT_DMA_RX)
@@ -667,7 +658,7 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
667 receive_chars_dma(info, num_bytes); 658 receive_chars_dma(info, num_bytes);
668 } 659 }
669 } 660 }
670 661
671 if (!(info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) && 662 if (!(info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) &&
672 (scratch & 0x02) && (info->IER & UART_IER_THRI)) { 663 (scratch & 0x02) && (info->IER & UART_IER_THRI)) {
673 if ((info->xmit_cnt <= 0) || info->tty->stopped) { 664 if ((info->xmit_cnt <= 0) || info->tty->stopped) {
@@ -722,11 +713,11 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
722 * --------------------------------------------------------------- 713 * ---------------------------------------------------------------
723 */ 714 */
724 715
725static inline void esp_basic_init(struct esp_struct * info) 716static void esp_basic_init(struct esp_struct *info)
726{ 717{
727 /* put ESPC in enhanced mode */ 718 /* put ESPC in enhanced mode */
728 serial_out(info, UART_ESI_CMD1, ESI_SET_MODE); 719 serial_out(info, UART_ESI_CMD1, ESI_SET_MODE);
729 720
730 if (info->stat_flags & ESP_STAT_NEVER_DMA) 721 if (info->stat_flags & ESP_STAT_NEVER_DMA)
731 serial_out(info, UART_ESI_CMD2, 0x01); 722 serial_out(info, UART_ESI_CMD2, 0x01);
732 else 723 else
@@ -783,13 +774,13 @@ static inline void esp_basic_init(struct esp_struct * info)
783 serial_out(info, UART_ESI_CMD2, 0xff); 774 serial_out(info, UART_ESI_CMD2, 0xff);
784} 775}
785 776
786static int startup(struct esp_struct * info) 777static int startup(struct esp_struct *info)
787{ 778{
788 unsigned long flags; 779 unsigned long flags;
789 int retval=0; 780 int retval = 0;
790 unsigned int num_chars; 781 unsigned int num_chars;
791 782
792 spin_lock_irqsave(&info->lock, flags); 783 spin_lock_irqsave(&info->lock, flags);
793 784
794 if (info->flags & ASYNC_INITIALIZED) 785 if (info->flags & ASYNC_INITIALIZED)
795 goto out; 786 goto out;
@@ -802,7 +793,8 @@ static int startup(struct esp_struct * info)
802 } 793 }
803 794
804#ifdef SERIAL_DEBUG_OPEN 795#ifdef SERIAL_DEBUG_OPEN
805 printk("starting up ttys%d (irq %d)...", info->line, info->irq); 796 printk(KERN_DEBUG "starting up ttys%d (irq %d)...",
797 info->line, info->irq);
806#endif 798#endif
807 799
808 /* Flush the RX buffer. Using the ESI flush command may cause */ 800 /* Flush the RX buffer. Using the ESI flush command may cause */
@@ -863,7 +855,7 @@ static int startup(struct esp_struct * info)
863 dma_buffer = NULL; 855 dma_buffer = NULL;
864 info->stat_flags |= ESP_STAT_USE_PIO; 856 info->stat_flags |= ESP_STAT_USE_PIO;
865 } 857 }
866 858
867 } 859 }
868 860
869 info->MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; 861 info->MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2;
@@ -872,7 +864,7 @@ static int startup(struct esp_struct * info)
872 serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART); 864 serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART);
873 serial_out(info, UART_ESI_CMD2, UART_MCR); 865 serial_out(info, UART_ESI_CMD2, UART_MCR);
874 serial_out(info, UART_ESI_CMD2, info->MCR); 866 serial_out(info, UART_ESI_CMD2, info->MCR);
875 867
876 /* 868 /*
877 * Finally, enable interrupts 869 * Finally, enable interrupts
878 */ 870 */
@@ -881,7 +873,7 @@ static int startup(struct esp_struct * info)
881 UART_IER_DMA_TC; 873 UART_IER_DMA_TC;
882 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK); 874 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
883 serial_out(info, UART_ESI_CMD2, info->IER); 875 serial_out(info, UART_ESI_CMD2, info->IER);
884 876
885 if (info->tty) 877 if (info->tty)
886 clear_bit(TTY_IO_ERROR, &info->tty->flags); 878 clear_bit(TTY_IO_ERROR, &info->tty->flags);
887 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 879 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
@@ -900,7 +892,7 @@ static int startup(struct esp_struct * info)
900 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 892 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
901 info->tty->alt_speed = 460800; 893 info->tty->alt_speed = 460800;
902 } 894 }
903 895
904 /* 896 /*
905 * set the speed of the serial port 897 * set the speed of the serial port
906 */ 898 */
@@ -918,7 +910,7 @@ out_unlocked:
918 * This routine will shutdown a serial port; interrupts are disabled, and 910 * This routine will shutdown a serial port; interrupts are disabled, and
919 * DTR is dropped if the hangup on close termio flag is on. 911 * DTR is dropped if the hangup on close termio flag is on.
920 */ 912 */
921static void shutdown(struct esp_struct * info) 913static void shutdown(struct esp_struct *info)
922{ 914{
923 unsigned long flags, f; 915 unsigned long flags, f;
924 916
@@ -929,7 +921,7 @@ static void shutdown(struct esp_struct * info)
929 printk("Shutting down serial port %d (irq %d)....", info->line, 921 printk("Shutting down serial port %d (irq %d)....", info->line,
930 info->irq); 922 info->irq);
931#endif 923#endif
932 924
933 spin_lock_irqsave(&info->lock, flags); 925 spin_lock_irqsave(&info->lock, flags);
934 /* 926 /*
935 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq 927 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
@@ -941,14 +933,14 @@ static void shutdown(struct esp_struct * info)
941 /* stop a DMA transfer on the port being closed */ 933 /* stop a DMA transfer on the port being closed */
942 /* DMA lock is higher priority always */ 934 /* DMA lock is higher priority always */
943 if (info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) { 935 if (info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) {
944 f=claim_dma_lock(); 936 f = claim_dma_lock();
945 disable_dma(dma); 937 disable_dma(dma);
946 clear_dma_ff(dma); 938 clear_dma_ff(dma);
947 release_dma_lock(f); 939 release_dma_lock(f);
948 940
949 dma_bytes = 0; 941 dma_bytes = 0;
950 } 942 }
951 943
952 /* 944 /*
953 * Free the IRQ 945 * Free the IRQ
954 */ 946 */
@@ -970,7 +962,7 @@ static void shutdown(struct esp_struct * info)
970 free_pages((unsigned long)dma_buffer, 962 free_pages((unsigned long)dma_buffer,
971 get_order(DMA_BUFFER_SZ)); 963 get_order(DMA_BUFFER_SZ));
972 dma_buffer = NULL; 964 dma_buffer = NULL;
973 } 965 }
974 } 966 }
975 967
976 if (info->xmit_buf) { 968 if (info->xmit_buf) {
@@ -992,7 +984,7 @@ static void shutdown(struct esp_struct * info)
992 984
993 if (info->tty) 985 if (info->tty)
994 set_bit(TTY_IO_ERROR, &info->tty->flags); 986 set_bit(TTY_IO_ERROR, &info->tty->flags);
995 987
996 info->flags &= ~ASYNC_INITIALIZED; 988 info->flags &= ~ASYNC_INITIALIZED;
997 spin_unlock_irqrestore(&info->lock, flags); 989 spin_unlock_irqrestore(&info->lock, flags);
998} 990}
@@ -1005,7 +997,7 @@ static void change_speed(struct esp_struct *info)
1005{ 997{
1006 unsigned short port; 998 unsigned short port;
1007 int quot = 0; 999 int quot = 0;
1008 unsigned cflag,cval; 1000 unsigned cflag, cval;
1009 int baud, bits; 1001 int baud, bits;
1010 unsigned char flow1 = 0, flow2 = 0; 1002 unsigned char flow1 = 0, flow2 = 0;
1011 unsigned long flags; 1003 unsigned long flags;
@@ -1014,14 +1006,14 @@ static void change_speed(struct esp_struct *info)
1014 return; 1006 return;
1015 cflag = info->tty->termios->c_cflag; 1007 cflag = info->tty->termios->c_cflag;
1016 port = info->port; 1008 port = info->port;
1017 1009
1018 /* byte size and parity */ 1010 /* byte size and parity */
1019 switch (cflag & CSIZE) { 1011 switch (cflag & CSIZE) {
1020 case CS5: cval = 0x00; bits = 7; break; 1012 case CS5: cval = 0x00; bits = 7; break;
1021 case CS6: cval = 0x01; bits = 8; break; 1013 case CS6: cval = 0x01; bits = 8; break;
1022 case CS7: cval = 0x02; bits = 9; break; 1014 case CS7: cval = 0x02; bits = 9; break;
1023 case CS8: cval = 0x03; bits = 10; break; 1015 case CS8: cval = 0x03; bits = 10; break;
1024 default: cval = 0x00; bits = 7; break; 1016 default: cval = 0x00; bits = 7; break;
1025 } 1017 }
1026 if (cflag & CSTOPB) { 1018 if (cflag & CSTOPB) {
1027 cval |= 0x04; 1019 cval |= 0x04;
@@ -1037,14 +1029,12 @@ static void change_speed(struct esp_struct *info)
1037 if (cflag & CMSPAR) 1029 if (cflag & CMSPAR)
1038 cval |= UART_LCR_SPAR; 1030 cval |= UART_LCR_SPAR;
1039#endif 1031#endif
1040
1041 baud = tty_get_baud_rate(info->tty); 1032 baud = tty_get_baud_rate(info->tty);
1042 if (baud == 38400 && 1033 if (baud == 38400 &&
1043 ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) 1034 ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
1044 quot = info->custom_divisor; 1035 quot = info->custom_divisor;
1045 else { 1036 else {
1046 if (baud == 134) 1037 if (baud == 134) /* Special case since 134 is really 134.5 */
1047 /* Special case since 134 is really 134.5 */
1048 quot = (2*BASE_BAUD / 269); 1038 quot = (2*BASE_BAUD / 269);
1049 else if (baud) 1039 else if (baud)
1050 quot = BASE_BAUD / baud; 1040 quot = BASE_BAUD / baud;
@@ -1052,7 +1042,12 @@ static void change_speed(struct esp_struct *info)
1052 /* If the quotient is ever zero, default to 9600 bps */ 1042 /* If the quotient is ever zero, default to 9600 bps */
1053 if (!quot) 1043 if (!quot)
1054 quot = BASE_BAUD / 9600; 1044 quot = BASE_BAUD / 9600;
1055 1045
1046 if (baud) {
1047 /* Actual rate */
1048 baud = BASE_BAUD/quot;
1049 tty_encode_baud_rate(info->tty, baud, baud);
1050 }
1056 info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50); 1051 info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50);
1057 1052
1058 /* CTS flow control flag and modem status interrupts */ 1053 /* CTS flow control flag and modem status interrupts */
@@ -1066,10 +1061,8 @@ static void change_speed(struct esp_struct *info)
1066 info->flags &= ~ASYNC_CTS_FLOW; 1061 info->flags &= ~ASYNC_CTS_FLOW;
1067 if (cflag & CLOCAL) 1062 if (cflag & CLOCAL)
1068 info->flags &= ~ASYNC_CHECK_CD; 1063 info->flags &= ~ASYNC_CHECK_CD;
1069 else { 1064 else
1070 info->flags |= ASYNC_CHECK_CD; 1065 info->flags |= ASYNC_CHECK_CD;
1071 /* info->IER |= UART_IER_MSI; */
1072 }
1073 1066
1074 /* 1067 /*
1075 * Set up parity check flag 1068 * Set up parity check flag
@@ -1079,7 +1072,7 @@ static void change_speed(struct esp_struct *info)
1079 info->read_status_mask |= UART_LSR_FE | UART_LSR_PE; 1072 info->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
1080 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 1073 if (I_BRKINT(info->tty) || I_PARMRK(info->tty))
1081 info->read_status_mask |= UART_LSR_BI; 1074 info->read_status_mask |= UART_LSR_BI;
1082 1075
1083 info->ignore_status_mask = 0; 1076 info->ignore_status_mask = 0;
1084#if 0 1077#if 0
1085 /* This should be safe, but for some broken bits of hardware... */ 1078 /* This should be safe, but for some broken bits of hardware... */
@@ -1092,7 +1085,7 @@ static void change_speed(struct esp_struct *info)
1092 info->ignore_status_mask |= UART_LSR_BI; 1085 info->ignore_status_mask |= UART_LSR_BI;
1093 info->read_status_mask |= UART_LSR_BI; 1086 info->read_status_mask |= UART_LSR_BI;
1094 /* 1087 /*
1095 * If we're ignore parity and break indicators, ignore 1088 * If we're ignore parity and break indicators, ignore
1096 * overruns too. (For real raw support). 1089 * overruns too. (For real raw support).
1097 */ 1090 */
1098 if (I_IGNPAR(info->tty)) { 1091 if (I_IGNPAR(info->tty)) {
@@ -1130,19 +1123,19 @@ static void change_speed(struct esp_struct *info)
1130 serial_out(info, UART_ESI_CMD2, 0x10); 1123 serial_out(info, UART_ESI_CMD2, 0x10);
1131 serial_out(info, UART_ESI_CMD2, 0x21); 1124 serial_out(info, UART_ESI_CMD2, 0x21);
1132 switch (cflag & CSIZE) { 1125 switch (cflag & CSIZE) {
1133 case CS5: 1126 case CS5:
1134 serial_out(info, UART_ESI_CMD2, 0x1f); 1127 serial_out(info, UART_ESI_CMD2, 0x1f);
1135 break; 1128 break;
1136 case CS6: 1129 case CS6:
1137 serial_out(info, UART_ESI_CMD2, 0x3f); 1130 serial_out(info, UART_ESI_CMD2, 0x3f);
1138 break; 1131 break;
1139 case CS7: 1132 case CS7:
1140 case CS8: 1133 case CS8:
1141 serial_out(info, UART_ESI_CMD2, 0x7f); 1134 serial_out(info, UART_ESI_CMD2, 0x7f);
1142 break; 1135 break;
1143 default: 1136 default:
1144 serial_out(info, UART_ESI_CMD2, 0xff); 1137 serial_out(info, UART_ESI_CMD2, 0xff);
1145 break; 1138 break;
1146 } 1139 }
1147 } 1140 }
1148 1141
@@ -1156,31 +1149,34 @@ static void change_speed(struct esp_struct *info)
1156 spin_unlock_irqrestore(&info->lock, flags); 1149 spin_unlock_irqrestore(&info->lock, flags);
1157} 1150}
1158 1151
1159static void rs_put_char(struct tty_struct *tty, unsigned char ch) 1152static int rs_put_char(struct tty_struct *tty, unsigned char ch)
1160{ 1153{
1161 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1154 struct esp_struct *info = tty->driver_data;
1162 unsigned long flags; 1155 unsigned long flags;
1156 int ret = 0;
1163 1157
1164 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 1158 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
1165 return; 1159 return 0;
1166 1160
1167 if (!info->xmit_buf) 1161 if (!info->xmit_buf)
1168 return; 1162 return 0;
1169 1163
1170 spin_lock_irqsave(&info->lock, flags); 1164 spin_lock_irqsave(&info->lock, flags);
1171 if (info->xmit_cnt < ESP_XMIT_SIZE - 1) { 1165 if (info->xmit_cnt < ESP_XMIT_SIZE - 1) {
1172 info->xmit_buf[info->xmit_head++] = ch; 1166 info->xmit_buf[info->xmit_head++] = ch;
1173 info->xmit_head &= ESP_XMIT_SIZE-1; 1167 info->xmit_head &= ESP_XMIT_SIZE-1;
1174 info->xmit_cnt++; 1168 info->xmit_cnt++;
1169 ret = 1;
1175 } 1170 }
1176 spin_unlock_irqrestore(&info->lock, flags); 1171 spin_unlock_irqrestore(&info->lock, flags);
1172 return ret;
1177} 1173}
1178 1174
1179static void rs_flush_chars(struct tty_struct *tty) 1175static void rs_flush_chars(struct tty_struct *tty)
1180{ 1176{
1181 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1177 struct esp_struct *info = tty->driver_data;
1182 unsigned long flags; 1178 unsigned long flags;
1183 1179
1184 if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) 1180 if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
1185 return; 1181 return;
1186 1182
@@ -1198,11 +1194,11 @@ out:
1198 spin_unlock_irqrestore(&info->lock, flags); 1194 spin_unlock_irqrestore(&info->lock, flags);
1199} 1195}
1200 1196
1201static int rs_write(struct tty_struct * tty, 1197static int rs_write(struct tty_struct *tty,
1202 const unsigned char *buf, int count) 1198 const unsigned char *buf, int count)
1203{ 1199{
1204 int c, t, ret = 0; 1200 int c, t, ret = 0;
1205 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1201 struct esp_struct *info = tty->driver_data;
1206 unsigned long flags; 1202 unsigned long flags;
1207 1203
1208 if (serial_paranoia_check(info, tty->name, "rs_write")) 1204 if (serial_paranoia_check(info, tty->name, "rs_write"))
@@ -1210,19 +1206,19 @@ static int rs_write(struct tty_struct * tty,
1210 1206
1211 if (!info->xmit_buf) 1207 if (!info->xmit_buf)
1212 return 0; 1208 return 0;
1213 1209
1214 while (1) { 1210 while (1) {
1215 /* Thanks to R. Wolff for suggesting how to do this with */ 1211 /* Thanks to R. Wolff for suggesting how to do this with */
1216 /* interrupts enabled */ 1212 /* interrupts enabled */
1217 1213
1218 c = count; 1214 c = count;
1219 t = ESP_XMIT_SIZE - info->xmit_cnt - 1; 1215 t = ESP_XMIT_SIZE - info->xmit_cnt - 1;
1220 1216
1221 if (t < c) 1217 if (t < c)
1222 c = t; 1218 c = t;
1223 1219
1224 t = ESP_XMIT_SIZE - info->xmit_head; 1220 t = ESP_XMIT_SIZE - info->xmit_head;
1225 1221
1226 if (t < c) 1222 if (t < c)
1227 c = t; 1223 c = t;
1228 1224
@@ -1252,10 +1248,10 @@ static int rs_write(struct tty_struct * tty,
1252 1248
1253static int rs_write_room(struct tty_struct *tty) 1249static int rs_write_room(struct tty_struct *tty)
1254{ 1250{
1255 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1251 struct esp_struct *info = tty->driver_data;
1256 int ret; 1252 int ret;
1257 unsigned long flags; 1253 unsigned long flags;
1258 1254
1259 if (serial_paranoia_check(info, tty->name, "rs_write_room")) 1255 if (serial_paranoia_check(info, tty->name, "rs_write_room"))
1260 return 0; 1256 return 0;
1261 1257
@@ -1270,8 +1266,8 @@ static int rs_write_room(struct tty_struct *tty)
1270 1266
1271static int rs_chars_in_buffer(struct tty_struct *tty) 1267static int rs_chars_in_buffer(struct tty_struct *tty)
1272{ 1268{
1273 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1269 struct esp_struct *info = tty->driver_data;
1274 1270
1275 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) 1271 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
1276 return 0; 1272 return 0;
1277 return info->xmit_cnt; 1273 return info->xmit_cnt;
@@ -1279,9 +1275,9 @@ static int rs_chars_in_buffer(struct tty_struct *tty)
1279 1275
1280static void rs_flush_buffer(struct tty_struct *tty) 1276static void rs_flush_buffer(struct tty_struct *tty)
1281{ 1277{
1282 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1278 struct esp_struct *info = tty->driver_data;
1283 unsigned long flags; 1279 unsigned long flags;
1284 1280
1285 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 1281 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
1286 return; 1282 return;
1287 spin_lock_irqsave(&info->lock, flags); 1283 spin_lock_irqsave(&info->lock, flags);
@@ -1293,20 +1289,20 @@ static void rs_flush_buffer(struct tty_struct *tty)
1293/* 1289/*
1294 * ------------------------------------------------------------ 1290 * ------------------------------------------------------------
1295 * rs_throttle() 1291 * rs_throttle()
1296 * 1292 *
1297 * This routine is called by the upper-layer tty layer to signal that 1293 * This routine is called by the upper-layer tty layer to signal that
1298 * incoming characters should be throttled. 1294 * incoming characters should be throttled.
1299 * ------------------------------------------------------------ 1295 * ------------------------------------------------------------
1300 */ 1296 */
1301static void rs_throttle(struct tty_struct * tty) 1297static void rs_throttle(struct tty_struct *tty)
1302{ 1298{
1303 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1299 struct esp_struct *info = tty->driver_data;
1304 unsigned long flags; 1300 unsigned long flags;
1305#ifdef SERIAL_DEBUG_THROTTLE 1301#ifdef SERIAL_DEBUG_THROTTLE
1306 char buf[64]; 1302 char buf[64];
1307 1303
1308 printk("throttle %s: %d....\n", tty_name(tty, buf), 1304 printk("throttle %s: %d....\n", tty_name(tty, buf),
1309 tty->ldisc.chars_in_buffer(tty)); 1305 tty_chars_in_buffer(tty));
1310#endif 1306#endif
1311 1307
1312 if (serial_paranoia_check(info, tty->name, "rs_throttle")) 1308 if (serial_paranoia_check(info, tty->name, "rs_throttle"))
@@ -1321,20 +1317,20 @@ static void rs_throttle(struct tty_struct * tty)
1321 spin_unlock_irqrestore(&info->lock, flags); 1317 spin_unlock_irqrestore(&info->lock, flags);
1322} 1318}
1323 1319
1324static void rs_unthrottle(struct tty_struct * tty) 1320static void rs_unthrottle(struct tty_struct *tty)
1325{ 1321{
1326 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1322 struct esp_struct *info = tty->driver_data;
1327 unsigned long flags; 1323 unsigned long flags;
1328#ifdef SERIAL_DEBUG_THROTTLE 1324#ifdef SERIAL_DEBUG_THROTTLE
1329 char buf[64]; 1325 char buf[64];
1330 1326
1331 printk("unthrottle %s: %d....\n", tty_name(tty, buf), 1327 printk(KERN_DEBUG "unthrottle %s: %d....\n", tty_name(tty, buf),
1332 tty->ldisc.chars_in_buffer(tty)); 1328 tty_chars_in_buffer(tty));
1333#endif 1329#endif
1334 1330
1335 if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) 1331 if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
1336 return; 1332 return;
1337 1333
1338 spin_lock_irqsave(&info->lock, flags); 1334 spin_lock_irqsave(&info->lock, flags);
1339 info->IER |= UART_IER_RDI; 1335 info->IER |= UART_IER_RDI;
1340 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK); 1336 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK);
@@ -1350,11 +1346,12 @@ static void rs_unthrottle(struct tty_struct * tty)
1350 * ------------------------------------------------------------ 1346 * ------------------------------------------------------------
1351 */ 1347 */
1352 1348
1353static int get_serial_info(struct esp_struct * info, 1349static int get_serial_info(struct esp_struct *info,
1354 struct serial_struct __user *retinfo) 1350 struct serial_struct __user *retinfo)
1355{ 1351{
1356 struct serial_struct tmp; 1352 struct serial_struct tmp;
1357 1353
1354 lock_kernel();
1358 memset(&tmp, 0, sizeof(tmp)); 1355 memset(&tmp, 0, sizeof(tmp));
1359 tmp.type = PORT_16550A; 1356 tmp.type = PORT_16550A;
1360 tmp.line = info->line; 1357 tmp.line = info->line;
@@ -1367,20 +1364,22 @@ static int get_serial_info(struct esp_struct * info,
1367 tmp.closing_wait = info->closing_wait; 1364 tmp.closing_wait = info->closing_wait;
1368 tmp.custom_divisor = info->custom_divisor; 1365 tmp.custom_divisor = info->custom_divisor;
1369 tmp.hub6 = 0; 1366 tmp.hub6 = 0;
1370 if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1367 unlock_kernel();
1368 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
1371 return -EFAULT; 1369 return -EFAULT;
1372 return 0; 1370 return 0;
1373} 1371}
1374 1372
1375static int get_esp_config(struct esp_struct * info, 1373static int get_esp_config(struct esp_struct *info,
1376 struct hayes_esp_config __user *retinfo) 1374 struct hayes_esp_config __user *retinfo)
1377{ 1375{
1378 struct hayes_esp_config tmp; 1376 struct hayes_esp_config tmp;
1379 1377
1380 if (!retinfo) 1378 if (!retinfo)
1381 return -EFAULT; 1379 return -EFAULT;
1382 1380
1383 memset(&tmp, 0, sizeof(tmp)); 1381 memset(&tmp, 0, sizeof(tmp));
1382 lock_kernel();
1384 tmp.rx_timeout = info->config.rx_timeout; 1383 tmp.rx_timeout = info->config.rx_timeout;
1385 tmp.rx_trigger = info->config.rx_trigger; 1384 tmp.rx_trigger = info->config.rx_trigger;
1386 tmp.tx_trigger = info->config.tx_trigger; 1385 tmp.tx_trigger = info->config.tx_trigger;
@@ -1388,11 +1387,12 @@ static int get_esp_config(struct esp_struct * info,
1388 tmp.flow_on = info->config.flow_on; 1387 tmp.flow_on = info->config.flow_on;
1389 tmp.pio_threshold = info->config.pio_threshold; 1388 tmp.pio_threshold = info->config.pio_threshold;
1390 tmp.dma_channel = (info->stat_flags & ESP_STAT_NEVER_DMA ? 0 : dma); 1389 tmp.dma_channel = (info->stat_flags & ESP_STAT_NEVER_DMA ? 0 : dma);
1390 unlock_kernel();
1391 1391
1392 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 1392 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
1393} 1393}
1394 1394
1395static int set_serial_info(struct esp_struct * info, 1395static int set_serial_info(struct esp_struct *info,
1396 struct serial_struct __user *new_info) 1396 struct serial_struct __user *new_info)
1397{ 1397{
1398 struct serial_struct new_serial; 1398 struct serial_struct new_serial;
@@ -1401,7 +1401,7 @@ static int set_serial_info(struct esp_struct * info,
1401 int retval = 0; 1401 int retval = 0;
1402 struct esp_struct *current_async; 1402 struct esp_struct *current_async;
1403 1403
1404 if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1404 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
1405 return -EFAULT; 1405 return -EFAULT;
1406 old_info = *info; 1406 old_info = *info;
1407 1407
@@ -1422,7 +1422,7 @@ static int set_serial_info(struct esp_struct * info,
1422 return -EINVAL; 1422 return -EINVAL;
1423 1423
1424 if (!capable(CAP_SYS_ADMIN)) { 1424 if (!capable(CAP_SYS_ADMIN)) {
1425 if (change_irq || 1425 if (change_irq ||
1426 (new_serial.close_delay != info->close_delay) || 1426 (new_serial.close_delay != info->close_delay) ||
1427 ((new_serial.flags & ~ASYNC_USR_MASK) != 1427 ((new_serial.flags & ~ASYNC_USR_MASK) !=
1428 (info->flags & ~ASYNC_USR_MASK))) 1428 (info->flags & ~ASYNC_USR_MASK)))
@@ -1507,8 +1507,8 @@ static int set_serial_info(struct esp_struct * info,
1507 return retval; 1507 return retval;
1508} 1508}
1509 1509
1510static int set_esp_config(struct esp_struct * info, 1510static int set_esp_config(struct esp_struct *info,
1511 struct hayes_esp_config __user * new_info) 1511 struct hayes_esp_config __user *new_info)
1512{ 1512{
1513 struct hayes_esp_config new_config; 1513 struct hayes_esp_config new_config;
1514 unsigned int change_dma; 1514 unsigned int change_dma;
@@ -1550,7 +1550,6 @@ static int set_esp_config(struct esp_struct * info,
1550 if (new_config.dma_channel) { 1550 if (new_config.dma_channel) {
1551 /* PIO mode to DMA mode transition OR */ 1551 /* PIO mode to DMA mode transition OR */
1552 /* change current DMA channel */ 1552 /* change current DMA channel */
1553
1554 current_async = ports; 1553 current_async = ports;
1555 1554
1556 while (current_async) { 1555 while (current_async) {
@@ -1559,16 +1558,15 @@ static int set_esp_config(struct esp_struct * info,
1559 return -EBUSY; 1558 return -EBUSY;
1560 } else if (current_async->count) 1559 } else if (current_async->count)
1561 return -EBUSY; 1560 return -EBUSY;
1562 1561
1563 current_async = 1562 current_async = current_async->next_port;
1564 current_async->next_port;
1565 } 1563 }
1566 1564
1567 shutdown(info); 1565 shutdown(info);
1568 dma = new_config.dma_channel; 1566 dma = new_config.dma_channel;
1569 info->stat_flags &= ~ESP_STAT_NEVER_DMA; 1567 info->stat_flags &= ~ESP_STAT_NEVER_DMA;
1570 1568
1571 /* all ports must use the same DMA channel */ 1569 /* all ports must use the same DMA channel */
1572 1570
1573 spin_lock_irqsave(&info->lock, flags); 1571 spin_lock_irqsave(&info->lock, flags);
1574 current_async = ports; 1572 current_async = ports;
@@ -1580,7 +1578,6 @@ static int set_esp_config(struct esp_struct * info,
1580 spin_unlock_irqrestore(&info->lock, flags); 1578 spin_unlock_irqrestore(&info->lock, flags);
1581 } else { 1579 } else {
1582 /* DMA mode to PIO mode only */ 1580 /* DMA mode to PIO mode only */
1583
1584 if (info->count > 1) 1581 if (info->count > 1)
1585 return -EBUSY; 1582 return -EBUSY;
1586 1583
@@ -1596,8 +1593,6 @@ static int set_esp_config(struct esp_struct * info,
1596 1593
1597 if ((new_config.flow_off != info->config.flow_off) || 1594 if ((new_config.flow_off != info->config.flow_off) ||
1598 (new_config.flow_on != info->config.flow_on)) { 1595 (new_config.flow_on != info->config.flow_on)) {
1599 unsigned long flags;
1600
1601 info->config.flow_off = new_config.flow_off; 1596 info->config.flow_off = new_config.flow_off;
1602 info->config.flow_on = new_config.flow_on; 1597 info->config.flow_on = new_config.flow_on;
1603 1598
@@ -1612,8 +1607,6 @@ static int set_esp_config(struct esp_struct * info,
1612 1607
1613 if ((new_config.rx_trigger != info->config.rx_trigger) || 1608 if ((new_config.rx_trigger != info->config.rx_trigger) ||
1614 (new_config.tx_trigger != info->config.tx_trigger)) { 1609 (new_config.tx_trigger != info->config.tx_trigger)) {
1615 unsigned long flags;
1616
1617 info->config.rx_trigger = new_config.rx_trigger; 1610 info->config.rx_trigger = new_config.rx_trigger;
1618 info->config.tx_trigger = new_config.tx_trigger; 1611 info->config.tx_trigger = new_config.tx_trigger;
1619 spin_lock_irqsave(&info->lock, flags); 1612 spin_lock_irqsave(&info->lock, flags);
@@ -1628,8 +1621,6 @@ static int set_esp_config(struct esp_struct * info,
1628 } 1621 }
1629 1622
1630 if (new_config.rx_timeout != info->config.rx_timeout) { 1623 if (new_config.rx_timeout != info->config.rx_timeout) {
1631 unsigned long flags;
1632
1633 info->config.rx_timeout = new_config.rx_timeout; 1624 info->config.rx_timeout = new_config.rx_timeout;
1634 spin_lock_irqsave(&info->lock, flags); 1625 spin_lock_irqsave(&info->lock, flags);
1635 1626
@@ -1657,9 +1648,9 @@ static int set_esp_config(struct esp_struct * info,
1657 * release the bus after transmitting. This must be done when 1648 * release the bus after transmitting. This must be done when
1658 * the transmit shift register is empty, not be done when the 1649 * the transmit shift register is empty, not be done when the
1659 * transmit holding register is empty. This functionality 1650 * transmit holding register is empty. This functionality
1660 * allows an RS485 driver to be written in user space. 1651 * allows an RS485 driver to be written in user space.
1661 */ 1652 */
1662static int get_lsr_info(struct esp_struct * info, unsigned int __user *value) 1653static int get_lsr_info(struct esp_struct *info, unsigned int __user *value)
1663{ 1654{
1664 unsigned char status; 1655 unsigned char status;
1665 unsigned int result; 1656 unsigned int result;
@@ -1670,17 +1661,17 @@ static int get_lsr_info(struct esp_struct * info, unsigned int __user *value)
1670 status = serial_in(info, UART_ESI_STAT1); 1661 status = serial_in(info, UART_ESI_STAT1);
1671 spin_unlock_irqrestore(&info->lock, flags); 1662 spin_unlock_irqrestore(&info->lock, flags);
1672 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0); 1663 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
1673 return put_user(result,value); 1664 return put_user(result, value);
1674} 1665}
1675 1666
1676 1667
1677static int esp_tiocmget(struct tty_struct *tty, struct file *file) 1668static int esp_tiocmget(struct tty_struct *tty, struct file *file)
1678{ 1669{
1679 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1670 struct esp_struct *info = tty->driver_data;
1680 unsigned char control, status; 1671 unsigned char control, status;
1681 unsigned long flags; 1672 unsigned long flags;
1682 1673
1683 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1674 if (serial_paranoia_check(info, tty->name, __func__))
1684 return -ENODEV; 1675 return -ENODEV;
1685 if (tty->flags & (1 << TTY_IO_ERROR)) 1676 if (tty->flags & (1 << TTY_IO_ERROR))
1686 return -EIO; 1677 return -EIO;
@@ -1703,10 +1694,10 @@ static int esp_tiocmget(struct tty_struct *tty, struct file *file)
1703static int esp_tiocmset(struct tty_struct *tty, struct file *file, 1694static int esp_tiocmset(struct tty_struct *tty, struct file *file,
1704 unsigned int set, unsigned int clear) 1695 unsigned int set, unsigned int clear)
1705{ 1696{
1706 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1697 struct esp_struct *info = tty->driver_data;
1707 unsigned long flags; 1698 unsigned long flags;
1708 1699
1709 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1700 if (serial_paranoia_check(info, tty->name, __func__))
1710 return -ENODEV; 1701 return -ENODEV;
1711 if (tty->flags & (1 << TTY_IO_ERROR)) 1702 if (tty->flags & (1 << TTY_IO_ERROR))
1712 return -EIO; 1703 return -EIO;
@@ -1736,9 +1727,9 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file,
1736 */ 1727 */
1737static void esp_break(struct tty_struct *tty, int break_state) 1728static void esp_break(struct tty_struct *tty, int break_state)
1738{ 1729{
1739 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1730 struct esp_struct *info = tty->driver_data;
1740 unsigned long flags; 1731 unsigned long flags;
1741 1732
1742 if (serial_paranoia_check(info, tty->name, "esp_break")) 1733 if (serial_paranoia_check(info, tty->name, "esp_break"))
1743 return; 1734 return;
1744 1735
@@ -1758,14 +1749,15 @@ static void esp_break(struct tty_struct *tty, int break_state)
1758 } 1749 }
1759} 1750}
1760 1751
1761static int rs_ioctl(struct tty_struct *tty, struct file * file, 1752static int rs_ioctl(struct tty_struct *tty, struct file *file,
1762 unsigned int cmd, unsigned long arg) 1753 unsigned int cmd, unsigned long arg)
1763{ 1754{
1764 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1755 struct esp_struct *info = tty->driver_data;
1765 struct async_icount cprev, cnow; /* kernel counter temps */ 1756 struct async_icount cprev, cnow; /* kernel counter temps */
1766 struct serial_icounter_struct __user *p_cuser; /* user space */ 1757 struct serial_icounter_struct __user *p_cuser; /* user space */
1767 void __user *argp = (void __user *)arg; 1758 void __user *argp = (void __user *)arg;
1768 unsigned long flags; 1759 unsigned long flags;
1760 int ret;
1769 1761
1770 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) 1762 if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1771 return -ENODEV; 1763 return -ENODEV;
@@ -1778,97 +1770,93 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
1778 if (tty->flags & (1 << TTY_IO_ERROR)) 1770 if (tty->flags & (1 << TTY_IO_ERROR))
1779 return -EIO; 1771 return -EIO;
1780 } 1772 }
1781
1782 switch (cmd) {
1783 case TIOCGSERIAL:
1784 return get_serial_info(info, argp);
1785 case TIOCSSERIAL:
1786 return set_serial_info(info, argp);
1787 case TIOCSERCONFIG:
1788 /* do not reconfigure after initial configuration */
1789 return 0;
1790
1791 case TIOCSERGWILD:
1792 return put_user(0L, (unsigned long __user *)argp);
1793 1773
1794 case TIOCSERGETLSR: /* Get line status register */ 1774 switch (cmd) {
1795 return get_lsr_info(info, argp); 1775 case TIOCGSERIAL:
1796 1776 return get_serial_info(info, argp);
1797 case TIOCSERSWILD: 1777 case TIOCSSERIAL:
1798 if (!capable(CAP_SYS_ADMIN)) 1778 lock_kernel();
1799 return -EPERM; 1779 ret = set_serial_info(info, argp);
1800 return 0; 1780 unlock_kernel();
1801 1781 return ret;
1802 /* 1782 case TIOCSERGWILD:
1803 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 1783 return put_user(0L, (unsigned long __user *)argp);
1804 * - mask passed in arg for lines of interest 1784 case TIOCSERGETLSR: /* Get line status register */
1805 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1785 return get_lsr_info(info, argp);
1806 * Caller should use TIOCGICOUNT to see which one it was 1786 case TIOCSERSWILD:
1807 */ 1787 if (!capable(CAP_SYS_ADMIN))
1808 case TIOCMIWAIT: 1788 return -EPERM;
1789 return 0;
1790 /*
1791 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1792 * - mask passed in arg for lines of interest
1793 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
1794 * Caller should use TIOCGICOUNT to see which one it was
1795 */
1796 case TIOCMIWAIT:
1797 spin_lock_irqsave(&info->lock, flags);
1798 cprev = info->icount; /* note the counters on entry */
1799 spin_unlock_irqrestore(&info->lock, flags);
1800 while (1) {
1801 /* FIXME: convert to new style wakeup */
1802 interruptible_sleep_on(&info->delta_msr_wait);
1803 /* see if a signal did it */
1804 if (signal_pending(current))
1805 return -ERESTARTSYS;
1809 spin_lock_irqsave(&info->lock, flags); 1806 spin_lock_irqsave(&info->lock, flags);
1810 cprev = info->icount; /* note the counters on entry */ 1807 cnow = info->icount; /* atomic copy */
1811 spin_unlock_irqrestore(&info->lock, flags); 1808 spin_unlock_irqrestore(&info->lock, flags);
1812 while (1) { 1809 if (cnow.rng == cprev.rng &&
1813 /* FIXME: convert to new style wakeup */ 1810 cnow.dsr == cprev.dsr &&
1814 interruptible_sleep_on(&info->delta_msr_wait); 1811 cnow.dcd == cprev.dcd &&
1815 /* see if a signal did it */ 1812 cnow.cts == cprev.cts)
1816 if (signal_pending(current)) 1813 return -EIO; /* no change => error */
1817 return -ERESTARTSYS; 1814 if (((arg & TIOCM_RNG) &&
1818 spin_lock_irqsave(&info->lock, flags); 1815 (cnow.rng != cprev.rng)) ||
1819 cnow = info->icount; /* atomic copy */ 1816 ((arg & TIOCM_DSR) &&
1820 spin_unlock_irqrestore(&info->lock, flags); 1817 (cnow.dsr != cprev.dsr)) ||
1821 if (cnow.rng == cprev.rng && 1818 ((arg & TIOCM_CD) &&
1822 cnow.dsr == cprev.dsr && 1819 (cnow.dcd != cprev.dcd)) ||
1823 cnow.dcd == cprev.dcd && 1820 ((arg & TIOCM_CTS) &&
1824 cnow.cts == cprev.cts) 1821 (cnow.cts != cprev.cts))) {
1825 return -EIO; /* no change => error */ 1822 return 0;
1826 if (((arg & TIOCM_RNG) &&
1827 (cnow.rng != cprev.rng)) ||
1828 ((arg & TIOCM_DSR) &&
1829 (cnow.dsr != cprev.dsr)) ||
1830 ((arg & TIOCM_CD) &&
1831 (cnow.dcd != cprev.dcd)) ||
1832 ((arg & TIOCM_CTS) &&
1833 (cnow.cts != cprev.cts)) ) {
1834 return 0;
1835 }
1836 cprev = cnow;
1837 } 1823 }
1838 /* NOTREACHED */ 1824 cprev = cnow;
1839 1825 }
1840 /* 1826 /* NOTREACHED */
1841 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1827 /*
1842 * Return: write counters to the user passed counter struct 1828 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
1843 * NB: both 1->0 and 0->1 transitions are counted except for 1829 * Return: write counters to the user passed counter struct
1844 * RI where only 0->1 is counted. 1830 * NB: both 1->0 and 0->1 transitions are counted except for
1845 */ 1831 * RI where only 0->1 is counted.
1846 case TIOCGICOUNT: 1832 */
1847 spin_lock_irqsave(&info->lock, flags); 1833 case TIOCGICOUNT:
1848 cnow = info->icount; 1834 spin_lock_irqsave(&info->lock, flags);
1849 spin_unlock_irqrestore(&info->lock, flags); 1835 cnow = info->icount;
1850 p_cuser = argp; 1836 spin_unlock_irqrestore(&info->lock, flags);
1851 if (put_user(cnow.cts, &p_cuser->cts) || 1837 p_cuser = argp;
1852 put_user(cnow.dsr, &p_cuser->dsr) || 1838 if (put_user(cnow.cts, &p_cuser->cts) ||
1853 put_user(cnow.rng, &p_cuser->rng) || 1839 put_user(cnow.dsr, &p_cuser->dsr) ||
1854 put_user(cnow.dcd, &p_cuser->dcd)) 1840 put_user(cnow.rng, &p_cuser->rng) ||
1855 return -EFAULT; 1841 put_user(cnow.dcd, &p_cuser->dcd))
1856 1842 return -EFAULT;
1857 return 0; 1843 return 0;
1858 case TIOCGHAYESESP: 1844 case TIOCGHAYESESP:
1859 return get_esp_config(info, argp); 1845 return get_esp_config(info, argp);
1860 case TIOCSHAYESESP: 1846 case TIOCSHAYESESP:
1861 return set_esp_config(info, argp); 1847 lock_kernel();
1862 1848 ret = set_esp_config(info, argp);
1863 default: 1849 unlock_kernel();
1864 return -ENOIOCTLCMD; 1850 return ret;
1865 } 1851 default:
1852 return -ENOIOCTLCMD;
1853 }
1866 return 0; 1854 return 0;
1867} 1855}
1868 1856
1869static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1857static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1870{ 1858{
1871 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1859 struct esp_struct *info = tty->driver_data;
1872 unsigned long flags; 1860 unsigned long flags;
1873 1861
1874 change_speed(info); 1862 change_speed(info);
@@ -1905,32 +1893,33 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1905/* 1893/*
1906 * ------------------------------------------------------------ 1894 * ------------------------------------------------------------
1907 * rs_close() 1895 * rs_close()
1908 * 1896 *
1909 * This routine is called when the serial port gets closed. First, we 1897 * This routine is called when the serial port gets closed. First, we
1910 * wait for the last remaining data to be sent. Then, we unlink its 1898 * wait for the last remaining data to be sent. Then, we unlink its
1911 * async structure from the interrupt chain if necessary, and we free 1899 * async structure from the interrupt chain if necessary, and we free
1912 * that IRQ if nothing is left in the chain. 1900 * that IRQ if nothing is left in the chain.
1913 * ------------------------------------------------------------ 1901 * ------------------------------------------------------------
1914 */ 1902 */
1915static void rs_close(struct tty_struct *tty, struct file * filp) 1903static void rs_close(struct tty_struct *tty, struct file *filp)
1916{ 1904{
1917 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1905 struct esp_struct *info = tty->driver_data;
1918 unsigned long flags; 1906 unsigned long flags;
1919 1907
1920 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1908 if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
1921 return; 1909 return;
1922 1910
1923 spin_lock_irqsave(&info->lock, flags); 1911 spin_lock_irqsave(&info->lock, flags);
1924 1912
1925 if (tty_hung_up_p(filp)) { 1913 if (tty_hung_up_p(filp)) {
1926 DBG_CNT("before DEC-hung"); 1914 DBG_CNT("before DEC-hung");
1927 goto out; 1915 goto out;
1928 } 1916 }
1929 1917
1930#ifdef SERIAL_DEBUG_OPEN 1918#ifdef SERIAL_DEBUG_OPEN
1931 printk("rs_close ttys%d, count = %d\n", info->line, info->count); 1919 printk(KERN_DEBUG "rs_close ttys%d, count = %d\n",
1920 info->line, info->count);
1932#endif 1921#endif
1933 if ((tty->count == 1) && (info->count != 1)) { 1922 if (tty->count == 1 && info->count != 1) {
1934 /* 1923 /*
1935 * Uh, oh. tty->count is 1, which means that the tty 1924 * Uh, oh. tty->count is 1, which means that the tty
1936 * structure will be freed. Info->count should always 1925 * structure will be freed. Info->count should always
@@ -1938,12 +1927,11 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1938 * one, we've got real problems, since it means the 1927 * one, we've got real problems, since it means the
1939 * serial port won't be shutdown. 1928 * serial port won't be shutdown.
1940 */ 1929 */
1941 printk("rs_close: bad serial port count; tty->count is 1, " 1930 printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count);
1942 "info->count is %d\n", info->count);
1943 info->count = 1; 1931 info->count = 1;
1944 } 1932 }
1945 if (--info->count < 0) { 1933 if (--info->count < 0) {
1946 printk("rs_close: bad serial port count for ttys%d: %d\n", 1934 printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
1947 info->line, info->count); 1935 info->line, info->count);
1948 info->count = 0; 1936 info->count = 0;
1949 } 1937 }
@@ -1955,7 +1943,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1955 1943
1956 spin_unlock_irqrestore(&info->lock, flags); 1944 spin_unlock_irqrestore(&info->lock, flags);
1957 /* 1945 /*
1958 * Now we wait for the transmit buffer to clear; and we notify 1946 * Now we wait for the transmit buffer to clear; and we notify
1959 * the line discipline to only process XON/XOFF characters. 1947 * the line discipline to only process XON/XOFF characters.
1960 */ 1948 */
1961 tty->closing = 1; 1949 tty->closing = 1;
@@ -1990,16 +1978,14 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1990 rs_wait_until_sent(tty, info->timeout); 1978 rs_wait_until_sent(tty, info->timeout);
1991 } 1979 }
1992 shutdown(info); 1980 shutdown(info);
1993 if (tty->driver->flush_buffer) 1981 rs_flush_buffer(tty);
1994 tty->driver->flush_buffer(tty);
1995 tty_ldisc_flush(tty); 1982 tty_ldisc_flush(tty);
1996 tty->closing = 0; 1983 tty->closing = 0;
1997 info->tty = NULL; 1984 info->tty = NULL;
1998 1985
1999 if (info->blocked_open) { 1986 if (info->blocked_open) {
2000 if (info->close_delay) { 1987 if (info->close_delay)
2001 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1988 msleep_interruptible(jiffies_to_msecs(info->close_delay));
2002 }
2003 wake_up_interruptible(&info->open_wait); 1989 wake_up_interruptible(&info->open_wait);
2004 } 1990 }
2005 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1991 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -2012,7 +1998,7 @@ out:
2012 1998
2013static void rs_wait_until_sent(struct tty_struct *tty, int timeout) 1999static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
2014{ 2000{
2015 struct esp_struct *info = (struct esp_struct *)tty->driver_data; 2001 struct esp_struct *info = tty->driver_data;
2016 unsigned long orig_jiffies, char_time; 2002 unsigned long orig_jiffies, char_time;
2017 unsigned long flags; 2003 unsigned long flags;
2018 2004
@@ -2036,10 +2022,10 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
2036 msleep_interruptible(jiffies_to_msecs(char_time)); 2022 msleep_interruptible(jiffies_to_msecs(char_time));
2037 2023
2038 if (signal_pending(current)) 2024 if (signal_pending(current))
2039 break; 2025 return;
2040 2026
2041 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 2027 if (timeout && time_after(jiffies, orig_jiffies + timeout))
2042 break; 2028 return;
2043 2029
2044 spin_lock_irqsave(&info->lock, flags); 2030 spin_lock_irqsave(&info->lock, flags);
2045 serial_out(info, UART_ESI_CMD1, ESI_NO_COMMAND); 2031 serial_out(info, UART_ESI_CMD1, ESI_NO_COMMAND);
@@ -2054,11 +2040,11 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
2054 */ 2040 */
2055static void esp_hangup(struct tty_struct *tty) 2041static void esp_hangup(struct tty_struct *tty)
2056{ 2042{
2057 struct esp_struct * info = (struct esp_struct *)tty->driver_data; 2043 struct esp_struct *info = tty->driver_data;
2058 2044
2059 if (serial_paranoia_check(info, tty->name, "esp_hangup")) 2045 if (serial_paranoia_check(info, tty->name, "esp_hangup"))
2060 return; 2046 return;
2061 2047
2062 rs_flush_buffer(tty); 2048 rs_flush_buffer(tty);
2063 shutdown(info); 2049 shutdown(info);
2064 info->count = 0; 2050 info->count = 0;
@@ -2072,7 +2058,7 @@ static void esp_hangup(struct tty_struct *tty)
2072 * esp_open() and friends 2058 * esp_open() and friends
2073 * ------------------------------------------------------------ 2059 * ------------------------------------------------------------
2074 */ 2060 */
2075static int block_til_ready(struct tty_struct *tty, struct file * filp, 2061static int block_til_ready(struct tty_struct *tty, struct file *filp,
2076 struct esp_struct *info) 2062 struct esp_struct *info)
2077{ 2063{
2078 DECLARE_WAITQUEUE(wait, current); 2064 DECLARE_WAITQUEUE(wait, current);
@@ -2121,11 +2107,11 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
2121 retval = 0; 2107 retval = 0;
2122 add_wait_queue(&info->open_wait, &wait); 2108 add_wait_queue(&info->open_wait, &wait);
2123#ifdef SERIAL_DEBUG_OPEN 2109#ifdef SERIAL_DEBUG_OPEN
2124 printk("block_til_ready before block: ttys%d, count = %d\n", 2110 printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n",
2125 info->line, info->count); 2111 info->line, info->count);
2126#endif 2112#endif
2127 spin_lock_irqsave(&info->lock, flags); 2113 spin_lock_irqsave(&info->lock, flags);
2128 if (!tty_hung_up_p(filp)) 2114 if (!tty_hung_up_p(filp))
2129 info->count--; 2115 info->count--;
2130 info->blocked_open++; 2116 info->blocked_open++;
2131 while (1) { 2117 while (1) {
@@ -2147,7 +2133,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
2147 if (info->flags & ASYNC_HUP_NOTIFY) 2133 if (info->flags & ASYNC_HUP_NOTIFY)
2148 retval = -EAGAIN; 2134 retval = -EAGAIN;
2149 else 2135 else
2150 retval = -ERESTARTSYS; 2136 retval = -ERESTARTSYS;
2151#else 2137#else
2152 retval = -EAGAIN; 2138 retval = -EAGAIN;
2153#endif 2139#endif
@@ -2166,7 +2152,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
2166 break; 2152 break;
2167 } 2153 }
2168#ifdef SERIAL_DEBUG_OPEN 2154#ifdef SERIAL_DEBUG_OPEN
2169 printk("block_til_ready blocking: ttys%d, count = %d\n", 2155 printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n",
2170 info->line, info->count); 2156 info->line, info->count);
2171#endif 2157#endif
2172 spin_unlock_irqrestore(&info->lock, flags); 2158 spin_unlock_irqrestore(&info->lock, flags);
@@ -2180,14 +2166,14 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
2180 info->blocked_open--; 2166 info->blocked_open--;
2181 spin_unlock_irqrestore(&info->lock, flags); 2167 spin_unlock_irqrestore(&info->lock, flags);
2182#ifdef SERIAL_DEBUG_OPEN 2168#ifdef SERIAL_DEBUG_OPEN
2183 printk("block_til_ready after blocking: ttys%d, count = %d\n", 2169 printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n",
2184 info->line, info->count); 2170 info->line, info->count);
2185#endif 2171#endif
2186 if (retval) 2172 if (retval)
2187 return retval; 2173 return retval;
2188 info->flags |= ASYNC_NORMAL_ACTIVE; 2174 info->flags |= ASYNC_NORMAL_ACTIVE;
2189 return 0; 2175 return 0;
2190} 2176}
2191 2177
2192/* 2178/*
2193 * This routine is called whenever a serial port is opened. It 2179 * This routine is called whenever a serial port is opened. It
@@ -2195,7 +2181,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
2195 * the IRQ chain. It also performs the serial-specific 2181 * the IRQ chain. It also performs the serial-specific
2196 * initialization for the tty structure. 2182 * initialization for the tty structure.
2197 */ 2183 */
2198static int esp_open(struct tty_struct *tty, struct file * filp) 2184static int esp_open(struct tty_struct *tty, struct file *filp)
2199{ 2185{
2200 struct esp_struct *info; 2186 struct esp_struct *info;
2201 int retval, line; 2187 int retval, line;
@@ -2218,7 +2204,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp)
2218 } 2204 }
2219 2205
2220#ifdef SERIAL_DEBUG_OPEN 2206#ifdef SERIAL_DEBUG_OPEN
2221 printk("esp_open %s, count = %d\n", tty->name, info->count); 2207 printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count);
2222#endif 2208#endif
2223 spin_lock_irqsave(&info->lock, flags); 2209 spin_lock_irqsave(&info->lock, flags);
2224 info->count++; 2210 info->count++;
@@ -2226,7 +2212,7 @@ static int esp_open(struct tty_struct *tty, struct file * filp)
2226 info->tty = tty; 2212 info->tty = tty;
2227 2213
2228 spin_unlock_irqrestore(&info->lock, flags); 2214 spin_unlock_irqrestore(&info->lock, flags);
2229 2215
2230 /* 2216 /*
2231 * Start up serial port 2217 * Start up serial port
2232 */ 2218 */
@@ -2237,14 +2223,13 @@ static int esp_open(struct tty_struct *tty, struct file * filp)
2237 retval = block_til_ready(tty, filp, info); 2223 retval = block_til_ready(tty, filp, info);
2238 if (retval) { 2224 if (retval) {
2239#ifdef SERIAL_DEBUG_OPEN 2225#ifdef SERIAL_DEBUG_OPEN
2240 printk("esp_open returning after block_til_ready with %d\n", 2226 printk(KERN_DEBUG "esp_open returning after block_til_ready with %d\n",
2241 retval); 2227 retval);
2242#endif 2228#endif
2243 return retval; 2229 return retval;
2244 } 2230 }
2245
2246#ifdef SERIAL_DEBUG_OPEN 2231#ifdef SERIAL_DEBUG_OPEN
2247 printk("esp_open %s successful...", tty->name); 2232 printk(KERN_DEBUG "esp_open %s successful...", tty->name);
2248#endif 2233#endif
2249 return 0; 2234 return 0;
2250} 2235}
@@ -2262,10 +2247,10 @@ static int esp_open(struct tty_struct *tty, struct file * filp)
2262 * number, and identifies which options were configured into this 2247 * number, and identifies which options were configured into this
2263 * driver. 2248 * driver.
2264 */ 2249 */
2265 2250
2266static inline void show_serial_version(void) 2251static void show_serial_version(void)
2267{ 2252{
2268 printk(KERN_INFO "%s version %s (DMA %u)\n", 2253 printk(KERN_INFO "%s version %s (DMA %u)\n",
2269 serial_name, serial_version, dma); 2254 serial_name, serial_version, dma);
2270} 2255}
2271 2256
@@ -2273,7 +2258,7 @@ static inline void show_serial_version(void)
2273 * This routine is called by espserial_init() to initialize a specific serial 2258 * This routine is called by espserial_init() to initialize a specific serial
2274 * port. 2259 * port.
2275 */ 2260 */
2276static inline int autoconfig(struct esp_struct * info) 2261static int autoconfig(struct esp_struct *info)
2277{ 2262{
2278 int port_detected = 0; 2263 int port_detected = 0;
2279 unsigned long flags; 2264 unsigned long flags;
@@ -2349,14 +2334,14 @@ static const struct tty_operations esp_ops = {
2349static int __init espserial_init(void) 2334static int __init espserial_init(void)
2350{ 2335{
2351 int i, offset; 2336 int i, offset;
2352 struct esp_struct * info; 2337 struct esp_struct *info;
2353 struct esp_struct *last_primary = NULL; 2338 struct esp_struct *last_primary = NULL;
2354 int esp[] = {0x100,0x140,0x180,0x200,0x240,0x280,0x300,0x380}; 2339 int esp[] = { 0x100, 0x140, 0x180, 0x200, 0x240, 0x280, 0x300, 0x380 };
2355 2340
2356 esp_driver = alloc_tty_driver(NR_PORTS); 2341 esp_driver = alloc_tty_driver(NR_PORTS);
2357 if (!esp_driver) 2342 if (!esp_driver)
2358 return -ENOMEM; 2343 return -ENOMEM;
2359 2344
2360 for (i = 0; i < NR_PRIMARY; i++) { 2345 for (i = 0; i < NR_PRIMARY; i++) {
2361 if (irq[i] != 0) { 2346 if (irq[i] != 0) {
2362 if ((irq[i] < 2) || (irq[i] > 15) || (irq[i] == 6) || 2347 if ((irq[i] < 2) || (irq[i] > 15) || (irq[i] == 6) ||
@@ -2378,20 +2363,20 @@ static int __init espserial_init(void)
2378 2363
2379 if ((flow_off < 1) || (flow_off > 1023)) 2364 if ((flow_off < 1) || (flow_off > 1023))
2380 flow_off = 1016; 2365 flow_off = 1016;
2381 2366
2382 if ((flow_on < 1) || (flow_on > 1023)) 2367 if ((flow_on < 1) || (flow_on > 1023))
2383 flow_on = 944; 2368 flow_on = 944;
2384 2369
2385 if ((rx_timeout < 0) || (rx_timeout > 255)) 2370 if ((rx_timeout < 0) || (rx_timeout > 255))
2386 rx_timeout = 128; 2371 rx_timeout = 128;
2387 2372
2388 if (flow_on >= flow_off) 2373 if (flow_on >= flow_off)
2389 flow_on = flow_off - 1; 2374 flow_on = flow_off - 1;
2390 2375
2391 show_serial_version(); 2376 show_serial_version();
2392 2377
2393 /* Initialize the tty_driver structure */ 2378 /* Initialize the tty_driver structure */
2394 2379
2395 esp_driver->owner = THIS_MODULE; 2380 esp_driver->owner = THIS_MODULE;
2396 esp_driver->name = "ttyP"; 2381 esp_driver->name = "ttyP";
2397 esp_driver->major = ESP_IN_MAJOR; 2382 esp_driver->major = ESP_IN_MAJOR;
@@ -2401,10 +2386,11 @@ static int __init espserial_init(void)
2401 esp_driver->init_termios = tty_std_termios; 2386 esp_driver->init_termios = tty_std_termios;
2402 esp_driver->init_termios.c_cflag = 2387 esp_driver->init_termios.c_cflag =
2403 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2388 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2389 esp_driver->init_termios.c_ispeed = 9600;
2390 esp_driver->init_termios.c_ospeed = 9600;
2404 esp_driver->flags = TTY_DRIVER_REAL_RAW; 2391 esp_driver->flags = TTY_DRIVER_REAL_RAW;
2405 tty_set_operations(esp_driver, &esp_ops); 2392 tty_set_operations(esp_driver, &esp_ops);
2406 if (tty_register_driver(esp_driver)) 2393 if (tty_register_driver(esp_driver)) {
2407 {
2408 printk(KERN_ERR "Couldn't register esp serial driver"); 2394 printk(KERN_ERR "Couldn't register esp serial driver");
2409 put_tty_driver(esp_driver); 2395 put_tty_driver(esp_driver);
2410 return 1; 2396 return 1;
@@ -2412,8 +2398,7 @@ static int __init espserial_init(void)
2412 2398
2413 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); 2399 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
2414 2400
2415 if (!info) 2401 if (!info) {
2416 {
2417 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); 2402 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
2418 tty_unregister_driver(esp_driver); 2403 tty_unregister_driver(esp_driver);
2419 put_tty_driver(esp_driver); 2404 put_tty_driver(esp_driver);
@@ -2476,10 +2461,8 @@ static int __init espserial_init(void)
2476 info->stat_flags |= ESP_STAT_NEVER_DMA; 2461 info->stat_flags |= ESP_STAT_NEVER_DMA;
2477 2462
2478 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); 2463 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
2479 if (!info) 2464 if (!info) {
2480 { 2465 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
2481 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
2482
2483 /* allow use of the already detected ports */ 2466 /* allow use of the already detected ports */
2484 return 0; 2467 return 0;
2485 } 2468 }
@@ -2503,22 +2486,20 @@ static int __init espserial_init(void)
2503 return 0; 2486 return 0;
2504} 2487}
2505 2488
2506static void __exit espserial_exit(void) 2489static void __exit espserial_exit(void)
2507{ 2490{
2508 int e1; 2491 int e1;
2509 struct esp_struct *temp_async; 2492 struct esp_struct *temp_async;
2510 struct esp_pio_buffer *pio_buf; 2493 struct esp_pio_buffer *pio_buf;
2511 2494
2512 /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ 2495 e1 = tty_unregister_driver(esp_driver);
2513 if ((e1 = tty_unregister_driver(esp_driver))) 2496 if (e1)
2514 printk("SERIAL: failed to unregister serial driver (%d)\n", 2497 printk(KERN_ERR "esp: failed to unregister driver (%d)\n", e1);
2515 e1);
2516 put_tty_driver(esp_driver); 2498 put_tty_driver(esp_driver);
2517 2499
2518 while (ports) { 2500 while (ports) {
2519 if (ports->port) { 2501 if (ports->port)
2520 release_region(ports->port, REGION_SIZE); 2502 release_region(ports->port, REGION_SIZE);
2521 }
2522 temp_async = ports->next_port; 2503 temp_async = ports->next_port;
2523 kfree(ports); 2504 kfree(ports);
2524 ports = temp_async; 2505 ports = temp_async;
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index 7ed7da1d99cf..252f73e48596 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -40,27 +40,27 @@ static int gs_debug;
40#define gs_dprintk(f, str...) /* nothing */ 40#define gs_dprintk(f, str...) /* nothing */
41#endif 41#endif
42 42
43#define func_enter() gs_dprintk (GS_DEBUG_FLOW, "gs: enter %s\n", __FUNCTION__) 43#define func_enter() gs_dprintk (GS_DEBUG_FLOW, "gs: enter %s\n", __func__)
44#define func_exit() gs_dprintk (GS_DEBUG_FLOW, "gs: exit %s\n", __FUNCTION__) 44#define func_exit() gs_dprintk (GS_DEBUG_FLOW, "gs: exit %s\n", __func__)
45 45
46#define RS_EVENT_WRITE_WAKEUP 1 46#define RS_EVENT_WRITE_WAKEUP 1
47 47
48module_param(gs_debug, int, 0644); 48module_param(gs_debug, int, 0644);
49 49
50 50
51void gs_put_char(struct tty_struct * tty, unsigned char ch) 51int gs_put_char(struct tty_struct * tty, unsigned char ch)
52{ 52{
53 struct gs_port *port; 53 struct gs_port *port;
54 54
55 func_enter (); 55 func_enter ();
56 56
57 if (!tty) return; 57 if (!tty) return 0;
58 58
59 port = tty->driver_data; 59 port = tty->driver_data;
60 60
61 if (!port) return; 61 if (!port) return 0;
62 62
63 if (! (port->flags & ASYNC_INITIALIZED)) return; 63 if (! (port->flags & ASYNC_INITIALIZED)) return 0;
64 64
65 /* Take a lock on the serial tranmit buffer! */ 65 /* Take a lock on the serial tranmit buffer! */
66 mutex_lock(& port->port_write_mutex); 66 mutex_lock(& port->port_write_mutex);
@@ -68,7 +68,7 @@ void gs_put_char(struct tty_struct * tty, unsigned char ch)
68 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { 68 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
69 /* Sorry, buffer is full, drop character. Update statistics???? -- REW */ 69 /* Sorry, buffer is full, drop character. Update statistics???? -- REW */
70 mutex_unlock(&port->port_write_mutex); 70 mutex_unlock(&port->port_write_mutex);
71 return; 71 return 0;
72 } 72 }
73 73
74 port->xmit_buf[port->xmit_head++] = ch; 74 port->xmit_buf[port->xmit_head++] = ch;
@@ -77,6 +77,7 @@ void gs_put_char(struct tty_struct * tty, unsigned char ch)
77 77
78 mutex_unlock(&port->port_write_mutex); 78 mutex_unlock(&port->port_write_mutex);
79 func_exit (); 79 func_exit ();
80 return 1;
80} 81}
81 82
82 83
@@ -586,8 +587,7 @@ void gs_close(struct tty_struct * tty, struct file * filp)
586 587
587 port->flags &= ~GS_ACTIVE; 588 port->flags &= ~GS_ACTIVE;
588 589
589 if (tty->driver->flush_buffer) 590 gs_flush_buffer(tty);
590 tty->driver->flush_buffer(tty);
591 591
592 tty_ldisc_flush(tty); 592 tty_ldisc_flush(tty);
593 tty->closing = 0; 593 tty->closing = 0;
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 1399971be689..e7fb0bca3667 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -308,7 +308,7 @@ static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
308 if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, 308 if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT,
309 PAGE_SIZE, vma->vm_page_prot)) { 309 PAGE_SIZE, vma->vm_page_prot)) {
310 printk(KERN_ERR "%s: io_remap_pfn_range failed\n", 310 printk(KERN_ERR "%s: io_remap_pfn_range failed\n",
311 __FUNCTION__); 311 __func__);
312 return -EAGAIN; 312 return -EAGAIN;
313 } 313 }
314 314
@@ -748,7 +748,7 @@ int hpet_alloc(struct hpet_data *hdp)
748 */ 748 */
749 if (hpet_is_known(hdp)) { 749 if (hpet_is_known(hdp)) {
750 printk(KERN_DEBUG "%s: duplicate HPET ignored\n", 750 printk(KERN_DEBUG "%s: duplicate HPET ignored\n",
751 __FUNCTION__); 751 __func__);
752 return 0; 752 return 0;
753 } 753 }
754 754
@@ -869,7 +869,7 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
869 869
870 if (hpet_is_known(hdp)) { 870 if (hpet_is_known(hdp)) {
871 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 871 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
872 __FUNCTION__, hdp->hd_phys_address); 872 __func__, hdp->hd_phys_address);
873 iounmap(hdp->hd_address); 873 iounmap(hdp->hd_address);
874 return AE_ALREADY_EXISTS; 874 return AE_ALREADY_EXISTS;
875 } 875 }
@@ -886,7 +886,7 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
886 886
887 if (hpet_is_known(hdp)) { 887 if (hpet_is_known(hdp)) {
888 printk(KERN_DEBUG "%s: 0x%lx is busy\n", 888 printk(KERN_DEBUG "%s: 0x%lx is busy\n",
889 __FUNCTION__, hdp->hd_phys_address); 889 __func__, hdp->hd_phys_address);
890 iounmap(hdp->hd_address); 890 iounmap(hdp->hd_address);
891 return AE_ALREADY_EXISTS; 891 return AE_ALREADY_EXISTS;
892 } 892 }
@@ -925,7 +925,7 @@ static int hpet_acpi_add(struct acpi_device *device)
925 return -ENODEV; 925 return -ENODEV;
926 926
927 if (!data.hd_address || !data.hd_nirqs) { 927 if (!data.hd_address || !data.hd_nirqs) {
928 printk("%s: no address or irqs in _CRS\n", __FUNCTION__); 928 printk("%s: no address or irqs in _CRS\n", __func__);
929 return -ENODEV; 929 return -ENODEV;
930 } 930 }
931 931
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index d5a752da322f..59c6f9ab94e4 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -246,7 +246,7 @@ static void compact_inbuf(struct hvsi_struct *hp, uint8_t *read_to)
246{ 246{
247 int remaining = (int)(hp->inbuf_end - read_to); 247 int remaining = (int)(hp->inbuf_end - read_to);
248 248
249 pr_debug("%s: %i chars remain\n", __FUNCTION__, remaining); 249 pr_debug("%s: %i chars remain\n", __func__, remaining);
250 250
251 if (read_to != hp->inbuf) 251 if (read_to != hp->inbuf)
252 memmove(hp->inbuf, read_to, remaining); 252 memmove(hp->inbuf, read_to, remaining);
@@ -365,7 +365,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
365 packet.u.version = HVSI_VERSION; 365 packet.u.version = HVSI_VERSION;
366 packet.query_seqno = query_seqno+1; 366 packet.query_seqno = query_seqno+1;
367 367
368 pr_debug("%s: sending %i bytes\n", __FUNCTION__, packet.len); 368 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
369 dbg_dump_hex((uint8_t*)&packet, packet.len); 369 dbg_dump_hex((uint8_t*)&packet, packet.len);
370 370
371 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); 371 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@ -437,7 +437,7 @@ static struct tty_struct *hvsi_recv_data(struct hvsi_struct *hp,
437 return NULL; 437 return NULL;
438 438
439 if (overflow > 0) { 439 if (overflow > 0) {
440 pr_debug("%s: got >TTY_THRESHOLD_THROTTLE bytes\n", __FUNCTION__); 440 pr_debug("%s: got >TTY_THRESHOLD_THROTTLE bytes\n", __func__);
441 datalen = TTY_THRESHOLD_THROTTLE; 441 datalen = TTY_THRESHOLD_THROTTLE;
442 } 442 }
443 443
@@ -448,7 +448,7 @@ static struct tty_struct *hvsi_recv_data(struct hvsi_struct *hp,
448 * we still have more data to deliver, so we need to save off the 448 * we still have more data to deliver, so we need to save off the
449 * overflow and send it later 449 * overflow and send it later
450 */ 450 */
451 pr_debug("%s: deferring overflow\n", __FUNCTION__); 451 pr_debug("%s: deferring overflow\n", __func__);
452 memcpy(hp->throttle_buf, data + TTY_THRESHOLD_THROTTLE, overflow); 452 memcpy(hp->throttle_buf, data + TTY_THRESHOLD_THROTTLE, overflow);
453 hp->n_throttle = overflow; 453 hp->n_throttle = overflow;
454 } 454 }
@@ -474,11 +474,11 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
474 474
475 chunklen = hvsi_read(hp, hp->inbuf_end, HVSI_MAX_READ); 475 chunklen = hvsi_read(hp, hp->inbuf_end, HVSI_MAX_READ);
476 if (chunklen == 0) { 476 if (chunklen == 0) {
477 pr_debug("%s: 0-length read\n", __FUNCTION__); 477 pr_debug("%s: 0-length read\n", __func__);
478 return 0; 478 return 0;
479 } 479 }
480 480
481 pr_debug("%s: got %i bytes\n", __FUNCTION__, chunklen); 481 pr_debug("%s: got %i bytes\n", __func__, chunklen);
482 dbg_dump_hex(hp->inbuf_end, chunklen); 482 dbg_dump_hex(hp->inbuf_end, chunklen);
483 483
484 hp->inbuf_end += chunklen; 484 hp->inbuf_end += chunklen;
@@ -495,7 +495,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
495 continue; 495 continue;
496 } 496 }
497 497
498 pr_debug("%s: handling %i-byte packet\n", __FUNCTION__, 498 pr_debug("%s: handling %i-byte packet\n", __func__,
499 len_packet(packet)); 499 len_packet(packet));
500 dbg_dump_packet(packet); 500 dbg_dump_packet(packet);
501 501
@@ -526,7 +526,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
526 packet += len_packet(packet); 526 packet += len_packet(packet);
527 527
528 if (*hangup || *handshake) { 528 if (*hangup || *handshake) {
529 pr_debug("%s: hangup or handshake\n", __FUNCTION__); 529 pr_debug("%s: hangup or handshake\n", __func__);
530 /* 530 /*
531 * we need to send the hangup now before receiving any more data. 531 * we need to send the hangup now before receiving any more data.
532 * If we get "data, hangup, data", we can't deliver the second 532 * If we get "data, hangup, data", we can't deliver the second
@@ -543,7 +543,7 @@ static int hvsi_load_chunk(struct hvsi_struct *hp, struct tty_struct **flip,
543 543
544static void hvsi_send_overflow(struct hvsi_struct *hp) 544static void hvsi_send_overflow(struct hvsi_struct *hp)
545{ 545{
546 pr_debug("%s: delivering %i bytes overflow\n", __FUNCTION__, 546 pr_debug("%s: delivering %i bytes overflow\n", __func__,
547 hp->n_throttle); 547 hp->n_throttle);
548 548
549 hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle); 549 hvsi_insert_chars(hp, hp->throttle_buf, hp->n_throttle);
@@ -563,7 +563,7 @@ static irqreturn_t hvsi_interrupt(int irq, void *arg)
563 unsigned long flags; 563 unsigned long flags;
564 int again = 1; 564 int again = 1;
565 565
566 pr_debug("%s\n", __FUNCTION__); 566 pr_debug("%s\n", __func__);
567 567
568 while (again) { 568 while (again) {
569 spin_lock_irqsave(&hp->lock, flags); 569 spin_lock_irqsave(&hp->lock, flags);
@@ -647,7 +647,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
647 packet.seqno = atomic_inc_return(&hp->seqno); 647 packet.seqno = atomic_inc_return(&hp->seqno);
648 packet.verb = verb; 648 packet.verb = verb;
649 649
650 pr_debug("%s: sending %i bytes\n", __FUNCTION__, packet.len); 650 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
651 dbg_dump_hex((uint8_t*)&packet, packet.len); 651 dbg_dump_hex((uint8_t*)&packet, packet.len);
652 652
653 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); 653 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@ -674,7 +674,7 @@ static int hvsi_get_mctrl(struct hvsi_struct *hp)
674 return ret; 674 return ret;
675 } 675 }
676 676
677 pr_debug("%s: mctrl 0x%x\n", __FUNCTION__, hp->mctrl); 677 pr_debug("%s: mctrl 0x%x\n", __func__, hp->mctrl);
678 678
679 return 0; 679 return 0;
680} 680}
@@ -694,7 +694,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
694 if (mctrl & TIOCM_DTR) 694 if (mctrl & TIOCM_DTR)
695 packet.word = HVSI_TSDTR; 695 packet.word = HVSI_TSDTR;
696 696
697 pr_debug("%s: sending %i bytes\n", __FUNCTION__, packet.len); 697 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
698 dbg_dump_hex((uint8_t*)&packet, packet.len); 698 dbg_dump_hex((uint8_t*)&packet, packet.len);
699 699
700 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); 700 wrote = hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@ -790,7 +790,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
790 packet.len = 6; 790 packet.len = 6;
791 packet.verb = VSV_CLOSE_PROTOCOL; 791 packet.verb = VSV_CLOSE_PROTOCOL;
792 792
793 pr_debug("%s: sending %i bytes\n", __FUNCTION__, packet.len); 793 pr_debug("%s: sending %i bytes\n", __func__, packet.len);
794 dbg_dump_hex((uint8_t*)&packet, packet.len); 794 dbg_dump_hex((uint8_t*)&packet, packet.len);
795 795
796 hvc_put_chars(hp->vtermno, (char *)&packet, packet.len); 796 hvc_put_chars(hp->vtermno, (char *)&packet, packet.len);
@@ -803,7 +803,7 @@ static int hvsi_open(struct tty_struct *tty, struct file *filp)
803 int line = tty->index; 803 int line = tty->index;
804 int ret; 804 int ret;
805 805
806 pr_debug("%s\n", __FUNCTION__); 806 pr_debug("%s\n", __func__);
807 807
808 if (line < 0 || line >= hvsi_count) 808 if (line < 0 || line >= hvsi_count)
809 return -ENODEV; 809 return -ENODEV;
@@ -868,7 +868,7 @@ static void hvsi_close(struct tty_struct *tty, struct file *filp)
868 struct hvsi_struct *hp = tty->driver_data; 868 struct hvsi_struct *hp = tty->driver_data;
869 unsigned long flags; 869 unsigned long flags;
870 870
871 pr_debug("%s\n", __FUNCTION__); 871 pr_debug("%s\n", __func__);
872 872
873 if (tty_hung_up_p(filp)) 873 if (tty_hung_up_p(filp))
874 return; 874 return;
@@ -920,7 +920,7 @@ static void hvsi_hangup(struct tty_struct *tty)
920 struct hvsi_struct *hp = tty->driver_data; 920 struct hvsi_struct *hp = tty->driver_data;
921 unsigned long flags; 921 unsigned long flags;
922 922
923 pr_debug("%s\n", __FUNCTION__); 923 pr_debug("%s\n", __func__);
924 924
925 spin_lock_irqsave(&hp->lock, flags); 925 spin_lock_irqsave(&hp->lock, flags);
926 926
@@ -942,7 +942,7 @@ static void hvsi_push(struct hvsi_struct *hp)
942 n = hvsi_put_chars(hp, hp->outbuf, hp->n_outbuf); 942 n = hvsi_put_chars(hp, hp->outbuf, hp->n_outbuf);
943 if (n > 0) { 943 if (n > 0) {
944 /* success */ 944 /* success */
945 pr_debug("%s: wrote %i chars\n", __FUNCTION__, n); 945 pr_debug("%s: wrote %i chars\n", __func__, n);
946 hp->n_outbuf = 0; 946 hp->n_outbuf = 0;
947 } else if (n == -EIO) { 947 } else if (n == -EIO) {
948 __set_state(hp, HVSI_FSP_DIED); 948 __set_state(hp, HVSI_FSP_DIED);
@@ -965,7 +965,7 @@ static void hvsi_write_worker(struct work_struct *work)
965 965
966 spin_lock_irqsave(&hp->lock, flags); 966 spin_lock_irqsave(&hp->lock, flags);
967 967
968 pr_debug("%s: %i chars in buffer\n", __FUNCTION__, hp->n_outbuf); 968 pr_debug("%s: %i chars in buffer\n", __func__, hp->n_outbuf);
969 969
970 if (!is_open(hp)) { 970 if (!is_open(hp)) {
971 /* 971 /*
@@ -983,7 +983,7 @@ static void hvsi_write_worker(struct work_struct *work)
983 schedule_delayed_work(&hp->writer, 10); 983 schedule_delayed_work(&hp->writer, 10);
984 else { 984 else {
985#ifdef DEBUG 985#ifdef DEBUG
986 pr_debug("%s: outbuf emptied after %li jiffies\n", __FUNCTION__, 986 pr_debug("%s: outbuf emptied after %li jiffies\n", __func__,
987 jiffies - start_j); 987 jiffies - start_j);
988 start_j = 0; 988 start_j = 0;
989#endif /* DEBUG */ 989#endif /* DEBUG */
@@ -1020,11 +1020,11 @@ static int hvsi_write(struct tty_struct *tty,
1020 1020
1021 spin_lock_irqsave(&hp->lock, flags); 1021 spin_lock_irqsave(&hp->lock, flags);
1022 1022
1023 pr_debug("%s: %i chars in buffer\n", __FUNCTION__, hp->n_outbuf); 1023 pr_debug("%s: %i chars in buffer\n", __func__, hp->n_outbuf);
1024 1024
1025 if (!is_open(hp)) { 1025 if (!is_open(hp)) {
1026 /* we're either closing or not yet open; don't accept data */ 1026 /* we're either closing or not yet open; don't accept data */
1027 pr_debug("%s: not open\n", __FUNCTION__); 1027 pr_debug("%s: not open\n", __func__);
1028 goto out; 1028 goto out;
1029 } 1029 }
1030 1030
@@ -1058,7 +1058,7 @@ out:
1058 spin_unlock_irqrestore(&hp->lock, flags); 1058 spin_unlock_irqrestore(&hp->lock, flags);
1059 1059
1060 if (total != origcount) 1060 if (total != origcount)
1061 pr_debug("%s: wanted %i, only wrote %i\n", __FUNCTION__, origcount, 1061 pr_debug("%s: wanted %i, only wrote %i\n", __func__, origcount,
1062 total); 1062 total);
1063 1063
1064 return total; 1064 return total;
@@ -1072,7 +1072,7 @@ static void hvsi_throttle(struct tty_struct *tty)
1072{ 1072{
1073 struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; 1073 struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data;
1074 1074
1075 pr_debug("%s\n", __FUNCTION__); 1075 pr_debug("%s\n", __func__);
1076 1076
1077 h_vio_signal(hp->vtermno, VIO_IRQ_DISABLE); 1077 h_vio_signal(hp->vtermno, VIO_IRQ_DISABLE);
1078} 1078}
@@ -1083,7 +1083,7 @@ static void hvsi_unthrottle(struct tty_struct *tty)
1083 unsigned long flags; 1083 unsigned long flags;
1084 int shouldflip = 0; 1084 int shouldflip = 0;
1085 1085
1086 pr_debug("%s\n", __FUNCTION__); 1086 pr_debug("%s\n", __func__);
1087 1087
1088 spin_lock_irqsave(&hp->lock, flags); 1088 spin_lock_irqsave(&hp->lock, flags);
1089 if (hp->n_throttle) { 1089 if (hp->n_throttle) {
@@ -1302,7 +1302,7 @@ static int __init hvsi_console_init(void)
1302 hp->virq = irq_create_mapping(NULL, irq[0]); 1302 hp->virq = irq_create_mapping(NULL, irq[0]);
1303 if (hp->virq == NO_IRQ) { 1303 if (hp->virq == NO_IRQ) {
1304 printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n", 1304 printk(KERN_ERR "%s: couldn't create irq mapping for 0x%x\n",
1305 __FUNCTION__, irq[0]); 1305 __func__, irq[0]);
1306 continue; 1306 continue;
1307 } 1307 }
1308 1308
diff --git a/drivers/char/ip2/i2ellis.c b/drivers/char/ip2/i2ellis.c
index 61ef013b8445..3601017f58cf 100644
--- a/drivers/char/ip2/i2ellis.c
+++ b/drivers/char/ip2/i2ellis.c
@@ -53,7 +53,7 @@ static int ii2Safe; // Safe I/O address for delay routine
53 53
54static int iiDelayed; // Set when the iiResetDelay function is 54static int iiDelayed; // Set when the iiResetDelay function is
55 // called. Cleared when ANY board is reset. 55 // called. Cleared when ANY board is reset.
56static rwlock_t Dl_spinlock; 56static DEFINE_RWLOCK(Dl_spinlock);
57 57
58//******** 58//********
59//* Code * 59//* Code *
@@ -82,7 +82,6 @@ static rwlock_t Dl_spinlock;
82static void 82static void
83iiEllisInit(void) 83iiEllisInit(void)
84{ 84{
85 LOCK_INIT(&Dl_spinlock);
86} 85}
87 86
88//****************************************************************************** 87//******************************************************************************
@@ -132,7 +131,7 @@ iiSetAddress( i2eBordStrPtr pB, int address, delayFunc_t delay )
132 || (address & 0x7) 131 || (address & 0x7)
133 ) 132 )
134 { 133 {
135 COMPLETE(pB,I2EE_BADADDR); 134 I2_COMPLETE(pB, I2EE_BADADDR);
136 } 135 }
137 136
138 // Initialize accelerators 137 // Initialize accelerators
@@ -152,7 +151,7 @@ iiSetAddress( i2eBordStrPtr pB, int address, delayFunc_t delay )
152 pB->i2eValid = I2E_MAGIC; 151 pB->i2eValid = I2E_MAGIC;
153 pB->i2eState = II_STATE_COLD; 152 pB->i2eState = II_STATE_COLD;
154 153
155 COMPLETE(pB, I2EE_GOOD); 154 I2_COMPLETE(pB, I2EE_GOOD);
156} 155}
157 156
158//****************************************************************************** 157//******************************************************************************
@@ -177,12 +176,12 @@ iiReset(i2eBordStrPtr pB)
177 // Magic number should be set, else even the address is suspect 176 // Magic number should be set, else even the address is suspect
178 if (pB->i2eValid != I2E_MAGIC) 177 if (pB->i2eValid != I2E_MAGIC)
179 { 178 {
180 COMPLETE(pB, I2EE_BADMAGIC); 179 I2_COMPLETE(pB, I2EE_BADMAGIC);
181 } 180 }
182 181
183 OUTB(pB->i2eBase + FIFO_RESET, 0); // Any data will do 182 outb(0, pB->i2eBase + FIFO_RESET); /* Any data will do */
184 iiDelay(pB, 50); // Pause between resets 183 iiDelay(pB, 50); // Pause between resets
185 OUTB(pB->i2eBase + FIFO_RESET, 0); // Second reset 184 outb(0, pB->i2eBase + FIFO_RESET); /* Second reset */
186 185
187 // We must wait before even attempting to read anything from the FIFO: the 186 // We must wait before even attempting to read anything from the FIFO: the
188 // board's P.O.S.T may actually attempt to read and write its end of the 187 // board's P.O.S.T may actually attempt to read and write its end of the
@@ -203,7 +202,7 @@ iiReset(i2eBordStrPtr pB)
203 // Ensure anything which would have been of use to standard loadware is 202 // Ensure anything which would have been of use to standard loadware is
204 // blanked out, since board has now forgotten everything!. 203 // blanked out, since board has now forgotten everything!.
205 204
206 pB->i2eUsingIrq = IRQ_UNDEFINED; // Not set up to use an interrupt yet 205 pB->i2eUsingIrq = I2_IRQ_UNDEFINED; /* to not use an interrupt so far */
207 pB->i2eWaitingForEmptyFifo = 0; 206 pB->i2eWaitingForEmptyFifo = 0;
208 pB->i2eOutMailWaiting = 0; 207 pB->i2eOutMailWaiting = 0;
209 pB->i2eChannelPtr = NULL; 208 pB->i2eChannelPtr = NULL;
@@ -215,7 +214,7 @@ iiReset(i2eBordStrPtr pB)
215 pB->i2eFatalTrap = NULL; 214 pB->i2eFatalTrap = NULL;
216 pB->i2eFatal = 0; 215 pB->i2eFatal = 0;
217 216
218 COMPLETE(pB, I2EE_GOOD); 217 I2_COMPLETE(pB, I2EE_GOOD);
219} 218}
220 219
221//****************************************************************************** 220//******************************************************************************
@@ -235,14 +234,14 @@ static int
235iiResetDelay(i2eBordStrPtr pB) 234iiResetDelay(i2eBordStrPtr pB)
236{ 235{
237 if (pB->i2eValid != I2E_MAGIC) { 236 if (pB->i2eValid != I2E_MAGIC) {
238 COMPLETE(pB, I2EE_BADMAGIC); 237 I2_COMPLETE(pB, I2EE_BADMAGIC);
239 } 238 }
240 if (pB->i2eState != II_STATE_RESET) { 239 if (pB->i2eState != II_STATE_RESET) {
241 COMPLETE(pB, I2EE_BADSTATE); 240 I2_COMPLETE(pB, I2EE_BADSTATE);
242 } 241 }
243 iiDelay(pB,2000); /* Now we wait for two seconds. */ 242 iiDelay(pB,2000); /* Now we wait for two seconds. */
244 iiDelayed = 1; /* Delay has been called: ok to initialize */ 243 iiDelayed = 1; /* Delay has been called: ok to initialize */
245 COMPLETE(pB, I2EE_GOOD); 244 I2_COMPLETE(pB, I2EE_GOOD);
246} 245}
247 246
248//****************************************************************************** 247//******************************************************************************
@@ -273,12 +272,12 @@ iiInitialize(i2eBordStrPtr pB)
273 272
274 if (pB->i2eValid != I2E_MAGIC) 273 if (pB->i2eValid != I2E_MAGIC)
275 { 274 {
276 COMPLETE(pB, I2EE_BADMAGIC); 275 I2_COMPLETE(pB, I2EE_BADMAGIC);
277 } 276 }
278 277
279 if (pB->i2eState != II_STATE_RESET || !iiDelayed) 278 if (pB->i2eState != II_STATE_RESET || !iiDelayed)
280 { 279 {
281 COMPLETE(pB, I2EE_BADSTATE); 280 I2_COMPLETE(pB, I2EE_BADSTATE);
282 } 281 }
283 282
284 // In case there is a failure short of our completely reading the power-up 283 // In case there is a failure short of our completely reading the power-up
@@ -291,13 +290,12 @@ iiInitialize(i2eBordStrPtr pB)
291 for (itemp = 0; itemp < sizeof(porStr); itemp++) 290 for (itemp = 0; itemp < sizeof(porStr); itemp++)
292 { 291 {
293 // We expect the entire message is ready. 292 // We expect the entire message is ready.
294 if (HAS_NO_INPUT(pB)) 293 if (!I2_HAS_INPUT(pB)) {
295 {
296 pB->i2ePomSize = itemp; 294 pB->i2ePomSize = itemp;
297 COMPLETE(pB, I2EE_PORM_SHORT); 295 I2_COMPLETE(pB, I2EE_PORM_SHORT);
298 } 296 }
299 297
300 pB->i2ePom.c[itemp] = c = BYTE_FROM(pB); 298 pB->i2ePom.c[itemp] = c = inb(pB->i2eData);
301 299
302 // We check the magic numbers as soon as they are supposed to be read 300 // We check the magic numbers as soon as they are supposed to be read
303 // (rather than after) to minimize effect of reading something we 301 // (rather than after) to minimize effect of reading something we
@@ -306,22 +304,22 @@ iiInitialize(i2eBordStrPtr pB)
306 (itemp == POR_2_INDEX && c != POR_MAGIC_2)) 304 (itemp == POR_2_INDEX && c != POR_MAGIC_2))
307 { 305 {
308 pB->i2ePomSize = itemp+1; 306 pB->i2ePomSize = itemp+1;
309 COMPLETE(pB, I2EE_BADMAGIC); 307 I2_COMPLETE(pB, I2EE_BADMAGIC);
310 } 308 }
311 } 309 }
312 310
313 pB->i2ePomSize = itemp; 311 pB->i2ePomSize = itemp;
314 312
315 // Ensure that this was all the data... 313 // Ensure that this was all the data...
316 if (HAS_INPUT(pB)) 314 if (I2_HAS_INPUT(pB))
317 COMPLETE(pB, I2EE_PORM_LONG); 315 I2_COMPLETE(pB, I2EE_PORM_LONG);
318 316
319 // For now, we'll fail to initialize if P.O.S.T reports bad chip mapper: 317 // For now, we'll fail to initialize if P.O.S.T reports bad chip mapper:
320 // Implying we will not be able to download any code either: That's ok: the 318 // Implying we will not be able to download any code either: That's ok: the
321 // condition is pretty explicit. 319 // condition is pretty explicit.
322 if (pB->i2ePom.e.porDiag1 & POR_BAD_MAPPER) 320 if (pB->i2ePom.e.porDiag1 & POR_BAD_MAPPER)
323 { 321 {
324 COMPLETE(pB, I2EE_POSTERR); 322 I2_COMPLETE(pB, I2EE_POSTERR);
325 } 323 }
326 324
327 // Determine anything which must be done differently depending on the family 325 // Determine anything which must be done differently depending on the family
@@ -332,7 +330,7 @@ iiInitialize(i2eBordStrPtr pB)
332 330
333 pB->i2eFifoStyle = FIFO_II; 331 pB->i2eFifoStyle = FIFO_II;
334 pB->i2eFifoSize = 512; // 512 bytes, always 332 pB->i2eFifoSize = 512; // 512 bytes, always
335 pB->i2eDataWidth16 = NO; 333 pB->i2eDataWidth16 = false;
336 334
337 pB->i2eMaxIrq = 15; // Because board cannot tell us it is in an 8-bit 335 pB->i2eMaxIrq = 15; // Because board cannot tell us it is in an 8-bit
338 // slot, we do allow it to be done (documentation!) 336 // slot, we do allow it to be done (documentation!)
@@ -354,7 +352,7 @@ iiInitialize(i2eBordStrPtr pB)
354 // should always be consistent for IntelliPort-II. Ditto below... 352 // should always be consistent for IntelliPort-II. Ditto below...
355 if (pB->i2ePom.e.porPorts1 != 4) 353 if (pB->i2ePom.e.porPorts1 != 4)
356 { 354 {
357 COMPLETE(pB, I2EE_INCONSIST); 355 I2_COMPLETE(pB, I2EE_INCONSIST);
358 } 356 }
359 break; 357 break;
360 358
@@ -364,7 +362,7 @@ iiInitialize(i2eBordStrPtr pB)
364 pB->i2eChannelMap[0] = 0xff; // Eight port 362 pB->i2eChannelMap[0] = 0xff; // Eight port
365 if (pB->i2ePom.e.porPorts1 != 8) 363 if (pB->i2ePom.e.porPorts1 != 8)
366 { 364 {
367 COMPLETE(pB, I2EE_INCONSIST); 365 I2_COMPLETE(pB, I2EE_INCONSIST);
368 } 366 }
369 break; 367 break;
370 368
@@ -373,7 +371,7 @@ iiInitialize(i2eBordStrPtr pB)
373 pB->i2eChannelMap[0] = 0x3f; // Six Port 371 pB->i2eChannelMap[0] = 0x3f; // Six Port
374 if (pB->i2ePom.e.porPorts1 != 6) 372 if (pB->i2ePom.e.porPorts1 != 6)
375 { 373 {
376 COMPLETE(pB, I2EE_INCONSIST); 374 I2_COMPLETE(pB, I2EE_INCONSIST);
377 } 375 }
378 break; 376 break;
379 } 377 }
@@ -402,7 +400,7 @@ iiInitialize(i2eBordStrPtr pB)
402 400
403 if (itemp < 8 || itemp > 15) 401 if (itemp < 8 || itemp > 15)
404 { 402 {
405 COMPLETE(pB, I2EE_INCONSIST); 403 I2_COMPLETE(pB, I2EE_INCONSIST);
406 } 404 }
407 pB->i2eFifoSize = (1 << itemp); 405 pB->i2eFifoSize = (1 << itemp);
408 406
@@ -450,26 +448,26 @@ iiInitialize(i2eBordStrPtr pB)
450 switch (pB->i2ePom.e.porBus & (POR_BUS_SLOT16 | POR_BUS_DIP16) ) 448 switch (pB->i2ePom.e.porBus & (POR_BUS_SLOT16 | POR_BUS_DIP16) )
451 { 449 {
452 case POR_BUS_SLOT16 | POR_BUS_DIP16: 450 case POR_BUS_SLOT16 | POR_BUS_DIP16:
453 pB->i2eDataWidth16 = YES; 451 pB->i2eDataWidth16 = true;
454 pB->i2eMaxIrq = 15; 452 pB->i2eMaxIrq = 15;
455 break; 453 break;
456 454
457 case POR_BUS_SLOT16: 455 case POR_BUS_SLOT16:
458 pB->i2eDataWidth16 = NO; 456 pB->i2eDataWidth16 = false;
459 pB->i2eMaxIrq = 15; 457 pB->i2eMaxIrq = 15;
460 break; 458 break;
461 459
462 case 0: 460 case 0:
463 case POR_BUS_DIP16: // In an 8-bit slot, DIP switch don't care. 461 case POR_BUS_DIP16: // In an 8-bit slot, DIP switch don't care.
464 default: 462 default:
465 pB->i2eDataWidth16 = NO; 463 pB->i2eDataWidth16 = false;
466 pB->i2eMaxIrq = 7; 464 pB->i2eMaxIrq = 7;
467 break; 465 break;
468 } 466 }
469 break; // POR_ID_FIIEX case 467 break; // POR_ID_FIIEX case
470 468
471 default: // Unknown type of board 469 default: // Unknown type of board
472 COMPLETE(pB, I2EE_BAD_FAMILY); 470 I2_COMPLETE(pB, I2EE_BAD_FAMILY);
473 break; 471 break;
474 } // End the switch based on family 472 } // End the switch based on family
475 473
@@ -483,17 +481,14 @@ iiInitialize(i2eBordStrPtr pB)
483 { 481 {
484 case POR_BUS_T_ISA: 482 case POR_BUS_T_ISA:
485 case POR_BUS_T_UNK: // If the type of bus is undeclared, assume ok. 483 case POR_BUS_T_UNK: // If the type of bus is undeclared, assume ok.
486 pB->i2eChangeIrq = YES;
487 break;
488 case POR_BUS_T_MCA: 484 case POR_BUS_T_MCA:
489 case POR_BUS_T_EISA: 485 case POR_BUS_T_EISA:
490 pB->i2eChangeIrq = NO;
491 break; 486 break;
492 default: 487 default:
493 COMPLETE(pB, I2EE_BADBUS); 488 I2_COMPLETE(pB, I2EE_BADBUS);
494 } 489 }
495 490
496 if (pB->i2eDataWidth16 == YES) 491 if (pB->i2eDataWidth16)
497 { 492 {
498 pB->i2eWriteBuf = iiWriteBuf16; 493 pB->i2eWriteBuf = iiWriteBuf16;
499 pB->i2eReadBuf = iiReadBuf16; 494 pB->i2eReadBuf = iiReadBuf16;
@@ -529,7 +524,7 @@ iiInitialize(i2eBordStrPtr pB)
529 break; 524 break;
530 525
531 default: 526 default:
532 COMPLETE(pB, I2EE_INCONSIST); 527 I2_COMPLETE(pB, I2EE_INCONSIST);
533 } 528 }
534 529
535 // Initialize state information. 530 // Initialize state information.
@@ -549,7 +544,7 @@ iiInitialize(i2eBordStrPtr pB)
549 // Everything is ok now, return with good status/ 544 // Everything is ok now, return with good status/
550 545
551 pB->i2eValid = I2E_MAGIC; 546 pB->i2eValid = I2E_MAGIC;
552 COMPLETE(pB, I2EE_GOOD); 547 I2_COMPLETE(pB, I2EE_GOOD);
553} 548}
554 549
555//****************************************************************************** 550//******************************************************************************
@@ -658,7 +653,7 @@ ii2DelayIO(unsigned int mseconds)
658 while(mseconds--) { 653 while(mseconds--) {
659 int i = ii2DelValue; 654 int i = ii2DelValue;
660 while ( i-- ) { 655 while ( i-- ) {
661 INB ( ii2Safe ); 656 inb(ii2Safe);
662 } 657 }
663 } 658 }
664} 659}
@@ -709,11 +704,11 @@ iiWriteBuf16(i2eBordStrPtr pB, unsigned char *address, int count)
709{ 704{
710 // Rudimentary sanity checking here. 705 // Rudimentary sanity checking here.
711 if (pB->i2eValid != I2E_MAGIC) 706 if (pB->i2eValid != I2E_MAGIC)
712 COMPLETE(pB, I2EE_INVALID); 707 I2_COMPLETE(pB, I2EE_INVALID);
713 708
714 OUTSW ( pB->i2eData, address, count); 709 I2_OUTSW(pB->i2eData, address, count);
715 710
716 COMPLETE(pB, I2EE_GOOD); 711 I2_COMPLETE(pB, I2EE_GOOD);
717} 712}
718 713
719//****************************************************************************** 714//******************************************************************************
@@ -738,11 +733,11 @@ iiWriteBuf8(i2eBordStrPtr pB, unsigned char *address, int count)
738{ 733{
739 /* Rudimentary sanity checking here */ 734 /* Rudimentary sanity checking here */
740 if (pB->i2eValid != I2E_MAGIC) 735 if (pB->i2eValid != I2E_MAGIC)
741 COMPLETE(pB, I2EE_INVALID); 736 I2_COMPLETE(pB, I2EE_INVALID);
742 737
743 OUTSB ( pB->i2eData, address, count ); 738 I2_OUTSB(pB->i2eData, address, count);
744 739
745 COMPLETE(pB, I2EE_GOOD); 740 I2_COMPLETE(pB, I2EE_GOOD);
746} 741}
747 742
748//****************************************************************************** 743//******************************************************************************
@@ -767,11 +762,11 @@ iiReadBuf16(i2eBordStrPtr pB, unsigned char *address, int count)
767{ 762{
768 // Rudimentary sanity checking here. 763 // Rudimentary sanity checking here.
769 if (pB->i2eValid != I2E_MAGIC) 764 if (pB->i2eValid != I2E_MAGIC)
770 COMPLETE(pB, I2EE_INVALID); 765 I2_COMPLETE(pB, I2EE_INVALID);
771 766
772 INSW ( pB->i2eData, address, count); 767 I2_INSW(pB->i2eData, address, count);
773 768
774 COMPLETE(pB, I2EE_GOOD); 769 I2_COMPLETE(pB, I2EE_GOOD);
775} 770}
776 771
777//****************************************************************************** 772//******************************************************************************
@@ -796,11 +791,11 @@ iiReadBuf8(i2eBordStrPtr pB, unsigned char *address, int count)
796{ 791{
797 // Rudimentary sanity checking here. 792 // Rudimentary sanity checking here.
798 if (pB->i2eValid != I2E_MAGIC) 793 if (pB->i2eValid != I2E_MAGIC)
799 COMPLETE(pB, I2EE_INVALID); 794 I2_COMPLETE(pB, I2EE_INVALID);
800 795
801 INSB ( pB->i2eData, address, count); 796 I2_INSB(pB->i2eData, address, count);
802 797
803 COMPLETE(pB, I2EE_GOOD); 798 I2_COMPLETE(pB, I2EE_GOOD);
804} 799}
805 800
806//****************************************************************************** 801//******************************************************************************
@@ -820,7 +815,7 @@ iiReadBuf8(i2eBordStrPtr pB, unsigned char *address, int count)
820static unsigned short 815static unsigned short
821iiReadWord16(i2eBordStrPtr pB) 816iiReadWord16(i2eBordStrPtr pB)
822{ 817{
823 return (unsigned short)( INW(pB->i2eData) ); 818 return inw(pB->i2eData);
824} 819}
825 820
826//****************************************************************************** 821//******************************************************************************
@@ -842,9 +837,9 @@ iiReadWord8(i2eBordStrPtr pB)
842{ 837{
843 unsigned short urs; 838 unsigned short urs;
844 839
845 urs = INB ( pB->i2eData ); 840 urs = inb(pB->i2eData);
846 841
847 return ( ( INB ( pB->i2eData ) << 8 ) | urs ); 842 return (inb(pB->i2eData) << 8) | urs;
848} 843}
849 844
850//****************************************************************************** 845//******************************************************************************
@@ -865,7 +860,7 @@ iiReadWord8(i2eBordStrPtr pB)
865static void 860static void
866iiWriteWord16(i2eBordStrPtr pB, unsigned short value) 861iiWriteWord16(i2eBordStrPtr pB, unsigned short value)
867{ 862{
868 WORD_TO(pB, (int)value); 863 outw((int)value, pB->i2eData);
869} 864}
870 865
871//****************************************************************************** 866//******************************************************************************
@@ -886,8 +881,8 @@ iiWriteWord16(i2eBordStrPtr pB, unsigned short value)
886static void 881static void
887iiWriteWord8(i2eBordStrPtr pB, unsigned short value) 882iiWriteWord8(i2eBordStrPtr pB, unsigned short value)
888{ 883{
889 BYTE_TO(pB, (char)value); 884 outb((char)value, pB->i2eData);
890 BYTE_TO(pB, (char)(value >> 8) ); 885 outb((char)(value >> 8), pB->i2eData);
891} 886}
892 887
893//****************************************************************************** 888//******************************************************************************
@@ -939,30 +934,30 @@ iiWaitForTxEmptyII(i2eBordStrPtr pB, int mSdelay)
939 // interrupts of any kind. 934 // interrupts of any kind.
940 935
941 936
942 WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) 937 write_lock_irqsave(&Dl_spinlock, flags);
943 OUTB(pB->i2ePointer, SEL_COMMAND); 938 outb(SEL_COMMAND, pB->i2ePointer);
944 OUTB(pB->i2ePointer, SEL_CMD_SH); 939 outb(SEL_CMD_SH, pB->i2ePointer);
945 940
946 itemp = INB(pB->i2eStatus); 941 itemp = inb(pB->i2eStatus);
947 942
948 OUTB(pB->i2ePointer, SEL_COMMAND); 943 outb(SEL_COMMAND, pB->i2ePointer);
949 OUTB(pB->i2ePointer, SEL_CMD_UNSH); 944 outb(SEL_CMD_UNSH, pB->i2ePointer);
950 945
951 if (itemp & ST_IN_EMPTY) 946 if (itemp & ST_IN_EMPTY)
952 { 947 {
953 UPDATE_FIFO_ROOM(pB); 948 I2_UPDATE_FIFO_ROOM(pB);
954 WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 949 write_unlock_irqrestore(&Dl_spinlock, flags);
955 COMPLETE(pB, I2EE_GOOD); 950 I2_COMPLETE(pB, I2EE_GOOD);
956 } 951 }
957 952
958 WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 953 write_unlock_irqrestore(&Dl_spinlock, flags);
959 954
960 if (mSdelay-- == 0) 955 if (mSdelay-- == 0)
961 break; 956 break;
962 957
963 iiDelay(pB, 1); /* 1 mS granularity on checking condition */ 958 iiDelay(pB, 1); /* 1 mS granularity on checking condition */
964 } 959 }
965 COMPLETE(pB, I2EE_TXE_TIME); 960 I2_COMPLETE(pB, I2EE_TXE_TIME);
966} 961}
967 962
968//****************************************************************************** 963//******************************************************************************
@@ -1002,21 +997,21 @@ iiWaitForTxEmptyIIEX(i2eBordStrPtr pB, int mSdelay)
1002 // you will generally not want to service interrupts or in any way 997 // you will generally not want to service interrupts or in any way
1003 // disrupt the assumptions implicit in the larger context. 998 // disrupt the assumptions implicit in the larger context.
1004 999
1005 WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) 1000 write_lock_irqsave(&Dl_spinlock, flags);
1006 1001
1007 if (INB(pB->i2eStatus) & STE_OUT_MT) { 1002 if (inb(pB->i2eStatus) & STE_OUT_MT) {
1008 UPDATE_FIFO_ROOM(pB); 1003 I2_UPDATE_FIFO_ROOM(pB);
1009 WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 1004 write_unlock_irqrestore(&Dl_spinlock, flags);
1010 COMPLETE(pB, I2EE_GOOD); 1005 I2_COMPLETE(pB, I2EE_GOOD);
1011 } 1006 }
1012 WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 1007 write_unlock_irqrestore(&Dl_spinlock, flags);
1013 1008
1014 if (mSdelay-- == 0) 1009 if (mSdelay-- == 0)
1015 break; 1010 break;
1016 1011
1017 iiDelay(pB, 1); // 1 mS granularity on checking condition 1012 iiDelay(pB, 1); // 1 mS granularity on checking condition
1018 } 1013 }
1019 COMPLETE(pB, I2EE_TXE_TIME); 1014 I2_COMPLETE(pB, I2EE_TXE_TIME);
1020} 1015}
1021 1016
1022//****************************************************************************** 1017//******************************************************************************
@@ -1038,8 +1033,8 @@ static int
1038iiTxMailEmptyII(i2eBordStrPtr pB) 1033iiTxMailEmptyII(i2eBordStrPtr pB)
1039{ 1034{
1040 int port = pB->i2ePointer; 1035 int port = pB->i2ePointer;
1041 OUTB ( port, SEL_OUTMAIL ); 1036 outb(SEL_OUTMAIL, port);
1042 return ( INB(port) == 0 ); 1037 return inb(port) == 0;
1043} 1038}
1044 1039
1045//****************************************************************************** 1040//******************************************************************************
@@ -1060,7 +1055,7 @@ iiTxMailEmptyII(i2eBordStrPtr pB)
1060static int 1055static int
1061iiTxMailEmptyIIEX(i2eBordStrPtr pB) 1056iiTxMailEmptyIIEX(i2eBordStrPtr pB)
1062{ 1057{
1063 return !(INB(pB->i2eStatus) & STE_OUT_MAIL); 1058 return !(inb(pB->i2eStatus) & STE_OUT_MAIL);
1064} 1059}
1065 1060
1066//****************************************************************************** 1061//******************************************************************************
@@ -1084,10 +1079,10 @@ iiTrySendMailII(i2eBordStrPtr pB, unsigned char mail)
1084{ 1079{
1085 int port = pB->i2ePointer; 1080 int port = pB->i2ePointer;
1086 1081
1087 OUTB(port, SEL_OUTMAIL); 1082 outb(SEL_OUTMAIL, port);
1088 if (INB(port) == 0) { 1083 if (inb(port) == 0) {
1089 OUTB(port, SEL_OUTMAIL); 1084 outb(SEL_OUTMAIL, port);
1090 OUTB(port, mail); 1085 outb(mail, port);
1091 return 1; 1086 return 1;
1092 } 1087 }
1093 return 0; 1088 return 0;
@@ -1112,10 +1107,9 @@ iiTrySendMailII(i2eBordStrPtr pB, unsigned char mail)
1112static int 1107static int
1113iiTrySendMailIIEX(i2eBordStrPtr pB, unsigned char mail) 1108iiTrySendMailIIEX(i2eBordStrPtr pB, unsigned char mail)
1114{ 1109{
1115 if(INB(pB->i2eStatus) & STE_OUT_MAIL) { 1110 if (inb(pB->i2eStatus) & STE_OUT_MAIL)
1116 return 0; 1111 return 0;
1117 } 1112 outb(mail, pB->i2eXMail);
1118 OUTB(pB->i2eXMail, mail);
1119 return 1; 1113 return 1;
1120} 1114}
1121 1115
@@ -1136,9 +1130,9 @@ iiTrySendMailIIEX(i2eBordStrPtr pB, unsigned char mail)
1136static unsigned short 1130static unsigned short
1137iiGetMailII(i2eBordStrPtr pB) 1131iiGetMailII(i2eBordStrPtr pB)
1138{ 1132{
1139 if (HAS_MAIL(pB)) { 1133 if (I2_HAS_MAIL(pB)) {
1140 OUTB(pB->i2ePointer, SEL_INMAIL); 1134 outb(SEL_INMAIL, pB->i2ePointer);
1141 return INB(pB->i2ePointer); 1135 return inb(pB->i2ePointer);
1142 } else { 1136 } else {
1143 return NO_MAIL_HERE; 1137 return NO_MAIL_HERE;
1144 } 1138 }
@@ -1161,11 +1155,10 @@ iiGetMailII(i2eBordStrPtr pB)
1161static unsigned short 1155static unsigned short
1162iiGetMailIIEX(i2eBordStrPtr pB) 1156iiGetMailIIEX(i2eBordStrPtr pB)
1163{ 1157{
1164 if (HAS_MAIL(pB)) { 1158 if (I2_HAS_MAIL(pB))
1165 return INB(pB->i2eXMail); 1159 return inb(pB->i2eXMail);
1166 } else { 1160 else
1167 return NO_MAIL_HERE; 1161 return NO_MAIL_HERE;
1168 }
1169} 1162}
1170 1163
1171//****************************************************************************** 1164//******************************************************************************
@@ -1184,8 +1177,8 @@ iiGetMailIIEX(i2eBordStrPtr pB)
1184static void 1177static void
1185iiEnableMailIrqII(i2eBordStrPtr pB) 1178iiEnableMailIrqII(i2eBordStrPtr pB)
1186{ 1179{
1187 OUTB(pB->i2ePointer, SEL_MASK); 1180 outb(SEL_MASK, pB->i2ePointer);
1188 OUTB(pB->i2ePointer, ST_IN_MAIL); 1181 outb(ST_IN_MAIL, pB->i2ePointer);
1189} 1182}
1190 1183
1191//****************************************************************************** 1184//******************************************************************************
@@ -1204,7 +1197,7 @@ iiEnableMailIrqII(i2eBordStrPtr pB)
1204static void 1197static void
1205iiEnableMailIrqIIEX(i2eBordStrPtr pB) 1198iiEnableMailIrqIIEX(i2eBordStrPtr pB)
1206{ 1199{
1207 OUTB(pB->i2eXMask, MX_IN_MAIL); 1200 outb(MX_IN_MAIL, pB->i2eXMask);
1208} 1201}
1209 1202
1210//****************************************************************************** 1203//******************************************************************************
@@ -1223,8 +1216,8 @@ iiEnableMailIrqIIEX(i2eBordStrPtr pB)
1223static void 1216static void
1224iiWriteMaskII(i2eBordStrPtr pB, unsigned char value) 1217iiWriteMaskII(i2eBordStrPtr pB, unsigned char value)
1225{ 1218{
1226 OUTB(pB->i2ePointer, SEL_MASK); 1219 outb(SEL_MASK, pB->i2ePointer);
1227 OUTB(pB->i2ePointer, value); 1220 outb(value, pB->i2ePointer);
1228} 1221}
1229 1222
1230//****************************************************************************** 1223//******************************************************************************
@@ -1243,7 +1236,7 @@ iiWriteMaskII(i2eBordStrPtr pB, unsigned char value)
1243static void 1236static void
1244iiWriteMaskIIEX(i2eBordStrPtr pB, unsigned char value) 1237iiWriteMaskIIEX(i2eBordStrPtr pB, unsigned char value)
1245{ 1238{
1246 OUTB(pB->i2eXMask, value); 1239 outb(value, pB->i2eXMask);
1247} 1240}
1248 1241
1249//****************************************************************************** 1242//******************************************************************************
@@ -1354,9 +1347,8 @@ iiDownloadBlock ( i2eBordStrPtr pB, loadHdrStrPtr pSource, int isStandard)
1354 // immediately and be harmless, though not strictly necessary. 1347 // immediately and be harmless, though not strictly necessary.
1355 itemp = MAX_DLOAD_ACK_TIME/10; 1348 itemp = MAX_DLOAD_ACK_TIME/10;
1356 while (--itemp) { 1349 while (--itemp) {
1357 if (HAS_INPUT(pB)) { 1350 if (I2_HAS_INPUT(pB)) {
1358 switch(BYTE_FROM(pB)) 1351 switch (inb(pB->i2eData)) {
1359 {
1360 case LOADWARE_OK: 1352 case LOADWARE_OK:
1361 pB->i2eState = 1353 pB->i2eState =
1362 isStandard ? II_STATE_STDLOADED :II_STATE_LOADED; 1354 isStandard ? II_STATE_STDLOADED :II_STATE_LOADED;
diff --git a/drivers/char/ip2/i2ellis.h b/drivers/char/ip2/i2ellis.h
index 433305062fb8..c88a64e527aa 100644
--- a/drivers/char/ip2/i2ellis.h
+++ b/drivers/char/ip2/i2ellis.h
@@ -185,10 +185,6 @@ typedef struct _i2eBordStr
185 // The highest allowable IRQ, based on the 185 // The highest allowable IRQ, based on the
186 // slot size. 186 // slot size.
187 187
188 unsigned char i2eChangeIrq;
189 // Whether tis valid to change IRQ's
190 // ISA = ok, EISA, MicroChannel, no
191
192 // Accelerators for various addresses on the board 188 // Accelerators for various addresses on the board
193 int i2eBase; // I/O Address of the Board 189 int i2eBase; // I/O Address of the Board
194 int i2eData; // From here data transfers happen 190 int i2eData; // From here data transfers happen
@@ -431,12 +427,6 @@ typedef struct _i2eBordStr
431// Manifests for i2eBordStr: 427// Manifests for i2eBordStr:
432//------------------------------------------- 428//-------------------------------------------
433 429
434#define YES 1
435#define NO 0
436
437#define NULLFUNC (void (*)(void))0
438#define NULLPTR (void *)0
439
440typedef void (*delayFunc_t)(unsigned int); 430typedef void (*delayFunc_t)(unsigned int);
441 431
442// i2eValid 432// i2eValid
@@ -494,8 +484,8 @@ typedef void (*delayFunc_t)(unsigned int);
494 484
495// i2eUsingIrq 485// i2eUsingIrq
496// 486//
497#define IRQ_UNDEFINED 0x1352 // No valid irq (or polling = 0) can ever 487#define I2_IRQ_UNDEFINED 0x1352 /* No valid irq (or polling = 0) can
498 // promote to this! 488 * ever promote to this! */
499//------------------------------------------ 489//------------------------------------------
500// Handy Macros for i2ellis.c and others 490// Handy Macros for i2ellis.c and others
501// Note these are common to -II and -IIEX 491// Note these are common to -II and -IIEX
@@ -504,41 +494,14 @@ typedef void (*delayFunc_t)(unsigned int);
504// Given a pointer to the board structure, does the input FIFO have any data or 494// Given a pointer to the board structure, does the input FIFO have any data or
505// not? 495// not?
506// 496//
507#define HAS_INPUT(pB) !(INB(pB->i2eStatus) & ST_IN_EMPTY) 497#define I2_HAS_INPUT(pB) !(inb(pB->i2eStatus) & ST_IN_EMPTY)
508#define HAS_NO_INPUT(pB) (INB(pB->i2eStatus) & ST_IN_EMPTY)
509
510// Given a pointer to board structure, read a byte or word from the fifo
511//
512#define BYTE_FROM(pB) (unsigned char)INB(pB->i2eData)
513#define WORD_FROM(pB) (unsigned short)INW(pB->i2eData)
514
515// Given a pointer to board structure, is there room for any data to be written
516// to the data fifo?
517//
518#define HAS_OUTROOM(pB) !(INB(pB->i2eStatus) & ST_OUT_FULL)
519#define HAS_NO_OUTROOM(pB) (INB(pB->i2eStatus) & ST_OUT_FULL)
520
521// Given a pointer to board structure, write a single byte to the fifo
522// structure. Note that for 16-bit interfaces, the high order byte is undefined
523// and unknown.
524//
525#define BYTE_TO(pB, c) OUTB(pB->i2eData,(c))
526
527// Write a word to the fifo structure. For 8-bit interfaces, this may have
528// unknown results.
529//
530#define WORD_TO(pB, c) OUTW(pB->i2eData,(c))
531 498
532// Given a pointer to the board structure, is there anything in the incoming 499// Given a pointer to the board structure, is there anything in the incoming
533// mailbox? 500// mailbox?
534// 501//
535#define HAS_MAIL(pB) (INB(pB->i2eStatus) & ST_IN_MAIL) 502#define I2_HAS_MAIL(pB) (inb(pB->i2eStatus) & ST_IN_MAIL)
536 503
537#define UPDATE_FIFO_ROOM(pB) (pB)->i2eFifoRemains=(pB)->i2eFifoSize 504#define I2_UPDATE_FIFO_ROOM(pB) ((pB)->i2eFifoRemains = (pB)->i2eFifoSize)
538
539// Handy macro to round up a number (like the buffer write and read routines do)
540//
541#define ROUNDUP(number) (((number)+1) & (~1))
542 505
543//------------------------------------------ 506//------------------------------------------
544// Function Declarations for i2ellis.c 507// Function Declarations for i2ellis.c
@@ -593,20 +556,11 @@ static int iiDownloadBlock(i2eBordStrPtr, loadHdrStrPtr, int);
593// 556//
594static int iiDownloadAll(i2eBordStrPtr, loadHdrStrPtr, int, int); 557static int iiDownloadAll(i2eBordStrPtr, loadHdrStrPtr, int, int);
595 558
596// Called indirectly always. Needed externally so the routine might be
597// SPECIFIED as an argument to iiReset()
598//
599//static void ii2DelayIO(unsigned int); // N-millisecond delay using
600 //hardware spin
601//static void ii2DelayTimer(unsigned int); // N-millisecond delay using Linux
602 //timer
603
604// Many functions defined here return True if good, False otherwise, with an 559// Many functions defined here return True if good, False otherwise, with an
605// error code in i2eError field. Here is a handy macro for setting the error 560// error code in i2eError field. Here is a handy macro for setting the error
606// code and returning. 561// code and returning.
607// 562//
608#define COMPLETE(pB,code) \ 563#define I2_COMPLETE(pB,code) do { \
609 do { \
610 pB->i2eError = code; \ 564 pB->i2eError = code; \
611 return (code == I2EE_GOOD);\ 565 return (code == I2EE_GOOD);\
612 } while (0) 566 } while (0)
diff --git a/drivers/char/ip2/i2hw.h b/drivers/char/ip2/i2hw.h
index 15fe04e748f4..8aa6e7ab8d5b 100644
--- a/drivers/char/ip2/i2hw.h
+++ b/drivers/char/ip2/i2hw.h
@@ -129,7 +129,6 @@ registers, use byte operations only.
129//------------------------------------------------ 129//------------------------------------------------
130// 130//
131#include "ip2types.h" 131#include "ip2types.h"
132#include "i2os.h" /* For any o.s., compiler, or host-related issues */
133 132
134//------------------------------------------------------------------------- 133//-------------------------------------------------------------------------
135// Manifests for the I/O map: 134// Manifests for the I/O map:
@@ -644,5 +643,10 @@ typedef union _loadHdrStr
644#define ABS_BIGGEST_BOX 16 // Absolute the most ports per box 643#define ABS_BIGGEST_BOX 16 // Absolute the most ports per box
645#define ABS_MOST_PORTS (ABS_MAX_BOXES * ABS_BIGGEST_BOX) 644#define ABS_MOST_PORTS (ABS_MAX_BOXES * ABS_BIGGEST_BOX)
646 645
646#define I2_OUTSW(port, addr, count) outsw((port), (addr), (((count)+1)/2))
647#define I2_OUTSB(port, addr, count) outsb((port), (addr), (((count)+1))&-2)
648#define I2_INSW(port, addr, count) insw((port), (addr), (((count)+1)/2))
649#define I2_INSB(port, addr, count) insb((port), (addr), (((count)+1))&-2)
650
647#endif // I2HW_H 651#endif // I2HW_H
648 652
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index 9c25320121ef..938879cc7bcc 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -227,17 +227,17 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
227 i2ChanStrPtr *ppCh; 227 i2ChanStrPtr *ppCh;
228 228
229 if (pB->i2eValid != I2E_MAGIC) { 229 if (pB->i2eValid != I2E_MAGIC) {
230 COMPLETE(pB, I2EE_BADMAGIC); 230 I2_COMPLETE(pB, I2EE_BADMAGIC);
231 } 231 }
232 if (pB->i2eState != II_STATE_STDLOADED) { 232 if (pB->i2eState != II_STATE_STDLOADED) {
233 COMPLETE(pB, I2EE_BADSTATE); 233 I2_COMPLETE(pB, I2EE_BADSTATE);
234 } 234 }
235 235
236 LOCK_INIT(&pB->read_fifo_spinlock); 236 rwlock_init(&pB->read_fifo_spinlock);
237 LOCK_INIT(&pB->write_fifo_spinlock); 237 rwlock_init(&pB->write_fifo_spinlock);
238 LOCK_INIT(&pB->Dbuf_spinlock); 238 rwlock_init(&pB->Dbuf_spinlock);
239 LOCK_INIT(&pB->Bbuf_spinlock); 239 rwlock_init(&pB->Bbuf_spinlock);
240 LOCK_INIT(&pB->Fbuf_spinlock); 240 rwlock_init(&pB->Fbuf_spinlock);
241 241
242 // NO LOCK needed yet - this is init 242 // NO LOCK needed yet - this is init
243 243
@@ -259,10 +259,10 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
259 if ( !(pB->i2eChannelMap[index >> 4] & (1 << (index & 0xf)) ) ) { 259 if ( !(pB->i2eChannelMap[index >> 4] & (1 << (index & 0xf)) ) ) {
260 continue; 260 continue;
261 } 261 }
262 LOCK_INIT(&pCh->Ibuf_spinlock); 262 rwlock_init(&pCh->Ibuf_spinlock);
263 LOCK_INIT(&pCh->Obuf_spinlock); 263 rwlock_init(&pCh->Obuf_spinlock);
264 LOCK_INIT(&pCh->Cbuf_spinlock); 264 rwlock_init(&pCh->Cbuf_spinlock);
265 LOCK_INIT(&pCh->Pbuf_spinlock); 265 rwlock_init(&pCh->Pbuf_spinlock);
266 // NO LOCK needed yet - this is init 266 // NO LOCK needed yet - this is init
267 // Set up validity flag according to support level 267 // Set up validity flag according to support level
268 if (pB->i2eGoodMap[index >> 4] & (1 << (index & 0xf)) ) { 268 if (pB->i2eGoodMap[index >> 4] & (1 << (index & 0xf)) ) {
@@ -347,7 +347,7 @@ i2InitChannels ( i2eBordStrPtr pB, int nChannels, i2ChanStrPtr pCh)
347 } 347 }
348 // No need to check for wrap here; this is initialization. 348 // No need to check for wrap here; this is initialization.
349 pB->i2Fbuf_stuff = stuffIndex; 349 pB->i2Fbuf_stuff = stuffIndex;
350 COMPLETE(pB, I2EE_GOOD); 350 I2_COMPLETE(pB, I2EE_GOOD);
351 351
352} 352}
353 353
@@ -374,7 +374,7 @@ i2DeQueueNeeds(i2eBordStrPtr pB, int type)
374 374
375 case NEED_INLINE: 375 case NEED_INLINE:
376 376
377 WRITE_LOCK_IRQSAVE(&pB->Dbuf_spinlock,flags); 377 write_lock_irqsave(&pB->Dbuf_spinlock, flags);
378 if ( pB->i2Dbuf_stuff != pB->i2Dbuf_strip) 378 if ( pB->i2Dbuf_stuff != pB->i2Dbuf_strip)
379 { 379 {
380 queueIndex = pB->i2Dbuf_strip; 380 queueIndex = pB->i2Dbuf_strip;
@@ -386,12 +386,12 @@ i2DeQueueNeeds(i2eBordStrPtr pB, int type)
386 pB->i2Dbuf_strip = queueIndex; 386 pB->i2Dbuf_strip = queueIndex;
387 pCh->channelNeeds &= ~NEED_INLINE; 387 pCh->channelNeeds &= ~NEED_INLINE;
388 } 388 }
389 WRITE_UNLOCK_IRQRESTORE(&pB->Dbuf_spinlock,flags); 389 write_unlock_irqrestore(&pB->Dbuf_spinlock, flags);
390 break; 390 break;
391 391
392 case NEED_BYPASS: 392 case NEED_BYPASS:
393 393
394 WRITE_LOCK_IRQSAVE(&pB->Bbuf_spinlock,flags); 394 write_lock_irqsave(&pB->Bbuf_spinlock, flags);
395 if (pB->i2Bbuf_stuff != pB->i2Bbuf_strip) 395 if (pB->i2Bbuf_stuff != pB->i2Bbuf_strip)
396 { 396 {
397 queueIndex = pB->i2Bbuf_strip; 397 queueIndex = pB->i2Bbuf_strip;
@@ -403,12 +403,12 @@ i2DeQueueNeeds(i2eBordStrPtr pB, int type)
403 pB->i2Bbuf_strip = queueIndex; 403 pB->i2Bbuf_strip = queueIndex;
404 pCh->channelNeeds &= ~NEED_BYPASS; 404 pCh->channelNeeds &= ~NEED_BYPASS;
405 } 405 }
406 WRITE_UNLOCK_IRQRESTORE(&pB->Bbuf_spinlock,flags); 406 write_unlock_irqrestore(&pB->Bbuf_spinlock, flags);
407 break; 407 break;
408 408
409 case NEED_FLOW: 409 case NEED_FLOW:
410 410
411 WRITE_LOCK_IRQSAVE(&pB->Fbuf_spinlock,flags); 411 write_lock_irqsave(&pB->Fbuf_spinlock, flags);
412 if (pB->i2Fbuf_stuff != pB->i2Fbuf_strip) 412 if (pB->i2Fbuf_stuff != pB->i2Fbuf_strip)
413 { 413 {
414 queueIndex = pB->i2Fbuf_strip; 414 queueIndex = pB->i2Fbuf_strip;
@@ -420,7 +420,7 @@ i2DeQueueNeeds(i2eBordStrPtr pB, int type)
420 pB->i2Fbuf_strip = queueIndex; 420 pB->i2Fbuf_strip = queueIndex;
421 pCh->channelNeeds &= ~NEED_FLOW; 421 pCh->channelNeeds &= ~NEED_FLOW;
422 } 422 }
423 WRITE_UNLOCK_IRQRESTORE(&pB->Fbuf_spinlock,flags); 423 write_unlock_irqrestore(&pB->Fbuf_spinlock, flags);
424 break; 424 break;
425 default: 425 default:
426 printk(KERN_ERR "i2DeQueueNeeds called with bad type:%x\n",type); 426 printk(KERN_ERR "i2DeQueueNeeds called with bad type:%x\n",type);
@@ -453,7 +453,7 @@ i2QueueNeeds(i2eBordStrPtr pB, i2ChanStrPtr pCh, int type)
453 453
454 case NEED_INLINE: 454 case NEED_INLINE:
455 455
456 WRITE_LOCK_IRQSAVE(&pB->Dbuf_spinlock,flags); 456 write_lock_irqsave(&pB->Dbuf_spinlock, flags);
457 if ( !(pCh->channelNeeds & NEED_INLINE) ) 457 if ( !(pCh->channelNeeds & NEED_INLINE) )
458 { 458 {
459 pCh->channelNeeds |= NEED_INLINE; 459 pCh->channelNeeds |= NEED_INLINE;
@@ -463,12 +463,12 @@ i2QueueNeeds(i2eBordStrPtr pB, i2ChanStrPtr pCh, int type)
463 queueIndex = 0; 463 queueIndex = 0;
464 pB->i2Dbuf_stuff = queueIndex; 464 pB->i2Dbuf_stuff = queueIndex;
465 } 465 }
466 WRITE_UNLOCK_IRQRESTORE(&pB->Dbuf_spinlock,flags); 466 write_unlock_irqrestore(&pB->Dbuf_spinlock, flags);
467 break; 467 break;
468 468
469 case NEED_BYPASS: 469 case NEED_BYPASS:
470 470
471 WRITE_LOCK_IRQSAVE(&pB->Bbuf_spinlock,flags); 471 write_lock_irqsave(&pB->Bbuf_spinlock, flags);
472 if ((type & NEED_BYPASS) && !(pCh->channelNeeds & NEED_BYPASS)) 472 if ((type & NEED_BYPASS) && !(pCh->channelNeeds & NEED_BYPASS))
473 { 473 {
474 pCh->channelNeeds |= NEED_BYPASS; 474 pCh->channelNeeds |= NEED_BYPASS;
@@ -478,12 +478,12 @@ i2QueueNeeds(i2eBordStrPtr pB, i2ChanStrPtr pCh, int type)
478 queueIndex = 0; 478 queueIndex = 0;
479 pB->i2Bbuf_stuff = queueIndex; 479 pB->i2Bbuf_stuff = queueIndex;
480 } 480 }
481 WRITE_UNLOCK_IRQRESTORE(&pB->Bbuf_spinlock,flags); 481 write_unlock_irqrestore(&pB->Bbuf_spinlock, flags);
482 break; 482 break;
483 483
484 case NEED_FLOW: 484 case NEED_FLOW:
485 485
486 WRITE_LOCK_IRQSAVE(&pB->Fbuf_spinlock,flags); 486 write_lock_irqsave(&pB->Fbuf_spinlock, flags);
487 if ((type & NEED_FLOW) && !(pCh->channelNeeds & NEED_FLOW)) 487 if ((type & NEED_FLOW) && !(pCh->channelNeeds & NEED_FLOW))
488 { 488 {
489 pCh->channelNeeds |= NEED_FLOW; 489 pCh->channelNeeds |= NEED_FLOW;
@@ -493,7 +493,7 @@ i2QueueNeeds(i2eBordStrPtr pB, i2ChanStrPtr pCh, int type)
493 queueIndex = 0; 493 queueIndex = 0;
494 pB->i2Fbuf_stuff = queueIndex; 494 pB->i2Fbuf_stuff = queueIndex;
495 } 495 }
496 WRITE_UNLOCK_IRQRESTORE(&pB->Fbuf_spinlock,flags); 496 write_unlock_irqrestore(&pB->Fbuf_spinlock, flags);
497 break; 497 break;
498 498
499 case NEED_CREDIT: 499 case NEED_CREDIT:
@@ -562,9 +562,8 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
562 pB = pCh->pMyBord; 562 pB = pCh->pMyBord;
563 563
564 // Board must also exist, and THE INTERRUPT COMMAND ALREADY SENT 564 // Board must also exist, and THE INTERRUPT COMMAND ALREADY SENT
565 if (pB->i2eValid != I2E_MAGIC || pB->i2eUsingIrq == IRQ_UNDEFINED) { 565 if (pB->i2eValid != I2E_MAGIC || pB->i2eUsingIrq == I2_IRQ_UNDEFINED)
566 return -2; 566 return -2;
567 }
568 // If the board has gone fatal, return bad, and also hit the trap routine if 567 // If the board has gone fatal, return bad, and also hit the trap routine if
569 // it exists. 568 // it exists.
570 if (pB->i2eFatal) { 569 if (pB->i2eFatal) {
@@ -620,13 +619,13 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
620 switch(type) { 619 switch(type) {
621 case PTYPE_INLINE: 620 case PTYPE_INLINE:
622 lock_var_p = &pCh->Obuf_spinlock; 621 lock_var_p = &pCh->Obuf_spinlock;
623 WRITE_LOCK_IRQSAVE(lock_var_p,flags); 622 write_lock_irqsave(lock_var_p, flags);
624 stuffIndex = pCh->Obuf_stuff; 623 stuffIndex = pCh->Obuf_stuff;
625 bufroom = pCh->Obuf_strip - stuffIndex; 624 bufroom = pCh->Obuf_strip - stuffIndex;
626 break; 625 break;
627 case PTYPE_BYPASS: 626 case PTYPE_BYPASS:
628 lock_var_p = &pCh->Cbuf_spinlock; 627 lock_var_p = &pCh->Cbuf_spinlock;
629 WRITE_LOCK_IRQSAVE(lock_var_p,flags); 628 write_lock_irqsave(lock_var_p, flags);
630 stuffIndex = pCh->Cbuf_stuff; 629 stuffIndex = pCh->Cbuf_stuff;
631 bufroom = pCh->Cbuf_strip - stuffIndex; 630 bufroom = pCh->Cbuf_strip - stuffIndex;
632 break; 631 break;
@@ -645,7 +644,7 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
645 break; /* from for()- Enough room: goto proceed */ 644 break; /* from for()- Enough room: goto proceed */
646 } 645 }
647 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize); 646 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
648 WRITE_UNLOCK_IRQRESTORE(lock_var_p, flags); 647 write_unlock_irqrestore(lock_var_p, flags);
649 } else 648 } else
650 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize); 649 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize);
651 650
@@ -747,7 +746,7 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
747 { 746 {
748 case PTYPE_INLINE: 747 case PTYPE_INLINE:
749 pCh->Obuf_stuff = stuffIndex; // Store buffer pointer 748 pCh->Obuf_stuff = stuffIndex; // Store buffer pointer
750 WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 749 write_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
751 750
752 pB->debugInlineQueued++; 751 pB->debugInlineQueued++;
753 // Add the channel pointer to list of channels needing service (first 752 // Add the channel pointer to list of channels needing service (first
@@ -757,7 +756,7 @@ i2QueueCommands(int type, i2ChanStrPtr pCh, int timeout, int nCommands,
757 756
758 case PTYPE_BYPASS: 757 case PTYPE_BYPASS:
759 pCh->Cbuf_stuff = stuffIndex; // Store buffer pointer 758 pCh->Cbuf_stuff = stuffIndex; // Store buffer pointer
760 WRITE_UNLOCK_IRQRESTORE(&pCh->Cbuf_spinlock,flags); 759 write_unlock_irqrestore(&pCh->Cbuf_spinlock, flags);
761 760
762 pB->debugBypassQueued++; 761 pB->debugBypassQueued++;
763 // Add the channel pointer to list of channels needing service (first 762 // Add the channel pointer to list of channels needing service (first
@@ -840,7 +839,7 @@ i2Input(i2ChanStrPtr pCh)
840 count = -1; 839 count = -1;
841 goto i2Input_exit; 840 goto i2Input_exit;
842 } 841 }
843 WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 842 write_lock_irqsave(&pCh->Ibuf_spinlock, flags);
844 843
845 // initialize some accelerators and private copies 844 // initialize some accelerators and private copies
846 stripIndex = pCh->Ibuf_strip; 845 stripIndex = pCh->Ibuf_strip;
@@ -850,7 +849,7 @@ i2Input(i2ChanStrPtr pCh)
850 // If buffer is empty or requested data count was 0, (trivial case) return 849 // If buffer is empty or requested data count was 0, (trivial case) return
851 // without any further thought. 850 // without any further thought.
852 if ( count == 0 ) { 851 if ( count == 0 ) {
853 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 852 write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
854 goto i2Input_exit; 853 goto i2Input_exit;
855 } 854 }
856 // Adjust for buffer wrap 855 // Adjust for buffer wrap
@@ -891,10 +890,10 @@ i2Input(i2ChanStrPtr pCh)
891 890
892 if ((pCh->sinceLastFlow += count) >= pCh->whenSendFlow) { 891 if ((pCh->sinceLastFlow += count) >= pCh->whenSendFlow) {
893 pCh->sinceLastFlow -= pCh->whenSendFlow; 892 pCh->sinceLastFlow -= pCh->whenSendFlow;
894 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 893 write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
895 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW); 894 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW);
896 } else { 895 } else {
897 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 896 write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
898 } 897 }
899 898
900i2Input_exit: 899i2Input_exit:
@@ -926,7 +925,7 @@ i2InputFlush(i2ChanStrPtr pCh)
926 925
927 ip2trace (CHANN, ITRC_INPUT, 10, 0); 926 ip2trace (CHANN, ITRC_INPUT, 10, 0);
928 927
929 WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 928 write_lock_irqsave(&pCh->Ibuf_spinlock, flags);
930 count = pCh->Ibuf_stuff - pCh->Ibuf_strip; 929 count = pCh->Ibuf_stuff - pCh->Ibuf_strip;
931 930
932 // Adjust for buffer wrap 931 // Adjust for buffer wrap
@@ -947,10 +946,10 @@ i2InputFlush(i2ChanStrPtr pCh)
947 if ( (pCh->sinceLastFlow += count) >= pCh->whenSendFlow ) 946 if ( (pCh->sinceLastFlow += count) >= pCh->whenSendFlow )
948 { 947 {
949 pCh->sinceLastFlow -= pCh->whenSendFlow; 948 pCh->sinceLastFlow -= pCh->whenSendFlow;
950 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 949 write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
951 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW); 950 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW);
952 } else { 951 } else {
953 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 952 write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
954 } 953 }
955 954
956 ip2trace (CHANN, ITRC_INPUT, 19, 1, count); 955 ip2trace (CHANN, ITRC_INPUT, 19, 1, count);
@@ -979,9 +978,9 @@ i2InputAvailable(i2ChanStrPtr pCh)
979 978
980 979
981 // initialize some accelerators and private copies 980 // initialize some accelerators and private copies
982 READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 981 read_lock_irqsave(&pCh->Ibuf_spinlock, flags);
983 count = pCh->Ibuf_stuff - pCh->Ibuf_strip; 982 count = pCh->Ibuf_stuff - pCh->Ibuf_strip;
984 READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 983 read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
985 984
986 // Adjust for buffer wrap 985 // Adjust for buffer wrap
987 if (count < 0) 986 if (count < 0)
@@ -1045,9 +1044,9 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1045 while ( count > 0 ) { 1044 while ( count > 0 ) {
1046 1045
1047 // How much room in output buffer is there? 1046 // How much room in output buffer is there?
1048 READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1047 read_lock_irqsave(&pCh->Obuf_spinlock, flags);
1049 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1; 1048 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1;
1050 READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1049 read_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
1051 if (amountToMove < 0) { 1050 if (amountToMove < 0) {
1052 amountToMove += OBUF_SIZE; 1051 amountToMove += OBUF_SIZE;
1053 } 1052 }
@@ -1075,7 +1074,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1075 if ( !(pCh->flush_flags && i2RetryFlushOutput(pCh) ) 1074 if ( !(pCh->flush_flags && i2RetryFlushOutput(pCh) )
1076 && amountToMove > 0 ) 1075 && amountToMove > 0 )
1077 { 1076 {
1078 WRITE_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1077 write_lock_irqsave(&pCh->Obuf_spinlock, flags);
1079 stuffIndex = pCh->Obuf_stuff; 1078 stuffIndex = pCh->Obuf_stuff;
1080 1079
1081 // Had room to move some data: don't know whether the block size, 1080 // Had room to move some data: don't know whether the block size,
@@ -1102,7 +1101,7 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1102 } 1101 }
1103 pCh->Obuf_stuff = stuffIndex; 1102 pCh->Obuf_stuff = stuffIndex;
1104 1103
1105 WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1104 write_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
1106 1105
1107 ip2trace (CHANN, ITRC_OUTPUT, 13, 1, stuffIndex ); 1106 ip2trace (CHANN, ITRC_OUTPUT, 13, 1, stuffIndex );
1108 1107
@@ -1352,9 +1351,9 @@ i2OutputFree(i2ChanStrPtr pCh)
1352 if ( !i2Validate ( pCh ) ) { 1351 if ( !i2Validate ( pCh ) ) {
1353 return -1; 1352 return -1;
1354 } 1353 }
1355 READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1354 read_lock_irqsave(&pCh->Obuf_spinlock, flags);
1356 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1; 1355 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1;
1357 READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1356 read_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
1358 1357
1359 if (amountToMove < 0) { 1358 if (amountToMove < 0) {
1360 amountToMove += OBUF_SIZE; 1359 amountToMove += OBUF_SIZE;
@@ -1464,11 +1463,11 @@ i2StripFifo(i2eBordStrPtr pB)
1464 1463
1465// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_ENTER, 0 ); 1464// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_ENTER, 0 );
1466 1465
1467 while (HAS_INPUT(pB)) { 1466 while (I2_HAS_INPUT(pB)) {
1468// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 2, 0 ); 1467// ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 2, 0 );
1469 1468
1470 // Process packet from fifo a one atomic unit 1469 // Process packet from fifo a one atomic unit
1471 WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock,bflags); 1470 write_lock_irqsave(&pB->read_fifo_spinlock, bflags);
1472 1471
1473 // The first word (or two bytes) will have channel number and type of 1472 // The first word (or two bytes) will have channel number and type of
1474 // packet, possibly other information 1473 // packet, possibly other information
@@ -1490,7 +1489,8 @@ i2StripFifo(i2eBordStrPtr pB)
1490// sick! 1489// sick!
1491 if ( ((unsigned int)count) > IBUF_SIZE ) { 1490 if ( ((unsigned int)count) > IBUF_SIZE ) {
1492 pB->i2eFatal = 2; 1491 pB->i2eFatal = 2;
1493 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1492 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1493 bflags);
1494 return; /* Bail out ASAP */ 1494 return; /* Bail out ASAP */
1495 } 1495 }
1496 // Channel is illegally big ? 1496 // Channel is illegally big ?
@@ -1498,7 +1498,8 @@ i2StripFifo(i2eBordStrPtr pB)
1498 (NULL==(pCh = ((i2ChanStrPtr*)pB->i2eChannelPtr)[channel]))) 1498 (NULL==(pCh = ((i2ChanStrPtr*)pB->i2eChannelPtr)[channel])))
1499 { 1499 {
1500 iiReadBuf(pB, junkBuffer, count); 1500 iiReadBuf(pB, junkBuffer, count);
1501 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1501 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1502 bflags);
1502 break; /* From switch: ready for next packet */ 1503 break; /* From switch: ready for next packet */
1503 } 1504 }
1504 1505
@@ -1512,14 +1513,15 @@ i2StripFifo(i2eBordStrPtr pB)
1512 if(ID_OF(pB->i2eLeadoffWord) == ID_HOT_KEY) 1513 if(ID_OF(pB->i2eLeadoffWord) == ID_HOT_KEY)
1513 { 1514 {
1514 pCh->hotKeyIn = iiReadWord(pB) & 0xff; 1515 pCh->hotKeyIn = iiReadWord(pB) & 0xff;
1515 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1516 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1517 bflags);
1516 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_HOTACK); 1518 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_HOTACK);
1517 break; /* From the switch: ready for next packet */ 1519 break; /* From the switch: ready for next packet */
1518 } 1520 }
1519 1521
1520 // Normal data! We crudely assume there is room for the data in our 1522 // Normal data! We crudely assume there is room for the data in our
1521 // buffer because the board wouldn't have exceeded his credit limit. 1523 // buffer because the board wouldn't have exceeded his credit limit.
1522 WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,cflags); 1524 write_lock_irqsave(&pCh->Ibuf_spinlock, cflags);
1523 // We have 2 locks now 1525 // We have 2 locks now
1524 stuffIndex = pCh->Ibuf_stuff; 1526 stuffIndex = pCh->Ibuf_stuff;
1525 amountToRead = IBUF_SIZE - stuffIndex; 1527 amountToRead = IBUF_SIZE - stuffIndex;
@@ -1562,8 +1564,9 @@ i2StripFifo(i2eBordStrPtr pB)
1562 1564
1563 // Update stuff index 1565 // Update stuff index
1564 pCh->Ibuf_stuff = stuffIndex; 1566 pCh->Ibuf_stuff = stuffIndex;
1565 WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,cflags); 1567 write_unlock_irqrestore(&pCh->Ibuf_spinlock, cflags);
1566 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1568 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1569 bflags);
1567 1570
1568#ifdef USE_IQ 1571#ifdef USE_IQ
1569 schedule_work(&pCh->tqueue_input); 1572 schedule_work(&pCh->tqueue_input);
@@ -1585,7 +1588,8 @@ i2StripFifo(i2eBordStrPtr pB)
1585 1588
1586 iiReadBuf(pB, cmdBuffer, count); 1589 iiReadBuf(pB, cmdBuffer, count);
1587 // We can release early with buffer grab 1590 // We can release early with buffer grab
1588 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1591 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1592 bflags);
1589 1593
1590 pc = cmdBuffer; 1594 pc = cmdBuffer;
1591 pcLimit = &(cmdBuffer[count]); 1595 pcLimit = &(cmdBuffer[count]);
@@ -1830,12 +1834,12 @@ i2StripFifo(i2eBordStrPtr pB)
1830 default: // Neither packet? should be impossible 1834 default: // Neither packet? should be impossible
1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1, 1835 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1,
1832 PTYPE_OF(pB->i2eLeadoffWord) ); 1836 PTYPE_OF(pB->i2eLeadoffWord) );
1833 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, 1837 write_unlock_irqrestore(&pB->read_fifo_spinlock,
1834 bflags); 1838 bflags);
1835 1839
1836 break; 1840 break;
1837 } // End of switch on type of packets 1841 } // End of switch on type of packets
1838 } //while(board HAS_INPUT) 1842 } /*while(board I2_HAS_INPUT)*/
1839 1843
1840 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_RETURN, 0 ); 1844 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_RETURN, 0 );
1841 1845
@@ -1858,7 +1862,7 @@ i2Write2Fifo(i2eBordStrPtr pB, unsigned char *source, int count,int reserve)
1858{ 1862{
1859 int rc = 0; 1863 int rc = 0;
1860 unsigned long flags; 1864 unsigned long flags;
1861 WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1865 write_lock_irqsave(&pB->write_fifo_spinlock, flags);
1862 if (!pB->i2eWaitingForEmptyFifo) { 1866 if (!pB->i2eWaitingForEmptyFifo) {
1863 if (pB->i2eFifoRemains > (count+reserve)) { 1867 if (pB->i2eFifoRemains > (count+reserve)) {
1864 pB->i2eFifoRemains -= count; 1868 pB->i2eFifoRemains -= count;
@@ -1867,7 +1871,7 @@ i2Write2Fifo(i2eBordStrPtr pB, unsigned char *source, int count,int reserve)
1867 rc = count; 1871 rc = count;
1868 } 1872 }
1869 } 1873 }
1870 WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1874 write_unlock_irqrestore(&pB->write_fifo_spinlock, flags);
1871 return rc; 1875 return rc;
1872} 1876}
1873//****************************************************************************** 1877//******************************************************************************
@@ -1898,7 +1902,7 @@ i2StuffFifoBypass(i2eBordStrPtr pB)
1898 while ( --bailout && notClogged && 1902 while ( --bailout && notClogged &&
1899 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_BYPASS)))) 1903 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_BYPASS))))
1900 { 1904 {
1901 WRITE_LOCK_IRQSAVE(&pCh->Cbuf_spinlock,flags); 1905 write_lock_irqsave(&pCh->Cbuf_spinlock, flags);
1902 stripIndex = pCh->Cbuf_strip; 1906 stripIndex = pCh->Cbuf_strip;
1903 1907
1904 // as long as there are packets for this channel... 1908 // as long as there are packets for this channel...
@@ -1906,7 +1910,7 @@ i2StuffFifoBypass(i2eBordStrPtr pB)
1906 while (stripIndex != pCh->Cbuf_stuff) { 1910 while (stripIndex != pCh->Cbuf_stuff) {
1907 pRemove = &(pCh->Cbuf[stripIndex]); 1911 pRemove = &(pCh->Cbuf[stripIndex]);
1908 packetSize = CMD_COUNT_OF(pRemove) + sizeof(i2CmdHeader); 1912 packetSize = CMD_COUNT_OF(pRemove) + sizeof(i2CmdHeader);
1909 paddedSize = ROUNDUP(packetSize); 1913 paddedSize = roundup(packetSize, 2);
1910 1914
1911 if (paddedSize > 0) { 1915 if (paddedSize > 0) {
1912 if ( 0 == i2Write2Fifo(pB, pRemove, paddedSize,0)) { 1916 if ( 0 == i2Write2Fifo(pB, pRemove, paddedSize,0)) {
@@ -1930,7 +1934,7 @@ WriteDBGBuf("BYPS", pRemove, paddedSize);
1930 // Done with this channel. Move to next, removing this one from 1934 // Done with this channel. Move to next, removing this one from
1931 // the queue of channels if we cleaned it out (i.e., didn't get clogged. 1935 // the queue of channels if we cleaned it out (i.e., didn't get clogged.
1932 pCh->Cbuf_strip = stripIndex; 1936 pCh->Cbuf_strip = stripIndex;
1933 WRITE_UNLOCK_IRQRESTORE(&pCh->Cbuf_spinlock,flags); 1937 write_unlock_irqrestore(&pCh->Cbuf_spinlock, flags);
1934 } // Either clogged or finished all the work 1938 } // Either clogged or finished all the work
1935 1939
1936#ifdef IP2DEBUG_TRACE 1940#ifdef IP2DEBUG_TRACE
@@ -1954,7 +1958,7 @@ static inline void
1954i2StuffFifoFlow(i2eBordStrPtr pB) 1958i2StuffFifoFlow(i2eBordStrPtr pB)
1955{ 1959{
1956 i2ChanStrPtr pCh; 1960 i2ChanStrPtr pCh;
1957 unsigned short paddedSize = ROUNDUP(sizeof(flowIn)); 1961 unsigned short paddedSize = roundup(sizeof(flowIn), 2);
1958 1962
1959 ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2, 1963 ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2,
1960 pB->i2eFifoRemains, paddedSize ); 1964 pB->i2eFifoRemains, paddedSize );
@@ -2010,7 +2014,7 @@ i2StuffFifoInline(i2eBordStrPtr pB)
2010 while ( --bailout && notClogged && 2014 while ( --bailout && notClogged &&
2011 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_INLINE))) ) 2015 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_INLINE))) )
2012 { 2016 {
2013 WRITE_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 2017 write_lock_irqsave(&pCh->Obuf_spinlock, flags);
2014 stripIndex = pCh->Obuf_strip; 2018 stripIndex = pCh->Obuf_strip;
2015 2019
2016 ip2trace (CHANN, ITRC_SICMD, 3, 2, stripIndex, pCh->Obuf_stuff ); 2020 ip2trace (CHANN, ITRC_SICMD, 3, 2, stripIndex, pCh->Obuf_stuff );
@@ -2031,7 +2035,7 @@ i2StuffFifoInline(i2eBordStrPtr pB)
2031 packetSize = flowsize + sizeof(i2CmdHeader); 2035 packetSize = flowsize + sizeof(i2CmdHeader);
2032 } 2036 }
2033 flowsize = CREDIT_USAGE(flowsize); 2037 flowsize = CREDIT_USAGE(flowsize);
2034 paddedSize = ROUNDUP(packetSize); 2038 paddedSize = roundup(packetSize, 2);
2035 2039
2036 ip2trace (CHANN, ITRC_SICMD, 4, 2, pB->i2eFifoRemains, paddedSize ); 2040 ip2trace (CHANN, ITRC_SICMD, 4, 2, pB->i2eFifoRemains, paddedSize );
2037 2041
@@ -2086,7 +2090,7 @@ WriteDBGBuf("DATA", pRemove, paddedSize);
2086 // Done with this channel. Move to next, removing this one from the 2090 // Done with this channel. Move to next, removing this one from the
2087 // queue of channels if we cleaned it out (i.e., didn't get clogged. 2091 // queue of channels if we cleaned it out (i.e., didn't get clogged.
2088 pCh->Obuf_strip = stripIndex; 2092 pCh->Obuf_strip = stripIndex;
2089 WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 2093 write_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
2090 if ( notClogged ) 2094 if ( notClogged )
2091 { 2095 {
2092 2096
@@ -2190,10 +2194,11 @@ i2ServiceBoard ( i2eBordStrPtr pB )
2190 2194
2191 if (inmail & MB_OUT_STRIPPED) { 2195 if (inmail & MB_OUT_STRIPPED) {
2192 pB->i2eFifoOutInts++; 2196 pB->i2eFifoOutInts++;
2193 WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 2197 write_lock_irqsave(&pB->write_fifo_spinlock, flags);
2194 pB->i2eFifoRemains = pB->i2eFifoSize; 2198 pB->i2eFifoRemains = pB->i2eFifoSize;
2195 pB->i2eWaitingForEmptyFifo = 0; 2199 pB->i2eWaitingForEmptyFifo = 0;
2196 WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 2200 write_unlock_irqrestore(&pB->write_fifo_spinlock,
2201 flags);
2197 2202
2198 ip2trace (ITRC_NO_PORT, ITRC_INTR, 30, 1, pB->i2eFifoRemains ); 2203 ip2trace (ITRC_NO_PORT, ITRC_INTR, 30, 1, pB->i2eFifoRemains );
2199 2204
diff --git a/drivers/char/ip2/i2os.h b/drivers/char/ip2/i2os.h
deleted file mode 100644
index eff9b542d699..000000000000
--- a/drivers/char/ip2/i2os.h
+++ /dev/null
@@ -1,127 +0,0 @@
1/*******************************************************************************
2*
3* (c) 1999 by Computone Corporation
4*
5********************************************************************************
6*
7*
8* PACKAGE: Linux tty Device Driver for IntelliPort II family of multiport
9* serial I/O controllers.
10*
11* DESCRIPTION: Defines, definitions and includes which are heavily dependent
12* on O/S, host, compiler, etc. This file is tailored for:
13* Linux v2.0.0 and later
14* Gnu gcc c2.7.2
15* 80x86 architecture
16*
17*******************************************************************************/
18
19#ifndef I2OS_H /* To prevent multiple includes */
20#define I2OS_H 1
21
22//-------------------------------------------------
23// Required Includes
24//-------------------------------------------------
25
26#include "ip2types.h"
27#include <asm/io.h> /* For inb, etc */
28
29//------------------------------------
30// Defines for I/O instructions:
31//------------------------------------
32
33#define INB(port) inb(port)
34#define OUTB(port,value) outb((value),(port))
35#define INW(port) inw(port)
36#define OUTW(port,value) outw((value),(port))
37#define OUTSW(port,addr,count) outsw((port),(addr),(((count)+1)/2))
38#define OUTSB(port,addr,count) outsb((port),(addr),(((count)+1))&-2)
39#define INSW(port,addr,count) insw((port),(addr),(((count)+1)/2))
40#define INSB(port,addr,count) insb((port),(addr),(((count)+1))&-2)
41
42//--------------------------------------------
43// Interrupt control
44//--------------------------------------------
45
46#define LOCK_INIT(a) rwlock_init(a)
47
48#define SAVE_AND_DISABLE_INTS(a,b) { \
49 /* printk("get_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
50 spin_lock_irqsave(a,b); \
51}
52
53#define RESTORE_INTS(a,b) { \
54 /* printk("rel_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
55 spin_unlock_irqrestore(a,b); \
56}
57
58#define READ_LOCK_IRQSAVE(a,b) { \
59 /* printk("get_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
60 read_lock_irqsave(a,b); \
61}
62
63#define READ_UNLOCK_IRQRESTORE(a,b) { \
64 /* printk("rel_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
65 read_unlock_irqrestore(a,b); \
66}
67
68#define WRITE_LOCK_IRQSAVE(a,b) { \
69 /* printk("get_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
70 write_lock_irqsave(a,b); \
71}
72
73#define WRITE_UNLOCK_IRQRESTORE(a,b) { \
74 /* printk("rel_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \
75 write_unlock_irqrestore(a,b); \
76}
77
78
79//------------------------------------------------------------------------------
80// Hardware-delay loop
81//
82// Probably used in only one place (see i2ellis.c) but this helps keep things
83// together. Note we have unwound the IN instructions. On machines with a
84// reasonable cache, the eight instructions (1 byte each) should fit in cache
85// nicely, and on un-cached machines, the code-fetch would tend not to dominate.
86// Note that cx is shifted so that "count" still reflects the total number of
87// iterations assuming no unwinding.
88//------------------------------------------------------------------------------
89
90//#define DELAY1MS(port,count,label)
91
92//------------------------------------------------------------------------------
93// Macros to switch to a new stack, saving stack pointers, and to restore the
94// old stack (Used, for example, in i2lib.c) "heap" is the address of some
95// buffer which will become the new stack (working down from highest address).
96// The two words at the two lowest addresses in this stack are for storing the
97// SS and SP.
98//------------------------------------------------------------------------------
99
100//#define TO_NEW_STACK(heap,size)
101//#define TO_OLD_STACK(heap)
102
103//------------------------------------------------------------------------------
104// Macros to save the original IRQ vectors and masks, and to patch in new ones.
105//------------------------------------------------------------------------------
106
107//#define SAVE_IRQ_MASKS(dest)
108//#define WRITE_IRQ_MASKS(src)
109//#define SAVE_IRQ_VECTOR(value,dest)
110//#define WRITE_IRQ_VECTOR(value,src)
111
112//------------------------------------------------------------------------------
113// Macro to copy data from one far pointer to another.
114//------------------------------------------------------------------------------
115
116#define I2_MOVE_DATA(fpSource,fpDest,count) memmove(fpDest,fpSource,count);
117
118//------------------------------------------------------------------------------
119// Macros to issue eoi's to host interrupt control (IBM AT 8259-style).
120//------------------------------------------------------------------------------
121
122//#define MASTER_EOI
123//#define SLAVE_EOI
124
125#endif /* I2OS_H */
126
127
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c
index 0a61856c631f..70957acaa960 100644
--- a/drivers/char/ip2/ip2main.c
+++ b/drivers/char/ip2/ip2main.c
@@ -169,7 +169,7 @@ static int Fip_firmware_size;
169static int ip2_open(PTTY, struct file *); 169static int ip2_open(PTTY, struct file *);
170static void ip2_close(PTTY, struct file *); 170static void ip2_close(PTTY, struct file *);
171static int ip2_write(PTTY, const unsigned char *, int); 171static int ip2_write(PTTY, const unsigned char *, int);
172static void ip2_putchar(PTTY, unsigned char); 172static int ip2_putchar(PTTY, unsigned char);
173static void ip2_flush_chars(PTTY); 173static void ip2_flush_chars(PTTY);
174static int ip2_write_room(PTTY); 174static int ip2_write_room(PTTY);
175static int ip2_chars_in_buf(PTTY); 175static int ip2_chars_in_buf(PTTY);
@@ -355,14 +355,15 @@ have_requested_irq( char irq )
355/* the driver initialisation function and returns what it returns. */ 355/* the driver initialisation function and returns what it returns. */
356/******************************************************************************/ 356/******************************************************************************/
357#ifdef MODULE 357#ifdef MODULE
358int 358static int __init
359init_module(void) 359ip2_init_module(void)
360{ 360{
361#ifdef IP2DEBUG_INIT 361#ifdef IP2DEBUG_INIT
362 printk (KERN_DEBUG "Loading module ...\n" ); 362 printk (KERN_DEBUG "Loading module ...\n" );
363#endif 363#endif
364 return 0; 364 return 0;
365} 365}
366module_init(ip2_init_module);
366#endif /* MODULE */ 367#endif /* MODULE */
367 368
368/******************************************************************************/ 369/******************************************************************************/
@@ -381,8 +382,8 @@ init_module(void)
381/* driver should be returned since it may be unloaded from memory. */ 382/* driver should be returned since it may be unloaded from memory. */
382/******************************************************************************/ 383/******************************************************************************/
383#ifdef MODULE 384#ifdef MODULE
384void 385void __exit
385cleanup_module(void) 386ip2_cleanup_module(void)
386{ 387{
387 int err; 388 int err;
388 int i; 389 int i;
@@ -452,6 +453,7 @@ cleanup_module(void)
452 printk (KERN_DEBUG "IP2 Unloaded\n" ); 453 printk (KERN_DEBUG "IP2 Unloaded\n" );
453#endif 454#endif
454} 455}
456module_exit(ip2_cleanup_module);
455#endif /* MODULE */ 457#endif /* MODULE */
456 458
457static const struct tty_operations ip2_ops = { 459static const struct tty_operations ip2_ops = {
@@ -1050,9 +1052,9 @@ set_irq( int boardnum, int boardIrq )
1050 * Write to FIFO; don't bother to adjust fifo capacity for this, since 1052 * Write to FIFO; don't bother to adjust fifo capacity for this, since
1051 * board will respond almost immediately after SendMail hit. 1053 * board will respond almost immediately after SendMail hit.
1052 */ 1054 */
1053 WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1055 write_lock_irqsave(&pB->write_fifo_spinlock, flags);
1054 iiWriteBuf(pB, tempCommand, 4); 1056 iiWriteBuf(pB, tempCommand, 4);
1055 WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1057 write_unlock_irqrestore(&pB->write_fifo_spinlock, flags);
1056 pB->i2eUsingIrq = boardIrq; 1058 pB->i2eUsingIrq = boardIrq;
1057 pB->i2eOutMailWaiting |= MB_OUT_STUFFED; 1059 pB->i2eOutMailWaiting |= MB_OUT_STUFFED;
1058 1060
@@ -1070,9 +1072,9 @@ set_irq( int boardnum, int boardIrq )
1070 (CMD_OF(tempCommand))[4] = 64; // chars 1072 (CMD_OF(tempCommand))[4] = 64; // chars
1071 1073
1072 (CMD_OF(tempCommand))[5] = 87; // HW_TEST 1074 (CMD_OF(tempCommand))[5] = 87; // HW_TEST
1073 WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1075 write_lock_irqsave(&pB->write_fifo_spinlock, flags);
1074 iiWriteBuf(pB, tempCommand, 8); 1076 iiWriteBuf(pB, tempCommand, 8);
1075 WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1077 write_unlock_irqrestore(&pB->write_fifo_spinlock, flags);
1076 1078
1077 CHANNEL_OF(tempCommand) = 0; 1079 CHANNEL_OF(tempCommand) = 0;
1078 PTYPE_OF(tempCommand) = PTYPE_BYPASS; 1080 PTYPE_OF(tempCommand) = PTYPE_BYPASS;
@@ -1087,9 +1089,9 @@ set_irq( int boardnum, int boardIrq )
1087 CMD_COUNT_OF(tempCommand) = 2; 1089 CMD_COUNT_OF(tempCommand) = 2;
1088 (CMD_OF(tempCommand))[0] = 44; /* get ping */ 1090 (CMD_OF(tempCommand))[0] = 44; /* get ping */
1089 (CMD_OF(tempCommand))[1] = 200; /* 200 ms */ 1091 (CMD_OF(tempCommand))[1] = 200; /* 200 ms */
1090 WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1092 write_lock_irqsave(&pB->write_fifo_spinlock, flags);
1091 iiWriteBuf(pB, tempCommand, 4); 1093 iiWriteBuf(pB, tempCommand, 4);
1092 WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1094 write_unlock_irqrestore(&pB->write_fifo_spinlock, flags);
1093#endif 1095#endif
1094 1096
1095 iiEnableMailIrq(pB); 1097 iiEnableMailIrq(pB);
@@ -1268,12 +1270,12 @@ static void do_input(struct work_struct *work)
1268 1270
1269 // Data input 1271 // Data input
1270 if ( pCh->pTTY != NULL ) { 1272 if ( pCh->pTTY != NULL ) {
1271 READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags) 1273 read_lock_irqsave(&pCh->Ibuf_spinlock, flags);
1272 if (!pCh->throttled && (pCh->Ibuf_stuff != pCh->Ibuf_strip)) { 1274 if (!pCh->throttled && (pCh->Ibuf_stuff != pCh->Ibuf_strip)) {
1273 READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1275 read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
1274 i2Input( pCh ); 1276 i2Input( pCh );
1275 } else 1277 } else
1276 READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1278 read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
1277 } else { 1279 } else {
1278 ip2trace(CHANN, ITRC_INPUT, 22, 0 ); 1280 ip2trace(CHANN, ITRC_INPUT, 22, 0 );
1279 1281
@@ -1614,10 +1616,8 @@ ip2_close( PTTY tty, struct file *pFile )
1614 1616
1615 serviceOutgoingFifo ( pCh->pMyBord ); 1617 serviceOutgoingFifo ( pCh->pMyBord );
1616 1618
1617 if ( tty->driver->flush_buffer ) 1619 tty_ldisc_flush(tty);
1618 tty->driver->flush_buffer(tty); 1620 tty_driver_flush_buffer(tty);
1619 if ( tty->ldisc.flush_buffer )
1620 tty->ldisc.flush_buffer(tty);
1621 tty->closing = 0; 1621 tty->closing = 0;
1622 1622
1623 pCh->pTTY = NULL; 1623 pCh->pTTY = NULL;
@@ -1717,9 +1717,9 @@ ip2_write( PTTY tty, const unsigned char *pData, int count)
1717 ip2_flush_chars( tty ); 1717 ip2_flush_chars( tty );
1718 1718
1719 /* This is the actual move bit. Make sure it does what we need!!!!! */ 1719 /* This is the actual move bit. Make sure it does what we need!!!!! */
1720 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1720 write_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1721 bytesSent = i2Output( pCh, pData, count); 1721 bytesSent = i2Output( pCh, pData, count);
1722 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1722 write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1723 1723
1724 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); 1724 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent );
1725 1725
@@ -1736,7 +1736,7 @@ ip2_write( PTTY tty, const unsigned char *pData, int count)
1736/* */ 1736/* */
1737/* */ 1737/* */
1738/******************************************************************************/ 1738/******************************************************************************/
1739static void 1739static int
1740ip2_putchar( PTTY tty, unsigned char ch ) 1740ip2_putchar( PTTY tty, unsigned char ch )
1741{ 1741{
1742 i2ChanStrPtr pCh = tty->driver_data; 1742 i2ChanStrPtr pCh = tty->driver_data;
@@ -1744,13 +1744,14 @@ ip2_putchar( PTTY tty, unsigned char ch )
1744 1744
1745// ip2trace (CHANN, ITRC_PUTC, ITRC_ENTER, 1, ch ); 1745// ip2trace (CHANN, ITRC_PUTC, ITRC_ENTER, 1, ch );
1746 1746
1747 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1747 write_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1748 pCh->Pbuf[pCh->Pbuf_stuff++] = ch; 1748 pCh->Pbuf[pCh->Pbuf_stuff++] = ch;
1749 if ( pCh->Pbuf_stuff == sizeof pCh->Pbuf ) { 1749 if ( pCh->Pbuf_stuff == sizeof pCh->Pbuf ) {
1750 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1750 write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1751 ip2_flush_chars( tty ); 1751 ip2_flush_chars( tty );
1752 } else 1752 } else
1753 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1753 write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1754 return 1;
1754 1755
1755// ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch ); 1756// ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch );
1756} 1757}
@@ -1770,7 +1771,7 @@ ip2_flush_chars( PTTY tty )
1770 i2ChanStrPtr pCh = tty->driver_data; 1771 i2ChanStrPtr pCh = tty->driver_data;
1771 unsigned long flags; 1772 unsigned long flags;
1772 1773
1773 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1774 write_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1774 if ( pCh->Pbuf_stuff ) { 1775 if ( pCh->Pbuf_stuff ) {
1775 1776
1776// ip2trace (CHANN, ITRC_PUTC, 10, 1, strip ); 1777// ip2trace (CHANN, ITRC_PUTC, 10, 1, strip );
@@ -1784,7 +1785,7 @@ ip2_flush_chars( PTTY tty )
1784 } 1785 }
1785 pCh->Pbuf_stuff -= strip; 1786 pCh->Pbuf_stuff -= strip;
1786 } 1787 }
1787 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1788 write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1788} 1789}
1789 1790
1790/******************************************************************************/ 1791/******************************************************************************/
@@ -1802,9 +1803,9 @@ ip2_write_room ( PTTY tty )
1802 i2ChanStrPtr pCh = tty->driver_data; 1803 i2ChanStrPtr pCh = tty->driver_data;
1803 unsigned long flags; 1804 unsigned long flags;
1804 1805
1805 READ_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1806 read_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1806 bytesFree = i2OutputFree( pCh ) - pCh->Pbuf_stuff; 1807 bytesFree = i2OutputFree( pCh ) - pCh->Pbuf_stuff;
1807 READ_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1808 read_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1808 1809
1809 ip2trace (CHANN, ITRC_WRITE, 11, 1, bytesFree ); 1810 ip2trace (CHANN, ITRC_WRITE, 11, 1, bytesFree );
1810 1811
@@ -1834,12 +1835,12 @@ ip2_chars_in_buf ( PTTY tty )
1834 pCh->Obuf_char_count + pCh->Pbuf_stuff, 1835 pCh->Obuf_char_count + pCh->Pbuf_stuff,
1835 pCh->Obuf_char_count, pCh->Pbuf_stuff ); 1836 pCh->Obuf_char_count, pCh->Pbuf_stuff );
1836#endif 1837#endif
1837 READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1838 read_lock_irqsave(&pCh->Obuf_spinlock, flags);
1838 rc = pCh->Obuf_char_count; 1839 rc = pCh->Obuf_char_count;
1839 READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1840 read_unlock_irqrestore(&pCh->Obuf_spinlock, flags);
1840 READ_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1841 read_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1841 rc += pCh->Pbuf_stuff; 1842 rc += pCh->Pbuf_stuff;
1842 READ_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1843 read_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1843 return rc; 1844 return rc;
1844} 1845}
1845 1846
@@ -1863,9 +1864,9 @@ ip2_flush_buffer( PTTY tty )
1863#ifdef IP2DEBUG_WRITE 1864#ifdef IP2DEBUG_WRITE
1864 printk (KERN_DEBUG "IP2: flush buffer\n" ); 1865 printk (KERN_DEBUG "IP2: flush buffer\n" );
1865#endif 1866#endif
1866 WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1867 write_lock_irqsave(&pCh->Pbuf_spinlock, flags);
1867 pCh->Pbuf_stuff = 0; 1868 pCh->Pbuf_stuff = 0;
1868 WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1869 write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags);
1869 i2FlushOutput( pCh ); 1870 i2FlushOutput( pCh );
1870 ip2_owake(tty); 1871 ip2_owake(tty);
1871 1872
@@ -1951,15 +1952,15 @@ ip2_unthrottle ( PTTY tty )
1951 pCh->throttled = 0; 1952 pCh->throttled = 0;
1952 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_RESUME); 1953 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_RESUME);
1953 serviceOutgoingFifo( pCh->pMyBord ); 1954 serviceOutgoingFifo( pCh->pMyBord );
1954 READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags) 1955 read_lock_irqsave(&pCh->Ibuf_spinlock, flags);
1955 if ( pCh->Ibuf_stuff != pCh->Ibuf_strip ) { 1956 if ( pCh->Ibuf_stuff != pCh->Ibuf_strip ) {
1956 READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1957 read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
1957#ifdef IP2DEBUG_READ 1958#ifdef IP2DEBUG_READ
1958 printk (KERN_DEBUG "i2Input called from unthrottle\n" ); 1959 printk (KERN_DEBUG "i2Input called from unthrottle\n" );
1959#endif 1960#endif
1960 i2Input( pCh ); 1961 i2Input( pCh );
1961 } else 1962 } else
1962 READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1963 read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags);
1963} 1964}
1964 1965
1965static void 1966static void
@@ -2202,9 +2203,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
2202 * for masking). Caller should use TIOCGICOUNT to see which one it was 2203 * for masking). Caller should use TIOCGICOUNT to see which one it was
2203 */ 2204 */
2204 case TIOCMIWAIT: 2205 case TIOCMIWAIT:
2205 WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2206 write_lock_irqsave(&pB->read_fifo_spinlock, flags);
2206 cprev = pCh->icount; /* note the counters on entry */ 2207 cprev = pCh->icount; /* note the counters on entry */
2207 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2208 write_unlock_irqrestore(&pB->read_fifo_spinlock, flags);
2208 i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4, 2209 i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4,
2209 CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP); 2210 CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP);
2210 init_waitqueue_entry(&wait, current); 2211 init_waitqueue_entry(&wait, current);
@@ -2224,9 +2225,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
2224 rc = -ERESTARTSYS; 2225 rc = -ERESTARTSYS;
2225 break; 2226 break;
2226 } 2227 }
2227 WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2228 write_lock_irqsave(&pB->read_fifo_spinlock, flags);
2228 cnow = pCh->icount; /* atomic copy */ 2229 cnow = pCh->icount; /* atomic copy */
2229 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2230 write_unlock_irqrestore(&pB->read_fifo_spinlock, flags);
2230 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 2231 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2231 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { 2232 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) {
2232 rc = -EIO; /* no change => rc */ 2233 rc = -EIO; /* no change => rc */
@@ -2264,9 +2265,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg )
2264 case TIOCGICOUNT: 2265 case TIOCGICOUNT:
2265 ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc ); 2266 ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc );
2266 2267
2267 WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2268 write_lock_irqsave(&pB->read_fifo_spinlock, flags);
2268 cnow = pCh->icount; 2269 cnow = pCh->icount;
2269 WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2270 write_unlock_irqrestore(&pB->read_fifo_spinlock, flags);
2270 p_cuser = argp; 2271 p_cuser = argp;
2271 rc = put_user(cnow.cts, &p_cuser->cts); 2272 rc = put_user(cnow.cts, &p_cuser->cts);
2272 rc = put_user(cnow.dsr, &p_cuser->dsr); 2273 rc = put_user(cnow.dsr, &p_cuser->dsr);
@@ -2872,7 +2873,7 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg )
2872 case 65: /* Board - ip2stat */ 2873 case 65: /* Board - ip2stat */
2873 if ( pB ) { 2874 if ( pB ) {
2874 rc = copy_to_user(argp, pB, sizeof(i2eBordStr)); 2875 rc = copy_to_user(argp, pB, sizeof(i2eBordStr));
2875 rc = put_user(INB(pB->i2eStatus), 2876 rc = put_user(inb(pB->i2eStatus),
2876 (ULONG __user *)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) ); 2877 (ULONG __user *)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) );
2877 } else { 2878 } else {
2878 rc = -ENODEV; 2879 rc = -ENODEV;
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index eba2883b630e..4f3cefa8eb0e 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -126,8 +126,8 @@
126#include <linux/delay.h> 126#include <linux/delay.h>
127#include <linux/ioport.h> 127#include <linux/ioport.h>
128 128
129#include <asm/uaccess.h> 129#include <linux/uaccess.h>
130#include <asm/io.h> 130#include <linux/io.h>
131#include <asm/system.h> 131#include <asm/system.h>
132 132
133#include <linux/pci.h> 133#include <linux/pci.h>
@@ -189,7 +189,7 @@ struct isi_board {
189 unsigned short status; 189 unsigned short status;
190 unsigned short port_status; /* each bit for each port */ 190 unsigned short port_status; /* each bit for each port */
191 unsigned short shift_count; 191 unsigned short shift_count;
192 struct isi_port * ports; 192 struct isi_port *ports;
193 signed char count; 193 signed char count;
194 spinlock_t card_lock; /* Card wide lock 11/5/00 -sameer */ 194 spinlock_t card_lock; /* Card wide lock 11/5/00 -sameer */
195 unsigned long flags; 195 unsigned long flags;
@@ -205,11 +205,11 @@ struct isi_port {
205 u16 channel; 205 u16 channel;
206 u16 status; 206 u16 status;
207 u16 closing_wait; 207 u16 closing_wait;
208 struct isi_board * card; 208 struct isi_board *card;
209 struct tty_struct * tty; 209 struct tty_struct *tty;
210 wait_queue_head_t close_wait; 210 wait_queue_head_t close_wait;
211 wait_queue_head_t open_wait; 211 wait_queue_head_t open_wait;
212 unsigned char * xmit_buf; 212 unsigned char *xmit_buf;
213 int xmit_head; 213 int xmit_head;
214 int xmit_tail; 214 int xmit_tail;
215 int xmit_cnt; 215 int xmit_cnt;
@@ -405,7 +405,7 @@ static void isicom_tx(unsigned long _data)
405 405
406 /* find next active board */ 406 /* find next active board */
407 card = (prev_card + 1) & 0x0003; 407 card = (prev_card + 1) & 0x0003;
408 while(count-- > 0) { 408 while (count-- > 0) {
409 if (isi_card[card].status & BOARD_ACTIVE) 409 if (isi_card[card].status & BOARD_ACTIVE)
410 break; 410 break;
411 card = (card + 1) & 0x0003; 411 card = (card + 1) & 0x0003;
@@ -428,7 +428,7 @@ static void isicom_tx(unsigned long _data)
428 if (retries >= 100) 428 if (retries >= 100)
429 goto unlock; 429 goto unlock;
430 430
431 for (;count > 0;count--, port++) { 431 for (; count > 0; count--, port++) {
432 /* port not active or tx disabled to force flow control */ 432 /* port not active or tx disabled to force flow control */
433 if (!(port->flags & ASYNC_INITIALIZED) || 433 if (!(port->flags & ASYNC_INITIALIZED) ||
434 !(port->status & ISI_TXOK)) 434 !(port->status & ISI_TXOK))
@@ -471,9 +471,10 @@ static void isicom_tx(unsigned long _data)
471 break; 471 break;
472 } 472 }
473 } 473 }
474 if (cnt <= 0) break; 474 if (cnt <= 0)
475 break;
475 word_count = cnt >> 1; 476 word_count = cnt >> 1;
476 outsw(base, port->xmit_buf+port->xmit_tail,word_count); 477 outsw(base, port->xmit_buf+port->xmit_tail, word_count);
477 port->xmit_tail = (port->xmit_tail 478 port->xmit_tail = (port->xmit_tail
478 + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1); 479 + (word_count << 1)) & (SERIAL_XMIT_SIZE - 1);
479 txcount -= (word_count << 1); 480 txcount -= (word_count << 1);
@@ -556,7 +557,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
556 tty = port->tty; 557 tty = port->tty;
557 if (tty == NULL) { 558 if (tty == NULL) {
558 word_count = byte_count >> 1; 559 word_count = byte_count >> 1;
559 while(byte_count > 1) { 560 while (byte_count > 1) {
560 inw(base); 561 inw(base);
561 byte_count -= 2; 562 byte_count -= 2;
562 } 563 }
@@ -569,7 +570,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
569 570
570 if (header & 0x8000) { /* Status Packet */ 571 if (header & 0x8000) { /* Status Packet */
571 header = inw(base); 572 header = inw(base);
572 switch(header & 0xff) { 573 switch (header & 0xff) {
573 case 0: /* Change in EIA signals */ 574 case 0: /* Change in EIA signals */
574 if (port->flags & ASYNC_CHECK_CD) { 575 if (port->flags & ASYNC_CHECK_CD) {
575 if (port->status & ISI_DCD) { 576 if (port->status & ISI_DCD) {
@@ -656,7 +657,8 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
656 if (byte_count > 0) { 657 if (byte_count > 0) {
657 pr_dbg("Intr(0x%lx:%d): Flip buffer overflow! dropping " 658 pr_dbg("Intr(0x%lx:%d): Flip buffer overflow! dropping "
658 "bytes...\n", base, channel + 1); 659 "bytes...\n", base, channel + 1);
659 while(byte_count > 0) { /* drain out unread xtra data */ 660 /* drain out unread xtra data */
661 while (byte_count > 0) {
660 inw(base); 662 inw(base);
661 byte_count -= 2; 663 byte_count -= 2;
662 } 664 }
@@ -679,8 +681,11 @@ static void isicom_config_port(struct isi_port *port)
679 shift_count = card->shift_count; 681 shift_count = card->shift_count;
680 unsigned char flow_ctrl; 682 unsigned char flow_ctrl;
681 683
682 if (!(tty = port->tty) || !tty->termios) 684 tty = port->tty;
685
686 if (tty == NULL)
683 return; 687 return;
688 /* FIXME: Switch to new tty baud API */
684 baud = C_BAUD(tty); 689 baud = C_BAUD(tty);
685 if (baud & CBAUDEX) { 690 if (baud & CBAUDEX) {
686 baud &= ~CBAUDEX; 691 baud &= ~CBAUDEX;
@@ -706,7 +711,7 @@ static void isicom_config_port(struct isi_port *port)
706 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) 711 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
707 baud++; /* 57.6 Kbps */ 712 baud++; /* 57.6 Kbps */
708 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) 713 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
709 baud +=2; /* 115 Kbps */ 714 baud += 2; /* 115 Kbps */
710 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) 715 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
711 baud += 3; /* 230 kbps*/ 716 baud += 3; /* 230 kbps*/
712 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 717 if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
@@ -716,15 +721,14 @@ static void isicom_config_port(struct isi_port *port)
716 /* hang up */ 721 /* hang up */
717 drop_dtr(port); 722 drop_dtr(port);
718 return; 723 return;
719 } 724 } else
720 else
721 raise_dtr(port); 725 raise_dtr(port);
722 726
723 if (WaitTillCardIsFree(base) == 0) { 727 if (WaitTillCardIsFree(base) == 0) {
724 outw(0x8000 | (channel << shift_count) |0x03, base); 728 outw(0x8000 | (channel << shift_count) | 0x03, base);
725 outw(linuxb_to_isib[baud] << 8 | 0x03, base); 729 outw(linuxb_to_isib[baud] << 8 | 0x03, base);
726 channel_setup = 0; 730 channel_setup = 0;
727 switch(C_CSIZE(tty)) { 731 switch (C_CSIZE(tty)) {
728 case CS5: 732 case CS5:
729 channel_setup |= ISICOM_CS5; 733 channel_setup |= ISICOM_CS5;
730 break; 734 break;
@@ -767,7 +771,7 @@ static void isicom_config_port(struct isi_port *port)
767 flow_ctrl |= ISICOM_INITIATE_XONXOFF; 771 flow_ctrl |= ISICOM_INITIATE_XONXOFF;
768 772
769 if (WaitTillCardIsFree(base) == 0) { 773 if (WaitTillCardIsFree(base) == 0) {
770 outw(0x8000 | (channel << shift_count) |0x04, base); 774 outw(0x8000 | (channel << shift_count) | 0x04, base);
771 outw(flow_ctrl << 8 | 0x05, base); 775 outw(flow_ctrl << 8 | 0x05, base);
772 outw((STOP_CHAR(tty)) << 8 | (START_CHAR(tty)), base); 776 outw((STOP_CHAR(tty)) << 8 | (START_CHAR(tty)), base);
773 InterruptTheCard(base); 777 InterruptTheCard(base);
@@ -805,20 +809,17 @@ static int isicom_setup_port(struct isi_port *port)
805 struct isi_board *card = port->card; 809 struct isi_board *card = port->card;
806 unsigned long flags; 810 unsigned long flags;
807 811
808 if (port->flags & ASYNC_INITIALIZED) { 812 if (port->flags & ASYNC_INITIALIZED)
809 return 0; 813 return 0;
810 }
811 if (!port->xmit_buf) { 814 if (!port->xmit_buf) {
812 unsigned long page; 815 /* Relies on BKL */
813 816 unsigned long page = get_zeroed_page(GFP_KERNEL);
814 if (!(page = get_zeroed_page(GFP_KERNEL))) 817 if (page == 0)
815 return -ENOMEM; 818 return -ENOMEM;
816 819 if (port->xmit_buf)
817 if (port->xmit_buf) {
818 free_page(page); 820 free_page(page);
819 return -ERESTARTSYS; 821 else
820 } 822 port->xmit_buf = (unsigned char *) page;
821 port->xmit_buf = (unsigned char *) page;
822 } 823 }
823 824
824 spin_lock_irqsave(&card->card_lock, flags); 825 spin_lock_irqsave(&card->card_lock, flags);
@@ -949,21 +950,18 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
949 port->count++; 950 port->count++;
950 tty->driver_data = port; 951 tty->driver_data = port;
951 port->tty = tty; 952 port->tty = tty;
952 if ((error = isicom_setup_port(port))!=0) 953 error = isicom_setup_port(port);
953 return error; 954 if (error == 0)
954 if ((error = block_til_ready(tty, filp, port))!=0) 955 error = block_til_ready(tty, filp, port);
955 return error; 956 return error;
956
957 return 0;
958} 957}
959 958
960/* close et all */ 959/* close et all */
961 960
962static inline void isicom_shutdown_board(struct isi_board *bp) 961static inline void isicom_shutdown_board(struct isi_board *bp)
963{ 962{
964 if (bp->status & BOARD_ACTIVE) { 963 if (bp->status & BOARD_ACTIVE)
965 bp->status &= ~BOARD_ACTIVE; 964 bp->status &= ~BOARD_ACTIVE;
966 }
967} 965}
968 966
969/* card->lock HAS to be held */ 967/* card->lock HAS to be held */
@@ -1012,6 +1010,22 @@ static void isicom_shutdown_port(struct isi_port *port)
1012 } 1010 }
1013} 1011}
1014 1012
1013static void isicom_flush_buffer(struct tty_struct *tty)
1014{
1015 struct isi_port *port = tty->driver_data;
1016 struct isi_board *card = port->card;
1017 unsigned long flags;
1018
1019 if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer"))
1020 return;
1021
1022 spin_lock_irqsave(&card->card_lock, flags);
1023 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1024 spin_unlock_irqrestore(&card->card_lock, flags);
1025
1026 tty_wakeup(tty);
1027}
1028
1015static void isicom_close(struct tty_struct *tty, struct file *filp) 1029static void isicom_close(struct tty_struct *tty, struct file *filp)
1016{ 1030{
1017 struct isi_port *port = tty->driver_data; 1031 struct isi_port *port = tty->driver_data;
@@ -1065,8 +1079,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
1065 isicom_shutdown_port(port); 1079 isicom_shutdown_port(port);
1066 spin_unlock_irqrestore(&card->card_lock, flags); 1080 spin_unlock_irqrestore(&card->card_lock, flags);
1067 1081
1068 if (tty->driver->flush_buffer) 1082 isicom_flush_buffer(tty);
1069 tty->driver->flush_buffer(tty);
1070 tty_ldisc_flush(tty); 1083 tty_ldisc_flush(tty);
1071 1084
1072 spin_lock_irqsave(&card->card_lock, flags); 1085 spin_lock_irqsave(&card->card_lock, flags);
@@ -1104,7 +1117,7 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,
1104 1117
1105 spin_lock_irqsave(&card->card_lock, flags); 1118 spin_lock_irqsave(&card->card_lock, flags);
1106 1119
1107 while(1) { 1120 while (1) {
1108 cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt 1121 cnt = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt
1109 - 1, SERIAL_XMIT_SIZE - port->xmit_head)); 1122 - 1, SERIAL_XMIT_SIZE - port->xmit_head));
1110 if (cnt <= 0) 1123 if (cnt <= 0)
@@ -1125,28 +1138,29 @@ static int isicom_write(struct tty_struct *tty, const unsigned char *buf,
1125} 1138}
1126 1139
1127/* put_char et all */ 1140/* put_char et all */
1128static void isicom_put_char(struct tty_struct *tty, unsigned char ch) 1141static int isicom_put_char(struct tty_struct *tty, unsigned char ch)
1129{ 1142{
1130 struct isi_port *port = tty->driver_data; 1143 struct isi_port *port = tty->driver_data;
1131 struct isi_board *card = port->card; 1144 struct isi_board *card = port->card;
1132 unsigned long flags; 1145 unsigned long flags;
1133 1146
1134 if (isicom_paranoia_check(port, tty->name, "isicom_put_char")) 1147 if (isicom_paranoia_check(port, tty->name, "isicom_put_char"))
1135 return; 1148 return 0;
1136 1149
1137 if (!port->xmit_buf) 1150 if (!port->xmit_buf)
1138 return; 1151 return 0;
1139 1152
1140 spin_lock_irqsave(&card->card_lock, flags); 1153 spin_lock_irqsave(&card->card_lock, flags);
1141 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { 1154 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) {
1142 spin_unlock_irqrestore(&card->card_lock, flags); 1155 spin_unlock_irqrestore(&card->card_lock, flags);
1143 return; 1156 return 0;
1144 } 1157 }
1145 1158
1146 port->xmit_buf[port->xmit_head++] = ch; 1159 port->xmit_buf[port->xmit_head++] = ch;
1147 port->xmit_head &= (SERIAL_XMIT_SIZE - 1); 1160 port->xmit_head &= (SERIAL_XMIT_SIZE - 1);
1148 port->xmit_cnt++; 1161 port->xmit_cnt++;
1149 spin_unlock_irqrestore(&card->card_lock, flags); 1162 spin_unlock_irqrestore(&card->card_lock, flags);
1163 return 1;
1150} 1164}
1151 1165
1152/* flush_chars et all */ 1166/* flush_chars et all */
@@ -1258,6 +1272,8 @@ static int isicom_set_serial_info(struct isi_port *port,
1258 if (copy_from_user(&newinfo, info, sizeof(newinfo))) 1272 if (copy_from_user(&newinfo, info, sizeof(newinfo)))
1259 return -EFAULT; 1273 return -EFAULT;
1260 1274
1275 lock_kernel();
1276
1261 reconfig_port = ((port->flags & ASYNC_SPD_MASK) != 1277 reconfig_port = ((port->flags & ASYNC_SPD_MASK) !=
1262 (newinfo.flags & ASYNC_SPD_MASK)); 1278 (newinfo.flags & ASYNC_SPD_MASK));
1263 1279
@@ -1265,12 +1281,13 @@ static int isicom_set_serial_info(struct isi_port *port,
1265 if ((newinfo.close_delay != port->close_delay) || 1281 if ((newinfo.close_delay != port->close_delay) ||
1266 (newinfo.closing_wait != port->closing_wait) || 1282 (newinfo.closing_wait != port->closing_wait) ||
1267 ((newinfo.flags & ~ASYNC_USR_MASK) != 1283 ((newinfo.flags & ~ASYNC_USR_MASK) !=
1268 (port->flags & ~ASYNC_USR_MASK))) 1284 (port->flags & ~ASYNC_USR_MASK))) {
1285 unlock_kernel();
1269 return -EPERM; 1286 return -EPERM;
1270 port->flags = ((port->flags & ~ ASYNC_USR_MASK) | 1287 }
1288 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1271 (newinfo.flags & ASYNC_USR_MASK)); 1289 (newinfo.flags & ASYNC_USR_MASK));
1272 } 1290 } else {
1273 else {
1274 port->close_delay = newinfo.close_delay; 1291 port->close_delay = newinfo.close_delay;
1275 port->closing_wait = newinfo.closing_wait; 1292 port->closing_wait = newinfo.closing_wait;
1276 port->flags = ((port->flags & ~ASYNC_FLAGS) | 1293 port->flags = ((port->flags & ~ASYNC_FLAGS) |
@@ -1282,6 +1299,7 @@ static int isicom_set_serial_info(struct isi_port *port,
1282 isicom_config_port(port); 1299 isicom_config_port(port);
1283 spin_unlock_irqrestore(&port->card->card_lock, flags); 1300 spin_unlock_irqrestore(&port->card->card_lock, flags);
1284 } 1301 }
1302 unlock_kernel();
1285 return 0; 1303 return 0;
1286} 1304}
1287 1305
@@ -1290,6 +1308,7 @@ static int isicom_get_serial_info(struct isi_port *port,
1290{ 1308{
1291 struct serial_struct out_info; 1309 struct serial_struct out_info;
1292 1310
1311 lock_kernel();
1293 memset(&out_info, 0, sizeof(out_info)); 1312 memset(&out_info, 0, sizeof(out_info));
1294/* out_info.type = ? */ 1313/* out_info.type = ? */
1295 out_info.line = port - isi_ports; 1314 out_info.line = port - isi_ports;
@@ -1299,6 +1318,7 @@ static int isicom_get_serial_info(struct isi_port *port,
1299/* out_info.baud_base = ? */ 1318/* out_info.baud_base = ? */
1300 out_info.close_delay = port->close_delay; 1319 out_info.close_delay = port->close_delay;
1301 out_info.closing_wait = port->closing_wait; 1320 out_info.closing_wait = port->closing_wait;
1321 unlock_kernel();
1302 if (copy_to_user(info, &out_info, sizeof(out_info))) 1322 if (copy_to_user(info, &out_info, sizeof(out_info)))
1303 return -EFAULT; 1323 return -EFAULT;
1304 return 0; 1324 return 0;
@@ -1314,7 +1334,7 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
1314 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl")) 1334 if (isicom_paranoia_check(port, tty->name, "isicom_ioctl"))
1315 return -ENODEV; 1335 return -ENODEV;
1316 1336
1317 switch(cmd) { 1337 switch (cmd) {
1318 case TCSBRK: 1338 case TCSBRK:
1319 retval = tty_check_change(tty); 1339 retval = tty_check_change(tty);
1320 if (retval) 1340 if (retval)
@@ -1331,19 +1351,6 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
1331 tty_wait_until_sent(tty, 0); 1351 tty_wait_until_sent(tty, 0);
1332 isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4); 1352 isicom_send_break(port, arg ? arg * (HZ/10) : HZ/4);
1333 return 0; 1353 return 0;
1334
1335 case TIOCGSOFTCAR:
1336 return put_user(C_CLOCAL(tty) ? 1 : 0,
1337 (unsigned long __user *)argp);
1338
1339 case TIOCSSOFTCAR:
1340 if (get_user(arg, (unsigned long __user *) argp))
1341 return -EFAULT;
1342 tty->termios->c_cflag =
1343 ((tty->termios->c_cflag & ~CLOCAL) |
1344 (arg ? CLOCAL : 0));
1345 return 0;
1346
1347 case TIOCGSERIAL: 1354 case TIOCGSERIAL:
1348 return isicom_get_serial_info(port, argp); 1355 return isicom_get_serial_info(port, argp);
1349 1356
@@ -1453,22 +1460,6 @@ static void isicom_hangup(struct tty_struct *tty)
1453 wake_up_interruptible(&port->open_wait); 1460 wake_up_interruptible(&port->open_wait);
1454} 1461}
1455 1462
1456/* flush_buffer et all */
1457static void isicom_flush_buffer(struct tty_struct *tty)
1458{
1459 struct isi_port *port = tty->driver_data;
1460 struct isi_board *card = port->card;
1461 unsigned long flags;
1462
1463 if (isicom_paranoia_check(port, tty->name, "isicom_flush_buffer"))
1464 return;
1465
1466 spin_lock_irqsave(&card->card_lock, flags);
1467 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1468 spin_unlock_irqrestore(&card->card_lock, flags);
1469
1470 tty_wakeup(tty);
1471}
1472 1463
1473/* 1464/*
1474 * Driver init and deinit functions 1465 * Driver init and deinit functions
@@ -1592,7 +1583,7 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1592 default: 1583 default:
1593 dev_err(&pdev->dev, "Unknown signature.\n"); 1584 dev_err(&pdev->dev, "Unknown signature.\n");
1594 goto end; 1585 goto end;
1595 } 1586 }
1596 1587
1597 retval = request_firmware(&fw, name, &pdev->dev); 1588 retval = request_firmware(&fw, name, &pdev->dev);
1598 if (retval) 1589 if (retval)
@@ -1620,7 +1611,8 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1620 if (WaitTillCardIsFree(base)) 1611 if (WaitTillCardIsFree(base))
1621 goto errrelfw; 1612 goto errrelfw;
1622 1613
1623 if ((status = inw(base + 0x4)) != 0) { 1614 status = inw(base + 0x4);
1615 if (status != 0) {
1624 dev_warn(&pdev->dev, "Card%d rejected load header:\n" 1616 dev_warn(&pdev->dev, "Card%d rejected load header:\n"
1625 KERN_WARNING "Address:0x%x\n" 1617 KERN_WARNING "Address:0x%x\n"
1626 KERN_WARNING "Count:0x%x\n" 1618 KERN_WARNING "Count:0x%x\n"
@@ -1637,12 +1629,13 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1637 if (WaitTillCardIsFree(base)) 1629 if (WaitTillCardIsFree(base))
1638 goto errrelfw; 1630 goto errrelfw;
1639 1631
1640 if ((status = inw(base + 0x4)) != 0) { 1632 status = inw(base + 0x4);
1633 if (status != 0) {
1641 dev_err(&pdev->dev, "Card%d got out of sync.Card " 1634 dev_err(&pdev->dev, "Card%d got out of sync.Card "
1642 "Status:0x%x\n", index + 1, status); 1635 "Status:0x%x\n", index + 1, status);
1643 goto errrelfw; 1636 goto errrelfw;
1644 } 1637 }
1645 } 1638 }
1646 1639
1647/* XXX: should we test it by reading it back and comparing with original like 1640/* XXX: should we test it by reading it back and comparing with original like
1648 * in load firmware package? */ 1641 * in load firmware package? */
@@ -1666,7 +1659,8 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1666 if (WaitTillCardIsFree(base)) 1659 if (WaitTillCardIsFree(base))
1667 goto errrelfw; 1660 goto errrelfw;
1668 1661
1669 if ((status = inw(base + 0x4)) != 0) { 1662 status = inw(base + 0x4);
1663 if (status != 0) {
1670 dev_warn(&pdev->dev, "Card%d rejected verify header:\n" 1664 dev_warn(&pdev->dev, "Card%d rejected verify header:\n"
1671 KERN_WARNING "Address:0x%x\n" 1665 KERN_WARNING "Address:0x%x\n"
1672 KERN_WARNING "Count:0x%x\n" 1666 KERN_WARNING "Count:0x%x\n"
@@ -1699,7 +1693,8 @@ static int __devinit load_firmware(struct pci_dev *pdev,
1699 if (WaitTillCardIsFree(base)) 1693 if (WaitTillCardIsFree(base))
1700 goto errrelfw; 1694 goto errrelfw;
1701 1695
1702 if ((status = inw(base + 0x4)) != 0) { 1696 status = inw(base + 0x4);
1697 if (status != 0) {
1703 dev_err(&pdev->dev, "Card%d verify got out of sync. " 1698 dev_err(&pdev->dev, "Card%d verify got out of sync. "
1704 "Card Status:0x%x\n", index + 1, status); 1699 "Card Status:0x%x\n", index + 1, status);
1705 goto errrelfw; 1700 goto errrelfw;
@@ -1764,7 +1759,7 @@ static int __devinit isicom_probe(struct pci_dev *pdev,
1764 index + 1); 1759 index + 1);
1765 retval = -EBUSY; 1760 retval = -EBUSY;
1766 goto errdec; 1761 goto errdec;
1767 } 1762 }
1768 1763
1769 retval = request_irq(board->irq, isicom_interrupt, 1764 retval = request_irq(board->irq, isicom_interrupt,
1770 IRQF_SHARED | IRQF_DISABLED, ISICOM_NAME, board); 1765 IRQF_SHARED | IRQF_DISABLED, ISICOM_NAME, board);
@@ -1818,7 +1813,7 @@ static int __init isicom_init(void)
1818 int retval, idx, channel; 1813 int retval, idx, channel;
1819 struct isi_port *port; 1814 struct isi_port *port;
1820 1815
1821 for(idx = 0; idx < BOARD_COUNT; idx++) { 1816 for (idx = 0; idx < BOARD_COUNT; idx++) {
1822 port = &isi_ports[idx * 16]; 1817 port = &isi_ports[idx * 16];
1823 isi_card[idx].ports = port; 1818 isi_card[idx].ports = port;
1824 spin_lock_init(&isi_card[idx].card_lock); 1819 spin_lock_init(&isi_card[idx].card_lock);
@@ -1832,7 +1827,7 @@ static int __init isicom_init(void)
1832 init_waitqueue_head(&port->open_wait); 1827 init_waitqueue_head(&port->open_wait);
1833 init_waitqueue_head(&port->close_wait); 1828 init_waitqueue_head(&port->close_wait);
1834 /* . . . */ 1829 /* . . . */
1835 } 1830 }
1836 isi_card[idx].base = 0; 1831 isi_card[idx].base = 0;
1837 isi_card[idx].irq = 0; 1832 isi_card[idx].irq = 0;
1838 } 1833 }
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index c645455c3fd1..7c8b62f162bf 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -1682,16 +1682,6 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
1682 rc = 0; 1682 rc = 0;
1683 1683
1684 switch (cmd) { 1684 switch (cmd) {
1685 case TIOCGSOFTCAR:
1686 rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
1687 (unsigned __user *) arg);
1688 break;
1689 case TIOCSSOFTCAR:
1690 if ((rc = get_user(ival, (unsigned __user *) arg)) == 0)
1691 tty->termios->c_cflag =
1692 (tty->termios->c_cflag & ~CLOCAL) |
1693 (ival ? CLOCAL : 0);
1694 break;
1695 case TIOCGSERIAL: 1685 case TIOCGSERIAL:
1696 rc = stli_getserial(portp, argp); 1686 rc = stli_getserial(portp, argp);
1697 break; 1687 break;
@@ -3267,7 +3257,7 @@ static int stli_initecp(struct stlibrd *brdp)
3267 */ 3257 */
3268 EBRDINIT(brdp); 3258 EBRDINIT(brdp);
3269 3259
3270 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3260 brdp->membase = ioremap_nocache(brdp->memaddr, brdp->memsize);
3271 if (brdp->membase == NULL) { 3261 if (brdp->membase == NULL) {
3272 retval = -ENOMEM; 3262 retval = -ENOMEM;
3273 goto err_reg; 3263 goto err_reg;
@@ -3424,7 +3414,7 @@ static int stli_initonb(struct stlibrd *brdp)
3424 */ 3414 */
3425 EBRDINIT(brdp); 3415 EBRDINIT(brdp);
3426 3416
3427 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3417 brdp->membase = ioremap_nocache(brdp->memaddr, brdp->memsize);
3428 if (brdp->membase == NULL) { 3418 if (brdp->membase == NULL) {
3429 retval = -ENOMEM; 3419 retval = -ENOMEM;
3430 goto err_reg; 3420 goto err_reg;
@@ -3675,7 +3665,7 @@ static int stli_eisamemprobe(struct stlibrd *brdp)
3675 */ 3665 */
3676 for (i = 0; (i < stli_eisamempsize); i++) { 3666 for (i = 0; (i < stli_eisamempsize); i++) {
3677 brdp->memaddr = stli_eisamemprobeaddrs[i]; 3667 brdp->memaddr = stli_eisamemprobeaddrs[i];
3678 brdp->membase = ioremap(brdp->memaddr, brdp->memsize); 3668 brdp->membase = ioremap_nocache(brdp->memaddr, brdp->memsize);
3679 if (brdp->membase == NULL) 3669 if (brdp->membase == NULL)
3680 continue; 3670 continue;
3681 3671
@@ -4433,6 +4423,8 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
4433 done = 0; 4423 done = 0;
4434 rc = 0; 4424 rc = 0;
4435 4425
4426 lock_kernel();
4427
4436 switch (cmd) { 4428 switch (cmd) {
4437 case COM_GETPORTSTATS: 4429 case COM_GETPORTSTATS:
4438 rc = stli_getportstats(NULL, argp); 4430 rc = stli_getportstats(NULL, argp);
@@ -4455,6 +4447,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
4455 done++; 4447 done++;
4456 break; 4448 break;
4457 } 4449 }
4450 unlock_kernel();
4458 4451
4459 if (done) 4452 if (done)
4460 return rc; 4453 return rc;
@@ -4472,6 +4465,8 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
4472 if (brdp->state == 0) 4465 if (brdp->state == 0)
4473 return -ENODEV; 4466 return -ENODEV;
4474 4467
4468 lock_kernel();
4469
4475 switch (cmd) { 4470 switch (cmd) {
4476 case STL_BINTR: 4471 case STL_BINTR:
4477 EBRDINTR(brdp); 4472 EBRDINTR(brdp);
@@ -4494,6 +4489,7 @@ static int stli_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, un
4494 rc = -ENOIOCTLCMD; 4489 rc = -ENOIOCTLCMD;
4495 break; 4490 break;
4496 } 4491 }
4492 unlock_kernel();
4497 return rc; 4493 return rc;
4498} 4494}
4499 4495
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 60b934adea65..7f7e798c1384 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -110,6 +110,7 @@ const int max_vals[] = {
110const int NR_TYPES = ARRAY_SIZE(max_vals); 110const int NR_TYPES = ARRAY_SIZE(max_vals);
111 111
112struct kbd_struct kbd_table[MAX_NR_CONSOLES]; 112struct kbd_struct kbd_table[MAX_NR_CONSOLES];
113EXPORT_SYMBOL_GPL(kbd_table);
113static struct kbd_struct *kbd = kbd_table; 114static struct kbd_struct *kbd = kbd_table;
114 115
115struct vt_spawn_console vt_spawn_con = { 116struct vt_spawn_console vt_spawn_con = {
@@ -260,6 +261,7 @@ void kd_mksound(unsigned int hz, unsigned int ticks)
260 } else 261 } else
261 kd_nosound(0); 262 kd_nosound(0);
262} 263}
264EXPORT_SYMBOL(kd_mksound);
263 265
264/* 266/*
265 * Setting the keyboard rate. 267 * Setting the keyboard rate.
@@ -1230,7 +1232,7 @@ static void kbd_keycode(unsigned int keycode, int down, int hw_raw)
1230 1232
1231 if (rep && 1233 if (rep &&
1232 (!vc_kbd_mode(kbd, VC_REPEAT) || 1234 (!vc_kbd_mode(kbd, VC_REPEAT) ||
1233 (tty && !L_ECHO(tty) && tty->driver->chars_in_buffer(tty)))) { 1235 (tty && !L_ECHO(tty) && tty_chars_in_buffer(tty)))) {
1234 /* 1236 /*
1235 * Don't repeat a key if the input buffers are not empty and the 1237 * Don't repeat a key if the input buffers are not empty and the
1236 * characters get aren't echoed locally. This makes key repeat 1238 * characters get aren't echoed locally. This makes key repeat
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index e60a74c66e3d..d83db5d880e0 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -74,9 +74,8 @@ static const struct file_operations mmtimer_fops = {
74 * We only have comparison registers RTC1-4 currently available per 74 * We only have comparison registers RTC1-4 currently available per
75 * node. RTC0 is used by SAL. 75 * node. RTC0 is used by SAL.
76 */ 76 */
77#define NUM_COMPARATORS 3
78/* Check for an RTC interrupt pending */ 77/* Check for an RTC interrupt pending */
79static int inline mmtimer_int_pending(int comparator) 78static int mmtimer_int_pending(int comparator)
80{ 79{
81 if (HUB_L((unsigned long *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED)) & 80 if (HUB_L((unsigned long *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED)) &
82 SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator) 81 SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator)
@@ -84,15 +83,16 @@ static int inline mmtimer_int_pending(int comparator)
84 else 83 else
85 return 0; 84 return 0;
86} 85}
86
87/* Clear the RTC interrupt pending bit */ 87/* Clear the RTC interrupt pending bit */
88static void inline mmtimer_clr_int_pending(int comparator) 88static void mmtimer_clr_int_pending(int comparator)
89{ 89{
90 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS), 90 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_EVENT_OCCURRED_ALIAS),
91 SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator); 91 SH_EVENT_OCCURRED_RTC1_INT_MASK << comparator);
92} 92}
93 93
94/* Setup timer on comparator RTC1 */ 94/* Setup timer on comparator RTC1 */
95static void inline mmtimer_setup_int_0(u64 expires) 95static void mmtimer_setup_int_0(int cpu, u64 expires)
96{ 96{
97 u64 val; 97 u64 val;
98 98
@@ -106,7 +106,7 @@ static void inline mmtimer_setup_int_0(u64 expires)
106 mmtimer_clr_int_pending(0); 106 mmtimer_clr_int_pending(0);
107 107
108 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC1_INT_CONFIG_IDX_SHFT) | 108 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC1_INT_CONFIG_IDX_SHFT) |
109 ((u64)cpu_physical_id(smp_processor_id()) << 109 ((u64)cpu_physical_id(cpu) <<
110 SH_RTC1_INT_CONFIG_PID_SHFT); 110 SH_RTC1_INT_CONFIG_PID_SHFT);
111 111
112 /* Set configuration */ 112 /* Set configuration */
@@ -122,7 +122,7 @@ static void inline mmtimer_setup_int_0(u64 expires)
122} 122}
123 123
124/* Setup timer on comparator RTC2 */ 124/* Setup timer on comparator RTC2 */
125static void inline mmtimer_setup_int_1(u64 expires) 125static void mmtimer_setup_int_1(int cpu, u64 expires)
126{ 126{
127 u64 val; 127 u64 val;
128 128
@@ -133,7 +133,7 @@ static void inline mmtimer_setup_int_1(u64 expires)
133 mmtimer_clr_int_pending(1); 133 mmtimer_clr_int_pending(1);
134 134
135 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC2_INT_CONFIG_IDX_SHFT) | 135 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC2_INT_CONFIG_IDX_SHFT) |
136 ((u64)cpu_physical_id(smp_processor_id()) << 136 ((u64)cpu_physical_id(cpu) <<
137 SH_RTC2_INT_CONFIG_PID_SHFT); 137 SH_RTC2_INT_CONFIG_PID_SHFT);
138 138
139 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_CONFIG), val); 139 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC2_INT_CONFIG), val);
@@ -144,7 +144,7 @@ static void inline mmtimer_setup_int_1(u64 expires)
144} 144}
145 145
146/* Setup timer on comparator RTC3 */ 146/* Setup timer on comparator RTC3 */
147static void inline mmtimer_setup_int_2(u64 expires) 147static void mmtimer_setup_int_2(int cpu, u64 expires)
148{ 148{
149 u64 val; 149 u64 val;
150 150
@@ -155,7 +155,7 @@ static void inline mmtimer_setup_int_2(u64 expires)
155 mmtimer_clr_int_pending(2); 155 mmtimer_clr_int_pending(2);
156 156
157 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC3_INT_CONFIG_IDX_SHFT) | 157 val = ((u64)SGI_MMTIMER_VECTOR << SH_RTC3_INT_CONFIG_IDX_SHFT) |
158 ((u64)cpu_physical_id(smp_processor_id()) << 158 ((u64)cpu_physical_id(cpu) <<
159 SH_RTC3_INT_CONFIG_PID_SHFT); 159 SH_RTC3_INT_CONFIG_PID_SHFT);
160 160
161 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_CONFIG), val); 161 HUB_S((u64 *)LOCAL_MMR_ADDR(SH_RTC3_INT_CONFIG), val);
@@ -170,22 +170,22 @@ static void inline mmtimer_setup_int_2(u64 expires)
170 * in order to insure that the setup succeeds in a deterministic time frame. 170 * in order to insure that the setup succeeds in a deterministic time frame.
171 * It will check if the interrupt setup succeeded. 171 * It will check if the interrupt setup succeeded.
172 */ 172 */
173static int inline mmtimer_setup(int comparator, unsigned long expires) 173static int mmtimer_setup(int cpu, int comparator, unsigned long expires)
174{ 174{
175 175
176 switch (comparator) { 176 switch (comparator) {
177 case 0: 177 case 0:
178 mmtimer_setup_int_0(expires); 178 mmtimer_setup_int_0(cpu, expires);
179 break; 179 break;
180 case 1: 180 case 1:
181 mmtimer_setup_int_1(expires); 181 mmtimer_setup_int_1(cpu, expires);
182 break; 182 break;
183 case 2: 183 case 2:
184 mmtimer_setup_int_2(expires); 184 mmtimer_setup_int_2(cpu, expires);
185 break; 185 break;
186 } 186 }
187 /* We might've missed our expiration time */ 187 /* We might've missed our expiration time */
188 if (rtc_time() < expires) 188 if (rtc_time() <= expires)
189 return 1; 189 return 1;
190 190
191 /* 191 /*
@@ -195,7 +195,7 @@ static int inline mmtimer_setup(int comparator, unsigned long expires)
195 return mmtimer_int_pending(comparator); 195 return mmtimer_int_pending(comparator);
196} 196}
197 197
198static int inline mmtimer_disable_int(long nasid, int comparator) 198static int mmtimer_disable_int(long nasid, int comparator)
199{ 199{
200 switch (comparator) { 200 switch (comparator) {
201 case 0: 201 case 0:
@@ -216,18 +216,124 @@ static int inline mmtimer_disable_int(long nasid, int comparator)
216 return 0; 216 return 0;
217} 217}
218 218
219#define TIMER_OFF 0xbadcabLL 219#define COMPARATOR 1 /* The comparator to use */
220 220
221/* There is one of these for each comparator */ 221#define TIMER_OFF 0xbadcabLL /* Timer is not setup */
222typedef struct mmtimer { 222#define TIMER_SET 0 /* Comparator is set for this timer */
223 spinlock_t lock ____cacheline_aligned; 223
224/* There is one of these for each timer */
225struct mmtimer {
226 struct rb_node list;
224 struct k_itimer *timer; 227 struct k_itimer *timer;
225 int i;
226 int cpu; 228 int cpu;
229};
230
231struct mmtimer_node {
232 spinlock_t lock ____cacheline_aligned;
233 struct rb_root timer_head;
234 struct rb_node *next;
227 struct tasklet_struct tasklet; 235 struct tasklet_struct tasklet;
228} mmtimer_t; 236};
237static struct mmtimer_node *timers;
238
239
240/*
241 * Add a new mmtimer struct to the node's mmtimer list.
242 * This function assumes the struct mmtimer_node is locked.
243 */
244static void mmtimer_add_list(struct mmtimer *n)
245{
246 int nodeid = n->timer->it.mmtimer.node;
247 unsigned long expires = n->timer->it.mmtimer.expires;
248 struct rb_node **link = &timers[nodeid].timer_head.rb_node;
249 struct rb_node *parent = NULL;
250 struct mmtimer *x;
251
252 /*
253 * Find the right place in the rbtree:
254 */
255 while (*link) {
256 parent = *link;
257 x = rb_entry(parent, struct mmtimer, list);
258
259 if (expires < x->timer->it.mmtimer.expires)
260 link = &(*link)->rb_left;
261 else
262 link = &(*link)->rb_right;
263 }
264
265 /*
266 * Insert the timer to the rbtree and check whether it
267 * replaces the first pending timer
268 */
269 rb_link_node(&n->list, parent, link);
270 rb_insert_color(&n->list, &timers[nodeid].timer_head);
271
272 if (!timers[nodeid].next || expires < rb_entry(timers[nodeid].next,
273 struct mmtimer, list)->timer->it.mmtimer.expires)
274 timers[nodeid].next = &n->list;
275}
276
277/*
278 * Set the comparator for the next timer.
279 * This function assumes the struct mmtimer_node is locked.
280 */
281static void mmtimer_set_next_timer(int nodeid)
282{
283 struct mmtimer_node *n = &timers[nodeid];
284 struct mmtimer *x;
285 struct k_itimer *t;
286 int o;
287
288restart:
289 if (n->next == NULL)
290 return;
229 291
230static mmtimer_t ** timers; 292 x = rb_entry(n->next, struct mmtimer, list);
293 t = x->timer;
294 if (!t->it.mmtimer.incr) {
295 /* Not an interval timer */
296 if (!mmtimer_setup(x->cpu, COMPARATOR,
297 t->it.mmtimer.expires)) {
298 /* Late setup, fire now */
299 tasklet_schedule(&n->tasklet);
300 }
301 return;
302 }
303
304 /* Interval timer */
305 o = 0;
306 while (!mmtimer_setup(x->cpu, COMPARATOR, t->it.mmtimer.expires)) {
307 unsigned long e, e1;
308 struct rb_node *next;
309 t->it.mmtimer.expires += t->it.mmtimer.incr << o;
310 t->it_overrun += 1 << o;
311 o++;
312 if (o > 20) {
313 printk(KERN_ALERT "mmtimer: cannot reschedule timer\n");
314 t->it.mmtimer.clock = TIMER_OFF;
315 n->next = rb_next(&x->list);
316 rb_erase(&x->list, &n->timer_head);
317 kfree(x);
318 goto restart;
319 }
320
321 e = t->it.mmtimer.expires;
322 next = rb_next(&x->list);
323
324 if (next == NULL)
325 continue;
326
327 e1 = rb_entry(next, struct mmtimer, list)->
328 timer->it.mmtimer.expires;
329 if (e > e1) {
330 n->next = next;
331 rb_erase(&x->list, &n->timer_head);
332 mmtimer_add_list(x);
333 goto restart;
334 }
335 }
336}
231 337
232/** 338/**
233 * mmtimer_ioctl - ioctl interface for /dev/mmtimer 339 * mmtimer_ioctl - ioctl interface for /dev/mmtimer
@@ -390,35 +496,6 @@ static int sgi_clock_set(clockid_t clockid, struct timespec *tp)
390 return 0; 496 return 0;
391} 497}
392 498
393/*
394 * Schedule the next periodic interrupt. This function will attempt
395 * to schedule a periodic interrupt later if necessary. If the scheduling
396 * of an interrupt fails then the time to skip is lengthened
397 * exponentially in order to ensure that the next interrupt
398 * can be properly scheduled..
399 */
400static int inline reschedule_periodic_timer(mmtimer_t *x)
401{
402 int n;
403 struct k_itimer *t = x->timer;
404
405 t->it.mmtimer.clock = x->i;
406 t->it_overrun--;
407
408 n = 0;
409 do {
410
411 t->it.mmtimer.expires += t->it.mmtimer.incr << n;
412 t->it_overrun += 1 << n;
413 n++;
414 if (n > 20)
415 return 1;
416
417 } while (!mmtimer_setup(x->i, t->it.mmtimer.expires));
418
419 return 0;
420}
421
422/** 499/**
423 * mmtimer_interrupt - timer interrupt handler 500 * mmtimer_interrupt - timer interrupt handler
424 * @irq: irq received 501 * @irq: irq received
@@ -435,71 +512,75 @@ static int inline reschedule_periodic_timer(mmtimer_t *x)
435static irqreturn_t 512static irqreturn_t
436mmtimer_interrupt(int irq, void *dev_id) 513mmtimer_interrupt(int irq, void *dev_id)
437{ 514{
438 int i;
439 unsigned long expires = 0; 515 unsigned long expires = 0;
440 int result = IRQ_NONE; 516 int result = IRQ_NONE;
441 unsigned indx = cpu_to_node(smp_processor_id()); 517 unsigned indx = cpu_to_node(smp_processor_id());
518 struct mmtimer *base;
442 519
443 /* 520 spin_lock(&timers[indx].lock);
444 * Do this once for each comparison register 521 base = rb_entry(timers[indx].next, struct mmtimer, list);
445 */ 522 if (base == NULL) {
446 for (i = 0; i < NUM_COMPARATORS; i++) { 523 spin_unlock(&timers[indx].lock);
447 mmtimer_t *base = timers[indx] + i; 524 return result;
448 /* Make sure this doesn't get reused before tasklet_sched */ 525 }
449 spin_lock(&base->lock); 526
450 if (base->cpu == smp_processor_id()) { 527 if (base->cpu == smp_processor_id()) {
451 if (base->timer) 528 if (base->timer)
452 expires = base->timer->it.mmtimer.expires; 529 expires = base->timer->it.mmtimer.expires;
453 /* expires test won't work with shared irqs */ 530 /* expires test won't work with shared irqs */
454 if ((mmtimer_int_pending(i) > 0) || 531 if ((mmtimer_int_pending(COMPARATOR) > 0) ||
455 (expires && (expires < rtc_time()))) { 532 (expires && (expires <= rtc_time()))) {
456 mmtimer_clr_int_pending(i); 533 mmtimer_clr_int_pending(COMPARATOR);
457 tasklet_schedule(&base->tasklet); 534 tasklet_schedule(&timers[indx].tasklet);
458 result = IRQ_HANDLED; 535 result = IRQ_HANDLED;
459 }
460 } 536 }
461 spin_unlock(&base->lock);
462 expires = 0;
463 } 537 }
538 spin_unlock(&timers[indx].lock);
464 return result; 539 return result;
465} 540}
466 541
467void mmtimer_tasklet(unsigned long data) { 542static void mmtimer_tasklet(unsigned long data)
468 mmtimer_t *x = (mmtimer_t *)data; 543{
469 struct k_itimer *t = x->timer; 544 int nodeid = data;
545 struct mmtimer_node *mn = &timers[nodeid];
546 struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list);
547 struct k_itimer *t;
470 unsigned long flags; 548 unsigned long flags;
471 549
472 if (t == NULL)
473 return;
474
475 /* Send signal and deal with periodic signals */ 550 /* Send signal and deal with periodic signals */
476 spin_lock_irqsave(&t->it_lock, flags); 551 spin_lock_irqsave(&mn->lock, flags);
477 spin_lock(&x->lock); 552 if (!mn->next)
478 /* If timer was deleted between interrupt and here, leave */
479 if (t != x->timer)
480 goto out; 553 goto out;
481 t->it_overrun = 0;
482 554
483 if (posix_timer_event(t, 0) != 0) { 555 x = rb_entry(mn->next, struct mmtimer, list);
556 t = x->timer;
557
558 if (t->it.mmtimer.clock == TIMER_OFF)
559 goto out;
560
561 t->it_overrun = 0;
484 562
485 // printk(KERN_WARNING "mmtimer: cannot deliver signal.\n"); 563 mn->next = rb_next(&x->list);
564 rb_erase(&x->list, &mn->timer_head);
486 565
566 if (posix_timer_event(t, 0) != 0)
487 t->it_overrun++; 567 t->it_overrun++;
488 } 568
489 if(t->it.mmtimer.incr) { 569 if(t->it.mmtimer.incr) {
490 /* Periodic timer */ 570 t->it.mmtimer.expires += t->it.mmtimer.incr;
491 if (reschedule_periodic_timer(x)) { 571 mmtimer_add_list(x);
492 printk(KERN_WARNING "mmtimer: unable to reschedule\n");
493 x->timer = NULL;
494 }
495 } else { 572 } else {
496 /* Ensure we don't false trigger in mmtimer_interrupt */ 573 /* Ensure we don't false trigger in mmtimer_interrupt */
574 t->it.mmtimer.clock = TIMER_OFF;
497 t->it.mmtimer.expires = 0; 575 t->it.mmtimer.expires = 0;
576 kfree(x);
498 } 577 }
578 /* Set comparator for next timer, if there is one */
579 mmtimer_set_next_timer(nodeid);
580
499 t->it_overrun_last = t->it_overrun; 581 t->it_overrun_last = t->it_overrun;
500out: 582out:
501 spin_unlock(&x->lock); 583 spin_unlock_irqrestore(&mn->lock, flags);
502 spin_unlock_irqrestore(&t->it_lock, flags);
503} 584}
504 585
505static int sgi_timer_create(struct k_itimer *timer) 586static int sgi_timer_create(struct k_itimer *timer)
@@ -516,19 +597,50 @@ static int sgi_timer_create(struct k_itimer *timer)
516 */ 597 */
517static int sgi_timer_del(struct k_itimer *timr) 598static int sgi_timer_del(struct k_itimer *timr)
518{ 599{
519 int i = timr->it.mmtimer.clock;
520 cnodeid_t nodeid = timr->it.mmtimer.node; 600 cnodeid_t nodeid = timr->it.mmtimer.node;
521 mmtimer_t *t = timers[nodeid] + i;
522 unsigned long irqflags; 601 unsigned long irqflags;
523 602
524 if (i != TIMER_OFF) { 603 spin_lock_irqsave(&timers[nodeid].lock, irqflags);
525 spin_lock_irqsave(&t->lock, irqflags); 604 if (timr->it.mmtimer.clock != TIMER_OFF) {
526 mmtimer_disable_int(cnodeid_to_nasid(nodeid),i); 605 unsigned long expires = timr->it.mmtimer.expires;
527 t->timer = NULL; 606 struct rb_node *n = timers[nodeid].timer_head.rb_node;
607 struct mmtimer *uninitialized_var(t);
608 int r = 0;
609
528 timr->it.mmtimer.clock = TIMER_OFF; 610 timr->it.mmtimer.clock = TIMER_OFF;
529 timr->it.mmtimer.expires = 0; 611 timr->it.mmtimer.expires = 0;
530 spin_unlock_irqrestore(&t->lock, irqflags); 612
613 while (n) {
614 t = rb_entry(n, struct mmtimer, list);
615 if (t->timer == timr)
616 break;
617
618 if (expires < t->timer->it.mmtimer.expires)
619 n = n->rb_left;
620 else
621 n = n->rb_right;
622 }
623
624 if (!n) {
625 spin_unlock_irqrestore(&timers[nodeid].lock, irqflags);
626 return 0;
627 }
628
629 if (timers[nodeid].next == n) {
630 timers[nodeid].next = rb_next(n);
631 r = 1;
632 }
633
634 rb_erase(n, &timers[nodeid].timer_head);
635 kfree(t);
636
637 if (r) {
638 mmtimer_disable_int(cnodeid_to_nasid(nodeid),
639 COMPARATOR);
640 mmtimer_set_next_timer(nodeid);
641 }
531 } 642 }
643 spin_unlock_irqrestore(&timers[nodeid].lock, irqflags);
532 return 0; 644 return 0;
533} 645}
534 646
@@ -557,12 +669,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
557 struct itimerspec * new_setting, 669 struct itimerspec * new_setting,
558 struct itimerspec * old_setting) 670 struct itimerspec * old_setting)
559{ 671{
560
561 int i;
562 unsigned long when, period, irqflags; 672 unsigned long when, period, irqflags;
563 int err = 0; 673 int err = 0;
564 cnodeid_t nodeid; 674 cnodeid_t nodeid;
565 mmtimer_t *base; 675 struct mmtimer *base;
676 struct rb_node *n;
566 677
567 if (old_setting) 678 if (old_setting)
568 sgi_timer_get(timr, old_setting); 679 sgi_timer_get(timr, old_setting);
@@ -575,6 +686,10 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
575 /* Clear timer */ 686 /* Clear timer */
576 return 0; 687 return 0;
577 688
689 base = kmalloc(sizeof(struct mmtimer), GFP_KERNEL);
690 if (base == NULL)
691 return -ENOMEM;
692
578 if (flags & TIMER_ABSTIME) { 693 if (flags & TIMER_ABSTIME) {
579 struct timespec n; 694 struct timespec n;
580 unsigned long now; 695 unsigned long now;
@@ -604,47 +719,38 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
604 preempt_disable(); 719 preempt_disable();
605 720
606 nodeid = cpu_to_node(smp_processor_id()); 721 nodeid = cpu_to_node(smp_processor_id());
607retry:
608 /* Don't use an allocated timer, or a deleted one that's pending */
609 for(i = 0; i< NUM_COMPARATORS; i++) {
610 base = timers[nodeid] + i;
611 if (!base->timer && !base->tasklet.state) {
612 break;
613 }
614 }
615
616 if (i == NUM_COMPARATORS) {
617 preempt_enable();
618 return -EBUSY;
619 }
620 722
621 spin_lock_irqsave(&base->lock, irqflags); 723 /* Lock the node timer structure */
724 spin_lock_irqsave(&timers[nodeid].lock, irqflags);
622 725
623 if (base->timer || base->tasklet.state != 0) {
624 spin_unlock_irqrestore(&base->lock, irqflags);
625 goto retry;
626 }
627 base->timer = timr; 726 base->timer = timr;
628 base->cpu = smp_processor_id(); 727 base->cpu = smp_processor_id();
629 728
630 timr->it.mmtimer.clock = i; 729 timr->it.mmtimer.clock = TIMER_SET;
631 timr->it.mmtimer.node = nodeid; 730 timr->it.mmtimer.node = nodeid;
632 timr->it.mmtimer.incr = period; 731 timr->it.mmtimer.incr = period;
633 timr->it.mmtimer.expires = when; 732 timr->it.mmtimer.expires = when;
634 733
635 if (period == 0) { 734 n = timers[nodeid].next;
636 if (!mmtimer_setup(i, when)) { 735
637 mmtimer_disable_int(-1, i); 736 /* Add the new struct mmtimer to node's timer list */
638 posix_timer_event(timr, 0); 737 mmtimer_add_list(base);
639 timr->it.mmtimer.expires = 0; 738
640 } 739 if (timers[nodeid].next == n) {
641 } else { 740 /* No need to reprogram comparator for now */
642 timr->it.mmtimer.expires -= period; 741 spin_unlock_irqrestore(&timers[nodeid].lock, irqflags);
643 if (reschedule_periodic_timer(base)) 742 preempt_enable();
644 err = -EINVAL; 743 return err;
645 } 744 }
646 745
647 spin_unlock_irqrestore(&base->lock, irqflags); 746 /* We need to reprogram the comparator */
747 if (n)
748 mmtimer_disable_int(cnodeid_to_nasid(nodeid), COMPARATOR);
749
750 mmtimer_set_next_timer(nodeid);
751
752 /* Unlock the node timer structure */
753 spin_unlock_irqrestore(&timers[nodeid].lock, irqflags);
648 754
649 preempt_enable(); 755 preempt_enable();
650 756
@@ -669,7 +775,6 @@ static struct k_clock sgi_clock = {
669 */ 775 */
670static int __init mmtimer_init(void) 776static int __init mmtimer_init(void)
671{ 777{
672 unsigned i;
673 cnodeid_t node, maxn = -1; 778 cnodeid_t node, maxn = -1;
674 779
675 if (!ia64_platform_is("sn2")) 780 if (!ia64_platform_is("sn2"))
@@ -706,31 +811,18 @@ static int __init mmtimer_init(void)
706 maxn++; 811 maxn++;
707 812
708 /* Allocate list of node ptrs to mmtimer_t's */ 813 /* Allocate list of node ptrs to mmtimer_t's */
709 timers = kzalloc(sizeof(mmtimer_t *)*maxn, GFP_KERNEL); 814 timers = kzalloc(sizeof(struct mmtimer_node)*maxn, GFP_KERNEL);
710 if (timers == NULL) { 815 if (timers == NULL) {
711 printk(KERN_ERR "%s: failed to allocate memory for device\n", 816 printk(KERN_ERR "%s: failed to allocate memory for device\n",
712 MMTIMER_NAME); 817 MMTIMER_NAME);
713 goto out3; 818 goto out3;
714 } 819 }
715 820
716 /* Allocate mmtimer_t's for each online node */ 821 /* Initialize struct mmtimer's for each online node */
717 for_each_online_node(node) { 822 for_each_online_node(node) {
718 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); 823 spin_lock_init(&timers[node].lock);
719 if (timers[node] == NULL) { 824 tasklet_init(&timers[node].tasklet, mmtimer_tasklet,
720 printk(KERN_ERR "%s: failed to allocate memory for device\n", 825 (unsigned long) node);
721 MMTIMER_NAME);
722 goto out4;
723 }
724 for (i=0; i< NUM_COMPARATORS; i++) {
725 mmtimer_t * base = timers[node] + i;
726
727 spin_lock_init(&base->lock);
728 base->timer = NULL;
729 base->cpu = 0;
730 base->i = i;
731 tasklet_init(&base->tasklet, mmtimer_tasklet,
732 (unsigned long) (base));
733 }
734 } 826 }
735 827
736 sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second; 828 sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second;
@@ -741,11 +833,8 @@ static int __init mmtimer_init(void)
741 833
742 return 0; 834 return 0;
743 835
744out4:
745 for_each_online_node(node) {
746 kfree(timers[node]);
747 }
748out3: 836out3:
837 kfree(timers);
749 misc_deregister(&mmtimer_miscdev); 838 misc_deregister(&mmtimer_miscdev);
750out2: 839out2:
751 free_irq(SGI_MMTIMER_VECTOR, NULL); 840 free_irq(SGI_MMTIMER_VECTOR, NULL);
@@ -754,4 +843,3 @@ out1:
754} 843}
755 844
756module_init(mmtimer_init); 845module_init(mmtimer_init);
757
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 64b7b2b18352..d57d3a61919b 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -2,7 +2,8 @@
2/* 2/*
3 * moxa.c -- MOXA Intellio family multiport serial driver. 3 * moxa.c -- MOXA Intellio family multiport serial driver.
4 * 4 *
5 * Copyright (C) 1999-2000 Moxa Technologies (support@moxa.com.tw). 5 * Copyright (C) 1999-2000 Moxa Technologies (support@moxa.com).
6 * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
6 * 7 *
7 * This code is loosely based on the Linux serial driver, written by 8 * This code is loosely based on the Linux serial driver, written by
8 * Linus Torvalds, Theodore T'so and others. 9 * Linus Torvalds, Theodore T'so and others.
@@ -25,6 +26,7 @@
25#include <linux/mm.h> 26#include <linux/mm.h>
26#include <linux/ioport.h> 27#include <linux/ioport.h>
27#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/firmware.h>
28#include <linux/signal.h> 30#include <linux/signal.h>
29#include <linux/sched.h> 31#include <linux/sched.h>
30#include <linux/timer.h> 32#include <linux/timer.h>
@@ -41,21 +43,26 @@
41#include <linux/pci.h> 43#include <linux/pci.h>
42#include <linux/init.h> 44#include <linux/init.h>
43#include <linux/bitops.h> 45#include <linux/bitops.h>
44#include <linux/completion.h>
45 46
46#include <asm/system.h> 47#include <asm/system.h>
47#include <asm/io.h> 48#include <asm/io.h>
48#include <asm/uaccess.h> 49#include <asm/uaccess.h>
49 50
50#define MOXA_VERSION "5.1k" 51#include "moxa.h"
52
53#define MOXA_VERSION "6.0k"
54
55#define MOXA_FW_HDRLEN 32
51 56
52#define MOXAMAJOR 172 57#define MOXAMAJOR 172
53#define MOXACUMAJOR 173
54 58
55#define MAX_BOARDS 4 /* Don't change this value */ 59#define MAX_BOARDS 4 /* Don't change this value */
56#define MAX_PORTS_PER_BOARD 32 /* Don't change this value */ 60#define MAX_PORTS_PER_BOARD 32 /* Don't change this value */
57#define MAX_PORTS (MAX_BOARDS * MAX_PORTS_PER_BOARD) 61#define MAX_PORTS (MAX_BOARDS * MAX_PORTS_PER_BOARD)
58 62
63#define MOXA_IS_320(brd) ((brd)->boardType == MOXA_BOARD_C320_ISA || \
64 (brd)->boardType == MOXA_BOARD_C320_PCI)
65
59/* 66/*
60 * Define the Moxa PCI vendor and device IDs. 67 * Define the Moxa PCI vendor and device IDs.
61 */ 68 */
@@ -92,24 +99,16 @@ static struct pci_device_id moxa_pcibrds[] = {
92MODULE_DEVICE_TABLE(pci, moxa_pcibrds); 99MODULE_DEVICE_TABLE(pci, moxa_pcibrds);
93#endif /* CONFIG_PCI */ 100#endif /* CONFIG_PCI */
94 101
95struct moxa_isa_board_conf { 102struct moxa_port;
96 int boardType;
97 int numPorts;
98 unsigned long baseAddr;
99};
100
101static struct moxa_isa_board_conf moxa_isa_boards[] =
102{
103/* {MOXA_BOARD_C218_ISA,8,0xDC000}, */
104};
105 103
106static struct moxa_board_conf { 104static struct moxa_board_conf {
107 int boardType; 105 int boardType;
108 int numPorts; 106 int numPorts;
109 unsigned long baseAddr;
110 int busType; 107 int busType;
111 108
112 int loadstat; 109 unsigned int ready;
110
111 struct moxa_port *ports;
113 112
114 void __iomem *basemem; 113 void __iomem *basemem;
115 void __iomem *intNdx; 114 void __iomem *intNdx;
@@ -131,30 +130,27 @@ struct moxaq_str {
131}; 130};
132 131
133struct moxa_port { 132struct moxa_port {
133 struct moxa_board_conf *board;
134 struct tty_struct *tty;
135 void __iomem *tableAddr;
136
134 int type; 137 int type;
135 int port;
136 int close_delay; 138 int close_delay;
137 unsigned short closing_wait; 139 unsigned int count;
138 int count;
139 int blocked_open;
140 long event; /* long req'd for set_bit --RR */
141 int asyncflags; 140 int asyncflags;
142 unsigned long statusflags;
143 struct tty_struct *tty;
144 int cflag; 141 int cflag;
142 unsigned long statusflags;
145 wait_queue_head_t open_wait; 143 wait_queue_head_t open_wait;
146 struct completion close_wait;
147
148 struct timer_list emptyTimer;
149 144
150 char chkPort; 145 u8 DCDState;
151 char lineCtrl; 146 u8 lineCtrl;
152 void __iomem *tableAddr; 147 u8 lowChkFlag;
153 long curBaud; 148};
154 char DCDState;
155 char lowChkFlag;
156 149
157 ushort breakCnt; 150struct mon_str {
151 int tick;
152 int rxcnt[MAX_PORTS];
153 int txcnt[MAX_PORTS];
158}; 154};
159 155
160/* statusflags */ 156/* statusflags */
@@ -168,20 +164,27 @@ struct moxa_port {
168#define WAKEUP_CHARS 256 164#define WAKEUP_CHARS 256
169 165
170static int ttymajor = MOXAMAJOR; 166static int ttymajor = MOXAMAJOR;
167static struct mon_str moxaLog;
168static unsigned int moxaFuncTout = HZ / 2;
169static unsigned int moxaLowWaterChk;
170static DEFINE_MUTEX(moxa_openlock);
171/* Variables for insmod */ 171/* Variables for insmod */
172#ifdef MODULE 172#ifdef MODULE
173static int baseaddr[4]; 173static unsigned long baseaddr[MAX_BOARDS];
174static int type[4]; 174static unsigned int type[MAX_BOARDS];
175static int numports[4]; 175static unsigned int numports[MAX_BOARDS];
176#endif 176#endif
177 177
178MODULE_AUTHOR("William Chen"); 178MODULE_AUTHOR("William Chen");
179MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver"); 179MODULE_DESCRIPTION("MOXA Intellio Family Multiport Board Device Driver");
180MODULE_LICENSE("GPL"); 180MODULE_LICENSE("GPL");
181#ifdef MODULE 181#ifdef MODULE
182module_param_array(type, int, NULL, 0); 182module_param_array(type, uint, NULL, 0);
183module_param_array(baseaddr, int, NULL, 0); 183MODULE_PARM_DESC(type, "card type: C218=2, C320=4");
184module_param_array(numports, int, NULL, 0); 184module_param_array(baseaddr, ulong, NULL, 0);
185MODULE_PARM_DESC(baseaddr, "base address");
186module_param_array(numports, uint, NULL, 0);
187MODULE_PARM_DESC(numports, "numports (ignored for C218)");
185#endif 188#endif
186module_param(ttymajor, int, 0); 189module_param(ttymajor, int, 0);
187 190
@@ -194,9 +197,6 @@ static int moxa_write(struct tty_struct *, const unsigned char *, int);
194static int moxa_write_room(struct tty_struct *); 197static int moxa_write_room(struct tty_struct *);
195static void moxa_flush_buffer(struct tty_struct *); 198static void moxa_flush_buffer(struct tty_struct *);
196static int moxa_chars_in_buffer(struct tty_struct *); 199static int moxa_chars_in_buffer(struct tty_struct *);
197static void moxa_flush_chars(struct tty_struct *);
198static void moxa_put_char(struct tty_struct *, unsigned char);
199static int moxa_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long);
200static void moxa_throttle(struct tty_struct *); 200static void moxa_throttle(struct tty_struct *);
201static void moxa_unthrottle(struct tty_struct *); 201static void moxa_unthrottle(struct tty_struct *);
202static void moxa_set_termios(struct tty_struct *, struct ktermios *); 202static void moxa_set_termios(struct tty_struct *, struct ktermios *);
@@ -208,44 +208,183 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
208 unsigned int set, unsigned int clear); 208 unsigned int set, unsigned int clear);
209static void moxa_poll(unsigned long); 209static void moxa_poll(unsigned long);
210static void moxa_set_tty_param(struct tty_struct *, struct ktermios *); 210static void moxa_set_tty_param(struct tty_struct *, struct ktermios *);
211static int moxa_block_till_ready(struct tty_struct *, struct file *,
212 struct moxa_port *);
213static void moxa_setup_empty_event(struct tty_struct *); 211static void moxa_setup_empty_event(struct tty_struct *);
214static void moxa_check_xmit_empty(unsigned long);
215static void moxa_shut_down(struct moxa_port *); 212static void moxa_shut_down(struct moxa_port *);
216static void moxa_receive_data(struct moxa_port *);
217/* 213/*
218 * moxa board interface functions: 214 * moxa board interface functions:
219 */ 215 */
220static void MoxaDriverInit(void); 216static void MoxaPortEnable(struct moxa_port *);
221static int MoxaDriverIoctl(unsigned int, unsigned long, int); 217static void MoxaPortDisable(struct moxa_port *);
222static int MoxaDriverPoll(void); 218static int MoxaPortSetTermio(struct moxa_port *, struct ktermios *, speed_t);
223static int MoxaPortsOfCard(int); 219static int MoxaPortGetLineOut(struct moxa_port *, int *, int *);
224static int MoxaPortIsValid(int); 220static void MoxaPortLineCtrl(struct moxa_port *, int, int);
225static void MoxaPortEnable(int); 221static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int);
226static void MoxaPortDisable(int); 222static int MoxaPortLineStatus(struct moxa_port *);
227static long MoxaPortGetMaxBaud(int); 223static void MoxaPortFlushData(struct moxa_port *, int);
228static long MoxaPortSetBaud(int, long); 224static int MoxaPortWriteData(struct moxa_port *, const unsigned char *, int);
229static int MoxaPortSetTermio(int, struct ktermios *, speed_t); 225static int MoxaPortReadData(struct moxa_port *);
230static int MoxaPortGetLineOut(int, int *, int *); 226static int MoxaPortTxQueue(struct moxa_port *);
231static void MoxaPortLineCtrl(int, int, int); 227static int MoxaPortRxQueue(struct moxa_port *);
232static void MoxaPortFlowCtrl(int, int, int, int, int, int); 228static int MoxaPortTxFree(struct moxa_port *);
233static int MoxaPortLineStatus(int); 229static void MoxaPortTxDisable(struct moxa_port *);
234static int MoxaPortDCDChange(int); 230static void MoxaPortTxEnable(struct moxa_port *);
235static int MoxaPortDCDON(int);
236static void MoxaPortFlushData(int, int);
237static int MoxaPortWriteData(int, unsigned char *, int);
238static int MoxaPortReadData(int, struct tty_struct *tty);
239static int MoxaPortTxQueue(int);
240static int MoxaPortRxQueue(int);
241static int MoxaPortTxFree(int);
242static void MoxaPortTxDisable(int);
243static void MoxaPortTxEnable(int);
244static int MoxaPortResetBrkCnt(int);
245static void MoxaPortSendBreak(int, int);
246static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *); 231static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *);
247static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *); 232static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *);
248static void MoxaSetFifo(int port, int enable); 233static void MoxaSetFifo(struct moxa_port *port, int enable);
234
235/*
236 * I/O functions
237 */
238
239static void moxa_wait_finish(void __iomem *ofsAddr)
240{
241 unsigned long end = jiffies + moxaFuncTout;
242
243 while (readw(ofsAddr + FuncCode) != 0)
244 if (time_after(jiffies, end))
245 return;
246 if (readw(ofsAddr + FuncCode) != 0 && printk_ratelimit())
247 printk(KERN_WARNING "moxa function expired\n");
248}
249
250static void moxafunc(void __iomem *ofsAddr, u16 cmd, u16 arg)
251{
252 writew(arg, ofsAddr + FuncArg);
253 writew(cmd, ofsAddr + FuncCode);
254 moxa_wait_finish(ofsAddr);
255}
256
257static void moxa_low_water_check(void __iomem *ofsAddr)
258{
259 u16 rptr, wptr, mask, len;
260
261 if (readb(ofsAddr + FlagStat) & Xoff_state) {
262 rptr = readw(ofsAddr + RXrptr);
263 wptr = readw(ofsAddr + RXwptr);
264 mask = readw(ofsAddr + RX_mask);
265 len = (wptr - rptr) & mask;
266 if (len <= Low_water)
267 moxafunc(ofsAddr, FC_SendXon, 0);
268 }
269}
270
271/*
272 * TTY operations
273 */
274
275static int moxa_ioctl(struct tty_struct *tty, struct file *file,
276 unsigned int cmd, unsigned long arg)
277{
278 struct moxa_port *ch = tty->driver_data;
279 void __user *argp = (void __user *)arg;
280 int status, ret = 0;
281
282 if (tty->index == MAX_PORTS) {
283 if (cmd != MOXA_GETDATACOUNT && cmd != MOXA_GET_IOQUEUE &&
284 cmd != MOXA_GETMSTATUS)
285 return -EINVAL;
286 } else if (!ch)
287 return -ENODEV;
288
289 switch (cmd) {
290 case MOXA_GETDATACOUNT:
291 moxaLog.tick = jiffies;
292 if (copy_to_user(argp, &moxaLog, sizeof(moxaLog)))
293 ret = -EFAULT;
294 break;
295 case MOXA_FLUSH_QUEUE:
296 MoxaPortFlushData(ch, arg);
297 break;
298 case MOXA_GET_IOQUEUE: {
299 struct moxaq_str __user *argm = argp;
300 struct moxaq_str tmp;
301 struct moxa_port *p;
302 unsigned int i, j;
303
304 mutex_lock(&moxa_openlock);
305 for (i = 0; i < MAX_BOARDS; i++) {
306 p = moxa_boards[i].ports;
307 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) {
308 memset(&tmp, 0, sizeof(tmp));
309 if (moxa_boards[i].ready) {
310 tmp.inq = MoxaPortRxQueue(p);
311 tmp.outq = MoxaPortTxQueue(p);
312 }
313 if (copy_to_user(argm, &tmp, sizeof(tmp))) {
314 mutex_unlock(&moxa_openlock);
315 return -EFAULT;
316 }
317 }
318 }
319 mutex_unlock(&moxa_openlock);
320 break;
321 } case MOXA_GET_OQUEUE:
322 status = MoxaPortTxQueue(ch);
323 ret = put_user(status, (unsigned long __user *)argp);
324 break;
325 case MOXA_GET_IQUEUE:
326 status = MoxaPortRxQueue(ch);
327 ret = put_user(status, (unsigned long __user *)argp);
328 break;
329 case MOXA_GETMSTATUS: {
330 struct mxser_mstatus __user *argm = argp;
331 struct mxser_mstatus tmp;
332 struct moxa_port *p;
333 unsigned int i, j;
334
335 mutex_lock(&moxa_openlock);
336 for (i = 0; i < MAX_BOARDS; i++) {
337 p = moxa_boards[i].ports;
338 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) {
339 memset(&tmp, 0, sizeof(tmp));
340 if (!moxa_boards[i].ready)
341 goto copy;
342
343 status = MoxaPortLineStatus(p);
344 if (status & 1)
345 tmp.cts = 1;
346 if (status & 2)
347 tmp.dsr = 1;
348 if (status & 4)
349 tmp.dcd = 1;
350
351 if (!p->tty || !p->tty->termios)
352 tmp.cflag = p->cflag;
353 else
354 tmp.cflag = p->tty->termios->c_cflag;
355copy:
356 if (copy_to_user(argm, &tmp, sizeof(tmp))) {
357 mutex_unlock(&moxa_openlock);
358 return -EFAULT;
359 }
360 }
361 }
362 mutex_unlock(&moxa_openlock);
363 break;
364 }
365 case TIOCGSERIAL:
366 mutex_lock(&moxa_openlock);
367 ret = moxa_get_serial_info(ch, argp);
368 mutex_unlock(&moxa_openlock);
369 break;
370 case TIOCSSERIAL:
371 mutex_lock(&moxa_openlock);
372 ret = moxa_set_serial_info(ch, argp);
373 mutex_unlock(&moxa_openlock);
374 break;
375 default:
376 ret = -ENOIOCTLCMD;
377 }
378 return ret;
379}
380
381static void moxa_break_ctl(struct tty_struct *tty, int state)
382{
383 struct moxa_port *port = tty->driver_data;
384
385 moxafunc(port->tableAddr, state ? FC_SendBreak : FC_StopBreak,
386 Magic_code);
387}
249 388
250static const struct tty_operations moxa_ops = { 389static const struct tty_operations moxa_ops = {
251 .open = moxa_open, 390 .open = moxa_open,
@@ -254,8 +393,6 @@ static const struct tty_operations moxa_ops = {
254 .write_room = moxa_write_room, 393 .write_room = moxa_write_room,
255 .flush_buffer = moxa_flush_buffer, 394 .flush_buffer = moxa_flush_buffer,
256 .chars_in_buffer = moxa_chars_in_buffer, 395 .chars_in_buffer = moxa_chars_in_buffer,
257 .flush_chars = moxa_flush_chars,
258 .put_char = moxa_put_char,
259 .ioctl = moxa_ioctl, 396 .ioctl = moxa_ioctl,
260 .throttle = moxa_throttle, 397 .throttle = moxa_throttle,
261 .unthrottle = moxa_unthrottle, 398 .unthrottle = moxa_unthrottle,
@@ -263,15 +400,509 @@ static const struct tty_operations moxa_ops = {
263 .stop = moxa_stop, 400 .stop = moxa_stop,
264 .start = moxa_start, 401 .start = moxa_start,
265 .hangup = moxa_hangup, 402 .hangup = moxa_hangup,
403 .break_ctl = moxa_break_ctl,
266 .tiocmget = moxa_tiocmget, 404 .tiocmget = moxa_tiocmget,
267 .tiocmset = moxa_tiocmset, 405 .tiocmset = moxa_tiocmset,
268}; 406};
269 407
270static struct tty_driver *moxaDriver; 408static struct tty_driver *moxaDriver;
271static struct moxa_port moxa_ports[MAX_PORTS];
272static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0); 409static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0);
273static DEFINE_SPINLOCK(moxa_lock); 410static DEFINE_SPINLOCK(moxa_lock);
274 411
412/*
413 * HW init
414 */
415
416static int moxa_check_fw_model(struct moxa_board_conf *brd, u8 model)
417{
418 switch (brd->boardType) {
419 case MOXA_BOARD_C218_ISA:
420 case MOXA_BOARD_C218_PCI:
421 if (model != 1)
422 goto err;
423 break;
424 case MOXA_BOARD_CP204J:
425 if (model != 3)
426 goto err;
427 break;
428 default:
429 if (model != 2)
430 goto err;
431 break;
432 }
433 return 0;
434err:
435 return -EINVAL;
436}
437
438static int moxa_check_fw(const void *ptr)
439{
440 const __le16 *lptr = ptr;
441
442 if (*lptr != cpu_to_le16(0x7980))
443 return -EINVAL;
444
445 return 0;
446}
447
448static int moxa_load_bios(struct moxa_board_conf *brd, const u8 *buf,
449 size_t len)
450{
451 void __iomem *baseAddr = brd->basemem;
452 u16 tmp;
453
454 writeb(HW_reset, baseAddr + Control_reg); /* reset */
455 msleep(10);
456 memset_io(baseAddr, 0, 4096);
457 memcpy_toio(baseAddr, buf, len); /* download BIOS */
458 writeb(0, baseAddr + Control_reg); /* restart */
459
460 msleep(2000);
461
462 switch (brd->boardType) {
463 case MOXA_BOARD_C218_ISA:
464 case MOXA_BOARD_C218_PCI:
465 tmp = readw(baseAddr + C218_key);
466 if (tmp != C218_KeyCode)
467 goto err;
468 break;
469 case MOXA_BOARD_CP204J:
470 tmp = readw(baseAddr + C218_key);
471 if (tmp != CP204J_KeyCode)
472 goto err;
473 break;
474 default:
475 tmp = readw(baseAddr + C320_key);
476 if (tmp != C320_KeyCode)
477 goto err;
478 tmp = readw(baseAddr + C320_status);
479 if (tmp != STS_init) {
480 printk(KERN_ERR "MOXA: bios upload failed -- CPU/Basic "
481 "module not found\n");
482 return -EIO;
483 }
484 break;
485 }
486
487 return 0;
488err:
489 printk(KERN_ERR "MOXA: bios upload failed -- board not found\n");
490 return -EIO;
491}
492
493static int moxa_load_320b(struct moxa_board_conf *brd, const u8 *ptr,
494 size_t len)
495{
496 void __iomem *baseAddr = brd->basemem;
497
498 if (len < 7168) {
499 printk(KERN_ERR "MOXA: invalid 320 bios -- too short\n");
500 return -EINVAL;
501 }
502
503 writew(len - 7168 - 2, baseAddr + C320bapi_len);
504 writeb(1, baseAddr + Control_reg); /* Select Page 1 */
505 memcpy_toio(baseAddr + DynPage_addr, ptr, 7168);
506 writeb(2, baseAddr + Control_reg); /* Select Page 2 */
507 memcpy_toio(baseAddr + DynPage_addr, ptr + 7168, len - 7168);
508
509 return 0;
510}
511
512static int moxa_real_load_code(struct moxa_board_conf *brd, const void *ptr,
513 size_t len)
514{
515 void __iomem *baseAddr = brd->basemem;
516 const u16 *uptr = ptr;
517 size_t wlen, len2, j;
518 unsigned long key, loadbuf, loadlen, checksum, checksum_ok;
519 unsigned int i, retry;
520 u16 usum, keycode;
521
522 keycode = (brd->boardType == MOXA_BOARD_CP204J) ? CP204J_KeyCode :
523 C218_KeyCode;
524
525 switch (brd->boardType) {
526 case MOXA_BOARD_CP204J:
527 case MOXA_BOARD_C218_ISA:
528 case MOXA_BOARD_C218_PCI:
529 key = C218_key;
530 loadbuf = C218_LoadBuf;
531 loadlen = C218DLoad_len;
532 checksum = C218check_sum;
533 checksum_ok = C218chksum_ok;
534 break;
535 default:
536 key = C320_key;
537 keycode = C320_KeyCode;
538 loadbuf = C320_LoadBuf;
539 loadlen = C320DLoad_len;
540 checksum = C320check_sum;
541 checksum_ok = C320chksum_ok;
542 break;
543 }
544
545 usum = 0;
546 wlen = len >> 1;
547 for (i = 0; i < wlen; i++)
548 usum += le16_to_cpu(uptr[i]);
549 retry = 0;
550 do {
551 wlen = len >> 1;
552 j = 0;
553 while (wlen) {
554 len2 = (wlen > 2048) ? 2048 : wlen;
555 wlen -= len2;
556 memcpy_toio(baseAddr + loadbuf, ptr + j, len2 << 1);
557 j += len2 << 1;
558
559 writew(len2, baseAddr + loadlen);
560 writew(0, baseAddr + key);
561 for (i = 0; i < 100; i++) {
562 if (readw(baseAddr + key) == keycode)
563 break;
564 msleep(10);
565 }
566 if (readw(baseAddr + key) != keycode)
567 return -EIO;
568 }
569 writew(0, baseAddr + loadlen);
570 writew(usum, baseAddr + checksum);
571 writew(0, baseAddr + key);
572 for (i = 0; i < 100; i++) {
573 if (readw(baseAddr + key) == keycode)
574 break;
575 msleep(10);
576 }
577 retry++;
578 } while ((readb(baseAddr + checksum_ok) != 1) && (retry < 3));
579 if (readb(baseAddr + checksum_ok) != 1)
580 return -EIO;
581
582 writew(0, baseAddr + key);
583 for (i = 0; i < 600; i++) {
584 if (readw(baseAddr + Magic_no) == Magic_code)
585 break;
586 msleep(10);
587 }
588 if (readw(baseAddr + Magic_no) != Magic_code)
589 return -EIO;
590
591 if (MOXA_IS_320(brd)) {
592 if (brd->busType == MOXA_BUS_TYPE_PCI) { /* ASIC board */
593 writew(0x3800, baseAddr + TMS320_PORT1);
594 writew(0x3900, baseAddr + TMS320_PORT2);
595 writew(28499, baseAddr + TMS320_CLOCK);
596 } else {
597 writew(0x3200, baseAddr + TMS320_PORT1);
598 writew(0x3400, baseAddr + TMS320_PORT2);
599 writew(19999, baseAddr + TMS320_CLOCK);
600 }
601 }
602 writew(1, baseAddr + Disable_IRQ);
603 writew(0, baseAddr + Magic_no);
604 for (i = 0; i < 500; i++) {
605 if (readw(baseAddr + Magic_no) == Magic_code)
606 break;
607 msleep(10);
608 }
609 if (readw(baseAddr + Magic_no) != Magic_code)
610 return -EIO;
611
612 if (MOXA_IS_320(brd)) {
613 j = readw(baseAddr + Module_cnt);
614 if (j <= 0)
615 return -EIO;
616 brd->numPorts = j * 8;
617 writew(j, baseAddr + Module_no);
618 writew(0, baseAddr + Magic_no);
619 for (i = 0; i < 600; i++) {
620 if (readw(baseAddr + Magic_no) == Magic_code)
621 break;
622 msleep(10);
623 }
624 if (readw(baseAddr + Magic_no) != Magic_code)
625 return -EIO;
626 }
627 brd->intNdx = baseAddr + IRQindex;
628 brd->intPend = baseAddr + IRQpending;
629 brd->intTable = baseAddr + IRQtable;
630
631 return 0;
632}
633
634static int moxa_load_code(struct moxa_board_conf *brd, const void *ptr,
635 size_t len)
636{
637 void __iomem *ofsAddr, *baseAddr = brd->basemem;
638 struct moxa_port *port;
639 int retval, i;
640
641 if (len % 2) {
642 printk(KERN_ERR "MOXA: bios length is not even\n");
643 return -EINVAL;
644 }
645
646 retval = moxa_real_load_code(brd, ptr, len); /* may change numPorts */
647 if (retval)
648 return retval;
649
650 switch (brd->boardType) {
651 case MOXA_BOARD_C218_ISA:
652 case MOXA_BOARD_C218_PCI:
653 case MOXA_BOARD_CP204J:
654 port = brd->ports;
655 for (i = 0; i < brd->numPorts; i++, port++) {
656 port->board = brd;
657 port->DCDState = 0;
658 port->tableAddr = baseAddr + Extern_table +
659 Extern_size * i;
660 ofsAddr = port->tableAddr;
661 writew(C218rx_mask, ofsAddr + RX_mask);
662 writew(C218tx_mask, ofsAddr + TX_mask);
663 writew(C218rx_spage + i * C218buf_pageno, ofsAddr + Page_rxb);
664 writew(readw(ofsAddr + Page_rxb) + C218rx_pageno, ofsAddr + EndPage_rxb);
665
666 writew(C218tx_spage + i * C218buf_pageno, ofsAddr + Page_txb);
667 writew(readw(ofsAddr + Page_txb) + C218tx_pageno, ofsAddr + EndPage_txb);
668
669 }
670 break;
671 default:
672 port = brd->ports;
673 for (i = 0; i < brd->numPorts; i++, port++) {
674 port->board = brd;
675 port->DCDState = 0;
676 port->tableAddr = baseAddr + Extern_table +
677 Extern_size * i;
678 ofsAddr = port->tableAddr;
679 switch (brd->numPorts) {
680 case 8:
681 writew(C320p8rx_mask, ofsAddr + RX_mask);
682 writew(C320p8tx_mask, ofsAddr + TX_mask);
683 writew(C320p8rx_spage + i * C320p8buf_pgno, ofsAddr + Page_rxb);
684 writew(readw(ofsAddr + Page_rxb) + C320p8rx_pgno, ofsAddr + EndPage_rxb);
685 writew(C320p8tx_spage + i * C320p8buf_pgno, ofsAddr + Page_txb);
686 writew(readw(ofsAddr + Page_txb) + C320p8tx_pgno, ofsAddr + EndPage_txb);
687
688 break;
689 case 16:
690 writew(C320p16rx_mask, ofsAddr + RX_mask);
691 writew(C320p16tx_mask, ofsAddr + TX_mask);
692 writew(C320p16rx_spage + i * C320p16buf_pgno, ofsAddr + Page_rxb);
693 writew(readw(ofsAddr + Page_rxb) + C320p16rx_pgno, ofsAddr + EndPage_rxb);
694 writew(C320p16tx_spage + i * C320p16buf_pgno, ofsAddr + Page_txb);
695 writew(readw(ofsAddr + Page_txb) + C320p16tx_pgno, ofsAddr + EndPage_txb);
696 break;
697
698 case 24:
699 writew(C320p24rx_mask, ofsAddr + RX_mask);
700 writew(C320p24tx_mask, ofsAddr + TX_mask);
701 writew(C320p24rx_spage + i * C320p24buf_pgno, ofsAddr + Page_rxb);
702 writew(readw(ofsAddr + Page_rxb) + C320p24rx_pgno, ofsAddr + EndPage_rxb);
703 writew(C320p24tx_spage + i * C320p24buf_pgno, ofsAddr + Page_txb);
704 writew(readw(ofsAddr + Page_txb), ofsAddr + EndPage_txb);
705 break;
706 case 32:
707 writew(C320p32rx_mask, ofsAddr + RX_mask);
708 writew(C320p32tx_mask, ofsAddr + TX_mask);
709 writew(C320p32tx_ofs, ofsAddr + Ofs_txb);
710 writew(C320p32rx_spage + i * C320p32buf_pgno, ofsAddr + Page_rxb);
711 writew(readb(ofsAddr + Page_rxb), ofsAddr + EndPage_rxb);
712 writew(C320p32tx_spage + i * C320p32buf_pgno, ofsAddr + Page_txb);
713 writew(readw(ofsAddr + Page_txb), ofsAddr + EndPage_txb);
714 break;
715 }
716 }
717 break;
718 }
719 return 0;
720}
721
722static int moxa_load_fw(struct moxa_board_conf *brd, const struct firmware *fw)
723{
724 void *ptr = fw->data;
725 char rsn[64];
726 u16 lens[5];
727 size_t len;
728 unsigned int a, lenp, lencnt;
729 int ret = -EINVAL;
730 struct {
731 __le32 magic; /* 0x34303430 */
732 u8 reserved1[2];
733 u8 type; /* UNIX = 3 */
734 u8 model; /* C218T=1, C320T=2, CP204=3 */
735 u8 reserved2[8];
736 __le16 len[5];
737 } *hdr = ptr;
738
739 BUILD_BUG_ON(ARRAY_SIZE(hdr->len) != ARRAY_SIZE(lens));
740
741 if (fw->size < MOXA_FW_HDRLEN) {
742 strcpy(rsn, "too short (even header won't fit)");
743 goto err;
744 }
745 if (hdr->magic != cpu_to_le32(0x30343034)) {
746 sprintf(rsn, "bad magic: %.8x", le32_to_cpu(hdr->magic));
747 goto err;
748 }
749 if (hdr->type != 3) {
750 sprintf(rsn, "not for linux, type is %u", hdr->type);
751 goto err;
752 }
753 if (moxa_check_fw_model(brd, hdr->model)) {
754 sprintf(rsn, "not for this card, model is %u", hdr->model);
755 goto err;
756 }
757
758 len = MOXA_FW_HDRLEN;
759 lencnt = hdr->model == 2 ? 5 : 3;
760 for (a = 0; a < ARRAY_SIZE(lens); a++) {
761 lens[a] = le16_to_cpu(hdr->len[a]);
762 if (lens[a] && len + lens[a] <= fw->size &&
763 moxa_check_fw(&fw->data[len]))
764 printk(KERN_WARNING "MOXA firmware: unexpected input "
765 "at offset %u, but going on\n", (u32)len);
766 if (!lens[a] && a < lencnt) {
767 sprintf(rsn, "too few entries in fw file");
768 goto err;
769 }
770 len += lens[a];
771 }
772
773 if (len != fw->size) {
774 sprintf(rsn, "bad length: %u (should be %u)", (u32)fw->size,
775 (u32)len);
776 goto err;
777 }
778
779 ptr += MOXA_FW_HDRLEN;
780 lenp = 0; /* bios */
781
782 strcpy(rsn, "read above");
783
784 ret = moxa_load_bios(brd, ptr, lens[lenp]);
785 if (ret)
786 goto err;
787
788 /* we skip the tty section (lens[1]), since we don't need it */
789 ptr += lens[lenp] + lens[lenp + 1];
790 lenp += 2; /* comm */
791
792 if (hdr->model == 2) {
793 ret = moxa_load_320b(brd, ptr, lens[lenp]);
794 if (ret)
795 goto err;
796 /* skip another tty */
797 ptr += lens[lenp] + lens[lenp + 1];
798 lenp += 2;
799 }
800
801 ret = moxa_load_code(brd, ptr, lens[lenp]);
802 if (ret)
803 goto err;
804
805 return 0;
806err:
807 printk(KERN_ERR "firmware failed to load, reason: %s\n", rsn);
808 return ret;
809}
810
811static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
812{
813 const struct firmware *fw;
814 const char *file;
815 struct moxa_port *p;
816 unsigned int i;
817 int ret;
818
819 brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
820 GFP_KERNEL);
821 if (brd->ports == NULL) {
822 printk(KERN_ERR "cannot allocate memory for ports\n");
823 ret = -ENOMEM;
824 goto err;
825 }
826
827 for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) {
828 p->type = PORT_16550A;
829 p->close_delay = 5 * HZ / 10;
830 p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
831 init_waitqueue_head(&p->open_wait);
832 }
833
834 switch (brd->boardType) {
835 case MOXA_BOARD_C218_ISA:
836 case MOXA_BOARD_C218_PCI:
837 file = "c218tunx.cod";
838 break;
839 case MOXA_BOARD_CP204J:
840 file = "cp204unx.cod";
841 break;
842 default:
843 file = "c320tunx.cod";
844 break;
845 }
846
847 ret = request_firmware(&fw, file, dev);
848 if (ret) {
849 printk(KERN_ERR "MOXA: request_firmware failed. Make sure "
850 "you've placed '%s' file into your firmware "
851 "loader directory (e.g. /lib/firmware)\n",
852 file);
853 goto err_free;
854 }
855
856 ret = moxa_load_fw(brd, fw);
857
858 release_firmware(fw);
859
860 if (ret)
861 goto err_free;
862
863 spin_lock_bh(&moxa_lock);
864 brd->ready = 1;
865 if (!timer_pending(&moxaTimer))
866 mod_timer(&moxaTimer, jiffies + HZ / 50);
867 spin_unlock_bh(&moxa_lock);
868
869 return 0;
870err_free:
871 kfree(brd->ports);
872err:
873 return ret;
874}
875
876static void moxa_board_deinit(struct moxa_board_conf *brd)
877{
878 unsigned int a, opened;
879
880 mutex_lock(&moxa_openlock);
881 spin_lock_bh(&moxa_lock);
882 brd->ready = 0;
883 spin_unlock_bh(&moxa_lock);
884
885 /* pci hot-un-plug support */
886 for (a = 0; a < brd->numPorts; a++)
887 if (brd->ports[a].asyncflags & ASYNC_INITIALIZED)
888 tty_hangup(brd->ports[a].tty);
889 while (1) {
890 opened = 0;
891 for (a = 0; a < brd->numPorts; a++)
892 if (brd->ports[a].asyncflags & ASYNC_INITIALIZED)
893 opened++;
894 mutex_unlock(&moxa_openlock);
895 if (!opened)
896 break;
897 msleep(50);
898 mutex_lock(&moxa_openlock);
899 }
900
901 iounmap(brd->basemem);
902 brd->basemem = NULL;
903 kfree(brd->ports);
904}
905
275#ifdef CONFIG_PCI 906#ifdef CONFIG_PCI
276static int __devinit moxa_pci_probe(struct pci_dev *pdev, 907static int __devinit moxa_pci_probe(struct pci_dev *pdev,
277 const struct pci_device_id *ent) 908 const struct pci_device_id *ent)
@@ -299,10 +930,17 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
299 } 930 }
300 931
301 board = &moxa_boards[i]; 932 board = &moxa_boards[i];
302 board->basemem = pci_iomap(pdev, 2, 0x4000); 933
934 retval = pci_request_region(pdev, 2, "moxa-base");
935 if (retval) {
936 dev_err(&pdev->dev, "can't request pci region 2\n");
937 goto err;
938 }
939
940 board->basemem = ioremap_nocache(pci_resource_start(pdev, 2), 0x4000);
303 if (board->basemem == NULL) { 941 if (board->basemem == NULL) {
304 dev_err(&pdev->dev, "can't remap io space 2\n"); 942 dev_err(&pdev->dev, "can't remap io space 2\n");
305 goto err; 943 goto err_reg;
306 } 944 }
307 945
308 board->boardType = board_type; 946 board->boardType = board_type;
@@ -321,9 +959,21 @@ static int __devinit moxa_pci_probe(struct pci_dev *pdev,
321 } 959 }
322 board->busType = MOXA_BUS_TYPE_PCI; 960 board->busType = MOXA_BUS_TYPE_PCI;
323 961
962 retval = moxa_init_board(board, &pdev->dev);
963 if (retval)
964 goto err_base;
965
324 pci_set_drvdata(pdev, board); 966 pci_set_drvdata(pdev, board);
325 967
326 return (0); 968 dev_info(&pdev->dev, "board '%s' ready (%u ports, firmware loaded)\n",
969 moxa_brdname[board_type - 1], board->numPorts);
970
971 return 0;
972err_base:
973 iounmap(board->basemem);
974 board->basemem = NULL;
975err_reg:
976 pci_release_region(pdev, 2);
327err: 977err:
328 return retval; 978 return retval;
329} 979}
@@ -332,8 +982,9 @@ static void __devexit moxa_pci_remove(struct pci_dev *pdev)
332{ 982{
333 struct moxa_board_conf *brd = pci_get_drvdata(pdev); 983 struct moxa_board_conf *brd = pci_get_drvdata(pdev);
334 984
335 pci_iounmap(pdev, brd->basemem); 985 moxa_board_deinit(brd);
336 brd->basemem = NULL; 986
987 pci_release_region(pdev, 2);
337} 988}
338 989
339static struct pci_driver moxa_pci_driver = { 990static struct pci_driver moxa_pci_driver = {
@@ -346,8 +997,8 @@ static struct pci_driver moxa_pci_driver = {
346 997
347static int __init moxa_init(void) 998static int __init moxa_init(void)
348{ 999{
349 int i, numBoards, retval = 0; 1000 unsigned int isabrds = 0;
350 struct moxa_port *ch; 1001 int retval = 0;
351 1002
352 printk(KERN_INFO "MOXA Intellio family driver version %s\n", 1003 printk(KERN_INFO "MOXA Intellio family driver version %s\n",
353 MOXA_VERSION); 1004 MOXA_VERSION);
@@ -368,154 +1019,176 @@ static int __init moxa_init(void)
368 moxaDriver->flags = TTY_DRIVER_REAL_RAW; 1019 moxaDriver->flags = TTY_DRIVER_REAL_RAW;
369 tty_set_operations(moxaDriver, &moxa_ops); 1020 tty_set_operations(moxaDriver, &moxa_ops);
370 1021
371 for (i = 0, ch = moxa_ports; i < MAX_PORTS; i++, ch++) {
372 ch->type = PORT_16550A;
373 ch->port = i;
374 ch->close_delay = 5 * HZ / 10;
375 ch->closing_wait = 30 * HZ;
376 ch->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
377 init_waitqueue_head(&ch->open_wait);
378 init_completion(&ch->close_wait);
379
380 setup_timer(&ch->emptyTimer, moxa_check_xmit_empty,
381 (unsigned long)ch);
382 }
383
384 pr_debug("Moxa tty devices major number = %d\n", ttymajor);
385
386 if (tty_register_driver(moxaDriver)) { 1022 if (tty_register_driver(moxaDriver)) {
387 printk(KERN_ERR "Couldn't install MOXA Smartio family driver !\n"); 1023 printk(KERN_ERR "can't register MOXA Smartio tty driver!\n");
388 put_tty_driver(moxaDriver); 1024 put_tty_driver(moxaDriver);
389 return -1; 1025 return -1;
390 } 1026 }
391 1027
392 mod_timer(&moxaTimer, jiffies + HZ / 50); 1028 /* Find the boards defined from module args. */
393
394 /* Find the boards defined in source code */
395 numBoards = 0;
396 for (i = 0; i < MAX_BOARDS; i++) {
397 if ((moxa_isa_boards[i].boardType == MOXA_BOARD_C218_ISA) ||
398 (moxa_isa_boards[i].boardType == MOXA_BOARD_C320_ISA)) {
399 moxa_boards[numBoards].boardType = moxa_isa_boards[i].boardType;
400 if (moxa_isa_boards[i].boardType == MOXA_BOARD_C218_ISA)
401 moxa_boards[numBoards].numPorts = 8;
402 else
403 moxa_boards[numBoards].numPorts = moxa_isa_boards[i].numPorts;
404 moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA;
405 moxa_boards[numBoards].baseAddr = moxa_isa_boards[i].baseAddr;
406 pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n",
407 numBoards + 1,
408 moxa_brdname[moxa_boards[numBoards].boardType-1],
409 moxa_boards[numBoards].baseAddr);
410 numBoards++;
411 }
412 }
413 /* Find the boards defined form module args. */
414#ifdef MODULE 1029#ifdef MODULE
1030 {
1031 struct moxa_board_conf *brd = moxa_boards;
1032 unsigned int i;
415 for (i = 0; i < MAX_BOARDS; i++) { 1033 for (i = 0; i < MAX_BOARDS; i++) {
416 if ((type[i] == MOXA_BOARD_C218_ISA) || 1034 if (!baseaddr[i])
417 (type[i] == MOXA_BOARD_C320_ISA)) { 1035 break;
1036 if (type[i] == MOXA_BOARD_C218_ISA ||
1037 type[i] == MOXA_BOARD_C320_ISA) {
418 pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n", 1038 pr_debug("Moxa board %2d: %s board(baseAddr=%lx)\n",
419 numBoards + 1, moxa_brdname[type[i] - 1], 1039 isabrds + 1, moxa_brdname[type[i] - 1],
420 (unsigned long)baseaddr[i]); 1040 baseaddr[i]);
421 if (numBoards >= MAX_BOARDS) { 1041 brd->boardType = type[i];
422 printk(KERN_WARNING "More than %d MOXA " 1042 brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 :
423 "Intellio family boards found. Board " 1043 numports[i];
424 "is ignored.\n", MAX_BOARDS); 1044 brd->busType = MOXA_BUS_TYPE_ISA;
1045 brd->basemem = ioremap_nocache(baseaddr[i], 0x4000);
1046 if (!brd->basemem) {
1047 printk(KERN_ERR "MOXA: can't remap %lx\n",
1048 baseaddr[i]);
425 continue; 1049 continue;
426 } 1050 }
427 moxa_boards[numBoards].boardType = type[i]; 1051 if (moxa_init_board(brd, NULL)) {
428 if (moxa_isa_boards[i].boardType == MOXA_BOARD_C218_ISA) 1052 iounmap(brd->basemem);
429 moxa_boards[numBoards].numPorts = 8; 1053 brd->basemem = NULL;
430 else 1054 continue;
431 moxa_boards[numBoards].numPorts = numports[i]; 1055 }
432 moxa_boards[numBoards].busType = MOXA_BUS_TYPE_ISA; 1056
433 moxa_boards[numBoards].baseAddr = baseaddr[i]; 1057 printk(KERN_INFO "MOXA isa board found at 0x%.8lu and "
434 numBoards++; 1058 "ready (%u ports, firmware loaded)\n",
1059 baseaddr[i], brd->numPorts);
1060
1061 brd++;
1062 isabrds++;
435 } 1063 }
436 } 1064 }
1065 }
437#endif 1066#endif
438 1067
439#ifdef CONFIG_PCI 1068#ifdef CONFIG_PCI
440 retval = pci_register_driver(&moxa_pci_driver); 1069 retval = pci_register_driver(&moxa_pci_driver);
441 if (retval) { 1070 if (retval) {
442 printk(KERN_ERR "Can't register moxa pci driver!\n"); 1071 printk(KERN_ERR "Can't register MOXA pci driver!\n");
443 if (numBoards) 1072 if (isabrds)
444 retval = 0; 1073 retval = 0;
445 } 1074 }
446#endif 1075#endif
447 1076
448 for (i = 0; i < numBoards; i++) {
449 moxa_boards[i].basemem = ioremap(moxa_boards[i].baseAddr,
450 0x4000);
451 }
452
453 return retval; 1077 return retval;
454} 1078}
455 1079
456static void __exit moxa_exit(void) 1080static void __exit moxa_exit(void)
457{ 1081{
458 int i; 1082 unsigned int i;
459 1083
460 del_timer_sync(&moxaTimer); 1084#ifdef CONFIG_PCI
1085 pci_unregister_driver(&moxa_pci_driver);
1086#endif
1087
1088 for (i = 0; i < MAX_BOARDS; i++) /* ISA boards */
1089 if (moxa_boards[i].ready)
1090 moxa_board_deinit(&moxa_boards[i]);
461 1091
462 for (i = 0; i < MAX_PORTS; i++) 1092 del_timer_sync(&moxaTimer);
463 del_timer_sync(&moxa_ports[i].emptyTimer);
464 1093
465 if (tty_unregister_driver(moxaDriver)) 1094 if (tty_unregister_driver(moxaDriver))
466 printk(KERN_ERR "Couldn't unregister MOXA Intellio family " 1095 printk(KERN_ERR "Couldn't unregister MOXA Intellio family "
467 "serial driver\n"); 1096 "serial driver\n");
468 put_tty_driver(moxaDriver); 1097 put_tty_driver(moxaDriver);
469
470#ifdef CONFIG_PCI
471 pci_unregister_driver(&moxa_pci_driver);
472#endif
473
474 for (i = 0; i < MAX_BOARDS; i++)
475 if (moxa_boards[i].basemem)
476 iounmap(moxa_boards[i].basemem);
477} 1098}
478 1099
479module_init(moxa_init); 1100module_init(moxa_init);
480module_exit(moxa_exit); 1101module_exit(moxa_exit);
481 1102
1103static void moxa_close_port(struct moxa_port *ch)
1104{
1105 moxa_shut_down(ch);
1106 MoxaPortFlushData(ch, 2);
1107 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
1108 ch->tty->driver_data = NULL;
1109 ch->tty = NULL;
1110}
1111
1112static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
1113 struct moxa_port *ch)
1114{
1115 DEFINE_WAIT(wait);
1116 int retval = 0;
1117 u8 dcd;
1118
1119 while (1) {
1120 prepare_to_wait(&ch->open_wait, &wait, TASK_INTERRUPTIBLE);
1121 if (tty_hung_up_p(filp)) {
1122#ifdef SERIAL_DO_RESTART
1123 retval = -ERESTARTSYS;
1124#else
1125 retval = -EAGAIN;
1126#endif
1127 break;
1128 }
1129 spin_lock_bh(&moxa_lock);
1130 dcd = ch->DCDState;
1131 spin_unlock_bh(&moxa_lock);
1132 if (dcd)
1133 break;
1134
1135 if (signal_pending(current)) {
1136 retval = -ERESTARTSYS;
1137 break;
1138 }
1139 schedule();
1140 }
1141 finish_wait(&ch->open_wait, &wait);
1142
1143 return retval;
1144}
1145
482static int moxa_open(struct tty_struct *tty, struct file *filp) 1146static int moxa_open(struct tty_struct *tty, struct file *filp)
483{ 1147{
1148 struct moxa_board_conf *brd;
484 struct moxa_port *ch; 1149 struct moxa_port *ch;
485 int port; 1150 int port;
486 int retval; 1151 int retval;
487 1152
488 port = tty->index; 1153 port = tty->index;
489 if (port == MAX_PORTS) { 1154 if (port == MAX_PORTS) {
490 return (0); 1155 return capable(CAP_SYS_ADMIN) ? 0 : -EPERM;
491 } 1156 }
492 if (!MoxaPortIsValid(port)) { 1157 if (mutex_lock_interruptible(&moxa_openlock))
493 tty->driver_data = NULL; 1158 return -ERESTARTSYS;
494 return (-ENODEV); 1159 brd = &moxa_boards[port / MAX_PORTS_PER_BOARD];
1160 if (!brd->ready) {
1161 mutex_unlock(&moxa_openlock);
1162 return -ENODEV;
495 } 1163 }
496 1164
497 ch = &moxa_ports[port]; 1165 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
498 ch->count++; 1166 ch->count++;
499 tty->driver_data = ch; 1167 tty->driver_data = ch;
500 ch->tty = tty; 1168 ch->tty = tty;
501 if (!(ch->asyncflags & ASYNC_INITIALIZED)) { 1169 if (!(ch->asyncflags & ASYNC_INITIALIZED)) {
502 ch->statusflags = 0; 1170 ch->statusflags = 0;
503 moxa_set_tty_param(tty, tty->termios); 1171 moxa_set_tty_param(tty, tty->termios);
504 MoxaPortLineCtrl(ch->port, 1, 1); 1172 MoxaPortLineCtrl(ch, 1, 1);
505 MoxaPortEnable(ch->port); 1173 MoxaPortEnable(ch);
1174 MoxaSetFifo(ch, ch->type == PORT_16550A);
506 ch->asyncflags |= ASYNC_INITIALIZED; 1175 ch->asyncflags |= ASYNC_INITIALIZED;
507 } 1176 }
508 retval = moxa_block_till_ready(tty, filp, ch); 1177 mutex_unlock(&moxa_openlock);
509 1178
510 moxa_unthrottle(tty); 1179 retval = 0;
511 1180 if (!(filp->f_flags & O_NONBLOCK) && !C_CLOCAL(tty))
512 if (ch->type == PORT_16550A) { 1181 retval = moxa_block_till_ready(tty, filp, ch);
513 MoxaSetFifo(ch->port, 1); 1182 mutex_lock(&moxa_openlock);
514 } else { 1183 if (retval) {
515 MoxaSetFifo(ch->port, 0); 1184 if (ch->count) /* 0 means already hung up... */
516 } 1185 if (--ch->count == 0)
1186 moxa_close_port(ch);
1187 } else
1188 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
1189 mutex_unlock(&moxa_openlock);
517 1190
518 return (retval); 1191 return retval;
519} 1192}
520 1193
521static void moxa_close(struct tty_struct *tty, struct file *filp) 1194static void moxa_close(struct tty_struct *tty, struct file *filp)
@@ -524,23 +1197,14 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
524 int port; 1197 int port;
525 1198
526 port = tty->index; 1199 port = tty->index;
527 if (port == MAX_PORTS) { 1200 if (port == MAX_PORTS || tty_hung_up_p(filp))
528 return;
529 }
530 if (!MoxaPortIsValid(port)) {
531 pr_debug("Invalid portno in moxa_close\n");
532 tty->driver_data = NULL;
533 return;
534 }
535 if (tty->driver_data == NULL) {
536 return; 1201 return;
537 }
538 if (tty_hung_up_p(filp)) {
539 return;
540 }
541 ch = (struct moxa_port *) tty->driver_data;
542 1202
543 if ((tty->count == 1) && (ch->count != 1)) { 1203 mutex_lock(&moxa_openlock);
1204 ch = tty->driver_data;
1205 if (ch == NULL)
1206 goto unlock;
1207 if (tty->count == 1 && ch->count != 1) {
544 printk(KERN_WARNING "moxa_close: bad serial port count; " 1208 printk(KERN_WARNING "moxa_close: bad serial port count; "
545 "tty->count is 1, ch->count is %d\n", ch->count); 1209 "tty->count is 1, ch->count is %d\n", ch->count);
546 ch->count = 1; 1210 ch->count = 1;
@@ -550,59 +1214,35 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
550 "device=%s\n", tty->name); 1214 "device=%s\n", tty->name);
551 ch->count = 0; 1215 ch->count = 0;
552 } 1216 }
553 if (ch->count) { 1217 if (ch->count)
554 return; 1218 goto unlock;
555 }
556 ch->asyncflags |= ASYNC_CLOSING;
557 1219
558 ch->cflag = tty->termios->c_cflag; 1220 ch->cflag = tty->termios->c_cflag;
559 if (ch->asyncflags & ASYNC_INITIALIZED) { 1221 if (ch->asyncflags & ASYNC_INITIALIZED) {
560 moxa_setup_empty_event(tty); 1222 moxa_setup_empty_event(tty);
561 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ 1223 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */
562 del_timer_sync(&moxa_ports[ch->port].emptyTimer);
563 }
564 moxa_shut_down(ch);
565 MoxaPortFlushData(port, 2);
566
567 if (tty->driver->flush_buffer)
568 tty->driver->flush_buffer(tty);
569 tty_ldisc_flush(tty);
570
571 tty->closing = 0;
572 ch->event = 0;
573 ch->tty = NULL;
574 if (ch->blocked_open) {
575 if (ch->close_delay) {
576 msleep_interruptible(jiffies_to_msecs(ch->close_delay));
577 }
578 wake_up_interruptible(&ch->open_wait);
579 } 1224 }
580 ch->asyncflags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); 1225
581 complete_all(&ch->close_wait); 1226 moxa_close_port(ch);
1227unlock:
1228 mutex_unlock(&moxa_openlock);
582} 1229}
583 1230
584static int moxa_write(struct tty_struct *tty, 1231static int moxa_write(struct tty_struct *tty,
585 const unsigned char *buf, int count) 1232 const unsigned char *buf, int count)
586{ 1233{
587 struct moxa_port *ch; 1234 struct moxa_port *ch = tty->driver_data;
588 int len, port; 1235 int len;
589 unsigned long flags;
590 1236
591 ch = (struct moxa_port *) tty->driver_data;
592 if (ch == NULL) 1237 if (ch == NULL)
593 return (0); 1238 return 0;
594 port = ch->port;
595 1239
596 spin_lock_irqsave(&moxa_lock, flags); 1240 spin_lock_bh(&moxa_lock);
597 len = MoxaPortWriteData(port, (unsigned char *) buf, count); 1241 len = MoxaPortWriteData(ch, buf, count);
598 spin_unlock_irqrestore(&moxa_lock, flags); 1242 spin_unlock_bh(&moxa_lock);
599 1243
600 /*********************************************
601 if ( !(ch->statusflags & LOWWAIT) &&
602 ((len != count) || (MoxaPortTxFree(port) <= 100)) )
603 ************************************************/
604 ch->statusflags |= LOWWAIT; 1244 ch->statusflags |= LOWWAIT;
605 return (len); 1245 return len;
606} 1246}
607 1247
608static int moxa_write_room(struct tty_struct *tty) 1248static int moxa_write_room(struct tty_struct *tty)
@@ -610,27 +1250,27 @@ static int moxa_write_room(struct tty_struct *tty)
610 struct moxa_port *ch; 1250 struct moxa_port *ch;
611 1251
612 if (tty->stopped) 1252 if (tty->stopped)
613 return (0); 1253 return 0;
614 ch = (struct moxa_port *) tty->driver_data; 1254 ch = tty->driver_data;
615 if (ch == NULL) 1255 if (ch == NULL)
616 return (0); 1256 return 0;
617 return (MoxaPortTxFree(ch->port)); 1257 return MoxaPortTxFree(ch);
618} 1258}
619 1259
620static void moxa_flush_buffer(struct tty_struct *tty) 1260static void moxa_flush_buffer(struct tty_struct *tty)
621{ 1261{
622 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1262 struct moxa_port *ch = tty->driver_data;
623 1263
624 if (ch == NULL) 1264 if (ch == NULL)
625 return; 1265 return;
626 MoxaPortFlushData(ch->port, 1); 1266 MoxaPortFlushData(ch, 1);
627 tty_wakeup(tty); 1267 tty_wakeup(tty);
628} 1268}
629 1269
630static int moxa_chars_in_buffer(struct tty_struct *tty) 1270static int moxa_chars_in_buffer(struct tty_struct *tty)
631{ 1271{
1272 struct moxa_port *ch = tty->driver_data;
632 int chars; 1273 int chars;
633 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
634 1274
635 /* 1275 /*
636 * Sigh...I have to check if driver_data is NULL here, because 1276 * Sigh...I have to check if driver_data is NULL here, because
@@ -639,8 +1279,9 @@ static int moxa_chars_in_buffer(struct tty_struct *tty)
639 * routine. And since the open() failed, we return 0 here. TDJ 1279 * routine. And since the open() failed, we return 0 here. TDJ
640 */ 1280 */
641 if (ch == NULL) 1281 if (ch == NULL)
642 return (0); 1282 return 0;
643 chars = MoxaPortTxQueue(ch->port); 1283 lock_kernel();
1284 chars = MoxaPortTxQueue(ch);
644 if (chars) { 1285 if (chars) {
645 /* 1286 /*
646 * Make it possible to wakeup anything waiting for output 1287 * Make it possible to wakeup anything waiting for output
@@ -649,73 +1290,54 @@ static int moxa_chars_in_buffer(struct tty_struct *tty)
649 if (!(ch->statusflags & EMPTYWAIT)) 1290 if (!(ch->statusflags & EMPTYWAIT))
650 moxa_setup_empty_event(tty); 1291 moxa_setup_empty_event(tty);
651 } 1292 }
652 return (chars); 1293 unlock_kernel();
653} 1294 return chars;
654
655static void moxa_flush_chars(struct tty_struct *tty)
656{
657 /*
658 * Don't think I need this, because this is called to empty the TX
659 * buffer for the 16450, 16550, etc.
660 */
661}
662
663static void moxa_put_char(struct tty_struct *tty, unsigned char c)
664{
665 struct moxa_port *ch;
666 int port;
667 unsigned long flags;
668
669 ch = (struct moxa_port *) tty->driver_data;
670 if (ch == NULL)
671 return;
672 port = ch->port;
673 spin_lock_irqsave(&moxa_lock, flags);
674 MoxaPortWriteData(port, &c, 1);
675 spin_unlock_irqrestore(&moxa_lock, flags);
676 /************************************************
677 if ( !(ch->statusflags & LOWWAIT) && (MoxaPortTxFree(port) <= 100) )
678 *************************************************/
679 ch->statusflags |= LOWWAIT;
680} 1295}
681 1296
682static int moxa_tiocmget(struct tty_struct *tty, struct file *file) 1297static int moxa_tiocmget(struct tty_struct *tty, struct file *file)
683{ 1298{
684 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1299 struct moxa_port *ch;
685 int port;
686 int flag = 0, dtr, rts; 1300 int flag = 0, dtr, rts;
687 1301
688 port = tty->index; 1302 mutex_lock(&moxa_openlock);
689 if ((port != MAX_PORTS) && (!ch)) 1303 ch = tty->driver_data;
690 return (-EINVAL); 1304 if (!ch) {
1305 mutex_unlock(&moxa_openlock);
1306 return -EINVAL;
1307 }
691 1308
692 MoxaPortGetLineOut(ch->port, &dtr, &rts); 1309 MoxaPortGetLineOut(ch, &dtr, &rts);
693 if (dtr) 1310 if (dtr)
694 flag |= TIOCM_DTR; 1311 flag |= TIOCM_DTR;
695 if (rts) 1312 if (rts)
696 flag |= TIOCM_RTS; 1313 flag |= TIOCM_RTS;
697 dtr = MoxaPortLineStatus(ch->port); 1314 dtr = MoxaPortLineStatus(ch);
698 if (dtr & 1) 1315 if (dtr & 1)
699 flag |= TIOCM_CTS; 1316 flag |= TIOCM_CTS;
700 if (dtr & 2) 1317 if (dtr & 2)
701 flag |= TIOCM_DSR; 1318 flag |= TIOCM_DSR;
702 if (dtr & 4) 1319 if (dtr & 4)
703 flag |= TIOCM_CD; 1320 flag |= TIOCM_CD;
1321 mutex_unlock(&moxa_openlock);
704 return flag; 1322 return flag;
705} 1323}
706 1324
707static int moxa_tiocmset(struct tty_struct *tty, struct file *file, 1325static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
708 unsigned int set, unsigned int clear) 1326 unsigned int set, unsigned int clear)
709{ 1327{
710 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1328 struct moxa_port *ch;
711 int port; 1329 int port;
712 int dtr, rts; 1330 int dtr, rts;
713 1331
714 port = tty->index; 1332 port = tty->index;
715 if ((port != MAX_PORTS) && (!ch)) 1333 mutex_lock(&moxa_openlock);
716 return (-EINVAL); 1334 ch = tty->driver_data;
1335 if (!ch) {
1336 mutex_unlock(&moxa_openlock);
1337 return -EINVAL;
1338 }
717 1339
718 MoxaPortGetLineOut(ch->port, &dtr, &rts); 1340 MoxaPortGetLineOut(ch, &dtr, &rts);
719 if (set & TIOCM_RTS) 1341 if (set & TIOCM_RTS)
720 rts = 1; 1342 rts = 1;
721 if (set & TIOCM_DTR) 1343 if (set & TIOCM_DTR)
@@ -724,105 +1346,51 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
724 rts = 0; 1346 rts = 0;
725 if (clear & TIOCM_DTR) 1347 if (clear & TIOCM_DTR)
726 dtr = 0; 1348 dtr = 0;
727 MoxaPortLineCtrl(ch->port, dtr, rts); 1349 MoxaPortLineCtrl(ch, dtr, rts);
1350 mutex_unlock(&moxa_openlock);
728 return 0; 1351 return 0;
729} 1352}
730 1353
731static int moxa_ioctl(struct tty_struct *tty, struct file *file,
732 unsigned int cmd, unsigned long arg)
733{
734 struct moxa_port *ch = (struct moxa_port *) tty->driver_data;
735 register int port;
736 void __user *argp = (void __user *)arg;
737 int retval;
738
739 port = tty->index;
740 if ((port != MAX_PORTS) && (!ch))
741 return (-EINVAL);
742
743 switch (cmd) {
744 case TCSBRK: /* SVID version: non-zero arg --> no break */
745 retval = tty_check_change(tty);
746 if (retval)
747 return (retval);
748 moxa_setup_empty_event(tty);
749 tty_wait_until_sent(tty, 0);
750 if (!arg)
751 MoxaPortSendBreak(ch->port, 0);
752 return (0);
753 case TCSBRKP: /* support for POSIX tcsendbreak() */
754 retval = tty_check_change(tty);
755 if (retval)
756 return (retval);
757 moxa_setup_empty_event(tty);
758 tty_wait_until_sent(tty, 0);
759 MoxaPortSendBreak(ch->port, arg);
760 return (0);
761 case TIOCGSOFTCAR:
762 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) argp);
763 case TIOCSSOFTCAR:
764 if(get_user(retval, (unsigned long __user *) argp))
765 return -EFAULT;
766 arg = retval;
767 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) |
768 (arg ? CLOCAL : 0));
769 if (C_CLOCAL(tty))
770 ch->asyncflags &= ~ASYNC_CHECK_CD;
771 else
772 ch->asyncflags |= ASYNC_CHECK_CD;
773 return (0);
774 case TIOCGSERIAL:
775 return moxa_get_serial_info(ch, argp);
776
777 case TIOCSSERIAL:
778 return moxa_set_serial_info(ch, argp);
779 default:
780 retval = MoxaDriverIoctl(cmd, arg, port);
781 }
782 return (retval);
783}
784
785static void moxa_throttle(struct tty_struct *tty) 1354static void moxa_throttle(struct tty_struct *tty)
786{ 1355{
787 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1356 struct moxa_port *ch = tty->driver_data;
788 1357
789 ch->statusflags |= THROTTLE; 1358 ch->statusflags |= THROTTLE;
790} 1359}
791 1360
792static void moxa_unthrottle(struct tty_struct *tty) 1361static void moxa_unthrottle(struct tty_struct *tty)
793{ 1362{
794 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1363 struct moxa_port *ch = tty->driver_data;
795 1364
796 ch->statusflags &= ~THROTTLE; 1365 ch->statusflags &= ~THROTTLE;
797} 1366}
798 1367
799static void moxa_set_termios(struct tty_struct *tty, 1368static void moxa_set_termios(struct tty_struct *tty,
800 struct ktermios *old_termios) 1369 struct ktermios *old_termios)
801{ 1370{
802 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1371 struct moxa_port *ch = tty->driver_data;
803 1372
804 if (ch == NULL) 1373 if (ch == NULL)
805 return; 1374 return;
806 moxa_set_tty_param(tty, old_termios); 1375 moxa_set_tty_param(tty, old_termios);
807 if (!(old_termios->c_cflag & CLOCAL) && 1376 if (!(old_termios->c_cflag & CLOCAL) && C_CLOCAL(tty))
808 (tty->termios->c_cflag & CLOCAL))
809 wake_up_interruptible(&ch->open_wait); 1377 wake_up_interruptible(&ch->open_wait);
810} 1378}
811 1379
812static void moxa_stop(struct tty_struct *tty) 1380static void moxa_stop(struct tty_struct *tty)
813{ 1381{
814 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1382 struct moxa_port *ch = tty->driver_data;
815 1383
816 if (ch == NULL) 1384 if (ch == NULL)
817 return; 1385 return;
818 MoxaPortTxDisable(ch->port); 1386 MoxaPortTxDisable(ch);
819 ch->statusflags |= TXSTOPPED; 1387 ch->statusflags |= TXSTOPPED;
820} 1388}
821 1389
822 1390
823static void moxa_start(struct tty_struct *tty) 1391static void moxa_start(struct tty_struct *tty)
824{ 1392{
825 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1393 struct moxa_port *ch = tty->driver_data;
826 1394
827 if (ch == NULL) 1395 if (ch == NULL)
828 return; 1396 return;
@@ -830,91 +1398,143 @@ static void moxa_start(struct tty_struct *tty)
830 if (!(ch->statusflags & TXSTOPPED)) 1398 if (!(ch->statusflags & TXSTOPPED))
831 return; 1399 return;
832 1400
833 MoxaPortTxEnable(ch->port); 1401 MoxaPortTxEnable(ch);
834 ch->statusflags &= ~TXSTOPPED; 1402 ch->statusflags &= ~TXSTOPPED;
835} 1403}
836 1404
837static void moxa_hangup(struct tty_struct *tty) 1405static void moxa_hangup(struct tty_struct *tty)
838{ 1406{
839 struct moxa_port *ch = (struct moxa_port *) tty->driver_data; 1407 struct moxa_port *ch;
840 1408
841 moxa_flush_buffer(tty); 1409 mutex_lock(&moxa_openlock);
842 moxa_shut_down(ch); 1410 ch = tty->driver_data;
843 ch->event = 0; 1411 if (ch == NULL) {
1412 mutex_unlock(&moxa_openlock);
1413 return;
1414 }
844 ch->count = 0; 1415 ch->count = 0;
845 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE; 1416 moxa_close_port(ch);
846 ch->tty = NULL; 1417 mutex_unlock(&moxa_openlock);
1418
847 wake_up_interruptible(&ch->open_wait); 1419 wake_up_interruptible(&ch->open_wait);
848} 1420}
849 1421
850static void moxa_poll(unsigned long ignored) 1422static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
851{ 1423{
852 register int card; 1424 dcd = !!dcd;
853 struct moxa_port *ch;
854 struct tty_struct *tp;
855 int i, ports;
856 1425
857 del_timer(&moxaTimer); 1426 if (dcd != p->DCDState && p->tty && C_CLOCAL(p->tty)) {
1427 if (!dcd)
1428 tty_hangup(p->tty);
1429 }
1430 p->DCDState = dcd;
1431}
858 1432
859 if (MoxaDriverPoll() < 0) { 1433static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
860 mod_timer(&moxaTimer, jiffies + HZ / 50); 1434 u16 __iomem *ip)
861 return; 1435{
1436 struct tty_struct *tty = p->tty;
1437 void __iomem *ofsAddr;
1438 unsigned int inited = p->asyncflags & ASYNC_INITIALIZED;
1439 u16 intr;
1440
1441 if (tty) {
1442 if ((p->statusflags & EMPTYWAIT) &&
1443 MoxaPortTxQueue(p) == 0) {
1444 p->statusflags &= ~EMPTYWAIT;
1445 tty_wakeup(tty);
1446 }
1447 if ((p->statusflags & LOWWAIT) && !tty->stopped &&
1448 MoxaPortTxQueue(p) <= WAKEUP_CHARS) {
1449 p->statusflags &= ~LOWWAIT;
1450 tty_wakeup(tty);
1451 }
1452
1453 if (inited && !(p->statusflags & THROTTLE) &&
1454 MoxaPortRxQueue(p) > 0) { /* RX */
1455 MoxaPortReadData(p);
1456 tty_schedule_flip(tty);
1457 }
1458 } else {
1459 p->statusflags &= ~EMPTYWAIT;
1460 MoxaPortFlushData(p, 0); /* flush RX */
862 } 1461 }
1462
1463 if (!handle) /* nothing else to do */
1464 return 0;
1465
1466 intr = readw(ip); /* port irq status */
1467 if (intr == 0)
1468 return 0;
1469
1470 writew(0, ip); /* ACK port */
1471 ofsAddr = p->tableAddr;
1472 if (intr & IntrTx) /* disable tx intr */
1473 writew(readw(ofsAddr + HostStat) & ~WakeupTx,
1474 ofsAddr + HostStat);
1475
1476 if (!inited)
1477 return 0;
1478
1479 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */
1480 tty_insert_flip_char(tty, 0, TTY_BREAK);
1481 tty_schedule_flip(tty);
1482 }
1483
1484 if (intr & IntrLine)
1485 moxa_new_dcdstate(p, readb(ofsAddr + FlagStat) & DCD_state);
1486
1487 return 0;
1488}
1489
1490static void moxa_poll(unsigned long ignored)
1491{
1492 struct moxa_board_conf *brd;
1493 u16 __iomem *ip;
1494 unsigned int card, port, served = 0;
1495
1496 spin_lock(&moxa_lock);
863 for (card = 0; card < MAX_BOARDS; card++) { 1497 for (card = 0; card < MAX_BOARDS; card++) {
864 if ((ports = MoxaPortsOfCard(card)) <= 0) 1498 brd = &moxa_boards[card];
1499 if (!brd->ready)
865 continue; 1500 continue;
866 ch = &moxa_ports[card * MAX_PORTS_PER_BOARD]; 1501
867 for (i = 0; i < ports; i++, ch++) { 1502 served++;
868 if ((ch->asyncflags & ASYNC_INITIALIZED) == 0) 1503
869 continue; 1504 ip = NULL;
870 if (!(ch->statusflags & THROTTLE) && 1505 if (readb(brd->intPend) == 0xff)
871 (MoxaPortRxQueue(ch->port) > 0)) 1506 ip = brd->intTable + readb(brd->intNdx);
872 moxa_receive_data(ch); 1507
873 if ((tp = ch->tty) == 0) 1508 for (port = 0; port < brd->numPorts; port++)
874 continue; 1509 moxa_poll_port(&brd->ports[port], !!ip, ip + port);
875 if (ch->statusflags & LOWWAIT) { 1510
876 if (MoxaPortTxQueue(ch->port) <= WAKEUP_CHARS) { 1511 if (ip)
877 if (!tp->stopped) { 1512 writeb(0, brd->intPend); /* ACK */
878 ch->statusflags &= ~LOWWAIT; 1513
879 tty_wakeup(tp); 1514 if (moxaLowWaterChk) {
880 } 1515 struct moxa_port *p = brd->ports;
881 } 1516 for (port = 0; port < brd->numPorts; port++, p++)
882 } 1517 if (p->lowChkFlag) {
883 if (!I_IGNBRK(tp) && (MoxaPortResetBrkCnt(ch->port) > 0)) { 1518 p->lowChkFlag = 0;
884 tty_insert_flip_char(tp, 0, TTY_BREAK); 1519 moxa_low_water_check(p->tableAddr);
885 tty_schedule_flip(tp);
886 }
887 if (MoxaPortDCDChange(ch->port)) {
888 if (ch->asyncflags & ASYNC_CHECK_CD) {
889 if (MoxaPortDCDON(ch->port))
890 wake_up_interruptible(&ch->open_wait);
891 else {
892 tty_hangup(tp);
893 wake_up_interruptible(&ch->open_wait);
894 ch->asyncflags &= ~ASYNC_NORMAL_ACTIVE;
895 }
896 } 1520 }
897 }
898 } 1521 }
899 } 1522 }
1523 moxaLowWaterChk = 0;
900 1524
901 mod_timer(&moxaTimer, jiffies + HZ / 50); 1525 if (served)
1526 mod_timer(&moxaTimer, jiffies + HZ / 50);
1527 spin_unlock(&moxa_lock);
902} 1528}
903 1529
904/******************************************************************************/ 1530/******************************************************************************/
905 1531
906static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios) 1532static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_termios)
907{ 1533{
908 register struct ktermios *ts; 1534 register struct ktermios *ts = tty->termios;
909 struct moxa_port *ch; 1535 struct moxa_port *ch = tty->driver_data;
910 int rts, cts, txflow, rxflow, xany, baud; 1536 int rts, cts, txflow, rxflow, xany, baud;
911 1537
912 ch = (struct moxa_port *) tty->driver_data;
913 ts = tty->termios;
914 if (ts->c_cflag & CLOCAL)
915 ch->asyncflags &= ~ASYNC_CHECK_CD;
916 else
917 ch->asyncflags |= ASYNC_CHECK_CD;
918 rts = cts = txflow = rxflow = xany = 0; 1538 rts = cts = txflow = rxflow = xany = 0;
919 if (ts->c_cflag & CRTSCTS) 1539 if (ts->c_cflag & CRTSCTS)
920 rts = cts = 1; 1540 rts = cts = 1;
@@ -927,776 +1547,60 @@ static void moxa_set_tty_param(struct tty_struct *tty, struct ktermios *old_term
927 1547
928 /* Clear the features we don't support */ 1548 /* Clear the features we don't support */
929 ts->c_cflag &= ~CMSPAR; 1549 ts->c_cflag &= ~CMSPAR;
930 MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); 1550 MoxaPortFlowCtrl(ch, rts, cts, txflow, rxflow, xany);
931 baud = MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty)); 1551 baud = MoxaPortSetTermio(ch, ts, tty_get_baud_rate(tty));
932 if (baud == -1) 1552 if (baud == -1)
933 baud = tty_termios_baud_rate(old_termios); 1553 baud = tty_termios_baud_rate(old_termios);
934 /* Not put the baud rate into the termios data */ 1554 /* Not put the baud rate into the termios data */
935 tty_encode_baud_rate(tty, baud, baud); 1555 tty_encode_baud_rate(tty, baud, baud);
936} 1556}
937 1557
938static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
939 struct moxa_port *ch)
940{
941 DECLARE_WAITQUEUE(wait,current);
942 unsigned long flags;
943 int retval;
944 int do_clocal = C_CLOCAL(tty);
945
946 /*
947 * If the device is in the middle of being closed, then block
948 * until it's done, and then try again.
949 */
950 if (tty_hung_up_p(filp) || (ch->asyncflags & ASYNC_CLOSING)) {
951 if (ch->asyncflags & ASYNC_CLOSING)
952 wait_for_completion_interruptible(&ch->close_wait);
953#ifdef SERIAL_DO_RESTART
954 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
955 return (-EAGAIN);
956 else
957 return (-ERESTARTSYS);
958#else
959 return (-EAGAIN);
960#endif
961 }
962 /*
963 * If non-blocking mode is set, then make the check up front
964 * and then exit.
965 */
966 if (filp->f_flags & O_NONBLOCK) {
967 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
968 return (0);
969 }
970 /*
971 * Block waiting for the carrier detect and the line to become free
972 */
973 retval = 0;
974 add_wait_queue(&ch->open_wait, &wait);
975 pr_debug("block_til_ready before block: ttys%d, count = %d\n",
976 ch->port, ch->count);
977 spin_lock_irqsave(&moxa_lock, flags);
978 if (!tty_hung_up_p(filp))
979 ch->count--;
980 ch->blocked_open++;
981 spin_unlock_irqrestore(&moxa_lock, flags);
982
983 while (1) {
984 set_current_state(TASK_INTERRUPTIBLE);
985 if (tty_hung_up_p(filp) ||
986 !(ch->asyncflags & ASYNC_INITIALIZED)) {
987#ifdef SERIAL_DO_RESTART
988 if (ch->asyncflags & ASYNC_HUP_NOTIFY)
989 retval = -EAGAIN;
990 else
991 retval = -ERESTARTSYS;
992#else
993 retval = -EAGAIN;
994#endif
995 break;
996 }
997 if (!(ch->asyncflags & ASYNC_CLOSING) && (do_clocal ||
998 MoxaPortDCDON(ch->port)))
999 break;
1000
1001 if (signal_pending(current)) {
1002 retval = -ERESTARTSYS;
1003 break;
1004 }
1005 schedule();
1006 }
1007 set_current_state(TASK_RUNNING);
1008 remove_wait_queue(&ch->open_wait, &wait);
1009
1010 spin_lock_irqsave(&moxa_lock, flags);
1011 if (!tty_hung_up_p(filp))
1012 ch->count++;
1013 ch->blocked_open--;
1014 spin_unlock_irqrestore(&moxa_lock, flags);
1015 pr_debug("block_til_ready after blocking: ttys%d, count = %d\n",
1016 ch->port, ch->count);
1017 if (retval)
1018 return (retval);
1019 /* FIXME: review to see if we need to use set_bit on these */
1020 ch->asyncflags |= ASYNC_NORMAL_ACTIVE;
1021 return 0;
1022}
1023
1024static void moxa_setup_empty_event(struct tty_struct *tty) 1558static void moxa_setup_empty_event(struct tty_struct *tty)
1025{ 1559{
1026 struct moxa_port *ch = tty->driver_data; 1560 struct moxa_port *ch = tty->driver_data;
1027 unsigned long flags;
1028 1561
1029 spin_lock_irqsave(&moxa_lock, flags); 1562 spin_lock_bh(&moxa_lock);
1030 ch->statusflags |= EMPTYWAIT; 1563 ch->statusflags |= EMPTYWAIT;
1031 mod_timer(&moxa_ports[ch->port].emptyTimer, jiffies + HZ); 1564 spin_unlock_bh(&moxa_lock);
1032 spin_unlock_irqrestore(&moxa_lock, flags);
1033}
1034
1035static void moxa_check_xmit_empty(unsigned long data)
1036{
1037 struct moxa_port *ch;
1038
1039 ch = (struct moxa_port *) data;
1040 if (ch->tty && (ch->statusflags & EMPTYWAIT)) {
1041 if (MoxaPortTxQueue(ch->port) == 0) {
1042 ch->statusflags &= ~EMPTYWAIT;
1043 tty_wakeup(ch->tty);
1044 return;
1045 }
1046 mod_timer(&moxa_ports[ch->port].emptyTimer,
1047 round_jiffies(jiffies + HZ));
1048 } else
1049 ch->statusflags &= ~EMPTYWAIT;
1050} 1565}
1051 1566
1052static void moxa_shut_down(struct moxa_port *ch) 1567static void moxa_shut_down(struct moxa_port *ch)
1053{ 1568{
1054 struct tty_struct *tp; 1569 struct tty_struct *tp = ch->tty;
1055 1570
1056 if (!(ch->asyncflags & ASYNC_INITIALIZED)) 1571 if (!(ch->asyncflags & ASYNC_INITIALIZED))
1057 return; 1572 return;
1058 1573
1059 tp = ch->tty; 1574 MoxaPortDisable(ch);
1060
1061 MoxaPortDisable(ch->port);
1062 1575
1063 /* 1576 /*
1064 * If we're a modem control device and HUPCL is on, drop RTS & DTR. 1577 * If we're a modem control device and HUPCL is on, drop RTS & DTR.
1065 */ 1578 */
1066 if (tp->termios->c_cflag & HUPCL) 1579 if (C_HUPCL(tp))
1067 MoxaPortLineCtrl(ch->port, 0, 0); 1580 MoxaPortLineCtrl(ch, 0, 0);
1068 1581
1582 spin_lock_bh(&moxa_lock);
1069 ch->asyncflags &= ~ASYNC_INITIALIZED; 1583 ch->asyncflags &= ~ASYNC_INITIALIZED;
1584 spin_unlock_bh(&moxa_lock);
1070} 1585}
1071 1586
1072static void moxa_receive_data(struct moxa_port *ch)
1073{
1074 struct tty_struct *tp;
1075 struct ktermios *ts;
1076 unsigned long flags;
1077
1078 ts = NULL;
1079 tp = ch->tty;
1080 if (tp)
1081 ts = tp->termios;
1082 /**************************************************
1083 if ( !tp || !ts || !(ts->c_cflag & CREAD) ) {
1084 *****************************************************/
1085 if (!tp || !ts) {
1086 MoxaPortFlushData(ch->port, 0);
1087 return;
1088 }
1089 spin_lock_irqsave(&moxa_lock, flags);
1090 MoxaPortReadData(ch->port, tp);
1091 spin_unlock_irqrestore(&moxa_lock, flags);
1092 tty_schedule_flip(tp);
1093}
1094
1095#define Magic_code 0x404
1096
1097/*
1098 * System Configuration
1099 */
1100/*
1101 * for C218 BIOS initialization
1102 */
1103#define C218_ConfBase 0x800
1104#define C218_status (C218_ConfBase + 0) /* BIOS running status */
1105#define C218_diag (C218_ConfBase + 2) /* diagnostic status */
1106#define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */
1107#define C218DLoad_len (C218_ConfBase + 6) /* WORD */
1108#define C218check_sum (C218_ConfBase + 8) /* BYTE */
1109#define C218chksum_ok (C218_ConfBase + 0x0a) /* BYTE (1:ok) */
1110#define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */
1111#define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */
1112#define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */
1113#define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */
1114
1115#define C218_LoadBuf 0x0F00
1116#define C218_KeyCode 0x218
1117#define CP204J_KeyCode 0x204
1118
1119/*
1120 * for C320 BIOS initialization
1121 */
1122#define C320_ConfBase 0x800
1123#define C320_LoadBuf 0x0f00
1124#define STS_init 0x05 /* for C320_status */
1125
1126#define C320_status C320_ConfBase + 0 /* BIOS running status */
1127#define C320_diag C320_ConfBase + 2 /* diagnostic status */
1128#define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */
1129#define C320DLoad_len C320_ConfBase + 6 /* WORD */
1130#define C320check_sum C320_ConfBase + 8 /* WORD */
1131#define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */
1132#define C320bapi_len C320_ConfBase + 0x0c /* WORD */
1133#define C320UART_no C320_ConfBase + 0x0e /* WORD */
1134
1135#define C320_KeyCode 0x320
1136
1137#define FixPage_addr 0x0000 /* starting addr of static page */
1138#define DynPage_addr 0x2000 /* starting addr of dynamic page */
1139#define C218_start 0x3000 /* starting addr of C218 BIOS prg */
1140#define Control_reg 0x1ff0 /* select page and reset control */
1141#define HW_reset 0x80
1142
1143/*
1144 * Function Codes
1145 */
1146#define FC_CardReset 0x80
1147#define FC_ChannelReset 1 /* C320 firmware not supported */
1148#define FC_EnableCH 2
1149#define FC_DisableCH 3
1150#define FC_SetParam 4
1151#define FC_SetMode 5
1152#define FC_SetRate 6
1153#define FC_LineControl 7
1154#define FC_LineStatus 8
1155#define FC_XmitControl 9
1156#define FC_FlushQueue 10
1157#define FC_SendBreak 11
1158#define FC_StopBreak 12
1159#define FC_LoopbackON 13
1160#define FC_LoopbackOFF 14
1161#define FC_ClrIrqTable 15
1162#define FC_SendXon 16
1163#define FC_SetTermIrq 17 /* C320 firmware not supported */
1164#define FC_SetCntIrq 18 /* C320 firmware not supported */
1165#define FC_SetBreakIrq 19
1166#define FC_SetLineIrq 20
1167#define FC_SetFlowCtl 21
1168#define FC_GenIrq 22
1169#define FC_InCD180 23
1170#define FC_OutCD180 24
1171#define FC_InUARTreg 23
1172#define FC_OutUARTreg 24
1173#define FC_SetXonXoff 25
1174#define FC_OutCD180CCR 26
1175#define FC_ExtIQueue 27
1176#define FC_ExtOQueue 28
1177#define FC_ClrLineIrq 29
1178#define FC_HWFlowCtl 30
1179#define FC_GetClockRate 35
1180#define FC_SetBaud 36
1181#define FC_SetDataMode 41
1182#define FC_GetCCSR 43
1183#define FC_GetDataError 45
1184#define FC_RxControl 50
1185#define FC_ImmSend 51
1186#define FC_SetXonState 52
1187#define FC_SetXoffState 53
1188#define FC_SetRxFIFOTrig 54
1189#define FC_SetTxFIFOCnt 55
1190#define FC_UnixRate 56
1191#define FC_UnixResetTimer 57
1192
1193#define RxFIFOTrig1 0
1194#define RxFIFOTrig4 1
1195#define RxFIFOTrig8 2
1196#define RxFIFOTrig14 3
1197
1198/*
1199 * Dual-Ported RAM
1200 */
1201#define DRAM_global 0
1202#define INT_data (DRAM_global + 0)
1203#define Config_base (DRAM_global + 0x108)
1204
1205#define IRQindex (INT_data + 0)
1206#define IRQpending (INT_data + 4)
1207#define IRQtable (INT_data + 8)
1208
1209/*
1210 * Interrupt Status
1211 */
1212#define IntrRx 0x01 /* receiver data O.K. */
1213#define IntrTx 0x02 /* transmit buffer empty */
1214#define IntrFunc 0x04 /* function complete */
1215#define IntrBreak 0x08 /* received break */
1216#define IntrLine 0x10 /* line status change
1217 for transmitter */
1218#define IntrIntr 0x20 /* received INTR code */
1219#define IntrQuit 0x40 /* received QUIT code */
1220#define IntrEOF 0x80 /* received EOF code */
1221
1222#define IntrRxTrigger 0x100 /* rx data count reach tigger value */
1223#define IntrTxTrigger 0x200 /* tx data count below trigger value */
1224
1225#define Magic_no (Config_base + 0)
1226#define Card_model_no (Config_base + 2)
1227#define Total_ports (Config_base + 4)
1228#define Module_cnt (Config_base + 8)
1229#define Module_no (Config_base + 10)
1230#define Timer_10ms (Config_base + 14)
1231#define Disable_IRQ (Config_base + 20)
1232#define TMS320_PORT1 (Config_base + 22)
1233#define TMS320_PORT2 (Config_base + 24)
1234#define TMS320_CLOCK (Config_base + 26)
1235
1236/*
1237 * DATA BUFFER in DRAM
1238 */
1239#define Extern_table 0x400 /* Base address of the external table
1240 (24 words * 64) total 3K bytes
1241 (24 words * 128) total 6K bytes */
1242#define Extern_size 0x60 /* 96 bytes */
1243#define RXrptr 0x00 /* read pointer for RX buffer */
1244#define RXwptr 0x02 /* write pointer for RX buffer */
1245#define TXrptr 0x04 /* read pointer for TX buffer */
1246#define TXwptr 0x06 /* write pointer for TX buffer */
1247#define HostStat 0x08 /* IRQ flag and general flag */
1248#define FlagStat 0x0A
1249#define FlowControl 0x0C /* B7 B6 B5 B4 B3 B2 B1 B0 */
1250 /* x x x x | | | | */
1251 /* | | | + CTS flow */
1252 /* | | +--- RTS flow */
1253 /* | +------ TX Xon/Xoff */
1254 /* +--------- RX Xon/Xoff */
1255#define Break_cnt 0x0E /* received break count */
1256#define CD180TXirq 0x10 /* if non-0: enable TX irq */
1257#define RX_mask 0x12
1258#define TX_mask 0x14
1259#define Ofs_rxb 0x16
1260#define Ofs_txb 0x18
1261#define Page_rxb 0x1A
1262#define Page_txb 0x1C
1263#define EndPage_rxb 0x1E
1264#define EndPage_txb 0x20
1265#define Data_error 0x22
1266#define RxTrigger 0x28
1267#define TxTrigger 0x2a
1268
1269#define rRXwptr 0x34
1270#define Low_water 0x36
1271
1272#define FuncCode 0x40
1273#define FuncArg 0x42
1274#define FuncArg1 0x44
1275
1276#define C218rx_size 0x2000 /* 8K bytes */
1277#define C218tx_size 0x8000 /* 32K bytes */
1278
1279#define C218rx_mask (C218rx_size - 1)
1280#define C218tx_mask (C218tx_size - 1)
1281
1282#define C320p8rx_size 0x2000
1283#define C320p8tx_size 0x8000
1284#define C320p8rx_mask (C320p8rx_size - 1)
1285#define C320p8tx_mask (C320p8tx_size - 1)
1286
1287#define C320p16rx_size 0x2000
1288#define C320p16tx_size 0x4000
1289#define C320p16rx_mask (C320p16rx_size - 1)
1290#define C320p16tx_mask (C320p16tx_size - 1)
1291
1292#define C320p24rx_size 0x2000
1293#define C320p24tx_size 0x2000
1294#define C320p24rx_mask (C320p24rx_size - 1)
1295#define C320p24tx_mask (C320p24tx_size - 1)
1296
1297#define C320p32rx_size 0x1000
1298#define C320p32tx_size 0x1000
1299#define C320p32rx_mask (C320p32rx_size - 1)
1300#define C320p32tx_mask (C320p32tx_size - 1)
1301
1302#define Page_size 0x2000
1303#define Page_mask (Page_size - 1)
1304#define C218rx_spage 3
1305#define C218tx_spage 4
1306#define C218rx_pageno 1
1307#define C218tx_pageno 4
1308#define C218buf_pageno 5
1309
1310#define C320p8rx_spage 3
1311#define C320p8tx_spage 4
1312#define C320p8rx_pgno 1
1313#define C320p8tx_pgno 4
1314#define C320p8buf_pgno 5
1315
1316#define C320p16rx_spage 3
1317#define C320p16tx_spage 4
1318#define C320p16rx_pgno 1
1319#define C320p16tx_pgno 2
1320#define C320p16buf_pgno 3
1321
1322#define C320p24rx_spage 3
1323#define C320p24tx_spage 4
1324#define C320p24rx_pgno 1
1325#define C320p24tx_pgno 1
1326#define C320p24buf_pgno 2
1327
1328#define C320p32rx_spage 3
1329#define C320p32tx_ofs C320p32rx_size
1330#define C320p32tx_spage 3
1331#define C320p32buf_pgno 1
1332
1333/*
1334 * Host Status
1335 */
1336#define WakeupRx 0x01
1337#define WakeupTx 0x02
1338#define WakeupBreak 0x08
1339#define WakeupLine 0x10
1340#define WakeupIntr 0x20
1341#define WakeupQuit 0x40
1342#define WakeupEOF 0x80 /* used in VTIME control */
1343#define WakeupRxTrigger 0x100
1344#define WakeupTxTrigger 0x200
1345/*
1346 * Flag status
1347 */
1348#define Rx_over 0x01
1349#define Xoff_state 0x02
1350#define Tx_flowOff 0x04
1351#define Tx_enable 0x08
1352#define CTS_state 0x10
1353#define DSR_state 0x20
1354#define DCD_state 0x80
1355/*
1356 * FlowControl
1357 */
1358#define CTS_FlowCtl 1
1359#define RTS_FlowCtl 2
1360#define Tx_FlowCtl 4
1361#define Rx_FlowCtl 8
1362#define IXM_IXANY 0x10
1363
1364#define LowWater 128
1365
1366#define DTR_ON 1
1367#define RTS_ON 2
1368#define CTS_ON 1
1369#define DSR_ON 2
1370#define DCD_ON 8
1371
1372/* mode definition */
1373#define MX_CS8 0x03
1374#define MX_CS7 0x02
1375#define MX_CS6 0x01
1376#define MX_CS5 0x00
1377
1378#define MX_STOP1 0x00
1379#define MX_STOP15 0x04
1380#define MX_STOP2 0x08
1381
1382#define MX_PARNONE 0x00
1383#define MX_PAREVEN 0x40
1384#define MX_PARODD 0xC0
1385
1386/*
1387 * Query
1388 */
1389
1390struct mon_str {
1391 int tick;
1392 int rxcnt[MAX_PORTS];
1393 int txcnt[MAX_PORTS];
1394};
1395
1396#define DCD_changed 0x01
1397#define DCD_oldstate 0x80
1398
1399static unsigned char moxaBuff[10240];
1400static int moxaLowWaterChk;
1401static int moxaCard;
1402static struct mon_str moxaLog;
1403static int moxaFuncTout = HZ / 2;
1404
1405static void moxafunc(void __iomem *, int, ushort);
1406static void moxa_wait_finish(void __iomem *);
1407static void moxa_low_water_check(void __iomem *);
1408static int moxaloadbios(int, unsigned char __user *, int);
1409static int moxafindcard(int);
1410static int moxaload320b(int, unsigned char __user *, int);
1411static int moxaloadcode(int, unsigned char __user *, int);
1412static int moxaloadc218(int, void __iomem *, int);
1413static int moxaloadc320(int, void __iomem *, int, int *);
1414
1415/***************************************************************************** 1587/*****************************************************************************
1416 * Driver level functions: * 1588 * Driver level functions: *
1417 * 1. MoxaDriverInit(void); *
1418 * 2. MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port); *
1419 * 3. MoxaDriverPoll(void); *
1420 *****************************************************************************/ 1589 *****************************************************************************/
1421void MoxaDriverInit(void)
1422{
1423 struct moxa_port *p;
1424 unsigned int i;
1425 1590
1426 moxaFuncTout = HZ / 2; /* 500 mini-seconds */ 1591static void MoxaPortFlushData(struct moxa_port *port, int mode)
1427 moxaCard = 0;
1428 moxaLog.tick = 0;
1429 moxaLowWaterChk = 0;
1430 for (i = 0; i < MAX_PORTS; i++) {
1431 p = &moxa_ports[i];
1432 p->chkPort = 0;
1433 p->lowChkFlag = 0;
1434 p->lineCtrl = 0;
1435 moxaLog.rxcnt[i] = 0;
1436 moxaLog.txcnt[i] = 0;
1437 }
1438}
1439
1440#define MOXA 0x400
1441#define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */
1442#define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */
1443#define MOXA_INIT_DRIVER (MOXA + 6) /* moxaCard=0 */
1444#define MOXA_LOAD_BIOS (MOXA + 9) /* download BIOS */
1445#define MOXA_FIND_BOARD (MOXA + 10) /* Check if MOXA card exist? */
1446#define MOXA_LOAD_C320B (MOXA + 11) /* download 320B firmware */
1447#define MOXA_LOAD_CODE (MOXA + 12) /* download firmware */
1448#define MOXA_GETDATACOUNT (MOXA + 23)
1449#define MOXA_GET_IOQUEUE (MOXA + 27)
1450#define MOXA_FLUSH_QUEUE (MOXA + 28)
1451#define MOXA_GET_CONF (MOXA + 35) /* configuration */
1452#define MOXA_GET_MAJOR (MOXA + 63)
1453#define MOXA_GET_CUMAJOR (MOXA + 64)
1454#define MOXA_GETMSTATUS (MOXA + 65)
1455
1456struct dl_str {
1457 char __user *buf;
1458 int len;
1459 int cardno;
1460};
1461
1462static struct dl_str dltmp;
1463
1464void MoxaPortFlushData(int port, int mode)
1465{ 1592{
1466 void __iomem *ofsAddr; 1593 void __iomem *ofsAddr;
1467 if ((mode < 0) || (mode > 2)) 1594 if (mode < 0 || mode > 2)
1468 return; 1595 return;
1469 ofsAddr = moxa_ports[port].tableAddr; 1596 ofsAddr = port->tableAddr;
1470 moxafunc(ofsAddr, FC_FlushQueue, mode); 1597 moxafunc(ofsAddr, FC_FlushQueue, mode);
1471 if (mode != 1) { 1598 if (mode != 1) {
1472 moxa_ports[port].lowChkFlag = 0; 1599 port->lowChkFlag = 0;
1473 moxa_low_water_check(ofsAddr); 1600 moxa_low_water_check(ofsAddr);
1474 } 1601 }
1475} 1602}
1476 1603
1477int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port)
1478{
1479 int i;
1480 int status;
1481 int MoxaPortTxQueue(int), MoxaPortRxQueue(int);
1482 void __user *argp = (void __user *)arg;
1483
1484 if (port == MAX_PORTS) {
1485 if ((cmd != MOXA_GET_CONF) && (cmd != MOXA_INIT_DRIVER) &&
1486 (cmd != MOXA_LOAD_BIOS) && (cmd != MOXA_FIND_BOARD) && (cmd != MOXA_LOAD_C320B) &&
1487 (cmd != MOXA_LOAD_CODE) && (cmd != MOXA_GETDATACOUNT) &&
1488 (cmd != MOXA_GET_IOQUEUE) && (cmd != MOXA_GET_MAJOR) &&
1489 (cmd != MOXA_GET_CUMAJOR) && (cmd != MOXA_GETMSTATUS))
1490 return (-EINVAL);
1491 }
1492 switch (cmd) {
1493 case MOXA_GET_CONF:
1494 if(copy_to_user(argp, &moxa_boards, MAX_BOARDS *
1495 sizeof(struct moxa_board_conf)))
1496 return -EFAULT;
1497 return (0);
1498 case MOXA_INIT_DRIVER:
1499 if ((int) arg == 0x404)
1500 MoxaDriverInit();
1501 return (0);
1502 case MOXA_GETDATACOUNT:
1503 moxaLog.tick = jiffies;
1504 if(copy_to_user(argp, &moxaLog, sizeof(struct mon_str)))
1505 return -EFAULT;
1506 return (0);
1507 case MOXA_FLUSH_QUEUE:
1508 MoxaPortFlushData(port, arg);
1509 return (0);
1510 case MOXA_GET_IOQUEUE: {
1511 struct moxaq_str __user *argm = argp;
1512 struct moxaq_str tmp;
1513
1514 for (i = 0; i < MAX_PORTS; i++, argm++) {
1515 memset(&tmp, 0, sizeof(tmp));
1516 if (moxa_ports[i].chkPort) {
1517 tmp.inq = MoxaPortRxQueue(i);
1518 tmp.outq = MoxaPortTxQueue(i);
1519 }
1520 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1521 return -EFAULT;
1522 }
1523 return (0);
1524 } case MOXA_GET_OQUEUE:
1525 i = MoxaPortTxQueue(port);
1526 return put_user(i, (unsigned long __user *)argp);
1527 case MOXA_GET_IQUEUE:
1528 i = MoxaPortRxQueue(port);
1529 return put_user(i, (unsigned long __user *)argp);
1530 case MOXA_GET_MAJOR:
1531 if(copy_to_user(argp, &ttymajor, sizeof(int)))
1532 return -EFAULT;
1533 return 0;
1534 case MOXA_GET_CUMAJOR:
1535 i = 0;
1536 if(copy_to_user(argp, &i, sizeof(int)))
1537 return -EFAULT;
1538 return 0;
1539 case MOXA_GETMSTATUS: {
1540 struct mxser_mstatus __user *argm = argp;
1541 struct mxser_mstatus tmp;
1542 struct moxa_port *p;
1543
1544 for (i = 0; i < MAX_PORTS; i++, argm++) {
1545 p = &moxa_ports[i];
1546 memset(&tmp, 0, sizeof(tmp));
1547 if (!p->chkPort) {
1548 goto copy;
1549 } else {
1550 status = MoxaPortLineStatus(p->port);
1551 if (status & 1)
1552 tmp.cts = 1;
1553 if (status & 2)
1554 tmp.dsr = 1;
1555 if (status & 4)
1556 tmp.dcd = 1;
1557 }
1558
1559 if (!p->tty || !p->tty->termios)
1560 tmp.cflag = p->cflag;
1561 else
1562 tmp.cflag = p->tty->termios->c_cflag;
1563copy:
1564 if (copy_to_user(argm, &tmp, sizeof(tmp)))
1565 return -EFAULT;
1566 }
1567 return 0;
1568 } default:
1569 return (-ENOIOCTLCMD);
1570 case MOXA_LOAD_BIOS:
1571 case MOXA_FIND_BOARD:
1572 case MOXA_LOAD_C320B:
1573 case MOXA_LOAD_CODE:
1574 if (!capable(CAP_SYS_RAWIO))
1575 return -EPERM;
1576 break;
1577 }
1578
1579 if(copy_from_user(&dltmp, argp, sizeof(struct dl_str)))
1580 return -EFAULT;
1581 if(dltmp.cardno < 0 || dltmp.cardno >= MAX_BOARDS || dltmp.len < 0)
1582 return -EINVAL;
1583
1584 switch(cmd)
1585 {
1586 case MOXA_LOAD_BIOS:
1587 i = moxaloadbios(dltmp.cardno, dltmp.buf, dltmp.len);
1588 return (i);
1589 case MOXA_FIND_BOARD:
1590 return moxafindcard(dltmp.cardno);
1591 case MOXA_LOAD_C320B:
1592 moxaload320b(dltmp.cardno, dltmp.buf, dltmp.len);
1593 default: /* to keep gcc happy */
1594 return (0);
1595 case MOXA_LOAD_CODE:
1596 i = moxaloadcode(dltmp.cardno, dltmp.buf, dltmp.len);
1597 if (i == -1)
1598 return (-EFAULT);
1599 return (i);
1600
1601 }
1602}
1603
1604int MoxaDriverPoll(void)
1605{
1606 struct moxa_board_conf *brd;
1607 register ushort temp;
1608 register int card;
1609 void __iomem *ofsAddr;
1610 void __iomem *ip;
1611 int port, p, ports;
1612
1613 if (moxaCard == 0)
1614 return (-1);
1615 for (card = 0; card < MAX_BOARDS; card++) {
1616 brd = &moxa_boards[card];
1617 if (brd->loadstat == 0)
1618 continue;
1619 if ((ports = brd->numPorts) == 0)
1620 continue;
1621 if (readb(brd->intPend) == 0xff) {
1622 ip = brd->intTable + readb(brd->intNdx);
1623 p = card * MAX_PORTS_PER_BOARD;
1624 ports <<= 1;
1625 for (port = 0; port < ports; port += 2, p++) {
1626 if ((temp = readw(ip + port)) != 0) {
1627 writew(0, ip + port);
1628 ofsAddr = moxa_ports[p].tableAddr;
1629 if (temp & IntrTx)
1630 writew(readw(ofsAddr + HostStat) & ~WakeupTx, ofsAddr + HostStat);
1631 if (temp & IntrBreak) {
1632 moxa_ports[p].breakCnt++;
1633 }
1634 if (temp & IntrLine) {
1635 if (readb(ofsAddr + FlagStat) & DCD_state) {
1636 if ((moxa_ports[p].DCDState & DCD_oldstate) == 0)
1637 moxa_ports[p].DCDState = (DCD_oldstate |
1638 DCD_changed);
1639 } else {
1640 if (moxa_ports[p].DCDState & DCD_oldstate)
1641 moxa_ports[p].DCDState = DCD_changed;
1642 }
1643 }
1644 }
1645 }
1646 writeb(0, brd->intPend);
1647 }
1648 if (moxaLowWaterChk) {
1649 p = card * MAX_PORTS_PER_BOARD;
1650 for (port = 0; port < ports; port++, p++) {
1651 if (moxa_ports[p].lowChkFlag) {
1652 moxa_ports[p].lowChkFlag = 0;
1653 ofsAddr = moxa_ports[p].tableAddr;
1654 moxa_low_water_check(ofsAddr);
1655 }
1656 }
1657 }
1658 }
1659 moxaLowWaterChk = 0;
1660 return (0);
1661}
1662
1663/*****************************************************************************
1664 * Card level function: *
1665 * 1. MoxaPortsOfCard(int cardno); *
1666 *****************************************************************************/
1667int MoxaPortsOfCard(int cardno)
1668{
1669
1670 if (moxa_boards[cardno].boardType == 0)
1671 return (0);
1672 return (moxa_boards[cardno].numPorts);
1673}
1674
1675/*****************************************************************************
1676 * Port level functions: *
1677 * 1. MoxaPortIsValid(int port); *
1678 * 2. MoxaPortEnable(int port); *
1679 * 3. MoxaPortDisable(int port); *
1680 * 4. MoxaPortGetMaxBaud(int port); *
1681 * 6. MoxaPortSetBaud(int port, long baud); *
1682 * 8. MoxaPortSetTermio(int port, unsigned char *termio); *
1683 * 9. MoxaPortGetLineOut(int port, int *dtrState, int *rtsState); *
1684 * 10. MoxaPortLineCtrl(int port, int dtrState, int rtsState); *
1685 * 11. MoxaPortFlowCtrl(int port, int rts, int cts, int rx, int tx,int xany); *
1686 * 12. MoxaPortLineStatus(int port); *
1687 * 13. MoxaPortDCDChange(int port); *
1688 * 14. MoxaPortDCDON(int port); *
1689 * 15. MoxaPortFlushData(int port, int mode); *
1690 * 16. MoxaPortWriteData(int port, unsigned char * buffer, int length); *
1691 * 17. MoxaPortReadData(int port, struct tty_struct *tty); *
1692 * 20. MoxaPortTxQueue(int port); *
1693 * 21. MoxaPortTxFree(int port); *
1694 * 22. MoxaPortRxQueue(int port); *
1695 * 24. MoxaPortTxDisable(int port); *
1696 * 25. MoxaPortTxEnable(int port); *
1697 * 27. MoxaPortResetBrkCnt(int port); *
1698 * 30. MoxaPortSendBreak(int port, int ticks); *
1699 *****************************************************************************/
1700/* 1604/*
1701 * Moxa Port Number Description: 1605 * Moxa Port Number Description:
1702 * 1606 *
@@ -1733,33 +1637,6 @@ int MoxaPortsOfCard(int cardno)
1733 * -ENOIOCTLCMD 1637 * -ENOIOCTLCMD
1734 * 1638 *
1735 * 1639 *
1736 * Function 3: Moxa driver polling process routine.
1737 * Syntax:
1738 * int MoxaDriverPoll(void);
1739 *
1740 * return: 0 ; polling O.K.
1741 * -1 : no any Moxa card.
1742 *
1743 *
1744 * Function 4: Get the ports of this card.
1745 * Syntax:
1746 * int MoxaPortsOfCard(int cardno);
1747 *
1748 * int cardno : card number (0 - 3)
1749 *
1750 * return: 0 : this card is invalid
1751 * 8/16/24/32
1752 *
1753 *
1754 * Function 5: Check this port is valid or invalid
1755 * Syntax:
1756 * int MoxaPortIsValid(int port);
1757 * int port : port number (0 - 127, ref port description)
1758 *
1759 * return: 0 : this port is invalid
1760 * 1 : this port is valid
1761 *
1762 *
1763 * Function 6: Enable this port to start Tx/Rx data. 1640 * Function 6: Enable this port to start Tx/Rx data.
1764 * Syntax: 1641 * Syntax:
1765 * void MoxaPortEnable(int port); 1642 * void MoxaPortEnable(int port);
@@ -1772,18 +1649,9 @@ int MoxaPortsOfCard(int cardno)
1772 * int port : port number (0 - 127) 1649 * int port : port number (0 - 127)
1773 * 1650 *
1774 * 1651 *
1775 * Function 8: Get the maximun available baud rate of this port.
1776 * Syntax:
1777 * long MoxaPortGetMaxBaud(int port);
1778 * int port : port number (0 - 127)
1779 *
1780 * return: 0 : this port is invalid
1781 * 38400/57600/115200 bps
1782 *
1783 *
1784 * Function 10: Setting baud rate of this port. 1652 * Function 10: Setting baud rate of this port.
1785 * Syntax: 1653 * Syntax:
1786 * long MoxaPortSetBaud(int port, long baud); 1654 * speed_t MoxaPortSetBaud(int port, speed_t baud);
1787 * int port : port number (0 - 127) 1655 * int port : port number (0 - 127)
1788 * long baud : baud rate (50 - 115200) 1656 * long baud : baud rate (50 - 115200)
1789 * 1657 *
@@ -1850,25 +1718,6 @@ int MoxaPortsOfCard(int cardno)
1850 * Bit 2 - DCD state (0: off, 1: on) 1718 * Bit 2 - DCD state (0: off, 1: on)
1851 * 1719 *
1852 * 1720 *
1853 * Function 17: Check the DCD state has changed since the last read
1854 * of this function.
1855 * Syntax:
1856 * int MoxaPortDCDChange(int port);
1857 * int port : port number (0 - 127)
1858 *
1859 * return: 0 : no changed
1860 * 1 : DCD has changed
1861 *
1862 *
1863 * Function 18: Check ths current DCD state is ON or not.
1864 * Syntax:
1865 * int MoxaPortDCDON(int port);
1866 * int port : port number (0 - 127)
1867 *
1868 * return: 0 : DCD off
1869 * 1 : DCD on
1870 *
1871 *
1872 * Function 19: Flush the Rx/Tx buffer data of this port. 1721 * Function 19: Flush the Rx/Tx buffer data of this port.
1873 * Syntax: 1722 * Syntax:
1874 * void MoxaPortFlushData(int port, int mode); 1723 * void MoxaPortFlushData(int port, int mode);
@@ -1942,40 +1791,20 @@ int MoxaPortsOfCard(int cardno)
1942 * return: 0 - .. : BREAK signal count 1791 * return: 0 - .. : BREAK signal count
1943 * 1792 *
1944 * 1793 *
1945 * Function 34: Send out a BREAK signal.
1946 * Syntax:
1947 * void MoxaPortSendBreak(int port, int ms100);
1948 * int port : port number (0 - 127)
1949 * int ms100 : break signal time interval.
1950 * unit: 100 mini-second. if ms100 == 0, it will
1951 * send out a about 250 ms BREAK signal.
1952 *
1953 */ 1794 */
1954int MoxaPortIsValid(int port)
1955{
1956
1957 if (moxaCard == 0)
1958 return (0);
1959 if (moxa_ports[port].chkPort == 0)
1960 return (0);
1961 return (1);
1962}
1963 1795
1964void MoxaPortEnable(int port) 1796static void MoxaPortEnable(struct moxa_port *port)
1965{ 1797{
1966 void __iomem *ofsAddr; 1798 void __iomem *ofsAddr;
1967 int MoxaPortLineStatus(int); 1799 u16 lowwater = 512;
1968 short lowwater = 512;
1969 1800
1970 ofsAddr = moxa_ports[port].tableAddr; 1801 ofsAddr = port->tableAddr;
1971 writew(lowwater, ofsAddr + Low_water); 1802 writew(lowwater, ofsAddr + Low_water);
1972 moxa_ports[port].breakCnt = 0; 1803 if (MOXA_IS_320(port->board))
1973 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
1974 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
1975 moxafunc(ofsAddr, FC_SetBreakIrq, 0); 1804 moxafunc(ofsAddr, FC_SetBreakIrq, 0);
1976 } else { 1805 else
1977 writew(readw(ofsAddr + HostStat) | WakeupBreak, ofsAddr + HostStat); 1806 writew(readw(ofsAddr + HostStat) | WakeupBreak,
1978 } 1807 ofsAddr + HostStat);
1979 1808
1980 moxafunc(ofsAddr, FC_SetLineIrq, Magic_code); 1809 moxafunc(ofsAddr, FC_SetLineIrq, Magic_code);
1981 moxafunc(ofsAddr, FC_FlushQueue, 2); 1810 moxafunc(ofsAddr, FC_FlushQueue, 2);
@@ -1984,9 +1813,9 @@ void MoxaPortEnable(int port)
1984 MoxaPortLineStatus(port); 1813 MoxaPortLineStatus(port);
1985} 1814}
1986 1815
1987void MoxaPortDisable(int port) 1816static void MoxaPortDisable(struct moxa_port *port)
1988{ 1817{
1989 void __iomem *ofsAddr = moxa_ports[port].tableAddr; 1818 void __iomem *ofsAddr = port->tableAddr;
1990 1819
1991 moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */ 1820 moxafunc(ofsAddr, FC_SetFlowCtl, 0); /* disable flow control */
1992 moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code); 1821 moxafunc(ofsAddr, FC_ClrLineIrq, Magic_code);
@@ -1994,49 +1823,32 @@ void MoxaPortDisable(int port)
1994 moxafunc(ofsAddr, FC_DisableCH, Magic_code); 1823 moxafunc(ofsAddr, FC_DisableCH, Magic_code);
1995} 1824}
1996 1825
1997long MoxaPortGetMaxBaud(int port) 1826static speed_t MoxaPortSetBaud(struct moxa_port *port, speed_t baud)
1998{
1999 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
2000 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI))
2001 return (460800L);
2002 else
2003 return (921600L);
2004}
2005
2006
2007long MoxaPortSetBaud(int port, long baud)
2008{ 1827{
2009 void __iomem *ofsAddr; 1828 void __iomem *ofsAddr = port->tableAddr;
2010 long max, clock; 1829 unsigned int clock, val;
2011 unsigned int val; 1830 speed_t max;
2012 1831
2013 if ((baud < 50L) || ((max = MoxaPortGetMaxBaud(port)) == 0)) 1832 max = MOXA_IS_320(port->board) ? 460800 : 921600;
2014 return (0); 1833 if (baud < 50)
2015 ofsAddr = moxa_ports[port].tableAddr; 1834 return 0;
2016 if (baud > max) 1835 if (baud > max)
2017 baud = max; 1836 baud = max;
2018 if (max == 38400L) 1837 clock = 921600;
2019 clock = 614400L; /* for 9.8304 Mhz : max. 38400 bps */
2020 else if (max == 57600L)
2021 clock = 691200L; /* for 11.0592 Mhz : max. 57600 bps */
2022 else
2023 clock = 921600L; /* for 14.7456 Mhz : max. 115200 bps */
2024 val = clock / baud; 1838 val = clock / baud;
2025 moxafunc(ofsAddr, FC_SetBaud, val); 1839 moxafunc(ofsAddr, FC_SetBaud, val);
2026 baud = clock / val; 1840 baud = clock / val;
2027 moxa_ports[port].curBaud = baud; 1841 return baud;
2028 return (baud);
2029} 1842}
2030 1843
2031int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) 1844static int MoxaPortSetTermio(struct moxa_port *port, struct ktermios *termio,
1845 speed_t baud)
2032{ 1846{
2033 void __iomem *ofsAddr; 1847 void __iomem *ofsAddr;
2034 tcflag_t cflag; 1848 tcflag_t cflag;
2035 tcflag_t mode = 0; 1849 tcflag_t mode = 0;
2036 1850
2037 if (moxa_ports[port].chkPort == 0 || termio == 0) 1851 ofsAddr = port->tableAddr;
2038 return (-1);
2039 ofsAddr = moxa_ports[port].tableAddr;
2040 cflag = termio->c_cflag; /* termio->c_cflag */ 1852 cflag = termio->c_cflag; /* termio->c_cflag */
2041 1853
2042 mode = termio->c_cflag & CSIZE; 1854 mode = termio->c_cflag & CSIZE;
@@ -2065,13 +1877,11 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
2065 } else 1877 } else
2066 mode |= MX_PARNONE; 1878 mode |= MX_PARNONE;
2067 1879
2068 moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); 1880 moxafunc(ofsAddr, FC_SetDataMode, (u16)mode);
1881
1882 if (MOXA_IS_320(port->board) && baud >= 921600)
1883 return -1;
2069 1884
2070 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) ||
2071 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
2072 if (baud >= 921600L)
2073 return (-1);
2074 }
2075 baud = MoxaPortSetBaud(port, baud); 1885 baud = MoxaPortSetBaud(port, baud);
2076 1886
2077 if (termio->c_iflag & (IXON | IXOFF | IXANY)) { 1887 if (termio->c_iflag & (IXON | IXOFF | IXANY)) {
@@ -2081,51 +1891,37 @@ int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud)
2081 moxa_wait_finish(ofsAddr); 1891 moxa_wait_finish(ofsAddr);
2082 1892
2083 } 1893 }
2084 return (baud); 1894 return baud;
2085} 1895}
2086 1896
2087int MoxaPortGetLineOut(int port, int *dtrState, int *rtsState) 1897static int MoxaPortGetLineOut(struct moxa_port *port, int *dtrState,
1898 int *rtsState)
2088{ 1899{
1900 if (dtrState)
1901 *dtrState = !!(port->lineCtrl & DTR_ON);
1902 if (rtsState)
1903 *rtsState = !!(port->lineCtrl & RTS_ON);
2089 1904
2090 if (!MoxaPortIsValid(port)) 1905 return 0;
2091 return (-1);
2092 if (dtrState) {
2093 if (moxa_ports[port].lineCtrl & DTR_ON)
2094 *dtrState = 1;
2095 else
2096 *dtrState = 0;
2097 }
2098 if (rtsState) {
2099 if (moxa_ports[port].lineCtrl & RTS_ON)
2100 *rtsState = 1;
2101 else
2102 *rtsState = 0;
2103 }
2104 return (0);
2105} 1906}
2106 1907
2107void MoxaPortLineCtrl(int port, int dtr, int rts) 1908static void MoxaPortLineCtrl(struct moxa_port *port, int dtr, int rts)
2108{ 1909{
2109 void __iomem *ofsAddr; 1910 u8 mode = 0;
2110 int mode;
2111 1911
2112 ofsAddr = moxa_ports[port].tableAddr;
2113 mode = 0;
2114 if (dtr) 1912 if (dtr)
2115 mode |= DTR_ON; 1913 mode |= DTR_ON;
2116 if (rts) 1914 if (rts)
2117 mode |= RTS_ON; 1915 mode |= RTS_ON;
2118 moxa_ports[port].lineCtrl = mode; 1916 port->lineCtrl = mode;
2119 moxafunc(ofsAddr, FC_LineControl, mode); 1917 moxafunc(port->tableAddr, FC_LineControl, mode);
2120} 1918}
2121 1919
2122void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int txany) 1920static void MoxaPortFlowCtrl(struct moxa_port *port, int rts, int cts,
1921 int txflow, int rxflow, int txany)
2123{ 1922{
2124 void __iomem *ofsAddr; 1923 int mode = 0;
2125 int mode;
2126 1924
2127 ofsAddr = moxa_ports[port].tableAddr;
2128 mode = 0;
2129 if (rts) 1925 if (rts)
2130 mode |= RTS_FlowCtl; 1926 mode |= RTS_FlowCtl;
2131 if (cts) 1927 if (cts)
@@ -2136,81 +1932,50 @@ void MoxaPortFlowCtrl(int port, int rts, int cts, int txflow, int rxflow, int tx
2136 mode |= Rx_FlowCtl; 1932 mode |= Rx_FlowCtl;
2137 if (txany) 1933 if (txany)
2138 mode |= IXM_IXANY; 1934 mode |= IXM_IXANY;
2139 moxafunc(ofsAddr, FC_SetFlowCtl, mode); 1935 moxafunc(port->tableAddr, FC_SetFlowCtl, mode);
2140} 1936}
2141 1937
2142int MoxaPortLineStatus(int port) 1938static int MoxaPortLineStatus(struct moxa_port *port)
2143{ 1939{
2144 void __iomem *ofsAddr; 1940 void __iomem *ofsAddr;
2145 int val; 1941 int val;
2146 1942
2147 ofsAddr = moxa_ports[port].tableAddr; 1943 ofsAddr = port->tableAddr;
2148 if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || 1944 if (MOXA_IS_320(port->board)) {
2149 (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) {
2150 moxafunc(ofsAddr, FC_LineStatus, 0); 1945 moxafunc(ofsAddr, FC_LineStatus, 0);
2151 val = readw(ofsAddr + FuncArg); 1946 val = readw(ofsAddr + FuncArg);
2152 } else { 1947 } else {
2153 val = readw(ofsAddr + FlagStat) >> 4; 1948 val = readw(ofsAddr + FlagStat) >> 4;
2154 } 1949 }
2155 val &= 0x0B; 1950 val &= 0x0B;
2156 if (val & 8) { 1951 if (val & 8)
2157 val |= 4; 1952 val |= 4;
2158 if ((moxa_ports[port].DCDState & DCD_oldstate) == 0) 1953 spin_lock_bh(&moxa_lock);
2159 moxa_ports[port].DCDState = (DCD_oldstate | DCD_changed); 1954 moxa_new_dcdstate(port, val & 8);
2160 } else { 1955 spin_unlock_bh(&moxa_lock);
2161 if (moxa_ports[port].DCDState & DCD_oldstate)
2162 moxa_ports[port].DCDState = DCD_changed;
2163 }
2164 val &= 7; 1956 val &= 7;
2165 return (val); 1957 return val;
2166}
2167
2168int MoxaPortDCDChange(int port)
2169{
2170 int n;
2171
2172 if (moxa_ports[port].chkPort == 0)
2173 return (0);
2174 n = moxa_ports[port].DCDState;
2175 moxa_ports[port].DCDState &= ~DCD_changed;
2176 n &= DCD_changed;
2177 return (n);
2178}
2179
2180int MoxaPortDCDON(int port)
2181{
2182 int n;
2183
2184 if (moxa_ports[port].chkPort == 0)
2185 return (0);
2186 if (moxa_ports[port].DCDState & DCD_oldstate)
2187 n = 1;
2188 else
2189 n = 0;
2190 return (n);
2191} 1958}
2192 1959
2193int MoxaPortWriteData(int port, unsigned char * buffer, int len) 1960static int MoxaPortWriteData(struct moxa_port *port,
1961 const unsigned char *buffer, int len)
2194{ 1962{
2195 int c, total, i;
2196 ushort tail;
2197 int cnt;
2198 ushort head, tx_mask, spage, epage;
2199 ushort pageno, pageofs, bufhead;
2200 void __iomem *baseAddr, *ofsAddr, *ofs; 1963 void __iomem *baseAddr, *ofsAddr, *ofs;
1964 unsigned int c, total;
1965 u16 head, tail, tx_mask, spage, epage;
1966 u16 pageno, pageofs, bufhead;
2201 1967
2202 ofsAddr = moxa_ports[port].tableAddr; 1968 ofsAddr = port->tableAddr;
2203 baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; 1969 baseAddr = port->board->basemem;
2204 tx_mask = readw(ofsAddr + TX_mask); 1970 tx_mask = readw(ofsAddr + TX_mask);
2205 spage = readw(ofsAddr + Page_txb); 1971 spage = readw(ofsAddr + Page_txb);
2206 epage = readw(ofsAddr + EndPage_txb); 1972 epage = readw(ofsAddr + EndPage_txb);
2207 tail = readw(ofsAddr + TXwptr); 1973 tail = readw(ofsAddr + TXwptr);
2208 head = readw(ofsAddr + TXrptr); 1974 head = readw(ofsAddr + TXrptr);
2209 c = (head > tail) ? (head - tail - 1) 1975 c = (head > tail) ? (head - tail - 1) : (head - tail + tx_mask);
2210 : (head - tail + tx_mask);
2211 if (c > len) 1976 if (c > len)
2212 c = len; 1977 c = len;
2213 moxaLog.txcnt[port] += c; 1978 moxaLog.txcnt[port->tty->index] += c;
2214 total = c; 1979 total = c;
2215 if (spage == epage) { 1980 if (spage == epage) {
2216 bufhead = readw(ofsAddr + Ofs_txb); 1981 bufhead = readw(ofsAddr + Ofs_txb);
@@ -2222,249 +1987,179 @@ int MoxaPortWriteData(int port, unsigned char * buffer, int len)
2222 len = tx_mask + 1 - tail; 1987 len = tx_mask + 1 - tail;
2223 len = (c > len) ? len : c; 1988 len = (c > len) ? len : c;
2224 ofs = baseAddr + DynPage_addr + bufhead + tail; 1989 ofs = baseAddr + DynPage_addr + bufhead + tail;
2225 for (i = 0; i < len; i++) 1990 memcpy_toio(ofs, buffer, len);
2226 writeb(*buffer++, ofs + i); 1991 buffer += len;
2227 tail = (tail + len) & tx_mask; 1992 tail = (tail + len) & tx_mask;
2228 c -= len; 1993 c -= len;
2229 } 1994 }
2230 writew(tail, ofsAddr + TXwptr);
2231 } else { 1995 } else {
2232 len = c;
2233 pageno = spage + (tail >> 13); 1996 pageno = spage + (tail >> 13);
2234 pageofs = tail & Page_mask; 1997 pageofs = tail & Page_mask;
2235 do { 1998 while (c > 0) {
2236 cnt = Page_size - pageofs; 1999 len = Page_size - pageofs;
2237 if (cnt > c) 2000 if (len > c)
2238 cnt = c; 2001 len = c;
2239 c -= cnt;
2240 writeb(pageno, baseAddr + Control_reg); 2002 writeb(pageno, baseAddr + Control_reg);
2241 ofs = baseAddr + DynPage_addr + pageofs; 2003 ofs = baseAddr + DynPage_addr + pageofs;
2242 for (i = 0; i < cnt; i++) 2004 memcpy_toio(ofs, buffer, len);
2243 writeb(*buffer++, ofs + i); 2005 buffer += len;
2244 if (c == 0) {
2245 writew((tail + len) & tx_mask, ofsAddr + TXwptr);
2246 break;
2247 }
2248 if (++pageno == epage) 2006 if (++pageno == epage)
2249 pageno = spage; 2007 pageno = spage;
2250 pageofs = 0; 2008 pageofs = 0;
2251 } while (1); 2009 c -= len;
2010 }
2011 tail = (tail + total) & tx_mask;
2252 } 2012 }
2013 writew(tail, ofsAddr + TXwptr);
2253 writeb(1, ofsAddr + CD180TXirq); /* start to send */ 2014 writeb(1, ofsAddr + CD180TXirq); /* start to send */
2254 return (total); 2015 return total;
2255} 2016}
2256 2017
2257int MoxaPortReadData(int port, struct tty_struct *tty) 2018static int MoxaPortReadData(struct moxa_port *port)
2258{ 2019{
2259 register ushort head, pageofs; 2020 struct tty_struct *tty = port->tty;
2260 int i, count, cnt, len, total, remain; 2021 unsigned char *dst;
2261 ushort tail, rx_mask, spage, epage;
2262 ushort pageno, bufhead;
2263 void __iomem *baseAddr, *ofsAddr, *ofs; 2022 void __iomem *baseAddr, *ofsAddr, *ofs;
2023 unsigned int count, len, total;
2024 u16 tail, rx_mask, spage, epage;
2025 u16 pageno, pageofs, bufhead, head;
2264 2026
2265 ofsAddr = moxa_ports[port].tableAddr; 2027 ofsAddr = port->tableAddr;
2266 baseAddr = moxa_boards[port / MAX_PORTS_PER_BOARD].basemem; 2028 baseAddr = port->board->basemem;
2267 head = readw(ofsAddr + RXrptr); 2029 head = readw(ofsAddr + RXrptr);
2268 tail = readw(ofsAddr + RXwptr); 2030 tail = readw(ofsAddr + RXwptr);
2269 rx_mask = readw(ofsAddr + RX_mask); 2031 rx_mask = readw(ofsAddr + RX_mask);
2270 spage = readw(ofsAddr + Page_rxb); 2032 spage = readw(ofsAddr + Page_rxb);
2271 epage = readw(ofsAddr + EndPage_rxb); 2033 epage = readw(ofsAddr + EndPage_rxb);
2272 count = (tail >= head) ? (tail - head) 2034 count = (tail >= head) ? (tail - head) : (tail - head + rx_mask + 1);
2273 : (tail - head + rx_mask + 1);
2274 if (count == 0) 2035 if (count == 0)
2275 return 0; 2036 return 0;
2276 2037
2277 total = count; 2038 total = count;
2278 remain = count - total; 2039 moxaLog.rxcnt[tty->index] += total;
2279 moxaLog.rxcnt[port] += total;
2280 count = total;
2281 if (spage == epage) { 2040 if (spage == epage) {
2282 bufhead = readw(ofsAddr + Ofs_rxb); 2041 bufhead = readw(ofsAddr + Ofs_rxb);
2283 writew(spage, baseAddr + Control_reg); 2042 writew(spage, baseAddr + Control_reg);
2284 while (count > 0) { 2043 while (count > 0) {
2285 if (tail >= head)
2286 len = tail - head;
2287 else
2288 len = rx_mask + 1 - head;
2289 len = (count > len) ? len : count;
2290 ofs = baseAddr + DynPage_addr + bufhead + head; 2044 ofs = baseAddr + DynPage_addr + bufhead + head;
2291 for (i = 0; i < len; i++) 2045 len = (tail >= head) ? (tail - head) :
2292 tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL); 2046 (rx_mask + 1 - head);
2047 len = tty_prepare_flip_string(tty, &dst,
2048 min(len, count));
2049 memcpy_fromio(dst, ofs, len);
2293 head = (head + len) & rx_mask; 2050 head = (head + len) & rx_mask;
2294 count -= len; 2051 count -= len;
2295 } 2052 }
2296 writew(head, ofsAddr + RXrptr);
2297 } else { 2053 } else {
2298 len = count;
2299 pageno = spage + (head >> 13); 2054 pageno = spage + (head >> 13);
2300 pageofs = head & Page_mask; 2055 pageofs = head & Page_mask;
2301 do { 2056 while (count > 0) {
2302 cnt = Page_size - pageofs;
2303 if (cnt > count)
2304 cnt = count;
2305 count -= cnt;
2306 writew(pageno, baseAddr + Control_reg); 2057 writew(pageno, baseAddr + Control_reg);
2307 ofs = baseAddr + DynPage_addr + pageofs; 2058 ofs = baseAddr + DynPage_addr + pageofs;
2308 for (i = 0; i < cnt; i++) 2059 len = tty_prepare_flip_string(tty, &dst,
2309 tty_insert_flip_char(tty, readb(ofs + i), TTY_NORMAL); 2060 min(Page_size - pageofs, count));
2310 if (count == 0) { 2061 memcpy_fromio(dst, ofs, len);
2311 writew((head + len) & rx_mask, ofsAddr + RXrptr); 2062
2312 break; 2063 count -= len;
2313 } 2064 pageofs = (pageofs + len) & Page_mask;
2314 if (++pageno == epage) 2065 if (pageofs == 0 && ++pageno == epage)
2315 pageno = spage; 2066 pageno = spage;
2316 pageofs = 0; 2067 }
2317 } while (1); 2068 head = (head + total) & rx_mask;
2318 } 2069 }
2319 if ((readb(ofsAddr + FlagStat) & Xoff_state) && (remain < LowWater)) { 2070 writew(head, ofsAddr + RXrptr);
2071 if (readb(ofsAddr + FlagStat) & Xoff_state) {
2320 moxaLowWaterChk = 1; 2072 moxaLowWaterChk = 1;
2321 moxa_ports[port].lowChkFlag = 1; 2073 port->lowChkFlag = 1;
2322 } 2074 }
2323 return (total); 2075 return total;
2324} 2076}
2325 2077
2326 2078
2327int MoxaPortTxQueue(int port) 2079static int MoxaPortTxQueue(struct moxa_port *port)
2328{ 2080{
2329 void __iomem *ofsAddr; 2081 void __iomem *ofsAddr = port->tableAddr;
2330 ushort rptr, wptr, mask; 2082 u16 rptr, wptr, mask;
2331 int len;
2332 2083
2333 ofsAddr = moxa_ports[port].tableAddr;
2334 rptr = readw(ofsAddr + TXrptr); 2084 rptr = readw(ofsAddr + TXrptr);
2335 wptr = readw(ofsAddr + TXwptr); 2085 wptr = readw(ofsAddr + TXwptr);
2336 mask = readw(ofsAddr + TX_mask); 2086 mask = readw(ofsAddr + TX_mask);
2337 len = (wptr - rptr) & mask; 2087 return (wptr - rptr) & mask;
2338 return (len);
2339} 2088}
2340 2089
2341int MoxaPortTxFree(int port) 2090static int MoxaPortTxFree(struct moxa_port *port)
2342{ 2091{
2343 void __iomem *ofsAddr; 2092 void __iomem *ofsAddr = port->tableAddr;
2344 ushort rptr, wptr, mask; 2093 u16 rptr, wptr, mask;
2345 int len;
2346 2094
2347 ofsAddr = moxa_ports[port].tableAddr;
2348 rptr = readw(ofsAddr + TXrptr); 2095 rptr = readw(ofsAddr + TXrptr);
2349 wptr = readw(ofsAddr + TXwptr); 2096 wptr = readw(ofsAddr + TXwptr);
2350 mask = readw(ofsAddr + TX_mask); 2097 mask = readw(ofsAddr + TX_mask);
2351 len = mask - ((wptr - rptr) & mask); 2098 return mask - ((wptr - rptr) & mask);
2352 return (len);
2353} 2099}
2354 2100
2355int MoxaPortRxQueue(int port) 2101static int MoxaPortRxQueue(struct moxa_port *port)
2356{ 2102{
2357 void __iomem *ofsAddr; 2103 void __iomem *ofsAddr = port->tableAddr;
2358 ushort rptr, wptr, mask; 2104 u16 rptr, wptr, mask;
2359 int len;
2360 2105
2361 ofsAddr = moxa_ports[port].tableAddr;
2362 rptr = readw(ofsAddr + RXrptr); 2106 rptr = readw(ofsAddr + RXrptr);
2363 wptr = readw(ofsAddr + RXwptr); 2107 wptr = readw(ofsAddr + RXwptr);
2364 mask = readw(ofsAddr + RX_mask); 2108 mask = readw(ofsAddr + RX_mask);
2365 len = (wptr - rptr) & mask; 2109 return (wptr - rptr) & mask;
2366 return (len);
2367} 2110}
2368 2111
2369 2112static void MoxaPortTxDisable(struct moxa_port *port)
2370void MoxaPortTxDisable(int port)
2371{ 2113{
2372 void __iomem *ofsAddr; 2114 moxafunc(port->tableAddr, FC_SetXoffState, Magic_code);
2373
2374 ofsAddr = moxa_ports[port].tableAddr;
2375 moxafunc(ofsAddr, FC_SetXoffState, Magic_code);
2376} 2115}
2377 2116
2378void MoxaPortTxEnable(int port) 2117static void MoxaPortTxEnable(struct moxa_port *port)
2379{ 2118{
2380 void __iomem *ofsAddr; 2119 moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
2381
2382 ofsAddr = moxa_ports[port].tableAddr;
2383 moxafunc(ofsAddr, FC_SetXonState, Magic_code);
2384}
2385
2386
2387int MoxaPortResetBrkCnt(int port)
2388{
2389 ushort cnt;
2390 cnt = moxa_ports[port].breakCnt;
2391 moxa_ports[port].breakCnt = 0;
2392 return (cnt);
2393}
2394
2395
2396void MoxaPortSendBreak(int port, int ms100)
2397{
2398 void __iomem *ofsAddr;
2399
2400 ofsAddr = moxa_ports[port].tableAddr;
2401 if (ms100) {
2402 moxafunc(ofsAddr, FC_SendBreak, Magic_code);
2403 msleep(ms100 * 10);
2404 } else {
2405 moxafunc(ofsAddr, FC_SendBreak, Magic_code);
2406 msleep(250);
2407 }
2408 moxafunc(ofsAddr, FC_StopBreak, Magic_code);
2409} 2120}
2410 2121
2411static int moxa_get_serial_info(struct moxa_port *info, 2122static int moxa_get_serial_info(struct moxa_port *info,
2412 struct serial_struct __user *retinfo) 2123 struct serial_struct __user *retinfo)
2413{ 2124{
2414 struct serial_struct tmp; 2125 struct serial_struct tmp = {
2415 2126 .type = info->type,
2416 memset(&tmp, 0, sizeof(tmp)); 2127 .line = info->tty->index,
2417 tmp.type = info->type; 2128 .flags = info->asyncflags,
2418 tmp.line = info->port; 2129 .baud_base = 921600,
2419 tmp.port = 0; 2130 .close_delay = info->close_delay
2420 tmp.irq = 0; 2131 };
2421 tmp.flags = info->asyncflags; 2132 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
2422 tmp.baud_base = 921600;
2423 tmp.close_delay = info->close_delay;
2424 tmp.closing_wait = info->closing_wait;
2425 tmp.custom_divisor = 0;
2426 tmp.hub6 = 0;
2427 if(copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2428 return -EFAULT;
2429 return (0);
2430} 2133}
2431 2134
2432 2135
2433static int moxa_set_serial_info(struct moxa_port *info, 2136static int moxa_set_serial_info(struct moxa_port *info,
2434 struct serial_struct __user *new_info) 2137 struct serial_struct __user *new_info)
2435{ 2138{
2436 struct serial_struct new_serial; 2139 struct serial_struct new_serial;
2437 2140
2438 if(copy_from_user(&new_serial, new_info, sizeof(new_serial))) 2141 if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
2439 return -EFAULT; 2142 return -EFAULT;
2440 2143
2441 if ((new_serial.irq != 0) || 2144 if (new_serial.irq != 0 || new_serial.port != 0 ||
2442 (new_serial.port != 0) || 2145 new_serial.custom_divisor != 0 ||
2443// (new_serial.type != info->type) || 2146 new_serial.baud_base != 921600)
2444 (new_serial.custom_divisor != 0) || 2147 return -EPERM;
2445 (new_serial.baud_base != 921600))
2446 return (-EPERM);
2447 2148
2448 if (!capable(CAP_SYS_ADMIN)) { 2149 if (!capable(CAP_SYS_ADMIN)) {
2449 if (((new_serial.flags & ~ASYNC_USR_MASK) != 2150 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
2450 (info->asyncflags & ~ASYNC_USR_MASK))) 2151 (info->asyncflags & ~ASYNC_USR_MASK)))
2451 return (-EPERM); 2152 return -EPERM;
2452 } else { 2153 } else
2453 info->close_delay = new_serial.close_delay * HZ / 100; 2154 info->close_delay = new_serial.close_delay * HZ / 100;
2454 info->closing_wait = new_serial.closing_wait * HZ / 100;
2455 }
2456 2155
2457 new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS); 2156 new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
2458 new_serial.flags |= (info->asyncflags & ASYNC_FLAGS); 2157 new_serial.flags |= (info->asyncflags & ASYNC_FLAGS);
2459 2158
2460 if (new_serial.type == PORT_16550A) { 2159 MoxaSetFifo(info, new_serial.type == PORT_16550A);
2461 MoxaSetFifo(info->port, 1);
2462 } else {
2463 MoxaSetFifo(info->port, 0);
2464 }
2465 2160
2466 info->type = new_serial.type; 2161 info->type = new_serial.type;
2467 return (0); 2162 return 0;
2468} 2163}
2469 2164
2470 2165
@@ -2472,374 +2167,10 @@ static int moxa_set_serial_info(struct moxa_port *info,
2472/***************************************************************************** 2167/*****************************************************************************
2473 * Static local functions: * 2168 * Static local functions: *
2474 *****************************************************************************/ 2169 *****************************************************************************/
2475static void moxafunc(void __iomem *ofsAddr, int cmd, ushort arg)
2476{
2477
2478 writew(arg, ofsAddr + FuncArg);
2479 writew(cmd, ofsAddr + FuncCode);
2480 moxa_wait_finish(ofsAddr);
2481}
2482
2483static void moxa_wait_finish(void __iomem *ofsAddr)
2484{
2485 unsigned long i, j;
2486
2487 i = jiffies;
2488 while (readw(ofsAddr + FuncCode) != 0) {
2489 j = jiffies;
2490 if ((j - i) > moxaFuncTout) {
2491 return;
2492 }
2493 }
2494}
2495
2496static void moxa_low_water_check(void __iomem *ofsAddr)
2497{
2498 int len;
2499 ushort rptr, wptr, mask;
2500
2501 if (readb(ofsAddr + FlagStat) & Xoff_state) {
2502 rptr = readw(ofsAddr + RXrptr);
2503 wptr = readw(ofsAddr + RXwptr);
2504 mask = readw(ofsAddr + RX_mask);
2505 len = (wptr - rptr) & mask;
2506 if (len <= Low_water)
2507 moxafunc(ofsAddr, FC_SendXon, 0);
2508 }
2509}
2510
2511static int moxaloadbios(int cardno, unsigned char __user *tmp, int len)
2512{
2513 void __iomem *baseAddr;
2514 int i;
2515
2516 if(len < 0 || len > sizeof(moxaBuff))
2517 return -EINVAL;
2518 if(copy_from_user(moxaBuff, tmp, len))
2519 return -EFAULT;
2520 baseAddr = moxa_boards[cardno].basemem;
2521 writeb(HW_reset, baseAddr + Control_reg); /* reset */
2522 msleep(10);
2523 for (i = 0; i < 4096; i++)
2524 writeb(0, baseAddr + i); /* clear fix page */
2525 for (i = 0; i < len; i++)
2526 writeb(moxaBuff[i], baseAddr + i); /* download BIOS */
2527 writeb(0, baseAddr + Control_reg); /* restart */
2528 return (0);
2529}
2530
2531static int moxafindcard(int cardno)
2532{
2533 void __iomem *baseAddr;
2534 ushort tmp;
2535
2536 baseAddr = moxa_boards[cardno].basemem;
2537 switch (moxa_boards[cardno].boardType) {
2538 case MOXA_BOARD_C218_ISA:
2539 case MOXA_BOARD_C218_PCI:
2540 if ((tmp = readw(baseAddr + C218_key)) != C218_KeyCode) {
2541 return (-1);
2542 }
2543 break;
2544 case MOXA_BOARD_CP204J:
2545 if ((tmp = readw(baseAddr + C218_key)) != CP204J_KeyCode) {
2546 return (-1);
2547 }
2548 break;
2549 default:
2550 if ((tmp = readw(baseAddr + C320_key)) != C320_KeyCode) {
2551 return (-1);
2552 }
2553 if ((tmp = readw(baseAddr + C320_status)) != STS_init) {
2554 return (-2);
2555 }
2556 }
2557 return (0);
2558}
2559
2560static int moxaload320b(int cardno, unsigned char __user *tmp, int len)
2561{
2562 void __iomem *baseAddr;
2563 int i;
2564
2565 if(len < 0 || len > sizeof(moxaBuff))
2566 return -EINVAL;
2567 if(copy_from_user(moxaBuff, tmp, len))
2568 return -EFAULT;
2569 baseAddr = moxa_boards[cardno].basemem;
2570 writew(len - 7168 - 2, baseAddr + C320bapi_len);
2571 writeb(1, baseAddr + Control_reg); /* Select Page 1 */
2572 for (i = 0; i < 7168; i++)
2573 writeb(moxaBuff[i], baseAddr + DynPage_addr + i);
2574 writeb(2, baseAddr + Control_reg); /* Select Page 2 */
2575 for (i = 0; i < (len - 7168); i++)
2576 writeb(moxaBuff[i + 7168], baseAddr + DynPage_addr + i);
2577 return (0);
2578}
2579
2580static int moxaloadcode(int cardno, unsigned char __user *tmp, int len)
2581{
2582 void __iomem *baseAddr, *ofsAddr;
2583 int retval, port, i;
2584
2585 if(len < 0 || len > sizeof(moxaBuff))
2586 return -EINVAL;
2587 if(copy_from_user(moxaBuff, tmp, len))
2588 return -EFAULT;
2589 baseAddr = moxa_boards[cardno].basemem;
2590 switch (moxa_boards[cardno].boardType) {
2591 case MOXA_BOARD_C218_ISA:
2592 case MOXA_BOARD_C218_PCI:
2593 case MOXA_BOARD_CP204J:
2594 retval = moxaloadc218(cardno, baseAddr, len);
2595 if (retval)
2596 return (retval);
2597 port = cardno * MAX_PORTS_PER_BOARD;
2598 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
2599 struct moxa_port *p = &moxa_ports[port];
2600
2601 p->chkPort = 1;
2602 p->curBaud = 9600L;
2603 p->DCDState = 0;
2604 p->tableAddr = baseAddr + Extern_table + Extern_size * i;
2605 ofsAddr = p->tableAddr;
2606 writew(C218rx_mask, ofsAddr + RX_mask);
2607 writew(C218tx_mask, ofsAddr + TX_mask);
2608 writew(C218rx_spage + i * C218buf_pageno, ofsAddr + Page_rxb);
2609 writew(readw(ofsAddr + Page_rxb) + C218rx_pageno, ofsAddr + EndPage_rxb);
2610
2611 writew(C218tx_spage + i * C218buf_pageno, ofsAddr + Page_txb);
2612 writew(readw(ofsAddr + Page_txb) + C218tx_pageno, ofsAddr + EndPage_txb);
2613
2614 }
2615 break;
2616 default:
2617 retval = moxaloadc320(cardno, baseAddr, len,
2618 &moxa_boards[cardno].numPorts);
2619 if (retval)
2620 return (retval);
2621 port = cardno * MAX_PORTS_PER_BOARD;
2622 for (i = 0; i < moxa_boards[cardno].numPorts; i++, port++) {
2623 struct moxa_port *p = &moxa_ports[port];
2624
2625 p->chkPort = 1;
2626 p->curBaud = 9600L;
2627 p->DCDState = 0;
2628 p->tableAddr = baseAddr + Extern_table + Extern_size * i;
2629 ofsAddr = p->tableAddr;
2630 if (moxa_boards[cardno].numPorts == 8) {
2631 writew(C320p8rx_mask, ofsAddr + RX_mask);
2632 writew(C320p8tx_mask, ofsAddr + TX_mask);
2633 writew(C320p8rx_spage + i * C320p8buf_pgno, ofsAddr + Page_rxb);
2634 writew(readw(ofsAddr + Page_rxb) + C320p8rx_pgno, ofsAddr + EndPage_rxb);
2635 writew(C320p8tx_spage + i * C320p8buf_pgno, ofsAddr + Page_txb);
2636 writew(readw(ofsAddr + Page_txb) + C320p8tx_pgno, ofsAddr + EndPage_txb);
2637
2638 } else if (moxa_boards[cardno].numPorts == 16) {
2639 writew(C320p16rx_mask, ofsAddr + RX_mask);
2640 writew(C320p16tx_mask, ofsAddr + TX_mask);
2641 writew(C320p16rx_spage + i * C320p16buf_pgno, ofsAddr + Page_rxb);
2642 writew(readw(ofsAddr + Page_rxb) + C320p16rx_pgno, ofsAddr + EndPage_rxb);
2643 writew(C320p16tx_spage + i * C320p16buf_pgno, ofsAddr + Page_txb);
2644 writew(readw(ofsAddr + Page_txb) + C320p16tx_pgno, ofsAddr + EndPage_txb);
2645
2646 } else if (moxa_boards[cardno].numPorts == 24) {
2647 writew(C320p24rx_mask, ofsAddr + RX_mask);
2648 writew(C320p24tx_mask, ofsAddr + TX_mask);
2649 writew(C320p24rx_spage + i * C320p24buf_pgno, ofsAddr + Page_rxb);
2650 writew(readw(ofsAddr + Page_rxb) + C320p24rx_pgno, ofsAddr + EndPage_rxb);
2651 writew(C320p24tx_spage + i * C320p24buf_pgno, ofsAddr + Page_txb);
2652 writew(readw(ofsAddr + Page_txb), ofsAddr + EndPage_txb);
2653 } else if (moxa_boards[cardno].numPorts == 32) {
2654 writew(C320p32rx_mask, ofsAddr + RX_mask);
2655 writew(C320p32tx_mask, ofsAddr + TX_mask);
2656 writew(C320p32tx_ofs, ofsAddr + Ofs_txb);
2657 writew(C320p32rx_spage + i * C320p32buf_pgno, ofsAddr + Page_rxb);
2658 writew(readb(ofsAddr + Page_rxb), ofsAddr + EndPage_rxb);
2659 writew(C320p32tx_spage + i * C320p32buf_pgno, ofsAddr + Page_txb);
2660 writew(readw(ofsAddr + Page_txb), ofsAddr + EndPage_txb);
2661 }
2662 }
2663 break;
2664 }
2665 moxa_boards[cardno].loadstat = 1;
2666 return (0);
2667}
2668
2669static int moxaloadc218(int cardno, void __iomem *baseAddr, int len)
2670{
2671 char retry;
2672 int i, j, len1, len2;
2673 ushort usum, *ptr, keycode;
2674
2675 if (moxa_boards[cardno].boardType == MOXA_BOARD_CP204J)
2676 keycode = CP204J_KeyCode;
2677 else
2678 keycode = C218_KeyCode;
2679 usum = 0;
2680 len1 = len >> 1;
2681 ptr = (ushort *) moxaBuff;
2682 for (i = 0; i < len1; i++)
2683 usum += le16_to_cpu(*(ptr + i));
2684 retry = 0;
2685 do {
2686 len1 = len >> 1;
2687 j = 0;
2688 while (len1) {
2689 len2 = (len1 > 2048) ? 2048 : len1;
2690 len1 -= len2;
2691 for (i = 0; i < len2 << 1; i++)
2692 writeb(moxaBuff[i + j], baseAddr + C218_LoadBuf + i);
2693 j += i;
2694
2695 writew(len2, baseAddr + C218DLoad_len);
2696 writew(0, baseAddr + C218_key);
2697 for (i = 0; i < 100; i++) {
2698 if (readw(baseAddr + C218_key) == keycode)
2699 break;
2700 msleep(10);
2701 }
2702 if (readw(baseAddr + C218_key) != keycode) {
2703 return (-1);
2704 }
2705 }
2706 writew(0, baseAddr + C218DLoad_len);
2707 writew(usum, baseAddr + C218check_sum);
2708 writew(0, baseAddr + C218_key);
2709 for (i = 0; i < 100; i++) {
2710 if (readw(baseAddr + C218_key) == keycode)
2711 break;
2712 msleep(10);
2713 }
2714 retry++;
2715 } while ((readb(baseAddr + C218chksum_ok) != 1) && (retry < 3));
2716 if (readb(baseAddr + C218chksum_ok) != 1) {
2717 return (-1);
2718 }
2719 writew(0, baseAddr + C218_key);
2720 for (i = 0; i < 100; i++) {
2721 if (readw(baseAddr + Magic_no) == Magic_code)
2722 break;
2723 msleep(10);
2724 }
2725 if (readw(baseAddr + Magic_no) != Magic_code) {
2726 return (-1);
2727 }
2728 writew(1, baseAddr + Disable_IRQ);
2729 writew(0, baseAddr + Magic_no);
2730 for (i = 0; i < 100; i++) {
2731 if (readw(baseAddr + Magic_no) == Magic_code)
2732 break;
2733 msleep(10);
2734 }
2735 if (readw(baseAddr + Magic_no) != Magic_code) {
2736 return (-1);
2737 }
2738 moxaCard = 1;
2739 moxa_boards[cardno].intNdx = baseAddr + IRQindex;
2740 moxa_boards[cardno].intPend = baseAddr + IRQpending;
2741 moxa_boards[cardno].intTable = baseAddr + IRQtable;
2742 return (0);
2743}
2744
2745static int moxaloadc320(int cardno, void __iomem *baseAddr, int len, int *numPorts)
2746{
2747 ushort usum;
2748 int i, j, wlen, len2, retry;
2749 ushort *uptr;
2750
2751 usum = 0;
2752 wlen = len >> 1;
2753 uptr = (ushort *) moxaBuff;
2754 for (i = 0; i < wlen; i++)
2755 usum += le16_to_cpu(uptr[i]);
2756 retry = 0;
2757 j = 0;
2758 do {
2759 while (wlen) {
2760 if (wlen > 2048)
2761 len2 = 2048;
2762 else
2763 len2 = wlen;
2764 wlen -= len2;
2765 len2 <<= 1;
2766 for (i = 0; i < len2; i++)
2767 writeb(moxaBuff[j + i], baseAddr + C320_LoadBuf + i);
2768 len2 >>= 1;
2769 j += i;
2770 writew(len2, baseAddr + C320DLoad_len);
2771 writew(0, baseAddr + C320_key);
2772 for (i = 0; i < 10; i++) {
2773 if (readw(baseAddr + C320_key) == C320_KeyCode)
2774 break;
2775 msleep(10);
2776 }
2777 if (readw(baseAddr + C320_key) != C320_KeyCode)
2778 return (-1);
2779 }
2780 writew(0, baseAddr + C320DLoad_len);
2781 writew(usum, baseAddr + C320check_sum);
2782 writew(0, baseAddr + C320_key);
2783 for (i = 0; i < 10; i++) {
2784 if (readw(baseAddr + C320_key) == C320_KeyCode)
2785 break;
2786 msleep(10);
2787 }
2788 retry++;
2789 } while ((readb(baseAddr + C320chksum_ok) != 1) && (retry < 3));
2790 if (readb(baseAddr + C320chksum_ok) != 1)
2791 return (-1);
2792 writew(0, baseAddr + C320_key);
2793 for (i = 0; i < 600; i++) {
2794 if (readw(baseAddr + Magic_no) == Magic_code)
2795 break;
2796 msleep(10);
2797 }
2798 if (readw(baseAddr + Magic_no) != Magic_code)
2799 return (-100);
2800
2801 if (moxa_boards[cardno].busType == MOXA_BUS_TYPE_PCI) { /* ASIC board */
2802 writew(0x3800, baseAddr + TMS320_PORT1);
2803 writew(0x3900, baseAddr + TMS320_PORT2);
2804 writew(28499, baseAddr + TMS320_CLOCK);
2805 } else {
2806 writew(0x3200, baseAddr + TMS320_PORT1);
2807 writew(0x3400, baseAddr + TMS320_PORT2);
2808 writew(19999, baseAddr + TMS320_CLOCK);
2809 }
2810 writew(1, baseAddr + Disable_IRQ);
2811 writew(0, baseAddr + Magic_no);
2812 for (i = 0; i < 500; i++) {
2813 if (readw(baseAddr + Magic_no) == Magic_code)
2814 break;
2815 msleep(10);
2816 }
2817 if (readw(baseAddr + Magic_no) != Magic_code)
2818 return (-102);
2819
2820 j = readw(baseAddr + Module_cnt);
2821 if (j <= 0)
2822 return (-101);
2823 *numPorts = j * 8;
2824 writew(j, baseAddr + Module_no);
2825 writew(0, baseAddr + Magic_no);
2826 for (i = 0; i < 600; i++) {
2827 if (readw(baseAddr + Magic_no) == Magic_code)
2828 break;
2829 msleep(10);
2830 }
2831 if (readw(baseAddr + Magic_no) != Magic_code)
2832 return (-102);
2833 moxaCard = 1;
2834 moxa_boards[cardno].intNdx = baseAddr + IRQindex;
2835 moxa_boards[cardno].intPend = baseAddr + IRQpending;
2836 moxa_boards[cardno].intTable = baseAddr + IRQtable;
2837 return (0);
2838}
2839 2170
2840static void MoxaSetFifo(int port, int enable) 2171static void MoxaSetFifo(struct moxa_port *port, int enable)
2841{ 2172{
2842 void __iomem *ofsAddr = moxa_ports[port].tableAddr; 2173 void __iomem *ofsAddr = port->tableAddr;
2843 2174
2844 if (!enable) { 2175 if (!enable) {
2845 moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0); 2176 moxafunc(ofsAddr, FC_SetRxFIFOTrig, 0);
diff --git a/drivers/char/moxa.h b/drivers/char/moxa.h
new file mode 100644
index 000000000000..87d16ce57be7
--- /dev/null
+++ b/drivers/char/moxa.h
@@ -0,0 +1,304 @@
1#ifndef MOXA_H_FILE
2#define MOXA_H_FILE
3
4#define MOXA 0x400
5#define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */
6#define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */
7#define MOXA_GETDATACOUNT (MOXA + 23)
8#define MOXA_GET_IOQUEUE (MOXA + 27)
9#define MOXA_FLUSH_QUEUE (MOXA + 28)
10#define MOXA_GETMSTATUS (MOXA + 65)
11
12/*
13 * System Configuration
14 */
15
16#define Magic_code 0x404
17
18/*
19 * for C218 BIOS initialization
20 */
21#define C218_ConfBase 0x800
22#define C218_status (C218_ConfBase + 0) /* BIOS running status */
23#define C218_diag (C218_ConfBase + 2) /* diagnostic status */
24#define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */
25#define C218DLoad_len (C218_ConfBase + 6) /* WORD */
26#define C218check_sum (C218_ConfBase + 8) /* BYTE */
27#define C218chksum_ok (C218_ConfBase + 0x0a) /* BYTE (1:ok) */
28#define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */
29#define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */
30#define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */
31#define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */
32
33#define C218_LoadBuf 0x0F00
34#define C218_KeyCode 0x218
35#define CP204J_KeyCode 0x204
36
37/*
38 * for C320 BIOS initialization
39 */
40#define C320_ConfBase 0x800
41#define C320_LoadBuf 0x0f00
42#define STS_init 0x05 /* for C320_status */
43
44#define C320_status C320_ConfBase + 0 /* BIOS running status */
45#define C320_diag C320_ConfBase + 2 /* diagnostic status */
46#define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */
47#define C320DLoad_len C320_ConfBase + 6 /* WORD */
48#define C320check_sum C320_ConfBase + 8 /* WORD */
49#define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */
50#define C320bapi_len C320_ConfBase + 0x0c /* WORD */
51#define C320UART_no C320_ConfBase + 0x0e /* WORD */
52
53#define C320_KeyCode 0x320
54
55#define FixPage_addr 0x0000 /* starting addr of static page */
56#define DynPage_addr 0x2000 /* starting addr of dynamic page */
57#define C218_start 0x3000 /* starting addr of C218 BIOS prg */
58#define Control_reg 0x1ff0 /* select page and reset control */
59#define HW_reset 0x80
60
61/*
62 * Function Codes
63 */
64#define FC_CardReset 0x80
65#define FC_ChannelReset 1 /* C320 firmware not supported */
66#define FC_EnableCH 2
67#define FC_DisableCH 3
68#define FC_SetParam 4
69#define FC_SetMode 5
70#define FC_SetRate 6
71#define FC_LineControl 7
72#define FC_LineStatus 8
73#define FC_XmitControl 9
74#define FC_FlushQueue 10
75#define FC_SendBreak 11
76#define FC_StopBreak 12
77#define FC_LoopbackON 13
78#define FC_LoopbackOFF 14
79#define FC_ClrIrqTable 15
80#define FC_SendXon 16
81#define FC_SetTermIrq 17 /* C320 firmware not supported */
82#define FC_SetCntIrq 18 /* C320 firmware not supported */
83#define FC_SetBreakIrq 19
84#define FC_SetLineIrq 20
85#define FC_SetFlowCtl 21
86#define FC_GenIrq 22
87#define FC_InCD180 23
88#define FC_OutCD180 24
89#define FC_InUARTreg 23
90#define FC_OutUARTreg 24
91#define FC_SetXonXoff 25
92#define FC_OutCD180CCR 26
93#define FC_ExtIQueue 27
94#define FC_ExtOQueue 28
95#define FC_ClrLineIrq 29
96#define FC_HWFlowCtl 30
97#define FC_GetClockRate 35
98#define FC_SetBaud 36
99#define FC_SetDataMode 41
100#define FC_GetCCSR 43
101#define FC_GetDataError 45
102#define FC_RxControl 50
103#define FC_ImmSend 51
104#define FC_SetXonState 52
105#define FC_SetXoffState 53
106#define FC_SetRxFIFOTrig 54
107#define FC_SetTxFIFOCnt 55
108#define FC_UnixRate 56
109#define FC_UnixResetTimer 57
110
111#define RxFIFOTrig1 0
112#define RxFIFOTrig4 1
113#define RxFIFOTrig8 2
114#define RxFIFOTrig14 3
115
116/*
117 * Dual-Ported RAM
118 */
119#define DRAM_global 0
120#define INT_data (DRAM_global + 0)
121#define Config_base (DRAM_global + 0x108)
122
123#define IRQindex (INT_data + 0)
124#define IRQpending (INT_data + 4)
125#define IRQtable (INT_data + 8)
126
127/*
128 * Interrupt Status
129 */
130#define IntrRx 0x01 /* receiver data O.K. */
131#define IntrTx 0x02 /* transmit buffer empty */
132#define IntrFunc 0x04 /* function complete */
133#define IntrBreak 0x08 /* received break */
134#define IntrLine 0x10 /* line status change
135 for transmitter */
136#define IntrIntr 0x20 /* received INTR code */
137#define IntrQuit 0x40 /* received QUIT code */
138#define IntrEOF 0x80 /* received EOF code */
139
140#define IntrRxTrigger 0x100 /* rx data count reach tigger value */
141#define IntrTxTrigger 0x200 /* tx data count below trigger value */
142
143#define Magic_no (Config_base + 0)
144#define Card_model_no (Config_base + 2)
145#define Total_ports (Config_base + 4)
146#define Module_cnt (Config_base + 8)
147#define Module_no (Config_base + 10)
148#define Timer_10ms (Config_base + 14)
149#define Disable_IRQ (Config_base + 20)
150#define TMS320_PORT1 (Config_base + 22)
151#define TMS320_PORT2 (Config_base + 24)
152#define TMS320_CLOCK (Config_base + 26)
153
154/*
155 * DATA BUFFER in DRAM
156 */
157#define Extern_table 0x400 /* Base address of the external table
158 (24 words * 64) total 3K bytes
159 (24 words * 128) total 6K bytes */
160#define Extern_size 0x60 /* 96 bytes */
161#define RXrptr 0x00 /* read pointer for RX buffer */
162#define RXwptr 0x02 /* write pointer for RX buffer */
163#define TXrptr 0x04 /* read pointer for TX buffer */
164#define TXwptr 0x06 /* write pointer for TX buffer */
165#define HostStat 0x08 /* IRQ flag and general flag */
166#define FlagStat 0x0A
167#define FlowControl 0x0C /* B7 B6 B5 B4 B3 B2 B1 B0 */
168 /* x x x x | | | | */
169 /* | | | + CTS flow */
170 /* | | +--- RTS flow */
171 /* | +------ TX Xon/Xoff */
172 /* +--------- RX Xon/Xoff */
173#define Break_cnt 0x0E /* received break count */
174#define CD180TXirq 0x10 /* if non-0: enable TX irq */
175#define RX_mask 0x12
176#define TX_mask 0x14
177#define Ofs_rxb 0x16
178#define Ofs_txb 0x18
179#define Page_rxb 0x1A
180#define Page_txb 0x1C
181#define EndPage_rxb 0x1E
182#define EndPage_txb 0x20
183#define Data_error 0x22
184#define RxTrigger 0x28
185#define TxTrigger 0x2a
186
187#define rRXwptr 0x34
188#define Low_water 0x36
189
190#define FuncCode 0x40
191#define FuncArg 0x42
192#define FuncArg1 0x44
193
194#define C218rx_size 0x2000 /* 8K bytes */
195#define C218tx_size 0x8000 /* 32K bytes */
196
197#define C218rx_mask (C218rx_size - 1)
198#define C218tx_mask (C218tx_size - 1)
199
200#define C320p8rx_size 0x2000
201#define C320p8tx_size 0x8000
202#define C320p8rx_mask (C320p8rx_size - 1)
203#define C320p8tx_mask (C320p8tx_size - 1)
204
205#define C320p16rx_size 0x2000
206#define C320p16tx_size 0x4000
207#define C320p16rx_mask (C320p16rx_size - 1)
208#define C320p16tx_mask (C320p16tx_size - 1)
209
210#define C320p24rx_size 0x2000
211#define C320p24tx_size 0x2000
212#define C320p24rx_mask (C320p24rx_size - 1)
213#define C320p24tx_mask (C320p24tx_size - 1)
214
215#define C320p32rx_size 0x1000
216#define C320p32tx_size 0x1000
217#define C320p32rx_mask (C320p32rx_size - 1)
218#define C320p32tx_mask (C320p32tx_size - 1)
219
220#define Page_size 0x2000U
221#define Page_mask (Page_size - 1)
222#define C218rx_spage 3
223#define C218tx_spage 4
224#define C218rx_pageno 1
225#define C218tx_pageno 4
226#define C218buf_pageno 5
227
228#define C320p8rx_spage 3
229#define C320p8tx_spage 4
230#define C320p8rx_pgno 1
231#define C320p8tx_pgno 4
232#define C320p8buf_pgno 5
233
234#define C320p16rx_spage 3
235#define C320p16tx_spage 4
236#define C320p16rx_pgno 1
237#define C320p16tx_pgno 2
238#define C320p16buf_pgno 3
239
240#define C320p24rx_spage 3
241#define C320p24tx_spage 4
242#define C320p24rx_pgno 1
243#define C320p24tx_pgno 1
244#define C320p24buf_pgno 2
245
246#define C320p32rx_spage 3
247#define C320p32tx_ofs C320p32rx_size
248#define C320p32tx_spage 3
249#define C320p32buf_pgno 1
250
251/*
252 * Host Status
253 */
254#define WakeupRx 0x01
255#define WakeupTx 0x02
256#define WakeupBreak 0x08
257#define WakeupLine 0x10
258#define WakeupIntr 0x20
259#define WakeupQuit 0x40
260#define WakeupEOF 0x80 /* used in VTIME control */
261#define WakeupRxTrigger 0x100
262#define WakeupTxTrigger 0x200
263/*
264 * Flag status
265 */
266#define Rx_over 0x01
267#define Xoff_state 0x02
268#define Tx_flowOff 0x04
269#define Tx_enable 0x08
270#define CTS_state 0x10
271#define DSR_state 0x20
272#define DCD_state 0x80
273/*
274 * FlowControl
275 */
276#define CTS_FlowCtl 1
277#define RTS_FlowCtl 2
278#define Tx_FlowCtl 4
279#define Rx_FlowCtl 8
280#define IXM_IXANY 0x10
281
282#define LowWater 128
283
284#define DTR_ON 1
285#define RTS_ON 2
286#define CTS_ON 1
287#define DSR_ON 2
288#define DCD_ON 8
289
290/* mode definition */
291#define MX_CS8 0x03
292#define MX_CS7 0x02
293#define MX_CS6 0x01
294#define MX_CS5 0x00
295
296#define MX_STOP1 0x00
297#define MX_STOP15 0x04
298#define MX_STOP2 0x08
299
300#define MX_PARNONE 0x00
301#define MX_PAREVEN 0x40
302#define MX_PARODD 0xC0
303
304#endif
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index 68c2e9234691..4b81a85c5b53 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -307,6 +307,200 @@ static unsigned char mxser_msr[MXSER_PORTS + 1];
307static struct mxser_mon_ext mon_data_ext; 307static struct mxser_mon_ext mon_data_ext;
308static int mxser_set_baud_method[MXSER_PORTS + 1]; 308static int mxser_set_baud_method[MXSER_PORTS + 1];
309 309
310static void mxser_enable_must_enchance_mode(unsigned long baseio)
311{
312 u8 oldlcr;
313 u8 efr;
314
315 oldlcr = inb(baseio + UART_LCR);
316 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
317
318 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
319 efr |= MOXA_MUST_EFR_EFRB_ENABLE;
320
321 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
322 outb(oldlcr, baseio + UART_LCR);
323}
324
325static void mxser_disable_must_enchance_mode(unsigned long baseio)
326{
327 u8 oldlcr;
328 u8 efr;
329
330 oldlcr = inb(baseio + UART_LCR);
331 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
332
333 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
334 efr &= ~MOXA_MUST_EFR_EFRB_ENABLE;
335
336 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
337 outb(oldlcr, baseio + UART_LCR);
338}
339
340static void mxser_set_must_xon1_value(unsigned long baseio, u8 value)
341{
342 u8 oldlcr;
343 u8 efr;
344
345 oldlcr = inb(baseio + UART_LCR);
346 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
347
348 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
349 efr &= ~MOXA_MUST_EFR_BANK_MASK;
350 efr |= MOXA_MUST_EFR_BANK0;
351
352 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
353 outb(value, baseio + MOXA_MUST_XON1_REGISTER);
354 outb(oldlcr, baseio + UART_LCR);
355}
356
357static void mxser_set_must_xoff1_value(unsigned long baseio, u8 value)
358{
359 u8 oldlcr;
360 u8 efr;
361
362 oldlcr = inb(baseio + UART_LCR);
363 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
364
365 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
366 efr &= ~MOXA_MUST_EFR_BANK_MASK;
367 efr |= MOXA_MUST_EFR_BANK0;
368
369 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
370 outb(value, baseio + MOXA_MUST_XOFF1_REGISTER);
371 outb(oldlcr, baseio + UART_LCR);
372}
373
374static void mxser_set_must_fifo_value(struct mxser_port *info)
375{
376 u8 oldlcr;
377 u8 efr;
378
379 oldlcr = inb(info->ioaddr + UART_LCR);
380 outb(MOXA_MUST_ENTER_ENCHANCE, info->ioaddr + UART_LCR);
381
382 efr = inb(info->ioaddr + MOXA_MUST_EFR_REGISTER);
383 efr &= ~MOXA_MUST_EFR_BANK_MASK;
384 efr |= MOXA_MUST_EFR_BANK1;
385
386 outb(efr, info->ioaddr + MOXA_MUST_EFR_REGISTER);
387 outb((u8)info->rx_high_water, info->ioaddr + MOXA_MUST_RBRTH_REGISTER);
388 outb((u8)info->rx_trigger, info->ioaddr + MOXA_MUST_RBRTI_REGISTER);
389 outb((u8)info->rx_low_water, info->ioaddr + MOXA_MUST_RBRTL_REGISTER);
390 outb(oldlcr, info->ioaddr + UART_LCR);
391}
392
393static void mxser_set_must_enum_value(unsigned long baseio, u8 value)
394{
395 u8 oldlcr;
396 u8 efr;
397
398 oldlcr = inb(baseio + UART_LCR);
399 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
400
401 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
402 efr &= ~MOXA_MUST_EFR_BANK_MASK;
403 efr |= MOXA_MUST_EFR_BANK2;
404
405 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
406 outb(value, baseio + MOXA_MUST_ENUM_REGISTER);
407 outb(oldlcr, baseio + UART_LCR);
408}
409
410static void mxser_get_must_hardware_id(unsigned long baseio, u8 *pId)
411{
412 u8 oldlcr;
413 u8 efr;
414
415 oldlcr = inb(baseio + UART_LCR);
416 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
417
418 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
419 efr &= ~MOXA_MUST_EFR_BANK_MASK;
420 efr |= MOXA_MUST_EFR_BANK2;
421
422 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
423 *pId = inb(baseio + MOXA_MUST_HWID_REGISTER);
424 outb(oldlcr, baseio + UART_LCR);
425}
426
427static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio)
428{
429 u8 oldlcr;
430 u8 efr;
431
432 oldlcr = inb(baseio + UART_LCR);
433 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
434
435 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
436 efr &= ~MOXA_MUST_EFR_SF_MASK;
437
438 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
439 outb(oldlcr, baseio + UART_LCR);
440}
441
442static void mxser_enable_must_tx_software_flow_control(unsigned long baseio)
443{
444 u8 oldlcr;
445 u8 efr;
446
447 oldlcr = inb(baseio + UART_LCR);
448 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
449
450 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
451 efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
452 efr |= MOXA_MUST_EFR_SF_TX1;
453
454 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
455 outb(oldlcr, baseio + UART_LCR);
456}
457
458static void mxser_disable_must_tx_software_flow_control(unsigned long baseio)
459{
460 u8 oldlcr;
461 u8 efr;
462
463 oldlcr = inb(baseio + UART_LCR);
464 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
465
466 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
467 efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
468
469 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
470 outb(oldlcr, baseio + UART_LCR);
471}
472
473static void mxser_enable_must_rx_software_flow_control(unsigned long baseio)
474{
475 u8 oldlcr;
476 u8 efr;
477
478 oldlcr = inb(baseio + UART_LCR);
479 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
480
481 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
482 efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
483 efr |= MOXA_MUST_EFR_SF_RX1;
484
485 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
486 outb(oldlcr, baseio + UART_LCR);
487}
488
489static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
490{
491 u8 oldlcr;
492 u8 efr;
493
494 oldlcr = inb(baseio + UART_LCR);
495 outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
496
497 efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
498 efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
499
500 outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
501 outb(oldlcr, baseio + UART_LCR);
502}
503
310#ifdef CONFIG_PCI 504#ifdef CONFIG_PCI
311static int __devinit CheckIsMoxaMust(unsigned long io) 505static int __devinit CheckIsMoxaMust(unsigned long io)
312{ 506{
@@ -314,16 +508,16 @@ static int __devinit CheckIsMoxaMust(unsigned long io)
314 int i; 508 int i;
315 509
316 outb(0, io + UART_LCR); 510 outb(0, io + UART_LCR);
317 DISABLE_MOXA_MUST_ENCHANCE_MODE(io); 511 mxser_disable_must_enchance_mode(io);
318 oldmcr = inb(io + UART_MCR); 512 oldmcr = inb(io + UART_MCR);
319 outb(0, io + UART_MCR); 513 outb(0, io + UART_MCR);
320 SET_MOXA_MUST_XON1_VALUE(io, 0x11); 514 mxser_set_must_xon1_value(io, 0x11);
321 if ((hwid = inb(io + UART_MCR)) != 0) { 515 if ((hwid = inb(io + UART_MCR)) != 0) {
322 outb(oldmcr, io + UART_MCR); 516 outb(oldmcr, io + UART_MCR);
323 return MOXA_OTHER_UART; 517 return MOXA_OTHER_UART;
324 } 518 }
325 519
326 GET_MOXA_MUST_HARDWARE_ID(io, &hwid); 520 mxser_get_must_hardware_id(io, &hwid);
327 for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */ 521 for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */
328 if (hwid == Gpci_uart_info[i].type) 522 if (hwid == Gpci_uart_info[i].type)
329 return (int)hwid; 523 return (int)hwid;
@@ -494,10 +688,10 @@ static int mxser_set_baud(struct mxser_port *info, long newspd)
494 } else 688 } else
495 quot /= newspd; 689 quot /= newspd;
496 690
497 SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, quot); 691 mxser_set_must_enum_value(info->ioaddr, quot);
498 } else 692 } else
499#endif 693#endif
500 SET_MOXA_MUST_ENUM_VALUE(info->ioaddr, 0); 694 mxser_set_must_enum_value(info->ioaddr, 0);
501 695
502 return 0; 696 return 0;
503} 697}
@@ -553,14 +747,14 @@ static int mxser_change_speed(struct mxser_port *info,
553 if (info->board->chip_flag) { 747 if (info->board->chip_flag) {
554 fcr = UART_FCR_ENABLE_FIFO; 748 fcr = UART_FCR_ENABLE_FIFO;
555 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 749 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
556 SET_MOXA_MUST_FIFO_VALUE(info); 750 mxser_set_must_fifo_value(info);
557 } else 751 } else
558 fcr = 0; 752 fcr = 0;
559 } else { 753 } else {
560 fcr = UART_FCR_ENABLE_FIFO; 754 fcr = UART_FCR_ENABLE_FIFO;
561 if (info->board->chip_flag) { 755 if (info->board->chip_flag) {
562 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE; 756 fcr |= MOXA_MUST_FCR_GDA_MODE_ENABLE;
563 SET_MOXA_MUST_FIFO_VALUE(info); 757 mxser_set_must_fifo_value(info);
564 } else { 758 } else {
565 switch (info->rx_trigger) { 759 switch (info->rx_trigger) {
566 case 1: 760 case 1:
@@ -657,17 +851,21 @@ static int mxser_change_speed(struct mxser_port *info,
657 } 851 }
658 } 852 }
659 if (info->board->chip_flag) { 853 if (info->board->chip_flag) {
660 SET_MOXA_MUST_XON1_VALUE(info->ioaddr, START_CHAR(info->tty)); 854 mxser_set_must_xon1_value(info->ioaddr, START_CHAR(info->tty));
661 SET_MOXA_MUST_XOFF1_VALUE(info->ioaddr, STOP_CHAR(info->tty)); 855 mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(info->tty));
662 if (I_IXON(info->tty)) { 856 if (I_IXON(info->tty)) {
663 ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 857 mxser_enable_must_rx_software_flow_control(
858 info->ioaddr);
664 } else { 859 } else {
665 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 860 mxser_disable_must_rx_software_flow_control(
861 info->ioaddr);
666 } 862 }
667 if (I_IXOFF(info->tty)) { 863 if (I_IXOFF(info->tty)) {
668 ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 864 mxser_enable_must_tx_software_flow_control(
865 info->ioaddr);
669 } else { 866 } else {
670 DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 867 mxser_disable_must_tx_software_flow_control(
868 info->ioaddr);
671 } 869 }
672 } 870 }
673 871
@@ -927,6 +1125,27 @@ static int mxser_open(struct tty_struct *tty, struct file *filp)
927 return 0; 1125 return 0;
928} 1126}
929 1127
1128static void mxser_flush_buffer(struct tty_struct *tty)
1129{
1130 struct mxser_port *info = tty->driver_data;
1131 char fcr;
1132 unsigned long flags;
1133
1134
1135 spin_lock_irqsave(&info->slock, flags);
1136 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1137
1138 fcr = inb(info->ioaddr + UART_FCR);
1139 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1140 info->ioaddr + UART_FCR);
1141 outb(fcr, info->ioaddr + UART_FCR);
1142
1143 spin_unlock_irqrestore(&info->slock, flags);
1144
1145 tty_wakeup(tty);
1146}
1147
1148
930/* 1149/*
931 * This routine is called when the serial port gets closed. First, we 1150 * This routine is called when the serial port gets closed. First, we
932 * wait for the last remaining data to be sent. Then, we unlink its 1151 * wait for the last remaining data to be sent. Then, we unlink its
@@ -1013,9 +1232,7 @@ static void mxser_close(struct tty_struct *tty, struct file *filp)
1013 } 1232 }
1014 mxser_shutdown(info); 1233 mxser_shutdown(info);
1015 1234
1016 if (tty->driver->flush_buffer) 1235 mxser_flush_buffer(tty);
1017 tty->driver->flush_buffer(tty);
1018
1019 tty_ldisc_flush(tty); 1236 tty_ldisc_flush(tty);
1020 1237
1021 tty->closing = 0; 1238 tty->closing = 0;
@@ -1072,16 +1289,16 @@ static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int cou
1072 return total; 1289 return total;
1073} 1290}
1074 1291
1075static void mxser_put_char(struct tty_struct *tty, unsigned char ch) 1292static int mxser_put_char(struct tty_struct *tty, unsigned char ch)
1076{ 1293{
1077 struct mxser_port *info = tty->driver_data; 1294 struct mxser_port *info = tty->driver_data;
1078 unsigned long flags; 1295 unsigned long flags;
1079 1296
1080 if (!info->xmit_buf) 1297 if (!info->xmit_buf)
1081 return; 1298 return 0;
1082 1299
1083 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) 1300 if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1084 return; 1301 return 0;
1085 1302
1086 spin_lock_irqsave(&info->slock, flags); 1303 spin_lock_irqsave(&info->slock, flags);
1087 info->xmit_buf[info->xmit_head++] = ch; 1304 info->xmit_buf[info->xmit_head++] = ch;
@@ -1099,6 +1316,7 @@ static void mxser_put_char(struct tty_struct *tty, unsigned char ch)
1099 spin_unlock_irqrestore(&info->slock, flags); 1316 spin_unlock_irqrestore(&info->slock, flags);
1100 } 1317 }
1101 } 1318 }
1319 return 1;
1102} 1320}
1103 1321
1104 1322
@@ -1142,26 +1360,6 @@ static int mxser_chars_in_buffer(struct tty_struct *tty)
1142 return info->xmit_cnt; 1360 return info->xmit_cnt;
1143} 1361}
1144 1362
1145static void mxser_flush_buffer(struct tty_struct *tty)
1146{
1147 struct mxser_port *info = tty->driver_data;
1148 char fcr;
1149 unsigned long flags;
1150
1151
1152 spin_lock_irqsave(&info->slock, flags);
1153 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1154
1155 fcr = inb(info->ioaddr + UART_FCR);
1156 outb((fcr | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT),
1157 info->ioaddr + UART_FCR);
1158 outb(fcr, info->ioaddr + UART_FCR);
1159
1160 spin_unlock_irqrestore(&info->slock, flags);
1161
1162 tty_wakeup(tty);
1163}
1164
1165/* 1363/*
1166 * ------------------------------------------------------------ 1364 * ------------------------------------------------------------
1167 * friends of mxser_ioctl() 1365 * friends of mxser_ioctl()
@@ -1460,6 +1658,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1460 struct mxser_port *port; 1658 struct mxser_port *port;
1461 int result, status; 1659 int result, status;
1462 unsigned int i, j; 1660 unsigned int i, j;
1661 int ret = 0;
1463 1662
1464 switch (cmd) { 1663 switch (cmd) {
1465 case MOXA_GET_MAJOR: 1664 case MOXA_GET_MAJOR:
@@ -1467,18 +1666,21 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1467 1666
1468 case MOXA_CHKPORTENABLE: 1667 case MOXA_CHKPORTENABLE:
1469 result = 0; 1668 result = 0;
1470 1669 lock_kernel();
1471 for (i = 0; i < MXSER_BOARDS; i++) 1670 for (i = 0; i < MXSER_BOARDS; i++)
1472 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) 1671 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++)
1473 if (mxser_boards[i].ports[j].ioaddr) 1672 if (mxser_boards[i].ports[j].ioaddr)
1474 result |= (1 << i); 1673 result |= (1 << i);
1475 1674 unlock_kernel();
1476 return put_user(result, (unsigned long __user *)argp); 1675 return put_user(result, (unsigned long __user *)argp);
1477 case MOXA_GETDATACOUNT: 1676 case MOXA_GETDATACOUNT:
1677 lock_kernel();
1478 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log))) 1678 if (copy_to_user(argp, &mxvar_log, sizeof(mxvar_log)))
1479 return -EFAULT; 1679 ret = -EFAULT;
1480 return 0; 1680 unlock_kernel();
1681 return ret;
1481 case MOXA_GETMSTATUS: 1682 case MOXA_GETMSTATUS:
1683 lock_kernel();
1482 for (i = 0; i < MXSER_BOARDS; i++) 1684 for (i = 0; i < MXSER_BOARDS; i++)
1483 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { 1685 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
1484 port = &mxser_boards[i].ports[j]; 1686 port = &mxser_boards[i].ports[j];
@@ -1515,6 +1717,7 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1515 else 1717 else
1516 GMStatus[i].cts = 0; 1718 GMStatus[i].cts = 0;
1517 } 1719 }
1720 unlock_kernel();
1518 if (copy_to_user(argp, GMStatus, 1721 if (copy_to_user(argp, GMStatus,
1519 sizeof(struct mxser_mstatus) * MXSER_PORTS)) 1722 sizeof(struct mxser_mstatus) * MXSER_PORTS))
1520 return -EFAULT; 1723 return -EFAULT;
@@ -1524,7 +1727,8 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1524 unsigned long opmode; 1727 unsigned long opmode;
1525 unsigned cflag, iflag; 1728 unsigned cflag, iflag;
1526 1729
1527 for (i = 0; i < MXSER_BOARDS; i++) 1730 lock_kernel();
1731 for (i = 0; i < MXSER_BOARDS; i++) {
1528 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) { 1732 for (j = 0; j < MXSER_PORTS_PER_BOARD; j++) {
1529 port = &mxser_boards[i].ports[j]; 1733 port = &mxser_boards[i].ports[j];
1530 if (!port->ioaddr) 1734 if (!port->ioaddr)
@@ -1589,13 +1793,14 @@ static int mxser_ioctl_special(unsigned int cmd, void __user *argp)
1589 mon_data_ext.iftype[i] = opmode; 1793 mon_data_ext.iftype[i] = opmode;
1590 1794
1591 } 1795 }
1592 if (copy_to_user(argp, &mon_data_ext, 1796 }
1593 sizeof(mon_data_ext))) 1797 unlock_kernel();
1594 return -EFAULT; 1798 if (copy_to_user(argp, &mon_data_ext,
1595 1799 sizeof(mon_data_ext)))
1596 return 0; 1800 return -EFAULT;
1597 1801 return 0;
1598 } default: 1802 }
1803 default:
1599 return -ENOIOCTLCMD; 1804 return -ENOIOCTLCMD;
1600 } 1805 }
1601 return 0; 1806 return 0;
@@ -1651,16 +1856,20 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1651 opmode != RS422_MODE && 1856 opmode != RS422_MODE &&
1652 opmode != RS485_4WIRE_MODE) 1857 opmode != RS485_4WIRE_MODE)
1653 return -EFAULT; 1858 return -EFAULT;
1859 lock_kernel();
1654 mask = ModeMask[p]; 1860 mask = ModeMask[p];
1655 shiftbit = p * 2; 1861 shiftbit = p * 2;
1656 val = inb(info->opmode_ioaddr); 1862 val = inb(info->opmode_ioaddr);
1657 val &= mask; 1863 val &= mask;
1658 val |= (opmode << shiftbit); 1864 val |= (opmode << shiftbit);
1659 outb(val, info->opmode_ioaddr); 1865 outb(val, info->opmode_ioaddr);
1866 unlock_kernel();
1660 } else { 1867 } else {
1868 lock_kernel();
1661 shiftbit = p * 2; 1869 shiftbit = p * 2;
1662 opmode = inb(info->opmode_ioaddr) >> shiftbit; 1870 opmode = inb(info->opmode_ioaddr) >> shiftbit;
1663 opmode &= OP_MODE_MASK; 1871 opmode &= OP_MODE_MASK;
1872 unlock_kernel();
1664 if (put_user(opmode, (int __user *)argp)) 1873 if (put_user(opmode, (int __user *)argp))
1665 return -EFAULT; 1874 return -EFAULT;
1666 } 1875 }
@@ -1687,19 +1896,18 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1687 tty_wait_until_sent(tty, 0); 1896 tty_wait_until_sent(tty, 0);
1688 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4); 1897 mxser_send_break(info, arg ? arg * (HZ / 10) : HZ / 4);
1689 return 0; 1898 return 0;
1690 case TIOCGSOFTCAR:
1691 return put_user(!!C_CLOCAL(tty), (unsigned long __user *)argp);
1692 case TIOCSSOFTCAR:
1693 if (get_user(arg, (unsigned long __user *)argp))
1694 return -EFAULT;
1695 tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0));
1696 return 0;
1697 case TIOCGSERIAL: 1899 case TIOCGSERIAL:
1698 return mxser_get_serial_info(info, argp); 1900 lock_kernel();
1901 retval = mxser_get_serial_info(info, argp);
1902 unlock_kernel();
1903 return retval;
1699 case TIOCSSERIAL: 1904 case TIOCSSERIAL:
1700 return mxser_set_serial_info(info, argp); 1905 lock_kernel();
1906 retval = mxser_set_serial_info(info, argp);
1907 unlock_kernel();
1908 return retval;
1701 case TIOCSERGETLSR: /* Get line status register */ 1909 case TIOCSERGETLSR: /* Get line status register */
1702 return mxser_get_lsr_info(info, argp); 1910 return mxser_get_lsr_info(info, argp);
1703 /* 1911 /*
1704 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 1912 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
1705 * - mask passed in arg for lines of interest 1913 * - mask passed in arg for lines of interest
@@ -1746,24 +1954,27 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1746 case MOXA_HighSpeedOn: 1954 case MOXA_HighSpeedOn:
1747 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); 1955 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp);
1748 case MOXA_SDS_RSTICOUNTER: 1956 case MOXA_SDS_RSTICOUNTER:
1957 lock_kernel();
1749 info->mon_data.rxcnt = 0; 1958 info->mon_data.rxcnt = 0;
1750 info->mon_data.txcnt = 0; 1959 info->mon_data.txcnt = 0;
1960 unlock_kernel();
1751 return 0; 1961 return 0;
1752 1962
1753 case MOXA_ASPP_OQUEUE:{ 1963 case MOXA_ASPP_OQUEUE:{
1754 int len, lsr; 1964 int len, lsr;
1755 1965
1966 lock_kernel();
1756 len = mxser_chars_in_buffer(tty); 1967 len = mxser_chars_in_buffer(tty);
1757
1758 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT; 1968 lsr = inb(info->ioaddr + UART_LSR) & UART_LSR_TEMT;
1759
1760 len += (lsr ? 0 : 1); 1969 len += (lsr ? 0 : 1);
1970 unlock_kernel();
1761 1971
1762 return put_user(len, (int __user *)argp); 1972 return put_user(len, (int __user *)argp);
1763 } 1973 }
1764 case MOXA_ASPP_MON: { 1974 case MOXA_ASPP_MON: {
1765 int mcr, status; 1975 int mcr, status;
1766 1976
1977 lock_kernel();
1767 status = mxser_get_msr(info->ioaddr, 1, tty->index); 1978 status = mxser_get_msr(info->ioaddr, 1, tty->index);
1768 mxser_check_modem_status(info, status); 1979 mxser_check_modem_status(info, status);
1769 1980
@@ -1782,7 +1993,7 @@ static int mxser_ioctl(struct tty_struct *tty, struct file *file,
1782 info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD; 1993 info->mon_data.hold_reason |= NPPI_NOTIFY_CTSHOLD;
1783 else 1994 else
1784 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD; 1995 info->mon_data.hold_reason &= ~NPPI_NOTIFY_CTSHOLD;
1785 1996 unlock_kernel();
1786 if (copy_to_user(argp, &info->mon_data, 1997 if (copy_to_user(argp, &info->mon_data,
1787 sizeof(struct mxser_mon))) 1998 sizeof(struct mxser_mon)))
1788 return -EFAULT; 1999 return -EFAULT;
@@ -1925,7 +2136,8 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
1925 2136
1926 if (info->board->chip_flag) { 2137 if (info->board->chip_flag) {
1927 spin_lock_irqsave(&info->slock, flags); 2138 spin_lock_irqsave(&info->slock, flags);
1928 DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(info->ioaddr); 2139 mxser_disable_must_rx_software_flow_control(
2140 info->ioaddr);
1929 spin_unlock_irqrestore(&info->slock, flags); 2141 spin_unlock_irqrestore(&info->slock, flags);
1930 } 2142 }
1931 2143
@@ -1979,6 +2191,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1979 timeout, char_time); 2191 timeout, char_time);
1980 printk("jiff=%lu...", jiffies); 2192 printk("jiff=%lu...", jiffies);
1981#endif 2193#endif
2194 lock_kernel();
1982 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) { 2195 while (!((lsr = inb(info->ioaddr + UART_LSR)) & UART_LSR_TEMT)) {
1983#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 2196#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1984 printk("lsr = %d (jiff=%lu)...", lsr, jiffies); 2197 printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
@@ -1990,6 +2203,7 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
1990 break; 2203 break;
1991 } 2204 }
1992 set_current_state(TASK_RUNNING); 2205 set_current_state(TASK_RUNNING);
2206 unlock_kernel();
1993 2207
1994#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 2208#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1995 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 2209 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
@@ -2342,7 +2556,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd,
2342 2556
2343 /* Enhance mode enabled here */ 2557 /* Enhance mode enabled here */
2344 if (brd->chip_flag != MOXA_OTHER_UART) 2558 if (brd->chip_flag != MOXA_OTHER_UART)
2345 ENABLE_MOXA_MUST_ENCHANCE_MODE(info->ioaddr); 2559 mxser_enable_must_enchance_mode(info->ioaddr);
2346 2560
2347 info->flags = ASYNC_SHARE_IRQ; 2561 info->flags = ASYNC_SHARE_IRQ;
2348 info->type = brd->uart_type; 2562 info->type = brd->uart_type;
diff --git a/drivers/char/mxser.h b/drivers/char/mxser.h
index 844171115954..41878a69203d 100644
--- a/drivers/char/mxser.h
+++ b/drivers/char/mxser.h
@@ -147,141 +147,4 @@
147/* Rx software flow control mask */ 147/* Rx software flow control mask */
148#define MOXA_MUST_EFR_SF_RX_MASK 0x03 148#define MOXA_MUST_EFR_SF_RX_MASK 0x03
149 149
150#define ENABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
151 u8 __oldlcr, __efr; \
152 __oldlcr = inb((baseio)+UART_LCR); \
153 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
154 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
155 __efr |= MOXA_MUST_EFR_EFRB_ENABLE; \
156 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
157 outb(__oldlcr, (baseio)+UART_LCR); \
158} while (0)
159
160#define DISABLE_MOXA_MUST_ENCHANCE_MODE(baseio) do { \
161 u8 __oldlcr, __efr; \
162 __oldlcr = inb((baseio)+UART_LCR); \
163 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
164 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
165 __efr &= ~MOXA_MUST_EFR_EFRB_ENABLE; \
166 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
167 outb(__oldlcr, (baseio)+UART_LCR); \
168} while (0)
169
170#define SET_MOXA_MUST_XON1_VALUE(baseio, Value) do { \
171 u8 __oldlcr, __efr; \
172 __oldlcr = inb((baseio)+UART_LCR); \
173 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
174 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
175 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
176 __efr |= MOXA_MUST_EFR_BANK0; \
177 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
178 outb((u8)(Value), (baseio)+MOXA_MUST_XON1_REGISTER); \
179 outb(__oldlcr, (baseio)+UART_LCR); \
180} while (0)
181
182#define SET_MOXA_MUST_XOFF1_VALUE(baseio, Value) do { \
183 u8 __oldlcr, __efr; \
184 __oldlcr = inb((baseio)+UART_LCR); \
185 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
186 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
187 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
188 __efr |= MOXA_MUST_EFR_BANK0; \
189 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
190 outb((u8)(Value), (baseio)+MOXA_MUST_XOFF1_REGISTER); \
191 outb(__oldlcr, (baseio)+UART_LCR); \
192} while (0)
193
194#define SET_MOXA_MUST_FIFO_VALUE(info) do { \
195 u8 __oldlcr, __efr; \
196 __oldlcr = inb((info)->ioaddr+UART_LCR); \
197 outb(MOXA_MUST_ENTER_ENCHANCE, (info)->ioaddr+UART_LCR);\
198 __efr = inb((info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
199 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
200 __efr |= MOXA_MUST_EFR_BANK1; \
201 outb(__efr, (info)->ioaddr+MOXA_MUST_EFR_REGISTER); \
202 outb((u8)((info)->rx_high_water), (info)->ioaddr+ \
203 MOXA_MUST_RBRTH_REGISTER); \
204 outb((u8)((info)->rx_trigger), (info)->ioaddr+ \
205 MOXA_MUST_RBRTI_REGISTER); \
206 outb((u8)((info)->rx_low_water), (info)->ioaddr+ \
207 MOXA_MUST_RBRTL_REGISTER); \
208 outb(__oldlcr, (info)->ioaddr+UART_LCR); \
209} while (0)
210
211#define SET_MOXA_MUST_ENUM_VALUE(baseio, Value) do { \
212 u8 __oldlcr, __efr; \
213 __oldlcr = inb((baseio)+UART_LCR); \
214 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
215 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
216 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
217 __efr |= MOXA_MUST_EFR_BANK2; \
218 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
219 outb((u8)(Value), (baseio)+MOXA_MUST_ENUM_REGISTER); \
220 outb(__oldlcr, (baseio)+UART_LCR); \
221} while (0)
222
223#define GET_MOXA_MUST_HARDWARE_ID(baseio, pId) do { \
224 u8 __oldlcr, __efr; \
225 __oldlcr = inb((baseio)+UART_LCR); \
226 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
227 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
228 __efr &= ~MOXA_MUST_EFR_BANK_MASK; \
229 __efr |= MOXA_MUST_EFR_BANK2; \
230 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
231 *pId = inb((baseio)+MOXA_MUST_HWID_REGISTER); \
232 outb(__oldlcr, (baseio)+UART_LCR); \
233} while (0)
234
235#define SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(baseio) do { \
236 u8 __oldlcr, __efr; \
237 __oldlcr = inb((baseio)+UART_LCR); \
238 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
239 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
240 __efr &= ~MOXA_MUST_EFR_SF_MASK; \
241 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
242 outb(__oldlcr, (baseio)+UART_LCR); \
243} while (0)
244
245#define ENABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
246 u8 __oldlcr, __efr; \
247 __oldlcr = inb((baseio)+UART_LCR); \
248 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
249 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
250 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
251 __efr |= MOXA_MUST_EFR_SF_TX1; \
252 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
253 outb(__oldlcr, (baseio)+UART_LCR); \
254} while (0)
255
256#define DISABLE_MOXA_MUST_TX_SOFTWARE_FLOW_CONTROL(baseio) do { \
257 u8 __oldlcr, __efr; \
258 __oldlcr = inb((baseio)+UART_LCR); \
259 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
260 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
261 __efr &= ~MOXA_MUST_EFR_SF_TX_MASK; \
262 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
263 outb(__oldlcr, (baseio)+UART_LCR); \
264} while (0)
265
266#define ENABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
267 u8 __oldlcr, __efr; \
268 __oldlcr = inb((baseio)+UART_LCR); \
269 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
270 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
271 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
272 __efr |= MOXA_MUST_EFR_SF_RX1; \
273 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
274 outb(__oldlcr, (baseio)+UART_LCR); \
275} while (0)
276
277#define DISABLE_MOXA_MUST_RX_SOFTWARE_FLOW_CONTROL(baseio) do { \
278 u8 __oldlcr, __efr; \
279 __oldlcr = inb((baseio)+UART_LCR); \
280 outb(MOXA_MUST_ENTER_ENCHANCE, (baseio)+UART_LCR); \
281 __efr = inb((baseio)+MOXA_MUST_EFR_REGISTER); \
282 __efr &= ~MOXA_MUST_EFR_SF_RX_MASK; \
283 outb(__efr, (baseio)+MOXA_MUST_EFR_REGISTER); \
284 outb(__oldlcr, (baseio)+UART_LCR); \
285} while (0)
286
287#endif 150#endif
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index 06803ed5568c..a35bfd7ee80e 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -342,12 +342,10 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
342#endif 342#endif
343 343
344 /* Flush any pending characters in the driver and discipline. */ 344 /* Flush any pending characters in the driver and discipline. */
345
346 if (tty->ldisc.flush_buffer) 345 if (tty->ldisc.flush_buffer)
347 tty->ldisc.flush_buffer (tty); 346 tty->ldisc.flush_buffer(tty);
348 347
349 if (tty->driver->flush_buffer) 348 tty_driver_flush_buffer(tty);
350 tty->driver->flush_buffer (tty);
351 349
352 if (debuglevel >= DEBUG_LEVEL_INFO) 350 if (debuglevel >= DEBUG_LEVEL_INFO)
353 printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__); 351 printk("%s(%d)n_hdlc_tty_open() success\n",__FILE__,__LINE__);
@@ -399,7 +397,7 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
399 397
400 /* Send the next block of data to device */ 398 /* Send the next block of data to device */
401 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 399 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
402 actual = tty->driver->write(tty, tbuf->buf, tbuf->count); 400 actual = tty->ops->write(tty, tbuf->buf, tbuf->count);
403 401
404 /* rollback was possible and has been done */ 402 /* rollback was possible and has been done */
405 if (actual == -ERESTARTSYS) { 403 if (actual == -ERESTARTSYS) {
@@ -578,26 +576,36 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
578 return -EFAULT; 576 return -EFAULT;
579 } 577 }
580 578
579 lock_kernel();
580
581 for (;;) { 581 for (;;) {
582 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) 582 if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) {
583 unlock_kernel();
583 return -EIO; 584 return -EIO;
585 }
584 586
585 n_hdlc = tty2n_hdlc (tty); 587 n_hdlc = tty2n_hdlc (tty);
586 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC || 588 if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC ||
587 tty != n_hdlc->tty) 589 tty != n_hdlc->tty) {
590 unlock_kernel();
588 return 0; 591 return 0;
592 }
589 593
590 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list); 594 rbuf = n_hdlc_buf_get(&n_hdlc->rx_buf_list);
591 if (rbuf) 595 if (rbuf)
592 break; 596 break;
593 597
594 /* no data */ 598 /* no data */
595 if (file->f_flags & O_NONBLOCK) 599 if (file->f_flags & O_NONBLOCK) {
600 unlock_kernel();
596 return -EAGAIN; 601 return -EAGAIN;
602 }
597 603
598 interruptible_sleep_on (&tty->read_wait); 604 interruptible_sleep_on (&tty->read_wait);
599 if (signal_pending(current)) 605 if (signal_pending(current)) {
606 unlock_kernel();
600 return -EINTR; 607 return -EINTR;
608 }
601 } 609 }
602 610
603 if (rbuf->count > nr) 611 if (rbuf->count > nr)
@@ -618,7 +626,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file,
618 kfree(rbuf); 626 kfree(rbuf);
619 else 627 else
620 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf); 628 n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,rbuf);
621 629 unlock_kernel();
622 return ret; 630 return ret;
623 631
624} /* end of n_hdlc_tty_read() */ 632} /* end of n_hdlc_tty_read() */
@@ -661,6 +669,8 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
661 count = maxframe; 669 count = maxframe;
662 } 670 }
663 671
672 lock_kernel();
673
664 add_wait_queue(&tty->write_wait, &wait); 674 add_wait_queue(&tty->write_wait, &wait);
665 set_current_state(TASK_INTERRUPTIBLE); 675 set_current_state(TASK_INTERRUPTIBLE);
666 676
@@ -695,7 +705,7 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
695 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf); 705 n_hdlc_buf_put(&n_hdlc->tx_buf_list,tbuf);
696 n_hdlc_send_frames(n_hdlc,tty); 706 n_hdlc_send_frames(n_hdlc,tty);
697 } 707 }
698 708 unlock_kernel();
699 return error; 709 return error;
700 710
701} /* end of n_hdlc_tty_write() */ 711} /* end of n_hdlc_tty_write() */
@@ -740,8 +750,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
740 750
741 case TIOCOUTQ: 751 case TIOCOUTQ:
742 /* get the pending tx byte count in the driver */ 752 /* get the pending tx byte count in the driver */
743 count = tty->driver->chars_in_buffer ? 753 count = tty_chars_in_buffer(tty);
744 tty->driver->chars_in_buffer(tty) : 0;
745 /* add size of next output frame in queue */ 754 /* add size of next output frame in queue */
746 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags); 755 spin_lock_irqsave(&n_hdlc->tx_buf_list.spinlock,flags);
747 if (n_hdlc->tx_buf_list.head) 756 if (n_hdlc->tx_buf_list.head)
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c
index 6b918b80f73e..902169062332 100644
--- a/drivers/char/n_r3964.c
+++ b/drivers/char/n_r3964.c
@@ -376,8 +376,9 @@ static void put_char(struct r3964_info *pInfo, unsigned char ch)
376 if (tty == NULL) 376 if (tty == NULL)
377 return; 377 return;
378 378
379 if (tty->driver->put_char) { 379 /* FIXME: put_char should not be called from an IRQ */
380 tty->driver->put_char(tty, ch); 380 if (tty->ops->put_char) {
381 tty->ops->put_char(tty, ch);
381 } 382 }
382 pInfo->bcc ^= ch; 383 pInfo->bcc ^= ch;
383} 384}
@@ -386,12 +387,9 @@ static void flush(struct r3964_info *pInfo)
386{ 387{
387 struct tty_struct *tty = pInfo->tty; 388 struct tty_struct *tty = pInfo->tty;
388 389
389 if (tty == NULL) 390 if (tty == NULL || tty->ops->flush_chars == NULL)
390 return; 391 return;
391 392 tty->ops->flush_chars(tty);
392 if (tty->driver->flush_chars) {
393 tty->driver->flush_chars(tty);
394 }
395} 393}
396 394
397static void trigger_transmit(struct r3964_info *pInfo) 395static void trigger_transmit(struct r3964_info *pInfo)
@@ -449,12 +447,11 @@ static void transmit_block(struct r3964_info *pInfo)
449 struct r3964_block_header *pBlock = pInfo->tx_first; 447 struct r3964_block_header *pBlock = pInfo->tx_first;
450 int room = 0; 448 int room = 0;
451 449
452 if ((tty == NULL) || (pBlock == NULL)) { 450 if (tty == NULL || pBlock == NULL) {
453 return; 451 return;
454 } 452 }
455 453
456 if (tty->driver->write_room) 454 room = tty_write_room(tty);
457 room = tty->driver->write_room(tty);
458 455
459 TRACE_PS("transmit_block %p, room %d, length %d", 456 TRACE_PS("transmit_block %p, room %d, length %d",
460 pBlock, room, pBlock->length); 457 pBlock, room, pBlock->length);
@@ -1075,12 +1072,15 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1075 1072
1076 TRACE_L("read()"); 1073 TRACE_L("read()");
1077 1074
1075 lock_kernel();
1076
1078 pClient = findClient(pInfo, task_pid(current)); 1077 pClient = findClient(pInfo, task_pid(current));
1079 if (pClient) { 1078 if (pClient) {
1080 pMsg = remove_msg(pInfo, pClient); 1079 pMsg = remove_msg(pInfo, pClient);
1081 if (pMsg == NULL) { 1080 if (pMsg == NULL) {
1082 /* no messages available. */ 1081 /* no messages available. */
1083 if (file->f_flags & O_NONBLOCK) { 1082 if (file->f_flags & O_NONBLOCK) {
1083 unlock_kernel();
1084 return -EAGAIN; 1084 return -EAGAIN;
1085 } 1085 }
1086 /* block until there is a message: */ 1086 /* block until there is a message: */
@@ -1090,8 +1090,10 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1090 1090
1091 /* If we still haven't got a message, we must have been signalled */ 1091 /* If we still haven't got a message, we must have been signalled */
1092 1092
1093 if (!pMsg) 1093 if (!pMsg) {
1094 unlock_kernel();
1094 return -EINTR; 1095 return -EINTR;
1096 }
1095 1097
1096 /* deliver msg to client process: */ 1098 /* deliver msg to client process: */
1097 theMsg.msg_id = pMsg->msg_id; 1099 theMsg.msg_id = pMsg->msg_id;
@@ -1102,12 +1104,15 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file,
1102 kfree(pMsg); 1104 kfree(pMsg);
1103 TRACE_M("r3964_read - msg kfree %p", pMsg); 1105 TRACE_M("r3964_read - msg kfree %p", pMsg);
1104 1106
1105 if (copy_to_user(buf, &theMsg, count)) 1107 if (copy_to_user(buf, &theMsg, count)) {
1108 unlock_kernel();
1106 return -EFAULT; 1109 return -EFAULT;
1110 }
1107 1111
1108 TRACE_PS("read - return %d", count); 1112 TRACE_PS("read - return %d", count);
1109 return count; 1113 return count;
1110 } 1114 }
1115 unlock_kernel();
1111 return -EPERM; 1116 return -EPERM;
1112} 1117}
1113 1118
@@ -1156,6 +1161,8 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
1156 pHeader->locks = 0; 1161 pHeader->locks = 0;
1157 pHeader->owner = NULL; 1162 pHeader->owner = NULL;
1158 1163
1164 lock_kernel();
1165
1159 pClient = findClient(pInfo, task_pid(current)); 1166 pClient = findClient(pInfo, task_pid(current));
1160 if (pClient) { 1167 if (pClient) {
1161 pHeader->owner = pClient; 1168 pHeader->owner = pClient;
@@ -1173,6 +1180,8 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file,
1173 add_tx_queue(pInfo, pHeader); 1180 add_tx_queue(pInfo, pHeader);
1174 trigger_transmit(pInfo); 1181 trigger_transmit(pInfo);
1175 1182
1183 unlock_kernel();
1184
1176 return 0; 1185 return 0;
1177} 1186}
1178 1187
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index 0c09409fa45d..19105ec203f7 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -147,10 +147,8 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty)
147 147
148static void check_unthrottle(struct tty_struct *tty) 148static void check_unthrottle(struct tty_struct *tty)
149{ 149{
150 if (tty->count && 150 if (tty->count)
151 test_and_clear_bit(TTY_THROTTLED, &tty->flags) && 151 tty_unthrottle(tty);
152 tty->driver->unthrottle)
153 tty->driver->unthrottle(tty);
154} 152}
155 153
156/** 154/**
@@ -183,22 +181,24 @@ static void reset_buffer_flags(struct tty_struct *tty)
183 * at hangup) or when the N_TTY line discipline internally has to 181 * at hangup) or when the N_TTY line discipline internally has to
184 * clean the pending queue (for example some signals). 182 * clean the pending queue (for example some signals).
185 * 183 *
186 * FIXME: tty->ctrl_status is not spinlocked and relies on 184 * Locking: ctrl_lock
187 * lock_kernel() still.
188 */ 185 */
189 186
190static void n_tty_flush_buffer(struct tty_struct *tty) 187static void n_tty_flush_buffer(struct tty_struct *tty)
191{ 188{
189 unsigned long flags;
192 /* clear everything and unthrottle the driver */ 190 /* clear everything and unthrottle the driver */
193 reset_buffer_flags(tty); 191 reset_buffer_flags(tty);
194 192
195 if (!tty->link) 193 if (!tty->link)
196 return; 194 return;
197 195
196 spin_lock_irqsave(&tty->ctrl_lock, flags);
198 if (tty->link->packet) { 197 if (tty->link->packet) {
199 tty->ctrl_status |= TIOCPKT_FLUSHREAD; 198 tty->ctrl_status |= TIOCPKT_FLUSHREAD;
200 wake_up_interruptible(&tty->link->read_wait); 199 wake_up_interruptible(&tty->link->read_wait);
201 } 200 }
201 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
202} 202}
203 203
204/** 204/**
@@ -264,17 +264,18 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
264 * relevant in the world today. If you ever need them, add them here. 264 * relevant in the world today. If you ever need them, add them here.
265 * 265 *
266 * Called from both the receive and transmit sides and can be called 266 * Called from both the receive and transmit sides and can be called
267 * re-entrantly. Relies on lock_kernel() still. 267 * re-entrantly. Relies on lock_kernel() for tty->column state.
268 */ 268 */
269 269
270static int opost(unsigned char c, struct tty_struct *tty) 270static int opost(unsigned char c, struct tty_struct *tty)
271{ 271{
272 int space, spaces; 272 int space, spaces;
273 273
274 space = tty->driver->write_room(tty); 274 space = tty_write_room(tty);
275 if (!space) 275 if (!space)
276 return -1; 276 return -1;
277 277
278 lock_kernel();
278 if (O_OPOST(tty)) { 279 if (O_OPOST(tty)) {
279 switch (c) { 280 switch (c) {
280 case '\n': 281 case '\n':
@@ -283,7 +284,7 @@ static int opost(unsigned char c, struct tty_struct *tty)
283 if (O_ONLCR(tty)) { 284 if (O_ONLCR(tty)) {
284 if (space < 2) 285 if (space < 2)
285 return -1; 286 return -1;
286 tty->driver->put_char(tty, '\r'); 287 tty_put_char(tty, '\r');
287 tty->column = 0; 288 tty->column = 0;
288 } 289 }
289 tty->canon_column = tty->column; 290 tty->canon_column = tty->column;
@@ -305,7 +306,7 @@ static int opost(unsigned char c, struct tty_struct *tty)
305 if (space < spaces) 306 if (space < spaces)
306 return -1; 307 return -1;
307 tty->column += spaces; 308 tty->column += spaces;
308 tty->driver->write(tty, " ", spaces); 309 tty->ops->write(tty, " ", spaces);
309 return 0; 310 return 0;
310 } 311 }
311 tty->column += spaces; 312 tty->column += spaces;
@@ -322,7 +323,8 @@ static int opost(unsigned char c, struct tty_struct *tty)
322 break; 323 break;
323 } 324 }
324 } 325 }
325 tty->driver->put_char(tty, c); 326 tty_put_char(tty, c);
327 unlock_kernel();
326 return 0; 328 return 0;
327} 329}
328 330
@@ -337,7 +339,8 @@ static int opost(unsigned char c, struct tty_struct *tty)
337 * the simple cases normally found and helps to generate blocks of 339 * the simple cases normally found and helps to generate blocks of
338 * symbols for the console driver and thus improve performance. 340 * symbols for the console driver and thus improve performance.
339 * 341 *
340 * Called from write_chan under the tty layer write lock. 342 * Called from write_chan under the tty layer write lock. Relies
343 * on lock_kernel for the tty->column state.
341 */ 344 */
342 345
343static ssize_t opost_block(struct tty_struct *tty, 346static ssize_t opost_block(struct tty_struct *tty,
@@ -347,12 +350,13 @@ static ssize_t opost_block(struct tty_struct *tty,
347 int i; 350 int i;
348 const unsigned char *cp; 351 const unsigned char *cp;
349 352
350 space = tty->driver->write_room(tty); 353 space = tty_write_room(tty);
351 if (!space) 354 if (!space)
352 return 0; 355 return 0;
353 if (nr > space) 356 if (nr > space)
354 nr = space; 357 nr = space;
355 358
359 lock_kernel();
356 for (i = 0, cp = buf; i < nr; i++, cp++) { 360 for (i = 0, cp = buf; i < nr; i++, cp++) {
357 switch (*cp) { 361 switch (*cp) {
358 case '\n': 362 case '\n':
@@ -384,27 +388,15 @@ static ssize_t opost_block(struct tty_struct *tty,
384 } 388 }
385 } 389 }
386break_out: 390break_out:
387 if (tty->driver->flush_chars) 391 if (tty->ops->flush_chars)
388 tty->driver->flush_chars(tty); 392 tty->ops->flush_chars(tty);
389 i = tty->driver->write(tty, buf, i); 393 i = tty->ops->write(tty, buf, i);
394 unlock_kernel();
390 return i; 395 return i;
391} 396}
392 397
393 398
394/** 399/**
395 * put_char - write character to driver
396 * @c: character (or part of unicode symbol)
397 * @tty: terminal device
398 *
399 * Queue a byte to the driver layer for output
400 */
401
402static inline void put_char(unsigned char c, struct tty_struct *tty)
403{
404 tty->driver->put_char(tty, c);
405}
406
407/**
408 * echo_char - echo characters 400 * echo_char - echo characters
409 * @c: unicode byte to echo 401 * @c: unicode byte to echo
410 * @tty: terminal device 402 * @tty: terminal device
@@ -416,8 +408,8 @@ static inline void put_char(unsigned char c, struct tty_struct *tty)
416static void echo_char(unsigned char c, struct tty_struct *tty) 408static void echo_char(unsigned char c, struct tty_struct *tty)
417{ 409{
418 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') { 410 if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') {
419 put_char('^', tty); 411 tty_put_char(tty, '^');
420 put_char(c ^ 0100, tty); 412 tty_put_char(tty, c ^ 0100);
421 tty->column += 2; 413 tty->column += 2;
422 } else 414 } else
423 opost(c, tty); 415 opost(c, tty);
@@ -426,7 +418,7 @@ static void echo_char(unsigned char c, struct tty_struct *tty)
426static inline void finish_erasing(struct tty_struct *tty) 418static inline void finish_erasing(struct tty_struct *tty)
427{ 419{
428 if (tty->erasing) { 420 if (tty->erasing) {
429 put_char('/', tty); 421 tty_put_char(tty, '/');
430 tty->column++; 422 tty->column++;
431 tty->erasing = 0; 423 tty->erasing = 0;
432 } 424 }
@@ -510,7 +502,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
510 if (L_ECHO(tty)) { 502 if (L_ECHO(tty)) {
511 if (L_ECHOPRT(tty)) { 503 if (L_ECHOPRT(tty)) {
512 if (!tty->erasing) { 504 if (!tty->erasing) {
513 put_char('\\', tty); 505 tty_put_char(tty, '\\');
514 tty->column++; 506 tty->column++;
515 tty->erasing = 1; 507 tty->erasing = 1;
516 } 508 }
@@ -518,7 +510,7 @@ static void eraser(unsigned char c, struct tty_struct *tty)
518 echo_char(c, tty); 510 echo_char(c, tty);
519 while (--cnt > 0) { 511 while (--cnt > 0) {
520 head = (head+1) & (N_TTY_BUF_SIZE-1); 512 head = (head+1) & (N_TTY_BUF_SIZE-1);
521 put_char(tty->read_buf[head], tty); 513 tty_put_char(tty, tty->read_buf[head]);
522 } 514 }
523 } else if (kill_type == ERASE && !L_ECHOE(tty)) { 515 } else if (kill_type == ERASE && !L_ECHOE(tty)) {
524 echo_char(ERASE_CHAR(tty), tty); 516 echo_char(ERASE_CHAR(tty), tty);
@@ -546,22 +538,22 @@ static void eraser(unsigned char c, struct tty_struct *tty)
546 /* Now backup to that column. */ 538 /* Now backup to that column. */
547 while (tty->column > col) { 539 while (tty->column > col) {
548 /* Can't use opost here. */ 540 /* Can't use opost here. */
549 put_char('\b', tty); 541 tty_put_char(tty, '\b');
550 if (tty->column > 0) 542 if (tty->column > 0)
551 tty->column--; 543 tty->column--;
552 } 544 }
553 } else { 545 } else {
554 if (iscntrl(c) && L_ECHOCTL(tty)) { 546 if (iscntrl(c) && L_ECHOCTL(tty)) {
555 put_char('\b', tty); 547 tty_put_char(tty, '\b');
556 put_char(' ', tty); 548 tty_put_char(tty, ' ');
557 put_char('\b', tty); 549 tty_put_char(tty, '\b');
558 if (tty->column > 0) 550 if (tty->column > 0)
559 tty->column--; 551 tty->column--;
560 } 552 }
561 if (!iscntrl(c) || L_ECHOCTL(tty)) { 553 if (!iscntrl(c) || L_ECHOCTL(tty)) {
562 put_char('\b', tty); 554 tty_put_char(tty, '\b');
563 put_char(' ', tty); 555 tty_put_char(tty, ' ');
564 put_char('\b', tty); 556 tty_put_char(tty, '\b');
565 if (tty->column > 0) 557 if (tty->column > 0)
566 tty->column--; 558 tty->column--;
567 } 559 }
@@ -592,8 +584,7 @@ static inline void isig(int sig, struct tty_struct *tty, int flush)
592 kill_pgrp(tty->pgrp, sig, 1); 584 kill_pgrp(tty->pgrp, sig, 1);
593 if (flush || !L_NOFLSH(tty)) { 585 if (flush || !L_NOFLSH(tty)) {
594 n_tty_flush_buffer(tty); 586 n_tty_flush_buffer(tty);
595 if (tty->driver->flush_buffer) 587 tty_driver_flush_buffer(tty);
596 tty->driver->flush_buffer(tty);
597 } 588 }
598} 589}
599 590
@@ -701,7 +692,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
701 692
702 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && 693 if (tty->stopped && !tty->flow_stopped && I_IXON(tty) &&
703 ((I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty)) || 694 ((I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty)) ||
704 c == INTR_CHAR(tty) || c == QUIT_CHAR(tty))) 695 c == INTR_CHAR(tty) || c == QUIT_CHAR(tty) || c == SUSP_CHAR(tty)))
705 start_tty(tty); 696 start_tty(tty);
706 697
707 if (tty->closing) { 698 if (tty->closing) {
@@ -725,7 +716,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
725 tty->lnext = 0; 716 tty->lnext = 0;
726 if (L_ECHO(tty)) { 717 if (L_ECHO(tty)) {
727 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { 718 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) {
728 put_char('\a', tty); /* beep if no space */ 719 tty_put_char(tty, '\a'); /* beep if no space */
729 return; 720 return;
730 } 721 }
731 /* Record the column of first canon char. */ 722 /* Record the column of first canon char. */
@@ -739,13 +730,6 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
739 return; 730 return;
740 } 731 }
741 732
742 if (c == '\r') {
743 if (I_IGNCR(tty))
744 return;
745 if (I_ICRNL(tty))
746 c = '\n';
747 } else if (c == '\n' && I_INLCR(tty))
748 c = '\r';
749 if (I_IXON(tty)) { 733 if (I_IXON(tty)) {
750 if (c == START_CHAR(tty)) { 734 if (c == START_CHAR(tty)) {
751 start_tty(tty); 735 start_tty(tty);
@@ -756,6 +740,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
756 return; 740 return;
757 } 741 }
758 } 742 }
743
759 if (L_ISIG(tty)) { 744 if (L_ISIG(tty)) {
760 int signal; 745 int signal;
761 signal = SIGINT; 746 signal = SIGINT;
@@ -775,8 +760,7 @@ send_signal:
775 */ 760 */
776 if (!L_NOFLSH(tty)) { 761 if (!L_NOFLSH(tty)) {
777 n_tty_flush_buffer(tty); 762 n_tty_flush_buffer(tty);
778 if (tty->driver->flush_buffer) 763 tty_driver_flush_buffer(tty);
779 tty->driver->flush_buffer(tty);
780 } 764 }
781 if (L_ECHO(tty)) 765 if (L_ECHO(tty))
782 echo_char(c, tty); 766 echo_char(c, tty);
@@ -785,6 +769,15 @@ send_signal:
785 return; 769 return;
786 } 770 }
787 } 771 }
772
773 if (c == '\r') {
774 if (I_IGNCR(tty))
775 return;
776 if (I_ICRNL(tty))
777 c = '\n';
778 } else if (c == '\n' && I_INLCR(tty))
779 c = '\r';
780
788 if (tty->icanon) { 781 if (tty->icanon) {
789 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || 782 if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) ||
790 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { 783 (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) {
@@ -796,8 +789,8 @@ send_signal:
796 if (L_ECHO(tty)) { 789 if (L_ECHO(tty)) {
797 finish_erasing(tty); 790 finish_erasing(tty);
798 if (L_ECHOCTL(tty)) { 791 if (L_ECHOCTL(tty)) {
799 put_char('^', tty); 792 tty_put_char(tty, '^');
800 put_char('\b', tty); 793 tty_put_char(tty, '\b');
801 } 794 }
802 } 795 }
803 return; 796 return;
@@ -818,7 +811,7 @@ send_signal:
818 if (c == '\n') { 811 if (c == '\n') {
819 if (L_ECHO(tty) || L_ECHONL(tty)) { 812 if (L_ECHO(tty) || L_ECHONL(tty)) {
820 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) 813 if (tty->read_cnt >= N_TTY_BUF_SIZE-1)
821 put_char('\a', tty); 814 tty_put_char(tty, '\a');
822 opost('\n', tty); 815 opost('\n', tty);
823 } 816 }
824 goto handle_newline; 817 goto handle_newline;
@@ -836,7 +829,7 @@ send_signal:
836 */ 829 */
837 if (L_ECHO(tty)) { 830 if (L_ECHO(tty)) {
838 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) 831 if (tty->read_cnt >= N_TTY_BUF_SIZE-1)
839 put_char('\a', tty); 832 tty_put_char(tty, '\a');
840 /* Record the column of first canon char. */ 833 /* Record the column of first canon char. */
841 if (tty->canon_head == tty->read_head) 834 if (tty->canon_head == tty->read_head)
842 tty->canon_column = tty->column; 835 tty->canon_column = tty->column;
@@ -866,7 +859,7 @@ handle_newline:
866 finish_erasing(tty); 859 finish_erasing(tty);
867 if (L_ECHO(tty)) { 860 if (L_ECHO(tty)) {
868 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { 861 if (tty->read_cnt >= N_TTY_BUF_SIZE-1) {
869 put_char('\a', tty); /* beep if no space */ 862 tty_put_char(tty, '\a'); /* beep if no space */
870 return; 863 return;
871 } 864 }
872 if (c == '\n') 865 if (c == '\n')
@@ -970,8 +963,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
970 break; 963 break;
971 } 964 }
972 } 965 }
973 if (tty->driver->flush_chars) 966 if (tty->ops->flush_chars)
974 tty->driver->flush_chars(tty); 967 tty->ops->flush_chars(tty);
975 } 968 }
976 969
977 n_tty_set_room(tty); 970 n_tty_set_room(tty);
@@ -987,12 +980,8 @@ static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
987 * mode. We don't want to throttle the driver if we're in 980 * mode. We don't want to throttle the driver if we're in
988 * canonical mode and don't have a newline yet! 981 * canonical mode and don't have a newline yet!
989 */ 982 */
990 if (tty->receive_room < TTY_THRESHOLD_THROTTLE) { 983 if (tty->receive_room < TTY_THRESHOLD_THROTTLE)
991 /* check TTY_THROTTLED first so it indicates our state */ 984 tty_throttle(tty);
992 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) &&
993 tty->driver->throttle)
994 tty->driver->throttle(tty);
995 }
996} 985}
997 986
998int is_ignored(int sig) 987int is_ignored(int sig)
@@ -1076,6 +1065,9 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
1076 tty->real_raw = 0; 1065 tty->real_raw = 0;
1077 } 1066 }
1078 n_tty_set_room(tty); 1067 n_tty_set_room(tty);
1068 /* The termios change make the tty ready for I/O */
1069 wake_up_interruptible(&tty->write_wait);
1070 wake_up_interruptible(&tty->read_wait);
1079} 1071}
1080 1072
1081/** 1073/**
@@ -1194,6 +1186,11 @@ extern ssize_t redirected_tty_write(struct file *, const char __user *,
1194 * Perform job control management checks on this file/tty descriptor 1186 * Perform job control management checks on this file/tty descriptor
1195 * and if appropriate send any needed signals and return a negative 1187 * and if appropriate send any needed signals and return a negative
1196 * error code if action should be taken. 1188 * error code if action should be taken.
1189 *
1190 * FIXME:
1191 * Locking: None - redirected write test is safe, testing
1192 * current->signal should possibly lock current->sighand
1193 * pgrp locking ?
1197 */ 1194 */
1198 1195
1199static int job_control(struct tty_struct *tty, struct file *file) 1196static int job_control(struct tty_struct *tty, struct file *file)
@@ -1246,6 +1243,7 @@ static ssize_t read_chan(struct tty_struct *tty, struct file *file,
1246 ssize_t size; 1243 ssize_t size;
1247 long timeout; 1244 long timeout;
1248 unsigned long flags; 1245 unsigned long flags;
1246 int packet;
1249 1247
1250do_it_again: 1248do_it_again:
1251 1249
@@ -1289,16 +1287,19 @@ do_it_again:
1289 if (mutex_lock_interruptible(&tty->atomic_read_lock)) 1287 if (mutex_lock_interruptible(&tty->atomic_read_lock))
1290 return -ERESTARTSYS; 1288 return -ERESTARTSYS;
1291 } 1289 }
1290 packet = tty->packet;
1292 1291
1293 add_wait_queue(&tty->read_wait, &wait); 1292 add_wait_queue(&tty->read_wait, &wait);
1294 while (nr) { 1293 while (nr) {
1295 /* First test for status change. */ 1294 /* First test for status change. */
1296 if (tty->packet && tty->link->ctrl_status) { 1295 if (packet && tty->link->ctrl_status) {
1297 unsigned char cs; 1296 unsigned char cs;
1298 if (b != buf) 1297 if (b != buf)
1299 break; 1298 break;
1299 spin_lock_irqsave(&tty->link->ctrl_lock, flags);
1300 cs = tty->link->ctrl_status; 1300 cs = tty->link->ctrl_status;
1301 tty->link->ctrl_status = 0; 1301 tty->link->ctrl_status = 0;
1302 spin_unlock_irqrestore(&tty->link->ctrl_lock, flags);
1302 if (tty_put_user(tty, cs, b++)) { 1303 if (tty_put_user(tty, cs, b++)) {
1303 retval = -EFAULT; 1304 retval = -EFAULT;
1304 b--; 1305 b--;
@@ -1333,6 +1334,7 @@ do_it_again:
1333 retval = -ERESTARTSYS; 1334 retval = -ERESTARTSYS;
1334 break; 1335 break;
1335 } 1336 }
1337 /* FIXME: does n_tty_set_room need locking ? */
1336 n_tty_set_room(tty); 1338 n_tty_set_room(tty);
1337 timeout = schedule_timeout(timeout); 1339 timeout = schedule_timeout(timeout);
1338 continue; 1340 continue;
@@ -1340,7 +1342,7 @@ do_it_again:
1340 __set_current_state(TASK_RUNNING); 1342 __set_current_state(TASK_RUNNING);
1341 1343
1342 /* Deal with packet mode. */ 1344 /* Deal with packet mode. */
1343 if (tty->packet && b == buf) { 1345 if (packet && b == buf) {
1344 if (tty_put_user(tty, TIOCPKT_DATA, b++)) { 1346 if (tty_put_user(tty, TIOCPKT_DATA, b++)) {
1345 retval = -EFAULT; 1347 retval = -EFAULT;
1346 b--; 1348 b--;
@@ -1388,6 +1390,8 @@ do_it_again:
1388 break; 1390 break;
1389 } else { 1391 } else {
1390 int uncopied; 1392 int uncopied;
1393 /* The copy function takes the read lock and handles
1394 locking internally for this case */
1391 uncopied = copy_from_read_buf(tty, &b, &nr); 1395 uncopied = copy_from_read_buf(tty, &b, &nr);
1392 uncopied += copy_from_read_buf(tty, &b, &nr); 1396 uncopied += copy_from_read_buf(tty, &b, &nr);
1393 if (uncopied) { 1397 if (uncopied) {
@@ -1429,7 +1433,6 @@ do_it_again:
1429 goto do_it_again; 1433 goto do_it_again;
1430 1434
1431 n_tty_set_room(tty); 1435 n_tty_set_room(tty);
1432
1433 return retval; 1436 return retval;
1434} 1437}
1435 1438
@@ -1492,11 +1495,11 @@ static ssize_t write_chan(struct tty_struct *tty, struct file *file,
1492 break; 1495 break;
1493 b++; nr--; 1496 b++; nr--;
1494 } 1497 }
1495 if (tty->driver->flush_chars) 1498 if (tty->ops->flush_chars)
1496 tty->driver->flush_chars(tty); 1499 tty->ops->flush_chars(tty);
1497 } else { 1500 } else {
1498 while (nr > 0) { 1501 while (nr > 0) {
1499 c = tty->driver->write(tty, b, nr); 1502 c = tty->ops->write(tty, b, nr);
1500 if (c < 0) { 1503 if (c < 0) {
1501 retval = c; 1504 retval = c;
1502 goto break_out; 1505 goto break_out;
@@ -1533,11 +1536,6 @@ break_out:
1533 * 1536 *
1534 * This code must be sure never to sleep through a hangup. 1537 * This code must be sure never to sleep through a hangup.
1535 * Called without the kernel lock held - fine 1538 * Called without the kernel lock held - fine
1536 *
1537 * FIXME: if someone changes the VMIN or discipline settings for the
1538 * terminal while another process is in poll() the poll does not
1539 * recompute the new limits. Possibly set_termios should issue
1540 * a read wakeup to fix this bug.
1541 */ 1539 */
1542 1540
1543static unsigned int normal_poll(struct tty_struct *tty, struct file *file, 1541static unsigned int normal_poll(struct tty_struct *tty, struct file *file,
@@ -1561,9 +1559,9 @@ static unsigned int normal_poll(struct tty_struct *tty, struct file *file,
1561 else 1559 else
1562 tty->minimum_to_wake = 1; 1560 tty->minimum_to_wake = 1;
1563 } 1561 }
1564 if (!tty_is_writelocked(tty) && 1562 if (tty->ops->write && !tty_is_writelocked(tty) &&
1565 tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS && 1563 tty_chars_in_buffer(tty) < WAKEUP_CHARS &&
1566 tty->driver->write_room(tty) > 0) 1564 tty_write_room(tty) > 0)
1567 mask |= POLLOUT | POLLWRNORM; 1565 mask |= POLLOUT | POLLWRNORM;
1568 return mask; 1566 return mask;
1569} 1567}
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c
index 6a6843a0a674..66a0f931c66c 100644
--- a/drivers/char/nozomi.c
+++ b/drivers/char/nozomi.c
@@ -73,7 +73,7 @@ do { \
73 char tmp[P_BUF_SIZE]; \ 73 char tmp[P_BUF_SIZE]; \
74 snprintf(tmp, sizeof(tmp), ##args); \ 74 snprintf(tmp, sizeof(tmp), ##args); \
75 printk(_err_flag_ "[%d] %s(): %s\n", __LINE__, \ 75 printk(_err_flag_ "[%d] %s(): %s\n", __LINE__, \
76 __FUNCTION__, tmp); \ 76 __func__, tmp); \
77} while (0) 77} while (0)
78 78
79#define DBG1(args...) D_(0x01, ##args) 79#define DBG1(args...) D_(0x01, ##args)
@@ -1407,7 +1407,7 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev,
1407 /* Find out what card type it is */ 1407 /* Find out what card type it is */
1408 nozomi_get_card_type(dc); 1408 nozomi_get_card_type(dc);
1409 1409
1410 dc->base_addr = ioremap(start, dc->card_type); 1410 dc->base_addr = ioremap_nocache(start, dc->card_type);
1411 if (!dc->base_addr) { 1411 if (!dc->base_addr) {
1412 dev_err(&pdev->dev, "Unable to map card MMIO\n"); 1412 dev_err(&pdev->dev, "Unable to map card MMIO\n");
1413 ret = -ENODEV; 1413 ret = -ENODEV;
@@ -1724,6 +1724,8 @@ static int ntty_tiocmget(struct tty_struct *tty, struct file *file)
1724 const struct ctrl_dl *ctrl_dl = &port->ctrl_dl; 1724 const struct ctrl_dl *ctrl_dl = &port->ctrl_dl;
1725 const struct ctrl_ul *ctrl_ul = &port->ctrl_ul; 1725 const struct ctrl_ul *ctrl_ul = &port->ctrl_ul;
1726 1726
1727 /* Note: these could change under us but it is not clear this
1728 matters if so */
1727 return (ctrl_ul->RTS ? TIOCM_RTS : 0) | 1729 return (ctrl_ul->RTS ? TIOCM_RTS : 0) |
1728 (ctrl_ul->DTR ? TIOCM_DTR : 0) | 1730 (ctrl_ul->DTR ? TIOCM_DTR : 0) |
1729 (ctrl_dl->DCD ? TIOCM_CAR : 0) | 1731 (ctrl_dl->DCD ? TIOCM_CAR : 0) |
@@ -1849,16 +1851,6 @@ static void ntty_throttle(struct tty_struct *tty)
1849 spin_unlock_irqrestore(&dc->spin_mutex, flags); 1851 spin_unlock_irqrestore(&dc->spin_mutex, flags);
1850} 1852}
1851 1853
1852/* just to discard single character writes */
1853static void ntty_put_char(struct tty_struct *tty, unsigned char c)
1854{
1855 /*
1856 * card does not react correct when we write single chars
1857 * to the card, so we discard them
1858 */
1859 DBG2("PUT CHAR Function: %c", c);
1860}
1861
1862/* Returns number of chars in buffer, called by tty layer */ 1854/* Returns number of chars in buffer, called by tty layer */
1863static s32 ntty_chars_in_buffer(struct tty_struct *tty) 1855static s32 ntty_chars_in_buffer(struct tty_struct *tty)
1864{ 1856{
@@ -1892,7 +1884,6 @@ static const struct tty_operations tty_ops = {
1892 .unthrottle = ntty_unthrottle, 1884 .unthrottle = ntty_unthrottle,
1893 .throttle = ntty_throttle, 1885 .throttle = ntty_throttle,
1894 .chars_in_buffer = ntty_chars_in_buffer, 1886 .chars_in_buffer = ntty_chars_in_buffer,
1895 .put_char = ntty_put_char,
1896 .tiocmget = ntty_tiocmget, 1887 .tiocmget = ntty_tiocmget,
1897 .tiocmset = ntty_tiocmset, 1888 .tiocmset = ntty_tiocmset,
1898}; 1889};
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 454d7324ba40..4a933d413423 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -53,7 +53,7 @@ module_param(pc_debug, int, 0600);
53#define DEBUGP(n, rdr, x, args...) do { \ 53#define DEBUGP(n, rdr, x, args...) do { \
54 if (pc_debug >= (n)) \ 54 if (pc_debug >= (n)) \
55 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \ 55 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
56 __FUNCTION__ , ## args); \ 56 __func__ , ## args); \
57 } while (0) 57 } while (0)
58#else 58#else
59#define DEBUGP(n, rdr, x, args...) 59#define DEBUGP(n, rdr, x, args...)
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 5f291bf739a6..035084c07329 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -47,7 +47,7 @@ module_param(pc_debug, int, 0600);
47#define DEBUGP(n, rdr, x, args...) do { \ 47#define DEBUGP(n, rdr, x, args...) do { \
48 if (pc_debug >= (n)) \ 48 if (pc_debug >= (n)) \
49 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \ 49 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
50 __FUNCTION__ , ##args); \ 50 __func__ , ##args); \
51 } while (0) 51 } while (0)
52#else 52#else
53#define DEBUGP(n, rdr, x, args...) 53#define DEBUGP(n, rdr, x, args...)
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 583356426dfb..1dd0e992c83d 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -503,20 +503,9 @@ static void* mgslpc_get_text_ptr(void)
503 * The wrappers maintain line discipline references 503 * The wrappers maintain line discipline references
504 * while calling into the line discipline. 504 * while calling into the line discipline.
505 * 505 *
506 * ldisc_flush_buffer - flush line discipline receive buffers
507 * ldisc_receive_buf - pass receive data to line discipline 506 * ldisc_receive_buf - pass receive data to line discipline
508 */ 507 */
509 508
510static void ldisc_flush_buffer(struct tty_struct *tty)
511{
512 struct tty_ldisc *ld = tty_ldisc_ref(tty);
513 if (ld) {
514 if (ld->flush_buffer)
515 ld->flush_buffer(tty);
516 tty_ldisc_deref(ld);
517 }
518}
519
520static void ldisc_receive_buf(struct tty_struct *tty, 509static void ldisc_receive_buf(struct tty_struct *tty,
521 const __u8 *data, char *flags, int count) 510 const __u8 *data, char *flags, int count)
522{ 511{
@@ -1556,7 +1545,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info)
1556 1545
1557/* Add a character to the transmit buffer 1546/* Add a character to the transmit buffer
1558 */ 1547 */
1559static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch) 1548static int mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
1560{ 1549{
1561 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data; 1550 MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
1562 unsigned long flags; 1551 unsigned long flags;
@@ -1567,10 +1556,10 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
1567 } 1556 }
1568 1557
1569 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char")) 1558 if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char"))
1570 return; 1559 return 0;
1571 1560
1572 if (!info->tx_buf) 1561 if (!info->tx_buf)
1573 return; 1562 return 0;
1574 1563
1575 spin_lock_irqsave(&info->lock,flags); 1564 spin_lock_irqsave(&info->lock,flags);
1576 1565
@@ -1583,6 +1572,7 @@ static void mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
1583 } 1572 }
1584 1573
1585 spin_unlock_irqrestore(&info->lock,flags); 1574 spin_unlock_irqrestore(&info->lock,flags);
1575 return 1;
1586} 1576}
1587 1577
1588/* Enable transmitter so remaining characters in the 1578/* Enable transmitter so remaining characters in the
@@ -2467,10 +2457,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
2467 if (info->flags & ASYNC_INITIALIZED) 2457 if (info->flags & ASYNC_INITIALIZED)
2468 mgslpc_wait_until_sent(tty, info->timeout); 2458 mgslpc_wait_until_sent(tty, info->timeout);
2469 2459
2470 if (tty->driver->flush_buffer) 2460 mgslpc_flush_buffer(tty);
2471 tty->driver->flush_buffer(tty);
2472 2461
2473 ldisc_flush_buffer(tty); 2462 tty_ldisc_flush(tty);
2474 2463
2475 shutdown(info); 2464 shutdown(info);
2476 2465
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 706ff34728f1..0a05c038ae6f 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -181,6 +181,7 @@ static int pty_set_lock(struct tty_struct *tty, int __user * arg)
181static void pty_flush_buffer(struct tty_struct *tty) 181static void pty_flush_buffer(struct tty_struct *tty)
182{ 182{
183 struct tty_struct *to = tty->link; 183 struct tty_struct *to = tty->link;
184 unsigned long flags;
184 185
185 if (!to) 186 if (!to)
186 return; 187 return;
@@ -189,8 +190,10 @@ static void pty_flush_buffer(struct tty_struct *tty)
189 to->ldisc.flush_buffer(to); 190 to->ldisc.flush_buffer(to);
190 191
191 if (to->packet) { 192 if (to->packet) {
193 spin_lock_irqsave(&tty->ctrl_lock, flags);
192 tty->ctrl_status |= TIOCPKT_FLUSHWRITE; 194 tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
193 wake_up_interruptible(&to->read_wait); 195 wake_up_interruptible(&to->read_wait);
196 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
194 } 197 }
195} 198}
196 199
@@ -251,6 +254,18 @@ static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
251static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 254static int legacy_count = CONFIG_LEGACY_PTY_COUNT;
252module_param(legacy_count, int, 0); 255module_param(legacy_count, int, 0);
253 256
257static const struct tty_operations pty_ops_bsd = {
258 .open = pty_open,
259 .close = pty_close,
260 .write = pty_write,
261 .write_room = pty_write_room,
262 .flush_buffer = pty_flush_buffer,
263 .chars_in_buffer = pty_chars_in_buffer,
264 .unthrottle = pty_unthrottle,
265 .set_termios = pty_set_termios,
266 .ioctl = pty_bsd_ioctl,
267};
268
254static void __init legacy_pty_init(void) 269static void __init legacy_pty_init(void)
255{ 270{
256 if (legacy_count <= 0) 271 if (legacy_count <= 0)
@@ -281,7 +296,6 @@ static void __init legacy_pty_init(void)
281 pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW; 296 pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
282 pty_driver->other = pty_slave_driver; 297 pty_driver->other = pty_slave_driver;
283 tty_set_operations(pty_driver, &pty_ops); 298 tty_set_operations(pty_driver, &pty_ops);
284 pty_driver->ioctl = pty_bsd_ioctl;
285 299
286 pty_slave_driver->owner = THIS_MODULE; 300 pty_slave_driver->owner = THIS_MODULE;
287 pty_slave_driver->driver_name = "pty_slave"; 301 pty_slave_driver->driver_name = "pty_slave";
@@ -374,6 +388,19 @@ static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
374 return -ENOIOCTLCMD; 388 return -ENOIOCTLCMD;
375} 389}
376 390
391static const struct tty_operations pty_unix98_ops = {
392 .open = pty_open,
393 .close = pty_close,
394 .write = pty_write,
395 .write_room = pty_write_room,
396 .flush_buffer = pty_flush_buffer,
397 .chars_in_buffer = pty_chars_in_buffer,
398 .unthrottle = pty_unthrottle,
399 .set_termios = pty_set_termios,
400 .ioctl = pty_unix98_ioctl
401};
402
403
377static void __init unix98_pty_init(void) 404static void __init unix98_pty_init(void)
378{ 405{
379 ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX); 406 ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
@@ -400,8 +427,7 @@ static void __init unix98_pty_init(void)
400 ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 427 ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
401 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM; 428 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM;
402 ptm_driver->other = pts_driver; 429 ptm_driver->other = pts_driver;
403 tty_set_operations(ptm_driver, &pty_ops); 430 tty_set_operations(ptm_driver, &pty_unix98_ops);
404 ptm_driver->ioctl = pty_unix98_ioctl;
405 431
406 pts_driver->owner = THIS_MODULE; 432 pts_driver->owner = THIS_MODULE;
407 pts_driver->driver_name = "pty_slave"; 433 pts_driver->driver_name = "pty_slave";
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index f4f837f86829..a03a538a3efb 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -43,83 +43,83 @@
43/* Bit fields for particular registers shared with driver */ 43/* Bit fields for particular registers shared with driver */
44 44
45/* COR1 - driver and RTA */ 45/* COR1 - driver and RTA */
46#define COR1_ODD 0x80 /* Odd parity */ 46#define RIOC_COR1_ODD 0x80 /* Odd parity */
47#define COR1_EVEN 0x00 /* Even parity */ 47#define RIOC_COR1_EVEN 0x00 /* Even parity */
48#define COR1_NOP 0x00 /* No parity */ 48#define RIOC_COR1_NOP 0x00 /* No parity */
49#define COR1_FORCE 0x20 /* Force parity */ 49#define RIOC_COR1_FORCE 0x20 /* Force parity */
50#define COR1_NORMAL 0x40 /* With parity */ 50#define RIOC_COR1_NORMAL 0x40 /* With parity */
51#define COR1_1STOP 0x00 /* 1 stop bit */ 51#define RIOC_COR1_1STOP 0x00 /* 1 stop bit */
52#define COR1_15STOP 0x04 /* 1.5 stop bits */ 52#define RIOC_COR1_15STOP 0x04 /* 1.5 stop bits */
53#define COR1_2STOP 0x08 /* 2 stop bits */ 53#define RIOC_COR1_2STOP 0x08 /* 2 stop bits */
54#define COR1_5BITS 0x00 /* 5 data bits */ 54#define RIOC_COR1_5BITS 0x00 /* 5 data bits */
55#define COR1_6BITS 0x01 /* 6 data bits */ 55#define RIOC_COR1_6BITS 0x01 /* 6 data bits */
56#define COR1_7BITS 0x02 /* 7 data bits */ 56#define RIOC_COR1_7BITS 0x02 /* 7 data bits */
57#define COR1_8BITS 0x03 /* 8 data bits */ 57#define RIOC_COR1_8BITS 0x03 /* 8 data bits */
58 58
59#define COR1_HOST 0xef /* Safe host bits */ 59#define RIOC_COR1_HOST 0xef /* Safe host bits */
60 60
61/* RTA only */ 61/* RTA only */
62#define COR1_CINPCK 0x00 /* Check parity of received characters */ 62#define RIOC_COR1_CINPCK 0x00 /* Check parity of received characters */
63#define COR1_CNINPCK 0x10 /* Don't check parity */ 63#define RIOC_COR1_CNINPCK 0x10 /* Don't check parity */
64 64
65/* COR2 bits for both RTA and driver use */ 65/* COR2 bits for both RTA and driver use */
66#define COR2_IXANY 0x80 /* IXANY - any character is XON */ 66#define RIOC_COR2_IXANY 0x80 /* IXANY - any character is XON */
67#define COR2_IXON 0x40 /* IXON - enable tx soft flowcontrol */ 67#define RIOC_COR2_IXON 0x40 /* IXON - enable tx soft flowcontrol */
68#define COR2_RTSFLOW 0x02 /* Enable tx hardware flow control */ 68#define RIOC_COR2_RTSFLOW 0x02 /* Enable tx hardware flow control */
69 69
70/* Additional driver bits */ 70/* Additional driver bits */
71#define COR2_HUPCL 0x20 /* Hang up on close */ 71#define RIOC_COR2_HUPCL 0x20 /* Hang up on close */
72#define COR2_CTSFLOW 0x04 /* Enable rx hardware flow control */ 72#define RIOC_COR2_CTSFLOW 0x04 /* Enable rx hardware flow control */
73#define COR2_IXOFF 0x01 /* Enable rx software flow control */ 73#define RIOC_COR2_IXOFF 0x01 /* Enable rx software flow control */
74#define COR2_DTRFLOW 0x08 /* Enable tx hardware flow control */ 74#define RIOC_COR2_DTRFLOW 0x08 /* Enable tx hardware flow control */
75 75
76/* RTA use only */ 76/* RTA use only */
77#define COR2_ETC 0x20 /* Embedded transmit options */ 77#define RIOC_COR2_ETC 0x20 /* Embedded transmit options */
78#define COR2_LOCAL 0x10 /* Local loopback mode */ 78#define RIOC_COR2_LOCAL 0x10 /* Local loopback mode */
79#define COR2_REMOTE 0x08 /* Remote loopback mode */ 79#define RIOC_COR2_REMOTE 0x08 /* Remote loopback mode */
80#define COR2_HOST 0xc2 /* Safe host bits */ 80#define RIOC_COR2_HOST 0xc2 /* Safe host bits */
81 81
82/* COR3 - RTA use only */ 82/* COR3 - RTA use only */
83#define COR3_SCDRNG 0x80 /* Enable special char detect for range */ 83#define RIOC_COR3_SCDRNG 0x80 /* Enable special char detect for range */
84#define COR3_SCD34 0x40 /* Special character detect for SCHR's 3 + 4 */ 84#define RIOC_COR3_SCD34 0x40 /* Special character detect for SCHR's 3 + 4 */
85#define COR3_FCT 0x20 /* Flow control transparency */ 85#define RIOC_COR3_FCT 0x20 /* Flow control transparency */
86#define COR3_SCD12 0x10 /* Special character detect for SCHR's 1 + 2 */ 86#define RIOC_COR3_SCD12 0x10 /* Special character detect for SCHR's 1 + 2 */
87#define COR3_FIFO12 0x0c /* 12 chars for receive FIFO threshold */ 87#define RIOC_COR3_FIFO12 0x0c /* 12 chars for receive FIFO threshold */
88#define COR3_FIFO10 0x0a /* 10 chars for receive FIFO threshold */ 88#define RIOC_COR3_FIFO10 0x0a /* 10 chars for receive FIFO threshold */
89#define COR3_FIFO8 0x08 /* 8 chars for receive FIFO threshold */ 89#define RIOC_COR3_FIFO8 0x08 /* 8 chars for receive FIFO threshold */
90#define COR3_FIFO6 0x06 /* 6 chars for receive FIFO threshold */ 90#define RIOC_COR3_FIFO6 0x06 /* 6 chars for receive FIFO threshold */
91 91
92#define COR3_THRESHOLD COR3_FIFO8 /* MUST BE LESS THAN MCOR_THRESHOLD */ 92#define RIOC_COR3_THRESHOLD RIOC_COR3_FIFO8 /* MUST BE LESS THAN MCOR_THRESHOLD */
93 93
94#define COR3_DEFAULT (COR3_FCT | COR3_THRESHOLD) 94#define RIOC_COR3_DEFAULT (RIOC_COR3_FCT | RIOC_COR3_THRESHOLD)
95 /* Default bits for COR3 */ 95 /* Default bits for COR3 */
96 96
97/* COR4 driver and RTA use */ 97/* COR4 driver and RTA use */
98#define COR4_IGNCR 0x80 /* Throw away CR's on input */ 98#define RIOC_COR4_IGNCR 0x80 /* Throw away CR's on input */
99#define COR4_ICRNL 0x40 /* Map CR -> NL on input */ 99#define RIOC_COR4_ICRNL 0x40 /* Map CR -> NL on input */
100#define COR4_INLCR 0x20 /* Map NL -> CR on input */ 100#define RIOC_COR4_INLCR 0x20 /* Map NL -> CR on input */
101#define COR4_IGNBRK 0x10 /* Ignore Break */ 101#define RIOC_COR4_IGNBRK 0x10 /* Ignore Break */
102#define COR4_NBRKINT 0x08 /* No interrupt on break (-BRKINT) */ 102#define RIOC_COR4_NBRKINT 0x08 /* No interrupt on break (-BRKINT) */
103#define COR4_RAISEMOD 0x01 /* Raise modem output lines on non-zero baud */ 103#define RIOC_COR4_RAISEMOD 0x01 /* Raise modem output lines on non-zero baud */
104 104
105 105
106/* COR4 driver only */ 106/* COR4 driver only */
107#define COR4_IGNPAR 0x04 /* IGNPAR (ignore characters with errors) */ 107#define RIOC_COR4_IGNPAR 0x04 /* IGNPAR (ignore characters with errors) */
108#define COR4_PARMRK 0x02 /* PARMRK */ 108#define RIOC_COR4_PARMRK 0x02 /* PARMRK */
109 109
110#define COR4_HOST 0xf8 /* Safe host bits */ 110#define RIOC_COR4_HOST 0xf8 /* Safe host bits */
111 111
112/* COR4 RTA only */ 112/* COR4 RTA only */
113#define COR4_CIGNPAR 0x02 /* Thrown away bad characters */ 113#define RIOC_COR4_CIGNPAR 0x02 /* Thrown away bad characters */
114#define COR4_CPARMRK 0x04 /* PARMRK characters */ 114#define RIOC_COR4_CPARMRK 0x04 /* PARMRK characters */
115#define COR4_CNPARMRK 0x03 /* Don't PARMRK */ 115#define RIOC_COR4_CNPARMRK 0x03 /* Don't PARMRK */
116 116
117/* COR5 driver and RTA use */ 117/* COR5 driver and RTA use */
118#define COR5_ISTRIP 0x80 /* Strip input chars to 7 bits */ 118#define RIOC_COR5_ISTRIP 0x80 /* Strip input chars to 7 bits */
119#define COR5_LNE 0x40 /* Enable LNEXT processing */ 119#define RIOC_COR5_LNE 0x40 /* Enable LNEXT processing */
120#define COR5_CMOE 0x20 /* Match good and errored characters */ 120#define RIOC_COR5_CMOE 0x20 /* Match good and errored characters */
121#define COR5_ONLCR 0x02 /* NL -> CR NL on output */ 121#define RIOC_COR5_ONLCR 0x02 /* NL -> CR NL on output */
122#define COR5_OCRNL 0x01 /* CR -> NL on output */ 122#define RIOC_COR5_OCRNL 0x01 /* CR -> NL on output */
123 123
124/* 124/*
125** Spare bits - these are not used in the CIRRUS registers, so we use 125** Spare bits - these are not used in the CIRRUS registers, so we use
@@ -128,86 +128,86 @@
128/* 128/*
129** tstop and tbusy indication 129** tstop and tbusy indication
130*/ 130*/
131#define COR5_TSTATE_ON 0x08 /* Turn on monitoring of tbusy and tstop */ 131#define RIOC_COR5_TSTATE_ON 0x08 /* Turn on monitoring of tbusy and tstop */
132#define COR5_TSTATE_OFF 0x04 /* Turn off monitoring of tbusy and tstop */ 132#define RIOC_COR5_TSTATE_OFF 0x04 /* Turn off monitoring of tbusy and tstop */
133/* 133/*
134** TAB3 134** TAB3
135*/ 135*/
136#define COR5_TAB3 0x10 /* TAB3 mode */ 136#define RIOC_COR5_TAB3 0x10 /* TAB3 mode */
137 137
138#define COR5_HOST 0xc3 /* Safe host bits */ 138#define RIOC_COR5_HOST 0xc3 /* Safe host bits */
139 139
140/* CCSR */ 140/* CCSR */
141#define CCSR_TXFLOFF 0x04 /* Tx is xoffed */ 141#define RIOC_CCSR_TXFLOFF 0x04 /* Tx is xoffed */
142 142
143/* MSVR1 */ 143/* MSVR1 */
144/* NB. DTR / CD swapped from Cirrus spec as the pins are also reversed on the 144/* NB. DTR / CD swapped from Cirrus spec as the pins are also reversed on the
145 RTA. This is because otherwise DCD would get lost on the 1 parallel / 3 145 RTA. This is because otherwise DCD would get lost on the 1 parallel / 3
146 serial option. 146 serial option.
147*/ 147*/
148#define MSVR1_CD 0x80 /* CD (DSR on Cirrus) */ 148#define RIOC_MSVR1_CD 0x80 /* CD (DSR on Cirrus) */
149#define MSVR1_RTS 0x40 /* RTS (CTS on Cirrus) */ 149#define RIOC_MSVR1_RTS 0x40 /* RTS (CTS on Cirrus) */
150#define MSVR1_RI 0x20 /* RI */ 150#define RIOC_MSVR1_RI 0x20 /* RI */
151#define MSVR1_DTR 0x10 /* DTR (CD on Cirrus) */ 151#define RIOC_MSVR1_DTR 0x10 /* DTR (CD on Cirrus) */
152#define MSVR1_CTS 0x01 /* CTS output pin (RTS on Cirrus) */ 152#define RIOC_MSVR1_CTS 0x01 /* CTS output pin (RTS on Cirrus) */
153/* Next two used to indicate state of tbusy and tstop to driver */ 153/* Next two used to indicate state of tbusy and tstop to driver */
154#define MSVR1_TSTOP 0x08 /* Set if port flow controlled */ 154#define RIOC_MSVR1_TSTOP 0x08 /* Set if port flow controlled */
155#define MSVR1_TEMPTY 0x04 /* Set if port tx buffer empty */ 155#define RIOC_MSVR1_TEMPTY 0x04 /* Set if port tx buffer empty */
156 156
157#define MSVR1_HOST 0xf3 /* The bits the host wants */ 157#define RIOC_MSVR1_HOST 0xf3 /* The bits the host wants */
158 158
159/* Defines for the subscripts of a CONFIG packet */ 159/* Defines for the subscripts of a CONFIG packet */
160#define CONFIG_COR1 1 /* Option register 1 */ 160#define RIOC_CONFIG_COR1 1 /* Option register 1 */
161#define CONFIG_COR2 2 /* Option register 2 */ 161#define RIOC_CONFIG_COR2 2 /* Option register 2 */
162#define CONFIG_COR4 3 /* Option register 4 */ 162#define RIOC_CONFIG_COR4 3 /* Option register 4 */
163#define CONFIG_COR5 4 /* Option register 5 */ 163#define RIOC_CONFIG_COR5 4 /* Option register 5 */
164#define CONFIG_TXXON 5 /* Tx XON character */ 164#define RIOC_CONFIG_TXXON 5 /* Tx XON character */
165#define CONFIG_TXXOFF 6 /* Tx XOFF character */ 165#define RIOC_CONFIG_TXXOFF 6 /* Tx XOFF character */
166#define CONFIG_RXXON 7 /* Rx XON character */ 166#define RIOC_CONFIG_RXXON 7 /* Rx XON character */
167#define CONFIG_RXXOFF 8 /* Rx XOFF character */ 167#define RIOC_CONFIG_RXXOFF 8 /* Rx XOFF character */
168#define CONFIG_LNEXT 9 /* LNEXT character */ 168#define RIOC_CONFIG_LNEXT 9 /* LNEXT character */
169#define CONFIG_TXBAUD 10 /* Tx baud rate */ 169#define RIOC_CONFIG_TXBAUD 10 /* Tx baud rate */
170#define CONFIG_RXBAUD 11 /* Rx baud rate */ 170#define RIOC_CONFIG_RXBAUD 11 /* Rx baud rate */
171 171
172#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */ 172#define RIOC_PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
173 173
174/* Packet types going from Host to remote - with the exception of OPEN, MOPEN, 174/* Packet types going from Host to remote - with the exception of OPEN, MOPEN,
175 CONFIG, SBREAK and MEMDUMP the remaining bytes of the data array will not 175 CONFIG, SBREAK and MEMDUMP the remaining bytes of the data array will not
176 be used 176 be used
177*/ 177*/
178#define OPEN 0x00 /* Open a port */ 178#define RIOC_OPEN 0x00 /* Open a port */
179#define CONFIG 0x01 /* Configure a port */ 179#define RIOC_CONFIG 0x01 /* Configure a port */
180#define MOPEN 0x02 /* Modem open (block for DCD) */ 180#define RIOC_MOPEN 0x02 /* Modem open (block for DCD) */
181#define CLOSE 0x03 /* Close a port */ 181#define RIOC_CLOSE 0x03 /* Close a port */
182#define WFLUSH (0x04 | PRE_EMPTIVE) /* Write flush */ 182#define RIOC_WFLUSH (0x04 | RIOC_PRE_EMPTIVE) /* Write flush */
183#define RFLUSH (0x05 | PRE_EMPTIVE) /* Read flush */ 183#define RIOC_RFLUSH (0x05 | RIOC_PRE_EMPTIVE) /* Read flush */
184#define RESUME (0x06 | PRE_EMPTIVE) /* Resume if xoffed */ 184#define RIOC_RESUME (0x06 | RIOC_PRE_EMPTIVE) /* Resume if xoffed */
185#define SBREAK 0x07 /* Start break */ 185#define RIOC_SBREAK 0x07 /* Start break */
186#define EBREAK 0x08 /* End break */ 186#define RIOC_EBREAK 0x08 /* End break */
187#define SUSPEND (0x09 | PRE_EMPTIVE) /* Susp op (behave as tho xoffed) */ 187#define RIOC_SUSPEND (0x09 | RIOC_PRE_EMPTIVE) /* Susp op (behave as tho xoffed) */
188#define FCLOSE (0x0a | PRE_EMPTIVE) /* Force close */ 188#define RIOC_FCLOSE (0x0a | RIOC_PRE_EMPTIVE) /* Force close */
189#define XPRINT 0x0b /* Xprint packet */ 189#define RIOC_XPRINT 0x0b /* Xprint packet */
190#define MBIS (0x0c | PRE_EMPTIVE) /* Set modem lines */ 190#define RIOC_MBIS (0x0c | RIOC_PRE_EMPTIVE) /* Set modem lines */
191#define MBIC (0x0d | PRE_EMPTIVE) /* Clear modem lines */ 191#define RIOC_MBIC (0x0d | RIOC_PRE_EMPTIVE) /* Clear modem lines */
192#define MSET (0x0e | PRE_EMPTIVE) /* Set modem lines */ 192#define RIOC_MSET (0x0e | RIOC_PRE_EMPTIVE) /* Set modem lines */
193#define PCLOSE 0x0f /* Pseudo close - Leaves rx/tx enabled */ 193#define RIOC_PCLOSE 0x0f /* Pseudo close - Leaves rx/tx enabled */
194#define MGET (0x10 | PRE_EMPTIVE) /* Force update of modem status */ 194#define RIOC_MGET (0x10 | RIOC_PRE_EMPTIVE) /* Force update of modem status */
195#define MEMDUMP (0x11 | PRE_EMPTIVE) /* Send back mem from addr supplied */ 195#define RIOC_MEMDUMP (0x11 | RIOC_PRE_EMPTIVE) /* Send back mem from addr supplied */
196#define READ_REGISTER (0x12 | PRE_EMPTIVE) /* Read CD1400 register (debug) */ 196#define RIOC_READ_REGISTER (0x12 | RIOC_PRE_EMPTIVE) /* Read CD1400 register (debug) */
197 197
198/* "Command" packets going from remote to host COMPLETE and MODEM_STATUS 198/* "Command" packets going from remote to host COMPLETE and MODEM_STATUS
199 use data[4] / data[3] to indicate current state and modem status respectively 199 use data[4] / data[3] to indicate current state and modem status respectively
200*/ 200*/
201 201
202#define COMPLETE (0x20 | PRE_EMPTIVE) 202#define RIOC_COMPLETE (0x20 | RIOC_PRE_EMPTIVE)
203 /* Command complete */ 203 /* Command complete */
204#define BREAK_RECEIVED (0x21 | PRE_EMPTIVE) 204#define RIOC_BREAK_RECEIVED (0x21 | RIOC_PRE_EMPTIVE)
205 /* Break received */ 205 /* Break received */
206#define MODEM_STATUS (0x22 | PRE_EMPTIVE) 206#define RIOC_MODEM_STATUS (0x22 | RIOC_PRE_EMPTIVE)
207 /* Change in modem status */ 207 /* Change in modem status */
208 208
209/* "Command" packet that could go either way - handshake wake-up */ 209/* "Command" packet that could go either way - handshake wake-up */
210#define HANDSHAKE (0x23 | PRE_EMPTIVE) 210#define RIOC_HANDSHAKE (0x23 | RIOC_PRE_EMPTIVE)
211 /* Wake-up to HOST / RTA */ 211 /* Wake-up to HOST / RTA */
212 212
213#endif 213#endif
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 0ce96670f979..412777cd1e68 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -344,7 +344,7 @@ int rio_minor(struct tty_struct *tty)
344 344
345static int rio_set_real_termios(void *ptr) 345static int rio_set_real_termios(void *ptr)
346{ 346{
347 return RIOParam((struct Port *) ptr, CONFIG, 1, 1); 347 return RIOParam((struct Port *) ptr, RIOC_CONFIG, 1, 1);
348} 348}
349 349
350 350
@@ -487,7 +487,7 @@ static int rio_get_CD(void *ptr)
487 int rv; 487 int rv;
488 488
489 func_enter(); 489 func_enter();
490 rv = (PortP->ModemState & MSVR1_CD) != 0; 490 rv = (PortP->ModemState & RIOC_MSVR1_CD) != 0;
491 491
492 rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv); 492 rio_dprintk(RIO_DEBUG_INIT, "Getting CD status: %d\n", rv);
493 493
@@ -607,7 +607,8 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
607 rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n"); 607 rio_dprintk(RIO_DEBUG_TTY, "BREAK on deleted RTA\n");
608 rc = -EIO; 608 rc = -EIO;
609 } else { 609 } else {
610 if (RIOShortCommand(p, PortP, SBREAK, 2, 250) == RIO_FAIL) { 610 if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2, 250) ==
611 RIO_FAIL) {
611 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); 612 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
612 rc = -EIO; 613 rc = -EIO;
613 } 614 }
@@ -622,7 +623,8 @@ static int rio_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd
622 l = arg ? arg * 100 : 250; 623 l = arg ? arg * 100 : 250;
623 if (l > 255) 624 if (l > 255)
624 l = 255; 625 l = 255;
625 if (RIOShortCommand(p, PortP, SBREAK, 2, arg ? arg * 100 : 250) == RIO_FAIL) { 626 if (RIOShortCommand(p, PortP, RIOC_SBREAK, 2,
627 arg ? arg * 100 : 250) == RIO_FAIL) {
626 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n"); 628 rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
627 rc = -EIO; 629 rc = -EIO;
628 } 630 }
diff --git a/drivers/char/rio/rio_linux.h b/drivers/char/rio/rio_linux.h
index dc3f005614a3..7f26cd7c815e 100644
--- a/drivers/char/rio/rio_linux.h
+++ b/drivers/char/rio/rio_linux.h
@@ -186,9 +186,9 @@ static inline void *rio_memcpy_fromio(void *dest, void __iomem *source, int n)
186 186
187#ifdef DEBUG 187#ifdef DEBUG
188#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0) 188#define rio_dprintk(f, str...) do { if (rio_debug & f) printk (str);} while (0)
189#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __FUNCTION__) 189#define func_enter() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s\n", __func__)
190#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __FUNCTION__) 190#define func_exit() rio_dprintk (RIO_DEBUG_FLOW, "rio: exit %s\n", __func__)
191#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__FUNCTION__, port->line) 191#define func_enter2() rio_dprintk (RIO_DEBUG_FLOW, "rio: enter %s (port %d)\n",__func__, port->line)
192#else 192#else
193#define rio_dprintk(f, str...) /* nothing */ 193#define rio_dprintk(f, str...) /* nothing */
194#define func_enter() 194#define func_enter()
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index bf36959fc121..7b96e0814887 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -417,7 +417,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
417 PortP = p->RIOPortp[SysPort]; 417 PortP = p->RIOPortp[SysPort];
418 rio_spin_lock_irqsave(&PortP->portSem, flags); 418 rio_spin_lock_irqsave(&PortP->portSem, flags);
419 switch (readb(&PktCmdP->Command)) { 419 switch (readb(&PktCmdP->Command)) {
420 case BREAK_RECEIVED: 420 case RIOC_BREAK_RECEIVED:
421 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n"); 421 rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
422 /* If the current line disc. is not multi-threading and 422 /* If the current line disc. is not multi-threading and
423 the current processor is not the default, reset rup_intr 423 the current processor is not the default, reset rup_intr
@@ -428,16 +428,16 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
428 gs_got_break(&PortP->gs); 428 gs_got_break(&PortP->gs);
429 break; 429 break;
430 430
431 case COMPLETE: 431 case RIOC_COMPLETE:
432 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts); 432 rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
433 subCommand = 1; 433 subCommand = 1;
434 switch (readb(&PktCmdP->SubCommand)) { 434 switch (readb(&PktCmdP->SubCommand)) {
435 case MEMDUMP: 435 case RIOC_MEMDUMP:
436 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr)); 436 rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
437 break; 437 break;
438 case READ_REGISTER: 438 case RIOC_READ_REGISTER:
439 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr)); 439 rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
440 p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST); 440 p->CdRegister = (readb(&PktCmdP->ModemStatus) & RIOC_MSVR1_HOST);
441 break; 441 break;
442 default: 442 default:
443 subCommand = 0; 443 subCommand = 0;
@@ -456,14 +456,15 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
456 rio_dprintk(RIO_DEBUG_CMD, "No change\n"); 456 rio_dprintk(RIO_DEBUG_CMD, "No change\n");
457 457
458 /* FALLTHROUGH */ 458 /* FALLTHROUGH */
459 case MODEM_STATUS: 459 case RIOC_MODEM_STATUS:
460 /* 460 /*
461 ** Knock out the tbusy and tstop bits, as these are not relevant 461 ** Knock out the tbusy and tstop bits, as these are not relevant
462 ** to the check for modem status change (they're just there because 462 ** to the check for modem status change (they're just there because
463 ** it's a convenient place to put them!). 463 ** it's a convenient place to put them!).
464 */ 464 */
465 ReportedModemStatus = readb(&PktCmdP->ModemStatus); 465 ReportedModemStatus = readb(&PktCmdP->ModemStatus);
466 if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) { 466 if ((PortP->ModemState & RIOC_MSVR1_HOST) ==
467 (ReportedModemStatus & RIOC_MSVR1_HOST)) {
467 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState); 468 rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
468 /* 469 /*
469 ** Update ModemState just in case tbusy or tstop states have 470 ** Update ModemState just in case tbusy or tstop states have
@@ -497,7 +498,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struc
497 /* 498 /*
498 ** Is there a carrier? 499 ** Is there a carrier?
499 */ 500 */
500 if (PortP->ModemState & MSVR1_CD) { 501 if (PortP->ModemState & RIOC_MSVR1_CD) {
501 /* 502 /*
502 ** Has carrier just appeared? 503 ** Has carrier just appeared?
503 */ 504 */
@@ -691,7 +692,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
691 */ 692 */
692 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags); 693 rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
693 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP); 694 FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
694 if (readb(&PacketP->data[5]) == MEMDUMP) { 695 if (readb(&PacketP->data[5]) == RIOC_MEMDUMP) {
695 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6]))); 696 rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", readw(&(PacketP->data[6])));
696 rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32); 697 rio_memcpy_fromio(p->RIOMemDump, &(PacketP->data[8]), 32);
697 } 698 }
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index d8eb2bcbe015..d65ceb9a434a 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -422,7 +422,8 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
422 } 422 }
423 423
424 rio_spin_lock_irqsave(&PortP->portSem, flags); 424 rio_spin_lock_irqsave(&PortP->portSem, flags);
425 if (RIOPreemptiveCmd(p, (p->RIOPortp[port]), RESUME) == RIO_FAIL) { 425 if (RIOPreemptiveCmd(p, (p->RIOPortp[port]), RIOC_RESUME) ==
426 RIO_FAIL) {
426 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME failed\n"); 427 rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME failed\n");
427 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 428 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
428 return -EBUSY; 429 return -EBUSY;
@@ -636,7 +637,8 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
636 return -ENXIO; 637 return -ENXIO;
637 } 638 }
638 PortP = (p->RIOPortp[PortTty.port]); 639 PortP = (p->RIOPortp[PortTty.port]);
639 RIOParam(PortP, CONFIG, PortP->State & RIO_MODEM, OK_TO_SLEEP); 640 RIOParam(PortP, RIOC_CONFIG, PortP->State & RIO_MODEM,
641 OK_TO_SLEEP);
640 return retval; 642 return retval;
641 643
642 case RIO_SET_PORT_PARAMS: 644 case RIO_SET_PORT_PARAMS:
@@ -1247,7 +1249,7 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
1247 1249
1248 rio_spin_lock_irqsave(&PortP->portSem, flags); 1250 rio_spin_lock_irqsave(&PortP->portSem, flags);
1249 1251
1250 if (RIOPreemptiveCmd(p, PortP, MEMDUMP) == RIO_FAIL) { 1252 if (RIOPreemptiveCmd(p, PortP, RIOC_MEMDUMP) == RIO_FAIL) {
1251 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP failed\n"); 1253 rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP failed\n");
1252 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1254 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1253 return -EBUSY; 1255 return -EBUSY;
@@ -1313,7 +1315,8 @@ int riocontrol(struct rio_info *p, dev_t dev, int cmd, unsigned long arg, int su
1313 1315
1314 rio_spin_lock_irqsave(&PortP->portSem, flags); 1316 rio_spin_lock_irqsave(&PortP->portSem, flags);
1315 1317
1316 if (RIOPreemptiveCmd(p, PortP, READ_REGISTER) == RIO_FAIL) { 1318 if (RIOPreemptiveCmd(p, PortP, RIOC_READ_REGISTER) ==
1319 RIO_FAIL) {
1317 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER failed\n"); 1320 rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER failed\n");
1318 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 1321 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
1319 return -EBUSY; 1322 return -EBUSY;
@@ -1434,50 +1437,50 @@ int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
1434 PktCmdP->PhbNum = port; 1437 PktCmdP->PhbNum = port;
1435 1438
1436 switch (Cmd) { 1439 switch (Cmd) {
1437 case MEMDUMP: 1440 case RIOC_MEMDUMP:
1438 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p " 1441 rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p "
1439 "(addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr); 1442 "(addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
1440 PktCmdP->SubCommand = MEMDUMP; 1443 PktCmdP->SubCommand = RIOC_MEMDUMP;
1441 PktCmdP->SubAddr = SubCmd.Addr; 1444 PktCmdP->SubAddr = SubCmd.Addr;
1442 break; 1445 break;
1443 case FCLOSE: 1446 case RIOC_FCLOSE:
1444 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", 1447 rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n",
1445 CmdBlkP); 1448 CmdBlkP);
1446 break; 1449 break;
1447 case READ_REGISTER: 1450 case RIOC_READ_REGISTER:
1448 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) " 1451 rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) "
1449 "command blk %p\n", (int) SubCmd.Addr, CmdBlkP); 1452 "command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
1450 PktCmdP->SubCommand = READ_REGISTER; 1453 PktCmdP->SubCommand = RIOC_READ_REGISTER;
1451 PktCmdP->SubAddr = SubCmd.Addr; 1454 PktCmdP->SubAddr = SubCmd.Addr;
1452 break; 1455 break;
1453 case RESUME: 1456 case RIOC_RESUME:
1454 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", 1457 rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n",
1455 CmdBlkP); 1458 CmdBlkP);
1456 break; 1459 break;
1457 case RFLUSH: 1460 case RIOC_RFLUSH:
1458 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", 1461 rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n",
1459 CmdBlkP); 1462 CmdBlkP);
1460 CmdBlkP->PostFuncP = RIORFlushEnable; 1463 CmdBlkP->PostFuncP = RIORFlushEnable;
1461 break; 1464 break;
1462 case SUSPEND: 1465 case RIOC_SUSPEND:
1463 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", 1466 rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n",
1464 CmdBlkP); 1467 CmdBlkP);
1465 break; 1468 break;
1466 1469
1467 case MGET: 1470 case RIOC_MGET:
1468 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", 1471 rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n",
1469 CmdBlkP); 1472 CmdBlkP);
1470 break; 1473 break;
1471 1474
1472 case MSET: 1475 case RIOC_MSET:
1473 case MBIC: 1476 case RIOC_MBIC:
1474 case MBIS: 1477 case RIOC_MBIS:
1475 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines; 1478 CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
1476 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command " 1479 rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command "
1477 "blk %p\n", CmdBlkP); 1480 "blk %p\n", CmdBlkP);
1478 break; 1481 break;
1479 1482
1480 case WFLUSH: 1483 case RIOC_WFLUSH:
1481 /* 1484 /*
1482 ** If we have queued up the maximum number of Write flushes 1485 ** If we have queued up the maximum number of Write flushes
1483 ** allowed then we should not bother sending any more to the 1486 ** allowed then we should not bother sending any more to the
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 4734e26e1ccd..ea21686c69a4 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -401,9 +401,8 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
401 PortP->InUse = NOT_INUSE; 401 PortP->InUse = NOT_INUSE;
402 402
403 rio_spin_unlock(&PortP->portSem); 403 rio_spin_unlock(&PortP->portSem);
404 if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) { 404 if (RIOParam(PortP, RIOC_OPEN, ((PortP->Cor2Copy & (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) == (RIOC_COR2_RTSFLOW | RIOC_COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL)
405 continue; /* with next port */ 405 continue; /* with next port */
406 }
407 rio_spin_lock(&PortP->portSem); 406 rio_spin_lock(&PortP->portSem);
408 PortP->MagicFlags &= ~MAGIC_REBOOT; 407 PortP->MagicFlags &= ~MAGIC_REBOOT;
409 } 408 }
@@ -429,7 +428,7 @@ void RIOServiceHost(struct rio_info *p, struct Host *HostP)
429 */ 428 */
430 PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0]; 429 PktCmdP = (struct PktCmd __iomem *) &PacketP->data[0];
431 430
432 writeb(WFLUSH, &PktCmdP->Command); 431 writeb(RIOC_WFLUSH, &PktCmdP->Command);
433 432
434 p = PortP->HostPort % (u16) PORTS_PER_RTA; 433 p = PortP->HostPort % (u16) PORTS_PER_RTA;
435 434
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index da276ed57b3f..4810b845cc21 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -177,7 +177,7 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
177 } 177 }
178 rio_spin_lock_irqsave(&PortP->portSem, flags); 178 rio_spin_lock_irqsave(&PortP->portSem, flags);
179 179
180 if (cmd == OPEN) { 180 if (cmd == RIOC_OPEN) {
181 /* 181 /*
182 ** If the port is set to store or lock the parameters, and it is 182 ** If the port is set to store or lock the parameters, and it is
183 ** paramed with OPEN, we want to restore the saved port termio, but 183 ** paramed with OPEN, we want to restore the saved port termio, but
@@ -241,50 +241,50 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
241 case CS5: 241 case CS5:
242 { 242 {
243 rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n"); 243 rio_dprintk(RIO_DEBUG_PARAM, "5 bit data\n");
244 Cor1 |= COR1_5BITS; 244 Cor1 |= RIOC_COR1_5BITS;
245 break; 245 break;
246 } 246 }
247 case CS6: 247 case CS6:
248 { 248 {
249 rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n"); 249 rio_dprintk(RIO_DEBUG_PARAM, "6 bit data\n");
250 Cor1 |= COR1_6BITS; 250 Cor1 |= RIOC_COR1_6BITS;
251 break; 251 break;
252 } 252 }
253 case CS7: 253 case CS7:
254 { 254 {
255 rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n"); 255 rio_dprintk(RIO_DEBUG_PARAM, "7 bit data\n");
256 Cor1 |= COR1_7BITS; 256 Cor1 |= RIOC_COR1_7BITS;
257 break; 257 break;
258 } 258 }
259 case CS8: 259 case CS8:
260 { 260 {
261 rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n"); 261 rio_dprintk(RIO_DEBUG_PARAM, "8 bit data\n");
262 Cor1 |= COR1_8BITS; 262 Cor1 |= RIOC_COR1_8BITS;
263 break; 263 break;
264 } 264 }
265 } 265 }
266 266
267 if (TtyP->termios->c_cflag & CSTOPB) { 267 if (TtyP->termios->c_cflag & CSTOPB) {
268 rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n"); 268 rio_dprintk(RIO_DEBUG_PARAM, "2 stop bits\n");
269 Cor1 |= COR1_2STOP; 269 Cor1 |= RIOC_COR1_2STOP;
270 } else { 270 } else {
271 rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n"); 271 rio_dprintk(RIO_DEBUG_PARAM, "1 stop bit\n");
272 Cor1 |= COR1_1STOP; 272 Cor1 |= RIOC_COR1_1STOP;
273 } 273 }
274 274
275 if (TtyP->termios->c_cflag & PARENB) { 275 if (TtyP->termios->c_cflag & PARENB) {
276 rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n"); 276 rio_dprintk(RIO_DEBUG_PARAM, "Enable parity\n");
277 Cor1 |= COR1_NORMAL; 277 Cor1 |= RIOC_COR1_NORMAL;
278 } else { 278 } else {
279 rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n"); 279 rio_dprintk(RIO_DEBUG_PARAM, "Disable parity\n");
280 Cor1 |= COR1_NOP; 280 Cor1 |= RIOC_COR1_NOP;
281 } 281 }
282 if (TtyP->termios->c_cflag & PARODD) { 282 if (TtyP->termios->c_cflag & PARODD) {
283 rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n"); 283 rio_dprintk(RIO_DEBUG_PARAM, "Odd parity\n");
284 Cor1 |= COR1_ODD; 284 Cor1 |= RIOC_COR1_ODD;
285 } else { 285 } else {
286 rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n"); 286 rio_dprintk(RIO_DEBUG_PARAM, "Even parity\n");
287 Cor1 |= COR1_EVEN; 287 Cor1 |= RIOC_COR1_EVEN;
288 } 288 }
289 289
290 /* 290 /*
@@ -292,11 +292,11 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
292 */ 292 */
293 if (TtyP->termios->c_iflag & IXON) { 293 if (TtyP->termios->c_iflag & IXON) {
294 rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n"); 294 rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop output control\n");
295 Cor2 |= COR2_IXON; 295 Cor2 |= RIOC_COR2_IXON;
296 } else { 296 } else {
297 if (PortP->Config & RIO_IXON) { 297 if (PortP->Config & RIO_IXON) {
298 rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n"); 298 rio_dprintk(RIO_DEBUG_PARAM, "Force enable start/stop output control\n");
299 Cor2 |= COR2_IXON; 299 Cor2 |= RIOC_COR2_IXON;
300 } else 300 } else
301 rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n"); 301 rio_dprintk(RIO_DEBUG_PARAM, "IXON has been disabled.\n");
302 } 302 }
@@ -304,29 +304,29 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
304 if (TtyP->termios->c_iflag & IXANY) { 304 if (TtyP->termios->c_iflag & IXANY) {
305 if (PortP->Config & RIO_IXANY) { 305 if (PortP->Config & RIO_IXANY) {
306 rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n"); 306 rio_dprintk(RIO_DEBUG_PARAM, "Enable any key to restart output\n");
307 Cor2 |= COR2_IXANY; 307 Cor2 |= RIOC_COR2_IXANY;
308 } else 308 } else
309 rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n"); 309 rio_dprintk(RIO_DEBUG_PARAM, "IXANY has been disabled due to sanity reasons.\n");
310 } 310 }
311 311
312 if (TtyP->termios->c_iflag & IXOFF) { 312 if (TtyP->termios->c_iflag & IXOFF) {
313 rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n"); 313 rio_dprintk(RIO_DEBUG_PARAM, "Enable start/stop input control 2\n");
314 Cor2 |= COR2_IXOFF; 314 Cor2 |= RIOC_COR2_IXOFF;
315 } 315 }
316 316
317 if (TtyP->termios->c_cflag & HUPCL) { 317 if (TtyP->termios->c_cflag & HUPCL) {
318 rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n"); 318 rio_dprintk(RIO_DEBUG_PARAM, "Hangup on last close\n");
319 Cor2 |= COR2_HUPCL; 319 Cor2 |= RIOC_COR2_HUPCL;
320 } 320 }
321 321
322 if (C_CRTSCTS(TtyP)) { 322 if (C_CRTSCTS(TtyP)) {
323 rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n"); 323 rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control enabled\n");
324 Cor2 |= COR2_CTSFLOW; 324 Cor2 |= RIOC_COR2_CTSFLOW;
325 Cor2 |= COR2_RTSFLOW; 325 Cor2 |= RIOC_COR2_RTSFLOW;
326 } else { 326 } else {
327 rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n"); 327 rio_dprintk(RIO_DEBUG_PARAM, "Rx hardware flow control disabled\n");
328 Cor2 &= ~COR2_CTSFLOW; 328 Cor2 &= ~RIOC_COR2_CTSFLOW;
329 Cor2 &= ~COR2_RTSFLOW; 329 Cor2 &= ~RIOC_COR2_RTSFLOW;
330 } 330 }
331 331
332 332
@@ -341,36 +341,36 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
341 */ 341 */
342 if (TtyP->termios->c_iflag & IGNBRK) { 342 if (TtyP->termios->c_iflag & IGNBRK) {
343 rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n"); 343 rio_dprintk(RIO_DEBUG_PARAM, "Ignore break condition\n");
344 Cor4 |= COR4_IGNBRK; 344 Cor4 |= RIOC_COR4_IGNBRK;
345 } 345 }
346 if (!(TtyP->termios->c_iflag & BRKINT)) { 346 if (!(TtyP->termios->c_iflag & BRKINT)) {
347 rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n"); 347 rio_dprintk(RIO_DEBUG_PARAM, "Break generates NULL condition\n");
348 Cor4 |= COR4_NBRKINT; 348 Cor4 |= RIOC_COR4_NBRKINT;
349 } else { 349 } else {
350 rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n"); 350 rio_dprintk(RIO_DEBUG_PARAM, "Interrupt on break condition\n");
351 } 351 }
352 352
353 if (TtyP->termios->c_iflag & INLCR) { 353 if (TtyP->termios->c_iflag & INLCR) {
354 rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n"); 354 rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage return on input\n");
355 Cor4 |= COR4_INLCR; 355 Cor4 |= RIOC_COR4_INLCR;
356 } 356 }
357 357
358 if (TtyP->termios->c_iflag & IGNCR) { 358 if (TtyP->termios->c_iflag & IGNCR) {
359 rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n"); 359 rio_dprintk(RIO_DEBUG_PARAM, "Ignore carriage return on input\n");
360 Cor4 |= COR4_IGNCR; 360 Cor4 |= RIOC_COR4_IGNCR;
361 } 361 }
362 362
363 if (TtyP->termios->c_iflag & ICRNL) { 363 if (TtyP->termios->c_iflag & ICRNL) {
364 rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n"); 364 rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on input\n");
365 Cor4 |= COR4_ICRNL; 365 Cor4 |= RIOC_COR4_ICRNL;
366 } 366 }
367 if (TtyP->termios->c_iflag & IGNPAR) { 367 if (TtyP->termios->c_iflag & IGNPAR) {
368 rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n"); 368 rio_dprintk(RIO_DEBUG_PARAM, "Ignore characters with parity errors\n");
369 Cor4 |= COR4_IGNPAR; 369 Cor4 |= RIOC_COR4_IGNPAR;
370 } 370 }
371 if (TtyP->termios->c_iflag & PARMRK) { 371 if (TtyP->termios->c_iflag & PARMRK) {
372 rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n"); 372 rio_dprintk(RIO_DEBUG_PARAM, "Mark parity errors\n");
373 Cor4 |= COR4_PARMRK; 373 Cor4 |= RIOC_COR4_PARMRK;
374 } 374 }
375 375
376 /* 376 /*
@@ -378,22 +378,22 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
378 ** on reception of a config packet. 378 ** on reception of a config packet.
379 ** The download code handles the zero baud condition. 379 ** The download code handles the zero baud condition.
380 */ 380 */
381 Cor4 |= COR4_RAISEMOD; 381 Cor4 |= RIOC_COR4_RAISEMOD;
382 382
383 /* 383 /*
384 ** COR 5 384 ** COR 5
385 */ 385 */
386 386
387 Cor5 = COR5_CMOE; 387 Cor5 = RIOC_COR5_CMOE;
388 388
389 /* 389 /*
390 ** Set to monitor tbusy/tstop (or not). 390 ** Set to monitor tbusy/tstop (or not).
391 */ 391 */
392 392
393 if (PortP->MonitorTstate) 393 if (PortP->MonitorTstate)
394 Cor5 |= COR5_TSTATE_ON; 394 Cor5 |= RIOC_COR5_TSTATE_ON;
395 else 395 else
396 Cor5 |= COR5_TSTATE_OFF; 396 Cor5 |= RIOC_COR5_TSTATE_OFF;
397 397
398 /* 398 /*
399 ** Could set LNE here if you wanted LNext processing. SVR4 will use it. 399 ** Could set LNE here if you wanted LNext processing. SVR4 will use it.
@@ -401,24 +401,24 @@ int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
401 if (TtyP->termios->c_iflag & ISTRIP) { 401 if (TtyP->termios->c_iflag & ISTRIP) {
402 rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n"); 402 rio_dprintk(RIO_DEBUG_PARAM, "Strip input characters\n");
403 if (!(PortP->State & RIO_TRIAD_MODE)) { 403 if (!(PortP->State & RIO_TRIAD_MODE)) {
404 Cor5 |= COR5_ISTRIP; 404 Cor5 |= RIOC_COR5_ISTRIP;
405 } 405 }
406 } 406 }
407 407
408 if (TtyP->termios->c_oflag & ONLCR) { 408 if (TtyP->termios->c_oflag & ONLCR) {
409 rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n"); 409 rio_dprintk(RIO_DEBUG_PARAM, "Map newline to carriage-return, newline on output\n");
410 if (PortP->CookMode == COOK_MEDIUM) 410 if (PortP->CookMode == COOK_MEDIUM)
411 Cor5 |= COR5_ONLCR; 411 Cor5 |= RIOC_COR5_ONLCR;
412 } 412 }
413 if (TtyP->termios->c_oflag & OCRNL) { 413 if (TtyP->termios->c_oflag & OCRNL) {
414 rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n"); 414 rio_dprintk(RIO_DEBUG_PARAM, "Map carriage return to newline on output\n");
415 if (PortP->CookMode == COOK_MEDIUM) 415 if (PortP->CookMode == COOK_MEDIUM)
416 Cor5 |= COR5_OCRNL; 416 Cor5 |= RIOC_COR5_OCRNL;
417 } 417 }
418 if ((TtyP->termios->c_oflag & TABDLY) == TAB3) { 418 if ((TtyP->termios->c_oflag & TABDLY) == TAB3) {
419 rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n"); 419 rio_dprintk(RIO_DEBUG_PARAM, "Tab delay 3 set\n");
420 if (PortP->CookMode == COOK_MEDIUM) 420 if (PortP->CookMode == COOK_MEDIUM)
421 Cor5 |= COR5_TAB3; 421 Cor5 |= RIOC_COR5_TAB3;
422 } 422 }
423 423
424 /* 424 /*
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 1cb8580a161d..c99354843be1 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -211,7 +211,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
211 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n"); 211 rio_dprintk(RIO_DEBUG_TTY, "Waiting for RIO_CLOSING to go away\n");
212 if (repeat_this-- <= 0) { 212 if (repeat_this-- <= 0) {
213 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 213 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
214 RIOPreemptiveCmd(p, PortP, FCLOSE); 214 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
215 retval = -EINTR; 215 retval = -EINTR;
216 goto bombout; 216 goto bombout;
217 } 217 }
@@ -264,7 +264,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
264 here. If I read the docs correctly the "open" 264 here. If I read the docs correctly the "open"
265 command piggybacks the parameters immediately. 265 command piggybacks the parameters immediately.
266 -- REW */ 266 -- REW */
267 RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */ 267 RIOParam(PortP, RIOC_OPEN, 1, OK_TO_SLEEP); /* Open the port */
268 rio_spin_lock_irqsave(&PortP->portSem, flags); 268 rio_spin_lock_irqsave(&PortP->portSem, flags);
269 269
270 /* 270 /*
@@ -275,7 +275,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
275 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 275 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
276 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 276 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
277 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n"); 277 rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
278 RIOPreemptiveCmd(p, PortP, FCLOSE); 278 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
279 func_exit(); 279 func_exit();
280 return -EINTR; 280 return -EINTR;
281 } 281 }
@@ -297,7 +297,8 @@ int riotopen(struct tty_struct *tty, struct file *filp)
297 ** insert test for carrier here. -- ??? 297 ** insert test for carrier here. -- ???
298 ** I already see that test here. What's the deal? -- REW 298 ** I already see that test here. What's the deal? -- REW
299 */ 299 */
300 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) { 300 if ((PortP->gs.tty->termios->c_cflag & CLOCAL) ||
301 (PortP->ModemState & RIOC_MSVR1_CD)) {
301 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort); 302 rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
302 /* 303 /*
303 tp->tm.c_state |= CARR_ON; 304 tp->tm.c_state |= CARR_ON;
@@ -325,7 +326,7 @@ int riotopen(struct tty_struct *tty, struct file *filp)
325 ** I think it's OK. -- REW 326 ** I think it's OK. -- REW
326 */ 327 */
327 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort); 328 rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
328 RIOPreemptiveCmd(p, PortP, FCLOSE); 329 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
329 /* 330 /*
330 tp->tm.c_state &= ~WOPEN; 331 tp->tm.c_state &= ~WOPEN;
331 */ 332 */
@@ -416,7 +417,7 @@ int riotclose(void *ptr)
416 */ 417 */
417 PortP->State &= ~RIO_MOPEN; 418 PortP->State &= ~RIO_MOPEN;
418 PortP->State &= ~RIO_CARR_ON; 419 PortP->State &= ~RIO_CARR_ON;
419 PortP->ModemState &= ~MSVR1_CD; 420 PortP->ModemState &= ~RIOC_MSVR1_CD;
420 /* 421 /*
421 ** If the device was open as both a Modem and a tty line 422 ** If the device was open as both a Modem and a tty line
422 ** then we need to wimp out here, as the port has not really 423 ** then we need to wimp out here, as the port has not really
@@ -453,7 +454,7 @@ int riotclose(void *ptr)
453 if (repeat_this-- <= 0) { 454 if (repeat_this-- <= 0) {
454 rv = -EINTR; 455 rv = -EINTR;
455 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n"); 456 rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
456 RIOPreemptiveCmd(p, PortP, FCLOSE); 457 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
457 goto close_end; 458 goto close_end;
458 } 459 }
459 rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n"); 460 rio_dprintk(RIO_DEBUG_TTY, "Calling timeout to flush in closing\n");
@@ -492,8 +493,8 @@ int riotclose(void *ptr)
492 /* Can't call RIOShortCommand with the port locked. */ 493 /* Can't call RIOShortCommand with the port locked. */
493 rio_spin_unlock_irqrestore(&PortP->portSem, flags); 494 rio_spin_unlock_irqrestore(&PortP->portSem, flags);
494 495
495 if (RIOShortCommand(p, PortP, CLOSE, 1, 0) == RIO_FAIL) { 496 if (RIOShortCommand(p, PortP, RIOC_CLOSE, 1, 0) == RIO_FAIL) {
496 RIOPreemptiveCmd(p, PortP, FCLOSE); 497 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
497 rio_spin_lock_irqsave(&PortP->portSem, flags); 498 rio_spin_lock_irqsave(&PortP->portSem, flags);
498 goto close_end; 499 goto close_end;
499 } 500 }
@@ -503,7 +504,7 @@ int riotclose(void *ptr)
503 try--; 504 try--;
504 if (time_after(jiffies, end_time)) { 505 if (time_after(jiffies, end_time)) {
505 rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n"); 506 rio_dprintk(RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n");
506 RIOPreemptiveCmd(p, PortP, FCLOSE); 507 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
507 break; 508 break;
508 } 509 }
509 rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN); 510 rio_dprintk(RIO_DEBUG_TTY, "Close: PortState:ISOPEN is %d\n", PortP->PortState & PORT_ISOPEN);
@@ -515,14 +516,14 @@ int riotclose(void *ptr)
515 } 516 }
516 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) { 517 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
517 rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n"); 518 rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");
518 RIOPreemptiveCmd(p, PortP, FCLOSE); 519 RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE);
519 break; 520 break;
520 } 521 }
521 } 522 }
522 rio_spin_lock_irqsave(&PortP->portSem, flags); 523 rio_spin_lock_irqsave(&PortP->portSem, flags);
523 rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try); 524 rio_dprintk(RIO_DEBUG_TTY, "Close: try was %d on completion\n", try);
524 525
525 /* RIOPreemptiveCmd(p, PortP, FCLOSE); */ 526 /* RIOPreemptiveCmd(p, PortP, RIOC_FCLOSE); */
526 527
527/* 528/*
528** 15.10.1998 ARG - ESIL 0761 part fix 529** 15.10.1998 ARG - ESIL 0761 part fix
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 3f9d0a9ac36d..f073c710ab8d 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -4,9 +4,9 @@
4 * Copyright (C) 1994-1996 Dmitry Gorodchanin (pgmdsg@ibi.com) 4 * Copyright (C) 1994-1996 Dmitry Gorodchanin (pgmdsg@ibi.com)
5 * 5 *
6 * This code is loosely based on the Linux serial driver, written by 6 * This code is loosely based on the Linux serial driver, written by
7 * Linus Torvalds, Theodore T'so and others. The RISCom/8 card 7 * Linus Torvalds, Theodore T'so and others. The RISCom/8 card
8 * programming info was obtained from various drivers for other OSes 8 * programming info was obtained from various drivers for other OSes
9 * (FreeBSD, ISC, etc), but no source code from those drivers were 9 * (FreeBSD, ISC, etc), but no source code from those drivers were
10 * directly included in this driver. 10 * directly included in this driver.
11 * 11 *
12 * 12 *
@@ -33,7 +33,7 @@
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35 35
36#include <asm/io.h> 36#include <linux/io.h>
37#include <linux/kernel.h> 37#include <linux/kernel.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/ioport.h> 39#include <linux/ioport.h>
@@ -49,7 +49,7 @@
49#include <linux/tty_flip.h> 49#include <linux/tty_flip.h>
50#include <linux/spinlock.h> 50#include <linux/spinlock.h>
51 51
52#include <asm/uaccess.h> 52#include <linux/uaccess.h>
53 53
54#include "riscom8.h" 54#include "riscom8.h"
55#include "riscom8_reg.h" 55#include "riscom8_reg.h"
@@ -57,15 +57,15 @@
57/* Am I paranoid or not ? ;-) */ 57/* Am I paranoid or not ? ;-) */
58#define RISCOM_PARANOIA_CHECK 58#define RISCOM_PARANOIA_CHECK
59 59
60/* 60/*
61 * Crazy InteliCom/8 boards sometimes has swapped CTS & DSR signals. 61 * Crazy InteliCom/8 boards sometimes have swapped CTS & DSR signals.
62 * You can slightly speed up things by #undefing the following option, 62 * You can slightly speed up things by #undefing the following option,
63 * if you are REALLY sure that your board is correct one. 63 * if you are REALLY sure that your board is correct one.
64 */ 64 */
65 65
66#define RISCOM_BRAIN_DAMAGED_CTS 66#define RISCOM_BRAIN_DAMAGED_CTS
67 67
68/* 68/*
69 * The following defines are mostly for testing purposes. But if you need 69 * The following defines are mostly for testing purposes. But if you need
70 * some nice reporting in your syslog, you can define them also. 70 * some nice reporting in your syslog, you can define them also.
71 */ 71 */
@@ -112,7 +112,7 @@ static unsigned short rc_ioport[] = {
112#define RC_NIOPORT ARRAY_SIZE(rc_ioport) 112#define RC_NIOPORT ARRAY_SIZE(rc_ioport)
113 113
114 114
115static inline int rc_paranoia_check(struct riscom_port const * port, 115static int rc_paranoia_check(struct riscom_port const *port,
116 char *name, const char *routine) 116 char *name, const char *routine)
117{ 117{
118#ifdef RISCOM_PARANOIA_CHECK 118#ifdef RISCOM_PARANOIA_CHECK
@@ -134,52 +134,53 @@ static inline int rc_paranoia_check(struct riscom_port const * port,
134} 134}
135 135
136/* 136/*
137 * 137 *
138 * Service functions for RISCom/8 driver. 138 * Service functions for RISCom/8 driver.
139 * 139 *
140 */ 140 */
141 141
142/* Get board number from pointer */ 142/* Get board number from pointer */
143static inline int board_No (struct riscom_board const * bp) 143static inline int board_No(struct riscom_board const *bp)
144{ 144{
145 return bp - rc_board; 145 return bp - rc_board;
146} 146}
147 147
148/* Get port number from pointer */ 148/* Get port number from pointer */
149static inline int port_No (struct riscom_port const * port) 149static inline int port_No(struct riscom_port const *port)
150{ 150{
151 return RC_PORT(port - rc_port); 151 return RC_PORT(port - rc_port);
152} 152}
153 153
154/* Get pointer to board from pointer to port */ 154/* Get pointer to board from pointer to port */
155static inline struct riscom_board * port_Board(struct riscom_port const * port) 155static inline struct riscom_board *port_Board(struct riscom_port const *port)
156{ 156{
157 return &rc_board[RC_BOARD(port - rc_port)]; 157 return &rc_board[RC_BOARD(port - rc_port)];
158} 158}
159 159
160/* Input Byte from CL CD180 register */ 160/* Input Byte from CL CD180 register */
161static inline unsigned char rc_in(struct riscom_board const * bp, unsigned short reg) 161static inline unsigned char rc_in(struct riscom_board const *bp,
162 unsigned short reg)
162{ 163{
163 return inb(bp->base + RC_TO_ISA(reg)); 164 return inb(bp->base + RC_TO_ISA(reg));
164} 165}
165 166
166/* Output Byte to CL CD180 register */ 167/* Output Byte to CL CD180 register */
167static inline void rc_out(struct riscom_board const * bp, unsigned short reg, 168static inline void rc_out(struct riscom_board const *bp, unsigned short reg,
168 unsigned char val) 169 unsigned char val)
169{ 170{
170 outb(val, bp->base + RC_TO_ISA(reg)); 171 outb(val, bp->base + RC_TO_ISA(reg));
171} 172}
172 173
173/* Wait for Channel Command Register ready */ 174/* Wait for Channel Command Register ready */
174static inline void rc_wait_CCR(struct riscom_board const * bp) 175static void rc_wait_CCR(struct riscom_board const *bp)
175{ 176{
176 unsigned long delay; 177 unsigned long delay;
177 178
178 /* FIXME: need something more descriptive then 100000 :) */ 179 /* FIXME: need something more descriptive then 100000 :) */
179 for (delay = 100000; delay; delay--) 180 for (delay = 100000; delay; delay--)
180 if (!rc_in(bp, CD180_CCR)) 181 if (!rc_in(bp, CD180_CCR))
181 return; 182 return;
182 183
183 printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp)); 184 printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp));
184} 185}
185 186
@@ -187,11 +188,11 @@ static inline void rc_wait_CCR(struct riscom_board const * bp)
187 * RISCom/8 probe functions. 188 * RISCom/8 probe functions.
188 */ 189 */
189 190
190static inline int rc_request_io_range(struct riscom_board * const bp) 191static int rc_request_io_range(struct riscom_board * const bp)
191{ 192{
192 int i; 193 int i;
193 194
194 for (i = 0; i < RC_NIOPORT; i++) 195 for (i = 0; i < RC_NIOPORT; i++)
195 if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1, 196 if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1,
196 "RISCom/8")) { 197 "RISCom/8")) {
197 goto out_release; 198 goto out_release;
@@ -200,42 +201,42 @@ static inline int rc_request_io_range(struct riscom_board * const bp)
200out_release: 201out_release:
201 printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n", 202 printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
202 board_No(bp), bp->base); 203 board_No(bp), bp->base);
203 while(--i >= 0) 204 while (--i >= 0)
204 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1); 205 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
205 return 1; 206 return 1;
206} 207}
207 208
208static inline void rc_release_io_range(struct riscom_board * const bp) 209static void rc_release_io_range(struct riscom_board * const bp)
209{ 210{
210 int i; 211 int i;
211 212
212 for (i = 0; i < RC_NIOPORT; i++) 213 for (i = 0; i < RC_NIOPORT; i++)
213 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1); 214 release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
214} 215}
215 216
216/* Reset and setup CD180 chip */ 217/* Reset and setup CD180 chip */
217static void __init rc_init_CD180(struct riscom_board const * bp) 218static void __init rc_init_CD180(struct riscom_board const *bp)
218{ 219{
219 unsigned long flags; 220 unsigned long flags;
220 221
221 spin_lock_irqsave(&riscom_lock, flags); 222 spin_lock_irqsave(&riscom_lock, flags);
222 223
223 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */ 224 rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
224 rc_wait_CCR(bp); /* Wait for CCR ready */ 225 rc_wait_CCR(bp); /* Wait for CCR ready */
225 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */ 226 rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
226 spin_unlock_irqrestore(&riscom_lock, flags); 227 spin_unlock_irqrestore(&riscom_lock, flags);
227 msleep(50); /* Delay 0.05 sec */ 228 msleep(50); /* Delay 0.05 sec */
228 spin_lock_irqsave(&riscom_lock, flags); 229 spin_lock_irqsave(&riscom_lock, flags);
229 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */ 230 rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
230 rc_out(bp, CD180_GICR, 0); /* Clear all bits */ 231 rc_out(bp, CD180_GICR, 0); /* Clear all bits */
231 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */ 232 rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
232 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for transmitter intr */ 233 rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for tx intr */
233 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for receiver intr */ 234 rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for rx intr */
234 235
235 /* Setting up prescaler. We need 4 ticks per 1 ms */ 236 /* Setting up prescaler. We need 4 ticks per 1 ms */
236 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8); 237 rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
237 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff); 238 rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
238 239
239 spin_unlock_irqrestore(&riscom_lock, flags); 240 spin_unlock_irqrestore(&riscom_lock, flags);
240} 241}
241 242
@@ -245,12 +246,12 @@ static int __init rc_probe(struct riscom_board *bp)
245 unsigned char val1, val2; 246 unsigned char val1, val2;
246 int irqs = 0; 247 int irqs = 0;
247 int retries; 248 int retries;
248 249
249 bp->irq = 0; 250 bp->irq = 0;
250 251
251 if (rc_request_io_range(bp)) 252 if (rc_request_io_range(bp))
252 return 1; 253 return 1;
253 254
254 /* Are the I/O ports here ? */ 255 /* Are the I/O ports here ? */
255 rc_out(bp, CD180_PPRL, 0x5a); 256 rc_out(bp, CD180_PPRL, 0x5a);
256 outb(0xff, 0x80); 257 outb(0xff, 0x80);
@@ -258,34 +259,34 @@ static int __init rc_probe(struct riscom_board *bp)
258 rc_out(bp, CD180_PPRL, 0xa5); 259 rc_out(bp, CD180_PPRL, 0xa5);
259 outb(0x00, 0x80); 260 outb(0x00, 0x80);
260 val2 = rc_in(bp, CD180_PPRL); 261 val2 = rc_in(bp, CD180_PPRL);
261 262
262 if ((val1 != 0x5a) || (val2 != 0xa5)) { 263 if ((val1 != 0x5a) || (val2 != 0xa5)) {
263 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n", 264 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
264 board_No(bp), bp->base); 265 board_No(bp), bp->base);
265 goto out_release; 266 goto out_release;
266 } 267 }
267 268
268 /* It's time to find IRQ for this board */ 269 /* It's time to find IRQ for this board */
269 for (retries = 0; retries < 5 && irqs <= 0; retries++) { 270 for (retries = 0; retries < 5 && irqs <= 0; retries++) {
270 irqs = probe_irq_on(); 271 irqs = probe_irq_on();
271 rc_init_CD180(bp); /* Reset CD180 chip */ 272 rc_init_CD180(bp); /* Reset CD180 chip */
272 rc_out(bp, CD180_CAR, 2); /* Select port 2 */ 273 rc_out(bp, CD180_CAR, 2); /* Select port 2 */
273 rc_wait_CCR(bp); 274 rc_wait_CCR(bp);
274 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */ 275 rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
275 rc_out(bp, CD180_IER, IER_TXRDY); /* Enable tx empty intr */ 276 rc_out(bp, CD180_IER, IER_TXRDY);/* Enable tx empty intr */
276 msleep(50); 277 msleep(50);
277 irqs = probe_irq_off(irqs); 278 irqs = probe_irq_off(irqs);
278 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */ 279 val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
279 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */ 280 val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
280 rc_init_CD180(bp); /* Reset CD180 again */ 281 rc_init_CD180(bp); /* Reset CD180 again */
281 282
282 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) { 283 if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
283 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not " 284 printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
284 "found.\n", board_No(bp), bp->base); 285 "found.\n", board_No(bp), bp->base);
285 goto out_release; 286 goto out_release;
286 } 287 }
287 } 288 }
288 289
289 if (irqs <= 0) { 290 if (irqs <= 0) {
290 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board " 291 printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
291 "at 0x%03x.\n", board_No(bp), bp->base); 292 "at 0x%03x.\n", board_No(bp), bp->base);
@@ -293,113 +294,112 @@ static int __init rc_probe(struct riscom_board *bp)
293 } 294 }
294 bp->irq = irqs; 295 bp->irq = irqs;
295 bp->flags |= RC_BOARD_PRESENT; 296 bp->flags |= RC_BOARD_PRESENT;
296 297
297 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at " 298 printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
298 "0x%03x, IRQ %d.\n", 299 "0x%03x, IRQ %d.\n",
299 board_No(bp), 300 board_No(bp),
300 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */ 301 (rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
301 bp->base, bp->irq); 302 bp->base, bp->irq);
302 303
303 return 0; 304 return 0;
304out_release: 305out_release:
305 rc_release_io_range(bp); 306 rc_release_io_range(bp);
306 return 1; 307 return 1;
307} 308}
308 309
309/* 310/*
310 * 311 *
311 * Interrupt processing routines. 312 * Interrupt processing routines.
312 * 313 *
313 */ 314 */
314 315
315static inline struct riscom_port * rc_get_port(struct riscom_board const * bp, 316static struct riscom_port *rc_get_port(struct riscom_board const *bp,
316 unsigned char const * what) 317 unsigned char const *what)
317{ 318{
318 unsigned char channel; 319 unsigned char channel;
319 struct riscom_port * port; 320 struct riscom_port *port;
320 321
321 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF; 322 channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
322 if (channel < CD180_NCH) { 323 if (channel < CD180_NCH) {
323 port = &rc_port[board_No(bp) * RC_NPORT + channel]; 324 port = &rc_port[board_No(bp) * RC_NPORT + channel];
324 if (port->flags & ASYNC_INITIALIZED) { 325 if (port->flags & ASYNC_INITIALIZED)
325 return port; 326 return port;
326 }
327 } 327 }
328 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n", 328 printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
329 board_No(bp), what, channel); 329 board_No(bp), what, channel);
330 return NULL; 330 return NULL;
331} 331}
332 332
333static inline void rc_receive_exc(struct riscom_board const * bp) 333static void rc_receive_exc(struct riscom_board const *bp)
334{ 334{
335 struct riscom_port *port; 335 struct riscom_port *port;
336 struct tty_struct *tty; 336 struct tty_struct *tty;
337 unsigned char status; 337 unsigned char status;
338 unsigned char ch, flag; 338 unsigned char ch, flag;
339 339
340 if (!(port = rc_get_port(bp, "Receive"))) 340 port = rc_get_port(bp, "Receive");
341 if (port == NULL)
341 return; 342 return;
342 343
343 tty = port->tty; 344 tty = port->tty;
344 345
345#ifdef RC_REPORT_OVERRUN 346#ifdef RC_REPORT_OVERRUN
346 status = rc_in(bp, CD180_RCSR); 347 status = rc_in(bp, CD180_RCSR);
347 if (status & RCSR_OE) 348 if (status & RCSR_OE)
348 port->overrun++; 349 port->overrun++;
349 status &= port->mark_mask; 350 status &= port->mark_mask;
350#else 351#else
351 status = rc_in(bp, CD180_RCSR) & port->mark_mask; 352 status = rc_in(bp, CD180_RCSR) & port->mark_mask;
352#endif 353#endif
353 ch = rc_in(bp, CD180_RDR); 354 ch = rc_in(bp, CD180_RDR);
354 if (!status) { 355 if (!status)
355 return; 356 return;
356 }
357 if (status & RCSR_TOUT) { 357 if (status & RCSR_TOUT) {
358 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. " 358 printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
359 "Hardware problems ?\n", 359 "Hardware problems ?\n",
360 board_No(bp), port_No(port)); 360 board_No(bp), port_No(port));
361 return; 361 return;
362 362
363 } else if (status & RCSR_BREAK) { 363 } else if (status & RCSR_BREAK) {
364 printk(KERN_INFO "rc%d: port %d: Handling break...\n", 364 printk(KERN_INFO "rc%d: port %d: Handling break...\n",
365 board_No(bp), port_No(port)); 365 board_No(bp), port_No(port));
366 flag = TTY_BREAK; 366 flag = TTY_BREAK;
367 if (port->flags & ASYNC_SAK) 367 if (port->flags & ASYNC_SAK)
368 do_SAK(tty); 368 do_SAK(tty);
369 369
370 } else if (status & RCSR_PE) 370 } else if (status & RCSR_PE)
371 flag = TTY_PARITY; 371 flag = TTY_PARITY;
372 372
373 else if (status & RCSR_FE) 373 else if (status & RCSR_FE)
374 flag = TTY_FRAME; 374 flag = TTY_FRAME;
375 375
376 else if (status & RCSR_OE) 376 else if (status & RCSR_OE)
377 flag = TTY_OVERRUN; 377 flag = TTY_OVERRUN;
378
379 else 378 else
380 flag = TTY_NORMAL; 379 flag = TTY_NORMAL;
381 380
382 tty_insert_flip_char(tty, ch, flag); 381 tty_insert_flip_char(tty, ch, flag);
383 tty_flip_buffer_push(tty); 382 tty_flip_buffer_push(tty);
384} 383}
385 384
386static inline void rc_receive(struct riscom_board const * bp) 385static void rc_receive(struct riscom_board const *bp)
387{ 386{
388 struct riscom_port *port; 387 struct riscom_port *port;
389 struct tty_struct *tty; 388 struct tty_struct *tty;
390 unsigned char count; 389 unsigned char count;
391 390
392 if (!(port = rc_get_port(bp, "Receive"))) 391 port = rc_get_port(bp, "Receive");
392 if (port == NULL)
393 return; 393 return;
394 394
395 tty = port->tty; 395 tty = port->tty;
396 396
397 count = rc_in(bp, CD180_RDCR); 397 count = rc_in(bp, CD180_RDCR);
398 398
399#ifdef RC_REPORT_FIFO 399#ifdef RC_REPORT_FIFO
400 port->hits[count > 8 ? 9 : count]++; 400 port->hits[count > 8 ? 9 : count]++;
401#endif 401#endif
402 402
403 while (count--) { 403 while (count--) {
404 if (tty_buffer_request_room(tty, 1) == 0) { 404 if (tty_buffer_request_room(tty, 1) == 0) {
405 printk(KERN_WARNING "rc%d: port %d: Working around " 405 printk(KERN_WARNING "rc%d: port %d: Working around "
@@ -412,26 +412,26 @@ static inline void rc_receive(struct riscom_board const * bp)
412 tty_flip_buffer_push(tty); 412 tty_flip_buffer_push(tty);
413} 413}
414 414
415static inline void rc_transmit(struct riscom_board const * bp) 415static void rc_transmit(struct riscom_board const *bp)
416{ 416{
417 struct riscom_port *port; 417 struct riscom_port *port;
418 struct tty_struct *tty; 418 struct tty_struct *tty;
419 unsigned char count; 419 unsigned char count;
420 420
421 421 port = rc_get_port(bp, "Transmit");
422 if (!(port = rc_get_port(bp, "Transmit"))) 422 if (port == NULL)
423 return; 423 return;
424 424
425 tty = port->tty; 425 tty = port->tty;
426 426
427 if (port->IER & IER_TXEMPTY) { 427 if (port->IER & IER_TXEMPTY) {
428 /* FIFO drained */ 428 /* FIFO drained */
429 rc_out(bp, CD180_CAR, port_No(port)); 429 rc_out(bp, CD180_CAR, port_No(port));
430 port->IER &= ~IER_TXEMPTY; 430 port->IER &= ~IER_TXEMPTY;
431 rc_out(bp, CD180_IER, port->IER); 431 rc_out(bp, CD180_IER, port->IER);
432 return; 432 return;
433 } 433 }
434 434
435 if ((port->xmit_cnt <= 0 && !port->break_length) 435 if ((port->xmit_cnt <= 0 && !port->break_length)
436 || tty->stopped || tty->hw_stopped) { 436 || tty->stopped || tty->hw_stopped) {
437 rc_out(bp, CD180_CAR, port_No(port)); 437 rc_out(bp, CD180_CAR, port_No(port));
@@ -439,7 +439,7 @@ static inline void rc_transmit(struct riscom_board const * bp)
439 rc_out(bp, CD180_IER, port->IER); 439 rc_out(bp, CD180_IER, port->IER);
440 return; 440 return;
441 } 441 }
442 442
443 if (port->break_length) { 443 if (port->break_length) {
444 if (port->break_length > 0) { 444 if (port->break_length > 0) {
445 if (port->COR2 & COR2_ETC) { 445 if (port->COR2 & COR2_ETC) {
@@ -451,7 +451,8 @@ static inline void rc_transmit(struct riscom_board const * bp)
451 rc_out(bp, CD180_TDR, CD180_C_ESC); 451 rc_out(bp, CD180_TDR, CD180_C_ESC);
452 rc_out(bp, CD180_TDR, CD180_C_DELAY); 452 rc_out(bp, CD180_TDR, CD180_C_DELAY);
453 rc_out(bp, CD180_TDR, count); 453 rc_out(bp, CD180_TDR, count);
454 if (!(port->break_length -= count)) 454 port->break_length -= count;
455 if (port->break_length == 0)
455 port->break_length--; 456 port->break_length--;
456 } else { 457 } else {
457 rc_out(bp, CD180_TDR, CD180_C_ESC); 458 rc_out(bp, CD180_TDR, CD180_C_ESC);
@@ -463,7 +464,7 @@ static inline void rc_transmit(struct riscom_board const * bp)
463 } 464 }
464 return; 465 return;
465 } 466 }
466 467
467 count = CD180_NFIFO; 468 count = CD180_NFIFO;
468 do { 469 do {
469 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]); 470 rc_out(bp, CD180_TDR, port->xmit_buf[port->xmit_tail++]);
@@ -471,7 +472,7 @@ static inline void rc_transmit(struct riscom_board const * bp)
471 if (--port->xmit_cnt <= 0) 472 if (--port->xmit_cnt <= 0)
472 break; 473 break;
473 } while (--count > 0); 474 } while (--count > 0);
474 475
475 if (port->xmit_cnt <= 0) { 476 if (port->xmit_cnt <= 0) {
476 rc_out(bp, CD180_CAR, port_No(port)); 477 rc_out(bp, CD180_CAR, port_No(port));
477 port->IER &= ~IER_TXRDY; 478 port->IER &= ~IER_TXRDY;
@@ -481,25 +482,26 @@ static inline void rc_transmit(struct riscom_board const * bp)
481 tty_wakeup(tty); 482 tty_wakeup(tty);
482} 483}
483 484
484static inline void rc_check_modem(struct riscom_board const * bp) 485static void rc_check_modem(struct riscom_board const *bp)
485{ 486{
486 struct riscom_port *port; 487 struct riscom_port *port;
487 struct tty_struct *tty; 488 struct tty_struct *tty;
488 unsigned char mcr; 489 unsigned char mcr;
489 490
490 if (!(port = rc_get_port(bp, "Modem"))) 491 port = rc_get_port(bp, "Modem");
492 if (port == NULL)
491 return; 493 return;
492 494
493 tty = port->tty; 495 tty = port->tty;
494 496
495 mcr = rc_in(bp, CD180_MCR); 497 mcr = rc_in(bp, CD180_MCR);
496 if (mcr & MCR_CDCHG) { 498 if (mcr & MCR_CDCHG) {
497 if (rc_in(bp, CD180_MSVR) & MSVR_CD) 499 if (rc_in(bp, CD180_MSVR) & MSVR_CD)
498 wake_up_interruptible(&port->open_wait); 500 wake_up_interruptible(&port->open_wait);
499 else 501 else
500 tty_hangup(tty); 502 tty_hangup(tty);
501 } 503 }
502 504
503#ifdef RISCOM_BRAIN_DAMAGED_CTS 505#ifdef RISCOM_BRAIN_DAMAGED_CTS
504 if (mcr & MCR_CTSCHG) { 506 if (mcr & MCR_CTSCHG) {
505 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) { 507 if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
@@ -526,13 +528,13 @@ static inline void rc_check_modem(struct riscom_board const * bp)
526 rc_out(bp, CD180_IER, port->IER); 528 rc_out(bp, CD180_IER, port->IER);
527 } 529 }
528#endif /* RISCOM_BRAIN_DAMAGED_CTS */ 530#endif /* RISCOM_BRAIN_DAMAGED_CTS */
529 531
530 /* Clear change bits */ 532 /* Clear change bits */
531 rc_out(bp, CD180_MCR, 0); 533 rc_out(bp, CD180_MCR, 0);
532} 534}
533 535
534/* The main interrupt processing routine */ 536/* The main interrupt processing routine */
535static irqreturn_t rc_interrupt(int dummy, void * dev_id) 537static irqreturn_t rc_interrupt(int dummy, void *dev_id)
536{ 538{
537 unsigned char status; 539 unsigned char status;
538 unsigned char ack; 540 unsigned char ack;
@@ -547,13 +549,11 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
547 (RC_BSR_TOUT | RC_BSR_TINT | 549 (RC_BSR_TOUT | RC_BSR_TINT |
548 RC_BSR_MINT | RC_BSR_RINT))) { 550 RC_BSR_MINT | RC_BSR_RINT))) {
549 handled = 1; 551 handled = 1;
550 if (status & RC_BSR_TOUT) 552 if (status & RC_BSR_TOUT)
551 printk(KERN_WARNING "rc%d: Got timeout. Hardware " 553 printk(KERN_WARNING "rc%d: Got timeout. Hardware "
552 "error?\n", board_No(bp)); 554 "error?\n", board_No(bp));
553
554 else if (status & RC_BSR_RINT) { 555 else if (status & RC_BSR_RINT) {
555 ack = rc_in(bp, RC_ACK_RINT); 556 ack = rc_in(bp, RC_ACK_RINT);
556
557 if (ack == (RC_ID | GIVR_IT_RCV)) 557 if (ack == (RC_ID | GIVR_IT_RCV))
558 rc_receive(bp); 558 rc_receive(bp);
559 else if (ack == (RC_ID | GIVR_IT_REXC)) 559 else if (ack == (RC_ID | GIVR_IT_REXC))
@@ -562,29 +562,23 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
562 printk(KERN_WARNING "rc%d: Bad receive ack " 562 printk(KERN_WARNING "rc%d: Bad receive ack "
563 "0x%02x.\n", 563 "0x%02x.\n",
564 board_No(bp), ack); 564 board_No(bp), ack);
565
566 } else if (status & RC_BSR_TINT) { 565 } else if (status & RC_BSR_TINT) {
567 ack = rc_in(bp, RC_ACK_TINT); 566 ack = rc_in(bp, RC_ACK_TINT);
568
569 if (ack == (RC_ID | GIVR_IT_TX)) 567 if (ack == (RC_ID | GIVR_IT_TX))
570 rc_transmit(bp); 568 rc_transmit(bp);
571 else 569 else
572 printk(KERN_WARNING "rc%d: Bad transmit ack " 570 printk(KERN_WARNING "rc%d: Bad transmit ack "
573 "0x%02x.\n", 571 "0x%02x.\n",
574 board_No(bp), ack); 572 board_No(bp), ack);
575
576 } else /* if (status & RC_BSR_MINT) */ { 573 } else /* if (status & RC_BSR_MINT) */ {
577 ack = rc_in(bp, RC_ACK_MINT); 574 ack = rc_in(bp, RC_ACK_MINT);
578 575 if (ack == (RC_ID | GIVR_IT_MODEM))
579 if (ack == (RC_ID | GIVR_IT_MODEM))
580 rc_check_modem(bp); 576 rc_check_modem(bp);
581 else 577 else
582 printk(KERN_WARNING "rc%d: Bad modem ack " 578 printk(KERN_WARNING "rc%d: Bad modem ack "
583 "0x%02x.\n", 579 "0x%02x.\n",
584 board_No(bp), ack); 580 board_No(bp), ack);
585 581 }
586 }
587
588 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */ 582 rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
589 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */ 583 rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
590 } 584 }
@@ -596,24 +590,24 @@ static irqreturn_t rc_interrupt(int dummy, void * dev_id)
596 */ 590 */
597 591
598/* Called with disabled interrupts */ 592/* Called with disabled interrupts */
599static int rc_setup_board(struct riscom_board * bp) 593static int rc_setup_board(struct riscom_board *bp)
600{ 594{
601 int error; 595 int error;
602 596
603 if (bp->flags & RC_BOARD_ACTIVE) 597 if (bp->flags & RC_BOARD_ACTIVE)
604 return 0; 598 return 0;
605 599
606 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED, 600 error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
607 "RISCom/8", bp); 601 "RISCom/8", bp);
608 if (error) 602 if (error)
609 return error; 603 return error;
610 604
611 rc_out(bp, RC_CTOUT, 0); /* Just in case */ 605 rc_out(bp, RC_CTOUT, 0); /* Just in case */
612 bp->DTR = ~0; 606 bp->DTR = ~0;
613 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */ 607 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
614 608
615 bp->flags |= RC_BOARD_ACTIVE; 609 bp->flags |= RC_BOARD_ACTIVE;
616 610
617 return 0; 611 return 0;
618} 612}
619 613
@@ -622,40 +616,40 @@ static void rc_shutdown_board(struct riscom_board *bp)
622{ 616{
623 if (!(bp->flags & RC_BOARD_ACTIVE)) 617 if (!(bp->flags & RC_BOARD_ACTIVE))
624 return; 618 return;
625 619
626 bp->flags &= ~RC_BOARD_ACTIVE; 620 bp->flags &= ~RC_BOARD_ACTIVE;
627 621
628 free_irq(bp->irq, NULL); 622 free_irq(bp->irq, NULL);
629 623
630 bp->DTR = ~0; 624 bp->DTR = ~0;
631 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */ 625 rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
632 626
633} 627}
634 628
635/* 629/*
636 * Setting up port characteristics. 630 * Setting up port characteristics.
637 * Must be called with disabled interrupts 631 * Must be called with disabled interrupts
638 */ 632 */
639static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port) 633static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
640{ 634{
641 struct tty_struct *tty; 635 struct tty_struct *tty = port->tty;
642 unsigned long baud; 636 unsigned long baud;
643 long tmp; 637 long tmp;
644 unsigned char cor1 = 0, cor3 = 0; 638 unsigned char cor1 = 0, cor3 = 0;
645 unsigned char mcor1 = 0, mcor2 = 0; 639 unsigned char mcor1 = 0, mcor2 = 0;
646 640
647 if (!(tty = port->tty) || !tty->termios) 641 if (tty == NULL || tty->termios == NULL)
648 return; 642 return;
649 643
650 port->IER = 0; 644 port->IER = 0;
651 port->COR2 = 0; 645 port->COR2 = 0;
652 port->MSVR = MSVR_RTS; 646 port->MSVR = MSVR_RTS;
653 647
654 baud = tty_get_baud_rate(tty); 648 baud = tty_get_baud_rate(tty);
655 649
656 /* Select port on the board */ 650 /* Select port on the board */
657 rc_out(bp, CD180_CAR, port_No(port)); 651 rc_out(bp, CD180_CAR, port_No(port));
658 652
659 if (!baud) { 653 if (!baud) {
660 /* Drop DTR & exit */ 654 /* Drop DTR & exit */
661 bp->DTR |= (1u << port_No(port)); 655 bp->DTR |= (1u << port_No(port));
@@ -666,69 +660,68 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
666 bp->DTR &= ~(1u << port_No(port)); 660 bp->DTR &= ~(1u << port_No(port));
667 rc_out(bp, RC_DTR, bp->DTR); 661 rc_out(bp, RC_DTR, bp->DTR);
668 } 662 }
669 663
670 /* 664 /*
671 * Now we must calculate some speed depended things 665 * Now we must calculate some speed depended things
672 */ 666 */
673 667
674 /* Set baud rate for port */ 668 /* Set baud rate for port */
675 tmp = (((RC_OSCFREQ + baud/2) / baud + 669 tmp = (((RC_OSCFREQ + baud/2) / baud +
676 CD180_TPC/2) / CD180_TPC); 670 CD180_TPC/2) / CD180_TPC);
677 671
678 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff); 672 rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
679 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff); 673 rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
680 rc_out(bp, CD180_RBPRL, tmp & 0xff); 674 rc_out(bp, CD180_RBPRL, tmp & 0xff);
681 rc_out(bp, CD180_TBPRL, tmp & 0xff); 675 rc_out(bp, CD180_TBPRL, tmp & 0xff);
682 676
683 baud = (baud + 5) / 10; /* Estimated CPS */ 677 baud = (baud + 5) / 10; /* Estimated CPS */
684 678
685 /* Two timer ticks seems enough to wakeup something like SLIP driver */ 679 /* Two timer ticks seems enough to wakeup something like SLIP driver */
686 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO; 680 tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
687 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ? 681 port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
688 SERIAL_XMIT_SIZE - 1 : tmp); 682 SERIAL_XMIT_SIZE - 1 : tmp);
689 683
690 /* Receiver timeout will be transmission time for 1.5 chars */ 684 /* Receiver timeout will be transmission time for 1.5 chars */
691 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud; 685 tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
692 tmp = (tmp > 0xff) ? 0xff : tmp; 686 tmp = (tmp > 0xff) ? 0xff : tmp;
693 rc_out(bp, CD180_RTPR, tmp); 687 rc_out(bp, CD180_RTPR, tmp);
694 688
695 switch (C_CSIZE(tty)) { 689 switch (C_CSIZE(tty)) {
696 case CS5: 690 case CS5:
697 cor1 |= COR1_5BITS; 691 cor1 |= COR1_5BITS;
698 break; 692 break;
699 case CS6: 693 case CS6:
700 cor1 |= COR1_6BITS; 694 cor1 |= COR1_6BITS;
701 break; 695 break;
702 case CS7: 696 case CS7:
703 cor1 |= COR1_7BITS; 697 cor1 |= COR1_7BITS;
704 break; 698 break;
705 case CS8: 699 case CS8:
706 cor1 |= COR1_8BITS; 700 cor1 |= COR1_8BITS;
707 break; 701 break;
708 } 702 }
709 703 if (C_CSTOPB(tty))
710 if (C_CSTOPB(tty))
711 cor1 |= COR1_2SB; 704 cor1 |= COR1_2SB;
712 705
713 cor1 |= COR1_IGNORE; 706 cor1 |= COR1_IGNORE;
714 if (C_PARENB(tty)) { 707 if (C_PARENB(tty)) {
715 cor1 |= COR1_NORMPAR; 708 cor1 |= COR1_NORMPAR;
716 if (C_PARODD(tty)) 709 if (C_PARODD(tty))
717 cor1 |= COR1_ODDP; 710 cor1 |= COR1_ODDP;
718 if (I_INPCK(tty)) 711 if (I_INPCK(tty))
719 cor1 &= ~COR1_IGNORE; 712 cor1 &= ~COR1_IGNORE;
720 } 713 }
721 /* Set marking of some errors */ 714 /* Set marking of some errors */
722 port->mark_mask = RCSR_OE | RCSR_TOUT; 715 port->mark_mask = RCSR_OE | RCSR_TOUT;
723 if (I_INPCK(tty)) 716 if (I_INPCK(tty))
724 port->mark_mask |= RCSR_FE | RCSR_PE; 717 port->mark_mask |= RCSR_FE | RCSR_PE;
725 if (I_BRKINT(tty) || I_PARMRK(tty)) 718 if (I_BRKINT(tty) || I_PARMRK(tty))
726 port->mark_mask |= RCSR_BREAK; 719 port->mark_mask |= RCSR_BREAK;
727 if (I_IGNPAR(tty)) 720 if (I_IGNPAR(tty))
728 port->mark_mask &= ~(RCSR_FE | RCSR_PE); 721 port->mark_mask &= ~(RCSR_FE | RCSR_PE);
729 if (I_IGNBRK(tty)) { 722 if (I_IGNBRK(tty)) {
730 port->mark_mask &= ~RCSR_BREAK; 723 port->mark_mask &= ~RCSR_BREAK;
731 if (I_IGNPAR(tty)) 724 if (I_IGNPAR(tty))
732 /* Real raw mode. Ignore all */ 725 /* Real raw mode. Ignore all */
733 port->mark_mask &= ~RCSR_OE; 726 port->mark_mask &= ~RCSR_OE;
734 } 727 }
@@ -738,7 +731,8 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
738 port->IER |= IER_DSR | IER_CTS; 731 port->IER |= IER_DSR | IER_CTS;
739 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD; 732 mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
740 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD; 733 mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
741 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) & (MSVR_CTS|MSVR_DSR)); 734 tty->hw_stopped = !(rc_in(bp, CD180_MSVR) &
735 (MSVR_CTS|MSVR_DSR));
742#else 736#else
743 port->COR2 |= COR2_CTSAE; 737 port->COR2 |= COR2_CTSAE;
744#endif 738#endif
@@ -761,13 +755,13 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
761 mcor1 |= MCOR1_CDZD; 755 mcor1 |= MCOR1_CDZD;
762 mcor2 |= MCOR2_CDOD; 756 mcor2 |= MCOR2_CDOD;
763 } 757 }
764 758
765 if (C_CREAD(tty)) 759 if (C_CREAD(tty))
766 /* Enable receiver */ 760 /* Enable receiver */
767 port->IER |= IER_RXD; 761 port->IER |= IER_RXD;
768 762
769 /* Set input FIFO size (1-8 bytes) */ 763 /* Set input FIFO size (1-8 bytes) */
770 cor3 |= RISCOM_RXFIFO; 764 cor3 |= RISCOM_RXFIFO;
771 /* Setting up CD180 channel registers */ 765 /* Setting up CD180 channel registers */
772 rc_out(bp, CD180_COR1, cor1); 766 rc_out(bp, CD180_COR1, cor1);
773 rc_out(bp, CD180_COR2, port->COR2); 767 rc_out(bp, CD180_COR2, port->COR2);
@@ -791,36 +785,30 @@ static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
791static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port) 785static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
792{ 786{
793 unsigned long flags; 787 unsigned long flags;
794 788
795 if (port->flags & ASYNC_INITIALIZED) 789 if (port->flags & ASYNC_INITIALIZED)
796 return 0; 790 return 0;
797 791
798 if (!port->xmit_buf) { 792 if (!port->xmit_buf) {
799 /* We may sleep in get_zeroed_page() */ 793 /* We may sleep in get_zeroed_page() */
800 unsigned long tmp; 794 unsigned long tmp = get_zeroed_page(GFP_KERNEL);
801 795 if (tmp == 0)
802 if (!(tmp = get_zeroed_page(GFP_KERNEL)))
803 return -ENOMEM; 796 return -ENOMEM;
804 797 if (port->xmit_buf)
805 if (port->xmit_buf) {
806 free_page(tmp); 798 free_page(tmp);
807 return -ERESTARTSYS; 799 else
808 } 800 port->xmit_buf = (unsigned char *) tmp;
809 port->xmit_buf = (unsigned char *) tmp;
810 } 801 }
811
812 spin_lock_irqsave(&riscom_lock, flags); 802 spin_lock_irqsave(&riscom_lock, flags);
813 803
814 if (port->tty) 804 if (port->tty)
815 clear_bit(TTY_IO_ERROR, &port->tty->flags); 805 clear_bit(TTY_IO_ERROR, &port->tty->flags);
816 806 if (port->count == 1)
817 if (port->count == 1)
818 bp->count++; 807 bp->count++;
819
820 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 808 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
821 rc_change_speed(bp, port); 809 rc_change_speed(bp, port);
822 port->flags |= ASYNC_INITIALIZED; 810 port->flags |= ASYNC_INITIALIZED;
823 811
824 spin_unlock_irqrestore(&riscom_lock, flags); 812 spin_unlock_irqrestore(&riscom_lock, flags);
825 return 0; 813 return 0;
826} 814}
@@ -829,38 +817,39 @@ static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
829static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port) 817static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
830{ 818{
831 struct tty_struct *tty; 819 struct tty_struct *tty;
832 820
833 if (!(port->flags & ASYNC_INITIALIZED)) 821 if (!(port->flags & ASYNC_INITIALIZED))
834 return; 822 return;
835 823
836#ifdef RC_REPORT_OVERRUN 824#ifdef RC_REPORT_OVERRUN
837 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n", 825 printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
838 board_No(bp), port_No(port), port->overrun); 826 board_No(bp), port_No(port), port->overrun);
839#endif 827#endif
840#ifdef RC_REPORT_FIFO 828#ifdef RC_REPORT_FIFO
841 { 829 {
842 int i; 830 int i;
843 831
844 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ", 832 printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
845 board_No(bp), port_No(port)); 833 board_No(bp), port_No(port));
846 for (i = 0; i < 10; i++) { 834 for (i = 0; i < 10; i++)
847 printk("%ld ", port->hits[i]); 835 printk("%ld ", port->hits[i]);
848 }
849 printk("].\n"); 836 printk("].\n");
850 } 837 }
851#endif 838#endif
852 if (port->xmit_buf) { 839 if (port->xmit_buf) {
853 free_page((unsigned long) port->xmit_buf); 840 free_page((unsigned long) port->xmit_buf);
854 port->xmit_buf = NULL; 841 port->xmit_buf = NULL;
855 } 842 }
856 843
857 if (!(tty = port->tty) || C_HUPCL(tty)) { 844 tty = port->tty;
845
846 if (tty == NULL || C_HUPCL(tty)) {
858 /* Drop DTR */ 847 /* Drop DTR */
859 bp->DTR |= (1u << port_No(port)); 848 bp->DTR |= (1u << port_No(port));
860 rc_out(bp, RC_DTR, bp->DTR); 849 rc_out(bp, RC_DTR, bp->DTR);
861 } 850 }
862 851
863 /* Select port */ 852 /* Select port */
864 rc_out(bp, CD180_CAR, port_No(port)); 853 rc_out(bp, CD180_CAR, port_No(port));
865 /* Reset port */ 854 /* Reset port */
866 rc_wait_CCR(bp); 855 rc_wait_CCR(bp);
@@ -868,28 +857,26 @@ static void rc_shutdown_port(struct riscom_board *bp, struct riscom_port *port)
868 /* Disable all interrupts from this port */ 857 /* Disable all interrupts from this port */
869 port->IER = 0; 858 port->IER = 0;
870 rc_out(bp, CD180_IER, port->IER); 859 rc_out(bp, CD180_IER, port->IER);
871 860
872 if (tty) 861 if (tty)
873 set_bit(TTY_IO_ERROR, &tty->flags); 862 set_bit(TTY_IO_ERROR, &tty->flags);
874 port->flags &= ~ASYNC_INITIALIZED; 863 port->flags &= ~ASYNC_INITIALIZED;
875 864
876 if (--bp->count < 0) { 865 if (--bp->count < 0) {
877 printk(KERN_INFO "rc%d: rc_shutdown_port: " 866 printk(KERN_INFO "rc%d: rc_shutdown_port: "
878 "bad board count: %d\n", 867 "bad board count: %d\n",
879 board_No(bp), bp->count); 868 board_No(bp), bp->count);
880 bp->count = 0; 869 bp->count = 0;
881 } 870 }
882
883 /* 871 /*
884 * If this is the last opened port on the board 872 * If this is the last opened port on the board
885 * shutdown whole board 873 * shutdown whole board
886 */ 874 */
887 if (!bp->count) 875 if (!bp->count)
888 rc_shutdown_board(bp); 876 rc_shutdown_board(bp);
889} 877}
890 878
891 879static int block_til_ready(struct tty_struct *tty, struct file *filp,
892static int block_til_ready(struct tty_struct *tty, struct file * filp,
893 struct riscom_port *port) 880 struct riscom_port *port)
894{ 881{
895 DECLARE_WAITQUEUE(wait, current); 882 DECLARE_WAITQUEUE(wait, current);
@@ -921,7 +908,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
921 return 0; 908 return 0;
922 } 909 }
923 910
924 if (C_CLOCAL(tty)) 911 if (C_CLOCAL(tty))
925 do_clocal = 1; 912 do_clocal = 1;
926 913
927 /* 914 /*
@@ -959,7 +946,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
959 if (port->flags & ASYNC_HUP_NOTIFY) 946 if (port->flags & ASYNC_HUP_NOTIFY)
960 retval = -EAGAIN; 947 retval = -EAGAIN;
961 else 948 else
962 retval = -ERESTARTSYS; 949 retval = -ERESTARTSYS;
963 break; 950 break;
964 } 951 }
965 if (!(port->flags & ASYNC_CLOSING) && 952 if (!(port->flags & ASYNC_CLOSING) &&
@@ -978,50 +965,63 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
978 port->blocked_open--; 965 port->blocked_open--;
979 if (retval) 966 if (retval)
980 return retval; 967 return retval;
981 968
982 port->flags |= ASYNC_NORMAL_ACTIVE; 969 port->flags |= ASYNC_NORMAL_ACTIVE;
983 return 0; 970 return 0;
984} 971}
985 972
986static int rc_open(struct tty_struct * tty, struct file * filp) 973static int rc_open(struct tty_struct *tty, struct file *filp)
987{ 974{
988 int board; 975 int board;
989 int error; 976 int error;
990 struct riscom_port * port; 977 struct riscom_port *port;
991 struct riscom_board * bp; 978 struct riscom_board *bp;
992 979
993 board = RC_BOARD(tty->index); 980 board = RC_BOARD(tty->index);
994 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT)) 981 if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
995 return -ENODEV; 982 return -ENODEV;
996 983
997 bp = &rc_board[board]; 984 bp = &rc_board[board];
998 port = rc_port + board * RC_NPORT + RC_PORT(tty->index); 985 port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
999 if (rc_paranoia_check(port, tty->name, "rc_open")) 986 if (rc_paranoia_check(port, tty->name, "rc_open"))
1000 return -ENODEV; 987 return -ENODEV;
1001 988
1002 if ((error = rc_setup_board(bp))) 989 error = rc_setup_board(bp);
990 if (error)
1003 return error; 991 return error;
1004 992
1005 port->count++; 993 port->count++;
1006 tty->driver_data = port; 994 tty->driver_data = port;
1007 port->tty = tty; 995 port->tty = tty;
1008 996
1009 if ((error = rc_setup_port(bp, port))) 997 error = rc_setup_port(bp, port);
1010 return error; 998 if (error == 0)
1011 999 error = block_til_ready(tty, filp, port);
1012 if ((error = block_til_ready(tty, filp, port))) 1000 return error;
1013 return error;
1014
1015 return 0;
1016} 1001}
1017 1002
1018static void rc_close(struct tty_struct * tty, struct file * filp) 1003static void rc_flush_buffer(struct tty_struct *tty)
1004{
1005 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1006 unsigned long flags;
1007
1008 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1009 return;
1010
1011 spin_lock_irqsave(&riscom_lock, flags);
1012 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1013 spin_unlock_irqrestore(&riscom_lock, flags);
1014
1015 tty_wakeup(tty);
1016}
1017
1018static void rc_close(struct tty_struct *tty, struct file *filp)
1019{ 1019{
1020 struct riscom_port *port = (struct riscom_port *) tty->driver_data; 1020 struct riscom_port *port = (struct riscom_port *) tty->driver_data;
1021 struct riscom_board *bp; 1021 struct riscom_board *bp;
1022 unsigned long flags; 1022 unsigned long flags;
1023 unsigned long timeout; 1023 unsigned long timeout;
1024 1024
1025 if (!port || rc_paranoia_check(port, tty->name, "close")) 1025 if (!port || rc_paranoia_check(port, tty->name, "close"))
1026 return; 1026 return;
1027 1027
@@ -1029,7 +1029,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
1029 1029
1030 if (tty_hung_up_p(filp)) 1030 if (tty_hung_up_p(filp))
1031 goto out; 1031 goto out;
1032 1032
1033 bp = port_Board(port); 1033 bp = port_Board(port);
1034 if ((tty->count == 1) && (port->count != 1)) { 1034 if ((tty->count == 1) && (port->count != 1)) {
1035 printk(KERN_INFO "rc%d: rc_close: bad port count;" 1035 printk(KERN_INFO "rc%d: rc_close: bad port count;"
@@ -1047,7 +1047,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
1047 goto out; 1047 goto out;
1048 port->flags |= ASYNC_CLOSING; 1048 port->flags |= ASYNC_CLOSING;
1049 /* 1049 /*
1050 * Now we wait for the transmit buffer to clear; and we notify 1050 * Now we wait for the transmit buffer to clear; and we notify
1051 * the line discipline to only process XON/XOFF characters. 1051 * the line discipline to only process XON/XOFF characters.
1052 */ 1052 */
1053 tty->closing = 1; 1053 tty->closing = 1;
@@ -1070,24 +1070,22 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
1070 * has completely drained; this is especially 1070 * has completely drained; this is especially
1071 * important if there is a transmit FIFO! 1071 * important if there is a transmit FIFO!
1072 */ 1072 */
1073 timeout = jiffies+HZ; 1073 timeout = jiffies + HZ;
1074 while(port->IER & IER_TXEMPTY) { 1074 while (port->IER & IER_TXEMPTY) {
1075 msleep_interruptible(jiffies_to_msecs(port->timeout)); 1075 msleep_interruptible(jiffies_to_msecs(port->timeout));
1076 if (time_after(jiffies, timeout)) 1076 if (time_after(jiffies, timeout))
1077 break; 1077 break;
1078 } 1078 }
1079 } 1079 }
1080 rc_shutdown_port(bp, port); 1080 rc_shutdown_port(bp, port);
1081 if (tty->driver->flush_buffer) 1081 rc_flush_buffer(tty);
1082 tty->driver->flush_buffer(tty);
1083 tty_ldisc_flush(tty); 1082 tty_ldisc_flush(tty);
1084 1083
1085 tty->closing = 0; 1084 tty->closing = 0;
1086 port->tty = NULL; 1085 port->tty = NULL;
1087 if (port->blocked_open) { 1086 if (port->blocked_open) {
1088 if (port->close_delay) { 1087 if (port->close_delay)
1089 msleep_interruptible(jiffies_to_msecs(port->close_delay)); 1088 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1090 }
1091 wake_up_interruptible(&port->open_wait); 1089 wake_up_interruptible(&port->open_wait);
1092 } 1090 }
1093 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1091 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
@@ -1097,17 +1095,17 @@ out:
1097 spin_unlock_irqrestore(&riscom_lock, flags); 1095 spin_unlock_irqrestore(&riscom_lock, flags);
1098} 1096}
1099 1097
1100static int rc_write(struct tty_struct * tty, 1098static int rc_write(struct tty_struct *tty,
1101 const unsigned char *buf, int count) 1099 const unsigned char *buf, int count)
1102{ 1100{
1103 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1101 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1104 struct riscom_board *bp; 1102 struct riscom_board *bp;
1105 int c, total = 0; 1103 int c, total = 0;
1106 unsigned long flags; 1104 unsigned long flags;
1107 1105
1108 if (rc_paranoia_check(port, tty->name, "rc_write")) 1106 if (rc_paranoia_check(port, tty->name, "rc_write"))
1109 return 0; 1107 return 0;
1110 1108
1111 bp = port_Board(port); 1109 bp = port_Board(port);
1112 1110
1113 if (!tty || !port->xmit_buf) 1111 if (!tty || !port->xmit_buf)
@@ -1144,38 +1142,41 @@ static int rc_write(struct tty_struct * tty,
1144 return total; 1142 return total;
1145} 1143}
1146 1144
1147static void rc_put_char(struct tty_struct * tty, unsigned char ch) 1145static int rc_put_char(struct tty_struct *tty, unsigned char ch)
1148{ 1146{
1149 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1147 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1150 unsigned long flags; 1148 unsigned long flags;
1149 int ret = 0;
1151 1150
1152 if (rc_paranoia_check(port, tty->name, "rc_put_char")) 1151 if (rc_paranoia_check(port, tty->name, "rc_put_char"))
1153 return; 1152 return 0;
1154 1153
1155 if (!tty || !port->xmit_buf) 1154 if (!tty || !port->xmit_buf)
1156 return; 1155 return 0;
1157 1156
1158 spin_lock_irqsave(&riscom_lock, flags); 1157 spin_lock_irqsave(&riscom_lock, flags);
1159 1158
1160 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1) 1159 if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
1161 goto out; 1160 goto out;
1162 1161
1163 port->xmit_buf[port->xmit_head++] = ch; 1162 port->xmit_buf[port->xmit_head++] = ch;
1164 port->xmit_head &= SERIAL_XMIT_SIZE - 1; 1163 port->xmit_head &= SERIAL_XMIT_SIZE - 1;
1165 port->xmit_cnt++; 1164 port->xmit_cnt++;
1165 ret = 1;
1166 1166
1167out: 1167out:
1168 spin_unlock_irqrestore(&riscom_lock, flags); 1168 spin_unlock_irqrestore(&riscom_lock, flags);
1169 return ret;
1169} 1170}
1170 1171
1171static void rc_flush_chars(struct tty_struct * tty) 1172static void rc_flush_chars(struct tty_struct *tty)
1172{ 1173{
1173 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1174 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1174 unsigned long flags; 1175 unsigned long flags;
1175 1176
1176 if (rc_paranoia_check(port, tty->name, "rc_flush_chars")) 1177 if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
1177 return; 1178 return;
1178 1179
1179 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || 1180 if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
1180 !port->xmit_buf) 1181 !port->xmit_buf)
1181 return; 1182 return;
@@ -1189,11 +1190,11 @@ static void rc_flush_chars(struct tty_struct * tty)
1189 spin_unlock_irqrestore(&riscom_lock, flags); 1190 spin_unlock_irqrestore(&riscom_lock, flags);
1190} 1191}
1191 1192
1192static int rc_write_room(struct tty_struct * tty) 1193static int rc_write_room(struct tty_struct *tty)
1193{ 1194{
1194 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1195 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1195 int ret; 1196 int ret;
1196 1197
1197 if (rc_paranoia_check(port, tty->name, "rc_write_room")) 1198 if (rc_paranoia_check(port, tty->name, "rc_write_room"))
1198 return 0; 1199 return 0;
1199 1200
@@ -1206,39 +1207,22 @@ static int rc_write_room(struct tty_struct * tty)
1206static int rc_chars_in_buffer(struct tty_struct *tty) 1207static int rc_chars_in_buffer(struct tty_struct *tty)
1207{ 1208{
1208 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1209 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1209 1210
1210 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer")) 1211 if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
1211 return 0; 1212 return 0;
1212
1213 return port->xmit_cnt;
1214}
1215
1216static void rc_flush_buffer(struct tty_struct *tty)
1217{
1218 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1219 unsigned long flags;
1220
1221 if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
1222 return;
1223
1224 spin_lock_irqsave(&riscom_lock, flags);
1225
1226 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1227 1213
1228 spin_unlock_irqrestore(&riscom_lock, flags); 1214 return port->xmit_cnt;
1229
1230 tty_wakeup(tty);
1231} 1215}
1232 1216
1233static int rc_tiocmget(struct tty_struct *tty, struct file *file) 1217static int rc_tiocmget(struct tty_struct *tty, struct file *file)
1234{ 1218{
1235 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1219 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1236 struct riscom_board * bp; 1220 struct riscom_board *bp;
1237 unsigned char status; 1221 unsigned char status;
1238 unsigned int result; 1222 unsigned int result;
1239 unsigned long flags; 1223 unsigned long flags;
1240 1224
1241 if (rc_paranoia_check(port, tty->name, __FUNCTION__)) 1225 if (rc_paranoia_check(port, tty->name, __func__))
1242 return -ENODEV; 1226 return -ENODEV;
1243 1227
1244 bp = port_Board(port); 1228 bp = port_Board(port);
@@ -1266,7 +1250,7 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1266 unsigned long flags; 1250 unsigned long flags;
1267 struct riscom_board *bp; 1251 struct riscom_board *bp;
1268 1252
1269 if (rc_paranoia_check(port, tty->name, __FUNCTION__)) 1253 if (rc_paranoia_check(port, tty->name, __func__))
1270 return -ENODEV; 1254 return -ENODEV;
1271 1255
1272 bp = port_Board(port); 1256 bp = port_Board(port);
@@ -1292,11 +1276,11 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file,
1292 return 0; 1276 return 0;
1293} 1277}
1294 1278
1295static inline void rc_send_break(struct riscom_port * port, unsigned long length) 1279static void rc_send_break(struct riscom_port *port, unsigned long length)
1296{ 1280{
1297 struct riscom_board *bp = port_Board(port); 1281 struct riscom_board *bp = port_Board(port);
1298 unsigned long flags; 1282 unsigned long flags;
1299 1283
1300 spin_lock_irqsave(&riscom_lock, flags); 1284 spin_lock_irqsave(&riscom_lock, flags);
1301 1285
1302 port->break_length = RISCOM_TPS / HZ * length; 1286 port->break_length = RISCOM_TPS / HZ * length;
@@ -1312,17 +1296,17 @@ static inline void rc_send_break(struct riscom_port * port, unsigned long length
1312 spin_unlock_irqrestore(&riscom_lock, flags); 1296 spin_unlock_irqrestore(&riscom_lock, flags);
1313} 1297}
1314 1298
1315static inline int rc_set_serial_info(struct riscom_port * port, 1299static int rc_set_serial_info(struct riscom_port *port,
1316 struct serial_struct __user * newinfo) 1300 struct serial_struct __user *newinfo)
1317{ 1301{
1318 struct serial_struct tmp; 1302 struct serial_struct tmp;
1319 struct riscom_board *bp = port_Board(port); 1303 struct riscom_board *bp = port_Board(port);
1320 int change_speed; 1304 int change_speed;
1321 1305
1322 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) 1306 if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
1323 return -EFAULT; 1307 return -EFAULT;
1324 1308
1325#if 0 1309#if 0
1326 if ((tmp.irq != bp->irq) || 1310 if ((tmp.irq != bp->irq) ||
1327 (tmp.port != bp->base) || 1311 (tmp.port != bp->base) ||
1328 (tmp.type != PORT_CIRRUS) || 1312 (tmp.type != PORT_CIRRUS) ||
@@ -1331,16 +1315,16 @@ static inline int rc_set_serial_info(struct riscom_port * port,
1331 (tmp.xmit_fifo_size != CD180_NFIFO) || 1315 (tmp.xmit_fifo_size != CD180_NFIFO) ||
1332 (tmp.flags & ~RISCOM_LEGAL_FLAGS)) 1316 (tmp.flags & ~RISCOM_LEGAL_FLAGS))
1333 return -EINVAL; 1317 return -EINVAL;
1334#endif 1318#endif
1335 1319
1336 change_speed = ((port->flags & ASYNC_SPD_MASK) != 1320 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1337 (tmp.flags & ASYNC_SPD_MASK)); 1321 (tmp.flags & ASYNC_SPD_MASK));
1338 1322
1339 if (!capable(CAP_SYS_ADMIN)) { 1323 if (!capable(CAP_SYS_ADMIN)) {
1340 if ((tmp.close_delay != port->close_delay) || 1324 if ((tmp.close_delay != port->close_delay) ||
1341 (tmp.closing_wait != port->closing_wait) || 1325 (tmp.closing_wait != port->closing_wait) ||
1342 ((tmp.flags & ~ASYNC_USR_MASK) != 1326 ((tmp.flags & ~ASYNC_USR_MASK) !=
1343 (port->flags & ~ASYNC_USR_MASK))) 1327 (port->flags & ~ASYNC_USR_MASK)))
1344 return -EPERM; 1328 return -EPERM;
1345 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1329 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
1346 (tmp.flags & ASYNC_USR_MASK)); 1330 (tmp.flags & ASYNC_USR_MASK));
@@ -1360,12 +1344,12 @@ static inline int rc_set_serial_info(struct riscom_port * port,
1360 return 0; 1344 return 0;
1361} 1345}
1362 1346
1363static inline int rc_get_serial_info(struct riscom_port * port, 1347static int rc_get_serial_info(struct riscom_port *port,
1364 struct serial_struct __user *retinfo) 1348 struct serial_struct __user *retinfo)
1365{ 1349{
1366 struct serial_struct tmp; 1350 struct serial_struct tmp;
1367 struct riscom_board *bp = port_Board(port); 1351 struct riscom_board *bp = port_Board(port);
1368 1352
1369 memset(&tmp, 0, sizeof(tmp)); 1353 memset(&tmp, 0, sizeof(tmp));
1370 tmp.type = PORT_CIRRUS; 1354 tmp.type = PORT_CIRRUS;
1371 tmp.line = port - rc_port; 1355 tmp.line = port - rc_port;
@@ -1379,19 +1363,18 @@ static inline int rc_get_serial_info(struct riscom_port * port,
1379 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0; 1363 return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
1380} 1364}
1381 1365
1382static int rc_ioctl(struct tty_struct * tty, struct file * filp, 1366static int rc_ioctl(struct tty_struct *tty, struct file *filp,
1383 unsigned int cmd, unsigned long arg) 1367 unsigned int cmd, unsigned long arg)
1384
1385{ 1368{
1386 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1369 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1387 void __user *argp = (void __user *)arg; 1370 void __user *argp = (void __user *)arg;
1388 int retval; 1371 int retval = 0;
1389 1372
1390 if (rc_paranoia_check(port, tty->name, "rc_ioctl")) 1373 if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
1391 return -ENODEV; 1374 return -ENODEV;
1392 1375
1393 switch (cmd) { 1376 switch (cmd) {
1394 case TCSBRK: /* SVID version: non-zero arg --> no break */ 1377 case TCSBRK: /* SVID version: non-zero arg --> no break */
1395 retval = tty_check_change(tty); 1378 retval = tty_check_change(tty);
1396 if (retval) 1379 if (retval)
1397 return retval; 1380 return retval;
@@ -1399,45 +1382,40 @@ static int rc_ioctl(struct tty_struct * tty, struct file * filp,
1399 if (!arg) 1382 if (!arg)
1400 rc_send_break(port, HZ/4); /* 1/4 second */ 1383 rc_send_break(port, HZ/4); /* 1/4 second */
1401 break; 1384 break;
1402 case TCSBRKP: /* support for POSIX tcsendbreak() */ 1385 case TCSBRKP: /* support for POSIX tcsendbreak() */
1403 retval = tty_check_change(tty); 1386 retval = tty_check_change(tty);
1404 if (retval) 1387 if (retval)
1405 return retval; 1388 return retval;
1406 tty_wait_until_sent(tty, 0); 1389 tty_wait_until_sent(tty, 0);
1407 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4); 1390 rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
1408 break; 1391 break;
1409 case TIOCGSOFTCAR: 1392 case TIOCGSERIAL:
1410 return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp); 1393 lock_kernel();
1411 case TIOCSSOFTCAR: 1394 retval = rc_get_serial_info(port, argp);
1412 if (get_user(arg,(unsigned __user *) argp)) 1395 unlock_kernel();
1413 return -EFAULT;
1414 tty->termios->c_cflag =
1415 ((tty->termios->c_cflag & ~CLOCAL) |
1416 (arg ? CLOCAL : 0));
1417 break; 1396 break;
1418 case TIOCGSERIAL: 1397 case TIOCSSERIAL:
1419 return rc_get_serial_info(port, argp); 1398 lock_kernel();
1420 case TIOCSSERIAL: 1399 retval = rc_set_serial_info(port, argp);
1421 return rc_set_serial_info(port, argp); 1400 unlock_kernel();
1422 default: 1401 break;
1423 return -ENOIOCTLCMD; 1402 default:
1403 retval = -ENOIOCTLCMD;
1424 } 1404 }
1425 return 0; 1405 return retval;
1426} 1406}
1427 1407
1428static void rc_throttle(struct tty_struct * tty) 1408static void rc_throttle(struct tty_struct *tty)
1429{ 1409{
1430 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1410 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1431 struct riscom_board *bp; 1411 struct riscom_board *bp;
1432 unsigned long flags; 1412 unsigned long flags;
1433 1413
1434 if (rc_paranoia_check(port, tty->name, "rc_throttle")) 1414 if (rc_paranoia_check(port, tty->name, "rc_throttle"))
1435 return; 1415 return;
1436
1437 bp = port_Board(port); 1416 bp = port_Board(port);
1438 1417
1439 spin_lock_irqsave(&riscom_lock, flags); 1418 spin_lock_irqsave(&riscom_lock, flags);
1440
1441 port->MSVR &= ~MSVR_RTS; 1419 port->MSVR &= ~MSVR_RTS;
1442 rc_out(bp, CD180_CAR, port_No(port)); 1420 rc_out(bp, CD180_CAR, port_No(port));
1443 if (I_IXOFF(tty)) { 1421 if (I_IXOFF(tty)) {
@@ -1446,23 +1424,20 @@ static void rc_throttle(struct tty_struct * tty)
1446 rc_wait_CCR(bp); 1424 rc_wait_CCR(bp);
1447 } 1425 }
1448 rc_out(bp, CD180_MSVR, port->MSVR); 1426 rc_out(bp, CD180_MSVR, port->MSVR);
1449
1450 spin_unlock_irqrestore(&riscom_lock, flags); 1427 spin_unlock_irqrestore(&riscom_lock, flags);
1451} 1428}
1452 1429
1453static void rc_unthrottle(struct tty_struct * tty) 1430static void rc_unthrottle(struct tty_struct *tty)
1454{ 1431{
1455 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1432 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1456 struct riscom_board *bp; 1433 struct riscom_board *bp;
1457 unsigned long flags; 1434 unsigned long flags;
1458 1435
1459 if (rc_paranoia_check(port, tty->name, "rc_unthrottle")) 1436 if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
1460 return; 1437 return;
1461
1462 bp = port_Board(port); 1438 bp = port_Board(port);
1463
1464 spin_lock_irqsave(&riscom_lock, flags);
1465 1439
1440 spin_lock_irqsave(&riscom_lock, flags);
1466 port->MSVR |= MSVR_RTS; 1441 port->MSVR |= MSVR_RTS;
1467 rc_out(bp, CD180_CAR, port_No(port)); 1442 rc_out(bp, CD180_CAR, port_No(port));
1468 if (I_IXOFF(tty)) { 1443 if (I_IXOFF(tty)) {
@@ -1471,62 +1446,58 @@ static void rc_unthrottle(struct tty_struct * tty)
1471 rc_wait_CCR(bp); 1446 rc_wait_CCR(bp);
1472 } 1447 }
1473 rc_out(bp, CD180_MSVR, port->MSVR); 1448 rc_out(bp, CD180_MSVR, port->MSVR);
1474
1475 spin_unlock_irqrestore(&riscom_lock, flags); 1449 spin_unlock_irqrestore(&riscom_lock, flags);
1476} 1450}
1477 1451
1478static void rc_stop(struct tty_struct * tty) 1452static void rc_stop(struct tty_struct *tty)
1479{ 1453{
1480 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1454 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1481 struct riscom_board *bp; 1455 struct riscom_board *bp;
1482 unsigned long flags; 1456 unsigned long flags;
1483 1457
1484 if (rc_paranoia_check(port, tty->name, "rc_stop")) 1458 if (rc_paranoia_check(port, tty->name, "rc_stop"))
1485 return; 1459 return;
1486 1460
1487 bp = port_Board(port); 1461 bp = port_Board(port);
1488
1489 spin_lock_irqsave(&riscom_lock, flags);
1490 1462
1463 spin_lock_irqsave(&riscom_lock, flags);
1491 port->IER &= ~IER_TXRDY; 1464 port->IER &= ~IER_TXRDY;
1492 rc_out(bp, CD180_CAR, port_No(port)); 1465 rc_out(bp, CD180_CAR, port_No(port));
1493 rc_out(bp, CD180_IER, port->IER); 1466 rc_out(bp, CD180_IER, port->IER);
1494
1495 spin_unlock_irqrestore(&riscom_lock, flags); 1467 spin_unlock_irqrestore(&riscom_lock, flags);
1496} 1468}
1497 1469
1498static void rc_start(struct tty_struct * tty) 1470static void rc_start(struct tty_struct *tty)
1499{ 1471{
1500 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1472 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1501 struct riscom_board *bp; 1473 struct riscom_board *bp;
1502 unsigned long flags; 1474 unsigned long flags;
1503 1475
1504 if (rc_paranoia_check(port, tty->name, "rc_start")) 1476 if (rc_paranoia_check(port, tty->name, "rc_start"))
1505 return; 1477 return;
1506 1478
1507 bp = port_Board(port); 1479 bp = port_Board(port);
1508 1480
1509 spin_lock_irqsave(&riscom_lock, flags); 1481 spin_lock_irqsave(&riscom_lock, flags);
1510 1482
1511 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) { 1483 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
1512 port->IER |= IER_TXRDY; 1484 port->IER |= IER_TXRDY;
1513 rc_out(bp, CD180_CAR, port_No(port)); 1485 rc_out(bp, CD180_CAR, port_No(port));
1514 rc_out(bp, CD180_IER, port->IER); 1486 rc_out(bp, CD180_IER, port->IER);
1515 } 1487 }
1516
1517 spin_unlock_irqrestore(&riscom_lock, flags); 1488 spin_unlock_irqrestore(&riscom_lock, flags);
1518} 1489}
1519 1490
1520static void rc_hangup(struct tty_struct * tty) 1491static void rc_hangup(struct tty_struct *tty)
1521{ 1492{
1522 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1493 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1523 struct riscom_board *bp; 1494 struct riscom_board *bp;
1524 1495
1525 if (rc_paranoia_check(port, tty->name, "rc_hangup")) 1496 if (rc_paranoia_check(port, tty->name, "rc_hangup"))
1526 return; 1497 return;
1527 1498
1528 bp = port_Board(port); 1499 bp = port_Board(port);
1529 1500
1530 rc_shutdown_port(bp, port); 1501 rc_shutdown_port(bp, port);
1531 port->count = 0; 1502 port->count = 0;
1532 port->flags &= ~ASYNC_NORMAL_ACTIVE; 1503 port->flags &= ~ASYNC_NORMAL_ACTIVE;
@@ -1534,17 +1505,14 @@ static void rc_hangup(struct tty_struct * tty)
1534 wake_up_interruptible(&port->open_wait); 1505 wake_up_interruptible(&port->open_wait);
1535} 1506}
1536 1507
1537static void rc_set_termios(struct tty_struct * tty, struct ktermios * old_termios) 1508static void rc_set_termios(struct tty_struct *tty,
1509 struct ktermios *old_termios)
1538{ 1510{
1539 struct riscom_port *port = (struct riscom_port *)tty->driver_data; 1511 struct riscom_port *port = (struct riscom_port *)tty->driver_data;
1540 unsigned long flags; 1512 unsigned long flags;
1541 1513
1542 if (rc_paranoia_check(port, tty->name, "rc_set_termios")) 1514 if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
1543 return; 1515 return;
1544
1545 if (tty->termios->c_cflag == old_termios->c_cflag &&
1546 tty->termios->c_iflag == old_termios->c_iflag)
1547 return;
1548 1516
1549 spin_lock_irqsave(&riscom_lock, flags); 1517 spin_lock_irqsave(&riscom_lock, flags);
1550 rc_change_speed(port_Board(port), port); 1518 rc_change_speed(port_Board(port), port);
@@ -1583,9 +1551,9 @@ static int __init rc_init_drivers(void)
1583 int i; 1551 int i;
1584 1552
1585 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT); 1553 riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
1586 if (!riscom_driver) 1554 if (!riscom_driver)
1587 return -ENOMEM; 1555 return -ENOMEM;
1588 1556
1589 riscom_driver->owner = THIS_MODULE; 1557 riscom_driver->owner = THIS_MODULE;
1590 riscom_driver->name = "ttyL"; 1558 riscom_driver->name = "ttyL";
1591 riscom_driver->major = RISCOM8_NORMAL_MAJOR; 1559 riscom_driver->major = RISCOM8_NORMAL_MAJOR;
@@ -1598,23 +1566,21 @@ static int __init rc_init_drivers(void)
1598 riscom_driver->init_termios.c_ospeed = 9600; 1566 riscom_driver->init_termios.c_ospeed = 9600;
1599 riscom_driver->flags = TTY_DRIVER_REAL_RAW; 1567 riscom_driver->flags = TTY_DRIVER_REAL_RAW;
1600 tty_set_operations(riscom_driver, &riscom_ops); 1568 tty_set_operations(riscom_driver, &riscom_ops);
1601 if ((error = tty_register_driver(riscom_driver))) { 1569 error = tty_register_driver(riscom_driver);
1570 if (error != 0) {
1602 put_tty_driver(riscom_driver); 1571 put_tty_driver(riscom_driver);
1603 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, " 1572 printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
1604 "error = %d\n", 1573 "error = %d\n", error);
1605 error);
1606 return 1; 1574 return 1;
1607 } 1575 }
1608
1609 memset(rc_port, 0, sizeof(rc_port)); 1576 memset(rc_port, 0, sizeof(rc_port));
1610 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { 1577 for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
1611 rc_port[i].magic = RISCOM8_MAGIC; 1578 rc_port[i].magic = RISCOM8_MAGIC;
1612 rc_port[i].close_delay = 50 * HZ/100; 1579 rc_port[i].close_delay = 50 * HZ / 100;
1613 rc_port[i].closing_wait = 3000 * HZ/100; 1580 rc_port[i].closing_wait = 3000 * HZ / 100;
1614 init_waitqueue_head(&rc_port[i].open_wait); 1581 init_waitqueue_head(&rc_port[i].open_wait);
1615 init_waitqueue_head(&rc_port[i].close_wait); 1582 init_waitqueue_head(&rc_port[i].close_wait);
1616 } 1583 }
1617
1618 return 0; 1584 return 0;
1619} 1585}
1620 1586
@@ -1627,13 +1593,13 @@ static void rc_release_drivers(void)
1627#ifndef MODULE 1593#ifndef MODULE
1628/* 1594/*
1629 * Called at boot time. 1595 * Called at boot time.
1630 * 1596 *
1631 * You can specify IO base for up to RC_NBOARD cards, 1597 * You can specify IO base for up to RC_NBOARD cards,
1632 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt. 1598 * using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
1633 * Note that there will be no probing at default 1599 * Note that there will be no probing at default
1634 * addresses in this case. 1600 * addresses in this case.
1635 * 1601 *
1636 */ 1602 */
1637static int __init riscom8_setup(char *str) 1603static int __init riscom8_setup(char *str)
1638{ 1604{
1639 int ints[RC_NBOARD]; 1605 int ints[RC_NBOARD];
@@ -1644,7 +1610,7 @@ static int __init riscom8_setup(char *str)
1644 for (i = 0; i < RC_NBOARD; i++) { 1610 for (i = 0; i < RC_NBOARD; i++) {
1645 if (i < ints[0]) 1611 if (i < ints[0])
1646 rc_board[i].base = ints[i+1]; 1612 rc_board[i].base = ints[i+1];
1647 else 1613 else
1648 rc_board[i].base = 0; 1614 rc_board[i].base = 0;
1649 } 1615 }
1650 return 1; 1616 return 1;
@@ -1659,8 +1625,8 @@ static char banner[] __initdata =
1659static char no_boards_msg[] __initdata = 1625static char no_boards_msg[] __initdata =
1660 KERN_INFO "rc: No RISCom/8 boards detected.\n"; 1626 KERN_INFO "rc: No RISCom/8 boards detected.\n";
1661 1627
1662/* 1628/*
1663 * This routine must be called by kernel at boot time 1629 * This routine must be called by kernel at boot time
1664 */ 1630 */
1665static int __init riscom8_init(void) 1631static int __init riscom8_init(void)
1666{ 1632{
@@ -1669,13 +1635,12 @@ static int __init riscom8_init(void)
1669 1635
1670 printk(banner); 1636 printk(banner);
1671 1637
1672 if (rc_init_drivers()) 1638 if (rc_init_drivers())
1673 return -EIO; 1639 return -EIO;
1674 1640
1675 for (i = 0; i < RC_NBOARD; i++) 1641 for (i = 0; i < RC_NBOARD; i++)
1676 if (rc_board[i].base && !rc_probe(&rc_board[i])) 1642 if (rc_board[i].base && !rc_probe(&rc_board[i]))
1677 found++; 1643 found++;
1678
1679 if (!found) { 1644 if (!found) {
1680 rc_release_drivers(); 1645 rc_release_drivers();
1681 printk(no_boards_msg); 1646 printk(no_boards_msg);
@@ -1702,13 +1667,13 @@ MODULE_LICENSE("GPL");
1702 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter. 1667 * by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
1703 * 1668 *
1704 */ 1669 */
1705static int __init riscom8_init_module (void) 1670static int __init riscom8_init_module(void)
1706{ 1671{
1707#ifdef MODULE 1672#ifdef MODULE
1708 int i; 1673 int i;
1709 1674
1710 if (iobase || iobase1 || iobase2 || iobase3) { 1675 if (iobase || iobase1 || iobase2 || iobase3) {
1711 for(i = 0; i < RC_NBOARD; i++) 1676 for (i = 0; i < RC_NBOARD; i++)
1712 rc_board[i].base = 0; 1677 rc_board[i].base = 0;
1713 } 1678 }
1714 1679
@@ -1724,18 +1689,17 @@ static int __init riscom8_init_module (void)
1724 1689
1725 return riscom8_init(); 1690 return riscom8_init();
1726} 1691}
1727 1692
1728static void __exit riscom8_exit_module (void) 1693static void __exit riscom8_exit_module(void)
1729{ 1694{
1730 int i; 1695 int i;
1731 1696
1732 rc_release_drivers(); 1697 rc_release_drivers();
1733 for (i = 0; i < RC_NBOARD; i++) 1698 for (i = 0; i < RC_NBOARD; i++)
1734 if (rc_board[i].flags & RC_BOARD_PRESENT) 1699 if (rc_board[i].flags & RC_BOARD_PRESENT)
1735 rc_release_io_range(&rc_board[i]); 1700 rc_release_io_range(&rc_board[i]);
1736 1701
1737} 1702}
1738 1703
1739module_init(riscom8_init_module); 1704module_init(riscom8_init_module);
1740module_exit(riscom8_exit_module); 1705module_exit(riscom8_exit_module);
1741
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index f585bc8579e9..743dc80a9325 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -449,7 +449,8 @@ static void rp_do_transmit(struct r_port *info)
449 while (1) { 449 while (1) {
450 if (tty->stopped || tty->hw_stopped) 450 if (tty->stopped || tty->hw_stopped)
451 break; 451 break;
452 c = min(info->xmit_fifo_room, min(info->xmit_cnt, XMIT_BUF_SIZE - info->xmit_tail)); 452 c = min(info->xmit_fifo_room, info->xmit_cnt);
453 c = min(c, XMIT_BUF_SIZE - info->xmit_tail);
453 if (c <= 0 || info->xmit_fifo_room <= 0) 454 if (c <= 0 || info->xmit_fifo_room <= 0)
454 break; 455 break;
455 sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) (info->xmit_buf + info->xmit_tail), c / 2); 456 sOutStrW(sGetTxRxDataIO(cp), (unsigned short *) (info->xmit_buf + info->xmit_tail), c / 2);
@@ -1433,29 +1434,38 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file,
1433{ 1434{
1434 struct r_port *info = (struct r_port *) tty->driver_data; 1435 struct r_port *info = (struct r_port *) tty->driver_data;
1435 void __user *argp = (void __user *)arg; 1436 void __user *argp = (void __user *)arg;
1437 int ret = 0;
1436 1438
1437 if (cmd != RCKP_GET_PORTS && rocket_paranoia_check(info, "rp_ioctl")) 1439 if (cmd != RCKP_GET_PORTS && rocket_paranoia_check(info, "rp_ioctl"))
1438 return -ENXIO; 1440 return -ENXIO;
1439 1441
1442 lock_kernel();
1443
1440 switch (cmd) { 1444 switch (cmd) {
1441 case RCKP_GET_STRUCT: 1445 case RCKP_GET_STRUCT:
1442 if (copy_to_user(argp, info, sizeof (struct r_port))) 1446 if (copy_to_user(argp, info, sizeof (struct r_port)))
1443 return -EFAULT; 1447 ret = -EFAULT;
1444 return 0; 1448 break;
1445 case RCKP_GET_CONFIG: 1449 case RCKP_GET_CONFIG:
1446 return get_config(info, argp); 1450 ret = get_config(info, argp);
1451 break;
1447 case RCKP_SET_CONFIG: 1452 case RCKP_SET_CONFIG:
1448 return set_config(info, argp); 1453 ret = set_config(info, argp);
1454 break;
1449 case RCKP_GET_PORTS: 1455 case RCKP_GET_PORTS:
1450 return get_ports(info, argp); 1456 ret = get_ports(info, argp);
1457 break;
1451 case RCKP_RESET_RM2: 1458 case RCKP_RESET_RM2:
1452 return reset_rm2(info, argp); 1459 ret = reset_rm2(info, argp);
1460 break;
1453 case RCKP_GET_VERSION: 1461 case RCKP_GET_VERSION:
1454 return get_version(info, argp); 1462 ret = get_version(info, argp);
1463 break;
1455 default: 1464 default:
1456 return -ENOIOCTLCMD; 1465 ret = -ENOIOCTLCMD;
1457 } 1466 }
1458 return 0; 1467 unlock_kernel();
1468 return ret;
1459} 1469}
1460 1470
1461static void rp_send_xchar(struct tty_struct *tty, char ch) 1471static void rp_send_xchar(struct tty_struct *tty, char ch)
@@ -1575,6 +1585,7 @@ static void rp_wait_until_sent(struct tty_struct *tty, int timeout)
1575 jiffies); 1585 jiffies);
1576 printk(KERN_INFO "cps=%d...\n", info->cps); 1586 printk(KERN_INFO "cps=%d...\n", info->cps);
1577#endif 1587#endif
1588 lock_kernel();
1578 while (1) { 1589 while (1) {
1579 txcnt = sGetTxCnt(cp); 1590 txcnt = sGetTxCnt(cp);
1580 if (!txcnt) { 1591 if (!txcnt) {
@@ -1602,6 +1613,7 @@ static void rp_wait_until_sent(struct tty_struct *tty, int timeout)
1602 break; 1613 break;
1603 } 1614 }
1604 __set_current_state(TASK_RUNNING); 1615 __set_current_state(TASK_RUNNING);
1616 unlock_kernel();
1605#ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT 1617#ifdef ROCKET_DEBUG_WAIT_UNTIL_SENT
1606 printk(KERN_INFO "txcnt = %d (jiff=%lu)...done\n", txcnt, jiffies); 1618 printk(KERN_INFO "txcnt = %d (jiff=%lu)...done\n", txcnt, jiffies);
1607#endif 1619#endif
@@ -1651,14 +1663,14 @@ static void rp_hangup(struct tty_struct *tty)
1651 * writing routines will write directly to transmit FIFO. 1663 * writing routines will write directly to transmit FIFO.
1652 * Write buffer and counters protected by spinlocks 1664 * Write buffer and counters protected by spinlocks
1653 */ 1665 */
1654static void rp_put_char(struct tty_struct *tty, unsigned char ch) 1666static int rp_put_char(struct tty_struct *tty, unsigned char ch)
1655{ 1667{
1656 struct r_port *info = (struct r_port *) tty->driver_data; 1668 struct r_port *info = (struct r_port *) tty->driver_data;
1657 CHANNEL_t *cp; 1669 CHANNEL_t *cp;
1658 unsigned long flags; 1670 unsigned long flags;
1659 1671
1660 if (rocket_paranoia_check(info, "rp_put_char")) 1672 if (rocket_paranoia_check(info, "rp_put_char"))
1661 return; 1673 return 0;
1662 1674
1663 /* 1675 /*
1664 * Grab the port write mutex, locking out other processes that try to 1676 * Grab the port write mutex, locking out other processes that try to
@@ -1687,6 +1699,7 @@ static void rp_put_char(struct tty_struct *tty, unsigned char ch)
1687 } 1699 }
1688 spin_unlock_irqrestore(&info->slock, flags); 1700 spin_unlock_irqrestore(&info->slock, flags);
1689 mutex_unlock(&info->write_mtx); 1701 mutex_unlock(&info->write_mtx);
1702 return 1;
1690} 1703}
1691 1704
1692/* 1705/*
@@ -1749,10 +1762,10 @@ static int rp_write(struct tty_struct *tty,
1749 1762
1750 /* Write remaining data into the port's xmit_buf */ 1763 /* Write remaining data into the port's xmit_buf */
1751 while (1) { 1764 while (1) {
1752 if (!info->tty) /* Seemingly obligatory check... */ 1765 if (!info->tty) /* Seemingly obligatory check... */
1753 goto end; 1766 goto end;
1754 1767 c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1);
1755 c = min(count, min(XMIT_BUF_SIZE - info->xmit_cnt - 1, XMIT_BUF_SIZE - info->xmit_head)); 1768 c = min(c, XMIT_BUF_SIZE - info->xmit_head);
1756 if (c <= 0) 1769 if (c <= 0)
1757 break; 1770 break;
1758 1771
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index df8cd0ca97eb..fd2db07a50fc 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -1060,7 +1060,7 @@ static void config_setup(struct cyclades_port *info)
1060 1060
1061} /* config_setup */ 1061} /* config_setup */
1062 1062
1063static void cy_put_char(struct tty_struct *tty, unsigned char ch) 1063static int cy_put_char(struct tty_struct *tty, unsigned char ch)
1064{ 1064{
1065 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; 1065 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1066 unsigned long flags; 1066 unsigned long flags;
@@ -1070,7 +1070,7 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
1070#endif 1070#endif
1071 1071
1072 if (serial_paranoia_check(info, tty->name, "cy_put_char")) 1072 if (serial_paranoia_check(info, tty->name, "cy_put_char"))
1073 return; 1073 return 0;
1074 1074
1075 if (!info->xmit_buf) 1075 if (!info->xmit_buf)
1076 return; 1076 return;
@@ -1078,13 +1078,14 @@ static void cy_put_char(struct tty_struct *tty, unsigned char ch)
1078 local_irq_save(flags); 1078 local_irq_save(flags);
1079 if (info->xmit_cnt >= PAGE_SIZE - 1) { 1079 if (info->xmit_cnt >= PAGE_SIZE - 1) {
1080 local_irq_restore(flags); 1080 local_irq_restore(flags);
1081 return; 1081 return 0;
1082 } 1082 }
1083 1083
1084 info->xmit_buf[info->xmit_head++] = ch; 1084 info->xmit_buf[info->xmit_head++] = ch;
1085 info->xmit_head &= PAGE_SIZE - 1; 1085 info->xmit_head &= PAGE_SIZE - 1;
1086 info->xmit_cnt++; 1086 info->xmit_cnt++;
1087 local_irq_restore(flags); 1087 local_irq_restore(flags);
1088 return 1;
1088} /* cy_put_char */ 1089} /* cy_put_char */
1089 1090
1090static void cy_flush_chars(struct tty_struct *tty) 1091static void cy_flush_chars(struct tty_struct *tty)
@@ -1539,6 +1540,8 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
1539 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */ 1540 printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
1540#endif 1541#endif
1541 1542
1543 lock_kernel();
1544
1542 switch (cmd) { 1545 switch (cmd) {
1543 case CYGETMON: 1546 case CYGETMON:
1544 ret_val = get_mon_info(info, argp); 1547 ret_val = get_mon_info(info, argp);
@@ -1584,18 +1587,6 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
1584 break; 1587 break;
1585 1588
1586/* The following commands are incompletely implemented!!! */ 1589/* The following commands are incompletely implemented!!! */
1587 case TIOCGSOFTCAR:
1588 ret_val =
1589 put_user(C_CLOCAL(tty) ? 1 : 0,
1590 (unsigned long __user *)argp);
1591 break;
1592 case TIOCSSOFTCAR:
1593 ret_val = get_user(val, (unsigned long __user *)argp);
1594 if (ret_val)
1595 break;
1596 tty->termios->c_cflag =
1597 ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
1598 break;
1599 case TIOCGSERIAL: 1590 case TIOCGSERIAL:
1600 ret_val = get_serial_info(info, argp); 1591 ret_val = get_serial_info(info, argp);
1601 break; 1592 break;
@@ -1605,6 +1596,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
1605 default: 1596 default:
1606 ret_val = -ENOIOCTLCMD; 1597 ret_val = -ENOIOCTLCMD;
1607 } 1598 }
1599 unlock_kernel();
1608 1600
1609#ifdef SERIAL_DEBUG_OTHER 1601#ifdef SERIAL_DEBUG_OTHER
1610 printk("cy_ioctl done\n"); 1602 printk("cy_ioctl done\n");
@@ -1683,8 +1675,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp)
1683 if (info->flags & ASYNC_INITIALIZED) 1675 if (info->flags & ASYNC_INITIALIZED)
1684 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */ 1676 tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
1685 shutdown(info); 1677 shutdown(info);
1686 if (tty->driver->flush_buffer) 1678 cy_flush_buffer(tty);
1687 tty->driver->flush_buffer(tty);
1688 tty_ldisc_flush(tty); 1679 tty_ldisc_flush(tty);
1689 info->tty = NULL; 1680 info->tty = NULL;
1690 if (info->blocked_open) { 1681 if (info->blocked_open) {
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index b9c1dba6bd01..8fe099a41065 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -80,7 +80,7 @@ scdrv_open(struct inode *inode, struct file *file)
80 sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); 80 sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
81 if (sd == NULL) { 81 if (sd == NULL) {
82 printk("%s: couldn't allocate subchannel data\n", 82 printk("%s: couldn't allocate subchannel data\n",
83 __FUNCTION__); 83 __func__);
84 return -ENOMEM; 84 return -ENOMEM;
85 } 85 }
86 86
@@ -90,7 +90,7 @@ scdrv_open(struct inode *inode, struct file *file)
90 90
91 if (sd->sd_subch < 0) { 91 if (sd->sd_subch < 0) {
92 kfree(sd); 92 kfree(sd);
93 printk("%s: couldn't allocate subchannel\n", __FUNCTION__); 93 printk("%s: couldn't allocate subchannel\n", __func__);
94 return -EBUSY; 94 return -EBUSY;
95 } 95 }
96 96
@@ -110,7 +110,7 @@ scdrv_open(struct inode *inode, struct file *file)
110 if (rv) { 110 if (rv) {
111 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 111 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch);
112 kfree(sd); 112 kfree(sd);
113 printk("%s: irq request failed (%d)\n", __FUNCTION__, rv); 113 printk("%s: irq request failed (%d)\n", __func__, rv);
114 return -EBUSY; 114 return -EBUSY;
115 } 115 }
116 116
@@ -215,7 +215,7 @@ scdrv_read(struct file *file, char __user *buf, size_t count, loff_t *f_pos)
215 */ 215 */
216 if (count < len) { 216 if (count < len) {
217 pr_debug("%s: only accepting %d of %d bytes\n", 217 pr_debug("%s: only accepting %d of %d bytes\n",
218 __FUNCTION__, (int) count, len); 218 __func__, (int) count, len);
219 } 219 }
220 len = min((int) count, len); 220 len = min((int) count, len);
221 if (copy_to_user(buf, sd->sd_rb, len)) 221 if (copy_to_user(buf, sd->sd_rb, len))
@@ -384,7 +384,7 @@ scdrv_init(void)
384 if (alloc_chrdev_region(&first_dev, 0, num_cnodes, 384 if (alloc_chrdev_region(&first_dev, 0, num_cnodes,
385 SYSCTL_BASENAME) < 0) { 385 SYSCTL_BASENAME) < 0) {
386 printk("%s: failed to register SN system controller device\n", 386 printk("%s: failed to register SN system controller device\n",
387 __FUNCTION__); 387 __func__);
388 return -ENODEV; 388 return -ENODEV;
389 } 389 }
390 snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME); 390 snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME);
@@ -403,7 +403,7 @@ scdrv_init(void)
403 GFP_KERNEL); 403 GFP_KERNEL);
404 if (!scd) { 404 if (!scd) {
405 printk("%s: failed to allocate device info" 405 printk("%s: failed to allocate device info"
406 "for %s/%s\n", __FUNCTION__, 406 "for %s/%s\n", __func__,
407 SYSCTL_BASENAME, devname); 407 SYSCTL_BASENAME, devname);
408 continue; 408 continue;
409 } 409 }
@@ -412,7 +412,7 @@ scdrv_init(void)
412 scd->scd_nasid = cnodeid_to_nasid(cnode); 412 scd->scd_nasid = cnodeid_to_nasid(cnode);
413 if (!(salbuf = kmalloc(SCDRV_BUFSZ, GFP_KERNEL))) { 413 if (!(salbuf = kmalloc(SCDRV_BUFSZ, GFP_KERNEL))) {
414 printk("%s: failed to allocate driver buffer" 414 printk("%s: failed to allocate driver buffer"
415 "(%s%s)\n", __FUNCTION__, 415 "(%s%s)\n", __func__,
416 SYSCTL_BASENAME, devname); 416 SYSCTL_BASENAME, devname);
417 kfree(scd); 417 kfree(scd);
418 continue; 418 continue;
@@ -424,7 +424,7 @@ scdrv_init(void)
424 ("%s: failed to initialize SAL for" 424 ("%s: failed to initialize SAL for"
425 " system controller communication" 425 " system controller communication"
426 " (%s/%s): outdated PROM?\n", 426 " (%s/%s): outdated PROM?\n",
427 __FUNCTION__, SYSCTL_BASENAME, devname); 427 __func__, SYSCTL_BASENAME, devname);
428 kfree(scd); 428 kfree(scd);
429 kfree(salbuf); 429 kfree(salbuf);
430 continue; 430 continue;
@@ -435,7 +435,7 @@ scdrv_init(void)
435 if (cdev_add(&scd->scd_cdev, dev, 1)) { 435 if (cdev_add(&scd->scd_cdev, dev, 1)) {
436 printk("%s: failed to register system" 436 printk("%s: failed to register system"
437 " controller device (%s%s)\n", 437 " controller device (%s%s)\n",
438 __FUNCTION__, SYSCTL_BASENAME, devname); 438 __func__, SYSCTL_BASENAME, devname);
439 kfree(scd); 439 kfree(scd);
440 kfree(salbuf); 440 kfree(salbuf);
441 continue; 441 continue;
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index 31a7765eaf73..53b3d44f8c06 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -271,7 +271,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
271 event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL); 271 event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
272 if (event_sd == NULL) { 272 if (event_sd == NULL) {
273 printk(KERN_WARNING "%s: couldn't allocate subchannel info" 273 printk(KERN_WARNING "%s: couldn't allocate subchannel info"
274 " for event monitoring\n", __FUNCTION__); 274 " for event monitoring\n", __func__);
275 return; 275 return;
276 } 276 }
277 277
@@ -285,7 +285,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
285 if (event_sd->sd_subch < 0) { 285 if (event_sd->sd_subch < 0) {
286 kfree(event_sd); 286 kfree(event_sd);
287 printk(KERN_WARNING "%s: couldn't open event subchannel\n", 287 printk(KERN_WARNING "%s: couldn't open event subchannel\n",
288 __FUNCTION__); 288 __func__);
289 return; 289 return;
290 } 290 }
291 291
@@ -295,7 +295,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
295 "system controller events", event_sd); 295 "system controller events", event_sd);
296 if (rv) { 296 if (rv) {
297 printk(KERN_WARNING "%s: irq request failed (%d)\n", 297 printk(KERN_WARNING "%s: irq request failed (%d)\n",
298 __FUNCTION__, rv); 298 __func__, rv);
299 ia64_sn_irtr_close(event_sd->sd_nasid, event_sd->sd_subch); 299 ia64_sn_irtr_close(event_sd->sd_nasid, event_sd->sd_subch);
300 kfree(event_sd); 300 kfree(event_sd);
301 return; 301 return;
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index c03ad164c39a..58533de59027 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -506,7 +506,7 @@ static struct sonypi_device {
506 while (--n && (command)) \ 506 while (--n && (command)) \
507 udelay(1); \ 507 udelay(1); \
508 if (!n && (verbose || !quiet)) \ 508 if (!n && (verbose || !quiet)) \
509 printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \ 509 printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __func__, __LINE__); \
510} 510}
511 511
512#ifdef CONFIG_ACPI 512#ifdef CONFIG_ACPI
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index 4b5b5b78acb4..2ee4d9893757 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -131,8 +131,8 @@ static int sx_rxfifo = SPECIALIX_RXFIFO;
131#define SX_DEBUG_FIFO 0x0800 131#define SX_DEBUG_FIFO 0x0800
132 132
133 133
134#define func_enter() dprintk (SX_DEBUG_FLOW, "io8: enter %s\n",__FUNCTION__) 134#define func_enter() dprintk (SX_DEBUG_FLOW, "io8: enter %s\n",__func__)
135#define func_exit() dprintk (SX_DEBUG_FLOW, "io8: exit %s\n", __FUNCTION__) 135#define func_exit() dprintk (SX_DEBUG_FLOW, "io8: exit %s\n", __func__)
136 136
137#define jiffies_from_ms(a) ((((a) * HZ)/1000)+1) 137#define jiffies_from_ms(a) ((((a) * HZ)/1000)+1)
138 138
@@ -874,7 +874,7 @@ static irqreturn_t sx_interrupt(int dummy, void *dev_id)
874 874
875 spin_lock_irqsave(&bp->lock, flags); 875 spin_lock_irqsave(&bp->lock, flags);
876 876
877 dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __FUNCTION__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1); 877 dprintk (SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__, port_No(sx_get_port(bp, "INT")), SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
878 if (!(bp->flags & SX_BOARD_ACTIVE)) { 878 if (!(bp->flags & SX_BOARD_ACTIVE)) {
879 dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq); 879 dprintk (SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n", bp->irq);
880 spin_unlock_irqrestore(&bp->lock, flags); 880 spin_unlock_irqrestore(&bp->lock, flags);
@@ -1504,6 +1504,27 @@ static int sx_open(struct tty_struct * tty, struct file * filp)
1504 return 0; 1504 return 0;
1505} 1505}
1506 1506
1507static void sx_flush_buffer(struct tty_struct *tty)
1508{
1509 struct specialix_port *port = (struct specialix_port *)tty->driver_data;
1510 unsigned long flags;
1511 struct specialix_board * bp;
1512
1513 func_enter();
1514
1515 if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) {
1516 func_exit();
1517 return;
1518 }
1519
1520 bp = port_Board(port);
1521 spin_lock_irqsave(&port->lock, flags);
1522 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1523 spin_unlock_irqrestore(&port->lock, flags);
1524 tty_wakeup(tty);
1525
1526 func_exit();
1527}
1507 1528
1508static void sx_close(struct tty_struct * tty, struct file * filp) 1529static void sx_close(struct tty_struct * tty, struct file * filp)
1509{ 1530{
@@ -1597,8 +1618,7 @@ static void sx_close(struct tty_struct * tty, struct file * filp)
1597 } 1618 }
1598 1619
1599 sx_shutdown_port(bp, port); 1620 sx_shutdown_port(bp, port);
1600 if (tty->driver->flush_buffer) 1621 sx_flush_buffer(tty);
1601 tty->driver->flush_buffer(tty);
1602 tty_ldisc_flush(tty); 1622 tty_ldisc_flush(tty);
1603 spin_lock_irqsave(&port->lock, flags); 1623 spin_lock_irqsave(&port->lock, flags);
1604 tty->closing = 0; 1624 tty->closing = 0;
@@ -1670,7 +1690,7 @@ static int sx_write(struct tty_struct * tty,
1670} 1690}
1671 1691
1672 1692
1673static void sx_put_char(struct tty_struct * tty, unsigned char ch) 1693static int sx_put_char(struct tty_struct * tty, unsigned char ch)
1674{ 1694{
1675 struct specialix_port *port = (struct specialix_port *)tty->driver_data; 1695 struct specialix_port *port = (struct specialix_port *)tty->driver_data;
1676 unsigned long flags; 1696 unsigned long flags;
@@ -1680,12 +1700,12 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
1680 1700
1681 if (sx_paranoia_check(port, tty->name, "sx_put_char")) { 1701 if (sx_paranoia_check(port, tty->name, "sx_put_char")) {
1682 func_exit(); 1702 func_exit();
1683 return; 1703 return 0;
1684 } 1704 }
1685 dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf); 1705 dprintk (SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
1686 if (!port->xmit_buf) { 1706 if (!port->xmit_buf) {
1687 func_exit(); 1707 func_exit();
1688 return; 1708 return 0;
1689 } 1709 }
1690 bp = port_Board(port); 1710 bp = port_Board(port);
1691 spin_lock_irqsave(&port->lock, flags); 1711 spin_lock_irqsave(&port->lock, flags);
@@ -1695,7 +1715,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
1695 spin_unlock_irqrestore(&port->lock, flags); 1715 spin_unlock_irqrestore(&port->lock, flags);
1696 dprintk (SX_DEBUG_TX, "Exit size\n"); 1716 dprintk (SX_DEBUG_TX, "Exit size\n");
1697 func_exit(); 1717 func_exit();
1698 return; 1718 return 0;
1699 } 1719 }
1700 dprintk (SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf); 1720 dprintk (SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf);
1701 port->xmit_buf[port->xmit_head++] = ch; 1721 port->xmit_buf[port->xmit_head++] = ch;
@@ -1704,6 +1724,7 @@ static void sx_put_char(struct tty_struct * tty, unsigned char ch)
1704 spin_unlock_irqrestore(&port->lock, flags); 1724 spin_unlock_irqrestore(&port->lock, flags);
1705 1725
1706 func_exit(); 1726 func_exit();
1727 return 1;
1707} 1728}
1708 1729
1709 1730
@@ -1770,28 +1791,6 @@ static int sx_chars_in_buffer(struct tty_struct *tty)
1770} 1791}
1771 1792
1772 1793
1773static void sx_flush_buffer(struct tty_struct *tty)
1774{
1775 struct specialix_port *port = (struct specialix_port *)tty->driver_data;
1776 unsigned long flags;
1777 struct specialix_board * bp;
1778
1779 func_enter();
1780
1781 if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) {
1782 func_exit();
1783 return;
1784 }
1785
1786 bp = port_Board(port);
1787 spin_lock_irqsave(&port->lock, flags);
1788 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
1789 spin_unlock_irqrestore(&port->lock, flags);
1790 tty_wakeup(tty);
1791
1792 func_exit();
1793}
1794
1795 1794
1796static int sx_tiocmget(struct tty_struct *tty, struct file *file) 1795static int sx_tiocmget(struct tty_struct *tty, struct file *file)
1797{ 1796{
@@ -1803,7 +1802,7 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file)
1803 1802
1804 func_enter(); 1803 func_enter();
1805 1804
1806 if (sx_paranoia_check(port, tty->name, __FUNCTION__)) { 1805 if (sx_paranoia_check(port, tty->name, __func__)) {
1807 func_exit(); 1806 func_exit();
1808 return -ENODEV; 1807 return -ENODEV;
1809 } 1808 }
@@ -1845,7 +1844,7 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
1845 1844
1846 func_enter(); 1845 func_enter();
1847 1846
1848 if (sx_paranoia_check(port, tty->name, __FUNCTION__)) { 1847 if (sx_paranoia_check(port, tty->name, __func__)) {
1849 func_exit(); 1848 func_exit();
1850 return -ENODEV; 1849 return -ENODEV;
1851 } 1850 }
@@ -1922,29 +1921,13 @@ static inline int sx_set_serial_info(struct specialix_port * port,
1922 int change_speed; 1921 int change_speed;
1923 1922
1924 func_enter(); 1923 func_enter();
1925 /* 1924
1926 if (!access_ok(VERIFY_READ, (void *) newinfo, sizeof(tmp))) {
1927 func_exit();
1928 return -EFAULT;
1929 }
1930 */
1931 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) { 1925 if (copy_from_user(&tmp, newinfo, sizeof(tmp))) {
1932 func_enter(); 1926 func_enter();
1933 return -EFAULT; 1927 return -EFAULT;
1934 } 1928 }
1935 1929
1936#if 0 1930 lock_kernel();
1937 if ((tmp.irq != bp->irq) ||
1938 (tmp.port != bp->base) ||
1939 (tmp.type != PORT_CIRRUS) ||
1940 (tmp.baud_base != (SX_OSCFREQ + CD186x_TPC/2) / CD186x_TPC) ||
1941 (tmp.custom_divisor != 0) ||
1942 (tmp.xmit_fifo_size != CD186x_NFIFO) ||
1943 (tmp.flags & ~SPECIALIX_LEGAL_FLAGS)) {
1944 func_exit();
1945 return -EINVAL;
1946 }
1947#endif
1948 1931
1949 change_speed = ((port->flags & ASYNC_SPD_MASK) != 1932 change_speed = ((port->flags & ASYNC_SPD_MASK) !=
1950 (tmp.flags & ASYNC_SPD_MASK)); 1933 (tmp.flags & ASYNC_SPD_MASK));
@@ -1956,6 +1939,7 @@ static inline int sx_set_serial_info(struct specialix_port * port,
1956 ((tmp.flags & ~ASYNC_USR_MASK) != 1939 ((tmp.flags & ~ASYNC_USR_MASK) !=
1957 (port->flags & ~ASYNC_USR_MASK))) { 1940 (port->flags & ~ASYNC_USR_MASK))) {
1958 func_exit(); 1941 func_exit();
1942 unlock_kernel();
1959 return -EPERM; 1943 return -EPERM;
1960 } 1944 }
1961 port->flags = ((port->flags & ~ASYNC_USR_MASK) | 1945 port->flags = ((port->flags & ~ASYNC_USR_MASK) |
@@ -1972,6 +1956,7 @@ static inline int sx_set_serial_info(struct specialix_port * port,
1972 sx_change_speed(bp, port); 1956 sx_change_speed(bp, port);
1973 } 1957 }
1974 func_exit(); 1958 func_exit();
1959 unlock_kernel();
1975 return 0; 1960 return 0;
1976} 1961}
1977 1962
@@ -1984,12 +1969,8 @@ static inline int sx_get_serial_info(struct specialix_port * port,
1984 1969
1985 func_enter(); 1970 func_enter();
1986 1971
1987 /*
1988 if (!access_ok(VERIFY_WRITE, (void *) retinfo, sizeof(tmp)))
1989 return -EFAULT;
1990 */
1991
1992 memset(&tmp, 0, sizeof(tmp)); 1972 memset(&tmp, 0, sizeof(tmp));
1973 lock_kernel();
1993 tmp.type = PORT_CIRRUS; 1974 tmp.type = PORT_CIRRUS;
1994 tmp.line = port - sx_port; 1975 tmp.line = port - sx_port;
1995 tmp.port = bp->base; 1976 tmp.port = bp->base;
@@ -2000,6 +1981,7 @@ static inline int sx_get_serial_info(struct specialix_port * port,
2000 tmp.closing_wait = port->closing_wait * HZ/100; 1981 tmp.closing_wait = port->closing_wait * HZ/100;
2001 tmp.custom_divisor = port->custom_divisor; 1982 tmp.custom_divisor = port->custom_divisor;
2002 tmp.xmit_fifo_size = CD186x_NFIFO; 1983 tmp.xmit_fifo_size = CD186x_NFIFO;
1984 unlock_kernel();
2003 if (copy_to_user(retinfo, &tmp, sizeof(tmp))) { 1985 if (copy_to_user(retinfo, &tmp, sizeof(tmp))) {
2004 func_exit(); 1986 func_exit();
2005 return -EFAULT; 1987 return -EFAULT;
@@ -2045,23 +2027,6 @@ static int sx_ioctl(struct tty_struct * tty, struct file * filp,
2045 sx_send_break(port, arg ? arg*(HZ/10) : HZ/4); 2027 sx_send_break(port, arg ? arg*(HZ/10) : HZ/4);
2046 func_exit(); 2028 func_exit();
2047 return 0; 2029 return 0;
2048 case TIOCGSOFTCAR:
2049 if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)argp)) {
2050 func_exit();
2051 return -EFAULT;
2052 }
2053 func_exit();
2054 return 0;
2055 case TIOCSSOFTCAR:
2056 if (get_user(arg, (unsigned long __user *) argp)) {
2057 func_exit();
2058 return -EFAULT;
2059 }
2060 tty->termios->c_cflag =
2061 ((tty->termios->c_cflag & ~CLOCAL) |
2062 (arg ? CLOCAL : 0));
2063 func_exit();
2064 return 0;
2065 case TIOCGSERIAL: 2030 case TIOCGSERIAL:
2066 func_exit(); 2031 func_exit();
2067 return sx_get_serial_info(port, argp); 2032 return sx_get_serial_info(port, argp);
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index 874aaa08e956..d17be10c5d21 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -875,6 +875,7 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout)
875 timeout = HZ; 875 timeout = HZ;
876 tend = jiffies + timeout; 876 tend = jiffies + timeout;
877 877
878 lock_kernel();
878 while (stl_datastate(portp)) { 879 while (stl_datastate(portp)) {
879 if (signal_pending(current)) 880 if (signal_pending(current))
880 break; 881 break;
@@ -882,6 +883,7 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout)
882 if (time_after_eq(jiffies, tend)) 883 if (time_after_eq(jiffies, tend))
883 break; 884 break;
884 } 885 }
886 unlock_kernel();
885} 887}
886 888
887/*****************************************************************************/ 889/*****************************************************************************/
@@ -1273,18 +1275,9 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd
1273 1275
1274 rc = 0; 1276 rc = 0;
1275 1277
1278 lock_kernel();
1279
1276 switch (cmd) { 1280 switch (cmd) {
1277 case TIOCGSOFTCAR:
1278 rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
1279 (unsigned __user *) argp);
1280 break;
1281 case TIOCSSOFTCAR:
1282 if (get_user(ival, (unsigned int __user *) arg))
1283 return -EFAULT;
1284 tty->termios->c_cflag =
1285 (tty->termios->c_cflag & ~CLOCAL) |
1286 (ival ? CLOCAL : 0);
1287 break;
1288 case TIOCGSERIAL: 1281 case TIOCGSERIAL:
1289 rc = stl_getserial(portp, argp); 1282 rc = stl_getserial(portp, argp);
1290 break; 1283 break;
@@ -1308,7 +1301,7 @@ static int stl_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd
1308 rc = -ENOIOCTLCMD; 1301 rc = -ENOIOCTLCMD;
1309 break; 1302 break;
1310 } 1303 }
1311 1304 unlock_kernel();
1312 return rc; 1305 return rc;
1313} 1306}
1314 1307
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index a6e1c9ba1217..f39f6fd89350 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -384,11 +384,11 @@ static struct real_driver sx_real_driver = {
384#define sx_dprintk(f, str...) /* nothing */ 384#define sx_dprintk(f, str...) /* nothing */
385#endif 385#endif
386 386
387#define func_enter() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s\n",__FUNCTION__) 387#define func_enter() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s\n",__func__)
388#define func_exit() sx_dprintk(SX_DEBUG_FLOW, "sx: exit %s\n",__FUNCTION__) 388#define func_exit() sx_dprintk(SX_DEBUG_FLOW, "sx: exit %s\n",__func__)
389 389
390#define func_enter2() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \ 390#define func_enter2() sx_dprintk(SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \
391 __FUNCTION__, port->line) 391 __func__, port->line)
392 392
393/* 393/*
394 * Firmware loader driver specific routines 394 * Firmware loader driver specific routines
@@ -1574,7 +1574,7 @@ static void sx_close(void *ptr)
1574 sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", 1574 sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n",
1575 port->gs.count); 1575 port->gs.count);
1576 /*printk("%s SETTING port count to zero: %p count: %d\n", 1576 /*printk("%s SETTING port count to zero: %p count: %d\n",
1577 __FUNCTION__, port, port->gs.count); 1577 __func__, port, port->gs.count);
1578 port->gs.count = 0;*/ 1578 port->gs.count = 0;*/
1579 } 1579 }
1580 1580
@@ -1844,6 +1844,7 @@ static void sx_break(struct tty_struct *tty, int flag)
1844 int rv; 1844 int rv;
1845 1845
1846 func_enter(); 1846 func_enter();
1847 lock_kernel();
1847 1848
1848 if (flag) 1849 if (flag)
1849 rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK); 1850 rv = sx_send_command(port, HS_START, -1, HS_IDLE_BREAK);
@@ -1852,7 +1853,7 @@ static void sx_break(struct tty_struct *tty, int flag)
1852 if (rv != 1) 1853 if (rv != 1)
1853 printk(KERN_ERR "sx: couldn't send break (%x).\n", 1854 printk(KERN_ERR "sx: couldn't send break (%x).\n",
1854 read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat))); 1855 read_sx_byte(port->board, CHAN_OFFSET(port, hi_hstat)));
1855 1856 unlock_kernel();
1856 func_exit(); 1857 func_exit();
1857} 1858}
1858 1859
@@ -1888,23 +1889,12 @@ static int sx_ioctl(struct tty_struct *tty, struct file *filp,
1888 int rc; 1889 int rc;
1889 struct sx_port *port = tty->driver_data; 1890 struct sx_port *port = tty->driver_data;
1890 void __user *argp = (void __user *)arg; 1891 void __user *argp = (void __user *)arg;
1891 int ival;
1892 1892
1893 /* func_enter2(); */ 1893 /* func_enter2(); */
1894 1894
1895 rc = 0; 1895 rc = 0;
1896 lock_kernel();
1896 switch (cmd) { 1897 switch (cmd) {
1897 case TIOCGSOFTCAR:
1898 rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
1899 (unsigned __user *)argp);
1900 break;
1901 case TIOCSSOFTCAR:
1902 if ((rc = get_user(ival, (unsigned __user *)argp)) == 0) {
1903 tty->termios->c_cflag =
1904 (tty->termios->c_cflag & ~CLOCAL) |
1905 (ival ? CLOCAL : 0);
1906 }
1907 break;
1908 case TIOCGSERIAL: 1898 case TIOCGSERIAL:
1909 rc = gs_getserial(&port->gs, argp); 1899 rc = gs_getserial(&port->gs, argp);
1910 break; 1900 break;
@@ -1915,6 +1905,7 @@ static int sx_ioctl(struct tty_struct *tty, struct file *filp,
1915 rc = -ENOIOCTLCMD; 1905 rc = -ENOIOCTLCMD;
1916 break; 1906 break;
1917 } 1907 }
1908 unlock_kernel();
1918 1909
1919 /* func_exit(); */ 1910 /* func_exit(); */
1920 return rc; 1911 return rc;
@@ -2549,7 +2540,7 @@ static int __devinit sx_eisa_probe(struct device *dev)
2549 goto err_flag; 2540 goto err_flag;
2550 } 2541 }
2551 board->base2 = 2542 board->base2 =
2552 board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN); 2543 board->base = ioremap_nocache(board->hw_base, SI2_EISA_WINDOW_LEN);
2553 if (!board->base) { 2544 if (!board->base) {
2554 dev_err(dev, "can't remap memory\n"); 2545 dev_err(dev, "can't remap memory\n");
2555 goto err_reg; 2546 goto err_reg;
@@ -2626,7 +2617,7 @@ static void __devinit fix_sx_pci(struct pci_dev *pdev, struct sx_board *board)
2626 2617
2627 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase); 2618 pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
2628 hwbase &= PCI_BASE_ADDRESS_MEM_MASK; 2619 hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
2629 rebase = ioremap(hwbase, 0x80); 2620 rebase = ioremap_nocache(hwbase, 0x80);
2630 t = readl(rebase + CNTRL_REG_OFFSET); 2621 t = readl(rebase + CNTRL_REG_OFFSET);
2631 if (t != CNTRL_REG_GOODVALUE) { 2622 if (t != CNTRL_REG_GOODVALUE) {
2632 printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> " 2623 printk(KERN_DEBUG "sx: performing cntrl reg fix: %08x -> "
@@ -2770,7 +2761,7 @@ static int __init sx_init(void)
2770 if (!request_region(board->hw_base, board->hw_len, "sx")) 2761 if (!request_region(board->hw_base, board->hw_len, "sx"))
2771 continue; 2762 continue;
2772 board->base2 = 2763 board->base2 =
2773 board->base = ioremap(board->hw_base, board->hw_len); 2764 board->base = ioremap_nocache(board->hw_base, board->hw_len);
2774 if (!board->base) 2765 if (!board->base)
2775 goto err_sx_reg; 2766 goto err_sx_reg;
2776 board->flags &= ~SX_BOARD_TYPE; 2767 board->flags &= ~SX_BOARD_TYPE;
@@ -2794,7 +2785,7 @@ err_sx_reg:
2794 if (!request_region(board->hw_base, board->hw_len, "sx")) 2785 if (!request_region(board->hw_base, board->hw_len, "sx"))
2795 continue; 2786 continue;
2796 board->base2 = 2787 board->base2 =
2797 board->base = ioremap(board->hw_base, board->hw_len); 2788 board->base = ioremap_nocache(board->hw_base, board->hw_len);
2798 if (!board->base) 2789 if (!board->base)
2799 goto err_si_reg; 2790 goto err_si_reg;
2800 board->flags &= ~SX_BOARD_TYPE; 2791 board->flags &= ~SX_BOARD_TYPE;
@@ -2817,7 +2808,7 @@ err_si_reg:
2817 if (!request_region(board->hw_base, board->hw_len, "sx")) 2808 if (!request_region(board->hw_base, board->hw_len, "sx"))
2818 continue; 2809 continue;
2819 board->base2 = 2810 board->base2 =
2820 board->base = ioremap(board->hw_base, board->hw_len); 2811 board->base = ioremap_nocache(board->hw_base, board->hw_len);
2821 if (!board->base) 2812 if (!board->base)
2822 goto err_si1_reg; 2813 goto err_si1_reg;
2823 board->flags &= ~SX_BOARD_TYPE; 2814 board->flags &= ~SX_BOARD_TYPE;
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index fadab1d9510f..513b7c2f3e26 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -2026,10 +2026,11 @@ static void mgsl_change_params(struct mgsl_struct *info)
2026 * 2026 *
2027 * Return Value: None 2027 * Return Value: None
2028 */ 2028 */
2029static void mgsl_put_char(struct tty_struct *tty, unsigned char ch) 2029static int mgsl_put_char(struct tty_struct *tty, unsigned char ch)
2030{ 2030{
2031 struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; 2031 struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data;
2032 unsigned long flags; 2032 unsigned long flags;
2033 int ret;
2033 2034
2034 if ( debug_level >= DEBUG_LEVEL_INFO ) { 2035 if ( debug_level >= DEBUG_LEVEL_INFO ) {
2035 printk( "%s(%d):mgsl_put_char(%d) on %s\n", 2036 printk( "%s(%d):mgsl_put_char(%d) on %s\n",
@@ -2037,23 +2038,23 @@ static void mgsl_put_char(struct tty_struct *tty, unsigned char ch)
2037 } 2038 }
2038 2039
2039 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char")) 2040 if (mgsl_paranoia_check(info, tty->name, "mgsl_put_char"))
2040 return; 2041 return 0;
2041 2042
2042 if (!tty || !info->xmit_buf) 2043 if (!tty || !info->xmit_buf)
2043 return; 2044 return 0;
2044 2045
2045 spin_lock_irqsave(&info->irq_spinlock,flags); 2046 spin_lock_irqsave(&info->irq_spinlock,flags);
2046 2047
2047 if ( (info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active ) { 2048 if ( (info->params.mode == MGSL_MODE_ASYNC ) || !info->tx_active ) {
2048
2049 if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) { 2049 if (info->xmit_cnt < SERIAL_XMIT_SIZE - 1) {
2050 info->xmit_buf[info->xmit_head++] = ch; 2050 info->xmit_buf[info->xmit_head++] = ch;
2051 info->xmit_head &= SERIAL_XMIT_SIZE-1; 2051 info->xmit_head &= SERIAL_XMIT_SIZE-1;
2052 info->xmit_cnt++; 2052 info->xmit_cnt++;
2053 ret = 1;
2053 } 2054 }
2054 } 2055 }
2055
2056 spin_unlock_irqrestore(&info->irq_spinlock,flags); 2056 spin_unlock_irqrestore(&info->irq_spinlock,flags);
2057 return ret;
2057 2058
2058} /* end of mgsl_put_char() */ 2059} /* end of mgsl_put_char() */
2059 2060
@@ -2942,6 +2943,7 @@ static int mgsl_ioctl(struct tty_struct *tty, struct file * file,
2942 unsigned int cmd, unsigned long arg) 2943 unsigned int cmd, unsigned long arg)
2943{ 2944{
2944 struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; 2945 struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data;
2946 int ret;
2945 2947
2946 if (debug_level >= DEBUG_LEVEL_INFO) 2948 if (debug_level >= DEBUG_LEVEL_INFO)
2947 printk("%s(%d):mgsl_ioctl %s cmd=%08X\n", __FILE__,__LINE__, 2949 printk("%s(%d):mgsl_ioctl %s cmd=%08X\n", __FILE__,__LINE__,
@@ -2956,7 +2958,10 @@ static int mgsl_ioctl(struct tty_struct *tty, struct file * file,
2956 return -EIO; 2958 return -EIO;
2957 } 2959 }
2958 2960
2959 return mgsl_ioctl_common(info, cmd, arg); 2961 lock_kernel();
2962 ret = mgsl_ioctl_common(info, cmd, arg);
2963 unlock_kernel();
2964 return ret;
2960} 2965}
2961 2966
2962static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg) 2967static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg)
@@ -3153,8 +3158,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
3153 if (info->flags & ASYNC_INITIALIZED) 3158 if (info->flags & ASYNC_INITIALIZED)
3154 mgsl_wait_until_sent(tty, info->timeout); 3159 mgsl_wait_until_sent(tty, info->timeout);
3155 3160
3156 if (tty->driver->flush_buffer) 3161 mgsl_flush_buffer(tty);
3157 tty->driver->flush_buffer(tty);
3158 3162
3159 tty_ldisc_flush(tty); 3163 tty_ldisc_flush(tty);
3160 3164
@@ -3217,7 +3221,8 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
3217 * interval should also be less than the timeout. 3221 * interval should also be less than the timeout.
3218 * Note: use tight timings here to satisfy the NIST-PCTS. 3222 * Note: use tight timings here to satisfy the NIST-PCTS.
3219 */ 3223 */
3220 3224
3225 lock_kernel();
3221 if ( info->params.data_rate ) { 3226 if ( info->params.data_rate ) {
3222 char_time = info->timeout/(32 * 5); 3227 char_time = info->timeout/(32 * 5);
3223 if (!char_time) 3228 if (!char_time)
@@ -3247,6 +3252,7 @@ static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout)
3247 break; 3252 break;
3248 } 3253 }
3249 } 3254 }
3255 unlock_kernel();
3250 3256
3251exit: 3257exit:
3252 if (debug_level >= DEBUG_LEVEL_INFO) 3258 if (debug_level >= DEBUG_LEVEL_INFO)
@@ -4144,7 +4150,8 @@ static int mgsl_claim_resources(struct mgsl_struct *info)
4144 } 4150 }
4145 info->lcr_mem_requested = true; 4151 info->lcr_mem_requested = true;
4146 4152
4147 info->memory_base = ioremap(info->phys_memory_base,0x40000); 4153 info->memory_base = ioremap_nocache(info->phys_memory_base,
4154 0x40000);
4148 if (!info->memory_base) { 4155 if (!info->memory_base) {
4149 printk( "%s(%d):Cant map shared memory on device %s MemAddr=%08X\n", 4156 printk( "%s(%d):Cant map shared memory on device %s MemAddr=%08X\n",
4150 __FILE__,__LINE__,info->device_name, info->phys_memory_base ); 4157 __FILE__,__LINE__,info->device_name, info->phys_memory_base );
@@ -4157,12 +4164,14 @@ static int mgsl_claim_resources(struct mgsl_struct *info)
4157 goto errout; 4164 goto errout;
4158 } 4165 }
4159 4166
4160 info->lcr_base = ioremap(info->phys_lcr_base,PAGE_SIZE) + info->lcr_offset; 4167 info->lcr_base = ioremap_nocache(info->phys_lcr_base,
4168 PAGE_SIZE);
4161 if (!info->lcr_base) { 4169 if (!info->lcr_base) {
4162 printk( "%s(%d):Cant map LCR memory on device %s MemAddr=%08X\n", 4170 printk( "%s(%d):Cant map LCR memory on device %s MemAddr=%08X\n",
4163 __FILE__,__LINE__,info->device_name, info->phys_lcr_base ); 4171 __FILE__,__LINE__,info->device_name, info->phys_lcr_base );
4164 goto errout; 4172 goto errout;
4165 } 4173 }
4174 info->lcr_base += info->lcr_offset;
4166 4175
4167 } else { 4176 } else {
4168 /* claim DMA channel */ 4177 /* claim DMA channel */
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index f3d8d72e5ea4..2001b0e52dc6 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -151,7 +151,7 @@ static void hangup(struct tty_struct *tty);
151static void set_termios(struct tty_struct *tty, struct ktermios *old_termios); 151static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
152 152
153static int write(struct tty_struct *tty, const unsigned char *buf, int count); 153static int write(struct tty_struct *tty, const unsigned char *buf, int count);
154static void put_char(struct tty_struct *tty, unsigned char ch); 154static int put_char(struct tty_struct *tty, unsigned char ch);
155static void send_xchar(struct tty_struct *tty, char ch); 155static void send_xchar(struct tty_struct *tty, char ch);
156static void wait_until_sent(struct tty_struct *tty, int timeout); 156static void wait_until_sent(struct tty_struct *tty, int timeout);
157static int write_room(struct tty_struct *tty); 157static int write_room(struct tty_struct *tty);
@@ -771,8 +771,7 @@ static void close(struct tty_struct *tty, struct file *filp)
771 771
772 if (info->flags & ASYNC_INITIALIZED) 772 if (info->flags & ASYNC_INITIALIZED)
773 wait_until_sent(tty, info->timeout); 773 wait_until_sent(tty, info->timeout);
774 if (tty->driver->flush_buffer) 774 flush_buffer(tty);
775 tty->driver->flush_buffer(tty);
776 tty_ldisc_flush(tty); 775 tty_ldisc_flush(tty);
777 776
778 shutdown(info); 777 shutdown(info);
@@ -913,20 +912,24 @@ cleanup:
913 return ret; 912 return ret;
914} 913}
915 914
916static void put_char(struct tty_struct *tty, unsigned char ch) 915static int put_char(struct tty_struct *tty, unsigned char ch)
917{ 916{
918 struct slgt_info *info = tty->driver_data; 917 struct slgt_info *info = tty->driver_data;
919 unsigned long flags; 918 unsigned long flags;
919 int ret;
920 920
921 if (sanity_check(info, tty->name, "put_char")) 921 if (sanity_check(info, tty->name, "put_char"))
922 return; 922 return 0;
923 DBGINFO(("%s put_char(%d)\n", info->device_name, ch)); 923 DBGINFO(("%s put_char(%d)\n", info->device_name, ch));
924 if (!info->tx_buf) 924 if (!info->tx_buf)
925 return; 925 return 0;
926 spin_lock_irqsave(&info->lock,flags); 926 spin_lock_irqsave(&info->lock,flags);
927 if (!info->tx_active && (info->tx_count < info->max_frame_size)) 927 if (!info->tx_active && (info->tx_count < info->max_frame_size)) {
928 info->tx_buf[info->tx_count++] = ch; 928 info->tx_buf[info->tx_count++] = ch;
929 ret = 1;
930 }
929 spin_unlock_irqrestore(&info->lock,flags); 931 spin_unlock_irqrestore(&info->lock,flags);
932 return ret;
930} 933}
931 934
932static void send_xchar(struct tty_struct *tty, char ch) 935static void send_xchar(struct tty_struct *tty, char ch)
@@ -967,6 +970,8 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
967 * Note: use tight timings here to satisfy the NIST-PCTS. 970 * Note: use tight timings here to satisfy the NIST-PCTS.
968 */ 971 */
969 972
973 lock_kernel();
974
970 if (info->params.data_rate) { 975 if (info->params.data_rate) {
971 char_time = info->timeout/(32 * 5); 976 char_time = info->timeout/(32 * 5);
972 if (!char_time) 977 if (!char_time)
@@ -984,6 +989,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
984 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 989 if (timeout && time_after(jiffies, orig_jiffies + timeout))
985 break; 990 break;
986 } 991 }
992 unlock_kernel();
987 993
988exit: 994exit:
989 DBGINFO(("%s wait_until_sent exit\n", info->device_name)); 995 DBGINFO(("%s wait_until_sent exit\n", info->device_name));
@@ -1097,6 +1103,7 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1097 struct serial_icounter_struct __user *p_cuser; /* user space */ 1103 struct serial_icounter_struct __user *p_cuser; /* user space */
1098 unsigned long flags; 1104 unsigned long flags;
1099 void __user *argp = (void __user *)arg; 1105 void __user *argp = (void __user *)arg;
1106 int ret;
1100 1107
1101 if (sanity_check(info, tty->name, "ioctl")) 1108 if (sanity_check(info, tty->name, "ioctl"))
1102 return -ENODEV; 1109 return -ENODEV;
@@ -1108,37 +1115,54 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1108 return -EIO; 1115 return -EIO;
1109 } 1116 }
1110 1117
1118 lock_kernel();
1119
1111 switch (cmd) { 1120 switch (cmd) {
1112 case MGSL_IOCGPARAMS: 1121 case MGSL_IOCGPARAMS:
1113 return get_params(info, argp); 1122 ret = get_params(info, argp);
1123 break;
1114 case MGSL_IOCSPARAMS: 1124 case MGSL_IOCSPARAMS:
1115 return set_params(info, argp); 1125 ret = set_params(info, argp);
1126 break;
1116 case MGSL_IOCGTXIDLE: 1127 case MGSL_IOCGTXIDLE:
1117 return get_txidle(info, argp); 1128 ret = get_txidle(info, argp);
1129 break;
1118 case MGSL_IOCSTXIDLE: 1130 case MGSL_IOCSTXIDLE:
1119 return set_txidle(info, (int)arg); 1131 ret = set_txidle(info, (int)arg);
1132 break;
1120 case MGSL_IOCTXENABLE: 1133 case MGSL_IOCTXENABLE:
1121 return tx_enable(info, (int)arg); 1134 ret = tx_enable(info, (int)arg);
1135 break;
1122 case MGSL_IOCRXENABLE: 1136 case MGSL_IOCRXENABLE:
1123 return rx_enable(info, (int)arg); 1137 ret = rx_enable(info, (int)arg);
1138 break;
1124 case MGSL_IOCTXABORT: 1139 case MGSL_IOCTXABORT:
1125 return tx_abort(info); 1140 ret = tx_abort(info);
1141 break;
1126 case MGSL_IOCGSTATS: 1142 case MGSL_IOCGSTATS:
1127 return get_stats(info, argp); 1143 ret = get_stats(info, argp);
1144 break;
1128 case MGSL_IOCWAITEVENT: 1145 case MGSL_IOCWAITEVENT:
1129 return wait_mgsl_event(info, argp); 1146 ret = wait_mgsl_event(info, argp);
1147 break;
1130 case TIOCMIWAIT: 1148 case TIOCMIWAIT:
1131 return modem_input_wait(info,(int)arg); 1149 ret = modem_input_wait(info,(int)arg);
1150 break;
1132 case MGSL_IOCGIF: 1151 case MGSL_IOCGIF:
1133 return get_interface(info, argp); 1152 ret = get_interface(info, argp);
1153 break;
1134 case MGSL_IOCSIF: 1154 case MGSL_IOCSIF:
1135 return set_interface(info,(int)arg); 1155 ret = set_interface(info,(int)arg);
1156 break;
1136 case MGSL_IOCSGPIO: 1157 case MGSL_IOCSGPIO:
1137 return set_gpio(info, argp); 1158 ret = set_gpio(info, argp);
1159 break;
1138 case MGSL_IOCGGPIO: 1160 case MGSL_IOCGGPIO:
1139 return get_gpio(info, argp); 1161 ret = get_gpio(info, argp);
1162 break;
1140 case MGSL_IOCWAITGPIO: 1163 case MGSL_IOCWAITGPIO:
1141 return wait_gpio(info, argp); 1164 ret = wait_gpio(info, argp);
1165 break;
1142 case TIOCGICOUNT: 1166 case TIOCGICOUNT:
1143 spin_lock_irqsave(&info->lock,flags); 1167 spin_lock_irqsave(&info->lock,flags);
1144 cnow = info->icount; 1168 cnow = info->icount;
@@ -1155,12 +1179,14 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1155 put_user(cnow.parity, &p_cuser->parity) || 1179 put_user(cnow.parity, &p_cuser->parity) ||
1156 put_user(cnow.brk, &p_cuser->brk) || 1180 put_user(cnow.brk, &p_cuser->brk) ||
1157 put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) 1181 put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
1158 return -EFAULT; 1182 ret = -EFAULT;
1159 return 0; 1183 ret = 0;
1184 break;
1160 default: 1185 default:
1161 return -ENOIOCTLCMD; 1186 ret = -ENOIOCTLCMD;
1162 } 1187 }
1163 return 0; 1188 unlock_kernel();
1189 return ret;
1164} 1190}
1165 1191
1166/* 1192/*
@@ -3324,7 +3350,7 @@ static int claim_resources(struct slgt_info *info)
3324 else 3350 else
3325 info->reg_addr_requested = true; 3351 info->reg_addr_requested = true;
3326 3352
3327 info->reg_addr = ioremap(info->phys_reg_addr, SLGT_REG_SIZE); 3353 info->reg_addr = ioremap_nocache(info->phys_reg_addr, SLGT_REG_SIZE);
3328 if (!info->reg_addr) { 3354 if (!info->reg_addr) {
3329 DBGERR(("%s cant map device registers, addr=%08X\n", 3355 DBGERR(("%s cant map device registers, addr=%08X\n",
3330 info->device_name, info->phys_reg_addr)); 3356 info->device_name, info->phys_reg_addr));
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index e98c3e6f8216..bec54866e0bb 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -519,7 +519,7 @@ static void hangup(struct tty_struct *tty);
519static void set_termios(struct tty_struct *tty, struct ktermios *old_termios); 519static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
520 520
521static int write(struct tty_struct *tty, const unsigned char *buf, int count); 521static int write(struct tty_struct *tty, const unsigned char *buf, int count);
522static void put_char(struct tty_struct *tty, unsigned char ch); 522static int put_char(struct tty_struct *tty, unsigned char ch);
523static void send_xchar(struct tty_struct *tty, char ch); 523static void send_xchar(struct tty_struct *tty, char ch);
524static void wait_until_sent(struct tty_struct *tty, int timeout); 524static void wait_until_sent(struct tty_struct *tty, int timeout);
525static int write_room(struct tty_struct *tty); 525static int write_room(struct tty_struct *tty);
@@ -862,8 +862,7 @@ static void close(struct tty_struct *tty, struct file *filp)
862 if (info->flags & ASYNC_INITIALIZED) 862 if (info->flags & ASYNC_INITIALIZED)
863 wait_until_sent(tty, info->timeout); 863 wait_until_sent(tty, info->timeout);
864 864
865 if (tty->driver->flush_buffer) 865 flush_buffer(tty);
866 tty->driver->flush_buffer(tty);
867 866
868 tty_ldisc_flush(tty); 867 tty_ldisc_flush(tty);
869 868
@@ -1046,10 +1045,11 @@ cleanup:
1046 1045
1047/* Add a character to the transmit buffer. 1046/* Add a character to the transmit buffer.
1048 */ 1047 */
1049static void put_char(struct tty_struct *tty, unsigned char ch) 1048static int put_char(struct tty_struct *tty, unsigned char ch)
1050{ 1049{
1051 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; 1050 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
1052 unsigned long flags; 1051 unsigned long flags;
1052 int ret = 0;
1053 1053
1054 if ( debug_level >= DEBUG_LEVEL_INFO ) { 1054 if ( debug_level >= DEBUG_LEVEL_INFO ) {
1055 printk( "%s(%d):%s put_char(%d)\n", 1055 printk( "%s(%d):%s put_char(%d)\n",
@@ -1057,10 +1057,10 @@ static void put_char(struct tty_struct *tty, unsigned char ch)
1057 } 1057 }
1058 1058
1059 if (sanity_check(info, tty->name, "put_char")) 1059 if (sanity_check(info, tty->name, "put_char"))
1060 return; 1060 return 0;
1061 1061
1062 if (!info->tx_buf) 1062 if (!info->tx_buf)
1063 return; 1063 return 0;
1064 1064
1065 spin_lock_irqsave(&info->lock,flags); 1065 spin_lock_irqsave(&info->lock,flags);
1066 1066
@@ -1072,10 +1072,12 @@ static void put_char(struct tty_struct *tty, unsigned char ch)
1072 if (info->tx_put >= info->max_frame_size) 1072 if (info->tx_put >= info->max_frame_size)
1073 info->tx_put -= info->max_frame_size; 1073 info->tx_put -= info->max_frame_size;
1074 info->tx_count++; 1074 info->tx_count++;
1075 ret = 1;
1075 } 1076 }
1076 } 1077 }
1077 1078
1078 spin_unlock_irqrestore(&info->lock,flags); 1079 spin_unlock_irqrestore(&info->lock,flags);
1080 return ret;
1079} 1081}
1080 1082
1081/* Send a high-priority XON/XOFF character 1083/* Send a high-priority XON/XOFF character
@@ -1119,6 +1121,8 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
1119 if (sanity_check(info, tty->name, "wait_until_sent")) 1121 if (sanity_check(info, tty->name, "wait_until_sent"))
1120 return; 1122 return;
1121 1123
1124 lock_kernel();
1125
1122 if (!(info->flags & ASYNC_INITIALIZED)) 1126 if (!(info->flags & ASYNC_INITIALIZED))
1123 goto exit; 1127 goto exit;
1124 1128
@@ -1161,6 +1165,7 @@ static void wait_until_sent(struct tty_struct *tty, int timeout)
1161 } 1165 }
1162 1166
1163exit: 1167exit:
1168 unlock_kernel();
1164 if (debug_level >= DEBUG_LEVEL_INFO) 1169 if (debug_level >= DEBUG_LEVEL_INFO)
1165 printk("%s(%d):%s wait_until_sent() exit\n", 1170 printk("%s(%d):%s wait_until_sent() exit\n",
1166 __FILE__,__LINE__, info->device_name ); 1171 __FILE__,__LINE__, info->device_name );
@@ -1176,6 +1181,7 @@ static int write_room(struct tty_struct *tty)
1176 if (sanity_check(info, tty->name, "write_room")) 1181 if (sanity_check(info, tty->name, "write_room"))
1177 return 0; 1182 return 0;
1178 1183
1184 lock_kernel();
1179 if (info->params.mode == MGSL_MODE_HDLC) { 1185 if (info->params.mode == MGSL_MODE_HDLC) {
1180 ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE; 1186 ret = (info->tx_active) ? 0 : HDLC_MAX_FRAME_SIZE;
1181 } else { 1187 } else {
@@ -1183,6 +1189,7 @@ static int write_room(struct tty_struct *tty)
1183 if (ret < 0) 1189 if (ret < 0)
1184 ret = 0; 1190 ret = 0;
1185 } 1191 }
1192 unlock_kernel();
1186 1193
1187 if (debug_level >= DEBUG_LEVEL_INFO) 1194 if (debug_level >= DEBUG_LEVEL_INFO)
1188 printk("%s(%d):%s write_room()=%d\n", 1195 printk("%s(%d):%s write_room()=%d\n",
@@ -1303,7 +1310,7 @@ static void tx_release(struct tty_struct *tty)
1303 * 1310 *
1304 * Return Value: 0 if success, otherwise error code 1311 * Return Value: 0 if success, otherwise error code
1305 */ 1312 */
1306static int ioctl(struct tty_struct *tty, struct file *file, 1313static int do_ioctl(struct tty_struct *tty, struct file *file,
1307 unsigned int cmd, unsigned long arg) 1314 unsigned int cmd, unsigned long arg)
1308{ 1315{
1309 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; 1316 SLMP_INFO *info = (SLMP_INFO *)tty->driver_data;
@@ -1393,6 +1400,16 @@ static int ioctl(struct tty_struct *tty, struct file *file,
1393 return 0; 1400 return 0;
1394} 1401}
1395 1402
1403static int ioctl(struct tty_struct *tty, struct file *file,
1404 unsigned int cmd, unsigned long arg)
1405{
1406 int ret;
1407 lock_kernel();
1408 ret = do_ioctl(tty, file, cmd, arg);
1409 unlock_kernel();
1410 return ret;
1411}
1412
1396/* 1413/*
1397 * /proc fs routines.... 1414 * /proc fs routines....
1398 */ 1415 */
@@ -3626,7 +3643,8 @@ static int claim_resources(SLMP_INFO *info)
3626 else 3643 else
3627 info->sca_statctrl_requested = true; 3644 info->sca_statctrl_requested = true;
3628 3645
3629 info->memory_base = ioremap(info->phys_memory_base,SCA_MEM_SIZE); 3646 info->memory_base = ioremap_nocache(info->phys_memory_base,
3647 SCA_MEM_SIZE);
3630 if (!info->memory_base) { 3648 if (!info->memory_base) {
3631 printk( "%s(%d):%s Cant map shared memory, MemAddr=%08X\n", 3649 printk( "%s(%d):%s Cant map shared memory, MemAddr=%08X\n",
3632 __FILE__,__LINE__,info->device_name, info->phys_memory_base ); 3650 __FILE__,__LINE__,info->device_name, info->phys_memory_base );
@@ -3634,7 +3652,7 @@ static int claim_resources(SLMP_INFO *info)
3634 goto errout; 3652 goto errout;
3635 } 3653 }
3636 3654
3637 info->lcr_base = ioremap(info->phys_lcr_base,PAGE_SIZE); 3655 info->lcr_base = ioremap_nocache(info->phys_lcr_base, PAGE_SIZE);
3638 if (!info->lcr_base) { 3656 if (!info->lcr_base) {
3639 printk( "%s(%d):%s Cant map LCR memory, MemAddr=%08X\n", 3657 printk( "%s(%d):%s Cant map LCR memory, MemAddr=%08X\n",
3640 __FILE__,__LINE__,info->device_name, info->phys_lcr_base ); 3658 __FILE__,__LINE__,info->device_name, info->phys_lcr_base );
@@ -3643,7 +3661,7 @@ static int claim_resources(SLMP_INFO *info)
3643 } 3661 }
3644 info->lcr_base += info->lcr_offset; 3662 info->lcr_base += info->lcr_offset;
3645 3663
3646 info->sca_base = ioremap(info->phys_sca_base,PAGE_SIZE); 3664 info->sca_base = ioremap_nocache(info->phys_sca_base, PAGE_SIZE);
3647 if (!info->sca_base) { 3665 if (!info->sca_base) {
3648 printk( "%s(%d):%s Cant map SCA memory, MemAddr=%08X\n", 3666 printk( "%s(%d):%s Cant map SCA memory, MemAddr=%08X\n",
3649 __FILE__,__LINE__,info->device_name, info->phys_sca_base ); 3667 __FILE__,__LINE__,info->device_name, info->phys_sca_base );
@@ -3652,7 +3670,8 @@ static int claim_resources(SLMP_INFO *info)
3652 } 3670 }
3653 info->sca_base += info->sca_offset; 3671 info->sca_base += info->sca_offset;
3654 3672
3655 info->statctrl_base = ioremap(info->phys_statctrl_base,PAGE_SIZE); 3673 info->statctrl_base = ioremap_nocache(info->phys_statctrl_base,
3674 PAGE_SIZE);
3656 if (!info->statctrl_base) { 3675 if (!info->statctrl_base) {
3657 printk( "%s(%d):%s Cant map SCA Status/Control memory, MemAddr=%08X\n", 3676 printk( "%s(%d):%s Cant map SCA Status/Control memory, MemAddr=%08X\n",
3658 __FILE__,__LINE__,info->device_name, info->phys_statctrl_base ); 3677 __FILE__,__LINE__,info->device_name, info->phys_statctrl_base );
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 2fa6856706ab..1d298c2cf930 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -91,7 +91,6 @@
91#include <linux/module.h> 91#include <linux/module.h>
92#include <linux/smp_lock.h> 92#include <linux/smp_lock.h>
93#include <linux/device.h> 93#include <linux/device.h>
94#include <linux/idr.h>
95#include <linux/wait.h> 94#include <linux/wait.h>
96#include <linux/bitops.h> 95#include <linux/bitops.h>
97#include <linux/delay.h> 96#include <linux/delay.h>
@@ -137,9 +136,6 @@ EXPORT_SYMBOL(tty_mutex);
137 136
138#ifdef CONFIG_UNIX98_PTYS 137#ifdef CONFIG_UNIX98_PTYS
139extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ 138extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */
140extern int pty_limit; /* Config limit on Unix98 ptys */
141static DEFINE_IDR(allocated_ptys);
142static DEFINE_MUTEX(allocated_ptys_lock);
143static int ptmx_open(struct inode *, struct file *); 139static int ptmx_open(struct inode *, struct file *);
144#endif 140#endif
145 141
@@ -152,8 +148,7 @@ ssize_t redirected_tty_write(struct file *, const char __user *,
152static unsigned int tty_poll(struct file *, poll_table *); 148static unsigned int tty_poll(struct file *, poll_table *);
153static int tty_open(struct inode *, struct file *); 149static int tty_open(struct inode *, struct file *);
154static int tty_release(struct inode *, struct file *); 150static int tty_release(struct inode *, struct file *);
155int tty_ioctl(struct inode *inode, struct file *file, 151long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
156 unsigned int cmd, unsigned long arg);
157#ifdef CONFIG_COMPAT 152#ifdef CONFIG_COMPAT
158static long tty_compat_ioctl(struct file *file, unsigned int cmd, 153static long tty_compat_ioctl(struct file *file, unsigned int cmd,
159 unsigned long arg); 154 unsigned long arg);
@@ -1109,8 +1104,8 @@ restart:
1109 a reference to the old ldisc. If we ended up flipping back 1104 a reference to the old ldisc. If we ended up flipping back
1110 to the existing ldisc we have two references to it */ 1105 to the existing ldisc we have two references to it */
1111 1106
1112 if (tty->ldisc.num != o_ldisc.num && tty->driver->set_ldisc) 1107 if (tty->ldisc.num != o_ldisc.num && tty->ops->set_ldisc)
1113 tty->driver->set_ldisc(tty); 1108 tty->ops->set_ldisc(tty);
1114 1109
1115 tty_ldisc_put(o_ldisc.num); 1110 tty_ldisc_put(o_ldisc.num);
1116 1111
@@ -1182,9 +1177,8 @@ struct tty_driver *tty_find_polling_driver(char *name, int *line)
1182 if (*str == '\0') 1177 if (*str == '\0')
1183 str = NULL; 1178 str = NULL;
1184 1179
1185 if (tty_line >= 0 && tty_line <= p->num && p->poll_init && 1180 if (tty_line >= 0 && tty_line <= p->num && p->ops &&
1186 !p->poll_init(p, tty_line, str)) { 1181 p->ops->poll_init && !p->ops->poll_init(p, tty_line, str)) {
1187
1188 res = p; 1182 res = p;
1189 *line = tty_line; 1183 *line = tty_line;
1190 break; 1184 break;
@@ -1205,26 +1199,37 @@ EXPORT_SYMBOL_GPL(tty_find_polling_driver);
1205 * not in the foreground, send a SIGTTOU. If the signal is blocked or 1199 * not in the foreground, send a SIGTTOU. If the signal is blocked or
1206 * ignored, go ahead and perform the operation. (POSIX 7.2) 1200 * ignored, go ahead and perform the operation. (POSIX 7.2)
1207 * 1201 *
1208 * Locking: none 1202 * Locking: ctrl_lock
1209 */ 1203 */
1210 1204
1211int tty_check_change(struct tty_struct *tty) 1205int tty_check_change(struct tty_struct *tty)
1212{ 1206{
1207 unsigned long flags;
1208 int ret = 0;
1209
1213 if (current->signal->tty != tty) 1210 if (current->signal->tty != tty)
1214 return 0; 1211 return 0;
1212
1213 spin_lock_irqsave(&tty->ctrl_lock, flags);
1214
1215 if (!tty->pgrp) { 1215 if (!tty->pgrp) {
1216 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n"); 1216 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n");
1217 return 0; 1217 goto out;
1218 } 1218 }
1219 if (task_pgrp(current) == tty->pgrp) 1219 if (task_pgrp(current) == tty->pgrp)
1220 return 0; 1220 goto out;
1221 if (is_ignored(SIGTTOU)) 1221 if (is_ignored(SIGTTOU))
1222 return 0; 1222 goto out;
1223 if (is_current_pgrp_orphaned()) 1223 if (is_current_pgrp_orphaned()) {
1224 return -EIO; 1224 ret = -EIO;
1225 goto out;
1226 }
1225 kill_pgrp(task_pgrp(current), SIGTTOU, 1); 1227 kill_pgrp(task_pgrp(current), SIGTTOU, 1);
1226 set_thread_flag(TIF_SIGPENDING); 1228 set_thread_flag(TIF_SIGPENDING);
1227 return -ERESTARTSYS; 1229 ret = -ERESTARTSYS;
1230out:
1231 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1232 return ret;
1228} 1233}
1229 1234
1230EXPORT_SYMBOL(tty_check_change); 1235EXPORT_SYMBOL(tty_check_change);
@@ -1247,8 +1252,8 @@ static unsigned int hung_up_tty_poll(struct file *filp, poll_table *wait)
1247 return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM; 1252 return POLLIN | POLLOUT | POLLERR | POLLHUP | POLLRDNORM | POLLWRNORM;
1248} 1253}
1249 1254
1250static int hung_up_tty_ioctl(struct inode *inode, struct file *file, 1255static long hung_up_tty_ioctl(struct file *file, unsigned int cmd,
1251 unsigned int cmd, unsigned long arg) 1256 unsigned long arg)
1252{ 1257{
1253 return cmd == TIOCSPGRP ? -ENOTTY : -EIO; 1258 return cmd == TIOCSPGRP ? -ENOTTY : -EIO;
1254} 1259}
@@ -1264,7 +1269,7 @@ static const struct file_operations tty_fops = {
1264 .read = tty_read, 1269 .read = tty_read,
1265 .write = tty_write, 1270 .write = tty_write,
1266 .poll = tty_poll, 1271 .poll = tty_poll,
1267 .ioctl = tty_ioctl, 1272 .unlocked_ioctl = tty_ioctl,
1268 .compat_ioctl = tty_compat_ioctl, 1273 .compat_ioctl = tty_compat_ioctl,
1269 .open = tty_open, 1274 .open = tty_open,
1270 .release = tty_release, 1275 .release = tty_release,
@@ -1277,7 +1282,7 @@ static const struct file_operations ptmx_fops = {
1277 .read = tty_read, 1282 .read = tty_read,
1278 .write = tty_write, 1283 .write = tty_write,
1279 .poll = tty_poll, 1284 .poll = tty_poll,
1280 .ioctl = tty_ioctl, 1285 .unlocked_ioctl = tty_ioctl,
1281 .compat_ioctl = tty_compat_ioctl, 1286 .compat_ioctl = tty_compat_ioctl,
1282 .open = ptmx_open, 1287 .open = ptmx_open,
1283 .release = tty_release, 1288 .release = tty_release,
@@ -1290,7 +1295,7 @@ static const struct file_operations console_fops = {
1290 .read = tty_read, 1295 .read = tty_read,
1291 .write = redirected_tty_write, 1296 .write = redirected_tty_write,
1292 .poll = tty_poll, 1297 .poll = tty_poll,
1293 .ioctl = tty_ioctl, 1298 .unlocked_ioctl = tty_ioctl,
1294 .compat_ioctl = tty_compat_ioctl, 1299 .compat_ioctl = tty_compat_ioctl,
1295 .open = tty_open, 1300 .open = tty_open,
1296 .release = tty_release, 1301 .release = tty_release,
@@ -1302,7 +1307,7 @@ static const struct file_operations hung_up_tty_fops = {
1302 .read = hung_up_tty_read, 1307 .read = hung_up_tty_read,
1303 .write = hung_up_tty_write, 1308 .write = hung_up_tty_write,
1304 .poll = hung_up_tty_poll, 1309 .poll = hung_up_tty_poll,
1305 .ioctl = hung_up_tty_ioctl, 1310 .unlocked_ioctl = hung_up_tty_ioctl,
1306 .compat_ioctl = hung_up_tty_compat_ioctl, 1311 .compat_ioctl = hung_up_tty_compat_ioctl,
1307 .release = tty_release, 1312 .release = tty_release,
1308}; 1313};
@@ -1404,6 +1409,7 @@ static void do_tty_hangup(struct work_struct *work)
1404 struct task_struct *p; 1409 struct task_struct *p;
1405 struct tty_ldisc *ld; 1410 struct tty_ldisc *ld;
1406 int closecount = 0, n; 1411 int closecount = 0, n;
1412 unsigned long flags;
1407 1413
1408 if (!tty) 1414 if (!tty)
1409 return; 1415 return;
@@ -1441,8 +1447,7 @@ static void do_tty_hangup(struct work_struct *work)
1441 /* We may have no line discipline at this point */ 1447 /* We may have no line discipline at this point */
1442 if (ld->flush_buffer) 1448 if (ld->flush_buffer)
1443 ld->flush_buffer(tty); 1449 ld->flush_buffer(tty);
1444 if (tty->driver->flush_buffer) 1450 tty_driver_flush_buffer(tty);
1445 tty->driver->flush_buffer(tty);
1446 if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) && 1451 if ((test_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) &&
1447 ld->write_wakeup) 1452 ld->write_wakeup)
1448 ld->write_wakeup(tty); 1453 ld->write_wakeup(tty);
@@ -1480,19 +1485,24 @@ static void do_tty_hangup(struct work_struct *work)
1480 __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p); 1485 __group_send_sig_info(SIGHUP, SEND_SIG_PRIV, p);
1481 __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p); 1486 __group_send_sig_info(SIGCONT, SEND_SIG_PRIV, p);
1482 put_pid(p->signal->tty_old_pgrp); /* A noop */ 1487 put_pid(p->signal->tty_old_pgrp); /* A noop */
1488 spin_lock_irqsave(&tty->ctrl_lock, flags);
1483 if (tty->pgrp) 1489 if (tty->pgrp)
1484 p->signal->tty_old_pgrp = get_pid(tty->pgrp); 1490 p->signal->tty_old_pgrp = get_pid(tty->pgrp);
1491 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1485 spin_unlock_irq(&p->sighand->siglock); 1492 spin_unlock_irq(&p->sighand->siglock);
1486 } while_each_pid_task(tty->session, PIDTYPE_SID, p); 1493 } while_each_pid_task(tty->session, PIDTYPE_SID, p);
1487 } 1494 }
1488 read_unlock(&tasklist_lock); 1495 read_unlock(&tasklist_lock);
1489 1496
1497 spin_lock_irqsave(&tty->ctrl_lock, flags);
1490 tty->flags = 0; 1498 tty->flags = 0;
1491 put_pid(tty->session); 1499 put_pid(tty->session);
1492 put_pid(tty->pgrp); 1500 put_pid(tty->pgrp);
1493 tty->session = NULL; 1501 tty->session = NULL;
1494 tty->pgrp = NULL; 1502 tty->pgrp = NULL;
1495 tty->ctrl_status = 0; 1503 tty->ctrl_status = 0;
1504 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1505
1496 /* 1506 /*
1497 * If one of the devices matches a console pointer, we 1507 * If one of the devices matches a console pointer, we
1498 * cannot just call hangup() because that will cause 1508 * cannot just call hangup() because that will cause
@@ -1500,11 +1510,11 @@ static void do_tty_hangup(struct work_struct *work)
1500 * So we just call close() the right number of times. 1510 * So we just call close() the right number of times.
1501 */ 1511 */
1502 if (cons_filp) { 1512 if (cons_filp) {
1503 if (tty->driver->close) 1513 if (tty->ops->close)
1504 for (n = 0; n < closecount; n++) 1514 for (n = 0; n < closecount; n++)
1505 tty->driver->close(tty, cons_filp); 1515 tty->ops->close(tty, cons_filp);
1506 } else if (tty->driver->hangup) 1516 } else if (tty->ops->hangup)
1507 (tty->driver->hangup)(tty); 1517 (tty->ops->hangup)(tty);
1508 /* 1518 /*
1509 * We don't want to have driver/ldisc interactions beyond 1519 * We don't want to have driver/ldisc interactions beyond
1510 * the ones we did here. The driver layer expects no 1520 * the ones we did here. The driver layer expects no
@@ -1626,16 +1636,17 @@ void disassociate_ctty(int on_exit)
1626 struct tty_struct *tty; 1636 struct tty_struct *tty;
1627 struct pid *tty_pgrp = NULL; 1637 struct pid *tty_pgrp = NULL;
1628 1638
1629 lock_kernel();
1630 1639
1631 mutex_lock(&tty_mutex); 1640 mutex_lock(&tty_mutex);
1632 tty = get_current_tty(); 1641 tty = get_current_tty();
1633 if (tty) { 1642 if (tty) {
1634 tty_pgrp = get_pid(tty->pgrp); 1643 tty_pgrp = get_pid(tty->pgrp);
1635 mutex_unlock(&tty_mutex); 1644 mutex_unlock(&tty_mutex);
1645 lock_kernel();
1636 /* XXX: here we race, there is nothing protecting tty */ 1646 /* XXX: here we race, there is nothing protecting tty */
1637 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY) 1647 if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
1638 tty_vhangup(tty); 1648 tty_vhangup(tty);
1649 unlock_kernel();
1639 } else if (on_exit) { 1650 } else if (on_exit) {
1640 struct pid *old_pgrp; 1651 struct pid *old_pgrp;
1641 spin_lock_irq(&current->sighand->siglock); 1652 spin_lock_irq(&current->sighand->siglock);
@@ -1648,7 +1659,6 @@ void disassociate_ctty(int on_exit)
1648 put_pid(old_pgrp); 1659 put_pid(old_pgrp);
1649 } 1660 }
1650 mutex_unlock(&tty_mutex); 1661 mutex_unlock(&tty_mutex);
1651 unlock_kernel();
1652 return; 1662 return;
1653 } 1663 }
1654 if (tty_pgrp) { 1664 if (tty_pgrp) {
@@ -1667,10 +1677,13 @@ void disassociate_ctty(int on_exit)
1667 /* It is possible that do_tty_hangup has free'd this tty */ 1677 /* It is possible that do_tty_hangup has free'd this tty */
1668 tty = get_current_tty(); 1678 tty = get_current_tty();
1669 if (tty) { 1679 if (tty) {
1680 unsigned long flags;
1681 spin_lock_irqsave(&tty->ctrl_lock, flags);
1670 put_pid(tty->session); 1682 put_pid(tty->session);
1671 put_pid(tty->pgrp); 1683 put_pid(tty->pgrp);
1672 tty->session = NULL; 1684 tty->session = NULL;
1673 tty->pgrp = NULL; 1685 tty->pgrp = NULL;
1686 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1674 } else { 1687 } else {
1675#ifdef TTY_DEBUG_HANGUP 1688#ifdef TTY_DEBUG_HANGUP
1676 printk(KERN_DEBUG "error attempted to write to tty [0x%p]" 1689 printk(KERN_DEBUG "error attempted to write to tty [0x%p]"
@@ -1683,7 +1696,6 @@ void disassociate_ctty(int on_exit)
1683 read_lock(&tasklist_lock); 1696 read_lock(&tasklist_lock);
1684 session_clear_tty(task_session(current)); 1697 session_clear_tty(task_session(current));
1685 read_unlock(&tasklist_lock); 1698 read_unlock(&tasklist_lock);
1686 unlock_kernel();
1687} 1699}
1688 1700
1689/** 1701/**
@@ -1693,8 +1705,10 @@ void disassociate_ctty(int on_exit)
1693void no_tty(void) 1705void no_tty(void)
1694{ 1706{
1695 struct task_struct *tsk = current; 1707 struct task_struct *tsk = current;
1708 lock_kernel();
1696 if (tsk->signal->leader) 1709 if (tsk->signal->leader)
1697 disassociate_ctty(0); 1710 disassociate_ctty(0);
1711 unlock_kernel();
1698 proc_clear_tty(tsk); 1712 proc_clear_tty(tsk);
1699} 1713}
1700 1714
@@ -1714,21 +1728,26 @@ void no_tty(void)
1714 * but not always. 1728 * but not always.
1715 * 1729 *
1716 * Locking: 1730 * Locking:
1717 * Broken. Relies on BKL which is unsafe here. 1731 * Uses the tty control lock internally
1718 */ 1732 */
1719 1733
1720void stop_tty(struct tty_struct *tty) 1734void stop_tty(struct tty_struct *tty)
1721{ 1735{
1722 if (tty->stopped) 1736 unsigned long flags;
1737 spin_lock_irqsave(&tty->ctrl_lock, flags);
1738 if (tty->stopped) {
1739 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1723 return; 1740 return;
1741 }
1724 tty->stopped = 1; 1742 tty->stopped = 1;
1725 if (tty->link && tty->link->packet) { 1743 if (tty->link && tty->link->packet) {
1726 tty->ctrl_status &= ~TIOCPKT_START; 1744 tty->ctrl_status &= ~TIOCPKT_START;
1727 tty->ctrl_status |= TIOCPKT_STOP; 1745 tty->ctrl_status |= TIOCPKT_STOP;
1728 wake_up_interruptible(&tty->link->read_wait); 1746 wake_up_interruptible(&tty->link->read_wait);
1729 } 1747 }
1730 if (tty->driver->stop) 1748 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1731 (tty->driver->stop)(tty); 1749 if (tty->ops->stop)
1750 (tty->ops->stop)(tty);
1732} 1751}
1733 1752
1734EXPORT_SYMBOL(stop_tty); 1753EXPORT_SYMBOL(stop_tty);
@@ -1743,21 +1762,26 @@ EXPORT_SYMBOL(stop_tty);
1743 * driver start method is invoked and the line discipline woken. 1762 * driver start method is invoked and the line discipline woken.
1744 * 1763 *
1745 * Locking: 1764 * Locking:
1746 * Broken. Relies on BKL which is unsafe here. 1765 * ctrl_lock
1747 */ 1766 */
1748 1767
1749void start_tty(struct tty_struct *tty) 1768void start_tty(struct tty_struct *tty)
1750{ 1769{
1751 if (!tty->stopped || tty->flow_stopped) 1770 unsigned long flags;
1771 spin_lock_irqsave(&tty->ctrl_lock, flags);
1772 if (!tty->stopped || tty->flow_stopped) {
1773 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1752 return; 1774 return;
1775 }
1753 tty->stopped = 0; 1776 tty->stopped = 0;
1754 if (tty->link && tty->link->packet) { 1777 if (tty->link && tty->link->packet) {
1755 tty->ctrl_status &= ~TIOCPKT_STOP; 1778 tty->ctrl_status &= ~TIOCPKT_STOP;
1756 tty->ctrl_status |= TIOCPKT_START; 1779 tty->ctrl_status |= TIOCPKT_START;
1757 wake_up_interruptible(&tty->link->read_wait); 1780 wake_up_interruptible(&tty->link->read_wait);
1758 } 1781 }
1759 if (tty->driver->start) 1782 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1760 (tty->driver->start)(tty); 1783 if (tty->ops->start)
1784 (tty->ops->start)(tty);
1761 /* If we have a running line discipline it may need kicking */ 1785 /* If we have a running line discipline it may need kicking */
1762 tty_wakeup(tty); 1786 tty_wakeup(tty);
1763} 1787}
@@ -1775,10 +1799,8 @@ EXPORT_SYMBOL(start_tty);
1775 * for hung up devices before calling the line discipline method. 1799 * for hung up devices before calling the line discipline method.
1776 * 1800 *
1777 * Locking: 1801 * Locking:
1778 * Locks the line discipline internally while needed 1802 * Locks the line discipline internally while needed. Multiple
1779 * For historical reasons the line discipline read method is 1803 * read calls may be outstanding in parallel.
1780 * invoked under the BKL. This will go away in time so do not rely on it
1781 * in new code. Multiple read calls may be outstanding in parallel.
1782 */ 1804 */
1783 1805
1784static ssize_t tty_read(struct file *file, char __user *buf, size_t count, 1806static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
@@ -1799,13 +1821,11 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
1799 /* We want to wait for the line discipline to sort out in this 1821 /* We want to wait for the line discipline to sort out in this
1800 situation */ 1822 situation */
1801 ld = tty_ldisc_ref_wait(tty); 1823 ld = tty_ldisc_ref_wait(tty);
1802 lock_kernel();
1803 if (ld->read) 1824 if (ld->read)
1804 i = (ld->read)(tty, file, buf, count); 1825 i = (ld->read)(tty, file, buf, count);
1805 else 1826 else
1806 i = -EIO; 1827 i = -EIO;
1807 tty_ldisc_deref(ld); 1828 tty_ldisc_deref(ld);
1808 unlock_kernel();
1809 if (i > 0) 1829 if (i > 0)
1810 inode->i_atime = current_fs_time(inode->i_sb); 1830 inode->i_atime = current_fs_time(inode->i_sb);
1811 return i; 1831 return i;
@@ -1893,9 +1913,7 @@ static inline ssize_t do_tty_write(
1893 ret = -EFAULT; 1913 ret = -EFAULT;
1894 if (copy_from_user(tty->write_buf, buf, size)) 1914 if (copy_from_user(tty->write_buf, buf, size))
1895 break; 1915 break;
1896 lock_kernel();
1897 ret = write(tty, file, tty->write_buf, size); 1916 ret = write(tty, file, tty->write_buf, size);
1898 unlock_kernel();
1899 if (ret <= 0) 1917 if (ret <= 0)
1900 break; 1918 break;
1901 written += ret; 1919 written += ret;
@@ -1948,10 +1966,13 @@ static ssize_t tty_write(struct file *file, const char __user *buf,
1948 tty = (struct tty_struct *)file->private_data; 1966 tty = (struct tty_struct *)file->private_data;
1949 if (tty_paranoia_check(tty, inode, "tty_write")) 1967 if (tty_paranoia_check(tty, inode, "tty_write"))
1950 return -EIO; 1968 return -EIO;
1951 if (!tty || !tty->driver->write || 1969 if (!tty || !tty->ops->write ||
1952 (test_bit(TTY_IO_ERROR, &tty->flags))) 1970 (test_bit(TTY_IO_ERROR, &tty->flags)))
1953 return -EIO; 1971 return -EIO;
1954 1972 /* Short term debug to catch buggy drivers */
1973 if (tty->ops->write_room == NULL)
1974 printk(KERN_ERR "tty driver %s lacks a write_room method.\n",
1975 tty->driver->name);
1955 ld = tty_ldisc_ref_wait(tty); 1976 ld = tty_ldisc_ref_wait(tty);
1956 if (!ld->write) 1977 if (!ld->write)
1957 ret = -EIO; 1978 ret = -EIO;
@@ -2098,6 +2119,7 @@ static int init_dev(struct tty_driver *driver, int idx,
2098 goto fail_no_mem; 2119 goto fail_no_mem;
2099 initialize_tty_struct(tty); 2120 initialize_tty_struct(tty);
2100 tty->driver = driver; 2121 tty->driver = driver;
2122 tty->ops = driver->ops;
2101 tty->index = idx; 2123 tty->index = idx;
2102 tty_line_name(driver, idx, tty->name); 2124 tty_line_name(driver, idx, tty->name);
2103 2125
@@ -2128,6 +2150,7 @@ static int init_dev(struct tty_driver *driver, int idx,
2128 goto free_mem_out; 2150 goto free_mem_out;
2129 initialize_tty_struct(o_tty); 2151 initialize_tty_struct(o_tty);
2130 o_tty->driver = driver->other; 2152 o_tty->driver = driver->other;
2153 o_tty->ops = driver->ops;
2131 o_tty->index = idx; 2154 o_tty->index = idx;
2132 tty_line_name(driver->other, idx, o_tty->name); 2155 tty_line_name(driver->other, idx, o_tty->name);
2133 2156
@@ -2432,8 +2455,8 @@ static void release_dev(struct file *filp)
2432 } 2455 }
2433 } 2456 }
2434#endif 2457#endif
2435 if (tty->driver->close) 2458 if (tty->ops->close)
2436 tty->driver->close(tty, filp); 2459 tty->ops->close(tty, filp);
2437 2460
2438 /* 2461 /*
2439 * Sanity check: if tty->count is going to zero, there shouldn't be 2462 * Sanity check: if tty->count is going to zero, there shouldn't be
@@ -2612,15 +2635,9 @@ static void release_dev(struct file *filp)
2612 */ 2635 */
2613 release_tty(tty, idx); 2636 release_tty(tty, idx);
2614 2637
2615#ifdef CONFIG_UNIX98_PTYS
2616 /* Make this pty number available for reallocation */ 2638 /* Make this pty number available for reallocation */
2617 if (devpts) { 2639 if (devpts)
2618 mutex_lock(&allocated_ptys_lock); 2640 devpts_kill_index(idx);
2619 idr_remove(&allocated_ptys, idx);
2620 mutex_unlock(&allocated_ptys_lock);
2621 }
2622#endif
2623
2624} 2641}
2625 2642
2626/** 2643/**
@@ -2716,8 +2733,8 @@ got_driver:
2716 printk(KERN_DEBUG "opening %s...", tty->name); 2733 printk(KERN_DEBUG "opening %s...", tty->name);
2717#endif 2734#endif
2718 if (!retval) { 2735 if (!retval) {
2719 if (tty->driver->open) 2736 if (tty->ops->open)
2720 retval = tty->driver->open(tty, filp); 2737 retval = tty->ops->open(tty, filp);
2721 else 2738 else
2722 retval = -ENODEV; 2739 retval = -ENODEV;
2723 } 2740 }
@@ -2776,29 +2793,13 @@ static int ptmx_open(struct inode *inode, struct file *filp)
2776 struct tty_struct *tty; 2793 struct tty_struct *tty;
2777 int retval; 2794 int retval;
2778 int index; 2795 int index;
2779 int idr_ret;
2780 2796
2781 nonseekable_open(inode, filp); 2797 nonseekable_open(inode, filp);
2782 2798
2783 /* find a device that is not in use. */ 2799 /* find a device that is not in use. */
2784 mutex_lock(&allocated_ptys_lock); 2800 index = devpts_new_index();
2785 if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) { 2801 if (index < 0)
2786 mutex_unlock(&allocated_ptys_lock); 2802 return index;
2787 return -ENOMEM;
2788 }
2789 idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
2790 if (idr_ret < 0) {
2791 mutex_unlock(&allocated_ptys_lock);
2792 if (idr_ret == -EAGAIN)
2793 return -ENOMEM;
2794 return -EIO;
2795 }
2796 if (index >= pty_limit) {
2797 idr_remove(&allocated_ptys, index);
2798 mutex_unlock(&allocated_ptys_lock);
2799 return -EIO;
2800 }
2801 mutex_unlock(&allocated_ptys_lock);
2802 2803
2803 mutex_lock(&tty_mutex); 2804 mutex_lock(&tty_mutex);
2804 retval = init_dev(ptm_driver, index, &tty); 2805 retval = init_dev(ptm_driver, index, &tty);
@@ -2811,21 +2812,19 @@ static int ptmx_open(struct inode *inode, struct file *filp)
2811 filp->private_data = tty; 2812 filp->private_data = tty;
2812 file_move(filp, &tty->tty_files); 2813 file_move(filp, &tty->tty_files);
2813 2814
2814 retval = -ENOMEM; 2815 retval = devpts_pty_new(tty->link);
2815 if (devpts_pty_new(tty->link)) 2816 if (retval)
2816 goto out1; 2817 goto out1;
2817 2818
2818 check_tty_count(tty, "tty_open"); 2819 check_tty_count(tty, "ptmx_open");
2819 retval = ptm_driver->open(tty, filp); 2820 retval = ptm_driver->ops->open(tty, filp);
2820 if (!retval) 2821 if (!retval)
2821 return 0; 2822 return 0;
2822out1: 2823out1:
2823 release_dev(filp); 2824 release_dev(filp);
2824 return retval; 2825 return retval;
2825out: 2826out:
2826 mutex_lock(&allocated_ptys_lock); 2827 devpts_kill_index(index);
2827 idr_remove(&allocated_ptys, index);
2828 mutex_unlock(&allocated_ptys_lock);
2829 return retval; 2828 return retval;
2830} 2829}
2831#endif 2830#endif
@@ -2882,6 +2881,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
2882static int tty_fasync(int fd, struct file *filp, int on) 2881static int tty_fasync(int fd, struct file *filp, int on)
2883{ 2882{
2884 struct tty_struct *tty; 2883 struct tty_struct *tty;
2884 unsigned long flags;
2885 int retval; 2885 int retval;
2886 2886
2887 tty = (struct tty_struct *)filp->private_data; 2887 tty = (struct tty_struct *)filp->private_data;
@@ -2897,6 +2897,7 @@ static int tty_fasync(int fd, struct file *filp, int on)
2897 struct pid *pid; 2897 struct pid *pid;
2898 if (!waitqueue_active(&tty->read_wait)) 2898 if (!waitqueue_active(&tty->read_wait))
2899 tty->minimum_to_wake = 1; 2899 tty->minimum_to_wake = 1;
2900 spin_lock_irqsave(&tty->ctrl_lock, flags);
2900 if (tty->pgrp) { 2901 if (tty->pgrp) {
2901 pid = tty->pgrp; 2902 pid = tty->pgrp;
2902 type = PIDTYPE_PGID; 2903 type = PIDTYPE_PGID;
@@ -2904,6 +2905,7 @@ static int tty_fasync(int fd, struct file *filp, int on)
2904 pid = task_pid(current); 2905 pid = task_pid(current);
2905 type = PIDTYPE_PID; 2906 type = PIDTYPE_PID;
2906 } 2907 }
2908 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
2907 retval = __f_setown(filp, pid, type, 0); 2909 retval = __f_setown(filp, pid, type, 0);
2908 if (retval) 2910 if (retval)
2909 return retval; 2911 return retval;
@@ -2989,6 +2991,8 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty,
2989 struct winsize __user *arg) 2991 struct winsize __user *arg)
2990{ 2992{
2991 struct winsize tmp_ws; 2993 struct winsize tmp_ws;
2994 struct pid *pgrp, *rpgrp;
2995 unsigned long flags;
2992 2996
2993 if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) 2997 if (copy_from_user(&tmp_ws, arg, sizeof(*arg)))
2994 return -EFAULT; 2998 return -EFAULT;
@@ -3006,10 +3010,21 @@ static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty,
3006 } 3010 }
3007 } 3011 }
3008#endif 3012#endif
3009 if (tty->pgrp) 3013 /* Get the PID values and reference them so we can
3010 kill_pgrp(tty->pgrp, SIGWINCH, 1); 3014 avoid holding the tty ctrl lock while sending signals */
3011 if ((real_tty->pgrp != tty->pgrp) && real_tty->pgrp) 3015 spin_lock_irqsave(&tty->ctrl_lock, flags);
3012 kill_pgrp(real_tty->pgrp, SIGWINCH, 1); 3016 pgrp = get_pid(tty->pgrp);
3017 rpgrp = get_pid(real_tty->pgrp);
3018 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
3019
3020 if (pgrp)
3021 kill_pgrp(pgrp, SIGWINCH, 1);
3022 if (rpgrp != pgrp && rpgrp)
3023 kill_pgrp(rpgrp, SIGWINCH, 1);
3024
3025 put_pid(pgrp);
3026 put_pid(rpgrp);
3027
3013 tty->winsize = tmp_ws; 3028 tty->winsize = tmp_ws;
3014 real_tty->winsize = tmp_ws; 3029 real_tty->winsize = tmp_ws;
3015done: 3030done:
@@ -3070,10 +3085,13 @@ static int fionbio(struct file *file, int __user *p)
3070 if (get_user(nonblock, p)) 3085 if (get_user(nonblock, p))
3071 return -EFAULT; 3086 return -EFAULT;
3072 3087
3088 /* file->f_flags is still BKL protected in the fs layer - vomit */
3089 lock_kernel();
3073 if (nonblock) 3090 if (nonblock)
3074 file->f_flags |= O_NONBLOCK; 3091 file->f_flags |= O_NONBLOCK;
3075 else 3092 else
3076 file->f_flags &= ~O_NONBLOCK; 3093 file->f_flags &= ~O_NONBLOCK;
3094 unlock_kernel();
3077 return 0; 3095 return 0;
3078} 3096}
3079 3097
@@ -3131,6 +3149,27 @@ unlock:
3131} 3149}
3132 3150
3133/** 3151/**
3152 * tty_get_pgrp - return a ref counted pgrp pid
3153 * @tty: tty to read
3154 *
3155 * Returns a refcounted instance of the pid struct for the process
3156 * group controlling the tty.
3157 */
3158
3159struct pid *tty_get_pgrp(struct tty_struct *tty)
3160{
3161 unsigned long flags;
3162 struct pid *pgrp;
3163
3164 spin_lock_irqsave(&tty->ctrl_lock, flags);
3165 pgrp = get_pid(tty->pgrp);
3166 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
3167
3168 return pgrp;
3169}
3170EXPORT_SYMBOL_GPL(tty_get_pgrp);
3171
3172/**
3134 * tiocgpgrp - get process group 3173 * tiocgpgrp - get process group
3135 * @tty: tty passed by user 3174 * @tty: tty passed by user
3136 * @real_tty: tty side of the tty pased by the user if a pty else the tty 3175 * @real_tty: tty side of the tty pased by the user if a pty else the tty
@@ -3144,13 +3183,18 @@ unlock:
3144 3183
3145static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) 3184static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
3146{ 3185{
3186 struct pid *pid;
3187 int ret;
3147 /* 3188 /*
3148 * (tty == real_tty) is a cheap way of 3189 * (tty == real_tty) is a cheap way of
3149 * testing if the tty is NOT a master pty. 3190 * testing if the tty is NOT a master pty.
3150 */ 3191 */
3151 if (tty == real_tty && current->signal->tty != real_tty) 3192 if (tty == real_tty && current->signal->tty != real_tty)
3152 return -ENOTTY; 3193 return -ENOTTY;
3153 return put_user(pid_vnr(real_tty->pgrp), p); 3194 pid = tty_get_pgrp(real_tty);
3195 ret = put_user(pid_vnr(pid), p);
3196 put_pid(pid);
3197 return ret;
3154} 3198}
3155 3199
3156/** 3200/**
@@ -3162,7 +3206,7 @@ static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
3162 * Set the process group of the tty to the session passed. Only 3206 * Set the process group of the tty to the session passed. Only
3163 * permitted where the tty session is our session. 3207 * permitted where the tty session is our session.
3164 * 3208 *
3165 * Locking: None 3209 * Locking: RCU, ctrl lock
3166 */ 3210 */
3167 3211
3168static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) 3212static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p)
@@ -3170,6 +3214,7 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
3170 struct pid *pgrp; 3214 struct pid *pgrp;
3171 pid_t pgrp_nr; 3215 pid_t pgrp_nr;
3172 int retval = tty_check_change(real_tty); 3216 int retval = tty_check_change(real_tty);
3217 unsigned long flags;
3173 3218
3174 if (retval == -EIO) 3219 if (retval == -EIO)
3175 return -ENOTTY; 3220 return -ENOTTY;
@@ -3192,8 +3237,10 @@ static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t
3192 if (session_of_pgrp(pgrp) != task_session(current)) 3237 if (session_of_pgrp(pgrp) != task_session(current))
3193 goto out_unlock; 3238 goto out_unlock;
3194 retval = 0; 3239 retval = 0;
3240 spin_lock_irqsave(&tty->ctrl_lock, flags);
3195 put_pid(real_tty->pgrp); 3241 put_pid(real_tty->pgrp);
3196 real_tty->pgrp = get_pid(pgrp); 3242 real_tty->pgrp = get_pid(pgrp);
3243 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
3197out_unlock: 3244out_unlock:
3198 rcu_read_unlock(); 3245 rcu_read_unlock();
3199 return retval; 3246 return retval;
@@ -3237,10 +3284,16 @@ static int tiocgsid(struct tty_struct *tty, struct tty_struct *real_tty, pid_t _
3237static int tiocsetd(struct tty_struct *tty, int __user *p) 3284static int tiocsetd(struct tty_struct *tty, int __user *p)
3238{ 3285{
3239 int ldisc; 3286 int ldisc;
3287 int ret;
3240 3288
3241 if (get_user(ldisc, p)) 3289 if (get_user(ldisc, p))
3242 return -EFAULT; 3290 return -EFAULT;
3243 return tty_set_ldisc(tty, ldisc); 3291
3292 lock_kernel();
3293 ret = tty_set_ldisc(tty, ldisc);
3294 unlock_kernel();
3295
3296 return ret;
3244} 3297}
3245 3298
3246/** 3299/**
@@ -3260,18 +3313,18 @@ static int send_break(struct tty_struct *tty, unsigned int duration)
3260{ 3313{
3261 if (tty_write_lock(tty, 0) < 0) 3314 if (tty_write_lock(tty, 0) < 0)
3262 return -EINTR; 3315 return -EINTR;
3263 tty->driver->break_ctl(tty, -1); 3316 tty->ops->break_ctl(tty, -1);
3264 if (!signal_pending(current)) 3317 if (!signal_pending(current))
3265 msleep_interruptible(duration); 3318 msleep_interruptible(duration);
3266 tty->driver->break_ctl(tty, 0); 3319 tty->ops->break_ctl(tty, 0);
3267 tty_write_unlock(tty); 3320 tty_write_unlock(tty);
3268 if (signal_pending(current)) 3321 if (!signal_pending(current))
3269 return -EINTR; 3322 return -EINTR;
3270 return 0; 3323 return 0;
3271} 3324}
3272 3325
3273/** 3326/**
3274 * tiocmget - get modem status 3327 * tty_tiocmget - get modem status
3275 * @tty: tty device 3328 * @tty: tty device
3276 * @file: user file pointer 3329 * @file: user file pointer
3277 * @p: pointer to result 3330 * @p: pointer to result
@@ -3286,8 +3339,8 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
3286{ 3339{
3287 int retval = -EINVAL; 3340 int retval = -EINVAL;
3288 3341
3289 if (tty->driver->tiocmget) { 3342 if (tty->ops->tiocmget) {
3290 retval = tty->driver->tiocmget(tty, file); 3343 retval = tty->ops->tiocmget(tty, file);
3291 3344
3292 if (retval >= 0) 3345 if (retval >= 0)
3293 retval = put_user(retval, p); 3346 retval = put_user(retval, p);
@@ -3296,7 +3349,7 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
3296} 3349}
3297 3350
3298/** 3351/**
3299 * tiocmset - set modem status 3352 * tty_tiocmset - set modem status
3300 * @tty: tty device 3353 * @tty: tty device
3301 * @file: user file pointer 3354 * @file: user file pointer
3302 * @cmd: command - clear bits, set bits or set all 3355 * @cmd: command - clear bits, set bits or set all
@@ -3313,7 +3366,7 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int
3313{ 3366{
3314 int retval = -EINVAL; 3367 int retval = -EINVAL;
3315 3368
3316 if (tty->driver->tiocmset) { 3369 if (tty->ops->tiocmset) {
3317 unsigned int set, clear, val; 3370 unsigned int set, clear, val;
3318 3371
3319 retval = get_user(val, p); 3372 retval = get_user(val, p);
@@ -3337,7 +3390,7 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int
3337 set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; 3390 set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
3338 clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; 3391 clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
3339 3392
3340 retval = tty->driver->tiocmset(tty, file, set, clear); 3393 retval = tty->ops->tiocmset(tty, file, set, clear);
3341 } 3394 }
3342 return retval; 3395 return retval;
3343} 3396}
@@ -3345,20 +3398,18 @@ static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int
3345/* 3398/*
3346 * Split this up, as gcc can choke on it otherwise.. 3399 * Split this up, as gcc can choke on it otherwise..
3347 */ 3400 */
3348int tty_ioctl(struct inode *inode, struct file *file, 3401long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
3349 unsigned int cmd, unsigned long arg)
3350{ 3402{
3351 struct tty_struct *tty, *real_tty; 3403 struct tty_struct *tty, *real_tty;
3352 void __user *p = (void __user *)arg; 3404 void __user *p = (void __user *)arg;
3353 int retval; 3405 int retval;
3354 struct tty_ldisc *ld; 3406 struct tty_ldisc *ld;
3407 struct inode *inode = file->f_dentry->d_inode;
3355 3408
3356 tty = (struct tty_struct *)file->private_data; 3409 tty = (struct tty_struct *)file->private_data;
3357 if (tty_paranoia_check(tty, inode, "tty_ioctl")) 3410 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
3358 return -EINVAL; 3411 return -EINVAL;
3359 3412
3360 /* CHECKME: is this safe as one end closes ? */
3361
3362 real_tty = tty; 3413 real_tty = tty;
3363 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 3414 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
3364 tty->driver->subtype == PTY_TYPE_MASTER) 3415 tty->driver->subtype == PTY_TYPE_MASTER)
@@ -3367,21 +3418,28 @@ int tty_ioctl(struct inode *inode, struct file *file,
3367 /* 3418 /*
3368 * Break handling by driver 3419 * Break handling by driver
3369 */ 3420 */
3370 if (!tty->driver->break_ctl) { 3421
3422 retval = -EINVAL;
3423
3424 if (!tty->ops->break_ctl) {
3371 switch (cmd) { 3425 switch (cmd) {
3372 case TIOCSBRK: 3426 case TIOCSBRK:
3373 case TIOCCBRK: 3427 case TIOCCBRK:
3374 if (tty->driver->ioctl) 3428 if (tty->ops->ioctl)
3375 return tty->driver->ioctl(tty, file, cmd, arg); 3429 retval = tty->ops->ioctl(tty, file, cmd, arg);
3376 return -EINVAL; 3430 if (retval != -EINVAL && retval != -ENOIOCTLCMD)
3431 printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name);
3432 return retval;
3377 3433
3378 /* These two ioctl's always return success; even if */ 3434 /* These two ioctl's always return success; even if */
3379 /* the driver doesn't support them. */ 3435 /* the driver doesn't support them. */
3380 case TCSBRK: 3436 case TCSBRK:
3381 case TCSBRKP: 3437 case TCSBRKP:
3382 if (!tty->driver->ioctl) 3438 if (!tty->ops->ioctl)
3383 return 0; 3439 return 0;
3384 retval = tty->driver->ioctl(tty, file, cmd, arg); 3440 retval = tty->ops->ioctl(tty, file, cmd, arg);
3441 if (retval != -EINVAL && retval != -ENOIOCTLCMD)
3442 printk(KERN_WARNING "tty: driver %s needs updating to use break_ctl\n", tty->driver->name);
3385 if (retval == -ENOIOCTLCMD) 3443 if (retval == -ENOIOCTLCMD)
3386 retval = 0; 3444 retval = 0;
3387 return retval; 3445 return retval;
@@ -3439,7 +3497,6 @@ int tty_ioctl(struct inode *inode, struct file *file,
3439 case TIOCGSID: 3497 case TIOCGSID:
3440 return tiocgsid(tty, real_tty, p); 3498 return tiocgsid(tty, real_tty, p);
3441 case TIOCGETD: 3499 case TIOCGETD:
3442 /* FIXME: check this is ok */
3443 return put_user(tty->ldisc.num, (int __user *)p); 3500 return put_user(tty->ldisc.num, (int __user *)p);
3444 case TIOCSETD: 3501 case TIOCSETD:
3445 return tiocsetd(tty, p); 3502 return tiocsetd(tty, p);
@@ -3451,11 +3508,13 @@ int tty_ioctl(struct inode *inode, struct file *file,
3451 * Break handling 3508 * Break handling
3452 */ 3509 */
3453 case TIOCSBRK: /* Turn break on, unconditionally */ 3510 case TIOCSBRK: /* Turn break on, unconditionally */
3454 tty->driver->break_ctl(tty, -1); 3511 if (tty->ops->break_ctl)
3512 tty->ops->break_ctl(tty, -1);
3455 return 0; 3513 return 0;
3456 3514
3457 case TIOCCBRK: /* Turn break off, unconditionally */ 3515 case TIOCCBRK: /* Turn break off, unconditionally */
3458 tty->driver->break_ctl(tty, 0); 3516 if (tty->ops->break_ctl)
3517 tty->ops->break_ctl(tty, 0);
3459 return 0; 3518 return 0;
3460 case TCSBRK: /* SVID version: non-zero arg --> no break */ 3519 case TCSBRK: /* SVID version: non-zero arg --> no break */
3461 /* non-zero arg means wait for all output data 3520 /* non-zero arg means wait for all output data
@@ -3484,8 +3543,8 @@ int tty_ioctl(struct inode *inode, struct file *file,
3484 } 3543 }
3485 break; 3544 break;
3486 } 3545 }
3487 if (tty->driver->ioctl) { 3546 if (tty->ops->ioctl) {
3488 retval = (tty->driver->ioctl)(tty, file, cmd, arg); 3547 retval = (tty->ops->ioctl)(tty, file, cmd, arg);
3489 if (retval != -ENOIOCTLCMD) 3548 if (retval != -ENOIOCTLCMD)
3490 return retval; 3549 return retval;
3491 } 3550 }
@@ -3512,8 +3571,8 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
3512 if (tty_paranoia_check(tty, inode, "tty_ioctl")) 3571 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
3513 return -EINVAL; 3572 return -EINVAL;
3514 3573
3515 if (tty->driver->compat_ioctl) { 3574 if (tty->ops->compat_ioctl) {
3516 retval = (tty->driver->compat_ioctl)(tty, file, cmd, arg); 3575 retval = (tty->ops->compat_ioctl)(tty, file, cmd, arg);
3517 if (retval != -ENOIOCTLCMD) 3576 if (retval != -ENOIOCTLCMD)
3518 return retval; 3577 return retval;
3519 } 3578 }
@@ -3563,8 +3622,7 @@ void __do_SAK(struct tty_struct *tty)
3563 3622
3564 tty_ldisc_flush(tty); 3623 tty_ldisc_flush(tty);
3565 3624
3566 if (tty->driver->flush_buffer) 3625 tty_driver_flush_buffer(tty);
3567 tty->driver->flush_buffer(tty);
3568 3626
3569 read_lock(&tasklist_lock); 3627 read_lock(&tasklist_lock);
3570 /* Kill the entire session */ 3628 /* Kill the entire session */
@@ -3770,19 +3828,32 @@ static void initialize_tty_struct(struct tty_struct *tty)
3770 mutex_init(&tty->atomic_read_lock); 3828 mutex_init(&tty->atomic_read_lock);
3771 mutex_init(&tty->atomic_write_lock); 3829 mutex_init(&tty->atomic_write_lock);
3772 spin_lock_init(&tty->read_lock); 3830 spin_lock_init(&tty->read_lock);
3831 spin_lock_init(&tty->ctrl_lock);
3773 INIT_LIST_HEAD(&tty->tty_files); 3832 INIT_LIST_HEAD(&tty->tty_files);
3774 INIT_WORK(&tty->SAK_work, do_SAK_work); 3833 INIT_WORK(&tty->SAK_work, do_SAK_work);
3775} 3834}
3776 3835
3777/* 3836/**
3778 * The default put_char routine if the driver did not define one. 3837 * tty_put_char - write one character to a tty
3838 * @tty: tty
3839 * @ch: character
3840 *
3841 * Write one byte to the tty using the provided put_char method
3842 * if present. Returns the number of characters successfully output.
3843 *
3844 * Note: the specific put_char operation in the driver layer may go
3845 * away soon. Don't call it directly, use this method
3779 */ 3846 */
3780 3847
3781static void tty_default_put_char(struct tty_struct *tty, unsigned char ch) 3848int tty_put_char(struct tty_struct *tty, unsigned char ch)
3782{ 3849{
3783 tty->driver->write(tty, &ch, 1); 3850 if (tty->ops->put_char)
3851 return tty->ops->put_char(tty, ch);
3852 return tty->ops->write(tty, &ch, 1);
3784} 3853}
3785 3854
3855EXPORT_SYMBOL_GPL(tty_put_char);
3856
3786static struct class *tty_class; 3857static struct class *tty_class;
3787 3858
3788/** 3859/**
@@ -3865,37 +3936,8 @@ void put_tty_driver(struct tty_driver *driver)
3865void tty_set_operations(struct tty_driver *driver, 3936void tty_set_operations(struct tty_driver *driver,
3866 const struct tty_operations *op) 3937 const struct tty_operations *op)
3867{ 3938{
3868 driver->open = op->open; 3939 driver->ops = op;
3869 driver->close = op->close; 3940};
3870 driver->write = op->write;
3871 driver->put_char = op->put_char;
3872 driver->flush_chars = op->flush_chars;
3873 driver->write_room = op->write_room;
3874 driver->chars_in_buffer = op->chars_in_buffer;
3875 driver->ioctl = op->ioctl;
3876 driver->compat_ioctl = op->compat_ioctl;
3877 driver->set_termios = op->set_termios;
3878 driver->throttle = op->throttle;
3879 driver->unthrottle = op->unthrottle;
3880 driver->stop = op->stop;
3881 driver->start = op->start;
3882 driver->hangup = op->hangup;
3883 driver->break_ctl = op->break_ctl;
3884 driver->flush_buffer = op->flush_buffer;
3885 driver->set_ldisc = op->set_ldisc;
3886 driver->wait_until_sent = op->wait_until_sent;
3887 driver->send_xchar = op->send_xchar;
3888 driver->read_proc = op->read_proc;
3889 driver->write_proc = op->write_proc;
3890 driver->tiocmget = op->tiocmget;
3891 driver->tiocmset = op->tiocmset;
3892#ifdef CONFIG_CONSOLE_POLL
3893 driver->poll_init = op->poll_init;
3894 driver->poll_get_char = op->poll_get_char;
3895 driver->poll_put_char = op->poll_put_char;
3896#endif
3897}
3898
3899 3941
3900EXPORT_SYMBOL(alloc_tty_driver); 3942EXPORT_SYMBOL(alloc_tty_driver);
3901EXPORT_SYMBOL(put_tty_driver); 3943EXPORT_SYMBOL(put_tty_driver);
@@ -3958,9 +4000,6 @@ int tty_register_driver(struct tty_driver *driver)
3958 return error; 4000 return error;
3959 } 4001 }
3960 4002
3961 if (!driver->put_char)
3962 driver->put_char = tty_default_put_char;
3963
3964 mutex_lock(&tty_mutex); 4003 mutex_lock(&tty_mutex);
3965 list_add(&driver->tty_drivers, &tty_drivers); 4004 list_add(&driver->tty_drivers, &tty_drivers);
3966 mutex_unlock(&tty_mutex); 4005 mutex_unlock(&tty_mutex);
@@ -4036,14 +4075,19 @@ void proc_clear_tty(struct task_struct *p)
4036} 4075}
4037EXPORT_SYMBOL(proc_clear_tty); 4076EXPORT_SYMBOL(proc_clear_tty);
4038 4077
4078/* Called under the sighand lock */
4079
4039static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty) 4080static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty)
4040{ 4081{
4041 if (tty) { 4082 if (tty) {
4042 /* We should not have a session or pgrp to here but.... */ 4083 unsigned long flags;
4084 /* We should not have a session or pgrp to put here but.... */
4085 spin_lock_irqsave(&tty->ctrl_lock, flags);
4043 put_pid(tty->session); 4086 put_pid(tty->session);
4044 put_pid(tty->pgrp); 4087 put_pid(tty->pgrp);
4045 tty->session = get_pid(task_session(tsk));
4046 tty->pgrp = get_pid(task_pgrp(tsk)); 4088 tty->pgrp = get_pid(task_pgrp(tsk));
4089 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
4090 tty->session = get_pid(task_session(tsk));
4047 } 4091 }
4048 put_pid(tsk->signal->tty_old_pgrp); 4092 put_pid(tsk->signal->tty_old_pgrp);
4049 tsk->signal->tty = tty; 4093 tsk->signal->tty = tty;
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index f95a80b2265f..b1a757a5ee27 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -21,6 +21,7 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/bitops.h> 22#include <linux/bitops.h>
23#include <linux/mutex.h> 23#include <linux/mutex.h>
24#include <linux/smp_lock.h>
24 25
25#include <asm/io.h> 26#include <asm/io.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
@@ -39,6 +40,50 @@
39#define TERMIOS_OLD 8 40#define TERMIOS_OLD 8
40 41
41 42
43int tty_chars_in_buffer(struct tty_struct *tty)
44{
45 if (tty->ops->chars_in_buffer)
46 return tty->ops->chars_in_buffer(tty);
47 else
48 return 0;
49}
50
51EXPORT_SYMBOL(tty_chars_in_buffer);
52
53int tty_write_room(struct tty_struct *tty)
54{
55 if (tty->ops->write_room)
56 return tty->ops->write_room(tty);
57 return 2048;
58}
59
60EXPORT_SYMBOL(tty_write_room);
61
62void tty_driver_flush_buffer(struct tty_struct *tty)
63{
64 if (tty->ops->flush_buffer)
65 tty->ops->flush_buffer(tty);
66}
67
68EXPORT_SYMBOL(tty_driver_flush_buffer);
69
70void tty_throttle(struct tty_struct *tty)
71{
72 /* check TTY_THROTTLED first so it indicates our state */
73 if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) &&
74 tty->ops->throttle)
75 tty->ops->throttle(tty);
76}
77EXPORT_SYMBOL(tty_throttle);
78
79void tty_unthrottle(struct tty_struct *tty)
80{
81 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) &&
82 tty->ops->unthrottle)
83 tty->ops->unthrottle(tty);
84}
85EXPORT_SYMBOL(tty_unthrottle);
86
42/** 87/**
43 * tty_wait_until_sent - wait for I/O to finish 88 * tty_wait_until_sent - wait for I/O to finish
44 * @tty: tty we are waiting for 89 * @tty: tty we are waiting for
@@ -57,15 +102,13 @@ void tty_wait_until_sent(struct tty_struct *tty, long timeout)
57 102
58 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf)); 103 printk(KERN_DEBUG "%s wait until sent...\n", tty_name(tty, buf));
59#endif 104#endif
60 if (!tty->driver->chars_in_buffer)
61 return;
62 if (!timeout) 105 if (!timeout)
63 timeout = MAX_SCHEDULE_TIMEOUT; 106 timeout = MAX_SCHEDULE_TIMEOUT;
64 if (wait_event_interruptible_timeout(tty->write_wait, 107 if (wait_event_interruptible_timeout(tty->write_wait,
65 !tty->driver->chars_in_buffer(tty), timeout) < 0) 108 !tty_chars_in_buffer(tty), timeout) >= 0) {
66 return; 109 if (tty->ops->wait_until_sent)
67 if (tty->driver->wait_until_sent) 110 tty->ops->wait_until_sent(tty, timeout);
68 tty->driver->wait_until_sent(tty, timeout); 111 }
69} 112}
70EXPORT_SYMBOL(tty_wait_until_sent); 113EXPORT_SYMBOL(tty_wait_until_sent);
71 114
@@ -393,8 +436,9 @@ EXPORT_SYMBOL(tty_termios_hw_change);
393static void change_termios(struct tty_struct *tty, struct ktermios *new_termios) 436static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
394{ 437{
395 int canon_change; 438 int canon_change;
396 struct ktermios old_termios = *tty->termios; 439 struct ktermios old_termios;
397 struct tty_ldisc *ld; 440 struct tty_ldisc *ld;
441 unsigned long flags;
398 442
399 /* 443 /*
400 * Perform the actual termios internal changes under lock. 444 * Perform the actual termios internal changes under lock.
@@ -404,7 +448,7 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
404 /* FIXME: we need to decide on some locking/ordering semantics 448 /* FIXME: we need to decide on some locking/ordering semantics
405 for the set_termios notification eventually */ 449 for the set_termios notification eventually */
406 mutex_lock(&tty->termios_mutex); 450 mutex_lock(&tty->termios_mutex);
407 451 old_termios = *tty->termios;
408 *tty->termios = *new_termios; 452 *tty->termios = *new_termios;
409 unset_locked_termios(tty->termios, &old_termios, tty->termios_locked); 453 unset_locked_termios(tty->termios, &old_termios, tty->termios_locked);
410 canon_change = (old_termios.c_lflag ^ tty->termios->c_lflag) & ICANON; 454 canon_change = (old_termios.c_lflag ^ tty->termios->c_lflag) & ICANON;
@@ -429,17 +473,19 @@ static void change_termios(struct tty_struct *tty, struct ktermios *new_termios)
429 STOP_CHAR(tty) == '\023' && 473 STOP_CHAR(tty) == '\023' &&
430 START_CHAR(tty) == '\021'); 474 START_CHAR(tty) == '\021');
431 if (old_flow != new_flow) { 475 if (old_flow != new_flow) {
476 spin_lock_irqsave(&tty->ctrl_lock, flags);
432 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); 477 tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP);
433 if (new_flow) 478 if (new_flow)
434 tty->ctrl_status |= TIOCPKT_DOSTOP; 479 tty->ctrl_status |= TIOCPKT_DOSTOP;
435 else 480 else
436 tty->ctrl_status |= TIOCPKT_NOSTOP; 481 tty->ctrl_status |= TIOCPKT_NOSTOP;
482 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
437 wake_up_interruptible(&tty->link->read_wait); 483 wake_up_interruptible(&tty->link->read_wait);
438 } 484 }
439 } 485 }
440 486
441 if (tty->driver->set_termios) 487 if (tty->ops->set_termios)
442 (*tty->driver->set_termios)(tty, &old_termios); 488 (*tty->ops->set_termios)(tty, &old_termios);
443 else 489 else
444 tty_termios_copy_hw(tty->termios, &old_termios); 490 tty_termios_copy_hw(tty->termios, &old_termios);
445 491
@@ -474,7 +520,9 @@ static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
474 if (retval) 520 if (retval)
475 return retval; 521 return retval;
476 522
523 mutex_lock(&tty->termios_mutex);
477 memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios)); 524 memcpy(&tmp_termios, tty->termios, sizeof(struct ktermios));
525 mutex_unlock(&tty->termios_mutex);
478 526
479 if (opt & TERMIOS_TERMIO) { 527 if (opt & TERMIOS_TERMIO) {
480 if (user_termio_to_kernel_termios(&tmp_termios, 528 if (user_termio_to_kernel_termios(&tmp_termios,
@@ -660,12 +708,14 @@ static int get_tchars(struct tty_struct *tty, struct tchars __user *tchars)
660{ 708{
661 struct tchars tmp; 709 struct tchars tmp;
662 710
711 mutex_lock(&tty->termios_mutex);
663 tmp.t_intrc = tty->termios->c_cc[VINTR]; 712 tmp.t_intrc = tty->termios->c_cc[VINTR];
664 tmp.t_quitc = tty->termios->c_cc[VQUIT]; 713 tmp.t_quitc = tty->termios->c_cc[VQUIT];
665 tmp.t_startc = tty->termios->c_cc[VSTART]; 714 tmp.t_startc = tty->termios->c_cc[VSTART];
666 tmp.t_stopc = tty->termios->c_cc[VSTOP]; 715 tmp.t_stopc = tty->termios->c_cc[VSTOP];
667 tmp.t_eofc = tty->termios->c_cc[VEOF]; 716 tmp.t_eofc = tty->termios->c_cc[VEOF];
668 tmp.t_brkc = tty->termios->c_cc[VEOL2]; /* what is brkc anyway? */ 717 tmp.t_brkc = tty->termios->c_cc[VEOL2]; /* what is brkc anyway? */
718 mutex_unlock(&tty->termios_mutex);
669 return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0; 719 return copy_to_user(tchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
670} 720}
671 721
@@ -675,12 +725,14 @@ static int set_tchars(struct tty_struct *tty, struct tchars __user *tchars)
675 725
676 if (copy_from_user(&tmp, tchars, sizeof(tmp))) 726 if (copy_from_user(&tmp, tchars, sizeof(tmp)))
677 return -EFAULT; 727 return -EFAULT;
728 mutex_lock(&tty->termios_mutex);
678 tty->termios->c_cc[VINTR] = tmp.t_intrc; 729 tty->termios->c_cc[VINTR] = tmp.t_intrc;
679 tty->termios->c_cc[VQUIT] = tmp.t_quitc; 730 tty->termios->c_cc[VQUIT] = tmp.t_quitc;
680 tty->termios->c_cc[VSTART] = tmp.t_startc; 731 tty->termios->c_cc[VSTART] = tmp.t_startc;
681 tty->termios->c_cc[VSTOP] = tmp.t_stopc; 732 tty->termios->c_cc[VSTOP] = tmp.t_stopc;
682 tty->termios->c_cc[VEOF] = tmp.t_eofc; 733 tty->termios->c_cc[VEOF] = tmp.t_eofc;
683 tty->termios->c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */ 734 tty->termios->c_cc[VEOL2] = tmp.t_brkc; /* what is brkc anyway? */
735 mutex_unlock(&tty->termios_mutex);
684 return 0; 736 return 0;
685} 737}
686#endif 738#endif
@@ -690,6 +742,7 @@ static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
690{ 742{
691 struct ltchars tmp; 743 struct ltchars tmp;
692 744
745 mutex_lock(&tty->termios_mutex);
693 tmp.t_suspc = tty->termios->c_cc[VSUSP]; 746 tmp.t_suspc = tty->termios->c_cc[VSUSP];
694 /* what is dsuspc anyway? */ 747 /* what is dsuspc anyway? */
695 tmp.t_dsuspc = tty->termios->c_cc[VSUSP]; 748 tmp.t_dsuspc = tty->termios->c_cc[VSUSP];
@@ -698,6 +751,7 @@ static int get_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
698 tmp.t_flushc = tty->termios->c_cc[VEOL2]; 751 tmp.t_flushc = tty->termios->c_cc[VEOL2];
699 tmp.t_werasc = tty->termios->c_cc[VWERASE]; 752 tmp.t_werasc = tty->termios->c_cc[VWERASE];
700 tmp.t_lnextc = tty->termios->c_cc[VLNEXT]; 753 tmp.t_lnextc = tty->termios->c_cc[VLNEXT];
754 mutex_unlock(&tty->termios_mutex);
701 return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0; 755 return copy_to_user(ltchars, &tmp, sizeof(tmp)) ? -EFAULT : 0;
702} 756}
703 757
@@ -708,6 +762,7 @@ static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
708 if (copy_from_user(&tmp, ltchars, sizeof(tmp))) 762 if (copy_from_user(&tmp, ltchars, sizeof(tmp)))
709 return -EFAULT; 763 return -EFAULT;
710 764
765 mutex_lock(&tty->termios_mutex);
711 tty->termios->c_cc[VSUSP] = tmp.t_suspc; 766 tty->termios->c_cc[VSUSP] = tmp.t_suspc;
712 /* what is dsuspc anyway? */ 767 /* what is dsuspc anyway? */
713 tty->termios->c_cc[VEOL2] = tmp.t_dsuspc; 768 tty->termios->c_cc[VEOL2] = tmp.t_dsuspc;
@@ -716,6 +771,7 @@ static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
716 tty->termios->c_cc[VEOL2] = tmp.t_flushc; 771 tty->termios->c_cc[VEOL2] = tmp.t_flushc;
717 tty->termios->c_cc[VWERASE] = tmp.t_werasc; 772 tty->termios->c_cc[VWERASE] = tmp.t_werasc;
718 tty->termios->c_cc[VLNEXT] = tmp.t_lnextc; 773 tty->termios->c_cc[VLNEXT] = tmp.t_lnextc;
774 mutex_unlock(&tty->termios_mutex);
719 return 0; 775 return 0;
720} 776}
721#endif 777#endif
@@ -732,8 +788,8 @@ static int send_prio_char(struct tty_struct *tty, char ch)
732{ 788{
733 int was_stopped = tty->stopped; 789 int was_stopped = tty->stopped;
734 790
735 if (tty->driver->send_xchar) { 791 if (tty->ops->send_xchar) {
736 tty->driver->send_xchar(tty, ch); 792 tty->ops->send_xchar(tty, ch);
737 return 0; 793 return 0;
738 } 794 }
739 795
@@ -742,7 +798,7 @@ static int send_prio_char(struct tty_struct *tty, char ch)
742 798
743 if (was_stopped) 799 if (was_stopped)
744 start_tty(tty); 800 start_tty(tty);
745 tty->driver->write(tty, &ch, 1); 801 tty->ops->write(tty, &ch, 1);
746 if (was_stopped) 802 if (was_stopped)
747 stop_tty(tty); 803 stop_tty(tty);
748 tty_write_unlock(tty); 804 tty_write_unlock(tty);
@@ -750,6 +806,33 @@ static int send_prio_char(struct tty_struct *tty, char ch)
750} 806}
751 807
752/** 808/**
809 * tty_change_softcar - carrier change ioctl helper
810 * @tty: tty to update
811 * @arg: enable/disable CLOCAL
812 *
813 * Perform a change to the CLOCAL state and call into the driver
814 * layer to make it visible. All done with the termios mutex
815 */
816
817static int tty_change_softcar(struct tty_struct *tty, int arg)
818{
819 int ret = 0;
820 int bit = arg ? CLOCAL : 0;
821 struct ktermios old;
822
823 mutex_lock(&tty->termios_mutex);
824 old = *tty->termios;
825 tty->termios->c_cflag &= ~CLOCAL;
826 tty->termios->c_cflag |= bit;
827 if (tty->ops->set_termios)
828 tty->ops->set_termios(tty, &old);
829 if ((tty->termios->c_cflag & CLOCAL) != bit)
830 ret = -EINVAL;
831 mutex_unlock(&tty->termios_mutex);
832 return ret;
833}
834
835/**
753 * tty_mode_ioctl - mode related ioctls 836 * tty_mode_ioctl - mode related ioctls
754 * @tty: tty for the ioctl 837 * @tty: tty for the ioctl
755 * @file: file pointer for the tty 838 * @file: file pointer for the tty
@@ -859,12 +942,7 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
859 case TIOCSSOFTCAR: 942 case TIOCSSOFTCAR:
860 if (get_user(arg, (unsigned int __user *) arg)) 943 if (get_user(arg, (unsigned int __user *) arg))
861 return -EFAULT; 944 return -EFAULT;
862 mutex_lock(&tty->termios_mutex); 945 return tty_change_softcar(tty, arg);
863 tty->termios->c_cflag =
864 ((tty->termios->c_cflag & ~CLOCAL) |
865 (arg ? CLOCAL : 0));
866 mutex_unlock(&tty->termios_mutex);
867 return 0;
868 default: 946 default:
869 return -ENOIOCTLCMD; 947 return -ENOIOCTLCMD;
870 } 948 }
@@ -889,8 +967,7 @@ int tty_perform_flush(struct tty_struct *tty, unsigned long arg)
889 ld->flush_buffer(tty); 967 ld->flush_buffer(tty);
890 /* fall through */ 968 /* fall through */
891 case TCOFLUSH: 969 case TCOFLUSH:
892 if (tty->driver->flush_buffer) 970 tty_driver_flush_buffer(tty);
893 tty->driver->flush_buffer(tty);
894 break; 971 break;
895 default: 972 default:
896 tty_ldisc_deref(ld); 973 tty_ldisc_deref(ld);
@@ -905,6 +982,7 @@ int n_tty_ioctl(struct tty_struct *tty, struct file *file,
905 unsigned int cmd, unsigned long arg) 982 unsigned int cmd, unsigned long arg)
906{ 983{
907 struct tty_struct *real_tty; 984 struct tty_struct *real_tty;
985 unsigned long flags;
908 int retval; 986 int retval;
909 987
910 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && 988 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
@@ -946,9 +1024,7 @@ int n_tty_ioctl(struct tty_struct *tty, struct file *file,
946 case TCFLSH: 1024 case TCFLSH:
947 return tty_perform_flush(tty, arg); 1025 return tty_perform_flush(tty, arg);
948 case TIOCOUTQ: 1026 case TIOCOUTQ:
949 return put_user(tty->driver->chars_in_buffer ? 1027 return put_user(tty_chars_in_buffer(tty), (int __user *) arg);
950 tty->driver->chars_in_buffer(tty) : 0,
951 (int __user *) arg);
952 case TIOCINQ: 1028 case TIOCINQ:
953 retval = tty->read_cnt; 1029 retval = tty->read_cnt;
954 if (L_ICANON(tty)) 1030 if (L_ICANON(tty))
@@ -963,6 +1039,7 @@ int n_tty_ioctl(struct tty_struct *tty, struct file *file,
963 return -ENOTTY; 1039 return -ENOTTY;
964 if (get_user(pktmode, (int __user *) arg)) 1040 if (get_user(pktmode, (int __user *) arg))
965 return -EFAULT; 1041 return -EFAULT;
1042 spin_lock_irqsave(&tty->ctrl_lock, flags);
966 if (pktmode) { 1043 if (pktmode) {
967 if (!tty->packet) { 1044 if (!tty->packet) {
968 tty->packet = 1; 1045 tty->packet = 1;
@@ -970,6 +1047,7 @@ int n_tty_ioctl(struct tty_struct *tty, struct file *file,
970 } 1047 }
971 } else 1048 } else
972 tty->packet = 0; 1049 tty->packet = 0;
1050 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
973 return 0; 1051 return 0;
974 } 1052 }
975 default: 1053 default:
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index 8de6b95aeb84..3d3e1c2b310f 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -628,13 +628,13 @@ static int viotty_write(struct tty_struct *tty, const unsigned char *buf,
628/* 628/*
629 * TTY put_char method 629 * TTY put_char method
630 */ 630 */
631static void viotty_put_char(struct tty_struct *tty, unsigned char ch) 631static int viotty_put_char(struct tty_struct *tty, unsigned char ch)
632{ 632{
633 struct port_info *pi; 633 struct port_info *pi;
634 634
635 pi = get_port_data(tty); 635 pi = get_port_data(tty);
636 if (pi == NULL) 636 if (pi == NULL)
637 return; 637 return 0;
638 638
639 /* This will append '\r' as well if the char is '\n' */ 639 /* This will append '\r' as well if the char is '\n' */
640 if (viochar_is_console(pi)) 640 if (viochar_is_console(pi))
@@ -642,6 +642,7 @@ static void viotty_put_char(struct tty_struct *tty, unsigned char ch)
642 642
643 if (viopath_isactive(pi->lp)) 643 if (viopath_isactive(pi->lp))
644 internal_write(pi, &ch, 1); 644 internal_write(pi, &ch, 1);
645 return 1;
645} 646}
646 647
647/* 648/*
@@ -704,8 +705,11 @@ static int viotty_ioctl(struct tty_struct *tty, struct file *file,
704 case KDSKBLED: 705 case KDSKBLED:
705 return 0; 706 return 0;
706 } 707 }
707 708 /* FIXME: WTF is this being called for ??? */
708 return n_tty_ioctl(tty, file, cmd, arg); 709 lock_kernel();
710 ret = n_tty_ioctl(tty, file, cmd, arg);
711 unlock_kernel();
712 return ret;
709} 713}
710 714
711/* 715/*
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 1c2660477135..e458b08139af 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -909,15 +909,21 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
909 909
910 if (vc->vc_tty) { 910 if (vc->vc_tty) {
911 struct winsize ws, *cws = &vc->vc_tty->winsize; 911 struct winsize ws, *cws = &vc->vc_tty->winsize;
912 unsigned long flags;
912 913
913 memset(&ws, 0, sizeof(ws)); 914 memset(&ws, 0, sizeof(ws));
914 ws.ws_row = vc->vc_rows; 915 ws.ws_row = vc->vc_rows;
915 ws.ws_col = vc->vc_cols; 916 ws.ws_col = vc->vc_cols;
916 ws.ws_ypixel = vc->vc_scan_lines; 917 ws.ws_ypixel = vc->vc_scan_lines;
918
919 mutex_lock(&vc->vc_tty->termios_mutex);
920 spin_lock_irqsave(&vc->vc_tty->ctrl_lock, flags);
917 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) && 921 if ((ws.ws_row != cws->ws_row || ws.ws_col != cws->ws_col) &&
918 vc->vc_tty->pgrp) 922 vc->vc_tty->pgrp)
919 kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1); 923 kill_pgrp(vc->vc_tty->pgrp, SIGWINCH, 1);
924 spin_unlock_irqrestore(&vc->vc_tty->ctrl_lock, flags);
920 *cws = ws; 925 *cws = ws;
926 mutex_unlock(&vc->vc_tty->termios_mutex);
921 } 927 }
922 928
923 if (CON_IS_VISIBLE(vc)) 929 if (CON_IS_VISIBLE(vc))
@@ -2541,6 +2547,9 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2541 if (get_user(type, p)) 2547 if (get_user(type, p))
2542 return -EFAULT; 2548 return -EFAULT;
2543 ret = 0; 2549 ret = 0;
2550
2551 lock_kernel();
2552
2544 switch (type) 2553 switch (type)
2545 { 2554 {
2546 case TIOCL_SETSEL: 2555 case TIOCL_SETSEL:
@@ -2560,7 +2569,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2560 ret = sel_loadlut(p); 2569 ret = sel_loadlut(p);
2561 break; 2570 break;
2562 case TIOCL_GETSHIFTSTATE: 2571 case TIOCL_GETSHIFTSTATE:
2563 2572
2564 /* 2573 /*
2565 * Make it possible to react to Shift+Mousebutton. 2574 * Make it possible to react to Shift+Mousebutton.
2566 * Note that 'shift_state' is an undocumented 2575 * Note that 'shift_state' is an undocumented
@@ -2615,6 +2624,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2615 ret = -EINVAL; 2624 ret = -EINVAL;
2616 break; 2625 break;
2617 } 2626 }
2627 unlock_kernel();
2618 return ret; 2628 return ret;
2619} 2629}
2620 2630
@@ -2632,11 +2642,11 @@ static int con_write(struct tty_struct *tty, const unsigned char *buf, int count
2632 return retval; 2642 return retval;
2633} 2643}
2634 2644
2635static void con_put_char(struct tty_struct *tty, unsigned char ch) 2645static int con_put_char(struct tty_struct *tty, unsigned char ch)
2636{ 2646{
2637 if (in_interrupt()) 2647 if (in_interrupt())
2638 return; /* n_r3964 calls put_char() from interrupt context */ 2648 return 0; /* n_r3964 calls put_char() from interrupt context */
2639 do_con_write(tty, &ch, 1); 2649 return do_con_write(tty, &ch, 1);
2640} 2650}
2641 2651
2642static int con_write_room(struct tty_struct *tty) 2652static int con_write_room(struct tty_struct *tty)
@@ -3829,7 +3839,7 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op)
3829 goto out; 3839 goto out;
3830 3840
3831 c = (font.width+7)/8 * 32 * font.charcount; 3841 c = (font.width+7)/8 * 32 * font.charcount;
3832 3842
3833 if (op->data && font.charcount > op->charcount) 3843 if (op->data && font.charcount > op->charcount)
3834 rc = -ENOSPC; 3844 rc = -ENOSPC;
3835 if (!(op->flags & KD_FONT_FLAG_OLD)) { 3845 if (!(op->flags & KD_FONT_FLAG_OLD)) {
@@ -3994,6 +4004,7 @@ u16 screen_glyph(struct vc_data *vc, int offset)
3994 c |= 0x100; 4004 c |= 0x100;
3995 return c; 4005 return c;
3996} 4006}
4007EXPORT_SYMBOL_GPL(screen_glyph);
3997 4008
3998/* used by vcs - note the word offset */ 4009/* used by vcs - note the word offset */
3999unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) 4010unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed)
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c
index e6f89e8b9258..3211afd9d57e 100644
--- a/drivers/char/vt_ioctl.c
+++ b/drivers/char/vt_ioctl.c
@@ -373,11 +373,17 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
373 unsigned char ucval; 373 unsigned char ucval;
374 void __user *up = (void __user *)arg; 374 void __user *up = (void __user *)arg;
375 int i, perm; 375 int i, perm;
376 376 int ret = 0;
377
377 console = vc->vc_num; 378 console = vc->vc_num;
378 379
379 if (!vc_cons_allocated(console)) /* impossible? */ 380 lock_kernel();
380 return -ENOIOCTLCMD; 381
382 if (!vc_cons_allocated(console)) { /* impossible? */
383 ret = -ENOIOCTLCMD;
384 goto out;
385 }
386
381 387
382 /* 388 /*
383 * To have permissions to do most of the vt ioctls, we either have 389 * To have permissions to do most of the vt ioctls, we either have
@@ -391,15 +397,15 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
391 switch (cmd) { 397 switch (cmd) {
392 case KIOCSOUND: 398 case KIOCSOUND:
393 if (!perm) 399 if (!perm)
394 return -EPERM; 400 goto eperm;
395 if (arg) 401 if (arg)
396 arg = CLOCK_TICK_RATE / arg; 402 arg = CLOCK_TICK_RATE / arg;
397 kd_mksound(arg, 0); 403 kd_mksound(arg, 0);
398 return 0; 404 break;
399 405
400 case KDMKTONE: 406 case KDMKTONE:
401 if (!perm) 407 if (!perm)
402 return -EPERM; 408 goto eperm;
403 { 409 {
404 unsigned int ticks, count; 410 unsigned int ticks, count;
405 411
@@ -412,7 +418,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
412 if (count) 418 if (count)
413 count = CLOCK_TICK_RATE / count; 419 count = CLOCK_TICK_RATE / count;
414 kd_mksound(count, ticks); 420 kd_mksound(count, ticks);
415 return 0; 421 break;
416 } 422 }
417 423
418 case KDGKBTYPE: 424 case KDGKBTYPE:
@@ -435,14 +441,18 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
435 * KDADDIO and KDDELIO may be able to add ports beyond what 441 * KDADDIO and KDDELIO may be able to add ports beyond what
436 * we reject here, but to be safe... 442 * we reject here, but to be safe...
437 */ 443 */
438 if (arg < GPFIRST || arg > GPLAST) 444 if (arg < GPFIRST || arg > GPLAST) {
439 return -EINVAL; 445 ret = -EINVAL;
440 return sys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0; 446 break;
447 }
448 ret = sys_ioperm(arg, 1, (cmd == KDADDIO)) ? -ENXIO : 0;
449 break;
441 450
442 case KDENABIO: 451 case KDENABIO:
443 case KDDISABIO: 452 case KDDISABIO:
444 return sys_ioperm(GPFIRST, GPNUM, 453 ret = sys_ioperm(GPFIRST, GPNUM,
445 (cmd == KDENABIO)) ? -ENXIO : 0; 454 (cmd == KDENABIO)) ? -ENXIO : 0;
455 break;
446#endif 456#endif
447 457
448 /* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */ 458 /* Linux m68k/i386 interface for setting the keyboard delay/repeat rate */
@@ -450,19 +460,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
450 case KDKBDREP: 460 case KDKBDREP:
451 { 461 {
452 struct kbd_repeat kbrep; 462 struct kbd_repeat kbrep;
453 int err;
454 463
455 if (!capable(CAP_SYS_TTY_CONFIG)) 464 if (!capable(CAP_SYS_TTY_CONFIG))
456 return -EPERM; 465 goto eperm;
457 466
458 if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat))) 467 if (copy_from_user(&kbrep, up, sizeof(struct kbd_repeat))) {
459 return -EFAULT; 468 ret = -EFAULT;
460 err = kbd_rate(&kbrep); 469 break;
461 if (err) 470 }
462 return err; 471 ret = kbd_rate(&kbrep);
472 if (ret)
473 break;
463 if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat))) 474 if (copy_to_user(up, &kbrep, sizeof(struct kbd_repeat)))
464 return -EFAULT; 475 ret = -EFAULT;
465 return 0; 476 break;
466 } 477 }
467 478
468 case KDSETMODE: 479 case KDSETMODE:
@@ -475,7 +486,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
475 * need to restore their engine state. --BenH 486 * need to restore their engine state. --BenH
476 */ 487 */
477 if (!perm) 488 if (!perm)
478 return -EPERM; 489 goto eperm;
479 switch (arg) { 490 switch (arg) {
480 case KD_GRAPHICS: 491 case KD_GRAPHICS:
481 break; 492 break;
@@ -485,13 +496,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
485 case KD_TEXT: 496 case KD_TEXT:
486 break; 497 break;
487 default: 498 default:
488 return -EINVAL; 499 ret = -EINVAL;
500 goto out;
489 } 501 }
490 if (vc->vc_mode == (unsigned char) arg) 502 if (vc->vc_mode == (unsigned char) arg)
491 return 0; 503 break;
492 vc->vc_mode = (unsigned char) arg; 504 vc->vc_mode = (unsigned char) arg;
493 if (console != fg_console) 505 if (console != fg_console)
494 return 0; 506 break;
495 /* 507 /*
496 * explicitly blank/unblank the screen if switching modes 508 * explicitly blank/unblank the screen if switching modes
497 */ 509 */
@@ -501,7 +513,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
501 else 513 else
502 do_blank_screen(1); 514 do_blank_screen(1);
503 release_console_sem(); 515 release_console_sem();
504 return 0; 516 break;
505 517
506 case KDGETMODE: 518 case KDGETMODE:
507 ucval = vc->vc_mode; 519 ucval = vc->vc_mode;
@@ -513,11 +525,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
513 * these work like a combination of mmap and KDENABIO. 525 * these work like a combination of mmap and KDENABIO.
514 * this could be easily finished. 526 * this could be easily finished.
515 */ 527 */
516 return -EINVAL; 528 ret = -EINVAL;
529 break;
517 530
518 case KDSKBMODE: 531 case KDSKBMODE:
519 if (!perm) 532 if (!perm)
520 return -EPERM; 533 goto eperm;
521 switch(arg) { 534 switch(arg) {
522 case K_RAW: 535 case K_RAW:
523 kbd->kbdmode = VC_RAW; 536 kbd->kbdmode = VC_RAW;
@@ -534,10 +547,11 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
534 compute_shiftstate(); 547 compute_shiftstate();
535 break; 548 break;
536 default: 549 default:
537 return -EINVAL; 550 ret = -EINVAL;
551 goto out;
538 } 552 }
539 tty_ldisc_flush(tty); 553 tty_ldisc_flush(tty);
540 return 0; 554 break;
541 555
542 case KDGKBMODE: 556 case KDGKBMODE:
543 ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW : 557 ucval = ((kbd->kbdmode == VC_RAW) ? K_RAW :
@@ -557,28 +571,32 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
557 set_vc_kbd_mode(kbd, VC_META); 571 set_vc_kbd_mode(kbd, VC_META);
558 break; 572 break;
559 default: 573 default:
560 return -EINVAL; 574 ret = -EINVAL;
561 } 575 }
562 return 0; 576 break;
563 577
564 case KDGKBMETA: 578 case KDGKBMETA:
565 ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT); 579 ucval = (vc_kbd_mode(kbd, VC_META) ? K_ESCPREFIX : K_METABIT);
566 setint: 580 setint:
567 return put_user(ucval, (int __user *)arg); 581 ret = put_user(ucval, (int __user *)arg);
582 break;
568 583
569 case KDGETKEYCODE: 584 case KDGETKEYCODE:
570 case KDSETKEYCODE: 585 case KDSETKEYCODE:
571 if(!capable(CAP_SYS_TTY_CONFIG)) 586 if(!capable(CAP_SYS_TTY_CONFIG))
572 perm=0; 587 perm = 0;
573 return do_kbkeycode_ioctl(cmd, up, perm); 588 ret = do_kbkeycode_ioctl(cmd, up, perm);
589 break;
574 590
575 case KDGKBENT: 591 case KDGKBENT:
576 case KDSKBENT: 592 case KDSKBENT:
577 return do_kdsk_ioctl(cmd, up, perm, kbd); 593 ret = do_kdsk_ioctl(cmd, up, perm, kbd);
594 break;
578 595
579 case KDGKBSENT: 596 case KDGKBSENT:
580 case KDSKBSENT: 597 case KDSKBSENT:
581 return do_kdgkb_ioctl(cmd, up, perm); 598 ret = do_kdgkb_ioctl(cmd, up, perm);
599 break;
582 600
583 case KDGKBDIACR: 601 case KDGKBDIACR:
584 { 602 {
@@ -586,26 +604,31 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
586 struct kbdiacr diacr; 604 struct kbdiacr diacr;
587 int i; 605 int i;
588 606
589 if (put_user(accent_table_size, &a->kb_cnt)) 607 if (put_user(accent_table_size, &a->kb_cnt)) {
590 return -EFAULT; 608 ret = -EFAULT;
609 break;
610 }
591 for (i = 0; i < accent_table_size; i++) { 611 for (i = 0; i < accent_table_size; i++) {
592 diacr.diacr = conv_uni_to_8bit(accent_table[i].diacr); 612 diacr.diacr = conv_uni_to_8bit(accent_table[i].diacr);
593 diacr.base = conv_uni_to_8bit(accent_table[i].base); 613 diacr.base = conv_uni_to_8bit(accent_table[i].base);
594 diacr.result = conv_uni_to_8bit(accent_table[i].result); 614 diacr.result = conv_uni_to_8bit(accent_table[i].result);
595 if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr))) 615 if (copy_to_user(a->kbdiacr + i, &diacr, sizeof(struct kbdiacr))) {
596 return -EFAULT; 616 ret = -EFAULT;
617 break;
618 }
597 } 619 }
598 return 0; 620 break;
599 } 621 }
600 case KDGKBDIACRUC: 622 case KDGKBDIACRUC:
601 { 623 {
602 struct kbdiacrsuc __user *a = up; 624 struct kbdiacrsuc __user *a = up;
603 625
604 if (put_user(accent_table_size, &a->kb_cnt)) 626 if (put_user(accent_table_size, &a->kb_cnt))
605 return -EFAULT; 627 ret = -EFAULT;
606 if (copy_to_user(a->kbdiacruc, accent_table, accent_table_size*sizeof(struct kbdiacruc))) 628 else if (copy_to_user(a->kbdiacruc, accent_table,
607 return -EFAULT; 629 accent_table_size*sizeof(struct kbdiacruc)))
608 return 0; 630 ret = -EFAULT;
631 break;
609 } 632 }
610 633
611 case KDSKBDIACR: 634 case KDSKBDIACR:
@@ -616,20 +639,26 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
616 int i; 639 int i;
617 640
618 if (!perm) 641 if (!perm)
619 return -EPERM; 642 goto eperm;
620 if (get_user(ct,&a->kb_cnt)) 643 if (get_user(ct,&a->kb_cnt)) {
621 return -EFAULT; 644 ret = -EFAULT;
622 if (ct >= MAX_DIACR) 645 break;
623 return -EINVAL; 646 }
647 if (ct >= MAX_DIACR) {
648 ret = -EINVAL;
649 break;
650 }
624 accent_table_size = ct; 651 accent_table_size = ct;
625 for (i = 0; i < ct; i++) { 652 for (i = 0; i < ct; i++) {
626 if (copy_from_user(&diacr, a->kbdiacr + i, sizeof(struct kbdiacr))) 653 if (copy_from_user(&diacr, a->kbdiacr + i, sizeof(struct kbdiacr))) {
627 return -EFAULT; 654 ret = -EFAULT;
655 break;
656 }
628 accent_table[i].diacr = conv_8bit_to_uni(diacr.diacr); 657 accent_table[i].diacr = conv_8bit_to_uni(diacr.diacr);
629 accent_table[i].base = conv_8bit_to_uni(diacr.base); 658 accent_table[i].base = conv_8bit_to_uni(diacr.base);
630 accent_table[i].result = conv_8bit_to_uni(diacr.result); 659 accent_table[i].result = conv_8bit_to_uni(diacr.result);
631 } 660 }
632 return 0; 661 break;
633 } 662 }
634 663
635 case KDSKBDIACRUC: 664 case KDSKBDIACRUC:
@@ -638,15 +667,19 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
638 unsigned int ct; 667 unsigned int ct;
639 668
640 if (!perm) 669 if (!perm)
641 return -EPERM; 670 goto eperm;
642 if (get_user(ct,&a->kb_cnt)) 671 if (get_user(ct,&a->kb_cnt)) {
643 return -EFAULT; 672 ret = -EFAULT;
644 if (ct >= MAX_DIACR) 673 break;
645 return -EINVAL; 674 }
675 if (ct >= MAX_DIACR) {
676 ret = -EINVAL;
677 break;
678 }
646 accent_table_size = ct; 679 accent_table_size = ct;
647 if (copy_from_user(accent_table, a->kbdiacruc, ct*sizeof(struct kbdiacruc))) 680 if (copy_from_user(accent_table, a->kbdiacruc, ct*sizeof(struct kbdiacruc)))
648 return -EFAULT; 681 ret = -EFAULT;
649 return 0; 682 break;
650 } 683 }
651 684
652 /* the ioctls below read/set the flags usually shown in the leds */ 685 /* the ioctls below read/set the flags usually shown in the leds */
@@ -657,26 +690,29 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
657 690
658 case KDSKBLED: 691 case KDSKBLED:
659 if (!perm) 692 if (!perm)
660 return -EPERM; 693 goto eperm;
661 if (arg & ~0x77) 694 if (arg & ~0x77) {
662 return -EINVAL; 695 ret = -EINVAL;
696 break;
697 }
663 kbd->ledflagstate = (arg & 7); 698 kbd->ledflagstate = (arg & 7);
664 kbd->default_ledflagstate = ((arg >> 4) & 7); 699 kbd->default_ledflagstate = ((arg >> 4) & 7);
665 set_leds(); 700 set_leds();
666 return 0; 701 break;
667 702
668 /* the ioctls below only set the lights, not the functions */ 703 /* the ioctls below only set the lights, not the functions */
669 /* for those, see KDGKBLED and KDSKBLED above */ 704 /* for those, see KDGKBLED and KDSKBLED above */
670 case KDGETLED: 705 case KDGETLED:
671 ucval = getledstate(); 706 ucval = getledstate();
672 setchar: 707 setchar:
673 return put_user(ucval, (char __user *)arg); 708 ret = put_user(ucval, (char __user *)arg);
709 break;
674 710
675 case KDSETLED: 711 case KDSETLED:
676 if (!perm) 712 if (!perm)
677 return -EPERM; 713 goto eperm;
678 setledstate(kbd, arg); 714 setledstate(kbd, arg);
679 return 0; 715 break;
680 716
681 /* 717 /*
682 * A process can indicate its willingness to accept signals 718 * A process can indicate its willingness to accept signals
@@ -688,16 +724,17 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
688 case KDSIGACCEPT: 724 case KDSIGACCEPT:
689 { 725 {
690 if (!perm || !capable(CAP_KILL)) 726 if (!perm || !capable(CAP_KILL))
691 return -EPERM; 727 goto eperm;
692 if (!valid_signal(arg) || arg < 1 || arg == SIGKILL) 728 if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
693 return -EINVAL; 729 ret = -EINVAL;
694 730 else {
695 spin_lock_irq(&vt_spawn_con.lock); 731 spin_lock_irq(&vt_spawn_con.lock);
696 put_pid(vt_spawn_con.pid); 732 put_pid(vt_spawn_con.pid);
697 vt_spawn_con.pid = get_pid(task_pid(current)); 733 vt_spawn_con.pid = get_pid(task_pid(current));
698 vt_spawn_con.sig = arg; 734 vt_spawn_con.sig = arg;
699 spin_unlock_irq(&vt_spawn_con.lock); 735 spin_unlock_irq(&vt_spawn_con.lock);
700 return 0; 736 }
737 break;
701 } 738 }
702 739
703 case VT_SETMODE: 740 case VT_SETMODE:
@@ -705,11 +742,15 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
705 struct vt_mode tmp; 742 struct vt_mode tmp;
706 743
707 if (!perm) 744 if (!perm)
708 return -EPERM; 745 goto eperm;
709 if (copy_from_user(&tmp, up, sizeof(struct vt_mode))) 746 if (copy_from_user(&tmp, up, sizeof(struct vt_mode))) {
710 return -EFAULT; 747 ret = -EFAULT;
711 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) 748 goto out;
712 return -EINVAL; 749 }
750 if (tmp.mode != VT_AUTO && tmp.mode != VT_PROCESS) {
751 ret = -EINVAL;
752 goto out;
753 }
713 acquire_console_sem(); 754 acquire_console_sem();
714 vc->vt_mode = tmp; 755 vc->vt_mode = tmp;
715 /* the frsig is ignored, so we set it to 0 */ 756 /* the frsig is ignored, so we set it to 0 */
@@ -719,7 +760,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
719 /* no switch is required -- saw@shade.msu.ru */ 760 /* no switch is required -- saw@shade.msu.ru */
720 vc->vt_newvt = -1; 761 vc->vt_newvt = -1;
721 release_console_sem(); 762 release_console_sem();
722 return 0; 763 break;
723 } 764 }
724 765
725 case VT_GETMODE: 766 case VT_GETMODE:
@@ -732,7 +773,9 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
732 release_console_sem(); 773 release_console_sem();
733 774
734 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode)); 775 rc = copy_to_user(up, &tmp, sizeof(struct vt_mode));
735 return rc ? -EFAULT : 0; 776 if (rc)
777 ret = -EFAULT;
778 break;
736 } 779 }
737 780
738 /* 781 /*
@@ -746,12 +789,16 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
746 unsigned short state, mask; 789 unsigned short state, mask;
747 790
748 if (put_user(fg_console + 1, &vtstat->v_active)) 791 if (put_user(fg_console + 1, &vtstat->v_active))
749 return -EFAULT; 792 ret = -EFAULT;
750 state = 1; /* /dev/tty0 is always open */ 793 else {
751 for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask; ++i, mask <<= 1) 794 state = 1; /* /dev/tty0 is always open */
752 if (VT_IS_IN_USE(i)) 795 for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
753 state |= mask; 796 ++i, mask <<= 1)
754 return put_user(state, &vtstat->v_state); 797 if (VT_IS_IN_USE(i))
798 state |= mask;
799 ret = put_user(state, &vtstat->v_state);
800 }
801 break;
755 } 802 }
756 803
757 /* 804 /*
@@ -771,27 +818,31 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
771 */ 818 */
772 case VT_ACTIVATE: 819 case VT_ACTIVATE:
773 if (!perm) 820 if (!perm)
774 return -EPERM; 821 goto eperm;
775 if (arg == 0 || arg > MAX_NR_CONSOLES) 822 if (arg == 0 || arg > MAX_NR_CONSOLES)
776 return -ENXIO; 823 ret = -ENXIO;
777 arg--; 824 else {
778 acquire_console_sem(); 825 arg--;
779 i = vc_allocate(arg); 826 acquire_console_sem();
780 release_console_sem(); 827 ret = vc_allocate(arg);
781 if (i) 828 release_console_sem();
782 return i; 829 if (ret)
783 set_console(arg); 830 break;
784 return 0; 831 set_console(arg);
832 }
833 break;
785 834
786 /* 835 /*
787 * wait until the specified VT has been activated 836 * wait until the specified VT has been activated
788 */ 837 */
789 case VT_WAITACTIVE: 838 case VT_WAITACTIVE:
790 if (!perm) 839 if (!perm)
791 return -EPERM; 840 goto eperm;
792 if (arg == 0 || arg > MAX_NR_CONSOLES) 841 if (arg == 0 || arg > MAX_NR_CONSOLES)
793 return -ENXIO; 842 ret = -ENXIO;
794 return vt_waitactive(arg-1); 843 else
844 ret = vt_waitactive(arg - 1);
845 break;
795 846
796 /* 847 /*
797 * If a vt is under process control, the kernel will not switch to it 848 * If a vt is under process control, the kernel will not switch to it
@@ -805,10 +856,12 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
805 */ 856 */
806 case VT_RELDISP: 857 case VT_RELDISP:
807 if (!perm) 858 if (!perm)
808 return -EPERM; 859 goto eperm;
809 if (vc->vt_mode.mode != VT_PROCESS)
810 return -EINVAL;
811 860
861 if (vc->vt_mode.mode != VT_PROCESS) {
862 ret = -EINVAL;
863 break;
864 }
812 /* 865 /*
813 * Switching-from response 866 * Switching-from response
814 */ 867 */
@@ -829,10 +882,10 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
829 int newvt; 882 int newvt;
830 newvt = vc->vt_newvt; 883 newvt = vc->vt_newvt;
831 vc->vt_newvt = -1; 884 vc->vt_newvt = -1;
832 i = vc_allocate(newvt); 885 ret = vc_allocate(newvt);
833 if (i) { 886 if (ret) {
834 release_console_sem(); 887 release_console_sem();
835 return i; 888 break;
836 } 889 }
837 /* 890 /*
838 * When we actually do the console switch, 891 * When we actually do the console switch,
@@ -841,31 +894,27 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
841 */ 894 */
842 complete_change_console(vc_cons[newvt].d); 895 complete_change_console(vc_cons[newvt].d);
843 } 896 }
844 } 897 } else {
845 898 /*
846 /* 899 * Switched-to response
847 * Switched-to response 900 */
848 */
849 else
850 {
851 /* 901 /*
852 * If it's just an ACK, ignore it 902 * If it's just an ACK, ignore it
853 */ 903 */
854 if (arg != VT_ACKACQ) { 904 if (arg != VT_ACKACQ)
855 release_console_sem(); 905 ret = -EINVAL;
856 return -EINVAL;
857 }
858 } 906 }
859 release_console_sem(); 907 release_console_sem();
860 908 break;
861 return 0;
862 909
863 /* 910 /*
864 * Disallocate memory associated to VT (but leave VT1) 911 * Disallocate memory associated to VT (but leave VT1)
865 */ 912 */
866 case VT_DISALLOCATE: 913 case VT_DISALLOCATE:
867 if (arg > MAX_NR_CONSOLES) 914 if (arg > MAX_NR_CONSOLES) {
868 return -ENXIO; 915 ret = -ENXIO;
916 break;
917 }
869 if (arg == 0) { 918 if (arg == 0) {
870 /* deallocate all unused consoles, but leave 0 */ 919 /* deallocate all unused consoles, but leave 0 */
871 acquire_console_sem(); 920 acquire_console_sem();
@@ -877,14 +926,14 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
877 /* deallocate a single console, if possible */ 926 /* deallocate a single console, if possible */
878 arg--; 927 arg--;
879 if (VT_BUSY(arg)) 928 if (VT_BUSY(arg))
880 return -EBUSY; 929 ret = -EBUSY;
881 if (arg) { /* leave 0 */ 930 else if (arg) { /* leave 0 */
882 acquire_console_sem(); 931 acquire_console_sem();
883 vc_deallocate(arg); 932 vc_deallocate(arg);
884 release_console_sem(); 933 release_console_sem();
885 } 934 }
886 } 935 }
887 return 0; 936 break;
888 937
889 case VT_RESIZE: 938 case VT_RESIZE:
890 { 939 {
@@ -893,21 +942,21 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
893 942
894 ushort ll,cc; 943 ushort ll,cc;
895 if (!perm) 944 if (!perm)
896 return -EPERM; 945 goto eperm;
897 if (get_user(ll, &vtsizes->v_rows) || 946 if (get_user(ll, &vtsizes->v_rows) ||
898 get_user(cc, &vtsizes->v_cols)) 947 get_user(cc, &vtsizes->v_cols))
899 return -EFAULT; 948 ret = -EFAULT;
900 949 else {
901 for (i = 0; i < MAX_NR_CONSOLES; i++) { 950 for (i = 0; i < MAX_NR_CONSOLES; i++) {
902 vc = vc_cons[i].d; 951 vc = vc_cons[i].d;
903 952
904 if (vc) { 953 if (vc) {
905 vc->vc_resize_user = 1; 954 vc->vc_resize_user = 1;
906 vc_lock_resize(vc_cons[i].d, cc, ll); 955 vc_lock_resize(vc_cons[i].d, cc, ll);
956 }
907 } 957 }
908 } 958 }
909 959 break;
910 return 0;
911 } 960 }
912 961
913 case VT_RESIZEX: 962 case VT_RESIZEX:
@@ -915,10 +964,13 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
915 struct vt_consize __user *vtconsize = up; 964 struct vt_consize __user *vtconsize = up;
916 ushort ll,cc,vlin,clin,vcol,ccol; 965 ushort ll,cc,vlin,clin,vcol,ccol;
917 if (!perm) 966 if (!perm)
918 return -EPERM; 967 goto eperm;
919 if (!access_ok(VERIFY_READ, vtconsize, 968 if (!access_ok(VERIFY_READ, vtconsize,
920 sizeof(struct vt_consize))) 969 sizeof(struct vt_consize))) {
921 return -EFAULT; 970 ret = -EFAULT;
971 break;
972 }
973 /* FIXME: Should check the copies properly */
922 __get_user(ll, &vtconsize->v_rows); 974 __get_user(ll, &vtconsize->v_rows);
923 __get_user(cc, &vtconsize->v_cols); 975 __get_user(cc, &vtconsize->v_cols);
924 __get_user(vlin, &vtconsize->v_vlin); 976 __get_user(vlin, &vtconsize->v_vlin);
@@ -928,21 +980,28 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
928 vlin = vlin ? vlin : vc->vc_scan_lines; 980 vlin = vlin ? vlin : vc->vc_scan_lines;
929 if (clin) { 981 if (clin) {
930 if (ll) { 982 if (ll) {
931 if (ll != vlin/clin) 983 if (ll != vlin/clin) {
932 return -EINVAL; /* Parameters don't add up */ 984 /* Parameters don't add up */
985 ret = -EINVAL;
986 break;
987 }
933 } else 988 } else
934 ll = vlin/clin; 989 ll = vlin/clin;
935 } 990 }
936 if (vcol && ccol) { 991 if (vcol && ccol) {
937 if (cc) { 992 if (cc) {
938 if (cc != vcol/ccol) 993 if (cc != vcol/ccol) {
939 return -EINVAL; 994 ret = -EINVAL;
995 break;
996 }
940 } else 997 } else
941 cc = vcol/ccol; 998 cc = vcol/ccol;
942 } 999 }
943 1000
944 if (clin > 32) 1001 if (clin > 32) {
945 return -EINVAL; 1002 ret = -EINVAL;
1003 break;
1004 }
946 1005
947 for (i = 0; i < MAX_NR_CONSOLES; i++) { 1006 for (i = 0; i < MAX_NR_CONSOLES; i++) {
948 if (!vc_cons[i].d) 1007 if (!vc_cons[i].d)
@@ -956,19 +1015,20 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
956 vc_resize(vc_cons[i].d, cc, ll); 1015 vc_resize(vc_cons[i].d, cc, ll);
957 release_console_sem(); 1016 release_console_sem();
958 } 1017 }
959 return 0; 1018 break;
960 } 1019 }
961 1020
962 case PIO_FONT: { 1021 case PIO_FONT: {
963 if (!perm) 1022 if (!perm)
964 return -EPERM; 1023 goto eperm;
965 op.op = KD_FONT_OP_SET; 1024 op.op = KD_FONT_OP_SET;
966 op.flags = KD_FONT_FLAG_OLD | KD_FONT_FLAG_DONT_RECALC; /* Compatibility */ 1025 op.flags = KD_FONT_FLAG_OLD | KD_FONT_FLAG_DONT_RECALC; /* Compatibility */
967 op.width = 8; 1026 op.width = 8;
968 op.height = 0; 1027 op.height = 0;
969 op.charcount = 256; 1028 op.charcount = 256;
970 op.data = up; 1029 op.data = up;
971 return con_font_op(vc_cons[fg_console].d, &op); 1030 ret = con_font_op(vc_cons[fg_console].d, &op);
1031 break;
972 } 1032 }
973 1033
974 case GIO_FONT: { 1034 case GIO_FONT: {
@@ -978,100 +1038,124 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
978 op.height = 32; 1038 op.height = 32;
979 op.charcount = 256; 1039 op.charcount = 256;
980 op.data = up; 1040 op.data = up;
981 return con_font_op(vc_cons[fg_console].d, &op); 1041 ret = con_font_op(vc_cons[fg_console].d, &op);
1042 break;
982 } 1043 }
983 1044
984 case PIO_CMAP: 1045 case PIO_CMAP:
985 if (!perm) 1046 if (!perm)
986 return -EPERM; 1047 ret = -EPERM;
987 return con_set_cmap(up); 1048 else
1049 ret = con_set_cmap(up);
1050 break;
988 1051
989 case GIO_CMAP: 1052 case GIO_CMAP:
990 return con_get_cmap(up); 1053 ret = con_get_cmap(up);
1054 break;
991 1055
992 case PIO_FONTX: 1056 case PIO_FONTX:
993 case GIO_FONTX: 1057 case GIO_FONTX:
994 return do_fontx_ioctl(cmd, up, perm, &op); 1058 ret = do_fontx_ioctl(cmd, up, perm, &op);
1059 break;
995 1060
996 case PIO_FONTRESET: 1061 case PIO_FONTRESET:
997 { 1062 {
998 if (!perm) 1063 if (!perm)
999 return -EPERM; 1064 goto eperm;
1000 1065
1001#ifdef BROKEN_GRAPHICS_PROGRAMS 1066#ifdef BROKEN_GRAPHICS_PROGRAMS
1002 /* With BROKEN_GRAPHICS_PROGRAMS defined, the default 1067 /* With BROKEN_GRAPHICS_PROGRAMS defined, the default
1003 font is not saved. */ 1068 font is not saved. */
1004 return -ENOSYS; 1069 ret = -ENOSYS;
1070 break;
1005#else 1071#else
1006 { 1072 {
1007 op.op = KD_FONT_OP_SET_DEFAULT; 1073 op.op = KD_FONT_OP_SET_DEFAULT;
1008 op.data = NULL; 1074 op.data = NULL;
1009 i = con_font_op(vc_cons[fg_console].d, &op); 1075 ret = con_font_op(vc_cons[fg_console].d, &op);
1010 if (i) 1076 if (ret)
1011 return i; 1077 break;
1012 con_set_default_unimap(vc_cons[fg_console].d); 1078 con_set_default_unimap(vc_cons[fg_console].d);
1013 return 0; 1079 break;
1014 } 1080 }
1015#endif 1081#endif
1016 } 1082 }
1017 1083
1018 case KDFONTOP: { 1084 case KDFONTOP: {
1019 if (copy_from_user(&op, up, sizeof(op))) 1085 if (copy_from_user(&op, up, sizeof(op))) {
1020 return -EFAULT; 1086 ret = -EFAULT;
1087 break;
1088 }
1021 if (!perm && op.op != KD_FONT_OP_GET) 1089 if (!perm && op.op != KD_FONT_OP_GET)
1022 return -EPERM; 1090 goto eperm;
1023 i = con_font_op(vc, &op); 1091 ret = con_font_op(vc, &op);
1024 if (i) return i; 1092 if (ret)
1093 break;
1025 if (copy_to_user(up, &op, sizeof(op))) 1094 if (copy_to_user(up, &op, sizeof(op)))
1026 return -EFAULT; 1095 ret = -EFAULT;
1027 return 0; 1096 break;
1028 } 1097 }
1029 1098
1030 case PIO_SCRNMAP: 1099 case PIO_SCRNMAP:
1031 if (!perm) 1100 if (!perm)
1032 return -EPERM; 1101 ret = -EPERM;
1033 return con_set_trans_old(up); 1102 else
1103 ret = con_set_trans_old(up);
1104 break;
1034 1105
1035 case GIO_SCRNMAP: 1106 case GIO_SCRNMAP:
1036 return con_get_trans_old(up); 1107 ret = con_get_trans_old(up);
1108 break;
1037 1109
1038 case PIO_UNISCRNMAP: 1110 case PIO_UNISCRNMAP:
1039 if (!perm) 1111 if (!perm)
1040 return -EPERM; 1112 ret = -EPERM;
1041 return con_set_trans_new(up); 1113 else
1114 ret = con_set_trans_new(up);
1115 break;
1042 1116
1043 case GIO_UNISCRNMAP: 1117 case GIO_UNISCRNMAP:
1044 return con_get_trans_new(up); 1118 ret = con_get_trans_new(up);
1119 break;
1045 1120
1046 case PIO_UNIMAPCLR: 1121 case PIO_UNIMAPCLR:
1047 { struct unimapinit ui; 1122 { struct unimapinit ui;
1048 if (!perm) 1123 if (!perm)
1049 return -EPERM; 1124 goto eperm;
1050 i = copy_from_user(&ui, up, sizeof(struct unimapinit)); 1125 ret = copy_from_user(&ui, up, sizeof(struct unimapinit));
1051 if (i) return -EFAULT; 1126 if (!ret)
1052 con_clear_unimap(vc, &ui); 1127 con_clear_unimap(vc, &ui);
1053 return 0; 1128 break;
1054 } 1129 }
1055 1130
1056 case PIO_UNIMAP: 1131 case PIO_UNIMAP:
1057 case GIO_UNIMAP: 1132 case GIO_UNIMAP:
1058 return do_unimap_ioctl(cmd, up, perm, vc); 1133 ret = do_unimap_ioctl(cmd, up, perm, vc);
1134 break;
1059 1135
1060 case VT_LOCKSWITCH: 1136 case VT_LOCKSWITCH:
1061 if (!capable(CAP_SYS_TTY_CONFIG)) 1137 if (!capable(CAP_SYS_TTY_CONFIG))
1062 return -EPERM; 1138 goto eperm;
1063 vt_dont_switch = 1; 1139 vt_dont_switch = 1;
1064 return 0; 1140 break;
1065 case VT_UNLOCKSWITCH: 1141 case VT_UNLOCKSWITCH:
1066 if (!capable(CAP_SYS_TTY_CONFIG)) 1142 if (!capable(CAP_SYS_TTY_CONFIG))
1067 return -EPERM; 1143 goto eperm;
1068 vt_dont_switch = 0; 1144 vt_dont_switch = 0;
1069 return 0; 1145 break;
1070 case VT_GETHIFONTMASK: 1146 case VT_GETHIFONTMASK:
1071 return put_user(vc->vc_hi_font_mask, (unsigned short __user *)arg); 1147 ret = put_user(vc->vc_hi_font_mask,
1148 (unsigned short __user *)arg);
1149 break;
1072 default: 1150 default:
1073 return -ENOIOCTLCMD; 1151 ret = -ENOIOCTLCMD;
1074 } 1152 }
1153out:
1154 unlock_kernel();
1155 return ret;
1156eperm:
1157 ret = -EPERM;
1158 goto out;
1075} 1159}
1076 1160
1077/* 1161/*
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 24c62b848bf9..7f138c6195ff 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -382,7 +382,7 @@ fail:
382 spin_unlock_irqrestore(&gpio_lock, flags); 382 spin_unlock_irqrestore(&gpio_lock, flags);
383 if (status) 383 if (status)
384 pr_debug("%s: gpio-%d status %d\n", 384 pr_debug("%s: gpio-%d status %d\n",
385 __FUNCTION__, gpio, status); 385 __func__, gpio, status);
386 return status; 386 return status;
387} 387}
388EXPORT_SYMBOL_GPL(gpio_direction_input); 388EXPORT_SYMBOL_GPL(gpio_direction_input);
@@ -420,7 +420,7 @@ fail:
420 spin_unlock_irqrestore(&gpio_lock, flags); 420 spin_unlock_irqrestore(&gpio_lock, flags);
421 if (status) 421 if (status)
422 pr_debug("%s: gpio-%d status %d\n", 422 pr_debug("%s: gpio-%d status %d\n",
423 __FUNCTION__, gpio, status); 423 __func__, gpio, status);
424 return status; 424 return status;
425} 425}
426EXPORT_SYMBOL_GPL(gpio_direction_output); 426EXPORT_SYMBOL_GPL(gpio_direction_output);
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index ed71a8bc70dc..5c8b6e0ff47c 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -224,7 +224,7 @@ static int ads7828_detect(struct i2c_adapter *adapter, int address, int kind)
224 if (in_data & 0xF000) { 224 if (in_data & 0xF000) {
225 printk(KERN_DEBUG 225 printk(KERN_DEBUG
226 "%s : Doesn't look like an ads7828 device\n", 226 "%s : Doesn't look like an ads7828 device\n",
227 __FUNCTION__); 227 __func__);
228 goto exit_free; 228 goto exit_free;
229 } 229 }
230 } 230 }
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c
index e1a3a79ab3f9..7ff71ba7b7c9 100644
--- a/drivers/input/serio/serport.c
+++ b/drivers/input/serio/serport.c
@@ -46,7 +46,7 @@ struct serport {
46static int serport_serio_write(struct serio *serio, unsigned char data) 46static int serport_serio_write(struct serio *serio, unsigned char data)
47{ 47{
48 struct serport *serport = serio->port_data; 48 struct serport *serport = serio->port_data;
49 return -(serport->tty->driver->write(serport->tty, &data, 1) != 1); 49 return -(serport->tty->ops->write(serport->tty, &data, 1) != 1);
50} 50}
51 51
52static int serport_serio_open(struct serio *serio) 52static int serport_serio_open(struct serio *serio)
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 24c6b7ca62be..6ca0bb949ad3 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -1111,11 +1111,12 @@ static int capinc_tty_write(struct tty_struct * tty,
1111 return count; 1111 return count;
1112} 1112}
1113 1113
1114static void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) 1114static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
1115{ 1115{
1116 struct capiminor *mp = (struct capiminor *)tty->driver_data; 1116 struct capiminor *mp = (struct capiminor *)tty->driver_data;
1117 struct sk_buff *skb; 1117 struct sk_buff *skb;
1118 unsigned long flags; 1118 unsigned long flags;
1119 int ret = 1;
1119 1120
1120#ifdef _DEBUG_TTYFUNCS 1121#ifdef _DEBUG_TTYFUNCS
1121 printk(KERN_DEBUG "capinc_put_char(%u)\n", ch); 1122 printk(KERN_DEBUG "capinc_put_char(%u)\n", ch);
@@ -1125,7 +1126,7 @@ static void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
1125#ifdef _DEBUG_TTYFUNCS 1126#ifdef _DEBUG_TTYFUNCS
1126 printk(KERN_DEBUG "capinc_tty_put_char: mp or mp->ncci NULL\n"); 1127 printk(KERN_DEBUG "capinc_tty_put_char: mp or mp->ncci NULL\n");
1127#endif 1128#endif
1128 return; 1129 return 0;
1129 } 1130 }
1130 1131
1131 spin_lock_irqsave(&workaround_lock, flags); 1132 spin_lock_irqsave(&workaround_lock, flags);
@@ -1134,7 +1135,7 @@ static void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
1134 if (skb_tailroom(skb) > 0) { 1135 if (skb_tailroom(skb) > 0) {
1135 *(skb_put(skb, 1)) = ch; 1136 *(skb_put(skb, 1)) = ch;
1136 spin_unlock_irqrestore(&workaround_lock, flags); 1137 spin_unlock_irqrestore(&workaround_lock, flags);
1137 return; 1138 return 1;
1138 } 1139 }
1139 mp->ttyskb = NULL; 1140 mp->ttyskb = NULL;
1140 skb_queue_tail(&mp->outqueue, skb); 1141 skb_queue_tail(&mp->outqueue, skb);
@@ -1148,8 +1149,10 @@ static void capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
1148 mp->ttyskb = skb; 1149 mp->ttyskb = skb;
1149 } else { 1150 } else {
1150 printk(KERN_ERR "capinc_put_char: char %u lost\n", ch); 1151 printk(KERN_ERR "capinc_put_char: char %u lost\n", ch);
1152 ret = 0;
1151 } 1153 }
1152 spin_unlock_irqrestore(&workaround_lock, flags); 1154 spin_unlock_irqrestore(&workaround_lock, flags);
1155 return ret;
1153} 1156}
1154 1157
1155static void capinc_tty_flush_chars(struct tty_struct *tty) 1158static void capinc_tty_flush_chars(struct tty_struct *tty)
diff --git a/drivers/isdn/gigaset/ser-gigaset.c b/drivers/isdn/gigaset/ser-gigaset.c
index fceeb1d57682..45d1ee93cd39 100644
--- a/drivers/isdn/gigaset/ser-gigaset.c
+++ b/drivers/isdn/gigaset/ser-gigaset.c
@@ -68,10 +68,10 @@ static int write_modem(struct cardstate *cs)
68 struct tty_struct *tty = cs->hw.ser->tty; 68 struct tty_struct *tty = cs->hw.ser->tty;
69 struct bc_state *bcs = &cs->bcs[0]; /* only one channel */ 69 struct bc_state *bcs = &cs->bcs[0]; /* only one channel */
70 struct sk_buff *skb = bcs->tx_skb; 70 struct sk_buff *skb = bcs->tx_skb;
71 int sent; 71 int sent = -EOPNOTSUPP;
72 72
73 if (!tty || !tty->driver || !skb) 73 if (!tty || !tty->driver || !skb)
74 return -EFAULT; 74 return -EINVAL;
75 75
76 if (!skb->len) { 76 if (!skb->len) {
77 dev_kfree_skb_any(skb); 77 dev_kfree_skb_any(skb);
@@ -80,7 +80,8 @@ static int write_modem(struct cardstate *cs)
80 } 80 }
81 81
82 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 82 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
83 sent = tty->driver->write(tty, skb->data, skb->len); 83 if (tty->ops->write)
84 sent = tty->ops->write(tty, skb->data, skb->len);
84 gig_dbg(DEBUG_OUTPUT, "write_modem: sent %d", sent); 85 gig_dbg(DEBUG_OUTPUT, "write_modem: sent %d", sent);
85 if (sent < 0) { 86 if (sent < 0) {
86 /* error */ 87 /* error */
@@ -120,7 +121,7 @@ static int send_cb(struct cardstate *cs)
120 121
121 if (cb->len) { 122 if (cb->len) {
122 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 123 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
123 sent = tty->driver->write(tty, cb->buf + cb->offset, cb->len); 124 sent = tty->ops->write(tty, cb->buf + cb->offset, cb->len);
124 if (sent < 0) { 125 if (sent < 0) {
125 /* error */ 126 /* error */
126 gig_dbg(DEBUG_OUTPUT, "send_cb: write error %d", sent); 127 gig_dbg(DEBUG_OUTPUT, "send_cb: write error %d", sent);
@@ -440,14 +441,14 @@ static int gigaset_set_modem_ctrl(struct cardstate *cs, unsigned old_state, unsi
440 struct tty_struct *tty = cs->hw.ser->tty; 441 struct tty_struct *tty = cs->hw.ser->tty;
441 unsigned int set, clear; 442 unsigned int set, clear;
442 443
443 if (!tty || !tty->driver || !tty->driver->tiocmset) 444 if (!tty || !tty->driver || !tty->ops->tiocmset)
444 return -EFAULT; 445 return -EINVAL;
445 set = new_state & ~old_state; 446 set = new_state & ~old_state;
446 clear = old_state & ~new_state; 447 clear = old_state & ~new_state;
447 if (!set && !clear) 448 if (!set && !clear)
448 return 0; 449 return 0;
449 gig_dbg(DEBUG_IF, "tiocmset set %x clear %x", set, clear); 450 gig_dbg(DEBUG_IF, "tiocmset set %x clear %x", set, clear);
450 return tty->driver->tiocmset(tty, NULL, set, clear); 451 return tty->ops->tiocmset(tty, NULL, set, clear);
451} 452}
452 453
453static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag) 454static int gigaset_baud_rate(struct cardstate *cs, unsigned cflag)
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index 8af0df1d5b8c..1a2222cbb805 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -1352,12 +1352,14 @@ isdn_tty_tiocmget(struct tty_struct *tty, struct file *file)
1352 if (tty->flags & (1 << TTY_IO_ERROR)) 1352 if (tty->flags & (1 << TTY_IO_ERROR))
1353 return -EIO; 1353 return -EIO;
1354 1354
1355 lock_kernel();
1355#ifdef ISDN_DEBUG_MODEM_IOCTL 1356#ifdef ISDN_DEBUG_MODEM_IOCTL
1356 printk(KERN_DEBUG "ttyI%d ioctl TIOCMGET\n", info->line); 1357 printk(KERN_DEBUG "ttyI%d ioctl TIOCMGET\n", info->line);
1357#endif 1358#endif
1358 1359
1359 control = info->mcr; 1360 control = info->mcr;
1360 status = info->msr; 1361 status = info->msr;
1362 unlock_kernel();
1361 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0) 1363 return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
1362 | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0) 1364 | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
1363 | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0) 1365 | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
@@ -1381,6 +1383,7 @@ isdn_tty_tiocmset(struct tty_struct *tty, struct file *file,
1381 printk(KERN_DEBUG "ttyI%d ioctl TIOCMxxx: %x %x\n", info->line, set, clear); 1383 printk(KERN_DEBUG "ttyI%d ioctl TIOCMxxx: %x %x\n", info->line, set, clear);
1382#endif 1384#endif
1383 1385
1386 lock_kernel();
1384 if (set & TIOCM_RTS) 1387 if (set & TIOCM_RTS)
1385 info->mcr |= UART_MCR_RTS; 1388 info->mcr |= UART_MCR_RTS;
1386 if (set & TIOCM_DTR) { 1389 if (set & TIOCM_DTR) {
@@ -1402,6 +1405,7 @@ isdn_tty_tiocmset(struct tty_struct *tty, struct file *file,
1402 isdn_tty_modem_hup(info, 1); 1405 isdn_tty_modem_hup(info, 1);
1403 } 1406 }
1404 } 1407 }
1408 unlock_kernel();
1405 return 0; 1409 return 0;
1406} 1410}
1407 1411
@@ -1435,21 +1439,6 @@ isdn_tty_ioctl(struct tty_struct *tty, struct file *file,
1435 return retval; 1439 return retval;
1436 tty_wait_until_sent(tty, 0); 1440 tty_wait_until_sent(tty, 0);
1437 return 0; 1441 return 0;
1438 case TIOCGSOFTCAR:
1439#ifdef ISDN_DEBUG_MODEM_IOCTL
1440 printk(KERN_DEBUG "ttyI%d ioctl TIOCGSOFTCAR\n", info->line);
1441#endif
1442 return put_user(C_CLOCAL(tty) ? 1 : 0, (ulong __user *) arg);
1443 case TIOCSSOFTCAR:
1444#ifdef ISDN_DEBUG_MODEM_IOCTL
1445 printk(KERN_DEBUG "ttyI%d ioctl TIOCSSOFTCAR\n", info->line);
1446#endif
1447 if (get_user(arg, (ulong __user *) arg))
1448 return -EFAULT;
1449 tty->termios->c_cflag =
1450 ((tty->termios->c_cflag & ~CLOCAL) |
1451 (arg ? CLOCAL : 0));
1452 return 0;
1453 case TIOCSERGETLSR: /* Get line status register */ 1442 case TIOCSERGETLSR: /* Get line status register */
1454#ifdef ISDN_DEBUG_MODEM_IOCTL 1443#ifdef ISDN_DEBUG_MODEM_IOCTL
1455 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line); 1444 printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line);
@@ -1472,13 +1461,14 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1472 if (!old_termios) 1461 if (!old_termios)
1473 isdn_tty_change_speed(info); 1462 isdn_tty_change_speed(info);
1474 else { 1463 else {
1475 if (tty->termios->c_cflag == old_termios->c_cflag) 1464 if (tty->termios->c_cflag == old_termios->c_cflag &&
1465 tty->termios->c_ispeed == old_termios->c_ispeed &&
1466 tty->termios->c_ospeed == old_termios->c_ospeed)
1476 return; 1467 return;
1477 isdn_tty_change_speed(info); 1468 isdn_tty_change_speed(info);
1478 if ((old_termios->c_cflag & CRTSCTS) && 1469 if ((old_termios->c_cflag & CRTSCTS) &&
1479 !(tty->termios->c_cflag & CRTSCTS)) { 1470 !(tty->termios->c_cflag & CRTSCTS))
1480 tty->hw_stopped = 0; 1471 tty->hw_stopped = 0;
1481 }
1482 } 1472 }
1483} 1473}
1484 1474
@@ -1718,9 +1708,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
1718 } 1708 }
1719 dev->modempoll--; 1709 dev->modempoll--;
1720 isdn_tty_shutdown(info); 1710 isdn_tty_shutdown(info);
1721 1711 isdn_tty_flush_buffer(tty);
1722 if (tty->driver->flush_buffer)
1723 tty->driver->flush_buffer(tty);
1724 tty_ldisc_flush(tty); 1712 tty_ldisc_flush(tty);
1725 info->tty = NULL; 1713 info->tty = NULL;
1726 info->ncarrier = 0; 1714 info->ncarrier = 0;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index bb3e4b1cb773..83eb78b00137 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -276,6 +276,7 @@ static mddev_t * mddev_find(dev_t unit)
276 init_waitqueue_head(&new->sb_wait); 276 init_waitqueue_head(&new->sb_wait);
277 new->reshape_position = MaxSector; 277 new->reshape_position = MaxSector;
278 new->resync_max = MaxSector; 278 new->resync_max = MaxSector;
279 new->level = LEVEL_NONE;
279 280
280 new->queue = blk_alloc_queue(GFP_KERNEL); 281 new->queue = blk_alloc_queue(GFP_KERNEL);
281 if (!new->queue) { 282 if (!new->queue) {
@@ -1369,6 +1370,11 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1369 MD_BUG(); 1370 MD_BUG();
1370 return -EINVAL; 1371 return -EINVAL;
1371 } 1372 }
1373
1374 /* prevent duplicates */
1375 if (find_rdev(mddev, rdev->bdev->bd_dev))
1376 return -EEXIST;
1377
1372 /* make sure rdev->size exceeds mddev->size */ 1378 /* make sure rdev->size exceeds mddev->size */
1373 if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) { 1379 if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) {
1374 if (mddev->pers) { 1380 if (mddev->pers) {
@@ -1652,6 +1658,8 @@ static void md_update_sb(mddev_t * mddev, int force_change)
1652 int sync_req; 1658 int sync_req;
1653 int nospares = 0; 1659 int nospares = 0;
1654 1660
1661 if (mddev->external)
1662 return;
1655repeat: 1663repeat:
1656 spin_lock_irq(&mddev->write_lock); 1664 spin_lock_irq(&mddev->write_lock);
1657 1665
@@ -1820,6 +1828,10 @@ state_show(mdk_rdev_t *rdev, char *page)
1820 len += sprintf(page+len, "%swrite_mostly",sep); 1828 len += sprintf(page+len, "%swrite_mostly",sep);
1821 sep = ","; 1829 sep = ",";
1822 } 1830 }
1831 if (test_bit(Blocked, &rdev->flags)) {
1832 len += sprintf(page+len, "%sblocked", sep);
1833 sep = ",";
1834 }
1823 if (!test_bit(Faulty, &rdev->flags) && 1835 if (!test_bit(Faulty, &rdev->flags) &&
1824 !test_bit(In_sync, &rdev->flags)) { 1836 !test_bit(In_sync, &rdev->flags)) {
1825 len += sprintf(page+len, "%sspare", sep); 1837 len += sprintf(page+len, "%sspare", sep);
@@ -1836,6 +1848,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1836 * remove - disconnects the device 1848 * remove - disconnects the device
1837 * writemostly - sets write_mostly 1849 * writemostly - sets write_mostly
1838 * -writemostly - clears write_mostly 1850 * -writemostly - clears write_mostly
1851 * blocked - sets the Blocked flag
1852 * -blocked - clears the Blocked flag
1839 */ 1853 */
1840 int err = -EINVAL; 1854 int err = -EINVAL;
1841 if (cmd_match(buf, "faulty") && rdev->mddev->pers) { 1855 if (cmd_match(buf, "faulty") && rdev->mddev->pers) {
@@ -1858,6 +1872,16 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1858 } else if (cmd_match(buf, "-writemostly")) { 1872 } else if (cmd_match(buf, "-writemostly")) {
1859 clear_bit(WriteMostly, &rdev->flags); 1873 clear_bit(WriteMostly, &rdev->flags);
1860 err = 0; 1874 err = 0;
1875 } else if (cmd_match(buf, "blocked")) {
1876 set_bit(Blocked, &rdev->flags);
1877 err = 0;
1878 } else if (cmd_match(buf, "-blocked")) {
1879 clear_bit(Blocked, &rdev->flags);
1880 wake_up(&rdev->blocked_wait);
1881 set_bit(MD_RECOVERY_NEEDED, &rdev->mddev->recovery);
1882 md_wakeup_thread(rdev->mddev->thread);
1883
1884 err = 0;
1861 } 1885 }
1862 return err ? err : len; 1886 return err ? err : len;
1863} 1887}
@@ -2097,7 +2121,7 @@ rdev_attr_store(struct kobject *kobj, struct attribute *attr,
2097 rv = -EBUSY; 2121 rv = -EBUSY;
2098 else 2122 else
2099 rv = entry->store(rdev, page, length); 2123 rv = entry->store(rdev, page, length);
2100 mddev_unlock(rdev->mddev); 2124 mddev_unlock(mddev);
2101 } 2125 }
2102 return rv; 2126 return rv;
2103} 2127}
@@ -2186,7 +2210,9 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
2186 goto abort_free; 2210 goto abort_free;
2187 } 2211 }
2188 } 2212 }
2213
2189 INIT_LIST_HEAD(&rdev->same_set); 2214 INIT_LIST_HEAD(&rdev->same_set);
2215 init_waitqueue_head(&rdev->blocked_wait);
2190 2216
2191 return rdev; 2217 return rdev;
2192 2218
@@ -2457,7 +2483,6 @@ resync_start_show(mddev_t *mddev, char *page)
2457static ssize_t 2483static ssize_t
2458resync_start_store(mddev_t *mddev, const char *buf, size_t len) 2484resync_start_store(mddev_t *mddev, const char *buf, size_t len)
2459{ 2485{
2460 /* can only set chunk_size if array is not yet active */
2461 char *e; 2486 char *e;
2462 unsigned long long n = simple_strtoull(buf, &e, 10); 2487 unsigned long long n = simple_strtoull(buf, &e, 10);
2463 2488
@@ -2591,15 +2616,20 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2591 err = do_md_stop(mddev, 1); 2616 err = do_md_stop(mddev, 1);
2592 else { 2617 else {
2593 mddev->ro = 1; 2618 mddev->ro = 1;
2619 set_disk_ro(mddev->gendisk, 1);
2594 err = do_md_run(mddev); 2620 err = do_md_run(mddev);
2595 } 2621 }
2596 break; 2622 break;
2597 case read_auto: 2623 case read_auto:
2598 /* stopping an active array */
2599 if (mddev->pers) { 2624 if (mddev->pers) {
2600 err = do_md_stop(mddev, 1); 2625 if (mddev->ro != 1)
2601 if (err == 0) 2626 err = do_md_stop(mddev, 1);
2602 mddev->ro = 2; /* FIXME mark devices writable */ 2627 else
2628 err = restart_array(mddev);
2629 if (err == 0) {
2630 mddev->ro = 2;
2631 set_disk_ro(mddev->gendisk, 0);
2632 }
2603 } else { 2633 } else {
2604 mddev->ro = 2; 2634 mddev->ro = 2;
2605 err = do_md_run(mddev); 2635 err = do_md_run(mddev);
@@ -2612,6 +2642,8 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2612 if (atomic_read(&mddev->writes_pending) == 0) { 2642 if (atomic_read(&mddev->writes_pending) == 0) {
2613 if (mddev->in_sync == 0) { 2643 if (mddev->in_sync == 0) {
2614 mddev->in_sync = 1; 2644 mddev->in_sync = 1;
2645 if (mddev->safemode == 1)
2646 mddev->safemode = 0;
2615 if (mddev->persistent) 2647 if (mddev->persistent)
2616 set_bit(MD_CHANGE_CLEAN, 2648 set_bit(MD_CHANGE_CLEAN,
2617 &mddev->flags); 2649 &mddev->flags);
@@ -2635,6 +2667,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
2635 err = 0; 2667 err = 0;
2636 } else { 2668 } else {
2637 mddev->ro = 0; 2669 mddev->ro = 0;
2670 set_disk_ro(mddev->gendisk, 0);
2638 err = do_md_run(mddev); 2671 err = do_md_run(mddev);
2639 } 2672 }
2640 break; 2673 break;
@@ -3712,6 +3745,30 @@ static int do_md_stop(mddev_t * mddev, int mode)
3712 mddev->reshape_position = MaxSector; 3745 mddev->reshape_position = MaxSector;
3713 mddev->external = 0; 3746 mddev->external = 0;
3714 mddev->persistent = 0; 3747 mddev->persistent = 0;
3748 mddev->level = LEVEL_NONE;
3749 mddev->clevel[0] = 0;
3750 mddev->flags = 0;
3751 mddev->ro = 0;
3752 mddev->metadata_type[0] = 0;
3753 mddev->chunk_size = 0;
3754 mddev->ctime = mddev->utime = 0;
3755 mddev->layout = 0;
3756 mddev->max_disks = 0;
3757 mddev->events = 0;
3758 mddev->delta_disks = 0;
3759 mddev->new_level = LEVEL_NONE;
3760 mddev->new_layout = 0;
3761 mddev->new_chunk = 0;
3762 mddev->curr_resync = 0;
3763 mddev->resync_mismatches = 0;
3764 mddev->suspend_lo = mddev->suspend_hi = 0;
3765 mddev->sync_speed_min = mddev->sync_speed_max = 0;
3766 mddev->recovery = 0;
3767 mddev->in_sync = 0;
3768 mddev->changed = 0;
3769 mddev->degraded = 0;
3770 mddev->barriers_work = 0;
3771 mddev->safemode = 0;
3715 3772
3716 } else if (mddev->pers) 3773 } else if (mddev->pers)
3717 printk(KERN_INFO "md: %s switched to read-only mode.\n", 3774 printk(KERN_INFO "md: %s switched to read-only mode.\n",
@@ -4919,6 +4976,9 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
4919 4976
4920 if (!rdev || test_bit(Faulty, &rdev->flags)) 4977 if (!rdev || test_bit(Faulty, &rdev->flags))
4921 return; 4978 return;
4979
4980 if (mddev->external)
4981 set_bit(Blocked, &rdev->flags);
4922/* 4982/*
4923 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n", 4983 dprintk("md_error dev:%s, rdev:(%d:%d), (caller: %p,%p,%p,%p).\n",
4924 mdname(mddev), 4984 mdname(mddev),
@@ -5365,6 +5425,8 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
5365 md_wakeup_thread(mddev->sync_thread); 5425 md_wakeup_thread(mddev->sync_thread);
5366 } 5426 }
5367 atomic_inc(&mddev->writes_pending); 5427 atomic_inc(&mddev->writes_pending);
5428 if (mddev->safemode == 1)
5429 mddev->safemode = 0;
5368 if (mddev->in_sync) { 5430 if (mddev->in_sync) {
5369 spin_lock_irq(&mddev->write_lock); 5431 spin_lock_irq(&mddev->write_lock);
5370 if (mddev->in_sync) { 5432 if (mddev->in_sync) {
@@ -5719,7 +5781,7 @@ static int remove_and_add_spares(mddev_t *mddev)
5719 5781
5720 rdev_for_each(rdev, rtmp, mddev) 5782 rdev_for_each(rdev, rtmp, mddev)
5721 if (rdev->raid_disk >= 0 && 5783 if (rdev->raid_disk >= 0 &&
5722 !mddev->external && 5784 !test_bit(Blocked, &rdev->flags) &&
5723 (test_bit(Faulty, &rdev->flags) || 5785 (test_bit(Faulty, &rdev->flags) ||
5724 ! test_bit(In_sync, &rdev->flags)) && 5786 ! test_bit(In_sync, &rdev->flags)) &&
5725 atomic_read(&rdev->nr_pending)==0) { 5787 atomic_read(&rdev->nr_pending)==0) {
@@ -5789,7 +5851,7 @@ void md_check_recovery(mddev_t *mddev)
5789 return; 5851 return;
5790 5852
5791 if (signal_pending(current)) { 5853 if (signal_pending(current)) {
5792 if (mddev->pers->sync_request) { 5854 if (mddev->pers->sync_request && !mddev->external) {
5793 printk(KERN_INFO "md: %s in immediate safe mode\n", 5855 printk(KERN_INFO "md: %s in immediate safe mode\n",
5794 mdname(mddev)); 5856 mdname(mddev));
5795 mddev->safemode = 2; 5857 mddev->safemode = 2;
@@ -5801,7 +5863,7 @@ void md_check_recovery(mddev_t *mddev)
5801 (mddev->flags && !mddev->external) || 5863 (mddev->flags && !mddev->external) ||
5802 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || 5864 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
5803 test_bit(MD_RECOVERY_DONE, &mddev->recovery) || 5865 test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
5804 (mddev->safemode == 1) || 5866 (mddev->external == 0 && mddev->safemode == 1) ||
5805 (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending) 5867 (mddev->safemode == 2 && ! atomic_read(&mddev->writes_pending)
5806 && !mddev->in_sync && mddev->recovery_cp == MaxSector) 5868 && !mddev->in_sync && mddev->recovery_cp == MaxSector)
5807 )) 5869 ))
@@ -5810,16 +5872,20 @@ void md_check_recovery(mddev_t *mddev)
5810 if (mddev_trylock(mddev)) { 5872 if (mddev_trylock(mddev)) {
5811 int spares = 0; 5873 int spares = 0;
5812 5874
5813 spin_lock_irq(&mddev->write_lock); 5875 if (!mddev->external) {
5814 if (mddev->safemode && !atomic_read(&mddev->writes_pending) && 5876 spin_lock_irq(&mddev->write_lock);
5815 !mddev->in_sync && mddev->recovery_cp == MaxSector) { 5877 if (mddev->safemode &&
5816 mddev->in_sync = 1; 5878 !atomic_read(&mddev->writes_pending) &&
5817 if (mddev->persistent) 5879 !mddev->in_sync &&
5818 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 5880 mddev->recovery_cp == MaxSector) {
5881 mddev->in_sync = 1;
5882 if (mddev->persistent)
5883 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
5884 }
5885 if (mddev->safemode == 1)
5886 mddev->safemode = 0;
5887 spin_unlock_irq(&mddev->write_lock);
5819 } 5888 }
5820 if (mddev->safemode == 1)
5821 mddev->safemode = 0;
5822 spin_unlock_irq(&mddev->write_lock);
5823 5889
5824 if (mddev->flags) 5890 if (mddev->flags)
5825 md_update_sb(mddev, 0); 5891 md_update_sb(mddev, 0);
@@ -5914,6 +5980,16 @@ void md_check_recovery(mddev_t *mddev)
5914 } 5980 }
5915} 5981}
5916 5982
5983void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
5984{
5985 sysfs_notify(&rdev->kobj, NULL, "state");
5986 wait_event_timeout(rdev->blocked_wait,
5987 !test_bit(Blocked, &rdev->flags),
5988 msecs_to_jiffies(5000));
5989 rdev_dec_pending(rdev, mddev);
5990}
5991EXPORT_SYMBOL(md_wait_for_blocked_rdev);
5992
5917static int md_notify_reboot(struct notifier_block *this, 5993static int md_notify_reboot(struct notifier_block *this,
5918 unsigned long code, void *x) 5994 unsigned long code, void *x)
5919{ 5995{
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9fd473a6dbf5..6778b7cb39bd 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -773,7 +773,6 @@ static int make_request(struct request_queue *q, struct bio * bio)
773 r1bio_t *r1_bio; 773 r1bio_t *r1_bio;
774 struct bio *read_bio; 774 struct bio *read_bio;
775 int i, targets = 0, disks; 775 int i, targets = 0, disks;
776 mdk_rdev_t *rdev;
777 struct bitmap *bitmap = mddev->bitmap; 776 struct bitmap *bitmap = mddev->bitmap;
778 unsigned long flags; 777 unsigned long flags;
779 struct bio_list bl; 778 struct bio_list bl;
@@ -781,6 +780,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
781 const int rw = bio_data_dir(bio); 780 const int rw = bio_data_dir(bio);
782 const int do_sync = bio_sync(bio); 781 const int do_sync = bio_sync(bio);
783 int do_barriers; 782 int do_barriers;
783 mdk_rdev_t *blocked_rdev;
784 784
785 /* 785 /*
786 * Register the new request and wait if the reconstruction 786 * Register the new request and wait if the reconstruction
@@ -862,10 +862,17 @@ static int make_request(struct request_queue *q, struct bio * bio)
862 first = 0; 862 first = 0;
863 } 863 }
864#endif 864#endif
865 retry_write:
866 blocked_rdev = NULL;
865 rcu_read_lock(); 867 rcu_read_lock();
866 for (i = 0; i < disks; i++) { 868 for (i = 0; i < disks; i++) {
867 if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL && 869 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
868 !test_bit(Faulty, &rdev->flags)) { 870 if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
871 atomic_inc(&rdev->nr_pending);
872 blocked_rdev = rdev;
873 break;
874 }
875 if (rdev && !test_bit(Faulty, &rdev->flags)) {
869 atomic_inc(&rdev->nr_pending); 876 atomic_inc(&rdev->nr_pending);
870 if (test_bit(Faulty, &rdev->flags)) { 877 if (test_bit(Faulty, &rdev->flags)) {
871 rdev_dec_pending(rdev, mddev); 878 rdev_dec_pending(rdev, mddev);
@@ -878,6 +885,20 @@ static int make_request(struct request_queue *q, struct bio * bio)
878 } 885 }
879 rcu_read_unlock(); 886 rcu_read_unlock();
880 887
888 if (unlikely(blocked_rdev)) {
889 /* Wait for this device to become unblocked */
890 int j;
891
892 for (j = 0; j < i; j++)
893 if (r1_bio->bios[j])
894 rdev_dec_pending(conf->mirrors[j].rdev, mddev);
895
896 allow_barrier(conf);
897 md_wait_for_blocked_rdev(blocked_rdev, mddev);
898 wait_barrier(conf);
899 goto retry_write;
900 }
901
881 BUG_ON(targets == 0); /* we never fail the last device */ 902 BUG_ON(targets == 0); /* we never fail the last device */
882 903
883 if (targets < conf->raid_disks) { 904 if (targets < conf->raid_disks) {
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1e96aa3ff513..5938fa962922 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -790,6 +790,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
790 const int do_sync = bio_sync(bio); 790 const int do_sync = bio_sync(bio);
791 struct bio_list bl; 791 struct bio_list bl;
792 unsigned long flags; 792 unsigned long flags;
793 mdk_rdev_t *blocked_rdev;
793 794
794 if (unlikely(bio_barrier(bio))) { 795 if (unlikely(bio_barrier(bio))) {
795 bio_endio(bio, -EOPNOTSUPP); 796 bio_endio(bio, -EOPNOTSUPP);
@@ -879,17 +880,23 @@ static int make_request(struct request_queue *q, struct bio * bio)
879 /* 880 /*
880 * WRITE: 881 * WRITE:
881 */ 882 */
882 /* first select target devices under spinlock and 883 /* first select target devices under rcu_lock and
883 * inc refcount on their rdev. Record them by setting 884 * inc refcount on their rdev. Record them by setting
884 * bios[x] to bio 885 * bios[x] to bio
885 */ 886 */
886 raid10_find_phys(conf, r10_bio); 887 raid10_find_phys(conf, r10_bio);
888 retry_write:
889 blocked_rdev = 0;
887 rcu_read_lock(); 890 rcu_read_lock();
888 for (i = 0; i < conf->copies; i++) { 891 for (i = 0; i < conf->copies; i++) {
889 int d = r10_bio->devs[i].devnum; 892 int d = r10_bio->devs[i].devnum;
890 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev); 893 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev);
891 if (rdev && 894 if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
892 !test_bit(Faulty, &rdev->flags)) { 895 atomic_inc(&rdev->nr_pending);
896 blocked_rdev = rdev;
897 break;
898 }
899 if (rdev && !test_bit(Faulty, &rdev->flags)) {
893 atomic_inc(&rdev->nr_pending); 900 atomic_inc(&rdev->nr_pending);
894 r10_bio->devs[i].bio = bio; 901 r10_bio->devs[i].bio = bio;
895 } else { 902 } else {
@@ -899,6 +906,22 @@ static int make_request(struct request_queue *q, struct bio * bio)
899 } 906 }
900 rcu_read_unlock(); 907 rcu_read_unlock();
901 908
909 if (unlikely(blocked_rdev)) {
910 /* Have to wait for this device to get unblocked, then retry */
911 int j;
912 int d;
913
914 for (j = 0; j < i; j++)
915 if (r10_bio->devs[j].bio) {
916 d = r10_bio->devs[j].devnum;
917 rdev_dec_pending(conf->mirrors[d].rdev, mddev);
918 }
919 allow_barrier(conf);
920 md_wait_for_blocked_rdev(blocked_rdev, mddev);
921 wait_barrier(conf);
922 goto retry_write;
923 }
924
902 atomic_set(&r10_bio->remaining, 0); 925 atomic_set(&r10_bio->remaining, 0);
903 926
904 bio_list_init(&bl); 927 bio_list_init(&bl);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 968dacaced6d..087eee0cb809 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2607,6 +2607,7 @@ static void handle_stripe_expansion(raid5_conf_t *conf, struct stripe_head *sh,
2607 } 2607 }
2608} 2608}
2609 2609
2610
2610/* 2611/*
2611 * handle_stripe - do things to a stripe. 2612 * handle_stripe - do things to a stripe.
2612 * 2613 *
@@ -2632,6 +2633,7 @@ static void handle_stripe5(struct stripe_head *sh)
2632 struct stripe_head_state s; 2633 struct stripe_head_state s;
2633 struct r5dev *dev; 2634 struct r5dev *dev;
2634 unsigned long pending = 0; 2635 unsigned long pending = 0;
2636 mdk_rdev_t *blocked_rdev = NULL;
2635 2637
2636 memset(&s, 0, sizeof(s)); 2638 memset(&s, 0, sizeof(s));
2637 pr_debug("handling stripe %llu, state=%#lx cnt=%d, pd_idx=%d " 2639 pr_debug("handling stripe %llu, state=%#lx cnt=%d, pd_idx=%d "
@@ -2691,6 +2693,11 @@ static void handle_stripe5(struct stripe_head *sh)
2691 if (dev->written) 2693 if (dev->written)
2692 s.written++; 2694 s.written++;
2693 rdev = rcu_dereference(conf->disks[i].rdev); 2695 rdev = rcu_dereference(conf->disks[i].rdev);
2696 if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
2697 blocked_rdev = rdev;
2698 atomic_inc(&rdev->nr_pending);
2699 break;
2700 }
2694 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 2701 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
2695 /* The ReadError flag will just be confusing now */ 2702 /* The ReadError flag will just be confusing now */
2696 clear_bit(R5_ReadError, &dev->flags); 2703 clear_bit(R5_ReadError, &dev->flags);
@@ -2705,6 +2712,11 @@ static void handle_stripe5(struct stripe_head *sh)
2705 } 2712 }
2706 rcu_read_unlock(); 2713 rcu_read_unlock();
2707 2714
2715 if (unlikely(blocked_rdev)) {
2716 set_bit(STRIPE_HANDLE, &sh->state);
2717 goto unlock;
2718 }
2719
2708 if (s.to_fill && !test_and_set_bit(STRIPE_OP_BIOFILL, &sh->ops.pending)) 2720 if (s.to_fill && !test_and_set_bit(STRIPE_OP_BIOFILL, &sh->ops.pending))
2709 sh->ops.count++; 2721 sh->ops.count++;
2710 2722
@@ -2894,8 +2906,13 @@ static void handle_stripe5(struct stripe_head *sh)
2894 if (sh->ops.count) 2906 if (sh->ops.count)
2895 pending = get_stripe_work(sh); 2907 pending = get_stripe_work(sh);
2896 2908
2909 unlock:
2897 spin_unlock(&sh->lock); 2910 spin_unlock(&sh->lock);
2898 2911
2912 /* wait for this device to become unblocked */
2913 if (unlikely(blocked_rdev))
2914 md_wait_for_blocked_rdev(blocked_rdev, conf->mddev);
2915
2899 if (pending) 2916 if (pending)
2900 raid5_run_ops(sh, pending); 2917 raid5_run_ops(sh, pending);
2901 2918
@@ -2912,6 +2929,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2912 struct stripe_head_state s; 2929 struct stripe_head_state s;
2913 struct r6_state r6s; 2930 struct r6_state r6s;
2914 struct r5dev *dev, *pdev, *qdev; 2931 struct r5dev *dev, *pdev, *qdev;
2932 mdk_rdev_t *blocked_rdev = NULL;
2915 2933
2916 r6s.qd_idx = raid6_next_disk(pd_idx, disks); 2934 r6s.qd_idx = raid6_next_disk(pd_idx, disks);
2917 pr_debug("handling stripe %llu, state=%#lx cnt=%d, " 2935 pr_debug("handling stripe %llu, state=%#lx cnt=%d, "
@@ -2975,6 +2993,11 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2975 if (dev->written) 2993 if (dev->written)
2976 s.written++; 2994 s.written++;
2977 rdev = rcu_dereference(conf->disks[i].rdev); 2995 rdev = rcu_dereference(conf->disks[i].rdev);
2996 if (rdev && unlikely(test_bit(Blocked, &rdev->flags))) {
2997 blocked_rdev = rdev;
2998 atomic_inc(&rdev->nr_pending);
2999 break;
3000 }
2978 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 3001 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
2979 /* The ReadError flag will just be confusing now */ 3002 /* The ReadError flag will just be confusing now */
2980 clear_bit(R5_ReadError, &dev->flags); 3003 clear_bit(R5_ReadError, &dev->flags);
@@ -2989,6 +3012,11 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
2989 set_bit(R5_Insync, &dev->flags); 3012 set_bit(R5_Insync, &dev->flags);
2990 } 3013 }
2991 rcu_read_unlock(); 3014 rcu_read_unlock();
3015
3016 if (unlikely(blocked_rdev)) {
3017 set_bit(STRIPE_HANDLE, &sh->state);
3018 goto unlock;
3019 }
2992 pr_debug("locked=%d uptodate=%d to_read=%d" 3020 pr_debug("locked=%d uptodate=%d to_read=%d"
2993 " to_write=%d failed=%d failed_num=%d,%d\n", 3021 " to_write=%d failed=%d failed_num=%d,%d\n",
2994 s.locked, s.uptodate, s.to_read, s.to_write, s.failed, 3022 s.locked, s.uptodate, s.to_read, s.to_write, s.failed,
@@ -3094,8 +3122,13 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
3094 !test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending)) 3122 !test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending))
3095 handle_stripe_expansion(conf, sh, &r6s); 3123 handle_stripe_expansion(conf, sh, &r6s);
3096 3124
3125 unlock:
3097 spin_unlock(&sh->lock); 3126 spin_unlock(&sh->lock);
3098 3127
3128 /* wait for this device to become unblocked */
3129 if (unlikely(blocked_rdev))
3130 md_wait_for_blocked_rdev(blocked_rdev, conf->mddev);
3131
3099 return_io(return_bi); 3132 return_io(return_bi);
3100 3133
3101 for (i=disks; i-- ;) { 3134 for (i=disks; i-- ;) {
diff --git a/drivers/media/common/Makefile b/drivers/media/common/Makefile
index 8e7448230643..351b98b9b302 100644
--- a/drivers/media/common/Makefile
+++ b/drivers/media/common/Makefile
@@ -2,6 +2,7 @@ saa7146-objs := saa7146_i2c.o saa7146_core.o
2saa7146_vv-objs := saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o 2saa7146_vv-objs := saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o
3ir-common-objs := ir-functions.o ir-keymaps.o 3ir-common-objs := ir-functions.o ir-keymaps.o
4 4
5obj-y += tuners/
5obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o 6obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
6obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o 7obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o
7obj-$(CONFIG_VIDEO_IR) += ir-common.o 8obj-$(CONFIG_VIDEO_IR) += ir-common.o
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 03816b73f847..27da7b423275 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -81,8 +81,6 @@
81/* Limits scaled width, which must be a multiple of 4. */ 81/* Limits scaled width, which must be a multiple of 4. */
82#define MAX_HACTIVE (0x3FF & -4) 82#define MAX_HACTIVE (0x3FF & -4)
83 83
84#define clamp(x, low, high) min (max (low, x), high)
85
86#define BTTV_NORMS (\ 84#define BTTV_NORMS (\
87 V4L2_STD_PAL | V4L2_STD_PAL_N | \ 85 V4L2_STD_PAL | V4L2_STD_PAL_N | \
88 V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \ 86 V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 64819353276a..17f542dfb366 100644
--- a/drivers/media/video/usbvideo/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -70,12 +70,6 @@
70 70
71#define VICAM_HEADER_SIZE 64 71#define VICAM_HEADER_SIZE 64
72 72
73#define clamp( x, l, h ) max_t( __typeof__( x ), \
74 ( l ), \
75 min_t( __typeof__( x ), \
76 ( h ), \
77 ( x ) ) )
78
79/* Not sure what all the bytes in these char 73/* Not sure what all the bytes in these char
80 * arrays do, but they're necessary to make 74 * arrays do, but they're necessary to make
81 * the camera work. 75 * the camera work.
diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
index f6f2d960cadb..ef8a492766a7 100644
--- a/drivers/mfd/asic3.c
+++ b/drivers/mfd/asic3.c
@@ -132,7 +132,7 @@ static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc)
132 132
133 if (iter >= MAX_ASIC_ISR_LOOPS) 133 if (iter >= MAX_ASIC_ISR_LOOPS)
134 printk(KERN_ERR "%s: interrupt processing overrun\n", 134 printk(KERN_ERR "%s: interrupt processing overrun\n",
135 __FUNCTION__); 135 __func__);
136} 136}
137 137
138static inline int asic3_irq_to_bank(struct asic3 *asic, int irq) 138static inline int asic3_irq_to_bank(struct asic3 *asic, int irq)
@@ -409,7 +409,7 @@ int asic3_gpio_get_value(struct asic3 *asic, unsigned gpio)
409 return asic3_get_gpio_d(asic, Status) & mask; 409 return asic3_get_gpio_d(asic, Status) & mask;
410 default: 410 default:
411 printk(KERN_ERR "%s: invalid GPIO value 0x%x", 411 printk(KERN_ERR "%s: invalid GPIO value 0x%x",
412 __FUNCTION__, gpio); 412 __func__, gpio);
413 return -EINVAL; 413 return -EINVAL;
414 } 414 }
415} 415}
@@ -437,7 +437,7 @@ void asic3_gpio_set_value(struct asic3 *asic, unsigned gpio, int val)
437 return; 437 return;
438 default: 438 default:
439 printk(KERN_ERR "%s: invalid GPIO value 0x%x", 439 printk(KERN_ERR "%s: invalid GPIO value 0x%x",
440 __FUNCTION__, gpio); 440 __func__, gpio);
441 return; 441 return;
442 } 442 }
443} 443}
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 6e655b4c6682..2fe64734d8af 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -349,11 +349,11 @@ int sm501_unit_power(struct device *dev, unsigned int unit, unsigned int to)
349 mode &= 3; /* get current power mode */ 349 mode &= 3; /* get current power mode */
350 350
351 if (unit >= ARRAY_SIZE(sm->unit_power)) { 351 if (unit >= ARRAY_SIZE(sm->unit_power)) {
352 dev_err(dev, "%s: bad unit %d\n", __FUNCTION__, unit); 352 dev_err(dev, "%s: bad unit %d\n", __func__, unit);
353 goto already; 353 goto already;
354 } 354 }
355 355
356 dev_dbg(sm->dev, "%s: unit %d, cur %d, to %d\n", __FUNCTION__, unit, 356 dev_dbg(sm->dev, "%s: unit %d, cur %d, to %d\n", __func__, unit,
357 sm->unit_power[unit], to); 357 sm->unit_power[unit], to);
358 358
359 if (to == 0 && sm->unit_power[unit] == 0) { 359 if (to == 0 && sm->unit_power[unit] == 0) {
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 6d6286c4eeac..30a1af857c7a 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -132,7 +132,7 @@ static int send_ack;
132static int final_ack; 132static int final_ack;
133static int hw_break_val; 133static int hw_break_val;
134static int hw_break_val2; 134static int hw_break_val2;
135#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) 135#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_SPARC)
136static int arch_needs_sstep_emulation = 1; 136static int arch_needs_sstep_emulation = 1;
137#else 137#else
138static int arch_needs_sstep_emulation; 138static int arch_needs_sstep_emulation;
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 9c6573419f5a..fdfb2b2cb734 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -670,7 +670,7 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
670 memcpy(adapter->current_dma.target, adapter->dma_buffer, adapter->current_dma.length); 670 memcpy(adapter->current_dma.target, adapter->dma_buffer, adapter->current_dma.length);
671 } 671 }
672 skb->protocol = eth_type_trans(skb,dev); 672 skb->protocol = eth_type_trans(skb,dev);
673 adapter->stats.rx_bytes += skb->len; 673 dev->stats.rx_bytes += skb->len;
674 netif_rx(skb); 674 netif_rx(skb);
675 dev->last_rx = jiffies; 675 dev->last_rx = jiffies;
676 } 676 }
@@ -773,12 +773,12 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
773 * received board statistics 773 * received board statistics
774 */ 774 */
775 case CMD_NETWORK_STATISTICS_RESPONSE: 775 case CMD_NETWORK_STATISTICS_RESPONSE:
776 adapter->stats.rx_packets += adapter->irx_pcb.data.netstat.tot_recv; 776 dev->stats.rx_packets += adapter->irx_pcb.data.netstat.tot_recv;
777 adapter->stats.tx_packets += adapter->irx_pcb.data.netstat.tot_xmit; 777 dev->stats.tx_packets += adapter->irx_pcb.data.netstat.tot_xmit;
778 adapter->stats.rx_crc_errors += adapter->irx_pcb.data.netstat.err_CRC; 778 dev->stats.rx_crc_errors += adapter->irx_pcb.data.netstat.err_CRC;
779 adapter->stats.rx_frame_errors += adapter->irx_pcb.data.netstat.err_align; 779 dev->stats.rx_frame_errors += adapter->irx_pcb.data.netstat.err_align;
780 adapter->stats.rx_fifo_errors += adapter->irx_pcb.data.netstat.err_ovrrun; 780 dev->stats.rx_fifo_errors += adapter->irx_pcb.data.netstat.err_ovrrun;
781 adapter->stats.rx_over_errors += adapter->irx_pcb.data.netstat.err_res; 781 dev->stats.rx_over_errors += adapter->irx_pcb.data.netstat.err_res;
782 adapter->got[CMD_NETWORK_STATISTICS] = 1; 782 adapter->got[CMD_NETWORK_STATISTICS] = 1;
783 if (elp_debug >= 3) 783 if (elp_debug >= 3)
784 printk(KERN_DEBUG "%s: interrupt - statistics response received\n", dev->name); 784 printk(KERN_DEBUG "%s: interrupt - statistics response received\n", dev->name);
@@ -794,11 +794,11 @@ static irqreturn_t elp_interrupt(int irq, void *dev_id)
794 break; 794 break;
795 switch (adapter->irx_pcb.data.xmit_resp.c_stat) { 795 switch (adapter->irx_pcb.data.xmit_resp.c_stat) {
796 case 0xffff: 796 case 0xffff:
797 adapter->stats.tx_aborted_errors++; 797 dev->stats.tx_aborted_errors++;
798 printk(KERN_INFO "%s: transmit timed out, network cable problem?\n", dev->name); 798 printk(KERN_INFO "%s: transmit timed out, network cable problem?\n", dev->name);
799 break; 799 break;
800 case 0xfffe: 800 case 0xfffe:
801 adapter->stats.tx_fifo_errors++; 801 dev->stats.tx_fifo_errors++;
802 printk(KERN_INFO "%s: transmit timed out, FIFO underrun\n", dev->name); 802 printk(KERN_INFO "%s: transmit timed out, FIFO underrun\n", dev->name);
803 break; 803 break;
804 } 804 }
@@ -986,7 +986,7 @@ static bool send_packet(struct net_device *dev, struct sk_buff *skb)
986 return false; 986 return false;
987 } 987 }
988 988
989 adapter->stats.tx_bytes += nlen; 989 dev->stats.tx_bytes += nlen;
990 990
991 /* 991 /*
992 * send the adapter a transmit packet command. Ignore segment and offset 992 * send the adapter a transmit packet command. Ignore segment and offset
@@ -1041,7 +1041,6 @@ static bool send_packet(struct net_device *dev, struct sk_buff *skb)
1041 1041
1042static void elp_timeout(struct net_device *dev) 1042static void elp_timeout(struct net_device *dev)
1043{ 1043{
1044 elp_device *adapter = dev->priv;
1045 int stat; 1044 int stat;
1046 1045
1047 stat = inb_status(dev->base_addr); 1046 stat = inb_status(dev->base_addr);
@@ -1049,7 +1048,7 @@ static void elp_timeout(struct net_device *dev)
1049 if (elp_debug >= 1) 1048 if (elp_debug >= 1)
1050 printk(KERN_DEBUG "%s: status %#02x\n", dev->name, stat); 1049 printk(KERN_DEBUG "%s: status %#02x\n", dev->name, stat);
1051 dev->trans_start = jiffies; 1050 dev->trans_start = jiffies;
1052 adapter->stats.tx_dropped++; 1051 dev->stats.tx_dropped++;
1053 netif_wake_queue(dev); 1052 netif_wake_queue(dev);
1054} 1053}
1055 1054
@@ -1113,7 +1112,7 @@ static struct net_device_stats *elp_get_stats(struct net_device *dev)
1113 /* If the device is closed, just return the latest stats we have, 1112 /* If the device is closed, just return the latest stats we have,
1114 - we cannot ask from the adapter without interrupts */ 1113 - we cannot ask from the adapter without interrupts */
1115 if (!netif_running(dev)) 1114 if (!netif_running(dev))
1116 return &adapter->stats; 1115 return &dev->stats;
1117 1116
1118 /* send a get statistics command to the board */ 1117 /* send a get statistics command to the board */
1119 adapter->tx_pcb.command = CMD_NETWORK_STATISTICS; 1118 adapter->tx_pcb.command = CMD_NETWORK_STATISTICS;
@@ -1126,12 +1125,12 @@ static struct net_device_stats *elp_get_stats(struct net_device *dev)
1126 while (adapter->got[CMD_NETWORK_STATISTICS] == 0 && time_before(jiffies, timeout)); 1125 while (adapter->got[CMD_NETWORK_STATISTICS] == 0 && time_before(jiffies, timeout));
1127 if (time_after_eq(jiffies, timeout)) { 1126 if (time_after_eq(jiffies, timeout)) {
1128 TIMEOUT_MSG(__LINE__); 1127 TIMEOUT_MSG(__LINE__);
1129 return &adapter->stats; 1128 return &dev->stats;
1130 } 1129 }
1131 } 1130 }
1132 1131
1133 /* statistics are now up to date */ 1132 /* statistics are now up to date */
1134 return &adapter->stats; 1133 return &dev->stats;
1135} 1134}
1136 1135
1137 1136
@@ -1571,7 +1570,6 @@ static int __init elplus_setup(struct net_device *dev)
1571 dev->set_multicast_list = elp_set_mc_list; /* local */ 1570 dev->set_multicast_list = elp_set_mc_list; /* local */
1572 dev->ethtool_ops = &netdev_ethtool_ops; /* local */ 1571 dev->ethtool_ops = &netdev_ethtool_ops; /* local */
1573 1572
1574 memset(&(adapter->stats), 0, sizeof(struct net_device_stats));
1575 dev->mem_start = dev->mem_end = 0; 1573 dev->mem_start = dev->mem_end = 0;
1576 1574
1577 err = register_netdev(dev); 1575 err = register_netdev(dev);
diff --git a/drivers/net/3c505.h b/drivers/net/3c505.h
index 1910cb1dc787..04df2a9002b6 100644
--- a/drivers/net/3c505.h
+++ b/drivers/net/3c505.h
@@ -264,7 +264,6 @@ typedef struct {
264 pcb_struct rx_pcb; /* PCB for foreground receiving */ 264 pcb_struct rx_pcb; /* PCB for foreground receiving */
265 pcb_struct itx_pcb; /* PCB for background sending */ 265 pcb_struct itx_pcb; /* PCB for background sending */
266 pcb_struct irx_pcb; /* PCB for background receiving */ 266 pcb_struct irx_pcb; /* PCB for background receiving */
267 struct net_device_stats stats;
268 267
269 void *dma_buffer; 268 void *dma_buffer;
270 269
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 54dac0696d91..e6c545fe5f58 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -167,7 +167,6 @@ enum RxFilter {
167enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA }; 167enum el3_cardtype { EL3_ISA, EL3_PNP, EL3_MCA, EL3_EISA };
168 168
169struct el3_private { 169struct el3_private {
170 struct net_device_stats stats;
171 spinlock_t lock; 170 spinlock_t lock;
172 /* skb send-queue */ 171 /* skb send-queue */
173 int head, size; 172 int head, size;
@@ -794,7 +793,6 @@ el3_open(struct net_device *dev)
794static void 793static void
795el3_tx_timeout (struct net_device *dev) 794el3_tx_timeout (struct net_device *dev)
796{ 795{
797 struct el3_private *lp = netdev_priv(dev);
798 int ioaddr = dev->base_addr; 796 int ioaddr = dev->base_addr;
799 797
800 /* Transmitter timeout, serious problems. */ 798 /* Transmitter timeout, serious problems. */
@@ -802,7 +800,7 @@ el3_tx_timeout (struct net_device *dev)
802 "Tx FIFO room %d.\n", 800 "Tx FIFO room %d.\n",
803 dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS), 801 dev->name, inb(ioaddr + TX_STATUS), inw(ioaddr + EL3_STATUS),
804 inw(ioaddr + TX_FREE)); 802 inw(ioaddr + TX_FREE));
805 lp->stats.tx_errors++; 803 dev->stats.tx_errors++;
806 dev->trans_start = jiffies; 804 dev->trans_start = jiffies;
807 /* Issue TX_RESET and TX_START commands. */ 805 /* Issue TX_RESET and TX_START commands. */
808 outw(TxReset, ioaddr + EL3_CMD); 806 outw(TxReset, ioaddr + EL3_CMD);
@@ -820,7 +818,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
820 818
821 netif_stop_queue (dev); 819 netif_stop_queue (dev);
822 820
823 lp->stats.tx_bytes += skb->len; 821 dev->stats.tx_bytes += skb->len;
824 822
825 if (el3_debug > 4) { 823 if (el3_debug > 4) {
826 printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n", 824 printk(KERN_DEBUG "%s: el3_start_xmit(length = %u) called, status %4.4x.\n",
@@ -881,7 +879,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev)
881 int i = 4; 879 int i = 4;
882 880
883 while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { 881 while (--i > 0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
884 if (tx_status & 0x38) lp->stats.tx_aborted_errors++; 882 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
885 if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); 883 if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
886 if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); 884 if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
887 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ 885 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
@@ -931,12 +929,11 @@ el3_interrupt(int irq, void *dev_id)
931 outw(AckIntr | RxEarly, ioaddr + EL3_CMD); 929 outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
932 } 930 }
933 if (status & TxComplete) { /* Really Tx error. */ 931 if (status & TxComplete) { /* Really Tx error. */
934 struct el3_private *lp = netdev_priv(dev);
935 short tx_status; 932 short tx_status;
936 int i = 4; 933 int i = 4;
937 934
938 while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) { 935 while (--i>0 && (tx_status = inb(ioaddr + TX_STATUS)) > 0) {
939 if (tx_status & 0x38) lp->stats.tx_aborted_errors++; 936 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
940 if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD); 937 if (tx_status & 0x30) outw(TxReset, ioaddr + EL3_CMD);
941 if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD); 938 if (tx_status & 0x3C) outw(TxEnable, ioaddr + EL3_CMD);
942 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ 939 outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
@@ -1002,7 +999,7 @@ el3_get_stats(struct net_device *dev)
1002 spin_lock_irqsave(&lp->lock, flags); 999 spin_lock_irqsave(&lp->lock, flags);
1003 update_stats(dev); 1000 update_stats(dev);
1004 spin_unlock_irqrestore(&lp->lock, flags); 1001 spin_unlock_irqrestore(&lp->lock, flags);
1005 return &lp->stats; 1002 return &dev->stats;
1006} 1003}
1007 1004
1008/* Update statistics. We change to register window 6, so this should be run 1005/* Update statistics. We change to register window 6, so this should be run
@@ -1012,7 +1009,6 @@ el3_get_stats(struct net_device *dev)
1012 */ 1009 */
1013static void update_stats(struct net_device *dev) 1010static void update_stats(struct net_device *dev)
1014{ 1011{
1015 struct el3_private *lp = netdev_priv(dev);
1016 int ioaddr = dev->base_addr; 1012 int ioaddr = dev->base_addr;
1017 1013
1018 if (el3_debug > 5) 1014 if (el3_debug > 5)
@@ -1021,13 +1017,13 @@ static void update_stats(struct net_device *dev)
1021 outw(StatsDisable, ioaddr + EL3_CMD); 1017 outw(StatsDisable, ioaddr + EL3_CMD);
1022 /* Switch to the stats window, and read everything. */ 1018 /* Switch to the stats window, and read everything. */
1023 EL3WINDOW(6); 1019 EL3WINDOW(6);
1024 lp->stats.tx_carrier_errors += inb(ioaddr + 0); 1020 dev->stats.tx_carrier_errors += inb(ioaddr + 0);
1025 lp->stats.tx_heartbeat_errors += inb(ioaddr + 1); 1021 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
1026 /* Multiple collisions. */ inb(ioaddr + 2); 1022 /* Multiple collisions. */ inb(ioaddr + 2);
1027 lp->stats.collisions += inb(ioaddr + 3); 1023 dev->stats.collisions += inb(ioaddr + 3);
1028 lp->stats.tx_window_errors += inb(ioaddr + 4); 1024 dev->stats.tx_window_errors += inb(ioaddr + 4);
1029 lp->stats.rx_fifo_errors += inb(ioaddr + 5); 1025 dev->stats.rx_fifo_errors += inb(ioaddr + 5);
1030 lp->stats.tx_packets += inb(ioaddr + 6); 1026 dev->stats.tx_packets += inb(ioaddr + 6);
1031 /* Rx packets */ inb(ioaddr + 7); 1027 /* Rx packets */ inb(ioaddr + 7);
1032 /* Tx deferrals */ inb(ioaddr + 8); 1028 /* Tx deferrals */ inb(ioaddr + 8);
1033 inw(ioaddr + 10); /* Total Rx and Tx octets. */ 1029 inw(ioaddr + 10); /* Total Rx and Tx octets. */
@@ -1042,7 +1038,6 @@ static void update_stats(struct net_device *dev)
1042static int 1038static int
1043el3_rx(struct net_device *dev) 1039el3_rx(struct net_device *dev)
1044{ 1040{
1045 struct el3_private *lp = netdev_priv(dev);
1046 int ioaddr = dev->base_addr; 1041 int ioaddr = dev->base_addr;
1047 short rx_status; 1042 short rx_status;
1048 1043
@@ -1054,21 +1049,21 @@ el3_rx(struct net_device *dev)
1054 short error = rx_status & 0x3800; 1049 short error = rx_status & 0x3800;
1055 1050
1056 outw(RxDiscard, ioaddr + EL3_CMD); 1051 outw(RxDiscard, ioaddr + EL3_CMD);
1057 lp->stats.rx_errors++; 1052 dev->stats.rx_errors++;
1058 switch (error) { 1053 switch (error) {
1059 case 0x0000: lp->stats.rx_over_errors++; break; 1054 case 0x0000: dev->stats.rx_over_errors++; break;
1060 case 0x0800: lp->stats.rx_length_errors++; break; 1055 case 0x0800: dev->stats.rx_length_errors++; break;
1061 case 0x1000: lp->stats.rx_frame_errors++; break; 1056 case 0x1000: dev->stats.rx_frame_errors++; break;
1062 case 0x1800: lp->stats.rx_length_errors++; break; 1057 case 0x1800: dev->stats.rx_length_errors++; break;
1063 case 0x2000: lp->stats.rx_frame_errors++; break; 1058 case 0x2000: dev->stats.rx_frame_errors++; break;
1064 case 0x2800: lp->stats.rx_crc_errors++; break; 1059 case 0x2800: dev->stats.rx_crc_errors++; break;
1065 } 1060 }
1066 } else { 1061 } else {
1067 short pkt_len = rx_status & 0x7ff; 1062 short pkt_len = rx_status & 0x7ff;
1068 struct sk_buff *skb; 1063 struct sk_buff *skb;
1069 1064
1070 skb = dev_alloc_skb(pkt_len+5); 1065 skb = dev_alloc_skb(pkt_len+5);
1071 lp->stats.rx_bytes += pkt_len; 1066 dev->stats.rx_bytes += pkt_len;
1072 if (el3_debug > 4) 1067 if (el3_debug > 4)
1073 printk("Receiving packet size %d status %4.4x.\n", 1068 printk("Receiving packet size %d status %4.4x.\n",
1074 pkt_len, rx_status); 1069 pkt_len, rx_status);
@@ -1083,11 +1078,11 @@ el3_rx(struct net_device *dev)
1083 skb->protocol = eth_type_trans(skb,dev); 1078 skb->protocol = eth_type_trans(skb,dev);
1084 netif_rx(skb); 1079 netif_rx(skb);
1085 dev->last_rx = jiffies; 1080 dev->last_rx = jiffies;
1086 lp->stats.rx_packets++; 1081 dev->stats.rx_packets++;
1087 continue; 1082 continue;
1088 } 1083 }
1089 outw(RxDiscard, ioaddr + EL3_CMD); 1084 outw(RxDiscard, ioaddr + EL3_CMD);
1090 lp->stats.rx_dropped++; 1085 dev->stats.rx_dropped++;
1091 if (el3_debug) 1086 if (el3_debug)
1092 printk("%s: Couldn't allocate a sk_buff of size %d.\n", 1087 printk("%s: Couldn't allocate a sk_buff of size %d.\n",
1093 dev->name, pkt_len); 1088 dev->name, pkt_len);
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index 6ab84b661d70..105a8c7ca7e9 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -310,7 +310,6 @@ struct corkscrew_private {
310 struct sk_buff *tx_skbuff[TX_RING_SIZE]; 310 struct sk_buff *tx_skbuff[TX_RING_SIZE];
311 unsigned int cur_rx, cur_tx; /* The next free ring entry */ 311 unsigned int cur_rx, cur_tx; /* The next free ring entry */
312 unsigned int dirty_rx, dirty_tx;/* The ring entries to be free()ed. */ 312 unsigned int dirty_rx, dirty_tx;/* The ring entries to be free()ed. */
313 struct net_device_stats stats;
314 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */ 313 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */
315 struct timer_list timer; /* Media selection timer. */ 314 struct timer_list timer; /* Media selection timer. */
316 int capabilities ; /* Adapter capabilities word. */ 315 int capabilities ; /* Adapter capabilities word. */
@@ -983,8 +982,8 @@ static void corkscrew_timeout(struct net_device *dev)
983 break; 982 break;
984 outw(TxEnable, ioaddr + EL3_CMD); 983 outw(TxEnable, ioaddr + EL3_CMD);
985 dev->trans_start = jiffies; 984 dev->trans_start = jiffies;
986 vp->stats.tx_errors++; 985 dev->stats.tx_errors++;
987 vp->stats.tx_dropped++; 986 dev->stats.tx_dropped++;
988 netif_wake_queue(dev); 987 netif_wake_queue(dev);
989} 988}
990 989
@@ -1050,7 +1049,7 @@ static int corkscrew_start_xmit(struct sk_buff *skb,
1050 } 1049 }
1051 /* Put out the doubleword header... */ 1050 /* Put out the doubleword header... */
1052 outl(skb->len, ioaddr + TX_FIFO); 1051 outl(skb->len, ioaddr + TX_FIFO);
1053 vp->stats.tx_bytes += skb->len; 1052 dev->stats.tx_bytes += skb->len;
1054#ifdef VORTEX_BUS_MASTER 1053#ifdef VORTEX_BUS_MASTER
1055 if (vp->bus_master) { 1054 if (vp->bus_master) {
1056 /* Set the bus-master controller to transfer the packet. */ 1055 /* Set the bus-master controller to transfer the packet. */
@@ -1094,9 +1093,9 @@ static int corkscrew_start_xmit(struct sk_buff *skb,
1094 printk("%s: Tx error, status %2.2x.\n", 1093 printk("%s: Tx error, status %2.2x.\n",
1095 dev->name, tx_status); 1094 dev->name, tx_status);
1096 if (tx_status & 0x04) 1095 if (tx_status & 0x04)
1097 vp->stats.tx_fifo_errors++; 1096 dev->stats.tx_fifo_errors++;
1098 if (tx_status & 0x38) 1097 if (tx_status & 0x38)
1099 vp->stats.tx_aborted_errors++; 1098 dev->stats.tx_aborted_errors++;
1100 if (tx_status & 0x30) { 1099 if (tx_status & 0x30) {
1101 int j; 1100 int j;
1102 outw(TxReset, ioaddr + EL3_CMD); 1101 outw(TxReset, ioaddr + EL3_CMD);
@@ -1257,7 +1256,6 @@ static irqreturn_t corkscrew_interrupt(int irq, void *dev_id)
1257 1256
1258static int corkscrew_rx(struct net_device *dev) 1257static int corkscrew_rx(struct net_device *dev)
1259{ 1258{
1260 struct corkscrew_private *vp = netdev_priv(dev);
1261 int ioaddr = dev->base_addr; 1259 int ioaddr = dev->base_addr;
1262 int i; 1260 int i;
1263 short rx_status; 1261 short rx_status;
@@ -1271,17 +1269,17 @@ static int corkscrew_rx(struct net_device *dev)
1271 if (corkscrew_debug > 2) 1269 if (corkscrew_debug > 2)
1272 printk(" Rx error: status %2.2x.\n", 1270 printk(" Rx error: status %2.2x.\n",
1273 rx_error); 1271 rx_error);
1274 vp->stats.rx_errors++; 1272 dev->stats.rx_errors++;
1275 if (rx_error & 0x01) 1273 if (rx_error & 0x01)
1276 vp->stats.rx_over_errors++; 1274 dev->stats.rx_over_errors++;
1277 if (rx_error & 0x02) 1275 if (rx_error & 0x02)
1278 vp->stats.rx_length_errors++; 1276 dev->stats.rx_length_errors++;
1279 if (rx_error & 0x04) 1277 if (rx_error & 0x04)
1280 vp->stats.rx_frame_errors++; 1278 dev->stats.rx_frame_errors++;
1281 if (rx_error & 0x08) 1279 if (rx_error & 0x08)
1282 vp->stats.rx_crc_errors++; 1280 dev->stats.rx_crc_errors++;
1283 if (rx_error & 0x10) 1281 if (rx_error & 0x10)
1284 vp->stats.rx_length_errors++; 1282 dev->stats.rx_length_errors++;
1285 } else { 1283 } else {
1286 /* The packet length: up to 4.5K!. */ 1284 /* The packet length: up to 4.5K!. */
1287 short pkt_len = rx_status & 0x1fff; 1285 short pkt_len = rx_status & 0x1fff;
@@ -1301,8 +1299,8 @@ static int corkscrew_rx(struct net_device *dev)
1301 skb->protocol = eth_type_trans(skb, dev); 1299 skb->protocol = eth_type_trans(skb, dev);
1302 netif_rx(skb); 1300 netif_rx(skb);
1303 dev->last_rx = jiffies; 1301 dev->last_rx = jiffies;
1304 vp->stats.rx_packets++; 1302 dev->stats.rx_packets++;
1305 vp->stats.rx_bytes += pkt_len; 1303 dev->stats.rx_bytes += pkt_len;
1306 /* Wait a limited time to go to next packet. */ 1304 /* Wait a limited time to go to next packet. */
1307 for (i = 200; i >= 0; i--) 1305 for (i = 200; i >= 0; i--)
1308 if (! (inw(ioaddr + EL3_STATUS) & CmdInProgress)) 1306 if (! (inw(ioaddr + EL3_STATUS) & CmdInProgress))
@@ -1312,7 +1310,7 @@ static int corkscrew_rx(struct net_device *dev)
1312 printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, pkt_len); 1310 printk("%s: Couldn't allocate a sk_buff of size %d.\n", dev->name, pkt_len);
1313 } 1311 }
1314 outw(RxDiscard, ioaddr + EL3_CMD); 1312 outw(RxDiscard, ioaddr + EL3_CMD);
1315 vp->stats.rx_dropped++; 1313 dev->stats.rx_dropped++;
1316 /* Wait a limited time to skip this packet. */ 1314 /* Wait a limited time to skip this packet. */
1317 for (i = 200; i >= 0; i--) 1315 for (i = 200; i >= 0; i--)
1318 if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress)) 1316 if (!(inw(ioaddr + EL3_STATUS) & CmdInProgress))
@@ -1337,23 +1335,23 @@ static int boomerang_rx(struct net_device *dev)
1337 if (corkscrew_debug > 2) 1335 if (corkscrew_debug > 2)
1338 printk(" Rx error: status %2.2x.\n", 1336 printk(" Rx error: status %2.2x.\n",
1339 rx_error); 1337 rx_error);
1340 vp->stats.rx_errors++; 1338 dev->stats.rx_errors++;
1341 if (rx_error & 0x01) 1339 if (rx_error & 0x01)
1342 vp->stats.rx_over_errors++; 1340 dev->stats.rx_over_errors++;
1343 if (rx_error & 0x02) 1341 if (rx_error & 0x02)
1344 vp->stats.rx_length_errors++; 1342 dev->stats.rx_length_errors++;
1345 if (rx_error & 0x04) 1343 if (rx_error & 0x04)
1346 vp->stats.rx_frame_errors++; 1344 dev->stats.rx_frame_errors++;
1347 if (rx_error & 0x08) 1345 if (rx_error & 0x08)
1348 vp->stats.rx_crc_errors++; 1346 dev->stats.rx_crc_errors++;
1349 if (rx_error & 0x10) 1347 if (rx_error & 0x10)
1350 vp->stats.rx_length_errors++; 1348 dev->stats.rx_length_errors++;
1351 } else { 1349 } else {
1352 /* The packet length: up to 4.5K!. */ 1350 /* The packet length: up to 4.5K!. */
1353 short pkt_len = rx_status & 0x1fff; 1351 short pkt_len = rx_status & 0x1fff;
1354 struct sk_buff *skb; 1352 struct sk_buff *skb;
1355 1353
1356 vp->stats.rx_bytes += pkt_len; 1354 dev->stats.rx_bytes += pkt_len;
1357 if (corkscrew_debug > 4) 1355 if (corkscrew_debug > 4)
1358 printk("Receiving packet size %d status %4.4x.\n", 1356 printk("Receiving packet size %d status %4.4x.\n",
1359 pkt_len, rx_status); 1357 pkt_len, rx_status);
@@ -1388,7 +1386,7 @@ static int boomerang_rx(struct net_device *dev)
1388 skb->protocol = eth_type_trans(skb, dev); 1386 skb->protocol = eth_type_trans(skb, dev);
1389 netif_rx(skb); 1387 netif_rx(skb);
1390 dev->last_rx = jiffies; 1388 dev->last_rx = jiffies;
1391 vp->stats.rx_packets++; 1389 dev->stats.rx_packets++;
1392 } 1390 }
1393 entry = (++vp->cur_rx) % RX_RING_SIZE; 1391 entry = (++vp->cur_rx) % RX_RING_SIZE;
1394 } 1392 }
@@ -1475,7 +1473,7 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev)
1475 update_stats(dev->base_addr, dev); 1473 update_stats(dev->base_addr, dev);
1476 spin_unlock_irqrestore(&vp->lock, flags); 1474 spin_unlock_irqrestore(&vp->lock, flags);
1477 } 1475 }
1478 return &vp->stats; 1476 return &dev->stats;
1479} 1477}
1480 1478
1481/* Update statistics. 1479/* Update statistics.
@@ -1487,19 +1485,17 @@ static struct net_device_stats *corkscrew_get_stats(struct net_device *dev)
1487 */ 1485 */
1488static void update_stats(int ioaddr, struct net_device *dev) 1486static void update_stats(int ioaddr, struct net_device *dev)
1489{ 1487{
1490 struct corkscrew_private *vp = netdev_priv(dev);
1491
1492 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */ 1488 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */
1493 /* Switch to the stats window, and read everything. */ 1489 /* Switch to the stats window, and read everything. */
1494 EL3WINDOW(6); 1490 EL3WINDOW(6);
1495 vp->stats.tx_carrier_errors += inb(ioaddr + 0); 1491 dev->stats.tx_carrier_errors += inb(ioaddr + 0);
1496 vp->stats.tx_heartbeat_errors += inb(ioaddr + 1); 1492 dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
1497 /* Multiple collisions. */ inb(ioaddr + 2); 1493 /* Multiple collisions. */ inb(ioaddr + 2);
1498 vp->stats.collisions += inb(ioaddr + 3); 1494 dev->stats.collisions += inb(ioaddr + 3);
1499 vp->stats.tx_window_errors += inb(ioaddr + 4); 1495 dev->stats.tx_window_errors += inb(ioaddr + 4);
1500 vp->stats.rx_fifo_errors += inb(ioaddr + 5); 1496 dev->stats.rx_fifo_errors += inb(ioaddr + 5);
1501 vp->stats.tx_packets += inb(ioaddr + 6); 1497 dev->stats.tx_packets += inb(ioaddr + 6);
1502 vp->stats.tx_packets += (inb(ioaddr + 9) & 0x30) << 4; 1498 dev->stats.tx_packets += (inb(ioaddr + 9) & 0x30) << 4;
1503 /* Rx packets */ inb(ioaddr + 7); 1499 /* Rx packets */ inb(ioaddr + 7);
1504 /* Must read to clear */ 1500 /* Must read to clear */
1505 /* Tx deferrals */ inb(ioaddr + 8); 1501 /* Tx deferrals */ inb(ioaddr + 8);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index f90a86ba7e2f..af46341827f2 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2593,6 +2593,7 @@ config BNX2X
2593 To compile this driver as a module, choose M here: the module 2593 To compile this driver as a module, choose M here: the module
2594 will be called bnx2x. This is recommended. 2594 will be called bnx2x. This is recommended.
2595 2595
2596source "drivers/net/sfc/Kconfig"
2596 2597
2597endif # NETDEV_10000 2598endif # NETDEV_10000
2598 2599
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 2f1f3f2739fd..dcbfe8421154 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -253,3 +253,5 @@ obj-$(CONFIG_FS_ENET) += fs_enet/
253obj-$(CONFIG_NETXEN_NIC) += netxen/ 253obj-$(CONFIG_NETXEN_NIC) += netxen/
254obj-$(CONFIG_NIU) += niu.o 254obj-$(CONFIG_NIU) += niu.o
255obj-$(CONFIG_VIRTIO_NET) += virtio_net.o 255obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
256obj-$(CONFIG_SFC) += sfc/
257
diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig
index f9cc2b621fe2..8eda6eeb43b7 100644
--- a/drivers/net/arm/Kconfig
+++ b/drivers/net/arm/Kconfig
@@ -47,3 +47,11 @@ config EP93XX_ETH
47 help 47 help
48 This is a driver for the ethernet hardware included in EP93xx CPUs. 48 This is a driver for the ethernet hardware included in EP93xx CPUs.
49 Say Y if you are building a kernel for EP93xx based devices. 49 Say Y if you are building a kernel for EP93xx based devices.
50
51config IXP4XX_ETH
52 tristate "Intel IXP4xx Ethernet support"
53 depends on ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR
54 select MII
55 help
56 Say Y here if you want to use built-in Ethernet ports
57 on IXP4xx processor.
diff --git a/drivers/net/arm/Makefile b/drivers/net/arm/Makefile
index a4c868278e11..7c812ac2b6a5 100644
--- a/drivers/net/arm/Makefile
+++ b/drivers/net/arm/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_ARM_ETHER3) += ether3.o
9obj-$(CONFIG_ARM_ETHER1) += ether1.o 9obj-$(CONFIG_ARM_ETHER1) += ether1.o
10obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o 10obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o
11obj-$(CONFIG_EP93XX_ETH) += ep93xx_eth.o 11obj-$(CONFIG_EP93XX_ETH) += ep93xx_eth.o
12obj-$(CONFIG_IXP4XX_ETH) += ixp4xx_eth.o
diff --git a/drivers/net/arm/ixp4xx_eth.c b/drivers/net/arm/ixp4xx_eth.c
new file mode 100644
index 000000000000..c617b64c288e
--- /dev/null
+++ b/drivers/net/arm/ixp4xx_eth.c
@@ -0,0 +1,1265 @@
1/*
2 * Intel IXP4xx Ethernet driver for Linux
3 *
4 * Copyright (C) 2007 Krzysztof Halasa <khc@pm.waw.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation.
9 *
10 * Ethernet port config (0x00 is not present on IXP42X):
11 *
12 * logical port 0x00 0x10 0x20
13 * NPE 0 (NPE-A) 1 (NPE-B) 2 (NPE-C)
14 * physical PortId 2 0 1
15 * TX queue 23 24 25
16 * RX-free queue 26 27 28
17 * TX-done queue is always 31, per-port RX and TX-ready queues are configurable
18 *
19 *
20 * Queue entries:
21 * bits 0 -> 1 - NPE ID (RX and TX-done)
22 * bits 0 -> 2 - priority (TX, per 802.1D)
23 * bits 3 -> 4 - port ID (user-set?)
24 * bits 5 -> 31 - physical descriptor address
25 */
26
27#include <linux/delay.h>
28#include <linux/dma-mapping.h>
29#include <linux/dmapool.h>
30#include <linux/etherdevice.h>
31#include <linux/io.h>
32#include <linux/kernel.h>
33#include <linux/mii.h>
34#include <linux/platform_device.h>
35#include <asm/arch/npe.h>
36#include <asm/arch/qmgr.h>
37
38#define DEBUG_QUEUES 0
39#define DEBUG_DESC 0
40#define DEBUG_RX 0
41#define DEBUG_TX 0
42#define DEBUG_PKT_BYTES 0
43#define DEBUG_MDIO 0
44#define DEBUG_CLOSE 0
45
46#define DRV_NAME "ixp4xx_eth"
47
48#define MAX_NPES 3
49
50#define RX_DESCS 64 /* also length of all RX queues */
51#define TX_DESCS 16 /* also length of all TX queues */
52#define TXDONE_QUEUE_LEN 64 /* dwords */
53
54#define POOL_ALLOC_SIZE (sizeof(struct desc) * (RX_DESCS + TX_DESCS))
55#define REGS_SIZE 0x1000
56#define MAX_MRU 1536 /* 0x600 */
57#define RX_BUFF_SIZE ALIGN((NET_IP_ALIGN) + MAX_MRU, 4)
58
59#define NAPI_WEIGHT 16
60#define MDIO_INTERVAL (3 * HZ)
61#define MAX_MDIO_RETRIES 100 /* microseconds, typically 30 cycles */
62#define MAX_MII_RESET_RETRIES 100 /* mdio_read() cycles, typically 4 */
63#define MAX_CLOSE_WAIT 1000 /* microseconds, typically 2-3 cycles */
64
65#define NPE_ID(port_id) ((port_id) >> 4)
66#define PHYSICAL_ID(port_id) ((NPE_ID(port_id) + 2) % 3)
67#define TX_QUEUE(port_id) (NPE_ID(port_id) + 23)
68#define RXFREE_QUEUE(port_id) (NPE_ID(port_id) + 26)
69#define TXDONE_QUEUE 31
70
71/* TX Control Registers */
72#define TX_CNTRL0_TX_EN 0x01
73#define TX_CNTRL0_HALFDUPLEX 0x02
74#define TX_CNTRL0_RETRY 0x04
75#define TX_CNTRL0_PAD_EN 0x08
76#define TX_CNTRL0_APPEND_FCS 0x10
77#define TX_CNTRL0_2DEFER 0x20
78#define TX_CNTRL0_RMII 0x40 /* reduced MII */
79#define TX_CNTRL1_RETRIES 0x0F /* 4 bits */
80
81/* RX Control Registers */
82#define RX_CNTRL0_RX_EN 0x01
83#define RX_CNTRL0_PADSTRIP_EN 0x02
84#define RX_CNTRL0_SEND_FCS 0x04
85#define RX_CNTRL0_PAUSE_EN 0x08
86#define RX_CNTRL0_LOOP_EN 0x10
87#define RX_CNTRL0_ADDR_FLTR_EN 0x20
88#define RX_CNTRL0_RX_RUNT_EN 0x40
89#define RX_CNTRL0_BCAST_DIS 0x80
90#define RX_CNTRL1_DEFER_EN 0x01
91
92/* Core Control Register */
93#define CORE_RESET 0x01
94#define CORE_RX_FIFO_FLUSH 0x02
95#define CORE_TX_FIFO_FLUSH 0x04
96#define CORE_SEND_JAM 0x08
97#define CORE_MDC_EN 0x10 /* MDIO using NPE-B ETH-0 only */
98
99#define DEFAULT_TX_CNTRL0 (TX_CNTRL0_TX_EN | TX_CNTRL0_RETRY | \
100 TX_CNTRL0_PAD_EN | TX_CNTRL0_APPEND_FCS | \
101 TX_CNTRL0_2DEFER)
102#define DEFAULT_RX_CNTRL0 RX_CNTRL0_RX_EN
103#define DEFAULT_CORE_CNTRL CORE_MDC_EN
104
105
106/* NPE message codes */
107#define NPE_GETSTATUS 0x00
108#define NPE_EDB_SETPORTADDRESS 0x01
109#define NPE_EDB_GETMACADDRESSDATABASE 0x02
110#define NPE_EDB_SETMACADDRESSSDATABASE 0x03
111#define NPE_GETSTATS 0x04
112#define NPE_RESETSTATS 0x05
113#define NPE_SETMAXFRAMELENGTHS 0x06
114#define NPE_VLAN_SETRXTAGMODE 0x07
115#define NPE_VLAN_SETDEFAULTRXVID 0x08
116#define NPE_VLAN_SETPORTVLANTABLEENTRY 0x09
117#define NPE_VLAN_SETPORTVLANTABLERANGE 0x0A
118#define NPE_VLAN_SETRXQOSENTRY 0x0B
119#define NPE_VLAN_SETPORTIDEXTRACTIONMODE 0x0C
120#define NPE_STP_SETBLOCKINGSTATE 0x0D
121#define NPE_FW_SETFIREWALLMODE 0x0E
122#define NPE_PC_SETFRAMECONTROLDURATIONID 0x0F
123#define NPE_PC_SETAPMACTABLE 0x11
124#define NPE_SETLOOPBACK_MODE 0x12
125#define NPE_PC_SETBSSIDTABLE 0x13
126#define NPE_ADDRESS_FILTER_CONFIG 0x14
127#define NPE_APPENDFCSCONFIG 0x15
128#define NPE_NOTIFY_MAC_RECOVERY_DONE 0x16
129#define NPE_MAC_RECOVERY_START 0x17
130
131
132#ifdef __ARMEB__
133typedef struct sk_buff buffer_t;
134#define free_buffer dev_kfree_skb
135#define free_buffer_irq dev_kfree_skb_irq
136#else
137typedef void buffer_t;
138#define free_buffer kfree
139#define free_buffer_irq kfree
140#endif
141
142struct eth_regs {
143 u32 tx_control[2], __res1[2]; /* 000 */
144 u32 rx_control[2], __res2[2]; /* 010 */
145 u32 random_seed, __res3[3]; /* 020 */
146 u32 partial_empty_threshold, __res4; /* 030 */
147 u32 partial_full_threshold, __res5; /* 038 */
148 u32 tx_start_bytes, __res6[3]; /* 040 */
149 u32 tx_deferral, rx_deferral, __res7[2];/* 050 */
150 u32 tx_2part_deferral[2], __res8[2]; /* 060 */
151 u32 slot_time, __res9[3]; /* 070 */
152 u32 mdio_command[4]; /* 080 */
153 u32 mdio_status[4]; /* 090 */
154 u32 mcast_mask[6], __res10[2]; /* 0A0 */
155 u32 mcast_addr[6], __res11[2]; /* 0C0 */
156 u32 int_clock_threshold, __res12[3]; /* 0E0 */
157 u32 hw_addr[6], __res13[61]; /* 0F0 */
158 u32 core_control; /* 1FC */
159};
160
161struct port {
162 struct resource *mem_res;
163 struct eth_regs __iomem *regs;
164 struct npe *npe;
165 struct net_device *netdev;
166 struct napi_struct napi;
167 struct net_device_stats stat;
168 struct mii_if_info mii;
169 struct delayed_work mdio_thread;
170 struct eth_plat_info *plat;
171 buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
172 struct desc *desc_tab; /* coherent */
173 u32 desc_tab_phys;
174 int id; /* logical port ID */
175 u16 mii_bmcr;
176};
177
178/* NPE message structure */
179struct msg {
180#ifdef __ARMEB__
181 u8 cmd, eth_id, byte2, byte3;
182 u8 byte4, byte5, byte6, byte7;
183#else
184 u8 byte3, byte2, eth_id, cmd;
185 u8 byte7, byte6, byte5, byte4;
186#endif
187};
188
189/* Ethernet packet descriptor */
190struct desc {
191 u32 next; /* pointer to next buffer, unused */
192
193#ifdef __ARMEB__
194 u16 buf_len; /* buffer length */
195 u16 pkt_len; /* packet length */
196 u32 data; /* pointer to data buffer in RAM */
197 u8 dest_id;
198 u8 src_id;
199 u16 flags;
200 u8 qos;
201 u8 padlen;
202 u16 vlan_tci;
203#else
204 u16 pkt_len; /* packet length */
205 u16 buf_len; /* buffer length */
206 u32 data; /* pointer to data buffer in RAM */
207 u16 flags;
208 u8 src_id;
209 u8 dest_id;
210 u16 vlan_tci;
211 u8 padlen;
212 u8 qos;
213#endif
214
215#ifdef __ARMEB__
216 u8 dst_mac_0, dst_mac_1, dst_mac_2, dst_mac_3;
217 u8 dst_mac_4, dst_mac_5, src_mac_0, src_mac_1;
218 u8 src_mac_2, src_mac_3, src_mac_4, src_mac_5;
219#else
220 u8 dst_mac_3, dst_mac_2, dst_mac_1, dst_mac_0;
221 u8 src_mac_1, src_mac_0, dst_mac_5, dst_mac_4;
222 u8 src_mac_5, src_mac_4, src_mac_3, src_mac_2;
223#endif
224};
225
226
227#define rx_desc_phys(port, n) ((port)->desc_tab_phys + \
228 (n) * sizeof(struct desc))
229#define rx_desc_ptr(port, n) (&(port)->desc_tab[n])
230
231#define tx_desc_phys(port, n) ((port)->desc_tab_phys + \
232 ((n) + RX_DESCS) * sizeof(struct desc))
233#define tx_desc_ptr(port, n) (&(port)->desc_tab[(n) + RX_DESCS])
234
235#ifndef __ARMEB__
236static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt)
237{
238 int i;
239 for (i = 0; i < cnt; i++)
240 dest[i] = swab32(src[i]);
241}
242#endif
243
244static spinlock_t mdio_lock;
245static struct eth_regs __iomem *mdio_regs; /* mdio command and status only */
246static int ports_open;
247static struct port *npe_port_tab[MAX_NPES];
248static struct dma_pool *dma_pool;
249
250
251static u16 mdio_cmd(struct net_device *dev, int phy_id, int location,
252 int write, u16 cmd)
253{
254 int cycles = 0;
255
256 if (__raw_readl(&mdio_regs->mdio_command[3]) & 0x80) {
257 printk(KERN_ERR "%s: MII not ready to transmit\n", dev->name);
258 return 0;
259 }
260
261 if (write) {
262 __raw_writel(cmd & 0xFF, &mdio_regs->mdio_command[0]);
263 __raw_writel(cmd >> 8, &mdio_regs->mdio_command[1]);
264 }
265 __raw_writel(((phy_id << 5) | location) & 0xFF,
266 &mdio_regs->mdio_command[2]);
267 __raw_writel((phy_id >> 3) | (write << 2) | 0x80 /* GO */,
268 &mdio_regs->mdio_command[3]);
269
270 while ((cycles < MAX_MDIO_RETRIES) &&
271 (__raw_readl(&mdio_regs->mdio_command[3]) & 0x80)) {
272 udelay(1);
273 cycles++;
274 }
275
276 if (cycles == MAX_MDIO_RETRIES) {
277 printk(KERN_ERR "%s: MII write failed\n", dev->name);
278 return 0;
279 }
280
281#if DEBUG_MDIO
282 printk(KERN_DEBUG "%s: mdio_cmd() took %i cycles\n", dev->name,
283 cycles);
284#endif
285
286 if (write)
287 return 0;
288
289 if (__raw_readl(&mdio_regs->mdio_status[3]) & 0x80) {
290 printk(KERN_ERR "%s: MII read failed\n", dev->name);
291 return 0;
292 }
293
294 return (__raw_readl(&mdio_regs->mdio_status[0]) & 0xFF) |
295 (__raw_readl(&mdio_regs->mdio_status[1]) << 8);
296}
297
298static int mdio_read(struct net_device *dev, int phy_id, int location)
299{
300 unsigned long flags;
301 u16 val;
302
303 spin_lock_irqsave(&mdio_lock, flags);
304 val = mdio_cmd(dev, phy_id, location, 0, 0);
305 spin_unlock_irqrestore(&mdio_lock, flags);
306 return val;
307}
308
309static void mdio_write(struct net_device *dev, int phy_id, int location,
310 int val)
311{
312 unsigned long flags;
313
314 spin_lock_irqsave(&mdio_lock, flags);
315 mdio_cmd(dev, phy_id, location, 1, val);
316 spin_unlock_irqrestore(&mdio_lock, flags);
317}
318
319static void phy_reset(struct net_device *dev, int phy_id)
320{
321 struct port *port = netdev_priv(dev);
322 int cycles = 0;
323
324 mdio_write(dev, phy_id, MII_BMCR, port->mii_bmcr | BMCR_RESET);
325
326 while (cycles < MAX_MII_RESET_RETRIES) {
327 if (!(mdio_read(dev, phy_id, MII_BMCR) & BMCR_RESET)) {
328#if DEBUG_MDIO
329 printk(KERN_DEBUG "%s: phy_reset() took %i cycles\n",
330 dev->name, cycles);
331#endif
332 return;
333 }
334 udelay(1);
335 cycles++;
336 }
337
338 printk(KERN_ERR "%s: MII reset failed\n", dev->name);
339}
340
341static void eth_set_duplex(struct port *port)
342{
343 if (port->mii.full_duplex)
344 __raw_writel(DEFAULT_TX_CNTRL0 & ~TX_CNTRL0_HALFDUPLEX,
345 &port->regs->tx_control[0]);
346 else
347 __raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX,
348 &port->regs->tx_control[0]);
349}
350
351
352static void phy_check_media(struct port *port, int init)
353{
354 if (mii_check_media(&port->mii, 1, init))
355 eth_set_duplex(port);
356 if (port->mii.force_media) { /* mii_check_media() doesn't work */
357 struct net_device *dev = port->netdev;
358 int cur_link = mii_link_ok(&port->mii);
359 int prev_link = netif_carrier_ok(dev);
360
361 if (!prev_link && cur_link) {
362 printk(KERN_INFO "%s: link up\n", dev->name);
363 netif_carrier_on(dev);
364 } else if (prev_link && !cur_link) {
365 printk(KERN_INFO "%s: link down\n", dev->name);
366 netif_carrier_off(dev);
367 }
368 }
369}
370
371
372static void mdio_thread(struct work_struct *work)
373{
374 struct port *port = container_of(work, struct port, mdio_thread.work);
375
376 phy_check_media(port, 0);
377 schedule_delayed_work(&port->mdio_thread, MDIO_INTERVAL);
378}
379
380
381static inline void debug_pkt(struct net_device *dev, const char *func,
382 u8 *data, int len)
383{
384#if DEBUG_PKT_BYTES
385 int i;
386
387 printk(KERN_DEBUG "%s: %s(%i) ", dev->name, func, len);
388 for (i = 0; i < len; i++) {
389 if (i >= DEBUG_PKT_BYTES)
390 break;
391 printk("%s%02X",
392 ((i == 6) || (i == 12) || (i >= 14)) ? " " : "",
393 data[i]);
394 }
395 printk("\n");
396#endif
397}
398
399
400static inline void debug_desc(u32 phys, struct desc *desc)
401{
402#if DEBUG_DESC
403 printk(KERN_DEBUG "%X: %X %3X %3X %08X %2X < %2X %4X %X"
404 " %X %X %02X%02X%02X%02X%02X%02X < %02X%02X%02X%02X%02X%02X\n",
405 phys, desc->next, desc->buf_len, desc->pkt_len,
406 desc->data, desc->dest_id, desc->src_id, desc->flags,
407 desc->qos, desc->padlen, desc->vlan_tci,
408 desc->dst_mac_0, desc->dst_mac_1, desc->dst_mac_2,
409 desc->dst_mac_3, desc->dst_mac_4, desc->dst_mac_5,
410 desc->src_mac_0, desc->src_mac_1, desc->src_mac_2,
411 desc->src_mac_3, desc->src_mac_4, desc->src_mac_5);
412#endif
413}
414
415static inline void debug_queue(unsigned int queue, int is_get, u32 phys)
416{
417#if DEBUG_QUEUES
418 static struct {
419 int queue;
420 char *name;
421 } names[] = {
422 { TX_QUEUE(0x10), "TX#0 " },
423 { TX_QUEUE(0x20), "TX#1 " },
424 { TX_QUEUE(0x00), "TX#2 " },
425 { RXFREE_QUEUE(0x10), "RX-free#0 " },
426 { RXFREE_QUEUE(0x20), "RX-free#1 " },
427 { RXFREE_QUEUE(0x00), "RX-free#2 " },
428 { TXDONE_QUEUE, "TX-done " },
429 };
430 int i;
431
432 for (i = 0; i < ARRAY_SIZE(names); i++)
433 if (names[i].queue == queue)
434 break;
435
436 printk(KERN_DEBUG "Queue %i %s%s %X\n", queue,
437 i < ARRAY_SIZE(names) ? names[i].name : "",
438 is_get ? "->" : "<-", phys);
439#endif
440}
441
442static inline u32 queue_get_entry(unsigned int queue)
443{
444 u32 phys = qmgr_get_entry(queue);
445 debug_queue(queue, 1, phys);
446 return phys;
447}
448
449static inline int queue_get_desc(unsigned int queue, struct port *port,
450 int is_tx)
451{
452 u32 phys, tab_phys, n_desc;
453 struct desc *tab;
454
455 if (!(phys = queue_get_entry(queue)))
456 return -1;
457
458 phys &= ~0x1F; /* mask out non-address bits */
459 tab_phys = is_tx ? tx_desc_phys(port, 0) : rx_desc_phys(port, 0);
460 tab = is_tx ? tx_desc_ptr(port, 0) : rx_desc_ptr(port, 0);
461 n_desc = (phys - tab_phys) / sizeof(struct desc);
462 BUG_ON(n_desc >= (is_tx ? TX_DESCS : RX_DESCS));
463 debug_desc(phys, &tab[n_desc]);
464 BUG_ON(tab[n_desc].next);
465 return n_desc;
466}
467
468static inline void queue_put_desc(unsigned int queue, u32 phys,
469 struct desc *desc)
470{
471 debug_queue(queue, 0, phys);
472 debug_desc(phys, desc);
473 BUG_ON(phys & 0x1F);
474 qmgr_put_entry(queue, phys);
475 BUG_ON(qmgr_stat_overflow(queue));
476}
477
478
479static inline void dma_unmap_tx(struct port *port, struct desc *desc)
480{
481#ifdef __ARMEB__
482 dma_unmap_single(&port->netdev->dev, desc->data,
483 desc->buf_len, DMA_TO_DEVICE);
484#else
485 dma_unmap_single(&port->netdev->dev, desc->data & ~3,
486 ALIGN((desc->data & 3) + desc->buf_len, 4),
487 DMA_TO_DEVICE);
488#endif
489}
490
491
492static void eth_rx_irq(void *pdev)
493{
494 struct net_device *dev = pdev;
495 struct port *port = netdev_priv(dev);
496
497#if DEBUG_RX
498 printk(KERN_DEBUG "%s: eth_rx_irq\n", dev->name);
499#endif
500 qmgr_disable_irq(port->plat->rxq);
501 netif_rx_schedule(dev, &port->napi);
502}
503
504static int eth_poll(struct napi_struct *napi, int budget)
505{
506 struct port *port = container_of(napi, struct port, napi);
507 struct net_device *dev = port->netdev;
508 unsigned int rxq = port->plat->rxq, rxfreeq = RXFREE_QUEUE(port->id);
509 int received = 0;
510
511#if DEBUG_RX
512 printk(KERN_DEBUG "%s: eth_poll\n", dev->name);
513#endif
514
515 while (received < budget) {
516 struct sk_buff *skb;
517 struct desc *desc;
518 int n;
519#ifdef __ARMEB__
520 struct sk_buff *temp;
521 u32 phys;
522#endif
523
524 if ((n = queue_get_desc(rxq, port, 0)) < 0) {
525 received = 0; /* No packet received */
526#if DEBUG_RX
527 printk(KERN_DEBUG "%s: eth_poll netif_rx_complete\n",
528 dev->name);
529#endif
530 netif_rx_complete(dev, napi);
531 qmgr_enable_irq(rxq);
532 if (!qmgr_stat_empty(rxq) &&
533 netif_rx_reschedule(dev, napi)) {
534#if DEBUG_RX
535 printk(KERN_DEBUG "%s: eth_poll"
536 " netif_rx_reschedule successed\n",
537 dev->name);
538#endif
539 qmgr_disable_irq(rxq);
540 continue;
541 }
542#if DEBUG_RX
543 printk(KERN_DEBUG "%s: eth_poll all done\n",
544 dev->name);
545#endif
546 return 0; /* all work done */
547 }
548
549 desc = rx_desc_ptr(port, n);
550
551#ifdef __ARMEB__
552 if ((skb = netdev_alloc_skb(dev, RX_BUFF_SIZE))) {
553 phys = dma_map_single(&dev->dev, skb->data,
554 RX_BUFF_SIZE, DMA_FROM_DEVICE);
555 if (dma_mapping_error(phys)) {
556 dev_kfree_skb(skb);
557 skb = NULL;
558 }
559 }
560#else
561 skb = netdev_alloc_skb(dev,
562 ALIGN(NET_IP_ALIGN + desc->pkt_len, 4));
563#endif
564
565 if (!skb) {
566 port->stat.rx_dropped++;
567 /* put the desc back on RX-ready queue */
568 desc->buf_len = MAX_MRU;
569 desc->pkt_len = 0;
570 queue_put_desc(rxfreeq, rx_desc_phys(port, n), desc);
571 continue;
572 }
573
574 /* process received frame */
575#ifdef __ARMEB__
576 temp = skb;
577 skb = port->rx_buff_tab[n];
578 dma_unmap_single(&dev->dev, desc->data - NET_IP_ALIGN,
579 RX_BUFF_SIZE, DMA_FROM_DEVICE);
580#else
581 dma_sync_single(&dev->dev, desc->data - NET_IP_ALIGN,
582 RX_BUFF_SIZE, DMA_FROM_DEVICE);
583 memcpy_swab32((u32 *)skb->data, (u32 *)port->rx_buff_tab[n],
584 ALIGN(NET_IP_ALIGN + desc->pkt_len, 4) / 4);
585#endif
586 skb_reserve(skb, NET_IP_ALIGN);
587 skb_put(skb, desc->pkt_len);
588
589 debug_pkt(dev, "eth_poll", skb->data, skb->len);
590
591 skb->protocol = eth_type_trans(skb, dev);
592 dev->last_rx = jiffies;
593 port->stat.rx_packets++;
594 port->stat.rx_bytes += skb->len;
595 netif_receive_skb(skb);
596
597 /* put the new buffer on RX-free queue */
598#ifdef __ARMEB__
599 port->rx_buff_tab[n] = temp;
600 desc->data = phys + NET_IP_ALIGN;
601#endif
602 desc->buf_len = MAX_MRU;
603 desc->pkt_len = 0;
604 queue_put_desc(rxfreeq, rx_desc_phys(port, n), desc);
605 received++;
606 }
607
608#if DEBUG_RX
609 printk(KERN_DEBUG "eth_poll(): end, not all work done\n");
610#endif
611 return received; /* not all work done */
612}
613
614
615static void eth_txdone_irq(void *unused)
616{
617 u32 phys;
618
619#if DEBUG_TX
620 printk(KERN_DEBUG DRV_NAME ": eth_txdone_irq\n");
621#endif
622 while ((phys = queue_get_entry(TXDONE_QUEUE)) != 0) {
623 u32 npe_id, n_desc;
624 struct port *port;
625 struct desc *desc;
626 int start;
627
628 npe_id = phys & 3;
629 BUG_ON(npe_id >= MAX_NPES);
630 port = npe_port_tab[npe_id];
631 BUG_ON(!port);
632 phys &= ~0x1F; /* mask out non-address bits */
633 n_desc = (phys - tx_desc_phys(port, 0)) / sizeof(struct desc);
634 BUG_ON(n_desc >= TX_DESCS);
635 desc = tx_desc_ptr(port, n_desc);
636 debug_desc(phys, desc);
637
638 if (port->tx_buff_tab[n_desc]) { /* not the draining packet */
639 port->stat.tx_packets++;
640 port->stat.tx_bytes += desc->pkt_len;
641
642 dma_unmap_tx(port, desc);
643#if DEBUG_TX
644 printk(KERN_DEBUG "%s: eth_txdone_irq free %p\n",
645 port->netdev->name, port->tx_buff_tab[n_desc]);
646#endif
647 free_buffer_irq(port->tx_buff_tab[n_desc]);
648 port->tx_buff_tab[n_desc] = NULL;
649 }
650
651 start = qmgr_stat_empty(port->plat->txreadyq);
652 queue_put_desc(port->plat->txreadyq, phys, desc);
653 if (start) {
654#if DEBUG_TX
655 printk(KERN_DEBUG "%s: eth_txdone_irq xmit ready\n",
656 port->netdev->name);
657#endif
658 netif_wake_queue(port->netdev);
659 }
660 }
661}
662
663static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
664{
665 struct port *port = netdev_priv(dev);
666 unsigned int txreadyq = port->plat->txreadyq;
667 int len, offset, bytes, n;
668 void *mem;
669 u32 phys;
670 struct desc *desc;
671
672#if DEBUG_TX
673 printk(KERN_DEBUG "%s: eth_xmit\n", dev->name);
674#endif
675
676 if (unlikely(skb->len > MAX_MRU)) {
677 dev_kfree_skb(skb);
678 port->stat.tx_errors++;
679 return NETDEV_TX_OK;
680 }
681
682 debug_pkt(dev, "eth_xmit", skb->data, skb->len);
683
684 len = skb->len;
685#ifdef __ARMEB__
686 offset = 0; /* no need to keep alignment */
687 bytes = len;
688 mem = skb->data;
689#else
690 offset = (int)skb->data & 3; /* keep 32-bit alignment */
691 bytes = ALIGN(offset + len, 4);
692 if (!(mem = kmalloc(bytes, GFP_ATOMIC))) {
693 dev_kfree_skb(skb);
694 port->stat.tx_dropped++;
695 return NETDEV_TX_OK;
696 }
697 memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4);
698 dev_kfree_skb(skb);
699#endif
700
701 phys = dma_map_single(&dev->dev, mem, bytes, DMA_TO_DEVICE);
702 if (dma_mapping_error(phys)) {
703#ifdef __ARMEB__
704 dev_kfree_skb(skb);
705#else
706 kfree(mem);
707#endif
708 port->stat.tx_dropped++;
709 return NETDEV_TX_OK;
710 }
711
712 n = queue_get_desc(txreadyq, port, 1);
713 BUG_ON(n < 0);
714 desc = tx_desc_ptr(port, n);
715
716#ifdef __ARMEB__
717 port->tx_buff_tab[n] = skb;
718#else
719 port->tx_buff_tab[n] = mem;
720#endif
721 desc->data = phys + offset;
722 desc->buf_len = desc->pkt_len = len;
723
724 /* NPE firmware pads short frames with zeros internally */
725 wmb();
726 queue_put_desc(TX_QUEUE(port->id), tx_desc_phys(port, n), desc);
727 dev->trans_start = jiffies;
728
729 if (qmgr_stat_empty(txreadyq)) {
730#if DEBUG_TX
731 printk(KERN_DEBUG "%s: eth_xmit queue full\n", dev->name);
732#endif
733 netif_stop_queue(dev);
734 /* we could miss TX ready interrupt */
735 if (!qmgr_stat_empty(txreadyq)) {
736#if DEBUG_TX
737 printk(KERN_DEBUG "%s: eth_xmit ready again\n",
738 dev->name);
739#endif
740 netif_wake_queue(dev);
741 }
742 }
743
744#if DEBUG_TX
745 printk(KERN_DEBUG "%s: eth_xmit end\n", dev->name);
746#endif
747 return NETDEV_TX_OK;
748}
749
750
751static struct net_device_stats *eth_stats(struct net_device *dev)
752{
753 struct port *port = netdev_priv(dev);
754 return &port->stat;
755}
756
757static void eth_set_mcast_list(struct net_device *dev)
758{
759 struct port *port = netdev_priv(dev);
760 struct dev_mc_list *mclist = dev->mc_list;
761 u8 diffs[ETH_ALEN], *addr;
762 int cnt = dev->mc_count, i;
763
764 if ((dev->flags & IFF_PROMISC) || !mclist || !cnt) {
765 __raw_writel(DEFAULT_RX_CNTRL0 & ~RX_CNTRL0_ADDR_FLTR_EN,
766 &port->regs->rx_control[0]);
767 return;
768 }
769
770 memset(diffs, 0, ETH_ALEN);
771 addr = mclist->dmi_addr; /* first MAC address */
772
773 while (--cnt && (mclist = mclist->next))
774 for (i = 0; i < ETH_ALEN; i++)
775 diffs[i] |= addr[i] ^ mclist->dmi_addr[i];
776
777 for (i = 0; i < ETH_ALEN; i++) {
778 __raw_writel(addr[i], &port->regs->mcast_addr[i]);
779 __raw_writel(~diffs[i], &port->regs->mcast_mask[i]);
780 }
781
782 __raw_writel(DEFAULT_RX_CNTRL0 | RX_CNTRL0_ADDR_FLTR_EN,
783 &port->regs->rx_control[0]);
784}
785
786
787static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
788{
789 struct port *port = netdev_priv(dev);
790 unsigned int duplex_chg;
791 int err;
792
793 if (!netif_running(dev))
794 return -EINVAL;
795 err = generic_mii_ioctl(&port->mii, if_mii(req), cmd, &duplex_chg);
796 if (duplex_chg)
797 eth_set_duplex(port);
798 return err;
799}
800
801
802static int request_queues(struct port *port)
803{
804 int err;
805
806 err = qmgr_request_queue(RXFREE_QUEUE(port->id), RX_DESCS, 0, 0);
807 if (err)
808 return err;
809
810 err = qmgr_request_queue(port->plat->rxq, RX_DESCS, 0, 0);
811 if (err)
812 goto rel_rxfree;
813
814 err = qmgr_request_queue(TX_QUEUE(port->id), TX_DESCS, 0, 0);
815 if (err)
816 goto rel_rx;
817
818 err = qmgr_request_queue(port->plat->txreadyq, TX_DESCS, 0, 0);
819 if (err)
820 goto rel_tx;
821
822 /* TX-done queue handles skbs sent out by the NPEs */
823 if (!ports_open) {
824 err = qmgr_request_queue(TXDONE_QUEUE, TXDONE_QUEUE_LEN, 0, 0);
825 if (err)
826 goto rel_txready;
827 }
828 return 0;
829
830rel_txready:
831 qmgr_release_queue(port->plat->txreadyq);
832rel_tx:
833 qmgr_release_queue(TX_QUEUE(port->id));
834rel_rx:
835 qmgr_release_queue(port->plat->rxq);
836rel_rxfree:
837 qmgr_release_queue(RXFREE_QUEUE(port->id));
838 printk(KERN_DEBUG "%s: unable to request hardware queues\n",
839 port->netdev->name);
840 return err;
841}
842
843static void release_queues(struct port *port)
844{
845 qmgr_release_queue(RXFREE_QUEUE(port->id));
846 qmgr_release_queue(port->plat->rxq);
847 qmgr_release_queue(TX_QUEUE(port->id));
848 qmgr_release_queue(port->plat->txreadyq);
849
850 if (!ports_open)
851 qmgr_release_queue(TXDONE_QUEUE);
852}
853
854static int init_queues(struct port *port)
855{
856 int i;
857
858 if (!ports_open)
859 if (!(dma_pool = dma_pool_create(DRV_NAME, NULL,
860 POOL_ALLOC_SIZE, 32, 0)))
861 return -ENOMEM;
862
863 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
864 &port->desc_tab_phys)))
865 return -ENOMEM;
866 memset(port->desc_tab, 0, POOL_ALLOC_SIZE);
867 memset(port->rx_buff_tab, 0, sizeof(port->rx_buff_tab)); /* tables */
868 memset(port->tx_buff_tab, 0, sizeof(port->tx_buff_tab));
869
870 /* Setup RX buffers */
871 for (i = 0; i < RX_DESCS; i++) {
872 struct desc *desc = rx_desc_ptr(port, i);
873 buffer_t *buff; /* skb or kmalloc()ated memory */
874 void *data;
875#ifdef __ARMEB__
876 if (!(buff = netdev_alloc_skb(port->netdev, RX_BUFF_SIZE)))
877 return -ENOMEM;
878 data = buff->data;
879#else
880 if (!(buff = kmalloc(RX_BUFF_SIZE, GFP_KERNEL)))
881 return -ENOMEM;
882 data = buff;
883#endif
884 desc->buf_len = MAX_MRU;
885 desc->data = dma_map_single(&port->netdev->dev, data,
886 RX_BUFF_SIZE, DMA_FROM_DEVICE);
887 if (dma_mapping_error(desc->data)) {
888 free_buffer(buff);
889 return -EIO;
890 }
891 desc->data += NET_IP_ALIGN;
892 port->rx_buff_tab[i] = buff;
893 }
894
895 return 0;
896}
897
898static void destroy_queues(struct port *port)
899{
900 int i;
901
902 if (port->desc_tab) {
903 for (i = 0; i < RX_DESCS; i++) {
904 struct desc *desc = rx_desc_ptr(port, i);
905 buffer_t *buff = port->rx_buff_tab[i];
906 if (buff) {
907 dma_unmap_single(&port->netdev->dev,
908 desc->data - NET_IP_ALIGN,
909 RX_BUFF_SIZE, DMA_FROM_DEVICE);
910 free_buffer(buff);
911 }
912 }
913 for (i = 0; i < TX_DESCS; i++) {
914 struct desc *desc = tx_desc_ptr(port, i);
915 buffer_t *buff = port->tx_buff_tab[i];
916 if (buff) {
917 dma_unmap_tx(port, desc);
918 free_buffer(buff);
919 }
920 }
921 dma_pool_free(dma_pool, port->desc_tab, port->desc_tab_phys);
922 port->desc_tab = NULL;
923 }
924
925 if (!ports_open && dma_pool) {
926 dma_pool_destroy(dma_pool);
927 dma_pool = NULL;
928 }
929}
930
931static int eth_open(struct net_device *dev)
932{
933 struct port *port = netdev_priv(dev);
934 struct npe *npe = port->npe;
935 struct msg msg;
936 int i, err;
937
938 if (!npe_running(npe)) {
939 err = npe_load_firmware(npe, npe_name(npe), &dev->dev);
940 if (err)
941 return err;
942
943 if (npe_recv_message(npe, &msg, "ETH_GET_STATUS")) {
944 printk(KERN_ERR "%s: %s not responding\n", dev->name,
945 npe_name(npe));
946 return -EIO;
947 }
948 }
949
950 mdio_write(dev, port->plat->phy, MII_BMCR, port->mii_bmcr);
951
952 memset(&msg, 0, sizeof(msg));
953 msg.cmd = NPE_VLAN_SETRXQOSENTRY;
954 msg.eth_id = port->id;
955 msg.byte5 = port->plat->rxq | 0x80;
956 msg.byte7 = port->plat->rxq << 4;
957 for (i = 0; i < 8; i++) {
958 msg.byte3 = i;
959 if (npe_send_recv_message(port->npe, &msg, "ETH_SET_RXQ"))
960 return -EIO;
961 }
962
963 msg.cmd = NPE_EDB_SETPORTADDRESS;
964 msg.eth_id = PHYSICAL_ID(port->id);
965 msg.byte2 = dev->dev_addr[0];
966 msg.byte3 = dev->dev_addr[1];
967 msg.byte4 = dev->dev_addr[2];
968 msg.byte5 = dev->dev_addr[3];
969 msg.byte6 = dev->dev_addr[4];
970 msg.byte7 = dev->dev_addr[5];
971 if (npe_send_recv_message(port->npe, &msg, "ETH_SET_MAC"))
972 return -EIO;
973
974 memset(&msg, 0, sizeof(msg));
975 msg.cmd = NPE_FW_SETFIREWALLMODE;
976 msg.eth_id = port->id;
977 if (npe_send_recv_message(port->npe, &msg, "ETH_SET_FIREWALL_MODE"))
978 return -EIO;
979
980 if ((err = request_queues(port)) != 0)
981 return err;
982
983 if ((err = init_queues(port)) != 0) {
984 destroy_queues(port);
985 release_queues(port);
986 return err;
987 }
988
989 for (i = 0; i < ETH_ALEN; i++)
990 __raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
991 __raw_writel(0x08, &port->regs->random_seed);
992 __raw_writel(0x12, &port->regs->partial_empty_threshold);
993 __raw_writel(0x30, &port->regs->partial_full_threshold);
994 __raw_writel(0x08, &port->regs->tx_start_bytes);
995 __raw_writel(0x15, &port->regs->tx_deferral);
996 __raw_writel(0x08, &port->regs->tx_2part_deferral[0]);
997 __raw_writel(0x07, &port->regs->tx_2part_deferral[1]);
998 __raw_writel(0x80, &port->regs->slot_time);
999 __raw_writel(0x01, &port->regs->int_clock_threshold);
1000
1001 /* Populate queues with buffers, no failure after this point */
1002 for (i = 0; i < TX_DESCS; i++)
1003 queue_put_desc(port->plat->txreadyq,
1004 tx_desc_phys(port, i), tx_desc_ptr(port, i));
1005
1006 for (i = 0; i < RX_DESCS; i++)
1007 queue_put_desc(RXFREE_QUEUE(port->id),
1008 rx_desc_phys(port, i), rx_desc_ptr(port, i));
1009
1010 __raw_writel(TX_CNTRL1_RETRIES, &port->regs->tx_control[1]);
1011 __raw_writel(DEFAULT_TX_CNTRL0, &port->regs->tx_control[0]);
1012 __raw_writel(0, &port->regs->rx_control[1]);
1013 __raw_writel(DEFAULT_RX_CNTRL0, &port->regs->rx_control[0]);
1014
1015 napi_enable(&port->napi);
1016 phy_check_media(port, 1);
1017 eth_set_mcast_list(dev);
1018 netif_start_queue(dev);
1019 schedule_delayed_work(&port->mdio_thread, MDIO_INTERVAL);
1020
1021 qmgr_set_irq(port->plat->rxq, QUEUE_IRQ_SRC_NOT_EMPTY,
1022 eth_rx_irq, dev);
1023 if (!ports_open) {
1024 qmgr_set_irq(TXDONE_QUEUE, QUEUE_IRQ_SRC_NOT_EMPTY,
1025 eth_txdone_irq, NULL);
1026 qmgr_enable_irq(TXDONE_QUEUE);
1027 }
1028 ports_open++;
1029 /* we may already have RX data, enables IRQ */
1030 netif_rx_schedule(dev, &port->napi);
1031 return 0;
1032}
1033
1034static int eth_close(struct net_device *dev)
1035{
1036 struct port *port = netdev_priv(dev);
1037 struct msg msg;
1038 int buffs = RX_DESCS; /* allocated RX buffers */
1039 int i;
1040
1041 ports_open--;
1042 qmgr_disable_irq(port->plat->rxq);
1043 napi_disable(&port->napi);
1044 netif_stop_queue(dev);
1045
1046 while (queue_get_desc(RXFREE_QUEUE(port->id), port, 0) >= 0)
1047 buffs--;
1048
1049 memset(&msg, 0, sizeof(msg));
1050 msg.cmd = NPE_SETLOOPBACK_MODE;
1051 msg.eth_id = port->id;
1052 msg.byte3 = 1;
1053 if (npe_send_recv_message(port->npe, &msg, "ETH_ENABLE_LOOPBACK"))
1054 printk(KERN_CRIT "%s: unable to enable loopback\n", dev->name);
1055
1056 i = 0;
1057 do { /* drain RX buffers */
1058 while (queue_get_desc(port->plat->rxq, port, 0) >= 0)
1059 buffs--;
1060 if (!buffs)
1061 break;
1062 if (qmgr_stat_empty(TX_QUEUE(port->id))) {
1063 /* we have to inject some packet */
1064 struct desc *desc;
1065 u32 phys;
1066 int n = queue_get_desc(port->plat->txreadyq, port, 1);
1067 BUG_ON(n < 0);
1068 desc = tx_desc_ptr(port, n);
1069 phys = tx_desc_phys(port, n);
1070 desc->buf_len = desc->pkt_len = 1;
1071 wmb();
1072 queue_put_desc(TX_QUEUE(port->id), phys, desc);
1073 }
1074 udelay(1);
1075 } while (++i < MAX_CLOSE_WAIT);
1076
1077 if (buffs)
1078 printk(KERN_CRIT "%s: unable to drain RX queue, %i buffer(s)"
1079 " left in NPE\n", dev->name, buffs);
1080#if DEBUG_CLOSE
1081 if (!buffs)
1082 printk(KERN_DEBUG "Draining RX queue took %i cycles\n", i);
1083#endif
1084
1085 buffs = TX_DESCS;
1086 while (queue_get_desc(TX_QUEUE(port->id), port, 1) >= 0)
1087 buffs--; /* cancel TX */
1088
1089 i = 0;
1090 do {
1091 while (queue_get_desc(port->plat->txreadyq, port, 1) >= 0)
1092 buffs--;
1093 if (!buffs)
1094 break;
1095 } while (++i < MAX_CLOSE_WAIT);
1096
1097 if (buffs)
1098 printk(KERN_CRIT "%s: unable to drain TX queue, %i buffer(s) "
1099 "left in NPE\n", dev->name, buffs);
1100#if DEBUG_CLOSE
1101 if (!buffs)
1102 printk(KERN_DEBUG "Draining TX queues took %i cycles\n", i);
1103#endif
1104
1105 msg.byte3 = 0;
1106 if (npe_send_recv_message(port->npe, &msg, "ETH_DISABLE_LOOPBACK"))
1107 printk(KERN_CRIT "%s: unable to disable loopback\n",
1108 dev->name);
1109
1110 port->mii_bmcr = mdio_read(dev, port->plat->phy, MII_BMCR) &
1111 ~(BMCR_RESET | BMCR_PDOWN); /* may have been altered */
1112 mdio_write(dev, port->plat->phy, MII_BMCR,
1113 port->mii_bmcr | BMCR_PDOWN);
1114
1115 if (!ports_open)
1116 qmgr_disable_irq(TXDONE_QUEUE);
1117 cancel_rearming_delayed_work(&port->mdio_thread);
1118 destroy_queues(port);
1119 release_queues(port);
1120 return 0;
1121}
1122
1123static int __devinit eth_init_one(struct platform_device *pdev)
1124{
1125 struct port *port;
1126 struct net_device *dev;
1127 struct eth_plat_info *plat = pdev->dev.platform_data;
1128 u32 regs_phys;
1129 int err;
1130
1131 if (!(dev = alloc_etherdev(sizeof(struct port))))
1132 return -ENOMEM;
1133
1134 SET_NETDEV_DEV(dev, &pdev->dev);
1135 port = netdev_priv(dev);
1136 port->netdev = dev;
1137 port->id = pdev->id;
1138
1139 switch (port->id) {
1140 case IXP4XX_ETH_NPEA:
1141 port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
1142 regs_phys = IXP4XX_EthA_BASE_PHYS;
1143 break;
1144 case IXP4XX_ETH_NPEB:
1145 port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
1146 regs_phys = IXP4XX_EthB_BASE_PHYS;
1147 break;
1148 case IXP4XX_ETH_NPEC:
1149 port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
1150 regs_phys = IXP4XX_EthC_BASE_PHYS;
1151 break;
1152 default:
1153 err = -ENOSYS;
1154 goto err_free;
1155 }
1156
1157 dev->open = eth_open;
1158 dev->hard_start_xmit = eth_xmit;
1159 dev->stop = eth_close;
1160 dev->get_stats = eth_stats;
1161 dev->do_ioctl = eth_ioctl;
1162 dev->set_multicast_list = eth_set_mcast_list;
1163 dev->tx_queue_len = 100;
1164
1165 netif_napi_add(dev, &port->napi, eth_poll, NAPI_WEIGHT);
1166
1167 if (!(port->npe = npe_request(NPE_ID(port->id)))) {
1168 err = -EIO;
1169 goto err_free;
1170 }
1171
1172 if (register_netdev(dev)) {
1173 err = -EIO;
1174 goto err_npe_rel;
1175 }
1176
1177 port->mem_res = request_mem_region(regs_phys, REGS_SIZE, dev->name);
1178 if (!port->mem_res) {
1179 err = -EBUSY;
1180 goto err_unreg;
1181 }
1182
1183 port->plat = plat;
1184 npe_port_tab[NPE_ID(port->id)] = port;
1185 memcpy(dev->dev_addr, plat->hwaddr, ETH_ALEN);
1186
1187 platform_set_drvdata(pdev, dev);
1188
1189 __raw_writel(DEFAULT_CORE_CNTRL | CORE_RESET,
1190 &port->regs->core_control);
1191 udelay(50);
1192 __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
1193 udelay(50);
1194
1195 port->mii.dev = dev;
1196 port->mii.mdio_read = mdio_read;
1197 port->mii.mdio_write = mdio_write;
1198 port->mii.phy_id = plat->phy;
1199 port->mii.phy_id_mask = 0x1F;
1200 port->mii.reg_num_mask = 0x1F;
1201
1202 printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
1203 npe_name(port->npe));
1204
1205 phy_reset(dev, plat->phy);
1206 port->mii_bmcr = mdio_read(dev, plat->phy, MII_BMCR) &
1207 ~(BMCR_RESET | BMCR_PDOWN);
1208 mdio_write(dev, plat->phy, MII_BMCR, port->mii_bmcr | BMCR_PDOWN);
1209
1210 INIT_DELAYED_WORK(&port->mdio_thread, mdio_thread);
1211 return 0;
1212
1213err_unreg:
1214 unregister_netdev(dev);
1215err_npe_rel:
1216 npe_release(port->npe);
1217err_free:
1218 free_netdev(dev);
1219 return err;
1220}
1221
1222static int __devexit eth_remove_one(struct platform_device *pdev)
1223{
1224 struct net_device *dev = platform_get_drvdata(pdev);
1225 struct port *port = netdev_priv(dev);
1226
1227 unregister_netdev(dev);
1228 npe_port_tab[NPE_ID(port->id)] = NULL;
1229 platform_set_drvdata(pdev, NULL);
1230 npe_release(port->npe);
1231 release_resource(port->mem_res);
1232 free_netdev(dev);
1233 return 0;
1234}
1235
1236static struct platform_driver drv = {
1237 .driver.name = DRV_NAME,
1238 .probe = eth_init_one,
1239 .remove = eth_remove_one,
1240};
1241
1242static int __init eth_init_module(void)
1243{
1244 if (!(ixp4xx_read_feature_bits() & IXP4XX_FEATURE_NPEB_ETH0))
1245 return -ENOSYS;
1246
1247 /* All MII PHY accesses use NPE-B Ethernet registers */
1248 spin_lock_init(&mdio_lock);
1249 mdio_regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
1250 __raw_writel(DEFAULT_CORE_CNTRL, &mdio_regs->core_control);
1251
1252 return platform_driver_register(&drv);
1253}
1254
1255static void __exit eth_cleanup_module(void)
1256{
1257 platform_driver_unregister(&drv);
1258}
1259
1260MODULE_AUTHOR("Krzysztof Halasa");
1261MODULE_DESCRIPTION("Intel IXP4xx Ethernet driver");
1262MODULE_LICENSE("GPL v2");
1263MODULE_ALIAS("platform:ixp4xx_eth");
1264module_init(eth_init_module);
1265module_exit(eth_cleanup_module);
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 4fec8581bfd7..89c0018132ec 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -27,6 +27,7 @@
27#include <linux/phy.h> 27#include <linux/phy.h>
28#include <linux/netdevice.h> 28#include <linux/netdevice.h>
29#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
30#include <linux/ethtool.h>
30#include <linux/skbuff.h> 31#include <linux/skbuff.h>
31#include <linux/platform_device.h> 32#include <linux/platform_device.h>
32 33
@@ -42,7 +43,7 @@
42#define DRV_NAME "bfin_mac" 43#define DRV_NAME "bfin_mac"
43#define DRV_VERSION "1.1" 44#define DRV_VERSION "1.1"
44#define DRV_AUTHOR "Bryan Wu, Luke Yang" 45#define DRV_AUTHOR "Bryan Wu, Luke Yang"
45#define DRV_DESC "Blackfin BF53[67] BF527 on-chip Ethernet MAC driver" 46#define DRV_DESC "Blackfin on-chip Ethernet MAC driver"
46 47
47MODULE_AUTHOR(DRV_AUTHOR); 48MODULE_AUTHOR(DRV_AUTHOR);
48MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
@@ -73,8 +74,14 @@ static struct net_dma_desc_tx *current_tx_ptr;
73static struct net_dma_desc_tx *tx_desc; 74static struct net_dma_desc_tx *tx_desc;
74static struct net_dma_desc_rx *rx_desc; 75static struct net_dma_desc_rx *rx_desc;
75 76
76static void bf537mac_disable(void); 77#if defined(CONFIG_BFIN_MAC_RMII)
77static void bf537mac_enable(void); 78static u16 pin_req[] = P_RMII0;
79#else
80static u16 pin_req[] = P_MII0;
81#endif
82
83static void bfin_mac_disable(void);
84static void bfin_mac_enable(void);
78 85
79static void desc_list_free(void) 86static void desc_list_free(void)
80{ 87{
@@ -243,27 +250,6 @@ init_error:
243 250
244/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/ 251/*---PHY CONTROL AND CONFIGURATION-----------------------------------------*/
245 252
246/* Set FER regs to MUX in Ethernet pins */
247static int setup_pin_mux(int action)
248{
249#if defined(CONFIG_BFIN_MAC_RMII)
250 u16 pin_req[] = P_RMII0;
251#else
252 u16 pin_req[] = P_MII0;
253#endif
254
255 if (action) {
256 if (peripheral_request_list(pin_req, DRV_NAME)) {
257 printk(KERN_ERR DRV_NAME
258 ": Requesting Peripherals failed\n");
259 return -EFAULT;
260 }
261 } else
262 peripheral_free_list(pin_req);
263
264 return 0;
265}
266
267/* 253/*
268 * MII operations 254 * MII operations
269 */ 255 */
@@ -322,9 +308,9 @@ static int mdiobus_reset(struct mii_bus *bus)
322 return 0; 308 return 0;
323} 309}
324 310
325static void bf537_adjust_link(struct net_device *dev) 311static void bfin_mac_adjust_link(struct net_device *dev)
326{ 312{
327 struct bf537mac_local *lp = netdev_priv(dev); 313 struct bfin_mac_local *lp = netdev_priv(dev);
328 struct phy_device *phydev = lp->phydev; 314 struct phy_device *phydev = lp->phydev;
329 unsigned long flags; 315 unsigned long flags;
330 int new_state = 0; 316 int new_state = 0;
@@ -395,7 +381,7 @@ static void bf537_adjust_link(struct net_device *dev)
395 381
396static int mii_probe(struct net_device *dev) 382static int mii_probe(struct net_device *dev)
397{ 383{
398 struct bf537mac_local *lp = netdev_priv(dev); 384 struct bfin_mac_local *lp = netdev_priv(dev);
399 struct phy_device *phydev = NULL; 385 struct phy_device *phydev = NULL;
400 unsigned short sysctl; 386 unsigned short sysctl;
401 int i; 387 int i;
@@ -431,10 +417,10 @@ static int mii_probe(struct net_device *dev)
431 } 417 }
432 418
433#if defined(CONFIG_BFIN_MAC_RMII) 419#if defined(CONFIG_BFIN_MAC_RMII)
434 phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, 420 phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0,
435 PHY_INTERFACE_MODE_RMII); 421 PHY_INTERFACE_MODE_RMII);
436#else 422#else
437 phydev = phy_connect(dev, phydev->dev.bus_id, &bf537_adjust_link, 0, 423 phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0,
438 PHY_INTERFACE_MODE_MII); 424 PHY_INTERFACE_MODE_MII);
439#endif 425#endif
440 426
@@ -469,6 +455,51 @@ static int mii_probe(struct net_device *dev)
469 return 0; 455 return 0;
470} 456}
471 457
458/*
459 * Ethtool support
460 */
461
462static int
463bfin_mac_ethtool_getsettings(struct net_device *dev, struct ethtool_cmd *cmd)
464{
465 struct bfin_mac_local *lp = netdev_priv(dev);
466
467 if (lp->phydev)
468 return phy_ethtool_gset(lp->phydev, cmd);
469
470 return -EINVAL;
471}
472
473static int
474bfin_mac_ethtool_setsettings(struct net_device *dev, struct ethtool_cmd *cmd)
475{
476 struct bfin_mac_local *lp = netdev_priv(dev);
477
478 if (!capable(CAP_NET_ADMIN))
479 return -EPERM;
480
481 if (lp->phydev)
482 return phy_ethtool_sset(lp->phydev, cmd);
483
484 return -EINVAL;
485}
486
487static void bfin_mac_ethtool_getdrvinfo(struct net_device *dev,
488 struct ethtool_drvinfo *info)
489{
490 strcpy(info->driver, DRV_NAME);
491 strcpy(info->version, DRV_VERSION);
492 strcpy(info->fw_version, "N/A");
493 strcpy(info->bus_info, dev->dev.bus_id);
494}
495
496static struct ethtool_ops bfin_mac_ethtool_ops = {
497 .get_settings = bfin_mac_ethtool_getsettings,
498 .set_settings = bfin_mac_ethtool_setsettings,
499 .get_link = ethtool_op_get_link,
500 .get_drvinfo = bfin_mac_ethtool_getdrvinfo,
501};
502
472/**************************************************************************/ 503/**************************************************************************/
473void setup_system_regs(struct net_device *dev) 504void setup_system_regs(struct net_device *dev)
474{ 505{
@@ -511,7 +542,7 @@ static void setup_mac_addr(u8 *mac_addr)
511 bfin_write_EMAC_ADDRHI(addr_hi); 542 bfin_write_EMAC_ADDRHI(addr_hi);
512} 543}
513 544
514static int bf537mac_set_mac_address(struct net_device *dev, void *p) 545static int bfin_mac_set_mac_address(struct net_device *dev, void *p)
515{ 546{
516 struct sockaddr *addr = p; 547 struct sockaddr *addr = p;
517 if (netif_running(dev)) 548 if (netif_running(dev))
@@ -573,7 +604,7 @@ adjust_head:
573 604
574} 605}
575 606
576static int bf537mac_hard_start_xmit(struct sk_buff *skb, 607static int bfin_mac_hard_start_xmit(struct sk_buff *skb,
577 struct net_device *dev) 608 struct net_device *dev)
578{ 609{
579 unsigned int data; 610 unsigned int data;
@@ -631,7 +662,7 @@ out:
631 return 0; 662 return 0;
632} 663}
633 664
634static void bf537mac_rx(struct net_device *dev) 665static void bfin_mac_rx(struct net_device *dev)
635{ 666{
636 struct sk_buff *skb, *new_skb; 667 struct sk_buff *skb, *new_skb;
637 unsigned short len; 668 unsigned short len;
@@ -680,7 +711,7 @@ out:
680} 711}
681 712
682/* interrupt routine to handle rx and error signal */ 713/* interrupt routine to handle rx and error signal */
683static irqreturn_t bf537mac_interrupt(int irq, void *dev_id) 714static irqreturn_t bfin_mac_interrupt(int irq, void *dev_id)
684{ 715{
685 struct net_device *dev = dev_id; 716 struct net_device *dev = dev_id;
686 int number = 0; 717 int number = 0;
@@ -700,21 +731,21 @@ get_one_packet:
700 } 731 }
701 732
702real_rx: 733real_rx:
703 bf537mac_rx(dev); 734 bfin_mac_rx(dev);
704 number++; 735 number++;
705 goto get_one_packet; 736 goto get_one_packet;
706} 737}
707 738
708#ifdef CONFIG_NET_POLL_CONTROLLER 739#ifdef CONFIG_NET_POLL_CONTROLLER
709static void bf537mac_poll(struct net_device *dev) 740static void bfin_mac_poll(struct net_device *dev)
710{ 741{
711 disable_irq(IRQ_MAC_RX); 742 disable_irq(IRQ_MAC_RX);
712 bf537mac_interrupt(IRQ_MAC_RX, dev); 743 bfin_mac_interrupt(IRQ_MAC_RX, dev);
713 enable_irq(IRQ_MAC_RX); 744 enable_irq(IRQ_MAC_RX);
714} 745}
715#endif /* CONFIG_NET_POLL_CONTROLLER */ 746#endif /* CONFIG_NET_POLL_CONTROLLER */
716 747
717static void bf537mac_disable(void) 748static void bfin_mac_disable(void)
718{ 749{
719 unsigned int opmode; 750 unsigned int opmode;
720 751
@@ -728,7 +759,7 @@ static void bf537mac_disable(void)
728/* 759/*
729 * Enable Interrupts, Receive, and Transmit 760 * Enable Interrupts, Receive, and Transmit
730 */ 761 */
731static void bf537mac_enable(void) 762static void bfin_mac_enable(void)
732{ 763{
733 u32 opmode; 764 u32 opmode;
734 765
@@ -766,23 +797,23 @@ static void bf537mac_enable(void)
766} 797}
767 798
768/* Our watchdog timed out. Called by the networking layer */ 799/* Our watchdog timed out. Called by the networking layer */
769static void bf537mac_timeout(struct net_device *dev) 800static void bfin_mac_timeout(struct net_device *dev)
770{ 801{
771 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 802 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
772 803
773 bf537mac_disable(); 804 bfin_mac_disable();
774 805
775 /* reset tx queue */ 806 /* reset tx queue */
776 tx_list_tail = tx_list_head->next; 807 tx_list_tail = tx_list_head->next;
777 808
778 bf537mac_enable(); 809 bfin_mac_enable();
779 810
780 /* We can accept TX packets again */ 811 /* We can accept TX packets again */
781 dev->trans_start = jiffies; 812 dev->trans_start = jiffies;
782 netif_wake_queue(dev); 813 netif_wake_queue(dev);
783} 814}
784 815
785static void bf537mac_multicast_hash(struct net_device *dev) 816static void bfin_mac_multicast_hash(struct net_device *dev)
786{ 817{
787 u32 emac_hashhi, emac_hashlo; 818 u32 emac_hashhi, emac_hashlo;
788 struct dev_mc_list *dmi = dev->mc_list; 819 struct dev_mc_list *dmi = dev->mc_list;
@@ -821,7 +852,7 @@ static void bf537mac_multicast_hash(struct net_device *dev)
821 * promiscuous mode (for TCPDUMP and cousins) or accept 852 * promiscuous mode (for TCPDUMP and cousins) or accept
822 * a select set of multicast packets 853 * a select set of multicast packets
823 */ 854 */
824static void bf537mac_set_multicast_list(struct net_device *dev) 855static void bfin_mac_set_multicast_list(struct net_device *dev)
825{ 856{
826 u32 sysctl; 857 u32 sysctl;
827 858
@@ -840,7 +871,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev)
840 sysctl = bfin_read_EMAC_OPMODE(); 871 sysctl = bfin_read_EMAC_OPMODE();
841 sysctl |= HM; 872 sysctl |= HM;
842 bfin_write_EMAC_OPMODE(sysctl); 873 bfin_write_EMAC_OPMODE(sysctl);
843 bf537mac_multicast_hash(dev); 874 bfin_mac_multicast_hash(dev);
844 } else { 875 } else {
845 /* clear promisc or multicast mode */ 876 /* clear promisc or multicast mode */
846 sysctl = bfin_read_EMAC_OPMODE(); 877 sysctl = bfin_read_EMAC_OPMODE();
@@ -852,7 +883,7 @@ static void bf537mac_set_multicast_list(struct net_device *dev)
852/* 883/*
853 * this puts the device in an inactive state 884 * this puts the device in an inactive state
854 */ 885 */
855static void bf537mac_shutdown(struct net_device *dev) 886static void bfin_mac_shutdown(struct net_device *dev)
856{ 887{
857 /* Turn off the EMAC */ 888 /* Turn off the EMAC */
858 bfin_write_EMAC_OPMODE(0x00000000); 889 bfin_write_EMAC_OPMODE(0x00000000);
@@ -866,9 +897,9 @@ static void bf537mac_shutdown(struct net_device *dev)
866 * 897 *
867 * Set up everything, reset the card, etc.. 898 * Set up everything, reset the card, etc..
868 */ 899 */
869static int bf537mac_open(struct net_device *dev) 900static int bfin_mac_open(struct net_device *dev)
870{ 901{
871 struct bf537mac_local *lp = netdev_priv(dev); 902 struct bfin_mac_local *lp = netdev_priv(dev);
872 int retval; 903 int retval;
873 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 904 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
874 905
@@ -891,8 +922,8 @@ static int bf537mac_open(struct net_device *dev)
891 phy_start(lp->phydev); 922 phy_start(lp->phydev);
892 phy_write(lp->phydev, MII_BMCR, BMCR_RESET); 923 phy_write(lp->phydev, MII_BMCR, BMCR_RESET);
893 setup_system_regs(dev); 924 setup_system_regs(dev);
894 bf537mac_disable(); 925 bfin_mac_disable();
895 bf537mac_enable(); 926 bfin_mac_enable();
896 pr_debug("hardware init finished\n"); 927 pr_debug("hardware init finished\n");
897 netif_start_queue(dev); 928 netif_start_queue(dev);
898 netif_carrier_on(dev); 929 netif_carrier_on(dev);
@@ -906,9 +937,9 @@ static int bf537mac_open(struct net_device *dev)
906 * and not talk to the outside world. Caused by 937 * and not talk to the outside world. Caused by
907 * an 'ifconfig ethX down' 938 * an 'ifconfig ethX down'
908 */ 939 */
909static int bf537mac_close(struct net_device *dev) 940static int bfin_mac_close(struct net_device *dev)
910{ 941{
911 struct bf537mac_local *lp = netdev_priv(dev); 942 struct bfin_mac_local *lp = netdev_priv(dev);
912 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 943 pr_debug("%s: %s\n", dev->name, __FUNCTION__);
913 944
914 netif_stop_queue(dev); 945 netif_stop_queue(dev);
@@ -918,7 +949,7 @@ static int bf537mac_close(struct net_device *dev)
918 phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN); 949 phy_write(lp->phydev, MII_BMCR, BMCR_PDOWN);
919 950
920 /* clear everything */ 951 /* clear everything */
921 bf537mac_shutdown(dev); 952 bfin_mac_shutdown(dev);
922 953
923 /* free the rx/tx buffers */ 954 /* free the rx/tx buffers */
924 desc_list_free(); 955 desc_list_free();
@@ -926,46 +957,59 @@ static int bf537mac_close(struct net_device *dev)
926 return 0; 957 return 0;
927} 958}
928 959
929static int __init bf537mac_probe(struct net_device *dev) 960static int __init bfin_mac_probe(struct platform_device *pdev)
930{ 961{
931 struct bf537mac_local *lp = netdev_priv(dev); 962 struct net_device *ndev;
932 int retval; 963 struct bfin_mac_local *lp;
933 int i; 964 int rc, i;
965
966 ndev = alloc_etherdev(sizeof(struct bfin_mac_local));
967 if (!ndev) {
968 dev_err(&pdev->dev, "Cannot allocate net device!\n");
969 return -ENOMEM;
970 }
971
972 SET_NETDEV_DEV(ndev, &pdev->dev);
973 platform_set_drvdata(pdev, ndev);
974 lp = netdev_priv(ndev);
934 975
935 /* Grab the MAC address in the MAC */ 976 /* Grab the MAC address in the MAC */
936 *(__le32 *) (&(dev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO()); 977 *(__le32 *) (&(ndev->dev_addr[0])) = cpu_to_le32(bfin_read_EMAC_ADDRLO());
937 *(__le16 *) (&(dev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI()); 978 *(__le16 *) (&(ndev->dev_addr[4])) = cpu_to_le16((u16) bfin_read_EMAC_ADDRHI());
938 979
939 /* probe mac */ 980 /* probe mac */
940 /*todo: how to proble? which is revision_register */ 981 /*todo: how to proble? which is revision_register */
941 bfin_write_EMAC_ADDRLO(0x12345678); 982 bfin_write_EMAC_ADDRLO(0x12345678);
942 if (bfin_read_EMAC_ADDRLO() != 0x12345678) { 983 if (bfin_read_EMAC_ADDRLO() != 0x12345678) {
943 pr_debug("can't detect bf537 mac!\n"); 984 dev_err(&pdev->dev, "Cannot detect Blackfin on-chip ethernet MAC controller!\n");
944 retval = -ENODEV; 985 rc = -ENODEV;
945 goto err_out; 986 goto out_err_probe_mac;
946 } 987 }
947 988
948 /* set the GPIO pins to Ethernet mode */ 989 /* set the GPIO pins to Ethernet mode */
949 retval = setup_pin_mux(1); 990 rc = peripheral_request_list(pin_req, DRV_NAME);
950 if (retval) 991 if (rc) {
951 return retval; 992 dev_err(&pdev->dev, "Requesting peripherals failed!\n");
952 993 rc = -EFAULT;
953 /*Is it valid? (Did bootloader initialize it?) */ 994 goto out_err_setup_pin_mux;
954 if (!is_valid_ether_addr(dev->dev_addr)) {
955 /* Grab the MAC from the board somehow - this is done in the
956 arch/blackfin/mach-bf537/boards/eth_mac.c */
957 bfin_get_ether_addr(dev->dev_addr);
958 } 995 }
959 996
997 /*
998 * Is it valid? (Did bootloader initialize it?)
999 * Grab the MAC from the board somehow
1000 * this is done in the arch/blackfin/mach-bfxxx/boards/eth_mac.c
1001 */
1002 if (!is_valid_ether_addr(ndev->dev_addr))
1003 bfin_get_ether_addr(ndev->dev_addr);
1004
960 /* If still not valid, get a random one */ 1005 /* If still not valid, get a random one */
961 if (!is_valid_ether_addr(dev->dev_addr)) { 1006 if (!is_valid_ether_addr(ndev->dev_addr))
962 random_ether_addr(dev->dev_addr); 1007 random_ether_addr(ndev->dev_addr);
963 }
964 1008
965 setup_mac_addr(dev->dev_addr); 1009 setup_mac_addr(ndev->dev_addr);
966 1010
967 /* MDIO bus initial */ 1011 /* MDIO bus initial */
968 lp->mii_bus.priv = dev; 1012 lp->mii_bus.priv = ndev;
969 lp->mii_bus.read = mdiobus_read; 1013 lp->mii_bus.read = mdiobus_read;
970 lp->mii_bus.write = mdiobus_write; 1014 lp->mii_bus.write = mdiobus_write;
971 lp->mii_bus.reset = mdiobus_reset; 1015 lp->mii_bus.reset = mdiobus_reset;
@@ -975,86 +1019,86 @@ static int __init bf537mac_probe(struct net_device *dev)
975 for (i = 0; i < PHY_MAX_ADDR; ++i) 1019 for (i = 0; i < PHY_MAX_ADDR; ++i)
976 lp->mii_bus.irq[i] = PHY_POLL; 1020 lp->mii_bus.irq[i] = PHY_POLL;
977 1021
978 mdiobus_register(&lp->mii_bus); 1022 rc = mdiobus_register(&lp->mii_bus);
1023 if (rc) {
1024 dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
1025 goto out_err_mdiobus_register;
1026 }
979 1027
980 retval = mii_probe(dev); 1028 rc = mii_probe(ndev);
981 if (retval) 1029 if (rc) {
982 return retval; 1030 dev_err(&pdev->dev, "MII Probe failed!\n");
1031 goto out_err_mii_probe;
1032 }
983 1033
984 /* Fill in the fields of the device structure with ethernet values. */ 1034 /* Fill in the fields of the device structure with ethernet values. */
985 ether_setup(dev); 1035 ether_setup(ndev);
986 1036
987 dev->open = bf537mac_open; 1037 ndev->open = bfin_mac_open;
988 dev->stop = bf537mac_close; 1038 ndev->stop = bfin_mac_close;
989 dev->hard_start_xmit = bf537mac_hard_start_xmit; 1039 ndev->hard_start_xmit = bfin_mac_hard_start_xmit;
990 dev->set_mac_address = bf537mac_set_mac_address; 1040 ndev->set_mac_address = bfin_mac_set_mac_address;
991 dev->tx_timeout = bf537mac_timeout; 1041 ndev->tx_timeout = bfin_mac_timeout;
992 dev->set_multicast_list = bf537mac_set_multicast_list; 1042 ndev->set_multicast_list = bfin_mac_set_multicast_list;
993#ifdef CONFIG_NET_POLL_CONTROLLER 1043#ifdef CONFIG_NET_POLL_CONTROLLER
994 dev->poll_controller = bf537mac_poll; 1044 ndev->poll_controller = bfin_mac_poll;
995#endif 1045#endif
1046 ndev->ethtool_ops = &bfin_mac_ethtool_ops;
996 1047
997 spin_lock_init(&lp->lock); 1048 spin_lock_init(&lp->lock);
998 1049
999 /* now, enable interrupts */ 1050 /* now, enable interrupts */
1000 /* register irq handler */ 1051 /* register irq handler */
1001 if (request_irq 1052 rc = request_irq(IRQ_MAC_RX, bfin_mac_interrupt,
1002 (IRQ_MAC_RX, bf537mac_interrupt, IRQF_DISABLED | IRQF_SHARED, 1053 IRQF_DISABLED | IRQF_SHARED, "EMAC_RX", ndev);
1003 "EMAC_RX", dev)) { 1054 if (rc) {
1004 printk(KERN_WARNING DRV_NAME 1055 dev_err(&pdev->dev, "Cannot request Blackfin MAC RX IRQ!\n");
1005 ": Unable to attach BlackFin MAC RX interrupt\n"); 1056 rc = -EBUSY;
1006 return -EBUSY; 1057 goto out_err_request_irq;
1007 } 1058 }
1008 1059
1009 1060 rc = register_netdev(ndev);
1010 retval = register_netdev(dev); 1061 if (rc) {
1011 if (retval == 0) { 1062 dev_err(&pdev->dev, "Cannot register net device!\n");
1012 /* now, print out the card info, in a short format.. */ 1063 goto out_err_reg_ndev;
1013 printk(KERN_INFO "%s: Version %s, %s\n",
1014 DRV_NAME, DRV_VERSION, DRV_DESC);
1015 }
1016
1017err_out:
1018 return retval;
1019}
1020
1021static int bfin_mac_probe(struct platform_device *pdev)
1022{
1023 struct net_device *ndev;
1024
1025 ndev = alloc_etherdev(sizeof(struct bf537mac_local));
1026 if (!ndev) {
1027 printk(KERN_WARNING DRV_NAME ": could not allocate device\n");
1028 return -ENOMEM;
1029 } 1064 }
1030 1065
1031 SET_NETDEV_DEV(ndev, &pdev->dev); 1066 /* now, print out the card info, in a short format.. */
1067 dev_info(&pdev->dev, "%s, Version %s\n", DRV_DESC, DRV_VERSION);
1032 1068
1033 platform_set_drvdata(pdev, ndev); 1069 return 0;
1034 1070
1035 if (bf537mac_probe(ndev) != 0) { 1071out_err_reg_ndev:
1036 platform_set_drvdata(pdev, NULL); 1072 free_irq(IRQ_MAC_RX, ndev);
1037 free_netdev(ndev); 1073out_err_request_irq:
1038 printk(KERN_WARNING DRV_NAME ": not found\n"); 1074out_err_mii_probe:
1039 return -ENODEV; 1075 mdiobus_unregister(&lp->mii_bus);
1040 } 1076out_err_mdiobus_register:
1077 peripheral_free_list(pin_req);
1078out_err_setup_pin_mux:
1079out_err_probe_mac:
1080 platform_set_drvdata(pdev, NULL);
1081 free_netdev(ndev);
1041 1082
1042 return 0; 1083 return rc;
1043} 1084}
1044 1085
1045static int bfin_mac_remove(struct platform_device *pdev) 1086static int bfin_mac_remove(struct platform_device *pdev)
1046{ 1087{
1047 struct net_device *ndev = platform_get_drvdata(pdev); 1088 struct net_device *ndev = platform_get_drvdata(pdev);
1089 struct bfin_mac_local *lp = netdev_priv(ndev);
1048 1090
1049 platform_set_drvdata(pdev, NULL); 1091 platform_set_drvdata(pdev, NULL);
1050 1092
1093 mdiobus_unregister(&lp->mii_bus);
1094
1051 unregister_netdev(ndev); 1095 unregister_netdev(ndev);
1052 1096
1053 free_irq(IRQ_MAC_RX, ndev); 1097 free_irq(IRQ_MAC_RX, ndev);
1054 1098
1055 free_netdev(ndev); 1099 free_netdev(ndev);
1056 1100
1057 setup_pin_mux(0); 1101 peripheral_free_list(pin_req);
1058 1102
1059 return 0; 1103 return 0;
1060} 1104}
@@ -1065,7 +1109,7 @@ static int bfin_mac_suspend(struct platform_device *pdev, pm_message_t mesg)
1065 struct net_device *net_dev = platform_get_drvdata(pdev); 1109 struct net_device *net_dev = platform_get_drvdata(pdev);
1066 1110
1067 if (netif_running(net_dev)) 1111 if (netif_running(net_dev))
1068 bf537mac_close(net_dev); 1112 bfin_mac_close(net_dev);
1069 1113
1070 return 0; 1114 return 0;
1071} 1115}
@@ -1075,7 +1119,7 @@ static int bfin_mac_resume(struct platform_device *pdev)
1075 struct net_device *net_dev = platform_get_drvdata(pdev); 1119 struct net_device *net_dev = platform_get_drvdata(pdev);
1076 1120
1077 if (netif_running(net_dev)) 1121 if (netif_running(net_dev))
1078 bf537mac_open(net_dev); 1122 bfin_mac_open(net_dev);
1079 1123
1080 return 0; 1124 return 0;
1081} 1125}
diff --git a/drivers/net/bfin_mac.h b/drivers/net/bfin_mac.h
index f774d5a36942..beff51064ff4 100644
--- a/drivers/net/bfin_mac.h
+++ b/drivers/net/bfin_mac.h
@@ -49,7 +49,7 @@ struct net_dma_desc_tx {
49 struct status_area_tx status; 49 struct status_area_tx status;
50}; 50};
51 51
52struct bf537mac_local { 52struct bfin_mac_local {
53 /* 53 /*
54 * these are things that the kernel wants me to keep, so users 54 * these are things that the kernel wants me to keep, so users
55 * can find out semi-useless statistics of how well the card is 55 * can find out semi-useless statistics of how well the card is
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index 83bda6ccde98..56f50491a453 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -633,7 +633,7 @@ static void __init printEEPROMInfo(struct net_device *dev)
633 printk(KERN_DEBUG " PC: %d\n", GetBit(Word,ee_PC)); 633 printk(KERN_DEBUG " PC: %d\n", GetBit(Word,ee_PC));
634 printk(KERN_DEBUG " TPE/AUI: %d\n", GetBit(Word,ee_TPE_AUI)); 634 printk(KERN_DEBUG " TPE/AUI: %d\n", GetBit(Word,ee_TPE_AUI));
635 printk(KERN_DEBUG " Jabber: %d\n", GetBit(Word,ee_Jabber)); 635 printk(KERN_DEBUG " Jabber: %d\n", GetBit(Word,ee_Jabber));
636 printk(KERN_DEBUG " AutoPort: %d\n", GetBit(!Word,ee_Jabber)); 636 printk(KERN_DEBUG " AutoPort: %d\n", !GetBit(Word,ee_AutoPort));
637 printk(KERN_DEBUG " Duplex: %d\n", GetBit(Word,ee_Duplex)); 637 printk(KERN_DEBUG " Duplex: %d\n", GetBit(Word,ee_Duplex));
638 } 638 }
639 639
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index e5e6352556fa..d21b7ab64bd1 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -491,20 +491,23 @@ static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id)
491 491
492 out_be32(&fec->ievent, ievent); /* clear pending events */ 492 out_be32(&fec->ievent, ievent); /* clear pending events */
493 493
494 if (ievent & ~(FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) { 494 /* on fifo error, soft-reset fec */
495 if (ievent & ~FEC_IEVENT_TFINT) 495 if (ievent & (FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) {
496 dev_dbg(&dev->dev, "ievent: %08x\n", ievent); 496
497 if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR))
498 dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n");
499 if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR))
500 dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n");
501
502 mpc52xx_fec_reset(dev);
503
504 netif_wake_queue(dev);
497 return IRQ_HANDLED; 505 return IRQ_HANDLED;
498 } 506 }
499 507
500 if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR)) 508 if (ievent & ~FEC_IEVENT_TFINT)
501 dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n"); 509 dev_dbg(&dev->dev, "ievent: %08x\n", ievent);
502 if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR))
503 dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n");
504 510
505 mpc52xx_fec_reset(dev);
506
507 netif_wake_queue(dev);
508 return IRQ_HANDLED; 511 return IRQ_HANDLED;
509} 512}
510 513
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 99a4b990939f..587afe7be689 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -131,8 +131,6 @@ static void free_skb_resources(struct gfar_private *priv);
131static void gfar_set_multi(struct net_device *dev); 131static void gfar_set_multi(struct net_device *dev);
132static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); 132static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
133static void gfar_configure_serdes(struct net_device *dev); 133static void gfar_configure_serdes(struct net_device *dev);
134extern int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id, int regnum, u16 value);
135extern int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum);
136#ifdef CONFIG_GFAR_NAPI 134#ifdef CONFIG_GFAR_NAPI
137static int gfar_poll(struct napi_struct *napi, int budget); 135static int gfar_poll(struct napi_struct *napi, int budget);
138#endif 136#endif
@@ -477,24 +475,30 @@ static int init_phy(struct net_device *dev)
477 return 0; 475 return 0;
478} 476}
479 477
478/*
479 * Initialize TBI PHY interface for communicating with the
480 * SERDES lynx PHY on the chip. We communicate with this PHY
481 * through the MDIO bus on each controller, treating it as a
482 * "normal" PHY at the address found in the TBIPA register. We assume
483 * that the TBIPA register is valid. Either the MDIO bus code will set
484 * it to a value that doesn't conflict with other PHYs on the bus, or the
485 * value doesn't matter, as there are no other PHYs on the bus.
486 */
480static void gfar_configure_serdes(struct net_device *dev) 487static void gfar_configure_serdes(struct net_device *dev)
481{ 488{
482 struct gfar_private *priv = netdev_priv(dev); 489 struct gfar_private *priv = netdev_priv(dev);
483 struct gfar_mii __iomem *regs = 490 struct gfar_mii __iomem *regs =
484 (void __iomem *)&priv->regs->gfar_mii_regs; 491 (void __iomem *)&priv->regs->gfar_mii_regs;
492 int tbipa = gfar_read(&priv->regs->tbipa);
485 493
486 /* Initialise TBI i/f to communicate with serdes (lynx phy) */ 494 /* Single clk mode, mii mode off(for serdes communication) */
495 gfar_local_mdio_write(regs, tbipa, MII_TBICON, TBICON_CLK_SELECT);
487 496
488 /* Single clk mode, mii mode off(for aerdes communication) */ 497 gfar_local_mdio_write(regs, tbipa, MII_ADVERTISE,
489 gfar_local_mdio_write(regs, TBIPA_VALUE, MII_TBICON, TBICON_CLK_SELECT);
490
491 /* Supported pause and full-duplex, no half-duplex */
492 gfar_local_mdio_write(regs, TBIPA_VALUE, MII_ADVERTISE,
493 ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE | 498 ADVERTISE_1000XFULL | ADVERTISE_1000XPAUSE |
494 ADVERTISE_1000XPSE_ASYM); 499 ADVERTISE_1000XPSE_ASYM);
495 500
496 /* ANEG enable, restart ANEG, full duplex mode, speed[1] set */ 501 gfar_local_mdio_write(regs, tbipa, MII_BMCR, BMCR_ANENABLE |
497 gfar_local_mdio_write(regs, TBIPA_VALUE, MII_BMCR, BMCR_ANENABLE |
498 BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000); 502 BMCR_ANRESTART | BMCR_FULLDPLX | BMCR_SPEED1000);
499} 503}
500 504
@@ -541,9 +545,6 @@ static void init_registers(struct net_device *dev)
541 545
542 /* Initialize the Minimum Frame Length Register */ 546 /* Initialize the Minimum Frame Length Register */
543 gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS); 547 gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS);
544
545 /* Assign the TBI an address which won't conflict with the PHYs */
546 gfar_write(&priv->regs->tbipa, TBIPA_VALUE);
547} 548}
548 549
549 550
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 0d0883609469..fd487be3993e 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -137,7 +137,6 @@ extern const char gfar_driver_version[];
137#define DEFAULT_RXCOUNT 0 137#define DEFAULT_RXCOUNT 0
138#endif /* CONFIG_GFAR_NAPI */ 138#endif /* CONFIG_GFAR_NAPI */
139 139
140#define TBIPA_VALUE 0x1f
141#define MIIMCFG_INIT_VALUE 0x00000007 140#define MIIMCFG_INIT_VALUE 0x00000007
142#define MIIMCFG_RESET 0x80000000 141#define MIIMCFG_RESET 0x80000000
143#define MIIMIND_BUSY 0x00000001 142#define MIIMIND_BUSY 0x00000001
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index b8898927236a..ebcfb27a904e 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -78,7 +78,6 @@ int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id,
78 * same as system mdio bus, used for controlling the external PHYs, for eg. 78 * same as system mdio bus, used for controlling the external PHYs, for eg.
79 */ 79 */
80int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum) 80int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum)
81
82{ 81{
83 u16 value; 82 u16 value;
84 83
@@ -122,7 +121,7 @@ int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
122} 121}
123 122
124/* Reset the MIIM registers, and wait for the bus to free */ 123/* Reset the MIIM registers, and wait for the bus to free */
125int gfar_mdio_reset(struct mii_bus *bus) 124static int gfar_mdio_reset(struct mii_bus *bus)
126{ 125{
127 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv; 126 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
128 unsigned int timeout = PHY_INIT_TIMEOUT; 127 unsigned int timeout = PHY_INIT_TIMEOUT;
@@ -152,14 +151,15 @@ int gfar_mdio_reset(struct mii_bus *bus)
152} 151}
153 152
154 153
155int gfar_mdio_probe(struct device *dev) 154static int gfar_mdio_probe(struct device *dev)
156{ 155{
157 struct platform_device *pdev = to_platform_device(dev); 156 struct platform_device *pdev = to_platform_device(dev);
158 struct gianfar_mdio_data *pdata; 157 struct gianfar_mdio_data *pdata;
159 struct gfar_mii __iomem *regs; 158 struct gfar_mii __iomem *regs;
159 struct gfar __iomem *enet_regs;
160 struct mii_bus *new_bus; 160 struct mii_bus *new_bus;
161 struct resource *r; 161 struct resource *r;
162 int err = 0; 162 int i, err = 0;
163 163
164 if (NULL == dev) 164 if (NULL == dev)
165 return -EINVAL; 165 return -EINVAL;
@@ -199,6 +199,34 @@ int gfar_mdio_probe(struct device *dev)
199 new_bus->dev = dev; 199 new_bus->dev = dev;
200 dev_set_drvdata(dev, new_bus); 200 dev_set_drvdata(dev, new_bus);
201 201
202 /*
203 * This is mildly evil, but so is our hardware for doing this.
204 * Also, we have to cast back to struct gfar_mii because of
205 * definition weirdness done in gianfar.h.
206 */
207 enet_regs = (struct gfar __iomem *)
208 ((char *)regs - offsetof(struct gfar, gfar_mii_regs));
209
210 /* Scan the bus, looking for an empty spot for TBIPA */
211 gfar_write(&enet_regs->tbipa, 0);
212 for (i = PHY_MAX_ADDR; i > 0; i--) {
213 u32 phy_id;
214 int r;
215
216 r = get_phy_id(new_bus, i, &phy_id);
217 if (r)
218 return r;
219
220 if (phy_id == 0xffffffff)
221 break;
222 }
223
224 /* The bus is full. We don't support using 31 PHYs, sorry */
225 if (i == 0)
226 return -EBUSY;
227
228 gfar_write(&enet_regs->tbipa, i);
229
202 err = mdiobus_register(new_bus); 230 err = mdiobus_register(new_bus);
203 231
204 if (0 != err) { 232 if (0 != err) {
@@ -218,7 +246,7 @@ reg_map_fail:
218} 246}
219 247
220 248
221int gfar_mdio_remove(struct device *dev) 249static int gfar_mdio_remove(struct device *dev)
222{ 250{
223 struct mii_bus *bus = dev_get_drvdata(dev); 251 struct mii_bus *bus = dev_get_drvdata(dev);
224 252
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
index b373091c7031..2af28b16a0e2 100644
--- a/drivers/net/gianfar_mii.h
+++ b/drivers/net/gianfar_mii.h
@@ -41,6 +41,9 @@ struct gfar_mii {
41 41
42int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum); 42int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum);
43int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value); 43int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value);
44int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id,
45 int regnum, u16 value);
46int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum);
44int __init gfar_mdio_init(void); 47int __init gfar_mdio_init(void);
45void gfar_mdio_exit(void); 48void gfar_mdio_exit(void);
46#endif /* GIANFAR_PHY_H */ 49#endif /* GIANFAR_PHY_H */
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 1da55dd2a5a0..9d5721287d6f 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -148,13 +148,13 @@ static void sp_xmit_on_air(unsigned long channel)
148 148
149 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) { 149 if (((sp->status1 & SIXP_DCD_MASK) == 0) && (random < sp->persistence)) {
150 sp->led_state = 0x70; 150 sp->led_state = 0x70;
151 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 151 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
152 sp->tx_enable = 1; 152 sp->tx_enable = 1;
153 actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2); 153 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2);
154 sp->xleft -= actual; 154 sp->xleft -= actual;
155 sp->xhead += actual; 155 sp->xhead += actual;
156 sp->led_state = 0x60; 156 sp->led_state = 0x60;
157 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 157 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
158 sp->status2 = 0; 158 sp->status2 = 0;
159 } else 159 } else
160 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100); 160 mod_timer(&sp->tx_t, jiffies + ((when + 1) * HZ) / 100);
@@ -220,13 +220,13 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
220 */ 220 */
221 if (sp->duplex == 1) { 221 if (sp->duplex == 1) {
222 sp->led_state = 0x70; 222 sp->led_state = 0x70;
223 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 223 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
224 sp->tx_enable = 1; 224 sp->tx_enable = 1;
225 actual = sp->tty->driver->write(sp->tty, sp->xbuff, count); 225 actual = sp->tty->ops->write(sp->tty, sp->xbuff, count);
226 sp->xleft = count - actual; 226 sp->xleft = count - actual;
227 sp->xhead = sp->xbuff + actual; 227 sp->xhead = sp->xbuff + actual;
228 sp->led_state = 0x60; 228 sp->led_state = 0x60;
229 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 229 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
230 } else { 230 } else {
231 sp->xleft = count; 231 sp->xleft = count;
232 sp->xhead = sp->xbuff; 232 sp->xhead = sp->xbuff;
@@ -444,7 +444,7 @@ static void sixpack_write_wakeup(struct tty_struct *tty)
444 } 444 }
445 445
446 if (sp->tx_enable) { 446 if (sp->tx_enable) {
447 actual = tty->driver->write(tty, sp->xhead, sp->xleft); 447 actual = tty->ops->write(tty, sp->xhead, sp->xleft);
448 sp->xleft -= actual; 448 sp->xleft -= actual;
449 sp->xhead += actual; 449 sp->xhead += actual;
450 } 450 }
@@ -491,9 +491,7 @@ static void sixpack_receive_buf(struct tty_struct *tty,
491 sixpack_decode(sp, buf, count1); 491 sixpack_decode(sp, buf, count1);
492 492
493 sp_put(sp); 493 sp_put(sp);
494 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 494 tty_unthrottle(tty);
495 && tty->driver->unthrottle)
496 tty->driver->unthrottle(tty);
497} 495}
498 496
499/* 497/*
@@ -554,8 +552,8 @@ static void resync_tnc(unsigned long channel)
554 /* resync the TNC */ 552 /* resync the TNC */
555 553
556 sp->led_state = 0x60; 554 sp->led_state = 0x60;
557 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 555 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
558 sp->tty->driver->write(sp->tty, &resync_cmd, 1); 556 sp->tty->ops->write(sp->tty, &resync_cmd, 1);
559 557
560 558
561 /* Start resync timer again -- the TNC might be still absent */ 559 /* Start resync timer again -- the TNC might be still absent */
@@ -573,7 +571,7 @@ static inline int tnc_init(struct sixpack *sp)
573 571
574 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP); 572 tnc_set_sync_state(sp, TNC_UNSYNC_STARTUP);
575 573
576 sp->tty->driver->write(sp->tty, &inbyte, 1); 574 sp->tty->ops->write(sp->tty, &inbyte, 1);
577 575
578 del_timer(&sp->resync_t); 576 del_timer(&sp->resync_t);
579 sp->resync_t.data = (unsigned long) sp; 577 sp->resync_t.data = (unsigned long) sp;
@@ -601,6 +599,8 @@ static int sixpack_open(struct tty_struct *tty)
601 599
602 if (!capable(CAP_NET_ADMIN)) 600 if (!capable(CAP_NET_ADMIN))
603 return -EPERM; 601 return -EPERM;
602 if (tty->ops->write == NULL)
603 return -EOPNOTSUPP;
604 604
605 dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup); 605 dev = alloc_netdev(sizeof(struct sixpack), "sp%d", sp_setup);
606 if (!dev) { 606 if (!dev) {
@@ -914,9 +914,9 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
914 } else { /* output watchdog char if idle */ 914 } else { /* output watchdog char if idle */
915 if ((sp->status2 != 0) && (sp->duplex == 1)) { 915 if ((sp->status2 != 0) && (sp->duplex == 1)) {
916 sp->led_state = 0x70; 916 sp->led_state = 0x70;
917 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 917 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
918 sp->tx_enable = 1; 918 sp->tx_enable = 1;
919 actual = sp->tty->driver->write(sp->tty, sp->xbuff, sp->status2); 919 actual = sp->tty->ops->write(sp->tty, sp->xbuff, sp->status2);
920 sp->xleft -= actual; 920 sp->xleft -= actual;
921 sp->xhead += actual; 921 sp->xhead += actual;
922 sp->led_state = 0x60; 922 sp->led_state = 0x60;
@@ -926,7 +926,7 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
926 } 926 }
927 927
928 /* needed to trigger the TNC watchdog */ 928 /* needed to trigger the TNC watchdog */
929 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 929 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
930 930
931 /* if the state byte has been received, the TNC is present, 931 /* if the state byte has been received, the TNC is present,
932 so the resync timer can be reset. */ 932 so the resync timer can be reset. */
@@ -956,12 +956,12 @@ static void decode_std_command(struct sixpack *sp, unsigned char cmd)
956 if ((sp->status & SIXP_RX_DCD_MASK) == 956 if ((sp->status & SIXP_RX_DCD_MASK) ==
957 SIXP_RX_DCD_MASK) { 957 SIXP_RX_DCD_MASK) {
958 sp->led_state = 0x68; 958 sp->led_state = 0x68;
959 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 959 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
960 } 960 }
961 } else { 961 } else {
962 sp->led_state = 0x60; 962 sp->led_state = 0x60;
963 /* fill trailing bytes with zeroes */ 963 /* fill trailing bytes with zeroes */
964 sp->tty->driver->write(sp->tty, &sp->led_state, 1); 964 sp->tty->ops->write(sp->tty, &sp->led_state, 1);
965 rest = sp->rx_count; 965 rest = sp->rx_count;
966 if (rest != 0) 966 if (rest != 0)
967 for (i = rest; i <= 3; i++) 967 for (i = rest; i <= 3; i++)
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 30c9b3b0d131..65166035aca0 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -516,7 +516,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
516 spin_unlock_bh(&ax->buflock); 516 spin_unlock_bh(&ax->buflock);
517 517
518 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags); 518 set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
519 actual = ax->tty->driver->write(ax->tty, ax->xbuff, count); 519 actual = ax->tty->ops->write(ax->tty, ax->xbuff, count);
520 ax->stats.tx_packets++; 520 ax->stats.tx_packets++;
521 ax->stats.tx_bytes += actual; 521 ax->stats.tx_bytes += actual;
522 522
@@ -546,7 +546,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
546 } 546 }
547 547
548 printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name, 548 printk(KERN_ERR "mkiss: %s: transmit timed out, %s?\n", dev->name,
549 (ax->tty->driver->chars_in_buffer(ax->tty) || ax->xleft) ? 549 (ax->tty->ops->chars_in_buffer(ax->tty) || ax->xleft) ?
550 "bad line quality" : "driver error"); 550 "bad line quality" : "driver error");
551 551
552 ax->xleft = 0; 552 ax->xleft = 0;
@@ -736,6 +736,8 @@ static int mkiss_open(struct tty_struct *tty)
736 736
737 if (!capable(CAP_NET_ADMIN)) 737 if (!capable(CAP_NET_ADMIN))
738 return -EPERM; 738 return -EPERM;
739 if (tty->ops->write == NULL)
740 return -EOPNOTSUPP;
739 741
740 dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup); 742 dev = alloc_netdev(sizeof(struct mkiss), "ax%d", ax_setup);
741 if (!dev) { 743 if (!dev) {
@@ -754,8 +756,7 @@ static int mkiss_open(struct tty_struct *tty)
754 tty->disc_data = ax; 756 tty->disc_data = ax;
755 tty->receive_room = 65535; 757 tty->receive_room = 65535;
756 758
757 if (tty->driver->flush_buffer) 759 tty_driver_flush_buffer(tty);
758 tty->driver->flush_buffer(tty);
759 760
760 /* Restore default settings */ 761 /* Restore default settings */
761 dev->type = ARPHRD_AX25; 762 dev->type = ARPHRD_AX25;
@@ -935,9 +936,7 @@ static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
935 } 936 }
936 937
937 mkiss_put(ax); 938 mkiss_put(ax);
938 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 939 tty_unthrottle(tty);
939 && tty->driver->unthrottle)
940 tty->driver->unthrottle(tty);
941} 940}
942 941
943/* 942/*
@@ -962,7 +961,7 @@ static void mkiss_write_wakeup(struct tty_struct *tty)
962 goto out; 961 goto out;
963 } 962 }
964 963
965 actual = tty->driver->write(tty, ax->xhead, ax->xleft); 964 actual = tty->ops->write(tty, ax->xhead, ax->xleft);
966 ax->xleft -= actual; 965 ax->xleft -= actual;
967 ax->xhead += actual; 966 ax->xhead += actual;
968 967
diff --git a/drivers/net/irda/irtty-sir.c b/drivers/net/irda/irtty-sir.c
index fc753d7f674e..e6f40b7f9041 100644
--- a/drivers/net/irda/irtty-sir.c
+++ b/drivers/net/irda/irtty-sir.c
@@ -64,7 +64,7 @@ static int irtty_chars_in_buffer(struct sir_dev *dev)
64 IRDA_ASSERT(priv != NULL, return -1;); 64 IRDA_ASSERT(priv != NULL, return -1;);
65 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); 65 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
66 66
67 return priv->tty->driver->chars_in_buffer(priv->tty); 67 return tty_chars_in_buffer(priv->tty);
68} 68}
69 69
70/* Wait (sleep) until underlaying hardware finished transmission 70/* Wait (sleep) until underlaying hardware finished transmission
@@ -93,10 +93,8 @@ static void irtty_wait_until_sent(struct sir_dev *dev)
93 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;); 93 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);
94 94
95 tty = priv->tty; 95 tty = priv->tty;
96 if (tty->driver->wait_until_sent) { 96 if (tty->ops->wait_until_sent) {
97 lock_kernel(); 97 tty->ops->wait_until_sent(tty, msecs_to_jiffies(100));
98 tty->driver->wait_until_sent(tty, msecs_to_jiffies(100));
99 unlock_kernel();
100 } 98 }
101 else { 99 else {
102 msleep(USBSERIAL_TX_DONE_DELAY); 100 msleep(USBSERIAL_TX_DONE_DELAY);
@@ -125,48 +123,14 @@ static int irtty_change_speed(struct sir_dev *dev, unsigned speed)
125 123
126 tty = priv->tty; 124 tty = priv->tty;
127 125
128 lock_kernel(); 126 mutex_lock(&tty->termios_mutex);
129 old_termios = *(tty->termios); 127 old_termios = *(tty->termios);
130 cflag = tty->termios->c_cflag; 128 cflag = tty->termios->c_cflag;
131 129 tty_encode_baud_rate(tty, speed, speed);
132 cflag &= ~CBAUD; 130 if (tty->ops->set_termios)
133 131 tty->ops->set_termios(tty, &old_termios);
134 IRDA_DEBUG(2, "%s(), Setting speed to %d\n", __FUNCTION__, speed);
135
136 switch (speed) {
137 case 1200:
138 cflag |= B1200;
139 break;
140 case 2400:
141 cflag |= B2400;
142 break;
143 case 4800:
144 cflag |= B4800;
145 break;
146 case 19200:
147 cflag |= B19200;
148 break;
149 case 38400:
150 cflag |= B38400;
151 break;
152 case 57600:
153 cflag |= B57600;
154 break;
155 case 115200:
156 cflag |= B115200;
157 break;
158 case 9600:
159 default:
160 cflag |= B9600;
161 break;
162 }
163
164 tty->termios->c_cflag = cflag;
165 if (tty->driver->set_termios)
166 tty->driver->set_termios(tty, &old_termios);
167 unlock_kernel();
168
169 priv->io.speed = speed; 132 priv->io.speed = speed;
133 mutex_unlock(&tty->termios_mutex);
170 134
171 return 0; 135 return 0;
172} 136}
@@ -202,8 +166,8 @@ static int irtty_set_dtr_rts(struct sir_dev *dev, int dtr, int rts)
202 * This function is not yet defined for all tty driver, so 166 * This function is not yet defined for all tty driver, so
203 * let's be careful... Jean II 167 * let's be careful... Jean II
204 */ 168 */
205 IRDA_ASSERT(priv->tty->driver->tiocmset != NULL, return -1;); 169 IRDA_ASSERT(priv->tty->ops->tiocmset != NULL, return -1;);
206 priv->tty->driver->tiocmset(priv->tty, NULL, set, clear); 170 priv->tty->ops->tiocmset(priv->tty, NULL, set, clear);
207 171
208 return 0; 172 return 0;
209} 173}
@@ -225,17 +189,13 @@ static int irtty_do_write(struct sir_dev *dev, const unsigned char *ptr, size_t
225 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;); 189 IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -1;);
226 190
227 tty = priv->tty; 191 tty = priv->tty;
228 if (!tty->driver->write) 192 if (!tty->ops->write)
229 return 0; 193 return 0;
230 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 194 tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
231 if (tty->driver->write_room) { 195 writelen = tty_write_room(tty);
232 writelen = tty->driver->write_room(tty); 196 if (writelen > len)
233 if (writelen > len)
234 writelen = len;
235 }
236 else
237 writelen = len; 197 writelen = len;
238 return tty->driver->write(tty, ptr, writelen); 198 return tty->ops->write(tty, ptr, writelen);
239} 199}
240 200
241/* ------------------------------------------------------- */ 201/* ------------------------------------------------------- */
@@ -321,7 +281,7 @@ static inline void irtty_stop_receiver(struct tty_struct *tty, int stop)
321 struct ktermios old_termios; 281 struct ktermios old_termios;
322 int cflag; 282 int cflag;
323 283
324 lock_kernel(); 284 mutex_lock(&tty->termios_mutex);
325 old_termios = *(tty->termios); 285 old_termios = *(tty->termios);
326 cflag = tty->termios->c_cflag; 286 cflag = tty->termios->c_cflag;
327 287
@@ -331,9 +291,9 @@ static inline void irtty_stop_receiver(struct tty_struct *tty, int stop)
331 cflag |= CREAD; 291 cflag |= CREAD;
332 292
333 tty->termios->c_cflag = cflag; 293 tty->termios->c_cflag = cflag;
334 if (tty->driver->set_termios) 294 if (tty->ops->set_termios)
335 tty->driver->set_termios(tty, &old_termios); 295 tty->ops->set_termios(tty, &old_termios);
336 unlock_kernel(); 296 mutex_unlock(&tty->termios_mutex);
337} 297}
338 298
339/*****************************************************************/ 299/*****************************************************************/
@@ -359,8 +319,8 @@ static int irtty_start_dev(struct sir_dev *dev)
359 319
360 tty = priv->tty; 320 tty = priv->tty;
361 321
362 if (tty->driver->start) 322 if (tty->ops->start)
363 tty->driver->start(tty); 323 tty->ops->start(tty);
364 /* Make sure we can receive more data */ 324 /* Make sure we can receive more data */
365 irtty_stop_receiver(tty, FALSE); 325 irtty_stop_receiver(tty, FALSE);
366 326
@@ -388,8 +348,8 @@ static int irtty_stop_dev(struct sir_dev *dev)
388 348
389 /* Make sure we don't receive more data */ 349 /* Make sure we don't receive more data */
390 irtty_stop_receiver(tty, TRUE); 350 irtty_stop_receiver(tty, TRUE);
391 if (tty->driver->stop) 351 if (tty->ops->stop)
392 tty->driver->stop(tty); 352 tty->ops->stop(tty);
393 353
394 mutex_unlock(&irtty_mutex); 354 mutex_unlock(&irtty_mutex);
395 355
@@ -483,11 +443,10 @@ static int irtty_open(struct tty_struct *tty)
483 443
484 /* stop the underlying driver */ 444 /* stop the underlying driver */
485 irtty_stop_receiver(tty, TRUE); 445 irtty_stop_receiver(tty, TRUE);
486 if (tty->driver->stop) 446 if (tty->ops->stop)
487 tty->driver->stop(tty); 447 tty->ops->stop(tty);
488 448
489 if (tty->driver->flush_buffer) 449 tty_driver_flush_buffer(tty);
490 tty->driver->flush_buffer(tty);
491 450
492 /* apply mtt override */ 451 /* apply mtt override */
493 sir_tty_drv.qos_mtt_bits = qos_mtt_bits; 452 sir_tty_drv.qos_mtt_bits = qos_mtt_bits;
@@ -564,8 +523,8 @@ static void irtty_close(struct tty_struct *tty)
564 /* Stop tty */ 523 /* Stop tty */
565 irtty_stop_receiver(tty, TRUE); 524 irtty_stop_receiver(tty, TRUE);
566 tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); 525 tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
567 if (tty->driver->stop) 526 if (tty->ops->stop)
568 tty->driver->stop(tty); 527 tty->ops->stop(tty);
569 528
570 kfree(priv); 529 kfree(priv);
571 530
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 3ac8529bb92c..6bf9e76b0a00 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -48,7 +48,7 @@ config VITESSE_PHY
48config SMSC_PHY 48config SMSC_PHY
49 tristate "Drivers for SMSC PHYs" 49 tristate "Drivers for SMSC PHYs"
50 ---help--- 50 ---help---
51 Currently supports the LAN83C185 PHY 51 Currently supports the LAN83C185, LAN8187 and LAN8700 PHYs
52 52
53config BROADCOM_PHY 53config BROADCOM_PHY
54 tristate "Drivers for Broadcom PHYs" 54 tristate "Drivers for Broadcom PHYs"
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ddf8d51832a6..ac3c01d28fdf 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -256,7 +256,7 @@ void phy_prepare_link(struct phy_device *phydev,
256/** 256/**
257 * phy_connect - connect an ethernet device to a PHY device 257 * phy_connect - connect an ethernet device to a PHY device
258 * @dev: the network device to connect 258 * @dev: the network device to connect
259 * @phy_id: the PHY device to connect 259 * @bus_id: the id string of the PHY device to connect
260 * @handler: callback function for state change notifications 260 * @handler: callback function for state change notifications
261 * @flags: PHY device's dev_flags 261 * @flags: PHY device's dev_flags
262 * @interface: PHY device's interface 262 * @interface: PHY device's interface
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index b1d8ed40ad98..73baa7a3bb0e 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -12,6 +12,8 @@
12 * Free Software Foundation; either version 2 of the License, or (at your 12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@smsc.com
16 *
15 */ 17 */
16 18
17#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -38,7 +40,7 @@
38 (MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4) 40 (MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4)
39 41
40 42
41static int lan83c185_config_intr(struct phy_device *phydev) 43static int smsc_phy_config_intr(struct phy_device *phydev)
42{ 44{
43 int rc = phy_write (phydev, MII_LAN83C185_IM, 45 int rc = phy_write (phydev, MII_LAN83C185_IM,
44 ((PHY_INTERRUPT_ENABLED == phydev->interrupts) 46 ((PHY_INTERRUPT_ENABLED == phydev->interrupts)
@@ -48,16 +50,16 @@ static int lan83c185_config_intr(struct phy_device *phydev)
48 return rc < 0 ? rc : 0; 50 return rc < 0 ? rc : 0;
49} 51}
50 52
51static int lan83c185_ack_interrupt(struct phy_device *phydev) 53static int smsc_phy_ack_interrupt(struct phy_device *phydev)
52{ 54{
53 int rc = phy_read (phydev, MII_LAN83C185_ISF); 55 int rc = phy_read (phydev, MII_LAN83C185_ISF);
54 56
55 return rc < 0 ? rc : 0; 57 return rc < 0 ? rc : 0;
56} 58}
57 59
58static int lan83c185_config_init(struct phy_device *phydev) 60static int smsc_phy_config_init(struct phy_device *phydev)
59{ 61{
60 return lan83c185_ack_interrupt (phydev); 62 return smsc_phy_ack_interrupt (phydev);
61} 63}
62 64
63 65
@@ -73,22 +75,87 @@ static struct phy_driver lan83c185_driver = {
73 /* basic functions */ 75 /* basic functions */
74 .config_aneg = genphy_config_aneg, 76 .config_aneg = genphy_config_aneg,
75 .read_status = genphy_read_status, 77 .read_status = genphy_read_status,
76 .config_init = lan83c185_config_init, 78 .config_init = smsc_phy_config_init,
77 79
78 /* IRQ related */ 80 /* IRQ related */
79 .ack_interrupt = lan83c185_ack_interrupt, 81 .ack_interrupt = smsc_phy_ack_interrupt,
80 .config_intr = lan83c185_config_intr, 82 .config_intr = smsc_phy_config_intr,
83
84 .driver = { .owner = THIS_MODULE, }
85};
86
87static struct phy_driver lan8187_driver = {
88 .phy_id = 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
89 .phy_id_mask = 0xfffffff0,
90 .name = "SMSC LAN8187",
91
92 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
93 | SUPPORTED_Asym_Pause),
94 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
95
96 /* basic functions */
97 .config_aneg = genphy_config_aneg,
98 .read_status = genphy_read_status,
99 .config_init = smsc_phy_config_init,
100
101 /* IRQ related */
102 .ack_interrupt = smsc_phy_ack_interrupt,
103 .config_intr = smsc_phy_config_intr,
104
105 .driver = { .owner = THIS_MODULE, }
106};
107
108static struct phy_driver lan8700_driver = {
109 .phy_id = 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
110 .phy_id_mask = 0xfffffff0,
111 .name = "SMSC LAN8700",
112
113 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
114 | SUPPORTED_Asym_Pause),
115 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
116
117 /* basic functions */
118 .config_aneg = genphy_config_aneg,
119 .read_status = genphy_read_status,
120 .config_init = smsc_phy_config_init,
121
122 /* IRQ related */
123 .ack_interrupt = smsc_phy_ack_interrupt,
124 .config_intr = smsc_phy_config_intr,
81 125
82 .driver = { .owner = THIS_MODULE, } 126 .driver = { .owner = THIS_MODULE, }
83}; 127};
84 128
85static int __init smsc_init(void) 129static int __init smsc_init(void)
86{ 130{
87 return phy_driver_register (&lan83c185_driver); 131 int ret;
132
133 ret = phy_driver_register (&lan83c185_driver);
134 if (ret)
135 goto err1;
136
137 ret = phy_driver_register (&lan8187_driver);
138 if (ret)
139 goto err2;
140
141 ret = phy_driver_register (&lan8700_driver);
142 if (ret)
143 goto err3;
144
145 return 0;
146
147err3:
148 phy_driver_unregister (&lan8187_driver);
149err2:
150 phy_driver_unregister (&lan83c185_driver);
151err1:
152 return ret;
88} 153}
89 154
90static void __exit smsc_exit(void) 155static void __exit smsc_exit(void)
91{ 156{
157 phy_driver_unregister (&lan8700_driver);
158 phy_driver_unregister (&lan8187_driver);
92 phy_driver_unregister (&lan83c185_driver); 159 phy_driver_unregister (&lan83c185_driver);
93} 160}
94 161
diff --git a/drivers/net/ppp_async.c b/drivers/net/ppp_async.c
index f023d5b67e6e..f1a52def1241 100644
--- a/drivers/net/ppp_async.c
+++ b/drivers/net/ppp_async.c
@@ -158,6 +158,9 @@ ppp_asynctty_open(struct tty_struct *tty)
158 struct asyncppp *ap; 158 struct asyncppp *ap;
159 int err; 159 int err;
160 160
161 if (tty->ops->write == NULL)
162 return -EOPNOTSUPP;
163
161 err = -ENOMEM; 164 err = -ENOMEM;
162 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 165 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
163 if (!ap) 166 if (!ap)
@@ -358,9 +361,7 @@ ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,
358 if (!skb_queue_empty(&ap->rqueue)) 361 if (!skb_queue_empty(&ap->rqueue))
359 tasklet_schedule(&ap->tsk); 362 tasklet_schedule(&ap->tsk);
360 ap_put(ap); 363 ap_put(ap);
361 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 364 tty_unthrottle(tty);
362 && tty->driver->unthrottle)
363 tty->driver->unthrottle(tty);
364} 365}
365 366
366static void 367static void
@@ -676,7 +677,7 @@ ppp_async_push(struct asyncppp *ap)
676 if (!tty_stuffed && ap->optr < ap->olim) { 677 if (!tty_stuffed && ap->optr < ap->olim) {
677 avail = ap->olim - ap->optr; 678 avail = ap->olim - ap->optr;
678 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 679 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
679 sent = tty->driver->write(tty, ap->optr, avail); 680 sent = tty->ops->write(tty, ap->optr, avail);
680 if (sent < 0) 681 if (sent < 0)
681 goto flush; /* error, e.g. loss of CD */ 682 goto flush; /* error, e.g. loss of CD */
682 ap->optr += sent; 683 ap->optr += sent;
diff --git a/drivers/net/ppp_synctty.c b/drivers/net/ppp_synctty.c
index 0d80fa546719..b8f0369a71e7 100644
--- a/drivers/net/ppp_synctty.c
+++ b/drivers/net/ppp_synctty.c
@@ -207,6 +207,9 @@ ppp_sync_open(struct tty_struct *tty)
207 struct syncppp *ap; 207 struct syncppp *ap;
208 int err; 208 int err;
209 209
210 if (tty->ops->write == NULL)
211 return -EOPNOTSUPP;
212
210 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 213 ap = kzalloc(sizeof(*ap), GFP_KERNEL);
211 err = -ENOMEM; 214 err = -ENOMEM;
212 if (!ap) 215 if (!ap)
@@ -398,9 +401,7 @@ ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,
398 if (!skb_queue_empty(&ap->rqueue)) 401 if (!skb_queue_empty(&ap->rqueue))
399 tasklet_schedule(&ap->tsk); 402 tasklet_schedule(&ap->tsk);
400 sp_put(ap); 403 sp_put(ap);
401 if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) 404 tty_unthrottle(tty);
402 && tty->driver->unthrottle)
403 tty->driver->unthrottle(tty);
404} 405}
405 406
406static void 407static void
@@ -653,7 +654,7 @@ ppp_sync_push(struct syncppp *ap)
653 tty_stuffed = 0; 654 tty_stuffed = 0;
654 if (!tty_stuffed && ap->tpkt) { 655 if (!tty_stuffed && ap->tpkt) {
655 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); 656 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
656 sent = tty->driver->write(tty, ap->tpkt->data, ap->tpkt->len); 657 sent = tty->ops->write(tty, ap->tpkt->data, ap->tpkt->len);
657 if (sent < 0) 658 if (sent < 0)
658 goto flush; /* error, e.g. loss of CD */ 659 goto flush; /* error, e.g. loss of CD */
659 if (sent < ap->tpkt->len) { 660 if (sent < ap->tpkt->len) {
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 3acfeeabdee1..657242504621 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1617,6 +1617,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1617 SET_NETDEV_DEV(dev, &pdev->dev); 1617 SET_NETDEV_DEV(dev, &pdev->dev);
1618 tp = netdev_priv(dev); 1618 tp = netdev_priv(dev);
1619 tp->dev = dev; 1619 tp->dev = dev;
1620 tp->pci_dev = pdev;
1620 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT); 1621 tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
1621 1622
1622 /* enable device (incl. PCI PM wakeup and hotplug setup) */ 1623 /* enable device (incl. PCI PM wakeup and hotplug setup) */
@@ -1705,18 +1706,18 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1705 1706
1706 rtl8169_print_mac_version(tp); 1707 rtl8169_print_mac_version(tp);
1707 1708
1708 for (i = ARRAY_SIZE(rtl_chip_info) - 1; i >= 0; i--) { 1709 for (i = 0; i < ARRAY_SIZE(rtl_chip_info); i++) {
1709 if (tp->mac_version == rtl_chip_info[i].mac_version) 1710 if (tp->mac_version == rtl_chip_info[i].mac_version)
1710 break; 1711 break;
1711 } 1712 }
1712 if (i < 0) { 1713 if (i == ARRAY_SIZE(rtl_chip_info)) {
1713 /* Unknown chip: assume array element #0, original RTL-8169 */ 1714 /* Unknown chip: assume array element #0, original RTL-8169 */
1714 if (netif_msg_probe(tp)) { 1715 if (netif_msg_probe(tp)) {
1715 dev_printk(KERN_DEBUG, &pdev->dev, 1716 dev_printk(KERN_DEBUG, &pdev->dev,
1716 "unknown chip version, assuming %s\n", 1717 "unknown chip version, assuming %s\n",
1717 rtl_chip_info[0].name); 1718 rtl_chip_info[0].name);
1718 } 1719 }
1719 i++; 1720 i = 0;
1720 } 1721 }
1721 tp->chipset = i; 1722 tp->chipset = i;
1722 1723
@@ -1777,7 +1778,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1777#endif 1778#endif
1778 1779
1779 tp->intr_mask = 0xffff; 1780 tp->intr_mask = 0xffff;
1780 tp->pci_dev = pdev;
1781 tp->mmio_addr = ioaddr; 1781 tp->mmio_addr = ioaddr;
1782 tp->align = cfg->align; 1782 tp->align = cfg->align;
1783 tp->hw_start = cfg->hw_start; 1783 tp->hw_start = cfg->hw_start;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 157fd932e951..523478ebfd69 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -86,7 +86,7 @@
86#include "s2io.h" 86#include "s2io.h"
87#include "s2io-regs.h" 87#include "s2io-regs.h"
88 88
89#define DRV_VERSION "2.0.26.22" 89#define DRV_VERSION "2.0.26.23"
90 90
91/* S2io Driver name & version. */ 91/* S2io Driver name & version. */
92static char s2io_driver_name[] = "Neterion"; 92static char s2io_driver_name[] = "Neterion";
@@ -809,6 +809,7 @@ static int init_shared_mem(struct s2io_nic *nic)
809 config->rx_cfg[i].num_rxd - 1; 809 config->rx_cfg[i].num_rxd - 1;
810 mac_control->rings[i].nic = nic; 810 mac_control->rings[i].nic = nic;
811 mac_control->rings[i].ring_no = i; 811 mac_control->rings[i].ring_no = i;
812 mac_control->rings[i].lro = lro_enable;
812 813
813 blk_cnt = config->rx_cfg[i].num_rxd / 814 blk_cnt = config->rx_cfg[i].num_rxd /
814 (rxd_count[nic->rxd_mode] + 1); 815 (rxd_count[nic->rxd_mode] + 1);
@@ -1560,113 +1561,112 @@ static int init_nic(struct s2io_nic *nic)
1560 writeq(val64, &bar0->tx_fifo_partition_0); 1561 writeq(val64, &bar0->tx_fifo_partition_0);
1561 1562
1562 /* Filling the Rx round robin registers as per the 1563 /* Filling the Rx round robin registers as per the
1563 * number of Rings and steering based on QoS. 1564 * number of Rings and steering based on QoS with
1564 */ 1565 * equal priority.
1566 */
1565 switch (config->rx_ring_num) { 1567 switch (config->rx_ring_num) {
1566 case 1: 1568 case 1:
1569 val64 = 0x0;
1570 writeq(val64, &bar0->rx_w_round_robin_0);
1571 writeq(val64, &bar0->rx_w_round_robin_1);
1572 writeq(val64, &bar0->rx_w_round_robin_2);
1573 writeq(val64, &bar0->rx_w_round_robin_3);
1574 writeq(val64, &bar0->rx_w_round_robin_4);
1575
1567 val64 = 0x8080808080808080ULL; 1576 val64 = 0x8080808080808080ULL;
1568 writeq(val64, &bar0->rts_qos_steering); 1577 writeq(val64, &bar0->rts_qos_steering);
1569 break; 1578 break;
1570 case 2: 1579 case 2:
1571 val64 = 0x0000010000010000ULL; 1580 val64 = 0x0001000100010001ULL;
1572 writeq(val64, &bar0->rx_w_round_robin_0); 1581 writeq(val64, &bar0->rx_w_round_robin_0);
1573 val64 = 0x0100000100000100ULL;
1574 writeq(val64, &bar0->rx_w_round_robin_1); 1582 writeq(val64, &bar0->rx_w_round_robin_1);
1575 val64 = 0x0001000001000001ULL;
1576 writeq(val64, &bar0->rx_w_round_robin_2); 1583 writeq(val64, &bar0->rx_w_round_robin_2);
1577 val64 = 0x0000010000010000ULL;
1578 writeq(val64, &bar0->rx_w_round_robin_3); 1584 writeq(val64, &bar0->rx_w_round_robin_3);
1579 val64 = 0x0100000000000000ULL; 1585 val64 = 0x0001000100000000ULL;
1580 writeq(val64, &bar0->rx_w_round_robin_4); 1586 writeq(val64, &bar0->rx_w_round_robin_4);
1581 1587
1582 val64 = 0x8080808040404040ULL; 1588 val64 = 0x8080808040404040ULL;
1583 writeq(val64, &bar0->rts_qos_steering); 1589 writeq(val64, &bar0->rts_qos_steering);
1584 break; 1590 break;
1585 case 3: 1591 case 3:
1586 val64 = 0x0001000102000001ULL; 1592 val64 = 0x0001020001020001ULL;
1587 writeq(val64, &bar0->rx_w_round_robin_0); 1593 writeq(val64, &bar0->rx_w_round_robin_0);
1588 val64 = 0x0001020000010001ULL; 1594 val64 = 0x0200010200010200ULL;
1589 writeq(val64, &bar0->rx_w_round_robin_1); 1595 writeq(val64, &bar0->rx_w_round_robin_1);
1590 val64 = 0x0200000100010200ULL; 1596 val64 = 0x0102000102000102ULL;
1591 writeq(val64, &bar0->rx_w_round_robin_2); 1597 writeq(val64, &bar0->rx_w_round_robin_2);
1592 val64 = 0x0001000102000001ULL; 1598 val64 = 0x0001020001020001ULL;
1593 writeq(val64, &bar0->rx_w_round_robin_3); 1599 writeq(val64, &bar0->rx_w_round_robin_3);
1594 val64 = 0x0001020000000000ULL; 1600 val64 = 0x0200010200000000ULL;
1595 writeq(val64, &bar0->rx_w_round_robin_4); 1601 writeq(val64, &bar0->rx_w_round_robin_4);
1596 1602
1597 val64 = 0x8080804040402020ULL; 1603 val64 = 0x8080804040402020ULL;
1598 writeq(val64, &bar0->rts_qos_steering); 1604 writeq(val64, &bar0->rts_qos_steering);
1599 break; 1605 break;
1600 case 4: 1606 case 4:
1601 val64 = 0x0001020300010200ULL; 1607 val64 = 0x0001020300010203ULL;
1602 writeq(val64, &bar0->rx_w_round_robin_0); 1608 writeq(val64, &bar0->rx_w_round_robin_0);
1603 val64 = 0x0100000102030001ULL;
1604 writeq(val64, &bar0->rx_w_round_robin_1); 1609 writeq(val64, &bar0->rx_w_round_robin_1);
1605 val64 = 0x0200010000010203ULL;
1606 writeq(val64, &bar0->rx_w_round_robin_2); 1610 writeq(val64, &bar0->rx_w_round_robin_2);
1607 val64 = 0x0001020001000001ULL;
1608 writeq(val64, &bar0->rx_w_round_robin_3); 1611 writeq(val64, &bar0->rx_w_round_robin_3);
1609 val64 = 0x0203000100000000ULL; 1612 val64 = 0x0001020300000000ULL;
1610 writeq(val64, &bar0->rx_w_round_robin_4); 1613 writeq(val64, &bar0->rx_w_round_robin_4);
1611 1614
1612 val64 = 0x8080404020201010ULL; 1615 val64 = 0x8080404020201010ULL;
1613 writeq(val64, &bar0->rts_qos_steering); 1616 writeq(val64, &bar0->rts_qos_steering);
1614 break; 1617 break;
1615 case 5: 1618 case 5:
1616 val64 = 0x0001000203000102ULL; 1619 val64 = 0x0001020304000102ULL;
1617 writeq(val64, &bar0->rx_w_round_robin_0); 1620 writeq(val64, &bar0->rx_w_round_robin_0);
1618 val64 = 0x0001020001030004ULL; 1621 val64 = 0x0304000102030400ULL;
1619 writeq(val64, &bar0->rx_w_round_robin_1); 1622 writeq(val64, &bar0->rx_w_round_robin_1);
1620 val64 = 0x0001000203000102ULL; 1623 val64 = 0x0102030400010203ULL;
1621 writeq(val64, &bar0->rx_w_round_robin_2); 1624 writeq(val64, &bar0->rx_w_round_robin_2);
1622 val64 = 0x0001020001030004ULL; 1625 val64 = 0x0400010203040001ULL;
1623 writeq(val64, &bar0->rx_w_round_robin_3); 1626 writeq(val64, &bar0->rx_w_round_robin_3);
1624 val64 = 0x0001000000000000ULL; 1627 val64 = 0x0203040000000000ULL;
1625 writeq(val64, &bar0->rx_w_round_robin_4); 1628 writeq(val64, &bar0->rx_w_round_robin_4);
1626 1629
1627 val64 = 0x8080404020201008ULL; 1630 val64 = 0x8080404020201008ULL;
1628 writeq(val64, &bar0->rts_qos_steering); 1631 writeq(val64, &bar0->rts_qos_steering);
1629 break; 1632 break;
1630 case 6: 1633 case 6:
1631 val64 = 0x0001020304000102ULL; 1634 val64 = 0x0001020304050001ULL;
1632 writeq(val64, &bar0->rx_w_round_robin_0); 1635 writeq(val64, &bar0->rx_w_round_robin_0);
1633 val64 = 0x0304050001020001ULL; 1636 val64 = 0x0203040500010203ULL;
1634 writeq(val64, &bar0->rx_w_round_robin_1); 1637 writeq(val64, &bar0->rx_w_round_robin_1);
1635 val64 = 0x0203000100000102ULL; 1638 val64 = 0x0405000102030405ULL;
1636 writeq(val64, &bar0->rx_w_round_robin_2); 1639 writeq(val64, &bar0->rx_w_round_robin_2);
1637 val64 = 0x0304000102030405ULL; 1640 val64 = 0x0001020304050001ULL;
1638 writeq(val64, &bar0->rx_w_round_robin_3); 1641 writeq(val64, &bar0->rx_w_round_robin_3);
1639 val64 = 0x0001000200000000ULL; 1642 val64 = 0x0203040500000000ULL;
1640 writeq(val64, &bar0->rx_w_round_robin_4); 1643 writeq(val64, &bar0->rx_w_round_robin_4);
1641 1644
1642 val64 = 0x8080404020100804ULL; 1645 val64 = 0x8080404020100804ULL;
1643 writeq(val64, &bar0->rts_qos_steering); 1646 writeq(val64, &bar0->rts_qos_steering);
1644 break; 1647 break;
1645 case 7: 1648 case 7:
1646 val64 = 0x0001020001020300ULL; 1649 val64 = 0x0001020304050600ULL;
1647 writeq(val64, &bar0->rx_w_round_robin_0); 1650 writeq(val64, &bar0->rx_w_round_robin_0);
1648 val64 = 0x0102030400010203ULL; 1651 val64 = 0x0102030405060001ULL;
1649 writeq(val64, &bar0->rx_w_round_robin_1); 1652 writeq(val64, &bar0->rx_w_round_robin_1);
1650 val64 = 0x0405060001020001ULL; 1653 val64 = 0x0203040506000102ULL;
1651 writeq(val64, &bar0->rx_w_round_robin_2); 1654 writeq(val64, &bar0->rx_w_round_robin_2);
1652 val64 = 0x0304050000010200ULL; 1655 val64 = 0x0304050600010203ULL;
1653 writeq(val64, &bar0->rx_w_round_robin_3); 1656 writeq(val64, &bar0->rx_w_round_robin_3);
1654 val64 = 0x0102030000000000ULL; 1657 val64 = 0x0405060000000000ULL;
1655 writeq(val64, &bar0->rx_w_round_robin_4); 1658 writeq(val64, &bar0->rx_w_round_robin_4);
1656 1659
1657 val64 = 0x8080402010080402ULL; 1660 val64 = 0x8080402010080402ULL;
1658 writeq(val64, &bar0->rts_qos_steering); 1661 writeq(val64, &bar0->rts_qos_steering);
1659 break; 1662 break;
1660 case 8: 1663 case 8:
1661 val64 = 0x0001020300040105ULL; 1664 val64 = 0x0001020304050607ULL;
1662 writeq(val64, &bar0->rx_w_round_robin_0); 1665 writeq(val64, &bar0->rx_w_round_robin_0);
1663 val64 = 0x0200030106000204ULL;
1664 writeq(val64, &bar0->rx_w_round_robin_1); 1666 writeq(val64, &bar0->rx_w_round_robin_1);
1665 val64 = 0x0103000502010007ULL;
1666 writeq(val64, &bar0->rx_w_round_robin_2); 1667 writeq(val64, &bar0->rx_w_round_robin_2);
1667 val64 = 0x0304010002060500ULL;
1668 writeq(val64, &bar0->rx_w_round_robin_3); 1668 writeq(val64, &bar0->rx_w_round_robin_3);
1669 val64 = 0x0103020400000000ULL; 1669 val64 = 0x0001020300000000ULL;
1670 writeq(val64, &bar0->rx_w_round_robin_4); 1670 writeq(val64, &bar0->rx_w_round_robin_4);
1671 1671
1672 val64 = 0x8040201008040201ULL; 1672 val64 = 0x8040201008040201ULL;
@@ -2499,8 +2499,7 @@ static void stop_nic(struct s2io_nic *nic)
2499 2499
2500/** 2500/**
2501 * fill_rx_buffers - Allocates the Rx side skbs 2501 * fill_rx_buffers - Allocates the Rx side skbs
2502 * @nic: device private variable 2502 * @ring_info: per ring structure
2503 * @ring_no: ring number
2504 * Description: 2503 * Description:
2505 * The function allocates Rx side skbs and puts the physical 2504 * The function allocates Rx side skbs and puts the physical
2506 * address of these buffers into the RxD buffer pointers, so that the NIC 2505 * address of these buffers into the RxD buffer pointers, so that the NIC
@@ -2518,103 +2517,94 @@ static void stop_nic(struct s2io_nic *nic)
2518 * SUCCESS on success or an appropriate -ve value on failure. 2517 * SUCCESS on success or an appropriate -ve value on failure.
2519 */ 2518 */
2520 2519
2521static int fill_rx_buffers(struct s2io_nic *nic, int ring_no) 2520static int fill_rx_buffers(struct ring_info *ring)
2522{ 2521{
2523 struct net_device *dev = nic->dev;
2524 struct sk_buff *skb; 2522 struct sk_buff *skb;
2525 struct RxD_t *rxdp; 2523 struct RxD_t *rxdp;
2526 int off, off1, size, block_no, block_no1; 2524 int off, size, block_no, block_no1;
2527 u32 alloc_tab = 0; 2525 u32 alloc_tab = 0;
2528 u32 alloc_cnt; 2526 u32 alloc_cnt;
2529 struct mac_info *mac_control;
2530 struct config_param *config;
2531 u64 tmp; 2527 u64 tmp;
2532 struct buffAdd *ba; 2528 struct buffAdd *ba;
2533 struct RxD_t *first_rxdp = NULL; 2529 struct RxD_t *first_rxdp = NULL;
2534 u64 Buffer0_ptr = 0, Buffer1_ptr = 0; 2530 u64 Buffer0_ptr = 0, Buffer1_ptr = 0;
2531 int rxd_index = 0;
2535 struct RxD1 *rxdp1; 2532 struct RxD1 *rxdp1;
2536 struct RxD3 *rxdp3; 2533 struct RxD3 *rxdp3;
2537 struct swStat *stats = &nic->mac_control.stats_info->sw_stat; 2534 struct swStat *stats = &ring->nic->mac_control.stats_info->sw_stat;
2538 2535
2539 mac_control = &nic->mac_control; 2536 alloc_cnt = ring->pkt_cnt - ring->rx_bufs_left;
2540 config = &nic->config;
2541 alloc_cnt = mac_control->rings[ring_no].pkt_cnt -
2542 atomic_read(&nic->rx_bufs_left[ring_no]);
2543 2537
2544 block_no1 = mac_control->rings[ring_no].rx_curr_get_info.block_index; 2538 block_no1 = ring->rx_curr_get_info.block_index;
2545 off1 = mac_control->rings[ring_no].rx_curr_get_info.offset;
2546 while (alloc_tab < alloc_cnt) { 2539 while (alloc_tab < alloc_cnt) {
2547 block_no = mac_control->rings[ring_no].rx_curr_put_info. 2540 block_no = ring->rx_curr_put_info.block_index;
2548 block_index;
2549 off = mac_control->rings[ring_no].rx_curr_put_info.offset;
2550 2541
2551 rxdp = mac_control->rings[ring_no]. 2542 off = ring->rx_curr_put_info.offset;
2552 rx_blocks[block_no].rxds[off].virt_addr; 2543
2544 rxdp = ring->rx_blocks[block_no].rxds[off].virt_addr;
2545
2546 rxd_index = off + 1;
2547 if (block_no)
2548 rxd_index += (block_no * ring->rxd_count);
2553 2549
2554 if ((block_no == block_no1) && (off == off1) && 2550 if ((block_no == block_no1) &&
2555 (rxdp->Host_Control)) { 2551 (off == ring->rx_curr_get_info.offset) &&
2552 (rxdp->Host_Control)) {
2556 DBG_PRINT(INTR_DBG, "%s: Get and Put", 2553 DBG_PRINT(INTR_DBG, "%s: Get and Put",
2557 dev->name); 2554 ring->dev->name);
2558 DBG_PRINT(INTR_DBG, " info equated\n"); 2555 DBG_PRINT(INTR_DBG, " info equated\n");
2559 goto end; 2556 goto end;
2560 } 2557 }
2561 if (off && (off == rxd_count[nic->rxd_mode])) { 2558 if (off && (off == ring->rxd_count)) {
2562 mac_control->rings[ring_no].rx_curr_put_info. 2559 ring->rx_curr_put_info.block_index++;
2563 block_index++; 2560 if (ring->rx_curr_put_info.block_index ==
2564 if (mac_control->rings[ring_no].rx_curr_put_info. 2561 ring->block_count)
2565 block_index == mac_control->rings[ring_no]. 2562 ring->rx_curr_put_info.block_index = 0;
2566 block_count) 2563 block_no = ring->rx_curr_put_info.block_index;
2567 mac_control->rings[ring_no].rx_curr_put_info. 2564 off = 0;
2568 block_index = 0; 2565 ring->rx_curr_put_info.offset = off;
2569 block_no = mac_control->rings[ring_no]. 2566 rxdp = ring->rx_blocks[block_no].block_virt_addr;
2570 rx_curr_put_info.block_index;
2571 if (off == rxd_count[nic->rxd_mode])
2572 off = 0;
2573 mac_control->rings[ring_no].rx_curr_put_info.
2574 offset = off;
2575 rxdp = mac_control->rings[ring_no].
2576 rx_blocks[block_no].block_virt_addr;
2577 DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n", 2567 DBG_PRINT(INTR_DBG, "%s: Next block at: %p\n",
2578 dev->name, rxdp); 2568 ring->dev->name, rxdp);
2569
2579 } 2570 }
2580 2571
2581 if ((rxdp->Control_1 & RXD_OWN_XENA) && 2572 if ((rxdp->Control_1 & RXD_OWN_XENA) &&
2582 ((nic->rxd_mode == RXD_MODE_3B) && 2573 ((ring->rxd_mode == RXD_MODE_3B) &&
2583 (rxdp->Control_2 & s2BIT(0)))) { 2574 (rxdp->Control_2 & s2BIT(0)))) {
2584 mac_control->rings[ring_no].rx_curr_put_info. 2575 ring->rx_curr_put_info.offset = off;
2585 offset = off;
2586 goto end; 2576 goto end;
2587 } 2577 }
2588 /* calculate size of skb based on ring mode */ 2578 /* calculate size of skb based on ring mode */
2589 size = dev->mtu + HEADER_ETHERNET_II_802_3_SIZE + 2579 size = ring->mtu + HEADER_ETHERNET_II_802_3_SIZE +
2590 HEADER_802_2_SIZE + HEADER_SNAP_SIZE; 2580 HEADER_802_2_SIZE + HEADER_SNAP_SIZE;
2591 if (nic->rxd_mode == RXD_MODE_1) 2581 if (ring->rxd_mode == RXD_MODE_1)
2592 size += NET_IP_ALIGN; 2582 size += NET_IP_ALIGN;
2593 else 2583 else
2594 size = dev->mtu + ALIGN_SIZE + BUF0_LEN + 4; 2584 size = ring->mtu + ALIGN_SIZE + BUF0_LEN + 4;
2595 2585
2596 /* allocate skb */ 2586 /* allocate skb */
2597 skb = dev_alloc_skb(size); 2587 skb = dev_alloc_skb(size);
2598 if(!skb) { 2588 if(!skb) {
2599 DBG_PRINT(INFO_DBG, "%s: Out of ", dev->name); 2589 DBG_PRINT(INFO_DBG, "%s: Out of ", ring->dev->name);
2600 DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n"); 2590 DBG_PRINT(INFO_DBG, "memory to allocate SKBs\n");
2601 if (first_rxdp) { 2591 if (first_rxdp) {
2602 wmb(); 2592 wmb();
2603 first_rxdp->Control_1 |= RXD_OWN_XENA; 2593 first_rxdp->Control_1 |= RXD_OWN_XENA;
2604 } 2594 }
2605 nic->mac_control.stats_info->sw_stat. \ 2595 stats->mem_alloc_fail_cnt++;
2606 mem_alloc_fail_cnt++; 2596
2607 return -ENOMEM ; 2597 return -ENOMEM ;
2608 } 2598 }
2609 nic->mac_control.stats_info->sw_stat.mem_allocated 2599 stats->mem_allocated += skb->truesize;
2610 += skb->truesize; 2600
2611 if (nic->rxd_mode == RXD_MODE_1) { 2601 if (ring->rxd_mode == RXD_MODE_1) {
2612 /* 1 buffer mode - normal operation mode */ 2602 /* 1 buffer mode - normal operation mode */
2613 rxdp1 = (struct RxD1*)rxdp; 2603 rxdp1 = (struct RxD1*)rxdp;
2614 memset(rxdp, 0, sizeof(struct RxD1)); 2604 memset(rxdp, 0, sizeof(struct RxD1));
2615 skb_reserve(skb, NET_IP_ALIGN); 2605 skb_reserve(skb, NET_IP_ALIGN);
2616 rxdp1->Buffer0_ptr = pci_map_single 2606 rxdp1->Buffer0_ptr = pci_map_single
2617 (nic->pdev, skb->data, size - NET_IP_ALIGN, 2607 (ring->pdev, skb->data, size - NET_IP_ALIGN,
2618 PCI_DMA_FROMDEVICE); 2608 PCI_DMA_FROMDEVICE);
2619 if( (rxdp1->Buffer0_ptr == 0) || 2609 if( (rxdp1->Buffer0_ptr == 0) ||
2620 (rxdp1->Buffer0_ptr == 2610 (rxdp1->Buffer0_ptr ==
@@ -2623,8 +2613,8 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2623 2613
2624 rxdp->Control_2 = 2614 rxdp->Control_2 =
2625 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN); 2615 SET_BUFFER0_SIZE_1(size - NET_IP_ALIGN);
2626 2616 rxdp->Host_Control = (unsigned long) (skb);
2627 } else if (nic->rxd_mode == RXD_MODE_3B) { 2617 } else if (ring->rxd_mode == RXD_MODE_3B) {
2628 /* 2618 /*
2629 * 2 buffer mode - 2619 * 2 buffer mode -
2630 * 2 buffer mode provides 128 2620 * 2 buffer mode provides 128
@@ -2640,7 +2630,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2640 rxdp3->Buffer0_ptr = Buffer0_ptr; 2630 rxdp3->Buffer0_ptr = Buffer0_ptr;
2641 rxdp3->Buffer1_ptr = Buffer1_ptr; 2631 rxdp3->Buffer1_ptr = Buffer1_ptr;
2642 2632
2643 ba = &mac_control->rings[ring_no].ba[block_no][off]; 2633 ba = &ring->ba[block_no][off];
2644 skb_reserve(skb, BUF0_LEN); 2634 skb_reserve(skb, BUF0_LEN);
2645 tmp = (u64)(unsigned long) skb->data; 2635 tmp = (u64)(unsigned long) skb->data;
2646 tmp += ALIGN_SIZE; 2636 tmp += ALIGN_SIZE;
@@ -2650,10 +2640,10 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2650 2640
2651 if (!(rxdp3->Buffer0_ptr)) 2641 if (!(rxdp3->Buffer0_ptr))
2652 rxdp3->Buffer0_ptr = 2642 rxdp3->Buffer0_ptr =
2653 pci_map_single(nic->pdev, ba->ba_0, BUF0_LEN, 2643 pci_map_single(ring->pdev, ba->ba_0,
2654 PCI_DMA_FROMDEVICE); 2644 BUF0_LEN, PCI_DMA_FROMDEVICE);
2655 else 2645 else
2656 pci_dma_sync_single_for_device(nic->pdev, 2646 pci_dma_sync_single_for_device(ring->pdev,
2657 (dma_addr_t) rxdp3->Buffer0_ptr, 2647 (dma_addr_t) rxdp3->Buffer0_ptr,
2658 BUF0_LEN, PCI_DMA_FROMDEVICE); 2648 BUF0_LEN, PCI_DMA_FROMDEVICE);
2659 if( (rxdp3->Buffer0_ptr == 0) || 2649 if( (rxdp3->Buffer0_ptr == 0) ||
@@ -2661,7 +2651,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2661 goto pci_map_failed; 2651 goto pci_map_failed;
2662 2652
2663 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN); 2653 rxdp->Control_2 = SET_BUFFER0_SIZE_3(BUF0_LEN);
2664 if (nic->rxd_mode == RXD_MODE_3B) { 2654 if (ring->rxd_mode == RXD_MODE_3B) {
2665 /* Two buffer mode */ 2655 /* Two buffer mode */
2666 2656
2667 /* 2657 /*
@@ -2669,39 +2659,42 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2669 * L4 payload 2659 * L4 payload
2670 */ 2660 */
2671 rxdp3->Buffer2_ptr = pci_map_single 2661 rxdp3->Buffer2_ptr = pci_map_single
2672 (nic->pdev, skb->data, dev->mtu + 4, 2662 (ring->pdev, skb->data, ring->mtu + 4,
2673 PCI_DMA_FROMDEVICE); 2663 PCI_DMA_FROMDEVICE);
2674 2664
2675 if( (rxdp3->Buffer2_ptr == 0) || 2665 if( (rxdp3->Buffer2_ptr == 0) ||
2676 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE)) 2666 (rxdp3->Buffer2_ptr == DMA_ERROR_CODE))
2677 goto pci_map_failed; 2667 goto pci_map_failed;
2678 2668
2679 rxdp3->Buffer1_ptr = 2669 if (!rxdp3->Buffer1_ptr)
2680 pci_map_single(nic->pdev, 2670 rxdp3->Buffer1_ptr =
2671 pci_map_single(ring->pdev,
2681 ba->ba_1, BUF1_LEN, 2672 ba->ba_1, BUF1_LEN,
2682 PCI_DMA_FROMDEVICE); 2673 PCI_DMA_FROMDEVICE);
2674
2683 if( (rxdp3->Buffer1_ptr == 0) || 2675 if( (rxdp3->Buffer1_ptr == 0) ||
2684 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) { 2676 (rxdp3->Buffer1_ptr == DMA_ERROR_CODE)) {
2685 pci_unmap_single 2677 pci_unmap_single
2686 (nic->pdev, 2678 (ring->pdev,
2687 (dma_addr_t)rxdp3->Buffer2_ptr, 2679 (dma_addr_t)(unsigned long)
2688 dev->mtu + 4, 2680 skb->data,
2681 ring->mtu + 4,
2689 PCI_DMA_FROMDEVICE); 2682 PCI_DMA_FROMDEVICE);
2690 goto pci_map_failed; 2683 goto pci_map_failed;
2691 } 2684 }
2692 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1); 2685 rxdp->Control_2 |= SET_BUFFER1_SIZE_3(1);
2693 rxdp->Control_2 |= SET_BUFFER2_SIZE_3 2686 rxdp->Control_2 |= SET_BUFFER2_SIZE_3
2694 (dev->mtu + 4); 2687 (ring->mtu + 4);
2695 } 2688 }
2696 rxdp->Control_2 |= s2BIT(0); 2689 rxdp->Control_2 |= s2BIT(0);
2690 rxdp->Host_Control = (unsigned long) (skb);
2697 } 2691 }
2698 rxdp->Host_Control = (unsigned long) (skb);
2699 if (alloc_tab & ((1 << rxsync_frequency) - 1)) 2692 if (alloc_tab & ((1 << rxsync_frequency) - 1))
2700 rxdp->Control_1 |= RXD_OWN_XENA; 2693 rxdp->Control_1 |= RXD_OWN_XENA;
2701 off++; 2694 off++;
2702 if (off == (rxd_count[nic->rxd_mode] + 1)) 2695 if (off == (ring->rxd_count + 1))
2703 off = 0; 2696 off = 0;
2704 mac_control->rings[ring_no].rx_curr_put_info.offset = off; 2697 ring->rx_curr_put_info.offset = off;
2705 2698
2706 rxdp->Control_2 |= SET_RXD_MARKER; 2699 rxdp->Control_2 |= SET_RXD_MARKER;
2707 if (!(alloc_tab & ((1 << rxsync_frequency) - 1))) { 2700 if (!(alloc_tab & ((1 << rxsync_frequency) - 1))) {
@@ -2711,7 +2704,7 @@ static int fill_rx_buffers(struct s2io_nic *nic, int ring_no)
2711 } 2704 }
2712 first_rxdp = rxdp; 2705 first_rxdp = rxdp;
2713 } 2706 }
2714 atomic_inc(&nic->rx_bufs_left[ring_no]); 2707 ring->rx_bufs_left += 1;
2715 alloc_tab++; 2708 alloc_tab++;
2716 } 2709 }
2717 2710
@@ -2783,7 +2776,7 @@ static void free_rxd_blk(struct s2io_nic *sp, int ring_no, int blk)
2783 } 2776 }
2784 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize; 2777 sp->mac_control.stats_info->sw_stat.mem_freed += skb->truesize;
2785 dev_kfree_skb(skb); 2778 dev_kfree_skb(skb);
2786 atomic_dec(&sp->rx_bufs_left[ring_no]); 2779 mac_control->rings[ring_no].rx_bufs_left -= 1;
2787 } 2780 }
2788} 2781}
2789 2782
@@ -2814,7 +2807,7 @@ static void free_rx_buffers(struct s2io_nic *sp)
2814 mac_control->rings[i].rx_curr_get_info.block_index = 0; 2807 mac_control->rings[i].rx_curr_get_info.block_index = 0;
2815 mac_control->rings[i].rx_curr_put_info.offset = 0; 2808 mac_control->rings[i].rx_curr_put_info.offset = 0;
2816 mac_control->rings[i].rx_curr_get_info.offset = 0; 2809 mac_control->rings[i].rx_curr_get_info.offset = 0;
2817 atomic_set(&sp->rx_bufs_left[i], 0); 2810 mac_control->rings[i].rx_bufs_left = 0;
2818 DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n", 2811 DBG_PRINT(INIT_DBG, "%s:Freed 0x%x Rx Buffers on ring%d\n",
2819 dev->name, buf_cnt, i); 2812 dev->name, buf_cnt, i);
2820 } 2813 }
@@ -2864,7 +2857,7 @@ static int s2io_poll(struct napi_struct *napi, int budget)
2864 netif_rx_complete(dev, napi); 2857 netif_rx_complete(dev, napi);
2865 2858
2866 for (i = 0; i < config->rx_ring_num; i++) { 2859 for (i = 0; i < config->rx_ring_num; i++) {
2867 if (fill_rx_buffers(nic, i) == -ENOMEM) { 2860 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) {
2868 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2861 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name);
2869 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n"); 2862 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n");
2870 break; 2863 break;
@@ -2877,7 +2870,7 @@ static int s2io_poll(struct napi_struct *napi, int budget)
2877 2870
2878no_rx: 2871no_rx:
2879 for (i = 0; i < config->rx_ring_num; i++) { 2872 for (i = 0; i < config->rx_ring_num; i++) {
2880 if (fill_rx_buffers(nic, i) == -ENOMEM) { 2873 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) {
2881 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2874 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name);
2882 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n"); 2875 DBG_PRINT(INFO_DBG, " in Rx Poll!!\n");
2883 break; 2876 break;
@@ -2928,7 +2921,7 @@ static void s2io_netpoll(struct net_device *dev)
2928 rx_intr_handler(&mac_control->rings[i]); 2921 rx_intr_handler(&mac_control->rings[i]);
2929 2922
2930 for (i = 0; i < config->rx_ring_num; i++) { 2923 for (i = 0; i < config->rx_ring_num; i++) {
2931 if (fill_rx_buffers(nic, i) == -ENOMEM) { 2924 if (fill_rx_buffers(&mac_control->rings[i]) == -ENOMEM) {
2932 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name); 2925 DBG_PRINT(INFO_DBG, "%s:Out of memory", dev->name);
2933 DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n"); 2926 DBG_PRINT(INFO_DBG, " in Rx Netpoll!!\n");
2934 break; 2927 break;
@@ -2953,8 +2946,6 @@ static void s2io_netpoll(struct net_device *dev)
2953 */ 2946 */
2954static void rx_intr_handler(struct ring_info *ring_data) 2947static void rx_intr_handler(struct ring_info *ring_data)
2955{ 2948{
2956 struct s2io_nic *nic = ring_data->nic;
2957 struct net_device *dev = (struct net_device *) nic->dev;
2958 int get_block, put_block; 2949 int get_block, put_block;
2959 struct rx_curr_get_info get_info, put_info; 2950 struct rx_curr_get_info get_info, put_info;
2960 struct RxD_t *rxdp; 2951 struct RxD_t *rxdp;
@@ -2977,33 +2968,34 @@ static void rx_intr_handler(struct ring_info *ring_data)
2977 */ 2968 */
2978 if ((get_block == put_block) && 2969 if ((get_block == put_block) &&
2979 (get_info.offset + 1) == put_info.offset) { 2970 (get_info.offset + 1) == put_info.offset) {
2980 DBG_PRINT(INTR_DBG, "%s: Ring Full\n",dev->name); 2971 DBG_PRINT(INTR_DBG, "%s: Ring Full\n",
2972 ring_data->dev->name);
2981 break; 2973 break;
2982 } 2974 }
2983 skb = (struct sk_buff *) ((unsigned long)rxdp->Host_Control); 2975 skb = (struct sk_buff *) ((unsigned long)rxdp->Host_Control);
2984 if (skb == NULL) { 2976 if (skb == NULL) {
2985 DBG_PRINT(ERR_DBG, "%s: The skb is ", 2977 DBG_PRINT(ERR_DBG, "%s: The skb is ",
2986 dev->name); 2978 ring_data->dev->name);
2987 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n"); 2979 DBG_PRINT(ERR_DBG, "Null in Rx Intr\n");
2988 return; 2980 return;
2989 } 2981 }
2990 if (nic->rxd_mode == RXD_MODE_1) { 2982 if (ring_data->rxd_mode == RXD_MODE_1) {
2991 rxdp1 = (struct RxD1*)rxdp; 2983 rxdp1 = (struct RxD1*)rxdp;
2992 pci_unmap_single(nic->pdev, (dma_addr_t) 2984 pci_unmap_single(ring_data->pdev, (dma_addr_t)
2993 rxdp1->Buffer0_ptr, 2985 rxdp1->Buffer0_ptr,
2994 dev->mtu + 2986 ring_data->mtu +
2995 HEADER_ETHERNET_II_802_3_SIZE + 2987 HEADER_ETHERNET_II_802_3_SIZE +
2996 HEADER_802_2_SIZE + 2988 HEADER_802_2_SIZE +
2997 HEADER_SNAP_SIZE, 2989 HEADER_SNAP_SIZE,
2998 PCI_DMA_FROMDEVICE); 2990 PCI_DMA_FROMDEVICE);
2999 } else if (nic->rxd_mode == RXD_MODE_3B) { 2991 } else if (ring_data->rxd_mode == RXD_MODE_3B) {
3000 rxdp3 = (struct RxD3*)rxdp; 2992 rxdp3 = (struct RxD3*)rxdp;
3001 pci_dma_sync_single_for_cpu(nic->pdev, (dma_addr_t) 2993 pci_dma_sync_single_for_cpu(ring_data->pdev, (dma_addr_t)
3002 rxdp3->Buffer0_ptr, 2994 rxdp3->Buffer0_ptr,
3003 BUF0_LEN, PCI_DMA_FROMDEVICE); 2995 BUF0_LEN, PCI_DMA_FROMDEVICE);
3004 pci_unmap_single(nic->pdev, (dma_addr_t) 2996 pci_unmap_single(ring_data->pdev, (dma_addr_t)
3005 rxdp3->Buffer2_ptr, 2997 rxdp3->Buffer2_ptr,
3006 dev->mtu + 4, 2998 ring_data->mtu + 4,
3007 PCI_DMA_FROMDEVICE); 2999 PCI_DMA_FROMDEVICE);
3008 } 3000 }
3009 prefetch(skb->data); 3001 prefetch(skb->data);
@@ -3012,7 +3004,7 @@ static void rx_intr_handler(struct ring_info *ring_data)
3012 ring_data->rx_curr_get_info.offset = get_info.offset; 3004 ring_data->rx_curr_get_info.offset = get_info.offset;
3013 rxdp = ring_data->rx_blocks[get_block]. 3005 rxdp = ring_data->rx_blocks[get_block].
3014 rxds[get_info.offset].virt_addr; 3006 rxds[get_info.offset].virt_addr;
3015 if (get_info.offset == rxd_count[nic->rxd_mode]) { 3007 if (get_info.offset == rxd_count[ring_data->rxd_mode]) {
3016 get_info.offset = 0; 3008 get_info.offset = 0;
3017 ring_data->rx_curr_get_info.offset = get_info.offset; 3009 ring_data->rx_curr_get_info.offset = get_info.offset;
3018 get_block++; 3010 get_block++;
@@ -3022,19 +3014,21 @@ static void rx_intr_handler(struct ring_info *ring_data)
3022 rxdp = ring_data->rx_blocks[get_block].block_virt_addr; 3014 rxdp = ring_data->rx_blocks[get_block].block_virt_addr;
3023 } 3015 }
3024 3016
3025 nic->pkts_to_process -= 1; 3017 if(ring_data->nic->config.napi){
3026 if ((napi) && (!nic->pkts_to_process)) 3018 ring_data->nic->pkts_to_process -= 1;
3027 break; 3019 if (!ring_data->nic->pkts_to_process)
3020 break;
3021 }
3028 pkt_cnt++; 3022 pkt_cnt++;
3029 if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts)) 3023 if ((indicate_max_pkts) && (pkt_cnt > indicate_max_pkts))
3030 break; 3024 break;
3031 } 3025 }
3032 if (nic->lro) { 3026 if (ring_data->lro) {
3033 /* Clear all LRO sessions before exiting */ 3027 /* Clear all LRO sessions before exiting */
3034 for (i=0; i<MAX_LRO_SESSIONS; i++) { 3028 for (i=0; i<MAX_LRO_SESSIONS; i++) {
3035 struct lro *lro = &nic->lro0_n[i]; 3029 struct lro *lro = &ring_data->lro0_n[i];
3036 if (lro->in_use) { 3030 if (lro->in_use) {
3037 update_L3L4_header(nic, lro); 3031 update_L3L4_header(ring_data->nic, lro);
3038 queue_rx_frame(lro->parent, lro->vlan_tag); 3032 queue_rx_frame(lro->parent, lro->vlan_tag);
3039 clear_lro_session(lro); 3033 clear_lro_session(lro);
3040 } 3034 }
@@ -4333,10 +4327,10 @@ s2io_alarm_handle(unsigned long data)
4333 mod_timer(&sp->alarm_timer, jiffies + HZ / 2); 4327 mod_timer(&sp->alarm_timer, jiffies + HZ / 2);
4334} 4328}
4335 4329
4336static int s2io_chk_rx_buffers(struct s2io_nic *sp, int rng_n) 4330static int s2io_chk_rx_buffers(struct ring_info *ring)
4337{ 4331{
4338 if (fill_rx_buffers(sp, rng_n) == -ENOMEM) { 4332 if (fill_rx_buffers(ring) == -ENOMEM) {
4339 DBG_PRINT(INFO_DBG, "%s:Out of memory", sp->dev->name); 4333 DBG_PRINT(INFO_DBG, "%s:Out of memory", ring->dev->name);
4340 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n"); 4334 DBG_PRINT(INFO_DBG, " in Rx Intr!!\n");
4341 } 4335 }
4342 return 0; 4336 return 0;
@@ -4351,7 +4345,7 @@ static irqreturn_t s2io_msix_ring_handle(int irq, void *dev_id)
4351 return IRQ_HANDLED; 4345 return IRQ_HANDLED;
4352 4346
4353 rx_intr_handler(ring); 4347 rx_intr_handler(ring);
4354 s2io_chk_rx_buffers(sp, ring->ring_no); 4348 s2io_chk_rx_buffers(ring);
4355 4349
4356 return IRQ_HANDLED; 4350 return IRQ_HANDLED;
4357} 4351}
@@ -4809,7 +4803,7 @@ static irqreturn_t s2io_isr(int irq, void *dev_id)
4809 */ 4803 */
4810 if (!config->napi) { 4804 if (!config->napi) {
4811 for (i = 0; i < config->rx_ring_num; i++) 4805 for (i = 0; i < config->rx_ring_num; i++)
4812 s2io_chk_rx_buffers(sp, i); 4806 s2io_chk_rx_buffers(&mac_control->rings[i]);
4813 } 4807 }
4814 writeq(sp->general_int_mask, &bar0->general_int_mask); 4808 writeq(sp->general_int_mask, &bar0->general_int_mask);
4815 readl(&bar0->general_int_status); 4809 readl(&bar0->general_int_status);
@@ -4866,6 +4860,7 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4866 struct s2io_nic *sp = dev->priv; 4860 struct s2io_nic *sp = dev->priv;
4867 struct mac_info *mac_control; 4861 struct mac_info *mac_control;
4868 struct config_param *config; 4862 struct config_param *config;
4863 int i;
4869 4864
4870 4865
4871 mac_control = &sp->mac_control; 4866 mac_control = &sp->mac_control;
@@ -4885,6 +4880,13 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4885 sp->stats.rx_length_errors = 4880 sp->stats.rx_length_errors =
4886 le64_to_cpu(mac_control->stats_info->rmac_long_frms); 4881 le64_to_cpu(mac_control->stats_info->rmac_long_frms);
4887 4882
4883 /* collect per-ring rx_packets and rx_bytes */
4884 sp->stats.rx_packets = sp->stats.rx_bytes = 0;
4885 for (i = 0; i < config->rx_ring_num; i++) {
4886 sp->stats.rx_packets += mac_control->rings[i].rx_packets;
4887 sp->stats.rx_bytes += mac_control->rings[i].rx_bytes;
4888 }
4889
4888 return (&sp->stats); 4890 return (&sp->stats);
4889} 4891}
4890 4892
@@ -7157,7 +7159,9 @@ static int s2io_card_up(struct s2io_nic * sp)
7157 config = &sp->config; 7159 config = &sp->config;
7158 7160
7159 for (i = 0; i < config->rx_ring_num; i++) { 7161 for (i = 0; i < config->rx_ring_num; i++) {
7160 if ((ret = fill_rx_buffers(sp, i))) { 7162 mac_control->rings[i].mtu = dev->mtu;
7163 ret = fill_rx_buffers(&mac_control->rings[i]);
7164 if (ret) {
7161 DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n", 7165 DBG_PRINT(ERR_DBG, "%s: Out of memory in Open\n",
7162 dev->name); 7166 dev->name);
7163 s2io_reset(sp); 7167 s2io_reset(sp);
@@ -7165,7 +7169,7 @@ static int s2io_card_up(struct s2io_nic * sp)
7165 return -ENOMEM; 7169 return -ENOMEM;
7166 } 7170 }
7167 DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i, 7171 DBG_PRINT(INFO_DBG, "Buf in ring:%d is %d:\n", i,
7168 atomic_read(&sp->rx_bufs_left[i])); 7172 mac_control->rings[i].rx_bufs_left);
7169 } 7173 }
7170 7174
7171 /* Initialise napi */ 7175 /* Initialise napi */
@@ -7300,7 +7304,7 @@ static void s2io_tx_watchdog(struct net_device *dev)
7300static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp) 7304static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7301{ 7305{
7302 struct s2io_nic *sp = ring_data->nic; 7306 struct s2io_nic *sp = ring_data->nic;
7303 struct net_device *dev = (struct net_device *) sp->dev; 7307 struct net_device *dev = (struct net_device *) ring_data->dev;
7304 struct sk_buff *skb = (struct sk_buff *) 7308 struct sk_buff *skb = (struct sk_buff *)
7305 ((unsigned long) rxdp->Host_Control); 7309 ((unsigned long) rxdp->Host_Control);
7306 int ring_no = ring_data->ring_no; 7310 int ring_no = ring_data->ring_no;
@@ -7377,19 +7381,19 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7377 sp->mac_control.stats_info->sw_stat.mem_freed 7381 sp->mac_control.stats_info->sw_stat.mem_freed
7378 += skb->truesize; 7382 += skb->truesize;
7379 dev_kfree_skb(skb); 7383 dev_kfree_skb(skb);
7380 atomic_dec(&sp->rx_bufs_left[ring_no]); 7384 ring_data->rx_bufs_left -= 1;
7381 rxdp->Host_Control = 0; 7385 rxdp->Host_Control = 0;
7382 return 0; 7386 return 0;
7383 } 7387 }
7384 } 7388 }
7385 7389
7386 /* Updating statistics */ 7390 /* Updating statistics */
7387 sp->stats.rx_packets++; 7391 ring_data->rx_packets++;
7388 rxdp->Host_Control = 0; 7392 rxdp->Host_Control = 0;
7389 if (sp->rxd_mode == RXD_MODE_1) { 7393 if (sp->rxd_mode == RXD_MODE_1) {
7390 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2); 7394 int len = RXD_GET_BUFFER0_SIZE_1(rxdp->Control_2);
7391 7395
7392 sp->stats.rx_bytes += len; 7396 ring_data->rx_bytes += len;
7393 skb_put(skb, len); 7397 skb_put(skb, len);
7394 7398
7395 } else if (sp->rxd_mode == RXD_MODE_3B) { 7399 } else if (sp->rxd_mode == RXD_MODE_3B) {
@@ -7400,13 +7404,13 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7400 unsigned char *buff = skb_push(skb, buf0_len); 7404 unsigned char *buff = skb_push(skb, buf0_len);
7401 7405
7402 struct buffAdd *ba = &ring_data->ba[get_block][get_off]; 7406 struct buffAdd *ba = &ring_data->ba[get_block][get_off];
7403 sp->stats.rx_bytes += buf0_len + buf2_len; 7407 ring_data->rx_bytes += buf0_len + buf2_len;
7404 memcpy(buff, ba->ba_0, buf0_len); 7408 memcpy(buff, ba->ba_0, buf0_len);
7405 skb_put(skb, buf2_len); 7409 skb_put(skb, buf2_len);
7406 } 7410 }
7407 7411
7408 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && ((!sp->lro) || 7412 if ((rxdp->Control_1 & TCP_OR_UDP_FRAME) && ((!ring_data->lro) ||
7409 (sp->lro && (!(rxdp->Control_1 & RXD_FRAME_IP_FRAG)))) && 7413 (ring_data->lro && (!(rxdp->Control_1 & RXD_FRAME_IP_FRAG)))) &&
7410 (sp->rx_csum)) { 7414 (sp->rx_csum)) {
7411 l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1); 7415 l3_csum = RXD_GET_L3_CKSUM(rxdp->Control_1);
7412 l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1); 7416 l4_csum = RXD_GET_L4_CKSUM(rxdp->Control_1);
@@ -7417,14 +7421,14 @@ static int rx_osm_handler(struct ring_info *ring_data, struct RxD_t * rxdp)
7417 * a flag in the RxD. 7421 * a flag in the RxD.
7418 */ 7422 */
7419 skb->ip_summed = CHECKSUM_UNNECESSARY; 7423 skb->ip_summed = CHECKSUM_UNNECESSARY;
7420 if (sp->lro) { 7424 if (ring_data->lro) {
7421 u32 tcp_len; 7425 u32 tcp_len;
7422 u8 *tcp; 7426 u8 *tcp;
7423 int ret = 0; 7427 int ret = 0;
7424 7428
7425 ret = s2io_club_tcp_session(skb->data, &tcp, 7429 ret = s2io_club_tcp_session(ring_data,
7426 &tcp_len, &lro, 7430 skb->data, &tcp, &tcp_len, &lro,
7427 rxdp, sp); 7431 rxdp, sp);
7428 switch (ret) { 7432 switch (ret) {
7429 case 3: /* Begin anew */ 7433 case 3: /* Begin anew */
7430 lro->parent = skb; 7434 lro->parent = skb;
@@ -7486,7 +7490,7 @@ send_up:
7486 queue_rx_frame(skb, RXD_GET_VLAN_TAG(rxdp->Control_2)); 7490 queue_rx_frame(skb, RXD_GET_VLAN_TAG(rxdp->Control_2));
7487 dev->last_rx = jiffies; 7491 dev->last_rx = jiffies;
7488aggregate: 7492aggregate:
7489 atomic_dec(&sp->rx_bufs_left[ring_no]); 7493 sp->mac_control.rings[ring_no].rx_bufs_left -= 1;
7490 return SUCCESS; 7494 return SUCCESS;
7491} 7495}
7492 7496
@@ -7603,12 +7607,14 @@ static int s2io_verify_parm(struct pci_dev *pdev, u8 *dev_intr_type,
7603 tx_steering_type = NO_STEERING; 7607 tx_steering_type = NO_STEERING;
7604 } 7608 }
7605 7609
7606 if ( rx_ring_num > 8) { 7610 if (rx_ring_num > MAX_RX_RINGS) {
7607 DBG_PRINT(ERR_DBG, "s2io: Requested number of Rx rings not " 7611 DBG_PRINT(ERR_DBG, "s2io: Requested number of rx rings not "
7608 "supported\n"); 7612 "supported\n");
7609 DBG_PRINT(ERR_DBG, "s2io: Default to 8 Rx rings\n"); 7613 DBG_PRINT(ERR_DBG, "s2io: Default to %d rx rings\n",
7610 rx_ring_num = 8; 7614 MAX_RX_RINGS);
7615 rx_ring_num = MAX_RX_RINGS;
7611 } 7616 }
7617
7612 if (*dev_intr_type != INTA) 7618 if (*dev_intr_type != INTA)
7613 napi = 0; 7619 napi = 0;
7614 7620
@@ -7836,10 +7842,15 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7836 7842
7837 /* Rx side parameters. */ 7843 /* Rx side parameters. */
7838 config->rx_ring_num = rx_ring_num; 7844 config->rx_ring_num = rx_ring_num;
7839 for (i = 0; i < MAX_RX_RINGS; i++) { 7845 for (i = 0; i < config->rx_ring_num; i++) {
7840 config->rx_cfg[i].num_rxd = rx_ring_sz[i] * 7846 config->rx_cfg[i].num_rxd = rx_ring_sz[i] *
7841 (rxd_count[sp->rxd_mode] + 1); 7847 (rxd_count[sp->rxd_mode] + 1);
7842 config->rx_cfg[i].ring_priority = i; 7848 config->rx_cfg[i].ring_priority = i;
7849 mac_control->rings[i].rx_bufs_left = 0;
7850 mac_control->rings[i].rxd_mode = sp->rxd_mode;
7851 mac_control->rings[i].rxd_count = rxd_count[sp->rxd_mode];
7852 mac_control->rings[i].pdev = sp->pdev;
7853 mac_control->rings[i].dev = sp->dev;
7843 } 7854 }
7844 7855
7845 for (i = 0; i < rx_ring_num; i++) { 7856 for (i = 0; i < rx_ring_num; i++) {
@@ -7854,10 +7865,6 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7854 mac_control->mc_pause_threshold_q4q7 = mc_pause_threshold_q4q7; 7865 mac_control->mc_pause_threshold_q4q7 = mc_pause_threshold_q4q7;
7855 7866
7856 7867
7857 /* Initialize Ring buffer parameters. */
7858 for (i = 0; i < config->rx_ring_num; i++)
7859 atomic_set(&sp->rx_bufs_left[i], 0);
7860
7861 /* initialize the shared memory used by the NIC and the host */ 7868 /* initialize the shared memory used by the NIC and the host */
7862 if (init_shared_mem(sp)) { 7869 if (init_shared_mem(sp)) {
7863 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n", 7870 DBG_PRINT(ERR_DBG, "%s: Memory allocation failed\n",
@@ -8077,6 +8084,9 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
8077 DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name, 8084 DBG_PRINT(ERR_DBG, "%s: Using %d Tx fifo(s)\n", dev->name,
8078 sp->config.tx_fifo_num); 8085 sp->config.tx_fifo_num);
8079 8086
8087 DBG_PRINT(ERR_DBG, "%s: Using %d Rx ring(s)\n", dev->name,
8088 sp->config.rx_ring_num);
8089
8080 switch(sp->config.intr_type) { 8090 switch(sp->config.intr_type) {
8081 case INTA: 8091 case INTA:
8082 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name); 8092 DBG_PRINT(ERR_DBG, "%s: Interrupt type INTA\n", dev->name);
@@ -8391,8 +8401,9 @@ static int verify_l3_l4_lro_capable(struct lro *l_lro, struct iphdr *ip,
8391} 8401}
8392 8402
8393static int 8403static int
8394s2io_club_tcp_session(u8 *buffer, u8 **tcp, u32 *tcp_len, struct lro **lro, 8404s2io_club_tcp_session(struct ring_info *ring_data, u8 *buffer, u8 **tcp,
8395 struct RxD_t *rxdp, struct s2io_nic *sp) 8405 u32 *tcp_len, struct lro **lro, struct RxD_t *rxdp,
8406 struct s2io_nic *sp)
8396{ 8407{
8397 struct iphdr *ip; 8408 struct iphdr *ip;
8398 struct tcphdr *tcph; 8409 struct tcphdr *tcph;
@@ -8410,7 +8421,7 @@ s2io_club_tcp_session(u8 *buffer, u8 **tcp, u32 *tcp_len, struct lro **lro,
8410 tcph = (struct tcphdr *)*tcp; 8421 tcph = (struct tcphdr *)*tcp;
8411 *tcp_len = get_l4_pyld_length(ip, tcph); 8422 *tcp_len = get_l4_pyld_length(ip, tcph);
8412 for (i=0; i<MAX_LRO_SESSIONS; i++) { 8423 for (i=0; i<MAX_LRO_SESSIONS; i++) {
8413 struct lro *l_lro = &sp->lro0_n[i]; 8424 struct lro *l_lro = &ring_data->lro0_n[i];
8414 if (l_lro->in_use) { 8425 if (l_lro->in_use) {
8415 if (check_for_socket_match(l_lro, ip, tcph)) 8426 if (check_for_socket_match(l_lro, ip, tcph))
8416 continue; 8427 continue;
@@ -8448,7 +8459,7 @@ s2io_club_tcp_session(u8 *buffer, u8 **tcp, u32 *tcp_len, struct lro **lro,
8448 } 8459 }
8449 8460
8450 for (i=0; i<MAX_LRO_SESSIONS; i++) { 8461 for (i=0; i<MAX_LRO_SESSIONS; i++) {
8451 struct lro *l_lro = &sp->lro0_n[i]; 8462 struct lro *l_lro = &ring_data->lro0_n[i];
8452 if (!(l_lro->in_use)) { 8463 if (!(l_lro->in_use)) {
8453 *lro = l_lro; 8464 *lro = l_lro;
8454 ret = 3; /* Begin anew */ 8465 ret = 3; /* Begin anew */
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index ce53a02105f2..0709ebae9139 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -678,11 +678,53 @@ struct rx_block_info {
678 struct rxd_info *rxds; 678 struct rxd_info *rxds;
679}; 679};
680 680
681/* Data structure to represent a LRO session */
682struct lro {
683 struct sk_buff *parent;
684 struct sk_buff *last_frag;
685 u8 *l2h;
686 struct iphdr *iph;
687 struct tcphdr *tcph;
688 u32 tcp_next_seq;
689 __be32 tcp_ack;
690 int total_len;
691 int frags_len;
692 int sg_num;
693 int in_use;
694 __be16 window;
695 u16 vlan_tag;
696 u32 cur_tsval;
697 __be32 cur_tsecr;
698 u8 saw_ts;
699} ____cacheline_aligned;
700
681/* Ring specific structure */ 701/* Ring specific structure */
682struct ring_info { 702struct ring_info {
683 /* The ring number */ 703 /* The ring number */
684 int ring_no; 704 int ring_no;
685 705
706 /* per-ring buffer counter */
707 u32 rx_bufs_left;
708
709 #define MAX_LRO_SESSIONS 32
710 struct lro lro0_n[MAX_LRO_SESSIONS];
711 u8 lro;
712
713 /* copy of sp->rxd_mode flag */
714 int rxd_mode;
715
716 /* Number of rxds per block for the rxd_mode */
717 int rxd_count;
718
719 /* copy of sp pointer */
720 struct s2io_nic *nic;
721
722 /* copy of sp->dev pointer */
723 struct net_device *dev;
724
725 /* copy of sp->pdev pointer */
726 struct pci_dev *pdev;
727
686 /* 728 /*
687 * Place holders for the virtual and physical addresses of 729 * Place holders for the virtual and physical addresses of
688 * all the Rx Blocks 730 * all the Rx Blocks
@@ -703,10 +745,16 @@ struct ring_info {
703 */ 745 */
704 struct rx_curr_get_info rx_curr_get_info; 746 struct rx_curr_get_info rx_curr_get_info;
705 747
748 /* interface MTU value */
749 unsigned mtu;
750
706 /* Buffer Address store. */ 751 /* Buffer Address store. */
707 struct buffAdd **ba; 752 struct buffAdd **ba;
708 struct s2io_nic *nic; 753
709}; 754 /* per-Ring statistics */
755 unsigned long rx_packets;
756 unsigned long rx_bytes;
757} ____cacheline_aligned;
710 758
711/* Fifo specific structure */ 759/* Fifo specific structure */
712struct fifo_info { 760struct fifo_info {
@@ -813,26 +861,6 @@ struct msix_info_st {
813 u64 data; 861 u64 data;
814}; 862};
815 863
816/* Data structure to represent a LRO session */
817struct lro {
818 struct sk_buff *parent;
819 struct sk_buff *last_frag;
820 u8 *l2h;
821 struct iphdr *iph;
822 struct tcphdr *tcph;
823 u32 tcp_next_seq;
824 __be32 tcp_ack;
825 int total_len;
826 int frags_len;
827 int sg_num;
828 int in_use;
829 __be16 window;
830 u16 vlan_tag;
831 u32 cur_tsval;
832 __be32 cur_tsecr;
833 u8 saw_ts;
834} ____cacheline_aligned;
835
836/* These flags represent the devices temporary state */ 864/* These flags represent the devices temporary state */
837enum s2io_device_state_t 865enum s2io_device_state_t
838{ 866{
@@ -872,8 +900,6 @@ struct s2io_nic {
872 /* Space to back up the PCI config space */ 900 /* Space to back up the PCI config space */
873 u32 config_space[256 / sizeof(u32)]; 901 u32 config_space[256 / sizeof(u32)];
874 902
875 atomic_t rx_bufs_left[MAX_RX_RINGS];
876
877#define PROMISC 1 903#define PROMISC 1
878#define ALL_MULTI 2 904#define ALL_MULTI 2
879 905
@@ -950,8 +976,6 @@ struct s2io_nic {
950#define XFRAME_II_DEVICE 2 976#define XFRAME_II_DEVICE 2
951 u8 device_type; 977 u8 device_type;
952 978
953#define MAX_LRO_SESSIONS 32
954 struct lro lro0_n[MAX_LRO_SESSIONS];
955 unsigned long clubbed_frms_cnt; 979 unsigned long clubbed_frms_cnt;
956 unsigned long sending_both; 980 unsigned long sending_both;
957 u8 lro; 981 u8 lro;
@@ -1118,9 +1142,9 @@ static int do_s2io_add_mc(struct s2io_nic *sp, u8 *addr);
1118static int do_s2io_add_mac(struct s2io_nic *sp, u64 addr, int offset); 1142static int do_s2io_add_mac(struct s2io_nic *sp, u64 addr, int offset);
1119static int do_s2io_delete_unicast_mc(struct s2io_nic *sp, u64 addr); 1143static int do_s2io_delete_unicast_mc(struct s2io_nic *sp, u64 addr);
1120 1144
1121static int 1145static int s2io_club_tcp_session(struct ring_info *ring_data, u8 *buffer,
1122s2io_club_tcp_session(u8 *buffer, u8 **tcp, u32 *tcp_len, struct lro **lro, 1146 u8 **tcp, u32 *tcp_len, struct lro **lro, struct RxD_t *rxdp,
1123 struct RxD_t *rxdp, struct s2io_nic *sp); 1147 struct s2io_nic *sp);
1124static void clear_lro_session(struct lro *lro); 1148static void clear_lro_session(struct lro *lro);
1125static void queue_rx_frame(struct sk_buff *skb, u16 vlan_tag); 1149static void queue_rx_frame(struct sk_buff *skb, u16 vlan_tag);
1126static void update_L3L4_header(struct s2io_nic *sp, struct lro *lro); 1150static void update_L3L4_header(struct s2io_nic *sp, struct lro *lro);
diff --git a/drivers/net/sfc/Kconfig b/drivers/net/sfc/Kconfig
new file mode 100644
index 000000000000..dbad95c295bd
--- /dev/null
+++ b/drivers/net/sfc/Kconfig
@@ -0,0 +1,12 @@
1config SFC
2 tristate "Solarflare Solarstorm SFC4000 support"
3 depends on PCI && INET
4 select MII
5 select INET_LRO
6 select CRC32
7 help
8 This driver supports 10-gigabit Ethernet cards based on
9 the Solarflare Communications Solarstorm SFC4000 controller.
10
11 To compile this driver as a module, choose M here. The module
12 will be called sfc.
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
new file mode 100644
index 000000000000..0f023447eafd
--- /dev/null
+++ b/drivers/net/sfc/Makefile
@@ -0,0 +1,5 @@
1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \
2 i2c-direct.o ethtool.o xfp_phy.o mdio_10g.o \
3 tenxpress.o boards.o sfe4001.o
4
5obj-$(CONFIG_SFC) += sfc.o
diff --git a/drivers/net/sfc/bitfield.h b/drivers/net/sfc/bitfield.h
new file mode 100644
index 000000000000..2806201644cc
--- /dev/null
+++ b/drivers/net/sfc/bitfield.h
@@ -0,0 +1,508 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_BITFIELD_H
12#define EFX_BITFIELD_H
13
14/*
15 * Efx bitfield access
16 *
17 * Efx NICs make extensive use of bitfields up to 128 bits
18 * wide. Since there is no native 128-bit datatype on most systems,
19 * and since 64-bit datatypes are inefficient on 32-bit systems and
20 * vice versa, we wrap accesses in a way that uses the most efficient
21 * datatype.
22 *
23 * The NICs are PCI devices and therefore little-endian. Since most
24 * of the quantities that we deal with are DMAed to/from host memory,
25 * we define our datatypes (efx_oword_t, efx_qword_t and
26 * efx_dword_t) to be little-endian.
27 */
28
29/* Lowest bit numbers and widths */
30#define EFX_DUMMY_FIELD_LBN 0
31#define EFX_DUMMY_FIELD_WIDTH 0
32#define EFX_DWORD_0_LBN 0
33#define EFX_DWORD_0_WIDTH 32
34#define EFX_DWORD_1_LBN 32
35#define EFX_DWORD_1_WIDTH 32
36#define EFX_DWORD_2_LBN 64
37#define EFX_DWORD_2_WIDTH 32
38#define EFX_DWORD_3_LBN 96
39#define EFX_DWORD_3_WIDTH 32
40
41/* Specified attribute (e.g. LBN) of the specified field */
42#define EFX_VAL(field, attribute) field ## _ ## attribute
43/* Low bit number of the specified field */
44#define EFX_LOW_BIT(field) EFX_VAL(field, LBN)
45/* Bit width of the specified field */
46#define EFX_WIDTH(field) EFX_VAL(field, WIDTH)
47/* High bit number of the specified field */
48#define EFX_HIGH_BIT(field) (EFX_LOW_BIT(field) + EFX_WIDTH(field) - 1)
49/* Mask equal in width to the specified field.
50 *
51 * For example, a field with width 5 would have a mask of 0x1f.
52 *
53 * The maximum width mask that can be generated is 64 bits.
54 */
55#define EFX_MASK64(field) \
56 (EFX_WIDTH(field) == 64 ? ~((u64) 0) : \
57 (((((u64) 1) << EFX_WIDTH(field))) - 1))
58
59/* Mask equal in width to the specified field.
60 *
61 * For example, a field with width 5 would have a mask of 0x1f.
62 *
63 * The maximum width mask that can be generated is 32 bits. Use
64 * EFX_MASK64 for higher width fields.
65 */
66#define EFX_MASK32(field) \
67 (EFX_WIDTH(field) == 32 ? ~((u32) 0) : \
68 (((((u32) 1) << EFX_WIDTH(field))) - 1))
69
70/* A doubleword (i.e. 4 byte) datatype - little-endian in HW */
71typedef union efx_dword {
72 __le32 u32[1];
73} efx_dword_t;
74
75/* A quadword (i.e. 8 byte) datatype - little-endian in HW */
76typedef union efx_qword {
77 __le64 u64[1];
78 __le32 u32[2];
79 efx_dword_t dword[2];
80} efx_qword_t;
81
82/* An octword (eight-word, i.e. 16 byte) datatype - little-endian in HW */
83typedef union efx_oword {
84 __le64 u64[2];
85 efx_qword_t qword[2];
86 __le32 u32[4];
87 efx_dword_t dword[4];
88} efx_oword_t;
89
90/* Format string and value expanders for printk */
91#define EFX_DWORD_FMT "%08x"
92#define EFX_QWORD_FMT "%08x:%08x"
93#define EFX_OWORD_FMT "%08x:%08x:%08x:%08x"
94#define EFX_DWORD_VAL(dword) \
95 ((unsigned int) le32_to_cpu((dword).u32[0]))
96#define EFX_QWORD_VAL(qword) \
97 ((unsigned int) le32_to_cpu((qword).u32[1])), \
98 ((unsigned int) le32_to_cpu((qword).u32[0]))
99#define EFX_OWORD_VAL(oword) \
100 ((unsigned int) le32_to_cpu((oword).u32[3])), \
101 ((unsigned int) le32_to_cpu((oword).u32[2])), \
102 ((unsigned int) le32_to_cpu((oword).u32[1])), \
103 ((unsigned int) le32_to_cpu((oword).u32[0]))
104
105/*
106 * Extract bit field portion [low,high) from the native-endian element
107 * which contains bits [min,max).
108 *
109 * For example, suppose "element" represents the high 32 bits of a
110 * 64-bit value, and we wish to extract the bits belonging to the bit
111 * field occupying bits 28-45 of this 64-bit value.
112 *
113 * Then EFX_EXTRACT ( element, 32, 63, 28, 45 ) would give
114 *
115 * ( element ) << 4
116 *
117 * The result will contain the relevant bits filled in in the range
118 * [0,high-low), with garbage in bits [high-low+1,...).
119 */
120#define EFX_EXTRACT_NATIVE(native_element, min, max, low, high) \
121 (((low > max) || (high < min)) ? 0 : \
122 ((low > min) ? \
123 ((native_element) >> (low - min)) : \
124 ((native_element) << (min - low))))
125
126/*
127 * Extract bit field portion [low,high) from the 64-bit little-endian
128 * element which contains bits [min,max)
129 */
130#define EFX_EXTRACT64(element, min, max, low, high) \
131 EFX_EXTRACT_NATIVE(le64_to_cpu(element), min, max, low, high)
132
133/*
134 * Extract bit field portion [low,high) from the 32-bit little-endian
135 * element which contains bits [min,max)
136 */
137#define EFX_EXTRACT32(element, min, max, low, high) \
138 EFX_EXTRACT_NATIVE(le32_to_cpu(element), min, max, low, high)
139
140#define EFX_EXTRACT_OWORD64(oword, low, high) \
141 (EFX_EXTRACT64((oword).u64[0], 0, 63, low, high) | \
142 EFX_EXTRACT64((oword).u64[1], 64, 127, low, high))
143
144#define EFX_EXTRACT_QWORD64(qword, low, high) \
145 EFX_EXTRACT64((qword).u64[0], 0, 63, low, high)
146
147#define EFX_EXTRACT_OWORD32(oword, low, high) \
148 (EFX_EXTRACT32((oword).u32[0], 0, 31, low, high) | \
149 EFX_EXTRACT32((oword).u32[1], 32, 63, low, high) | \
150 EFX_EXTRACT32((oword).u32[2], 64, 95, low, high) | \
151 EFX_EXTRACT32((oword).u32[3], 96, 127, low, high))
152
153#define EFX_EXTRACT_QWORD32(qword, low, high) \
154 (EFX_EXTRACT32((qword).u32[0], 0, 31, low, high) | \
155 EFX_EXTRACT32((qword).u32[1], 32, 63, low, high))
156
157#define EFX_EXTRACT_DWORD(dword, low, high) \
158 EFX_EXTRACT32((dword).u32[0], 0, 31, low, high)
159
160#define EFX_OWORD_FIELD64(oword, field) \
161 (EFX_EXTRACT_OWORD64(oword, EFX_LOW_BIT(field), EFX_HIGH_BIT(field)) \
162 & EFX_MASK64(field))
163
164#define EFX_QWORD_FIELD64(qword, field) \
165 (EFX_EXTRACT_QWORD64(qword, EFX_LOW_BIT(field), EFX_HIGH_BIT(field)) \
166 & EFX_MASK64(field))
167
168#define EFX_OWORD_FIELD32(oword, field) \
169 (EFX_EXTRACT_OWORD32(oword, EFX_LOW_BIT(field), EFX_HIGH_BIT(field)) \
170 & EFX_MASK32(field))
171
172#define EFX_QWORD_FIELD32(qword, field) \
173 (EFX_EXTRACT_QWORD32(qword, EFX_LOW_BIT(field), EFX_HIGH_BIT(field)) \
174 & EFX_MASK32(field))
175
176#define EFX_DWORD_FIELD(dword, field) \
177 (EFX_EXTRACT_DWORD(dword, EFX_LOW_BIT(field), EFX_HIGH_BIT(field)) \
178 & EFX_MASK32(field))
179
180#define EFX_OWORD_IS_ZERO64(oword) \
181 (((oword).u64[0] | (oword).u64[1]) == (__force __le64) 0)
182
183#define EFX_QWORD_IS_ZERO64(qword) \
184 (((qword).u64[0]) == (__force __le64) 0)
185
186#define EFX_OWORD_IS_ZERO32(oword) \
187 (((oword).u32[0] | (oword).u32[1] | (oword).u32[2] | (oword).u32[3]) \
188 == (__force __le32) 0)
189
190#define EFX_QWORD_IS_ZERO32(qword) \
191 (((qword).u32[0] | (qword).u32[1]) == (__force __le32) 0)
192
193#define EFX_DWORD_IS_ZERO(dword) \
194 (((dword).u32[0]) == (__force __le32) 0)
195
196#define EFX_OWORD_IS_ALL_ONES64(oword) \
197 (((oword).u64[0] & (oword).u64[1]) == ~((__force __le64) 0))
198
199#define EFX_QWORD_IS_ALL_ONES64(qword) \
200 ((qword).u64[0] == ~((__force __le64) 0))
201
202#define EFX_OWORD_IS_ALL_ONES32(oword) \
203 (((oword).u32[0] & (oword).u32[1] & (oword).u32[2] & (oword).u32[3]) \
204 == ~((__force __le32) 0))
205
206#define EFX_QWORD_IS_ALL_ONES32(qword) \
207 (((qword).u32[0] & (qword).u32[1]) == ~((__force __le32) 0))
208
209#define EFX_DWORD_IS_ALL_ONES(dword) \
210 ((dword).u32[0] == ~((__force __le32) 0))
211
212#if BITS_PER_LONG == 64
213#define EFX_OWORD_FIELD EFX_OWORD_FIELD64
214#define EFX_QWORD_FIELD EFX_QWORD_FIELD64
215#define EFX_OWORD_IS_ZERO EFX_OWORD_IS_ZERO64
216#define EFX_QWORD_IS_ZERO EFX_QWORD_IS_ZERO64
217#define EFX_OWORD_IS_ALL_ONES EFX_OWORD_IS_ALL_ONES64
218#define EFX_QWORD_IS_ALL_ONES EFX_QWORD_IS_ALL_ONES64
219#else
220#define EFX_OWORD_FIELD EFX_OWORD_FIELD32
221#define EFX_QWORD_FIELD EFX_QWORD_FIELD32
222#define EFX_OWORD_IS_ZERO EFX_OWORD_IS_ZERO32
223#define EFX_QWORD_IS_ZERO EFX_QWORD_IS_ZERO32
224#define EFX_OWORD_IS_ALL_ONES EFX_OWORD_IS_ALL_ONES32
225#define EFX_QWORD_IS_ALL_ONES EFX_QWORD_IS_ALL_ONES32
226#endif
227
228/*
229 * Construct bit field portion
230 *
231 * Creates the portion of the bit field [low,high) that lies within
232 * the range [min,max).
233 */
234#define EFX_INSERT_NATIVE64(min, max, low, high, value) \
235 (((low > max) || (high < min)) ? 0 : \
236 ((low > min) ? \
237 (((u64) (value)) << (low - min)) : \
238 (((u64) (value)) >> (min - low))))
239
240#define EFX_INSERT_NATIVE32(min, max, low, high, value) \
241 (((low > max) || (high < min)) ? 0 : \
242 ((low > min) ? \
243 (((u32) (value)) << (low - min)) : \
244 (((u32) (value)) >> (min - low))))
245
246#define EFX_INSERT_NATIVE(min, max, low, high, value) \
247 ((((max - min) >= 32) || ((high - low) >= 32)) ? \
248 EFX_INSERT_NATIVE64(min, max, low, high, value) : \
249 EFX_INSERT_NATIVE32(min, max, low, high, value))
250
251/*
252 * Construct bit field portion
253 *
254 * Creates the portion of the named bit field that lies within the
255 * range [min,max).
256 */
257#define EFX_INSERT_FIELD_NATIVE(min, max, field, value) \
258 EFX_INSERT_NATIVE(min, max, EFX_LOW_BIT(field), \
259 EFX_HIGH_BIT(field), value)
260
261/*
262 * Construct bit field
263 *
264 * Creates the portion of the named bit fields that lie within the
265 * range [min,max).
266 */
267#define EFX_INSERT_FIELDS_NATIVE(min, max, \
268 field1, value1, \
269 field2, value2, \
270 field3, value3, \
271 field4, value4, \
272 field5, value5, \
273 field6, value6, \
274 field7, value7, \
275 field8, value8, \
276 field9, value9, \
277 field10, value10) \
278 (EFX_INSERT_FIELD_NATIVE((min), (max), field1, (value1)) | \
279 EFX_INSERT_FIELD_NATIVE((min), (max), field2, (value2)) | \
280 EFX_INSERT_FIELD_NATIVE((min), (max), field3, (value3)) | \
281 EFX_INSERT_FIELD_NATIVE((min), (max), field4, (value4)) | \
282 EFX_INSERT_FIELD_NATIVE((min), (max), field5, (value5)) | \
283 EFX_INSERT_FIELD_NATIVE((min), (max), field6, (value6)) | \
284 EFX_INSERT_FIELD_NATIVE((min), (max), field7, (value7)) | \
285 EFX_INSERT_FIELD_NATIVE((min), (max), field8, (value8)) | \
286 EFX_INSERT_FIELD_NATIVE((min), (max), field9, (value9)) | \
287 EFX_INSERT_FIELD_NATIVE((min), (max), field10, (value10)))
288
289#define EFX_INSERT_FIELDS64(...) \
290 cpu_to_le64(EFX_INSERT_FIELDS_NATIVE(__VA_ARGS__))
291
292#define EFX_INSERT_FIELDS32(...) \
293 cpu_to_le32(EFX_INSERT_FIELDS_NATIVE(__VA_ARGS__))
294
295#define EFX_POPULATE_OWORD64(oword, ...) do { \
296 (oword).u64[0] = EFX_INSERT_FIELDS64(0, 63, __VA_ARGS__); \
297 (oword).u64[1] = EFX_INSERT_FIELDS64(64, 127, __VA_ARGS__); \
298 } while (0)
299
300#define EFX_POPULATE_QWORD64(qword, ...) do { \
301 (qword).u64[0] = EFX_INSERT_FIELDS64(0, 63, __VA_ARGS__); \
302 } while (0)
303
304#define EFX_POPULATE_OWORD32(oword, ...) do { \
305 (oword).u32[0] = EFX_INSERT_FIELDS32(0, 31, __VA_ARGS__); \
306 (oword).u32[1] = EFX_INSERT_FIELDS32(32, 63, __VA_ARGS__); \
307 (oword).u32[2] = EFX_INSERT_FIELDS32(64, 95, __VA_ARGS__); \
308 (oword).u32[3] = EFX_INSERT_FIELDS32(96, 127, __VA_ARGS__); \
309 } while (0)
310
311#define EFX_POPULATE_QWORD32(qword, ...) do { \
312 (qword).u32[0] = EFX_INSERT_FIELDS32(0, 31, __VA_ARGS__); \
313 (qword).u32[1] = EFX_INSERT_FIELDS32(32, 63, __VA_ARGS__); \
314 } while (0)
315
316#define EFX_POPULATE_DWORD(dword, ...) do { \
317 (dword).u32[0] = EFX_INSERT_FIELDS32(0, 31, __VA_ARGS__); \
318 } while (0)
319
320#if BITS_PER_LONG == 64
321#define EFX_POPULATE_OWORD EFX_POPULATE_OWORD64
322#define EFX_POPULATE_QWORD EFX_POPULATE_QWORD64
323#else
324#define EFX_POPULATE_OWORD EFX_POPULATE_OWORD32
325#define EFX_POPULATE_QWORD EFX_POPULATE_QWORD32
326#endif
327
328/* Populate an octword field with various numbers of arguments */
329#define EFX_POPULATE_OWORD_10 EFX_POPULATE_OWORD
330#define EFX_POPULATE_OWORD_9(oword, ...) \
331 EFX_POPULATE_OWORD_10(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
332#define EFX_POPULATE_OWORD_8(oword, ...) \
333 EFX_POPULATE_OWORD_9(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
334#define EFX_POPULATE_OWORD_7(oword, ...) \
335 EFX_POPULATE_OWORD_8(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
336#define EFX_POPULATE_OWORD_6(oword, ...) \
337 EFX_POPULATE_OWORD_7(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
338#define EFX_POPULATE_OWORD_5(oword, ...) \
339 EFX_POPULATE_OWORD_6(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
340#define EFX_POPULATE_OWORD_4(oword, ...) \
341 EFX_POPULATE_OWORD_5(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
342#define EFX_POPULATE_OWORD_3(oword, ...) \
343 EFX_POPULATE_OWORD_4(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
344#define EFX_POPULATE_OWORD_2(oword, ...) \
345 EFX_POPULATE_OWORD_3(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
346#define EFX_POPULATE_OWORD_1(oword, ...) \
347 EFX_POPULATE_OWORD_2(oword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
348#define EFX_ZERO_OWORD(oword) \
349 EFX_POPULATE_OWORD_1(oword, EFX_DUMMY_FIELD, 0)
350#define EFX_SET_OWORD(oword) \
351 EFX_POPULATE_OWORD_4(oword, \
352 EFX_DWORD_0, 0xffffffff, \
353 EFX_DWORD_1, 0xffffffff, \
354 EFX_DWORD_2, 0xffffffff, \
355 EFX_DWORD_3, 0xffffffff)
356
357/* Populate a quadword field with various numbers of arguments */
358#define EFX_POPULATE_QWORD_10 EFX_POPULATE_QWORD
359#define EFX_POPULATE_QWORD_9(qword, ...) \
360 EFX_POPULATE_QWORD_10(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
361#define EFX_POPULATE_QWORD_8(qword, ...) \
362 EFX_POPULATE_QWORD_9(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
363#define EFX_POPULATE_QWORD_7(qword, ...) \
364 EFX_POPULATE_QWORD_8(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
365#define EFX_POPULATE_QWORD_6(qword, ...) \
366 EFX_POPULATE_QWORD_7(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
367#define EFX_POPULATE_QWORD_5(qword, ...) \
368 EFX_POPULATE_QWORD_6(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
369#define EFX_POPULATE_QWORD_4(qword, ...) \
370 EFX_POPULATE_QWORD_5(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
371#define EFX_POPULATE_QWORD_3(qword, ...) \
372 EFX_POPULATE_QWORD_4(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
373#define EFX_POPULATE_QWORD_2(qword, ...) \
374 EFX_POPULATE_QWORD_3(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
375#define EFX_POPULATE_QWORD_1(qword, ...) \
376 EFX_POPULATE_QWORD_2(qword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
377#define EFX_ZERO_QWORD(qword) \
378 EFX_POPULATE_QWORD_1(qword, EFX_DUMMY_FIELD, 0)
379#define EFX_SET_QWORD(qword) \
380 EFX_POPULATE_QWORD_2(qword, \
381 EFX_DWORD_0, 0xffffffff, \
382 EFX_DWORD_1, 0xffffffff)
383
384/* Populate a dword field with various numbers of arguments */
385#define EFX_POPULATE_DWORD_10 EFX_POPULATE_DWORD
386#define EFX_POPULATE_DWORD_9(dword, ...) \
387 EFX_POPULATE_DWORD_10(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
388#define EFX_POPULATE_DWORD_8(dword, ...) \
389 EFX_POPULATE_DWORD_9(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
390#define EFX_POPULATE_DWORD_7(dword, ...) \
391 EFX_POPULATE_DWORD_8(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
392#define EFX_POPULATE_DWORD_6(dword, ...) \
393 EFX_POPULATE_DWORD_7(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
394#define EFX_POPULATE_DWORD_5(dword, ...) \
395 EFX_POPULATE_DWORD_6(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
396#define EFX_POPULATE_DWORD_4(dword, ...) \
397 EFX_POPULATE_DWORD_5(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
398#define EFX_POPULATE_DWORD_3(dword, ...) \
399 EFX_POPULATE_DWORD_4(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
400#define EFX_POPULATE_DWORD_2(dword, ...) \
401 EFX_POPULATE_DWORD_3(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
402#define EFX_POPULATE_DWORD_1(dword, ...) \
403 EFX_POPULATE_DWORD_2(dword, EFX_DUMMY_FIELD, 0, __VA_ARGS__)
404#define EFX_ZERO_DWORD(dword) \
405 EFX_POPULATE_DWORD_1(dword, EFX_DUMMY_FIELD, 0)
406#define EFX_SET_DWORD(dword) \
407 EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 0xffffffff)
408
409/*
410 * Modify a named field within an already-populated structure. Used
411 * for read-modify-write operations.
412 *
413 */
414
415#define EFX_INVERT_OWORD(oword) do { \
416 (oword).u64[0] = ~((oword).u64[0]); \
417 (oword).u64[1] = ~((oword).u64[1]); \
418 } while (0)
419
420#define EFX_INSERT_FIELD64(...) \
421 cpu_to_le64(EFX_INSERT_FIELD_NATIVE(__VA_ARGS__))
422
423#define EFX_INSERT_FIELD32(...) \
424 cpu_to_le32(EFX_INSERT_FIELD_NATIVE(__VA_ARGS__))
425
426#define EFX_INPLACE_MASK64(min, max, field) \
427 EFX_INSERT_FIELD64(min, max, field, EFX_MASK64(field))
428
429#define EFX_INPLACE_MASK32(min, max, field) \
430 EFX_INSERT_FIELD32(min, max, field, EFX_MASK32(field))
431
432#define EFX_SET_OWORD_FIELD64(oword, field, value) do { \
433 (oword).u64[0] = (((oword).u64[0] \
434 & ~EFX_INPLACE_MASK64(0, 63, field)) \
435 | EFX_INSERT_FIELD64(0, 63, field, value)); \
436 (oword).u64[1] = (((oword).u64[1] \
437 & ~EFX_INPLACE_MASK64(64, 127, field)) \
438 | EFX_INSERT_FIELD64(64, 127, field, value)); \
439 } while (0)
440
441#define EFX_SET_QWORD_FIELD64(qword, field, value) do { \
442 (qword).u64[0] = (((qword).u64[0] \
443 & ~EFX_INPLACE_MASK64(0, 63, field)) \
444 | EFX_INSERT_FIELD64(0, 63, field, value)); \
445 } while (0)
446
447#define EFX_SET_OWORD_FIELD32(oword, field, value) do { \
448 (oword).u32[0] = (((oword).u32[0] \
449 & ~EFX_INPLACE_MASK32(0, 31, field)) \
450 | EFX_INSERT_FIELD32(0, 31, field, value)); \
451 (oword).u32[1] = (((oword).u32[1] \
452 & ~EFX_INPLACE_MASK32(32, 63, field)) \
453 | EFX_INSERT_FIELD32(32, 63, field, value)); \
454 (oword).u32[2] = (((oword).u32[2] \
455 & ~EFX_INPLACE_MASK32(64, 95, field)) \
456 | EFX_INSERT_FIELD32(64, 95, field, value)); \
457 (oword).u32[3] = (((oword).u32[3] \
458 & ~EFX_INPLACE_MASK32(96, 127, field)) \
459 | EFX_INSERT_FIELD32(96, 127, field, value)); \
460 } while (0)
461
462#define EFX_SET_QWORD_FIELD32(qword, field, value) do { \
463 (qword).u32[0] = (((qword).u32[0] \
464 & ~EFX_INPLACE_MASK32(0, 31, field)) \
465 | EFX_INSERT_FIELD32(0, 31, field, value)); \
466 (qword).u32[1] = (((qword).u32[1] \
467 & ~EFX_INPLACE_MASK32(32, 63, field)) \
468 | EFX_INSERT_FIELD32(32, 63, field, value)); \
469 } while (0)
470
471#define EFX_SET_DWORD_FIELD(dword, field, value) do { \
472 (dword).u32[0] = (((dword).u32[0] \
473 & ~EFX_INPLACE_MASK32(0, 31, field)) \
474 | EFX_INSERT_FIELD32(0, 31, field, value)); \
475 } while (0)
476
477#if BITS_PER_LONG == 64
478#define EFX_SET_OWORD_FIELD EFX_SET_OWORD_FIELD64
479#define EFX_SET_QWORD_FIELD EFX_SET_QWORD_FIELD64
480#else
481#define EFX_SET_OWORD_FIELD EFX_SET_OWORD_FIELD32
482#define EFX_SET_QWORD_FIELD EFX_SET_QWORD_FIELD32
483#endif
484
485#define EFX_SET_OWORD_FIELD_VER(efx, oword, field, value) do { \
486 if (FALCON_REV(efx) >= FALCON_REV_B0) { \
487 EFX_SET_OWORD_FIELD((oword), field##_B0, (value)); \
488 } else { \
489 EFX_SET_OWORD_FIELD((oword), field##_A1, (value)); \
490 } \
491} while (0)
492
493#define EFX_QWORD_FIELD_VER(efx, qword, field) \
494 (FALCON_REV(efx) >= FALCON_REV_B0 ? \
495 EFX_QWORD_FIELD((qword), field##_B0) : \
496 EFX_QWORD_FIELD((qword), field##_A1))
497
498/* Used to avoid compiler warnings about shift range exceeding width
499 * of the data types when dma_addr_t is only 32 bits wide.
500 */
501#define DMA_ADDR_T_WIDTH (8 * sizeof(dma_addr_t))
502#define EFX_DMA_TYPE_WIDTH(width) \
503 (((width) < DMA_ADDR_T_WIDTH) ? (width) : DMA_ADDR_T_WIDTH)
504#define EFX_DMA_MAX_MASK ((DMA_ADDR_T_WIDTH == 64) ? \
505 ~((u64) 0) : ~((u32) 0))
506#define EFX_DMA_MASK(mask) ((mask) & EFX_DMA_MAX_MASK)
507
508#endif /* EFX_BITFIELD_H */
diff --git a/drivers/net/sfc/boards.c b/drivers/net/sfc/boards.c
new file mode 100644
index 000000000000..eecaa6d58584
--- /dev/null
+++ b/drivers/net/sfc/boards.c
@@ -0,0 +1,167 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#include "net_driver.h"
11#include "phy.h"
12#include "boards.h"
13#include "efx.h"
14
15/* Macros for unpacking the board revision */
16/* The revision info is in host byte order. */
17#define BOARD_TYPE(_rev) (_rev >> 8)
18#define BOARD_MAJOR(_rev) ((_rev >> 4) & 0xf)
19#define BOARD_MINOR(_rev) (_rev & 0xf)
20
21/* Blink support. If the PHY has no auto-blink mode so we hang it off a timer */
22#define BLINK_INTERVAL (HZ/2)
23
24static void blink_led_timer(unsigned long context)
25{
26 struct efx_nic *efx = (struct efx_nic *)context;
27 struct efx_blinker *bl = &efx->board_info.blinker;
28 efx->board_info.set_fault_led(efx, bl->state);
29 bl->state = !bl->state;
30 if (bl->resubmit) {
31 bl->timer.expires = jiffies + BLINK_INTERVAL;
32 add_timer(&bl->timer);
33 }
34}
35
36static void board_blink(struct efx_nic *efx, int blink)
37{
38 struct efx_blinker *blinker = &efx->board_info.blinker;
39
40 /* The rtnl mutex serialises all ethtool ioctls, so
41 * nothing special needs doing here. */
42 if (blink) {
43 blinker->resubmit = 1;
44 blinker->state = 0;
45 setup_timer(&blinker->timer, blink_led_timer,
46 (unsigned long)efx);
47 blinker->timer.expires = jiffies + BLINK_INTERVAL;
48 add_timer(&blinker->timer);
49 } else {
50 blinker->resubmit = 0;
51 if (blinker->timer.function)
52 del_timer_sync(&blinker->timer);
53 efx->board_info.set_fault_led(efx, 0);
54 }
55}
56
57/*****************************************************************************
58 * Support for the SFE4002
59 *
60 */
61/****************************************************************************/
62/* LED allocations. Note that on rev A0 boards the schematic and the reality
63 * differ: red and green are swapped. Below is the fixed (A1) layout (there
64 * are only 3 A0 boards in existence, so no real reason to make this
65 * conditional).
66 */
67#define SFE4002_FAULT_LED (2) /* Red */
68#define SFE4002_RX_LED (0) /* Green */
69#define SFE4002_TX_LED (1) /* Amber */
70
71static int sfe4002_init_leds(struct efx_nic *efx)
72{
73 /* Set the TX and RX LEDs to reflect status and activity, and the
74 * fault LED off */
75 xfp_set_led(efx, SFE4002_TX_LED,
76 QUAKE_LED_TXLINK | QUAKE_LED_LINK_ACTSTAT);
77 xfp_set_led(efx, SFE4002_RX_LED,
78 QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACTSTAT);
79 xfp_set_led(efx, SFE4002_FAULT_LED, QUAKE_LED_OFF);
80 efx->board_info.blinker.led_num = SFE4002_FAULT_LED;
81 return 0;
82}
83
84static void sfe4002_fault_led(struct efx_nic *efx, int state)
85{
86 xfp_set_led(efx, SFE4002_FAULT_LED, state ? QUAKE_LED_ON :
87 QUAKE_LED_OFF);
88}
89
90static int sfe4002_init(struct efx_nic *efx)
91{
92 efx->board_info.init_leds = sfe4002_init_leds;
93 efx->board_info.set_fault_led = sfe4002_fault_led;
94 efx->board_info.blink = board_blink;
95 return 0;
96}
97
98/* This will get expanded as board-specific details get moved out of the
99 * PHY drivers. */
100struct efx_board_data {
101 const char *ref_model;
102 const char *gen_type;
103 int (*init) (struct efx_nic *nic);
104};
105
106static int dummy_init(struct efx_nic *nic)
107{
108 return 0;
109}
110
111static struct efx_board_data board_data[] = {
112 [EFX_BOARD_INVALID] =
113 {NULL, NULL, dummy_init},
114 [EFX_BOARD_SFE4001] =
115 {"SFE4001", "10GBASE-T adapter", sfe4001_poweron},
116 [EFX_BOARD_SFE4002] =
117 {"SFE4002", "XFP adapter", sfe4002_init},
118};
119
120int efx_set_board_info(struct efx_nic *efx, u16 revision_info)
121{
122 int rc = 0;
123 struct efx_board_data *data;
124
125 if (BOARD_TYPE(revision_info) >= EFX_BOARD_MAX) {
126 EFX_ERR(efx, "squashing unknown board type %d\n",
127 BOARD_TYPE(revision_info));
128 revision_info = 0;
129 }
130
131 if (BOARD_TYPE(revision_info) == 0) {
132 efx->board_info.major = 0;
133 efx->board_info.minor = 0;
134 /* For early boards that don't have revision info. there is
135 * only 1 board for each PHY type, so we can work it out, with
136 * the exception of the PHY-less boards. */
137 switch (efx->phy_type) {
138 case PHY_TYPE_10XPRESS:
139 efx->board_info.type = EFX_BOARD_SFE4001;
140 break;
141 case PHY_TYPE_XFP:
142 efx->board_info.type = EFX_BOARD_SFE4002;
143 break;
144 default:
145 efx->board_info.type = 0;
146 break;
147 }
148 } else {
149 efx->board_info.type = BOARD_TYPE(revision_info);
150 efx->board_info.major = BOARD_MAJOR(revision_info);
151 efx->board_info.minor = BOARD_MINOR(revision_info);
152 }
153
154 data = &board_data[efx->board_info.type];
155
156 /* Report the board model number or generic type for recognisable
157 * boards. */
158 if (efx->board_info.type != 0)
159 EFX_INFO(efx, "board is %s rev %c%d\n",
160 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
161 ? data->ref_model : data->gen_type,
162 'A' + efx->board_info.major, efx->board_info.minor);
163
164 efx->board_info.init = data->init;
165
166 return rc;
167}
diff --git a/drivers/net/sfc/boards.h b/drivers/net/sfc/boards.h
new file mode 100644
index 000000000000..f56341d428e1
--- /dev/null
+++ b/drivers/net/sfc/boards.h
@@ -0,0 +1,26 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_BOARDS_H
11#define EFX_BOARDS_H
12
13/* Board IDs (must fit in 8 bits) */
14enum efx_board_type {
15 EFX_BOARD_INVALID = 0,
16 EFX_BOARD_SFE4001 = 1, /* SFE4001 (10GBASE-T) */
17 EFX_BOARD_SFE4002 = 2,
18 /* Insert new types before here */
19 EFX_BOARD_MAX
20};
21
22extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info);
23extern int sfe4001_poweron(struct efx_nic *efx);
24extern void sfe4001_poweroff(struct efx_nic *efx);
25
26#endif
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
new file mode 100644
index 000000000000..59edcf793c19
--- /dev/null
+++ b/drivers/net/sfc/efx.c
@@ -0,0 +1,2208 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2005-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/module.h>
12#include <linux/pci.h>
13#include <linux/netdevice.h>
14#include <linux/etherdevice.h>
15#include <linux/delay.h>
16#include <linux/notifier.h>
17#include <linux/ip.h>
18#include <linux/tcp.h>
19#include <linux/in.h>
20#include <linux/crc32.h>
21#include <linux/ethtool.h>
22#include "net_driver.h"
23#include "gmii.h"
24#include "ethtool.h"
25#include "tx.h"
26#include "rx.h"
27#include "efx.h"
28#include "mdio_10g.h"
29#include "falcon.h"
30#include "workarounds.h"
31#include "mac.h"
32
33#define EFX_MAX_MTU (9 * 1024)
34
35/* RX slow fill workqueue. If memory allocation fails in the fast path,
36 * a work item is pushed onto this work queue to retry the allocation later,
37 * to avoid the NIC being starved of RX buffers. Since this is a per cpu
38 * workqueue, there is nothing to be gained in making it per NIC
39 */
40static struct workqueue_struct *refill_workqueue;
41
42/**************************************************************************
43 *
44 * Configurable values
45 *
46 *************************************************************************/
47
48/*
49 * Enable large receive offload (LRO) aka soft segment reassembly (SSR)
50 *
51 * This sets the default for new devices. It can be controlled later
52 * using ethtool.
53 */
54static int lro = 1;
55module_param(lro, int, 0644);
56MODULE_PARM_DESC(lro, "Large receive offload acceleration");
57
58/*
59 * Use separate channels for TX and RX events
60 *
61 * Set this to 1 to use separate channels for TX and RX. It allows us to
62 * apply a higher level of interrupt moderation to TX events.
63 *
64 * This is forced to 0 for MSI interrupt mode as the interrupt vector
65 * is not written
66 */
67static unsigned int separate_tx_and_rx_channels = 1;
68
69/* This is the weight assigned to each of the (per-channel) virtual
70 * NAPI devices.
71 */
72static int napi_weight = 64;
73
74/* This is the time (in jiffies) between invocations of the hardware
75 * monitor, which checks for known hardware bugs and resets the
76 * hardware and driver as necessary.
77 */
78unsigned int efx_monitor_interval = 1 * HZ;
79
80/* This controls whether or not the hardware monitor will trigger a
81 * reset when it detects an error condition.
82 */
83static unsigned int monitor_reset = 1;
84
85/* This controls whether or not the driver will initialise devices
86 * with invalid MAC addresses stored in the EEPROM or flash. If true,
87 * such devices will be initialised with a random locally-generated
88 * MAC address. This allows for loading the sfc_mtd driver to
89 * reprogram the flash, even if the flash contents (including the MAC
90 * address) have previously been erased.
91 */
92static unsigned int allow_bad_hwaddr;
93
94/* Initial interrupt moderation settings. They can be modified after
95 * module load with ethtool.
96 *
97 * The default for RX should strike a balance between increasing the
98 * round-trip latency and reducing overhead.
99 */
100static unsigned int rx_irq_mod_usec = 60;
101
102/* Initial interrupt moderation settings. They can be modified after
103 * module load with ethtool.
104 *
105 * This default is chosen to ensure that a 10G link does not go idle
106 * while a TX queue is stopped after it has become full. A queue is
107 * restarted when it drops below half full. The time this takes (assuming
108 * worst case 3 descriptors per packet and 1024 descriptors) is
109 * 512 / 3 * 1.2 = 205 usec.
110 */
111static unsigned int tx_irq_mod_usec = 150;
112
113/* This is the first interrupt mode to try out of:
114 * 0 => MSI-X
115 * 1 => MSI
116 * 2 => legacy
117 */
118static unsigned int interrupt_mode;
119
120/* This is the requested number of CPUs to use for Receive-Side Scaling (RSS),
121 * i.e. the number of CPUs among which we may distribute simultaneous
122 * interrupt handling.
123 *
124 * Cards without MSI-X will only target one CPU via legacy or MSI interrupt.
125 * The default (0) means to assign an interrupt to each package (level II cache)
126 */
127static unsigned int rss_cpus;
128module_param(rss_cpus, uint, 0444);
129MODULE_PARM_DESC(rss_cpus, "Number of CPUs to use for Receive-Side Scaling");
130
131/**************************************************************************
132 *
133 * Utility functions and prototypes
134 *
135 *************************************************************************/
136static void efx_remove_channel(struct efx_channel *channel);
137static void efx_remove_port(struct efx_nic *efx);
138static void efx_fini_napi(struct efx_nic *efx);
139static void efx_fini_channels(struct efx_nic *efx);
140
141#define EFX_ASSERT_RESET_SERIALISED(efx) \
142 do { \
143 if ((efx->state == STATE_RUNNING) || \
144 (efx->state == STATE_RESETTING)) \
145 ASSERT_RTNL(); \
146 } while (0)
147
148/**************************************************************************
149 *
150 * Event queue processing
151 *
152 *************************************************************************/
153
154/* Process channel's event queue
155 *
156 * This function is responsible for processing the event queue of a
157 * single channel. The caller must guarantee that this function will
158 * never be concurrently called more than once on the same channel,
159 * though different channels may be being processed concurrently.
160 */
161static inline int efx_process_channel(struct efx_channel *channel, int rx_quota)
162{
163 int rxdmaqs;
164 struct efx_rx_queue *rx_queue;
165
166 if (unlikely(channel->efx->reset_pending != RESET_TYPE_NONE ||
167 !channel->enabled))
168 return rx_quota;
169
170 rxdmaqs = falcon_process_eventq(channel, &rx_quota);
171
172 /* Deliver last RX packet. */
173 if (channel->rx_pkt) {
174 __efx_rx_packet(channel, channel->rx_pkt,
175 channel->rx_pkt_csummed);
176 channel->rx_pkt = NULL;
177 }
178
179 efx_flush_lro(channel);
180 efx_rx_strategy(channel);
181
182 /* Refill descriptor rings as necessary */
183 rx_queue = &channel->efx->rx_queue[0];
184 while (rxdmaqs) {
185 if (rxdmaqs & 0x01)
186 efx_fast_push_rx_descriptors(rx_queue);
187 rx_queue++;
188 rxdmaqs >>= 1;
189 }
190
191 return rx_quota;
192}
193
194/* Mark channel as finished processing
195 *
196 * Note that since we will not receive further interrupts for this
197 * channel before we finish processing and call the eventq_read_ack()
198 * method, there is no need to use the interrupt hold-off timers.
199 */
200static inline void efx_channel_processed(struct efx_channel *channel)
201{
202 /* Write to EVQ_RPTR_REG. If a new event arrived in a race
203 * with finishing processing, a new interrupt will be raised.
204 */
205 channel->work_pending = 0;
206 smp_wmb(); /* Ensure channel updated before any new interrupt. */
207 falcon_eventq_read_ack(channel);
208}
209
210/* NAPI poll handler
211 *
212 * NAPI guarantees serialisation of polls of the same device, which
213 * provides the guarantee required by efx_process_channel().
214 */
215static int efx_poll(struct napi_struct *napi, int budget)
216{
217 struct efx_channel *channel =
218 container_of(napi, struct efx_channel, napi_str);
219 struct net_device *napi_dev = channel->napi_dev;
220 int unused;
221 int rx_packets;
222
223 EFX_TRACE(channel->efx, "channel %d NAPI poll executing on CPU %d\n",
224 channel->channel, raw_smp_processor_id());
225
226 unused = efx_process_channel(channel, budget);
227 rx_packets = (budget - unused);
228
229 if (rx_packets < budget) {
230 /* There is no race here; although napi_disable() will
231 * only wait for netif_rx_complete(), this isn't a problem
232 * since efx_channel_processed() will have no effect if
233 * interrupts have already been disabled.
234 */
235 netif_rx_complete(napi_dev, napi);
236 efx_channel_processed(channel);
237 }
238
239 return rx_packets;
240}
241
242/* Process the eventq of the specified channel immediately on this CPU
243 *
244 * Disable hardware generated interrupts, wait for any existing
245 * processing to finish, then directly poll (and ack ) the eventq.
246 * Finally reenable NAPI and interrupts.
247 *
248 * Since we are touching interrupts the caller should hold the suspend lock
249 */
250void efx_process_channel_now(struct efx_channel *channel)
251{
252 struct efx_nic *efx = channel->efx;
253
254 BUG_ON(!channel->used_flags);
255 BUG_ON(!channel->enabled);
256
257 /* Disable interrupts and wait for ISRs to complete */
258 falcon_disable_interrupts(efx);
259 if (efx->legacy_irq)
260 synchronize_irq(efx->legacy_irq);
261 if (channel->has_interrupt && channel->irq)
262 synchronize_irq(channel->irq);
263
264 /* Wait for any NAPI processing to complete */
265 napi_disable(&channel->napi_str);
266
267 /* Poll the channel */
268 (void) efx_process_channel(channel, efx->type->evq_size);
269
270 /* Ack the eventq. This may cause an interrupt to be generated
271 * when they are reenabled */
272 efx_channel_processed(channel);
273
274 napi_enable(&channel->napi_str);
275 falcon_enable_interrupts(efx);
276}
277
278/* Create event queue
279 * Event queue memory allocations are done only once. If the channel
280 * is reset, the memory buffer will be reused; this guards against
281 * errors during channel reset and also simplifies interrupt handling.
282 */
283static int efx_probe_eventq(struct efx_channel *channel)
284{
285 EFX_LOG(channel->efx, "chan %d create event queue\n", channel->channel);
286
287 return falcon_probe_eventq(channel);
288}
289
290/* Prepare channel's event queue */
291static int efx_init_eventq(struct efx_channel *channel)
292{
293 EFX_LOG(channel->efx, "chan %d init event queue\n", channel->channel);
294
295 channel->eventq_read_ptr = 0;
296
297 return falcon_init_eventq(channel);
298}
299
300static void efx_fini_eventq(struct efx_channel *channel)
301{
302 EFX_LOG(channel->efx, "chan %d fini event queue\n", channel->channel);
303
304 falcon_fini_eventq(channel);
305}
306
307static void efx_remove_eventq(struct efx_channel *channel)
308{
309 EFX_LOG(channel->efx, "chan %d remove event queue\n", channel->channel);
310
311 falcon_remove_eventq(channel);
312}
313
314/**************************************************************************
315 *
316 * Channel handling
317 *
318 *************************************************************************/
319
320/* Setup per-NIC RX buffer parameters.
321 * Calculate the rx buffer allocation parameters required to support
322 * the current MTU, including padding for header alignment and overruns.
323 */
324static void efx_calc_rx_buffer_params(struct efx_nic *efx)
325{
326 unsigned int order, len;
327
328 len = (max(EFX_PAGE_IP_ALIGN, NET_IP_ALIGN) +
329 EFX_MAX_FRAME_LEN(efx->net_dev->mtu) +
330 efx->type->rx_buffer_padding);
331
332 /* Calculate page-order */
333 for (order = 0; ((1u << order) * PAGE_SIZE) < len; ++order)
334 ;
335
336 efx->rx_buffer_len = len;
337 efx->rx_buffer_order = order;
338}
339
340static int efx_probe_channel(struct efx_channel *channel)
341{
342 struct efx_tx_queue *tx_queue;
343 struct efx_rx_queue *rx_queue;
344 int rc;
345
346 EFX_LOG(channel->efx, "creating channel %d\n", channel->channel);
347
348 rc = efx_probe_eventq(channel);
349 if (rc)
350 goto fail1;
351
352 efx_for_each_channel_tx_queue(tx_queue, channel) {
353 rc = efx_probe_tx_queue(tx_queue);
354 if (rc)
355 goto fail2;
356 }
357
358 efx_for_each_channel_rx_queue(rx_queue, channel) {
359 rc = efx_probe_rx_queue(rx_queue);
360 if (rc)
361 goto fail3;
362 }
363
364 channel->n_rx_frm_trunc = 0;
365
366 return 0;
367
368 fail3:
369 efx_for_each_channel_rx_queue(rx_queue, channel)
370 efx_remove_rx_queue(rx_queue);
371 fail2:
372 efx_for_each_channel_tx_queue(tx_queue, channel)
373 efx_remove_tx_queue(tx_queue);
374 fail1:
375 return rc;
376}
377
378
379/* Channels are shutdown and reinitialised whilst the NIC is running
380 * to propagate configuration changes (mtu, checksum offload), or
381 * to clear hardware error conditions
382 */
383static int efx_init_channels(struct efx_nic *efx)
384{
385 struct efx_tx_queue *tx_queue;
386 struct efx_rx_queue *rx_queue;
387 struct efx_channel *channel;
388 int rc = 0;
389
390 efx_calc_rx_buffer_params(efx);
391
392 /* Initialise the channels */
393 efx_for_each_channel(channel, efx) {
394 EFX_LOG(channel->efx, "init chan %d\n", channel->channel);
395
396 rc = efx_init_eventq(channel);
397 if (rc)
398 goto err;
399
400 efx_for_each_channel_tx_queue(tx_queue, channel) {
401 rc = efx_init_tx_queue(tx_queue);
402 if (rc)
403 goto err;
404 }
405
406 /* The rx buffer allocation strategy is MTU dependent */
407 efx_rx_strategy(channel);
408
409 efx_for_each_channel_rx_queue(rx_queue, channel) {
410 rc = efx_init_rx_queue(rx_queue);
411 if (rc)
412 goto err;
413 }
414
415 WARN_ON(channel->rx_pkt != NULL);
416 efx_rx_strategy(channel);
417 }
418
419 return 0;
420
421 err:
422 EFX_ERR(efx, "failed to initialise channel %d\n",
423 channel ? channel->channel : -1);
424 efx_fini_channels(efx);
425 return rc;
426}
427
428/* This enables event queue processing and packet transmission.
429 *
430 * Note that this function is not allowed to fail, since that would
431 * introduce too much complexity into the suspend/resume path.
432 */
433static void efx_start_channel(struct efx_channel *channel)
434{
435 struct efx_rx_queue *rx_queue;
436
437 EFX_LOG(channel->efx, "starting chan %d\n", channel->channel);
438
439 if (!(channel->efx->net_dev->flags & IFF_UP))
440 netif_napi_add(channel->napi_dev, &channel->napi_str,
441 efx_poll, napi_weight);
442
443 channel->work_pending = 0;
444 channel->enabled = 1;
445 smp_wmb(); /* ensure channel updated before first interrupt */
446
447 napi_enable(&channel->napi_str);
448
449 /* Load up RX descriptors */
450 efx_for_each_channel_rx_queue(rx_queue, channel)
451 efx_fast_push_rx_descriptors(rx_queue);
452}
453
454/* This disables event queue processing and packet transmission.
455 * This function does not guarantee that all queue processing
456 * (e.g. RX refill) is complete.
457 */
458static void efx_stop_channel(struct efx_channel *channel)
459{
460 struct efx_rx_queue *rx_queue;
461
462 if (!channel->enabled)
463 return;
464
465 EFX_LOG(channel->efx, "stop chan %d\n", channel->channel);
466
467 channel->enabled = 0;
468 napi_disable(&channel->napi_str);
469
470 /* Ensure that any worker threads have exited or will be no-ops */
471 efx_for_each_channel_rx_queue(rx_queue, channel) {
472 spin_lock_bh(&rx_queue->add_lock);
473 spin_unlock_bh(&rx_queue->add_lock);
474 }
475}
476
477static void efx_fini_channels(struct efx_nic *efx)
478{
479 struct efx_channel *channel;
480 struct efx_tx_queue *tx_queue;
481 struct efx_rx_queue *rx_queue;
482
483 EFX_ASSERT_RESET_SERIALISED(efx);
484 BUG_ON(efx->port_enabled);
485
486 efx_for_each_channel(channel, efx) {
487 EFX_LOG(channel->efx, "shut down chan %d\n", channel->channel);
488
489 efx_for_each_channel_rx_queue(rx_queue, channel)
490 efx_fini_rx_queue(rx_queue);
491 efx_for_each_channel_tx_queue(tx_queue, channel)
492 efx_fini_tx_queue(tx_queue);
493 }
494
495 /* Do the event queues last so that we can handle flush events
496 * for all DMA queues. */
497 efx_for_each_channel(channel, efx) {
498 EFX_LOG(channel->efx, "shut down evq %d\n", channel->channel);
499
500 efx_fini_eventq(channel);
501 }
502}
503
504static void efx_remove_channel(struct efx_channel *channel)
505{
506 struct efx_tx_queue *tx_queue;
507 struct efx_rx_queue *rx_queue;
508
509 EFX_LOG(channel->efx, "destroy chan %d\n", channel->channel);
510
511 efx_for_each_channel_rx_queue(rx_queue, channel)
512 efx_remove_rx_queue(rx_queue);
513 efx_for_each_channel_tx_queue(tx_queue, channel)
514 efx_remove_tx_queue(tx_queue);
515 efx_remove_eventq(channel);
516
517 channel->used_flags = 0;
518}
519
520void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue, int delay)
521{
522 queue_delayed_work(refill_workqueue, &rx_queue->work, delay);
523}
524
525/**************************************************************************
526 *
527 * Port handling
528 *
529 **************************************************************************/
530
531/* This ensures that the kernel is kept informed (via
532 * netif_carrier_on/off) of the link status, and also maintains the
533 * link status's stop on the port's TX queue.
534 */
535static void efx_link_status_changed(struct efx_nic *efx)
536{
537 int carrier_ok;
538
539 /* SFC Bug 5356: A net_dev notifier is registered, so we must ensure
540 * that no events are triggered between unregister_netdev() and the
541 * driver unloading. A more general condition is that NETDEV_CHANGE
542 * can only be generated between NETDEV_UP and NETDEV_DOWN */
543 if (!netif_running(efx->net_dev))
544 return;
545
546 carrier_ok = netif_carrier_ok(efx->net_dev) ? 1 : 0;
547 if (efx->link_up != carrier_ok) {
548 efx->n_link_state_changes++;
549
550 if (efx->link_up)
551 netif_carrier_on(efx->net_dev);
552 else
553 netif_carrier_off(efx->net_dev);
554 }
555
556 /* Status message for kernel log */
557 if (efx->link_up) {
558 struct mii_if_info *gmii = &efx->mii;
559 unsigned adv, lpa;
560 /* NONE here means direct XAUI from the controller, with no
561 * MDIO-attached device we can query. */
562 if (efx->phy_type != PHY_TYPE_NONE) {
563 adv = gmii_advertised(gmii);
564 lpa = gmii_lpa(gmii);
565 } else {
566 lpa = GM_LPA_10000 | LPA_DUPLEX;
567 adv = lpa;
568 }
569 EFX_INFO(efx, "link up at %dMbps %s-duplex "
570 "(adv %04x lpa %04x) (MTU %d)%s\n",
571 (efx->link_options & GM_LPA_10000 ? 10000 :
572 (efx->link_options & GM_LPA_1000 ? 1000 :
573 (efx->link_options & GM_LPA_100 ? 100 :
574 10))),
575 (efx->link_options & GM_LPA_DUPLEX ?
576 "full" : "half"),
577 adv, lpa,
578 efx->net_dev->mtu,
579 (efx->promiscuous ? " [PROMISC]" : ""));
580 } else {
581 EFX_INFO(efx, "link down\n");
582 }
583
584}
585
586/* This call reinitialises the MAC to pick up new PHY settings. The
587 * caller must hold the mac_lock */
588static void __efx_reconfigure_port(struct efx_nic *efx)
589{
590 WARN_ON(!mutex_is_locked(&efx->mac_lock));
591
592 EFX_LOG(efx, "reconfiguring MAC from PHY settings on CPU %d\n",
593 raw_smp_processor_id());
594
595 falcon_reconfigure_xmac(efx);
596
597 /* Inform kernel of loss/gain of carrier */
598 efx_link_status_changed(efx);
599}
600
601/* Reinitialise the MAC to pick up new PHY settings, even if the port is
602 * disabled. */
603void efx_reconfigure_port(struct efx_nic *efx)
604{
605 EFX_ASSERT_RESET_SERIALISED(efx);
606
607 mutex_lock(&efx->mac_lock);
608 __efx_reconfigure_port(efx);
609 mutex_unlock(&efx->mac_lock);
610}
611
612/* Asynchronous efx_reconfigure_port work item. To speed up efx_flush_all()
613 * we don't efx_reconfigure_port() if the port is disabled. Care is taken
614 * in efx_stop_all() and efx_start_port() to prevent PHY events being lost */
615static void efx_reconfigure_work(struct work_struct *data)
616{
617 struct efx_nic *efx = container_of(data, struct efx_nic,
618 reconfigure_work);
619
620 mutex_lock(&efx->mac_lock);
621 if (efx->port_enabled)
622 __efx_reconfigure_port(efx);
623 mutex_unlock(&efx->mac_lock);
624}
625
626static int efx_probe_port(struct efx_nic *efx)
627{
628 int rc;
629
630 EFX_LOG(efx, "create port\n");
631
632 /* Connect up MAC/PHY operations table and read MAC address */
633 rc = falcon_probe_port(efx);
634 if (rc)
635 goto err;
636
637 /* Sanity check MAC address */
638 if (is_valid_ether_addr(efx->mac_address)) {
639 memcpy(efx->net_dev->dev_addr, efx->mac_address, ETH_ALEN);
640 } else {
641 DECLARE_MAC_BUF(mac);
642
643 EFX_ERR(efx, "invalid MAC address %s\n",
644 print_mac(mac, efx->mac_address));
645 if (!allow_bad_hwaddr) {
646 rc = -EINVAL;
647 goto err;
648 }
649 random_ether_addr(efx->net_dev->dev_addr);
650 EFX_INFO(efx, "using locally-generated MAC %s\n",
651 print_mac(mac, efx->net_dev->dev_addr));
652 }
653
654 return 0;
655
656 err:
657 efx_remove_port(efx);
658 return rc;
659}
660
661static int efx_init_port(struct efx_nic *efx)
662{
663 int rc;
664
665 EFX_LOG(efx, "init port\n");
666
667 /* Initialise the MAC and PHY */
668 rc = falcon_init_xmac(efx);
669 if (rc)
670 return rc;
671
672 efx->port_initialized = 1;
673
674 /* Reconfigure port to program MAC registers */
675 falcon_reconfigure_xmac(efx);
676
677 return 0;
678}
679
680/* Allow efx_reconfigure_port() to be scheduled, and close the window
681 * between efx_stop_port and efx_flush_all whereby a previously scheduled
682 * efx_reconfigure_port() may have been cancelled */
683static void efx_start_port(struct efx_nic *efx)
684{
685 EFX_LOG(efx, "start port\n");
686 BUG_ON(efx->port_enabled);
687
688 mutex_lock(&efx->mac_lock);
689 efx->port_enabled = 1;
690 __efx_reconfigure_port(efx);
691 mutex_unlock(&efx->mac_lock);
692}
693
694/* Prevent efx_reconfigure_work and efx_monitor() from executing, and
695 * efx_set_multicast_list() from scheduling efx_reconfigure_work.
696 * efx_reconfigure_work can still be scheduled via NAPI processing
697 * until efx_flush_all() is called */
698static void efx_stop_port(struct efx_nic *efx)
699{
700 EFX_LOG(efx, "stop port\n");
701
702 mutex_lock(&efx->mac_lock);
703 efx->port_enabled = 0;
704 mutex_unlock(&efx->mac_lock);
705
706 /* Serialise against efx_set_multicast_list() */
707 if (NET_DEV_REGISTERED(efx)) {
708 netif_tx_lock_bh(efx->net_dev);
709 netif_tx_unlock_bh(efx->net_dev);
710 }
711}
712
713static void efx_fini_port(struct efx_nic *efx)
714{
715 EFX_LOG(efx, "shut down port\n");
716
717 if (!efx->port_initialized)
718 return;
719
720 falcon_fini_xmac(efx);
721 efx->port_initialized = 0;
722
723 efx->link_up = 0;
724 efx_link_status_changed(efx);
725}
726
727static void efx_remove_port(struct efx_nic *efx)
728{
729 EFX_LOG(efx, "destroying port\n");
730
731 falcon_remove_port(efx);
732}
733
734/**************************************************************************
735 *
736 * NIC handling
737 *
738 **************************************************************************/
739
740/* This configures the PCI device to enable I/O and DMA. */
741static int efx_init_io(struct efx_nic *efx)
742{
743 struct pci_dev *pci_dev = efx->pci_dev;
744 dma_addr_t dma_mask = efx->type->max_dma_mask;
745 int rc;
746
747 EFX_LOG(efx, "initialising I/O\n");
748
749 rc = pci_enable_device(pci_dev);
750 if (rc) {
751 EFX_ERR(efx, "failed to enable PCI device\n");
752 goto fail1;
753 }
754
755 pci_set_master(pci_dev);
756
757 /* Set the PCI DMA mask. Try all possibilities from our
758 * genuine mask down to 32 bits, because some architectures
759 * (e.g. x86_64 with iommu_sac_force set) will allow 40 bit
760 * masks event though they reject 46 bit masks.
761 */
762 while (dma_mask > 0x7fffffffUL) {
763 if (pci_dma_supported(pci_dev, dma_mask) &&
764 ((rc = pci_set_dma_mask(pci_dev, dma_mask)) == 0))
765 break;
766 dma_mask >>= 1;
767 }
768 if (rc) {
769 EFX_ERR(efx, "could not find a suitable DMA mask\n");
770 goto fail2;
771 }
772 EFX_LOG(efx, "using DMA mask %llx\n", (unsigned long long) dma_mask);
773 rc = pci_set_consistent_dma_mask(pci_dev, dma_mask);
774 if (rc) {
775 /* pci_set_consistent_dma_mask() is not *allowed* to
776 * fail with a mask that pci_set_dma_mask() accepted,
777 * but just in case...
778 */
779 EFX_ERR(efx, "failed to set consistent DMA mask\n");
780 goto fail2;
781 }
782
783 efx->membase_phys = pci_resource_start(efx->pci_dev,
784 efx->type->mem_bar);
785 rc = pci_request_region(pci_dev, efx->type->mem_bar, "sfc");
786 if (rc) {
787 EFX_ERR(efx, "request for memory BAR failed\n");
788 rc = -EIO;
789 goto fail3;
790 }
791 efx->membase = ioremap_nocache(efx->membase_phys,
792 efx->type->mem_map_size);
793 if (!efx->membase) {
794 EFX_ERR(efx, "could not map memory BAR %d at %lx+%x\n",
795 efx->type->mem_bar, efx->membase_phys,
796 efx->type->mem_map_size);
797 rc = -ENOMEM;
798 goto fail4;
799 }
800 EFX_LOG(efx, "memory BAR %u at %lx+%x (virtual %p)\n",
801 efx->type->mem_bar, efx->membase_phys, efx->type->mem_map_size,
802 efx->membase);
803
804 return 0;
805
806 fail4:
807 release_mem_region(efx->membase_phys, efx->type->mem_map_size);
808 fail3:
809 efx->membase_phys = 0UL;
810 fail2:
811 pci_disable_device(efx->pci_dev);
812 fail1:
813 return rc;
814}
815
816static void efx_fini_io(struct efx_nic *efx)
817{
818 EFX_LOG(efx, "shutting down I/O\n");
819
820 if (efx->membase) {
821 iounmap(efx->membase);
822 efx->membase = NULL;
823 }
824
825 if (efx->membase_phys) {
826 pci_release_region(efx->pci_dev, efx->type->mem_bar);
827 efx->membase_phys = 0UL;
828 }
829
830 pci_disable_device(efx->pci_dev);
831}
832
833/* Probe the number and type of interrupts we are able to obtain. */
834static void efx_probe_interrupts(struct efx_nic *efx)
835{
836 int max_channel = efx->type->phys_addr_channels - 1;
837 struct msix_entry xentries[EFX_MAX_CHANNELS];
838 int rc, i;
839
840 if (efx->interrupt_mode == EFX_INT_MODE_MSIX) {
841 BUG_ON(!pci_find_capability(efx->pci_dev, PCI_CAP_ID_MSIX));
842
843 efx->rss_queues = rss_cpus ? rss_cpus : num_online_cpus();
844 efx->rss_queues = min(efx->rss_queues, max_channel + 1);
845 efx->rss_queues = min(efx->rss_queues, EFX_MAX_CHANNELS);
846
847 /* Request maximum number of MSI interrupts, and fill out
848 * the channel interrupt information the allowed allocation */
849 for (i = 0; i < efx->rss_queues; i++)
850 xentries[i].entry = i;
851 rc = pci_enable_msix(efx->pci_dev, xentries, efx->rss_queues);
852 if (rc > 0) {
853 EFX_BUG_ON_PARANOID(rc >= efx->rss_queues);
854 efx->rss_queues = rc;
855 rc = pci_enable_msix(efx->pci_dev, xentries,
856 efx->rss_queues);
857 }
858
859 if (rc == 0) {
860 for (i = 0; i < efx->rss_queues; i++) {
861 efx->channel[i].has_interrupt = 1;
862 efx->channel[i].irq = xentries[i].vector;
863 }
864 } else {
865 /* Fall back to single channel MSI */
866 efx->interrupt_mode = EFX_INT_MODE_MSI;
867 EFX_ERR(efx, "could not enable MSI-X\n");
868 }
869 }
870
871 /* Try single interrupt MSI */
872 if (efx->interrupt_mode == EFX_INT_MODE_MSI) {
873 efx->rss_queues = 1;
874 rc = pci_enable_msi(efx->pci_dev);
875 if (rc == 0) {
876 efx->channel[0].irq = efx->pci_dev->irq;
877 efx->channel[0].has_interrupt = 1;
878 } else {
879 EFX_ERR(efx, "could not enable MSI\n");
880 efx->interrupt_mode = EFX_INT_MODE_LEGACY;
881 }
882 }
883
884 /* Assume legacy interrupts */
885 if (efx->interrupt_mode == EFX_INT_MODE_LEGACY) {
886 efx->rss_queues = 1;
887 /* Every channel is interruptible */
888 for (i = 0; i < EFX_MAX_CHANNELS; i++)
889 efx->channel[i].has_interrupt = 1;
890 efx->legacy_irq = efx->pci_dev->irq;
891 }
892}
893
894static void efx_remove_interrupts(struct efx_nic *efx)
895{
896 struct efx_channel *channel;
897
898 /* Remove MSI/MSI-X interrupts */
899 efx_for_each_channel_with_interrupt(channel, efx)
900 channel->irq = 0;
901 pci_disable_msi(efx->pci_dev);
902 pci_disable_msix(efx->pci_dev);
903
904 /* Remove legacy interrupt */
905 efx->legacy_irq = 0;
906}
907
908/* Select number of used resources
909 * Should be called after probe_interrupts()
910 */
911static void efx_select_used(struct efx_nic *efx)
912{
913 struct efx_tx_queue *tx_queue;
914 struct efx_rx_queue *rx_queue;
915 int i;
916
917 /* TX queues. One per port per channel with TX capability
918 * (more than one per port won't work on Linux, due to out
919 * of order issues... but will be fine on Solaris)
920 */
921 tx_queue = &efx->tx_queue[0];
922
923 /* Perform this for each channel with TX capabilities.
924 * At the moment, we only support a single TX queue
925 */
926 tx_queue->used = 1;
927 if ((!EFX_INT_MODE_USE_MSI(efx)) && separate_tx_and_rx_channels)
928 tx_queue->channel = &efx->channel[1];
929 else
930 tx_queue->channel = &efx->channel[0];
931 tx_queue->channel->used_flags |= EFX_USED_BY_TX;
932 tx_queue++;
933
934 /* RX queues. Each has a dedicated channel. */
935 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) {
936 rx_queue = &efx->rx_queue[i];
937
938 if (i < efx->rss_queues) {
939 rx_queue->used = 1;
940 /* If we allow multiple RX queues per channel
941 * we need to decide that here
942 */
943 rx_queue->channel = &efx->channel[rx_queue->queue];
944 rx_queue->channel->used_flags |= EFX_USED_BY_RX;
945 rx_queue++;
946 }
947 }
948}
949
950static int efx_probe_nic(struct efx_nic *efx)
951{
952 int rc;
953
954 EFX_LOG(efx, "creating NIC\n");
955
956 /* Carry out hardware-type specific initialisation */
957 rc = falcon_probe_nic(efx);
958 if (rc)
959 return rc;
960
961 /* Determine the number of channels and RX queues by trying to hook
962 * in MSI-X interrupts. */
963 efx_probe_interrupts(efx);
964
965 /* Determine number of RX queues and TX queues */
966 efx_select_used(efx);
967
968 /* Initialise the interrupt moderation settings */
969 efx_init_irq_moderation(efx, tx_irq_mod_usec, rx_irq_mod_usec);
970
971 return 0;
972}
973
974static void efx_remove_nic(struct efx_nic *efx)
975{
976 EFX_LOG(efx, "destroying NIC\n");
977
978 efx_remove_interrupts(efx);
979 falcon_remove_nic(efx);
980}
981
982/**************************************************************************
983 *
984 * NIC startup/shutdown
985 *
986 *************************************************************************/
987
988static int efx_probe_all(struct efx_nic *efx)
989{
990 struct efx_channel *channel;
991 int rc;
992
993 /* Create NIC */
994 rc = efx_probe_nic(efx);
995 if (rc) {
996 EFX_ERR(efx, "failed to create NIC\n");
997 goto fail1;
998 }
999
1000 /* Create port */
1001 rc = efx_probe_port(efx);
1002 if (rc) {
1003 EFX_ERR(efx, "failed to create port\n");
1004 goto fail2;
1005 }
1006
1007 /* Create channels */
1008 efx_for_each_channel(channel, efx) {
1009 rc = efx_probe_channel(channel);
1010 if (rc) {
1011 EFX_ERR(efx, "failed to create channel %d\n",
1012 channel->channel);
1013 goto fail3;
1014 }
1015 }
1016
1017 return 0;
1018
1019 fail3:
1020 efx_for_each_channel(channel, efx)
1021 efx_remove_channel(channel);
1022 efx_remove_port(efx);
1023 fail2:
1024 efx_remove_nic(efx);
1025 fail1:
1026 return rc;
1027}
1028
1029/* Called after previous invocation(s) of efx_stop_all, restarts the
1030 * port, kernel transmit queue, NAPI processing and hardware interrupts,
1031 * and ensures that the port is scheduled to be reconfigured.
1032 * This function is safe to call multiple times when the NIC is in any
1033 * state. */
1034static void efx_start_all(struct efx_nic *efx)
1035{
1036 struct efx_channel *channel;
1037
1038 EFX_ASSERT_RESET_SERIALISED(efx);
1039
1040 /* Check that it is appropriate to restart the interface. All
1041 * of these flags are safe to read under just the rtnl lock */
1042 if (efx->port_enabled)
1043 return;
1044 if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT))
1045 return;
1046 if (NET_DEV_REGISTERED(efx) && !netif_running(efx->net_dev))
1047 return;
1048
1049 /* Mark the port as enabled so port reconfigurations can start, then
1050 * restart the transmit interface early so the watchdog timer stops */
1051 efx_start_port(efx);
1052 efx_wake_queue(efx);
1053
1054 efx_for_each_channel(channel, efx)
1055 efx_start_channel(channel);
1056
1057 falcon_enable_interrupts(efx);
1058
1059 /* Start hardware monitor if we're in RUNNING */
1060 if (efx->state == STATE_RUNNING)
1061 queue_delayed_work(efx->workqueue, &efx->monitor_work,
1062 efx_monitor_interval);
1063}
1064
1065/* Flush all delayed work. Should only be called when no more delayed work
1066 * will be scheduled. This doesn't flush pending online resets (efx_reset),
1067 * since we're holding the rtnl_lock at this point. */
1068static void efx_flush_all(struct efx_nic *efx)
1069{
1070 struct efx_rx_queue *rx_queue;
1071
1072 /* Make sure the hardware monitor is stopped */
1073 cancel_delayed_work_sync(&efx->monitor_work);
1074
1075 /* Ensure that all RX slow refills are complete. */
1076 efx_for_each_rx_queue(rx_queue, efx) {
1077 cancel_delayed_work_sync(&rx_queue->work);
1078 }
1079
1080 /* Stop scheduled port reconfigurations */
1081 cancel_work_sync(&efx->reconfigure_work);
1082
1083}
1084
1085/* Quiesce hardware and software without bringing the link down.
1086 * Safe to call multiple times, when the nic and interface is in any
1087 * state. The caller is guaranteed to subsequently be in a position
1088 * to modify any hardware and software state they see fit without
1089 * taking locks. */
1090static void efx_stop_all(struct efx_nic *efx)
1091{
1092 struct efx_channel *channel;
1093
1094 EFX_ASSERT_RESET_SERIALISED(efx);
1095
1096 /* port_enabled can be read safely under the rtnl lock */
1097 if (!efx->port_enabled)
1098 return;
1099
1100 /* Disable interrupts and wait for ISR to complete */
1101 falcon_disable_interrupts(efx);
1102 if (efx->legacy_irq)
1103 synchronize_irq(efx->legacy_irq);
1104 efx_for_each_channel_with_interrupt(channel, efx)
1105 if (channel->irq)
1106 synchronize_irq(channel->irq);
1107
1108 /* Stop all NAPI processing and synchronous rx refills */
1109 efx_for_each_channel(channel, efx)
1110 efx_stop_channel(channel);
1111
1112 /* Stop all asynchronous port reconfigurations. Since all
1113 * event processing has already been stopped, there is no
1114 * window to loose phy events */
1115 efx_stop_port(efx);
1116
1117 /* Flush reconfigure_work, refill_workqueue, monitor_work */
1118 efx_flush_all(efx);
1119
1120 /* Isolate the MAC from the TX and RX engines, so that queue
1121 * flushes will complete in a timely fashion. */
1122 falcon_deconfigure_mac_wrapper(efx);
1123 falcon_drain_tx_fifo(efx);
1124
1125 /* Stop the kernel transmit interface late, so the watchdog
1126 * timer isn't ticking over the flush */
1127 efx_stop_queue(efx);
1128 if (NET_DEV_REGISTERED(efx)) {
1129 netif_tx_lock_bh(efx->net_dev);
1130 netif_tx_unlock_bh(efx->net_dev);
1131 }
1132}
1133
1134static void efx_remove_all(struct efx_nic *efx)
1135{
1136 struct efx_channel *channel;
1137
1138 efx_for_each_channel(channel, efx)
1139 efx_remove_channel(channel);
1140 efx_remove_port(efx);
1141 efx_remove_nic(efx);
1142}
1143
1144/* A convinience function to safely flush all the queues */
1145int efx_flush_queues(struct efx_nic *efx)
1146{
1147 int rc;
1148
1149 EFX_ASSERT_RESET_SERIALISED(efx);
1150
1151 efx_stop_all(efx);
1152
1153 efx_fini_channels(efx);
1154 rc = efx_init_channels(efx);
1155 if (rc) {
1156 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
1157 return rc;
1158 }
1159
1160 efx_start_all(efx);
1161
1162 return 0;
1163}
1164
1165/**************************************************************************
1166 *
1167 * Interrupt moderation
1168 *
1169 **************************************************************************/
1170
1171/* Set interrupt moderation parameters */
1172void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs)
1173{
1174 struct efx_tx_queue *tx_queue;
1175 struct efx_rx_queue *rx_queue;
1176
1177 EFX_ASSERT_RESET_SERIALISED(efx);
1178
1179 efx_for_each_tx_queue(tx_queue, efx)
1180 tx_queue->channel->irq_moderation = tx_usecs;
1181
1182 efx_for_each_rx_queue(rx_queue, efx)
1183 rx_queue->channel->irq_moderation = rx_usecs;
1184}
1185
1186/**************************************************************************
1187 *
1188 * Hardware monitor
1189 *
1190 **************************************************************************/
1191
1192/* Run periodically off the general workqueue. Serialised against
1193 * efx_reconfigure_port via the mac_lock */
1194static void efx_monitor(struct work_struct *data)
1195{
1196 struct efx_nic *efx = container_of(data, struct efx_nic,
1197 monitor_work.work);
1198 int rc = 0;
1199
1200 EFX_TRACE(efx, "hardware monitor executing on CPU %d\n",
1201 raw_smp_processor_id());
1202
1203
1204 /* If the mac_lock is already held then it is likely a port
1205 * reconfiguration is already in place, which will likely do
1206 * most of the work of check_hw() anyway. */
1207 if (!mutex_trylock(&efx->mac_lock)) {
1208 queue_delayed_work(efx->workqueue, &efx->monitor_work,
1209 efx_monitor_interval);
1210 return;
1211 }
1212
1213 if (efx->port_enabled)
1214 rc = falcon_check_xmac(efx);
1215 mutex_unlock(&efx->mac_lock);
1216
1217 if (rc) {
1218 if (monitor_reset) {
1219 EFX_ERR(efx, "hardware monitor detected a fault: "
1220 "triggering reset\n");
1221 efx_schedule_reset(efx, RESET_TYPE_MONITOR);
1222 } else {
1223 EFX_ERR(efx, "hardware monitor detected a fault, "
1224 "skipping reset\n");
1225 }
1226 }
1227
1228 queue_delayed_work(efx->workqueue, &efx->monitor_work,
1229 efx_monitor_interval);
1230}
1231
1232/**************************************************************************
1233 *
1234 * ioctls
1235 *
1236 *************************************************************************/
1237
1238/* Net device ioctl
1239 * Context: process, rtnl_lock() held.
1240 */
1241static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
1242{
1243 struct efx_nic *efx = net_dev->priv;
1244
1245 EFX_ASSERT_RESET_SERIALISED(efx);
1246
1247 return generic_mii_ioctl(&efx->mii, if_mii(ifr), cmd, NULL);
1248}
1249
1250/**************************************************************************
1251 *
1252 * NAPI interface
1253 *
1254 **************************************************************************/
1255
1256static int efx_init_napi(struct efx_nic *efx)
1257{
1258 struct efx_channel *channel;
1259 int rc;
1260
1261 efx_for_each_channel(channel, efx) {
1262 channel->napi_dev = efx->net_dev;
1263 rc = efx_lro_init(&channel->lro_mgr, efx);
1264 if (rc)
1265 goto err;
1266 }
1267 return 0;
1268 err:
1269 efx_fini_napi(efx);
1270 return rc;
1271}
1272
1273static void efx_fini_napi(struct efx_nic *efx)
1274{
1275 struct efx_channel *channel;
1276
1277 efx_for_each_channel(channel, efx) {
1278 efx_lro_fini(&channel->lro_mgr);
1279 channel->napi_dev = NULL;
1280 }
1281}
1282
1283/**************************************************************************
1284 *
1285 * Kernel netpoll interface
1286 *
1287 *************************************************************************/
1288
1289#ifdef CONFIG_NET_POLL_CONTROLLER
1290
1291/* Although in the common case interrupts will be disabled, this is not
1292 * guaranteed. However, all our work happens inside the NAPI callback,
1293 * so no locking is required.
1294 */
1295static void efx_netpoll(struct net_device *net_dev)
1296{
1297 struct efx_nic *efx = net_dev->priv;
1298 struct efx_channel *channel;
1299
1300 efx_for_each_channel_with_interrupt(channel, efx)
1301 efx_schedule_channel(channel);
1302}
1303
1304#endif
1305
1306/**************************************************************************
1307 *
1308 * Kernel net device interface
1309 *
1310 *************************************************************************/
1311
1312/* Context: process, rtnl_lock() held. */
1313static int efx_net_open(struct net_device *net_dev)
1314{
1315 struct efx_nic *efx = net_dev->priv;
1316 EFX_ASSERT_RESET_SERIALISED(efx);
1317
1318 EFX_LOG(efx, "opening device %s on CPU %d\n", net_dev->name,
1319 raw_smp_processor_id());
1320
1321 efx_start_all(efx);
1322 return 0;
1323}
1324
1325/* Context: process, rtnl_lock() held.
1326 * Note that the kernel will ignore our return code; this method
1327 * should really be a void.
1328 */
1329static int efx_net_stop(struct net_device *net_dev)
1330{
1331 struct efx_nic *efx = net_dev->priv;
1332 int rc;
1333
1334 EFX_LOG(efx, "closing %s on CPU %d\n", net_dev->name,
1335 raw_smp_processor_id());
1336
1337 /* Stop the device and flush all the channels */
1338 efx_stop_all(efx);
1339 efx_fini_channels(efx);
1340 rc = efx_init_channels(efx);
1341 if (rc)
1342 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
1343
1344 return 0;
1345}
1346
1347/* Context: process, dev_base_lock held, non-blocking. */
1348static struct net_device_stats *efx_net_stats(struct net_device *net_dev)
1349{
1350 struct efx_nic *efx = net_dev->priv;
1351 struct efx_mac_stats *mac_stats = &efx->mac_stats;
1352 struct net_device_stats *stats = &net_dev->stats;
1353
1354 if (!spin_trylock(&efx->stats_lock))
1355 return stats;
1356 if (efx->state == STATE_RUNNING) {
1357 falcon_update_stats_xmac(efx);
1358 falcon_update_nic_stats(efx);
1359 }
1360 spin_unlock(&efx->stats_lock);
1361
1362 stats->rx_packets = mac_stats->rx_packets;
1363 stats->tx_packets = mac_stats->tx_packets;
1364 stats->rx_bytes = mac_stats->rx_bytes;
1365 stats->tx_bytes = mac_stats->tx_bytes;
1366 stats->multicast = mac_stats->rx_multicast;
1367 stats->collisions = mac_stats->tx_collision;
1368 stats->rx_length_errors = (mac_stats->rx_gtjumbo +
1369 mac_stats->rx_length_error);
1370 stats->rx_over_errors = efx->n_rx_nodesc_drop_cnt;
1371 stats->rx_crc_errors = mac_stats->rx_bad;
1372 stats->rx_frame_errors = mac_stats->rx_align_error;
1373 stats->rx_fifo_errors = mac_stats->rx_overflow;
1374 stats->rx_missed_errors = mac_stats->rx_missed;
1375 stats->tx_window_errors = mac_stats->tx_late_collision;
1376
1377 stats->rx_errors = (stats->rx_length_errors +
1378 stats->rx_over_errors +
1379 stats->rx_crc_errors +
1380 stats->rx_frame_errors +
1381 stats->rx_fifo_errors +
1382 stats->rx_missed_errors +
1383 mac_stats->rx_symbol_error);
1384 stats->tx_errors = (stats->tx_window_errors +
1385 mac_stats->tx_bad);
1386
1387 return stats;
1388}
1389
1390/* Context: netif_tx_lock held, BHs disabled. */
1391static void efx_watchdog(struct net_device *net_dev)
1392{
1393 struct efx_nic *efx = net_dev->priv;
1394
1395 EFX_ERR(efx, "TX stuck with stop_count=%d port_enabled=%d: %s\n",
1396 atomic_read(&efx->netif_stop_count), efx->port_enabled,
1397 monitor_reset ? "resetting channels" : "skipping reset");
1398
1399 if (monitor_reset)
1400 efx_schedule_reset(efx, RESET_TYPE_MONITOR);
1401}
1402
1403
1404/* Context: process, rtnl_lock() held. */
1405static int efx_change_mtu(struct net_device *net_dev, int new_mtu)
1406{
1407 struct efx_nic *efx = net_dev->priv;
1408 int rc = 0;
1409
1410 EFX_ASSERT_RESET_SERIALISED(efx);
1411
1412 if (new_mtu > EFX_MAX_MTU)
1413 return -EINVAL;
1414
1415 efx_stop_all(efx);
1416
1417 EFX_LOG(efx, "changing MTU to %d\n", new_mtu);
1418
1419 efx_fini_channels(efx);
1420 net_dev->mtu = new_mtu;
1421 rc = efx_init_channels(efx);
1422 if (rc)
1423 goto fail;
1424
1425 efx_start_all(efx);
1426 return rc;
1427
1428 fail:
1429 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
1430 return rc;
1431}
1432
1433static int efx_set_mac_address(struct net_device *net_dev, void *data)
1434{
1435 struct efx_nic *efx = net_dev->priv;
1436 struct sockaddr *addr = data;
1437 char *new_addr = addr->sa_data;
1438
1439 EFX_ASSERT_RESET_SERIALISED(efx);
1440
1441 if (!is_valid_ether_addr(new_addr)) {
1442 DECLARE_MAC_BUF(mac);
1443 EFX_ERR(efx, "invalid ethernet MAC address requested: %s\n",
1444 print_mac(mac, new_addr));
1445 return -EINVAL;
1446 }
1447
1448 memcpy(net_dev->dev_addr, new_addr, net_dev->addr_len);
1449
1450 /* Reconfigure the MAC */
1451 efx_reconfigure_port(efx);
1452
1453 return 0;
1454}
1455
1456/* Context: netif_tx_lock held, BHs disabled. */
1457static void efx_set_multicast_list(struct net_device *net_dev)
1458{
1459 struct efx_nic *efx = net_dev->priv;
1460 struct dev_mc_list *mc_list = net_dev->mc_list;
1461 union efx_multicast_hash *mc_hash = &efx->multicast_hash;
1462 int promiscuous;
1463 u32 crc;
1464 int bit;
1465 int i;
1466
1467 /* Set per-MAC promiscuity flag and reconfigure MAC if necessary */
1468 promiscuous = (net_dev->flags & IFF_PROMISC) ? 1 : 0;
1469 if (efx->promiscuous != promiscuous) {
1470 efx->promiscuous = promiscuous;
1471 /* Close the window between efx_stop_port() and efx_flush_all()
1472 * by only queuing work when the port is enabled. */
1473 if (efx->port_enabled)
1474 queue_work(efx->workqueue, &efx->reconfigure_work);
1475 }
1476
1477 /* Build multicast hash table */
1478 if (promiscuous || (net_dev->flags & IFF_ALLMULTI)) {
1479 memset(mc_hash, 0xff, sizeof(*mc_hash));
1480 } else {
1481 memset(mc_hash, 0x00, sizeof(*mc_hash));
1482 for (i = 0; i < net_dev->mc_count; i++) {
1483 crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr);
1484 bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
1485 set_bit_le(bit, mc_hash->byte);
1486 mc_list = mc_list->next;
1487 }
1488 }
1489
1490 /* Create and activate new global multicast hash table */
1491 falcon_set_multicast_hash(efx);
1492}
1493
1494static int efx_netdev_event(struct notifier_block *this,
1495 unsigned long event, void *ptr)
1496{
1497 struct net_device *net_dev = (struct net_device *)ptr;
1498
1499 if (net_dev->open == efx_net_open && event == NETDEV_CHANGENAME) {
1500 struct efx_nic *efx = net_dev->priv;
1501
1502 strcpy(efx->name, net_dev->name);
1503 }
1504
1505 return NOTIFY_DONE;
1506}
1507
1508static struct notifier_block efx_netdev_notifier = {
1509 .notifier_call = efx_netdev_event,
1510};
1511
1512static int efx_register_netdev(struct efx_nic *efx)
1513{
1514 struct net_device *net_dev = efx->net_dev;
1515 int rc;
1516
1517 net_dev->watchdog_timeo = 5 * HZ;
1518 net_dev->irq = efx->pci_dev->irq;
1519 net_dev->open = efx_net_open;
1520 net_dev->stop = efx_net_stop;
1521 net_dev->get_stats = efx_net_stats;
1522 net_dev->tx_timeout = &efx_watchdog;
1523 net_dev->hard_start_xmit = efx_hard_start_xmit;
1524 net_dev->do_ioctl = efx_ioctl;
1525 net_dev->change_mtu = efx_change_mtu;
1526 net_dev->set_mac_address = efx_set_mac_address;
1527 net_dev->set_multicast_list = efx_set_multicast_list;
1528#ifdef CONFIG_NET_POLL_CONTROLLER
1529 net_dev->poll_controller = efx_netpoll;
1530#endif
1531 SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev);
1532 SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);
1533
1534 /* Always start with carrier off; PHY events will detect the link */
1535 netif_carrier_off(efx->net_dev);
1536
1537 /* Clear MAC statistics */
1538 falcon_update_stats_xmac(efx);
1539 memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));
1540
1541 rc = register_netdev(net_dev);
1542 if (rc) {
1543 EFX_ERR(efx, "could not register net dev\n");
1544 return rc;
1545 }
1546 strcpy(efx->name, net_dev->name);
1547
1548 return 0;
1549}
1550
1551static void efx_unregister_netdev(struct efx_nic *efx)
1552{
1553 struct efx_tx_queue *tx_queue;
1554
1555 if (!efx->net_dev)
1556 return;
1557
1558 BUG_ON(efx->net_dev->priv != efx);
1559
1560 /* Free up any skbs still remaining. This has to happen before
1561 * we try to unregister the netdev as running their destructors
1562 * may be needed to get the device ref. count to 0. */
1563 efx_for_each_tx_queue(tx_queue, efx)
1564 efx_release_tx_buffers(tx_queue);
1565
1566 if (NET_DEV_REGISTERED(efx)) {
1567 strlcpy(efx->name, pci_name(efx->pci_dev), sizeof(efx->name));
1568 unregister_netdev(efx->net_dev);
1569 }
1570}
1571
1572/**************************************************************************
1573 *
1574 * Device reset and suspend
1575 *
1576 **************************************************************************/
1577
1578/* The final hardware and software finalisation before reset. */
1579static int efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd)
1580{
1581 int rc;
1582
1583 EFX_ASSERT_RESET_SERIALISED(efx);
1584
1585 rc = falcon_xmac_get_settings(efx, ecmd);
1586 if (rc) {
1587 EFX_ERR(efx, "could not back up PHY settings\n");
1588 goto fail;
1589 }
1590
1591 efx_fini_channels(efx);
1592 return 0;
1593
1594 fail:
1595 return rc;
1596}
1597
1598/* The first part of software initialisation after a hardware reset
1599 * This function does not handle serialisation with the kernel, it
1600 * assumes the caller has done this */
1601static int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd)
1602{
1603 int rc;
1604
1605 rc = efx_init_channels(efx);
1606 if (rc)
1607 goto fail1;
1608
1609 /* Restore MAC and PHY settings. */
1610 rc = falcon_xmac_set_settings(efx, ecmd);
1611 if (rc) {
1612 EFX_ERR(efx, "could not restore PHY settings\n");
1613 goto fail2;
1614 }
1615
1616 return 0;
1617
1618 fail2:
1619 efx_fini_channels(efx);
1620 fail1:
1621 return rc;
1622}
1623
1624/* Reset the NIC as transparently as possible. Do not reset the PHY
1625 * Note that the reset may fail, in which case the card will be left
1626 * in a most-probably-unusable state.
1627 *
1628 * This function will sleep. You cannot reset from within an atomic
1629 * state; use efx_schedule_reset() instead.
1630 *
1631 * Grabs the rtnl_lock.
1632 */
1633static int efx_reset(struct efx_nic *efx)
1634{
1635 struct ethtool_cmd ecmd;
1636 enum reset_type method = efx->reset_pending;
1637 int rc;
1638
1639 /* Serialise with kernel interfaces */
1640 rtnl_lock();
1641
1642 /* If we're not RUNNING then don't reset. Leave the reset_pending
1643 * flag set so that efx_pci_probe_main will be retried */
1644 if (efx->state != STATE_RUNNING) {
1645 EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n");
1646 goto unlock_rtnl;
1647 }
1648
1649 efx->state = STATE_RESETTING;
1650 EFX_INFO(efx, "resetting (%d)\n", method);
1651
1652 /* The net_dev->get_stats handler is quite slow, and will fail
1653 * if a fetch is pending over reset. Serialise against it. */
1654 spin_lock(&efx->stats_lock);
1655 spin_unlock(&efx->stats_lock);
1656
1657 efx_stop_all(efx);
1658 mutex_lock(&efx->mac_lock);
1659
1660 rc = efx_reset_down(efx, &ecmd);
1661 if (rc)
1662 goto fail1;
1663
1664 rc = falcon_reset_hw(efx, method);
1665 if (rc) {
1666 EFX_ERR(efx, "failed to reset hardware\n");
1667 goto fail2;
1668 }
1669
1670 /* Allow resets to be rescheduled. */
1671 efx->reset_pending = RESET_TYPE_NONE;
1672
1673 /* Reinitialise bus-mastering, which may have been turned off before
1674 * the reset was scheduled. This is still appropriate, even in the
1675 * RESET_TYPE_DISABLE since this driver generally assumes the hardware
1676 * can respond to requests. */
1677 pci_set_master(efx->pci_dev);
1678
1679 /* Reinitialise device. This is appropriate in the RESET_TYPE_DISABLE
1680 * case so the driver can talk to external SRAM */
1681 rc = falcon_init_nic(efx);
1682 if (rc) {
1683 EFX_ERR(efx, "failed to initialise NIC\n");
1684 goto fail3;
1685 }
1686
1687 /* Leave device stopped if necessary */
1688 if (method == RESET_TYPE_DISABLE) {
1689 /* Reinitialise the device anyway so the driver unload sequence
1690 * can talk to the external SRAM */
1691 (void) falcon_init_nic(efx);
1692 rc = -EIO;
1693 goto fail4;
1694 }
1695
1696 rc = efx_reset_up(efx, &ecmd);
1697 if (rc)
1698 goto fail5;
1699
1700 mutex_unlock(&efx->mac_lock);
1701 EFX_LOG(efx, "reset complete\n");
1702
1703 efx->state = STATE_RUNNING;
1704 efx_start_all(efx);
1705
1706 unlock_rtnl:
1707 rtnl_unlock();
1708 return 0;
1709
1710 fail5:
1711 fail4:
1712 fail3:
1713 fail2:
1714 fail1:
1715 EFX_ERR(efx, "has been disabled\n");
1716 efx->state = STATE_DISABLED;
1717
1718 mutex_unlock(&efx->mac_lock);
1719 rtnl_unlock();
1720 efx_unregister_netdev(efx);
1721 efx_fini_port(efx);
1722 return rc;
1723}
1724
1725/* The worker thread exists so that code that cannot sleep can
1726 * schedule a reset for later.
1727 */
1728static void efx_reset_work(struct work_struct *data)
1729{
1730 struct efx_nic *nic = container_of(data, struct efx_nic, reset_work);
1731
1732 efx_reset(nic);
1733}
1734
1735void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
1736{
1737 enum reset_type method;
1738
1739 if (efx->reset_pending != RESET_TYPE_NONE) {
1740 EFX_INFO(efx, "quenching already scheduled reset\n");
1741 return;
1742 }
1743
1744 switch (type) {
1745 case RESET_TYPE_INVISIBLE:
1746 case RESET_TYPE_ALL:
1747 case RESET_TYPE_WORLD:
1748 case RESET_TYPE_DISABLE:
1749 method = type;
1750 break;
1751 case RESET_TYPE_RX_RECOVERY:
1752 case RESET_TYPE_RX_DESC_FETCH:
1753 case RESET_TYPE_TX_DESC_FETCH:
1754 case RESET_TYPE_TX_SKIP:
1755 method = RESET_TYPE_INVISIBLE;
1756 break;
1757 default:
1758 method = RESET_TYPE_ALL;
1759 break;
1760 }
1761
1762 if (method != type)
1763 EFX_LOG(efx, "scheduling reset (%d:%d)\n", type, method);
1764 else
1765 EFX_LOG(efx, "scheduling reset (%d)\n", method);
1766
1767 efx->reset_pending = method;
1768
1769 queue_work(efx->workqueue, &efx->reset_work);
1770}
1771
1772/**************************************************************************
1773 *
1774 * List of NICs we support
1775 *
1776 **************************************************************************/
1777
1778/* PCI device ID table */
1779static struct pci_device_id efx_pci_table[] __devinitdata = {
1780 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_A_P_DEVID),
1781 .driver_data = (unsigned long) &falcon_a_nic_type},
1782 {PCI_DEVICE(EFX_VENDID_SFC, FALCON_B_P_DEVID),
1783 .driver_data = (unsigned long) &falcon_b_nic_type},
1784 {0} /* end of list */
1785};
1786
1787/**************************************************************************
1788 *
1789 * Dummy PHY/MAC/Board operations
1790 *
1791 * Can be used where the MAC does not implement this operation
1792 * Needed so all function pointers are valid and do not have to be tested
1793 * before use
1794 *
1795 **************************************************************************/
1796int efx_port_dummy_op_int(struct efx_nic *efx)
1797{
1798 return 0;
1799}
1800void efx_port_dummy_op_void(struct efx_nic *efx) {}
1801void efx_port_dummy_op_blink(struct efx_nic *efx, int blink) {}
1802
1803static struct efx_phy_operations efx_dummy_phy_operations = {
1804 .init = efx_port_dummy_op_int,
1805 .reconfigure = efx_port_dummy_op_void,
1806 .check_hw = efx_port_dummy_op_int,
1807 .fini = efx_port_dummy_op_void,
1808 .clear_interrupt = efx_port_dummy_op_void,
1809 .reset_xaui = efx_port_dummy_op_void,
1810};
1811
1812/* Dummy board operations */
1813static int efx_nic_dummy_op_int(struct efx_nic *nic)
1814{
1815 return 0;
1816}
1817
1818static struct efx_board efx_dummy_board_info = {
1819 .init = efx_nic_dummy_op_int,
1820 .init_leds = efx_port_dummy_op_int,
1821 .set_fault_led = efx_port_dummy_op_blink,
1822};
1823
1824/**************************************************************************
1825 *
1826 * Data housekeeping
1827 *
1828 **************************************************************************/
1829
1830/* This zeroes out and then fills in the invariants in a struct
1831 * efx_nic (including all sub-structures).
1832 */
1833static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1834 struct pci_dev *pci_dev, struct net_device *net_dev)
1835{
1836 struct efx_channel *channel;
1837 struct efx_tx_queue *tx_queue;
1838 struct efx_rx_queue *rx_queue;
1839 int i, rc;
1840
1841 /* Initialise common structures */
1842 memset(efx, 0, sizeof(*efx));
1843 spin_lock_init(&efx->biu_lock);
1844 spin_lock_init(&efx->phy_lock);
1845 INIT_WORK(&efx->reset_work, efx_reset_work);
1846 INIT_DELAYED_WORK(&efx->monitor_work, efx_monitor);
1847 efx->pci_dev = pci_dev;
1848 efx->state = STATE_INIT;
1849 efx->reset_pending = RESET_TYPE_NONE;
1850 strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name));
1851 efx->board_info = efx_dummy_board_info;
1852
1853 efx->net_dev = net_dev;
1854 efx->rx_checksum_enabled = 1;
1855 spin_lock_init(&efx->netif_stop_lock);
1856 spin_lock_init(&efx->stats_lock);
1857 mutex_init(&efx->mac_lock);
1858 efx->phy_op = &efx_dummy_phy_operations;
1859 efx->mii.dev = net_dev;
1860 INIT_WORK(&efx->reconfigure_work, efx_reconfigure_work);
1861 atomic_set(&efx->netif_stop_count, 1);
1862
1863 for (i = 0; i < EFX_MAX_CHANNELS; i++) {
1864 channel = &efx->channel[i];
1865 channel->efx = efx;
1866 channel->channel = i;
1867 channel->evqnum = i;
1868 channel->work_pending = 0;
1869 }
1870 for (i = 0; i < EFX_MAX_TX_QUEUES; i++) {
1871 tx_queue = &efx->tx_queue[i];
1872 tx_queue->efx = efx;
1873 tx_queue->queue = i;
1874 tx_queue->buffer = NULL;
1875 tx_queue->channel = &efx->channel[0]; /* for safety */
1876 }
1877 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) {
1878 rx_queue = &efx->rx_queue[i];
1879 rx_queue->efx = efx;
1880 rx_queue->queue = i;
1881 rx_queue->channel = &efx->channel[0]; /* for safety */
1882 rx_queue->buffer = NULL;
1883 spin_lock_init(&rx_queue->add_lock);
1884 INIT_DELAYED_WORK(&rx_queue->work, efx_rx_work);
1885 }
1886
1887 efx->type = type;
1888
1889 /* Sanity-check NIC type */
1890 EFX_BUG_ON_PARANOID(efx->type->txd_ring_mask &
1891 (efx->type->txd_ring_mask + 1));
1892 EFX_BUG_ON_PARANOID(efx->type->rxd_ring_mask &
1893 (efx->type->rxd_ring_mask + 1));
1894 EFX_BUG_ON_PARANOID(efx->type->evq_size &
1895 (efx->type->evq_size - 1));
1896 /* As close as we can get to guaranteeing that we don't overflow */
1897 EFX_BUG_ON_PARANOID(efx->type->evq_size <
1898 (efx->type->txd_ring_mask + 1 +
1899 efx->type->rxd_ring_mask + 1));
1900 EFX_BUG_ON_PARANOID(efx->type->phys_addr_channels > EFX_MAX_CHANNELS);
1901
1902 /* Higher numbered interrupt modes are less capable! */
1903 efx->interrupt_mode = max(efx->type->max_interrupt_mode,
1904 interrupt_mode);
1905
1906 efx->workqueue = create_singlethread_workqueue("sfc_work");
1907 if (!efx->workqueue) {
1908 rc = -ENOMEM;
1909 goto fail1;
1910 }
1911
1912 return 0;
1913
1914 fail1:
1915 return rc;
1916}
1917
1918static void efx_fini_struct(struct efx_nic *efx)
1919{
1920 if (efx->workqueue) {
1921 destroy_workqueue(efx->workqueue);
1922 efx->workqueue = NULL;
1923 }
1924}
1925
1926/**************************************************************************
1927 *
1928 * PCI interface
1929 *
1930 **************************************************************************/
1931
1932/* Main body of final NIC shutdown code
1933 * This is called only at module unload (or hotplug removal).
1934 */
1935static void efx_pci_remove_main(struct efx_nic *efx)
1936{
1937 EFX_ASSERT_RESET_SERIALISED(efx);
1938
1939 /* Skip everything if we never obtained a valid membase */
1940 if (!efx->membase)
1941 return;
1942
1943 efx_fini_channels(efx);
1944 efx_fini_port(efx);
1945
1946 /* Shutdown the board, then the NIC and board state */
1947 falcon_fini_interrupt(efx);
1948
1949 efx_fini_napi(efx);
1950 efx_remove_all(efx);
1951}
1952
1953/* Final NIC shutdown
1954 * This is called only at module unload (or hotplug removal).
1955 */
1956static void efx_pci_remove(struct pci_dev *pci_dev)
1957{
1958 struct efx_nic *efx;
1959
1960 efx = pci_get_drvdata(pci_dev);
1961 if (!efx)
1962 return;
1963
1964 /* Mark the NIC as fini, then stop the interface */
1965 rtnl_lock();
1966 efx->state = STATE_FINI;
1967 dev_close(efx->net_dev);
1968
1969 /* Allow any queued efx_resets() to complete */
1970 rtnl_unlock();
1971
1972 if (efx->membase == NULL)
1973 goto out;
1974
1975 efx_unregister_netdev(efx);
1976
1977 /* Wait for any scheduled resets to complete. No more will be
1978 * scheduled from this point because efx_stop_all() has been
1979 * called, we are no longer registered with driverlink, and
1980 * the net_device's have been removed. */
1981 flush_workqueue(efx->workqueue);
1982
1983 efx_pci_remove_main(efx);
1984
1985out:
1986 efx_fini_io(efx);
1987 EFX_LOG(efx, "shutdown successful\n");
1988
1989 pci_set_drvdata(pci_dev, NULL);
1990 efx_fini_struct(efx);
1991 free_netdev(efx->net_dev);
1992};
1993
1994/* Main body of NIC initialisation
1995 * This is called at module load (or hotplug insertion, theoretically).
1996 */
1997static int efx_pci_probe_main(struct efx_nic *efx)
1998{
1999 int rc;
2000
2001 /* Do start-of-day initialisation */
2002 rc = efx_probe_all(efx);
2003 if (rc)
2004 goto fail1;
2005
2006 rc = efx_init_napi(efx);
2007 if (rc)
2008 goto fail2;
2009
2010 /* Initialise the board */
2011 rc = efx->board_info.init(efx);
2012 if (rc) {
2013 EFX_ERR(efx, "failed to initialise board\n");
2014 goto fail3;
2015 }
2016
2017 rc = falcon_init_nic(efx);
2018 if (rc) {
2019 EFX_ERR(efx, "failed to initialise NIC\n");
2020 goto fail4;
2021 }
2022
2023 rc = efx_init_port(efx);
2024 if (rc) {
2025 EFX_ERR(efx, "failed to initialise port\n");
2026 goto fail5;
2027 }
2028
2029 rc = efx_init_channels(efx);
2030 if (rc)
2031 goto fail6;
2032
2033 rc = falcon_init_interrupt(efx);
2034 if (rc)
2035 goto fail7;
2036
2037 return 0;
2038
2039 fail7:
2040 efx_fini_channels(efx);
2041 fail6:
2042 efx_fini_port(efx);
2043 fail5:
2044 fail4:
2045 fail3:
2046 efx_fini_napi(efx);
2047 fail2:
2048 efx_remove_all(efx);
2049 fail1:
2050 return rc;
2051}
2052
2053/* NIC initialisation
2054 *
2055 * This is called at module load (or hotplug insertion,
2056 * theoretically). It sets up PCI mappings, tests and resets the NIC,
2057 * sets up and registers the network devices with the kernel and hooks
2058 * the interrupt service routine. It does not prepare the device for
2059 * transmission; this is left to the first time one of the network
2060 * interfaces is brought up (i.e. efx_net_open).
2061 */
2062static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2063 const struct pci_device_id *entry)
2064{
2065 struct efx_nic_type *type = (struct efx_nic_type *) entry->driver_data;
2066 struct net_device *net_dev;
2067 struct efx_nic *efx;
2068 int i, rc;
2069
2070 /* Allocate and initialise a struct net_device and struct efx_nic */
2071 net_dev = alloc_etherdev(sizeof(*efx));
2072 if (!net_dev)
2073 return -ENOMEM;
2074 net_dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA;
2075 if (lro)
2076 net_dev->features |= NETIF_F_LRO;
2077 efx = net_dev->priv;
2078 pci_set_drvdata(pci_dev, efx);
2079 rc = efx_init_struct(efx, type, pci_dev, net_dev);
2080 if (rc)
2081 goto fail1;
2082
2083 EFX_INFO(efx, "Solarflare Communications NIC detected\n");
2084
2085 /* Set up basic I/O (BAR mappings etc) */
2086 rc = efx_init_io(efx);
2087 if (rc)
2088 goto fail2;
2089
2090 /* No serialisation is required with the reset path because
2091 * we're in STATE_INIT. */
2092 for (i = 0; i < 5; i++) {
2093 rc = efx_pci_probe_main(efx);
2094 if (rc == 0)
2095 break;
2096
2097 /* Serialise against efx_reset(). No more resets will be
2098 * scheduled since efx_stop_all() has been called, and we
2099 * have not and never have been registered with either
2100 * the rtnetlink or driverlink layers. */
2101 cancel_work_sync(&efx->reset_work);
2102
2103 /* Retry if a recoverably reset event has been scheduled */
2104 if ((efx->reset_pending != RESET_TYPE_INVISIBLE) &&
2105 (efx->reset_pending != RESET_TYPE_ALL))
2106 goto fail3;
2107
2108 efx->reset_pending = RESET_TYPE_NONE;
2109 }
2110
2111 if (rc) {
2112 EFX_ERR(efx, "Could not reset NIC\n");
2113 goto fail4;
2114 }
2115
2116 /* Switch to the running state before we expose the device to
2117 * the OS. This is to ensure that the initial gathering of
2118 * MAC stats succeeds. */
2119 rtnl_lock();
2120 efx->state = STATE_RUNNING;
2121 rtnl_unlock();
2122
2123 rc = efx_register_netdev(efx);
2124 if (rc)
2125 goto fail5;
2126
2127 EFX_LOG(efx, "initialisation successful\n");
2128
2129 return 0;
2130
2131 fail5:
2132 efx_pci_remove_main(efx);
2133 fail4:
2134 fail3:
2135 efx_fini_io(efx);
2136 fail2:
2137 efx_fini_struct(efx);
2138 fail1:
2139 EFX_LOG(efx, "initialisation failed. rc=%d\n", rc);
2140 free_netdev(net_dev);
2141 return rc;
2142}
2143
2144static struct pci_driver efx_pci_driver = {
2145 .name = EFX_DRIVER_NAME,
2146 .id_table = efx_pci_table,
2147 .probe = efx_pci_probe,
2148 .remove = efx_pci_remove,
2149};
2150
2151/**************************************************************************
2152 *
2153 * Kernel module interface
2154 *
2155 *************************************************************************/
2156
2157module_param(interrupt_mode, uint, 0444);
2158MODULE_PARM_DESC(interrupt_mode,
2159 "Interrupt mode (0=>MSIX 1=>MSI 2=>legacy)");
2160
2161static int __init efx_init_module(void)
2162{
2163 int rc;
2164
2165 printk(KERN_INFO "Solarflare NET driver v" EFX_DRIVER_VERSION "\n");
2166
2167 rc = register_netdevice_notifier(&efx_netdev_notifier);
2168 if (rc)
2169 goto err_notifier;
2170
2171 refill_workqueue = create_workqueue("sfc_refill");
2172 if (!refill_workqueue) {
2173 rc = -ENOMEM;
2174 goto err_refill;
2175 }
2176
2177 rc = pci_register_driver(&efx_pci_driver);
2178 if (rc < 0)
2179 goto err_pci;
2180
2181 return 0;
2182
2183 err_pci:
2184 destroy_workqueue(refill_workqueue);
2185 err_refill:
2186 unregister_netdevice_notifier(&efx_netdev_notifier);
2187 err_notifier:
2188 return rc;
2189}
2190
2191static void __exit efx_exit_module(void)
2192{
2193 printk(KERN_INFO "Solarflare NET driver unloading\n");
2194
2195 pci_unregister_driver(&efx_pci_driver);
2196 destroy_workqueue(refill_workqueue);
2197 unregister_netdevice_notifier(&efx_netdev_notifier);
2198
2199}
2200
2201module_init(efx_init_module);
2202module_exit(efx_exit_module);
2203
2204MODULE_AUTHOR("Michael Brown <mbrown@fensystems.co.uk> and "
2205 "Solarflare Communications");
2206MODULE_DESCRIPTION("Solarflare Communications network driver");
2207MODULE_LICENSE("GPL");
2208MODULE_DEVICE_TABLE(pci, efx_pci_table);
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
new file mode 100644
index 000000000000..3b2f69f4a9ab
--- /dev/null
+++ b/drivers/net/sfc/efx.h
@@ -0,0 +1,67 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_EFX_H
12#define EFX_EFX_H
13
14#include "net_driver.h"
15
16/* PCI IDs */
17#define EFX_VENDID_SFC 0x1924
18#define FALCON_A_P_DEVID 0x0703
19#define FALCON_A_S_DEVID 0x6703
20#define FALCON_B_P_DEVID 0x0710
21
22/* TX */
23extern int efx_xmit(struct efx_nic *efx,
24 struct efx_tx_queue *tx_queue, struct sk_buff *skb);
25extern void efx_stop_queue(struct efx_nic *efx);
26extern void efx_wake_queue(struct efx_nic *efx);
27
28/* RX */
29extern void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index);
30extern void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
31 unsigned int len, int checksummed, int discard);
32extern void efx_schedule_slow_fill(struct efx_rx_queue *rx_queue, int delay);
33
34/* Channels */
35extern void efx_process_channel_now(struct efx_channel *channel);
36extern int efx_flush_queues(struct efx_nic *efx);
37
38/* Ports */
39extern void efx_reconfigure_port(struct efx_nic *efx);
40
41/* Global */
42extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
43extern void efx_suspend(struct efx_nic *efx);
44extern void efx_resume(struct efx_nic *efx);
45extern void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs,
46 int rx_usecs);
47extern int efx_request_power(struct efx_nic *efx, int mw, const char *name);
48extern void efx_hex_dump(const u8 *, unsigned int, const char *);
49
50/* Dummy PHY ops for PHY drivers */
51extern int efx_port_dummy_op_int(struct efx_nic *efx);
52extern void efx_port_dummy_op_void(struct efx_nic *efx);
53extern void efx_port_dummy_op_blink(struct efx_nic *efx, int blink);
54
55
56extern unsigned int efx_monitor_interval;
57
58static inline void efx_schedule_channel(struct efx_channel *channel)
59{
60 EFX_TRACE(channel->efx, "channel %d scheduling NAPI poll on CPU%d\n",
61 channel->channel, raw_smp_processor_id());
62 channel->work_pending = 1;
63
64 netif_rx_schedule(channel->napi_dev, &channel->napi_str);
65}
66
67#endif /* EFX_EFX_H */
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h
new file mode 100644
index 000000000000..43663a4619da
--- /dev/null
+++ b/drivers/net/sfc/enum.h
@@ -0,0 +1,50 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_ENUM_H
11#define EFX_ENUM_H
12
13/*****************************************************************************/
14
15/**
16 * enum reset_type - reset types
17 *
18 * %RESET_TYPE_INVSIBLE, %RESET_TYPE_ALL, %RESET_TYPE_WORLD and
19 * %RESET_TYPE_DISABLE specify the method/scope of the reset. The
20 * other valuesspecify reasons, which efx_schedule_reset() will choose
21 * a method for.
22 *
23 * @RESET_TYPE_INVISIBLE: don't reset the PHYs or interrupts
24 * @RESET_TYPE_ALL: reset everything but PCI core blocks
25 * @RESET_TYPE_WORLD: reset everything, save & restore PCI config
26 * @RESET_TYPE_DISABLE: disable NIC
27 * @RESET_TYPE_MONITOR: reset due to hardware monitor
28 * @RESET_TYPE_INT_ERROR: reset due to internal error
29 * @RESET_TYPE_RX_RECOVERY: reset to recover from RX datapath errors
30 * @RESET_TYPE_RX_DESC_FETCH: pcie error during rx descriptor fetch
31 * @RESET_TYPE_TX_DESC_FETCH: pcie error during tx descriptor fetch
32 * @RESET_TYPE_TX_SKIP: hardware completed empty tx descriptors
33 */
34enum reset_type {
35 RESET_TYPE_NONE = -1,
36 RESET_TYPE_INVISIBLE = 0,
37 RESET_TYPE_ALL = 1,
38 RESET_TYPE_WORLD = 2,
39 RESET_TYPE_DISABLE = 3,
40 RESET_TYPE_MAX_METHOD,
41 RESET_TYPE_MONITOR,
42 RESET_TYPE_INT_ERROR,
43 RESET_TYPE_RX_RECOVERY,
44 RESET_TYPE_RX_DESC_FETCH,
45 RESET_TYPE_TX_DESC_FETCH,
46 RESET_TYPE_TX_SKIP,
47 RESET_TYPE_MAX,
48};
49
50#endif /* EFX_ENUM_H */
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
new file mode 100644
index 000000000000..ad541badbd98
--- /dev/null
+++ b/drivers/net/sfc/ethtool.c
@@ -0,0 +1,460 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/netdevice.h>
12#include <linux/ethtool.h>
13#include <linux/rtnetlink.h>
14#include "net_driver.h"
15#include "efx.h"
16#include "ethtool.h"
17#include "falcon.h"
18#include "gmii.h"
19#include "mac.h"
20
21static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable);
22
23struct ethtool_string {
24 char name[ETH_GSTRING_LEN];
25};
26
27struct efx_ethtool_stat {
28 const char *name;
29 enum {
30 EFX_ETHTOOL_STAT_SOURCE_mac_stats,
31 EFX_ETHTOOL_STAT_SOURCE_nic,
32 EFX_ETHTOOL_STAT_SOURCE_channel
33 } source;
34 unsigned offset;
35 u64(*get_stat) (void *field); /* Reader function */
36};
37
38/* Initialiser for a struct #efx_ethtool_stat with type-checking */
39#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
40 get_stat_function) { \
41 .name = #stat_name, \
42 .source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
43 .offset = ((((field_type *) 0) == \
44 &((struct efx_##source_name *)0)->field) ? \
45 offsetof(struct efx_##source_name, field) : \
46 offsetof(struct efx_##source_name, field)), \
47 .get_stat = get_stat_function, \
48}
49
50static u64 efx_get_uint_stat(void *field)
51{
52 return *(unsigned int *)field;
53}
54
55static u64 efx_get_ulong_stat(void *field)
56{
57 return *(unsigned long *)field;
58}
59
60static u64 efx_get_u64_stat(void *field)
61{
62 return *(u64 *) field;
63}
64
65static u64 efx_get_atomic_stat(void *field)
66{
67 return atomic_read((atomic_t *) field);
68}
69
70#define EFX_ETHTOOL_ULONG_MAC_STAT(field) \
71 EFX_ETHTOOL_STAT(field, mac_stats, field, \
72 unsigned long, efx_get_ulong_stat)
73
74#define EFX_ETHTOOL_U64_MAC_STAT(field) \
75 EFX_ETHTOOL_STAT(field, mac_stats, field, \
76 u64, efx_get_u64_stat)
77
78#define EFX_ETHTOOL_UINT_NIC_STAT(name) \
79 EFX_ETHTOOL_STAT(name, nic, n_##name, \
80 unsigned int, efx_get_uint_stat)
81
82#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
83 EFX_ETHTOOL_STAT(field, nic, field, \
84 atomic_t, efx_get_atomic_stat)
85
86#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
87 EFX_ETHTOOL_STAT(field, channel, n_##field, \
88 unsigned int, efx_get_uint_stat)
89
90static struct efx_ethtool_stat efx_ethtool_stats[] = {
91 EFX_ETHTOOL_U64_MAC_STAT(tx_bytes),
92 EFX_ETHTOOL_U64_MAC_STAT(tx_good_bytes),
93 EFX_ETHTOOL_U64_MAC_STAT(tx_bad_bytes),
94 EFX_ETHTOOL_ULONG_MAC_STAT(tx_packets),
95 EFX_ETHTOOL_ULONG_MAC_STAT(tx_bad),
96 EFX_ETHTOOL_ULONG_MAC_STAT(tx_pause),
97 EFX_ETHTOOL_ULONG_MAC_STAT(tx_control),
98 EFX_ETHTOOL_ULONG_MAC_STAT(tx_unicast),
99 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multicast),
100 EFX_ETHTOOL_ULONG_MAC_STAT(tx_broadcast),
101 EFX_ETHTOOL_ULONG_MAC_STAT(tx_lt64),
102 EFX_ETHTOOL_ULONG_MAC_STAT(tx_64),
103 EFX_ETHTOOL_ULONG_MAC_STAT(tx_65_to_127),
104 EFX_ETHTOOL_ULONG_MAC_STAT(tx_128_to_255),
105 EFX_ETHTOOL_ULONG_MAC_STAT(tx_256_to_511),
106 EFX_ETHTOOL_ULONG_MAC_STAT(tx_512_to_1023),
107 EFX_ETHTOOL_ULONG_MAC_STAT(tx_1024_to_15xx),
108 EFX_ETHTOOL_ULONG_MAC_STAT(tx_15xx_to_jumbo),
109 EFX_ETHTOOL_ULONG_MAC_STAT(tx_gtjumbo),
110 EFX_ETHTOOL_ULONG_MAC_STAT(tx_collision),
111 EFX_ETHTOOL_ULONG_MAC_STAT(tx_single_collision),
112 EFX_ETHTOOL_ULONG_MAC_STAT(tx_multiple_collision),
113 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_collision),
114 EFX_ETHTOOL_ULONG_MAC_STAT(tx_deferred),
115 EFX_ETHTOOL_ULONG_MAC_STAT(tx_late_collision),
116 EFX_ETHTOOL_ULONG_MAC_STAT(tx_excessive_deferred),
117 EFX_ETHTOOL_ULONG_MAC_STAT(tx_non_tcpudp),
118 EFX_ETHTOOL_ULONG_MAC_STAT(tx_mac_src_error),
119 EFX_ETHTOOL_ULONG_MAC_STAT(tx_ip_src_error),
120 EFX_ETHTOOL_U64_MAC_STAT(rx_bytes),
121 EFX_ETHTOOL_U64_MAC_STAT(rx_good_bytes),
122 EFX_ETHTOOL_U64_MAC_STAT(rx_bad_bytes),
123 EFX_ETHTOOL_ULONG_MAC_STAT(rx_packets),
124 EFX_ETHTOOL_ULONG_MAC_STAT(rx_good),
125 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad),
126 EFX_ETHTOOL_ULONG_MAC_STAT(rx_pause),
127 EFX_ETHTOOL_ULONG_MAC_STAT(rx_control),
128 EFX_ETHTOOL_ULONG_MAC_STAT(rx_unicast),
129 EFX_ETHTOOL_ULONG_MAC_STAT(rx_multicast),
130 EFX_ETHTOOL_ULONG_MAC_STAT(rx_broadcast),
131 EFX_ETHTOOL_ULONG_MAC_STAT(rx_lt64),
132 EFX_ETHTOOL_ULONG_MAC_STAT(rx_64),
133 EFX_ETHTOOL_ULONG_MAC_STAT(rx_65_to_127),
134 EFX_ETHTOOL_ULONG_MAC_STAT(rx_128_to_255),
135 EFX_ETHTOOL_ULONG_MAC_STAT(rx_256_to_511),
136 EFX_ETHTOOL_ULONG_MAC_STAT(rx_512_to_1023),
137 EFX_ETHTOOL_ULONG_MAC_STAT(rx_1024_to_15xx),
138 EFX_ETHTOOL_ULONG_MAC_STAT(rx_15xx_to_jumbo),
139 EFX_ETHTOOL_ULONG_MAC_STAT(rx_gtjumbo),
140 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_lt64),
141 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_64_to_15xx),
142 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_15xx_to_jumbo),
143 EFX_ETHTOOL_ULONG_MAC_STAT(rx_bad_gtjumbo),
144 EFX_ETHTOOL_ULONG_MAC_STAT(rx_overflow),
145 EFX_ETHTOOL_ULONG_MAC_STAT(rx_missed),
146 EFX_ETHTOOL_ULONG_MAC_STAT(rx_false_carrier),
147 EFX_ETHTOOL_ULONG_MAC_STAT(rx_symbol_error),
148 EFX_ETHTOOL_ULONG_MAC_STAT(rx_align_error),
149 EFX_ETHTOOL_ULONG_MAC_STAT(rx_length_error),
150 EFX_ETHTOOL_ULONG_MAC_STAT(rx_internal_error),
151 EFX_ETHTOOL_UINT_NIC_STAT(rx_nodesc_drop_cnt),
152 EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
153 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tobe_disc),
154 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
155 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
156 EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
157};
158
159/* Number of ethtool statistics */
160#define EFX_ETHTOOL_NUM_STATS ARRAY_SIZE(efx_ethtool_stats)
161
162/**************************************************************************
163 *
164 * Ethtool operations
165 *
166 **************************************************************************
167 */
168
169/* Identify device by flashing LEDs */
170static int efx_ethtool_phys_id(struct net_device *net_dev, u32 seconds)
171{
172 struct efx_nic *efx = net_dev->priv;
173
174 efx->board_info.blink(efx, 1);
175 schedule_timeout_interruptible(seconds * HZ);
176 efx->board_info.blink(efx, 0);
177 return 0;
178}
179
180/* This must be called with rtnl_lock held. */
181int efx_ethtool_get_settings(struct net_device *net_dev,
182 struct ethtool_cmd *ecmd)
183{
184 struct efx_nic *efx = net_dev->priv;
185 int rc;
186
187 mutex_lock(&efx->mac_lock);
188 rc = falcon_xmac_get_settings(efx, ecmd);
189 mutex_unlock(&efx->mac_lock);
190
191 return rc;
192}
193
194/* This must be called with rtnl_lock held. */
195int efx_ethtool_set_settings(struct net_device *net_dev,
196 struct ethtool_cmd *ecmd)
197{
198 struct efx_nic *efx = net_dev->priv;
199 int rc;
200
201 mutex_lock(&efx->mac_lock);
202 rc = falcon_xmac_set_settings(efx, ecmd);
203 mutex_unlock(&efx->mac_lock);
204 if (!rc)
205 efx_reconfigure_port(efx);
206
207 return rc;
208}
209
210static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
211 struct ethtool_drvinfo *info)
212{
213 struct efx_nic *efx = net_dev->priv;
214
215 strlcpy(info->driver, EFX_DRIVER_NAME, sizeof(info->driver));
216 strlcpy(info->version, EFX_DRIVER_VERSION, sizeof(info->version));
217 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
218}
219
220static int efx_ethtool_get_stats_count(struct net_device *net_dev)
221{
222 return EFX_ETHTOOL_NUM_STATS;
223}
224
225static void efx_ethtool_get_strings(struct net_device *net_dev,
226 u32 string_set, u8 *strings)
227{
228 struct ethtool_string *ethtool_strings =
229 (struct ethtool_string *)strings;
230 int i;
231
232 if (string_set == ETH_SS_STATS)
233 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
234 strncpy(ethtool_strings[i].name,
235 efx_ethtool_stats[i].name,
236 sizeof(ethtool_strings[i].name));
237}
238
239static void efx_ethtool_get_stats(struct net_device *net_dev,
240 struct ethtool_stats *stats,
241 u64 *data)
242{
243 struct efx_nic *efx = net_dev->priv;
244 struct efx_mac_stats *mac_stats = &efx->mac_stats;
245 struct efx_ethtool_stat *stat;
246 struct efx_channel *channel;
247 int i;
248
249 EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
250
251 /* Update MAC and NIC statistics */
252 net_dev->get_stats(net_dev);
253
254 /* Fill detailed statistics buffer */
255 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
256 stat = &efx_ethtool_stats[i];
257 switch (stat->source) {
258 case EFX_ETHTOOL_STAT_SOURCE_mac_stats:
259 data[i] = stat->get_stat((void *)mac_stats +
260 stat->offset);
261 break;
262 case EFX_ETHTOOL_STAT_SOURCE_nic:
263 data[i] = stat->get_stat((void *)efx + stat->offset);
264 break;
265 case EFX_ETHTOOL_STAT_SOURCE_channel:
266 data[i] = 0;
267 efx_for_each_channel(channel, efx)
268 data[i] += stat->get_stat((void *)channel +
269 stat->offset);
270 break;
271 }
272 }
273}
274
275static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
276{
277 struct efx_nic *efx = net_dev->priv;
278 int rc;
279
280 rc = ethtool_op_set_tx_csum(net_dev, enable);
281 if (rc)
282 return rc;
283
284 efx_flush_queues(efx);
285
286 return 0;
287}
288
289static int efx_ethtool_set_rx_csum(struct net_device *net_dev, u32 enable)
290{
291 struct efx_nic *efx = net_dev->priv;
292
293 /* No way to stop the hardware doing the checks; we just
294 * ignore the result.
295 */
296 efx->rx_checksum_enabled = (enable ? 1 : 0);
297
298 return 0;
299}
300
301static u32 efx_ethtool_get_rx_csum(struct net_device *net_dev)
302{
303 struct efx_nic *efx = net_dev->priv;
304
305 return efx->rx_checksum_enabled;
306}
307
308/* Restart autonegotiation */
309static int efx_ethtool_nway_reset(struct net_device *net_dev)
310{
311 struct efx_nic *efx = net_dev->priv;
312
313 return mii_nway_restart(&efx->mii);
314}
315
316static u32 efx_ethtool_get_link(struct net_device *net_dev)
317{
318 struct efx_nic *efx = net_dev->priv;
319
320 return efx->link_up;
321}
322
323static int efx_ethtool_get_coalesce(struct net_device *net_dev,
324 struct ethtool_coalesce *coalesce)
325{
326 struct efx_nic *efx = net_dev->priv;
327 struct efx_tx_queue *tx_queue;
328 struct efx_rx_queue *rx_queue;
329 struct efx_channel *channel;
330
331 memset(coalesce, 0, sizeof(*coalesce));
332
333 /* Find lowest IRQ moderation across all used TX queues */
334 coalesce->tx_coalesce_usecs_irq = ~((u32) 0);
335 efx_for_each_tx_queue(tx_queue, efx) {
336 channel = tx_queue->channel;
337 if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) {
338 if (channel->used_flags != EFX_USED_BY_RX_TX)
339 coalesce->tx_coalesce_usecs_irq =
340 channel->irq_moderation;
341 else
342 coalesce->tx_coalesce_usecs_irq = 0;
343 }
344 }
345
346 /* Find lowest IRQ moderation across all used RX queues */
347 coalesce->rx_coalesce_usecs_irq = ~((u32) 0);
348 efx_for_each_rx_queue(rx_queue, efx) {
349 channel = rx_queue->channel;
350 if (channel->irq_moderation < coalesce->rx_coalesce_usecs_irq)
351 coalesce->rx_coalesce_usecs_irq =
352 channel->irq_moderation;
353 }
354
355 return 0;
356}
357
358/* Set coalescing parameters
359 * The difficulties occur for shared channels
360 */
361static int efx_ethtool_set_coalesce(struct net_device *net_dev,
362 struct ethtool_coalesce *coalesce)
363{
364 struct efx_nic *efx = net_dev->priv;
365 struct efx_channel *channel;
366 struct efx_tx_queue *tx_queue;
367 unsigned tx_usecs, rx_usecs;
368
369 if (coalesce->use_adaptive_rx_coalesce ||
370 coalesce->use_adaptive_tx_coalesce)
371 return -EOPNOTSUPP;
372
373 if (coalesce->rx_coalesce_usecs || coalesce->tx_coalesce_usecs) {
374 EFX_ERR(efx, "invalid coalescing setting. "
375 "Only rx/tx_coalesce_usecs_irq are supported\n");
376 return -EOPNOTSUPP;
377 }
378
379 rx_usecs = coalesce->rx_coalesce_usecs_irq;
380 tx_usecs = coalesce->tx_coalesce_usecs_irq;
381
382 /* If the channel is shared only allow RX parameters to be set */
383 efx_for_each_tx_queue(tx_queue, efx) {
384 if ((tx_queue->channel->used_flags == EFX_USED_BY_RX_TX) &&
385 tx_usecs) {
386 EFX_ERR(efx, "Channel is shared. "
387 "Only RX coalescing may be set\n");
388 return -EOPNOTSUPP;
389 }
390 }
391
392 efx_init_irq_moderation(efx, tx_usecs, rx_usecs);
393
394 /* Reset channel to pick up new moderation value. Note that
395 * this may change the value of the irq_moderation field
396 * (e.g. to allow for hardware timer granularity).
397 */
398 efx_for_each_channel(channel, efx)
399 falcon_set_int_moderation(channel);
400
401 return 0;
402}
403
404static int efx_ethtool_set_pauseparam(struct net_device *net_dev,
405 struct ethtool_pauseparam *pause)
406{
407 struct efx_nic *efx = net_dev->priv;
408 enum efx_fc_type flow_control = efx->flow_control;
409 int rc;
410
411 flow_control &= ~(EFX_FC_RX | EFX_FC_TX | EFX_FC_AUTO);
412 flow_control |= pause->rx_pause ? EFX_FC_RX : 0;
413 flow_control |= pause->tx_pause ? EFX_FC_TX : 0;
414 flow_control |= pause->autoneg ? EFX_FC_AUTO : 0;
415
416 /* Try to push the pause parameters */
417 mutex_lock(&efx->mac_lock);
418 rc = falcon_xmac_set_pause(efx, flow_control);
419 mutex_unlock(&efx->mac_lock);
420
421 if (!rc)
422 efx_reconfigure_port(efx);
423
424 return rc;
425}
426
427static void efx_ethtool_get_pauseparam(struct net_device *net_dev,
428 struct ethtool_pauseparam *pause)
429{
430 struct efx_nic *efx = net_dev->priv;
431
432 pause->rx_pause = (efx->flow_control & EFX_FC_RX) ? 1 : 0;
433 pause->tx_pause = (efx->flow_control & EFX_FC_TX) ? 1 : 0;
434 pause->autoneg = (efx->flow_control & EFX_FC_AUTO) ? 1 : 0;
435}
436
437
438struct ethtool_ops efx_ethtool_ops = {
439 .get_settings = efx_ethtool_get_settings,
440 .set_settings = efx_ethtool_set_settings,
441 .get_drvinfo = efx_ethtool_get_drvinfo,
442 .nway_reset = efx_ethtool_nway_reset,
443 .get_link = efx_ethtool_get_link,
444 .get_coalesce = efx_ethtool_get_coalesce,
445 .set_coalesce = efx_ethtool_set_coalesce,
446 .get_pauseparam = efx_ethtool_get_pauseparam,
447 .set_pauseparam = efx_ethtool_set_pauseparam,
448 .get_rx_csum = efx_ethtool_get_rx_csum,
449 .set_rx_csum = efx_ethtool_set_rx_csum,
450 .get_tx_csum = ethtool_op_get_tx_csum,
451 .set_tx_csum = efx_ethtool_set_tx_csum,
452 .get_sg = ethtool_op_get_sg,
453 .set_sg = ethtool_op_set_sg,
454 .get_flags = ethtool_op_get_flags,
455 .set_flags = ethtool_op_set_flags,
456 .get_strings = efx_ethtool_get_strings,
457 .phys_id = efx_ethtool_phys_id,
458 .get_stats_count = efx_ethtool_get_stats_count,
459 .get_ethtool_stats = efx_ethtool_get_stats,
460};
diff --git a/drivers/net/sfc/ethtool.h b/drivers/net/sfc/ethtool.h
new file mode 100644
index 000000000000..3628e43df14d
--- /dev/null
+++ b/drivers/net/sfc/ethtool.h
@@ -0,0 +1,27 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005 Fen Systems Ltd.
4 * Copyright 2006 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_ETHTOOL_H
12#define EFX_ETHTOOL_H
13
14#include "net_driver.h"
15
16/*
17 * Ethtool support
18 */
19
20extern int efx_ethtool_get_settings(struct net_device *net_dev,
21 struct ethtool_cmd *ecmd);
22extern int efx_ethtool_set_settings(struct net_device *net_dev,
23 struct ethtool_cmd *ecmd);
24
25extern struct ethtool_ops efx_ethtool_ops;
26
27#endif /* EFX_ETHTOOL_H */
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
new file mode 100644
index 000000000000..46db549ce580
--- /dev/null
+++ b/drivers/net/sfc/falcon.c
@@ -0,0 +1,2722 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/bitops.h>
12#include <linux/delay.h>
13#include <linux/pci.h>
14#include <linux/module.h>
15#include <linux/seq_file.h>
16#include "net_driver.h"
17#include "bitfield.h"
18#include "efx.h"
19#include "mac.h"
20#include "gmii.h"
21#include "spi.h"
22#include "falcon.h"
23#include "falcon_hwdefs.h"
24#include "falcon_io.h"
25#include "mdio_10g.h"
26#include "phy.h"
27#include "boards.h"
28#include "workarounds.h"
29
30/* Falcon hardware control.
31 * Falcon is the internal codename for the SFC4000 controller that is
32 * present in SFE400X evaluation boards
33 */
34
35/**
36 * struct falcon_nic_data - Falcon NIC state
37 * @next_buffer_table: First available buffer table id
38 * @pci_dev2: The secondary PCI device if present
39 */
40struct falcon_nic_data {
41 unsigned next_buffer_table;
42 struct pci_dev *pci_dev2;
43};
44
45/**************************************************************************
46 *
47 * Configurable values
48 *
49 **************************************************************************
50 */
51
52static int disable_dma_stats;
53
54/* This is set to 16 for a good reason. In summary, if larger than
55 * 16, the descriptor cache holds more than a default socket
56 * buffer's worth of packets (for UDP we can only have at most one
57 * socket buffer's worth outstanding). This combined with the fact
58 * that we only get 1 TX event per descriptor cache means the NIC
59 * goes idle.
60 */
61#define TX_DC_ENTRIES 16
62#define TX_DC_ENTRIES_ORDER 0
63#define TX_DC_BASE 0x130000
64
65#define RX_DC_ENTRIES 64
66#define RX_DC_ENTRIES_ORDER 2
67#define RX_DC_BASE 0x100000
68
69/* RX FIFO XOFF watermark
70 *
71 * When the amount of the RX FIFO increases used increases past this
72 * watermark send XOFF. Only used if RX flow control is enabled (ethtool -A)
73 * This also has an effect on RX/TX arbitration
74 */
75static int rx_xoff_thresh_bytes = -1;
76module_param(rx_xoff_thresh_bytes, int, 0644);
77MODULE_PARM_DESC(rx_xoff_thresh_bytes, "RX fifo XOFF threshold");
78
79/* RX FIFO XON watermark
80 *
81 * When the amount of the RX FIFO used decreases below this
82 * watermark send XON. Only used if TX flow control is enabled (ethtool -A)
83 * This also has an effect on RX/TX arbitration
84 */
85static int rx_xon_thresh_bytes = -1;
86module_param(rx_xon_thresh_bytes, int, 0644);
87MODULE_PARM_DESC(rx_xon_thresh_bytes, "RX fifo XON threshold");
88
89/* TX descriptor ring size - min 512 max 4k */
90#define FALCON_TXD_RING_ORDER TX_DESCQ_SIZE_1K
91#define FALCON_TXD_RING_SIZE 1024
92#define FALCON_TXD_RING_MASK (FALCON_TXD_RING_SIZE - 1)
93
94/* RX descriptor ring size - min 512 max 4k */
95#define FALCON_RXD_RING_ORDER RX_DESCQ_SIZE_1K
96#define FALCON_RXD_RING_SIZE 1024
97#define FALCON_RXD_RING_MASK (FALCON_RXD_RING_SIZE - 1)
98
99/* Event queue size - max 32k */
100#define FALCON_EVQ_ORDER EVQ_SIZE_4K
101#define FALCON_EVQ_SIZE 4096
102#define FALCON_EVQ_MASK (FALCON_EVQ_SIZE - 1)
103
104/* Max number of internal errors. After this resets will not be performed */
105#define FALCON_MAX_INT_ERRORS 4
106
107/* Maximum period that we wait for flush events. If the flush event
108 * doesn't arrive in this period of time then we check if the queue
109 * was disabled anyway. */
110#define FALCON_FLUSH_TIMEOUT 10 /* 10ms */
111
112/**************************************************************************
113 *
114 * Falcon constants
115 *
116 **************************************************************************
117 */
118
119/* DMA address mask (up to 46-bit, avoiding compiler warnings)
120 *
121 * Note that it is possible to have a platform with 64-bit longs and
122 * 32-bit DMA addresses, or vice versa. EFX_DMA_MASK takes care of the
123 * platform DMA mask.
124 */
125#if BITS_PER_LONG == 64
126#define FALCON_DMA_MASK EFX_DMA_MASK(0x00003fffffffffffUL)
127#else
128#define FALCON_DMA_MASK EFX_DMA_MASK(0x00003fffffffffffULL)
129#endif
130
131/* TX DMA length mask (13-bit) */
132#define FALCON_TX_DMA_MASK (4096 - 1)
133
134/* Size and alignment of special buffers (4KB) */
135#define FALCON_BUF_SIZE 4096
136
137/* Dummy SRAM size code */
138#define SRM_NB_BSZ_ONCHIP_ONLY (-1)
139
140/* Be nice if these (or equiv.) were in linux/pci_regs.h, but they're not. */
141#define PCI_EXP_DEVCAP_PWR_VAL_LBN 18
142#define PCI_EXP_DEVCAP_PWR_SCL_LBN 26
143#define PCI_EXP_DEVCTL_PAYLOAD_LBN 5
144#define PCI_EXP_LNKSTA_LNK_WID 0x3f0
145#define PCI_EXP_LNKSTA_LNK_WID_LBN 4
146
147#define FALCON_IS_DUAL_FUNC(efx) \
148 (FALCON_REV(efx) < FALCON_REV_B0)
149
150/**************************************************************************
151 *
152 * Falcon hardware access
153 *
154 **************************************************************************/
155
156/* Read the current event from the event queue */
157static inline efx_qword_t *falcon_event(struct efx_channel *channel,
158 unsigned int index)
159{
160 return (((efx_qword_t *) (channel->eventq.addr)) + index);
161}
162
163/* See if an event is present
164 *
165 * We check both the high and low dword of the event for all ones. We
166 * wrote all ones when we cleared the event, and no valid event can
167 * have all ones in either its high or low dwords. This approach is
168 * robust against reordering.
169 *
170 * Note that using a single 64-bit comparison is incorrect; even
171 * though the CPU read will be atomic, the DMA write may not be.
172 */
173static inline int falcon_event_present(efx_qword_t *event)
174{
175 return (!(EFX_DWORD_IS_ALL_ONES(event->dword[0]) |
176 EFX_DWORD_IS_ALL_ONES(event->dword[1])));
177}
178
179/**************************************************************************
180 *
181 * I2C bus - this is a bit-bashing interface using GPIO pins
182 * Note that it uses the output enables to tristate the outputs
183 * SDA is the data pin and SCL is the clock
184 *
185 **************************************************************************
186 */
187static void falcon_setsdascl(struct efx_i2c_interface *i2c)
188{
189 efx_oword_t reg;
190
191 falcon_read(i2c->efx, &reg, GPIO_CTL_REG_KER);
192 EFX_SET_OWORD_FIELD(reg, GPIO0_OEN, (i2c->scl ? 0 : 1));
193 EFX_SET_OWORD_FIELD(reg, GPIO3_OEN, (i2c->sda ? 0 : 1));
194 falcon_write(i2c->efx, &reg, GPIO_CTL_REG_KER);
195}
196
197static int falcon_getsda(struct efx_i2c_interface *i2c)
198{
199 efx_oword_t reg;
200
201 falcon_read(i2c->efx, &reg, GPIO_CTL_REG_KER);
202 return EFX_OWORD_FIELD(reg, GPIO3_IN);
203}
204
205static int falcon_getscl(struct efx_i2c_interface *i2c)
206{
207 efx_oword_t reg;
208
209 falcon_read(i2c->efx, &reg, GPIO_CTL_REG_KER);
210 return EFX_DWORD_FIELD(reg, GPIO0_IN);
211}
212
213static struct efx_i2c_bit_operations falcon_i2c_bit_operations = {
214 .setsda = falcon_setsdascl,
215 .setscl = falcon_setsdascl,
216 .getsda = falcon_getsda,
217 .getscl = falcon_getscl,
218 .udelay = 100,
219 .mdelay = 10,
220};
221
222/**************************************************************************
223 *
224 * Falcon special buffer handling
225 * Special buffers are used for event queues and the TX and RX
226 * descriptor rings.
227 *
228 *************************************************************************/
229
230/*
231 * Initialise a Falcon special buffer
232 *
233 * This will define a buffer (previously allocated via
234 * falcon_alloc_special_buffer()) in Falcon's buffer table, allowing
235 * it to be used for event queues, descriptor rings etc.
236 */
237static int
238falcon_init_special_buffer(struct efx_nic *efx,
239 struct efx_special_buffer *buffer)
240{
241 efx_qword_t buf_desc;
242 int index;
243 dma_addr_t dma_addr;
244 int i;
245
246 EFX_BUG_ON_PARANOID(!buffer->addr);
247
248 /* Write buffer descriptors to NIC */
249 for (i = 0; i < buffer->entries; i++) {
250 index = buffer->index + i;
251 dma_addr = buffer->dma_addr + (i * 4096);
252 EFX_LOG(efx, "mapping special buffer %d at %llx\n",
253 index, (unsigned long long)dma_addr);
254 EFX_POPULATE_QWORD_4(buf_desc,
255 IP_DAT_BUF_SIZE, IP_DAT_BUF_SIZE_4K,
256 BUF_ADR_REGION, 0,
257 BUF_ADR_FBUF, (dma_addr >> 12),
258 BUF_OWNER_ID_FBUF, 0);
259 falcon_write_sram(efx, &buf_desc, index);
260 }
261
262 return 0;
263}
264
265/* Unmaps a buffer from Falcon and clears the buffer table entries */
266static void
267falcon_fini_special_buffer(struct efx_nic *efx,
268 struct efx_special_buffer *buffer)
269{
270 efx_oword_t buf_tbl_upd;
271 unsigned int start = buffer->index;
272 unsigned int end = (buffer->index + buffer->entries - 1);
273
274 if (!buffer->entries)
275 return;
276
277 EFX_LOG(efx, "unmapping special buffers %d-%d\n",
278 buffer->index, buffer->index + buffer->entries - 1);
279
280 EFX_POPULATE_OWORD_4(buf_tbl_upd,
281 BUF_UPD_CMD, 0,
282 BUF_CLR_CMD, 1,
283 BUF_CLR_END_ID, end,
284 BUF_CLR_START_ID, start);
285 falcon_write(efx, &buf_tbl_upd, BUF_TBL_UPD_REG_KER);
286}
287
288/*
289 * Allocate a new Falcon special buffer
290 *
291 * This allocates memory for a new buffer, clears it and allocates a
292 * new buffer ID range. It does not write into Falcon's buffer table.
293 *
294 * This call will allocate 4KB buffers, since Falcon can't use 8KB
295 * buffers for event queues and descriptor rings.
296 */
297static int falcon_alloc_special_buffer(struct efx_nic *efx,
298 struct efx_special_buffer *buffer,
299 unsigned int len)
300{
301 struct falcon_nic_data *nic_data = efx->nic_data;
302
303 len = ALIGN(len, FALCON_BUF_SIZE);
304
305 buffer->addr = pci_alloc_consistent(efx->pci_dev, len,
306 &buffer->dma_addr);
307 if (!buffer->addr)
308 return -ENOMEM;
309 buffer->len = len;
310 buffer->entries = len / FALCON_BUF_SIZE;
311 BUG_ON(buffer->dma_addr & (FALCON_BUF_SIZE - 1));
312
313 /* All zeros is a potentially valid event so memset to 0xff */
314 memset(buffer->addr, 0xff, len);
315
316 /* Select new buffer ID */
317 buffer->index = nic_data->next_buffer_table;
318 nic_data->next_buffer_table += buffer->entries;
319
320 EFX_LOG(efx, "allocating special buffers %d-%d at %llx+%x "
321 "(virt %p phys %lx)\n", buffer->index,
322 buffer->index + buffer->entries - 1,
323 (unsigned long long)buffer->dma_addr, len,
324 buffer->addr, virt_to_phys(buffer->addr));
325
326 return 0;
327}
328
329static void falcon_free_special_buffer(struct efx_nic *efx,
330 struct efx_special_buffer *buffer)
331{
332 if (!buffer->addr)
333 return;
334
335 EFX_LOG(efx, "deallocating special buffers %d-%d at %llx+%x "
336 "(virt %p phys %lx)\n", buffer->index,
337 buffer->index + buffer->entries - 1,
338 (unsigned long long)buffer->dma_addr, buffer->len,
339 buffer->addr, virt_to_phys(buffer->addr));
340
341 pci_free_consistent(efx->pci_dev, buffer->len, buffer->addr,
342 buffer->dma_addr);
343 buffer->addr = NULL;
344 buffer->entries = 0;
345}
346
347/**************************************************************************
348 *
349 * Falcon generic buffer handling
350 * These buffers are used for interrupt status and MAC stats
351 *
352 **************************************************************************/
353
354static int falcon_alloc_buffer(struct efx_nic *efx,
355 struct efx_buffer *buffer, unsigned int len)
356{
357 buffer->addr = pci_alloc_consistent(efx->pci_dev, len,
358 &buffer->dma_addr);
359 if (!buffer->addr)
360 return -ENOMEM;
361 buffer->len = len;
362 memset(buffer->addr, 0, len);
363 return 0;
364}
365
366static void falcon_free_buffer(struct efx_nic *efx, struct efx_buffer *buffer)
367{
368 if (buffer->addr) {
369 pci_free_consistent(efx->pci_dev, buffer->len,
370 buffer->addr, buffer->dma_addr);
371 buffer->addr = NULL;
372 }
373}
374
375/**************************************************************************
376 *
377 * Falcon TX path
378 *
379 **************************************************************************/
380
381/* Returns a pointer to the specified transmit descriptor in the TX
382 * descriptor queue belonging to the specified channel.
383 */
384static inline efx_qword_t *falcon_tx_desc(struct efx_tx_queue *tx_queue,
385 unsigned int index)
386{
387 return (((efx_qword_t *) (tx_queue->txd.addr)) + index);
388}
389
390/* This writes to the TX_DESC_WPTR; write pointer for TX descriptor ring */
391static inline void falcon_notify_tx_desc(struct efx_tx_queue *tx_queue)
392{
393 unsigned write_ptr;
394 efx_dword_t reg;
395
396 write_ptr = tx_queue->write_count & FALCON_TXD_RING_MASK;
397 EFX_POPULATE_DWORD_1(reg, TX_DESC_WPTR_DWORD, write_ptr);
398 falcon_writel_page(tx_queue->efx, &reg,
399 TX_DESC_UPD_REG_KER_DWORD, tx_queue->queue);
400}
401
402
403/* For each entry inserted into the software descriptor ring, create a
404 * descriptor in the hardware TX descriptor ring (in host memory), and
405 * write a doorbell.
406 */
407void falcon_push_buffers(struct efx_tx_queue *tx_queue)
408{
409
410 struct efx_tx_buffer *buffer;
411 efx_qword_t *txd;
412 unsigned write_ptr;
413
414 BUG_ON(tx_queue->write_count == tx_queue->insert_count);
415
416 do {
417 write_ptr = tx_queue->write_count & FALCON_TXD_RING_MASK;
418 buffer = &tx_queue->buffer[write_ptr];
419 txd = falcon_tx_desc(tx_queue, write_ptr);
420 ++tx_queue->write_count;
421
422 /* Create TX descriptor ring entry */
423 EFX_POPULATE_QWORD_5(*txd,
424 TX_KER_PORT, 0,
425 TX_KER_CONT, buffer->continuation,
426 TX_KER_BYTE_CNT, buffer->len,
427 TX_KER_BUF_REGION, 0,
428 TX_KER_BUF_ADR, buffer->dma_addr);
429 } while (tx_queue->write_count != tx_queue->insert_count);
430
431 wmb(); /* Ensure descriptors are written before they are fetched */
432 falcon_notify_tx_desc(tx_queue);
433}
434
435/* Allocate hardware resources for a TX queue */
436int falcon_probe_tx(struct efx_tx_queue *tx_queue)
437{
438 struct efx_nic *efx = tx_queue->efx;
439 return falcon_alloc_special_buffer(efx, &tx_queue->txd,
440 FALCON_TXD_RING_SIZE *
441 sizeof(efx_qword_t));
442}
443
444int falcon_init_tx(struct efx_tx_queue *tx_queue)
445{
446 efx_oword_t tx_desc_ptr;
447 struct efx_nic *efx = tx_queue->efx;
448 int rc;
449
450 /* Pin TX descriptor ring */
451 rc = falcon_init_special_buffer(efx, &tx_queue->txd);
452 if (rc)
453 return rc;
454
455 /* Push TX descriptor ring to card */
456 EFX_POPULATE_OWORD_10(tx_desc_ptr,
457 TX_DESCQ_EN, 1,
458 TX_ISCSI_DDIG_EN, 0,
459 TX_ISCSI_HDIG_EN, 0,
460 TX_DESCQ_BUF_BASE_ID, tx_queue->txd.index,
461 TX_DESCQ_EVQ_ID, tx_queue->channel->evqnum,
462 TX_DESCQ_OWNER_ID, 0,
463 TX_DESCQ_LABEL, tx_queue->queue,
464 TX_DESCQ_SIZE, FALCON_TXD_RING_ORDER,
465 TX_DESCQ_TYPE, 0,
466 TX_NON_IP_DROP_DIS_B0, 1);
467
468 if (FALCON_REV(efx) >= FALCON_REV_B0) {
469 int csum = !(efx->net_dev->features & NETIF_F_IP_CSUM);
470 EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_IP_CHKSM_DIS_B0, csum);
471 EFX_SET_OWORD_FIELD(tx_desc_ptr, TX_TCP_CHKSM_DIS_B0, csum);
472 }
473
474 falcon_write_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base,
475 tx_queue->queue);
476
477 if (FALCON_REV(efx) < FALCON_REV_B0) {
478 efx_oword_t reg;
479
480 BUG_ON(tx_queue->queue >= 128); /* HW limit */
481
482 falcon_read(efx, &reg, TX_CHKSM_CFG_REG_KER_A1);
483 if (efx->net_dev->features & NETIF_F_IP_CSUM)
484 clear_bit_le(tx_queue->queue, (void *)&reg);
485 else
486 set_bit_le(tx_queue->queue, (void *)&reg);
487 falcon_write(efx, &reg, TX_CHKSM_CFG_REG_KER_A1);
488 }
489
490 return 0;
491}
492
493static int falcon_flush_tx_queue(struct efx_tx_queue *tx_queue)
494{
495 struct efx_nic *efx = tx_queue->efx;
496 struct efx_channel *channel = &efx->channel[0];
497 efx_oword_t tx_flush_descq;
498 unsigned int read_ptr, i;
499
500 /* Post a flush command */
501 EFX_POPULATE_OWORD_2(tx_flush_descq,
502 TX_FLUSH_DESCQ_CMD, 1,
503 TX_FLUSH_DESCQ, tx_queue->queue);
504 falcon_write(efx, &tx_flush_descq, TX_FLUSH_DESCQ_REG_KER);
505 msleep(FALCON_FLUSH_TIMEOUT);
506
507 if (EFX_WORKAROUND_7803(efx))
508 return 0;
509
510 /* Look for a flush completed event */
511 read_ptr = channel->eventq_read_ptr;
512 for (i = 0; i < FALCON_EVQ_SIZE; ++i) {
513 efx_qword_t *event = falcon_event(channel, read_ptr);
514 int ev_code, ev_sub_code, ev_queue;
515 if (!falcon_event_present(event))
516 break;
517
518 ev_code = EFX_QWORD_FIELD(*event, EV_CODE);
519 ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);
520 ev_queue = EFX_QWORD_FIELD(*event, DRIVER_EV_TX_DESCQ_ID);
521 if ((ev_sub_code == TX_DESCQ_FLS_DONE_EV_DECODE) &&
522 (ev_queue == tx_queue->queue)) {
523 EFX_LOG(efx, "tx queue %d flush command succesful\n",
524 tx_queue->queue);
525 return 0;
526 }
527
528 read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;
529 }
530
531 if (EFX_WORKAROUND_11557(efx)) {
532 efx_oword_t reg;
533 int enabled;
534
535 falcon_read_table(efx, &reg, efx->type->txd_ptr_tbl_base,
536 tx_queue->queue);
537 enabled = EFX_OWORD_FIELD(reg, TX_DESCQ_EN);
538 if (!enabled) {
539 EFX_LOG(efx, "tx queue %d disabled without a "
540 "flush event seen\n", tx_queue->queue);
541 return 0;
542 }
543 }
544
545 EFX_ERR(efx, "tx queue %d flush command timed out\n", tx_queue->queue);
546 return -ETIMEDOUT;
547}
548
549void falcon_fini_tx(struct efx_tx_queue *tx_queue)
550{
551 struct efx_nic *efx = tx_queue->efx;
552 efx_oword_t tx_desc_ptr;
553
554 /* Stop the hardware using the queue */
555 if (falcon_flush_tx_queue(tx_queue))
556 EFX_ERR(efx, "failed to flush tx queue %d\n", tx_queue->queue);
557
558 /* Remove TX descriptor ring from card */
559 EFX_ZERO_OWORD(tx_desc_ptr);
560 falcon_write_table(efx, &tx_desc_ptr, efx->type->txd_ptr_tbl_base,
561 tx_queue->queue);
562
563 /* Unpin TX descriptor ring */
564 falcon_fini_special_buffer(efx, &tx_queue->txd);
565}
566
567/* Free buffers backing TX queue */
568void falcon_remove_tx(struct efx_tx_queue *tx_queue)
569{
570 falcon_free_special_buffer(tx_queue->efx, &tx_queue->txd);
571}
572
573/**************************************************************************
574 *
575 * Falcon RX path
576 *
577 **************************************************************************/
578
579/* Returns a pointer to the specified descriptor in the RX descriptor queue */
580static inline efx_qword_t *falcon_rx_desc(struct efx_rx_queue *rx_queue,
581 unsigned int index)
582{
583 return (((efx_qword_t *) (rx_queue->rxd.addr)) + index);
584}
585
586/* This creates an entry in the RX descriptor queue */
587static inline void falcon_build_rx_desc(struct efx_rx_queue *rx_queue,
588 unsigned index)
589{
590 struct efx_rx_buffer *rx_buf;
591 efx_qword_t *rxd;
592
593 rxd = falcon_rx_desc(rx_queue, index);
594 rx_buf = efx_rx_buffer(rx_queue, index);
595 EFX_POPULATE_QWORD_3(*rxd,
596 RX_KER_BUF_SIZE,
597 rx_buf->len -
598 rx_queue->efx->type->rx_buffer_padding,
599 RX_KER_BUF_REGION, 0,
600 RX_KER_BUF_ADR, rx_buf->dma_addr);
601}
602
603/* This writes to the RX_DESC_WPTR register for the specified receive
604 * descriptor ring.
605 */
606void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue)
607{
608 efx_dword_t reg;
609 unsigned write_ptr;
610
611 while (rx_queue->notified_count != rx_queue->added_count) {
612 falcon_build_rx_desc(rx_queue,
613 rx_queue->notified_count &
614 FALCON_RXD_RING_MASK);
615 ++rx_queue->notified_count;
616 }
617
618 wmb();
619 write_ptr = rx_queue->added_count & FALCON_RXD_RING_MASK;
620 EFX_POPULATE_DWORD_1(reg, RX_DESC_WPTR_DWORD, write_ptr);
621 falcon_writel_page(rx_queue->efx, &reg,
622 RX_DESC_UPD_REG_KER_DWORD, rx_queue->queue);
623}
624
625int falcon_probe_rx(struct efx_rx_queue *rx_queue)
626{
627 struct efx_nic *efx = rx_queue->efx;
628 return falcon_alloc_special_buffer(efx, &rx_queue->rxd,
629 FALCON_RXD_RING_SIZE *
630 sizeof(efx_qword_t));
631}
632
633int falcon_init_rx(struct efx_rx_queue *rx_queue)
634{
635 efx_oword_t rx_desc_ptr;
636 struct efx_nic *efx = rx_queue->efx;
637 int rc;
638 int is_b0 = FALCON_REV(efx) >= FALCON_REV_B0;
639 int iscsi_digest_en = is_b0;
640
641 EFX_LOG(efx, "RX queue %d ring in special buffers %d-%d\n",
642 rx_queue->queue, rx_queue->rxd.index,
643 rx_queue->rxd.index + rx_queue->rxd.entries - 1);
644
645 /* Pin RX descriptor ring */
646 rc = falcon_init_special_buffer(efx, &rx_queue->rxd);
647 if (rc)
648 return rc;
649
650 /* Push RX descriptor ring to card */
651 EFX_POPULATE_OWORD_10(rx_desc_ptr,
652 RX_ISCSI_DDIG_EN, iscsi_digest_en,
653 RX_ISCSI_HDIG_EN, iscsi_digest_en,
654 RX_DESCQ_BUF_BASE_ID, rx_queue->rxd.index,
655 RX_DESCQ_EVQ_ID, rx_queue->channel->evqnum,
656 RX_DESCQ_OWNER_ID, 0,
657 RX_DESCQ_LABEL, rx_queue->queue,
658 RX_DESCQ_SIZE, FALCON_RXD_RING_ORDER,
659 RX_DESCQ_TYPE, 0 /* kernel queue */ ,
660 /* For >=B0 this is scatter so disable */
661 RX_DESCQ_JUMBO, !is_b0,
662 RX_DESCQ_EN, 1);
663 falcon_write_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
664 rx_queue->queue);
665 return 0;
666}
667
668static int falcon_flush_rx_queue(struct efx_rx_queue *rx_queue)
669{
670 struct efx_nic *efx = rx_queue->efx;
671 struct efx_channel *channel = &efx->channel[0];
672 unsigned int read_ptr, i;
673 efx_oword_t rx_flush_descq;
674
675 /* Post a flush command */
676 EFX_POPULATE_OWORD_2(rx_flush_descq,
677 RX_FLUSH_DESCQ_CMD, 1,
678 RX_FLUSH_DESCQ, rx_queue->queue);
679 falcon_write(efx, &rx_flush_descq, RX_FLUSH_DESCQ_REG_KER);
680 msleep(FALCON_FLUSH_TIMEOUT);
681
682 if (EFX_WORKAROUND_7803(efx))
683 return 0;
684
685 /* Look for a flush completed event */
686 read_ptr = channel->eventq_read_ptr;
687 for (i = 0; i < FALCON_EVQ_SIZE; ++i) {
688 efx_qword_t *event = falcon_event(channel, read_ptr);
689 int ev_code, ev_sub_code, ev_queue, ev_failed;
690 if (!falcon_event_present(event))
691 break;
692
693 ev_code = EFX_QWORD_FIELD(*event, EV_CODE);
694 ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);
695 ev_queue = EFX_QWORD_FIELD(*event, DRIVER_EV_RX_DESCQ_ID);
696 ev_failed = EFX_QWORD_FIELD(*event, DRIVER_EV_RX_FLUSH_FAIL);
697
698 if ((ev_sub_code == RX_DESCQ_FLS_DONE_EV_DECODE) &&
699 (ev_queue == rx_queue->queue)) {
700 if (ev_failed) {
701 EFX_INFO(efx, "rx queue %d flush command "
702 "failed\n", rx_queue->queue);
703 return -EAGAIN;
704 } else {
705 EFX_LOG(efx, "rx queue %d flush command "
706 "succesful\n", rx_queue->queue);
707 return 0;
708 }
709 }
710
711 read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;
712 }
713
714 if (EFX_WORKAROUND_11557(efx)) {
715 efx_oword_t reg;
716 int enabled;
717
718 falcon_read_table(efx, &reg, efx->type->rxd_ptr_tbl_base,
719 rx_queue->queue);
720 enabled = EFX_OWORD_FIELD(reg, RX_DESCQ_EN);
721 if (!enabled) {
722 EFX_LOG(efx, "rx queue %d disabled without a "
723 "flush event seen\n", rx_queue->queue);
724 return 0;
725 }
726 }
727
728 EFX_ERR(efx, "rx queue %d flush command timed out\n", rx_queue->queue);
729 return -ETIMEDOUT;
730}
731
732void falcon_fini_rx(struct efx_rx_queue *rx_queue)
733{
734 efx_oword_t rx_desc_ptr;
735 struct efx_nic *efx = rx_queue->efx;
736 int i, rc;
737
738 /* Try and flush the rx queue. This may need to be repeated */
739 for (i = 0; i < 5; i++) {
740 rc = falcon_flush_rx_queue(rx_queue);
741 if (rc == -EAGAIN)
742 continue;
743 break;
744 }
745 if (rc)
746 EFX_ERR(efx, "failed to flush rx queue %d\n", rx_queue->queue);
747
748 /* Remove RX descriptor ring from card */
749 EFX_ZERO_OWORD(rx_desc_ptr);
750 falcon_write_table(efx, &rx_desc_ptr, efx->type->rxd_ptr_tbl_base,
751 rx_queue->queue);
752
753 /* Unpin RX descriptor ring */
754 falcon_fini_special_buffer(efx, &rx_queue->rxd);
755}
756
757/* Free buffers backing RX queue */
758void falcon_remove_rx(struct efx_rx_queue *rx_queue)
759{
760 falcon_free_special_buffer(rx_queue->efx, &rx_queue->rxd);
761}
762
763/**************************************************************************
764 *
765 * Falcon event queue processing
766 * Event queues are processed by per-channel tasklets.
767 *
768 **************************************************************************/
769
770/* Update a channel's event queue's read pointer (RPTR) register
771 *
772 * This writes the EVQ_RPTR_REG register for the specified channel's
773 * event queue.
774 *
775 * Note that EVQ_RPTR_REG contains the index of the "last read" event,
776 * whereas channel->eventq_read_ptr contains the index of the "next to
777 * read" event.
778 */
779void falcon_eventq_read_ack(struct efx_channel *channel)
780{
781 efx_dword_t reg;
782 struct efx_nic *efx = channel->efx;
783
784 EFX_POPULATE_DWORD_1(reg, EVQ_RPTR_DWORD, channel->eventq_read_ptr);
785 falcon_writel_table(efx, &reg, efx->type->evq_rptr_tbl_base,
786 channel->evqnum);
787}
788
789/* Use HW to insert a SW defined event */
790void falcon_generate_event(struct efx_channel *channel, efx_qword_t *event)
791{
792 efx_oword_t drv_ev_reg;
793
794 EFX_POPULATE_OWORD_2(drv_ev_reg,
795 DRV_EV_QID, channel->evqnum,
796 DRV_EV_DATA,
797 EFX_QWORD_FIELD64(*event, WHOLE_EVENT));
798 falcon_write(channel->efx, &drv_ev_reg, DRV_EV_REG_KER);
799}
800
801/* Handle a transmit completion event
802 *
803 * Falcon batches TX completion events; the message we receive is of
804 * the form "complete all TX events up to this index".
805 */
806static inline void falcon_handle_tx_event(struct efx_channel *channel,
807 efx_qword_t *event)
808{
809 unsigned int tx_ev_desc_ptr;
810 unsigned int tx_ev_q_label;
811 struct efx_tx_queue *tx_queue;
812 struct efx_nic *efx = channel->efx;
813
814 if (likely(EFX_QWORD_FIELD(*event, TX_EV_COMP))) {
815 /* Transmit completion */
816 tx_ev_desc_ptr = EFX_QWORD_FIELD(*event, TX_EV_DESC_PTR);
817 tx_ev_q_label = EFX_QWORD_FIELD(*event, TX_EV_Q_LABEL);
818 tx_queue = &efx->tx_queue[tx_ev_q_label];
819 efx_xmit_done(tx_queue, tx_ev_desc_ptr);
820 } else if (EFX_QWORD_FIELD(*event, TX_EV_WQ_FF_FULL)) {
821 /* Rewrite the FIFO write pointer */
822 tx_ev_q_label = EFX_QWORD_FIELD(*event, TX_EV_Q_LABEL);
823 tx_queue = &efx->tx_queue[tx_ev_q_label];
824
825 if (NET_DEV_REGISTERED(efx))
826 netif_tx_lock(efx->net_dev);
827 falcon_notify_tx_desc(tx_queue);
828 if (NET_DEV_REGISTERED(efx))
829 netif_tx_unlock(efx->net_dev);
830 } else if (EFX_QWORD_FIELD(*event, TX_EV_PKT_ERR) &&
831 EFX_WORKAROUND_10727(efx)) {
832 efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH);
833 } else {
834 EFX_ERR(efx, "channel %d unexpected TX event "
835 EFX_QWORD_FMT"\n", channel->channel,
836 EFX_QWORD_VAL(*event));
837 }
838}
839
840/* Check received packet's destination MAC address. */
841static int check_dest_mac(struct efx_rx_queue *rx_queue,
842 const efx_qword_t *event)
843{
844 struct efx_rx_buffer *rx_buf;
845 struct efx_nic *efx = rx_queue->efx;
846 int rx_ev_desc_ptr;
847 struct ethhdr *eh;
848
849 if (efx->promiscuous)
850 return 1;
851
852 rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, RX_EV_DESC_PTR);
853 rx_buf = efx_rx_buffer(rx_queue, rx_ev_desc_ptr);
854 eh = (struct ethhdr *)rx_buf->data;
855 if (memcmp(eh->h_dest, efx->net_dev->dev_addr, ETH_ALEN))
856 return 0;
857 return 1;
858}
859
860/* Detect errors included in the rx_evt_pkt_ok bit. */
861static void falcon_handle_rx_not_ok(struct efx_rx_queue *rx_queue,
862 const efx_qword_t *event,
863 unsigned *rx_ev_pkt_ok,
864 int *discard, int byte_count)
865{
866 struct efx_nic *efx = rx_queue->efx;
867 unsigned rx_ev_buf_owner_id_err, rx_ev_ip_hdr_chksum_err;
868 unsigned rx_ev_tcp_udp_chksum_err, rx_ev_eth_crc_err;
869 unsigned rx_ev_frm_trunc, rx_ev_drib_nib, rx_ev_tobe_disc;
870 unsigned rx_ev_pkt_type, rx_ev_other_err, rx_ev_pause_frm;
871 unsigned rx_ev_ip_frag_err, rx_ev_hdr_type, rx_ev_mcast_pkt;
872 int snap, non_ip;
873
874 rx_ev_hdr_type = EFX_QWORD_FIELD(*event, RX_EV_HDR_TYPE);
875 rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, RX_EV_MCAST_PKT);
876 rx_ev_tobe_disc = EFX_QWORD_FIELD(*event, RX_EV_TOBE_DISC);
877 rx_ev_pkt_type = EFX_QWORD_FIELD(*event, RX_EV_PKT_TYPE);
878 rx_ev_buf_owner_id_err = EFX_QWORD_FIELD(*event,
879 RX_EV_BUF_OWNER_ID_ERR);
880 rx_ev_ip_frag_err = EFX_QWORD_FIELD(*event, RX_EV_IF_FRAG_ERR);
881 rx_ev_ip_hdr_chksum_err = EFX_QWORD_FIELD(*event,
882 RX_EV_IP_HDR_CHKSUM_ERR);
883 rx_ev_tcp_udp_chksum_err = EFX_QWORD_FIELD(*event,
884 RX_EV_TCP_UDP_CHKSUM_ERR);
885 rx_ev_eth_crc_err = EFX_QWORD_FIELD(*event, RX_EV_ETH_CRC_ERR);
886 rx_ev_frm_trunc = EFX_QWORD_FIELD(*event, RX_EV_FRM_TRUNC);
887 rx_ev_drib_nib = ((FALCON_REV(efx) >= FALCON_REV_B0) ?
888 0 : EFX_QWORD_FIELD(*event, RX_EV_DRIB_NIB));
889 rx_ev_pause_frm = EFX_QWORD_FIELD(*event, RX_EV_PAUSE_FRM_ERR);
890
891 /* Every error apart from tobe_disc and pause_frm */
892 rx_ev_other_err = (rx_ev_drib_nib | rx_ev_tcp_udp_chksum_err |
893 rx_ev_buf_owner_id_err | rx_ev_eth_crc_err |
894 rx_ev_frm_trunc | rx_ev_ip_hdr_chksum_err);
895
896 snap = (rx_ev_pkt_type == RX_EV_PKT_TYPE_LLC_DECODE) ||
897 (rx_ev_pkt_type == RX_EV_PKT_TYPE_VLAN_LLC_DECODE);
898 non_ip = (rx_ev_hdr_type == RX_EV_HDR_TYPE_NON_IP_DECODE);
899
900 /* SFC bug 5475/8970: The Falcon XMAC incorrectly calculates the
901 * length field of an LLC frame, which sets TOBE_DISC. We could set
902 * PASS_LEN_ERR, but we want the MAC to filter out short frames (to
903 * protect the RX block).
904 *
905 * bug5475 - LLC/SNAP: Falcon identifies SNAP packets.
906 * bug8970 - LLC/noSNAP: Falcon does not provide an LLC flag.
907 * LLC can't encapsulate IP, so by definition
908 * these packets are NON_IP.
909 *
910 * Unicast mismatch will also cause TOBE_DISC, so the driver needs
911 * to check this.
912 */
913 if (EFX_WORKAROUND_5475(efx) && rx_ev_tobe_disc && (snap || non_ip)) {
914 /* If all the other flags are zero then we can state the
915 * entire packet is ok, which will flag to the kernel not
916 * to recalculate checksums.
917 */
918 if (!(non_ip | rx_ev_other_err | rx_ev_pause_frm))
919 *rx_ev_pkt_ok = 1;
920
921 rx_ev_tobe_disc = 0;
922
923 /* TOBE_DISC is set for unicast mismatch. But given that
924 * we can't trust TOBE_DISC here, we must validate the dest
925 * MAC address ourselves.
926 */
927 if (!rx_ev_mcast_pkt && !check_dest_mac(rx_queue, event))
928 rx_ev_tobe_disc = 1;
929 }
930
931 /* Count errors that are not in MAC stats. */
932 if (rx_ev_frm_trunc)
933 ++rx_queue->channel->n_rx_frm_trunc;
934 else if (rx_ev_tobe_disc)
935 ++rx_queue->channel->n_rx_tobe_disc;
936 else if (rx_ev_ip_hdr_chksum_err)
937 ++rx_queue->channel->n_rx_ip_hdr_chksum_err;
938 else if (rx_ev_tcp_udp_chksum_err)
939 ++rx_queue->channel->n_rx_tcp_udp_chksum_err;
940 if (rx_ev_ip_frag_err)
941 ++rx_queue->channel->n_rx_ip_frag_err;
942
943 /* The frame must be discarded if any of these are true. */
944 *discard = (rx_ev_eth_crc_err | rx_ev_frm_trunc | rx_ev_drib_nib |
945 rx_ev_tobe_disc | rx_ev_pause_frm);
946
947 /* TOBE_DISC is expected on unicast mismatches; don't print out an
948 * error message. FRM_TRUNC indicates RXDP dropped the packet due
949 * to a FIFO overflow.
950 */
951#ifdef EFX_ENABLE_DEBUG
952 if (rx_ev_other_err) {
953 EFX_INFO_RL(efx, " RX queue %d unexpected RX event "
954 EFX_QWORD_FMT "%s%s%s%s%s%s%s%s%s\n",
955 rx_queue->queue, EFX_QWORD_VAL(*event),
956 rx_ev_buf_owner_id_err ? " [OWNER_ID_ERR]" : "",
957 rx_ev_ip_hdr_chksum_err ?
958 " [IP_HDR_CHKSUM_ERR]" : "",
959 rx_ev_tcp_udp_chksum_err ?
960 " [TCP_UDP_CHKSUM_ERR]" : "",
961 rx_ev_eth_crc_err ? " [ETH_CRC_ERR]" : "",
962 rx_ev_frm_trunc ? " [FRM_TRUNC]" : "",
963 rx_ev_drib_nib ? " [DRIB_NIB]" : "",
964 rx_ev_tobe_disc ? " [TOBE_DISC]" : "",
965 rx_ev_pause_frm ? " [PAUSE]" : "",
966 snap ? " [SNAP/LLC]" : "");
967 }
968#endif
969
970 if (unlikely(rx_ev_eth_crc_err && EFX_WORKAROUND_10750(efx) &&
971 efx->phy_type == PHY_TYPE_10XPRESS))
972 tenxpress_crc_err(efx);
973}
974
975/* Handle receive events that are not in-order. */
976static void falcon_handle_rx_bad_index(struct efx_rx_queue *rx_queue,
977 unsigned index)
978{
979 struct efx_nic *efx = rx_queue->efx;
980 unsigned expected, dropped;
981
982 expected = rx_queue->removed_count & FALCON_RXD_RING_MASK;
983 dropped = ((index + FALCON_RXD_RING_SIZE - expected) &
984 FALCON_RXD_RING_MASK);
985 EFX_INFO(efx, "dropped %d events (index=%d expected=%d)\n",
986 dropped, index, expected);
987
988 efx_schedule_reset(efx, EFX_WORKAROUND_5676(efx) ?
989 RESET_TYPE_RX_RECOVERY : RESET_TYPE_DISABLE);
990}
991
992/* Handle a packet received event
993 *
994 * Falcon silicon gives a "discard" flag if it's a unicast packet with the
995 * wrong destination address
996 * Also "is multicast" and "matches multicast filter" flags can be used to
997 * discard non-matching multicast packets.
998 */
999static inline int falcon_handle_rx_event(struct efx_channel *channel,
1000 const efx_qword_t *event)
1001{
1002 unsigned int rx_ev_q_label, rx_ev_desc_ptr, rx_ev_byte_cnt;
1003 unsigned int rx_ev_pkt_ok, rx_ev_hdr_type, rx_ev_mcast_pkt;
1004 unsigned expected_ptr;
1005 int discard = 0, checksummed;
1006 struct efx_rx_queue *rx_queue;
1007 struct efx_nic *efx = channel->efx;
1008
1009 /* Basic packet information */
1010 rx_ev_byte_cnt = EFX_QWORD_FIELD(*event, RX_EV_BYTE_CNT);
1011 rx_ev_pkt_ok = EFX_QWORD_FIELD(*event, RX_EV_PKT_OK);
1012 rx_ev_hdr_type = EFX_QWORD_FIELD(*event, RX_EV_HDR_TYPE);
1013 WARN_ON(EFX_QWORD_FIELD(*event, RX_EV_JUMBO_CONT));
1014 WARN_ON(EFX_QWORD_FIELD(*event, RX_EV_SOP) != 1);
1015
1016 rx_ev_q_label = EFX_QWORD_FIELD(*event, RX_EV_Q_LABEL);
1017 rx_queue = &efx->rx_queue[rx_ev_q_label];
1018
1019 rx_ev_desc_ptr = EFX_QWORD_FIELD(*event, RX_EV_DESC_PTR);
1020 expected_ptr = rx_queue->removed_count & FALCON_RXD_RING_MASK;
1021 if (unlikely(rx_ev_desc_ptr != expected_ptr)) {
1022 falcon_handle_rx_bad_index(rx_queue, rx_ev_desc_ptr);
1023 return rx_ev_q_label;
1024 }
1025
1026 if (likely(rx_ev_pkt_ok)) {
1027 /* If packet is marked as OK and packet type is TCP/IPv4 or
1028 * UDP/IPv4, then we can rely on the hardware checksum.
1029 */
1030 checksummed = RX_EV_HDR_TYPE_HAS_CHECKSUMS(rx_ev_hdr_type);
1031 } else {
1032 falcon_handle_rx_not_ok(rx_queue, event, &rx_ev_pkt_ok,
1033 &discard, rx_ev_byte_cnt);
1034 checksummed = 0;
1035 }
1036
1037 /* Detect multicast packets that didn't match the filter */
1038 rx_ev_mcast_pkt = EFX_QWORD_FIELD(*event, RX_EV_MCAST_PKT);
1039 if (rx_ev_mcast_pkt) {
1040 unsigned int rx_ev_mcast_hash_match =
1041 EFX_QWORD_FIELD(*event, RX_EV_MCAST_HASH_MATCH);
1042
1043 if (unlikely(!rx_ev_mcast_hash_match))
1044 discard = 1;
1045 }
1046
1047 /* Handle received packet */
1048 efx_rx_packet(rx_queue, rx_ev_desc_ptr, rx_ev_byte_cnt,
1049 checksummed, discard);
1050
1051 return rx_ev_q_label;
1052}
1053
1054/* Global events are basically PHY events */
1055static void falcon_handle_global_event(struct efx_channel *channel,
1056 efx_qword_t *event)
1057{
1058 struct efx_nic *efx = channel->efx;
1059 int is_phy_event = 0, handled = 0;
1060
1061 /* Check for interrupt on either port. Some boards have a
1062 * single PHY wired to the interrupt line for port 1. */
1063 if (EFX_QWORD_FIELD(*event, G_PHY0_INTR) ||
1064 EFX_QWORD_FIELD(*event, G_PHY1_INTR) ||
1065 EFX_QWORD_FIELD(*event, XG_PHY_INTR))
1066 is_phy_event = 1;
1067
1068 if ((FALCON_REV(efx) >= FALCON_REV_B0) &&
1069 EFX_OWORD_FIELD(*event, XG_MNT_INTR_B0))
1070 is_phy_event = 1;
1071
1072 if (is_phy_event) {
1073 efx->phy_op->clear_interrupt(efx);
1074 queue_work(efx->workqueue, &efx->reconfigure_work);
1075 handled = 1;
1076 }
1077
1078 if (EFX_QWORD_FIELD_VER(efx, *event, RX_RECOVERY)) {
1079 EFX_ERR(efx, "channel %d seen global RX_RESET "
1080 "event. Resetting.\n", channel->channel);
1081
1082 atomic_inc(&efx->rx_reset);
1083 efx_schedule_reset(efx, EFX_WORKAROUND_6555(efx) ?
1084 RESET_TYPE_RX_RECOVERY : RESET_TYPE_DISABLE);
1085 handled = 1;
1086 }
1087
1088 if (!handled)
1089 EFX_ERR(efx, "channel %d unknown global event "
1090 EFX_QWORD_FMT "\n", channel->channel,
1091 EFX_QWORD_VAL(*event));
1092}
1093
1094static void falcon_handle_driver_event(struct efx_channel *channel,
1095 efx_qword_t *event)
1096{
1097 struct efx_nic *efx = channel->efx;
1098 unsigned int ev_sub_code;
1099 unsigned int ev_sub_data;
1100
1101 ev_sub_code = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_CODE);
1102 ev_sub_data = EFX_QWORD_FIELD(*event, DRIVER_EV_SUB_DATA);
1103
1104 switch (ev_sub_code) {
1105 case TX_DESCQ_FLS_DONE_EV_DECODE:
1106 EFX_TRACE(efx, "channel %d TXQ %d flushed\n",
1107 channel->channel, ev_sub_data);
1108 break;
1109 case RX_DESCQ_FLS_DONE_EV_DECODE:
1110 EFX_TRACE(efx, "channel %d RXQ %d flushed\n",
1111 channel->channel, ev_sub_data);
1112 break;
1113 case EVQ_INIT_DONE_EV_DECODE:
1114 EFX_LOG(efx, "channel %d EVQ %d initialised\n",
1115 channel->channel, ev_sub_data);
1116 break;
1117 case SRM_UPD_DONE_EV_DECODE:
1118 EFX_TRACE(efx, "channel %d SRAM update done\n",
1119 channel->channel);
1120 break;
1121 case WAKE_UP_EV_DECODE:
1122 EFX_TRACE(efx, "channel %d RXQ %d wakeup event\n",
1123 channel->channel, ev_sub_data);
1124 break;
1125 case TIMER_EV_DECODE:
1126 EFX_TRACE(efx, "channel %d RX queue %d timer expired\n",
1127 channel->channel, ev_sub_data);
1128 break;
1129 case RX_RECOVERY_EV_DECODE:
1130 EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. "
1131 "Resetting.\n", channel->channel);
1132 efx_schedule_reset(efx,
1133 EFX_WORKAROUND_6555(efx) ?
1134 RESET_TYPE_RX_RECOVERY :
1135 RESET_TYPE_DISABLE);
1136 break;
1137 case RX_DSC_ERROR_EV_DECODE:
1138 EFX_ERR(efx, "RX DMA Q %d reports descriptor fetch error."
1139 " RX Q %d is disabled.\n", ev_sub_data, ev_sub_data);
1140 efx_schedule_reset(efx, RESET_TYPE_RX_DESC_FETCH);
1141 break;
1142 case TX_DSC_ERROR_EV_DECODE:
1143 EFX_ERR(efx, "TX DMA Q %d reports descriptor fetch error."
1144 " TX Q %d is disabled.\n", ev_sub_data, ev_sub_data);
1145 efx_schedule_reset(efx, RESET_TYPE_TX_DESC_FETCH);
1146 break;
1147 default:
1148 EFX_TRACE(efx, "channel %d unknown driver event code %d "
1149 "data %04x\n", channel->channel, ev_sub_code,
1150 ev_sub_data);
1151 break;
1152 }
1153}
1154
1155int falcon_process_eventq(struct efx_channel *channel, int *rx_quota)
1156{
1157 unsigned int read_ptr;
1158 efx_qword_t event, *p_event;
1159 int ev_code;
1160 int rxq;
1161 int rxdmaqs = 0;
1162
1163 read_ptr = channel->eventq_read_ptr;
1164
1165 do {
1166 p_event = falcon_event(channel, read_ptr);
1167 event = *p_event;
1168
1169 if (!falcon_event_present(&event))
1170 /* End of events */
1171 break;
1172
1173 EFX_TRACE(channel->efx, "channel %d event is "EFX_QWORD_FMT"\n",
1174 channel->channel, EFX_QWORD_VAL(event));
1175
1176 /* Clear this event by marking it all ones */
1177 EFX_SET_QWORD(*p_event);
1178
1179 ev_code = EFX_QWORD_FIELD(event, EV_CODE);
1180
1181 switch (ev_code) {
1182 case RX_IP_EV_DECODE:
1183 rxq = falcon_handle_rx_event(channel, &event);
1184 rxdmaqs |= (1 << rxq);
1185 (*rx_quota)--;
1186 break;
1187 case TX_IP_EV_DECODE:
1188 falcon_handle_tx_event(channel, &event);
1189 break;
1190 case DRV_GEN_EV_DECODE:
1191 channel->eventq_magic
1192 = EFX_QWORD_FIELD(event, EVQ_MAGIC);
1193 EFX_LOG(channel->efx, "channel %d received generated "
1194 "event "EFX_QWORD_FMT"\n", channel->channel,
1195 EFX_QWORD_VAL(event));
1196 break;
1197 case GLOBAL_EV_DECODE:
1198 falcon_handle_global_event(channel, &event);
1199 break;
1200 case DRIVER_EV_DECODE:
1201 falcon_handle_driver_event(channel, &event);
1202 break;
1203 default:
1204 EFX_ERR(channel->efx, "channel %d unknown event type %d"
1205 " (data " EFX_QWORD_FMT ")\n", channel->channel,
1206 ev_code, EFX_QWORD_VAL(event));
1207 }
1208
1209 /* Increment read pointer */
1210 read_ptr = (read_ptr + 1) & FALCON_EVQ_MASK;
1211
1212 } while (*rx_quota);
1213
1214 channel->eventq_read_ptr = read_ptr;
1215 return rxdmaqs;
1216}
1217
1218void falcon_set_int_moderation(struct efx_channel *channel)
1219{
1220 efx_dword_t timer_cmd;
1221 struct efx_nic *efx = channel->efx;
1222
1223 /* Set timer register */
1224 if (channel->irq_moderation) {
1225 /* Round to resolution supported by hardware. The value we
1226 * program is based at 0. So actual interrupt moderation
1227 * achieved is ((x + 1) * res).
1228 */
1229 unsigned int res = 5;
1230 channel->irq_moderation -= (channel->irq_moderation % res);
1231 if (channel->irq_moderation < res)
1232 channel->irq_moderation = res;
1233 EFX_POPULATE_DWORD_2(timer_cmd,
1234 TIMER_MODE, TIMER_MODE_INT_HLDOFF,
1235 TIMER_VAL,
1236 (channel->irq_moderation / res) - 1);
1237 } else {
1238 EFX_POPULATE_DWORD_2(timer_cmd,
1239 TIMER_MODE, TIMER_MODE_DIS,
1240 TIMER_VAL, 0);
1241 }
1242 falcon_writel_page_locked(efx, &timer_cmd, TIMER_CMD_REG_KER,
1243 channel->evqnum);
1244
1245}
1246
1247/* Allocate buffer table entries for event queue */
1248int falcon_probe_eventq(struct efx_channel *channel)
1249{
1250 struct efx_nic *efx = channel->efx;
1251 unsigned int evq_size;
1252
1253 evq_size = FALCON_EVQ_SIZE * sizeof(efx_qword_t);
1254 return falcon_alloc_special_buffer(efx, &channel->eventq, evq_size);
1255}
1256
1257int falcon_init_eventq(struct efx_channel *channel)
1258{
1259 efx_oword_t evq_ptr;
1260 struct efx_nic *efx = channel->efx;
1261 int rc;
1262
1263 EFX_LOG(efx, "channel %d event queue in special buffers %d-%d\n",
1264 channel->channel, channel->eventq.index,
1265 channel->eventq.index + channel->eventq.entries - 1);
1266
1267 /* Pin event queue buffer */
1268 rc = falcon_init_special_buffer(efx, &channel->eventq);
1269 if (rc)
1270 return rc;
1271
1272 /* Fill event queue with all ones (i.e. empty events) */
1273 memset(channel->eventq.addr, 0xff, channel->eventq.len);
1274
1275 /* Push event queue to card */
1276 EFX_POPULATE_OWORD_3(evq_ptr,
1277 EVQ_EN, 1,
1278 EVQ_SIZE, FALCON_EVQ_ORDER,
1279 EVQ_BUF_BASE_ID, channel->eventq.index);
1280 falcon_write_table(efx, &evq_ptr, efx->type->evq_ptr_tbl_base,
1281 channel->evqnum);
1282
1283 falcon_set_int_moderation(channel);
1284
1285 return 0;
1286}
1287
1288void falcon_fini_eventq(struct efx_channel *channel)
1289{
1290 efx_oword_t eventq_ptr;
1291 struct efx_nic *efx = channel->efx;
1292
1293 /* Remove event queue from card */
1294 EFX_ZERO_OWORD(eventq_ptr);
1295 falcon_write_table(efx, &eventq_ptr, efx->type->evq_ptr_tbl_base,
1296 channel->evqnum);
1297
1298 /* Unpin event queue */
1299 falcon_fini_special_buffer(efx, &channel->eventq);
1300}
1301
1302/* Free buffers backing event queue */
1303void falcon_remove_eventq(struct efx_channel *channel)
1304{
1305 falcon_free_special_buffer(channel->efx, &channel->eventq);
1306}
1307
1308
1309/* Generates a test event on the event queue. A subsequent call to
1310 * process_eventq() should pick up the event and place the value of
1311 * "magic" into channel->eventq_magic;
1312 */
1313void falcon_generate_test_event(struct efx_channel *channel, unsigned int magic)
1314{
1315 efx_qword_t test_event;
1316
1317 EFX_POPULATE_QWORD_2(test_event,
1318 EV_CODE, DRV_GEN_EV_DECODE,
1319 EVQ_MAGIC, magic);
1320 falcon_generate_event(channel, &test_event);
1321}
1322
1323
1324/**************************************************************************
1325 *
1326 * Falcon hardware interrupts
1327 * The hardware interrupt handler does very little work; all the event
1328 * queue processing is carried out by per-channel tasklets.
1329 *
1330 **************************************************************************/
1331
1332/* Enable/disable/generate Falcon interrupts */
1333static inline void falcon_interrupts(struct efx_nic *efx, int enabled,
1334 int force)
1335{
1336 efx_oword_t int_en_reg_ker;
1337
1338 EFX_POPULATE_OWORD_2(int_en_reg_ker,
1339 KER_INT_KER, force,
1340 DRV_INT_EN_KER, enabled);
1341 falcon_write(efx, &int_en_reg_ker, INT_EN_REG_KER);
1342}
1343
1344void falcon_enable_interrupts(struct efx_nic *efx)
1345{
1346 efx_oword_t int_adr_reg_ker;
1347 struct efx_channel *channel;
1348
1349 EFX_ZERO_OWORD(*((efx_oword_t *) efx->irq_status.addr));
1350 wmb(); /* Ensure interrupt vector is clear before interrupts enabled */
1351
1352 /* Program address */
1353 EFX_POPULATE_OWORD_2(int_adr_reg_ker,
1354 NORM_INT_VEC_DIS_KER, EFX_INT_MODE_USE_MSI(efx),
1355 INT_ADR_KER, efx->irq_status.dma_addr);
1356 falcon_write(efx, &int_adr_reg_ker, INT_ADR_REG_KER);
1357
1358 /* Enable interrupts */
1359 falcon_interrupts(efx, 1, 0);
1360
1361 /* Force processing of all the channels to get the EVQ RPTRs up to
1362 date */
1363 efx_for_each_channel_with_interrupt(channel, efx)
1364 efx_schedule_channel(channel);
1365}
1366
1367void falcon_disable_interrupts(struct efx_nic *efx)
1368{
1369 /* Disable interrupts */
1370 falcon_interrupts(efx, 0, 0);
1371}
1372
1373/* Generate a Falcon test interrupt
1374 * Interrupt must already have been enabled, otherwise nasty things
1375 * may happen.
1376 */
1377void falcon_generate_interrupt(struct efx_nic *efx)
1378{
1379 falcon_interrupts(efx, 1, 1);
1380}
1381
1382/* Acknowledge a legacy interrupt from Falcon
1383 *
1384 * This acknowledges a legacy (not MSI) interrupt via INT_ACK_KER_REG.
1385 *
1386 * Due to SFC bug 3706 (silicon revision <=A1) reads can be duplicated in the
1387 * BIU. Interrupt acknowledge is read sensitive so must write instead
1388 * (then read to ensure the BIU collector is flushed)
1389 *
1390 * NB most hardware supports MSI interrupts
1391 */
1392static inline void falcon_irq_ack_a1(struct efx_nic *efx)
1393{
1394 efx_dword_t reg;
1395
1396 EFX_POPULATE_DWORD_1(reg, INT_ACK_DUMMY_DATA, 0xb7eb7e);
1397 falcon_writel(efx, &reg, INT_ACK_REG_KER_A1);
1398 falcon_readl(efx, &reg, WORK_AROUND_BROKEN_PCI_READS_REG_KER_A1);
1399}
1400
1401/* Process a fatal interrupt
1402 * Disable bus mastering ASAP and schedule a reset
1403 */
1404static irqreturn_t falcon_fatal_interrupt(struct efx_nic *efx)
1405{
1406 struct falcon_nic_data *nic_data = efx->nic_data;
1407 efx_oword_t *int_ker = (efx_oword_t *) efx->irq_status.addr;
1408 efx_oword_t fatal_intr;
1409 int error, mem_perr;
1410 static int n_int_errors;
1411
1412 falcon_read(efx, &fatal_intr, FATAL_INTR_REG_KER);
1413 error = EFX_OWORD_FIELD(fatal_intr, INT_KER_ERROR);
1414
1415 EFX_ERR(efx, "SYSTEM ERROR " EFX_OWORD_FMT " status "
1416 EFX_OWORD_FMT ": %s\n", EFX_OWORD_VAL(*int_ker),
1417 EFX_OWORD_VAL(fatal_intr),
1418 error ? "disabling bus mastering" : "no recognised error");
1419 if (error == 0)
1420 goto out;
1421
1422 /* If this is a memory parity error dump which blocks are offending */
1423 mem_perr = EFX_OWORD_FIELD(fatal_intr, MEM_PERR_INT_KER);
1424 if (mem_perr) {
1425 efx_oword_t reg;
1426 falcon_read(efx, &reg, MEM_STAT_REG_KER);
1427 EFX_ERR(efx, "SYSTEM ERROR: memory parity error "
1428 EFX_OWORD_FMT "\n", EFX_OWORD_VAL(reg));
1429 }
1430
1431 /* Disable DMA bus mastering on both devices */
1432 pci_disable_device(efx->pci_dev);
1433 if (FALCON_IS_DUAL_FUNC(efx))
1434 pci_disable_device(nic_data->pci_dev2);
1435
1436 if (++n_int_errors < FALCON_MAX_INT_ERRORS) {
1437 EFX_ERR(efx, "SYSTEM ERROR - reset scheduled\n");
1438 efx_schedule_reset(efx, RESET_TYPE_INT_ERROR);
1439 } else {
1440 EFX_ERR(efx, "SYSTEM ERROR - max number of errors seen."
1441 "NIC will be disabled\n");
1442 efx_schedule_reset(efx, RESET_TYPE_DISABLE);
1443 }
1444out:
1445 return IRQ_HANDLED;
1446}
1447
1448/* Handle a legacy interrupt from Falcon
1449 * Acknowledges the interrupt and schedule event queue processing.
1450 */
1451static irqreturn_t falcon_legacy_interrupt_b0(int irq, void *dev_id)
1452{
1453 struct efx_nic *efx = (struct efx_nic *)dev_id;
1454 efx_oword_t *int_ker = (efx_oword_t *) efx->irq_status.addr;
1455 struct efx_channel *channel;
1456 efx_dword_t reg;
1457 u32 queues;
1458 int syserr;
1459
1460 /* Read the ISR which also ACKs the interrupts */
1461 falcon_readl(efx, &reg, INT_ISR0_B0);
1462 queues = EFX_EXTRACT_DWORD(reg, 0, 31);
1463
1464 /* Check to see if we have a serious error condition */
1465 syserr = EFX_OWORD_FIELD(*int_ker, FATAL_INT);
1466 if (unlikely(syserr))
1467 return falcon_fatal_interrupt(efx);
1468
1469 if (queues == 0)
1470 return IRQ_NONE;
1471
1472 efx->last_irq_cpu = raw_smp_processor_id();
1473 EFX_TRACE(efx, "IRQ %d on CPU %d status " EFX_DWORD_FMT "\n",
1474 irq, raw_smp_processor_id(), EFX_DWORD_VAL(reg));
1475
1476 /* Schedule processing of any interrupting queues */
1477 channel = &efx->channel[0];
1478 while (queues) {
1479 if (queues & 0x01)
1480 efx_schedule_channel(channel);
1481 channel++;
1482 queues >>= 1;
1483 }
1484
1485 return IRQ_HANDLED;
1486}
1487
1488
1489static irqreturn_t falcon_legacy_interrupt_a1(int irq, void *dev_id)
1490{
1491 struct efx_nic *efx = (struct efx_nic *)dev_id;
1492 efx_oword_t *int_ker = (efx_oword_t *) efx->irq_status.addr;
1493 struct efx_channel *channel;
1494 int syserr;
1495 int queues;
1496
1497 /* Check to see if this is our interrupt. If it isn't, we
1498 * exit without having touched the hardware.
1499 */
1500 if (unlikely(EFX_OWORD_IS_ZERO(*int_ker))) {
1501 EFX_TRACE(efx, "IRQ %d on CPU %d not for me\n", irq,
1502 raw_smp_processor_id());
1503 return IRQ_NONE;
1504 }
1505 efx->last_irq_cpu = raw_smp_processor_id();
1506 EFX_TRACE(efx, "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
1507 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
1508
1509 /* Check to see if we have a serious error condition */
1510 syserr = EFX_OWORD_FIELD(*int_ker, FATAL_INT);
1511 if (unlikely(syserr))
1512 return falcon_fatal_interrupt(efx);
1513
1514 /* Determine interrupting queues, clear interrupt status
1515 * register and acknowledge the device interrupt.
1516 */
1517 BUILD_BUG_ON(INT_EVQS_WIDTH > EFX_MAX_CHANNELS);
1518 queues = EFX_OWORD_FIELD(*int_ker, INT_EVQS);
1519 EFX_ZERO_OWORD(*int_ker);
1520 wmb(); /* Ensure the vector is cleared before interrupt ack */
1521 falcon_irq_ack_a1(efx);
1522
1523 /* Schedule processing of any interrupting queues */
1524 channel = &efx->channel[0];
1525 while (queues) {
1526 if (queues & 0x01)
1527 efx_schedule_channel(channel);
1528 channel++;
1529 queues >>= 1;
1530 }
1531
1532 return IRQ_HANDLED;
1533}
1534
1535/* Handle an MSI interrupt from Falcon
1536 *
1537 * Handle an MSI hardware interrupt. This routine schedules event
1538 * queue processing. No interrupt acknowledgement cycle is necessary.
1539 * Also, we never need to check that the interrupt is for us, since
1540 * MSI interrupts cannot be shared.
1541 */
1542static irqreturn_t falcon_msi_interrupt(int irq, void *dev_id)
1543{
1544 struct efx_channel *channel = (struct efx_channel *)dev_id;
1545 struct efx_nic *efx = channel->efx;
1546 efx_oword_t *int_ker = (efx_oword_t *) efx->irq_status.addr;
1547 int syserr;
1548
1549 efx->last_irq_cpu = raw_smp_processor_id();
1550 EFX_TRACE(efx, "IRQ %d on CPU %d status " EFX_OWORD_FMT "\n",
1551 irq, raw_smp_processor_id(), EFX_OWORD_VAL(*int_ker));
1552
1553 /* Check to see if we have a serious error condition */
1554 syserr = EFX_OWORD_FIELD(*int_ker, FATAL_INT);
1555 if (unlikely(syserr))
1556 return falcon_fatal_interrupt(efx);
1557
1558 /* Schedule processing of the channel */
1559 efx_schedule_channel(channel);
1560
1561 return IRQ_HANDLED;
1562}
1563
1564
1565/* Setup RSS indirection table.
1566 * This maps from the hash value of the packet to RXQ
1567 */
1568static void falcon_setup_rss_indir_table(struct efx_nic *efx)
1569{
1570 int i = 0;
1571 unsigned long offset;
1572 efx_dword_t dword;
1573
1574 if (FALCON_REV(efx) < FALCON_REV_B0)
1575 return;
1576
1577 for (offset = RX_RSS_INDIR_TBL_B0;
1578 offset < RX_RSS_INDIR_TBL_B0 + 0x800;
1579 offset += 0x10) {
1580 EFX_POPULATE_DWORD_1(dword, RX_RSS_INDIR_ENT_B0,
1581 i % efx->rss_queues);
1582 falcon_writel(efx, &dword, offset);
1583 i++;
1584 }
1585}
1586
1587/* Hook interrupt handler(s)
1588 * Try MSI and then legacy interrupts.
1589 */
1590int falcon_init_interrupt(struct efx_nic *efx)
1591{
1592 struct efx_channel *channel;
1593 int rc;
1594
1595 if (!EFX_INT_MODE_USE_MSI(efx)) {
1596 irq_handler_t handler;
1597 if (FALCON_REV(efx) >= FALCON_REV_B0)
1598 handler = falcon_legacy_interrupt_b0;
1599 else
1600 handler = falcon_legacy_interrupt_a1;
1601
1602 rc = request_irq(efx->legacy_irq, handler, IRQF_SHARED,
1603 efx->name, efx);
1604 if (rc) {
1605 EFX_ERR(efx, "failed to hook legacy IRQ %d\n",
1606 efx->pci_dev->irq);
1607 goto fail1;
1608 }
1609 return 0;
1610 }
1611
1612 /* Hook MSI or MSI-X interrupt */
1613 efx_for_each_channel_with_interrupt(channel, efx) {
1614 rc = request_irq(channel->irq, falcon_msi_interrupt,
1615 IRQF_PROBE_SHARED, /* Not shared */
1616 efx->name, channel);
1617 if (rc) {
1618 EFX_ERR(efx, "failed to hook IRQ %d\n", channel->irq);
1619 goto fail2;
1620 }
1621 }
1622
1623 return 0;
1624
1625 fail2:
1626 efx_for_each_channel_with_interrupt(channel, efx)
1627 free_irq(channel->irq, channel);
1628 fail1:
1629 return rc;
1630}
1631
1632void falcon_fini_interrupt(struct efx_nic *efx)
1633{
1634 struct efx_channel *channel;
1635 efx_oword_t reg;
1636
1637 /* Disable MSI/MSI-X interrupts */
1638 efx_for_each_channel_with_interrupt(channel, efx)
1639 if (channel->irq)
1640 free_irq(channel->irq, channel);
1641
1642 /* ACK legacy interrupt */
1643 if (FALCON_REV(efx) >= FALCON_REV_B0)
1644 falcon_read(efx, &reg, INT_ISR0_B0);
1645 else
1646 falcon_irq_ack_a1(efx);
1647
1648 /* Disable legacy interrupt */
1649 if (efx->legacy_irq)
1650 free_irq(efx->legacy_irq, efx);
1651}
1652
1653/**************************************************************************
1654 *
1655 * EEPROM/flash
1656 *
1657 **************************************************************************
1658 */
1659
1660#define FALCON_SPI_MAX_LEN sizeof(efx_oword_t)
1661
1662/* Wait for SPI command completion */
1663static int falcon_spi_wait(struct efx_nic *efx)
1664{
1665 efx_oword_t reg;
1666 int cmd_en, timer_active;
1667 int count;
1668
1669 count = 0;
1670 do {
1671 falcon_read(efx, &reg, EE_SPI_HCMD_REG_KER);
1672 cmd_en = EFX_OWORD_FIELD(reg, EE_SPI_HCMD_CMD_EN);
1673 timer_active = EFX_OWORD_FIELD(reg, EE_WR_TIMER_ACTIVE);
1674 if (!cmd_en && !timer_active)
1675 return 0;
1676 udelay(10);
1677 } while (++count < 10000); /* wait upto 100msec */
1678 EFX_ERR(efx, "timed out waiting for SPI\n");
1679 return -ETIMEDOUT;
1680}
1681
1682static int
1683falcon_spi_read(struct efx_nic *efx, int device_id, unsigned int command,
1684 unsigned int address, unsigned int addr_len,
1685 void *data, unsigned int len)
1686{
1687 efx_oword_t reg;
1688 int rc;
1689
1690 BUG_ON(len > FALCON_SPI_MAX_LEN);
1691
1692 /* Check SPI not currently being accessed */
1693 rc = falcon_spi_wait(efx);
1694 if (rc)
1695 return rc;
1696
1697 /* Program address register */
1698 EFX_POPULATE_OWORD_1(reg, EE_SPI_HADR_ADR, address);
1699 falcon_write(efx, &reg, EE_SPI_HADR_REG_KER);
1700
1701 /* Issue read command */
1702 EFX_POPULATE_OWORD_7(reg,
1703 EE_SPI_HCMD_CMD_EN, 1,
1704 EE_SPI_HCMD_SF_SEL, device_id,
1705 EE_SPI_HCMD_DABCNT, len,
1706 EE_SPI_HCMD_READ, EE_SPI_READ,
1707 EE_SPI_HCMD_DUBCNT, 0,
1708 EE_SPI_HCMD_ADBCNT, addr_len,
1709 EE_SPI_HCMD_ENC, command);
1710 falcon_write(efx, &reg, EE_SPI_HCMD_REG_KER);
1711
1712 /* Wait for read to complete */
1713 rc = falcon_spi_wait(efx);
1714 if (rc)
1715 return rc;
1716
1717 /* Read data */
1718 falcon_read(efx, &reg, EE_SPI_HDATA_REG_KER);
1719 memcpy(data, &reg, len);
1720 return 0;
1721}
1722
1723/**************************************************************************
1724 *
1725 * MAC wrapper
1726 *
1727 **************************************************************************
1728 */
1729void falcon_drain_tx_fifo(struct efx_nic *efx)
1730{
1731 efx_oword_t temp;
1732 int count;
1733
1734 if (FALCON_REV(efx) < FALCON_REV_B0)
1735 return;
1736
1737 falcon_read(efx, &temp, MAC0_CTRL_REG_KER);
1738 /* There is no point in draining more than once */
1739 if (EFX_OWORD_FIELD(temp, TXFIFO_DRAIN_EN_B0))
1740 return;
1741
1742 /* MAC stats will fail whilst the TX fifo is draining. Serialise
1743 * the drain sequence with the statistics fetch */
1744 spin_lock(&efx->stats_lock);
1745
1746 EFX_SET_OWORD_FIELD(temp, TXFIFO_DRAIN_EN_B0, 1);
1747 falcon_write(efx, &temp, MAC0_CTRL_REG_KER);
1748
1749 /* Reset the MAC and EM block. */
1750 falcon_read(efx, &temp, GLB_CTL_REG_KER);
1751 EFX_SET_OWORD_FIELD(temp, RST_XGTX, 1);
1752 EFX_SET_OWORD_FIELD(temp, RST_XGRX, 1);
1753 EFX_SET_OWORD_FIELD(temp, RST_EM, 1);
1754 falcon_write(efx, &temp, GLB_CTL_REG_KER);
1755
1756 count = 0;
1757 while (1) {
1758 falcon_read(efx, &temp, GLB_CTL_REG_KER);
1759 if (!EFX_OWORD_FIELD(temp, RST_XGTX) &&
1760 !EFX_OWORD_FIELD(temp, RST_XGRX) &&
1761 !EFX_OWORD_FIELD(temp, RST_EM)) {
1762 EFX_LOG(efx, "Completed MAC reset after %d loops\n",
1763 count);
1764 break;
1765 }
1766 if (count > 20) {
1767 EFX_ERR(efx, "MAC reset failed\n");
1768 break;
1769 }
1770 count++;
1771 udelay(10);
1772 }
1773
1774 spin_unlock(&efx->stats_lock);
1775
1776 /* If we've reset the EM block and the link is up, then
1777 * we'll have to kick the XAUI link so the PHY can recover */
1778 if (efx->link_up && EFX_WORKAROUND_5147(efx))
1779 falcon_reset_xaui(efx);
1780}
1781
1782void falcon_deconfigure_mac_wrapper(struct efx_nic *efx)
1783{
1784 efx_oword_t temp;
1785
1786 if (FALCON_REV(efx) < FALCON_REV_B0)
1787 return;
1788
1789 /* Isolate the MAC -> RX */
1790 falcon_read(efx, &temp, RX_CFG_REG_KER);
1791 EFX_SET_OWORD_FIELD(temp, RX_INGR_EN_B0, 0);
1792 falcon_write(efx, &temp, RX_CFG_REG_KER);
1793
1794 if (!efx->link_up)
1795 falcon_drain_tx_fifo(efx);
1796}
1797
1798void falcon_reconfigure_mac_wrapper(struct efx_nic *efx)
1799{
1800 efx_oword_t reg;
1801 int link_speed;
1802 unsigned int tx_fc;
1803
1804 if (efx->link_options & GM_LPA_10000)
1805 link_speed = 0x3;
1806 else if (efx->link_options & GM_LPA_1000)
1807 link_speed = 0x2;
1808 else if (efx->link_options & GM_LPA_100)
1809 link_speed = 0x1;
1810 else
1811 link_speed = 0x0;
1812 /* MAC_LINK_STATUS controls MAC backpressure but doesn't work
1813 * as advertised. Disable to ensure packets are not
1814 * indefinitely held and TX queue can be flushed at any point
1815 * while the link is down. */
1816 EFX_POPULATE_OWORD_5(reg,
1817 MAC_XOFF_VAL, 0xffff /* max pause time */,
1818 MAC_BCAD_ACPT, 1,
1819 MAC_UC_PROM, efx->promiscuous,
1820 MAC_LINK_STATUS, 1, /* always set */
1821 MAC_SPEED, link_speed);
1822 /* On B0, MAC backpressure can be disabled and packets get
1823 * discarded. */
1824 if (FALCON_REV(efx) >= FALCON_REV_B0) {
1825 EFX_SET_OWORD_FIELD(reg, TXFIFO_DRAIN_EN_B0,
1826 !efx->link_up);
1827 }
1828
1829 falcon_write(efx, &reg, MAC0_CTRL_REG_KER);
1830
1831 /* Restore the multicast hash registers. */
1832 falcon_set_multicast_hash(efx);
1833
1834 /* Transmission of pause frames when RX crosses the threshold is
1835 * covered by RX_XOFF_MAC_EN and XM_TX_CFG_REG:XM_FCNTL.
1836 * Action on receipt of pause frames is controller by XM_DIS_FCNTL */
1837 tx_fc = (efx->flow_control & EFX_FC_TX) ? 1 : 0;
1838 falcon_read(efx, &reg, RX_CFG_REG_KER);
1839 EFX_SET_OWORD_FIELD_VER(efx, reg, RX_XOFF_MAC_EN, tx_fc);
1840
1841 /* Unisolate the MAC -> RX */
1842 if (FALCON_REV(efx) >= FALCON_REV_B0)
1843 EFX_SET_OWORD_FIELD(reg, RX_INGR_EN_B0, 1);
1844 falcon_write(efx, &reg, RX_CFG_REG_KER);
1845}
1846
1847int falcon_dma_stats(struct efx_nic *efx, unsigned int done_offset)
1848{
1849 efx_oword_t reg;
1850 u32 *dma_done;
1851 int i;
1852
1853 if (disable_dma_stats)
1854 return 0;
1855
1856 /* Statistics fetch will fail if the MAC is in TX drain */
1857 if (FALCON_REV(efx) >= FALCON_REV_B0) {
1858 efx_oword_t temp;
1859 falcon_read(efx, &temp, MAC0_CTRL_REG_KER);
1860 if (EFX_OWORD_FIELD(temp, TXFIFO_DRAIN_EN_B0))
1861 return 0;
1862 }
1863
1864 dma_done = (efx->stats_buffer.addr + done_offset);
1865 *dma_done = FALCON_STATS_NOT_DONE;
1866 wmb(); /* ensure done flag is clear */
1867
1868 /* Initiate DMA transfer of stats */
1869 EFX_POPULATE_OWORD_2(reg,
1870 MAC_STAT_DMA_CMD, 1,
1871 MAC_STAT_DMA_ADR,
1872 efx->stats_buffer.dma_addr);
1873 falcon_write(efx, &reg, MAC0_STAT_DMA_REG_KER);
1874
1875 /* Wait for transfer to complete */
1876 for (i = 0; i < 400; i++) {
1877 if (*(volatile u32 *)dma_done == FALCON_STATS_DONE)
1878 return 0;
1879 udelay(10);
1880 }
1881
1882 EFX_ERR(efx, "timed out waiting for statistics\n");
1883 return -ETIMEDOUT;
1884}
1885
1886/**************************************************************************
1887 *
1888 * PHY access via GMII
1889 *
1890 **************************************************************************
1891 */
1892
1893/* Use the top bit of the MII PHY id to indicate the PHY type
1894 * (1G/10G), with the remaining bits as the actual PHY id.
1895 *
1896 * This allows us to avoid leaking information from the mii_if_info
1897 * structure into other data structures.
1898 */
1899#define FALCON_PHY_ID_ID_WIDTH EFX_WIDTH(MD_PRT_DEV_ADR)
1900#define FALCON_PHY_ID_ID_MASK ((1 << FALCON_PHY_ID_ID_WIDTH) - 1)
1901#define FALCON_PHY_ID_WIDTH (FALCON_PHY_ID_ID_WIDTH + 1)
1902#define FALCON_PHY_ID_MASK ((1 << FALCON_PHY_ID_WIDTH) - 1)
1903#define FALCON_PHY_ID_10G (1 << (FALCON_PHY_ID_WIDTH - 1))
1904
1905
1906/* Packing the clause 45 port and device fields into a single value */
1907#define MD_PRT_ADR_COMP_LBN (MD_PRT_ADR_LBN - MD_DEV_ADR_LBN)
1908#define MD_PRT_ADR_COMP_WIDTH MD_PRT_ADR_WIDTH
1909#define MD_DEV_ADR_COMP_LBN 0
1910#define MD_DEV_ADR_COMP_WIDTH MD_DEV_ADR_WIDTH
1911
1912
1913/* Wait for GMII access to complete */
1914static int falcon_gmii_wait(struct efx_nic *efx)
1915{
1916 efx_dword_t md_stat;
1917 int count;
1918
1919 for (count = 0; count < 1000; count++) { /* wait upto 10ms */
1920 falcon_readl(efx, &md_stat, MD_STAT_REG_KER);
1921 if (EFX_DWORD_FIELD(md_stat, MD_BSY) == 0) {
1922 if (EFX_DWORD_FIELD(md_stat, MD_LNFL) != 0 ||
1923 EFX_DWORD_FIELD(md_stat, MD_BSERR) != 0) {
1924 EFX_ERR(efx, "error from GMII access "
1925 EFX_DWORD_FMT"\n",
1926 EFX_DWORD_VAL(md_stat));
1927 return -EIO;
1928 }
1929 return 0;
1930 }
1931 udelay(10);
1932 }
1933 EFX_ERR(efx, "timed out waiting for GMII\n");
1934 return -ETIMEDOUT;
1935}
1936
1937/* Writes a GMII register of a PHY connected to Falcon using MDIO. */
1938static void falcon_mdio_write(struct net_device *net_dev, int phy_id,
1939 int addr, int value)
1940{
1941 struct efx_nic *efx = (struct efx_nic *)net_dev->priv;
1942 unsigned int phy_id2 = phy_id & FALCON_PHY_ID_ID_MASK;
1943 efx_oword_t reg;
1944
1945 /* The 'generic' prt/dev packing in mdio_10g.h is conveniently
1946 * chosen so that the only current user, Falcon, can take the
1947 * packed value and use them directly.
1948 * Fail to build if this assumption is broken.
1949 */
1950 BUILD_BUG_ON(FALCON_PHY_ID_10G != MDIO45_XPRT_ID_IS10G);
1951 BUILD_BUG_ON(FALCON_PHY_ID_ID_WIDTH != MDIO45_PRT_DEV_WIDTH);
1952 BUILD_BUG_ON(MD_PRT_ADR_COMP_LBN != MDIO45_PRT_ID_COMP_LBN);
1953 BUILD_BUG_ON(MD_DEV_ADR_COMP_LBN != MDIO45_DEV_ID_COMP_LBN);
1954
1955 if (phy_id2 == PHY_ADDR_INVALID)
1956 return;
1957
1958 /* See falcon_mdio_read for an explanation. */
1959 if (!(phy_id & FALCON_PHY_ID_10G)) {
1960 int mmd = ffs(efx->phy_op->mmds) - 1;
1961 EFX_TRACE(efx, "Fixing erroneous clause22 write\n");
1962 phy_id2 = mdio_clause45_pack(phy_id2, mmd)
1963 & FALCON_PHY_ID_ID_MASK;
1964 }
1965
1966 EFX_REGDUMP(efx, "writing GMII %d register %02x with %04x\n", phy_id,
1967 addr, value);
1968
1969 spin_lock_bh(&efx->phy_lock);
1970
1971 /* Check MII not currently being accessed */
1972 if (falcon_gmii_wait(efx) != 0)
1973 goto out;
1974
1975 /* Write the address/ID register */
1976 EFX_POPULATE_OWORD_1(reg, MD_PHY_ADR, addr);
1977 falcon_write(efx, &reg, MD_PHY_ADR_REG_KER);
1978
1979 EFX_POPULATE_OWORD_1(reg, MD_PRT_DEV_ADR, phy_id2);
1980 falcon_write(efx, &reg, MD_ID_REG_KER);
1981
1982 /* Write data */
1983 EFX_POPULATE_OWORD_1(reg, MD_TXD, value);
1984 falcon_write(efx, &reg, MD_TXD_REG_KER);
1985
1986 EFX_POPULATE_OWORD_2(reg,
1987 MD_WRC, 1,
1988 MD_GC, 0);
1989 falcon_write(efx, &reg, MD_CS_REG_KER);
1990
1991 /* Wait for data to be written */
1992 if (falcon_gmii_wait(efx) != 0) {
1993 /* Abort the write operation */
1994 EFX_POPULATE_OWORD_2(reg,
1995 MD_WRC, 0,
1996 MD_GC, 1);
1997 falcon_write(efx, &reg, MD_CS_REG_KER);
1998 udelay(10);
1999 }
2000
2001 out:
2002 spin_unlock_bh(&efx->phy_lock);
2003}
2004
2005/* Reads a GMII register from a PHY connected to Falcon. If no value
2006 * could be read, -1 will be returned. */
2007static int falcon_mdio_read(struct net_device *net_dev, int phy_id, int addr)
2008{
2009 struct efx_nic *efx = (struct efx_nic *)net_dev->priv;
2010 unsigned int phy_addr = phy_id & FALCON_PHY_ID_ID_MASK;
2011 efx_oword_t reg;
2012 int value = -1;
2013
2014 if (phy_addr == PHY_ADDR_INVALID)
2015 return -1;
2016
2017 /* Our PHY code knows whether it needs to talk clause 22(1G) or 45(10G)
2018 * but the generic Linux code does not make any distinction or have
2019 * any state for this.
2020 * We spot the case where someone tried to talk 22 to a 45 PHY and
2021 * redirect the request to the lowest numbered MMD as a clause45
2022 * request. This is enough to allow simple queries like id and link
2023 * state to succeed. TODO: We may need to do more in future.
2024 */
2025 if (!(phy_id & FALCON_PHY_ID_10G)) {
2026 int mmd = ffs(efx->phy_op->mmds) - 1;
2027 EFX_TRACE(efx, "Fixing erroneous clause22 read\n");
2028 phy_addr = mdio_clause45_pack(phy_addr, mmd)
2029 & FALCON_PHY_ID_ID_MASK;
2030 }
2031
2032 spin_lock_bh(&efx->phy_lock);
2033
2034 /* Check MII not currently being accessed */
2035 if (falcon_gmii_wait(efx) != 0)
2036 goto out;
2037
2038 EFX_POPULATE_OWORD_1(reg, MD_PHY_ADR, addr);
2039 falcon_write(efx, &reg, MD_PHY_ADR_REG_KER);
2040
2041 EFX_POPULATE_OWORD_1(reg, MD_PRT_DEV_ADR, phy_addr);
2042 falcon_write(efx, &reg, MD_ID_REG_KER);
2043
2044 /* Request data to be read */
2045 EFX_POPULATE_OWORD_2(reg, MD_RDC, 1, MD_GC, 0);
2046 falcon_write(efx, &reg, MD_CS_REG_KER);
2047
2048 /* Wait for data to become available */
2049 value = falcon_gmii_wait(efx);
2050 if (value == 0) {
2051 falcon_read(efx, &reg, MD_RXD_REG_KER);
2052 value = EFX_OWORD_FIELD(reg, MD_RXD);
2053 EFX_REGDUMP(efx, "read from GMII %d register %02x, got %04x\n",
2054 phy_id, addr, value);
2055 } else {
2056 /* Abort the read operation */
2057 EFX_POPULATE_OWORD_2(reg,
2058 MD_RIC, 0,
2059 MD_GC, 1);
2060 falcon_write(efx, &reg, MD_CS_REG_KER);
2061
2062 EFX_LOG(efx, "read from GMII 0x%x register %02x, got "
2063 "error %d\n", phy_id, addr, value);
2064 }
2065
2066 out:
2067 spin_unlock_bh(&efx->phy_lock);
2068
2069 return value;
2070}
2071
2072static void falcon_init_mdio(struct mii_if_info *gmii)
2073{
2074 gmii->mdio_read = falcon_mdio_read;
2075 gmii->mdio_write = falcon_mdio_write;
2076 gmii->phy_id_mask = FALCON_PHY_ID_MASK;
2077 gmii->reg_num_mask = ((1 << EFX_WIDTH(MD_PHY_ADR)) - 1);
2078}
2079
2080static int falcon_probe_phy(struct efx_nic *efx)
2081{
2082 switch (efx->phy_type) {
2083 case PHY_TYPE_10XPRESS:
2084 efx->phy_op = &falcon_tenxpress_phy_ops;
2085 break;
2086 case PHY_TYPE_XFP:
2087 efx->phy_op = &falcon_xfp_phy_ops;
2088 break;
2089 default:
2090 EFX_ERR(efx, "Unknown PHY type %d\n",
2091 efx->phy_type);
2092 return -1;
2093 }
2094 return 0;
2095}
2096
2097/* This call is responsible for hooking in the MAC and PHY operations */
2098int falcon_probe_port(struct efx_nic *efx)
2099{
2100 int rc;
2101
2102 /* Hook in PHY operations table */
2103 rc = falcon_probe_phy(efx);
2104 if (rc)
2105 return rc;
2106
2107 /* Set up GMII structure for PHY */
2108 efx->mii.supports_gmii = 1;
2109 falcon_init_mdio(&efx->mii);
2110
2111 /* Hardware flow ctrl. FalconA RX FIFO too small for pause generation */
2112 if (FALCON_REV(efx) >= FALCON_REV_B0)
2113 efx->flow_control = EFX_FC_RX | EFX_FC_TX;
2114 else
2115 efx->flow_control = EFX_FC_RX;
2116
2117 /* Allocate buffer for stats */
2118 rc = falcon_alloc_buffer(efx, &efx->stats_buffer,
2119 FALCON_MAC_STATS_SIZE);
2120 if (rc)
2121 return rc;
2122 EFX_LOG(efx, "stats buffer at %llx (virt %p phys %lx)\n",
2123 (unsigned long long)efx->stats_buffer.dma_addr,
2124 efx->stats_buffer.addr,
2125 virt_to_phys(efx->stats_buffer.addr));
2126
2127 return 0;
2128}
2129
2130void falcon_remove_port(struct efx_nic *efx)
2131{
2132 falcon_free_buffer(efx, &efx->stats_buffer);
2133}
2134
2135/**************************************************************************
2136 *
2137 * Multicast filtering
2138 *
2139 **************************************************************************
2140 */
2141
2142void falcon_set_multicast_hash(struct efx_nic *efx)
2143{
2144 union efx_multicast_hash *mc_hash = &efx->multicast_hash;
2145
2146 /* Broadcast packets go through the multicast hash filter.
2147 * ether_crc_le() of the broadcast address is 0xbe2612ff
2148 * so we always add bit 0xff to the mask.
2149 */
2150 set_bit_le(0xff, mc_hash->byte);
2151
2152 falcon_write(efx, &mc_hash->oword[0], MAC_MCAST_HASH_REG0_KER);
2153 falcon_write(efx, &mc_hash->oword[1], MAC_MCAST_HASH_REG1_KER);
2154}
2155
2156/**************************************************************************
2157 *
2158 * Device reset
2159 *
2160 **************************************************************************
2161 */
2162
2163/* Resets NIC to known state. This routine must be called in process
2164 * context and is allowed to sleep. */
2165int falcon_reset_hw(struct efx_nic *efx, enum reset_type method)
2166{
2167 struct falcon_nic_data *nic_data = efx->nic_data;
2168 efx_oword_t glb_ctl_reg_ker;
2169 int rc;
2170
2171 EFX_LOG(efx, "performing hardware reset (%d)\n", method);
2172
2173 /* Initiate device reset */
2174 if (method == RESET_TYPE_WORLD) {
2175 rc = pci_save_state(efx->pci_dev);
2176 if (rc) {
2177 EFX_ERR(efx, "failed to backup PCI state of primary "
2178 "function prior to hardware reset\n");
2179 goto fail1;
2180 }
2181 if (FALCON_IS_DUAL_FUNC(efx)) {
2182 rc = pci_save_state(nic_data->pci_dev2);
2183 if (rc) {
2184 EFX_ERR(efx, "failed to backup PCI state of "
2185 "secondary function prior to "
2186 "hardware reset\n");
2187 goto fail2;
2188 }
2189 }
2190
2191 EFX_POPULATE_OWORD_2(glb_ctl_reg_ker,
2192 EXT_PHY_RST_DUR, 0x7,
2193 SWRST, 1);
2194 } else {
2195 int reset_phy = (method == RESET_TYPE_INVISIBLE ?
2196 EXCLUDE_FROM_RESET : 0);
2197
2198 EFX_POPULATE_OWORD_7(glb_ctl_reg_ker,
2199 EXT_PHY_RST_CTL, reset_phy,
2200 PCIE_CORE_RST_CTL, EXCLUDE_FROM_RESET,
2201 PCIE_NSTCK_RST_CTL, EXCLUDE_FROM_RESET,
2202 PCIE_SD_RST_CTL, EXCLUDE_FROM_RESET,
2203 EE_RST_CTL, EXCLUDE_FROM_RESET,
2204 EXT_PHY_RST_DUR, 0x7 /* 10ms */,
2205 SWRST, 1);
2206 }
2207 falcon_write(efx, &glb_ctl_reg_ker, GLB_CTL_REG_KER);
2208
2209 EFX_LOG(efx, "waiting for hardware reset\n");
2210 schedule_timeout_uninterruptible(HZ / 20);
2211
2212 /* Restore PCI configuration if needed */
2213 if (method == RESET_TYPE_WORLD) {
2214 if (FALCON_IS_DUAL_FUNC(efx)) {
2215 rc = pci_restore_state(nic_data->pci_dev2);
2216 if (rc) {
2217 EFX_ERR(efx, "failed to restore PCI config for "
2218 "the secondary function\n");
2219 goto fail3;
2220 }
2221 }
2222 rc = pci_restore_state(efx->pci_dev);
2223 if (rc) {
2224 EFX_ERR(efx, "failed to restore PCI config for the "
2225 "primary function\n");
2226 goto fail4;
2227 }
2228 EFX_LOG(efx, "successfully restored PCI config\n");
2229 }
2230
2231 /* Assert that reset complete */
2232 falcon_read(efx, &glb_ctl_reg_ker, GLB_CTL_REG_KER);
2233 if (EFX_OWORD_FIELD(glb_ctl_reg_ker, SWRST) != 0) {
2234 rc = -ETIMEDOUT;
2235 EFX_ERR(efx, "timed out waiting for hardware reset\n");
2236 goto fail5;
2237 }
2238 EFX_LOG(efx, "hardware reset complete\n");
2239
2240 return 0;
2241
2242 /* pci_save_state() and pci_restore_state() MUST be called in pairs */
2243fail2:
2244fail3:
2245 pci_restore_state(efx->pci_dev);
2246fail1:
2247fail4:
2248fail5:
2249 return rc;
2250}
2251
2252/* Zeroes out the SRAM contents. This routine must be called in
2253 * process context and is allowed to sleep.
2254 */
2255static int falcon_reset_sram(struct efx_nic *efx)
2256{
2257 efx_oword_t srm_cfg_reg_ker, gpio_cfg_reg_ker;
2258 int count;
2259
2260 /* Set the SRAM wake/sleep GPIO appropriately. */
2261 falcon_read(efx, &gpio_cfg_reg_ker, GPIO_CTL_REG_KER);
2262 EFX_SET_OWORD_FIELD(gpio_cfg_reg_ker, GPIO1_OEN, 1);
2263 EFX_SET_OWORD_FIELD(gpio_cfg_reg_ker, GPIO1_OUT, 1);
2264 falcon_write(efx, &gpio_cfg_reg_ker, GPIO_CTL_REG_KER);
2265
2266 /* Initiate SRAM reset */
2267 EFX_POPULATE_OWORD_2(srm_cfg_reg_ker,
2268 SRAM_OOB_BT_INIT_EN, 1,
2269 SRM_NUM_BANKS_AND_BANK_SIZE, 0);
2270 falcon_write(efx, &srm_cfg_reg_ker, SRM_CFG_REG_KER);
2271
2272 /* Wait for SRAM reset to complete */
2273 count = 0;
2274 do {
2275 EFX_LOG(efx, "waiting for SRAM reset (attempt %d)...\n", count);
2276
2277 /* SRAM reset is slow; expect around 16ms */
2278 schedule_timeout_uninterruptible(HZ / 50);
2279
2280 /* Check for reset complete */
2281 falcon_read(efx, &srm_cfg_reg_ker, SRM_CFG_REG_KER);
2282 if (!EFX_OWORD_FIELD(srm_cfg_reg_ker, SRAM_OOB_BT_INIT_EN)) {
2283 EFX_LOG(efx, "SRAM reset complete\n");
2284
2285 return 0;
2286 }
2287 } while (++count < 20); /* wait upto 0.4 sec */
2288
2289 EFX_ERR(efx, "timed out waiting for SRAM reset\n");
2290 return -ETIMEDOUT;
2291}
2292
2293/* Extract non-volatile configuration */
2294static int falcon_probe_nvconfig(struct efx_nic *efx)
2295{
2296 struct falcon_nvconfig *nvconfig;
2297 efx_oword_t nic_stat;
2298 int device_id;
2299 unsigned addr_len;
2300 size_t offset, len;
2301 int magic_num, struct_ver, board_rev;
2302 int rc;
2303
2304 /* Find the boot device. */
2305 falcon_read(efx, &nic_stat, NIC_STAT_REG);
2306 if (EFX_OWORD_FIELD(nic_stat, SF_PRST)) {
2307 device_id = EE_SPI_FLASH;
2308 addr_len = 3;
2309 } else if (EFX_OWORD_FIELD(nic_stat, EE_PRST)) {
2310 device_id = EE_SPI_EEPROM;
2311 addr_len = 2;
2312 } else {
2313 return -ENODEV;
2314 }
2315
2316 nvconfig = kmalloc(sizeof(*nvconfig), GFP_KERNEL);
2317
2318 /* Read the whole configuration structure into memory. */
2319 for (offset = 0; offset < sizeof(*nvconfig); offset += len) {
2320 len = min(sizeof(*nvconfig) - offset,
2321 (size_t) FALCON_SPI_MAX_LEN);
2322 rc = falcon_spi_read(efx, device_id, SPI_READ,
2323 NVCONFIG_BASE + offset, addr_len,
2324 (char *)nvconfig + offset, len);
2325 if (rc)
2326 goto out;
2327 }
2328
2329 /* Read the MAC addresses */
2330 memcpy(efx->mac_address, nvconfig->mac_address[0], ETH_ALEN);
2331
2332 /* Read the board configuration. */
2333 magic_num = le16_to_cpu(nvconfig->board_magic_num);
2334 struct_ver = le16_to_cpu(nvconfig->board_struct_ver);
2335
2336 if (magic_num != NVCONFIG_BOARD_MAGIC_NUM || struct_ver < 2) {
2337 EFX_ERR(efx, "Non volatile memory bad magic=%x ver=%x "
2338 "therefore using defaults\n", magic_num, struct_ver);
2339 efx->phy_type = PHY_TYPE_NONE;
2340 efx->mii.phy_id = PHY_ADDR_INVALID;
2341 board_rev = 0;
2342 } else {
2343 struct falcon_nvconfig_board_v2 *v2 = &nvconfig->board_v2;
2344
2345 efx->phy_type = v2->port0_phy_type;
2346 efx->mii.phy_id = v2->port0_phy_addr;
2347 board_rev = le16_to_cpu(v2->board_revision);
2348 }
2349
2350 EFX_LOG(efx, "PHY is %d phy_id %d\n", efx->phy_type, efx->mii.phy_id);
2351
2352 efx_set_board_info(efx, board_rev);
2353
2354 out:
2355 kfree(nvconfig);
2356 return rc;
2357}
2358
2359/* Probe the NIC variant (revision, ASIC vs FPGA, function count, port
2360 * count, port speed). Set workaround and feature flags accordingly.
2361 */
2362static int falcon_probe_nic_variant(struct efx_nic *efx)
2363{
2364 efx_oword_t altera_build;
2365
2366 falcon_read(efx, &altera_build, ALTERA_BUILD_REG_KER);
2367 if (EFX_OWORD_FIELD(altera_build, VER_ALL)) {
2368 EFX_ERR(efx, "Falcon FPGA not supported\n");
2369 return -ENODEV;
2370 }
2371
2372 switch (FALCON_REV(efx)) {
2373 case FALCON_REV_A0:
2374 case 0xff:
2375 EFX_ERR(efx, "Falcon rev A0 not supported\n");
2376 return -ENODEV;
2377
2378 case FALCON_REV_A1:{
2379 efx_oword_t nic_stat;
2380
2381 falcon_read(efx, &nic_stat, NIC_STAT_REG);
2382
2383 if (EFX_OWORD_FIELD(nic_stat, STRAP_PCIE) == 0) {
2384 EFX_ERR(efx, "Falcon rev A1 PCI-X not supported\n");
2385 return -ENODEV;
2386 }
2387 if (!EFX_OWORD_FIELD(nic_stat, STRAP_10G)) {
2388 EFX_ERR(efx, "1G mode not supported\n");
2389 return -ENODEV;
2390 }
2391 break;
2392 }
2393
2394 case FALCON_REV_B0:
2395 break;
2396
2397 default:
2398 EFX_ERR(efx, "Unknown Falcon rev %d\n", FALCON_REV(efx));
2399 return -ENODEV;
2400 }
2401
2402 return 0;
2403}
2404
2405int falcon_probe_nic(struct efx_nic *efx)
2406{
2407 struct falcon_nic_data *nic_data;
2408 int rc;
2409
2410 /* Initialise I2C interface state */
2411 efx->i2c.efx = efx;
2412 efx->i2c.op = &falcon_i2c_bit_operations;
2413 efx->i2c.sda = 1;
2414 efx->i2c.scl = 1;
2415
2416 /* Allocate storage for hardware specific data */
2417 nic_data = kzalloc(sizeof(*nic_data), GFP_KERNEL);
2418 efx->nic_data = (void *) nic_data;
2419
2420 /* Determine number of ports etc. */
2421 rc = falcon_probe_nic_variant(efx);
2422 if (rc)
2423 goto fail1;
2424
2425 /* Probe secondary function if expected */
2426 if (FALCON_IS_DUAL_FUNC(efx)) {
2427 struct pci_dev *dev = pci_dev_get(efx->pci_dev);
2428
2429 while ((dev = pci_get_device(EFX_VENDID_SFC, FALCON_A_S_DEVID,
2430 dev))) {
2431 if (dev->bus == efx->pci_dev->bus &&
2432 dev->devfn == efx->pci_dev->devfn + 1) {
2433 nic_data->pci_dev2 = dev;
2434 break;
2435 }
2436 }
2437 if (!nic_data->pci_dev2) {
2438 EFX_ERR(efx, "failed to find secondary function\n");
2439 rc = -ENODEV;
2440 goto fail2;
2441 }
2442 }
2443
2444 /* Now we can reset the NIC */
2445 rc = falcon_reset_hw(efx, RESET_TYPE_ALL);
2446 if (rc) {
2447 EFX_ERR(efx, "failed to reset NIC\n");
2448 goto fail3;
2449 }
2450
2451 /* Allocate memory for INT_KER */
2452 rc = falcon_alloc_buffer(efx, &efx->irq_status, sizeof(efx_oword_t));
2453 if (rc)
2454 goto fail4;
2455 BUG_ON(efx->irq_status.dma_addr & 0x0f);
2456
2457 EFX_LOG(efx, "INT_KER at %llx (virt %p phys %lx)\n",
2458 (unsigned long long)efx->irq_status.dma_addr,
2459 efx->irq_status.addr, virt_to_phys(efx->irq_status.addr));
2460
2461 /* Read in the non-volatile configuration */
2462 rc = falcon_probe_nvconfig(efx);
2463 if (rc)
2464 goto fail5;
2465
2466 return 0;
2467
2468 fail5:
2469 falcon_free_buffer(efx, &efx->irq_status);
2470 fail4:
2471 /* fall-thru */
2472 fail3:
2473 if (nic_data->pci_dev2) {
2474 pci_dev_put(nic_data->pci_dev2);
2475 nic_data->pci_dev2 = NULL;
2476 }
2477 fail2:
2478 /* fall-thru */
2479 fail1:
2480 kfree(efx->nic_data);
2481 return rc;
2482}
2483
2484/* This call performs hardware-specific global initialisation, such as
2485 * defining the descriptor cache sizes and number of RSS channels.
2486 * It does not set up any buffers, descriptor rings or event queues.
2487 */
2488int falcon_init_nic(struct efx_nic *efx)
2489{
2490 struct falcon_nic_data *data;
2491 efx_oword_t temp;
2492 unsigned thresh;
2493 int rc;
2494
2495 data = (struct falcon_nic_data *)efx->nic_data;
2496
2497 /* Set up the address region register. This is only needed
2498 * for the B0 FPGA, but since we are just pushing in the
2499 * reset defaults this may as well be unconditional. */
2500 EFX_POPULATE_OWORD_4(temp, ADR_REGION0, 0,
2501 ADR_REGION1, (1 << 16),
2502 ADR_REGION2, (2 << 16),
2503 ADR_REGION3, (3 << 16));
2504 falcon_write(efx, &temp, ADR_REGION_REG_KER);
2505
2506 /* Use on-chip SRAM */
2507 falcon_read(efx, &temp, NIC_STAT_REG);
2508 EFX_SET_OWORD_FIELD(temp, ONCHIP_SRAM, 1);
2509 falcon_write(efx, &temp, NIC_STAT_REG);
2510
2511 /* Set buffer table mode */
2512 EFX_POPULATE_OWORD_1(temp, BUF_TBL_MODE, BUF_TBL_MODE_FULL);
2513 falcon_write(efx, &temp, BUF_TBL_CFG_REG_KER);
2514
2515 rc = falcon_reset_sram(efx);
2516 if (rc)
2517 return rc;
2518
2519 /* Set positions of descriptor caches in SRAM. */
2520 EFX_POPULATE_OWORD_1(temp, SRM_TX_DC_BASE_ADR, TX_DC_BASE / 8);
2521 falcon_write(efx, &temp, SRM_TX_DC_CFG_REG_KER);
2522 EFX_POPULATE_OWORD_1(temp, SRM_RX_DC_BASE_ADR, RX_DC_BASE / 8);
2523 falcon_write(efx, &temp, SRM_RX_DC_CFG_REG_KER);
2524
2525 /* Set TX descriptor cache size. */
2526 BUILD_BUG_ON(TX_DC_ENTRIES != (16 << TX_DC_ENTRIES_ORDER));
2527 EFX_POPULATE_OWORD_1(temp, TX_DC_SIZE, TX_DC_ENTRIES_ORDER);
2528 falcon_write(efx, &temp, TX_DC_CFG_REG_KER);
2529
2530 /* Set RX descriptor cache size. Set low watermark to size-8, as
2531 * this allows most efficient prefetching.
2532 */
2533 BUILD_BUG_ON(RX_DC_ENTRIES != (16 << RX_DC_ENTRIES_ORDER));
2534 EFX_POPULATE_OWORD_1(temp, RX_DC_SIZE, RX_DC_ENTRIES_ORDER);
2535 falcon_write(efx, &temp, RX_DC_CFG_REG_KER);
2536 EFX_POPULATE_OWORD_1(temp, RX_DC_PF_LWM, RX_DC_ENTRIES - 8);
2537 falcon_write(efx, &temp, RX_DC_PF_WM_REG_KER);
2538
2539 /* Clear the parity enables on the TX data fifos as
2540 * they produce false parity errors because of timing issues
2541 */
2542 if (EFX_WORKAROUND_5129(efx)) {
2543 falcon_read(efx, &temp, SPARE_REG_KER);
2544 EFX_SET_OWORD_FIELD(temp, MEM_PERR_EN_TX_DATA, 0);
2545 falcon_write(efx, &temp, SPARE_REG_KER);
2546 }
2547
2548 /* Enable all the genuinely fatal interrupts. (They are still
2549 * masked by the overall interrupt mask, controlled by
2550 * falcon_interrupts()).
2551 *
2552 * Note: All other fatal interrupts are enabled
2553 */
2554 EFX_POPULATE_OWORD_3(temp,
2555 ILL_ADR_INT_KER_EN, 1,
2556 RBUF_OWN_INT_KER_EN, 1,
2557 TBUF_OWN_INT_KER_EN, 1);
2558 EFX_INVERT_OWORD(temp);
2559 falcon_write(efx, &temp, FATAL_INTR_REG_KER);
2560
2561 /* Set number of RSS queues for receive path. */
2562 falcon_read(efx, &temp, RX_FILTER_CTL_REG);
2563 if (FALCON_REV(efx) >= FALCON_REV_B0)
2564 EFX_SET_OWORD_FIELD(temp, NUM_KER, 0);
2565 else
2566 EFX_SET_OWORD_FIELD(temp, NUM_KER, efx->rss_queues - 1);
2567 if (EFX_WORKAROUND_7244(efx)) {
2568 EFX_SET_OWORD_FIELD(temp, UDP_FULL_SRCH_LIMIT, 8);
2569 EFX_SET_OWORD_FIELD(temp, UDP_WILD_SRCH_LIMIT, 8);
2570 EFX_SET_OWORD_FIELD(temp, TCP_FULL_SRCH_LIMIT, 8);
2571 EFX_SET_OWORD_FIELD(temp, TCP_WILD_SRCH_LIMIT, 8);
2572 }
2573 falcon_write(efx, &temp, RX_FILTER_CTL_REG);
2574
2575 falcon_setup_rss_indir_table(efx);
2576
2577 /* Setup RX. Wait for descriptor is broken and must
2578 * be disabled. RXDP recovery shouldn't be needed, but is.
2579 */
2580 falcon_read(efx, &temp, RX_SELF_RST_REG_KER);
2581 EFX_SET_OWORD_FIELD(temp, RX_NODESC_WAIT_DIS, 1);
2582 EFX_SET_OWORD_FIELD(temp, RX_RECOVERY_EN, 1);
2583 if (EFX_WORKAROUND_5583(efx))
2584 EFX_SET_OWORD_FIELD(temp, RX_ISCSI_DIS, 1);
2585 falcon_write(efx, &temp, RX_SELF_RST_REG_KER);
2586
2587 /* Disable the ugly timer-based TX DMA backoff and allow TX DMA to be
2588 * controlled by the RX FIFO fill level. Set arbitration to one pkt/Q.
2589 */
2590 falcon_read(efx, &temp, TX_CFG2_REG_KER);
2591 EFX_SET_OWORD_FIELD(temp, TX_RX_SPACER, 0xfe);
2592 EFX_SET_OWORD_FIELD(temp, TX_RX_SPACER_EN, 1);
2593 EFX_SET_OWORD_FIELD(temp, TX_ONE_PKT_PER_Q, 1);
2594 EFX_SET_OWORD_FIELD(temp, TX_CSR_PUSH_EN, 0);
2595 EFX_SET_OWORD_FIELD(temp, TX_DIS_NON_IP_EV, 1);
2596 /* Enable SW_EV to inherit in char driver - assume harmless here */
2597 EFX_SET_OWORD_FIELD(temp, TX_SW_EV_EN, 1);
2598 /* Prefetch threshold 2 => fetch when descriptor cache half empty */
2599 EFX_SET_OWORD_FIELD(temp, TX_PREF_THRESHOLD, 2);
2600 /* Squash TX of packets of 16 bytes or less */
2601 if (FALCON_REV(efx) >= FALCON_REV_B0 && EFX_WORKAROUND_9141(efx))
2602 EFX_SET_OWORD_FIELD(temp, TX_FLUSH_MIN_LEN_EN_B0, 1);
2603 falcon_write(efx, &temp, TX_CFG2_REG_KER);
2604
2605 /* Do not enable TX_NO_EOP_DISC_EN, since it limits packets to 16
2606 * descriptors (which is bad).
2607 */
2608 falcon_read(efx, &temp, TX_CFG_REG_KER);
2609 EFX_SET_OWORD_FIELD(temp, TX_NO_EOP_DISC_EN, 0);
2610 falcon_write(efx, &temp, TX_CFG_REG_KER);
2611
2612 /* RX config */
2613 falcon_read(efx, &temp, RX_CFG_REG_KER);
2614 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_DESC_PUSH_EN, 0);
2615 if (EFX_WORKAROUND_7575(efx))
2616 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_USR_BUF_SIZE,
2617 (3 * 4096) / 32);
2618 if (FALCON_REV(efx) >= FALCON_REV_B0)
2619 EFX_SET_OWORD_FIELD(temp, RX_INGR_EN_B0, 1);
2620
2621 /* RX FIFO flow control thresholds */
2622 thresh = ((rx_xon_thresh_bytes >= 0) ?
2623 rx_xon_thresh_bytes : efx->type->rx_xon_thresh);
2624 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XON_MAC_TH, thresh / 256);
2625 thresh = ((rx_xoff_thresh_bytes >= 0) ?
2626 rx_xoff_thresh_bytes : efx->type->rx_xoff_thresh);
2627 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XOFF_MAC_TH, thresh / 256);
2628 /* RX control FIFO thresholds [32 entries] */
2629 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XON_TX_TH, 25);
2630 EFX_SET_OWORD_FIELD_VER(efx, temp, RX_XOFF_TX_TH, 20);
2631 falcon_write(efx, &temp, RX_CFG_REG_KER);
2632
2633 /* Set destination of both TX and RX Flush events */
2634 if (FALCON_REV(efx) >= FALCON_REV_B0) {
2635 EFX_POPULATE_OWORD_1(temp, FLS_EVQ_ID, 0);
2636 falcon_write(efx, &temp, DP_CTRL_REG);
2637 }
2638
2639 return 0;
2640}
2641
2642void falcon_remove_nic(struct efx_nic *efx)
2643{
2644 struct falcon_nic_data *nic_data = efx->nic_data;
2645
2646 falcon_free_buffer(efx, &efx->irq_status);
2647
2648 (void) falcon_reset_hw(efx, RESET_TYPE_ALL);
2649
2650 /* Release the second function after the reset */
2651 if (nic_data->pci_dev2) {
2652 pci_dev_put(nic_data->pci_dev2);
2653 nic_data->pci_dev2 = NULL;
2654 }
2655
2656 /* Tear down the private nic state */
2657 kfree(efx->nic_data);
2658 efx->nic_data = NULL;
2659}
2660
2661void falcon_update_nic_stats(struct efx_nic *efx)
2662{
2663 efx_oword_t cnt;
2664
2665 falcon_read(efx, &cnt, RX_NODESC_DROP_REG_KER);
2666 efx->n_rx_nodesc_drop_cnt += EFX_OWORD_FIELD(cnt, RX_NODESC_DROP_CNT);
2667}
2668
2669/**************************************************************************
2670 *
2671 * Revision-dependent attributes used by efx.c
2672 *
2673 **************************************************************************
2674 */
2675
2676struct efx_nic_type falcon_a_nic_type = {
2677 .mem_bar = 2,
2678 .mem_map_size = 0x20000,
2679 .txd_ptr_tbl_base = TX_DESC_PTR_TBL_KER_A1,
2680 .rxd_ptr_tbl_base = RX_DESC_PTR_TBL_KER_A1,
2681 .buf_tbl_base = BUF_TBL_KER_A1,
2682 .evq_ptr_tbl_base = EVQ_PTR_TBL_KER_A1,
2683 .evq_rptr_tbl_base = EVQ_RPTR_REG_KER_A1,
2684 .txd_ring_mask = FALCON_TXD_RING_MASK,
2685 .rxd_ring_mask = FALCON_RXD_RING_MASK,
2686 .evq_size = FALCON_EVQ_SIZE,
2687 .max_dma_mask = FALCON_DMA_MASK,
2688 .tx_dma_mask = FALCON_TX_DMA_MASK,
2689 .bug5391_mask = 0xf,
2690 .rx_xoff_thresh = 2048,
2691 .rx_xon_thresh = 512,
2692 .rx_buffer_padding = 0x24,
2693 .max_interrupt_mode = EFX_INT_MODE_MSI,
2694 .phys_addr_channels = 4,
2695};
2696
2697struct efx_nic_type falcon_b_nic_type = {
2698 .mem_bar = 2,
2699 /* Map everything up to and including the RSS indirection
2700 * table. Don't map MSI-X table, MSI-X PBA since Linux
2701 * requires that they not be mapped. */
2702 .mem_map_size = RX_RSS_INDIR_TBL_B0 + 0x800,
2703 .txd_ptr_tbl_base = TX_DESC_PTR_TBL_KER_B0,
2704 .rxd_ptr_tbl_base = RX_DESC_PTR_TBL_KER_B0,
2705 .buf_tbl_base = BUF_TBL_KER_B0,
2706 .evq_ptr_tbl_base = EVQ_PTR_TBL_KER_B0,
2707 .evq_rptr_tbl_base = EVQ_RPTR_REG_KER_B0,
2708 .txd_ring_mask = FALCON_TXD_RING_MASK,
2709 .rxd_ring_mask = FALCON_RXD_RING_MASK,
2710 .evq_size = FALCON_EVQ_SIZE,
2711 .max_dma_mask = FALCON_DMA_MASK,
2712 .tx_dma_mask = FALCON_TX_DMA_MASK,
2713 .bug5391_mask = 0,
2714 .rx_xoff_thresh = 54272, /* ~80Kb - 3*max MTU */
2715 .rx_xon_thresh = 27648, /* ~3*max MTU */
2716 .rx_buffer_padding = 0,
2717 .max_interrupt_mode = EFX_INT_MODE_MSIX,
2718 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
2719 * interrupt handler only supports 32
2720 * channels */
2721};
2722
diff --git a/drivers/net/sfc/falcon.h b/drivers/net/sfc/falcon.h
new file mode 100644
index 000000000000..6117403b0c03
--- /dev/null
+++ b/drivers/net/sfc/falcon.h
@@ -0,0 +1,130 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_FALCON_H
12#define EFX_FALCON_H
13
14#include "net_driver.h"
15
16/*
17 * Falcon hardware control
18 */
19
20enum falcon_revision {
21 FALCON_REV_A0 = 0,
22 FALCON_REV_A1 = 1,
23 FALCON_REV_B0 = 2,
24};
25
26#define FALCON_REV(efx) ((efx)->pci_dev->revision)
27
28extern struct efx_nic_type falcon_a_nic_type;
29extern struct efx_nic_type falcon_b_nic_type;
30
31/**************************************************************************
32 *
33 * Externs
34 *
35 **************************************************************************
36 */
37
38/* TX data path */
39extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
40extern int falcon_init_tx(struct efx_tx_queue *tx_queue);
41extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
42extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
43extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
44
45/* RX data path */
46extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
47extern int falcon_init_rx(struct efx_rx_queue *rx_queue);
48extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
49extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
50extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
51
52/* Event data path */
53extern int falcon_probe_eventq(struct efx_channel *channel);
54extern int falcon_init_eventq(struct efx_channel *channel);
55extern void falcon_fini_eventq(struct efx_channel *channel);
56extern void falcon_remove_eventq(struct efx_channel *channel);
57extern int falcon_process_eventq(struct efx_channel *channel, int *rx_quota);
58extern void falcon_eventq_read_ack(struct efx_channel *channel);
59
60/* Ports */
61extern int falcon_probe_port(struct efx_nic *efx);
62extern void falcon_remove_port(struct efx_nic *efx);
63
64/* MAC/PHY */
65extern int falcon_xaui_link_ok(struct efx_nic *efx);
66extern int falcon_dma_stats(struct efx_nic *efx,
67 unsigned int done_offset);
68extern void falcon_drain_tx_fifo(struct efx_nic *efx);
69extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
70extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
71
72/* Interrupts and test events */
73extern int falcon_init_interrupt(struct efx_nic *efx);
74extern void falcon_enable_interrupts(struct efx_nic *efx);
75extern void falcon_generate_test_event(struct efx_channel *channel,
76 unsigned int magic);
77extern void falcon_generate_interrupt(struct efx_nic *efx);
78extern void falcon_set_int_moderation(struct efx_channel *channel);
79extern void falcon_disable_interrupts(struct efx_nic *efx);
80extern void falcon_fini_interrupt(struct efx_nic *efx);
81
82/* Global Resources */
83extern int falcon_probe_nic(struct efx_nic *efx);
84extern int falcon_probe_resources(struct efx_nic *efx);
85extern int falcon_init_nic(struct efx_nic *efx);
86extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
87extern void falcon_remove_resources(struct efx_nic *efx);
88extern void falcon_remove_nic(struct efx_nic *efx);
89extern void falcon_update_nic_stats(struct efx_nic *efx);
90extern void falcon_set_multicast_hash(struct efx_nic *efx);
91extern int falcon_reset_xaui(struct efx_nic *efx);
92
93/**************************************************************************
94 *
95 * Falcon MAC stats
96 *
97 **************************************************************************
98 */
99
100#define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
101#define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
102
103/* Retrieve statistic from statistics block */
104#define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
105 if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
106 (efx)->mac_stats.efx_stat += le16_to_cpu( \
107 *((__force __le16 *) \
108 (efx->stats_buffer.addr + \
109 FALCON_STAT_OFFSET(falcon_stat)))); \
110 else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
111 (efx)->mac_stats.efx_stat += le32_to_cpu( \
112 *((__force __le32 *) \
113 (efx->stats_buffer.addr + \
114 FALCON_STAT_OFFSET(falcon_stat)))); \
115 else \
116 (efx)->mac_stats.efx_stat += le64_to_cpu( \
117 *((__force __le64 *) \
118 (efx->stats_buffer.addr + \
119 FALCON_STAT_OFFSET(falcon_stat)))); \
120 } while (0)
121
122#define FALCON_MAC_STATS_SIZE 0x100
123
124#define MAC_DATA_LBN 0
125#define MAC_DATA_WIDTH 32
126
127extern void falcon_generate_event(struct efx_channel *channel,
128 efx_qword_t *event);
129
130#endif /* EFX_FALCON_H */
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
new file mode 100644
index 000000000000..0485a63eaff6
--- /dev/null
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -0,0 +1,1135 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_FALCON_HWDEFS_H
12#define EFX_FALCON_HWDEFS_H
13
14/*
15 * Falcon hardware value definitions.
16 * Falcon is the internal codename for the SFC4000 controller that is
17 * present in SFE400X evaluation boards
18 */
19
20/**************************************************************************
21 *
22 * Falcon registers
23 *
24 **************************************************************************
25 */
26
27/* Address region register */
28#define ADR_REGION_REG_KER 0x00
29#define ADR_REGION0_LBN 0
30#define ADR_REGION0_WIDTH 18
31#define ADR_REGION1_LBN 32
32#define ADR_REGION1_WIDTH 18
33#define ADR_REGION2_LBN 64
34#define ADR_REGION2_WIDTH 18
35#define ADR_REGION3_LBN 96
36#define ADR_REGION3_WIDTH 18
37
38/* Interrupt enable register */
39#define INT_EN_REG_KER 0x0010
40#define KER_INT_KER_LBN 3
41#define KER_INT_KER_WIDTH 1
42#define DRV_INT_EN_KER_LBN 0
43#define DRV_INT_EN_KER_WIDTH 1
44
45/* Interrupt status address register */
46#define INT_ADR_REG_KER 0x0030
47#define NORM_INT_VEC_DIS_KER_LBN 64
48#define NORM_INT_VEC_DIS_KER_WIDTH 1
49#define INT_ADR_KER_LBN 0
50#define INT_ADR_KER_WIDTH EFX_DMA_TYPE_WIDTH(64) /* not 46 for this one */
51
52/* Interrupt status register (B0 only) */
53#define INT_ISR0_B0 0x90
54#define INT_ISR1_B0 0xA0
55
56/* Interrupt acknowledge register (A0/A1 only) */
57#define INT_ACK_REG_KER_A1 0x0050
58#define INT_ACK_DUMMY_DATA_LBN 0
59#define INT_ACK_DUMMY_DATA_WIDTH 32
60
61/* Interrupt acknowledge work-around register (A0/A1 only )*/
62#define WORK_AROUND_BROKEN_PCI_READS_REG_KER_A1 0x0070
63
64/* SPI host command register */
65#define EE_SPI_HCMD_REG_KER 0x0100
66#define EE_SPI_HCMD_CMD_EN_LBN 31
67#define EE_SPI_HCMD_CMD_EN_WIDTH 1
68#define EE_WR_TIMER_ACTIVE_LBN 28
69#define EE_WR_TIMER_ACTIVE_WIDTH 1
70#define EE_SPI_HCMD_SF_SEL_LBN 24
71#define EE_SPI_HCMD_SF_SEL_WIDTH 1
72#define EE_SPI_EEPROM 0
73#define EE_SPI_FLASH 1
74#define EE_SPI_HCMD_DABCNT_LBN 16
75#define EE_SPI_HCMD_DABCNT_WIDTH 5
76#define EE_SPI_HCMD_READ_LBN 15
77#define EE_SPI_HCMD_READ_WIDTH 1
78#define EE_SPI_READ 1
79#define EE_SPI_WRITE 0
80#define EE_SPI_HCMD_DUBCNT_LBN 12
81#define EE_SPI_HCMD_DUBCNT_WIDTH 2
82#define EE_SPI_HCMD_ADBCNT_LBN 8
83#define EE_SPI_HCMD_ADBCNT_WIDTH 2
84#define EE_SPI_HCMD_ENC_LBN 0
85#define EE_SPI_HCMD_ENC_WIDTH 8
86
87/* SPI host address register */
88#define EE_SPI_HADR_REG_KER 0x0110
89#define EE_SPI_HADR_ADR_LBN 0
90#define EE_SPI_HADR_ADR_WIDTH 24
91
92/* SPI host data register */
93#define EE_SPI_HDATA_REG_KER 0x0120
94
95/* PCIE CORE ACCESS REG */
96#define PCIE_CORE_ADDR_PCIE_DEVICE_CTRL_STAT 0x68
97#define PCIE_CORE_ADDR_PCIE_LINK_CTRL_STAT 0x70
98#define PCIE_CORE_ADDR_ACK_RPL_TIMER 0x700
99#define PCIE_CORE_ADDR_ACK_FREQ 0x70C
100
101/* NIC status register */
102#define NIC_STAT_REG 0x0200
103#define ONCHIP_SRAM_LBN 16
104#define ONCHIP_SRAM_WIDTH 1
105#define SF_PRST_LBN 9
106#define SF_PRST_WIDTH 1
107#define EE_PRST_LBN 8
108#define EE_PRST_WIDTH 1
109/* See pic_mode_t for decoding of this field */
110/* These bit definitions are extrapolated from the list of numerical
111 * values for STRAP_PINS.
112 */
113#define STRAP_10G_LBN 2
114#define STRAP_10G_WIDTH 1
115#define STRAP_PCIE_LBN 0
116#define STRAP_PCIE_WIDTH 1
117
118/* GPIO control register */
119#define GPIO_CTL_REG_KER 0x0210
120#define GPIO_OUTPUTS_LBN (16)
121#define GPIO_OUTPUTS_WIDTH (4)
122#define GPIO_INPUTS_LBN (8)
123#define GPIO_DIRECTION_LBN (24)
124#define GPIO_DIRECTION_WIDTH (4)
125#define GPIO_DIRECTION_OUT (1)
126#define GPIO_SRAM_SLEEP (1 << 1)
127
128#define GPIO3_OEN_LBN (GPIO_DIRECTION_LBN + 3)
129#define GPIO3_OEN_WIDTH 1
130#define GPIO2_OEN_LBN (GPIO_DIRECTION_LBN + 2)
131#define GPIO2_OEN_WIDTH 1
132#define GPIO1_OEN_LBN (GPIO_DIRECTION_LBN + 1)
133#define GPIO1_OEN_WIDTH 1
134#define GPIO0_OEN_LBN (GPIO_DIRECTION_LBN + 0)
135#define GPIO0_OEN_WIDTH 1
136
137#define GPIO3_OUT_LBN (GPIO_OUTPUTS_LBN + 3)
138#define GPIO3_OUT_WIDTH 1
139#define GPIO2_OUT_LBN (GPIO_OUTPUTS_LBN + 2)
140#define GPIO2_OUT_WIDTH 1
141#define GPIO1_OUT_LBN (GPIO_OUTPUTS_LBN + 1)
142#define GPIO1_OUT_WIDTH 1
143#define GPIO0_OUT_LBN (GPIO_OUTPUTS_LBN + 0)
144#define GPIO0_OUT_WIDTH 1
145
146#define GPIO3_IN_LBN (GPIO_INPUTS_LBN + 3)
147#define GPIO3_IN_WIDTH 1
148#define GPIO2_IN_WIDTH 1
149#define GPIO1_IN_WIDTH 1
150#define GPIO0_IN_LBN (GPIO_INPUTS_LBN + 0)
151#define GPIO0_IN_WIDTH 1
152
153/* Global control register */
154#define GLB_CTL_REG_KER 0x0220
155#define EXT_PHY_RST_CTL_LBN 63
156#define EXT_PHY_RST_CTL_WIDTH 1
157#define PCIE_SD_RST_CTL_LBN 61
158#define PCIE_SD_RST_CTL_WIDTH 1
159
160#define PCIE_NSTCK_RST_CTL_LBN 58
161#define PCIE_NSTCK_RST_CTL_WIDTH 1
162#define PCIE_CORE_RST_CTL_LBN 57
163#define PCIE_CORE_RST_CTL_WIDTH 1
164#define EE_RST_CTL_LBN 49
165#define EE_RST_CTL_WIDTH 1
166#define RST_XGRX_LBN 24
167#define RST_XGRX_WIDTH 1
168#define RST_XGTX_LBN 23
169#define RST_XGTX_WIDTH 1
170#define RST_EM_LBN 22
171#define RST_EM_WIDTH 1
172#define EXT_PHY_RST_DUR_LBN 1
173#define EXT_PHY_RST_DUR_WIDTH 3
174#define SWRST_LBN 0
175#define SWRST_WIDTH 1
176#define INCLUDE_IN_RESET 0
177#define EXCLUDE_FROM_RESET 1
178
179/* Fatal interrupt register */
180#define FATAL_INTR_REG_KER 0x0230
181#define RBUF_OWN_INT_KER_EN_LBN 39
182#define RBUF_OWN_INT_KER_EN_WIDTH 1
183#define TBUF_OWN_INT_KER_EN_LBN 38
184#define TBUF_OWN_INT_KER_EN_WIDTH 1
185#define ILL_ADR_INT_KER_EN_LBN 33
186#define ILL_ADR_INT_KER_EN_WIDTH 1
187#define MEM_PERR_INT_KER_LBN 8
188#define MEM_PERR_INT_KER_WIDTH 1
189#define INT_KER_ERROR_LBN 0
190#define INT_KER_ERROR_WIDTH 12
191
192#define DP_CTRL_REG 0x250
193#define FLS_EVQ_ID_LBN 0
194#define FLS_EVQ_ID_WIDTH 11
195
196#define MEM_STAT_REG_KER 0x260
197
198/* Debug probe register */
199#define DEBUG_BLK_SEL_MISC 7
200#define DEBUG_BLK_SEL_SERDES 6
201#define DEBUG_BLK_SEL_EM 5
202#define DEBUG_BLK_SEL_SR 4
203#define DEBUG_BLK_SEL_EV 3
204#define DEBUG_BLK_SEL_RX 2
205#define DEBUG_BLK_SEL_TX 1
206#define DEBUG_BLK_SEL_BIU 0
207
208/* FPGA build version */
209#define ALTERA_BUILD_REG_KER 0x0300
210#define VER_ALL_LBN 0
211#define VER_ALL_WIDTH 32
212
213/* Spare EEPROM bits register (flash 0x390) */
214#define SPARE_REG_KER 0x310
215#define MEM_PERR_EN_TX_DATA_LBN 72
216#define MEM_PERR_EN_TX_DATA_WIDTH 2
217
218/* Timer table for kernel access */
219#define TIMER_CMD_REG_KER 0x420
220#define TIMER_MODE_LBN 12
221#define TIMER_MODE_WIDTH 2
222#define TIMER_MODE_DIS 0
223#define TIMER_MODE_INT_HLDOFF 2
224#define TIMER_VAL_LBN 0
225#define TIMER_VAL_WIDTH 12
226
227/* Driver generated event register */
228#define DRV_EV_REG_KER 0x440
229#define DRV_EV_QID_LBN 64
230#define DRV_EV_QID_WIDTH 12
231#define DRV_EV_DATA_LBN 0
232#define DRV_EV_DATA_WIDTH 64
233
234/* Buffer table configuration register */
235#define BUF_TBL_CFG_REG_KER 0x600
236#define BUF_TBL_MODE_LBN 3
237#define BUF_TBL_MODE_WIDTH 1
238#define BUF_TBL_MODE_HALF 0
239#define BUF_TBL_MODE_FULL 1
240
241/* SRAM receive descriptor cache configuration register */
242#define SRM_RX_DC_CFG_REG_KER 0x610
243#define SRM_RX_DC_BASE_ADR_LBN 0
244#define SRM_RX_DC_BASE_ADR_WIDTH 21
245
246/* SRAM transmit descriptor cache configuration register */
247#define SRM_TX_DC_CFG_REG_KER 0x620
248#define SRM_TX_DC_BASE_ADR_LBN 0
249#define SRM_TX_DC_BASE_ADR_WIDTH 21
250
251/* SRAM configuration register */
252#define SRM_CFG_REG_KER 0x630
253#define SRAM_OOB_BT_INIT_EN_LBN 3
254#define SRAM_OOB_BT_INIT_EN_WIDTH 1
255#define SRM_NUM_BANKS_AND_BANK_SIZE_LBN 0
256#define SRM_NUM_BANKS_AND_BANK_SIZE_WIDTH 3
257#define SRM_NB_BSZ_1BANKS_2M 0
258#define SRM_NB_BSZ_1BANKS_4M 1
259#define SRM_NB_BSZ_1BANKS_8M 2
260#define SRM_NB_BSZ_DEFAULT 3 /* char driver will set the default */
261#define SRM_NB_BSZ_2BANKS_4M 4
262#define SRM_NB_BSZ_2BANKS_8M 5
263#define SRM_NB_BSZ_2BANKS_16M 6
264#define SRM_NB_BSZ_RESERVED 7
265
266/* Special buffer table update register */
267#define BUF_TBL_UPD_REG_KER 0x0650
268#define BUF_UPD_CMD_LBN 63
269#define BUF_UPD_CMD_WIDTH 1
270#define BUF_CLR_CMD_LBN 62
271#define BUF_CLR_CMD_WIDTH 1
272#define BUF_CLR_END_ID_LBN 32
273#define BUF_CLR_END_ID_WIDTH 20
274#define BUF_CLR_START_ID_LBN 0
275#define BUF_CLR_START_ID_WIDTH 20
276
277/* Receive configuration register */
278#define RX_CFG_REG_KER 0x800
279
280/* B0 */
281#define RX_INGR_EN_B0_LBN 47
282#define RX_INGR_EN_B0_WIDTH 1
283#define RX_DESC_PUSH_EN_B0_LBN 43
284#define RX_DESC_PUSH_EN_B0_WIDTH 1
285#define RX_XON_TX_TH_B0_LBN 33
286#define RX_XON_TX_TH_B0_WIDTH 5
287#define RX_XOFF_TX_TH_B0_LBN 28
288#define RX_XOFF_TX_TH_B0_WIDTH 5
289#define RX_USR_BUF_SIZE_B0_LBN 19
290#define RX_USR_BUF_SIZE_B0_WIDTH 9
291#define RX_XON_MAC_TH_B0_LBN 10
292#define RX_XON_MAC_TH_B0_WIDTH 9
293#define RX_XOFF_MAC_TH_B0_LBN 1
294#define RX_XOFF_MAC_TH_B0_WIDTH 9
295#define RX_XOFF_MAC_EN_B0_LBN 0
296#define RX_XOFF_MAC_EN_B0_WIDTH 1
297
298/* A1 */
299#define RX_DESC_PUSH_EN_A1_LBN 35
300#define RX_DESC_PUSH_EN_A1_WIDTH 1
301#define RX_XON_TX_TH_A1_LBN 25
302#define RX_XON_TX_TH_A1_WIDTH 5
303#define RX_XOFF_TX_TH_A1_LBN 20
304#define RX_XOFF_TX_TH_A1_WIDTH 5
305#define RX_USR_BUF_SIZE_A1_LBN 11
306#define RX_USR_BUF_SIZE_A1_WIDTH 9
307#define RX_XON_MAC_TH_A1_LBN 6
308#define RX_XON_MAC_TH_A1_WIDTH 5
309#define RX_XOFF_MAC_TH_A1_LBN 1
310#define RX_XOFF_MAC_TH_A1_WIDTH 5
311#define RX_XOFF_MAC_EN_A1_LBN 0
312#define RX_XOFF_MAC_EN_A1_WIDTH 1
313
314/* Receive filter control register */
315#define RX_FILTER_CTL_REG 0x810
316#define UDP_FULL_SRCH_LIMIT_LBN 32
317#define UDP_FULL_SRCH_LIMIT_WIDTH 8
318#define NUM_KER_LBN 24
319#define NUM_KER_WIDTH 2
320#define UDP_WILD_SRCH_LIMIT_LBN 16
321#define UDP_WILD_SRCH_LIMIT_WIDTH 8
322#define TCP_WILD_SRCH_LIMIT_LBN 8
323#define TCP_WILD_SRCH_LIMIT_WIDTH 8
324#define TCP_FULL_SRCH_LIMIT_LBN 0
325#define TCP_FULL_SRCH_LIMIT_WIDTH 8
326
327/* RX queue flush register */
328#define RX_FLUSH_DESCQ_REG_KER 0x0820
329#define RX_FLUSH_DESCQ_CMD_LBN 24
330#define RX_FLUSH_DESCQ_CMD_WIDTH 1
331#define RX_FLUSH_DESCQ_LBN 0
332#define RX_FLUSH_DESCQ_WIDTH 12
333
334/* Receive descriptor update register */
335#define RX_DESC_UPD_REG_KER_DWORD (0x830 + 12)
336#define RX_DESC_WPTR_DWORD_LBN 0
337#define RX_DESC_WPTR_DWORD_WIDTH 12
338
339/* Receive descriptor cache configuration register */
340#define RX_DC_CFG_REG_KER 0x840
341#define RX_DC_SIZE_LBN 0
342#define RX_DC_SIZE_WIDTH 2
343
344#define RX_DC_PF_WM_REG_KER 0x850
345#define RX_DC_PF_LWM_LBN 0
346#define RX_DC_PF_LWM_WIDTH 6
347
348/* RX no descriptor drop counter */
349#define RX_NODESC_DROP_REG_KER 0x880
350#define RX_NODESC_DROP_CNT_LBN 0
351#define RX_NODESC_DROP_CNT_WIDTH 16
352
353/* RX black magic register */
354#define RX_SELF_RST_REG_KER 0x890
355#define RX_ISCSI_DIS_LBN 17
356#define RX_ISCSI_DIS_WIDTH 1
357#define RX_NODESC_WAIT_DIS_LBN 9
358#define RX_NODESC_WAIT_DIS_WIDTH 1
359#define RX_RECOVERY_EN_LBN 8
360#define RX_RECOVERY_EN_WIDTH 1
361
362/* TX queue flush register */
363#define TX_FLUSH_DESCQ_REG_KER 0x0a00
364#define TX_FLUSH_DESCQ_CMD_LBN 12
365#define TX_FLUSH_DESCQ_CMD_WIDTH 1
366#define TX_FLUSH_DESCQ_LBN 0
367#define TX_FLUSH_DESCQ_WIDTH 12
368
369/* Transmit descriptor update register */
370#define TX_DESC_UPD_REG_KER_DWORD (0xa10 + 12)
371#define TX_DESC_WPTR_DWORD_LBN 0
372#define TX_DESC_WPTR_DWORD_WIDTH 12
373
374/* Transmit descriptor cache configuration register */
375#define TX_DC_CFG_REG_KER 0xa20
376#define TX_DC_SIZE_LBN 0
377#define TX_DC_SIZE_WIDTH 2
378
379/* Transmit checksum configuration register (A0/A1 only) */
380#define TX_CHKSM_CFG_REG_KER_A1 0xa30
381
382/* Transmit configuration register */
383#define TX_CFG_REG_KER 0xa50
384#define TX_NO_EOP_DISC_EN_LBN 5
385#define TX_NO_EOP_DISC_EN_WIDTH 1
386
387/* Transmit configuration register 2 */
388#define TX_CFG2_REG_KER 0xa80
389#define TX_CSR_PUSH_EN_LBN 89
390#define TX_CSR_PUSH_EN_WIDTH 1
391#define TX_RX_SPACER_LBN 64
392#define TX_RX_SPACER_WIDTH 8
393#define TX_SW_EV_EN_LBN 59
394#define TX_SW_EV_EN_WIDTH 1
395#define TX_RX_SPACER_EN_LBN 57
396#define TX_RX_SPACER_EN_WIDTH 1
397#define TX_PREF_THRESHOLD_LBN 19
398#define TX_PREF_THRESHOLD_WIDTH 2
399#define TX_ONE_PKT_PER_Q_LBN 18
400#define TX_ONE_PKT_PER_Q_WIDTH 1
401#define TX_DIS_NON_IP_EV_LBN 17
402#define TX_DIS_NON_IP_EV_WIDTH 1
403#define TX_FLUSH_MIN_LEN_EN_B0_LBN 7
404#define TX_FLUSH_MIN_LEN_EN_B0_WIDTH 1
405
406/* PHY management transmit data register */
407#define MD_TXD_REG_KER 0xc00
408#define MD_TXD_LBN 0
409#define MD_TXD_WIDTH 16
410
411/* PHY management receive data register */
412#define MD_RXD_REG_KER 0xc10
413#define MD_RXD_LBN 0
414#define MD_RXD_WIDTH 16
415
416/* PHY management configuration & status register */
417#define MD_CS_REG_KER 0xc20
418#define MD_GC_LBN 4
419#define MD_GC_WIDTH 1
420#define MD_RIC_LBN 2
421#define MD_RIC_WIDTH 1
422#define MD_RDC_LBN 1
423#define MD_RDC_WIDTH 1
424#define MD_WRC_LBN 0
425#define MD_WRC_WIDTH 1
426
427/* PHY management PHY address register */
428#define MD_PHY_ADR_REG_KER 0xc30
429#define MD_PHY_ADR_LBN 0
430#define MD_PHY_ADR_WIDTH 16
431
432/* PHY management ID register */
433#define MD_ID_REG_KER 0xc40
434#define MD_PRT_ADR_LBN 11
435#define MD_PRT_ADR_WIDTH 5
436#define MD_DEV_ADR_LBN 6
437#define MD_DEV_ADR_WIDTH 5
438/* Used for writing both at once */
439#define MD_PRT_DEV_ADR_LBN 6
440#define MD_PRT_DEV_ADR_WIDTH 10
441
442/* PHY management status & mask register (DWORD read only) */
443#define MD_STAT_REG_KER 0xc50
444#define MD_BSERR_LBN 2
445#define MD_BSERR_WIDTH 1
446#define MD_LNFL_LBN 1
447#define MD_LNFL_WIDTH 1
448#define MD_BSY_LBN 0
449#define MD_BSY_WIDTH 1
450
451/* Port 0 and 1 MAC stats registers */
452#define MAC0_STAT_DMA_REG_KER 0xc60
453#define MAC_STAT_DMA_CMD_LBN 48
454#define MAC_STAT_DMA_CMD_WIDTH 1
455#define MAC_STAT_DMA_ADR_LBN 0
456#define MAC_STAT_DMA_ADR_WIDTH EFX_DMA_TYPE_WIDTH(46)
457
458/* Port 0 and 1 MAC control registers */
459#define MAC0_CTRL_REG_KER 0xc80
460#define MAC_XOFF_VAL_LBN 16
461#define MAC_XOFF_VAL_WIDTH 16
462#define TXFIFO_DRAIN_EN_B0_LBN 7
463#define TXFIFO_DRAIN_EN_B0_WIDTH 1
464#define MAC_BCAD_ACPT_LBN 4
465#define MAC_BCAD_ACPT_WIDTH 1
466#define MAC_UC_PROM_LBN 3
467#define MAC_UC_PROM_WIDTH 1
468#define MAC_LINK_STATUS_LBN 2
469#define MAC_LINK_STATUS_WIDTH 1
470#define MAC_SPEED_LBN 0
471#define MAC_SPEED_WIDTH 2
472
473/* 10G XAUI XGXS default values */
474#define XX_TXDRV_DEQ_DEFAULT 0xe /* deq=.6 */
475#define XX_TXDRV_DTX_DEFAULT 0x5 /* 1.25 */
476#define XX_SD_CTL_DRV_DEFAULT 0 /* 20mA */
477
478/* Multicast address hash table */
479#define MAC_MCAST_HASH_REG0_KER 0xca0
480#define MAC_MCAST_HASH_REG1_KER 0xcb0
481
482/* GMAC registers */
483#define FALCON_GMAC_REGBANK 0xe00
484#define FALCON_GMAC_REGBANK_SIZE 0x200
485#define FALCON_GMAC_REG_SIZE 0x10
486
487/* XMAC registers */
488#define FALCON_XMAC_REGBANK 0x1200
489#define FALCON_XMAC_REGBANK_SIZE 0x200
490#define FALCON_XMAC_REG_SIZE 0x10
491
492/* XGMAC address register low */
493#define XM_ADR_LO_REG_MAC 0x00
494#define XM_ADR_3_LBN 24
495#define XM_ADR_3_WIDTH 8
496#define XM_ADR_2_LBN 16
497#define XM_ADR_2_WIDTH 8
498#define XM_ADR_1_LBN 8
499#define XM_ADR_1_WIDTH 8
500#define XM_ADR_0_LBN 0
501#define XM_ADR_0_WIDTH 8
502
503/* XGMAC address register high */
504#define XM_ADR_HI_REG_MAC 0x01
505#define XM_ADR_5_LBN 8
506#define XM_ADR_5_WIDTH 8
507#define XM_ADR_4_LBN 0
508#define XM_ADR_4_WIDTH 8
509
510/* XGMAC global configuration */
511#define XM_GLB_CFG_REG_MAC 0x02
512#define XM_RX_STAT_EN_LBN 11
513#define XM_RX_STAT_EN_WIDTH 1
514#define XM_TX_STAT_EN_LBN 10
515#define XM_TX_STAT_EN_WIDTH 1
516#define XM_RX_JUMBO_MODE_LBN 6
517#define XM_RX_JUMBO_MODE_WIDTH 1
518#define XM_INTCLR_MODE_LBN 3
519#define XM_INTCLR_MODE_WIDTH 1
520#define XM_CORE_RST_LBN 0
521#define XM_CORE_RST_WIDTH 1
522
523/* XGMAC transmit configuration */
524#define XM_TX_CFG_REG_MAC 0x03
525#define XM_IPG_LBN 16
526#define XM_IPG_WIDTH 4
527#define XM_FCNTL_LBN 10
528#define XM_FCNTL_WIDTH 1
529#define XM_TXCRC_LBN 8
530#define XM_TXCRC_WIDTH 1
531#define XM_AUTO_PAD_LBN 5
532#define XM_AUTO_PAD_WIDTH 1
533#define XM_TX_PRMBL_LBN 2
534#define XM_TX_PRMBL_WIDTH 1
535#define XM_TXEN_LBN 1
536#define XM_TXEN_WIDTH 1
537
538/* XGMAC receive configuration */
539#define XM_RX_CFG_REG_MAC 0x04
540#define XM_PASS_CRC_ERR_LBN 25
541#define XM_PASS_CRC_ERR_WIDTH 1
542#define XM_ACPT_ALL_MCAST_LBN 11
543#define XM_ACPT_ALL_MCAST_WIDTH 1
544#define XM_ACPT_ALL_UCAST_LBN 9
545#define XM_ACPT_ALL_UCAST_WIDTH 1
546#define XM_AUTO_DEPAD_LBN 8
547#define XM_AUTO_DEPAD_WIDTH 1
548#define XM_RXEN_LBN 1
549#define XM_RXEN_WIDTH 1
550
551/* XGMAC management interrupt mask register */
552#define XM_MGT_INT_MSK_REG_MAC_B0 0x5
553#define XM_MSK_PRMBLE_ERR_LBN 2
554#define XM_MSK_PRMBLE_ERR_WIDTH 1
555#define XM_MSK_RMTFLT_LBN 1
556#define XM_MSK_RMTFLT_WIDTH 1
557#define XM_MSK_LCLFLT_LBN 0
558#define XM_MSK_LCLFLT_WIDTH 1
559
560/* XGMAC flow control register */
561#define XM_FC_REG_MAC 0x7
562#define XM_PAUSE_TIME_LBN 16
563#define XM_PAUSE_TIME_WIDTH 16
564#define XM_DIS_FCNTL_LBN 0
565#define XM_DIS_FCNTL_WIDTH 1
566
567/* XGMAC pause time count register */
568#define XM_PAUSE_TIME_REG_MAC 0x9
569
570/* XGMAC transmit parameter register */
571#define XM_TX_PARAM_REG_MAC 0x0d
572#define XM_TX_JUMBO_MODE_LBN 31
573#define XM_TX_JUMBO_MODE_WIDTH 1
574#define XM_MAX_TX_FRM_SIZE_LBN 16
575#define XM_MAX_TX_FRM_SIZE_WIDTH 14
576
577/* XGMAC receive parameter register */
578#define XM_RX_PARAM_REG_MAC 0x0e
579#define XM_MAX_RX_FRM_SIZE_LBN 0
580#define XM_MAX_RX_FRM_SIZE_WIDTH 14
581
582/* XGMAC management interrupt status register */
583#define XM_MGT_INT_REG_MAC_B0 0x0f
584#define XM_PRMBLE_ERR 2
585#define XM_PRMBLE_WIDTH 1
586#define XM_RMTFLT_LBN 1
587#define XM_RMTFLT_WIDTH 1
588#define XM_LCLFLT_LBN 0
589#define XM_LCLFLT_WIDTH 1
590
591/* XGXS/XAUI powerdown/reset register */
592#define XX_PWR_RST_REG_MAC 0x10
593
594#define XX_PWRDND_EN_LBN 15
595#define XX_PWRDND_EN_WIDTH 1
596#define XX_PWRDNC_EN_LBN 14
597#define XX_PWRDNC_EN_WIDTH 1
598#define XX_PWRDNB_EN_LBN 13
599#define XX_PWRDNB_EN_WIDTH 1
600#define XX_PWRDNA_EN_LBN 12
601#define XX_PWRDNA_EN_WIDTH 1
602#define XX_RSTPLLCD_EN_LBN 9
603#define XX_RSTPLLCD_EN_WIDTH 1
604#define XX_RSTPLLAB_EN_LBN 8
605#define XX_RSTPLLAB_EN_WIDTH 1
606#define XX_RESETD_EN_LBN 7
607#define XX_RESETD_EN_WIDTH 1
608#define XX_RESETC_EN_LBN 6
609#define XX_RESETC_EN_WIDTH 1
610#define XX_RESETB_EN_LBN 5
611#define XX_RESETB_EN_WIDTH 1
612#define XX_RESETA_EN_LBN 4
613#define XX_RESETA_EN_WIDTH 1
614#define XX_RSTXGXSRX_EN_LBN 2
615#define XX_RSTXGXSRX_EN_WIDTH 1
616#define XX_RSTXGXSTX_EN_LBN 1
617#define XX_RSTXGXSTX_EN_WIDTH 1
618#define XX_RST_XX_EN_LBN 0
619#define XX_RST_XX_EN_WIDTH 1
620
621/* XGXS/XAUI powerdown/reset control register */
622#define XX_SD_CTL_REG_MAC 0x11
623#define XX_HIDRVD_LBN 15
624#define XX_HIDRVD_WIDTH 1
625#define XX_LODRVD_LBN 14
626#define XX_LODRVD_WIDTH 1
627#define XX_HIDRVC_LBN 13
628#define XX_HIDRVC_WIDTH 1
629#define XX_LODRVC_LBN 12
630#define XX_LODRVC_WIDTH 1
631#define XX_HIDRVB_LBN 11
632#define XX_HIDRVB_WIDTH 1
633#define XX_LODRVB_LBN 10
634#define XX_LODRVB_WIDTH 1
635#define XX_HIDRVA_LBN 9
636#define XX_HIDRVA_WIDTH 1
637#define XX_LODRVA_LBN 8
638#define XX_LODRVA_WIDTH 1
639
640#define XX_TXDRV_CTL_REG_MAC 0x12
641#define XX_DEQD_LBN 28
642#define XX_DEQD_WIDTH 4
643#define XX_DEQC_LBN 24
644#define XX_DEQC_WIDTH 4
645#define XX_DEQB_LBN 20
646#define XX_DEQB_WIDTH 4
647#define XX_DEQA_LBN 16
648#define XX_DEQA_WIDTH 4
649#define XX_DTXD_LBN 12
650#define XX_DTXD_WIDTH 4
651#define XX_DTXC_LBN 8
652#define XX_DTXC_WIDTH 4
653#define XX_DTXB_LBN 4
654#define XX_DTXB_WIDTH 4
655#define XX_DTXA_LBN 0
656#define XX_DTXA_WIDTH 4
657
658/* XAUI XGXS core status register */
659#define XX_FORCE_SIG_DECODE_FORCED 0xff
660#define XX_CORE_STAT_REG_MAC 0x16
661#define XX_ALIGN_DONE_LBN 20
662#define XX_ALIGN_DONE_WIDTH 1
663#define XX_SYNC_STAT_LBN 16
664#define XX_SYNC_STAT_WIDTH 4
665#define XX_SYNC_STAT_DECODE_SYNCED 0xf
666#define XX_COMMA_DET_LBN 12
667#define XX_COMMA_DET_WIDTH 4
668#define XX_COMMA_DET_DECODE_DETECTED 0xf
669#define XX_COMMA_DET_RESET 0xf
670#define XX_CHARERR_LBN 4
671#define XX_CHARERR_WIDTH 4
672#define XX_CHARERR_RESET 0xf
673#define XX_DISPERR_LBN 0
674#define XX_DISPERR_WIDTH 4
675#define XX_DISPERR_RESET 0xf
676
677/* Receive filter table */
678#define RX_FILTER_TBL0 0xF00000
679
680/* Receive descriptor pointer table */
681#define RX_DESC_PTR_TBL_KER_A1 0x11800
682#define RX_DESC_PTR_TBL_KER_B0 0xF40000
683#define RX_DESC_PTR_TBL_KER_P0 0x900
684#define RX_ISCSI_DDIG_EN_LBN 88
685#define RX_ISCSI_DDIG_EN_WIDTH 1
686#define RX_ISCSI_HDIG_EN_LBN 87
687#define RX_ISCSI_HDIG_EN_WIDTH 1
688#define RX_DESCQ_BUF_BASE_ID_LBN 36
689#define RX_DESCQ_BUF_BASE_ID_WIDTH 20
690#define RX_DESCQ_EVQ_ID_LBN 24
691#define RX_DESCQ_EVQ_ID_WIDTH 12
692#define RX_DESCQ_OWNER_ID_LBN 10
693#define RX_DESCQ_OWNER_ID_WIDTH 14
694#define RX_DESCQ_LABEL_LBN 5
695#define RX_DESCQ_LABEL_WIDTH 5
696#define RX_DESCQ_SIZE_LBN 3
697#define RX_DESCQ_SIZE_WIDTH 2
698#define RX_DESCQ_SIZE_4K 3
699#define RX_DESCQ_SIZE_2K 2
700#define RX_DESCQ_SIZE_1K 1
701#define RX_DESCQ_SIZE_512 0
702#define RX_DESCQ_TYPE_LBN 2
703#define RX_DESCQ_TYPE_WIDTH 1
704#define RX_DESCQ_JUMBO_LBN 1
705#define RX_DESCQ_JUMBO_WIDTH 1
706#define RX_DESCQ_EN_LBN 0
707#define RX_DESCQ_EN_WIDTH 1
708
709/* Transmit descriptor pointer table */
710#define TX_DESC_PTR_TBL_KER_A1 0x11900
711#define TX_DESC_PTR_TBL_KER_B0 0xF50000
712#define TX_DESC_PTR_TBL_KER_P0 0xa40
713#define TX_NON_IP_DROP_DIS_B0_LBN 91
714#define TX_NON_IP_DROP_DIS_B0_WIDTH 1
715#define TX_IP_CHKSM_DIS_B0_LBN 90
716#define TX_IP_CHKSM_DIS_B0_WIDTH 1
717#define TX_TCP_CHKSM_DIS_B0_LBN 89
718#define TX_TCP_CHKSM_DIS_B0_WIDTH 1
719#define TX_DESCQ_EN_LBN 88
720#define TX_DESCQ_EN_WIDTH 1
721#define TX_ISCSI_DDIG_EN_LBN 87
722#define TX_ISCSI_DDIG_EN_WIDTH 1
723#define TX_ISCSI_HDIG_EN_LBN 86
724#define TX_ISCSI_HDIG_EN_WIDTH 1
725#define TX_DESCQ_BUF_BASE_ID_LBN 36
726#define TX_DESCQ_BUF_BASE_ID_WIDTH 20
727#define TX_DESCQ_EVQ_ID_LBN 24
728#define TX_DESCQ_EVQ_ID_WIDTH 12
729#define TX_DESCQ_OWNER_ID_LBN 10
730#define TX_DESCQ_OWNER_ID_WIDTH 14
731#define TX_DESCQ_LABEL_LBN 5
732#define TX_DESCQ_LABEL_WIDTH 5
733#define TX_DESCQ_SIZE_LBN 3
734#define TX_DESCQ_SIZE_WIDTH 2
735#define TX_DESCQ_SIZE_4K 3
736#define TX_DESCQ_SIZE_2K 2
737#define TX_DESCQ_SIZE_1K 1
738#define TX_DESCQ_SIZE_512 0
739#define TX_DESCQ_TYPE_LBN 1
740#define TX_DESCQ_TYPE_WIDTH 2
741
742/* Event queue pointer */
743#define EVQ_PTR_TBL_KER_A1 0x11a00
744#define EVQ_PTR_TBL_KER_B0 0xf60000
745#define EVQ_PTR_TBL_KER_P0 0x500
746#define EVQ_EN_LBN 23
747#define EVQ_EN_WIDTH 1
748#define EVQ_SIZE_LBN 20
749#define EVQ_SIZE_WIDTH 3
750#define EVQ_SIZE_32K 6
751#define EVQ_SIZE_16K 5
752#define EVQ_SIZE_8K 4
753#define EVQ_SIZE_4K 3
754#define EVQ_SIZE_2K 2
755#define EVQ_SIZE_1K 1
756#define EVQ_SIZE_512 0
757#define EVQ_BUF_BASE_ID_LBN 0
758#define EVQ_BUF_BASE_ID_WIDTH 20
759
760/* Event queue read pointer */
761#define EVQ_RPTR_REG_KER_A1 0x11b00
762#define EVQ_RPTR_REG_KER_B0 0xfa0000
763#define EVQ_RPTR_REG_KER_DWORD (EVQ_RPTR_REG_KER + 0)
764#define EVQ_RPTR_DWORD_LBN 0
765#define EVQ_RPTR_DWORD_WIDTH 14
766
767/* RSS indirection table */
768#define RX_RSS_INDIR_TBL_B0 0xFB0000
769#define RX_RSS_INDIR_ENT_B0_LBN 0
770#define RX_RSS_INDIR_ENT_B0_WIDTH 6
771
772/* Special buffer descriptors (full-mode) */
773#define BUF_FULL_TBL_KER_A1 0x8000
774#define BUF_FULL_TBL_KER_B0 0x800000
775#define IP_DAT_BUF_SIZE_LBN 50
776#define IP_DAT_BUF_SIZE_WIDTH 1
777#define IP_DAT_BUF_SIZE_8K 1
778#define IP_DAT_BUF_SIZE_4K 0
779#define BUF_ADR_REGION_LBN 48
780#define BUF_ADR_REGION_WIDTH 2
781#define BUF_ADR_FBUF_LBN 14
782#define BUF_ADR_FBUF_WIDTH 34
783#define BUF_OWNER_ID_FBUF_LBN 0
784#define BUF_OWNER_ID_FBUF_WIDTH 14
785
786/* Transmit descriptor */
787#define TX_KER_PORT_LBN 63
788#define TX_KER_PORT_WIDTH 1
789#define TX_KER_CONT_LBN 62
790#define TX_KER_CONT_WIDTH 1
791#define TX_KER_BYTE_CNT_LBN 48
792#define TX_KER_BYTE_CNT_WIDTH 14
793#define TX_KER_BUF_REGION_LBN 46
794#define TX_KER_BUF_REGION_WIDTH 2
795#define TX_KER_BUF_REGION0_DECODE 0
796#define TX_KER_BUF_REGION1_DECODE 1
797#define TX_KER_BUF_REGION2_DECODE 2
798#define TX_KER_BUF_REGION3_DECODE 3
799#define TX_KER_BUF_ADR_LBN 0
800#define TX_KER_BUF_ADR_WIDTH EFX_DMA_TYPE_WIDTH(46)
801
802/* Receive descriptor */
803#define RX_KER_BUF_SIZE_LBN 48
804#define RX_KER_BUF_SIZE_WIDTH 14
805#define RX_KER_BUF_REGION_LBN 46
806#define RX_KER_BUF_REGION_WIDTH 2
807#define RX_KER_BUF_REGION0_DECODE 0
808#define RX_KER_BUF_REGION1_DECODE 1
809#define RX_KER_BUF_REGION2_DECODE 2
810#define RX_KER_BUF_REGION3_DECODE 3
811#define RX_KER_BUF_ADR_LBN 0
812#define RX_KER_BUF_ADR_WIDTH EFX_DMA_TYPE_WIDTH(46)
813
814/**************************************************************************
815 *
816 * Falcon events
817 *
818 **************************************************************************
819 */
820
821/* Event queue entries */
822#define EV_CODE_LBN 60
823#define EV_CODE_WIDTH 4
824#define RX_IP_EV_DECODE 0
825#define TX_IP_EV_DECODE 2
826#define DRIVER_EV_DECODE 5
827#define GLOBAL_EV_DECODE 6
828#define DRV_GEN_EV_DECODE 7
829#define WHOLE_EVENT_LBN 0
830#define WHOLE_EVENT_WIDTH 64
831
832/* Receive events */
833#define RX_EV_PKT_OK_LBN 56
834#define RX_EV_PKT_OK_WIDTH 1
835#define RX_EV_PAUSE_FRM_ERR_LBN 55
836#define RX_EV_PAUSE_FRM_ERR_WIDTH 1
837#define RX_EV_BUF_OWNER_ID_ERR_LBN 54
838#define RX_EV_BUF_OWNER_ID_ERR_WIDTH 1
839#define RX_EV_IF_FRAG_ERR_LBN 53
840#define RX_EV_IF_FRAG_ERR_WIDTH 1
841#define RX_EV_IP_HDR_CHKSUM_ERR_LBN 52
842#define RX_EV_IP_HDR_CHKSUM_ERR_WIDTH 1
843#define RX_EV_TCP_UDP_CHKSUM_ERR_LBN 51
844#define RX_EV_TCP_UDP_CHKSUM_ERR_WIDTH 1
845#define RX_EV_ETH_CRC_ERR_LBN 50
846#define RX_EV_ETH_CRC_ERR_WIDTH 1
847#define RX_EV_FRM_TRUNC_LBN 49
848#define RX_EV_FRM_TRUNC_WIDTH 1
849#define RX_EV_DRIB_NIB_LBN 48
850#define RX_EV_DRIB_NIB_WIDTH 1
851#define RX_EV_TOBE_DISC_LBN 47
852#define RX_EV_TOBE_DISC_WIDTH 1
853#define RX_EV_PKT_TYPE_LBN 44
854#define RX_EV_PKT_TYPE_WIDTH 3
855#define RX_EV_PKT_TYPE_ETH_DECODE 0
856#define RX_EV_PKT_TYPE_LLC_DECODE 1
857#define RX_EV_PKT_TYPE_JUMBO_DECODE 2
858#define RX_EV_PKT_TYPE_VLAN_DECODE 3
859#define RX_EV_PKT_TYPE_VLAN_LLC_DECODE 4
860#define RX_EV_PKT_TYPE_VLAN_JUMBO_DECODE 5
861#define RX_EV_HDR_TYPE_LBN 42
862#define RX_EV_HDR_TYPE_WIDTH 2
863#define RX_EV_HDR_TYPE_TCP_IPV4_DECODE 0
864#define RX_EV_HDR_TYPE_UDP_IPV4_DECODE 1
865#define RX_EV_HDR_TYPE_OTHER_IP_DECODE 2
866#define RX_EV_HDR_TYPE_NON_IP_DECODE 3
867#define RX_EV_HDR_TYPE_HAS_CHECKSUMS(hdr_type) \
868 ((hdr_type) <= RX_EV_HDR_TYPE_UDP_IPV4_DECODE)
869#define RX_EV_MCAST_HASH_MATCH_LBN 40
870#define RX_EV_MCAST_HASH_MATCH_WIDTH 1
871#define RX_EV_MCAST_PKT_LBN 39
872#define RX_EV_MCAST_PKT_WIDTH 1
873#define RX_EV_Q_LABEL_LBN 32
874#define RX_EV_Q_LABEL_WIDTH 5
875#define RX_EV_JUMBO_CONT_LBN 31
876#define RX_EV_JUMBO_CONT_WIDTH 1
877#define RX_EV_BYTE_CNT_LBN 16
878#define RX_EV_BYTE_CNT_WIDTH 14
879#define RX_EV_SOP_LBN 15
880#define RX_EV_SOP_WIDTH 1
881#define RX_EV_DESC_PTR_LBN 0
882#define RX_EV_DESC_PTR_WIDTH 12
883
884/* Transmit events */
885#define TX_EV_PKT_ERR_LBN 38
886#define TX_EV_PKT_ERR_WIDTH 1
887#define TX_EV_Q_LABEL_LBN 32
888#define TX_EV_Q_LABEL_WIDTH 5
889#define TX_EV_WQ_FF_FULL_LBN 15
890#define TX_EV_WQ_FF_FULL_WIDTH 1
891#define TX_EV_COMP_LBN 12
892#define TX_EV_COMP_WIDTH 1
893#define TX_EV_DESC_PTR_LBN 0
894#define TX_EV_DESC_PTR_WIDTH 12
895
896/* Driver events */
897#define DRIVER_EV_SUB_CODE_LBN 56
898#define DRIVER_EV_SUB_CODE_WIDTH 4
899#define DRIVER_EV_SUB_DATA_LBN 0
900#define DRIVER_EV_SUB_DATA_WIDTH 14
901#define TX_DESCQ_FLS_DONE_EV_DECODE 0
902#define RX_DESCQ_FLS_DONE_EV_DECODE 1
903#define EVQ_INIT_DONE_EV_DECODE 2
904#define EVQ_NOT_EN_EV_DECODE 3
905#define RX_DESCQ_FLSFF_OVFL_EV_DECODE 4
906#define SRM_UPD_DONE_EV_DECODE 5
907#define WAKE_UP_EV_DECODE 6
908#define TX_PKT_NON_TCP_UDP_DECODE 9
909#define TIMER_EV_DECODE 10
910#define RX_RECOVERY_EV_DECODE 11
911#define RX_DSC_ERROR_EV_DECODE 14
912#define TX_DSC_ERROR_EV_DECODE 15
913#define DRIVER_EV_TX_DESCQ_ID_LBN 0
914#define DRIVER_EV_TX_DESCQ_ID_WIDTH 12
915#define DRIVER_EV_RX_FLUSH_FAIL_LBN 12
916#define DRIVER_EV_RX_FLUSH_FAIL_WIDTH 1
917#define DRIVER_EV_RX_DESCQ_ID_LBN 0
918#define DRIVER_EV_RX_DESCQ_ID_WIDTH 12
919#define SRM_CLR_EV_DECODE 0
920#define SRM_UPD_EV_DECODE 1
921#define SRM_ILLCLR_EV_DECODE 2
922
923/* Global events */
924#define RX_RECOVERY_B0_LBN 12
925#define RX_RECOVERY_B0_WIDTH 1
926#define XG_MNT_INTR_B0_LBN 11
927#define XG_MNT_INTR_B0_WIDTH 1
928#define RX_RECOVERY_A1_LBN 11
929#define RX_RECOVERY_A1_WIDTH 1
930#define XG_PHY_INTR_LBN 9
931#define XG_PHY_INTR_WIDTH 1
932#define G_PHY1_INTR_LBN 8
933#define G_PHY1_INTR_WIDTH 1
934#define G_PHY0_INTR_LBN 7
935#define G_PHY0_INTR_WIDTH 1
936
937/* Driver-generated test events */
938#define EVQ_MAGIC_LBN 0
939#define EVQ_MAGIC_WIDTH 32
940
941/**************************************************************************
942 *
943 * Falcon MAC stats
944 *
945 **************************************************************************
946 *
947 */
948#define GRxGoodOct_offset 0x0
949#define GRxBadOct_offset 0x8
950#define GRxMissPkt_offset 0x10
951#define GRxFalseCRS_offset 0x14
952#define GRxPausePkt_offset 0x18
953#define GRxBadPkt_offset 0x1C
954#define GRxUcastPkt_offset 0x20
955#define GRxMcastPkt_offset 0x24
956#define GRxBcastPkt_offset 0x28
957#define GRxGoodLt64Pkt_offset 0x2C
958#define GRxBadLt64Pkt_offset 0x30
959#define GRx64Pkt_offset 0x34
960#define GRx65to127Pkt_offset 0x38
961#define GRx128to255Pkt_offset 0x3C
962#define GRx256to511Pkt_offset 0x40
963#define GRx512to1023Pkt_offset 0x44
964#define GRx1024to15xxPkt_offset 0x48
965#define GRx15xxtoJumboPkt_offset 0x4C
966#define GRxGtJumboPkt_offset 0x50
967#define GRxFcsErr64to15xxPkt_offset 0x54
968#define GRxFcsErr15xxtoJumboPkt_offset 0x58
969#define GRxFcsErrGtJumboPkt_offset 0x5C
970#define GTxGoodBadOct_offset 0x80
971#define GTxGoodOct_offset 0x88
972#define GTxSglColPkt_offset 0x90
973#define GTxMultColPkt_offset 0x94
974#define GTxExColPkt_offset 0x98
975#define GTxDefPkt_offset 0x9C
976#define GTxLateCol_offset 0xA0
977#define GTxExDefPkt_offset 0xA4
978#define GTxPausePkt_offset 0xA8
979#define GTxBadPkt_offset 0xAC
980#define GTxUcastPkt_offset 0xB0
981#define GTxMcastPkt_offset 0xB4
982#define GTxBcastPkt_offset 0xB8
983#define GTxLt64Pkt_offset 0xBC
984#define GTx64Pkt_offset 0xC0
985#define GTx65to127Pkt_offset 0xC4
986#define GTx128to255Pkt_offset 0xC8
987#define GTx256to511Pkt_offset 0xCC
988#define GTx512to1023Pkt_offset 0xD0
989#define GTx1024to15xxPkt_offset 0xD4
990#define GTx15xxtoJumboPkt_offset 0xD8
991#define GTxGtJumboPkt_offset 0xDC
992#define GTxNonTcpUdpPkt_offset 0xE0
993#define GTxMacSrcErrPkt_offset 0xE4
994#define GTxIpSrcErrPkt_offset 0xE8
995#define GDmaDone_offset 0xEC
996
997#define XgRxOctets_offset 0x0
998#define XgRxOctets_WIDTH 48
999#define XgRxOctetsOK_offset 0x8
1000#define XgRxOctetsOK_WIDTH 48
1001#define XgRxPkts_offset 0x10
1002#define XgRxPkts_WIDTH 32
1003#define XgRxPktsOK_offset 0x14
1004#define XgRxPktsOK_WIDTH 32
1005#define XgRxBroadcastPkts_offset 0x18
1006#define XgRxBroadcastPkts_WIDTH 32
1007#define XgRxMulticastPkts_offset 0x1C
1008#define XgRxMulticastPkts_WIDTH 32
1009#define XgRxUnicastPkts_offset 0x20
1010#define XgRxUnicastPkts_WIDTH 32
1011#define XgRxUndersizePkts_offset 0x24
1012#define XgRxUndersizePkts_WIDTH 32
1013#define XgRxOversizePkts_offset 0x28
1014#define XgRxOversizePkts_WIDTH 32
1015#define XgRxJabberPkts_offset 0x2C
1016#define XgRxJabberPkts_WIDTH 32
1017#define XgRxUndersizeFCSerrorPkts_offset 0x30
1018#define XgRxUndersizeFCSerrorPkts_WIDTH 32
1019#define XgRxDropEvents_offset 0x34
1020#define XgRxDropEvents_WIDTH 32
1021#define XgRxFCSerrorPkts_offset 0x38
1022#define XgRxFCSerrorPkts_WIDTH 32
1023#define XgRxAlignError_offset 0x3C
1024#define XgRxAlignError_WIDTH 32
1025#define XgRxSymbolError_offset 0x40
1026#define XgRxSymbolError_WIDTH 32
1027#define XgRxInternalMACError_offset 0x44
1028#define XgRxInternalMACError_WIDTH 32
1029#define XgRxControlPkts_offset 0x48
1030#define XgRxControlPkts_WIDTH 32
1031#define XgRxPausePkts_offset 0x4C
1032#define XgRxPausePkts_WIDTH 32
1033#define XgRxPkts64Octets_offset 0x50
1034#define XgRxPkts64Octets_WIDTH 32
1035#define XgRxPkts65to127Octets_offset 0x54
1036#define XgRxPkts65to127Octets_WIDTH 32
1037#define XgRxPkts128to255Octets_offset 0x58
1038#define XgRxPkts128to255Octets_WIDTH 32
1039#define XgRxPkts256to511Octets_offset 0x5C
1040#define XgRxPkts256to511Octets_WIDTH 32
1041#define XgRxPkts512to1023Octets_offset 0x60
1042#define XgRxPkts512to1023Octets_WIDTH 32
1043#define XgRxPkts1024to15xxOctets_offset 0x64
1044#define XgRxPkts1024to15xxOctets_WIDTH 32
1045#define XgRxPkts15xxtoMaxOctets_offset 0x68
1046#define XgRxPkts15xxtoMaxOctets_WIDTH 32
1047#define XgRxLengthError_offset 0x6C
1048#define XgRxLengthError_WIDTH 32
1049#define XgTxPkts_offset 0x80
1050#define XgTxPkts_WIDTH 32
1051#define XgTxOctets_offset 0x88
1052#define XgTxOctets_WIDTH 48
1053#define XgTxMulticastPkts_offset 0x90
1054#define XgTxMulticastPkts_WIDTH 32
1055#define XgTxBroadcastPkts_offset 0x94
1056#define XgTxBroadcastPkts_WIDTH 32
1057#define XgTxUnicastPkts_offset 0x98
1058#define XgTxUnicastPkts_WIDTH 32
1059#define XgTxControlPkts_offset 0x9C
1060#define XgTxControlPkts_WIDTH 32
1061#define XgTxPausePkts_offset 0xA0
1062#define XgTxPausePkts_WIDTH 32
1063#define XgTxPkts64Octets_offset 0xA4
1064#define XgTxPkts64Octets_WIDTH 32
1065#define XgTxPkts65to127Octets_offset 0xA8
1066#define XgTxPkts65to127Octets_WIDTH 32
1067#define XgTxPkts128to255Octets_offset 0xAC
1068#define XgTxPkts128to255Octets_WIDTH 32
1069#define XgTxPkts256to511Octets_offset 0xB0
1070#define XgTxPkts256to511Octets_WIDTH 32
1071#define XgTxPkts512to1023Octets_offset 0xB4
1072#define XgTxPkts512to1023Octets_WIDTH 32
1073#define XgTxPkts1024to15xxOctets_offset 0xB8
1074#define XgTxPkts1024to15xxOctets_WIDTH 32
1075#define XgTxPkts1519toMaxOctets_offset 0xBC
1076#define XgTxPkts1519toMaxOctets_WIDTH 32
1077#define XgTxUndersizePkts_offset 0xC0
1078#define XgTxUndersizePkts_WIDTH 32
1079#define XgTxOversizePkts_offset 0xC4
1080#define XgTxOversizePkts_WIDTH 32
1081#define XgTxNonTcpUdpPkt_offset 0xC8
1082#define XgTxNonTcpUdpPkt_WIDTH 16
1083#define XgTxMacSrcErrPkt_offset 0xCC
1084#define XgTxMacSrcErrPkt_WIDTH 16
1085#define XgTxIpSrcErrPkt_offset 0xD0
1086#define XgTxIpSrcErrPkt_WIDTH 16
1087#define XgDmaDone_offset 0xD4
1088
1089#define FALCON_STATS_NOT_DONE 0x00000000
1090#define FALCON_STATS_DONE 0xffffffff
1091
1092/* Interrupt status register bits */
1093#define FATAL_INT_LBN 64
1094#define FATAL_INT_WIDTH 1
1095#define INT_EVQS_LBN 40
1096#define INT_EVQS_WIDTH 4
1097
1098/**************************************************************************
1099 *
1100 * Falcon non-volatile configuration
1101 *
1102 **************************************************************************
1103 */
1104
1105/* Board configuration v2 (v1 is obsolete; later versions are compatible) */
1106struct falcon_nvconfig_board_v2 {
1107 __le16 nports;
1108 u8 port0_phy_addr;
1109 u8 port0_phy_type;
1110 u8 port1_phy_addr;
1111 u8 port1_phy_type;
1112 __le16 asic_sub_revision;
1113 __le16 board_revision;
1114} __attribute__ ((packed));
1115
1116#define NVCONFIG_BASE 0x300
1117#define NVCONFIG_BOARD_MAGIC_NUM 0xFA1C
1118struct falcon_nvconfig {
1119 efx_oword_t ee_vpd_cfg_reg; /* 0x300 */
1120 u8 mac_address[2][8]; /* 0x310 */
1121 efx_oword_t pcie_sd_ctl0123_reg; /* 0x320 */
1122 efx_oword_t pcie_sd_ctl45_reg; /* 0x330 */
1123 efx_oword_t pcie_pcs_ctl_stat_reg; /* 0x340 */
1124 efx_oword_t hw_init_reg; /* 0x350 */
1125 efx_oword_t nic_stat_reg; /* 0x360 */
1126 efx_oword_t glb_ctl_reg; /* 0x370 */
1127 efx_oword_t srm_cfg_reg; /* 0x380 */
1128 efx_oword_t spare_reg; /* 0x390 */
1129 __le16 board_magic_num; /* 0x3A0 */
1130 __le16 board_struct_ver;
1131 __le16 board_checksum;
1132 struct falcon_nvconfig_board_v2 board_v2;
1133} __attribute__ ((packed));
1134
1135#endif /* EFX_FALCON_HWDEFS_H */
diff --git a/drivers/net/sfc/falcon_io.h b/drivers/net/sfc/falcon_io.h
new file mode 100644
index 000000000000..ea08184ddfa9
--- /dev/null
+++ b/drivers/net/sfc/falcon_io.h
@@ -0,0 +1,243 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_FALCON_IO_H
12#define EFX_FALCON_IO_H
13
14#include <linux/io.h>
15#include <linux/spinlock.h>
16#include "net_driver.h"
17
18/**************************************************************************
19 *
20 * Falcon hardware access
21 *
22 **************************************************************************
23 *
24 * Notes on locking strategy:
25 *
26 * Most Falcon registers require 16-byte (or 8-byte, for SRAM
27 * registers) atomic writes which necessitates locking.
28 * Under normal operation few writes to the Falcon BAR are made and these
29 * registers (EVQ_RPTR_REG, RX_DESC_UPD_REG and TX_DESC_UPD_REG) are special
30 * cased to allow 4-byte (hence lockless) accesses.
31 *
32 * It *is* safe to write to these 4-byte registers in the middle of an
33 * access to an 8-byte or 16-byte register. We therefore use a
34 * spinlock to protect accesses to the larger registers, but no locks
35 * for the 4-byte registers.
36 *
37 * A write barrier is needed to ensure that DW3 is written after DW0/1/2
38 * due to the way the 16byte registers are "collected" in the Falcon BIU
39 *
40 * We also lock when carrying out reads, to ensure consistency of the
41 * data (made possible since the BIU reads all 128 bits into a cache).
42 * Reads are very rare, so this isn't a significant performance
43 * impact. (Most data transferred from NIC to host is DMAed directly
44 * into host memory).
45 *
46 * I/O BAR access uses locks for both reads and writes (but is only provided
47 * for testing purposes).
48 */
49
50/* Special buffer descriptors (Falcon SRAM) */
51#define BUF_TBL_KER_A1 0x18000
52#define BUF_TBL_KER_B0 0x800000
53
54
55#if BITS_PER_LONG == 64
56#define FALCON_USE_QWORD_IO 1
57#endif
58
59#define _falcon_writeq(efx, value, reg) \
60 __raw_writeq((__force u64) (value), (efx)->membase + (reg))
61#define _falcon_writel(efx, value, reg) \
62 __raw_writel((__force u32) (value), (efx)->membase + (reg))
63#define _falcon_readq(efx, reg) \
64 ((__force __le64) __raw_readq((efx)->membase + (reg)))
65#define _falcon_readl(efx, reg) \
66 ((__force __le32) __raw_readl((efx)->membase + (reg)))
67
68/* Writes to a normal 16-byte Falcon register, locking as appropriate. */
69static inline void falcon_write(struct efx_nic *efx, efx_oword_t *value,
70 unsigned int reg)
71{
72 unsigned long flags;
73
74 EFX_REGDUMP(efx, "writing register %x with " EFX_OWORD_FMT "\n", reg,
75 EFX_OWORD_VAL(*value));
76
77 spin_lock_irqsave(&efx->biu_lock, flags);
78#ifdef FALCON_USE_QWORD_IO
79 _falcon_writeq(efx, value->u64[0], reg + 0);
80 wmb();
81 _falcon_writeq(efx, value->u64[1], reg + 8);
82#else
83 _falcon_writel(efx, value->u32[0], reg + 0);
84 _falcon_writel(efx, value->u32[1], reg + 4);
85 _falcon_writel(efx, value->u32[2], reg + 8);
86 wmb();
87 _falcon_writel(efx, value->u32[3], reg + 12);
88#endif
89 mmiowb();
90 spin_unlock_irqrestore(&efx->biu_lock, flags);
91}
92
93/* Writes to an 8-byte Falcon SRAM register, locking as appropriate. */
94static inline void falcon_write_sram(struct efx_nic *efx, efx_qword_t *value,
95 unsigned int index)
96{
97 unsigned int reg = efx->type->buf_tbl_base + (index * sizeof(*value));
98 unsigned long flags;
99
100 EFX_REGDUMP(efx, "writing SRAM register %x with " EFX_QWORD_FMT "\n",
101 reg, EFX_QWORD_VAL(*value));
102
103 spin_lock_irqsave(&efx->biu_lock, flags);
104#ifdef FALCON_USE_QWORD_IO
105 _falcon_writeq(efx, value->u64[0], reg + 0);
106#else
107 _falcon_writel(efx, value->u32[0], reg + 0);
108 wmb();
109 _falcon_writel(efx, value->u32[1], reg + 4);
110#endif
111 mmiowb();
112 spin_unlock_irqrestore(&efx->biu_lock, flags);
113}
114
115/* Write dword to Falcon register that allows partial writes
116 *
117 * Some Falcon registers (EVQ_RPTR_REG, RX_DESC_UPD_REG and
118 * TX_DESC_UPD_REG) can be written to as a single dword. This allows
119 * for lockless writes.
120 */
121static inline void falcon_writel(struct efx_nic *efx, efx_dword_t *value,
122 unsigned int reg)
123{
124 EFX_REGDUMP(efx, "writing partial register %x with "EFX_DWORD_FMT"\n",
125 reg, EFX_DWORD_VAL(*value));
126
127 /* No lock required */
128 _falcon_writel(efx, value->u32[0], reg);
129}
130
131/* Read from a Falcon register
132 *
133 * This reads an entire 16-byte Falcon register in one go, locking as
134 * appropriate. It is essential to read the first dword first, as this
135 * prompts Falcon to load the current value into the shadow register.
136 */
137static inline void falcon_read(struct efx_nic *efx, efx_oword_t *value,
138 unsigned int reg)
139{
140 unsigned long flags;
141
142 spin_lock_irqsave(&efx->biu_lock, flags);
143 value->u32[0] = _falcon_readl(efx, reg + 0);
144 rmb();
145 value->u32[1] = _falcon_readl(efx, reg + 4);
146 value->u32[2] = _falcon_readl(efx, reg + 8);
147 value->u32[3] = _falcon_readl(efx, reg + 12);
148 spin_unlock_irqrestore(&efx->biu_lock, flags);
149
150 EFX_REGDUMP(efx, "read from register %x, got " EFX_OWORD_FMT "\n", reg,
151 EFX_OWORD_VAL(*value));
152}
153
154/* This reads an 8-byte Falcon SRAM entry in one go. */
155static inline void falcon_read_sram(struct efx_nic *efx, efx_qword_t *value,
156 unsigned int index)
157{
158 unsigned int reg = efx->type->buf_tbl_base + (index * sizeof(*value));
159 unsigned long flags;
160
161 spin_lock_irqsave(&efx->biu_lock, flags);
162#ifdef FALCON_USE_QWORD_IO
163 value->u64[0] = _falcon_readq(efx, reg + 0);
164#else
165 value->u32[0] = _falcon_readl(efx, reg + 0);
166 rmb();
167 value->u32[1] = _falcon_readl(efx, reg + 4);
168#endif
169 spin_unlock_irqrestore(&efx->biu_lock, flags);
170
171 EFX_REGDUMP(efx, "read from SRAM register %x, got "EFX_QWORD_FMT"\n",
172 reg, EFX_QWORD_VAL(*value));
173}
174
175/* Read dword from Falcon register that allows partial writes (sic) */
176static inline void falcon_readl(struct efx_nic *efx, efx_dword_t *value,
177 unsigned int reg)
178{
179 value->u32[0] = _falcon_readl(efx, reg);
180 EFX_REGDUMP(efx, "read from register %x, got "EFX_DWORD_FMT"\n",
181 reg, EFX_DWORD_VAL(*value));
182}
183
184/* Write to a register forming part of a table */
185static inline void falcon_write_table(struct efx_nic *efx, efx_oword_t *value,
186 unsigned int reg, unsigned int index)
187{
188 falcon_write(efx, value, reg + index * sizeof(efx_oword_t));
189}
190
191/* Read to a register forming part of a table */
192static inline void falcon_read_table(struct efx_nic *efx, efx_oword_t *value,
193 unsigned int reg, unsigned int index)
194{
195 falcon_read(efx, value, reg + index * sizeof(efx_oword_t));
196}
197
198/* Write to a dword register forming part of a table */
199static inline void falcon_writel_table(struct efx_nic *efx, efx_dword_t *value,
200 unsigned int reg, unsigned int index)
201{
202 falcon_writel(efx, value, reg + index * sizeof(efx_oword_t));
203}
204
205/* Page-mapped register block size */
206#define FALCON_PAGE_BLOCK_SIZE 0x2000
207
208/* Calculate offset to page-mapped register block */
209#define FALCON_PAGED_REG(page, reg) \
210 ((page) * FALCON_PAGE_BLOCK_SIZE + (reg))
211
212/* As for falcon_write(), but for a page-mapped register. */
213static inline void falcon_write_page(struct efx_nic *efx, efx_oword_t *value,
214 unsigned int reg, unsigned int page)
215{
216 falcon_write(efx, value, FALCON_PAGED_REG(page, reg));
217}
218
219/* As for falcon_writel(), but for a page-mapped register. */
220static inline void falcon_writel_page(struct efx_nic *efx, efx_dword_t *value,
221 unsigned int reg, unsigned int page)
222{
223 falcon_writel(efx, value, FALCON_PAGED_REG(page, reg));
224}
225
226/* Write dword to Falcon page-mapped register with an extra lock.
227 *
228 * As for falcon_writel_page(), but for a register that suffers from
229 * SFC bug 3181. Take out a lock so the BIU collector cannot be
230 * confused. */
231static inline void falcon_writel_page_locked(struct efx_nic *efx,
232 efx_dword_t *value,
233 unsigned int reg,
234 unsigned int page)
235{
236 unsigned long flags;
237
238 spin_lock_irqsave(&efx->biu_lock, flags);
239 falcon_writel(efx, value, FALCON_PAGED_REG(page, reg));
240 spin_unlock_irqrestore(&efx->biu_lock, flags);
241}
242
243#endif /* EFX_FALCON_IO_H */
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c
new file mode 100644
index 000000000000..aa7521b24a5d
--- /dev/null
+++ b/drivers/net/sfc/falcon_xmac.c
@@ -0,0 +1,585 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/delay.h>
12#include "net_driver.h"
13#include "efx.h"
14#include "falcon.h"
15#include "falcon_hwdefs.h"
16#include "falcon_io.h"
17#include "mac.h"
18#include "gmii.h"
19#include "mdio_10g.h"
20#include "phy.h"
21#include "boards.h"
22#include "workarounds.h"
23
24/**************************************************************************
25 *
26 * MAC register access
27 *
28 **************************************************************************/
29
30/* Offset of an XMAC register within Falcon */
31#define FALCON_XMAC_REG(mac_reg) \
32 (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE))
33
34void falcon_xmac_writel(struct efx_nic *efx,
35 efx_dword_t *value, unsigned int mac_reg)
36{
37 efx_oword_t temp;
38
39 EFX_POPULATE_OWORD_1(temp, MAC_DATA, EFX_DWORD_FIELD(*value, MAC_DATA));
40 falcon_write(efx, &temp, FALCON_XMAC_REG(mac_reg));
41}
42
43void falcon_xmac_readl(struct efx_nic *efx,
44 efx_dword_t *value, unsigned int mac_reg)
45{
46 efx_oword_t temp;
47
48 falcon_read(efx, &temp, FALCON_XMAC_REG(mac_reg));
49 EFX_POPULATE_DWORD_1(*value, MAC_DATA, EFX_OWORD_FIELD(temp, MAC_DATA));
50}
51
52/**************************************************************************
53 *
54 * MAC operations
55 *
56 *************************************************************************/
57static int falcon_reset_xmac(struct efx_nic *efx)
58{
59 efx_dword_t reg;
60 int count;
61
62 EFX_POPULATE_DWORD_1(reg, XM_CORE_RST, 1);
63 falcon_xmac_writel(efx, &reg, XM_GLB_CFG_REG_MAC);
64
65 for (count = 0; count < 10000; count++) { /* wait upto 100ms */
66 falcon_xmac_readl(efx, &reg, XM_GLB_CFG_REG_MAC);
67 if (EFX_DWORD_FIELD(reg, XM_CORE_RST) == 0)
68 return 0;
69 udelay(10);
70 }
71
72 EFX_ERR(efx, "timed out waiting for XMAC core reset\n");
73 return -ETIMEDOUT;
74}
75
76/* Configure the XAUI driver that is an output from Falcon */
77static void falcon_setup_xaui(struct efx_nic *efx)
78{
79 efx_dword_t sdctl, txdrv;
80
81 /* Move the XAUI into low power, unless there is no PHY, in
82 * which case the XAUI will have to drive a cable. */
83 if (efx->phy_type == PHY_TYPE_NONE)
84 return;
85
86 falcon_xmac_readl(efx, &sdctl, XX_SD_CTL_REG_MAC);
87 EFX_SET_DWORD_FIELD(sdctl, XX_HIDRVD, XX_SD_CTL_DRV_DEFAULT);
88 EFX_SET_DWORD_FIELD(sdctl, XX_LODRVD, XX_SD_CTL_DRV_DEFAULT);
89 EFX_SET_DWORD_FIELD(sdctl, XX_HIDRVC, XX_SD_CTL_DRV_DEFAULT);
90 EFX_SET_DWORD_FIELD(sdctl, XX_LODRVC, XX_SD_CTL_DRV_DEFAULT);
91 EFX_SET_DWORD_FIELD(sdctl, XX_HIDRVB, XX_SD_CTL_DRV_DEFAULT);
92 EFX_SET_DWORD_FIELD(sdctl, XX_LODRVB, XX_SD_CTL_DRV_DEFAULT);
93 EFX_SET_DWORD_FIELD(sdctl, XX_HIDRVA, XX_SD_CTL_DRV_DEFAULT);
94 EFX_SET_DWORD_FIELD(sdctl, XX_LODRVA, XX_SD_CTL_DRV_DEFAULT);
95 falcon_xmac_writel(efx, &sdctl, XX_SD_CTL_REG_MAC);
96
97 EFX_POPULATE_DWORD_8(txdrv,
98 XX_DEQD, XX_TXDRV_DEQ_DEFAULT,
99 XX_DEQC, XX_TXDRV_DEQ_DEFAULT,
100 XX_DEQB, XX_TXDRV_DEQ_DEFAULT,
101 XX_DEQA, XX_TXDRV_DEQ_DEFAULT,
102 XX_DTXD, XX_TXDRV_DTX_DEFAULT,
103 XX_DTXC, XX_TXDRV_DTX_DEFAULT,
104 XX_DTXB, XX_TXDRV_DTX_DEFAULT,
105 XX_DTXA, XX_TXDRV_DTX_DEFAULT);
106 falcon_xmac_writel(efx, &txdrv, XX_TXDRV_CTL_REG_MAC);
107}
108
109static void falcon_hold_xaui_in_rst(struct efx_nic *efx)
110{
111 efx_dword_t reg;
112
113 EFX_ZERO_DWORD(reg);
114 EFX_SET_DWORD_FIELD(reg, XX_PWRDNA_EN, 1);
115 EFX_SET_DWORD_FIELD(reg, XX_PWRDNB_EN, 1);
116 EFX_SET_DWORD_FIELD(reg, XX_PWRDNC_EN, 1);
117 EFX_SET_DWORD_FIELD(reg, XX_PWRDND_EN, 1);
118 EFX_SET_DWORD_FIELD(reg, XX_RSTPLLAB_EN, 1);
119 EFX_SET_DWORD_FIELD(reg, XX_RSTPLLCD_EN, 1);
120 EFX_SET_DWORD_FIELD(reg, XX_RESETA_EN, 1);
121 EFX_SET_DWORD_FIELD(reg, XX_RESETB_EN, 1);
122 EFX_SET_DWORD_FIELD(reg, XX_RESETC_EN, 1);
123 EFX_SET_DWORD_FIELD(reg, XX_RESETD_EN, 1);
124 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 1);
125 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 1);
126 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
127 udelay(10);
128}
129
130static int _falcon_reset_xaui_a(struct efx_nic *efx)
131{
132 efx_dword_t reg;
133
134 falcon_hold_xaui_in_rst(efx);
135 falcon_xmac_readl(efx, &reg, XX_PWR_RST_REG_MAC);
136
137 /* Follow the RAMBUS XAUI data reset sequencing
138 * Channels A and B first: power down, reset PLL, reset, clear
139 */
140 EFX_SET_DWORD_FIELD(reg, XX_PWRDNA_EN, 0);
141 EFX_SET_DWORD_FIELD(reg, XX_PWRDNB_EN, 0);
142 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
143 udelay(10);
144
145 EFX_SET_DWORD_FIELD(reg, XX_RSTPLLAB_EN, 0);
146 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
147 udelay(10);
148
149 EFX_SET_DWORD_FIELD(reg, XX_RESETA_EN, 0);
150 EFX_SET_DWORD_FIELD(reg, XX_RESETB_EN, 0);
151 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
152 udelay(10);
153
154 /* Channels C and D: power down, reset PLL, reset, clear */
155 EFX_SET_DWORD_FIELD(reg, XX_PWRDNC_EN, 0);
156 EFX_SET_DWORD_FIELD(reg, XX_PWRDND_EN, 0);
157 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
158 udelay(10);
159
160 EFX_SET_DWORD_FIELD(reg, XX_RSTPLLCD_EN, 0);
161 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
162 udelay(10);
163
164 EFX_SET_DWORD_FIELD(reg, XX_RESETC_EN, 0);
165 EFX_SET_DWORD_FIELD(reg, XX_RESETD_EN, 0);
166 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
167 udelay(10);
168
169 /* Setup XAUI */
170 falcon_setup_xaui(efx);
171 udelay(10);
172
173 /* Take XGXS out of reset */
174 EFX_ZERO_DWORD(reg);
175 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
176 udelay(10);
177
178 return 0;
179}
180
181static int _falcon_reset_xaui_b(struct efx_nic *efx)
182{
183 efx_dword_t reg;
184 int count;
185
186 EFX_POPULATE_DWORD_1(reg, XX_RST_XX_EN, 1);
187 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
188
189 /* Give some time for the link to establish */
190 for (count = 0; count < 1000; count++) { /* wait upto 10ms */
191 falcon_xmac_readl(efx, &reg, XX_PWR_RST_REG_MAC);
192 if (EFX_DWORD_FIELD(reg, XX_RST_XX_EN) == 0) {
193 falcon_setup_xaui(efx);
194 return 0;
195 }
196 udelay(10);
197 }
198 EFX_ERR(efx, "timed out waiting for XAUI/XGXS reset\n");
199 return -ETIMEDOUT;
200}
201
202int falcon_reset_xaui(struct efx_nic *efx)
203{
204 int rc;
205
206 if (EFX_WORKAROUND_9388(efx)) {
207 falcon_hold_xaui_in_rst(efx);
208 efx->phy_op->reset_xaui(efx);
209 rc = _falcon_reset_xaui_a(efx);
210 } else {
211 rc = _falcon_reset_xaui_b(efx);
212 }
213 return rc;
214}
215
216static int falcon_xgmii_status(struct efx_nic *efx)
217{
218 efx_dword_t reg;
219
220 if (FALCON_REV(efx) < FALCON_REV_B0)
221 return 1;
222
223 /* The ISR latches, so clear it and re-read */
224 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
225 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
226
227 if (EFX_DWORD_FIELD(reg, XM_LCLFLT) ||
228 EFX_DWORD_FIELD(reg, XM_RMTFLT)) {
229 EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg));
230 return 0;
231 }
232
233 return 1;
234}
235
236static void falcon_mask_status_intr(struct efx_nic *efx, int enable)
237{
238 efx_dword_t reg;
239
240 if (FALCON_REV(efx) < FALCON_REV_B0)
241 return;
242
243 /* Flush the ISR */
244 if (enable)
245 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
246
247 EFX_POPULATE_DWORD_2(reg,
248 XM_MSK_RMTFLT, !enable,
249 XM_MSK_LCLFLT, !enable);
250 falcon_xmac_writel(efx, &reg, XM_MGT_INT_MSK_REG_MAC_B0);
251}
252
253int falcon_init_xmac(struct efx_nic *efx)
254{
255 int rc;
256
257 /* Initialize the PHY first so the clock is around */
258 rc = efx->phy_op->init(efx);
259 if (rc)
260 goto fail1;
261
262 rc = falcon_reset_xaui(efx);
263 if (rc)
264 goto fail2;
265
266 /* Wait again. Give the PHY and MAC time to come back */
267 schedule_timeout_uninterruptible(HZ / 10);
268
269 rc = falcon_reset_xmac(efx);
270 if (rc)
271 goto fail2;
272
273 falcon_mask_status_intr(efx, 1);
274 return 0;
275
276 fail2:
277 efx->phy_op->fini(efx);
278 fail1:
279 return rc;
280}
281
282int falcon_xaui_link_ok(struct efx_nic *efx)
283{
284 efx_dword_t reg;
285 int align_done, sync_status, link_ok = 0;
286
287 /* Read link status */
288 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
289
290 align_done = EFX_DWORD_FIELD(reg, XX_ALIGN_DONE);
291 sync_status = EFX_DWORD_FIELD(reg, XX_SYNC_STAT);
292 if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED))
293 link_ok = 1;
294
295 /* Clear link status ready for next read */
296 EFX_SET_DWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET);
297 EFX_SET_DWORD_FIELD(reg, XX_CHARERR, XX_CHARERR_RESET);
298 EFX_SET_DWORD_FIELD(reg, XX_DISPERR, XX_DISPERR_RESET);
299 falcon_xmac_writel(efx, &reg, XX_CORE_STAT_REG_MAC);
300
301 /* If the link is up, then check the phy side of the xaui link
302 * (error conditions from the wire side propoagate back through
303 * the phy to the xaui side). */
304 if (efx->link_up && link_ok) {
305 int has_phyxs = efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS);
306 if (has_phyxs)
307 link_ok = mdio_clause45_phyxgxs_lane_sync(efx);
308 }
309
310 /* If the PHY and XAUI links are up, then check the mac's xgmii
311 * fault state */
312 if (efx->link_up && link_ok)
313 link_ok = falcon_xgmii_status(efx);
314
315 return link_ok;
316}
317
318static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
319{
320 unsigned int max_frame_len;
321 efx_dword_t reg;
322 int rx_fc = (efx->flow_control & EFX_FC_RX) ? 1 : 0;
323
324 /* Configure MAC - cut-thru mode is hard wired on */
325 EFX_POPULATE_DWORD_3(reg,
326 XM_RX_JUMBO_MODE, 1,
327 XM_TX_STAT_EN, 1,
328 XM_RX_STAT_EN, 1);
329 falcon_xmac_writel(efx, &reg, XM_GLB_CFG_REG_MAC);
330
331 /* Configure TX */
332 EFX_POPULATE_DWORD_6(reg,
333 XM_TXEN, 1,
334 XM_TX_PRMBL, 1,
335 XM_AUTO_PAD, 1,
336 XM_TXCRC, 1,
337 XM_FCNTL, 1,
338 XM_IPG, 0x3);
339 falcon_xmac_writel(efx, &reg, XM_TX_CFG_REG_MAC);
340
341 /* Configure RX */
342 EFX_POPULATE_DWORD_5(reg,
343 XM_RXEN, 1,
344 XM_AUTO_DEPAD, 0,
345 XM_ACPT_ALL_MCAST, 1,
346 XM_ACPT_ALL_UCAST, efx->promiscuous,
347 XM_PASS_CRC_ERR, 1);
348 falcon_xmac_writel(efx, &reg, XM_RX_CFG_REG_MAC);
349
350 /* Set frame length */
351 max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu);
352 EFX_POPULATE_DWORD_1(reg, XM_MAX_RX_FRM_SIZE, max_frame_len);
353 falcon_xmac_writel(efx, &reg, XM_RX_PARAM_REG_MAC);
354 EFX_POPULATE_DWORD_2(reg,
355 XM_MAX_TX_FRM_SIZE, max_frame_len,
356 XM_TX_JUMBO_MODE, 1);
357 falcon_xmac_writel(efx, &reg, XM_TX_PARAM_REG_MAC);
358
359 EFX_POPULATE_DWORD_2(reg,
360 XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */
361 XM_DIS_FCNTL, rx_fc ? 0 : 1);
362 falcon_xmac_writel(efx, &reg, XM_FC_REG_MAC);
363
364 /* Set MAC address */
365 EFX_POPULATE_DWORD_4(reg,
366 XM_ADR_0, efx->net_dev->dev_addr[0],
367 XM_ADR_1, efx->net_dev->dev_addr[1],
368 XM_ADR_2, efx->net_dev->dev_addr[2],
369 XM_ADR_3, efx->net_dev->dev_addr[3]);
370 falcon_xmac_writel(efx, &reg, XM_ADR_LO_REG_MAC);
371 EFX_POPULATE_DWORD_2(reg,
372 XM_ADR_4, efx->net_dev->dev_addr[4],
373 XM_ADR_5, efx->net_dev->dev_addr[5]);
374 falcon_xmac_writel(efx, &reg, XM_ADR_HI_REG_MAC);
375}
376
377/* Try and bring the Falcon side of the Falcon-Phy XAUI link fails
378 * to come back up. Bash it until it comes back up */
379static int falcon_check_xaui_link_up(struct efx_nic *efx)
380{
381 int max_tries, tries;
382 tries = EFX_WORKAROUND_5147(efx) ? 5 : 1;
383 max_tries = tries;
384
385 if (efx->phy_type == PHY_TYPE_NONE)
386 return 0;
387
388 while (tries) {
389 if (falcon_xaui_link_ok(efx))
390 return 1;
391
392 EFX_LOG(efx, "%s Clobbering XAUI (%d tries left).\n",
393 __func__, tries);
394 (void) falcon_reset_xaui(efx);
395 udelay(200);
396 tries--;
397 }
398
399 EFX_ERR(efx, "Failed to bring XAUI link back up in %d tries!\n",
400 max_tries);
401 return 0;
402}
403
404void falcon_reconfigure_xmac(struct efx_nic *efx)
405{
406 int xaui_link_ok;
407
408 falcon_mask_status_intr(efx, 0);
409
410 falcon_deconfigure_mac_wrapper(efx);
411 efx->phy_op->reconfigure(efx);
412 falcon_reconfigure_xmac_core(efx);
413 falcon_reconfigure_mac_wrapper(efx);
414
415 /* Ensure XAUI link is up */
416 xaui_link_ok = falcon_check_xaui_link_up(efx);
417
418 if (xaui_link_ok && efx->link_up)
419 falcon_mask_status_intr(efx, 1);
420}
421
422void falcon_fini_xmac(struct efx_nic *efx)
423{
424 /* Isolate the MAC - PHY */
425 falcon_deconfigure_mac_wrapper(efx);
426
427 /* Potentially power down the PHY */
428 efx->phy_op->fini(efx);
429}
430
431void falcon_update_stats_xmac(struct efx_nic *efx)
432{
433 struct efx_mac_stats *mac_stats = &efx->mac_stats;
434 int rc;
435
436 rc = falcon_dma_stats(efx, XgDmaDone_offset);
437 if (rc)
438 return;
439
440 /* Update MAC stats from DMAed values */
441 FALCON_STAT(efx, XgRxOctets, rx_bytes);
442 FALCON_STAT(efx, XgRxOctetsOK, rx_good_bytes);
443 FALCON_STAT(efx, XgRxPkts, rx_packets);
444 FALCON_STAT(efx, XgRxPktsOK, rx_good);
445 FALCON_STAT(efx, XgRxBroadcastPkts, rx_broadcast);
446 FALCON_STAT(efx, XgRxMulticastPkts, rx_multicast);
447 FALCON_STAT(efx, XgRxUnicastPkts, rx_unicast);
448 FALCON_STAT(efx, XgRxUndersizePkts, rx_lt64);
449 FALCON_STAT(efx, XgRxOversizePkts, rx_gtjumbo);
450 FALCON_STAT(efx, XgRxJabberPkts, rx_bad_gtjumbo);
451 FALCON_STAT(efx, XgRxUndersizeFCSerrorPkts, rx_bad_lt64);
452 FALCON_STAT(efx, XgRxDropEvents, rx_overflow);
453 FALCON_STAT(efx, XgRxFCSerrorPkts, rx_bad);
454 FALCON_STAT(efx, XgRxAlignError, rx_align_error);
455 FALCON_STAT(efx, XgRxSymbolError, rx_symbol_error);
456 FALCON_STAT(efx, XgRxInternalMACError, rx_internal_error);
457 FALCON_STAT(efx, XgRxControlPkts, rx_control);
458 FALCON_STAT(efx, XgRxPausePkts, rx_pause);
459 FALCON_STAT(efx, XgRxPkts64Octets, rx_64);
460 FALCON_STAT(efx, XgRxPkts65to127Octets, rx_65_to_127);
461 FALCON_STAT(efx, XgRxPkts128to255Octets, rx_128_to_255);
462 FALCON_STAT(efx, XgRxPkts256to511Octets, rx_256_to_511);
463 FALCON_STAT(efx, XgRxPkts512to1023Octets, rx_512_to_1023);
464 FALCON_STAT(efx, XgRxPkts1024to15xxOctets, rx_1024_to_15xx);
465 FALCON_STAT(efx, XgRxPkts15xxtoMaxOctets, rx_15xx_to_jumbo);
466 FALCON_STAT(efx, XgRxLengthError, rx_length_error);
467 FALCON_STAT(efx, XgTxPkts, tx_packets);
468 FALCON_STAT(efx, XgTxOctets, tx_bytes);
469 FALCON_STAT(efx, XgTxMulticastPkts, tx_multicast);
470 FALCON_STAT(efx, XgTxBroadcastPkts, tx_broadcast);
471 FALCON_STAT(efx, XgTxUnicastPkts, tx_unicast);
472 FALCON_STAT(efx, XgTxControlPkts, tx_control);
473 FALCON_STAT(efx, XgTxPausePkts, tx_pause);
474 FALCON_STAT(efx, XgTxPkts64Octets, tx_64);
475 FALCON_STAT(efx, XgTxPkts65to127Octets, tx_65_to_127);
476 FALCON_STAT(efx, XgTxPkts128to255Octets, tx_128_to_255);
477 FALCON_STAT(efx, XgTxPkts256to511Octets, tx_256_to_511);
478 FALCON_STAT(efx, XgTxPkts512to1023Octets, tx_512_to_1023);
479 FALCON_STAT(efx, XgTxPkts1024to15xxOctets, tx_1024_to_15xx);
480 FALCON_STAT(efx, XgTxPkts1519toMaxOctets, tx_15xx_to_jumbo);
481 FALCON_STAT(efx, XgTxUndersizePkts, tx_lt64);
482 FALCON_STAT(efx, XgTxOversizePkts, tx_gtjumbo);
483 FALCON_STAT(efx, XgTxNonTcpUdpPkt, tx_non_tcpudp);
484 FALCON_STAT(efx, XgTxMacSrcErrPkt, tx_mac_src_error);
485 FALCON_STAT(efx, XgTxIpSrcErrPkt, tx_ip_src_error);
486
487 /* Update derived statistics */
488 mac_stats->tx_good_bytes =
489 (mac_stats->tx_bytes - mac_stats->tx_bad_bytes);
490 mac_stats->rx_bad_bytes =
491 (mac_stats->rx_bytes - mac_stats->rx_good_bytes);
492}
493
494#define EFX_XAUI_RETRAIN_MAX 8
495
496int falcon_check_xmac(struct efx_nic *efx)
497{
498 unsigned xaui_link_ok;
499 int rc;
500
501 falcon_mask_status_intr(efx, 0);
502 xaui_link_ok = falcon_xaui_link_ok(efx);
503
504 if (EFX_WORKAROUND_5147(efx) && !xaui_link_ok)
505 (void) falcon_reset_xaui(efx);
506
507 /* Call the PHY check_hw routine */
508 rc = efx->phy_op->check_hw(efx);
509
510 /* Unmask interrupt if everything was (and still is) ok */
511 if (xaui_link_ok && efx->link_up)
512 falcon_mask_status_intr(efx, 1);
513
514 return rc;
515}
516
517/* Simulate a PHY event */
518void falcon_xmac_sim_phy_event(struct efx_nic *efx)
519{
520 efx_qword_t phy_event;
521
522 EFX_POPULATE_QWORD_2(phy_event,
523 EV_CODE, GLOBAL_EV_DECODE,
524 XG_PHY_INTR, 1);
525 falcon_generate_event(&efx->channel[0], &phy_event);
526}
527
528int falcon_xmac_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
529{
530 mdio_clause45_get_settings(efx, ecmd);
531 ecmd->transceiver = XCVR_INTERNAL;
532 ecmd->phy_address = efx->mii.phy_id;
533 ecmd->autoneg = AUTONEG_DISABLE;
534 ecmd->duplex = DUPLEX_FULL;
535 return 0;
536}
537
538int falcon_xmac_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
539{
540 if (ecmd->transceiver != XCVR_INTERNAL)
541 return -EINVAL;
542 if (ecmd->autoneg != AUTONEG_DISABLE)
543 return -EINVAL;
544 if (ecmd->duplex != DUPLEX_FULL)
545 return -EINVAL;
546
547 return mdio_clause45_set_settings(efx, ecmd);
548}
549
550
551int falcon_xmac_set_pause(struct efx_nic *efx, enum efx_fc_type flow_control)
552{
553 int reset;
554
555 if (flow_control & EFX_FC_AUTO) {
556 EFX_LOG(efx, "10G does not support flow control "
557 "autonegotiation\n");
558 return -EINVAL;
559 }
560
561 if ((flow_control & EFX_FC_TX) && !(flow_control & EFX_FC_RX))
562 return -EINVAL;
563
564 /* TX flow control may automatically turn itself off if the
565 * link partner (intermittently) stops responding to pause
566 * frames. There isn't any indication that this has happened,
567 * so the best we do is leave it up to the user to spot this
568 * and fix it be cycling transmit flow control on this end. */
569 reset = ((flow_control & EFX_FC_TX) &&
570 !(efx->flow_control & EFX_FC_TX));
571 if (EFX_WORKAROUND_11482(efx) && reset) {
572 if (FALCON_REV(efx) >= FALCON_REV_B0) {
573 /* Recover by resetting the EM block */
574 if (efx->link_up)
575 falcon_drain_tx_fifo(efx);
576 } else {
577 /* Schedule a reset to recover */
578 efx_schedule_reset(efx, RESET_TYPE_INVISIBLE);
579 }
580 }
581
582 efx->flow_control = flow_control;
583
584 return 0;
585}
diff --git a/drivers/net/sfc/gmii.h b/drivers/net/sfc/gmii.h
new file mode 100644
index 000000000000..d25bbd1297f4
--- /dev/null
+++ b/drivers/net/sfc/gmii.h
@@ -0,0 +1,195 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_GMII_H
12#define EFX_GMII_H
13
14/*
15 * GMII interface
16 */
17
18#include <linux/mii.h>
19
20/* GMII registers, excluding registers already defined as MII
21 * registers in mii.h
22 */
23#define GMII_IER 0x12 /* Interrupt enable register */
24#define GMII_ISR 0x13 /* Interrupt status register */
25
26/* Interrupt enable register */
27#define IER_ANEG_ERR 0x8000 /* Bit 15 - autonegotiation error */
28#define IER_SPEED_CHG 0x4000 /* Bit 14 - speed changed */
29#define IER_DUPLEX_CHG 0x2000 /* Bit 13 - duplex changed */
30#define IER_PAGE_RCVD 0x1000 /* Bit 12 - page received */
31#define IER_ANEG_DONE 0x0800 /* Bit 11 - autonegotiation complete */
32#define IER_LINK_CHG 0x0400 /* Bit 10 - link status changed */
33#define IER_SYM_ERR 0x0200 /* Bit 9 - symbol error */
34#define IER_FALSE_CARRIER 0x0100 /* Bit 8 - false carrier */
35#define IER_FIFO_ERR 0x0080 /* Bit 7 - FIFO over/underflow */
36#define IER_MDIX_CHG 0x0040 /* Bit 6 - MDI crossover changed */
37#define IER_DOWNSHIFT 0x0020 /* Bit 5 - downshift */
38#define IER_ENERGY 0x0010 /* Bit 4 - energy detect */
39#define IER_DTE_POWER 0x0004 /* Bit 2 - DTE power detect */
40#define IER_POLARITY_CHG 0x0002 /* Bit 1 - polarity changed */
41#define IER_JABBER 0x0001 /* Bit 0 - jabber */
42
43/* Interrupt status register */
44#define ISR_ANEG_ERR 0x8000 /* Bit 15 - autonegotiation error */
45#define ISR_SPEED_CHG 0x4000 /* Bit 14 - speed changed */
46#define ISR_DUPLEX_CHG 0x2000 /* Bit 13 - duplex changed */
47#define ISR_PAGE_RCVD 0x1000 /* Bit 12 - page received */
48#define ISR_ANEG_DONE 0x0800 /* Bit 11 - autonegotiation complete */
49#define ISR_LINK_CHG 0x0400 /* Bit 10 - link status changed */
50#define ISR_SYM_ERR 0x0200 /* Bit 9 - symbol error */
51#define ISR_FALSE_CARRIER 0x0100 /* Bit 8 - false carrier */
52#define ISR_FIFO_ERR 0x0080 /* Bit 7 - FIFO over/underflow */
53#define ISR_MDIX_CHG 0x0040 /* Bit 6 - MDI crossover changed */
54#define ISR_DOWNSHIFT 0x0020 /* Bit 5 - downshift */
55#define ISR_ENERGY 0x0010 /* Bit 4 - energy detect */
56#define ISR_DTE_POWER 0x0004 /* Bit 2 - DTE power detect */
57#define ISR_POLARITY_CHG 0x0002 /* Bit 1 - polarity changed */
58#define ISR_JABBER 0x0001 /* Bit 0 - jabber */
59
60/* Logically extended advertisement register */
61#define GM_ADVERTISE_SLCT ADVERTISE_SLCT
62#define GM_ADVERTISE_CSMA ADVERTISE_CSMA
63#define GM_ADVERTISE_10HALF ADVERTISE_10HALF
64#define GM_ADVERTISE_1000XFULL ADVERTISE_1000XFULL
65#define GM_ADVERTISE_10FULL ADVERTISE_10FULL
66#define GM_ADVERTISE_1000XHALF ADVERTISE_1000XHALF
67#define GM_ADVERTISE_100HALF ADVERTISE_100HALF
68#define GM_ADVERTISE_1000XPAUSE ADVERTISE_1000XPAUSE
69#define GM_ADVERTISE_100FULL ADVERTISE_100FULL
70#define GM_ADVERTISE_1000XPSE_ASYM ADVERTISE_1000XPSE_ASYM
71#define GM_ADVERTISE_100BASE4 ADVERTISE_100BASE4
72#define GM_ADVERTISE_PAUSE_CAP ADVERTISE_PAUSE_CAP
73#define GM_ADVERTISE_PAUSE_ASYM ADVERTISE_PAUSE_ASYM
74#define GM_ADVERTISE_RESV ADVERTISE_RESV
75#define GM_ADVERTISE_RFAULT ADVERTISE_RFAULT
76#define GM_ADVERTISE_LPACK ADVERTISE_LPACK
77#define GM_ADVERTISE_NPAGE ADVERTISE_NPAGE
78#define GM_ADVERTISE_1000FULL (ADVERTISE_1000FULL << 8)
79#define GM_ADVERTISE_1000HALF (ADVERTISE_1000HALF << 8)
80#define GM_ADVERTISE_1000 (GM_ADVERTISE_1000FULL | \
81 GM_ADVERTISE_1000HALF)
82#define GM_ADVERTISE_FULL (GM_ADVERTISE_1000FULL | \
83 ADVERTISE_FULL)
84#define GM_ADVERTISE_ALL (GM_ADVERTISE_1000FULL | \
85 GM_ADVERTISE_1000HALF | \
86 ADVERTISE_ALL)
87
88/* Logically extended link partner ability register */
89#define GM_LPA_SLCT LPA_SLCT
90#define GM_LPA_10HALF LPA_10HALF
91#define GM_LPA_1000XFULL LPA_1000XFULL
92#define GM_LPA_10FULL LPA_10FULL
93#define GM_LPA_1000XHALF LPA_1000XHALF
94#define GM_LPA_100HALF LPA_100HALF
95#define GM_LPA_1000XPAUSE LPA_1000XPAUSE
96#define GM_LPA_100FULL LPA_100FULL
97#define GM_LPA_1000XPAUSE_ASYM LPA_1000XPAUSE_ASYM
98#define GM_LPA_100BASE4 LPA_100BASE4
99#define GM_LPA_PAUSE_CAP LPA_PAUSE_CAP
100#define GM_LPA_PAUSE_ASYM LPA_PAUSE_ASYM
101#define GM_LPA_RESV LPA_RESV
102#define GM_LPA_RFAULT LPA_RFAULT
103#define GM_LPA_LPACK LPA_LPACK
104#define GM_LPA_NPAGE LPA_NPAGE
105#define GM_LPA_1000FULL (LPA_1000FULL << 6)
106#define GM_LPA_1000HALF (LPA_1000HALF << 6)
107#define GM_LPA_10000FULL 0x00040000
108#define GM_LPA_10000HALF 0x00080000
109#define GM_LPA_DUPLEX (GM_LPA_1000FULL | GM_LPA_10000FULL \
110 | LPA_DUPLEX)
111#define GM_LPA_10 (LPA_10FULL | LPA_10HALF)
112#define GM_LPA_100 LPA_100
113#define GM_LPA_1000 (GM_LPA_1000FULL | GM_LPA_1000HALF)
114#define GM_LPA_10000 (GM_LPA_10000FULL | GM_LPA_10000HALF)
115
116/* Retrieve GMII autonegotiation advertised abilities
117 *
118 * The MII advertisment register (MII_ADVERTISE) is logically extended
119 * to include advertisement bits ADVERTISE_1000FULL and
120 * ADVERTISE_1000HALF from MII_CTRL1000. The result can be tested
121 * against the GM_ADVERTISE_xxx constants.
122 */
123static inline unsigned int gmii_advertised(struct mii_if_info *gmii)
124{
125 unsigned int advertise;
126 unsigned int ctrl1000;
127
128 advertise = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_ADVERTISE);
129 ctrl1000 = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_CTRL1000);
130 return (((ctrl1000 << 8) & GM_ADVERTISE_1000) | advertise);
131}
132
133/* Retrieve GMII autonegotiation link partner abilities
134 *
135 * The MII link partner ability register (MII_LPA) is logically
136 * extended by adding bits LPA_1000HALF and LPA_1000FULL from
137 * MII_STAT1000. The result can be tested against the GM_LPA_xxx
138 * constants.
139 */
140static inline unsigned int gmii_lpa(struct mii_if_info *gmii)
141{
142 unsigned int lpa;
143 unsigned int stat1000;
144
145 lpa = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_LPA);
146 stat1000 = gmii->mdio_read(gmii->dev, gmii->phy_id, MII_STAT1000);
147 return (((stat1000 << 6) & GM_LPA_1000) | lpa);
148}
149
150/* Calculate GMII autonegotiated link technology
151 *
152 * "negotiated" should be the result of gmii_advertised() logically
153 * ANDed with the result of gmii_lpa().
154 *
155 * "tech" will be negotiated with the unused bits masked out. For
156 * example, if both ends of the link are capable of both
157 * GM_LPA_1000FULL and GM_LPA_100FULL, GM_LPA_100FULL will be masked
158 * out.
159 */
160static inline unsigned int gmii_nway_result(unsigned int negotiated)
161{
162 unsigned int other_bits;
163
164 /* Mask out the speed and duplexity bits */
165 other_bits = negotiated & ~(GM_LPA_10 | GM_LPA_100 | GM_LPA_1000);
166
167 if (negotiated & GM_LPA_1000FULL)
168 return (other_bits | GM_LPA_1000FULL);
169 else if (negotiated & GM_LPA_1000HALF)
170 return (other_bits | GM_LPA_1000HALF);
171 else
172 return (other_bits | mii_nway_result(negotiated));
173}
174
175/* Calculate GMII non-autonegotiated link technology
176 *
177 * This provides an equivalent to gmii_nway_result for the case when
178 * autonegotiation is disabled.
179 */
180static inline unsigned int gmii_forced_result(unsigned int bmcr)
181{
182 unsigned int result;
183 int full_duplex;
184
185 full_duplex = bmcr & BMCR_FULLDPLX;
186 if (bmcr & BMCR_SPEED1000)
187 result = full_duplex ? GM_LPA_1000FULL : GM_LPA_1000HALF;
188 else if (bmcr & BMCR_SPEED100)
189 result = full_duplex ? GM_LPA_100FULL : GM_LPA_100HALF;
190 else
191 result = full_duplex ? GM_LPA_10FULL : GM_LPA_10HALF;
192 return result;
193}
194
195#endif /* EFX_GMII_H */
diff --git a/drivers/net/sfc/i2c-direct.c b/drivers/net/sfc/i2c-direct.c
new file mode 100644
index 000000000000..b6c62d0ed9c2
--- /dev/null
+++ b/drivers/net/sfc/i2c-direct.c
@@ -0,0 +1,381 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/delay.h>
12#include "net_driver.h"
13#include "i2c-direct.h"
14
15/*
16 * I2C data (SDA) and clock (SCL) line read/writes with appropriate
17 * delays.
18 */
19
20static inline void setsda(struct efx_i2c_interface *i2c, int state)
21{
22 udelay(i2c->op->udelay);
23 i2c->sda = state;
24 i2c->op->setsda(i2c);
25 udelay(i2c->op->udelay);
26}
27
28static inline void setscl(struct efx_i2c_interface *i2c, int state)
29{
30 udelay(i2c->op->udelay);
31 i2c->scl = state;
32 i2c->op->setscl(i2c);
33 udelay(i2c->op->udelay);
34}
35
36static inline int getsda(struct efx_i2c_interface *i2c)
37{
38 int sda;
39
40 udelay(i2c->op->udelay);
41 sda = i2c->op->getsda(i2c);
42 udelay(i2c->op->udelay);
43 return sda;
44}
45
46static inline int getscl(struct efx_i2c_interface *i2c)
47{
48 int scl;
49
50 udelay(i2c->op->udelay);
51 scl = i2c->op->getscl(i2c);
52 udelay(i2c->op->udelay);
53 return scl;
54}
55
56/*
57 * I2C low-level protocol operations
58 *
59 */
60
61static inline void i2c_release(struct efx_i2c_interface *i2c)
62{
63 EFX_WARN_ON_PARANOID(!i2c->scl);
64 EFX_WARN_ON_PARANOID(!i2c->sda);
65 /* Devices may time out if operations do not end */
66 setscl(i2c, 1);
67 setsda(i2c, 1);
68 EFX_BUG_ON_PARANOID(getsda(i2c) != 1);
69 EFX_BUG_ON_PARANOID(getscl(i2c) != 1);
70}
71
72static inline void i2c_start(struct efx_i2c_interface *i2c)
73{
74 /* We may be restarting immediately after a {send,recv}_bit,
75 * so SCL will not necessarily already be high.
76 */
77 EFX_WARN_ON_PARANOID(!i2c->sda);
78 setscl(i2c, 1);
79 setsda(i2c, 0);
80 setscl(i2c, 0);
81 setsda(i2c, 1);
82}
83
84static inline void i2c_send_bit(struct efx_i2c_interface *i2c, int bit)
85{
86 EFX_WARN_ON_PARANOID(i2c->scl != 0);
87 setsda(i2c, bit);
88 setscl(i2c, 1);
89 setscl(i2c, 0);
90 setsda(i2c, 1);
91}
92
93static inline int i2c_recv_bit(struct efx_i2c_interface *i2c)
94{
95 int bit;
96
97 EFX_WARN_ON_PARANOID(i2c->scl != 0);
98 EFX_WARN_ON_PARANOID(!i2c->sda);
99 setscl(i2c, 1);
100 bit = getsda(i2c);
101 setscl(i2c, 0);
102 return bit;
103}
104
105static inline void i2c_stop(struct efx_i2c_interface *i2c)
106{
107 EFX_WARN_ON_PARANOID(i2c->scl != 0);
108 setsda(i2c, 0);
109 setscl(i2c, 1);
110 setsda(i2c, 1);
111}
112
113/*
114 * I2C mid-level protocol operations
115 *
116 */
117
118/* Sends a byte via the I2C bus and checks for an acknowledgement from
119 * the slave device.
120 */
121static int i2c_send_byte(struct efx_i2c_interface *i2c, u8 byte)
122{
123 int i;
124
125 /* Send byte */
126 for (i = 0; i < 8; i++) {
127 i2c_send_bit(i2c, !!(byte & 0x80));
128 byte <<= 1;
129 }
130
131 /* Check for acknowledgement from slave */
132 return (i2c_recv_bit(i2c) == 0 ? 0 : -EIO);
133}
134
135/* Receives a byte via the I2C bus and sends ACK/NACK to the slave device. */
136static u8 i2c_recv_byte(struct efx_i2c_interface *i2c, int ack)
137{
138 u8 value = 0;
139 int i;
140
141 /* Receive byte */
142 for (i = 0; i < 8; i++)
143 value = (value << 1) | i2c_recv_bit(i2c);
144
145 /* Send ACK/NACK */
146 i2c_send_bit(i2c, (ack ? 0 : 1));
147
148 return value;
149}
150
151/* Calculate command byte for a read operation */
152static inline u8 i2c_read_cmd(u8 device_id)
153{
154 return ((device_id << 1) | 1);
155}
156
157/* Calculate command byte for a write operation */
158static inline u8 i2c_write_cmd(u8 device_id)
159{
160 return ((device_id << 1) | 0);
161}
162
163int efx_i2c_check_presence(struct efx_i2c_interface *i2c, u8 device_id)
164{
165 int rc;
166
167 /* If someone is driving the bus low we just give up. */
168 if (getsda(i2c) == 0 || getscl(i2c) == 0) {
169 EFX_ERR(i2c->efx, "%s someone is holding the I2C bus low."
170 " Giving up.\n", __func__);
171 return -EFAULT;
172 }
173
174 /* Pretend to initiate a device write */
175 i2c_start(i2c);
176 rc = i2c_send_byte(i2c, i2c_write_cmd(device_id));
177 if (rc)
178 goto out;
179
180 out:
181 i2c_stop(i2c);
182 i2c_release(i2c);
183
184 return rc;
185}
186
187/* This performs a fast read of one or more consecutive bytes from an
188 * I2C device. Not all devices support consecutive reads of more than
189 * one byte; for these devices use efx_i2c_read() instead.
190 */
191int efx_i2c_fast_read(struct efx_i2c_interface *i2c,
192 u8 device_id, u8 offset, u8 *data, unsigned int len)
193{
194 int i;
195 int rc;
196
197 EFX_WARN_ON_PARANOID(getsda(i2c) != 1);
198 EFX_WARN_ON_PARANOID(getscl(i2c) != 1);
199 EFX_WARN_ON_PARANOID(data == NULL);
200 EFX_WARN_ON_PARANOID(len < 1);
201
202 /* Select device and starting offset */
203 i2c_start(i2c);
204 rc = i2c_send_byte(i2c, i2c_write_cmd(device_id));
205 if (rc)
206 goto out;
207 rc = i2c_send_byte(i2c, offset);
208 if (rc)
209 goto out;
210
211 /* Read data from device */
212 i2c_start(i2c);
213 rc = i2c_send_byte(i2c, i2c_read_cmd(device_id));
214 if (rc)
215 goto out;
216 for (i = 0; i < (len - 1); i++)
217 /* Read and acknowledge all but the last byte */
218 data[i] = i2c_recv_byte(i2c, 1);
219 /* Read last byte with no acknowledgement */
220 data[i] = i2c_recv_byte(i2c, 0);
221
222 out:
223 i2c_stop(i2c);
224 i2c_release(i2c);
225
226 return rc;
227}
228
229/* This performs a fast write of one or more consecutive bytes to an
230 * I2C device. Not all devices support consecutive writes of more
231 * than one byte; for these devices use efx_i2c_write() instead.
232 */
233int efx_i2c_fast_write(struct efx_i2c_interface *i2c,
234 u8 device_id, u8 offset,
235 const u8 *data, unsigned int len)
236{
237 int i;
238 int rc;
239
240 EFX_WARN_ON_PARANOID(getsda(i2c) != 1);
241 EFX_WARN_ON_PARANOID(getscl(i2c) != 1);
242 EFX_WARN_ON_PARANOID(len < 1);
243
244 /* Select device and starting offset */
245 i2c_start(i2c);
246 rc = i2c_send_byte(i2c, i2c_write_cmd(device_id));
247 if (rc)
248 goto out;
249 rc = i2c_send_byte(i2c, offset);
250 if (rc)
251 goto out;
252
253 /* Write data to device */
254 for (i = 0; i < len; i++) {
255 rc = i2c_send_byte(i2c, data[i]);
256 if (rc)
257 goto out;
258 }
259
260 out:
261 i2c_stop(i2c);
262 i2c_release(i2c);
263
264 return rc;
265}
266
267/* I2C byte-by-byte read */
268int efx_i2c_read(struct efx_i2c_interface *i2c,
269 u8 device_id, u8 offset, u8 *data, unsigned int len)
270{
271 int rc;
272
273 /* i2c_fast_read with length 1 is a single byte read */
274 for (; len > 0; offset++, data++, len--) {
275 rc = efx_i2c_fast_read(i2c, device_id, offset, data, 1);
276 if (rc)
277 return rc;
278 }
279
280 return 0;
281}
282
283/* I2C byte-by-byte write */
284int efx_i2c_write(struct efx_i2c_interface *i2c,
285 u8 device_id, u8 offset, const u8 *data, unsigned int len)
286{
287 int rc;
288
289 /* i2c_fast_write with length 1 is a single byte write */
290 for (; len > 0; offset++, data++, len--) {
291 rc = efx_i2c_fast_write(i2c, device_id, offset, data, 1);
292 if (rc)
293 return rc;
294 mdelay(i2c->op->mdelay);
295 }
296
297 return 0;
298}
299
300
301/* This is just a slightly neater wrapper round efx_i2c_fast_write
302 * in the case where the target doesn't take an offset
303 */
304int efx_i2c_send_bytes(struct efx_i2c_interface *i2c,
305 u8 device_id, const u8 *data, unsigned int len)
306{
307 return efx_i2c_fast_write(i2c, device_id, data[0], data + 1, len - 1);
308}
309
310/* I2C receiving of bytes - does not send an offset byte */
311int efx_i2c_recv_bytes(struct efx_i2c_interface *i2c, u8 device_id,
312 u8 *bytes, unsigned int len)
313{
314 int i;
315 int rc;
316
317 EFX_WARN_ON_PARANOID(getsda(i2c) != 1);
318 EFX_WARN_ON_PARANOID(getscl(i2c) != 1);
319 EFX_WARN_ON_PARANOID(len < 1);
320
321 /* Select device */
322 i2c_start(i2c);
323
324 /* Read data from device */
325 rc = i2c_send_byte(i2c, i2c_read_cmd(device_id));
326 if (rc)
327 goto out;
328
329 for (i = 0; i < (len - 1); i++)
330 /* Read and acknowledge all but the last byte */
331 bytes[i] = i2c_recv_byte(i2c, 1);
332 /* Read last byte with no acknowledgement */
333 bytes[i] = i2c_recv_byte(i2c, 0);
334
335 out:
336 i2c_stop(i2c);
337 i2c_release(i2c);
338
339 return rc;
340}
341
342/* SMBus and some I2C devices will time out if the I2C clock is
343 * held low for too long. This is most likely to happen in virtualised
344 * systems (when the entire domain is descheduled) but could in
345 * principle happen due to preemption on any busy system (and given the
346 * potential length of an I2C operation turning preemption off is not
347 * a sensible option). The following functions deal with the failure by
348 * retrying up to a fixed number of times.
349 */
350
351#define I2C_MAX_RETRIES (10)
352
353/* The timeout problem will result in -EIO. If the wrapped function
354 * returns any other error, pass this up and do not retry. */
355#define RETRY_WRAPPER(_f) \
356 int retries = I2C_MAX_RETRIES; \
357 int rc; \
358 while (retries) { \
359 rc = _f; \
360 if (rc != -EIO) \
361 return rc; \
362 retries--; \
363 } \
364 return rc; \
365
366int efx_i2c_check_presence_retry(struct efx_i2c_interface *i2c, u8 device_id)
367{
368 RETRY_WRAPPER(efx_i2c_check_presence(i2c, device_id))
369}
370
371int efx_i2c_read_retry(struct efx_i2c_interface *i2c,
372 u8 device_id, u8 offset, u8 *data, unsigned int len)
373{
374 RETRY_WRAPPER(efx_i2c_read(i2c, device_id, offset, data, len))
375}
376
377int efx_i2c_write_retry(struct efx_i2c_interface *i2c,
378 u8 device_id, u8 offset, const u8 *data, unsigned int len)
379{
380 RETRY_WRAPPER(efx_i2c_write(i2c, device_id, offset, data, len))
381}
diff --git a/drivers/net/sfc/i2c-direct.h b/drivers/net/sfc/i2c-direct.h
new file mode 100644
index 000000000000..291e561071f5
--- /dev/null
+++ b/drivers/net/sfc/i2c-direct.h
@@ -0,0 +1,91 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005 Fen Systems Ltd.
4 * Copyright 2006 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_I2C_DIRECT_H
12#define EFX_I2C_DIRECT_H
13
14#include "net_driver.h"
15
16/*
17 * Direct control of an I2C bus
18 */
19
20struct efx_i2c_interface;
21
22/**
23 * struct efx_i2c_bit_operations - I2C bus direct control methods
24 *
25 * I2C bus direct control methods.
26 *
27 * @setsda: Set state of SDA line
28 * @setscl: Set state of SCL line
29 * @getsda: Get state of SDA line
30 * @getscl: Get state of SCL line
31 * @udelay: Delay between each bit operation
32 * @mdelay: Delay between each byte write
33 */
34struct efx_i2c_bit_operations {
35 void (*setsda) (struct efx_i2c_interface *i2c);
36 void (*setscl) (struct efx_i2c_interface *i2c);
37 int (*getsda) (struct efx_i2c_interface *i2c);
38 int (*getscl) (struct efx_i2c_interface *i2c);
39 unsigned int udelay;
40 unsigned int mdelay;
41};
42
43/**
44 * struct efx_i2c_interface - an I2C interface
45 *
46 * An I2C interface.
47 *
48 * @efx: Attached Efx NIC
49 * @op: I2C bus control methods
50 * @sda: Current output state of SDA line
51 * @scl: Current output state of SCL line
52 */
53struct efx_i2c_interface {
54 struct efx_nic *efx;
55 struct efx_i2c_bit_operations *op;
56 unsigned int sda:1;
57 unsigned int scl:1;
58};
59
60extern int efx_i2c_check_presence(struct efx_i2c_interface *i2c, u8 device_id);
61extern int efx_i2c_fast_read(struct efx_i2c_interface *i2c,
62 u8 device_id, u8 offset,
63 u8 *data, unsigned int len);
64extern int efx_i2c_fast_write(struct efx_i2c_interface *i2c,
65 u8 device_id, u8 offset,
66 const u8 *data, unsigned int len);
67extern int efx_i2c_read(struct efx_i2c_interface *i2c,
68 u8 device_id, u8 offset, u8 *data, unsigned int len);
69extern int efx_i2c_write(struct efx_i2c_interface *i2c,
70 u8 device_id, u8 offset,
71 const u8 *data, unsigned int len);
72
73extern int efx_i2c_send_bytes(struct efx_i2c_interface *i2c, u8 device_id,
74 const u8 *bytes, unsigned int len);
75
76extern int efx_i2c_recv_bytes(struct efx_i2c_interface *i2c, u8 device_id,
77 u8 *bytes, unsigned int len);
78
79
80/* Versions of the API that retry on failure. */
81extern int efx_i2c_check_presence_retry(struct efx_i2c_interface *i2c,
82 u8 device_id);
83
84extern int efx_i2c_read_retry(struct efx_i2c_interface *i2c,
85 u8 device_id, u8 offset, u8 *data, unsigned int len);
86
87extern int efx_i2c_write_retry(struct efx_i2c_interface *i2c,
88 u8 device_id, u8 offset,
89 const u8 *data, unsigned int len);
90
91#endif /* EFX_I2C_DIRECT_H */
diff --git a/drivers/net/sfc/mac.h b/drivers/net/sfc/mac.h
new file mode 100644
index 000000000000..edd07d4dee18
--- /dev/null
+++ b/drivers/net/sfc/mac.h
@@ -0,0 +1,33 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2007 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_MAC_H
12#define EFX_MAC_H
13
14#include "net_driver.h"
15
16extern void falcon_xmac_writel(struct efx_nic *efx,
17 efx_dword_t *value, unsigned int mac_reg);
18extern void falcon_xmac_readl(struct efx_nic *efx,
19 efx_dword_t *value, unsigned int mac_reg);
20extern int falcon_init_xmac(struct efx_nic *efx);
21extern void falcon_reconfigure_xmac(struct efx_nic *efx);
22extern void falcon_update_stats_xmac(struct efx_nic *efx);
23extern void falcon_fini_xmac(struct efx_nic *efx);
24extern int falcon_check_xmac(struct efx_nic *efx);
25extern void falcon_xmac_sim_phy_event(struct efx_nic *efx);
26extern int falcon_xmac_get_settings(struct efx_nic *efx,
27 struct ethtool_cmd *ecmd);
28extern int falcon_xmac_set_settings(struct efx_nic *efx,
29 struct ethtool_cmd *ecmd);
30extern int falcon_xmac_set_pause(struct efx_nic *efx,
31 enum efx_fc_type pause_params);
32
33#endif
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
new file mode 100644
index 000000000000..dc06bb0aa575
--- /dev/null
+++ b/drivers/net/sfc/mdio_10g.c
@@ -0,0 +1,282 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006-2008 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9/*
10 * Useful functions for working with MDIO clause 45 PHYs
11 */
12#include <linux/types.h>
13#include <linux/ethtool.h>
14#include <linux/delay.h>
15#include "net_driver.h"
16#include "mdio_10g.h"
17#include "boards.h"
18
19int mdio_clause45_reset_mmd(struct efx_nic *port, int mmd,
20 int spins, int spintime)
21{
22 u32 ctrl;
23 int phy_id = port->mii.phy_id;
24
25 /* Catch callers passing values in the wrong units (or just silly) */
26 EFX_BUG_ON_PARANOID(spins * spintime >= 5000);
27
28 mdio_clause45_write(port, phy_id, mmd, MDIO_MMDREG_CTRL1,
29 (1 << MDIO_MMDREG_CTRL1_RESET_LBN));
30 /* Wait for the reset bit to clear. */
31 do {
32 msleep(spintime);
33 ctrl = mdio_clause45_read(port, phy_id, mmd, MDIO_MMDREG_CTRL1);
34 spins--;
35
36 } while (spins && (ctrl & (1 << MDIO_MMDREG_CTRL1_RESET_LBN)));
37
38 return spins ? spins : -ETIMEDOUT;
39}
40
41static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd,
42 int fault_fatal)
43{
44 int status;
45 int phy_id = efx->mii.phy_id;
46
47 /* Read MMD STATUS2 to check it is responding. */
48 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2);
49 if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) &
50 ((1 << MDIO_MMDREG_STAT2_PRESENT_WIDTH) - 1)) !=
51 MDIO_MMDREG_STAT2_PRESENT_VAL) {
52 EFX_ERR(efx, "PHY MMD %d not responding.\n", mmd);
53 return -EIO;
54 }
55
56 /* Read MMD STATUS 1 to check for fault. */
57 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT1);
58 if ((status & (1 << MDIO_MMDREG_STAT1_FAULT_LBN)) != 0) {
59 if (fault_fatal) {
60 EFX_ERR(efx, "PHY MMD %d reporting fatal"
61 " fault: status %x\n", mmd, status);
62 return -EIO;
63 } else {
64 EFX_LOG(efx, "PHY MMD %d reporting status"
65 " %x (expected)\n", mmd, status);
66 }
67 }
68 return 0;
69}
70
71/* This ought to be ridiculous overkill. We expect it to fail rarely */
72#define MDIO45_RESET_TIME 1000 /* ms */
73#define MDIO45_RESET_ITERS 100
74
75int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
76 unsigned int mmd_mask)
77{
78 const int spintime = MDIO45_RESET_TIME / MDIO45_RESET_ITERS;
79 int tries = MDIO45_RESET_ITERS;
80 int rc = 0;
81 int in_reset;
82
83 while (tries) {
84 int mask = mmd_mask;
85 int mmd = 0;
86 int stat;
87 in_reset = 0;
88 while (mask) {
89 if (mask & 1) {
90 stat = mdio_clause45_read(efx,
91 efx->mii.phy_id,
92 mmd,
93 MDIO_MMDREG_CTRL1);
94 if (stat < 0) {
95 EFX_ERR(efx, "failed to read status of"
96 " MMD %d\n", mmd);
97 return -EIO;
98 }
99 if (stat & (1 << MDIO_MMDREG_CTRL1_RESET_LBN))
100 in_reset |= (1 << mmd);
101 }
102 mask = mask >> 1;
103 mmd++;
104 }
105 if (!in_reset)
106 break;
107 tries--;
108 msleep(spintime);
109 }
110 if (in_reset != 0) {
111 EFX_ERR(efx, "not all MMDs came out of reset in time."
112 " MMDs still in reset: %x\n", in_reset);
113 rc = -ETIMEDOUT;
114 }
115 return rc;
116}
117
118int mdio_clause45_check_mmds(struct efx_nic *efx,
119 unsigned int mmd_mask, unsigned int fatal_mask)
120{
121 int devices, mmd = 0;
122 int probe_mmd;
123
124 /* Historically we have probed the PHYXS to find out what devices are
125 * present,but that doesn't work so well if the PHYXS isn't expected
126 * to exist, if so just find the first item in the list supplied. */
127 probe_mmd = (mmd_mask & MDIO_MMDREG_DEVS0_PHYXS) ? MDIO_MMD_PHYXS :
128 __ffs(mmd_mask);
129 devices = mdio_clause45_read(efx, efx->mii.phy_id,
130 probe_mmd, MDIO_MMDREG_DEVS0);
131
132 /* Check all the expected MMDs are present */
133 if (devices < 0) {
134 EFX_ERR(efx, "failed to read devices present\n");
135 return -EIO;
136 }
137 if ((devices & mmd_mask) != mmd_mask) {
138 EFX_ERR(efx, "required MMDs not present: got %x, "
139 "wanted %x\n", devices, mmd_mask);
140 return -ENODEV;
141 }
142 EFX_TRACE(efx, "Devices present: %x\n", devices);
143
144 /* Check all required MMDs are responding and happy. */
145 while (mmd_mask) {
146 if (mmd_mask & 1) {
147 int fault_fatal = fatal_mask & 1;
148 if (mdio_clause45_check_mmd(efx, mmd, fault_fatal))
149 return -EIO;
150 }
151 mmd_mask = mmd_mask >> 1;
152 fatal_mask = fatal_mask >> 1;
153 mmd++;
154 }
155
156 return 0;
157}
158
159int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
160{
161 int phy_id = efx->mii.phy_id;
162 int status;
163 int ok = 1;
164 int mmd = 0;
165 int good;
166
167 while (mmd_mask) {
168 if (mmd_mask & 1) {
169 /* Double reads because link state is latched, and a
170 * read moves the current state into the register */
171 status = mdio_clause45_read(efx, phy_id,
172 mmd, MDIO_MMDREG_STAT1);
173 status = mdio_clause45_read(efx, phy_id,
174 mmd, MDIO_MMDREG_STAT1);
175
176 good = status & (1 << MDIO_MMDREG_STAT1_LINK_LBN);
177 ok = ok && good;
178 }
179 mmd_mask = (mmd_mask >> 1);
180 mmd++;
181 }
182 return ok;
183}
184
185/**
186 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO.
187 * @efx: Efx NIC
188 * @ecmd: Buffer for settings
189 *
190 * On return the 'port', 'speed', 'supported' and 'advertising' fields of
191 * ecmd have been filled out based on the PMA type.
192 */
193void mdio_clause45_get_settings(struct efx_nic *efx,
194 struct ethtool_cmd *ecmd)
195{
196 int pma_type;
197
198 /* If no PMA is present we are presumably talking something XAUI-ish
199 * like CX4. Which we report as FIBRE (see below) */
200 if ((efx->phy_op->mmds & DEV_PRESENT_BIT(MDIO_MMD_PMAPMD)) == 0) {
201 ecmd->speed = SPEED_10000;
202 ecmd->port = PORT_FIBRE;
203 ecmd->supported = SUPPORTED_FIBRE;
204 ecmd->advertising = ADVERTISED_FIBRE;
205 return;
206 }
207
208 pma_type = mdio_clause45_read(efx, efx->mii.phy_id,
209 MDIO_MMD_PMAPMD, MDIO_MMDREG_CTRL2);
210 pma_type &= MDIO_PMAPMD_CTRL2_TYPE_MASK;
211
212 switch (pma_type) {
213 /* We represent CX4 as fibre in the absence of anything
214 better. */
215 case MDIO_PMAPMD_CTRL2_10G_CX4:
216 ecmd->speed = SPEED_10000;
217 ecmd->port = PORT_FIBRE;
218 ecmd->supported = SUPPORTED_FIBRE;
219 ecmd->advertising = ADVERTISED_FIBRE;
220 break;
221 /* 10G Base-T */
222 case MDIO_PMAPMD_CTRL2_10G_BT:
223 ecmd->speed = SPEED_10000;
224 ecmd->port = PORT_TP;
225 ecmd->supported = SUPPORTED_TP | SUPPORTED_10000baseT_Full;
226 ecmd->advertising = (ADVERTISED_FIBRE
227 | ADVERTISED_10000baseT_Full);
228 break;
229 case MDIO_PMAPMD_CTRL2_1G_BT:
230 ecmd->speed = SPEED_1000;
231 ecmd->port = PORT_TP;
232 ecmd->supported = SUPPORTED_TP | SUPPORTED_1000baseT_Full;
233 ecmd->advertising = (ADVERTISED_FIBRE
234 | ADVERTISED_1000baseT_Full);
235 break;
236 case MDIO_PMAPMD_CTRL2_100_BT:
237 ecmd->speed = SPEED_100;
238 ecmd->port = PORT_TP;
239 ecmd->supported = SUPPORTED_TP | SUPPORTED_100baseT_Full;
240 ecmd->advertising = (ADVERTISED_FIBRE
241 | ADVERTISED_100baseT_Full);
242 break;
243 case MDIO_PMAPMD_CTRL2_10_BT:
244 ecmd->speed = SPEED_10;
245 ecmd->port = PORT_TP;
246 ecmd->supported = SUPPORTED_TP | SUPPORTED_10baseT_Full;
247 ecmd->advertising = ADVERTISED_FIBRE | ADVERTISED_10baseT_Full;
248 break;
249 /* All the other defined modes are flavours of
250 * 10G optical */
251 default:
252 ecmd->speed = SPEED_10000;
253 ecmd->port = PORT_FIBRE;
254 ecmd->supported = SUPPORTED_FIBRE;
255 ecmd->advertising = ADVERTISED_FIBRE;
256 break;
257 }
258}
259
260/**
261 * mdio_clause45_set_settings - Set (some of) the PHY settings over MDIO.
262 * @efx: Efx NIC
263 * @ecmd: New settings
264 *
265 * Currently this just enforces that we are _not_ changing the
266 * 'port', 'speed', 'supported' or 'advertising' settings as these
267 * cannot be changed on any currently supported PHY.
268 */
269int mdio_clause45_set_settings(struct efx_nic *efx,
270 struct ethtool_cmd *ecmd)
271{
272 struct ethtool_cmd tmpcmd;
273 mdio_clause45_get_settings(efx, &tmpcmd);
274 /* None of the current PHYs support more than one mode
275 * of operation (and only 10GBT ever will), so keep things
276 * simple for now */
277 if ((ecmd->speed == tmpcmd.speed) && (ecmd->port == tmpcmd.port) &&
278 (ecmd->supported == tmpcmd.supported) &&
279 (ecmd->advertising == tmpcmd.advertising))
280 return 0;
281 return -EOPNOTSUPP;
282}
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
new file mode 100644
index 000000000000..2214b6d820a7
--- /dev/null
+++ b/drivers/net/sfc/mdio_10g.h
@@ -0,0 +1,232 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006-2008 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_MDIO_10G_H
11#define EFX_MDIO_10G_H
12
13/*
14 * Definitions needed for doing 10G MDIO as specified in clause 45
15 * MDIO, which do not appear in Linux yet. Also some helper functions.
16 */
17
18#include "efx.h"
19#include "boards.h"
20
21/* Numbering of the MDIO Manageable Devices (MMDs) */
22/* Physical Medium Attachment/ Physical Medium Dependent sublayer */
23#define MDIO_MMD_PMAPMD (1)
24/* WAN Interface Sublayer */
25#define MDIO_MMD_WIS (2)
26/* Physical Coding Sublayer */
27#define MDIO_MMD_PCS (3)
28/* PHY Extender Sublayer */
29#define MDIO_MMD_PHYXS (4)
30/* Extender Sublayer */
31#define MDIO_MMD_DTEXS (5)
32/* Transmission convergence */
33#define MDIO_MMD_TC (6)
34/* Auto negotiation */
35#define MDIO_MMD_AN (7)
36
37/* Generic register locations */
38#define MDIO_MMDREG_CTRL1 (0)
39#define MDIO_MMDREG_STAT1 (1)
40#define MDIO_MMDREG_IDHI (2)
41#define MDIO_MMDREG_IDLOW (3)
42#define MDIO_MMDREG_SPEED (4)
43#define MDIO_MMDREG_DEVS0 (5)
44#define MDIO_MMDREG_DEVS1 (6)
45#define MDIO_MMDREG_CTRL2 (7)
46#define MDIO_MMDREG_STAT2 (8)
47
48/* Bits in MMDREG_CTRL1 */
49/* Reset */
50#define MDIO_MMDREG_CTRL1_RESET_LBN (15)
51#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1)
52
53/* Bits in MMDREG_STAT1 */
54#define MDIO_MMDREG_STAT1_FAULT_LBN (7)
55#define MDIO_MMDREG_STAT1_FAULT_WIDTH (1)
56/* Link state */
57#define MDIO_MMDREG_STAT1_LINK_LBN (2)
58#define MDIO_MMDREG_STAT1_LINK_WIDTH (1)
59
60/* Bits in ID reg */
61#define MDIO_ID_REV(_id32) (_id32 & 0xf)
62#define MDIO_ID_MODEL(_id32) ((_id32 >> 4) & 0x3f)
63#define MDIO_ID_OUI(_id32) (_id32 >> 10)
64
65/* Bits in MMDREG_DEVS0. Someone thoughtfully layed things out
66 * so the 'bit present' bit number of an MMD is the number of
67 * that MMD */
68#define DEV_PRESENT_BIT(_b) (1 << _b)
69
70#define MDIO_MMDREG_DEVS0_PHYXS DEV_PRESENT_BIT(MDIO_MMD_PHYXS)
71#define MDIO_MMDREG_DEVS0_PCS DEV_PRESENT_BIT(MDIO_MMD_PCS)
72#define MDIO_MMDREG_DEVS0_PMAPMD DEV_PRESENT_BIT(MDIO_MMD_PMAPMD)
73
74/* Bits in MMDREG_STAT2 */
75#define MDIO_MMDREG_STAT2_PRESENT_VAL (2)
76#define MDIO_MMDREG_STAT2_PRESENT_LBN (14)
77#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2)
78
79/* PMA type (4 bits) */
80#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0)
81#define MDIO_PMAPMD_CTRL2_10G_EW (0x1)
82#define MDIO_PMAPMD_CTRL2_10G_LW (0x2)
83#define MDIO_PMAPMD_CTRL2_10G_SW (0x3)
84#define MDIO_PMAPMD_CTRL2_10G_LX4 (0x4)
85#define MDIO_PMAPMD_CTRL2_10G_ER (0x5)
86#define MDIO_PMAPMD_CTRL2_10G_LR (0x6)
87#define MDIO_PMAPMD_CTRL2_10G_SR (0x7)
88/* Reserved */
89#define MDIO_PMAPMD_CTRL2_10G_BT (0x9)
90/* Reserved */
91/* Reserved */
92#define MDIO_PMAPMD_CTRL2_1G_BT (0xc)
93/* Reserved */
94#define MDIO_PMAPMD_CTRL2_100_BT (0xe)
95#define MDIO_PMAPMD_CTRL2_10_BT (0xf)
96#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf)
97
98/* /\* PHY XGXS lane state *\/ */
99#define MDIO_PHYXS_LANE_STATE (0x18)
100#define MDIO_PHYXS_LANE_ALIGNED_LBN (12)
101
102/* AN registers */
103#define MDIO_AN_STATUS (1)
104#define MDIO_AN_STATUS_XNP_LBN (7)
105#define MDIO_AN_STATUS_PAGE_LBN (6)
106#define MDIO_AN_STATUS_AN_DONE_LBN (5)
107#define MDIO_AN_STATUS_LP_AN_CAP_LBN (0)
108
109#define MDIO_AN_10GBT_STATUS (33)
110#define MDIO_AN_10GBT_STATUS_MS_FLT_LBN (15) /* MASTER/SLAVE config fault */
111#define MDIO_AN_10GBT_STATUS_MS_LBN (14) /* MASTER/SLAVE config */
112#define MDIO_AN_10GBT_STATUS_LOC_OK_LBN (13) /* Local OK */
113#define MDIO_AN_10GBT_STATUS_REM_OK_LBN (12) /* Remote OK */
114#define MDIO_AN_10GBT_STATUS_LP_10G_LBN (11) /* Link partner is 10GBT capable */
115#define MDIO_AN_10GBT_STATUS_LP_LTA_LBN (10) /* LP loop timing ability */
116#define MDIO_AN_10GBT_STATUS_LP_TRR_LBN (9) /* LP Training Reset Request */
117
118
119/* Packing of the prt and dev arguments of clause 45 style MDIO into a
120 * single int so they can be passed into the mdio_read/write functions
121 * that currently exist. Note that as Falcon is the only current user,
122 * the packed form is chosen to match what Falcon needs to write into
123 * a register. This is checked at compile-time so do not change it. If
124 * your target chip needs things layed out differently you will need
125 * to unpack the arguments in your chip-specific mdio functions.
126 */
127 /* These are defined by the standard. */
128#define MDIO45_PRT_ID_WIDTH (5)
129#define MDIO45_DEV_ID_WIDTH (5)
130
131/* The prt ID is just packed in immediately to the left of the dev ID */
132#define MDIO45_PRT_DEV_WIDTH (MDIO45_PRT_ID_WIDTH + MDIO45_DEV_ID_WIDTH)
133
134#define MDIO45_PRT_ID_MASK ((1 << MDIO45_PRT_DEV_WIDTH) - 1)
135/* This is the prt + dev extended by 1 bit to hold the 'is clause 45' flag. */
136#define MDIO45_XPRT_ID_WIDTH (MDIO45_PRT_DEV_WIDTH + 1)
137#define MDIO45_XPRT_ID_MASK ((1 << MDIO45_XPRT_ID_WIDTH) - 1)
138#define MDIO45_XPRT_ID_IS10G (1 << (MDIO45_XPRT_ID_WIDTH - 1))
139
140
141#define MDIO45_PRT_ID_COMP_LBN MDIO45_DEV_ID_WIDTH
142#define MDIO45_PRT_ID_COMP_WIDTH MDIO45_PRT_ID_WIDTH
143#define MDIO45_DEV_ID_COMP_LBN 0
144#define MDIO45_DEV_ID_COMP_WIDTH MDIO45_DEV_ID_WIDTH
145
146/* Compose port and device into a phy_id */
147static inline int mdio_clause45_pack(u8 prt, u8 dev)
148{
149 efx_dword_t phy_id;
150 EFX_POPULATE_DWORD_2(phy_id, MDIO45_PRT_ID_COMP, prt,
151 MDIO45_DEV_ID_COMP, dev);
152 return MDIO45_XPRT_ID_IS10G | EFX_DWORD_VAL(phy_id);
153}
154
155static inline void mdio_clause45_unpack(u32 val, u8 *prt, u8 *dev)
156{
157 efx_dword_t phy_id;
158 EFX_POPULATE_DWORD_1(phy_id, EFX_DWORD_0, val);
159 *prt = EFX_DWORD_FIELD(phy_id, MDIO45_PRT_ID_COMP);
160 *dev = EFX_DWORD_FIELD(phy_id, MDIO45_DEV_ID_COMP);
161}
162
163static inline int mdio_clause45_read(struct efx_nic *efx,
164 u8 prt, u8 dev, u16 addr)
165{
166 return efx->mii.mdio_read(efx->net_dev,
167 mdio_clause45_pack(prt, dev), addr);
168}
169
170static inline void mdio_clause45_write(struct efx_nic *efx,
171 u8 prt, u8 dev, u16 addr, int value)
172{
173 efx->mii.mdio_write(efx->net_dev,
174 mdio_clause45_pack(prt, dev), addr, value);
175}
176
177
178static inline u32 mdio_clause45_read_id(struct efx_nic *efx, int mmd)
179{
180 int phy_id = efx->mii.phy_id;
181 u16 id_low = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_IDLOW);
182 u16 id_hi = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_IDHI);
183 return (id_hi << 16) | (id_low);
184}
185
186static inline int mdio_clause45_phyxgxs_lane_sync(struct efx_nic *efx)
187{
188 int i, sync, lane_status;
189
190 for (i = 0; i < 2; ++i)
191 lane_status = mdio_clause45_read(efx, efx->mii.phy_id,
192 MDIO_MMD_PHYXS,
193 MDIO_PHYXS_LANE_STATE);
194
195 sync = (lane_status & (1 << MDIO_PHYXS_LANE_ALIGNED_LBN)) != 0;
196 if (!sync)
197 EFX_INFO(efx, "XGXS lane status: %x\n", lane_status);
198 return sync;
199}
200
201extern const char *mdio_clause45_mmd_name(int mmd);
202
203/*
204 * Reset a specific MMD and wait for reset to clear.
205 * Return number of spins left (>0) on success, -%ETIMEDOUT on failure.
206 *
207 * This function will sleep
208 */
209extern int mdio_clause45_reset_mmd(struct efx_nic *efx, int mmd,
210 int spins, int spintime);
211
212/* As mdio_clause45_check_mmd but for multiple MMDs */
213int mdio_clause45_check_mmds(struct efx_nic *efx,
214 unsigned int mmd_mask, unsigned int fatal_mask);
215
216/* Check the link status of specified mmds in bit mask */
217extern int mdio_clause45_links_ok(struct efx_nic *efx,
218 unsigned int mmd_mask);
219
220/* Read (some of) the PHY settings over MDIO */
221extern void mdio_clause45_get_settings(struct efx_nic *efx,
222 struct ethtool_cmd *ecmd);
223
224/* Set (some of) the PHY settings over MDIO */
225extern int mdio_clause45_set_settings(struct efx_nic *efx,
226 struct ethtool_cmd *ecmd);
227
228/* Wait for specified MMDs to exit reset within a timeout */
229extern int mdio_clause45_wait_reset_mmds(struct efx_nic *efx,
230 unsigned int mmd_mask);
231
232#endif /* EFX_MDIO_10G_H */
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
new file mode 100644
index 000000000000..c505482c2520
--- /dev/null
+++ b/drivers/net/sfc/net_driver.h
@@ -0,0 +1,883 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2005-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11/* Common definitions for all Efx net driver code */
12
13#ifndef EFX_NET_DRIVER_H
14#define EFX_NET_DRIVER_H
15
16#include <linux/version.h>
17#include <linux/netdevice.h>
18#include <linux/etherdevice.h>
19#include <linux/ethtool.h>
20#include <linux/if_vlan.h>
21#include <linux/timer.h>
22#include <linux/mii.h>
23#include <linux/list.h>
24#include <linux/pci.h>
25#include <linux/device.h>
26#include <linux/highmem.h>
27#include <linux/workqueue.h>
28#include <linux/inet_lro.h>
29
30#include "enum.h"
31#include "bitfield.h"
32#include "i2c-direct.h"
33
34#define EFX_MAX_LRO_DESCRIPTORS 8
35#define EFX_MAX_LRO_AGGR MAX_SKB_FRAGS
36
37/**************************************************************************
38 *
39 * Build definitions
40 *
41 **************************************************************************/
42#ifndef EFX_DRIVER_NAME
43#define EFX_DRIVER_NAME "sfc"
44#endif
45#define EFX_DRIVER_VERSION "2.2.0136"
46
47#ifdef EFX_ENABLE_DEBUG
48#define EFX_BUG_ON_PARANOID(x) BUG_ON(x)
49#define EFX_WARN_ON_PARANOID(x) WARN_ON(x)
50#else
51#define EFX_BUG_ON_PARANOID(x) do {} while (0)
52#define EFX_WARN_ON_PARANOID(x) do {} while (0)
53#endif
54
55#define NET_DEV_REGISTERED(efx) \
56 ((efx)->net_dev->reg_state == NETREG_REGISTERED)
57
58/* Include net device name in log messages if it has been registered.
59 * Use efx->name not efx->net_dev->name so that races with (un)registration
60 * are harmless.
61 */
62#define NET_DEV_NAME(efx) (NET_DEV_REGISTERED(efx) ? (efx)->name : "")
63
64/* Un-rate-limited logging */
65#define EFX_ERR(efx, fmt, args...) \
66dev_err(&((efx)->pci_dev->dev), "ERR: %s " fmt, NET_DEV_NAME(efx), ##args)
67
68#define EFX_INFO(efx, fmt, args...) \
69dev_info(&((efx)->pci_dev->dev), "INFO: %s " fmt, NET_DEV_NAME(efx), ##args)
70
71#ifdef EFX_ENABLE_DEBUG
72#define EFX_LOG(efx, fmt, args...) \
73dev_info(&((efx)->pci_dev->dev), "DBG: %s " fmt, NET_DEV_NAME(efx), ##args)
74#else
75#define EFX_LOG(efx, fmt, args...) \
76dev_dbg(&((efx)->pci_dev->dev), "DBG: %s " fmt, NET_DEV_NAME(efx), ##args)
77#endif
78
79#define EFX_TRACE(efx, fmt, args...) do {} while (0)
80
81#define EFX_REGDUMP(efx, fmt, args...) do {} while (0)
82
83/* Rate-limited logging */
84#define EFX_ERR_RL(efx, fmt, args...) \
85do {if (net_ratelimit()) EFX_ERR(efx, fmt, ##args); } while (0)
86
87#define EFX_INFO_RL(efx, fmt, args...) \
88do {if (net_ratelimit()) EFX_INFO(efx, fmt, ##args); } while (0)
89
90#define EFX_LOG_RL(efx, fmt, args...) \
91do {if (net_ratelimit()) EFX_LOG(efx, fmt, ##args); } while (0)
92
93/* Kernel headers may redefine inline anyway */
94#ifndef inline
95#define inline inline __attribute__ ((always_inline))
96#endif
97
98/**************************************************************************
99 *
100 * Efx data structures
101 *
102 **************************************************************************/
103
104#define EFX_MAX_CHANNELS 32
105#define EFX_MAX_TX_QUEUES 1
106#define EFX_MAX_RX_QUEUES EFX_MAX_CHANNELS
107
108/**
109 * struct efx_special_buffer - An Efx special buffer
110 * @addr: CPU base address of the buffer
111 * @dma_addr: DMA base address of the buffer
112 * @len: Buffer length, in bytes
113 * @index: Buffer index within controller;s buffer table
114 * @entries: Number of buffer table entries
115 *
116 * Special buffers are used for the event queues and the TX and RX
117 * descriptor queues for each channel. They are *not* used for the
118 * actual transmit and receive buffers.
119 *
120 * Note that for Falcon, TX and RX descriptor queues live in host memory.
121 * Allocation and freeing procedures must take this into account.
122 */
123struct efx_special_buffer {
124 void *addr;
125 dma_addr_t dma_addr;
126 unsigned int len;
127 int index;
128 int entries;
129};
130
131/**
132 * struct efx_tx_buffer - An Efx TX buffer
133 * @skb: The associated socket buffer.
134 * Set only on the final fragment of a packet; %NULL for all other
135 * fragments. When this fragment completes, then we can free this
136 * skb.
137 * @dma_addr: DMA address of the fragment.
138 * @len: Length of this fragment.
139 * This field is zero when the queue slot is empty.
140 * @continuation: True if this fragment is not the end of a packet.
141 * @unmap_single: True if pci_unmap_single should be used.
142 * @unmap_addr: DMA address to unmap
143 * @unmap_len: Length of this fragment to unmap
144 */
145struct efx_tx_buffer {
146 const struct sk_buff *skb;
147 dma_addr_t dma_addr;
148 unsigned short len;
149 unsigned char continuation;
150 unsigned char unmap_single;
151 dma_addr_t unmap_addr;
152 unsigned short unmap_len;
153};
154
155/**
156 * struct efx_tx_queue - An Efx TX queue
157 *
158 * This is a ring buffer of TX fragments.
159 * Since the TX completion path always executes on the same
160 * CPU and the xmit path can operate on different CPUs,
161 * performance is increased by ensuring that the completion
162 * path and the xmit path operate on different cache lines.
163 * This is particularly important if the xmit path is always
164 * executing on one CPU which is different from the completion
165 * path. There is also a cache line for members which are
166 * read but not written on the fast path.
167 *
168 * @efx: The associated Efx NIC
169 * @queue: DMA queue number
170 * @used: Queue is used by net driver
171 * @channel: The associated channel
172 * @buffer: The software buffer ring
173 * @txd: The hardware descriptor ring
174 * @read_count: Current read pointer.
175 * This is the number of buffers that have been removed from both rings.
176 * @stopped: Stopped flag.
177 * Set if this TX queue is currently stopping its port.
178 * @insert_count: Current insert pointer
179 * This is the number of buffers that have been added to the
180 * software ring.
181 * @write_count: Current write pointer
182 * This is the number of buffers that have been added to the
183 * hardware ring.
184 * @old_read_count: The value of read_count when last checked.
185 * This is here for performance reasons. The xmit path will
186 * only get the up-to-date value of read_count if this
187 * variable indicates that the queue is full. This is to
188 * avoid cache-line ping-pong between the xmit path and the
189 * completion path.
190 */
191struct efx_tx_queue {
192 /* Members which don't change on the fast path */
193 struct efx_nic *efx ____cacheline_aligned_in_smp;
194 int queue;
195 int used;
196 struct efx_channel *channel;
197 struct efx_nic *nic;
198 struct efx_tx_buffer *buffer;
199 struct efx_special_buffer txd;
200
201 /* Members used mainly on the completion path */
202 unsigned int read_count ____cacheline_aligned_in_smp;
203 int stopped;
204
205 /* Members used only on the xmit path */
206 unsigned int insert_count ____cacheline_aligned_in_smp;
207 unsigned int write_count;
208 unsigned int old_read_count;
209};
210
211/**
212 * struct efx_rx_buffer - An Efx RX data buffer
213 * @dma_addr: DMA base address of the buffer
214 * @skb: The associated socket buffer, if any.
215 * If both this and page are %NULL, the buffer slot is currently free.
216 * @page: The associated page buffer, if any.
217 * If both this and skb are %NULL, the buffer slot is currently free.
218 * @data: Pointer to ethernet header
219 * @len: Buffer length, in bytes.
220 * @unmap_addr: DMA address to unmap
221 */
222struct efx_rx_buffer {
223 dma_addr_t dma_addr;
224 struct sk_buff *skb;
225 struct page *page;
226 char *data;
227 unsigned int len;
228 dma_addr_t unmap_addr;
229};
230
231/**
232 * struct efx_rx_queue - An Efx RX queue
233 * @efx: The associated Efx NIC
234 * @queue: DMA queue number
235 * @used: Queue is used by net driver
236 * @channel: The associated channel
237 * @buffer: The software buffer ring
238 * @rxd: The hardware descriptor ring
239 * @added_count: Number of buffers added to the receive queue.
240 * @notified_count: Number of buffers given to NIC (<= @added_count).
241 * @removed_count: Number of buffers removed from the receive queue.
242 * @add_lock: Receive queue descriptor add spin lock.
243 * This lock must be held in order to add buffers to the RX
244 * descriptor ring (rxd and buffer) and to update added_count (but
245 * not removed_count).
246 * @max_fill: RX descriptor maximum fill level (<= ring size)
247 * @fast_fill_trigger: RX descriptor fill level that will trigger a fast fill
248 * (<= @max_fill)
249 * @fast_fill_limit: The level to which a fast fill will fill
250 * (@fast_fill_trigger <= @fast_fill_limit <= @max_fill)
251 * @min_fill: RX descriptor minimum non-zero fill level.
252 * This records the minimum fill level observed when a ring
253 * refill was triggered.
254 * @min_overfill: RX descriptor minimum overflow fill level.
255 * This records the minimum fill level at which RX queue
256 * overflow was observed. It should never be set.
257 * @alloc_page_count: RX allocation strategy counter.
258 * @alloc_skb_count: RX allocation strategy counter.
259 * @work: Descriptor push work thread
260 * @buf_page: Page for next RX buffer.
261 * We can use a single page for multiple RX buffers. This tracks
262 * the remaining space in the allocation.
263 * @buf_dma_addr: Page's DMA address.
264 * @buf_data: Page's host address.
265 */
266struct efx_rx_queue {
267 struct efx_nic *efx;
268 int queue;
269 int used;
270 struct efx_channel *channel;
271 struct efx_rx_buffer *buffer;
272 struct efx_special_buffer rxd;
273
274 int added_count;
275 int notified_count;
276 int removed_count;
277 spinlock_t add_lock;
278 unsigned int max_fill;
279 unsigned int fast_fill_trigger;
280 unsigned int fast_fill_limit;
281 unsigned int min_fill;
282 unsigned int min_overfill;
283 unsigned int alloc_page_count;
284 unsigned int alloc_skb_count;
285 struct delayed_work work;
286 unsigned int slow_fill_count;
287
288 struct page *buf_page;
289 dma_addr_t buf_dma_addr;
290 char *buf_data;
291};
292
293/**
294 * struct efx_buffer - An Efx general-purpose buffer
295 * @addr: host base address of the buffer
296 * @dma_addr: DMA base address of the buffer
297 * @len: Buffer length, in bytes
298 *
299 * Falcon uses these buffers for its interrupt status registers and
300 * MAC stats dumps.
301 */
302struct efx_buffer {
303 void *addr;
304 dma_addr_t dma_addr;
305 unsigned int len;
306};
307
308
309/* Flags for channel->used_flags */
310#define EFX_USED_BY_RX 1
311#define EFX_USED_BY_TX 2
312#define EFX_USED_BY_RX_TX (EFX_USED_BY_RX | EFX_USED_BY_TX)
313
314enum efx_rx_alloc_method {
315 RX_ALLOC_METHOD_AUTO = 0,
316 RX_ALLOC_METHOD_SKB = 1,
317 RX_ALLOC_METHOD_PAGE = 2,
318};
319
320/**
321 * struct efx_channel - An Efx channel
322 *
323 * A channel comprises an event queue, at least one TX queue, at least
324 * one RX queue, and an associated tasklet for processing the event
325 * queue.
326 *
327 * @efx: Associated Efx NIC
328 * @evqnum: Event queue number
329 * @channel: Channel instance number
330 * @used_flags: Channel is used by net driver
331 * @enabled: Channel enabled indicator
332 * @irq: IRQ number (MSI and MSI-X only)
333 * @has_interrupt: Channel has an interrupt
334 * @irq_moderation: IRQ moderation value (in us)
335 * @napi_dev: Net device used with NAPI
336 * @napi_str: NAPI control structure
337 * @reset_work: Scheduled reset work thread
338 * @work_pending: Is work pending via NAPI?
339 * @eventq: Event queue buffer
340 * @eventq_read_ptr: Event queue read pointer
341 * @last_eventq_read_ptr: Last event queue read pointer value.
342 * @eventq_magic: Event queue magic value for driver-generated test events
343 * @lro_mgr: LRO state
344 * @rx_alloc_level: Watermark based heuristic counter for pushing descriptors
345 * and diagnostic counters
346 * @rx_alloc_push_pages: RX allocation method currently in use for pushing
347 * descriptors
348 * @rx_alloc_pop_pages: RX allocation method currently in use for popping
349 * descriptors
350 * @n_rx_tobe_disc: Count of RX_TOBE_DISC errors
351 * @n_rx_ip_frag_err: Count of RX IP fragment errors
352 * @n_rx_ip_hdr_chksum_err: Count of RX IP header checksum errors
353 * @n_rx_tcp_udp_chksum_err: Count of RX TCP and UDP checksum errors
354 * @n_rx_frm_trunc: Count of RX_FRM_TRUNC errors
355 * @n_rx_overlength: Count of RX_OVERLENGTH errors
356 * @n_skbuff_leaks: Count of skbuffs leaked due to RX overrun
357 */
358struct efx_channel {
359 struct efx_nic *efx;
360 int evqnum;
361 int channel;
362 int used_flags;
363 int enabled;
364 int irq;
365 unsigned int has_interrupt;
366 unsigned int irq_moderation;
367 struct net_device *napi_dev;
368 struct napi_struct napi_str;
369 struct work_struct reset_work;
370 int work_pending;
371 struct efx_special_buffer eventq;
372 unsigned int eventq_read_ptr;
373 unsigned int last_eventq_read_ptr;
374 unsigned int eventq_magic;
375
376 struct net_lro_mgr lro_mgr;
377 int rx_alloc_level;
378 int rx_alloc_push_pages;
379 int rx_alloc_pop_pages;
380
381 unsigned n_rx_tobe_disc;
382 unsigned n_rx_ip_frag_err;
383 unsigned n_rx_ip_hdr_chksum_err;
384 unsigned n_rx_tcp_udp_chksum_err;
385 unsigned n_rx_frm_trunc;
386 unsigned n_rx_overlength;
387 unsigned n_skbuff_leaks;
388
389 /* Used to pipeline received packets in order to optimise memory
390 * access with prefetches.
391 */
392 struct efx_rx_buffer *rx_pkt;
393 int rx_pkt_csummed;
394
395};
396
397/**
398 * struct efx_blinker - S/W LED blinking context
399 * @led_num: LED ID (board-specific meaning)
400 * @state: Current state - on or off
401 * @resubmit: Timer resubmission flag
402 * @timer: Control timer for blinking
403 */
404struct efx_blinker {
405 int led_num;
406 int state;
407 int resubmit;
408 struct timer_list timer;
409};
410
411
412/**
413 * struct efx_board - board information
414 * @type: Board model type
415 * @major: Major rev. ('A', 'B' ...)
416 * @minor: Minor rev. (0, 1, ...)
417 * @init: Initialisation function
418 * @init_leds: Sets up board LEDs
419 * @set_fault_led: Turns the fault LED on or off
420 * @blink: Starts/stops blinking
421 * @blinker: used to blink LEDs in software
422 */
423struct efx_board {
424 int type;
425 int major;
426 int minor;
427 int (*init) (struct efx_nic *nic);
428 /* As the LEDs are typically attached to the PHY, LEDs
429 * have a separate init callback that happens later than
430 * board init. */
431 int (*init_leds)(struct efx_nic *efx);
432 void (*set_fault_led) (struct efx_nic *efx, int state);
433 void (*blink) (struct efx_nic *efx, int start);
434 struct efx_blinker blinker;
435};
436
437enum efx_int_mode {
438 /* Be careful if altering to correct macro below */
439 EFX_INT_MODE_MSIX = 0,
440 EFX_INT_MODE_MSI = 1,
441 EFX_INT_MODE_LEGACY = 2,
442 EFX_INT_MODE_MAX /* Insert any new items before this */
443};
444#define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI)
445
446enum phy_type {
447 PHY_TYPE_NONE = 0,
448 PHY_TYPE_CX4_RTMR = 1,
449 PHY_TYPE_1G_ALASKA = 2,
450 PHY_TYPE_10XPRESS = 3,
451 PHY_TYPE_XFP = 4,
452 PHY_TYPE_PM8358 = 6,
453 PHY_TYPE_MAX /* Insert any new items before this */
454};
455
456#define PHY_ADDR_INVALID 0xff
457
458enum nic_state {
459 STATE_INIT = 0,
460 STATE_RUNNING = 1,
461 STATE_FINI = 2,
462 STATE_RESETTING = 3, /* rtnl_lock always held */
463 STATE_DISABLED = 4,
464 STATE_MAX,
465};
466
467/*
468 * Alignment of page-allocated RX buffers
469 *
470 * Controls the number of bytes inserted at the start of an RX buffer.
471 * This is the equivalent of NET_IP_ALIGN [which controls the alignment
472 * of the skb->head for hardware DMA].
473 */
474#if defined(__i386__) || defined(__x86_64__)
475#define EFX_PAGE_IP_ALIGN 0
476#else
477#define EFX_PAGE_IP_ALIGN NET_IP_ALIGN
478#endif
479
480/*
481 * Alignment of the skb->head which wraps a page-allocated RX buffer
482 *
483 * The skb allocated to wrap an rx_buffer can have this alignment. Since
484 * the data is memcpy'd from the rx_buf, it does not need to be equal to
485 * EFX_PAGE_IP_ALIGN.
486 */
487#define EFX_PAGE_SKB_ALIGN 2
488
489/* Forward declaration */
490struct efx_nic;
491
492/* Pseudo bit-mask flow control field */
493enum efx_fc_type {
494 EFX_FC_RX = 1,
495 EFX_FC_TX = 2,
496 EFX_FC_AUTO = 4,
497};
498
499/**
500 * struct efx_phy_operations - Efx PHY operations table
501 * @init: Initialise PHY
502 * @fini: Shut down PHY
503 * @reconfigure: Reconfigure PHY (e.g. for new link parameters)
504 * @clear_interrupt: Clear down interrupt
505 * @blink: Blink LEDs
506 * @check_hw: Check hardware
507 * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset)
508 * @mmds: MMD presence mask
509 */
510struct efx_phy_operations {
511 int (*init) (struct efx_nic *efx);
512 void (*fini) (struct efx_nic *efx);
513 void (*reconfigure) (struct efx_nic *efx);
514 void (*clear_interrupt) (struct efx_nic *efx);
515 int (*check_hw) (struct efx_nic *efx);
516 void (*reset_xaui) (struct efx_nic *efx);
517 int mmds;
518};
519
520/*
521 * Efx extended statistics
522 *
523 * Not all statistics are provided by all supported MACs. The purpose
524 * is this structure is to contain the raw statistics provided by each
525 * MAC.
526 */
527struct efx_mac_stats {
528 u64 tx_bytes;
529 u64 tx_good_bytes;
530 u64 tx_bad_bytes;
531 unsigned long tx_packets;
532 unsigned long tx_bad;
533 unsigned long tx_pause;
534 unsigned long tx_control;
535 unsigned long tx_unicast;
536 unsigned long tx_multicast;
537 unsigned long tx_broadcast;
538 unsigned long tx_lt64;
539 unsigned long tx_64;
540 unsigned long tx_65_to_127;
541 unsigned long tx_128_to_255;
542 unsigned long tx_256_to_511;
543 unsigned long tx_512_to_1023;
544 unsigned long tx_1024_to_15xx;
545 unsigned long tx_15xx_to_jumbo;
546 unsigned long tx_gtjumbo;
547 unsigned long tx_collision;
548 unsigned long tx_single_collision;
549 unsigned long tx_multiple_collision;
550 unsigned long tx_excessive_collision;
551 unsigned long tx_deferred;
552 unsigned long tx_late_collision;
553 unsigned long tx_excessive_deferred;
554 unsigned long tx_non_tcpudp;
555 unsigned long tx_mac_src_error;
556 unsigned long tx_ip_src_error;
557 u64 rx_bytes;
558 u64 rx_good_bytes;
559 u64 rx_bad_bytes;
560 unsigned long rx_packets;
561 unsigned long rx_good;
562 unsigned long rx_bad;
563 unsigned long rx_pause;
564 unsigned long rx_control;
565 unsigned long rx_unicast;
566 unsigned long rx_multicast;
567 unsigned long rx_broadcast;
568 unsigned long rx_lt64;
569 unsigned long rx_64;
570 unsigned long rx_65_to_127;
571 unsigned long rx_128_to_255;
572 unsigned long rx_256_to_511;
573 unsigned long rx_512_to_1023;
574 unsigned long rx_1024_to_15xx;
575 unsigned long rx_15xx_to_jumbo;
576 unsigned long rx_gtjumbo;
577 unsigned long rx_bad_lt64;
578 unsigned long rx_bad_64_to_15xx;
579 unsigned long rx_bad_15xx_to_jumbo;
580 unsigned long rx_bad_gtjumbo;
581 unsigned long rx_overflow;
582 unsigned long rx_missed;
583 unsigned long rx_false_carrier;
584 unsigned long rx_symbol_error;
585 unsigned long rx_align_error;
586 unsigned long rx_length_error;
587 unsigned long rx_internal_error;
588 unsigned long rx_good_lt64;
589};
590
591/* Number of bits used in a multicast filter hash address */
592#define EFX_MCAST_HASH_BITS 8
593
594/* Number of (single-bit) entries in a multicast filter hash */
595#define EFX_MCAST_HASH_ENTRIES (1 << EFX_MCAST_HASH_BITS)
596
597/* An Efx multicast filter hash */
598union efx_multicast_hash {
599 u8 byte[EFX_MCAST_HASH_ENTRIES / 8];
600 efx_oword_t oword[EFX_MCAST_HASH_ENTRIES / sizeof(efx_oword_t) / 8];
601};
602
603/**
604 * struct efx_nic - an Efx NIC
605 * @name: Device name (net device name or bus id before net device registered)
606 * @pci_dev: The PCI device
607 * @type: Controller type attributes
608 * @legacy_irq: IRQ number
609 * @workqueue: Workqueue for resets, port reconfigures and the HW monitor
610 * @reset_work: Scheduled reset workitem
611 * @monitor_work: Hardware monitor workitem
612 * @membase_phys: Memory BAR value as physical address
613 * @membase: Memory BAR value
614 * @biu_lock: BIU (bus interface unit) lock
615 * @interrupt_mode: Interrupt mode
616 * @i2c: I2C interface
617 * @board_info: Board-level information
618 * @state: Device state flag. Serialised by the rtnl_lock.
619 * @reset_pending: Pending reset method (normally RESET_TYPE_NONE)
620 * @tx_queue: TX DMA queues
621 * @rx_queue: RX DMA queues
622 * @channel: Channels
623 * @rss_queues: Number of RSS queues
624 * @rx_buffer_len: RX buffer length
625 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
626 * @irq_status: Interrupt status buffer
627 * @last_irq_cpu: Last CPU to handle interrupt.
628 * This register is written with the SMP processor ID whenever an
629 * interrupt is handled. It is used by falcon_test_interrupt()
630 * to verify that an interrupt has occurred.
631 * @n_rx_nodesc_drop_cnt: RX no descriptor drop count
632 * @nic_data: Hardware dependant state
633 * @mac_lock: MAC access lock. Protects @port_enabled, efx_monitor() and
634 * efx_reconfigure_port()
635 * @port_enabled: Port enabled indicator.
636 * Serialises efx_stop_all(), efx_start_all() and efx_monitor() and
637 * efx_reconfigure_work with kernel interfaces. Safe to read under any
638 * one of the rtnl_lock, mac_lock, or netif_tx_lock, but all three must
639 * be held to modify it.
640 * @port_initialized: Port initialized?
641 * @net_dev: Operating system network device. Consider holding the rtnl lock
642 * @rx_checksum_enabled: RX checksumming enabled
643 * @netif_stop_count: Port stop count
644 * @netif_stop_lock: Port stop lock
645 * @mac_stats: MAC statistics. These include all statistics the MACs
646 * can provide. Generic code converts these into a standard
647 * &struct net_device_stats.
648 * @stats_buffer: DMA buffer for statistics
649 * @stats_lock: Statistics update lock
650 * @mac_address: Permanent MAC address
651 * @phy_type: PHY type
652 * @phy_lock: PHY access lock
653 * @phy_op: PHY interface
654 * @phy_data: PHY private data (including PHY-specific stats)
655 * @mii: PHY interface
656 * @phy_powered: PHY power state
657 * @tx_disabled: PHY transmitter turned off
658 * @link_up: Link status
659 * @link_options: Link options (MII/GMII format)
660 * @n_link_state_changes: Number of times the link has changed state
661 * @promiscuous: Promiscuous flag. Protected by netif_tx_lock.
662 * @multicast_hash: Multicast hash table
663 * @flow_control: Flow control flags - separate RX/TX so can't use link_options
664 * @reconfigure_work: work item for dealing with PHY events
665 *
666 * The @priv field of the corresponding &struct net_device points to
667 * this.
668 */
669struct efx_nic {
670 char name[IFNAMSIZ];
671 struct pci_dev *pci_dev;
672 const struct efx_nic_type *type;
673 int legacy_irq;
674 struct workqueue_struct *workqueue;
675 struct work_struct reset_work;
676 struct delayed_work monitor_work;
677 unsigned long membase_phys;
678 void __iomem *membase;
679 spinlock_t biu_lock;
680 enum efx_int_mode interrupt_mode;
681
682 struct efx_i2c_interface i2c;
683 struct efx_board board_info;
684
685 enum nic_state state;
686 enum reset_type reset_pending;
687
688 struct efx_tx_queue tx_queue[EFX_MAX_TX_QUEUES];
689 struct efx_rx_queue rx_queue[EFX_MAX_RX_QUEUES];
690 struct efx_channel channel[EFX_MAX_CHANNELS];
691
692 int rss_queues;
693 unsigned int rx_buffer_len;
694 unsigned int rx_buffer_order;
695
696 struct efx_buffer irq_status;
697 volatile signed int last_irq_cpu;
698
699 unsigned n_rx_nodesc_drop_cnt;
700
701 void *nic_data;
702
703 struct mutex mac_lock;
704 int port_enabled;
705
706 int port_initialized;
707 struct net_device *net_dev;
708 int rx_checksum_enabled;
709
710 atomic_t netif_stop_count;
711 spinlock_t netif_stop_lock;
712
713 struct efx_mac_stats mac_stats;
714 struct efx_buffer stats_buffer;
715 spinlock_t stats_lock;
716
717 unsigned char mac_address[ETH_ALEN];
718
719 enum phy_type phy_type;
720 spinlock_t phy_lock;
721 struct efx_phy_operations *phy_op;
722 void *phy_data;
723 struct mii_if_info mii;
724
725 int link_up;
726 unsigned int link_options;
727 unsigned int n_link_state_changes;
728
729 int promiscuous;
730 union efx_multicast_hash multicast_hash;
731 enum efx_fc_type flow_control;
732 struct work_struct reconfigure_work;
733
734 atomic_t rx_reset;
735};
736
737/**
738 * struct efx_nic_type - Efx device type definition
739 * @mem_bar: Memory BAR number
740 * @mem_map_size: Memory BAR mapped size
741 * @txd_ptr_tbl_base: TX descriptor ring base address
742 * @rxd_ptr_tbl_base: RX descriptor ring base address
743 * @buf_tbl_base: Buffer table base address
744 * @evq_ptr_tbl_base: Event queue pointer table base address
745 * @evq_rptr_tbl_base: Event queue read-pointer table base address
746 * @txd_ring_mask: TX descriptor ring size - 1 (must be a power of two - 1)
747 * @rxd_ring_mask: RX descriptor ring size - 1 (must be a power of two - 1)
748 * @evq_size: Event queue size (must be a power of two)
749 * @max_dma_mask: Maximum possible DMA mask
750 * @tx_dma_mask: TX DMA mask
751 * @bug5391_mask: Address mask for bug 5391 workaround
752 * @rx_xoff_thresh: RX FIFO XOFF watermark (bytes)
753 * @rx_xon_thresh: RX FIFO XON watermark (bytes)
754 * @rx_buffer_padding: Padding added to each RX buffer
755 * @max_interrupt_mode: Highest capability interrupt mode supported
756 * from &enum efx_init_mode.
757 * @phys_addr_channels: Number of channels with physically addressed
758 * descriptors
759 */
760struct efx_nic_type {
761 unsigned int mem_bar;
762 unsigned int mem_map_size;
763 unsigned int txd_ptr_tbl_base;
764 unsigned int rxd_ptr_tbl_base;
765 unsigned int buf_tbl_base;
766 unsigned int evq_ptr_tbl_base;
767 unsigned int evq_rptr_tbl_base;
768
769 unsigned int txd_ring_mask;
770 unsigned int rxd_ring_mask;
771 unsigned int evq_size;
772 dma_addr_t max_dma_mask;
773 unsigned int tx_dma_mask;
774 unsigned bug5391_mask;
775
776 int rx_xoff_thresh;
777 int rx_xon_thresh;
778 unsigned int rx_buffer_padding;
779 unsigned int max_interrupt_mode;
780 unsigned int phys_addr_channels;
781};
782
783/**************************************************************************
784 *
785 * Prototypes and inline functions
786 *
787 *************************************************************************/
788
789/* Iterate over all used channels */
790#define efx_for_each_channel(_channel, _efx) \
791 for (_channel = &_efx->channel[0]; \
792 _channel < &_efx->channel[EFX_MAX_CHANNELS]; \
793 _channel++) \
794 if (!_channel->used_flags) \
795 continue; \
796 else
797
798/* Iterate over all used channels with interrupts */
799#define efx_for_each_channel_with_interrupt(_channel, _efx) \
800 for (_channel = &_efx->channel[0]; \
801 _channel < &_efx->channel[EFX_MAX_CHANNELS]; \
802 _channel++) \
803 if (!(_channel->used_flags && _channel->has_interrupt)) \
804 continue; \
805 else
806
807/* Iterate over all used TX queues */
808#define efx_for_each_tx_queue(_tx_queue, _efx) \
809 for (_tx_queue = &_efx->tx_queue[0]; \
810 _tx_queue < &_efx->tx_queue[EFX_MAX_TX_QUEUES]; \
811 _tx_queue++) \
812 if (!_tx_queue->used) \
813 continue; \
814 else
815
816/* Iterate over all TX queues belonging to a channel */
817#define efx_for_each_channel_tx_queue(_tx_queue, _channel) \
818 for (_tx_queue = &_channel->efx->tx_queue[0]; \
819 _tx_queue < &_channel->efx->tx_queue[EFX_MAX_TX_QUEUES]; \
820 _tx_queue++) \
821 if ((!_tx_queue->used) || \
822 (_tx_queue->channel != _channel)) \
823 continue; \
824 else
825
826/* Iterate over all used RX queues */
827#define efx_for_each_rx_queue(_rx_queue, _efx) \
828 for (_rx_queue = &_efx->rx_queue[0]; \
829 _rx_queue < &_efx->rx_queue[EFX_MAX_RX_QUEUES]; \
830 _rx_queue++) \
831 if (!_rx_queue->used) \
832 continue; \
833 else
834
835/* Iterate over all RX queues belonging to a channel */
836#define efx_for_each_channel_rx_queue(_rx_queue, _channel) \
837 for (_rx_queue = &_channel->efx->rx_queue[0]; \
838 _rx_queue < &_channel->efx->rx_queue[EFX_MAX_RX_QUEUES]; \
839 _rx_queue++) \
840 if ((!_rx_queue->used) || \
841 (_rx_queue->channel != _channel)) \
842 continue; \
843 else
844
845/* Returns a pointer to the specified receive buffer in the RX
846 * descriptor queue.
847 */
848static inline struct efx_rx_buffer *efx_rx_buffer(struct efx_rx_queue *rx_queue,
849 unsigned int index)
850{
851 return (&rx_queue->buffer[index]);
852}
853
854/* Set bit in a little-endian bitfield */
855static inline void set_bit_le(int nr, unsigned char *addr)
856{
857 addr[nr / 8] |= (1 << (nr % 8));
858}
859
860/* Clear bit in a little-endian bitfield */
861static inline void clear_bit_le(int nr, unsigned char *addr)
862{
863 addr[nr / 8] &= ~(1 << (nr % 8));
864}
865
866
867/**
868 * EFX_MAX_FRAME_LEN - calculate maximum frame length
869 *
870 * This calculates the maximum frame length that will be used for a
871 * given MTU. The frame length will be equal to the MTU plus a
872 * constant amount of header space and padding. This is the quantity
873 * that the net driver will program into the MAC as the maximum frame
874 * length.
875 *
876 * The 10G MAC used in Falcon requires 8-byte alignment on the frame
877 * length, so we round up to the nearest 8.
878 */
879#define EFX_MAX_FRAME_LEN(mtu) \
880 ((((mtu) + ETH_HLEN + VLAN_HLEN + 4/* FCS */) + 7) & ~7)
881
882
883#endif /* EFX_NET_DRIVER_H */
diff --git a/drivers/net/sfc/phy.h b/drivers/net/sfc/phy.h
new file mode 100644
index 000000000000..9d02c84e6b2d
--- /dev/null
+++ b/drivers/net/sfc/phy.h
@@ -0,0 +1,48 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_PHY_H
11#define EFX_PHY_H
12
13/****************************************************************************
14 * 10Xpress (SFX7101) PHY
15 */
16extern struct efx_phy_operations falcon_tenxpress_phy_ops;
17
18enum tenxpress_state {
19 TENXPRESS_STATUS_OFF = 0,
20 TENXPRESS_STATUS_OTEMP = 1,
21 TENXPRESS_STATUS_NORMAL = 2,
22};
23
24extern void tenxpress_set_state(struct efx_nic *efx,
25 enum tenxpress_state state);
26extern void tenxpress_phy_blink(struct efx_nic *efx, int blink);
27extern void tenxpress_crc_err(struct efx_nic *efx);
28
29/****************************************************************************
30 * Exported functions from the driver for XFP optical PHYs
31 */
32extern struct efx_phy_operations falcon_xfp_phy_ops;
33
34/* The QUAKE XFP PHY provides various H/W control states for LEDs */
35#define QUAKE_LED_LINK_INVAL (0)
36#define QUAKE_LED_LINK_STAT (1)
37#define QUAKE_LED_LINK_ACT (2)
38#define QUAKE_LED_LINK_ACTSTAT (3)
39#define QUAKE_LED_OFF (4)
40#define QUAKE_LED_ON (5)
41#define QUAKE_LED_LINK_INPUT (6) /* Pin is an input. */
42/* What link the LED tracks */
43#define QUAKE_LED_TXLINK (0)
44#define QUAKE_LED_RXLINK (8)
45
46extern void xfp_set_led(struct efx_nic *p, int led, int state);
47
48#endif
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
new file mode 100644
index 000000000000..551299b462ae
--- /dev/null
+++ b/drivers/net/sfc/rx.c
@@ -0,0 +1,875 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2005-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/socket.h>
12#include <linux/in.h>
13#include <linux/ip.h>
14#include <linux/tcp.h>
15#include <linux/udp.h>
16#include <net/ip.h>
17#include <net/checksum.h>
18#include "net_driver.h"
19#include "rx.h"
20#include "efx.h"
21#include "falcon.h"
22#include "workarounds.h"
23
24/* Number of RX descriptors pushed at once. */
25#define EFX_RX_BATCH 8
26
27/* Size of buffer allocated for skb header area. */
28#define EFX_SKB_HEADERS 64u
29
30/*
31 * rx_alloc_method - RX buffer allocation method
32 *
33 * This driver supports two methods for allocating and using RX buffers:
34 * each RX buffer may be backed by an skb or by an order-n page.
35 *
36 * When LRO is in use then the second method has a lower overhead,
37 * since we don't have to allocate then free skbs on reassembled frames.
38 *
39 * Values:
40 * - RX_ALLOC_METHOD_AUTO = 0
41 * - RX_ALLOC_METHOD_SKB = 1
42 * - RX_ALLOC_METHOD_PAGE = 2
43 *
44 * The heuristic for %RX_ALLOC_METHOD_AUTO is a simple hysteresis count
45 * controlled by the parameters below.
46 *
47 * - Since pushing and popping descriptors are separated by the rx_queue
48 * size, so the watermarks should be ~rxd_size.
49 * - The performance win by using page-based allocation for LRO is less
50 * than the performance hit of using page-based allocation of non-LRO,
51 * so the watermarks should reflect this.
52 *
53 * Per channel we maintain a single variable, updated by each channel:
54 *
55 * rx_alloc_level += (lro_performed ? RX_ALLOC_FACTOR_LRO :
56 * RX_ALLOC_FACTOR_SKB)
57 * Per NAPI poll interval, we constrain rx_alloc_level to 0..MAX (which
58 * limits the hysteresis), and update the allocation strategy:
59 *
60 * rx_alloc_method = (rx_alloc_level > RX_ALLOC_LEVEL_LRO ?
61 * RX_ALLOC_METHOD_PAGE : RX_ALLOC_METHOD_SKB)
62 */
63static int rx_alloc_method = RX_ALLOC_METHOD_PAGE;
64
65#define RX_ALLOC_LEVEL_LRO 0x2000
66#define RX_ALLOC_LEVEL_MAX 0x3000
67#define RX_ALLOC_FACTOR_LRO 1
68#define RX_ALLOC_FACTOR_SKB (-2)
69
70/* This is the percentage fill level below which new RX descriptors
71 * will be added to the RX descriptor ring.
72 */
73static unsigned int rx_refill_threshold = 90;
74
75/* This is the percentage fill level to which an RX queue will be refilled
76 * when the "RX refill threshold" is reached.
77 */
78static unsigned int rx_refill_limit = 95;
79
80/*
81 * RX maximum head room required.
82 *
83 * This must be at least 1 to prevent overflow and at least 2 to allow
84 * pipelined receives.
85 */
86#define EFX_RXD_HEAD_ROOM 2
87
88/* Macros for zero-order pages (potentially) containing multiple RX buffers */
89#define RX_DATA_OFFSET(_data) \
90 (((unsigned long) (_data)) & (PAGE_SIZE-1))
91#define RX_BUF_OFFSET(_rx_buf) \
92 RX_DATA_OFFSET((_rx_buf)->data)
93
94#define RX_PAGE_SIZE(_efx) \
95 (PAGE_SIZE * (1u << (_efx)->rx_buffer_order))
96
97
98/**************************************************************************
99 *
100 * Linux generic LRO handling
101 *
102 **************************************************************************
103 */
104
105static int efx_lro_get_skb_hdr(struct sk_buff *skb, void **ip_hdr,
106 void **tcpudp_hdr, u64 *hdr_flags, void *priv)
107{
108 struct efx_channel *channel = (struct efx_channel *)priv;
109 struct iphdr *iph;
110 struct tcphdr *th;
111
112 iph = (struct iphdr *)skb->data;
113 if (skb->protocol != htons(ETH_P_IP) || iph->protocol != IPPROTO_TCP)
114 goto fail;
115
116 th = (struct tcphdr *)(skb->data + iph->ihl * 4);
117
118 *tcpudp_hdr = th;
119 *ip_hdr = iph;
120 *hdr_flags = LRO_IPV4 | LRO_TCP;
121
122 channel->rx_alloc_level += RX_ALLOC_FACTOR_LRO;
123 return 0;
124fail:
125 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
126 return -1;
127}
128
129static int efx_get_frag_hdr(struct skb_frag_struct *frag, void **mac_hdr,
130 void **ip_hdr, void **tcpudp_hdr, u64 *hdr_flags,
131 void *priv)
132{
133 struct efx_channel *channel = (struct efx_channel *)priv;
134 struct ethhdr *eh;
135 struct iphdr *iph;
136
137 /* We support EtherII and VLAN encapsulated IPv4 */
138 eh = (struct ethhdr *)(page_address(frag->page) + frag->page_offset);
139 *mac_hdr = eh;
140
141 if (eh->h_proto == htons(ETH_P_IP)) {
142 iph = (struct iphdr *)(eh + 1);
143 } else {
144 struct vlan_ethhdr *veh = (struct vlan_ethhdr *)eh;
145 if (veh->h_vlan_encapsulated_proto != htons(ETH_P_IP))
146 goto fail;
147
148 iph = (struct iphdr *)(veh + 1);
149 }
150 *ip_hdr = iph;
151
152 /* We can only do LRO over TCP */
153 if (iph->protocol != IPPROTO_TCP)
154 goto fail;
155
156 *hdr_flags = LRO_IPV4 | LRO_TCP;
157 *tcpudp_hdr = (struct tcphdr *)((u8 *) iph + iph->ihl * 4);
158
159 channel->rx_alloc_level += RX_ALLOC_FACTOR_LRO;
160 return 0;
161 fail:
162 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
163 return -1;
164}
165
166int efx_lro_init(struct net_lro_mgr *lro_mgr, struct efx_nic *efx)
167{
168 size_t s = sizeof(struct net_lro_desc) * EFX_MAX_LRO_DESCRIPTORS;
169 struct net_lro_desc *lro_arr;
170
171 /* Allocate the LRO descriptors structure */
172 lro_arr = kzalloc(s, GFP_KERNEL);
173 if (lro_arr == NULL)
174 return -ENOMEM;
175
176 lro_mgr->lro_arr = lro_arr;
177 lro_mgr->max_desc = EFX_MAX_LRO_DESCRIPTORS;
178 lro_mgr->max_aggr = EFX_MAX_LRO_AGGR;
179 lro_mgr->frag_align_pad = EFX_PAGE_SKB_ALIGN;
180
181 lro_mgr->get_skb_header = efx_lro_get_skb_hdr;
182 lro_mgr->get_frag_header = efx_get_frag_hdr;
183 lro_mgr->dev = efx->net_dev;
184
185 lro_mgr->features = LRO_F_NAPI;
186
187 /* We can pass packets up with the checksum intact */
188 lro_mgr->ip_summed = CHECKSUM_UNNECESSARY;
189
190 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
191
192 return 0;
193}
194
195void efx_lro_fini(struct net_lro_mgr *lro_mgr)
196{
197 kfree(lro_mgr->lro_arr);
198 lro_mgr->lro_arr = NULL;
199}
200
201/**
202 * efx_init_rx_buffer_skb - create new RX buffer using skb-based allocation
203 *
204 * @rx_queue: Efx RX queue
205 * @rx_buf: RX buffer structure to populate
206 *
207 * This allocates memory for a new receive buffer, maps it for DMA,
208 * and populates a struct efx_rx_buffer with the relevant
209 * information. Return a negative error code or 0 on success.
210 */
211static inline int efx_init_rx_buffer_skb(struct efx_rx_queue *rx_queue,
212 struct efx_rx_buffer *rx_buf)
213{
214 struct efx_nic *efx = rx_queue->efx;
215 struct net_device *net_dev = efx->net_dev;
216 int skb_len = efx->rx_buffer_len;
217
218 rx_buf->skb = netdev_alloc_skb(net_dev, skb_len);
219 if (unlikely(!rx_buf->skb))
220 return -ENOMEM;
221
222 /* Adjust the SKB for padding and checksum */
223 skb_reserve(rx_buf->skb, NET_IP_ALIGN);
224 rx_buf->len = skb_len - NET_IP_ALIGN;
225 rx_buf->data = (char *)rx_buf->skb->data;
226 rx_buf->skb->ip_summed = CHECKSUM_UNNECESSARY;
227
228 rx_buf->dma_addr = pci_map_single(efx->pci_dev,
229 rx_buf->data, rx_buf->len,
230 PCI_DMA_FROMDEVICE);
231
232 if (unlikely(pci_dma_mapping_error(rx_buf->dma_addr))) {
233 dev_kfree_skb_any(rx_buf->skb);
234 rx_buf->skb = NULL;
235 return -EIO;
236 }
237
238 return 0;
239}
240
241/**
242 * efx_init_rx_buffer_page - create new RX buffer using page-based allocation
243 *
244 * @rx_queue: Efx RX queue
245 * @rx_buf: RX buffer structure to populate
246 *
247 * This allocates memory for a new receive buffer, maps it for DMA,
248 * and populates a struct efx_rx_buffer with the relevant
249 * information. Return a negative error code or 0 on success.
250 */
251static inline int efx_init_rx_buffer_page(struct efx_rx_queue *rx_queue,
252 struct efx_rx_buffer *rx_buf)
253{
254 struct efx_nic *efx = rx_queue->efx;
255 int bytes, space, offset;
256
257 bytes = efx->rx_buffer_len - EFX_PAGE_IP_ALIGN;
258
259 /* If there is space left in the previously allocated page,
260 * then use it. Otherwise allocate a new one */
261 rx_buf->page = rx_queue->buf_page;
262 if (rx_buf->page == NULL) {
263 dma_addr_t dma_addr;
264
265 rx_buf->page = alloc_pages(__GFP_COLD | __GFP_COMP | GFP_ATOMIC,
266 efx->rx_buffer_order);
267 if (unlikely(rx_buf->page == NULL))
268 return -ENOMEM;
269
270 dma_addr = pci_map_page(efx->pci_dev, rx_buf->page,
271 0, RX_PAGE_SIZE(efx),
272 PCI_DMA_FROMDEVICE);
273
274 if (unlikely(pci_dma_mapping_error(dma_addr))) {
275 __free_pages(rx_buf->page, efx->rx_buffer_order);
276 rx_buf->page = NULL;
277 return -EIO;
278 }
279
280 rx_queue->buf_page = rx_buf->page;
281 rx_queue->buf_dma_addr = dma_addr;
282 rx_queue->buf_data = ((char *) page_address(rx_buf->page) +
283 EFX_PAGE_IP_ALIGN);
284 }
285
286 offset = RX_DATA_OFFSET(rx_queue->buf_data);
287 rx_buf->len = bytes;
288 rx_buf->dma_addr = rx_queue->buf_dma_addr + offset;
289 rx_buf->data = rx_queue->buf_data;
290
291 /* Try to pack multiple buffers per page */
292 if (efx->rx_buffer_order == 0) {
293 /* The next buffer starts on the next 512 byte boundary */
294 rx_queue->buf_data += ((bytes + 0x1ff) & ~0x1ff);
295 offset += ((bytes + 0x1ff) & ~0x1ff);
296
297 space = RX_PAGE_SIZE(efx) - offset;
298 if (space >= bytes) {
299 /* Refs dropped on kernel releasing each skb */
300 get_page(rx_queue->buf_page);
301 goto out;
302 }
303 }
304
305 /* This is the final RX buffer for this page, so mark it for
306 * unmapping */
307 rx_queue->buf_page = NULL;
308 rx_buf->unmap_addr = rx_queue->buf_dma_addr;
309
310 out:
311 return 0;
312}
313
314/* This allocates memory for a new receive buffer, maps it for DMA,
315 * and populates a struct efx_rx_buffer with the relevant
316 * information.
317 */
318static inline int efx_init_rx_buffer(struct efx_rx_queue *rx_queue,
319 struct efx_rx_buffer *new_rx_buf)
320{
321 int rc = 0;
322
323 if (rx_queue->channel->rx_alloc_push_pages) {
324 new_rx_buf->skb = NULL;
325 rc = efx_init_rx_buffer_page(rx_queue, new_rx_buf);
326 rx_queue->alloc_page_count++;
327 } else {
328 new_rx_buf->page = NULL;
329 rc = efx_init_rx_buffer_skb(rx_queue, new_rx_buf);
330 rx_queue->alloc_skb_count++;
331 }
332
333 if (unlikely(rc < 0))
334 EFX_LOG_RL(rx_queue->efx, "%s RXQ[%d] =%d\n", __func__,
335 rx_queue->queue, rc);
336 return rc;
337}
338
339static inline void efx_unmap_rx_buffer(struct efx_nic *efx,
340 struct efx_rx_buffer *rx_buf)
341{
342 if (rx_buf->page) {
343 EFX_BUG_ON_PARANOID(rx_buf->skb);
344 if (rx_buf->unmap_addr) {
345 pci_unmap_page(efx->pci_dev, rx_buf->unmap_addr,
346 RX_PAGE_SIZE(efx), PCI_DMA_FROMDEVICE);
347 rx_buf->unmap_addr = 0;
348 }
349 } else if (likely(rx_buf->skb)) {
350 pci_unmap_single(efx->pci_dev, rx_buf->dma_addr,
351 rx_buf->len, PCI_DMA_FROMDEVICE);
352 }
353}
354
355static inline void efx_free_rx_buffer(struct efx_nic *efx,
356 struct efx_rx_buffer *rx_buf)
357{
358 if (rx_buf->page) {
359 __free_pages(rx_buf->page, efx->rx_buffer_order);
360 rx_buf->page = NULL;
361 } else if (likely(rx_buf->skb)) {
362 dev_kfree_skb_any(rx_buf->skb);
363 rx_buf->skb = NULL;
364 }
365}
366
367static inline void efx_fini_rx_buffer(struct efx_rx_queue *rx_queue,
368 struct efx_rx_buffer *rx_buf)
369{
370 efx_unmap_rx_buffer(rx_queue->efx, rx_buf);
371 efx_free_rx_buffer(rx_queue->efx, rx_buf);
372}
373
374/**
375 * efx_fast_push_rx_descriptors - push new RX descriptors quickly
376 * @rx_queue: RX descriptor queue
377 * @retry: Recheck the fill level
378 * This will aim to fill the RX descriptor queue up to
379 * @rx_queue->@fast_fill_limit. If there is insufficient atomic
380 * memory to do so, the caller should retry.
381 */
382static int __efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue,
383 int retry)
384{
385 struct efx_rx_buffer *rx_buf;
386 unsigned fill_level, index;
387 int i, space, rc = 0;
388
389 /* Calculate current fill level. Do this outside the lock,
390 * because most of the time we'll end up not wanting to do the
391 * fill anyway.
392 */
393 fill_level = (rx_queue->added_count - rx_queue->removed_count);
394 EFX_BUG_ON_PARANOID(fill_level >
395 rx_queue->efx->type->rxd_ring_mask + 1);
396
397 /* Don't fill if we don't need to */
398 if (fill_level >= rx_queue->fast_fill_trigger)
399 return 0;
400
401 /* Record minimum fill level */
402 if (unlikely(fill_level < rx_queue->min_fill))
403 if (fill_level)
404 rx_queue->min_fill = fill_level;
405
406 /* Acquire RX add lock. If this lock is contended, then a fast
407 * fill must already be in progress (e.g. in the refill
408 * tasklet), so we don't need to do anything
409 */
410 if (!spin_trylock_bh(&rx_queue->add_lock))
411 return -1;
412
413 retry:
414 /* Recalculate current fill level now that we have the lock */
415 fill_level = (rx_queue->added_count - rx_queue->removed_count);
416 EFX_BUG_ON_PARANOID(fill_level >
417 rx_queue->efx->type->rxd_ring_mask + 1);
418 space = rx_queue->fast_fill_limit - fill_level;
419 if (space < EFX_RX_BATCH)
420 goto out_unlock;
421
422 EFX_TRACE(rx_queue->efx, "RX queue %d fast-filling descriptor ring from"
423 " level %d to level %d using %s allocation\n",
424 rx_queue->queue, fill_level, rx_queue->fast_fill_limit,
425 rx_queue->channel->rx_alloc_push_pages ? "page" : "skb");
426
427 do {
428 for (i = 0; i < EFX_RX_BATCH; ++i) {
429 index = (rx_queue->added_count &
430 rx_queue->efx->type->rxd_ring_mask);
431 rx_buf = efx_rx_buffer(rx_queue, index);
432 rc = efx_init_rx_buffer(rx_queue, rx_buf);
433 if (unlikely(rc))
434 goto out;
435 ++rx_queue->added_count;
436 }
437 } while ((space -= EFX_RX_BATCH) >= EFX_RX_BATCH);
438
439 EFX_TRACE(rx_queue->efx, "RX queue %d fast-filled descriptor ring "
440 "to level %d\n", rx_queue->queue,
441 rx_queue->added_count - rx_queue->removed_count);
442
443 out:
444 /* Send write pointer to card. */
445 falcon_notify_rx_desc(rx_queue);
446
447 /* If the fast fill is running inside from the refill tasklet, then
448 * for SMP systems it may be running on a different CPU to
449 * RX event processing, which means that the fill level may now be
450 * out of date. */
451 if (unlikely(retry && (rc == 0)))
452 goto retry;
453
454 out_unlock:
455 spin_unlock_bh(&rx_queue->add_lock);
456
457 return rc;
458}
459
460/**
461 * efx_fast_push_rx_descriptors - push new RX descriptors quickly
462 * @rx_queue: RX descriptor queue
463 *
464 * This will aim to fill the RX descriptor queue up to
465 * @rx_queue->@fast_fill_limit. If there is insufficient memory to do so,
466 * it will schedule a work item to immediately continue the fast fill
467 */
468void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue)
469{
470 int rc;
471
472 rc = __efx_fast_push_rx_descriptors(rx_queue, 0);
473 if (unlikely(rc)) {
474 /* Schedule the work item to run immediately. The hope is
475 * that work is immediately pending to free some memory
476 * (e.g. an RX event or TX completion)
477 */
478 efx_schedule_slow_fill(rx_queue, 0);
479 }
480}
481
482void efx_rx_work(struct work_struct *data)
483{
484 struct efx_rx_queue *rx_queue;
485 int rc;
486
487 rx_queue = container_of(data, struct efx_rx_queue, work.work);
488
489 if (unlikely(!rx_queue->channel->enabled))
490 return;
491
492 EFX_TRACE(rx_queue->efx, "RX queue %d worker thread executing on CPU "
493 "%d\n", rx_queue->queue, raw_smp_processor_id());
494
495 ++rx_queue->slow_fill_count;
496 /* Push new RX descriptors, allowing at least 1 jiffy for
497 * the kernel to free some more memory. */
498 rc = __efx_fast_push_rx_descriptors(rx_queue, 1);
499 if (rc)
500 efx_schedule_slow_fill(rx_queue, 1);
501}
502
503static inline void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
504 struct efx_rx_buffer *rx_buf,
505 int len, int *discard,
506 int *leak_packet)
507{
508 struct efx_nic *efx = rx_queue->efx;
509 unsigned max_len = rx_buf->len - efx->type->rx_buffer_padding;
510
511 if (likely(len <= max_len))
512 return;
513
514 /* The packet must be discarded, but this is only a fatal error
515 * if the caller indicated it was
516 */
517 *discard = 1;
518
519 if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) {
520 EFX_ERR_RL(efx, " RX queue %d seriously overlength "
521 "RX event (0x%x > 0x%x+0x%x). Leaking\n",
522 rx_queue->queue, len, max_len,
523 efx->type->rx_buffer_padding);
524 /* If this buffer was skb-allocated, then the meta
525 * data at the end of the skb will be trashed. So
526 * we have no choice but to leak the fragment.
527 */
528 *leak_packet = (rx_buf->skb != NULL);
529 efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY);
530 } else {
531 EFX_ERR_RL(efx, " RX queue %d overlength RX event "
532 "(0x%x > 0x%x)\n", rx_queue->queue, len, max_len);
533 }
534
535 rx_queue->channel->n_rx_overlength++;
536}
537
538/* Pass a received packet up through the generic LRO stack
539 *
540 * Handles driverlink veto, and passes the fragment up via
541 * the appropriate LRO method
542 */
543static inline void efx_rx_packet_lro(struct efx_channel *channel,
544 struct efx_rx_buffer *rx_buf)
545{
546 struct net_lro_mgr *lro_mgr = &channel->lro_mgr;
547 void *priv = channel;
548
549 /* Pass the skb/page into the LRO engine */
550 if (rx_buf->page) {
551 struct skb_frag_struct frags;
552
553 frags.page = rx_buf->page;
554 frags.page_offset = RX_BUF_OFFSET(rx_buf);
555 frags.size = rx_buf->len;
556
557 lro_receive_frags(lro_mgr, &frags, rx_buf->len,
558 rx_buf->len, priv, 0);
559
560 EFX_BUG_ON_PARANOID(rx_buf->skb);
561 rx_buf->page = NULL;
562 } else {
563 EFX_BUG_ON_PARANOID(!rx_buf->skb);
564
565 lro_receive_skb(lro_mgr, rx_buf->skb, priv);
566 rx_buf->skb = NULL;
567 }
568}
569
570/* Allocate and construct an SKB around a struct page.*/
571static inline struct sk_buff *efx_rx_mk_skb(struct efx_rx_buffer *rx_buf,
572 struct efx_nic *efx,
573 int hdr_len)
574{
575 struct sk_buff *skb;
576
577 /* Allocate an SKB to store the headers */
578 skb = netdev_alloc_skb(efx->net_dev, hdr_len + EFX_PAGE_SKB_ALIGN);
579 if (unlikely(skb == NULL)) {
580 EFX_ERR_RL(efx, "RX out of memory for skb\n");
581 return NULL;
582 }
583
584 EFX_BUG_ON_PARANOID(skb_shinfo(skb)->nr_frags);
585 EFX_BUG_ON_PARANOID(rx_buf->len < hdr_len);
586
587 skb->ip_summed = CHECKSUM_UNNECESSARY;
588 skb_reserve(skb, EFX_PAGE_SKB_ALIGN);
589
590 skb->len = rx_buf->len;
591 skb->truesize = rx_buf->len + sizeof(struct sk_buff);
592 memcpy(skb->data, rx_buf->data, hdr_len);
593 skb->tail += hdr_len;
594
595 /* Append the remaining page onto the frag list */
596 if (unlikely(rx_buf->len > hdr_len)) {
597 struct skb_frag_struct *frag = skb_shinfo(skb)->frags;
598 frag->page = rx_buf->page;
599 frag->page_offset = RX_BUF_OFFSET(rx_buf) + hdr_len;
600 frag->size = skb->len - hdr_len;
601 skb_shinfo(skb)->nr_frags = 1;
602 skb->data_len = frag->size;
603 } else {
604 __free_pages(rx_buf->page, efx->rx_buffer_order);
605 skb->data_len = 0;
606 }
607
608 /* Ownership has transferred from the rx_buf to skb */
609 rx_buf->page = NULL;
610
611 /* Move past the ethernet header */
612 skb->protocol = eth_type_trans(skb, efx->net_dev);
613
614 return skb;
615}
616
617void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index,
618 unsigned int len, int checksummed, int discard)
619{
620 struct efx_nic *efx = rx_queue->efx;
621 struct efx_rx_buffer *rx_buf;
622 int leak_packet = 0;
623
624 rx_buf = efx_rx_buffer(rx_queue, index);
625 EFX_BUG_ON_PARANOID(!rx_buf->data);
626 EFX_BUG_ON_PARANOID(rx_buf->skb && rx_buf->page);
627 EFX_BUG_ON_PARANOID(!(rx_buf->skb || rx_buf->page));
628
629 /* This allows the refill path to post another buffer.
630 * EFX_RXD_HEAD_ROOM ensures that the slot we are using
631 * isn't overwritten yet.
632 */
633 rx_queue->removed_count++;
634
635 /* Validate the length encoded in the event vs the descriptor pushed */
636 efx_rx_packet__check_len(rx_queue, rx_buf, len,
637 &discard, &leak_packet);
638
639 EFX_TRACE(efx, "RX queue %d received id %x at %llx+%x %s%s\n",
640 rx_queue->queue, index,
641 (unsigned long long)rx_buf->dma_addr, len,
642 (checksummed ? " [SUMMED]" : ""),
643 (discard ? " [DISCARD]" : ""));
644
645 /* Discard packet, if instructed to do so */
646 if (unlikely(discard)) {
647 if (unlikely(leak_packet))
648 rx_queue->channel->n_skbuff_leaks++;
649 else
650 /* We haven't called efx_unmap_rx_buffer yet,
651 * so fini the entire rx_buffer here */
652 efx_fini_rx_buffer(rx_queue, rx_buf);
653 return;
654 }
655
656 /* Release card resources - assumes all RX buffers consumed in-order
657 * per RX queue
658 */
659 efx_unmap_rx_buffer(efx, rx_buf);
660
661 /* Prefetch nice and early so data will (hopefully) be in cache by
662 * the time we look at it.
663 */
664 prefetch(rx_buf->data);
665
666 /* Pipeline receives so that we give time for packet headers to be
667 * prefetched into cache.
668 */
669 rx_buf->len = len;
670 if (rx_queue->channel->rx_pkt)
671 __efx_rx_packet(rx_queue->channel,
672 rx_queue->channel->rx_pkt,
673 rx_queue->channel->rx_pkt_csummed);
674 rx_queue->channel->rx_pkt = rx_buf;
675 rx_queue->channel->rx_pkt_csummed = checksummed;
676}
677
678/* Handle a received packet. Second half: Touches packet payload. */
679void __efx_rx_packet(struct efx_channel *channel,
680 struct efx_rx_buffer *rx_buf, int checksummed)
681{
682 struct efx_nic *efx = channel->efx;
683 struct sk_buff *skb;
684 int lro = efx->net_dev->features & NETIF_F_LRO;
685
686 if (rx_buf->skb) {
687 prefetch(skb_shinfo(rx_buf->skb));
688
689 skb_put(rx_buf->skb, rx_buf->len);
690
691 /* Move past the ethernet header. rx_buf->data still points
692 * at the ethernet header */
693 rx_buf->skb->protocol = eth_type_trans(rx_buf->skb,
694 efx->net_dev);
695 }
696
697 /* Both our generic-LRO and SFC-SSR support skb and page based
698 * allocation, but neither support switching from one to the
699 * other on the fly. If we spot that the allocation mode has
700 * changed, then flush the LRO state.
701 */
702 if (unlikely(channel->rx_alloc_pop_pages != (rx_buf->page != NULL))) {
703 efx_flush_lro(channel);
704 channel->rx_alloc_pop_pages = (rx_buf->page != NULL);
705 }
706 if (likely(checksummed && lro)) {
707 efx_rx_packet_lro(channel, rx_buf);
708 goto done;
709 }
710
711 /* Form an skb if required */
712 if (rx_buf->page) {
713 int hdr_len = min(rx_buf->len, EFX_SKB_HEADERS);
714 skb = efx_rx_mk_skb(rx_buf, efx, hdr_len);
715 if (unlikely(skb == NULL)) {
716 efx_free_rx_buffer(efx, rx_buf);
717 goto done;
718 }
719 } else {
720 /* We now own the SKB */
721 skb = rx_buf->skb;
722 rx_buf->skb = NULL;
723 }
724
725 EFX_BUG_ON_PARANOID(rx_buf->page);
726 EFX_BUG_ON_PARANOID(rx_buf->skb);
727 EFX_BUG_ON_PARANOID(!skb);
728
729 /* Set the SKB flags */
730 if (unlikely(!checksummed || !efx->rx_checksum_enabled))
731 skb->ip_summed = CHECKSUM_NONE;
732
733 /* Pass the packet up */
734 netif_receive_skb(skb);
735
736 /* Update allocation strategy method */
737 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
738
739 /* fall-thru */
740done:
741 efx->net_dev->last_rx = jiffies;
742}
743
744void efx_rx_strategy(struct efx_channel *channel)
745{
746 enum efx_rx_alloc_method method = rx_alloc_method;
747
748 /* Only makes sense to use page based allocation if LRO is enabled */
749 if (!(channel->efx->net_dev->features & NETIF_F_LRO)) {
750 method = RX_ALLOC_METHOD_SKB;
751 } else if (method == RX_ALLOC_METHOD_AUTO) {
752 /* Constrain the rx_alloc_level */
753 if (channel->rx_alloc_level < 0)
754 channel->rx_alloc_level = 0;
755 else if (channel->rx_alloc_level > RX_ALLOC_LEVEL_MAX)
756 channel->rx_alloc_level = RX_ALLOC_LEVEL_MAX;
757
758 /* Decide on the allocation method */
759 method = ((channel->rx_alloc_level > RX_ALLOC_LEVEL_LRO) ?
760 RX_ALLOC_METHOD_PAGE : RX_ALLOC_METHOD_SKB);
761 }
762
763 /* Push the option */
764 channel->rx_alloc_push_pages = (method == RX_ALLOC_METHOD_PAGE);
765}
766
767int efx_probe_rx_queue(struct efx_rx_queue *rx_queue)
768{
769 struct efx_nic *efx = rx_queue->efx;
770 unsigned int rxq_size;
771 int rc;
772
773 EFX_LOG(efx, "creating RX queue %d\n", rx_queue->queue);
774
775 /* Allocate RX buffers */
776 rxq_size = (efx->type->rxd_ring_mask + 1) * sizeof(*rx_queue->buffer);
777 rx_queue->buffer = kzalloc(rxq_size, GFP_KERNEL);
778 if (!rx_queue->buffer) {
779 rc = -ENOMEM;
780 goto fail1;
781 }
782
783 rc = falcon_probe_rx(rx_queue);
784 if (rc)
785 goto fail2;
786
787 return 0;
788
789 fail2:
790 kfree(rx_queue->buffer);
791 rx_queue->buffer = NULL;
792 fail1:
793 rx_queue->used = 0;
794
795 return rc;
796}
797
798int efx_init_rx_queue(struct efx_rx_queue *rx_queue)
799{
800 struct efx_nic *efx = rx_queue->efx;
801 unsigned int max_fill, trigger, limit;
802
803 EFX_LOG(rx_queue->efx, "initialising RX queue %d\n", rx_queue->queue);
804
805 /* Initialise ptr fields */
806 rx_queue->added_count = 0;
807 rx_queue->notified_count = 0;
808 rx_queue->removed_count = 0;
809 rx_queue->min_fill = -1U;
810 rx_queue->min_overfill = -1U;
811
812 /* Initialise limit fields */
813 max_fill = efx->type->rxd_ring_mask + 1 - EFX_RXD_HEAD_ROOM;
814 trigger = max_fill * min(rx_refill_threshold, 100U) / 100U;
815 limit = max_fill * min(rx_refill_limit, 100U) / 100U;
816
817 rx_queue->max_fill = max_fill;
818 rx_queue->fast_fill_trigger = trigger;
819 rx_queue->fast_fill_limit = limit;
820
821 /* Set up RX descriptor ring */
822 return falcon_init_rx(rx_queue);
823}
824
825void efx_fini_rx_queue(struct efx_rx_queue *rx_queue)
826{
827 int i;
828 struct efx_rx_buffer *rx_buf;
829
830 EFX_LOG(rx_queue->efx, "shutting down RX queue %d\n", rx_queue->queue);
831
832 falcon_fini_rx(rx_queue);
833
834 /* Release RX buffers NB start at index 0 not current HW ptr */
835 if (rx_queue->buffer) {
836 for (i = 0; i <= rx_queue->efx->type->rxd_ring_mask; i++) {
837 rx_buf = efx_rx_buffer(rx_queue, i);
838 efx_fini_rx_buffer(rx_queue, rx_buf);
839 }
840 }
841
842 /* For a page that is part-way through splitting into RX buffers */
843 if (rx_queue->buf_page != NULL) {
844 pci_unmap_page(rx_queue->efx->pci_dev, rx_queue->buf_dma_addr,
845 RX_PAGE_SIZE(rx_queue->efx), PCI_DMA_FROMDEVICE);
846 __free_pages(rx_queue->buf_page,
847 rx_queue->efx->rx_buffer_order);
848 rx_queue->buf_page = NULL;
849 }
850}
851
852void efx_remove_rx_queue(struct efx_rx_queue *rx_queue)
853{
854 EFX_LOG(rx_queue->efx, "destroying RX queue %d\n", rx_queue->queue);
855
856 falcon_remove_rx(rx_queue);
857
858 kfree(rx_queue->buffer);
859 rx_queue->buffer = NULL;
860 rx_queue->used = 0;
861}
862
863void efx_flush_lro(struct efx_channel *channel)
864{
865 lro_flush_all(&channel->lro_mgr);
866}
867
868
869module_param(rx_alloc_method, int, 0644);
870MODULE_PARM_DESC(rx_alloc_method, "Allocation method used for RX buffers");
871
872module_param(rx_refill_threshold, uint, 0444);
873MODULE_PARM_DESC(rx_refill_threshold,
874 "RX descriptor ring fast/slow fill threshold (%)");
875
diff --git a/drivers/net/sfc/rx.h b/drivers/net/sfc/rx.h
new file mode 100644
index 000000000000..f35e377bfc5f
--- /dev/null
+++ b/drivers/net/sfc/rx.h
@@ -0,0 +1,29 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_RX_H
11#define EFX_RX_H
12
13#include "net_driver.h"
14
15int efx_probe_rx_queue(struct efx_rx_queue *rx_queue);
16void efx_remove_rx_queue(struct efx_rx_queue *rx_queue);
17int efx_init_rx_queue(struct efx_rx_queue *rx_queue);
18void efx_fini_rx_queue(struct efx_rx_queue *rx_queue);
19
20int efx_lro_init(struct net_lro_mgr *lro_mgr, struct efx_nic *efx);
21void efx_lro_fini(struct net_lro_mgr *lro_mgr);
22void efx_flush_lro(struct efx_channel *channel);
23void efx_rx_strategy(struct efx_channel *channel);
24void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue);
25void efx_rx_work(struct work_struct *data);
26void __efx_rx_packet(struct efx_channel *channel,
27 struct efx_rx_buffer *rx_buf, int checksummed);
28
29#endif /* EFX_RX_H */
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
new file mode 100644
index 000000000000..11fa9fb8f48b
--- /dev/null
+++ b/drivers/net/sfc/sfe4001.c
@@ -0,0 +1,252 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10/*****************************************************************************
11 * Support for the SFE4001 NIC: driver code for the PCA9539 I/O expander that
12 * controls the PHY power rails, and for the MAX6647 temp. sensor used to check
13 * the PHY
14 */
15#include <linux/delay.h>
16#include "efx.h"
17#include "phy.h"
18#include "boards.h"
19#include "falcon.h"
20#include "falcon_hwdefs.h"
21#include "mac.h"
22
23/**************************************************************************
24 *
25 * I2C IO Expander device
26 *
27 **************************************************************************/
28#define PCA9539 0x74
29
30#define P0_IN 0x00
31#define P0_OUT 0x02
32#define P0_INVERT 0x04
33#define P0_CONFIG 0x06
34
35#define P0_EN_1V0X_LBN 0
36#define P0_EN_1V0X_WIDTH 1
37#define P0_EN_1V2_LBN 1
38#define P0_EN_1V2_WIDTH 1
39#define P0_EN_2V5_LBN 2
40#define P0_EN_2V5_WIDTH 1
41#define P0_EN_3V3X_LBN 3
42#define P0_EN_3V3X_WIDTH 1
43#define P0_EN_5V_LBN 4
44#define P0_EN_5V_WIDTH 1
45#define P0_SHORTEN_JTAG_LBN 5
46#define P0_SHORTEN_JTAG_WIDTH 1
47#define P0_X_TRST_LBN 6
48#define P0_X_TRST_WIDTH 1
49#define P0_DSP_RESET_LBN 7
50#define P0_DSP_RESET_WIDTH 1
51
52#define P1_IN 0x01
53#define P1_OUT 0x03
54#define P1_INVERT 0x05
55#define P1_CONFIG 0x07
56
57#define P1_AFE_PWD_LBN 0
58#define P1_AFE_PWD_WIDTH 1
59#define P1_DSP_PWD25_LBN 1
60#define P1_DSP_PWD25_WIDTH 1
61#define P1_RESERVED_LBN 2
62#define P1_RESERVED_WIDTH 2
63#define P1_SPARE_LBN 4
64#define P1_SPARE_WIDTH 4
65
66
67/**************************************************************************
68 *
69 * Temperature Sensor
70 *
71 **************************************************************************/
72#define MAX6647 0x4e
73
74#define RLTS 0x00
75#define RLTE 0x01
76#define RSL 0x02
77#define RCL 0x03
78#define RCRA 0x04
79#define RLHN 0x05
80#define RLLI 0x06
81#define RRHI 0x07
82#define RRLS 0x08
83#define WCRW 0x0a
84#define WLHO 0x0b
85#define WRHA 0x0c
86#define WRLN 0x0e
87#define OSHT 0x0f
88#define REET 0x10
89#define RIET 0x11
90#define RWOE 0x19
91#define RWOI 0x20
92#define HYS 0x21
93#define QUEUE 0x22
94#define MFID 0xfe
95#define REVID 0xff
96
97/* Status bits */
98#define MAX6647_BUSY (1 << 7) /* ADC is converting */
99#define MAX6647_LHIGH (1 << 6) /* Local high temp. alarm */
100#define MAX6647_LLOW (1 << 5) /* Local low temp. alarm */
101#define MAX6647_RHIGH (1 << 4) /* Remote high temp. alarm */
102#define MAX6647_RLOW (1 << 3) /* Remote low temp. alarm */
103#define MAX6647_FAULT (1 << 2) /* DXN/DXP short/open circuit */
104#define MAX6647_EOT (1 << 1) /* Remote junction overtemp. */
105#define MAX6647_IOT (1 << 0) /* Local junction overtemp. */
106
107static const u8 xgphy_max_temperature = 90;
108
109void sfe4001_poweroff(struct efx_nic *efx)
110{
111 struct efx_i2c_interface *i2c = &efx->i2c;
112
113 u8 cfg, out, in;
114
115 EFX_INFO(efx, "%s\n", __func__);
116
117 /* Turn off all power rails */
118 out = 0xff;
119 (void) efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
120
121 /* Disable port 1 outputs on IO expander */
122 cfg = 0xff;
123 (void) efx_i2c_write(i2c, PCA9539, P1_CONFIG, &cfg, 1);
124
125 /* Disable port 0 outputs on IO expander */
126 cfg = 0xff;
127 (void) efx_i2c_write(i2c, PCA9539, P0_CONFIG, &cfg, 1);
128
129 /* Clear any over-temperature alert */
130 (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1);
131}
132
133/* This board uses an I2C expander to provider power to the PHY, which needs to
134 * be turned on before the PHY can be used.
135 * Context: Process context, rtnl lock held
136 */
137int sfe4001_poweron(struct efx_nic *efx)
138{
139 struct efx_i2c_interface *i2c = &efx->i2c;
140 unsigned int count;
141 int rc;
142 u8 out, in, cfg;
143 efx_dword_t reg;
144
145 /* 10Xpress has fixed-function LED pins, so there is no board-specific
146 * blink code. */
147 efx->board_info.blink = tenxpress_phy_blink;
148
149 /* Ensure that XGXS and XAUI SerDes are held in reset */
150 EFX_POPULATE_DWORD_7(reg, XX_PWRDNA_EN, 1,
151 XX_PWRDNB_EN, 1,
152 XX_RSTPLLAB_EN, 1,
153 XX_RESETA_EN, 1,
154 XX_RESETB_EN, 1,
155 XX_RSTXGXSRX_EN, 1,
156 XX_RSTXGXSTX_EN, 1);
157 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
158 udelay(10);
159
160 /* Set DSP over-temperature alert threshold */
161 EFX_INFO(efx, "DSP cut-out at %dC\n", xgphy_max_temperature);
162 rc = efx_i2c_write(i2c, MAX6647, WLHO,
163 &xgphy_max_temperature, 1);
164 if (rc)
165 goto fail1;
166
167 /* Read it back and verify */
168 rc = efx_i2c_read(i2c, MAX6647, RLHN, &in, 1);
169 if (rc)
170 goto fail1;
171 if (in != xgphy_max_temperature) {
172 rc = -EFAULT;
173 goto fail1;
174 }
175
176 /* Clear any previous over-temperature alert */
177 rc = efx_i2c_read(i2c, MAX6647, RSL, &in, 1);
178 if (rc)
179 goto fail1;
180
181 /* Enable port 0 and port 1 outputs on IO expander */
182 cfg = 0x00;
183 rc = efx_i2c_write(i2c, PCA9539, P0_CONFIG, &cfg, 1);
184 if (rc)
185 goto fail1;
186 cfg = 0xff & ~(1 << P1_SPARE_LBN);
187 rc = efx_i2c_write(i2c, PCA9539, P1_CONFIG, &cfg, 1);
188 if (rc)
189 goto fail2;
190
191 /* Turn all power off then wait 1 sec. This ensures PHY is reset */
192 out = 0xff & ~((0 << P0_EN_1V2_LBN) | (0 << P0_EN_2V5_LBN) |
193 (0 << P0_EN_3V3X_LBN) | (0 << P0_EN_5V_LBN) |
194 (0 << P0_EN_1V0X_LBN));
195 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
196 if (rc)
197 goto fail3;
198
199 schedule_timeout_uninterruptible(HZ);
200 count = 0;
201 do {
202 /* Turn on 1.2V, 2.5V, 3.3V and 5V power rails */
203 out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
204 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
205 (1 << P0_X_TRST_LBN));
206
207 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
208 if (rc)
209 goto fail3;
210 msleep(10);
211
212 /* Turn on 1V power rail */
213 out &= ~(1 << P0_EN_1V0X_LBN);
214 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
215 if (rc)
216 goto fail3;
217
218 EFX_INFO(efx, "waiting for power (attempt %d)...\n", count);
219
220 schedule_timeout_uninterruptible(HZ);
221
222 /* Check DSP is powered */
223 rc = efx_i2c_read(i2c, PCA9539, P1_IN, &in, 1);
224 if (rc)
225 goto fail3;
226 if (in & (1 << P1_AFE_PWD_LBN))
227 goto done;
228
229 } while (++count < 20);
230
231 EFX_INFO(efx, "timed out waiting for power\n");
232 rc = -ETIMEDOUT;
233 goto fail3;
234
235done:
236 EFX_INFO(efx, "PHY is powered on\n");
237 return 0;
238
239fail3:
240 /* Turn off all power rails */
241 out = 0xff;
242 (void) efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
243 /* Disable port 1 outputs on IO expander */
244 out = 0xff;
245 (void) efx_i2c_write(i2c, PCA9539, P1_CONFIG, &out, 1);
246fail2:
247 /* Disable port 0 outputs on IO expander */
248 out = 0xff;
249 (void) efx_i2c_write(i2c, PCA9539, P0_CONFIG, &out, 1);
250fail1:
251 return rc;
252}
diff --git a/drivers/net/sfc/spi.h b/drivers/net/sfc/spi.h
new file mode 100644
index 000000000000..34412f3d41c9
--- /dev/null
+++ b/drivers/net/sfc/spi.h
@@ -0,0 +1,71 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005 Fen Systems Ltd.
4 * Copyright 2006 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_SPI_H
12#define EFX_SPI_H
13
14#include "net_driver.h"
15
16/**************************************************************************
17 *
18 * Basic SPI command set and bit definitions
19 *
20 *************************************************************************/
21
22/*
23 * Commands common to all known devices.
24 *
25 */
26
27/* Write status register */
28#define SPI_WRSR 0x01
29
30/* Write data to memory array */
31#define SPI_WRITE 0x02
32
33/* Read data from memory array */
34#define SPI_READ 0x03
35
36/* Reset write enable latch */
37#define SPI_WRDI 0x04
38
39/* Read status register */
40#define SPI_RDSR 0x05
41
42/* Set write enable latch */
43#define SPI_WREN 0x06
44
45/* SST: Enable write to status register */
46#define SPI_SST_EWSR 0x50
47
48/*
49 * Status register bits. Not all bits are supported on all devices.
50 *
51 */
52
53/* Write-protect pin enabled */
54#define SPI_STATUS_WPEN 0x80
55
56/* Block protection bit 2 */
57#define SPI_STATUS_BP2 0x10
58
59/* Block protection bit 1 */
60#define SPI_STATUS_BP1 0x08
61
62/* Block protection bit 0 */
63#define SPI_STATUS_BP0 0x04
64
65/* State of the write enable latch */
66#define SPI_STATUS_WEN 0x02
67
68/* Device busy flag */
69#define SPI_STATUS_NRDY 0x01
70
71#endif /* EFX_SPI_H */
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
new file mode 100644
index 000000000000..a2e9f79e47b1
--- /dev/null
+++ b/drivers/net/sfc/tenxpress.c
@@ -0,0 +1,434 @@
1/****************************************************************************
2 * Driver for Solarflare 802.3an compliant PHY
3 * Copyright 2007 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#include <linux/delay.h>
11#include <linux/seq_file.h>
12#include "efx.h"
13#include "gmii.h"
14#include "mdio_10g.h"
15#include "falcon.h"
16#include "phy.h"
17#include "falcon_hwdefs.h"
18#include "boards.h"
19#include "mac.h"
20
21/* We expect these MMDs to be in the package */
22/* AN not here as mdio_check_mmds() requires STAT2 support */
23#define TENXPRESS_REQUIRED_DEVS (MDIO_MMDREG_DEVS0_PMAPMD | \
24 MDIO_MMDREG_DEVS0_PCS | \
25 MDIO_MMDREG_DEVS0_PHYXS)
26
27/* We complain if we fail to see the link partner as 10G capable this many
28 * times in a row (must be > 1 as sampling the autoneg. registers is racy)
29 */
30#define MAX_BAD_LP_TRIES (5)
31
32/* Extended control register */
33#define PMA_PMD_XCONTROL_REG 0xc000
34#define PMA_PMD_LNPGA_POWERDOWN_LBN 8
35#define PMA_PMD_LNPGA_POWERDOWN_WIDTH 1
36
37/* extended status register */
38#define PMA_PMD_XSTATUS_REG 0xc001
39#define PMA_PMD_XSTAT_FLP_LBN (12)
40
41/* LED control register */
42#define PMA_PMD_LED_CTRL_REG (0xc007)
43#define PMA_PMA_LED_ACTIVITY_LBN (3)
44
45/* LED function override register */
46#define PMA_PMD_LED_OVERR_REG (0xc009)
47/* Bit positions for different LEDs (there are more but not wired on SFE4001)*/
48#define PMA_PMD_LED_LINK_LBN (0)
49#define PMA_PMD_LED_SPEED_LBN (2)
50#define PMA_PMD_LED_TX_LBN (4)
51#define PMA_PMD_LED_RX_LBN (6)
52/* Override settings */
53#define PMA_PMD_LED_AUTO (0) /* H/W control */
54#define PMA_PMD_LED_ON (1)
55#define PMA_PMD_LED_OFF (2)
56#define PMA_PMD_LED_FLASH (3)
57/* All LEDs under hardware control */
58#define PMA_PMD_LED_FULL_AUTO (0)
59/* Green and Amber under hardware control, Red off */
60#define PMA_PMD_LED_DEFAULT (PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN)
61
62
63/* Self test (BIST) control register */
64#define PMA_PMD_BIST_CTRL_REG (0xc014)
65#define PMA_PMD_BIST_BER_LBN (2) /* Run BER test */
66#define PMA_PMD_BIST_CONT_LBN (1) /* Run continuous BIST until cleared */
67#define PMA_PMD_BIST_SINGLE_LBN (0) /* Run 1 BIST iteration (self clears) */
68/* Self test status register */
69#define PMA_PMD_BIST_STAT_REG (0xc015)
70#define PMA_PMD_BIST_ENX_LBN (3)
71#define PMA_PMD_BIST_PMA_LBN (2)
72#define PMA_PMD_BIST_RXD_LBN (1)
73#define PMA_PMD_BIST_AFE_LBN (0)
74
75#define BIST_MAX_DELAY (1000)
76#define BIST_POLL_DELAY (10)
77
78/* Misc register defines */
79#define PCS_CLOCK_CTRL_REG 0xd801
80#define PLL312_RST_N_LBN 2
81
82#define PCS_SOFT_RST2_REG 0xd806
83#define SERDES_RST_N_LBN 13
84#define XGXS_RST_N_LBN 12
85
86#define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */
87#define CLK312_EN_LBN 3
88
89/* Boot status register */
90#define PCS_BOOT_STATUS_REG (0xd000)
91#define PCS_BOOT_FATAL_ERR_LBN (0)
92#define PCS_BOOT_PROGRESS_LBN (1)
93#define PCS_BOOT_PROGRESS_WIDTH (2)
94#define PCS_BOOT_COMPLETE_LBN (3)
95#define PCS_BOOT_MAX_DELAY (100)
96#define PCS_BOOT_POLL_DELAY (10)
97
98/* Time to wait between powering down the LNPGA and turning off the power
99 * rails */
100#define LNPGA_PDOWN_WAIT (HZ / 5)
101
102static int crc_error_reset_threshold = 100;
103module_param(crc_error_reset_threshold, int, 0644);
104MODULE_PARM_DESC(crc_error_reset_threshold,
105 "Max number of CRC errors before XAUI reset");
106
107struct tenxpress_phy_data {
108 enum tenxpress_state state;
109 atomic_t bad_crc_count;
110 int bad_lp_tries;
111};
112
113static int tenxpress_state_is(struct efx_nic *efx, int state)
114{
115 struct tenxpress_phy_data *phy_data = efx->phy_data;
116 return (phy_data != NULL) && (state == phy_data->state);
117}
118
119void tenxpress_set_state(struct efx_nic *efx,
120 enum tenxpress_state state)
121{
122 struct tenxpress_phy_data *phy_data = efx->phy_data;
123 if (phy_data != NULL)
124 phy_data->state = state;
125}
126
127void tenxpress_crc_err(struct efx_nic *efx)
128{
129 struct tenxpress_phy_data *phy_data = efx->phy_data;
130 if (phy_data != NULL)
131 atomic_inc(&phy_data->bad_crc_count);
132}
133
134/* Check that the C166 has booted successfully */
135static int tenxpress_phy_check(struct efx_nic *efx)
136{
137 int phy_id = efx->mii.phy_id;
138 int count = PCS_BOOT_MAX_DELAY / PCS_BOOT_POLL_DELAY;
139 int boot_stat;
140
141 /* Wait for the boot to complete (or not) */
142 while (count) {
143 boot_stat = mdio_clause45_read(efx, phy_id,
144 MDIO_MMD_PCS,
145 PCS_BOOT_STATUS_REG);
146 if (boot_stat & (1 << PCS_BOOT_COMPLETE_LBN))
147 break;
148 count--;
149 udelay(PCS_BOOT_POLL_DELAY);
150 }
151
152 if (!count) {
153 EFX_ERR(efx, "%s: PHY boot timed out. Last status "
154 "%x\n", __func__,
155 (boot_stat >> PCS_BOOT_PROGRESS_LBN) &
156 ((1 << PCS_BOOT_PROGRESS_WIDTH) - 1));
157 return -ETIMEDOUT;
158 }
159
160 return 0;
161}
162
163static void tenxpress_reset_xaui(struct efx_nic *efx);
164
165static int tenxpress_init(struct efx_nic *efx)
166{
167 int rc, reg;
168
169 /* Turn on the clock */
170 reg = (1 << CLK312_EN_LBN);
171 mdio_clause45_write(efx, efx->mii.phy_id,
172 MDIO_MMD_PCS, PCS_TEST_SELECT_REG, reg);
173
174 rc = tenxpress_phy_check(efx);
175 if (rc < 0)
176 return rc;
177
178 /* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */
179 reg = mdio_clause45_read(efx, efx->mii.phy_id,
180 MDIO_MMD_PMAPMD, PMA_PMD_LED_CTRL_REG);
181 reg |= (1 << PMA_PMA_LED_ACTIVITY_LBN);
182 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
183 PMA_PMD_LED_CTRL_REG, reg);
184
185 reg = PMA_PMD_LED_DEFAULT;
186 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
187 PMA_PMD_LED_OVERR_REG, reg);
188
189 return rc;
190}
191
192static int tenxpress_phy_init(struct efx_nic *efx)
193{
194 struct tenxpress_phy_data *phy_data;
195 int rc = 0;
196
197 phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
198 efx->phy_data = phy_data;
199
200 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL);
201
202 rc = mdio_clause45_wait_reset_mmds(efx,
203 TENXPRESS_REQUIRED_DEVS);
204 if (rc < 0)
205 goto fail;
206
207 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
208 if (rc < 0)
209 goto fail;
210
211 rc = tenxpress_init(efx);
212 if (rc < 0)
213 goto fail;
214
215 schedule_timeout_uninterruptible(HZ / 5); /* 200ms */
216
217 /* Let XGXS and SerDes out of reset and resets 10XPress */
218 falcon_reset_xaui(efx);
219
220 return 0;
221
222 fail:
223 kfree(efx->phy_data);
224 efx->phy_data = NULL;
225 return rc;
226}
227
228static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp)
229{
230 struct tenxpress_phy_data *pd = efx->phy_data;
231 int reg;
232
233 /* Nothing to do if all is well and was previously so. */
234 if (!(bad_lp || pd->bad_lp_tries))
235 return;
236
237 reg = mdio_clause45_read(efx, efx->mii.phy_id,
238 MDIO_MMD_PMAPMD, PMA_PMD_LED_OVERR_REG);
239
240 if (bad_lp)
241 pd->bad_lp_tries++;
242 else
243 pd->bad_lp_tries = 0;
244
245 if (pd->bad_lp_tries == MAX_BAD_LP_TRIES) {
246 pd->bad_lp_tries = 0; /* Restart count */
247 reg &= ~(PMA_PMD_LED_FLASH << PMA_PMD_LED_RX_LBN);
248 reg |= (PMA_PMD_LED_FLASH << PMA_PMD_LED_RX_LBN);
249 EFX_ERR(efx, "This NIC appears to be plugged into"
250 " a port that is not 10GBASE-T capable.\n"
251 " This PHY is 10GBASE-T ONLY, so no link can"
252 " be established.\n");
253 } else {
254 reg |= (PMA_PMD_LED_OFF << PMA_PMD_LED_RX_LBN);
255 }
256 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
257 PMA_PMD_LED_OVERR_REG, reg);
258}
259
260/* Check link status and return a boolean OK value. If the link is NOT
261 * OK we have a quick rummage round to see if we appear to be plugged
262 * into a non-10GBT port and if so warn the user that they won't get
263 * link any time soon as we are 10GBT only, unless caller specified
264 * not to do this check (it isn't useful in loopback) */
265static int tenxpress_link_ok(struct efx_nic *efx, int check_lp)
266{
267 int ok = mdio_clause45_links_ok(efx, TENXPRESS_REQUIRED_DEVS);
268
269 if (ok) {
270 tenxpress_set_bad_lp(efx, 0);
271 } else if (check_lp) {
272 /* Are we plugged into the wrong sort of link? */
273 int bad_lp = 0;
274 int phy_id = efx->mii.phy_id;
275 int an_stat = mdio_clause45_read(efx, phy_id, MDIO_MMD_AN,
276 MDIO_AN_STATUS);
277 int xphy_stat = mdio_clause45_read(efx, phy_id,
278 MDIO_MMD_PMAPMD,
279 PMA_PMD_XSTATUS_REG);
280 /* Are we plugged into anything that sends FLPs? If
281 * not we can't distinguish between not being plugged
282 * in and being plugged into a non-AN antique. The FLP
283 * bit has the advantage of not clearing when autoneg
284 * restarts. */
285 if (!(xphy_stat & (1 << PMA_PMD_XSTAT_FLP_LBN))) {
286 tenxpress_set_bad_lp(efx, 0);
287 return ok;
288 }
289
290 /* If it can do 10GBT it must be XNP capable */
291 bad_lp = !(an_stat & (1 << MDIO_AN_STATUS_XNP_LBN));
292 if (!bad_lp && (an_stat & (1 << MDIO_AN_STATUS_PAGE_LBN))) {
293 bad_lp = !(mdio_clause45_read(efx, phy_id,
294 MDIO_MMD_AN, MDIO_AN_10GBT_STATUS) &
295 (1 << MDIO_AN_10GBT_STATUS_LP_10G_LBN));
296 }
297 tenxpress_set_bad_lp(efx, bad_lp);
298 }
299 return ok;
300}
301
302static void tenxpress_phy_reconfigure(struct efx_nic *efx)
303{
304 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL))
305 return;
306
307 efx->link_up = tenxpress_link_ok(efx, 0);
308 efx->link_options = GM_LPA_10000FULL;
309}
310
311static void tenxpress_phy_clear_interrupt(struct efx_nic *efx)
312{
313 /* Nothing done here - LASI interrupts aren't reliable so poll */
314}
315
316
317/* Poll PHY for interrupt */
318static int tenxpress_phy_check_hw(struct efx_nic *efx)
319{
320 struct tenxpress_phy_data *phy_data = efx->phy_data;
321 int phy_up = tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL);
322 int link_ok;
323
324 link_ok = phy_up && tenxpress_link_ok(efx, 1);
325
326 if (link_ok != efx->link_up)
327 falcon_xmac_sim_phy_event(efx);
328
329 /* Nothing to check if we've already shut down the PHY */
330 if (!phy_up)
331 return 0;
332
333 if (atomic_read(&phy_data->bad_crc_count) > crc_error_reset_threshold) {
334 EFX_ERR(efx, "Resetting XAUI due to too many CRC errors\n");
335 falcon_reset_xaui(efx);
336 atomic_set(&phy_data->bad_crc_count, 0);
337 }
338
339 return 0;
340}
341
342static void tenxpress_phy_fini(struct efx_nic *efx)
343{
344 int reg;
345
346 /* Power down the LNPGA */
347 reg = (1 << PMA_PMD_LNPGA_POWERDOWN_LBN);
348 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
349 PMA_PMD_XCONTROL_REG, reg);
350
351 /* Waiting here ensures that the board fini, which can turn off the
352 * power to the PHY, won't get run until the LNPGA powerdown has been
353 * given long enough to complete. */
354 schedule_timeout_uninterruptible(LNPGA_PDOWN_WAIT); /* 200 ms */
355
356 kfree(efx->phy_data);
357 efx->phy_data = NULL;
358}
359
360
361/* Set the RX and TX LEDs and Link LED flashing. The other LEDs
362 * (which probably aren't wired anyway) are left in AUTO mode */
363void tenxpress_phy_blink(struct efx_nic *efx, int blink)
364{
365 int reg;
366
367 if (blink)
368 reg = (PMA_PMD_LED_FLASH << PMA_PMD_LED_TX_LBN) |
369 (PMA_PMD_LED_FLASH << PMA_PMD_LED_RX_LBN) |
370 (PMA_PMD_LED_FLASH << PMA_PMD_LED_LINK_LBN);
371 else
372 reg = PMA_PMD_LED_DEFAULT;
373
374 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
375 PMA_PMD_LED_OVERR_REG, reg);
376}
377
378static void tenxpress_reset_xaui(struct efx_nic *efx)
379{
380 int phy = efx->mii.phy_id;
381 int clk_ctrl, test_select, soft_rst2;
382
383 /* Real work is done on clock_ctrl other resets are thought to be
384 * optional but make the reset more reliable
385 */
386
387 /* Read */
388 clk_ctrl = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,
389 PCS_CLOCK_CTRL_REG);
390 test_select = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,
391 PCS_TEST_SELECT_REG);
392 soft_rst2 = mdio_clause45_read(efx, phy, MDIO_MMD_PCS,
393 PCS_SOFT_RST2_REG);
394
395 /* Put in reset */
396 test_select &= ~(1 << CLK312_EN_LBN);
397 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
398 PCS_TEST_SELECT_REG, test_select);
399
400 soft_rst2 &= ~((1 << XGXS_RST_N_LBN) | (1 << SERDES_RST_N_LBN));
401 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
402 PCS_SOFT_RST2_REG, soft_rst2);
403
404 clk_ctrl &= ~(1 << PLL312_RST_N_LBN);
405 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
406 PCS_CLOCK_CTRL_REG, clk_ctrl);
407 udelay(10);
408
409 /* Remove reset */
410 clk_ctrl |= (1 << PLL312_RST_N_LBN);
411 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
412 PCS_CLOCK_CTRL_REG, clk_ctrl);
413 udelay(10);
414
415 soft_rst2 |= ((1 << XGXS_RST_N_LBN) | (1 << SERDES_RST_N_LBN));
416 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
417 PCS_SOFT_RST2_REG, soft_rst2);
418 udelay(10);
419
420 test_select |= (1 << CLK312_EN_LBN);
421 mdio_clause45_write(efx, phy, MDIO_MMD_PCS,
422 PCS_TEST_SELECT_REG, test_select);
423 udelay(10);
424}
425
426struct efx_phy_operations falcon_tenxpress_phy_ops = {
427 .init = tenxpress_phy_init,
428 .reconfigure = tenxpress_phy_reconfigure,
429 .check_hw = tenxpress_phy_check_hw,
430 .fini = tenxpress_phy_fini,
431 .clear_interrupt = tenxpress_phy_clear_interrupt,
432 .reset_xaui = tenxpress_reset_xaui,
433 .mmds = TENXPRESS_REQUIRED_DEVS,
434};
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
new file mode 100644
index 000000000000..fbb866b2185e
--- /dev/null
+++ b/drivers/net/sfc/tx.c
@@ -0,0 +1,452 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2005-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/pci.h>
12#include <linux/tcp.h>
13#include <linux/ip.h>
14#include <linux/in.h>
15#include <linux/if_ether.h>
16#include <linux/highmem.h>
17#include "net_driver.h"
18#include "tx.h"
19#include "efx.h"
20#include "falcon.h"
21#include "workarounds.h"
22
23/*
24 * TX descriptor ring full threshold
25 *
26 * The tx_queue descriptor ring fill-level must fall below this value
27 * before we restart the netif queue
28 */
29#define EFX_NETDEV_TX_THRESHOLD(_tx_queue) \
30 (_tx_queue->efx->type->txd_ring_mask / 2u)
31
32/* We want to be able to nest calls to netif_stop_queue(), since each
33 * channel can have an individual stop on the queue.
34 */
35void efx_stop_queue(struct efx_nic *efx)
36{
37 spin_lock_bh(&efx->netif_stop_lock);
38 EFX_TRACE(efx, "stop TX queue\n");
39
40 atomic_inc(&efx->netif_stop_count);
41 netif_stop_queue(efx->net_dev);
42
43 spin_unlock_bh(&efx->netif_stop_lock);
44}
45
46/* Wake netif's TX queue
47 * We want to be able to nest calls to netif_stop_queue(), since each
48 * channel can have an individual stop on the queue.
49 */
50inline void efx_wake_queue(struct efx_nic *efx)
51{
52 local_bh_disable();
53 if (atomic_dec_and_lock(&efx->netif_stop_count,
54 &efx->netif_stop_lock)) {
55 EFX_TRACE(efx, "waking TX queue\n");
56 netif_wake_queue(efx->net_dev);
57 spin_unlock(&efx->netif_stop_lock);
58 }
59 local_bh_enable();
60}
61
62static inline void efx_dequeue_buffer(struct efx_tx_queue *tx_queue,
63 struct efx_tx_buffer *buffer)
64{
65 if (buffer->unmap_len) {
66 struct pci_dev *pci_dev = tx_queue->efx->pci_dev;
67 if (buffer->unmap_single)
68 pci_unmap_single(pci_dev, buffer->unmap_addr,
69 buffer->unmap_len, PCI_DMA_TODEVICE);
70 else
71 pci_unmap_page(pci_dev, buffer->unmap_addr,
72 buffer->unmap_len, PCI_DMA_TODEVICE);
73 buffer->unmap_len = 0;
74 buffer->unmap_single = 0;
75 }
76
77 if (buffer->skb) {
78 dev_kfree_skb_any((struct sk_buff *) buffer->skb);
79 buffer->skb = NULL;
80 EFX_TRACE(tx_queue->efx, "TX queue %d transmission id %x "
81 "complete\n", tx_queue->queue, read_ptr);
82 }
83}
84
85
86/*
87 * Add a socket buffer to a TX queue
88 *
89 * This maps all fragments of a socket buffer for DMA and adds them to
90 * the TX queue. The queue's insert pointer will be incremented by
91 * the number of fragments in the socket buffer.
92 *
93 * If any DMA mapping fails, any mapped fragments will be unmapped,
94 * the queue's insert pointer will be restored to its original value.
95 *
96 * Returns NETDEV_TX_OK or NETDEV_TX_BUSY
97 * You must hold netif_tx_lock() to call this function.
98 */
99static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
100 const struct sk_buff *skb)
101{
102 struct efx_nic *efx = tx_queue->efx;
103 struct pci_dev *pci_dev = efx->pci_dev;
104 struct efx_tx_buffer *buffer;
105 skb_frag_t *fragment;
106 struct page *page;
107 int page_offset;
108 unsigned int len, unmap_len = 0, fill_level, insert_ptr, misalign;
109 dma_addr_t dma_addr, unmap_addr = 0;
110 unsigned int dma_len;
111 unsigned unmap_single;
112 int q_space, i = 0;
113 int rc = NETDEV_TX_OK;
114
115 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count);
116
117 /* Get size of the initial fragment */
118 len = skb_headlen(skb);
119
120 fill_level = tx_queue->insert_count - tx_queue->old_read_count;
121 q_space = efx->type->txd_ring_mask - 1 - fill_level;
122
123 /* Map for DMA. Use pci_map_single rather than pci_map_page
124 * since this is more efficient on machines with sparse
125 * memory.
126 */
127 unmap_single = 1;
128 dma_addr = pci_map_single(pci_dev, skb->data, len, PCI_DMA_TODEVICE);
129
130 /* Process all fragments */
131 while (1) {
132 if (unlikely(pci_dma_mapping_error(dma_addr)))
133 goto pci_err;
134
135 /* Store fields for marking in the per-fragment final
136 * descriptor */
137 unmap_len = len;
138 unmap_addr = dma_addr;
139
140 /* Add to TX queue, splitting across DMA boundaries */
141 do {
142 if (unlikely(q_space-- <= 0)) {
143 /* It might be that completions have
144 * happened since the xmit path last
145 * checked. Update the xmit path's
146 * copy of read_count.
147 */
148 ++tx_queue->stopped;
149 /* This memory barrier protects the
150 * change of stopped from the access
151 * of read_count. */
152 smp_mb();
153 tx_queue->old_read_count =
154 *(volatile unsigned *)
155 &tx_queue->read_count;
156 fill_level = (tx_queue->insert_count
157 - tx_queue->old_read_count);
158 q_space = (efx->type->txd_ring_mask - 1 -
159 fill_level);
160 if (unlikely(q_space-- <= 0))
161 goto stop;
162 smp_mb();
163 --tx_queue->stopped;
164 }
165
166 insert_ptr = (tx_queue->insert_count &
167 efx->type->txd_ring_mask);
168 buffer = &tx_queue->buffer[insert_ptr];
169 EFX_BUG_ON_PARANOID(buffer->skb);
170 EFX_BUG_ON_PARANOID(buffer->len);
171 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
172 EFX_BUG_ON_PARANOID(buffer->unmap_len);
173
174 dma_len = (((~dma_addr) & efx->type->tx_dma_mask) + 1);
175 if (likely(dma_len > len))
176 dma_len = len;
177
178 misalign = (unsigned)dma_addr & efx->type->bug5391_mask;
179 if (misalign && dma_len + misalign > 512)
180 dma_len = 512 - misalign;
181
182 /* Fill out per descriptor fields */
183 buffer->len = dma_len;
184 buffer->dma_addr = dma_addr;
185 len -= dma_len;
186 dma_addr += dma_len;
187 ++tx_queue->insert_count;
188 } while (len);
189
190 /* Transfer ownership of the unmapping to the final buffer */
191 buffer->unmap_addr = unmap_addr;
192 buffer->unmap_single = unmap_single;
193 buffer->unmap_len = unmap_len;
194 unmap_len = 0;
195
196 /* Get address and size of next fragment */
197 if (i >= skb_shinfo(skb)->nr_frags)
198 break;
199 fragment = &skb_shinfo(skb)->frags[i];
200 len = fragment->size;
201 page = fragment->page;
202 page_offset = fragment->page_offset;
203 i++;
204 /* Map for DMA */
205 unmap_single = 0;
206 dma_addr = pci_map_page(pci_dev, page, page_offset, len,
207 PCI_DMA_TODEVICE);
208 }
209
210 /* Transfer ownership of the skb to the final buffer */
211 buffer->skb = skb;
212 buffer->continuation = 0;
213
214 /* Pass off to hardware */
215 falcon_push_buffers(tx_queue);
216
217 return NETDEV_TX_OK;
218
219 pci_err:
220 EFX_ERR_RL(efx, " TX queue %d could not map skb with %d bytes %d "
221 "fragments for DMA\n", tx_queue->queue, skb->len,
222 skb_shinfo(skb)->nr_frags + 1);
223
224 /* Mark the packet as transmitted, and free the SKB ourselves */
225 dev_kfree_skb_any((struct sk_buff *)skb);
226 goto unwind;
227
228 stop:
229 rc = NETDEV_TX_BUSY;
230
231 if (tx_queue->stopped == 1)
232 efx_stop_queue(efx);
233
234 unwind:
235 /* Work backwards until we hit the original insert pointer value */
236 while (tx_queue->insert_count != tx_queue->write_count) {
237 --tx_queue->insert_count;
238 insert_ptr = tx_queue->insert_count & efx->type->txd_ring_mask;
239 buffer = &tx_queue->buffer[insert_ptr];
240 efx_dequeue_buffer(tx_queue, buffer);
241 buffer->len = 0;
242 }
243
244 /* Free the fragment we were mid-way through pushing */
245 if (unmap_len)
246 pci_unmap_page(pci_dev, unmap_addr, unmap_len,
247 PCI_DMA_TODEVICE);
248
249 return rc;
250}
251
252/* Remove packets from the TX queue
253 *
254 * This removes packets from the TX queue, up to and including the
255 * specified index.
256 */
257static inline void efx_dequeue_buffers(struct efx_tx_queue *tx_queue,
258 unsigned int index)
259{
260 struct efx_nic *efx = tx_queue->efx;
261 unsigned int stop_index, read_ptr;
262 unsigned int mask = tx_queue->efx->type->txd_ring_mask;
263
264 stop_index = (index + 1) & mask;
265 read_ptr = tx_queue->read_count & mask;
266
267 while (read_ptr != stop_index) {
268 struct efx_tx_buffer *buffer = &tx_queue->buffer[read_ptr];
269 if (unlikely(buffer->len == 0)) {
270 EFX_ERR(tx_queue->efx, "TX queue %d spurious TX "
271 "completion id %x\n", tx_queue->queue,
272 read_ptr);
273 efx_schedule_reset(efx, RESET_TYPE_TX_SKIP);
274 return;
275 }
276
277 efx_dequeue_buffer(tx_queue, buffer);
278 buffer->continuation = 1;
279 buffer->len = 0;
280
281 ++tx_queue->read_count;
282 read_ptr = tx_queue->read_count & mask;
283 }
284}
285
286/* Initiate a packet transmission on the specified TX queue.
287 * Note that returning anything other than NETDEV_TX_OK will cause the
288 * OS to free the skb.
289 *
290 * This function is split out from efx_hard_start_xmit to allow the
291 * loopback test to direct packets via specific TX queues. It is
292 * therefore a non-static inline, so as not to penalise performance
293 * for non-loopback transmissions.
294 *
295 * Context: netif_tx_lock held
296 */
297inline int efx_xmit(struct efx_nic *efx,
298 struct efx_tx_queue *tx_queue, struct sk_buff *skb)
299{
300 int rc;
301
302 /* Map fragments for DMA and add to TX queue */
303 rc = efx_enqueue_skb(tx_queue, skb);
304 if (unlikely(rc != NETDEV_TX_OK))
305 goto out;
306
307 /* Update last TX timer */
308 efx->net_dev->trans_start = jiffies;
309
310 out:
311 return rc;
312}
313
314/* Initiate a packet transmission. We use one channel per CPU
315 * (sharing when we have more CPUs than channels). On Falcon, the TX
316 * completion events will be directed back to the CPU that transmitted
317 * the packet, which should be cache-efficient.
318 *
319 * Context: non-blocking.
320 * Note that returning anything other than NETDEV_TX_OK will cause the
321 * OS to free the skb.
322 */
323int efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
324{
325 struct efx_nic *efx = net_dev->priv;
326 return efx_xmit(efx, &efx->tx_queue[0], skb);
327}
328
329void efx_xmit_done(struct efx_tx_queue *tx_queue, unsigned int index)
330{
331 unsigned fill_level;
332 struct efx_nic *efx = tx_queue->efx;
333
334 EFX_BUG_ON_PARANOID(index > efx->type->txd_ring_mask);
335
336 efx_dequeue_buffers(tx_queue, index);
337
338 /* See if we need to restart the netif queue. This barrier
339 * separates the update of read_count from the test of
340 * stopped. */
341 smp_mb();
342 if (unlikely(tx_queue->stopped)) {
343 fill_level = tx_queue->insert_count - tx_queue->read_count;
344 if (fill_level < EFX_NETDEV_TX_THRESHOLD(tx_queue)) {
345 EFX_BUG_ON_PARANOID(!NET_DEV_REGISTERED(efx));
346
347 /* Do this under netif_tx_lock(), to avoid racing
348 * with efx_xmit(). */
349 netif_tx_lock(efx->net_dev);
350 if (tx_queue->stopped) {
351 tx_queue->stopped = 0;
352 efx_wake_queue(efx);
353 }
354 netif_tx_unlock(efx->net_dev);
355 }
356 }
357}
358
359int efx_probe_tx_queue(struct efx_tx_queue *tx_queue)
360{
361 struct efx_nic *efx = tx_queue->efx;
362 unsigned int txq_size;
363 int i, rc;
364
365 EFX_LOG(efx, "creating TX queue %d\n", tx_queue->queue);
366
367 /* Allocate software ring */
368 txq_size = (efx->type->txd_ring_mask + 1) * sizeof(*tx_queue->buffer);
369 tx_queue->buffer = kzalloc(txq_size, GFP_KERNEL);
370 if (!tx_queue->buffer) {
371 rc = -ENOMEM;
372 goto fail1;
373 }
374 for (i = 0; i <= efx->type->txd_ring_mask; ++i)
375 tx_queue->buffer[i].continuation = 1;
376
377 /* Allocate hardware ring */
378 rc = falcon_probe_tx(tx_queue);
379 if (rc)
380 goto fail2;
381
382 return 0;
383
384 fail2:
385 kfree(tx_queue->buffer);
386 tx_queue->buffer = NULL;
387 fail1:
388 tx_queue->used = 0;
389
390 return rc;
391}
392
393int efx_init_tx_queue(struct efx_tx_queue *tx_queue)
394{
395 EFX_LOG(tx_queue->efx, "initialising TX queue %d\n", tx_queue->queue);
396
397 tx_queue->insert_count = 0;
398 tx_queue->write_count = 0;
399 tx_queue->read_count = 0;
400 tx_queue->old_read_count = 0;
401 BUG_ON(tx_queue->stopped);
402
403 /* Set up TX descriptor ring */
404 return falcon_init_tx(tx_queue);
405}
406
407void efx_release_tx_buffers(struct efx_tx_queue *tx_queue)
408{
409 struct efx_tx_buffer *buffer;
410
411 if (!tx_queue->buffer)
412 return;
413
414 /* Free any buffers left in the ring */
415 while (tx_queue->read_count != tx_queue->write_count) {
416 buffer = &tx_queue->buffer[tx_queue->read_count &
417 tx_queue->efx->type->txd_ring_mask];
418 efx_dequeue_buffer(tx_queue, buffer);
419 buffer->continuation = 1;
420 buffer->len = 0;
421
422 ++tx_queue->read_count;
423 }
424}
425
426void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)
427{
428 EFX_LOG(tx_queue->efx, "shutting down TX queue %d\n", tx_queue->queue);
429
430 /* Flush TX queue, remove descriptor ring */
431 falcon_fini_tx(tx_queue);
432
433 efx_release_tx_buffers(tx_queue);
434
435 /* Release queue's stop on port, if any */
436 if (tx_queue->stopped) {
437 tx_queue->stopped = 0;
438 efx_wake_queue(tx_queue->efx);
439 }
440}
441
442void efx_remove_tx_queue(struct efx_tx_queue *tx_queue)
443{
444 EFX_LOG(tx_queue->efx, "destroying TX queue %d\n", tx_queue->queue);
445 falcon_remove_tx(tx_queue);
446
447 kfree(tx_queue->buffer);
448 tx_queue->buffer = NULL;
449 tx_queue->used = 0;
450}
451
452
diff --git a/drivers/net/sfc/tx.h b/drivers/net/sfc/tx.h
new file mode 100644
index 000000000000..1526a73b4b51
--- /dev/null
+++ b/drivers/net/sfc/tx.h
@@ -0,0 +1,24 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_TX_H
12#define EFX_TX_H
13
14#include "net_driver.h"
15
16int efx_probe_tx_queue(struct efx_tx_queue *tx_queue);
17void efx_remove_tx_queue(struct efx_tx_queue *tx_queue);
18int efx_init_tx_queue(struct efx_tx_queue *tx_queue);
19void efx_fini_tx_queue(struct efx_tx_queue *tx_queue);
20
21int efx_hard_start_xmit(struct sk_buff *skb, struct net_device *net_dev);
22void efx_release_tx_buffers(struct efx_tx_queue *tx_queue);
23
24#endif /* EFX_TX_H */
diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h
new file mode 100644
index 000000000000..dca62f190198
--- /dev/null
+++ b/drivers/net/sfc/workarounds.h
@@ -0,0 +1,56 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006-2008 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_WORKAROUNDS_H
11#define EFX_WORKAROUNDS_H
12
13/*
14 * Hardware workarounds.
15 * Bug numbers are from Solarflare's Bugzilla.
16 */
17
18#define EFX_WORKAROUND_ALWAYS(efx) 1
19#define EFX_WORKAROUND_FALCON_A(efx) (FALCON_REV(efx) <= FALCON_REV_A1)
20
21/* XAUI resets if link not detected */
22#define EFX_WORKAROUND_5147 EFX_WORKAROUND_ALWAYS
23/* SNAP frames have TOBE_DISC set */
24#define EFX_WORKAROUND_5475 EFX_WORKAROUND_ALWAYS
25/* RX PCIe double split performance issue */
26#define EFX_WORKAROUND_7575 EFX_WORKAROUND_ALWAYS
27/* TX pkt parser problem with <= 16 byte TXes */
28#define EFX_WORKAROUND_9141 EFX_WORKAROUND_ALWAYS
29/* XGXS and XAUI reset sequencing in SW */
30#define EFX_WORKAROUND_9388 EFX_WORKAROUND_ALWAYS
31/* Low rate CRC errors require XAUI reset */
32#define EFX_WORKAROUND_10750 EFX_WORKAROUND_ALWAYS
33/* TX_EV_PKT_ERR can be caused by a dangling TX descriptor
34 * or a PCIe error (bug 11028) */
35#define EFX_WORKAROUND_10727 EFX_WORKAROUND_ALWAYS
36/* Transmit flow control may get disabled */
37#define EFX_WORKAROUND_11482 EFX_WORKAROUND_ALWAYS
38/* Flush events can take a very long time to appear */
39#define EFX_WORKAROUND_11557 EFX_WORKAROUND_ALWAYS
40
41/* Spurious parity errors in TSORT buffers */
42#define EFX_WORKAROUND_5129 EFX_WORKAROUND_FALCON_A
43/* iSCSI parsing errors */
44#define EFX_WORKAROUND_5583 EFX_WORKAROUND_FALCON_A
45/* RX events go missing */
46#define EFX_WORKAROUND_5676 EFX_WORKAROUND_FALCON_A
47/* RX_RESET on A1 */
48#define EFX_WORKAROUND_6555 EFX_WORKAROUND_FALCON_A
49/* Increase filter depth to avoid RX_RESET */
50#define EFX_WORKAROUND_7244 EFX_WORKAROUND_FALCON_A
51/* Flushes may never complete */
52#define EFX_WORKAROUND_7803 EFX_WORKAROUND_FALCON_A
53/* Leak overlength packets rather than free */
54#define EFX_WORKAROUND_8071 EFX_WORKAROUND_FALCON_A
55
56#endif /* EFX_WORKAROUNDS_H */
diff --git a/drivers/net/sfc/xenpack.h b/drivers/net/sfc/xenpack.h
new file mode 100644
index 000000000000..b0d1f225b70a
--- /dev/null
+++ b/drivers/net/sfc/xenpack.h
@@ -0,0 +1,62 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_XENPACK_H
11#define EFX_XENPACK_H
12
13/* Exported functions from Xenpack standard PHY control */
14
15#include "mdio_10g.h"
16
17/****************************************************************************/
18/* XENPACK MDIO register extensions */
19#define MDIO_XP_LASI_RX_CTRL (0x9000)
20#define MDIO_XP_LASI_TX_CTRL (0x9001)
21#define MDIO_XP_LASI_CTRL (0x9002)
22#define MDIO_XP_LASI_RX_STAT (0x9003)
23#define MDIO_XP_LASI_TX_STAT (0x9004)
24#define MDIO_XP_LASI_STAT (0x9005)
25
26/* Control/Status bits */
27#define XP_LASI_LS_ALARM (1 << 0)
28#define XP_LASI_TX_ALARM (1 << 1)
29#define XP_LASI_RX_ALARM (1 << 2)
30/* These two are Quake vendor extensions to the standard XENPACK defines */
31#define XP_LASI_LS_INTB (1 << 3)
32#define XP_LASI_TEST (1 << 7)
33
34/* Enable LASI interrupts for PHY */
35static inline void xenpack_enable_lasi_irqs(struct efx_nic *efx)
36{
37 int reg;
38 int phy_id = efx->mii.phy_id;
39 /* Read to clear LASI status register */
40 reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
41 MDIO_XP_LASI_STAT);
42
43 mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
44 MDIO_XP_LASI_CTRL, XP_LASI_LS_ALARM);
45}
46
47/* Read the LASI interrupt status to clear the interrupt. */
48static inline int xenpack_clear_lasi_irqs(struct efx_nic *efx)
49{
50 /* Read to clear link status alarm */
51 return mdio_clause45_read(efx, efx->mii.phy_id,
52 MDIO_MMD_PMAPMD, MDIO_XP_LASI_STAT);
53}
54
55/* Turn off LASI interrupts */
56static inline void xenpack_disable_lasi_irqs(struct efx_nic *efx)
57{
58 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
59 MDIO_XP_LASI_CTRL, 0);
60}
61
62#endif /* EFX_XENPACK_H */
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
new file mode 100644
index 000000000000..66dd5bf1eaa9
--- /dev/null
+++ b/drivers/net/sfc/xfp_phy.c
@@ -0,0 +1,132 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2006-2008 Solarflare Communications Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9/*
10 * Driver for XFP optical PHYs (plus some support specific to the Quake 2032)
11 * See www.amcc.com for details (search for qt2032)
12 */
13
14#include <linux/timer.h>
15#include <linux/delay.h>
16#include "efx.h"
17#include "gmii.h"
18#include "mdio_10g.h"
19#include "xenpack.h"
20#include "phy.h"
21#include "mac.h"
22
23#define XFP_REQUIRED_DEVS (MDIO_MMDREG_DEVS0_PCS | \
24 MDIO_MMDREG_DEVS0_PMAPMD | \
25 MDIO_MMDREG_DEVS0_PHYXS)
26
27/****************************************************************************/
28/* Quake-specific MDIO registers */
29#define MDIO_QUAKE_LED0_REG (0xD006)
30
31void xfp_set_led(struct efx_nic *p, int led, int mode)
32{
33 int addr = MDIO_QUAKE_LED0_REG + led;
34 mdio_clause45_write(p, p->mii.phy_id, MDIO_MMD_PMAPMD, addr,
35 mode);
36}
37
38#define XFP_MAX_RESET_TIME 500
39#define XFP_RESET_WAIT 10
40
41/* Reset the PHYXS MMD. This is documented (for the Quake PHY) as doing
42 * a complete soft reset.
43 */
44static int xfp_reset_phy(struct efx_nic *efx)
45{
46 int rc;
47
48 rc = mdio_clause45_reset_mmd(efx, MDIO_MMD_PHYXS,
49 XFP_MAX_RESET_TIME / XFP_RESET_WAIT,
50 XFP_RESET_WAIT);
51 if (rc < 0)
52 goto fail;
53
54 /* Wait 250ms for the PHY to complete bootup */
55 msleep(250);
56
57 /* Check that all the MMDs we expect are present and responding. We
58 * expect faults on some if the link is down, but not on the PHY XS */
59 rc = mdio_clause45_check_mmds(efx, XFP_REQUIRED_DEVS,
60 MDIO_MMDREG_DEVS0_PHYXS);
61 if (rc < 0)
62 goto fail;
63
64 efx->board_info.init_leds(efx);
65
66 return rc;
67
68 fail:
69 EFX_ERR(efx, "XFP: reset timed out!\n");
70 return rc;
71}
72
73static int xfp_phy_init(struct efx_nic *efx)
74{
75 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS);
76 int rc;
77
78 EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision"
79 " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid),
80 MDIO_ID_REV(devid));
81
82 rc = xfp_reset_phy(efx);
83
84 EFX_INFO(efx, "XFP: PHY init %s.\n",
85 rc ? "failed" : "successful");
86
87 return rc;
88}
89
90static void xfp_phy_clear_interrupt(struct efx_nic *efx)
91{
92 xenpack_clear_lasi_irqs(efx);
93}
94
95static int xfp_link_ok(struct efx_nic *efx)
96{
97 return mdio_clause45_links_ok(efx, XFP_REQUIRED_DEVS);
98}
99
100static int xfp_phy_check_hw(struct efx_nic *efx)
101{
102 int rc = 0;
103 int link_up = xfp_link_ok(efx);
104 /* Simulate a PHY event if link state has changed */
105 if (link_up != efx->link_up)
106 falcon_xmac_sim_phy_event(efx);
107
108 return rc;
109}
110
111static void xfp_phy_reconfigure(struct efx_nic *efx)
112{
113 efx->link_up = xfp_link_ok(efx);
114 efx->link_options = GM_LPA_10000FULL;
115}
116
117
118static void xfp_phy_fini(struct efx_nic *efx)
119{
120 /* Clobber the LED if it was blinking */
121 efx->board_info.blink(efx, 0);
122}
123
124struct efx_phy_operations falcon_xfp_phy_ops = {
125 .init = xfp_phy_init,
126 .reconfigure = xfp_phy_reconfigure,
127 .check_hw = xfp_phy_check_hw,
128 .fini = xfp_phy_fini,
129 .clear_interrupt = xfp_phy_clear_interrupt,
130 .reset_xaui = efx_port_dummy_op_void,
131 .mmds = XFP_REQUIRED_DEVS,
132};
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 20745fd4e973..abc63b0663be 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -212,6 +212,12 @@ enum _DescStatusBit {
212 THOL2 = 0x20000000, 212 THOL2 = 0x20000000,
213 THOL1 = 0x10000000, 213 THOL1 = 0x10000000,
214 THOL0 = 0x00000000, 214 THOL0 = 0x00000000,
215
216 WND = 0x00080000,
217 TABRT = 0x00040000,
218 FIFO = 0x00020000,
219 LINK = 0x00010000,
220 ColCountMask = 0x0000ffff,
215 /* RxDesc.status */ 221 /* RxDesc.status */
216 IPON = 0x20000000, 222 IPON = 0x20000000,
217 TCPON = 0x10000000, 223 TCPON = 0x10000000,
@@ -480,30 +486,23 @@ static inline void sis190_make_unusable_by_asic(struct RxDesc *desc)
480 desc->status = 0x0; 486 desc->status = 0x0;
481} 487}
482 488
483static int sis190_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff, 489static struct sk_buff *sis190_alloc_rx_skb(struct sis190_private *tp,
484 struct RxDesc *desc, u32 rx_buf_sz) 490 struct RxDesc *desc)
485{ 491{
492 u32 rx_buf_sz = tp->rx_buf_sz;
486 struct sk_buff *skb; 493 struct sk_buff *skb;
487 dma_addr_t mapping;
488 int ret = 0;
489
490 skb = dev_alloc_skb(rx_buf_sz);
491 if (!skb)
492 goto err_out;
493
494 *sk_buff = skb;
495 494
496 mapping = pci_map_single(pdev, skb->data, rx_buf_sz, 495 skb = netdev_alloc_skb(tp->dev, rx_buf_sz);
497 PCI_DMA_FROMDEVICE); 496 if (likely(skb)) {
497 dma_addr_t mapping;
498 498
499 sis190_map_to_asic(desc, mapping, rx_buf_sz); 499 mapping = pci_map_single(tp->pci_dev, skb->data, tp->rx_buf_sz,
500out: 500 PCI_DMA_FROMDEVICE);
501 return ret; 501 sis190_map_to_asic(desc, mapping, rx_buf_sz);
502 } else
503 sis190_make_unusable_by_asic(desc);
502 504
503err_out: 505 return skb;
504 ret = -ENOMEM;
505 sis190_make_unusable_by_asic(desc);
506 goto out;
507} 506}
508 507
509static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev, 508static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,
@@ -512,37 +511,41 @@ static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev,
512 u32 cur; 511 u32 cur;
513 512
514 for (cur = start; cur < end; cur++) { 513 for (cur = start; cur < end; cur++) {
515 int ret, i = cur % NUM_RX_DESC; 514 unsigned int i = cur % NUM_RX_DESC;
516 515
517 if (tp->Rx_skbuff[i]) 516 if (tp->Rx_skbuff[i])
518 continue; 517 continue;
519 518
520 ret = sis190_alloc_rx_skb(tp->pci_dev, tp->Rx_skbuff + i, 519 tp->Rx_skbuff[i] = sis190_alloc_rx_skb(tp, tp->RxDescRing + i);
521 tp->RxDescRing + i, tp->rx_buf_sz); 520
522 if (ret < 0) 521 if (!tp->Rx_skbuff[i])
523 break; 522 break;
524 } 523 }
525 return cur - start; 524 return cur - start;
526} 525}
527 526
528static inline int sis190_try_rx_copy(struct sk_buff **sk_buff, int pkt_size, 527static bool sis190_try_rx_copy(struct sis190_private *tp,
529 struct RxDesc *desc, int rx_buf_sz) 528 struct sk_buff **sk_buff, int pkt_size,
529 dma_addr_t addr)
530{ 530{
531 int ret = -1; 531 struct sk_buff *skb;
532 bool done = false;
532 533
533 if (pkt_size < rx_copybreak) { 534 if (pkt_size >= rx_copybreak)
534 struct sk_buff *skb; 535 goto out;
535 536
536 skb = dev_alloc_skb(pkt_size + NET_IP_ALIGN); 537 skb = netdev_alloc_skb(tp->dev, pkt_size + 2);
537 if (skb) { 538 if (!skb)
538 skb_reserve(skb, NET_IP_ALIGN); 539 goto out;
539 skb_copy_to_linear_data(skb, sk_buff[0]->data, pkt_size); 540
540 *sk_buff = skb; 541 pci_dma_sync_single_for_device(tp->pci_dev, addr, pkt_size,
541 sis190_give_to_asic(desc, rx_buf_sz); 542 PCI_DMA_FROMDEVICE);
542 ret = 0; 543 skb_reserve(skb, 2);
543 } 544 skb_copy_to_linear_data(skb, sk_buff[0]->data, pkt_size);
544 } 545 *sk_buff = skb;
545 return ret; 546 done = true;
547out:
548 return done;
546} 549}
547 550
548static inline int sis190_rx_pkt_err(u32 status, struct net_device_stats *stats) 551static inline int sis190_rx_pkt_err(u32 status, struct net_device_stats *stats)
@@ -592,9 +595,9 @@ static int sis190_rx_interrupt(struct net_device *dev,
592 sis190_give_to_asic(desc, tp->rx_buf_sz); 595 sis190_give_to_asic(desc, tp->rx_buf_sz);
593 else { 596 else {
594 struct sk_buff *skb = tp->Rx_skbuff[entry]; 597 struct sk_buff *skb = tp->Rx_skbuff[entry];
598 dma_addr_t addr = le32_to_cpu(desc->addr);
595 int pkt_size = (status & RxSizeMask) - 4; 599 int pkt_size = (status & RxSizeMask) - 4;
596 void (*pci_action)(struct pci_dev *, dma_addr_t, 600 struct pci_dev *pdev = tp->pci_dev;
597 size_t, int) = pci_dma_sync_single_for_device;
598 601
599 if (unlikely(pkt_size > tp->rx_buf_sz)) { 602 if (unlikely(pkt_size > tp->rx_buf_sz)) {
600 net_intr(tp, KERN_INFO 603 net_intr(tp, KERN_INFO
@@ -606,20 +609,18 @@ static int sis190_rx_interrupt(struct net_device *dev,
606 continue; 609 continue;
607 } 610 }
608 611
609 pci_dma_sync_single_for_cpu(tp->pci_dev,
610 le32_to_cpu(desc->addr), tp->rx_buf_sz,
611 PCI_DMA_FROMDEVICE);
612 612
613 if (sis190_try_rx_copy(&skb, pkt_size, desc, 613 if (sis190_try_rx_copy(tp, &skb, pkt_size, addr)) {
614 tp->rx_buf_sz)) { 614 pci_dma_sync_single_for_device(pdev, addr,
615 pci_action = pci_unmap_single; 615 tp->rx_buf_sz, PCI_DMA_FROMDEVICE);
616 sis190_give_to_asic(desc, tp->rx_buf_sz);
617 } else {
618 pci_unmap_single(pdev, addr, tp->rx_buf_sz,
619 PCI_DMA_FROMDEVICE);
616 tp->Rx_skbuff[entry] = NULL; 620 tp->Rx_skbuff[entry] = NULL;
617 sis190_make_unusable_by_asic(desc); 621 sis190_make_unusable_by_asic(desc);
618 } 622 }
619 623
620 pci_action(tp->pci_dev, le32_to_cpu(desc->addr),
621 tp->rx_buf_sz, PCI_DMA_FROMDEVICE);
622
623 skb_put(skb, pkt_size); 624 skb_put(skb, pkt_size);
624 skb->protocol = eth_type_trans(skb, dev); 625 skb->protocol = eth_type_trans(skb, dev);
625 626
@@ -658,9 +659,31 @@ static void sis190_unmap_tx_skb(struct pci_dev *pdev, struct sk_buff *skb,
658 memset(desc, 0x00, sizeof(*desc)); 659 memset(desc, 0x00, sizeof(*desc));
659} 660}
660 661
662static inline int sis190_tx_pkt_err(u32 status, struct net_device_stats *stats)
663{
664#define TxErrMask (WND | TABRT | FIFO | LINK)
665
666 if (!unlikely(status & TxErrMask))
667 return 0;
668
669 if (status & WND)
670 stats->tx_window_errors++;
671 if (status & TABRT)
672 stats->tx_aborted_errors++;
673 if (status & FIFO)
674 stats->tx_fifo_errors++;
675 if (status & LINK)
676 stats->tx_carrier_errors++;
677
678 stats->tx_errors++;
679
680 return -1;
681}
682
661static void sis190_tx_interrupt(struct net_device *dev, 683static void sis190_tx_interrupt(struct net_device *dev,
662 struct sis190_private *tp, void __iomem *ioaddr) 684 struct sis190_private *tp, void __iomem *ioaddr)
663{ 685{
686 struct net_device_stats *stats = &dev->stats;
664 u32 pending, dirty_tx = tp->dirty_tx; 687 u32 pending, dirty_tx = tp->dirty_tx;
665 /* 688 /*
666 * It would not be needed if queueing was allowed to be enabled 689 * It would not be needed if queueing was allowed to be enabled
@@ -675,15 +698,19 @@ static void sis190_tx_interrupt(struct net_device *dev,
675 for (; pending; pending--, dirty_tx++) { 698 for (; pending; pending--, dirty_tx++) {
676 unsigned int entry = dirty_tx % NUM_TX_DESC; 699 unsigned int entry = dirty_tx % NUM_TX_DESC;
677 struct TxDesc *txd = tp->TxDescRing + entry; 700 struct TxDesc *txd = tp->TxDescRing + entry;
701 u32 status = le32_to_cpu(txd->status);
678 struct sk_buff *skb; 702 struct sk_buff *skb;
679 703
680 if (le32_to_cpu(txd->status) & OWNbit) 704 if (status & OWNbit)
681 break; 705 break;
682 706
683 skb = tp->Tx_skbuff[entry]; 707 skb = tp->Tx_skbuff[entry];
684 708
685 dev->stats.tx_packets++; 709 if (likely(sis190_tx_pkt_err(status, stats) == 0)) {
686 dev->stats.tx_bytes += skb->len; 710 stats->tx_packets++;
711 stats->tx_bytes += skb->len;
712 stats->collisions += ((status & ColCountMask) - 1);
713 }
687 714
688 sis190_unmap_tx_skb(tp->pci_dev, skb, txd); 715 sis190_unmap_tx_skb(tp->pci_dev, skb, txd);
689 tp->Tx_skbuff[entry] = NULL; 716 tp->Tx_skbuff[entry] = NULL;
@@ -904,10 +931,9 @@ static void sis190_phy_task(struct work_struct *work)
904 mod_timer(&tp->timer, jiffies + HZ/10); 931 mod_timer(&tp->timer, jiffies + HZ/10);
905 } else if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) & 932 } else if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) &
906 BMSR_ANEGCOMPLETE)) { 933 BMSR_ANEGCOMPLETE)) {
907 net_link(tp, KERN_WARNING "%s: PHY reset until link up.\n",
908 dev->name);
909 netif_carrier_off(dev); 934 netif_carrier_off(dev);
910 mdio_write(ioaddr, phy_id, MII_BMCR, val | BMCR_RESET); 935 net_link(tp, KERN_WARNING "%s: auto-negotiating...\n",
936 dev->name);
911 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT); 937 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT);
912 } else { 938 } else {
913 /* Rejoice ! */ 939 /* Rejoice ! */
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 5a55ede352f4..84af68fdb6c2 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -396,14 +396,14 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len)
396 396
397 /* Order of next two lines is *very* important. 397 /* Order of next two lines is *very* important.
398 * When we are sending a little amount of data, 398 * When we are sending a little amount of data,
399 * the transfer may be completed inside driver.write() 399 * the transfer may be completed inside the ops->write()
400 * routine, because it's running with interrupts enabled. 400 * routine, because it's running with interrupts enabled.
401 * In this case we *never* got WRITE_WAKEUP event, 401 * In this case we *never* got WRITE_WAKEUP event,
402 * if we did not request it before write operation. 402 * if we did not request it before write operation.
403 * 14 Oct 1994 Dmitry Gorodchanin. 403 * 14 Oct 1994 Dmitry Gorodchanin.
404 */ 404 */
405 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 405 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
406 actual = sl->tty->driver->write(sl->tty, sl->xbuff, count); 406 actual = sl->tty->ops->write(sl->tty, sl->xbuff, count);
407#ifdef SL_CHECK_TRANSMIT 407#ifdef SL_CHECK_TRANSMIT
408 sl->dev->trans_start = jiffies; 408 sl->dev->trans_start = jiffies;
409#endif 409#endif
@@ -437,7 +437,7 @@ static void slip_write_wakeup(struct tty_struct *tty)
437 return; 437 return;
438 } 438 }
439 439
440 actual = tty->driver->write(tty, sl->xhead, sl->xleft); 440 actual = tty->ops->write(tty, sl->xhead, sl->xleft);
441 sl->xleft -= actual; 441 sl->xleft -= actual;
442 sl->xhead += actual; 442 sl->xhead += actual;
443} 443}
@@ -462,7 +462,7 @@ static void sl_tx_timeout(struct net_device *dev)
462 } 462 }
463 printk(KERN_WARNING "%s: transmit timed out, %s?\n", 463 printk(KERN_WARNING "%s: transmit timed out, %s?\n",
464 dev->name, 464 dev->name,
465 (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ? 465 (tty_chars_in_buffer(sl->tty) || sl->xleft) ?
466 "bad line quality" : "driver error"); 466 "bad line quality" : "driver error");
467 sl->xleft = 0; 467 sl->xleft = 0;
468 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); 468 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
@@ -830,6 +830,9 @@ static int slip_open(struct tty_struct *tty)
830 if (!capable(CAP_NET_ADMIN)) 830 if (!capable(CAP_NET_ADMIN))
831 return -EPERM; 831 return -EPERM;
832 832
833 if (tty->ops->write == NULL)
834 return -EOPNOTSUPP;
835
833 /* RTnetlink lock is misused here to serialize concurrent 836 /* RTnetlink lock is misused here to serialize concurrent
834 opens of slip channels. There are better ways, but it is 837 opens of slip channels. There are better ways, but it is
835 the simplest one. 838 the simplest one.
@@ -1432,7 +1435,7 @@ static void sl_outfill(unsigned long sls)
1432 /* put END into tty queue. Is it right ??? */ 1435 /* put END into tty queue. Is it right ??? */
1433 if (!netif_queue_stopped(sl->dev)) { 1436 if (!netif_queue_stopped(sl->dev)) {
1434 /* if device busy no outfill */ 1437 /* if device busy no outfill */
1435 sl->tty->driver->write(sl->tty, &s, 1); 1438 sl->tty->ops->write(sl->tty, &s, 1);
1436 } 1439 }
1437 } else 1440 } else
1438 set_bit(SLF_OUTWAIT, &sl->flags); 1441 set_bit(SLF_OUTWAIT, &sl->flags);
diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c
index 63abfd72542d..e03eef2f2282 100644
--- a/drivers/net/wan/pc300_tty.c
+++ b/drivers/net/wan/pc300_tty.c
@@ -178,6 +178,20 @@ static void cpc_tty_signal_on(pc300dev_t *pc300dev, unsigned char signal)
178 CPC_TTY_UNLOCK(card,flags); 178 CPC_TTY_UNLOCK(card,flags);
179} 179}
180 180
181
182static const struct tty_operations pc300_ops = {
183 .open = cpc_tty_open,
184 .close = cpc_tty_close,
185 .write = cpc_tty_write,
186 .write_room = cpc_tty_write_room,
187 .chars_in_buffer = cpc_tty_chars_in_buffer,
188 .tiocmset = pc300_tiocmset,
189 .tiocmget = pc300_tiocmget,
190 .flush_buffer = cpc_tty_flush_buffer,
191 .hangup = cpc_tty_hangup,
192};
193
194
181/* 195/*
182 * PC300 TTY initialization routine 196 * PC300 TTY initialization routine
183 * 197 *
@@ -225,15 +239,7 @@ void cpc_tty_init(pc300dev_t *pc300dev)
225 serial_drv.flags = TTY_DRIVER_REAL_RAW; 239 serial_drv.flags = TTY_DRIVER_REAL_RAW;
226 240
227 /* interface routines from the upper tty layer to the tty driver */ 241 /* interface routines from the upper tty layer to the tty driver */
228 serial_drv.open = cpc_tty_open; 242 tty_set_operations(&serial_drv, &pc300_ops);
229 serial_drv.close = cpc_tty_close;
230 serial_drv.write = cpc_tty_write;
231 serial_drv.write_room = cpc_tty_write_room;
232 serial_drv.chars_in_buffer = cpc_tty_chars_in_buffer;
233 serial_drv.tiocmset = pc300_tiocmset;
234 serial_drv.tiocmget = pc300_tiocmget;
235 serial_drv.flush_buffer = cpc_tty_flush_buffer;
236 serial_drv.hangup = cpc_tty_hangup;
237 243
238 /* register the TTY driver */ 244 /* register the TTY driver */
239 if (tty_register_driver(&serial_drv)) { 245 if (tty_register_driver(&serial_drv)) {
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 0f8aca8a4d43..249e18053d5f 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -17,7 +17,7 @@
17#include <linux/module.h> 17#include <linux/module.h>
18 18
19#include <asm/system.h> 19#include <asm/system.h>
20#include <asm/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/bitops.h> 21#include <linux/bitops.h>
22#include <linux/string.h> 22#include <linux/string.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
@@ -95,7 +95,7 @@ static struct x25_asy *x25_asy_alloc(void)
95 x25_asy_devs[i] = dev; 95 x25_asy_devs[i] = dev;
96 return sl; 96 return sl;
97 } else { 97 } else {
98 printk("x25_asy_alloc() - register_netdev() failure.\n"); 98 printk(KERN_WARNING "x25_asy_alloc() - register_netdev() failure.\n");
99 free_netdev(dev); 99 free_netdev(dev);
100 } 100 }
101 } 101 }
@@ -112,23 +112,22 @@ static void x25_asy_free(struct x25_asy *sl)
112 kfree(sl->xbuff); 112 kfree(sl->xbuff);
113 sl->xbuff = NULL; 113 sl->xbuff = NULL;
114 114
115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags)) { 115 if (!test_and_clear_bit(SLF_INUSE, &sl->flags))
116 printk("%s: x25_asy_free for already free unit.\n", sl->dev->name); 116 printk(KERN_ERR "%s: x25_asy_free for already free unit.\n",
117 } 117 sl->dev->name);
118} 118}
119 119
120static int x25_asy_change_mtu(struct net_device *dev, int newmtu) 120static int x25_asy_change_mtu(struct net_device *dev, int newmtu)
121{ 121{
122 struct x25_asy *sl = dev->priv; 122 struct x25_asy *sl = dev->priv;
123 unsigned char *xbuff, *rbuff; 123 unsigned char *xbuff, *rbuff;
124 int len = 2* newmtu; 124 int len = 2 * newmtu;
125 125
126 xbuff = kmalloc(len + 4, GFP_ATOMIC); 126 xbuff = kmalloc(len + 4, GFP_ATOMIC);
127 rbuff = kmalloc(len + 4, GFP_ATOMIC); 127 rbuff = kmalloc(len + 4, GFP_ATOMIC);
128 128
129 if (xbuff == NULL || rbuff == NULL) 129 if (xbuff == NULL || rbuff == NULL) {
130 { 130 printk(KERN_WARNING "%s: unable to grow X.25 buffers, MTU change cancelled.\n",
131 printk("%s: unable to grow X.25 buffers, MTU change cancelled.\n",
132 dev->name); 131 dev->name);
133 kfree(xbuff); 132 kfree(xbuff);
134 kfree(rbuff); 133 kfree(rbuff);
@@ -193,25 +192,23 @@ static void x25_asy_bump(struct x25_asy *sl)
193 int err; 192 int err;
194 193
195 count = sl->rcount; 194 count = sl->rcount;
196 sl->stats.rx_bytes+=count; 195 sl->stats.rx_bytes += count;
197 196
198 skb = dev_alloc_skb(count+1); 197 skb = dev_alloc_skb(count+1);
199 if (skb == NULL) 198 if (skb == NULL) {
200 { 199 printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n",
201 printk("%s: memory squeeze, dropping packet.\n", sl->dev->name); 200 sl->dev->name);
202 sl->stats.rx_dropped++; 201 sl->stats.rx_dropped++;
203 return; 202 return;
204 } 203 }
205 skb_push(skb,1); /* LAPB internal control */ 204 skb_push(skb, 1); /* LAPB internal control */
206 memcpy(skb_put(skb,count), sl->rbuff, count); 205 memcpy(skb_put(skb, count), sl->rbuff, count);
207 skb->protocol = x25_type_trans(skb, sl->dev); 206 skb->protocol = x25_type_trans(skb, sl->dev);
208 if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK) 207 err = lapb_data_received(skb->dev, skb);
209 { 208 if (err != LAPB_OK) {
210 kfree_skb(skb); 209 kfree_skb(skb);
211 printk(KERN_DEBUG "x25_asy: data received err - %d\n",err); 210 printk(KERN_DEBUG "x25_asy: data received err - %d\n", err);
212 } 211 } else {
213 else
214 {
215 netif_rx(skb); 212 netif_rx(skb);
216 sl->dev->last_rx = jiffies; 213 sl->dev->last_rx = jiffies;
217 sl->stats.rx_packets++; 214 sl->stats.rx_packets++;
@@ -224,10 +221,11 @@ static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len)
224 unsigned char *p; 221 unsigned char *p;
225 int actual, count, mtu = sl->dev->mtu; 222 int actual, count, mtu = sl->dev->mtu;
226 223
227 if (len > mtu) 224 if (len > mtu) {
228 { /* Sigh, shouldn't occur BUT ... */ 225 /* Sigh, shouldn't occur BUT ... */
229 len = mtu; 226 len = mtu;
230 printk ("%s: truncating oversized transmit packet!\n", sl->dev->name); 227 printk(KERN_DEBUG "%s: truncating oversized transmit packet!\n",
228 sl->dev->name);
231 sl->stats.tx_dropped++; 229 sl->stats.tx_dropped++;
232 x25_asy_unlock(sl); 230 x25_asy_unlock(sl);
233 return; 231 return;
@@ -245,7 +243,7 @@ static void x25_asy_encaps(struct x25_asy *sl, unsigned char *icp, int len)
245 * 14 Oct 1994 Dmitry Gorodchanin. 243 * 14 Oct 1994 Dmitry Gorodchanin.
246 */ 244 */
247 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP); 245 sl->tty->flags |= (1 << TTY_DO_WRITE_WAKEUP);
248 actual = sl->tty->driver->write(sl->tty, sl->xbuff, count); 246 actual = sl->tty->ops->write(sl->tty, sl->xbuff, count);
249 sl->xleft = count - actual; 247 sl->xleft = count - actual;
250 sl->xhead = sl->xbuff + actual; 248 sl->xhead = sl->xbuff + actual;
251 /* VSV */ 249 /* VSV */
@@ -265,8 +263,7 @@ static void x25_asy_write_wakeup(struct tty_struct *tty)
265 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev)) 263 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))
266 return; 264 return;
267 265
268 if (sl->xleft <= 0) 266 if (sl->xleft <= 0) {
269 {
270 /* Now serial buffer is almost free & we can start 267 /* Now serial buffer is almost free & we can start
271 * transmission of another packet */ 268 * transmission of another packet */
272 sl->stats.tx_packets++; 269 sl->stats.tx_packets++;
@@ -275,14 +272,14 @@ static void x25_asy_write_wakeup(struct tty_struct *tty)
275 return; 272 return;
276 } 273 }
277 274
278 actual = tty->driver->write(tty, sl->xhead, sl->xleft); 275 actual = tty->ops->write(tty, sl->xhead, sl->xleft);
279 sl->xleft -= actual; 276 sl->xleft -= actual;
280 sl->xhead += actual; 277 sl->xhead += actual;
281} 278}
282 279
283static void x25_asy_timeout(struct net_device *dev) 280static void x25_asy_timeout(struct net_device *dev)
284{ 281{
285 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 282 struct x25_asy *sl = dev->priv;
286 283
287 spin_lock(&sl->lock); 284 spin_lock(&sl->lock);
288 if (netif_queue_stopped(dev)) { 285 if (netif_queue_stopped(dev)) {
@@ -290,7 +287,7 @@ static void x25_asy_timeout(struct net_device *dev)
290 * 14 Oct 1994 Dmitry Gorodchanin. 287 * 14 Oct 1994 Dmitry Gorodchanin.
291 */ 288 */
292 printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, 289 printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
293 (sl->tty->driver->chars_in_buffer(sl->tty) || sl->xleft) ? 290 (tty_chars_in_buffer(sl->tty) || sl->xleft) ?
294 "bad line quality" : "driver error"); 291 "bad line quality" : "driver error");
295 sl->xleft = 0; 292 sl->xleft = 0;
296 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); 293 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
@@ -303,31 +300,34 @@ static void x25_asy_timeout(struct net_device *dev)
303 300
304static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) 301static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
305{ 302{
306 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 303 struct x25_asy *sl = dev->priv;
307 int err; 304 int err;
308 305
309 if (!netif_running(sl->dev)) { 306 if (!netif_running(sl->dev)) {
310 printk("%s: xmit call when iface is down\n", dev->name); 307 printk(KERN_ERR "%s: xmit call when iface is down\n",
308 dev->name);
311 kfree_skb(skb); 309 kfree_skb(skb);
312 return 0; 310 return 0;
313 } 311 }
314 312
315 switch(skb->data[0]) 313 switch (skb->data[0]) {
316 { 314 case 0x00:
317 case 0x00:break; 315 break;
318 case 0x01: /* Connection request .. do nothing */ 316 case 0x01: /* Connection request .. do nothing */
319 if((err=lapb_connect_request(dev))!=LAPB_OK) 317 err = lapb_connect_request(dev);
320 printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); 318 if (err != LAPB_OK)
321 kfree_skb(skb); 319 printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err);
322 return 0; 320 kfree_skb(skb);
323 case 0x02: /* Disconnect request .. do nothing - hang up ?? */ 321 return 0;
324 if((err=lapb_disconnect_request(dev))!=LAPB_OK) 322 case 0x02: /* Disconnect request .. do nothing - hang up ?? */
325 printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); 323 err = lapb_disconnect_request(dev);
326 default: 324 if (err != LAPB_OK)
327 kfree_skb(skb); 325 printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err);
328 return 0; 326 default:
327 kfree_skb(skb);
328 return 0;
329 } 329 }
330 skb_pull(skb,1); /* Remove control byte */ 330 skb_pull(skb, 1); /* Remove control byte */
331 /* 331 /*
332 * If we are busy already- too bad. We ought to be able 332 * If we are busy already- too bad. We ought to be able
333 * to queue things at this point, to allow for a little 333 * to queue things at this point, to allow for a little
@@ -338,10 +338,10 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
338 * So, no queues ! 338 * So, no queues !
339 * 14 Oct 1994 Dmitry Gorodchanin. 339 * 14 Oct 1994 Dmitry Gorodchanin.
340 */ 340 */
341 341
342 if((err=lapb_data_request(dev,skb))!=LAPB_OK) 342 err = lapb_data_request(dev, skb);
343 { 343 if (err != LAPB_OK) {
344 printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); 344 printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err);
345 kfree_skb(skb); 345 kfree_skb(skb);
346 return 0; 346 return 0;
347 } 347 }
@@ -357,7 +357,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev)
357 * Called when I frame data arrives. We did the work above - throw it 357 * Called when I frame data arrives. We did the work above - throw it
358 * at the net layer. 358 * at the net layer.
359 */ 359 */
360 360
361static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) 361static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
362{ 362{
363 skb->dev->last_rx = jiffies; 363 skb->dev->last_rx = jiffies;
@@ -369,24 +369,22 @@ static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
369 * busy cases too well. Its tricky to see how to do this nicely - 369 * busy cases too well. Its tricky to see how to do this nicely -
370 * perhaps lapb should allow us to bounce this ? 370 * perhaps lapb should allow us to bounce this ?
371 */ 371 */
372 372
373static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) 373static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb)
374{ 374{
375 struct x25_asy *sl=dev->priv; 375 struct x25_asy *sl = dev->priv;
376 376
377 spin_lock(&sl->lock); 377 spin_lock(&sl->lock);
378 if (netif_queue_stopped(sl->dev) || sl->tty == NULL) 378 if (netif_queue_stopped(sl->dev) || sl->tty == NULL) {
379 {
380 spin_unlock(&sl->lock); 379 spin_unlock(&sl->lock);
381 printk(KERN_ERR "x25_asy: tbusy drop\n"); 380 printk(KERN_ERR "x25_asy: tbusy drop\n");
382 kfree_skb(skb); 381 kfree_skb(skb);
383 return; 382 return;
384 } 383 }
385 /* We were not busy, so we are now... :-) */ 384 /* We were not busy, so we are now... :-) */
386 if (skb != NULL) 385 if (skb != NULL) {
387 {
388 x25_asy_lock(sl); 386 x25_asy_lock(sl);
389 sl->stats.tx_bytes+=skb->len; 387 sl->stats.tx_bytes += skb->len;
390 x25_asy_encaps(sl, skb->data, skb->len); 388 x25_asy_encaps(sl, skb->data, skb->len);
391 dev_kfree_skb(skb); 389 dev_kfree_skb(skb);
392 } 390 }
@@ -396,15 +394,16 @@ static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb)
396/* 394/*
397 * LAPB connection establish/down information. 395 * LAPB connection establish/down information.
398 */ 396 */
399 397
400static void x25_asy_connected(struct net_device *dev, int reason) 398static void x25_asy_connected(struct net_device *dev, int reason)
401{ 399{
402 struct x25_asy *sl = dev->priv; 400 struct x25_asy *sl = dev->priv;
403 struct sk_buff *skb; 401 struct sk_buff *skb;
404 unsigned char *ptr; 402 unsigned char *ptr;
405 403
406 if ((skb = dev_alloc_skb(1)) == NULL) { 404 skb = dev_alloc_skb(1);
407 printk(KERN_ERR "lapbeth: out of memory\n"); 405 if (skb == NULL) {
406 printk(KERN_ERR "x25_asy: out of memory\n");
408 return; 407 return;
409 } 408 }
410 409
@@ -422,7 +421,8 @@ static void x25_asy_disconnected(struct net_device *dev, int reason)
422 struct sk_buff *skb; 421 struct sk_buff *skb;
423 unsigned char *ptr; 422 unsigned char *ptr;
424 423
425 if ((skb = dev_alloc_skb(1)) == NULL) { 424 skb = dev_alloc_skb(1);
425 if (skb == NULL) {
426 printk(KERN_ERR "x25_asy: out of memory\n"); 426 printk(KERN_ERR "x25_asy: out of memory\n");
427 return; 427 return;
428 } 428 }
@@ -449,7 +449,7 @@ static struct lapb_register_struct x25_asy_callbacks = {
449/* Open the low-level part of the X.25 channel. Easy! */ 449/* Open the low-level part of the X.25 channel. Easy! */
450static int x25_asy_open(struct net_device *dev) 450static int x25_asy_open(struct net_device *dev)
451{ 451{
452 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 452 struct x25_asy *sl = dev->priv;
453 unsigned long len; 453 unsigned long len;
454 int err; 454 int err;
455 455
@@ -466,13 +466,11 @@ static int x25_asy_open(struct net_device *dev)
466 len = dev->mtu * 2; 466 len = dev->mtu * 2;
467 467
468 sl->rbuff = kmalloc(len + 4, GFP_KERNEL); 468 sl->rbuff = kmalloc(len + 4, GFP_KERNEL);
469 if (sl->rbuff == NULL) { 469 if (sl->rbuff == NULL)
470 goto norbuff; 470 goto norbuff;
471 }
472 sl->xbuff = kmalloc(len + 4, GFP_KERNEL); 471 sl->xbuff = kmalloc(len + 4, GFP_KERNEL);
473 if (sl->xbuff == NULL) { 472 if (sl->xbuff == NULL)
474 goto noxbuff; 473 goto noxbuff;
475 }
476 474
477 sl->buffsize = len; 475 sl->buffsize = len;
478 sl->rcount = 0; 476 sl->rcount = 0;
@@ -480,11 +478,12 @@ static int x25_asy_open(struct net_device *dev)
480 sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */ 478 sl->flags &= (1 << SLF_INUSE); /* Clear ESCAPE & ERROR flags */
481 479
482 netif_start_queue(dev); 480 netif_start_queue(dev);
483 481
484 /* 482 /*
485 * Now attach LAPB 483 * Now attach LAPB
486 */ 484 */
487 if((err=lapb_register(dev, &x25_asy_callbacks))==LAPB_OK) 485 err = lapb_register(dev, &x25_asy_callbacks);
486 if (err == LAPB_OK)
488 return 0; 487 return 0;
489 488
490 /* Cleanup */ 489 /* Cleanup */
@@ -499,18 +498,20 @@ norbuff:
499/* Close the low-level part of the X.25 channel. Easy! */ 498/* Close the low-level part of the X.25 channel. Easy! */
500static int x25_asy_close(struct net_device *dev) 499static int x25_asy_close(struct net_device *dev)
501{ 500{
502 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 501 struct x25_asy *sl = dev->priv;
503 int err; 502 int err;
504 503
505 spin_lock(&sl->lock); 504 spin_lock(&sl->lock);
506 if (sl->tty) 505 if (sl->tty)
507 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP); 506 sl->tty->flags &= ~(1 << TTY_DO_WRITE_WAKEUP);
508 507
509 netif_stop_queue(dev); 508 netif_stop_queue(dev);
510 sl->rcount = 0; 509 sl->rcount = 0;
511 sl->xleft = 0; 510 sl->xleft = 0;
512 if((err=lapb_unregister(dev))!=LAPB_OK) 511 err = lapb_unregister(dev);
513 printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",err); 512 if (err != LAPB_OK)
513 printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",
514 err);
514 spin_unlock(&sl->lock); 515 spin_unlock(&sl->lock);
515 return 0; 516 return 0;
516} 517}
@@ -521,8 +522,9 @@ static int x25_asy_close(struct net_device *dev)
521 * a block of X.25 data has been received, which can now be decapsulated 522 * a block of X.25 data has been received, which can now be decapsulated
522 * and sent on to some IP layer for further processing. 523 * and sent on to some IP layer for further processing.
523 */ 524 */
524 525
525static void x25_asy_receive_buf(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) 526static void x25_asy_receive_buf(struct tty_struct *tty,
527 const unsigned char *cp, char *fp, int count)
526{ 528{
527 struct x25_asy *sl = (struct x25_asy *) tty->disc_data; 529 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
528 530
@@ -533,9 +535,8 @@ static void x25_asy_receive_buf(struct tty_struct *tty, const unsigned char *cp,
533 /* Read the characters out of the buffer */ 535 /* Read the characters out of the buffer */
534 while (count--) { 536 while (count--) {
535 if (fp && *fp++) { 537 if (fp && *fp++) {
536 if (!test_and_set_bit(SLF_ERROR, &sl->flags)) { 538 if (!test_and_set_bit(SLF_ERROR, &sl->flags))
537 sl->stats.rx_errors++; 539 sl->stats.rx_errors++;
538 }
539 cp++; 540 cp++;
540 continue; 541 continue;
541 } 542 }
@@ -556,31 +557,31 @@ static int x25_asy_open_tty(struct tty_struct *tty)
556 struct x25_asy *sl = (struct x25_asy *) tty->disc_data; 557 struct x25_asy *sl = (struct x25_asy *) tty->disc_data;
557 int err; 558 int err;
558 559
560 if (tty->ops->write == NULL)
561 return -EOPNOTSUPP;
562
559 /* First make sure we're not already connected. */ 563 /* First make sure we're not already connected. */
560 if (sl && sl->magic == X25_ASY_MAGIC) { 564 if (sl && sl->magic == X25_ASY_MAGIC)
561 return -EEXIST; 565 return -EEXIST;
562 }
563 566
564 /* OK. Find a free X.25 channel to use. */ 567 /* OK. Find a free X.25 channel to use. */
565 if ((sl = x25_asy_alloc()) == NULL) { 568 sl = x25_asy_alloc();
569 if (sl == NULL)
566 return -ENFILE; 570 return -ENFILE;
567 }
568 571
569 sl->tty = tty; 572 sl->tty = tty;
570 tty->disc_data = sl; 573 tty->disc_data = sl;
571 tty->receive_room = 65536; 574 tty->receive_room = 65536;
572 if (tty->driver->flush_buffer) { 575 tty_driver_flush_buffer(tty);
573 tty->driver->flush_buffer(tty);
574 }
575 tty_ldisc_flush(tty); 576 tty_ldisc_flush(tty);
576 577
577 /* Restore default settings */ 578 /* Restore default settings */
578 sl->dev->type = ARPHRD_X25; 579 sl->dev->type = ARPHRD_X25;
579 580
580 /* Perform the low-level X.25 async init */ 581 /* Perform the low-level X.25 async init */
581 if ((err = x25_asy_open(sl->dev))) 582 err = x25_asy_open(sl->dev);
583 if (err)
582 return err; 584 return err;
583
584 /* Done. We have linked the TTY line to a channel. */ 585 /* Done. We have linked the TTY line to a channel. */
585 return sl->dev->base_addr; 586 return sl->dev->base_addr;
586} 587}
@@ -601,9 +602,7 @@ static void x25_asy_close_tty(struct tty_struct *tty)
601 return; 602 return;
602 603
603 if (sl->dev->flags & IFF_UP) 604 if (sl->dev->flags & IFF_UP)
604 { 605 dev_close(sl->dev);
605 (void) dev_close(sl->dev);
606 }
607 606
608 tty->disc_data = NULL; 607 tty->disc_data = NULL;
609 sl->tty = NULL; 608 sl->tty = NULL;
@@ -613,8 +612,7 @@ static void x25_asy_close_tty(struct tty_struct *tty)
613 612
614static struct net_device_stats *x25_asy_get_stats(struct net_device *dev) 613static struct net_device_stats *x25_asy_get_stats(struct net_device *dev)
615{ 614{
616 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 615 struct x25_asy *sl = dev->priv;
617
618 return &sl->stats; 616 return &sl->stats;
619} 617}
620 618
@@ -641,21 +639,19 @@ int x25_asy_esc(unsigned char *s, unsigned char *d, int len)
641 * character sequence, according to the X.25 protocol. 639 * character sequence, according to the X.25 protocol.
642 */ 640 */
643 641
644 while (len-- > 0) 642 while (len-- > 0) {
645 { 643 switch (c = *s++) {
646 switch(c = *s++) 644 case X25_END:
647 { 645 *ptr++ = X25_ESC;
648 case X25_END: 646 *ptr++ = X25_ESCAPE(X25_END);
649 *ptr++ = X25_ESC; 647 break;
650 *ptr++ = X25_ESCAPE(X25_END); 648 case X25_ESC:
651 break; 649 *ptr++ = X25_ESC;
652 case X25_ESC: 650 *ptr++ = X25_ESCAPE(X25_ESC);
653 *ptr++ = X25_ESC; 651 break;
654 *ptr++ = X25_ESCAPE(X25_ESC); 652 default:
655 break; 653 *ptr++ = c;
656 default: 654 break;
657 *ptr++ = c;
658 break;
659 } 655 }
660 } 656 }
661 *ptr++ = X25_END; 657 *ptr++ = X25_END;
@@ -665,31 +661,25 @@ int x25_asy_esc(unsigned char *s, unsigned char *d, int len)
665static void x25_asy_unesc(struct x25_asy *sl, unsigned char s) 661static void x25_asy_unesc(struct x25_asy *sl, unsigned char s)
666{ 662{
667 663
668 switch(s) 664 switch (s) {
669 { 665 case X25_END:
670 case X25_END: 666 if (!test_and_clear_bit(SLF_ERROR, &sl->flags)
671 if (!test_and_clear_bit(SLF_ERROR, &sl->flags) && (sl->rcount > 2)) 667 && sl->rcount > 2)
672 { 668 x25_asy_bump(sl);
673 x25_asy_bump(sl); 669 clear_bit(SLF_ESCAPE, &sl->flags);
674 } 670 sl->rcount = 0;
675 clear_bit(SLF_ESCAPE, &sl->flags); 671 return;
676 sl->rcount = 0; 672 case X25_ESC:
677 return; 673 set_bit(SLF_ESCAPE, &sl->flags);
678 674 return;
679 case X25_ESC: 675 case X25_ESCAPE(X25_ESC):
680 set_bit(SLF_ESCAPE, &sl->flags); 676 case X25_ESCAPE(X25_END):
681 return; 677 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags))
682 678 s = X25_UNESCAPE(s);
683 case X25_ESCAPE(X25_ESC): 679 break;
684 case X25_ESCAPE(X25_END): 680 }
685 if (test_and_clear_bit(SLF_ESCAPE, &sl->flags)) 681 if (!test_bit(SLF_ERROR, &sl->flags)) {
686 s = X25_UNESCAPE(s); 682 if (sl->rcount < sl->buffsize) {
687 break;
688 }
689 if (!test_bit(SLF_ERROR, &sl->flags))
690 {
691 if (sl->rcount < sl->buffsize)
692 {
693 sl->rbuff[sl->rcount++] = s; 683 sl->rbuff[sl->rcount++] = s;
694 return; 684 return;
695 } 685 }
@@ -709,7 +699,7 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
709 if (!sl || sl->magic != X25_ASY_MAGIC) 699 if (!sl || sl->magic != X25_ASY_MAGIC)
710 return -EINVAL; 700 return -EINVAL;
711 701
712 switch(cmd) { 702 switch (cmd) {
713 case SIOCGIFNAME: 703 case SIOCGIFNAME:
714 if (copy_to_user((void __user *)arg, sl->dev->name, 704 if (copy_to_user((void __user *)arg, sl->dev->name,
715 strlen(sl->dev->name) + 1)) 705 strlen(sl->dev->name) + 1))
@@ -724,8 +714,8 @@ static int x25_asy_ioctl(struct tty_struct *tty, struct file *file,
724 714
725static int x25_asy_open_dev(struct net_device *dev) 715static int x25_asy_open_dev(struct net_device *dev)
726{ 716{
727 struct x25_asy *sl = (struct x25_asy*)(dev->priv); 717 struct x25_asy *sl = dev->priv;
728 if(sl->tty==NULL) 718 if (sl->tty == NULL)
729 return -ENODEV; 719 return -ENODEV;
730 return 0; 720 return 0;
731} 721}
@@ -741,9 +731,9 @@ static void x25_asy_setup(struct net_device *dev)
741 set_bit(SLF_INUSE, &sl->flags); 731 set_bit(SLF_INUSE, &sl->flags);
742 732
743 /* 733 /*
744 * Finish setting up the DEVICE info. 734 * Finish setting up the DEVICE info.
745 */ 735 */
746 736
747 dev->mtu = SL_MTU; 737 dev->mtu = SL_MTU;
748 dev->hard_start_xmit = x25_asy_xmit; 738 dev->hard_start_xmit = x25_asy_xmit;
749 dev->tx_timeout = x25_asy_timeout; 739 dev->tx_timeout = x25_asy_timeout;
@@ -778,9 +768,10 @@ static int __init init_x25_asy(void)
778 x25_asy_maxdev = 4; /* Sanity */ 768 x25_asy_maxdev = 4; /* Sanity */
779 769
780 printk(KERN_INFO "X.25 async: version 0.00 ALPHA " 770 printk(KERN_INFO "X.25 async: version 0.00 ALPHA "
781 "(dynamic channels, max=%d).\n", x25_asy_maxdev ); 771 "(dynamic channels, max=%d).\n", x25_asy_maxdev);
782 772
783 x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device*), GFP_KERNEL); 773 x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device *),
774 GFP_KERNEL);
784 if (!x25_asy_devs) { 775 if (!x25_asy_devs) {
785 printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " 776 printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] "
786 "array! Uaargh! (-> No X.25 available)\n"); 777 "array! Uaargh! (-> No X.25 available)\n");
@@ -802,7 +793,7 @@ static void __exit exit_x25_asy(void)
802 struct x25_asy *sl = dev->priv; 793 struct x25_asy *sl = dev->priv;
803 794
804 spin_lock_bh(&sl->lock); 795 spin_lock_bh(&sl->lock);
805 if (sl->tty) 796 if (sl->tty)
806 tty_hangup(sl->tty); 797 tty_hangup(sl->tty);
807 798
808 spin_unlock_bh(&sl->lock); 799 spin_unlock_bh(&sl->lock);
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index 9a25f550fd16..d5b7a76fcaad 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -6,6 +6,10 @@ config IWLCORE
6 tristate "Intel Wireless Wifi Core" 6 tristate "Intel Wireless Wifi Core"
7 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 7 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
8 select IWLWIFI 8 select IWLWIFI
9 select MAC80211_LEDS if IWLWIFI_LEDS
10 select LEDS_CLASS if IWLWIFI_LEDS
11 select RFKILL if IWLWIFI_RFKILL
12 select RFKILL_INPUT if IWLWIFI_RFKILL
9 13
10config IWLWIFI_LEDS 14config IWLWIFI_LEDS
11 bool 15 bool
@@ -14,8 +18,6 @@ config IWLWIFI_LEDS
14config IWLWIFI_RFKILL 18config IWLWIFI_RFKILL
15 boolean "IWLWIFI RF kill support" 19 boolean "IWLWIFI RF kill support"
16 depends on IWLCORE 20 depends on IWLCORE
17 select RFKILL
18 select RFKILL_INPUT
19 21
20config IWL4965 22config IWL4965
21 tristate "Intel Wireless WiFi 4965AGN" 23 tristate "Intel Wireless WiFi 4965AGN"
@@ -55,8 +57,6 @@ config IWL4965_HT
55config IWL4965_LEDS 57config IWL4965_LEDS
56 bool "Enable LEDS features in iwl4965 driver" 58 bool "Enable LEDS features in iwl4965 driver"
57 depends on IWL4965 59 depends on IWL4965
58 select MAC80211_LEDS
59 select LEDS_CLASS
60 select IWLWIFI_LEDS 60 select IWLWIFI_LEDS
61 ---help--- 61 ---help---
62 This option enables LEDS for the iwlwifi drivers 62 This option enables LEDS for the iwlwifi drivers
@@ -112,6 +112,8 @@ config IWL3945
112 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 112 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL
113 select FW_LOADER 113 select FW_LOADER
114 select IWLWIFI 114 select IWLWIFI
115 select MAC80211_LEDS if IWL3945_LEDS
116 select LEDS_CLASS if IWL3945_LEDS
115 ---help--- 117 ---help---
116 Select to build the driver supporting the: 118 Select to build the driver supporting the:
117 119
@@ -143,8 +145,6 @@ config IWL3945_SPECTRUM_MEASUREMENT
143config IWL3945_LEDS 145config IWL3945_LEDS
144 bool "Enable LEDS features in iwl3945 driver" 146 bool "Enable LEDS features in iwl3945 driver"
145 depends on IWL3945 147 depends on IWL3945
146 select MAC80211_LEDS
147 select LEDS_CLASS
148 ---help--- 148 ---help---
149 This option enables LEDS for the iwl3945 driver. 149 This option enables LEDS for the iwl3945 driver.
150 150
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index bced3fe1cf8a..5dd23c93497d 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -768,41 +768,17 @@ static __u8 *UnStuffData(__u8 * src, __u8 * end, __u8 * dst,
768/* General routines for STRIP */ 768/* General routines for STRIP */
769 769
770/* 770/*
771 * get_baud returns the current baud rate, as one of the constants defined in
772 * termbits.h
773 * If the user has issued a baud rate override using the 'setserial' command
774 * and the logical current rate is set to 38.4, then the true baud rate
775 * currently in effect (57.6 or 115.2) is returned.
776 */
777static unsigned int get_baud(struct tty_struct *tty)
778{
779 if (!tty || !tty->termios)
780 return (0);
781 if ((tty->termios->c_cflag & CBAUD) == B38400 && tty->driver_data) {
782 struct async_struct *info =
783 (struct async_struct *) tty->driver_data;
784 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
785 return (B57600);
786 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
787 return (B115200);
788 }
789 return (tty->termios->c_cflag & CBAUD);
790}
791
792/*
793 * set_baud sets the baud rate to the rate defined by baudcode 771 * set_baud sets the baud rate to the rate defined by baudcode
794 * Note: The rate B38400 should be avoided, because the user may have
795 * issued a 'setserial' speed override to map that to a different speed.
796 * We could achieve a true rate of 38400 if we needed to by cancelling
797 * any user speed override that is in place, but that might annoy the
798 * user, so it is simplest to just avoid using 38400.
799 */ 772 */
800static void set_baud(struct tty_struct *tty, unsigned int baudcode) 773static void set_baud(struct tty_struct *tty, speed_t baudrate)
801{ 774{
802 struct ktermios old_termios = *(tty->termios); 775 struct ktermios old_termios;
803 tty->termios->c_cflag &= ~CBAUD; /* Clear the old baud setting */ 776
804 tty->termios->c_cflag |= baudcode; /* Set the new baud setting */ 777 mutex_lock(&tty->termios_mutex);
805 tty->driver->set_termios(tty, &old_termios); 778 old_termios =*(tty->termios);
779 tty_encode_baud_rate(tty, baudrate, baudrate);
780 tty->ops->set_termios(tty, &old_termios);
781 mutex_unlock(&tty->termios_mutex);
806} 782}
807 783
808/* 784/*
@@ -1217,7 +1193,7 @@ static void ResetRadio(struct strip *strip_info)
1217 strip_info->watchdog_doreset = jiffies + 1 * HZ; 1193 strip_info->watchdog_doreset = jiffies + 1 * HZ;
1218 1194
1219 /* If the user has selected a baud rate above 38.4 see what magic we have to do */ 1195 /* If the user has selected a baud rate above 38.4 see what magic we have to do */
1220 if (strip_info->user_baud > B38400) { 1196 if (strip_info->user_baud > 38400) {
1221 /* 1197 /*
1222 * Subtle stuff: Pay attention :-) 1198 * Subtle stuff: Pay attention :-)
1223 * If the serial port is currently at the user's selected (>38.4) rate, 1199 * If the serial port is currently at the user's selected (>38.4) rate,
@@ -1227,17 +1203,17 @@ static void ResetRadio(struct strip *strip_info)
1227 * issued the ATS304 command last time through, so this time we restore 1203 * issued the ATS304 command last time through, so this time we restore
1228 * the user's selected rate and issue the normal starmode reset string. 1204 * the user's selected rate and issue the normal starmode reset string.
1229 */ 1205 */
1230 if (strip_info->user_baud == get_baud(tty)) { 1206 if (strip_info->user_baud == tty_get_baud_rate(tty)) {
1231 static const char b0[] = "ate0q1s304=57600\r"; 1207 static const char b0[] = "ate0q1s304=57600\r";
1232 static const char b1[] = "ate0q1s304=115200\r"; 1208 static const char b1[] = "ate0q1s304=115200\r";
1233 static const StringDescriptor baudstring[2] = 1209 static const StringDescriptor baudstring[2] =
1234 { {b0, sizeof(b0) - 1} 1210 { {b0, sizeof(b0) - 1}
1235 , {b1, sizeof(b1) - 1} 1211 , {b1, sizeof(b1) - 1}
1236 }; 1212 };
1237 set_baud(tty, B19200); 1213 set_baud(tty, 19200);
1238 if (strip_info->user_baud == B57600) 1214 if (strip_info->user_baud == 57600)
1239 s = baudstring[0]; 1215 s = baudstring[0];
1240 else if (strip_info->user_baud == B115200) 1216 else if (strip_info->user_baud == 115200)
1241 s = baudstring[1]; 1217 s = baudstring[1];
1242 else 1218 else
1243 s = baudstring[1]; /* For now */ 1219 s = baudstring[1]; /* For now */
@@ -1245,7 +1221,7 @@ static void ResetRadio(struct strip *strip_info)
1245 set_baud(tty, strip_info->user_baud); 1221 set_baud(tty, strip_info->user_baud);
1246 } 1222 }
1247 1223
1248 tty->driver->write(tty, s.string, s.length); 1224 tty->ops->write(tty, s.string, s.length);
1249#ifdef EXT_COUNTERS 1225#ifdef EXT_COUNTERS
1250 strip_info->tx_ebytes += s.length; 1226 strip_info->tx_ebytes += s.length;
1251#endif 1227#endif
@@ -1267,7 +1243,7 @@ static void strip_write_some_more(struct tty_struct *tty)
1267 1243
1268 if (strip_info->tx_left > 0) { 1244 if (strip_info->tx_left > 0) {
1269 int num_written = 1245 int num_written =
1270 tty->driver->write(tty, strip_info->tx_head, 1246 tty->ops->write(tty, strip_info->tx_head,
1271 strip_info->tx_left); 1247 strip_info->tx_left);
1272 strip_info->tx_left -= num_written; 1248 strip_info->tx_left -= num_written;
1273 strip_info->tx_head += num_written; 1249 strip_info->tx_head += num_written;
@@ -2457,7 +2433,7 @@ static int strip_open_low(struct net_device *dev)
2457 strip_info->working = FALSE; 2433 strip_info->working = FALSE;
2458 strip_info->firmware_level = NoStructure; 2434 strip_info->firmware_level = NoStructure;
2459 strip_info->next_command = CompatibilityCommand; 2435 strip_info->next_command = CompatibilityCommand;
2460 strip_info->user_baud = get_baud(strip_info->tty); 2436 strip_info->user_baud = tty_get_baud_rate(strip_info->tty);
2461 2437
2462 printk(KERN_INFO "%s: Initializing Radio.\n", 2438 printk(KERN_INFO "%s: Initializing Radio.\n",
2463 strip_info->dev->name); 2439 strip_info->dev->name);
@@ -2632,6 +2608,13 @@ static int strip_open(struct tty_struct *tty)
2632 return -EEXIST; 2608 return -EEXIST;
2633 2609
2634 /* 2610 /*
2611 * We need a write method.
2612 */
2613
2614 if (tty->ops->write == NULL)
2615 return -EOPNOTSUPP;
2616
2617 /*
2635 * OK. Find a free STRIP channel to use. 2618 * OK. Find a free STRIP channel to use.
2636 */ 2619 */
2637 if ((strip_info = strip_alloc()) == NULL) 2620 if ((strip_info = strip_alloc()) == NULL)
@@ -2652,8 +2635,7 @@ static int strip_open(struct tty_struct *tty)
2652 tty->disc_data = strip_info; 2635 tty->disc_data = strip_info;
2653 tty->receive_room = 65536; 2636 tty->receive_room = 65536;
2654 2637
2655 if (tty->driver->flush_buffer) 2638 tty_driver_flush_buffer(tty);
2656 tty->driver->flush_buffer(tty);
2657 2639
2658 /* 2640 /*
2659 * Restore default settings 2641 * Restore default settings
diff --git a/drivers/parport/ieee1284.c b/drivers/parport/ieee1284.c
index 54a6ef72906e..0338b0912674 100644
--- a/drivers/parport/ieee1284.c
+++ b/drivers/parport/ieee1284.c
@@ -76,7 +76,7 @@ int parport_wait_event (struct parport *port, signed long timeout)
76 semaphore. */ 76 semaphore. */
77 return 1; 77 return 1;
78 78
79 init_timer (&timer); 79 init_timer_on_stack(&timer);
80 timer.expires = jiffies + timeout; 80 timer.expires = jiffies + timeout;
81 timer.function = timeout_waiting_on_port; 81 timer.function = timeout_waiting_on_port;
82 port_from_cookie[port->number % PARPORT_MAX] = port; 82 port_from_cookie[port->number % PARPORT_MAX] = port;
@@ -88,6 +88,8 @@ int parport_wait_event (struct parport *port, signed long timeout)
88 /* Timed out. */ 88 /* Timed out. */
89 ret = 1; 89 ret = 1;
90 90
91 destroy_timer_on_stack(&timer);
92
91 return ret; 93 return ret;
92} 94}
93 95
diff --git a/drivers/parport/parport_gsc.c b/drivers/parport/parport_gsc.c
index 0e77ae2b71a0..e6a7e847ee80 100644
--- a/drivers/parport/parport_gsc.c
+++ b/drivers/parport/parport_gsc.c
@@ -365,11 +365,11 @@ static int __devinit parport_init_chip(struct parisc_device *dev)
365 if (boot_cpu_data.cpu_type > pcxt && !pdc_add_valid(port+4)) { 365 if (boot_cpu_data.cpu_type > pcxt && !pdc_add_valid(port+4)) {
366 366
367 /* Initialize bidirectional-mode (0x10) & data-tranfer-mode #1 (0x20) */ 367 /* Initialize bidirectional-mode (0x10) & data-tranfer-mode #1 (0x20) */
368 printk("%s: initialize bidirectional-mode.\n", __FUNCTION__); 368 printk("%s: initialize bidirectional-mode.\n", __func__);
369 parport_writeb ( (0x10 + 0x20), port + 4); 369 parport_writeb ( (0x10 + 0x20), port + 4);
370 370
371 } else { 371 } else {
372 printk("%s: enhanced parport-modes not supported.\n", __FUNCTION__); 372 printk("%s: enhanced parport-modes not supported.\n", __func__);
373 } 373 }
374 374
375 p = parport_gsc_probe_port(port, 0, dev->irq, 375 p = parport_gsc_probe_port(port, 0, dev->irq,
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index e71092e80288..e0c2a4584ec6 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1415,7 +1415,7 @@ static void __devinit winbond_check(int io, int key)
1415{ 1415{
1416 int devid,devrev,oldid,x_devid,x_devrev,x_oldid; 1416 int devid,devrev,oldid,x_devid,x_devrev,x_oldid;
1417 1417
1418 if (!request_region(io, 3, __FUNCTION__)) 1418 if (!request_region(io, 3, __func__))
1419 return; 1419 return;
1420 1420
1421 /* First probe without key */ 1421 /* First probe without key */
@@ -1449,7 +1449,7 @@ static void __devinit winbond_check2(int io,int key)
1449{ 1449{
1450 int devid,devrev,oldid,x_devid,x_devrev,x_oldid; 1450 int devid,devrev,oldid,x_devid,x_devrev,x_oldid;
1451 1451
1452 if (!request_region(io, 3, __FUNCTION__)) 1452 if (!request_region(io, 3, __func__))
1453 return; 1453 return;
1454 1454
1455 /* First probe without the key */ 1455 /* First probe without the key */
@@ -1482,7 +1482,7 @@ static void __devinit smsc_check(int io, int key)
1482{ 1482{
1483 int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev; 1483 int id,rev,oldid,oldrev,x_id,x_rev,x_oldid,x_oldrev;
1484 1484
1485 if (!request_region(io, 3, __FUNCTION__)) 1485 if (!request_region(io, 3, __func__))
1486 return; 1486 return;
1487 1487
1488 /* First probe without the key */ 1488 /* First probe without the key */
@@ -1547,7 +1547,7 @@ static void __devinit detect_and_report_it87(void)
1547 u8 r; 1547 u8 r;
1548 if (verbose_probing) 1548 if (verbose_probing)
1549 printk(KERN_DEBUG "IT8705 Super-IO detection, now testing port 2E ...\n"); 1549 printk(KERN_DEBUG "IT8705 Super-IO detection, now testing port 2E ...\n");
1550 if (!request_region(0x2e, 1, __FUNCTION__)) 1550 if (!request_region(0x2e, 1, __func__))
1551 return; 1551 return;
1552 outb(0x87, 0x2e); 1552 outb(0x87, 0x2e);
1553 outb(0x01, 0x2e); 1553 outb(0x01, 0x2e);
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 0e1f35c9ed9d..3e5653c92f4b 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -982,15 +982,16 @@ tty3215_write(struct tty_struct * tty,
982/* 982/*
983 * Put character routine for 3215 ttys 983 * Put character routine for 3215 ttys
984 */ 984 */
985static void 985static int
986tty3215_put_char(struct tty_struct *tty, unsigned char ch) 986tty3215_put_char(struct tty_struct *tty, unsigned char ch)
987{ 987{
988 struct raw3215_info *raw; 988 struct raw3215_info *raw;
989 989
990 if (!tty) 990 if (!tty)
991 return; 991 return 0;
992 raw = (struct raw3215_info *) tty->driver_data; 992 raw = (struct raw3215_info *) tty->driver_data;
993 raw3215_putchar(raw, ch); 993 raw3215_putchar(raw, ch);
994 return 1;
994} 995}
995 996
996static void 997static void
diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c
index b8f35bc52b7b..9e784d5f7f57 100644
--- a/drivers/s390/char/sclp_config.c
+++ b/drivers/s390/char/sclp_config.c
@@ -10,6 +10,7 @@
10#include <linux/cpu.h> 10#include <linux/cpu.h>
11#include <linux/sysdev.h> 11#include <linux/sysdev.h>
12#include <linux/workqueue.h> 12#include <linux/workqueue.h>
13#include <asm/smp.h>
13#include "sclp.h" 14#include "sclp.h"
14 15
15#define TAG "sclp_config: " 16#define TAG "sclp_config: "
@@ -19,9 +20,11 @@ struct conf_mgm_data {
19 u8 ev_qualifier; 20 u8 ev_qualifier;
20} __attribute__((packed)); 21} __attribute__((packed));
21 22
23#define EV_QUAL_CPU_CHANGE 1
22#define EV_QUAL_CAP_CHANGE 3 24#define EV_QUAL_CAP_CHANGE 3
23 25
24static struct work_struct sclp_cpu_capability_work; 26static struct work_struct sclp_cpu_capability_work;
27static struct work_struct sclp_cpu_change_work;
25 28
26static void sclp_cpu_capability_notify(struct work_struct *work) 29static void sclp_cpu_capability_notify(struct work_struct *work)
27{ 30{
@@ -37,13 +40,24 @@ static void sclp_cpu_capability_notify(struct work_struct *work)
37 put_online_cpus(); 40 put_online_cpus();
38} 41}
39 42
43static void sclp_cpu_change_notify(struct work_struct *work)
44{
45 smp_rescan_cpus();
46}
47
40static void sclp_conf_receiver_fn(struct evbuf_header *evbuf) 48static void sclp_conf_receiver_fn(struct evbuf_header *evbuf)
41{ 49{
42 struct conf_mgm_data *cdata; 50 struct conf_mgm_data *cdata;
43 51
44 cdata = (struct conf_mgm_data *)(evbuf + 1); 52 cdata = (struct conf_mgm_data *)(evbuf + 1);
45 if (cdata->ev_qualifier == EV_QUAL_CAP_CHANGE) 53 switch (cdata->ev_qualifier) {
54 case EV_QUAL_CPU_CHANGE:
55 schedule_work(&sclp_cpu_change_work);
56 break;
57 case EV_QUAL_CAP_CHANGE:
46 schedule_work(&sclp_cpu_capability_work); 58 schedule_work(&sclp_cpu_capability_work);
59 break;
60 }
47} 61}
48 62
49static struct sclp_register sclp_conf_register = 63static struct sclp_register sclp_conf_register =
@@ -57,6 +71,7 @@ static int __init sclp_conf_init(void)
57 int rc; 71 int rc;
58 72
59 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify); 73 INIT_WORK(&sclp_cpu_capability_work, sclp_cpu_capability_notify);
74 INIT_WORK(&sclp_cpu_change_work, sclp_cpu_change_notify);
60 75
61 rc = sclp_register(&sclp_conf_register); 76 rc = sclp_register(&sclp_conf_register);
62 if (rc) { 77 if (rc) {
diff --git a/drivers/s390/char/sclp_tty.c b/drivers/s390/char/sclp_tty.c
index e3b3d390b4a3..40b11521cd20 100644
--- a/drivers/s390/char/sclp_tty.c
+++ b/drivers/s390/char/sclp_tty.c
@@ -412,14 +412,14 @@ sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
412 * - including previous characters from sclp_tty_put_char() and strings from 412 * - including previous characters from sclp_tty_put_char() and strings from
413 * sclp_write() without final '\n' - will be written. 413 * sclp_write() without final '\n' - will be written.
414 */ 414 */
415static void 415static int
416sclp_tty_put_char(struct tty_struct *tty, unsigned char ch) 416sclp_tty_put_char(struct tty_struct *tty, unsigned char ch)
417{ 417{
418 sclp_tty_chars[sclp_tty_chars_count++] = ch; 418 sclp_tty_chars[sclp_tty_chars_count++] = ch;
419 if (ch == '\n' || sclp_tty_chars_count >= SCLP_TTY_BUF_SIZE) { 419 if (ch == '\n' || sclp_tty_chars_count >= SCLP_TTY_BUF_SIZE) {
420 sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count); 420 sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count);
421 sclp_tty_chars_count = 0; 421 sclp_tty_chars_count = 0;
422 } 422 } return 1;
423} 423}
424 424
425/* 425/*
diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
index ed507594e62b..35707c04e613 100644
--- a/drivers/s390/char/sclp_vt220.c
+++ b/drivers/s390/char/sclp_vt220.c
@@ -524,11 +524,15 @@ sclp_vt220_close(struct tty_struct *tty, struct file *filp)
524 * NOTE: include/linux/tty_driver.h specifies that a character should be 524 * NOTE: include/linux/tty_driver.h specifies that a character should be
525 * ignored if there is no room in the queue. This driver implements a different 525 * ignored if there is no room in the queue. This driver implements a different
526 * semantic in that it will block when there is no more room left. 526 * semantic in that it will block when there is no more room left.
527 *
528 * FIXME: putchar can currently be called from BH and other non blocking
529 * handlers so this semantic isn't a good idea.
527 */ 530 */
528static void 531static int
529sclp_vt220_put_char(struct tty_struct *tty, unsigned char ch) 532sclp_vt220_put_char(struct tty_struct *tty, unsigned char ch)
530{ 533{
531 __sclp_vt220_write(&ch, 1, 0, 0, 1); 534 __sclp_vt220_write(&ch, 1, 0, 0, 1);
535 return 1;
532} 536}
533 537
534/* 538/*
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 70b1980a08b6..c1f2adefad41 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -965,7 +965,7 @@ tty3270_write_room(struct tty_struct *tty)
965 * Insert character into the screen at the current position with the 965 * Insert character into the screen at the current position with the
966 * current color and highlight. This function does NOT do cursor movement. 966 * current color and highlight. This function does NOT do cursor movement.
967 */ 967 */
968static void 968static int
969tty3270_put_character(struct tty3270 *tp, char ch) 969tty3270_put_character(struct tty3270 *tp, char ch)
970{ 970{
971 struct tty3270_line *line; 971 struct tty3270_line *line;
@@ -986,6 +986,7 @@ tty3270_put_character(struct tty3270 *tp, char ch)
986 cell->character = tp->view.ascebc[(unsigned int) ch]; 986 cell->character = tp->view.ascebc[(unsigned int) ch];
987 cell->highlight = tp->highlight; 987 cell->highlight = tp->highlight;
988 cell->f_color = tp->f_color; 988 cell->f_color = tp->f_color;
989 return 1;
989} 990}
990 991
991/* 992/*
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index fe1ad1722158..26a930e832bd 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -152,44 +152,89 @@ __ccwgroup_create_symlinks(struct ccwgroup_device *gdev)
152 return 0; 152 return 0;
153} 153}
154 154
155static int __get_next_bus_id(const char **buf, char *bus_id)
156{
157 int rc, len;
158 char *start, *end;
159
160 start = (char *)*buf;
161 end = strchr(start, ',');
162 if (!end) {
163 /* Last entry. Strip trailing newline, if applicable. */
164 end = strchr(start, '\n');
165 if (end)
166 *end = '\0';
167 len = strlen(start) + 1;
168 } else {
169 len = end - start + 1;
170 end++;
171 }
172 if (len < BUS_ID_SIZE) {
173 strlcpy(bus_id, start, len);
174 rc = 0;
175 } else
176 rc = -EINVAL;
177 *buf = end;
178 return rc;
179}
180
181static int __is_valid_bus_id(char bus_id[BUS_ID_SIZE])
182{
183 int cssid, ssid, devno;
184
185 /* Must be of form %x.%x.%04x */
186 if (sscanf(bus_id, "%x.%1x.%04x", &cssid, &ssid, &devno) != 3)
187 return 0;
188 return 1;
189}
190
155/** 191/**
156 * ccwgroup_create() - create and register a ccw group device 192 * ccwgroup_create_from_string() - create and register a ccw group device
157 * @root: parent device for the new device 193 * @root: parent device for the new device
158 * @creator_id: identifier of creating driver 194 * @creator_id: identifier of creating driver
159 * @cdrv: ccw driver of slave devices 195 * @cdrv: ccw driver of slave devices
160 * @argc: number of slave devices 196 * @num_devices: number of slave devices
161 * @argv: bus ids of slave devices 197 * @buf: buffer containing comma separated bus ids of slave devices
162 * 198 *
163 * Create and register a new ccw group device as a child of @root. Slave 199 * Create and register a new ccw group device as a child of @root. Slave
164 * devices are obtained from the list of bus ids given in @argv[] and must all 200 * devices are obtained from the list of bus ids given in @buf and must all
165 * belong to @cdrv. 201 * belong to @cdrv.
166 * Returns: 202 * Returns:
167 * %0 on success and an error code on failure. 203 * %0 on success and an error code on failure.
168 * Context: 204 * Context:
169 * non-atomic 205 * non-atomic
170 */ 206 */
171int ccwgroup_create(struct device *root, unsigned int creator_id, 207int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
172 struct ccw_driver *cdrv, int argc, char *argv[]) 208 struct ccw_driver *cdrv, int num_devices,
209 const char *buf)
173{ 210{
174 struct ccwgroup_device *gdev; 211 struct ccwgroup_device *gdev;
175 int i; 212 int rc, i;
176 int rc; 213 char tmp_bus_id[BUS_ID_SIZE];
214 const char *curr_buf;
177 215
178 if (argc > 256) /* disallow dumb users */ 216 gdev = kzalloc(sizeof(*gdev) + num_devices * sizeof(gdev->cdev[0]),
179 return -EINVAL; 217 GFP_KERNEL);
180
181 gdev = kzalloc(sizeof(*gdev) + argc*sizeof(gdev->cdev[0]), GFP_KERNEL);
182 if (!gdev) 218 if (!gdev)
183 return -ENOMEM; 219 return -ENOMEM;
184 220
185 atomic_set(&gdev->onoff, 0); 221 atomic_set(&gdev->onoff, 0);
186 mutex_init(&gdev->reg_mutex); 222 mutex_init(&gdev->reg_mutex);
187 mutex_lock(&gdev->reg_mutex); 223 mutex_lock(&gdev->reg_mutex);
188 for (i = 0; i < argc; i++) { 224 curr_buf = buf;
189 gdev->cdev[i] = get_ccwdev_by_busid(cdrv, argv[i]); 225 for (i = 0; i < num_devices && curr_buf; i++) {
190 226 rc = __get_next_bus_id(&curr_buf, tmp_bus_id);
191 /* all devices have to be of the same type in 227 if (rc != 0)
192 * order to be grouped */ 228 goto error;
229 if (!__is_valid_bus_id(tmp_bus_id)) {
230 rc = -EINVAL;
231 goto error;
232 }
233 gdev->cdev[i] = get_ccwdev_by_busid(cdrv, tmp_bus_id);
234 /*
235 * All devices have to be of the same type in
236 * order to be grouped.
237 */
193 if (!gdev->cdev[i] 238 if (!gdev->cdev[i]
194 || gdev->cdev[i]->id.driver_info != 239 || gdev->cdev[i]->id.driver_info !=
195 gdev->cdev[0]->id.driver_info) { 240 gdev->cdev[0]->id.driver_info) {
@@ -203,9 +248,18 @@ int ccwgroup_create(struct device *root, unsigned int creator_id,
203 } 248 }
204 dev_set_drvdata(&gdev->cdev[i]->dev, gdev); 249 dev_set_drvdata(&gdev->cdev[i]->dev, gdev);
205 } 250 }
206 251 /* Check for sufficient number of bus ids. */
252 if (i < num_devices && !curr_buf) {
253 rc = -EINVAL;
254 goto error;
255 }
256 /* Check for trailing stuff. */
257 if (i == num_devices && strlen(curr_buf) > 0) {
258 rc = -EINVAL;
259 goto error;
260 }
207 gdev->creator_id = creator_id; 261 gdev->creator_id = creator_id;
208 gdev->count = argc; 262 gdev->count = num_devices;
209 gdev->dev.bus = &ccwgroup_bus_type; 263 gdev->dev.bus = &ccwgroup_bus_type;
210 gdev->dev.parent = root; 264 gdev->dev.parent = root;
211 gdev->dev.release = ccwgroup_release; 265 gdev->dev.release = ccwgroup_release;
@@ -233,7 +287,7 @@ int ccwgroup_create(struct device *root, unsigned int creator_id,
233 device_remove_file(&gdev->dev, &dev_attr_ungroup); 287 device_remove_file(&gdev->dev, &dev_attr_ungroup);
234 device_unregister(&gdev->dev); 288 device_unregister(&gdev->dev);
235error: 289error:
236 for (i = 0; i < argc; i++) 290 for (i = 0; i < num_devices; i++)
237 if (gdev->cdev[i]) { 291 if (gdev->cdev[i]) {
238 if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev) 292 if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev)
239 dev_set_drvdata(&gdev->cdev[i]->dev, NULL); 293 dev_set_drvdata(&gdev->cdev[i]->dev, NULL);
@@ -243,6 +297,7 @@ error:
243 put_device(&gdev->dev); 297 put_device(&gdev->dev);
244 return rc; 298 return rc;
245} 299}
300EXPORT_SYMBOL(ccwgroup_create_from_string);
246 301
247static int __init 302static int __init
248init_ccwgroup (void) 303init_ccwgroup (void)
@@ -318,7 +373,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
318{ 373{
319 struct ccwgroup_device *gdev; 374 struct ccwgroup_device *gdev;
320 struct ccwgroup_driver *gdrv; 375 struct ccwgroup_driver *gdrv;
321 unsigned int value; 376 unsigned long value;
322 int ret; 377 int ret;
323 378
324 gdev = to_ccwgroupdev(dev); 379 gdev = to_ccwgroupdev(dev);
@@ -329,7 +384,9 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
329 if (!try_module_get(gdrv->owner)) 384 if (!try_module_get(gdrv->owner))
330 return -EINVAL; 385 return -EINVAL;
331 386
332 value = simple_strtoul(buf, NULL, 0); 387 ret = strict_strtoul(buf, 0, &value);
388 if (ret)
389 goto out;
333 ret = count; 390 ret = count;
334 if (value == 1) 391 if (value == 1)
335 ccwgroup_set_online(gdev); 392 ccwgroup_set_online(gdev);
@@ -337,6 +394,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
337 ccwgroup_set_offline(gdev); 394 ccwgroup_set_offline(gdev);
338 else 395 else
339 ret = -EINVAL; 396 ret = -EINVAL;
397out:
340 module_put(gdrv->owner); 398 module_put(gdrv->owner);
341 return ret; 399 return ret;
342} 400}
@@ -518,6 +576,5 @@ void ccwgroup_remove_ccwdev(struct ccw_device *cdev)
518MODULE_LICENSE("GPL"); 576MODULE_LICENSE("GPL");
519EXPORT_SYMBOL(ccwgroup_driver_register); 577EXPORT_SYMBOL(ccwgroup_driver_register);
520EXPORT_SYMBOL(ccwgroup_driver_unregister); 578EXPORT_SYMBOL(ccwgroup_driver_unregister);
521EXPORT_SYMBOL(ccwgroup_create);
522EXPORT_SYMBOL(ccwgroup_probe_ccwdev); 579EXPORT_SYMBOL(ccwgroup_probe_ccwdev);
523EXPORT_SYMBOL(ccwgroup_remove_ccwdev); 580EXPORT_SYMBOL(ccwgroup_remove_ccwdev);
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 23ffcc4768a7..08a578161306 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -407,8 +407,7 @@ cio_modify (struct subchannel *sch)
407/* 407/*
408 * Enable subchannel. 408 * Enable subchannel.
409 */ 409 */
410int cio_enable_subchannel(struct subchannel *sch, unsigned int isc, 410int cio_enable_subchannel(struct subchannel *sch, u32 intparm)
411 u32 intparm)
412{ 411{
413 char dbf_txt[15]; 412 char dbf_txt[15];
414 int ccode; 413 int ccode;
@@ -426,7 +425,7 @@ int cio_enable_subchannel(struct subchannel *sch, unsigned int isc,
426 425
427 for (retry = 5, ret = 0; retry > 0; retry--) { 426 for (retry = 5, ret = 0; retry > 0; retry--) {
428 sch->schib.pmcw.ena = 1; 427 sch->schib.pmcw.ena = 1;
429 sch->schib.pmcw.isc = isc; 428 sch->schib.pmcw.isc = sch->isc;
430 sch->schib.pmcw.intparm = intparm; 429 sch->schib.pmcw.intparm = intparm;
431 ret = cio_modify(sch); 430 ret = cio_modify(sch);
432 if (ret == -ENODEV) 431 if (ret == -ENODEV)
@@ -600,6 +599,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
600 else 599 else
601 sch->opm = chp_get_sch_opm(sch); 600 sch->opm = chp_get_sch_opm(sch);
602 sch->lpm = sch->schib.pmcw.pam & sch->opm; 601 sch->lpm = sch->schib.pmcw.pam & sch->opm;
602 sch->isc = 3;
603 603
604 CIO_DEBUG(KERN_INFO, 0, 604 CIO_DEBUG(KERN_INFO, 0,
605 "Detected device %04x on subchannel 0.%x.%04X" 605 "Detected device %04x on subchannel 0.%x.%04X"
@@ -610,13 +610,11 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
610 610
611 /* 611 /*
612 * We now have to initially ... 612 * We now have to initially ...
613 * ... set "interruption subclass"
614 * ... enable "concurrent sense" 613 * ... enable "concurrent sense"
615 * ... enable "multipath mode" if more than one 614 * ... enable "multipath mode" if more than one
616 * CHPID is available. This is done regardless 615 * CHPID is available. This is done regardless
617 * whether multiple paths are available for us. 616 * whether multiple paths are available for us.
618 */ 617 */
619 sch->schib.pmcw.isc = 3; /* could be smth. else */
620 sch->schib.pmcw.csense = 1; /* concurrent sense */ 618 sch->schib.pmcw.csense = 1; /* concurrent sense */
621 sch->schib.pmcw.ena = 0; 619 sch->schib.pmcw.ena = 0;
622 if ((sch->lpm & (sch->lpm - 1)) != 0) 620 if ((sch->lpm & (sch->lpm - 1)) != 0)
@@ -812,6 +810,7 @@ cio_probe_console(void)
812 * enable console I/O-interrupt subclass 7 810 * enable console I/O-interrupt subclass 7
813 */ 811 */
814 ctl_set_bit(6, 24); 812 ctl_set_bit(6, 24);
813 console_subchannel.isc = 7;
815 console_subchannel.schib.pmcw.isc = 7; 814 console_subchannel.schib.pmcw.isc = 7;
816 console_subchannel.schib.pmcw.intparm = 815 console_subchannel.schib.pmcw.intparm =
817 (u32)(addr_t)&console_subchannel; 816 (u32)(addr_t)&console_subchannel;
diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
index 08f2235c5a6f..3c75412904dc 100644
--- a/drivers/s390/cio/cio.h
+++ b/drivers/s390/cio/cio.h
@@ -74,6 +74,7 @@ struct subchannel {
74 __u8 lpm; /* logical path mask */ 74 __u8 lpm; /* logical path mask */
75 __u8 opm; /* operational path mask */ 75 __u8 opm; /* operational path mask */
76 struct schib schib; /* subchannel information block */ 76 struct schib schib; /* subchannel information block */
77 int isc; /* desired interruption subclass */
77 struct chsc_ssd_info ssd_info; /* subchannel description */ 78 struct chsc_ssd_info ssd_info; /* subchannel description */
78 struct device dev; /* entry in device tree */ 79 struct device dev; /* entry in device tree */
79 struct css_driver *driver; 80 struct css_driver *driver;
@@ -85,7 +86,7 @@ struct subchannel {
85#define to_subchannel(n) container_of(n, struct subchannel, dev) 86#define to_subchannel(n) container_of(n, struct subchannel, dev)
86 87
87extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id); 88extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id);
88extern int cio_enable_subchannel(struct subchannel *, unsigned int, u32); 89extern int cio_enable_subchannel(struct subchannel *, u32);
89extern int cio_disable_subchannel (struct subchannel *); 90extern int cio_disable_subchannel (struct subchannel *);
90extern int cio_cancel (struct subchannel *); 91extern int cio_cancel (struct subchannel *);
91extern int cio_clear (struct subchannel *); 92extern int cio_clear (struct subchannel *);
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index f4c132ab39ed..2808b6833b9e 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1219,16 +1219,21 @@ static ssize_t cmb_enable_store(struct device *dev,
1219{ 1219{
1220 struct ccw_device *cdev; 1220 struct ccw_device *cdev;
1221 int ret; 1221 int ret;
1222 unsigned long val;
1223
1224 ret = strict_strtoul(buf, 16, &val);
1225 if (ret)
1226 return ret;
1222 1227
1223 cdev = to_ccwdev(dev); 1228 cdev = to_ccwdev(dev);
1224 1229
1225 switch (buf[0]) { 1230 switch (val) {
1226 case '0': 1231 case 0:
1227 ret = disable_cmf(cdev); 1232 ret = disable_cmf(cdev);
1228 if (ret) 1233 if (ret)
1229 dev_info(&cdev->dev, "disable_cmf failed (%d)\n", ret); 1234 dev_info(&cdev->dev, "disable_cmf failed (%d)\n", ret);
1230 break; 1235 break;
1231 case '1': 1236 case 1:
1232 ret = enable_cmf(cdev); 1237 ret = enable_cmf(cdev);
1233 if (ret && ret != -EBUSY) 1238 if (ret && ret != -EBUSY)
1234 dev_info(&cdev->dev, "enable_cmf failed (%d)\n", ret); 1239 dev_info(&cdev->dev, "enable_cmf failed (%d)\n", ret);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index c1afab5f72d6..595e327d2f76 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -705,13 +705,17 @@ css_cm_enable_store(struct device *dev, struct device_attribute *attr,
705{ 705{
706 struct channel_subsystem *css = to_css(dev); 706 struct channel_subsystem *css = to_css(dev);
707 int ret; 707 int ret;
708 unsigned long val;
708 709
710 ret = strict_strtoul(buf, 16, &val);
711 if (ret)
712 return ret;
709 mutex_lock(&css->mutex); 713 mutex_lock(&css->mutex);
710 switch (buf[0]) { 714 switch (val) {
711 case '0': 715 case 0:
712 ret = css->cm_enabled ? chsc_secm(css, 0) : 0; 716 ret = css->cm_enabled ? chsc_secm(css, 0) : 0;
713 break; 717 break;
714 case '1': 718 case 1:
715 ret = css->cm_enabled ? 0 : chsc_secm(css, 1); 719 ret = css->cm_enabled ? 0 : chsc_secm(css, 1);
716 break; 720 break;
717 default: 721 default:
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index e0c7adb8958e..abfd601d237a 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -512,8 +512,8 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
512 const char *buf, size_t count) 512 const char *buf, size_t count)
513{ 513{
514 struct ccw_device *cdev = to_ccwdev(dev); 514 struct ccw_device *cdev = to_ccwdev(dev);
515 int i, force; 515 int force, ret;
516 char *tmp; 516 unsigned long i;
517 517
518 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0) 518 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
519 return -EAGAIN; 519 return -EAGAIN;
@@ -525,25 +525,30 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
525 if (!strncmp(buf, "force\n", count)) { 525 if (!strncmp(buf, "force\n", count)) {
526 force = 1; 526 force = 1;
527 i = 1; 527 i = 1;
528 ret = 0;
528 } else { 529 } else {
529 force = 0; 530 force = 0;
530 i = simple_strtoul(buf, &tmp, 16); 531 ret = strict_strtoul(buf, 16, &i);
531 } 532 }
532 533 if (ret)
534 goto out;
533 switch (i) { 535 switch (i) {
534 case 0: 536 case 0:
535 online_store_handle_offline(cdev); 537 online_store_handle_offline(cdev);
538 ret = count;
536 break; 539 break;
537 case 1: 540 case 1:
538 online_store_handle_online(cdev, force); 541 online_store_handle_online(cdev, force);
542 ret = count;
539 break; 543 break;
540 default: 544 default:
541 count = -EINVAL; 545 ret = -EINVAL;
542 } 546 }
547out:
543 if (cdev->drv) 548 if (cdev->drv)
544 module_put(cdev->drv->owner); 549 module_put(cdev->drv->owner);
545 atomic_set(&cdev->private->onoff, 0); 550 atomic_set(&cdev->private->onoff, 0);
546 return count; 551 return ret;
547} 552}
548 553
549static ssize_t 554static ssize_t
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 4b92c84fb438..99403b0a97a7 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -555,8 +555,7 @@ ccw_device_recognition(struct ccw_device *cdev)
555 (cdev->private->state != DEV_STATE_BOXED)) 555 (cdev->private->state != DEV_STATE_BOXED))
556 return -EINVAL; 556 return -EINVAL;
557 sch = to_subchannel(cdev->dev.parent); 557 sch = to_subchannel(cdev->dev.parent);
558 ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc, 558 ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
559 (u32)(addr_t)sch);
560 if (ret != 0) 559 if (ret != 0)
561 /* Couldn't enable the subchannel for i/o. Sick device. */ 560 /* Couldn't enable the subchannel for i/o. Sick device. */
562 return ret; 561 return ret;
@@ -667,8 +666,7 @@ ccw_device_online(struct ccw_device *cdev)
667 sch = to_subchannel(cdev->dev.parent); 666 sch = to_subchannel(cdev->dev.parent);
668 if (css_init_done && !get_device(&cdev->dev)) 667 if (css_init_done && !get_device(&cdev->dev))
669 return -ENODEV; 668 return -ENODEV;
670 ret = cio_enable_subchannel(sch, sch->schib.pmcw.isc, 669 ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
671 (u32)(addr_t)sch);
672 if (ret != 0) { 670 if (ret != 0) {
673 /* Couldn't enable the subchannel for i/o. Sick device. */ 671 /* Couldn't enable the subchannel for i/o. Sick device. */
674 if (ret == -ENODEV) 672 if (ret == -ENODEV)
@@ -1048,8 +1046,7 @@ ccw_device_start_id(struct ccw_device *cdev, enum dev_event dev_event)
1048 struct subchannel *sch; 1046 struct subchannel *sch;
1049 1047
1050 sch = to_subchannel(cdev->dev.parent); 1048 sch = to_subchannel(cdev->dev.parent);
1051 if (cio_enable_subchannel(sch, sch->schib.pmcw.isc, 1049 if (cio_enable_subchannel(sch, (u32)(addr_t)sch) != 0)
1052 (u32)(addr_t)sch) != 0)
1053 /* Couldn't enable the subchannel for i/o. Sick device. */ 1050 /* Couldn't enable the subchannel for i/o. Sick device. */
1054 return; 1051 return;
1055 1052
@@ -1082,7 +1079,6 @@ device_trigger_reprobe(struct subchannel *sch)
1082 */ 1079 */
1083 sch->lpm = sch->schib.pmcw.pam & sch->opm; 1080 sch->lpm = sch->schib.pmcw.pam & sch->opm;
1084 /* Re-set some bits in the pmcw that were lost. */ 1081 /* Re-set some bits in the pmcw that were lost. */
1085 sch->schib.pmcw.isc = 3;
1086 sch->schib.pmcw.csense = 1; 1082 sch->schib.pmcw.csense = 1;
1087 sch->schib.pmcw.ena = 0; 1083 sch->schib.pmcw.ena = 0;
1088 if ((sch->lpm & (sch->lpm - 1)) != 0) 1084 if ((sch->lpm & (sch->lpm - 1)) != 0)
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index a1718a0aa539..f308ad55a6d5 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -508,7 +508,7 @@ ccw_device_stlck(struct ccw_device *cdev)
508 return -ENOMEM; 508 return -ENOMEM;
509 } 509 }
510 spin_lock_irqsave(sch->lock, flags); 510 spin_lock_irqsave(sch->lock, flags);
511 ret = cio_enable_subchannel(sch, 3, (u32)(addr_t)sch); 511 ret = cio_enable_subchannel(sch, (u32)(addr_t)sch);
512 if (ret) 512 if (ret)
513 goto out_unlock; 513 goto out_unlock;
514 /* 514 /*
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 43876e287370..445cf364e461 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -3663,11 +3663,11 @@ qdio_performance_stats_show(struct bus_type *bus, char *buf)
3663static ssize_t 3663static ssize_t
3664qdio_performance_stats_store(struct bus_type *bus, const char *buf, size_t count) 3664qdio_performance_stats_store(struct bus_type *bus, const char *buf, size_t count)
3665{ 3665{
3666 char *tmp; 3666 unsigned long i;
3667 int i; 3667 int ret;
3668 3668
3669 i = simple_strtoul(buf, &tmp, 16); 3669 ret = strict_strtoul(buf, 16, &i);
3670 if ((i == 0) || (i == 1)) { 3670 if (!ret && ((i == 0) || (i == 1))) {
3671 if (i == qdio_performance_stats) 3671 if (i == qdio_performance_stats)
3672 return count; 3672 return count;
3673 qdio_performance_stats = i; 3673 qdio_performance_stats = i;
diff --git a/drivers/s390/kvm/kvm_virtio.c b/drivers/s390/kvm/kvm_virtio.c
index bbef3764fbf8..47a7e6200b26 100644
--- a/drivers/s390/kvm/kvm_virtio.c
+++ b/drivers/s390/kvm/kvm_virtio.c
@@ -17,6 +17,7 @@
17#include <linux/virtio_config.h> 17#include <linux/virtio_config.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/virtio_ring.h> 19#include <linux/virtio_ring.h>
20#include <linux/pfn.h>
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/kvm_para.h> 22#include <asm/kvm_para.h>
22#include <asm/kvm_virtio.h> 23#include <asm/kvm_virtio.h>
@@ -180,11 +181,10 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
180 181
181 config = kvm_vq_config(kdev->desc)+index; 182 config = kvm_vq_config(kdev->desc)+index;
182 183
183 if (add_shared_memory(config->address, 184 err = vmem_add_mapping(config->address,
184 vring_size(config->num, PAGE_SIZE))) { 185 vring_size(config->num, PAGE_SIZE));
185 err = -ENOMEM; 186 if (err)
186 goto out; 187 goto out;
187 }
188 188
189 vq = vring_new_virtqueue(config->num, vdev, (void *) config->address, 189 vq = vring_new_virtqueue(config->num, vdev, (void *) config->address,
190 kvm_notify, callback); 190 kvm_notify, callback);
@@ -202,8 +202,8 @@ static struct virtqueue *kvm_find_vq(struct virtio_device *vdev,
202 vq->priv = config; 202 vq->priv = config;
203 return vq; 203 return vq;
204unmap: 204unmap:
205 remove_shared_memory(config->address, vring_size(config->num, 205 vmem_remove_mapping(config->address,
206 PAGE_SIZE)); 206 vring_size(config->num, PAGE_SIZE));
207out: 207out:
208 return ERR_PTR(err); 208 return ERR_PTR(err);
209} 209}
@@ -213,8 +213,8 @@ static void kvm_del_vq(struct virtqueue *vq)
213 struct kvm_vqconfig *config = vq->priv; 213 struct kvm_vqconfig *config = vq->priv;
214 214
215 vring_del_virtqueue(vq); 215 vring_del_virtqueue(vq);
216 remove_shared_memory(config->address, 216 vmem_remove_mapping(config->address,
217 vring_size(config->num, PAGE_SIZE)); 217 vring_size(config->num, PAGE_SIZE));
218} 218}
219 219
220/* 220/*
@@ -318,12 +318,13 @@ static int __init kvm_devices_init(void)
318 return rc; 318 return rc;
319 } 319 }
320 320
321 if (add_shared_memory((max_pfn) << PAGE_SHIFT, PAGE_SIZE)) { 321 rc = vmem_add_mapping(PFN_PHYS(max_pfn), PAGE_SIZE);
322 if (rc) {
322 device_unregister(&kvm_root); 323 device_unregister(&kvm_root);
323 return -ENOMEM; 324 return rc;
324 } 325 }
325 326
326 kvm_devices = (void *) (max_pfn << PAGE_SHIFT); 327 kvm_devices = (void *) PFN_PHYS(max_pfn);
327 328
328 ctl_set_bit(0, 9); 329 ctl_set_bit(0, 9);
329 register_external_interrupt(0x2603, kvm_extint_handler); 330 register_external_interrupt(0x2603, kvm_extint_handler);
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index 76728ae4b843..8e7697305a4c 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -62,30 +62,14 @@ static struct device *cu3088_root_dev;
62static ssize_t 62static ssize_t
63group_write(struct device_driver *drv, const char *buf, size_t count) 63group_write(struct device_driver *drv, const char *buf, size_t count)
64{ 64{
65 const char *start, *end;
66 char bus_ids[2][BUS_ID_SIZE], *argv[2];
67 int i;
68 int ret; 65 int ret;
69 struct ccwgroup_driver *cdrv; 66 struct ccwgroup_driver *cdrv;
70 67
71 cdrv = to_ccwgroupdrv(drv); 68 cdrv = to_ccwgroupdrv(drv);
72 if (!cdrv) 69 if (!cdrv)
73 return -EINVAL; 70 return -EINVAL;
74 start = buf; 71 ret = ccwgroup_create_from_string(cu3088_root_dev, cdrv->driver_id,
75 for (i=0; i<2; i++) { 72 &cu3088_driver, 2, buf);
76 static const char delim[] = {',', '\n'};
77 int len;
78
79 if (!(end = strchr(start, delim[i])))
80 return -EINVAL;
81 len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start + 1);
82 strlcpy (bus_ids[i], start, len);
83 argv[i] = bus_ids[i];
84 start = end + 1;
85 }
86
87 ret = ccwgroup_create(cu3088_root_dev, cdrv->driver_id,
88 &cu3088_driver, 2, argv);
89 73
90 return (ret == 0) ? count : ret; 74 return (ret == 0) ? count : ret;
91} 75}
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index f51ed9972587..dd22f4b37037 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -1793,7 +1793,8 @@ lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len)
1793 skb->protocol = card->lan_type_trans(skb, card->dev); 1793 skb->protocol = card->lan_type_trans(skb, card->dev);
1794 card->stats.rx_bytes += skb_len; 1794 card->stats.rx_bytes += skb_len;
1795 card->stats.rx_packets++; 1795 card->stats.rx_packets++;
1796 *((__u32 *)skb->cb) = ++card->pkt_seq; 1796 if (skb->protocol == htons(ETH_P_802_2))
1797 *((__u32 *)skb->cb) = ++card->pkt_seq;
1797 netif_rx(skb); 1798 netif_rx(skb);
1798} 1799}
1799 1800
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 8f876f6ab367..e4ba6a0372ac 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1313,8 +1313,6 @@ static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
1313 * and throw away packet. 1313 * and throw away packet.
1314 */ 1314 */
1315 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) { 1315 if (fsm_getstate(privptr->fsm) != DEV_STATE_RUNNING) {
1316 if (!in_atomic())
1317 fsm_event(privptr->fsm, DEV_EVENT_START, dev);
1318 dev_kfree_skb(skb); 1316 dev_kfree_skb(skb);
1319 privptr->stats.tx_dropped++; 1317 privptr->stats.tx_dropped++;
1320 privptr->stats.tx_errors++; 1318 privptr->stats.tx_errors++;
@@ -2147,6 +2145,7 @@ static int __init netiucv_init(void)
2147 if (rc) 2145 if (rc)
2148 goto out_dbf; 2146 goto out_dbf;
2149 IUCV_DBF_TEXT(trace, 3, __func__); 2147 IUCV_DBF_TEXT(trace, 3, __func__);
2148 netiucv_driver.groups = netiucv_drv_attr_groups;
2150 rc = driver_register(&netiucv_driver); 2149 rc = driver_register(&netiucv_driver);
2151 if (rc) { 2150 if (rc) {
2152 PRINT_ERR("NETIUCV: failed to register driver.\n"); 2151 PRINT_ERR("NETIUCV: failed to register driver.\n");
diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h
index 66f4f12503c9..699ac11debd8 100644
--- a/drivers/s390/net/qeth_core.h
+++ b/drivers/s390/net/qeth_core.h
@@ -72,22 +72,7 @@ struct qeth_dbf_info {
72 debug_sprintf_event(qeth_dbf[QETH_DBF_MSG].id, level, text) 72 debug_sprintf_event(qeth_dbf[QETH_DBF_MSG].id, level, text)
73 73
74#define QETH_DBF_TEXT_(name, level, text...) \ 74#define QETH_DBF_TEXT_(name, level, text...) \
75 do { \ 75 qeth_dbf_longtext(QETH_DBF_##name, level, text)
76 if (qeth_dbf_passes(qeth_dbf[QETH_DBF_##name].id, level)) { \
77 char *dbf_txt_buf = \
78 get_cpu_var(QETH_DBF_TXT_BUF); \
79 sprintf(dbf_txt_buf, text); \
80 debug_text_event(qeth_dbf[QETH_DBF_##name].id, \
81 level, dbf_txt_buf); \
82 put_cpu_var(QETH_DBF_TXT_BUF); \
83 } \
84 } while (0)
85
86/* Allow to sort out low debug levels early to avoid wasted sprints */
87static inline int qeth_dbf_passes(debug_info_t *dbf_grp, int level)
88{
89 return (level <= dbf_grp->level);
90}
91 76
92/** 77/**
93 * some more debug stuff 78 * some more debug stuff
@@ -773,27 +758,6 @@ static inline int qeth_get_micros(void)
773 return (int) (get_clock() >> 12); 758 return (int) (get_clock() >> 12);
774} 759}
775 760
776static inline void *qeth_push_skb(struct qeth_card *card, struct sk_buff *skb,
777 int size)
778{
779 void *hdr;
780
781 hdr = (void *) skb_push(skb, size);
782 /*
783 * sanity check, the Linux memory allocation scheme should
784 * never present us cases like this one (the qdio header size plus
785 * the first 40 bytes of the paket cross a 4k boundary)
786 */
787 if ((((unsigned long) hdr) & (~(PAGE_SIZE - 1))) !=
788 (((unsigned long) hdr + size +
789 QETH_IP_HEADER_SIZE) & (~(PAGE_SIZE - 1)))) {
790 PRINT_ERR("Misaligned packet on interface %s. Discarded.",
791 QETH_CARD_IFNAME(card));
792 return NULL;
793 }
794 return hdr;
795}
796
797static inline int qeth_get_ip_version(struct sk_buff *skb) 761static inline int qeth_get_ip_version(struct sk_buff *skb)
798{ 762{
799 switch (skb->protocol) { 763 switch (skb->protocol) {
@@ -806,6 +770,12 @@ static inline int qeth_get_ip_version(struct sk_buff *skb)
806 } 770 }
807} 771}
808 772
773static inline void qeth_put_buffer_pool_entry(struct qeth_card *card,
774 struct qeth_buffer_pool_entry *entry)
775{
776 list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
777}
778
809struct qeth_eddp_context; 779struct qeth_eddp_context;
810extern struct ccwgroup_driver qeth_l2_ccwgroup_driver; 780extern struct ccwgroup_driver qeth_l2_ccwgroup_driver;
811extern struct ccwgroup_driver qeth_l3_ccwgroup_driver; 781extern struct ccwgroup_driver qeth_l3_ccwgroup_driver;
@@ -843,8 +813,6 @@ struct qeth_cmd_buffer *qeth_get_ipacmd_buffer(struct qeth_card *,
843int qeth_query_setadapterparms(struct qeth_card *); 813int qeth_query_setadapterparms(struct qeth_card *);
844int qeth_check_qdio_errors(struct qdio_buffer *, unsigned int, 814int qeth_check_qdio_errors(struct qdio_buffer *, unsigned int,
845 unsigned int, const char *); 815 unsigned int, const char *);
846void qeth_put_buffer_pool_entry(struct qeth_card *,
847 struct qeth_buffer_pool_entry *);
848void qeth_queue_input_buffer(struct qeth_card *, int); 816void qeth_queue_input_buffer(struct qeth_card *, int);
849struct sk_buff *qeth_core_get_next_skb(struct qeth_card *, 817struct sk_buff *qeth_core_get_next_skb(struct qeth_card *,
850 struct qdio_buffer *, struct qdio_buffer_element **, int *, 818 struct qdio_buffer *, struct qdio_buffer_element **, int *,
@@ -880,8 +848,6 @@ int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *,
880 void *reply_param); 848 void *reply_param);
881int qeth_get_cast_type(struct qeth_card *, struct sk_buff *); 849int qeth_get_cast_type(struct qeth_card *, struct sk_buff *);
882int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); 850int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int);
883struct sk_buff *qeth_prepare_skb(struct qeth_card *, struct sk_buff *,
884 struct qeth_hdr **);
885int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int); 851int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int);
886int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, 852int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *,
887 struct sk_buff *, struct qeth_hdr *, int, 853 struct sk_buff *, struct qeth_hdr *, int,
@@ -894,6 +860,8 @@ void qeth_core_get_ethtool_stats(struct net_device *,
894 struct ethtool_stats *, u64 *); 860 struct ethtool_stats *, u64 *);
895void qeth_core_get_strings(struct net_device *, u32, u8 *); 861void qeth_core_get_strings(struct net_device *, u32, u8 *);
896void qeth_core_get_drvinfo(struct net_device *, struct ethtool_drvinfo *); 862void qeth_core_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
863void qeth_dbf_longtext(enum qeth_dbf_names dbf_nix, int level, char *text, ...);
864int qeth_core_ethtool_get_settings(struct net_device *, struct ethtool_cmd *);
897 865
898/* exports for OSN */ 866/* exports for OSN */
899int qeth_osn_assist(struct net_device *, void *, int); 867int qeth_osn_assist(struct net_device *, void *, int);
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 055f5c3e7b56..436bf1f6d4a6 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -26,9 +26,6 @@
26#include "qeth_core.h" 26#include "qeth_core.h"
27#include "qeth_core_offl.h" 27#include "qeth_core_offl.h"
28 28
29static DEFINE_PER_CPU(char[256], qeth_core_dbf_txt_buf);
30#define QETH_DBF_TXT_BUF qeth_core_dbf_txt_buf
31
32struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS] = { 29struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS] = {
33 /* define dbf - Name, Pages, Areas, Maxlen, Level, View, Handle */ 30 /* define dbf - Name, Pages, Areas, Maxlen, Level, View, Handle */
34 /* N P A M L V H */ 31 /* N P A M L V H */
@@ -2255,14 +2252,6 @@ void qeth_print_status_message(struct qeth_card *card)
2255} 2252}
2256EXPORT_SYMBOL_GPL(qeth_print_status_message); 2253EXPORT_SYMBOL_GPL(qeth_print_status_message);
2257 2254
2258void qeth_put_buffer_pool_entry(struct qeth_card *card,
2259 struct qeth_buffer_pool_entry *entry)
2260{
2261 QETH_DBF_TEXT(TRACE, 6, "ptbfplen");
2262 list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
2263}
2264EXPORT_SYMBOL_GPL(qeth_put_buffer_pool_entry);
2265
2266static void qeth_initialize_working_pool_list(struct qeth_card *card) 2255static void qeth_initialize_working_pool_list(struct qeth_card *card)
2267{ 2256{
2268 struct qeth_buffer_pool_entry *entry; 2257 struct qeth_buffer_pool_entry *entry;
@@ -2603,7 +2592,6 @@ void qeth_queue_input_buffer(struct qeth_card *card, int index)
2603 int rc; 2592 int rc;
2604 int newcount = 0; 2593 int newcount = 0;
2605 2594
2606 QETH_DBF_TEXT(TRACE, 6, "queinbuf");
2607 count = (index < queue->next_buf_to_init)? 2595 count = (index < queue->next_buf_to_init)?
2608 card->qdio.in_buf_pool.buf_count - 2596 card->qdio.in_buf_pool.buf_count -
2609 (queue->next_buf_to_init - index) : 2597 (queue->next_buf_to_init - index) :
@@ -2792,8 +2780,6 @@ static void qeth_flush_buffers(struct qeth_qdio_out_q *queue, int under_int,
2792 int i; 2780 int i;
2793 unsigned int qdio_flags; 2781 unsigned int qdio_flags;
2794 2782
2795 QETH_DBF_TEXT(TRACE, 6, "flushbuf");
2796
2797 for (i = index; i < index + count; ++i) { 2783 for (i = index; i < index + count; ++i) {
2798 buf = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; 2784 buf = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q];
2799 buf->buffer->element[buf->next_element_to_fill - 1].flags |= 2785 buf->buffer->element[buf->next_element_to_fill - 1].flags |=
@@ -3037,49 +3023,6 @@ int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb,
3037} 3023}
3038EXPORT_SYMBOL_GPL(qeth_get_priority_queue); 3024EXPORT_SYMBOL_GPL(qeth_get_priority_queue);
3039 3025
3040static void __qeth_free_new_skb(struct sk_buff *orig_skb,
3041 struct sk_buff *new_skb)
3042{
3043 if (orig_skb != new_skb)
3044 dev_kfree_skb_any(new_skb);
3045}
3046
3047static inline struct sk_buff *qeth_realloc_headroom(struct qeth_card *card,
3048 struct sk_buff *skb, int size)
3049{
3050 struct sk_buff *new_skb = skb;
3051
3052 if (skb_headroom(skb) >= size)
3053 return skb;
3054 new_skb = skb_realloc_headroom(skb, size);
3055 if (!new_skb)
3056 PRINT_ERR("Could not realloc headroom for qeth_hdr "
3057 "on interface %s", QETH_CARD_IFNAME(card));
3058 return new_skb;
3059}
3060
3061struct sk_buff *qeth_prepare_skb(struct qeth_card *card, struct sk_buff *skb,
3062 struct qeth_hdr **hdr)
3063{
3064 struct sk_buff *new_skb;
3065
3066 QETH_DBF_TEXT(TRACE, 6, "prepskb");
3067
3068 new_skb = qeth_realloc_headroom(card, skb,
3069 sizeof(struct qeth_hdr));
3070 if (!new_skb)
3071 return NULL;
3072
3073 *hdr = ((struct qeth_hdr *)qeth_push_skb(card, new_skb,
3074 sizeof(struct qeth_hdr)));
3075 if (*hdr == NULL) {
3076 __qeth_free_new_skb(skb, new_skb);
3077 return NULL;
3078 }
3079 return new_skb;
3080}
3081EXPORT_SYMBOL_GPL(qeth_prepare_skb);
3082
3083int qeth_get_elements_no(struct qeth_card *card, void *hdr, 3026int qeth_get_elements_no(struct qeth_card *card, void *hdr,
3084 struct sk_buff *skb, int elems) 3027 struct sk_buff *skb, int elems)
3085{ 3028{
@@ -3100,8 +3043,8 @@ int qeth_get_elements_no(struct qeth_card *card, void *hdr,
3100} 3043}
3101EXPORT_SYMBOL_GPL(qeth_get_elements_no); 3044EXPORT_SYMBOL_GPL(qeth_get_elements_no);
3102 3045
3103static void __qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer, 3046static inline void __qeth_fill_buffer(struct sk_buff *skb,
3104 int is_tso, int *next_element_to_fill) 3047 struct qdio_buffer *buffer, int is_tso, int *next_element_to_fill)
3105{ 3048{
3106 int length = skb->len; 3049 int length = skb->len;
3107 int length_here; 3050 int length_here;
@@ -3143,15 +3086,13 @@ static void __qeth_fill_buffer(struct sk_buff *skb, struct qdio_buffer *buffer,
3143 *next_element_to_fill = element; 3086 *next_element_to_fill = element;
3144} 3087}
3145 3088
3146static int qeth_fill_buffer(struct qeth_qdio_out_q *queue, 3089static inline int qeth_fill_buffer(struct qeth_qdio_out_q *queue,
3147 struct qeth_qdio_out_buffer *buf, struct sk_buff *skb) 3090 struct qeth_qdio_out_buffer *buf, struct sk_buff *skb)
3148{ 3091{
3149 struct qdio_buffer *buffer; 3092 struct qdio_buffer *buffer;
3150 struct qeth_hdr_tso *hdr; 3093 struct qeth_hdr_tso *hdr;
3151 int flush_cnt = 0, hdr_len, large_send = 0; 3094 int flush_cnt = 0, hdr_len, large_send = 0;
3152 3095
3153 QETH_DBF_TEXT(TRACE, 6, "qdfillbf");
3154
3155 buffer = buf->buffer; 3096 buffer = buf->buffer;
3156 atomic_inc(&skb->users); 3097 atomic_inc(&skb->users);
3157 skb_queue_tail(&buf->skb_list, skb); 3098 skb_queue_tail(&buf->skb_list, skb);
@@ -3210,8 +3151,6 @@ int qeth_do_send_packet_fast(struct qeth_card *card,
3210 int flush_cnt = 0; 3151 int flush_cnt = 0;
3211 int index; 3152 int index;
3212 3153
3213 QETH_DBF_TEXT(TRACE, 6, "dosndpfa");
3214
3215 /* spin until we get the queue ... */ 3154 /* spin until we get the queue ... */
3216 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, 3155 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED,
3217 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); 3156 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED);
@@ -3263,8 +3202,6 @@ int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
3263 int tmp; 3202 int tmp;
3264 int rc = 0; 3203 int rc = 0;
3265 3204
3266 QETH_DBF_TEXT(TRACE, 6, "dosndpkt");
3267
3268 /* spin until we get the queue ... */ 3205 /* spin until we get the queue ... */
3269 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED, 3206 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED,
3270 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED); 3207 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED);
@@ -3827,27 +3764,8 @@ static struct ccw_driver qeth_ccw_driver = {
3827static int qeth_core_driver_group(const char *buf, struct device *root_dev, 3764static int qeth_core_driver_group(const char *buf, struct device *root_dev,
3828 unsigned long driver_id) 3765 unsigned long driver_id)
3829{ 3766{
3830 const char *start, *end; 3767 return ccwgroup_create_from_string(root_dev, driver_id,
3831 char bus_ids[3][BUS_ID_SIZE], *argv[3]; 3768 &qeth_ccw_driver, 3, buf);
3832 int i;
3833
3834 start = buf;
3835 for (i = 0; i < 3; i++) {
3836 static const char delim[] = { ',', ',', '\n' };
3837 int len;
3838
3839 end = strchr(start, delim[i]);
3840 if (!end)
3841 return -EINVAL;
3842 len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
3843 strncpy(bus_ids[i], start, len);
3844 bus_ids[i][len] = '\0';
3845 start = end + 1;
3846 argv[i] = bus_ids[i];
3847 }
3848
3849 return (ccwgroup_create(root_dev, driver_id,
3850 &qeth_ccw_driver, 3, argv));
3851} 3769}
3852 3770
3853int qeth_core_hardsetup_card(struct qeth_card *card) 3771int qeth_core_hardsetup_card(struct qeth_card *card)
@@ -3885,8 +3803,9 @@ retry:
3885 QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc); 3803 QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc);
3886 return rc; 3804 return rc;
3887 } 3805 }
3888 3806 mpno = qdio_get_ssqd_pct(CARD_DDEV(card));
3889 mpno = QETH_MAX_PORTNO; 3807 if (mpno)
3808 mpno = min(mpno - 1, QETH_MAX_PORTNO);
3890 if (card->info.portno > mpno) { 3809 if (card->info.portno > mpno) {
3891 PRINT_ERR("Device %s does not offer port number %d \n.", 3810 PRINT_ERR("Device %s does not offer port number %d \n.",
3892 CARD_BUS_ID(card), card->info.portno); 3811 CARD_BUS_ID(card), card->info.portno);
@@ -3980,7 +3899,6 @@ struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card,
3980 int use_rx_sg = 0; 3899 int use_rx_sg = 0;
3981 int frag = 0; 3900 int frag = 0;
3982 3901
3983 QETH_DBF_TEXT(TRACE, 6, "nextskb");
3984 /* qeth_hdr must not cross element boundaries */ 3902 /* qeth_hdr must not cross element boundaries */
3985 if (element->length < offset + sizeof(struct qeth_hdr)) { 3903 if (element->length < offset + sizeof(struct qeth_hdr)) {
3986 if (qeth_is_last_sbale(element)) 3904 if (qeth_is_last_sbale(element))
@@ -4086,6 +4004,18 @@ static void qeth_unregister_dbf_views(void)
4086 } 4004 }
4087} 4005}
4088 4006
4007void qeth_dbf_longtext(enum qeth_dbf_names dbf_nix, int level, char *text, ...)
4008{
4009 char dbf_txt_buf[32];
4010
4011 if (level > (qeth_dbf[dbf_nix].id)->level)
4012 return;
4013 snprintf(dbf_txt_buf, sizeof(dbf_txt_buf), text);
4014 debug_text_event(qeth_dbf[dbf_nix].id, level, dbf_txt_buf);
4015
4016}
4017EXPORT_SYMBOL_GPL(qeth_dbf_longtext);
4018
4089static int qeth_register_dbf_views(void) 4019static int qeth_register_dbf_views(void)
4090{ 4020{
4091 int ret; 4021 int ret;
@@ -4433,6 +4363,96 @@ void qeth_core_get_drvinfo(struct net_device *dev,
4433} 4363}
4434EXPORT_SYMBOL_GPL(qeth_core_get_drvinfo); 4364EXPORT_SYMBOL_GPL(qeth_core_get_drvinfo);
4435 4365
4366int qeth_core_ethtool_get_settings(struct net_device *netdev,
4367 struct ethtool_cmd *ecmd)
4368{
4369 struct qeth_card *card = netdev_priv(netdev);
4370 enum qeth_link_types link_type;
4371
4372 if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan))
4373 link_type = QETH_LINK_TYPE_10GBIT_ETH;
4374 else
4375 link_type = card->info.link_type;
4376
4377 ecmd->transceiver = XCVR_INTERNAL;
4378 ecmd->supported = SUPPORTED_Autoneg;
4379 ecmd->advertising = ADVERTISED_Autoneg;
4380 ecmd->duplex = DUPLEX_FULL;
4381 ecmd->autoneg = AUTONEG_ENABLE;
4382
4383 switch (link_type) {
4384 case QETH_LINK_TYPE_FAST_ETH:
4385 case QETH_LINK_TYPE_LANE_ETH100:
4386 ecmd->supported |= SUPPORTED_10baseT_Half |
4387 SUPPORTED_10baseT_Full |
4388 SUPPORTED_100baseT_Half |
4389 SUPPORTED_100baseT_Full |
4390 SUPPORTED_TP;
4391 ecmd->advertising |= ADVERTISED_10baseT_Half |
4392 ADVERTISED_10baseT_Full |
4393 ADVERTISED_100baseT_Half |
4394 ADVERTISED_100baseT_Full |
4395 ADVERTISED_TP;
4396 ecmd->speed = SPEED_100;
4397 ecmd->port = PORT_TP;
4398 break;
4399
4400 case QETH_LINK_TYPE_GBIT_ETH:
4401 case QETH_LINK_TYPE_LANE_ETH1000:
4402 ecmd->supported |= SUPPORTED_10baseT_Half |
4403 SUPPORTED_10baseT_Full |
4404 SUPPORTED_100baseT_Half |
4405 SUPPORTED_100baseT_Full |
4406 SUPPORTED_1000baseT_Half |
4407 SUPPORTED_1000baseT_Full |
4408 SUPPORTED_FIBRE;
4409 ecmd->advertising |= ADVERTISED_10baseT_Half |
4410 ADVERTISED_10baseT_Full |
4411 ADVERTISED_100baseT_Half |
4412 ADVERTISED_100baseT_Full |
4413 ADVERTISED_1000baseT_Half |
4414 ADVERTISED_1000baseT_Full |
4415 ADVERTISED_FIBRE;
4416 ecmd->speed = SPEED_1000;
4417 ecmd->port = PORT_FIBRE;
4418 break;
4419
4420 case QETH_LINK_TYPE_10GBIT_ETH:
4421 ecmd->supported |= SUPPORTED_10baseT_Half |
4422 SUPPORTED_10baseT_Full |
4423 SUPPORTED_100baseT_Half |
4424 SUPPORTED_100baseT_Full |
4425 SUPPORTED_1000baseT_Half |
4426 SUPPORTED_1000baseT_Full |
4427 SUPPORTED_10000baseT_Full |
4428 SUPPORTED_FIBRE;
4429 ecmd->advertising |= ADVERTISED_10baseT_Half |
4430 ADVERTISED_10baseT_Full |
4431 ADVERTISED_100baseT_Half |
4432 ADVERTISED_100baseT_Full |
4433 ADVERTISED_1000baseT_Half |
4434 ADVERTISED_1000baseT_Full |
4435 ADVERTISED_10000baseT_Full |
4436 ADVERTISED_FIBRE;
4437 ecmd->speed = SPEED_10000;
4438 ecmd->port = PORT_FIBRE;
4439 break;
4440
4441 default:
4442 ecmd->supported |= SUPPORTED_10baseT_Half |
4443 SUPPORTED_10baseT_Full |
4444 SUPPORTED_TP;
4445 ecmd->advertising |= ADVERTISED_10baseT_Half |
4446 ADVERTISED_10baseT_Full |
4447 ADVERTISED_TP;
4448 ecmd->speed = SPEED_10;
4449 ecmd->port = PORT_TP;
4450 }
4451
4452 return 0;
4453}
4454EXPORT_SYMBOL_GPL(qeth_core_ethtool_get_settings);
4455
4436static int __init qeth_core_init(void) 4456static int __init qeth_core_init(void)
4437{ 4457{
4438 int rc; 4458 int rc;
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 3921d1631a78..86ec50ddae13 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -22,9 +22,6 @@
22#include "qeth_core.h" 22#include "qeth_core.h"
23#include "qeth_core_offl.h" 23#include "qeth_core_offl.h"
24 24
25#define QETH_DBF_TXT_BUF qeth_l2_dbf_txt_buf
26static DEFINE_PER_CPU(char[256], qeth_l2_dbf_txt_buf);
27
28static int qeth_l2_set_offline(struct ccwgroup_device *); 25static int qeth_l2_set_offline(struct ccwgroup_device *);
29static int qeth_l2_stop(struct net_device *); 26static int qeth_l2_stop(struct net_device *);
30static int qeth_l2_send_delmac(struct qeth_card *, __u8 *); 27static int qeth_l2_send_delmac(struct qeth_card *, __u8 *);
@@ -635,8 +632,6 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
635 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 632 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
636 struct qeth_eddp_context *ctx = NULL; 633 struct qeth_eddp_context *ctx = NULL;
637 634
638 QETH_DBF_TEXT(TRACE, 6, "l2xmit");
639
640 if ((card->state != CARD_STATE_UP) || !card->lan_online) { 635 if ((card->state != CARD_STATE_UP) || !card->lan_online) {
641 card->stats.tx_carrier_errors++; 636 card->stats.tx_carrier_errors++;
642 goto tx_drop; 637 goto tx_drop;
@@ -658,9 +653,12 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
658 if (card->info.type == QETH_CARD_TYPE_OSN) 653 if (card->info.type == QETH_CARD_TYPE_OSN)
659 hdr = (struct qeth_hdr *)skb->data; 654 hdr = (struct qeth_hdr *)skb->data;
660 else { 655 else {
661 new_skb = qeth_prepare_skb(card, skb, &hdr); 656 /* create a clone with writeable headroom */
657 new_skb = skb_realloc_headroom(skb, sizeof(struct qeth_hdr));
662 if (!new_skb) 658 if (!new_skb)
663 goto tx_drop; 659 goto tx_drop;
660 hdr = (struct qeth_hdr *)skb_push(new_skb,
661 sizeof(struct qeth_hdr));
664 qeth_l2_fill_header(card, hdr, new_skb, ipv, cast_type); 662 qeth_l2_fill_header(card, hdr, new_skb, ipv, cast_type);
665 } 663 }
666 664
@@ -747,7 +745,6 @@ static void qeth_l2_qdio_input_handler(struct ccw_device *ccwdev,
747 int index; 745 int index;
748 int i; 746 int i;
749 747
750 QETH_DBF_TEXT(TRACE, 6, "qdinput");
751 card = (struct qeth_card *) card_ptr; 748 card = (struct qeth_card *) card_ptr;
752 net_dev = card->dev; 749 net_dev = card->dev;
753 if (card->options.performance_stats) { 750 if (card->options.performance_stats) {
@@ -852,6 +849,22 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
852 return; 849 return;
853} 850}
854 851
852static int qeth_l2_ethtool_set_tso(struct net_device *dev, u32 data)
853{
854 struct qeth_card *card = netdev_priv(dev);
855
856 if (data) {
857 if (card->options.large_send == QETH_LARGE_SEND_NO) {
858 card->options.large_send = QETH_LARGE_SEND_EDDP;
859 dev->features |= NETIF_F_TSO;
860 }
861 } else {
862 dev->features &= ~NETIF_F_TSO;
863 card->options.large_send = QETH_LARGE_SEND_NO;
864 }
865 return 0;
866}
867
855static struct ethtool_ops qeth_l2_ethtool_ops = { 868static struct ethtool_ops qeth_l2_ethtool_ops = {
856 .get_link = ethtool_op_get_link, 869 .get_link = ethtool_op_get_link,
857 .get_tx_csum = ethtool_op_get_tx_csum, 870 .get_tx_csum = ethtool_op_get_tx_csum,
@@ -859,11 +872,12 @@ static struct ethtool_ops qeth_l2_ethtool_ops = {
859 .get_sg = ethtool_op_get_sg, 872 .get_sg = ethtool_op_get_sg,
860 .set_sg = ethtool_op_set_sg, 873 .set_sg = ethtool_op_set_sg,
861 .get_tso = ethtool_op_get_tso, 874 .get_tso = ethtool_op_get_tso,
862 .set_tso = ethtool_op_set_tso, 875 .set_tso = qeth_l2_ethtool_set_tso,
863 .get_strings = qeth_core_get_strings, 876 .get_strings = qeth_core_get_strings,
864 .get_ethtool_stats = qeth_core_get_ethtool_stats, 877 .get_ethtool_stats = qeth_core_get_ethtool_stats,
865 .get_stats_count = qeth_core_get_stats_count, 878 .get_stats_count = qeth_core_get_stats_count,
866 .get_drvinfo = qeth_core_get_drvinfo, 879 .get_drvinfo = qeth_core_get_drvinfo,
880 .get_settings = qeth_core_ethtool_get_settings,
867}; 881};
868 882
869static struct ethtool_ops qeth_l2_osn_ops = { 883static struct ethtool_ops qeth_l2_osn_ops = {
diff --git a/drivers/s390/net/qeth_l3.h b/drivers/s390/net/qeth_l3.h
index 1be353593a59..9f143c83bba3 100644
--- a/drivers/s390/net/qeth_l3.h
+++ b/drivers/s390/net/qeth_l3.h
@@ -13,9 +13,6 @@
13 13
14#include "qeth_core.h" 14#include "qeth_core.h"
15 15
16#define QETH_DBF_TXT_BUF qeth_l3_dbf_txt_buf
17DECLARE_PER_CPU(char[256], qeth_l3_dbf_txt_buf);
18
19struct qeth_ipaddr { 16struct qeth_ipaddr {
20 struct list_head entry; 17 struct list_head entry;
21 enum qeth_ip_types type; 18 enum qeth_ip_types type;
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index e1bfe56087d6..94a8ead64ed4 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -28,8 +28,6 @@
28#include "qeth_l3.h" 28#include "qeth_l3.h"
29#include "qeth_core_offl.h" 29#include "qeth_core_offl.h"
30 30
31DEFINE_PER_CPU(char[256], qeth_l3_dbf_txt_buf);
32
33static int qeth_l3_set_offline(struct ccwgroup_device *); 31static int qeth_l3_set_offline(struct ccwgroup_device *);
34static int qeth_l3_recover(void *); 32static int qeth_l3_recover(void *);
35static int qeth_l3_stop(struct net_device *); 33static int qeth_l3_stop(struct net_device *);
@@ -2093,6 +2091,11 @@ static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
2093 (card->state == CARD_STATE_UP)) { 2091 (card->state == CARD_STATE_UP)) {
2094 if (recovery_mode) 2092 if (recovery_mode)
2095 qeth_l3_stop(card->dev); 2093 qeth_l3_stop(card->dev);
2094 else {
2095 rtnl_lock();
2096 dev_close(card->dev);
2097 rtnl_unlock();
2098 }
2096 if (!card->use_hard_stop) { 2099 if (!card->use_hard_stop) {
2097 rc = qeth_send_stoplan(card); 2100 rc = qeth_send_stoplan(card);
2098 if (rc) 2101 if (rc)
@@ -2559,8 +2562,6 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2559static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, 2562static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2560 struct sk_buff *skb, int ipv, int cast_type) 2563 struct sk_buff *skb, int ipv, int cast_type)
2561{ 2564{
2562 QETH_DBF_TEXT(TRACE, 6, "fillhdr");
2563
2564 memset(hdr, 0, sizeof(struct qeth_hdr)); 2565 memset(hdr, 0, sizeof(struct qeth_hdr));
2565 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3; 2566 hdr->hdr.l3.id = QETH_HEADER_TYPE_LAYER3;
2566 hdr->hdr.l3.ext_flags = 0; 2567 hdr->hdr.l3.ext_flags = 0;
@@ -2570,9 +2571,10 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
2570 * v6 uses passthrough, v4 sets the tag in the QDIO header. 2571 * v6 uses passthrough, v4 sets the tag in the QDIO header.
2571 */ 2572 */
2572 if (card->vlangrp && vlan_tx_tag_present(skb)) { 2573 if (card->vlangrp && vlan_tx_tag_present(skb)) {
2573 hdr->hdr.l3.ext_flags = (ipv == 4) ? 2574 if ((ipv == 4) || (card->info.type == QETH_CARD_TYPE_IQD))
2574 QETH_HDR_EXT_VLAN_FRAME : 2575 hdr->hdr.l3.ext_flags = QETH_HDR_EXT_VLAN_FRAME;
2575 QETH_HDR_EXT_INCLUDE_VLAN_TAG; 2576 else
2577 hdr->hdr.l3.ext_flags = QETH_HDR_EXT_INCLUDE_VLAN_TAG;
2576 hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb); 2578 hdr->hdr.l3.vlan_id = vlan_tx_tag_get(skb);
2577 } 2579 }
2578 2580
@@ -2638,8 +2640,6 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
2638 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO; 2640 enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
2639 struct qeth_eddp_context *ctx = NULL; 2641 struct qeth_eddp_context *ctx = NULL;
2640 2642
2641 QETH_DBF_TEXT(TRACE, 6, "l3xmit");
2642
2643 if ((card->info.type == QETH_CARD_TYPE_IQD) && 2643 if ((card->info.type == QETH_CARD_TYPE_IQD) &&
2644 (skb->protocol != htons(ETH_P_IPV6)) && 2644 (skb->protocol != htons(ETH_P_IPV6)) &&
2645 (skb->protocol != htons(ETH_P_IP))) 2645 (skb->protocol != htons(ETH_P_IP)))
@@ -2890,6 +2890,7 @@ static struct ethtool_ops qeth_l3_ethtool_ops = {
2890 .get_ethtool_stats = qeth_core_get_ethtool_stats, 2890 .get_ethtool_stats = qeth_core_get_ethtool_stats,
2891 .get_stats_count = qeth_core_get_stats_count, 2891 .get_stats_count = qeth_core_get_stats_count,
2892 .get_drvinfo = qeth_core_get_drvinfo, 2892 .get_drvinfo = qeth_core_get_drvinfo,
2893 .get_settings = qeth_core_ethtool_get_settings,
2893}; 2894};
2894 2895
2895/* 2896/*
@@ -2982,7 +2983,6 @@ static void qeth_l3_qdio_input_handler(struct ccw_device *ccwdev,
2982 int index; 2983 int index;
2983 int i; 2984 int i;
2984 2985
2985 QETH_DBF_TEXT(TRACE, 6, "qdinput");
2986 card = (struct qeth_card *) card_ptr; 2986 card = (struct qeth_card *) card_ptr;
2987 net_dev = card->dev; 2987 net_dev = card->dev;
2988 if (card->options.performance_stats) { 2988 if (card->options.performance_stats) {
@@ -3140,9 +3140,15 @@ static int __qeth_l3_set_online(struct ccwgroup_device *gdev, int recovery_mode)
3140 netif_carrier_on(card->dev); 3140 netif_carrier_on(card->dev);
3141 3141
3142 qeth_set_allowed_threads(card, 0xffffffff, 0); 3142 qeth_set_allowed_threads(card, 0xffffffff, 0);
3143 if ((recover_flag == CARD_STATE_RECOVER) && recovery_mode) { 3143 if (recover_flag == CARD_STATE_RECOVER) {
3144 if (recovery_mode)
3144 qeth_l3_open(card->dev); 3145 qeth_l3_open(card->dev);
3145 qeth_l3_set_multicast_list(card->dev); 3146 else {
3147 rtnl_lock();
3148 dev_open(card->dev);
3149 rtnl_unlock();
3150 }
3151 qeth_l3_set_multicast_list(card->dev);
3146 } 3152 }
3147 /* let user_space know that device is online */ 3153 /* let user_space know that device is online */
3148 kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE); 3154 kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE);
diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c
index a4e758143665..235703414370 100644
--- a/drivers/sbus/char/cpwatchdog.c
+++ b/drivers/sbus/char/cpwatchdog.c
@@ -637,7 +637,7 @@ static int wd_inittimer(int whichdog)
637 break; 637 break;
638 default: 638 default:
639 printk("%s: %s: invalid watchdog id: %i\n", 639 printk("%s: %s: invalid watchdog id: %i\n",
640 WD_OBPNAME, __FUNCTION__, whichdog); 640 WD_OBPNAME, __func__, whichdog);
641 return(1); 641 return(1);
642 } 642 }
643 if(0 != misc_register(whichmisc)) 643 if(0 != misc_register(whichmisc))
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c
index 44d2ef906ac7..383f32c1d347 100644
--- a/drivers/sbus/char/uctrl.c
+++ b/drivers/sbus/char/uctrl.c
@@ -393,13 +393,13 @@ static int __init ts102_uctrl_init(void)
393 err = request_irq(driver->irq, uctrl_interrupt, 0, "uctrl", driver); 393 err = request_irq(driver->irq, uctrl_interrupt, 0, "uctrl", driver);
394 if (err) { 394 if (err) {
395 printk("%s: unable to register irq %d\n", 395 printk("%s: unable to register irq %d\n",
396 __FUNCTION__, driver->irq); 396 __func__, driver->irq);
397 return err; 397 return err;
398 } 398 }
399 399
400 if (misc_register(&uctrl_dev)) { 400 if (misc_register(&uctrl_dev)) {
401 printk("%s: unable to get misc minor %d\n", 401 printk("%s: unable to get misc minor %d\n",
402 __FUNCTION__, uctrl_dev.minor); 402 __func__, uctrl_dev.minor);
403 free_irq(driver->irq, driver); 403 free_irq(driver->irq, driver);
404 return -ENODEV; 404 return -ENODEV;
405 } 405 }
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 2b8a410e0959..bbf5bc5892c7 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -200,7 +200,7 @@ static void rs_stop(struct tty_struct *tty)
200 local_irq_restore(flags); 200 local_irq_restore(flags);
201} 201}
202 202
203static void rs_put_char(char ch) 203static int rs_put_char(char ch)
204{ 204{
205 int flags, loops = 0; 205 int flags, loops = 0;
206 206
@@ -214,6 +214,7 @@ static void rs_put_char(char ch)
214 UTX_TXDATA = ch; 214 UTX_TXDATA = ch;
215 udelay(5); 215 udelay(5);
216 local_irq_restore(flags); 216 local_irq_restore(flags);
217 return 1;
217} 218}
218 219
219static void rs_start(struct tty_struct *tty) 220static void rs_start(struct tty_struct *tty)
@@ -1017,18 +1018,6 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
1017 tty_wait_until_sent(tty, 0); 1018 tty_wait_until_sent(tty, 0);
1018 send_break(info, arg ? arg*(100) : 250); 1019 send_break(info, arg ? arg*(100) : 250);
1019 return 0; 1020 return 0;
1020 case TIOCGSOFTCAR:
1021 error = put_user(C_CLOCAL(tty) ? 1 : 0,
1022 (unsigned long *) arg);
1023 if (error)
1024 return error;
1025 return 0;
1026 case TIOCSSOFTCAR:
1027 get_user(arg, (unsigned long *) arg);
1028 tty->termios->c_cflag =
1029 ((tty->termios->c_cflag & ~CLOCAL) |
1030 (arg ? CLOCAL : 0));
1031 return 0;
1032 case TIOCGSERIAL: 1021 case TIOCGSERIAL:
1033 if (access_ok(VERIFY_WRITE, (void *) arg, 1022 if (access_ok(VERIFY_WRITE, (void *) arg,
1034 sizeof(struct serial_struct))) 1023 sizeof(struct serial_struct)))
@@ -1061,9 +1050,6 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1061{ 1050{
1062 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; 1051 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
1063 1052
1064 if (tty->termios->c_cflag == old_termios->c_cflag)
1065 return;
1066
1067 change_speed(info); 1053 change_speed(info);
1068 1054
1069 if ((old_termios->c_cflag & CRTSCTS) && 1055 if ((old_termios->c_cflag & CRTSCTS) &&
@@ -1140,8 +1126,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1140 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK); 1126 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
1141 1127
1142 shutdown(info); 1128 shutdown(info);
1143 if (tty->driver->flush_buffer) 1129 rs_flush_buffer(tty);
1144 tty->driver->flush_buffer(tty);
1145 1130
1146 tty_ldisc_flush(tty); 1131 tty_ldisc_flush(tty);
1147 tty->closing = 0; 1132 tty->closing = 0;
diff --git a/drivers/serial/68360serial.c b/drivers/serial/68360serial.c
index f59463601874..d9d4e9552a4d 100644
--- a/drivers/serial/68360serial.c
+++ b/drivers/serial/68360serial.c
@@ -995,10 +995,10 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
995 volatile QUICC_BD *bdp; 995 volatile QUICC_BD *bdp;
996 996
997 if (serial_paranoia_check(info, tty->name, "rs_put_char")) 997 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
998 return; 998 return 0;
999 999
1000 if (!tty) 1000 if (!tty)
1001 return; 1001 return 0;
1002 1002
1003 bdp = info->tx_cur; 1003 bdp = info->tx_cur;
1004 while (bdp->status & BD_SC_READY); 1004 while (bdp->status & BD_SC_READY);
@@ -1016,6 +1016,7 @@ static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
1016 bdp++; 1016 bdp++;
1017 1017
1018 info->tx_cur = (QUICC_BD *)bdp; 1018 info->tx_cur = (QUICC_BD *)bdp;
1019 return 1;
1019 1020
1020} 1021}
1021 1022
@@ -1246,7 +1247,7 @@ static int rs_360_tiocmget(struct tty_struct *tty, struct file *file)
1246#ifdef modem_control 1247#ifdef modem_control
1247 unsigned char control, status; 1248 unsigned char control, status;
1248 1249
1249 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1250 if (serial_paranoia_check(info, tty->name, __func__))
1250 return -ENODEV; 1251 return -ENODEV;
1251 1252
1252 if (tty->flags & (1 << TTY_IO_ERROR)) 1253 if (tty->flags & (1 << TTY_IO_ERROR))
@@ -1277,12 +1278,12 @@ static int rs_360_tiocmset(struct tty_struct *tty, struct file *file,
1277 ser_info_t *info = (ser_info_t *)tty->driver_data; 1278 ser_info_t *info = (ser_info_t *)tty->driver_data;
1278 unsigned int arg; 1279 unsigned int arg;
1279 1280
1280 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) 1281 if (serial_paranoia_check(info, tty->name, __func__))
1281 return -ENODEV; 1282 return -ENODEV;
1282 1283
1283 if (tty->flags & (1 << TTY_IO_ERROR)) 1284 if (tty->flags & (1 << TTY_IO_ERROR))
1284 return -EIO; 1285 return -EIO;
1285 1286 /* FIXME: locking on info->mcr */
1286 if (set & TIOCM_RTS) 1287 if (set & TIOCM_RTS)
1287 info->mcr |= UART_MCR_RTS; 1288 info->mcr |= UART_MCR_RTS;
1288 if (set & TIOCM_DTR) 1289 if (set & TIOCM_DTR)
@@ -1436,18 +1437,6 @@ static int rs_360_ioctl(struct tty_struct *tty, struct file * file,
1436 return retval; 1437 return retval;
1437 end_break(info); 1438 end_break(info);
1438 return 0; 1439 return 0;
1439 case TIOCGSOFTCAR:
1440 /* return put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg); */
1441 put_user(C_CLOCAL(tty) ? 1 : 0, (int *) arg);
1442 return 0;
1443 case TIOCSSOFTCAR:
1444 error = get_user(arg, (unsigned int *) arg);
1445 if (error)
1446 return error;
1447 tty->termios->c_cflag =
1448 ((tty->termios->c_cflag & ~CLOCAL) |
1449 (arg ? CLOCAL : 0));
1450 return 0;
1451#ifdef maybe 1440#ifdef maybe
1452 case TIOCSERGETLSR: /* Get line status register */ 1441 case TIOCSERGETLSR: /* Get line status register */
1453 return get_lsr_info(info, (unsigned int *) arg); 1442 return get_lsr_info(info, (unsigned int *) arg);
@@ -1665,8 +1654,7 @@ static void rs_360_close(struct tty_struct *tty, struct file * filp)
1665 rs_360_wait_until_sent(tty, info->timeout); 1654 rs_360_wait_until_sent(tty, info->timeout);
1666 } 1655 }
1667 shutdown(info); 1656 shutdown(info);
1668 if (tty->driver->flush_buffer) 1657 rs_360_flush_buffer(tty);
1669 tty->driver->flush_buffer(tty);
1670 tty_ldisc_flush(tty); 1658 tty_ldisc_flush(tty);
1671 tty->closing = 0; 1659 tty->closing = 0;
1672 info->event = 0; 1660 info->event = 0;
@@ -1717,6 +1705,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
1717 printk("jiff=%lu...", jiffies); 1705 printk("jiff=%lu...", jiffies);
1718#endif 1706#endif
1719 1707
1708 lock_kernel();
1720 /* We go through the loop at least once because we can't tell 1709 /* We go through the loop at least once because we can't tell
1721 * exactly when the last character exits the shifter. There can 1710 * exactly when the last character exits the shifter. There can
1722 * be at least two characters waiting to be sent after the buffers 1711 * be at least two characters waiting to be sent after the buffers
@@ -1745,6 +1734,7 @@ static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
1745 bdp--; 1734 bdp--;
1746 } while (bdp->status & BD_SC_READY); 1735 } while (bdp->status & BD_SC_READY);
1747 current->state = TASK_RUNNING; 1736 current->state = TASK_RUNNING;
1737 unlock_kernel();
1748#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT 1738#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
1749 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies); 1739 printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
1750#endif 1740#endif
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 38776e8b064b..cd898704ba4f 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -156,7 +156,7 @@ static int __init parse_options(struct early_serial8250_device *device,
156 port->membase = ioremap(port->mapbase, 64); 156 port->membase = ioremap(port->mapbase, 64);
157 if (!port->membase) { 157 if (!port->membase) {
158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n", 158 printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
159 __FUNCTION__, 159 __func__,
160 (unsigned long long)port->mapbase); 160 (unsigned long long)port->mapbase);
161 return -ENOMEM; 161 return -ENOMEM;
162 } 162 }
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 34b809e3b596..36acbcca2d48 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1355,4 +1355,47 @@ config SERIAL_SC26XX_CONSOLE
1355 help 1355 help
1356 Support for Console on SC2681/SC2692 serial ports. 1356 Support for Console on SC2681/SC2692 serial ports.
1357 1357
1358config SERIAL_BFIN_SPORT
1359 tristate "Blackfin SPORT emulate UART (EXPERIMENTAL)"
1360 depends on BFIN && EXPERIMENTAL
1361 select SERIAL_CORE
1362 help
1363 Enble support SPORT emulate UART on Blackfin series.
1364
1365 To compile this driver as a module, choose M here: the
1366 module will be called bfin_sport_uart.
1367
1368choice
1369 prompt "Baud rate for Blackfin SPORT UART"
1370 depends on SERIAL_BFIN_SPORT
1371 default SERIAL_SPORT_BAUD_RATE_57600
1372 help
1373 Choose a baud rate for the SPORT UART, other uart settings are
1374 8 bit, 1 stop bit, no parity, no flow control.
1375
1376config SERIAL_SPORT_BAUD_RATE_115200
1377 bool "115200"
1378
1379config SERIAL_SPORT_BAUD_RATE_57600
1380 bool "57600"
1381
1382config SERIAL_SPORT_BAUD_RATE_38400
1383 bool "38400"
1384
1385config SERIAL_SPORT_BAUD_RATE_19200
1386 bool "19200"
1387
1388config SERIAL_SPORT_BAUD_RATE_9600
1389 bool "9600"
1390endchoice
1391
1392config SPORT_BAUD_RATE
1393 int
1394 depends on SERIAL_BFIN_SPORT
1395 default 115200 if (SERIAL_SPORT_BAUD_RATE_115200)
1396 default 57600 if (SERIAL_SPORT_BAUD_RATE_57600)
1397 default 38400 if (SERIAL_SPORT_BAUD_RATE_38400)
1398 default 19200 if (SERIAL_SPORT_BAUD_RATE_19200)
1399 default 9600 if (SERIAL_SPORT_BAUD_RATE_9600)
1400
1358endmenu 1401endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index f02ff9fad017..0d9c09b1e836 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_SERIAL_PXA) += pxa.o
27obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o 27obj-$(CONFIG_SERIAL_PNX8XXX) += pnx8xxx_uart.o
28obj-$(CONFIG_SERIAL_SA1100) += sa1100.o 28obj-$(CONFIG_SERIAL_SA1100) += sa1100.o
29obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o 29obj-$(CONFIG_SERIAL_BFIN) += bfin_5xx.o
30obj-$(CONFIG_SERIAL_BFIN_SPORT) += bfin_sport_uart.o
30obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o 31obj-$(CONFIG_SERIAL_S3C2410) += s3c2410.o
31obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o 32obj-$(CONFIG_SERIAL_SUNCORE) += suncore.o
32obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o 33obj-$(CONFIG_SERIAL_SUNHV) += sunhv.o
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 5f55534a290b..8a2f6a1baa74 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -762,7 +762,7 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
762 break; 762 break;
763 default: 763 default:
764 printk(KERN_ERR "%s: word lengh not supported\n", 764 printk(KERN_ERR "%s: word lengh not supported\n",
765 __FUNCTION__); 765 __func__);
766 } 766 }
767 767
768 if (termios->c_cflag & CSTOPB) 768 if (termios->c_cflag & CSTOPB)
@@ -1029,7 +1029,7 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
1029 1029
1030 *baud = get_sclk() / (16*(dll | dlh << 8)); 1030 *baud = get_sclk() / (16*(dll | dlh << 8));
1031 } 1031 }
1032 pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __FUNCTION__, *baud, *parity, *bits); 1032 pr_debug("%s:baud = %d, parity = %c, bits= %d\n", __func__, *baud, *parity, *bits);
1033} 1033}
1034#endif 1034#endif
1035 1035
diff --git a/drivers/serial/bfin_sport_uart.c b/drivers/serial/bfin_sport_uart.c
new file mode 100644
index 000000000000..aca1240ad808
--- /dev/null
+++ b/drivers/serial/bfin_sport_uart.c
@@ -0,0 +1,614 @@
1/*
2 * File: linux/drivers/serial/bfin_sport_uart.c
3 *
4 * Based on: drivers/serial/bfin_5xx.c by Aubrey Li.
5 * Author: Roy Huang <roy.huang@analog.com>
6 *
7 * Created: Nov 22, 2006
8 * Copyright: (c) 2006-2007 Analog Devices Inc.
9 * Description: this driver enable SPORTs on Blackfin emulate UART.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see the file COPYING, or write
23 * to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27/*
28 * This driver and the hardware supported are in term of EE-191 of ADI.
29 * http://www.analog.com/UploadedFiles/Application_Notes/399447663EE191.pdf
30 * This application note describe how to implement a UART on a Sharc DSP,
31 * but this driver is implemented on Blackfin Processor.
32 */
33
34/* After reset, there is a prelude of low level pulse when transmit data first
35 * time. No addtional pulse in following transmit.
36 * According to document:
37 * The SPORTs are ready to start transmitting or receiving data no later than
38 * three serial clock cycles after they are enabled in the SPORTx_TCR1 or
39 * SPORTx_RCR1 register. No serial clock cycles are lost from this point on.
40 * The first internal frame sync will occur one frame sync delay after the
41 * SPORTs are ready. External frame syncs can occur as soon as the SPORT is
42 * ready.
43 */
44
45/* Thanks to Axel Alatalo <axel@rubico.se> for fixing sport rx bug. Sometimes
46 * sport receives data incorrectly. The following is Axel's words.
47 * As EE-191, sport rx samples 3 times of the UART baudrate and takes the
48 * middle smaple of every 3 samples as the data bit. For a 8-N-1 UART setting,
49 * 30 samples will be required for a byte. If transmitter sends a 1/3 bit short
50 * byte due to buadrate drift, then the 30th sample of a byte, this sample is
51 * also the third sample of the stop bit, will happens on the immediately
52 * following start bit which will be thrown away and missed. Thus since parts
53 * of the startbit will be missed and the receiver will begin to drift, the
54 * effect accumulates over time until synchronization is lost.
55 * If only require 2 samples of the stopbit (by sampling in total 29 samples),
56 * then a to short byte as in the case above will be tolerated. Then the 1/3
57 * early startbit will trigger a framesync since the last read is complete
58 * after only 2/3 stopbit and framesync is active during the last 1/3 looking
59 * for a possible early startbit. */
60
61//#define DEBUG
62
63#include <linux/module.h>
64#include <linux/ioport.h>
65#include <linux/init.h>
66#include <linux/console.h>
67#include <linux/sysrq.h>
68#include <linux/platform_device.h>
69#include <linux/tty.h>
70#include <linux/tty_flip.h>
71#include <linux/serial_core.h>
72
73#include <asm/delay.h>
74#include <asm/portmux.h>
75
76#include "bfin_sport_uart.h"
77
78unsigned short bfin_uart_pin_req_sport0[] =
79 {P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS, \
80 P_SPORT0_DRPRI, P_SPORT0_RSCLK, P_SPORT0_DRSEC, P_SPORT0_DTSEC, 0};
81
82unsigned short bfin_uart_pin_req_sport1[] =
83 {P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS, \
84 P_SPORT1_DRPRI, P_SPORT1_RSCLK, P_SPORT1_DRSEC, P_SPORT1_DTSEC, 0};
85
86#define DRV_NAME "bfin-sport-uart"
87
88struct sport_uart_port {
89 struct uart_port port;
90 char *name;
91
92 int tx_irq;
93 int rx_irq;
94 int err_irq;
95};
96
97static void sport_uart_tx_chars(struct sport_uart_port *up);
98static void sport_stop_tx(struct uart_port *port);
99
100static inline void tx_one_byte(struct sport_uart_port *up, unsigned int value)
101{
102 pr_debug("%s value:%x\n", __FUNCTION__, value);
103 /* Place a Start and Stop bit */
104 __asm__ volatile (
105 "R2 = b#01111111100;\n\t"
106 "R3 = b#10000000001;\n\t"
107 "%0 <<= 2;\n\t"
108 "%0 = %0 & R2;\n\t"
109 "%0 = %0 | R3;\n\t"
110 :"=r"(value)
111 :"0"(value)
112 :"R2", "R3");
113 pr_debug("%s value:%x\n", __FUNCTION__, value);
114
115 SPORT_PUT_TX(up, value);
116}
117
118static inline unsigned int rx_one_byte(struct sport_uart_port *up)
119{
120 unsigned int value, extract;
121
122 value = SPORT_GET_RX32(up);
123 pr_debug("%s value:%x\n", __FUNCTION__, value);
124
125 /* Extract 8 bits data */
126 __asm__ volatile (
127 "R5 = 0;\n\t"
128 "P0 = 8;\n\t"
129 "R1 = 0x1801(Z);\n\t"
130 "R3 = 0x0300(Z);\n\t"
131 "R4 = 0;\n\t"
132 "LSETUP(loop_s, loop_e) LC0 = P0;\nloop_s:\t"
133 "R2 = extract(%1, R1.L)(Z);\n\t"
134 "R2 <<= R4;\n\t"
135 "R5 = R5 | R2;\n\t"
136 "R1 = R1 - R3;\nloop_e:\t"
137 "R4 += 1;\n\t"
138 "%0 = R5;\n\t"
139 :"=r"(extract)
140 :"r"(value)
141 :"P0", "R1", "R2","R3","R4", "R5");
142
143 pr_debug(" extract:%x\n", extract);
144 return extract;
145}
146
147static int sport_uart_setup(struct sport_uart_port *up, int sclk, int baud_rate)
148{
149 int tclkdiv, tfsdiv, rclkdiv;
150
151 /* Set TCR1 and TCR2 */
152 SPORT_PUT_TCR1(up, (LTFS | ITFS | TFSR | TLSBIT | ITCLK));
153 SPORT_PUT_TCR2(up, 10);
154 pr_debug("%s TCR1:%x, TCR2:%x\n", __FUNCTION__, SPORT_GET_TCR1(up), SPORT_GET_TCR2(up));
155
156 /* Set RCR1 and RCR2 */
157 SPORT_PUT_RCR1(up, (RCKFE | LARFS | LRFS | RFSR | IRCLK));
158 SPORT_PUT_RCR2(up, 28);
159 pr_debug("%s RCR1:%x, RCR2:%x\n", __FUNCTION__, SPORT_GET_RCR1(up), SPORT_GET_RCR2(up));
160
161 tclkdiv = sclk/(2 * baud_rate) - 1;
162 tfsdiv = 12;
163 rclkdiv = sclk/(2 * baud_rate * 3) - 1;
164 SPORT_PUT_TCLKDIV(up, tclkdiv);
165 SPORT_PUT_TFSDIV(up, tfsdiv);
166 SPORT_PUT_RCLKDIV(up, rclkdiv);
167 SSYNC();
168 pr_debug("%s sclk:%d, baud_rate:%d, tclkdiv:%d, tfsdiv:%d, rclkdiv:%d\n",
169 __FUNCTION__, sclk, baud_rate, tclkdiv, tfsdiv, rclkdiv);
170
171 return 0;
172}
173
174static irqreturn_t sport_uart_rx_irq(int irq, void *dev_id)
175{
176 struct sport_uart_port *up = dev_id;
177 struct tty_struct *tty = up->port.info->tty;
178 unsigned int ch;
179
180 do {
181 ch = rx_one_byte(up);
182 up->port.icount.rx++;
183
184 if (uart_handle_sysrq_char(&up->port, ch))
185 ;
186 else
187 tty_insert_flip_char(tty, ch, TTY_NORMAL);
188 } while (SPORT_GET_STAT(up) & RXNE);
189 tty_flip_buffer_push(tty);
190
191 return IRQ_HANDLED;
192}
193
194static irqreturn_t sport_uart_tx_irq(int irq, void *dev_id)
195{
196 sport_uart_tx_chars(dev_id);
197
198 return IRQ_HANDLED;
199}
200
201static irqreturn_t sport_uart_err_irq(int irq, void *dev_id)
202{
203 struct sport_uart_port *up = dev_id;
204 struct tty_struct *tty = up->port.info->tty;
205 unsigned int stat = SPORT_GET_STAT(up);
206
207 /* Overflow in RX FIFO */
208 if (stat & ROVF) {
209 up->port.icount.overrun++;
210 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
211 SPORT_PUT_STAT(up, ROVF); /* Clear ROVF bit */
212 }
213 /* These should not happen */
214 if (stat & (TOVF | TUVF | RUVF)) {
215 printk(KERN_ERR "SPORT Error:%s %s %s\n",
216 (stat & TOVF)?"TX overflow":"",
217 (stat & TUVF)?"TX underflow":"",
218 (stat & RUVF)?"RX underflow":"");
219 SPORT_PUT_TCR1(up, SPORT_GET_TCR1(up) & ~TSPEN);
220 SPORT_PUT_RCR1(up, SPORT_GET_RCR1(up) & ~RSPEN);
221 }
222 SSYNC();
223
224 return IRQ_HANDLED;
225}
226
227/* Reqeust IRQ, Setup clock */
228static int sport_startup(struct uart_port *port)
229{
230 struct sport_uart_port *up = (struct sport_uart_port *)port;
231 char buffer[20];
232 int retval;
233
234 pr_debug("%s enter\n", __FUNCTION__);
235 memset(buffer, 20, '\0');
236 snprintf(buffer, 20, "%s rx", up->name);
237 retval = request_irq(up->rx_irq, sport_uart_rx_irq, IRQF_SAMPLE_RANDOM, buffer, up);
238 if (retval) {
239 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
240 return retval;
241 }
242
243 snprintf(buffer, 20, "%s tx", up->name);
244 retval = request_irq(up->tx_irq, sport_uart_tx_irq, IRQF_SAMPLE_RANDOM, buffer, up);
245 if (retval) {
246 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
247 goto fail1;
248 }
249
250 snprintf(buffer, 20, "%s err", up->name);
251 retval = request_irq(up->err_irq, sport_uart_err_irq, IRQF_SAMPLE_RANDOM, buffer, up);
252 if (retval) {
253 printk(KERN_ERR "Unable to request interrupt %s\n", buffer);
254 goto fail2;
255 }
256
257 if (port->line) {
258 if (peripheral_request_list(bfin_uart_pin_req_sport1, DRV_NAME))
259 goto fail3;
260 } else {
261 if (peripheral_request_list(bfin_uart_pin_req_sport0, DRV_NAME))
262 goto fail3;
263 }
264
265 sport_uart_setup(up, get_sclk(), port->uartclk);
266
267 /* Enable receive interrupt */
268 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) | RSPEN));
269 SSYNC();
270
271 return 0;
272
273
274fail3:
275 printk(KERN_ERR DRV_NAME
276 ": Requesting Peripherals failed\n");
277
278 free_irq(up->err_irq, up);
279fail2:
280 free_irq(up->tx_irq, up);
281fail1:
282 free_irq(up->rx_irq, up);
283
284 return retval;
285
286}
287
288static void sport_uart_tx_chars(struct sport_uart_port *up)
289{
290 struct circ_buf *xmit = &up->port.info->xmit;
291
292 if (SPORT_GET_STAT(up) & TXF)
293 return;
294
295 if (up->port.x_char) {
296 tx_one_byte(up, up->port.x_char);
297 up->port.icount.tx++;
298 up->port.x_char = 0;
299 return;
300 }
301
302 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
303 sport_stop_tx(&up->port);
304 return;
305 }
306
307 while(!(SPORT_GET_STAT(up) & TXF) && !uart_circ_empty(xmit)) {
308 tx_one_byte(up, xmit->buf[xmit->tail]);
309 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE -1);
310 up->port.icount.tx++;
311 }
312
313 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
314 uart_write_wakeup(&up->port);
315}
316
317static unsigned int sport_tx_empty(struct uart_port *port)
318{
319 struct sport_uart_port *up = (struct sport_uart_port *)port;
320 unsigned int stat;
321
322 stat = SPORT_GET_STAT(up);
323 pr_debug("%s stat:%04x\n", __FUNCTION__, stat);
324 if (stat & TXHRE) {
325 return TIOCSER_TEMT;
326 } else
327 return 0;
328}
329
330static unsigned int sport_get_mctrl(struct uart_port *port)
331{
332 pr_debug("%s enter\n", __FUNCTION__);
333 return (TIOCM_CTS | TIOCM_CD | TIOCM_DSR);
334}
335
336static void sport_set_mctrl(struct uart_port *port, unsigned int mctrl)
337{
338 pr_debug("%s enter\n", __FUNCTION__);
339}
340
341static void sport_stop_tx(struct uart_port *port)
342{
343 struct sport_uart_port *up = (struct sport_uart_port *)port;
344 unsigned int stat;
345
346 pr_debug("%s enter\n", __FUNCTION__);
347
348 stat = SPORT_GET_STAT(up);
349 while(!(stat & TXHRE)) {
350 udelay(1);
351 stat = SPORT_GET_STAT(up);
352 }
353 /* Although the hold register is empty, last byte is still in shift
354 * register and not sent out yet. If baud rate is lower than default,
355 * delay should be longer. For example, if the baud rate is 9600,
356 * the delay must be at least 2ms by experience */
357 udelay(500);
358
359 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN));
360 SSYNC();
361
362 return;
363}
364
365static void sport_start_tx(struct uart_port *port)
366{
367 struct sport_uart_port *up = (struct sport_uart_port *)port;
368
369 pr_debug("%s enter\n", __FUNCTION__);
370 /* Write data into SPORT FIFO before enable SPROT to transmit */
371 sport_uart_tx_chars(up);
372
373 /* Enable transmit, then an interrupt will generated */
374 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) | TSPEN));
375 SSYNC();
376 pr_debug("%s exit\n", __FUNCTION__);
377}
378
379static void sport_stop_rx(struct uart_port *port)
380{
381 struct sport_uart_port *up = (struct sport_uart_port *)port;
382
383 pr_debug("%s enter\n", __FUNCTION__);
384 /* Disable sport to stop rx */
385 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) & ~RSPEN));
386 SSYNC();
387}
388
389static void sport_enable_ms(struct uart_port *port)
390{
391 pr_debug("%s enter\n", __FUNCTION__);
392}
393
394static void sport_break_ctl(struct uart_port *port, int break_state)
395{
396 pr_debug("%s enter\n", __FUNCTION__);
397}
398
399static void sport_shutdown(struct uart_port *port)
400{
401 struct sport_uart_port *up = (struct sport_uart_port *)port;
402
403 pr_debug("%s enter\n", __FUNCTION__);
404
405 /* Disable sport */
406 SPORT_PUT_TCR1(up, (SPORT_GET_TCR1(up) & ~TSPEN));
407 SPORT_PUT_RCR1(up, (SPORT_GET_RCR1(up) & ~RSPEN));
408 SSYNC();
409
410 if (port->line) {
411 peripheral_free_list(bfin_uart_pin_req_sport1);
412 } else {
413 peripheral_free_list(bfin_uart_pin_req_sport0);
414 }
415
416 free_irq(up->rx_irq, up);
417 free_irq(up->tx_irq, up);
418 free_irq(up->err_irq, up);
419}
420
421static void sport_set_termios(struct uart_port *port,
422 struct termios *termios, struct termios *old)
423{
424 pr_debug("%s enter, c_cflag:%08x\n", __FUNCTION__, termios->c_cflag);
425 uart_update_timeout(port, CS8 ,port->uartclk);
426}
427
428static const char *sport_type(struct uart_port *port)
429{
430 struct sport_uart_port *up = (struct sport_uart_port *)port;
431
432 pr_debug("%s enter\n", __FUNCTION__);
433 return up->name;
434}
435
436static void sport_release_port(struct uart_port *port)
437{
438 pr_debug("%s enter\n", __FUNCTION__);
439}
440
441static int sport_request_port(struct uart_port *port)
442{
443 pr_debug("%s enter\n", __FUNCTION__);
444 return 0;
445}
446
447static void sport_config_port(struct uart_port *port, int flags)
448{
449 struct sport_uart_port *up = (struct sport_uart_port *)port;
450
451 pr_debug("%s enter\n", __FUNCTION__);
452 up->port.type = PORT_BFIN_SPORT;
453}
454
455static int sport_verify_port(struct uart_port *port, struct serial_struct *ser)
456{
457 pr_debug("%s enter\n", __FUNCTION__);
458 return 0;
459}
460
461struct uart_ops sport_uart_ops = {
462 .tx_empty = sport_tx_empty,
463 .set_mctrl = sport_set_mctrl,
464 .get_mctrl = sport_get_mctrl,
465 .stop_tx = sport_stop_tx,
466 .start_tx = sport_start_tx,
467 .stop_rx = sport_stop_rx,
468 .enable_ms = sport_enable_ms,
469 .break_ctl = sport_break_ctl,
470 .startup = sport_startup,
471 .shutdown = sport_shutdown,
472 .set_termios = sport_set_termios,
473 .type = sport_type,
474 .release_port = sport_release_port,
475 .request_port = sport_request_port,
476 .config_port = sport_config_port,
477 .verify_port = sport_verify_port,
478};
479
480static struct sport_uart_port sport_uart_ports[] = {
481 { /* SPORT 0 */
482 .name = "SPORT0",
483 .tx_irq = IRQ_SPORT0_TX,
484 .rx_irq = IRQ_SPORT0_RX,
485 .err_irq= IRQ_SPORT0_ERROR,
486 .port = {
487 .type = PORT_BFIN_SPORT,
488 .iotype = UPIO_MEM,
489 .membase = (void __iomem *)SPORT0_TCR1,
490 .mapbase = SPORT0_TCR1,
491 .irq = IRQ_SPORT0_RX,
492 .uartclk = CONFIG_SPORT_BAUD_RATE,
493 .fifosize = 8,
494 .ops = &sport_uart_ops,
495 .line = 0,
496 },
497 }, { /* SPORT 1 */
498 .name = "SPORT1",
499 .tx_irq = IRQ_SPORT1_TX,
500 .rx_irq = IRQ_SPORT1_RX,
501 .err_irq= IRQ_SPORT1_ERROR,
502 .port = {
503 .type = PORT_BFIN_SPORT,
504 .iotype = UPIO_MEM,
505 .membase = (void __iomem *)SPORT1_TCR1,
506 .mapbase = SPORT1_TCR1,
507 .irq = IRQ_SPORT1_RX,
508 .uartclk = CONFIG_SPORT_BAUD_RATE,
509 .fifosize = 8,
510 .ops = &sport_uart_ops,
511 .line = 1,
512 },
513 }
514};
515
516static struct uart_driver sport_uart_reg = {
517 .owner = THIS_MODULE,
518 .driver_name = "SPORT-UART",
519 .dev_name = "ttySS",
520 .major = 204,
521 .minor = 84,
522 .nr = ARRAY_SIZE(sport_uart_ports),
523 .cons = NULL,
524};
525
526static int sport_uart_suspend(struct platform_device *dev, pm_message_t state)
527{
528 struct sport_uart_port *sport = platform_get_drvdata(dev);
529
530 pr_debug("%s enter\n", __FUNCTION__);
531 if (sport)
532 uart_suspend_port(&sport_uart_reg, &sport->port);
533
534 return 0;
535}
536
537static int sport_uart_resume(struct platform_device *dev)
538{
539 struct sport_uart_port *sport = platform_get_drvdata(dev);
540
541 pr_debug("%s enter\n", __FUNCTION__);
542 if (sport)
543 uart_resume_port(&sport_uart_reg, &sport->port);
544
545 return 0;
546}
547
548static int sport_uart_probe(struct platform_device *dev)
549{
550 pr_debug("%s enter\n", __FUNCTION__);
551 sport_uart_ports[dev->id].port.dev = &dev->dev;
552 uart_add_one_port(&sport_uart_reg, &sport_uart_ports[dev->id].port);
553 platform_set_drvdata(dev, &sport_uart_ports[dev->id]);
554
555 return 0;
556}
557
558static int sport_uart_remove(struct platform_device *dev)
559{
560 struct sport_uart_port *sport = platform_get_drvdata(dev);
561
562 pr_debug("%s enter\n", __FUNCTION__);
563 platform_set_drvdata(dev, NULL);
564
565 if (sport)
566 uart_remove_one_port(&sport_uart_reg, &sport->port);
567
568 return 0;
569}
570
571static struct platform_driver sport_uart_driver = {
572 .probe = sport_uart_probe,
573 .remove = sport_uart_remove,
574 .suspend = sport_uart_suspend,
575 .resume = sport_uart_resume,
576 .driver = {
577 .name = DRV_NAME,
578 },
579};
580
581static int __init sport_uart_init(void)
582{
583 int ret;
584
585 pr_debug("%s enter\n", __FUNCTION__);
586 ret = uart_register_driver(&sport_uart_reg);
587 if (ret != 0) {
588 printk(KERN_ERR "Failed to register %s:%d\n",
589 sport_uart_reg.driver_name, ret);
590 return ret;
591 }
592
593 ret = platform_driver_register(&sport_uart_driver);
594 if (ret != 0) {
595 printk(KERN_ERR "Failed to register sport uart driver:%d\n", ret);
596 uart_unregister_driver(&sport_uart_reg);
597 }
598
599
600 pr_debug("%s exit\n", __FUNCTION__);
601 return ret;
602}
603
604static void __exit sport_uart_exit(void)
605{
606 pr_debug("%s enter\n", __FUNCTION__);
607 platform_driver_unregister(&sport_uart_driver);
608 uart_unregister_driver(&sport_uart_reg);
609}
610
611module_init(sport_uart_init);
612module_exit(sport_uart_exit);
613
614MODULE_LICENSE("GPL");
diff --git a/drivers/serial/bfin_sport_uart.h b/drivers/serial/bfin_sport_uart.h
new file mode 100644
index 000000000000..671d41cc1a3f
--- /dev/null
+++ b/drivers/serial/bfin_sport_uart.h
@@ -0,0 +1,63 @@
1/*
2 * File: linux/drivers/serial/bfin_sport_uart.h
3 *
4 * Based on: include/asm-blackfin/mach-533/bfin_serial_5xx.h
5 * Author: Roy Huang <roy.huang>analog.com>
6 *
7 * Created: Nov 22, 2006
8 * Copyright: (C) Analog Device Inc.
9 * Description: this driver enable SPORTs on Blackfin emulate UART.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see the file COPYING, or write
23 * to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27
28#define OFFSET_TCR1 0x00 /* Transmit Configuration 1 Register */
29#define OFFSET_TCR2 0x04 /* Transmit Configuration 2 Register */
30#define OFFSET_TCLKDIV 0x08 /* Transmit Serial Clock Divider Register */
31#define OFFSET_TFSDIV 0x0C /* Transmit Frame Sync Divider Register */
32#define OFFSET_TX 0x10 /* Transmit Data Register */
33#define OFFSET_RX 0x18 /* Receive Data Register */
34#define OFFSET_RCR1 0x20 /* Receive Configuration 1 Register */
35#define OFFSET_RCR2 0x24 /* Receive Configuration 2 Register */
36#define OFFSET_RCLKDIV 0x28 /* Receive Serial Clock Divider Register */
37#define OFFSET_RFSDIV 0x2c /* Receive Frame Sync Divider Register */
38#define OFFSET_STAT 0x30 /* Status Register */
39
40#define SPORT_GET_TCR1(sport) bfin_read16(((sport)->port.membase + OFFSET_TCR1))
41#define SPORT_GET_TCR2(sport) bfin_read16(((sport)->port.membase + OFFSET_TCR2))
42#define SPORT_GET_TCLKDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_TCLKDIV))
43#define SPORT_GET_TFSDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_TFSDIV))
44#define SPORT_GET_TX(sport) bfin_read16(((sport)->port.membase + OFFSET_TX))
45#define SPORT_GET_RX(sport) bfin_read16(((sport)->port.membase + OFFSET_RX))
46#define SPORT_GET_RX32(sport) bfin_read32(((sport)->port.membase + OFFSET_RX))
47#define SPORT_GET_RCR1(sport) bfin_read16(((sport)->port.membase + OFFSET_RCR1))
48#define SPORT_GET_RCR2(sport) bfin_read16(((sport)->port.membase + OFFSET_RCR2))
49#define SPORT_GET_RCLKDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_RCLKDIV))
50#define SPORT_GET_RFSDIV(sport) bfin_read16(((sport)->port.membase + OFFSET_RFSDIV))
51#define SPORT_GET_STAT(sport) bfin_read16(((sport)->port.membase + OFFSET_STAT))
52
53#define SPORT_PUT_TCR1(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCR1), v)
54#define SPORT_PUT_TCR2(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCR2), v)
55#define SPORT_PUT_TCLKDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TCLKDIV), v)
56#define SPORT_PUT_TFSDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TFSDIV), v)
57#define SPORT_PUT_TX(sport, v) bfin_write16(((sport)->port.membase + OFFSET_TX), v)
58#define SPORT_PUT_RX(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RX), v)
59#define SPORT_PUT_RCR1(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCR1), v)
60#define SPORT_PUT_RCR2(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCR2), v)
61#define SPORT_PUT_RCLKDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RCLKDIV), v)
62#define SPORT_PUT_RFSDIV(sport, v) bfin_write16(((sport)->port.membase + OFFSET_RFSDIV), v)
63#define SPORT_PUT_STAT(sport, v) bfin_write16(((sport)->port.membase + OFFSET_STAT), v)
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index a638ba0679ac..a19dc7ef8861 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -1117,7 +1117,7 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con)
1117 1117
1118 line = cpm_uart_id2nr(idx); 1118 line = cpm_uart_id2nr(idx);
1119 if(line < 0) { 1119 if(line < 0) {
1120 printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx); 1120 printk(KERN_ERR"%s(): port %d is not registered", __func__, idx);
1121 return -EINVAL; 1121 return -EINVAL;
1122 } 1122 }
1123 1123
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index 88e7c1d5b919..f9fa237aa949 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -1788,7 +1788,7 @@ static unsigned int handle_descr_data(struct e100_serial *info,
1788 1788
1789 if (info->recv_cnt + recvl > 65536) { 1789 if (info->recv_cnt + recvl > 65536) {
1790 printk(KERN_CRIT 1790 printk(KERN_CRIT
1791 "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __FUNCTION__, recvl); 1791 "%s: Too much pending incoming serial data! Dropping %u bytes.\n", __func__, recvl);
1792 return 0; 1792 return 0;
1793 } 1793 }
1794 1794
@@ -1801,7 +1801,7 @@ static unsigned int handle_descr_data(struct e100_serial *info,
1801 append_recv_buffer(info, buffer); 1801 append_recv_buffer(info, buffer);
1802 1802
1803 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE))) 1803 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
1804 panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__); 1804 panic("%s: Failed to allocate memory for receive buffer!\n", __func__);
1805 1805
1806 descr->buf = virt_to_phys(buffer->buffer); 1806 descr->buf = virt_to_phys(buffer->buffer);
1807 1807
@@ -1925,7 +1925,7 @@ static int start_recv_dma(struct e100_serial *info)
1925 /* Set up the receiving descriptors */ 1925 /* Set up the receiving descriptors */
1926 for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) { 1926 for (i = 0; i < SERIAL_RECV_DESCRIPTORS; i++) {
1927 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE))) 1927 if (!(buffer = alloc_recv_buffer(SERIAL_DESCR_BUF_SIZE)))
1928 panic("%s: Failed to allocate memory for receive buffer!\n", __FUNCTION__); 1928 panic("%s: Failed to allocate memory for receive buffer!\n", __func__);
1929 1929
1930 descr[i].ctrl = d_int; 1930 descr[i].ctrl = d_int;
1931 descr[i].buf = virt_to_phys(buffer->buffer); 1931 descr[i].buf = virt_to_phys(buffer->buffer);
@@ -3581,8 +3581,9 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
3581 unsigned int set, unsigned int clear) 3581 unsigned int set, unsigned int clear)
3582{ 3582{
3583 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3583 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3584 unsigned long flags;
3584 3585
3585 lock_kernel(); 3586 local_irq_save(flags);
3586 3587
3587 if (clear & TIOCM_RTS) 3588 if (clear & TIOCM_RTS)
3588 e100_rts(info, 0); 3589 e100_rts(info, 0);
@@ -3604,7 +3605,7 @@ rs_tiocmset(struct tty_struct *tty, struct file *file,
3604 if (set & TIOCM_CD) 3605 if (set & TIOCM_CD)
3605 e100_cd_out(info, 1); 3606 e100_cd_out(info, 1);
3606 3607
3607 unlock_kernel(); 3608 local_irq_restore(flags);
3608 return 0; 3609 return 0;
3609} 3610}
3610 3611
@@ -3613,8 +3614,10 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
3613{ 3614{
3614 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3615 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3615 unsigned int result; 3616 unsigned int result;
3617 unsigned long flags;
3618
3619 local_irq_save(flags);
3616 3620
3617 lock_kernel();
3618 result = 3621 result =
3619 (!E100_RTS_GET(info) ? TIOCM_RTS : 0) 3622 (!E100_RTS_GET(info) ? TIOCM_RTS : 0)
3620 | (!E100_DTR_GET(info) ? TIOCM_DTR : 0) 3623 | (!E100_DTR_GET(info) ? TIOCM_DTR : 0)
@@ -3623,7 +3626,7 @@ rs_tiocmget(struct tty_struct *tty, struct file *file)
3623 | (!E100_CD_GET(info) ? TIOCM_CAR : 0) 3626 | (!E100_CD_GET(info) ? TIOCM_CAR : 0)
3624 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0); 3627 | (!E100_CTS_GET(info) ? TIOCM_CTS : 0);
3625 3628
3626 unlock_kernel(); 3629 local_irq_restore(flags);
3627 3630
3628#ifdef SERIAL_DEBUG_IO 3631#ifdef SERIAL_DEBUG_IO
3629 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n", 3632 printk(KERN_DEBUG "ser%i: modem state: %i 0x%08X\n",
@@ -3702,10 +3705,6 @@ rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
3702{ 3705{
3703 struct e100_serial *info = (struct e100_serial *)tty->driver_data; 3706 struct e100_serial *info = (struct e100_serial *)tty->driver_data;
3704 3707
3705 if (tty->termios->c_cflag == old_termios->c_cflag &&
3706 tty->termios->c_iflag == old_termios->c_iflag)
3707 return;
3708
3709 change_speed(info); 3708 change_speed(info);
3710 3709
3711 /* Handle turning off CRTSCTS */ 3710 /* Handle turning off CRTSCTS */
@@ -3808,10 +3807,8 @@ rs_close(struct tty_struct *tty, struct file * filp)
3808#endif 3807#endif
3809 3808
3810 shutdown(info); 3809 shutdown(info);
3811 if (tty->driver->flush_buffer) 3810 rs_flush_buffer(tty);
3812 tty->driver->flush_buffer(tty); 3811 tty_ldisc_flush_buffer(tty);
3813 if (tty->ldisc.flush_buffer)
3814 tty->ldisc.flush_buffer(tty);
3815 tty->closing = 0; 3812 tty->closing = 0;
3816 info->event = 0; 3813 info->event = 0;
3817 info->tty = 0; 3814 info->tty = 0;
@@ -3885,6 +3882,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
3885 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO 3882 * Check R_DMA_CHx_STATUS bit 0-6=number of available bytes in FIFO
3886 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k) 3883 * R_DMA_CHx_HWSW bit 31-16=nbr of bytes left in DMA buffer (0=64k)
3887 */ 3884 */
3885 lock_kernel();
3888 orig_jiffies = jiffies; 3886 orig_jiffies = jiffies;
3889 while (info->xmit.head != info->xmit.tail || /* More in send queue */ 3887 while (info->xmit.head != info->xmit.tail || /* More in send queue */
3890 (*info->ostatusadr & 0x007f) || /* more in FIFO */ 3888 (*info->ostatusadr & 0x007f) || /* more in FIFO */
@@ -3901,6 +3899,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
3901 curr_time_usec - info->last_tx_active_usec; 3899 curr_time_usec - info->last_tx_active_usec;
3902 } 3900 }
3903 set_current_state(TASK_RUNNING); 3901 set_current_state(TASK_RUNNING);
3902 unlock_kernel();
3904} 3903}
3905 3904
3906/* 3905/*
@@ -4520,7 +4519,7 @@ rs_init(void)
4520 4519
4521 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt, 4520 if (request_irq(SERIAL_IRQ_NBR, ser_interrupt,
4522 IRQF_SHARED | IRQF_DISABLED, "serial ", driver)) 4521 IRQF_SHARED | IRQF_DISABLED, "serial ", driver))
4523 panic("%s: Failed to request irq8", __FUNCTION__); 4522 panic("%s: Failed to request irq8", __func__);
4524 4523
4525#endif 4524#endif
4526#endif /* CONFIG_SVINTO_SIM */ 4525#endif /* CONFIG_SVINTO_SIM */
diff --git a/drivers/serial/ioc3_serial.c b/drivers/serial/ioc3_serial.c
index 168073f12cec..4f1af71e9a1b 100644
--- a/drivers/serial/ioc3_serial.c
+++ b/drivers/serial/ioc3_serial.c
@@ -52,7 +52,7 @@ static unsigned int Submodule_slot;
52#define DPRINT_CONFIG(_x...) ; 52#define DPRINT_CONFIG(_x...) ;
53//#define DPRINT_CONFIG(_x...) printk _x 53//#define DPRINT_CONFIG(_x...) printk _x
54#define NOT_PROGRESS() ; 54#define NOT_PROGRESS() ;
55//#define NOT_PROGRESS() printk("%s : fails %d\n", __FUNCTION__, __LINE__) 55//#define NOT_PROGRESS() printk("%s : fails %d\n", __func__, __LINE__)
56 56
57/* number of characters we want to transmit to the lower level at a time */ 57/* number of characters we want to transmit to the lower level at a time */
58#define MAX_CHARS 256 58#define MAX_CHARS 256
@@ -445,7 +445,7 @@ static int inline port_init(struct ioc3_port *port)
445 sbbr_h = &idd->vma->sbbr_h; 445 sbbr_h = &idd->vma->sbbr_h;
446 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf; 446 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf;
447 DPRINT_CONFIG(("%s: ring_pci_addr 0x%p\n", 447 DPRINT_CONFIG(("%s: ring_pci_addr 0x%p\n",
448 __FUNCTION__, (void *)ring_pci_addr)); 448 __func__, (void *)ring_pci_addr));
449 449
450 writel((unsigned int)((uint64_t) ring_pci_addr >> 32), sbbr_h); 450 writel((unsigned int)((uint64_t) ring_pci_addr >> 32), sbbr_h);
451 writel((unsigned int)ring_pci_addr | BUF_SIZE_BIT, sbbr_l); 451 writel((unsigned int)ring_pci_addr | BUF_SIZE_BIT, sbbr_l);
@@ -593,7 +593,7 @@ config_port(struct ioc3_port *port,
593 593
594 DPRINT_CONFIG(("%s: line %d baud %d byte_size %d stop %d parenb %d " 594 DPRINT_CONFIG(("%s: line %d baud %d byte_size %d stop %d parenb %d "
595 "parodd %d\n", 595 "parodd %d\n",
596 __FUNCTION__, ((struct uart_port *)port->ip_port)->line, 596 __func__, ((struct uart_port *)port->ip_port)->line,
597 baud, byte_size, stop_bits, parenb, parodd)); 597 baud, byte_size, stop_bits, parenb, parodd));
598 598
599 if (set_baud(port, baud)) 599 if (set_baud(port, baud))
@@ -871,14 +871,14 @@ static int ioc3_set_proto(struct ioc3_port *port, int proto)
871 default: 871 default:
872 case PROTO_RS232: 872 case PROTO_RS232:
873 /* Clear the appropriate GIO pin */ 873 /* Clear the appropriate GIO pin */
874 DPRINT_CONFIG(("%s: rs232\n", __FUNCTION__)); 874 DPRINT_CONFIG(("%s: rs232\n", __func__));
875 writel(0, (&port->ip_idd->vma->gppr[0] 875 writel(0, (&port->ip_idd->vma->gppr[0]
876 + hooks->rs422_select_pin)); 876 + hooks->rs422_select_pin));
877 break; 877 break;
878 878
879 case PROTO_RS422: 879 case PROTO_RS422:
880 /* Set the appropriate GIO pin */ 880 /* Set the appropriate GIO pin */
881 DPRINT_CONFIG(("%s: rs422\n", __FUNCTION__)); 881 DPRINT_CONFIG(("%s: rs422\n", __func__));
882 writel(1, (&port->ip_idd->vma->gppr[0] 882 writel(1, (&port->ip_idd->vma->gppr[0]
883 + hooks->rs422_select_pin)); 883 + hooks->rs422_select_pin));
884 break; 884 break;
@@ -988,7 +988,7 @@ ioc3_change_speed(struct uart_port *the_port,
988 } 988 }
989 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 989 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
990 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 990 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
991 DPRINT_CONFIG(("%s: returned baud %d for line %d\n", __FUNCTION__, baud, 991 DPRINT_CONFIG(("%s: returned baud %d for line %d\n", __func__, baud,
992 the_port->line)); 992 the_port->line));
993 993
994 if (!the_port->fifosize) 994 if (!the_port->fifosize)
@@ -1026,7 +1026,7 @@ ioc3_change_speed(struct uart_port *the_port,
1026 DPRINT_CONFIG(("%s : port 0x%p line %d cflag 0%o " 1026 DPRINT_CONFIG(("%s : port 0x%p line %d cflag 0%o "
1027 "config_port(baud %d data %d stop %d penable %d " 1027 "config_port(baud %d data %d stop %d penable %d "
1028 " parity %d), notification 0x%x\n", 1028 " parity %d), notification 0x%x\n",
1029 __FUNCTION__, (void *)port, the_port->line, cflag, baud, 1029 __func__, (void *)port, the_port->line, cflag, baud,
1030 new_data, new_stop, new_parity_enable, new_parity, 1030 new_data, new_stop, new_parity_enable, new_parity,
1031 the_port->ignore_status_mask)); 1031 the_port->ignore_status_mask));
1032 1032
@@ -1919,7 +1919,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1919 struct pci_dev *pdev = idd->pdev; 1919 struct pci_dev *pdev = idd->pdev;
1920 1920
1921 DPRINT_CONFIG(("%s: attach pdev 0x%p - card_ptr 0x%p\n", 1921 DPRINT_CONFIG(("%s: attach pdev 0x%p - card_ptr 0x%p\n",
1922 __FUNCTION__, pdev, (void *)card_ptr)); 1922 __func__, pdev, (void *)card_ptr));
1923 1923
1924 if (!card_ptr) 1924 if (!card_ptr)
1925 return -ENODEV; 1925 return -ENODEV;
@@ -1933,7 +1933,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1933 port->ip_port = the_port; 1933 port->ip_port = the_port;
1934 1934
1935 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p [%d/%d]\n", 1935 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p [%d/%d]\n",
1936 __FUNCTION__, (void *)the_port, (void *)port, 1936 __func__, (void *)the_port, (void *)port,
1937 phys_port, ii)); 1937 phys_port, ii));
1938 1938
1939 /* membase, iobase and mapbase just need to be non-0 */ 1939 /* membase, iobase and mapbase just need to be non-0 */
@@ -1950,7 +1950,7 @@ static inline int ioc3_serial_core_attach( struct ioc3_submodule *is,
1950 if (uart_add_one_port(&ioc3_uart, the_port) < 0) { 1950 if (uart_add_one_port(&ioc3_uart, the_port) < 0) {
1951 printk(KERN_WARNING 1951 printk(KERN_WARNING
1952 "%s: unable to add port %d bus %d\n", 1952 "%s: unable to add port %d bus %d\n",
1953 __FUNCTION__, the_port->line, pdev->bus->number); 1953 __func__, the_port->line, pdev->bus->number);
1954 } else { 1954 } else {
1955 DPRINT_CONFIG(("IOC3 serial port %d irq %d bus %d\n", 1955 DPRINT_CONFIG(("IOC3 serial port %d irq %d bus %d\n",
1956 the_port->line, the_port->irq, pdev->bus->number)); 1956 the_port->line, the_port->irq, pdev->bus->number));
@@ -2017,7 +2017,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2017 struct ioc3_port *ports[PORTS_PER_CARD]; 2017 struct ioc3_port *ports[PORTS_PER_CARD];
2018 int phys_port; 2018 int phys_port;
2019 2019
2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, is, idd)); 2020 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __func__, is, idd));
2021 2021
2022 card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL); 2022 card_ptr = kzalloc(sizeof(struct ioc3_card), GFP_KERNEL);
2023 if (!card_ptr) { 2023 if (!card_ptr) {
@@ -2067,7 +2067,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2067 2067
2068 DPRINT_CONFIG(("%s : Port A ip_serial_regs 0x%p " 2068 DPRINT_CONFIG(("%s : Port A ip_serial_regs 0x%p "
2069 "ip_uart_regs 0x%p\n", 2069 "ip_uart_regs 0x%p\n",
2070 __FUNCTION__, 2070 __func__,
2071 (void *)port->ip_serial_regs, 2071 (void *)port->ip_serial_regs,
2072 (void *)port->ip_uart_regs)); 2072 (void *)port->ip_uart_regs));
2073 2073
@@ -2082,7 +2082,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2082 DPRINT_CONFIG(("%s : Port A ip_cpu_ringbuf 0x%p " 2082 DPRINT_CONFIG(("%s : Port A ip_cpu_ringbuf 0x%p "
2083 "ip_dma_ringbuf 0x%p, ip_inring 0x%p " 2083 "ip_dma_ringbuf 0x%p, ip_inring 0x%p "
2084 "ip_outring 0x%p\n", 2084 "ip_outring 0x%p\n",
2085 __FUNCTION__, 2085 __func__,
2086 (void *)port->ip_cpu_ringbuf, 2086 (void *)port->ip_cpu_ringbuf,
2087 (void *)port->ip_dma_ringbuf, 2087 (void *)port->ip_dma_ringbuf,
2088 (void *)port->ip_inring, 2088 (void *)port->ip_inring,
@@ -2094,7 +2094,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2094 2094
2095 DPRINT_CONFIG(("%s : Port B ip_serial_regs 0x%p " 2095 DPRINT_CONFIG(("%s : Port B ip_serial_regs 0x%p "
2096 "ip_uart_regs 0x%p\n", 2096 "ip_uart_regs 0x%p\n",
2097 __FUNCTION__, 2097 __func__,
2098 (void *)port->ip_serial_regs, 2098 (void *)port->ip_serial_regs,
2099 (void *)port->ip_uart_regs)); 2099 (void *)port->ip_uart_regs));
2100 2100
@@ -2108,7 +2108,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2108 DPRINT_CONFIG(("%s : Port B ip_cpu_ringbuf 0x%p " 2108 DPRINT_CONFIG(("%s : Port B ip_cpu_ringbuf 0x%p "
2109 "ip_dma_ringbuf 0x%p, ip_inring 0x%p " 2109 "ip_dma_ringbuf 0x%p, ip_inring 0x%p "
2110 "ip_outring 0x%p\n", 2110 "ip_outring 0x%p\n",
2111 __FUNCTION__, 2111 __func__,
2112 (void *)port->ip_cpu_ringbuf, 2112 (void *)port->ip_cpu_ringbuf,
2113 (void *)port->ip_dma_ringbuf, 2113 (void *)port->ip_dma_ringbuf,
2114 (void *)port->ip_inring, 2114 (void *)port->ip_inring,
@@ -2116,7 +2116,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2116 } 2116 }
2117 2117
2118 DPRINT_CONFIG(("%s : port %d [addr 0x%p] card_ptr 0x%p", 2118 DPRINT_CONFIG(("%s : port %d [addr 0x%p] card_ptr 0x%p",
2119 __FUNCTION__, 2119 __func__,
2120 phys_port, (void *)port, (void *)card_ptr)); 2120 phys_port, (void *)port, (void *)card_ptr));
2121 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n", 2121 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n",
2122 (void *)port->ip_serial_regs, 2122 (void *)port->ip_serial_regs,
@@ -2127,7 +2127,7 @@ ioc3uart_probe(struct ioc3_submodule *is, struct ioc3_driver_data *idd)
2127 2127
2128 DPRINT_CONFIG(("%s: phys_port %d port 0x%p inring 0x%p " 2128 DPRINT_CONFIG(("%s: phys_port %d port 0x%p inring 0x%p "
2129 "outring 0x%p\n", 2129 "outring 0x%p\n",
2130 __FUNCTION__, 2130 __func__,
2131 phys_port, (void *)port, 2131 phys_port, (void *)port,
2132 (void *)port->ip_inring, 2132 (void *)port->ip_inring,
2133 (void *)port->ip_outring)); 2133 (void *)port->ip_outring));
@@ -2170,7 +2170,7 @@ static int __devinit ioc3uart_init(void)
2170 if ((ret = uart_register_driver(&ioc3_uart)) < 0) { 2170 if ((ret = uart_register_driver(&ioc3_uart)) < 0) {
2171 printk(KERN_WARNING 2171 printk(KERN_WARNING
2172 "%s: Couldn't register IOC3 uart serial driver\n", 2172 "%s: Couldn't register IOC3 uart serial driver\n",
2173 __FUNCTION__); 2173 __func__);
2174 return ret; 2174 return ret;
2175 } 2175 }
2176 ret = ioc3_register_submodule(&ioc3uart_submodule); 2176 ret = ioc3_register_submodule(&ioc3uart_submodule);
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index 0c179384fb0c..49b8a82b7b9f 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -889,7 +889,7 @@ static int inline port_init(struct ioc4_port *port)
889 889
890 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf; 890 ring_pci_addr = (unsigned long __iomem)port->ip_dma_ringbuf;
891 DPRINT_CONFIG(("%s: ring_pci_addr 0x%lx\n", 891 DPRINT_CONFIG(("%s: ring_pci_addr 0x%lx\n",
892 __FUNCTION__, ring_pci_addr)); 892 __func__, ring_pci_addr));
893 893
894 writel((unsigned int)((uint64_t)ring_pci_addr >> 32), sbbr_h); 894 writel((unsigned int)((uint64_t)ring_pci_addr >> 32), sbbr_h);
895 writel((unsigned int)ring_pci_addr | IOC4_BUF_SIZE_BIT, sbbr_l); 895 writel((unsigned int)ring_pci_addr | IOC4_BUF_SIZE_BIT, sbbr_l);
@@ -1028,7 +1028,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
1028 spin_lock_irqsave(&soft->is_ir_lock, flag); 1028 spin_lock_irqsave(&soft->is_ir_lock, flag);
1029 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x " 1029 printk ("%s : %d : mem 0x%p sio_ir 0x%x sio_ies 0x%x "
1030 "other_ir 0x%x other_ies 0x%x mask 0x%x\n", 1030 "other_ir 0x%x other_ies 0x%x mask 0x%x\n",
1031 __FUNCTION__, __LINE__, 1031 __func__, __LINE__,
1032 (void *)mem, readl(&mem->sio_ir.raw), 1032 (void *)mem, readl(&mem->sio_ir.raw),
1033 readl(&mem->sio_ies.raw), 1033 readl(&mem->sio_ies.raw),
1034 readl(&mem->other_ir.raw), 1034 readl(&mem->other_ir.raw),
@@ -1155,14 +1155,14 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1155 (TOTAL_RING_BUF_SIZE - 1)) == 0)); 1155 (TOTAL_RING_BUF_SIZE - 1)) == 0));
1156 DPRINT_CONFIG(("%s : ip_cpu_ringbuf 0x%p " 1156 DPRINT_CONFIG(("%s : ip_cpu_ringbuf 0x%p "
1157 "ip_dma_ringbuf 0x%p\n", 1157 "ip_dma_ringbuf 0x%p\n",
1158 __FUNCTION__, 1158 __func__,
1159 (void *)port->ip_cpu_ringbuf, 1159 (void *)port->ip_cpu_ringbuf,
1160 (void *)port->ip_dma_ringbuf)); 1160 (void *)port->ip_dma_ringbuf));
1161 port->ip_inring = RING(port, RX_0_OR_2); 1161 port->ip_inring = RING(port, RX_0_OR_2);
1162 port->ip_outring = RING(port, TX_0_OR_2); 1162 port->ip_outring = RING(port, TX_0_OR_2);
1163 } 1163 }
1164 DPRINT_CONFIG(("%s : port %d [addr 0x%p] control 0x%p", 1164 DPRINT_CONFIG(("%s : port %d [addr 0x%p] control 0x%p",
1165 __FUNCTION__, 1165 __func__,
1166 port_number, (void *)port, (void *)control)); 1166 port_number, (void *)port, (void *)control));
1167 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n", 1167 DPRINT_CONFIG((" ip_serial_regs 0x%p ip_uart_regs 0x%p\n",
1168 (void *)port->ip_serial_regs, 1168 (void *)port->ip_serial_regs,
@@ -1173,7 +1173,7 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
1173 1173
1174 DPRINT_CONFIG(("%s: port_number %d port 0x%p inring 0x%p " 1174 DPRINT_CONFIG(("%s: port_number %d port 0x%p inring 0x%p "
1175 "outring 0x%p\n", 1175 "outring 0x%p\n",
1176 __FUNCTION__, 1176 __func__,
1177 port_number, (void *)port, 1177 port_number, (void *)port,
1178 (void *)port->ip_inring, 1178 (void *)port->ip_inring,
1179 (void *)port->ip_outring)); 1179 (void *)port->ip_outring));
@@ -1317,7 +1317,7 @@ config_port(struct ioc4_port *port,
1317 int spiniter = 0; 1317 int spiniter = 0;
1318 1318
1319 DPRINT_CONFIG(("%s: baud %d byte_size %d stop %d parenb %d parodd %d\n", 1319 DPRINT_CONFIG(("%s: baud %d byte_size %d stop %d parenb %d parodd %d\n",
1320 __FUNCTION__, baud, byte_size, stop_bits, parenb, parodd)); 1320 __func__, baud, byte_size, stop_bits, parenb, parodd));
1321 1321
1322 if (set_baud(port, baud)) 1322 if (set_baud(port, baud))
1323 return 1; 1323 return 1;
@@ -1725,7 +1725,7 @@ ioc4_change_speed(struct uart_port *the_port,
1725 } 1725 }
1726 baud = uart_get_baud_rate(the_port, new_termios, old_termios, 1726 baud = uart_get_baud_rate(the_port, new_termios, old_termios,
1727 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED); 1727 MIN_BAUD_SUPPORTED, MAX_BAUD_SUPPORTED);
1728 DPRINT_CONFIG(("%s: returned baud %d\n", __FUNCTION__, baud)); 1728 DPRINT_CONFIG(("%s: returned baud %d\n", __func__, baud));
1729 1729
1730 /* default is 9600 */ 1730 /* default is 9600 */
1731 if (!baud) 1731 if (!baud)
@@ -1765,7 +1765,7 @@ ioc4_change_speed(struct uart_port *the_port,
1765 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o " 1765 DPRINT_CONFIG(("%s : port 0x%p cflag 0%o "
1766 "config_port(baud %d data %d stop %d p enable %d parity %d)," 1766 "config_port(baud %d data %d stop %d p enable %d parity %d),"
1767 " notification 0x%x\n", 1767 " notification 0x%x\n",
1768 __FUNCTION__, (void *)port, cflag, baud, new_data, new_stop, 1768 __func__, (void *)port, cflag, baud, new_data, new_stop,
1769 new_parity_enable, new_parity, the_port->ignore_status_mask)); 1769 new_parity_enable, new_parity, the_port->ignore_status_mask));
1770 1770
1771 if ((config_port(port, baud, /* baud */ 1771 if ((config_port(port, baud, /* baud */
@@ -2715,7 +2715,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2715 2715
2716 2716
2717 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n", 2717 DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n",
2718 __FUNCTION__, pdev, (void *)control)); 2718 __func__, pdev, (void *)control));
2719 2719
2720 if (!control) 2720 if (!control)
2721 return -ENODEV; 2721 return -ENODEV;
@@ -2734,7 +2734,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2734 port->ip_all_ports[port_type_idx] = the_port; 2734 port->ip_all_ports[port_type_idx] = the_port;
2735 2735
2736 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n", 2736 DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n",
2737 __FUNCTION__, (void *)the_port, 2737 __func__, (void *)the_port,
2738 (void *)port, 2738 (void *)port,
2739 port_type == PROTO_RS232 ? "rs232" : "rs422")); 2739 port_type == PROTO_RS232 ? "rs232" : "rs422"));
2740 2740
@@ -2752,7 +2752,7 @@ ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
2752 if (uart_add_one_port(u_driver, the_port) < 0) { 2752 if (uart_add_one_port(u_driver, the_port) < 0) {
2753 printk(KERN_WARNING 2753 printk(KERN_WARNING
2754 "%s: unable to add port %d bus %d\n", 2754 "%s: unable to add port %d bus %d\n",
2755 __FUNCTION__, the_port->line, pdev->bus->number); 2755 __func__, the_port->line, pdev->bus->number);
2756 } else { 2756 } else {
2757 DPRINT_CONFIG( 2757 DPRINT_CONFIG(
2758 ("IOC4 serial port %d irq = %d, bus %d\n", 2758 ("IOC4 serial port %d irq = %d, bus %d\n",
@@ -2777,7 +2777,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2777 int ret = 0; 2777 int ret = 0;
2778 2778
2779 2779
2780 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev, 2780 DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __func__, idd->idd_pdev,
2781 idd->idd_pci_id)); 2781 idd->idd_pci_id));
2782 2782
2783 /* PCI-RT does not bring out serial connections. 2783 /* PCI-RT does not bring out serial connections.
@@ -2806,7 +2806,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2806 goto out2; 2806 goto out2;
2807 } 2807 }
2808 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n", 2808 DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n",
2809 __FUNCTION__, (void *)idd->idd_misc_regs, 2809 __func__, (void *)idd->idd_misc_regs,
2810 (void *)serial)); 2810 (void *)serial));
2811 2811
2812 /* Get memory for the new card */ 2812 /* Get memory for the new card */
@@ -2858,7 +2858,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
2858 } else { 2858 } else {
2859 printk(KERN_WARNING 2859 printk(KERN_WARNING
2860 "%s : request_irq fails for IRQ 0x%x\n ", 2860 "%s : request_irq fails for IRQ 0x%x\n ",
2861 __FUNCTION__, idd->idd_pdev->irq); 2861 __func__, idd->idd_pdev->irq);
2862 } 2862 }
2863 ret = ioc4_attach_local(idd); 2863 ret = ioc4_attach_local(idd);
2864 if (ret) 2864 if (ret)
@@ -2911,13 +2911,13 @@ int ioc4_serial_init(void)
2911 if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) { 2911 if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
2912 printk(KERN_WARNING 2912 printk(KERN_WARNING
2913 "%s: Couldn't register rs232 IOC4 serial driver\n", 2913 "%s: Couldn't register rs232 IOC4 serial driver\n",
2914 __FUNCTION__); 2914 __func__);
2915 return ret; 2915 return ret;
2916 } 2916 }
2917 if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) { 2917 if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
2918 printk(KERN_WARNING 2918 printk(KERN_WARNING
2919 "%s: Couldn't register rs422 IOC4 serial driver\n", 2919 "%s: Couldn't register rs422 IOC4 serial driver\n",
2920 __FUNCTION__); 2920 __func__);
2921 return ret; 2921 return ret;
2922 } 2922 }
2923 2923
diff --git a/drivers/serial/kgdboc.c b/drivers/serial/kgdboc.c
index 9cf03327386a..eadc1ab6bbce 100644
--- a/drivers/serial/kgdboc.c
+++ b/drivers/serial/kgdboc.c
@@ -96,12 +96,14 @@ static void cleanup_kgdboc(void)
96 96
97static int kgdboc_get_char(void) 97static int kgdboc_get_char(void)
98{ 98{
99 return kgdb_tty_driver->poll_get_char(kgdb_tty_driver, kgdb_tty_line); 99 return kgdb_tty_driver->ops->poll_get_char(kgdb_tty_driver,
100 kgdb_tty_line);
100} 101}
101 102
102static void kgdboc_put_char(u8 chr) 103static void kgdboc_put_char(u8 chr)
103{ 104{
104 kgdb_tty_driver->poll_put_char(kgdb_tty_driver, kgdb_tty_line, chr); 105 kgdb_tty_driver->ops->poll_put_char(kgdb_tty_driver,
106 kgdb_tty_line, chr);
105} 107}
106 108
107static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp) 109static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index ddd3aa50d4ad..43af40d59b8a 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -1072,18 +1072,6 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
1072 tty_wait_until_sent(tty, 0); 1072 tty_wait_until_sent(tty, 0);
1073 send_break(info, arg ? arg*(HZ/10) : HZ/4); 1073 send_break(info, arg ? arg*(HZ/10) : HZ/4);
1074 return 0; 1074 return 0;
1075 case TIOCGSOFTCAR:
1076 error = put_user(C_CLOCAL(tty) ? 1 : 0,
1077 (unsigned long *) arg);
1078 if (error)
1079 return error;
1080 return 0;
1081 case TIOCSSOFTCAR:
1082 get_user(arg, (unsigned long *) arg);
1083 tty->termios->c_cflag =
1084 ((tty->termios->c_cflag & ~CLOCAL) |
1085 (arg ? CLOCAL : 0));
1086 return 0;
1087 case TIOCGSERIAL: 1075 case TIOCGSERIAL:
1088 if (access_ok(VERIFY_WRITE, (void *) arg, 1076 if (access_ok(VERIFY_WRITE, (void *) arg,
1089 sizeof(struct serial_struct))) 1077 sizeof(struct serial_struct)))
@@ -1222,8 +1210,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp)
1222 } else 1210 } else
1223#endif 1211#endif
1224 shutdown(info); 1212 shutdown(info);
1225 if (tty->driver->flush_buffer) 1213 mcfrs_flush_buffer(tty);
1226 tty->driver->flush_buffer(tty);
1227 tty_ldisc_flush(tty); 1214 tty_ldisc_flush(tty);
1228 1215
1229 tty->closing = 0; 1216 tty->closing = 0;
@@ -1276,6 +1263,8 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
1276 * Note: we have to use pretty tight timings here to satisfy 1263 * Note: we have to use pretty tight timings here to satisfy
1277 * the NIST-PCTS. 1264 * the NIST-PCTS.
1278 */ 1265 */
1266 lock_kernel();
1267
1279 fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud; 1268 fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud;
1280 char_time = fifo_time / 5; 1269 char_time = fifo_time / 5;
1281 if (char_time == 0) 1270 if (char_time == 0)
@@ -1312,6 +1301,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
1312 if (timeout && time_after(jiffies, orig_jiffies + timeout)) 1301 if (timeout && time_after(jiffies, orig_jiffies + timeout))
1313 break; 1302 break;
1314 } 1303 }
1304 unlock_kernel();
1315#else 1305#else
1316 /* 1306 /*
1317 * For the other coldfire models, assume all data has been sent 1307 * For the other coldfire models, assume all data has been sent
@@ -1907,7 +1897,7 @@ static struct tty_driver *mcfrs_console_device(struct console *c, int *index)
1907 * This is used for console output. 1897 * This is used for console output.
1908 */ 1898 */
1909 1899
1910void mcfrs_put_char(char ch) 1900int mcfrs_put_char(char ch)
1911{ 1901{
1912 volatile unsigned char *uartp; 1902 volatile unsigned char *uartp;
1913 unsigned long flags; 1903 unsigned long flags;
@@ -1931,7 +1921,7 @@ void mcfrs_put_char(char ch)
1931 mcfrs_init_console(); /* try and get it back */ 1921 mcfrs_init_console(); /* try and get it back */
1932 local_irq_restore(flags); 1922 local_irq_restore(flags);
1933 1923
1934 return; 1924 return 1;
1935} 1925}
1936 1926
1937 1927
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index d93b3578c5e2..7a3625f52a03 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -1221,8 +1221,8 @@ static struct of_device_id mpc52xx_uart_of_match[] = {
1221#endif 1221#endif
1222#ifdef CONFIG_PPC_MPC512x 1222#ifdef CONFIG_PPC_MPC512x
1223 { .compatible = "fsl,mpc5121-psc-uart", .data = &mpc512x_psc_ops, }, 1223 { .compatible = "fsl,mpc5121-psc-uart", .data = &mpc512x_psc_ops, },
1224 {},
1225#endif 1224#endif
1225 {},
1226}; 1226};
1227 1227
1228static int __devinit 1228static int __devinit
diff --git a/drivers/serial/netx-serial.c b/drivers/serial/netx-serial.c
index 3123ffeac8ad..81ac9bb4f39b 100644
--- a/drivers/serial/netx-serial.c
+++ b/drivers/serial/netx-serial.c
@@ -287,6 +287,7 @@ static void netx_set_mctrl(struct uart_port *port, unsigned int mctrl)
287{ 287{
288 unsigned int val; 288 unsigned int val;
289 289
290 /* FIXME: Locking needed ? */
290 if (mctrl & TIOCM_RTS) { 291 if (mctrl & TIOCM_RTS) {
291 val = readl(port->membase + UART_RTS_CR); 292 val = readl(port->membase + UART_RTS_CR);
292 writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR); 293 writel(val | RTS_CR_RTS, port->membase + UART_RTS_CR);
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index da5a02cb4f63..2b6a013639e6 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1096,13 +1096,13 @@ static int s3c24xx_serial_probe(struct platform_device *dev,
1096 ourport = &s3c24xx_serial_ports[probe_index]; 1096 ourport = &s3c24xx_serial_ports[probe_index];
1097 probe_index++; 1097 probe_index++;
1098 1098
1099 dbg("%s: initialising port %p...\n", __FUNCTION__, ourport); 1099 dbg("%s: initialising port %p...\n", __func__, ourport);
1100 1100
1101 ret = s3c24xx_serial_init_port(ourport, info, dev); 1101 ret = s3c24xx_serial_init_port(ourport, info, dev);
1102 if (ret < 0) 1102 if (ret < 0)
1103 goto probe_err; 1103 goto probe_err;
1104 1104
1105 dbg("%s: adding port\n", __FUNCTION__); 1105 dbg("%s: adding port\n", __func__);
1106 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); 1106 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
1107 platform_set_drvdata(dev, &ourport->port); 1107 platform_set_drvdata(dev, &ourport->port);
1108 1108
@@ -1587,7 +1587,7 @@ static int s3c2412_serial_resetport(struct uart_port *port,
1587 unsigned long ucon = rd_regl(port, S3C2410_UCON); 1587 unsigned long ucon = rd_regl(port, S3C2410_UCON);
1588 1588
1589 dbg("%s: port=%p (%08lx), cfg=%p\n", 1589 dbg("%s: port=%p (%08lx), cfg=%p\n",
1590 __FUNCTION__, port, port->mapbase, cfg); 1590 __func__, port, port->mapbase, cfg);
1591 1591
1592 /* ensure we don't change the clock settings... */ 1592 /* ensure we don't change the clock settings... */
1593 1593
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 67b2338913c2..62b38582f5e9 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -655,7 +655,7 @@ void __init sa1100_register_uart_fns(struct sa1100_port_fns *fns)
655void __init sa1100_register_uart(int idx, int port) 655void __init sa1100_register_uart(int idx, int port)
656{ 656{
657 if (idx >= NR_PORTS) { 657 if (idx >= NR_PORTS) {
658 printk(KERN_ERR "%s: bad index number %d\n", __FUNCTION__, idx); 658 printk(KERN_ERR "%s: bad index number %d\n", __func__, idx);
659 return; 659 return;
660 } 660 }
661 661
@@ -682,7 +682,7 @@ void __init sa1100_register_uart(int idx, int port)
682 break; 682 break;
683 683
684 default: 684 default:
685 printk(KERN_ERR "%s: bad port number %d\n", __FUNCTION__, port); 685 printk(KERN_ERR "%s: bad port number %d\n", __func__, port);
686 } 686 }
687} 687}
688 688
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 977ce820ce30..1e2b9d826f69 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -422,6 +422,7 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
422 422
423EXPORT_SYMBOL(uart_get_divisor); 423EXPORT_SYMBOL(uart_get_divisor);
424 424
425/* FIXME: Consistent locking policy */
425static void 426static void
426uart_change_speed(struct uart_state *state, struct ktermios *old_termios) 427uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
427{ 428{
@@ -454,27 +455,30 @@ uart_change_speed(struct uart_state *state, struct ktermios *old_termios)
454 port->ops->set_termios(port, termios, old_termios); 455 port->ops->set_termios(port, termios, old_termios);
455} 456}
456 457
457static inline void 458static inline int
458__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c) 459__uart_put_char(struct uart_port *port, struct circ_buf *circ, unsigned char c)
459{ 460{
460 unsigned long flags; 461 unsigned long flags;
462 int ret = 0;
461 463
462 if (!circ->buf) 464 if (!circ->buf)
463 return; 465 return 0;
464 466
465 spin_lock_irqsave(&port->lock, flags); 467 spin_lock_irqsave(&port->lock, flags);
466 if (uart_circ_chars_free(circ) != 0) { 468 if (uart_circ_chars_free(circ) != 0) {
467 circ->buf[circ->head] = c; 469 circ->buf[circ->head] = c;
468 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1); 470 circ->head = (circ->head + 1) & (UART_XMIT_SIZE - 1);
471 ret = 1;
469 } 472 }
470 spin_unlock_irqrestore(&port->lock, flags); 473 spin_unlock_irqrestore(&port->lock, flags);
474 return ret;
471} 475}
472 476
473static void uart_put_char(struct tty_struct *tty, unsigned char ch) 477static int uart_put_char(struct tty_struct *tty, unsigned char ch)
474{ 478{
475 struct uart_state *state = tty->driver_data; 479 struct uart_state *state = tty->driver_data;
476 480
477 __uart_put_char(state->port, &state->info->xmit, ch); 481 return __uart_put_char(state->port, &state->info->xmit, ch);
478} 482}
479 483
480static void uart_flush_chars(struct tty_struct *tty) 484static void uart_flush_chars(struct tty_struct *tty)
@@ -528,15 +532,25 @@ uart_write(struct tty_struct *tty, const unsigned char *buf, int count)
528static int uart_write_room(struct tty_struct *tty) 532static int uart_write_room(struct tty_struct *tty)
529{ 533{
530 struct uart_state *state = tty->driver_data; 534 struct uart_state *state = tty->driver_data;
535 unsigned long flags;
536 int ret;
531 537
532 return uart_circ_chars_free(&state->info->xmit); 538 spin_lock_irqsave(&state->port->lock, flags);
539 ret = uart_circ_chars_free(&state->info->xmit);
540 spin_unlock_irqrestore(&state->port->lock, flags);
541 return ret;
533} 542}
534 543
535static int uart_chars_in_buffer(struct tty_struct *tty) 544static int uart_chars_in_buffer(struct tty_struct *tty)
536{ 545{
537 struct uart_state *state = tty->driver_data; 546 struct uart_state *state = tty->driver_data;
547 unsigned long flags;
548 int ret;
538 549
539 return uart_circ_chars_pending(&state->info->xmit); 550 spin_lock_irqsave(&state->port->lock, flags);
551 ret = uart_circ_chars_pending(&state->info->xmit);
552 spin_unlock_irqrestore(&state->port->lock, flags);
553 return ret;
540} 554}
541 555
542static void uart_flush_buffer(struct tty_struct *tty) 556static void uart_flush_buffer(struct tty_struct *tty)
@@ -618,6 +632,11 @@ static int uart_get_info(struct uart_state *state,
618 struct serial_struct tmp; 632 struct serial_struct tmp;
619 633
620 memset(&tmp, 0, sizeof(tmp)); 634 memset(&tmp, 0, sizeof(tmp));
635
636 /* Ensure the state we copy is consistent and no hardware changes
637 occur as we go */
638 mutex_lock(&state->mutex);
639
621 tmp.type = port->type; 640 tmp.type = port->type;
622 tmp.line = port->line; 641 tmp.line = port->line;
623 tmp.port = port->iobase; 642 tmp.port = port->iobase;
@@ -637,6 +656,8 @@ static int uart_get_info(struct uart_state *state,
637 tmp.iomem_reg_shift = port->regshift; 656 tmp.iomem_reg_shift = port->regshift;
638 tmp.iomem_base = (void *)(unsigned long)port->mapbase; 657 tmp.iomem_base = (void *)(unsigned long)port->mapbase;
639 658
659 mutex_unlock(&state->mutex);
660
640 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 661 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
641 return -EFAULT; 662 return -EFAULT;
642 return 0; 663 return 0;
@@ -914,8 +935,6 @@ static void uart_break_ctl(struct tty_struct *tty, int break_state)
914 struct uart_state *state = tty->driver_data; 935 struct uart_state *state = tty->driver_data;
915 struct uart_port *port = state->port; 936 struct uart_port *port = state->port;
916 937
917 BUG_ON(!kernel_locked());
918
919 mutex_lock(&state->mutex); 938 mutex_lock(&state->mutex);
920 939
921 if (port->type != PORT_UNKNOWN) 940 if (port->type != PORT_UNKNOWN)
@@ -1059,7 +1078,7 @@ static int uart_get_count(struct uart_state *state,
1059} 1078}
1060 1079
1061/* 1080/*
1062 * Called via sys_ioctl under the BKL. We can use spin_lock_irq() here. 1081 * Called via sys_ioctl. We can use spin_lock_irq() here.
1063 */ 1082 */
1064static int 1083static int
1065uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, 1084uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
@@ -1069,7 +1088,6 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
1069 void __user *uarg = (void __user *)arg; 1088 void __user *uarg = (void __user *)arg;
1070 int ret = -ENOIOCTLCMD; 1089 int ret = -ENOIOCTLCMD;
1071 1090
1072 BUG_ON(!kernel_locked());
1073 1091
1074 /* 1092 /*
1075 * These ioctls don't rely on the hardware to be present. 1093 * These ioctls don't rely on the hardware to be present.
@@ -1140,9 +1158,9 @@ uart_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
1140 break; 1158 break;
1141 } 1159 }
1142 } 1160 }
1143 out_up: 1161out_up:
1144 mutex_unlock(&state->mutex); 1162 mutex_unlock(&state->mutex);
1145 out: 1163out:
1146 return ret; 1164 return ret;
1147} 1165}
1148 1166
@@ -1153,7 +1171,6 @@ static void uart_set_termios(struct tty_struct *tty,
1153 unsigned long flags; 1171 unsigned long flags;
1154 unsigned int cflag = tty->termios->c_cflag; 1172 unsigned int cflag = tty->termios->c_cflag;
1155 1173
1156 BUG_ON(!kernel_locked());
1157 1174
1158 /* 1175 /*
1159 * These are the bits that are used to setup various 1176 * These are the bits that are used to setup various
@@ -1165,8 +1182,9 @@ static void uart_set_termios(struct tty_struct *tty,
1165 if ((cflag ^ old_termios->c_cflag) == 0 && 1182 if ((cflag ^ old_termios->c_cflag) == 0 &&
1166 tty->termios->c_ospeed == old_termios->c_ospeed && 1183 tty->termios->c_ospeed == old_termios->c_ospeed &&
1167 tty->termios->c_ispeed == old_termios->c_ispeed && 1184 tty->termios->c_ispeed == old_termios->c_ispeed &&
1168 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) 1185 RELEVANT_IFLAG(tty->termios->c_iflag ^ old_termios->c_iflag) == 0) {
1169 return; 1186 return;
1187 }
1170 1188
1171 uart_change_speed(state, old_termios); 1189 uart_change_speed(state, old_termios);
1172 1190
@@ -1200,7 +1218,6 @@ static void uart_set_termios(struct tty_struct *tty,
1200 } 1218 }
1201 spin_unlock_irqrestore(&state->port->lock, flags); 1219 spin_unlock_irqrestore(&state->port->lock, flags);
1202 } 1220 }
1203
1204#if 0 1221#if 0
1205 /* 1222 /*
1206 * No need to wake up processes in open wait, since they 1223 * No need to wake up processes in open wait, since they
@@ -1316,11 +1333,11 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
1316 struct uart_port *port = state->port; 1333 struct uart_port *port = state->port;
1317 unsigned long char_time, expire; 1334 unsigned long char_time, expire;
1318 1335
1319 BUG_ON(!kernel_locked());
1320
1321 if (port->type == PORT_UNKNOWN || port->fifosize == 0) 1336 if (port->type == PORT_UNKNOWN || port->fifosize == 0)
1322 return; 1337 return;
1323 1338
1339 lock_kernel();
1340
1324 /* 1341 /*
1325 * Set the check interval to be 1/5 of the estimated time to 1342 * Set the check interval to be 1/5 of the estimated time to
1326 * send a single character, and make it at least 1. The check 1343 * send a single character, and make it at least 1. The check
@@ -1366,6 +1383,7 @@ static void uart_wait_until_sent(struct tty_struct *tty, int timeout)
1366 break; 1383 break;
1367 } 1384 }
1368 set_current_state(TASK_RUNNING); /* might not be needed */ 1385 set_current_state(TASK_RUNNING); /* might not be needed */
1386 unlock_kernel();
1369} 1387}
1370 1388
1371/* 1389/*
@@ -2079,7 +2097,9 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
2079 int ret; 2097 int ret;
2080 2098
2081 uart_change_pm(state, 0); 2099 uart_change_pm(state, 0);
2100 spin_lock_irq(&port->lock);
2082 ops->set_mctrl(port, 0); 2101 ops->set_mctrl(port, 0);
2102 spin_unlock_irq(&port->lock);
2083 ret = ops->startup(port); 2103 ret = ops->startup(port);
2084 if (ret == 0) { 2104 if (ret == 0) {
2085 uart_change_speed(state, NULL); 2105 uart_change_speed(state, NULL);
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index c2ea5d4df44a..969106187718 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -855,7 +855,7 @@ static int sci_notifier(struct notifier_block *self,
855 855
856 printk(KERN_INFO "%s: got a postchange notification " 856 printk(KERN_INFO "%s: got a postchange notification "
857 "for cpu %d (old %d, new %d)\n", 857 "for cpu %d (old %d, new %d)\n",
858 __FUNCTION__, freqs->cpu, freqs->old, freqs->new); 858 __func__, freqs->cpu, freqs->old, freqs->new);
859 } 859 }
860 860
861 return NOTIFY_OK; 861 return NOTIFY_OK;
diff --git a/drivers/serial/sn_console.c b/drivers/serial/sn_console.c
index 41fc61264443..019da2e05f0b 100644
--- a/drivers/serial/sn_console.c
+++ b/drivers/serial/sn_console.c
@@ -839,7 +839,7 @@ static int __init sn_sal_module_init(void)
839 839
840 if (uart_add_one_port(&sal_console_uart, &sal_console_port.sc_port) < 0) { 840 if (uart_add_one_port(&sal_console_uart, &sal_console_port.sc_port) < 0) {
841 /* error - not sure what I'd do - so I'll do nothing */ 841 /* error - not sure what I'd do - so I'll do nothing */
842 printk(KERN_ERR "%s: unable to add port\n", __FUNCTION__); 842 printk(KERN_ERR "%s: unable to add port\n", __func__);
843 } 843 }
844 844
845 /* when this driver is compiled in, the console initialization 845 /* when this driver is compiled in, the console initialization
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index b565d5a37499..b51c24245be4 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -584,7 +584,7 @@ ulite_of_probe(struct of_device *op, const struct of_device_id *match)
584 const unsigned int *id; 584 const unsigned int *id;
585 int irq, rc; 585 int irq, rc;
586 586
587 dev_dbg(&op->dev, "%s(%p, %p)\n", __FUNCTION__, op, match); 587 dev_dbg(&op->dev, "%s(%p, %p)\n", __func__, op, match);
588 588
589 rc = of_address_to_resource(op->node, 0, &res); 589 rc = of_address_to_resource(op->node, 0, &res);
590 if (rc) { 590 if (rc) {
diff --git a/drivers/serial/ucc_uart.c b/drivers/serial/ucc_uart.c
index 5e4310ccd591..01917c433f17 100644
--- a/drivers/serial/ucc_uart.c
+++ b/drivers/serial/ucc_uart.c
@@ -215,7 +215,7 @@ static inline dma_addr_t cpu2qe_addr(void *addr, struct uart_qe_port *qe_port)
215 return qe_port->bd_dma_addr + (addr - qe_port->bd_virt); 215 return qe_port->bd_dma_addr + (addr - qe_port->bd_virt);
216 216
217 /* something nasty happened */ 217 /* something nasty happened */
218 printk(KERN_ERR "%s: addr=%p\n", __FUNCTION__, addr); 218 printk(KERN_ERR "%s: addr=%p\n", __func__, addr);
219 BUG(); 219 BUG();
220 return 0; 220 return 0;
221} 221}
@@ -234,7 +234,7 @@ static inline void *qe2cpu_addr(dma_addr_t addr, struct uart_qe_port *qe_port)
234 return qe_port->bd_virt + (addr - qe_port->bd_dma_addr); 234 return qe_port->bd_virt + (addr - qe_port->bd_dma_addr);
235 235
236 /* something nasty happened */ 236 /* something nasty happened */
237 printk(KERN_ERR "%s: addr=%x\n", __FUNCTION__, addr); 237 printk(KERN_ERR "%s: addr=%x\n", __func__, addr);
238 BUG(); 238 BUG();
239 return NULL; 239 return NULL;
240} 240}
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index 02c8e305b14f..e81d59d78910 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -497,7 +497,7 @@ static int atmel_spi_setup(struct spi_device *spi)
497 struct atmel_spi *as; 497 struct atmel_spi *as;
498 u32 scbr, csr; 498 u32 scbr, csr;
499 unsigned int bits = spi->bits_per_word; 499 unsigned int bits = spi->bits_per_word;
500 unsigned long bus_hz, sck_hz; 500 unsigned long bus_hz;
501 unsigned int npcs_pin; 501 unsigned int npcs_pin;
502 int ret; 502 int ret;
503 503
@@ -536,14 +536,25 @@ static int atmel_spi_setup(struct spi_device *spi)
536 return -EINVAL; 536 return -EINVAL;
537 } 537 }
538 538
539 /* speed zero convention is used by some upper layers */ 539 /*
540 * Pre-new_1 chips start out at half the peripheral
541 * bus speed.
542 */
540 bus_hz = clk_get_rate(as->clk); 543 bus_hz = clk_get_rate(as->clk);
544 if (!as->new_1)
545 bus_hz /= 2;
546
541 if (spi->max_speed_hz) { 547 if (spi->max_speed_hz) {
542 /* assume div32/fdiv/mbz == 0 */ 548 /*
543 if (!as->new_1) 549 * Calculate the lowest divider that satisfies the
544 bus_hz /= 2; 550 * constraint, assuming div32/fdiv/mbz == 0.
545 scbr = ((bus_hz + spi->max_speed_hz - 1) 551 */
546 / spi->max_speed_hz); 552 scbr = DIV_ROUND_UP(bus_hz, spi->max_speed_hz);
553
554 /*
555 * If the resulting divider doesn't fit into the
556 * register bitfield, we can't satisfy the constraint.
557 */
547 if (scbr >= (1 << SPI_SCBR_SIZE)) { 558 if (scbr >= (1 << SPI_SCBR_SIZE)) {
548 dev_dbg(&spi->dev, 559 dev_dbg(&spi->dev,
549 "setup: %d Hz too slow, scbr %u; min %ld Hz\n", 560 "setup: %d Hz too slow, scbr %u; min %ld Hz\n",
@@ -551,8 +562,8 @@ static int atmel_spi_setup(struct spi_device *spi)
551 return -EINVAL; 562 return -EINVAL;
552 } 563 }
553 } else 564 } else
565 /* speed zero means "as slow as possible" */
554 scbr = 0xff; 566 scbr = 0xff;
555 sck_hz = bus_hz / scbr;
556 567
557 csr = SPI_BF(SCBR, scbr) | SPI_BF(BITS, bits - 8); 568 csr = SPI_BF(SCBR, scbr) | SPI_BF(BITS, bits - 8);
558 if (spi->mode & SPI_CPOL) 569 if (spi->mode & SPI_CPOL)
@@ -589,7 +600,7 @@ static int atmel_spi_setup(struct spi_device *spi)
589 600
590 dev_dbg(&spi->dev, 601 dev_dbg(&spi->dev,
591 "setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n", 602 "setup: %lu Hz bpw %u mode 0x%x -> csr%d %08x\n",
592 sck_hz, bits, spi->mode, spi->chip_select, csr); 603 bus_hz / scbr, bits, spi->mode, spi->chip_select, csr);
593 604
594 spi_writel(as, CSR0 + 4 * spi->chip_select, csr); 605 spi_writel(as, CSR0 + 4 * spi->chip_select, csr);
595 606
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 433b3f44f42e..8d158e5640e3 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -170,7 +170,7 @@ static int gs_open(struct tty_struct *tty, struct file *file);
170static void gs_close(struct tty_struct *tty, struct file *file); 170static void gs_close(struct tty_struct *tty, struct file *file);
171static int gs_write(struct tty_struct *tty, 171static int gs_write(struct tty_struct *tty,
172 const unsigned char *buf, int count); 172 const unsigned char *buf, int count);
173static void gs_put_char(struct tty_struct *tty, unsigned char ch); 173static int gs_put_char(struct tty_struct *tty, unsigned char ch);
174static void gs_flush_chars(struct tty_struct *tty); 174static void gs_flush_chars(struct tty_struct *tty);
175static int gs_write_room(struct tty_struct *tty); 175static int gs_write_room(struct tty_struct *tty);
176static int gs_chars_in_buffer(struct tty_struct *tty); 176static int gs_chars_in_buffer(struct tty_struct *tty);
@@ -883,14 +883,15 @@ exit:
883/* 883/*
884 * gs_put_char 884 * gs_put_char
885 */ 885 */
886static void gs_put_char(struct tty_struct *tty, unsigned char ch) 886static int gs_put_char(struct tty_struct *tty, unsigned char ch)
887{ 887{
888 unsigned long flags; 888 unsigned long flags;
889 struct gs_port *port = tty->driver_data; 889 struct gs_port *port = tty->driver_data;
890 int ret = 0;
890 891
891 if (port == NULL) { 892 if (port == NULL) {
892 pr_err("gs_put_char: NULL port pointer\n"); 893 pr_err("gs_put_char: NULL port pointer\n");
893 return; 894 return 0;
894 } 895 }
895 896
896 gs_debug("gs_put_char: (%d,%p) char=0x%x, called from %p\n", 897 gs_debug("gs_put_char: (%d,%p) char=0x%x, called from %p\n",
@@ -910,10 +911,11 @@ static void gs_put_char(struct tty_struct *tty, unsigned char ch)
910 goto exit; 911 goto exit;
911 } 912 }
912 913
913 gs_buf_put(port->port_write_buf, &ch, 1); 914 ret = gs_buf_put(port->port_write_buf, &ch, 1);
914 915
915exit: 916exit:
916 spin_unlock_irqrestore(&port->port_lock, flags); 917 spin_unlock_irqrestore(&port->port_lock, flags);
918 return ret;
917} 919}
918 920
919/* 921/*
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index d17d1645714f..04a56f300ea6 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -1421,8 +1421,7 @@ static void digi_close(struct usb_serial_port *port, struct file *filp)
1421 tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT); 1421 tty_wait_until_sent(tty, DIGI_CLOSE_TIMEOUT);
1422 1422
1423 /* flush driver and line discipline buffers */ 1423 /* flush driver and line discipline buffers */
1424 if (tty->driver->flush_buffer) 1424 tty_driver_flush_buffer(tty);
1425 tty->driver->flush_buffer(tty);
1426 tty_ldisc_flush(tty); 1425 tty_ldisc_flush(tty);
1427 1426
1428 if (port->serial->dev) { 1427 if (port->serial->dev) {
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index a9934a3f9845..0cb0d77dc429 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -296,16 +296,14 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
296 struct usb_serial_port *port = tty->driver_data; 296 struct usb_serial_port *port = tty->driver_data;
297 int retval = -ENODEV; 297 int retval = -ENODEV;
298 298
299 if (!port || port->serial->dev->state == USB_STATE_NOTATTACHED) 299 if (port->serial->dev->state == USB_STATE_NOTATTACHED)
300 goto exit; 300 goto exit;
301 301
302 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 302 dbg("%s - port %d, %d byte(s)", __func__, port->number, count);
303 303
304 if (!port->open_count) { 304 /* open_count is managed under the mutex lock for the tty so cannot
305 retval = -EINVAL; 305 drop to zero until after the last close completes */
306 dbg("%s - port not opened", __func__); 306 WARN_ON(!port->open_count);
307 goto exit;
308 }
309 307
310 /* pass on to the driver specific version of this function */ 308 /* pass on to the driver specific version of this function */
311 retval = port->serial->type->write(port, buf, count); 309 retval = port->serial->type->write(port, buf, count);
@@ -317,61 +315,28 @@ exit:
317static int serial_write_room (struct tty_struct *tty) 315static int serial_write_room (struct tty_struct *tty)
318{ 316{
319 struct usb_serial_port *port = tty->driver_data; 317 struct usb_serial_port *port = tty->driver_data;
320 int retval = -ENODEV;
321
322 if (!port)
323 goto exit;
324
325 dbg("%s - port %d", __func__, port->number); 318 dbg("%s - port %d", __func__, port->number);
326 319 WARN_ON(!port->open_count);
327 if (!port->open_count) {
328 dbg("%s - port not open", __func__);
329 goto exit;
330 }
331
332 /* pass on to the driver specific version of this function */ 320 /* pass on to the driver specific version of this function */
333 retval = port->serial->type->write_room(port); 321 return port->serial->type->write_room(port);
334
335exit:
336 return retval;
337} 322}
338 323
339static int serial_chars_in_buffer (struct tty_struct *tty) 324static int serial_chars_in_buffer (struct tty_struct *tty)
340{ 325{
341 struct usb_serial_port *port = tty->driver_data; 326 struct usb_serial_port *port = tty->driver_data;
342 int retval = -ENODEV;
343
344 if (!port)
345 goto exit;
346
347 dbg("%s = port %d", __func__, port->number); 327 dbg("%s = port %d", __func__, port->number);
348 328
349 if (!port->open_count) { 329 WARN_ON(!port->open_count);
350 dbg("%s - port not open", __func__);
351 goto exit;
352 }
353
354 /* pass on to the driver specific version of this function */ 330 /* pass on to the driver specific version of this function */
355 retval = port->serial->type->chars_in_buffer(port); 331 return port->serial->type->chars_in_buffer(port);
356
357exit:
358 return retval;
359} 332}
360 333
361static void serial_throttle (struct tty_struct * tty) 334static void serial_throttle (struct tty_struct * tty)
362{ 335{
363 struct usb_serial_port *port = tty->driver_data; 336 struct usb_serial_port *port = tty->driver_data;
364
365 if (!port)
366 return;
367
368 dbg("%s - port %d", __func__, port->number); 337 dbg("%s - port %d", __func__, port->number);
369 338
370 if (!port->open_count) { 339 WARN_ON(!port->open_count);
371 dbg ("%s - port not open", __func__);
372 return;
373 }
374
375 /* pass on to the driver specific version of this function */ 340 /* pass on to the driver specific version of this function */
376 if (port->serial->type->throttle) 341 if (port->serial->type->throttle)
377 port->serial->type->throttle(port); 342 port->serial->type->throttle(port);
@@ -380,17 +345,9 @@ static void serial_throttle (struct tty_struct * tty)
380static void serial_unthrottle (struct tty_struct * tty) 345static void serial_unthrottle (struct tty_struct * tty)
381{ 346{
382 struct usb_serial_port *port = tty->driver_data; 347 struct usb_serial_port *port = tty->driver_data;
383
384 if (!port)
385 return;
386
387 dbg("%s - port %d", __func__, port->number); 348 dbg("%s - port %d", __func__, port->number);
388 349
389 if (!port->open_count) { 350 WARN_ON(!port->open_count);
390 dbg("%s - port not open", __func__);
391 return;
392 }
393
394 /* pass on to the driver specific version of this function */ 351 /* pass on to the driver specific version of this function */
395 if (port->serial->type->unthrottle) 352 if (port->serial->type->unthrottle)
396 port->serial->type->unthrottle(port); 353 port->serial->type->unthrottle(port);
@@ -401,42 +358,27 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
401 struct usb_serial_port *port = tty->driver_data; 358 struct usb_serial_port *port = tty->driver_data;
402 int retval = -ENODEV; 359 int retval = -ENODEV;
403 360
404 lock_kernel();
405 if (!port)
406 goto exit;
407
408 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 361 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd);
409 362
410 /* Caution - port->open_count is BKL protected */ 363 WARN_ON(!port->open_count);
411 if (!port->open_count) {
412 dbg ("%s - port not open", __func__);
413 goto exit;
414 }
415 364
416 /* pass on to the driver specific version of this function if it is available */ 365 /* pass on to the driver specific version of this function if it is available */
417 if (port->serial->type->ioctl) 366 if (port->serial->type->ioctl) {
367 lock_kernel();
418 retval = port->serial->type->ioctl(port, file, cmd, arg); 368 retval = port->serial->type->ioctl(port, file, cmd, arg);
369 unlock_kernel();
370 }
419 else 371 else
420 retval = -ENOIOCTLCMD; 372 retval = -ENOIOCTLCMD;
421exit:
422 unlock_kernel();
423 return retval; 373 return retval;
424} 374}
425 375
426static void serial_set_termios (struct tty_struct *tty, struct ktermios * old) 376static void serial_set_termios (struct tty_struct *tty, struct ktermios * old)
427{ 377{
428 struct usb_serial_port *port = tty->driver_data; 378 struct usb_serial_port *port = tty->driver_data;
429
430 if (!port)
431 return;
432
433 dbg("%s - port %d", __func__, port->number); 379 dbg("%s - port %d", __func__, port->number);
434 380
435 if (!port->open_count) { 381 WARN_ON(!port->open_count);
436 dbg("%s - port not open", __func__);
437 return;
438 }
439
440 /* pass on to the driver specific version of this function if it is available */ 382 /* pass on to the driver specific version of this function if it is available */
441 if (port->serial->type->set_termios) 383 if (port->serial->type->set_termios)
442 port->serial->type->set_termios(port, old); 384 port->serial->type->set_termios(port, old);
@@ -448,24 +390,15 @@ static void serial_break (struct tty_struct *tty, int break_state)
448{ 390{
449 struct usb_serial_port *port = tty->driver_data; 391 struct usb_serial_port *port = tty->driver_data;
450 392
451 lock_kernel();
452 if (!port) {
453 unlock_kernel();
454 return;
455 }
456
457 dbg("%s - port %d", __func__, port->number); 393 dbg("%s - port %d", __func__, port->number);
458 394
459 if (!port->open_count) { 395 WARN_ON(!port->open_count);
460 dbg("%s - port not open", __func__);
461 unlock_kernel();
462 return;
463 }
464
465 /* pass on to the driver specific version of this function if it is available */ 396 /* pass on to the driver specific version of this function if it is available */
466 if (port->serial->type->break_ctl) 397 if (port->serial->type->break_ctl) {
398 lock_kernel();
467 port->serial->type->break_ctl(port, break_state); 399 port->serial->type->break_ctl(port, break_state);
468 unlock_kernel(); 400 unlock_kernel();
401 }
469} 402}
470 403
471static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data) 404static int serial_read_proc (char *page, char **start, off_t off, int count, int *eof, void *data)
@@ -519,19 +452,11 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
519{ 452{
520 struct usb_serial_port *port = tty->driver_data; 453 struct usb_serial_port *port = tty->driver_data;
521 454
522 if (!port)
523 return -ENODEV;
524
525 dbg("%s - port %d", __func__, port->number); 455 dbg("%s - port %d", __func__, port->number);
526 456
527 if (!port->open_count) { 457 WARN_ON(!port->open_count);
528 dbg("%s - port not open", __func__);
529 return -ENODEV;
530 }
531
532 if (port->serial->type->tiocmget) 458 if (port->serial->type->tiocmget)
533 return port->serial->type->tiocmget(port, file); 459 return port->serial->type->tiocmget(port, file);
534
535 return -EINVAL; 460 return -EINVAL;
536} 461}
537 462
@@ -540,19 +465,11 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
540{ 465{
541 struct usb_serial_port *port = tty->driver_data; 466 struct usb_serial_port *port = tty->driver_data;
542 467
543 if (!port)
544 return -ENODEV;
545
546 dbg("%s - port %d", __func__, port->number); 468 dbg("%s - port %d", __func__, port->number);
547 469
548 if (!port->open_count) { 470 WARN_ON(!port->open_count);
549 dbg("%s - port not open", __func__);
550 return -ENODEV;
551 }
552
553 if (port->serial->type->tiocmset) 471 if (port->serial->type->tiocmset)
554 return port->serial->type->tiocmset(port, file, set, clear); 472 return port->serial->type->tiocmset(port, file, set, clear);
555
556 return -EINVAL; 473 return -EINVAL;
557} 474}
558 475
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index e96bf8663ffc..f07e8a4c1f3d 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -673,15 +673,13 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
673 } 673 }
674*/ 674*/
675 675
676 if (port->tty->driver->flush_buffer) 676 tty_driver_flush_buffer(port->tty);
677 port->tty->driver->flush_buffer(port->tty);
678 tty_ldisc_flush(port->tty); 677 tty_ldisc_flush(port->tty);
679 678
680 firm_report_tx_done(port); 679 firm_report_tx_done(port);
681 680
682 firm_close(port); 681 firm_close(port);
683 682
684printk(KERN_ERR"Before processing rx_urbs_submitted.\n");
685 /* shutdown our bulk reads and writes */ 683 /* shutdown our bulk reads and writes */
686 mutex_lock(&info->deathwarrant); 684 mutex_lock(&info->deathwarrant);
687 spin_lock_irq(&info->lock); 685 spin_lock_irq(&info->lock);
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index a576dc261732..bb1dadaa4a23 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1774,6 +1774,11 @@ config FB_PXA
1774 1774
1775 If unsure, say N. 1775 If unsure, say N.
1776 1776
1777config FB_PXA_SMARTPANEL
1778 bool "PXA Smartpanel LCD support"
1779 default n
1780 depends on FB_PXA
1781
1777config FB_PXA_PARAMETERS 1782config FB_PXA_PARAMETERS
1778 bool "PXA LCD command line parameters" 1783 bool "PXA LCD command line parameters"
1779 default n 1784 default n
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 757651954e6c..3ab6e3d973a1 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -39,6 +39,9 @@
39#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
40#include <linux/clk.h> 40#include <linux/clk.h>
41#include <linux/err.h> 41#include <linux/err.h>
42#include <linux/completion.h>
43#include <linux/kthread.h>
44#include <linux/freezer.h>
42 45
43#include <asm/hardware.h> 46#include <asm/hardware.h>
44#include <asm/io.h> 47#include <asm/io.h>
@@ -57,19 +60,31 @@
57#include "pxafb.h" 60#include "pxafb.h"
58 61
59/* Bits which should not be set in machine configuration structures */ 62/* Bits which should not be set in machine configuration structures */
60#define LCCR0_INVALID_CONFIG_MASK (LCCR0_OUM|LCCR0_BM|LCCR0_QDM|LCCR0_DIS|LCCR0_EFM|LCCR0_IUM|LCCR0_SFM|LCCR0_LDM|LCCR0_ENB) 63#define LCCR0_INVALID_CONFIG_MASK (LCCR0_OUM | LCCR0_BM | LCCR0_QDM |\
61#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP|LCCR3_VSP|LCCR3_PCD|LCCR3_BPP) 64 LCCR0_DIS | LCCR0_EFM | LCCR0_IUM |\
65 LCCR0_SFM | LCCR0_LDM | LCCR0_ENB)
66
67#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP | LCCR3_VSP |\
68 LCCR3_PCD | LCCR3_BPP)
62 69
63static void (*pxafb_backlight_power)(int); 70static void (*pxafb_backlight_power)(int);
64static void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *); 71static void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
65 72
66static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *); 73static int pxafb_activate_var(struct fb_var_screeninfo *var,
74 struct pxafb_info *);
67static void set_ctrlr_state(struct pxafb_info *fbi, u_int state); 75static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
68 76
69#ifdef CONFIG_FB_PXA_PARAMETERS 77static inline unsigned long
70#define PXAFB_OPTIONS_SIZE 256 78lcd_readl(struct pxafb_info *fbi, unsigned int off)
71static char g_options[PXAFB_OPTIONS_SIZE] __devinitdata = ""; 79{
72#endif 80 return __raw_readl(fbi->mmio_base + off);
81}
82
83static inline void
84lcd_writel(struct pxafb_info *fbi, unsigned int off, unsigned long val)
85{
86 __raw_writel(val, fbi->mmio_base + off);
87}
73 88
74static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state) 89static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
75{ 90{
@@ -79,10 +94,12 @@ static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
79 /* 94 /*
80 * We need to handle two requests being made at the same time. 95 * We need to handle two requests being made at the same time.
81 * There are two important cases: 96 * There are two important cases:
82 * 1. When we are changing VT (C_REENABLE) while unblanking (C_ENABLE) 97 * 1. When we are changing VT (C_REENABLE) while unblanking
83 * We must perform the unblanking, which will do our REENABLE for us. 98 * (C_ENABLE) We must perform the unblanking, which will
84 * 2. When we are blanking, but immediately unblank before we have 99 * do our REENABLE for us.
85 * blanked. We do the "REENABLE" thing here as well, just to be sure. 100 * 2. When we are blanking, but immediately unblank before
101 * we have blanked. We do the "REENABLE" thing here as
102 * well, just to be sure.
86 */ 103 */
87 if (fbi->task_state == C_ENABLE && state == C_REENABLE) 104 if (fbi->task_state == C_ENABLE && state == C_REENABLE)
88 state = (u_int) -1; 105 state = (u_int) -1;
@@ -129,13 +146,13 @@ pxafb_setpalettereg(u_int regno, u_int red, u_int green, u_int blue,
129 val = ((red << 8) & 0x00f80000); 146 val = ((red << 8) & 0x00f80000);
130 val |= ((green >> 0) & 0x0000fc00); 147 val |= ((green >> 0) & 0x0000fc00);
131 val |= ((blue >> 8) & 0x000000f8); 148 val |= ((blue >> 8) & 0x000000f8);
132 ((u32*)(fbi->palette_cpu))[regno] = val; 149 ((u32 *)(fbi->palette_cpu))[regno] = val;
133 break; 150 break;
134 case LCCR4_PAL_FOR_2: 151 case LCCR4_PAL_FOR_2:
135 val = ((red << 8) & 0x00fc0000); 152 val = ((red << 8) & 0x00fc0000);
136 val |= ((green >> 0) & 0x0000fc00); 153 val |= ((green >> 0) & 0x0000fc00);
137 val |= ((blue >> 8) & 0x000000fc); 154 val |= ((blue >> 8) & 0x000000fc);
138 ((u32*)(fbi->palette_cpu))[regno] = val; 155 ((u32 *)(fbi->palette_cpu))[regno] = val;
139 break; 156 break;
140 } 157 }
141 158
@@ -203,15 +220,15 @@ pxafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
203 */ 220 */
204static int pxafb_bpp_to_lccr3(struct fb_var_screeninfo *var) 221static int pxafb_bpp_to_lccr3(struct fb_var_screeninfo *var)
205{ 222{
206 int ret = 0; 223 int ret = 0;
207 switch (var->bits_per_pixel) { 224 switch (var->bits_per_pixel) {
208 case 1: ret = LCCR3_1BPP; break; 225 case 1: ret = LCCR3_1BPP; break;
209 case 2: ret = LCCR3_2BPP; break; 226 case 2: ret = LCCR3_2BPP; break;
210 case 4: ret = LCCR3_4BPP; break; 227 case 4: ret = LCCR3_4BPP; break;
211 case 8: ret = LCCR3_8BPP; break; 228 case 8: ret = LCCR3_8BPP; break;
212 case 16: ret = LCCR3_16BPP; break; 229 case 16: ret = LCCR3_16BPP; break;
213 } 230 }
214 return ret; 231 return ret;
215} 232}
216 233
217#ifdef CONFIG_CPU_FREQ 234#ifdef CONFIG_CPU_FREQ
@@ -223,31 +240,32 @@ static int pxafb_bpp_to_lccr3(struct fb_var_screeninfo *var)
223 */ 240 */
224static unsigned int pxafb_display_dma_period(struct fb_var_screeninfo *var) 241static unsigned int pxafb_display_dma_period(struct fb_var_screeninfo *var)
225{ 242{
226 /* 243 /*
227 * Period = pixclock * bits_per_byte * bytes_per_transfer 244 * Period = pixclock * bits_per_byte * bytes_per_transfer
228 * / memory_bits_per_pixel; 245 * / memory_bits_per_pixel;
229 */ 246 */
230 return var->pixclock * 8 * 16 / var->bits_per_pixel; 247 return var->pixclock * 8 * 16 / var->bits_per_pixel;
231} 248}
232
233extern unsigned int get_clk_frequency_khz(int info);
234#endif 249#endif
235 250
236/* 251/*
237 * Select the smallest mode that allows the desired resolution to be 252 * Select the smallest mode that allows the desired resolution to be
238 * displayed. If desired parameters can be rounded up. 253 * displayed. If desired parameters can be rounded up.
239 */ 254 */
240static struct pxafb_mode_info *pxafb_getmode(struct pxafb_mach_info *mach, struct fb_var_screeninfo *var) 255static struct pxafb_mode_info *pxafb_getmode(struct pxafb_mach_info *mach,
256 struct fb_var_screeninfo *var)
241{ 257{
242 struct pxafb_mode_info *mode = NULL; 258 struct pxafb_mode_info *mode = NULL;
243 struct pxafb_mode_info *modelist = mach->modes; 259 struct pxafb_mode_info *modelist = mach->modes;
244 unsigned int best_x = 0xffffffff, best_y = 0xffffffff; 260 unsigned int best_x = 0xffffffff, best_y = 0xffffffff;
245 unsigned int i; 261 unsigned int i;
246 262
247 for (i = 0 ; i < mach->num_modes ; i++) { 263 for (i = 0; i < mach->num_modes; i++) {
248 if (modelist[i].xres >= var->xres && modelist[i].yres >= var->yres && 264 if (modelist[i].xres >= var->xres &&
249 modelist[i].xres < best_x && modelist[i].yres < best_y && 265 modelist[i].yres >= var->yres &&
250 modelist[i].bpp >= var->bits_per_pixel ) { 266 modelist[i].xres < best_x &&
267 modelist[i].yres < best_y &&
268 modelist[i].bpp >= var->bits_per_pixel) {
251 best_x = modelist[i].xres; 269 best_x = modelist[i].xres;
252 best_y = modelist[i].yres; 270 best_y = modelist[i].yres;
253 mode = &modelist[i]; 271 mode = &modelist[i];
@@ -257,7 +275,8 @@ static struct pxafb_mode_info *pxafb_getmode(struct pxafb_mach_info *mach, struc
257 return mode; 275 return mode;
258} 276}
259 277
260static void pxafb_setmode(struct fb_var_screeninfo *var, struct pxafb_mode_info *mode) 278static void pxafb_setmode(struct fb_var_screeninfo *var,
279 struct pxafb_mode_info *mode)
261{ 280{
262 var->xres = mode->xres; 281 var->xres = mode->xres;
263 var->yres = mode->yres; 282 var->yres = mode->yres;
@@ -315,19 +334,20 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
315 var->yres_virtual = 334 var->yres_virtual =
316 max(var->yres_virtual, var->yres); 335 max(var->yres_virtual, var->yres);
317 336
318 /* 337 /*
319 * Setup the RGB parameters for this display. 338 * Setup the RGB parameters for this display.
320 * 339 *
321 * The pixel packing format is described on page 7-11 of the 340 * The pixel packing format is described on page 7-11 of the
322 * PXA2XX Developer's Manual. 341 * PXA2XX Developer's Manual.
323 */ 342 */
324 if (var->bits_per_pixel == 16) { 343 if (var->bits_per_pixel == 16) {
325 var->red.offset = 11; var->red.length = 5; 344 var->red.offset = 11; var->red.length = 5;
326 var->green.offset = 5; var->green.length = 6; 345 var->green.offset = 5; var->green.length = 6;
327 var->blue.offset = 0; var->blue.length = 5; 346 var->blue.offset = 0; var->blue.length = 5;
328 var->transp.offset = var->transp.length = 0; 347 var->transp.offset = var->transp.length = 0;
329 } else { 348 } else {
330 var->red.offset = var->green.offset = var->blue.offset = var->transp.offset = 0; 349 var->red.offset = var->green.offset = 0;
350 var->blue.offset = var->transp.offset = 0;
331 var->red.length = 8; 351 var->red.length = 8;
332 var->green.length = 8; 352 var->green.length = 8;
333 var->blue.length = 8; 353 var->blue.length = 8;
@@ -345,8 +365,7 @@ static int pxafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
345 365
346static inline void pxafb_set_truecolor(u_int is_true_color) 366static inline void pxafb_set_truecolor(u_int is_true_color)
347{ 367{
348 pr_debug("pxafb: true_color = %d\n", is_true_color); 368 /* do your machine-specific setup if needed */
349 // do your machine-specific setup if needed
350} 369}
351 370
352/* 371/*
@@ -357,9 +376,6 @@ static int pxafb_set_par(struct fb_info *info)
357{ 376{
358 struct pxafb_info *fbi = (struct pxafb_info *)info; 377 struct pxafb_info *fbi = (struct pxafb_info *)info;
359 struct fb_var_screeninfo *var = &info->var; 378 struct fb_var_screeninfo *var = &info->var;
360 unsigned long palette_mem_size;
361
362 pr_debug("pxafb: set_par\n");
363 379
364 if (var->bits_per_pixel == 16) 380 if (var->bits_per_pixel == 16)
365 fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR; 381 fbi->fb.fix.visual = FB_VISUAL_TRUECOLOR;
@@ -379,17 +395,10 @@ static int pxafb_set_par(struct fb_info *info)
379 if (var->bits_per_pixel == 16) 395 if (var->bits_per_pixel == 16)
380 fbi->palette_size = 0; 396 fbi->palette_size = 0;
381 else 397 else
382 fbi->palette_size = var->bits_per_pixel == 1 ? 4 : 1 << var->bits_per_pixel; 398 fbi->palette_size = var->bits_per_pixel == 1 ?
383 399 4 : 1 << var->bits_per_pixel;
384 if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0)
385 palette_mem_size = fbi->palette_size * sizeof(u16);
386 else
387 palette_mem_size = fbi->palette_size * sizeof(u32);
388
389 pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size);
390 400
391 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size); 401 fbi->palette_cpu = (u16 *)&fbi->dma_buff->palette[0];
392 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size;
393 402
394 /* 403 /*
395 * Set (any) board control register to handle new color depth 404 * Set (any) board control register to handle new color depth
@@ -407,36 +416,6 @@ static int pxafb_set_par(struct fb_info *info)
407} 416}
408 417
409/* 418/*
410 * Formal definition of the VESA spec:
411 * On
412 * This refers to the state of the display when it is in full operation
413 * Stand-By
414 * This defines an optional operating state of minimal power reduction with
415 * the shortest recovery time
416 * Suspend
417 * This refers to a level of power management in which substantial power
418 * reduction is achieved by the display. The display can have a longer
419 * recovery time from this state than from the Stand-by state
420 * Off
421 * This indicates that the display is consuming the lowest level of power
422 * and is non-operational. Recovery from this state may optionally require
423 * the user to manually power on the monitor
424 *
425 * Now, the fbdev driver adds an additional state, (blank), where they
426 * turn off the video (maybe by colormap tricks), but don't mess with the
427 * video itself: think of it semantically between on and Stand-By.
428 *
429 * So here's what we should do in our fbdev blank routine:
430 *
431 * VESA_NO_BLANKING (mode 0) Video on, front/back light on
432 * VESA_VSYNC_SUSPEND (mode 1) Video on, front/back light off
433 * VESA_HSYNC_SUSPEND (mode 2) Video on, front/back light off
434 * VESA_POWERDOWN (mode 3) Video off, front/back light off
435 *
436 * This will match the matrox implementation.
437 */
438
439/*
440 * pxafb_blank(): 419 * pxafb_blank():
441 * Blank the display by setting all palette values to zero. Note, the 420 * Blank the display by setting all palette values to zero. Note, the
442 * 16 bpp mode does not really use the palette, so this will not 421 * 16 bpp mode does not really use the palette, so this will not
@@ -447,8 +426,6 @@ static int pxafb_blank(int blank, struct fb_info *info)
447 struct pxafb_info *fbi = (struct pxafb_info *)info; 426 struct pxafb_info *fbi = (struct pxafb_info *)info;
448 int i; 427 int i;
449 428
450 pr_debug("pxafb: blank=%d\n", blank);
451
452 switch (blank) { 429 switch (blank) {
453 case FB_BLANK_POWERDOWN: 430 case FB_BLANK_POWERDOWN:
454 case FB_BLANK_VSYNC_SUSPEND: 431 case FB_BLANK_VSYNC_SUSPEND:
@@ -460,11 +437,11 @@ static int pxafb_blank(int blank, struct fb_info *info)
460 pxafb_setpalettereg(i, 0, 0, 0, 0, info); 437 pxafb_setpalettereg(i, 0, 0, 0, 0, info);
461 438
462 pxafb_schedule_work(fbi, C_DISABLE); 439 pxafb_schedule_work(fbi, C_DISABLE);
463 //TODO if (pxafb_blank_helper) pxafb_blank_helper(blank); 440 /* TODO if (pxafb_blank_helper) pxafb_blank_helper(blank); */
464 break; 441 break;
465 442
466 case FB_BLANK_UNBLANK: 443 case FB_BLANK_UNBLANK:
467 //TODO if (pxafb_blank_helper) pxafb_blank_helper(blank); 444 /* TODO if (pxafb_blank_helper) pxafb_blank_helper(blank); */
468 if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR || 445 if (fbi->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR ||
469 fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR) 446 fbi->fb.fix.visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
470 fb_set_cmap(&fbi->fb.cmap, info); 447 fb_set_cmap(&fbi->fb.cmap, info);
@@ -480,7 +457,7 @@ static int pxafb_mmap(struct fb_info *info,
480 unsigned long off = vma->vm_pgoff << PAGE_SHIFT; 457 unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
481 458
482 if (off < info->fix.smem_len) { 459 if (off < info->fix.smem_len) {
483 vma->vm_pgoff += 1; 460 vma->vm_pgoff += fbi->video_offset / PAGE_SIZE;
484 return dma_mmap_writecombine(fbi->dev, vma, fbi->map_cpu, 461 return dma_mmap_writecombine(fbi->dev, vma, fbi->map_cpu,
485 fbi->map_dma, fbi->map_size); 462 fbi->map_dma, fbi->map_size);
486 } 463 }
@@ -529,7 +506,8 @@ static struct fb_ops pxafb_ops = {
529 * 506 *
530 * Factoring the 10^4 and 10^-12 out gives 10^-8 == 1 / 100000000 as used below. 507 * Factoring the 10^4 and 10^-12 out gives 10^-8 == 1 / 100000000 as used below.
531 */ 508 */
532static inline unsigned int get_pcd(struct pxafb_info *fbi, unsigned int pixclock) 509static inline unsigned int get_pcd(struct pxafb_info *fbi,
510 unsigned int pixclock)
533{ 511{
534 unsigned long long pcd; 512 unsigned long long pcd;
535 513
@@ -555,7 +533,7 @@ static inline void set_hsync_time(struct pxafb_info *fbi, unsigned int pcd)
555 unsigned long htime; 533 unsigned long htime;
556 534
557 if ((pcd == 0) || (fbi->fb.var.hsync_len == 0)) { 535 if ((pcd == 0) || (fbi->fb.var.hsync_len == 0)) {
558 fbi->hsync_time=0; 536 fbi->hsync_time = 0;
559 return; 537 return;
560 } 538 }
561 539
@@ -576,71 +554,231 @@ unsigned long pxafb_get_hsync_time(struct device *dev)
576} 554}
577EXPORT_SYMBOL(pxafb_get_hsync_time); 555EXPORT_SYMBOL(pxafb_get_hsync_time);
578 556
579/* 557static int setup_frame_dma(struct pxafb_info *fbi, int dma, int pal,
580 * pxafb_activate_var(): 558 unsigned int offset, size_t size)
581 * Configures LCD Controller based on entries in var parameter. Settings are
582 * only written to the controller if changes were made.
583 */
584static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *fbi)
585{ 559{
586 struct pxafb_lcd_reg new_regs; 560 struct pxafb_dma_descriptor *dma_desc, *pal_desc;
587 u_long flags; 561 unsigned int dma_desc_off, pal_desc_off;
588 u_int lines_per_panel, pcd = get_pcd(fbi, var->pixclock);
589 562
590 pr_debug("pxafb: Configuring PXA LCD\n"); 563 if (dma < 0 || dma >= DMA_MAX)
564 return -EINVAL;
591 565
592 pr_debug("var: xres=%d hslen=%d lm=%d rm=%d\n", 566 dma_desc = &fbi->dma_buff->dma_desc[dma];
593 var->xres, var->hsync_len, 567 dma_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[dma]);
594 var->left_margin, var->right_margin);
595 pr_debug("var: yres=%d vslen=%d um=%d bm=%d\n",
596 var->yres, var->vsync_len,
597 var->upper_margin, var->lower_margin);
598 pr_debug("var: pixclock=%d pcd=%d\n", var->pixclock, pcd);
599 568
600#if DEBUG_VAR 569 dma_desc->fsadr = fbi->screen_dma + offset;
601 if (var->xres < 16 || var->xres > 1024) 570 dma_desc->fidr = 0;
602 printk(KERN_ERR "%s: invalid xres %d\n", 571 dma_desc->ldcmd = size;
603 fbi->fb.fix.id, var->xres); 572
604 switch(var->bits_per_pixel) { 573 if (pal < 0 || pal >= PAL_MAX) {
605 case 1: 574 dma_desc->fdadr = fbi->dma_buff_phys + dma_desc_off;
606 case 2: 575 fbi->fdadr[dma] = fbi->dma_buff_phys + dma_desc_off;
607 case 4: 576 } else {
608 case 8: 577 pal_desc = &fbi->dma_buff->pal_desc[dma];
609 case 16: 578 pal_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[pal]);
610 break; 579
611 default: 580 pal_desc->fsadr = fbi->dma_buff_phys + pal * PALETTE_SIZE;
612 printk(KERN_ERR "%s: invalid bit depth %d\n", 581 pal_desc->fidr = 0;
613 fbi->fb.fix.id, var->bits_per_pixel); 582
614 break; 583 if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0)
584 pal_desc->ldcmd = fbi->palette_size * sizeof(u16);
585 else
586 pal_desc->ldcmd = fbi->palette_size * sizeof(u32);
587
588 pal_desc->ldcmd |= LDCMD_PAL;
589
590 /* flip back and forth between palette and frame buffer */
591 pal_desc->fdadr = fbi->dma_buff_phys + dma_desc_off;
592 dma_desc->fdadr = fbi->dma_buff_phys + pal_desc_off;
593 fbi->fdadr[dma] = fbi->dma_buff_phys + dma_desc_off;
615 } 594 }
616 if (var->hsync_len < 1 || var->hsync_len > 64)
617 printk(KERN_ERR "%s: invalid hsync_len %d\n",
618 fbi->fb.fix.id, var->hsync_len);
619 if (var->left_margin < 1 || var->left_margin > 255)
620 printk(KERN_ERR "%s: invalid left_margin %d\n",
621 fbi->fb.fix.id, var->left_margin);
622 if (var->right_margin < 1 || var->right_margin > 255)
623 printk(KERN_ERR "%s: invalid right_margin %d\n",
624 fbi->fb.fix.id, var->right_margin);
625 if (var->yres < 1 || var->yres > 1024)
626 printk(KERN_ERR "%s: invalid yres %d\n",
627 fbi->fb.fix.id, var->yres);
628 if (var->vsync_len < 1 || var->vsync_len > 64)
629 printk(KERN_ERR "%s: invalid vsync_len %d\n",
630 fbi->fb.fix.id, var->vsync_len);
631 if (var->upper_margin < 0 || var->upper_margin > 255)
632 printk(KERN_ERR "%s: invalid upper_margin %d\n",
633 fbi->fb.fix.id, var->upper_margin);
634 if (var->lower_margin < 0 || var->lower_margin > 255)
635 printk(KERN_ERR "%s: invalid lower_margin %d\n",
636 fbi->fb.fix.id, var->lower_margin);
637#endif
638 595
639 new_regs.lccr0 = fbi->lccr0 | 596 return 0;
640 (LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | 597}
641 LCCR0_QDM | LCCR0_BM | LCCR0_OUM); 598
599#ifdef CONFIG_FB_PXA_SMARTPANEL
600static int setup_smart_dma(struct pxafb_info *fbi)
601{
602 struct pxafb_dma_descriptor *dma_desc;
603 unsigned long dma_desc_off, cmd_buff_off;
604
605 dma_desc = &fbi->dma_buff->dma_desc[DMA_CMD];
606 dma_desc_off = offsetof(struct pxafb_dma_buff, dma_desc[DMA_CMD]);
607 cmd_buff_off = offsetof(struct pxafb_dma_buff, cmd_buff);
608
609 dma_desc->fdadr = fbi->dma_buff_phys + dma_desc_off;
610 dma_desc->fsadr = fbi->dma_buff_phys + cmd_buff_off;
611 dma_desc->fidr = 0;
612 dma_desc->ldcmd = fbi->n_smart_cmds * sizeof(uint16_t);
613
614 fbi->fdadr[DMA_CMD] = dma_desc->fdadr;
615 return 0;
616}
617
618int pxafb_smart_flush(struct fb_info *info)
619{
620 struct pxafb_info *fbi = container_of(info, struct pxafb_info, fb);
621 uint32_t prsr;
622 int ret = 0;
623
624 /* disable controller until all registers are set up */
625 lcd_writel(fbi, LCCR0, fbi->reg_lccr0 & ~LCCR0_ENB);
626
627 /* 1. make it an even number of commands to align on 32-bit boundary
628 * 2. add the interrupt command to the end of the chain so we can
629 * keep track of the end of the transfer
630 */
631
632 while (fbi->n_smart_cmds & 1)
633 fbi->smart_cmds[fbi->n_smart_cmds++] = SMART_CMD_NOOP;
634
635 fbi->smart_cmds[fbi->n_smart_cmds++] = SMART_CMD_INTERRUPT;
636 fbi->smart_cmds[fbi->n_smart_cmds++] = SMART_CMD_WAIT_FOR_VSYNC;
637 setup_smart_dma(fbi);
638
639 /* continue to execute next command */
640 prsr = lcd_readl(fbi, PRSR) | PRSR_ST_OK | PRSR_CON_NT;
641 lcd_writel(fbi, PRSR, prsr);
642
643 /* stop the processor in case it executed "wait for sync" cmd */
644 lcd_writel(fbi, CMDCR, 0x0001);
645
646 /* don't send interrupts for fifo underruns on channel 6 */
647 lcd_writel(fbi, LCCR5, LCCR5_IUM(6));
648
649 lcd_writel(fbi, LCCR1, fbi->reg_lccr1);
650 lcd_writel(fbi, LCCR2, fbi->reg_lccr2);
651 lcd_writel(fbi, LCCR3, fbi->reg_lccr3);
652 lcd_writel(fbi, FDADR0, fbi->fdadr[0]);
653 lcd_writel(fbi, FDADR6, fbi->fdadr[6]);
654
655 /* begin sending */
656 lcd_writel(fbi, LCCR0, fbi->reg_lccr0 | LCCR0_ENB);
657
658 if (wait_for_completion_timeout(&fbi->command_done, HZ/2) == 0) {
659 pr_warning("%s: timeout waiting for command done\n",
660 __func__);
661 ret = -ETIMEDOUT;
662 }
663
664 /* quick disable */
665 prsr = lcd_readl(fbi, PRSR) & ~(PRSR_ST_OK | PRSR_CON_NT);
666 lcd_writel(fbi, PRSR, prsr);
667 lcd_writel(fbi, LCCR0, fbi->reg_lccr0 & ~LCCR0_ENB);
668 lcd_writel(fbi, FDADR6, 0);
669 fbi->n_smart_cmds = 0;
670 return ret;
671}
672
673int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int n_cmds)
674{
675 int i;
676 struct pxafb_info *fbi = container_of(info, struct pxafb_info, fb);
677
678 /* leave 2 commands for INTERRUPT and WAIT_FOR_SYNC */
679 for (i = 0; i < n_cmds; i++) {
680 if (fbi->n_smart_cmds == CMD_BUFF_SIZE - 8)
681 pxafb_smart_flush(info);
682
683 fbi->smart_cmds[fbi->n_smart_cmds++] = *cmds++;
684 }
685
686 return 0;
687}
688
689static unsigned int __smart_timing(unsigned time_ns, unsigned long lcd_clk)
690{
691 unsigned int t = (time_ns * (lcd_clk / 1000000) / 1000);
692 return (t == 0) ? 1 : t;
693}
694
695static void setup_smart_timing(struct pxafb_info *fbi,
696 struct fb_var_screeninfo *var)
697{
698 struct pxafb_mach_info *inf = fbi->dev->platform_data;
699 struct pxafb_mode_info *mode = &inf->modes[0];
700 unsigned long lclk = clk_get_rate(fbi->clk);
701 unsigned t1, t2, t3, t4;
702
703 t1 = max(mode->a0csrd_set_hld, mode->a0cswr_set_hld);
704 t2 = max(mode->rd_pulse_width, mode->wr_pulse_width);
705 t3 = mode->op_hold_time;
706 t4 = mode->cmd_inh_time;
707
708 fbi->reg_lccr1 =
709 LCCR1_DisWdth(var->xres) |
710 LCCR1_BegLnDel(__smart_timing(t1, lclk)) |
711 LCCR1_EndLnDel(__smart_timing(t2, lclk)) |
712 LCCR1_HorSnchWdth(__smart_timing(t3, lclk));
713
714 fbi->reg_lccr2 = LCCR2_DisHght(var->yres);
715 fbi->reg_lccr3 = LCCR3_PixClkDiv(__smart_timing(t4, lclk));
716
717 /* FIXME: make this configurable */
718 fbi->reg_cmdcr = 1;
719}
720
721static int pxafb_smart_thread(void *arg)
722{
723 struct pxafb_info *fbi = arg;
724 struct pxafb_mach_info *inf = fbi->dev->platform_data;
725
726 if (!fbi || !inf->smart_update) {
727 pr_err("%s: not properly initialized, thread terminated\n",
728 __func__);
729 return -EINVAL;
730 }
642 731
643 new_regs.lccr1 = 732 pr_debug("%s(): task starting\n", __func__);
733
734 set_freezable();
735 while (!kthread_should_stop()) {
736
737 if (try_to_freeze())
738 continue;
739
740 if (fbi->state == C_ENABLE) {
741 inf->smart_update(&fbi->fb);
742 complete(&fbi->refresh_done);
743 }
744
745 set_current_state(TASK_INTERRUPTIBLE);
746 schedule_timeout(30 * HZ / 1000);
747 }
748
749 pr_debug("%s(): task ending\n", __func__);
750 return 0;
751}
752
753static int pxafb_smart_init(struct pxafb_info *fbi)
754{
755 fbi->smart_thread = kthread_run(pxafb_smart_thread, fbi,
756 "lcd_refresh");
757 if (IS_ERR(fbi->smart_thread)) {
758 printk(KERN_ERR "%s: unable to create kernel thread\n",
759 __func__);
760 return PTR_ERR(fbi->smart_thread);
761 }
762 return 0;
763}
764#else
765int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int n_cmds)
766{
767 return 0;
768}
769
770int pxafb_smart_flush(struct fb_info *info)
771{
772 return 0;
773}
774#endif /* CONFIG_FB_SMART_PANEL */
775
776static void setup_parallel_timing(struct pxafb_info *fbi,
777 struct fb_var_screeninfo *var)
778{
779 unsigned int lines_per_panel, pcd = get_pcd(fbi, var->pixclock);
780
781 fbi->reg_lccr1 =
644 LCCR1_DisWdth(var->xres) + 782 LCCR1_DisWdth(var->xres) +
645 LCCR1_HorSnchWdth(var->hsync_len) + 783 LCCR1_HorSnchWdth(var->hsync_len) +
646 LCCR1_BegLnDel(var->left_margin) + 784 LCCR1_BegLnDel(var->left_margin) +
@@ -654,110 +792,118 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
654 if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual) 792 if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual)
655 lines_per_panel /= 2; 793 lines_per_panel /= 2;
656 794
657 new_regs.lccr2 = 795 fbi->reg_lccr2 =
658 LCCR2_DisHght(lines_per_panel) + 796 LCCR2_DisHght(lines_per_panel) +
659 LCCR2_VrtSnchWdth(var->vsync_len) + 797 LCCR2_VrtSnchWdth(var->vsync_len) +
660 LCCR2_BegFrmDel(var->upper_margin) + 798 LCCR2_BegFrmDel(var->upper_margin) +
661 LCCR2_EndFrmDel(var->lower_margin); 799 LCCR2_EndFrmDel(var->lower_margin);
662 800
663 new_regs.lccr3 = fbi->lccr3 | 801 fbi->reg_lccr3 = fbi->lccr3 |
664 pxafb_bpp_to_lccr3(var) | 802 (var->sync & FB_SYNC_HOR_HIGH_ACT ?
665 (var->sync & FB_SYNC_HOR_HIGH_ACT ? LCCR3_HorSnchH : LCCR3_HorSnchL) | 803 LCCR3_HorSnchH : LCCR3_HorSnchL) |
666 (var->sync & FB_SYNC_VERT_HIGH_ACT ? LCCR3_VrtSnchH : LCCR3_VrtSnchL); 804 (var->sync & FB_SYNC_VERT_HIGH_ACT ?
805 LCCR3_VrtSnchH : LCCR3_VrtSnchL);
806
807 if (pcd) {
808 fbi->reg_lccr3 |= LCCR3_PixClkDiv(pcd);
809 set_hsync_time(fbi, pcd);
810 }
811}
667 812
668 if (pcd) 813/*
669 new_regs.lccr3 |= LCCR3_PixClkDiv(pcd); 814 * pxafb_activate_var():
815 * Configures LCD Controller based on entries in var parameter.
816 * Settings are only written to the controller if changes were made.
817 */
818static int pxafb_activate_var(struct fb_var_screeninfo *var,
819 struct pxafb_info *fbi)
820{
821 u_long flags;
822 size_t nbytes;
670 823
671 pr_debug("nlccr0 = 0x%08x\n", new_regs.lccr0); 824#if DEBUG_VAR
672 pr_debug("nlccr1 = 0x%08x\n", new_regs.lccr1); 825 if (!(fbi->lccr0 & LCCR0_LCDT)) {
673 pr_debug("nlccr2 = 0x%08x\n", new_regs.lccr2); 826 if (var->xres < 16 || var->xres > 1024)
674 pr_debug("nlccr3 = 0x%08x\n", new_regs.lccr3); 827 printk(KERN_ERR "%s: invalid xres %d\n",
828 fbi->fb.fix.id, var->xres);
829 switch (var->bits_per_pixel) {
830 case 1:
831 case 2:
832 case 4:
833 case 8:
834 case 16:
835 break;
836 default:
837 printk(KERN_ERR "%s: invalid bit depth %d\n",
838 fbi->fb.fix.id, var->bits_per_pixel);
839 break;
840 }
675 841
842 if (var->hsync_len < 1 || var->hsync_len > 64)
843 printk(KERN_ERR "%s: invalid hsync_len %d\n",
844 fbi->fb.fix.id, var->hsync_len);
845 if (var->left_margin < 1 || var->left_margin > 255)
846 printk(KERN_ERR "%s: invalid left_margin %d\n",
847 fbi->fb.fix.id, var->left_margin);
848 if (var->right_margin < 1 || var->right_margin > 255)
849 printk(KERN_ERR "%s: invalid right_margin %d\n",
850 fbi->fb.fix.id, var->right_margin);
851 if (var->yres < 1 || var->yres > 1024)
852 printk(KERN_ERR "%s: invalid yres %d\n",
853 fbi->fb.fix.id, var->yres);
854 if (var->vsync_len < 1 || var->vsync_len > 64)
855 printk(KERN_ERR "%s: invalid vsync_len %d\n",
856 fbi->fb.fix.id, var->vsync_len);
857 if (var->upper_margin < 0 || var->upper_margin > 255)
858 printk(KERN_ERR "%s: invalid upper_margin %d\n",
859 fbi->fb.fix.id, var->upper_margin);
860 if (var->lower_margin < 0 || var->lower_margin > 255)
861 printk(KERN_ERR "%s: invalid lower_margin %d\n",
862 fbi->fb.fix.id, var->lower_margin);
863 }
864#endif
676 /* Update shadow copy atomically */ 865 /* Update shadow copy atomically */
677 local_irq_save(flags); 866 local_irq_save(flags);
678 867
679 /* setup dma descriptors */ 868#ifdef CONFIG_FB_PXA_SMARTPANEL
680 fbi->dmadesc_fblow_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 3*16); 869 if (fbi->lccr0 & LCCR0_LCDT)
681 fbi->dmadesc_fbhigh_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 2*16); 870 setup_smart_timing(fbi, var);
682 fbi->dmadesc_palette_cpu = (struct pxafb_dma_descriptor *)((unsigned int)fbi->palette_cpu - 1*16); 871 else
683 872#endif
684 fbi->dmadesc_fblow_dma = fbi->palette_dma - 3*16; 873 setup_parallel_timing(fbi, var);
685 fbi->dmadesc_fbhigh_dma = fbi->palette_dma - 2*16;
686 fbi->dmadesc_palette_dma = fbi->palette_dma - 1*16;
687
688#define BYTES_PER_PANEL (lines_per_panel * fbi->fb.fix.line_length)
689
690 /* populate descriptors */
691 fbi->dmadesc_fblow_cpu->fdadr = fbi->dmadesc_fblow_dma;
692 fbi->dmadesc_fblow_cpu->fsadr = fbi->screen_dma + BYTES_PER_PANEL;
693 fbi->dmadesc_fblow_cpu->fidr = 0;
694 fbi->dmadesc_fblow_cpu->ldcmd = BYTES_PER_PANEL;
695 874
696 fbi->fdadr1 = fbi->dmadesc_fblow_dma; /* only used in dual-panel mode */ 875 fbi->reg_lccr0 = fbi->lccr0 |
876 (LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM |
877 LCCR0_QDM | LCCR0_BM | LCCR0_OUM);
697 878
698 fbi->dmadesc_fbhigh_cpu->fsadr = fbi->screen_dma; 879 fbi->reg_lccr3 |= pxafb_bpp_to_lccr3(var);
699 fbi->dmadesc_fbhigh_cpu->fidr = 0;
700 fbi->dmadesc_fbhigh_cpu->ldcmd = BYTES_PER_PANEL;
701 880
702 fbi->dmadesc_palette_cpu->fsadr = fbi->palette_dma; 881 nbytes = var->yres * fbi->fb.fix.line_length;
703 fbi->dmadesc_palette_cpu->fidr = 0;
704 if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0)
705 fbi->dmadesc_palette_cpu->ldcmd = fbi->palette_size *
706 sizeof(u16);
707 else
708 fbi->dmadesc_palette_cpu->ldcmd = fbi->palette_size *
709 sizeof(u32);
710 fbi->dmadesc_palette_cpu->ldcmd |= LDCMD_PAL;
711 882
712 if (var->bits_per_pixel == 16) { 883 if ((fbi->lccr0 & LCCR0_SDS) == LCCR0_Dual) {
713 /* palette shouldn't be loaded in true-color mode */ 884 nbytes = nbytes / 2;
714 fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_fbhigh_dma; 885 setup_frame_dma(fbi, DMA_LOWER, PAL_NONE, nbytes, nbytes);
715 fbi->fdadr0 = fbi->dmadesc_fbhigh_dma; /* no pal just fbhigh */
716 /* init it to something, even though we won't be using it */
717 fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_palette_dma;
718 } else {
719 fbi->dmadesc_palette_cpu->fdadr = fbi->dmadesc_fbhigh_dma;
720 fbi->dmadesc_fbhigh_cpu->fdadr = fbi->dmadesc_palette_dma;
721 fbi->fdadr0 = fbi->dmadesc_palette_dma; /* flips back and forth between pal and fbhigh */
722 } 886 }
723 887
724#if 0 888 if ((var->bits_per_pixel >= 16) || (fbi->lccr0 & LCCR0_LCDT))
725 pr_debug("fbi->dmadesc_fblow_cpu = 0x%p\n", fbi->dmadesc_fblow_cpu); 889 setup_frame_dma(fbi, DMA_BASE, PAL_NONE, 0, nbytes);
726 pr_debug("fbi->dmadesc_fbhigh_cpu = 0x%p\n", fbi->dmadesc_fbhigh_cpu); 890 else
727 pr_debug("fbi->dmadesc_palette_cpu = 0x%p\n", fbi->dmadesc_palette_cpu); 891 setup_frame_dma(fbi, DMA_BASE, PAL_BASE, 0, nbytes);
728 pr_debug("fbi->dmadesc_fblow_dma = 0x%x\n", fbi->dmadesc_fblow_dma);
729 pr_debug("fbi->dmadesc_fbhigh_dma = 0x%x\n", fbi->dmadesc_fbhigh_dma);
730 pr_debug("fbi->dmadesc_palette_dma = 0x%x\n", fbi->dmadesc_palette_dma);
731
732 pr_debug("fbi->dmadesc_fblow_cpu->fdadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fdadr);
733 pr_debug("fbi->dmadesc_fbhigh_cpu->fdadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fdadr);
734 pr_debug("fbi->dmadesc_palette_cpu->fdadr = 0x%x\n", fbi->dmadesc_palette_cpu->fdadr);
735
736 pr_debug("fbi->dmadesc_fblow_cpu->fsadr = 0x%x\n", fbi->dmadesc_fblow_cpu->fsadr);
737 pr_debug("fbi->dmadesc_fbhigh_cpu->fsadr = 0x%x\n", fbi->dmadesc_fbhigh_cpu->fsadr);
738 pr_debug("fbi->dmadesc_palette_cpu->fsadr = 0x%x\n", fbi->dmadesc_palette_cpu->fsadr);
739
740 pr_debug("fbi->dmadesc_fblow_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fblow_cpu->ldcmd);
741 pr_debug("fbi->dmadesc_fbhigh_cpu->ldcmd = 0x%x\n", fbi->dmadesc_fbhigh_cpu->ldcmd);
742 pr_debug("fbi->dmadesc_palette_cpu->ldcmd = 0x%x\n", fbi->dmadesc_palette_cpu->ldcmd);
743#endif
744 892
745 fbi->reg_lccr0 = new_regs.lccr0; 893 fbi->reg_lccr4 = lcd_readl(fbi, LCCR4) & ~LCCR4_PAL_FOR_MASK;
746 fbi->reg_lccr1 = new_regs.lccr1;
747 fbi->reg_lccr2 = new_regs.lccr2;
748 fbi->reg_lccr3 = new_regs.lccr3;
749 fbi->reg_lccr4 = LCCR4 & (~LCCR4_PAL_FOR_MASK);
750 fbi->reg_lccr4 |= (fbi->lccr4 & LCCR4_PAL_FOR_MASK); 894 fbi->reg_lccr4 |= (fbi->lccr4 & LCCR4_PAL_FOR_MASK);
751 set_hsync_time(fbi, pcd);
752 local_irq_restore(flags); 895 local_irq_restore(flags);
753 896
754 /* 897 /*
755 * Only update the registers if the controller is enabled 898 * Only update the registers if the controller is enabled
756 * and something has changed. 899 * and something has changed.
757 */ 900 */
758 if ((LCCR0 != fbi->reg_lccr0) || (LCCR1 != fbi->reg_lccr1) || 901 if ((lcd_readl(fbi, LCCR0) != fbi->reg_lccr0) ||
759 (LCCR2 != fbi->reg_lccr2) || (LCCR3 != fbi->reg_lccr3) || 902 (lcd_readl(fbi, LCCR1) != fbi->reg_lccr1) ||
760 (FDADR0 != fbi->fdadr0) || (FDADR1 != fbi->fdadr1)) 903 (lcd_readl(fbi, LCCR2) != fbi->reg_lccr2) ||
904 (lcd_readl(fbi, LCCR3) != fbi->reg_lccr3) ||
905 (lcd_readl(fbi, FDADR0) != fbi->fdadr[0]) ||
906 (lcd_readl(fbi, FDADR1) != fbi->fdadr[1]))
761 pxafb_schedule_work(fbi, C_REENABLE); 907 pxafb_schedule_work(fbi, C_REENABLE);
762 908
763 return 0; 909 return 0;
@@ -773,8 +919,8 @@ static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
773{ 919{
774 pr_debug("pxafb: backlight o%s\n", on ? "n" : "ff"); 920 pr_debug("pxafb: backlight o%s\n", on ? "n" : "ff");
775 921
776 if (pxafb_backlight_power) 922 if (pxafb_backlight_power)
777 pxafb_backlight_power(on); 923 pxafb_backlight_power(on);
778} 924}
779 925
780static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on) 926static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
@@ -788,11 +934,11 @@ static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
788static void pxafb_setup_gpio(struct pxafb_info *fbi) 934static void pxafb_setup_gpio(struct pxafb_info *fbi)
789{ 935{
790 int gpio, ldd_bits; 936 int gpio, ldd_bits;
791 unsigned int lccr0 = fbi->lccr0; 937 unsigned int lccr0 = fbi->lccr0;
792 938
793 /* 939 /*
794 * setup is based on type of panel supported 940 * setup is based on type of panel supported
795 */ 941 */
796 942
797 /* 4 bit interface */ 943 /* 4 bit interface */
798 if ((lccr0 & LCCR0_CMS) == LCCR0_Mono && 944 if ((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
@@ -801,21 +947,25 @@ static void pxafb_setup_gpio(struct pxafb_info *fbi)
801 ldd_bits = 4; 947 ldd_bits = 4;
802 948
803 /* 8 bit interface */ 949 /* 8 bit interface */
804 else if (((lccr0 & LCCR0_CMS) == LCCR0_Mono && 950 else if (((lccr0 & LCCR0_CMS) == LCCR0_Mono &&
805 ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_DPD) == LCCR0_8PixMono)) || 951 ((lccr0 & LCCR0_SDS) == LCCR0_Dual ||
806 ((lccr0 & LCCR0_CMS) == LCCR0_Color && 952 (lccr0 & LCCR0_DPD) == LCCR0_8PixMono)) ||
807 (lccr0 & LCCR0_PAS) == LCCR0_Pas && (lccr0 & LCCR0_SDS) == LCCR0_Sngl)) 953 ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
954 (lccr0 & LCCR0_PAS) == LCCR0_Pas &&
955 (lccr0 & LCCR0_SDS) == LCCR0_Sngl))
808 ldd_bits = 8; 956 ldd_bits = 8;
809 957
810 /* 16 bit interface */ 958 /* 16 bit interface */
811 else if ((lccr0 & LCCR0_CMS) == LCCR0_Color && 959 else if ((lccr0 & LCCR0_CMS) == LCCR0_Color &&
812 ((lccr0 & LCCR0_SDS) == LCCR0_Dual || (lccr0 & LCCR0_PAS) == LCCR0_Act)) 960 ((lccr0 & LCCR0_SDS) == LCCR0_Dual ||
961 (lccr0 & LCCR0_PAS) == LCCR0_Act))
813 ldd_bits = 16; 962 ldd_bits = 16;
814 963
815 else { 964 else {
816 printk(KERN_ERR "pxafb_setup_gpio: unable to determine bits per pixel\n"); 965 printk(KERN_ERR "pxafb_setup_gpio: unable to determine "
966 "bits per pixel\n");
817 return; 967 return;
818 } 968 }
819 969
820 for (gpio = 58; ldd_bits; gpio++, ldd_bits--) 970 for (gpio = 58; ldd_bits; gpio++, ldd_bits--)
821 pxa_gpio_mode(gpio | GPIO_ALT_FN_2_OUT); 971 pxa_gpio_mode(gpio | GPIO_ALT_FN_2_OUT);
@@ -828,8 +978,8 @@ static void pxafb_setup_gpio(struct pxafb_info *fbi)
828static void pxafb_enable_controller(struct pxafb_info *fbi) 978static void pxafb_enable_controller(struct pxafb_info *fbi)
829{ 979{
830 pr_debug("pxafb: Enabling LCD controller\n"); 980 pr_debug("pxafb: Enabling LCD controller\n");
831 pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr0); 981 pr_debug("fdadr0 0x%08x\n", (unsigned int) fbi->fdadr[0]);
832 pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr1); 982 pr_debug("fdadr1 0x%08x\n", (unsigned int) fbi->fdadr[1]);
833 pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0); 983 pr_debug("reg_lccr0 0x%08x\n", (unsigned int) fbi->reg_lccr0);
834 pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1); 984 pr_debug("reg_lccr1 0x%08x\n", (unsigned int) fbi->reg_lccr1);
835 pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2); 985 pr_debug("reg_lccr2 0x%08x\n", (unsigned int) fbi->reg_lccr2);
@@ -838,40 +988,40 @@ static void pxafb_enable_controller(struct pxafb_info *fbi)
838 /* enable LCD controller clock */ 988 /* enable LCD controller clock */
839 clk_enable(fbi->clk); 989 clk_enable(fbi->clk);
840 990
991 if (fbi->lccr0 & LCCR0_LCDT)
992 return;
993
841 /* Sequence from 11.7.10 */ 994 /* Sequence from 11.7.10 */
842 LCCR3 = fbi->reg_lccr3; 995 lcd_writel(fbi, LCCR3, fbi->reg_lccr3);
843 LCCR2 = fbi->reg_lccr2; 996 lcd_writel(fbi, LCCR2, fbi->reg_lccr2);
844 LCCR1 = fbi->reg_lccr1; 997 lcd_writel(fbi, LCCR1, fbi->reg_lccr1);
845 LCCR0 = fbi->reg_lccr0 & ~LCCR0_ENB; 998 lcd_writel(fbi, LCCR0, fbi->reg_lccr0 & ~LCCR0_ENB);
846 999
847 FDADR0 = fbi->fdadr0; 1000 lcd_writel(fbi, FDADR0, fbi->fdadr[0]);
848 FDADR1 = fbi->fdadr1; 1001 lcd_writel(fbi, FDADR1, fbi->fdadr[1]);
849 LCCR0 |= LCCR0_ENB; 1002 lcd_writel(fbi, LCCR0, fbi->reg_lccr0 | LCCR0_ENB);
850
851 pr_debug("FDADR0 0x%08x\n", (unsigned int) FDADR0);
852 pr_debug("FDADR1 0x%08x\n", (unsigned int) FDADR1);
853 pr_debug("LCCR0 0x%08x\n", (unsigned int) LCCR0);
854 pr_debug("LCCR1 0x%08x\n", (unsigned int) LCCR1);
855 pr_debug("LCCR2 0x%08x\n", (unsigned int) LCCR2);
856 pr_debug("LCCR3 0x%08x\n", (unsigned int) LCCR3);
857 pr_debug("LCCR4 0x%08x\n", (unsigned int) LCCR4);
858} 1003}
859 1004
860static void pxafb_disable_controller(struct pxafb_info *fbi) 1005static void pxafb_disable_controller(struct pxafb_info *fbi)
861{ 1006{
862 DECLARE_WAITQUEUE(wait, current); 1007 uint32_t lccr0;
863 1008
864 pr_debug("pxafb: disabling LCD controller\n"); 1009#ifdef CONFIG_FB_PXA_SMARTPANEL
1010 if (fbi->lccr0 & LCCR0_LCDT) {
1011 wait_for_completion_timeout(&fbi->refresh_done,
1012 200 * HZ / 1000);
1013 return;
1014 }
1015#endif
865 1016
866 set_current_state(TASK_UNINTERRUPTIBLE); 1017 /* Clear LCD Status Register */
867 add_wait_queue(&fbi->ctrlr_wait, &wait); 1018 lcd_writel(fbi, LCSR, 0xffffffff);
868 1019
869 LCSR = 0xffffffff; /* Clear LCD Status Register */ 1020 lccr0 = lcd_readl(fbi, LCCR0) & ~LCCR0_LDM;
870 LCCR0 &= ~LCCR0_LDM; /* Enable LCD Disable Done Interrupt */ 1021 lcd_writel(fbi, LCCR0, lccr0);
871 LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */ 1022 lcd_writel(fbi, LCCR0, lccr0 | LCCR0_DIS);
872 1023
873 schedule_timeout(200 * HZ / 1000); 1024 wait_for_completion_timeout(&fbi->disable_done, 200 * HZ / 1000);
874 remove_wait_queue(&fbi->ctrlr_wait, &wait);
875 1025
876 /* disable LCD controller clock */ 1026 /* disable LCD controller clock */
877 clk_disable(fbi->clk); 1027 clk_disable(fbi->clk);
@@ -883,14 +1033,20 @@ static void pxafb_disable_controller(struct pxafb_info *fbi)
883static irqreturn_t pxafb_handle_irq(int irq, void *dev_id) 1033static irqreturn_t pxafb_handle_irq(int irq, void *dev_id)
884{ 1034{
885 struct pxafb_info *fbi = dev_id; 1035 struct pxafb_info *fbi = dev_id;
886 unsigned int lcsr = LCSR; 1036 unsigned int lccr0, lcsr = lcd_readl(fbi, LCSR);
887 1037
888 if (lcsr & LCSR_LDD) { 1038 if (lcsr & LCSR_LDD) {
889 LCCR0 |= LCCR0_LDM; 1039 lccr0 = lcd_readl(fbi, LCCR0);
890 wake_up(&fbi->ctrlr_wait); 1040 lcd_writel(fbi, LCCR0, lccr0 | LCCR0_LDM);
1041 complete(&fbi->disable_done);
891 } 1042 }
892 1043
893 LCSR = lcsr; 1044#ifdef CONFIG_FB_PXA_SMARTPANEL
1045 if (lcsr & LCSR_CMD_INT)
1046 complete(&fbi->command_done);
1047#endif
1048
1049 lcd_writel(fbi, LCSR, lcsr);
894 return IRQ_HANDLED; 1050 return IRQ_HANDLED;
895} 1051}
896 1052
@@ -921,7 +1077,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
921 */ 1077 */
922 if (old_state != C_DISABLE && old_state != C_DISABLE_PM) { 1078 if (old_state != C_DISABLE && old_state != C_DISABLE_PM) {
923 fbi->state = state; 1079 fbi->state = state;
924 //TODO __pxafb_lcd_power(fbi, 0); 1080 /* TODO __pxafb_lcd_power(fbi, 0); */
925 pxafb_disable_controller(fbi); 1081 pxafb_disable_controller(fbi);
926 } 1082 }
927 break; 1083 break;
@@ -948,7 +1104,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
948 if (old_state == C_DISABLE_CLKCHANGE) { 1104 if (old_state == C_DISABLE_CLKCHANGE) {
949 fbi->state = C_ENABLE; 1105 fbi->state = C_ENABLE;
950 pxafb_enable_controller(fbi); 1106 pxafb_enable_controller(fbi);
951 //TODO __pxafb_lcd_power(fbi, 1); 1107 /* TODO __pxafb_lcd_power(fbi, 1); */
952 } 1108 }
953 break; 1109 break;
954 1110
@@ -1019,7 +1175,7 @@ static int
1019pxafb_freq_transition(struct notifier_block *nb, unsigned long val, void *data) 1175pxafb_freq_transition(struct notifier_block *nb, unsigned long val, void *data)
1020{ 1176{
1021 struct pxafb_info *fbi = TO_INF(nb, freq_transition); 1177 struct pxafb_info *fbi = TO_INF(nb, freq_transition);
1022 //TODO struct cpufreq_freqs *f = data; 1178 /* TODO struct cpufreq_freqs *f = data; */
1023 u_int pcd; 1179 u_int pcd;
1024 1180
1025 switch (val) { 1181 switch (val) {
@@ -1030,7 +1186,8 @@ pxafb_freq_transition(struct notifier_block *nb, unsigned long val, void *data)
1030 case CPUFREQ_POSTCHANGE: 1186 case CPUFREQ_POSTCHANGE:
1031 pcd = get_pcd(fbi, fbi->fb.var.pixclock); 1187 pcd = get_pcd(fbi, fbi->fb.var.pixclock);
1032 set_hsync_time(fbi, pcd); 1188 set_hsync_time(fbi, pcd);
1033 fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) | LCCR3_PixClkDiv(pcd); 1189 fbi->reg_lccr3 = (fbi->reg_lccr3 & ~0xff) |
1190 LCCR3_PixClkDiv(pcd);
1034 set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE); 1191 set_ctrlr_state(fbi, C_ENABLE_CLKCHANGE);
1035 break; 1192 break;
1036 } 1193 }
@@ -1050,18 +1207,8 @@ pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data)
1050 pr_debug("min dma period: %d ps, " 1207 pr_debug("min dma period: %d ps, "
1051 "new clock %d kHz\n", pxafb_display_dma_period(var), 1208 "new clock %d kHz\n", pxafb_display_dma_period(var),
1052 policy->max); 1209 policy->max);
1053 // TODO: fill in min/max values 1210 /* TODO: fill in min/max values */
1054 break;
1055#if 0
1056 case CPUFREQ_NOTIFY:
1057 printk(KERN_ERR "%s: got CPUFREQ_NOTIFY\n", __FUNCTION__);
1058 do {} while(0);
1059 /* todo: panic if min/max values aren't fulfilled
1060 * [can't really happen unless there's a bug in the
1061 * CPU policy verification process *
1062 */
1063 break; 1211 break;
1064#endif
1065 } 1212 }
1066 return 0; 1213 return 0;
1067} 1214}
@@ -1102,21 +1249,21 @@ static int pxafb_resume(struct platform_device *dev)
1102 */ 1249 */
1103static int __init pxafb_map_video_memory(struct pxafb_info *fbi) 1250static int __init pxafb_map_video_memory(struct pxafb_info *fbi)
1104{ 1251{
1105 u_long palette_mem_size;
1106
1107 /* 1252 /*
1108 * We reserve one page for the palette, plus the size 1253 * We reserve one page for the palette, plus the size
1109 * of the framebuffer. 1254 * of the framebuffer.
1110 */ 1255 */
1111 fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + PAGE_SIZE); 1256 fbi->video_offset = PAGE_ALIGN(sizeof(struct pxafb_dma_buff));
1257 fbi->map_size = PAGE_ALIGN(fbi->fb.fix.smem_len + fbi->video_offset);
1112 fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size, 1258 fbi->map_cpu = dma_alloc_writecombine(fbi->dev, fbi->map_size,
1113 &fbi->map_dma, GFP_KERNEL); 1259 &fbi->map_dma, GFP_KERNEL);
1114 1260
1115 if (fbi->map_cpu) { 1261 if (fbi->map_cpu) {
1116 /* prevent initial garbage on screen */ 1262 /* prevent initial garbage on screen */
1117 memset(fbi->map_cpu, 0, fbi->map_size); 1263 memset(fbi->map_cpu, 0, fbi->map_size);
1118 fbi->fb.screen_base = fbi->map_cpu + PAGE_SIZE; 1264 fbi->fb.screen_base = fbi->map_cpu + fbi->video_offset;
1119 fbi->screen_dma = fbi->map_dma + PAGE_SIZE; 1265 fbi->screen_dma = fbi->map_dma + fbi->video_offset;
1266
1120 /* 1267 /*
1121 * FIXME: this is actually the wrong thing to place in 1268 * FIXME: this is actually the wrong thing to place in
1122 * smem_start. But fbdev suffers from the problem that 1269 * smem_start. But fbdev suffers from the problem that
@@ -1126,27 +1273,86 @@ static int __init pxafb_map_video_memory(struct pxafb_info *fbi)
1126 fbi->fb.fix.smem_start = fbi->screen_dma; 1273 fbi->fb.fix.smem_start = fbi->screen_dma;
1127 fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16; 1274 fbi->palette_size = fbi->fb.var.bits_per_pixel == 8 ? 256 : 16;
1128 1275
1129 if ((fbi->lccr4 & LCCR4_PAL_FOR_MASK) == LCCR4_PAL_FOR_0) 1276 fbi->dma_buff = (void *) fbi->map_cpu;
1130 palette_mem_size = fbi->palette_size * sizeof(u16); 1277 fbi->dma_buff_phys = fbi->map_dma;
1131 else 1278 fbi->palette_cpu = (u16 *) fbi->dma_buff->palette;
1132 palette_mem_size = fbi->palette_size * sizeof(u32);
1133 1279
1134 pr_debug("pxafb: palette_mem_size = 0x%08lx\n", palette_mem_size); 1280#ifdef CONFIG_FB_PXA_SMARTPANEL
1135 1281 fbi->smart_cmds = (uint16_t *) fbi->dma_buff->cmd_buff;
1136 fbi->palette_cpu = (u16 *)(fbi->map_cpu + PAGE_SIZE - palette_mem_size); 1282 fbi->n_smart_cmds = 0;
1137 fbi->palette_dma = fbi->map_dma + PAGE_SIZE - palette_mem_size; 1283#endif
1138 } 1284 }
1139 1285
1140 return fbi->map_cpu ? 0 : -ENOMEM; 1286 return fbi->map_cpu ? 0 : -ENOMEM;
1141} 1287}
1142 1288
1289static void pxafb_decode_mode_info(struct pxafb_info *fbi,
1290 struct pxafb_mode_info *modes,
1291 unsigned int num_modes)
1292{
1293 unsigned int i, smemlen;
1294
1295 pxafb_setmode(&fbi->fb.var, &modes[0]);
1296
1297 for (i = 0; i < num_modes; i++) {
1298 smemlen = modes[i].xres * modes[i].yres * modes[i].bpp / 8;
1299 if (smemlen > fbi->fb.fix.smem_len)
1300 fbi->fb.fix.smem_len = smemlen;
1301 }
1302}
1303
1304static int pxafb_decode_mach_info(struct pxafb_info *fbi,
1305 struct pxafb_mach_info *inf)
1306{
1307 unsigned int lcd_conn = inf->lcd_conn;
1308
1309 fbi->cmap_inverse = inf->cmap_inverse;
1310 fbi->cmap_static = inf->cmap_static;
1311
1312 switch (lcd_conn & 0xf) {
1313 case LCD_TYPE_MONO_STN:
1314 fbi->lccr0 = LCCR0_CMS;
1315 break;
1316 case LCD_TYPE_MONO_DSTN:
1317 fbi->lccr0 = LCCR0_CMS | LCCR0_SDS;
1318 break;
1319 case LCD_TYPE_COLOR_STN:
1320 fbi->lccr0 = 0;
1321 break;
1322 case LCD_TYPE_COLOR_DSTN:
1323 fbi->lccr0 = LCCR0_SDS;
1324 break;
1325 case LCD_TYPE_COLOR_TFT:
1326 fbi->lccr0 = LCCR0_PAS;
1327 break;
1328 case LCD_TYPE_SMART_PANEL:
1329 fbi->lccr0 = LCCR0_LCDT | LCCR0_PAS;
1330 break;
1331 default:
1332 /* fall back to backward compatibility way */
1333 fbi->lccr0 = inf->lccr0;
1334 fbi->lccr3 = inf->lccr3;
1335 fbi->lccr4 = inf->lccr4;
1336 return -EINVAL;
1337 }
1338
1339 if (lcd_conn == LCD_MONO_STN_8BPP)
1340 fbi->lccr0 |= LCCR0_DPD;
1341
1342 fbi->lccr3 = LCCR3_Acb((inf->lcd_conn >> 10) & 0xff);
1343 fbi->lccr3 |= (lcd_conn & LCD_BIAS_ACTIVE_LOW) ? LCCR3_OEP : 0;
1344 fbi->lccr3 |= (lcd_conn & LCD_PCLK_EDGE_FALL) ? LCCR3_PCP : 0;
1345
1346 pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes);
1347 return 0;
1348}
1349
1143static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev) 1350static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1144{ 1351{
1145 struct pxafb_info *fbi; 1352 struct pxafb_info *fbi;
1146 void *addr; 1353 void *addr;
1147 struct pxafb_mach_info *inf = dev->platform_data; 1354 struct pxafb_mach_info *inf = dev->platform_data;
1148 struct pxafb_mode_info *mode = inf->modes; 1355 struct pxafb_mode_info *mode = inf->modes;
1149 int i, smemlen;
1150 1356
1151 /* Alloc the pxafb_info and pseudo_palette in one step */ 1357 /* Alloc the pxafb_info and pseudo_palette in one step */
1152 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL); 1358 fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
@@ -1186,187 +1392,233 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
1186 addr = addr + sizeof(struct pxafb_info); 1392 addr = addr + sizeof(struct pxafb_info);
1187 fbi->fb.pseudo_palette = addr; 1393 fbi->fb.pseudo_palette = addr;
1188 1394
1189 pxafb_setmode(&fbi->fb.var, mode); 1395 fbi->state = C_STARTUP;
1396 fbi->task_state = (u_char)-1;
1190 1397
1191 fbi->cmap_inverse = inf->cmap_inverse; 1398 pxafb_decode_mach_info(fbi, inf);
1192 fbi->cmap_static = inf->cmap_static;
1193
1194 fbi->lccr0 = inf->lccr0;
1195 fbi->lccr3 = inf->lccr3;
1196 fbi->lccr4 = inf->lccr4;
1197 fbi->state = C_STARTUP;
1198 fbi->task_state = (u_char)-1;
1199
1200 for (i = 0; i < inf->num_modes; i++) {
1201 smemlen = mode[i].xres * mode[i].yres * mode[i].bpp / 8;
1202 if (smemlen > fbi->fb.fix.smem_len)
1203 fbi->fb.fix.smem_len = smemlen;
1204 }
1205 1399
1206 init_waitqueue_head(&fbi->ctrlr_wait); 1400 init_waitqueue_head(&fbi->ctrlr_wait);
1207 INIT_WORK(&fbi->task, pxafb_task); 1401 INIT_WORK(&fbi->task, pxafb_task);
1208 init_MUTEX(&fbi->ctrlr_sem); 1402 init_MUTEX(&fbi->ctrlr_sem);
1403 init_completion(&fbi->disable_done);
1404#ifdef CONFIG_FB_PXA_SMARTPANEL
1405 init_completion(&fbi->command_done);
1406 init_completion(&fbi->refresh_done);
1407#endif
1209 1408
1210 return fbi; 1409 return fbi;
1211} 1410}
1212 1411
1213#ifdef CONFIG_FB_PXA_PARAMETERS 1412#ifdef CONFIG_FB_PXA_PARAMETERS
1214static int __init pxafb_parse_options(struct device *dev, char *options) 1413static int __init parse_opt_mode(struct device *dev, const char *this_opt)
1414{
1415 struct pxafb_mach_info *inf = dev->platform_data;
1416
1417 const char *name = this_opt+5;
1418 unsigned int namelen = strlen(name);
1419 int res_specified = 0, bpp_specified = 0;
1420 unsigned int xres = 0, yres = 0, bpp = 0;
1421 int yres_specified = 0;
1422 int i;
1423 for (i = namelen-1; i >= 0; i--) {
1424 switch (name[i]) {
1425 case '-':
1426 namelen = i;
1427 if (!bpp_specified && !yres_specified) {
1428 bpp = simple_strtoul(&name[i+1], NULL, 0);
1429 bpp_specified = 1;
1430 } else
1431 goto done;
1432 break;
1433 case 'x':
1434 if (!yres_specified) {
1435 yres = simple_strtoul(&name[i+1], NULL, 0);
1436 yres_specified = 1;
1437 } else
1438 goto done;
1439 break;
1440 case '0' ... '9':
1441 break;
1442 default:
1443 goto done;
1444 }
1445 }
1446 if (i < 0 && yres_specified) {
1447 xres = simple_strtoul(name, NULL, 0);
1448 res_specified = 1;
1449 }
1450done:
1451 if (res_specified) {
1452 dev_info(dev, "overriding resolution: %dx%d\n", xres, yres);
1453 inf->modes[0].xres = xres; inf->modes[0].yres = yres;
1454 }
1455 if (bpp_specified)
1456 switch (bpp) {
1457 case 1:
1458 case 2:
1459 case 4:
1460 case 8:
1461 case 16:
1462 inf->modes[0].bpp = bpp;
1463 dev_info(dev, "overriding bit depth: %d\n", bpp);
1464 break;
1465 default:
1466 dev_err(dev, "Depth %d is not valid\n", bpp);
1467 return -EINVAL;
1468 }
1469 return 0;
1470}
1471
1472static int __init parse_opt(struct device *dev, char *this_opt)
1215{ 1473{
1216 struct pxafb_mach_info *inf = dev->platform_data; 1474 struct pxafb_mach_info *inf = dev->platform_data;
1475 struct pxafb_mode_info *mode = &inf->modes[0];
1476 char s[64];
1477
1478 s[0] = '\0';
1479
1480 if (!strncmp(this_opt, "mode:", 5)) {
1481 return parse_opt_mode(dev, this_opt);
1482 } else if (!strncmp(this_opt, "pixclock:", 9)) {
1483 mode->pixclock = simple_strtoul(this_opt+9, NULL, 0);
1484 sprintf(s, "pixclock: %ld\n", mode->pixclock);
1485 } else if (!strncmp(this_opt, "left:", 5)) {
1486 mode->left_margin = simple_strtoul(this_opt+5, NULL, 0);
1487 sprintf(s, "left: %u\n", mode->left_margin);
1488 } else if (!strncmp(this_opt, "right:", 6)) {
1489 mode->right_margin = simple_strtoul(this_opt+6, NULL, 0);
1490 sprintf(s, "right: %u\n", mode->right_margin);
1491 } else if (!strncmp(this_opt, "upper:", 6)) {
1492 mode->upper_margin = simple_strtoul(this_opt+6, NULL, 0);
1493 sprintf(s, "upper: %u\n", mode->upper_margin);
1494 } else if (!strncmp(this_opt, "lower:", 6)) {
1495 mode->lower_margin = simple_strtoul(this_opt+6, NULL, 0);
1496 sprintf(s, "lower: %u\n", mode->lower_margin);
1497 } else if (!strncmp(this_opt, "hsynclen:", 9)) {
1498 mode->hsync_len = simple_strtoul(this_opt+9, NULL, 0);
1499 sprintf(s, "hsynclen: %u\n", mode->hsync_len);
1500 } else if (!strncmp(this_opt, "vsynclen:", 9)) {
1501 mode->vsync_len = simple_strtoul(this_opt+9, NULL, 0);
1502 sprintf(s, "vsynclen: %u\n", mode->vsync_len);
1503 } else if (!strncmp(this_opt, "hsync:", 6)) {
1504 if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
1505 sprintf(s, "hsync: Active Low\n");
1506 mode->sync &= ~FB_SYNC_HOR_HIGH_ACT;
1507 } else {
1508 sprintf(s, "hsync: Active High\n");
1509 mode->sync |= FB_SYNC_HOR_HIGH_ACT;
1510 }
1511 } else if (!strncmp(this_opt, "vsync:", 6)) {
1512 if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
1513 sprintf(s, "vsync: Active Low\n");
1514 mode->sync &= ~FB_SYNC_VERT_HIGH_ACT;
1515 } else {
1516 sprintf(s, "vsync: Active High\n");
1517 mode->sync |= FB_SYNC_VERT_HIGH_ACT;
1518 }
1519 } else if (!strncmp(this_opt, "dpc:", 4)) {
1520 if (simple_strtoul(this_opt+4, NULL, 0) == 0) {
1521 sprintf(s, "double pixel clock: false\n");
1522 inf->lccr3 &= ~LCCR3_DPC;
1523 } else {
1524 sprintf(s, "double pixel clock: true\n");
1525 inf->lccr3 |= LCCR3_DPC;
1526 }
1527 } else if (!strncmp(this_opt, "outputen:", 9)) {
1528 if (simple_strtoul(this_opt+9, NULL, 0) == 0) {
1529 sprintf(s, "output enable: active low\n");
1530 inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnL;
1531 } else {
1532 sprintf(s, "output enable: active high\n");
1533 inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnH;
1534 }
1535 } else if (!strncmp(this_opt, "pixclockpol:", 12)) {
1536 if (simple_strtoul(this_opt+12, NULL, 0) == 0) {
1537 sprintf(s, "pixel clock polarity: falling edge\n");
1538 inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixFlEdg;
1539 } else {
1540 sprintf(s, "pixel clock polarity: rising edge\n");
1541 inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixRsEdg;
1542 }
1543 } else if (!strncmp(this_opt, "color", 5)) {
1544 inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Color;
1545 } else if (!strncmp(this_opt, "mono", 4)) {
1546 inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Mono;
1547 } else if (!strncmp(this_opt, "active", 6)) {
1548 inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Act;
1549 } else if (!strncmp(this_opt, "passive", 7)) {
1550 inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Pas;
1551 } else if (!strncmp(this_opt, "single", 6)) {
1552 inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Sngl;
1553 } else if (!strncmp(this_opt, "dual", 4)) {
1554 inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Dual;
1555 } else if (!strncmp(this_opt, "4pix", 4)) {
1556 inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_4PixMono;
1557 } else if (!strncmp(this_opt, "8pix", 4)) {
1558 inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_8PixMono;
1559 } else {
1560 dev_err(dev, "unknown option: %s\n", this_opt);
1561 return -EINVAL;
1562 }
1563
1564 if (s[0] != '\0')
1565 dev_info(dev, "override %s", s);
1566
1567 return 0;
1568}
1569
1570static int __init pxafb_parse_options(struct device *dev, char *options)
1571{
1217 char *this_opt; 1572 char *this_opt;
1573 int ret;
1218 1574
1219 if (!options || !*options) 1575 if (!options || !*options)
1220 return 0; 1576 return 0;
1221 1577
1222 dev_dbg(dev, "options are \"%s\"\n", options ? options : "null"); 1578 dev_dbg(dev, "options are \"%s\"\n", options ? options : "null");
1223 1579
1224 /* could be made table driven or similar?... */ 1580 /* could be made table driven or similar?... */
1225 while ((this_opt = strsep(&options, ",")) != NULL) { 1581 while ((this_opt = strsep(&options, ",")) != NULL) {
1226 if (!strncmp(this_opt, "mode:", 5)) { 1582 ret = parse_opt(dev, this_opt);
1227 const char *name = this_opt+5; 1583 if (ret)
1228 unsigned int namelen = strlen(name); 1584 return ret;
1229 int res_specified = 0, bpp_specified = 0; 1585 }
1230 unsigned int xres = 0, yres = 0, bpp = 0; 1586 return 0;
1231 int yres_specified = 0; 1587}
1232 int i; 1588
1233 for (i = namelen-1; i >= 0; i--) { 1589static char g_options[256] __devinitdata = "";
1234 switch (name[i]) {
1235 case '-':
1236 namelen = i;
1237 if (!bpp_specified && !yres_specified) {
1238 bpp = simple_strtoul(&name[i+1], NULL, 0);
1239 bpp_specified = 1;
1240 } else
1241 goto done;
1242 break;
1243 case 'x':
1244 if (!yres_specified) {
1245 yres = simple_strtoul(&name[i+1], NULL, 0);
1246 yres_specified = 1;
1247 } else
1248 goto done;
1249 break;
1250 case '0' ... '9':
1251 break;
1252 default:
1253 goto done;
1254 }
1255 }
1256 if (i < 0 && yres_specified) {
1257 xres = simple_strtoul(name, NULL, 0);
1258 res_specified = 1;
1259 }
1260 done:
1261 if (res_specified) {
1262 dev_info(dev, "overriding resolution: %dx%d\n", xres, yres);
1263 inf->modes[0].xres = xres; inf->modes[0].yres = yres;
1264 }
1265 if (bpp_specified)
1266 switch (bpp) {
1267 case 1:
1268 case 2:
1269 case 4:
1270 case 8:
1271 case 16:
1272 inf->modes[0].bpp = bpp;
1273 dev_info(dev, "overriding bit depth: %d\n", bpp);
1274 break;
1275 default:
1276 dev_err(dev, "Depth %d is not valid\n", bpp);
1277 }
1278 } else if (!strncmp(this_opt, "pixclock:", 9)) {
1279 inf->modes[0].pixclock = simple_strtoul(this_opt+9, NULL, 0);
1280 dev_info(dev, "override pixclock: %ld\n", inf->modes[0].pixclock);
1281 } else if (!strncmp(this_opt, "left:", 5)) {
1282 inf->modes[0].left_margin = simple_strtoul(this_opt+5, NULL, 0);
1283 dev_info(dev, "override left: %u\n", inf->modes[0].left_margin);
1284 } else if (!strncmp(this_opt, "right:", 6)) {
1285 inf->modes[0].right_margin = simple_strtoul(this_opt+6, NULL, 0);
1286 dev_info(dev, "override right: %u\n", inf->modes[0].right_margin);
1287 } else if (!strncmp(this_opt, "upper:", 6)) {
1288 inf->modes[0].upper_margin = simple_strtoul(this_opt+6, NULL, 0);
1289 dev_info(dev, "override upper: %u\n", inf->modes[0].upper_margin);
1290 } else if (!strncmp(this_opt, "lower:", 6)) {
1291 inf->modes[0].lower_margin = simple_strtoul(this_opt+6, NULL, 0);
1292 dev_info(dev, "override lower: %u\n", inf->modes[0].lower_margin);
1293 } else if (!strncmp(this_opt, "hsynclen:", 9)) {
1294 inf->modes[0].hsync_len = simple_strtoul(this_opt+9, NULL, 0);
1295 dev_info(dev, "override hsynclen: %u\n", inf->modes[0].hsync_len);
1296 } else if (!strncmp(this_opt, "vsynclen:", 9)) {
1297 inf->modes[0].vsync_len = simple_strtoul(this_opt+9, NULL, 0);
1298 dev_info(dev, "override vsynclen: %u\n", inf->modes[0].vsync_len);
1299 } else if (!strncmp(this_opt, "hsync:", 6)) {
1300 if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
1301 dev_info(dev, "override hsync: Active Low\n");
1302 inf->modes[0].sync &= ~FB_SYNC_HOR_HIGH_ACT;
1303 } else {
1304 dev_info(dev, "override hsync: Active High\n");
1305 inf->modes[0].sync |= FB_SYNC_HOR_HIGH_ACT;
1306 }
1307 } else if (!strncmp(this_opt, "vsync:", 6)) {
1308 if (simple_strtoul(this_opt+6, NULL, 0) == 0) {
1309 dev_info(dev, "override vsync: Active Low\n");
1310 inf->modes[0].sync &= ~FB_SYNC_VERT_HIGH_ACT;
1311 } else {
1312 dev_info(dev, "override vsync: Active High\n");
1313 inf->modes[0].sync |= FB_SYNC_VERT_HIGH_ACT;
1314 }
1315 } else if (!strncmp(this_opt, "dpc:", 4)) {
1316 if (simple_strtoul(this_opt+4, NULL, 0) == 0) {
1317 dev_info(dev, "override double pixel clock: false\n");
1318 inf->lccr3 &= ~LCCR3_DPC;
1319 } else {
1320 dev_info(dev, "override double pixel clock: true\n");
1321 inf->lccr3 |= LCCR3_DPC;
1322 }
1323 } else if (!strncmp(this_opt, "outputen:", 9)) {
1324 if (simple_strtoul(this_opt+9, NULL, 0) == 0) {
1325 dev_info(dev, "override output enable: active low\n");
1326 inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnL;
1327 } else {
1328 dev_info(dev, "override output enable: active high\n");
1329 inf->lccr3 = (inf->lccr3 & ~LCCR3_OEP) | LCCR3_OutEnH;
1330 }
1331 } else if (!strncmp(this_opt, "pixclockpol:", 12)) {
1332 if (simple_strtoul(this_opt+12, NULL, 0) == 0) {
1333 dev_info(dev, "override pixel clock polarity: falling edge\n");
1334 inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixFlEdg;
1335 } else {
1336 dev_info(dev, "override pixel clock polarity: rising edge\n");
1337 inf->lccr3 = (inf->lccr3 & ~LCCR3_PCP) | LCCR3_PixRsEdg;
1338 }
1339 } else if (!strncmp(this_opt, "color", 5)) {
1340 inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Color;
1341 } else if (!strncmp(this_opt, "mono", 4)) {
1342 inf->lccr0 = (inf->lccr0 & ~LCCR0_CMS) | LCCR0_Mono;
1343 } else if (!strncmp(this_opt, "active", 6)) {
1344 inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Act;
1345 } else if (!strncmp(this_opt, "passive", 7)) {
1346 inf->lccr0 = (inf->lccr0 & ~LCCR0_PAS) | LCCR0_Pas;
1347 } else if (!strncmp(this_opt, "single", 6)) {
1348 inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Sngl;
1349 } else if (!strncmp(this_opt, "dual", 4)) {
1350 inf->lccr0 = (inf->lccr0 & ~LCCR0_SDS) | LCCR0_Dual;
1351 } else if (!strncmp(this_opt, "4pix", 4)) {
1352 inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_4PixMono;
1353 } else if (!strncmp(this_opt, "8pix", 4)) {
1354 inf->lccr0 = (inf->lccr0 & ~LCCR0_DPD) | LCCR0_8PixMono;
1355 } else {
1356 dev_err(dev, "unknown option: %s\n", this_opt);
1357 return -EINVAL;
1358 }
1359 }
1360 return 0;
1361 1590
1591#ifndef CONFIG_MODULES
1592static int __devinit pxafb_setup_options(void)
1593{
1594 char *options = NULL;
1595
1596 if (fb_get_options("pxafb", &options))
1597 return -ENODEV;
1598
1599 if (options)
1600 strlcpy(g_options, options, sizeof(g_options));
1601
1602 return 0;
1362} 1603}
1604#else
1605#define pxafb_setup_options() (0)
1606
1607module_param_string(options, g_options, sizeof(g_options), 0);
1608MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)");
1609#endif
1610
1611#else
1612#define pxafb_parse_options(...) (0)
1613#define pxafb_setup_options() (0)
1363#endif 1614#endif
1364 1615
1365static int __init pxafb_probe(struct platform_device *dev) 1616static int __init pxafb_probe(struct platform_device *dev)
1366{ 1617{
1367 struct pxafb_info *fbi; 1618 struct pxafb_info *fbi;
1368 struct pxafb_mach_info *inf; 1619 struct pxafb_mach_info *inf;
1369 int ret; 1620 struct resource *r;
1621 int irq, ret;
1370 1622
1371 dev_dbg(&dev->dev, "pxafb_probe\n"); 1623 dev_dbg(&dev->dev, "pxafb_probe\n");
1372 1624
@@ -1376,38 +1628,45 @@ static int __init pxafb_probe(struct platform_device *dev)
1376 if (!inf) 1628 if (!inf)
1377 goto failed; 1629 goto failed;
1378 1630
1379#ifdef CONFIG_FB_PXA_PARAMETERS
1380 ret = pxafb_parse_options(&dev->dev, g_options); 1631 ret = pxafb_parse_options(&dev->dev, g_options);
1381 if (ret < 0) 1632 if (ret < 0)
1382 goto failed; 1633 goto failed;
1383#endif
1384 1634
1385#ifdef DEBUG_VAR 1635#ifdef DEBUG_VAR
1386 /* Check for various illegal bit-combinations. Currently only 1636 /* Check for various illegal bit-combinations. Currently only
1387 * a warning is given. */ 1637 * a warning is given. */
1388 1638
1389 if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK) 1639 if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK)
1390 dev_warn(&dev->dev, "machine LCCR0 setting contains illegal bits: %08x\n", 1640 dev_warn(&dev->dev, "machine LCCR0 setting contains "
1391 inf->lccr0 & LCCR0_INVALID_CONFIG_MASK); 1641 "illegal bits: %08x\n",
1392 if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK) 1642 inf->lccr0 & LCCR0_INVALID_CONFIG_MASK);
1393 dev_warn(&dev->dev, "machine LCCR3 setting contains illegal bits: %08x\n", 1643 if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK)
1394 inf->lccr3 & LCCR3_INVALID_CONFIG_MASK); 1644 dev_warn(&dev->dev, "machine LCCR3 setting contains "
1395 if (inf->lccr0 & LCCR0_DPD && 1645 "illegal bits: %08x\n",
1646 inf->lccr3 & LCCR3_INVALID_CONFIG_MASK);
1647 if (inf->lccr0 & LCCR0_DPD &&
1396 ((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas || 1648 ((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas ||
1397 (inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl || 1649 (inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl ||
1398 (inf->lccr0 & LCCR0_CMS) != LCCR0_Mono)) 1650 (inf->lccr0 & LCCR0_CMS) != LCCR0_Mono))
1399 dev_warn(&dev->dev, "Double Pixel Data (DPD) mode is only valid in passive mono" 1651 dev_warn(&dev->dev, "Double Pixel Data (DPD) mode is "
1400 " single panel mode\n"); 1652 "only valid in passive mono"
1401 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act && 1653 " single panel mode\n");
1654 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act &&
1402 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual) 1655 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual)
1403 dev_warn(&dev->dev, "Dual panel only valid in passive mode\n"); 1656 dev_warn(&dev->dev, "Dual panel only valid in passive mode\n");
1404 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas && 1657 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas &&
1405 (inf->modes->upper_margin || inf->modes->lower_margin)) 1658 (inf->modes->upper_margin || inf->modes->lower_margin))
1406 dev_warn(&dev->dev, "Upper and lower margins must be 0 in passive mode\n"); 1659 dev_warn(&dev->dev, "Upper and lower margins must be 0 in "
1660 "passive mode\n");
1407#endif 1661#endif
1408 1662
1409 dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",inf->modes->xres, inf->modes->yres, inf->modes->bpp); 1663 dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",
1410 if (inf->modes->xres == 0 || inf->modes->yres == 0 || inf->modes->bpp == 0) { 1664 inf->modes->xres,
1665 inf->modes->yres,
1666 inf->modes->bpp);
1667 if (inf->modes->xres == 0 ||
1668 inf->modes->yres == 0 ||
1669 inf->modes->bpp == 0) {
1411 dev_err(&dev->dev, "Invalid resolution or bit depth\n"); 1670 dev_err(&dev->dev, "Invalid resolution or bit depth\n");
1412 ret = -EINVAL; 1671 ret = -EINVAL;
1413 goto failed; 1672 goto failed;
@@ -1416,26 +1675,62 @@ static int __init pxafb_probe(struct platform_device *dev)
1416 pxafb_lcd_power = inf->pxafb_lcd_power; 1675 pxafb_lcd_power = inf->pxafb_lcd_power;
1417 fbi = pxafb_init_fbinfo(&dev->dev); 1676 fbi = pxafb_init_fbinfo(&dev->dev);
1418 if (!fbi) { 1677 if (!fbi) {
1678 /* only reason for pxafb_init_fbinfo to fail is kmalloc */
1419 dev_err(&dev->dev, "Failed to initialize framebuffer device\n"); 1679 dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
1420 ret = -ENOMEM; // only reason for pxafb_init_fbinfo to fail is kmalloc 1680 ret = -ENOMEM;
1421 goto failed; 1681 goto failed;
1422 } 1682 }
1423 1683
1684 r = platform_get_resource(dev, IORESOURCE_MEM, 0);
1685 if (r == NULL) {
1686 dev_err(&dev->dev, "no I/O memory resource defined\n");
1687 ret = -ENODEV;
1688 goto failed;
1689 }
1690
1691 r = request_mem_region(r->start, r->end - r->start + 1, dev->name);
1692 if (r == NULL) {
1693 dev_err(&dev->dev, "failed to request I/O memory\n");
1694 ret = -EBUSY;
1695 goto failed;
1696 }
1697
1698 fbi->mmio_base = ioremap(r->start, r->end - r->start + 1);
1699 if (fbi->mmio_base == NULL) {
1700 dev_err(&dev->dev, "failed to map I/O memory\n");
1701 ret = -EBUSY;
1702 goto failed_free_res;
1703 }
1704
1424 /* Initialize video memory */ 1705 /* Initialize video memory */
1425 ret = pxafb_map_video_memory(fbi); 1706 ret = pxafb_map_video_memory(fbi);
1426 if (ret) { 1707 if (ret) {
1427 dev_err(&dev->dev, "Failed to allocate video RAM: %d\n", ret); 1708 dev_err(&dev->dev, "Failed to allocate video RAM: %d\n", ret);
1428 ret = -ENOMEM; 1709 ret = -ENOMEM;
1429 goto failed; 1710 goto failed_free_io;
1711 }
1712
1713 irq = platform_get_irq(dev, 0);
1714 if (irq < 0) {
1715 dev_err(&dev->dev, "no IRQ defined\n");
1716 ret = -ENODEV;
1717 goto failed_free_mem;
1430 } 1718 }
1431 1719
1432 ret = request_irq(IRQ_LCD, pxafb_handle_irq, IRQF_DISABLED, "LCD", fbi); 1720 ret = request_irq(irq, pxafb_handle_irq, IRQF_DISABLED, "LCD", fbi);
1433 if (ret) { 1721 if (ret) {
1434 dev_err(&dev->dev, "request_irq failed: %d\n", ret); 1722 dev_err(&dev->dev, "request_irq failed: %d\n", ret);
1435 ret = -EBUSY; 1723 ret = -EBUSY;
1436 goto failed; 1724 goto failed_free_mem;
1437 } 1725 }
1438 1726
1727#ifdef CONFIG_FB_PXA_SMARTPANEL
1728 ret = pxafb_smart_init(fbi);
1729 if (ret) {
1730 dev_err(&dev->dev, "failed to initialize smartpanel\n");
1731 goto failed_free_irq;
1732 }
1733#endif
1439 /* 1734 /*
1440 * This makes sure that our colour bitfield 1735 * This makes sure that our colour bitfield
1441 * descriptors are correctly initialised. 1736 * descriptors are correctly initialised.
@@ -1447,19 +1742,18 @@ static int __init pxafb_probe(struct platform_device *dev)
1447 1742
1448 ret = register_framebuffer(&fbi->fb); 1743 ret = register_framebuffer(&fbi->fb);
1449 if (ret < 0) { 1744 if (ret < 0) {
1450 dev_err(&dev->dev, "Failed to register framebuffer device: %d\n", ret); 1745 dev_err(&dev->dev,
1451 goto failed; 1746 "Failed to register framebuffer device: %d\n", ret);
1747 goto failed_free_irq;
1452 } 1748 }
1453 1749
1454#ifdef CONFIG_PM
1455 // TODO
1456#endif
1457
1458#ifdef CONFIG_CPU_FREQ 1750#ifdef CONFIG_CPU_FREQ
1459 fbi->freq_transition.notifier_call = pxafb_freq_transition; 1751 fbi->freq_transition.notifier_call = pxafb_freq_transition;
1460 fbi->freq_policy.notifier_call = pxafb_freq_policy; 1752 fbi->freq_policy.notifier_call = pxafb_freq_policy;
1461 cpufreq_register_notifier(&fbi->freq_transition, CPUFREQ_TRANSITION_NOTIFIER); 1753 cpufreq_register_notifier(&fbi->freq_transition,
1462 cpufreq_register_notifier(&fbi->freq_policy, CPUFREQ_POLICY_NOTIFIER); 1754 CPUFREQ_TRANSITION_NOTIFIER);
1755 cpufreq_register_notifier(&fbi->freq_policy,
1756 CPUFREQ_POLICY_NOTIFIER);
1463#endif 1757#endif
1464 1758
1465 /* 1759 /*
@@ -1469,6 +1763,15 @@ static int __init pxafb_probe(struct platform_device *dev)
1469 1763
1470 return 0; 1764 return 0;
1471 1765
1766failed_free_irq:
1767 free_irq(irq, fbi);
1768failed_free_res:
1769 release_mem_region(r->start, r->end - r->start + 1);
1770failed_free_io:
1771 iounmap(fbi->mmio_base);
1772failed_free_mem:
1773 dma_free_writecombine(&dev->dev, fbi->map_size,
1774 fbi->map_cpu, fbi->map_dma);
1472failed: 1775failed:
1473 platform_set_drvdata(dev, NULL); 1776 platform_set_drvdata(dev, NULL);
1474 kfree(fbi); 1777 kfree(fbi);
@@ -1477,40 +1780,18 @@ failed:
1477 1780
1478static struct platform_driver pxafb_driver = { 1781static struct platform_driver pxafb_driver = {
1479 .probe = pxafb_probe, 1782 .probe = pxafb_probe,
1480#ifdef CONFIG_PM
1481 .suspend = pxafb_suspend, 1783 .suspend = pxafb_suspend,
1482 .resume = pxafb_resume, 1784 .resume = pxafb_resume,
1483#endif
1484 .driver = { 1785 .driver = {
1485 .name = "pxa2xx-fb", 1786 .name = "pxa2xx-fb",
1486 }, 1787 },
1487}; 1788};
1488 1789
1489#ifndef MODULE
1490static int __devinit pxafb_setup(char *options)
1491{
1492# ifdef CONFIG_FB_PXA_PARAMETERS
1493 if (options)
1494 strlcpy(g_options, options, sizeof(g_options));
1495# endif
1496 return 0;
1497}
1498#else
1499# ifdef CONFIG_FB_PXA_PARAMETERS
1500module_param_string(options, g_options, sizeof(g_options), 0);
1501MODULE_PARM_DESC(options, "LCD parameters (see Documentation/fb/pxafb.txt)");
1502# endif
1503#endif
1504
1505static int __devinit pxafb_init(void) 1790static int __devinit pxafb_init(void)
1506{ 1791{
1507#ifndef MODULE 1792 if (pxafb_setup_options())
1508 char *option = NULL; 1793 return -EINVAL;
1509 1794
1510 if (fb_get_options("pxafb", &option))
1511 return -ENODEV;
1512 pxafb_setup(option);
1513#endif
1514 return platform_driver_register(&pxafb_driver); 1795 return platform_driver_register(&pxafb_driver);
1515} 1796}
1516 1797
diff --git a/drivers/video/pxafb.h b/drivers/video/pxafb.h
index d920b8a14c35..8238dc826429 100644
--- a/drivers/video/pxafb.h
+++ b/drivers/video/pxafb.h
@@ -21,14 +21,6 @@
21 * for more details. 21 * for more details.
22 */ 22 */
23 23
24/* Shadows for LCD controller registers */
25struct pxafb_lcd_reg {
26 unsigned int lccr0;
27 unsigned int lccr1;
28 unsigned int lccr2;
29 unsigned int lccr3;
30};
31
32/* PXA LCD DMA descriptor */ 24/* PXA LCD DMA descriptor */
33struct pxafb_dma_descriptor { 25struct pxafb_dma_descriptor {
34 unsigned int fdadr; 26 unsigned int fdadr;
@@ -37,11 +29,49 @@ struct pxafb_dma_descriptor {
37 unsigned int ldcmd; 29 unsigned int ldcmd;
38}; 30};
39 31
32enum {
33 PAL_NONE = -1,
34 PAL_BASE = 0,
35 PAL_OV1 = 1,
36 PAL_OV2 = 2,
37 PAL_MAX,
38};
39
40enum {
41 DMA_BASE = 0,
42 DMA_UPPER = 0,
43 DMA_LOWER = 1,
44 DMA_OV1 = 1,
45 DMA_OV2_Y = 2,
46 DMA_OV2_Cb = 3,
47 DMA_OV2_Cr = 4,
48 DMA_CURSOR = 5,
49 DMA_CMD = 6,
50 DMA_MAX,
51};
52
53/* maximum palette size - 256 entries, each 4 bytes long */
54#define PALETTE_SIZE (256 * 4)
55#define CMD_BUFF_SIZE (1024 * 50)
56
57struct pxafb_dma_buff {
58 unsigned char palette[PAL_MAX * PALETTE_SIZE];
59 uint16_t cmd_buff[CMD_BUFF_SIZE];
60 struct pxafb_dma_descriptor pal_desc[PAL_MAX];
61 struct pxafb_dma_descriptor dma_desc[DMA_MAX];
62};
63
40struct pxafb_info { 64struct pxafb_info {
41 struct fb_info fb; 65 struct fb_info fb;
42 struct device *dev; 66 struct device *dev;
43 struct clk *clk; 67 struct clk *clk;
44 68
69 void __iomem *mmio_base;
70
71 struct pxafb_dma_buff *dma_buff;
72 dma_addr_t dma_buff_phys;
73 dma_addr_t fdadr[DMA_MAX];
74
45 /* 75 /*
46 * These are the addresses we mapped 76 * These are the addresses we mapped
47 * the framebuffer memory region to. 77 * the framebuffer memory region to.
@@ -55,19 +85,8 @@ struct pxafb_info {
55 u_char * screen_cpu; /* virtual address of frame buffer */ 85 u_char * screen_cpu; /* virtual address of frame buffer */
56 dma_addr_t screen_dma; /* physical address of frame buffer */ 86 dma_addr_t screen_dma; /* physical address of frame buffer */
57 u16 * palette_cpu; /* virtual address of palette memory */ 87 u16 * palette_cpu; /* virtual address of palette memory */
58 dma_addr_t palette_dma; /* physical address of palette memory */
59 u_int palette_size; 88 u_int palette_size;
60 89 ssize_t video_offset;
61 /* DMA descriptors */
62 struct pxafb_dma_descriptor * dmadesc_fblow_cpu;
63 dma_addr_t dmadesc_fblow_dma;
64 struct pxafb_dma_descriptor * dmadesc_fbhigh_cpu;
65 dma_addr_t dmadesc_fbhigh_dma;
66 struct pxafb_dma_descriptor * dmadesc_palette_cpu;
67 dma_addr_t dmadesc_palette_dma;
68
69 dma_addr_t fdadr0;
70 dma_addr_t fdadr1;
71 90
72 u_int lccr0; 91 u_int lccr0;
73 u_int lccr3; 92 u_int lccr3;
@@ -81,6 +100,7 @@ struct pxafb_info {
81 u_int reg_lccr2; 100 u_int reg_lccr2;
82 u_int reg_lccr3; 101 u_int reg_lccr3;
83 u_int reg_lccr4; 102 u_int reg_lccr4;
103 u_int reg_cmdcr;
84 104
85 unsigned long hsync_time; 105 unsigned long hsync_time;
86 106
@@ -90,6 +110,16 @@ struct pxafb_info {
90 wait_queue_head_t ctrlr_wait; 110 wait_queue_head_t ctrlr_wait;
91 struct work_struct task; 111 struct work_struct task;
92 112
113 struct completion disable_done;
114
115#ifdef CONFIG_FB_PXA_SMARTPANEL
116 uint16_t *smart_cmds;
117 size_t n_smart_cmds;
118 struct completion command_done;
119 struct completion refresh_done;
120 struct task_struct *smart_thread;
121#endif
122
93#ifdef CONFIG_CPU_FREQ 123#ifdef CONFIG_CPU_FREQ
94 struct notifier_block freq_transition; 124 struct notifier_block freq_transition;
95 struct notifier_block freq_policy; 125 struct notifier_block freq_policy;
diff --git a/drivers/w1/w1_log.h b/drivers/w1/w1_log.h
index fe6bdf43380f..e6ab7cf08f88 100644
--- a/drivers/w1/w1_log.h
+++ b/drivers/w1/w1_log.h
@@ -30,7 +30,7 @@
30# define assert(expr) \ 30# define assert(expr) \
31 if(unlikely(!(expr))) { \ 31 if(unlikely(!(expr))) { \
32 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \ 32 printk(KERN_ERR "Assertion failed! %s,%s,%s,line=%d\n", \
33 #expr,__FILE__,__FUNCTION__,__LINE__); \ 33 #expr, __FILE__, __func__, __LINE__); \
34 } 34 }
35#endif 35#endif
36 36
diff --git a/fs/Kconfig b/fs/Kconfig
index 2e43d46f65d6..cf12c403b8c7 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1005,7 +1005,8 @@ config TMPFS_POSIX_ACL
1005 1005
1006config HUGETLBFS 1006config HUGETLBFS
1007 bool "HugeTLB file system support" 1007 bool "HugeTLB file system support"
1008 depends on X86 || IA64 || PPC64 || SPARC64 || (SUPERH && MMU) || BROKEN 1008 depends on X86 || IA64 || PPC64 || SPARC64 || (SUPERH && MMU) || \
1009 (S390 && 64BIT) || BROKEN
1009 help 1010 help
1010 hugetlbfs is a filesystem backing for HugeTLB pages, based on 1011 hugetlbfs is a filesystem backing for HugeTLB pages, based on
1011 ramfs. For architectures that support it, say Y here and read 1012 ramfs. For architectures that support it, say Y here and read
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 936f2af39c43..831157502d5a 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -75,7 +75,7 @@ extern unsigned int adfs_map_free(struct super_block *sb);
75/* Misc */ 75/* Misc */
76void __adfs_error(struct super_block *sb, const char *function, 76void __adfs_error(struct super_block *sb, const char *function,
77 const char *fmt, ...); 77 const char *fmt, ...);
78#define adfs_error(sb, fmt...) __adfs_error(sb, __FUNCTION__, fmt) 78#define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
79 79
80/* super.c */ 80/* super.c */
81 81
diff --git a/fs/affs/file.c b/fs/affs/file.c
index e87ede608f77..1a4f092f24ef 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -539,7 +539,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
539 tmp = min(bsize - boff, newsize - size); 539 tmp = min(bsize - boff, newsize - size);
540 BUG_ON(boff + tmp > bsize || tmp > bsize); 540 BUG_ON(boff + tmp > bsize || tmp > bsize);
541 memset(AFFS_DATA(bh) + boff, 0, tmp); 541 memset(AFFS_DATA(bh) + boff, 0, tmp);
542 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); 542 be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp);
543 affs_fix_checksum(sb, bh); 543 affs_fix_checksum(sb, bh);
544 mark_buffer_dirty_inode(bh, inode); 544 mark_buffer_dirty_inode(bh, inode);
545 size += tmp; 545 size += tmp;
@@ -680,7 +680,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
680 tmp = min(bsize - boff, to - from); 680 tmp = min(bsize - boff, to - from);
681 BUG_ON(boff + tmp > bsize || tmp > bsize); 681 BUG_ON(boff + tmp > bsize || tmp > bsize);
682 memcpy(AFFS_DATA(bh) + boff, data + from, tmp); 682 memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
683 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); 683 be32_add_cpu(&AFFS_DATA_HEAD(bh)->size, tmp);
684 affs_fix_checksum(sb, bh); 684 affs_fix_checksum(sb, bh);
685 mark_buffer_dirty_inode(bh, inode); 685 mark_buffer_dirty_inode(bh, inode);
686 written += tmp; 686 written += tmp;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index b58af8f18bc4..dfda03d4397d 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -140,7 +140,7 @@ static inline void afs_dir_check_page(struct inode *dir, struct page *page)
140 140
141 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) { 141 if (page->index == 0 && qty != ntohs(dbuf->blocks[0].pagehdr.npages)) {
142 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n", 142 printk("kAFS: %s(%lu): wrong number of dir blocks %d!=%hu\n",
143 __FUNCTION__, dir->i_ino, qty, 143 __func__, dir->i_ino, qty,
144 ntohs(dbuf->blocks[0].pagehdr.npages)); 144 ntohs(dbuf->blocks[0].pagehdr.npages));
145 goto error; 145 goto error;
146 } 146 }
@@ -159,7 +159,7 @@ static inline void afs_dir_check_page(struct inode *dir, struct page *page)
159 for (tmp = 0; tmp < qty; tmp++) { 159 for (tmp = 0; tmp < qty; tmp++) {
160 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) { 160 if (dbuf->blocks[tmp].pagehdr.magic != AFS_DIR_MAGIC) {
161 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n", 161 printk("kAFS: %s(%lu): bad magic %d/%d is %04hx\n",
162 __FUNCTION__, dir->i_ino, tmp, qty, 162 __func__, dir->i_ino, tmp, qty,
163 ntohs(dbuf->blocks[tmp].pagehdr.magic)); 163 ntohs(dbuf->blocks[tmp].pagehdr.magic));
164 goto error; 164 goto error;
165 } 165 }
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index eec41c76de72..7102824ba847 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -757,8 +757,8 @@ void _dbprintk(const char *fmt, ...)
757{ 757{
758} 758}
759 759
760#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) 760#define kenter(FMT,...) dbgprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
761#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) 761#define kleave(FMT,...) dbgprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
762#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__) 762#define kdebug(FMT,...) dbgprintk(" "FMT ,##__VA_ARGS__)
763 763
764 764
@@ -791,8 +791,8 @@ do { \
791} while (0) 791} while (0)
792 792
793#else 793#else
794#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__FUNCTION__ ,##__VA_ARGS__) 794#define _enter(FMT,...) _dbprintk("==> %s("FMT")",__func__ ,##__VA_ARGS__)
795#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__FUNCTION__ ,##__VA_ARGS__) 795#define _leave(FMT,...) _dbprintk("<== %s()"FMT"",__func__ ,##__VA_ARGS__)
796#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__) 796#define _debug(FMT,...) _dbprintk(" "FMT ,##__VA_ARGS__)
797#endif 797#endif
798 798
diff --git a/fs/aio.c b/fs/aio.c
index 99c2352906a0..b5253e77eb2f 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1078,9 +1078,7 @@ static void timeout_func(unsigned long data)
1078 1078
1079static inline void init_timeout(struct aio_timeout *to) 1079static inline void init_timeout(struct aio_timeout *to)
1080{ 1080{
1081 init_timer(&to->timer); 1081 setup_timer_on_stack(&to->timer, timeout_func, (unsigned long) to);
1082 to->timer.data = (unsigned long)to;
1083 to->timer.function = timeout_func;
1084 to->timed_out = 0; 1082 to->timed_out = 0;
1085 to->p = current; 1083 to->p = current;
1086} 1084}
@@ -1213,6 +1211,7 @@ retry:
1213 if (timeout) 1211 if (timeout)
1214 clear_timeout(&to); 1212 clear_timeout(&to);
1215out: 1213out:
1214 destroy_timer_on_stack(&to.timer);
1216 return i ? i : ret; 1215 return i ? i : ret;
1217} 1216}
1218 1217
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 2d4ae40718d9..c3d352d7fa93 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -35,7 +35,7 @@
35/* #define DEBUG */ 35/* #define DEBUG */
36 36
37#ifdef DEBUG 37#ifdef DEBUG
38#define DPRINTK(fmt,args...) do { printk(KERN_DEBUG "pid %d: %s: " fmt "\n" , current->pid , __FUNCTION__ , ##args); } while(0) 38#define DPRINTK(fmt,args...) do { printk(KERN_DEBUG "pid %d: %s: " fmt "\n" , current->pid , __func__ , ##args); } while(0)
39#else 39#else
40#define DPRINTK(fmt,args...) do {} while(0) 40#define DPRINTK(fmt,args...) do {} while(0)
41#endif 41#endif
diff --git a/fs/bfs/bfs.h b/fs/bfs/bfs.h
index 71faf4d23908..70f5d3a8eede 100644
--- a/fs/bfs/bfs.h
+++ b/fs/bfs/bfs.h
@@ -42,7 +42,7 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode)
42 42
43 43
44#define printf(format, args...) \ 44#define printf(format, args...) \
45 printk(KERN_ERR "BFS-fs: %s(): " format, __FUNCTION__, ## args) 45 printk(KERN_ERR "BFS-fs: %s(): " format, __func__, ## args)
46 46
47/* inode.c */ 47/* inode.c */
48extern struct inode *bfs_iget(struct super_block *sb, unsigned long ino); 48extern struct inode *bfs_iget(struct super_block *sb, unsigned long ino);
diff --git a/fs/buffer.c b/fs/buffer.c
index 189efa4efc6e..a073f3f4f013 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1101,7 +1101,7 @@ grow_buffers(struct block_device *bdev, sector_t block, int size)
1101 1101
1102 printk(KERN_ERR "%s: requested out-of-range block %llu for " 1102 printk(KERN_ERR "%s: requested out-of-range block %llu for "
1103 "device %s\n", 1103 "device %s\n",
1104 __FUNCTION__, (unsigned long long)block, 1104 __func__, (unsigned long long)block,
1105 bdevname(bdev, b)); 1105 bdevname(bdev, b));
1106 return -EIO; 1106 return -EIO;
1107 } 1107 }
diff --git a/fs/compat.c b/fs/compat.c
index 2ce4456aad30..139dc93c092d 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1634,7 +1634,7 @@ sticky:
1634 return ret; 1634 return ret;
1635} 1635}
1636 1636
1637#ifdef TIF_RESTORE_SIGMASK 1637#ifdef HAVE_SET_RESTORE_SIGMASK
1638asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp, 1638asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1639 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 1639 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
1640 struct compat_timespec __user *tsp, compat_sigset_t __user *sigmask, 1640 struct compat_timespec __user *tsp, compat_sigset_t __user *sigmask,
@@ -1720,7 +1720,7 @@ sticky:
1720 if (sigmask) { 1720 if (sigmask) {
1721 memcpy(&current->saved_sigmask, &sigsaved, 1721 memcpy(&current->saved_sigmask, &sigsaved,
1722 sizeof(sigsaved)); 1722 sizeof(sigsaved));
1723 set_thread_flag(TIF_RESTORE_SIGMASK); 1723 set_restore_sigmask();
1724 } 1724 }
1725 } else if (sigmask) 1725 } else if (sigmask)
1726 sigprocmask(SIG_SETMASK, &sigsaved, NULL); 1726 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
@@ -1791,7 +1791,7 @@ asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
1791 if (sigmask) { 1791 if (sigmask) {
1792 memcpy(&current->saved_sigmask, &sigsaved, 1792 memcpy(&current->saved_sigmask, &sigsaved,
1793 sizeof(sigsaved)); 1793 sizeof(sigsaved));
1794 set_thread_flag(TIF_RESTORE_SIGMASK); 1794 set_restore_sigmask();
1795 } 1795 }
1796 ret = -ERESTARTNOHAND; 1796 ret = -ERESTARTNOHAND;
1797 } else if (sigmask) 1797 } else if (sigmask)
@@ -1825,7 +1825,7 @@ sticky:
1825 1825
1826 return ret; 1826 return ret;
1827} 1827}
1828#endif /* TIF_RESTORE_SIGMASK */ 1828#endif /* HAVE_SET_RESTORE_SIGMASK */
1829 1829
1830#if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE) 1830#if defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)
1831/* Stuff for NFS server syscalls... */ 1831/* Stuff for NFS server syscalls... */
@@ -2080,7 +2080,7 @@ long asmlinkage compat_sys_nfsservctl(int cmd, void *notused, void *notused2)
2080 2080
2081#ifdef CONFIG_EPOLL 2081#ifdef CONFIG_EPOLL
2082 2082
2083#ifdef TIF_RESTORE_SIGMASK 2083#ifdef HAVE_SET_RESTORE_SIGMASK
2084asmlinkage long compat_sys_epoll_pwait(int epfd, 2084asmlinkage long compat_sys_epoll_pwait(int epfd,
2085 struct compat_epoll_event __user *events, 2085 struct compat_epoll_event __user *events,
2086 int maxevents, int timeout, 2086 int maxevents, int timeout,
@@ -2117,14 +2117,14 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,
2117 if (err == -EINTR) { 2117 if (err == -EINTR) {
2118 memcpy(&current->saved_sigmask, &sigsaved, 2118 memcpy(&current->saved_sigmask, &sigsaved,
2119 sizeof(sigsaved)); 2119 sizeof(sigsaved));
2120 set_thread_flag(TIF_RESTORE_SIGMASK); 2120 set_restore_sigmask();
2121 } else 2121 } else
2122 sigprocmask(SIG_SETMASK, &sigsaved, NULL); 2122 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
2123 } 2123 }
2124 2124
2125 return err; 2125 return err;
2126} 2126}
2127#endif /* TIF_RESTORE_SIGMASK */ 2127#endif /* HAVE_SET_RESTORE_SIGMASK */
2128 2128
2129#endif /* CONFIG_EPOLL */ 2129#endif /* CONFIG_EPOLL */
2130 2130
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c6e72aebd16b..97dba0d92348 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1046,14 +1046,14 @@ static int vt_check(struct file *file)
1046 struct inode *inode = file->f_path.dentry->d_inode; 1046 struct inode *inode = file->f_path.dentry->d_inode;
1047 struct vc_data *vc; 1047 struct vc_data *vc;
1048 1048
1049 if (file->f_op->ioctl != tty_ioctl) 1049 if (file->f_op->unlocked_ioctl != tty_ioctl)
1050 return -EINVAL; 1050 return -EINVAL;
1051 1051
1052 tty = (struct tty_struct *)file->private_data; 1052 tty = (struct tty_struct *)file->private_data;
1053 if (tty_paranoia_check(tty, inode, "tty_ioctl")) 1053 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
1054 return -EINVAL; 1054 return -EINVAL;
1055 1055
1056 if (tty->driver->ioctl != vt_ioctl) 1056 if (tty->ops->ioctl != vt_ioctl)
1057 return -EINVAL; 1057 return -EINVAL;
1058 1058
1059 vc = (struct vc_data *)tty->driver_data; 1059 vc = (struct vc_data *)tty->driver_data;
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index 397cb503a180..2b6cb23dd14e 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -115,7 +115,7 @@ configfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *pp
115 goto out; 115 goto out;
116 } 116 }
117 pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n", 117 pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",
118 __FUNCTION__, count, *ppos, buffer->page); 118 __func__, count, *ppos, buffer->page);
119 retval = simple_read_from_buffer(buf, count, ppos, buffer->page, 119 retval = simple_read_from_buffer(buf, count, ppos, buffer->page,
120 buffer->count); 120 buffer->count);
121out: 121out:
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 4c1ebff778ee..b9a1d810346d 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -47,7 +47,7 @@ static const struct address_space_operations configfs_aops = {
47 47
48static struct backing_dev_info configfs_backing_dev_info = { 48static struct backing_dev_info configfs_backing_dev_info = {
49 .ra_pages = 0, /* No readahead */ 49 .ra_pages = 0, /* No readahead */
50 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 50 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
51}; 51};
52 52
53static const struct inode_operations configfs_inode_operations ={ 53static const struct inode_operations configfs_inode_operations ={
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index de3b31d0a37d..8421cea7d8c7 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -92,7 +92,7 @@ static int configfs_fill_super(struct super_block *sb, void *data, int silent)
92 92
93 root = d_alloc_root(inode); 93 root = d_alloc_root(inode);
94 if (!root) { 94 if (!root) {
95 pr_debug("%s: could not get root dentry!\n",__FUNCTION__); 95 pr_debug("%s: could not get root dentry!\n",__func__);
96 iput(inode); 96 iput(inode);
97 return -ENOMEM; 97 return -ENOMEM;
98 } 98 }
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index 78929ea84ff2..2a731ef5f305 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -210,13 +210,13 @@ static int configfs_get_target_path(struct config_item * item, struct config_ite
210 if (size > PATH_MAX) 210 if (size > PATH_MAX)
211 return -ENAMETOOLONG; 211 return -ENAMETOOLONG;
212 212
213 pr_debug("%s: depth = %d, size = %d\n", __FUNCTION__, depth, size); 213 pr_debug("%s: depth = %d, size = %d\n", __func__, depth, size);
214 214
215 for (s = path; depth--; s += 3) 215 for (s = path; depth--; s += 3)
216 strcpy(s,"../"); 216 strcpy(s,"../");
217 217
218 fill_item_path(target, path, size); 218 fill_item_path(target, path, size);
219 pr_debug("%s: path = '%s'\n", __FUNCTION__, path); 219 pr_debug("%s: path = '%s'\n", __func__, path);
220 220
221 return 0; 221 return 0;
222} 222}
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index f120e1207874..285b64a8b06e 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -17,6 +17,8 @@
17#include <linux/namei.h> 17#include <linux/namei.h>
18#include <linux/mount.h> 18#include <linux/mount.h>
19#include <linux/tty.h> 19#include <linux/tty.h>
20#include <linux/mutex.h>
21#include <linux/idr.h>
20#include <linux/devpts_fs.h> 22#include <linux/devpts_fs.h>
21#include <linux/parser.h> 23#include <linux/parser.h>
22#include <linux/fsnotify.h> 24#include <linux/fsnotify.h>
@@ -26,6 +28,10 @@
26 28
27#define DEVPTS_DEFAULT_MODE 0600 29#define DEVPTS_DEFAULT_MODE 0600
28 30
31extern int pty_limit; /* Config limit on Unix98 ptys */
32static DEFINE_IDR(allocated_ptys);
33static DEFINE_MUTEX(allocated_ptys_lock);
34
29static struct vfsmount *devpts_mnt; 35static struct vfsmount *devpts_mnt;
30static struct dentry *devpts_root; 36static struct dentry *devpts_root;
31 37
@@ -171,9 +177,44 @@ static struct dentry *get_node(int num)
171 return lookup_one_len(s, root, sprintf(s, "%d", num)); 177 return lookup_one_len(s, root, sprintf(s, "%d", num));
172} 178}
173 179
180int devpts_new_index(void)
181{
182 int index;
183 int idr_ret;
184
185retry:
186 if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) {
187 return -ENOMEM;
188 }
189
190 mutex_lock(&allocated_ptys_lock);
191 idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
192 if (idr_ret < 0) {
193 mutex_unlock(&allocated_ptys_lock);
194 if (idr_ret == -EAGAIN)
195 goto retry;
196 return -EIO;
197 }
198
199 if (index >= pty_limit) {
200 idr_remove(&allocated_ptys, index);
201 mutex_unlock(&allocated_ptys_lock);
202 return -EIO;
203 }
204 mutex_unlock(&allocated_ptys_lock);
205 return index;
206}
207
208void devpts_kill_index(int idx)
209{
210 mutex_lock(&allocated_ptys_lock);
211 idr_remove(&allocated_ptys, idx);
212 mutex_unlock(&allocated_ptys_lock);
213}
214
174int devpts_pty_new(struct tty_struct *tty) 215int devpts_pty_new(struct tty_struct *tty)
175{ 216{
176 int number = tty->index; 217 int number = tty->index; /* tty layer puts index from devpts_new_index() in here */
177 struct tty_driver *driver = tty->driver; 218 struct tty_driver *driver = tty->driver;
178 dev_t device = MKDEV(driver->major, driver->minor_start+number); 219 dev_t device = MKDEV(driver->major, driver->minor_start+number);
179 struct dentry *dentry; 220 struct dentry *dentry;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index b64e55e0515d..499e16759e96 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -200,7 +200,7 @@ int __init dlm_lockspace_init(void)
200 200
201 dlm_kset = kset_create_and_add("dlm", NULL, kernel_kobj); 201 dlm_kset = kset_create_and_add("dlm", NULL, kernel_kobj);
202 if (!dlm_kset) { 202 if (!dlm_kset) {
203 printk(KERN_WARNING "%s: can not create kset\n", __FUNCTION__); 203 printk(KERN_WARNING "%s: can not create kset\n", __func__);
204 return -ENOMEM; 204 return -ENOMEM;
205 } 205 }
206 return 0; 206 return 0;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 0d237182d721..221086fef174 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1241,7 +1241,7 @@ error_return:
1241 return error; 1241 return error;
1242} 1242}
1243 1243
1244#ifdef TIF_RESTORE_SIGMASK 1244#ifdef HAVE_SET_RESTORE_SIGMASK
1245 1245
1246/* 1246/*
1247 * Implement the event wait interface for the eventpoll file. It is the kernel 1247 * Implement the event wait interface for the eventpoll file. It is the kernel
@@ -1279,7 +1279,7 @@ asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
1279 if (error == -EINTR) { 1279 if (error == -EINTR) {
1280 memcpy(&current->saved_sigmask, &sigsaved, 1280 memcpy(&current->saved_sigmask, &sigsaved,
1281 sizeof(sigsaved)); 1281 sizeof(sigsaved));
1282 set_thread_flag(TIF_RESTORE_SIGMASK); 1282 set_restore_sigmask();
1283 } else 1283 } else
1284 sigprocmask(SIG_SETMASK, &sigsaved, NULL); 1284 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
1285 } 1285 }
@@ -1287,7 +1287,7 @@ asmlinkage long sys_epoll_pwait(int epfd, struct epoll_event __user *events,
1287 return error; 1287 return error;
1288} 1288}
1289 1289
1290#endif /* #ifdef TIF_RESTORE_SIGMASK */ 1290#endif /* HAVE_SET_RESTORE_SIGMASK */
1291 1291
1292static int __init eventpoll_init(void) 1292static int __init eventpoll_init(void)
1293{ 1293{
@@ -1309,4 +1309,3 @@ static int __init eventpoll_init(void)
1309 return 0; 1309 return 0;
1310} 1310}
1311fs_initcall(eventpoll_init); 1311fs_initcall(eventpoll_init);
1312
diff --git a/fs/exec.c b/fs/exec.c
index a13883903ee9..9f9f931ef949 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -766,9 +766,7 @@ static int de_thread(struct task_struct *tsk)
766 766
767 /* 767 /*
768 * Kill all other threads in the thread group. 768 * Kill all other threads in the thread group.
769 * We must hold tasklist_lock to call zap_other_threads.
770 */ 769 */
771 read_lock(&tasklist_lock);
772 spin_lock_irq(lock); 770 spin_lock_irq(lock);
773 if (signal_group_exit(sig)) { 771 if (signal_group_exit(sig)) {
774 /* 772 /*
@@ -776,21 +774,10 @@ static int de_thread(struct task_struct *tsk)
776 * return so that the signal is processed. 774 * return so that the signal is processed.
777 */ 775 */
778 spin_unlock_irq(lock); 776 spin_unlock_irq(lock);
779 read_unlock(&tasklist_lock);
780 return -EAGAIN; 777 return -EAGAIN;
781 } 778 }
782
783 /*
784 * child_reaper ignores SIGKILL, change it now.
785 * Reparenting needs write_lock on tasklist_lock,
786 * so it is safe to do it under read_lock.
787 */
788 if (unlikely(tsk->group_leader == task_child_reaper(tsk)))
789 task_active_pid_ns(tsk)->child_reaper = tsk;
790
791 sig->group_exit_task = tsk; 779 sig->group_exit_task = tsk;
792 zap_other_threads(tsk); 780 zap_other_threads(tsk);
793 read_unlock(&tasklist_lock);
794 781
795 /* Account for the thread group leader hanging around: */ 782 /* Account for the thread group leader hanging around: */
796 count = thread_group_leader(tsk) ? 1 : 2; 783 count = thread_group_leader(tsk) ? 1 : 2;
@@ -811,7 +798,7 @@ static int de_thread(struct task_struct *tsk)
811 if (!thread_group_leader(tsk)) { 798 if (!thread_group_leader(tsk)) {
812 leader = tsk->group_leader; 799 leader = tsk->group_leader;
813 800
814 sig->notify_count = -1; 801 sig->notify_count = -1; /* for exit_notify() */
815 for (;;) { 802 for (;;) {
816 write_lock_irq(&tasklist_lock); 803 write_lock_irq(&tasklist_lock);
817 if (likely(leader->exit_state)) 804 if (likely(leader->exit_state))
@@ -821,6 +808,8 @@ static int de_thread(struct task_struct *tsk)
821 schedule(); 808 schedule();
822 } 809 }
823 810
811 if (unlikely(task_child_reaper(tsk) == leader))
812 task_active_pid_ns(tsk)->child_reaper = tsk;
824 /* 813 /*
825 * The only record we have of the real-time age of a 814 * The only record we have of the real-time age of a
826 * process, regardless of execs it's done, is start_time. 815 * process, regardless of execs it's done, is start_time.
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 109ab5e44eca..cc91227d3bb8 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -150,12 +150,12 @@ reconnect_path(struct vfsmount *mnt, struct dentry *target_dir)
150 if (IS_ERR(ppd)) { 150 if (IS_ERR(ppd)) {
151 err = PTR_ERR(ppd); 151 err = PTR_ERR(ppd);
152 dprintk("%s: get_parent of %ld failed, err %d\n", 152 dprintk("%s: get_parent of %ld failed, err %d\n",
153 __FUNCTION__, pd->d_inode->i_ino, err); 153 __func__, pd->d_inode->i_ino, err);
154 dput(pd); 154 dput(pd);
155 break; 155 break;
156 } 156 }
157 157
158 dprintk("%s: find name of %lu in %lu\n", __FUNCTION__, 158 dprintk("%s: find name of %lu in %lu\n", __func__,
159 pd->d_inode->i_ino, ppd->d_inode->i_ino); 159 pd->d_inode->i_ino, ppd->d_inode->i_ino);
160 err = exportfs_get_name(mnt, ppd, nbuf, pd); 160 err = exportfs_get_name(mnt, ppd, nbuf, pd);
161 if (err) { 161 if (err) {
@@ -168,14 +168,14 @@ reconnect_path(struct vfsmount *mnt, struct dentry *target_dir)
168 continue; 168 continue;
169 break; 169 break;
170 } 170 }
171 dprintk("%s: found name: %s\n", __FUNCTION__, nbuf); 171 dprintk("%s: found name: %s\n", __func__, nbuf);
172 mutex_lock(&ppd->d_inode->i_mutex); 172 mutex_lock(&ppd->d_inode->i_mutex);
173 npd = lookup_one_len(nbuf, ppd, strlen(nbuf)); 173 npd = lookup_one_len(nbuf, ppd, strlen(nbuf));
174 mutex_unlock(&ppd->d_inode->i_mutex); 174 mutex_unlock(&ppd->d_inode->i_mutex);
175 if (IS_ERR(npd)) { 175 if (IS_ERR(npd)) {
176 err = PTR_ERR(npd); 176 err = PTR_ERR(npd);
177 dprintk("%s: lookup failed: %d\n", 177 dprintk("%s: lookup failed: %d\n",
178 __FUNCTION__, err); 178 __func__, err);
179 dput(ppd); 179 dput(ppd);
180 dput(pd); 180 dput(pd);
181 break; 181 break;
@@ -188,7 +188,7 @@ reconnect_path(struct vfsmount *mnt, struct dentry *target_dir)
188 if (npd == pd) 188 if (npd == pd)
189 noprogress = 0; 189 noprogress = 0;
190 else 190 else
191 printk("%s: npd != pd\n", __FUNCTION__); 191 printk("%s: npd != pd\n", __func__);
192 dput(npd); 192 dput(npd);
193 dput(ppd); 193 dput(ppd);
194 if (IS_ROOT(pd)) { 194 if (IS_ROOT(pd)) {
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 639b3b4f86d1..fda25479af26 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -242,7 +242,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
242 /* prevent the infinite loop of cluster chain */ 242 /* prevent the infinite loop of cluster chain */
243 if (*fclus > limit) { 243 if (*fclus > limit) {
244 fat_fs_panic(sb, "%s: detected the cluster chain loop" 244 fat_fs_panic(sb, "%s: detected the cluster chain loop"
245 " (i_pos %lld)", __FUNCTION__, 245 " (i_pos %lld)", __func__,
246 MSDOS_I(inode)->i_pos); 246 MSDOS_I(inode)->i_pos);
247 nr = -EIO; 247 nr = -EIO;
248 goto out; 248 goto out;
@@ -253,7 +253,7 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
253 goto out; 253 goto out;
254 else if (nr == FAT_ENT_FREE) { 254 else if (nr == FAT_ENT_FREE) {
255 fat_fs_panic(sb, "%s: invalid cluster chain" 255 fat_fs_panic(sb, "%s: invalid cluster chain"
256 " (i_pos %lld)", __FUNCTION__, 256 " (i_pos %lld)", __func__,
257 MSDOS_I(inode)->i_pos); 257 MSDOS_I(inode)->i_pos);
258 nr = -EIO; 258 nr = -EIO;
259 goto out; 259 goto out;
@@ -286,7 +286,7 @@ static int fat_bmap_cluster(struct inode *inode, int cluster)
286 return ret; 286 return ret;
287 else if (ret == FAT_ENT_EOF) { 287 else if (ret == FAT_ENT_EOF) {
288 fat_fs_panic(sb, "%s: request beyond EOF (i_pos %lld)", 288 fat_fs_panic(sb, "%s: request beyond EOF (i_pos %lld)",
289 __FUNCTION__, MSDOS_I(inode)->i_pos); 289 __func__, MSDOS_I(inode)->i_pos);
290 return -EIO; 290 return -EIO;
291 } 291 }
292 return dclus; 292 return dclus;
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index 13ab763cc510..302e95c4af7e 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -546,7 +546,7 @@ int fat_free_clusters(struct inode *inode, int cluster)
546 goto error; 546 goto error;
547 } else if (cluster == FAT_ENT_FREE) { 547 } else if (cluster == FAT_ENT_FREE) {
548 fat_fs_panic(sb, "%s: deleting FAT entry beyond EOF", 548 fat_fs_panic(sb, "%s: deleting FAT entry beyond EOF",
549 __FUNCTION__); 549 __func__);
550 err = -EIO; 550 err = -EIO;
551 goto error; 551 goto error;
552 } 552 }
diff --git a/fs/fat/file.c b/fs/fat/file.c
index d604bb132422..27cc1164ec36 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -208,7 +208,7 @@ static int fat_free(struct inode *inode, int skip)
208 } else if (ret == FAT_ENT_FREE) { 208 } else if (ret == FAT_ENT_FREE) {
209 fat_fs_panic(sb, 209 fat_fs_panic(sb,
210 "%s: invalid cluster chain (i_pos %lld)", 210 "%s: invalid cluster chain (i_pos %lld)",
211 __FUNCTION__, MSDOS_I(inode)->i_pos); 211 __func__, MSDOS_I(inode)->i_pos);
212 ret = -EIO; 212 ret = -EIO;
213 } else if (ret > 0) { 213 } else if (ret > 0) {
214 err = fat_ent_write(inode, &fatent, FAT_ENT_EOF, wait); 214 err = fat_ent_write(inode, &fatent, FAT_ENT_EOF, wait);
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 105d4a271e07..4f3cab321415 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -117,7 +117,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
117 117
118 parent = fuse_control_sb->s_root; 118 parent = fuse_control_sb->s_root;
119 inc_nlink(parent->d_inode); 119 inc_nlink(parent->d_inode);
120 sprintf(name, "%llu", (unsigned long long) fc->id); 120 sprintf(name, "%u", fc->dev);
121 parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2, 121 parent = fuse_ctl_add_dentry(parent, fc, name, S_IFDIR | 0500, 2,
122 &simple_dir_inode_operations, 122 &simple_dir_inode_operations,
123 &simple_dir_operations); 123 &simple_dir_operations);
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index af639807524e..87250b6a8682 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -47,6 +47,14 @@ struct fuse_req *fuse_request_alloc(void)
47 return req; 47 return req;
48} 48}
49 49
50struct fuse_req *fuse_request_alloc_nofs(void)
51{
52 struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, GFP_NOFS);
53 if (req)
54 fuse_request_init(req);
55 return req;
56}
57
50void fuse_request_free(struct fuse_req *req) 58void fuse_request_free(struct fuse_req *req)
51{ 59{
52 kmem_cache_free(fuse_req_cachep, req); 60 kmem_cache_free(fuse_req_cachep, req);
@@ -291,6 +299,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
291 299
292static void wait_answer_interruptible(struct fuse_conn *fc, 300static void wait_answer_interruptible(struct fuse_conn *fc,
293 struct fuse_req *req) 301 struct fuse_req *req)
302 __releases(fc->lock) __acquires(fc->lock)
294{ 303{
295 if (signal_pending(current)) 304 if (signal_pending(current))
296 return; 305 return;
@@ -307,8 +316,8 @@ static void queue_interrupt(struct fuse_conn *fc, struct fuse_req *req)
307 kill_fasync(&fc->fasync, SIGIO, POLL_IN); 316 kill_fasync(&fc->fasync, SIGIO, POLL_IN);
308} 317}
309 318
310/* Called with fc->lock held. Releases, and then reacquires it. */
311static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req) 319static void request_wait_answer(struct fuse_conn *fc, struct fuse_req *req)
320 __releases(fc->lock) __acquires(fc->lock)
312{ 321{
313 if (!fc->no_interrupt) { 322 if (!fc->no_interrupt) {
314 /* Any signal may interrupt this */ 323 /* Any signal may interrupt this */
@@ -430,6 +439,17 @@ void request_send_background(struct fuse_conn *fc, struct fuse_req *req)
430} 439}
431 440
432/* 441/*
442 * Called under fc->lock
443 *
444 * fc->connected must have been checked previously
445 */
446void request_send_background_locked(struct fuse_conn *fc, struct fuse_req *req)
447{
448 req->isreply = 1;
449 request_send_nowait_locked(fc, req);
450}
451
452/*
433 * Lock the request. Up to the next unlock_request() there mustn't be 453 * Lock the request. Up to the next unlock_request() there mustn't be
434 * anything that could cause a page-fault. If the request was already 454 * anything that could cause a page-fault. If the request was already
435 * aborted bail out. 455 * aborted bail out.
@@ -968,6 +988,7 @@ static void end_requests(struct fuse_conn *fc, struct list_head *head)
968 * locked). 988 * locked).
969 */ 989 */
970static void end_io_requests(struct fuse_conn *fc) 990static void end_io_requests(struct fuse_conn *fc)
991 __releases(fc->lock) __acquires(fc->lock)
971{ 992{
972 while (!list_empty(&fc->io)) { 993 while (!list_empty(&fc->io)) {
973 struct fuse_req *req = 994 struct fuse_req *req =
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c4807b3fc8a3..2060bf06b906 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -132,7 +132,7 @@ static void fuse_lookup_init(struct fuse_req *req, struct inode *dir,
132 req->out.args[0].value = outarg; 132 req->out.args[0].value = outarg;
133} 133}
134 134
135static u64 fuse_get_attr_version(struct fuse_conn *fc) 135u64 fuse_get_attr_version(struct fuse_conn *fc)
136{ 136{
137 u64 curr_version; 137 u64 curr_version;
138 138
@@ -1107,6 +1107,50 @@ static void iattr_to_fattr(struct iattr *iattr, struct fuse_setattr_in *arg)
1107} 1107}
1108 1108
1109/* 1109/*
1110 * Prevent concurrent writepages on inode
1111 *
1112 * This is done by adding a negative bias to the inode write counter
1113 * and waiting for all pending writes to finish.
1114 */
1115void fuse_set_nowrite(struct inode *inode)
1116{
1117 struct fuse_conn *fc = get_fuse_conn(inode);
1118 struct fuse_inode *fi = get_fuse_inode(inode);
1119
1120 BUG_ON(!mutex_is_locked(&inode->i_mutex));
1121
1122 spin_lock(&fc->lock);
1123 BUG_ON(fi->writectr < 0);
1124 fi->writectr += FUSE_NOWRITE;
1125 spin_unlock(&fc->lock);
1126 wait_event(fi->page_waitq, fi->writectr == FUSE_NOWRITE);
1127}
1128
1129/*
1130 * Allow writepages on inode
1131 *
1132 * Remove the bias from the writecounter and send any queued
1133 * writepages.
1134 */
1135static void __fuse_release_nowrite(struct inode *inode)
1136{
1137 struct fuse_inode *fi = get_fuse_inode(inode);
1138
1139 BUG_ON(fi->writectr != FUSE_NOWRITE);
1140 fi->writectr = 0;
1141 fuse_flush_writepages(inode);
1142}
1143
1144void fuse_release_nowrite(struct inode *inode)
1145{
1146 struct fuse_conn *fc = get_fuse_conn(inode);
1147
1148 spin_lock(&fc->lock);
1149 __fuse_release_nowrite(inode);
1150 spin_unlock(&fc->lock);
1151}
1152
1153/*
1110 * Set attributes, and at the same time refresh them. 1154 * Set attributes, and at the same time refresh them.
1111 * 1155 *
1112 * Truncation is slightly complicated, because the 'truncate' request 1156 * Truncation is slightly complicated, because the 'truncate' request
@@ -1122,6 +1166,8 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
1122 struct fuse_req *req; 1166 struct fuse_req *req;
1123 struct fuse_setattr_in inarg; 1167 struct fuse_setattr_in inarg;
1124 struct fuse_attr_out outarg; 1168 struct fuse_attr_out outarg;
1169 bool is_truncate = false;
1170 loff_t oldsize;
1125 int err; 1171 int err;
1126 1172
1127 if (!fuse_allow_task(fc, current)) 1173 if (!fuse_allow_task(fc, current))
@@ -1145,12 +1191,16 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
1145 send_sig(SIGXFSZ, current, 0); 1191 send_sig(SIGXFSZ, current, 0);
1146 return -EFBIG; 1192 return -EFBIG;
1147 } 1193 }
1194 is_truncate = true;
1148 } 1195 }
1149 1196
1150 req = fuse_get_req(fc); 1197 req = fuse_get_req(fc);
1151 if (IS_ERR(req)) 1198 if (IS_ERR(req))
1152 return PTR_ERR(req); 1199 return PTR_ERR(req);
1153 1200
1201 if (is_truncate)
1202 fuse_set_nowrite(inode);
1203
1154 memset(&inarg, 0, sizeof(inarg)); 1204 memset(&inarg, 0, sizeof(inarg));
1155 memset(&outarg, 0, sizeof(outarg)); 1205 memset(&outarg, 0, sizeof(outarg));
1156 iattr_to_fattr(attr, &inarg); 1206 iattr_to_fattr(attr, &inarg);
@@ -1181,16 +1231,44 @@ static int fuse_do_setattr(struct dentry *entry, struct iattr *attr,
1181 if (err) { 1231 if (err) {
1182 if (err == -EINTR) 1232 if (err == -EINTR)
1183 fuse_invalidate_attr(inode); 1233 fuse_invalidate_attr(inode);
1184 return err; 1234 goto error;
1185 } 1235 }
1186 1236
1187 if ((inode->i_mode ^ outarg.attr.mode) & S_IFMT) { 1237 if ((inode->i_mode ^ outarg.attr.mode) & S_IFMT) {
1188 make_bad_inode(inode); 1238 make_bad_inode(inode);
1189 return -EIO; 1239 err = -EIO;
1240 goto error;
1241 }
1242
1243 spin_lock(&fc->lock);
1244 fuse_change_attributes_common(inode, &outarg.attr,
1245 attr_timeout(&outarg));
1246 oldsize = inode->i_size;
1247 i_size_write(inode, outarg.attr.size);
1248
1249 if (is_truncate) {
1250 /* NOTE: this may release/reacquire fc->lock */
1251 __fuse_release_nowrite(inode);
1252 }
1253 spin_unlock(&fc->lock);
1254
1255 /*
1256 * Only call invalidate_inode_pages2() after removing
1257 * FUSE_NOWRITE, otherwise fuse_launder_page() would deadlock.
1258 */
1259 if (S_ISREG(inode->i_mode) && oldsize != outarg.attr.size) {
1260 if (outarg.attr.size < oldsize)
1261 fuse_truncate(inode->i_mapping, outarg.attr.size);
1262 invalidate_inode_pages2(inode->i_mapping);
1190 } 1263 }
1191 1264
1192 fuse_change_attributes(inode, &outarg.attr, attr_timeout(&outarg), 0);
1193 return 0; 1265 return 0;
1266
1267error:
1268 if (is_truncate)
1269 fuse_release_nowrite(inode);
1270
1271 return err;
1194} 1272}
1195 1273
1196static int fuse_setattr(struct dentry *entry, struct iattr *attr) 1274static int fuse_setattr(struct dentry *entry, struct iattr *attr)
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 676b0bc8a86d..9ced35b00686 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -210,6 +210,49 @@ u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id)
210 return (u64) v0 + ((u64) v1 << 32); 210 return (u64) v0 + ((u64) v1 << 32);
211} 211}
212 212
213/*
214 * Check if page is under writeback
215 *
216 * This is currently done by walking the list of writepage requests
217 * for the inode, which can be pretty inefficient.
218 */
219static bool fuse_page_is_writeback(struct inode *inode, pgoff_t index)
220{
221 struct fuse_conn *fc = get_fuse_conn(inode);
222 struct fuse_inode *fi = get_fuse_inode(inode);
223 struct fuse_req *req;
224 bool found = false;
225
226 spin_lock(&fc->lock);
227 list_for_each_entry(req, &fi->writepages, writepages_entry) {
228 pgoff_t curr_index;
229
230 BUG_ON(req->inode != inode);
231 curr_index = req->misc.write.in.offset >> PAGE_CACHE_SHIFT;
232 if (curr_index == index) {
233 found = true;
234 break;
235 }
236 }
237 spin_unlock(&fc->lock);
238
239 return found;
240}
241
242/*
243 * Wait for page writeback to be completed.
244 *
245 * Since fuse doesn't rely on the VM writeback tracking, this has to
246 * use some other means.
247 */
248static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
249{
250 struct fuse_inode *fi = get_fuse_inode(inode);
251
252 wait_event(fi->page_waitq, !fuse_page_is_writeback(inode, index));
253 return 0;
254}
255
213static int fuse_flush(struct file *file, fl_owner_t id) 256static int fuse_flush(struct file *file, fl_owner_t id)
214{ 257{
215 struct inode *inode = file->f_path.dentry->d_inode; 258 struct inode *inode = file->f_path.dentry->d_inode;
@@ -245,6 +288,21 @@ static int fuse_flush(struct file *file, fl_owner_t id)
245 return err; 288 return err;
246} 289}
247 290
291/*
292 * Wait for all pending writepages on the inode to finish.
293 *
294 * This is currently done by blocking further writes with FUSE_NOWRITE
295 * and waiting for all sent writes to complete.
296 *
297 * This must be called under i_mutex, otherwise the FUSE_NOWRITE usage
298 * could conflict with truncation.
299 */
300static void fuse_sync_writes(struct inode *inode)
301{
302 fuse_set_nowrite(inode);
303 fuse_release_nowrite(inode);
304}
305
248int fuse_fsync_common(struct file *file, struct dentry *de, int datasync, 306int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,
249 int isdir) 307 int isdir)
250{ 308{
@@ -261,6 +319,17 @@ int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,
261 if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir)) 319 if ((!isdir && fc->no_fsync) || (isdir && fc->no_fsyncdir))
262 return 0; 320 return 0;
263 321
322 /*
323 * Start writeback against all dirty pages of the inode, then
324 * wait for all outstanding writes, before sending the FSYNC
325 * request.
326 */
327 err = write_inode_now(inode, 0);
328 if (err)
329 return err;
330
331 fuse_sync_writes(inode);
332
264 req = fuse_get_req(fc); 333 req = fuse_get_req(fc);
265 if (IS_ERR(req)) 334 if (IS_ERR(req))
266 return PTR_ERR(req); 335 return PTR_ERR(req);
@@ -294,7 +363,7 @@ static int fuse_fsync(struct file *file, struct dentry *de, int datasync)
294void fuse_read_fill(struct fuse_req *req, struct file *file, 363void fuse_read_fill(struct fuse_req *req, struct file *file,
295 struct inode *inode, loff_t pos, size_t count, int opcode) 364 struct inode *inode, loff_t pos, size_t count, int opcode)
296{ 365{
297 struct fuse_read_in *inarg = &req->misc.read_in; 366 struct fuse_read_in *inarg = &req->misc.read.in;
298 struct fuse_file *ff = file->private_data; 367 struct fuse_file *ff = file->private_data;
299 368
300 inarg->fh = ff->fh; 369 inarg->fh = ff->fh;
@@ -320,7 +389,7 @@ static size_t fuse_send_read(struct fuse_req *req, struct file *file,
320 389
321 fuse_read_fill(req, file, inode, pos, count, FUSE_READ); 390 fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
322 if (owner != NULL) { 391 if (owner != NULL) {
323 struct fuse_read_in *inarg = &req->misc.read_in; 392 struct fuse_read_in *inarg = &req->misc.read.in;
324 393
325 inarg->read_flags |= FUSE_READ_LOCKOWNER; 394 inarg->read_flags |= FUSE_READ_LOCKOWNER;
326 inarg->lock_owner = fuse_lock_owner_id(fc, owner); 395 inarg->lock_owner = fuse_lock_owner_id(fc, owner);
@@ -329,31 +398,66 @@ static size_t fuse_send_read(struct fuse_req *req, struct file *file,
329 return req->out.args[0].size; 398 return req->out.args[0].size;
330} 399}
331 400
401static void fuse_read_update_size(struct inode *inode, loff_t size,
402 u64 attr_ver)
403{
404 struct fuse_conn *fc = get_fuse_conn(inode);
405 struct fuse_inode *fi = get_fuse_inode(inode);
406
407 spin_lock(&fc->lock);
408 if (attr_ver == fi->attr_version && size < inode->i_size) {
409 fi->attr_version = ++fc->attr_version;
410 i_size_write(inode, size);
411 }
412 spin_unlock(&fc->lock);
413}
414
332static int fuse_readpage(struct file *file, struct page *page) 415static int fuse_readpage(struct file *file, struct page *page)
333{ 416{
334 struct inode *inode = page->mapping->host; 417 struct inode *inode = page->mapping->host;
335 struct fuse_conn *fc = get_fuse_conn(inode); 418 struct fuse_conn *fc = get_fuse_conn(inode);
336 struct fuse_req *req; 419 struct fuse_req *req;
420 size_t num_read;
421 loff_t pos = page_offset(page);
422 size_t count = PAGE_CACHE_SIZE;
423 u64 attr_ver;
337 int err; 424 int err;
338 425
339 err = -EIO; 426 err = -EIO;
340 if (is_bad_inode(inode)) 427 if (is_bad_inode(inode))
341 goto out; 428 goto out;
342 429
430 /*
431 * Page writeback can extend beyond the liftime of the
432 * page-cache page, so make sure we read a properly synced
433 * page.
434 */
435 fuse_wait_on_page_writeback(inode, page->index);
436
343 req = fuse_get_req(fc); 437 req = fuse_get_req(fc);
344 err = PTR_ERR(req); 438 err = PTR_ERR(req);
345 if (IS_ERR(req)) 439 if (IS_ERR(req))
346 goto out; 440 goto out;
347 441
442 attr_ver = fuse_get_attr_version(fc);
443
348 req->out.page_zeroing = 1; 444 req->out.page_zeroing = 1;
349 req->num_pages = 1; 445 req->num_pages = 1;
350 req->pages[0] = page; 446 req->pages[0] = page;
351 fuse_send_read(req, file, inode, page_offset(page), PAGE_CACHE_SIZE, 447 num_read = fuse_send_read(req, file, inode, pos, count, NULL);
352 NULL);
353 err = req->out.h.error; 448 err = req->out.h.error;
354 fuse_put_request(fc, req); 449 fuse_put_request(fc, req);
355 if (!err) 450
451 if (!err) {
452 /*
453 * Short read means EOF. If file size is larger, truncate it
454 */
455 if (num_read < count)
456 fuse_read_update_size(inode, pos + num_read, attr_ver);
457
356 SetPageUptodate(page); 458 SetPageUptodate(page);
459 }
460
357 fuse_invalidate_attr(inode); /* atime changed */ 461 fuse_invalidate_attr(inode); /* atime changed */
358 out: 462 out:
359 unlock_page(page); 463 unlock_page(page);
@@ -363,8 +467,19 @@ static int fuse_readpage(struct file *file, struct page *page)
363static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req) 467static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
364{ 468{
365 int i; 469 int i;
470 size_t count = req->misc.read.in.size;
471 size_t num_read = req->out.args[0].size;
472 struct inode *inode = req->pages[0]->mapping->host;
473
474 /*
475 * Short read means EOF. If file size is larger, truncate it
476 */
477 if (!req->out.h.error && num_read < count) {
478 loff_t pos = page_offset(req->pages[0]) + num_read;
479 fuse_read_update_size(inode, pos, req->misc.read.attr_ver);
480 }
366 481
367 fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */ 482 fuse_invalidate_attr(inode); /* atime changed */
368 483
369 for (i = 0; i < req->num_pages; i++) { 484 for (i = 0; i < req->num_pages; i++) {
370 struct page *page = req->pages[i]; 485 struct page *page = req->pages[i];
@@ -387,6 +502,7 @@ static void fuse_send_readpages(struct fuse_req *req, struct file *file,
387 size_t count = req->num_pages << PAGE_CACHE_SHIFT; 502 size_t count = req->num_pages << PAGE_CACHE_SHIFT;
388 req->out.page_zeroing = 1; 503 req->out.page_zeroing = 1;
389 fuse_read_fill(req, file, inode, pos, count, FUSE_READ); 504 fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
505 req->misc.read.attr_ver = fuse_get_attr_version(fc);
390 if (fc->async_read) { 506 if (fc->async_read) {
391 struct fuse_file *ff = file->private_data; 507 struct fuse_file *ff = file->private_data;
392 req->ff = fuse_file_get(ff); 508 req->ff = fuse_file_get(ff);
@@ -411,6 +527,8 @@ static int fuse_readpages_fill(void *_data, struct page *page)
411 struct inode *inode = data->inode; 527 struct inode *inode = data->inode;
412 struct fuse_conn *fc = get_fuse_conn(inode); 528 struct fuse_conn *fc = get_fuse_conn(inode);
413 529
530 fuse_wait_on_page_writeback(inode, page->index);
531
414 if (req->num_pages && 532 if (req->num_pages &&
415 (req->num_pages == FUSE_MAX_PAGES_PER_REQ || 533 (req->num_pages == FUSE_MAX_PAGES_PER_REQ ||
416 (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read || 534 (req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read ||
@@ -477,11 +595,10 @@ static ssize_t fuse_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
477} 595}
478 596
479static void fuse_write_fill(struct fuse_req *req, struct file *file, 597static void fuse_write_fill(struct fuse_req *req, struct file *file,
480 struct inode *inode, loff_t pos, size_t count, 598 struct fuse_file *ff, struct inode *inode,
481 int writepage) 599 loff_t pos, size_t count, int writepage)
482{ 600{
483 struct fuse_conn *fc = get_fuse_conn(inode); 601 struct fuse_conn *fc = get_fuse_conn(inode);
484 struct fuse_file *ff = file->private_data;
485 struct fuse_write_in *inarg = &req->misc.write.in; 602 struct fuse_write_in *inarg = &req->misc.write.in;
486 struct fuse_write_out *outarg = &req->misc.write.out; 603 struct fuse_write_out *outarg = &req->misc.write.out;
487 604
@@ -490,7 +607,7 @@ static void fuse_write_fill(struct fuse_req *req, struct file *file,
490 inarg->offset = pos; 607 inarg->offset = pos;
491 inarg->size = count; 608 inarg->size = count;
492 inarg->write_flags = writepage ? FUSE_WRITE_CACHE : 0; 609 inarg->write_flags = writepage ? FUSE_WRITE_CACHE : 0;
493 inarg->flags = file->f_flags; 610 inarg->flags = file ? file->f_flags : 0;
494 req->in.h.opcode = FUSE_WRITE; 611 req->in.h.opcode = FUSE_WRITE;
495 req->in.h.nodeid = get_node_id(inode); 612 req->in.h.nodeid = get_node_id(inode);
496 req->in.argpages = 1; 613 req->in.argpages = 1;
@@ -511,7 +628,7 @@ static size_t fuse_send_write(struct fuse_req *req, struct file *file,
511 fl_owner_t owner) 628 fl_owner_t owner)
512{ 629{
513 struct fuse_conn *fc = get_fuse_conn(inode); 630 struct fuse_conn *fc = get_fuse_conn(inode);
514 fuse_write_fill(req, file, inode, pos, count, 0); 631 fuse_write_fill(req, file, file->private_data, inode, pos, count, 0);
515 if (owner != NULL) { 632 if (owner != NULL) {
516 struct fuse_write_in *inarg = &req->misc.write.in; 633 struct fuse_write_in *inarg = &req->misc.write.in;
517 inarg->write_flags |= FUSE_WRITE_LOCKOWNER; 634 inarg->write_flags |= FUSE_WRITE_LOCKOWNER;
@@ -533,19 +650,36 @@ static int fuse_write_begin(struct file *file, struct address_space *mapping,
533 return 0; 650 return 0;
534} 651}
535 652
653static void fuse_write_update_size(struct inode *inode, loff_t pos)
654{
655 struct fuse_conn *fc = get_fuse_conn(inode);
656 struct fuse_inode *fi = get_fuse_inode(inode);
657
658 spin_lock(&fc->lock);
659 fi->attr_version = ++fc->attr_version;
660 if (pos > inode->i_size)
661 i_size_write(inode, pos);
662 spin_unlock(&fc->lock);
663}
664
536static int fuse_buffered_write(struct file *file, struct inode *inode, 665static int fuse_buffered_write(struct file *file, struct inode *inode,
537 loff_t pos, unsigned count, struct page *page) 666 loff_t pos, unsigned count, struct page *page)
538{ 667{
539 int err; 668 int err;
540 size_t nres; 669 size_t nres;
541 struct fuse_conn *fc = get_fuse_conn(inode); 670 struct fuse_conn *fc = get_fuse_conn(inode);
542 struct fuse_inode *fi = get_fuse_inode(inode);
543 unsigned offset = pos & (PAGE_CACHE_SIZE - 1); 671 unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
544 struct fuse_req *req; 672 struct fuse_req *req;
545 673
546 if (is_bad_inode(inode)) 674 if (is_bad_inode(inode))
547 return -EIO; 675 return -EIO;
548 676
677 /*
678 * Make sure writepages on the same page are not mixed up with
679 * plain writes.
680 */
681 fuse_wait_on_page_writeback(inode, page->index);
682
549 req = fuse_get_req(fc); 683 req = fuse_get_req(fc);
550 if (IS_ERR(req)) 684 if (IS_ERR(req))
551 return PTR_ERR(req); 685 return PTR_ERR(req);
@@ -560,12 +694,7 @@ static int fuse_buffered_write(struct file *file, struct inode *inode,
560 err = -EIO; 694 err = -EIO;
561 if (!err) { 695 if (!err) {
562 pos += nres; 696 pos += nres;
563 spin_lock(&fc->lock); 697 fuse_write_update_size(inode, pos);
564 fi->attr_version = ++fc->attr_version;
565 if (pos > inode->i_size)
566 i_size_write(inode, pos);
567 spin_unlock(&fc->lock);
568
569 if (count == PAGE_CACHE_SIZE) 698 if (count == PAGE_CACHE_SIZE)
570 SetPageUptodate(page); 699 SetPageUptodate(page);
571 } 700 }
@@ -588,6 +717,198 @@ static int fuse_write_end(struct file *file, struct address_space *mapping,
588 return res; 717 return res;
589} 718}
590 719
720static size_t fuse_send_write_pages(struct fuse_req *req, struct file *file,
721 struct inode *inode, loff_t pos,
722 size_t count)
723{
724 size_t res;
725 unsigned offset;
726 unsigned i;
727
728 for (i = 0; i < req->num_pages; i++)
729 fuse_wait_on_page_writeback(inode, req->pages[i]->index);
730
731 res = fuse_send_write(req, file, inode, pos, count, NULL);
732
733 offset = req->page_offset;
734 count = res;
735 for (i = 0; i < req->num_pages; i++) {
736 struct page *page = req->pages[i];
737
738 if (!req->out.h.error && !offset && count >= PAGE_CACHE_SIZE)
739 SetPageUptodate(page);
740
741 if (count > PAGE_CACHE_SIZE - offset)
742 count -= PAGE_CACHE_SIZE - offset;
743 else
744 count = 0;
745 offset = 0;
746
747 unlock_page(page);
748 page_cache_release(page);
749 }
750
751 return res;
752}
753
754static ssize_t fuse_fill_write_pages(struct fuse_req *req,
755 struct address_space *mapping,
756 struct iov_iter *ii, loff_t pos)
757{
758 struct fuse_conn *fc = get_fuse_conn(mapping->host);
759 unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
760 size_t count = 0;
761 int err;
762
763 req->page_offset = offset;
764
765 do {
766 size_t tmp;
767 struct page *page;
768 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
769 size_t bytes = min_t(size_t, PAGE_CACHE_SIZE - offset,
770 iov_iter_count(ii));
771
772 bytes = min_t(size_t, bytes, fc->max_write - count);
773
774 again:
775 err = -EFAULT;
776 if (iov_iter_fault_in_readable(ii, bytes))
777 break;
778
779 err = -ENOMEM;
780 page = __grab_cache_page(mapping, index);
781 if (!page)
782 break;
783
784 pagefault_disable();
785 tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes);
786 pagefault_enable();
787 flush_dcache_page(page);
788
789 if (!tmp) {
790 unlock_page(page);
791 page_cache_release(page);
792 bytes = min(bytes, iov_iter_single_seg_count(ii));
793 goto again;
794 }
795
796 err = 0;
797 req->pages[req->num_pages] = page;
798 req->num_pages++;
799
800 iov_iter_advance(ii, tmp);
801 count += tmp;
802 pos += tmp;
803 offset += tmp;
804 if (offset == PAGE_CACHE_SIZE)
805 offset = 0;
806
807 } while (iov_iter_count(ii) && count < fc->max_write &&
808 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0);
809
810 return count > 0 ? count : err;
811}
812
813static ssize_t fuse_perform_write(struct file *file,
814 struct address_space *mapping,
815 struct iov_iter *ii, loff_t pos)
816{
817 struct inode *inode = mapping->host;
818 struct fuse_conn *fc = get_fuse_conn(inode);
819 int err = 0;
820 ssize_t res = 0;
821
822 if (is_bad_inode(inode))
823 return -EIO;
824
825 do {
826 struct fuse_req *req;
827 ssize_t count;
828
829 req = fuse_get_req(fc);
830 if (IS_ERR(req)) {
831 err = PTR_ERR(req);
832 break;
833 }
834
835 count = fuse_fill_write_pages(req, mapping, ii, pos);
836 if (count <= 0) {
837 err = count;
838 } else {
839 size_t num_written;
840
841 num_written = fuse_send_write_pages(req, file, inode,
842 pos, count);
843 err = req->out.h.error;
844 if (!err) {
845 res += num_written;
846 pos += num_written;
847
848 /* break out of the loop on short write */
849 if (num_written != count)
850 err = -EIO;
851 }
852 }
853 fuse_put_request(fc, req);
854 } while (!err && iov_iter_count(ii));
855
856 if (res > 0)
857 fuse_write_update_size(inode, pos);
858
859 fuse_invalidate_attr(inode);
860
861 return res > 0 ? res : err;
862}
863
864static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
865 unsigned long nr_segs, loff_t pos)
866{
867 struct file *file = iocb->ki_filp;
868 struct address_space *mapping = file->f_mapping;
869 size_t count = 0;
870 ssize_t written = 0;
871 struct inode *inode = mapping->host;
872 ssize_t err;
873 struct iov_iter i;
874
875 WARN_ON(iocb->ki_pos != pos);
876
877 err = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ);
878 if (err)
879 return err;
880
881 mutex_lock(&inode->i_mutex);
882 vfs_check_frozen(inode->i_sb, SB_FREEZE_WRITE);
883
884 /* We can write back this queue in page reclaim */
885 current->backing_dev_info = mapping->backing_dev_info;
886
887 err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
888 if (err)
889 goto out;
890
891 if (count == 0)
892 goto out;
893
894 err = remove_suid(file->f_path.dentry);
895 if (err)
896 goto out;
897
898 file_update_time(file);
899
900 iov_iter_init(&i, iov, nr_segs, count, 0);
901 written = fuse_perform_write(file, mapping, &i, pos);
902 if (written >= 0)
903 iocb->ki_pos = pos + written;
904
905out:
906 current->backing_dev_info = NULL;
907 mutex_unlock(&inode->i_mutex);
908
909 return written ? written : err;
910}
911
591static void fuse_release_user_pages(struct fuse_req *req, int write) 912static void fuse_release_user_pages(struct fuse_req *req, int write)
592{ 913{
593 unsigned i; 914 unsigned i;
@@ -645,14 +966,15 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
645 966
646 while (count) { 967 while (count) {
647 size_t nres; 968 size_t nres;
648 size_t nbytes = min(count, nmax); 969 size_t nbytes_limit = min(count, nmax);
649 int err = fuse_get_user_pages(req, buf, nbytes, !write); 970 size_t nbytes;
971 int err = fuse_get_user_pages(req, buf, nbytes_limit, !write);
650 if (err) { 972 if (err) {
651 res = err; 973 res = err;
652 break; 974 break;
653 } 975 }
654 nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset; 976 nbytes = (req->num_pages << PAGE_SHIFT) - req->page_offset;
655 nbytes = min(count, nbytes); 977 nbytes = min(nbytes_limit, nbytes);
656 if (write) 978 if (write)
657 nres = fuse_send_write(req, file, inode, pos, nbytes, 979 nres = fuse_send_write(req, file, inode, pos, nbytes,
658 current->files); 980 current->files);
@@ -683,12 +1005,8 @@ static ssize_t fuse_direct_io(struct file *file, const char __user *buf,
683 } 1005 }
684 fuse_put_request(fc, req); 1006 fuse_put_request(fc, req);
685 if (res > 0) { 1007 if (res > 0) {
686 if (write) { 1008 if (write)
687 spin_lock(&fc->lock); 1009 fuse_write_update_size(inode, pos);
688 if (pos > inode->i_size)
689 i_size_write(inode, pos);
690 spin_unlock(&fc->lock);
691 }
692 *ppos = pos; 1010 *ppos = pos;
693 } 1011 }
694 fuse_invalidate_attr(inode); 1012 fuse_invalidate_attr(inode);
@@ -716,21 +1034,225 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
716 return res; 1034 return res;
717} 1035}
718 1036
719static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) 1037static void fuse_writepage_free(struct fuse_conn *fc, struct fuse_req *req)
720{ 1038{
721 if ((vma->vm_flags & VM_SHARED)) { 1039 __free_page(req->pages[0]);
722 if ((vma->vm_flags & VM_WRITE)) 1040 fuse_file_put(req->ff);
723 return -ENODEV; 1041 fuse_put_request(fc, req);
724 else 1042}
725 vma->vm_flags &= ~VM_MAYWRITE; 1043
1044static void fuse_writepage_finish(struct fuse_conn *fc, struct fuse_req *req)
1045{
1046 struct inode *inode = req->inode;
1047 struct fuse_inode *fi = get_fuse_inode(inode);
1048 struct backing_dev_info *bdi = inode->i_mapping->backing_dev_info;
1049
1050 list_del(&req->writepages_entry);
1051 dec_bdi_stat(bdi, BDI_WRITEBACK);
1052 dec_zone_page_state(req->pages[0], NR_WRITEBACK_TEMP);
1053 bdi_writeout_inc(bdi);
1054 wake_up(&fi->page_waitq);
1055}
1056
1057/* Called under fc->lock, may release and reacquire it */
1058static void fuse_send_writepage(struct fuse_conn *fc, struct fuse_req *req)
1059{
1060 struct fuse_inode *fi = get_fuse_inode(req->inode);
1061 loff_t size = i_size_read(req->inode);
1062 struct fuse_write_in *inarg = &req->misc.write.in;
1063
1064 if (!fc->connected)
1065 goto out_free;
1066
1067 if (inarg->offset + PAGE_CACHE_SIZE <= size) {
1068 inarg->size = PAGE_CACHE_SIZE;
1069 } else if (inarg->offset < size) {
1070 inarg->size = size & (PAGE_CACHE_SIZE - 1);
1071 } else {
1072 /* Got truncated off completely */
1073 goto out_free;
1074 }
1075
1076 req->in.args[1].size = inarg->size;
1077 fi->writectr++;
1078 request_send_background_locked(fc, req);
1079 return;
1080
1081 out_free:
1082 fuse_writepage_finish(fc, req);
1083 spin_unlock(&fc->lock);
1084 fuse_writepage_free(fc, req);
1085 spin_lock(&fc->lock);
1086}
1087
1088/*
1089 * If fi->writectr is positive (no truncate or fsync going on) send
1090 * all queued writepage requests.
1091 *
1092 * Called with fc->lock
1093 */
1094void fuse_flush_writepages(struct inode *inode)
1095{
1096 struct fuse_conn *fc = get_fuse_conn(inode);
1097 struct fuse_inode *fi = get_fuse_inode(inode);
1098 struct fuse_req *req;
1099
1100 while (fi->writectr >= 0 && !list_empty(&fi->queued_writes)) {
1101 req = list_entry(fi->queued_writes.next, struct fuse_req, list);
1102 list_del_init(&req->list);
1103 fuse_send_writepage(fc, req);
1104 }
1105}
1106
1107static void fuse_writepage_end(struct fuse_conn *fc, struct fuse_req *req)
1108{
1109 struct inode *inode = req->inode;
1110 struct fuse_inode *fi = get_fuse_inode(inode);
1111
1112 mapping_set_error(inode->i_mapping, req->out.h.error);
1113 spin_lock(&fc->lock);
1114 fi->writectr--;
1115 fuse_writepage_finish(fc, req);
1116 spin_unlock(&fc->lock);
1117 fuse_writepage_free(fc, req);
1118}
1119
1120static int fuse_writepage_locked(struct page *page)
1121{
1122 struct address_space *mapping = page->mapping;
1123 struct inode *inode = mapping->host;
1124 struct fuse_conn *fc = get_fuse_conn(inode);
1125 struct fuse_inode *fi = get_fuse_inode(inode);
1126 struct fuse_req *req;
1127 struct fuse_file *ff;
1128 struct page *tmp_page;
1129
1130 set_page_writeback(page);
1131
1132 req = fuse_request_alloc_nofs();
1133 if (!req)
1134 goto err;
1135
1136 tmp_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
1137 if (!tmp_page)
1138 goto err_free;
1139
1140 spin_lock(&fc->lock);
1141 BUG_ON(list_empty(&fi->write_files));
1142 ff = list_entry(fi->write_files.next, struct fuse_file, write_entry);
1143 req->ff = fuse_file_get(ff);
1144 spin_unlock(&fc->lock);
1145
1146 fuse_write_fill(req, NULL, ff, inode, page_offset(page), 0, 1);
1147
1148 copy_highpage(tmp_page, page);
1149 req->num_pages = 1;
1150 req->pages[0] = tmp_page;
1151 req->page_offset = 0;
1152 req->end = fuse_writepage_end;
1153 req->inode = inode;
1154
1155 inc_bdi_stat(mapping->backing_dev_info, BDI_WRITEBACK);
1156 inc_zone_page_state(tmp_page, NR_WRITEBACK_TEMP);
1157 end_page_writeback(page);
1158
1159 spin_lock(&fc->lock);
1160 list_add(&req->writepages_entry, &fi->writepages);
1161 list_add_tail(&req->list, &fi->queued_writes);
1162 fuse_flush_writepages(inode);
1163 spin_unlock(&fc->lock);
1164
1165 return 0;
1166
1167err_free:
1168 fuse_request_free(req);
1169err:
1170 end_page_writeback(page);
1171 return -ENOMEM;
1172}
1173
1174static int fuse_writepage(struct page *page, struct writeback_control *wbc)
1175{
1176 int err;
1177
1178 err = fuse_writepage_locked(page);
1179 unlock_page(page);
1180
1181 return err;
1182}
1183
1184static int fuse_launder_page(struct page *page)
1185{
1186 int err = 0;
1187 if (clear_page_dirty_for_io(page)) {
1188 struct inode *inode = page->mapping->host;
1189 err = fuse_writepage_locked(page);
1190 if (!err)
1191 fuse_wait_on_page_writeback(inode, page->index);
726 } 1192 }
727 return generic_file_mmap(file, vma); 1193 return err;
728} 1194}
729 1195
730static int fuse_set_page_dirty(struct page *page) 1196/*
1197 * Write back dirty pages now, because there may not be any suitable
1198 * open files later
1199 */
1200static void fuse_vma_close(struct vm_area_struct *vma)
731{ 1201{
732 printk("fuse_set_page_dirty: should not happen\n"); 1202 filemap_write_and_wait(vma->vm_file->f_mapping);
733 dump_stack(); 1203}
1204
1205/*
1206 * Wait for writeback against this page to complete before allowing it
1207 * to be marked dirty again, and hence written back again, possibly
1208 * before the previous writepage completed.
1209 *
1210 * Block here, instead of in ->writepage(), so that the userspace fs
1211 * can only block processes actually operating on the filesystem.
1212 *
1213 * Otherwise unprivileged userspace fs would be able to block
1214 * unrelated:
1215 *
1216 * - page migration
1217 * - sync(2)
1218 * - try_to_free_pages() with order > PAGE_ALLOC_COSTLY_ORDER
1219 */
1220static int fuse_page_mkwrite(struct vm_area_struct *vma, struct page *page)
1221{
1222 /*
1223 * Don't use page->mapping as it may become NULL from a
1224 * concurrent truncate.
1225 */
1226 struct inode *inode = vma->vm_file->f_mapping->host;
1227
1228 fuse_wait_on_page_writeback(inode, page->index);
1229 return 0;
1230}
1231
1232static struct vm_operations_struct fuse_file_vm_ops = {
1233 .close = fuse_vma_close,
1234 .fault = filemap_fault,
1235 .page_mkwrite = fuse_page_mkwrite,
1236};
1237
1238static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
1239{
1240 if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
1241 struct inode *inode = file->f_dentry->d_inode;
1242 struct fuse_conn *fc = get_fuse_conn(inode);
1243 struct fuse_inode *fi = get_fuse_inode(inode);
1244 struct fuse_file *ff = file->private_data;
1245 /*
1246 * file may be written through mmap, so chain it onto the
1247 * inodes's write_file list
1248 */
1249 spin_lock(&fc->lock);
1250 if (list_empty(&ff->write_entry))
1251 list_add(&ff->write_entry, &fi->write_files);
1252 spin_unlock(&fc->lock);
1253 }
1254 file_accessed(file);
1255 vma->vm_ops = &fuse_file_vm_ops;
734 return 0; 1256 return 0;
735} 1257}
736 1258
@@ -909,12 +1431,37 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
909 return err ? 0 : outarg.block; 1431 return err ? 0 : outarg.block;
910} 1432}
911 1433
1434static loff_t fuse_file_llseek(struct file *file, loff_t offset, int origin)
1435{
1436 loff_t retval;
1437 struct inode *inode = file->f_path.dentry->d_inode;
1438
1439 mutex_lock(&inode->i_mutex);
1440 switch (origin) {
1441 case SEEK_END:
1442 offset += i_size_read(inode);
1443 break;
1444 case SEEK_CUR:
1445 offset += file->f_pos;
1446 }
1447 retval = -EINVAL;
1448 if (offset >= 0 && offset <= inode->i_sb->s_maxbytes) {
1449 if (offset != file->f_pos) {
1450 file->f_pos = offset;
1451 file->f_version = 0;
1452 }
1453 retval = offset;
1454 }
1455 mutex_unlock(&inode->i_mutex);
1456 return retval;
1457}
1458
912static const struct file_operations fuse_file_operations = { 1459static const struct file_operations fuse_file_operations = {
913 .llseek = generic_file_llseek, 1460 .llseek = fuse_file_llseek,
914 .read = do_sync_read, 1461 .read = do_sync_read,
915 .aio_read = fuse_file_aio_read, 1462 .aio_read = fuse_file_aio_read,
916 .write = do_sync_write, 1463 .write = do_sync_write,
917 .aio_write = generic_file_aio_write, 1464 .aio_write = fuse_file_aio_write,
918 .mmap = fuse_file_mmap, 1465 .mmap = fuse_file_mmap,
919 .open = fuse_open, 1466 .open = fuse_open,
920 .flush = fuse_flush, 1467 .flush = fuse_flush,
@@ -926,7 +1473,7 @@ static const struct file_operations fuse_file_operations = {
926}; 1473};
927 1474
928static const struct file_operations fuse_direct_io_file_operations = { 1475static const struct file_operations fuse_direct_io_file_operations = {
929 .llseek = generic_file_llseek, 1476 .llseek = fuse_file_llseek,
930 .read = fuse_direct_read, 1477 .read = fuse_direct_read,
931 .write = fuse_direct_write, 1478 .write = fuse_direct_write,
932 .open = fuse_open, 1479 .open = fuse_open,
@@ -940,10 +1487,12 @@ static const struct file_operations fuse_direct_io_file_operations = {
940 1487
941static const struct address_space_operations fuse_file_aops = { 1488static const struct address_space_operations fuse_file_aops = {
942 .readpage = fuse_readpage, 1489 .readpage = fuse_readpage,
1490 .writepage = fuse_writepage,
1491 .launder_page = fuse_launder_page,
943 .write_begin = fuse_write_begin, 1492 .write_begin = fuse_write_begin,
944 .write_end = fuse_write_end, 1493 .write_end = fuse_write_end,
945 .readpages = fuse_readpages, 1494 .readpages = fuse_readpages,
946 .set_page_dirty = fuse_set_page_dirty, 1495 .set_page_dirty = __set_page_dirty_nobuffers,
947 .bmap = fuse_bmap, 1496 .bmap = fuse_bmap,
948}; 1497};
949 1498
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 67aaf6ee38ea..dadffa21a206 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -15,6 +15,7 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/backing-dev.h> 16#include <linux/backing-dev.h>
17#include <linux/mutex.h> 17#include <linux/mutex.h>
18#include <linux/rwsem.h>
18 19
19/** Max number of pages that can be used in a single read request */ 20/** Max number of pages that can be used in a single read request */
20#define FUSE_MAX_PAGES_PER_REQ 32 21#define FUSE_MAX_PAGES_PER_REQ 32
@@ -25,6 +26,9 @@
25/** Congestion starts at 75% of maximum */ 26/** Congestion starts at 75% of maximum */
26#define FUSE_CONGESTION_THRESHOLD (FUSE_MAX_BACKGROUND * 75 / 100) 27#define FUSE_CONGESTION_THRESHOLD (FUSE_MAX_BACKGROUND * 75 / 100)
27 28
29/** Bias for fi->writectr, meaning new writepages must not be sent */
30#define FUSE_NOWRITE INT_MIN
31
28/** It could be as large as PATH_MAX, but would that have any uses? */ 32/** It could be as large as PATH_MAX, but would that have any uses? */
29#define FUSE_NAME_MAX 1024 33#define FUSE_NAME_MAX 1024
30 34
@@ -73,6 +77,19 @@ struct fuse_inode {
73 77
74 /** Files usable in writepage. Protected by fc->lock */ 78 /** Files usable in writepage. Protected by fc->lock */
75 struct list_head write_files; 79 struct list_head write_files;
80
81 /** Writepages pending on truncate or fsync */
82 struct list_head queued_writes;
83
84 /** Number of sent writes, a negative bias (FUSE_NOWRITE)
85 * means more writes are blocked */
86 int writectr;
87
88 /** Waitq for writepage completion */
89 wait_queue_head_t page_waitq;
90
91 /** List of writepage requestst (pending or sent) */
92 struct list_head writepages;
76}; 93};
77 94
78/** FUSE specific file data */ 95/** FUSE specific file data */
@@ -222,7 +239,10 @@ struct fuse_req {
222 } release; 239 } release;
223 struct fuse_init_in init_in; 240 struct fuse_init_in init_in;
224 struct fuse_init_out init_out; 241 struct fuse_init_out init_out;
225 struct fuse_read_in read_in; 242 struct {
243 struct fuse_read_in in;
244 u64 attr_ver;
245 } read;
226 struct { 246 struct {
227 struct fuse_write_in in; 247 struct fuse_write_in in;
228 struct fuse_write_out out; 248 struct fuse_write_out out;
@@ -242,6 +262,12 @@ struct fuse_req {
242 /** File used in the request (or NULL) */ 262 /** File used in the request (or NULL) */
243 struct fuse_file *ff; 263 struct fuse_file *ff;
244 264
265 /** Inode used in the request or NULL */
266 struct inode *inode;
267
268 /** Link on fi->writepages */
269 struct list_head writepages_entry;
270
245 /** Request completion callback */ 271 /** Request completion callback */
246 void (*end)(struct fuse_conn *, struct fuse_req *); 272 void (*end)(struct fuse_conn *, struct fuse_req *);
247 273
@@ -390,8 +416,8 @@ struct fuse_conn {
390 /** Entry on the fuse_conn_list */ 416 /** Entry on the fuse_conn_list */
391 struct list_head entry; 417 struct list_head entry;
392 418
393 /** Unique ID */ 419 /** Device ID from super block */
394 u64 id; 420 dev_t dev;
395 421
396 /** Dentries in the control filesystem */ 422 /** Dentries in the control filesystem */
397 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; 423 struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
@@ -438,7 +464,7 @@ extern const struct file_operations fuse_dev_operations;
438/** 464/**
439 * Get a filled in inode 465 * Get a filled in inode
440 */ 466 */
441struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid, 467struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
442 int generation, struct fuse_attr *attr, 468 int generation, struct fuse_attr *attr,
443 u64 attr_valid, u64 attr_version); 469 u64 attr_valid, u64 attr_version);
444 470
@@ -446,7 +472,7 @@ struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid,
446 * Send FORGET command 472 * Send FORGET command
447 */ 473 */
448void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, 474void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
449 unsigned long nodeid, u64 nlookup); 475 u64 nodeid, u64 nlookup);
450 476
451/** 477/**
452 * Initialize READ or READDIR request 478 * Initialize READ or READDIR request
@@ -504,6 +530,11 @@ void fuse_init_symlink(struct inode *inode);
504void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, 530void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
505 u64 attr_valid, u64 attr_version); 531 u64 attr_valid, u64 attr_version);
506 532
533void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
534 u64 attr_valid);
535
536void fuse_truncate(struct address_space *mapping, loff_t offset);
537
507/** 538/**
508 * Initialize the client device 539 * Initialize the client device
509 */ 540 */
@@ -522,6 +553,8 @@ void fuse_ctl_cleanup(void);
522 */ 553 */
523struct fuse_req *fuse_request_alloc(void); 554struct fuse_req *fuse_request_alloc(void);
524 555
556struct fuse_req *fuse_request_alloc_nofs(void);
557
525/** 558/**
526 * Free a request 559 * Free a request
527 */ 560 */
@@ -558,6 +591,8 @@ void request_send_noreply(struct fuse_conn *fc, struct fuse_req *req);
558 */ 591 */
559void request_send_background(struct fuse_conn *fc, struct fuse_req *req); 592void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
560 593
594void request_send_background_locked(struct fuse_conn *fc, struct fuse_req *req);
595
561/* Abort all requests */ 596/* Abort all requests */
562void fuse_abort_conn(struct fuse_conn *fc); 597void fuse_abort_conn(struct fuse_conn *fc);
563 598
@@ -600,3 +635,10 @@ u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id);
600 635
601int fuse_update_attributes(struct inode *inode, struct kstat *stat, 636int fuse_update_attributes(struct inode *inode, struct kstat *stat,
602 struct file *file, bool *refreshed); 637 struct file *file, bool *refreshed);
638
639void fuse_flush_writepages(struct inode *inode);
640
641void fuse_set_nowrite(struct inode *inode);
642void fuse_release_nowrite(struct inode *inode);
643
644u64 fuse_get_attr_version(struct fuse_conn *fc);
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 4df34da2284a..79b615873838 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -59,7 +59,11 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
59 fi->nodeid = 0; 59 fi->nodeid = 0;
60 fi->nlookup = 0; 60 fi->nlookup = 0;
61 fi->attr_version = 0; 61 fi->attr_version = 0;
62 fi->writectr = 0;
62 INIT_LIST_HEAD(&fi->write_files); 63 INIT_LIST_HEAD(&fi->write_files);
64 INIT_LIST_HEAD(&fi->queued_writes);
65 INIT_LIST_HEAD(&fi->writepages);
66 init_waitqueue_head(&fi->page_waitq);
63 fi->forget_req = fuse_request_alloc(); 67 fi->forget_req = fuse_request_alloc();
64 if (!fi->forget_req) { 68 if (!fi->forget_req) {
65 kmem_cache_free(fuse_inode_cachep, inode); 69 kmem_cache_free(fuse_inode_cachep, inode);
@@ -73,13 +77,14 @@ static void fuse_destroy_inode(struct inode *inode)
73{ 77{
74 struct fuse_inode *fi = get_fuse_inode(inode); 78 struct fuse_inode *fi = get_fuse_inode(inode);
75 BUG_ON(!list_empty(&fi->write_files)); 79 BUG_ON(!list_empty(&fi->write_files));
80 BUG_ON(!list_empty(&fi->queued_writes));
76 if (fi->forget_req) 81 if (fi->forget_req)
77 fuse_request_free(fi->forget_req); 82 fuse_request_free(fi->forget_req);
78 kmem_cache_free(fuse_inode_cachep, inode); 83 kmem_cache_free(fuse_inode_cachep, inode);
79} 84}
80 85
81void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req, 86void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
82 unsigned long nodeid, u64 nlookup) 87 u64 nodeid, u64 nlookup)
83{ 88{
84 struct fuse_forget_in *inarg = &req->misc.forget_in; 89 struct fuse_forget_in *inarg = &req->misc.forget_in;
85 inarg->nlookup = nlookup; 90 inarg->nlookup = nlookup;
@@ -109,7 +114,7 @@ static int fuse_remount_fs(struct super_block *sb, int *flags, char *data)
109 return 0; 114 return 0;
110} 115}
111 116
112static void fuse_truncate(struct address_space *mapping, loff_t offset) 117void fuse_truncate(struct address_space *mapping, loff_t offset)
113{ 118{
114 /* See vmtruncate() */ 119 /* See vmtruncate() */
115 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); 120 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
@@ -117,19 +122,12 @@ static void fuse_truncate(struct address_space *mapping, loff_t offset)
117 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1); 122 unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
118} 123}
119 124
120 125void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
121void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, 126 u64 attr_valid)
122 u64 attr_valid, u64 attr_version)
123{ 127{
124 struct fuse_conn *fc = get_fuse_conn(inode); 128 struct fuse_conn *fc = get_fuse_conn(inode);
125 struct fuse_inode *fi = get_fuse_inode(inode); 129 struct fuse_inode *fi = get_fuse_inode(inode);
126 loff_t oldsize;
127 130
128 spin_lock(&fc->lock);
129 if (attr_version != 0 && fi->attr_version > attr_version) {
130 spin_unlock(&fc->lock);
131 return;
132 }
133 fi->attr_version = ++fc->attr_version; 131 fi->attr_version = ++fc->attr_version;
134 fi->i_time = attr_valid; 132 fi->i_time = attr_valid;
135 133
@@ -159,6 +157,22 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
159 fi->orig_i_mode = inode->i_mode; 157 fi->orig_i_mode = inode->i_mode;
160 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS)) 158 if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
161 inode->i_mode &= ~S_ISVTX; 159 inode->i_mode &= ~S_ISVTX;
160}
161
162void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
163 u64 attr_valid, u64 attr_version)
164{
165 struct fuse_conn *fc = get_fuse_conn(inode);
166 struct fuse_inode *fi = get_fuse_inode(inode);
167 loff_t oldsize;
168
169 spin_lock(&fc->lock);
170 if (attr_version != 0 && fi->attr_version > attr_version) {
171 spin_unlock(&fc->lock);
172 return;
173 }
174
175 fuse_change_attributes_common(inode, attr, attr_valid);
162 176
163 oldsize = inode->i_size; 177 oldsize = inode->i_size;
164 i_size_write(inode, attr->size); 178 i_size_write(inode, attr->size);
@@ -193,7 +207,7 @@ static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
193 207
194static int fuse_inode_eq(struct inode *inode, void *_nodeidp) 208static int fuse_inode_eq(struct inode *inode, void *_nodeidp)
195{ 209{
196 unsigned long nodeid = *(unsigned long *) _nodeidp; 210 u64 nodeid = *(u64 *) _nodeidp;
197 if (get_node_id(inode) == nodeid) 211 if (get_node_id(inode) == nodeid)
198 return 1; 212 return 1;
199 else 213 else
@@ -202,12 +216,12 @@ static int fuse_inode_eq(struct inode *inode, void *_nodeidp)
202 216
203static int fuse_inode_set(struct inode *inode, void *_nodeidp) 217static int fuse_inode_set(struct inode *inode, void *_nodeidp)
204{ 218{
205 unsigned long nodeid = *(unsigned long *) _nodeidp; 219 u64 nodeid = *(u64 *) _nodeidp;
206 get_fuse_inode(inode)->nodeid = nodeid; 220 get_fuse_inode(inode)->nodeid = nodeid;
207 return 0; 221 return 0;
208} 222}
209 223
210struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid, 224struct inode *fuse_iget(struct super_block *sb, u64 nodeid,
211 int generation, struct fuse_attr *attr, 225 int generation, struct fuse_attr *attr,
212 u64 attr_valid, u64 attr_version) 226 u64 attr_valid, u64 attr_version)
213{ 227{
@@ -447,7 +461,7 @@ static int fuse_show_options(struct seq_file *m, struct vfsmount *mnt)
447 return 0; 461 return 0;
448} 462}
449 463
450static struct fuse_conn *new_conn(void) 464static struct fuse_conn *new_conn(struct super_block *sb)
451{ 465{
452 struct fuse_conn *fc; 466 struct fuse_conn *fc;
453 int err; 467 int err;
@@ -468,19 +482,41 @@ static struct fuse_conn *new_conn(void)
468 atomic_set(&fc->num_waiting, 0); 482 atomic_set(&fc->num_waiting, 0);
469 fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE; 483 fc->bdi.ra_pages = (VM_MAX_READAHEAD * 1024) / PAGE_CACHE_SIZE;
470 fc->bdi.unplug_io_fn = default_unplug_io_fn; 484 fc->bdi.unplug_io_fn = default_unplug_io_fn;
485 /* fuse does it's own writeback accounting */
486 fc->bdi.capabilities = BDI_CAP_NO_ACCT_WB;
487 fc->dev = sb->s_dev;
471 err = bdi_init(&fc->bdi); 488 err = bdi_init(&fc->bdi);
472 if (err) { 489 if (err)
473 kfree(fc); 490 goto error_kfree;
474 fc = NULL; 491 err = bdi_register_dev(&fc->bdi, fc->dev);
475 goto out; 492 if (err)
476 } 493 goto error_bdi_destroy;
494 /*
495 * For a single fuse filesystem use max 1% of dirty +
496 * writeback threshold.
497 *
498 * This gives about 1M of write buffer for memory maps on a
499 * machine with 1G and 10% dirty_ratio, which should be more
500 * than enough.
501 *
502 * Privileged users can raise it by writing to
503 *
504 * /sys/class/bdi/<bdi>/max_ratio
505 */
506 bdi_set_max_ratio(&fc->bdi, 1);
477 fc->reqctr = 0; 507 fc->reqctr = 0;
478 fc->blocked = 1; 508 fc->blocked = 1;
479 fc->attr_version = 1; 509 fc->attr_version = 1;
480 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key)); 510 get_random_bytes(&fc->scramble_key, sizeof(fc->scramble_key));
481 } 511 }
482out:
483 return fc; 512 return fc;
513
514error_bdi_destroy:
515 bdi_destroy(&fc->bdi);
516error_kfree:
517 mutex_destroy(&fc->inst_mutex);
518 kfree(fc);
519 return NULL;
484} 520}
485 521
486void fuse_conn_put(struct fuse_conn *fc) 522void fuse_conn_put(struct fuse_conn *fc)
@@ -548,6 +584,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
548 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); 584 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
549 fc->minor = arg->minor; 585 fc->minor = arg->minor;
550 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 586 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
587 fc->max_write = min_t(unsigned, 4096, fc->max_write);
551 fc->conn_init = 1; 588 fc->conn_init = 1;
552 } 589 }
553 fuse_put_request(fc, req); 590 fuse_put_request(fc, req);
@@ -578,12 +615,6 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
578 request_send_background(fc, req); 615 request_send_background(fc, req);
579} 616}
580 617
581static u64 conn_id(void)
582{
583 static u64 ctr = 1;
584 return ctr++;
585}
586
587static int fuse_fill_super(struct super_block *sb, void *data, int silent) 618static int fuse_fill_super(struct super_block *sb, void *data, int silent)
588{ 619{
589 struct fuse_conn *fc; 620 struct fuse_conn *fc;
@@ -621,14 +652,14 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
621 if (file->f_op != &fuse_dev_operations) 652 if (file->f_op != &fuse_dev_operations)
622 return -EINVAL; 653 return -EINVAL;
623 654
624 fc = new_conn(); 655 fc = new_conn(sb);
625 if (!fc) 656 if (!fc)
626 return -ENOMEM; 657 return -ENOMEM;
627 658
628 fc->flags = d.flags; 659 fc->flags = d.flags;
629 fc->user_id = d.user_id; 660 fc->user_id = d.user_id;
630 fc->group_id = d.group_id; 661 fc->group_id = d.group_id;
631 fc->max_read = d.max_read; 662 fc->max_read = min_t(unsigned, 4096, d.max_read);
632 663
633 /* Used by get_root_inode() */ 664 /* Used by get_root_inode() */
634 sb->s_fs_info = fc; 665 sb->s_fs_info = fc;
@@ -659,7 +690,6 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
659 if (file->private_data) 690 if (file->private_data)
660 goto err_unlock; 691 goto err_unlock;
661 692
662 fc->id = conn_id();
663 err = fuse_ctl_add_conn(fc); 693 err = fuse_ctl_add_conn(fc);
664 if (err) 694 if (err)
665 goto err_unlock; 695 goto err_unlock;
diff --git a/fs/gfs2/locking/dlm/sysfs.c b/fs/gfs2/locking/dlm/sysfs.c
index 8479da47049c..a4ff271df9ee 100644
--- a/fs/gfs2/locking/dlm/sysfs.c
+++ b/fs/gfs2/locking/dlm/sysfs.c
@@ -212,7 +212,7 @@ int gdlm_sysfs_init(void)
212{ 212{
213 gdlm_kset = kset_create_and_add("lock_dlm", NULL, kernel_kobj); 213 gdlm_kset = kset_create_and_add("lock_dlm", NULL, kernel_kobj);
214 if (!gdlm_kset) { 214 if (!gdlm_kset) {
215 printk(KERN_WARNING "%s: can not create kset\n", __FUNCTION__); 215 printk(KERN_WARNING "%s: can not create kset\n", __func__);
216 return -ENOMEM; 216 return -ENOMEM;
217 } 217 }
218 return 0; 218 return 0;
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index 509c5d60bd80..7f48576289c9 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -41,7 +41,7 @@ int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
41 41
42#define gfs2_assert_withdraw(sdp, assertion) \ 42#define gfs2_assert_withdraw(sdp, assertion) \
43((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \ 43((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
44 __FUNCTION__, __FILE__, __LINE__)) 44 __func__, __FILE__, __LINE__))
45 45
46 46
47int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion, 47int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
@@ -49,28 +49,28 @@ int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
49 49
50#define gfs2_assert_warn(sdp, assertion) \ 50#define gfs2_assert_warn(sdp, assertion) \
51((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \ 51((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
52 __FUNCTION__, __FILE__, __LINE__)) 52 __func__, __FILE__, __LINE__))
53 53
54 54
55int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide, 55int gfs2_consist_i(struct gfs2_sbd *sdp, int cluster_wide,
56 const char *function, char *file, unsigned int line); 56 const char *function, char *file, unsigned int line);
57 57
58#define gfs2_consist(sdp) \ 58#define gfs2_consist(sdp) \
59gfs2_consist_i((sdp), 0, __FUNCTION__, __FILE__, __LINE__) 59gfs2_consist_i((sdp), 0, __func__, __FILE__, __LINE__)
60 60
61 61
62int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide, 62int gfs2_consist_inode_i(struct gfs2_inode *ip, int cluster_wide,
63 const char *function, char *file, unsigned int line); 63 const char *function, char *file, unsigned int line);
64 64
65#define gfs2_consist_inode(ip) \ 65#define gfs2_consist_inode(ip) \
66gfs2_consist_inode_i((ip), 0, __FUNCTION__, __FILE__, __LINE__) 66gfs2_consist_inode_i((ip), 0, __func__, __FILE__, __LINE__)
67 67
68 68
69int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide, 69int gfs2_consist_rgrpd_i(struct gfs2_rgrpd *rgd, int cluster_wide,
70 const char *function, char *file, unsigned int line); 70 const char *function, char *file, unsigned int line);
71 71
72#define gfs2_consist_rgrpd(rgd) \ 72#define gfs2_consist_rgrpd(rgd) \
73gfs2_consist_rgrpd_i((rgd), 0, __FUNCTION__, __FILE__, __LINE__) 73gfs2_consist_rgrpd_i((rgd), 0, __func__, __FILE__, __LINE__)
74 74
75 75
76int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, 76int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
@@ -91,7 +91,7 @@ static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
91} 91}
92 92
93#define gfs2_meta_check(sdp, bh) \ 93#define gfs2_meta_check(sdp, bh) \
94gfs2_meta_check_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__) 94gfs2_meta_check_i((sdp), (bh), __func__, __FILE__, __LINE__)
95 95
96 96
97int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh, 97int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
@@ -118,7 +118,7 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
118} 118}
119 119
120#define gfs2_metatype_check(sdp, bh, type) \ 120#define gfs2_metatype_check(sdp, bh, type) \
121gfs2_metatype_check_i((sdp), (bh), (type), __FUNCTION__, __FILE__, __LINE__) 121gfs2_metatype_check_i((sdp), (bh), (type), __func__, __FILE__, __LINE__)
122 122
123static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type, 123static inline void gfs2_metatype_set(struct buffer_head *bh, u16 type,
124 u16 format) 124 u16 format)
@@ -134,14 +134,14 @@ int gfs2_io_error_i(struct gfs2_sbd *sdp, const char *function,
134 char *file, unsigned int line); 134 char *file, unsigned int line);
135 135
136#define gfs2_io_error(sdp) \ 136#define gfs2_io_error(sdp) \
137gfs2_io_error_i((sdp), __FUNCTION__, __FILE__, __LINE__); 137gfs2_io_error_i((sdp), __func__, __FILE__, __LINE__);
138 138
139 139
140int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh, 140int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
141 const char *function, char *file, unsigned int line); 141 const char *function, char *file, unsigned int line);
142 142
143#define gfs2_io_error_bh(sdp, bh) \ 143#define gfs2_io_error_bh(sdp, bh) \
144gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__); 144gfs2_io_error_bh_i((sdp), (bh), __func__, __FILE__, __LINE__);
145 145
146 146
147extern struct kmem_cache *gfs2_glock_cachep; 147extern struct kmem_cache *gfs2_glock_cachep;
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 24cf6fc43021..f6621a785202 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -208,7 +208,9 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
208 struct hfs_bnode *node, *next_node; 208 struct hfs_bnode *node, *next_node;
209 struct page **pagep; 209 struct page **pagep;
210 u32 nidx, idx; 210 u32 nidx, idx;
211 u16 off, len; 211 unsigned off;
212 u16 off16;
213 u16 len;
212 u8 *data, byte, m; 214 u8 *data, byte, m;
213 int i; 215 int i;
214 216
@@ -235,7 +237,8 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
235 node = hfs_bnode_find(tree, nidx); 237 node = hfs_bnode_find(tree, nidx);
236 if (IS_ERR(node)) 238 if (IS_ERR(node))
237 return node; 239 return node;
238 len = hfs_brec_lenoff(node, 2, &off); 240 len = hfs_brec_lenoff(node, 2, &off16);
241 off = off16;
239 242
240 off += node->page_offset; 243 off += node->page_offset;
241 pagep = node->page + (off >> PAGE_CACHE_SHIFT); 244 pagep = node->page + (off >> PAGE_CACHE_SHIFT);
@@ -280,7 +283,8 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
280 return next_node; 283 return next_node;
281 node = next_node; 284 node = next_node;
282 285
283 len = hfs_brec_lenoff(node, 0, &off); 286 len = hfs_brec_lenoff(node, 0, &off16);
287 off = off16;
284 off += node->page_offset; 288 off += node->page_offset;
285 pagep = node->page + (off >> PAGE_CACHE_SHIFT); 289 pagep = node->page + (off >> PAGE_CACHE_SHIFT);
286 data = kmap(*pagep); 290 data = kmap(*pagep);
diff --git a/fs/hfs/mdb.c b/fs/hfs/mdb.c
index b4651e128d7f..36ca2e1a4fa3 100644
--- a/fs/hfs/mdb.c
+++ b/fs/hfs/mdb.c
@@ -215,7 +215,7 @@ int hfs_mdb_get(struct super_block *sb)
215 attrib &= cpu_to_be16(~HFS_SB_ATTRIB_UNMNT); 215 attrib &= cpu_to_be16(~HFS_SB_ATTRIB_UNMNT);
216 attrib |= cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT); 216 attrib |= cpu_to_be16(HFS_SB_ATTRIB_INCNSTNT);
217 mdb->drAtrb = attrib; 217 mdb->drAtrb = attrib;
218 mdb->drWrCnt = cpu_to_be32(be32_to_cpu(mdb->drWrCnt) + 1); 218 be32_add_cpu(&mdb->drWrCnt, 1);
219 mdb->drLsMod = hfs_mtime(); 219 mdb->drLsMod = hfs_mtime();
220 220
221 mark_buffer_dirty(HFS_SB(sb)->mdb_bh); 221 mark_buffer_dirty(HFS_SB(sb)->mdb_bh);
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index bb5433608a42..e49fcee1e293 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -184,7 +184,9 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
184 struct hfs_bnode *node, *next_node; 184 struct hfs_bnode *node, *next_node;
185 struct page **pagep; 185 struct page **pagep;
186 u32 nidx, idx; 186 u32 nidx, idx;
187 u16 off, len; 187 unsigned off;
188 u16 off16;
189 u16 len;
188 u8 *data, byte, m; 190 u8 *data, byte, m;
189 int i; 191 int i;
190 192
@@ -211,7 +213,8 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
211 node = hfs_bnode_find(tree, nidx); 213 node = hfs_bnode_find(tree, nidx);
212 if (IS_ERR(node)) 214 if (IS_ERR(node))
213 return node; 215 return node;
214 len = hfs_brec_lenoff(node, 2, &off); 216 len = hfs_brec_lenoff(node, 2, &off16);
217 off = off16;
215 218
216 off += node->page_offset; 219 off += node->page_offset;
217 pagep = node->page + (off >> PAGE_CACHE_SHIFT); 220 pagep = node->page + (off >> PAGE_CACHE_SHIFT);
@@ -256,7 +259,8 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
256 return next_node; 259 return next_node;
257 node = next_node; 260 node = next_node;
258 261
259 len = hfs_brec_lenoff(node, 0, &off); 262 len = hfs_brec_lenoff(node, 0, &off16);
263 off = off16;
260 off += node->page_offset; 264 off += node->page_offset;
261 pagep = node->page + (off >> PAGE_CACHE_SHIFT); 265 pagep = node->page + (off >> PAGE_CACHE_SHIFT);
262 data = kmap(*pagep); 266 data = kmap(*pagep);
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 946466cd9f25..ce97a54518d8 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -423,7 +423,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
423 */ 423 */
424 vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION); 424 vhdr->last_mount_vers = cpu_to_be32(HFSP_MOUNT_VERSION);
425 vhdr->modify_date = hfsp_now2mt(); 425 vhdr->modify_date = hfsp_now2mt();
426 vhdr->write_count = cpu_to_be32(be32_to_cpu(vhdr->write_count) + 1); 426 be32_add_cpu(&vhdr->write_count, 1);
427 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT); 427 vhdr->attributes &= cpu_to_be32(~HFSPLUS_VOL_UNMNT);
428 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT); 428 vhdr->attributes |= cpu_to_be32(HFSPLUS_VOL_INCNSTNT);
429 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh); 429 mark_buffer_dirty(HFSPLUS_SB(sb).s_vhbh);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9783723e8ffe..aeabf80f81a5 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -45,7 +45,7 @@ static const struct inode_operations hugetlbfs_inode_operations;
45 45
46static struct backing_dev_info hugetlbfs_backing_dev_info = { 46static struct backing_dev_info hugetlbfs_backing_dev_info = {
47 .ra_pages = 0, /* No readahead */ 47 .ra_pages = 0, /* No readahead */
48 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 48 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
49}; 49};
50 50
51int sysctl_hugetlb_shm_group; 51int sysctl_hugetlb_shm_group;
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c
index 1ba407c64df1..2f0dc5a14633 100644
--- a/fs/isofs/dir.c
+++ b/fs/isofs/dir.c
@@ -145,6 +145,14 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp,
145 } 145 }
146 de = tmpde; 146 de = tmpde;
147 } 147 }
148 /* Basic sanity check, whether name doesn't exceed dir entry */
149 if (de_len < de->name_len[0] +
150 sizeof(struct iso_directory_record)) {
151 printk(KERN_NOTICE "iso9660: Corrupted directory entry"
152 " in block %lu of inode %lu\n", block,
153 inode->i_ino);
154 return -EIO;
155 }
148 156
149 if (first_de) { 157 if (first_de) {
150 isofs_normalize_block_and_offset(de, 158 isofs_normalize_block_and_offset(de,
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c
index 344b247bc29a..8299889a835e 100644
--- a/fs/isofs/namei.c
+++ b/fs/isofs/namei.c
@@ -111,6 +111,13 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry,
111 111
112 dlen = de->name_len[0]; 112 dlen = de->name_len[0];
113 dpnt = de->name; 113 dpnt = de->name;
114 /* Basic sanity check, whether name doesn't exceed dir entry */
115 if (de_len < dlen + sizeof(struct iso_directory_record)) {
116 printk(KERN_NOTICE "iso9660: Corrupted directory entry"
117 " in block %lu of inode %lu\n", block,
118 dir->i_ino);
119 return 0;
120 }
114 121
115 if (sbi->s_rock && 122 if (sbi->s_rock &&
116 ((i = get_rock_ridge_filename(de, tmpname, dir)))) { 123 ((i = get_rock_ridge_filename(de, tmpname, dir)))) {
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h
index 9645275023e6..a113ecc3bafe 100644
--- a/fs/jffs2/debug.h
+++ b/fs/jffs2/debug.h
@@ -82,28 +82,28 @@
82 do { \ 82 do { \
83 printk(JFFS2_ERR_MSG_PREFIX \ 83 printk(JFFS2_ERR_MSG_PREFIX \
84 " (%d) %s: " fmt, task_pid_nr(current), \ 84 " (%d) %s: " fmt, task_pid_nr(current), \
85 __FUNCTION__ , ##__VA_ARGS__); \ 85 __func__ , ##__VA_ARGS__); \
86 } while(0) 86 } while(0)
87 87
88#define JFFS2_WARNING(fmt, ...) \ 88#define JFFS2_WARNING(fmt, ...) \
89 do { \ 89 do { \
90 printk(JFFS2_WARN_MSG_PREFIX \ 90 printk(JFFS2_WARN_MSG_PREFIX \
91 " (%d) %s: " fmt, task_pid_nr(current), \ 91 " (%d) %s: " fmt, task_pid_nr(current), \
92 __FUNCTION__ , ##__VA_ARGS__); \ 92 __func__ , ##__VA_ARGS__); \
93 } while(0) 93 } while(0)
94 94
95#define JFFS2_NOTICE(fmt, ...) \ 95#define JFFS2_NOTICE(fmt, ...) \
96 do { \ 96 do { \
97 printk(JFFS2_NOTICE_MSG_PREFIX \ 97 printk(JFFS2_NOTICE_MSG_PREFIX \
98 " (%d) %s: " fmt, task_pid_nr(current), \ 98 " (%d) %s: " fmt, task_pid_nr(current), \
99 __FUNCTION__ , ##__VA_ARGS__); \ 99 __func__ , ##__VA_ARGS__); \
100 } while(0) 100 } while(0)
101 101
102#define JFFS2_DEBUG(fmt, ...) \ 102#define JFFS2_DEBUG(fmt, ...) \
103 do { \ 103 do { \
104 printk(JFFS2_DBG_MSG_PREFIX \ 104 printk(JFFS2_DBG_MSG_PREFIX \
105 " (%d) %s: " fmt, task_pid_nr(current), \ 105 " (%d) %s: " fmt, task_pid_nr(current), \
106 __FUNCTION__ , ##__VA_ARGS__); \ 106 __func__ , ##__VA_ARGS__); \
107 } while(0) 107 } while(0)
108 108
109/* 109/*
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index e48665984cb3..574cb7532d6c 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -82,7 +82,7 @@ static int is_xattr_datum_unchecked(struct jffs2_sb_info *c, struct jffs2_xattr_
82static void unload_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd) 82static void unload_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *xd)
83{ 83{
84 /* must be called under down_write(xattr_sem) */ 84 /* must be called under down_write(xattr_sem) */
85 D1(dbg_xattr("%s: xid=%u, version=%u\n", __FUNCTION__, xd->xid, xd->version)); 85 D1(dbg_xattr("%s: xid=%u, version=%u\n", __func__, xd->xid, xd->version));
86 if (xd->xname) { 86 if (xd->xname) {
87 c->xdatum_mem_usage -= (xd->name_len + 1 + xd->value_len); 87 c->xdatum_mem_usage -= (xd->name_len + 1 + xd->value_len);
88 kfree(xd->xname); 88 kfree(xd->xname);
@@ -1252,7 +1252,7 @@ int jffs2_garbage_collect_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_
1252 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE); 1252 rc = jffs2_reserve_space_gc(c, totlen, &length, JFFS2_SUMMARY_XREF_SIZE);
1253 if (rc) { 1253 if (rc) {
1254 JFFS2_WARNING("%s: jffs2_reserve_space_gc() = %d, request = %u\n", 1254 JFFS2_WARNING("%s: jffs2_reserve_space_gc() = %d, request = %u\n",
1255 __FUNCTION__, rc, totlen); 1255 __func__, rc, totlen);
1256 rc = rc ? rc : -EBADFD; 1256 rc = rc ? rc : -EBADFD;
1257 goto out; 1257 goto out;
1258 } 1258 }
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 40b16f23e49a..5df517b81f3f 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -573,7 +573,7 @@ again:
573 /* Ensure the resulting lock will get added to granted list */ 573 /* Ensure the resulting lock will get added to granted list */
574 fl->fl_flags |= FL_SLEEP; 574 fl->fl_flags |= FL_SLEEP;
575 if (do_vfs_lock(fl) < 0) 575 if (do_vfs_lock(fl) < 0)
576 printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__); 576 printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__);
577 up_read(&host->h_rwsem); 577 up_read(&host->h_rwsem);
578 fl->fl_flags = fl_flags; 578 fl->fl_flags = fl_flags;
579 status = 0; 579 status = 0;
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 4d81553d2948..81aca859bfde 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -752,7 +752,7 @@ nlmsvc_grant_blocked(struct nlm_block *block)
752 return; 752 return;
753 default: 753 default:
754 printk(KERN_WARNING "lockd: unexpected error %d in %s!\n", 754 printk(KERN_WARNING "lockd: unexpected error %d in %s!\n",
755 -error, __FUNCTION__); 755 -error, __func__);
756 nlmsvc_insert_block(block, 10 * HZ); 756 nlmsvc_insert_block(block, 10 * HZ);
757 nlmsvc_release_block(block); 757 nlmsvc_release_block(block);
758 return; 758 return;
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c
index 2d4358c59f68..05ff4f1d7026 100644
--- a/fs/msdos/namei.c
+++ b/fs/msdos/namei.c
@@ -609,7 +609,7 @@ error_inode:
609 if (corrupt < 0) { 609 if (corrupt < 0) {
610 fat_fs_panic(new_dir->i_sb, 610 fat_fs_panic(new_dir->i_sb,
611 "%s: Filesystem corrupted (i_pos %lld)", 611 "%s: Filesystem corrupted (i_pos %lld)",
612 __FUNCTION__, sinfo.i_pos); 612 __func__, sinfo.i_pos);
613 } 613 }
614 goto out; 614 goto out;
615} 615}
diff --git a/fs/namespace.c b/fs/namespace.c
index 061e5edb4d27..4fc302c2a0e0 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2329,10 +2329,10 @@ void __init mnt_init(void)
2329 err = sysfs_init(); 2329 err = sysfs_init();
2330 if (err) 2330 if (err)
2331 printk(KERN_WARNING "%s: sysfs_init error: %d\n", 2331 printk(KERN_WARNING "%s: sysfs_init error: %d\n",
2332 __FUNCTION__, err); 2332 __func__, err);
2333 fs_kobj = kobject_create_and_add("fs", NULL); 2333 fs_kobj = kobject_create_and_add("fs", NULL);
2334 if (!fs_kobj) 2334 if (!fs_kobj)
2335 printk(KERN_WARNING "%s: kobj create error\n", __FUNCTION__); 2335 printk(KERN_WARNING "%s: kobj create error\n", __func__);
2336 init_rootfs(); 2336 init_rootfs();
2337 init_mount_tree(); 2337 init_mount_tree();
2338} 2338}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index fa220dc74609..7226a506f3ca 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1575,6 +1575,11 @@ static int nfs_compare_super(struct super_block *sb, void *data)
1575 return nfs_compare_mount_options(sb, server, mntflags); 1575 return nfs_compare_mount_options(sb, server, mntflags);
1576} 1576}
1577 1577
1578static int nfs_bdi_register(struct nfs_server *server)
1579{
1580 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
1581}
1582
1578static int nfs_get_sb(struct file_system_type *fs_type, 1583static int nfs_get_sb(struct file_system_type *fs_type,
1579 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) 1584 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt)
1580{ 1585{
@@ -1617,6 +1622,10 @@ static int nfs_get_sb(struct file_system_type *fs_type,
1617 if (s->s_fs_info != server) { 1622 if (s->s_fs_info != server) {
1618 nfs_free_server(server); 1623 nfs_free_server(server);
1619 server = NULL; 1624 server = NULL;
1625 } else {
1626 error = nfs_bdi_register(server);
1627 if (error)
1628 goto error_splat_super;
1620 } 1629 }
1621 1630
1622 if (!s->s_root) { 1631 if (!s->s_root) {
@@ -1664,6 +1673,7 @@ static void nfs_kill_super(struct super_block *s)
1664{ 1673{
1665 struct nfs_server *server = NFS_SB(s); 1674 struct nfs_server *server = NFS_SB(s);
1666 1675
1676 bdi_unregister(&server->backing_dev_info);
1667 kill_anon_super(s); 1677 kill_anon_super(s);
1668 nfs_free_server(server); 1678 nfs_free_server(server);
1669} 1679}
@@ -1708,6 +1718,10 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
1708 if (s->s_fs_info != server) { 1718 if (s->s_fs_info != server) {
1709 nfs_free_server(server); 1719 nfs_free_server(server);
1710 server = NULL; 1720 server = NULL;
1721 } else {
1722 error = nfs_bdi_register(server);
1723 if (error)
1724 goto error_splat_super;
1711 } 1725 }
1712 1726
1713 if (!s->s_root) { 1727 if (!s->s_root) {
@@ -1984,6 +1998,10 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
1984 if (s->s_fs_info != server) { 1998 if (s->s_fs_info != server) {
1985 nfs_free_server(server); 1999 nfs_free_server(server);
1986 server = NULL; 2000 server = NULL;
2001 } else {
2002 error = nfs_bdi_register(server);
2003 if (error)
2004 goto error_splat_super;
1987 } 2005 }
1988 2006
1989 if (!s->s_root) { 2007 if (!s->s_root) {
@@ -2070,6 +2088,10 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2070 if (s->s_fs_info != server) { 2088 if (s->s_fs_info != server) {
2071 nfs_free_server(server); 2089 nfs_free_server(server);
2072 server = NULL; 2090 server = NULL;
2091 } else {
2092 error = nfs_bdi_register(server);
2093 if (error)
2094 goto error_splat_super;
2073 } 2095 }
2074 2096
2075 if (!s->s_root) { 2097 if (!s->s_root) {
@@ -2149,6 +2171,10 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
2149 if (s->s_fs_info != server) { 2171 if (s->s_fs_info != server) {
2150 nfs_free_server(server); 2172 nfs_free_server(server);
2151 server = NULL; 2173 server = NULL;
2174 } else {
2175 error = nfs_bdi_register(server);
2176 if (error)
2177 goto error_splat_super;
2152 } 2178 }
2153 2179
2154 if (!s->s_root) { 2180 if (!s->s_root) {
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index 562abf3380d0..0b3ffa9840c2 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -104,7 +104,7 @@ xdr_writemem(__be32 *p, const void *ptr, int nbytes)
104} while (0) 104} while (0)
105#define RESERVE_SPACE(nbytes) do { \ 105#define RESERVE_SPACE(nbytes) do { \
106 p = xdr_reserve_space(xdr, nbytes); \ 106 p = xdr_reserve_space(xdr, nbytes); \
107 if (!p) dprintk("NFSD: RESERVE_SPACE(%d) failed in function %s\n", (int) (nbytes), __FUNCTION__); \ 107 if (!p) dprintk("NFSD: RESERVE_SPACE(%d) failed in function %s\n", (int) (nbytes), __func__); \
108 BUG_ON(!p); \ 108 BUG_ON(!p); \
109} while (0) 109} while (0)
110 110
@@ -134,7 +134,7 @@ xdr_error: \
134 p = xdr_inline_decode(xdr, nbytes); \ 134 p = xdr_inline_decode(xdr, nbytes); \
135 if (!p) { \ 135 if (!p) { \
136 dprintk("NFSD: %s: reply buffer overflowed in line %d.\n", \ 136 dprintk("NFSD: %s: reply buffer overflowed in line %d.\n", \
137 __FUNCTION__, __LINE__); \ 137 __func__, __LINE__); \
138 return -EIO; \ 138 return -EIO; \
139 } \ 139 } \
140} while (0) 140} while (0)
diff --git a/fs/ntfs/debug.h b/fs/ntfs/debug.h
index 8ac37c33d127..5e6724c1afd1 100644
--- a/fs/ntfs/debug.h
+++ b/fs/ntfs/debug.h
@@ -45,7 +45,7 @@ static void ntfs_debug(const char *f, ...);
45extern void __ntfs_debug (const char *file, int line, const char *function, 45extern void __ntfs_debug (const char *file, int line, const char *function,
46 const char *format, ...) __attribute__ ((format (printf, 4, 5))); 46 const char *format, ...) __attribute__ ((format (printf, 4, 5)));
47#define ntfs_debug(f, a...) \ 47#define ntfs_debug(f, a...) \
48 __ntfs_debug(__FILE__, __LINE__, __FUNCTION__, f, ##a) 48 __ntfs_debug(__FILE__, __LINE__, __func__, f, ##a)
49 49
50extern void ntfs_debug_dump_runlist(const runlist_element *rl); 50extern void ntfs_debug_dump_runlist(const runlist_element *rl);
51 51
@@ -58,10 +58,10 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl);
58 58
59extern void __ntfs_warning(const char *function, const struct super_block *sb, 59extern void __ntfs_warning(const char *function, const struct super_block *sb,
60 const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); 60 const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
61#define ntfs_warning(sb, f, a...) __ntfs_warning(__FUNCTION__, sb, f, ##a) 61#define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a)
62 62
63extern void __ntfs_error(const char *function, const struct super_block *sb, 63extern void __ntfs_error(const char *function, const struct super_block *sb,
64 const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); 64 const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
65#define ntfs_error(sb, f, a...) __ntfs_error(__FUNCTION__, sb, f, ##a) 65#define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a)
66 66
67#endif /* _LINUX_NTFS_DEBUG_H */ 67#endif /* _LINUX_NTFS_DEBUG_H */
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 61a000f8524c..e48aba698b77 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -327,7 +327,7 @@ clear_fields:
327 327
328static struct backing_dev_info dlmfs_backing_dev_info = { 328static struct backing_dev_info dlmfs_backing_dev_info = {
329 .ra_pages = 0, /* No readahead */ 329 .ra_pages = 0, /* No readahead */
330 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 330 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
331}; 331};
332 332
333static struct inode *dlmfs_get_root_inode(struct super_block *sb) 333static struct inode *dlmfs_get_root_inode(struct super_block *sb)
diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c
index e7dd1d4e3473..0fdda2e8a4cc 100644
--- a/fs/partitions/ldm.c
+++ b/fs/partitions/ldm.c
@@ -41,12 +41,12 @@
41#ifndef CONFIG_LDM_DEBUG 41#ifndef CONFIG_LDM_DEBUG
42#define ldm_debug(...) do {} while (0) 42#define ldm_debug(...) do {} while (0)
43#else 43#else
44#define ldm_debug(f, a...) _ldm_printk (KERN_DEBUG, __FUNCTION__, f, ##a) 44#define ldm_debug(f, a...) _ldm_printk (KERN_DEBUG, __func__, f, ##a)
45#endif 45#endif
46 46
47#define ldm_crit(f, a...) _ldm_printk (KERN_CRIT, __FUNCTION__, f, ##a) 47#define ldm_crit(f, a...) _ldm_printk (KERN_CRIT, __func__, f, ##a)
48#define ldm_error(f, a...) _ldm_printk (KERN_ERR, __FUNCTION__, f, ##a) 48#define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a)
49#define ldm_info(f, a...) _ldm_printk (KERN_INFO, __FUNCTION__, f, ##a) 49#define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a)
50 50
51__attribute__ ((format (printf, 3, 4))) 51__attribute__ ((format (printf, 3, 4)))
52static void _ldm_printk (const char *level, const char *function, 52static void _ldm_printk (const char *level, const char *function,
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 07d6c4853fe8..c135cbdd9127 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -425,12 +425,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
425 cutime = cstime = utime = stime = cputime_zero; 425 cutime = cstime = utime = stime = cputime_zero;
426 cgtime = gtime = cputime_zero; 426 cgtime = gtime = cputime_zero;
427 427
428 rcu_read_lock();
429 if (lock_task_sighand(task, &flags)) { 428 if (lock_task_sighand(task, &flags)) {
430 struct signal_struct *sig = task->signal; 429 struct signal_struct *sig = task->signal;
431 430
432 if (sig->tty) { 431 if (sig->tty) {
433 tty_pgrp = pid_nr_ns(sig->tty->pgrp, ns); 432 struct pid *pgrp = tty_get_pgrp(sig->tty);
433 tty_pgrp = pid_nr_ns(pgrp, ns);
434 put_pid(pgrp);
434 tty_nr = new_encode_dev(tty_devnum(sig->tty)); 435 tty_nr = new_encode_dev(tty_devnum(sig->tty));
435 } 436 }
436 437
@@ -469,7 +470,6 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
469 470
470 unlock_task_sighand(task, &flags); 471 unlock_task_sighand(task, &flags);
471 } 472 }
472 rcu_read_unlock();
473 473
474 if (!whole || num_threads < 2) 474 if (!whole || num_threads < 2)
475 wchan = get_wchan(task); 475 wchan = get_wchan(task);
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 48bcf20cec2f..74a323d2b850 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -179,6 +179,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
179 "PageTables: %8lu kB\n" 179 "PageTables: %8lu kB\n"
180 "NFS_Unstable: %8lu kB\n" 180 "NFS_Unstable: %8lu kB\n"
181 "Bounce: %8lu kB\n" 181 "Bounce: %8lu kB\n"
182 "WritebackTmp: %8lu kB\n"
182 "CommitLimit: %8lu kB\n" 183 "CommitLimit: %8lu kB\n"
183 "Committed_AS: %8lu kB\n" 184 "Committed_AS: %8lu kB\n"
184 "VmallocTotal: %8lu kB\n" 185 "VmallocTotal: %8lu kB\n"
@@ -210,6 +211,7 @@ static int meminfo_read_proc(char *page, char **start, off_t off,
210 K(global_page_state(NR_PAGETABLE)), 211 K(global_page_state(NR_PAGETABLE)),
211 K(global_page_state(NR_UNSTABLE_NFS)), 212 K(global_page_state(NR_UNSTABLE_NFS)),
212 K(global_page_state(NR_BOUNCE)), 213 K(global_page_state(NR_BOUNCE)),
214 K(global_page_state(NR_WRITEBACK_TEMP)),
213 K(allowed), 215 K(allowed),
214 K(committed), 216 K(committed),
215 (unsigned long)VMALLOC_TOTAL >> 10, 217 (unsigned long)VMALLOC_TOTAL >> 10,
diff --git a/fs/proc/proc_tty.c b/fs/proc/proc_tty.c
index ac26ccc25f42..21f490f5d65c 100644
--- a/fs/proc/proc_tty.c
+++ b/fs/proc/proc_tty.c
@@ -192,16 +192,14 @@ void proc_tty_register_driver(struct tty_driver *driver)
192{ 192{
193 struct proc_dir_entry *ent; 193 struct proc_dir_entry *ent;
194 194
195 if ((!driver->read_proc && !driver->write_proc) || 195 if (!driver->ops->read_proc || !driver->driver_name ||
196 !driver->driver_name ||
197 driver->proc_entry) 196 driver->proc_entry)
198 return; 197 return;
199 198
200 ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver); 199 ent = create_proc_entry(driver->driver_name, 0, proc_tty_driver);
201 if (!ent) 200 if (!ent)
202 return; 201 return;
203 ent->read_proc = driver->read_proc; 202 ent->read_proc = driver->ops->read_proc;
204 ent->write_proc = driver->write_proc;
205 ent->owner = driver->owner; 203 ent->owner = driver->owner;
206 ent->data = driver; 204 ent->data = driver;
207 205
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index 23b647f25d08..234ada903633 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -306,7 +306,7 @@ static uint find_free_dqentry(struct dquot *dquot, int *err)
306 printk(KERN_ERR "VFS: find_free_dqentry(): Can't remove block (%u) from entry free list.\n", blk); 306 printk(KERN_ERR "VFS: find_free_dqentry(): Can't remove block (%u) from entry free list.\n", blk);
307 goto out_buf; 307 goto out_buf;
308 } 308 }
309 dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)+1); 309 le16_add_cpu(&dh->dqdh_entries, 1);
310 memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk)); 310 memset(&fakedquot, 0, sizeof(struct v2_disk_dqblk));
311 /* Find free structure in block */ 311 /* Find free structure in block */
312 for (i = 0; i < V2_DQSTRINBLK && memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)); i++); 312 for (i = 0; i < V2_DQSTRINBLK && memcmp(&fakedquot, ddquot+i, sizeof(struct v2_disk_dqblk)); i++);
@@ -448,7 +448,7 @@ static int free_dqentry(struct dquot *dquot, uint blk)
448 goto out_buf; 448 goto out_buf;
449 } 449 }
450 dh = (struct v2_disk_dqdbheader *)buf; 450 dh = (struct v2_disk_dqdbheader *)buf;
451 dh->dqdh_entries = cpu_to_le16(le16_to_cpu(dh->dqdh_entries)-1); 451 le16_add_cpu(&dh->dqdh_entries, -1);
452 if (!le16_to_cpu(dh->dqdh_entries)) { /* Block got free? */ 452 if (!le16_to_cpu(dh->dqdh_entries)) { /* Block got free? */
453 if ((ret = remove_free_dqentry(sb, type, buf, blk)) < 0 || 453 if ((ret = remove_free_dqentry(sb, type, buf, blk)) < 0 ||
454 (ret = put_free_dqblk(sb, type, buf, blk)) < 0) { 454 (ret = put_free_dqblk(sb, type, buf, blk)) < 0) {
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 8428d5b2711d..b13123424e49 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -44,7 +44,7 @@ static const struct inode_operations ramfs_dir_inode_operations;
44 44
45static struct backing_dev_info ramfs_backing_dev_info = { 45static struct backing_dev_info ramfs_backing_dev_info = {
46 .ra_pages = 0, /* No readahead */ 46 .ra_pages = 0, /* No readahead */
47 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK | 47 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK |
48 BDI_CAP_MAP_DIRECT | BDI_CAP_MAP_COPY | 48 BDI_CAP_MAP_DIRECT | BDI_CAP_MAP_COPY |
49 BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP, 49 BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP,
50}; 50};
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index da86042b3e03..e396b2fa4743 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2574,11 +2574,9 @@ static int release_journal_dev(struct super_block *super,
2574 2574
2575 result = 0; 2575 result = 0;
2576 2576
2577 if (journal->j_dev_file != NULL) { 2577 if (journal->j_dev_bd != NULL) {
2578 result = filp_close(journal->j_dev_file, NULL); 2578 if (journal->j_dev_bd->bd_dev != super->s_dev)
2579 journal->j_dev_file = NULL; 2579 bd_release(journal->j_dev_bd);
2580 journal->j_dev_bd = NULL;
2581 } else if (journal->j_dev_bd != NULL) {
2582 result = blkdev_put(journal->j_dev_bd); 2580 result = blkdev_put(journal->j_dev_bd);
2583 journal->j_dev_bd = NULL; 2581 journal->j_dev_bd = NULL;
2584 } 2582 }
@@ -2603,7 +2601,6 @@ static int journal_init_dev(struct super_block *super,
2603 result = 0; 2601 result = 0;
2604 2602
2605 journal->j_dev_bd = NULL; 2603 journal->j_dev_bd = NULL;
2606 journal->j_dev_file = NULL;
2607 jdev = SB_ONDISK_JOURNAL_DEVICE(super) ? 2604 jdev = SB_ONDISK_JOURNAL_DEVICE(super) ?
2608 new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev; 2605 new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev;
2609 2606
@@ -2620,35 +2617,34 @@ static int journal_init_dev(struct super_block *super,
2620 "cannot init journal device '%s': %i", 2617 "cannot init journal device '%s': %i",
2621 __bdevname(jdev, b), result); 2618 __bdevname(jdev, b), result);
2622 return result; 2619 return result;
2623 } else if (jdev != super->s_dev) 2620 } else if (jdev != super->s_dev) {
2621 result = bd_claim(journal->j_dev_bd, journal);
2622 if (result) {
2623 blkdev_put(journal->j_dev_bd);
2624 return result;
2625 }
2626
2624 set_blocksize(journal->j_dev_bd, super->s_blocksize); 2627 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2628 }
2629
2625 return 0; 2630 return 0;
2626 } 2631 }
2627 2632
2628 journal->j_dev_file = filp_open(jdev_name, 0, 0); 2633 journal->j_dev_bd = open_bdev_excl(jdev_name, 0, journal);
2629 if (!IS_ERR(journal->j_dev_file)) { 2634 if (IS_ERR(journal->j_dev_bd)) {
2630 struct inode *jdev_inode = journal->j_dev_file->f_mapping->host; 2635 result = PTR_ERR(journal->j_dev_bd);
2631 if (!S_ISBLK(jdev_inode->i_mode)) { 2636 journal->j_dev_bd = NULL;
2632 reiserfs_warning(super, "journal_init_dev: '%s' is "
2633 "not a block device", jdev_name);
2634 result = -ENOTBLK;
2635 release_journal_dev(super, journal);
2636 } else {
2637 /* ok */
2638 journal->j_dev_bd = I_BDEV(jdev_inode);
2639 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2640 reiserfs_info(super,
2641 "journal_init_dev: journal device: %s\n",
2642 bdevname(journal->j_dev_bd, b));
2643 }
2644 } else {
2645 result = PTR_ERR(journal->j_dev_file);
2646 journal->j_dev_file = NULL;
2647 reiserfs_warning(super, 2637 reiserfs_warning(super,
2648 "journal_init_dev: Cannot open '%s': %i", 2638 "journal_init_dev: Cannot open '%s': %i",
2649 jdev_name, result); 2639 jdev_name, result);
2640 return result;
2650 } 2641 }
2651 return result; 2642
2643 set_blocksize(journal->j_dev_bd, super->s_blocksize);
2644 reiserfs_info(super,
2645 "journal_init_dev: journal device: %s\n",
2646 bdevname(journal->j_dev_bd, b));
2647 return 0;
2652} 2648}
2653 2649
2654/** 2650/**
diff --git a/fs/select.c b/fs/select.c
index 00f58c5c7e05..2c292146e246 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -425,7 +425,7 @@ sticky:
425 return ret; 425 return ret;
426} 426}
427 427
428#ifdef TIF_RESTORE_SIGMASK 428#ifdef HAVE_SET_RESTORE_SIGMASK
429asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp, 429asmlinkage long sys_pselect7(int n, fd_set __user *inp, fd_set __user *outp,
430 fd_set __user *exp, struct timespec __user *tsp, 430 fd_set __user *exp, struct timespec __user *tsp,
431 const sigset_t __user *sigmask, size_t sigsetsize) 431 const sigset_t __user *sigmask, size_t sigsetsize)
@@ -498,7 +498,7 @@ sticky:
498 if (sigmask) { 498 if (sigmask) {
499 memcpy(&current->saved_sigmask, &sigsaved, 499 memcpy(&current->saved_sigmask, &sigsaved,
500 sizeof(sigsaved)); 500 sizeof(sigsaved));
501 set_thread_flag(TIF_RESTORE_SIGMASK); 501 set_restore_sigmask();
502 } 502 }
503 } else if (sigmask) 503 } else if (sigmask)
504 sigprocmask(SIG_SETMASK, &sigsaved, NULL); 504 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
@@ -528,7 +528,7 @@ asmlinkage long sys_pselect6(int n, fd_set __user *inp, fd_set __user *outp,
528 528
529 return sys_pselect7(n, inp, outp, exp, tsp, up, sigsetsize); 529 return sys_pselect7(n, inp, outp, exp, tsp, up, sigsetsize);
530} 530}
531#endif /* TIF_RESTORE_SIGMASK */ 531#endif /* HAVE_SET_RESTORE_SIGMASK */
532 532
533struct poll_list { 533struct poll_list {
534 struct poll_list *next; 534 struct poll_list *next;
@@ -759,7 +759,7 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
759 return ret; 759 return ret;
760} 760}
761 761
762#ifdef TIF_RESTORE_SIGMASK 762#ifdef HAVE_SET_RESTORE_SIGMASK
763asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds, 763asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
764 struct timespec __user *tsp, const sigset_t __user *sigmask, 764 struct timespec __user *tsp, const sigset_t __user *sigmask,
765 size_t sigsetsize) 765 size_t sigsetsize)
@@ -805,7 +805,7 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
805 if (sigmask) { 805 if (sigmask) {
806 memcpy(&current->saved_sigmask, &sigsaved, 806 memcpy(&current->saved_sigmask, &sigsaved,
807 sizeof(sigsaved)); 807 sizeof(sigsaved));
808 set_thread_flag(TIF_RESTORE_SIGMASK); 808 set_restore_sigmask();
809 } 809 }
810 ret = -ERESTARTNOHAND; 810 ret = -ERESTARTNOHAND;
811 } else if (sigmask) 811 } else if (sigmask)
@@ -839,4 +839,4 @@ asmlinkage long sys_ppoll(struct pollfd __user *ufds, unsigned int nfds,
839 839
840 return ret; 840 return ret;
841} 841}
842#endif /* TIF_RESTORE_SIGMASK */ 842#endif /* HAVE_SET_RESTORE_SIGMASK */
diff --git a/fs/smbfs/smb_debug.h b/fs/smbfs/smb_debug.h
index 734972b92694..fc4b1a5dd755 100644
--- a/fs/smbfs/smb_debug.h
+++ b/fs/smbfs/smb_debug.h
@@ -11,14 +11,14 @@
11 * these are normally enabled. 11 * these are normally enabled.
12 */ 12 */
13#ifdef SMBFS_PARANOIA 13#ifdef SMBFS_PARANOIA
14# define PARANOIA(f, a...) printk(KERN_NOTICE "%s: " f, __FUNCTION__ , ## a) 14# define PARANOIA(f, a...) printk(KERN_NOTICE "%s: " f, __func__ , ## a)
15#else 15#else
16# define PARANOIA(f, a...) do { ; } while(0) 16# define PARANOIA(f, a...) do { ; } while(0)
17#endif 17#endif
18 18
19/* lots of debug messages */ 19/* lots of debug messages */
20#ifdef SMBFS_DEBUG_VERBOSE 20#ifdef SMBFS_DEBUG_VERBOSE
21# define VERBOSE(f, a...) printk(KERN_DEBUG "%s: " f, __FUNCTION__ , ## a) 21# define VERBOSE(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a)
22#else 22#else
23# define VERBOSE(f, a...) do { ; } while(0) 23# define VERBOSE(f, a...) do { ; } while(0)
24#endif 24#endif
@@ -28,7 +28,7 @@
28 * too common name. 28 * too common name.
29 */ 29 */
30#ifdef SMBFS_DEBUG 30#ifdef SMBFS_DEBUG
31#define DEBUG1(f, a...) printk(KERN_DEBUG "%s: " f, __FUNCTION__ , ## a) 31#define DEBUG1(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a)
32#else 32#else
33#define DEBUG1(f, a...) do { ; } while(0) 33#define DEBUG1(f, a...) do { ; } while(0)
34#endif 34#endif
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index dbdfabbfd609..e7735f643cd1 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -135,7 +135,7 @@ sysfs_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos)
135 goto out; 135 goto out;
136 } 136 }
137 pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n", 137 pr_debug("%s: count = %zd, ppos = %lld, buf = %s\n",
138 __FUNCTION__, count, *ppos, buffer->page); 138 __func__, count, *ppos, buffer->page);
139 retval = simple_read_from_buffer(buf, count, ppos, buffer->page, 139 retval = simple_read_from_buffer(buf, count, ppos, buffer->page,
140 buffer->count); 140 buffer->count);
141out: 141out:
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index d9262f74f94e..f8b82e73b3bf 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -30,7 +30,7 @@ static const struct address_space_operations sysfs_aops = {
30 30
31static struct backing_dev_info sysfs_backing_dev_info = { 31static struct backing_dev_info sysfs_backing_dev_info = {
32 .ra_pages = 0, /* No readahead */ 32 .ra_pages = 0, /* No readahead */
33 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 33 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
34}; 34};
35 35
36static const struct inode_operations sysfs_inode_operations ={ 36static const struct inode_operations sysfs_inode_operations ={
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 74168266cd59..14f0023984d7 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -61,7 +61,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
61 /* instantiate and link root dentry */ 61 /* instantiate and link root dentry */
62 root = d_alloc_root(inode); 62 root = d_alloc_root(inode);
63 if (!root) { 63 if (!root) {
64 pr_debug("%s: could not get root dentry!\n",__FUNCTION__); 64 pr_debug("%s: could not get root dentry!\n",__func__);
65 iput(inode); 65 iput(inode);
66 return -ENOMEM; 66 return -ENOMEM;
67 } 67 }
diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
index 42d51d1c05cd..38ebe3f85b3d 100644
--- a/fs/sysv/sysv.h
+++ b/fs/sysv/sysv.h
@@ -217,9 +217,9 @@ static inline __fs32 fs32_add(struct sysv_sb_info *sbi, __fs32 *n, int d)
217 if (sbi->s_bytesex == BYTESEX_PDP) 217 if (sbi->s_bytesex == BYTESEX_PDP)
218 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d); 218 *(__u32*)n = PDP_swab(PDP_swab(*(__u32*)n)+d);
219 else if (sbi->s_bytesex == BYTESEX_LE) 219 else if (sbi->s_bytesex == BYTESEX_LE)
220 *(__le32*)n = cpu_to_le32(le32_to_cpu(*(__le32*)n)+d); 220 le32_add_cpu((__le32 *)n, d);
221 else 221 else
222 *(__be32*)n = cpu_to_be32(be32_to_cpu(*(__be32*)n)+d); 222 be32_add_cpu((__be32 *)n, d);
223 return *n; 223 return *n;
224} 224}
225 225
@@ -242,9 +242,9 @@ static inline __fs16 cpu_to_fs16(struct sysv_sb_info *sbi, __u16 n)
242static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d) 242static inline __fs16 fs16_add(struct sysv_sb_info *sbi, __fs16 *n, int d)
243{ 243{
244 if (sbi->s_bytesex != BYTESEX_BE) 244 if (sbi->s_bytesex != BYTESEX_BE)
245 *(__le16*)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)+d); 245 le16_add_cpu((__le16 *)n, d);
246 else 246 else
247 *(__be16*)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)+d); 247 be16_add_cpu((__be16 *)n, d);
248 return *n; 248 return *n;
249} 249}
250 250
diff --git a/fs/udf/super.c b/fs/udf/super.c
index b564fc140fe4..9fb18a340fc1 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -240,7 +240,7 @@ static int udf_sb_alloc_partition_maps(struct super_block *sb, u32 count)
240 sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map), 240 sbi->s_partmaps = kcalloc(count, sizeof(struct udf_part_map),
241 GFP_KERNEL); 241 GFP_KERNEL);
242 if (!sbi->s_partmaps) { 242 if (!sbi->s_partmaps) {
243 udf_error(sb, __FUNCTION__, 243 udf_error(sb, __func__,
244 "Unable to allocate space for %d partition maps", 244 "Unable to allocate space for %d partition maps",
245 count); 245 count);
246 sbi->s_partitions = 0; 246 sbi->s_partitions = 0;
@@ -1086,7 +1086,7 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
1086 bitmap = vmalloc(size); /* TODO: get rid of vmalloc */ 1086 bitmap = vmalloc(size); /* TODO: get rid of vmalloc */
1087 1087
1088 if (bitmap == NULL) { 1088 if (bitmap == NULL) {
1089 udf_error(sb, __FUNCTION__, 1089 udf_error(sb, __func__,
1090 "Unable to allocate space for bitmap " 1090 "Unable to allocate space for bitmap "
1091 "and %d buffer_head pointers", nr_groups); 1091 "and %d buffer_head pointers", nr_groups);
1092 return NULL; 1092 return NULL;
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c
index 5b66162d0747..a3522727ea5b 100644
--- a/fs/vfat/namei.c
+++ b/fs/vfat/namei.c
@@ -986,7 +986,7 @@ error_inode:
986 if (corrupt < 0) { 986 if (corrupt < 0) {
987 fat_fs_panic(new_dir->i_sb, 987 fat_fs_panic(new_dir->i_sb,
988 "%s: Filesystem corrupted (i_pos %lld)", 988 "%s: Filesystem corrupted (i_pos %lld)",
989 __FUNCTION__, sinfo.i_pos); 989 __func__, sinfo.i_pos);
990 } 990 }
991 goto out; 991 goto out;
992} 992}
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 1bc9f600365f..4edc46915b57 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -75,6 +75,7 @@
75#include <linux/delay.h> 75#include <linux/delay.h>
76#include <linux/log2.h> 76#include <linux/log2.h>
77#include <linux/spinlock.h> 77#include <linux/spinlock.h>
78#include <linux/random.h>
78 79
79#include <asm/page.h> 80#include <asm/page.h>
80#include <asm/div64.h> 81#include <asm/div64.h>
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h
index 855da0408647..75845f950814 100644
--- a/fs/xfs/support/debug.h
+++ b/fs/xfs/support/debug.h
@@ -49,8 +49,6 @@ extern void assfail(char *expr, char *f, int l);
49 49
50#else /* DEBUG */ 50#else /* DEBUG */
51 51
52#include <linux/random.h>
53
54#define ASSERT(expr) \ 52#define ASSERT(expr) \
55 (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) 53 (unlikely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__))
56 54
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index a322012f16ac..4b2ea1e95c57 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -1406,202 +1406,6 @@
1406#define OSCC_OON (1 << 1) /* 32.768kHz OON (write-once only bit) */ 1406#define OSCC_OON (1 << 1) /* 32.768kHz OON (write-once only bit) */
1407#define OSCC_OOK (1 << 0) /* 32.768kHz OOK (read-only bit) */ 1407#define OSCC_OOK (1 << 0) /* 32.768kHz OOK (read-only bit) */
1408 1408
1409
1410/*
1411 * LCD
1412 */
1413
1414#define LCCR0 __REG(0x44000000) /* LCD Controller Control Register 0 */
1415#define LCCR1 __REG(0x44000004) /* LCD Controller Control Register 1 */
1416#define LCCR2 __REG(0x44000008) /* LCD Controller Control Register 2 */
1417#define LCCR3 __REG(0x4400000C) /* LCD Controller Control Register 3 */
1418#define LCCR4 __REG(0x44000010) /* LCD Controller Control Register 3 */
1419#define DFBR0 __REG(0x44000020) /* DMA Channel 0 Frame Branch Register */
1420#define DFBR1 __REG(0x44000024) /* DMA Channel 1 Frame Branch Register */
1421#define LCSR __REG(0x44000038) /* LCD Controller Status Register */
1422#define LIIDR __REG(0x4400003C) /* LCD Controller Interrupt ID Register */
1423#define TMEDRGBR __REG(0x44000040) /* TMED RGB Seed Register */
1424#define TMEDCR __REG(0x44000044) /* TMED Control Register */
1425
1426#define LCCR3_1BPP (0 << 24)
1427#define LCCR3_2BPP (1 << 24)
1428#define LCCR3_4BPP (2 << 24)
1429#define LCCR3_8BPP (3 << 24)
1430#define LCCR3_16BPP (4 << 24)
1431
1432#define LCCR3_PDFOR_0 (0 << 30)
1433#define LCCR3_PDFOR_1 (1 << 30)
1434#define LCCR3_PDFOR_2 (2 << 30)
1435#define LCCR3_PDFOR_3 (3 << 30)
1436
1437#define LCCR4_PAL_FOR_0 (0 << 15)
1438#define LCCR4_PAL_FOR_1 (1 << 15)
1439#define LCCR4_PAL_FOR_2 (2 << 15)
1440#define LCCR4_PAL_FOR_MASK (3 << 15)
1441
1442#define FDADR0 __REG(0x44000200) /* DMA Channel 0 Frame Descriptor Address Register */
1443#define FSADR0 __REG(0x44000204) /* DMA Channel 0 Frame Source Address Register */
1444#define FIDR0 __REG(0x44000208) /* DMA Channel 0 Frame ID Register */
1445#define LDCMD0 __REG(0x4400020C) /* DMA Channel 0 Command Register */
1446#define FDADR1 __REG(0x44000210) /* DMA Channel 1 Frame Descriptor Address Register */
1447#define FSADR1 __REG(0x44000214) /* DMA Channel 1 Frame Source Address Register */
1448#define FIDR1 __REG(0x44000218) /* DMA Channel 1 Frame ID Register */
1449#define LDCMD1 __REG(0x4400021C) /* DMA Channel 1 Command Register */
1450
1451#define LCCR0_ENB (1 << 0) /* LCD Controller enable */
1452#define LCCR0_CMS (1 << 1) /* Color/Monochrome Display Select */
1453#define LCCR0_Color (LCCR0_CMS*0) /* Color display */
1454#define LCCR0_Mono (LCCR0_CMS*1) /* Monochrome display */
1455#define LCCR0_SDS (1 << 2) /* Single/Dual Panel Display */
1456 /* Select */
1457#define LCCR0_Sngl (LCCR0_SDS*0) /* Single panel display */
1458#define LCCR0_Dual (LCCR0_SDS*1) /* Dual panel display */
1459
1460#define LCCR0_LDM (1 << 3) /* LCD Disable Done Mask */
1461#define LCCR0_SFM (1 << 4) /* Start of frame mask */
1462#define LCCR0_IUM (1 << 5) /* Input FIFO underrun mask */
1463#define LCCR0_EFM (1 << 6) /* End of Frame mask */
1464#define LCCR0_PAS (1 << 7) /* Passive/Active display Select */
1465#define LCCR0_Pas (LCCR0_PAS*0) /* Passive display (STN) */
1466#define LCCR0_Act (LCCR0_PAS*1) /* Active display (TFT) */
1467#define LCCR0_DPD (1 << 9) /* Double Pixel Data (monochrome */
1468 /* display mode) */
1469#define LCCR0_4PixMono (LCCR0_DPD*0) /* 4-Pixel/clock Monochrome */
1470 /* display */
1471#define LCCR0_8PixMono (LCCR0_DPD*1) /* 8-Pixel/clock Monochrome */
1472 /* display */
1473#define LCCR0_DIS (1 << 10) /* LCD Disable */
1474#define LCCR0_QDM (1 << 11) /* LCD Quick Disable mask */
1475#define LCCR0_PDD (0xff << 12) /* Palette DMA request delay */
1476#define LCCR0_PDD_S 12
1477#define LCCR0_BM (1 << 20) /* Branch mask */
1478#define LCCR0_OUM (1 << 21) /* Output FIFO underrun mask */
1479#define LCCR0_LCDT (1 << 22) /* LCD panel type */
1480#define LCCR0_RDSTM (1 << 23) /* Read status interrupt mask */
1481#define LCCR0_CMDIM (1 << 24) /* Command interrupt mask */
1482#define LCCR0_OUC (1 << 25) /* Overlay Underlay control bit */
1483#define LCCR0_LDDALT (1 << 26) /* LDD alternate mapping control */
1484
1485#define LCCR1_PPL Fld (10, 0) /* Pixels Per Line - 1 */
1486#define LCCR1_DisWdth(Pixel) /* Display Width [1..800 pix.] */ \
1487 (((Pixel) - 1) << FShft (LCCR1_PPL))
1488
1489#define LCCR1_HSW Fld (6, 10) /* Horizontal Synchronization */
1490#define LCCR1_HorSnchWdth(Tpix) /* Horizontal Synchronization */ \
1491 /* pulse Width [1..64 Tpix] */ \
1492 (((Tpix) - 1) << FShft (LCCR1_HSW))
1493
1494#define LCCR1_ELW Fld (8, 16) /* End-of-Line pixel clock Wait */
1495 /* count - 1 [Tpix] */
1496#define LCCR1_EndLnDel(Tpix) /* End-of-Line Delay */ \
1497 /* [1..256 Tpix] */ \
1498 (((Tpix) - 1) << FShft (LCCR1_ELW))
1499
1500#define LCCR1_BLW Fld (8, 24) /* Beginning-of-Line pixel clock */
1501 /* Wait count - 1 [Tpix] */
1502#define LCCR1_BegLnDel(Tpix) /* Beginning-of-Line Delay */ \
1503 /* [1..256 Tpix] */ \
1504 (((Tpix) - 1) << FShft (LCCR1_BLW))
1505
1506
1507#define LCCR2_LPP Fld (10, 0) /* Line Per Panel - 1 */
1508#define LCCR2_DisHght(Line) /* Display Height [1..1024 lines] */ \
1509 (((Line) - 1) << FShft (LCCR2_LPP))
1510
1511#define LCCR2_VSW Fld (6, 10) /* Vertical Synchronization pulse */
1512 /* Width - 1 [Tln] (L_FCLK) */
1513#define LCCR2_VrtSnchWdth(Tln) /* Vertical Synchronization pulse */ \
1514 /* Width [1..64 Tln] */ \
1515 (((Tln) - 1) << FShft (LCCR2_VSW))
1516
1517#define LCCR2_EFW Fld (8, 16) /* End-of-Frame line clock Wait */
1518 /* count [Tln] */
1519#define LCCR2_EndFrmDel(Tln) /* End-of-Frame Delay */ \
1520 /* [0..255 Tln] */ \
1521 ((Tln) << FShft (LCCR2_EFW))
1522
1523#define LCCR2_BFW Fld (8, 24) /* Beginning-of-Frame line clock */
1524 /* Wait count [Tln] */
1525#define LCCR2_BegFrmDel(Tln) /* Beginning-of-Frame Delay */ \
1526 /* [0..255 Tln] */ \
1527 ((Tln) << FShft (LCCR2_BFW))
1528
1529#if 0
1530#define LCCR3_PCD (0xff) /* Pixel clock divisor */
1531#define LCCR3_ACB (0xff << 8) /* AC Bias pin frequency */
1532#define LCCR3_ACB_S 8
1533#endif
1534
1535#define LCCR3_API (0xf << 16) /* AC Bias pin trasitions per interrupt */
1536#define LCCR3_API_S 16
1537#define LCCR3_VSP (1 << 20) /* vertical sync polarity */
1538#define LCCR3_HSP (1 << 21) /* horizontal sync polarity */
1539#define LCCR3_PCP (1 << 22) /* Pixel Clock Polarity (L_PCLK) */
1540#define LCCR3_PixRsEdg (LCCR3_PCP*0) /* Pixel clock Rising-Edge */
1541#define LCCR3_PixFlEdg (LCCR3_PCP*1) /* Pixel clock Falling-Edge */
1542
1543#define LCCR3_OEP (1 << 23) /* Output Enable Polarity (L_BIAS, */
1544 /* active display mode) */
1545#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
1546#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
1547
1548#if 0
1549#define LCCR3_BPP (7 << 24) /* bits per pixel */
1550#define LCCR3_BPP_S 24
1551#endif
1552#define LCCR3_DPC (1 << 27) /* double pixel clock mode */
1553
1554
1555#define LCCR3_PCD Fld (8, 0) /* Pixel Clock Divisor */
1556#define LCCR3_PixClkDiv(Div) /* Pixel Clock Divisor */ \
1557 (((Div) << FShft (LCCR3_PCD)))
1558
1559
1560#define LCCR3_BPP Fld (3, 24) /* Bit Per Pixel */
1561#define LCCR3_Bpp(Bpp) /* Bit Per Pixel */ \
1562 (((Bpp) << FShft (LCCR3_BPP)))
1563
1564#define LCCR3_ACB Fld (8, 8) /* AC Bias */
1565#define LCCR3_Acb(Acb) /* BAC Bias */ \
1566 (((Acb) << FShft (LCCR3_ACB)))
1567
1568#define LCCR3_HorSnchH (LCCR3_HSP*0) /* Horizontal Synchronization */
1569 /* pulse active High */
1570#define LCCR3_HorSnchL (LCCR3_HSP*1) /* Horizontal Synchronization */
1571
1572#define LCCR3_VrtSnchH (LCCR3_VSP*0) /* Vertical Synchronization pulse */
1573 /* active High */
1574#define LCCR3_VrtSnchL (LCCR3_VSP*1) /* Vertical Synchronization pulse */
1575 /* active Low */
1576
1577#define LCSR_LDD (1 << 0) /* LCD Disable Done */
1578#define LCSR_SOF (1 << 1) /* Start of frame */
1579#define LCSR_BER (1 << 2) /* Bus error */
1580#define LCSR_ABC (1 << 3) /* AC Bias count */
1581#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
1582#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
1583#define LCSR_OU (1 << 6) /* output FIFO underrun */
1584#define LCSR_QD (1 << 7) /* quick disable */
1585#define LCSR_EOF (1 << 8) /* end of frame */
1586#define LCSR_BS (1 << 9) /* branch status */
1587#define LCSR_SINT (1 << 10) /* subsequent interrupt */
1588
1589#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
1590
1591#define LCSR_LDD (1 << 0) /* LCD Disable Done */
1592#define LCSR_SOF (1 << 1) /* Start of frame */
1593#define LCSR_BER (1 << 2) /* Bus error */
1594#define LCSR_ABC (1 << 3) /* AC Bias count */
1595#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
1596#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
1597#define LCSR_OU (1 << 6) /* output FIFO underrun */
1598#define LCSR_QD (1 << 7) /* quick disable */
1599#define LCSR_EOF (1 << 8) /* end of frame */
1600#define LCSR_BS (1 << 9) /* branch status */
1601#define LCSR_SINT (1 << 10) /* subsequent interrupt */
1602
1603#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
1604
1605#ifdef CONFIG_PXA27x 1409#ifdef CONFIG_PXA27x
1606 1410
1607/* Camera Interface */ 1411/* Camera Interface */
diff --git a/include/asm-arm/arch-pxa/pxafb.h b/include/asm-arm/arch-pxa/pxafb.h
index ea2336aa70e4..bbd22396841a 100644
--- a/include/asm-arm/arch-pxa/pxafb.h
+++ b/include/asm-arm/arch-pxa/pxafb.h
@@ -13,6 +13,50 @@
13 */ 13 */
14 14
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <asm/arch/regs-lcd.h>
17
18/*
19 * Supported LCD connections
20 *
21 * bits 0 - 3: for LCD panel type:
22 *
23 * STN - for passive matrix
24 * DSTN - for dual scan passive matrix
25 * TFT - for active matrix
26 *
27 * bits 4 - 9 : for bus width
28 * bits 10-17 : for AC Bias Pin Frequency
29 * bit 18 : for output enable polarity
30 * bit 19 : for pixel clock edge
31 */
32#define LCD_CONN_TYPE(_x) ((_x) & 0x0f)
33#define LCD_CONN_WIDTH(_x) (((_x) >> 4) & 0x1f)
34
35#define LCD_TYPE_UNKNOWN 0
36#define LCD_TYPE_MONO_STN 1
37#define LCD_TYPE_MONO_DSTN 2
38#define LCD_TYPE_COLOR_STN 3
39#define LCD_TYPE_COLOR_DSTN 4
40#define LCD_TYPE_COLOR_TFT 5
41#define LCD_TYPE_SMART_PANEL 6
42#define LCD_TYPE_MAX 7
43
44#define LCD_MONO_STN_4BPP ((4 << 4) | LCD_TYPE_MONO_STN)
45#define LCD_MONO_STN_8BPP ((8 << 4) | LCD_TYPE_MONO_STN)
46#define LCD_MONO_DSTN_8BPP ((8 << 4) | LCD_TYPE_MONO_DSTN)
47#define LCD_COLOR_STN_8BPP ((8 << 4) | LCD_TYPE_COLOR_STN)
48#define LCD_COLOR_DSTN_16BPP ((16 << 4) | LCD_TYPE_COLOR_DSTN)
49#define LCD_COLOR_TFT_16BPP ((16 << 4) | LCD_TYPE_COLOR_TFT)
50#define LCD_COLOR_TFT_18BPP ((18 << 4) | LCD_TYPE_COLOR_TFT)
51#define LCD_SMART_PANEL_8BPP ((8 << 4) | LCD_TYPE_SMART_PANEL)
52#define LCD_SMART_PANEL_16BPP ((16 << 4) | LCD_TYPE_SMART_PANEL)
53#define LCD_SMART_PANEL_18BPP ((18 << 4) | LCD_TYPE_SMART_PANEL)
54
55#define LCD_AC_BIAS_FREQ(x) (((x) & 0xff) << 10)
56#define LCD_BIAS_ACTIVE_HIGH (0 << 17)
57#define LCD_BIAS_ACTIVE_LOW (1 << 17)
58#define LCD_PCLK_EDGE_RISE (0 << 18)
59#define LCD_PCLK_EDGE_FALL (1 << 18)
16 60
17/* 61/*
18 * This structure describes the machine which we are running on. 62 * This structure describes the machine which we are running on.
@@ -26,6 +70,10 @@ struct pxafb_mode_info {
26 u_short yres; 70 u_short yres;
27 71
28 u_char bpp; 72 u_char bpp;
73 u_int cmap_greyscale:1,
74 unused:31;
75
76 /* Parallel Mode Timing */
29 u_char hsync_len; 77 u_char hsync_len;
30 u_char left_margin; 78 u_char left_margin;
31 u_char right_margin; 79 u_char right_margin;
@@ -35,14 +83,28 @@ struct pxafb_mode_info {
35 u_char lower_margin; 83 u_char lower_margin;
36 u_char sync; 84 u_char sync;
37 85
38 u_int cmap_greyscale:1, 86 /* Smart Panel Mode Timing - see PXA27x DM 7.4.15.0.3 for details
39 unused:31; 87 * Note:
88 * 1. all parameters in nanosecond (ns)
89 * 2. a0cs{rd,wr}_set_hld are controlled by the same register bits
90 * in pxa27x and pxa3xx, initialize them to the same value or
91 * the larger one will be used
92 * 3. same to {rd,wr}_pulse_width
93 */
94 unsigned a0csrd_set_hld; /* A0 and CS Setup/Hold Time before/after L_FCLK_RD */
95 unsigned a0cswr_set_hld; /* A0 and CS Setup/Hold Time before/after L_PCLK_WR */
96 unsigned wr_pulse_width; /* L_PCLK_WR pulse width */
97 unsigned rd_pulse_width; /* L_FCLK_RD pulse width */
98 unsigned cmd_inh_time; /* Command Inhibit time between two writes */
99 unsigned op_hold_time; /* Output Hold time from L_FCLK_RD negation */
40}; 100};
41 101
42struct pxafb_mach_info { 102struct pxafb_mach_info {
43 struct pxafb_mode_info *modes; 103 struct pxafb_mode_info *modes;
44 unsigned int num_modes; 104 unsigned int num_modes;
45 105
106 unsigned int lcd_conn;
107
46 u_int fixed_modes:1, 108 u_int fixed_modes:1,
47 cmap_inverse:1, 109 cmap_inverse:1,
48 cmap_static:1, 110 cmap_static:1,
@@ -78,8 +140,11 @@ struct pxafb_mach_info {
78 u_int lccr4; 140 u_int lccr4;
79 void (*pxafb_backlight_power)(int); 141 void (*pxafb_backlight_power)(int);
80 void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *); 142 void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
81 143 void (*smart_update)(struct fb_info *);
82}; 144};
83void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info); 145void set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info);
84void set_pxa_fb_parent(struct device *parent_dev); 146void set_pxa_fb_parent(struct device *parent_dev);
85unsigned long pxafb_get_hsync_time(struct device *dev); 147unsigned long pxafb_get_hsync_time(struct device *dev);
148
149extern int pxafb_smart_queue(struct fb_info *info, uint16_t *cmds, int);
150extern int pxafb_smart_flush(struct fb_info *info);
diff --git a/include/asm-arm/arch-pxa/regs-lcd.h b/include/asm-arm/arch-pxa/regs-lcd.h
new file mode 100644
index 000000000000..f762493f5141
--- /dev/null
+++ b/include/asm-arm/arch-pxa/regs-lcd.h
@@ -0,0 +1,171 @@
1#ifndef __ASM_ARCH_REGS_LCD_H
2#define __ASM_ARCH_REGS_LCD_H
3/*
4 * LCD Controller Registers and Bits Definitions
5 */
6#define LCCR0 (0x000) /* LCD Controller Control Register 0 */
7#define LCCR1 (0x004) /* LCD Controller Control Register 1 */
8#define LCCR2 (0x008) /* LCD Controller Control Register 2 */
9#define LCCR3 (0x00C) /* LCD Controller Control Register 3 */
10#define LCCR4 (0x010) /* LCD Controller Control Register 4 */
11#define LCCR5 (0x014) /* LCD Controller Control Register 5 */
12#define DFBR0 (0x020) /* DMA Channel 0 Frame Branch Register */
13#define DFBR1 (0x024) /* DMA Channel 1 Frame Branch Register */
14#define LCSR (0x038) /* LCD Controller Status Register */
15#define LIIDR (0x03C) /* LCD Controller Interrupt ID Register */
16#define TMEDRGBR (0x040) /* TMED RGB Seed Register */
17#define TMEDCR (0x044) /* TMED Control Register */
18
19#define CMDCR (0x100) /* Command Control Register */
20#define PRSR (0x104) /* Panel Read Status Register */
21
22#define LCCR3_1BPP (0 << 24)
23#define LCCR3_2BPP (1 << 24)
24#define LCCR3_4BPP (2 << 24)
25#define LCCR3_8BPP (3 << 24)
26#define LCCR3_16BPP (4 << 24)
27
28#define LCCR3_PDFOR_0 (0 << 30)
29#define LCCR3_PDFOR_1 (1 << 30)
30#define LCCR3_PDFOR_2 (2 << 30)
31#define LCCR3_PDFOR_3 (3 << 30)
32
33#define LCCR4_PAL_FOR_0 (0 << 15)
34#define LCCR4_PAL_FOR_1 (1 << 15)
35#define LCCR4_PAL_FOR_2 (2 << 15)
36#define LCCR4_PAL_FOR_MASK (3 << 15)
37
38#define FDADR0 (0x200) /* DMA Channel 0 Frame Descriptor Address Register */
39#define FSADR0 (0x204) /* DMA Channel 0 Frame Source Address Register */
40#define FIDR0 (0x208) /* DMA Channel 0 Frame ID Register */
41#define LDCMD0 (0x20C) /* DMA Channel 0 Command Register */
42#define FDADR1 (0x210) /* DMA Channel 1 Frame Descriptor Address Register */
43#define FSADR1 (0x214) /* DMA Channel 1 Frame Source Address Register */
44#define FIDR1 (0x218) /* DMA Channel 1 Frame ID Register */
45#define LDCMD1 (0x21C) /* DMA Channel 1 Command Register */
46#define FDADR6 (0x260) /* DMA Channel 6 Frame Descriptor Address Register */
47#define FSADR6 (0x264) /* DMA Channel 6 Frame Source Address Register */
48#define FIDR6 (0x268) /* DMA Channel 6 Frame ID Register */
49
50#define LCCR0_ENB (1 << 0) /* LCD Controller enable */
51#define LCCR0_CMS (1 << 1) /* Color/Monochrome Display Select */
52#define LCCR0_Color (LCCR0_CMS*0) /* Color display */
53#define LCCR0_Mono (LCCR0_CMS*1) /* Monochrome display */
54#define LCCR0_SDS (1 << 2) /* Single/Dual Panel Display Select */
55#define LCCR0_Sngl (LCCR0_SDS*0) /* Single panel display */
56#define LCCR0_Dual (LCCR0_SDS*1) /* Dual panel display */
57
58#define LCCR0_LDM (1 << 3) /* LCD Disable Done Mask */
59#define LCCR0_SFM (1 << 4) /* Start of frame mask */
60#define LCCR0_IUM (1 << 5) /* Input FIFO underrun mask */
61#define LCCR0_EFM (1 << 6) /* End of Frame mask */
62#define LCCR0_PAS (1 << 7) /* Passive/Active display Select */
63#define LCCR0_Pas (LCCR0_PAS*0) /* Passive display (STN) */
64#define LCCR0_Act (LCCR0_PAS*1) /* Active display (TFT) */
65#define LCCR0_DPD (1 << 9) /* Double Pixel Data (monochrome) */
66#define LCCR0_4PixMono (LCCR0_DPD*0) /* 4-Pixel/clock Monochrome display */
67#define LCCR0_8PixMono (LCCR0_DPD*1) /* 8-Pixel/clock Monochrome display */
68#define LCCR0_DIS (1 << 10) /* LCD Disable */
69#define LCCR0_QDM (1 << 11) /* LCD Quick Disable mask */
70#define LCCR0_PDD (0xff << 12) /* Palette DMA request delay */
71#define LCCR0_PDD_S 12
72#define LCCR0_BM (1 << 20) /* Branch mask */
73#define LCCR0_OUM (1 << 21) /* Output FIFO underrun mask */
74#define LCCR0_LCDT (1 << 22) /* LCD panel type */
75#define LCCR0_RDSTM (1 << 23) /* Read status interrupt mask */
76#define LCCR0_CMDIM (1 << 24) /* Command interrupt mask */
77#define LCCR0_OUC (1 << 25) /* Overlay Underlay control bit */
78#define LCCR0_LDDALT (1 << 26) /* LDD alternate mapping control */
79
80#define LCCR1_PPL Fld (10, 0) /* Pixels Per Line - 1 */
81#define LCCR1_DisWdth(Pixel) (((Pixel) - 1) << FShft (LCCR1_PPL))
82
83#define LCCR1_HSW Fld (6, 10) /* Horizontal Synchronization */
84#define LCCR1_HorSnchWdth(Tpix) (((Tpix) - 1) << FShft (LCCR1_HSW))
85
86#define LCCR1_ELW Fld (8, 16) /* End-of-Line pixel clock Wait - 1 */
87#define LCCR1_EndLnDel(Tpix) (((Tpix) - 1) << FShft (LCCR1_ELW))
88
89#define LCCR1_BLW Fld (8, 24) /* Beginning-of-Line pixel clock */
90#define LCCR1_BegLnDel(Tpix) (((Tpix) - 1) << FShft (LCCR1_BLW))
91
92#define LCCR2_LPP Fld (10, 0) /* Line Per Panel - 1 */
93#define LCCR2_DisHght(Line) (((Line) - 1) << FShft (LCCR2_LPP))
94
95#define LCCR2_VSW Fld (6, 10) /* Vertical Synchronization pulse - 1 */
96#define LCCR2_VrtSnchWdth(Tln) (((Tln) - 1) << FShft (LCCR2_VSW))
97
98#define LCCR2_EFW Fld (8, 16) /* End-of-Frame line clock Wait */
99#define LCCR2_EndFrmDel(Tln) ((Tln) << FShft (LCCR2_EFW))
100
101#define LCCR2_BFW Fld (8, 24) /* Beginning-of-Frame line clock */
102#define LCCR2_BegFrmDel(Tln) ((Tln) << FShft (LCCR2_BFW))
103
104#define LCCR3_API (0xf << 16) /* AC Bias pin trasitions per interrupt */
105#define LCCR3_API_S 16
106#define LCCR3_VSP (1 << 20) /* vertical sync polarity */
107#define LCCR3_HSP (1 << 21) /* horizontal sync polarity */
108#define LCCR3_PCP (1 << 22) /* Pixel Clock Polarity (L_PCLK) */
109#define LCCR3_PixRsEdg (LCCR3_PCP*0) /* Pixel clock Rising-Edge */
110#define LCCR3_PixFlEdg (LCCR3_PCP*1) /* Pixel clock Falling-Edge */
111
112#define LCCR3_OEP (1 << 23) /* Output Enable Polarity */
113#define LCCR3_OutEnH (LCCR3_OEP*0) /* Output Enable active High */
114#define LCCR3_OutEnL (LCCR3_OEP*1) /* Output Enable active Low */
115
116#define LCCR3_DPC (1 << 27) /* double pixel clock mode */
117#define LCCR3_PCD Fld (8, 0) /* Pixel Clock Divisor */
118#define LCCR3_PixClkDiv(Div) (((Div) << FShft (LCCR3_PCD)))
119
120#define LCCR3_BPP Fld (3, 24) /* Bit Per Pixel */
121#define LCCR3_Bpp(Bpp) (((Bpp) << FShft (LCCR3_BPP)))
122
123#define LCCR3_ACB Fld (8, 8) /* AC Bias */
124#define LCCR3_Acb(Acb) (((Acb) << FShft (LCCR3_ACB)))
125
126#define LCCR3_HorSnchH (LCCR3_HSP*0) /* HSP Active High */
127#define LCCR3_HorSnchL (LCCR3_HSP*1) /* HSP Active Low */
128
129#define LCCR3_VrtSnchH (LCCR3_VSP*0) /* VSP Active High */
130#define LCCR3_VrtSnchL (LCCR3_VSP*1) /* VSP Active Low */
131
132#define LCCR5_IUM(x) (1 << ((x) + 23)) /* input underrun mask */
133#define LCCR5_BSM(x) (1 << ((x) + 15)) /* branch mask */
134#define LCCR5_EOFM(x) (1 << ((x) + 7)) /* end of frame mask */
135#define LCCR5_SOFM(x) (1 << ((x) + 0)) /* start of frame mask */
136
137#define LCSR_LDD (1 << 0) /* LCD Disable Done */
138#define LCSR_SOF (1 << 1) /* Start of frame */
139#define LCSR_BER (1 << 2) /* Bus error */
140#define LCSR_ABC (1 << 3) /* AC Bias count */
141#define LCSR_IUL (1 << 4) /* input FIFO underrun Lower panel */
142#define LCSR_IUU (1 << 5) /* input FIFO underrun Upper panel */
143#define LCSR_OU (1 << 6) /* output FIFO underrun */
144#define LCSR_QD (1 << 7) /* quick disable */
145#define LCSR_EOF (1 << 8) /* end of frame */
146#define LCSR_BS (1 << 9) /* branch status */
147#define LCSR_SINT (1 << 10) /* subsequent interrupt */
148#define LCSR_RD_ST (1 << 11) /* read status */
149#define LCSR_CMD_INT (1 << 12) /* command interrupt */
150
151#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
152
153/* smartpanel related */
154#define PRSR_DATA(x) ((x) & 0xff) /* Panel Data */
155#define PRSR_A0 (1 << 8) /* Read Data Source */
156#define PRSR_ST_OK (1 << 9) /* Status OK */
157#define PRSR_CON_NT (1 << 10) /* Continue to Next Command */
158
159#define SMART_CMD_A0 (0x1 << 8)
160#define SMART_CMD_READ_STATUS_REG (0x0 << 9)
161#define SMART_CMD_READ_FRAME_BUFFER ((0x0 << 9) | SMART_CMD_A0)
162#define SMART_CMD_WRITE_COMMAND (0x1 << 9)
163#define SMART_CMD_WRITE_DATA ((0x1 << 9) | SMART_CMD_A0)
164#define SMART_CMD_WRITE_FRAME ((0x2 << 9) | SMART_CMD_A0)
165#define SMART_CMD_WAIT_FOR_VSYNC (0x3 << 9)
166#define SMART_CMD_NOOP (0x4 << 9)
167#define SMART_CMD_INTERRUPT (0x5 << 9)
168
169#define SMART_CMD(x) (SMART_CMD_WRITE_COMMAND | ((x) & 0xff))
170#define SMART_DAT(x) (SMART_CMD_WRITE_DATA | ((x) & 0xff))
171#endif /* __ASM_ARCH_REGS_LCD_H */
diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h
index 15e6f253dda4..c9f369c4bd7e 100644
--- a/include/asm-generic/bitops.h
+++ b/include/asm-generic/bitops.h
@@ -17,8 +17,6 @@
17#include <asm-generic/bitops/fls64.h> 17#include <asm-generic/bitops/fls64.h>
18#include <asm-generic/bitops/find.h> 18#include <asm-generic/bitops/find.h>
19 19
20#ifdef __KERNEL__
21
22#ifndef _LINUX_BITOPS_H 20#ifndef _LINUX_BITOPS_H
23#error only <linux/bitops.h> can be included directly 21#error only <linux/bitops.h> can be included directly
24#endif 22#endif
@@ -32,6 +30,4 @@
32#include <asm-generic/bitops/ext2-atomic.h> 30#include <asm-generic/bitops/ext2-atomic.h>
33#include <asm-generic/bitops/minix.h> 31#include <asm-generic/bitops/minix.h>
34 32
35#endif /* __KERNEL__ */
36
37#endif /* _ASM_GENERIC_BITOPS_H */ 33#endif /* _ASM_GENERIC_BITOPS_H */
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index f422df0956a2..3c2344f48136 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -1,11 +1,9 @@
1#ifndef _ASM_GENERIC_FUTEX_H 1#ifndef _ASM_GENERIC_FUTEX_H
2#define _ASM_GENERIC_FUTEX_H 2#define _ASM_GENERIC_FUTEX_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
7#include <asm/errno.h> 6#include <asm/errno.h>
8#include <asm/uaccess.h>
9 7
10static inline int 8static inline int
11futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 9futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
@@ -56,4 +54,3 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
56} 54}
57 55
58#endif 56#endif
59#endif
diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h
index 52226e14bd7d..ae060c62aff1 100644
--- a/include/asm-generic/memory_model.h
+++ b/include/asm-generic/memory_model.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_MEMORY_MODEL_H 1#ifndef __ASM_MEMORY_MODEL_H
2#define __ASM_MEMORY_MODEL_H 2#define __ASM_MEMORY_MODEL_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6 5
7#if defined(CONFIG_FLATMEM) 6#if defined(CONFIG_FLATMEM)
@@ -81,6 +80,5 @@ extern unsigned long page_to_pfn(struct page *page);
81#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */ 80#endif /* CONFIG_OUT_OF_LINE_PFN_TO_PAGE */
82 81
83#endif /* __ASSEMBLY__ */ 82#endif /* __ASSEMBLY__ */
84#endif /* __KERNEL__ */
85 83
86#endif 84#endif
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index a96b5d986b6e..14db733b8e68 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -1,7 +1,6 @@
1#ifndef _ASM_GENERIC_PAGE_H 1#ifndef _ASM_GENERIC_PAGE_H
2#define _ASM_GENERIC_PAGE_H 2#define _ASM_GENERIC_PAGE_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6 5
7#include <linux/compiler.h> 6#include <linux/compiler.h>
@@ -21,6 +20,5 @@ static __inline__ __attribute_const__ int get_order(unsigned long size)
21} 20}
22 21
23#endif /* __ASSEMBLY__ */ 22#endif /* __ASSEMBLY__ */
24#endif /* __KERNEL__ */
25 23
26#endif /* _ASM_GENERIC_PAGE_H */ 24#endif /* _ASM_GENERIC_PAGE_H */
diff --git a/include/asm-generic/rtc.h b/include/asm-generic/rtc.h
index dd1bed860e64..be4af0029ac0 100644
--- a/include/asm-generic/rtc.h
+++ b/include/asm-generic/rtc.h
@@ -12,8 +12,6 @@
12#ifndef __ASM_RTC_H__ 12#ifndef __ASM_RTC_H__
13#define __ASM_RTC_H__ 13#define __ASM_RTC_H__
14 14
15#ifdef __KERNEL__
16
17#include <linux/mc146818rtc.h> 15#include <linux/mc146818rtc.h>
18#include <linux/rtc.h> 16#include <linux/rtc.h>
19#include <linux/bcd.h> 17#include <linux/bcd.h>
@@ -213,5 +211,4 @@ static inline int set_rtc_pll(struct rtc_pll_info *pll)
213 return -EINVAL; 211 return -EINVAL;
214} 212}
215 213
216#endif /* __KERNEL__ */
217#endif /* __ASM_RTC_H__ */ 214#endif /* __ASM_RTC_H__ */
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 8a98a2654139..c7f0f062239c 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -2,9 +2,9 @@
2#define _ASM_FUTEX_H 2#define _ASM_FUTEX_H
3 3
4#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
5#include <asm/errno.h> 6#include <asm/errno.h>
6#include <asm/system.h> 7#include <asm/system.h>
7#include <asm/uaccess.h>
8 8
9#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ 9#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10do { \ 10do { \
diff --git a/include/asm-ia64/thread_info.h b/include/asm-ia64/thread_info.h
index 6da8069a0f77..f30e05583869 100644
--- a/include/asm-ia64/thread_info.h
+++ b/include/asm-ia64/thread_info.h
@@ -101,7 +101,6 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
101#define TIF_SYSCALL_TRACE 2 /* syscall trace active */ 101#define TIF_SYSCALL_TRACE 2 /* syscall trace active */
102#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */ 102#define TIF_SYSCALL_AUDIT 3 /* syscall auditing active */
103#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ 103#define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */
104#define TIF_RESTORE_SIGMASK 5 /* restore signal mask in do_signal() */
105#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */ 104#define TIF_NOTIFY_RESUME 6 /* resumption notification requested */
106#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 105#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
107#define TIF_MEMDIE 17 106#define TIF_MEMDIE 17
@@ -109,6 +108,7 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
109#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */ 108#define TIF_DB_DISABLED 19 /* debug trap disabled for fsyscall */
110#define TIF_FREEZE 20 /* is freezing for suspend */ 109#define TIF_FREEZE 20 /* is freezing for suspend */
111#define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */ 110#define TIF_RESTORE_RSE 21 /* user RBS is newer than kernel RBS */
111#define TIF_RESTORE_SIGMASK 22 /* restore signal mask in do_signal() */
112 112
113#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 113#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
114#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 114#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
@@ -126,8 +126,7 @@ extern void tsk_clear_notify_resume(struct task_struct *tsk);
126 126
127/* "work to do on user-return" bits */ 127/* "work to do on user-return" bits */
128#define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\ 128#define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\
129 _TIF_NEED_RESCHED| _TIF_SYSCALL_TRACE|\ 129 _TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE)
130 _TIF_RESTORE_SIGMASK)
131/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */ 130/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */
132#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) 131#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT))
133 132
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 17f082cfea85..b9cce90346cf 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -11,9 +11,9 @@
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12 12
13#include <linux/futex.h> 13#include <linux/futex.h>
14#include <linux/uaccess.h>
14#include <asm/barrier.h> 15#include <asm/barrier.h>
15#include <asm/errno.h> 16#include <asm/errno.h>
16#include <asm/uaccess.h>
17#include <asm/war.h> 17#include <asm/war.h>
18 18
19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 19#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
diff --git a/include/asm-parisc/futex.h b/include/asm-parisc/futex.h
index fdc6d055ef7f..0c705c3a55ef 100644
--- a/include/asm-parisc/futex.h
+++ b/include/asm-parisc/futex.h
@@ -4,8 +4,8 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/uaccess.h>
9 9
10static inline int 10static inline int
11futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 11futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h
index 3f3673fd3ff3..6d406c5c5de4 100644
--- a/include/asm-powerpc/futex.h
+++ b/include/asm-powerpc/futex.h
@@ -4,9 +4,9 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/synch.h> 9#include <asm/synch.h>
9#include <asm/uaccess.h>
10#include <asm/asm-compat.h> 10#include <asm/asm-compat.h>
11 11
12#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \ 12#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
diff --git a/include/asm-s390/ccwgroup.h b/include/asm-s390/ccwgroup.h
index 289053ef5e60..a27f68985a79 100644
--- a/include/asm-s390/ccwgroup.h
+++ b/include/asm-s390/ccwgroup.h
@@ -57,10 +57,9 @@ struct ccwgroup_driver {
57 57
58extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver); 58extern int ccwgroup_driver_register (struct ccwgroup_driver *cdriver);
59extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver); 59extern void ccwgroup_driver_unregister (struct ccwgroup_driver *cdriver);
60extern int ccwgroup_create (struct device *root, 60int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
61 unsigned int creator_id, 61 struct ccw_driver *cdrv, int num_devices,
62 struct ccw_driver *gdrv, 62 const char *buf);
63 int argc, char *argv[]);
64 63
65extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev); 64extern int ccwgroup_probe_ccwdev(struct ccw_device *cdev);
66extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev); 65extern void ccwgroup_remove_ccwdev(struct ccw_device *cdev);
diff --git a/include/asm-s390/hugetlb.h b/include/asm-s390/hugetlb.h
new file mode 100644
index 000000000000..600a776f8f75
--- /dev/null
+++ b/include/asm-s390/hugetlb.h
@@ -0,0 +1,183 @@
1/*
2 * IBM System z Huge TLB Page Support for Kernel.
3 *
4 * Copyright IBM Corp. 2008
5 * Author(s): Gerald Schaefer <gerald.schaefer@de.ibm.com>
6 */
7
8#ifndef _ASM_S390_HUGETLB_H
9#define _ASM_S390_HUGETLB_H
10
11#include <asm/page.h>
12#include <asm/pgtable.h>
13
14
15#define is_hugepage_only_range(mm, addr, len) 0
16#define hugetlb_free_pgd_range free_pgd_range
17
18void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
19 pte_t *ptep, pte_t pte);
20
21/*
22 * If the arch doesn't supply something else, assume that hugepage
23 * size aligned regions are ok without further preparation.
24 */
25static inline int prepare_hugepage_range(unsigned long addr, unsigned long len)
26{
27 if (len & ~HPAGE_MASK)
28 return -EINVAL;
29 if (addr & ~HPAGE_MASK)
30 return -EINVAL;
31 return 0;
32}
33
34#define hugetlb_prefault_arch_hook(mm) do { } while (0)
35
36int arch_prepare_hugepage(struct page *page);
37void arch_release_hugepage(struct page *page);
38
39static inline pte_t pte_mkhuge(pte_t pte)
40{
41 /*
42 * PROT_NONE needs to be remapped from the pte type to the ste type.
43 * The HW invalid bit is also different for pte and ste. The pte
44 * invalid bit happens to be the same as the ste _SEGMENT_ENTRY_LARGE
45 * bit, so we don't have to clear it.
46 */
47 if (pte_val(pte) & _PAGE_INVALID) {
48 if (pte_val(pte) & _PAGE_SWT)
49 pte_val(pte) |= _HPAGE_TYPE_NONE;
50 pte_val(pte) |= _SEGMENT_ENTRY_INV;
51 }
52 /*
53 * Clear SW pte bits SWT and SWX, there are no SW bits in a segment
54 * table entry.
55 */
56 pte_val(pte) &= ~(_PAGE_SWT | _PAGE_SWX);
57 /*
58 * Also set the change-override bit because we don't need dirty bit
59 * tracking for hugetlbfs pages.
60 */
61 pte_val(pte) |= (_SEGMENT_ENTRY_LARGE | _SEGMENT_ENTRY_CO);
62 return pte;
63}
64
65static inline pte_t huge_pte_wrprotect(pte_t pte)
66{
67 pte_val(pte) |= _PAGE_RO;
68 return pte;
69}
70
71static inline int huge_pte_none(pte_t pte)
72{
73 return (pte_val(pte) & _SEGMENT_ENTRY_INV) &&
74 !(pte_val(pte) & _SEGMENT_ENTRY_RO);
75}
76
77static inline pte_t huge_ptep_get(pte_t *ptep)
78{
79 pte_t pte = *ptep;
80 unsigned long mask;
81
82 if (!MACHINE_HAS_HPAGE) {
83 ptep = (pte_t *) (pte_val(pte) & _SEGMENT_ENTRY_ORIGIN);
84 if (ptep) {
85 mask = pte_val(pte) &
86 (_SEGMENT_ENTRY_INV | _SEGMENT_ENTRY_RO);
87 pte = pte_mkhuge(*ptep);
88 pte_val(pte) |= mask;
89 }
90 }
91 return pte;
92}
93
94static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
95 unsigned long addr, pte_t *ptep)
96{
97 pte_t pte = huge_ptep_get(ptep);
98
99 pmd_clear((pmd_t *) ptep);
100 return pte;
101}
102
103static inline void __pmd_csp(pmd_t *pmdp)
104{
105 register unsigned long reg2 asm("2") = pmd_val(*pmdp);
106 register unsigned long reg3 asm("3") = pmd_val(*pmdp) |
107 _SEGMENT_ENTRY_INV;
108 register unsigned long reg4 asm("4") = ((unsigned long) pmdp) + 5;
109
110 asm volatile(
111 " csp %1,%3"
112 : "=m" (*pmdp)
113 : "d" (reg2), "d" (reg3), "d" (reg4), "m" (*pmdp) : "cc");
114 pmd_val(*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY;
115}
116
117static inline void __pmd_idte(unsigned long address, pmd_t *pmdp)
118{
119 unsigned long sto = (unsigned long) pmdp -
120 pmd_index(address) * sizeof(pmd_t);
121
122 if (!(pmd_val(*pmdp) & _SEGMENT_ENTRY_INV)) {
123 asm volatile(
124 " .insn rrf,0xb98e0000,%2,%3,0,0"
125 : "=m" (*pmdp)
126 : "m" (*pmdp), "a" (sto),
127 "a" ((address & HPAGE_MASK))
128 );
129 }
130 pmd_val(*pmdp) = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY;
131}
132
133static inline void huge_ptep_invalidate(struct mm_struct *mm,
134 unsigned long address, pte_t *ptep)
135{
136 pmd_t *pmdp = (pmd_t *) ptep;
137
138 if (!MACHINE_HAS_IDTE) {
139 __pmd_csp(pmdp);
140 if (mm->context.noexec) {
141 pmdp = get_shadow_table(pmdp);
142 __pmd_csp(pmdp);
143 }
144 return;
145 }
146
147 __pmd_idte(address, pmdp);
148 if (mm->context.noexec) {
149 pmdp = get_shadow_table(pmdp);
150 __pmd_idte(address, pmdp);
151 }
152 return;
153}
154
155#define huge_ptep_set_access_flags(__vma, __addr, __ptep, __entry, __dirty) \
156({ \
157 int __changed = !pte_same(huge_ptep_get(__ptep), __entry); \
158 if (__changed) { \
159 huge_ptep_invalidate((__vma)->vm_mm, __addr, __ptep); \
160 set_huge_pte_at((__vma)->vm_mm, __addr, __ptep, __entry); \
161 } \
162 __changed; \
163})
164
165#define huge_ptep_set_wrprotect(__mm, __addr, __ptep) \
166({ \
167 pte_t __pte = huge_ptep_get(__ptep); \
168 if (pte_write(__pte)) { \
169 if (atomic_read(&(__mm)->mm_users) > 1 || \
170 (__mm) != current->active_mm) \
171 huge_ptep_invalidate(__mm, __addr, __ptep); \
172 set_huge_pte_at(__mm, __addr, __ptep, \
173 huge_pte_wrprotect(__pte)); \
174 } \
175})
176
177static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
178 unsigned long address, pte_t *ptep)
179{
180 huge_ptep_invalidate(vma->vm_mm, address, ptep);
181}
182
183#endif /* _ASM_S390_HUGETLB_H */
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h
index fe7f92b6ae6d..f0f4579eac13 100644
--- a/include/asm-s390/page.h
+++ b/include/asm-s390/page.h
@@ -19,17 +19,34 @@
19#define PAGE_DEFAULT_ACC 0 19#define PAGE_DEFAULT_ACC 0
20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4) 20#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
21 21
22#define HPAGE_SHIFT 20
23#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
24#define HPAGE_MASK (~(HPAGE_SIZE - 1))
25#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
26
27#define ARCH_HAS_SETCLEAR_HUGE_PTE
28#define ARCH_HAS_HUGE_PTE_TYPE
29#define ARCH_HAS_PREPARE_HUGEPAGE
30#define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
31
22#include <asm/setup.h> 32#include <asm/setup.h>
23#ifndef __ASSEMBLY__ 33#ifndef __ASSEMBLY__
24 34
25static inline void clear_page(void *page) 35static inline void clear_page(void *page)
26{ 36{
27 register unsigned long reg1 asm ("1") = 0; 37 if (MACHINE_HAS_PFMF) {
28 register void *reg2 asm ("2") = page; 38 asm volatile(
29 register unsigned long reg3 asm ("3") = 4096; 39 " .insn rre,0xb9af0000,%0,%1"
30 asm volatile( 40 : : "d" (0x10000), "a" (page) : "memory", "cc");
31 " mvcl 2,0" 41 } else {
32 : "+d" (reg2), "+d" (reg3) : "d" (reg1) : "memory", "cc"); 42 register unsigned long reg1 asm ("1") = 0;
43 register void *reg2 asm ("2") = page;
44 register unsigned long reg3 asm ("3") = 4096;
45 asm volatile(
46 " mvcl 2,0"
47 : "+d" (reg2), "+d" (reg3) : "d" (reg1)
48 : "memory", "cc");
49 }
33} 50}
34 51
35static inline void copy_page(void *to, void *from) 52static inline void copy_page(void *to, void *from)
@@ -108,26 +125,6 @@ page_get_storage_key(unsigned long addr)
108 return skey; 125 return skey;
109} 126}
110 127
111extern unsigned long max_pfn;
112
113static inline int pfn_valid(unsigned long pfn)
114{
115 unsigned long dummy;
116 int ccode;
117
118 if (pfn >= max_pfn)
119 return 0;
120
121 asm volatile(
122 " lra %0,0(%2)\n"
123 " ipm %1\n"
124 " srl %1,28\n"
125 : "=d" (dummy), "=d" (ccode)
126 : "a" (pfn << PAGE_SHIFT)
127 : "cc");
128 return !ccode;
129}
130
131#endif /* !__ASSEMBLY__ */ 128#endif /* !__ASSEMBLY__ */
132 129
133/* to align the pointer to the (next) page boundary */ 130/* to align the pointer to the (next) page boundary */
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h
index f8347ce9c5a1..c7f4f8e3e297 100644
--- a/include/asm-s390/pgtable.h
+++ b/include/asm-s390/pgtable.h
@@ -129,7 +129,7 @@ extern char empty_zero_page[PAGE_SIZE];
129#define VMEM_MAX_PAGES ((VMEM_MAP_END - VMALLOC_END) / sizeof(struct page)) 129#define VMEM_MAX_PAGES ((VMEM_MAP_END - VMALLOC_END) / sizeof(struct page))
130#define VMEM_MAX_PFN min(VMALLOC_START >> PAGE_SHIFT, VMEM_MAX_PAGES) 130#define VMEM_MAX_PFN min(VMALLOC_START >> PAGE_SHIFT, VMEM_MAX_PAGES)
131#define VMEM_MAX_PHYS ((VMEM_MAX_PFN << PAGE_SHIFT) & ~((16 << 20) - 1)) 131#define VMEM_MAX_PHYS ((VMEM_MAX_PFN << PAGE_SHIFT) & ~((16 << 20) - 1))
132#define VMEM_MAP ((struct page *) VMALLOC_END) 132#define vmemmap ((struct page *) VMALLOC_END)
133 133
134/* 134/*
135 * A 31 bit pagetable entry of S390 has following format: 135 * A 31 bit pagetable entry of S390 has following format:
@@ -234,6 +234,15 @@ extern char empty_zero_page[PAGE_SIZE];
234#define _PAGE_TYPE_EX_RW 0x002 234#define _PAGE_TYPE_EX_RW 0x002
235 235
236/* 236/*
237 * Only four types for huge pages, using the invalid bit and protection bit
238 * of a segment table entry.
239 */
240#define _HPAGE_TYPE_EMPTY 0x020 /* _SEGMENT_ENTRY_INV */
241#define _HPAGE_TYPE_NONE 0x220
242#define _HPAGE_TYPE_RO 0x200 /* _SEGMENT_ENTRY_RO */
243#define _HPAGE_TYPE_RW 0x000
244
245/*
237 * PTE type bits are rather complicated. handle_pte_fault uses pte_present, 246 * PTE type bits are rather complicated. handle_pte_fault uses pte_present,
238 * pte_none and pte_file to find out the pte type WITHOUT holding the page 247 * pte_none and pte_file to find out the pte type WITHOUT holding the page
239 * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to 248 * table lock. ptep_clear_flush on the other hand uses ptep_clear_flush to
@@ -325,6 +334,9 @@ extern char empty_zero_page[PAGE_SIZE];
325#define _SEGMENT_ENTRY (0) 334#define _SEGMENT_ENTRY (0)
326#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV) 335#define _SEGMENT_ENTRY_EMPTY (_SEGMENT_ENTRY_INV)
327 336
337#define _SEGMENT_ENTRY_LARGE 0x400 /* STE-format control, large page */
338#define _SEGMENT_ENTRY_CO 0x100 /* change-recording override */
339
328#endif /* __s390x__ */ 340#endif /* __s390x__ */
329 341
330/* 342/*
@@ -1063,8 +1075,8 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
1063 1075
1064#define kern_addr_valid(addr) (1) 1076#define kern_addr_valid(addr) (1)
1065 1077
1066extern int add_shared_memory(unsigned long start, unsigned long size); 1078extern int vmem_add_mapping(unsigned long start, unsigned long size);
1067extern int remove_shared_memory(unsigned long start, unsigned long size); 1079extern int vmem_remove_mapping(unsigned long start, unsigned long size);
1068extern int s390_enable_sie(void); 1080extern int s390_enable_sie(void);
1069 1081
1070/* 1082/*
@@ -1072,9 +1084,6 @@ extern int s390_enable_sie(void);
1072 */ 1084 */
1073#define pgtable_cache_init() do { } while (0) 1085#define pgtable_cache_init() do { } while (0)
1074 1086
1075#define __HAVE_ARCH_MEMMAP_INIT
1076extern void memmap_init(unsigned long, int, unsigned long, unsigned long);
1077
1078#include <asm-generic/pgtable.h> 1087#include <asm-generic/pgtable.h>
1079 1088
1080#endif /* _S390_PAGE_H */ 1089#endif /* _S390_PAGE_H */
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h
index 8eaf343a12a8..a00f79dd323b 100644
--- a/include/asm-s390/processor.h
+++ b/include/asm-s390/processor.h
@@ -172,16 +172,7 @@ extern unsigned long thread_saved_pc(struct task_struct *t);
172 */ 172 */
173extern void task_show_regs(struct seq_file *m, struct task_struct *task); 173extern void task_show_regs(struct seq_file *m, struct task_struct *task);
174 174
175extern void show_registers(struct pt_regs *regs);
176extern void show_code(struct pt_regs *regs); 175extern void show_code(struct pt_regs *regs);
177extern void show_trace(struct task_struct *task, unsigned long *sp);
178#ifdef CONFIG_64BIT
179extern void show_last_breaking_event(struct pt_regs *regs);
180#else
181static inline void show_last_breaking_event(struct pt_regs *regs)
182{
183}
184#endif
185 176
186unsigned long get_wchan(struct task_struct *p); 177unsigned long get_wchan(struct task_struct *p);
187#define task_pt_regs(tsk) ((struct pt_regs *) \ 178#define task_pt_regs(tsk) ((struct pt_regs *) \
diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h
index 61f6952f2e35..441d7c260857 100644
--- a/include/asm-s390/ptrace.h
+++ b/include/asm-s390/ptrace.h
@@ -463,8 +463,6 @@ struct user_regs_struct
463}; 463};
464 464
465#ifdef __KERNEL__ 465#ifdef __KERNEL__
466#define __ARCH_SYS_PTRACE 1
467
468/* 466/*
469 * These are defined as per linux/ptrace.h, which see. 467 * These are defined as per linux/ptrace.h, which see.
470 */ 468 */
diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h
index 4b8ff55f680e..11240342a0f4 100644
--- a/include/asm-s390/qdio.h
+++ b/include/asm-s390/qdio.h
@@ -127,6 +127,7 @@ extern int do_QDIO(struct ccw_device*, unsigned int flags,
127 unsigned int qidx,unsigned int count, 127 unsigned int qidx,unsigned int count,
128 struct qdio_buffer *buffers); 128 struct qdio_buffer *buffers);
129 129
130extern int qdio_get_ssqd_pct(struct ccw_device*);
130extern int qdio_synchronize(struct ccw_device*, unsigned int flags, 131extern int qdio_synchronize(struct ccw_device*, unsigned int flags,
131 unsigned int queue_number); 132 unsigned int queue_number);
132 133
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h
index aaf4b518b940..ba69674012a7 100644
--- a/include/asm-s390/setup.h
+++ b/include/asm-s390/setup.h
@@ -59,23 +59,42 @@ extern unsigned int s390_noexec;
59 */ 59 */
60extern unsigned long machine_flags; 60extern unsigned long machine_flags;
61 61
62#define MACHINE_IS_VM (machine_flags & 1) 62#define MACHINE_FLAG_VM (1UL << 0)
63#define MACHINE_IS_P390 (machine_flags & 4) 63#define MACHINE_FLAG_IEEE (1UL << 1)
64#define MACHINE_HAS_MVPG (machine_flags & 16) 64#define MACHINE_FLAG_P390 (1UL << 2)
65#define MACHINE_IS_KVM (machine_flags & 64) 65#define MACHINE_FLAG_CSP (1UL << 3)
66#define MACHINE_HAS_IDTE (machine_flags & 128) 66#define MACHINE_FLAG_MVPG (1UL << 4)
67#define MACHINE_HAS_DIAG9C (machine_flags & 256) 67#define MACHINE_FLAG_DIAG44 (1UL << 5)
68#define MACHINE_FLAG_IDTE (1UL << 6)
69#define MACHINE_FLAG_DIAG9C (1UL << 7)
70#define MACHINE_FLAG_MVCOS (1UL << 8)
71#define MACHINE_FLAG_KVM (1UL << 9)
72#define MACHINE_FLAG_HPAGE (1UL << 10)
73#define MACHINE_FLAG_PFMF (1UL << 11)
74
75#define MACHINE_IS_VM (machine_flags & MACHINE_FLAG_VM)
76#define MACHINE_IS_KVM (machine_flags & MACHINE_FLAG_KVM)
77#define MACHINE_IS_P390 (machine_flags & MACHINE_FLAG_P390)
78#define MACHINE_HAS_DIAG9C (machine_flags & MACHINE_FLAG_DIAG9C)
68 79
69#ifndef __s390x__ 80#ifndef __s390x__
70#define MACHINE_HAS_IEEE (machine_flags & 2) 81#define MACHINE_HAS_IEEE (machine_flags & MACHINE_FLAG_IEEE)
71#define MACHINE_HAS_CSP (machine_flags & 8) 82#define MACHINE_HAS_CSP (machine_flags & MACHINE_FLAG_CSP)
83#define MACHINE_HAS_IDTE (0)
72#define MACHINE_HAS_DIAG44 (1) 84#define MACHINE_HAS_DIAG44 (1)
85#define MACHINE_HAS_MVPG (machine_flags & MACHINE_FLAG_MVPG)
73#define MACHINE_HAS_MVCOS (0) 86#define MACHINE_HAS_MVCOS (0)
87#define MACHINE_HAS_HPAGE (0)
88#define MACHINE_HAS_PFMF (0)
74#else /* __s390x__ */ 89#else /* __s390x__ */
75#define MACHINE_HAS_IEEE (1) 90#define MACHINE_HAS_IEEE (1)
76#define MACHINE_HAS_CSP (1) 91#define MACHINE_HAS_CSP (1)
77#define MACHINE_HAS_DIAG44 (machine_flags & 32) 92#define MACHINE_HAS_IDTE (machine_flags & MACHINE_FLAG_IDTE)
78#define MACHINE_HAS_MVCOS (machine_flags & 512) 93#define MACHINE_HAS_DIAG44 (machine_flags & MACHINE_FLAG_DIAG44)
94#define MACHINE_HAS_MVPG (1)
95#define MACHINE_HAS_MVCOS (machine_flags & MACHINE_FLAG_MVCOS)
96#define MACHINE_HAS_HPAGE (machine_flags & MACHINE_FLAG_HPAGE)
97#define MACHINE_HAS_PFMF (machine_flags & MACHINE_FLAG_PFMF)
79#endif /* __s390x__ */ 98#endif /* __s390x__ */
80 99
81#define MACHINE_HAS_SCLP (!MACHINE_IS_P390) 100#define MACHINE_HAS_SCLP (!MACHINE_IS_P390)
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h
index 6f3821a6a902..ae89cf2478fc 100644
--- a/include/asm-s390/smp.h
+++ b/include/asm-s390/smp.h
@@ -19,6 +19,7 @@
19#include <asm/lowcore.h> 19#include <asm/lowcore.h>
20#include <asm/sigp.h> 20#include <asm/sigp.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
22#include <asm/system.h>
22 23
23/* 24/*
24 s390 specific smp.c headers 25 s390 specific smp.c headers
@@ -53,10 +54,7 @@ extern void machine_power_off_smp(void);
53 54
54static inline __u16 hard_smp_processor_id(void) 55static inline __u16 hard_smp_processor_id(void)
55{ 56{
56 __u16 cpu_address; 57 return stap();
57
58 asm volatile("stap %0" : "=m" (cpu_address));
59 return cpu_address;
60} 58}
61 59
62/* 60/*
@@ -108,5 +106,11 @@ static inline void smp_send_stop(void)
108#define smp_cpu_not_running(cpu) 1 106#define smp_cpu_not_running(cpu) 1
109#endif 107#endif
110 108
109#ifdef CONFIG_HOTPLUG_CPU
110extern int smp_rescan_cpus(void);
111#else
112static inline int smp_rescan_cpus(void) { return 0; }
113#endif
114
111extern union save_area *zfcpdump_save_areas[NR_CPUS + 1]; 115extern union save_area *zfcpdump_save_areas[NR_CPUS + 1];
112#endif 116#endif
diff --git a/include/asm-s390/sparsemem.h b/include/asm-s390/sparsemem.h
new file mode 100644
index 000000000000..06dfdab6c0e8
--- /dev/null
+++ b/include/asm-s390/sparsemem.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_S390_SPARSEMEM_H
2#define _ASM_S390_SPARSEMEM_H
3
4#define SECTION_SIZE_BITS 25
5
6#ifdef CONFIG_64BIT
7
8#define MAX_PHYSADDR_BITS 42
9#define MAX_PHYSMEM_BITS 42
10
11#else
12
13#define MAX_PHYSADDR_BITS 31
14#define MAX_PHYSMEM_BITS 31
15
16#endif /* CONFIG_64BIT */
17
18#endif /* _ASM_S390_SPARSEMEM_H */
diff --git a/include/asm-s390/sysinfo.h b/include/asm-s390/sysinfo.h
index abe10ae15e46..79d01343f8b0 100644
--- a/include/asm-s390/sysinfo.h
+++ b/include/asm-s390/sysinfo.h
@@ -11,6 +11,9 @@
11 * Christian Borntraeger <borntraeger@de.ibm.com> 11 * Christian Borntraeger <borntraeger@de.ibm.com>
12 */ 12 */
13 13
14#ifndef __ASM_S390_SYSINFO_H
15#define __ASM_S390_SYSINFO_H
16
14struct sysinfo_1_1_1 { 17struct sysinfo_1_1_1 {
15 char reserved_0[32]; 18 char reserved_0[32];
16 char manufacturer[16]; 19 char manufacturer[16];
@@ -114,3 +117,5 @@ static inline int stsi(void *sysinfo, int fc, int sel1, int sel2)
114 : "cc", "memory"); 117 : "cc", "memory");
115 return r0; 118 return r0;
116} 119}
120
121#endif /* __ASM_S390_SYSINFO_H */
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index 92098df4d6e3..c819ae25a842 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -16,6 +16,7 @@
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/setup.h> 17#include <asm/setup.h>
18#include <asm/processor.h> 18#include <asm/processor.h>
19#include <asm/lowcore.h>
19 20
20#ifdef __KERNEL__ 21#ifdef __KERNEL__
21 22
@@ -422,6 +423,23 @@ extern void smp_ctl_clear_bit(int cr, int bit);
422 423
423#endif /* CONFIG_SMP */ 424#endif /* CONFIG_SMP */
424 425
426static inline unsigned int stfl(void)
427{
428 asm volatile(
429 " .insn s,0xb2b10000,0(0)\n" /* stfl */
430 "0:\n"
431 EX_TABLE(0b,0b));
432 return S390_lowcore.stfl_fac_list;
433}
434
435static inline unsigned short stap(void)
436{
437 unsigned short cpu_address;
438
439 asm volatile("stap %0" : "=m" (cpu_address));
440 return cpu_address;
441}
442
425extern void (*_machine_restart)(char *command); 443extern void (*_machine_restart)(char *command);
426extern void (*_machine_halt)(void); 444extern void (*_machine_halt)(void);
427extern void (*_machine_power_off)(void); 445extern void (*_machine_power_off)(void);
diff --git a/include/asm-s390/thread_info.h b/include/asm-s390/thread_info.h
index 0a518915bf90..99bbed99a3b2 100644
--- a/include/asm-s390/thread_info.h
+++ b/include/asm-s390/thread_info.h
@@ -89,7 +89,6 @@ static inline struct thread_info *current_thread_info(void)
89 * thread information flags bit numbers 89 * thread information flags bit numbers
90 */ 90 */
91#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 91#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
92#define TIF_RESTORE_SIGMASK 1 /* restore signal mask in do_signal() */
93#define TIF_SIGPENDING 2 /* signal pending */ 92#define TIF_SIGPENDING 2 /* signal pending */
94#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 93#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
95#define TIF_RESTART_SVC 4 /* restart svc with new svc number */ 94#define TIF_RESTART_SVC 4 /* restart svc with new svc number */
@@ -101,6 +100,7 @@ static inline struct thread_info *current_thread_info(void)
101 TIF_NEED_RESCHED */ 100 TIF_NEED_RESCHED */
102#define TIF_31BIT 18 /* 32bit process */ 101#define TIF_31BIT 18 /* 32bit process */
103#define TIF_MEMDIE 19 102#define TIF_MEMDIE 19
103#define TIF_RESTORE_SIGMASK 20 /* restore signal mask in do_signal() */
104 104
105#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 105#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
106#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 106#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
diff --git a/include/asm-s390/tlbflush.h b/include/asm-s390/tlbflush.h
index 9e57a93d7de1..d60394b9745e 100644
--- a/include/asm-s390/tlbflush.h
+++ b/include/asm-s390/tlbflush.h
@@ -2,6 +2,7 @@
2#define _S390_TLBFLUSH_H 2#define _S390_TLBFLUSH_H
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <linux/sched.h>
5#include <asm/processor.h> 6#include <asm/processor.h>
6#include <asm/pgalloc.h> 7#include <asm/pgalloc.h>
7 8
diff --git a/include/asm-s390/topology.h b/include/asm-s390/topology.h
index 8e97b06f298a..d96c91643458 100644
--- a/include/asm-s390/topology.h
+++ b/include/asm-s390/topology.h
@@ -7,6 +7,10 @@
7 7
8cpumask_t cpu_coregroup_map(unsigned int cpu); 8cpumask_t cpu_coregroup_map(unsigned int cpu);
9 9
10extern cpumask_t cpu_core_map[NR_CPUS];
11
12#define topology_core_siblings(cpu) (cpu_core_map[cpu])
13
10int topology_set_cpu_management(int fc); 14int topology_set_cpu_management(int fc);
11void topology_schedule_update(void); 15void topology_schedule_update(void);
12 16
diff --git a/include/asm-sh/futex.h b/include/asm-sh/futex.h
index 74ed3681d33c..68256ec5fa35 100644
--- a/include/asm-sh/futex.h
+++ b/include/asm-sh/futex.h
@@ -4,8 +4,8 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7#include <asm/errno.h> 8#include <asm/errno.h>
8#include <asm/uaccess.h>
9 9
10/* XXX: UP variants, fix for SH-4A and SMP.. */ 10/* XXX: UP variants, fix for SH-4A and SMP.. */
11#include <asm/futex-irq.h> 11#include <asm/futex-irq.h>
diff --git a/include/asm-sparc/head.h b/include/asm-sparc/head.h
index fcdba5116339..e6532c3e09c9 100644
--- a/include/asm-sparc/head.h
+++ b/include/asm-sparc/head.h
@@ -52,6 +52,17 @@
52 nop; \ 52 nop; \
53 nop; 53 nop;
54 54
55#ifdef CONFIG_KGDB
56#define KGDB_TRAP(num) \
57 b kgdb_trap_low; \
58 rd %psr,%l0; \
59 nop; \
60 nop;
61#else
62#define KGDB_TRAP(num) \
63 BAD_TRAP(num)
64#endif
65
55/* The Get Condition Codes software trap for userland. */ 66/* The Get Condition Codes software trap for userland. */
56#define GETCC_TRAP \ 67#define GETCC_TRAP \
57 b getcc_trap_handler; mov %psr, %l0; nop; nop; 68 b getcc_trap_handler; mov %psr, %l0; nop; nop;
diff --git a/include/asm-sparc/kgdb.h b/include/asm-sparc/kgdb.h
index d120adfb429f..b6ef301d05bf 100644
--- a/include/asm-sparc/kgdb.h
+++ b/include/asm-sparc/kgdb.h
@@ -1,94 +1,38 @@
1/* $Id: kgdb.h,v 1.8 1998/01/07 06:33:44 baccala Exp $
2 * kgdb.h: Defines and declarations for serial line source level
3 * remote debugging of the Linux kernel using gdb.
4 *
5 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6 */
7#ifndef _SPARC_KGDB_H 1#ifndef _SPARC_KGDB_H
8#define _SPARC_KGDB_H 2#define _SPARC_KGDB_H
9 3
10#ifndef __ASSEMBLY__ 4#ifdef CONFIG_SPARC32
11/* To init the kgdb engine. */ 5#define BUFMAX 2048
12extern void set_debug_traps(void); 6#else
13 7#define BUFMAX 4096
14/* To enter the debugger explicitly. */ 8#endif
15extern void breakpoint(void); 9
16 10enum regnames {
17/* For convenience we define the format of a kgdb trap breakpoint 11 GDB_G0, GDB_G1, GDB_G2, GDB_G3, GDB_G4, GDB_G5, GDB_G6, GDB_G7,
18 * frame here also. 12 GDB_O0, GDB_O1, GDB_O2, GDB_O3, GDB_O4, GDB_O5, GDB_SP, GDB_O7,
19 */ 13 GDB_L0, GDB_L1, GDB_L2, GDB_L3, GDB_L4, GDB_L5, GDB_L6, GDB_L7,
20struct kgdb_frame { 14 GDB_I0, GDB_I1, GDB_I2, GDB_I3, GDB_I4, GDB_I5, GDB_FP, GDB_I7,
21 unsigned long globals[8]; 15 GDB_F0,
22 unsigned long outs[8]; 16 GDB_F31 = GDB_F0 + 31,
23 unsigned long locals[8]; 17#ifdef CONFIG_SPARC32
24 unsigned long ins[8]; 18 GDB_Y, GDB_PSR, GDB_WIM, GDB_TBR, GDB_PC, GDB_NPC,
25 unsigned long fpregs[32]; 19 GDB_FSR, GDB_CSR,
26 unsigned long y; 20#else
27 unsigned long psr; 21 GDB_F32 = GDB_F0 + 32,
28 unsigned long wim; 22 GDB_F62 = GDB_F32 + 15,
29 unsigned long tbr; 23 GDB_PC, GDB_NPC, GDB_STATE, GDB_FSR, GDB_FPRS, GDB_Y,
30 unsigned long pc; 24#endif
31 unsigned long npc;
32 unsigned long fpsr;
33 unsigned long cpsr;
34}; 25};
35#endif /* !(__ASSEMBLY__) */
36
37/* Macros for assembly usage of the kgdb breakpoint frame. */
38#define KGDB_G0 0x000
39#define KGDB_G1 0x004
40#define KGDB_G2 0x008
41#define KGDB_G4 0x010
42#define KGDB_G6 0x018
43#define KGDB_I0 0x020
44#define KGDB_I2 0x028
45#define KGDB_I4 0x030
46#define KGDB_I6 0x038
47#define KGDB_Y 0x100
48#define KGDB_PSR 0x104
49#define KGDB_WIM 0x108
50#define KGDB_TBR 0x10c
51#define KGDB_PC 0x110
52#define KGDB_NPC 0x114
53
54#define SAVE_KGDB_GLOBALS(reg) \
55 std %g0, [%reg + STACKFRAME_SZ + KGDB_G0]; \
56 std %g2, [%reg + STACKFRAME_SZ + KGDB_G2]; \
57 std %g4, [%reg + STACKFRAME_SZ + KGDB_G4]; \
58 std %g6, [%reg + STACKFRAME_SZ + KGDB_G6];
59
60#define SAVE_KGDB_INS(reg) \
61 std %i0, [%reg + STACKFRAME_SZ + KGDB_I0]; \
62 std %i2, [%reg + STACKFRAME_SZ + KGDB_I2]; \
63 std %i4, [%reg + STACKFRAME_SZ + KGDB_I4]; \
64 std %i6, [%reg + STACKFRAME_SZ + KGDB_I6];
65
66#define SAVE_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \
67 st %reg_y, [%reg + STACKFRAME_SZ + KGDB_Y]; \
68 st %reg_psr, [%reg + STACKFRAME_SZ + KGDB_PSR]; \
69 st %reg_wim, [%reg + STACKFRAME_SZ + KGDB_WIM]; \
70 st %reg_tbr, [%reg + STACKFRAME_SZ + KGDB_TBR]; \
71 st %reg_pc, [%reg + STACKFRAME_SZ + KGDB_PC]; \
72 st %reg_npc, [%reg + STACKFRAME_SZ + KGDB_NPC];
73 26
74#define LOAD_KGDB_GLOBALS(reg) \ 27#ifdef CONFIG_SPARC32
75 ld [%reg + STACKFRAME_SZ + KGDB_G1], %g1; \ 28#define NUMREGBYTES ((GDB_CSR + 1) * 4)
76 ldd [%reg + STACKFRAME_SZ + KGDB_G2], %g2; \ 29#else
77 ldd [%reg + STACKFRAME_SZ + KGDB_G4], %g4; \ 30#define NUMREGBYTES ((GDB_Y + 1) * 8)
78 ldd [%reg + STACKFRAME_SZ + KGDB_G6], %g6; 31#endif
79 32
80#define LOAD_KGDB_INS(reg) \ 33extern void arch_kgdb_breakpoint(void);
81 ldd [%reg + STACKFRAME_SZ + KGDB_I0], %i0; \
82 ldd [%reg + STACKFRAME_SZ + KGDB_I2], %i2; \
83 ldd [%reg + STACKFRAME_SZ + KGDB_I4], %i4; \
84 ldd [%reg + STACKFRAME_SZ + KGDB_I6], %i6;
85 34
86#define LOAD_KGDB_SREGS(reg, reg_y, reg_psr, reg_wim, reg_tbr, reg_pc, reg_npc) \ 35#define BREAK_INSTR_SIZE 4
87 ld [%reg + STACKFRAME_SZ + KGDB_Y], %reg_y; \ 36#define CACHE_FLUSH_IS_SAFE 1
88 ld [%reg + STACKFRAME_SZ + KGDB_PSR], %reg_psr; \
89 ld [%reg + STACKFRAME_SZ + KGDB_WIM], %reg_wim; \
90 ld [%reg + STACKFRAME_SZ + KGDB_TBR], %reg_tbr; \
91 ld [%reg + STACKFRAME_SZ + KGDB_PC], %reg_pc; \
92 ld [%reg + STACKFRAME_SZ + KGDB_NPC], %reg_npc;
93 37
94#endif /* !(_SPARC_KGDB_H) */ 38#endif /* _SPARC_KGDB_H */
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index b3f492208fd2..e6d561599726 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -51,13 +51,11 @@ void smp_bogo(struct seq_file *);
51void smp_info(struct seq_file *); 51void smp_info(struct seq_file *);
52 52
53BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) 53BTFIXUPDEF_CALL(void, smp_cross_call, smpfunc_t, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long)
54BTFIXUPDEF_CALL(void, smp_message_pass, int, int, unsigned long, int)
55BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void) 54BTFIXUPDEF_CALL(int, __hard_smp_processor_id, void)
56BTFIXUPDEF_BLACKBOX(hard_smp_processor_id) 55BTFIXUPDEF_BLACKBOX(hard_smp_processor_id)
57BTFIXUPDEF_BLACKBOX(load_current) 56BTFIXUPDEF_BLACKBOX(load_current)
58 57
59#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5) 58#define smp_cross_call(func,arg1,arg2,arg3,arg4,arg5) BTFIXUP_CALL(smp_cross_call)(func,arg1,arg2,arg3,arg4,arg5)
60#define smp_message_pass(target,msg,data,wait) BTFIXUP_CALL(smp_message_pass)(target,msg,data,wait)
61 59
62static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); } 60static inline void xc0(smpfunc_t func) { smp_cross_call(func, 0, 0, 0, 0, 0); }
63static inline void xc1(smpfunc_t func, unsigned long arg1) 61static inline void xc1(smpfunc_t func, unsigned long arg1)
diff --git a/include/asm-sparc/system.h b/include/asm-sparc/system.h
index 4e08210cd4c2..b4b024445fc9 100644
--- a/include/asm-sparc/system.h
+++ b/include/asm-sparc/system.h
@@ -94,6 +94,8 @@ extern void fpsave(unsigned long *fpregs, unsigned long *fsr,
94 } while(0) 94 } while(0)
95#endif 95#endif
96 96
97extern void flushw_all(void);
98
97/* 99/*
98 * Flush windows so that the VM switch which follows 100 * Flush windows so that the VM switch which follows
99 * would not pull the stack from under us. 101 * would not pull the stack from under us.
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index df1097d6ffbe..d8378935ae90 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -2,9 +2,9 @@
2#define _SPARC64_FUTEX_H 2#define _SPARC64_FUTEX_H
3 3
4#include <linux/futex.h> 4#include <linux/futex.h>
5#include <linux/uaccess.h>
5#include <asm/errno.h> 6#include <asm/errno.h>
6#include <asm/system.h> 7#include <asm/system.h>
7#include <asm/uaccess.h>
8 8
9#define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \ 9#define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \
10 __asm__ __volatile__( \ 10 __asm__ __volatile__( \
diff --git a/include/asm-sparc64/kgdb.h b/include/asm-sparc64/kgdb.h
new file mode 100644
index 000000000000..aa6532fd3a13
--- /dev/null
+++ b/include/asm-sparc64/kgdb.h
@@ -0,0 +1 @@
#include <asm-sparc/kgdb.h>
diff --git a/include/asm-sparc64/pil.h b/include/asm-sparc64/pil.h
index 72927749aebf..2f5d126f7163 100644
--- a/include/asm-sparc64/pil.h
+++ b/include/asm-sparc64/pil.h
@@ -19,11 +19,4 @@
19#define PIL_SMP_CTX_NEW_VERSION 4 19#define PIL_SMP_CTX_NEW_VERSION 4
20#define PIL_DEVICE_IRQ 5 20#define PIL_DEVICE_IRQ 5
21 21
22#ifndef __ASSEMBLY__
23#define PIL_RESERVED(PIL) ((PIL) == PIL_SMP_CALL_FUNC || \
24 (PIL) == PIL_SMP_RECEIVE_SIGNAL || \
25 (PIL) == PIL_SMP_CAPTURE || \
26 (PIL) == PIL_SMP_CTX_NEW_VERSION)
27#endif
28
29#endif /* !(_SPARC64_PIL_H) */ 22#endif /* !(_SPARC64_PIL_H) */
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index 53eae091a171..6897ac31be41 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -180,12 +180,13 @@ do { if (test_thread_flag(TIF_PERFCTR)) { \
180 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \ 180 "ldx [%%sp + 2047 + 0x70], %%i6\n\t" \
181 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \ 181 "ldx [%%sp + 2047 + 0x78], %%i7\n\t" \
182 "ldx [%%g6 + %9], %%g4\n\t" \ 182 "ldx [%%g6 + %9], %%g4\n\t" \
183 "brz,pt %%o7, 1f\n\t" \ 183 "brz,pt %%o7, switch_to_pc\n\t" \
184 " mov %%g7, %0\n\t" \ 184 " mov %%g7, %0\n\t" \
185 "sethi %%hi(ret_from_syscall), %%g1\n\t" \ 185 "sethi %%hi(ret_from_syscall), %%g1\n\t" \
186 "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \ 186 "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \
187 " nop\n\t" \ 187 " nop\n\t" \
188 "1:\n\t" \ 188 ".globl switch_to_pc\n\t" \
189 "switch_to_pc:\n\t" \
189 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \ 190 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \
190 "=r" (__local_per_cpu_offset) \ 191 "=r" (__local_per_cpu_offset) \
191 : "0" (task_thread_info(next)), \ 192 : "0" (task_thread_info(next)), \
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
index d3cc4eff39a6..1b55538b944f 100644
--- a/include/asm-sparc64/ttable.h
+++ b/include/asm-sparc64/ttable.h
@@ -175,6 +175,12 @@
175#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl) 175#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
176#endif 176#endif
177 177
178#ifdef CONFIG_KGDB
179#define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl)
180#else
181#define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
182#endif
183
178#define SUN4V_ITSB_MISS \ 184#define SUN4V_ITSB_MISS \
179 ldxa [%g0] ASI_SCRATCHPAD, %g2; \ 185 ldxa [%g0] ASI_SCRATCHPAD, %g2; \
180 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \ 186 ldx [%g2 + HV_FAULT_I_ADDR_OFFSET], %g4; \
diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h
index ac0fbf24d722..e7a76b37b333 100644
--- a/include/asm-x86/futex.h
+++ b/include/asm-x86/futex.h
@@ -4,12 +4,12 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/futex.h> 6#include <linux/futex.h>
7#include <linux/uaccess.h>
7 8
8#include <asm/asm.h> 9#include <asm/asm.h>
9#include <asm/errno.h> 10#include <asm/errno.h>
10#include <asm/processor.h> 11#include <asm/processor.h>
11#include <asm/system.h> 12#include <asm/system.h>
12#include <asm/uaccess.h>
13 13
14#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \ 14#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15 asm volatile("1:\t" insn "\n" \ 15 asm volatile("1:\t" insn "\n" \
diff --git a/include/asm-x86/thread_info_32.h b/include/asm-x86/thread_info_32.h
index 531859962096..b6338829d1a8 100644
--- a/include/asm-x86/thread_info_32.h
+++ b/include/asm-x86/thread_info_32.h
@@ -131,7 +131,6 @@ static inline struct thread_info *current_thread_info(void)
131#define TIF_SYSCALL_EMU 5 /* syscall emulation active */ 131#define TIF_SYSCALL_EMU 5 /* syscall emulation active */
132#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ 132#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */
133#define TIF_SECCOMP 7 /* secure computing */ 133#define TIF_SECCOMP 7 /* secure computing */
134#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
135#define TIF_HRTICK_RESCHED 9 /* reprogram hrtick timer */ 134#define TIF_HRTICK_RESCHED 9 /* reprogram hrtick timer */
136#define TIF_MEMDIE 16 135#define TIF_MEMDIE 16
137#define TIF_DEBUG 17 /* uses debug registers */ 136#define TIF_DEBUG 17 /* uses debug registers */
@@ -151,7 +150,6 @@ static inline struct thread_info *current_thread_info(void)
151#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU) 150#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
152#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 151#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
153#define _TIF_SECCOMP (1 << TIF_SECCOMP) 152#define _TIF_SECCOMP (1 << TIF_SECCOMP)
154#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
155#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED) 153#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED)
156#define _TIF_DEBUG (1 << TIF_DEBUG) 154#define _TIF_DEBUG (1 << TIF_DEBUG)
157#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP) 155#define _TIF_IO_BITMAP (1 << TIF_IO_BITMAP)
@@ -188,9 +186,20 @@ static inline struct thread_info *current_thread_info(void)
188 this quantum (SMP) */ 186 this quantum (SMP) */
189#define TS_POLLING 0x0002 /* True if in idle loop 187#define TS_POLLING 0x0002 /* True if in idle loop
190 and not sleeping */ 188 and not sleeping */
189#define TS_RESTORE_SIGMASK 0x0004 /* restore signal mask in do_signal() */
191 190
192#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) 191#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
193 192
193#ifndef __ASSEMBLY__
194#define HAVE_SET_RESTORE_SIGMASK 1
195static inline void set_restore_sigmask(void)
196{
197 struct thread_info *ti = current_thread_info();
198 ti->status |= TS_RESTORE_SIGMASK;
199 set_bit(TIF_SIGPENDING, &ti->flags);
200}
201#endif /* !__ASSEMBLY__ */
202
194#endif /* __KERNEL__ */ 203#endif /* __KERNEL__ */
195 204
196#endif /* _ASM_THREAD_INFO_H */ 205#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-x86/thread_info_64.h b/include/asm-x86/thread_info_64.h
index ed664e874dec..cb69f70abba1 100644
--- a/include/asm-x86/thread_info_64.h
+++ b/include/asm-x86/thread_info_64.h
@@ -109,7 +109,6 @@ static inline struct thread_info *stack_thread_info(void)
109#define TIF_IRET 5 /* force IRET */ 109#define TIF_IRET 5 /* force IRET */
110#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 110#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
111#define TIF_SECCOMP 8 /* secure computing */ 111#define TIF_SECCOMP 8 /* secure computing */
112#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
113#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */ 112#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */
114#define TIF_HRTICK_RESCHED 11 /* reprogram hrtick timer */ 113#define TIF_HRTICK_RESCHED 11 /* reprogram hrtick timer */
115/* 16 free */ 114/* 16 free */
@@ -133,7 +132,6 @@ static inline struct thread_info *stack_thread_info(void)
133#define _TIF_IRET (1 << TIF_IRET) 132#define _TIF_IRET (1 << TIF_IRET)
134#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 133#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
135#define _TIF_SECCOMP (1 << TIF_SECCOMP) 134#define _TIF_SECCOMP (1 << TIF_SECCOMP)
136#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
137#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY) 135#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)
138#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED) 136#define _TIF_HRTICK_RESCHED (1 << TIF_HRTICK_RESCHED)
139#define _TIF_IA32 (1 << TIF_IA32) 137#define _TIF_IA32 (1 << TIF_IA32)
@@ -178,9 +176,20 @@ static inline struct thread_info *stack_thread_info(void)
178#define TS_COMPAT 0x0002 /* 32bit syscall active */ 176#define TS_COMPAT 0x0002 /* 32bit syscall active */
179#define TS_POLLING 0x0004 /* true if in idle loop 177#define TS_POLLING 0x0004 /* true if in idle loop
180 and not sleeping */ 178 and not sleeping */
179#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
181 180
182#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING) 181#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
183 182
183#ifndef __ASSEMBLY__
184#define HAVE_SET_RESTORE_SIGMASK 1
185static inline void set_restore_sigmask(void)
186{
187 struct thread_info *ti = current_thread_info();
188 ti->status |= TS_RESTORE_SIGMASK;
189 set_bit(TIF_SIGPENDING, &ti->flags);
190}
191#endif /* !__ASSEMBLY__ */
192
184#endif /* __KERNEL__ */ 193#endif /* __KERNEL__ */
185 194
186#endif /* _ASM_THREAD_INFO_H */ 195#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 03e34547d489..661d90d6cf7c 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -30,8 +30,6 @@
30#ifndef _AGP_BACKEND_H 30#ifndef _AGP_BACKEND_H
31#define _AGP_BACKEND_H 1 31#define _AGP_BACKEND_H 1
32 32
33#ifdef __KERNEL__
34
35#ifndef TRUE 33#ifndef TRUE
36#define TRUE 1 34#define TRUE 1
37#endif 35#endif
@@ -111,5 +109,4 @@ extern struct agp_bridge_data *agp_backend_acquire(struct pci_dev *);
111extern void agp_backend_release(struct agp_bridge_data *); 109extern void agp_backend_release(struct agp_bridge_data *);
112extern void agp_flush_chipset(struct agp_bridge_data *); 110extern void agp_flush_chipset(struct agp_bridge_data *);
113 111
114#endif /* __KERNEL__ */
115#endif /* _AGP_BACKEND_H */ 112#endif /* _AGP_BACKEND_H */
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index b66fa2bdfd9c..0a24d5550eb3 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -11,9 +11,13 @@
11#include <linux/percpu_counter.h> 11#include <linux/percpu_counter.h>
12#include <linux/log2.h> 12#include <linux/log2.h>
13#include <linux/proportions.h> 13#include <linux/proportions.h>
14#include <linux/kernel.h>
15#include <linux/fs.h>
14#include <asm/atomic.h> 16#include <asm/atomic.h>
15 17
16struct page; 18struct page;
19struct device;
20struct dentry;
17 21
18/* 22/*
19 * Bits in backing_dev_info.state 23 * Bits in backing_dev_info.state
@@ -48,11 +52,26 @@ struct backing_dev_info {
48 52
49 struct prop_local_percpu completions; 53 struct prop_local_percpu completions;
50 int dirty_exceeded; 54 int dirty_exceeded;
55
56 unsigned int min_ratio;
57 unsigned int max_ratio, max_prop_frac;
58
59 struct device *dev;
60
61#ifdef CONFIG_DEBUG_FS
62 struct dentry *debug_dir;
63 struct dentry *debug_stats;
64#endif
51}; 65};
52 66
53int bdi_init(struct backing_dev_info *bdi); 67int bdi_init(struct backing_dev_info *bdi);
54void bdi_destroy(struct backing_dev_info *bdi); 68void bdi_destroy(struct backing_dev_info *bdi);
55 69
70int bdi_register(struct backing_dev_info *bdi, struct device *parent,
71 const char *fmt, ...);
72int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
73void bdi_unregister(struct backing_dev_info *bdi);
74
56static inline void __add_bdi_stat(struct backing_dev_info *bdi, 75static inline void __add_bdi_stat(struct backing_dev_info *bdi,
57 enum bdi_stat_item item, s64 amount) 76 enum bdi_stat_item item, s64 amount)
58{ 77{
@@ -116,6 +135,8 @@ static inline s64 bdi_stat_sum(struct backing_dev_info *bdi,
116 return sum; 135 return sum;
117} 136}
118 137
138extern void bdi_writeout_inc(struct backing_dev_info *bdi);
139
119/* 140/*
120 * maximal error of a stat counter. 141 * maximal error of a stat counter.
121 */ 142 */
@@ -128,24 +149,48 @@ static inline unsigned long bdi_stat_error(struct backing_dev_info *bdi)
128#endif 149#endif
129} 150}
130 151
152int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio);
153int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
154
131/* 155/*
132 * Flags in backing_dev_info::capability 156 * Flags in backing_dev_info::capability
133 * - The first two flags control whether dirty pages will contribute to the 157 *
134 * VM's accounting and whether writepages() should be called for dirty pages 158 * The first three flags control whether dirty pages will contribute to the
135 * (something that would not, for example, be appropriate for ramfs) 159 * VM's accounting and whether writepages() should be called for dirty pages
136 * - These flags let !MMU mmap() govern direct device mapping vs immediate 160 * (something that would not, for example, be appropriate for ramfs)
137 * copying more easily for MAP_PRIVATE, especially for ROM filesystems 161 *
162 * WARNING: these flags are closely related and should not normally be
163 * used separately. The BDI_CAP_NO_ACCT_AND_WRITEBACK combines these
164 * three flags into a single convenience macro.
165 *
166 * BDI_CAP_NO_ACCT_DIRTY: Dirty pages shouldn't contribute to accounting
167 * BDI_CAP_NO_WRITEBACK: Don't write pages back
168 * BDI_CAP_NO_ACCT_WB: Don't automatically account writeback pages
169 *
170 * These flags let !MMU mmap() govern direct device mapping vs immediate
171 * copying more easily for MAP_PRIVATE, especially for ROM filesystems.
172 *
173 * BDI_CAP_MAP_COPY: Copy can be mapped (MAP_PRIVATE)
174 * BDI_CAP_MAP_DIRECT: Can be mapped directly (MAP_SHARED)
175 * BDI_CAP_READ_MAP: Can be mapped for reading
176 * BDI_CAP_WRITE_MAP: Can be mapped for writing
177 * BDI_CAP_EXEC_MAP: Can be mapped for execution
138 */ 178 */
139#define BDI_CAP_NO_ACCT_DIRTY 0x00000001 /* Dirty pages shouldn't contribute to accounting */ 179#define BDI_CAP_NO_ACCT_DIRTY 0x00000001
140#define BDI_CAP_NO_WRITEBACK 0x00000002 /* Don't write pages back */ 180#define BDI_CAP_NO_WRITEBACK 0x00000002
141#define BDI_CAP_MAP_COPY 0x00000004 /* Copy can be mapped (MAP_PRIVATE) */ 181#define BDI_CAP_MAP_COPY 0x00000004
142#define BDI_CAP_MAP_DIRECT 0x00000008 /* Can be mapped directly (MAP_SHARED) */ 182#define BDI_CAP_MAP_DIRECT 0x00000008
143#define BDI_CAP_READ_MAP 0x00000010 /* Can be mapped for reading */ 183#define BDI_CAP_READ_MAP 0x00000010
144#define BDI_CAP_WRITE_MAP 0x00000020 /* Can be mapped for writing */ 184#define BDI_CAP_WRITE_MAP 0x00000020
145#define BDI_CAP_EXEC_MAP 0x00000040 /* Can be mapped for execution */ 185#define BDI_CAP_EXEC_MAP 0x00000040
186#define BDI_CAP_NO_ACCT_WB 0x00000080
187
146#define BDI_CAP_VMFLAGS \ 188#define BDI_CAP_VMFLAGS \
147 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP) 189 (BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP)
148 190
191#define BDI_CAP_NO_ACCT_AND_WRITEBACK \
192 (BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
193
149#if defined(VM_MAYREAD) && \ 194#if defined(VM_MAYREAD) && \
150 (BDI_CAP_READ_MAP != VM_MAYREAD || \ 195 (BDI_CAP_READ_MAP != VM_MAYREAD || \
151 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \ 196 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
@@ -185,17 +230,32 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int rw);
185void set_bdi_congested(struct backing_dev_info *bdi, int rw); 230void set_bdi_congested(struct backing_dev_info *bdi, int rw);
186long congestion_wait(int rw, long timeout); 231long congestion_wait(int rw, long timeout);
187 232
188#define bdi_cap_writeback_dirty(bdi) \
189 (!((bdi)->capabilities & BDI_CAP_NO_WRITEBACK))
190 233
191#define bdi_cap_account_dirty(bdi) \ 234static inline bool bdi_cap_writeback_dirty(struct backing_dev_info *bdi)
192 (!((bdi)->capabilities & BDI_CAP_NO_ACCT_DIRTY)) 235{
236 return !(bdi->capabilities & BDI_CAP_NO_WRITEBACK);
237}
238
239static inline bool bdi_cap_account_dirty(struct backing_dev_info *bdi)
240{
241 return !(bdi->capabilities & BDI_CAP_NO_ACCT_DIRTY);
242}
193 243
194#define mapping_cap_writeback_dirty(mapping) \ 244static inline bool bdi_cap_account_writeback(struct backing_dev_info *bdi)
195 bdi_cap_writeback_dirty((mapping)->backing_dev_info) 245{
246 /* Paranoia: BDI_CAP_NO_WRITEBACK implies BDI_CAP_NO_ACCT_WB */
247 return !(bdi->capabilities & (BDI_CAP_NO_ACCT_WB |
248 BDI_CAP_NO_WRITEBACK));
249}
196 250
197#define mapping_cap_account_dirty(mapping) \ 251static inline bool mapping_cap_writeback_dirty(struct address_space *mapping)
198 bdi_cap_account_dirty((mapping)->backing_dev_info) 252{
253 return bdi_cap_writeback_dirty(mapping->backing_dev_info);
254}
199 255
256static inline bool mapping_cap_account_dirty(struct address_space *mapping)
257{
258 return bdi_cap_account_dirty(mapping->backing_dev_info);
259}
200 260
201#endif /* _LINUX_BACKING_DEV_H */ 261#endif /* _LINUX_BACKING_DEV_H */
diff --git a/include/linux/byteorder/Kbuild b/include/linux/byteorder/Kbuild
index 79bedddfd9ca..1133d5f9d818 100644
--- a/include/linux/byteorder/Kbuild
+++ b/include/linux/byteorder/Kbuild
@@ -1,5 +1,3 @@
1header-y += big_endian.h 1unifdef-y += big_endian.h
2header-y += little_endian.h 2unifdef-y += little_endian.h
3
4unifdef-y += generic.h
5unifdef-y += swab.h 3unifdef-y += swab.h
diff --git a/include/linux/byteorder/big_endian.h b/include/linux/byteorder/big_endian.h
index bef87891cb24..961ed4b48d8e 100644
--- a/include/linux/byteorder/big_endian.h
+++ b/include/linux/byteorder/big_endian.h
@@ -101,6 +101,8 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
101#define __cpu_to_be16s(x) do {} while (0) 101#define __cpu_to_be16s(x) do {} while (0)
102#define __be16_to_cpus(x) do {} while (0) 102#define __be16_to_cpus(x) do {} while (0)
103 103
104#ifdef __KERNEL__
104#include <linux/byteorder/generic.h> 105#include <linux/byteorder/generic.h>
106#endif
105 107
106#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ 108#endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index d3771551fdd9..0846e6b931ce 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -82,12 +82,6 @@
82 * 82 *
83 */ 83 */
84 84
85
86#if defined(__KERNEL__)
87/*
88 * inside the kernel, we can use nicknames;
89 * outside of it, we must avoid POSIX namespace pollution...
90 */
91#define cpu_to_le64 __cpu_to_le64 85#define cpu_to_le64 __cpu_to_le64
92#define le64_to_cpu __le64_to_cpu 86#define le64_to_cpu __le64_to_cpu
93#define cpu_to_le32 __cpu_to_le32 87#define cpu_to_le32 __cpu_to_le32
@@ -176,6 +170,4 @@ static inline void be64_add_cpu(__be64 *var, u64 val)
176 *var = cpu_to_be64(be64_to_cpu(*var) + val); 170 *var = cpu_to_be64(be64_to_cpu(*var) + val);
177} 171}
178 172
179#endif /* KERNEL */
180
181#endif /* _LINUX_BYTEORDER_GENERIC_H */ 173#endif /* _LINUX_BYTEORDER_GENERIC_H */
diff --git a/include/linux/byteorder/little_endian.h b/include/linux/byteorder/little_endian.h
index 86e62b750176..05dc7c35b3b2 100644
--- a/include/linux/byteorder/little_endian.h
+++ b/include/linux/byteorder/little_endian.h
@@ -101,6 +101,8 @@ static inline __u16 __be16_to_cpup(const __be16 *p)
101#define __cpu_to_be16s(x) __swab16s((x)) 101#define __cpu_to_be16s(x) __swab16s((x))
102#define __be16_to_cpus(x) __swab16s((x)) 102#define __be16_to_cpus(x) __swab16s((x))
103 103
104#ifdef __KERNEL__
104#include <linux/byteorder/generic.h> 105#include <linux/byteorder/generic.h>
106#endif
105 107
106#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ 108#endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index 1e29b13d0062..fb4591977b03 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_CDEV_H 1#ifndef _LINUX_CDEV_H
2#define _LINUX_CDEV_H 2#define _LINUX_CDEV_H
3#ifdef __KERNEL__
4 3
5#include <linux/kobject.h> 4#include <linux/kobject.h>
6#include <linux/kdev_t.h> 5#include <linux/kdev_t.h>
@@ -34,4 +33,3 @@ void cd_forget(struct inode *);
34extern struct backing_dev_info directly_mappable_cdev_bdi; 33extern struct backing_dev_info directly_mappable_cdev_bdi;
35 34
36#endif 35#endif
37#endif
diff --git a/include/linux/coda_fs_i.h b/include/linux/coda_fs_i.h
index 424fe9cf02c4..b3ef0c461578 100644
--- a/include/linux/coda_fs_i.h
+++ b/include/linux/coda_fs_i.h
@@ -8,7 +8,6 @@
8#ifndef _LINUX_CODA_FS_I 8#ifndef _LINUX_CODA_FS_I
9#define _LINUX_CODA_FS_I 9#define _LINUX_CODA_FS_I
10 10
11#ifdef __KERNEL__
12#include <linux/types.h> 11#include <linux/types.h>
13#include <linux/list.h> 12#include <linux/list.h>
14#include <linux/coda.h> 13#include <linux/coda.h>
@@ -52,4 +51,3 @@ struct inode *coda_fid_to_inode(struct CodaFid *fid, struct super_block *sb);
52void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *); 51void coda_replace_fid(struct inode *, struct CodaFid *, struct CodaFid *);
53 52
54#endif 53#endif
55#endif
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index b2fd7547b58d..5c8351b859f0 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -29,10 +29,11 @@
29 BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) 29 BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
30 30
31/* 31/*
32 * Force always-inline if the user requests it so via the .config: 32 * Force always-inline if the user requests it so via the .config,
33 * or if gcc is too old:
33 */ 34 */
34#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ 35#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \
35 !defined(CONFIG_OPTIMIZE_INLINING) && (__GNUC__ >= 4) 36 !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4)
36# define inline inline __attribute__((always_inline)) 37# define inline inline __attribute__((always_inline))
37# define __inline__ __inline__ __attribute__((always_inline)) 38# define __inline__ __inline__ __attribute__((always_inline))
38# define __inline __inline __attribute__((always_inline)) 39# define __inline __inline __attribute__((always_inline))
diff --git a/include/linux/concap.h b/include/linux/concap.h
index 27304651d700..977acb3d1fb2 100644
--- a/include/linux/concap.h
+++ b/include/linux/concap.h
@@ -8,7 +8,7 @@
8 8
9#ifndef _LINUX_CONCAP_H 9#ifndef _LINUX_CONCAP_H
10#define _LINUX_CONCAP_H 10#define _LINUX_CONCAP_H
11#ifdef __KERNEL__ 11
12#include <linux/skbuff.h> 12#include <linux/skbuff.h>
13#include <linux/netdevice.h> 13#include <linux/netdevice.h>
14 14
@@ -110,4 +110,3 @@ extern int concap_nop(struct concap_proto *cprot);
110 */ 110 */
111extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb); 111extern int concap_drop_skb(struct concap_proto *cprot, struct sk_buff *skb);
112#endif 112#endif
113#endif
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 4b287ad9371a..3ae65b1bf90f 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -35,8 +35,6 @@
35#ifndef _CONFIGFS_H_ 35#ifndef _CONFIGFS_H_
36#define _CONFIGFS_H_ 36#define _CONFIGFS_H_
37 37
38#ifdef __KERNEL__
39
40#include <linux/kernel.h> 38#include <linux/kernel.h>
41#include <linux/types.h> 39#include <linux/types.h>
42#include <linux/list.h> 40#include <linux/list.h>
@@ -194,6 +192,4 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
194int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target); 192int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);
195void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target); 193void configfs_undepend_item(struct configfs_subsystem *subsys, struct config_item *target);
196 194
197#endif /* __KERNEL__ */
198
199#endif /* _CONFIGFS_H_ */ 195#endif /* _CONFIGFS_H_ */
diff --git a/include/linux/console.h b/include/linux/console.h
index a5f88a6a259d..a4f27fbdf549 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -91,6 +91,7 @@ void give_up_console(const struct consw *sw);
91#define CON_ENABLED (4) 91#define CON_ENABLED (4)
92#define CON_BOOT (8) 92#define CON_BOOT (8)
93#define CON_ANYTIME (16) /* Safe to call when cpu is offline */ 93#define CON_ANYTIME (16) /* Safe to call when cpu is offline */
94#define CON_BRL (32) /* Used for a braille device */
94 95
95struct console { 96struct console {
96 char name[16]; 97 char name[16];
@@ -121,6 +122,9 @@ extern struct tty_driver *console_device(int *);
121extern void console_stop(struct console *); 122extern void console_stop(struct console *);
122extern void console_start(struct console *); 123extern void console_start(struct console *);
123extern int is_console_locked(void); 124extern int is_console_locked(void);
125extern int braille_register_console(struct console *, int index,
126 char *console_options, char *braille_options);
127extern int braille_unregister_console(struct console *);
124 128
125extern int console_suspend_enabled; 129extern int console_suspend_enabled;
126 130
diff --git a/include/linux/crc-ccitt.h b/include/linux/crc-ccitt.h
index 90037617da8f..f52696a1ff0d 100644
--- a/include/linux/crc-ccitt.h
+++ b/include/linux/crc-ccitt.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_CRC_CCITT_H 1#ifndef _LINUX_CRC_CCITT_H
2#define _LINUX_CRC_CCITT_H 2#define _LINUX_CRC_CCITT_H
3#ifdef __KERNEL__
4 3
5#include <linux/types.h> 4#include <linux/types.h>
6 5
@@ -13,5 +12,4 @@ static inline u16 crc_ccitt_byte(u16 crc, const u8 c)
13 return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff]; 12 return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff];
14} 13}
15 14
16#endif /* __KERNEL__ */
17#endif /* _LINUX_CRC_CCITT_H */ 15#endif /* _LINUX_CRC_CCITT_H */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index cfb1627ac51c..2a6639407c80 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -1,8 +1,6 @@
1#ifndef __LINUX_DCACHE_H 1#ifndef __LINUX_DCACHE_H
2#define __LINUX_DCACHE_H 2#define __LINUX_DCACHE_H
3 3
4#ifdef __KERNEL__
5
6#include <asm/atomic.h> 4#include <asm/atomic.h>
7#include <linux/list.h> 5#include <linux/list.h>
8#include <linux/spinlock.h> 6#include <linux/spinlock.h>
@@ -365,6 +363,4 @@ extern struct dentry *lookup_create(struct nameidata *nd, int is_dir);
365 363
366extern int sysctl_vfs_cache_pressure; 364extern int sysctl_vfs_cache_pressure;
367 365
368#endif /* __KERNEL__ */
369
370#endif /* __LINUX_DCACHE_H */ 366#endif /* __LINUX_DCACHE_H */
diff --git a/include/linux/debugobjects.h b/include/linux/debugobjects.h
new file mode 100644
index 000000000000..8c243aaa86a7
--- /dev/null
+++ b/include/linux/debugobjects.h
@@ -0,0 +1,90 @@
1#ifndef _LINUX_DEBUGOBJECTS_H
2#define _LINUX_DEBUGOBJECTS_H
3
4#include <linux/list.h>
5#include <linux/spinlock.h>
6
7enum debug_obj_state {
8 ODEBUG_STATE_NONE,
9 ODEBUG_STATE_INIT,
10 ODEBUG_STATE_INACTIVE,
11 ODEBUG_STATE_ACTIVE,
12 ODEBUG_STATE_DESTROYED,
13 ODEBUG_STATE_NOTAVAILABLE,
14 ODEBUG_STATE_MAX,
15};
16
17struct debug_obj_descr;
18
19/**
20 * struct debug_obj - representaion of an tracked object
21 * @node: hlist node to link the object into the tracker list
22 * @state: tracked object state
23 * @object: pointer to the real object
24 * @descr: pointer to an object type specific debug description structure
25 */
26struct debug_obj {
27 struct hlist_node node;
28 enum debug_obj_state state;
29 void *object;
30 struct debug_obj_descr *descr;
31};
32
33/**
34 * struct debug_obj_descr - object type specific debug description structure
35 * @name: name of the object typee
36 * @fixup_init: fixup function, which is called when the init check
37 * fails
38 * @fixup_activate: fixup function, which is called when the activate check
39 * fails
40 * @fixup_destroy: fixup function, which is called when the destroy check
41 * fails
42 * @fixup_free: fixup function, which is called when the free check
43 * fails
44 */
45struct debug_obj_descr {
46 const char *name;
47
48 int (*fixup_init) (void *addr, enum debug_obj_state state);
49 int (*fixup_activate) (void *addr, enum debug_obj_state state);
50 int (*fixup_destroy) (void *addr, enum debug_obj_state state);
51 int (*fixup_free) (void *addr, enum debug_obj_state state);
52};
53
54#ifdef CONFIG_DEBUG_OBJECTS
55extern void debug_object_init (void *addr, struct debug_obj_descr *descr);
56extern void
57debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr);
58extern void debug_object_activate (void *addr, struct debug_obj_descr *descr);
59extern void debug_object_deactivate(void *addr, struct debug_obj_descr *descr);
60extern void debug_object_destroy (void *addr, struct debug_obj_descr *descr);
61extern void debug_object_free (void *addr, struct debug_obj_descr *descr);
62
63extern void debug_objects_early_init(void);
64extern void debug_objects_mem_init(void);
65#else
66static inline void
67debug_object_init (void *addr, struct debug_obj_descr *descr) { }
68static inline void
69debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr) { }
70static inline void
71debug_object_activate (void *addr, struct debug_obj_descr *descr) { }
72static inline void
73debug_object_deactivate(void *addr, struct debug_obj_descr *descr) { }
74static inline void
75debug_object_destroy (void *addr, struct debug_obj_descr *descr) { }
76static inline void
77debug_object_free (void *addr, struct debug_obj_descr *descr) { }
78
79static inline void debug_objects_early_init(void) { }
80static inline void debug_objects_mem_init(void) { }
81#endif
82
83#ifdef CONFIG_DEBUG_OBJECTS_FREE
84extern void debug_check_no_obj_freed(const void *address, unsigned long size);
85#else
86static inline void
87debug_check_no_obj_freed(const void *address, unsigned long size) { }
88#endif
89
90#endif
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index ad3b787479a4..0d8d419d191a 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -8,8 +8,6 @@
8#ifndef _LINUX_DEVICE_MAPPER_H 8#ifndef _LINUX_DEVICE_MAPPER_H
9#define _LINUX_DEVICE_MAPPER_H 9#define _LINUX_DEVICE_MAPPER_H
10 10
11#ifdef __KERNEL__
12
13#include <linux/bio.h> 11#include <linux/bio.h>
14 12
15struct dm_target; 13struct dm_target;
@@ -344,5 +342,4 @@ static inline unsigned long to_bytes(sector_t n)
344 return (n << SECTOR_SHIFT); 342 return (n << SECTOR_SHIFT);
345} 343}
346 344
347#endif /* __KERNEL__ */
348#endif /* _LINUX_DEVICE_MAPPER_H */ 345#endif /* _LINUX_DEVICE_MAPPER_H */
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index b672ddc00735..154769cad3f3 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -17,6 +17,8 @@
17 17
18#ifdef CONFIG_UNIX98_PTYS 18#ifdef CONFIG_UNIX98_PTYS
19 19
20int devpts_new_index(void);
21void devpts_kill_index(int idx);
20int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */ 22int devpts_pty_new(struct tty_struct *tty); /* mknod in devpts */
21struct tty_struct *devpts_get_tty(int number); /* get tty structure */ 23struct tty_struct *devpts_get_tty(int number); /* get tty structure */
22void devpts_pty_kill(int number); /* unlink */ 24void devpts_pty_kill(int number); /* unlink */
@@ -24,6 +26,8 @@ void devpts_pty_kill(int number); /* unlink */
24#else 26#else
25 27
26/* Dummy stubs in the no-pty case */ 28/* Dummy stubs in the no-pty case */
29static inline int devpts_new_index(void) { return -EINVAL; }
30static inline void devpts_kill_index(int idx) { }
27static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; } 31static inline int devpts_pty_new(struct tty_struct *tty) { return -EINVAL; }
28static inline struct tty_struct *devpts_get_tty(int number) { return NULL; } 32static inline struct tty_struct *devpts_get_tty(int number) { return NULL; }
29static inline void devpts_pty_kill(int number) { } 33static inline void devpts_pty_kill(int number) { }
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index b489fc6d0b62..a701399b7fed 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -8,9 +8,6 @@
8#ifndef _LINUX_EVENTFD_H 8#ifndef _LINUX_EVENTFD_H
9#define _LINUX_EVENTFD_H 9#define _LINUX_EVENTFD_H
10 10
11
12#ifdef __KERNEL__
13
14#ifdef CONFIG_EVENTFD 11#ifdef CONFIG_EVENTFD
15 12
16struct file *eventfd_fget(int fd); 13struct file *eventfd_fget(int fd);
@@ -24,7 +21,5 @@ static inline int eventfd_signal(struct file *file, int n)
24 21
25#endif /* CONFIG_EVENTFD */ 22#endif /* CONFIG_EVENTFD */
26 23
27#endif /* __KERNEL__ */
28
29#endif /* _LINUX_EVENTFD_H */ 24#endif /* _LINUX_EVENTFD_H */
30 25
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 2cad5c67397e..c415a496de3a 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -14,7 +14,6 @@
14 * option) any later version. 14 * option) any later version.
15 */ 15 */
16 16
17#ifdef __KERNEL__
18#ifndef _FSL_DEVICE_H_ 17#ifndef _FSL_DEVICE_H_
19#define _FSL_DEVICE_H_ 18#define _FSL_DEVICE_H_
20 19
@@ -127,4 +126,3 @@ struct mpc8xx_pcmcia_ops {
127}; 126};
128 127
129#endif /* _FSL_DEVICE_H_ */ 128#endif /* _FSL_DEVICE_H_ */
130#endif /* __KERNEL__ */
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index d4b7c4ac72e6..a89513188ce7 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -11,8 +11,6 @@
11 * (C) Copyright 2005 Robert Love 11 * (C) Copyright 2005 Robert Love
12 */ 12 */
13 13
14#ifdef __KERNEL__
15
16#include <linux/dnotify.h> 14#include <linux/dnotify.h>
17#include <linux/inotify.h> 15#include <linux/inotify.h>
18#include <linux/audit.h> 16#include <linux/audit.h>
@@ -296,6 +294,4 @@ static inline void fsnotify_oldname_free(const char *old_name)
296 294
297#endif /* ! CONFIG_INOTIFY */ 295#endif /* ! CONFIG_INOTIFY */
298 296
299#endif /* __KERNEL__ */
300
301#endif /* _LINUX_FS_NOTIFY_H */ 297#endif /* _LINUX_FS_NOTIFY_H */
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
index 5412da28fa47..110833666e37 100644
--- a/include/linux/generic_serial.h
+++ b/include/linux/generic_serial.h
@@ -78,7 +78,7 @@ struct gs_port {
78#define GS_DEBUG_WRITE 0x00000040 78#define GS_DEBUG_WRITE 0x00000040
79 79
80#ifdef __KERNEL__ 80#ifdef __KERNEL__
81void gs_put_char(struct tty_struct *tty, unsigned char ch); 81int gs_put_char(struct tty_struct *tty, unsigned char ch);
82int gs_write(struct tty_struct *tty, 82int gs_write(struct tty_struct *tty,
83 const unsigned char *buf, int count); 83 const unsigned char *buf, int count);
84int gs_write_room(struct tty_struct *tty); 84int gs_write_room(struct tty_struct *tty);
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 56f3236da829..31a4d653389f 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -266,6 +266,21 @@ extern ktime_t ktime_get_real(void);
266extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock, 266extern void hrtimer_init(struct hrtimer *timer, clockid_t which_clock,
267 enum hrtimer_mode mode); 267 enum hrtimer_mode mode);
268 268
269#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
270extern void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t which_clock,
271 enum hrtimer_mode mode);
272
273extern void destroy_hrtimer_on_stack(struct hrtimer *timer);
274#else
275static inline void hrtimer_init_on_stack(struct hrtimer *timer,
276 clockid_t which_clock,
277 enum hrtimer_mode mode)
278{
279 hrtimer_init(timer, which_clock, mode);
280}
281static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
282#endif
283
269/* Basic timer operations: */ 284/* Basic timer operations: */
270extern int hrtimer_start(struct hrtimer *timer, ktime_t tim, 285extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
271 const enum hrtimer_mode mode); 286 const enum hrtimer_mode mode);
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 85d11916e9ea..7244456e7e65 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -11,7 +11,6 @@
11 11
12#ifndef LINUX_HWRANDOM_H_ 12#ifndef LINUX_HWRANDOM_H_
13#define LINUX_HWRANDOM_H_ 13#define LINUX_HWRANDOM_H_
14#ifdef __KERNEL__
15 14
16#include <linux/types.h> 15#include <linux/types.h>
17#include <linux/list.h> 16#include <linux/list.h>
@@ -46,5 +45,4 @@ extern int hwrng_register(struct hwrng *rng);
46/** Unregister a Hardware Random Number Generator driver. */ 45/** Unregister a Hardware Random Number Generator driver. */
47extern void hwrng_unregister(struct hwrng *rng); 46extern void hwrng_unregister(struct hwrng *rng);
48 47
49#endif /* __KERNEL__ */
50#endif /* LINUX_HWRANDOM_H_ */ 48#endif /* LINUX_HWRANDOM_H_ */
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index f65e58a1d925..7d51cbca49ab 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -18,8 +18,6 @@
18#ifndef _I2O_H 18#ifndef _I2O_H
19#define _I2O_H 19#define _I2O_H
20 20
21#ifdef __KERNEL__ /* This file to be included by kernel only */
22
23#include <linux/i2o-dev.h> 21#include <linux/i2o-dev.h>
24 22
25/* How many different OSM's are we allowing */ 23/* How many different OSM's are we allowing */
@@ -1255,5 +1253,4 @@ extern void i2o_dump_message(struct i2o_message *);
1255extern void i2o_dump_hrt(struct i2o_controller *c); 1253extern void i2o_dump_hrt(struct i2o_controller *c);
1256extern void i2o_debug_state(struct i2o_controller *c); 1254extern void i2o_debug_state(struct i2o_controller *c);
1257 1255
1258#endif /* __KERNEL__ */
1259#endif /* _I2O_H */ 1256#endif /* _I2O_H */
diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h
index 0d9d7ea2c1cc..5f200bac3749 100644
--- a/include/linux/if_macvlan.h
+++ b/include/linux/if_macvlan.h
@@ -1,9 +1,6 @@
1#ifndef _LINUX_IF_MACVLAN_H 1#ifndef _LINUX_IF_MACVLAN_H
2#define _LINUX_IF_MACVLAN_H 2#define _LINUX_IF_MACVLAN_H
3 3
4#ifdef __KERNEL__
5
6extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *); 4extern struct sk_buff *(*macvlan_handle_frame_hook)(struct sk_buff *);
7 5
8#endif /* __KERNEL__ */
9#endif /* _LINUX_IF_MACVLAN_H */ 6#endif /* _LINUX_IF_MACVLAN_H */
diff --git a/include/linux/inet.h b/include/linux/inet.h
index 675a7dbe86f8..1354080cf8cf 100644
--- a/include/linux/inet.h
+++ b/include/linux/inet.h
@@ -42,11 +42,9 @@
42#ifndef _LINUX_INET_H 42#ifndef _LINUX_INET_H
43#define _LINUX_INET_H 43#define _LINUX_INET_H
44 44
45#ifdef __KERNEL__
46#include <linux/types.h> 45#include <linux/types.h>
47 46
48extern __be32 in_aton(const char *str); 47extern __be32 in_aton(const char *str);
49extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); 48extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
50extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); 49extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end);
51#endif
52#endif /* _LINUX_INET_H */ 50#endif /* _LINUX_INET_H */
diff --git a/include/linux/isicom.h b/include/linux/isicom.h
index 8f4c71759d73..bbd42197298f 100644
--- a/include/linux/isicom.h
+++ b/include/linux/isicom.h
@@ -1,11 +1,6 @@
1#ifndef _LINUX_ISICOM_H 1#ifndef _LINUX_ISICOM_H
2#define _LINUX_ISICOM_H 2#define _LINUX_ISICOM_H
3 3
4/*#define ISICOM_DEBUG*/
5/*#define ISICOM_DEBUG_DTR_RTS*/
6
7#ifdef __KERNEL__
8
9#define YES 1 4#define YES 1
10#define NO 0 5#define NO 0
11 6
@@ -85,6 +80,4 @@
85 80
86#define ISI_TXOK 0x0001 81#define ISI_TXOK 0x0001
87 82
88#endif /* __KERNEL__ */
89
90#endif /* ISICOM_H */ 83#endif /* ISICOM_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 53839ba265ec..4d46e299afb5 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -338,33 +338,90 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
338#endif /* __LITTLE_ENDIAN */ 338#endif /* __LITTLE_ENDIAN */
339 339
340/* 340/*
341 * min()/max() macros that also do 341 * min()/max()/clamp() macros that also do
342 * strict type-checking.. See the 342 * strict type-checking.. See the
343 * "unnecessary" pointer comparison. 343 * "unnecessary" pointer comparison.
344 */ 344 */
345#define min(x,y) ({ \ 345#define min(x, y) ({ \
346 typeof(x) _x = (x); \ 346 typeof(x) _min1 = (x); \
347 typeof(y) _y = (y); \ 347 typeof(y) _min2 = (y); \
348 (void) (&_x == &_y); \ 348 (void) (&_min1 == &_min2); \
349 _x < _y ? _x : _y; }) 349 _min1 < _min2 ? _min1 : _min2; })
350 350
351#define max(x,y) ({ \ 351#define max(x, y) ({ \
352 typeof(x) _x = (x); \ 352 typeof(x) _max1 = (x); \
353 typeof(y) _y = (y); \ 353 typeof(y) _max2 = (y); \
354 (void) (&_x == &_y); \ 354 (void) (&_max1 == &_max2); \
355 _x > _y ? _x : _y; }) 355 _max1 > _max2 ? _max1 : _max2; })
356
357/**
358 * clamp - return a value clamped to a given range with strict typechecking
359 * @val: current value
360 * @min: minimum allowable value
361 * @max: maximum allowable value
362 *
363 * This macro does strict typechecking of min/max to make sure they are of the
364 * same type as val. See the unnecessary pointer comparisons.
365 */
366#define clamp(val, min, max) ({ \
367 typeof(val) __val = (val); \
368 typeof(min) __min = (min); \
369 typeof(max) __max = (max); \
370 (void) (&__val == &__min); \
371 (void) (&__val == &__max); \
372 __val = __val < __min ? __min: __val; \
373 __val > __max ? __max: __val; })
356 374
357/* 375/*
358 * ..and if you can't take the strict 376 * ..and if you can't take the strict
359 * types, you can specify one yourself. 377 * types, you can specify one yourself.
360 * 378 *
361 * Or not use min/max at all, of course. 379 * Or not use min/max/clamp at all, of course.
380 */
381#define min_t(type, x, y) ({ \
382 type __min1 = (x); \
383 type __min2 = (y); \
384 __min1 < __min2 ? __min1: __min2; })
385
386#define max_t(type, x, y) ({ \
387 type __max1 = (x); \
388 type __max2 = (y); \
389 __max1 > __max2 ? __max1: __max2; })
390
391/**
392 * clamp_t - return a value clamped to a given range using a given type
393 * @type: the type of variable to use
394 * @val: current value
395 * @min: minimum allowable value
396 * @max: maximum allowable value
397 *
398 * This macro does no typechecking and uses temporary variables of type
399 * 'type' to make all the comparisons.
362 */ 400 */
363#define min_t(type,x,y) \ 401#define clamp_t(type, val, min, max) ({ \
364 ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) 402 type __val = (val); \
365#define max_t(type,x,y) \ 403 type __min = (min); \
366 ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) 404 type __max = (max); \
405 __val = __val < __min ? __min: __val; \
406 __val > __max ? __max: __val; })
367 407
408/**
409 * clamp_val - return a value clamped to a given range using val's type
410 * @val: current value
411 * @min: minimum allowable value
412 * @max: maximum allowable value
413 *
414 * This macro does no typechecking and uses temporary variables of whatever
415 * type the input argument 'val' is. This is useful when val is an unsigned
416 * type and min and max are literals that will otherwise be assigned a signed
417 * integer type.
418 */
419#define clamp_val(val, min, max) ({ \
420 typeof(val) __val = (val); \
421 typeof(val) __min = (min); \
422 typeof(val) __max = (max); \
423 __val = __val < __min ? __min: __val; \
424 __val > __max ? __max: __val; })
368 425
369/** 426/**
370 * container_of - cast a member of a structure out to the containing structure 427 * container_of - cast a member of a structure out to the containing structure
diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
index 404f4464cb1a..29f62e1733ff 100644
--- a/include/linux/kfifo.h
+++ b/include/linux/kfifo.h
@@ -21,8 +21,6 @@
21#ifndef _LINUX_KFIFO_H 21#ifndef _LINUX_KFIFO_H
22#define _LINUX_KFIFO_H 22#define _LINUX_KFIFO_H
23 23
24#ifdef __KERNEL__
25
26#include <linux/kernel.h> 24#include <linux/kernel.h>
27#include <linux/spinlock.h> 25#include <linux/spinlock.h>
28 26
@@ -151,7 +149,4 @@ static inline unsigned int kfifo_len(struct kfifo *fifo)
151 return ret; 149 return ret;
152} 150}
153 151
154#else
155#warning "don't include kernel headers in userspace"
156#endif /* __KERNEL__ */
157#endif 152#endif
diff --git a/include/linux/kobj_map.h b/include/linux/kobj_map.h
index bafe178a381f..73717ed9ea79 100644
--- a/include/linux/kobj_map.h
+++ b/include/linux/kobj_map.h
@@ -1,5 +1,3 @@
1#ifdef __KERNEL__
2
3#include <linux/mutex.h> 1#include <linux/mutex.h>
4 2
5typedef struct kobject *kobj_probe_t(dev_t, int *, void *); 3typedef struct kobject *kobj_probe_t(dev_t, int *, void *);
@@ -10,5 +8,3 @@ int kobj_map(struct kobj_map *, dev_t, unsigned long, struct module *,
10void kobj_unmap(struct kobj_map *, dev_t, unsigned long); 8void kobj_unmap(struct kobj_map *, dev_t, unsigned long);
11struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *); 9struct kobject *kobj_lookup(struct kobj_map *, dev_t, int *);
12struct kobj_map *kobj_map_init(kobj_probe_t *, struct mutex *); 10struct kobj_map *kobj_map_init(kobj_probe_t *, struct mutex *);
13
14#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index caa3f411f15d..39e709f88aa0 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -16,8 +16,6 @@
16#ifndef _KOBJECT_H_ 16#ifndef _KOBJECT_H_
17#define _KOBJECT_H_ 17#define _KOBJECT_H_
18 18
19#ifdef __KERNEL__
20
21#include <linux/types.h> 19#include <linux/types.h>
22#include <linux/list.h> 20#include <linux/list.h>
23#include <linux/sysfs.h> 21#include <linux/sysfs.h>
@@ -224,5 +222,4 @@ static inline int kobject_action_type(const char *buf, size_t count,
224{ return -EINVAL; } 222{ return -EINVAL; }
225#endif 223#endif
226 224
227#endif /* __KERNEL__ */
228#endif /* _KOBJECT_H_ */ 225#endif /* _KOBJECT_H_ */
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 5d185635786e..0cef6badd6fb 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -15,8 +15,6 @@
15#ifndef _KREF_H_ 15#ifndef _KREF_H_
16#define _KREF_H_ 16#define _KREF_H_
17 17
18#ifdef __KERNEL__
19
20#include <linux/types.h> 18#include <linux/types.h>
21#include <asm/atomic.h> 19#include <asm/atomic.h>
22 20
@@ -29,5 +27,4 @@ void kref_init(struct kref *kref);
29void kref_get(struct kref *kref); 27void kref_get(struct kref *kref);
30int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 28int kref_put(struct kref *kref, void (*release) (struct kref *kref));
31 29
32#endif /* __KERNEL__ */
33#endif /* _KREF_H_ */ 30#endif /* _KREF_H_ */
diff --git a/include/linux/list.h b/include/linux/list.h
index 7627508f1b74..08cf4f651889 100644
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_LIST_H 1#ifndef _LINUX_LIST_H
2#define _LINUX_LIST_H 2#define _LINUX_LIST_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/stddef.h> 4#include <linux/stddef.h>
7#include <linux/poison.h> 5#include <linux/poison.h>
8#include <linux/prefetch.h> 6#include <linux/prefetch.h>
@@ -983,7 +981,4 @@ static inline void hlist_add_after_rcu(struct hlist_node *prev,
983 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ 981 ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
984 pos = rcu_dereference(pos->next)) 982 pos = rcu_dereference(pos->next))
985 983
986#else
987#warning "don't include kernel headers in userspace"
988#endif /* __KERNEL__ */
989#endif 984#endif
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index aad98003176f..c463cd8a15a4 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -1,7 +1,6 @@
1#ifndef _LINUX_MMZONE_H 1#ifndef _LINUX_MMZONE_H
2#define _LINUX_MMZONE_H 2#define _LINUX_MMZONE_H
3 3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
6#ifndef __GENERATING_BOUNDS_H 5#ifndef __GENERATING_BOUNDS_H
7 6
@@ -97,6 +96,7 @@ enum zone_stat_item {
97 NR_UNSTABLE_NFS, /* NFS unstable pages */ 96 NR_UNSTABLE_NFS, /* NFS unstable pages */
98 NR_BOUNCE, 97 NR_BOUNCE,
99 NR_VMSCAN_WRITE, 98 NR_VMSCAN_WRITE,
99 NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
100#ifdef CONFIG_NUMA 100#ifdef CONFIG_NUMA
101 NUMA_HIT, /* allocated in intended node */ 101 NUMA_HIT, /* allocated in intended node */
102 NUMA_MISS, /* allocated in non intended node */ 102 NUMA_MISS, /* allocated in non intended node */
@@ -1004,5 +1004,4 @@ unsigned long __init node_memmap_size_bytes(int, unsigned long, unsigned long);
1004 1004
1005#endif /* !__GENERATING_BOUNDS.H */ 1005#endif /* !__GENERATING_BOUNDS.H */
1006#endif /* !__ASSEMBLY__ */ 1006#endif /* !__ASSEMBLY__ */
1007#endif /* __KERNEL__ */
1008#endif /* _LINUX_MMZONE_H */ 1007#endif /* _LINUX_MMZONE_H */
diff --git a/include/linux/mount.h b/include/linux/mount.h
index b4836d58f428..4374d1adeb4b 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -10,7 +10,6 @@
10 */ 10 */
11#ifndef _LINUX_MOUNT_H 11#ifndef _LINUX_MOUNT_H
12#define _LINUX_MOUNT_H 12#define _LINUX_MOUNT_H
13#ifdef __KERNEL__
14 13
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/list.h> 15#include <linux/list.h>
@@ -114,5 +113,4 @@ extern void mark_mounts_for_expiry(struct list_head *mounts);
114extern spinlock_t vfsmount_lock; 113extern spinlock_t vfsmount_lock;
115extern dev_t name_to_dev_t(char *name); 114extern dev_t name_to_dev_t(char *name);
116 115
117#endif
118#endif /* _LINUX_MOUNT_H */ 116#endif /* _LINUX_MOUNT_H */
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
index bdb4c8ae6924..4b0bec477846 100644
--- a/include/linux/ncp_fs_i.h
+++ b/include/linux/ncp_fs_i.h
@@ -8,8 +8,6 @@
8#ifndef _LINUX_NCP_FS_I 8#ifndef _LINUX_NCP_FS_I
9#define _LINUX_NCP_FS_I 9#define _LINUX_NCP_FS_I
10 10
11#ifdef __KERNEL__
12
13/* 11/*
14 * This is the ncpfs part of the inode structure. This must contain 12 * This is the ncpfs part of the inode structure. This must contain
15 * all the information we need to work with an inode after creation. 13 * all the information we need to work with an inode after creation.
@@ -28,6 +26,4 @@ struct ncp_inode_info {
28 struct inode vfs_inode; 26 struct inode vfs_inode;
29}; 27};
30 28
31#endif /* __KERNEL__ */
32
33#endif /* _LINUX_NCP_FS_I */ 29#endif /* _LINUX_NCP_FS_I */
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 6dc11959770c..afe338217d91 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_OF_DEVICE_H 1#ifndef _LINUX_OF_DEVICE_H
2#define _LINUX_OF_DEVICE_H 2#define _LINUX_OF_DEVICE_H
3#ifdef __KERNEL__
4 3
5#include <linux/device.h> 4#include <linux/device.h>
6#include <linux/of.h> 5#include <linux/of.h>
@@ -25,5 +24,4 @@ static inline void of_device_free(struct of_device *dev)
25 of_release_dev(&dev->dev); 24 of_release_dev(&dev->dev);
26} 25}
27 26
28#endif /* __KERNEL__ */
29#endif /* _LINUX_OF_DEVICE_H */ 27#endif /* _LINUX_OF_DEVICE_H */
diff --git a/include/linux/pid.h b/include/linux/pid.h
index c7980810eb09..c21c7e8124a7 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -60,7 +60,7 @@ struct pid
60 /* lists of tasks that use this pid */ 60 /* lists of tasks that use this pid */
61 struct hlist_head tasks[PIDTYPE_MAX]; 61 struct hlist_head tasks[PIDTYPE_MAX];
62 struct rcu_head rcu; 62 struct rcu_head rcu;
63 int level; 63 unsigned int level;
64 struct upid numbers[1]; 64 struct upid numbers[1];
65}; 65};
66 66
@@ -89,9 +89,11 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);
89 * attach_pid() and detach_pid() must be called with the tasklist_lock 89 * attach_pid() and detach_pid() must be called with the tasklist_lock
90 * write-held. 90 * write-held.
91 */ 91 */
92extern int attach_pid(struct task_struct *task, enum pid_type type, 92extern void attach_pid(struct task_struct *task, enum pid_type type,
93 struct pid *pid); 93 struct pid *pid);
94extern void detach_pid(struct task_struct *task, enum pid_type); 94extern void detach_pid(struct task_struct *task, enum pid_type);
95extern void change_pid(struct task_struct *task, enum pid_type,
96 struct pid *pid);
95extern void transfer_pid(struct task_struct *old, struct task_struct *new, 97extern void transfer_pid(struct task_struct *old, struct task_struct *new,
96 enum pid_type); 98 enum pid_type);
97 99
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index fcd61fa2c833..caff5283d15c 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -20,7 +20,7 @@ struct pid_namespace {
20 int last_pid; 20 int last_pid;
21 struct task_struct *child_reaper; 21 struct task_struct *child_reaper;
22 struct kmem_cache *pid_cachep; 22 struct kmem_cache *pid_cachep;
23 int level; 23 unsigned int level;
24 struct pid_namespace *parent; 24 struct pid_namespace *parent;
25#ifdef CONFIG_PROC_FS 25#ifdef CONFIG_PROC_FS
26 struct vfsmount *proc_mnt; 26 struct vfsmount *proc_mnt;
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 1de72cbbe0d1..39a7ee859b67 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -21,8 +21,6 @@
21#ifndef _LINUX_PM_H 21#ifndef _LINUX_PM_H
22#define _LINUX_PM_H 22#define _LINUX_PM_H
23 23
24#ifdef __KERNEL__
25
26#include <linux/list.h> 24#include <linux/list.h>
27#include <asm/atomic.h> 25#include <asm/atomic.h>
28#include <asm/errno.h> 26#include <asm/errno.h>
@@ -225,6 +223,4 @@ extern unsigned int pm_flags;
225#define PM_APM 1 223#define PM_APM 1
226#define PM_ACPI 2 224#define PM_ACPI 2
227 225
228#endif /* __KERNEL__ */
229
230#endif /* _LINUX_PM_H */ 226#endif /* _LINUX_PM_H */
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index b2f05c230f4b..2f3bcf73052c 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -6,8 +6,6 @@
6#ifndef _LINUX_PNP_H 6#ifndef _LINUX_PNP_H
7#define _LINUX_PNP_H 7#define _LINUX_PNP_H
8 8
9#ifdef __KERNEL__
10
11#include <linux/device.h> 9#include <linux/device.h>
12#include <linux/list.h> 10#include <linux/list.h>
13#include <linux/errno.h> 11#include <linux/errno.h>
@@ -466,6 +464,4 @@ static inline void pnp_unregister_driver(struct pnp_driver *drv) { }
466#define pnp_dbg(format, arg...) do {} while (0) 464#define pnp_dbg(format, arg...) do {} while (0)
467#endif 465#endif
468 466
469#endif /* __KERNEL__ */
470
471#endif /* _LINUX_PNP_H */ 467#endif /* _LINUX_PNP_H */
diff --git a/include/linux/poison.h b/include/linux/poison.h
index a9c31be7052c..9f31683728fd 100644
--- a/include/linux/poison.h
+++ b/include/linux/poison.h
@@ -10,6 +10,13 @@
10#define LIST_POISON1 ((void *) 0x00100100) 10#define LIST_POISON1 ((void *) 0x00100100)
11#define LIST_POISON2 ((void *) 0x00200200) 11#define LIST_POISON2 ((void *) 0x00200200)
12 12
13/********** include/linux/timer.h **********/
14/*
15 * Magic number "tsta" to indicate a static timer initializer
16 * for the object debugging code.
17 */
18#define TIMER_ENTRY_STATIC ((void *) 0x74737461)
19
13/********** mm/slab.c **********/ 20/********** mm/slab.c **********/
14/* 21/*
15 * Magic nums for obj red zoning. 22 * Magic nums for obj red zoning.
diff --git a/include/linux/profile.h b/include/linux/profile.h
index ff576d1db67d..05c1cc736937 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_PROFILE_H 1#ifndef _LINUX_PROFILE_H
2#define _LINUX_PROFILE_H 2#define _LINUX_PROFILE_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/kernel.h> 4#include <linux/kernel.h>
7#include <linux/init.h> 5#include <linux/init.h>
8#include <linux/cpumask.h> 6#include <linux/cpumask.h>
@@ -118,6 +116,4 @@ static inline void unregister_timer_hook(int (*hook)(struct pt_regs *))
118 116
119#endif /* CONFIG_PROFILING */ 117#endif /* CONFIG_PROFILING */
120 118
121#endif /* __KERNEL__ */
122
123#endif /* _LINUX_PROFILE_H */ 119#endif /* _LINUX_PROFILE_H */
diff --git a/include/linux/proportions.h b/include/linux/proportions.h
index 2c3b3cad92be..5afc1b23346d 100644
--- a/include/linux/proportions.h
+++ b/include/linux/proportions.h
@@ -78,6 +78,19 @@ void prop_inc_percpu(struct prop_descriptor *pd, struct prop_local_percpu *pl)
78} 78}
79 79
80/* 80/*
81 * Limit the time part in order to ensure there are some bits left for the
82 * cycle counter and fraction multiply.
83 */
84#define PROP_MAX_SHIFT (3*BITS_PER_LONG/4)
85
86#define PROP_FRAC_SHIFT (BITS_PER_LONG - PROP_MAX_SHIFT - 1)
87#define PROP_FRAC_BASE (1UL << PROP_FRAC_SHIFT)
88
89void __prop_inc_percpu_max(struct prop_descriptor *pd,
90 struct prop_local_percpu *pl, long frac);
91
92
93/*
81 * ----- SINGLE ------ 94 * ----- SINGLE ------
82 */ 95 */
83 96
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index ebe0c17039cf..f98501ba557e 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -98,6 +98,10 @@ extern void ptrace_untrace(struct task_struct *child);
98extern int ptrace_may_attach(struct task_struct *task); 98extern int ptrace_may_attach(struct task_struct *task);
99extern int __ptrace_may_attach(struct task_struct *task); 99extern int __ptrace_may_attach(struct task_struct *task);
100 100
101static inline int ptrace_reparented(struct task_struct *child)
102{
103 return child->real_parent != child->parent;
104}
101static inline void ptrace_link(struct task_struct *child, 105static inline void ptrace_link(struct task_struct *child,
102 struct task_struct *new_parent) 106 struct task_struct *new_parent)
103{ 107{
diff --git a/include/linux/raid/md.h b/include/linux/raid/md.h
index 8ab630b67fcc..81a1a02d4566 100644
--- a/include/linux/raid/md.h
+++ b/include/linux/raid/md.h
@@ -94,6 +94,7 @@ extern int sync_page_io(struct block_device *bdev, sector_t sector, int size,
94extern void md_do_sync(mddev_t *mddev); 94extern void md_do_sync(mddev_t *mddev);
95extern void md_new_event(mddev_t *mddev); 95extern void md_new_event(mddev_t *mddev);
96extern void md_allow_write(mddev_t *mddev); 96extern void md_allow_write(mddev_t *mddev);
97extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
97 98
98#endif /* CONFIG_MD */ 99#endif /* CONFIG_MD */
99#endif 100#endif
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 7bb6d1abf71e..812ffa590cff 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -84,6 +84,10 @@ struct mdk_rdev_s
84#define AllReserved 6 /* If whole device is reserved for 84#define AllReserved 6 /* If whole device is reserved for
85 * one array */ 85 * one array */
86#define AutoDetected 7 /* added by auto-detect */ 86#define AutoDetected 7 /* added by auto-detect */
87#define Blocked 8 /* An error occured on an externally
88 * managed array, don't allow writes
89 * until it is cleared */
90 wait_queue_head_t blocked_wait;
87 91
88 int desc_nr; /* descriptor index in the superblock */ 92 int desc_nr; /* descriptor index in the superblock */
89 int raid_disk; /* role of device in array */ 93 int raid_disk; /* role of device in array */
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
index b3dccd68629e..b3aa05baab8a 100644
--- a/include/linux/rcuclassic.h
+++ b/include/linux/rcuclassic.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUCLASSIC_H 33#ifndef __LINUX_RCUCLASSIC_H
34#define __LINUX_RCUCLASSIC_H 34#define __LINUX_RCUCLASSIC_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -163,5 +161,4 @@ extern long rcu_batches_completed_bh(void);
163#define rcu_enter_nohz() do { } while (0) 161#define rcu_enter_nohz() do { } while (0)
164#define rcu_exit_nohz() do { } while (0) 162#define rcu_exit_nohz() do { } while (0)
165 163
166#endif /* __KERNEL__ */
167#endif /* __LINUX_RCUCLASSIC_H */ 164#endif /* __LINUX_RCUCLASSIC_H */
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 37a642c54871..8082d6587a0f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUPDATE_H 33#ifndef __LINUX_RCUPDATE_H
34#define __LINUX_RCUPDATE_H 34#define __LINUX_RCUPDATE_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -245,5 +243,4 @@ extern long rcu_batches_completed_bh(void);
245extern void rcu_init(void); 243extern void rcu_init(void);
246extern int rcu_needs_cpu(int cpu); 244extern int rcu_needs_cpu(int cpu);
247 245
248#endif /* __KERNEL__ */
249#endif /* __LINUX_RCUPDATE_H */ 246#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
index d038aa6e5ee1..8a05c7e20bc4 100644
--- a/include/linux/rcupreempt.h
+++ b/include/linux/rcupreempt.h
@@ -33,8 +33,6 @@
33#ifndef __LINUX_RCUPREEMPT_H 33#ifndef __LINUX_RCUPREEMPT_H
34#define __LINUX_RCUPREEMPT_H 34#define __LINUX_RCUPREEMPT_H
35 35
36#ifdef __KERNEL__
37
38#include <linux/cache.h> 36#include <linux/cache.h>
39#include <linux/spinlock.h> 37#include <linux/spinlock.h>
40#include <linux/threads.h> 38#include <linux/threads.h>
@@ -104,5 +102,4 @@ static inline void rcu_exit_nohz(void)
104#define rcu_exit_nohz() do { } while (0) 102#define rcu_exit_nohz() do { } while (0)
105#endif /* CONFIG_NO_HZ */ 103#endif /* CONFIG_NO_HZ */
106 104
107#endif /* __KERNEL__ */
108#endif /* __LINUX_RCUPREEMPT_H */ 105#endif /* __LINUX_RCUPREEMPT_H */
diff --git a/include/linux/rcupreempt_trace.h b/include/linux/rcupreempt_trace.h
index 21cd6b2a5c42..b99ae073192a 100644
--- a/include/linux/rcupreempt_trace.h
+++ b/include/linux/rcupreempt_trace.h
@@ -32,7 +32,6 @@
32#ifndef __LINUX_RCUPREEMPT_TRACE_H 32#ifndef __LINUX_RCUPREEMPT_TRACE_H
33#define __LINUX_RCUPREEMPT_TRACE_H 33#define __LINUX_RCUPREEMPT_TRACE_H
34 34
35#ifdef __KERNEL__
36#include <linux/types.h> 35#include <linux/types.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38 37
@@ -95,5 +94,4 @@ extern void rcupreempt_trace_done_remove(struct rcupreempt_trace *trace);
95extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace); 94extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace);
96extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace); 95extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace);
97 96
98#endif /* __KERNEL__ */
99#endif /* __LINUX_RCUPREEMPT_TRACE_H */ 97#endif /* __LINUX_RCUPREEMPT_TRACE_H */
diff --git a/include/linux/reiserfs_fs_sb.h b/include/linux/reiserfs_fs_sb.h
index db5ef9b83c3f..336ee43ed7d8 100644
--- a/include/linux/reiserfs_fs_sb.h
+++ b/include/linux/reiserfs_fs_sb.h
@@ -177,7 +177,6 @@ struct reiserfs_journal {
177 struct reiserfs_journal_cnode *j_last; /* newest journal block */ 177 struct reiserfs_journal_cnode *j_last; /* newest journal block */
178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */ 178 struct reiserfs_journal_cnode *j_first; /* oldest journal block. start here for traverse */
179 179
180 struct file *j_dev_file;
181 struct block_device *j_dev_bd; 180 struct block_device *j_dev_bd;
182 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */ 181 int j_1st_reserved_block; /* first block on s_dev of reserved area journal */
183 182
diff --git a/include/linux/rio.h b/include/linux/rio.h
index cfb66bbc0f27..c1c99c9643d3 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -14,8 +14,6 @@
14#ifndef LINUX_RIO_H 14#ifndef LINUX_RIO_H
15#define LINUX_RIO_H 15#define LINUX_RIO_H
16 16
17#ifdef __KERNEL__
18
19#include <linux/types.h> 17#include <linux/types.h>
20#include <linux/ioport.h> 18#include <linux/ioport.h>
21#include <linux/list.h> 19#include <linux/list.h>
@@ -331,5 +329,4 @@ extern void rio_close_inb_mbox(struct rio_mport *, int);
331extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int); 329extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
332extern void rio_close_outb_mbox(struct rio_mport *, int); 330extern void rio_close_outb_mbox(struct rio_mport *, int);
333 331
334#endif /* __KERNEL__ */
335#endif /* LINUX_RIO_H */ 332#endif /* LINUX_RIO_H */
diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h
index 7adb2a1aac92..90987b7bcc1b 100644
--- a/include/linux/rio_drv.h
+++ b/include/linux/rio_drv.h
@@ -13,8 +13,6 @@
13#ifndef LINUX_RIO_DRV_H 13#ifndef LINUX_RIO_DRV_H
14#define LINUX_RIO_DRV_H 14#define LINUX_RIO_DRV_H
15 15
16#ifdef __KERNEL__
17
18#include <linux/types.h> 16#include <linux/types.h>
19#include <linux/ioport.h> 17#include <linux/ioport.h>
20#include <linux/list.h> 18#include <linux/list.h>
@@ -465,5 +463,4 @@ extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from);
465extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did, 463extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did,
466 struct rio_dev *from); 464 struct rio_dev *from);
467 465
468#endif /* __KERNEL__ */
469#endif /* LINUX_RIO_DRV_H */ 466#endif /* LINUX_RIO_DRV_H */
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h
index 7b524b4109a0..efd348fe8ca7 100644
--- a/include/linux/rwsem.h
+++ b/include/linux/rwsem.h
@@ -9,8 +9,6 @@
9 9
10#include <linux/linkage.h> 10#include <linux/linkage.h>
11 11
12#ifdef __KERNEL__
13
14#include <linux/types.h> 12#include <linux/types.h>
15#include <linux/kernel.h> 13#include <linux/kernel.h>
16#include <asm/system.h> 14#include <asm/system.h>
@@ -90,5 +88,4 @@ extern void up_read_non_owner(struct rw_semaphore *sem);
90# define up_read_non_owner(sem) up_read(sem) 88# define up_read_non_owner(sem) up_read(sem)
91#endif 89#endif
92 90
93#endif /* __KERNEL__ */
94#endif /* _LINUX_RWSEM_H */ 91#endif /* _LINUX_RWSEM_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 1d02babdb2c7..03c238088aee 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -554,6 +554,14 @@ struct signal_struct {
554#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */ 554#define SIGNAL_STOP_DEQUEUED 0x00000002 /* stop signal dequeued */
555#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */ 555#define SIGNAL_STOP_CONTINUED 0x00000004 /* SIGCONT since WCONTINUED reap */
556#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */ 556#define SIGNAL_GROUP_EXIT 0x00000008 /* group exit in progress */
557/*
558 * Pending notifications to parent.
559 */
560#define SIGNAL_CLD_STOPPED 0x00000010
561#define SIGNAL_CLD_CONTINUED 0x00000020
562#define SIGNAL_CLD_MASK (SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
563
564#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */
557 565
558/* If true, all threads except ->group_exit_task have pending SIGKILL */ 566/* If true, all threads except ->group_exit_task have pending SIGKILL */
559static inline int signal_group_exit(const struct signal_struct *sig) 567static inline int signal_group_exit(const struct signal_struct *sig)
@@ -1167,7 +1175,7 @@ struct task_struct {
1167 struct sighand_struct *sighand; 1175 struct sighand_struct *sighand;
1168 1176
1169 sigset_t blocked, real_blocked; 1177 sigset_t blocked, real_blocked;
1170 sigset_t saved_sigmask; /* To be restored with TIF_RESTORE_SIGMASK */ 1178 sigset_t saved_sigmask; /* restored if set_restore_sigmask() was used */
1171 struct sigpending pending; 1179 struct sigpending pending;
1172 1180
1173 unsigned long sas_ss_sp; 1181 unsigned long sas_ss_sp;
@@ -1669,7 +1677,10 @@ extern struct pid_namespace init_pid_ns;
1669extern struct task_struct *find_task_by_pid_type_ns(int type, int pid, 1677extern struct task_struct *find_task_by_pid_type_ns(int type, int pid,
1670 struct pid_namespace *ns); 1678 struct pid_namespace *ns);
1671 1679
1672extern struct task_struct *find_task_by_pid(pid_t nr); 1680static inline struct task_struct *__deprecated find_task_by_pid(pid_t nr)
1681{
1682 return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
1683}
1673extern struct task_struct *find_task_by_vpid(pid_t nr); 1684extern struct task_struct *find_task_by_vpid(pid_t nr);
1674extern struct task_struct *find_task_by_pid_ns(pid_t nr, 1685extern struct task_struct *find_task_by_pid_ns(pid_t nr,
1675 struct pid_namespace *ns); 1686 struct pid_namespace *ns);
@@ -1745,8 +1756,7 @@ extern void zap_other_threads(struct task_struct *p);
1745extern int kill_proc(pid_t, int, int); 1756extern int kill_proc(pid_t, int, int);
1746extern struct sigqueue *sigqueue_alloc(void); 1757extern struct sigqueue *sigqueue_alloc(void);
1747extern void sigqueue_free(struct sigqueue *); 1758extern void sigqueue_free(struct sigqueue *);
1748extern int send_sigqueue(int, struct sigqueue *, struct task_struct *); 1759extern int send_sigqueue(struct sigqueue *, struct task_struct *, int group);
1749extern int send_group_sigqueue(int, struct sigqueue *, struct task_struct *);
1750extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *); 1760extern int do_sigaction(int, struct k_sigaction *, struct k_sigaction *);
1751extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long); 1761extern int do_sigaltstack(const stack_t __user *, stack_t __user *, unsigned long);
1752 1762
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 5b5369c3c209..a66304a09955 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -1,6 +1,5 @@
1#ifndef _LINUX_SEQ_FILE_H 1#ifndef _LINUX_SEQ_FILE_H
2#define _LINUX_SEQ_FILE_H 2#define _LINUX_SEQ_FILE_H
3#ifdef __KERNEL__
4 3
5#include <linux/types.h> 4#include <linux/types.h>
6#include <linux/string.h> 5#include <linux/string.h>
@@ -69,4 +68,3 @@ extern struct list_head *seq_list_next(void *v, struct list_head *head,
69 loff_t *ppos); 68 loff_t *ppos);
70 69
71#endif 70#endif
72#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 7cb094a82456..d32123ae08ad 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -149,13 +149,15 @@
149/* Freescale ColdFire */ 149/* Freescale ColdFire */
150#define PORT_MCF 78 150#define PORT_MCF 78
151 151
152#define PORT_SC26XX 79 152/* Blackfin SPORT */
153 153#define PORT_BFIN_SPORT 79
154 154
155/* MN10300 on-chip UART numbers */ 155/* MN10300 on-chip UART numbers */
156#define PORT_MN10300 80 156#define PORT_MN10300 80
157#define PORT_MN10300_CTS 81 157#define PORT_MN10300_CTS 81
158 158
159#define PORT_SC26XX 82
160
159#ifdef __KERNEL__ 161#ifdef __KERNEL__
160 162
161#include <linux/compiler.h> 163#include <linux/compiler.h>
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 42d2e0a948f4..84f997f8aa53 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -362,8 +362,6 @@ int unhandled_signal(struct task_struct *tsk, int sig);
362#define sig_kernel_stop(sig) \ 362#define sig_kernel_stop(sig) \
363 (((sig) < SIGRTMIN) && siginmask(sig, SIG_KERNEL_STOP_MASK)) 363 (((sig) < SIGRTMIN) && siginmask(sig, SIG_KERNEL_STOP_MASK))
364 364
365#define sig_needs_tasklist(sig) ((sig) == SIGCONT)
366
367#define sig_user_defined(t, signr) \ 365#define sig_user_defined(t, signr) \
368 (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \ 366 (((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_DFL) && \
369 ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN)) 367 ((t)->sighand->action[(signr)-1].sa.sa_handler != SIG_IGN))
diff --git a/include/linux/slab.h b/include/linux/slab.h
index f62caaad94e0..805ed4b92f9a 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -9,8 +9,6 @@
9#ifndef _LINUX_SLAB_H 9#ifndef _LINUX_SLAB_H
10#define _LINUX_SLAB_H 10#define _LINUX_SLAB_H
11 11
12#ifdef __KERNEL__
13
14#include <linux/gfp.h> 12#include <linux/gfp.h>
15#include <linux/types.h> 13#include <linux/types.h>
16 14
@@ -29,6 +27,13 @@
29#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */ 27#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
30#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */ 28#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
31 29
30/* Flag to prevent checks on free */
31#ifdef CONFIG_DEBUG_OBJECTS
32# define SLAB_DEBUG_OBJECTS 0x00400000UL
33#else
34# define SLAB_DEBUG_OBJECTS 0x00000000UL
35#endif
36
32/* The following flags affect the page allocator grouping pages by mobility */ 37/* The following flags affect the page allocator grouping pages by mobility */
33#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */ 38#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
34#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */ 39#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
@@ -276,5 +281,4 @@ extern const struct seq_operations slabinfo_op;
276ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *); 281ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
277#endif 282#endif
278 283
279#endif /* __KERNEL__ */
280#endif /* _LINUX_SLAB_H */ 284#endif /* _LINUX_SLAB_H */
diff --git a/include/linux/smb_fs_i.h b/include/linux/smb_fs_i.h
index 8516954a5141..8ccf4eca2c3d 100644
--- a/include/linux/smb_fs_i.h
+++ b/include/linux/smb_fs_i.h
@@ -9,7 +9,6 @@
9#ifndef _LINUX_SMB_FS_I 9#ifndef _LINUX_SMB_FS_I
10#define _LINUX_SMB_FS_I 10#define _LINUX_SMB_FS_I
11 11
12#ifdef __KERNEL__
13#include <linux/types.h> 12#include <linux/types.h>
14#include <linux/fs.h> 13#include <linux/fs.h>
15 14
@@ -36,4 +35,3 @@ struct smb_inode_info {
36}; 35};
37 36
38#endif 37#endif
39#endif
diff --git a/include/linux/smb_fs_sb.h b/include/linux/smb_fs_sb.h
index 3aa97aa4277f..8a060a7040d8 100644
--- a/include/linux/smb_fs_sb.h
+++ b/include/linux/smb_fs_sb.h
@@ -9,8 +9,6 @@
9#ifndef _SMB_FS_SB 9#ifndef _SMB_FS_SB
10#define _SMB_FS_SB 10#define _SMB_FS_SB
11 11
12#ifdef __KERNEL__
13
14#include <linux/types.h> 12#include <linux/types.h>
15#include <linux/smb.h> 13#include <linux/smb.h>
16 14
@@ -96,6 +94,4 @@ smb_unlock_server(struct smb_sb_info *server)
96 up(&(server->sem)); 94 up(&(server->sem));
97} 95}
98 96
99#endif /* __KERNEL__ */
100
101#endif 97#endif
diff --git a/include/linux/svga.h b/include/linux/svga.h
index 13ad0b82ac28..c59a51a2b0e7 100644
--- a/include/linux/svga.h
+++ b/include/linux/svga.h
@@ -1,8 +1,6 @@
1#ifndef _LINUX_SVGA_H 1#ifndef _LINUX_SVGA_H
2#define _LINUX_SVGA_H 2#define _LINUX_SVGA_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/pci.h> 4#include <linux/pci.h>
7#include <video/vga.h> 5#include <video/vga.h>
8 6
@@ -122,6 +120,5 @@ void svga_set_timings(const struct svga_timing_regs *tm, struct fb_var_screeninf
122 120
123int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix); 121int svga_match_format(const struct svga_fb_format *frm, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix);
124 122
125#endif /* __KERNEL__ */
126#endif /* _LINUX_SVGA_H */ 123#endif /* _LINUX_SVGA_H */
127 124
diff --git a/include/linux/textsearch.h b/include/linux/textsearch.h
index 004808a6df1d..6f371f24160b 100644
--- a/include/linux/textsearch.h
+++ b/include/linux/textsearch.h
@@ -1,8 +1,6 @@
1#ifndef __LINUX_TEXTSEARCH_H 1#ifndef __LINUX_TEXTSEARCH_H
2#define __LINUX_TEXTSEARCH_H 2#define __LINUX_TEXTSEARCH_H
3 3
4#ifdef __KERNEL__
5
6#include <linux/types.h> 4#include <linux/types.h>
7#include <linux/list.h> 5#include <linux/list.h>
8#include <linux/kernel.h> 6#include <linux/kernel.h>
@@ -177,6 +175,4 @@ static inline void *ts_config_priv(struct ts_config *conf)
177 return ((u8 *) conf + TS_PRIV_ALIGN(sizeof(struct ts_config))); 175 return ((u8 *) conf + TS_PRIV_ALIGN(sizeof(struct ts_config)));
178} 176}
179 177
180#endif /* __KERNEL__ */
181
182#endif 178#endif
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index accd7bad35b0..38a56477f27a 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -92,6 +92,31 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
92#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED) 92#define set_need_resched() set_thread_flag(TIF_NEED_RESCHED)
93#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED) 93#define clear_need_resched() clear_thread_flag(TIF_NEED_RESCHED)
94 94
95#endif 95#if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK
96/*
97 * An arch can define its own version of set_restore_sigmask() to get the
98 * job done however works, with or without TIF_RESTORE_SIGMASK.
99 */
100#define HAVE_SET_RESTORE_SIGMASK 1
101
102/**
103 * set_restore_sigmask() - make sure saved_sigmask processing gets done
104 *
105 * This sets TIF_RESTORE_SIGMASK and ensures that the arch signal code
106 * will run before returning to user mode, to process the flag. For
107 * all callers, TIF_SIGPENDING is already set or it's no harm to set
108 * it. TIF_RESTORE_SIGMASK need not be in the set of bits that the
109 * arch code will notice on return to user mode, in case those bits
110 * are scarce. We set TIF_SIGPENDING here to ensure that the arch
111 * signal code always gets run when TIF_RESTORE_SIGMASK is set.
112 */
113static inline void set_restore_sigmask(void)
114{
115 set_thread_flag(TIF_RESTORE_SIGMASK);
116 set_thread_flag(TIF_SIGPENDING);
117}
118#endif /* TIF_RESTORE_SIGMASK && !HAVE_SET_RESTORE_SIGMASK */
119
120#endif /* __KERNEL__ */
96 121
97#endif /* _LINUX_THREAD_INFO_H */ 122#endif /* _LINUX_THREAD_INFO_H */
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 979fefdeb862..d4ba79248a27 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -4,6 +4,7 @@
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/ktime.h> 5#include <linux/ktime.h>
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7#include <linux/debugobjects.h>
7 8
8struct tvec_base; 9struct tvec_base;
9 10
@@ -25,6 +26,7 @@ struct timer_list {
25extern struct tvec_base boot_tvec_bases; 26extern struct tvec_base boot_tvec_bases;
26 27
27#define TIMER_INITIALIZER(_function, _expires, _data) { \ 28#define TIMER_INITIALIZER(_function, _expires, _data) { \
29 .entry = { .prev = TIMER_ENTRY_STATIC }, \
28 .function = (_function), \ 30 .function = (_function), \
29 .expires = (_expires), \ 31 .expires = (_expires), \
30 .data = (_data), \ 32 .data = (_data), \
@@ -38,6 +40,17 @@ extern struct tvec_base boot_tvec_bases;
38void init_timer(struct timer_list *timer); 40void init_timer(struct timer_list *timer);
39void init_timer_deferrable(struct timer_list *timer); 41void init_timer_deferrable(struct timer_list *timer);
40 42
43#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
44extern void init_timer_on_stack(struct timer_list *timer);
45extern void destroy_timer_on_stack(struct timer_list *timer);
46#else
47static inline void destroy_timer_on_stack(struct timer_list *timer) { }
48static inline void init_timer_on_stack(struct timer_list *timer)
49{
50 init_timer(timer);
51}
52#endif
53
41static inline void setup_timer(struct timer_list * timer, 54static inline void setup_timer(struct timer_list * timer,
42 void (*function)(unsigned long), 55 void (*function)(unsigned long),
43 unsigned long data) 56 unsigned long data)
@@ -47,6 +60,15 @@ static inline void setup_timer(struct timer_list * timer,
47 init_timer(timer); 60 init_timer(timer);
48} 61}
49 62
63static inline void setup_timer_on_stack(struct timer_list *timer,
64 void (*function)(unsigned long),
65 unsigned long data)
66{
67 timer->function = function;
68 timer->data = data;
69 init_timer_on_stack(timer);
70}
71
50/** 72/**
51 * timer_pending - is a timer pending? 73 * timer_pending - is a timer pending?
52 * @timer: the timer in question 74 * @timer: the timer in question
@@ -164,5 +186,4 @@ unsigned long __round_jiffies_relative(unsigned long j, int cpu);
164unsigned long round_jiffies(unsigned long j); 186unsigned long round_jiffies(unsigned long j);
165unsigned long round_jiffies_relative(unsigned long j); 187unsigned long round_jiffies_relative(unsigned long j);
166 188
167
168#endif 189#endif
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 265831ccaa88..7f7121f9c968 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -177,27 +177,33 @@ struct signal_struct;
177 * size each time the window is created or resized anyway. 177 * size each time the window is created or resized anyway.
178 * - TYT, 9/14/92 178 * - TYT, 9/14/92
179 */ 179 */
180
181struct tty_operations;
182
180struct tty_struct { 183struct tty_struct {
181 int magic; 184 int magic;
182 struct tty_driver *driver; 185 struct tty_driver *driver;
186 const struct tty_operations *ops;
183 int index; 187 int index;
184 struct tty_ldisc ldisc; 188 struct tty_ldisc ldisc;
185 struct mutex termios_mutex; 189 struct mutex termios_mutex;
190 spinlock_t ctrl_lock;
191 /* Termios values are protected by the termios mutex */
186 struct ktermios *termios, *termios_locked; 192 struct ktermios *termios, *termios_locked;
187 char name[64]; 193 char name[64];
188 struct pid *pgrp; 194 struct pid *pgrp; /* Protected by ctrl lock */
189 struct pid *session; 195 struct pid *session;
190 unsigned long flags; 196 unsigned long flags;
191 int count; 197 int count;
192 struct winsize winsize; 198 struct winsize winsize; /* termios mutex */
193 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1; 199 unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
194 unsigned char low_latency:1, warned:1; 200 unsigned char low_latency:1, warned:1;
195 unsigned char ctrl_status; 201 unsigned char ctrl_status; /* ctrl_lock */
196 unsigned int receive_room; /* Bytes free for queue */ 202 unsigned int receive_room; /* Bytes free for queue */
197 203
198 struct tty_struct *link; 204 struct tty_struct *link;
199 struct fasync_struct *fasync; 205 struct fasync_struct *fasync;
200 struct tty_bufhead buf; 206 struct tty_bufhead buf; /* Locked internally */
201 int alt_speed; /* For magic substitution of 38400 bps */ 207 int alt_speed; /* For magic substitution of 38400 bps */
202 wait_queue_head_t write_wait; 208 wait_queue_head_t write_wait;
203 wait_queue_head_t read_wait; 209 wait_queue_head_t read_wait;
@@ -211,6 +217,7 @@ struct tty_struct {
211 /* 217 /*
212 * The following is data for the N_TTY line discipline. For 218 * The following is data for the N_TTY line discipline. For
213 * historical reasons, this is included in the tty structure. 219 * historical reasons, this is included in the tty structure.
220 * Mostly locked by the BKL.
214 */ 221 */
215 unsigned int column; 222 unsigned int column;
216 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1; 223 unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
@@ -292,8 +299,15 @@ extern void tty_unregister_device(struct tty_driver *driver, unsigned index);
292extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp, 299extern int tty_read_raw_data(struct tty_struct *tty, unsigned char *bufp,
293 int buflen); 300 int buflen);
294extern void tty_write_message(struct tty_struct *tty, char *msg); 301extern void tty_write_message(struct tty_struct *tty, char *msg);
302extern int tty_put_char(struct tty_struct *tty, unsigned char c);
303extern int tty_chars_in_buffer(struct tty_struct *tty);
304extern int tty_write_room(struct tty_struct *tty);
305extern void tty_driver_flush_buffer(struct tty_struct *tty);
306extern void tty_throttle(struct tty_struct *tty);
307extern void tty_unthrottle(struct tty_struct *tty);
295 308
296extern int is_current_pgrp_orphaned(void); 309extern int is_current_pgrp_orphaned(void);
310extern struct pid *tty_get_pgrp(struct tty_struct *tty);
297extern int is_ignored(int sig); 311extern int is_ignored(int sig);
298extern int tty_signal(int sig, struct tty_struct *tty); 312extern int tty_signal(int sig, struct tty_struct *tty);
299extern void tty_hangup(struct tty_struct * tty); 313extern void tty_hangup(struct tty_struct * tty);
@@ -323,8 +337,7 @@ extern void tty_ldisc_put(int);
323extern void tty_wakeup(struct tty_struct *tty); 337extern void tty_wakeup(struct tty_struct *tty);
324extern void tty_ldisc_flush(struct tty_struct *tty); 338extern void tty_ldisc_flush(struct tty_struct *tty);
325 339
326extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 340extern long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
327 unsigned long arg);
328extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file, 341extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
329 unsigned int cmd, unsigned long arg); 342 unsigned int cmd, unsigned long arg);
330extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); 343extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 21f69aca4505..59f1c0bd8f9c 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -12,11 +12,15 @@
12 * This routine is called when a particular tty device is opened. 12 * This routine is called when a particular tty device is opened.
13 * This routine is mandatory; if this routine is not filled in, 13 * This routine is mandatory; if this routine is not filled in,
14 * the attempted open will fail with ENODEV. 14 * the attempted open will fail with ENODEV.
15 *
16 * Required method.
15 * 17 *
16 * void (*close)(struct tty_struct * tty, struct file * filp); 18 * void (*close)(struct tty_struct * tty, struct file * filp);
17 * 19 *
18 * This routine is called when a particular tty device is closed. 20 * This routine is called when a particular tty device is closed.
19 * 21 *
22 * Required method.
23 *
20 * int (*write)(struct tty_struct * tty, 24 * int (*write)(struct tty_struct * tty,
21 * const unsigned char *buf, int count); 25 * const unsigned char *buf, int count);
22 * 26 *
@@ -26,7 +30,9 @@
26 * number of characters actually accepted for writing. This 30 * number of characters actually accepted for writing. This
27 * routine is mandatory. 31 * routine is mandatory.
28 * 32 *
29 * void (*put_char)(struct tty_struct *tty, unsigned char ch); 33 * Optional: Required for writable devices.
34 *
35 * int (*put_char)(struct tty_struct *tty, unsigned char ch);
30 * 36 *
31 * This routine is called by the kernel to write a single 37 * This routine is called by the kernel to write a single
32 * character to the tty device. If the kernel uses this routine, 38 * character to the tty device. If the kernel uses this routine,
@@ -34,10 +40,18 @@
34 * done stuffing characters into the driver. If there is no room 40 * done stuffing characters into the driver. If there is no room
35 * in the queue, the character is ignored. 41 * in the queue, the character is ignored.
36 * 42 *
43 * Optional: Kernel will use the write method if not provided.
44 *
45 * Note: Do not call this function directly, call tty_put_char
46 *
37 * void (*flush_chars)(struct tty_struct *tty); 47 * void (*flush_chars)(struct tty_struct *tty);
38 * 48 *
39 * This routine is called by the kernel after it has written a 49 * This routine is called by the kernel after it has written a
40 * series of characters to the tty device using put_char(). 50 * series of characters to the tty device using put_char().
51 *
52 * Optional:
53 *
54 * Note: Do not call this function directly, call tty_driver_flush_chars
41 * 55 *
42 * int (*write_room)(struct tty_struct *tty); 56 * int (*write_room)(struct tty_struct *tty);
43 * 57 *
@@ -45,6 +59,10 @@
45 * will accept for queuing to be written. This number is subject 59 * will accept for queuing to be written. This number is subject
46 * to change as output buffers get emptied, or if the output flow 60 * to change as output buffers get emptied, or if the output flow
47 * control is acted. 61 * control is acted.
62 *
63 * Required if write method is provided else not needed.
64 *
65 * Note: Do not call this function directly, call tty_write_room
48 * 66 *
49 * int (*ioctl)(struct tty_struct *tty, struct file * file, 67 * int (*ioctl)(struct tty_struct *tty, struct file * file,
50 * unsigned int cmd, unsigned long arg); 68 * unsigned int cmd, unsigned long arg);
@@ -53,28 +71,37 @@
53 * device-specific ioctl's. If the ioctl number passed in cmd 71 * device-specific ioctl's. If the ioctl number passed in cmd
54 * is not recognized by the driver, it should return ENOIOCTLCMD. 72 * is not recognized by the driver, it should return ENOIOCTLCMD.
55 * 73 *
74 * Optional
75 *
56 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file, 76 * long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
57 * unsigned int cmd, unsigned long arg); 77 * unsigned int cmd, unsigned long arg);
58 * 78 *
59 * implement ioctl processing for 32 bit process on 64 bit system 79 * implement ioctl processing for 32 bit process on 64 bit system
80 *
81 * Optional
60 * 82 *
61 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old); 83 * void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
62 * 84 *
63 * This routine allows the tty driver to be notified when 85 * This routine allows the tty driver to be notified when
64 * device's termios settings have changed. Note that a 86 * device's termios settings have changed.
65 * well-designed tty driver should be prepared to accept the case 87 *
66 * where old == NULL, and try to do something rational. 88 * Optional: Called under the termios lock
89 *
67 * 90 *
68 * void (*set_ldisc)(struct tty_struct *tty); 91 * void (*set_ldisc)(struct tty_struct *tty);
69 * 92 *
70 * This routine allows the tty driver to be notified when the 93 * This routine allows the tty driver to be notified when the
71 * device's termios settings have changed. 94 * device's termios settings have changed.
95 *
96 * Optional: Called under BKL (currently)
72 * 97 *
73 * void (*throttle)(struct tty_struct * tty); 98 * void (*throttle)(struct tty_struct * tty);
74 * 99 *
75 * This routine notifies the tty driver that input buffers for 100 * This routine notifies the tty driver that input buffers for
76 * the line discipline are close to full, and it should somehow 101 * the line discipline are close to full, and it should somehow
77 * signal that no more characters should be sent to the tty. 102 * signal that no more characters should be sent to the tty.
103 *
104 * Optional: Always invoke via tty_throttle();
78 * 105 *
79 * void (*unthrottle)(struct tty_struct * tty); 106 * void (*unthrottle)(struct tty_struct * tty);
80 * 107 *
@@ -82,21 +109,33 @@
82 * that characters can now be sent to the tty without fear of 109 * that characters can now be sent to the tty without fear of
83 * overrunning the input buffers of the line disciplines. 110 * overrunning the input buffers of the line disciplines.
84 * 111 *
112 * Optional: Always invoke via tty_unthrottle();
113 *
85 * void (*stop)(struct tty_struct *tty); 114 * void (*stop)(struct tty_struct *tty);
86 * 115 *
87 * This routine notifies the tty driver that it should stop 116 * This routine notifies the tty driver that it should stop
88 * outputting characters to the tty device. 117 * outputting characters to the tty device.
118 *
119 * Optional:
120 *
121 * Note: Call stop_tty not this method.
89 * 122 *
90 * void (*start)(struct tty_struct *tty); 123 * void (*start)(struct tty_struct *tty);
91 * 124 *
92 * This routine notifies the tty driver that it resume sending 125 * This routine notifies the tty driver that it resume sending
93 * characters to the tty device. 126 * characters to the tty device.
127 *
128 * Optional:
129 *
130 * Note: Call start_tty not this method.
94 * 131 *
95 * void (*hangup)(struct tty_struct *tty); 132 * void (*hangup)(struct tty_struct *tty);
96 * 133 *
97 * This routine notifies the tty driver that it should hangup the 134 * This routine notifies the tty driver that it should hangup the
98 * tty device. 135 * tty device.
99 * 136 *
137 * Required:
138 *
100 * void (*break_ctl)(struct tty_stuct *tty, int state); 139 * void (*break_ctl)(struct tty_stuct *tty, int state);
101 * 140 *
102 * This optional routine requests the tty driver to turn on or 141 * This optional routine requests the tty driver to turn on or
@@ -106,18 +145,26 @@
106 * 145 *
107 * If this routine is implemented, the high-level tty driver will 146 * If this routine is implemented, the high-level tty driver will
108 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK, 147 * handle the following ioctls: TCSBRK, TCSBRKP, TIOCSBRK,
109 * TIOCCBRK. Otherwise, these ioctls will be passed down to the 148 * TIOCCBRK.
110 * driver to handle. 149 *
150 * Optional: Required for TCSBRK/BRKP/etc handling.
111 * 151 *
112 * void (*wait_until_sent)(struct tty_struct *tty, int timeout); 152 * void (*wait_until_sent)(struct tty_struct *tty, int timeout);
113 * 153 *
114 * This routine waits until the device has written out all of the 154 * This routine waits until the device has written out all of the
115 * characters in its transmitter FIFO. 155 * characters in its transmitter FIFO.
116 * 156 *
157 * Optional: If not provided the device is assumed to have no FIFO
158 *
159 * Note: Usually correct to call tty_wait_until_sent
160 *
117 * void (*send_xchar)(struct tty_struct *tty, char ch); 161 * void (*send_xchar)(struct tty_struct *tty, char ch);
118 * 162 *
119 * This routine is used to send a high-priority XON/XOFF 163 * This routine is used to send a high-priority XON/XOFF
120 * character to the device. 164 * character to the device.
165 *
166 * Optional: If not provided then the write method is called under
167 * the atomic write lock to keep it serialized with the ldisc.
121 */ 168 */
122 169
123#include <linux/fs.h> 170#include <linux/fs.h>
@@ -132,7 +179,7 @@ struct tty_operations {
132 void (*close)(struct tty_struct * tty, struct file * filp); 179 void (*close)(struct tty_struct * tty, struct file * filp);
133 int (*write)(struct tty_struct * tty, 180 int (*write)(struct tty_struct * tty,
134 const unsigned char *buf, int count); 181 const unsigned char *buf, int count);
135 void (*put_char)(struct tty_struct *tty, unsigned char ch); 182 int (*put_char)(struct tty_struct *tty, unsigned char ch);
136 void (*flush_chars)(struct tty_struct *tty); 183 void (*flush_chars)(struct tty_struct *tty);
137 int (*write_room)(struct tty_struct *tty); 184 int (*write_room)(struct tty_struct *tty);
138 int (*chars_in_buffer)(struct tty_struct *tty); 185 int (*chars_in_buffer)(struct tty_struct *tty);
@@ -153,8 +200,6 @@ struct tty_operations {
153 void (*send_xchar)(struct tty_struct *tty, char ch); 200 void (*send_xchar)(struct tty_struct *tty, char ch);
154 int (*read_proc)(char *page, char **start, off_t off, 201 int (*read_proc)(char *page, char **start, off_t off,
155 int count, int *eof, void *data); 202 int count, int *eof, void *data);
156 int (*write_proc)(struct file *file, const char __user *buffer,
157 unsigned long count, void *data);
158 int (*tiocmget)(struct tty_struct *tty, struct file *file); 203 int (*tiocmget)(struct tty_struct *tty, struct file *file);
159 int (*tiocmset)(struct tty_struct *tty, struct file *file, 204 int (*tiocmset)(struct tty_struct *tty, struct file *file,
160 unsigned int set, unsigned int clear); 205 unsigned int set, unsigned int clear);
@@ -190,48 +235,13 @@ struct tty_driver {
190 struct tty_struct **ttys; 235 struct tty_struct **ttys;
191 struct ktermios **termios; 236 struct ktermios **termios;
192 struct ktermios **termios_locked; 237 struct ktermios **termios_locked;
193 void *driver_state; /* only used for the PTY driver */ 238 void *driver_state;
194 239
195 /* 240 /*
196 * Interface routines from the upper tty layer to the tty 241 * Driver methods
197 * driver. Will be replaced with struct tty_operations.
198 */ 242 */
199 int (*open)(struct tty_struct * tty, struct file * filp);
200 void (*close)(struct tty_struct * tty, struct file * filp);
201 int (*write)(struct tty_struct * tty,
202 const unsigned char *buf, int count);
203 void (*put_char)(struct tty_struct *tty, unsigned char ch);
204 void (*flush_chars)(struct tty_struct *tty);
205 int (*write_room)(struct tty_struct *tty);
206 int (*chars_in_buffer)(struct tty_struct *tty);
207 int (*ioctl)(struct tty_struct *tty, struct file * file,
208 unsigned int cmd, unsigned long arg);
209 long (*compat_ioctl)(struct tty_struct *tty, struct file * file,
210 unsigned int cmd, unsigned long arg);
211 void (*set_termios)(struct tty_struct *tty, struct ktermios * old);
212 void (*throttle)(struct tty_struct * tty);
213 void (*unthrottle)(struct tty_struct * tty);
214 void (*stop)(struct tty_struct *tty);
215 void (*start)(struct tty_struct *tty);
216 void (*hangup)(struct tty_struct *tty);
217 void (*break_ctl)(struct tty_struct *tty, int state);
218 void (*flush_buffer)(struct tty_struct *tty);
219 void (*set_ldisc)(struct tty_struct *tty);
220 void (*wait_until_sent)(struct tty_struct *tty, int timeout);
221 void (*send_xchar)(struct tty_struct *tty, char ch);
222 int (*read_proc)(char *page, char **start, off_t off,
223 int count, int *eof, void *data);
224 int (*write_proc)(struct file *file, const char __user *buffer,
225 unsigned long count, void *data);
226 int (*tiocmget)(struct tty_struct *tty, struct file *file);
227 int (*tiocmset)(struct tty_struct *tty, struct file *file,
228 unsigned int set, unsigned int clear);
229#ifdef CONFIG_CONSOLE_POLL
230 int (*poll_init)(struct tty_driver *driver, int line, char *options);
231 int (*poll_get_char)(struct tty_driver *driver, int line);
232 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
233#endif
234 243
244 const struct tty_operations *ops;
235 struct list_head tty_drivers; 245 struct list_head tty_drivers;
236}; 246};
237 247
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index b7b3362f7717..f462439cc288 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -114,6 +114,9 @@ struct file;
114int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *, 114int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
115 void __user *, size_t *, loff_t *); 115 void __user *, size_t *, loff_t *);
116 116
117void get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
118 struct backing_dev_info *bdi);
119
117void page_writeback_init(void); 120void page_writeback_init(void);
118void balance_dirty_pages_ratelimited_nr(struct address_space *mapping, 121void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
119 unsigned long nr_pages_dirtied); 122 unsigned long nr_pages_dirtied);
diff --git a/include/net/compat.h b/include/net/compat.h
index 05fa5d0254ab..164cb682e220 100644
--- a/include/net/compat.h
+++ b/include/net/compat.h
@@ -42,5 +42,8 @@ extern int cmsghdr_from_user_compat_to_kern(struct msghdr *, struct sock *, unsi
42 42
43extern int compat_mc_setsockopt(struct sock *, int, int, char __user *, int, 43extern int compat_mc_setsockopt(struct sock *, int, int, char __user *, int,
44 int (*)(struct sock *, int, int, char __user *, int)); 44 int (*)(struct sock *, int, int, char __user *, int));
45extern int compat_mc_getsockopt(struct sock *, int, int, char __user *,
46 int __user *, int (*)(struct sock *, int, int, char __user *,
47 int __user *));
45 48
46#endif /* NET_COMPAT_H */ 49#endif /* NET_COMPAT_H */
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 56f3c94ae620..9a51ebad3f1f 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -405,7 +405,8 @@ struct sk_buff;
405struct ip_vs_protocol { 405struct ip_vs_protocol {
406 struct ip_vs_protocol *next; 406 struct ip_vs_protocol *next;
407 char *name; 407 char *name;
408 __u16 protocol; 408 u16 protocol;
409 u16 num_states;
409 int dont_defrag; 410 int dont_defrag;
410 atomic_t appcnt; /* counter of proto app incs */ 411 atomic_t appcnt; /* counter of proto app incs */
411 int *timeout_table; /* protocol timeout table */ 412 int *timeout_table; /* protocol timeout table */
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index 1bb7087833d3..a6874ba22d54 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -107,16 +107,6 @@ struct nf_conntrack_tuple_mask
107 } src; 107 } src;
108}; 108};
109 109
110/* This is optimized opposed to a memset of the whole structure. Everything we
111 * really care about is the source/destination unions */
112#define NF_CT_TUPLE_U_BLANK(tuple) \
113 do { \
114 (tuple)->src.u.all = 0; \
115 (tuple)->dst.u.all = 0; \
116 memset(&(tuple)->src.u3, 0, sizeof((tuple)->src.u3)); \
117 memset(&(tuple)->dst.u3, 0, sizeof((tuple)->dst.u3)); \
118 } while (0)
119
120#ifdef __KERNEL__ 110#ifdef __KERNEL__
121 111
122static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t) 112static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t)
diff --git a/include/net/route.h b/include/net/route.h
index c6338802e8f1..fc836ff824cc 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -116,7 +116,7 @@ extern int __ip_route_output_key(struct net *, struct rtable **, const struct f
116extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); 116extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
117extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); 117extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
118extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); 118extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin);
119extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu); 119extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev);
120extern void ip_rt_send_redirect(struct sk_buff *skb); 120extern void ip_rt_send_redirect(struct sk_buff *skb);
121 121
122extern unsigned inet_addr_type(struct net *net, __be32 addr); 122extern unsigned inet_addr_type(struct net *net, __be32 addr);
diff --git a/init/main.c b/init/main.c
index 624266b524d4..a87d4ca5c36c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -52,6 +52,7 @@
52#include <linux/unwind.h> 52#include <linux/unwind.h>
53#include <linux/buffer_head.h> 53#include <linux/buffer_head.h>
54#include <linux/debug_locks.h> 54#include <linux/debug_locks.h>
55#include <linux/debugobjects.h>
55#include <linux/lockdep.h> 56#include <linux/lockdep.h>
56#include <linux/pid_namespace.h> 57#include <linux/pid_namespace.h>
57#include <linux/device.h> 58#include <linux/device.h>
@@ -459,7 +460,7 @@ static void noinline __init_refok rest_init(void)
459 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); 460 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
460 numa_default_policy(); 461 numa_default_policy();
461 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); 462 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
462 kthreadd_task = find_task_by_pid(pid); 463 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
463 unlock_kernel(); 464 unlock_kernel();
464 465
465 /* 466 /*
@@ -543,6 +544,7 @@ asmlinkage void __init start_kernel(void)
543 */ 544 */
544 unwind_init(); 545 unwind_init();
545 lockdep_init(); 546 lockdep_init();
547 debug_objects_early_init();
546 cgroup_init_early(); 548 cgroup_init_early();
547 549
548 local_irq_disable(); 550 local_irq_disable();
@@ -638,6 +640,7 @@ asmlinkage void __init start_kernel(void)
638 enable_debug_pagealloc(); 640 enable_debug_pagealloc();
639 cpu_hotplug_init(); 641 cpu_hotplug_init();
640 kmem_cache_init(); 642 kmem_cache_init();
643 debug_objects_mem_init();
641 idr_init_cache(); 644 idr_init_cache();
642 setup_per_cpu_pageset(); 645 setup_per_cpu_pageset();
643 numa_policy_init(); 646 numa_policy_init();
@@ -802,6 +805,8 @@ static int noinline init_post(void)
802 (void) sys_dup(0); 805 (void) sys_dup(0);
803 (void) sys_dup(0); 806 (void) sys_dup(0);
804 807
808 current->signal->flags |= SIGNAL_UNKILLABLE;
809
805 if (ramdisk_execute_command) { 810 if (ramdisk_execute_command) {
806 run_init_process(ramdisk_execute_command); 811 run_init_process(ramdisk_execute_command);
807 printk(KERN_WARNING "Failed to execute %s\n", 812 printk(KERN_WARNING "Failed to execute %s\n",
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index b9d467d83fc1..fbc6fc8949b4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -575,7 +575,7 @@ static struct inode_operations cgroup_dir_inode_operations;
575static struct file_operations proc_cgroupstats_operations; 575static struct file_operations proc_cgroupstats_operations;
576 576
577static struct backing_dev_info cgroup_backing_dev_info = { 577static struct backing_dev_info cgroup_backing_dev_info = {
578 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 578 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
579}; 579};
580 580
581static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb) 581static struct inode *cgroup_new_inode(mode_t mode, struct super_block *sb)
diff --git a/kernel/compat.c b/kernel/compat.c
index e1ef04870c2a..4a856a3643bb 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -898,7 +898,7 @@ asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat
898 898
899 current->state = TASK_INTERRUPTIBLE; 899 current->state = TASK_INTERRUPTIBLE;
900 schedule(); 900 schedule();
901 set_thread_flag(TIF_RESTORE_SIGMASK); 901 set_restore_sigmask();
902 return -ERESTARTNOHAND; 902 return -ERESTARTNOHAND;
903} 903}
904#endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ 904#endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */
@@ -1080,4 +1080,3 @@ compat_sys_sysinfo(struct compat_sysinfo __user *info)
1080 1080
1081 return 0; 1081 return 0;
1082} 1082}
1083
diff --git a/kernel/cpu.c b/kernel/cpu.c
index a98f6ab16ecd..c77bc3a1c722 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -215,7 +215,7 @@ static int __ref _cpu_down(unsigned int cpu, int tasks_frozen)
215 __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod, 215 __raw_notifier_call_chain(&cpu_chain, CPU_DOWN_FAILED | mod,
216 hcpu, nr_calls, NULL); 216 hcpu, nr_calls, NULL);
217 printk("%s: attempt to take down CPU %u failed\n", 217 printk("%s: attempt to take down CPU %u failed\n",
218 __FUNCTION__, cpu); 218 __func__, cpu);
219 err = -EINVAL; 219 err = -EINVAL;
220 goto out_release; 220 goto out_release;
221 } 221 }
@@ -295,7 +295,7 @@ static int __cpuinit _cpu_up(unsigned int cpu, int tasks_frozen)
295 if (ret == NOTIFY_BAD) { 295 if (ret == NOTIFY_BAD) {
296 nr_calls--; 296 nr_calls--;
297 printk("%s: attempt to bring up CPU %u failed\n", 297 printk("%s: attempt to bring up CPU %u failed\n",
298 __FUNCTION__, cpu); 298 __func__, cpu);
299 ret = -EINVAL; 299 ret = -EINVAL;
300 goto out_notify; 300 goto out_notify;
301 } 301 }
diff --git a/kernel/exit.c b/kernel/exit.c
index ae0f2c4e452b..d3ad54677f9c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -52,6 +52,11 @@
52 52
53static void exit_mm(struct task_struct * tsk); 53static void exit_mm(struct task_struct * tsk);
54 54
55static inline int task_detached(struct task_struct *p)
56{
57 return p->exit_signal == -1;
58}
59
55static void __unhash_process(struct task_struct *p) 60static void __unhash_process(struct task_struct *p)
56{ 61{
57 nr_threads--; 62 nr_threads--;
@@ -160,7 +165,7 @@ repeat:
160 zap_leader = 0; 165 zap_leader = 0;
161 leader = p->group_leader; 166 leader = p->group_leader;
162 if (leader != p && thread_group_empty(leader) && leader->exit_state == EXIT_ZOMBIE) { 167 if (leader != p && thread_group_empty(leader) && leader->exit_state == EXIT_ZOMBIE) {
163 BUG_ON(leader->exit_signal == -1); 168 BUG_ON(task_detached(leader));
164 do_notify_parent(leader, leader->exit_signal); 169 do_notify_parent(leader, leader->exit_signal);
165 /* 170 /*
166 * If we were the last child thread and the leader has 171 * If we were the last child thread and the leader has
@@ -170,7 +175,7 @@ repeat:
170 * do_notify_parent() will have marked it self-reaping in 175 * do_notify_parent() will have marked it self-reaping in
171 * that case. 176 * that case.
172 */ 177 */
173 zap_leader = (leader->exit_signal == -1); 178 zap_leader = task_detached(leader);
174 } 179 }
175 180
176 write_unlock_irq(&tasklist_lock); 181 write_unlock_irq(&tasklist_lock);
@@ -329,13 +334,11 @@ void __set_special_pids(struct pid *pid)
329 pid_t nr = pid_nr(pid); 334 pid_t nr = pid_nr(pid);
330 335
331 if (task_session(curr) != pid) { 336 if (task_session(curr) != pid) {
332 detach_pid(curr, PIDTYPE_SID); 337 change_pid(curr, PIDTYPE_SID, pid);
333 attach_pid(curr, PIDTYPE_SID, pid);
334 set_task_session(curr, nr); 338 set_task_session(curr, nr);
335 } 339 }
336 if (task_pgrp(curr) != pid) { 340 if (task_pgrp(curr) != pid) {
337 detach_pid(curr, PIDTYPE_PGID); 341 change_pid(curr, PIDTYPE_PGID, pid);
338 attach_pid(curr, PIDTYPE_PGID, pid);
339 set_task_pgrp(curr, nr); 342 set_task_pgrp(curr, nr);
340 } 343 }
341} 344}
@@ -693,7 +696,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
693 if (unlikely(traced)) { 696 if (unlikely(traced)) {
694 /* Preserve ptrace links if someone else is tracing this child. */ 697 /* Preserve ptrace links if someone else is tracing this child. */
695 list_del_init(&p->ptrace_list); 698 list_del_init(&p->ptrace_list);
696 if (p->parent != p->real_parent) 699 if (ptrace_reparented(p))
697 list_add(&p->ptrace_list, &p->real_parent->ptrace_children); 700 list_add(&p->ptrace_list, &p->real_parent->ptrace_children);
698 } else { 701 } else {
699 /* If this child is being traced, then we're the one tracing it 702 /* If this child is being traced, then we're the one tracing it
@@ -717,18 +720,18 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
717 /* If this is a threaded reparent there is no need to 720 /* If this is a threaded reparent there is no need to
718 * notify anyone anything has happened. 721 * notify anyone anything has happened.
719 */ 722 */
720 if (p->real_parent->group_leader == father->group_leader) 723 if (same_thread_group(p->real_parent, father))
721 return; 724 return;
722 725
723 /* We don't want people slaying init. */ 726 /* We don't want people slaying init. */
724 if (p->exit_signal != -1) 727 if (!task_detached(p))
725 p->exit_signal = SIGCHLD; 728 p->exit_signal = SIGCHLD;
726 729
727 /* If we'd notified the old parent about this child's death, 730 /* If we'd notified the old parent about this child's death,
728 * also notify the new parent. 731 * also notify the new parent.
729 */ 732 */
730 if (!traced && p->exit_state == EXIT_ZOMBIE && 733 if (!traced && p->exit_state == EXIT_ZOMBIE &&
731 p->exit_signal != -1 && thread_group_empty(p)) 734 !task_detached(p) && thread_group_empty(p))
732 do_notify_parent(p, p->exit_signal); 735 do_notify_parent(p, p->exit_signal);
733 736
734 kill_orphaned_pgrp(p, father); 737 kill_orphaned_pgrp(p, father);
@@ -781,18 +784,18 @@ static void forget_original_parent(struct task_struct *father)
781 } else { 784 } else {
782 /* reparent ptraced task to its real parent */ 785 /* reparent ptraced task to its real parent */
783 __ptrace_unlink (p); 786 __ptrace_unlink (p);
784 if (p->exit_state == EXIT_ZOMBIE && p->exit_signal != -1 && 787 if (p->exit_state == EXIT_ZOMBIE && !task_detached(p) &&
785 thread_group_empty(p)) 788 thread_group_empty(p))
786 do_notify_parent(p, p->exit_signal); 789 do_notify_parent(p, p->exit_signal);
787 } 790 }
788 791
789 /* 792 /*
790 * if the ptraced child is a zombie with exit_signal == -1 793 * if the ptraced child is a detached zombie we must collect
791 * we must collect it before we exit, or it will remain 794 * it before we exit, or it will remain zombie forever since
792 * zombie forever since we prevented it from self-reap itself 795 * we prevented it from self-reap itself while it was being
793 * while it was being traced by us, to be able to see it in wait4. 796 * traced by us, to be able to see it in wait4.
794 */ 797 */
795 if (unlikely(ptrace && p->exit_state == EXIT_ZOMBIE && p->exit_signal == -1)) 798 if (unlikely(ptrace && p->exit_state == EXIT_ZOMBIE && task_detached(p)))
796 list_add(&p->ptrace_list, &ptrace_dead); 799 list_add(&p->ptrace_list, &ptrace_dead);
797 } 800 }
798 801
@@ -849,29 +852,30 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
849 * we have changed execution domain as these two values started 852 * we have changed execution domain as these two values started
850 * the same after a fork. 853 * the same after a fork.
851 */ 854 */
852 if (tsk->exit_signal != SIGCHLD && tsk->exit_signal != -1 && 855 if (tsk->exit_signal != SIGCHLD && !task_detached(tsk) &&
853 (tsk->parent_exec_id != tsk->real_parent->self_exec_id || 856 (tsk->parent_exec_id != tsk->real_parent->self_exec_id ||
854 tsk->self_exec_id != tsk->parent_exec_id) 857 tsk->self_exec_id != tsk->parent_exec_id) &&
855 && !capable(CAP_KILL)) 858 !capable(CAP_KILL))
856 tsk->exit_signal = SIGCHLD; 859 tsk->exit_signal = SIGCHLD;
857 860
858
859 /* If something other than our normal parent is ptracing us, then 861 /* If something other than our normal parent is ptracing us, then
860 * send it a SIGCHLD instead of honoring exit_signal. exit_signal 862 * send it a SIGCHLD instead of honoring exit_signal. exit_signal
861 * only has special meaning to our real parent. 863 * only has special meaning to our real parent.
862 */ 864 */
863 if (tsk->exit_signal != -1 && thread_group_empty(tsk)) { 865 if (!task_detached(tsk) && thread_group_empty(tsk)) {
864 int signal = tsk->parent == tsk->real_parent ? tsk->exit_signal : SIGCHLD; 866 int signal = ptrace_reparented(tsk) ?
867 SIGCHLD : tsk->exit_signal;
865 do_notify_parent(tsk, signal); 868 do_notify_parent(tsk, signal);
866 } else if (tsk->ptrace) { 869 } else if (tsk->ptrace) {
867 do_notify_parent(tsk, SIGCHLD); 870 do_notify_parent(tsk, SIGCHLD);
868 } 871 }
869 872
870 state = EXIT_ZOMBIE; 873 state = EXIT_ZOMBIE;
871 if (tsk->exit_signal == -1 && likely(!tsk->ptrace)) 874 if (task_detached(tsk) && likely(!tsk->ptrace))
872 state = EXIT_DEAD; 875 state = EXIT_DEAD;
873 tsk->exit_state = state; 876 tsk->exit_state = state;
874 877
878 /* mt-exec, de_thread() is waiting for us */
875 if (thread_group_leader(tsk) && 879 if (thread_group_leader(tsk) &&
876 tsk->signal->notify_count < 0 && 880 tsk->signal->notify_count < 0 &&
877 tsk->signal->group_exit_task) 881 tsk->signal->group_exit_task)
@@ -1115,12 +1119,13 @@ asmlinkage long sys_exit(int error_code)
1115NORET_TYPE void 1119NORET_TYPE void
1116do_group_exit(int exit_code) 1120do_group_exit(int exit_code)
1117{ 1121{
1122 struct signal_struct *sig = current->signal;
1123
1118 BUG_ON(exit_code & 0x80); /* core dumps don't get here */ 1124 BUG_ON(exit_code & 0x80); /* core dumps don't get here */
1119 1125
1120 if (current->signal->flags & SIGNAL_GROUP_EXIT) 1126 if (signal_group_exit(sig))
1121 exit_code = current->signal->group_exit_code; 1127 exit_code = sig->group_exit_code;
1122 else if (!thread_group_empty(current)) { 1128 else if (!thread_group_empty(current)) {
1123 struct signal_struct *const sig = current->signal;
1124 struct sighand_struct *const sighand = current->sighand; 1129 struct sighand_struct *const sighand = current->sighand;
1125 spin_lock_irq(&sighand->siglock); 1130 spin_lock_irq(&sighand->siglock);
1126 if (signal_group_exit(sig)) 1131 if (signal_group_exit(sig))
@@ -1172,7 +1177,7 @@ static int eligible_child(enum pid_type type, struct pid *pid, int options,
1172 * Do not consider detached threads that are 1177 * Do not consider detached threads that are
1173 * not ptraced: 1178 * not ptraced:
1174 */ 1179 */
1175 if (p->exit_signal == -1 && !p->ptrace) 1180 if (task_detached(p) && !p->ptrace)
1176 return 0; 1181 return 0;
1177 1182
1178 /* Wait for all children (clone and not) if __WALL is set; 1183 /* Wait for all children (clone and not) if __WALL is set;
@@ -1262,8 +1267,7 @@ static int wait_task_zombie(struct task_struct *p, int noreap,
1262 return 0; 1267 return 0;
1263 } 1268 }
1264 1269
1265 /* traced means p->ptrace, but not vice versa */ 1270 traced = ptrace_reparented(p);
1266 traced = (p->real_parent != p->parent);
1267 1271
1268 if (likely(!traced)) { 1272 if (likely(!traced)) {
1269 struct signal_struct *psig; 1273 struct signal_struct *psig;
@@ -1364,9 +1368,9 @@ static int wait_task_zombie(struct task_struct *p, int noreap,
1364 * If it's still not detached after that, don't release 1368 * If it's still not detached after that, don't release
1365 * it now. 1369 * it now.
1366 */ 1370 */
1367 if (p->exit_signal != -1) { 1371 if (!task_detached(p)) {
1368 do_notify_parent(p, p->exit_signal); 1372 do_notify_parent(p, p->exit_signal);
1369 if (p->exit_signal != -1) { 1373 if (!task_detached(p)) {
1370 p->exit_state = EXIT_ZOMBIE; 1374 p->exit_state = EXIT_ZOMBIE;
1371 p = NULL; 1375 p = NULL;
1372 } 1376 }
diff --git a/kernel/fork.c b/kernel/fork.c
index 068ffe007529..2bb675af4de3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -892,7 +892,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
892 sig->group_exit_code = 0; 892 sig->group_exit_code = 0;
893 sig->group_exit_task = NULL; 893 sig->group_exit_task = NULL;
894 sig->group_stop_count = 0; 894 sig->group_stop_count = 0;
895 sig->curr_target = NULL; 895 sig->curr_target = tsk;
896 init_sigpending(&sig->shared_pending); 896 init_sigpending(&sig->shared_pending);
897 INIT_LIST_HEAD(&sig->posix_timers); 897 INIT_LIST_HEAD(&sig->posix_timers);
898 898
diff --git a/kernel/futex.c b/kernel/futex.c
index e43945e995f5..98092c9817f4 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1266,11 +1266,13 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1266 if (!abs_time) 1266 if (!abs_time)
1267 schedule(); 1267 schedule();
1268 else { 1268 else {
1269 hrtimer_init(&t.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 1269 hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC,
1270 HRTIMER_MODE_ABS);
1270 hrtimer_init_sleeper(&t, current); 1271 hrtimer_init_sleeper(&t, current);
1271 t.timer.expires = *abs_time; 1272 t.timer.expires = *abs_time;
1272 1273
1273 hrtimer_start(&t.timer, t.timer.expires, HRTIMER_MODE_ABS); 1274 hrtimer_start(&t.timer, t.timer.expires,
1275 HRTIMER_MODE_ABS);
1274 if (!hrtimer_active(&t.timer)) 1276 if (!hrtimer_active(&t.timer))
1275 t.task = NULL; 1277 t.task = NULL;
1276 1278
@@ -1286,6 +1288,8 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1286 1288
1287 /* Flag if a timeout occured */ 1289 /* Flag if a timeout occured */
1288 rem = (t.task == NULL); 1290 rem = (t.task == NULL);
1291
1292 destroy_hrtimer_on_stack(&t.timer);
1289 } 1293 }
1290 } 1294 }
1291 __set_current_state(TASK_RUNNING); 1295 __set_current_state(TASK_RUNNING);
@@ -1367,7 +1371,8 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1367 1371
1368 if (time) { 1372 if (time) {
1369 to = &timeout; 1373 to = &timeout;
1370 hrtimer_init(&to->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); 1374 hrtimer_init_on_stack(&to->timer, CLOCK_REALTIME,
1375 HRTIMER_MODE_ABS);
1371 hrtimer_init_sleeper(to, current); 1376 hrtimer_init_sleeper(to, current);
1372 to->timer.expires = *time; 1377 to->timer.expires = *time;
1373 } 1378 }
@@ -1581,6 +1586,8 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1581 unqueue_me_pi(&q); 1586 unqueue_me_pi(&q);
1582 futex_unlock_mm(fshared); 1587 futex_unlock_mm(fshared);
1583 1588
1589 if (to)
1590 destroy_hrtimer_on_stack(&to->timer);
1584 return ret != -EINTR ? ret : -ERESTARTNOINTR; 1591 return ret != -EINTR ? ret : -ERESTARTNOINTR;
1585 1592
1586 out_unlock_release_sem: 1593 out_unlock_release_sem:
@@ -1588,6 +1595,8 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1588 1595
1589 out_release_sem: 1596 out_release_sem:
1590 futex_unlock_mm(fshared); 1597 futex_unlock_mm(fshared);
1598 if (to)
1599 destroy_hrtimer_on_stack(&to->timer);
1591 return ret; 1600 return ret;
1592 1601
1593 uaddr_faulted: 1602 uaddr_faulted:
@@ -1615,6 +1624,8 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1615 if (!ret && (uval != -EFAULT)) 1624 if (!ret && (uval != -EFAULT))
1616 goto retry; 1625 goto retry;
1617 1626
1627 if (to)
1628 destroy_hrtimer_on_stack(&to->timer);
1618 return ret; 1629 return ret;
1619} 1630}
1620 1631
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index dea4c9124ac8..9af1d6a8095e 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -43,6 +43,7 @@
43#include <linux/tick.h> 43#include <linux/tick.h>
44#include <linux/seq_file.h> 44#include <linux/seq_file.h>
45#include <linux/err.h> 45#include <linux/err.h>
46#include <linux/debugobjects.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48 49
@@ -342,6 +343,115 @@ ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs)
342 return res; 343 return res;
343} 344}
344 345
346#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
347
348static struct debug_obj_descr hrtimer_debug_descr;
349
350/*
351 * fixup_init is called when:
352 * - an active object is initialized
353 */
354static int hrtimer_fixup_init(void *addr, enum debug_obj_state state)
355{
356 struct hrtimer *timer = addr;
357
358 switch (state) {
359 case ODEBUG_STATE_ACTIVE:
360 hrtimer_cancel(timer);
361 debug_object_init(timer, &hrtimer_debug_descr);
362 return 1;
363 default:
364 return 0;
365 }
366}
367
368/*
369 * fixup_activate is called when:
370 * - an active object is activated
371 * - an unknown object is activated (might be a statically initialized object)
372 */
373static int hrtimer_fixup_activate(void *addr, enum debug_obj_state state)
374{
375 switch (state) {
376
377 case ODEBUG_STATE_NOTAVAILABLE:
378 WARN_ON_ONCE(1);
379 return 0;
380
381 case ODEBUG_STATE_ACTIVE:
382 WARN_ON(1);
383
384 default:
385 return 0;
386 }
387}
388
389/*
390 * fixup_free is called when:
391 * - an active object is freed
392 */
393static int hrtimer_fixup_free(void *addr, enum debug_obj_state state)
394{
395 struct hrtimer *timer = addr;
396
397 switch (state) {
398 case ODEBUG_STATE_ACTIVE:
399 hrtimer_cancel(timer);
400 debug_object_free(timer, &hrtimer_debug_descr);
401 return 1;
402 default:
403 return 0;
404 }
405}
406
407static struct debug_obj_descr hrtimer_debug_descr = {
408 .name = "hrtimer",
409 .fixup_init = hrtimer_fixup_init,
410 .fixup_activate = hrtimer_fixup_activate,
411 .fixup_free = hrtimer_fixup_free,
412};
413
414static inline void debug_hrtimer_init(struct hrtimer *timer)
415{
416 debug_object_init(timer, &hrtimer_debug_descr);
417}
418
419static inline void debug_hrtimer_activate(struct hrtimer *timer)
420{
421 debug_object_activate(timer, &hrtimer_debug_descr);
422}
423
424static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
425{
426 debug_object_deactivate(timer, &hrtimer_debug_descr);
427}
428
429static inline void debug_hrtimer_free(struct hrtimer *timer)
430{
431 debug_object_free(timer, &hrtimer_debug_descr);
432}
433
434static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
435 enum hrtimer_mode mode);
436
437void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id,
438 enum hrtimer_mode mode)
439{
440 debug_object_init_on_stack(timer, &hrtimer_debug_descr);
441 __hrtimer_init(timer, clock_id, mode);
442}
443
444void destroy_hrtimer_on_stack(struct hrtimer *timer)
445{
446 debug_object_free(timer, &hrtimer_debug_descr);
447}
448
449#else
450static inline void debug_hrtimer_init(struct hrtimer *timer) { }
451static inline void debug_hrtimer_activate(struct hrtimer *timer) { }
452static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { }
453#endif
454
345/* 455/*
346 * Check, whether the timer is on the callback pending list 456 * Check, whether the timer is on the callback pending list
347 */ 457 */
@@ -567,6 +677,7 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
567 /* Timer is expired, act upon the callback mode */ 677 /* Timer is expired, act upon the callback mode */
568 switch(timer->cb_mode) { 678 switch(timer->cb_mode) {
569 case HRTIMER_CB_IRQSAFE_NO_RESTART: 679 case HRTIMER_CB_IRQSAFE_NO_RESTART:
680 debug_hrtimer_deactivate(timer);
570 /* 681 /*
571 * We can call the callback from here. No restart 682 * We can call the callback from here. No restart
572 * happens, so no danger of recursion 683 * happens, so no danger of recursion
@@ -581,6 +692,7 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
581 * the tick timer in the softirq ! The calling site 692 * the tick timer in the softirq ! The calling site
582 * takes care of this. 693 * takes care of this.
583 */ 694 */
695 debug_hrtimer_deactivate(timer);
584 return 1; 696 return 1;
585 case HRTIMER_CB_IRQSAFE: 697 case HRTIMER_CB_IRQSAFE:
586 case HRTIMER_CB_SOFTIRQ: 698 case HRTIMER_CB_SOFTIRQ:
@@ -735,6 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
735 struct hrtimer *entry; 847 struct hrtimer *entry;
736 int leftmost = 1; 848 int leftmost = 1;
737 849
850 debug_hrtimer_activate(timer);
851
738 /* 852 /*
739 * Find the right place in the rbtree: 853 * Find the right place in the rbtree:
740 */ 854 */
@@ -831,6 +945,7 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
831 * reprogramming happens in the interrupt handler. This is a 945 * reprogramming happens in the interrupt handler. This is a
832 * rare case and less expensive than a smp call. 946 * rare case and less expensive than a smp call.
833 */ 947 */
948 debug_hrtimer_deactivate(timer);
834 timer_stats_hrtimer_clear_start_info(timer); 949 timer_stats_hrtimer_clear_start_info(timer);
835 reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases); 950 reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases);
836 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 951 __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE,
@@ -878,6 +993,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
878 tim = ktime_add_safe(tim, base->resolution); 993 tim = ktime_add_safe(tim, base->resolution);
879#endif 994#endif
880 } 995 }
996
881 timer->expires = tim; 997 timer->expires = tim;
882 998
883 timer_stats_hrtimer_set_start_info(timer); 999 timer_stats_hrtimer_set_start_info(timer);
@@ -1011,14 +1127,8 @@ ktime_t hrtimer_get_next_event(void)
1011} 1127}
1012#endif 1128#endif
1013 1129
1014/** 1130static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1015 * hrtimer_init - initialize a timer to the given clock 1131 enum hrtimer_mode mode)
1016 * @timer: the timer to be initialized
1017 * @clock_id: the clock to be used
1018 * @mode: timer mode abs/rel
1019 */
1020void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1021 enum hrtimer_mode mode)
1022{ 1132{
1023 struct hrtimer_cpu_base *cpu_base; 1133 struct hrtimer_cpu_base *cpu_base;
1024 1134
@@ -1039,6 +1149,19 @@ void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1039 memset(timer->start_comm, 0, TASK_COMM_LEN); 1149 memset(timer->start_comm, 0, TASK_COMM_LEN);
1040#endif 1150#endif
1041} 1151}
1152
1153/**
1154 * hrtimer_init - initialize a timer to the given clock
1155 * @timer: the timer to be initialized
1156 * @clock_id: the clock to be used
1157 * @mode: timer mode abs/rel
1158 */
1159void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1160 enum hrtimer_mode mode)
1161{
1162 debug_hrtimer_init(timer);
1163 __hrtimer_init(timer, clock_id, mode);
1164}
1042EXPORT_SYMBOL_GPL(hrtimer_init); 1165EXPORT_SYMBOL_GPL(hrtimer_init);
1043 1166
1044/** 1167/**
@@ -1072,6 +1195,7 @@ static void run_hrtimer_pending(struct hrtimer_cpu_base *cpu_base)
1072 timer = list_entry(cpu_base->cb_pending.next, 1195 timer = list_entry(cpu_base->cb_pending.next,
1073 struct hrtimer, cb_entry); 1196 struct hrtimer, cb_entry);
1074 1197
1198 debug_hrtimer_deactivate(timer);
1075 timer_stats_account_hrtimer(timer); 1199 timer_stats_account_hrtimer(timer);
1076 1200
1077 fn = timer->function; 1201 fn = timer->function;
@@ -1120,6 +1244,7 @@ static void __run_hrtimer(struct hrtimer *timer)
1120 enum hrtimer_restart (*fn)(struct hrtimer *); 1244 enum hrtimer_restart (*fn)(struct hrtimer *);
1121 int restart; 1245 int restart;
1122 1246
1247 debug_hrtimer_deactivate(timer);
1123 __remove_hrtimer(timer, base, HRTIMER_STATE_CALLBACK, 0); 1248 __remove_hrtimer(timer, base, HRTIMER_STATE_CALLBACK, 0);
1124 timer_stats_account_hrtimer(timer); 1249 timer_stats_account_hrtimer(timer);
1125 1250
@@ -1378,22 +1503,27 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
1378{ 1503{
1379 struct hrtimer_sleeper t; 1504 struct hrtimer_sleeper t;
1380 struct timespec __user *rmtp; 1505 struct timespec __user *rmtp;
1506 int ret = 0;
1381 1507
1382 hrtimer_init(&t.timer, restart->nanosleep.index, HRTIMER_MODE_ABS); 1508 hrtimer_init_on_stack(&t.timer, restart->nanosleep.index,
1509 HRTIMER_MODE_ABS);
1383 t.timer.expires.tv64 = restart->nanosleep.expires; 1510 t.timer.expires.tv64 = restart->nanosleep.expires;
1384 1511
1385 if (do_nanosleep(&t, HRTIMER_MODE_ABS)) 1512 if (do_nanosleep(&t, HRTIMER_MODE_ABS))
1386 return 0; 1513 goto out;
1387 1514
1388 rmtp = restart->nanosleep.rmtp; 1515 rmtp = restart->nanosleep.rmtp;
1389 if (rmtp) { 1516 if (rmtp) {
1390 int ret = update_rmtp(&t.timer, rmtp); 1517 ret = update_rmtp(&t.timer, rmtp);
1391 if (ret <= 0) 1518 if (ret <= 0)
1392 return ret; 1519 goto out;
1393 } 1520 }
1394 1521
1395 /* The other values in restart are already filled in */ 1522 /* The other values in restart are already filled in */
1396 return -ERESTART_RESTARTBLOCK; 1523 ret = -ERESTART_RESTARTBLOCK;
1524out:
1525 destroy_hrtimer_on_stack(&t.timer);
1526 return ret;
1397} 1527}
1398 1528
1399long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, 1529long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
@@ -1401,20 +1531,23 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
1401{ 1531{
1402 struct restart_block *restart; 1532 struct restart_block *restart;
1403 struct hrtimer_sleeper t; 1533 struct hrtimer_sleeper t;
1534 int ret = 0;
1404 1535
1405 hrtimer_init(&t.timer, clockid, mode); 1536 hrtimer_init_on_stack(&t.timer, clockid, mode);
1406 t.timer.expires = timespec_to_ktime(*rqtp); 1537 t.timer.expires = timespec_to_ktime(*rqtp);
1407 if (do_nanosleep(&t, mode)) 1538 if (do_nanosleep(&t, mode))
1408 return 0; 1539 goto out;
1409 1540
1410 /* Absolute timers do not update the rmtp value and restart: */ 1541 /* Absolute timers do not update the rmtp value and restart: */
1411 if (mode == HRTIMER_MODE_ABS) 1542 if (mode == HRTIMER_MODE_ABS) {
1412 return -ERESTARTNOHAND; 1543 ret = -ERESTARTNOHAND;
1544 goto out;
1545 }
1413 1546
1414 if (rmtp) { 1547 if (rmtp) {
1415 int ret = update_rmtp(&t.timer, rmtp); 1548 ret = update_rmtp(&t.timer, rmtp);
1416 if (ret <= 0) 1549 if (ret <= 0)
1417 return ret; 1550 goto out;
1418 } 1551 }
1419 1552
1420 restart = &current_thread_info()->restart_block; 1553 restart = &current_thread_info()->restart_block;
@@ -1423,7 +1556,10 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
1423 restart->nanosleep.rmtp = rmtp; 1556 restart->nanosleep.rmtp = rmtp;
1424 restart->nanosleep.expires = t.timer.expires.tv64; 1557 restart->nanosleep.expires = t.timer.expires.tv64;
1425 1558
1426 return -ERESTART_RESTARTBLOCK; 1559 ret = -ERESTART_RESTARTBLOCK;
1560out:
1561 destroy_hrtimer_on_stack(&t.timer);
1562 return ret;
1427} 1563}
1428 1564
1429asmlinkage long 1565asmlinkage long
@@ -1468,6 +1604,7 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
1468 while ((node = rb_first(&old_base->active))) { 1604 while ((node = rb_first(&old_base->active))) {
1469 timer = rb_entry(node, struct hrtimer, node); 1605 timer = rb_entry(node, struct hrtimer, node);
1470 BUG_ON(hrtimer_callback_running(timer)); 1606 BUG_ON(hrtimer_callback_running(timer));
1607 debug_hrtimer_deactivate(timer);
1471 __remove_hrtimer(timer, old_base, HRTIMER_STATE_INACTIVE, 0); 1608 __remove_hrtimer(timer, old_base, HRTIMER_STATE_INACTIVE, 0);
1472 timer->base = new_base; 1609 timer->base = new_base;
1473 /* 1610 /*
diff --git a/kernel/kthread.c b/kernel/kthread.c
index ac72eea48339..bd1b9ea024e1 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -98,7 +98,7 @@ static void create_kthread(struct kthread_create_info *create)
98 struct sched_param param = { .sched_priority = 0 }; 98 struct sched_param param = { .sched_priority = 0 };
99 wait_for_completion(&create->started); 99 wait_for_completion(&create->started);
100 read_lock(&tasklist_lock); 100 read_lock(&tasklist_lock);
101 create->result = find_task_by_pid(pid); 101 create->result = find_task_by_pid_ns(pid, &init_pid_ns);
102 read_unlock(&tasklist_lock); 102 read_unlock(&tasklist_lock);
103 /* 103 /*
104 * root may have changed our (kthreadd's) priority or CPU mask. 104 * root may have changed our (kthreadd's) priority or CPU mask.
diff --git a/kernel/marker.c b/kernel/marker.c
index 139260e5460c..b5a9fe1d50d5 100644
--- a/kernel/marker.c
+++ b/kernel/marker.c
@@ -29,7 +29,7 @@ extern struct marker __start___markers[];
29extern struct marker __stop___markers[]; 29extern struct marker __stop___markers[];
30 30
31/* Set to 1 to enable marker debug output */ 31/* Set to 1 to enable marker debug output */
32const int marker_debug; 32static const int marker_debug;
33 33
34/* 34/*
35 * markers_mutex nests inside module_mutex. Markers mutex protects the builtin 35 * markers_mutex nests inside module_mutex. Markers mutex protects the builtin
diff --git a/kernel/pid.c b/kernel/pid.c
index 477691576b33..20d59fa2d493 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -111,10 +111,11 @@ EXPORT_SYMBOL(is_container_init);
111 111
112static __cacheline_aligned_in_smp DEFINE_SPINLOCK(pidmap_lock); 112static __cacheline_aligned_in_smp DEFINE_SPINLOCK(pidmap_lock);
113 113
114static void free_pidmap(struct pid_namespace *pid_ns, int pid) 114static void free_pidmap(struct upid *upid)
115{ 115{
116 struct pidmap *map = pid_ns->pidmap + pid / BITS_PER_PAGE; 116 int nr = upid->nr;
117 int offset = pid & BITS_PER_PAGE_MASK; 117 struct pidmap *map = upid->ns->pidmap + nr / BITS_PER_PAGE;
118 int offset = nr & BITS_PER_PAGE_MASK;
118 119
119 clear_bit(offset, map->page); 120 clear_bit(offset, map->page);
120 atomic_inc(&map->nr_free); 121 atomic_inc(&map->nr_free);
@@ -232,7 +233,7 @@ void free_pid(struct pid *pid)
232 spin_unlock_irqrestore(&pidmap_lock, flags); 233 spin_unlock_irqrestore(&pidmap_lock, flags);
233 234
234 for (i = 0; i <= pid->level; i++) 235 for (i = 0; i <= pid->level; i++)
235 free_pidmap(pid->numbers[i].ns, pid->numbers[i].nr); 236 free_pidmap(pid->numbers + i);
236 237
237 call_rcu(&pid->rcu, delayed_put_pid); 238 call_rcu(&pid->rcu, delayed_put_pid);
238} 239}
@@ -278,8 +279,8 @@ out:
278 return pid; 279 return pid;
279 280
280out_free: 281out_free:
281 for (i++; i <= ns->level; i++) 282 while (++i <= ns->level)
282 free_pidmap(pid->numbers[i].ns, pid->numbers[i].nr); 283 free_pidmap(pid->numbers + i);
283 284
284 kmem_cache_free(ns->pid_cachep, pid); 285 kmem_cache_free(ns->pid_cachep, pid);
285 pid = NULL; 286 pid = NULL;
@@ -316,7 +317,7 @@ EXPORT_SYMBOL_GPL(find_pid);
316/* 317/*
317 * attach_pid() must be called with the tasklist_lock write-held. 318 * attach_pid() must be called with the tasklist_lock write-held.
318 */ 319 */
319int attach_pid(struct task_struct *task, enum pid_type type, 320void attach_pid(struct task_struct *task, enum pid_type type,
320 struct pid *pid) 321 struct pid *pid)
321{ 322{
322 struct pid_link *link; 323 struct pid_link *link;
@@ -324,11 +325,10 @@ int attach_pid(struct task_struct *task, enum pid_type type,
324 link = &task->pids[type]; 325 link = &task->pids[type];
325 link->pid = pid; 326 link->pid = pid;
326 hlist_add_head_rcu(&link->node, &pid->tasks[type]); 327 hlist_add_head_rcu(&link->node, &pid->tasks[type]);
327
328 return 0;
329} 328}
330 329
331void detach_pid(struct task_struct *task, enum pid_type type) 330static void __change_pid(struct task_struct *task, enum pid_type type,
331 struct pid *new)
332{ 332{
333 struct pid_link *link; 333 struct pid_link *link;
334 struct pid *pid; 334 struct pid *pid;
@@ -338,7 +338,7 @@ void detach_pid(struct task_struct *task, enum pid_type type)
338 pid = link->pid; 338 pid = link->pid;
339 339
340 hlist_del_rcu(&link->node); 340 hlist_del_rcu(&link->node);
341 link->pid = NULL; 341 link->pid = new;
342 342
343 for (tmp = PIDTYPE_MAX; --tmp >= 0; ) 343 for (tmp = PIDTYPE_MAX; --tmp >= 0; )
344 if (!hlist_empty(&pid->tasks[tmp])) 344 if (!hlist_empty(&pid->tasks[tmp]))
@@ -347,13 +347,24 @@ void detach_pid(struct task_struct *task, enum pid_type type)
347 free_pid(pid); 347 free_pid(pid);
348} 348}
349 349
350void detach_pid(struct task_struct *task, enum pid_type type)
351{
352 __change_pid(task, type, NULL);
353}
354
355void change_pid(struct task_struct *task, enum pid_type type,
356 struct pid *pid)
357{
358 __change_pid(task, type, pid);
359 attach_pid(task, type, pid);
360}
361
350/* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */ 362/* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */
351void transfer_pid(struct task_struct *old, struct task_struct *new, 363void transfer_pid(struct task_struct *old, struct task_struct *new,
352 enum pid_type type) 364 enum pid_type type)
353{ 365{
354 new->pids[type].pid = old->pids[type].pid; 366 new->pids[type].pid = old->pids[type].pid;
355 hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node); 367 hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
356 old->pids[type].pid = NULL;
357} 368}
358 369
359struct task_struct *pid_task(struct pid *pid, enum pid_type type) 370struct task_struct *pid_task(struct pid *pid, enum pid_type type)
@@ -380,12 +391,6 @@ struct task_struct *find_task_by_pid_type_ns(int type, int nr,
380 391
381EXPORT_SYMBOL(find_task_by_pid_type_ns); 392EXPORT_SYMBOL(find_task_by_pid_type_ns);
382 393
383struct task_struct *find_task_by_pid(pid_t nr)
384{
385 return find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns);
386}
387EXPORT_SYMBOL(find_task_by_pid);
388
389struct task_struct *find_task_by_vpid(pid_t vnr) 394struct task_struct *find_task_by_vpid(pid_t vnr)
390{ 395{
391 return find_task_by_pid_type_ns(PIDTYPE_PID, vnr, 396 return find_task_by_pid_type_ns(PIDTYPE_PID, vnr,
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 5ca37fa50beb..98702b4b8851 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -66,7 +66,7 @@ err_alloc:
66 return NULL; 66 return NULL;
67} 67}
68 68
69static struct pid_namespace *create_pid_namespace(int level) 69static struct pid_namespace *create_pid_namespace(unsigned int level)
70{ 70{
71 struct pid_namespace *ns; 71 struct pid_namespace *ns;
72 int i; 72 int i;
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 8476956ffd92..dbd8398ddb0b 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -310,8 +310,7 @@ int posix_timer_event(struct k_itimer *timr,int si_private)
310 310
311 if (timr->it_sigev_notify & SIGEV_THREAD_ID) { 311 if (timr->it_sigev_notify & SIGEV_THREAD_ID) {
312 struct task_struct *leader; 312 struct task_struct *leader;
313 int ret = send_sigqueue(timr->it_sigev_signo, timr->sigq, 313 int ret = send_sigqueue(timr->sigq, timr->it_process, 0);
314 timr->it_process);
315 314
316 if (likely(ret >= 0)) 315 if (likely(ret >= 0))
317 return ret; 316 return ret;
@@ -322,8 +321,7 @@ int posix_timer_event(struct k_itimer *timr,int si_private)
322 timr->it_process = leader; 321 timr->it_process = leader;
323 } 322 }
324 323
325 return send_group_sigqueue(timr->it_sigev_signo, timr->sigq, 324 return send_sigqueue(timr->sigq, timr->it_process, 1);
326 timr->it_process);
327} 325}
328EXPORT_SYMBOL_GPL(posix_timer_event); 326EXPORT_SYMBOL_GPL(posix_timer_event);
329 327
diff --git a/kernel/printk.c b/kernel/printk.c
index d3f9c0f788bf..8fb01c32aa3b 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -111,6 +111,9 @@ struct console_cmdline
111 char name[8]; /* Name of the driver */ 111 char name[8]; /* Name of the driver */
112 int index; /* Minor dev. to use */ 112 int index; /* Minor dev. to use */
113 char *options; /* Options for the driver */ 113 char *options; /* Options for the driver */
114#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
115 char *brl_options; /* Options for braille driver */
116#endif
114}; 117};
115 118
116#define MAX_CMDLINECONSOLES 8 119#define MAX_CMDLINECONSOLES 8
@@ -808,15 +811,60 @@ static void call_console_drivers(unsigned start, unsigned end)
808 811
809#endif 812#endif
810 813
814static int __add_preferred_console(char *name, int idx, char *options,
815 char *brl_options)
816{
817 struct console_cmdline *c;
818 int i;
819
820 /*
821 * See if this tty is not yet registered, and
822 * if we have a slot free.
823 */
824 for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
825 if (strcmp(console_cmdline[i].name, name) == 0 &&
826 console_cmdline[i].index == idx) {
827 if (!brl_options)
828 selected_console = i;
829 return 0;
830 }
831 if (i == MAX_CMDLINECONSOLES)
832 return -E2BIG;
833 if (!brl_options)
834 selected_console = i;
835 c = &console_cmdline[i];
836 strlcpy(c->name, name, sizeof(c->name));
837 c->options = options;
838#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
839 c->brl_options = brl_options;
840#endif
841 c->index = idx;
842 return 0;
843}
811/* 844/*
812 * Set up a list of consoles. Called from init/main.c 845 * Set up a list of consoles. Called from init/main.c
813 */ 846 */
814static int __init console_setup(char *str) 847static int __init console_setup(char *str)
815{ 848{
816 char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */ 849 char buf[sizeof(console_cmdline[0].name) + 4]; /* 4 for index */
817 char *s, *options; 850 char *s, *options, *brl_options = NULL;
818 int idx; 851 int idx;
819 852
853#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
854 if (!memcmp(str, "brl,", 4)) {
855 brl_options = "";
856 str += 4;
857 } else if (!memcmp(str, "brl=", 4)) {
858 brl_options = str + 4;
859 str = strchr(brl_options, ',');
860 if (!str) {
861 printk(KERN_ERR "need port name after brl=\n");
862 return 1;
863 }
864 *(str++) = 0;
865 }
866#endif
867
820 /* 868 /*
821 * Decode str into name, index, options. 869 * Decode str into name, index, options.
822 */ 870 */
@@ -841,7 +889,7 @@ static int __init console_setup(char *str)
841 idx = simple_strtoul(s, NULL, 10); 889 idx = simple_strtoul(s, NULL, 10);
842 *s = 0; 890 *s = 0;
843 891
844 add_preferred_console(buf, idx, options); 892 __add_preferred_console(buf, idx, options, brl_options);
845 return 1; 893 return 1;
846} 894}
847__setup("console=", console_setup); 895__setup("console=", console_setup);
@@ -861,28 +909,7 @@ __setup("console=", console_setup);
861 */ 909 */
862int add_preferred_console(char *name, int idx, char *options) 910int add_preferred_console(char *name, int idx, char *options)
863{ 911{
864 struct console_cmdline *c; 912 return __add_preferred_console(name, idx, options, NULL);
865 int i;
866
867 /*
868 * See if this tty is not yet registered, and
869 * if we have a slot free.
870 */
871 for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
872 if (strcmp(console_cmdline[i].name, name) == 0 &&
873 console_cmdline[i].index == idx) {
874 selected_console = i;
875 return 0;
876 }
877 if (i == MAX_CMDLINECONSOLES)
878 return -E2BIG;
879 selected_console = i;
880 c = &console_cmdline[i];
881 memcpy(c->name, name, sizeof(c->name));
882 c->name[sizeof(c->name) - 1] = 0;
883 c->options = options;
884 c->index = idx;
885 return 0;
886} 913}
887 914
888int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options) 915int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, char *options)
@@ -894,7 +921,7 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha
894 if (strcmp(console_cmdline[i].name, name) == 0 && 921 if (strcmp(console_cmdline[i].name, name) == 0 &&
895 console_cmdline[i].index == idx) { 922 console_cmdline[i].index == idx) {
896 c = &console_cmdline[i]; 923 c = &console_cmdline[i];
897 memcpy(c->name, name_new, sizeof(c->name)); 924 strlcpy(c->name, name_new, sizeof(c->name));
898 c->name[sizeof(c->name) - 1] = 0; 925 c->name[sizeof(c->name) - 1] = 0;
899 c->options = options; 926 c->options = options;
900 c->index = idx_new; 927 c->index = idx_new;
@@ -1163,6 +1190,16 @@ void register_console(struct console *console)
1163 continue; 1190 continue;
1164 if (console->index < 0) 1191 if (console->index < 0)
1165 console->index = console_cmdline[i].index; 1192 console->index = console_cmdline[i].index;
1193#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
1194 if (console_cmdline[i].brl_options) {
1195 console->flags |= CON_BRL;
1196 braille_register_console(console,
1197 console_cmdline[i].index,
1198 console_cmdline[i].options,
1199 console_cmdline[i].brl_options);
1200 return;
1201 }
1202#endif
1166 if (console->setup && 1203 if (console->setup &&
1167 console->setup(console, console_cmdline[i].options) != 0) 1204 console->setup(console, console_cmdline[i].options) != 0)
1168 break; 1205 break;
@@ -1221,6 +1258,11 @@ int unregister_console(struct console *console)
1221 struct console *a, *b; 1258 struct console *a, *b;
1222 int res = 1; 1259 int res = 1;
1223 1260
1261#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
1262 if (console->flags & CON_BRL)
1263 return braille_unregister_console(console);
1264#endif
1265
1224 acquire_console_sem(); 1266 acquire_console_sem();
1225 if (console_drivers == console) { 1267 if (console_drivers == console) {
1226 console_drivers=console->next; 1268 console_drivers=console->next;
@@ -1272,8 +1314,8 @@ late_initcall(disable_boot_consoles);
1272 */ 1314 */
1273void tty_write_message(struct tty_struct *tty, char *msg) 1315void tty_write_message(struct tty_struct *tty, char *msg)
1274{ 1316{
1275 if (tty && tty->driver->write) 1317 if (tty && tty->ops->write)
1276 tty->driver->write(tty, msg, strlen(msg)); 1318 tty->ops->write(tty, msg, strlen(msg));
1277 return; 1319 return;
1278} 1320}
1279 1321
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index dac4b4e57293..dcc199c43a12 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -73,7 +73,7 @@ void __ptrace_unlink(struct task_struct *child)
73 BUG_ON(!child->ptrace); 73 BUG_ON(!child->ptrace);
74 74
75 child->ptrace = 0; 75 child->ptrace = 0;
76 if (!list_empty(&child->ptrace_list)) { 76 if (ptrace_reparented(child)) {
77 list_del_init(&child->ptrace_list); 77 list_del_init(&child->ptrace_list);
78 remove_parent(child); 78 remove_parent(child);
79 child->parent = child->real_parent; 79 child->parent = child->real_parent;
@@ -168,8 +168,6 @@ int ptrace_attach(struct task_struct *task)
168 audit_ptrace(task); 168 audit_ptrace(task);
169 169
170 retval = -EPERM; 170 retval = -EPERM;
171 if (task->pid <= 1)
172 goto out;
173 if (same_thread_group(task, current)) 171 if (same_thread_group(task, current))
174 goto out; 172 goto out;
175 173
@@ -208,8 +206,7 @@ repeat:
208 206
209 __ptrace_link(task, current); 207 __ptrace_link(task, current);
210 208
211 force_sig_specific(SIGSTOP, task); 209 send_sig_info(SIGSTOP, SEND_SIG_FORCED, task);
212
213bad: 210bad:
214 write_unlock_irqrestore(&tasklist_lock, flags); 211 write_unlock_irqrestore(&tasklist_lock, flags);
215 task_unlock(task); 212 task_unlock(task);
@@ -522,12 +519,6 @@ struct task_struct *ptrace_get_task_struct(pid_t pid)
522{ 519{
523 struct task_struct *child; 520 struct task_struct *child;
524 521
525 /*
526 * Tracing init is not allowed.
527 */
528 if (pid == 1)
529 return ERR_PTR(-EPERM);
530
531 read_lock(&tasklist_lock); 522 read_lock(&tasklist_lock);
532 child = find_task_by_vpid(pid); 523 child = find_task_by_vpid(pid);
533 if (child) 524 if (child)
diff --git a/kernel/signal.c b/kernel/signal.c
index 64ad0ed15992..72bb4f51f963 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -39,11 +39,19 @@
39 39
40static struct kmem_cache *sigqueue_cachep; 40static struct kmem_cache *sigqueue_cachep;
41 41
42static int __sig_ignored(struct task_struct *t, int sig)
43{
44 void __user *handler;
45
46 /* Is it explicitly or implicitly ignored? */
47
48 handler = t->sighand->action[sig - 1].sa.sa_handler;
49 return handler == SIG_IGN ||
50 (handler == SIG_DFL && sig_kernel_ignore(sig));
51}
42 52
43static int sig_ignored(struct task_struct *t, int sig) 53static int sig_ignored(struct task_struct *t, int sig)
44{ 54{
45 void __user * handler;
46
47 /* 55 /*
48 * Tracers always want to know about signals.. 56 * Tracers always want to know about signals..
49 */ 57 */
@@ -58,10 +66,7 @@ static int sig_ignored(struct task_struct *t, int sig)
58 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig)) 66 if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
59 return 0; 67 return 0;
60 68
61 /* Is it explicitly or implicitly ignored? */ 69 return __sig_ignored(t, sig);
62 handler = t->sighand->action[sig-1].sa.sa_handler;
63 return handler == SIG_IGN ||
64 (handler == SIG_DFL && sig_kernel_ignore(sig));
65} 70}
66 71
67/* 72/*
@@ -372,7 +377,7 @@ static int __dequeue_signal(struct sigpending *pending, sigset_t *mask,
372 */ 377 */
373int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) 378int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
374{ 379{
375 int signr = 0; 380 int signr;
376 381
377 /* We only dequeue private signals from ourselves, we don't let 382 /* We only dequeue private signals from ourselves, we don't let
378 * signalfd steal them 383 * signalfd steal them
@@ -405,8 +410,12 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
405 } 410 }
406 } 411 }
407 } 412 }
413
408 recalc_sigpending(); 414 recalc_sigpending();
409 if (signr && unlikely(sig_kernel_stop(signr))) { 415 if (!signr)
416 return 0;
417
418 if (unlikely(sig_kernel_stop(signr))) {
410 /* 419 /*
411 * Set a marker that we have dequeued a stop signal. Our 420 * Set a marker that we have dequeued a stop signal. Our
412 * caller might release the siglock and then the pending 421 * caller might release the siglock and then the pending
@@ -422,9 +431,7 @@ int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info)
422 if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT)) 431 if (!(tsk->signal->flags & SIGNAL_GROUP_EXIT))
423 tsk->signal->flags |= SIGNAL_STOP_DEQUEUED; 432 tsk->signal->flags |= SIGNAL_STOP_DEQUEUED;
424 } 433 }
425 if (signr && 434 if ((info->si_code & __SI_MASK) == __SI_TIMER && info->si_sys_private) {
426 ((info->si_code & __SI_MASK) == __SI_TIMER) &&
427 info->si_sys_private) {
428 /* 435 /*
429 * Release the siglock to ensure proper locking order 436 * Release the siglock to ensure proper locking order
430 * of timer locks outside of siglocks. Note, we leave 437 * of timer locks outside of siglocks. Note, we leave
@@ -526,21 +533,34 @@ static int rm_from_queue(unsigned long mask, struct sigpending *s)
526static int check_kill_permission(int sig, struct siginfo *info, 533static int check_kill_permission(int sig, struct siginfo *info,
527 struct task_struct *t) 534 struct task_struct *t)
528{ 535{
529 int error = -EINVAL; 536 struct pid *sid;
537 int error;
538
530 if (!valid_signal(sig)) 539 if (!valid_signal(sig))
531 return error; 540 return -EINVAL;
532 541
533 if (info == SEND_SIG_NOINFO || (!is_si_special(info) && SI_FROMUSER(info))) { 542 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
534 error = audit_signal_info(sig, t); /* Let audit system see the signal */ 543 return 0;
535 if (error) 544
536 return error; 545 error = audit_signal_info(sig, t); /* Let audit system see the signal */
537 error = -EPERM; 546 if (error)
538 if (((sig != SIGCONT) ||
539 (task_session_nr(current) != task_session_nr(t)))
540 && (current->euid ^ t->suid) && (current->euid ^ t->uid)
541 && (current->uid ^ t->suid) && (current->uid ^ t->uid)
542 && !capable(CAP_KILL))
543 return error; 547 return error;
548
549 if ((current->euid ^ t->suid) && (current->euid ^ t->uid) &&
550 (current->uid ^ t->suid) && (current->uid ^ t->uid) &&
551 !capable(CAP_KILL)) {
552 switch (sig) {
553 case SIGCONT:
554 sid = task_session(t);
555 /*
556 * We don't return the error if sid == NULL. The
557 * task was unhashed, the caller must notice this.
558 */
559 if (!sid || sid == task_session(current))
560 break;
561 default:
562 return -EPERM;
563 }
544 } 564 }
545 565
546 return security_task_kill(t, info, sig, 0); 566 return security_task_kill(t, info, sig, 0);
@@ -550,62 +570,44 @@ static int check_kill_permission(int sig, struct siginfo *info,
550static void do_notify_parent_cldstop(struct task_struct *tsk, int why); 570static void do_notify_parent_cldstop(struct task_struct *tsk, int why);
551 571
552/* 572/*
553 * Handle magic process-wide effects of stop/continue signals. 573 * Handle magic process-wide effects of stop/continue signals. Unlike
554 * Unlike the signal actions, these happen immediately at signal-generation 574 * the signal actions, these happen immediately at signal-generation
555 * time regardless of blocking, ignoring, or handling. This does the 575 * time regardless of blocking, ignoring, or handling. This does the
556 * actual continuing for SIGCONT, but not the actual stopping for stop 576 * actual continuing for SIGCONT, but not the actual stopping for stop
557 * signals. The process stop is done as a signal action for SIG_DFL. 577 * signals. The process stop is done as a signal action for SIG_DFL.
578 *
579 * Returns true if the signal should be actually delivered, otherwise
580 * it should be dropped.
558 */ 581 */
559static void handle_stop_signal(int sig, struct task_struct *p) 582static int prepare_signal(int sig, struct task_struct *p)
560{ 583{
584 struct signal_struct *signal = p->signal;
561 struct task_struct *t; 585 struct task_struct *t;
562 586
563 if (p->signal->flags & SIGNAL_GROUP_EXIT) 587 if (unlikely(signal->flags & SIGNAL_GROUP_EXIT)) {
564 /* 588 /*
565 * The process is in the middle of dying already. 589 * The process is in the middle of dying, nothing to do.
566 */ 590 */
567 return; 591 } else if (sig_kernel_stop(sig)) {
568
569 if (sig_kernel_stop(sig)) {
570 /* 592 /*
571 * This is a stop signal. Remove SIGCONT from all queues. 593 * This is a stop signal. Remove SIGCONT from all queues.
572 */ 594 */
573 rm_from_queue(sigmask(SIGCONT), &p->signal->shared_pending); 595 rm_from_queue(sigmask(SIGCONT), &signal->shared_pending);
574 t = p; 596 t = p;
575 do { 597 do {
576 rm_from_queue(sigmask(SIGCONT), &t->pending); 598 rm_from_queue(sigmask(SIGCONT), &t->pending);
577 t = next_thread(t); 599 } while_each_thread(p, t);
578 } while (t != p);
579 } else if (sig == SIGCONT) { 600 } else if (sig == SIGCONT) {
601 unsigned int why;
580 /* 602 /*
581 * Remove all stop signals from all queues, 603 * Remove all stop signals from all queues,
582 * and wake all threads. 604 * and wake all threads.
583 */ 605 */
584 if (unlikely(p->signal->group_stop_count > 0)) { 606 rm_from_queue(SIG_KERNEL_STOP_MASK, &signal->shared_pending);
585 /*
586 * There was a group stop in progress. We'll
587 * pretend it finished before we got here. We are
588 * obliged to report it to the parent: if the
589 * SIGSTOP happened "after" this SIGCONT, then it
590 * would have cleared this pending SIGCONT. If it
591 * happened "before" this SIGCONT, then the parent
592 * got the SIGCHLD about the stop finishing before
593 * the continue happened. We do the notification
594 * now, and it's as if the stop had finished and
595 * the SIGCHLD was pending on entry to this kill.
596 */
597 p->signal->group_stop_count = 0;
598 p->signal->flags = SIGNAL_STOP_CONTINUED;
599 spin_unlock(&p->sighand->siglock);
600 do_notify_parent_cldstop(p, CLD_STOPPED);
601 spin_lock(&p->sighand->siglock);
602 }
603 rm_from_queue(SIG_KERNEL_STOP_MASK, &p->signal->shared_pending);
604 t = p; 607 t = p;
605 do { 608 do {
606 unsigned int state; 609 unsigned int state;
607 rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending); 610 rm_from_queue(SIG_KERNEL_STOP_MASK, &t->pending);
608
609 /* 611 /*
610 * If there is a handler for SIGCONT, we must make 612 * If there is a handler for SIGCONT, we must make
611 * sure that no thread returns to user mode before 613 * sure that no thread returns to user mode before
@@ -615,7 +617,7 @@ static void handle_stop_signal(int sig, struct task_struct *p)
615 * running the handler. With the TIF_SIGPENDING 617 * running the handler. With the TIF_SIGPENDING
616 * flag set, the thread will pause and acquire the 618 * flag set, the thread will pause and acquire the
617 * siglock that we hold now and until we've queued 619 * siglock that we hold now and until we've queued
618 * the pending signal. 620 * the pending signal.
619 * 621 *
620 * Wake up the stopped thread _after_ setting 622 * Wake up the stopped thread _after_ setting
621 * TIF_SIGPENDING 623 * TIF_SIGPENDING
@@ -626,49 +628,163 @@ static void handle_stop_signal(int sig, struct task_struct *p)
626 state |= TASK_INTERRUPTIBLE; 628 state |= TASK_INTERRUPTIBLE;
627 } 629 }
628 wake_up_state(t, state); 630 wake_up_state(t, state);
631 } while_each_thread(p, t);
629 632
630 t = next_thread(t); 633 /*
631 } while (t != p); 634 * Notify the parent with CLD_CONTINUED if we were stopped.
635 *
636 * If we were in the middle of a group stop, we pretend it
637 * was already finished, and then continued. Since SIGCHLD
638 * doesn't queue we report only CLD_STOPPED, as if the next
639 * CLD_CONTINUED was dropped.
640 */
641 why = 0;
642 if (signal->flags & SIGNAL_STOP_STOPPED)
643 why |= SIGNAL_CLD_CONTINUED;
644 else if (signal->group_stop_count)
645 why |= SIGNAL_CLD_STOPPED;
632 646
633 if (p->signal->flags & SIGNAL_STOP_STOPPED) { 647 if (why) {
634 /* 648 /*
635 * We were in fact stopped, and are now continued. 649 * The first thread which returns from finish_stop()
636 * Notify the parent with CLD_CONTINUED. 650 * will take ->siglock, notice SIGNAL_CLD_MASK, and
651 * notify its parent. See get_signal_to_deliver().
637 */ 652 */
638 p->signal->flags = SIGNAL_STOP_CONTINUED; 653 signal->flags = why | SIGNAL_STOP_CONTINUED;
639 p->signal->group_exit_code = 0; 654 signal->group_stop_count = 0;
640 spin_unlock(&p->sighand->siglock); 655 signal->group_exit_code = 0;
641 do_notify_parent_cldstop(p, CLD_CONTINUED);
642 spin_lock(&p->sighand->siglock);
643 } else { 656 } else {
644 /* 657 /*
645 * We are not stopped, but there could be a stop 658 * We are not stopped, but there could be a stop
646 * signal in the middle of being processed after 659 * signal in the middle of being processed after
647 * being removed from the queue. Clear that too. 660 * being removed from the queue. Clear that too.
648 */ 661 */
649 p->signal->flags = 0; 662 signal->flags &= ~SIGNAL_STOP_DEQUEUED;
650 } 663 }
651 } else if (sig == SIGKILL) { 664 }
665
666 return !sig_ignored(p, sig);
667}
668
669/*
670 * Test if P wants to take SIG. After we've checked all threads with this,
671 * it's equivalent to finding no threads not blocking SIG. Any threads not
672 * blocking SIG were ruled out because they are not running and already
673 * have pending signals. Such threads will dequeue from the shared queue
674 * as soon as they're available, so putting the signal on the shared queue
675 * will be equivalent to sending it to one such thread.
676 */
677static inline int wants_signal(int sig, struct task_struct *p)
678{
679 if (sigismember(&p->blocked, sig))
680 return 0;
681 if (p->flags & PF_EXITING)
682 return 0;
683 if (sig == SIGKILL)
684 return 1;
685 if (task_is_stopped_or_traced(p))
686 return 0;
687 return task_curr(p) || !signal_pending(p);
688}
689
690static void complete_signal(int sig, struct task_struct *p, int group)
691{
692 struct signal_struct *signal = p->signal;
693 struct task_struct *t;
694
695 /*
696 * Now find a thread we can wake up to take the signal off the queue.
697 *
698 * If the main thread wants the signal, it gets first crack.
699 * Probably the least surprising to the average bear.
700 */
701 if (wants_signal(sig, p))
702 t = p;
703 else if (!group || thread_group_empty(p))
704 /*
705 * There is just one thread and it does not need to be woken.
706 * It will dequeue unblocked signals before it runs again.
707 */
708 return;
709 else {
652 /* 710 /*
653 * Make sure that any pending stop signal already dequeued 711 * Otherwise try to find a suitable thread.
654 * is undone by the wakeup for SIGKILL.
655 */ 712 */
656 p->signal->flags = 0; 713 t = signal->curr_target;
714 while (!wants_signal(sig, t)) {
715 t = next_thread(t);
716 if (t == signal->curr_target)
717 /*
718 * No thread needs to be woken.
719 * Any eligible threads will see
720 * the signal in the queue soon.
721 */
722 return;
723 }
724 signal->curr_target = t;
657 } 725 }
726
727 /*
728 * Found a killable thread. If the signal will be fatal,
729 * then start taking the whole group down immediately.
730 */
731 if (sig_fatal(p, sig) &&
732 !(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) &&
733 !sigismember(&t->real_blocked, sig) &&
734 (sig == SIGKILL || !(t->ptrace & PT_PTRACED))) {
735 /*
736 * This signal will be fatal to the whole group.
737 */
738 if (!sig_kernel_coredump(sig)) {
739 /*
740 * Start a group exit and wake everybody up.
741 * This way we don't have other threads
742 * running and doing things after a slower
743 * thread has the fatal signal pending.
744 */
745 signal->flags = SIGNAL_GROUP_EXIT;
746 signal->group_exit_code = sig;
747 signal->group_stop_count = 0;
748 t = p;
749 do {
750 sigaddset(&t->pending.signal, SIGKILL);
751 signal_wake_up(t, 1);
752 } while_each_thread(p, t);
753 return;
754 }
755 }
756
757 /*
758 * The signal is already in the shared-pending queue.
759 * Tell the chosen thread to wake up and dequeue it.
760 */
761 signal_wake_up(t, sig == SIGKILL);
762 return;
763}
764
765static inline int legacy_queue(struct sigpending *signals, int sig)
766{
767 return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
658} 768}
659 769
660static int send_signal(int sig, struct siginfo *info, struct task_struct *t, 770static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
661 struct sigpending *signals) 771 int group)
662{ 772{
663 struct sigqueue * q = NULL; 773 struct sigpending *pending;
664 int ret = 0; 774 struct sigqueue *q;
775
776 assert_spin_locked(&t->sighand->siglock);
777 if (!prepare_signal(sig, t))
778 return 0;
665 779
780 pending = group ? &t->signal->shared_pending : &t->pending;
666 /* 781 /*
667 * Deliver the signal to listening signalfds. This must be called 782 * Short-circuit ignored signals and support queuing
668 * with the sighand lock held. 783 * exactly one non-rt signal, so that we can get more
784 * detailed information about the cause of the signal.
669 */ 785 */
670 signalfd_notify(t, sig); 786 if (legacy_queue(pending, sig))
671 787 return 0;
672 /* 788 /*
673 * fast-pathed signals for kernel-internal things like SIGSTOP 789 * fast-pathed signals for kernel-internal things like SIGSTOP
674 * or SIGKILL. 790 * or SIGKILL.
@@ -688,7 +804,7 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
688 (is_si_special(info) || 804 (is_si_special(info) ||
689 info->si_code >= 0))); 805 info->si_code >= 0)));
690 if (q) { 806 if (q) {
691 list_add_tail(&q->list, &signals->list); 807 list_add_tail(&q->list, &pending->list);
692 switch ((unsigned long) info) { 808 switch ((unsigned long) info) {
693 case (unsigned long) SEND_SIG_NOINFO: 809 case (unsigned long) SEND_SIG_NOINFO:
694 q->info.si_signo = sig; 810 q->info.si_signo = sig;
@@ -718,13 +834,12 @@ static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
718 } 834 }
719 835
720out_set: 836out_set:
721 sigaddset(&signals->signal, sig); 837 signalfd_notify(t, sig);
722 return ret; 838 sigaddset(&pending->signal, sig);
839 complete_signal(sig, t, group);
840 return 0;
723} 841}
724 842
725#define LEGACY_QUEUE(sigptr, sig) \
726 (((sig) < SIGRTMIN) && sigismember(&(sigptr)->signal, (sig)))
727
728int print_fatal_signals; 843int print_fatal_signals;
729 844
730static void print_fatal_signal(struct pt_regs *regs, int signr) 845static void print_fatal_signal(struct pt_regs *regs, int signr)
@@ -757,29 +872,16 @@ static int __init setup_print_fatal_signals(char *str)
757 872
758__setup("print-fatal-signals=", setup_print_fatal_signals); 873__setup("print-fatal-signals=", setup_print_fatal_signals);
759 874
875int
876__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
877{
878 return send_signal(sig, info, p, 1);
879}
880
760static int 881static int
761specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t) 882specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
762{ 883{
763 int ret = 0; 884 return send_signal(sig, info, t, 0);
764
765 BUG_ON(!irqs_disabled());
766 assert_spin_locked(&t->sighand->siglock);
767
768 /* Short-circuit ignored signals. */
769 if (sig_ignored(t, sig))
770 goto out;
771
772 /* Support queueing exactly one non-rt signal, so that we
773 can get more detailed information about the cause of
774 the signal. */
775 if (LEGACY_QUEUE(&t->pending, sig))
776 goto out;
777
778 ret = send_signal(sig, info, t, &t->pending);
779 if (!ret && !sigismember(&t->blocked, sig))
780 signal_wake_up(t, sig == SIGKILL);
781out:
782 return ret;
783} 885}
784 886
785/* 887/*
@@ -790,7 +892,8 @@ out:
790 * since we do not want to have a signal handler that was blocked 892 * since we do not want to have a signal handler that was blocked
791 * be invoked when user space had explicitly blocked it. 893 * be invoked when user space had explicitly blocked it.
792 * 894 *
793 * We don't want to have recursive SIGSEGV's etc, for example. 895 * We don't want to have recursive SIGSEGV's etc, for example,
896 * that is why we also clear SIGNAL_UNKILLABLE.
794 */ 897 */
795int 898int
796force_sig_info(int sig, struct siginfo *info, struct task_struct *t) 899force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
@@ -810,6 +913,8 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
810 recalc_sigpending_and_wake(t); 913 recalc_sigpending_and_wake(t);
811 } 914 }
812 } 915 }
916 if (action->sa.sa_handler == SIG_DFL)
917 t->signal->flags &= ~SIGNAL_UNKILLABLE;
813 ret = specific_send_sig_info(sig, info, t); 918 ret = specific_send_sig_info(sig, info, t);
814 spin_unlock_irqrestore(&t->sighand->siglock, flags); 919 spin_unlock_irqrestore(&t->sighand->siglock, flags);
815 920
@@ -823,134 +928,6 @@ force_sig_specific(int sig, struct task_struct *t)
823} 928}
824 929
825/* 930/*
826 * Test if P wants to take SIG. After we've checked all threads with this,
827 * it's equivalent to finding no threads not blocking SIG. Any threads not
828 * blocking SIG were ruled out because they are not running and already
829 * have pending signals. Such threads will dequeue from the shared queue
830 * as soon as they're available, so putting the signal on the shared queue
831 * will be equivalent to sending it to one such thread.
832 */
833static inline int wants_signal(int sig, struct task_struct *p)
834{
835 if (sigismember(&p->blocked, sig))
836 return 0;
837 if (p->flags & PF_EXITING)
838 return 0;
839 if (sig == SIGKILL)
840 return 1;
841 if (task_is_stopped_or_traced(p))
842 return 0;
843 return task_curr(p) || !signal_pending(p);
844}
845
846static void
847__group_complete_signal(int sig, struct task_struct *p)
848{
849 struct task_struct *t;
850
851 /*
852 * Now find a thread we can wake up to take the signal off the queue.
853 *
854 * If the main thread wants the signal, it gets first crack.
855 * Probably the least surprising to the average bear.
856 */
857 if (wants_signal(sig, p))
858 t = p;
859 else if (thread_group_empty(p))
860 /*
861 * There is just one thread and it does not need to be woken.
862 * It will dequeue unblocked signals before it runs again.
863 */
864 return;
865 else {
866 /*
867 * Otherwise try to find a suitable thread.
868 */
869 t = p->signal->curr_target;
870 if (t == NULL)
871 /* restart balancing at this thread */
872 t = p->signal->curr_target = p;
873
874 while (!wants_signal(sig, t)) {
875 t = next_thread(t);
876 if (t == p->signal->curr_target)
877 /*
878 * No thread needs to be woken.
879 * Any eligible threads will see
880 * the signal in the queue soon.
881 */
882 return;
883 }
884 p->signal->curr_target = t;
885 }
886
887 /*
888 * Found a killable thread. If the signal will be fatal,
889 * then start taking the whole group down immediately.
890 */
891 if (sig_fatal(p, sig) && !(p->signal->flags & SIGNAL_GROUP_EXIT) &&
892 !sigismember(&t->real_blocked, sig) &&
893 (sig == SIGKILL || !(t->ptrace & PT_PTRACED))) {
894 /*
895 * This signal will be fatal to the whole group.
896 */
897 if (!sig_kernel_coredump(sig)) {
898 /*
899 * Start a group exit and wake everybody up.
900 * This way we don't have other threads
901 * running and doing things after a slower
902 * thread has the fatal signal pending.
903 */
904 p->signal->flags = SIGNAL_GROUP_EXIT;
905 p->signal->group_exit_code = sig;
906 p->signal->group_stop_count = 0;
907 t = p;
908 do {
909 sigaddset(&t->pending.signal, SIGKILL);
910 signal_wake_up(t, 1);
911 } while_each_thread(p, t);
912 return;
913 }
914 }
915
916 /*
917 * The signal is already in the shared-pending queue.
918 * Tell the chosen thread to wake up and dequeue it.
919 */
920 signal_wake_up(t, sig == SIGKILL);
921 return;
922}
923
924int
925__group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
926{
927 int ret = 0;
928
929 assert_spin_locked(&p->sighand->siglock);
930 handle_stop_signal(sig, p);
931
932 /* Short-circuit ignored signals. */
933 if (sig_ignored(p, sig))
934 return ret;
935
936 if (LEGACY_QUEUE(&p->signal->shared_pending, sig))
937 /* This is a non-RT signal and we already have one queued. */
938 return ret;
939
940 /*
941 * Put this signal on the shared-pending queue, or fail with EAGAIN.
942 * We always use the shared queue for process-wide signals,
943 * to avoid several races.
944 */
945 ret = send_signal(sig, info, p, &p->signal->shared_pending);
946 if (unlikely(ret))
947 return ret;
948
949 __group_complete_signal(sig, p);
950 return 0;
951}
952
953/*
954 * Nuke all other threads in the group. 931 * Nuke all other threads in the group.
955 */ 932 */
956void zap_other_threads(struct task_struct *p) 933void zap_other_threads(struct task_struct *p)
@@ -978,13 +955,11 @@ int __fatal_signal_pending(struct task_struct *tsk)
978} 955}
979EXPORT_SYMBOL(__fatal_signal_pending); 956EXPORT_SYMBOL(__fatal_signal_pending);
980 957
981/*
982 * Must be called under rcu_read_lock() or with tasklist_lock read-held.
983 */
984struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags) 958struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long *flags)
985{ 959{
986 struct sighand_struct *sighand; 960 struct sighand_struct *sighand;
987 961
962 rcu_read_lock();
988 for (;;) { 963 for (;;) {
989 sighand = rcu_dereference(tsk->sighand); 964 sighand = rcu_dereference(tsk->sighand);
990 if (unlikely(sighand == NULL)) 965 if (unlikely(sighand == NULL))
@@ -995,6 +970,7 @@ struct sighand_struct *lock_task_sighand(struct task_struct *tsk, unsigned long
995 break; 970 break;
996 spin_unlock_irqrestore(&sighand->siglock, *flags); 971 spin_unlock_irqrestore(&sighand->siglock, *flags);
997 } 972 }
973 rcu_read_unlock();
998 974
999 return sighand; 975 return sighand;
1000} 976}
@@ -1043,9 +1019,6 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
1043 struct task_struct *p; 1019 struct task_struct *p;
1044 1020
1045 rcu_read_lock(); 1021 rcu_read_lock();
1046 if (unlikely(sig_needs_tasklist(sig)))
1047 read_lock(&tasklist_lock);
1048
1049retry: 1022retry:
1050 p = pid_task(pid, PIDTYPE_PID); 1023 p = pid_task(pid, PIDTYPE_PID);
1051 if (p) { 1024 if (p) {
@@ -1059,10 +1032,8 @@ retry:
1059 */ 1032 */
1060 goto retry; 1033 goto retry;
1061 } 1034 }
1062
1063 if (unlikely(sig_needs_tasklist(sig)))
1064 read_unlock(&tasklist_lock);
1065 rcu_read_unlock(); 1035 rcu_read_unlock();
1036
1066 return error; 1037 return error;
1067} 1038}
1068 1039
@@ -1159,8 +1130,7 @@ static int kill_something_info(int sig, struct siginfo *info, int pid)
1159 */ 1130 */
1160 1131
1161/* 1132/*
1162 * These two are the most common entry points. They send a signal 1133 * The caller must ensure the task can't exit.
1163 * just to the specific thread.
1164 */ 1134 */
1165int 1135int
1166send_sig_info(int sig, struct siginfo *info, struct task_struct *p) 1136send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
@@ -1175,17 +1145,9 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1175 if (!valid_signal(sig)) 1145 if (!valid_signal(sig))
1176 return -EINVAL; 1146 return -EINVAL;
1177 1147
1178 /*
1179 * We need the tasklist lock even for the specific
1180 * thread case (when we don't need to follow the group
1181 * lists) in order to avoid races with "p->sighand"
1182 * going away or changing from under us.
1183 */
1184 read_lock(&tasklist_lock);
1185 spin_lock_irqsave(&p->sighand->siglock, flags); 1148 spin_lock_irqsave(&p->sighand->siglock, flags);
1186 ret = specific_send_sig_info(sig, info, p); 1149 ret = specific_send_sig_info(sig, info, p);
1187 spin_unlock_irqrestore(&p->sighand->siglock, flags); 1150 spin_unlock_irqrestore(&p->sighand->siglock, flags);
1188 read_unlock(&tasklist_lock);
1189 return ret; 1151 return ret;
1190} 1152}
1191 1153
@@ -1291,28 +1253,24 @@ void sigqueue_free(struct sigqueue *q)
1291 __sigqueue_free(q); 1253 __sigqueue_free(q);
1292} 1254}
1293 1255
1294int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p) 1256int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
1295{ 1257{
1258 int sig = q->info.si_signo;
1259 struct sigpending *pending;
1296 unsigned long flags; 1260 unsigned long flags;
1297 int ret = 0; 1261 int ret;
1298 1262
1299 BUG_ON(!(q->flags & SIGQUEUE_PREALLOC)); 1263 BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
1300 1264
1301 /* 1265 ret = -1;
1302 * The rcu based delayed sighand destroy makes it possible to 1266 if (!likely(lock_task_sighand(t, &flags)))
1303 * run this without tasklist lock held. The task struct itself 1267 goto ret;
1304 * cannot go away as create_timer did get_task_struct().
1305 *
1306 * We return -1, when the task is marked exiting, so
1307 * posix_timer_event can redirect it to the group leader
1308 */
1309 rcu_read_lock();
1310 1268
1311 if (!likely(lock_task_sighand(p, &flags))) { 1269 ret = 1; /* the signal is ignored */
1312 ret = -1; 1270 if (!prepare_signal(sig, t))
1313 goto out_err; 1271 goto out;
1314 }
1315 1272
1273 ret = 0;
1316 if (unlikely(!list_empty(&q->list))) { 1274 if (unlikely(!list_empty(&q->list))) {
1317 /* 1275 /*
1318 * If an SI_TIMER entry is already queue just increment 1276 * If an SI_TIMER entry is already queue just increment
@@ -1322,77 +1280,15 @@ int send_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
1322 q->info.si_overrun++; 1280 q->info.si_overrun++;
1323 goto out; 1281 goto out;
1324 } 1282 }
1325 /* Short-circuit ignored signals. */
1326 if (sig_ignored(p, sig)) {
1327 ret = 1;
1328 goto out;
1329 }
1330 /*
1331 * Deliver the signal to listening signalfds. This must be called
1332 * with the sighand lock held.
1333 */
1334 signalfd_notify(p, sig);
1335
1336 list_add_tail(&q->list, &p->pending.list);
1337 sigaddset(&p->pending.signal, sig);
1338 if (!sigismember(&p->blocked, sig))
1339 signal_wake_up(p, sig == SIGKILL);
1340
1341out:
1342 unlock_task_sighand(p, &flags);
1343out_err:
1344 rcu_read_unlock();
1345
1346 return ret;
1347}
1348
1349int
1350send_group_sigqueue(int sig, struct sigqueue *q, struct task_struct *p)
1351{
1352 unsigned long flags;
1353 int ret = 0;
1354
1355 BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
1356
1357 read_lock(&tasklist_lock);
1358 /* Since it_lock is held, p->sighand cannot be NULL. */
1359 spin_lock_irqsave(&p->sighand->siglock, flags);
1360 handle_stop_signal(sig, p);
1361
1362 /* Short-circuit ignored signals. */
1363 if (sig_ignored(p, sig)) {
1364 ret = 1;
1365 goto out;
1366 }
1367 1283
1368 if (unlikely(!list_empty(&q->list))) { 1284 signalfd_notify(t, sig);
1369 /* 1285 pending = group ? &t->signal->shared_pending : &t->pending;
1370 * If an SI_TIMER entry is already queue just increment 1286 list_add_tail(&q->list, &pending->list);
1371 * the overrun count. Other uses should not try to 1287 sigaddset(&pending->signal, sig);
1372 * send the signal multiple times. 1288 complete_signal(sig, t, group);
1373 */
1374 BUG_ON(q->info.si_code != SI_TIMER);
1375 q->info.si_overrun++;
1376 goto out;
1377 }
1378 /*
1379 * Deliver the signal to listening signalfds. This must be called
1380 * with the sighand lock held.
1381 */
1382 signalfd_notify(p, sig);
1383
1384 /*
1385 * Put this signal on the shared-pending queue.
1386 * We always use the shared queue for process-wide signals,
1387 * to avoid several races.
1388 */
1389 list_add_tail(&q->list, &p->signal->shared_pending.list);
1390 sigaddset(&p->signal->shared_pending.signal, sig);
1391
1392 __group_complete_signal(sig, p);
1393out: 1289out:
1394 spin_unlock_irqrestore(&p->sighand->siglock, flags); 1290 unlock_task_sighand(t, &flags);
1395 read_unlock(&tasklist_lock); 1291ret:
1396 return ret; 1292 return ret;
1397} 1293}
1398 1294
@@ -1723,8 +1619,9 @@ static int do_signal_stop(int signr)
1723 } else { 1619 } else {
1724 struct task_struct *t; 1620 struct task_struct *t;
1725 1621
1726 if (!likely(sig->flags & SIGNAL_STOP_DEQUEUED) || 1622 if (unlikely((sig->flags & (SIGNAL_STOP_DEQUEUED | SIGNAL_UNKILLABLE))
1727 unlikely(sig->group_exit_task)) 1623 != SIGNAL_STOP_DEQUEUED) ||
1624 unlikely(signal_group_exit(sig)))
1728 return 0; 1625 return 0;
1729 /* 1626 /*
1730 * There is no group stop already in progress. 1627 * There is no group stop already in progress.
@@ -1799,8 +1696,9 @@ static int ptrace_signal(int signr, siginfo_t *info,
1799int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, 1696int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
1800 struct pt_regs *regs, void *cookie) 1697 struct pt_regs *regs, void *cookie)
1801{ 1698{
1802 sigset_t *mask = &current->blocked; 1699 struct sighand_struct *sighand = current->sighand;
1803 int signr = 0; 1700 struct signal_struct *signal = current->signal;
1701 int signr;
1804 1702
1805relock: 1703relock:
1806 /* 1704 /*
@@ -1811,16 +1709,32 @@ relock:
1811 */ 1709 */
1812 try_to_freeze(); 1710 try_to_freeze();
1813 1711
1814 spin_lock_irq(&current->sighand->siglock); 1712 spin_lock_irq(&sighand->siglock);
1713 /*
1714 * Every stopped thread goes here after wakeup. Check to see if
1715 * we should notify the parent, prepare_signal(SIGCONT) encodes
1716 * the CLD_ si_code into SIGNAL_CLD_MASK bits.
1717 */
1718 if (unlikely(signal->flags & SIGNAL_CLD_MASK)) {
1719 int why = (signal->flags & SIGNAL_STOP_CONTINUED)
1720 ? CLD_CONTINUED : CLD_STOPPED;
1721 signal->flags &= ~SIGNAL_CLD_MASK;
1722 spin_unlock_irq(&sighand->siglock);
1723
1724 read_lock(&tasklist_lock);
1725 do_notify_parent_cldstop(current->group_leader, why);
1726 read_unlock(&tasklist_lock);
1727 goto relock;
1728 }
1729
1815 for (;;) { 1730 for (;;) {
1816 struct k_sigaction *ka; 1731 struct k_sigaction *ka;
1817 1732
1818 if (unlikely(current->signal->group_stop_count > 0) && 1733 if (unlikely(signal->group_stop_count > 0) &&
1819 do_signal_stop(0)) 1734 do_signal_stop(0))
1820 goto relock; 1735 goto relock;
1821 1736
1822 signr = dequeue_signal(current, mask, info); 1737 signr = dequeue_signal(current, &current->blocked, info);
1823
1824 if (!signr) 1738 if (!signr)
1825 break; /* will return 0 */ 1739 break; /* will return 0 */
1826 1740
@@ -1830,7 +1744,7 @@ relock:
1830 continue; 1744 continue;
1831 } 1745 }
1832 1746
1833 ka = &current->sighand->action[signr-1]; 1747 ka = &sighand->action[signr-1];
1834 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ 1748 if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */
1835 continue; 1749 continue;
1836 if (ka->sa.sa_handler != SIG_DFL) { 1750 if (ka->sa.sa_handler != SIG_DFL) {
@@ -1852,7 +1766,8 @@ relock:
1852 /* 1766 /*
1853 * Global init gets no signals it doesn't want. 1767 * Global init gets no signals it doesn't want.
1854 */ 1768 */
1855 if (is_global_init(current)) 1769 if (unlikely(signal->flags & SIGNAL_UNKILLABLE) &&
1770 !signal_group_exit(signal))
1856 continue; 1771 continue;
1857 1772
1858 if (sig_kernel_stop(signr)) { 1773 if (sig_kernel_stop(signr)) {
@@ -1867,14 +1782,14 @@ relock:
1867 * We need to check for that and bail out if necessary. 1782 * We need to check for that and bail out if necessary.
1868 */ 1783 */
1869 if (signr != SIGSTOP) { 1784 if (signr != SIGSTOP) {
1870 spin_unlock_irq(&current->sighand->siglock); 1785 spin_unlock_irq(&sighand->siglock);
1871 1786
1872 /* signals can be posted during this window */ 1787 /* signals can be posted during this window */
1873 1788
1874 if (is_current_pgrp_orphaned()) 1789 if (is_current_pgrp_orphaned())
1875 goto relock; 1790 goto relock;
1876 1791
1877 spin_lock_irq(&current->sighand->siglock); 1792 spin_lock_irq(&sighand->siglock);
1878 } 1793 }
1879 1794
1880 if (likely(do_signal_stop(signr))) { 1795 if (likely(do_signal_stop(signr))) {
@@ -1889,15 +1804,16 @@ relock:
1889 continue; 1804 continue;
1890 } 1805 }
1891 1806
1892 spin_unlock_irq(&current->sighand->siglock); 1807 spin_unlock_irq(&sighand->siglock);
1893 1808
1894 /* 1809 /*
1895 * Anything else is fatal, maybe with a core dump. 1810 * Anything else is fatal, maybe with a core dump.
1896 */ 1811 */
1897 current->flags |= PF_SIGNALED; 1812 current->flags |= PF_SIGNALED;
1898 if ((signr != SIGKILL) && print_fatal_signals) 1813
1899 print_fatal_signal(regs, signr);
1900 if (sig_kernel_coredump(signr)) { 1814 if (sig_kernel_coredump(signr)) {
1815 if (print_fatal_signals)
1816 print_fatal_signal(regs, signr);
1901 /* 1817 /*
1902 * If it was able to dump core, this kills all 1818 * If it was able to dump core, this kills all
1903 * other threads in the group and synchronizes with 1819 * other threads in the group and synchronizes with
@@ -1915,7 +1831,7 @@ relock:
1915 do_group_exit(signr); 1831 do_group_exit(signr);
1916 /* NOTREACHED */ 1832 /* NOTREACHED */
1917 } 1833 }
1918 spin_unlock_irq(&current->sighand->siglock); 1834 spin_unlock_irq(&sighand->siglock);
1919 return signr; 1835 return signr;
1920} 1836}
1921 1837
@@ -2259,6 +2175,7 @@ static int do_tkill(int tgid, int pid, int sig)
2259 int error; 2175 int error;
2260 struct siginfo info; 2176 struct siginfo info;
2261 struct task_struct *p; 2177 struct task_struct *p;
2178 unsigned long flags;
2262 2179
2263 error = -ESRCH; 2180 error = -ESRCH;
2264 info.si_signo = sig; 2181 info.si_signo = sig;
@@ -2267,22 +2184,24 @@ static int do_tkill(int tgid, int pid, int sig)
2267 info.si_pid = task_tgid_vnr(current); 2184 info.si_pid = task_tgid_vnr(current);
2268 info.si_uid = current->uid; 2185 info.si_uid = current->uid;
2269 2186
2270 read_lock(&tasklist_lock); 2187 rcu_read_lock();
2271 p = find_task_by_vpid(pid); 2188 p = find_task_by_vpid(pid);
2272 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) { 2189 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
2273 error = check_kill_permission(sig, &info, p); 2190 error = check_kill_permission(sig, &info, p);
2274 /* 2191 /*
2275 * The null signal is a permissions and process existence 2192 * The null signal is a permissions and process existence
2276 * probe. No signal is actually delivered. 2193 * probe. No signal is actually delivered.
2194 *
2195 * If lock_task_sighand() fails we pretend the task dies
2196 * after receiving the signal. The window is tiny, and the
2197 * signal is private anyway.
2277 */ 2198 */
2278 if (!error && sig && p->sighand) { 2199 if (!error && sig && lock_task_sighand(p, &flags)) {
2279 spin_lock_irq(&p->sighand->siglock);
2280 handle_stop_signal(sig, p);
2281 error = specific_send_sig_info(sig, &info, p); 2200 error = specific_send_sig_info(sig, &info, p);
2282 spin_unlock_irq(&p->sighand->siglock); 2201 unlock_task_sighand(p, &flags);
2283 } 2202 }
2284 } 2203 }
2285 read_unlock(&tasklist_lock); 2204 rcu_read_unlock();
2286 2205
2287 return error; 2206 return error;
2288} 2207}
@@ -2339,13 +2258,14 @@ sys_rt_sigqueueinfo(int pid, int sig, siginfo_t __user *uinfo)
2339 2258
2340int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact) 2259int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
2341{ 2260{
2261 struct task_struct *t = current;
2342 struct k_sigaction *k; 2262 struct k_sigaction *k;
2343 sigset_t mask; 2263 sigset_t mask;
2344 2264
2345 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig))) 2265 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
2346 return -EINVAL; 2266 return -EINVAL;
2347 2267
2348 k = &current->sighand->action[sig-1]; 2268 k = &t->sighand->action[sig-1];
2349 2269
2350 spin_lock_irq(&current->sighand->siglock); 2270 spin_lock_irq(&current->sighand->siglock);
2351 if (oact) 2271 if (oact)
@@ -2366,9 +2286,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
2366 * (for example, SIGCHLD), shall cause the pending signal to 2286 * (for example, SIGCHLD), shall cause the pending signal to
2367 * be discarded, whether or not it is blocked" 2287 * be discarded, whether or not it is blocked"
2368 */ 2288 */
2369 if (act->sa.sa_handler == SIG_IGN || 2289 if (__sig_ignored(t, sig)) {
2370 (act->sa.sa_handler == SIG_DFL && sig_kernel_ignore(sig))) {
2371 struct task_struct *t = current;
2372 sigemptyset(&mask); 2290 sigemptyset(&mask);
2373 sigaddset(&mask, sig); 2291 sigaddset(&mask, sig);
2374 rm_from_queue_full(&mask, &t->signal->shared_pending); 2292 rm_from_queue_full(&mask, &t->signal->shared_pending);
@@ -2623,7 +2541,7 @@ asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
2623 2541
2624 current->state = TASK_INTERRUPTIBLE; 2542 current->state = TASK_INTERRUPTIBLE;
2625 schedule(); 2543 schedule();
2626 set_thread_flag(TIF_RESTORE_SIGMASK); 2544 set_restore_sigmask();
2627 return -ERESTARTNOHAND; 2545 return -ERESTARTNOHAND;
2628} 2546}
2629#endif /* __ARCH_WANT_SYS_RT_SIGSUSPEND */ 2547#endif /* __ARCH_WANT_SYS_RT_SIGSUSPEND */
diff --git a/kernel/sys.c b/kernel/sys.c
index e423d0d9e6ff..895d2d4c9493 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -978,8 +978,7 @@ asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
978 goto out; 978 goto out;
979 979
980 if (task_pgrp(p) != pgrp) { 980 if (task_pgrp(p) != pgrp) {
981 detach_pid(p, PIDTYPE_PGID); 981 change_pid(p, PIDTYPE_PGID, pgrp);
982 attach_pid(p, PIDTYPE_PGID, pgrp);
983 set_task_pgrp(p, pid_nr(pgrp)); 982 set_task_pgrp(p, pid_nr(pgrp));
984 } 983 }
985 984
@@ -992,54 +991,67 @@ out:
992 991
993asmlinkage long sys_getpgid(pid_t pid) 992asmlinkage long sys_getpgid(pid_t pid)
994{ 993{
994 struct task_struct *p;
995 struct pid *grp;
996 int retval;
997
998 rcu_read_lock();
995 if (!pid) 999 if (!pid)
996 return task_pgrp_vnr(current); 1000 grp = task_pgrp(current);
997 else { 1001 else {
998 int retval;
999 struct task_struct *p;
1000
1001 read_lock(&tasklist_lock);
1002 p = find_task_by_vpid(pid);
1003 retval = -ESRCH; 1002 retval = -ESRCH;
1004 if (p) { 1003 p = find_task_by_vpid(pid);
1005 retval = security_task_getpgid(p); 1004 if (!p)
1006 if (!retval) 1005 goto out;
1007 retval = task_pgrp_vnr(p); 1006 grp = task_pgrp(p);
1008 } 1007 if (!grp)
1009 read_unlock(&tasklist_lock); 1008 goto out;
1010 return retval; 1009
1010 retval = security_task_getpgid(p);
1011 if (retval)
1012 goto out;
1011 } 1013 }
1014 retval = pid_vnr(grp);
1015out:
1016 rcu_read_unlock();
1017 return retval;
1012} 1018}
1013 1019
1014#ifdef __ARCH_WANT_SYS_GETPGRP 1020#ifdef __ARCH_WANT_SYS_GETPGRP
1015 1021
1016asmlinkage long sys_getpgrp(void) 1022asmlinkage long sys_getpgrp(void)
1017{ 1023{
1018 /* SMP - assuming writes are word atomic this is fine */ 1024 return sys_getpgid(0);
1019 return task_pgrp_vnr(current);
1020} 1025}
1021 1026
1022#endif 1027#endif
1023 1028
1024asmlinkage long sys_getsid(pid_t pid) 1029asmlinkage long sys_getsid(pid_t pid)
1025{ 1030{
1031 struct task_struct *p;
1032 struct pid *sid;
1033 int retval;
1034
1035 rcu_read_lock();
1026 if (!pid) 1036 if (!pid)
1027 return task_session_vnr(current); 1037 sid = task_session(current);
1028 else { 1038 else {
1029 int retval;
1030 struct task_struct *p;
1031
1032 rcu_read_lock();
1033 p = find_task_by_vpid(pid);
1034 retval = -ESRCH; 1039 retval = -ESRCH;
1035 if (p) { 1040 p = find_task_by_vpid(pid);
1036 retval = security_task_getsid(p); 1041 if (!p)
1037 if (!retval) 1042 goto out;
1038 retval = task_session_vnr(p); 1043 sid = task_session(p);
1039 } 1044 if (!sid)
1040 rcu_read_unlock(); 1045 goto out;
1041 return retval; 1046
1047 retval = security_task_getsid(p);
1048 if (retval)
1049 goto out;
1042 } 1050 }
1051 retval = pid_vnr(sid);
1052out:
1053 rcu_read_unlock();
1054 return retval;
1043} 1055}
1044 1056
1045asmlinkage long sys_setsid(void) 1057asmlinkage long sys_setsid(void)
@@ -1572,11 +1584,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
1572 goto out; 1584 goto out;
1573 } 1585 }
1574 1586
1575 rcu_read_lock(); 1587 if (!lock_task_sighand(p, &flags))
1576 if (!lock_task_sighand(p, &flags)) {
1577 rcu_read_unlock();
1578 return; 1588 return;
1579 }
1580 1589
1581 switch (who) { 1590 switch (who) {
1582 case RUSAGE_BOTH: 1591 case RUSAGE_BOTH:
@@ -1612,9 +1621,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
1612 default: 1621 default:
1613 BUG(); 1622 BUG();
1614 } 1623 }
1615
1616 unlock_task_sighand(p, &flags); 1624 unlock_task_sighand(p, &flags);
1617 rcu_read_unlock();
1618 1625
1619out: 1626out:
1620 cputime_to_timeval(utime, &r->ru_utime); 1627 cputime_to_timeval(utime, &r->ru_utime);
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 07e86a828073..4a23517169a6 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -183,7 +183,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
183 183
184 if (!tsk) { 184 if (!tsk) {
185 rcu_read_lock(); 185 rcu_read_lock();
186 tsk = find_task_by_pid(pid); 186 tsk = find_task_by_vpid(pid);
187 if (tsk) 187 if (tsk)
188 get_task_struct(tsk); 188 get_task_struct(tsk);
189 rcu_read_unlock(); 189 rcu_read_unlock();
@@ -230,7 +230,7 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
230 */ 230 */
231 rcu_read_lock(); 231 rcu_read_lock();
232 if (!first) 232 if (!first)
233 first = find_task_by_pid(tgid); 233 first = find_task_by_vpid(tgid);
234 234
235 if (!first || !lock_task_sighand(first, &flags)) 235 if (!first || !lock_task_sighand(first, &flags))
236 goto out; 236 goto out;
@@ -547,7 +547,7 @@ void taskstats_exit(struct task_struct *tsk, int group_dead)
547 if (!stats) 547 if (!stats)
548 goto err; 548 goto err;
549 549
550 rc = fill_pid(tsk->pid, tsk, stats); 550 rc = fill_pid(-1, tsk, stats);
551 if (rc < 0) 551 if (rc < 0)
552 goto err; 552 goto err;
553 553
diff --git a/kernel/timer.c b/kernel/timer.c
index f3d35d4ea42e..ceacc6626572 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -320,14 +320,130 @@ static void timer_stats_account_timer(struct timer_list *timer)
320static void timer_stats_account_timer(struct timer_list *timer) {} 320static void timer_stats_account_timer(struct timer_list *timer) {}
321#endif 321#endif
322 322
323/** 323#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
324 * init_timer - initialize a timer. 324
325 * @timer: the timer to be initialized 325static struct debug_obj_descr timer_debug_descr;
326 * 326
327 * init_timer() must be done to a timer prior calling *any* of the 327/*
328 * other timer functions. 328 * fixup_init is called when:
329 * - an active object is initialized
329 */ 330 */
330void init_timer(struct timer_list *timer) 331static int timer_fixup_init(void *addr, enum debug_obj_state state)
332{
333 struct timer_list *timer = addr;
334
335 switch (state) {
336 case ODEBUG_STATE_ACTIVE:
337 del_timer_sync(timer);
338 debug_object_init(timer, &timer_debug_descr);
339 return 1;
340 default:
341 return 0;
342 }
343}
344
345/*
346 * fixup_activate is called when:
347 * - an active object is activated
348 * - an unknown object is activated (might be a statically initialized object)
349 */
350static int timer_fixup_activate(void *addr, enum debug_obj_state state)
351{
352 struct timer_list *timer = addr;
353
354 switch (state) {
355
356 case ODEBUG_STATE_NOTAVAILABLE:
357 /*
358 * This is not really a fixup. The timer was
359 * statically initialized. We just make sure that it
360 * is tracked in the object tracker.
361 */
362 if (timer->entry.next == NULL &&
363 timer->entry.prev == TIMER_ENTRY_STATIC) {
364 debug_object_init(timer, &timer_debug_descr);
365 debug_object_activate(timer, &timer_debug_descr);
366 return 0;
367 } else {
368 WARN_ON_ONCE(1);
369 }
370 return 0;
371
372 case ODEBUG_STATE_ACTIVE:
373 WARN_ON(1);
374
375 default:
376 return 0;
377 }
378}
379
380/*
381 * fixup_free is called when:
382 * - an active object is freed
383 */
384static int timer_fixup_free(void *addr, enum debug_obj_state state)
385{
386 struct timer_list *timer = addr;
387
388 switch (state) {
389 case ODEBUG_STATE_ACTIVE:
390 del_timer_sync(timer);
391 debug_object_free(timer, &timer_debug_descr);
392 return 1;
393 default:
394 return 0;
395 }
396}
397
398static struct debug_obj_descr timer_debug_descr = {
399 .name = "timer_list",
400 .fixup_init = timer_fixup_init,
401 .fixup_activate = timer_fixup_activate,
402 .fixup_free = timer_fixup_free,
403};
404
405static inline void debug_timer_init(struct timer_list *timer)
406{
407 debug_object_init(timer, &timer_debug_descr);
408}
409
410static inline void debug_timer_activate(struct timer_list *timer)
411{
412 debug_object_activate(timer, &timer_debug_descr);
413}
414
415static inline void debug_timer_deactivate(struct timer_list *timer)
416{
417 debug_object_deactivate(timer, &timer_debug_descr);
418}
419
420static inline void debug_timer_free(struct timer_list *timer)
421{
422 debug_object_free(timer, &timer_debug_descr);
423}
424
425static void __init_timer(struct timer_list *timer);
426
427void init_timer_on_stack(struct timer_list *timer)
428{
429 debug_object_init_on_stack(timer, &timer_debug_descr);
430 __init_timer(timer);
431}
432EXPORT_SYMBOL_GPL(init_timer_on_stack);
433
434void destroy_timer_on_stack(struct timer_list *timer)
435{
436 debug_object_free(timer, &timer_debug_descr);
437}
438EXPORT_SYMBOL_GPL(destroy_timer_on_stack);
439
440#else
441static inline void debug_timer_init(struct timer_list *timer) { }
442static inline void debug_timer_activate(struct timer_list *timer) { }
443static inline void debug_timer_deactivate(struct timer_list *timer) { }
444#endif
445
446static void __init_timer(struct timer_list *timer)
331{ 447{
332 timer->entry.next = NULL; 448 timer->entry.next = NULL;
333 timer->base = __raw_get_cpu_var(tvec_bases); 449 timer->base = __raw_get_cpu_var(tvec_bases);
@@ -337,6 +453,19 @@ void init_timer(struct timer_list *timer)
337 memset(timer->start_comm, 0, TASK_COMM_LEN); 453 memset(timer->start_comm, 0, TASK_COMM_LEN);
338#endif 454#endif
339} 455}
456
457/**
458 * init_timer - initialize a timer.
459 * @timer: the timer to be initialized
460 *
461 * init_timer() must be done to a timer prior calling *any* of the
462 * other timer functions.
463 */
464void init_timer(struct timer_list *timer)
465{
466 debug_timer_init(timer);
467 __init_timer(timer);
468}
340EXPORT_SYMBOL(init_timer); 469EXPORT_SYMBOL(init_timer);
341 470
342void init_timer_deferrable(struct timer_list *timer) 471void init_timer_deferrable(struct timer_list *timer)
@@ -351,6 +480,8 @@ static inline void detach_timer(struct timer_list *timer,
351{ 480{
352 struct list_head *entry = &timer->entry; 481 struct list_head *entry = &timer->entry;
353 482
483 debug_timer_deactivate(timer);
484
354 __list_del(entry->prev, entry->next); 485 __list_del(entry->prev, entry->next);
355 if (clear_pending) 486 if (clear_pending)
356 entry->next = NULL; 487 entry->next = NULL;
@@ -405,6 +536,8 @@ int __mod_timer(struct timer_list *timer, unsigned long expires)
405 ret = 1; 536 ret = 1;
406 } 537 }
407 538
539 debug_timer_activate(timer);
540
408 new_base = __get_cpu_var(tvec_bases); 541 new_base = __get_cpu_var(tvec_bases);
409 542
410 if (base != new_base) { 543 if (base != new_base) {
@@ -450,6 +583,7 @@ void add_timer_on(struct timer_list *timer, int cpu)
450 BUG_ON(timer_pending(timer) || !timer->function); 583 BUG_ON(timer_pending(timer) || !timer->function);
451 spin_lock_irqsave(&base->lock, flags); 584 spin_lock_irqsave(&base->lock, flags);
452 timer_set_base(timer, base); 585 timer_set_base(timer, base);
586 debug_timer_activate(timer);
453 internal_add_timer(base, timer); 587 internal_add_timer(base, timer);
454 /* 588 /*
455 * Check whether the other CPU is idle and needs to be 589 * Check whether the other CPU is idle and needs to be
@@ -1086,11 +1220,14 @@ signed long __sched schedule_timeout(signed long timeout)
1086 1220
1087 expire = timeout + jiffies; 1221 expire = timeout + jiffies;
1088 1222
1089 setup_timer(&timer, process_timeout, (unsigned long)current); 1223 setup_timer_on_stack(&timer, process_timeout, (unsigned long)current);
1090 __mod_timer(&timer, expire); 1224 __mod_timer(&timer, expire);
1091 schedule(); 1225 schedule();
1092 del_singleshot_timer_sync(&timer); 1226 del_singleshot_timer_sync(&timer);
1093 1227
1228 /* Remove the timer from the object tracker */
1229 destroy_timer_on_stack(&timer);
1230
1094 timeout = expire - jiffies; 1231 timeout = expire - jiffies;
1095 1232
1096 out: 1233 out:
diff --git a/kernel/user.c b/kernel/user.c
index aefbbfa3159f..865ecf57a096 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -384,7 +384,7 @@ void free_uid(struct user_struct *up)
384 local_irq_restore(flags); 384 local_irq_restore(flags);
385} 385}
386 386
387struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid) 387struct user_struct *alloc_uid(struct user_namespace *ns, uid_t uid)
388{ 388{
389 struct hlist_head *hashent = uidhashentry(ns, uid); 389 struct hlist_head *hashent = uidhashentry(ns, uid);
390 struct user_struct *up, *new; 390 struct user_struct *up, *new;
@@ -399,26 +399,12 @@ struct user_struct * alloc_uid(struct user_namespace *ns, uid_t uid)
399 spin_unlock_irq(&uidhash_lock); 399 spin_unlock_irq(&uidhash_lock);
400 400
401 if (!up) { 401 if (!up) {
402 new = kmem_cache_alloc(uid_cachep, GFP_KERNEL); 402 new = kmem_cache_zalloc(uid_cachep, GFP_KERNEL);
403 if (!new) 403 if (!new)
404 goto out_unlock; 404 goto out_unlock;
405 405
406 new->uid = uid; 406 new->uid = uid;
407 atomic_set(&new->__count, 1); 407 atomic_set(&new->__count, 1);
408 atomic_set(&new->processes, 0);
409 atomic_set(&new->files, 0);
410 atomic_set(&new->sigpending, 0);
411#ifdef CONFIG_INOTIFY_USER
412 atomic_set(&new->inotify_watches, 0);
413 atomic_set(&new->inotify_devs, 0);
414#endif
415#ifdef CONFIG_POSIX_MQUEUE
416 new->mq_bytes = 0;
417#endif
418 new->locked_shm = 0;
419#ifdef CONFIG_KEYS
420 new->uid_keyring = new->session_keyring = NULL;
421#endif
422 408
423 if (sched_create_user(new) < 0) 409 if (sched_create_user(new) < 0)
424 goto out_free_user; 410 goto out_free_user;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 7db251a959c5..721093a22561 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -247,7 +247,7 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
247 if (cwq->run_depth > 3) { 247 if (cwq->run_depth > 3) {
248 /* morton gets to eat his hat */ 248 /* morton gets to eat his hat */
249 printk("%s: recursion depth exceeded: %d\n", 249 printk("%s: recursion depth exceeded: %d\n",
250 __FUNCTION__, cwq->run_depth); 250 __func__, cwq->run_depth);
251 dump_stack(); 251 dump_stack();
252 } 252 }
253 while (!list_empty(&cwq->worklist)) { 253 while (!list_empty(&cwq->worklist)) {
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 754cc0027f2a..d2099f41aa1e 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -194,6 +194,37 @@ config TIMER_STATS
194 (it defaults to deactivated on bootup and will only be activated 194 (it defaults to deactivated on bootup and will only be activated
195 if some application like powertop activates it explicitly). 195 if some application like powertop activates it explicitly).
196 196
197config DEBUG_OBJECTS
198 bool "Debug object operations"
199 depends on DEBUG_KERNEL
200 help
201 If you say Y here, additional code will be inserted into the
202 kernel to track the life time of various objects and validate
203 the operations on those objects.
204
205config DEBUG_OBJECTS_SELFTEST
206 bool "Debug objects selftest"
207 depends on DEBUG_OBJECTS
208 help
209 This enables the selftest of the object debug code.
210
211config DEBUG_OBJECTS_FREE
212 bool "Debug objects in freed memory"
213 depends on DEBUG_OBJECTS
214 help
215 This enables checks whether a k/v free operation frees an area
216 which contains an object which has not been deactivated
217 properly. This can make kmalloc/kfree-intensive workloads
218 much slower.
219
220config DEBUG_OBJECTS_TIMERS
221 bool "Debug timer objects"
222 depends on DEBUG_OBJECTS
223 help
224 If you say Y here, additional code will be inserted into the
225 timer routines to track the life time of timer objects and
226 validate the timer operations.
227
197config DEBUG_SLAB 228config DEBUG_SLAB
198 bool "Debug slab memory allocations" 229 bool "Debug slab memory allocations"
199 depends on DEBUG_KERNEL && SLAB 230 depends on DEBUG_KERNEL && SLAB
diff --git a/lib/Makefile b/lib/Makefile
index 0ae4eb047aac..74b0cfb1fcc3 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
36obj-$(CONFIG_PLIST) += plist.o 36obj-$(CONFIG_PLIST) += plist.o
37obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 37obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
38obj-$(CONFIG_DEBUG_LIST) += list_debug.o 38obj-$(CONFIG_DEBUG_LIST) += list_debug.o
39obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
39 40
40ifneq ($(CONFIG_HAVE_DEC_LOCK),y) 41ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
41 lib-y += dec_and_lock.o 42 lib-y += dec_and_lock.o
diff --git a/lib/debugobjects.c b/lib/debugobjects.c
new file mode 100644
index 000000000000..a76a5e122ae1
--- /dev/null
+++ b/lib/debugobjects.c
@@ -0,0 +1,890 @@
1/*
2 * Generic infrastructure for lifetime debugging of objects.
3 *
4 * Started by Thomas Gleixner
5 *
6 * Copyright (C) 2008, Thomas Gleixner <tglx@linutronix.de>
7 *
8 * For licencing details see kernel-base/COPYING
9 */
10#include <linux/debugobjects.h>
11#include <linux/interrupt.h>
12#include <linux/seq_file.h>
13#include <linux/debugfs.h>
14#include <linux/hash.h>
15
16#define ODEBUG_HASH_BITS 14
17#define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS)
18
19#define ODEBUG_POOL_SIZE 512
20#define ODEBUG_POOL_MIN_LEVEL 256
21
22#define ODEBUG_CHUNK_SHIFT PAGE_SHIFT
23#define ODEBUG_CHUNK_SIZE (1 << ODEBUG_CHUNK_SHIFT)
24#define ODEBUG_CHUNK_MASK (~(ODEBUG_CHUNK_SIZE - 1))
25
26struct debug_bucket {
27 struct hlist_head list;
28 spinlock_t lock;
29};
30
31static struct debug_bucket obj_hash[ODEBUG_HASH_SIZE];
32
33static struct debug_obj obj_static_pool[ODEBUG_POOL_SIZE];
34
35static DEFINE_SPINLOCK(pool_lock);
36
37static HLIST_HEAD(obj_pool);
38
39static int obj_pool_min_free = ODEBUG_POOL_SIZE;
40static int obj_pool_free = ODEBUG_POOL_SIZE;
41static int obj_pool_used;
42static int obj_pool_max_used;
43static struct kmem_cache *obj_cache;
44
45static int debug_objects_maxchain __read_mostly;
46static int debug_objects_fixups __read_mostly;
47static int debug_objects_warnings __read_mostly;
48static int debug_objects_enabled __read_mostly;
49static struct debug_obj_descr *descr_test __read_mostly;
50
51static int __init enable_object_debug(char *str)
52{
53 debug_objects_enabled = 1;
54 return 0;
55}
56early_param("debug_objects", enable_object_debug);
57
58static const char *obj_states[ODEBUG_STATE_MAX] = {
59 [ODEBUG_STATE_NONE] = "none",
60 [ODEBUG_STATE_INIT] = "initialized",
61 [ODEBUG_STATE_INACTIVE] = "inactive",
62 [ODEBUG_STATE_ACTIVE] = "active",
63 [ODEBUG_STATE_DESTROYED] = "destroyed",
64 [ODEBUG_STATE_NOTAVAILABLE] = "not available",
65};
66
67static int fill_pool(void)
68{
69 gfp_t gfp = GFP_ATOMIC | __GFP_NORETRY | __GFP_NOWARN;
70 struct debug_obj *new;
71
72 if (likely(obj_pool_free >= ODEBUG_POOL_MIN_LEVEL))
73 return obj_pool_free;
74
75 if (unlikely(!obj_cache))
76 return obj_pool_free;
77
78 while (obj_pool_free < ODEBUG_POOL_MIN_LEVEL) {
79
80 new = kmem_cache_zalloc(obj_cache, gfp);
81 if (!new)
82 return obj_pool_free;
83
84 spin_lock(&pool_lock);
85 hlist_add_head(&new->node, &obj_pool);
86 obj_pool_free++;
87 spin_unlock(&pool_lock);
88 }
89 return obj_pool_free;
90}
91
92/*
93 * Lookup an object in the hash bucket.
94 */
95static struct debug_obj *lookup_object(void *addr, struct debug_bucket *b)
96{
97 struct hlist_node *node;
98 struct debug_obj *obj;
99 int cnt = 0;
100
101 hlist_for_each_entry(obj, node, &b->list, node) {
102 cnt++;
103 if (obj->object == addr)
104 return obj;
105 }
106 if (cnt > debug_objects_maxchain)
107 debug_objects_maxchain = cnt;
108
109 return NULL;
110}
111
112/*
113 * Allocate a new object. If the pool is empty and no refill possible,
114 * switch off the debugger.
115 */
116static struct debug_obj *
117alloc_object(void *addr, struct debug_bucket *b, struct debug_obj_descr *descr)
118{
119 struct debug_obj *obj = NULL;
120 int retry = 0;
121
122repeat:
123 spin_lock(&pool_lock);
124 if (obj_pool.first) {
125 obj = hlist_entry(obj_pool.first, typeof(*obj), node);
126
127 obj->object = addr;
128 obj->descr = descr;
129 obj->state = ODEBUG_STATE_NONE;
130 hlist_del(&obj->node);
131
132 hlist_add_head(&obj->node, &b->list);
133
134 obj_pool_used++;
135 if (obj_pool_used > obj_pool_max_used)
136 obj_pool_max_used = obj_pool_used;
137
138 obj_pool_free--;
139 if (obj_pool_free < obj_pool_min_free)
140 obj_pool_min_free = obj_pool_free;
141 }
142 spin_unlock(&pool_lock);
143
144 if (fill_pool() && !obj && !retry++)
145 goto repeat;
146
147 return obj;
148}
149
150/*
151 * Put the object back into the pool or give it back to kmem_cache:
152 */
153static void free_object(struct debug_obj *obj)
154{
155 unsigned long idx = (unsigned long)(obj - obj_static_pool);
156
157 if (obj_pool_free < ODEBUG_POOL_SIZE || idx < ODEBUG_POOL_SIZE) {
158 spin_lock(&pool_lock);
159 hlist_add_head(&obj->node, &obj_pool);
160 obj_pool_free++;
161 obj_pool_used--;
162 spin_unlock(&pool_lock);
163 } else {
164 spin_lock(&pool_lock);
165 obj_pool_used--;
166 spin_unlock(&pool_lock);
167 kmem_cache_free(obj_cache, obj);
168 }
169}
170
171/*
172 * We run out of memory. That means we probably have tons of objects
173 * allocated.
174 */
175static void debug_objects_oom(void)
176{
177 struct debug_bucket *db = obj_hash;
178 struct hlist_node *node, *tmp;
179 struct debug_obj *obj;
180 unsigned long flags;
181 int i;
182
183 printk(KERN_WARNING "ODEBUG: Out of memory. ODEBUG disabled\n");
184
185 for (i = 0; i < ODEBUG_HASH_SIZE; i++, db++) {
186 spin_lock_irqsave(&db->lock, flags);
187 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
188 hlist_del(&obj->node);
189 free_object(obj);
190 }
191 spin_unlock_irqrestore(&db->lock, flags);
192 }
193}
194
195/*
196 * We use the pfn of the address for the hash. That way we can check
197 * for freed objects simply by checking the affected bucket.
198 */
199static struct debug_bucket *get_bucket(unsigned long addr)
200{
201 unsigned long hash;
202
203 hash = hash_long((addr >> ODEBUG_CHUNK_SHIFT), ODEBUG_HASH_BITS);
204 return &obj_hash[hash];
205}
206
207static void debug_print_object(struct debug_obj *obj, char *msg)
208{
209 static int limit;
210
211 if (limit < 5 && obj->descr != descr_test) {
212 limit++;
213 printk(KERN_ERR "ODEBUG: %s %s object type: %s\n", msg,
214 obj_states[obj->state], obj->descr->name);
215 WARN_ON(1);
216 }
217 debug_objects_warnings++;
218}
219
220/*
221 * Try to repair the damage, so we have a better chance to get useful
222 * debug output.
223 */
224static void
225debug_object_fixup(int (*fixup)(void *addr, enum debug_obj_state state),
226 void * addr, enum debug_obj_state state)
227{
228 if (fixup)
229 debug_objects_fixups += fixup(addr, state);
230}
231
232static void debug_object_is_on_stack(void *addr, int onstack)
233{
234 void *stack = current->stack;
235 int is_on_stack;
236 static int limit;
237
238 if (limit > 4)
239 return;
240
241 is_on_stack = (addr >= stack && addr < (stack + THREAD_SIZE));
242
243 if (is_on_stack == onstack)
244 return;
245
246 limit++;
247 if (is_on_stack)
248 printk(KERN_WARNING
249 "ODEBUG: object is on stack, but not annotated\n");
250 else
251 printk(KERN_WARNING
252 "ODEBUG: object is not on stack, but annotated\n");
253 WARN_ON(1);
254}
255
256static void
257__debug_object_init(void *addr, struct debug_obj_descr *descr, int onstack)
258{
259 enum debug_obj_state state;
260 struct debug_bucket *db;
261 struct debug_obj *obj;
262 unsigned long flags;
263
264 db = get_bucket((unsigned long) addr);
265
266 spin_lock_irqsave(&db->lock, flags);
267
268 obj = lookup_object(addr, db);
269 if (!obj) {
270 obj = alloc_object(addr, db, descr);
271 if (!obj) {
272 debug_objects_enabled = 0;
273 spin_unlock_irqrestore(&db->lock, flags);
274 debug_objects_oom();
275 return;
276 }
277 debug_object_is_on_stack(addr, onstack);
278 }
279
280 switch (obj->state) {
281 case ODEBUG_STATE_NONE:
282 case ODEBUG_STATE_INIT:
283 case ODEBUG_STATE_INACTIVE:
284 obj->state = ODEBUG_STATE_INIT;
285 break;
286
287 case ODEBUG_STATE_ACTIVE:
288 debug_print_object(obj, "init");
289 state = obj->state;
290 spin_unlock_irqrestore(&db->lock, flags);
291 debug_object_fixup(descr->fixup_init, addr, state);
292 return;
293
294 case ODEBUG_STATE_DESTROYED:
295 debug_print_object(obj, "init");
296 break;
297 default:
298 break;
299 }
300
301 spin_unlock_irqrestore(&db->lock, flags);
302}
303
304/**
305 * debug_object_init - debug checks when an object is initialized
306 * @addr: address of the object
307 * @descr: pointer to an object specific debug description structure
308 */
309void debug_object_init(void *addr, struct debug_obj_descr *descr)
310{
311 if (!debug_objects_enabled)
312 return;
313
314 __debug_object_init(addr, descr, 0);
315}
316
317/**
318 * debug_object_init_on_stack - debug checks when an object on stack is
319 * initialized
320 * @addr: address of the object
321 * @descr: pointer to an object specific debug description structure
322 */
323void debug_object_init_on_stack(void *addr, struct debug_obj_descr *descr)
324{
325 if (!debug_objects_enabled)
326 return;
327
328 __debug_object_init(addr, descr, 1);
329}
330
331/**
332 * debug_object_activate - debug checks when an object is activated
333 * @addr: address of the object
334 * @descr: pointer to an object specific debug description structure
335 */
336void debug_object_activate(void *addr, struct debug_obj_descr *descr)
337{
338 enum debug_obj_state state;
339 struct debug_bucket *db;
340 struct debug_obj *obj;
341 unsigned long flags;
342
343 if (!debug_objects_enabled)
344 return;
345
346 db = get_bucket((unsigned long) addr);
347
348 spin_lock_irqsave(&db->lock, flags);
349
350 obj = lookup_object(addr, db);
351 if (obj) {
352 switch (obj->state) {
353 case ODEBUG_STATE_INIT:
354 case ODEBUG_STATE_INACTIVE:
355 obj->state = ODEBUG_STATE_ACTIVE;
356 break;
357
358 case ODEBUG_STATE_ACTIVE:
359 debug_print_object(obj, "activate");
360 state = obj->state;
361 spin_unlock_irqrestore(&db->lock, flags);
362 debug_object_fixup(descr->fixup_activate, addr, state);
363 return;
364
365 case ODEBUG_STATE_DESTROYED:
366 debug_print_object(obj, "activate");
367 break;
368 default:
369 break;
370 }
371 spin_unlock_irqrestore(&db->lock, flags);
372 return;
373 }
374
375 spin_unlock_irqrestore(&db->lock, flags);
376 /*
377 * This happens when a static object is activated. We
378 * let the type specific code decide whether this is
379 * true or not.
380 */
381 debug_object_fixup(descr->fixup_activate, addr,
382 ODEBUG_STATE_NOTAVAILABLE);
383}
384
385/**
386 * debug_object_deactivate - debug checks when an object is deactivated
387 * @addr: address of the object
388 * @descr: pointer to an object specific debug description structure
389 */
390void debug_object_deactivate(void *addr, struct debug_obj_descr *descr)
391{
392 struct debug_bucket *db;
393 struct debug_obj *obj;
394 unsigned long flags;
395
396 if (!debug_objects_enabled)
397 return;
398
399 db = get_bucket((unsigned long) addr);
400
401 spin_lock_irqsave(&db->lock, flags);
402
403 obj = lookup_object(addr, db);
404 if (obj) {
405 switch (obj->state) {
406 case ODEBUG_STATE_INIT:
407 case ODEBUG_STATE_INACTIVE:
408 case ODEBUG_STATE_ACTIVE:
409 obj->state = ODEBUG_STATE_INACTIVE;
410 break;
411
412 case ODEBUG_STATE_DESTROYED:
413 debug_print_object(obj, "deactivate");
414 break;
415 default:
416 break;
417 }
418 } else {
419 struct debug_obj o = { .object = addr,
420 .state = ODEBUG_STATE_NOTAVAILABLE,
421 .descr = descr };
422
423 debug_print_object(&o, "deactivate");
424 }
425
426 spin_unlock_irqrestore(&db->lock, flags);
427}
428
429/**
430 * debug_object_destroy - debug checks when an object is destroyed
431 * @addr: address of the object
432 * @descr: pointer to an object specific debug description structure
433 */
434void debug_object_destroy(void *addr, struct debug_obj_descr *descr)
435{
436 enum debug_obj_state state;
437 struct debug_bucket *db;
438 struct debug_obj *obj;
439 unsigned long flags;
440
441 if (!debug_objects_enabled)
442 return;
443
444 db = get_bucket((unsigned long) addr);
445
446 spin_lock_irqsave(&db->lock, flags);
447
448 obj = lookup_object(addr, db);
449 if (!obj)
450 goto out_unlock;
451
452 switch (obj->state) {
453 case ODEBUG_STATE_NONE:
454 case ODEBUG_STATE_INIT:
455 case ODEBUG_STATE_INACTIVE:
456 obj->state = ODEBUG_STATE_DESTROYED;
457 break;
458 case ODEBUG_STATE_ACTIVE:
459 debug_print_object(obj, "destroy");
460 state = obj->state;
461 spin_unlock_irqrestore(&db->lock, flags);
462 debug_object_fixup(descr->fixup_destroy, addr, state);
463 return;
464
465 case ODEBUG_STATE_DESTROYED:
466 debug_print_object(obj, "destroy");
467 break;
468 default:
469 break;
470 }
471out_unlock:
472 spin_unlock_irqrestore(&db->lock, flags);
473}
474
475/**
476 * debug_object_free - debug checks when an object is freed
477 * @addr: address of the object
478 * @descr: pointer to an object specific debug description structure
479 */
480void debug_object_free(void *addr, struct debug_obj_descr *descr)
481{
482 enum debug_obj_state state;
483 struct debug_bucket *db;
484 struct debug_obj *obj;
485 unsigned long flags;
486
487 if (!debug_objects_enabled)
488 return;
489
490 db = get_bucket((unsigned long) addr);
491
492 spin_lock_irqsave(&db->lock, flags);
493
494 obj = lookup_object(addr, db);
495 if (!obj)
496 goto out_unlock;
497
498 switch (obj->state) {
499 case ODEBUG_STATE_ACTIVE:
500 debug_print_object(obj, "free");
501 state = obj->state;
502 spin_unlock_irqrestore(&db->lock, flags);
503 debug_object_fixup(descr->fixup_free, addr, state);
504 return;
505 default:
506 hlist_del(&obj->node);
507 free_object(obj);
508 break;
509 }
510out_unlock:
511 spin_unlock_irqrestore(&db->lock, flags);
512}
513
514#ifdef CONFIG_DEBUG_OBJECTS_FREE
515static void __debug_check_no_obj_freed(const void *address, unsigned long size)
516{
517 unsigned long flags, oaddr, saddr, eaddr, paddr, chunks;
518 struct hlist_node *node, *tmp;
519 struct debug_obj_descr *descr;
520 enum debug_obj_state state;
521 struct debug_bucket *db;
522 struct debug_obj *obj;
523 int cnt;
524
525 saddr = (unsigned long) address;
526 eaddr = saddr + size;
527 paddr = saddr & ODEBUG_CHUNK_MASK;
528 chunks = ((eaddr - paddr) + (ODEBUG_CHUNK_SIZE - 1));
529 chunks >>= ODEBUG_CHUNK_SHIFT;
530
531 for (;chunks > 0; chunks--, paddr += ODEBUG_CHUNK_SIZE) {
532 db = get_bucket(paddr);
533
534repeat:
535 cnt = 0;
536 spin_lock_irqsave(&db->lock, flags);
537 hlist_for_each_entry_safe(obj, node, tmp, &db->list, node) {
538 cnt++;
539 oaddr = (unsigned long) obj->object;
540 if (oaddr < saddr || oaddr >= eaddr)
541 continue;
542
543 switch (obj->state) {
544 case ODEBUG_STATE_ACTIVE:
545 debug_print_object(obj, "free");
546 descr = obj->descr;
547 state = obj->state;
548 spin_unlock_irqrestore(&db->lock, flags);
549 debug_object_fixup(descr->fixup_free,
550 (void *) oaddr, state);
551 goto repeat;
552 default:
553 hlist_del(&obj->node);
554 free_object(obj);
555 break;
556 }
557 }
558 spin_unlock_irqrestore(&db->lock, flags);
559 if (cnt > debug_objects_maxchain)
560 debug_objects_maxchain = cnt;
561 }
562}
563
564void debug_check_no_obj_freed(const void *address, unsigned long size)
565{
566 if (debug_objects_enabled)
567 __debug_check_no_obj_freed(address, size);
568}
569#endif
570
571#ifdef CONFIG_DEBUG_FS
572
573static int debug_stats_show(struct seq_file *m, void *v)
574{
575 seq_printf(m, "max_chain :%d\n", debug_objects_maxchain);
576 seq_printf(m, "warnings :%d\n", debug_objects_warnings);
577 seq_printf(m, "fixups :%d\n", debug_objects_fixups);
578 seq_printf(m, "pool_free :%d\n", obj_pool_free);
579 seq_printf(m, "pool_min_free :%d\n", obj_pool_min_free);
580 seq_printf(m, "pool_used :%d\n", obj_pool_used);
581 seq_printf(m, "pool_max_used :%d\n", obj_pool_max_used);
582 return 0;
583}
584
585static int debug_stats_open(struct inode *inode, struct file *filp)
586{
587 return single_open(filp, debug_stats_show, NULL);
588}
589
590static const struct file_operations debug_stats_fops = {
591 .open = debug_stats_open,
592 .read = seq_read,
593 .llseek = seq_lseek,
594 .release = single_release,
595};
596
597static int __init debug_objects_init_debugfs(void)
598{
599 struct dentry *dbgdir, *dbgstats;
600
601 if (!debug_objects_enabled)
602 return 0;
603
604 dbgdir = debugfs_create_dir("debug_objects", NULL);
605 if (!dbgdir)
606 return -ENOMEM;
607
608 dbgstats = debugfs_create_file("stats", 0444, dbgdir, NULL,
609 &debug_stats_fops);
610 if (!dbgstats)
611 goto err;
612
613 return 0;
614
615err:
616 debugfs_remove(dbgdir);
617
618 return -ENOMEM;
619}
620__initcall(debug_objects_init_debugfs);
621
622#else
623static inline void debug_objects_init_debugfs(void) { }
624#endif
625
626#ifdef CONFIG_DEBUG_OBJECTS_SELFTEST
627
628/* Random data structure for the self test */
629struct self_test {
630 unsigned long dummy1[6];
631 int static_init;
632 unsigned long dummy2[3];
633};
634
635static __initdata struct debug_obj_descr descr_type_test;
636
637/*
638 * fixup_init is called when:
639 * - an active object is initialized
640 */
641static int __init fixup_init(void *addr, enum debug_obj_state state)
642{
643 struct self_test *obj = addr;
644
645 switch (state) {
646 case ODEBUG_STATE_ACTIVE:
647 debug_object_deactivate(obj, &descr_type_test);
648 debug_object_init(obj, &descr_type_test);
649 return 1;
650 default:
651 return 0;
652 }
653}
654
655/*
656 * fixup_activate is called when:
657 * - an active object is activated
658 * - an unknown object is activated (might be a statically initialized object)
659 */
660static int __init fixup_activate(void *addr, enum debug_obj_state state)
661{
662 struct self_test *obj = addr;
663
664 switch (state) {
665 case ODEBUG_STATE_NOTAVAILABLE:
666 if (obj->static_init == 1) {
667 debug_object_init(obj, &descr_type_test);
668 debug_object_activate(obj, &descr_type_test);
669 /*
670 * Real code should return 0 here ! This is
671 * not a fixup of some bad behaviour. We
672 * merily call the debug_init function to keep
673 * track of the object.
674 */
675 return 1;
676 } else {
677 /* Real code needs to emit a warning here */
678 }
679 return 0;
680
681 case ODEBUG_STATE_ACTIVE:
682 debug_object_deactivate(obj, &descr_type_test);
683 debug_object_activate(obj, &descr_type_test);
684 return 1;
685
686 default:
687 return 0;
688 }
689}
690
691/*
692 * fixup_destroy is called when:
693 * - an active object is destroyed
694 */
695static int __init fixup_destroy(void *addr, enum debug_obj_state state)
696{
697 struct self_test *obj = addr;
698
699 switch (state) {
700 case ODEBUG_STATE_ACTIVE:
701 debug_object_deactivate(obj, &descr_type_test);
702 debug_object_destroy(obj, &descr_type_test);
703 return 1;
704 default:
705 return 0;
706 }
707}
708
709/*
710 * fixup_free is called when:
711 * - an active object is freed
712 */
713static int __init fixup_free(void *addr, enum debug_obj_state state)
714{
715 struct self_test *obj = addr;
716
717 switch (state) {
718 case ODEBUG_STATE_ACTIVE:
719 debug_object_deactivate(obj, &descr_type_test);
720 debug_object_free(obj, &descr_type_test);
721 return 1;
722 default:
723 return 0;
724 }
725}
726
727static int
728check_results(void *addr, enum debug_obj_state state, int fixups, int warnings)
729{
730 struct debug_bucket *db;
731 struct debug_obj *obj;
732 unsigned long flags;
733 int res = -EINVAL;
734
735 db = get_bucket((unsigned long) addr);
736
737 spin_lock_irqsave(&db->lock, flags);
738
739 obj = lookup_object(addr, db);
740 if (!obj && state != ODEBUG_STATE_NONE) {
741 printk(KERN_ERR "ODEBUG: selftest object not found\n");
742 WARN_ON(1);
743 goto out;
744 }
745 if (obj && obj->state != state) {
746 printk(KERN_ERR "ODEBUG: selftest wrong state: %d != %d\n",
747 obj->state, state);
748 WARN_ON(1);
749 goto out;
750 }
751 if (fixups != debug_objects_fixups) {
752 printk(KERN_ERR "ODEBUG: selftest fixups failed %d != %d\n",
753 fixups, debug_objects_fixups);
754 WARN_ON(1);
755 goto out;
756 }
757 if (warnings != debug_objects_warnings) {
758 printk(KERN_ERR "ODEBUG: selftest warnings failed %d != %d\n",
759 warnings, debug_objects_warnings);
760 WARN_ON(1);
761 goto out;
762 }
763 res = 0;
764out:
765 spin_unlock_irqrestore(&db->lock, flags);
766 if (res)
767 debug_objects_enabled = 0;
768 return res;
769}
770
771static __initdata struct debug_obj_descr descr_type_test = {
772 .name = "selftest",
773 .fixup_init = fixup_init,
774 .fixup_activate = fixup_activate,
775 .fixup_destroy = fixup_destroy,
776 .fixup_free = fixup_free,
777};
778
779static __initdata struct self_test obj = { .static_init = 0 };
780
781static void __init debug_objects_selftest(void)
782{
783 int fixups, oldfixups, warnings, oldwarnings;
784 unsigned long flags;
785
786 local_irq_save(flags);
787
788 fixups = oldfixups = debug_objects_fixups;
789 warnings = oldwarnings = debug_objects_warnings;
790 descr_test = &descr_type_test;
791
792 debug_object_init(&obj, &descr_type_test);
793 if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings))
794 goto out;
795 debug_object_activate(&obj, &descr_type_test);
796 if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings))
797 goto out;
798 debug_object_activate(&obj, &descr_type_test);
799 if (check_results(&obj, ODEBUG_STATE_ACTIVE, ++fixups, ++warnings))
800 goto out;
801 debug_object_deactivate(&obj, &descr_type_test);
802 if (check_results(&obj, ODEBUG_STATE_INACTIVE, fixups, warnings))
803 goto out;
804 debug_object_destroy(&obj, &descr_type_test);
805 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, warnings))
806 goto out;
807 debug_object_init(&obj, &descr_type_test);
808 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
809 goto out;
810 debug_object_activate(&obj, &descr_type_test);
811 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
812 goto out;
813 debug_object_deactivate(&obj, &descr_type_test);
814 if (check_results(&obj, ODEBUG_STATE_DESTROYED, fixups, ++warnings))
815 goto out;
816 debug_object_free(&obj, &descr_type_test);
817 if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings))
818 goto out;
819
820 obj.static_init = 1;
821 debug_object_activate(&obj, &descr_type_test);
822 if (check_results(&obj, ODEBUG_STATE_ACTIVE, ++fixups, warnings))
823 goto out;
824 debug_object_init(&obj, &descr_type_test);
825 if (check_results(&obj, ODEBUG_STATE_INIT, ++fixups, ++warnings))
826 goto out;
827 debug_object_free(&obj, &descr_type_test);
828 if (check_results(&obj, ODEBUG_STATE_NONE, fixups, warnings))
829 goto out;
830
831#ifdef CONFIG_DEBUG_OBJECTS_FREE
832 debug_object_init(&obj, &descr_type_test);
833 if (check_results(&obj, ODEBUG_STATE_INIT, fixups, warnings))
834 goto out;
835 debug_object_activate(&obj, &descr_type_test);
836 if (check_results(&obj, ODEBUG_STATE_ACTIVE, fixups, warnings))
837 goto out;
838 __debug_check_no_obj_freed(&obj, sizeof(obj));
839 if (check_results(&obj, ODEBUG_STATE_NONE, ++fixups, ++warnings))
840 goto out;
841#endif
842 printk(KERN_INFO "ODEBUG: selftest passed\n");
843
844out:
845 debug_objects_fixups = oldfixups;
846 debug_objects_warnings = oldwarnings;
847 descr_test = NULL;
848
849 local_irq_restore(flags);
850}
851#else
852static inline void debug_objects_selftest(void) { }
853#endif
854
855/*
856 * Called during early boot to initialize the hash buckets and link
857 * the static object pool objects into the poll list. After this call
858 * the object tracker is fully operational.
859 */
860void __init debug_objects_early_init(void)
861{
862 int i;
863
864 for (i = 0; i < ODEBUG_HASH_SIZE; i++)
865 spin_lock_init(&obj_hash[i].lock);
866
867 for (i = 0; i < ODEBUG_POOL_SIZE; i++)
868 hlist_add_head(&obj_static_pool[i].node, &obj_pool);
869}
870
871/*
872 * Called after the kmem_caches are functional to setup a dedicated
873 * cache pool, which has the SLAB_DEBUG_OBJECTS flag set. This flag
874 * prevents that the debug code is called on kmem_cache_free() for the
875 * debug tracker objects to avoid recursive calls.
876 */
877void __init debug_objects_mem_init(void)
878{
879 if (!debug_objects_enabled)
880 return;
881
882 obj_cache = kmem_cache_create("debug_objects_cache",
883 sizeof (struct debug_obj), 0,
884 SLAB_DEBUG_OBJECTS, NULL);
885
886 if (!obj_cache)
887 debug_objects_enabled = 0;
888 else
889 debug_objects_selftest();
890}
diff --git a/lib/kobject.c b/lib/kobject.c
index 2c6490370922..fd7874032163 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -90,7 +90,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
90 } 90 }
91 91
92 pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), 92 pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
93 kobj, __FUNCTION__, path); 93 kobj, __func__, path);
94} 94}
95 95
96/** 96/**
@@ -181,7 +181,7 @@ static int kobject_add_internal(struct kobject *kobj)
181 } 181 }
182 182
183 pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", 183 pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
184 kobject_name(kobj), kobj, __FUNCTION__, 184 kobject_name(kobj), kobj, __func__,
185 parent ? kobject_name(parent) : "<NULL>", 185 parent ? kobject_name(parent) : "<NULL>",
186 kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>"); 186 kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>");
187 187
@@ -196,10 +196,10 @@ static int kobject_add_internal(struct kobject *kobj)
196 printk(KERN_ERR "%s failed for %s with " 196 printk(KERN_ERR "%s failed for %s with "
197 "-EEXIST, don't try to register things with " 197 "-EEXIST, don't try to register things with "
198 "the same name in the same directory.\n", 198 "the same name in the same directory.\n",
199 __FUNCTION__, kobject_name(kobj)); 199 __func__, kobject_name(kobj));
200 else 200 else
201 printk(KERN_ERR "%s failed for %s (%d)\n", 201 printk(KERN_ERR "%s failed for %s (%d)\n",
202 __FUNCTION__, kobject_name(kobj), error); 202 __func__, kobject_name(kobj), error);
203 dump_stack(); 203 dump_stack();
204 } else 204 } else
205 kobj->state_in_sysfs = 1; 205 kobj->state_in_sysfs = 1;
@@ -540,7 +540,7 @@ static void kobject_cleanup(struct kobject *kobj)
540 const char *name = kobj->name; 540 const char *name = kobj->name;
541 541
542 pr_debug("kobject: '%s' (%p): %s\n", 542 pr_debug("kobject: '%s' (%p): %s\n",
543 kobject_name(kobj), kobj, __FUNCTION__); 543 kobject_name(kobj), kobj, __func__);
544 544
545 if (t && !t->release) 545 if (t && !t->release)
546 pr_debug("kobject: '%s' (%p): does not have a release() " 546 pr_debug("kobject: '%s' (%p): does not have a release() "
@@ -600,7 +600,7 @@ void kobject_put(struct kobject *kobj)
600 600
601static void dynamic_kobj_release(struct kobject *kobj) 601static void dynamic_kobj_release(struct kobject *kobj)
602{ 602{
603 pr_debug("kobject: (%p): %s\n", kobj, __FUNCTION__); 603 pr_debug("kobject: (%p): %s\n", kobj, __func__);
604 kfree(kobj); 604 kfree(kobj);
605} 605}
606 606
@@ -657,7 +657,7 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
657 retval = kobject_add(kobj, parent, "%s", name); 657 retval = kobject_add(kobj, parent, "%s", name);
658 if (retval) { 658 if (retval) {
659 printk(KERN_WARNING "%s: kobject_add error: %d\n", 659 printk(KERN_WARNING "%s: kobject_add error: %d\n",
660 __FUNCTION__, retval); 660 __func__, retval);
661 kobject_put(kobj); 661 kobject_put(kobj);
662 kobj = NULL; 662 kobj = NULL;
663 } 663 }
@@ -765,7 +765,7 @@ static void kset_release(struct kobject *kobj)
765{ 765{
766 struct kset *kset = container_of(kobj, struct kset, kobj); 766 struct kset *kset = container_of(kobj, struct kset, kobj);
767 pr_debug("kobject: '%s' (%p): %s\n", 767 pr_debug("kobject: '%s' (%p): %s\n",
768 kobject_name(kobj), kobj, __FUNCTION__); 768 kobject_name(kobj), kobj, __func__);
769 kfree(kset); 769 kfree(kset);
770} 770}
771 771
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 9fb6b86cf6b1..2fa545a63160 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -101,7 +101,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
101 int retval = 0; 101 int retval = 0;
102 102
103 pr_debug("kobject: '%s' (%p): %s\n", 103 pr_debug("kobject: '%s' (%p): %s\n",
104 kobject_name(kobj), kobj, __FUNCTION__); 104 kobject_name(kobj), kobj, __func__);
105 105
106 /* search the kset we belong to */ 106 /* search the kset we belong to */
107 top_kobj = kobj; 107 top_kobj = kobj;
@@ -111,7 +111,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
111 if (!top_kobj->kset) { 111 if (!top_kobj->kset) {
112 pr_debug("kobject: '%s' (%p): %s: attempted to send uevent " 112 pr_debug("kobject: '%s' (%p): %s: attempted to send uevent "
113 "without kset!\n", kobject_name(kobj), kobj, 113 "without kset!\n", kobject_name(kobj), kobj,
114 __FUNCTION__); 114 __func__);
115 return -EINVAL; 115 return -EINVAL;
116 } 116 }
117 117
@@ -123,7 +123,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
123 if (!uevent_ops->filter(kset, kobj)) { 123 if (!uevent_ops->filter(kset, kobj)) {
124 pr_debug("kobject: '%s' (%p): %s: filter function " 124 pr_debug("kobject: '%s' (%p): %s: filter function "
125 "caused the event to drop!\n", 125 "caused the event to drop!\n",
126 kobject_name(kobj), kobj, __FUNCTION__); 126 kobject_name(kobj), kobj, __func__);
127 return 0; 127 return 0;
128 } 128 }
129 129
@@ -135,7 +135,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
135 if (!subsystem) { 135 if (!subsystem) {
136 pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the " 136 pr_debug("kobject: '%s' (%p): %s: unset subsystem caused the "
137 "event to drop!\n", kobject_name(kobj), kobj, 137 "event to drop!\n", kobject_name(kobj), kobj,
138 __FUNCTION__); 138 __func__);
139 return 0; 139 return 0;
140 } 140 }
141 141
@@ -177,7 +177,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
177 if (retval) { 177 if (retval) {
178 pr_debug("kobject: '%s' (%p): %s: uevent() returned " 178 pr_debug("kobject: '%s' (%p): %s: uevent() returned "
179 "%d\n", kobject_name(kobj), kobj, 179 "%d\n", kobject_name(kobj), kobj,
180 __FUNCTION__, retval); 180 __func__, retval);
181 goto exit; 181 goto exit;
182 } 182 }
183 } 183 }
diff --git a/lib/percpu_counter.c b/lib/percpu_counter.c
index 393a0e915c23..119174494cb5 100644
--- a/lib/percpu_counter.c
+++ b/lib/percpu_counter.c
@@ -102,6 +102,7 @@ void percpu_counter_destroy(struct percpu_counter *fbc)
102 return; 102 return;
103 103
104 free_percpu(fbc->counters); 104 free_percpu(fbc->counters);
105 fbc->counters = NULL;
105#ifdef CONFIG_HOTPLUG_CPU 106#ifdef CONFIG_HOTPLUG_CPU
106 mutex_lock(&percpu_counters_lock); 107 mutex_lock(&percpu_counters_lock);
107 list_del(&fbc->list); 108 list_del(&fbc->list);
diff --git a/lib/proportions.c b/lib/proportions.c
index 9508d9a7af3e..4f387a643d72 100644
--- a/lib/proportions.c
+++ b/lib/proportions.c
@@ -73,12 +73,6 @@
73#include <linux/proportions.h> 73#include <linux/proportions.h>
74#include <linux/rcupdate.h> 74#include <linux/rcupdate.h>
75 75
76/*
77 * Limit the time part in order to ensure there are some bits left for the
78 * cycle counter.
79 */
80#define PROP_MAX_SHIFT (3*BITS_PER_LONG/4)
81
82int prop_descriptor_init(struct prop_descriptor *pd, int shift) 76int prop_descriptor_init(struct prop_descriptor *pd, int shift)
83{ 77{
84 int err; 78 int err;
@@ -268,6 +262,38 @@ void __prop_inc_percpu(struct prop_descriptor *pd, struct prop_local_percpu *pl)
268} 262}
269 263
270/* 264/*
265 * identical to __prop_inc_percpu, except that it limits this pl's fraction to
266 * @frac/PROP_FRAC_BASE by ignoring events when this limit has been exceeded.
267 */
268void __prop_inc_percpu_max(struct prop_descriptor *pd,
269 struct prop_local_percpu *pl, long frac)
270{
271 struct prop_global *pg = prop_get_global(pd);
272
273 prop_norm_percpu(pg, pl);
274
275 if (unlikely(frac != PROP_FRAC_BASE)) {
276 unsigned long period_2 = 1UL << (pg->shift - 1);
277 unsigned long counter_mask = period_2 - 1;
278 unsigned long global_count;
279 long numerator, denominator;
280
281 numerator = percpu_counter_read_positive(&pl->events);
282 global_count = percpu_counter_read(&pg->events);
283 denominator = period_2 + (global_count & counter_mask);
284
285 if (numerator > ((denominator * frac) >> PROP_FRAC_SHIFT))
286 goto out_put;
287 }
288
289 percpu_counter_add(&pl->events, 1);
290 percpu_counter_add(&pg->events, 1);
291
292out_put:
293 prop_put_global(pd, pg);
294}
295
296/*
271 * Obtain a fraction of this proportion 297 * Obtain a fraction of this proportion
272 * 298 *
273 * p_{j} = x_{j} / (period/2 + t % period/2) 299 * p_{j} = x_{j} / (period/2 + t % period/2)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index e8644b1e5527..7c4f9e097095 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -4,12 +4,229 @@
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/sched.h> 5#include <linux/sched.h>
6#include <linux/module.h> 6#include <linux/module.h>
7#include <linux/writeback.h>
8#include <linux/device.h>
9
10
11static struct class *bdi_class;
12
13#ifdef CONFIG_DEBUG_FS
14#include <linux/debugfs.h>
15#include <linux/seq_file.h>
16
17static struct dentry *bdi_debug_root;
18
19static void bdi_debug_init(void)
20{
21 bdi_debug_root = debugfs_create_dir("bdi", NULL);
22}
23
24static int bdi_debug_stats_show(struct seq_file *m, void *v)
25{
26 struct backing_dev_info *bdi = m->private;
27 long background_thresh;
28 long dirty_thresh;
29 long bdi_thresh;
30
31 get_dirty_limits(&background_thresh, &dirty_thresh, &bdi_thresh, bdi);
32
33#define K(x) ((x) << (PAGE_SHIFT - 10))
34 seq_printf(m,
35 "BdiWriteback: %8lu kB\n"
36 "BdiReclaimable: %8lu kB\n"
37 "BdiDirtyThresh: %8lu kB\n"
38 "DirtyThresh: %8lu kB\n"
39 "BackgroundThresh: %8lu kB\n",
40 (unsigned long) K(bdi_stat(bdi, BDI_WRITEBACK)),
41 (unsigned long) K(bdi_stat(bdi, BDI_RECLAIMABLE)),
42 K(bdi_thresh),
43 K(dirty_thresh),
44 K(background_thresh));
45#undef K
46
47 return 0;
48}
49
50static int bdi_debug_stats_open(struct inode *inode, struct file *file)
51{
52 return single_open(file, bdi_debug_stats_show, inode->i_private);
53}
54
55static const struct file_operations bdi_debug_stats_fops = {
56 .open = bdi_debug_stats_open,
57 .read = seq_read,
58 .llseek = seq_lseek,
59 .release = single_release,
60};
61
62static void bdi_debug_register(struct backing_dev_info *bdi, const char *name)
63{
64 bdi->debug_dir = debugfs_create_dir(name, bdi_debug_root);
65 bdi->debug_stats = debugfs_create_file("stats", 0444, bdi->debug_dir,
66 bdi, &bdi_debug_stats_fops);
67}
68
69static void bdi_debug_unregister(struct backing_dev_info *bdi)
70{
71 debugfs_remove(bdi->debug_stats);
72 debugfs_remove(bdi->debug_dir);
73}
74#else
75static inline void bdi_debug_init(void)
76{
77}
78static inline void bdi_debug_register(struct backing_dev_info *bdi,
79 const char *name)
80{
81}
82static inline void bdi_debug_unregister(struct backing_dev_info *bdi)
83{
84}
85#endif
86
87static ssize_t read_ahead_kb_store(struct device *dev,
88 struct device_attribute *attr,
89 const char *buf, size_t count)
90{
91 struct backing_dev_info *bdi = dev_get_drvdata(dev);
92 char *end;
93 unsigned long read_ahead_kb;
94 ssize_t ret = -EINVAL;
95
96 read_ahead_kb = simple_strtoul(buf, &end, 10);
97 if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
98 bdi->ra_pages = read_ahead_kb >> (PAGE_SHIFT - 10);
99 ret = count;
100 }
101 return ret;
102}
103
104#define K(pages) ((pages) << (PAGE_SHIFT - 10))
105
106#define BDI_SHOW(name, expr) \
107static ssize_t name##_show(struct device *dev, \
108 struct device_attribute *attr, char *page) \
109{ \
110 struct backing_dev_info *bdi = dev_get_drvdata(dev); \
111 \
112 return snprintf(page, PAGE_SIZE-1, "%lld\n", (long long)expr); \
113}
114
115BDI_SHOW(read_ahead_kb, K(bdi->ra_pages))
116
117static ssize_t min_ratio_store(struct device *dev,
118 struct device_attribute *attr, const char *buf, size_t count)
119{
120 struct backing_dev_info *bdi = dev_get_drvdata(dev);
121 char *end;
122 unsigned int ratio;
123 ssize_t ret = -EINVAL;
124
125 ratio = simple_strtoul(buf, &end, 10);
126 if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
127 ret = bdi_set_min_ratio(bdi, ratio);
128 if (!ret)
129 ret = count;
130 }
131 return ret;
132}
133BDI_SHOW(min_ratio, bdi->min_ratio)
134
135static ssize_t max_ratio_store(struct device *dev,
136 struct device_attribute *attr, const char *buf, size_t count)
137{
138 struct backing_dev_info *bdi = dev_get_drvdata(dev);
139 char *end;
140 unsigned int ratio;
141 ssize_t ret = -EINVAL;
142
143 ratio = simple_strtoul(buf, &end, 10);
144 if (*buf && (end[0] == '\0' || (end[0] == '\n' && end[1] == '\0'))) {
145 ret = bdi_set_max_ratio(bdi, ratio);
146 if (!ret)
147 ret = count;
148 }
149 return ret;
150}
151BDI_SHOW(max_ratio, bdi->max_ratio)
152
153#define __ATTR_RW(attr) __ATTR(attr, 0644, attr##_show, attr##_store)
154
155static struct device_attribute bdi_dev_attrs[] = {
156 __ATTR_RW(read_ahead_kb),
157 __ATTR_RW(min_ratio),
158 __ATTR_RW(max_ratio),
159 __ATTR_NULL,
160};
161
162static __init int bdi_class_init(void)
163{
164 bdi_class = class_create(THIS_MODULE, "bdi");
165 bdi_class->dev_attrs = bdi_dev_attrs;
166 bdi_debug_init();
167 return 0;
168}
169
170postcore_initcall(bdi_class_init);
171
172int bdi_register(struct backing_dev_info *bdi, struct device *parent,
173 const char *fmt, ...)
174{
175 char *name;
176 va_list args;
177 int ret = 0;
178 struct device *dev;
179
180 va_start(args, fmt);
181 name = kvasprintf(GFP_KERNEL, fmt, args);
182 va_end(args);
183
184 if (!name)
185 return -ENOMEM;
186
187 dev = device_create(bdi_class, parent, MKDEV(0, 0), name);
188 if (IS_ERR(dev)) {
189 ret = PTR_ERR(dev);
190 goto exit;
191 }
192
193 bdi->dev = dev;
194 dev_set_drvdata(bdi->dev, bdi);
195 bdi_debug_register(bdi, name);
196
197exit:
198 kfree(name);
199 return ret;
200}
201EXPORT_SYMBOL(bdi_register);
202
203int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev)
204{
205 return bdi_register(bdi, NULL, "%u:%u", MAJOR(dev), MINOR(dev));
206}
207EXPORT_SYMBOL(bdi_register_dev);
208
209void bdi_unregister(struct backing_dev_info *bdi)
210{
211 if (bdi->dev) {
212 bdi_debug_unregister(bdi);
213 device_unregister(bdi->dev);
214 bdi->dev = NULL;
215 }
216}
217EXPORT_SYMBOL(bdi_unregister);
7 218
8int bdi_init(struct backing_dev_info *bdi) 219int bdi_init(struct backing_dev_info *bdi)
9{ 220{
10 int i; 221 int i;
11 int err; 222 int err;
12 223
224 bdi->dev = NULL;
225
226 bdi->min_ratio = 0;
227 bdi->max_ratio = 100;
228 bdi->max_prop_frac = PROP_FRAC_BASE;
229
13 for (i = 0; i < NR_BDI_STAT_ITEMS; i++) { 230 for (i = 0; i < NR_BDI_STAT_ITEMS; i++) {
14 err = percpu_counter_init_irq(&bdi->bdi_stat[i], 0); 231 err = percpu_counter_init_irq(&bdi->bdi_stat[i], 0);
15 if (err) 232 if (err)
@@ -33,6 +250,8 @@ void bdi_destroy(struct backing_dev_info *bdi)
33{ 250{
34 int i; 251 int i;
35 252
253 bdi_unregister(bdi);
254
36 for (i = 0; i < NR_BDI_STAT_ITEMS; i++) 255 for (i = 0; i < NR_BDI_STAT_ITEMS; i++)
37 percpu_counter_destroy(&bdi->bdi_stat[i]); 256 percpu_counter_destroy(&bdi->bdi_stat[i]);
38 257
diff --git a/mm/migrate.c b/mm/migrate.c
index 4e0eccca5e26..449d77d409f5 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -383,7 +383,14 @@ static void migrate_page_copy(struct page *newpage, struct page *page)
383 383
384 if (PageDirty(page)) { 384 if (PageDirty(page)) {
385 clear_page_dirty_for_io(page); 385 clear_page_dirty_for_io(page);
386 set_page_dirty(newpage); 386 /*
387 * Want to mark the page and the radix tree as dirty, and
388 * redo the accounting that clear_page_dirty_for_io undid,
389 * but we can't use set_page_dirty because that function
390 * is actually a signal that all of the page has become dirty.
391 * Wheras only part of our page may be dirty.
392 */
393 __set_page_dirty_nobuffers(newpage);
387 } 394 }
388 395
389#ifdef CONFIG_SWAP 396#ifdef CONFIG_SWAP
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 5e00f1772c20..789b6adbef37 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -164,9 +164,20 @@ int dirty_ratio_handler(struct ctl_table *table, int write,
164 */ 164 */
165static inline void __bdi_writeout_inc(struct backing_dev_info *bdi) 165static inline void __bdi_writeout_inc(struct backing_dev_info *bdi)
166{ 166{
167 __prop_inc_percpu(&vm_completions, &bdi->completions); 167 __prop_inc_percpu_max(&vm_completions, &bdi->completions,
168 bdi->max_prop_frac);
168} 169}
169 170
171void bdi_writeout_inc(struct backing_dev_info *bdi)
172{
173 unsigned long flags;
174
175 local_irq_save(flags);
176 __bdi_writeout_inc(bdi);
177 local_irq_restore(flags);
178}
179EXPORT_SYMBOL_GPL(bdi_writeout_inc);
180
170static inline void task_dirty_inc(struct task_struct *tsk) 181static inline void task_dirty_inc(struct task_struct *tsk)
171{ 182{
172 prop_inc_single(&vm_dirties, &tsk->dirties); 183 prop_inc_single(&vm_dirties, &tsk->dirties);
@@ -200,7 +211,8 @@ clip_bdi_dirty_limit(struct backing_dev_info *bdi, long dirty, long *pbdi_dirty)
200 avail_dirty = dirty - 211 avail_dirty = dirty -
201 (global_page_state(NR_FILE_DIRTY) + 212 (global_page_state(NR_FILE_DIRTY) +
202 global_page_state(NR_WRITEBACK) + 213 global_page_state(NR_WRITEBACK) +
203 global_page_state(NR_UNSTABLE_NFS)); 214 global_page_state(NR_UNSTABLE_NFS) +
215 global_page_state(NR_WRITEBACK_TEMP));
204 216
205 if (avail_dirty < 0) 217 if (avail_dirty < 0)
206 avail_dirty = 0; 218 avail_dirty = 0;
@@ -243,6 +255,55 @@ static void task_dirty_limit(struct task_struct *tsk, long *pdirty)
243} 255}
244 256
245/* 257/*
258 *
259 */
260static DEFINE_SPINLOCK(bdi_lock);
261static unsigned int bdi_min_ratio;
262
263int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio)
264{
265 int ret = 0;
266 unsigned long flags;
267
268 spin_lock_irqsave(&bdi_lock, flags);
269 if (min_ratio > bdi->max_ratio) {
270 ret = -EINVAL;
271 } else {
272 min_ratio -= bdi->min_ratio;
273 if (bdi_min_ratio + min_ratio < 100) {
274 bdi_min_ratio += min_ratio;
275 bdi->min_ratio += min_ratio;
276 } else {
277 ret = -EINVAL;
278 }
279 }
280 spin_unlock_irqrestore(&bdi_lock, flags);
281
282 return ret;
283}
284
285int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio)
286{
287 unsigned long flags;
288 int ret = 0;
289
290 if (max_ratio > 100)
291 return -EINVAL;
292
293 spin_lock_irqsave(&bdi_lock, flags);
294 if (bdi->min_ratio > max_ratio) {
295 ret = -EINVAL;
296 } else {
297 bdi->max_ratio = max_ratio;
298 bdi->max_prop_frac = (PROP_FRAC_BASE * max_ratio) / 100;
299 }
300 spin_unlock_irqrestore(&bdi_lock, flags);
301
302 return ret;
303}
304EXPORT_SYMBOL(bdi_set_max_ratio);
305
306/*
246 * Work out the current dirty-memory clamping and background writeout 307 * Work out the current dirty-memory clamping and background writeout
247 * thresholds. 308 * thresholds.
248 * 309 *
@@ -300,7 +361,7 @@ static unsigned long determine_dirtyable_memory(void)
300 return x + 1; /* Ensure that we never return 0 */ 361 return x + 1; /* Ensure that we never return 0 */
301} 362}
302 363
303static void 364void
304get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty, 365get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
305 struct backing_dev_info *bdi) 366 struct backing_dev_info *bdi)
306{ 367{
@@ -330,7 +391,7 @@ get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
330 *pdirty = dirty; 391 *pdirty = dirty;
331 392
332 if (bdi) { 393 if (bdi) {
333 u64 bdi_dirty = dirty; 394 u64 bdi_dirty;
334 long numerator, denominator; 395 long numerator, denominator;
335 396
336 /* 397 /*
@@ -338,8 +399,12 @@ get_dirty_limits(long *pbackground, long *pdirty, long *pbdi_dirty,
338 */ 399 */
339 bdi_writeout_fraction(bdi, &numerator, &denominator); 400 bdi_writeout_fraction(bdi, &numerator, &denominator);
340 401
402 bdi_dirty = (dirty * (100 - bdi_min_ratio)) / 100;
341 bdi_dirty *= numerator; 403 bdi_dirty *= numerator;
342 do_div(bdi_dirty, denominator); 404 do_div(bdi_dirty, denominator);
405 bdi_dirty += (dirty * bdi->min_ratio) / 100;
406 if (bdi_dirty > (dirty * bdi->max_ratio) / 100)
407 bdi_dirty = dirty * bdi->max_ratio / 100;
343 408
344 *pbdi_dirty = bdi_dirty; 409 *pbdi_dirty = bdi_dirty;
345 clip_bdi_dirty_limit(bdi, dirty, pbdi_dirty); 410 clip_bdi_dirty_limit(bdi, dirty, pbdi_dirty);
@@ -1192,7 +1257,7 @@ int test_clear_page_writeback(struct page *page)
1192 radix_tree_tag_clear(&mapping->page_tree, 1257 radix_tree_tag_clear(&mapping->page_tree,
1193 page_index(page), 1258 page_index(page),
1194 PAGECACHE_TAG_WRITEBACK); 1259 PAGECACHE_TAG_WRITEBACK);
1195 if (bdi_cap_writeback_dirty(bdi)) { 1260 if (bdi_cap_account_writeback(bdi)) {
1196 __dec_bdi_stat(bdi, BDI_WRITEBACK); 1261 __dec_bdi_stat(bdi, BDI_WRITEBACK);
1197 __bdi_writeout_inc(bdi); 1262 __bdi_writeout_inc(bdi);
1198 } 1263 }
@@ -1221,7 +1286,7 @@ int test_set_page_writeback(struct page *page)
1221 radix_tree_tag_set(&mapping->page_tree, 1286 radix_tree_tag_set(&mapping->page_tree,
1222 page_index(page), 1287 page_index(page),
1223 PAGECACHE_TAG_WRITEBACK); 1288 PAGECACHE_TAG_WRITEBACK);
1224 if (bdi_cap_writeback_dirty(bdi)) 1289 if (bdi_cap_account_writeback(bdi))
1225 __inc_bdi_stat(bdi, BDI_WRITEBACK); 1290 __inc_bdi_stat(bdi, BDI_WRITEBACK);
1226 } 1291 }
1227 if (!PageDirty(page)) 1292 if (!PageDirty(page))
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 0a502e99ee22..bdd5c432c426 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -45,6 +45,7 @@
45#include <linux/fault-inject.h> 45#include <linux/fault-inject.h>
46#include <linux/page-isolation.h> 46#include <linux/page-isolation.h>
47#include <linux/memcontrol.h> 47#include <linux/memcontrol.h>
48#include <linux/debugobjects.h>
48 49
49#include <asm/tlbflush.h> 50#include <asm/tlbflush.h>
50#include <asm/div64.h> 51#include <asm/div64.h>
@@ -532,8 +533,11 @@ static void __free_pages_ok(struct page *page, unsigned int order)
532 if (reserved) 533 if (reserved)
533 return; 534 return;
534 535
535 if (!PageHighMem(page)) 536 if (!PageHighMem(page)) {
536 debug_check_no_locks_freed(page_address(page),PAGE_SIZE<<order); 537 debug_check_no_locks_freed(page_address(page),PAGE_SIZE<<order);
538 debug_check_no_obj_freed(page_address(page),
539 PAGE_SIZE << order);
540 }
537 arch_free_page(page, order); 541 arch_free_page(page, order);
538 kernel_map_pages(page, 1 << order, 0); 542 kernel_map_pages(page, 1 << order, 0);
539 543
@@ -995,8 +999,10 @@ static void free_hot_cold_page(struct page *page, int cold)
995 if (free_pages_check(page)) 999 if (free_pages_check(page))
996 return; 1000 return;
997 1001
998 if (!PageHighMem(page)) 1002 if (!PageHighMem(page)) {
999 debug_check_no_locks_freed(page_address(page), PAGE_SIZE); 1003 debug_check_no_locks_freed(page_address(page), PAGE_SIZE);
1004 debug_check_no_obj_freed(page_address(page), PAGE_SIZE);
1005 }
1000 arch_free_page(page, 0); 1006 arch_free_page(page, 0);
1001 kernel_map_pages(page, 1, 0); 1007 kernel_map_pages(page, 1, 0);
1002 1008
diff --git a/mm/readahead.c b/mm/readahead.c
index 8762e8988972..d8723a5f6496 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -235,7 +235,13 @@ unsigned long max_sane_readahead(unsigned long nr)
235 235
236static int __init readahead_init(void) 236static int __init readahead_init(void)
237{ 237{
238 return bdi_init(&default_backing_dev_info); 238 int err;
239
240 err = bdi_init(&default_backing_dev_info);
241 if (!err)
242 bdi_register(&default_backing_dev_info, NULL, "default");
243
244 return err;
239} 245}
240subsys_initcall(readahead_init); 246subsys_initcall(readahead_init);
241 247
diff --git a/mm/shmem.c b/mm/shmem.c
index e6d9298aa22a..e2a6ae1a44e9 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -201,7 +201,7 @@ static struct vm_operations_struct shmem_vm_ops;
201 201
202static struct backing_dev_info shmem_backing_dev_info __read_mostly = { 202static struct backing_dev_info shmem_backing_dev_info __read_mostly = {
203 .ra_pages = 0, /* No readahead */ 203 .ra_pages = 0, /* No readahead */
204 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 204 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
205 .unplug_io_fn = default_unplug_io_fn, 205 .unplug_io_fn = default_unplug_io_fn,
206}; 206};
207 207
diff --git a/mm/slab.c b/mm/slab.c
index 39d20f8a0791..06236e4ddc1b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -110,6 +110,7 @@
110#include <linux/fault-inject.h> 110#include <linux/fault-inject.h>
111#include <linux/rtmutex.h> 111#include <linux/rtmutex.h>
112#include <linux/reciprocal_div.h> 112#include <linux/reciprocal_div.h>
113#include <linux/debugobjects.h>
113 114
114#include <asm/cacheflush.h> 115#include <asm/cacheflush.h>
115#include <asm/tlbflush.h> 116#include <asm/tlbflush.h>
@@ -174,12 +175,14 @@
174 SLAB_CACHE_DMA | \ 175 SLAB_CACHE_DMA | \
175 SLAB_STORE_USER | \ 176 SLAB_STORE_USER | \
176 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ 177 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
177 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD) 178 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
179 SLAB_DEBUG_OBJECTS)
178#else 180#else
179# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \ 181# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \
180 SLAB_CACHE_DMA | \ 182 SLAB_CACHE_DMA | \
181 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \ 183 SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
182 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD) 184 SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD | \
185 SLAB_DEBUG_OBJECTS)
183#endif 186#endif
184 187
185/* 188/*
@@ -858,7 +861,7 @@ static void cache_estimate(unsigned long gfporder, size_t buffer_size,
858 *left_over = slab_size - nr_objs*buffer_size - mgmt_size; 861 *left_over = slab_size - nr_objs*buffer_size - mgmt_size;
859} 862}
860 863
861#define slab_error(cachep, msg) __slab_error(__FUNCTION__, cachep, msg) 864#define slab_error(cachep, msg) __slab_error(__func__, cachep, msg)
862 865
863static void __slab_error(const char *function, struct kmem_cache *cachep, 866static void __slab_error(const char *function, struct kmem_cache *cachep,
864 char *msg) 867 char *msg)
@@ -2153,7 +2156,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2153 */ 2156 */
2154 if (!name || in_interrupt() || (size < BYTES_PER_WORD) || 2157 if (!name || in_interrupt() || (size < BYTES_PER_WORD) ||
2155 size > KMALLOC_MAX_SIZE) { 2158 size > KMALLOC_MAX_SIZE) {
2156 printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__, 2159 printk(KERN_ERR "%s: Early error in slab %s\n", __func__,
2157 name); 2160 name);
2158 BUG(); 2161 BUG();
2159 } 2162 }
@@ -3760,6 +3763,8 @@ void kmem_cache_free(struct kmem_cache *cachep, void *objp)
3760 3763
3761 local_irq_save(flags); 3764 local_irq_save(flags);
3762 debug_check_no_locks_freed(objp, obj_size(cachep)); 3765 debug_check_no_locks_freed(objp, obj_size(cachep));
3766 if (!(cachep->flags & SLAB_DEBUG_OBJECTS))
3767 debug_check_no_obj_freed(objp, obj_size(cachep));
3763 __cache_free(cachep, objp); 3768 __cache_free(cachep, objp);
3764 local_irq_restore(flags); 3769 local_irq_restore(flags);
3765} 3770}
@@ -3785,6 +3790,7 @@ void kfree(const void *objp)
3785 kfree_debugcheck(objp); 3790 kfree_debugcheck(objp);
3786 c = virt_to_cache(objp); 3791 c = virt_to_cache(objp);
3787 debug_check_no_locks_freed(objp, obj_size(c)); 3792 debug_check_no_locks_freed(objp, obj_size(c));
3793 debug_check_no_obj_freed(objp, obj_size(c));
3788 __cache_free(c, (void *)objp); 3794 __cache_free(c, (void *)objp);
3789 local_irq_restore(flags); 3795 local_irq_restore(flags);
3790} 3796}
diff --git a/mm/slub.c b/mm/slub.c
index b145e798bf3d..70db2897c1ea 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -19,6 +19,7 @@
19#include <linux/cpuset.h> 19#include <linux/cpuset.h>
20#include <linux/mempolicy.h> 20#include <linux/mempolicy.h>
21#include <linux/ctype.h> 21#include <linux/ctype.h>
22#include <linux/debugobjects.h>
22#include <linux/kallsyms.h> 23#include <linux/kallsyms.h>
23#include <linux/memory.h> 24#include <linux/memory.h>
24 25
@@ -1747,6 +1748,8 @@ static __always_inline void slab_free(struct kmem_cache *s,
1747 local_irq_save(flags); 1748 local_irq_save(flags);
1748 c = get_cpu_slab(s, smp_processor_id()); 1749 c = get_cpu_slab(s, smp_processor_id());
1749 debug_check_no_locks_freed(object, c->objsize); 1750 debug_check_no_locks_freed(object, c->objsize);
1751 if (!(s->flags & SLAB_DEBUG_OBJECTS))
1752 debug_check_no_obj_freed(object, s->objsize);
1750 if (likely(page == c->page && c->node >= 0)) { 1753 if (likely(page == c->page && c->node >= 0)) {
1751 object[c->offset] = c->freelist; 1754 object[c->offset] = c->freelist;
1752 c->freelist = object; 1755 c->freelist = object;
diff --git a/mm/sparse.c b/mm/sparse.c
index dff71f173ae9..36511c7b5e2c 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -250,29 +250,18 @@ static unsigned long *__kmalloc_section_usemap(void)
250 250
251static unsigned long *__init sparse_early_usemap_alloc(unsigned long pnum) 251static unsigned long *__init sparse_early_usemap_alloc(unsigned long pnum)
252{ 252{
253 unsigned long *usemap, section_nr; 253 unsigned long *usemap;
254 struct mem_section *ms = __nr_to_section(pnum); 254 struct mem_section *ms = __nr_to_section(pnum);
255 int nid = sparse_early_nid(ms); 255 int nid = sparse_early_nid(ms);
256 struct pglist_data *pgdat = NODE_DATA(nid);
257 256
258 /* 257 usemap = alloc_bootmem_node(NODE_DATA(nid), usemap_size());
259 * Usemap's page can't be freed until freeing other sections
260 * which use it. And, Pgdat has same feature.
261 * If section A has pgdat and section B has usemap for other
262 * sections (includes section A), both sections can't be removed,
263 * because there is the dependency each other.
264 * To solve above issue, this collects all usemap on the same section
265 * which has pgdat.
266 */
267 section_nr = pfn_to_section_nr(__pa(pgdat) >> PAGE_SHIFT);
268 usemap = alloc_bootmem_section(usemap_size(), section_nr);
269 if (usemap) 258 if (usemap)
270 return usemap; 259 return usemap;
271 260
272 /* Stupid: suppress gcc warning for SPARSEMEM && !NUMA */ 261 /* Stupid: suppress gcc warning for SPARSEMEM && !NUMA */
273 nid = 0; 262 nid = 0;
274 263
275 printk(KERN_WARNING "%s: allocation failed\n", __FUNCTION__); 264 printk(KERN_WARNING "%s: allocation failed\n", __func__);
276 return NULL; 265 return NULL;
277} 266}
278 267
@@ -302,7 +291,7 @@ struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)
302 return map; 291 return map;
303 292
304 printk(KERN_ERR "%s: sparsemem memory map backing failed " 293 printk(KERN_ERR "%s: sparsemem memory map backing failed "
305 "some memory will not be available.\n", __FUNCTION__); 294 "some memory will not be available.\n", __func__);
306 ms->section_mem_map = 0; 295 ms->section_mem_map = 0;
307 return NULL; 296 return NULL;
308} 297}
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 50757ee3f9f3..d8aadaf2a0ba 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -33,7 +33,7 @@ static const struct address_space_operations swap_aops = {
33}; 33};
34 34
35static struct backing_dev_info swap_backing_dev_info = { 35static struct backing_dev_info swap_backing_dev_info = {
36 .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK, 36 .capabilities = BDI_CAP_NO_ACCT_AND_WRITEBACK,
37 .unplug_io_fn = swap_unplug_io_fn, 37 .unplug_io_fn = swap_unplug_io_fn,
38}; 38};
39 39
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index e33e0ae69ad1..2a39cf128aba 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -15,6 +15,7 @@
15#include <linux/spinlock.h> 15#include <linux/spinlock.h>
16#include <linux/interrupt.h> 16#include <linux/interrupt.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/debugobjects.h>
18#include <linux/vmalloc.h> 19#include <linux/vmalloc.h>
19#include <linux/kallsyms.h> 20#include <linux/kallsyms.h>
20 21
@@ -394,6 +395,7 @@ static void __vunmap(const void *addr, int deallocate_pages)
394 } 395 }
395 396
396 debug_check_no_locks_freed(addr, area->size); 397 debug_check_no_locks_freed(addr, area->size);
398 debug_check_no_obj_freed(addr, area->size);
397 399
398 if (deallocate_pages) { 400 if (deallocate_pages) {
399 int i; 401 int i;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 12e8627c9747..9a29901ad3b3 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -191,7 +191,7 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
191 shrinker->nr += delta; 191 shrinker->nr += delta;
192 if (shrinker->nr < 0) { 192 if (shrinker->nr < 0) {
193 printk(KERN_ERR "%s: nr=%ld\n", 193 printk(KERN_ERR "%s: nr=%ld\n",
194 __FUNCTION__, shrinker->nr); 194 __func__, shrinker->nr);
195 shrinker->nr = max_pass; 195 shrinker->nr = max_pass;
196 } 196 }
197 197
@@ -339,7 +339,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping,
339 if (PagePrivate(page)) { 339 if (PagePrivate(page)) {
340 if (try_to_free_buffers(page)) { 340 if (try_to_free_buffers(page)) {
341 ClearPageDirty(page); 341 ClearPageDirty(page);
342 printk("%s: orphaned page\n", __FUNCTION__); 342 printk("%s: orphaned page\n", __func__);
343 return PAGE_CLEAN; 343 return PAGE_CLEAN;
344 } 344 }
345 } 345 }
diff --git a/mm/vmstat.c b/mm/vmstat.c
index ec6035eda933..1a32130b958c 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -548,6 +548,10 @@ static int pagetypeinfo_show(struct seq_file *m, void *arg)
548{ 548{
549 pg_data_t *pgdat = (pg_data_t *)arg; 549 pg_data_t *pgdat = (pg_data_t *)arg;
550 550
551 /* check memoryless node */
552 if (!node_state(pgdat->node_id, N_HIGH_MEMORY))
553 return 0;
554
551 seq_printf(m, "Page block order: %d\n", pageblock_order); 555 seq_printf(m, "Page block order: %d\n", pageblock_order);
552 seq_printf(m, "Pages per block: %lu\n", pageblock_nr_pages); 556 seq_printf(m, "Pages per block: %lu\n", pageblock_nr_pages);
553 seq_putc(m, '\n'); 557 seq_putc(m, '\n');
@@ -608,6 +612,7 @@ static const char * const vmstat_text[] = {
608 "nr_unstable", 612 "nr_unstable",
609 "nr_bounce", 613 "nr_bounce",
610 "nr_vmscan_write", 614 "nr_vmscan_write",
615 "nr_writeback_temp",
611 616
612#ifdef CONFIG_NUMA 617#ifdef CONFIG_NUMA
613 "numa_hit", 618 "numa_hit",
diff --git a/net/bridge/br.c b/net/bridge/br.c
index a90182873120..8f3c58e5f7a5 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -76,7 +76,6 @@ static void __exit br_deinit(void)
76 rcu_assign_pointer(br_stp_sap->rcv_func, NULL); 76 rcu_assign_pointer(br_stp_sap->rcv_func, NULL);
77 77
78 br_netlink_fini(); 78 br_netlink_fini();
79 br_netfilter_fini();
80 unregister_netdevice_notifier(&br_device_notifier); 79 unregister_netdevice_notifier(&br_device_notifier);
81 brioctl_set(NULL); 80 brioctl_set(NULL);
82 81
@@ -84,6 +83,7 @@ static void __exit br_deinit(void)
84 83
85 synchronize_net(); 84 synchronize_net();
86 85
86 br_netfilter_fini();
87 llc_sap_put(br_stp_sap); 87 llc_sap_put(br_stp_sap);
88 br_fdb_get_hook = NULL; 88 br_fdb_get_hook = NULL;
89 br_fdb_put_hook = NULL; 89 br_fdb_put_hook = NULL;
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 298e0f463c56..77a981a1ee52 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -411,9 +411,12 @@ err2:
411 br_fdb_delete_by_port(br, p, 1); 411 br_fdb_delete_by_port(br, p, 1);
412err1: 412err1:
413 kobject_del(&p->kobj); 413 kobject_del(&p->kobj);
414 return err; 414 goto put_back;
415err0: 415err0:
416 kobject_put(&p->kobj); 416 kobject_put(&p->kobj);
417
418put_back:
419 dev_put(dev);
417 return err; 420 return err;
418} 421}
419 422
diff --git a/net/compat.c b/net/compat.c
index 01bf95d0832e..c823f6f290cb 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -548,6 +548,9 @@ struct compat_group_filter {
548 __attribute__ ((aligned(4))); 548 __attribute__ ((aligned(4)));
549} __attribute__ ((packed)); 549} __attribute__ ((packed));
550 550
551#define __COMPAT_GF0_SIZE (sizeof(struct compat_group_filter) - \
552 sizeof(struct __kernel_sockaddr_storage))
553
551 554
552int compat_mc_setsockopt(struct sock *sock, int level, int optname, 555int compat_mc_setsockopt(struct sock *sock, int level, int optname,
553 char __user *optval, int optlen, 556 char __user *optval, int optlen,
@@ -582,7 +585,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
582 case MCAST_UNBLOCK_SOURCE: 585 case MCAST_UNBLOCK_SOURCE:
583 { 586 {
584 struct compat_group_source_req __user *gsr32 = (void *)optval; 587 struct compat_group_source_req __user *gsr32 = (void *)optval;
585 struct group_source_req *kgsr = compat_alloc_user_space( 588 struct group_source_req __user *kgsr = compat_alloc_user_space(
586 sizeof(struct group_source_req)); 589 sizeof(struct group_source_req));
587 u32 interface; 590 u32 interface;
588 591
@@ -603,10 +606,10 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
603 case MCAST_MSFILTER: 606 case MCAST_MSFILTER:
604 { 607 {
605 struct compat_group_filter __user *gf32 = (void *)optval; 608 struct compat_group_filter __user *gf32 = (void *)optval;
606 struct group_filter *kgf; 609 struct group_filter __user *kgf;
607 u32 interface, fmode, numsrc; 610 u32 interface, fmode, numsrc;
608 611
609 if (!access_ok(VERIFY_READ, gf32, sizeof(*gf32)) || 612 if (!access_ok(VERIFY_READ, gf32, __COMPAT_GF0_SIZE) ||
610 __get_user(interface, &gf32->gf_interface) || 613 __get_user(interface, &gf32->gf_interface) ||
611 __get_user(fmode, &gf32->gf_fmode) || 614 __get_user(fmode, &gf32->gf_fmode) ||
612 __get_user(numsrc, &gf32->gf_numsrc)) 615 __get_user(numsrc, &gf32->gf_numsrc))
@@ -622,7 +625,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
622 __put_user(numsrc, &kgf->gf_numsrc) || 625 __put_user(numsrc, &kgf->gf_numsrc) ||
623 copy_in_user(&kgf->gf_group, &gf32->gf_group, 626 copy_in_user(&kgf->gf_group, &gf32->gf_group,
624 sizeof(kgf->gf_group)) || 627 sizeof(kgf->gf_group)) ||
625 (numsrc && copy_in_user(&kgf->gf_slist, &gf32->gf_slist, 628 (numsrc && copy_in_user(kgf->gf_slist, gf32->gf_slist,
626 numsrc * sizeof(kgf->gf_slist[0])))) 629 numsrc * sizeof(kgf->gf_slist[0]))))
627 return -EFAULT; 630 return -EFAULT;
628 koptval = (char __user *)kgf; 631 koptval = (char __user *)kgf;
@@ -637,6 +640,85 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
637 640
638EXPORT_SYMBOL(compat_mc_setsockopt); 641EXPORT_SYMBOL(compat_mc_setsockopt);
639 642
643int compat_mc_getsockopt(struct sock *sock, int level, int optname,
644 char __user *optval, int __user *optlen,
645 int (*getsockopt)(struct sock *,int,int,char __user *,int __user *))
646{
647 struct compat_group_filter __user *gf32 = (void *)optval;
648 struct group_filter __user *kgf;
649 int __user *koptlen;
650 u32 interface, fmode, numsrc;
651 int klen, ulen, err;
652
653 if (optname != MCAST_MSFILTER)
654 return getsockopt(sock, level, optname, optval, optlen);
655
656 koptlen = compat_alloc_user_space(sizeof(*koptlen));
657 if (!access_ok(VERIFY_READ, optlen, sizeof(*optlen)) ||
658 __get_user(ulen, optlen))
659 return -EFAULT;
660
661 /* adjust len for pad */
662 klen = ulen + sizeof(*kgf) - sizeof(*gf32);
663
664 if (klen < GROUP_FILTER_SIZE(0))
665 return -EINVAL;
666
667 if (!access_ok(VERIFY_WRITE, koptlen, sizeof(*koptlen)) ||
668 __put_user(klen, koptlen))
669 return -EFAULT;
670
671 /* have to allow space for previous compat_alloc_user_space, too */
672 kgf = compat_alloc_user_space(klen+sizeof(*optlen));
673
674 if (!access_ok(VERIFY_READ, gf32, __COMPAT_GF0_SIZE) ||
675 __get_user(interface, &gf32->gf_interface) ||
676 __get_user(fmode, &gf32->gf_fmode) ||
677 __get_user(numsrc, &gf32->gf_numsrc) ||
678 __put_user(interface, &kgf->gf_interface) ||
679 __put_user(fmode, &kgf->gf_fmode) ||
680 __put_user(numsrc, &kgf->gf_numsrc) ||
681 copy_in_user(&kgf->gf_group,&gf32->gf_group,sizeof(kgf->gf_group)))
682 return -EFAULT;
683
684 err = getsockopt(sock, level, optname, (char __user *)kgf, koptlen);
685 if (err)
686 return err;
687
688 if (!access_ok(VERIFY_READ, koptlen, sizeof(*koptlen)) ||
689 __get_user(klen, koptlen))
690 return -EFAULT;
691
692 ulen = klen - (sizeof(*kgf)-sizeof(*gf32));
693
694 if (!access_ok(VERIFY_WRITE, optlen, sizeof(*optlen)) ||
695 __put_user(ulen, optlen))
696 return -EFAULT;
697
698 if (!access_ok(VERIFY_READ, kgf, klen) ||
699 !access_ok(VERIFY_WRITE, gf32, ulen) ||
700 __get_user(interface, &kgf->gf_interface) ||
701 __get_user(fmode, &kgf->gf_fmode) ||
702 __get_user(numsrc, &kgf->gf_numsrc) ||
703 __put_user(interface, &gf32->gf_interface) ||
704 __put_user(fmode, &gf32->gf_fmode) ||
705 __put_user(numsrc, &gf32->gf_numsrc))
706 return -EFAULT;
707 if (numsrc) {
708 int copylen;
709
710 klen -= GROUP_FILTER_SIZE(0);
711 copylen = numsrc * sizeof(gf32->gf_slist[0]);
712 if (copylen > klen)
713 copylen = klen;
714 if (copy_in_user(gf32->gf_slist, kgf->gf_slist, copylen))
715 return -EFAULT;
716 }
717 return err;
718}
719
720EXPORT_SYMBOL(compat_mc_getsockopt);
721
640 722
641/* Argument list sizes for compat_sys_socketcall */ 723/* Argument list sizes for compat_sys_socketcall */
642#define AL(x) ((x) * sizeof(u32)) 724#define AL(x) ((x) * sizeof(u32))
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index c67d00e8c600..87397351ddac 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -691,7 +691,8 @@ static void icmp_unreach(struct sk_buff *skb)
691 NIPQUAD(iph->daddr)); 691 NIPQUAD(iph->daddr));
692 } else { 692 } else {
693 info = ip_rt_frag_needed(net, iph, 693 info = ip_rt_frag_needed(net, iph,
694 ntohs(icmph->un.frag.mtu)); 694 ntohs(icmph->un.frag.mtu),
695 skb->dev);
695 if (!info) 696 if (!info)
696 goto out; 697 goto out;
697 } 698 }
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 08349267ceb4..e527628f56cf 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -753,23 +753,15 @@ static inline int ip_ufo_append_data(struct sock *sk,
753 skb->ip_summed = CHECKSUM_PARTIAL; 753 skb->ip_summed = CHECKSUM_PARTIAL;
754 skb->csum = 0; 754 skb->csum = 0;
755 sk->sk_sndmsg_off = 0; 755 sk->sk_sndmsg_off = 0;
756 }
757 756
758 err = skb_append_datato_frags(sk,skb, getfrag, from, 757 /* specify the length of each IP datagram fragment */
759 (length - transhdrlen));
760 if (!err) {
761 /* specify the length of each IP datagram fragment*/
762 skb_shinfo(skb)->gso_size = mtu - fragheaderlen; 758 skb_shinfo(skb)->gso_size = mtu - fragheaderlen;
763 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; 759 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
764 __skb_queue_tail(&sk->sk_write_queue, skb); 760 __skb_queue_tail(&sk->sk_write_queue, skb);
765
766 return 0;
767 } 761 }
768 /* There is not enough support do UFO , 762
769 * so follow normal path 763 return skb_append_datato_frags(sk, skb, getfrag, from,
770 */ 764 (length - transhdrlen));
771 kfree_skb(skb);
772 return err;
773} 765}
774 766
775/* 767/*
@@ -863,9 +855,9 @@ int ip_append_data(struct sock *sk,
863 csummode = CHECKSUM_PARTIAL; 855 csummode = CHECKSUM_PARTIAL;
864 856
865 inet->cork.length += length; 857 inet->cork.length += length;
866 if (((length > mtu) && (sk->sk_protocol == IPPROTO_UDP)) && 858 if (((length> mtu) || !skb_queue_empty(&sk->sk_write_queue)) &&
867 (rt->u.dst.dev->features & NETIF_F_UFO)) { 859 (sk->sk_protocol == IPPROTO_UDP) &&
868 860 (rt->u.dst.dev->features & NETIF_F_UFO)) {
869 err = ip_ufo_append_data(sk, getfrag, from, length, hh_len, 861 err = ip_ufo_append_data(sk, getfrag, from, length, hh_len,
870 fragheaderlen, transhdrlen, mtu, 862 fragheaderlen, transhdrlen, mtu,
871 flags); 863 flags);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 4d8d95404f45..e0514e82308e 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1186,7 +1186,14 @@ int ip_getsockopt(struct sock *sk, int level,
1186int compat_ip_getsockopt(struct sock *sk, int level, int optname, 1186int compat_ip_getsockopt(struct sock *sk, int level, int optname,
1187 char __user *optval, int __user *optlen) 1187 char __user *optval, int __user *optlen)
1188{ 1188{
1189 int err = do_ip_getsockopt(sk, level, optname, optval, optlen); 1189 int err;
1190
1191 if (optname == MCAST_MSFILTER)
1192 return compat_mc_getsockopt(sk, level, optname, optval, optlen,
1193 ip_getsockopt);
1194
1195 err = do_ip_getsockopt(sk, level, optname, optval, optlen);
1196
1190#ifdef CONFIG_NETFILTER 1197#ifdef CONFIG_NETFILTER
1191 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1198 /* we need to exclude all possible ENOPROTOOPTs except default case */
1192 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS && 1199 if (err == -ENOPROTOOPT && optname != IP_PKTOPTIONS &&
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 0f42d1c1f690..89dee4346f60 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -412,12 +412,12 @@ static struct packet_type rarp_packet_type __initdata = {
412 .func = ic_rarp_recv, 412 .func = ic_rarp_recv,
413}; 413};
414 414
415static inline void ic_rarp_init(void) 415static inline void __init ic_rarp_init(void)
416{ 416{
417 dev_add_pack(&rarp_packet_type); 417 dev_add_pack(&rarp_packet_type);
418} 418}
419 419
420static inline void ic_rarp_cleanup(void) 420static inline void __init ic_rarp_cleanup(void)
421{ 421{
422 dev_remove_pack(&rarp_packet_type); 422 dev_remove_pack(&rarp_packet_type);
423} 423}
@@ -682,7 +682,7 @@ static void __init ic_bootp_init_ext(u8 *e)
682/* 682/*
683 * Initialize the DHCP/BOOTP mechanism. 683 * Initialize the DHCP/BOOTP mechanism.
684 */ 684 */
685static inline void ic_bootp_init(void) 685static inline void __init ic_bootp_init(void)
686{ 686{
687 int i; 687 int i;
688 688
@@ -696,7 +696,7 @@ static inline void ic_bootp_init(void)
696/* 696/*
697 * DHCP/BOOTP cleanup. 697 * DHCP/BOOTP cleanup.
698 */ 698 */
699static inline void ic_bootp_cleanup(void) 699static inline void __init ic_bootp_cleanup(void)
700{ 700{
701 dev_remove_pack(&bootp_packet_type); 701 dev_remove_pack(&bootp_packet_type);
702} 702}
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c
index dde28a250d92..4b1c16cbb16b 100644
--- a/net/ipv4/ipvs/ip_vs_proto.c
+++ b/net/ipv4/ipvs/ip_vs_proto.c
@@ -148,7 +148,7 @@ const char * ip_vs_state_name(__u16 proto, int state)
148 struct ip_vs_protocol *pp = ip_vs_proto_get(proto); 148 struct ip_vs_protocol *pp = ip_vs_proto_get(proto);
149 149
150 if (pp == NULL || pp->state_name == NULL) 150 if (pp == NULL || pp->state_name == NULL)
151 return "ERR!"; 151 return (IPPROTO_IP == proto) ? "NONE" : "ERR!";
152 return pp->state_name(state); 152 return pp->state_name(state);
153} 153}
154 154
diff --git a/net/ipv4/ipvs/ip_vs_proto_ah.c b/net/ipv4/ipvs/ip_vs_proto_ah.c
index a842676e1c69..4bf835e1d86d 100644
--- a/net/ipv4/ipvs/ip_vs_proto_ah.c
+++ b/net/ipv4/ipvs/ip_vs_proto_ah.c
@@ -160,6 +160,7 @@ static void ah_exit(struct ip_vs_protocol *pp)
160struct ip_vs_protocol ip_vs_protocol_ah = { 160struct ip_vs_protocol ip_vs_protocol_ah = {
161 .name = "AH", 161 .name = "AH",
162 .protocol = IPPROTO_AH, 162 .protocol = IPPROTO_AH,
163 .num_states = 1,
163 .dont_defrag = 1, 164 .dont_defrag = 1,
164 .init = ah_init, 165 .init = ah_init,
165 .exit = ah_exit, 166 .exit = ah_exit,
diff --git a/net/ipv4/ipvs/ip_vs_proto_esp.c b/net/ipv4/ipvs/ip_vs_proto_esp.c
index aef0d3ee8e44..db6a6b7b1a0b 100644
--- a/net/ipv4/ipvs/ip_vs_proto_esp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_esp.c
@@ -159,6 +159,7 @@ static void esp_exit(struct ip_vs_protocol *pp)
159struct ip_vs_protocol ip_vs_protocol_esp = { 159struct ip_vs_protocol ip_vs_protocol_esp = {
160 .name = "ESP", 160 .name = "ESP",
161 .protocol = IPPROTO_ESP, 161 .protocol = IPPROTO_ESP,
162 .num_states = 1,
162 .dont_defrag = 1, 163 .dont_defrag = 1,
163 .init = esp_init, 164 .init = esp_init,
164 .exit = esp_exit, 165 .exit = esp_exit,
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index 620e40ff79a9..b83dc14b0a4d 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -594,6 +594,7 @@ static void ip_vs_tcp_exit(struct ip_vs_protocol *pp)
594struct ip_vs_protocol ip_vs_protocol_tcp = { 594struct ip_vs_protocol ip_vs_protocol_tcp = {
595 .name = "TCP", 595 .name = "TCP",
596 .protocol = IPPROTO_TCP, 596 .protocol = IPPROTO_TCP,
597 .num_states = IP_VS_TCP_S_LAST,
597 .dont_defrag = 0, 598 .dont_defrag = 0,
598 .appcnt = ATOMIC_INIT(0), 599 .appcnt = ATOMIC_INIT(0),
599 .init = ip_vs_tcp_init, 600 .init = ip_vs_tcp_init,
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 1caa2908373f..75771cb3cd6f 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -409,6 +409,7 @@ static void udp_exit(struct ip_vs_protocol *pp)
409struct ip_vs_protocol ip_vs_protocol_udp = { 409struct ip_vs_protocol ip_vs_protocol_udp = {
410 .name = "UDP", 410 .name = "UDP",
411 .protocol = IPPROTO_UDP, 411 .protocol = IPPROTO_UDP,
412 .num_states = IP_VS_UDP_S_LAST,
412 .dont_defrag = 0, 413 .dont_defrag = 0,
413 .init = udp_init, 414 .init = udp_init,
414 .exit = udp_exit, 415 .exit = udp_exit,
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 69c56663cc9a..eff54efe0351 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -288,11 +288,16 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
288 char *p; 288 char *p;
289 int i; 289 int i;
290 290
291 if (buflen < sizeof(struct ip_vs_sync_mesg)) {
292 IP_VS_ERR_RL("sync message header too short\n");
293 return;
294 }
295
291 /* Convert size back to host byte order */ 296 /* Convert size back to host byte order */
292 m->size = ntohs(m->size); 297 m->size = ntohs(m->size);
293 298
294 if (buflen != m->size) { 299 if (buflen != m->size) {
295 IP_VS_ERR("bogus message\n"); 300 IP_VS_ERR_RL("bogus sync message size\n");
296 return; 301 return;
297 } 302 }
298 303
@@ -307,9 +312,48 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
307 for (i=0; i<m->nr_conns; i++) { 312 for (i=0; i<m->nr_conns; i++) {
308 unsigned flags, state; 313 unsigned flags, state;
309 314
310 s = (struct ip_vs_sync_conn *)p; 315 if (p + SIMPLE_CONN_SIZE > buffer+buflen) {
316 IP_VS_ERR_RL("bogus conn in sync message\n");
317 return;
318 }
319 s = (struct ip_vs_sync_conn *) p;
311 flags = ntohs(s->flags) | IP_VS_CONN_F_SYNC; 320 flags = ntohs(s->flags) | IP_VS_CONN_F_SYNC;
321 flags &= ~IP_VS_CONN_F_HASHED;
322 if (flags & IP_VS_CONN_F_SEQ_MASK) {
323 opt = (struct ip_vs_sync_conn_options *)&s[1];
324 p += FULL_CONN_SIZE;
325 if (p > buffer+buflen) {
326 IP_VS_ERR_RL("bogus conn options in sync message\n");
327 return;
328 }
329 } else {
330 opt = NULL;
331 p += SIMPLE_CONN_SIZE;
332 }
333
312 state = ntohs(s->state); 334 state = ntohs(s->state);
335 if (!(flags & IP_VS_CONN_F_TEMPLATE)) {
336 pp = ip_vs_proto_get(s->protocol);
337 if (!pp) {
338 IP_VS_ERR_RL("Unsupported protocol %u in sync msg\n",
339 s->protocol);
340 continue;
341 }
342 if (state >= pp->num_states) {
343 IP_VS_DBG(2, "Invalid %s state %u in sync msg\n",
344 pp->name, state);
345 continue;
346 }
347 } else {
348 /* protocol in templates is not used for state/timeout */
349 pp = NULL;
350 if (state > 0) {
351 IP_VS_DBG(2, "Invalid template state %u in sync msg\n",
352 state);
353 state = 0;
354 }
355 }
356
313 if (!(flags & IP_VS_CONN_F_TEMPLATE)) 357 if (!(flags & IP_VS_CONN_F_TEMPLATE))
314 cp = ip_vs_conn_in_get(s->protocol, 358 cp = ip_vs_conn_in_get(s->protocol,
315 s->caddr, s->cport, 359 s->caddr, s->cport,
@@ -345,14 +389,9 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
345 IP_VS_ERR("ip_vs_conn_new failed\n"); 389 IP_VS_ERR("ip_vs_conn_new failed\n");
346 return; 390 return;
347 } 391 }
348 cp->state = state;
349 } else if (!cp->dest) { 392 } else if (!cp->dest) {
350 dest = ip_vs_try_bind_dest(cp); 393 dest = ip_vs_try_bind_dest(cp);
351 if (!dest) { 394 if (dest)
352 /* it is an unbound entry created by
353 * synchronization */
354 cp->flags = flags | IP_VS_CONN_F_HASHED;
355 } else
356 atomic_dec(&dest->refcnt); 395 atomic_dec(&dest->refcnt);
357 } else if ((cp->dest) && (cp->protocol == IPPROTO_TCP) && 396 } else if ((cp->dest) && (cp->protocol == IPPROTO_TCP) &&
358 (cp->state != state)) { 397 (cp->state != state)) {
@@ -371,23 +410,22 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen)
371 } 410 }
372 } 411 }
373 412
374 if (flags & IP_VS_CONN_F_SEQ_MASK) { 413 if (opt)
375 opt = (struct ip_vs_sync_conn_options *)&s[1];
376 memcpy(&cp->in_seq, opt, sizeof(*opt)); 414 memcpy(&cp->in_seq, opt, sizeof(*opt));
377 p += FULL_CONN_SIZE;
378 } else
379 p += SIMPLE_CONN_SIZE;
380
381 atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]); 415 atomic_set(&cp->in_pkts, sysctl_ip_vs_sync_threshold[0]);
382 cp->state = state; 416 cp->state = state;
383 pp = ip_vs_proto_get(s->protocol); 417 cp->old_state = cp->state;
384 cp->timeout = pp->timeout_table[cp->state]; 418 /*
419 * We can not recover the right timeout for templates
420 * in all cases, we can not find the right fwmark
421 * virtual service. If needed, we can do it for
422 * non-fwmark persistent services.
423 */
424 if (!(flags & IP_VS_CONN_F_TEMPLATE) && pp->timeout_table)
425 cp->timeout = pp->timeout_table[state];
426 else
427 cp->timeout = (3*60*HZ);
385 ip_vs_conn_put(cp); 428 ip_vs_conn_put(cp);
386
387 if (p > buffer+buflen) {
388 IP_VS_ERR("bogus message\n");
389 return;
390 }
391 } 429 }
392} 430}
393 431
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c
index 719be29f7506..26a37cedcf2e 100644
--- a/net/ipv4/netfilter/ip_queue.c
+++ b/net/ipv4/netfilter/ip_queue.c
@@ -296,9 +296,8 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
296 if (v->data_len > 0xFFFF) 296 if (v->data_len > 0xFFFF)
297 return -EINVAL; 297 return -EINVAL;
298 if (diff > skb_tailroom(e->skb)) { 298 if (diff > skb_tailroom(e->skb)) {
299 nskb = skb_copy_expand(e->skb, 0, 299 nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
300 diff - skb_tailroom(e->skb), 300 diff, GFP_ATOMIC);
301 GFP_ATOMIC);
302 if (!nskb) { 301 if (!nskb) {
303 printk(KERN_WARNING "ip_queue: error " 302 printk(KERN_WARNING "ip_queue: error "
304 "in mangle, dropping packet\n"); 303 "in mangle, dropping packet\n");
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index cacb9cb27dab..5a955c440364 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -303,7 +303,7 @@ getorigdst(struct sock *sk, int optval, void __user *user, int *len)
303 const struct nf_conntrack_tuple_hash *h; 303 const struct nf_conntrack_tuple_hash *h;
304 struct nf_conntrack_tuple tuple; 304 struct nf_conntrack_tuple tuple;
305 305
306 NF_CT_TUPLE_U_BLANK(&tuple); 306 memset(&tuple, 0, sizeof(tuple));
307 tuple.src.u3.ip = inet->rcv_saddr; 307 tuple.src.u3.ip = inet->rcv_saddr;
308 tuple.src.u.tcp.port = inet->sport; 308 tuple.src.u.tcp.port = inet->sport;
309 tuple.dst.u3.ip = inet->daddr; 309 tuple.dst.u3.ip = inet->daddr;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index ce25a13f3430..5e3685c5c407 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1430,11 +1430,13 @@ static inline unsigned short guess_mtu(unsigned short old_mtu)
1430} 1430}
1431 1431
1432unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, 1432unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1433 unsigned short new_mtu) 1433 unsigned short new_mtu,
1434 struct net_device *dev)
1434{ 1435{
1435 int i; 1436 int i, k;
1436 unsigned short old_mtu = ntohs(iph->tot_len); 1437 unsigned short old_mtu = ntohs(iph->tot_len);
1437 struct rtable *rth; 1438 struct rtable *rth;
1439 int ikeys[2] = { dev->ifindex, 0 };
1438 __be32 skeys[2] = { iph->saddr, 0, }; 1440 __be32 skeys[2] = { iph->saddr, 0, };
1439 __be32 daddr = iph->daddr; 1441 __be32 daddr = iph->daddr;
1440 unsigned short est_mtu = 0; 1442 unsigned short est_mtu = 0;
@@ -1442,22 +1444,26 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1442 if (ipv4_config.no_pmtu_disc) 1444 if (ipv4_config.no_pmtu_disc)
1443 return 0; 1445 return 0;
1444 1446
1445 for (i = 0; i < 2; i++) { 1447 for (k = 0; k < 2; k++) {
1446 unsigned hash = rt_hash(daddr, skeys[i], 0); 1448 for (i = 0; i < 2; i++) {
1449 unsigned hash = rt_hash(daddr, skeys[i], ikeys[k]);
1447 1450
1448 rcu_read_lock(); 1451 rcu_read_lock();
1449 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth; 1452 for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
1450 rth = rcu_dereference(rth->u.dst.rt_next)) { 1453 rth = rcu_dereference(rth->u.dst.rt_next)) {
1451 if (rth->fl.fl4_dst == daddr &&
1452 rth->fl.fl4_src == skeys[i] &&
1453 rth->rt_dst == daddr &&
1454 rth->rt_src == iph->saddr &&
1455 rth->fl.iif == 0 &&
1456 !(dst_metric_locked(&rth->u.dst, RTAX_MTU)) &&
1457 net_eq(dev_net(rth->u.dst.dev), net) &&
1458 rth->rt_genid == atomic_read(&rt_genid)) {
1459 unsigned short mtu = new_mtu; 1454 unsigned short mtu = new_mtu;
1460 1455
1456 if (rth->fl.fl4_dst != daddr ||
1457 rth->fl.fl4_src != skeys[i] ||
1458 rth->rt_dst != daddr ||
1459 rth->rt_src != iph->saddr ||
1460 rth->fl.oif != ikeys[k] ||
1461 rth->fl.iif != 0 ||
1462 dst_metric_locked(&rth->u.dst, RTAX_MTU) ||
1463 !net_eq(dev_net(rth->u.dst.dev), net) ||
1464 rth->rt_genid != atomic_read(&rt_genid))
1465 continue;
1466
1461 if (new_mtu < 68 || new_mtu >= old_mtu) { 1467 if (new_mtu < 68 || new_mtu >= old_mtu) {
1462 1468
1463 /* BSD 4.2 compatibility hack :-( */ 1469 /* BSD 4.2 compatibility hack :-( */
@@ -1483,8 +1489,8 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1483 est_mtu = mtu; 1489 est_mtu = mtu;
1484 } 1490 }
1485 } 1491 }
1492 rcu_read_unlock();
1486 } 1493 }
1487 rcu_read_unlock();
1488 } 1494 }
1489 return est_mtu ? : new_mtu; 1495 return est_mtu ? : new_mtu;
1490} 1496}
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 3a6be23d222f..6a250828b767 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -285,14 +285,12 @@ int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight)
285 if (in_flight >= tp->snd_cwnd) 285 if (in_flight >= tp->snd_cwnd)
286 return 1; 286 return 1;
287 287
288 if (!sk_can_gso(sk))
289 return 0;
290
291 left = tp->snd_cwnd - in_flight; 288 left = tp->snd_cwnd - in_flight;
292 if (sysctl_tcp_tso_win_divisor) 289 if (sk_can_gso(sk) &&
293 return left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd; 290 left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd &&
294 else 291 left * tp->mss_cache < sk->sk_gso_max_size)
295 return left <= tcp_max_burst(tp); 292 return 1;
293 return left <= tcp_max_burst(tp);
296} 294}
297EXPORT_SYMBOL_GPL(tcp_is_cwnd_limited); 295EXPORT_SYMBOL_GPL(tcp_is_cwnd_limited);
298 296
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index be24d6ee34bd..0e1a8c91f78e 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -229,7 +229,8 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
229 */ 229 */
230 tcp_reno_cong_avoid(sk, ack, in_flight); 230 tcp_reno_cong_avoid(sk, ack, in_flight);
231 } else { 231 } else {
232 u32 rtt, target_cwnd, diff; 232 u32 rtt, diff;
233 u64 target_cwnd;
233 234
234 /* We have enough RTT samples, so, using the Vegas 235 /* We have enough RTT samples, so, using the Vegas
235 * algorithm, we determine if we should increase or 236 * algorithm, we determine if we should increase or
@@ -252,8 +253,9 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
252 * We keep it as a fixed point number with 253 * We keep it as a fixed point number with
253 * V_PARAM_SHIFT bits to the right of the binary point. 254 * V_PARAM_SHIFT bits to the right of the binary point.
254 */ 255 */
255 target_cwnd = ((old_wnd * vegas->baseRTT) 256 target_cwnd = ((u64)old_wnd * vegas->baseRTT);
256 << V_PARAM_SHIFT) / rtt; 257 target_cwnd <<= V_PARAM_SHIFT;
258 do_div(target_cwnd, rtt);
257 259
258 /* Calculate the difference between the window we had, 260 /* Calculate the difference between the window we had,
259 * and the window we would like to have. This quantity 261 * and the window we would like to have. This quantity
@@ -279,7 +281,7 @@ static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
279 * utilization. 281 * utilization.
280 */ 282 */
281 tp->snd_cwnd = min(tp->snd_cwnd, 283 tp->snd_cwnd = min(tp->snd_cwnd,
282 (target_cwnd >> 284 ((u32)target_cwnd >>
283 V_PARAM_SHIFT)+1); 285 V_PARAM_SHIFT)+1);
284 286
285 } else if (tp->snd_cwnd <= tp->snd_ssthresh) { 287 } else if (tp->snd_cwnd <= tp->snd_ssthresh) {
diff --git a/net/ipv4/tcp_veno.c b/net/ipv4/tcp_veno.c
index d16689e98516..2bf618a3b00b 100644
--- a/net/ipv4/tcp_veno.c
+++ b/net/ipv4/tcp_veno.c
@@ -133,7 +133,8 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
133 */ 133 */
134 tcp_reno_cong_avoid(sk, ack, in_flight); 134 tcp_reno_cong_avoid(sk, ack, in_flight);
135 } else { 135 } else {
136 u32 rtt, target_cwnd; 136 u64 target_cwnd;
137 u32 rtt;
137 138
138 /* We have enough rtt samples, so, using the Veno 139 /* We have enough rtt samples, so, using the Veno
139 * algorithm, we determine the state of the network. 140 * algorithm, we determine the state of the network.
@@ -141,8 +142,9 @@ static void tcp_veno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
141 142
142 rtt = veno->minrtt; 143 rtt = veno->minrtt;
143 144
144 target_cwnd = ((tp->snd_cwnd * veno->basertt) 145 target_cwnd = (tp->snd_cwnd * veno->basertt);
145 << V_PARAM_SHIFT) / rtt; 146 target_cwnd <<= V_PARAM_SHIFT;
147 do_div(target_cwnd, rtt);
146 148
147 veno->diff = (tp->snd_cwnd << V_PARAM_SHIFT) - target_cwnd; 149 veno->diff = (tp->snd_cwnd << V_PARAM_SHIFT) - target_cwnd;
148 150
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index db6fdc1498aa..b4a26f2505f8 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -1089,6 +1089,10 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
1089 if(level != SOL_IPV6) 1089 if(level != SOL_IPV6)
1090 return -ENOPROTOOPT; 1090 return -ENOPROTOOPT;
1091 1091
1092 if (optname == MCAST_MSFILTER)
1093 return compat_mc_getsockopt(sk, level, optname, optval, optlen,
1094 ipv6_getsockopt);
1095
1092 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen); 1096 err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
1093#ifdef CONFIG_NETFILTER 1097#ifdef CONFIG_NETFILTER
1094 /* we need to exclude all possible ENOPROTOOPTs except default case */ 1098 /* we need to exclude all possible ENOPROTOOPTs except default case */
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c
index 92a36c9e5402..2eff3ae8977d 100644
--- a/net/ipv6/netfilter/ip6_queue.c
+++ b/net/ipv6/netfilter/ip6_queue.c
@@ -298,9 +298,8 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, struct nf_queue_entry *e)
298 if (v->data_len > 0xFFFF) 298 if (v->data_len > 0xFFFF)
299 return -EINVAL; 299 return -EINVAL;
300 if (diff > skb_tailroom(e->skb)) { 300 if (diff > skb_tailroom(e->skb)) {
301 nskb = skb_copy_expand(e->skb, 0, 301 nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
302 diff - skb_tailroom(e->skb), 302 diff, GFP_ATOMIC);
303 GFP_ATOMIC);
304 if (!nskb) { 303 if (!nskb) {
305 printk(KERN_WARNING "ip6_queue: OOM " 304 printk(KERN_WARNING "ip6_queue: OOM "
306 "in mangle, dropping packet\n"); 305 "in mangle, dropping packet\n");
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index d2620410cb0a..76c3057d0179 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -555,10 +555,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
555 555
556 ircomm_tty_shutdown(self); 556 ircomm_tty_shutdown(self);
557 557
558 if (tty->driver->flush_buffer) 558 tty_driver_flush_buffer(tty);
559 tty->driver->flush_buffer(tty); 559 tty_ldisc_flush(tty);
560 if (tty->ldisc.flush_buffer)
561 tty->ldisc.flush_buffer(tty);
562 560
563 tty->closing = 0; 561 tty->closing = 0;
564 self->tty = NULL; 562 self->tty = NULL;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 4eac65c74ed0..c4b1799da5d7 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -104,7 +104,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
104 const struct nf_conntrack_l3proto *l3proto, 104 const struct nf_conntrack_l3proto *l3proto,
105 const struct nf_conntrack_l4proto *l4proto) 105 const struct nf_conntrack_l4proto *l4proto)
106{ 106{
107 NF_CT_TUPLE_U_BLANK(tuple); 107 memset(tuple, 0, sizeof(*tuple));
108 108
109 tuple->src.l3num = l3num; 109 tuple->src.l3num = l3num;
110 if (l3proto->pkt_to_tuple(skb, nhoff, tuple) == 0) 110 if (l3proto->pkt_to_tuple(skb, nhoff, tuple) == 0)
@@ -151,7 +151,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
151 const struct nf_conntrack_l3proto *l3proto, 151 const struct nf_conntrack_l3proto *l3proto,
152 const struct nf_conntrack_l4proto *l4proto) 152 const struct nf_conntrack_l4proto *l4proto)
153{ 153{
154 NF_CT_TUPLE_U_BLANK(inverse); 154 memset(inverse, 0, sizeof(*inverse));
155 155
156 inverse->src.l3num = orig->src.l3num; 156 inverse->src.l3num = orig->src.l3num;
157 if (l3proto->invert_tuple(inverse, orig) == 0) 157 if (l3proto->invert_tuple(inverse, orig) == 0)
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 2c9fe5c12894..3447025ce068 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -454,9 +454,8 @@ nfqnl_mangle(void *data, int data_len, struct nf_queue_entry *e)
454 if (data_len > 0xFFFF) 454 if (data_len > 0xFFFF)
455 return -EINVAL; 455 return -EINVAL;
456 if (diff > skb_tailroom(e->skb)) { 456 if (diff > skb_tailroom(e->skb)) {
457 nskb = skb_copy_expand(e->skb, 0, 457 nskb = skb_copy_expand(e->skb, skb_headroom(e->skb),
458 diff - skb_tailroom(e->skb), 458 diff, GFP_ATOMIC);
459 GFP_ATOMIC);
460 if (!nskb) { 459 if (!nskb) {
461 printk(KERN_WARNING "nf_queue: OOM " 460 printk(KERN_WARNING "nf_queue: OOM "
462 "in mangle, dropping packet\n"); 461 "in mangle, dropping packet\n");
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index f52f7f810ac4..11b22abc2b70 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -787,7 +787,7 @@ static const struct file_operations xt_table_ops = {
787 .open = xt_table_open, 787 .open = xt_table_open,
788 .read = seq_read, 788 .read = seq_read,
789 .llseek = seq_lseek, 789 .llseek = seq_lseek,
790 .release = seq_release, 790 .release = seq_release_net,
791}; 791};
792 792
793static void *xt_match_seq_start(struct seq_file *seq, loff_t *pos) 793static void *xt_match_seq_start(struct seq_file *seq, loff_t *pos)
diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
index 3b2aa56833b9..9685b6fcbc81 100644
--- a/net/netfilter/xt_TCPOPTSTRIP.c
+++ b/net/netfilter/xt_TCPOPTSTRIP.c
@@ -90,7 +90,7 @@ tcpoptstrip_tg6(struct sk_buff *skb, const struct net_device *in,
90 const struct xt_target *target, const void *targinfo) 90 const struct xt_target *target, const void *targinfo)
91{ 91{
92 struct ipv6hdr *ipv6h = ipv6_hdr(skb); 92 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
93 unsigned int tcphoff; 93 int tcphoff;
94 u_int8_t nexthdr; 94 u_int8_t nexthdr;
95 95
96 nexthdr = ipv6h->nexthdr; 96 nexthdr = ipv6h->nexthdr;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index a20e2ef7704b..f0463d757a98 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -521,7 +521,8 @@ static void sfq_destroy(struct Qdisc *sch)
521 struct sfq_sched_data *q = qdisc_priv(sch); 521 struct sfq_sched_data *q = qdisc_priv(sch);
522 522
523 tcf_destroy_chain(q->filter_list); 523 tcf_destroy_chain(q->filter_list);
524 del_timer(&q->perturb_timer); 524 q->perturb_period = 0;
525 del_timer_sync(&q->perturb_timer);
525} 526}
526 527
527static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb) 528static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index c912137f80e2..5d20a2e24cd1 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -7,12 +7,6 @@
7 * 7 *
8 * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S 8 * Usage: nm -n vmlinux | scripts/kallsyms [--all-symbols] > symbols.S
9 * 9 *
10 * ChangeLog:
11 *
12 * (25/Aug/2004) Paulo Marques <pmarques@grupopie.com>
13 * Changed the compression method from stem compression to "table lookup"
14 * compression
15 *
16 * Table compression uses all the unused char codes on the symbols and 10 * Table compression uses all the unused char codes on the symbols and
17 * maps these to the most used substrings (tokens). For instance, it might 11 * maps these to the most used substrings (tokens). For instance, it might
18 * map char code 0xF7 to represent "write_" and then in every symbol where 12 * map char code 0xF7 to represent "write_" and then in every symbol where
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 85a220465a8f..1b50a6ebc55f 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3286,9 +3286,6 @@ static int selinux_task_kill(struct task_struct *p, struct siginfo *info,
3286 if (rc) 3286 if (rc)
3287 return rc; 3287 return rc;
3288 3288
3289 if (info != SEND_SIG_NOINFO && (is_si_special(info) || SI_FROMKERNEL(info)))
3290 return 0;
3291
3292 if (!sig) 3289 if (!sig)
3293 perm = PROCESS__SIGNULL; /* null signal; existence test */ 3290 perm = PROCESS__SIGNULL; /* null signal; existence test */
3294 else 3291 else
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index fe0ae1bf1650..b5c8f9237008 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1131,15 +1131,6 @@ static int smack_task_kill(struct task_struct *p, struct siginfo *info,
1131 int sig, u32 secid) 1131 int sig, u32 secid)
1132{ 1132{
1133 /* 1133 /*
1134 * Special cases where signals really ought to go through
1135 * in spite of policy. Stephen Smalley suggests it may
1136 * make sense to change the caller so that it doesn't
1137 * bother with the LSM hook in these cases.
1138 */
1139 if (info != SEND_SIG_NOINFO &&
1140 (is_si_special(info) || SI_FROMKERNEL(info)))
1141 return 0;
1142 /*
1143 * Sending a signal requires that the sender 1134 * Sending a signal requires that the sender
1144 * can write the receiver. 1135 * can write the receiver.
1145 */ 1136 */